aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-30 13:33:48 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-30 13:33:48 -0400
commit15dd859cacf312f606f54502d1f66537a1e5c78c (patch)
treee50e125eaa6da83fa715704e53c1bde013d1ef8e
parentb2d9d33412b9d13a40cd314d93ab517950fc5950 (diff)
parent6e86841d05f371b5b9b86ce76c02aaee83352298 (diff)
Merge commit 'v2.6.27-rc1' into x86/core
Conflicts: include/asm-x86/dma-mapping.h include/asm-x86/namei.h include/asm-x86/uaccess.h Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--Documentation/DMA-API.txt4
-rw-r--r--Documentation/Intel-IOMMU.txt4
-rw-r--r--Documentation/SubmittingPatches26
-rw-r--r--Documentation/accounting/taskstats-struct.txt2
-rw-r--r--Documentation/arm/Interrupts10
-rw-r--r--Documentation/cpu-freq/governors.txt2
-rw-r--r--Documentation/edac.txt2
-rw-r--r--Documentation/feature-removal-schedule.txt24
-rw-r--r--Documentation/filesystems/omfs.txt106
-rw-r--r--Documentation/filesystems/proc.txt4
-rw-r--r--Documentation/filesystems/relay.txt10
-rw-r--r--Documentation/filesystems/vfs.txt6
-rw-r--r--Documentation/i2c/upgrading-clients281
-rw-r--r--Documentation/ia64/kvm.txt8
-rw-r--r--Documentation/input/cs461x.txt2
-rw-r--r--Documentation/ioctl/ioctl-decoding.txt4
-rw-r--r--Documentation/iostats.txt2
-rw-r--r--Documentation/isdn/README.mISDN6
-rw-r--r--Documentation/kdump/kdump.txt20
-rw-r--r--Documentation/keys.txt2
-rw-r--r--Documentation/leds-class.txt2
-rw-r--r--Documentation/lguest/lguest.c519
-rw-r--r--Documentation/local_ops.txt2
-rw-r--r--Documentation/networking/bonding.txt2
-rw-r--r--Documentation/networking/can.txt4
-rw-r--r--Documentation/networking/packet_mmap.txt2
-rw-r--r--Documentation/networking/tc-actions-env-rules.txt15
-rw-r--r--Documentation/powerpc/booting-without-of.txt8
-rw-r--r--Documentation/powerpc/qe_firmware.txt2
-rw-r--r--Documentation/s390/driver-model.txt2
-rw-r--r--Documentation/scsi/ibmmca.txt6
-rw-r--r--Documentation/scsi/lpfc.txt2
-rw-r--r--Documentation/scsi/scsi_fc_transport.txt6
-rw-r--r--Documentation/sh/clk.txt2
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt1
-rw-r--r--Documentation/sound/alsa/Audiophile-Usb.txt10
-rw-r--r--Documentation/sound/alsa/hda_codec.txt2
-rw-r--r--Documentation/sound/alsa/soc/dapm.txt2
-rw-r--r--Documentation/sparse.txt8
-rw-r--r--Documentation/sysctl/vm.txt2
-rw-r--r--Documentation/timers/highres.txt2
-rw-r--r--Documentation/usb/authorization.txt2
-rw-r--r--Documentation/video4linux/CARDLIST.au08281
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx45
-rw-r--r--Documentation/video4linux/gspca.txt2
-rw-r--r--Documentation/video4linux/sn9c102.txt2
-rw-r--r--Documentation/vm/hugetlbpage.txt2
-rw-r--r--Documentation/vm/numa_memory_policy.txt4
-rw-r--r--Documentation/volatile-considered-harmful.txt2
-rw-r--r--Kbuild3
-rw-r--r--MAINTAINERS12
-rw-r--r--Makefile123
-rw-r--r--arch/Kconfig18
-rw-r--r--arch/alpha/kernel/osf_sys.c10
-rw-r--r--arch/alpha/mm/init.c30
-rw-r--r--arch/alpha/mm/numa.c35
-rw-r--r--arch/arm/Kconfig9
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/common/dmabounce.c2
-rw-r--r--arch/arm/common/locomo.c10
-rw-r--r--arch/arm/common/sa1111.c14
-rw-r--r--arch/arm/configs/eseries_pxa_defconfig1073
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c8
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c8
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c8
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c12
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c8
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c12
-rw-r--r--arch/arm/mach-at91/board-cam60.c2
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c8
-rw-r--r--arch/arm/mach-at91/board-dk.c2
-rw-r--r--arch/arm/mach-at91/board-kb9202.c2
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c2
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c2
-rw-r--r--[-rwxr-xr-x]arch/arm/mach-at91/board-yl-9200.c2
-rw-r--r--arch/arm/mach-at91/irq.c8
-rw-r--r--arch/arm/mach-ep93xx/core.c14
-rw-r--r--arch/arm/mach-imx/irq.c12
-rw-r--r--arch/arm/mach-ixp2000/core.c8
-rw-r--r--arch/arm/mach-ixp23xx/core.c10
-rw-r--r--arch/arm/mach-ixp23xx/roadrunner.c4
-rw-r--r--arch/arm/mach-ixp4xx/avila-pci.c8
-rw-r--r--arch/arm/mach-ixp4xx/common.c10
-rw-r--r--arch/arm/mach-ixp4xx/coyote-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-pci.c12
-rw-r--r--arch/arm/mach-ixp4xx/fsg-pci.c6
-rw-r--r--arch/arm/mach-ixp4xx/gateway7001-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/gtwx5715-pci.c8
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-pci.c8
-rw-r--r--arch/arm/mach-ixp4xx/ixdpg425-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-pci.c10
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-pci.c6
-rw-r--r--arch/arm/mach-ixp4xx/wg302v2-pci.c4
-rw-r--r--arch/arm/mach-ks8695/irq.c10
-rw-r--r--arch/arm/mach-netx/generic.c8
-rw-r--r--arch/arm/mach-omap1/board-osk.c6
-rw-r--r--arch/arm/mach-omap1/board-palmz71.c4
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c8
-rw-r--r--arch/arm/mach-omap1/fpga.c2
-rw-r--r--arch/arm/mach-omap2/board-apollon.c6
-rw-r--r--arch/arm/mach-orion5x/db88f5281-setup.c4
-rw-r--r--arch/arm/mach-orion5x/irq.c12
-rw-r--r--arch/arm/mach-orion5x/rd88f5182-setup.c4
-rw-r--r--arch/arm/mach-orion5x/ts209-setup.c4
-rw-r--r--arch/arm/mach-pnx4008/irq.c10
-rw-r--r--arch/arm/mach-pxa/cm-x270-pci.c2
-rw-r--r--arch/arm/mach-pxa/lpd270.c2
-rw-r--r--arch/arm/mach-pxa/lubbock.c2
-rw-r--r--arch/arm/mach-pxa/mainstone.c2
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c8
-rw-r--r--arch/arm/mach-pxa/trizeps4.c2
-rw-r--r--arch/arm/mach-sa1100/cerf.c2
-rw-r--r--arch/arm/mach-sa1100/h3600.c2
-rw-r--r--arch/arm/mach-sa1100/irq.c8
-rw-r--r--arch/arm/mach-sa1100/neponset.c2
-rw-r--r--arch/arm/mach-sa1100/pleb.c2
-rw-r--r--arch/arm/mm/consistent.c8
-rw-r--r--arch/arm/mm/fault-armv.c10
-rw-r--r--arch/arm/plat-mxc/gpio.c10
-rw-r--r--arch/arm/plat-omap/gpio.c28
-rw-r--r--arch/arm/plat-s3c24xx/Kconfig2
-rw-r--r--arch/arm/plat-s3c24xx/dma.c2
-rw-r--r--arch/arm/plat-s3c24xx/irq.c12
-rw-r--r--arch/avr32/boards/atstk1000/Kconfig4
-rw-r--r--arch/avr32/boards/atstk1000/Makefile1
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c97
-rw-r--r--arch/avr32/boards/atstk1000/atstk1003.c2
-rw-r--r--arch/avr32/boards/atstk1000/atstk1004.c2
-rw-r--r--arch/avr32/kernel/time.c6
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c108
-rw-r--r--arch/avr32/mach-at32ap/hsmc.c2
-rw-r--r--arch/avr32/mm/init.c39
-rw-r--r--arch/blackfin/Kconfig100
-rw-r--r--arch/blackfin/Kconfig.debug7
-rw-r--r--arch/blackfin/Makefile5
-rw-r--r--arch/blackfin/configs/BF527-EZKIT_defconfig187
-rw-r--r--arch/blackfin/configs/BF533-EZKIT_defconfig279
-rw-r--r--arch/blackfin/configs/BF533-STAMP_defconfig340
-rw-r--r--arch/blackfin/configs/BF537-STAMP_defconfig337
-rw-r--r--arch/blackfin/configs/BF548-EZKIT_defconfig65
-rw-r--r--arch/blackfin/configs/BF561-EZKIT_defconfig273
-rw-r--r--arch/blackfin/configs/CM-BF527_defconfig1185
-rw-r--r--arch/blackfin/configs/CM-BF533_defconfig14
-rw-r--r--arch/blackfin/configs/CM-BF537E_defconfig21
-rw-r--r--arch/blackfin/configs/CM-BF537U_defconfig18
-rw-r--r--arch/blackfin/configs/CM-BF548_defconfig10
-rw-r--r--arch/blackfin/configs/CM-BF561_defconfig14
-rw-r--r--arch/blackfin/configs/H8606_defconfig2
-rw-r--r--arch/blackfin/configs/IP0X_defconfig2
-rw-r--r--arch/blackfin/configs/PNAV-10_defconfig4
-rw-r--r--arch/blackfin/configs/SRV1_defconfig2
-rw-r--r--arch/blackfin/kernel/Makefile1
-rw-r--r--arch/blackfin/kernel/bfin_dma_5xx.c34
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c118
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbhdlr.S2
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbinit.c6
-rw-r--r--arch/blackfin/kernel/dualcore_test.c49
-rw-r--r--arch/blackfin/kernel/entry.S5
-rw-r--r--arch/blackfin/kernel/kgdb.c16
-rw-r--r--arch/blackfin/kernel/module.c74
-rw-r--r--arch/blackfin/kernel/ptrace.c28
-rw-r--r--arch/blackfin/kernel/setup.c90
-rw-r--r--arch/blackfin/kernel/traps.c296
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S40
-rw-r--r--arch/blackfin/mach-bf527/boards/Kconfig5
-rw-r--r--arch/blackfin/mach-bf527/boards/Makefile1
-rw-r--r--arch/blackfin/mach-bf527/boards/cm_bf527.c1011
-rw-r--r--arch/blackfin/mach-bf527/head.S12
-rw-r--r--arch/blackfin/mach-bf533/head.S12
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c88
-rw-r--r--arch/blackfin/mach-bf537/head.S12
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c44
-rw-r--r--arch/blackfin/mach-bf548/head.S6
-rw-r--r--arch/blackfin/mach-bf561/head.S6
-rw-r--r--arch/blackfin/mach-common/arch_checks.c6
-rw-r--r--arch/blackfin/mach-common/dpmc_modes.S607
-rw-r--r--arch/blackfin/mach-common/entry.S50
-rw-r--r--arch/blackfin/mach-common/ints-priority.c4
-rw-r--r--arch/blackfin/mach-common/pm.c225
-rw-r--r--arch/blackfin/mm/blackfin_sram.c543
-rw-r--r--arch/blackfin/mm/blackfin_sram.h4
-rw-r--r--arch/blackfin/mm/init.c39
-rw-r--r--arch/cris/arch-v10/kernel/kgdb.c79
-rw-r--r--arch/cris/arch-v32/drivers/Kconfig1
-rw-r--r--arch/cris/arch-v32/drivers/pci/dma.c106
-rw-r--r--arch/cris/arch-v32/kernel/kgdb.c60
-rw-r--r--arch/cris/mm/init.c30
-rw-r--r--arch/frv/kernel/gdb-stub.c88
-rw-r--r--arch/frv/mm/init.c31
-rw-r--r--arch/h8300/mm/init.c27
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c5
-rw-r--r--arch/ia64/hp/common/sba_iommu.c2
-rw-r--r--arch/ia64/kernel/perfmon.c4
-rw-r--r--arch/ia64/kvm/kvm-ia64.c5
-rw-r--r--arch/ia64/sn/pci/pci_dma.c2
-rw-r--r--arch/m32r/mm/init.c36
-rw-r--r--arch/m68k/mm/init.c30
-rw-r--r--arch/m68knommu/mm/init.c27
-rw-r--r--arch/mips/mm/Makefile3
-rw-r--r--arch/mips/mm/dma-default.c2
-rw-r--r--arch/mips/mm/pgtable.c36
-rw-r--r--arch/mn10300/kernel/gdb-stub.c108
-rw-r--r--arch/mn10300/mm/pgtable.c27
-rw-r--r--arch/parisc/hpux/sys_hpux.c10
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/kernel/entry_32.S17
-rw-r--r--arch/powerpc/kernel/entry_64.S10
-rw-r--r--arch/powerpc/kernel/legacy_serial.c44
-rw-r--r--arch/powerpc/kernel/machine_kexec.c2
-rw-r--r--arch/powerpc/kernel/process.c8
-rw-r--r--arch/powerpc/kernel/prom_init.c39
-rw-r--r--arch/powerpc/kernel/ptrace.c54
-rw-r--r--arch/powerpc/kernel/rtas_flash.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c24
-rw-r--r--arch/powerpc/kernel/setup_64.c3
-rw-r--r--arch/powerpc/kernel/signal.c23
-rw-r--r--arch/powerpc/kernel/smp.c119
-rw-r--r--arch/powerpc/kernel/stacktrace.c1
-rw-r--r--arch/powerpc/kernel/sysfs.c311
-rw-r--r--arch/powerpc/kernel/vio.c6
-rw-r--r--arch/powerpc/kvm/44x_tlb.c5
-rw-r--r--arch/powerpc/kvm/emulate.c2
-rw-r--r--arch/powerpc/mm/hugetlbpage.c18
-rw-r--r--arch/powerpc/mm/init_64.c24
-rw-r--r--arch/powerpc/mm/mem.c39
-rw-r--r--arch/powerpc/platforms/cell/celleb_scc_pciex.c2
-rw-r--r--arch/powerpc/platforms/cell/spider-pci.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c2
-rw-r--r--arch/powerpc/platforms/iseries/mf.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c72
-rw-r--r--arch/powerpc/platforms/powermac/udbg_scc.c12
-rw-r--r--arch/powerpc/platforms/pseries/cmm.c8
-rw-r--r--arch/s390/kernel/kprobes.c6
-rw-r--r--arch/s390/kvm/gaccess.h62
-rw-r--r--arch/s390/kvm/intercept.c14
-rw-r--r--arch/s390/kvm/interrupt.c21
-rw-r--r--arch/s390/kvm/kvm-s390.c9
-rw-r--r--arch/s390/kvm/sigp.c5
-rw-r--r--arch/s390/mm/init.c32
-rw-r--r--arch/sh/Kconfig35
-rw-r--r--arch/sh/Kconfig.debug3
-rw-r--r--arch/sh/Makefile4
-rw-r--r--arch/sh/boards/dreamcast/rtc.c4
-rw-r--r--arch/sh/boards/renesas/ap325rxa/Makefile1
-rw-r--r--arch/sh/boards/renesas/ap325rxa/setup.c313
-rw-r--r--arch/sh/boards/renesas/migor/Kconfig15
-rw-r--r--arch/sh/boards/renesas/migor/Makefile1
-rw-r--r--arch/sh/boards/renesas/migor/lcd_qvga.c165
-rw-r--r--arch/sh/boards/renesas/migor/setup.c276
-rw-r--r--arch/sh/boards/renesas/rsk7203/Makefile1
-rw-r--r--arch/sh/boards/renesas/rsk7203/setup.c126
-rw-r--r--arch/sh/boards/renesas/sh7763rdp/Makefile1
-rw-r--r--arch/sh/boards/renesas/sh7763rdp/irq.c45
-rw-r--r--arch/sh/boards/renesas/sh7763rdp/setup.c128
-rw-r--r--arch/sh/boards/renesas/sh7785lcr/Makefile1
-rw-r--r--arch/sh/boards/renesas/sh7785lcr/setup.c302
-rw-r--r--arch/sh/boards/se/7343/irq.c232
-rw-r--r--arch/sh/boards/se/7343/setup.c70
-rw-r--r--arch/sh/boards/se/770x/io.c59
-rw-r--r--arch/sh/boards/se/770x/setup.c53
-rw-r--r--arch/sh/boards/se/7722/setup.c8
-rw-r--r--arch/sh/boot/Makefile2
-rw-r--r--arch/sh/boot/compressed/Makefile_325
-rw-r--r--arch/sh/boot/compressed/Makefile_645
-rw-r--r--arch/sh/boot/compressed/piggy.S8
-rw-r--r--arch/sh/boot/compressed/vmlinux.scr9
-rw-r--r--arch/sh/configs/ap325rxa_defconfig947
-rw-r--r--arch/sh/configs/se7343_defconfig735
-rw-r--r--arch/sh/configs/se7712_defconfig659
-rw-r--r--arch/sh/configs/sh7763rdp_defconfig1052
-rw-r--r--arch/sh/configs/sh7785lcr_defconfig1388
-rw-r--r--arch/sh/drivers/pci/Makefile1
-rw-r--r--arch/sh/drivers/pci/fixups-sh7785lcr.c46
-rw-r--r--arch/sh/drivers/pci/ops-dreamcast.c2
-rw-r--r--arch/sh/drivers/pci/ops-sh7785lcr.c66
-rw-r--r--arch/sh/drivers/pci/pci-auto.c2
-rw-r--r--arch/sh/drivers/pci/pci.c2
-rw-r--r--arch/sh/kernel/Makefile_322
-rw-r--r--arch/sh/kernel/cf-enabler.c2
-rw-r--r--arch/sh/kernel/cpu/clock.c20
-rw-r--r--arch/sh/kernel/cpu/irq/intc.c31
-rw-r--r--arch/sh/kernel/cpu/sh2/entry.S133
-rw-r--r--arch/sh/kernel/cpu/sh2/ex.S15
-rw-r--r--arch/sh/kernel/cpu/sh2/setup-sh7619.c24
-rw-r--r--arch/sh/kernel/cpu/sh2a/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh2a/entry.S249
-rw-r--r--arch/sh/kernel/cpu/sh2a/ex.S72
-rw-r--r--arch/sh/kernel/cpu/sh3/ex.S38
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c6
-rw-r--r--arch/sh/kernel/cpu/sh4a/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7343.c99
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c221
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7343.c253
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7366.c139
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c85
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7723.c138
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7763.c21
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7780.c11
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7785.c17
-rw-r--r--arch/sh/kernel/entry-common.S2
-rw-r--r--arch/sh/kernel/machine_kexec.c2
-rw-r--r--arch/sh/kernel/process_32.c14
-rw-r--r--arch/sh/kernel/process_64.c10
-rw-r--r--arch/sh/kernel/ptrace_32.c23
-rw-r--r--arch/sh/kernel/setup.c7
-rw-r--r--arch/sh/kernel/signal_32.c36
-rw-r--r--arch/sh/kernel/syscalls_32.S6
-rw-r--r--arch/sh/kernel/syscalls_64.S6
-rw-r--r--arch/sh/kernel/time_32.c2
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c2
-rw-r--r--arch/sh/kernel/traps_32.c4
-rw-r--r--arch/sh/lib/Makefile4
-rw-r--r--arch/sh/mm/Kconfig20
-rw-r--r--arch/sh/mm/cache-debugfs.c2
-rw-r--r--arch/sh/mm/cache-sh4.c67
-rw-r--r--arch/sh/mm/consistent.c128
-rw-r--r--arch/sh/mm/fault_32.c12
-rw-r--r--arch/sh/mm/init.c41
-rw-r--r--arch/sh/mm/pg-sh4.c2
-rw-r--r--arch/sh/mm/pg-sh7705.c2
-rw-r--r--arch/sh/mm/pmb.c4
-rw-r--r--arch/sh/tools/mach-types4
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/Kbuild45
-rw-r--r--arch/sparc/include/asm/agp.h (renamed from include/asm-sparc/agp.h)0
-rw-r--r--arch/sparc/include/asm/apb.h (renamed from include/asm-sparc/apb.h)0
-rw-r--r--arch/sparc/include/asm/apc.h (renamed from include/asm-sparc/apc.h)0
-rw-r--r--arch/sparc/include/asm/asi.h (renamed from include/asm-sparc/asi.h)0
-rw-r--r--arch/sparc/include/asm/asmmacro.h (renamed from include/asm-sparc/asmmacro.h)0
-rw-r--r--arch/sparc/include/asm/atomic.h (renamed from include/asm-sparc/atomic.h)4
-rw-r--r--arch/sparc/include/asm/atomic_32.h (renamed from include/asm-sparc/atomic_32.h)0
-rw-r--r--arch/sparc/include/asm/atomic_64.h (renamed from include/asm-sparc/atomic_64.h)0
-rw-r--r--arch/sparc/include/asm/auxio.h (renamed from include/asm-sparc/auxio.h)4
-rw-r--r--arch/sparc/include/asm/auxio_32.h (renamed from include/asm-sparc/auxio_32.h)2
-rw-r--r--arch/sparc/include/asm/auxio_64.h (renamed from include/asm-sparc/auxio_64.h)0
-rw-r--r--arch/sparc/include/asm/auxvec.h (renamed from include/asm-sparc/auxvec.h)0
-rw-r--r--arch/sparc/include/asm/backoff.h (renamed from include/asm-sparc/backoff.h)0
-rw-r--r--arch/sparc/include/asm/bbc.h (renamed from include/asm-sparc/bbc.h)0
-rw-r--r--arch/sparc/include/asm/bitext.h (renamed from include/asm-sparc/bitext.h)0
-rw-r--r--arch/sparc/include/asm/bitops.h (renamed from include/asm-sparc/bitops.h)4
-rw-r--r--arch/sparc/include/asm/bitops_32.h (renamed from include/asm-sparc/bitops_32.h)0
-rw-r--r--arch/sparc/include/asm/bitops_64.h (renamed from include/asm-sparc/bitops_64.h)0
-rw-r--r--arch/sparc/include/asm/bpp.h (renamed from include/asm-sparc/bpp.h)0
-rw-r--r--arch/sparc/include/asm/btfixup.h (renamed from include/asm-sparc/btfixup.h)2
-rw-r--r--arch/sparc/include/asm/bug.h (renamed from include/asm-sparc/bug.h)0
-rw-r--r--arch/sparc/include/asm/bugs.h (renamed from include/asm-sparc/bugs.h)2
-rw-r--r--arch/sparc/include/asm/byteorder.h (renamed from include/asm-sparc/byteorder.h)0
-rw-r--r--arch/sparc/include/asm/cache.h (renamed from include/asm-sparc/cache.h)0
-rw-r--r--arch/sparc/include/asm/cacheflush.h (renamed from include/asm-sparc/cacheflush.h)4
-rw-r--r--arch/sparc/include/asm/cacheflush_32.h (renamed from include/asm-sparc/cacheflush_32.h)0
-rw-r--r--arch/sparc/include/asm/cacheflush_64.h (renamed from include/asm-sparc/cacheflush_64.h)0
-rw-r--r--arch/sparc/include/asm/chafsr.h (renamed from include/asm-sparc/chafsr.h)0
-rw-r--r--arch/sparc/include/asm/checksum.h (renamed from include/asm-sparc/checksum.h)4
-rw-r--r--arch/sparc/include/asm/checksum_32.h (renamed from include/asm-sparc/checksum_32.h)0
-rw-r--r--arch/sparc/include/asm/checksum_64.h (renamed from include/asm-sparc/checksum_64.h)0
-rw-r--r--arch/sparc/include/asm/chmctrl.h (renamed from include/asm-sparc/chmctrl.h)0
-rw-r--r--arch/sparc/include/asm/clock.h (renamed from include/asm-sparc/clock.h)0
-rw-r--r--arch/sparc/include/asm/cmt.h (renamed from include/asm-sparc/cmt.h)0
-rw-r--r--arch/sparc/include/asm/compat.h (renamed from include/asm-sparc/compat.h)0
-rw-r--r--arch/sparc/include/asm/compat_signal.h (renamed from include/asm-sparc/compat_signal.h)0
-rw-r--r--arch/sparc/include/asm/contregs.h (renamed from include/asm-sparc/contregs.h)0
-rw-r--r--arch/sparc/include/asm/cpudata.h (renamed from include/asm-sparc/cpudata.h)4
-rw-r--r--arch/sparc/include/asm/cpudata_32.h (renamed from include/asm-sparc/cpudata_32.h)2
-rw-r--r--arch/sparc/include/asm/cpudata_64.h (renamed from include/asm-sparc/cpudata_64.h)0
-rw-r--r--arch/sparc/include/asm/cputime.h (renamed from include/asm-sparc/cputime.h)0
-rw-r--r--arch/sparc/include/asm/current.h (renamed from include/asm-sparc/current.h)2
-rw-r--r--arch/sparc/include/asm/cypress.h (renamed from include/asm-sparc/cypress.h)0
-rw-r--r--arch/sparc/include/asm/dcr.h (renamed from include/asm-sparc/dcr.h)0
-rw-r--r--arch/sparc/include/asm/dcu.h (renamed from include/asm-sparc/dcu.h)0
-rw-r--r--arch/sparc/include/asm/delay.h (renamed from include/asm-sparc/delay.h)4
-rw-r--r--arch/sparc/include/asm/delay_32.h (renamed from include/asm-sparc/delay_32.h)0
-rw-r--r--arch/sparc/include/asm/delay_64.h (renamed from include/asm-sparc/delay_64.h)0
-rw-r--r--arch/sparc/include/asm/device.h (renamed from include/asm-sparc/device.h)0
-rw-r--r--arch/sparc/include/asm/display7seg.h (renamed from include/asm-sparc/display7seg.h)0
-rw-r--r--arch/sparc/include/asm/div64.h (renamed from include/asm-sparc/div64.h)0
-rw-r--r--arch/sparc/include/asm/dma-mapping.h (renamed from include/asm-sparc/dma-mapping.h)4
-rw-r--r--arch/sparc/include/asm/dma-mapping_32.h (renamed from include/asm-sparc/dma-mapping_32.h)0
-rw-r--r--arch/sparc/include/asm/dma-mapping_64.h (renamed from include/asm-sparc/dma-mapping_64.h)2
-rw-r--r--arch/sparc/include/asm/dma.h (renamed from include/asm-sparc/dma.h)4
-rw-r--r--arch/sparc/include/asm/dma_32.h (renamed from include/asm-sparc/dma_32.h)2
-rw-r--r--arch/sparc/include/asm/dma_64.h (renamed from include/asm-sparc/dma_64.h)2
-rw-r--r--arch/sparc/include/asm/ebus.h (renamed from include/asm-sparc/ebus.h)4
-rw-r--r--arch/sparc/include/asm/ebus_32.h (renamed from include/asm-sparc/ebus_32.h)0
-rw-r--r--arch/sparc/include/asm/ebus_64.h (renamed from include/asm-sparc/ebus_64.h)0
-rw-r--r--arch/sparc/include/asm/ecc.h (renamed from include/asm-sparc/ecc.h)0
-rw-r--r--arch/sparc/include/asm/eeprom.h (renamed from include/asm-sparc/eeprom.h)0
-rw-r--r--arch/sparc/include/asm/elf.h (renamed from include/asm-sparc/elf.h)4
-rw-r--r--arch/sparc/include/asm/elf_32.h (renamed from include/asm-sparc/elf_32.h)0
-rw-r--r--arch/sparc/include/asm/elf_64.h (renamed from include/asm-sparc/elf_64.h)0
-rw-r--r--arch/sparc/include/asm/emergency-restart.h (renamed from include/asm-sparc/emergency-restart.h)0
-rw-r--r--arch/sparc/include/asm/envctrl.h (renamed from include/asm-sparc/envctrl.h)0
-rw-r--r--arch/sparc/include/asm/errno.h (renamed from include/asm-sparc/errno.h)0
-rw-r--r--arch/sparc/include/asm/estate.h (renamed from include/asm-sparc/estate.h)0
-rw-r--r--arch/sparc/include/asm/fb.h (renamed from include/asm-sparc/fb.h)0
-rw-r--r--arch/sparc/include/asm/fbio.h (renamed from include/asm-sparc/fbio.h)0
-rw-r--r--arch/sparc/include/asm/fcntl.h (renamed from include/asm-sparc/fcntl.h)0
-rw-r--r--arch/sparc/include/asm/fhc.h (renamed from include/asm-sparc/fhc.h)0
-rw-r--r--arch/sparc/include/asm/fixmap.h (renamed from include/asm-sparc/fixmap.h)0
-rw-r--r--arch/sparc/include/asm/floppy.h (renamed from include/asm-sparc/floppy.h)4
-rw-r--r--arch/sparc/include/asm/floppy_32.h (renamed from include/asm-sparc/floppy_32.h)2
-rw-r--r--arch/sparc/include/asm/floppy_64.h (renamed from include/asm-sparc/floppy_64.h)0
-rw-r--r--arch/sparc/include/asm/fpumacro.h (renamed from include/asm-sparc/fpumacro.h)0
-rw-r--r--arch/sparc/include/asm/ftrace.h (renamed from include/asm-sparc64/ftrace.h)0
-rw-r--r--arch/sparc/include/asm/futex.h (renamed from include/asm-sparc/futex.h)4
-rw-r--r--arch/sparc/include/asm/futex_32.h (renamed from include/asm-sparc/futex_32.h)0
-rw-r--r--arch/sparc/include/asm/futex_64.h (renamed from include/asm-sparc/futex_64.h)0
-rw-r--r--arch/sparc/include/asm/hardirq.h (renamed from include/asm-sparc/hardirq.h)4
-rw-r--r--arch/sparc/include/asm/hardirq_32.h (renamed from include/asm-sparc/hardirq_32.h)0
-rw-r--r--arch/sparc/include/asm/hardirq_64.h (renamed from include/asm-sparc/hardirq_64.h)0
-rw-r--r--arch/sparc/include/asm/head.h (renamed from include/asm-sparc/head.h)4
-rw-r--r--arch/sparc/include/asm/head_32.h (renamed from include/asm-sparc/head_32.h)0
-rw-r--r--arch/sparc/include/asm/head_64.h (renamed from include/asm-sparc/head_64.h)0
-rw-r--r--arch/sparc/include/asm/highmem.h (renamed from include/asm-sparc/highmem.h)0
-rw-r--r--arch/sparc/include/asm/hugetlb.h (renamed from include/asm-sparc/hugetlb.h)0
-rw-r--r--arch/sparc/include/asm/hvtramp.h (renamed from include/asm-sparc/hvtramp.h)0
-rw-r--r--arch/sparc/include/asm/hw_irq.h (renamed from include/asm-sparc/hw_irq.h)0
-rw-r--r--arch/sparc/include/asm/hypervisor.h (renamed from include/asm-sparc/hypervisor.h)0
-rw-r--r--arch/sparc/include/asm/ide.h (renamed from include/asm-sparc/ide.h)0
-rw-r--r--arch/sparc/include/asm/idprom.h (renamed from include/asm-sparc/idprom.h)0
-rw-r--r--arch/sparc/include/asm/intr_queue.h (renamed from include/asm-sparc/intr_queue.h)0
-rw-r--r--arch/sparc/include/asm/io-unit.h (renamed from include/asm-sparc/io-unit.h)0
-rw-r--r--arch/sparc/include/asm/io.h (renamed from include/asm-sparc/io.h)4
-rw-r--r--arch/sparc/include/asm/io_32.h (renamed from include/asm-sparc/io_32.h)0
-rw-r--r--arch/sparc/include/asm/io_64.h (renamed from include/asm-sparc/io_64.h)0
-rw-r--r--arch/sparc/include/asm/ioctl.h (renamed from include/asm-sparc/ioctl.h)0
-rw-r--r--arch/sparc/include/asm/ioctls.h (renamed from include/asm-sparc/ioctls.h)0
-rw-r--r--arch/sparc/include/asm/iommu.h (renamed from include/asm-sparc/iommu.h)4
-rw-r--r--arch/sparc/include/asm/iommu_32.h (renamed from include/asm-sparc/iommu_32.h)0
-rw-r--r--arch/sparc/include/asm/iommu_64.h (renamed from include/asm-sparc/iommu_64.h)0
-rw-r--r--arch/sparc/include/asm/ipcbuf.h (renamed from include/asm-sparc/ipcbuf.h)4
-rw-r--r--arch/sparc/include/asm/ipcbuf_32.h (renamed from include/asm-sparc/ipcbuf_32.h)0
-rw-r--r--arch/sparc/include/asm/ipcbuf_64.h (renamed from include/asm-sparc/ipcbuf_64.h)0
-rw-r--r--arch/sparc/include/asm/irq.h (renamed from include/asm-sparc/irq.h)4
-rw-r--r--arch/sparc/include/asm/irq_32.h (renamed from include/asm-sparc/irq_32.h)0
-rw-r--r--arch/sparc/include/asm/irq_64.h (renamed from include/asm-sparc/irq_64.h)0
-rw-r--r--arch/sparc/include/asm/irq_regs.h (renamed from include/asm-sparc/irq_regs.h)0
-rw-r--r--arch/sparc/include/asm/irqflags.h (renamed from include/asm-sparc/irqflags.h)4
-rw-r--r--arch/sparc/include/asm/irqflags_32.h (renamed from include/asm-sparc/irqflags_32.h)2
-rw-r--r--arch/sparc/include/asm/irqflags_64.h (renamed from include/asm-sparc/irqflags_64.h)2
-rw-r--r--arch/sparc/include/asm/jsflash.h (renamed from include/asm-sparc/jsflash.h)0
-rw-r--r--arch/sparc/include/asm/kdebug.h (renamed from include/asm-sparc/kdebug.h)4
-rw-r--r--arch/sparc/include/asm/kdebug_32.h (renamed from include/asm-sparc/kdebug_32.h)0
-rw-r--r--arch/sparc/include/asm/kdebug_64.h (renamed from include/asm-sparc/kdebug_64.h)0
-rw-r--r--arch/sparc/include/asm/kgdb.h (renamed from include/asm-sparc/kgdb.h)0
-rw-r--r--arch/sparc/include/asm/kmap_types.h (renamed from include/asm-sparc/kmap_types.h)0
-rw-r--r--arch/sparc/include/asm/kprobes.h (renamed from include/asm-sparc/kprobes.h)0
-rw-r--r--arch/sparc/include/asm/ldc.h (renamed from include/asm-sparc/ldc.h)0
-rw-r--r--arch/sparc/include/asm/linkage.h (renamed from include/asm-sparc/linkage.h)0
-rw-r--r--arch/sparc/include/asm/lmb.h (renamed from include/asm-sparc/lmb.h)0
-rw-r--r--arch/sparc/include/asm/local.h (renamed from include/asm-sparc/local.h)0
-rw-r--r--arch/sparc/include/asm/lsu.h (renamed from include/asm-sparc/lsu.h)0
-rw-r--r--arch/sparc/include/asm/machines.h (renamed from include/asm-sparc/machines.h)0
-rw-r--r--arch/sparc/include/asm/mbus.h (renamed from include/asm-sparc/mbus.h)0
-rw-r--r--arch/sparc/include/asm/mc146818rtc.h (renamed from include/asm-sparc/mc146818rtc.h)4
-rw-r--r--arch/sparc/include/asm/mc146818rtc_32.h (renamed from include/asm-sparc/mc146818rtc_32.h)0
-rw-r--r--arch/sparc/include/asm/mc146818rtc_64.h (renamed from include/asm-sparc/mc146818rtc_64.h)0
-rw-r--r--arch/sparc/include/asm/mdesc.h (renamed from include/asm-sparc/mdesc.h)0
-rw-r--r--arch/sparc/include/asm/memreg.h (renamed from include/asm-sparc/memreg.h)0
-rw-r--r--arch/sparc/include/asm/mman.h (renamed from include/asm-sparc/mman.h)0
-rw-r--r--arch/sparc/include/asm/mmu.h (renamed from include/asm-sparc/mmu.h)4
-rw-r--r--arch/sparc/include/asm/mmu_32.h (renamed from include/asm-sparc/mmu_32.h)0
-rw-r--r--arch/sparc/include/asm/mmu_64.h (renamed from include/asm-sparc/mmu_64.h)0
-rw-r--r--arch/sparc/include/asm/mmu_context.h (renamed from include/asm-sparc/mmu_context.h)4
-rw-r--r--arch/sparc/include/asm/mmu_context_32.h (renamed from include/asm-sparc/mmu_context_32.h)0
-rw-r--r--arch/sparc/include/asm/mmu_context_64.h (renamed from include/asm-sparc/mmu_context_64.h)0
-rw-r--r--arch/sparc/include/asm/mmzone.h (renamed from include/asm-sparc/mmzone.h)0
-rw-r--r--arch/sparc/include/asm/module.h (renamed from include/asm-sparc/module.h)4
-rw-r--r--arch/sparc/include/asm/module_32.h (renamed from include/asm-sparc/module_32.h)0
-rw-r--r--arch/sparc/include/asm/module_64.h (renamed from include/asm-sparc/module_64.h)0
-rw-r--r--arch/sparc/include/asm/mostek.h (renamed from include/asm-sparc/mostek.h)4
-rw-r--r--arch/sparc/include/asm/mostek_32.h (renamed from include/asm-sparc/mostek_32.h)0
-rw-r--r--arch/sparc/include/asm/mostek_64.h (renamed from include/asm-sparc/mostek_64.h)0
-rw-r--r--arch/sparc/include/asm/mpmbox.h (renamed from include/asm-sparc/mpmbox.h)0
-rw-r--r--arch/sparc/include/asm/msgbuf.h (renamed from include/asm-sparc/msgbuf.h)0
-rw-r--r--arch/sparc/include/asm/msi.h (renamed from include/asm-sparc/msi.h)0
-rw-r--r--arch/sparc/include/asm/mutex.h (renamed from include/asm-sparc/mutex.h)0
-rw-r--r--arch/sparc/include/asm/mxcc.h (renamed from include/asm-sparc/mxcc.h)0
-rw-r--r--arch/sparc/include/asm/ns87303.h (renamed from include/asm-sparc/ns87303.h)0
-rw-r--r--arch/sparc/include/asm/obio.h (renamed from include/asm-sparc/obio.h)0
-rw-r--r--arch/sparc/include/asm/of_device.h (renamed from include/asm-sparc/of_device.h)0
-rw-r--r--arch/sparc/include/asm/of_platform.h (renamed from include/asm-sparc/of_platform.h)4
-rw-r--r--arch/sparc/include/asm/of_platform_32.h (renamed from include/asm-sparc/of_platform_32.h)2
-rw-r--r--arch/sparc/include/asm/of_platform_64.h (renamed from include/asm-sparc/of_platform_64.h)2
-rw-r--r--arch/sparc/include/asm/openprom.h (renamed from include/asm-sparc/openprom.h)4
-rw-r--r--arch/sparc/include/asm/openprom_32.h (renamed from include/asm-sparc/openprom_32.h)0
-rw-r--r--arch/sparc/include/asm/openprom_64.h (renamed from include/asm-sparc/openprom_64.h)0
-rw-r--r--arch/sparc/include/asm/openpromio.h (renamed from include/asm-sparc/openpromio.h)0
-rw-r--r--arch/sparc/include/asm/oplib.h (renamed from include/asm-sparc/oplib.h)4
-rw-r--r--arch/sparc/include/asm/oplib_32.h (renamed from include/asm-sparc/oplib_32.h)0
-rw-r--r--arch/sparc/include/asm/oplib_64.h (renamed from include/asm-sparc/oplib_64.h)0
-rw-r--r--arch/sparc/include/asm/page.h (renamed from include/asm-sparc/page.h)4
-rw-r--r--arch/sparc/include/asm/page_32.h (renamed from include/asm-sparc/page_32.h)0
-rw-r--r--arch/sparc/include/asm/page_64.h (renamed from include/asm-sparc/page_64.h)0
-rw-r--r--arch/sparc/include/asm/param.h (renamed from include/asm-sparc/param.h)0
-rw-r--r--arch/sparc/include/asm/parport.h (renamed from include/asm-sparc/parport.h)0
-rw-r--r--arch/sparc/include/asm/pbm.h (renamed from include/asm-sparc/pbm.h)0
-rw-r--r--arch/sparc/include/asm/pci.h (renamed from include/asm-sparc/pci.h)4
-rw-r--r--arch/sparc/include/asm/pci_32.h (renamed from include/asm-sparc/pci_32.h)3
-rw-r--r--arch/sparc/include/asm/pci_64.h (renamed from include/asm-sparc/pci_64.h)5
-rw-r--r--arch/sparc/include/asm/pcic.h (renamed from include/asm-sparc/pcic.h)0
-rw-r--r--arch/sparc/include/asm/percpu.h (renamed from include/asm-sparc/percpu.h)4
-rw-r--r--arch/sparc/include/asm/percpu_32.h (renamed from include/asm-sparc/percpu_32.h)0
-rw-r--r--arch/sparc/include/asm/percpu_64.h (renamed from include/asm-sparc/percpu_64.h)0
-rw-r--r--arch/sparc/include/asm/perfctr.h (renamed from include/asm-sparc/perfctr.h)0
-rw-r--r--arch/sparc/include/asm/pgalloc.h (renamed from include/asm-sparc/pgalloc.h)4
-rw-r--r--arch/sparc/include/asm/pgalloc_32.h (renamed from include/asm-sparc/pgalloc_32.h)0
-rw-r--r--arch/sparc/include/asm/pgalloc_64.h (renamed from include/asm-sparc/pgalloc_64.h)0
-rw-r--r--arch/sparc/include/asm/pgtable.h (renamed from include/asm-sparc/pgtable.h)4
-rw-r--r--arch/sparc/include/asm/pgtable_32.h (renamed from include/asm-sparc/pgtable_32.h)2
-rw-r--r--arch/sparc/include/asm/pgtable_64.h (renamed from include/asm-sparc/pgtable_64.h)0
-rw-r--r--arch/sparc/include/asm/pgtsrmmu.h (renamed from include/asm-sparc/pgtsrmmu.h)0
-rw-r--r--arch/sparc/include/asm/pgtsun4.h (renamed from include/asm-sparc/pgtsun4.h)0
-rw-r--r--arch/sparc/include/asm/pgtsun4c.h (renamed from include/asm-sparc/pgtsun4c.h)0
-rw-r--r--arch/sparc/include/asm/pil.h (renamed from include/asm-sparc/pil.h)0
-rw-r--r--arch/sparc/include/asm/poll.h (renamed from include/asm-sparc/poll.h)0
-rw-r--r--arch/sparc/include/asm/posix_types.h (renamed from include/asm-sparc/posix_types.h)4
-rw-r--r--arch/sparc/include/asm/posix_types_32.h (renamed from include/asm-sparc/posix_types_32.h)0
-rw-r--r--arch/sparc/include/asm/posix_types_64.h (renamed from include/asm-sparc/posix_types_64.h)0
-rw-r--r--arch/sparc/include/asm/processor.h (renamed from include/asm-sparc/processor.h)4
-rw-r--r--arch/sparc/include/asm/processor_32.h (renamed from include/asm-sparc/processor_32.h)3
-rw-r--r--arch/sparc/include/asm/processor_64.h (renamed from include/asm-sparc/processor_64.h)2
-rw-r--r--arch/sparc/include/asm/prom.h (renamed from include/asm-sparc/prom.h)0
-rw-r--r--arch/sparc/include/asm/psr.h (renamed from include/asm-sparc/psr.h)0
-rw-r--r--arch/sparc/include/asm/psrcompat.h (renamed from include/asm-sparc/psrcompat.h)0
-rw-r--r--arch/sparc/include/asm/pstate.h (renamed from include/asm-sparc/pstate.h)0
-rw-r--r--arch/sparc/include/asm/ptrace.h (renamed from include/asm-sparc/ptrace.h)4
-rw-r--r--arch/sparc/include/asm/ptrace_32.h (renamed from include/asm-sparc/ptrace_32.h)1
-rw-r--r--arch/sparc/include/asm/ptrace_64.h (renamed from include/asm-sparc/ptrace_64.h)1
-rw-r--r--arch/sparc/include/asm/reboot.h (renamed from include/asm-sparc/reboot.h)0
-rw-r--r--arch/sparc/include/asm/reg.h (renamed from include/asm-sparc/reg.h)4
-rw-r--r--arch/sparc/include/asm/reg_32.h (renamed from include/asm-sparc/reg_32.h)2
-rw-r--r--arch/sparc/include/asm/reg_64.h (renamed from include/asm-sparc/reg_64.h)2
-rw-r--r--arch/sparc/include/asm/resource.h (renamed from include/asm-sparc/resource.h)0
-rw-r--r--arch/sparc/include/asm/ross.h (renamed from include/asm-sparc/ross.h)0
-rw-r--r--arch/sparc/include/asm/rtc.h (renamed from include/asm-sparc/rtc.h)0
-rw-r--r--arch/sparc/include/asm/rwsem-const.h (renamed from include/asm-sparc/rwsem-const.h)0
-rw-r--r--arch/sparc/include/asm/rwsem.h (renamed from include/asm-sparc/rwsem.h)0
-rw-r--r--arch/sparc/include/asm/sbi.h (renamed from include/asm-sparc/sbi.h)0
-rw-r--r--arch/sparc/include/asm/sbus.h (renamed from include/asm-sparc/sbus.h)4
-rw-r--r--arch/sparc/include/asm/sbus_32.h (renamed from include/asm-sparc/sbus_32.h)0
-rw-r--r--arch/sparc/include/asm/sbus_64.h (renamed from include/asm-sparc/sbus_64.h)0
-rw-r--r--arch/sparc/include/asm/scatterlist.h (renamed from include/asm-sparc/scatterlist.h)4
-rw-r--r--arch/sparc/include/asm/scatterlist_32.h (renamed from include/asm-sparc/scatterlist_32.h)0
-rw-r--r--arch/sparc/include/asm/scatterlist_64.h (renamed from include/asm-sparc/scatterlist_64.h)0
-rw-r--r--arch/sparc/include/asm/scratchpad.h (renamed from include/asm-sparc/scratchpad.h)0
-rw-r--r--arch/sparc/include/asm/seccomp.h (renamed from include/asm-sparc/seccomp.h)0
-rw-r--r--arch/sparc/include/asm/sections.h (renamed from include/asm-sparc/sections.h)4
-rw-r--r--arch/sparc/include/asm/sections_32.h (renamed from include/asm-sparc/sections_32.h)0
-rw-r--r--arch/sparc/include/asm/sections_64.h (renamed from include/asm-sparc/sections_64.h)0
-rw-r--r--arch/sparc/include/asm/sembuf.h (renamed from include/asm-sparc/sembuf.h)0
-rw-r--r--arch/sparc/include/asm/setup.h (renamed from include/asm-sparc/setup.h)0
-rw-r--r--arch/sparc/include/asm/sfafsr.h (renamed from include/asm-sparc/sfafsr.h)0
-rw-r--r--arch/sparc/include/asm/sfp-machine.h (renamed from include/asm-sparc/sfp-machine.h)4
-rw-r--r--arch/sparc/include/asm/sfp-machine_32.h (renamed from include/asm-sparc/sfp-machine_32.h)0
-rw-r--r--arch/sparc/include/asm/sfp-machine_64.h (renamed from include/asm-sparc/sfp-machine_64.h)0
-rw-r--r--arch/sparc/include/asm/shmbuf.h (renamed from include/asm-sparc/shmbuf.h)0
-rw-r--r--arch/sparc/include/asm/shmparam.h (renamed from include/asm-sparc/shmparam.h)4
-rw-r--r--arch/sparc/include/asm/shmparam_32.h (renamed from include/asm-sparc/shmparam_32.h)0
-rw-r--r--arch/sparc/include/asm/shmparam_64.h (renamed from include/asm-sparc/shmparam_64.h)0
-rw-r--r--arch/sparc/include/asm/sigcontext.h (renamed from include/asm-sparc/sigcontext.h)4
-rw-r--r--arch/sparc/include/asm/sigcontext_32.h (renamed from include/asm-sparc/sigcontext_32.h)0
-rw-r--r--arch/sparc/include/asm/sigcontext_64.h (renamed from include/asm-sparc/sigcontext_64.h)0
-rw-r--r--arch/sparc/include/asm/siginfo.h (renamed from include/asm-sparc/siginfo.h)4
-rw-r--r--arch/sparc/include/asm/siginfo_32.h (renamed from include/asm-sparc/siginfo_32.h)0
-rw-r--r--arch/sparc/include/asm/siginfo_64.h (renamed from include/asm-sparc/siginfo_64.h)0
-rw-r--r--arch/sparc/include/asm/signal.h (renamed from include/asm-sparc/signal.h)4
-rw-r--r--arch/sparc/include/asm/signal_32.h (renamed from include/asm-sparc/signal_32.h)0
-rw-r--r--arch/sparc/include/asm/signal_64.h (renamed from include/asm-sparc/signal_64.h)0
-rw-r--r--arch/sparc/include/asm/smp.h (renamed from include/asm-sparc/smp.h)4
-rw-r--r--arch/sparc/include/asm/smp_32.h (renamed from include/asm-sparc/smp_32.h)0
-rw-r--r--arch/sparc/include/asm/smp_64.h (renamed from include/asm-sparc/smp_64.h)0
-rw-r--r--arch/sparc/include/asm/smpprim.h (renamed from include/asm-sparc/smpprim.h)0
-rw-r--r--arch/sparc/include/asm/socket.h (renamed from include/asm-sparc/socket.h)0
-rw-r--r--arch/sparc/include/asm/sockios.h (renamed from include/asm-sparc/sockios.h)0
-rw-r--r--arch/sparc/include/asm/sparsemem.h (renamed from include/asm-sparc/sparsemem.h)0
-rw-r--r--arch/sparc/include/asm/spinlock.h (renamed from include/asm-sparc/spinlock.h)4
-rw-r--r--arch/sparc/include/asm/spinlock_32.h (renamed from include/asm-sparc/spinlock_32.h)0
-rw-r--r--arch/sparc/include/asm/spinlock_64.h (renamed from include/asm-sparc/spinlock_64.h)0
-rw-r--r--arch/sparc/include/asm/spinlock_types.h (renamed from include/asm-sparc/spinlock_types.h)0
-rw-r--r--arch/sparc/include/asm/spitfire.h (renamed from include/asm-sparc/spitfire.h)0
-rw-r--r--arch/sparc/include/asm/sstate.h (renamed from include/asm-sparc/sstate.h)0
-rw-r--r--arch/sparc/include/asm/stacktrace.h (renamed from include/asm-sparc/stacktrace.h)0
-rw-r--r--arch/sparc/include/asm/starfire.h (renamed from include/asm-sparc/starfire.h)0
-rw-r--r--arch/sparc/include/asm/stat.h (renamed from include/asm-sparc/stat.h)4
-rw-r--r--arch/sparc/include/asm/stat_32.h (renamed from include/asm-sparc/stat_32.h)0
-rw-r--r--arch/sparc/include/asm/stat_64.h (renamed from include/asm-sparc/stat_64.h)0
-rw-r--r--arch/sparc/include/asm/statfs.h (renamed from include/asm-sparc/statfs.h)4
-rw-r--r--arch/sparc/include/asm/statfs_32.h (renamed from include/asm-sparc/statfs_32.h)0
-rw-r--r--arch/sparc/include/asm/statfs_64.h (renamed from include/asm-sparc/statfs_64.h)0
-rw-r--r--arch/sparc/include/asm/string.h (renamed from include/asm-sparc/string.h)4
-rw-r--r--arch/sparc/include/asm/string_32.h (renamed from include/asm-sparc/string_32.h)0
-rw-r--r--arch/sparc/include/asm/string_64.h (renamed from include/asm-sparc/string_64.h)0
-rw-r--r--arch/sparc/include/asm/sun4paddr.h (renamed from include/asm-sparc/sun4paddr.h)0
-rw-r--r--arch/sparc/include/asm/sun4prom.h (renamed from include/asm-sparc/sun4prom.h)0
-rw-r--r--arch/sparc/include/asm/sunbpp.h (renamed from include/asm-sparc/sunbpp.h)2
-rw-r--r--arch/sparc/include/asm/swift.h (renamed from include/asm-sparc/swift.h)0
-rw-r--r--arch/sparc/include/asm/syscall.h120
-rw-r--r--arch/sparc/include/asm/syscalls.h (renamed from include/asm-sparc/syscalls.h)0
-rw-r--r--arch/sparc/include/asm/sysen.h (renamed from include/asm-sparc/sysen.h)0
-rw-r--r--arch/sparc/include/asm/system.h (renamed from include/asm-sparc/system.h)4
-rw-r--r--arch/sparc/include/asm/system_32.h (renamed from include/asm-sparc/system_32.h)0
-rw-r--r--arch/sparc/include/asm/system_64.h (renamed from include/asm-sparc/system_64.h)0
-rw-r--r--arch/sparc/include/asm/termbits.h (renamed from include/asm-sparc/termbits.h)0
-rw-r--r--arch/sparc/include/asm/termios.h (renamed from include/asm-sparc/termios.h)0
-rw-r--r--arch/sparc/include/asm/thread_info.h (renamed from include/asm-sparc/thread_info.h)4
-rw-r--r--arch/sparc/include/asm/thread_info_32.h (renamed from include/asm-sparc/thread_info_32.h)7
-rw-r--r--arch/sparc/include/asm/thread_info_64.h (renamed from include/asm-sparc/thread_info_64.h)8
-rw-r--r--arch/sparc/include/asm/timer.h (renamed from include/asm-sparc/timer.h)4
-rw-r--r--arch/sparc/include/asm/timer_32.h (renamed from include/asm-sparc/timer_32.h)0
-rw-r--r--arch/sparc/include/asm/timer_64.h (renamed from include/asm-sparc/timer_64.h)0
-rw-r--r--arch/sparc/include/asm/timex.h (renamed from include/asm-sparc/timex.h)4
-rw-r--r--arch/sparc/include/asm/timex_32.h (renamed from include/asm-sparc/timex_32.h)2
-rw-r--r--arch/sparc/include/asm/timex_64.h (renamed from include/asm-sparc/timex_64.h)2
-rw-r--r--arch/sparc/include/asm/tlb.h (renamed from include/asm-sparc/tlb.h)4
-rw-r--r--arch/sparc/include/asm/tlb_32.h (renamed from include/asm-sparc/tlb_32.h)0
-rw-r--r--arch/sparc/include/asm/tlb_64.h (renamed from include/asm-sparc/tlb_64.h)0
-rw-r--r--arch/sparc/include/asm/tlbflush.h (renamed from include/asm-sparc/tlbflush.h)4
-rw-r--r--arch/sparc/include/asm/tlbflush_32.h (renamed from include/asm-sparc/tlbflush_32.h)0
-rw-r--r--arch/sparc/include/asm/tlbflush_64.h (renamed from include/asm-sparc/tlbflush_64.h)0
-rw-r--r--arch/sparc/include/asm/topology.h (renamed from include/asm-sparc/topology.h)4
-rw-r--r--arch/sparc/include/asm/topology_32.h (renamed from include/asm-sparc/topology_32.h)0
-rw-r--r--arch/sparc/include/asm/topology_64.h (renamed from include/asm-sparc/topology_64.h)0
-rw-r--r--arch/sparc/include/asm/traps.h (renamed from include/asm-sparc/traps.h)0
-rw-r--r--arch/sparc/include/asm/tsb.h (renamed from include/asm-sparc/tsb.h)0
-rw-r--r--arch/sparc/include/asm/tsunami.h (renamed from include/asm-sparc/tsunami.h)0
-rw-r--r--arch/sparc/include/asm/ttable.h (renamed from include/asm-sparc/ttable.h)0
-rw-r--r--arch/sparc/include/asm/turbosparc.h (renamed from include/asm-sparc/turbosparc.h)0
-rw-r--r--arch/sparc/include/asm/types.h (renamed from include/asm-sparc/types.h)0
-rw-r--r--arch/sparc/include/asm/uaccess.h (renamed from include/asm-sparc/uaccess.h)4
-rw-r--r--arch/sparc/include/asm/uaccess_32.h (renamed from include/asm-sparc/uaccess_32.h)0
-rw-r--r--arch/sparc/include/asm/uaccess_64.h (renamed from include/asm-sparc/uaccess_64.h)0
-rw-r--r--arch/sparc/include/asm/uctx.h (renamed from include/asm-sparc/uctx.h)0
-rw-r--r--arch/sparc/include/asm/unaligned.h (renamed from include/asm-sparc/unaligned.h)0
-rw-r--r--arch/sparc/include/asm/unistd.h (renamed from include/asm-sparc/unistd.h)4
-rw-r--r--arch/sparc/include/asm/unistd_32.h (renamed from include/asm-sparc/unistd_32.h)0
-rw-r--r--arch/sparc/include/asm/unistd_64.h (renamed from include/asm-sparc/unistd_64.h)0
-rw-r--r--arch/sparc/include/asm/upa.h (renamed from include/asm-sparc/upa.h)0
-rw-r--r--arch/sparc/include/asm/user.h (renamed from include/asm-sparc/user.h)0
-rw-r--r--arch/sparc/include/asm/utrap.h (renamed from include/asm-sparc/utrap.h)2
-rw-r--r--arch/sparc/include/asm/vac-ops.h (renamed from include/asm-sparc/vac-ops.h)0
-rw-r--r--arch/sparc/include/asm/vaddrs.h (renamed from include/asm-sparc/vaddrs.h)2
-rw-r--r--arch/sparc/include/asm/vfc_ioctls.h (renamed from include/asm-sparc/vfc_ioctls.h)0
-rw-r--r--arch/sparc/include/asm/vga.h (renamed from include/asm-sparc/vga.h)0
-rw-r--r--arch/sparc/include/asm/viking.h (renamed from include/asm-sparc/viking.h)0
-rw-r--r--arch/sparc/include/asm/vio.h (renamed from include/asm-sparc/vio.h)0
-rw-r--r--arch/sparc/include/asm/visasm.h (renamed from include/asm-sparc/visasm.h)0
-rw-r--r--arch/sparc/include/asm/watchdog.h (renamed from include/asm-sparc/watchdog.h)0
-rw-r--r--arch/sparc/include/asm/winmacro.h (renamed from include/asm-sparc/winmacro.h)0
-rw-r--r--arch/sparc/include/asm/xor.h (renamed from include/asm-sparc/xor.h)4
-rw-r--r--arch/sparc/include/asm/xor_32.h (renamed from include/asm-sparc/xor_32.h)2
-rw-r--r--arch/sparc/include/asm/xor_64.h (renamed from include/asm-sparc/xor_64.h)2
-rw-r--r--arch/sparc/kernel/entry.S12
-rw-r--r--arch/sparc/kernel/ptrace.c26
-rw-r--r--arch/sparc/kernel/rtrap.S5
-rw-r--r--arch/sparc/kernel/signal.c16
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--arch/sparc64/kernel/compat_audit.c2
-rw-r--r--arch/sparc64/kernel/entry.h3
-rw-r--r--arch/sparc64/kernel/ptrace.c32
-rw-r--r--arch/sparc64/kernel/rtrap.S6
-rw-r--r--arch/sparc64/kernel/signal.c8
-rw-r--r--arch/sparc64/kernel/signal32.c3
-rw-r--r--arch/sparc64/kernel/syscalls.S4
-rw-r--r--arch/sparc64/mm/init.c45
-rw-r--r--arch/um/kernel/mem.c31
-rw-r--r--arch/x86/Kconfig10
-rw-r--r--arch/x86/ia32/ia32_aout.c6
-rw-r--r--arch/x86/kernel/acpi/cstate.c3
-rw-r--r--arch/x86/kernel/amd_iommu.c13
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c10
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.c15
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c12
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-ich.c3
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c3
-rw-r--r--arch/x86/kernel/head_32.S8
-rw-r--r--arch/x86/kernel/ldt.c6
-rw-r--r--arch/x86/kernel/machine_kexec_32.c39
-rw-r--r--arch/x86/kernel/machine_kexec_64.c2
-rw-r--r--arch/x86/kernel/microcode.c17
-rw-r--r--arch/x86/kernel/pci-calgary_64.c73
-rw-r--r--arch/x86/kernel/pci-dma.c149
-rw-r--r--arch/x86/kernel/pci-gart_64.c14
-rw-r--r--arch/x86/kernel/pci-nommu.c14
-rw-r--r--arch/x86/kernel/pci-swiotlb_64.c2
-rw-r--r--arch/x86/kernel/reboot.c11
-rw-r--r--arch/x86/kernel/relocate_kernel_32.S174
-rw-r--r--arch/x86/kernel/setup_percpu.c21
-rw-r--r--arch/x86/kvm/Kconfig1
-rw-r--r--arch/x86/kvm/mmu.c7
-rw-r--r--arch/x86/kvm/svm.c10
-rw-r--r--arch/x86/kvm/vmx.c22
-rw-r--r--arch/x86/kvm/x86.c109
-rw-r--r--arch/x86/lguest/boot.c3
-rw-r--r--arch/x86/mm/Makefile1
-rw-r--r--arch/x86/mm/gup.c298
-rw-r--r--arch/x86/mm/init_64.c37
-rw-r--r--arch/x86/mm/pgtable_32.c47
-rw-r--r--arch/x86/pci/fixup.c3
-rw-r--r--arch/x86/pci/i386.c26
-rw-r--r--arch/x86/pci/irq.c106
-rw-r--r--arch/x86/pci/numaq_32.c5
-rw-r--r--arch/xtensa/mm/init.c29
-rw-r--r--block/as-iosched.c3
-rw-r--r--block/blk-map.c8
-rw-r--r--drivers/acpi/pci_slot.c18
-rw-r--r--drivers/acpi/processor_idle.c21
-rw-r--r--drivers/acpi/processor_throttling.c11
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/base/core.c6
-rw-r--r--drivers/base/isa.c4
-rw-r--r--drivers/base/memory.c6
-rw-r--r--drivers/base/sys.c12
-rw-r--r--drivers/char/dsp56k.c4
-rw-r--r--drivers/char/hw_random/intel-rng.c6
-rw-r--r--drivers/char/nwflash.c6
-rw-r--r--drivers/char/pcmcia/ipwireless/hardware.c275
-rw-r--r--drivers/char/pcmcia/ipwireless/hardware.h4
-rw-r--r--drivers/char/pcmcia/ipwireless/main.c86
-rw-r--r--drivers/char/pcmcia/ipwireless/main.h5
-rw-r--r--drivers/char/pcmcia/ipwireless/network.c58
-rw-r--r--drivers/char/pcmcia/ipwireless/network.h1
-rw-r--r--drivers/char/pcmcia/ipwireless/tty.c2
-rw-r--r--drivers/char/rtc.c5
-rw-r--r--drivers/char/ser_a2232.c52
-rw-r--r--drivers/char/tpm/tpm.c128
-rw-r--r--drivers/char/tpm/tpm_bios.c4
-rw-r--r--drivers/char/tpm/tpm_tis.c1
-rw-r--r--drivers/char/vme_scc.c59
-rw-r--r--drivers/cpuidle/cpuidle.c2
-rw-r--r--drivers/crypto/talitos.c49
-rw-r--r--drivers/firewire/Kconfig9
-rw-r--r--drivers/firewire/fw-card.c2
-rw-r--r--drivers/firewire/fw-cdev.c6
-rw-r--r--drivers/firewire/fw-iso.c2
-rw-r--r--drivers/firewire/fw-ohci.c39
-rw-r--r--drivers/firewire/fw-sbp2.c8
-rw-r--r--drivers/firewire/fw-topology.c2
-rw-r--r--drivers/firewire/fw-transaction.c79
-rw-r--r--drivers/firmware/dcdbas.c3
-rw-r--r--drivers/firmware/memmap.c6
-rw-r--r--drivers/gpu/drm/drm_drv.c2
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c35
-rw-r--r--drivers/i2c/busses/i2c-gpio.c9
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c129
-rw-r--r--drivers/infiniband/core/ucm.c10
-rw-r--r--drivers/infiniband/core/ucma.c11
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sdma.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_sdma.c6
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c1
-rw-r--r--drivers/infiniband/hw/mlx4/main.c1
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h1
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c1
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c1
-rw-r--r--drivers/infiniband/hw/mlx4/srq.c1
-rw-r--r--drivers/infiniband/hw/mlx4/user.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.c4
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c2034
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.h23
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c9
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c15
-rw-r--r--drivers/infiniband/ulp/ipoib/Kconfig22
-rw-r--r--drivers/input/keyboard/sh_keysc.c27
-rw-r--r--drivers/input/misc/uinput.c1
-rw-r--r--drivers/input/serio/serio.c55
-rw-r--r--drivers/input/touchscreen/Kconfig12
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/ads7846.c16
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c332
-rw-r--r--drivers/input/touchscreen/corgi_ts.c8
-rw-r--r--drivers/input/touchscreen/mainstone-wm97xx.c2
-rw-r--r--drivers/isdn/Kconfig4
-rw-r--r--drivers/isdn/Makefile1
-rw-r--r--drivers/isdn/hardware/Makefile1
-rw-r--r--drivers/isdn/hardware/mISDN/Kconfig25
-rw-r--r--drivers/isdn/hardware/mISDN/Makefile7
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_multi.h1204
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_pci.h228
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c5320
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c2255
-rw-r--r--drivers/isdn/hisax/hisax_fcpcipnp.c2
-rw-r--r--drivers/isdn/mISDN/Kconfig44
-rw-r--r--drivers/isdn/mISDN/Makefile13
-rw-r--r--drivers/isdn/mISDN/core.c244
-rw-r--r--drivers/isdn/mISDN/core.h77
-rw-r--r--drivers/isdn/mISDN/dsp.h263
-rw-r--r--drivers/isdn/mISDN/dsp_audio.c434
-rw-r--r--drivers/isdn/mISDN/dsp_biquad.h65
-rw-r--r--drivers/isdn/mISDN/dsp_blowfish.c672
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c1886
-rw-r--r--drivers/isdn/mISDN/dsp_core.c1191
-rw-r--r--drivers/isdn/mISDN/dsp_dtmf.c303
-rw-r--r--drivers/isdn/mISDN/dsp_ecdis.h110
-rw-r--r--drivers/isdn/mISDN/dsp_hwec.c138
-rw-r--r--drivers/isdn/mISDN/dsp_hwec.h10
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c348
-rw-r--r--drivers/isdn/mISDN/dsp_tones.c551
-rw-r--r--drivers/isdn/mISDN/fsm.c183
-rw-r--r--drivers/isdn/mISDN/fsm.h67
-rw-r--r--drivers/isdn/mISDN/hwchannel.c365
-rw-r--r--drivers/isdn/mISDN/l1oip.h91
-rw-r--r--drivers/isdn/mISDN/l1oip_codec.c374
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c1518
-rw-r--r--drivers/isdn/mISDN/layer1.c403
-rw-r--r--drivers/isdn/mISDN/layer1.h26
-rw-r--r--drivers/isdn/mISDN/layer2.c2216
-rw-r--r--drivers/isdn/mISDN/layer2.h140
-rw-r--r--drivers/isdn/mISDN/socket.c781
-rw-r--r--drivers/isdn/mISDN/stack.c674
-rw-r--r--drivers/isdn/mISDN/tei.c1340
-rw-r--r--drivers/isdn/mISDN/timerdev.c301
-rw-r--r--drivers/lguest/core.c1
-rw-r--r--drivers/lguest/interrupts_and_traps.c24
-rw-r--r--drivers/lguest/x86/core.c4
-rw-r--r--drivers/md/dm-mpath.c13
-rw-r--r--drivers/media/common/saa7146_fops.c2
-rw-r--r--drivers/media/common/saa7146_video.c19
-rw-r--r--drivers/media/common/tuners/Kconfig16
-rw-r--r--drivers/media/common/tuners/Makefile1
-rw-r--r--drivers/media/common/tuners/mt20xx.c3
-rw-r--r--drivers/media/common/tuners/mxl5007t.c1030
-rw-r--r--drivers/media/common/tuners/mxl5007t.h104
-rw-r--r--drivers/media/common/tuners/tda9887.c2
-rw-r--r--drivers/media/common/tuners/tuner-simple.c2
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig10
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c425
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.h9
-rw-r--r--drivers/media/dvb/frontends/Kconfig38
-rw-r--r--drivers/media/dvb/frontends/Makefile1
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c1504
-rw-r--r--drivers/media/dvb/frontends/drx397xD.h130
-rw-r--r--drivers/media/dvb/frontends/drx397xD_fw.h40
-rw-r--r--drivers/media/dvb/frontends/z0194a.h97
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c2
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c14
-rw-r--r--drivers/media/dvb/siano/smsdvb.c4
-rw-r--r--drivers/media/dvb/ttpci/Kconfig4
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig2
-rw-r--r--drivers/media/radio/dsbr100.c18
-rw-r--r--drivers/media/radio/miropcm20-radio.c3
-rw-r--r--drivers/media/radio/radio-aimslab.c14
-rw-r--r--drivers/media/radio/radio-aztech.c14
-rw-r--r--drivers/media/radio/radio-cadet.c14
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c13
-rw-r--r--drivers/media/radio/radio-gemtek.c13
-rw-r--r--drivers/media/radio/radio-maestro.c12
-rw-r--r--drivers/media/radio/radio-maxiradio.c15
-rw-r--r--drivers/media/radio/radio-rtrack2.c14
-rw-r--r--drivers/media/radio/radio-sf16fmi.c14
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c14
-rw-r--r--drivers/media/radio/radio-si470x.c22
-rw-r--r--drivers/media/radio/radio-terratec.c14
-rw-r--r--drivers/media/radio/radio-trust.c14
-rw-r--r--drivers/media/radio/radio-typhoon.c14
-rw-r--r--drivers/media/radio/radio-zoltrix.c14
-rw-r--r--drivers/media/video/Kconfig19
-rw-r--r--drivers/media/video/Makefile3
-rw-r--r--drivers/media/video/arv.c1
-rw-r--r--drivers/media/video/au0828/Kconfig1
-rw-r--r--drivers/media/video/au0828/au0828-cards.c12
-rw-r--r--drivers/media/video/au0828/au0828-cards.h1
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c15
-rw-r--r--drivers/media/video/bt8xx/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c58
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c1
-rw-r--r--drivers/media/video/bw-qcam.c3
-rw-r--r--drivers/media/video/c-qcam.c3
-rw-r--r--drivers/media/video/cafe_ccic.c26
-rw-r--r--drivers/media/video/compat_ioctl32.c2
-rw-r--r--drivers/media/video/cpia.c2
-rw-r--r--drivers/media/video/cpia.h1
-rw-r--r--drivers/media/video/cpia2/cpia2_core.c1
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c5
-rw-r--r--drivers/media/video/cs5345.c2
-rw-r--r--drivers/media/video/cs53l32a.c2
-rw-r--r--drivers/media/video/cx18/Kconfig2
-rw-r--r--drivers/media/video/cx18/cx18-av-audio.c111
-rw-r--r--drivers/media/video/cx18/cx18-driver.h1
-rw-r--r--drivers/media/video/cx18/cx18-firmware.c54
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c92
-rw-r--r--drivers/media/video/cx18/cx18-streams.c5
-rw-r--r--drivers/media/video/cx23885/Kconfig2
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c19
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c54
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c147
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c19
-rw-r--r--drivers/media/video/cx25840/Kconfig2
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c2
-rw-r--r--drivers/media/video/cx25840/cx25840-core.h2
-rw-r--r--drivers/media/video/cx88/Kconfig3
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c15
-rw-r--r--drivers/media/video/cx88/cx88-cards.c2
-rw-r--r--drivers/media/video/cx88/cx88-core.c3
-rw-r--r--drivers/media/video/cx88/cx88-video.c37
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c977
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c13
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c61
-rw-r--r--drivers/media/video/em28xx/em28xx.h49
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c5
-rw-r--r--drivers/media/video/gspca/conex.c9
-rw-r--r--drivers/media/video/gspca/etoms.c30
-rw-r--r--drivers/media/video/gspca/gspca.c43
-rw-r--r--drivers/media/video/gspca/mars.c9
-rw-r--r--drivers/media/video/gspca/ov519.c33
-rw-r--r--drivers/media/video/gspca/pac207.c29
-rw-r--r--drivers/media/video/gspca/pac7311.c22
-rw-r--r--drivers/media/video/gspca/sonixb.c484
-rw-r--r--drivers/media/video/gspca/sonixj.c492
-rw-r--r--drivers/media/video/gspca/spca500.c139
-rw-r--r--drivers/media/video/gspca/spca501.c75
-rw-r--r--drivers/media/video/gspca/spca505.c140
-rw-r--r--drivers/media/video/gspca/spca506.c121
-rw-r--r--drivers/media/video/gspca/spca508.c164
-rw-r--r--drivers/media/video/gspca/spca561.c62
-rw-r--r--drivers/media/video/gspca/stk014.c9
-rw-r--r--drivers/media/video/gspca/sunplus.c355
-rw-r--r--drivers/media/video/gspca/t613.c26
-rw-r--r--drivers/media/video/gspca/tv8532.c17
-rw-r--r--drivers/media/video/gspca/vc032x.c44
-rw-r--r--drivers/media/video/gspca/zc3xx.c486
-rw-r--r--drivers/media/video/ivtv/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c5
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h1
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c130
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c7
-rw-r--r--drivers/media/video/m52790.c2
-rw-r--r--drivers/media/video/meye.c19
-rw-r--r--drivers/media/video/msp3400-driver.c2
-rw-r--r--drivers/media/video/msp3400-kthreads.c1
-rw-r--r--drivers/media/video/mt9m001.c2
-rw-r--r--drivers/media/video/ov511.c38
-rw-r--r--drivers/media/video/ov511.h1
-rw-r--r--drivers/media/video/planb.c2309
-rw-r--r--drivers/media/video/planb.h232
-rw-r--r--drivers/media/video/pms.c3
-rw-r--r--drivers/media/video/pvrusb2/Kconfig2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.h4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.c11
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.h26
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c9
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c6
-rw-r--r--drivers/media/video/pwc/pwc-if.c16
-rw-r--r--drivers/media/video/pwc/pwc.h2
-rw-r--r--drivers/media/video/s2255drv.c130
-rw-r--r--drivers/media/video/saa5246a.c3
-rw-r--r--drivers/media/video/saa5249.c3
-rw-r--r--drivers/media/video/saa7134/Kconfig2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c3
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c16
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c54
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c98
-rw-r--r--drivers/media/video/saa7134/saa7134.h7
-rw-r--r--drivers/media/video/saa717x.c1
-rw-r--r--drivers/media/video/saa7196.h117
-rw-r--r--drivers/media/video/se401.c2
-rw-r--r--drivers/media/video/se401.h1
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c1
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h1
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c62
-rw-r--r--drivers/media/video/soc_camera.c68
-rw-r--r--drivers/media/video/stk-webcam.c69
-rw-r--r--drivers/media/video/stradis.c2
-rw-r--r--drivers/media/video/stv680.c52
-rw-r--r--drivers/media/video/tda7432.c3
-rw-r--r--drivers/media/video/tda9875.c2
-rw-r--r--drivers/media/video/tlv320aic23b.c2
-rw-r--r--drivers/media/video/tuner-core.c1
-rw-r--r--drivers/media/video/tveeprom.c122
-rw-r--r--drivers/media/video/tvp5150.c2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c4
-rw-r--r--drivers/media/video/usbvideo/usbvideo.h1
-rw-r--r--drivers/media/video/usbvideo/vicam.c3
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c113
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c15
-rw-r--r--drivers/media/video/uvc/uvc_driver.c4
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c1
-rw-r--r--drivers/media/video/v4l1-compat.c1
-rw-r--r--drivers/media/video/v4l2-common.c2
-rw-r--r--drivers/media/video/v4l2-dev.c422
-rw-r--r--drivers/media/video/v4l2-ioctl.c1875
-rw-r--r--drivers/media/video/videobuf-dma-contig.c8
-rw-r--r--drivers/media/video/videobuf-vmalloc.c2
-rw-r--r--drivers/media/video/videodev.c2262
-rw-r--r--drivers/media/video/vino.c4
-rw-r--r--drivers/media/video/vivi.c18
-rw-r--r--drivers/media/video/vp27smpx.c2
-rw-r--r--drivers/media/video/w9966.c5
-rw-r--r--drivers/media/video/w9968cf.c5
-rw-r--r--drivers/media/video/w9968cf.h2
-rw-r--r--drivers/media/video/wm8739.c2
-rw-r--r--drivers/media/video/wm8775.c2
-rw-r--r--drivers/media/video/zc0301/zc0301.h1
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c2
-rw-r--r--drivers/media/video/zoran_card.c42
-rw-r--r--drivers/media/video/zoran_card.h2
-rw-r--r--drivers/media/video/zoran_driver.c7
-rw-r--r--drivers/media/video/zr364xx.c18
-rw-r--r--drivers/memstick/core/memstick.c36
-rw-r--r--drivers/memstick/core/mspro_block.c365
-rw-r--r--drivers/memstick/host/jmb38x_ms.c102
-rw-r--r--drivers/memstick/host/tifm_ms.c66
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt6
-rw-r--r--drivers/message/fusion/mptbase.c24
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptfc.c8
-rw-r--r--drivers/message/fusion/mptlan.c26
-rw-r--r--drivers/message/fusion/mptsas.c54
-rw-r--r--drivers/message/fusion/mptscsih.c4
-rw-r--r--drivers/mfd/asic3.c22
-rw-r--r--drivers/mfd/mfd-core.c32
-rw-r--r--drivers/mfd/tc6393xb.c10
-rw-r--r--drivers/misc/Kconfig2
-rw-r--r--drivers/misc/atmel-ssc.c1
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c3
-rw-r--r--drivers/mmc/core/Makefile1
-rw-r--r--drivers/mmc/core/bus.c8
-rw-r--r--drivers/mmc/core/core.h7
-rw-r--r--drivers/mmc/core/debugfs.c225
-rw-r--r--drivers/mmc/core/host.c8
-rw-r--r--drivers/mmc/host/atmel-mci-regs.h2
-rw-r--r--drivers/mmc/host/atmel-mci.c206
-rw-r--r--drivers/mmc/host/imxmmc.c50
-rw-r--r--drivers/mmc/host/mmc_spi.c3
-rw-r--r--drivers/mmc/host/sdhci.c4
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/Kconfig2
-rw-r--r--drivers/mtd/afs.c2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c17
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c3
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c2
-rw-r--r--drivers/mtd/chips/cfi_probe.c1
-rw-r--r--drivers/mtd/chips/cfi_util.c3
-rw-r--r--drivers/mtd/chips/chipreg.c2
-rw-r--r--drivers/mtd/chips/gen_probe.c5
-rw-r--r--drivers/mtd/chips/jedec_probe.c133
-rw-r--r--drivers/mtd/chips/map_absent.c1
-rw-r--r--drivers/mtd/chips/map_ram.c1
-rw-r--r--drivers/mtd/chips/map_rom.c1
-rw-r--r--drivers/mtd/cmdlinepart.c4
-rw-r--r--drivers/mtd/devices/Kconfig1
-rw-r--r--drivers/mtd/devices/Makefile1
-rw-r--r--drivers/mtd/devices/block2mtd.c6
-rw-r--r--drivers/mtd/devices/doc2000.c2
-rw-r--r--drivers/mtd/devices/doc2001.c2
-rw-r--r--drivers/mtd/devices/doc2001plus.c2
-rw-r--r--drivers/mtd/devices/docecc.c2
-rw-r--r--drivers/mtd/devices/docprobe.c5
-rw-r--r--drivers/mtd/devices/lart.c2
-rw-r--r--drivers/mtd/devices/m25p80.c22
-rw-r--r--drivers/mtd/devices/ms02-nv.c2
-rw-r--r--drivers/mtd/devices/ms02-nv.h2
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c135
-rw-r--r--drivers/mtd/devices/mtdram.c1
-rw-r--r--drivers/mtd/devices/phram.c2
-rw-r--r--drivers/mtd/devices/pmc551.c2
-rw-r--r--drivers/mtd/devices/slram.c2
-rw-r--r--drivers/mtd/ftl.c3
-rw-r--r--drivers/mtd/inftlcore.c5
-rw-r--r--drivers/mtd/inftlmount.c4
-rw-r--r--drivers/mtd/maps/Kconfig30
-rw-r--r--drivers/mtd/maps/Makefile3
-rw-r--r--drivers/mtd/maps/amd76xrom.c1
-rw-r--r--drivers/mtd/maps/autcpu12-nvram.c2
-rw-r--r--drivers/mtd/maps/bast-flash.c226
-rw-r--r--drivers/mtd/maps/bfin-async-flash.c219
-rw-r--r--drivers/mtd/maps/cdb89712.c1
-rw-r--r--drivers/mtd/maps/ceiva.c1
-rw-r--r--drivers/mtd/maps/cfi_flagadm.c2
-rw-r--r--drivers/mtd/maps/dbox2-flash.c2
-rw-r--r--drivers/mtd/maps/dc21285.c2
-rw-r--r--drivers/mtd/maps/dilnetpc.c2
-rw-r--r--drivers/mtd/maps/dmv182.c2
-rw-r--r--drivers/mtd/maps/ebony.c2
-rw-r--r--drivers/mtd/maps/edb7312.c2
-rw-r--r--drivers/mtd/maps/fortunet.c1
-rw-r--r--drivers/mtd/maps/h720x-flash.c2
-rw-r--r--drivers/mtd/maps/ichxrom.c1
-rw-r--r--drivers/mtd/maps/impa7.c2
-rw-r--r--drivers/mtd/maps/integrator-flash.c2
-rw-r--r--drivers/mtd/maps/ipaq-flash.c2
-rw-r--r--drivers/mtd/maps/ixp2000.c2
-rw-r--r--drivers/mtd/maps/ixp4xx.c2
-rw-r--r--drivers/mtd/maps/l440gx.c2
-rw-r--r--drivers/mtd/maps/map_funcs.c2
-rw-r--r--drivers/mtd/maps/mbx860.c2
-rw-r--r--drivers/mtd/maps/netsc520.c2
-rw-r--r--drivers/mtd/maps/nettel.c2
-rw-r--r--drivers/mtd/maps/octagon-5066.c1
-rw-r--r--drivers/mtd/maps/omap-toto-flash.c2
-rw-r--r--drivers/mtd/maps/pci.c2
-rw-r--r--drivers/mtd/maps/pcmciamtd.c5
-rw-r--r--drivers/mtd/maps/physmap.c24
-rw-r--r--drivers/mtd/maps/plat-ram.c2
-rw-r--r--drivers/mtd/maps/redwood.c2
-rw-r--r--drivers/mtd/maps/rpxlite.c2
-rw-r--r--drivers/mtd/maps/sa1100-flash.c2
-rw-r--r--drivers/mtd/maps/sbc8240.c3
-rw-r--r--drivers/mtd/maps/sbc_gxx.c2
-rw-r--r--drivers/mtd/maps/sc520cdp.c2
-rw-r--r--drivers/mtd/maps/scb2_flash.c1
-rw-r--r--drivers/mtd/maps/scx200_docflash.c2
-rw-r--r--drivers/mtd/maps/sharpsl-flash.c2
-rw-r--r--drivers/mtd/maps/solutionengine.c2
-rw-r--r--drivers/mtd/maps/sun_uflash.c2
-rw-r--r--drivers/mtd/maps/tqm8xxl.c2
-rw-r--r--drivers/mtd/maps/ts5500_flash.c2
-rw-r--r--drivers/mtd/maps/tsunami_flash.c1
-rw-r--r--drivers/mtd/maps/uclinux.c2
-rw-r--r--drivers/mtd/maps/vmax301.c1
-rw-r--r--drivers/mtd/maps/walnut.c2
-rw-r--r--drivers/mtd/maps/wr_sbc82xx_flash.c2
-rw-r--r--drivers/mtd/mtd_blkdevs.c34
-rw-r--r--drivers/mtd/mtdblock.c2
-rw-r--r--drivers/mtd/mtdblock_ro.c2
-rw-r--r--drivers/mtd/mtdchar.c24
-rw-r--r--drivers/mtd/mtdconcat.c2
-rw-r--r--drivers/mtd/mtdcore.c14
-rw-r--r--drivers/mtd/mtdpart.c448
-rw-r--r--drivers/mtd/nand/Kconfig28
-rw-r--r--drivers/mtd/nand/Makefile3
-rw-r--r--drivers/mtd/nand/atmel_nand.c (renamed from drivers/mtd/nand/at91_nand.c)278
-rw-r--r--drivers/mtd/nand/atmel_nand_ecc.h36
-rw-r--r--drivers/mtd/nand/au1550nd.c4
-rw-r--r--drivers/mtd/nand/autcpu12.c2
-rw-r--r--drivers/mtd/nand/cafe_nand.c6
-rw-r--r--drivers/mtd/nand/diskonchip.c4
-rw-r--r--drivers/mtd/nand/edb7312.c2
-rw-r--r--drivers/mtd/nand/excite_nandflash.c2
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c63
-rw-r--r--drivers/mtd/nand/h1910.c2
-rw-r--r--drivers/mtd/nand/nand_base.c87
-rw-r--r--drivers/mtd/nand/nand_bbt.c2
-rw-r--r--drivers/mtd/nand/nand_ecc.c2
-rw-r--r--drivers/mtd/nand/nand_ids.c2
-rw-r--r--drivers/mtd/nand/nandsim.c41
-rw-r--r--drivers/mtd/nand/ppchameleonevb.c2
-rw-r--r--drivers/mtd/nand/rtc_from4.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c168
-rw-r--r--drivers/mtd/nand/sharpsl.c2
-rw-r--r--drivers/mtd/nand/spia.c2
-rw-r--r--drivers/mtd/nand/toto.c2
-rw-r--r--drivers/mtd/nand/ts7250.c2
-rw-r--r--drivers/mtd/nftlcore.c5
-rw-r--r--drivers/mtd/nftlmount.c4
-rw-r--r--drivers/mtd/onenand/onenand_base.c54
-rw-r--r--drivers/mtd/redboot.c2
-rw-r--r--drivers/mtd/rfd_ftl.c2
-rw-r--r--drivers/net/arm/ep93xx_eth.c4
-rw-r--r--drivers/net/bnx2x_main.c14
-rw-r--r--drivers/net/cassini.c12
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000e/ethtool.c4
-rw-r--r--drivers/net/e1000e/netdev.c11
-rw-r--r--drivers/net/ibmveth.c40
-rw-r--r--drivers/net/iseries_veth.c4
-rw-r--r--drivers/net/mlx4/alloc.c1
-rw-r--r--drivers/net/mlx4/catas.c1
-rw-r--r--drivers/net/mlx4/cmd.c2
-rw-r--r--drivers/net/mlx4/cq.c2
-rw-r--r--drivers/net/mlx4/eq.c4
-rw-r--r--drivers/net/mlx4/fw.c2
-rw-r--r--drivers/net/mlx4/fw.h2
-rw-r--r--drivers/net/mlx4/icm.c2
-rw-r--r--drivers/net/mlx4/icm.h2
-rw-r--r--drivers/net/mlx4/intf.c1
-rw-r--r--drivers/net/mlx4/main.c2
-rw-r--r--drivers/net/mlx4/mcg.c1
-rw-r--r--drivers/net/mlx4/mlx4.h2
-rw-r--r--drivers/net/mlx4/mr.c2
-rw-r--r--drivers/net/mlx4/qp.c2
-rw-r--r--drivers/net/mlx4/reset.c1
-rw-r--r--drivers/net/mlx4/srq.c1
-rw-r--r--drivers/net/pasemi_mac.c6
-rw-r--r--drivers/net/ppp_generic.c6
-rw-r--r--drivers/net/qla3xxx.c12
-rw-r--r--drivers/net/s2io.c48
-rw-r--r--drivers/net/sfc/rx.c4
-rw-r--r--drivers/net/sfc/tx.c7
-rw-r--r--drivers/net/spider_net.c4
-rw-r--r--drivers/net/tc35815.c4
-rw-r--r--drivers/net/wireless/ath5k/base.c4
-rw-r--r--drivers/of/Kconfig6
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/base.c88
-rw-r--r--drivers/of/of_i2c.c64
-rw-r--r--drivers/of/of_spi.c93
-rw-r--r--drivers/parport/ieee1284.c2
-rw-r--r--drivers/parport/parport_cs.c2
-rw-r--r--drivers/parport/parport_pc.c2
-rw-r--r--drivers/parport/procfs.c3
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/msi.c15
-rw-r--r--drivers/pci/pci-acpi.c7
-rw-r--r--drivers/pci/pci.c10
-rw-r--r--drivers/pci/pcie/aspm.c32
-rw-r--r--drivers/pci/probe.c245
-rw-r--r--drivers/pci/quirks.c13
-rw-r--r--drivers/pcmcia/soc_common.c12
-rw-r--r--drivers/pnp/base.h1
-rw-r--r--drivers/pnp/card.c6
-rw-r--r--drivers/pnp/quirks.c13
-rw-r--r--drivers/s390/kvm/Makefile2
-rw-r--r--drivers/s390/net/qeth_core_main.c14
-rw-r--r--drivers/s390/net/qeth_l2_main.c26
-rw-r--r--drivers/s390/net/qeth_l3_main.c30
-rw-r--r--drivers/scsi/3w-9xxx.c40
-rw-r--r--drivers/scsi/3w-9xxx.h9
-rw-r--r--drivers/scsi/Kconfig1
-rw-r--r--drivers/scsi/Makefile2
-rw-r--r--drivers/scsi/advansys.c2
-rw-r--r--drivers/scsi/aha152x.c12
-rw-r--r--drivers/scsi/aic94xx/aic94xx.h4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c46
-rw-r--r--drivers/scsi/aic94xx/aic94xx_task.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_tmf.c18
-rw-r--r--drivers/scsi/arm/fas216.c4
-rw-r--r--drivers/scsi/ch.c1
-rw-r--r--drivers/scsi/device_handler/Kconfig8
-rw-r--r--drivers/scsi/device_handler/Makefile1
-rw-r--r--drivers/scsi/device_handler/scsi_dh.c446
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c802
-rw-r--r--drivers/scsi/device_handler/scsi_dh_emc.c644
-rw-r--r--drivers/scsi/device_handler/scsi_dh_hp_sw.c348
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c262
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c208
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.h44
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c4
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c4
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c2
-rw-r--r--drivers/scsi/imm.c2
-rw-r--r--drivers/scsi/ipr.h6
-rw-r--r--drivers/scsi/libsas/sas_ata.c16
-rw-r--r--drivers/scsi/libsas/sas_expander.c12
-rw-r--r--drivers/scsi/libsas/sas_port.c4
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c30
-rw-r--r--drivers/scsi/libsrp.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c6
-rw-r--r--drivers/scsi/megaraid/mega_common.h2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c16
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c4
-rw-r--r--drivers/scsi/nsp32.c4
-rw-r--r--drivers/scsi/nsp32_debug.c2
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_debug.c2
-rw-r--r--drivers/scsi/ppa.c2
-rw-r--r--drivers/scsi/qla1280.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c119
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h12
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h5
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c133
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c14
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c9
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c94
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c48
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c4
-rw-r--r--drivers/scsi/scsi.c55
-rw-r--r--drivers/scsi/scsi_debug.c12
-rw-r--r--drivers/scsi/scsi_devinfo.c6
-rw-r--r--drivers/scsi/scsi_error.c34
-rw-r--r--drivers/scsi/scsi_lib.c55
-rw-r--r--drivers/scsi/scsi_netlink.c8
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_proc.c4
-rw-r--r--drivers/scsi/scsi_scan.c13
-rw-r--r--drivers/scsi/scsi_sysfs.c4
-rw-r--r--drivers/scsi/scsi_tgt_priv.h2
-rw-r--r--drivers/scsi/scsi_transport_fc.c12
-rw-r--r--drivers/scsi/scsi_transport_sas.c4
-rw-r--r--drivers/scsi/sd.c291
-rw-r--r--drivers/scsi/sd.h54
-rw-r--r--drivers/scsi/sd_dif.c538
-rw-r--r--drivers/scsi/st.c11
-rw-r--r--drivers/scsi/stex.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c2
-rw-r--r--drivers/scsi/tmscsim.c8
-rw-r--r--drivers/scsi/wd7000.c8
-rw-r--r--drivers/scsi/zalon.c8
-rw-r--r--drivers/serial/sh-sci.c17
-rw-r--r--drivers/serial/sh-sci.h38
-rw-r--r--drivers/spi/atmel_spi.c4
-rw-r--r--drivers/spi/au1550_spi.c6
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c22
-rw-r--r--drivers/spi/omap2_mcspi.c4
-rw-r--r--drivers/spi/pxa2xx_spi.c4
-rw-r--r--drivers/spi/spi.c139
-rw-r--r--drivers/spi/spi_imx.c6
-rw-r--r--drivers/spi/spi_s3c24xx.c1
-rw-r--r--drivers/usb/mon/mon_text.c4
-rw-r--r--drivers/usb/serial/ipaq.c10
-rw-r--r--drivers/video/am200epd.c2
-rw-r--r--drivers/video/console/sticon.c2
-rw-r--r--drivers/video/console/sticore.c33
-rw-r--r--drivers/video/fbmem.c1
-rw-r--r--drivers/video/macfb.c2
-rw-r--r--drivers/video/omap/sossi.c2
-rw-r--r--drivers/video/pxafb.c2
-rw-r--r--drivers/video/sh7760fb.c1
-rw-r--r--drivers/video/sticore.h2
-rw-r--r--drivers/video/stifb.c6
-rw-r--r--fs/Kconfig13
-rw-r--r--fs/Kconfig.binfmt2
-rw-r--r--fs/Makefile1
-rw-r--r--fs/adfs/super.c2
-rw-r--r--fs/affs/affs.h3
-rw-r--r--fs/affs/bitmap.c18
-rw-r--r--fs/affs/file.c4
-rw-r--r--fs/affs/super.c4
-rw-r--r--fs/afs/internal.h4
-rw-r--r--fs/afs/security.c2
-rw-r--r--fs/afs/super.c4
-rw-r--r--fs/aio.c6
-rw-r--r--fs/attr.c7
-rw-r--r--fs/bad_inode.c3
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/bfs/bfs.h5
-rw-r--r--fs/bfs/dir.c46
-rw-r--r--fs/bfs/file.c4
-rw-r--r--fs/bfs/inode.c29
-rw-r--r--fs/binfmt_aout.c6
-rw-r--r--fs/binfmt_elf.c6
-rw-r--r--fs/binfmt_elf_fdpic.c52
-rw-r--r--fs/binfmt_flat.c3
-rw-r--r--fs/binfmt_som.c2
-rw-r--r--fs/bio-integrity.c1
-rw-r--r--fs/bio.c8
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/buffer.c55
-rw-r--r--fs/cifs/asn1.c4
-rw-r--r--fs/cifs/cifs_debug.c645
-rw-r--r--fs/cifs/cifsacl.c41
-rw-r--r--fs/cifs/cifsencrypt.c3
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/cifspdu.h8
-rw-r--r--fs/cifs/cifssmb.c10
-rw-r--r--fs/cifs/connect.c37
-rw-r--r--fs/cifs/inode.c151
-rw-r--r--fs/cifs/readdir.c1
-rw-r--r--fs/coda/dir.c4
-rw-r--r--fs/coda/inode.c2
-rw-r--r--fs/coda/pioctl.c20
-rw-r--r--fs/compat.c20
-rw-r--r--fs/dcache.c1
-rw-r--r--fs/direct-io.c10
-rw-r--r--fs/dlm/lock.c4
-rw-r--r--fs/dlm/lowcomms.c4
-rw-r--r--fs/dlm/user.c2
-rw-r--r--fs/ecryptfs/crypto.c30
-rw-r--r--fs/ecryptfs/inode.c21
-rw-r--r--fs/ecryptfs/main.c4
-rw-r--r--fs/efs/super.c2
-rw-r--r--fs/exec.c94
-rw-r--r--fs/ext2/acl.c2
-rw-r--r--fs/ext2/acl.h2
-rw-r--r--fs/ext2/inode.c1
-rw-r--r--fs/ext2/super.c2
-rw-r--r--fs/ext3/acl.c2
-rw-r--r--fs/ext3/acl.h2
-rw-r--r--fs/ext3/inode.c67
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/acl.c2
-rw-r--r--fs/ext4/acl.h2
-rw-r--r--fs/ext4/inode.c92
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/fat/cache.c2
-rw-r--r--fs/fat/file.c15
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/fcntl.c33
-rw-r--r--fs/fifo.c8
-rw-r--r--fs/file.c9
-rw-r--r--fs/file_table.c10
-rw-r--r--fs/fuse/dir.c6
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/gfs2/inode.c6
-rw-r--r--fs/gfs2/inode.h2
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/gfs2/ops_export.c2
-rw-r--r--fs/gfs2/ops_inode.c16
-rw-r--r--fs/gfs2/super.c2
-rw-r--r--fs/hfs/inode.c7
-rw-r--r--fs/hfs/super.c2
-rw-r--r--fs/hfsplus/inode.c6
-rw-r--r--fs/hfsplus/super.c2
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hpfs/namei.c2
-rw-r--r--fs/hpfs/super.c2
-rw-r--r--fs/hppfs/hppfs.c7
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/inode.c4
-rw-r--r--fs/inotify_user.c22
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/jffs2/acl.c2
-rw-r--r--fs/jffs2/acl.h2
-rw-r--r--fs/jffs2/dir.c2
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/jffs2/ioctl.c3
-rw-r--r--fs/jffs2/os-linux.h2
-rw-r--r--fs/jffs2/super.c2
-rw-r--r--fs/jfs/acl.c2
-rw-r--r--fs/jfs/jfs_acl.h2
-rw-r--r--fs/jfs/jfs_metapage.c2
-rw-r--r--fs/jfs/super.c2
-rw-r--r--fs/locks.c2
-rw-r--r--fs/minix/inode.c2
-rw-r--r--fs/namei.c354
-rw-r--r--fs/namespace.c109
-rw-r--r--fs/ncpfs/dir.c4
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/nfs/dir.c11
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/super.c6
-rw-r--r--fs/nfs/unlink.c3
-rw-r--r--fs/nfsd/nfsctl.c1
-rw-r--r--fs/nfsd/nfsfh.c2
-rw-r--r--fs/nfsd/vfs.c14
-rw-r--r--fs/ntfs/file.c2
-rw-r--r--fs/ntfs/super.c2
-rw-r--r--fs/ocfs2/dlm/dlmfs.c3
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/ocfs2/file.h3
-rw-r--r--fs/ocfs2/super.c2
-rw-r--r--fs/omfs/Makefile4
-rw-r--r--fs/omfs/bitmap.c192
-rw-r--r--fs/omfs/dir.c504
-rw-r--r--fs/omfs/file.c346
-rw-r--r--fs/omfs/inode.c553
-rw-r--r--fs/omfs/omfs.h67
-rw-r--r--fs/omfs/omfs_fs.h80
-rw-r--r--fs/open.c179
-rw-r--r--fs/openpromfs/inode.c2
-rw-r--r--fs/pipe.c51
-rw-r--r--fs/proc/array.c9
-rw-r--r--fs/proc/base.c105
-rw-r--r--fs/proc/generic.c5
-rw-r--r--fs/proc/inode.c7
-rw-r--r--fs/proc/proc_sysctl.c429
-rw-r--r--fs/qnx4/inode.c2
-rw-r--r--fs/reiserfs/super.c2
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/romfs/inode.c2
-rw-r--r--fs/smbfs/file.c4
-rw-r--r--fs/smbfs/inode.c2
-rw-r--r--fs/splice.c45
-rw-r--r--fs/stat.c32
-rw-r--r--fs/sysfs/dir.c5
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--fs/sysfs/group.c3
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/ubifs/file.c1
-rw-r--r--fs/ubifs/super.c2
-rw-r--r--fs/udf/super.c2
-rw-r--r--fs/ufs/super.c2
-rw-r--r--fs/utimes.c139
-rw-r--r--fs/xattr.c98
-rw-r--r--fs/xfs/linux-2.6/kmem.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c14
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c1
-rw-r--r--include/Kbuild5
-rw-r--r--include/acpi/actbl.h1
-rw-r--r--include/asm-alpha/dma-mapping.h6
-rw-r--r--include/asm-alpha/namei.h17
-rw-r--r--include/asm-alpha/pci.h2
-rw-r--r--include/asm-arm/arch-at91/at91_ecc.h38
-rw-r--r--include/asm-arm/arch-at91/board.h4
-rw-r--r--include/asm-arm/arch-pnx4008/irqs.h48
-rw-r--r--include/asm-arm/arch-pxa/idp.h10
-rw-r--r--include/asm-arm/arch-pxa/pcm990_baseboard.h14
-rw-r--r--include/asm-arm/arch-pxa/pxa25x-udc.h2
-rw-r--r--include/asm-arm/arch-s3c2410/spi.h1
-rw-r--r--include/asm-arm/arch-sa1100/ide.h2
-rw-r--r--include/asm-arm/bitops.h9
-rw-r--r--include/asm-arm/cacheflush.h21
-rw-r--r--include/asm-arm/dma-mapping.h4
-rw-r--r--include/asm-arm/irq.h17
-rw-r--r--include/asm-arm/namei.h25
-rw-r--r--include/asm-arm/pci.h8
-rw-r--r--include/asm-arm/plat-s3c/iic.h1
-rw-r--r--include/asm-avr32/arch-at32ap/board.h23
-rw-r--r--include/asm-avr32/dma-mapping.h2
-rw-r--r--include/asm-avr32/namei.h7
-rw-r--r--include/asm-blackfin/bfin-global.h8
-rw-r--r--include/asm-blackfin/dma.h8
-rw-r--r--include/asm-blackfin/dpmc.h82
-rw-r--r--include/asm-blackfin/elf.h2
-rw-r--r--include/asm-blackfin/gpio.h19
-rw-r--r--include/asm-blackfin/mach-bf527/anomaly.h2
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_sir.h21
-rw-r--r--include/asm-blackfin/mach-bf527/defBF527.h1
-rw-r--r--include/asm-blackfin/mach-bf527/mem_init.h27
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_sir.h13
-rw-r--r--include/asm-blackfin/mach-bf533/mem_init.h27
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_sir.h21
-rw-r--r--include/asm-blackfin/mach-bf537/defBF537.h1
-rw-r--r--include/asm-blackfin/mach-bf537/mem_init.h27
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_sir.h37
-rw-r--r--include/asm-blackfin/mach-bf548/gpio.h8
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_sir.h13
-rw-r--r--include/asm-blackfin/mach-bf561/mem_init.h27
-rw-r--r--include/asm-blackfin/module.h5
-rw-r--r--include/asm-blackfin/namei.h19
-rw-r--r--include/asm-blackfin/processor.h21
-rw-r--r--include/asm-cris/dma-mapping.h4
-rw-r--r--include/asm-cris/namei.h17
-rw-r--r--include/asm-frv/dma-mapping.h2
-rw-r--r--include/asm-frv/namei.h18
-rw-r--r--include/asm-generic/dma-coherent.h32
-rw-r--r--include/asm-generic/dma-mapping-broken.h2
-rw-r--r--include/asm-generic/dma-mapping.h4
-rw-r--r--include/asm-generic/gpio.h3
-rw-r--r--include/asm-generic/pci-dma-compat.h4
-rw-r--r--include/asm-generic/pgtable-nopmd.h6
-rw-r--r--include/asm-generic/syscall.h141
-rw-r--r--include/asm-generic/vmlinux.lds.h6
-rw-r--r--include/asm-h8300/namei.h17
-rw-r--r--include/asm-ia64/machvec.h2
-rw-r--r--include/asm-ia64/namei.h25
-rw-r--r--include/asm-m32r/namei.h17
-rw-r--r--include/asm-m68k/dma-mapping.h2
-rw-r--r--include/asm-m68k/namei.h17
-rw-r--r--include/asm-m68knommu/namei.h1
-rw-r--r--include/asm-mips/dma-mapping.h2
-rw-r--r--include/asm-mips/namei.h11
-rw-r--r--include/asm-mn10300/dma-mapping.h2
-rw-r--r--include/asm-mn10300/namei.h22
-rw-r--r--include/asm-parisc/cacheflush.h4
-rw-r--r--include/asm-parisc/dma-mapping.h2
-rw-r--r--include/asm-parisc/namei.h17
-rw-r--r--include/asm-powerpc/dma-mapping.h2
-rw-r--r--include/asm-powerpc/kvm_ppc.h3
-rw-r--r--include/asm-powerpc/namei.h20
-rw-r--r--include/asm-powerpc/pgtable-4k.h2
-rw-r--r--include/asm-powerpc/pgtable-64k.h2
-rw-r--r--include/asm-powerpc/pgtable-ppc32.h3
-rw-r--r--include/asm-powerpc/pgtable-ppc64.h4
-rw-r--r--include/asm-powerpc/ptrace.h1
-rw-r--r--include/asm-powerpc/signal.h3
-rw-r--r--include/asm-powerpc/smp.h2
-rw-r--r--include/asm-powerpc/syscall.h84
-rw-r--r--include/asm-powerpc/thread_info.h5
-rw-r--r--include/asm-powerpc/topology.h2
-rw-r--r--include/asm-s390/kvm_host.h4
-rw-r--r--include/asm-s390/namei.h21
-rw-r--r--include/asm-sh/clock.h21
-rw-r--r--include/asm-sh/cpu-sh4/cacheflush.h1
-rw-r--r--include/asm-sh/cpu-sh4/freq.h4
-rw-r--r--include/asm-sh/device.h5
-rw-r--r--include/asm-sh/dma-mapping.h3
-rw-r--r--include/asm-sh/elf.h53
-rw-r--r--include/asm-sh/hw_irq.h4
-rw-r--r--include/asm-sh/migor.h15
-rw-r--r--include/asm-sh/mmu.h4
-rw-r--r--include/asm-sh/mmu_context.h3
-rw-r--r--include/asm-sh/namei.h17
-rw-r--r--include/asm-sh/page.h2
-rw-r--r--include/asm-sh/pgtable_32.h4
-rw-r--r--include/asm-sh/processor.h1
-rw-r--r--include/asm-sh/processor_32.h5
-rw-r--r--include/asm-sh/processor_64.h4
-rw-r--r--include/asm-sh/ptrace.h5
-rw-r--r--include/asm-sh/se.h17
-rw-r--r--include/asm-sh/se7343.h93
-rw-r--r--include/asm-sh/se7722.h4
-rw-r--r--include/asm-sh/segment.h30
-rw-r--r--include/asm-sh/sh7763rdp.h54
-rw-r--r--include/asm-sh/sh7785lcr.h55
-rw-r--r--include/asm-sh/system.h8
-rw-r--r--include/asm-sh/thread_info.h2
-rw-r--r--include/asm-sh/timer.h1
-rw-r--r--include/asm-sh/uaccess.h222
-rw-r--r--include/asm-sh/uaccess_32.h344
-rw-r--r--include/asm-sh/uaccess_64.h206
-rw-r--r--include/asm-sh/unistd.h14
-rw-r--r--include/asm-sh/unistd_32.h8
-rw-r--r--include/asm-sh/unistd_64.h8
-rw-r--r--include/asm-sparc/Kbuild1
-rw-r--r--include/asm-sparc/namei.h8
-rw-r--r--include/asm-sparc/namei_32.h13
-rw-r--r--include/asm-sparc/namei_64.h13
-rw-r--r--include/asm-sparc64/Kbuild1
-rw-r--r--include/asm-sparc64/agp.h1
-rw-r--r--include/asm-sparc64/apb.h1
-rw-r--r--include/asm-sparc64/asi.h1
-rw-r--r--include/asm-sparc64/atomic.h1
-rw-r--r--include/asm-sparc64/auxio.h1
-rw-r--r--include/asm-sparc64/auxvec.h1
-rw-r--r--include/asm-sparc64/backoff.h1
-rw-r--r--include/asm-sparc64/bbc.h1
-rw-r--r--include/asm-sparc64/bitops.h1
-rw-r--r--include/asm-sparc64/bpp.h1
-rw-r--r--include/asm-sparc64/bug.h1
-rw-r--r--include/asm-sparc64/bugs.h1
-rw-r--r--include/asm-sparc64/byteorder.h1
-rw-r--r--include/asm-sparc64/cache.h1
-rw-r--r--include/asm-sparc64/cacheflush.h1
-rw-r--r--include/asm-sparc64/chafsr.h1
-rw-r--r--include/asm-sparc64/checksum.h1
-rw-r--r--include/asm-sparc64/chmctrl.h1
-rw-r--r--include/asm-sparc64/cmt.h1
-rw-r--r--include/asm-sparc64/compat.h1
-rw-r--r--include/asm-sparc64/compat_signal.h1
-rw-r--r--include/asm-sparc64/cpudata.h1
-rw-r--r--include/asm-sparc64/cputime.h1
-rw-r--r--include/asm-sparc64/current.h1
-rw-r--r--include/asm-sparc64/dcr.h1
-rw-r--r--include/asm-sparc64/dcu.h1
-rw-r--r--include/asm-sparc64/delay.h1
-rw-r--r--include/asm-sparc64/device.h1
-rw-r--r--include/asm-sparc64/display7seg.h1
-rw-r--r--include/asm-sparc64/div64.h1
-rw-r--r--include/asm-sparc64/dma-mapping.h1
-rw-r--r--include/asm-sparc64/dma.h1
-rw-r--r--include/asm-sparc64/ebus.h1
-rw-r--r--include/asm-sparc64/elf.h1
-rw-r--r--include/asm-sparc64/emergency-restart.h1
-rw-r--r--include/asm-sparc64/envctrl.h1
-rw-r--r--include/asm-sparc64/errno.h1
-rw-r--r--include/asm-sparc64/estate.h1
-rw-r--r--include/asm-sparc64/fb.h1
-rw-r--r--include/asm-sparc64/fbio.h1
-rw-r--r--include/asm-sparc64/fcntl.h1
-rw-r--r--include/asm-sparc64/fhc.h1
-rw-r--r--include/asm-sparc64/floppy.h1
-rw-r--r--include/asm-sparc64/fpumacro.h1
-rw-r--r--include/asm-sparc64/futex.h1
-rw-r--r--include/asm-sparc64/hardirq.h1
-rw-r--r--include/asm-sparc64/head.h1
-rw-r--r--include/asm-sparc64/hugetlb.h1
-rw-r--r--include/asm-sparc64/hvtramp.h1
-rw-r--r--include/asm-sparc64/hw_irq.h1
-rw-r--r--include/asm-sparc64/hypervisor.h1
-rw-r--r--include/asm-sparc64/ide.h1
-rw-r--r--include/asm-sparc64/idprom.h1
-rw-r--r--include/asm-sparc64/intr_queue.h1
-rw-r--r--include/asm-sparc64/io.h1
-rw-r--r--include/asm-sparc64/ioctl.h1
-rw-r--r--include/asm-sparc64/ioctls.h1
-rw-r--r--include/asm-sparc64/iommu.h1
-rw-r--r--include/asm-sparc64/ipcbuf.h1
-rw-r--r--include/asm-sparc64/irq.h1
-rw-r--r--include/asm-sparc64/irq_regs.h1
-rw-r--r--include/asm-sparc64/irqflags.h1
-rw-r--r--include/asm-sparc64/kdebug.h1
-rw-r--r--include/asm-sparc64/kgdb.h1
-rw-r--r--include/asm-sparc64/kmap_types.h1
-rw-r--r--include/asm-sparc64/kprobes.h1
-rw-r--r--include/asm-sparc64/ldc.h1
-rw-r--r--include/asm-sparc64/linkage.h1
-rw-r--r--include/asm-sparc64/lmb.h1
-rw-r--r--include/asm-sparc64/local.h1
-rw-r--r--include/asm-sparc64/lsu.h1
-rw-r--r--include/asm-sparc64/mc146818rtc.h1
-rw-r--r--include/asm-sparc64/mdesc.h1
-rw-r--r--include/asm-sparc64/mman.h1
-rw-r--r--include/asm-sparc64/mmu.h1
-rw-r--r--include/asm-sparc64/mmu_context.h1
-rw-r--r--include/asm-sparc64/mmzone.h1
-rw-r--r--include/asm-sparc64/module.h1
-rw-r--r--include/asm-sparc64/mostek.h1
-rw-r--r--include/asm-sparc64/msgbuf.h1
-rw-r--r--include/asm-sparc64/mutex.h1
-rw-r--r--include/asm-sparc64/namei.h1
-rw-r--r--include/asm-sparc64/ns87303.h1
-rw-r--r--include/asm-sparc64/of_device.h1
-rw-r--r--include/asm-sparc64/of_platform.h1
-rw-r--r--include/asm-sparc64/openprom.h1
-rw-r--r--include/asm-sparc64/openpromio.h1
-rw-r--r--include/asm-sparc64/oplib.h1
-rw-r--r--include/asm-sparc64/page.h1
-rw-r--r--include/asm-sparc64/param.h1
-rw-r--r--include/asm-sparc64/parport.h1
-rw-r--r--include/asm-sparc64/pci.h1
-rw-r--r--include/asm-sparc64/percpu.h1
-rw-r--r--include/asm-sparc64/perfctr.h1
-rw-r--r--include/asm-sparc64/pgalloc.h1
-rw-r--r--include/asm-sparc64/pgtable.h1
-rw-r--r--include/asm-sparc64/pil.h1
-rw-r--r--include/asm-sparc64/poll.h1
-rw-r--r--include/asm-sparc64/posix_types.h1
-rw-r--r--include/asm-sparc64/processor.h1
-rw-r--r--include/asm-sparc64/prom.h1
-rw-r--r--include/asm-sparc64/psrcompat.h1
-rw-r--r--include/asm-sparc64/pstate.h1
-rw-r--r--include/asm-sparc64/ptrace.h1
-rw-r--r--include/asm-sparc64/reboot.h1
-rw-r--r--include/asm-sparc64/reg.h1
-rw-r--r--include/asm-sparc64/resource.h1
-rw-r--r--include/asm-sparc64/rtc.h1
-rw-r--r--include/asm-sparc64/rwsem-const.h1
-rw-r--r--include/asm-sparc64/rwsem.h1
-rw-r--r--include/asm-sparc64/sbus.h1
-rw-r--r--include/asm-sparc64/scatterlist.h1
-rw-r--r--include/asm-sparc64/scratchpad.h1
-rw-r--r--include/asm-sparc64/seccomp.h1
-rw-r--r--include/asm-sparc64/sections.h1
-rw-r--r--include/asm-sparc64/sembuf.h1
-rw-r--r--include/asm-sparc64/setup.h1
-rw-r--r--include/asm-sparc64/sfafsr.h1
-rw-r--r--include/asm-sparc64/sfp-machine.h1
-rw-r--r--include/asm-sparc64/shmbuf.h1
-rw-r--r--include/asm-sparc64/shmparam.h1
-rw-r--r--include/asm-sparc64/sigcontext.h1
-rw-r--r--include/asm-sparc64/siginfo.h1
-rw-r--r--include/asm-sparc64/signal.h1
-rw-r--r--include/asm-sparc64/smp.h1
-rw-r--r--include/asm-sparc64/socket.h1
-rw-r--r--include/asm-sparc64/sockios.h1
-rw-r--r--include/asm-sparc64/sparsemem.h1
-rw-r--r--include/asm-sparc64/spinlock.h1
-rw-r--r--include/asm-sparc64/spinlock_types.h1
-rw-r--r--include/asm-sparc64/spitfire.h1
-rw-r--r--include/asm-sparc64/sstate.h1
-rw-r--r--include/asm-sparc64/stacktrace.h1
-rw-r--r--include/asm-sparc64/starfire.h1
-rw-r--r--include/asm-sparc64/stat.h1
-rw-r--r--include/asm-sparc64/statfs.h1
-rw-r--r--include/asm-sparc64/string.h1
-rw-r--r--include/asm-sparc64/sunbpp.h1
-rw-r--r--include/asm-sparc64/syscalls.h1
-rw-r--r--include/asm-sparc64/system.h1
-rw-r--r--include/asm-sparc64/termbits.h1
-rw-r--r--include/asm-sparc64/termios.h1
-rw-r--r--include/asm-sparc64/thread_info.h1
-rw-r--r--include/asm-sparc64/timer.h1
-rw-r--r--include/asm-sparc64/timex.h1
-rw-r--r--include/asm-sparc64/tlb.h1
-rw-r--r--include/asm-sparc64/tlbflush.h1
-rw-r--r--include/asm-sparc64/topology.h1
-rw-r--r--include/asm-sparc64/tsb.h1
-rw-r--r--include/asm-sparc64/ttable.h1
-rw-r--r--include/asm-sparc64/types.h1
-rw-r--r--include/asm-sparc64/uaccess.h1
-rw-r--r--include/asm-sparc64/uctx.h1
-rw-r--r--include/asm-sparc64/unaligned.h1
-rw-r--r--include/asm-sparc64/unistd.h1
-rw-r--r--include/asm-sparc64/upa.h1
-rw-r--r--include/asm-sparc64/user.h1
-rw-r--r--include/asm-sparc64/utrap.h1
-rw-r--r--include/asm-sparc64/vga.h1
-rw-r--r--include/asm-sparc64/vio.h1
-rw-r--r--include/asm-sparc64/visasm.h1
-rw-r--r--include/asm-sparc64/watchdog.h1
-rw-r--r--include/asm-sparc64/xor.h1
-rw-r--r--include/asm-um/namei.h6
-rw-r--r--include/asm-v850/namei.h17
-rw-r--r--include/asm-x86/device.h3
-rw-r--r--include/asm-x86/dma-mapping.h121
-rw-r--r--include/asm-x86/iommu.h1
-rw-r--r--include/asm-x86/kexec.h18
-rw-r--r--include/asm-x86/kvm_host.h1
-rw-r--r--include/asm-x86/namei.h11
-rw-r--r--include/asm-x86/pgtable.h9
-rw-r--r--include/asm-x86/swiotlb.h2
-rw-r--r--include/asm-x86/uaccess.h1
-rw-r--r--include/asm-xtensa/dma-mapping.h2
-rw-r--r--include/asm-xtensa/namei.h26
-rw-r--r--include/linux/aio.h1
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/coda_linux.h2
-rw-r--r--include/linux/cpumask.h63
-rw-r--r--include/linux/fs.h103
-rw-r--r--include/linux/fs_struct.h3
-rw-r--r--include/linux/hugetlb.h5
-rw-r--r--include/linux/i2o.h2
-rw-r--r--include/linux/init.h7
-rw-r--r--include/linux/iommu-helper.h1
-rw-r--r--include/linux/jffs2.h3
-rw-r--r--include/linux/kexec.h17
-rw-r--r--include/linux/mISDNdsp.h37
-rw-r--r--include/linux/mISDNhw.h193
-rw-r--r--include/linux/mISDNif.h487
-rw-r--r--include/linux/maple.h2
-rw-r--r--include/linux/memstick.h6
-rw-r--r--include/linux/mfd/core.h30
-rw-r--r--include/linux/mlx4/qp.h4
-rw-r--r--include/linux/mm.h37
-rw-r--r--include/linux/mm_types.h4
-rw-r--r--include/linux/mmc/card.h2
-rw-r--r--include/linux/mmc/host.h2
-rw-r--r--include/linux/mmu_notifier.h279
-rw-r--r--include/linux/mount.h2
-rw-r--r--include/linux/mtd/blktrans.h2
-rw-r--r--include/linux/mtd/cfi.h1
-rw-r--r--include/linux/mtd/cfi_endian.h5
-rw-r--r--include/linux/mtd/concat.h2
-rw-r--r--include/linux/mtd/doc2000.h2
-rw-r--r--include/linux/mtd/flashchip.h3
-rw-r--r--include/linux/mtd/ftl.h2
-rw-r--r--include/linux/mtd/gen_probe.h1
-rw-r--r--include/linux/mtd/inftl.h4
-rw-r--r--include/linux/mtd/map.h1
-rw-r--r--include/linux/mtd/mtd.h2
-rw-r--r--include/linux/mtd/nand.h7
-rw-r--r--include/linux/mtd/nand_ecc.h2
-rw-r--r--include/linux/mtd/nftl.h2
-rw-r--r--include/linux/mtd/partitions.h2
-rw-r--r--include/linux/mtd/physmap.h2
-rw-r--r--include/linux/mtd/plat-ram.h2
-rw-r--r--include/linux/mtd/pmc551.h4
-rw-r--r--include/linux/mtd/xip.h2
-rw-r--r--include/linux/namei.h19
-rw-r--r--include/linux/nfs_fs.h3
-rw-r--r--include/linux/of.h1
-rw-r--r--include/linux/of_spi.h18
-rw-r--r--include/linux/pagemap.h112
-rw-r--r--include/linux/parport.h3
-rw-r--r--include/linux/pci-aspm.h5
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/pci_ids.h34
-rw-r--r--include/linux/pci_regs.h1
-rw-r--r--include/linux/percpu.h29
-rw-r--r--include/linux/proc_fs.h5
-rw-r--r--include/linux/ptrace.h72
-rw-r--r--include/linux/radix-tree.h12
-rw-r--r--include/linux/rculist.h28
-rw-r--r--include/linux/reiserfs_xattr.h2
-rw-r--r--include/linux/relay.h5
-rw-r--r--include/linux/rmap.h8
-rw-r--r--include/linux/rtc.h2
-rw-r--r--include/linux/rtnetlink.h7
-rw-r--r--include/linux/sched.h43
-rw-r--r--include/linux/security.h7
-rw-r--r--include/linux/serio.h3
-rw-r--r--include/linux/shmem_fs.h2
-rw-r--r--include/linux/slab.h3
-rw-r--r--include/linux/slub_def.h2
-rw-r--r--include/linux/smp.h5
-rw-r--r--include/linux/socket.h4
-rw-r--r--include/linux/spi/spi.h12
-rw-r--r--include/linux/ssb/ssb.h4
-rw-r--r--include/linux/stop_machine.h50
-rw-r--r--include/linux/suspend.h2
-rw-r--r--include/linux/swap.h3
-rw-r--r--include/linux/sysctl.h25
-rw-r--r--include/linux/task_io_accounting.h18
-rw-r--r--include/linux/task_io_accounting_ops.h46
-rw-r--r--include/linux/tracehook.h576
-rw-r--r--include/linux/videodev.h15
-rw-r--r--include/linux/videodev2.h386
-rw-r--r--include/linux/videotext.h16
-rw-r--r--include/media/audiochip.h26
-rw-r--r--include/media/saa7146_vv.h1
-rw-r--r--include/media/tveeprom.h7
-rw-r--r--include/media/v4l2-chip-ident.h7
-rw-r--r--include/media/v4l2-common.h31
-rw-r--r--include/media/v4l2-dev.h325
-rw-r--r--include/media/v4l2-ioctl.h301
-rw-r--r--include/mtd/inftl-user.h2
-rw-r--r--include/mtd/jffs2-user.h2
-rw-r--r--include/mtd/mtd-abi.h2
-rw-r--r--include/mtd/mtd-user.h2
-rw-r--r--include/mtd/nftl-user.h2
-rw-r--r--include/net/af_unix.h2
-rw-r--r--include/net/ip.h2
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/net_namespace.h4
-rw-r--r--include/net/request_sock.h5
-rw-r--r--include/net/route.h2
-rw-r--r--include/rdma/ib_verbs.h2
-rw-r--r--include/scsi/scsi.h3
-rw-r--r--include/scsi/scsi_cmnd.h86
-rw-r--r--include/scsi/scsi_device.h17
-rw-r--r--include/scsi/scsi_dh.h11
-rw-r--r--include/scsi/scsi_eh.h2
-rw-r--r--include/scsi/scsi_host.h86
-rw-r--r--include/video/atmel_lcdc.h1
-rw-r--r--init/Kconfig8
-rw-r--r--init/do_mounts.c2
-rw-r--r--init/do_mounts.h1
-rw-r--r--init/main.c22
-rw-r--r--ipc/mqueue.c4
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/cgroup.c3
-rw-r--r--kernel/cpu.c41
-rw-r--r--kernel/dma-coherent.c154
-rw-r--r--kernel/exec_domain.c1
-rw-r--r--kernel/exit.c85
-rw-r--r--kernel/fork.c101
-rw-r--r--kernel/irq/chip.c12
-rw-r--r--kernel/irq/manage.c3
-rw-r--r--kernel/kexec.c104
-rw-r--r--kernel/kthread.c2
-rw-r--r--kernel/module.c33
-rw-r--r--kernel/power/main.c7
-rw-r--r--kernel/power/power.h2
-rw-r--r--kernel/ptrace.c2
-rw-r--r--kernel/rcuclassic.c4
-rw-r--r--kernel/relay.c170
-rw-r--r--kernel/sched.c34
-rw-r--r--kernel/signal.c99
-rw-r--r--kernel/smp.c4
-rw-r--r--kernel/softirq.c3
-rw-r--r--kernel/softlockup.c25
-rw-r--r--kernel/stop_machine.c288
-rw-r--r--kernel/sys.c31
-rw-r--r--kernel/sysctl.c168
-rw-r--r--kernel/time/tick-common.c8
-rw-r--r--kernel/trace/ftrace.c6
-rw-r--r--kernel/trace/trace.c4
-rw-r--r--kernel/trace/trace_irqsoff.c8
-rw-r--r--kernel/trace/trace_sched_wakeup.c27
-rw-r--r--kernel/trace/trace_sysprof.c4
-rw-r--r--kernel/tsacct.c8
-rw-r--r--lib/Makefile4
-rw-r--r--lib/debugobjects.c15
-rw-r--r--lib/idr.c2
-rw-r--r--lib/iomap.c3
-rw-r--r--lib/iommu-helper.c8
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--lib/plist.c13
-rw-r--r--lib/radix-tree.c180
-rw-r--r--lib/ratelimit.c3
-rw-r--r--lib/show_mem.c63
-rw-r--r--lib/smp_processor_id.c5
-rw-r--r--lib/swiotlb.c4
-rw-r--r--lib/syscall.c75
-rw-r--r--mm/Kconfig6
-rw-r--r--mm/Makefile1
-rw-r--r--mm/allocpercpu.c20
-rw-r--r--mm/filemap.c242
-rw-r--r--mm/filemap_xip.c5
-rw-r--r--mm/fremap.c3
-rw-r--r--mm/hugetlb.c28
-rw-r--r--mm/memory.c38
-rw-r--r--mm/migrate.c29
-rw-r--r--mm/mmap.c160
-rw-r--r--mm/mmu_notifier.c277
-rw-r--r--mm/mprotect.c3
-rw-r--r--mm/mremap.c6
-rw-r--r--mm/nommu.c4
-rw-r--r--mm/page-writeback.c12
-rw-r--r--mm/page_alloc.c4
-rw-r--r--mm/readahead.c6
-rw-r--r--mm/rmap.c15
-rw-r--r--mm/shmem.c11
-rw-r--r--mm/shmem_acl.c2
-rw-r--r--mm/slab.c11
-rw-r--r--mm/slob.c7
-rw-r--r--mm/slub.c13
-rw-r--r--mm/sparse.c2
-rw-r--r--mm/swap_state.c30
-rw-r--r--mm/swapfile.c10
-rw-r--r--mm/truncate.c6
-rw-r--r--mm/util.c55
-rw-r--r--mm/vmalloc.c6
-rw-r--r--mm/vmscan.c80
-rw-r--r--net/appletalk/ddp.c4
-rw-r--r--net/bridge/netfilter/ebtable_filter.c18
-rw-r--r--net/bridge/netfilter/ebtable_nat.c18
-rw-r--r--net/core/datagram.c8
-rw-r--r--net/core/dev.c10
-rw-r--r--net/core/request_sock.c2
-rw-r--r--net/core/skbuff.c20
-rw-r--r--net/core/stream.c6
-rw-r--r--net/core/user_dma.c5
-rw-r--r--net/dccp/dccp.h4
-rw-r--r--net/dccp/input.c2
-rw-r--r--net/dccp/ipv4.c11
-rw-r--r--net/dccp/ipv6.c18
-rw-r--r--net/dccp/output.c53
-rw-r--r--net/dccp/proto.c4
-rw-r--r--net/dccp/timer.c20
-rw-r--r--net/ipv4/af_inet.c18
-rw-r--r--net/ipv4/devinet.c6
-rw-r--r--net/ipv4/inet_connection_sock.c18
-rw-r--r--net/ipv4/inet_fragment.c4
-rw-r--r--net/ipv4/inet_hashtables.c8
-rw-r--r--net/ipv4/inet_timewait_sock.c2
-rw-r--r--net/ipv4/ip_fragment.c4
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/ipcomp.c4
-rw-r--r--net/ipv4/netfilter/arptable_filter.c39
-rw-r--r--net/ipv4/netfilter/iptable_security.c2
-rw-r--r--net/ipv4/route.c13
-rw-r--r--net/ipv4/syncookies.c1
-rw-r--r--net/ipv4/sysctl_net_ipv4.c7
-rw-r--r--net/ipv4/tcp.c12
-rw-r--r--net/ipv4/tcp_input.c20
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/tcp_timer.c2
-rw-r--r--net/ipv6/addrconf.c11
-rw-r--r--net/ipv6/af_inet6.c14
-rw-r--r--net/ipv6/inet6_connection_sock.c2
-rw-r--r--net/ipv6/inet6_hashtables.c4
-rw-r--r--net/ipv6/ip6_fib.c31
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ipcomp6.c4
-rw-r--r--net/ipv6/mip6.c8
-rw-r--r--net/ipv6/netfilter/ip6table_security.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c4
-rw-r--r--net/ipv6/reassembly.c4
-rw-r--r--net/ipv6/syncookies.c1
-rw-r--r--net/ipv6/sysctl_net_ipv6.c16
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/key/af_key.c4
-rw-r--r--net/netfilter/nf_conntrack_extend.c10
-rw-r--r--net/netlink/af_netlink.c7
-rw-r--r--net/packet/af_packet.c4
-rw-r--r--net/rxrpc/af_rxrpc.c6
-rw-r--r--net/sched/act_api.c2
-rw-r--r--net/sched/act_police.c2
-rw-r--r--net/sched/cls_u32.c10
-rw-r--r--net/sched/sch_atm.c4
-rw-r--r--net/sched/sch_cbq.c4
-rw-r--r--net/sched/sch_generic.c2
-rw-r--r--net/sched/sch_htb.c16
-rw-r--r--net/sched/sch_sfq.c9
-rw-r--r--net/sctp/associola.c2
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/rpc_pipe.c2
-rw-r--r--net/sunrpc/svc.c3
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_sendto.c3
-rw-r--r--net/sysctl_net.c24
-rw-r--r--net/unix/af_unix.c10
-rw-r--r--net/unix/garbage.c18
-rw-r--r--net/xfrm/xfrm_algo.c4
-rw-r--r--net/xfrm/xfrm_ipcomp.c3
-rw-r--r--net/xfrm/xfrm_state.c2
-rw-r--r--scripts/Makefile.headersinst230
-rwxr-xr-xscripts/diffconfig129
-rwxr-xr-xscripts/hdrcheck.sh10
-rwxr-xr-xscripts/headers.sh41
-rw-r--r--scripts/headers_check.pl56
-rw-r--r--scripts/headers_install.pl45
-rw-r--r--scripts/kconfig/conf.c161
-rw-r--r--scripts/kconfig/confdata.c70
-rw-r--r--scripts/kconfig/lkc.h9
-rwxr-xr-xscripts/kernel-doc1
-rwxr-xr-xscripts/setlocalversion4
-rw-r--r--security/capability.c3
-rw-r--r--security/security.c5
-rw-r--r--security/selinux/hooks.c54
-rw-r--r--security/smack/smack_lsm.c3
-rw-r--r--sound/i2c/other/tea575x-tuner.c2
-rw-r--r--sound/isa/cs423x/cs4236.c1
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c6
-rw-r--r--sound/pci/ac97/ac97_codec.c3
-rw-r--r--sound/pci/ac97/ac97_patch.c4
-rw-r--r--sound/pci/azt3328.h4
-rw-r--r--sound/pci/ens1370.c3
-rw-r--r--sound/pci/hda/hda_intel.c6
-rw-r--r--sound/pci/hda/patch_realtek.c181
-rw-r--r--sound/pci/hda/patch_sigmatel.c14
-rw-r--r--sound/soc/au1x/psc-i2s.c2
-rw-r--r--sound/soc/codecs/wm9712.c10
-rw-r--r--sound/soc/soc-dapm.c105
2069 files changed, 68676 insertions, 23901 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 80d150458c80..d8b63d164e41 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -298,10 +298,10 @@ recommended that you never use these unless you really know what the
298cache width is. 298cache width is.
299 299
300int 300int
301dma_mapping_error(dma_addr_t dma_addr) 301dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
302 302
303int 303int
304pci_dma_mapping_error(dma_addr_t dma_addr) 304pci_dma_mapping_error(struct pci_dev *hwdev, dma_addr_t dma_addr)
305 305
306In some circumstances dma_map_single and dma_map_page will fail to create 306In some circumstances dma_map_single and dma_map_page will fail to create
307a mapping. A driver can check for these errors by testing the returned 307a mapping. A driver can check for these errors by testing the returned
diff --git a/Documentation/Intel-IOMMU.txt b/Documentation/Intel-IOMMU.txt
index c2321903aa09..21bc416d887e 100644
--- a/Documentation/Intel-IOMMU.txt
+++ b/Documentation/Intel-IOMMU.txt
@@ -48,7 +48,7 @@ IOVA generation is pretty generic. We used the same technique as vmalloc()
48but these are not global address spaces, but separate for each domain. 48but these are not global address spaces, but separate for each domain.
49Different DMA engines may support different number of domains. 49Different DMA engines may support different number of domains.
50 50
51We also allocate gaurd pages with each mapping, so we can attempt to catch 51We also allocate guard pages with each mapping, so we can attempt to catch
52any overflow that might happen. 52any overflow that might happen.
53 53
54 54
@@ -112,4 +112,4 @@ TBD
112 112
113- For compatibility testing, could use unity map domain for all devices, just 113- For compatibility testing, could use unity map domain for all devices, just
114 provide a 1-1 for all useful memory under a single domain for all devices. 114 provide a 1-1 for all useful memory under a single domain for all devices.
115- API for paravirt ops for abstracting functionlity for VMM folks. 115- API for paravirt ops for abstracting functionality for VMM folks.
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 118ca6e9404f..f79ad9ff6031 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -528,7 +528,33 @@ See more details on the proper patch format in the following
528references. 528references.
529 529
530 530
53116) Sending "git pull" requests (from Linus emails)
531 532
533Please write the git repo address and branch name alone on the same line
534so that I can't even by mistake pull from the wrong branch, and so
535that a triple-click just selects the whole thing.
536
537So the proper format is something along the lines of:
538
539 "Please pull from
540
541 git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus
542
543 to get these changes:"
544
545so that I don't have to hunt-and-peck for the address and inevitably
546get it wrong (actually, I've only gotten it wrong a few times, and
547checking against the diffstat tells me when I get it wrong, but I'm
548just a lot more comfortable when I don't have to "look for" the right
549thing to pull, and double-check that I have the right branch-name).
550
551
552Please use "git diff -M --stat --summary" to generate the diffstat:
553the -M enables rename detection, and the summary enables a summary of
554new/deleted or renamed files.
555
556With rename detection, the statistics are rather different [...]
557because git will notice that a fair number of the changes are renames.
532 558
533----------------------------------- 559-----------------------------------
534SECTION 2 - HINTS, TIPS, AND TRICKS 560SECTION 2 - HINTS, TIPS, AND TRICKS
diff --git a/Documentation/accounting/taskstats-struct.txt b/Documentation/accounting/taskstats-struct.txt
index b988d110db59..e7512c061c15 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -6,7 +6,7 @@ This document contains an explanation of the struct taskstats fields.
6There are three different groups of fields in the struct taskstats: 6There are three different groups of fields in the struct taskstats:
7 7
81) Common and basic accounting fields 81) Common and basic accounting fields
9 If CONFIG_TASKSTATS is set, the taskstats inteface is enabled and 9 If CONFIG_TASKSTATS is set, the taskstats interface is enabled and
10 the common fields and basic accounting fields are collected for 10 the common fields and basic accounting fields are collected for
11 delivery at do_exit() of a task. 11 delivery at do_exit() of a task.
122) Delay accounting fields 122) Delay accounting fields
diff --git a/Documentation/arm/Interrupts b/Documentation/arm/Interrupts
index 0d3dbf1099bc..c202ed35d7d6 100644
--- a/Documentation/arm/Interrupts
+++ b/Documentation/arm/Interrupts
@@ -138,14 +138,8 @@ So, what's changed?
138 138
139 Set active the IRQ edge(s)/level. This replaces the 139 Set active the IRQ edge(s)/level. This replaces the
140 SA1111 INTPOL manipulation, and the set_GPIO_IRQ_edge() 140 SA1111 INTPOL manipulation, and the set_GPIO_IRQ_edge()
141 function. Type should be one of the following: 141 function. Type should be one of IRQ_TYPE_xxx defined in
142 142 <linux/irq.h>
143 #define IRQT_NOEDGE (0)
144 #define IRQT_RISING (__IRQT_RISEDGE)
145 #define IRQT_FALLING (__IRQT_FALEDGE)
146 #define IRQT_BOTHEDGE (__IRQT_RISEDGE|__IRQT_FALEDGE)
147 #define IRQT_LOW (__IRQT_LOWLVL)
148 #define IRQT_HIGH (__IRQT_HIGHLVL)
149 143
1503. set_GPIO_IRQ_edge() is obsolete, and should be replaced by set_irq_type. 1443. set_GPIO_IRQ_edge() is obsolete, and should be replaced by set_irq_type.
151 145
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt
index dcec0564d040..5b0cfa67aff9 100644
--- a/Documentation/cpu-freq/governors.txt
+++ b/Documentation/cpu-freq/governors.txt
@@ -122,7 +122,7 @@ around '10000' or more.
122show_sampling_rate_(min|max): the minimum and maximum sampling rates 122show_sampling_rate_(min|max): the minimum and maximum sampling rates
123available that you may set 'sampling_rate' to. 123available that you may set 'sampling_rate' to.
124 124
125up_threshold: defines what the average CPU usaged between the samplings 125up_threshold: defines what the average CPU usage between the samplings
126of 'sampling_rate' needs to be for the kernel to make a decision on 126of 'sampling_rate' needs to be for the kernel to make a decision on
127whether it should increase the frequency. For example when it is set 127whether it should increase the frequency. For example when it is set
128to its default value of '80' it means that between the checking 128to its default value of '80' it means that between the checking
diff --git a/Documentation/edac.txt b/Documentation/edac.txt
index ced527388001..8eda3fb66416 100644
--- a/Documentation/edac.txt
+++ b/Documentation/edac.txt
@@ -327,7 +327,7 @@ Sdram memory scrubbing rate:
327 'sdram_scrub_rate' 327 'sdram_scrub_rate'
328 328
329 Read/Write attribute file that controls memory scrubbing. The scrubbing 329 Read/Write attribute file that controls memory scrubbing. The scrubbing
330 rate is set by writing a minimum bandwith in bytes/sec to the attribute 330 rate is set by writing a minimum bandwidth in bytes/sec to the attribute
331 file. The rate will be translated to an internal value that gives at 331 file. The rate will be translated to an internal value that gives at
332 least the specified rate. 332 least the specified rate.
333 333
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 721c71b86e06..c23955404bf5 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -47,6 +47,30 @@ Who: Mauro Carvalho Chehab <mchehab@infradead.org>
47 47
48--------------------------- 48---------------------------
49 49
50What: old tuner-3036 i2c driver
51When: 2.6.28
52Why: This driver is for VERY old i2c-over-parallel port teletext receiver
53 boxes. Rather then spending effort on converting this driver to V4L2,
54 and since it is extremely unlikely that anyone still uses one of these
55 devices, it was decided to drop it.
56Who: Hans Verkuil <hverkuil@xs4all.nl>
57 Mauro Carvalho Chehab <mchehab@infradead.org>
58
59 ---------------------------
60
61What: V4L2 dpc7146 driver
62When: 2.6.28
63Why: Old driver for the dpc7146 demonstration board that is no longer
64 relevant. The last time this was tested on actual hardware was
65 probably around 2002. Since this is a driver for a demonstration
66 board the decision was made to remove it rather than spending a
67 lot of effort continually updating this driver to stay in sync
68 with the latest internal V4L2 or I2C API.
69Who: Hans Verkuil <hverkuil@xs4all.nl>
70 Mauro Carvalho Chehab <mchehab@infradead.org>
71
72---------------------------
73
50What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl]) 74What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl])
51When: November 2005 75When: November 2005
52Files: drivers/pcmcia/: pcmcia_ioctl.c 76Files: drivers/pcmcia/: pcmcia_ioctl.c
diff --git a/Documentation/filesystems/omfs.txt b/Documentation/filesystems/omfs.txt
new file mode 100644
index 000000000000..1d0d41ff5c65
--- /dev/null
+++ b/Documentation/filesystems/omfs.txt
@@ -0,0 +1,106 @@
1Optimized MPEG Filesystem (OMFS)
2
3Overview
4========
5
6OMFS is a filesystem created by SonicBlue for use in the ReplayTV DVR
7and Rio Karma MP3 player. The filesystem is extent-based, utilizing
8block sizes from 2k to 8k, with hash-based directories. This
9filesystem driver may be used to read and write disks from these
10devices.
11
12Note, it is not recommended that this FS be used in place of a general
13filesystem for your own streaming media device. Native Linux filesystems
14will likely perform better.
15
16More information is available at:
17
18 http://linux-karma.sf.net/
19
20Various utilities, including mkomfs and omfsck, are included with
21omfsprogs, available at:
22
23 http://bobcopeland.com/karma/
24
25Instructions are included in its README.
26
27Options
28=======
29
30OMFS supports the following mount-time options:
31
32 uid=n - make all files owned by specified user
33 gid=n - make all files owned by specified group
34 umask=xxx - set permission umask to xxx
35 fmask=xxx - set umask to xxx for files
36 dmask=xxx - set umask to xxx for directories
37
38Disk format
39===========
40
41OMFS discriminates between "sysblocks" and normal data blocks. The sysblock
42group consists of super block information, file metadata, directory structures,
43and extents. Each sysblock has a header containing CRCs of the entire
44sysblock, and may be mirrored in successive blocks on the disk. A sysblock may
45have a smaller size than a data block, but since they are both addressed by the
46same 64-bit block number, any remaining space in the smaller sysblock is
47unused.
48
49Sysblock header information:
50
51struct omfs_header {
52 __be64 h_self; /* FS block where this is located */
53 __be32 h_body_size; /* size of useful data after header */
54 __be16 h_crc; /* crc-ccitt of body_size bytes */
55 char h_fill1[2];
56 u8 h_version; /* version, always 1 */
57 char h_type; /* OMFS_INODE_X */
58 u8 h_magic; /* OMFS_IMAGIC */
59 u8 h_check_xor; /* XOR of header bytes before this */
60 __be32 h_fill2;
61};
62
63Files and directories are both represented by omfs_inode:
64
65struct omfs_inode {
66 struct omfs_header i_head; /* header */
67 __be64 i_parent; /* parent containing this inode */
68 __be64 i_sibling; /* next inode in hash bucket */
69 __be64 i_ctime; /* ctime, in milliseconds */
70 char i_fill1[35];
71 char i_type; /* OMFS_[DIR,FILE] */
72 __be32 i_fill2;
73 char i_fill3[64];
74 char i_name[OMFS_NAMELEN]; /* filename */
75 __be64 i_size; /* size of file, in bytes */
76};
77
78Directories in OMFS are implemented as a large hash table. Filenames are
79hashed then prepended into the bucket list beginning at OMFS_DIR_START.
80Lookup requires hashing the filename, then seeking across i_sibling pointers
81until a match is found on i_name. Empty buckets are represented by block
82pointers with all-1s (~0).
83
84A file is an omfs_inode structure followed by an extent table beginning at
85OMFS_EXTENT_START:
86
87struct omfs_extent_entry {
88 __be64 e_cluster; /* start location of a set of blocks */
89 __be64 e_blocks; /* number of blocks after e_cluster */
90};
91
92struct omfs_extent {
93 __be64 e_next; /* next extent table location */
94 __be32 e_extent_count; /* total # extents in this table */
95 __be32 e_fill;
96 struct omfs_extent_entry e_entry; /* start of extent entries */
97};
98
99Each extent holds the block offset followed by number of blocks allocated to
100the extent. The final extent in each table is a terminator with e_cluster
101being ~0 and e_blocks being ones'-complement of the total number of blocks
102in the table.
103
104If this table overflows, a continuation inode is written and pointed to by
105e_next. These have a header but lack the rest of the inode structure.
106
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 8c6384bdfed4..64557821ee59 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -931,7 +931,7 @@ group_prealloc max_to_scan mb_groups mb_history min_to_scan order2_req
931stats stream_req 931stats stream_req
932 932
933mb_groups: 933mb_groups:
934This file gives the details of mutiblock allocator buddy cache of free blocks 934This file gives the details of multiblock allocator buddy cache of free blocks
935 935
936mb_history: 936mb_history:
937Multiblock allocation history. 937Multiblock allocation history.
@@ -1474,7 +1474,7 @@ used because pages_free(1355) is smaller than watermark + protection[2]
1474normal page requirement. If requirement is DMA zone(index=0), protection[0] 1474normal page requirement. If requirement is DMA zone(index=0), protection[0]
1475(=0) is used. 1475(=0) is used.
1476 1476
1477zone[i]'s protection[j] is calculated by following exprssion. 1477zone[i]'s protection[j] is calculated by following expression.
1478 1478
1479(i < j): 1479(i < j):
1480 zone[i]->protection[j] 1480 zone[i]->protection[j]
diff --git a/Documentation/filesystems/relay.txt b/Documentation/filesystems/relay.txt
index 094f2d2f38b1..510b722667ac 100644
--- a/Documentation/filesystems/relay.txt
+++ b/Documentation/filesystems/relay.txt
@@ -294,6 +294,16 @@ user-defined data with a channel, and is immediately available
294(including in create_buf_file()) via chan->private_data or 294(including in create_buf_file()) via chan->private_data or
295buf->chan->private_data. 295buf->chan->private_data.
296 296
297Buffer-only channels
298--------------------
299
300These channels have no files associated and can be created with
301relay_open(NULL, NULL, ...). Such channels are useful in scenarios such
302as when doing early tracing in the kernel, before the VFS is up. In these
303cases, one may open a buffer-only channel and then call
304relay_late_setup_files() when the kernel is ready to handle files,
305to expose the buffered data to the userspace.
306
297Channel 'modes' 307Channel 'modes'
298--------------- 308---------------
299 309
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index b7522c6cbae3..c4d348dabe94 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -143,7 +143,7 @@ struct file_system_type {
143 143
144The get_sb() method has the following arguments: 144The get_sb() method has the following arguments:
145 145
146 struct file_system_type *fs_type: decribes the filesystem, partly initialized 146 struct file_system_type *fs_type: describes the filesystem, partly initialized
147 by the specific filesystem code 147 by the specific filesystem code
148 148
149 int flags: mount flags 149 int flags: mount flags
@@ -895,9 +895,9 @@ struct dentry_operations {
895 iput() yourself 895 iput() yourself
896 896
897 d_dname: called when the pathname of a dentry should be generated. 897 d_dname: called when the pathname of a dentry should be generated.
898 Usefull for some pseudo filesystems (sockfs, pipefs, ...) to delay 898 Useful for some pseudo filesystems (sockfs, pipefs, ...) to delay
899 pathname generation. (Instead of doing it when dentry is created, 899 pathname generation. (Instead of doing it when dentry is created,
900 its done only when the path is needed.). Real filesystems probably 900 it's done only when the path is needed.). Real filesystems probably
901 dont want to use it, because their dentries are present in global 901 dont want to use it, because their dentries are present in global
902 dcache hash, so their hash should be an invariant. As no lock is 902 dcache hash, so their hash should be an invariant. As no lock is
903 held, d_dname() should not try to modify the dentry itself, unless 903 held, d_dname() should not try to modify the dentry itself, unless
diff --git a/Documentation/i2c/upgrading-clients b/Documentation/i2c/upgrading-clients
new file mode 100644
index 000000000000..9a45f9bb6a25
--- /dev/null
+++ b/Documentation/i2c/upgrading-clients
@@ -0,0 +1,281 @@
1Upgrading I2C Drivers to the new 2.6 Driver Model
2=================================================
3
4Ben Dooks <ben-linux@fluff.org>
5
6Introduction
7------------
8
9This guide outlines how to alter existing Linux 2.6 client drivers from
10the old to the new new binding methods.
11
12
13Example old-style driver
14------------------------
15
16
17struct example_state {
18 struct i2c_client client;
19 ....
20};
21
22static struct i2c_driver example_driver;
23
24static unsigned short ignore[] = { I2C_CLIENT_END };
25static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END };
26
27I2C_CLIENT_INSMOD;
28
29static int example_attach(struct i2c_adapter *adap, int addr, int kind)
30{
31 struct example_state *state;
32 struct device *dev = &adap->dev; /* to use for dev_ reports */
33 int ret;
34
35 state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
36 if (state == NULL) {
37 dev_err(dev, "failed to create our state\n");
38 return -ENOMEM;
39 }
40
41 example->client.addr = addr;
42 example->client.flags = 0;
43 example->client.adapter = adap;
44
45 i2c_set_clientdata(&state->i2c_client, state);
46 strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE);
47
48 ret = i2c_attach_client(&state->i2c_client);
49 if (ret < 0) {
50 dev_err(dev, "failed to attach client\n");
51 kfree(state);
52 return ret;
53 }
54
55 dev = &state->i2c_client.dev;
56
57 /* rest of the initialisation goes here. */
58
59 dev_info(dev, "example client created\n");
60
61 return 0;
62}
63
64static int __devexit example_detach(struct i2c_client *client)
65{
66 struct example_state *state = i2c_get_clientdata(client);
67
68 i2c_detach_client(client);
69 kfree(state);
70 return 0;
71}
72
73static int example_attach_adapter(struct i2c_adapter *adap)
74{
75 return i2c_probe(adap, &addr_data, example_attach);
76}
77
78static struct i2c_driver example_driver = {
79 .driver = {
80 .owner = THIS_MODULE,
81 .name = "example",
82 },
83 .attach_adapter = example_attach_adapter,
84 .detach_client = __devexit_p(example_detach),
85 .suspend = example_suspend,
86 .resume = example_resume,
87};
88
89
90Updating the client
91-------------------
92
93The new style binding model will check against a list of supported
94devices and their associated address supplied by the code registering
95the busses. This means that the driver .attach_adapter and
96.detach_adapter methods can be removed, along with the addr_data,
97as follows:
98
99- static struct i2c_driver example_driver;
100
101- static unsigned short ignore[] = { I2C_CLIENT_END };
102- static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END };
103
104- I2C_CLIENT_INSMOD;
105
106- static int example_attach_adapter(struct i2c_adapter *adap)
107- {
108- return i2c_probe(adap, &addr_data, example_attach);
109- }
110
111 static struct i2c_driver example_driver = {
112- .attach_adapter = example_attach_adapter,
113- .detach_client = __devexit_p(example_detach),
114 }
115
116Add the probe and remove methods to the i2c_driver, as so:
117
118 static struct i2c_driver example_driver = {
119+ .probe = example_probe,
120+ .remove = __devexit_p(example_remove),
121 }
122
123Change the example_attach method to accept the new parameters
124which include the i2c_client that it will be working with:
125
126- static int example_attach(struct i2c_adapter *adap, int addr, int kind)
127+ static int example_probe(struct i2c_client *client,
128+ const struct i2c_device_id *id)
129
130Change the name of example_attach to example_probe to align it with the
131i2c_driver entry names. The rest of the probe routine will now need to be
132changed as the i2c_client has already been setup for use.
133
134The necessary client fields have already been setup before
135the probe function is called, so the following client setup
136can be removed:
137
138- example->client.addr = addr;
139- example->client.flags = 0;
140- example->client.adapter = adap;
141-
142- strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE);
143
144The i2c_set_clientdata is now:
145
146- i2c_set_clientdata(&state->client, state);
147+ i2c_set_clientdata(client, state);
148
149The call to i2c_attach_client is no longer needed, if the probe
150routine exits successfully, then the driver will be automatically
151attached by the core. Change the probe routine as so:
152
153- ret = i2c_attach_client(&state->i2c_client);
154- if (ret < 0) {
155- dev_err(dev, "failed to attach client\n");
156- kfree(state);
157- return ret;
158- }
159
160
161Remove the storage of 'struct i2c_client' from the 'struct example_state'
162as we are provided with the i2c_client in our example_probe. Instead we
163store a pointer to it for when it is needed.
164
165struct example_state {
166- struct i2c_client client;
167+ struct i2c_client *client;
168
169the new i2c client as so:
170
171- struct device *dev = &adap->dev; /* to use for dev_ reports */
172+ struct device *dev = &i2c_client->dev; /* to use for dev_ reports */
173
174And remove the change after our client is attached, as the driver no
175longer needs to register a new client structure with the core:
176
177- dev = &state->i2c_client.dev;
178
179In the probe routine, ensure that the new state has the client stored
180in it:
181
182static int example_probe(struct i2c_client *i2c_client,
183 const struct i2c_device_id *id)
184{
185 struct example_state *state;
186 struct device *dev = &i2c_client->dev;
187 int ret;
188
189 state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
190 if (state == NULL) {
191 dev_err(dev, "failed to create our state\n");
192 return -ENOMEM;
193 }
194
195+ state->client = i2c_client;
196
197Update the detach method, by changing the name to _remove and
198to delete the i2c_detach_client call. It is possible that you
199can also remove the ret variable as it is not not needed for
200any of the core functions.
201
202- static int __devexit example_detach(struct i2c_client *client)
203+ static int __devexit example_remove(struct i2c_client *client)
204{
205 struct example_state *state = i2c_get_clientdata(client);
206
207- i2c_detach_client(client);
208
209And finally ensure that we have the correct ID table for the i2c-core
210and other utilities:
211
212+ struct i2c_device_id example_idtable[] = {
213+ { "example", 0 },
214+ { }
215+};
216+
217+MODULE_DEVICE_TABLE(i2c, example_idtable);
218
219static struct i2c_driver example_driver = {
220 .driver = {
221 .owner = THIS_MODULE,
222 .name = "example",
223 },
224+ .id_table = example_ids,
225
226
227Our driver should now look like this:
228
229struct example_state {
230 struct i2c_client *client;
231 ....
232};
233
234static int example_probe(struct i2c_client *client,
235 const struct i2c_device_id *id)
236{
237 struct example_state *state;
238 struct device *dev = &client->dev;
239
240 state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
241 if (state == NULL) {
242 dev_err(dev, "failed to create our state\n");
243 return -ENOMEM;
244 }
245
246 state->client = client;
247 i2c_set_clientdata(client, state);
248
249 /* rest of the initialisation goes here. */
250
251 dev_info(dev, "example client created\n");
252
253 return 0;
254}
255
256static int __devexit example_remove(struct i2c_client *client)
257{
258 struct example_state *state = i2c_get_clientdata(client);
259
260 kfree(state);
261 return 0;
262}
263
264static struct i2c_device_id example_idtable[] = {
265 { "example", 0 },
266 { }
267};
268
269MODULE_DEVICE_TABLE(i2c, example_idtable);
270
271static struct i2c_driver example_driver = {
272 .driver = {
273 .owner = THIS_MODULE,
274 .name = "example",
275 },
276 .id_table = example_idtable,
277 .probe = example_probe,
278 .remove = __devexit_p(example_remove),
279 .suspend = example_suspend,
280 .resume = example_resume,
281};
diff --git a/Documentation/ia64/kvm.txt b/Documentation/ia64/kvm.txt
index bec9d815da33..914d07f49268 100644
--- a/Documentation/ia64/kvm.txt
+++ b/Documentation/ia64/kvm.txt
@@ -50,9 +50,9 @@ Note: For step 2, please make sure that host page size == TARGET_PAGE_SIZE of qe
50 /usr/local/bin/qemu-system-ia64 -smp xx -m 512 -hda $your_image 50 /usr/local/bin/qemu-system-ia64 -smp xx -m 512 -hda $your_image
51 (xx is the number of virtual processors for the guest, now the maximum value is 4) 51 (xx is the number of virtual processors for the guest, now the maximum value is 4)
52 52
535. Known possibile issue on some platforms with old Firmware. 535. Known possible issue on some platforms with old Firmware.
54 54
55If meet strange host crashe issues, try to solve it through either of the following ways: 55In the event of strange host crash issues, try to solve it through either of the following ways:
56 56
57(1): Upgrade your Firmware to the latest one. 57(1): Upgrade your Firmware to the latest one.
58 58
@@ -65,8 +65,8 @@ index 0b53344..f02b0f7 100644
65 mov ar.pfs = loc1 65 mov ar.pfs = loc1
66 mov rp = loc0 66 mov rp = loc0
67 ;; 67 ;;
68- srlz.d // seralize restoration of psr.l 68- srlz.d // serialize restoration of psr.l
69+ srlz.i // seralize restoration of psr.l 69+ srlz.i // serialize restoration of psr.l
70+ ;; 70+ ;;
71 br.ret.sptk.many b0 71 br.ret.sptk.many b0
72 END(ia64_pal_call_static) 72 END(ia64_pal_call_static)
diff --git a/Documentation/input/cs461x.txt b/Documentation/input/cs461x.txt
index afe0d6543e09..202e9dbacec3 100644
--- a/Documentation/input/cs461x.txt
+++ b/Documentation/input/cs461x.txt
@@ -31,7 +31,7 @@ The driver works with ALSA drivers simultaneously. For example, the xracer
31uses joystick as input device and PCM device as sound output in one time. 31uses joystick as input device and PCM device as sound output in one time.
32There are no sound or input collisions detected. The source code have 32There are no sound or input collisions detected. The source code have
33comments about them; but I've found the joystick can be initialized 33comments about them; but I've found the joystick can be initialized
34separately of ALSA modules. So, you canm use only one joystick driver 34separately of ALSA modules. So, you can use only one joystick driver
35without ALSA drivers. The ALSA drivers are not needed to compile or 35without ALSA drivers. The ALSA drivers are not needed to compile or
36run this driver. 36run this driver.
37 37
diff --git a/Documentation/ioctl/ioctl-decoding.txt b/Documentation/ioctl/ioctl-decoding.txt
index bfdf7f3ee4f0..e35efb0cec2e 100644
--- a/Documentation/ioctl/ioctl-decoding.txt
+++ b/Documentation/ioctl/ioctl-decoding.txt
@@ -1,6 +1,6 @@
1To decode a hex IOCTL code: 1To decode a hex IOCTL code:
2 2
3Most architecures use this generic format, but check 3Most architectures use this generic format, but check
4include/ARCH/ioctl.h for specifics, e.g. powerpc 4include/ARCH/ioctl.h for specifics, e.g. powerpc
5uses 3 bits to encode read/write and 13 bits for size. 5uses 3 bits to encode read/write and 13 bits for size.
6 6
@@ -18,7 +18,7 @@ uses 3 bits to encode read/write and 13 bits for size.
18 7-0 function # 18 7-0 function #
19 19
20 20
21 So for example 0x82187201 is a read with arg length of 0x218, 21So for example 0x82187201 is a read with arg length of 0x218,
22character 'r' function 1. Grepping the source reveals this is: 22character 'r' function 1. Grepping the source reveals this is:
23 23
24#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) 24#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
diff --git a/Documentation/iostats.txt b/Documentation/iostats.txt
index 5925c3cd030d..59a69ec67c40 100644
--- a/Documentation/iostats.txt
+++ b/Documentation/iostats.txt
@@ -143,7 +143,7 @@ disk and partition statistics are consistent again. Since we still don't
143keep record of the partition-relative address, an operation is attributed to 143keep record of the partition-relative address, an operation is attributed to
144the partition which contains the first sector of the request after the 144the partition which contains the first sector of the request after the
145eventual merges. As requests can be merged across partition, this could lead 145eventual merges. As requests can be merged across partition, this could lead
146to some (probably insignificant) innacuracy. 146to some (probably insignificant) inaccuracy.
147 147
148Additional notes 148Additional notes
149---------------- 149----------------
diff --git a/Documentation/isdn/README.mISDN b/Documentation/isdn/README.mISDN
new file mode 100644
index 000000000000..cd8bf920e77b
--- /dev/null
+++ b/Documentation/isdn/README.mISDN
@@ -0,0 +1,6 @@
1mISDN is a new modular ISDN driver, in the long term it should replace
2the old I4L driver architecture for passiv ISDN cards.
3It was designed to allow a broad range of applications and interfaces
4but only have the basic function in kernel, the interface to the user
5space is based on sockets with a own address family AF_ISDN.
6
diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt
index 9691c7f5166c..0705040531a5 100644
--- a/Documentation/kdump/kdump.txt
+++ b/Documentation/kdump/kdump.txt
@@ -65,26 +65,26 @@ Install kexec-tools
65 65
662) Download the kexec-tools user-space package from the following URL: 662) Download the kexec-tools user-space package from the following URL:
67 67
68http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-tools-testing.tar.gz 68http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-tools.tar.gz
69 69
70This is a symlink to the latest version, which at the time of writing is 70This is a symlink to the latest version.
7120061214, the only release of kexec-tools-testing so far. As other versions
72are released, the older ones will remain available at
73http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/
74 71
75Note: Latest kexec-tools-testing git tree is available at 72The latest kexec-tools git tree is available at:
76 73
77git://git.kernel.org/pub/scm/linux/kernel/git/horms/kexec-tools-testing.git 74git://git.kernel.org/pub/scm/linux/kernel/git/horms/kexec-tools.git
78or 75or
79http://www.kernel.org/git/?p=linux/kernel/git/horms/kexec-tools-testing.git;a=summary 76http://www.kernel.org/git/?p=linux/kernel/git/horms/kexec-tools.git
77
78More information about kexec-tools can be found at
79http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/README.html
80 80
813) Unpack the tarball with the tar command, as follows: 813) Unpack the tarball with the tar command, as follows:
82 82
83 tar xvpzf kexec-tools-testing.tar.gz 83 tar xvpzf kexec-tools.tar.gz
84 84
854) Change to the kexec-tools directory, as follows: 854) Change to the kexec-tools directory, as follows:
86 86
87 cd kexec-tools-testing-VERSION 87 cd kexec-tools-VERSION
88 88
895) Configure the package, as follows: 895) Configure the package, as follows:
90 90
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index d5c7a57d1700..b56aacc1fff8 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -864,7 +864,7 @@ payload contents" for more information.
864 request_key_with_auxdata() respectively. 864 request_key_with_auxdata() respectively.
865 865
866 These two functions return with the key potentially still under 866 These two functions return with the key potentially still under
867 construction. To wait for contruction completion, the following should be 867 construction. To wait for construction completion, the following should be
868 called: 868 called:
869 869
870 int wait_for_key_construction(struct key *key, bool intr); 870 int wait_for_key_construction(struct key *key, bool intr);
diff --git a/Documentation/leds-class.txt b/Documentation/leds-class.txt
index 18860ad9935a..6399557cdab3 100644
--- a/Documentation/leds-class.txt
+++ b/Documentation/leds-class.txt
@@ -59,7 +59,7 @@ Hardware accelerated blink of LEDs
59 59
60Some LEDs can be programmed to blink without any CPU interaction. To 60Some LEDs can be programmed to blink without any CPU interaction. To
61support this feature, a LED driver can optionally implement the 61support this feature, a LED driver can optionally implement the
62blink_set() function (see <linux/leds.h>). If implemeted, triggers can 62blink_set() function (see <linux/leds.h>). If implemented, triggers can
63attempt to use it before falling back to software timers. The blink_set() 63attempt to use it before falling back to software timers. The blink_set()
64function should return 0 if the blink setting is supported, or -EINVAL 64function should return 0 if the blink setting is supported, or -EINVAL
65otherwise, which means that LED blinking will be handled by software. 65otherwise, which means that LED blinking will be handled by software.
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 82fafe0429fe..b88b0ea54e90 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -36,11 +36,13 @@
36#include <sched.h> 36#include <sched.h>
37#include <limits.h> 37#include <limits.h>
38#include <stddef.h> 38#include <stddef.h>
39#include <signal.h>
39#include "linux/lguest_launcher.h" 40#include "linux/lguest_launcher.h"
40#include "linux/virtio_config.h" 41#include "linux/virtio_config.h"
41#include "linux/virtio_net.h" 42#include "linux/virtio_net.h"
42#include "linux/virtio_blk.h" 43#include "linux/virtio_blk.h"
43#include "linux/virtio_console.h" 44#include "linux/virtio_console.h"
45#include "linux/virtio_rng.h"
44#include "linux/virtio_ring.h" 46#include "linux/virtio_ring.h"
45#include "asm-x86/bootparam.h" 47#include "asm-x86/bootparam.h"
46/*L:110 We can ignore the 39 include files we need for this program, but I do 48/*L:110 We can ignore the 39 include files we need for this program, but I do
@@ -64,8 +66,8 @@ typedef uint8_t u8;
64#endif 66#endif
65/* We can have up to 256 pages for devices. */ 67/* We can have up to 256 pages for devices. */
66#define DEVICE_PAGES 256 68#define DEVICE_PAGES 256
67/* This will occupy 2 pages: it must be a power of 2. */ 69/* This will occupy 3 pages: it must be a power of 2. */
68#define VIRTQUEUE_NUM 128 70#define VIRTQUEUE_NUM 256
69 71
70/*L:120 verbose is both a global flag and a macro. The C preprocessor allows 72/*L:120 verbose is both a global flag and a macro. The C preprocessor allows
71 * this, and although I wouldn't recommend it, it works quite nicely here. */ 73 * this, and although I wouldn't recommend it, it works quite nicely here. */
@@ -74,12 +76,19 @@ static bool verbose;
74 do { if (verbose) printf(args); } while(0) 76 do { if (verbose) printf(args); } while(0)
75/*:*/ 77/*:*/
76 78
77/* The pipe to send commands to the waker process */ 79/* File descriptors for the Waker. */
78static int waker_fd; 80struct {
81 int pipe[2];
82 int lguest_fd;
83} waker_fds;
84
79/* The pointer to the start of guest memory. */ 85/* The pointer to the start of guest memory. */
80static void *guest_base; 86static void *guest_base;
81/* The maximum guest physical address allowed, and maximum possible. */ 87/* The maximum guest physical address allowed, and maximum possible. */
82static unsigned long guest_limit, guest_max; 88static unsigned long guest_limit, guest_max;
89/* The pipe for signal hander to write to. */
90static int timeoutpipe[2];
91static unsigned int timeout_usec = 500;
83 92
84/* a per-cpu variable indicating whose vcpu is currently running */ 93/* a per-cpu variable indicating whose vcpu is currently running */
85static unsigned int __thread cpu_id; 94static unsigned int __thread cpu_id;
@@ -155,11 +164,14 @@ struct virtqueue
155 /* Last available index we saw. */ 164 /* Last available index we saw. */
156 u16 last_avail_idx; 165 u16 last_avail_idx;
157 166
158 /* The routine to call when the Guest pings us. */ 167 /* The routine to call when the Guest pings us, or timeout. */
159 void (*handle_output)(int fd, struct virtqueue *me); 168 void (*handle_output)(int fd, struct virtqueue *me, bool timeout);
160 169
161 /* Outstanding buffers */ 170 /* Outstanding buffers */
162 unsigned int inflight; 171 unsigned int inflight;
172
173 /* Is this blocked awaiting a timer? */
174 bool blocked;
163}; 175};
164 176
165/* Remember the arguments to the program so we can "reboot" */ 177/* Remember the arguments to the program so we can "reboot" */
@@ -190,6 +202,9 @@ static void *_convert(struct iovec *iov, size_t size, size_t align,
190 return iov->iov_base; 202 return iov->iov_base;
191} 203}
192 204
205/* Wrapper for the last available index. Makes it easier to change. */
206#define lg_last_avail(vq) ((vq)->last_avail_idx)
207
193/* The virtio configuration space is defined to be little-endian. x86 is 208/* The virtio configuration space is defined to be little-endian. x86 is
194 * little-endian too, but it's nice to be explicit so we have these helpers. */ 209 * little-endian too, but it's nice to be explicit so we have these helpers. */
195#define cpu_to_le16(v16) (v16) 210#define cpu_to_le16(v16) (v16)
@@ -199,6 +214,33 @@ static void *_convert(struct iovec *iov, size_t size, size_t align,
199#define le32_to_cpu(v32) (v32) 214#define le32_to_cpu(v32) (v32)
200#define le64_to_cpu(v64) (v64) 215#define le64_to_cpu(v64) (v64)
201 216
217/* Is this iovec empty? */
218static bool iov_empty(const struct iovec iov[], unsigned int num_iov)
219{
220 unsigned int i;
221
222 for (i = 0; i < num_iov; i++)
223 if (iov[i].iov_len)
224 return false;
225 return true;
226}
227
228/* Take len bytes from the front of this iovec. */
229static void iov_consume(struct iovec iov[], unsigned num_iov, unsigned len)
230{
231 unsigned int i;
232
233 for (i = 0; i < num_iov; i++) {
234 unsigned int used;
235
236 used = iov[i].iov_len < len ? iov[i].iov_len : len;
237 iov[i].iov_base += used;
238 iov[i].iov_len -= used;
239 len -= used;
240 }
241 assert(len == 0);
242}
243
202/* The device virtqueue descriptors are followed by feature bitmasks. */ 244/* The device virtqueue descriptors are followed by feature bitmasks. */
203static u8 *get_feature_bits(struct device *dev) 245static u8 *get_feature_bits(struct device *dev)
204{ 246{
@@ -254,6 +296,7 @@ static void *map_zeroed_pages(unsigned int num)
254 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0); 296 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, fd, 0);
255 if (addr == MAP_FAILED) 297 if (addr == MAP_FAILED)
256 err(1, "Mmaping %u pages of /dev/zero", num); 298 err(1, "Mmaping %u pages of /dev/zero", num);
299 close(fd);
257 300
258 return addr; 301 return addr;
259} 302}
@@ -540,69 +583,64 @@ static void add_device_fd(int fd)
540 * watch, but handing a file descriptor mask through to the kernel is fairly 583 * watch, but handing a file descriptor mask through to the kernel is fairly
541 * icky. 584 * icky.
542 * 585 *
543 * Instead, we fork off a process which watches the file descriptors and writes 586 * Instead, we clone off a thread which watches the file descriptors and writes
544 * the LHREQ_BREAK command to the /dev/lguest file descriptor to tell the Host 587 * the LHREQ_BREAK command to the /dev/lguest file descriptor to tell the Host
545 * stop running the Guest. This causes the Launcher to return from the 588 * stop running the Guest. This causes the Launcher to return from the
546 * /dev/lguest read with -EAGAIN, where it will write to /dev/lguest to reset 589 * /dev/lguest read with -EAGAIN, where it will write to /dev/lguest to reset
547 * the LHREQ_BREAK and wake us up again. 590 * the LHREQ_BREAK and wake us up again.
548 * 591 *
549 * This, of course, is merely a different *kind* of icky. 592 * This, of course, is merely a different *kind* of icky.
593 *
594 * Given my well-known antipathy to threads, I'd prefer to use processes. But
595 * it's easier to share Guest memory with threads, and trivial to share the
596 * devices.infds as the Launcher changes it.
550 */ 597 */
551static void wake_parent(int pipefd, int lguest_fd) 598static int waker(void *unused)
552{ 599{
553 /* Add the pipe from the Launcher to the fdset in the device_list, so 600 /* Close the write end of the pipe: only the Launcher has it open. */
554 * we watch it, too. */ 601 close(waker_fds.pipe[1]);
555 add_device_fd(pipefd);
556 602
557 for (;;) { 603 for (;;) {
558 fd_set rfds = devices.infds; 604 fd_set rfds = devices.infds;
559 unsigned long args[] = { LHREQ_BREAK, 1 }; 605 unsigned long args[] = { LHREQ_BREAK, 1 };
606 unsigned int maxfd = devices.max_infd;
607
608 /* We also listen to the pipe from the Launcher. */
609 FD_SET(waker_fds.pipe[0], &rfds);
610 if (waker_fds.pipe[0] > maxfd)
611 maxfd = waker_fds.pipe[0];
560 612
561 /* Wait until input is ready from one of the devices. */ 613 /* Wait until input is ready from one of the devices. */
562 select(devices.max_infd+1, &rfds, NULL, NULL, NULL); 614 select(maxfd+1, &rfds, NULL, NULL, NULL);
563 /* Is it a message from the Launcher? */ 615
564 if (FD_ISSET(pipefd, &rfds)) { 616 /* Message from Launcher? */
565 int fd; 617 if (FD_ISSET(waker_fds.pipe[0], &rfds)) {
566 /* If read() returns 0, it means the Launcher has 618 char c;
567 * exited. We silently follow. */ 619 /* If this fails, then assume Launcher has exited.
568 if (read(pipefd, &fd, sizeof(fd)) == 0) 620 * Don't do anything on exit: we're just a thread! */
569 exit(0); 621 if (read(waker_fds.pipe[0], &c, 1) != 1)
570 /* Otherwise it's telling us to change what file 622 _exit(0);
571 * descriptors we're to listen to. Positive means 623 continue;
572 * listen to a new one, negative means stop 624 }
573 * listening. */ 625
574 if (fd >= 0) 626 /* Send LHREQ_BREAK command to snap the Launcher out of it. */
575 FD_SET(fd, &devices.infds); 627 pwrite(waker_fds.lguest_fd, args, sizeof(args), cpu_id);
576 else
577 FD_CLR(-fd - 1, &devices.infds);
578 } else /* Send LHREQ_BREAK command. */
579 pwrite(lguest_fd, args, sizeof(args), cpu_id);
580 } 628 }
629 return 0;
581} 630}
582 631
583/* This routine just sets up a pipe to the Waker process. */ 632/* This routine just sets up a pipe to the Waker process. */
584static int setup_waker(int lguest_fd) 633static void setup_waker(int lguest_fd)
585{ 634{
586 int pipefd[2], child; 635 /* This pipe is closed when Launcher dies, telling Waker. */
587 636 if (pipe(waker_fds.pipe) != 0)
588 /* We create a pipe to talk to the Waker, and also so it knows when the 637 err(1, "Creating pipe for Waker");
589 * Launcher dies (and closes pipe). */
590 pipe(pipefd);
591 child = fork();
592 if (child == -1)
593 err(1, "forking");
594
595 if (child == 0) {
596 /* We are the Waker: close the "writing" end of our copy of the
597 * pipe and start waiting for input. */
598 close(pipefd[1]);
599 wake_parent(pipefd[0], lguest_fd);
600 }
601 /* Close the reading end of our copy of the pipe. */
602 close(pipefd[0]);
603 638
604 /* Here is the fd used to talk to the waker. */ 639 /* Waker also needs to know the lguest fd */
605 return pipefd[1]; 640 waker_fds.lguest_fd = lguest_fd;
641
642 if (clone(waker, malloc(4096) + 4096, CLONE_VM | SIGCHLD, NULL) == -1)
643 err(1, "Creating Waker");
606} 644}
607 645
608/* 646/*
@@ -661,19 +699,22 @@ static unsigned get_vq_desc(struct virtqueue *vq,
661 unsigned int *out_num, unsigned int *in_num) 699 unsigned int *out_num, unsigned int *in_num)
662{ 700{
663 unsigned int i, head; 701 unsigned int i, head;
702 u16 last_avail;
664 703
665 /* Check it isn't doing very strange things with descriptor numbers. */ 704 /* Check it isn't doing very strange things with descriptor numbers. */
666 if ((u16)(vq->vring.avail->idx - vq->last_avail_idx) > vq->vring.num) 705 last_avail = lg_last_avail(vq);
706 if ((u16)(vq->vring.avail->idx - last_avail) > vq->vring.num)
667 errx(1, "Guest moved used index from %u to %u", 707 errx(1, "Guest moved used index from %u to %u",
668 vq->last_avail_idx, vq->vring.avail->idx); 708 last_avail, vq->vring.avail->idx);
669 709
670 /* If there's nothing new since last we looked, return invalid. */ 710 /* If there's nothing new since last we looked, return invalid. */
671 if (vq->vring.avail->idx == vq->last_avail_idx) 711 if (vq->vring.avail->idx == last_avail)
672 return vq->vring.num; 712 return vq->vring.num;
673 713
674 /* Grab the next descriptor number they're advertising, and increment 714 /* Grab the next descriptor number they're advertising, and increment
675 * the index we've seen. */ 715 * the index we've seen. */
676 head = vq->vring.avail->ring[vq->last_avail_idx++ % vq->vring.num]; 716 head = vq->vring.avail->ring[last_avail % vq->vring.num];
717 lg_last_avail(vq)++;
677 718
678 /* If their number is silly, that's a fatal mistake. */ 719 /* If their number is silly, that's a fatal mistake. */
679 if (head >= vq->vring.num) 720 if (head >= vq->vring.num)
@@ -821,8 +862,8 @@ static bool handle_console_input(int fd, struct device *dev)
821 unsigned long args[] = { LHREQ_BREAK, 0 }; 862 unsigned long args[] = { LHREQ_BREAK, 0 };
822 /* Close the fd so Waker will know it has to 863 /* Close the fd so Waker will know it has to
823 * exit. */ 864 * exit. */
824 close(waker_fd); 865 close(waker_fds.pipe[1]);
825 /* Just in case waker is blocked in BREAK, send 866 /* Just in case Waker is blocked in BREAK, send
826 * unbreak now. */ 867 * unbreak now. */
827 write(fd, args, sizeof(args)); 868 write(fd, args, sizeof(args));
828 exit(2); 869 exit(2);
@@ -839,7 +880,7 @@ static bool handle_console_input(int fd, struct device *dev)
839 880
840/* Handling output for console is simple: we just get all the output buffers 881/* Handling output for console is simple: we just get all the output buffers
841 * and write them to stdout. */ 882 * and write them to stdout. */
842static void handle_console_output(int fd, struct virtqueue *vq) 883static void handle_console_output(int fd, struct virtqueue *vq, bool timeout)
843{ 884{
844 unsigned int head, out, in; 885 unsigned int head, out, in;
845 int len; 886 int len;
@@ -854,6 +895,21 @@ static void handle_console_output(int fd, struct virtqueue *vq)
854 } 895 }
855} 896}
856 897
898static void block_vq(struct virtqueue *vq)
899{
900 struct itimerval itm;
901
902 vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
903 vq->blocked = true;
904
905 itm.it_interval.tv_sec = 0;
906 itm.it_interval.tv_usec = 0;
907 itm.it_value.tv_sec = 0;
908 itm.it_value.tv_usec = timeout_usec;
909
910 setitimer(ITIMER_REAL, &itm, NULL);
911}
912
857/* 913/*
858 * The Network 914 * The Network
859 * 915 *
@@ -861,22 +917,34 @@ static void handle_console_output(int fd, struct virtqueue *vq)
861 * and write them (ignoring the first element) to this device's file descriptor 917 * and write them (ignoring the first element) to this device's file descriptor
862 * (/dev/net/tun). 918 * (/dev/net/tun).
863 */ 919 */
864static void handle_net_output(int fd, struct virtqueue *vq) 920static void handle_net_output(int fd, struct virtqueue *vq, bool timeout)
865{ 921{
866 unsigned int head, out, in; 922 unsigned int head, out, in, num = 0;
867 int len; 923 int len;
868 struct iovec iov[vq->vring.num]; 924 struct iovec iov[vq->vring.num];
925 static int last_timeout_num;
869 926
870 /* Keep getting output buffers from the Guest until we run out. */ 927 /* Keep getting output buffers from the Guest until we run out. */
871 while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) { 928 while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
872 if (in) 929 if (in)
873 errx(1, "Input buffers in output queue?"); 930 errx(1, "Input buffers in output queue?");
874 /* Check header, but otherwise ignore it (we told the Guest we 931 len = writev(vq->dev->fd, iov, out);
875 * supported no features, so it shouldn't have anything 932 if (len < 0)
876 * interesting). */ 933 err(1, "Writing network packet to tun");
877 (void)convert(&iov[0], struct virtio_net_hdr);
878 len = writev(vq->dev->fd, iov+1, out-1);
879 add_used_and_trigger(fd, vq, head, len); 934 add_used_and_trigger(fd, vq, head, len);
935 num++;
936 }
937
938 /* Block further kicks and set up a timer if we saw anything. */
939 if (!timeout && num)
940 block_vq(vq);
941
942 if (timeout) {
943 if (num < last_timeout_num)
944 timeout_usec += 10;
945 else if (timeout_usec > 1)
946 timeout_usec--;
947 last_timeout_num = num;
880 } 948 }
881} 949}
882 950
@@ -887,7 +955,6 @@ static bool handle_tun_input(int fd, struct device *dev)
887 unsigned int head, in_num, out_num; 955 unsigned int head, in_num, out_num;
888 int len; 956 int len;
889 struct iovec iov[dev->vq->vring.num]; 957 struct iovec iov[dev->vq->vring.num];
890 struct virtio_net_hdr *hdr;
891 958
892 /* First we need a network buffer from the Guests's recv virtqueue. */ 959 /* First we need a network buffer from the Guests's recv virtqueue. */
893 head = get_vq_desc(dev->vq, iov, &out_num, &in_num); 960 head = get_vq_desc(dev->vq, iov, &out_num, &in_num);
@@ -896,25 +963,23 @@ static bool handle_tun_input(int fd, struct device *dev)
896 * early, the Guest won't be ready yet. Wait until the device 963 * early, the Guest won't be ready yet. Wait until the device
897 * status says it's ready. */ 964 * status says it's ready. */
898 /* FIXME: Actually want DRIVER_ACTIVE here. */ 965 /* FIXME: Actually want DRIVER_ACTIVE here. */
899 if (dev->desc->status & VIRTIO_CONFIG_S_DRIVER_OK) 966
900 warn("network: no dma buffer!"); 967 /* Now tell it we want to know if new things appear. */
968 dev->vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY;
969 wmb();
970
901 /* We'll turn this back on if input buffers are registered. */ 971 /* We'll turn this back on if input buffers are registered. */
902 return false; 972 return false;
903 } else if (out_num) 973 } else if (out_num)
904 errx(1, "Output buffers in network recv queue?"); 974 errx(1, "Output buffers in network recv queue?");
905 975
906 /* First element is the header: we set it to 0 (no features). */
907 hdr = convert(&iov[0], struct virtio_net_hdr);
908 hdr->flags = 0;
909 hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
910
911 /* Read the packet from the device directly into the Guest's buffer. */ 976 /* Read the packet from the device directly into the Guest's buffer. */
912 len = readv(dev->fd, iov+1, in_num-1); 977 len = readv(dev->fd, iov, in_num);
913 if (len <= 0) 978 if (len <= 0)
914 err(1, "reading network"); 979 err(1, "reading network");
915 980
916 /* Tell the Guest about the new packet. */ 981 /* Tell the Guest about the new packet. */
917 add_used_and_trigger(fd, dev->vq, head, sizeof(*hdr) + len); 982 add_used_and_trigger(fd, dev->vq, head, len);
918 983
919 verbose("tun input packet len %i [%02x %02x] (%s)\n", len, 984 verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
920 ((u8 *)iov[1].iov_base)[0], ((u8 *)iov[1].iov_base)[1], 985 ((u8 *)iov[1].iov_base)[0], ((u8 *)iov[1].iov_base)[1],
@@ -927,11 +992,18 @@ static bool handle_tun_input(int fd, struct device *dev)
927/*L:215 This is the callback attached to the network and console input 992/*L:215 This is the callback attached to the network and console input
928 * virtqueues: it ensures we try again, in case we stopped console or net 993 * virtqueues: it ensures we try again, in case we stopped console or net
929 * delivery because Guest didn't have any buffers. */ 994 * delivery because Guest didn't have any buffers. */
930static void enable_fd(int fd, struct virtqueue *vq) 995static void enable_fd(int fd, struct virtqueue *vq, bool timeout)
931{ 996{
932 add_device_fd(vq->dev->fd); 997 add_device_fd(vq->dev->fd);
933 /* Tell waker to listen to it again */ 998 /* Snap the Waker out of its select loop. */
934 write(waker_fd, &vq->dev->fd, sizeof(vq->dev->fd)); 999 write(waker_fds.pipe[1], "", 1);
1000}
1001
1002static void net_enable_fd(int fd, struct virtqueue *vq, bool timeout)
1003{
1004 /* We don't need to know again when Guest refills receive buffer. */
1005 vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
1006 enable_fd(fd, vq, timeout);
935} 1007}
936 1008
937/* When the Guest tells us they updated the status field, we handle it. */ 1009/* When the Guest tells us they updated the status field, we handle it. */
@@ -951,7 +1023,7 @@ static void update_device_status(struct device *dev)
951 for (vq = dev->vq; vq; vq = vq->next) { 1023 for (vq = dev->vq; vq; vq = vq->next) {
952 memset(vq->vring.desc, 0, 1024 memset(vq->vring.desc, 0,
953 vring_size(vq->config.num, getpagesize())); 1025 vring_size(vq->config.num, getpagesize()));
954 vq->last_avail_idx = 0; 1026 lg_last_avail(vq) = 0;
955 } 1027 }
956 } else if (dev->desc->status & VIRTIO_CONFIG_S_FAILED) { 1028 } else if (dev->desc->status & VIRTIO_CONFIG_S_FAILED) {
957 warnx("Device %s configuration FAILED", dev->name); 1029 warnx("Device %s configuration FAILED", dev->name);
@@ -960,10 +1032,10 @@ static void update_device_status(struct device *dev)
960 1032
961 verbose("Device %s OK: offered", dev->name); 1033 verbose("Device %s OK: offered", dev->name);
962 for (i = 0; i < dev->desc->feature_len; i++) 1034 for (i = 0; i < dev->desc->feature_len; i++)
963 verbose(" %08x", get_feature_bits(dev)[i]); 1035 verbose(" %02x", get_feature_bits(dev)[i]);
964 verbose(", accepted"); 1036 verbose(", accepted");
965 for (i = 0; i < dev->desc->feature_len; i++) 1037 for (i = 0; i < dev->desc->feature_len; i++)
966 verbose(" %08x", get_feature_bits(dev) 1038 verbose(" %02x", get_feature_bits(dev)
967 [dev->desc->feature_len+i]); 1039 [dev->desc->feature_len+i]);
968 1040
969 if (dev->ready) 1041 if (dev->ready)
@@ -1000,7 +1072,7 @@ static void handle_output(int fd, unsigned long addr)
1000 if (strcmp(vq->dev->name, "console") != 0) 1072 if (strcmp(vq->dev->name, "console") != 0)
1001 verbose("Output to %s\n", vq->dev->name); 1073 verbose("Output to %s\n", vq->dev->name);
1002 if (vq->handle_output) 1074 if (vq->handle_output)
1003 vq->handle_output(fd, vq); 1075 vq->handle_output(fd, vq, false);
1004 return; 1076 return;
1005 } 1077 }
1006 } 1078 }
@@ -1014,6 +1086,29 @@ static void handle_output(int fd, unsigned long addr)
1014 strnlen(from_guest_phys(addr), guest_limit - addr)); 1086 strnlen(from_guest_phys(addr), guest_limit - addr));
1015} 1087}
1016 1088
1089static void handle_timeout(int fd)
1090{
1091 char buf[32];
1092 struct device *i;
1093 struct virtqueue *vq;
1094
1095 /* Clear the pipe */
1096 read(timeoutpipe[0], buf, sizeof(buf));
1097
1098 /* Check each device and virtqueue: flush blocked ones. */
1099 for (i = devices.dev; i; i = i->next) {
1100 for (vq = i->vq; vq; vq = vq->next) {
1101 if (!vq->blocked)
1102 continue;
1103
1104 vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY;
1105 vq->blocked = false;
1106 if (vq->handle_output)
1107 vq->handle_output(fd, vq, true);
1108 }
1109 }
1110}
1111
1017/* This is called when the Waker wakes us up: check for incoming file 1112/* This is called when the Waker wakes us up: check for incoming file
1018 * descriptors. */ 1113 * descriptors. */
1019static void handle_input(int fd) 1114static void handle_input(int fd)
@@ -1024,16 +1119,20 @@ static void handle_input(int fd)
1024 for (;;) { 1119 for (;;) {
1025 struct device *i; 1120 struct device *i;
1026 fd_set fds = devices.infds; 1121 fd_set fds = devices.infds;
1122 int num;
1027 1123
1124 num = select(devices.max_infd+1, &fds, NULL, NULL, &poll);
1125 /* Could get interrupted */
1126 if (num < 0)
1127 continue;
1028 /* If nothing is ready, we're done. */ 1128 /* If nothing is ready, we're done. */
1029 if (select(devices.max_infd+1, &fds, NULL, NULL, &poll) == 0) 1129 if (num == 0)
1030 break; 1130 break;
1031 1131
1032 /* Otherwise, call the device(s) which have readable file 1132 /* Otherwise, call the device(s) which have readable file
1033 * descriptors and a method of handling them. */ 1133 * descriptors and a method of handling them. */
1034 for (i = devices.dev; i; i = i->next) { 1134 for (i = devices.dev; i; i = i->next) {
1035 if (i->handle_input && FD_ISSET(i->fd, &fds)) { 1135 if (i->handle_input && FD_ISSET(i->fd, &fds)) {
1036 int dev_fd;
1037 if (i->handle_input(fd, i)) 1136 if (i->handle_input(fd, i))
1038 continue; 1137 continue;
1039 1138
@@ -1043,13 +1142,12 @@ static void handle_input(int fd)
1043 * buffers to deliver into. Console also uses 1142 * buffers to deliver into. Console also uses
1044 * it when it discovers that stdin is closed. */ 1143 * it when it discovers that stdin is closed. */
1045 FD_CLR(i->fd, &devices.infds); 1144 FD_CLR(i->fd, &devices.infds);
1046 /* Tell waker to ignore it too, by sending a
1047 * negative fd number (-1, since 0 is a valid
1048 * FD number). */
1049 dev_fd = -i->fd - 1;
1050 write(waker_fd, &dev_fd, sizeof(dev_fd));
1051 } 1145 }
1052 } 1146 }
1147
1148 /* Is this the timeout fd? */
1149 if (FD_ISSET(timeoutpipe[0], &fds))
1150 handle_timeout(fd);
1053 } 1151 }
1054} 1152}
1055 1153
@@ -1098,7 +1196,7 @@ static struct lguest_device_desc *new_dev_desc(u16 type)
1098/* Each device descriptor is followed by the description of its virtqueues. We 1196/* Each device descriptor is followed by the description of its virtqueues. We
1099 * specify how many descriptors the virtqueue is to have. */ 1197 * specify how many descriptors the virtqueue is to have. */
1100static void add_virtqueue(struct device *dev, unsigned int num_descs, 1198static void add_virtqueue(struct device *dev, unsigned int num_descs,
1101 void (*handle_output)(int fd, struct virtqueue *me)) 1199 void (*handle_output)(int, struct virtqueue *, bool))
1102{ 1200{
1103 unsigned int pages; 1201 unsigned int pages;
1104 struct virtqueue **i, *vq = malloc(sizeof(*vq)); 1202 struct virtqueue **i, *vq = malloc(sizeof(*vq));
@@ -1114,6 +1212,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
1114 vq->last_avail_idx = 0; 1212 vq->last_avail_idx = 0;
1115 vq->dev = dev; 1213 vq->dev = dev;
1116 vq->inflight = 0; 1214 vq->inflight = 0;
1215 vq->blocked = false;
1117 1216
1118 /* Initialize the configuration. */ 1217 /* Initialize the configuration. */
1119 vq->config.num = num_descs; 1218 vq->config.num = num_descs;
@@ -1246,6 +1345,24 @@ static void setup_console(void)
1246} 1345}
1247/*:*/ 1346/*:*/
1248 1347
1348static void timeout_alarm(int sig)
1349{
1350 write(timeoutpipe[1], "", 1);
1351}
1352
1353static void setup_timeout(void)
1354{
1355 if (pipe(timeoutpipe) != 0)
1356 err(1, "Creating timeout pipe");
1357
1358 if (fcntl(timeoutpipe[1], F_SETFL,
1359 fcntl(timeoutpipe[1], F_GETFL) | O_NONBLOCK) != 0)
1360 err(1, "Making timeout pipe nonblocking");
1361
1362 add_device_fd(timeoutpipe[0]);
1363 signal(SIGALRM, timeout_alarm);
1364}
1365
1249/*M:010 Inter-guest networking is an interesting area. Simplest is to have a 1366/*M:010 Inter-guest networking is an interesting area. Simplest is to have a
1250 * --sharenet=<name> option which opens or creates a named pipe. This can be 1367 * --sharenet=<name> option which opens or creates a named pipe. This can be
1251 * used to send packets to another guest in a 1:1 manner. 1368 * used to send packets to another guest in a 1:1 manner.
@@ -1264,10 +1381,25 @@ static void setup_console(void)
1264 1381
1265static u32 str2ip(const char *ipaddr) 1382static u32 str2ip(const char *ipaddr)
1266{ 1383{
1267 unsigned int byte[4]; 1384 unsigned int b[4];
1268 1385
1269 sscanf(ipaddr, "%u.%u.%u.%u", &byte[0], &byte[1], &byte[2], &byte[3]); 1386 if (sscanf(ipaddr, "%u.%u.%u.%u", &b[0], &b[1], &b[2], &b[3]) != 4)
1270 return (byte[0] << 24) | (byte[1] << 16) | (byte[2] << 8) | byte[3]; 1387 errx(1, "Failed to parse IP address '%s'", ipaddr);
1388 return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
1389}
1390
1391static void str2mac(const char *macaddr, unsigned char mac[6])
1392{
1393 unsigned int m[6];
1394 if (sscanf(macaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
1395 &m[0], &m[1], &m[2], &m[3], &m[4], &m[5]) != 6)
1396 errx(1, "Failed to parse mac address '%s'", macaddr);
1397 mac[0] = m[0];
1398 mac[1] = m[1];
1399 mac[2] = m[2];
1400 mac[3] = m[3];
1401 mac[4] = m[4];
1402 mac[5] = m[5];
1271} 1403}
1272 1404
1273/* This code is "adapted" from libbridge: it attaches the Host end of the 1405/* This code is "adapted" from libbridge: it attaches the Host end of the
@@ -1288,6 +1420,7 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name)
1288 errx(1, "interface %s does not exist!", if_name); 1420 errx(1, "interface %s does not exist!", if_name);
1289 1421
1290 strncpy(ifr.ifr_name, br_name, IFNAMSIZ); 1422 strncpy(ifr.ifr_name, br_name, IFNAMSIZ);
1423 ifr.ifr_name[IFNAMSIZ-1] = '\0';
1291 ifr.ifr_ifindex = ifidx; 1424 ifr.ifr_ifindex = ifidx;
1292 if (ioctl(fd, SIOCBRADDIF, &ifr) < 0) 1425 if (ioctl(fd, SIOCBRADDIF, &ifr) < 0)
1293 err(1, "can't add %s to bridge %s", if_name, br_name); 1426 err(1, "can't add %s to bridge %s", if_name, br_name);
@@ -1296,64 +1429,90 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name)
1296/* This sets up the Host end of the network device with an IP address, brings 1429/* This sets up the Host end of the network device with an IP address, brings
1297 * it up so packets will flow, the copies the MAC address into the hwaddr 1430 * it up so packets will flow, the copies the MAC address into the hwaddr
1298 * pointer. */ 1431 * pointer. */
1299static void configure_device(int fd, const char *devname, u32 ipaddr, 1432static void configure_device(int fd, const char *tapif, u32 ipaddr)
1300 unsigned char hwaddr[6])
1301{ 1433{
1302 struct ifreq ifr; 1434 struct ifreq ifr;
1303 struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr; 1435 struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
1304 1436
1305 /* Don't read these incantations. Just cut & paste them like I did! */
1306 memset(&ifr, 0, sizeof(ifr)); 1437 memset(&ifr, 0, sizeof(ifr));
1307 strcpy(ifr.ifr_name, devname); 1438 strcpy(ifr.ifr_name, tapif);
1439
1440 /* Don't read these incantations. Just cut & paste them like I did! */
1308 sin->sin_family = AF_INET; 1441 sin->sin_family = AF_INET;
1309 sin->sin_addr.s_addr = htonl(ipaddr); 1442 sin->sin_addr.s_addr = htonl(ipaddr);
1310 if (ioctl(fd, SIOCSIFADDR, &ifr) != 0) 1443 if (ioctl(fd, SIOCSIFADDR, &ifr) != 0)
1311 err(1, "Setting %s interface address", devname); 1444 err(1, "Setting %s interface address", tapif);
1312 ifr.ifr_flags = IFF_UP; 1445 ifr.ifr_flags = IFF_UP;
1313 if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0) 1446 if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0)
1314 err(1, "Bringing interface %s up", devname); 1447 err(1, "Bringing interface %s up", tapif);
1448}
1449
1450static void get_mac(int fd, const char *tapif, unsigned char hwaddr[6])
1451{
1452 struct ifreq ifr;
1453
1454 memset(&ifr, 0, sizeof(ifr));
1455 strcpy(ifr.ifr_name, tapif);
1315 1456
1316 /* SIOC stands for Socket I/O Control. G means Get (vs S for Set 1457 /* SIOC stands for Socket I/O Control. G means Get (vs S for Set
1317 * above). IF means Interface, and HWADDR is hardware address. 1458 * above). IF means Interface, and HWADDR is hardware address.
1318 * Simple! */ 1459 * Simple! */
1319 if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0) 1460 if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0)
1320 err(1, "getting hw address for %s", devname); 1461 err(1, "getting hw address for %s", tapif);
1321 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); 1462 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6);
1322} 1463}
1323 1464
1324/*L:195 Our network is a Host<->Guest network. This can either use bridging or 1465static int get_tun_device(char tapif[IFNAMSIZ])
1325 * routing, but the principle is the same: it uses the "tun" device to inject
1326 * packets into the Host as if they came in from a normal network card. We
1327 * just shunt packets between the Guest and the tun device. */
1328static void setup_tun_net(const char *arg)
1329{ 1466{
1330 struct device *dev;
1331 struct ifreq ifr; 1467 struct ifreq ifr;
1332 int netfd, ipfd; 1468 int netfd;
1333 u32 ip; 1469
1334 const char *br_name = NULL; 1470 /* Start with this zeroed. Messy but sure. */
1335 struct virtio_net_config conf; 1471 memset(&ifr, 0, sizeof(ifr));
1336 1472
1337 /* We open the /dev/net/tun device and tell it we want a tap device. A 1473 /* We open the /dev/net/tun device and tell it we want a tap device. A
1338 * tap device is like a tun device, only somehow different. To tell 1474 * tap device is like a tun device, only somehow different. To tell
1339 * the truth, I completely blundered my way through this code, but it 1475 * the truth, I completely blundered my way through this code, but it
1340 * works now! */ 1476 * works now! */
1341 netfd = open_or_die("/dev/net/tun", O_RDWR); 1477 netfd = open_or_die("/dev/net/tun", O_RDWR);
1342 memset(&ifr, 0, sizeof(ifr)); 1478 ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
1343 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
1344 strcpy(ifr.ifr_name, "tap%d"); 1479 strcpy(ifr.ifr_name, "tap%d");
1345 if (ioctl(netfd, TUNSETIFF, &ifr) != 0) 1480 if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
1346 err(1, "configuring /dev/net/tun"); 1481 err(1, "configuring /dev/net/tun");
1482
1483 if (ioctl(netfd, TUNSETOFFLOAD,
1484 TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
1485 err(1, "Could not set features for tun device");
1486
1347 /* We don't need checksums calculated for packets coming in this 1487 /* We don't need checksums calculated for packets coming in this
1348 * device: trust us! */ 1488 * device: trust us! */
1349 ioctl(netfd, TUNSETNOCSUM, 1); 1489 ioctl(netfd, TUNSETNOCSUM, 1);
1350 1490
1491 memcpy(tapif, ifr.ifr_name, IFNAMSIZ);
1492 return netfd;
1493}
1494
1495/*L:195 Our network is a Host<->Guest network. This can either use bridging or
1496 * routing, but the principle is the same: it uses the "tun" device to inject
1497 * packets into the Host as if they came in from a normal network card. We
1498 * just shunt packets between the Guest and the tun device. */
1499static void setup_tun_net(char *arg)
1500{
1501 struct device *dev;
1502 int netfd, ipfd;
1503 u32 ip = INADDR_ANY;
1504 bool bridging = false;
1505 char tapif[IFNAMSIZ], *p;
1506 struct virtio_net_config conf;
1507
1508 netfd = get_tun_device(tapif);
1509
1351 /* First we create a new network device. */ 1510 /* First we create a new network device. */
1352 dev = new_device("net", VIRTIO_ID_NET, netfd, handle_tun_input); 1511 dev = new_device("net", VIRTIO_ID_NET, netfd, handle_tun_input);
1353 1512
1354 /* Network devices need a receive and a send queue, just like 1513 /* Network devices need a receive and a send queue, just like
1355 * console. */ 1514 * console. */
1356 add_virtqueue(dev, VIRTQUEUE_NUM, enable_fd); 1515 add_virtqueue(dev, VIRTQUEUE_NUM, net_enable_fd);
1357 add_virtqueue(dev, VIRTQUEUE_NUM, handle_net_output); 1516 add_virtqueue(dev, VIRTQUEUE_NUM, handle_net_output);
1358 1517
1359 /* We need a socket to perform the magic network ioctls to bring up the 1518 /* We need a socket to perform the magic network ioctls to bring up the
@@ -1364,28 +1523,56 @@ static void setup_tun_net(const char *arg)
1364 1523
1365 /* If the command line was --tunnet=bridge:<name> do bridging. */ 1524 /* If the command line was --tunnet=bridge:<name> do bridging. */
1366 if (!strncmp(BRIDGE_PFX, arg, strlen(BRIDGE_PFX))) { 1525 if (!strncmp(BRIDGE_PFX, arg, strlen(BRIDGE_PFX))) {
1367 ip = INADDR_ANY; 1526 arg += strlen(BRIDGE_PFX);
1368 br_name = arg + strlen(BRIDGE_PFX); 1527 bridging = true;
1369 add_to_bridge(ipfd, ifr.ifr_name, br_name); 1528 }
1370 } else /* It is an IP address to set up the device with */ 1529
1530 /* A mac address may follow the bridge name or IP address */
1531 p = strchr(arg, ':');
1532 if (p) {
1533 str2mac(p+1, conf.mac);
1534 *p = '\0';
1535 } else {
1536 p = arg + strlen(arg);
1537 /* None supplied; query the randomly assigned mac. */
1538 get_mac(ipfd, tapif, conf.mac);
1539 }
1540
1541 /* arg is now either an IP address or a bridge name */
1542 if (bridging)
1543 add_to_bridge(ipfd, tapif, arg);
1544 else
1371 ip = str2ip(arg); 1545 ip = str2ip(arg);
1372 1546
1373 /* Set up the tun device, and get the mac address for the interface. */ 1547 /* Set up the tun device. */
1374 configure_device(ipfd, ifr.ifr_name, ip, conf.mac); 1548 configure_device(ipfd, tapif, ip);
1375 1549
1376 /* Tell Guest what MAC address to use. */ 1550 /* Tell Guest what MAC address to use. */
1377 add_feature(dev, VIRTIO_NET_F_MAC); 1551 add_feature(dev, VIRTIO_NET_F_MAC);
1378 add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); 1552 add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
1553 /* Expect Guest to handle everything except UFO */
1554 add_feature(dev, VIRTIO_NET_F_CSUM);
1555 add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
1556 add_feature(dev, VIRTIO_NET_F_MAC);
1557 add_feature(dev, VIRTIO_NET_F_GUEST_TSO4);
1558 add_feature(dev, VIRTIO_NET_F_GUEST_TSO6);
1559 add_feature(dev, VIRTIO_NET_F_GUEST_ECN);
1560 add_feature(dev, VIRTIO_NET_F_HOST_TSO4);
1561 add_feature(dev, VIRTIO_NET_F_HOST_TSO6);
1562 add_feature(dev, VIRTIO_NET_F_HOST_ECN);
1379 set_config(dev, sizeof(conf), &conf); 1563 set_config(dev, sizeof(conf), &conf);
1380 1564
1381 /* We don't need the socket any more; setup is done. */ 1565 /* We don't need the socket any more; setup is done. */
1382 close(ipfd); 1566 close(ipfd);
1383 1567
1384 verbose("device %u: tun net %u.%u.%u.%u\n", 1568 devices.device_num++;
1385 devices.device_num++, 1569
1386 (u8)(ip>>24),(u8)(ip>>16),(u8)(ip>>8),(u8)ip); 1570 if (bridging)
1387 if (br_name) 1571 verbose("device %u: tun %s attached to bridge: %s\n",
1388 verbose("attached to bridge: %s\n", br_name); 1572 devices.device_num, tapif, arg);
1573 else
1574 verbose("device %u: tun %s: %s\n",
1575 devices.device_num, tapif, arg);
1389} 1576}
1390 1577
1391/* Our block (disk) device should be really simple: the Guest asks for a block 1578/* Our block (disk) device should be really simple: the Guest asks for a block
@@ -1550,7 +1737,7 @@ static bool handle_io_finish(int fd, struct device *dev)
1550} 1737}
1551 1738
1552/* When the Guest submits some I/O, we just need to wake the I/O thread. */ 1739/* When the Guest submits some I/O, we just need to wake the I/O thread. */
1553static void handle_virtblk_output(int fd, struct virtqueue *vq) 1740static void handle_virtblk_output(int fd, struct virtqueue *vq, bool timeout)
1554{ 1741{
1555 struct vblk_info *vblk = vq->dev->priv; 1742 struct vblk_info *vblk = vq->dev->priv;
1556 char c = 0; 1743 char c = 0;
@@ -1621,6 +1808,64 @@ static void setup_block_file(const char *filename)
1621 verbose("device %u: virtblock %llu sectors\n", 1808 verbose("device %u: virtblock %llu sectors\n",
1622 devices.device_num, le64_to_cpu(conf.capacity)); 1809 devices.device_num, le64_to_cpu(conf.capacity));
1623} 1810}
1811
1812/* Our random number generator device reads from /dev/random into the Guest's
1813 * input buffers. The usual case is that the Guest doesn't want random numbers
1814 * and so has no buffers although /dev/random is still readable, whereas
1815 * console is the reverse.
1816 *
1817 * The same logic applies, however. */
1818static bool handle_rng_input(int fd, struct device *dev)
1819{
1820 int len;
1821 unsigned int head, in_num, out_num, totlen = 0;
1822 struct iovec iov[dev->vq->vring.num];
1823
1824 /* First we need a buffer from the Guests's virtqueue. */
1825 head = get_vq_desc(dev->vq, iov, &out_num, &in_num);
1826
1827 /* If they're not ready for input, stop listening to this file
1828 * descriptor. We'll start again once they add an input buffer. */
1829 if (head == dev->vq->vring.num)
1830 return false;
1831
1832 if (out_num)
1833 errx(1, "Output buffers in rng?");
1834
1835 /* This is why we convert to iovecs: the readv() call uses them, and so
1836 * it reads straight into the Guest's buffer. We loop to make sure we
1837 * fill it. */
1838 while (!iov_empty(iov, in_num)) {
1839 len = readv(dev->fd, iov, in_num);
1840 if (len <= 0)
1841 err(1, "Read from /dev/random gave %i", len);
1842 iov_consume(iov, in_num, len);
1843 totlen += len;
1844 }
1845
1846 /* Tell the Guest about the new input. */
1847 add_used_and_trigger(fd, dev->vq, head, totlen);
1848
1849 /* Everything went OK! */
1850 return true;
1851}
1852
1853/* And this creates a "hardware" random number device for the Guest. */
1854static void setup_rng(void)
1855{
1856 struct device *dev;
1857 int fd;
1858
1859 fd = open_or_die("/dev/random", O_RDONLY);
1860
1861 /* The device responds to return from I/O thread. */
1862 dev = new_device("rng", VIRTIO_ID_RNG, fd, handle_rng_input);
1863
1864 /* The device has one virtqueue, where the Guest places inbufs. */
1865 add_virtqueue(dev, VIRTQUEUE_NUM, enable_fd);
1866
1867 verbose("device %u: rng\n", devices.device_num++);
1868}
1624/* That's the end of device setup. */ 1869/* That's the end of device setup. */
1625 1870
1626/*L:230 Reboot is pretty easy: clean up and exec() the Launcher afresh. */ 1871/*L:230 Reboot is pretty easy: clean up and exec() the Launcher afresh. */
@@ -1628,11 +1873,12 @@ static void __attribute__((noreturn)) restart_guest(void)
1628{ 1873{
1629 unsigned int i; 1874 unsigned int i;
1630 1875
1631 /* Closing pipes causes the Waker thread and io_threads to die, and 1876 /* Since we don't track all open fds, we simply close everything beyond
1632 * closing /dev/lguest cleans up the Guest. Since we don't track all 1877 * stderr. */
1633 * open fds, we simply close everything beyond stderr. */
1634 for (i = 3; i < FD_SETSIZE; i++) 1878 for (i = 3; i < FD_SETSIZE; i++)
1635 close(i); 1879 close(i);
1880
1881 /* The exec automatically gets rid of the I/O and Waker threads. */
1636 execv(main_args[0], main_args); 1882 execv(main_args[0], main_args);
1637 err(1, "Could not exec %s", main_args[0]); 1883 err(1, "Could not exec %s", main_args[0]);
1638} 1884}
@@ -1663,7 +1909,7 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1663 /* ERESTART means that we need to reboot the guest */ 1909 /* ERESTART means that we need to reboot the guest */
1664 } else if (errno == ERESTART) { 1910 } else if (errno == ERESTART) {
1665 restart_guest(); 1911 restart_guest();
1666 /* EAGAIN means the Waker wanted us to look at some input. 1912 /* EAGAIN means a signal (timeout).
1667 * Anything else means a bug or incompatible change. */ 1913 * Anything else means a bug or incompatible change. */
1668 } else if (errno != EAGAIN) 1914 } else if (errno != EAGAIN)
1669 err(1, "Running guest failed"); 1915 err(1, "Running guest failed");
@@ -1691,13 +1937,14 @@ static struct option opts[] = {
1691 { "verbose", 0, NULL, 'v' }, 1937 { "verbose", 0, NULL, 'v' },
1692 { "tunnet", 1, NULL, 't' }, 1938 { "tunnet", 1, NULL, 't' },
1693 { "block", 1, NULL, 'b' }, 1939 { "block", 1, NULL, 'b' },
1940 { "rng", 0, NULL, 'r' },
1694 { "initrd", 1, NULL, 'i' }, 1941 { "initrd", 1, NULL, 'i' },
1695 { NULL }, 1942 { NULL },
1696}; 1943};
1697static void usage(void) 1944static void usage(void)
1698{ 1945{
1699 errx(1, "Usage: lguest [--verbose] " 1946 errx(1, "Usage: lguest [--verbose] "
1700 "[--tunnet=(<ipaddr>|bridge:<bridgename>)\n" 1947 "[--tunnet=(<ipaddr>:<macaddr>|bridge:<bridgename>:<macaddr>)\n"
1701 "|--block=<filename>|--initrd=<filename>]...\n" 1948 "|--block=<filename>|--initrd=<filename>]...\n"
1702 "<mem-in-mb> vmlinux [args...]"); 1949 "<mem-in-mb> vmlinux [args...]");
1703} 1950}
@@ -1765,6 +2012,9 @@ int main(int argc, char *argv[])
1765 case 'b': 2012 case 'b':
1766 setup_block_file(optarg); 2013 setup_block_file(optarg);
1767 break; 2014 break;
2015 case 'r':
2016 setup_rng();
2017 break;
1768 case 'i': 2018 case 'i':
1769 initrd_name = optarg; 2019 initrd_name = optarg;
1770 break; 2020 break;
@@ -1783,6 +2033,9 @@ int main(int argc, char *argv[])
1783 /* We always have a console device */ 2033 /* We always have a console device */
1784 setup_console(); 2034 setup_console();
1785 2035
2036 /* We can timeout waiting for Guest network transmit. */
2037 setup_timeout();
2038
1786 /* Now we load the kernel */ 2039 /* Now we load the kernel */
1787 start = load_kernel(open_or_die(argv[optind+1], O_RDONLY)); 2040 start = load_kernel(open_or_die(argv[optind+1], O_RDONLY));
1788 2041
@@ -1826,10 +2079,10 @@ int main(int argc, char *argv[])
1826 * /dev/lguest file descriptor. */ 2079 * /dev/lguest file descriptor. */
1827 lguest_fd = tell_kernel(pgdir, start); 2080 lguest_fd = tell_kernel(pgdir, start);
1828 2081
1829 /* We fork off a child process, which wakes the Launcher whenever one 2082 /* We clone off a thread, which wakes the Launcher whenever one of the
1830 * of the input file descriptors needs attention. We call this the 2083 * input file descriptors needs attention. We call this the Waker, and
1831 * Waker, and we'll cover it in a moment. */ 2084 * we'll cover it in a moment. */
1832 waker_fd = setup_waker(lguest_fd); 2085 setup_waker(lguest_fd);
1833 2086
1834 /* Finally, run the Guest. This doesn't return. */ 2087 /* Finally, run the Guest. This doesn't return. */
1835 run_guest(lguest_fd); 2088 run_guest(lguest_fd);
diff --git a/Documentation/local_ops.txt b/Documentation/local_ops.txt
index 4269a1105b37..f4f8b1c6c8ba 100644
--- a/Documentation/local_ops.txt
+++ b/Documentation/local_ops.txt
@@ -36,7 +36,7 @@ It can be done by slightly modifying the standard atomic operations : only
36their UP variant must be kept. It typically means removing LOCK prefix (on 36their UP variant must be kept. It typically means removing LOCK prefix (on
37i386 and x86_64) and any SMP sychronization barrier. If the architecture does 37i386 and x86_64) and any SMP sychronization barrier. If the architecture does
38not have a different behavior between SMP and UP, including asm-generic/local.h 38not have a different behavior between SMP and UP, including asm-generic/local.h
39in your archtecture's local.h is sufficient. 39in your architecture's local.h is sufficient.
40 40
41The local_t type is defined as an opaque signed long by embedding an 41The local_t type is defined as an opaque signed long by embedding an
42atomic_long_t inside a structure. This is made so a cast from this type to a 42atomic_long_t inside a structure. This is made so a cast from this type to a
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 7fa7fe71d7a8..688dfe1e6b70 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -631,7 +631,7 @@ xmit_hash_policy
631 in environments where a layer3 gateway device is 631 in environments where a layer3 gateway device is
632 required to reach most destinations. 632 required to reach most destinations.
633 633
634 This algorithm is 802.3ad complient. 634 This algorithm is 802.3ad compliant.
635 635
636 layer3+4 636 layer3+4
637 637
diff --git a/Documentation/networking/can.txt b/Documentation/networking/can.txt
index 641d2afacffa..297ba7b1ccaf 100644
--- a/Documentation/networking/can.txt
+++ b/Documentation/networking/can.txt
@@ -186,7 +186,7 @@ solution for a couple of reasons:
186 186
187 The Linux network devices (by default) just can handle the 187 The Linux network devices (by default) just can handle the
188 transmission and reception of media dependent frames. Due to the 188 transmission and reception of media dependent frames. Due to the
189 arbritration on the CAN bus the transmission of a low prio CAN-ID 189 arbitration on the CAN bus the transmission of a low prio CAN-ID
190 may be delayed by the reception of a high prio CAN frame. To 190 may be delayed by the reception of a high prio CAN frame. To
191 reflect the correct* traffic on the node the loopback of the sent 191 reflect the correct* traffic on the node the loopback of the sent
192 data has to be performed right after a successful transmission. If 192 data has to be performed right after a successful transmission. If
@@ -481,7 +481,7 @@ solution for a couple of reasons:
481 - stats_timer: To calculate the Socket CAN core statistics 481 - stats_timer: To calculate the Socket CAN core statistics
482 (e.g. current/maximum frames per second) this 1 second timer is 482 (e.g. current/maximum frames per second) this 1 second timer is
483 invoked at can.ko module start time by default. This timer can be 483 invoked at can.ko module start time by default. This timer can be
484 disabled by using stattimer=0 on the module comandline. 484 disabled by using stattimer=0 on the module commandline.
485 485
486 - debug: (removed since SocketCAN SVN r546) 486 - debug: (removed since SocketCAN SVN r546)
487 487
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index db0cd5169581..07c53d596035 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -326,7 +326,7 @@ just one call to mmap is needed:
326 mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 326 mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
327 327
328If tp_frame_size is a divisor of tp_block_size frames will be 328If tp_frame_size is a divisor of tp_block_size frames will be
329contiguosly spaced by tp_frame_size bytes. If not, each 329contiguously spaced by tp_frame_size bytes. If not, each
330tp_block_size/tp_frame_size frames there will be a gap between 330tp_block_size/tp_frame_size frames there will be a gap between
331the frames. This is because a frame cannot be spawn across two 331the frames. This is because a frame cannot be spawn across two
332blocks. 332blocks.
diff --git a/Documentation/networking/tc-actions-env-rules.txt b/Documentation/networking/tc-actions-env-rules.txt
index 01e716d185f4..dcadf6f88e34 100644
--- a/Documentation/networking/tc-actions-env-rules.txt
+++ b/Documentation/networking/tc-actions-env-rules.txt
@@ -4,26 +4,27 @@ The "enviromental" rules for authors of any new tc actions are:
41) If you stealeth or borroweth any packet thou shalt be branching 41) If you stealeth or borroweth any packet thou shalt be branching
5from the righteous path and thou shalt cloneth. 5from the righteous path and thou shalt cloneth.
6 6
7For example if your action queues a packet to be processed later 7For example if your action queues a packet to be processed later,
8or intentionaly branches by redirecting a packet then you need to 8or intentionally branches by redirecting a packet, then you need to
9clone the packet. 9clone the packet.
10
10There are certain fields in the skb tc_verd that need to be reset so we 11There are certain fields in the skb tc_verd that need to be reset so we
11avoid loops etc. A few are generic enough so much so that skb_act_clone() 12avoid loops, etc. A few are generic enough that skb_act_clone()
12resets them for you. So invoke skb_act_clone() rather than skb_clone() 13resets them for you, so invoke skb_act_clone() rather than skb_clone().
13 14
142) If you munge any packet thou shalt call pskb_expand_head in the case 152) If you munge any packet thou shalt call pskb_expand_head in the case
15someone else is referencing the skb. After that you "own" the skb. 16someone else is referencing the skb. After that you "own" the skb.
16You must also tell us if it is ok to munge the packet (TC_OK2MUNGE), 17You must also tell us if it is ok to munge the packet (TC_OK2MUNGE),
17this way any action downstream can stomp on the packet. 18this way any action downstream can stomp on the packet.
18 19
193) dropping packets you dont own is a nono. You simply return 203) Dropping packets you don't own is a no-no. You simply return
20TC_ACT_SHOT to the caller and they will drop it. 21TC_ACT_SHOT to the caller and they will drop it.
21 22
22The "enviromental" rules for callers of actions (qdiscs etc) are: 23The "enviromental" rules for callers of actions (qdiscs etc) are:
23 24
24*) thou art responsible for freeing anything returned as being 25*) Thou art responsible for freeing anything returned as being
25TC_ACT_SHOT/STOLEN/QUEUED. If none of TC_ACT_SHOT/STOLEN/QUEUED is 26TC_ACT_SHOT/STOLEN/QUEUED. If none of TC_ACT_SHOT/STOLEN/QUEUED is
26returned then all is great and you dont need to do anything. 27returned, then all is great and you don't need to do anything.
27 28
28Post on netdev if something is unclear. 29Post on netdev if something is unclear.
29 30
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 99514ced82c5..928a79ceb7aa 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -708,7 +708,7 @@ device or bus to be described by the device tree.
708In general, the format of an address for a device is defined by the 708In general, the format of an address for a device is defined by the
709parent bus type, based on the #address-cells and #size-cells 709parent bus type, based on the #address-cells and #size-cells
710properties. Note that the parent's parent definitions of #address-cells 710properties. Note that the parent's parent definitions of #address-cells
711and #size-cells are not inhereted so every node with children must specify 711and #size-cells are not inherited so every node with children must specify
712them. The kernel requires the root node to have those properties defining 712them. The kernel requires the root node to have those properties defining
713addresses format for devices directly mapped on the processor bus. 713addresses format for devices directly mapped on the processor bus.
714 714
@@ -1777,7 +1777,7 @@ platforms are moved over to use the flattened-device-tree model.
1777 1777
1778 Xilinx uartlite devices are simple fixed speed serial ports. 1778 Xilinx uartlite devices are simple fixed speed serial ports.
1779 1779
1780 Requred properties: 1780 Required properties:
1781 - current-speed : Baud rate of uartlite 1781 - current-speed : Baud rate of uartlite
1782 1782
1783 v) Xilinx hwicap 1783 v) Xilinx hwicap
@@ -1799,7 +1799,7 @@ platforms are moved over to use the flattened-device-tree model.
1799 Xilinx UART 16550 devices are very similar to the NS16550 but with 1799 Xilinx UART 16550 devices are very similar to the NS16550 but with
1800 different register spacing and an offset from the base address. 1800 different register spacing and an offset from the base address.
1801 1801
1802 Requred properties: 1802 Required properties:
1803 - clock-frequency : Frequency of the clock input 1803 - clock-frequency : Frequency of the clock input
1804 - reg-offset : A value of 3 is required 1804 - reg-offset : A value of 3 is required
1805 - reg-shift : A value of 2 is required 1805 - reg-shift : A value of 2 is required
@@ -1953,7 +1953,7 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd.
19531) The /system-controller node 19531) The /system-controller node
1954 1954
1955 This node is used to represent the system-controller and must be 1955 This node is used to represent the system-controller and must be
1956 present when the system uses a system contller chip. The top-level 1956 present when the system uses a system controller chip. The top-level
1957 system-controller node contains information that is global to all 1957 system-controller node contains information that is global to all
1958 devices within the system controller chip. The node name begins 1958 devices within the system controller chip. The node name begins
1959 with "system-controller" followed by the unit address, which is 1959 with "system-controller" followed by the unit address, which is
diff --git a/Documentation/powerpc/qe_firmware.txt b/Documentation/powerpc/qe_firmware.txt
index 896266432d33..06da4d4b44f9 100644
--- a/Documentation/powerpc/qe_firmware.txt
+++ b/Documentation/powerpc/qe_firmware.txt
@@ -217,7 +217,7 @@ Although it is not recommended, you can specify '0' in the soc.model
217field to skip matching SOCs altogether. 217field to skip matching SOCs altogether.
218 218
219The 'model' field is a 16-bit number that matches the actual SOC. The 219The 'model' field is a 16-bit number that matches the actual SOC. The
220'major' and 'minor' fields are the major and minor revision numbrs, 220'major' and 'minor' fields are the major and minor revision numbers,
221respectively, of the SOC. 221respectively, of the SOC.
222 222
223For example, to match the 8323, revision 1.0: 223For example, to match the 8323, revision 1.0:
diff --git a/Documentation/s390/driver-model.txt b/Documentation/s390/driver-model.txt
index e938c442277d..bde473df748d 100644
--- a/Documentation/s390/driver-model.txt
+++ b/Documentation/s390/driver-model.txt
@@ -25,7 +25,7 @@ device 4711 via subchannel 1 in subchannel set 0, and subchannel 2 is a non-I/O
25subchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1. 25subchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1.
26 26
27The subchannel named 'defunct' does not represent any real subchannel on the 27The subchannel named 'defunct' does not represent any real subchannel on the
28system; it is a pseudo subchannel where disconnnected ccw devices are moved to 28system; it is a pseudo subchannel where disconnected ccw devices are moved to
29if they are displaced by another ccw device becoming operational on their 29if they are displaced by another ccw device becoming operational on their
30former subchannel. The ccw devices will be moved again to a proper subchannel 30former subchannel. The ccw devices will be moved again to a proper subchannel
31if they become operational again on that subchannel. 31if they become operational again on that subchannel.
diff --git a/Documentation/scsi/ibmmca.txt b/Documentation/scsi/ibmmca.txt
index a810421f1fb3..3920f28710c4 100644
--- a/Documentation/scsi/ibmmca.txt
+++ b/Documentation/scsi/ibmmca.txt
@@ -524,7 +524,7 @@
524 - Michael Lang 524 - Michael Lang
525 525
526 June 25 1997: (v1.8b) 526 June 25 1997: (v1.8b)
527 1) Some cosmetical changes for the handling of SCSI-device-types. 527 1) Some cosmetic changes for the handling of SCSI-device-types.
528 Now, also CD-Burners / WORMs and SCSI-scanners should work. For 528 Now, also CD-Burners / WORMs and SCSI-scanners should work. For
529 MO-drives I have no experience, therefore not yet supported. 529 MO-drives I have no experience, therefore not yet supported.
530 In logical_devices I changed from different type-variables to one 530 In logical_devices I changed from different type-variables to one
@@ -914,7 +914,7 @@
914 in version 4.0. This was never really necessary, as all troubles were 914 in version 4.0. This was never really necessary, as all troubles were
915 based on non-command related reasons up to now, so bypassing commands 915 based on non-command related reasons up to now, so bypassing commands
916 did not help to avoid any bugs. It is kept in 3.2X for debugging reasons. 916 did not help to avoid any bugs. It is kept in 3.2X for debugging reasons.
917 5) Dynamical reassignment of ldns was again verified and analyzed to be 917 5) Dynamic reassignment of ldns was again verified and analyzed to be
918 completely inoperational. This is corrected and should work now. 918 completely inoperational. This is corrected and should work now.
919 6) All commands that get sent to the SCSI adapter were verified and 919 6) All commands that get sent to the SCSI adapter were verified and
920 completed in such a way, that they are now completely conform to the 920 completed in such a way, that they are now completely conform to the
@@ -1386,7 +1386,7 @@
1386 concerning the Linux-kernel in special, this SCSI-driver comes without any 1386 concerning the Linux-kernel in special, this SCSI-driver comes without any
1387 warranty. Its functionality is tested as good as possible on certain 1387 warranty. Its functionality is tested as good as possible on certain
1388 machines and combinations of computer hardware, which does not exclude, 1388 machines and combinations of computer hardware, which does not exclude,
1389 that dataloss or severe damage of hardware is possible while using this 1389 that data loss or severe damage of hardware is possible while using this
1390 part of software on some arbitrary computer hardware or in combination 1390 part of software on some arbitrary computer hardware or in combination
1391 with other software packages. It is highly recommended to make backup 1391 with other software packages. It is highly recommended to make backup
1392 copies of your data before using this software. Furthermore, personal 1392 copies of your data before using this software. Furthermore, personal
diff --git a/Documentation/scsi/lpfc.txt b/Documentation/scsi/lpfc.txt
index 4dbe41370a6d..5741ea8aa88a 100644
--- a/Documentation/scsi/lpfc.txt
+++ b/Documentation/scsi/lpfc.txt
@@ -36,7 +36,7 @@ Cable pull and temporary device Loss:
36 being removed, a switch rebooting, or a device reboot), the driver could 36 being removed, a switch rebooting, or a device reboot), the driver could
37 hide the disappearance of the device from the midlayer. I/O's issued to 37 hide the disappearance of the device from the midlayer. I/O's issued to
38 the LLDD would simply be queued for a short duration, allowing the device 38 the LLDD would simply be queued for a short duration, allowing the device
39 to reappear or link come back alive, with no inadvertant side effects 39 to reappear or link come back alive, with no inadvertent side effects
40 to the system. If the driver did not hide these conditions, i/o would be 40 to the system. If the driver did not hide these conditions, i/o would be
41 errored by the driver, the mid-layer would exhaust its retries, and the 41 errored by the driver, the mid-layer would exhaust its retries, and the
42 device would be taken offline. Manual intervention would be required to 42 device would be taken offline. Manual intervention would be required to
diff --git a/Documentation/scsi/scsi_fc_transport.txt b/Documentation/scsi/scsi_fc_transport.txt
index d403e46d8463..75143f0c23b6 100644
--- a/Documentation/scsi/scsi_fc_transport.txt
+++ b/Documentation/scsi/scsi_fc_transport.txt
@@ -65,7 +65,7 @@ Overview:
65 discussion will concentrate on NPIV. 65 discussion will concentrate on NPIV.
66 66
67 Note: World Wide Name assignment (and uniqueness guarantees) are left 67 Note: World Wide Name assignment (and uniqueness guarantees) are left
68 up to an administrative entity controling the vport. For example, 68 up to an administrative entity controlling the vport. For example,
69 if vports are to be associated with virtual machines, a XEN mgmt 69 if vports are to be associated with virtual machines, a XEN mgmt
70 utility would be responsible for creating wwpn/wwnn's for the vport, 70 utility would be responsible for creating wwpn/wwnn's for the vport,
71 using it's own naming authority and OUI. (Note: it already does this 71 using it's own naming authority and OUI. (Note: it already does this
@@ -91,7 +91,7 @@ Device Trees and Vport Objects:
91 Here's what to expect in the device tree : 91 Here's what to expect in the device tree :
92 The typical Physical Port's Scsi_Host: 92 The typical Physical Port's Scsi_Host:
93 /sys/devices/.../host17/ 93 /sys/devices/.../host17/
94 and it has the typical decendent tree: 94 and it has the typical descendant tree:
95 /sys/devices/.../host17/rport-17:0-0/target17:0:0/17:0:0:0: 95 /sys/devices/.../host17/rport-17:0-0/target17:0:0/17:0:0:0:
96 and then the vport is created on the Physical Port: 96 and then the vport is created on the Physical Port:
97 /sys/devices/.../host17/vport-17:0-0 97 /sys/devices/.../host17/vport-17:0-0
@@ -192,7 +192,7 @@ Vport States:
192 independent of the adapter's link state. 192 independent of the adapter's link state.
193 - Instantiation of the vport on the FC link via ELS traffic, etc. 193 - Instantiation of the vport on the FC link via ELS traffic, etc.
194 This is equivalent to a "link up" and successfull link initialization. 194 This is equivalent to a "link up" and successfull link initialization.
195 Futher information can be found in the interfaces section below for 195 Further information can be found in the interfaces section below for
196 Vport Creation. 196 Vport Creation.
197 197
198 Once a vport has been instantiated with the kernel/LLDD, a vport state 198 Once a vport has been instantiated with the kernel/LLDD, a vport state
diff --git a/Documentation/sh/clk.txt b/Documentation/sh/clk.txt
index 9aef710e9a4b..114b595cfa97 100644
--- a/Documentation/sh/clk.txt
+++ b/Documentation/sh/clk.txt
@@ -12,7 +12,7 @@ means no changes to adjanced clock
12Internally, the clk_set_rate_ex forwards request to clk->ops->set_rate method, 12Internally, the clk_set_rate_ex forwards request to clk->ops->set_rate method,
13if it is present in ops structure. The method should set the clock rate and adjust 13if it is present in ops structure. The method should set the clock rate and adjust
14all needed clocks according to the passed algo_id. 14all needed clocks according to the passed algo_id.
15Exact values for algo_id are machine-dependend. For the sh7722, the following 15Exact values for algo_id are machine-dependent. For the sh7722, the following
16values are defined: 16values are defined:
17 17
18 NO_CHANGE = 0, 18 NO_CHANGE = 0,
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 72aff61e7315..6f6d117ac7e2 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -1024,6 +1024,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1024 intel-mac-v3 Intel Mac Type 3 1024 intel-mac-v3 Intel Mac Type 3
1025 intel-mac-v4 Intel Mac Type 4 1025 intel-mac-v4 Intel Mac Type 4
1026 intel-mac-v5 Intel Mac Type 5 1026 intel-mac-v5 Intel Mac Type 5
1027 intel-mac-auto Intel Mac (detect type according to subsystem id)
1027 macmini Intel Mac Mini (equivalent with type 3) 1028 macmini Intel Mac Mini (equivalent with type 3)
1028 macbook Intel Mac Book (eq. type 5) 1029 macbook Intel Mac Book (eq. type 5)
1029 macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3) 1030 macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3)
diff --git a/Documentation/sound/alsa/Audiophile-Usb.txt b/Documentation/sound/alsa/Audiophile-Usb.txt
index 2ad5e6306c44..a4c53d8961e1 100644
--- a/Documentation/sound/alsa/Audiophile-Usb.txt
+++ b/Documentation/sound/alsa/Audiophile-Usb.txt
@@ -236,15 +236,15 @@ The parameter can be given:
236 alias snd-card-1 snd-usb-audio 236 alias snd-card-1 snd-usb-audio
237 options snd-usb-audio index=1 device_setup=0x09 237 options snd-usb-audio index=1 device_setup=0x09
238 238
239CAUTION when initializaing the device 239CAUTION when initializing the device
240------------------------------------- 240-------------------------------------
241 241
242 * Correct initialization on the device requires that device_setup is given to 242 * Correct initialization on the device requires that device_setup is given to
243 the module BEFORE the device is turned on. So, if you use the "manual probing" 243 the module BEFORE the device is turned on. So, if you use the "manual probing"
244 method described above, take care to power-on the device AFTER this initialization. 244 method described above, take care to power-on the device AFTER this initialization.
245 245
246 * Failing to respect this will lead in a misconfiguration of the device. In this case 246 * Failing to respect this will lead to a misconfiguration of the device. In this case
247 turn off the device, unproble the snd-usb-audio module, then probe it again with 247 turn off the device, unprobe the snd-usb-audio module, then probe it again with
248 correct device_setup parameter and then (and only then) turn on the device again. 248 correct device_setup parameter and then (and only then) turn on the device again.
249 249
250 * If you've correctly initialized the device in a valid mode and then want to switch 250 * If you've correctly initialized the device in a valid mode and then want to switch
@@ -388,9 +388,9 @@ There are 2 main potential issues when using Jackd with the device:
388 388
389Jack supports big endian devices only in recent versions (thanks to 389Jack supports big endian devices only in recent versions (thanks to
390Andreas Steinmetz for his first big-endian patch). I can't remember 390Andreas Steinmetz for his first big-endian patch). I can't remember
391extacly when this support was released into jackd, let's just say that 391exactly when this support was released into jackd, let's just say that
392with jackd version 0.103.0 it's almost ok (just a small bug is affecting 392with jackd version 0.103.0 it's almost ok (just a small bug is affecting
39316bits Big-Endian devices, but since you've read carefully the above 39316bits Big-Endian devices, but since you've read carefully the above
394paragraphs, you're now using kernel >= 2.6.23 and your 16bits devices 394paragraphs, you're now using kernel >= 2.6.23 and your 16bits devices
395are now Little Endians ;-) ). 395are now Little Endians ;-) ).
396 396
diff --git a/Documentation/sound/alsa/hda_codec.txt b/Documentation/sound/alsa/hda_codec.txt
index 8e1b02526698..34e87ec1379c 100644
--- a/Documentation/sound/alsa/hda_codec.txt
+++ b/Documentation/sound/alsa/hda_codec.txt
@@ -67,7 +67,7 @@ CONFIG_SND_HDA_POWER_SAVE kconfig. It's called when the codec needs
67to power up or may power down. The controller should check the all 67to power up or may power down. The controller should check the all
68belonging codecs on the bus whether they are actually powered off 68belonging codecs on the bus whether they are actually powered off
69(check codec->power_on), and optionally the driver may power down the 69(check codec->power_on), and optionally the driver may power down the
70contoller side, too. 70controller side, too.
71 71
72The bus instance is created via snd_hda_bus_new(). You need to pass 72The bus instance is created via snd_hda_bus_new(). You need to pass
73the card instance, the template, and the pointer to store the 73the card instance, the template, and the pointer to store the
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt
index c784a18b94dc..b2ed6983f40d 100644
--- a/Documentation/sound/alsa/soc/dapm.txt
+++ b/Documentation/sound/alsa/soc/dapm.txt
@@ -68,7 +68,7 @@ Audio DAPM widgets fall into a number of types:-
68(Widgets are defined in include/sound/soc-dapm.h) 68(Widgets are defined in include/sound/soc-dapm.h)
69 69
70Widgets are usually added in the codec driver and the machine driver. There are 70Widgets are usually added in the codec driver and the machine driver. There are
71convience macros defined in soc-dapm.h that can be used to quickly build a 71convenience macros defined in soc-dapm.h that can be used to quickly build a
72list of widgets of the codecs and machines DAPM widgets. 72list of widgets of the codecs and machines DAPM widgets.
73 73
74Most widgets have a name, register, shift and invert. Some widgets have extra 74Most widgets have a name, register, shift and invert. Some widgets have extra
diff --git a/Documentation/sparse.txt b/Documentation/sparse.txt
index 1a3bdc27d95e..42f43fa59f24 100644
--- a/Documentation/sparse.txt
+++ b/Documentation/sparse.txt
@@ -73,10 +73,10 @@ recompiled, or use "make C=2" to run sparse on the files whether they need to
73be recompiled or not. The latter is a fast way to check the whole tree if you 73be recompiled or not. The latter is a fast way to check the whole tree if you
74have already built it. 74have already built it.
75 75
76The optional make variable CHECKFLAGS can be used to pass arguments to sparse. 76The optional make variable CF can be used to pass arguments to sparse. The
77The build system passes -Wbitwise to sparse automatically. To perform 77build system passes -Wbitwise to sparse automatically. To perform endianness
78endianness checks, you may define __CHECK_ENDIAN__: 78checks, you may define __CHECK_ENDIAN__:
79 79
80 make C=2 CHECKFLAGS="-D__CHECK_ENDIAN__" 80 make C=2 CF="-D__CHECK_ENDIAN__"
81 81
82These checks are disabled by default as they generate a host of warnings. 82These checks are disabled by default as they generate a host of warnings.
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index 8a4863c4edd4..d79eeda7a699 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -116,7 +116,7 @@ of kilobytes free. The VM uses this number to compute a pages_min
116value for each lowmem zone in the system. Each lowmem zone gets 116value for each lowmem zone in the system. Each lowmem zone gets
117a number of reserved free pages based proportionally on its size. 117a number of reserved free pages based proportionally on its size.
118 118
119Some minimal ammount of memory is needed to satisfy PF_MEMALLOC 119Some minimal amount of memory is needed to satisfy PF_MEMALLOC
120allocations; if you set this to lower than 1024KB, your system will 120allocations; if you set this to lower than 1024KB, your system will
121become subtly broken, and prone to deadlock under high loads. 121become subtly broken, and prone to deadlock under high loads.
122 122
diff --git a/Documentation/timers/highres.txt b/Documentation/timers/highres.txt
index a73ecf5b4bdb..21332233cef1 100644
--- a/Documentation/timers/highres.txt
+++ b/Documentation/timers/highres.txt
@@ -125,7 +125,7 @@ increase of flexibility and the avoidance of duplicated code across
125architectures justifies the slight increase of the binary size. 125architectures justifies the slight increase of the binary size.
126 126
127The conversion of an architecture has no functional impact, but allows to 127The conversion of an architecture has no functional impact, but allows to
128utilize the high resolution and dynamic tick functionalites without any change 128utilize the high resolution and dynamic tick functionalities without any change
129to the clock event device and timer interrupt code. After the conversion the 129to the clock event device and timer interrupt code. After the conversion the
130enabling of high resolution timers and dynamic ticks is simply provided by 130enabling of high resolution timers and dynamic ticks is simply provided by
131adding the kernel/time/Kconfig file to the architecture specific Kconfig and 131adding the kernel/time/Kconfig file to the architecture specific Kconfig and
diff --git a/Documentation/usb/authorization.txt b/Documentation/usb/authorization.txt
index 2af400609498..381b22ee7834 100644
--- a/Documentation/usb/authorization.txt
+++ b/Documentation/usb/authorization.txt
@@ -8,7 +8,7 @@ not) in a system. This feature will allow you to implement a lock-down
8of USB devices, fully controlled by user space. 8of USB devices, fully controlled by user space.
9 9
10As of now, when a USB device is connected it is configured and 10As of now, when a USB device is connected it is configured and
11it's interfaces inmediately made available to the users. With this 11its interfaces are immediately made available to the users. With this
12modification, only if root authorizes the device to be configured will 12modification, only if root authorizes the device to be configured will
13then it be possible to use it. 13then it be possible to use it.
14 14
diff --git a/Documentation/video4linux/CARDLIST.au0828 b/Documentation/video4linux/CARDLIST.au0828
index 86d1c8e7b18f..eedc399e8deb 100644
--- a/Documentation/video4linux/CARDLIST.au0828
+++ b/Documentation/video4linux/CARDLIST.au0828
@@ -2,3 +2,4 @@
2 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721f,2040:7280,0fd9:0008] 2 1 -> Hauppauge HVR950Q (au0828) [2040:7200,2040:7210,2040:7217,2040:721b,2040:721f,2040:7280,0fd9:0008]
3 2 -> Hauppauge HVR850 (au0828) [2040:7240] 3 2 -> Hauppauge HVR850 (au0828) [2040:7240]
4 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] 4 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620]
5 4 -> Hauppauge HVR950Q rev xxF8 (au0828) [2040:7201,2040:7211,2040:7281]
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 10591467ef16..89c7f32abf9f 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -1,11 +1,11 @@
1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800] 1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800]
2 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2750,eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883] 2 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883]
3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036] 3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036]
4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208] 4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208]
5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201] 5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201]
6 5 -> MSI VOX USB 2.0 (em2820/em2840) 6 5 -> MSI VOX USB 2.0 (em2820/em2840)
7 6 -> Terratec Cinergy 200 USB (em2800) 7 6 -> Terratec Cinergy 200 USB (em2800)
8 7 -> Leadtek Winfast USB II (em2800) 8 7 -> Leadtek Winfast USB II (em2800) [0413:6023]
9 8 -> Kworld USB2800 (em2800) 9 8 -> Kworld USB2800 (em2800)
10 9 -> Pinnacle Dazzle DVC 90/DVC 100 (em2820/em2840) [2304:0207,2304:021a] 10 9 -> Pinnacle Dazzle DVC 90/DVC 100 (em2820/em2840) [2304:0207,2304:021a]
11 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500] 11 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500]
@@ -14,7 +14,46 @@
14 13 -> Terratec Prodigy XS (em2880) [0ccd:0047] 14 13 -> Terratec Prodigy XS (em2880) [0ccd:0047]
15 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840) 15 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840)
16 15 -> V-Gear PocketTV (em2800) 16 15 -> V-Gear PocketTV (em2800)
17 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513,2040:6517,2040:651b,2040:651f] 17 16 -> Hauppauge WinTV HVR 950 (em2883) [2040:6513,2040:6517,2040:651b,2040:651f]
18 17 -> Pinnacle PCTV HD Pro Stick (em2880) [2304:0227] 18 17 -> Pinnacle PCTV HD Pro Stick (em2880) [2304:0227]
19 18 -> Hauppauge WinTV HVR 900 (R2) (em2880) [2040:6502] 19 18 -> Hauppauge WinTV HVR 900 (R2) (em2880) [2040:6502]
20 19 -> PointNix Intra-Oral Camera (em2860) 20 19 -> PointNix Intra-Oral Camera (em2860)
21 20 -> AMD ATI TV Wonder HD 600 (em2880) [0438:b002]
22 21 -> eMPIA Technology, Inc. GrabBeeX+ Video Encoder (em2800) [eb1a:2801]
23 22 -> Unknown EM2750/EM2751 webcam grabber (em2750) [eb1a:2750,eb1a:2751]
24 23 -> Huaqi DLCW-130 (em2750)
25 24 -> D-Link DUB-T210 TV Tuner (em2820/em2840) [2001:f112]
26 25 -> Gadmei UTV310 (em2820/em2840)
27 26 -> Hercules Smart TV USB 2.0 (em2820/em2840)
28 27 -> Pinnacle PCTV USB 2 (Philips FM1216ME) (em2820/em2840)
29 28 -> Leadtek Winfast USB II Deluxe (em2820/em2840)
30 29 -> Pinnacle Dazzle DVC 100 (em2820/em2840)
31 30 -> Videology 20K14XUSB USB2.0 (em2820/em2840)
32 31 -> Usbgear VD204v9 (em2821)
33 32 -> Supercomp USB 2.0 TV (em2821)
34 33 -> SIIG AVTuner-PVR/Prolink PlayTV USB 2.0 (em2821)
35 34 -> Terratec Cinergy A Hybrid XS (em2860) [0ccd:004f]
36 35 -> Typhoon DVD Maker (em2860)
37 36 -> NetGMBH Cam (em2860)
38 37 -> Gadmei UTV330 (em2860)
39 38 -> Yakumo MovieMixer (em2861)
40 39 -> KWorld PVRTV 300U (em2861) [eb1a:e300]
41 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005]
42 41 -> Kworld 350 U DVB-T (em2870) [eb1a:e350]
43 42 -> Kworld 355 U DVB-T (em2870) [eb1a:e355,eb1a:e357]
44 43 -> Terratec Cinergy T XS (em2870) [0ccd:0043]
45 44 -> Terratec Cinergy T XS (MT2060) (em2870)
46 45 -> Pinnacle PCTV DVB-T (em2870)
47 46 -> Compro, VideoMate U3 (em2870) [185b:2870]
48 47 -> KWorld DVB-T 305U (em2880) [eb1a:e305]
49 48 -> KWorld DVB-T 310U (em2880)
50 49 -> MSI DigiVox A/D (em2880) [eb1a:e310]
51 50 -> MSI DigiVox A/D II (em2880) [eb1a:e320]
52 51 -> Terratec Hybrid XS Secam (em2880) [0ccd:004c]
53 52 -> DNT DA2 Hybrid (em2881)
54 53 -> Pinnacle Hybrid Pro (em2881)
55 54 -> Kworld VS-DVB-T 323UR (em2882) [eb1a:e323]
56 55 -> Terratec Hybrid XS (em2882) (em2882) [0ccd:005e]
57 56 -> Pinnacle Hybrid Pro (2) (em2882) [2304:0226]
58 57 -> Kworld PlusTV HD Hybrid 330 (em2883) [eb1a:a316]
59 58 -> Compro VideoMate ForYou/Stereo (em2820/em2840) [185b:2041]
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
index 0c4880af57a3..bcaf4ab383be 100644
--- a/Documentation/video4linux/gspca.txt
+++ b/Documentation/video4linux/gspca.txt
@@ -1,4 +1,4 @@
1List of the webcams know by gspca. 1List of the webcams known by gspca.
2 2
3The modules are: 3The modules are:
4 gspca_main main driver 4 gspca_main main driver
diff --git a/Documentation/video4linux/sn9c102.txt b/Documentation/video4linux/sn9c102.txt
index b26f5195af51..73de4050d637 100644
--- a/Documentation/video4linux/sn9c102.txt
+++ b/Documentation/video4linux/sn9c102.txt
@@ -157,7 +157,7 @@ Loading can be done as shown below:
157 157
158 [root@localhost home]# modprobe sn9c102 158 [root@localhost home]# modprobe sn9c102
159 159
160Note that the module is called "sn9c102" for historic reasons, althought it 160Note that the module is called "sn9c102" for historic reasons, although it
161does not just support the SN9C102. 161does not just support the SN9C102.
162 162
163At this point all the devices supported by the driver and connected to the USB 163At this point all the devices supported by the driver and connected to the USB
diff --git a/Documentation/vm/hugetlbpage.txt b/Documentation/vm/hugetlbpage.txt
index 8a5b5763f0fe..ea8714fcc3ad 100644
--- a/Documentation/vm/hugetlbpage.txt
+++ b/Documentation/vm/hugetlbpage.txt
@@ -77,7 +77,7 @@ memory that is preset in system at this time. System administrators may want
77to put this command in one of the local rc init files. This will enable the 77to put this command in one of the local rc init files. This will enable the
78kernel to request huge pages early in the boot process (when the possibility 78kernel to request huge pages early in the boot process (when the possibility
79of getting physical contiguous pages is still very high). In either 79of getting physical contiguous pages is still very high). In either
80case, adminstrators will want to verify the number of hugepages actually 80case, administrators will want to verify the number of hugepages actually
81allocated by checking the sysctl or meminfo. 81allocated by checking the sysctl or meminfo.
82 82
83/proc/sys/vm/nr_overcommit_hugepages indicates how large the pool of 83/proc/sys/vm/nr_overcommit_hugepages indicates how large the pool of
diff --git a/Documentation/vm/numa_memory_policy.txt b/Documentation/vm/numa_memory_policy.txt
index bad16d3f6a47..6aaaeb38730c 100644
--- a/Documentation/vm/numa_memory_policy.txt
+++ b/Documentation/vm/numa_memory_policy.txt
@@ -58,7 +58,7 @@ most general to most specific:
58 the policy at the time they were allocated. 58 the policy at the time they were allocated.
59 59
60 VMA Policy: A "VMA" or "Virtual Memory Area" refers to a range of a task's 60 VMA Policy: A "VMA" or "Virtual Memory Area" refers to a range of a task's
61 virtual adddress space. A task may define a specific policy for a range 61 virtual address space. A task may define a specific policy for a range
62 of its virtual address space. See the MEMORY POLICIES APIS section, 62 of its virtual address space. See the MEMORY POLICIES APIS section,
63 below, for an overview of the mbind() system call used to set a VMA 63 below, for an overview of the mbind() system call used to set a VMA
64 policy. 64 policy.
@@ -353,7 +353,7 @@ follows:
353 353
354 Because of this extra reference counting, and because we must lookup 354 Because of this extra reference counting, and because we must lookup
355 shared policies in a tree structure under spinlock, shared policies are 355 shared policies in a tree structure under spinlock, shared policies are
356 more expensive to use in the page allocation path. This is expecially 356 more expensive to use in the page allocation path. This is especially
357 true for shared policies on shared memory regions shared by tasks running 357 true for shared policies on shared memory regions shared by tasks running
358 on different NUMA nodes. This extra overhead can be avoided by always 358 on different NUMA nodes. This extra overhead can be avoided by always
359 falling back to task or system default policy for shared memory regions, 359 falling back to task or system default policy for shared memory regions,
diff --git a/Documentation/volatile-considered-harmful.txt b/Documentation/volatile-considered-harmful.txt
index 10c2e411cca8..991c26a6ef64 100644
--- a/Documentation/volatile-considered-harmful.txt
+++ b/Documentation/volatile-considered-harmful.txt
@@ -114,6 +114,6 @@ CREDITS
114 114
115Original impetus and research by Randy Dunlap 115Original impetus and research by Randy Dunlap
116Written by Jonathan Corbet 116Written by Jonathan Corbet
117Improvements via coments from Satyam Sharma, Johannes Stezenbach, Jesper 117Improvements via comments from Satyam Sharma, Johannes Stezenbach, Jesper
118 Juhl, Heikki Orsila, H. Peter Anvin, Philipp Hahn, and Stefan 118 Juhl, Heikki Orsila, H. Peter Anvin, Philipp Hahn, and Stefan
119 Richter. 119 Richter.
diff --git a/Kbuild b/Kbuild
index e750e9c3fe59..f056b4feee51 100644
--- a/Kbuild
+++ b/Kbuild
@@ -43,7 +43,7 @@ $(obj)/$(bounds-file): kernel/bounds.s Kbuild
43# 2) Generate asm-offsets.h 43# 2) Generate asm-offsets.h
44# 44#
45 45
46offsets-file := include/asm-$(SRCARCH)/asm-offsets.h 46offsets-file := include/asm/asm-offsets.h
47 47
48always += $(offsets-file) 48always += $(offsets-file)
49targets += $(offsets-file) 49targets += $(offsets-file)
@@ -81,7 +81,6 @@ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
81 $(call if_changed_dep,cc_s_c) 81 $(call if_changed_dep,cc_s_c)
82 82
83$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild 83$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
84 $(Q)mkdir -p $(dir $@)
85 $(call cmd,offsets) 84 $(call cmd,offsets)
86 85
87##### 86#####
diff --git a/MAINTAINERS b/MAINTAINERS
index 4cbf6016a9b9..deedc0d827b5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3123,6 +3123,12 @@ W: http://oss.oracle.com/projects/ocfs2/
3123T: git git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2.git 3123T: git git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2.git
3124S: Supported 3124S: Supported
3125 3125
3126OMFS FILESYSTEM
3127P: Bob Copeland
3128M: me@bobcopeland.com
3129L: linux-karma-devel@lists.sourceforge.net
3130S: Maintained
3131
3126OMNIKEY CARDMAN 4000 DRIVER 3132OMNIKEY CARDMAN 4000 DRIVER
3127P: Harald Welte 3133P: Harald Welte
3128M: laforge@gnumonks.org 3134M: laforge@gnumonks.org
@@ -3790,6 +3796,12 @@ P: Ben Nizette
3790M: bn@niasdigital.com 3796M: bn@niasdigital.com
3791S: Maintained 3797S: Maintained
3792 3798
3799SOC-CAMERA V4L2 SUBSYSTEM
3800P: Guennadi Liakhovetski
3801M: g.liakhovetski@gmx.de
3802L: video4linux-list@redhat.com
3803S: Maintained
3804
3793SOFTWARE RAID (Multiple Disks) SUPPORT 3805SOFTWARE RAID (Multiple Disks) SUPPORT
3794P: Ingo Molnar 3806P: Ingo Molnar
3795M: mingo@redhat.com 3807M: mingo@redhat.com
diff --git a/Makefile b/Makefile
index 3cad7db5eba7..aa527a46c807 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 26 3SUBLEVEL = 27
4EXTRAVERSION = 4EXTRAVERSION = -rc1
5NAME = Rotary Wombat 5NAME = Rotary Wombat
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -205,6 +205,13 @@ ifeq ($(ARCH),x86_64)
205 SRCARCH := x86 205 SRCARCH := x86
206endif 206endif
207 207
208# Where to locate arch specific headers
209ifeq ($(ARCH),sparc64)
210 hdr-arch := sparc
211else
212 hdr-arch := $(SRCARCH)
213endif
214
208KCONFIG_CONFIG ?= .config 215KCONFIG_CONFIG ?= .config
209 216
210# SHELL used by kbuild 217# SHELL used by kbuild
@@ -326,7 +333,8 @@ AFLAGS_KERNEL =
326# Needed to be compatible with the O= option 333# Needed to be compatible with the O= option
327LINUXINCLUDE := -Iinclude \ 334LINUXINCLUDE := -Iinclude \
328 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ 335 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
329 -include include/linux/autoconf.h 336 -I$(srctree)/arch/$(hdr-arch)/include \
337 -include include/linux/autoconf.h
330 338
331KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 339KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
332 340
@@ -922,7 +930,9 @@ ifneq ($(KBUILD_SRC),)
922 /bin/false; \ 930 /bin/false; \
923 fi; 931 fi;
924 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; 932 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
925 $(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm 933 $(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/system.h ]; then \
934 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
935 fi
926endif 936endif
927 937
928# prepare2 creates a makefile if using a separate output directory 938# prepare2 creates a makefile if using a separate output directory
@@ -948,22 +958,34 @@ export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
948 958
949# The asm symlink changes when $(ARCH) changes. 959# The asm symlink changes when $(ARCH) changes.
950# Detect this and ask user to run make mrproper 960# Detect this and ask user to run make mrproper
951 961define check-symlink
952include/asm: FORCE 962 set -e; \
953 $(Q)set -e; asmlink=`readlink include/asm | cut -d '-' -f 2`; \ 963 if [ -L include/asm ]; then \
954 if [ -L include/asm ]; then \ 964 asmlink=`readlink include/asm | cut -d '-' -f 2`; \
955 if [ "$$asmlink" != "$(SRCARCH)" ]; then \ 965 if [ "$$asmlink" != "$(SRCARCH)" ]; then \
956 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \ 966 echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
957 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \ 967 echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
958 exit 1; \ 968 exit 1; \
959 fi; \ 969 fi; \
960 else \
961 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
962 if [ ! -d include ]; then \
963 mkdir -p include; \
964 fi; \
965 ln -fsn asm-$(SRCARCH) $@; \
966 fi 970 fi
971endef
972
973# We create the target directory of the symlink if it does
974# not exist so the test in chack-symlink works and we have a
975# directory for generated filesas used by some architectures.
976define create-symlink
977 if [ ! -L include/asm ]; then \
978 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
979 if [ ! -d include/asm-$(SRCARCH) ]; then \
980 mkdir -p include/asm-$(SRCARCH); \
981 fi; \
982 ln -fsn asm-$(SRCARCH) $@; \
983 fi
984endef
985
986include/asm: FORCE
987 $(Q)$(check-symlink)
988 $(Q)$(create-symlink)
967 989
968# Generate some files 990# Generate some files
969# --------------------------------------------------------------------------- 991# ---------------------------------------------------------------------------
@@ -1010,36 +1032,43 @@ firmware_install: FORCE
1010 1032
1011# --------------------------------------------------------------------------- 1033# ---------------------------------------------------------------------------
1012# Kernel headers 1034# Kernel headers
1013INSTALL_HDR_PATH=$(objtree)/usr
1014export INSTALL_HDR_PATH
1015 1035
1016HDRFILTER=generic i386 x86_64 1036#Default location for installed headers
1017HDRARCHES=$(filter-out $(HDRFILTER),$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) 1037export INSTALL_HDR_PATH = $(objtree)/usr
1018 1038
1019PHONY += headers_install_all 1039hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
1020headers_install_all: include/linux/version.h scripts_basic FORCE 1040# Find out where the Kbuild file is located to support
1041# arch/$(ARCH)/include/asm
1042hdr-dir = $(strip \
1043 $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
1044 arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))
1045
1046# If we do an all arch process set dst to asm-$(hdr-arch)
1047hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
1048
1049PHONY += __headers
1050__headers: include/linux/version.h scripts_basic FORCE
1021 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 1051 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
1022 $(Q)for arch in $(HDRARCHES); do \ 1052
1023 $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ 1053PHONY += headers_install_all
1024 done 1054headers_install_all:
1055 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
1025 1056
1026PHONY += headers_install 1057PHONY += headers_install
1027headers_install: include/linux/version.h scripts_basic FORCE 1058headers_install: __headers
1028 @if [ ! -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1059 $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
1029 echo '*** Error: Headers not exportable for this architecture ($(SRCARCH))'; \ 1060 $(error Headers not exportable for the $(SRCARCH) architecture))
1030 exit 1 ; fi 1061 $(Q)$(MAKE) $(hdr-inst)=include
1031 $(Q)$(MAKE) $(build)=scripts scripts/unifdef 1062 $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)
1032 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include
1033 1063
1034PHONY += headers_check_all 1064PHONY += headers_check_all
1035headers_check_all: headers_install_all 1065headers_check_all: headers_install_all
1036 $(Q)for arch in $(HDRARCHES); do \ 1066 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
1037 $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch HDRCHECK=1 ;\
1038 done
1039 1067
1040PHONY += headers_check 1068PHONY += headers_check
1041headers_check: headers_install 1069headers_check: headers_install
1042 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst ARCH=$(SRCARCH) obj=include HDRCHECK=1 1070 $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
1071 $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
1043 1072
1044# --------------------------------------------------------------------------- 1073# ---------------------------------------------------------------------------
1045# Modules 1074# Modules
@@ -1131,7 +1160,7 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
1131 include/linux/autoconf.h include/linux/version.h \ 1160 include/linux/autoconf.h include/linux/version.h \
1132 include/linux/utsrelease.h \ 1161 include/linux/utsrelease.h \
1133 include/linux/bounds.h include/asm*/asm-offsets.h \ 1162 include/linux/bounds.h include/asm*/asm-offsets.h \
1134 Module.symvers tags TAGS cscope* 1163 Module.symvers Module.markers tags TAGS cscope*
1135 1164
1136# clean - Delete most, but leave enough to build external modules 1165# clean - Delete most, but leave enough to build external modules
1137# 1166#
@@ -1150,7 +1179,7 @@ clean: archclean $(clean-dirs)
1150 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1179 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1151 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1180 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1152 -o -name '*.symtypes' -o -name 'modules.order' \ 1181 -o -name '*.symtypes' -o -name 'modules.order' \
1153 -o -name 'Module.markers' \) \ 1182 -o -name 'Module.markers' -o -name '.tmp_*.o.*' \) \
1154 -type f -print | xargs rm -f 1183 -type f -print | xargs rm -f
1155 1184
1156# mrproper - Delete all generated files, including .config 1185# mrproper - Delete all generated files, including .config
@@ -1224,21 +1253,17 @@ help:
1224 @echo ' cscope - Generate cscope index' 1253 @echo ' cscope - Generate cscope index'
1225 @echo ' kernelrelease - Output the release version string' 1254 @echo ' kernelrelease - Output the release version string'
1226 @echo ' kernelversion - Output the version stored in Makefile' 1255 @echo ' kernelversion - Output the version stored in Makefile'
1227 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1256 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1228 echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1229 echo ' (default: $(INSTALL_HDR_PATH))'; \ 1257 echo ' (default: $(INSTALL_HDR_PATH))'; \
1230 fi 1258 echo ''
1231 @echo ''
1232 @echo 'Static analysers' 1259 @echo 'Static analysers'
1233 @echo ' checkstack - Generate a list of stack hogs' 1260 @echo ' checkstack - Generate a list of stack hogs'
1234 @echo ' namespacecheck - Name space analysis on compiled kernel' 1261 @echo ' namespacecheck - Name space analysis on compiled kernel'
1235 @echo ' versioncheck - Sanity check on version.h usage' 1262 @echo ' versioncheck - Sanity check on version.h usage'
1236 @echo ' includecheck - Check for duplicate included header files' 1263 @echo ' includecheck - Check for duplicate included header files'
1237 @echo ' export_report - List the usages of all exported symbols' 1264 @echo ' export_report - List the usages of all exported symbols'
1238 @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ 1265 @echo ' headers_check - Sanity check on exported headers'; \
1239 echo ' headers_check - Sanity check on exported headers'; \ 1266 echo ''
1240 fi
1241 @echo ''
1242 @echo 'Kernel packaging:' 1267 @echo 'Kernel packaging:'
1243 @$(MAKE) $(build)=$(package-dir) help 1268 @$(MAKE) $(build)=$(package-dir) help
1244 @echo '' 1269 @echo ''
@@ -1411,7 +1436,11 @@ define find-sources
1411 \( -name config -o -name 'asm-*' \) -prune \ 1436 \( -name config -o -name 'asm-*' \) -prune \
1412 -o -name $1 -print; \ 1437 -o -name $1 -print; \
1413 for arch in $(ALLINCLUDE_ARCHS) ; do \ 1438 for arch in $(ALLINCLUDE_ARCHS) ; do \
1414 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ 1439 test -e $(__srctree)include/asm-$${arch} && \
1440 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1441 -name $1 -print; \
1442 test -e $(__srctree)arch/$${arch}/include/asm && \
1443 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1415 -name $1 -print; \ 1444 -name $1 -print; \
1416 done ; \ 1445 done ; \
1417 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ 1446 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
diff --git a/arch/Kconfig b/arch/Kconfig
index b0fabfa864ff..364c6dadde0a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -59,6 +59,24 @@ config HAVE_KPROBES
59config HAVE_KRETPROBES 59config HAVE_KRETPROBES
60 def_bool n 60 def_bool n
61 61
62#
63# An arch should select this if it provides all these things:
64#
65# task_pt_regs() in asm/processor.h or asm/ptrace.h
66# arch_has_single_step() if there is hardware single-step support
67# arch_has_block_step() if there is hardware block-step support
68# arch_ptrace() and not #define __ARCH_SYS_PTRACE
69# compat_arch_ptrace() and #define __ARCH_WANT_COMPAT_SYS_PTRACE
70# asm/syscall.h supplying asm-generic/syscall.h interface
71# linux/regset.h user_regset interfaces
72# CORE_DUMP_USE_REGSET #define'd in linux/elf.h
73# TIF_SYSCALL_TRACE calls tracehook_report_syscall_{entry,exit}
74# TIF_NOTIFY_RESUME calls tracehook_notify_resume()
75# signal delivery calls tracehook_signal_handler()
76#
77config HAVE_ARCH_TRACEHOOK
78 def_bool n
79
62config HAVE_DMA_ATTRS 80config HAVE_DMA_ATTRS
63 def_bool n 81 def_bool n
64 82
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 32ca1b927307..6e943135f0e0 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -253,15 +253,15 @@ do_osf_statfs(struct dentry * dentry, struct osf_statfs __user *buffer,
253} 253}
254 254
255asmlinkage int 255asmlinkage int
256osf_statfs(char __user *path, struct osf_statfs __user *buffer, unsigned long bufsiz) 256osf_statfs(char __user *pathname, struct osf_statfs __user *buffer, unsigned long bufsiz)
257{ 257{
258 struct nameidata nd; 258 struct path path;
259 int retval; 259 int retval;
260 260
261 retval = user_path_walk(path, &nd); 261 retval = user_path(pathname, &path);
262 if (!retval) { 262 if (!retval) {
263 retval = do_osf_statfs(nd.path.dentry, buffer, bufsiz); 263 retval = do_osf_statfs(path.dentry, buffer, bufsiz);
264 path_put(&nd.path); 264 path_put(&path);
265 } 265 }
266 return retval; 266 return retval;
267} 267}
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 40c15e7301de..234e42b8ee74 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -94,36 +94,6 @@ __bad_page(void)
94 return pte_mkdirty(mk_pte(virt_to_page(EMPTY_PGE), PAGE_SHARED)); 94 return pte_mkdirty(mk_pte(virt_to_page(EMPTY_PGE), PAGE_SHARED));
95} 95}
96 96
97#ifndef CONFIG_DISCONTIGMEM
98void
99show_mem(void)
100{
101 long i,free = 0,total = 0,reserved = 0;
102 long shared = 0, cached = 0;
103
104 printk("\nMem-info:\n");
105 show_free_areas();
106 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
107 i = max_mapnr;
108 while (i-- > 0) {
109 total++;
110 if (PageReserved(mem_map+i))
111 reserved++;
112 else if (PageSwapCache(mem_map+i))
113 cached++;
114 else if (!page_count(mem_map+i))
115 free++;
116 else
117 shared += page_count(mem_map + i) - 1;
118 }
119 printk("%ld pages of RAM\n",total);
120 printk("%ld free pages\n",free);
121 printk("%ld reserved pages\n",reserved);
122 printk("%ld pages shared\n",shared);
123 printk("%ld pages swap cached\n",cached);
124}
125#endif
126
127static inline unsigned long 97static inline unsigned long
128load_PCB(struct pcb_struct *pcb) 98load_PCB(struct pcb_struct *pcb)
129{ 99{
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index d8c4ceaf00b9..a13de49d1265 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -359,38 +359,3 @@ void __init mem_init(void)
359 mem_stress(); 359 mem_stress();
360#endif 360#endif
361} 361}
362
363void
364show_mem(void)
365{
366 long i,free = 0,total = 0,reserved = 0;
367 long shared = 0, cached = 0;
368 int nid;
369
370 printk("\nMem-info:\n");
371 show_free_areas();
372 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
373 for_each_online_node(nid) {
374 unsigned long flags;
375 pgdat_resize_lock(NODE_DATA(nid), &flags);
376 i = node_spanned_pages(nid);
377 while (i-- > 0) {
378 struct page *page = nid_page_nr(nid, i);
379 total++;
380 if (PageReserved(page))
381 reserved++;
382 else if (PageSwapCache(page))
383 cached++;
384 else if (!page_count(page))
385 free++;
386 else
387 shared += page_count(page) - 1;
388 }
389 pgdat_resize_unlock(NODE_DATA(nid), &flags);
390 }
391 printk("%ld pages of RAM\n",total);
392 printk("%ld free pages\n",free);
393 printk("%ld reserved pages\n",reserved);
394 printk("%ld pages shared\n",shared);
395 printk("%ld pages swap cached\n",cached);
396}
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dabb015aa40b..257033c691f2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -17,6 +17,7 @@ config ARM
17 select HAVE_KRETPROBES if (HAVE_KPROBES) 17 select HAVE_KRETPROBES if (HAVE_KPROBES)
18 select HAVE_FTRACE if (!XIP_KERNEL) 18 select HAVE_FTRACE if (!XIP_KERNEL)
19 select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE) 19 select HAVE_DYNAMIC_FTRACE if (HAVE_FTRACE)
20 select HAVE_GENERIC_DMA_COHERENT
20 help 21 help
21 The ARM series is a line of low-power-consumption RISC chip designs 22 The ARM series is a line of low-power-consumption RISC chip designs
22 licensed by ARM Ltd and targeted at embedded applications and 23 licensed by ARM Ltd and targeted at embedded applications and
@@ -234,6 +235,7 @@ config ARCH_VERSATILE
234config ARCH_AT91 235config ARCH_AT91
235 bool "Atmel AT91" 236 bool "Atmel AT91"
236 select GENERIC_GPIO 237 select GENERIC_GPIO
238 select HAVE_CLK
237 help 239 help
238 This enables support for systems based on the Atmel AT91RM9200, 240 This enables support for systems based on the Atmel AT91RM9200,
239 AT91SAM9 and AT91CAP9 processors. 241 AT91SAM9 and AT91CAP9 processors.
@@ -267,7 +269,6 @@ config ARCH_EP93XX
267 select ARM_VIC 269 select ARM_VIC
268 select GENERIC_GPIO 270 select GENERIC_GPIO
269 select HAVE_CLK 271 select HAVE_CLK
270 select HAVE_CLK
271 select ARCH_REQUIRE_GPIOLIB 272 select ARCH_REQUIRE_GPIOLIB
272 help 273 help
273 This enables support for the Cirrus EP93xx series of CPUs. 274 This enables support for the Cirrus EP93xx series of CPUs.
@@ -314,7 +315,7 @@ config ARCH_IOP32X
314 select PLAT_IOP 315 select PLAT_IOP
315 select PCI 316 select PCI
316 select GENERIC_GPIO 317 select GENERIC_GPIO
317 select HAVE_GPIO_LIB 318 select ARCH_REQUIRE_GPIOLIB
318 help 319 help
319 Support for Intel's 80219 and IOP32X (XScale) family of 320 Support for Intel's 80219 and IOP32X (XScale) family of
320 processors. 321 processors.
@@ -325,7 +326,7 @@ config ARCH_IOP33X
325 select PLAT_IOP 326 select PLAT_IOP
326 select PCI 327 select PCI
327 select GENERIC_GPIO 328 select GENERIC_GPIO
328 select HAVE_GPIO_LIB 329 select ARCH_REQUIRE_GPIOLIB
329 help 330 help
330 Support for Intel's IOP33X (XScale) family of processors. 331 Support for Intel's IOP33X (XScale) family of processors.
331 332
@@ -418,7 +419,7 @@ config ARCH_MXC
418 select GENERIC_CLOCKEVENTS 419 select GENERIC_CLOCKEVENTS
419 select ARCH_MTD_XIP 420 select ARCH_MTD_XIP
420 select GENERIC_GPIO 421 select GENERIC_GPIO
421 select HAVE_GPIO_LIB 422 select ARCH_REQUIRE_GPIOLIB
422 help 423 help
423 Support for Freescale MXC/iMX-based family of processors 424 Support for Freescale MXC/iMX-based family of processors
424 425
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index b20995a82e04..2f0747744236 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -67,7 +67,7 @@ tune-$(CONFIG_CPU_ARM720T) :=-mtune=arm7tdmi
67tune-$(CONFIG_CPU_ARM740T) :=-mtune=arm7tdmi 67tune-$(CONFIG_CPU_ARM740T) :=-mtune=arm7tdmi
68tune-$(CONFIG_CPU_ARM9TDMI) :=-mtune=arm9tdmi 68tune-$(CONFIG_CPU_ARM9TDMI) :=-mtune=arm9tdmi
69tune-$(CONFIG_CPU_ARM940T) :=-mtune=arm9tdmi 69tune-$(CONFIG_CPU_ARM940T) :=-mtune=arm9tdmi
70tune-$(CONFIG_CPU_ARM946T) :=$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi) 70tune-$(CONFIG_CPU_ARM946E) :=$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi)
71tune-$(CONFIG_CPU_ARM920T) :=-mtune=arm9tdmi 71tune-$(CONFIG_CPU_ARM920T) :=-mtune=arm9tdmi
72tune-$(CONFIG_CPU_ARM922T) :=-mtune=arm9tdmi 72tune-$(CONFIG_CPU_ARM922T) :=-mtune=arm9tdmi
73tune-$(CONFIG_CPU_ARM925T) :=-mtune=arm9tdmi 73tune-$(CONFIG_CPU_ARM925T) :=-mtune=arm9tdmi
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index dd2947342604..69130f365904 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -280,7 +280,7 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
280 /* 280 /*
281 * Trying to unmap an invalid mapping 281 * Trying to unmap an invalid mapping
282 */ 282 */
283 if (dma_mapping_error(dma_addr)) { 283 if (dma_mapping_error(dev, dma_addr)) {
284 dev_err(dev, "Trying to unmap invalid mapping\n"); 284 dev_err(dev, "Trying to unmap invalid mapping\n");
285 return; 285 return;
286 } 286 }
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index c3c3a3339049..85579654d3b7 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -331,17 +331,17 @@ static int locomo_gpio_type(unsigned int irq, unsigned int type)
331 331
332 mask = 1 << (irq - LOCOMO_IRQ_GPIO_START); 332 mask = 1 << (irq - LOCOMO_IRQ_GPIO_START);
333 333
334 if (type == IRQT_PROBE) { 334 if (type == IRQ_TYPE_PROBE) {
335 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask) 335 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
336 return 0; 336 return 0;
337 type = __IRQT_RISEDGE | __IRQT_FALEDGE; 337 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
338 } 338 }
339 339
340 if (type & __IRQT_RISEDGE) 340 if (type & IRQ_TYPE_EDGE_RISING)
341 GPIO_IRQ_rising_edge |= mask; 341 GPIO_IRQ_rising_edge |= mask;
342 else 342 else
343 GPIO_IRQ_rising_edge &= ~mask; 343 GPIO_IRQ_rising_edge &= ~mask;
344 if (type & __IRQT_FALEDGE) 344 if (type & IRQ_TYPE_EDGE_FALLING)
345 GPIO_IRQ_falling_edge |= mask; 345 GPIO_IRQ_falling_edge |= mask;
346 else 346 else
347 GPIO_IRQ_falling_edge &= ~mask; 347 GPIO_IRQ_falling_edge &= ~mask;
@@ -473,7 +473,7 @@ static void locomo_setup_irq(struct locomo *lchip)
473 /* 473 /*
474 * Install handler for IRQ_LOCOMO_HW. 474 * Install handler for IRQ_LOCOMO_HW.
475 */ 475 */
476 set_irq_type(lchip->irq, IRQT_FALLING); 476 set_irq_type(lchip->irq, IRQ_TYPE_EDGE_FALLING);
477 set_irq_chip_data(lchip->irq, irqbase); 477 set_irq_chip_data(lchip->irq, irqbase);
478 set_irq_chained_handler(lchip->irq, locomo_handler); 478 set_irq_chained_handler(lchip->irq, locomo_handler);
479 479
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 0a8e1ff2af8a..f6d3fdda7067 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -241,14 +241,14 @@ static int sa1111_type_lowirq(unsigned int irq, unsigned int flags)
241 void __iomem *mapbase = get_irq_chip_data(irq); 241 void __iomem *mapbase = get_irq_chip_data(irq);
242 unsigned long ip0; 242 unsigned long ip0;
243 243
244 if (flags == IRQT_PROBE) 244 if (flags == IRQ_TYPE_PROBE)
245 return 0; 245 return 0;
246 246
247 if ((!(flags & __IRQT_RISEDGE) ^ !(flags & __IRQT_FALEDGE)) == 0) 247 if ((!(flags & IRQ_TYPE_EDGE_RISING) ^ !(flags & IRQ_TYPE_EDGE_FALLING)) == 0)
248 return -EINVAL; 248 return -EINVAL;
249 249
250 ip0 = sa1111_readl(mapbase + SA1111_INTPOL0); 250 ip0 = sa1111_readl(mapbase + SA1111_INTPOL0);
251 if (flags & __IRQT_RISEDGE) 251 if (flags & IRQ_TYPE_EDGE_RISING)
252 ip0 &= ~mask; 252 ip0 &= ~mask;
253 else 253 else
254 ip0 |= mask; 254 ip0 |= mask;
@@ -338,14 +338,14 @@ static int sa1111_type_highirq(unsigned int irq, unsigned int flags)
338 void __iomem *mapbase = get_irq_chip_data(irq); 338 void __iomem *mapbase = get_irq_chip_data(irq);
339 unsigned long ip1; 339 unsigned long ip1;
340 340
341 if (flags == IRQT_PROBE) 341 if (flags == IRQ_TYPE_PROBE)
342 return 0; 342 return 0;
343 343
344 if ((!(flags & __IRQT_RISEDGE) ^ !(flags & __IRQT_FALEDGE)) == 0) 344 if ((!(flags & IRQ_TYPE_EDGE_RISING) ^ !(flags & IRQ_TYPE_EDGE_FALLING)) == 0)
345 return -EINVAL; 345 return -EINVAL;
346 346
347 ip1 = sa1111_readl(mapbase + SA1111_INTPOL1); 347 ip1 = sa1111_readl(mapbase + SA1111_INTPOL1);
348 if (flags & __IRQT_RISEDGE) 348 if (flags & IRQ_TYPE_EDGE_RISING)
349 ip1 &= ~mask; 349 ip1 &= ~mask;
350 else 350 else
351 ip1 |= mask; 351 ip1 |= mask;
@@ -427,7 +427,7 @@ static void sa1111_setup_irq(struct sa1111 *sachip)
427 /* 427 /*
428 * Register SA1111 interrupt 428 * Register SA1111 interrupt
429 */ 429 */
430 set_irq_type(sachip->irq, IRQT_RISING); 430 set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING);
431 set_irq_data(sachip->irq, irqbase); 431 set_irq_data(sachip->irq, irqbase);
432 set_irq_chained_handler(sachip->irq, sa1111_irq_handler); 432 set_irq_chained_handler(sachip->irq, sa1111_irq_handler);
433} 433}
diff --git a/arch/arm/configs/eseries_pxa_defconfig b/arch/arm/configs/eseries_pxa_defconfig
index 493ecee24f94..2307587a38a9 100644
--- a/arch/arm/configs/eseries_pxa_defconfig
+++ b/arch/arm/configs/eseries_pxa_defconfig
@@ -1,15 +1,19 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-hh17 3# Linux kernel version: 2.6.26
4# Fri Nov 9 20:23:03 2007 4# Sat Jul 26 22:28:46 2008
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y 8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y 9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
10CONFIG_MMU=y 11CONFIG_MMU=y
11# CONFIG_NO_IOPORT is not set 12# CONFIG_NO_IOPORT is not set
12CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y
13CONFIG_TRACE_IRQFLAGS_SUPPORT=y 17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
14CONFIG_HARDIRQS_SW_RESEND=y 18CONFIG_HARDIRQS_SW_RESEND=y
15CONFIG_GENERIC_IRQ_PROBE=y 19CONFIG_GENERIC_IRQ_PROBE=y
@@ -18,75 +22,90 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
18# CONFIG_ARCH_HAS_ILOG2_U64 is not set 22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
19CONFIG_GENERIC_HWEIGHT=y 23CONFIG_GENERIC_HWEIGHT=y
20CONFIG_GENERIC_CALIBRATE_DELAY=y 24CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_SUPPORTS_AOUT=y
21CONFIG_ZONE_DMA=y 26CONFIG_ZONE_DMA=y
22CONFIG_ARCH_MTD_XIP=y 27CONFIG_ARCH_MTD_XIP=y
28CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
23CONFIG_VECTORS_BASE=0xffff0000 29CONFIG_VECTORS_BASE=0xffff0000
24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
25 31
26# 32#
27# Code maturity level options 33# General setup
28# 34#
29CONFIG_EXPERIMENTAL=y 35CONFIG_EXPERIMENTAL=y
30CONFIG_BROKEN_ON_SMP=y 36CONFIG_BROKEN_ON_SMP=y
31CONFIG_INIT_ENV_ARG_LIMIT=32 37CONFIG_INIT_ENV_ARG_LIMIT=32
32
33#
34# General setup
35#
36CONFIG_LOCALVERSION="" 38CONFIG_LOCALVERSION=""
37CONFIG_LOCALVERSION_AUTO=y 39CONFIG_LOCALVERSION_AUTO=y
38CONFIG_SWAP=y 40CONFIG_SWAP=y
39CONFIG_SYSVIPC=y 41CONFIG_SYSVIPC=y
40# CONFIG_IPC_NS is not set
41CONFIG_SYSVIPC_SYSCTL=y 42CONFIG_SYSVIPC_SYSCTL=y
42# CONFIG_POSIX_MQUEUE is not set 43# CONFIG_POSIX_MQUEUE is not set
43# CONFIG_BSD_PROCESS_ACCT is not set 44# CONFIG_BSD_PROCESS_ACCT is not set
44# CONFIG_TASKSTATS is not set 45# CONFIG_TASKSTATS is not set
45# CONFIG_UTS_NS is not set
46# CONFIG_AUDIT is not set 46# CONFIG_AUDIT is not set
47# CONFIG_IKCONFIG is not set 47# CONFIG_IKCONFIG is not set
48CONFIG_LOG_BUF_SHIFT=14
49# CONFIG_CGROUPS is not set
50# CONFIG_GROUP_SCHED is not set
48CONFIG_SYSFS_DEPRECATED=y 51CONFIG_SYSFS_DEPRECATED=y
52CONFIG_SYSFS_DEPRECATED_V2=y
49# CONFIG_RELAY is not set 53# CONFIG_RELAY is not set
50CONFIG_BLK_DEV_INITRD=y 54# CONFIG_NAMESPACES is not set
51CONFIG_INITRAMFS_SOURCE="" 55# CONFIG_BLK_DEV_INITRD is not set
52# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 56# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
53CONFIG_SYSCTL=y 57CONFIG_SYSCTL=y
54CONFIG_EMBEDDED=y 58CONFIG_EMBEDDED=y
55CONFIG_UID16=y 59CONFIG_UID16=y
56CONFIG_SYSCTL_SYSCALL=y 60CONFIG_SYSCTL_SYSCALL=y
61CONFIG_SYSCTL_SYSCALL_CHECK=y
57# CONFIG_KALLSYMS is not set 62# CONFIG_KALLSYMS is not set
58CONFIG_HOTPLUG=y 63CONFIG_HOTPLUG=y
59CONFIG_PRINTK=y 64CONFIG_PRINTK=y
60CONFIG_BUG=y 65CONFIG_BUG=y
61CONFIG_ELF_CORE=y 66CONFIG_ELF_CORE=y
67CONFIG_COMPAT_BRK=y
62CONFIG_BASE_FULL=y 68CONFIG_BASE_FULL=y
63CONFIG_FUTEX=y 69CONFIG_FUTEX=y
70CONFIG_ANON_INODES=y
64CONFIG_EPOLL=y 71CONFIG_EPOLL=y
72CONFIG_SIGNALFD=y
73CONFIG_TIMERFD=y
74CONFIG_EVENTFD=y
65CONFIG_SHMEM=y 75CONFIG_SHMEM=y
66CONFIG_SLAB=y
67CONFIG_VM_EVENT_COUNTERS=y 76CONFIG_VM_EVENT_COUNTERS=y
77CONFIG_SLAB=y
78# CONFIG_SLUB is not set
79# CONFIG_SLOB is not set
80# CONFIG_PROFILING is not set
81# CONFIG_MARKERS is not set
82CONFIG_HAVE_OPROFILE=y
83# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
84# CONFIG_HAVE_IOREMAP_PROT is not set
85CONFIG_HAVE_KPROBES=y
86CONFIG_HAVE_KRETPROBES=y
87# CONFIG_HAVE_ARCH_TRACEHOOK is not set
88# CONFIG_HAVE_DMA_ATTRS is not set
89# CONFIG_USE_GENERIC_SMP_HELPERS is not set
90CONFIG_HAVE_CLK=y
91CONFIG_PROC_PAGE_MONITOR=y
92CONFIG_SLABINFO=y
68CONFIG_RT_MUTEXES=y 93CONFIG_RT_MUTEXES=y
69# CONFIG_TINY_SHMEM is not set 94# CONFIG_TINY_SHMEM is not set
70CONFIG_BASE_SMALL=0 95CONFIG_BASE_SMALL=0
71# CONFIG_SLOB is not set
72
73#
74# Loadable module support
75#
76CONFIG_MODULES=y 96CONFIG_MODULES=y
97# CONFIG_MODULE_FORCE_LOAD is not set
77CONFIG_MODULE_UNLOAD=y 98CONFIG_MODULE_UNLOAD=y
78CONFIG_MODULE_FORCE_UNLOAD=y 99CONFIG_MODULE_FORCE_UNLOAD=y
79# CONFIG_MODVERSIONS is not set 100# CONFIG_MODVERSIONS is not set
80# CONFIG_MODULE_SRCVERSION_ALL is not set 101# CONFIG_MODULE_SRCVERSION_ALL is not set
81CONFIG_KMOD=y 102CONFIG_KMOD=y
82
83#
84# Block layer
85#
86CONFIG_BLOCK=y 103CONFIG_BLOCK=y
87# CONFIG_LBD is not set 104# CONFIG_LBD is not set
88# CONFIG_BLK_DEV_IO_TRACE is not set 105# CONFIG_BLK_DEV_IO_TRACE is not set
89# CONFIG_LSF is not set 106# CONFIG_LSF is not set
107# CONFIG_BLK_DEV_BSG is not set
108# CONFIG_BLK_DEV_INTEGRITY is not set
90 109
91# 110#
92# IO Schedulers 111# IO Schedulers
@@ -100,6 +119,7 @@ CONFIG_DEFAULT_AS=y
100# CONFIG_DEFAULT_CFQ is not set 119# CONFIG_DEFAULT_CFQ is not set
101# CONFIG_DEFAULT_NOOP is not set 120# CONFIG_DEFAULT_NOOP is not set
102CONFIG_DEFAULT_IOSCHED="anticipatory" 121CONFIG_DEFAULT_IOSCHED="anticipatory"
122CONFIG_CLASSIC_RCU=y
103 123
104# 124#
105# System Type 125# System Type
@@ -111,21 +131,26 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
111# CONFIG_ARCH_AT91 is not set 131# CONFIG_ARCH_AT91 is not set
112# CONFIG_ARCH_CLPS7500 is not set 132# CONFIG_ARCH_CLPS7500 is not set
113# CONFIG_ARCH_CLPS711X is not set 133# CONFIG_ARCH_CLPS711X is not set
114# CONFIG_ARCH_CO285 is not set
115# CONFIG_ARCH_EBSA110 is not set 134# CONFIG_ARCH_EBSA110 is not set
116# CONFIG_ARCH_EP93XX is not set 135# CONFIG_ARCH_EP93XX is not set
117# CONFIG_ARCH_FOOTBRIDGE is not set 136# CONFIG_ARCH_FOOTBRIDGE is not set
118# CONFIG_ARCH_NETX is not set 137# CONFIG_ARCH_NETX is not set
119# CONFIG_ARCH_H720X is not set 138# CONFIG_ARCH_H720X is not set
120# CONFIG_ARCH_IMX is not set 139# CONFIG_ARCH_IMX is not set
140# CONFIG_ARCH_IOP13XX is not set
121# CONFIG_ARCH_IOP32X is not set 141# CONFIG_ARCH_IOP32X is not set
122# CONFIG_ARCH_IOP33X is not set 142# CONFIG_ARCH_IOP33X is not set
123# CONFIG_ARCH_IOP13XX is not set
124# CONFIG_ARCH_IXP4XX is not set
125# CONFIG_ARCH_IXP2000 is not set
126# CONFIG_ARCH_IXP23XX is not set 143# CONFIG_ARCH_IXP23XX is not set
144# CONFIG_ARCH_IXP2000 is not set
145# CONFIG_ARCH_IXP4XX is not set
127# CONFIG_ARCH_L7200 is not set 146# CONFIG_ARCH_L7200 is not set
147# CONFIG_ARCH_KIRKWOOD is not set
148# CONFIG_ARCH_KS8695 is not set
128# CONFIG_ARCH_NS9XXX is not set 149# CONFIG_ARCH_NS9XXX is not set
150# CONFIG_ARCH_LOKI is not set
151# CONFIG_ARCH_MV78XX0 is not set
152# CONFIG_ARCH_MXC is not set
153# CONFIG_ARCH_ORION5X is not set
129# CONFIG_ARCH_PNX4008 is not set 154# CONFIG_ARCH_PNX4008 is not set
130CONFIG_ARCH_PXA=y 155CONFIG_ARCH_PXA=y
131# CONFIG_ARCH_RPC is not set 156# CONFIG_ARCH_RPC is not set
@@ -133,80 +158,48 @@ CONFIG_ARCH_PXA=y
133# CONFIG_ARCH_S3C2410 is not set 158# CONFIG_ARCH_S3C2410 is not set
134# CONFIG_ARCH_SHARK is not set 159# CONFIG_ARCH_SHARK is not set
135# CONFIG_ARCH_LH7A40X is not set 160# CONFIG_ARCH_LH7A40X is not set
161# CONFIG_ARCH_DAVINCI is not set
136# CONFIG_ARCH_OMAP is not set 162# CONFIG_ARCH_OMAP is not set
137# CONFIG_BOARD_IRQ_MAP_SMALL is not set 163# CONFIG_ARCH_MSM7X00A is not set
138CONFIG_BOARD_IRQ_MAP_BIG=y
139CONFIG_DMABOUNCE=y
140 164
141# 165#
142# Intel PXA2xx Implementations 166# Intel PXA2xx/PXA3xx Implementations
143# 167#
168# CONFIG_ARCH_GUMSTIX is not set
144# CONFIG_ARCH_LUBBOCK is not set 169# CONFIG_ARCH_LUBBOCK is not set
145# CONFIG_MACH_LOGICPD_PXA270 is not set 170# CONFIG_MACH_LOGICPD_PXA270 is not set
146# CONFIG_MACH_MAINSTONE is not set 171# CONFIG_MACH_MAINSTONE is not set
147# CONFIG_ARCH_PXA_IDP is not set 172# CONFIG_ARCH_PXA_IDP is not set
148CONFIG_TOSHIBA_TMIO_OHCI=y 173# CONFIG_PXA_SHARPSL is not set
149CONFIG_ARCH_ESERIES=y 174CONFIG_ARCH_PXA_ESERIES=y
150CONFIG_MACH_E330=y 175CONFIG_MACH_E330=y
176CONFIG_MACH_E350=y
151CONFIG_MACH_E740=y 177CONFIG_MACH_E740=y
152CONFIG_MACH_E750=y 178CONFIG_MACH_E750=y
153CONFIG_MACH_E400=y 179CONFIG_MACH_E400=y
154CONFIG_MACH_E800=y 180CONFIG_MACH_E800=y
155CONFIG_E330_LCD=y
156CONFIG_E740_LCD=y
157CONFIG_E750_LCD=y
158CONFIG_E400_LCD=y
159CONFIG_E800_LCD=y
160CONFIG_ESERIES_UDC=y
161CONFIG_E330_TC6387XB=y
162CONFIG_E740_T7L66XB=y
163CONFIG_E400_T7L66XB=y
164CONFIG_E750_E800_TC6393XB=y
165CONFIG_E740_PCMCIA=m
166CONFIG_E750_PCMCIA=m
167CONFIG_E800_PCMCIA=m
168# CONFIG_MACH_A620 is not set
169# CONFIG_MACH_A716 is not set
170# CONFIG_MACH_A730 is not set
171# CONFIG_ARCH_H1900 is not set
172# CONFIG_ARCH_H2200 is not set
173# CONFIG_MACH_H3900 is not set
174# CONFIG_MACH_H4000 is not set
175# CONFIG_MACH_H4700 is not set
176# CONFIG_MACH_HX2750 is not set
177# CONFIG_ARCH_H5400 is not set
178# CONFIG_MACH_HIMALAYA is not set
179# CONFIG_MACH_HTCUNIVERSAL is not set
180# CONFIG_MACH_HTCALPINE is not set
181# CONFIG_MACH_MAGICIAN is not set
182# CONFIG_MACH_HTCAPACHE is not set
183# CONFIG_MACH_BLUEANGEL is not set
184
185#
186# HTC_HW6X00
187#
188# CONFIG_MACH_HTCBEETLES is not set
189# CONFIG_MACH_HW6900 is not set
190# CONFIG_MACH_HTCATHENA is not set
191# CONFIG_ARCH_AXIMX3 is not set
192# CONFIG_ARCH_AXIMX5 is not set
193# CONFIG_MACH_X50 is not set
194# CONFIG_ARCH_ROVERP1 is not set
195# CONFIG_ARCH_ROVERP5P is not set
196# CONFIG_MACH_XSCALE_PALMLD is not set
197# CONFIG_MACH_T3XSCALE is not set
198# CONFIG_MACH_RECON is not set
199# CONFIG_MACH_GHI270HG is not set
200# CONFIG_MACH_GHI270 is not set
201# CONFIG_MACH_LOOXC550 is not set
202# CONFIG_PXA_SHARPSL is not set
203# CONFIG_MACH_TRIZEPS4 is not set 181# CONFIG_MACH_TRIZEPS4 is not set
182# CONFIG_MACH_EM_X270 is not set
183# CONFIG_MACH_COLIBRI is not set
184# CONFIG_MACH_ZYLONITE is not set
185# CONFIG_MACH_LITTLETON is not set
186# CONFIG_MACH_TAVOREVB is not set
187# CONFIG_MACH_SAAR is not set
188# CONFIG_MACH_ARMCORE is not set
189# CONFIG_MACH_MAGICIAN is not set
190# CONFIG_MACH_PCM027 is not set
191# CONFIG_ARCH_PXA_PALM is not set
192# CONFIG_PXA_EZX is not set
204CONFIG_PXA25x=y 193CONFIG_PXA25x=y
194# CONFIG_PXA_PWM is not set
195
196#
197# Boot options
198#
205 199
206# 200#
207# Linux As Bootloader 201# Power management
208# 202#
209# CONFIG_LAB is not set
210 203
211# 204#
212# Processor Type 205# Processor Type
@@ -215,6 +208,7 @@ CONFIG_CPU_32=y
215CONFIG_CPU_XSCALE=y 208CONFIG_CPU_XSCALE=y
216CONFIG_CPU_32v5=y 209CONFIG_CPU_32v5=y
217CONFIG_CPU_ABRT_EV5T=y 210CONFIG_CPU_ABRT_EV5T=y
211CONFIG_CPU_PABRT_NOIFAR=y
218CONFIG_CPU_CACHE_VIVT=y 212CONFIG_CPU_CACHE_VIVT=y
219CONFIG_CPU_TLB_V4WBI=y 213CONFIG_CPU_TLB_V4WBI=y
220CONFIG_CPU_CP15=y 214CONFIG_CPU_CP15=y
@@ -232,11 +226,9 @@ CONFIG_XSCALE_PMU=y
232# 226#
233# Bus support 227# Bus support
234# 228#
235 229# CONFIG_PCI_SYSCALL is not set
236# 230# CONFIG_ARCH_SUPPORTS_MSI is not set
237# PCCARD (PCMCIA/CardBus) support 231CONFIG_PCCARD=y
238#
239CONFIG_PCCARD=m
240# CONFIG_PCMCIA_DEBUG is not set 232# CONFIG_PCMCIA_DEBUG is not set
241CONFIG_PCMCIA=m 233CONFIG_PCMCIA=m
242CONFIG_PCMCIA_LOAD_CIS=y 234CONFIG_PCMCIA_LOAD_CIS=y
@@ -245,11 +237,14 @@ CONFIG_PCMCIA_IOCTL=y
245# 237#
246# PC-card bridges 238# PC-card bridges
247# 239#
248CONFIG_PCMCIA_PXA2XX=m
249 240
250# 241#
251# Kernel Features 242# Kernel Features
252# 243#
244CONFIG_TICK_ONESHOT=y
245# CONFIG_NO_HZ is not set
246# CONFIG_HIGH_RES_TIMERS is not set
247CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
253# CONFIG_PREEMPT is not set 248# CONFIG_PREEMPT is not set
254CONFIG_HZ=100 249CONFIG_HZ=100
255CONFIG_AEABI=y 250CONFIG_AEABI=y
@@ -262,9 +257,13 @@ CONFIG_FLATMEM_MANUAL=y
262CONFIG_FLATMEM=y 257CONFIG_FLATMEM=y
263CONFIG_FLAT_NODE_MEM_MAP=y 258CONFIG_FLAT_NODE_MEM_MAP=y
264# CONFIG_SPARSEMEM_STATIC is not set 259# CONFIG_SPARSEMEM_STATIC is not set
260# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
261CONFIG_PAGEFLAGS_EXTENDED=y
265CONFIG_SPLIT_PTLOCK_CPUS=4096 262CONFIG_SPLIT_PTLOCK_CPUS=4096
266# CONFIG_RESOURCES_64BIT is not set 263# CONFIG_RESOURCES_64BIT is not set
267CONFIG_ZONE_DMA_FLAG=1 264CONFIG_ZONE_DMA_FLAG=1
265CONFIG_BOUNCE=y
266CONFIG_VIRT_TO_BUS=y
268CONFIG_ALIGNMENT_TRAP=y 267CONFIG_ALIGNMENT_TRAP=y
269 268
270# 269#
@@ -275,7 +274,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
275CONFIG_CMDLINE="" 274CONFIG_CMDLINE=""
276# CONFIG_XIP_KERNEL is not set 275# CONFIG_XIP_KERNEL is not set
277CONFIG_KEXEC=y 276CONFIG_KEXEC=y
278# CONFIG_TXTOFFSET_DELTA is not set 277CONFIG_ATAGS_PROC=y
279 278
280# 279#
281# CPU Frequency scaling 280# CPU Frequency scaling
@@ -304,11 +303,12 @@ CONFIG_BINFMT_MISC=y
304# Power management options 303# Power management options
305# 304#
306CONFIG_PM=y 305CONFIG_PM=y
307CONFIG_PM_LEGACY=y
308# CONFIG_PM_DEBUG is not set 306# CONFIG_PM_DEBUG is not set
309# CONFIG_DPM_DEBUG is not set 307CONFIG_PM_SLEEP=y
310# CONFIG_PM_SYSFS_DEPRECATED is not set 308CONFIG_SUSPEND=y
309CONFIG_SUSPEND_FREEZER=y
311# CONFIG_APM_EMULATION is not set 310# CONFIG_APM_EMULATION is not set
311CONFIG_ARCH_SUSPEND_POSSIBLE=y
312 312
313# 313#
314# Networking 314# Networking
@@ -318,13 +318,13 @@ CONFIG_NET=y
318# 318#
319# Networking options 319# Networking options
320# 320#
321# CONFIG_NETDEBUG is not set
322# CONFIG_PACKET is not set 321# CONFIG_PACKET is not set
323CONFIG_UNIX=y 322CONFIG_UNIX=y
324CONFIG_XFRM=y 323CONFIG_XFRM=y
325# CONFIG_XFRM_USER is not set 324# CONFIG_XFRM_USER is not set
326# CONFIG_XFRM_SUB_POLICY is not set 325# CONFIG_XFRM_SUB_POLICY is not set
327# CONFIG_XFRM_MIGRATE is not set 326# CONFIG_XFRM_MIGRATE is not set
327# CONFIG_XFRM_STATISTICS is not set
328# CONFIG_NET_KEY is not set 328# CONFIG_NET_KEY is not set
329CONFIG_INET=y 329CONFIG_INET=y
330# CONFIG_IP_MULTICAST is not set 330# CONFIG_IP_MULTICAST is not set
@@ -339,35 +339,40 @@ CONFIG_IP_FIB_HASH=y
339# CONFIG_INET_ESP is not set 339# CONFIG_INET_ESP is not set
340# CONFIG_INET_IPCOMP is not set 340# CONFIG_INET_IPCOMP is not set
341# CONFIG_INET_XFRM_TUNNEL is not set 341# CONFIG_INET_XFRM_TUNNEL is not set
342# CONFIG_INET_TUNNEL is not set 342CONFIG_INET_TUNNEL=y
343CONFIG_INET_XFRM_MODE_TRANSPORT=y 343CONFIG_INET_XFRM_MODE_TRANSPORT=y
344CONFIG_INET_XFRM_MODE_TUNNEL=y 344CONFIG_INET_XFRM_MODE_TUNNEL=y
345CONFIG_INET_XFRM_MODE_BEET=y 345CONFIG_INET_XFRM_MODE_BEET=y
346# CONFIG_INET_LRO is not set
346CONFIG_INET_DIAG=y 347CONFIG_INET_DIAG=y
347CONFIG_INET_TCP_DIAG=y 348CONFIG_INET_TCP_DIAG=y
348# CONFIG_TCP_CONG_ADVANCED is not set 349# CONFIG_TCP_CONG_ADVANCED is not set
349CONFIG_TCP_CONG_CUBIC=y 350CONFIG_TCP_CONG_CUBIC=y
350CONFIG_DEFAULT_TCP_CONG="cubic" 351CONFIG_DEFAULT_TCP_CONG="cubic"
351# CONFIG_TCP_MD5SIG is not set 352# CONFIG_TCP_MD5SIG is not set
352# CONFIG_IPV6 is not set 353CONFIG_IPV6=y
354# CONFIG_IPV6_PRIVACY is not set
355# CONFIG_IPV6_ROUTER_PREF is not set
356# CONFIG_IPV6_OPTIMISTIC_DAD is not set
357# CONFIG_INET6_AH is not set
358# CONFIG_INET6_ESP is not set
359# CONFIG_INET6_IPCOMP is not set
360# CONFIG_IPV6_MIP6 is not set
353# CONFIG_INET6_XFRM_TUNNEL is not set 361# CONFIG_INET6_XFRM_TUNNEL is not set
354# CONFIG_INET6_TUNNEL is not set 362# CONFIG_INET6_TUNNEL is not set
363CONFIG_INET6_XFRM_MODE_TRANSPORT=y
364CONFIG_INET6_XFRM_MODE_TUNNEL=y
365CONFIG_INET6_XFRM_MODE_BEET=y
366# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
367CONFIG_IPV6_SIT=y
368CONFIG_IPV6_NDISC_NODETYPE=y
369# CONFIG_IPV6_TUNNEL is not set
370# CONFIG_IPV6_MULTIPLE_TABLES is not set
371# CONFIG_IPV6_MROUTE is not set
355# CONFIG_NETWORK_SECMARK is not set 372# CONFIG_NETWORK_SECMARK is not set
356# CONFIG_NETFILTER is not set 373# CONFIG_NETFILTER is not set
357
358#
359# DCCP Configuration (EXPERIMENTAL)
360#
361# CONFIG_IP_DCCP is not set 374# CONFIG_IP_DCCP is not set
362
363#
364# SCTP Configuration (EXPERIMENTAL)
365#
366# CONFIG_IP_SCTP is not set 375# CONFIG_IP_SCTP is not set
367
368#
369# TIPC Configuration (EXPERIMENTAL)
370#
371# CONFIG_TIPC is not set 376# CONFIG_TIPC is not set
372# CONFIG_ATM is not set 377# CONFIG_ATM is not set
373# CONFIG_BRIDGE is not set 378# CONFIG_BRIDGE is not set
@@ -380,10 +385,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
380# CONFIG_LAPB is not set 385# CONFIG_LAPB is not set
381# CONFIG_ECONET is not set 386# CONFIG_ECONET is not set
382# CONFIG_WAN_ROUTER is not set 387# CONFIG_WAN_ROUTER is not set
383
384#
385# QoS and/or fair queueing
386#
387# CONFIG_NET_SCHED is not set 388# CONFIG_NET_SCHED is not set
388 389
389# 390#
@@ -391,15 +392,74 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
391# 392#
392# CONFIG_NET_PKTGEN is not set 393# CONFIG_NET_PKTGEN is not set
393# CONFIG_HAMRADIO is not set 394# CONFIG_HAMRADIO is not set
394# CONFIG_IRDA is not set 395# CONFIG_CAN is not set
396CONFIG_IRDA=y
397
398#
399# IrDA protocols
400#
401CONFIG_IRLAN=m
402CONFIG_IRCOMM=m
403CONFIG_IRDA_ULTRA=y
404
405#
406# IrDA options
407#
408CONFIG_IRDA_CACHE_LAST_LSAP=y
409CONFIG_IRDA_FAST_RR=y
410# CONFIG_IRDA_DEBUG is not set
411
412#
413# Infrared-port device drivers
414#
415
416#
417# SIR device drivers
418#
419# CONFIG_IRTTY_SIR is not set
420
421#
422# Dongle support
423#
424# CONFIG_KINGSUN_DONGLE is not set
425# CONFIG_KSDAZZLE_DONGLE is not set
426# CONFIG_KS959_DONGLE is not set
427
428#
429# FIR device drivers
430#
431# CONFIG_USB_IRDA is not set
432# CONFIG_SIGMATEL_FIR is not set
433CONFIG_PXA_FICP=y
434# CONFIG_MCS_FIR is not set
395# CONFIG_BT is not set 435# CONFIG_BT is not set
436# CONFIG_AF_RXRPC is not set
437
438#
439# Wireless
440#
441CONFIG_CFG80211=m
442CONFIG_NL80211=y
443CONFIG_WIRELESS_EXT=y
444CONFIG_WIRELESS_EXT_SYSFS=y
445CONFIG_MAC80211=m
446
447#
448# Rate control algorithm selection
449#
450CONFIG_MAC80211_RC_PID=y
451CONFIG_MAC80211_RC_DEFAULT_PID=y
452CONFIG_MAC80211_RC_DEFAULT="pid"
453# CONFIG_MAC80211_MESH is not set
454# CONFIG_MAC80211_LEDS is not set
455# CONFIG_MAC80211_DEBUG_MENU is not set
396CONFIG_IEEE80211=m 456CONFIG_IEEE80211=m
397# CONFIG_IEEE80211_DEBUG is not set 457# CONFIG_IEEE80211_DEBUG is not set
398CONFIG_IEEE80211_CRYPT_WEP=m 458CONFIG_IEEE80211_CRYPT_WEP=m
399# CONFIG_IEEE80211_CRYPT_CCMP is not set 459CONFIG_IEEE80211_CRYPT_CCMP=m
400# CONFIG_IEEE80211_CRYPT_TKIP is not set 460CONFIG_IEEE80211_CRYPT_TKIP=m
401# CONFIG_IEEE80211_SOFTMAC is not set 461# CONFIG_RFKILL is not set
402CONFIG_WIRELESS_EXT=y 462# CONFIG_NET_9P is not set
403 463
404# 464#
405# Device Drivers 465# Device Drivers
@@ -408,38 +468,32 @@ CONFIG_WIRELESS_EXT=y
408# 468#
409# Generic Driver Options 469# Generic Driver Options
410# 470#
471CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
411# CONFIG_STANDALONE is not set 472# CONFIG_STANDALONE is not set
412CONFIG_PREVENT_FIRMWARE_BUILD=y 473CONFIG_PREVENT_FIRMWARE_BUILD=y
413CONFIG_FW_LOADER=y 474CONFIG_FW_LOADER=y
475CONFIG_FIRMWARE_IN_KERNEL=y
476CONFIG_EXTRA_FIRMWARE=""
414# CONFIG_SYS_HYPERVISOR is not set 477# CONFIG_SYS_HYPERVISOR is not set
415
416#
417# Connector - unified userspace <-> kernelspace linker
418#
419# CONFIG_CONNECTOR is not set 478# CONFIG_CONNECTOR is not set
420
421#
422# Memory Technology Devices (MTD)
423#
424CONFIG_MTD=m 479CONFIG_MTD=m
425# CONFIG_MTD_DEBUG is not set 480# CONFIG_MTD_DEBUG is not set
426# CONFIG_MTD_CONCAT is not set 481# CONFIG_MTD_CONCAT is not set
427CONFIG_MTD_PARTITIONS=y 482# CONFIG_MTD_PARTITIONS is not set
428# CONFIG_MTD_REDBOOT_PARTS is not set
429# CONFIG_MTD_AFS_PARTS is not set
430 483
431# 484#
432# User Modules And Translation Layers 485# User Modules And Translation Layers
433# 486#
434CONFIG_MTD_CHAR=m 487# CONFIG_MTD_CHAR is not set
435CONFIG_MTD_BLKDEVS=m 488# CONFIG_MTD_BLKDEVS is not set
436CONFIG_MTD_BLOCK=m 489# CONFIG_MTD_BLOCK is not set
437# CONFIG_MTD_BLOCK_RO is not set 490# CONFIG_MTD_BLOCK_RO is not set
438# CONFIG_FTL is not set 491# CONFIG_FTL is not set
439# CONFIG_NFTL is not set 492# CONFIG_NFTL is not set
440# CONFIG_INFTL is not set 493# CONFIG_INFTL is not set
441# CONFIG_RFD_FTL is not set 494# CONFIG_RFD_FTL is not set
442# CONFIG_SSFDC is not set 495# CONFIG_SSFDC is not set
496# CONFIG_MTD_OOPS is not set
443 497
444# 498#
445# RAM/ROM/Flash chip drivers 499# RAM/ROM/Flash chip drivers
@@ -459,7 +513,6 @@ CONFIG_MTD_CFI_I2=y
459# CONFIG_MTD_RAM is not set 513# CONFIG_MTD_RAM is not set
460# CONFIG_MTD_ROM is not set 514# CONFIG_MTD_ROM is not set
461# CONFIG_MTD_ABSENT is not set 515# CONFIG_MTD_ABSENT is not set
462# CONFIG_MTD_OBSOLETE_CHIPS is not set
463 516
464# 517#
465# Mapping drivers for chip access 518# Mapping drivers for chip access
@@ -482,82 +535,43 @@ CONFIG_MTD_CFI_I2=y
482# CONFIG_MTD_DOC2000 is not set 535# CONFIG_MTD_DOC2000 is not set
483# CONFIG_MTD_DOC2001 is not set 536# CONFIG_MTD_DOC2001 is not set
484# CONFIG_MTD_DOC2001PLUS is not set 537# CONFIG_MTD_DOC2001PLUS is not set
485
486#
487# NAND Flash Device Drivers
488#
489CONFIG_MTD_NAND=m 538CONFIG_MTD_NAND=m
490CONFIG_MTD_NAND_VERIFY_WRITE=y 539# CONFIG_MTD_NAND_VERIFY_WRITE is not set
491# CONFIG_MTD_NAND_ECC_SMC is not set 540# CONFIG_MTD_NAND_ECC_SMC is not set
492# CONFIG_MTD_NAND_H1900 is not set 541# CONFIG_MTD_NAND_MUSEUM_IDS is not set
493CONFIG_MTD_NAND_IDS=m 542CONFIG_MTD_NAND_IDS=m
494# CONFIG_MTD_NAND_DISKONCHIP is not set 543# CONFIG_MTD_NAND_DISKONCHIP is not set
495# CONFIG_MTD_NAND_SHARPSL is not set 544# CONFIG_MTD_NAND_SHARPSL is not set
496# CONFIG_MTD_NAND_NANDSIM is not set 545# CONFIG_MTD_NAND_PLATFORM is not set
497 546# CONFIG_MTD_ALAUDA is not set
498#
499# OneNAND Flash Device Drivers
500#
501# CONFIG_MTD_ONENAND is not set 547# CONFIG_MTD_ONENAND is not set
502 548
503# 549#
504# Parallel port support 550# UBI - Unsorted block images
505# 551#
552# CONFIG_MTD_UBI is not set
506# CONFIG_PARPORT is not set 553# CONFIG_PARPORT is not set
507 554CONFIG_BLK_DEV=y
508#
509# Plug and Play support
510#
511# CONFIG_PNPACPI is not set
512
513#
514# Block devices
515#
516# CONFIG_BLK_DEV_COW_COMMON is not set 555# CONFIG_BLK_DEV_COW_COMMON is not set
517CONFIG_BLK_DEV_LOOP=m 556CONFIG_BLK_DEV_LOOP=m
518# CONFIG_BLK_DEV_CRYPTOLOOP is not set 557# CONFIG_BLK_DEV_CRYPTOLOOP is not set
519# CONFIG_BLK_DEV_NBD is not set 558# CONFIG_BLK_DEV_NBD is not set
520# CONFIG_BLK_DEV_UB is not set 559# CONFIG_BLK_DEV_UB is not set
521CONFIG_BLK_DEV_RAM=y 560# CONFIG_BLK_DEV_RAM is not set
522CONFIG_BLK_DEV_RAM_COUNT=16
523CONFIG_BLK_DEV_RAM_SIZE=6144
524CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
525# CONFIG_CDROM_PKTCDVD is not set 561# CONFIG_CDROM_PKTCDVD is not set
526# CONFIG_ATA_OVER_ETH is not set 562# CONFIG_ATA_OVER_ETH is not set
527 563CONFIG_MISC_DEVICES=y
528# 564# CONFIG_EEPROM_93CX6 is not set
529# ATA/ATAPI/MFM/RLL support 565# CONFIG_ENCLOSURE_SERVICES is not set
530# 566CONFIG_HAVE_IDE=y
531CONFIG_IDE=m 567# CONFIG_IDE is not set
532CONFIG_IDE_MAX_HWIFS=4
533CONFIG_BLK_DEV_IDE=m
534
535#
536# Please see Documentation/ide.txt for help/info on IDE drives
537#
538# CONFIG_BLK_DEV_IDE_SATA is not set
539CONFIG_BLK_DEV_IDEDISK=m
540# CONFIG_IDEDISK_MULTI_MODE is not set
541# CONFIG_BLK_DEV_IDECS is not set
542# CONFIG_BLK_DEV_IDECD is not set
543# CONFIG_BLK_DEV_IDETAPE is not set
544# CONFIG_BLK_DEV_IDEFLOPPY is not set
545# CONFIG_BLK_DEV_IDESCSI is not set
546# CONFIG_IDE_TASK_IOCTL is not set
547
548#
549# IDE chipset support/bugfixes
550#
551# CONFIG_IDE_GENERIC is not set
552# CONFIG_IDE_ARM is not set
553# CONFIG_BLK_DEV_IDEDMA is not set
554# CONFIG_BLK_DEV_HD is not set
555 568
556# 569#
557# SCSI device support 570# SCSI device support
558# 571#
559# CONFIG_RAID_ATTRS is not set 572# CONFIG_RAID_ATTRS is not set
560CONFIG_SCSI=m 573CONFIG_SCSI=m
574CONFIG_SCSI_DMA=y
561# CONFIG_SCSI_TGT is not set 575# CONFIG_SCSI_TGT is not set
562# CONFIG_SCSI_NETLINK is not set 576# CONFIG_SCSI_NETLINK is not set
563# CONFIG_SCSI_PROC_FS is not set 577# CONFIG_SCSI_PROC_FS is not set
@@ -565,7 +579,7 @@ CONFIG_SCSI=m
565# 579#
566# SCSI support type (disk, tape, CD-ROM) 580# SCSI support type (disk, tape, CD-ROM)
567# 581#
568# CONFIG_BLK_DEV_SD is not set 582CONFIG_BLK_DEV_SD=m
569# CONFIG_CHR_DEV_ST is not set 583# CONFIG_CHR_DEV_ST is not set
570# CONFIG_CHR_DEV_OSST is not set 584# CONFIG_CHR_DEV_OSST is not set
571# CONFIG_BLK_DEV_SR is not set 585# CONFIG_BLK_DEV_SR is not set
@@ -579,6 +593,7 @@ CONFIG_SCSI=m
579# CONFIG_SCSI_CONSTANTS is not set 593# CONFIG_SCSI_CONSTANTS is not set
580# CONFIG_SCSI_LOGGING is not set 594# CONFIG_SCSI_LOGGING is not set
581# CONFIG_SCSI_SCAN_ASYNC is not set 595# CONFIG_SCSI_SCAN_ASYNC is not set
596CONFIG_SCSI_WAIT_SCAN=m
582 597
583# 598#
584# SCSI Transports 599# SCSI Transports
@@ -586,132 +601,78 @@ CONFIG_SCSI=m
586# CONFIG_SCSI_SPI_ATTRS is not set 601# CONFIG_SCSI_SPI_ATTRS is not set
587# CONFIG_SCSI_FC_ATTRS is not set 602# CONFIG_SCSI_FC_ATTRS is not set
588# CONFIG_SCSI_ISCSI_ATTRS is not set 603# CONFIG_SCSI_ISCSI_ATTRS is not set
589# CONFIG_SCSI_SAS_ATTRS is not set
590# CONFIG_SCSI_SAS_LIBSAS is not set 604# CONFIG_SCSI_SAS_LIBSAS is not set
591 605# CONFIG_SCSI_SRP_ATTRS is not set
592# 606# CONFIG_SCSI_LOWLEVEL is not set
593# SCSI low-level drivers 607# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set
594# 608# CONFIG_SCSI_DH is not set
595# CONFIG_ISCSI_TCP is not set 609CONFIG_ATA=m
596# CONFIG_SCSI_DEBUG is not set 610# CONFIG_ATA_NONSTANDARD is not set
597 611# CONFIG_SATA_PMP is not set
598# 612CONFIG_ATA_SFF=y
599# PCMCIA SCSI adapter support 613# CONFIG_SATA_MV is not set
600# 614CONFIG_PATA_PCMCIA=m
601# CONFIG_PCMCIA_AHA152X is not set 615# CONFIG_PATA_PLATFORM is not set
602# CONFIG_PCMCIA_FDOMAIN is not set
603# CONFIG_PCMCIA_NINJA_SCSI is not set
604# CONFIG_PCMCIA_QLOGIC is not set
605# CONFIG_PCMCIA_SYM53C500 is not set
606
607#
608# Serial ATA (prod) and Parallel ATA (experimental) drivers
609#
610# CONFIG_ATA is not set
611
612#
613# Multi-device support (RAID and LVM)
614#
615# CONFIG_MD is not set 616# CONFIG_MD is not set
616
617#
618# Fusion MPT device support
619#
620# CONFIG_FUSION is not set
621
622#
623# IEEE 1394 (FireWire) support
624#
625
626#
627# I2O device support
628#
629
630#
631# Network device support
632#
633CONFIG_NETDEVICES=y 617CONFIG_NETDEVICES=y
634# CONFIG_DUMMY is not set 618# CONFIG_DUMMY is not set
635# CONFIG_BONDING is not set 619# CONFIG_BONDING is not set
620# CONFIG_MACVLAN is not set
636# CONFIG_EQUALIZER is not set 621# CONFIG_EQUALIZER is not set
637# CONFIG_TUN is not set 622# CONFIG_TUN is not set
638 623# CONFIG_VETH is not set
639#
640# PHY device support
641#
642
643#
644# Ethernet (10 or 100Mbit)
645#
646# CONFIG_NET_ETHERNET is not set 624# CONFIG_NET_ETHERNET is not set
625# CONFIG_NETDEV_1000 is not set
626# CONFIG_NETDEV_10000 is not set
647 627
648# 628#
649# Ethernet (1000 Mbit) 629# Wireless LAN
650#
651
652#
653# Ethernet (10000 Mbit)
654#
655
656#
657# Token Ring devices
658#
659
660#
661# Wireless LAN (non-hamradio)
662#
663CONFIG_NET_RADIO=y
664# CONFIG_NET_WIRELESS_RTNETLINK is not set
665
666#
667# Obsolete Wireless cards support (pre-802.11)
668#
669# CONFIG_STRIP is not set
670# CONFIG_PCMCIA_WAVELAN is not set
671# CONFIG_PCMCIA_NETWAVE is not set
672
673#
674# Wireless 802.11 Frequency Hopping cards support
675# 630#
631# CONFIG_WLAN_PRE80211 is not set
632CONFIG_WLAN_80211=y
676# CONFIG_PCMCIA_RAYCS is not set 633# CONFIG_PCMCIA_RAYCS is not set
677 634# CONFIG_LIBERTAS is not set
678# 635CONFIG_HERMES=m
679# Wireless 802.11b ISA/PCI cards support 636CONFIG_PCMCIA_HERMES=m
680# 637# CONFIG_PCMCIA_SPECTRUM is not set
681# CONFIG_HERMES is not set
682# CONFIG_ATMEL is not set 638# CONFIG_ATMEL is not set
683
684#
685# Wireless 802.11b Pcmcia/Cardbus cards support
686#
687# CONFIG_AIRO_CS is not set 639# CONFIG_AIRO_CS is not set
688# CONFIG_PCMCIA_WL3501 is not set 640# CONFIG_PCMCIA_WL3501 is not set
689# CONFIG_USB_ZD1201 is not set 641# CONFIG_USB_ZD1201 is not set
690CONFIG_HOSTAP=m 642# CONFIG_USB_NET_RNDIS_WLAN is not set
691# CONFIG_HOSTAP_FIRMWARE is not set 643# CONFIG_RTL8187 is not set
692# CONFIG_HOSTAP_CS is not set 644# CONFIG_MAC80211_HWSIM is not set
693# CONFIG_ACX is not set 645# CONFIG_P54_COMMON is not set
694CONFIG_NET_WIRELESS=y 646# CONFIG_IWLWIFI_LEDS is not set
695 647# CONFIG_HOSTAP is not set
696# 648# CONFIG_B43 is not set
697# PCMCIA network device support 649# CONFIG_B43LEGACY is not set
698# 650# CONFIG_ZD1211RW is not set
699# CONFIG_NET_PCMCIA is not set 651# CONFIG_RT2X00 is not set
700 652
701# 653#
702# Wan interfaces 654# USB Network Adapters
703# 655#
656# CONFIG_USB_CATC is not set
657# CONFIG_USB_KAWETH is not set
658# CONFIG_USB_PEGASUS is not set
659# CONFIG_USB_RTL8150 is not set
660# CONFIG_USB_USBNET is not set
661CONFIG_NET_PCMCIA=y
662# CONFIG_PCMCIA_3C589 is not set
663# CONFIG_PCMCIA_3C574 is not set
664# CONFIG_PCMCIA_FMVJ18X is not set
665CONFIG_PCMCIA_PCNET=m
666# CONFIG_PCMCIA_NMCLAN is not set
667# CONFIG_PCMCIA_SMC91C92 is not set
668# CONFIG_PCMCIA_XIRC2PS is not set
669# CONFIG_PCMCIA_AXNET is not set
704# CONFIG_WAN is not set 670# CONFIG_WAN is not set
705# CONFIG_PPP is not set 671# CONFIG_PPP is not set
706# CONFIG_SLIP is not set 672# CONFIG_SLIP is not set
707# CONFIG_SHAPER is not set
708# CONFIG_NETCONSOLE is not set 673# CONFIG_NETCONSOLE is not set
709# CONFIG_NETPOLL is not set 674# CONFIG_NETPOLL is not set
710# CONFIG_NET_POLL_CONTROLLER is not set 675# CONFIG_NET_POLL_CONTROLLER is not set
711
712#
713# ISDN subsystem
714#
715# CONFIG_ISDN is not set 676# CONFIG_ISDN is not set
716 677
717# 678#
@@ -719,38 +680,48 @@ CONFIG_NET_WIRELESS=y
719# 680#
720CONFIG_INPUT=y 681CONFIG_INPUT=y
721# CONFIG_INPUT_FF_MEMLESS is not set 682# CONFIG_INPUT_FF_MEMLESS is not set
683# CONFIG_INPUT_POLLDEV is not set
722 684
723# 685#
724# Userland interfaces 686# Userland interfaces
725# 687#
726# CONFIG_INPUT_MOUSEDEV is not set 688# CONFIG_INPUT_MOUSEDEV is not set
727# CONFIG_INPUT_JOYDEV is not set 689# CONFIG_INPUT_JOYDEV is not set
728CONFIG_INPUT_TSDEV=m
729CONFIG_INPUT_TSDEV_SCREEN_X=240
730CONFIG_INPUT_TSDEV_SCREEN_Y=320
731CONFIG_INPUT_EVDEV=m 690CONFIG_INPUT_EVDEV=m
732# CONFIG_INPUT_EVBUG is not set 691# CONFIG_INPUT_EVBUG is not set
733# CONFIG_INPUT_LED_TRIGGER is not set
734 692
735# 693#
736# Input Device Drivers 694# Input Device Drivers
737# 695#
738# CONFIG_INPUT_KEYBOARD is not set 696CONFIG_INPUT_KEYBOARD=y
697# CONFIG_KEYBOARD_ATKBD is not set
698# CONFIG_KEYBOARD_SUNKBD is not set
699# CONFIG_KEYBOARD_LKKBD is not set
700# CONFIG_KEYBOARD_XTKBD is not set
701# CONFIG_KEYBOARD_NEWTON is not set
702# CONFIG_KEYBOARD_STOWAWAY is not set
703CONFIG_KEYBOARD_GPIO=m
739# CONFIG_INPUT_MOUSE is not set 704# CONFIG_INPUT_MOUSE is not set
740# CONFIG_INPUT_JOYSTICK is not set 705# CONFIG_INPUT_JOYSTICK is not set
706# CONFIG_INPUT_TABLET is not set
741CONFIG_INPUT_TOUCHSCREEN=y 707CONFIG_INPUT_TOUCHSCREEN=y
708# CONFIG_TOUCHSCREEN_FUJITSU is not set
742# CONFIG_TOUCHSCREEN_GUNZE is not set 709# CONFIG_TOUCHSCREEN_GUNZE is not set
743# CONFIG_TOUCHSCREEN_ELO is not set 710# CONFIG_TOUCHSCREEN_ELO is not set
744# CONFIG_TOUCHSCREEN_MTOUCH is not set 711# CONFIG_TOUCHSCREEN_MTOUCH is not set
712# CONFIG_TOUCHSCREEN_INEXIO is not set
745# CONFIG_TOUCHSCREEN_MK712 is not set 713# CONFIG_TOUCHSCREEN_MK712 is not set
746CONFIG_TOUCHSCREEN_WM97XX=m
747CONFIG_TOUCHSCREEN_WM9705=y
748CONFIG_TOUCHSCREEN_WM9712=y
749CONFIG_TOUCHSCREEN_WM9713=y
750# CONFIG_TOUCHSCREEN_PENMOUNT is not set 714# CONFIG_TOUCHSCREEN_PENMOUNT is not set
751# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set 715# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
752# CONFIG_TOUCHSCREEN_TOUCHWIN is not set 716# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
753# CONFIG_TOUCHSCREEN_UCB1400 is not set 717# CONFIG_TOUCHSCREEN_UCB1400 is not set
718CONFIG_TOUCHSCREEN_WM97XX=m
719CONFIG_TOUCHSCREEN_WM9705=y
720CONFIG_TOUCHSCREEN_WM9712=y
721CONFIG_TOUCHSCREEN_WM9713=y
722# CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE is not set
723# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
724# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
754# CONFIG_INPUT_MISC is not set 725# CONFIG_INPUT_MISC is not set
755 726
756# 727#
@@ -763,9 +734,11 @@ CONFIG_TOUCHSCREEN_WM9713=y
763# Character devices 734# Character devices
764# 735#
765CONFIG_VT=y 736CONFIG_VT=y
737CONFIG_CONSOLE_TRANSLATIONS=y
766CONFIG_VT_CONSOLE=y 738CONFIG_VT_CONSOLE=y
767CONFIG_HW_CONSOLE=y 739CONFIG_HW_CONSOLE=y
768# CONFIG_VT_HW_CONSOLE_BINDING is not set 740# CONFIG_VT_HW_CONSOLE_BINDING is not set
741CONFIG_DEVKMEM=y
769# CONFIG_SERIAL_NONSTANDARD is not set 742# CONFIG_SERIAL_NONSTANDARD is not set
770 743
771# 744#
@@ -777,25 +750,12 @@ CONFIG_HW_CONSOLE=y
777# Non-8250 serial port support 750# Non-8250 serial port support
778# 751#
779# CONFIG_SERIAL_PXA is not set 752# CONFIG_SERIAL_PXA is not set
780# CONFIG_RS232_SERIAL is not set
781CONFIG_UNIX98_PTYS=y 753CONFIG_UNIX98_PTYS=y
782# CONFIG_LEGACY_PTYS is not set 754# CONFIG_LEGACY_PTYS is not set
783
784#
785# IPMI
786#
787# CONFIG_IPMI_HANDLER is not set 755# CONFIG_IPMI_HANDLER is not set
788
789#
790# Watchdog Cards
791#
792# CONFIG_WATCHDOG is not set
793CONFIG_HW_RANDOM=m 756CONFIG_HW_RANDOM=m
794# CONFIG_NVRAM is not set 757# CONFIG_NVRAM is not set
795# CONFIG_SA1100_RTC is not set
796# CONFIG_DTLK is not set
797# CONFIG_R3964 is not set 758# CONFIG_R3964 is not set
798# CONFIG_TIHTC is not set
799 759
800# 760#
801# PCMCIA character devices 761# PCMCIA character devices
@@ -803,117 +763,79 @@ CONFIG_HW_RANDOM=m
803# CONFIG_SYNCLINK_CS is not set 763# CONFIG_SYNCLINK_CS is not set
804# CONFIG_CARDMAN_4000 is not set 764# CONFIG_CARDMAN_4000 is not set
805# CONFIG_CARDMAN_4040 is not set 765# CONFIG_CARDMAN_4040 is not set
766# CONFIG_IPWIRELESS is not set
806# CONFIG_RAW_DRIVER is not set 767# CONFIG_RAW_DRIVER is not set
807
808#
809# TPM devices
810#
811# CONFIG_TCG_TPM is not set 768# CONFIG_TCG_TPM is not set
812
813#
814# I2C support
815#
816# CONFIG_I2C is not set 769# CONFIG_I2C is not set
817
818#
819# SPI support
820#
821# CONFIG_SPI is not set 770# CONFIG_SPI is not set
822# CONFIG_SPI_MASTER is not set 771CONFIG_ARCH_REQUIRE_GPIOLIB=y
823 772CONFIG_GPIOLIB=y
824# 773# CONFIG_GPIO_SYSFS is not set
825# Dallas's 1-wire bus
826#
827# CONFIG_W1 is not set
828 774
829# 775#
830# Hardware Monitoring support 776# I2C GPIO expanders:
831#
832# CONFIG_HWMON is not set
833# CONFIG_HWMON_VID is not set
834# CONFIG_POWER_SUPPLY is not set
835
836#
837# L3 serial bus support
838#
839# CONFIG_L3 is not set
840
841#
842# Misc devices
843# 777#
844 778
845# 779#
846# Multimedia Capabilities Port drivers 780# PCI GPIO expanders:
847# 781#
848# CONFIG_ADC is not set
849 782
850# 783#
851# Compaq/iPAQ Drivers 784# SPI GPIO expanders:
852# 785#
786# CONFIG_W1 is not set
787# CONFIG_POWER_SUPPLY is not set
788# CONFIG_HWMON is not set
789# CONFIG_WATCHDOG is not set
853 790
854# 791#
855# Compaq/HP iPAQ Drivers 792# Sonics Silicon Backplane
856# 793#
857# CONFIG_IPAQ_SLEEVE is not set 794CONFIG_SSB_POSSIBLE=y
858# CONFIG_SLEEVE_DEBUG is not set 795# CONFIG_SSB is not set
859 796
860# 797#
861# Multifunction device drivers 798# Multifunction device drivers
862# 799#
800CONFIG_MFD_CORE=y
863# CONFIG_MFD_SM501 is not set 801# CONFIG_MFD_SM501 is not set
864# CONFIG_HTC_ASIC2 is not set
865# CONFIG_HTC_ASIC3 is not set
866# CONFIG_HTC_PASIC3 is not set
867# CONFIG_HTC_EGPIO is not set 802# CONFIG_HTC_EGPIO is not set
868# CONFIG_HTC_BBKEYS is not set 803# CONFIG_HTC_PASIC3 is not set
869# CONFIG_HTC_ASIC3_DS1WM is not set 804CONFIG_MFD_TC6393XB=y
870# CONFIG_SOC_SAMCOP is not set
871# CONFIG_SOC_HAMCOP is not set
872# CONFIG_SOC_MQ11XX is not set
873CONFIG_SOC_T7L66XB=y
874# CONFIG_SOC_TC6387XB is not set
875CONFIG_SOC_TC6393XB=y
876# CONFIG_SOC_TSC2101 is not set
877# CONFIG_SOC_TSC2200 is not set
878
879#
880# LED devices
881#
882# CONFIG_NEW_LEDS is not set
883
884#
885# LED drivers
886#
887 805
888# 806#
889# LED Triggers 807# Multimedia devices
890# 808#
891# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
892 809
893# 810#
894# Multimedia devices 811# Multimedia core support
895# 812#
896# CONFIG_VIDEO_DEV is not set 813# CONFIG_VIDEO_DEV is not set
814# CONFIG_DVB_CORE is not set
815# CONFIG_VIDEO_MEDIA is not set
897 816
898# 817#
899# Digital Video Broadcasting Devices 818# Multimedia drivers
900# 819#
901# CONFIG_DVB is not set 820# CONFIG_DAB is not set
902# CONFIG_USB_DABUSB is not set
903 821
904# 822#
905# Graphics support 823# Graphics support
906# 824#
907CONFIG_BACKLIGHT_LCD_SUPPORT=y 825# CONFIG_VGASTATE is not set
908CONFIG_BACKLIGHT_CLASS_DEVICE=y 826# CONFIG_VIDEO_OUTPUT_CONTROL is not set
909CONFIG_LCD_CLASS_DEVICE=y
910CONFIG_BACKLIGHT_CORGI=y
911CONFIG_FB=y 827CONFIG_FB=y
912# CONFIG_FIRMWARE_EDID is not set 828# CONFIG_FIRMWARE_EDID is not set
913# CONFIG_FB_DDC is not set 829# CONFIG_FB_DDC is not set
914CONFIG_FB_CFB_FILLRECT=y 830CONFIG_FB_CFB_FILLRECT=y
915CONFIG_FB_CFB_COPYAREA=y 831CONFIG_FB_CFB_COPYAREA=y
916CONFIG_FB_CFB_IMAGEBLIT=y 832CONFIG_FB_CFB_IMAGEBLIT=y
833# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
834# CONFIG_FB_SYS_FILLRECT is not set
835# CONFIG_FB_SYS_COPYAREA is not set
836# CONFIG_FB_SYS_IMAGEBLIT is not set
837# CONFIG_FB_FOREIGN_ENDIAN is not set
838# CONFIG_FB_SYS_FOPS is not set
917# CONFIG_FB_SVGALIB is not set 839# CONFIG_FB_SVGALIB is not set
918# CONFIG_FB_MACMODES is not set 840# CONFIG_FB_MACMODES is not set
919# CONFIG_FB_BACKLIGHT is not set 841# CONFIG_FB_BACKLIGHT is not set
@@ -923,14 +845,25 @@ CONFIG_FB_CFB_IMAGEBLIT=y
923# 845#
924# Frame buffer hardware drivers 846# Frame buffer hardware drivers
925# 847#
926# CONFIG_FB_IMAGEON is not set
927# CONFIG_FB_S1D13XXX is not set 848# CONFIG_FB_S1D13XXX is not set
928CONFIG_FB_PXA=y 849CONFIG_FB_PXA=y
850# CONFIG_FB_PXA_SMARTPANEL is not set
929# CONFIG_FB_PXA_PARAMETERS is not set 851# CONFIG_FB_PXA_PARAMETERS is not set
930# CONFIG_FB_MBX is not set 852# CONFIG_FB_MBX is not set
931CONFIG_FB_W100=y 853CONFIG_FB_W100=y
854# CONFIG_FB_AM200EPD is not set
932# CONFIG_FB_VIRTUAL is not set 855# CONFIG_FB_VIRTUAL is not set
933# CONFIG_FB_VSFB is not set 856CONFIG_BACKLIGHT_LCD_SUPPORT=y
857CONFIG_LCD_CLASS_DEVICE=y
858# CONFIG_LCD_ILI9320 is not set
859# CONFIG_LCD_PLATFORM is not set
860CONFIG_BACKLIGHT_CLASS_DEVICE=y
861CONFIG_BACKLIGHT_CORGI=y
862
863#
864# Display device support
865#
866# CONFIG_DISPLAY_SUPPORT is not set
934 867
935# 868#
936# Console display driver support 869# Console display driver support
@@ -938,6 +871,7 @@ CONFIG_FB_W100=y
938# CONFIG_VGA_CONSOLE is not set 871# CONFIG_VGA_CONSOLE is not set
939CONFIG_DUMMY_CONSOLE=y 872CONFIG_DUMMY_CONSOLE=y
940CONFIG_FRAMEBUFFER_CONSOLE=y 873CONFIG_FRAMEBUFFER_CONSOLE=y
874# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
941# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set 875# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
942CONFIG_FONTS=y 876CONFIG_FONTS=y
943# CONFIG_FONT_8x8 is not set 877# CONFIG_FONT_8x8 is not set
@@ -945,28 +879,13 @@ CONFIG_FONTS=y
945# CONFIG_FONT_6x11 is not set 879# CONFIG_FONT_6x11 is not set
946# CONFIG_FONT_7x14 is not set 880# CONFIG_FONT_7x14 is not set
947# CONFIG_FONT_PEARL_8x8 is not set 881# CONFIG_FONT_PEARL_8x8 is not set
948CONFIG_FONT_ACORN_8x8=y 882# CONFIG_FONT_ACORN_8x8 is not set
949# CONFIG_FONT_MINI_4x6 is not set 883CONFIG_FONT_MINI_4x6=y
950# CONFIG_FONT_SUN8x16 is not set 884# CONFIG_FONT_SUN8x16 is not set
951# CONFIG_FONT_SUN12x22 is not set 885# CONFIG_FONT_SUN12x22 is not set
952# CONFIG_FONT_10x18 is not set 886# CONFIG_FONT_10x18 is not set
953 887# CONFIG_LOGO is not set
954#
955# Logo configuration
956#
957CONFIG_LOGO=y
958# CONFIG_LOGO_LINUX_MONO is not set
959# CONFIG_LOGO_LINUX_VGA16 is not set
960CONFIG_LOGO_LINUX_CLUT224=y
961
962#
963# Sound
964#
965CONFIG_SOUND=y 888CONFIG_SOUND=y
966
967#
968# Advanced Linux Sound Architecture
969#
970CONFIG_SND=m 889CONFIG_SND=m
971CONFIG_SND_TIMER=m 890CONFIG_SND_TIMER=m
972CONFIG_SND_PCM=m 891CONFIG_SND_PCM=m
@@ -980,125 +899,75 @@ CONFIG_SND_SUPPORT_OLD_API=y
980CONFIG_SND_VERBOSE_PROCFS=y 899CONFIG_SND_VERBOSE_PROCFS=y
981CONFIG_SND_VERBOSE_PRINTK=y 900CONFIG_SND_VERBOSE_PRINTK=y
982# CONFIG_SND_DEBUG is not set 901# CONFIG_SND_DEBUG is not set
983 902CONFIG_SND_DRIVERS=y
984#
985# Generic devices
986#
987# CONFIG_SND_DUMMY is not set 903# CONFIG_SND_DUMMY is not set
988# CONFIG_SND_MTPAV is not set 904# CONFIG_SND_MTPAV is not set
989# CONFIG_SND_SERIAL_U16550 is not set 905# CONFIG_SND_SERIAL_U16550 is not set
990# CONFIG_SND_MPU401 is not set 906# CONFIG_SND_MPU401 is not set
991 907CONFIG_SND_ARM=y
992#
993# ALSA ARM devices
994#
995# CONFIG_SND_PXA2XX_AC97 is not set 908# CONFIG_SND_PXA2XX_AC97 is not set
996# CONFIG_SND_RECON is not set 909# CONFIG_SND_USB is not set
997 910# CONFIG_SND_PCMCIA is not set
998#
999# USB devices
1000#
1001# CONFIG_SND_USB_AUDIO is not set
1002
1003#
1004# PCMCIA devices
1005#
1006# CONFIG_SND_VXPOCKET is not set
1007# CONFIG_SND_PDAUDIOCF is not set
1008
1009#
1010# SoC audio support
1011#
1012CONFIG_SND_SOC_AC97_BUS=y
1013CONFIG_SND_SOC=m 911CONFIG_SND_SOC=m
1014 912CONFIG_SND_SOC_AC97_BUS=y
1015#
1016# SoC Platforms
1017#
1018
1019#
1020# SoC Audio for the Atmel AT91
1021#
1022
1023#
1024# SoC Audio for the Intel PXA2xx
1025#
1026CONFIG_SND_PXA2XX_SOC=m 913CONFIG_SND_PXA2XX_SOC=m
1027CONFIG_SND_PXA2XX_SOC_AC97=m 914CONFIG_SND_PXA2XX_SOC_AC97=m
1028CONFIG_SND_PXA2XX_SOC_E740_WM9705=m 915CONFIG_SND_PXA2XX_SOC_E800=m
1029CONFIG_SND_PXA2XX_SOC_E750_WM9705=m
1030CONFIG_SND_PXA2XX_SOC_E800_WM9712=m
1031# CONFIG_SND_PXA2XX_SOC_MAGICIAN is not set
1032# CONFIG_SND_PXA2XX_SOC_BLUEANGEL is not set
1033# CONFIG_SND_PXA2XX_SOC_H5000 is not set
1034
1035#
1036# SoC Audio for the Freescale i.MX
1037#
1038
1039#
1040# SoC Audio for the Samsung S3C24XX
1041#
1042# CONFIG_SND_SOC_AC97_CODEC is not set
1043# CONFIG_SND_SOC_WM8711 is not set
1044# CONFIG_SND_SOC_WM8510 is not set
1045# CONFIG_SND_SOC_WM8731 is not set
1046# CONFIG_SND_SOC_WM8750 is not set
1047# CONFIG_SND_SOC_WM8753 is not set
1048# CONFIG_SND_SOC_WM8772 is not set
1049# CONFIG_SND_SOC_WM8971 is not set
1050# CONFIG_SND_SOC_WM8956 is not set
1051# CONFIG_SND_SOC_WM8960 is not set
1052# CONFIG_SND_SOC_WM8976 is not set
1053# CONFIG_SND_SOC_WM8974 is not set
1054# CONFIG_SND_SOC_WM8980 is not set
1055CONFIG_SND_SOC_WM9705=m
1056# CONFIG_SND_SOC_WM9713 is not set
1057CONFIG_SND_SOC_WM9712=m 916CONFIG_SND_SOC_WM9712=m
1058# CONFIG_SND_SOC_UDA1380 is not set
1059# CONFIG_SND_SOC_AK4535 is not set
1060
1061#
1062# Open Sound System
1063#
1064# CONFIG_SOUND_PRIME is not set 917# CONFIG_SOUND_PRIME is not set
1065CONFIG_AC97_BUS=m 918CONFIG_AC97_BUS=m
919CONFIG_HID_SUPPORT=y
920CONFIG_HID=y
921# CONFIG_HID_DEBUG is not set
922# CONFIG_HIDRAW is not set
1066 923
1067# 924#
1068# HID Devices 925# USB Input Devices
1069# 926#
1070CONFIG_HID=y 927CONFIG_USB_HID=m
1071# CONFIG_HID_DEBUG is not set 928# CONFIG_USB_HIDINPUT_POWERBOOK is not set
929# CONFIG_HID_FF is not set
930# CONFIG_USB_HIDDEV is not set
1072 931
1073# 932#
1074# USB support 933# USB HID Boot Protocol drivers
1075# 934#
935# CONFIG_USB_KBD is not set
936# CONFIG_USB_MOUSE is not set
937CONFIG_USB_SUPPORT=y
1076CONFIG_USB_ARCH_HAS_HCD=y 938CONFIG_USB_ARCH_HAS_HCD=y
1077CONFIG_USB_ARCH_HAS_OHCI=y 939# CONFIG_USB_ARCH_HAS_OHCI is not set
1078# CONFIG_USB_ARCH_HAS_EHCI is not set 940# CONFIG_USB_ARCH_HAS_EHCI is not set
1079CONFIG_USB=m 941CONFIG_USB=m
1080CONFIG_USB_DEBUG=y 942# CONFIG_USB_DEBUG is not set
943# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1081 944
1082# 945#
1083# Miscellaneous USB options 946# Miscellaneous USB options
1084# 947#
1085CONFIG_USB_DEVICEFS=y 948# CONFIG_USB_DEVICEFS is not set
1086CONFIG_USB_DYNAMIC_MINORS=y 949CONFIG_USB_DEVICE_CLASS=y
950# CONFIG_USB_DYNAMIC_MINORS is not set
1087# CONFIG_USB_SUSPEND is not set 951# CONFIG_USB_SUSPEND is not set
1088# CONFIG_USB_OTG is not set 952# CONFIG_USB_OTG is not set
953# CONFIG_USB_OTG_WHITELIST is not set
954# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1089 955
1090# 956#
1091# USB Host Controller Drivers 957# USB Host Controller Drivers
1092# 958#
959# CONFIG_USB_C67X00_HCD is not set
1093# CONFIG_USB_ISP116X_HCD is not set 960# CONFIG_USB_ISP116X_HCD is not set
1094# CONFIG_USB_OHCI_HCD is not set 961# CONFIG_USB_ISP1760_HCD is not set
1095# CONFIG_USB_SL811_HCD is not set 962# CONFIG_USB_SL811_HCD is not set
963# CONFIG_USB_R8A66597_HCD is not set
1096 964
1097# 965#
1098# USB Device Class drivers 966# USB Device Class drivers
1099# 967#
1100# CONFIG_USB_ACM is not set 968# CONFIG_USB_ACM is not set
1101# CONFIG_USB_PRINTER is not set 969# CONFIG_USB_PRINTER is not set
970# CONFIG_USB_WDM is not set
1102 971
1103# 972#
1104# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 973# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -1107,68 +976,19 @@ CONFIG_USB_DYNAMIC_MINORS=y
1107# 976#
1108# may also be needed; see USB_STORAGE Help for more information 977# may also be needed; see USB_STORAGE Help for more information
1109# 978#
1110CONFIG_USB_STORAGE=m 979# CONFIG_USB_STORAGE is not set
1111# CONFIG_USB_STORAGE_DEBUG is not set
1112# CONFIG_USB_STORAGE_DATAFAB is not set
1113# CONFIG_USB_STORAGE_FREECOM is not set
1114# CONFIG_USB_STORAGE_ISD200 is not set
1115# CONFIG_USB_STORAGE_DPCM is not set
1116# CONFIG_USB_STORAGE_USBAT is not set
1117# CONFIG_USB_STORAGE_SDDR09 is not set
1118# CONFIG_USB_STORAGE_SDDR55 is not set
1119# CONFIG_USB_STORAGE_JUMPSHOT is not set
1120# CONFIG_USB_STORAGE_ALAUDA is not set
1121# CONFIG_USB_STORAGE_KARMA is not set
1122# CONFIG_USB_LIBUSUAL is not set 980# CONFIG_USB_LIBUSUAL is not set
1123 981
1124# 982#
1125# USB Input Devices
1126#
1127# CONFIG_USB_HID is not set
1128
1129#
1130# USB HID Boot Protocol drivers
1131#
1132# CONFIG_USB_KBD is not set
1133# CONFIG_USB_MOUSE is not set
1134# CONFIG_USB_AIPTEK is not set
1135# CONFIG_USB_WACOM is not set
1136# CONFIG_USB_ACECAD is not set
1137# CONFIG_USB_KBTAB is not set
1138# CONFIG_USB_POWERMATE is not set
1139# CONFIG_USB_TOUCHSCREEN is not set
1140# CONFIG_USB_YEALINK is not set
1141# CONFIG_USB_XPAD is not set
1142# CONFIG_USB_ATI_REMOTE is not set
1143# CONFIG_USB_ATI_REMOTE2 is not set
1144# CONFIG_USB_KEYSPAN_REMOTE is not set
1145# CONFIG_USB_APPLETOUCH is not set
1146# CONFIG_USB_GTCO is not set
1147
1148#
1149# USB Imaging devices 983# USB Imaging devices
1150# 984#
1151# CONFIG_USB_MDC800 is not set 985# CONFIG_USB_MDC800 is not set
1152# CONFIG_USB_MICROTEK is not set 986# CONFIG_USB_MICROTEK is not set
1153 987CONFIG_USB_MON=y
1154#
1155# USB Network Adapters
1156#
1157# CONFIG_USB_CATC is not set
1158# CONFIG_USB_KAWETH is not set
1159# CONFIG_USB_PEGASUS is not set
1160# CONFIG_USB_RTL8150 is not set
1161# CONFIG_USB_USBNET_MII is not set
1162# CONFIG_USB_USBNET is not set
1163# CONFIG_USB_MON is not set
1164 988
1165# 989#
1166# USB port drivers 990# USB port drivers
1167# 991#
1168
1169#
1170# USB Serial Converter support
1171#
1172# CONFIG_USB_SERIAL is not set 992# CONFIG_USB_SERIAL is not set
1173 993
1174# 994#
@@ -1192,56 +1012,57 @@ CONFIG_USB_STORAGE=m
1192# CONFIG_USB_LD is not set 1012# CONFIG_USB_LD is not set
1193# CONFIG_USB_TRANCEVIBRATOR is not set 1013# CONFIG_USB_TRANCEVIBRATOR is not set
1194# CONFIG_USB_IOWARRIOR is not set 1014# CONFIG_USB_IOWARRIOR is not set
1195# CONFIG_USB_TEST is not set 1015# CONFIG_USB_ISIGHTFW is not set
1196
1197#
1198# USB DSL modem support
1199#
1200
1201#
1202# USB Gadget Support
1203#
1204CONFIG_USB_GADGET=y 1016CONFIG_USB_GADGET=y
1205# CONFIG_USB_GADGET_DEBUG_FILES is not set 1017# CONFIG_USB_GADGET_DEBUG_FILES is not set
1206CONFIG_USB_GADGET_SELECTED=y 1018CONFIG_USB_GADGET_SELECTED=y
1019# CONFIG_USB_GADGET_AMD5536UDC is not set
1020# CONFIG_USB_GADGET_ATMEL_USBA is not set
1021# CONFIG_USB_GADGET_FSL_USB2 is not set
1207# CONFIG_USB_GADGET_NET2280 is not set 1022# CONFIG_USB_GADGET_NET2280 is not set
1208CONFIG_USB_GADGET_PXA2XX=y 1023CONFIG_USB_GADGET_PXA25X=y
1209CONFIG_USB_PXA2XX=y 1024CONFIG_USB_PXA25X=y
1210# CONFIG_USB_PXA2XX_SMALL is not set 1025CONFIG_USB_PXA25X_SMALL=y
1026# CONFIG_USB_GADGET_M66592 is not set
1211# CONFIG_USB_GADGET_PXA27X is not set 1027# CONFIG_USB_GADGET_PXA27X is not set
1212# CONFIG_USB_GADGET_GOKU is not set 1028# CONFIG_USB_GADGET_GOKU is not set
1213# CONFIG_USB_GADGET_MQ11XX is not set
1214# CONFIG_USB_GADGET_LH7A40X is not set 1029# CONFIG_USB_GADGET_LH7A40X is not set
1215# CONFIG_USB_GADGET_S3C2410 is not set
1216# CONFIG_USB_GADGET_OMAP is not set 1030# CONFIG_USB_GADGET_OMAP is not set
1031# CONFIG_USB_GADGET_S3C2410 is not set
1217# CONFIG_USB_GADGET_AT91 is not set 1032# CONFIG_USB_GADGET_AT91 is not set
1218# CONFIG_USB_GADGET_DUMMY_HCD is not set 1033# CONFIG_USB_GADGET_DUMMY_HCD is not set
1219# CONFIG_USB_GADGET_DUALSPEED is not set 1034# CONFIG_USB_GADGET_DUALSPEED is not set
1220# CONFIG_USB_ZERO is not set 1035# CONFIG_USB_ZERO is not set
1221CONFIG_USB_ETH=y 1036CONFIG_USB_ETH=m
1222# CONFIG_USB_ETH_RNDIS is not set 1037# CONFIG_USB_ETH_RNDIS is not set
1223# CONFIG_USB_GADGETFS is not set 1038# CONFIG_USB_GADGETFS is not set
1224# CONFIG_USB_FILE_STORAGE is not set 1039# CONFIG_USB_FILE_STORAGE is not set
1225# CONFIG_USB_G_SERIAL is not set 1040# CONFIG_USB_G_SERIAL is not set
1226# CONFIG_USB_MIDI_GADGET is not set 1041# CONFIG_USB_MIDI_GADGET is not set
1227# CONFIG_USB_G_CHAR is not set 1042# CONFIG_USB_G_PRINTER is not set
1228# CONFIG_USB_PXA2XX_GPIO is not set 1043# CONFIG_USB_CDC_COMPOSITE is not set
1044CONFIG_MMC=y
1045# CONFIG_MMC_DEBUG is not set
1046CONFIG_MMC_UNSAFE_RESUME=y
1229 1047
1230# 1048#
1231# MMC/SD Card support 1049# MMC/SD Card Drivers
1232# 1050#
1233CONFIG_MMC=y
1234# CONFIG_MMC_DEBUG is not set
1235CONFIG_MMC_BLOCK=y 1051CONFIG_MMC_BLOCK=y
1236# CONFIG_MMC_PXA is not set 1052CONFIG_MMC_BLOCK_BOUNCE=y
1237CONFIG_MMC_TMIO=y 1053# CONFIG_SDIO_UART is not set
1238# CONFIG_MMC_SAMCOP is not set 1054# CONFIG_MMC_TEST is not set
1239 1055
1240# 1056#
1241# Real Time Clock 1057# MMC/SD Host Controller Drivers
1242# 1058#
1059# CONFIG_MMC_PXA is not set
1060# CONFIG_MMC_SDHCI is not set
1061# CONFIG_NEW_LEDS is not set
1243CONFIG_RTC_LIB=y 1062CONFIG_RTC_LIB=y
1244# CONFIG_RTC_CLASS is not set 1063# CONFIG_RTC_CLASS is not set
1064# CONFIG_DMADEVICES is not set
1065# CONFIG_UIO is not set
1245 1066
1246# 1067#
1247# File systems 1068# File systems
@@ -1255,14 +1076,11 @@ CONFIG_EXT2_FS=y
1255# CONFIG_JFS_FS is not set 1076# CONFIG_JFS_FS is not set
1256# CONFIG_FS_POSIX_ACL is not set 1077# CONFIG_FS_POSIX_ACL is not set
1257# CONFIG_XFS_FS is not set 1078# CONFIG_XFS_FS is not set
1258# CONFIG_GFS2_FS is not set
1259# CONFIG_OCFS2_FS is not set 1079# CONFIG_OCFS2_FS is not set
1260# CONFIG_MINIX_FS is not set 1080CONFIG_DNOTIFY=y
1261# CONFIG_ROMFS_FS is not set
1262CONFIG_INOTIFY=y 1081CONFIG_INOTIFY=y
1263CONFIG_INOTIFY_USER=y 1082CONFIG_INOTIFY_USER=y
1264# CONFIG_QUOTA is not set 1083# CONFIG_QUOTA is not set
1265CONFIG_DNOTIFY=y
1266# CONFIG_AUTOFS_FS is not set 1084# CONFIG_AUTOFS_FS is not set
1267# CONFIG_AUTOFS4_FS is not set 1085# CONFIG_AUTOFS4_FS is not set
1268# CONFIG_FUSE_FS is not set 1086# CONFIG_FUSE_FS is not set
@@ -1292,7 +1110,6 @@ CONFIG_SYSFS=y
1292CONFIG_TMPFS=y 1110CONFIG_TMPFS=y
1293# CONFIG_TMPFS_POSIX_ACL is not set 1111# CONFIG_TMPFS_POSIX_ACL is not set
1294# CONFIG_HUGETLB_PAGE is not set 1112# CONFIG_HUGETLB_PAGE is not set
1295CONFIG_RAMFS=y
1296# CONFIG_CONFIGFS_FS is not set 1113# CONFIG_CONFIGFS_FS is not set
1297 1114
1298# 1115#
@@ -1305,30 +1122,21 @@ CONFIG_RAMFS=y
1305# CONFIG_BEFS_FS is not set 1122# CONFIG_BEFS_FS is not set
1306# CONFIG_BFS_FS is not set 1123# CONFIG_BFS_FS is not set
1307# CONFIG_EFS_FS is not set 1124# CONFIG_EFS_FS is not set
1308CONFIG_JFFS2_FS=m 1125# CONFIG_JFFS2_FS is not set
1309CONFIG_JFFS2_FS_DEBUG=0
1310CONFIG_JFFS2_FS_WRITEBUFFER=y
1311# CONFIG_JFFS2_SUMMARY is not set
1312# CONFIG_JFFS2_FS_XATTR is not set
1313# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1314CONFIG_JFFS2_ZLIB=y
1315CONFIG_JFFS2_RTIME=y
1316# CONFIG_JFFS2_RUBIN is not set
1317# CONFIG_CRAMFS is not set 1126# CONFIG_CRAMFS is not set
1318# CONFIG_VXFS_FS is not set 1127# CONFIG_VXFS_FS is not set
1128# CONFIG_MINIX_FS is not set
1129# CONFIG_OMFS_FS is not set
1319# CONFIG_HPFS_FS is not set 1130# CONFIG_HPFS_FS is not set
1320# CONFIG_QNX4FS_FS is not set 1131# CONFIG_QNX4FS_FS is not set
1132# CONFIG_ROMFS_FS is not set
1321# CONFIG_SYSV_FS is not set 1133# CONFIG_SYSV_FS is not set
1322# CONFIG_UFS_FS is not set 1134# CONFIG_UFS_FS is not set
1323 1135CONFIG_NETWORK_FILESYSTEMS=y
1324#
1325# Network File Systems
1326#
1327CONFIG_NFS_FS=y 1136CONFIG_NFS_FS=y
1328CONFIG_NFS_V3=y 1137CONFIG_NFS_V3=y
1329# CONFIG_NFS_V3_ACL is not set 1138# CONFIG_NFS_V3_ACL is not set
1330# CONFIG_NFS_V4 is not set 1139# CONFIG_NFS_V4 is not set
1331# CONFIG_NFS_DIRECTIO is not set
1332# CONFIG_NFSD is not set 1140# CONFIG_NFSD is not set
1333CONFIG_LOCKD=y 1141CONFIG_LOCKD=y
1334CONFIG_LOCKD_V4=y 1142CONFIG_LOCKD_V4=y
@@ -1341,7 +1149,6 @@ CONFIG_SUNRPC=y
1341# CONFIG_NCP_FS is not set 1149# CONFIG_NCP_FS is not set
1342# CONFIG_CODA_FS is not set 1150# CONFIG_CODA_FS is not set
1343# CONFIG_AFS_FS is not set 1151# CONFIG_AFS_FS is not set
1344# CONFIG_9P_FS is not set
1345 1152
1346# 1153#
1347# Partition Types 1154# Partition Types
@@ -1363,10 +1170,7 @@ CONFIG_MSDOS_PARTITION=y
1363# CONFIG_SUN_PARTITION is not set 1170# CONFIG_SUN_PARTITION is not set
1364# CONFIG_KARMA_PARTITION is not set 1171# CONFIG_KARMA_PARTITION is not set
1365# CONFIG_EFI_PARTITION is not set 1172# CONFIG_EFI_PARTITION is not set
1366 1173# CONFIG_SYSV68_PARTITION is not set
1367#
1368# Native Language Support
1369#
1370CONFIG_NLS=y 1174CONFIG_NLS=y
1371CONFIG_NLS_DEFAULT="iso8859-1" 1175CONFIG_NLS_DEFAULT="iso8859-1"
1372CONFIG_NLS_CODEPAGE_437=y 1176CONFIG_NLS_CODEPAGE_437=y
@@ -1407,30 +1211,32 @@ CONFIG_NLS_ISO8859_1=y
1407# CONFIG_NLS_KOI8_R is not set 1211# CONFIG_NLS_KOI8_R is not set
1408# CONFIG_NLS_KOI8_U is not set 1212# CONFIG_NLS_KOI8_U is not set
1409# CONFIG_NLS_UTF8 is not set 1213# CONFIG_NLS_UTF8 is not set
1410
1411#
1412# Distributed Lock Manager
1413#
1414# CONFIG_DLM is not set 1214# CONFIG_DLM is not set
1415 1215
1416# 1216#
1417# Profiling support
1418#
1419# CONFIG_PROFILING is not set
1420
1421#
1422# Kernel hacking 1217# Kernel hacking
1423# 1218#
1424# CONFIG_PRINTK_TIME is not set 1219# CONFIG_PRINTK_TIME is not set
1425CONFIG_ENABLE_MUST_CHECK=y 1220# CONFIG_ENABLE_WARN_DEPRECATED is not set
1221# CONFIG_ENABLE_MUST_CHECK is not set
1222CONFIG_FRAME_WARN=1024
1426# CONFIG_MAGIC_SYSRQ is not set 1223# CONFIG_MAGIC_SYSRQ is not set
1427# CONFIG_UNUSED_SYMBOLS is not set 1224# CONFIG_UNUSED_SYMBOLS is not set
1428# CONFIG_DEBUG_FS is not set 1225# CONFIG_DEBUG_FS is not set
1429# CONFIG_HEADERS_CHECK is not set 1226# CONFIG_HEADERS_CHECK is not set
1430# CONFIG_DEBUG_KERNEL is not set 1227# CONFIG_DEBUG_KERNEL is not set
1431CONFIG_LOG_BUF_SHIFT=14
1432# CONFIG_DEBUG_BUGVERBOSE is not set 1228# CONFIG_DEBUG_BUGVERBOSE is not set
1229# CONFIG_DEBUG_MEMORY_INIT is not set
1433CONFIG_FRAME_POINTER=y 1230CONFIG_FRAME_POINTER=y
1231# CONFIG_LATENCYTOP is not set
1232CONFIG_HAVE_FTRACE=y
1233CONFIG_HAVE_DYNAMIC_FTRACE=y
1234# CONFIG_FTRACE is not set
1235# CONFIG_IRQSOFF_TRACER is not set
1236# CONFIG_SCHED_TRACER is not set
1237# CONFIG_CONTEXT_SWITCH_TRACER is not set
1238# CONFIG_SAMPLES is not set
1239CONFIG_HAVE_ARCH_KGDB=y
1434# CONFIG_DEBUG_USER is not set 1240# CONFIG_DEBUG_USER is not set
1435 1241
1436# 1242#
@@ -1438,61 +1244,102 @@ CONFIG_FRAME_POINTER=y
1438# 1244#
1439# CONFIG_KEYS is not set 1245# CONFIG_KEYS is not set
1440# CONFIG_SECURITY is not set 1246# CONFIG_SECURITY is not set
1247# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1248CONFIG_CRYPTO=y
1441 1249
1442# 1250#
1443# Cryptographic options 1251# Crypto core or helper
1444# 1252#
1445CONFIG_CRYPTO=y
1446CONFIG_CRYPTO_ALGAPI=m 1253CONFIG_CRYPTO_ALGAPI=m
1447CONFIG_CRYPTO_BLKCIPHER=m 1254CONFIG_CRYPTO_BLKCIPHER=m
1448CONFIG_CRYPTO_MANAGER=m 1255CONFIG_CRYPTO_MANAGER=m
1256# CONFIG_CRYPTO_GF128MUL is not set
1257# CONFIG_CRYPTO_NULL is not set
1258# CONFIG_CRYPTO_CRYPTD is not set
1259# CONFIG_CRYPTO_AUTHENC is not set
1260# CONFIG_CRYPTO_TEST is not set
1261
1262#
1263# Authenticated Encryption with Associated Data
1264#
1265# CONFIG_CRYPTO_CCM is not set
1266# CONFIG_CRYPTO_GCM is not set
1267# CONFIG_CRYPTO_SEQIV is not set
1268
1269#
1270# Block modes
1271#
1272CONFIG_CRYPTO_CBC=m
1273# CONFIG_CRYPTO_CTR is not set
1274# CONFIG_CRYPTO_CTS is not set
1275CONFIG_CRYPTO_ECB=m
1276# CONFIG_CRYPTO_LRW is not set
1277CONFIG_CRYPTO_PCBC=m
1278# CONFIG_CRYPTO_XTS is not set
1279
1280#
1281# Hash modes
1282#
1449# CONFIG_CRYPTO_HMAC is not set 1283# CONFIG_CRYPTO_HMAC is not set
1450# CONFIG_CRYPTO_XCBC is not set 1284# CONFIG_CRYPTO_XCBC is not set
1451# CONFIG_CRYPTO_NULL is not set 1285
1286#
1287# Digest
1288#
1289# CONFIG_CRYPTO_CRC32C is not set
1452# CONFIG_CRYPTO_MD4 is not set 1290# CONFIG_CRYPTO_MD4 is not set
1453# CONFIG_CRYPTO_MD5 is not set 1291# CONFIG_CRYPTO_MD5 is not set
1292CONFIG_CRYPTO_MICHAEL_MIC=m
1293# CONFIG_CRYPTO_RMD128 is not set
1294# CONFIG_CRYPTO_RMD160 is not set
1295# CONFIG_CRYPTO_RMD256 is not set
1296# CONFIG_CRYPTO_RMD320 is not set
1454# CONFIG_CRYPTO_SHA1 is not set 1297# CONFIG_CRYPTO_SHA1 is not set
1455# CONFIG_CRYPTO_SHA256 is not set 1298# CONFIG_CRYPTO_SHA256 is not set
1456# CONFIG_CRYPTO_SHA512 is not set 1299# CONFIG_CRYPTO_SHA512 is not set
1457# CONFIG_CRYPTO_WP512 is not set
1458# CONFIG_CRYPTO_TGR192 is not set 1300# CONFIG_CRYPTO_TGR192 is not set
1459# CONFIG_CRYPTO_GF128MUL is not set 1301# CONFIG_CRYPTO_WP512 is not set
1460CONFIG_CRYPTO_ECB=m 1302
1461CONFIG_CRYPTO_CBC=m 1303#
1462CONFIG_CRYPTO_PCBC=m 1304# Ciphers
1463# CONFIG_CRYPTO_LRW is not set 1305#
1464# CONFIG_CRYPTO_DES is not set 1306CONFIG_CRYPTO_AES=m
1465# CONFIG_CRYPTO_FCRYPT is not set 1307# CONFIG_CRYPTO_ANUBIS is not set
1308CONFIG_CRYPTO_ARC4=m
1466# CONFIG_CRYPTO_BLOWFISH is not set 1309# CONFIG_CRYPTO_BLOWFISH is not set
1467# CONFIG_CRYPTO_TWOFISH is not set 1310# CONFIG_CRYPTO_CAMELLIA is not set
1468# CONFIG_CRYPTO_SERPENT is not set
1469# CONFIG_CRYPTO_AES is not set
1470# CONFIG_CRYPTO_CAST5 is not set 1311# CONFIG_CRYPTO_CAST5 is not set
1471# CONFIG_CRYPTO_CAST6 is not set 1312# CONFIG_CRYPTO_CAST6 is not set
1472# CONFIG_CRYPTO_TEA is not set 1313# CONFIG_CRYPTO_DES is not set
1473CONFIG_CRYPTO_ARC4=m 1314# CONFIG_CRYPTO_FCRYPT is not set
1474# CONFIG_CRYPTO_KHAZAD is not set 1315# CONFIG_CRYPTO_KHAZAD is not set
1475# CONFIG_CRYPTO_ANUBIS is not set 1316# CONFIG_CRYPTO_SALSA20 is not set
1476# CONFIG_CRYPTO_DEFLATE is not set 1317# CONFIG_CRYPTO_SEED is not set
1477# CONFIG_CRYPTO_MICHAEL_MIC is not set 1318# CONFIG_CRYPTO_SERPENT is not set
1478# CONFIG_CRYPTO_CRC32C is not set 1319# CONFIG_CRYPTO_TEA is not set
1479# CONFIG_CRYPTO_CAMELLIA is not set 1320# CONFIG_CRYPTO_TWOFISH is not set
1480# CONFIG_CRYPTO_TEST is not set
1481 1321
1482# 1322#
1483# Hardware crypto devices 1323# Compression
1484# 1324#
1325# CONFIG_CRYPTO_DEFLATE is not set
1326# CONFIG_CRYPTO_LZO is not set
1327CONFIG_CRYPTO_HW=y
1485 1328
1486# 1329#
1487# Library routines 1330# Library routines
1488# 1331#
1489CONFIG_BITREVERSE=y 1332CONFIG_BITREVERSE=y
1490# CONFIG_CRC_CCITT is not set 1333# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1334# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1335CONFIG_CRC_CCITT=y
1491# CONFIG_CRC16 is not set 1336# CONFIG_CRC16 is not set
1337# CONFIG_CRC_T10DIF is not set
1338# CONFIG_CRC_ITU_T is not set
1492CONFIG_CRC32=y 1339CONFIG_CRC32=y
1340# CONFIG_CRC7 is not set
1493# CONFIG_LIBCRC32C is not set 1341# CONFIG_LIBCRC32C is not set
1494CONFIG_ZLIB_INFLATE=m
1495CONFIG_ZLIB_DEFLATE=m
1496CONFIG_PLIST=y 1342CONFIG_PLIST=y
1497CONFIG_HAS_IOMEM=y 1343CONFIG_HAS_IOMEM=y
1498CONFIG_HAS_IOPORT=y 1344CONFIG_HAS_IOPORT=y
1345CONFIG_HAS_DMA=y
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index 747b9dedab88..dc8b40783d94 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -377,7 +377,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
377 * -------------------------------------------------------------------- */ 377 * -------------------------------------------------------------------- */
378 378
379#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 379#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
380static struct at91_nand_data nand_data; 380static struct atmel_nand_data nand_data;
381 381
382#define NAND_BASE AT91_CHIPSELECT_3 382#define NAND_BASE AT91_CHIPSELECT_3
383 383
@@ -395,7 +395,7 @@ static struct resource nand_resources[] = {
395}; 395};
396 396
397static struct platform_device at91cap9_nand_device = { 397static struct platform_device at91cap9_nand_device = {
398 .name = "at91_nand", 398 .name = "atmel_nand",
399 .id = -1, 399 .id = -1,
400 .dev = { 400 .dev = {
401 .platform_data = &nand_data, 401 .platform_data = &nand_data,
@@ -404,7 +404,7 @@ static struct platform_device at91cap9_nand_device = {
404 .num_resources = ARRAY_SIZE(nand_resources), 404 .num_resources = ARRAY_SIZE(nand_resources),
405}; 405};
406 406
407void __init at91_add_device_nand(struct at91_nand_data *data) 407void __init at91_add_device_nand(struct atmel_nand_data *data)
408{ 408{
409 unsigned long csa, mode; 409 unsigned long csa, mode;
410 410
@@ -445,7 +445,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
445 platform_device_register(&at91cap9_nand_device); 445 platform_device_register(&at91cap9_nand_device);
446} 446}
447#else 447#else
448void __init at91_add_device_nand(struct at91_nand_data *data) {} 448void __init at91_add_device_nand(struct atmel_nand_data *data) {}
449#endif 449#endif
450 450
451 451
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index de19bee83f75..8ced9bc82099 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -369,7 +369,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
369 * -------------------------------------------------------------------- */ 369 * -------------------------------------------------------------------- */
370 370
371#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 371#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
372static struct at91_nand_data nand_data; 372static struct atmel_nand_data nand_data;
373 373
374#define NAND_BASE AT91_CHIPSELECT_3 374#define NAND_BASE AT91_CHIPSELECT_3
375 375
@@ -382,7 +382,7 @@ static struct resource nand_resources[] = {
382}; 382};
383 383
384static struct platform_device at91rm9200_nand_device = { 384static struct platform_device at91rm9200_nand_device = {
385 .name = "at91_nand", 385 .name = "atmel_nand",
386 .id = -1, 386 .id = -1,
387 .dev = { 387 .dev = {
388 .platform_data = &nand_data, 388 .platform_data = &nand_data,
@@ -391,7 +391,7 @@ static struct platform_device at91rm9200_nand_device = {
391 .num_resources = ARRAY_SIZE(nand_resources), 391 .num_resources = ARRAY_SIZE(nand_resources),
392}; 392};
393 393
394void __init at91_add_device_nand(struct at91_nand_data *data) 394void __init at91_add_device_nand(struct atmel_nand_data *data)
395{ 395{
396 unsigned int csa; 396 unsigned int csa;
397 397
@@ -429,7 +429,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
429 platform_device_register(&at91rm9200_nand_device); 429 platform_device_register(&at91rm9200_nand_device);
430} 430}
431#else 431#else
432void __init at91_add_device_nand(struct at91_nand_data *data) {} 432void __init at91_add_device_nand(struct atmel_nand_data *data) {}
433#endif 433#endif
434 434
435 435
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 86cba4ac29b1..cae5f52f1278 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -284,7 +284,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
284 * -------------------------------------------------------------------- */ 284 * -------------------------------------------------------------------- */
285 285
286#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 286#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
287static struct at91_nand_data nand_data; 287static struct atmel_nand_data nand_data;
288 288
289#define NAND_BASE AT91_CHIPSELECT_3 289#define NAND_BASE AT91_CHIPSELECT_3
290 290
@@ -302,7 +302,7 @@ static struct resource nand_resources[] = {
302}; 302};
303 303
304static struct platform_device at91sam9260_nand_device = { 304static struct platform_device at91sam9260_nand_device = {
305 .name = "at91_nand", 305 .name = "atmel_nand",
306 .id = -1, 306 .id = -1,
307 .dev = { 307 .dev = {
308 .platform_data = &nand_data, 308 .platform_data = &nand_data,
@@ -311,7 +311,7 @@ static struct platform_device at91sam9260_nand_device = {
311 .num_resources = ARRAY_SIZE(nand_resources), 311 .num_resources = ARRAY_SIZE(nand_resources),
312}; 312};
313 313
314void __init at91_add_device_nand(struct at91_nand_data *data) 314void __init at91_add_device_nand(struct atmel_nand_data *data)
315{ 315{
316 unsigned long csa, mode; 316 unsigned long csa, mode;
317 317
@@ -373,7 +373,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
373 platform_device_register(&at91sam9260_nand_device); 373 platform_device_register(&at91sam9260_nand_device);
374} 374}
375#else 375#else
376void __init at91_add_device_nand(struct at91_nand_data *data) {} 376void __init at91_add_device_nand(struct atmel_nand_data *data) {}
377#endif 377#endif
378 378
379 379
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index ec1891375dfb..483d436af22d 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -199,7 +199,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
199 * -------------------------------------------------------------------- */ 199 * -------------------------------------------------------------------- */
200 200
201#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 201#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
202static struct at91_nand_data nand_data; 202static struct atmel_nand_data nand_data;
203 203
204#define NAND_BASE AT91_CHIPSELECT_3 204#define NAND_BASE AT91_CHIPSELECT_3
205 205
@@ -211,8 +211,8 @@ static struct resource nand_resources[] = {
211 } 211 }
212}; 212};
213 213
214static struct platform_device at91_nand_device = { 214static struct platform_device atmel_nand_device = {
215 .name = "at91_nand", 215 .name = "atmel_nand",
216 .id = -1, 216 .id = -1,
217 .dev = { 217 .dev = {
218 .platform_data = &nand_data, 218 .platform_data = &nand_data,
@@ -221,7 +221,7 @@ static struct platform_device at91_nand_device = {
221 .num_resources = ARRAY_SIZE(nand_resources), 221 .num_resources = ARRAY_SIZE(nand_resources),
222}; 222};
223 223
224void __init at91_add_device_nand(struct at91_nand_data *data) 224void __init at91_add_device_nand(struct atmel_nand_data *data)
225{ 225{
226 unsigned long csa, mode; 226 unsigned long csa, mode;
227 227
@@ -262,11 +262,11 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
262 at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */ 262 at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */
263 263
264 nand_data = *data; 264 nand_data = *data;
265 platform_device_register(&at91_nand_device); 265 platform_device_register(&atmel_nand_device);
266} 266}
267 267
268#else 268#else
269void __init at91_add_device_nand(struct at91_nand_data *data) {} 269void __init at91_add_device_nand(struct atmel_nand_data *data) {}
270#endif 270#endif
271 271
272 272
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 8a81f76f0200..9762b15f658a 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -353,7 +353,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
353 * -------------------------------------------------------------------- */ 353 * -------------------------------------------------------------------- */
354 354
355#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 355#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
356static struct at91_nand_data nand_data; 356static struct atmel_nand_data nand_data;
357 357
358#define NAND_BASE AT91_CHIPSELECT_3 358#define NAND_BASE AT91_CHIPSELECT_3
359 359
@@ -371,7 +371,7 @@ static struct resource nand_resources[] = {
371}; 371};
372 372
373static struct platform_device at91sam9263_nand_device = { 373static struct platform_device at91sam9263_nand_device = {
374 .name = "at91_nand", 374 .name = "atmel_nand",
375 .id = -1, 375 .id = -1,
376 .dev = { 376 .dev = {
377 .platform_data = &nand_data, 377 .platform_data = &nand_data,
@@ -380,7 +380,7 @@ static struct platform_device at91sam9263_nand_device = {
380 .num_resources = ARRAY_SIZE(nand_resources), 380 .num_resources = ARRAY_SIZE(nand_resources),
381}; 381};
382 382
383void __init at91_add_device_nand(struct at91_nand_data *data) 383void __init at91_add_device_nand(struct atmel_nand_data *data)
384{ 384{
385 unsigned long csa, mode; 385 unsigned long csa, mode;
386 386
@@ -421,7 +421,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
421 platform_device_register(&at91sam9263_nand_device); 421 platform_device_register(&at91sam9263_nand_device);
422} 422}
423#else 423#else
424void __init at91_add_device_nand(struct at91_nand_data *data) {} 424void __init at91_add_device_nand(struct atmel_nand_data *data) {}
425#endif 425#endif
426 426
427 427
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index ae28101e7542..5f3094870cad 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -195,7 +195,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
195 * -------------------------------------------------------------------- */ 195 * -------------------------------------------------------------------- */
196 196
197#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) 197#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
198static struct at91_nand_data nand_data; 198static struct atmel_nand_data nand_data;
199 199
200#define NAND_BASE AT91_CHIPSELECT_3 200#define NAND_BASE AT91_CHIPSELECT_3
201 201
@@ -212,8 +212,8 @@ static struct resource nand_resources[] = {
212 } 212 }
213}; 213};
214 214
215static struct platform_device at91_nand_device = { 215static struct platform_device atmel_nand_device = {
216 .name = "at91_nand", 216 .name = "atmel_nand",
217 .id = -1, 217 .id = -1,
218 .dev = { 218 .dev = {
219 .platform_data = &nand_data, 219 .platform_data = &nand_data,
@@ -222,7 +222,7 @@ static struct platform_device at91_nand_device = {
222 .num_resources = ARRAY_SIZE(nand_resources), 222 .num_resources = ARRAY_SIZE(nand_resources),
223}; 223};
224 224
225void __init at91_add_device_nand(struct at91_nand_data *data) 225void __init at91_add_device_nand(struct atmel_nand_data *data)
226{ 226{
227 unsigned long csa; 227 unsigned long csa;
228 228
@@ -259,11 +259,11 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
259 at91_set_A_periph(AT91_PIN_PB5, 0); /* NANDWE */ 259 at91_set_A_periph(AT91_PIN_PB5, 0); /* NANDWE */
260 260
261 nand_data = *data; 261 nand_data = *data;
262 platform_device_register(&at91_nand_device); 262 platform_device_register(&atmel_nand_device);
263} 263}
264 264
265#else 265#else
266void __init at91_add_device_nand(struct at91_nand_data *data) {} 266void __init at91_add_device_nand(struct atmel_nand_data *data) {}
267#endif 267#endif
268 268
269 269
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index b22a1a004055..af2c33aff1a8 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -142,7 +142,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
142 return cam60_nand_partition; 142 return cam60_nand_partition;
143} 143}
144 144
145static struct at91_nand_data __initdata cam60_nand_data = { 145static struct atmel_nand_data __initdata cam60_nand_data = {
146 .ale = 21, 146 .ale = 21,
147 .cle = 22, 147 .cle = 22,
148 // .det_pin = ... not there 148 // .det_pin = ... not there
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
index 8a2a958639db..117cf6c9afce 100644
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -181,7 +181,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
181 return cap9adk_nand_partitions; 181 return cap9adk_nand_partitions;
182} 182}
183 183
184static struct at91_nand_data __initdata cap9adk_nand_data = { 184static struct atmel_nand_data __initdata cap9adk_nand_data = {
185 .ale = 21, 185 .ale = 21,
186 .cle = 22, 186 .cle = 22,
187// .det_pin = ... not connected 187// .det_pin = ... not connected
@@ -330,10 +330,10 @@ static void __init cap9adk_board_init(void)
330 /* Serial */ 330 /* Serial */
331 at91_add_device_serial(); 331 at91_add_device_serial();
332 /* USB Host */ 332 /* USB Host */
333 set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH); 333 set_irq_type(AT91CAP9_ID_UHP, IRQ_TYPE_LEVEL_HIGH);
334 at91_add_device_usbh(&cap9adk_usbh_data); 334 at91_add_device_usbh(&cap9adk_usbh_data);
335 /* USB HS */ 335 /* USB HS */
336 set_irq_type(AT91CAP9_ID_UDPHS, IRQT_HIGH); 336 set_irq_type(AT91CAP9_ID_UDPHS, IRQ_TYPE_LEVEL_HIGH);
337 at91_add_device_usba(&cap9adk_usba_udc_data); 337 at91_add_device_usba(&cap9adk_usba_udc_data);
338 /* SPI */ 338 /* SPI */
339 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices)); 339 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
@@ -350,7 +350,7 @@ static void __init cap9adk_board_init(void)
350 /* I2C */ 350 /* I2C */
351 at91_add_device_i2c(NULL, 0); 351 at91_add_device_i2c(NULL, 0);
352 /* LCD Controller */ 352 /* LCD Controller */
353 set_irq_type(AT91CAP9_ID_LCDC, IRQT_HIGH); 353 set_irq_type(AT91CAP9_ID_LCDC, IRQ_TYPE_LEVEL_HIGH);
354 at91_add_device_lcdc(&cap9adk_lcdc_data); 354 at91_add_device_lcdc(&cap9adk_lcdc_data);
355 /* AC97 */ 355 /* AC97 */
356 at91_add_device_ac97(&cap9adk_ac97_data); 356 at91_add_device_ac97(&cap9adk_ac97_data);
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c
index dab958d25926..02a70b2f355b 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-dk.c
@@ -147,7 +147,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
147 return dk_nand_partition; 147 return dk_nand_partition;
148} 148}
149 149
150static struct at91_nand_data __initdata dk_nand_data = { 150static struct atmel_nand_data __initdata dk_nand_data = {
151 .ale = 22, 151 .ale = 22,
152 .cle = 21, 152 .cle = 21,
153 .det_pin = AT91_PIN_PB1, 153 .det_pin = AT91_PIN_PB1,
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index cb065febd95e..082ed59365a4 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -105,7 +105,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
105 return kb9202_nand_partition; 105 return kb9202_nand_partition;
106} 106}
107 107
108static struct at91_nand_data __initdata kb9202_nand_data = { 108static struct atmel_nand_data __initdata kb9202_nand_data = {
109 .ale = 22, 109 .ale = 22,
110 .cle = 21, 110 .cle = 21,
111 // .det_pin = ... not there 111 // .det_pin = ... not there
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index 8f76af5e219a..57a6221943ed 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -141,7 +141,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
141 return ek_nand_partition; 141 return ek_nand_partition;
142} 142}
143 143
144static struct at91_nand_data __initdata ek_nand_data = { 144static struct atmel_nand_data __initdata ek_nand_data = {
145 .ale = 21, 145 .ale = 21,
146 .cle = 22, 146 .cle = 22,
147// .det_pin = ... not connected 147// .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index 4d1d9c777084..6a680795c3c8 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -178,7 +178,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
178 return ek_nand_partition; 178 return ek_nand_partition;
179} 179}
180 180
181static struct at91_nand_data __initdata ek_nand_data = { 181static struct atmel_nand_data __initdata ek_nand_data = {
182 .ale = 21, 182 .ale = 21,
183 .cle = 22, 183 .cle = 22,
184// .det_pin = ... not connected 184// .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 08382c0df221..43dfbd0d543a 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -183,7 +183,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
183 return ek_nand_partition; 183 return ek_nand_partition;
184} 184}
185 185
186static struct at91_nand_data __initdata ek_nand_data = { 186static struct atmel_nand_data __initdata ek_nand_data = {
187 .ale = 22, 187 .ale = 22,
188 .cle = 21, 188 .cle = 21,
189// .det_pin = ... not connected 189// .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index b4cd5d0ed597..6605a0980117 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -187,7 +187,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
187 return ek_nand_partition; 187 return ek_nand_partition;
188} 188}
189 189
190static struct at91_nand_data __initdata ek_nand_data = { 190static struct atmel_nand_data __initdata ek_nand_data = {
191 .ale = 21, 191 .ale = 21,
192 .cle = 22, 192 .cle = 22,
193// .det_pin = ... not connected 193// .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index b6a70fc735c3..66e77bb2e079 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -96,7 +96,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
96 return ek_nand_partition; 96 return ek_nand_partition;
97} 97}
98 98
99static struct at91_nand_data __initdata ek_nand_data = { 99static struct atmel_nand_data __initdata ek_nand_data = {
100 .ale = 21, 100 .ale = 21,
101 .cle = 22, 101 .cle = 22,
102// .det_pin = ... not connected 102// .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index 7079050ab88d..bbbfd06f5e0c 100755..100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -180,7 +180,7 @@ static struct mtd_partition * __init nand_partitions(int size, int *num_partitio
180 return yl9200_nand_partition; 180 return yl9200_nand_partition;
181} 181}
182 182
183static struct at91_nand_data __initdata yl9200_nand_data = { 183static struct atmel_nand_data __initdata yl9200_nand_data = {
184 .ale = 6, 184 .ale = 6,
185 .cle = 7, 185 .cle = 7,
186 // .det_pin = ... not connected 186 // .det_pin = ... not connected
diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c
index 78a5cdb746dc..ca87587b2b4b 100644
--- a/arch/arm/mach-at91/irq.c
+++ b/arch/arm/mach-at91/irq.c
@@ -56,19 +56,19 @@ static int at91_aic_set_type(unsigned irq, unsigned type)
56 unsigned int smr, srctype; 56 unsigned int smr, srctype;
57 57
58 switch (type) { 58 switch (type) {
59 case IRQT_HIGH: 59 case IRQ_TYPE_LEVEL_HIGH:
60 srctype = AT91_AIC_SRCTYPE_HIGH; 60 srctype = AT91_AIC_SRCTYPE_HIGH;
61 break; 61 break;
62 case IRQT_RISING: 62 case IRQ_TYPE_EDGE_RISING:
63 srctype = AT91_AIC_SRCTYPE_RISING; 63 srctype = AT91_AIC_SRCTYPE_RISING;
64 break; 64 break;
65 case IRQT_LOW: 65 case IRQ_TYPE_LEVEL_LOW:
66 if ((irq == AT91_ID_FIQ) || is_extern_irq(irq)) /* only supported on external interrupts */ 66 if ((irq == AT91_ID_FIQ) || is_extern_irq(irq)) /* only supported on external interrupts */
67 srctype = AT91_AIC_SRCTYPE_LOW; 67 srctype = AT91_AIC_SRCTYPE_LOW;
68 else 68 else
69 return -EINVAL; 69 return -EINVAL;
70 break; 70 break;
71 case IRQT_FALLING: 71 case IRQ_TYPE_EDGE_FALLING:
72 if ((irq == AT91_ID_FIQ) || is_extern_irq(irq)) /* only supported on external interrupts */ 72 if ((irq == AT91_ID_FIQ) || is_extern_irq(irq)) /* only supported on external interrupts */
73 srctype = AT91_AIC_SRCTYPE_FALLING; 73 srctype = AT91_AIC_SRCTYPE_FALLING;
74 else 74 else
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 1d7bca6aa441..5fed57608507 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -226,7 +226,7 @@ static void ep93xx_gpio_irq_ack(unsigned int irq)
226 int port = line >> 3; 226 int port = line >> 3;
227 int port_mask = 1 << (line & 7); 227 int port_mask = 1 << (line & 7);
228 228
229 if ((irq_desc[irq].status & IRQ_TYPE_SENSE_MASK) == IRQT_BOTHEDGE) { 229 if ((irq_desc[irq].status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
230 gpio_int_type2[port] ^= port_mask; /* switch edge direction */ 230 gpio_int_type2[port] ^= port_mask; /* switch edge direction */
231 ep93xx_gpio_update_int_params(port); 231 ep93xx_gpio_update_int_params(port);
232 } 232 }
@@ -240,7 +240,7 @@ static void ep93xx_gpio_irq_mask_ack(unsigned int irq)
240 int port = line >> 3; 240 int port = line >> 3;
241 int port_mask = 1 << (line & 7); 241 int port_mask = 1 << (line & 7);
242 242
243 if ((irq_desc[irq].status & IRQ_TYPE_SENSE_MASK) == IRQT_BOTHEDGE) 243 if ((irq_desc[irq].status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
244 gpio_int_type2[port] ^= port_mask; /* switch edge direction */ 244 gpio_int_type2[port] ^= port_mask; /* switch edge direction */
245 245
246 gpio_int_unmasked[port] &= ~port_mask; 246 gpio_int_unmasked[port] &= ~port_mask;
@@ -283,27 +283,27 @@ static int ep93xx_gpio_irq_type(unsigned int irq, unsigned int type)
283 gpio_direction_input(gpio); 283 gpio_direction_input(gpio);
284 284
285 switch (type) { 285 switch (type) {
286 case IRQT_RISING: 286 case IRQ_TYPE_EDGE_RISING:
287 gpio_int_type1[port] |= port_mask; 287 gpio_int_type1[port] |= port_mask;
288 gpio_int_type2[port] |= port_mask; 288 gpio_int_type2[port] |= port_mask;
289 desc->handle_irq = handle_edge_irq; 289 desc->handle_irq = handle_edge_irq;
290 break; 290 break;
291 case IRQT_FALLING: 291 case IRQ_TYPE_EDGE_FALLING:
292 gpio_int_type1[port] |= port_mask; 292 gpio_int_type1[port] |= port_mask;
293 gpio_int_type2[port] &= ~port_mask; 293 gpio_int_type2[port] &= ~port_mask;
294 desc->handle_irq = handle_edge_irq; 294 desc->handle_irq = handle_edge_irq;
295 break; 295 break;
296 case IRQT_HIGH: 296 case IRQ_TYPE_LEVEL_HIGH:
297 gpio_int_type1[port] &= ~port_mask; 297 gpio_int_type1[port] &= ~port_mask;
298 gpio_int_type2[port] |= port_mask; 298 gpio_int_type2[port] |= port_mask;
299 desc->handle_irq = handle_level_irq; 299 desc->handle_irq = handle_level_irq;
300 break; 300 break;
301 case IRQT_LOW: 301 case IRQ_TYPE_LEVEL_LOW:
302 gpio_int_type1[port] &= ~port_mask; 302 gpio_int_type1[port] &= ~port_mask;
303 gpio_int_type2[port] &= ~port_mask; 303 gpio_int_type2[port] &= ~port_mask;
304 desc->handle_irq = handle_level_irq; 304 desc->handle_irq = handle_level_irq;
305 break; 305 break;
306 case IRQT_BOTHEDGE: 306 case IRQ_TYPE_EDGE_BOTH:
307 gpio_int_type1[port] |= port_mask; 307 gpio_int_type1[port] |= port_mask;
308 /* set initial polarity based on current input level */ 308 /* set initial polarity based on current input level */
309 if (gpio_get_value(gpio)) 309 if (gpio_get_value(gpio))
diff --git a/arch/arm/mach-imx/irq.c b/arch/arm/mach-imx/irq.c
index e6695c4e623b..e1b1f028b930 100644
--- a/arch/arm/mach-imx/irq.c
+++ b/arch/arm/mach-imx/irq.c
@@ -111,7 +111,7 @@ imx_gpio_irq_type(unsigned int _irq, unsigned int type)
111 reg = irq >> 5; 111 reg = irq >> 5;
112 bit = 1 << (irq % 32); 112 bit = 1 << (irq % 32);
113 113
114 if (type == IRQT_PROBE) { 114 if (type == IRQ_TYPE_PROBE) {
115 /* Don't mess with enabled GPIOs using preconfigured edges or 115 /* Don't mess with enabled GPIOs using preconfigured edges or
116 GPIOs set to alternate function during probe */ 116 GPIOs set to alternate function during probe */
117 /* TODO: support probe */ 117 /* TODO: support probe */
@@ -120,7 +120,7 @@ imx_gpio_irq_type(unsigned int _irq, unsigned int type)
120// return 0; 120// return 0;
121// if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2))) 121// if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2)))
122// return 0; 122// return 0;
123// type = __IRQT_RISEDGE | __IRQT_FALEDGE; 123// type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
124 } 124 }
125 125
126 GIUS(reg) |= bit; 126 GIUS(reg) |= bit;
@@ -128,19 +128,19 @@ imx_gpio_irq_type(unsigned int _irq, unsigned int type)
128 128
129 DEBUG_IRQ("setting type of irq %d to ", _irq); 129 DEBUG_IRQ("setting type of irq %d to ", _irq);
130 130
131 if (type & __IRQT_RISEDGE) { 131 if (type & IRQ_TYPE_EDGE_RISING) {
132 DEBUG_IRQ("rising edges\n"); 132 DEBUG_IRQ("rising edges\n");
133 irq_type = 0x0; 133 irq_type = 0x0;
134 } 134 }
135 if (type & __IRQT_FALEDGE) { 135 if (type & IRQ_TYPE_EDGE_FALLING) {
136 DEBUG_IRQ("falling edges\n"); 136 DEBUG_IRQ("falling edges\n");
137 irq_type = 0x1; 137 irq_type = 0x1;
138 } 138 }
139 if (type & __IRQT_LOWLVL) { 139 if (type & IRQ_TYPE_LEVEL_LOW) {
140 DEBUG_IRQ("low level\n"); 140 DEBUG_IRQ("low level\n");
141 irq_type = 0x3; 141 irq_type = 0x3;
142 } 142 }
143 if (type & __IRQT_HIGHLVL) { 143 if (type & IRQ_TYPE_LEVEL_HIGH) {
144 DEBUG_IRQ("high level\n"); 144 DEBUG_IRQ("high level\n");
145 irq_type = 0x2; 145 irq_type = 0x2;
146 } 146 }
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index 81cdc8267206..daf28074134b 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -329,19 +329,19 @@ static int ixp2000_GPIO_irq_type(unsigned int irq, unsigned int type)
329 /* 329 /*
330 * Then, set the proper trigger type. 330 * Then, set the proper trigger type.
331 */ 331 */
332 if (type & IRQT_FALLING) 332 if (type & IRQ_TYPE_EDGE_FALLING)
333 GPIO_IRQ_falling_edge |= 1 << line; 333 GPIO_IRQ_falling_edge |= 1 << line;
334 else 334 else
335 GPIO_IRQ_falling_edge &= ~(1 << line); 335 GPIO_IRQ_falling_edge &= ~(1 << line);
336 if (type & IRQT_RISING) 336 if (type & IRQ_TYPE_EDGE_RISING)
337 GPIO_IRQ_rising_edge |= 1 << line; 337 GPIO_IRQ_rising_edge |= 1 << line;
338 else 338 else
339 GPIO_IRQ_rising_edge &= ~(1 << line); 339 GPIO_IRQ_rising_edge &= ~(1 << line);
340 if (type & IRQT_LOW) 340 if (type & IRQ_TYPE_LEVEL_LOW)
341 GPIO_IRQ_level_low |= 1 << line; 341 GPIO_IRQ_level_low |= 1 << line;
342 else 342 else
343 GPIO_IRQ_level_low &= ~(1 << line); 343 GPIO_IRQ_level_low &= ~(1 << line);
344 if (type & IRQT_HIGH) 344 if (type & IRQ_TYPE_LEVEL_HIGH)
345 GPIO_IRQ_level_high |= 1 << line; 345 GPIO_IRQ_level_high |= 1 << line;
346 else 346 else
347 GPIO_IRQ_level_high &= ~(1 << line); 347 GPIO_IRQ_level_high &= ~(1 << line);
diff --git a/arch/arm/mach-ixp23xx/core.c b/arch/arm/mach-ixp23xx/core.c
index 5fea5a132939..df16a4eac490 100644
--- a/arch/arm/mach-ixp23xx/core.c
+++ b/arch/arm/mach-ixp23xx/core.c
@@ -126,23 +126,23 @@ static int ixp23xx_irq_set_type(unsigned int irq, unsigned int type)
126 return -EINVAL; 126 return -EINVAL;
127 127
128 switch (type) { 128 switch (type) {
129 case IRQT_BOTHEDGE: 129 case IRQ_TYPE_EDGE_BOTH:
130 int_style = IXP23XX_GPIO_STYLE_TRANSITIONAL; 130 int_style = IXP23XX_GPIO_STYLE_TRANSITIONAL;
131 irq_type = IXP23XX_IRQ_EDGE; 131 irq_type = IXP23XX_IRQ_EDGE;
132 break; 132 break;
133 case IRQT_RISING: 133 case IRQ_TYPE_EDGE_RISING:
134 int_style = IXP23XX_GPIO_STYLE_RISING_EDGE; 134 int_style = IXP23XX_GPIO_STYLE_RISING_EDGE;
135 irq_type = IXP23XX_IRQ_EDGE; 135 irq_type = IXP23XX_IRQ_EDGE;
136 break; 136 break;
137 case IRQT_FALLING: 137 case IRQ_TYPE_EDGE_FALLING:
138 int_style = IXP23XX_GPIO_STYLE_FALLING_EDGE; 138 int_style = IXP23XX_GPIO_STYLE_FALLING_EDGE;
139 irq_type = IXP23XX_IRQ_EDGE; 139 irq_type = IXP23XX_IRQ_EDGE;
140 break; 140 break;
141 case IRQT_HIGH: 141 case IRQ_TYPE_LEVEL_HIGH:
142 int_style = IXP23XX_GPIO_STYLE_ACTIVE_HIGH; 142 int_style = IXP23XX_GPIO_STYLE_ACTIVE_HIGH;
143 irq_type = IXP23XX_IRQ_LEVEL; 143 irq_type = IXP23XX_IRQ_LEVEL;
144 break; 144 break;
145 case IRQT_LOW: 145 case IRQ_TYPE_LEVEL_LOW:
146 int_style = IXP23XX_GPIO_STYLE_ACTIVE_LOW; 146 int_style = IXP23XX_GPIO_STYLE_ACTIVE_LOW;
147 irq_type = IXP23XX_IRQ_LEVEL; 147 irq_type = IXP23XX_IRQ_LEVEL;
148 break; 148 break;
diff --git a/arch/arm/mach-ixp23xx/roadrunner.c b/arch/arm/mach-ixp23xx/roadrunner.c
index f0f70ba1e46d..896ff9f840d9 100644
--- a/arch/arm/mach-ixp23xx/roadrunner.c
+++ b/arch/arm/mach-ixp23xx/roadrunner.c
@@ -110,8 +110,8 @@ static int __init roadrunner_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
110 110
111static void __init roadrunner_pci_preinit(void) 111static void __init roadrunner_pci_preinit(void)
112{ 112{
113 set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQT_LOW); 113 set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
114 set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQT_LOW); 114 set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
115 115
116 ixp23xx_pci_preinit(); 116 ixp23xx_pci_preinit();
117} 117}
diff --git a/arch/arm/mach-ixp4xx/avila-pci.c b/arch/arm/mach-ixp4xx/avila-pci.c
index 3f867691d9f2..c6e044befccb 100644
--- a/arch/arm/mach-ixp4xx/avila-pci.c
+++ b/arch/arm/mach-ixp4xx/avila-pci.c
@@ -30,10 +30,10 @@
30 30
31void __init avila_pci_preinit(void) 31void __init avila_pci_preinit(void)
32{ 32{
33 set_irq_type(IRQ_AVILA_PCI_INTA, IRQT_LOW); 33 set_irq_type(IRQ_AVILA_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
34 set_irq_type(IRQ_AVILA_PCI_INTB, IRQT_LOW); 34 set_irq_type(IRQ_AVILA_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
35 set_irq_type(IRQ_AVILA_PCI_INTC, IRQT_LOW); 35 set_irq_type(IRQ_AVILA_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
36 set_irq_type(IRQ_AVILA_PCI_INTD, IRQT_LOW); 36 set_irq_type(IRQ_AVILA_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
37 37
38 ixp4xx_pci_preinit(); 38 ixp4xx_pci_preinit();
39} 39}
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 3781b3db9f49..3947c506b4f3 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -142,23 +142,23 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
142 return -EINVAL; 142 return -EINVAL;
143 143
144 switch (type){ 144 switch (type){
145 case IRQT_BOTHEDGE: 145 case IRQ_TYPE_EDGE_BOTH:
146 int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL; 146 int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL;
147 irq_type = IXP4XX_IRQ_EDGE; 147 irq_type = IXP4XX_IRQ_EDGE;
148 break; 148 break;
149 case IRQT_RISING: 149 case IRQ_TYPE_EDGE_RISING:
150 int_style = IXP4XX_GPIO_STYLE_RISING_EDGE; 150 int_style = IXP4XX_GPIO_STYLE_RISING_EDGE;
151 irq_type = IXP4XX_IRQ_EDGE; 151 irq_type = IXP4XX_IRQ_EDGE;
152 break; 152 break;
153 case IRQT_FALLING: 153 case IRQ_TYPE_EDGE_FALLING:
154 int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE; 154 int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE;
155 irq_type = IXP4XX_IRQ_EDGE; 155 irq_type = IXP4XX_IRQ_EDGE;
156 break; 156 break;
157 case IRQT_HIGH: 157 case IRQ_TYPE_LEVEL_HIGH:
158 int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH; 158 int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH;
159 irq_type = IXP4XX_IRQ_LEVEL; 159 irq_type = IXP4XX_IRQ_LEVEL;
160 break; 160 break;
161 case IRQT_LOW: 161 case IRQ_TYPE_LEVEL_LOW:
162 int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW; 162 int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW;
163 irq_type = IXP4XX_IRQ_LEVEL; 163 irq_type = IXP4XX_IRQ_LEVEL;
164 break; 164 break;
diff --git a/arch/arm/mach-ixp4xx/coyote-pci.c b/arch/arm/mach-ixp4xx/coyote-pci.c
index ad2e5b97966e..be4f4a208b90 100644
--- a/arch/arm/mach-ixp4xx/coyote-pci.c
+++ b/arch/arm/mach-ixp4xx/coyote-pci.c
@@ -27,8 +27,8 @@
27 27
28void __init coyote_pci_preinit(void) 28void __init coyote_pci_preinit(void)
29{ 29{
30 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW); 30 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQ_TYPE_LEVEL_LOW);
31 set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQT_LOW); 31 set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQ_TYPE_LEVEL_LOW);
32 32
33 ixp4xx_pci_preinit(); 33 ixp4xx_pci_preinit();
34} 34}
diff --git a/arch/arm/mach-ixp4xx/dsmg600-pci.c b/arch/arm/mach-ixp4xx/dsmg600-pci.c
index 9db7e1f42011..926d15f885fb 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-pci.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-pci.c
@@ -25,12 +25,12 @@
25 25
26void __init dsmg600_pci_preinit(void) 26void __init dsmg600_pci_preinit(void)
27{ 27{
28 set_irq_type(IRQ_DSMG600_PCI_INTA, IRQT_LOW); 28 set_irq_type(IRQ_DSMG600_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
29 set_irq_type(IRQ_DSMG600_PCI_INTB, IRQT_LOW); 29 set_irq_type(IRQ_DSMG600_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
30 set_irq_type(IRQ_DSMG600_PCI_INTC, IRQT_LOW); 30 set_irq_type(IRQ_DSMG600_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
31 set_irq_type(IRQ_DSMG600_PCI_INTD, IRQT_LOW); 31 set_irq_type(IRQ_DSMG600_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
32 set_irq_type(IRQ_DSMG600_PCI_INTE, IRQT_LOW); 32 set_irq_type(IRQ_DSMG600_PCI_INTE, IRQ_TYPE_LEVEL_LOW);
33 set_irq_type(IRQ_DSMG600_PCI_INTF, IRQT_LOW); 33 set_irq_type(IRQ_DSMG600_PCI_INTF, IRQ_TYPE_LEVEL_LOW);
34 34
35 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
36} 36}
diff --git a/arch/arm/mach-ixp4xx/fsg-pci.c b/arch/arm/mach-ixp4xx/fsg-pci.c
index f19f3f6feda1..ca12a9ca0830 100644
--- a/arch/arm/mach-ixp4xx/fsg-pci.c
+++ b/arch/arm/mach-ixp4xx/fsg-pci.c
@@ -25,9 +25,9 @@
25 25
26void __init fsg_pci_preinit(void) 26void __init fsg_pci_preinit(void)
27{ 27{
28 set_irq_type(IRQ_FSG_PCI_INTA, IRQT_LOW); 28 set_irq_type(IRQ_FSG_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
29 set_irq_type(IRQ_FSG_PCI_INTB, IRQT_LOW); 29 set_irq_type(IRQ_FSG_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
30 set_irq_type(IRQ_FSG_PCI_INTC, IRQT_LOW); 30 set_irq_type(IRQ_FSG_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
31 31
32 ixp4xx_pci_preinit(); 32 ixp4xx_pci_preinit();
33} 33}
diff --git a/arch/arm/mach-ixp4xx/gateway7001-pci.c b/arch/arm/mach-ixp4xx/gateway7001-pci.c
index 6abf568322d3..afd1dc14e597 100644
--- a/arch/arm/mach-ixp4xx/gateway7001-pci.c
+++ b/arch/arm/mach-ixp4xx/gateway7001-pci.c
@@ -29,8 +29,8 @@
29 29
30void __init gateway7001_pci_preinit(void) 30void __init gateway7001_pci_preinit(void)
31{ 31{
32 set_irq_type(IRQ_IXP4XX_GPIO10, IRQT_LOW); 32 set_irq_type(IRQ_IXP4XX_GPIO10, IRQ_TYPE_LEVEL_LOW);
33 set_irq_type(IRQ_IXP4XX_GPIO11, IRQT_LOW); 33 set_irq_type(IRQ_IXP4XX_GPIO11, IRQ_TYPE_LEVEL_LOW);
34 34
35 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
36} 36}
diff --git a/arch/arm/mach-ixp4xx/gtwx5715-pci.c b/arch/arm/mach-ixp4xx/gtwx5715-pci.c
index 49dec7868807..20960704183b 100644
--- a/arch/arm/mach-ixp4xx/gtwx5715-pci.c
+++ b/arch/arm/mach-ixp4xx/gtwx5715-pci.c
@@ -41,10 +41,10 @@
41 */ 41 */
42void __init gtwx5715_pci_preinit(void) 42void __init gtwx5715_pci_preinit(void)
43{ 43{
44 set_irq_type(GTWX5715_PCI_SLOT0_INTA_IRQ, IRQT_LOW); 44 set_irq_type(GTWX5715_PCI_SLOT0_INTA_IRQ, IRQ_TYPE_LEVEL_LOW);
45 set_irq_type(GTWX5715_PCI_SLOT0_INTB_IRQ, IRQT_LOW); 45 set_irq_type(GTWX5715_PCI_SLOT0_INTB_IRQ, IRQ_TYPE_LEVEL_LOW);
46 set_irq_type(GTWX5715_PCI_SLOT1_INTA_IRQ, IRQT_LOW); 46 set_irq_type(GTWX5715_PCI_SLOT1_INTA_IRQ, IRQ_TYPE_LEVEL_LOW);
47 set_irq_type(GTWX5715_PCI_SLOT1_INTB_IRQ, IRQT_LOW); 47 set_irq_type(GTWX5715_PCI_SLOT1_INTB_IRQ, IRQ_TYPE_LEVEL_LOW);
48 48
49 ixp4xx_pci_preinit(); 49 ixp4xx_pci_preinit();
50} 50}
diff --git a/arch/arm/mach-ixp4xx/ixdp425-pci.c b/arch/arm/mach-ixp4xx/ixdp425-pci.c
index 408796004812..7d9bb4d23104 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-pci.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-pci.c
@@ -27,10 +27,10 @@
27 27
28void __init ixdp425_pci_preinit(void) 28void __init ixdp425_pci_preinit(void)
29{ 29{
30 set_irq_type(IRQ_IXDP425_PCI_INTA, IRQT_LOW); 30 set_irq_type(IRQ_IXDP425_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
31 set_irq_type(IRQ_IXDP425_PCI_INTB, IRQT_LOW); 31 set_irq_type(IRQ_IXDP425_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
32 set_irq_type(IRQ_IXDP425_PCI_INTC, IRQT_LOW); 32 set_irq_type(IRQ_IXDP425_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
33 set_irq_type(IRQ_IXDP425_PCI_INTD, IRQT_LOW); 33 set_irq_type(IRQ_IXDP425_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
34 34
35 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
36} 36}
diff --git a/arch/arm/mach-ixp4xx/ixdpg425-pci.c b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
index d1e75b7dc3b1..37d9f2e8f602 100644
--- a/arch/arm/mach-ixp4xx/ixdpg425-pci.c
+++ b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
@@ -25,8 +25,8 @@
25 25
26void __init ixdpg425_pci_preinit(void) 26void __init ixdpg425_pci_preinit(void)
27{ 27{
28 set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW); 28 set_irq_type(IRQ_IXP4XX_GPIO6, IRQ_TYPE_LEVEL_LOW);
29 set_irq_type(IRQ_IXP4XX_GPIO7, IRQT_LOW); 29 set_irq_type(IRQ_IXP4XX_GPIO7, IRQ_TYPE_LEVEL_LOW);
30 30
31 ixp4xx_pci_preinit(); 31 ixp4xx_pci_preinit();
32} 32}
diff --git a/arch/arm/mach-ixp4xx/nas100d-pci.c b/arch/arm/mach-ixp4xx/nas100d-pci.c
index b8ebaf4a9c8e..1088426fdcee 100644
--- a/arch/arm/mach-ixp4xx/nas100d-pci.c
+++ b/arch/arm/mach-ixp4xx/nas100d-pci.c
@@ -24,11 +24,11 @@
24 24
25void __init nas100d_pci_preinit(void) 25void __init nas100d_pci_preinit(void)
26{ 26{
27 set_irq_type(IRQ_NAS100D_PCI_INTA, IRQT_LOW); 27 set_irq_type(IRQ_NAS100D_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
28 set_irq_type(IRQ_NAS100D_PCI_INTB, IRQT_LOW); 28 set_irq_type(IRQ_NAS100D_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
29 set_irq_type(IRQ_NAS100D_PCI_INTC, IRQT_LOW); 29 set_irq_type(IRQ_NAS100D_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
30 set_irq_type(IRQ_NAS100D_PCI_INTD, IRQT_LOW); 30 set_irq_type(IRQ_NAS100D_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
31 set_irq_type(IRQ_NAS100D_PCI_INTE, IRQT_LOW); 31 set_irq_type(IRQ_NAS100D_PCI_INTE, IRQ_TYPE_LEVEL_LOW);
32 32
33 ixp4xx_pci_preinit(); 33 ixp4xx_pci_preinit();
34} 34}
diff --git a/arch/arm/mach-ixp4xx/nslu2-pci.c b/arch/arm/mach-ixp4xx/nslu2-pci.c
index 04661fef97f5..4429b8448b61 100644
--- a/arch/arm/mach-ixp4xx/nslu2-pci.c
+++ b/arch/arm/mach-ixp4xx/nslu2-pci.c
@@ -24,9 +24,9 @@
24 24
25void __init nslu2_pci_preinit(void) 25void __init nslu2_pci_preinit(void)
26{ 26{
27 set_irq_type(IRQ_NSLU2_PCI_INTA, IRQT_LOW); 27 set_irq_type(IRQ_NSLU2_PCI_INTA, IRQ_TYPE_LEVEL_LOW);
28 set_irq_type(IRQ_NSLU2_PCI_INTB, IRQT_LOW); 28 set_irq_type(IRQ_NSLU2_PCI_INTB, IRQ_TYPE_LEVEL_LOW);
29 set_irq_type(IRQ_NSLU2_PCI_INTC, IRQT_LOW); 29 set_irq_type(IRQ_NSLU2_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
30 30
31 ixp4xx_pci_preinit(); 31 ixp4xx_pci_preinit();
32} 32}
diff --git a/arch/arm/mach-ixp4xx/wg302v2-pci.c b/arch/arm/mach-ixp4xx/wg302v2-pci.c
index 6588f2c758e2..0f00feab67f8 100644
--- a/arch/arm/mach-ixp4xx/wg302v2-pci.c
+++ b/arch/arm/mach-ixp4xx/wg302v2-pci.c
@@ -29,8 +29,8 @@
29 29
30void __init wg302v2_pci_preinit(void) 30void __init wg302v2_pci_preinit(void)
31{ 31{
32 set_irq_type(IRQ_IXP4XX_GPIO8, IRQT_LOW); 32 set_irq_type(IRQ_IXP4XX_GPIO8, IRQ_TYPE_LEVEL_LOW);
33 set_irq_type(IRQ_IXP4XX_GPIO9, IRQT_LOW); 33 set_irq_type(IRQ_IXP4XX_GPIO9, IRQ_TYPE_LEVEL_LOW);
34 34
35 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
36} 36}
diff --git a/arch/arm/mach-ks8695/irq.c b/arch/arm/mach-ks8695/irq.c
index 4c3ab43e1046..0b06941a1eed 100644
--- a/arch/arm/mach-ks8695/irq.c
+++ b/arch/arm/mach-ks8695/irq.c
@@ -72,21 +72,21 @@ static int ks8695_irq_set_type(unsigned int irqno, unsigned int type)
72 ctrl = __raw_readl(KS8695_GPIO_VA + KS8695_IOPC); 72 ctrl = __raw_readl(KS8695_GPIO_VA + KS8695_IOPC);
73 73
74 switch (type) { 74 switch (type) {
75 case IRQT_HIGH: 75 case IRQ_TYPE_LEVEL_HIGH:
76 mode = IOPC_TM_HIGH; 76 mode = IOPC_TM_HIGH;
77 level_triggered = 1; 77 level_triggered = 1;
78 break; 78 break;
79 case IRQT_LOW: 79 case IRQ_TYPE_LEVEL_LOW:
80 mode = IOPC_TM_LOW; 80 mode = IOPC_TM_LOW;
81 level_triggered = 1; 81 level_triggered = 1;
82 break; 82 break;
83 case IRQT_RISING: 83 case IRQ_TYPE_EDGE_RISING:
84 mode = IOPC_TM_RISING; 84 mode = IOPC_TM_RISING;
85 break; 85 break;
86 case IRQT_FALLING: 86 case IRQ_TYPE_EDGE_FALLING:
87 mode = IOPC_TM_FALLING; 87 mode = IOPC_TM_FALLING;
88 break; 88 break;
89 case IRQT_BOTHEDGE: 89 case IRQ_TYPE_EDGE_BOTH:
90 mode = IOPC_TM_EDGE; 90 mode = IOPC_TM_EDGE;
91 break; 91 break;
92 default: 92 default:
diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c
index fd7537f7d11e..99d4fb19a08a 100644
--- a/arch/arm/mach-netx/generic.c
+++ b/arch/arm/mach-netx/generic.c
@@ -99,19 +99,19 @@ netx_hif_irq_type(unsigned int _irq, unsigned int type)
99 99
100 irq = _irq - NETX_IRQ_HIF_CHAINED(0); 100 irq = _irq - NETX_IRQ_HIF_CHAINED(0);
101 101
102 if (type & __IRQT_RISEDGE) { 102 if (type & IRQ_TYPE_EDGE_RISING) {
103 DEBUG_IRQ("rising edges\n"); 103 DEBUG_IRQ("rising edges\n");
104 val |= (1 << 26) << irq; 104 val |= (1 << 26) << irq;
105 } 105 }
106 if (type & __IRQT_FALEDGE) { 106 if (type & IRQ_TYPE_EDGE_FALLING) {
107 DEBUG_IRQ("falling edges\n"); 107 DEBUG_IRQ("falling edges\n");
108 val &= ~((1 << 26) << irq); 108 val &= ~((1 << 26) << irq);
109 } 109 }
110 if (type & __IRQT_LOWLVL) { 110 if (type & IRQ_TYPE_LEVEL_LOW) {
111 DEBUG_IRQ("low level\n"); 111 DEBUG_IRQ("low level\n");
112 val &= ~((1 << 26) << irq); 112 val &= ~((1 << 26) << irq);
113 } 113 }
114 if (type & __IRQT_HIGHLVL) { 114 if (type & IRQ_TYPE_LEVEL_HIGH) {
115 DEBUG_IRQ("high level\n"); 115 DEBUG_IRQ("high level\n");
116 val |= (1 << 26) << irq; 116 val |= (1 << 26) << irq;
117 } 117 }
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 845c66371ca3..41f94f6fc15c 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -288,7 +288,7 @@ static void __init osk_init_cf(void)
288 return; 288 return;
289 } 289 }
290 /* the CF I/O IRQ is really active-low */ 290 /* the CF I/O IRQ is really active-low */
291 set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING); 291 set_irq_type(OMAP_GPIO_IRQ(62), IRQ_TYPE_EDGE_FALLING);
292} 292}
293 293
294static void __init osk_init_irq(void) 294static void __init osk_init_irq(void)
@@ -483,7 +483,7 @@ static void __init osk_mistral_init(void)
483 omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */ 483 omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */
484 gpio_request(4, "ts_int"); 484 gpio_request(4, "ts_int");
485 gpio_direction_input(4); 485 gpio_direction_input(4);
486 set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING); 486 set_irq_type(OMAP_GPIO_IRQ(4), IRQ_TYPE_EDGE_FALLING);
487 487
488 spi_register_board_info(mistral_boardinfo, 488 spi_register_board_info(mistral_boardinfo,
489 ARRAY_SIZE(mistral_boardinfo)); 489 ARRAY_SIZE(mistral_boardinfo));
@@ -494,7 +494,7 @@ static void __init osk_mistral_init(void)
494 int ret = 0; 494 int ret = 0;
495 495
496 gpio_direction_input(OMAP_MPUIO(2)); 496 gpio_direction_input(OMAP_MPUIO(2));
497 set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING); 497 set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQ_TYPE_EDGE_RISING);
498#ifdef CONFIG_PM 498#ifdef CONFIG_PM
499 /* share the IRQ in case someone wants to use the 499 /* share the IRQ in case someone wants to use the
500 * button for more than wakeup from system sleep. 500 * button for more than wakeup from system sleep.
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index e020c2774606..34389b63b0ec 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -298,11 +298,11 @@ palmz71_powercable(int irq, void *dev_id)
298 if (omap_get_gpio_datain(PALMZ71_USBDETECT_GPIO)) { 298 if (omap_get_gpio_datain(PALMZ71_USBDETECT_GPIO)) {
299 printk(KERN_INFO "PM: Power cable connected\n"); 299 printk(KERN_INFO "PM: Power cable connected\n");
300 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO), 300 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
301 IRQT_FALLING); 301 IRQ_TYPE_EDGE_FALLING);
302 } else { 302 } else {
303 printk(KERN_INFO "PM: Power cable disconnected\n"); 303 printk(KERN_INFO "PM: Power cable disconnected\n");
304 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO), 304 set_irq_type(OMAP_GPIO_IRQ(PALMZ71_USBDETECT_GPIO),
305 IRQT_RISING); 305 IRQ_TYPE_EDGE_RISING);
306 } 306 }
307 return IRQ_HANDLED; 307 return IRQ_HANDLED;
308} 308}
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 5c00b3f39cdd..8948d45a2769 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -186,10 +186,10 @@ static void __init voiceblue_init(void)
186 omap_request_gpio(13); 186 omap_request_gpio(13);
187 omap_request_gpio(14); 187 omap_request_gpio(14);
188 omap_request_gpio(15); 188 omap_request_gpio(15);
189 set_irq_type(OMAP_GPIO_IRQ(12), IRQT_RISING); 189 set_irq_type(OMAP_GPIO_IRQ(12), IRQ_TYPE_EDGE_RISING);
190 set_irq_type(OMAP_GPIO_IRQ(13), IRQT_RISING); 190 set_irq_type(OMAP_GPIO_IRQ(13), IRQ_TYPE_EDGE_RISING);
191 set_irq_type(OMAP_GPIO_IRQ(14), IRQT_RISING); 191 set_irq_type(OMAP_GPIO_IRQ(14), IRQ_TYPE_EDGE_RISING);
192 set_irq_type(OMAP_GPIO_IRQ(15), IRQT_RISING); 192 set_irq_type(OMAP_GPIO_IRQ(15), IRQ_TYPE_EDGE_RISING);
193 193
194 platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices)); 194 platform_add_devices(voiceblue_devices, ARRAY_SIZE(voiceblue_devices));
195 omap_board_config = voiceblue_config; 195 omap_board_config = voiceblue_config;
diff --git a/arch/arm/mach-omap1/fpga.c b/arch/arm/mach-omap1/fpga.c
index 0cf62ef5ecb7..d963125ed755 100644
--- a/arch/arm/mach-omap1/fpga.c
+++ b/arch/arm/mach-omap1/fpga.c
@@ -181,7 +181,7 @@ void omap1510_fpga_init_irq(void)
181 */ 181 */
182 omap_request_gpio(13); 182 omap_request_gpio(13);
183 omap_set_gpio_direction(13, 1); 183 omap_set_gpio_direction(13, 1);
184 set_irq_type(OMAP_GPIO_IRQ(13), IRQT_RISING); 184 set_irq_type(OMAP_GPIO_IRQ(13), IRQ_TYPE_EDGE_RISING);
185 set_irq_chained_handler(OMAP1510_INT_FPGA, innovator_fpga_IRQ_demux); 185 set_irq_chained_handler(OMAP1510_INT_FPGA, innovator_fpga_IRQ_demux);
186} 186}
187 187
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index 620fa0f120ee..870b34972d3b 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -337,17 +337,17 @@ static void __init apollon_sw_init(void)
337 omap_request_gpio(SW_DOWN_GPIO58); 337 omap_request_gpio(SW_DOWN_GPIO58);
338 omap_set_gpio_direction(SW_DOWN_GPIO58, 1); 338 omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
339 339
340 set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQT_RISING); 340 set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQ_TYPE_EDGE_RISING);
341 if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt, 341 if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt,
342 IRQF_SHARED, "enter sw", 342 IRQF_SHARED, "enter sw",
343 &apollon_sw_interrupt)) 343 &apollon_sw_interrupt))
344 return; 344 return;
345 set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQT_RISING); 345 set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQ_TYPE_EDGE_RISING);
346 if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt, 346 if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt,
347 IRQF_SHARED, "up sw", 347 IRQF_SHARED, "up sw",
348 &apollon_sw_interrupt)) 348 &apollon_sw_interrupt))
349 return; 349 return;
350 set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQT_RISING); 350 set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQ_TYPE_EDGE_RISING);
351 if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt, 351 if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt,
352 IRQF_SHARED, "down sw", 352 IRQF_SHARED, "down sw",
353 &apollon_sw_interrupt)) 353 &apollon_sw_interrupt))
diff --git a/arch/arm/mach-orion5x/db88f5281-setup.c b/arch/arm/mach-orion5x/db88f5281-setup.c
index 88405e74e5e3..40a0bee4fbb3 100644
--- a/arch/arm/mach-orion5x/db88f5281-setup.c
+++ b/arch/arm/mach-orion5x/db88f5281-setup.c
@@ -213,7 +213,7 @@ void __init db88f5281_pci_preinit(void)
213 pin = DB88F5281_PCI_SLOT0_IRQ_PIN; 213 pin = DB88F5281_PCI_SLOT0_IRQ_PIN;
214 if (gpio_request(pin, "PCI Int1") == 0) { 214 if (gpio_request(pin, "PCI Int1") == 0) {
215 if (gpio_direction_input(pin) == 0) { 215 if (gpio_direction_input(pin) == 0) {
216 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 216 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
217 } else { 217 } else {
218 printk(KERN_ERR "db88f5281_pci_preinit faield to " 218 printk(KERN_ERR "db88f5281_pci_preinit faield to "
219 "set_irq_type pin %d\n", pin); 219 "set_irq_type pin %d\n", pin);
@@ -226,7 +226,7 @@ void __init db88f5281_pci_preinit(void)
226 pin = DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN; 226 pin = DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN;
227 if (gpio_request(pin, "PCI Int2") == 0) { 227 if (gpio_request(pin, "PCI Int2") == 0) {
228 if (gpio_direction_input(pin) == 0) { 228 if (gpio_direction_input(pin) == 0) {
229 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 229 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
230 } else { 230 } else {
231 printk(KERN_ERR "db88f5281_pci_preinit faield " 231 printk(KERN_ERR "db88f5281_pci_preinit faield "
232 "to set_irq_type pin %d\n", pin); 232 "to set_irq_type pin %d\n", pin);
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index e2a0084ab4a3..9ae3f6dc7839 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -91,27 +91,27 @@ static int orion5x_gpio_set_irq_type(u32 irq, u32 type)
91 desc = irq_desc + irq; 91 desc = irq_desc + irq;
92 92
93 switch (type) { 93 switch (type) {
94 case IRQT_HIGH: 94 case IRQ_TYPE_LEVEL_HIGH:
95 desc->handle_irq = handle_level_irq; 95 desc->handle_irq = handle_level_irq;
96 desc->status |= IRQ_LEVEL; 96 desc->status |= IRQ_LEVEL;
97 orion5x_clrbits(GPIO_IN_POL, (1 << pin)); 97 orion5x_clrbits(GPIO_IN_POL, (1 << pin));
98 break; 98 break;
99 case IRQT_LOW: 99 case IRQ_TYPE_LEVEL_LOW:
100 desc->handle_irq = handle_level_irq; 100 desc->handle_irq = handle_level_irq;
101 desc->status |= IRQ_LEVEL; 101 desc->status |= IRQ_LEVEL;
102 orion5x_setbits(GPIO_IN_POL, (1 << pin)); 102 orion5x_setbits(GPIO_IN_POL, (1 << pin));
103 break; 103 break;
104 case IRQT_RISING: 104 case IRQ_TYPE_EDGE_RISING:
105 desc->handle_irq = handle_edge_irq; 105 desc->handle_irq = handle_edge_irq;
106 desc->status &= ~IRQ_LEVEL; 106 desc->status &= ~IRQ_LEVEL;
107 orion5x_clrbits(GPIO_IN_POL, (1 << pin)); 107 orion5x_clrbits(GPIO_IN_POL, (1 << pin));
108 break; 108 break;
109 case IRQT_FALLING: 109 case IRQ_TYPE_EDGE_FALLING:
110 desc->handle_irq = handle_edge_irq; 110 desc->handle_irq = handle_edge_irq;
111 desc->status &= ~IRQ_LEVEL; 111 desc->status &= ~IRQ_LEVEL;
112 orion5x_setbits(GPIO_IN_POL, (1 << pin)); 112 orion5x_setbits(GPIO_IN_POL, (1 << pin));
113 break; 113 break;
114 case IRQT_BOTHEDGE: 114 case IRQ_TYPE_EDGE_BOTH:
115 desc->handle_irq = handle_edge_irq; 115 desc->handle_irq = handle_edge_irq;
116 desc->status &= ~IRQ_LEVEL; 116 desc->status &= ~IRQ_LEVEL;
117 /* 117 /*
@@ -156,7 +156,7 @@ static void orion5x_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
156 if (cause & (1 << pin)) { 156 if (cause & (1 << pin)) {
157 irq = gpio_to_irq(pin); 157 irq = gpio_to_irq(pin);
158 desc = irq_desc + irq; 158 desc = irq_desc + irq;
159 if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQT_BOTHEDGE) { 159 if ((desc->status & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) {
160 /* Swap polarity (race with GPIO line) */ 160 /* Swap polarity (race with GPIO line) */
161 u32 polarity = readl(GPIO_IN_POL); 161 u32 polarity = readl(GPIO_IN_POL);
162 polarity ^= 1 << pin; 162 polarity ^= 1 << pin;
diff --git a/arch/arm/mach-orion5x/rd88f5182-setup.c b/arch/arm/mach-orion5x/rd88f5182-setup.c
index 10ae62864269..2a46d27209c1 100644
--- a/arch/arm/mach-orion5x/rd88f5182-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5182-setup.c
@@ -148,7 +148,7 @@ void __init rd88f5182_pci_preinit(void)
148 pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN; 148 pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
149 if (gpio_request(pin, "PCI IntA") == 0) { 149 if (gpio_request(pin, "PCI IntA") == 0) {
150 if (gpio_direction_input(pin) == 0) { 150 if (gpio_direction_input(pin) == 0) {
151 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 151 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
152 } else { 152 } else {
153 printk(KERN_ERR "rd88f5182_pci_preinit faield to " 153 printk(KERN_ERR "rd88f5182_pci_preinit faield to "
154 "set_irq_type pin %d\n", pin); 154 "set_irq_type pin %d\n", pin);
@@ -161,7 +161,7 @@ void __init rd88f5182_pci_preinit(void)
161 pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN; 161 pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
162 if (gpio_request(pin, "PCI IntB") == 0) { 162 if (gpio_request(pin, "PCI IntB") == 0) {
163 if (gpio_direction_input(pin) == 0) { 163 if (gpio_direction_input(pin) == 0) {
164 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 164 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
165 } else { 165 } else {
166 printk(KERN_ERR "rd88f5182_pci_preinit faield to " 166 printk(KERN_ERR "rd88f5182_pci_preinit faield to "
167 "set_irq_type pin %d\n", pin); 167 "set_irq_type pin %d\n", pin);
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c
index a9cef9703d5b..f270ada2def9 100644
--- a/arch/arm/mach-orion5x/ts209-setup.c
+++ b/arch/arm/mach-orion5x/ts209-setup.c
@@ -117,7 +117,7 @@ void __init qnap_ts209_pci_preinit(void)
117 pin = QNAP_TS209_PCI_SLOT0_IRQ_PIN; 117 pin = QNAP_TS209_PCI_SLOT0_IRQ_PIN;
118 if (gpio_request(pin, "PCI Int1") == 0) { 118 if (gpio_request(pin, "PCI Int1") == 0) {
119 if (gpio_direction_input(pin) == 0) { 119 if (gpio_direction_input(pin) == 0) {
120 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 120 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
121 } else { 121 } else {
122 printk(KERN_ERR "qnap_ts209_pci_preinit failed to " 122 printk(KERN_ERR "qnap_ts209_pci_preinit failed to "
123 "set_irq_type pin %d\n", pin); 123 "set_irq_type pin %d\n", pin);
@@ -131,7 +131,7 @@ void __init qnap_ts209_pci_preinit(void)
131 pin = QNAP_TS209_PCI_SLOT1_IRQ_PIN; 131 pin = QNAP_TS209_PCI_SLOT1_IRQ_PIN;
132 if (gpio_request(pin, "PCI Int2") == 0) { 132 if (gpio_request(pin, "PCI Int2") == 0) {
133 if (gpio_direction_input(pin) == 0) { 133 if (gpio_direction_input(pin) == 0) {
134 set_irq_type(gpio_to_irq(pin), IRQT_LOW); 134 set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
135 } else { 135 } else {
136 printk(KERN_ERR "qnap_ts209_pci_preinit failed " 136 printk(KERN_ERR "qnap_ts209_pci_preinit failed "
137 "to set_irq_type pin %d\n", pin); 137 "to set_irq_type pin %d\n", pin);
diff --git a/arch/arm/mach-pnx4008/irq.c b/arch/arm/mach-pnx4008/irq.c
index 968d0b027597..5ed67e1947a8 100644
--- a/arch/arm/mach-pnx4008/irq.c
+++ b/arch/arm/mach-pnx4008/irq.c
@@ -56,28 +56,28 @@ static void pnx4008_mask_ack_irq(unsigned int irq)
56static int pnx4008_set_irq_type(unsigned int irq, unsigned int type) 56static int pnx4008_set_irq_type(unsigned int irq, unsigned int type)
57{ 57{
58 switch (type) { 58 switch (type) {
59 case IRQT_RISING: 59 case IRQ_TYPE_EDGE_RISING:
60 __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq)); /*edge sensitive */ 60 __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq)); /*edge sensitive */
61 __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq)); /*rising edge */ 61 __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq)); /*rising edge */
62 set_irq_handler(irq, handle_edge_irq); 62 set_irq_handler(irq, handle_edge_irq);
63 break; 63 break;
64 case IRQT_FALLING: 64 case IRQ_TYPE_EDGE_FALLING:
65 __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq)); /*edge sensitive */ 65 __raw_writel(__raw_readl(INTC_ATR(irq)) | INTC_BIT(irq), INTC_ATR(irq)); /*edge sensitive */
66 __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq)); /*falling edge */ 66 __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq)); /*falling edge */
67 set_irq_handler(irq, handle_edge_irq); 67 set_irq_handler(irq, handle_edge_irq);
68 break; 68 break;
69 case IRQT_LOW: 69 case IRQ_TYPE_LEVEL_LOW:
70 __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq)); /*level sensitive */ 70 __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq)); /*level sensitive */
71 __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq)); /*low level */ 71 __raw_writel(__raw_readl(INTC_APR(irq)) & ~INTC_BIT(irq), INTC_APR(irq)); /*low level */
72 set_irq_handler(irq, handle_level_irq); 72 set_irq_handler(irq, handle_level_irq);
73 break; 73 break;
74 case IRQT_HIGH: 74 case IRQ_TYPE_LEVEL_HIGH:
75 __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq)); /*level sensitive */ 75 __raw_writel(__raw_readl(INTC_ATR(irq)) & ~INTC_BIT(irq), INTC_ATR(irq)); /*level sensitive */
76 __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq)); /* high level */ 76 __raw_writel(__raw_readl(INTC_APR(irq)) | INTC_BIT(irq), INTC_APR(irq)); /* high level */
77 set_irq_handler(irq, handle_level_irq); 77 set_irq_handler(irq, handle_level_irq);
78 break; 78 break;
79 79
80 /* IRQT_BOTHEDGE is not supported */ 80 /* IRQ_TYPE_EDGE_BOTH is not supported */
81 default: 81 default:
82 printk(KERN_ERR "PNX4008 IRQ: Unsupported irq type %d\n", type); 82 printk(KERN_ERR "PNX4008 IRQ: Unsupported irq type %d\n", type);
83 return -1; 83 return -1;
diff --git a/arch/arm/mach-pxa/cm-x270-pci.c b/arch/arm/mach-pxa/cm-x270-pci.c
index bcf0cde6ccc9..31f5bd411ced 100644
--- a/arch/arm/mach-pxa/cm-x270-pci.c
+++ b/arch/arm/mach-pxa/cm-x270-pci.c
@@ -71,7 +71,7 @@ void __cmx270_pci_init_irq(int irq_gpio)
71 71
72 cmx270_it8152_irq_gpio = irq_gpio; 72 cmx270_it8152_irq_gpio = irq_gpio;
73 73
74 set_irq_type(gpio_to_irq(irq_gpio), IRQT_RISING); 74 set_irq_type(gpio_to_irq(irq_gpio), IRQ_TYPE_EDGE_RISING);
75 75
76 set_irq_chained_handler(gpio_to_irq(irq_gpio), cmx270_it8152_irq_demux); 76 set_irq_chained_handler(gpio_to_irq(irq_gpio), cmx270_it8152_irq_demux);
77} 77}
diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c
index cc1c4fa06145..8d1ab54e7b20 100644
--- a/arch/arm/mach-pxa/lpd270.c
+++ b/arch/arm/mach-pxa/lpd270.c
@@ -113,7 +113,7 @@ static void __init lpd270_init_irq(void)
113 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 113 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
114 } 114 }
115 set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler); 115 set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler);
116 set_irq_type(IRQ_GPIO(0), IRQT_FALLING); 116 set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
117} 117}
118 118
119 119
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index ac26423cd20c..af7375bb46a4 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -152,7 +152,7 @@ static void __init lubbock_init_irq(void)
152 } 152 }
153 153
154 set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler); 154 set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
155 set_irq_type(IRQ_GPIO(0), IRQT_FALLING); 155 set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
156} 156}
157 157
158#ifdef CONFIG_PM 158#ifdef CONFIG_PM
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 851ec2d9b699..c8e38b5ff1c4 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -191,7 +191,7 @@ static void __init mainstone_init_irq(void)
191 MST_INTSETCLR = 0; 191 MST_INTSETCLR = 0;
192 192
193 set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler); 193 set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler);
194 set_irq_type(IRQ_GPIO(0), IRQT_FALLING); 194 set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
195} 195}
196 196
197#ifdef CONFIG_PM 197#ifdef CONFIG_PM
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 34cd585075b0..23e9b9283301 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -146,18 +146,18 @@ void sharpsl_pm_pxa_init(void)
146 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, IRQF_DISABLED, "AC Input Detect", sharpsl_ac_isr)) { 146 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, IRQF_DISABLED, "AC Input Detect", sharpsl_ac_isr)) {
147 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin)); 147 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin));
148 } 148 }
149 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQT_BOTHEDGE); 149 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQ_TYPE_EDGE_BOTH);
150 150
151 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, IRQF_DISABLED, "Battery Cover", sharpsl_fatal_isr)) { 151 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, IRQF_DISABLED, "Battery Cover", sharpsl_fatal_isr)) {
152 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock)); 152 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock));
153 } 153 }
154 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQT_FALLING); 154 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQ_TYPE_EDGE_FALLING);
155 155
156 if (sharpsl_pm.machinfo->gpio_fatal) { 156 if (sharpsl_pm.machinfo->gpio_fatal) {
157 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, IRQF_DISABLED, "Fatal Battery", sharpsl_fatal_isr)) { 157 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, IRQF_DISABLED, "Fatal Battery", sharpsl_fatal_isr)) {
158 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal)); 158 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal));
159 } 159 }
160 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING); 160 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQ_TYPE_EDGE_FALLING);
161 } 161 }
162 162
163 if (sharpsl_pm.machinfo->batfull_irq) 163 if (sharpsl_pm.machinfo->batfull_irq)
@@ -166,7 +166,7 @@ void sharpsl_pm_pxa_init(void)
166 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, IRQF_DISABLED, "CO", sharpsl_chrg_full_isr)) { 166 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, IRQF_DISABLED, "CO", sharpsl_chrg_full_isr)) {
167 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull)); 167 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull));
168 } 168 }
169 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); 169 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQ_TYPE_EDGE_RISING);
170 } 170 }
171} 171}
172 172
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index dee7bf36f013..12811b7aea07 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -122,7 +122,7 @@ static struct resource dm9000_resources[] = {
122 [2] = { 122 [2] = {
123 .start = TRIZEPS4_ETH_IRQ, 123 .start = TRIZEPS4_ETH_IRQ,
124 .end = TRIZEPS4_ETH_IRQ, 124 .end = TRIZEPS4_ETH_IRQ,
125 .flags = (IORESOURCE_IRQ | IRQT_RISING), 125 .flags = (IORESOURCE_IRQ | IRQ_TYPE_EDGE_RISING),
126 }, 126 },
127}; 127};
128 128
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
index 31afe50d7cd5..56d3ee01baae 100644
--- a/arch/arm/mach-sa1100/cerf.c
+++ b/arch/arm/mach-sa1100/cerf.c
@@ -96,7 +96,7 @@ static struct resource cerf_flash_resource = {
96static void __init cerf_init_irq(void) 96static void __init cerf_init_irq(void)
97{ 97{
98 sa1100_init_irq(); 98 sa1100_init_irq();
99 set_irq_type(CERF_ETH_IRQ, IRQT_RISING); 99 set_irq_type(CERF_ETH_IRQ, IRQ_TYPE_EDGE_RISING);
100} 100}
101 101
102static struct map_desc cerf_io_desc[] __initdata = { 102static struct map_desc cerf_io_desc[] __initdata = {
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index 8473c37b77d6..b34ff42bbd75 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -834,7 +834,7 @@ static void __init h3800_init_irq(void)
834 set_irq_chip(irq, &h3800_gpio_irqchip); 834 set_irq_chip(irq, &h3800_gpio_irqchip);
835 } 835 }
836#endif 836#endif
837 set_irq_type(IRQ_GPIO_H3800_ASIC, IRQT_RISING); 837 set_irq_type(IRQ_GPIO_H3800_ASIC, IRQ_TYPE_EDGE_RISING);
838 set_irq_chained_handler(IRQ_GPIO_H3800_ASIC, h3800_IRQ_demux); 838 set_irq_chained_handler(IRQ_GPIO_H3800_ASIC, h3800_IRQ_demux);
839} 839}
840 840
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index fa0403af7eec..c5e438b12ec7 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -46,17 +46,17 @@ static int sa1100_gpio_type(unsigned int irq, unsigned int type)
46 else 46 else
47 mask = GPIO11_27_MASK(irq); 47 mask = GPIO11_27_MASK(irq);
48 48
49 if (type == IRQT_PROBE) { 49 if (type == IRQ_TYPE_PROBE) {
50 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask) 50 if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
51 return 0; 51 return 0;
52 type = __IRQT_RISEDGE | __IRQT_FALEDGE; 52 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
53 } 53 }
54 54
55 if (type & __IRQT_RISEDGE) { 55 if (type & IRQ_TYPE_EDGE_RISING) {
56 GPIO_IRQ_rising_edge |= mask; 56 GPIO_IRQ_rising_edge |= mask;
57 } else 57 } else
58 GPIO_IRQ_rising_edge &= ~mask; 58 GPIO_IRQ_rising_edge &= ~mask;
59 if (type & __IRQT_FALEDGE) { 59 if (type & IRQ_TYPE_EDGE_FALLING) {
60 GPIO_IRQ_falling_edge |= mask; 60 GPIO_IRQ_falling_edge |= mask;
61 } else 61 } else
62 GPIO_IRQ_falling_edge &= ~mask; 62 GPIO_IRQ_falling_edge &= ~mask;
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 9f1ed1509301..967a48454f6b 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -151,7 +151,7 @@ static int __devinit neponset_probe(struct platform_device *dev)
151 /* 151 /*
152 * Install handler for GPIO25. 152 * Install handler for GPIO25.
153 */ 153 */
154 set_irq_type(IRQ_GPIO25, IRQT_RISING); 154 set_irq_type(IRQ_GPIO25, IRQ_TYPE_EDGE_RISING);
155 set_irq_chained_handler(IRQ_GPIO25, neponset_irq_handler); 155 set_irq_chained_handler(IRQ_GPIO25, neponset_irq_handler);
156 156
157 /* 157 /*
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
index c7bf7e0038f0..69a71f11625e 100644
--- a/arch/arm/mach-sa1100/pleb.c
+++ b/arch/arm/mach-sa1100/pleb.c
@@ -143,7 +143,7 @@ static void __init pleb_map_io(void)
143 143
144 GPDR &= ~GPIO_ETH0_IRQ; 144 GPDR &= ~GPIO_ETH0_IRQ;
145 145
146 set_irq_type(GPIO_ETH0_IRQ, IRQT_FALLING); 146 set_irq_type(GPIO_ETH0_IRQ, IRQ_TYPE_EDGE_FALLING);
147} 147}
148 148
149MACHINE_START(PLEB, "PLEB") 149MACHINE_START(PLEB, "PLEB")
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index 333a82a3717e..db7b3e38ef1d 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -274,6 +274,11 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
274void * 274void *
275dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp) 275dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
276{ 276{
277 void *memory;
278
279 if (dma_alloc_from_coherent(dev, size, handle, &memory))
280 return memory;
281
277 if (arch_is_coherent()) { 282 if (arch_is_coherent()) {
278 void *virt; 283 void *virt;
279 284
@@ -362,6 +367,9 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr
362 367
363 WARN_ON(irqs_disabled()); 368 WARN_ON(irqs_disabled());
364 369
370 if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
371 return;
372
365 if (arch_is_coherent()) { 373 if (arch_is_coherent()) {
366 kfree(cpu_addr); 374 kfree(cpu_addr);
367 return; 375 return;
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index fbfa26058442..a8ec97b4752e 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -37,7 +37,7 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
37 pgd_t *pgd; 37 pgd_t *pgd;
38 pmd_t *pmd; 38 pmd_t *pmd;
39 pte_t *pte, entry; 39 pte_t *pte, entry;
40 int ret = 0; 40 int ret;
41 41
42 pgd = pgd_offset(vma->vm_mm, address); 42 pgd = pgd_offset(vma->vm_mm, address);
43 if (pgd_none(*pgd)) 43 if (pgd_none(*pgd))
@@ -55,15 +55,19 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
55 entry = *pte; 55 entry = *pte;
56 56
57 /* 57 /*
58 * If this page is present, it's actually being shared.
59 */
60 ret = pte_present(entry);
61
62 /*
58 * If this page isn't present, or is already setup to 63 * If this page isn't present, or is already setup to
59 * fault (ie, is old), we can safely ignore any issues. 64 * fault (ie, is old), we can safely ignore any issues.
60 */ 65 */
61 if (pte_present(entry) && pte_val(entry) & shared_pte_mask) { 66 if (ret && pte_val(entry) & shared_pte_mask) {
62 flush_cache_page(vma, address, pte_pfn(entry)); 67 flush_cache_page(vma, address, pte_pfn(entry));
63 pte_val(entry) &= ~shared_pte_mask; 68 pte_val(entry) &= ~shared_pte_mask;
64 set_pte_at(vma->vm_mm, address, pte, entry); 69 set_pte_at(vma->vm_mm, address, pte, entry);
65 flush_tlb_page(vma, address); 70 flush_tlb_page(vma, address);
66 ret = 1;
67 } 71 }
68 pte_unmap(pte); 72 pte_unmap(pte);
69 return ret; 73 return ret;
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 4a7736717d86..318b268f938e 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -73,19 +73,19 @@ static int gpio_set_irq_type(u32 irq, u32 type)
73 void __iomem *reg = port->base; 73 void __iomem *reg = port->base;
74 74
75 switch (type) { 75 switch (type) {
76 case IRQT_RISING: 76 case IRQ_TYPE_EDGE_RISING:
77 edge = GPIO_INT_RISE_EDGE; 77 edge = GPIO_INT_RISE_EDGE;
78 break; 78 break;
79 case IRQT_FALLING: 79 case IRQ_TYPE_EDGE_FALLING:
80 edge = GPIO_INT_FALL_EDGE; 80 edge = GPIO_INT_FALL_EDGE;
81 break; 81 break;
82 case IRQT_LOW: 82 case IRQ_TYPE_LEVEL_LOW:
83 edge = GPIO_INT_LOW_LEV; 83 edge = GPIO_INT_LOW_LEV;
84 break; 84 break;
85 case IRQT_HIGH: 85 case IRQ_TYPE_LEVEL_HIGH:
86 edge = GPIO_INT_HIGH_LEV; 86 edge = GPIO_INT_HIGH_LEV;
87 break; 87 break;
88 default: /* this includes IRQT_BOTHEDGE */ 88 default: /* this includes IRQ_TYPE_EDGE_BOTH */
89 return -EINVAL; 89 return -EINVAL;
90 } 90 }
91 91
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index d8e9c2c3f0f6..63e094342ef6 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -517,13 +517,13 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
517 u32 gpio_bit = 1 << gpio; 517 u32 gpio_bit = 1 << gpio;
518 518
519 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit, 519 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
520 trigger & __IRQT_LOWLVL); 520 trigger & IRQ_TYPE_LEVEL_LOW);
521 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit, 521 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
522 trigger & __IRQT_HIGHLVL); 522 trigger & IRQ_TYPE_LEVEL_HIGH);
523 MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit, 523 MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
524 trigger & __IRQT_RISEDGE); 524 trigger & IRQ_TYPE_EDGE_RISING);
525 MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit, 525 MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
526 trigger & __IRQT_FALEDGE); 526 trigger & IRQ_TYPE_EDGE_FALLING);
527 527
528 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) { 528 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
529 if (trigger != 0) 529 if (trigger != 0)
@@ -555,9 +555,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
555 case METHOD_MPUIO: 555 case METHOD_MPUIO:
556 reg += OMAP_MPUIO_GPIO_INT_EDGE; 556 reg += OMAP_MPUIO_GPIO_INT_EDGE;
557 l = __raw_readl(reg); 557 l = __raw_readl(reg);
558 if (trigger & __IRQT_RISEDGE) 558 if (trigger & IRQ_TYPE_EDGE_RISING)
559 l |= 1 << gpio; 559 l |= 1 << gpio;
560 else if (trigger & __IRQT_FALEDGE) 560 else if (trigger & IRQ_TYPE_EDGE_FALLING)
561 l &= ~(1 << gpio); 561 l &= ~(1 << gpio);
562 else 562 else
563 goto bad; 563 goto bad;
@@ -567,9 +567,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
567 case METHOD_GPIO_1510: 567 case METHOD_GPIO_1510:
568 reg += OMAP1510_GPIO_INT_CONTROL; 568 reg += OMAP1510_GPIO_INT_CONTROL;
569 l = __raw_readl(reg); 569 l = __raw_readl(reg);
570 if (trigger & __IRQT_RISEDGE) 570 if (trigger & IRQ_TYPE_EDGE_RISING)
571 l |= 1 << gpio; 571 l |= 1 << gpio;
572 else if (trigger & __IRQT_FALEDGE) 572 else if (trigger & IRQ_TYPE_EDGE_FALLING)
573 l &= ~(1 << gpio); 573 l &= ~(1 << gpio);
574 else 574 else
575 goto bad; 575 goto bad;
@@ -584,9 +584,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
584 gpio &= 0x07; 584 gpio &= 0x07;
585 l = __raw_readl(reg); 585 l = __raw_readl(reg);
586 l &= ~(3 << (gpio << 1)); 586 l &= ~(3 << (gpio << 1));
587 if (trigger & __IRQT_RISEDGE) 587 if (trigger & IRQ_TYPE_EDGE_RISING)
588 l |= 2 << (gpio << 1); 588 l |= 2 << (gpio << 1);
589 if (trigger & __IRQT_FALEDGE) 589 if (trigger & IRQ_TYPE_EDGE_FALLING)
590 l |= 1 << (gpio << 1); 590 l |= 1 << (gpio << 1);
591 if (trigger) 591 if (trigger)
592 /* Enable wake-up during idle for dynamic tick */ 592 /* Enable wake-up during idle for dynamic tick */
@@ -599,9 +599,9 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
599 case METHOD_GPIO_730: 599 case METHOD_GPIO_730:
600 reg += OMAP730_GPIO_INT_CONTROL; 600 reg += OMAP730_GPIO_INT_CONTROL;
601 l = __raw_readl(reg); 601 l = __raw_readl(reg);
602 if (trigger & __IRQT_RISEDGE) 602 if (trigger & IRQ_TYPE_EDGE_RISING)
603 l |= 1 << gpio; 603 l |= 1 << gpio;
604 else if (trigger & __IRQT_FALEDGE) 604 else if (trigger & IRQ_TYPE_EDGE_FALLING)
605 l &= ~(1 << gpio); 605 l &= ~(1 << gpio);
606 else 606 else
607 goto bad; 607 goto bad;
@@ -887,7 +887,7 @@ static void _reset_gpio(struct gpio_bank *bank, int gpio)
887 _set_gpio_direction(bank, get_gpio_index(gpio), 1); 887 _set_gpio_direction(bank, get_gpio_index(gpio), 1);
888 _set_gpio_irqenable(bank, gpio, 0); 888 _set_gpio_irqenable(bank, gpio, 0);
889 _clear_gpio_irqstatus(bank, gpio); 889 _clear_gpio_irqstatus(bank, gpio);
890 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQT_NOEDGE); 890 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
891} 891}
892 892
893/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */ 893/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */
@@ -924,7 +924,7 @@ int omap_request_gpio(int gpio)
924 /* Set trigger to none. You need to enable the desired trigger with 924 /* Set trigger to none. You need to enable the desired trigger with
925 * request_irq() or set_irq_type(). 925 * request_irq() or set_irq_type().
926 */ 926 */
927 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQT_NOEDGE); 927 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
928 928
929#ifdef CONFIG_ARCH_OMAP15XX 929#ifdef CONFIG_ARCH_OMAP15XX
930 if (bank->method == METHOD_GPIO_1510) { 930 if (bank->method == METHOD_GPIO_1510) {
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index 5e28c217b8c2..0af3872fb763 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -9,7 +9,7 @@ config PLAT_S3C24XX
9 depends on ARCH_S3C2410 9 depends on ARCH_S3C2410
10 default y if ARCH_S3C2410 10 default y if ARCH_S3C2410
11 select NO_IOPORT 11 select NO_IOPORT
12 select HAVE_GPIO_LIB 12 select ARCH_REQUIRE_GPIOLIB
13 help 13 help
14 Base platform code for any Samsung S3C24XX device 14 Base platform code for any Samsung S3C24XX device
15 15
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index 60f162dc4fad..8c5e656d5d8c 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -1304,7 +1304,7 @@ struct sysdev_class dma_sysclass = {
1304 1304
1305/* kmem cache implementation */ 1305/* kmem cache implementation */
1306 1306
1307static void s3c2410_dma_cache_ctor(struct kmem_cache *c, void *p) 1307static void s3c2410_dma_cache_ctor(void *p)
1308{ 1308{
1309 memset(p, 0, sizeof(struct s3c2410_dma_buf)); 1309 memset(p, 0, sizeof(struct s3c2410_dma_buf));
1310} 1310}
diff --git a/arch/arm/plat-s3c24xx/irq.c b/arch/arm/plat-s3c24xx/irq.c
index ae2c5d7efc9d..001436c04b13 100644
--- a/arch/arm/plat-s3c24xx/irq.c
+++ b/arch/arm/plat-s3c24xx/irq.c
@@ -292,27 +292,27 @@ s3c_irqext_type(unsigned int irq, unsigned int type)
292 /* Set the external interrupt to pointed trigger type */ 292 /* Set the external interrupt to pointed trigger type */
293 switch (type) 293 switch (type)
294 { 294 {
295 case IRQT_NOEDGE: 295 case IRQ_TYPE_NONE:
296 printk(KERN_WARNING "No edge setting!\n"); 296 printk(KERN_WARNING "No edge setting!\n");
297 break; 297 break;
298 298
299 case IRQT_RISING: 299 case IRQ_TYPE_EDGE_RISING:
300 newvalue = S3C2410_EXTINT_RISEEDGE; 300 newvalue = S3C2410_EXTINT_RISEEDGE;
301 break; 301 break;
302 302
303 case IRQT_FALLING: 303 case IRQ_TYPE_EDGE_FALLING:
304 newvalue = S3C2410_EXTINT_FALLEDGE; 304 newvalue = S3C2410_EXTINT_FALLEDGE;
305 break; 305 break;
306 306
307 case IRQT_BOTHEDGE: 307 case IRQ_TYPE_EDGE_BOTH:
308 newvalue = S3C2410_EXTINT_BOTHEDGE; 308 newvalue = S3C2410_EXTINT_BOTHEDGE;
309 break; 309 break;
310 310
311 case IRQT_LOW: 311 case IRQ_TYPE_LEVEL_LOW:
312 newvalue = S3C2410_EXTINT_LOWLEV; 312 newvalue = S3C2410_EXTINT_LOWLEV;
313 break; 313 break;
314 314
315 case IRQT_HIGH: 315 case IRQ_TYPE_LEVEL_HIGH:
316 newvalue = S3C2410_EXTINT_HILEV; 316 newvalue = S3C2410_EXTINT_HILEV;
317 break; 317 break;
318 318
diff --git a/arch/avr32/boards/atstk1000/Kconfig b/arch/avr32/boards/atstk1000/Kconfig
index af90b00100fd..8dc48214f0b7 100644
--- a/arch/avr32/boards/atstk1000/Kconfig
+++ b/arch/avr32/boards/atstk1000/Kconfig
@@ -18,6 +18,10 @@ config BOARD_ATSTK1004
18 bool "ATSTK1004" 18 bool "ATSTK1004"
19 select CPU_AT32AP7002 19 select CPU_AT32AP7002
20 20
21config BOARD_ATSTK1006
22 bool "ATSTK1006"
23 select CPU_AT32AP7000
24
21endchoice 25endchoice
22 26
23 27
diff --git a/arch/avr32/boards/atstk1000/Makefile b/arch/avr32/boards/atstk1000/Makefile
index beead86462e8..edecee03742d 100644
--- a/arch/avr32/boards/atstk1000/Makefile
+++ b/arch/avr32/boards/atstk1000/Makefile
@@ -2,3 +2,4 @@ obj-y += setup.o flash.o
2obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o 2obj-$(CONFIG_BOARD_ATSTK1002) += atstk1002.o
3obj-$(CONFIG_BOARD_ATSTK1003) += atstk1003.o 3obj-$(CONFIG_BOARD_ATSTK1003) += atstk1003.o
4obj-$(CONFIG_BOARD_ATSTK1004) += atstk1004.o 4obj-$(CONFIG_BOARD_ATSTK1004) += atstk1004.o
5obj-$(CONFIG_BOARD_ATSTK1006) += atstk1002.o
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index e11659b732fa..8538ba75ef92 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ATSTK1002 daughterboard-specific init code 2 * ATSTK1002/ATSTK1006 daughterboard-specific init code
3 * 3 *
4 * Copyright (C) 2005-2006 Atmel Corporation 4 * Copyright (C) 2005-2007 Atmel Corporation
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License version 2 as
@@ -21,6 +21,8 @@
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/setup.h> 23#include <asm/setup.h>
24#include <asm/atmel-mci.h>
25
24#include <asm/arch/at32ap700x.h> 26#include <asm/arch/at32ap700x.h>
25#include <asm/arch/board.h> 27#include <asm/arch/board.h>
26#include <asm/arch/init.h> 28#include <asm/arch/init.h>
@@ -35,6 +37,74 @@ unsigned long at32_board_osc_rates[3] = {
35 [2] = 12000000, /* 12 MHz on osc1 */ 37 [2] = 12000000, /* 12 MHz on osc1 */
36}; 38};
37 39
40/*
41 * The ATSTK1006 daughterboard is very similar to the ATSTK1002. Both
42 * have the AT32AP7000 chip on board; the difference is that the
43 * STK1006 has 128 MB SDRAM (the STK1002 uses the 8 MB SDRAM chip on
44 * the STK1000 motherboard) and 256 MB NAND flash (the STK1002 has
45 * none.)
46 *
47 * The RAM difference is handled by the boot loader, so the only
48 * difference we end up handling here is the NAND flash.
49 */
50#ifdef CONFIG_BOARD_ATSTK1006
51#include <linux/mtd/partitions.h>
52#include <asm/arch/smc.h>
53
54static struct smc_timing nand_timing __initdata = {
55 .ncs_read_setup = 0,
56 .nrd_setup = 10,
57 .ncs_write_setup = 0,
58 .nwe_setup = 10,
59
60 .ncs_read_pulse = 30,
61 .nrd_pulse = 15,
62 .ncs_write_pulse = 30,
63 .nwe_pulse = 15,
64
65 .read_cycle = 30,
66 .write_cycle = 30,
67
68 .ncs_read_recover = 0,
69 .nrd_recover = 15,
70 .ncs_write_recover = 0,
71 /* WE# high -> RE# low min 60 ns */
72 .nwe_recover = 50,
73};
74
75static struct smc_config nand_config __initdata = {
76 .bus_width = 1,
77 .nrd_controlled = 1,
78 .nwe_controlled = 1,
79 .nwait_mode = 0,
80 .byte_write = 0,
81 .tdf_cycles = 2,
82 .tdf_mode = 0,
83};
84
85static struct mtd_partition nand_partitions[] = {
86 {
87 .name = "main",
88 .offset = 0x00000000,
89 .size = MTDPART_SIZ_FULL,
90 },
91};
92
93static struct mtd_partition *nand_part_info(int size, int *num_partitions)
94{
95 *num_partitions = ARRAY_SIZE(nand_partitions);
96 return nand_partitions;
97}
98
99struct atmel_nand_data atstk1006_nand_data __initdata = {
100 .cle = 21,
101 .ale = 22,
102 .rdy_pin = GPIO_PIN_PB(30),
103 .enable_pin = GPIO_PIN_PB(29),
104 .partition_info = nand_part_info,
105};
106#endif
107
38struct eth_addr { 108struct eth_addr {
39 u8 addr[6]; 109 u8 addr[6];
40}; 110};
@@ -192,6 +262,21 @@ void __init setup_board(void)
192 at32_setup_serial_console(0); 262 at32_setup_serial_console(0);
193} 263}
194 264
265#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
266
267/* MMC card detect requires MACB0 *NOT* be used */
268#ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM
269static struct mci_platform_data __initdata mci0_data = {
270 .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */
271 .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */
272};
273#define MCI_PDATA &mci0_data
274#else
275#define MCI_PDATA NULL
276#endif /* SW6 for sd{cd,wp} routing */
277
278#endif /* SW2 for MMC signal routing */
279
195static int __init atstk1002_init(void) 280static int __init atstk1002_init(void)
196{ 281{
197 /* 282 /*
@@ -218,6 +303,12 @@ static int __init atstk1002_init(void)
218 303
219 at32_add_system_devices(); 304 at32_add_system_devices();
220 305
306#ifdef CONFIG_BOARD_ATSTK1006
307 smc_set_timing(&nand_config, &nand_timing);
308 smc_set_configuration(3, &nand_config);
309 at32_add_device_nand(0, &atstk1006_nand_data);
310#endif
311
221#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 312#ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
222 at32_add_device_usart(1); 313 at32_add_device_usart(1);
223#else 314#else
@@ -235,7 +326,7 @@ static int __init atstk1002_init(void)
235 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 326 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
236#endif 327#endif
237#ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM 328#ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM
238 at32_add_device_mci(0, NULL); 329 at32_add_device_mci(0, MCI_PDATA);
239#endif 330#endif
240#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM 331#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
241 set_hw_addr(at32_add_device_eth(1, &eth_data[1])); 332 set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
diff --git a/arch/avr32/boards/atstk1000/atstk1003.c b/arch/avr32/boards/atstk1000/atstk1003.c
index ea109f435a83..591fc73b554a 100644
--- a/arch/avr32/boards/atstk1000/atstk1003.c
+++ b/arch/avr32/boards/atstk1000/atstk1003.c
@@ -154,7 +154,7 @@ static int __init atstk1003_init(void)
154 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 154 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
155#endif 155#endif
156#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 156#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
157 at32_add_device_mci(0); 157 at32_add_device_mci(0, NULL);
158#endif 158#endif
159 at32_add_device_usba(0, NULL); 159 at32_add_device_usba(0, NULL);
160#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM 160#ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
diff --git a/arch/avr32/boards/atstk1000/atstk1004.c b/arch/avr32/boards/atstk1000/atstk1004.c
index c7236df74d74..d9c5e0a21256 100644
--- a/arch/avr32/boards/atstk1000/atstk1004.c
+++ b/arch/avr32/boards/atstk1000/atstk1004.c
@@ -137,7 +137,7 @@ static int __init atstk1004_init(void)
137 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 137 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
138#endif 138#endif
139#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 139#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
140 at32_add_device_mci(0); 140 at32_add_device_mci(0, NULL);
141#endif 141#endif
142 at32_add_device_lcdc(0, &atstk1000_lcdc_data, 142 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
143 fbmem_start, fbmem_size, 0); 143 fbmem_start, fbmem_size, 0);
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index abd954fb7ba0..7e7f32771ae1 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -43,6 +43,9 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
43{ 43{
44 struct clock_event_device *evdev = dev_id; 44 struct clock_event_device *evdev = dev_id;
45 45
46 if (unlikely(!(intc_get_pending(0) & 1)))
47 return IRQ_NONE;
48
46 /* 49 /*
47 * Disable the interrupt until the clockevent subsystem 50 * Disable the interrupt until the clockevent subsystem
48 * reprograms it. 51 * reprograms it.
@@ -55,7 +58,8 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
55 58
56static struct irqaction timer_irqaction = { 59static struct irqaction timer_irqaction = {
57 .handler = timer_interrupt, 60 .handler = timer_interrupt,
58 .flags = IRQF_TIMER | IRQF_DISABLED, 61 /* Oprofile uses the same irq as the timer, so allow it to be shared */
62 .flags = IRQF_TIMER | IRQF_DISABLED | IRQF_SHARED,
59 .name = "avr32_comparator", 63 .name = "avr32_comparator",
60}; 64};
61 65
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 604f44f5dd16..1617048c86c5 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/gpio.h>
15#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
16#include <linux/usb/atmel_usba_udc.h> 17#include <linux/usb/atmel_usba_udc.h>
17 18
@@ -1285,7 +1286,6 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1285{ 1286{
1286 struct mci_platform_data _data; 1287 struct mci_platform_data _data;
1287 struct platform_device *pdev; 1288 struct platform_device *pdev;
1288 struct dw_dma_slave *dws;
1289 1289
1290 if (id != 0) 1290 if (id != 0)
1291 return NULL; 1291 return NULL;
@@ -1300,7 +1300,9 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1300 1300
1301 if (!data) { 1301 if (!data) {
1302 data = &_data; 1302 data = &_data;
1303 memset(data, 0, sizeof(struct mci_platform_data)); 1303 memset(data, -1, sizeof(struct mci_platform_data));
1304 data->detect_pin = GPIO_PIN_NONE;
1305 data->wp_pin = GPIO_PIN_NONE;
1304 } 1306 }
1305 1307
1306 if (platform_device_add_data(pdev, data, 1308 if (platform_device_add_data(pdev, data,
@@ -1314,12 +1316,10 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1314 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ 1316 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
1315 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ 1317 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
1316 1318
1317 if (data) { 1319 if (gpio_is_valid(data->detect_pin))
1318 if (data->detect_pin != GPIO_PIN_NONE) 1320 at32_select_gpio(data->detect_pin, 0);
1319 at32_select_gpio(data->detect_pin, 0); 1321 if (gpio_is_valid(data->wp_pin))
1320 if (data->wp_pin != GPIO_PIN_NONE) 1322 at32_select_gpio(data->wp_pin, 0);
1321 at32_select_gpio(data->wp_pin, 0);
1322 }
1323 1323
1324 atmel_mci0_pclk.dev = &pdev->dev; 1324 atmel_mci0_pclk.dev = &pdev->dev;
1325 1325
@@ -1853,11 +1853,11 @@ at32_add_device_cf(unsigned int id, unsigned int extint,
1853 if (at32_init_ide_or_cf(pdev, data->cs, extint)) 1853 if (at32_init_ide_or_cf(pdev, data->cs, extint))
1854 goto fail; 1854 goto fail;
1855 1855
1856 if (data->detect_pin != GPIO_PIN_NONE) 1856 if (gpio_is_valid(data->detect_pin))
1857 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); 1857 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH);
1858 if (data->reset_pin != GPIO_PIN_NONE) 1858 if (gpio_is_valid(data->reset_pin))
1859 at32_select_gpio(data->reset_pin, 0); 1859 at32_select_gpio(data->reset_pin, 0);
1860 if (data->vcc_pin != GPIO_PIN_NONE) 1860 if (gpio_is_valid(data->vcc_pin))
1861 at32_select_gpio(data->vcc_pin, 0); 1861 at32_select_gpio(data->vcc_pin, 0);
1862 /* READY is used as extint, so we can't select it as gpio */ 1862 /* READY is used as extint, so we can't select it as gpio */
1863 1863
@@ -1871,6 +1871,58 @@ fail:
1871#endif 1871#endif
1872 1872
1873/* -------------------------------------------------------------------- 1873/* --------------------------------------------------------------------
1874 * NAND Flash / SmartMedia
1875 * -------------------------------------------------------------------- */
1876static struct resource smc_cs3_resource[] __initdata = {
1877 {
1878 .start = 0x0c000000,
1879 .end = 0x0fffffff,
1880 .flags = IORESOURCE_MEM,
1881 }, {
1882 .start = 0xfff03c00,
1883 .end = 0xfff03fff,
1884 .flags = IORESOURCE_MEM,
1885 },
1886};
1887
1888struct platform_device *__init
1889at32_add_device_nand(unsigned int id, struct atmel_nand_data *data)
1890{
1891 struct platform_device *pdev;
1892
1893 if (id != 0 || !data)
1894 return NULL;
1895
1896 pdev = platform_device_alloc("atmel_nand", id);
1897 if (!pdev)
1898 goto fail;
1899
1900 if (platform_device_add_resources(pdev, smc_cs3_resource,
1901 ARRAY_SIZE(smc_cs3_resource)))
1902 goto fail;
1903
1904 if (platform_device_add_data(pdev, data,
1905 sizeof(struct atmel_nand_data)))
1906 goto fail;
1907
1908 set_ebi_sfr_bits(HMATRIX_BIT(CS3A));
1909 if (data->enable_pin)
1910 at32_select_gpio(data->enable_pin,
1911 AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
1912 if (data->rdy_pin)
1913 at32_select_gpio(data->rdy_pin, 0);
1914 if (data->det_pin)
1915 at32_select_gpio(data->det_pin, 0);
1916
1917 platform_device_add(pdev);
1918 return pdev;
1919
1920fail:
1921 platform_device_put(pdev);
1922 return NULL;
1923}
1924
1925/* --------------------------------------------------------------------
1874 * AC97C 1926 * AC97C
1875 * -------------------------------------------------------------------- */ 1927 * -------------------------------------------------------------------- */
1876static struct resource atmel_ac97c0_resource[] __initdata = { 1928static struct resource atmel_ac97c0_resource[] __initdata = {
@@ -1885,9 +1937,11 @@ static struct clk atmel_ac97c0_pclk = {
1885 .index = 10, 1937 .index = 10,
1886}; 1938};
1887 1939
1888struct platform_device *__init at32_add_device_ac97c(unsigned int id) 1940struct platform_device *__init
1941at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data)
1889{ 1942{
1890 struct platform_device *pdev; 1943 struct platform_device *pdev;
1944 struct ac97c_platform_data _data;
1891 1945
1892 if (id != 0) 1946 if (id != 0)
1893 return NULL; 1947 return NULL;
@@ -1898,19 +1952,37 @@ struct platform_device *__init at32_add_device_ac97c(unsigned int id)
1898 1952
1899 if (platform_device_add_resources(pdev, atmel_ac97c0_resource, 1953 if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
1900 ARRAY_SIZE(atmel_ac97c0_resource))) 1954 ARRAY_SIZE(atmel_ac97c0_resource)))
1901 goto err_add_resources; 1955 goto fail;
1902 1956
1903 select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */ 1957 if (!data) {
1904 select_peripheral(PB(21), PERIPH_B, 0); /* SDO */ 1958 data = &_data;
1905 select_peripheral(PB(22), PERIPH_B, 0); /* SDI */ 1959 memset(data, 0, sizeof(struct ac97c_platform_data));
1906 select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */ 1960 data->reset_pin = GPIO_PIN_NONE;
1961 }
1962
1963 data->dma_rx_periph_id = 3;
1964 data->dma_tx_periph_id = 4;
1965 data->dma_controller_id = 0;
1966
1967 if (platform_device_add_data(pdev, data,
1968 sizeof(struct ac97c_platform_data)))
1969 goto fail;
1970
1971 select_peripheral(PB(20), PERIPH_B, 0); /* SDO */
1972 select_peripheral(PB(21), PERIPH_B, 0); /* SYNC */
1973 select_peripheral(PB(22), PERIPH_B, 0); /* SCLK */
1974 select_peripheral(PB(23), PERIPH_B, 0); /* SDI */
1975
1976 /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */
1977 if (data->reset_pin != GPIO_PIN_NONE)
1978 at32_select_gpio(data->reset_pin, 0);
1907 1979
1908 atmel_ac97c0_pclk.dev = &pdev->dev; 1980 atmel_ac97c0_pclk.dev = &pdev->dev;
1909 1981
1910 platform_device_add(pdev); 1982 platform_device_add(pdev);
1911 return pdev; 1983 return pdev;
1912 1984
1913err_add_resources: 1985fail:
1914 platform_device_put(pdev); 1986 platform_device_put(pdev);
1915 return NULL; 1987 return NULL;
1916} 1988}
diff --git a/arch/avr32/mach-at32ap/hsmc.c b/arch/avr32/mach-at32ap/hsmc.c
index fa427ed42787..b2d9bc61a35c 100644
--- a/arch/avr32/mach-at32ap/hsmc.c
+++ b/arch/avr32/mach-at32ap/hsmc.c
@@ -278,4 +278,4 @@ static int __init hsmc_init(void)
278{ 278{
279 return platform_driver_register(&hsmc_driver); 279 return platform_driver_register(&hsmc_driver);
280} 280}
281arch_initcall(hsmc_init); 281core_initcall(hsmc_init);
diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 3c85fdaa9487..fa92ff6d95f7 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -38,45 +38,6 @@ EXPORT_SYMBOL(empty_zero_page);
38 */ 38 */
39unsigned long mmu_context_cache = NO_CONTEXT; 39unsigned long mmu_context_cache = NO_CONTEXT;
40 40
41void show_mem(void)
42{
43 int total = 0, reserved = 0, cached = 0;
44 int slab = 0, free = 0, shared = 0;
45 pg_data_t *pgdat;
46
47 printk("Mem-info:\n");
48 show_free_areas();
49
50 for_each_online_pgdat(pgdat) {
51 struct page *page, *end;
52
53 page = pgdat->node_mem_map;
54 end = page + pgdat->node_spanned_pages;
55
56 do {
57 total++;
58 if (PageReserved(page))
59 reserved++;
60 else if (PageSwapCache(page))
61 cached++;
62 else if (PageSlab(page))
63 slab++;
64 else if (!page_count(page))
65 free++;
66 else
67 shared += page_count(page) - 1;
68 page++;
69 } while (page < end);
70 }
71
72 printk ("%d pages of RAM\n", total);
73 printk ("%d free pages\n", free);
74 printk ("%d reserved pages\n", reserved);
75 printk ("%d slab pages\n", slab);
76 printk ("%d pages shared\n", shared);
77 printk ("%d pages swap cached\n", cached);
78}
79
80/* 41/*
81 * paging_init() sets up the page tables 42 * paging_init() sets up the page tables
82 * 43 *
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index b83b8ef84e91..5a097c46bc46 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -234,7 +234,7 @@ config MEM_MT48LC16M16A2TG_75
234 bool 234 bool
235 depends on (BFIN533_EZKIT || BFIN561_EZKIT \ 235 depends on (BFIN533_EZKIT || BFIN561_EZKIT \
236 || BFIN533_BLUETECHNIX_CM || BFIN537_BLUETECHNIX_CM \ 236 || BFIN533_BLUETECHNIX_CM || BFIN537_BLUETECHNIX_CM \
237 || H8606_HVSISTEMAS) 237 || H8606_HVSISTEMAS || BFIN527_BLUETECHNIX_CM)
238 default y 238 default y
239 239
240config MEM_MT48LC32M8A2_75 240config MEM_MT48LC32M8A2_75
@@ -310,25 +310,6 @@ config BFIN_KERNEL_CLOCK
310 are also not changed, and the Bootloader does 100% of the hardware 310 are also not changed, and the Bootloader does 100% of the hardware
311 configuration. 311 configuration.
312 312
313config MEM_SIZE
314 int "SDRAM Memory Size in MBytes"
315 depends on BFIN_KERNEL_CLOCK
316 default 64
317
318config MEM_ADD_WIDTH
319 int "Memory Address Width"
320 depends on BFIN_KERNEL_CLOCK
321 depends on (!BF54x)
322 range 8 11
323 default 9 if BFIN533_EZKIT
324 default 9 if BFIN561_EZKIT
325 default 9 if H8606_HVSISTEMAS
326 default 10 if BFIN527_EZKIT
327 default 10 if BFIN537_STAMP
328 default 11 if BFIN533_STAMP
329 default 10 if PNAV10
330 default 10 if BFIN532_IP0X
331
332config PLL_BYPASS 313config PLL_BYPASS
333 bool "Bypass PLL" 314 bool "Bypass PLL"
334 depends on BFIN_KERNEL_CLOCK 315 depends on BFIN_KERNEL_CLOCK
@@ -349,8 +330,7 @@ config VCO_MULT
349 default "45" if BFIN533_STAMP 330 default "45" if BFIN533_STAMP
350 default "20" if (BFIN537_STAMP || BFIN527_EZKIT || BFIN548_EZKIT || BFIN548_BLUETECHNIX_CM) 331 default "20" if (BFIN537_STAMP || BFIN527_EZKIT || BFIN548_EZKIT || BFIN548_BLUETECHNIX_CM)
351 default "22" if BFIN533_BLUETECHNIX_CM 332 default "22" if BFIN533_BLUETECHNIX_CM
352 default "20" if BFIN537_BLUETECHNIX_CM 333 default "20" if (BFIN537_BLUETECHNIX_CM || BFIN527_BLUETECHNIX_CM || BFIN561_BLUETECHNIX_CM)
353 default "20" if BFIN561_BLUETECHNIX_CM
354 default "20" if BFIN561_EZKIT 334 default "20" if BFIN561_EZKIT
355 default "16" if H8606_HVSISTEMAS 335 default "16" if H8606_HVSISTEMAS
356 help 336 help
@@ -390,7 +370,7 @@ config SCLK_DIV
390 370
391config MAX_MEM_SIZE 371config MAX_MEM_SIZE
392 int "Max SDRAM Memory Size in MBytes" 372 int "Max SDRAM Memory Size in MBytes"
393 depends on !BFIN_KERNEL_CLOCK && !MPU 373 depends on !MPU
394 default 512 374 default 512
395 help 375 help
396 This is the max memory size that the kernel will create CPLB 376 This is the max memory size that the kernel will create CPLB
@@ -748,14 +728,6 @@ config BFIN_WT
748 728
749endchoice 729endchoice
750 730
751config L1_MAX_PIECE
752 int "Set the max L1 SRAM pieces"
753 default 16
754 help
755 Set the max memory pieces for the L1 SRAM allocation algorithm.
756 Min value is 16. Max value is 1024.
757
758
759config MPU 731config MPU
760 bool "Enable the memory protection unit (EXPERIMENTAL)" 732 bool "Enable the memory protection unit (EXPERIMENTAL)"
761 default n 733 default n
@@ -899,7 +871,7 @@ config ARCH_SUSPEND_POSSIBLE
899 depends on !SMP 871 depends on !SMP
900 872
901choice 873choice
902 prompt "Default Power Saving Mode" 874 prompt "Standby Power Saving Mode"
903 depends on PM 875 depends on PM
904 default PM_BFIN_SLEEP_DEEPER 876 default PM_BFIN_SLEEP_DEEPER
905config PM_BFIN_SLEEP_DEEPER 877config PM_BFIN_SLEEP_DEEPER
@@ -918,6 +890,8 @@ config PM_BFIN_SLEEP_DEEPER
918 normal during Sleep Deeper, due to the reduced SCLK frequency. 890 normal during Sleep Deeper, due to the reduced SCLK frequency.
919 When in the sleep mode, system DMA access to L1 memory is not supported. 891 When in the sleep mode, system DMA access to L1 memory is not supported.
920 892
893 If unsure, select "Sleep Deeper".
894
921config PM_BFIN_SLEEP 895config PM_BFIN_SLEEP
922 bool "Sleep" 896 bool "Sleep"
923 help 897 help
@@ -925,15 +899,17 @@ config PM_BFIN_SLEEP
925 dissipation by disabling the clock to the processor core (CCLK). 899 dissipation by disabling the clock to the processor core (CCLK).
926 The PLL and system clock (SCLK), however, continue to operate in 900 The PLL and system clock (SCLK), however, continue to operate in
927 this mode. Typically an external event or RTC activity will wake 901 this mode. Typically an external event or RTC activity will wake
928 up the processor. When in the sleep mode, 902 up the processor. When in the sleep mode, system DMA access to L1
929 system DMA access to L1 memory is not supported. 903 memory is not supported.
904
905 If unsure, select "Sleep Deeper".
930endchoice 906endchoice
931 907
932config PM_WAKEUP_BY_GPIO 908config PM_WAKEUP_BY_GPIO
933 bool "Cause Wakeup Event by GPIO" 909 bool "Allow Wakeup from Standby by GPIO"
934 910
935config PM_WAKEUP_GPIO_NUMBER 911config PM_WAKEUP_GPIO_NUMBER
936 int "Wakeup GPIO number" 912 int "GPIO number"
937 range 0 47 913 range 0 47
938 depends on PM_WAKEUP_BY_GPIO 914 depends on PM_WAKEUP_BY_GPIO
939 default 2 if BFIN537_STAMP 915 default 2 if BFIN537_STAMP
@@ -954,6 +930,58 @@ config PM_WAKEUP_GPIO_POLAR_EDGE_B
954 bool "Both EDGE" 930 bool "Both EDGE"
955endchoice 931endchoice
956 932
933comment "Possible Suspend Mem / Hibernate Wake-Up Sources"
934 depends on PM
935
936config PM_BFIN_WAKE_RTC
937 bool "Allow Wake-Up from RESET and on-chip RTC"
938 depends on PM
939 default n
940 help
941 Enable RTC Wake-Up (Voltage Regulator Power-Up)
942
943config PM_BFIN_WAKE_PH6
944 bool "Allow Wake-Up from on-chip PHY or PH6 GP"
945 depends on PM && (BF52x || BF534 || BF536 || BF537)
946 default n
947 help
948 Enable PHY and PH6 GP Wake-Up (Voltage Regulator Power-Up)
949
950config PM_BFIN_WAKE_CAN
951 bool "Allow Wake-Up from on-chip CAN0/1"
952 depends on PM && (BF54x || BF534 || BF536 || BF537)
953 default n
954 help
955 Enable CAN0/1 Wake-Up (Voltage Regulator Power-Up)
956
957config PM_BFIN_WAKE_GP
958 bool "Allow Wake-Up from GPIOs"
959 depends on PM && BF54x
960 default n
961 help
962 Enable General-Purpose Wake-Up (Voltage Regulator Power-Up)
963
964config PM_BFIN_WAKE_USB
965 bool "Allow Wake-Up from on-chip USB"
966 depends on PM && (BF54x || BF52x)
967 default n
968 help
969 Enable USB Wake-Up (Voltage Regulator Power-Up)
970
971config PM_BFIN_WAKE_KEYPAD
972 bool "Allow Wake-Up from on-chip Keypad"
973 depends on PM && BF54x
974 default n
975 help
976 Enable Keypad Wake-Up (Voltage Regulator Power-Up)
977
978config PM_BFIN_WAKE_ROTARY
979 bool "Allow Wake-Up from on-chip Rotary"
980 depends on PM && BF54x
981 default n
982 help
983 Enable Rotary Wake-Up (Voltage Regulator Power-Up)
984
957endmenu 985endmenu
958 986
959menu "CPU Frequency scaling" 987menu "CPU Frequency scaling"
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
index c61bdebb9974..c468624d55f0 100644
--- a/arch/blackfin/Kconfig.debug
+++ b/arch/blackfin/Kconfig.debug
@@ -154,13 +154,6 @@ config EARLY_PRINTK
154 all of this lives in the init section and is thrown away after the 154 all of this lives in the init section and is thrown away after the
155 kernel boots completely. 155 kernel boots completely.
156 156
157config DUAL_CORE_TEST_MODULE
158 tristate "Dual Core Test Module"
159 depends on (BF561)
160 default n
161 help
162 Say Y here to build-in dual core test module for dual core test.
163
164config CPLB_INFO 157config CPLB_INFO
165 bool "Display the CPLB information" 158 bool "Display the CPLB information"
166 help 159 help
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 3cbe16caad4b..9564731ad3a8 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -6,8 +6,9 @@
6# for more details. 6# for more details.
7# 7#
8 8
9 9ifeq ($(CROSS_COMPILE),)
10CROSS_COMPILE ?= bfin-uclinux- 10CROSS_COMPILE := bfin-uclinux-
11endif
11LDFLAGS_vmlinux := -X 12LDFLAGS_vmlinux := -X
12OBJCOPYFLAGS := -O binary -R .note -R .comment -S 13OBJCOPYFLAGS := -O binary -R .note -R .comment -S
13GZFLAGS := -9 14GZFLAGS := -9
diff --git a/arch/blackfin/configs/BF527-EZKIT_defconfig b/arch/blackfin/configs/BF527-EZKIT_defconfig
index 5e6fb9d8e50f..66854a83c0de 100644
--- a/arch/blackfin/configs/BF527-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT_defconfig
@@ -1,7 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24.7 3# Linux kernel version: 2.6.24.7
4# Fri May 16 10:02:29 2008
5# 4#
6# CONFIG_MMU is not set 5# CONFIG_MMU is not set
7# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -290,7 +289,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
290# CONFIG_RESOURCES_64BIT is not set 289# CONFIG_RESOURCES_64BIT is not set
291CONFIG_ZONE_DMA_FLAG=1 290CONFIG_ZONE_DMA_FLAG=1
292CONFIG_VIRT_TO_BUS=y 291CONFIG_VIRT_TO_BUS=y
293# CONFIG_BFIN_GPTIMERS is not set 292CONFIG_BFIN_GPTIMERS=y
294CONFIG_BFIN_DMA_5XX=y 293CONFIG_BFIN_DMA_5XX=y
295# CONFIG_DMA_UNCACHED_4M is not set 294# CONFIG_DMA_UNCACHED_4M is not set
296# CONFIG_DMA_UNCACHED_2M is not set 295# CONFIG_DMA_UNCACHED_2M is not set
@@ -430,7 +429,58 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
430# 429#
431# CONFIG_NET_PKTGEN is not set 430# CONFIG_NET_PKTGEN is not set
432# CONFIG_HAMRADIO is not set 431# CONFIG_HAMRADIO is not set
433# CONFIG_IRDA is not set 432CONFIG_IRDA=m
433
434#
435# IrDA protocols
436#
437CONFIG_IRLAN=m
438CONFIG_IRCOMM=m
439# CONFIG_IRDA_ULTRA is not set
440
441#
442# IrDA options
443#
444# CONFIG_IRDA_CACHE_LAST_LSAP is not set
445# CONFIG_IRDA_FAST_RR is not set
446# CONFIG_IRDA_DEBUG is not set
447
448#
449# Infrared-port device drivers
450#
451
452#
453# SIR device drivers
454#
455CONFIG_IRTTY_SIR=m
456CONFIG_BFIN_SIR=m
457CONFIG_BFIN_SIR0=y
458CONFIG_SIR_BFIN_DMA=y
459# CONFIG_SIR_BFIN_PIO is not set
460
461#
462# Dongle support
463#
464# CONFIG_DONGLE is not set
465# CONFIG_KINGSUN_DONGLE is not set
466# CONFIG_KSDAZZLE_DONGLE is not set
467# CONFIG_KS959_DONGLE is not set
468
469#
470# Old SIR device drivers
471#
472# CONFIG_IRPORT_SIR is not set
473
474#
475# Old Serial dongle support
476#
477
478#
479# FIR device drivers
480#
481# CONFIG_USB_IRDA is not set
482# CONFIG_SIGMATEL_FIR is not set
483# CONFIG_MCS_FIR is not set
434# CONFIG_BT is not set 484# CONFIG_BT is not set
435# CONFIG_AF_RXRPC is not set 485# CONFIG_AF_RXRPC is not set
436 486
@@ -689,8 +739,11 @@ CONFIG_BFIN_OTP=y
689# CONFIG_BFIN_SPORT is not set 739# CONFIG_BFIN_SPORT is not set
690# CONFIG_BFIN_TIMER_LATENCY is not set 740# CONFIG_BFIN_TIMER_LATENCY is not set
691# CONFIG_TWI_LCD is not set 741# CONFIG_TWI_LCD is not set
692# CONFIG_SIMPLE_GPIO is not set 742CONFIG_SIMPLE_GPIO=m
693# CONFIG_VT is not set 743CONFIG_VT=y
744CONFIG_VT_CONSOLE=y
745CONFIG_HW_CONSOLE=y
746# CONFIG_VT_HW_CONSOLE_BINDING is not set
694# CONFIG_SERIAL_NONSTANDARD is not set 747# CONFIG_SERIAL_NONSTANDARD is not set
695 748
696# 749#
@@ -872,8 +925,36 @@ CONFIG_SSB_POSSIBLE=y
872# 925#
873# CONFIG_VGASTATE is not set 926# CONFIG_VGASTATE is not set
874# CONFIG_VIDEO_OUTPUT_CONTROL is not set 927# CONFIG_VIDEO_OUTPUT_CONTROL is not set
875# CONFIG_FB is not set 928CONFIG_FB=y
876# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 929# CONFIG_FIRMWARE_EDID is not set
930# CONFIG_FB_DDC is not set
931CONFIG_FB_CFB_FILLRECT=y
932CONFIG_FB_CFB_COPYAREA=y
933CONFIG_FB_CFB_IMAGEBLIT=y
934# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
935# CONFIG_FB_SYS_FILLRECT is not set
936# CONFIG_FB_SYS_COPYAREA is not set
937# CONFIG_FB_SYS_IMAGEBLIT is not set
938# CONFIG_FB_SYS_FOPS is not set
939CONFIG_FB_DEFERRED_IO=y
940# CONFIG_FB_SVGALIB is not set
941# CONFIG_FB_MACMODES is not set
942# CONFIG_FB_BACKLIGHT is not set
943# CONFIG_FB_MODE_HELPERS is not set
944# CONFIG_FB_TILEBLITTING is not set
945
946#
947# Frame buffer hardware drivers
948#
949CONFIG_FB_BFIN_T350MCQB=y
950# CONFIG_FB_BFIN_7393 is not set
951# CONFIG_FB_S1D13XXX is not set
952# CONFIG_FB_VIRTUAL is not set
953CONFIG_BACKLIGHT_LCD_SUPPORT=y
954CONFIG_LCD_CLASS_DEVICE=m
955CONFIG_LCD_LTV350QV=m
956CONFIG_BACKLIGHT_CLASS_DEVICE=m
957# CONFIG_BACKLIGHT_CORGI is not set
877 958
878# 959#
879# Display device support 960# Display device support
@@ -881,9 +962,99 @@ CONFIG_SSB_POSSIBLE=y
881# CONFIG_DISPLAY_SUPPORT is not set 962# CONFIG_DISPLAY_SUPPORT is not set
882 963
883# 964#
965# Console display driver support
966#
967CONFIG_DUMMY_CONSOLE=y
968CONFIG_FRAMEBUFFER_CONSOLE=y
969# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
970# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
971# CONFIG_FONTS is not set
972CONFIG_FONT_8x8=y
973CONFIG_FONT_8x16=y
974CONFIG_LOGO=y
975# CONFIG_LOGO_LINUX_MONO is not set
976# CONFIG_LOGO_LINUX_VGA16 is not set
977# CONFIG_LOGO_LINUX_CLUT224 is not set
978# CONFIG_LOGO_BLACKFIN_VGA16 is not set
979CONFIG_LOGO_BLACKFIN_CLUT224=y
980
981#
884# Sound 982# Sound
885# 983#
886# CONFIG_SOUND is not set 984CONFIG_SOUND=m
985
986#
987# Advanced Linux Sound Architecture
988#
989CONFIG_SND=m
990CONFIG_SND_TIMER=m
991CONFIG_SND_PCM=m
992# CONFIG_SND_SEQUENCER is not set
993# CONFIG_SND_MIXER_OSS is not set
994# CONFIG_SND_PCM_OSS is not set
995# CONFIG_SND_DYNAMIC_MINORS is not set
996CONFIG_SND_SUPPORT_OLD_API=y
997CONFIG_SND_VERBOSE_PROCFS=y
998# CONFIG_SND_VERBOSE_PRINTK is not set
999# CONFIG_SND_DEBUG is not set
1000
1001#
1002# Generic devices
1003#
1004# CONFIG_SND_DUMMY is not set
1005# CONFIG_SND_MTPAV is not set
1006# CONFIG_SND_SERIAL_U16550 is not set
1007# CONFIG_SND_MPU401 is not set
1008
1009#
1010# SPI devices
1011#
1012
1013#
1014# ALSA Blackfin devices
1015#
1016# CONFIG_SND_BLACKFIN_AD1836 is not set
1017# CONFIG_SND_BLACKFIN_AD1836_TDM is not set
1018# CONFIG_SND_BLACKFIN_AD1836_I2S is not set
1019# CONFIG_SND_BLACKFIN_AD1836_MULSUB is not set
1020# CONFIG_SND_BLACKFIN_AD1836_5P1 is not set
1021# CONFIG_SND_BFIN_AD73311 is not set
1022# CONFIG_SND_BFIN_AD73322 is not set
1023
1024#
1025# USB devices
1026#
1027# CONFIG_SND_USB_AUDIO is not set
1028# CONFIG_SND_USB_CAIAQ is not set
1029
1030#
1031# System on Chip audio support
1032#
1033CONFIG_SND_SOC_AC97_BUS=y
1034CONFIG_SND_SOC=m
1035CONFIG_SND_BF5XX_SOC=m
1036CONFIG_SND_MMAP_SUPPORT=y
1037CONFIG_SND_BF5XX_SOC_I2S=m
1038CONFIG_SND_BF5XX_SOC_AC97=m
1039# CONFIG_SND_BF5XX_SOC_WM8750 is not set
1040# CONFIG_SND_BF5XX_SOC_WM8731 is not set
1041CONFIG_SND_BF5XX_SOC_SSM2602=m
1042CONFIG_SND_BF5XX_SOC_BF5xx=m
1043CONFIG_SND_BF5XX_SPORT_NUM=0
1044# CONFIG_SND_BF5XX_HAVE_COLD_RESET is not set
1045
1046#
1047# SoC Audio support for SuperH
1048#
1049CONFIG_SND_SOC_SSM2602=m
1050# CONFIG_SND_SOC_SSM2602_SPI is not set
1051CONFIG_SND_SOC_AD1980=m
1052
1053#
1054# Open Sound System
1055#
1056# CONFIG_SOUND_PRIME is not set
1057CONFIG_AC97_BUS=m
887CONFIG_HID_SUPPORT=y 1058CONFIG_HID_SUPPORT=y
888CONFIG_HID=y 1059CONFIG_HID=y
889# CONFIG_HID_DEBUG is not set 1060# CONFIG_HID_DEBUG is not set
diff --git a/arch/blackfin/configs/BF533-EZKIT_defconfig b/arch/blackfin/configs/BF533-EZKIT_defconfig
index 8d817ba01945..6bc11db12690 100644
--- a/arch/blackfin/configs/BF533-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF533-EZKIT_defconfig
@@ -1,6 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22.16 3# Linux kernel version: 2.6.24.7
4# 4#
5# CONFIG_MMU is not set 5# CONFIG_MMU is not set
6# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -13,35 +13,34 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
13CONFIG_GENERIC_HWEIGHT=y 13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_HARDIRQS=y 14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y 15CONFIG_GENERIC_IRQ_PROBE=y
16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_GPIO=y 16CONFIG_GENERIC_GPIO=y
18CONFIG_FORCE_MAX_ZONEORDER=14 17CONFIG_FORCE_MAX_ZONEORDER=14
19CONFIG_GENERIC_CALIBRATE_DELAY=y 18CONFIG_GENERIC_CALIBRATE_DELAY=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21 20
22# 21#
23# Code maturity level options 22# General setup
24# 23#
25CONFIG_EXPERIMENTAL=y 24CONFIG_EXPERIMENTAL=y
26CONFIG_BROKEN_ON_SMP=y 25CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32 26CONFIG_INIT_ENV_ARG_LIMIT=32
28
29#
30# General setup
31#
32CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
33CONFIG_LOCALVERSION_AUTO=y 28CONFIG_LOCALVERSION_AUTO=y
34CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
35# CONFIG_IPC_NS is not set
36CONFIG_SYSVIPC_SYSCTL=y 30CONFIG_SYSVIPC_SYSCTL=y
37# CONFIG_POSIX_MQUEUE is not set 31# CONFIG_POSIX_MQUEUE is not set
38# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
39# CONFIG_TASKSTATS is not set 33# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 34# CONFIG_USER_NS is not set
35# CONFIG_PID_NS is not set
41# CONFIG_AUDIT is not set 36# CONFIG_AUDIT is not set
42CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=14 39CONFIG_LOG_BUF_SHIFT=14
40# CONFIG_CGROUPS is not set
41CONFIG_FAIR_GROUP_SCHED=y
42CONFIG_FAIR_USER_SCHED=y
43# CONFIG_FAIR_CGROUP_SCHED is not set
45CONFIG_SYSFS_DEPRECATED=y 44CONFIG_SYSFS_DEPRECATED=y
46# CONFIG_RELAY is not set 45# CONFIG_RELAY is not set
47CONFIG_BLK_DEV_INITRD=y 46CONFIG_BLK_DEV_INITRD=y
@@ -64,32 +63,24 @@ CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y 63CONFIG_SIGNALFD=y
65CONFIG_EVENTFD=y 64CONFIG_EVENTFD=y
66CONFIG_VM_EVENT_COUNTERS=y 65CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
68# CONFIG_NP2 is not set
69CONFIG_SLAB=y 66CONFIG_SLAB=y
70# CONFIG_SLUB is not set 67# CONFIG_SLUB is not set
71# CONFIG_SLOB is not set 68# CONFIG_SLOB is not set
69CONFIG_SLABINFO=y
72CONFIG_RT_MUTEXES=y 70CONFIG_RT_MUTEXES=y
73CONFIG_TINY_SHMEM=y 71CONFIG_TINY_SHMEM=y
74CONFIG_BASE_SMALL=0 72CONFIG_BASE_SMALL=0
75
76#
77# Loadable module support
78#
79CONFIG_MODULES=y 73CONFIG_MODULES=y
80CONFIG_MODULE_UNLOAD=y 74CONFIG_MODULE_UNLOAD=y
81# CONFIG_MODULE_FORCE_UNLOAD is not set 75# CONFIG_MODULE_FORCE_UNLOAD is not set
82# CONFIG_MODVERSIONS is not set 76# CONFIG_MODVERSIONS is not set
83# CONFIG_MODULE_SRCVERSION_ALL is not set 77# CONFIG_MODULE_SRCVERSION_ALL is not set
84CONFIG_KMOD=y 78CONFIG_KMOD=y
85
86#
87# Block layer
88#
89CONFIG_BLOCK=y 79CONFIG_BLOCK=y
90# CONFIG_LBD is not set 80# CONFIG_LBD is not set
91# CONFIG_BLK_DEV_IO_TRACE is not set 81# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set 82# CONFIG_LSF is not set
83# CONFIG_BLK_DEV_BSG is not set
93 84
94# 85#
95# IO Schedulers 86# IO Schedulers
@@ -141,12 +132,12 @@ CONFIG_BF_REV_0_3=y
141# CONFIG_BF_REV_ANY is not set 132# CONFIG_BF_REV_ANY is not set
142# CONFIG_BF_REV_NONE is not set 133# CONFIG_BF_REV_NONE is not set
143CONFIG_BF53x=y 134CONFIG_BF53x=y
144CONFIG_BFIN_SINGLE_CORE=y
145CONFIG_MEM_MT48LC16M16A2TG_75=y 135CONFIG_MEM_MT48LC16M16A2TG_75=y
146CONFIG_BFIN533_EZKIT=y 136CONFIG_BFIN533_EZKIT=y
147# CONFIG_BFIN533_STAMP is not set 137# CONFIG_BFIN533_STAMP is not set
148# CONFIG_BFIN533_BLUETECHNIX_CM is not set 138# CONFIG_BFIN533_BLUETECHNIX_CM is not set
149# CONFIG_H8606_HVSISTEMAS is not set 139# CONFIG_H8606_HVSISTEMAS is not set
140# CONFIG_BFIN532_IP0X is not set
150# CONFIG_GENERIC_BF533_BOARD is not set 141# CONFIG_GENERIC_BF533_BOARD is not set
151 142
152# 143#
@@ -189,12 +180,14 @@ CONFIG_WDTIMER=13
189# Board customizations 180# Board customizations
190# 181#
191# CONFIG_CMDLINE_BOOL is not set 182# CONFIG_CMDLINE_BOOL is not set
183CONFIG_BOOT_LOAD=0x1000
192 184
193# 185#
194# Clock/PLL Setup 186# Clock/PLL Setup
195# 187#
196CONFIG_CLKIN_HZ=27000000 188CONFIG_CLKIN_HZ=27000000
197# CONFIG_BFIN_KERNEL_CLOCK is not set 189# CONFIG_BFIN_KERNEL_CLOCK is not set
190CONFIG_MAX_MEM_SIZE=512
198CONFIG_MAX_VCO_HZ=750000000 191CONFIG_MAX_VCO_HZ=750000000
199CONFIG_MIN_VCO_HZ=50000000 192CONFIG_MIN_VCO_HZ=50000000
200CONFIG_MAX_SCLK_HZ=133333333 193CONFIG_MAX_SCLK_HZ=133333333
@@ -208,13 +201,17 @@ CONFIG_HZ_250=y
208# CONFIG_HZ_300 is not set 201# CONFIG_HZ_300 is not set
209# CONFIG_HZ_1000 is not set 202# CONFIG_HZ_1000 is not set
210CONFIG_HZ=250 203CONFIG_HZ=250
204CONFIG_GENERIC_TIME=y
205CONFIG_GENERIC_CLOCKEVENTS=y
206# CONFIG_CYCLES_CLOCKSOURCE is not set
207CONFIG_TICK_ONESHOT=y
208# CONFIG_NO_HZ is not set
209CONFIG_HIGH_RES_TIMERS=y
210CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
211 211
212# 212#
213# Memory Setup 213# Misc
214# 214#
215CONFIG_MAX_MEM_SIZE=512
216CONFIG_MEM_ADD_WIDTH=9
217CONFIG_BOOT_LOAD=0x1000
218CONFIG_BFIN_SCRATCH_REG_RETN=y 215CONFIG_BFIN_SCRATCH_REG_RETN=y
219# CONFIG_BFIN_SCRATCH_REG_RETE is not set 216# CONFIG_BFIN_SCRATCH_REG_RETE is not set
220# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set 217# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -250,12 +247,14 @@ CONFIG_FLATMEM_MANUAL=y
250CONFIG_FLATMEM=y 247CONFIG_FLATMEM=y
251CONFIG_FLAT_NODE_MEM_MAP=y 248CONFIG_FLAT_NODE_MEM_MAP=y
252# CONFIG_SPARSEMEM_STATIC is not set 249# CONFIG_SPARSEMEM_STATIC is not set
250# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
253CONFIG_SPLIT_PTLOCK_CPUS=4 251CONFIG_SPLIT_PTLOCK_CPUS=4
254# CONFIG_RESOURCES_64BIT is not set 252# CONFIG_RESOURCES_64BIT is not set
255CONFIG_ZONE_DMA_FLAG=1 253CONFIG_ZONE_DMA_FLAG=1
256CONFIG_LARGE_ALLOCS=y 254CONFIG_VIRT_TO_BUS=y
257# CONFIG_BFIN_GPTIMERS is not set 255# CONFIG_BFIN_GPTIMERS is not set
258CONFIG_BFIN_DMA_5XX=y 256CONFIG_BFIN_DMA_5XX=y
257# CONFIG_DMA_UNCACHED_4M is not set
259# CONFIG_DMA_UNCACHED_2M is not set 258# CONFIG_DMA_UNCACHED_2M is not set
260CONFIG_DMA_UNCACHED_1M=y 259CONFIG_DMA_UNCACHED_1M=y
261# CONFIG_DMA_UNCACHED_NONE is not set 260# CONFIG_DMA_UNCACHED_NONE is not set
@@ -293,17 +292,13 @@ CONFIG_C_AMBEN_ALL=y
293CONFIG_BANK_0=0x7BB0 292CONFIG_BANK_0=0x7BB0
294CONFIG_BANK_1=0x7BB0 293CONFIG_BANK_1=0x7BB0
295CONFIG_BANK_2=0x7BB0 294CONFIG_BANK_2=0x7BB0
296CONFIG_BANK_3=0xAAC3 295CONFIG_BANK_3=0xAAC2
297 296
298# 297#
299# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 298# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
300# 299#
301# CONFIG_PCI is not set 300# CONFIG_PCI is not set
302# CONFIG_ARCH_SUPPORTS_MSI is not set 301# CONFIG_ARCH_SUPPORTS_MSI is not set
303
304#
305# PCCARD (PCMCIA/CardBus) support
306#
307# CONFIG_PCCARD is not set 302# CONFIG_PCCARD is not set
308 303
309# 304#
@@ -321,7 +316,9 @@ CONFIG_BINFMT_ZFLAT=y
321CONFIG_PM=y 316CONFIG_PM=y
322# CONFIG_PM_LEGACY is not set 317# CONFIG_PM_LEGACY is not set
323# CONFIG_PM_DEBUG is not set 318# CONFIG_PM_DEBUG is not set
324# CONFIG_PM_SYSFS_DEPRECATED is not set 319CONFIG_PM_SLEEP=y
320CONFIG_SUSPEND_UP_POSSIBLE=y
321CONFIG_SUSPEND=y
325CONFIG_PM_BFIN_SLEEP_DEEPER=y 322CONFIG_PM_BFIN_SLEEP_DEEPER=y
326# CONFIG_PM_BFIN_SLEEP is not set 323# CONFIG_PM_BFIN_SLEEP is not set
327# CONFIG_PM_WAKEUP_BY_GPIO is not set 324# CONFIG_PM_WAKEUP_BY_GPIO is not set
@@ -367,6 +364,7 @@ CONFIG_SYN_COOKIES=y
367CONFIG_INET_XFRM_MODE_TRANSPORT=y 364CONFIG_INET_XFRM_MODE_TRANSPORT=y
368CONFIG_INET_XFRM_MODE_TUNNEL=y 365CONFIG_INET_XFRM_MODE_TUNNEL=y
369CONFIG_INET_XFRM_MODE_BEET=y 366CONFIG_INET_XFRM_MODE_BEET=y
367# CONFIG_INET_LRO is not set
370CONFIG_INET_DIAG=y 368CONFIG_INET_DIAG=y
371CONFIG_INET_TCP_DIAG=y 369CONFIG_INET_TCP_DIAG=y
372# CONFIG_TCP_CONG_ADVANCED is not set 370# CONFIG_TCP_CONG_ADVANCED is not set
@@ -393,10 +391,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
393# CONFIG_LAPB is not set 391# CONFIG_LAPB is not set
394# CONFIG_ECONET is not set 392# CONFIG_ECONET is not set
395# CONFIG_WAN_ROUTER is not set 393# CONFIG_WAN_ROUTER is not set
396
397#
398# QoS and/or fair queueing
399#
400# CONFIG_NET_SCHED is not set 394# CONFIG_NET_SCHED is not set
401 395
402# 396#
@@ -428,6 +422,7 @@ CONFIG_IRDA_CACHE_LAST_LSAP=y
428# SIR device drivers 422# SIR device drivers
429# 423#
430CONFIG_IRTTY_SIR=m 424CONFIG_IRTTY_SIR=m
425# CONFIG_BFIN_SIR is not set
431 426
432# 427#
433# Dongle support 428# Dongle support
@@ -457,6 +452,7 @@ CONFIG_IRTTY_SIR=m
457# CONFIG_MAC80211 is not set 452# CONFIG_MAC80211 is not set
458# CONFIG_IEEE80211 is not set 453# CONFIG_IEEE80211 is not set
459# CONFIG_RFKILL is not set 454# CONFIG_RFKILL is not set
455# CONFIG_NET_9P is not set
460 456
461# 457#
462# Device Drivers 458# Device Drivers
@@ -465,14 +461,11 @@ CONFIG_IRTTY_SIR=m
465# 461#
466# Generic Driver Options 462# Generic Driver Options
467# 463#
464CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
468CONFIG_STANDALONE=y 465CONFIG_STANDALONE=y
469CONFIG_PREVENT_FIRMWARE_BUILD=y 466CONFIG_PREVENT_FIRMWARE_BUILD=y
470# CONFIG_FW_LOADER is not set 467# CONFIG_FW_LOADER is not set
471# CONFIG_SYS_HYPERVISOR is not set 468# CONFIG_SYS_HYPERVISOR is not set
472
473#
474# Connector - unified userspace <-> kernelspace linker
475#
476# CONFIG_CONNECTOR is not set 469# CONFIG_CONNECTOR is not set
477CONFIG_MTD=y 470CONFIG_MTD=y
478# CONFIG_MTD_DEBUG is not set 471# CONFIG_MTD_DEBUG is not set
@@ -492,6 +485,7 @@ CONFIG_MTD_BLOCK=y
492# CONFIG_INFTL is not set 485# CONFIG_INFTL is not set
493# CONFIG_RFD_FTL is not set 486# CONFIG_RFD_FTL is not set
494# CONFIG_SSFDC is not set 487# CONFIG_SSFDC is not set
488# CONFIG_MTD_OOPS is not set
495 489
496# 490#
497# RAM/ROM/Flash chip drivers 491# RAM/ROM/Flash chip drivers
@@ -548,20 +542,8 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y
548# UBI - Unsorted block images 542# UBI - Unsorted block images
549# 543#
550# CONFIG_MTD_UBI is not set 544# CONFIG_MTD_UBI is not set
551
552#
553# Parallel port support
554#
555# CONFIG_PARPORT is not set 545# CONFIG_PARPORT is not set
556 546CONFIG_BLK_DEV=y
557#
558# Plug and Play support
559#
560# CONFIG_PNPACPI is not set
561
562#
563# Block devices
564#
565# CONFIG_BLK_DEV_COW_COMMON is not set 547# CONFIG_BLK_DEV_COW_COMMON is not set
566# CONFIG_BLK_DEV_LOOP is not set 548# CONFIG_BLK_DEV_LOOP is not set
567# CONFIG_BLK_DEV_NBD is not set 549# CONFIG_BLK_DEV_NBD is not set
@@ -571,10 +553,8 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
571CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 553CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
572# CONFIG_CDROM_PKTCDVD is not set 554# CONFIG_CDROM_PKTCDVD is not set
573# CONFIG_ATA_OVER_ETH is not set 555# CONFIG_ATA_OVER_ETH is not set
574 556CONFIG_MISC_DEVICES=y
575# 557# CONFIG_EEPROM_93CX6 is not set
576# Misc devices
577#
578# CONFIG_IDE is not set 558# CONFIG_IDE is not set
579 559
580# 560#
@@ -582,32 +562,29 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
582# 562#
583# CONFIG_RAID_ATTRS is not set 563# CONFIG_RAID_ATTRS is not set
584# CONFIG_SCSI is not set 564# CONFIG_SCSI is not set
565# CONFIG_SCSI_DMA is not set
585# CONFIG_SCSI_NETLINK is not set 566# CONFIG_SCSI_NETLINK is not set
586# CONFIG_ATA is not set 567# CONFIG_ATA is not set
587
588#
589# Multi-device support (RAID and LVM)
590#
591# CONFIG_MD is not set 568# CONFIG_MD is not set
592
593#
594# Network device support
595#
596CONFIG_NETDEVICES=y 569CONFIG_NETDEVICES=y
570# CONFIG_NETDEVICES_MULTIQUEUE is not set
597# CONFIG_DUMMY is not set 571# CONFIG_DUMMY is not set
598# CONFIG_BONDING is not set 572# CONFIG_BONDING is not set
573# CONFIG_MACVLAN is not set
599# CONFIG_EQUALIZER is not set 574# CONFIG_EQUALIZER is not set
600# CONFIG_TUN is not set 575# CONFIG_TUN is not set
576# CONFIG_VETH is not set
601# CONFIG_PHYLIB is not set 577# CONFIG_PHYLIB is not set
602
603#
604# Ethernet (10 or 100Mbit)
605#
606CONFIG_NET_ETHERNET=y 578CONFIG_NET_ETHERNET=y
607CONFIG_MII=y 579CONFIG_MII=y
608CONFIG_SMC91X=y 580CONFIG_SMC91X=y
609# CONFIG_SMSC911X is not set 581# CONFIG_SMSC911X is not set
610# CONFIG_DM9000 is not set 582# CONFIG_DM9000 is not set
583# CONFIG_IBM_NEW_EMAC_ZMII is not set
584# CONFIG_IBM_NEW_EMAC_RGMII is not set
585# CONFIG_IBM_NEW_EMAC_TAH is not set
586# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
587# CONFIG_B44 is not set
611CONFIG_NETDEV_1000=y 588CONFIG_NETDEV_1000=y
612# CONFIG_AX88180 is not set 589# CONFIG_AX88180 is not set
613CONFIG_NETDEV_10000=y 590CONFIG_NETDEV_10000=y
@@ -624,15 +601,7 @@ CONFIG_NETDEV_10000=y
624# CONFIG_NETCONSOLE is not set 601# CONFIG_NETCONSOLE is not set
625# CONFIG_NETPOLL is not set 602# CONFIG_NETPOLL is not set
626# CONFIG_NET_POLL_CONTROLLER is not set 603# CONFIG_NET_POLL_CONTROLLER is not set
627
628#
629# ISDN subsystem
630#
631# CONFIG_ISDN is not set 604# CONFIG_ISDN is not set
632
633#
634# Telephony Support
635#
636# CONFIG_PHONE is not set 605# CONFIG_PHONE is not set
637 606
638# 607#
@@ -647,7 +616,6 @@ CONFIG_INPUT=m
647# 616#
648# CONFIG_INPUT_MOUSEDEV is not set 617# CONFIG_INPUT_MOUSEDEV is not set
649# CONFIG_INPUT_JOYDEV is not set 618# CONFIG_INPUT_JOYDEV is not set
650# CONFIG_INPUT_TSDEV is not set
651CONFIG_INPUT_EVDEV=m 619CONFIG_INPUT_EVDEV=m
652# CONFIG_INPUT_EVBUG is not set 620# CONFIG_INPUT_EVBUG is not set
653 621
@@ -672,13 +640,12 @@ CONFIG_INPUT_EVDEV=m
672# 640#
673# CONFIG_AD9960 is not set 641# CONFIG_AD9960 is not set
674# CONFIG_SPI_ADC_BF533 is not set 642# CONFIG_SPI_ADC_BF533 is not set
675# CONFIG_BF5xx_PFLAGS is not set
676# CONFIG_BF5xx_PPIFCD is not set 643# CONFIG_BF5xx_PPIFCD is not set
677# CONFIG_BFIN_SIMPLE_TIMER is not set 644# CONFIG_BFIN_SIMPLE_TIMER is not set
678# CONFIG_BF5xx_PPI is not set 645# CONFIG_BF5xx_PPI is not set
679CONFIG_BFIN_SPORT=y 646CONFIG_BFIN_SPORT=y
680# CONFIG_BFIN_TIMER_LATENCY is not set 647# CONFIG_BFIN_TIMER_LATENCY is not set
681# CONFIG_AD5304 is not set 648CONFIG_SIMPLE_GPIO=m
682# CONFIG_VT is not set 649# CONFIG_VT is not set
683# CONFIG_SERIAL_NONSTANDARD is not set 650# CONFIG_SERIAL_NONSTANDARD is not set
684 651
@@ -706,28 +673,11 @@ CONFIG_UNIX98_PTYS=y
706# CAN, the car bus and industrial fieldbus 673# CAN, the car bus and industrial fieldbus
707# 674#
708# CONFIG_CAN4LINUX is not set 675# CONFIG_CAN4LINUX is not set
709
710#
711# IPMI
712#
713# CONFIG_IPMI_HANDLER is not set 676# CONFIG_IPMI_HANDLER is not set
714CONFIG_WATCHDOG=y
715# CONFIG_WATCHDOG_NOWAYOUT is not set
716
717#
718# Watchdog Device Drivers
719#
720# CONFIG_SOFT_WATCHDOG is not set
721CONFIG_BFIN_WDT=y
722CONFIG_HW_RANDOM=y 677CONFIG_HW_RANDOM=y
723# CONFIG_GEN_RTC is not set 678# CONFIG_GEN_RTC is not set
724CONFIG_BLACKFIN_DPMC=y
725# CONFIG_R3964 is not set 679# CONFIG_R3964 is not set
726# CONFIG_RAW_DRIVER is not set 680# CONFIG_RAW_DRIVER is not set
727
728#
729# TPM devices
730#
731# CONFIG_TCG_TPM is not set 681# CONFIG_TCG_TPM is not set
732# CONFIG_I2C is not set 682# CONFIG_I2C is not set
733 683
@@ -748,22 +698,37 @@ CONFIG_SPI_BFIN=y
748# 698#
749# CONFIG_SPI_AT25 is not set 699# CONFIG_SPI_AT25 is not set
750# CONFIG_SPI_SPIDEV is not set 700# CONFIG_SPI_SPIDEV is not set
751 701# CONFIG_SPI_TLE62X0 is not set
752#
753# Dallas's 1-wire bus
754#
755# CONFIG_W1 is not set 702# CONFIG_W1 is not set
703# CONFIG_POWER_SUPPLY is not set
756CONFIG_HWMON=y 704CONFIG_HWMON=y
757# CONFIG_HWMON_VID is not set 705# CONFIG_HWMON_VID is not set
758# CONFIG_SENSORS_ABITUGURU is not set
759# CONFIG_SENSORS_F71805F is not set 706# CONFIG_SENSORS_F71805F is not set
707# CONFIG_SENSORS_F71882FG is not set
708# CONFIG_SENSORS_IT87 is not set
760# CONFIG_SENSORS_LM70 is not set 709# CONFIG_SENSORS_LM70 is not set
710# CONFIG_SENSORS_PC87360 is not set
761# CONFIG_SENSORS_PC87427 is not set 711# CONFIG_SENSORS_PC87427 is not set
762# CONFIG_SENSORS_SMSC47M1 is not set 712# CONFIG_SENSORS_SMSC47M1 is not set
763# CONFIG_SENSORS_SMSC47B397 is not set 713# CONFIG_SENSORS_SMSC47B397 is not set
764# CONFIG_SENSORS_VT1211 is not set 714# CONFIG_SENSORS_VT1211 is not set
765# CONFIG_SENSORS_W83627HF is not set 715# CONFIG_SENSORS_W83627HF is not set
716# CONFIG_SENSORS_W83627EHF is not set
766# CONFIG_HWMON_DEBUG_CHIP is not set 717# CONFIG_HWMON_DEBUG_CHIP is not set
718CONFIG_WATCHDOG=y
719# CONFIG_WATCHDOG_NOWAYOUT is not set
720
721#
722# Watchdog Device Drivers
723#
724# CONFIG_SOFT_WATCHDOG is not set
725CONFIG_BFIN_WDT=y
726
727#
728# Sonics Silicon Backplane
729#
730CONFIG_SSB_POSSIBLE=y
731# CONFIG_SSB is not set
767 732
768# 733#
769# Multifunction device drivers 734# Multifunction device drivers
@@ -780,72 +745,27 @@ CONFIG_DAB=y
780# 745#
781# Graphics support 746# Graphics support
782# 747#
748# CONFIG_VGASTATE is not set
749# CONFIG_VIDEO_OUTPUT_CONTROL is not set
750# CONFIG_FB is not set
783# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 751# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
784 752
785# 753#
786# Display device support 754# Display device support
787# 755#
788# CONFIG_DISPLAY_SUPPORT is not set 756# CONFIG_DISPLAY_SUPPORT is not set
789# CONFIG_VGASTATE is not set
790# CONFIG_FB is not set
791 757
792# 758#
793# Sound 759# Sound
794# 760#
795# CONFIG_SOUND is not set 761# CONFIG_SOUND is not set
796 762CONFIG_HID_SUPPORT=y
797#
798# HID Devices
799#
800CONFIG_HID=m 763CONFIG_HID=m
801# CONFIG_HID_DEBUG is not set 764# CONFIG_HID_DEBUG is not set
802 765# CONFIG_HIDRAW is not set
803# 766# CONFIG_USB_SUPPORT is not set
804# USB support
805#
806CONFIG_USB_ARCH_HAS_HCD=y
807# CONFIG_USB_ARCH_HAS_OHCI is not set
808# CONFIG_USB_ARCH_HAS_EHCI is not set
809# CONFIG_USB is not set
810
811#
812# Enable Host or Gadget support to see Inventra options
813#
814
815#
816# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
817#
818
819#
820# USB Gadget Support
821#
822# CONFIG_USB_GADGET is not set
823# CONFIG_MMC is not set 767# CONFIG_MMC is not set
824
825#
826# LED devices
827#
828# CONFIG_NEW_LEDS is not set 768# CONFIG_NEW_LEDS is not set
829
830#
831# LED drivers
832#
833
834#
835# LED Triggers
836#
837
838#
839# InfiniBand support
840#
841
842#
843# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
844#
845
846#
847# Real Time Clock
848#
849CONFIG_RTC_LIB=y 769CONFIG_RTC_LIB=y
850CONFIG_RTC_CLASS=y 770CONFIG_RTC_CLASS=y
851CONFIG_RTC_HCTOSYS=y 771CONFIG_RTC_HCTOSYS=y
@@ -862,10 +782,6 @@ CONFIG_RTC_INTF_DEV=y
862# CONFIG_RTC_DRV_TEST is not set 782# CONFIG_RTC_DRV_TEST is not set
863 783
864# 784#
865# I2C RTC drivers
866#
867
868#
869# SPI RTC drivers 785# SPI RTC drivers
870# 786#
871# CONFIG_RTC_DRV_RS5C348 is not set 787# CONFIG_RTC_DRV_RS5C348 is not set
@@ -875,8 +791,10 @@ CONFIG_RTC_INTF_DEV=y
875# Platform RTC drivers 791# Platform RTC drivers
876# 792#
877# CONFIG_RTC_DRV_DS1553 is not set 793# CONFIG_RTC_DRV_DS1553 is not set
794# CONFIG_RTC_DRV_STK17TA8 is not set
878# CONFIG_RTC_DRV_DS1742 is not set 795# CONFIG_RTC_DRV_DS1742 is not set
879# CONFIG_RTC_DRV_M48T86 is not set 796# CONFIG_RTC_DRV_M48T86 is not set
797# CONFIG_RTC_DRV_M48T59 is not set
880# CONFIG_RTC_DRV_V3020 is not set 798# CONFIG_RTC_DRV_V3020 is not set
881 799
882# 800#
@@ -885,22 +803,9 @@ CONFIG_RTC_INTF_DEV=y
885CONFIG_RTC_DRV_BFIN=y 803CONFIG_RTC_DRV_BFIN=y
886 804
887# 805#
888# DMA Engine support 806# Userspace I/O
889#
890# CONFIG_DMA_ENGINE is not set
891
892#
893# DMA Clients
894#
895
896#
897# DMA Devices
898# 807#
899 808# CONFIG_UIO is not set
900#
901# PBX support
902#
903# CONFIG_PBX is not set
904 809
905# 810#
906# File systems 811# File systems
@@ -945,7 +850,6 @@ CONFIG_PROC_SYSCTL=y
945CONFIG_SYSFS=y 850CONFIG_SYSFS=y
946# CONFIG_TMPFS is not set 851# CONFIG_TMPFS is not set
947# CONFIG_HUGETLB_PAGE is not set 852# CONFIG_HUGETLB_PAGE is not set
948CONFIG_RAMFS=y
949# CONFIG_CONFIGFS_FS is not set 853# CONFIG_CONFIGFS_FS is not set
950 854
951# 855#
@@ -971,10 +875,12 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
971CONFIG_JFFS2_FS=m 875CONFIG_JFFS2_FS=m
972CONFIG_JFFS2_FS_DEBUG=0 876CONFIG_JFFS2_FS_DEBUG=0
973CONFIG_JFFS2_FS_WRITEBUFFER=y 877CONFIG_JFFS2_FS_WRITEBUFFER=y
878# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
974# CONFIG_JFFS2_SUMMARY is not set 879# CONFIG_JFFS2_SUMMARY is not set
975# CONFIG_JFFS2_FS_XATTR is not set 880# CONFIG_JFFS2_FS_XATTR is not set
976# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 881# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
977CONFIG_JFFS2_ZLIB=y 882CONFIG_JFFS2_ZLIB=y
883# CONFIG_JFFS2_LZO is not set
978CONFIG_JFFS2_RTIME=y 884CONFIG_JFFS2_RTIME=y
979# CONFIG_JFFS2_RUBIN is not set 885# CONFIG_JFFS2_RUBIN is not set
980# CONFIG_CRAMFS is not set 886# CONFIG_CRAMFS is not set
@@ -983,10 +889,7 @@ CONFIG_JFFS2_RTIME=y
983# CONFIG_QNX4FS_FS is not set 889# CONFIG_QNX4FS_FS is not set
984# CONFIG_SYSV_FS is not set 890# CONFIG_SYSV_FS is not set
985# CONFIG_UFS_FS is not set 891# CONFIG_UFS_FS is not set
986 892CONFIG_NETWORK_FILESYSTEMS=y
987#
988# Network File Systems
989#
990CONFIG_NFS_FS=m 893CONFIG_NFS_FS=m
991CONFIG_NFS_V3=y 894CONFIG_NFS_V3=y
992# CONFIG_NFS_V3_ACL is not set 895# CONFIG_NFS_V3_ACL is not set
@@ -1006,17 +909,12 @@ CONFIG_SMB_FS=m
1006# CONFIG_NCP_FS is not set 909# CONFIG_NCP_FS is not set
1007# CONFIG_CODA_FS is not set 910# CONFIG_CODA_FS is not set
1008# CONFIG_AFS_FS is not set 911# CONFIG_AFS_FS is not set
1009# CONFIG_9P_FS is not set
1010 912
1011# 913#
1012# Partition Types 914# Partition Types
1013# 915#
1014# CONFIG_PARTITION_ADVANCED is not set 916# CONFIG_PARTITION_ADVANCED is not set
1015CONFIG_MSDOS_PARTITION=y 917CONFIG_MSDOS_PARTITION=y
1016
1017#
1018# Native Language Support
1019#
1020CONFIG_NLS=m 918CONFIG_NLS=m
1021CONFIG_NLS_DEFAULT="iso8859-1" 919CONFIG_NLS_DEFAULT="iso8859-1"
1022# CONFIG_NLS_CODEPAGE_437 is not set 920# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1057,21 +955,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1057# CONFIG_NLS_KOI8_R is not set 955# CONFIG_NLS_KOI8_R is not set
1058# CONFIG_NLS_KOI8_U is not set 956# CONFIG_NLS_KOI8_U is not set
1059# CONFIG_NLS_UTF8 is not set 957# CONFIG_NLS_UTF8 is not set
1060
1061#
1062# Distributed Lock Manager
1063#
1064# CONFIG_DLM is not set 958# CONFIG_DLM is not set
1065 959CONFIG_INSTRUMENTATION=y
1066#
1067# Profiling support
1068#
1069# CONFIG_PROFILING is not set 960# CONFIG_PROFILING is not set
961# CONFIG_MARKERS is not set
1070 962
1071# 963#
1072# Kernel hacking 964# Kernel hacking
1073# 965#
1074# CONFIG_PRINTK_TIME is not set 966# CONFIG_PRINTK_TIME is not set
967CONFIG_ENABLE_WARN_DEPRECATED=y
1075CONFIG_ENABLE_MUST_CHECK=y 968CONFIG_ENABLE_MUST_CHECK=y
1076# CONFIG_MAGIC_SYSRQ is not set 969# CONFIG_MAGIC_SYSRQ is not set
1077# CONFIG_UNUSED_SYMBOLS is not set 970# CONFIG_UNUSED_SYMBOLS is not set
@@ -1079,6 +972,7 @@ CONFIG_DEBUG_FS=y
1079# CONFIG_HEADERS_CHECK is not set 972# CONFIG_HEADERS_CHECK is not set
1080# CONFIG_DEBUG_KERNEL is not set 973# CONFIG_DEBUG_KERNEL is not set
1081# CONFIG_DEBUG_BUGVERBOSE is not set 974# CONFIG_DEBUG_BUGVERBOSE is not set
975# CONFIG_SAMPLES is not set
1082CONFIG_DEBUG_MMRS=y 976CONFIG_DEBUG_MMRS=y
1083CONFIG_DEBUG_HUNT_FOR_ZERO=y 977CONFIG_DEBUG_HUNT_FOR_ZERO=y
1084CONFIG_DEBUG_BFIN_HWTRACE_ON=y 978CONFIG_DEBUG_BFIN_HWTRACE_ON=y
@@ -1098,11 +992,7 @@ CONFIG_ACCESS_CHECK=y
1098# CONFIG_KEYS is not set 992# CONFIG_KEYS is not set
1099CONFIG_SECURITY=y 993CONFIG_SECURITY=y
1100# CONFIG_SECURITY_NETWORK is not set 994# CONFIG_SECURITY_NETWORK is not set
1101CONFIG_SECURITY_CAPABILITIES=m 995# CONFIG_SECURITY_CAPABILITIES is not set
1102
1103#
1104# Cryptographic options
1105#
1106# CONFIG_CRYPTO is not set 996# CONFIG_CRYPTO is not set
1107 997
1108# 998#
@@ -1113,6 +1003,7 @@ CONFIG_CRC_CCITT=m
1113# CONFIG_CRC16 is not set 1003# CONFIG_CRC16 is not set
1114# CONFIG_CRC_ITU_T is not set 1004# CONFIG_CRC_ITU_T is not set
1115CONFIG_CRC32=y 1005CONFIG_CRC32=y
1006# CONFIG_CRC7 is not set
1116# CONFIG_LIBCRC32C is not set 1007# CONFIG_LIBCRC32C is not set
1117CONFIG_ZLIB_INFLATE=y 1008CONFIG_ZLIB_INFLATE=y
1118CONFIG_ZLIB_DEFLATE=m 1009CONFIG_ZLIB_DEFLATE=m
diff --git a/arch/blackfin/configs/BF533-STAMP_defconfig b/arch/blackfin/configs/BF533-STAMP_defconfig
index 20d598d17bd1..d77d991a1f61 100644
--- a/arch/blackfin/configs/BF533-STAMP_defconfig
+++ b/arch/blackfin/configs/BF533-STAMP_defconfig
@@ -1,6 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22.16 3# Linux kernel version: 2.6.24.7
4# 4#
5# CONFIG_MMU is not set 5# CONFIG_MMU is not set
6# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -13,35 +13,34 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
13CONFIG_GENERIC_HWEIGHT=y 13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_HARDIRQS=y 14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y 15CONFIG_GENERIC_IRQ_PROBE=y
16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_GPIO=y 16CONFIG_GENERIC_GPIO=y
18CONFIG_FORCE_MAX_ZONEORDER=14 17CONFIG_FORCE_MAX_ZONEORDER=14
19CONFIG_GENERIC_CALIBRATE_DELAY=y 18CONFIG_GENERIC_CALIBRATE_DELAY=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21 20
22# 21#
23# Code maturity level options 22# General setup
24# 23#
25CONFIG_EXPERIMENTAL=y 24CONFIG_EXPERIMENTAL=y
26CONFIG_BROKEN_ON_SMP=y 25CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32 26CONFIG_INIT_ENV_ARG_LIMIT=32
28
29#
30# General setup
31#
32CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
33CONFIG_LOCALVERSION_AUTO=y 28CONFIG_LOCALVERSION_AUTO=y
34CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
35# CONFIG_IPC_NS is not set
36CONFIG_SYSVIPC_SYSCTL=y 30CONFIG_SYSVIPC_SYSCTL=y
37# CONFIG_POSIX_MQUEUE is not set 31# CONFIG_POSIX_MQUEUE is not set
38# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
39# CONFIG_TASKSTATS is not set 33# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 34# CONFIG_USER_NS is not set
35# CONFIG_PID_NS is not set
41# CONFIG_AUDIT is not set 36# CONFIG_AUDIT is not set
42CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=14 39CONFIG_LOG_BUF_SHIFT=14
40# CONFIG_CGROUPS is not set
41CONFIG_FAIR_GROUP_SCHED=y
42CONFIG_FAIR_USER_SCHED=y
43# CONFIG_FAIR_CGROUP_SCHED is not set
45CONFIG_SYSFS_DEPRECATED=y 44CONFIG_SYSFS_DEPRECATED=y
46# CONFIG_RELAY is not set 45# CONFIG_RELAY is not set
47CONFIG_BLK_DEV_INITRD=y 46CONFIG_BLK_DEV_INITRD=y
@@ -64,32 +63,24 @@ CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y 63CONFIG_SIGNALFD=y
65CONFIG_EVENTFD=y 64CONFIG_EVENTFD=y
66CONFIG_VM_EVENT_COUNTERS=y 65CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
68# CONFIG_NP2 is not set
69CONFIG_SLAB=y 66CONFIG_SLAB=y
70# CONFIG_SLUB is not set 67# CONFIG_SLUB is not set
71# CONFIG_SLOB is not set 68# CONFIG_SLOB is not set
69CONFIG_SLABINFO=y
72CONFIG_RT_MUTEXES=y 70CONFIG_RT_MUTEXES=y
73CONFIG_TINY_SHMEM=y 71CONFIG_TINY_SHMEM=y
74CONFIG_BASE_SMALL=0 72CONFIG_BASE_SMALL=0
75
76#
77# Loadable module support
78#
79CONFIG_MODULES=y 73CONFIG_MODULES=y
80CONFIG_MODULE_UNLOAD=y 74CONFIG_MODULE_UNLOAD=y
81# CONFIG_MODULE_FORCE_UNLOAD is not set 75# CONFIG_MODULE_FORCE_UNLOAD is not set
82# CONFIG_MODVERSIONS is not set 76# CONFIG_MODVERSIONS is not set
83# CONFIG_MODULE_SRCVERSION_ALL is not set 77# CONFIG_MODULE_SRCVERSION_ALL is not set
84CONFIG_KMOD=y 78CONFIG_KMOD=y
85
86#
87# Block layer
88#
89CONFIG_BLOCK=y 79CONFIG_BLOCK=y
90# CONFIG_LBD is not set 80# CONFIG_LBD is not set
91# CONFIG_BLK_DEV_IO_TRACE is not set 81# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set 82# CONFIG_LSF is not set
83# CONFIG_BLK_DEV_BSG is not set
93 84
94# 85#
95# IO Schedulers 86# IO Schedulers
@@ -141,12 +132,12 @@ CONFIG_BF_REV_0_3=y
141# CONFIG_BF_REV_ANY is not set 132# CONFIG_BF_REV_ANY is not set
142# CONFIG_BF_REV_NONE is not set 133# CONFIG_BF_REV_NONE is not set
143CONFIG_BF53x=y 134CONFIG_BF53x=y
144CONFIG_BFIN_SINGLE_CORE=y
145CONFIG_MEM_MT48LC64M4A2FB_7E=y 135CONFIG_MEM_MT48LC64M4A2FB_7E=y
146# CONFIG_BFIN533_EZKIT is not set 136# CONFIG_BFIN533_EZKIT is not set
147CONFIG_BFIN533_STAMP=y 137CONFIG_BFIN533_STAMP=y
148# CONFIG_BFIN533_BLUETECHNIX_CM is not set 138# CONFIG_BFIN533_BLUETECHNIX_CM is not set
149# CONFIG_H8606_HVSISTEMAS is not set 139# CONFIG_H8606_HVSISTEMAS is not set
140# CONFIG_BFIN532_IP0X is not set
150# CONFIG_GENERIC_BF533_BOARD is not set 141# CONFIG_GENERIC_BF533_BOARD is not set
151 142
152# 143#
@@ -189,12 +180,14 @@ CONFIG_WDTIMER=13
189# Board customizations 180# Board customizations
190# 181#
191# CONFIG_CMDLINE_BOOL is not set 182# CONFIG_CMDLINE_BOOL is not set
183CONFIG_BOOT_LOAD=0x1000
192 184
193# 185#
194# Clock/PLL Setup 186# Clock/PLL Setup
195# 187#
196CONFIG_CLKIN_HZ=11059200 188CONFIG_CLKIN_HZ=11059200
197# CONFIG_BFIN_KERNEL_CLOCK is not set 189# CONFIG_BFIN_KERNEL_CLOCK is not set
190CONFIG_MAX_MEM_SIZE=512
198CONFIG_MAX_VCO_HZ=750000000 191CONFIG_MAX_VCO_HZ=750000000
199CONFIG_MIN_VCO_HZ=50000000 192CONFIG_MIN_VCO_HZ=50000000
200CONFIG_MAX_SCLK_HZ=133333333 193CONFIG_MAX_SCLK_HZ=133333333
@@ -208,14 +201,17 @@ CONFIG_HZ_250=y
208# CONFIG_HZ_300 is not set 201# CONFIG_HZ_300 is not set
209# CONFIG_HZ_1000 is not set 202# CONFIG_HZ_1000 is not set
210CONFIG_HZ=250 203CONFIG_HZ=250
204CONFIG_GENERIC_TIME=y
205CONFIG_GENERIC_CLOCKEVENTS=y
206# CONFIG_CYCLES_CLOCKSOURCE is not set
207CONFIG_TICK_ONESHOT=y
208# CONFIG_NO_HZ is not set
209CONFIG_HIGH_RES_TIMERS=y
210CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
211 211
212# 212#
213# Memory Setup 213# Misc
214# 214#
215CONFIG_MAX_MEM_SIZE=512
216CONFIG_MEM_ADD_WIDTH=11
217CONFIG_ENET_FLASH_PIN=0
218CONFIG_BOOT_LOAD=0x1000
219CONFIG_BFIN_SCRATCH_REG_RETN=y 215CONFIG_BFIN_SCRATCH_REG_RETN=y
220# CONFIG_BFIN_SCRATCH_REG_RETE is not set 216# CONFIG_BFIN_SCRATCH_REG_RETE is not set
221# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set 217# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -251,12 +247,14 @@ CONFIG_FLATMEM_MANUAL=y
251CONFIG_FLATMEM=y 247CONFIG_FLATMEM=y
252CONFIG_FLAT_NODE_MEM_MAP=y 248CONFIG_FLAT_NODE_MEM_MAP=y
253# CONFIG_SPARSEMEM_STATIC is not set 249# CONFIG_SPARSEMEM_STATIC is not set
250# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
254CONFIG_SPLIT_PTLOCK_CPUS=4 251CONFIG_SPLIT_PTLOCK_CPUS=4
255# CONFIG_RESOURCES_64BIT is not set 252# CONFIG_RESOURCES_64BIT is not set
256CONFIG_ZONE_DMA_FLAG=1 253CONFIG_ZONE_DMA_FLAG=1
257CONFIG_LARGE_ALLOCS=y 254CONFIG_VIRT_TO_BUS=y
258# CONFIG_BFIN_GPTIMERS is not set 255# CONFIG_BFIN_GPTIMERS is not set
259CONFIG_BFIN_DMA_5XX=y 256CONFIG_BFIN_DMA_5XX=y
257# CONFIG_DMA_UNCACHED_4M is not set
260# CONFIG_DMA_UNCACHED_2M is not set 258# CONFIG_DMA_UNCACHED_2M is not set
261CONFIG_DMA_UNCACHED_1M=y 259CONFIG_DMA_UNCACHED_1M=y
262# CONFIG_DMA_UNCACHED_NONE is not set 260# CONFIG_DMA_UNCACHED_NONE is not set
@@ -294,17 +292,13 @@ CONFIG_C_AMBEN_ALL=y
294CONFIG_BANK_0=0x7BB0 292CONFIG_BANK_0=0x7BB0
295CONFIG_BANK_1=0x7BB0 293CONFIG_BANK_1=0x7BB0
296CONFIG_BANK_2=0x7BB0 294CONFIG_BANK_2=0x7BB0
297CONFIG_BANK_3=0xAAC3 295CONFIG_BANK_3=0xAAC2
298 296
299# 297#
300# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 298# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
301# 299#
302# CONFIG_PCI is not set 300# CONFIG_PCI is not set
303# CONFIG_ARCH_SUPPORTS_MSI is not set 301# CONFIG_ARCH_SUPPORTS_MSI is not set
304
305#
306# PCCARD (PCMCIA/CardBus) support
307#
308# CONFIG_PCCARD is not set 302# CONFIG_PCCARD is not set
309 303
310# 304#
@@ -322,7 +316,9 @@ CONFIG_BINFMT_ZFLAT=y
322CONFIG_PM=y 316CONFIG_PM=y
323# CONFIG_PM_LEGACY is not set 317# CONFIG_PM_LEGACY is not set
324# CONFIG_PM_DEBUG is not set 318# CONFIG_PM_DEBUG is not set
325# CONFIG_PM_SYSFS_DEPRECATED is not set 319CONFIG_PM_SLEEP=y
320CONFIG_SUSPEND_UP_POSSIBLE=y
321CONFIG_SUSPEND=y
326CONFIG_PM_BFIN_SLEEP_DEEPER=y 322CONFIG_PM_BFIN_SLEEP_DEEPER=y
327# CONFIG_PM_BFIN_SLEEP is not set 323# CONFIG_PM_BFIN_SLEEP is not set
328# CONFIG_PM_WAKEUP_BY_GPIO is not set 324# CONFIG_PM_WAKEUP_BY_GPIO is not set
@@ -368,6 +364,7 @@ CONFIG_SYN_COOKIES=y
368CONFIG_INET_XFRM_MODE_TRANSPORT=y 364CONFIG_INET_XFRM_MODE_TRANSPORT=y
369CONFIG_INET_XFRM_MODE_TUNNEL=y 365CONFIG_INET_XFRM_MODE_TUNNEL=y
370CONFIG_INET_XFRM_MODE_BEET=y 366CONFIG_INET_XFRM_MODE_BEET=y
367# CONFIG_INET_LRO is not set
371CONFIG_INET_DIAG=y 368CONFIG_INET_DIAG=y
372CONFIG_INET_TCP_DIAG=y 369CONFIG_INET_TCP_DIAG=y
373# CONFIG_TCP_CONG_ADVANCED is not set 370# CONFIG_TCP_CONG_ADVANCED is not set
@@ -394,10 +391,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
394# CONFIG_LAPB is not set 391# CONFIG_LAPB is not set
395# CONFIG_ECONET is not set 392# CONFIG_ECONET is not set
396# CONFIG_WAN_ROUTER is not set 393# CONFIG_WAN_ROUTER is not set
397
398#
399# QoS and/or fair queueing
400#
401# CONFIG_NET_SCHED is not set 394# CONFIG_NET_SCHED is not set
402 395
403# 396#
@@ -429,6 +422,9 @@ CONFIG_IRDA_CACHE_LAST_LSAP=y
429# SIR device drivers 422# SIR device drivers
430# 423#
431CONFIG_IRTTY_SIR=m 424CONFIG_IRTTY_SIR=m
425CONFIG_BFIN_SIR=m
426CONFIG_SIR_BFIN_DMA=y
427# CONFIG_SIR_BFIN_PIO is not set
432 428
433# 429#
434# Dongle support 430# Dongle support
@@ -458,6 +454,7 @@ CONFIG_IRTTY_SIR=m
458# CONFIG_MAC80211 is not set 454# CONFIG_MAC80211 is not set
459# CONFIG_IEEE80211 is not set 455# CONFIG_IEEE80211 is not set
460# CONFIG_RFKILL is not set 456# CONFIG_RFKILL is not set
457# CONFIG_NET_9P is not set
461 458
462# 459#
463# Device Drivers 460# Device Drivers
@@ -466,14 +463,11 @@ CONFIG_IRTTY_SIR=m
466# 463#
467# Generic Driver Options 464# Generic Driver Options
468# 465#
466CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
469CONFIG_STANDALONE=y 467CONFIG_STANDALONE=y
470CONFIG_PREVENT_FIRMWARE_BUILD=y 468CONFIG_PREVENT_FIRMWARE_BUILD=y
471# CONFIG_FW_LOADER is not set 469# CONFIG_FW_LOADER is not set
472# CONFIG_SYS_HYPERVISOR is not set 470# CONFIG_SYS_HYPERVISOR is not set
473
474#
475# Connector - unified userspace <-> kernelspace linker
476#
477# CONFIG_CONNECTOR is not set 471# CONFIG_CONNECTOR is not set
478CONFIG_MTD=y 472CONFIG_MTD=y
479# CONFIG_MTD_DEBUG is not set 473# CONFIG_MTD_DEBUG is not set
@@ -493,6 +487,7 @@ CONFIG_MTD_BLOCK=y
493# CONFIG_INFTL is not set 487# CONFIG_INFTL is not set
494# CONFIG_RFD_FTL is not set 488# CONFIG_RFD_FTL is not set
495# CONFIG_SSFDC is not set 489# CONFIG_SSFDC is not set
490# CONFIG_MTD_OOPS is not set
496 491
497# 492#
498# RAM/ROM/Flash chip drivers 493# RAM/ROM/Flash chip drivers
@@ -524,11 +519,7 @@ CONFIG_MTD_ROM=m
524# 519#
525CONFIG_MTD_COMPLEX_MAPPINGS=y 520CONFIG_MTD_COMPLEX_MAPPINGS=y
526# CONFIG_MTD_PHYSMAP is not set 521# CONFIG_MTD_PHYSMAP is not set
527CONFIG_MTD_BF5xx=m 522CONFIG_MTD_BFIN_ASYNC=m
528CONFIG_BFIN_FLASH_BANK_0=0x7BB0
529CONFIG_BFIN_FLASH_BANK_1=0x7BB0
530CONFIG_BFIN_FLASH_BANK_2=0x7BB0
531CONFIG_BFIN_FLASH_BANK_3=0x7BB0
532# CONFIG_MTD_UCLINUX is not set 523# CONFIG_MTD_UCLINUX is not set
533# CONFIG_MTD_PLATRAM is not set 524# CONFIG_MTD_PLATRAM is not set
534 525
@@ -555,20 +546,8 @@ CONFIG_BFIN_FLASH_BANK_3=0x7BB0
555# UBI - Unsorted block images 546# UBI - Unsorted block images
556# 547#
557# CONFIG_MTD_UBI is not set 548# CONFIG_MTD_UBI is not set
558
559#
560# Parallel port support
561#
562# CONFIG_PARPORT is not set 549# CONFIG_PARPORT is not set
563 550CONFIG_BLK_DEV=y
564#
565# Plug and Play support
566#
567# CONFIG_PNPACPI is not set
568
569#
570# Block devices
571#
572# CONFIG_BLK_DEV_COW_COMMON is not set 551# CONFIG_BLK_DEV_COW_COMMON is not set
573# CONFIG_BLK_DEV_LOOP is not set 552# CONFIG_BLK_DEV_LOOP is not set
574# CONFIG_BLK_DEV_NBD is not set 553# CONFIG_BLK_DEV_NBD is not set
@@ -578,10 +557,8 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
578CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 557CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
579# CONFIG_CDROM_PKTCDVD is not set 558# CONFIG_CDROM_PKTCDVD is not set
580# CONFIG_ATA_OVER_ETH is not set 559# CONFIG_ATA_OVER_ETH is not set
581 560CONFIG_MISC_DEVICES=y
582# 561# CONFIG_EEPROM_93CX6 is not set
583# Misc devices
584#
585# CONFIG_IDE is not set 562# CONFIG_IDE is not set
586 563
587# 564#
@@ -589,32 +566,29 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
589# 566#
590# CONFIG_RAID_ATTRS is not set 567# CONFIG_RAID_ATTRS is not set
591# CONFIG_SCSI is not set 568# CONFIG_SCSI is not set
569# CONFIG_SCSI_DMA is not set
592# CONFIG_SCSI_NETLINK is not set 570# CONFIG_SCSI_NETLINK is not set
593# CONFIG_ATA is not set 571# CONFIG_ATA is not set
594
595#
596# Multi-device support (RAID and LVM)
597#
598# CONFIG_MD is not set 572# CONFIG_MD is not set
599
600#
601# Network device support
602#
603CONFIG_NETDEVICES=y 573CONFIG_NETDEVICES=y
574# CONFIG_NETDEVICES_MULTIQUEUE is not set
604# CONFIG_DUMMY is not set 575# CONFIG_DUMMY is not set
605# CONFIG_BONDING is not set 576# CONFIG_BONDING is not set
577# CONFIG_MACVLAN is not set
606# CONFIG_EQUALIZER is not set 578# CONFIG_EQUALIZER is not set
607# CONFIG_TUN is not set 579# CONFIG_TUN is not set
580# CONFIG_VETH is not set
608# CONFIG_PHYLIB is not set 581# CONFIG_PHYLIB is not set
609
610#
611# Ethernet (10 or 100Mbit)
612#
613CONFIG_NET_ETHERNET=y 582CONFIG_NET_ETHERNET=y
614CONFIG_MII=y 583CONFIG_MII=y
615CONFIG_SMC91X=y 584CONFIG_SMC91X=y
616# CONFIG_SMSC911X is not set 585# CONFIG_SMSC911X is not set
617# CONFIG_DM9000 is not set 586# CONFIG_DM9000 is not set
587# CONFIG_IBM_NEW_EMAC_ZMII is not set
588# CONFIG_IBM_NEW_EMAC_RGMII is not set
589# CONFIG_IBM_NEW_EMAC_TAH is not set
590# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
591# CONFIG_B44 is not set
618CONFIG_NETDEV_1000=y 592CONFIG_NETDEV_1000=y
619# CONFIG_AX88180 is not set 593# CONFIG_AX88180 is not set
620CONFIG_NETDEV_10000=y 594CONFIG_NETDEV_10000=y
@@ -631,15 +605,7 @@ CONFIG_NETDEV_10000=y
631# CONFIG_NETCONSOLE is not set 605# CONFIG_NETCONSOLE is not set
632# CONFIG_NETPOLL is not set 606# CONFIG_NETPOLL is not set
633# CONFIG_NET_POLL_CONTROLLER is not set 607# CONFIG_NET_POLL_CONTROLLER is not set
634
635#
636# ISDN subsystem
637#
638# CONFIG_ISDN is not set 608# CONFIG_ISDN is not set
639
640#
641# Telephony Support
642#
643# CONFIG_PHONE is not set 609# CONFIG_PHONE is not set
644 610
645# 611#
@@ -654,7 +620,6 @@ CONFIG_INPUT=y
654# 620#
655# CONFIG_INPUT_MOUSEDEV is not set 621# CONFIG_INPUT_MOUSEDEV is not set
656# CONFIG_INPUT_JOYDEV is not set 622# CONFIG_INPUT_JOYDEV is not set
657# CONFIG_INPUT_TSDEV is not set
658CONFIG_INPUT_EVDEV=m 623CONFIG_INPUT_EVDEV=m
659# CONFIG_INPUT_EVBUG is not set 624# CONFIG_INPUT_EVBUG is not set
660 625
@@ -667,14 +632,8 @@ CONFIG_INPUT_EVDEV=m
667# CONFIG_INPUT_TABLET is not set 632# CONFIG_INPUT_TABLET is not set
668# CONFIG_INPUT_TOUCHSCREEN is not set 633# CONFIG_INPUT_TOUCHSCREEN is not set
669CONFIG_INPUT_MISC=y 634CONFIG_INPUT_MISC=y
670# CONFIG_INPUT_ATI_REMOTE is not set
671# CONFIG_INPUT_ATI_REMOTE2 is not set
672# CONFIG_INPUT_KEYSPAN_REMOTE is not set
673# CONFIG_INPUT_POWERMATE is not set
674# CONFIG_INPUT_YEALINK is not set
675# CONFIG_INPUT_UINPUT is not set 635# CONFIG_INPUT_UINPUT is not set
676CONFIG_TWI_KEYPAD=m 636CONFIG_TWI_KEYPAD=m
677CONFIG_BFIN_TWIKEYPAD_IRQ_PFX=39
678 637
679# 638#
680# Hardware I/O ports 639# Hardware I/O ports
@@ -687,15 +646,13 @@ CONFIG_BFIN_TWIKEYPAD_IRQ_PFX=39
687# 646#
688# CONFIG_AD9960 is not set 647# CONFIG_AD9960 is not set
689# CONFIG_SPI_ADC_BF533 is not set 648# CONFIG_SPI_ADC_BF533 is not set
690# CONFIG_BF5xx_PFLAGS is not set
691# CONFIG_BF5xx_PPIFCD is not set 649# CONFIG_BF5xx_PPIFCD is not set
692# CONFIG_BFIN_SIMPLE_TIMER is not set 650# CONFIG_BFIN_SIMPLE_TIMER is not set
693# CONFIG_BF5xx_PPI is not set 651# CONFIG_BF5xx_PPI is not set
694CONFIG_BFIN_SPORT=y 652CONFIG_BFIN_SPORT=y
695# CONFIG_BFIN_TIMER_LATENCY is not set 653# CONFIG_BFIN_TIMER_LATENCY is not set
696CONFIG_TWI_LCD=m 654CONFIG_TWI_LCD=m
697CONFIG_TWI_LCD_SLAVE_ADDR=34 655CONFIG_SIMPLE_GPIO=m
698# CONFIG_AD5304 is not set
699# CONFIG_VT is not set 656# CONFIG_VT is not set
700# CONFIG_SERIAL_NONSTANDARD is not set 657# CONFIG_SERIAL_NONSTANDARD is not set
701 658
@@ -723,28 +680,11 @@ CONFIG_UNIX98_PTYS=y
723# CAN, the car bus and industrial fieldbus 680# CAN, the car bus and industrial fieldbus
724# 681#
725# CONFIG_CAN4LINUX is not set 682# CONFIG_CAN4LINUX is not set
726
727#
728# IPMI
729#
730# CONFIG_IPMI_HANDLER is not set 683# CONFIG_IPMI_HANDLER is not set
731CONFIG_WATCHDOG=y
732# CONFIG_WATCHDOG_NOWAYOUT is not set
733
734#
735# Watchdog Device Drivers
736#
737# CONFIG_SOFT_WATCHDOG is not set
738CONFIG_BFIN_WDT=y
739CONFIG_HW_RANDOM=y 684CONFIG_HW_RANDOM=y
740# CONFIG_GEN_RTC is not set 685# CONFIG_GEN_RTC is not set
741CONFIG_BLACKFIN_DPMC=y
742# CONFIG_R3964 is not set 686# CONFIG_R3964 is not set
743# CONFIG_RAW_DRIVER is not set 687# CONFIG_RAW_DRIVER is not set
744
745#
746# TPM devices
747#
748# CONFIG_TCG_TPM is not set 688# CONFIG_TCG_TPM is not set
749CONFIG_I2C=m 689CONFIG_I2C=m
750CONFIG_I2C_BOARDINFO=y 690CONFIG_I2C_BOARDINFO=y
@@ -764,6 +704,7 @@ CONFIG_I2C_ALGOBIT=m
764# CONFIG_I2C_OCORES is not set 704# CONFIG_I2C_OCORES is not set
765# CONFIG_I2C_PARPORT_LIGHT is not set 705# CONFIG_I2C_PARPORT_LIGHT is not set
766# CONFIG_I2C_SIMTEC is not set 706# CONFIG_I2C_SIMTEC is not set
707# CONFIG_I2C_TAOS_EVM is not set
767# CONFIG_I2C_STUB is not set 708# CONFIG_I2C_STUB is not set
768 709
769# 710#
@@ -771,14 +712,15 @@ CONFIG_I2C_ALGOBIT=m
771# 712#
772# CONFIG_SENSORS_DS1337 is not set 713# CONFIG_SENSORS_DS1337 is not set
773# CONFIG_SENSORS_DS1374 is not set 714# CONFIG_SENSORS_DS1374 is not set
715# CONFIG_DS1682 is not set
774# CONFIG_SENSORS_AD5252 is not set 716# CONFIG_SENSORS_AD5252 is not set
775# CONFIG_SENSORS_EEPROM is not set 717# CONFIG_SENSORS_EEPROM is not set
776# CONFIG_SENSORS_PCF8574 is not set 718# CONFIG_SENSORS_PCF8574 is not set
777# CONFIG_SENSORS_PCF8575 is not set 719# CONFIG_SENSORS_PCF8575 is not set
778# CONFIG_SENSORS_PCA9543 is not set
779# CONFIG_SENSORS_PCA9539 is not set 720# CONFIG_SENSORS_PCA9539 is not set
780# CONFIG_SENSORS_PCF8591 is not set 721# CONFIG_SENSORS_PCF8591 is not set
781# CONFIG_SENSORS_MAX6875 is not set 722# CONFIG_SENSORS_MAX6875 is not set
723# CONFIG_SENSORS_TSL2550 is not set
782# CONFIG_I2C_DEBUG_CORE is not set 724# CONFIG_I2C_DEBUG_CORE is not set
783# CONFIG_I2C_DEBUG_ALGO is not set 725# CONFIG_I2C_DEBUG_ALGO is not set
784# CONFIG_I2C_DEBUG_BUS is not set 726# CONFIG_I2C_DEBUG_BUS is not set
@@ -801,14 +743,11 @@ CONFIG_SPI_BFIN=y
801# 743#
802# CONFIG_SPI_AT25 is not set 744# CONFIG_SPI_AT25 is not set
803# CONFIG_SPI_SPIDEV is not set 745# CONFIG_SPI_SPIDEV is not set
804 746# CONFIG_SPI_TLE62X0 is not set
805#
806# Dallas's 1-wire bus
807#
808# CONFIG_W1 is not set 747# CONFIG_W1 is not set
748# CONFIG_POWER_SUPPLY is not set
809CONFIG_HWMON=y 749CONFIG_HWMON=y
810# CONFIG_HWMON_VID is not set 750# CONFIG_HWMON_VID is not set
811# CONFIG_SENSORS_ABITUGURU is not set
812# CONFIG_SENSORS_AD7418 is not set 751# CONFIG_SENSORS_AD7418 is not set
813# CONFIG_SENSORS_ADM1021 is not set 752# CONFIG_SENSORS_ADM1021 is not set
814# CONFIG_SENSORS_ADM1025 is not set 753# CONFIG_SENSORS_ADM1025 is not set
@@ -816,12 +755,12 @@ CONFIG_HWMON=y
816# CONFIG_SENSORS_ADM1029 is not set 755# CONFIG_SENSORS_ADM1029 is not set
817# CONFIG_SENSORS_ADM1031 is not set 756# CONFIG_SENSORS_ADM1031 is not set
818# CONFIG_SENSORS_ADM9240 is not set 757# CONFIG_SENSORS_ADM9240 is not set
819# CONFIG_SENSORS_ASB100 is not set 758# CONFIG_SENSORS_ADT7470 is not set
820# CONFIG_SENSORS_ATXP1 is not set 759# CONFIG_SENSORS_ATXP1 is not set
821# CONFIG_SENSORS_DS1621 is not set 760# CONFIG_SENSORS_DS1621 is not set
822# CONFIG_SENSORS_F71805F is not set 761# CONFIG_SENSORS_F71805F is not set
823# CONFIG_SENSORS_FSCHER is not set 762# CONFIG_SENSORS_F71882FG is not set
824# CONFIG_SENSORS_FSCPOS is not set 763# CONFIG_SENSORS_F75375S is not set
825# CONFIG_SENSORS_GL518SM is not set 764# CONFIG_SENSORS_GL518SM is not set
826# CONFIG_SENSORS_GL520SM is not set 765# CONFIG_SENSORS_GL520SM is not set
827# CONFIG_SENSORS_IT87 is not set 766# CONFIG_SENSORS_IT87 is not set
@@ -836,13 +775,16 @@ CONFIG_HWMON=y
836# CONFIG_SENSORS_LM87 is not set 775# CONFIG_SENSORS_LM87 is not set
837# CONFIG_SENSORS_LM90 is not set 776# CONFIG_SENSORS_LM90 is not set
838# CONFIG_SENSORS_LM92 is not set 777# CONFIG_SENSORS_LM92 is not set
778# CONFIG_SENSORS_LM93 is not set
839# CONFIG_SENSORS_MAX1619 is not set 779# CONFIG_SENSORS_MAX1619 is not set
840# CONFIG_SENSORS_MAX6650 is not set 780# CONFIG_SENSORS_MAX6650 is not set
841# CONFIG_SENSORS_PC87360 is not set 781# CONFIG_SENSORS_PC87360 is not set
842# CONFIG_SENSORS_PC87427 is not set 782# CONFIG_SENSORS_PC87427 is not set
783# CONFIG_SENSORS_DME1737 is not set
843# CONFIG_SENSORS_SMSC47M1 is not set 784# CONFIG_SENSORS_SMSC47M1 is not set
844# CONFIG_SENSORS_SMSC47M192 is not set 785# CONFIG_SENSORS_SMSC47M192 is not set
845# CONFIG_SENSORS_SMSC47B397 is not set 786# CONFIG_SENSORS_SMSC47B397 is not set
787# CONFIG_SENSORS_THMC50 is not set
846# CONFIG_SENSORS_VT1211 is not set 788# CONFIG_SENSORS_VT1211 is not set
847# CONFIG_SENSORS_W83781D is not set 789# CONFIG_SENSORS_W83781D is not set
848# CONFIG_SENSORS_W83791D is not set 790# CONFIG_SENSORS_W83791D is not set
@@ -852,6 +794,20 @@ CONFIG_HWMON=y
852# CONFIG_SENSORS_W83627HF is not set 794# CONFIG_SENSORS_W83627HF is not set
853# CONFIG_SENSORS_W83627EHF is not set 795# CONFIG_SENSORS_W83627EHF is not set
854# CONFIG_HWMON_DEBUG_CHIP is not set 796# CONFIG_HWMON_DEBUG_CHIP is not set
797CONFIG_WATCHDOG=y
798# CONFIG_WATCHDOG_NOWAYOUT is not set
799
800#
801# Watchdog Device Drivers
802#
803# CONFIG_SOFT_WATCHDOG is not set
804CONFIG_BFIN_WDT=y
805
806#
807# Sonics Silicon Backplane
808#
809CONFIG_SSB_POSSIBLE=y
810# CONFIG_SSB is not set
855 811
856# 812#
857# Multifunction device drivers 813# Multifunction device drivers
@@ -863,24 +819,20 @@ CONFIG_HWMON=y
863# 819#
864# CONFIG_VIDEO_DEV is not set 820# CONFIG_VIDEO_DEV is not set
865# CONFIG_DVB_CORE is not set 821# CONFIG_DVB_CORE is not set
866CONFIG_DAB=y 822# CONFIG_DAB is not set
867 823
868# 824#
869# Graphics support 825# Graphics support
870# 826#
871# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
872
873#
874# Display device support
875#
876# CONFIG_DISPLAY_SUPPORT is not set
877# CONFIG_VGASTATE is not set 827# CONFIG_VGASTATE is not set
828# CONFIG_VIDEO_OUTPUT_CONTROL is not set
878CONFIG_FB=m 829CONFIG_FB=m
879CONFIG_FIRMWARE_EDID=y 830CONFIG_FIRMWARE_EDID=y
880# CONFIG_FB_DDC is not set 831# CONFIG_FB_DDC is not set
881CONFIG_FB_CFB_FILLRECT=m 832CONFIG_FB_CFB_FILLRECT=m
882CONFIG_FB_CFB_COPYAREA=m 833CONFIG_FB_CFB_COPYAREA=m
883CONFIG_FB_CFB_IMAGEBLIT=m 834CONFIG_FB_CFB_IMAGEBLIT=m
835# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
884# CONFIG_FB_SYS_FILLRECT is not set 836# CONFIG_FB_SYS_FILLRECT is not set
885# CONFIG_FB_SYS_COPYAREA is not set 837# CONFIG_FB_SYS_COPYAREA is not set
886# CONFIG_FB_SYS_IMAGEBLIT is not set 838# CONFIG_FB_SYS_IMAGEBLIT is not set
@@ -895,7 +847,7 @@ CONFIG_FB_DEFERRED_IO=y
895# 847#
896# Frame buffer hardware drivers 848# Frame buffer hardware drivers
897# 849#
898CONFIG_FB_BFIN_7171=m 850# CONFIG_FB_BFIN_T350MCQB is not set
899CONFIG_FB_BFIN_7393=m 851CONFIG_FB_BFIN_7393=m
900CONFIG_NTSC=y 852CONFIG_NTSC=y
901# CONFIG_PAL is not set 853# CONFIG_PAL is not set
@@ -905,9 +857,14 @@ CONFIG_NTSC=y
905# CONFIG_PAL_YCBCR is not set 857# CONFIG_PAL_YCBCR is not set
906CONFIG_ADV7393_1XMEM=y 858CONFIG_ADV7393_1XMEM=y
907# CONFIG_ADV7393_2XMEM is not set 859# CONFIG_ADV7393_2XMEM is not set
908# CONFIG_FB_BFIN_T350MCQB is not set
909# CONFIG_FB_S1D13XXX is not set 860# CONFIG_FB_S1D13XXX is not set
910# CONFIG_FB_VIRTUAL is not set 861# CONFIG_FB_VIRTUAL is not set
862# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
863
864#
865# Display device support
866#
867# CONFIG_DISPLAY_SUPPORT is not set
911# CONFIG_LOGO is not set 868# CONFIG_LOGO is not set
912 869
913# 870#
@@ -941,6 +898,10 @@ CONFIG_SND_VERBOSE_PROCFS=y
941# CONFIG_SND_MPU401 is not set 898# CONFIG_SND_MPU401 is not set
942 899
943# 900#
901# SPI devices
902#
903
904#
944# ALSA Blackfin devices 905# ALSA Blackfin devices
945# 906#
946CONFIG_SND_BLACKFIN_AD1836=m 907CONFIG_SND_BLACKFIN_AD1836=m
@@ -953,69 +914,43 @@ CONFIG_SND_BLACKFIN_SPI_PFBIT=4
953CONFIG_SND_BFIN_AD73311=m 914CONFIG_SND_BFIN_AD73311=m
954CONFIG_SND_BFIN_SPORT=0 915CONFIG_SND_BFIN_SPORT=0
955CONFIG_SND_BFIN_AD73311_SE=4 916CONFIG_SND_BFIN_AD73311_SE=4
917CONFIG_SND_BFIN_AD73322=m
918CONFIG_SND_BFIN_AD73322_SPORT0_SE=10
919CONFIG_SND_BFIN_AD73322_SPORT1_SE=14
920CONFIG_SND_BFIN_AD73322_RESET=12
956 921
957# 922#
958# System on Chip audio support 923# System on Chip audio support
959# 924#
960# CONFIG_SND_SOC is not set 925CONFIG_SND_SOC_AC97_BUS=y
926CONFIG_SND_SOC=m
927CONFIG_SND_BF5XX_SOC=m
928CONFIG_SND_MMAP_SUPPORT=y
929CONFIG_SND_BF5XX_SOC_AC97=m
930# CONFIG_SND_BF5XX_SOC_WM8750 is not set
931# CONFIG_SND_BF5XX_SOC_WM8731 is not set
932# CONFIG_SND_BF5XX_SOC_SSM2602 is not set
933CONFIG_SND_BF5XX_SOC_BF5xx=m
934CONFIG_SND_BF5XX_SPORT_NUM=0
935# CONFIG_SND_BF5XX_HAVE_COLD_RESET is not set
961 936
962# 937#
963# Open Sound System 938# SoC Audio support for SuperH
964# 939#
965# CONFIG_SOUND_PRIME is not set 940CONFIG_SND_SOC_AD1980=m
966 941
967# 942#
968# HID Devices 943# Open Sound System
969# 944#
945# CONFIG_SOUND_PRIME is not set
946CONFIG_AC97_BUS=m
947CONFIG_HID_SUPPORT=y
970CONFIG_HID=y 948CONFIG_HID=y
971# CONFIG_HID_DEBUG is not set 949# CONFIG_HID_DEBUG is not set
972 950# CONFIG_HIDRAW is not set
973# 951# CONFIG_USB_SUPPORT is not set
974# USB support
975#
976CONFIG_USB_ARCH_HAS_HCD=y
977# CONFIG_USB_ARCH_HAS_OHCI is not set
978# CONFIG_USB_ARCH_HAS_EHCI is not set
979# CONFIG_USB is not set
980
981#
982# Enable Host or Gadget support to see Inventra options
983#
984
985#
986# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
987#
988
989#
990# USB Gadget Support
991#
992# CONFIG_USB_GADGET is not set
993# CONFIG_MMC is not set 952# CONFIG_MMC is not set
994
995#
996# LED devices
997#
998# CONFIG_NEW_LEDS is not set 953# CONFIG_NEW_LEDS is not set
999
1000#
1001# LED drivers
1002#
1003
1004#
1005# LED Triggers
1006#
1007
1008#
1009# InfiniBand support
1010#
1011
1012#
1013# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1014#
1015
1016#
1017# Real Time Clock
1018#
1019CONFIG_RTC_LIB=y 954CONFIG_RTC_LIB=y
1020CONFIG_RTC_CLASS=y 955CONFIG_RTC_CLASS=y
1021CONFIG_RTC_HCTOSYS=y 956CONFIG_RTC_HCTOSYS=y
@@ -1035,6 +970,7 @@ CONFIG_RTC_INTF_DEV=y
1035# I2C RTC drivers 970# I2C RTC drivers
1036# 971#
1037# CONFIG_RTC_DRV_DS1307 is not set 972# CONFIG_RTC_DRV_DS1307 is not set
973# CONFIG_RTC_DRV_DS1374 is not set
1038# CONFIG_RTC_DRV_DS1672 is not set 974# CONFIG_RTC_DRV_DS1672 is not set
1039# CONFIG_RTC_DRV_MAX6900 is not set 975# CONFIG_RTC_DRV_MAX6900 is not set
1040# CONFIG_RTC_DRV_RS5C372 is not set 976# CONFIG_RTC_DRV_RS5C372 is not set
@@ -1042,6 +978,7 @@ CONFIG_RTC_INTF_DEV=y
1042# CONFIG_RTC_DRV_X1205 is not set 978# CONFIG_RTC_DRV_X1205 is not set
1043# CONFIG_RTC_DRV_PCF8563 is not set 979# CONFIG_RTC_DRV_PCF8563 is not set
1044# CONFIG_RTC_DRV_PCF8583 is not set 980# CONFIG_RTC_DRV_PCF8583 is not set
981# CONFIG_RTC_DRV_M41T80 is not set
1045 982
1046# 983#
1047# SPI RTC drivers 984# SPI RTC drivers
@@ -1053,8 +990,10 @@ CONFIG_RTC_INTF_DEV=y
1053# Platform RTC drivers 990# Platform RTC drivers
1054# 991#
1055# CONFIG_RTC_DRV_DS1553 is not set 992# CONFIG_RTC_DRV_DS1553 is not set
993# CONFIG_RTC_DRV_STK17TA8 is not set
1056# CONFIG_RTC_DRV_DS1742 is not set 994# CONFIG_RTC_DRV_DS1742 is not set
1057# CONFIG_RTC_DRV_M48T86 is not set 995# CONFIG_RTC_DRV_M48T86 is not set
996# CONFIG_RTC_DRV_M48T59 is not set
1058# CONFIG_RTC_DRV_V3020 is not set 997# CONFIG_RTC_DRV_V3020 is not set
1059 998
1060# 999#
@@ -1063,22 +1002,9 @@ CONFIG_RTC_INTF_DEV=y
1063CONFIG_RTC_DRV_BFIN=y 1002CONFIG_RTC_DRV_BFIN=y
1064 1003
1065# 1004#
1066# DMA Engine support 1005# Userspace I/O
1067# 1006#
1068# CONFIG_DMA_ENGINE is not set 1007# CONFIG_UIO is not set
1069
1070#
1071# DMA Clients
1072#
1073
1074#
1075# DMA Devices
1076#
1077
1078#
1079# PBX support
1080#
1081# CONFIG_PBX is not set
1082 1008
1083# 1009#
1084# File systems 1010# File systems
@@ -1123,7 +1049,6 @@ CONFIG_PROC_SYSCTL=y
1123CONFIG_SYSFS=y 1049CONFIG_SYSFS=y
1124# CONFIG_TMPFS is not set 1050# CONFIG_TMPFS is not set
1125# CONFIG_HUGETLB_PAGE is not set 1051# CONFIG_HUGETLB_PAGE is not set
1126CONFIG_RAMFS=y
1127# CONFIG_CONFIGFS_FS is not set 1052# CONFIG_CONFIGFS_FS is not set
1128 1053
1129# 1054#
@@ -1149,10 +1074,12 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
1149CONFIG_JFFS2_FS=m 1074CONFIG_JFFS2_FS=m
1150CONFIG_JFFS2_FS_DEBUG=0 1075CONFIG_JFFS2_FS_DEBUG=0
1151CONFIG_JFFS2_FS_WRITEBUFFER=y 1076CONFIG_JFFS2_FS_WRITEBUFFER=y
1077# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1152# CONFIG_JFFS2_SUMMARY is not set 1078# CONFIG_JFFS2_SUMMARY is not set
1153# CONFIG_JFFS2_FS_XATTR is not set 1079# CONFIG_JFFS2_FS_XATTR is not set
1154# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 1080# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1155CONFIG_JFFS2_ZLIB=y 1081CONFIG_JFFS2_ZLIB=y
1082# CONFIG_JFFS2_LZO is not set
1156CONFIG_JFFS2_RTIME=y 1083CONFIG_JFFS2_RTIME=y
1157# CONFIG_JFFS2_RUBIN is not set 1084# CONFIG_JFFS2_RUBIN is not set
1158# CONFIG_CRAMFS is not set 1085# CONFIG_CRAMFS is not set
@@ -1161,10 +1088,7 @@ CONFIG_JFFS2_RTIME=y
1161# CONFIG_QNX4FS_FS is not set 1088# CONFIG_QNX4FS_FS is not set
1162# CONFIG_SYSV_FS is not set 1089# CONFIG_SYSV_FS is not set
1163# CONFIG_UFS_FS is not set 1090# CONFIG_UFS_FS is not set
1164 1091CONFIG_NETWORK_FILESYSTEMS=y
1165#
1166# Network File Systems
1167#
1168CONFIG_NFS_FS=m 1092CONFIG_NFS_FS=m
1169CONFIG_NFS_V3=y 1093CONFIG_NFS_V3=y
1170# CONFIG_NFS_V3_ACL is not set 1094# CONFIG_NFS_V3_ACL is not set
@@ -1184,17 +1108,12 @@ CONFIG_SMB_FS=m
1184# CONFIG_NCP_FS is not set 1108# CONFIG_NCP_FS is not set
1185# CONFIG_CODA_FS is not set 1109# CONFIG_CODA_FS is not set
1186# CONFIG_AFS_FS is not set 1110# CONFIG_AFS_FS is not set
1187# CONFIG_9P_FS is not set
1188 1111
1189# 1112#
1190# Partition Types 1113# Partition Types
1191# 1114#
1192# CONFIG_PARTITION_ADVANCED is not set 1115# CONFIG_PARTITION_ADVANCED is not set
1193CONFIG_MSDOS_PARTITION=y 1116CONFIG_MSDOS_PARTITION=y
1194
1195#
1196# Native Language Support
1197#
1198CONFIG_NLS=m 1117CONFIG_NLS=m
1199CONFIG_NLS_DEFAULT="iso8859-1" 1118CONFIG_NLS_DEFAULT="iso8859-1"
1200# CONFIG_NLS_CODEPAGE_437 is not set 1119# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1235,21 +1154,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1235# CONFIG_NLS_KOI8_R is not set 1154# CONFIG_NLS_KOI8_R is not set
1236# CONFIG_NLS_KOI8_U is not set 1155# CONFIG_NLS_KOI8_U is not set
1237# CONFIG_NLS_UTF8 is not set 1156# CONFIG_NLS_UTF8 is not set
1238
1239#
1240# Distributed Lock Manager
1241#
1242# CONFIG_DLM is not set 1157# CONFIG_DLM is not set
1243 1158CONFIG_INSTRUMENTATION=y
1244#
1245# Profiling support
1246#
1247# CONFIG_PROFILING is not set 1159# CONFIG_PROFILING is not set
1160# CONFIG_MARKERS is not set
1248 1161
1249# 1162#
1250# Kernel hacking 1163# Kernel hacking
1251# 1164#
1252# CONFIG_PRINTK_TIME is not set 1165# CONFIG_PRINTK_TIME is not set
1166CONFIG_ENABLE_WARN_DEPRECATED=y
1253CONFIG_ENABLE_MUST_CHECK=y 1167CONFIG_ENABLE_MUST_CHECK=y
1254# CONFIG_MAGIC_SYSRQ is not set 1168# CONFIG_MAGIC_SYSRQ is not set
1255# CONFIG_UNUSED_SYMBOLS is not set 1169# CONFIG_UNUSED_SYMBOLS is not set
@@ -1257,6 +1171,7 @@ CONFIG_DEBUG_FS=y
1257# CONFIG_HEADERS_CHECK is not set 1171# CONFIG_HEADERS_CHECK is not set
1258# CONFIG_DEBUG_KERNEL is not set 1172# CONFIG_DEBUG_KERNEL is not set
1259# CONFIG_DEBUG_BUGVERBOSE is not set 1173# CONFIG_DEBUG_BUGVERBOSE is not set
1174# CONFIG_SAMPLES is not set
1260CONFIG_DEBUG_MMRS=y 1175CONFIG_DEBUG_MMRS=y
1261CONFIG_DEBUG_HUNT_FOR_ZERO=y 1176CONFIG_DEBUG_HUNT_FOR_ZERO=y
1262CONFIG_DEBUG_BFIN_HWTRACE_ON=y 1177CONFIG_DEBUG_BFIN_HWTRACE_ON=y
@@ -1276,11 +1191,7 @@ CONFIG_ACCESS_CHECK=y
1276# CONFIG_KEYS is not set 1191# CONFIG_KEYS is not set
1277CONFIG_SECURITY=y 1192CONFIG_SECURITY=y
1278# CONFIG_SECURITY_NETWORK is not set 1193# CONFIG_SECURITY_NETWORK is not set
1279CONFIG_SECURITY_CAPABILITIES=m 1194# CONFIG_SECURITY_CAPABILITIES is not set
1280
1281#
1282# Cryptographic options
1283#
1284# CONFIG_CRYPTO is not set 1195# CONFIG_CRYPTO is not set
1285 1196
1286# 1197#
@@ -1291,6 +1202,7 @@ CONFIG_CRC_CCITT=m
1291# CONFIG_CRC16 is not set 1202# CONFIG_CRC16 is not set
1292# CONFIG_CRC_ITU_T is not set 1203# CONFIG_CRC_ITU_T is not set
1293CONFIG_CRC32=y 1204CONFIG_CRC32=y
1205# CONFIG_CRC7 is not set
1294# CONFIG_LIBCRC32C is not set 1206# CONFIG_LIBCRC32C is not set
1295CONFIG_ZLIB_INFLATE=y 1207CONFIG_ZLIB_INFLATE=y
1296CONFIG_ZLIB_DEFLATE=m 1208CONFIG_ZLIB_DEFLATE=m
diff --git a/arch/blackfin/configs/BF537-STAMP_defconfig b/arch/blackfin/configs/BF537-STAMP_defconfig
index b5189c8ba263..5fd7c4b143df 100644
--- a/arch/blackfin/configs/BF537-STAMP_defconfig
+++ b/arch/blackfin/configs/BF537-STAMP_defconfig
@@ -1,6 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22.16 3# Linux kernel version: 2.6.24.7
4# 4#
5# CONFIG_MMU is not set 5# CONFIG_MMU is not set
6# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -13,35 +13,34 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
13CONFIG_GENERIC_HWEIGHT=y 13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_HARDIRQS=y 14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y 15CONFIG_GENERIC_IRQ_PROBE=y
16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_GPIO=y 16CONFIG_GENERIC_GPIO=y
18CONFIG_FORCE_MAX_ZONEORDER=14 17CONFIG_FORCE_MAX_ZONEORDER=14
19CONFIG_GENERIC_CALIBRATE_DELAY=y 18CONFIG_GENERIC_CALIBRATE_DELAY=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21 20
22# 21#
23# Code maturity level options 22# General setup
24# 23#
25CONFIG_EXPERIMENTAL=y 24CONFIG_EXPERIMENTAL=y
26CONFIG_BROKEN_ON_SMP=y 25CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32 26CONFIG_INIT_ENV_ARG_LIMIT=32
28
29#
30# General setup
31#
32CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
33CONFIG_LOCALVERSION_AUTO=y 28CONFIG_LOCALVERSION_AUTO=y
34CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
35# CONFIG_IPC_NS is not set
36CONFIG_SYSVIPC_SYSCTL=y 30CONFIG_SYSVIPC_SYSCTL=y
37# CONFIG_POSIX_MQUEUE is not set 31# CONFIG_POSIX_MQUEUE is not set
38# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
39# CONFIG_TASKSTATS is not set 33# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 34# CONFIG_USER_NS is not set
35# CONFIG_PID_NS is not set
41# CONFIG_AUDIT is not set 36# CONFIG_AUDIT is not set
42CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=14 39CONFIG_LOG_BUF_SHIFT=14
40# CONFIG_CGROUPS is not set
41CONFIG_FAIR_GROUP_SCHED=y
42CONFIG_FAIR_USER_SCHED=y
43# CONFIG_FAIR_CGROUP_SCHED is not set
45CONFIG_SYSFS_DEPRECATED=y 44CONFIG_SYSFS_DEPRECATED=y
46# CONFIG_RELAY is not set 45# CONFIG_RELAY is not set
47CONFIG_BLK_DEV_INITRD=y 46CONFIG_BLK_DEV_INITRD=y
@@ -64,32 +63,24 @@ CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y 63CONFIG_SIGNALFD=y
65CONFIG_EVENTFD=y 64CONFIG_EVENTFD=y
66CONFIG_VM_EVENT_COUNTERS=y 65CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
68# CONFIG_NP2 is not set
69CONFIG_SLAB=y 66CONFIG_SLAB=y
70# CONFIG_SLUB is not set 67# CONFIG_SLUB is not set
71# CONFIG_SLOB is not set 68# CONFIG_SLOB is not set
69CONFIG_SLABINFO=y
72CONFIG_RT_MUTEXES=y 70CONFIG_RT_MUTEXES=y
73CONFIG_TINY_SHMEM=y 71CONFIG_TINY_SHMEM=y
74CONFIG_BASE_SMALL=0 72CONFIG_BASE_SMALL=0
75
76#
77# Loadable module support
78#
79CONFIG_MODULES=y 73CONFIG_MODULES=y
80CONFIG_MODULE_UNLOAD=y 74CONFIG_MODULE_UNLOAD=y
81# CONFIG_MODULE_FORCE_UNLOAD is not set 75# CONFIG_MODULE_FORCE_UNLOAD is not set
82# CONFIG_MODVERSIONS is not set 76# CONFIG_MODVERSIONS is not set
83# CONFIG_MODULE_SRCVERSION_ALL is not set 77# CONFIG_MODULE_SRCVERSION_ALL is not set
84CONFIG_KMOD=y 78CONFIG_KMOD=y
85
86#
87# Block layer
88#
89CONFIG_BLOCK=y 79CONFIG_BLOCK=y
90# CONFIG_LBD is not set 80# CONFIG_LBD is not set
91# CONFIG_BLK_DEV_IO_TRACE is not set 81# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set 82# CONFIG_LSF is not set
83# CONFIG_BLK_DEV_BSG is not set
93 84
94# 85#
95# IO Schedulers 86# IO Schedulers
@@ -141,7 +132,6 @@ CONFIG_BF_REV_0_2=y
141# CONFIG_BF_REV_ANY is not set 132# CONFIG_BF_REV_ANY is not set
142# CONFIG_BF_REV_NONE is not set 133# CONFIG_BF_REV_NONE is not set
143CONFIG_BF53x=y 134CONFIG_BF53x=y
144CONFIG_BFIN_SINGLE_CORE=y
145CONFIG_MEM_MT48LC32M8A2_75=y 135CONFIG_MEM_MT48LC32M8A2_75=y
146CONFIG_IRQ_PLL_WAKEUP=7 136CONFIG_IRQ_PLL_WAKEUP=7
147CONFIG_IRQ_RTC=8 137CONFIG_IRQ_RTC=8
@@ -197,12 +187,14 @@ CONFIG_IRQ_PROG_INTA=12
197# Board customizations 187# Board customizations
198# 188#
199# CONFIG_CMDLINE_BOOL is not set 189# CONFIG_CMDLINE_BOOL is not set
190CONFIG_BOOT_LOAD=0x1000
200 191
201# 192#
202# Clock/PLL Setup 193# Clock/PLL Setup
203# 194#
204CONFIG_CLKIN_HZ=25000000 195CONFIG_CLKIN_HZ=25000000
205# CONFIG_BFIN_KERNEL_CLOCK is not set 196# CONFIG_BFIN_KERNEL_CLOCK is not set
197CONFIG_MAX_MEM_SIZE=512
206CONFIG_MAX_VCO_HZ=600000000 198CONFIG_MAX_VCO_HZ=600000000
207CONFIG_MIN_VCO_HZ=50000000 199CONFIG_MIN_VCO_HZ=50000000
208CONFIG_MAX_SCLK_HZ=133333333 200CONFIG_MAX_SCLK_HZ=133333333
@@ -216,13 +208,17 @@ CONFIG_HZ_250=y
216# CONFIG_HZ_300 is not set 208# CONFIG_HZ_300 is not set
217# CONFIG_HZ_1000 is not set 209# CONFIG_HZ_1000 is not set
218CONFIG_HZ=250 210CONFIG_HZ=250
211CONFIG_GENERIC_TIME=y
212CONFIG_GENERIC_CLOCKEVENTS=y
213# CONFIG_CYCLES_CLOCKSOURCE is not set
214CONFIG_TICK_ONESHOT=y
215# CONFIG_NO_HZ is not set
216CONFIG_HIGH_RES_TIMERS=y
217CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
219 218
220# 219#
221# Memory Setup 220# Misc
222# 221#
223CONFIG_MAX_MEM_SIZE=512
224CONFIG_MEM_ADD_WIDTH=10
225CONFIG_BOOT_LOAD=0x1000
226CONFIG_BFIN_SCRATCH_REG_RETN=y 222CONFIG_BFIN_SCRATCH_REG_RETN=y
227# CONFIG_BFIN_SCRATCH_REG_RETE is not set 223# CONFIG_BFIN_SCRATCH_REG_RETE is not set
228# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set 224# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -258,12 +254,14 @@ CONFIG_FLATMEM_MANUAL=y
258CONFIG_FLATMEM=y 254CONFIG_FLATMEM=y
259CONFIG_FLAT_NODE_MEM_MAP=y 255CONFIG_FLAT_NODE_MEM_MAP=y
260# CONFIG_SPARSEMEM_STATIC is not set 256# CONFIG_SPARSEMEM_STATIC is not set
257# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
261CONFIG_SPLIT_PTLOCK_CPUS=4 258CONFIG_SPLIT_PTLOCK_CPUS=4
262# CONFIG_RESOURCES_64BIT is not set 259# CONFIG_RESOURCES_64BIT is not set
263CONFIG_ZONE_DMA_FLAG=1 260CONFIG_ZONE_DMA_FLAG=1
264CONFIG_LARGE_ALLOCS=y 261CONFIG_VIRT_TO_BUS=y
265# CONFIG_BFIN_GPTIMERS is not set 262# CONFIG_BFIN_GPTIMERS is not set
266CONFIG_BFIN_DMA_5XX=y 263CONFIG_BFIN_DMA_5XX=y
264# CONFIG_DMA_UNCACHED_4M is not set
267# CONFIG_DMA_UNCACHED_2M is not set 265# CONFIG_DMA_UNCACHED_2M is not set
268CONFIG_DMA_UNCACHED_1M=y 266CONFIG_DMA_UNCACHED_1M=y
269# CONFIG_DMA_UNCACHED_NONE is not set 267# CONFIG_DMA_UNCACHED_NONE is not set
@@ -301,17 +299,13 @@ CONFIG_C_AMBEN_ALL=y
301CONFIG_BANK_0=0x7BB0 299CONFIG_BANK_0=0x7BB0
302CONFIG_BANK_1=0x7BB0 300CONFIG_BANK_1=0x7BB0
303CONFIG_BANK_2=0x7BB0 301CONFIG_BANK_2=0x7BB0
304CONFIG_BANK_3=0x99B3 302CONFIG_BANK_3=0x99B2
305 303
306# 304#
307# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 305# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
308# 306#
309# CONFIG_PCI is not set 307# CONFIG_PCI is not set
310# CONFIG_ARCH_SUPPORTS_MSI is not set 308# CONFIG_ARCH_SUPPORTS_MSI is not set
311
312#
313# PCCARD (PCMCIA/CardBus) support
314#
315# CONFIG_PCCARD is not set 309# CONFIG_PCCARD is not set
316 310
317# 311#
@@ -329,7 +323,9 @@ CONFIG_BINFMT_ZFLAT=y
329CONFIG_PM=y 323CONFIG_PM=y
330# CONFIG_PM_LEGACY is not set 324# CONFIG_PM_LEGACY is not set
331# CONFIG_PM_DEBUG is not set 325# CONFIG_PM_DEBUG is not set
332# CONFIG_PM_SYSFS_DEPRECATED is not set 326CONFIG_PM_SLEEP=y
327CONFIG_SUSPEND_UP_POSSIBLE=y
328CONFIG_SUSPEND=y
333CONFIG_PM_BFIN_SLEEP_DEEPER=y 329CONFIG_PM_BFIN_SLEEP_DEEPER=y
334# CONFIG_PM_BFIN_SLEEP is not set 330# CONFIG_PM_BFIN_SLEEP is not set
335# CONFIG_PM_WAKEUP_BY_GPIO is not set 331# CONFIG_PM_WAKEUP_BY_GPIO is not set
@@ -375,6 +371,7 @@ CONFIG_SYN_COOKIES=y
375CONFIG_INET_XFRM_MODE_TRANSPORT=y 371CONFIG_INET_XFRM_MODE_TRANSPORT=y
376CONFIG_INET_XFRM_MODE_TUNNEL=y 372CONFIG_INET_XFRM_MODE_TUNNEL=y
377CONFIG_INET_XFRM_MODE_BEET=y 373CONFIG_INET_XFRM_MODE_BEET=y
374# CONFIG_INET_LRO is not set
378CONFIG_INET_DIAG=y 375CONFIG_INET_DIAG=y
379CONFIG_INET_TCP_DIAG=y 376CONFIG_INET_TCP_DIAG=y
380# CONFIG_TCP_CONG_ADVANCED is not set 377# CONFIG_TCP_CONG_ADVANCED is not set
@@ -401,10 +398,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
401# CONFIG_LAPB is not set 398# CONFIG_LAPB is not set
402# CONFIG_ECONET is not set 399# CONFIG_ECONET is not set
403# CONFIG_WAN_ROUTER is not set 400# CONFIG_WAN_ROUTER is not set
404
405#
406# QoS and/or fair queueing
407#
408# CONFIG_NET_SCHED is not set 401# CONFIG_NET_SCHED is not set
409 402
410# 403#
@@ -436,6 +429,10 @@ CONFIG_IRDA_CACHE_LAST_LSAP=y
436# SIR device drivers 429# SIR device drivers
437# 430#
438CONFIG_IRTTY_SIR=m 431CONFIG_IRTTY_SIR=m
432CONFIG_BFIN_SIR=m
433CONFIG_BFIN_SIR1=y
434CONFIG_SIR_BFIN_DMA=y
435# CONFIG_SIR_BFIN_PIO is not set
439 436
440# 437#
441# Dongle support 438# Dongle support
@@ -465,6 +462,7 @@ CONFIG_IRTTY_SIR=m
465# CONFIG_MAC80211 is not set 462# CONFIG_MAC80211 is not set
466# CONFIG_IEEE80211 is not set 463# CONFIG_IEEE80211 is not set
467# CONFIG_RFKILL is not set 464# CONFIG_RFKILL is not set
465# CONFIG_NET_9P is not set
468 466
469# 467#
470# Device Drivers 468# Device Drivers
@@ -473,14 +471,11 @@ CONFIG_IRTTY_SIR=m
473# 471#
474# Generic Driver Options 472# Generic Driver Options
475# 473#
474CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
476CONFIG_STANDALONE=y 475CONFIG_STANDALONE=y
477CONFIG_PREVENT_FIRMWARE_BUILD=y 476CONFIG_PREVENT_FIRMWARE_BUILD=y
478# CONFIG_FW_LOADER is not set 477# CONFIG_FW_LOADER is not set
479# CONFIG_SYS_HYPERVISOR is not set 478# CONFIG_SYS_HYPERVISOR is not set
480
481#
482# Connector - unified userspace <-> kernelspace linker
483#
484# CONFIG_CONNECTOR is not set 479# CONFIG_CONNECTOR is not set
485CONFIG_MTD=y 480CONFIG_MTD=y
486# CONFIG_MTD_DEBUG is not set 481# CONFIG_MTD_DEBUG is not set
@@ -500,6 +495,7 @@ CONFIG_MTD_BLOCK=y
500# CONFIG_INFTL is not set 495# CONFIG_INFTL is not set
501# CONFIG_RFD_FTL is not set 496# CONFIG_RFD_FTL is not set
502# CONFIG_SSFDC is not set 497# CONFIG_SSFDC is not set
498# CONFIG_MTD_OOPS is not set
503 499
504# 500#
505# RAM/ROM/Flash chip drivers 501# RAM/ROM/Flash chip drivers
@@ -572,20 +568,8 @@ CONFIG_MTD_NAND_IDS=m
572# UBI - Unsorted block images 568# UBI - Unsorted block images
573# 569#
574# CONFIG_MTD_UBI is not set 570# CONFIG_MTD_UBI is not set
575
576#
577# Parallel port support
578#
579# CONFIG_PARPORT is not set 571# CONFIG_PARPORT is not set
580 572CONFIG_BLK_DEV=y
581#
582# Plug and Play support
583#
584# CONFIG_PNPACPI is not set
585
586#
587# Block devices
588#
589# CONFIG_BLK_DEV_COW_COMMON is not set 573# CONFIG_BLK_DEV_COW_COMMON is not set
590# CONFIG_BLK_DEV_LOOP is not set 574# CONFIG_BLK_DEV_LOOP is not set
591# CONFIG_BLK_DEV_NBD is not set 575# CONFIG_BLK_DEV_NBD is not set
@@ -595,10 +579,8 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
595CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 579CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
596# CONFIG_CDROM_PKTCDVD is not set 580# CONFIG_CDROM_PKTCDVD is not set
597# CONFIG_ATA_OVER_ETH is not set 581# CONFIG_ATA_OVER_ETH is not set
598 582CONFIG_MISC_DEVICES=y
599# 583# CONFIG_EEPROM_93CX6 is not set
600# Misc devices
601#
602# CONFIG_IDE is not set 584# CONFIG_IDE is not set
603 585
604# 586#
@@ -606,22 +588,18 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
606# 588#
607# CONFIG_RAID_ATTRS is not set 589# CONFIG_RAID_ATTRS is not set
608# CONFIG_SCSI is not set 590# CONFIG_SCSI is not set
591# CONFIG_SCSI_DMA is not set
609# CONFIG_SCSI_NETLINK is not set 592# CONFIG_SCSI_NETLINK is not set
610# CONFIG_ATA is not set 593# CONFIG_ATA is not set
611
612#
613# Multi-device support (RAID and LVM)
614#
615# CONFIG_MD is not set 594# CONFIG_MD is not set
616
617#
618# Network device support
619#
620CONFIG_NETDEVICES=y 595CONFIG_NETDEVICES=y
596# CONFIG_NETDEVICES_MULTIQUEUE is not set
621# CONFIG_DUMMY is not set 597# CONFIG_DUMMY is not set
622# CONFIG_BONDING is not set 598# CONFIG_BONDING is not set
599# CONFIG_MACVLAN is not set
623# CONFIG_EQUALIZER is not set 600# CONFIG_EQUALIZER is not set
624# CONFIG_TUN is not set 601# CONFIG_TUN is not set
602# CONFIG_VETH is not set
625CONFIG_PHYLIB=y 603CONFIG_PHYLIB=y
626 604
627# 605#
@@ -635,21 +613,24 @@ CONFIG_PHYLIB=y
635# CONFIG_VITESSE_PHY is not set 613# CONFIG_VITESSE_PHY is not set
636CONFIG_SMSC_PHY=y 614CONFIG_SMSC_PHY=y
637# CONFIG_BROADCOM_PHY is not set 615# CONFIG_BROADCOM_PHY is not set
616# CONFIG_ICPLUS_PHY is not set
638# CONFIG_FIXED_PHY is not set 617# CONFIG_FIXED_PHY is not set
639 618# CONFIG_MDIO_BITBANG is not set
640#
641# Ethernet (10 or 100Mbit)
642#
643CONFIG_NET_ETHERNET=y 619CONFIG_NET_ETHERNET=y
644CONFIG_MII=y 620CONFIG_MII=y
645# CONFIG_SMC91X is not set
646CONFIG_BFIN_MAC=y 621CONFIG_BFIN_MAC=y
647CONFIG_BFIN_MAC_USE_L1=y 622CONFIG_BFIN_MAC_USE_L1=y
648CONFIG_BFIN_TX_DESC_NUM=10 623CONFIG_BFIN_TX_DESC_NUM=10
649CONFIG_BFIN_RX_DESC_NUM=20 624CONFIG_BFIN_RX_DESC_NUM=20
650# CONFIG_BFIN_MAC_RMII is not set 625# CONFIG_BFIN_MAC_RMII is not set
626# CONFIG_SMC91X is not set
651# CONFIG_SMSC911X is not set 627# CONFIG_SMSC911X is not set
652# CONFIG_DM9000 is not set 628# CONFIG_DM9000 is not set
629# CONFIG_IBM_NEW_EMAC_ZMII is not set
630# CONFIG_IBM_NEW_EMAC_RGMII is not set
631# CONFIG_IBM_NEW_EMAC_TAH is not set
632# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
633# CONFIG_B44 is not set
653CONFIG_NETDEV_1000=y 634CONFIG_NETDEV_1000=y
654# CONFIG_AX88180 is not set 635# CONFIG_AX88180 is not set
655CONFIG_NETDEV_10000=y 636CONFIG_NETDEV_10000=y
@@ -666,15 +647,7 @@ CONFIG_NETDEV_10000=y
666# CONFIG_NETCONSOLE is not set 647# CONFIG_NETCONSOLE is not set
667# CONFIG_NETPOLL is not set 648# CONFIG_NETPOLL is not set
668# CONFIG_NET_POLL_CONTROLLER is not set 649# CONFIG_NET_POLL_CONTROLLER is not set
669
670#
671# ISDN subsystem
672#
673# CONFIG_ISDN is not set 650# CONFIG_ISDN is not set
674
675#
676# Telephony Support
677#
678# CONFIG_PHONE is not set 651# CONFIG_PHONE is not set
679 652
680# 653#
@@ -689,7 +662,6 @@ CONFIG_INPUT=y
689# 662#
690# CONFIG_INPUT_MOUSEDEV is not set 663# CONFIG_INPUT_MOUSEDEV is not set
691# CONFIG_INPUT_JOYDEV is not set 664# CONFIG_INPUT_JOYDEV is not set
692# CONFIG_INPUT_TSDEV is not set
693CONFIG_INPUT_EVDEV=m 665CONFIG_INPUT_EVDEV=m
694# CONFIG_INPUT_EVBUG is not set 666# CONFIG_INPUT_EVBUG is not set
695 667
@@ -702,14 +674,8 @@ CONFIG_INPUT_EVDEV=m
702# CONFIG_INPUT_TABLET is not set 674# CONFIG_INPUT_TABLET is not set
703# CONFIG_INPUT_TOUCHSCREEN is not set 675# CONFIG_INPUT_TOUCHSCREEN is not set
704CONFIG_INPUT_MISC=y 676CONFIG_INPUT_MISC=y
705# CONFIG_INPUT_ATI_REMOTE is not set
706# CONFIG_INPUT_ATI_REMOTE2 is not set
707# CONFIG_INPUT_KEYSPAN_REMOTE is not set
708# CONFIG_INPUT_POWERMATE is not set
709# CONFIG_INPUT_YEALINK is not set
710# CONFIG_INPUT_UINPUT is not set 677# CONFIG_INPUT_UINPUT is not set
711CONFIG_TWI_KEYPAD=m 678CONFIG_TWI_KEYPAD=m
712CONFIG_BFIN_TWIKEYPAD_IRQ_PFX=72
713 679
714# 680#
715# Hardware I/O ports 681# Hardware I/O ports
@@ -722,15 +688,13 @@ CONFIG_BFIN_TWIKEYPAD_IRQ_PFX=72
722# 688#
723# CONFIG_AD9960 is not set 689# CONFIG_AD9960 is not set
724# CONFIG_SPI_ADC_BF533 is not set 690# CONFIG_SPI_ADC_BF533 is not set
725# CONFIG_BF5xx_PFLAGS is not set
726# CONFIG_BF5xx_PPIFCD is not set 691# CONFIG_BF5xx_PPIFCD is not set
727# CONFIG_BFIN_SIMPLE_TIMER is not set 692# CONFIG_BFIN_SIMPLE_TIMER is not set
728# CONFIG_BF5xx_PPI is not set 693# CONFIG_BF5xx_PPI is not set
729CONFIG_BFIN_SPORT=y 694CONFIG_BFIN_SPORT=y
730# CONFIG_BFIN_TIMER_LATENCY is not set 695# CONFIG_BFIN_TIMER_LATENCY is not set
731CONFIG_TWI_LCD=m 696CONFIG_TWI_LCD=m
732CONFIG_TWI_LCD_SLAVE_ADDR=34 697CONFIG_SIMPLE_GPIO=m
733# CONFIG_AD5304 is not set
734# CONFIG_VT is not set 698# CONFIG_VT is not set
735# CONFIG_SERIAL_NONSTANDARD is not set 699# CONFIG_SERIAL_NONSTANDARD is not set
736 700
@@ -766,28 +730,11 @@ CONFIG_CAN4LINUX=y
766# CONFIG_CAN_MCF5282 is not set 730# CONFIG_CAN_MCF5282 is not set
767# CONFIG_CAN_UNCTWINCAN is not set 731# CONFIG_CAN_UNCTWINCAN is not set
768CONFIG_CAN_BLACKFIN=m 732CONFIG_CAN_BLACKFIN=m
769
770#
771# IPMI
772#
773# CONFIG_IPMI_HANDLER is not set 733# CONFIG_IPMI_HANDLER is not set
774CONFIG_WATCHDOG=y
775# CONFIG_WATCHDOG_NOWAYOUT is not set
776
777#
778# Watchdog Device Drivers
779#
780# CONFIG_SOFT_WATCHDOG is not set
781CONFIG_BFIN_WDT=y
782CONFIG_HW_RANDOM=y 734CONFIG_HW_RANDOM=y
783# CONFIG_GEN_RTC is not set 735# CONFIG_GEN_RTC is not set
784CONFIG_BLACKFIN_DPMC=y
785# CONFIG_R3964 is not set 736# CONFIG_R3964 is not set
786# CONFIG_RAW_DRIVER is not set 737# CONFIG_RAW_DRIVER is not set
787
788#
789# TPM devices
790#
791# CONFIG_TCG_TPM is not set 738# CONFIG_TCG_TPM is not set
792CONFIG_I2C=m 739CONFIG_I2C=m
793CONFIG_I2C_BOARDINFO=y 740CONFIG_I2C_BOARDINFO=y
@@ -809,6 +756,7 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50
809# CONFIG_I2C_OCORES is not set 756# CONFIG_I2C_OCORES is not set
810# CONFIG_I2C_PARPORT_LIGHT is not set 757# CONFIG_I2C_PARPORT_LIGHT is not set
811# CONFIG_I2C_SIMTEC is not set 758# CONFIG_I2C_SIMTEC is not set
759# CONFIG_I2C_TAOS_EVM is not set
812# CONFIG_I2C_STUB is not set 760# CONFIG_I2C_STUB is not set
813 761
814# 762#
@@ -816,14 +764,15 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50
816# 764#
817# CONFIG_SENSORS_DS1337 is not set 765# CONFIG_SENSORS_DS1337 is not set
818# CONFIG_SENSORS_DS1374 is not set 766# CONFIG_SENSORS_DS1374 is not set
767# CONFIG_DS1682 is not set
819CONFIG_SENSORS_AD5252=m 768CONFIG_SENSORS_AD5252=m
820# CONFIG_SENSORS_EEPROM is not set 769# CONFIG_SENSORS_EEPROM is not set
821# CONFIG_SENSORS_PCF8574 is not set 770# CONFIG_SENSORS_PCF8574 is not set
822# CONFIG_SENSORS_PCF8575 is not set 771# CONFIG_SENSORS_PCF8575 is not set
823# CONFIG_SENSORS_PCA9543 is not set
824# CONFIG_SENSORS_PCA9539 is not set 772# CONFIG_SENSORS_PCA9539 is not set
825# CONFIG_SENSORS_PCF8591 is not set 773# CONFIG_SENSORS_PCF8591 is not set
826# CONFIG_SENSORS_MAX6875 is not set 774# CONFIG_SENSORS_MAX6875 is not set
775# CONFIG_SENSORS_TSL2550 is not set
827# CONFIG_I2C_DEBUG_CORE is not set 776# CONFIG_I2C_DEBUG_CORE is not set
828# CONFIG_I2C_DEBUG_ALGO is not set 777# CONFIG_I2C_DEBUG_ALGO is not set
829# CONFIG_I2C_DEBUG_BUS is not set 778# CONFIG_I2C_DEBUG_BUS is not set
@@ -846,14 +795,11 @@ CONFIG_SPI_BFIN=y
846# 795#
847# CONFIG_SPI_AT25 is not set 796# CONFIG_SPI_AT25 is not set
848# CONFIG_SPI_SPIDEV is not set 797# CONFIG_SPI_SPIDEV is not set
849 798# CONFIG_SPI_TLE62X0 is not set
850#
851# Dallas's 1-wire bus
852#
853# CONFIG_W1 is not set 799# CONFIG_W1 is not set
800# CONFIG_POWER_SUPPLY is not set
854CONFIG_HWMON=y 801CONFIG_HWMON=y
855# CONFIG_HWMON_VID is not set 802# CONFIG_HWMON_VID is not set
856# CONFIG_SENSORS_ABITUGURU is not set
857# CONFIG_SENSORS_AD7418 is not set 803# CONFIG_SENSORS_AD7418 is not set
858# CONFIG_SENSORS_ADM1021 is not set 804# CONFIG_SENSORS_ADM1021 is not set
859# CONFIG_SENSORS_ADM1025 is not set 805# CONFIG_SENSORS_ADM1025 is not set
@@ -861,12 +807,12 @@ CONFIG_HWMON=y
861# CONFIG_SENSORS_ADM1029 is not set 807# CONFIG_SENSORS_ADM1029 is not set
862# CONFIG_SENSORS_ADM1031 is not set 808# CONFIG_SENSORS_ADM1031 is not set
863# CONFIG_SENSORS_ADM9240 is not set 809# CONFIG_SENSORS_ADM9240 is not set
864# CONFIG_SENSORS_ASB100 is not set 810# CONFIG_SENSORS_ADT7470 is not set
865# CONFIG_SENSORS_ATXP1 is not set 811# CONFIG_SENSORS_ATXP1 is not set
866# CONFIG_SENSORS_DS1621 is not set 812# CONFIG_SENSORS_DS1621 is not set
867# CONFIG_SENSORS_F71805F is not set 813# CONFIG_SENSORS_F71805F is not set
868# CONFIG_SENSORS_FSCHER is not set 814# CONFIG_SENSORS_F71882FG is not set
869# CONFIG_SENSORS_FSCPOS is not set 815# CONFIG_SENSORS_F75375S is not set
870# CONFIG_SENSORS_GL518SM is not set 816# CONFIG_SENSORS_GL518SM is not set
871# CONFIG_SENSORS_GL520SM is not set 817# CONFIG_SENSORS_GL520SM is not set
872# CONFIG_SENSORS_IT87 is not set 818# CONFIG_SENSORS_IT87 is not set
@@ -881,13 +827,16 @@ CONFIG_HWMON=y
881# CONFIG_SENSORS_LM87 is not set 827# CONFIG_SENSORS_LM87 is not set
882# CONFIG_SENSORS_LM90 is not set 828# CONFIG_SENSORS_LM90 is not set
883# CONFIG_SENSORS_LM92 is not set 829# CONFIG_SENSORS_LM92 is not set
830# CONFIG_SENSORS_LM93 is not set
884# CONFIG_SENSORS_MAX1619 is not set 831# CONFIG_SENSORS_MAX1619 is not set
885# CONFIG_SENSORS_MAX6650 is not set 832# CONFIG_SENSORS_MAX6650 is not set
886# CONFIG_SENSORS_PC87360 is not set 833# CONFIG_SENSORS_PC87360 is not set
887# CONFIG_SENSORS_PC87427 is not set 834# CONFIG_SENSORS_PC87427 is not set
835# CONFIG_SENSORS_DME1737 is not set
888# CONFIG_SENSORS_SMSC47M1 is not set 836# CONFIG_SENSORS_SMSC47M1 is not set
889# CONFIG_SENSORS_SMSC47M192 is not set 837# CONFIG_SENSORS_SMSC47M192 is not set
890# CONFIG_SENSORS_SMSC47B397 is not set 838# CONFIG_SENSORS_SMSC47B397 is not set
839# CONFIG_SENSORS_THMC50 is not set
891# CONFIG_SENSORS_VT1211 is not set 840# CONFIG_SENSORS_VT1211 is not set
892# CONFIG_SENSORS_W83781D is not set 841# CONFIG_SENSORS_W83781D is not set
893# CONFIG_SENSORS_W83791D is not set 842# CONFIG_SENSORS_W83791D is not set
@@ -897,6 +846,20 @@ CONFIG_HWMON=y
897# CONFIG_SENSORS_W83627HF is not set 846# CONFIG_SENSORS_W83627HF is not set
898# CONFIG_SENSORS_W83627EHF is not set 847# CONFIG_SENSORS_W83627EHF is not set
899# CONFIG_HWMON_DEBUG_CHIP is not set 848# CONFIG_HWMON_DEBUG_CHIP is not set
849CONFIG_WATCHDOG=y
850# CONFIG_WATCHDOG_NOWAYOUT is not set
851
852#
853# Watchdog Device Drivers
854#
855# CONFIG_SOFT_WATCHDOG is not set
856CONFIG_BFIN_WDT=y
857
858#
859# Sonics Silicon Backplane
860#
861CONFIG_SSB_POSSIBLE=y
862# CONFIG_SSB is not set
900 863
901# 864#
902# Multifunction device drivers 865# Multifunction device drivers
@@ -913,21 +876,15 @@ CONFIG_DAB=y
913# 876#
914# Graphics support 877# Graphics support
915# 878#
916CONFIG_BACKLIGHT_LCD_SUPPORT=y
917CONFIG_BACKLIGHT_CLASS_DEVICE=m
918CONFIG_LCD_CLASS_DEVICE=m
919
920#
921# Display device support
922#
923# CONFIG_DISPLAY_SUPPORT is not set
924# CONFIG_VGASTATE is not set 879# CONFIG_VGASTATE is not set
880# CONFIG_VIDEO_OUTPUT_CONTROL is not set
925CONFIG_FB=m 881CONFIG_FB=m
926CONFIG_FIRMWARE_EDID=y 882CONFIG_FIRMWARE_EDID=y
927# CONFIG_FB_DDC is not set 883# CONFIG_FB_DDC is not set
928CONFIG_FB_CFB_FILLRECT=m 884CONFIG_FB_CFB_FILLRECT=m
929CONFIG_FB_CFB_COPYAREA=m 885CONFIG_FB_CFB_COPYAREA=m
930CONFIG_FB_CFB_IMAGEBLIT=m 886CONFIG_FB_CFB_IMAGEBLIT=m
887# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
931# CONFIG_FB_SYS_FILLRECT is not set 888# CONFIG_FB_SYS_FILLRECT is not set
932# CONFIG_FB_SYS_COPYAREA is not set 889# CONFIG_FB_SYS_COPYAREA is not set
933# CONFIG_FB_SYS_IMAGEBLIT is not set 890# CONFIG_FB_SYS_IMAGEBLIT is not set
@@ -942,7 +899,8 @@ CONFIG_FB_DEFERRED_IO=y
942# 899#
943# Frame buffer hardware drivers 900# Frame buffer hardware drivers
944# 901#
945CONFIG_FB_BFIN_7171=m 902# CONFIG_FB_HITACHI_TX09 is not set
903# CONFIG_FB_BFIN_T350MCQB is not set
946CONFIG_FB_BFIN_7393=m 904CONFIG_FB_BFIN_7393=m
947CONFIG_NTSC=y 905CONFIG_NTSC=y
948# CONFIG_PAL is not set 906# CONFIG_PAL is not set
@@ -956,10 +914,18 @@ CONFIG_FB_BF537_LQ035=m
956CONFIG_LQ035_SLAVE_ADDR=0x58 914CONFIG_LQ035_SLAVE_ADDR=0x58
957# CONFIG_FB_BFIN_LANDSCAPE is not set 915# CONFIG_FB_BFIN_LANDSCAPE is not set
958# CONFIG_FB_BFIN_BGR is not set 916# CONFIG_FB_BFIN_BGR is not set
959# CONFIG_FB_BFIN_T350MCQB is not set
960# CONFIG_FB_HITACHI_TX09 is not set
961# CONFIG_FB_S1D13XXX is not set 917# CONFIG_FB_S1D13XXX is not set
962# CONFIG_FB_VIRTUAL is not set 918# CONFIG_FB_VIRTUAL is not set
919CONFIG_BACKLIGHT_LCD_SUPPORT=y
920CONFIG_LCD_CLASS_DEVICE=m
921# CONFIG_LCD_LTV350QV is not set
922CONFIG_BACKLIGHT_CLASS_DEVICE=m
923CONFIG_BACKLIGHT_CORGI=m
924
925#
926# Display device support
927#
928# CONFIG_DISPLAY_SUPPORT is not set
963# CONFIG_LOGO is not set 929# CONFIG_LOGO is not set
964 930
965# 931#
@@ -993,6 +959,10 @@ CONFIG_SND_VERBOSE_PROCFS=y
993# CONFIG_SND_MPU401 is not set 959# CONFIG_SND_MPU401 is not set
994 960
995# 961#
962# SPI devices
963#
964
965#
996# ALSA Blackfin devices 966# ALSA Blackfin devices
997# 967#
998CONFIG_SND_BLACKFIN_AD1836=m 968CONFIG_SND_BLACKFIN_AD1836=m
@@ -1005,6 +975,10 @@ CONFIG_SND_BLACKFIN_SPI_PFBIT=4
1005CONFIG_SND_BFIN_AD73311=m 975CONFIG_SND_BFIN_AD73311=m
1006CONFIG_SND_BFIN_SPORT=0 976CONFIG_SND_BFIN_SPORT=0
1007CONFIG_SND_BFIN_AD73311_SE=4 977CONFIG_SND_BFIN_AD73311_SE=4
978CONFIG_SND_BFIN_AD73322=m
979CONFIG_SND_BFIN_AD73322_SPORT0_SE=10
980CONFIG_SND_BFIN_AD73322_SPORT1_SE=14
981CONFIG_SND_BFIN_AD73322_RESET=12
1008 982
1009# 983#
1010# System on Chip audio support 984# System on Chip audio support
@@ -1016,9 +990,14 @@ CONFIG_SND_MMAP_SUPPORT=y
1016CONFIG_SND_BF5XX_SOC_AC97=m 990CONFIG_SND_BF5XX_SOC_AC97=m
1017# CONFIG_SND_BF5XX_SOC_WM8750 is not set 991# CONFIG_SND_BF5XX_SOC_WM8750 is not set
1018# CONFIG_SND_BF5XX_SOC_WM8731 is not set 992# CONFIG_SND_BF5XX_SOC_WM8731 is not set
993# CONFIG_SND_BF5XX_SOC_SSM2602 is not set
1019CONFIG_SND_BF5XX_SOC_BF5xx=m 994CONFIG_SND_BF5XX_SOC_BF5xx=m
1020CONFIG_SND_BF5XX_SPORT_NUM=0 995CONFIG_SND_BF5XX_SPORT_NUM=0
1021# CONFIG_SND_BF5XX_HAVE_COLD_RESET is not set 996# CONFIG_SND_BF5XX_HAVE_COLD_RESET is not set
997
998#
999# SoC Audio support for SuperH
1000#
1022CONFIG_SND_SOC_AD1980=m 1001CONFIG_SND_SOC_AD1980=m
1023 1002
1024# 1003#
@@ -1026,59 +1005,18 @@ CONFIG_SND_SOC_AD1980=m
1026# 1005#
1027# CONFIG_SOUND_PRIME is not set 1006# CONFIG_SOUND_PRIME is not set
1028CONFIG_AC97_BUS=m 1007CONFIG_AC97_BUS=m
1029 1008CONFIG_HID_SUPPORT=y
1030#
1031# HID Devices
1032#
1033CONFIG_HID=y 1009CONFIG_HID=y
1034# CONFIG_HID_DEBUG is not set 1010# CONFIG_HID_DEBUG is not set
1035 1011# CONFIG_HIDRAW is not set
1036# 1012# CONFIG_USB_SUPPORT is not set
1037# USB support 1013# CONFIG_NO_DUMMY_DELAY is not set
1038# 1014# CONFIG_DUMMY_DELAY_BANK0 is not set
1039CONFIG_USB_ARCH_HAS_HCD=y 1015# CONFIG_DUMMY_DELAY_BANK1 is not set
1040# CONFIG_USB_ARCH_HAS_OHCI is not set 1016# CONFIG_DUMMY_DELAY_BANK2 is not set
1041# CONFIG_USB_ARCH_HAS_EHCI is not set 1017# CONFIG_DUMMY_DELAY_BANK3 is not set
1042# CONFIG_USB is not set
1043
1044#
1045# Enable Host or Gadget support to see Inventra options
1046#
1047
1048#
1049# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1050#
1051
1052#
1053# USB Gadget Support
1054#
1055# CONFIG_USB_GADGET is not set
1056# CONFIG_MMC is not set 1018# CONFIG_MMC is not set
1057
1058#
1059# LED devices
1060#
1061# CONFIG_NEW_LEDS is not set 1019# CONFIG_NEW_LEDS is not set
1062
1063#
1064# LED drivers
1065#
1066
1067#
1068# LED Triggers
1069#
1070
1071#
1072# InfiniBand support
1073#
1074
1075#
1076# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1077#
1078
1079#
1080# Real Time Clock
1081#
1082CONFIG_RTC_LIB=y 1020CONFIG_RTC_LIB=y
1083CONFIG_RTC_CLASS=y 1021CONFIG_RTC_CLASS=y
1084CONFIG_RTC_HCTOSYS=y 1022CONFIG_RTC_HCTOSYS=y
@@ -1098,6 +1036,7 @@ CONFIG_RTC_INTF_DEV=y
1098# I2C RTC drivers 1036# I2C RTC drivers
1099# 1037#
1100# CONFIG_RTC_DRV_DS1307 is not set 1038# CONFIG_RTC_DRV_DS1307 is not set
1039# CONFIG_RTC_DRV_DS1374 is not set
1101# CONFIG_RTC_DRV_DS1672 is not set 1040# CONFIG_RTC_DRV_DS1672 is not set
1102# CONFIG_RTC_DRV_MAX6900 is not set 1041# CONFIG_RTC_DRV_MAX6900 is not set
1103# CONFIG_RTC_DRV_RS5C372 is not set 1042# CONFIG_RTC_DRV_RS5C372 is not set
@@ -1105,6 +1044,7 @@ CONFIG_RTC_INTF_DEV=y
1105# CONFIG_RTC_DRV_X1205 is not set 1044# CONFIG_RTC_DRV_X1205 is not set
1106# CONFIG_RTC_DRV_PCF8563 is not set 1045# CONFIG_RTC_DRV_PCF8563 is not set
1107# CONFIG_RTC_DRV_PCF8583 is not set 1046# CONFIG_RTC_DRV_PCF8583 is not set
1047# CONFIG_RTC_DRV_M41T80 is not set
1108 1048
1109# 1049#
1110# SPI RTC drivers 1050# SPI RTC drivers
@@ -1116,8 +1056,10 @@ CONFIG_RTC_INTF_DEV=y
1116# Platform RTC drivers 1056# Platform RTC drivers
1117# 1057#
1118# CONFIG_RTC_DRV_DS1553 is not set 1058# CONFIG_RTC_DRV_DS1553 is not set
1059# CONFIG_RTC_DRV_STK17TA8 is not set
1119# CONFIG_RTC_DRV_DS1742 is not set 1060# CONFIG_RTC_DRV_DS1742 is not set
1120# CONFIG_RTC_DRV_M48T86 is not set 1061# CONFIG_RTC_DRV_M48T86 is not set
1062# CONFIG_RTC_DRV_M48T59 is not set
1121# CONFIG_RTC_DRV_V3020 is not set 1063# CONFIG_RTC_DRV_V3020 is not set
1122 1064
1123# 1065#
@@ -1126,22 +1068,9 @@ CONFIG_RTC_INTF_DEV=y
1126CONFIG_RTC_DRV_BFIN=y 1068CONFIG_RTC_DRV_BFIN=y
1127 1069
1128# 1070#
1129# DMA Engine support 1071# Userspace I/O
1130# 1072#
1131# CONFIG_DMA_ENGINE is not set 1073# CONFIG_UIO is not set
1132
1133#
1134# DMA Clients
1135#
1136
1137#
1138# DMA Devices
1139#
1140
1141#
1142# PBX support
1143#
1144# CONFIG_PBX is not set
1145 1074
1146# 1075#
1147# File systems 1076# File systems
@@ -1186,7 +1115,6 @@ CONFIG_PROC_SYSCTL=y
1186CONFIG_SYSFS=y 1115CONFIG_SYSFS=y
1187# CONFIG_TMPFS is not set 1116# CONFIG_TMPFS is not set
1188# CONFIG_HUGETLB_PAGE is not set 1117# CONFIG_HUGETLB_PAGE is not set
1189CONFIG_RAMFS=y
1190# CONFIG_CONFIGFS_FS is not set 1118# CONFIG_CONFIGFS_FS is not set
1191 1119
1192# 1120#
@@ -1212,10 +1140,12 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
1212CONFIG_JFFS2_FS=m 1140CONFIG_JFFS2_FS=m
1213CONFIG_JFFS2_FS_DEBUG=0 1141CONFIG_JFFS2_FS_DEBUG=0
1214CONFIG_JFFS2_FS_WRITEBUFFER=y 1142CONFIG_JFFS2_FS_WRITEBUFFER=y
1143# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1215# CONFIG_JFFS2_SUMMARY is not set 1144# CONFIG_JFFS2_SUMMARY is not set
1216# CONFIG_JFFS2_FS_XATTR is not set 1145# CONFIG_JFFS2_FS_XATTR is not set
1217# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 1146# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1218CONFIG_JFFS2_ZLIB=y 1147CONFIG_JFFS2_ZLIB=y
1148# CONFIG_JFFS2_LZO is not set
1219CONFIG_JFFS2_RTIME=y 1149CONFIG_JFFS2_RTIME=y
1220# CONFIG_JFFS2_RUBIN is not set 1150# CONFIG_JFFS2_RUBIN is not set
1221# CONFIG_CRAMFS is not set 1151# CONFIG_CRAMFS is not set
@@ -1224,10 +1154,7 @@ CONFIG_JFFS2_RTIME=y
1224# CONFIG_QNX4FS_FS is not set 1154# CONFIG_QNX4FS_FS is not set
1225# CONFIG_SYSV_FS is not set 1155# CONFIG_SYSV_FS is not set
1226# CONFIG_UFS_FS is not set 1156# CONFIG_UFS_FS is not set
1227 1157CONFIG_NETWORK_FILESYSTEMS=y
1228#
1229# Network File Systems
1230#
1231CONFIG_NFS_FS=m 1158CONFIG_NFS_FS=m
1232CONFIG_NFS_V3=y 1159CONFIG_NFS_V3=y
1233# CONFIG_NFS_V3_ACL is not set 1160# CONFIG_NFS_V3_ACL is not set
@@ -1247,17 +1174,12 @@ CONFIG_SMB_FS=m
1247# CONFIG_NCP_FS is not set 1174# CONFIG_NCP_FS is not set
1248# CONFIG_CODA_FS is not set 1175# CONFIG_CODA_FS is not set
1249# CONFIG_AFS_FS is not set 1176# CONFIG_AFS_FS is not set
1250# CONFIG_9P_FS is not set
1251 1177
1252# 1178#
1253# Partition Types 1179# Partition Types
1254# 1180#
1255# CONFIG_PARTITION_ADVANCED is not set 1181# CONFIG_PARTITION_ADVANCED is not set
1256CONFIG_MSDOS_PARTITION=y 1182CONFIG_MSDOS_PARTITION=y
1257
1258#
1259# Native Language Support
1260#
1261CONFIG_NLS=m 1183CONFIG_NLS=m
1262CONFIG_NLS_DEFAULT="iso8859-1" 1184CONFIG_NLS_DEFAULT="iso8859-1"
1263# CONFIG_NLS_CODEPAGE_437 is not set 1185# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1298,21 +1220,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1298# CONFIG_NLS_KOI8_R is not set 1220# CONFIG_NLS_KOI8_R is not set
1299# CONFIG_NLS_KOI8_U is not set 1221# CONFIG_NLS_KOI8_U is not set
1300# CONFIG_NLS_UTF8 is not set 1222# CONFIG_NLS_UTF8 is not set
1301
1302#
1303# Distributed Lock Manager
1304#
1305# CONFIG_DLM is not set 1223# CONFIG_DLM is not set
1306 1224CONFIG_INSTRUMENTATION=y
1307#
1308# Profiling support
1309#
1310# CONFIG_PROFILING is not set 1225# CONFIG_PROFILING is not set
1226# CONFIG_MARKERS is not set
1311 1227
1312# 1228#
1313# Kernel hacking 1229# Kernel hacking
1314# 1230#
1315# CONFIG_PRINTK_TIME is not set 1231# CONFIG_PRINTK_TIME is not set
1232CONFIG_ENABLE_WARN_DEPRECATED=y
1316CONFIG_ENABLE_MUST_CHECK=y 1233CONFIG_ENABLE_MUST_CHECK=y
1317# CONFIG_MAGIC_SYSRQ is not set 1234# CONFIG_MAGIC_SYSRQ is not set
1318# CONFIG_UNUSED_SYMBOLS is not set 1235# CONFIG_UNUSED_SYMBOLS is not set
@@ -1320,6 +1237,7 @@ CONFIG_DEBUG_FS=y
1320# CONFIG_HEADERS_CHECK is not set 1237# CONFIG_HEADERS_CHECK is not set
1321# CONFIG_DEBUG_KERNEL is not set 1238# CONFIG_DEBUG_KERNEL is not set
1322# CONFIG_DEBUG_BUGVERBOSE is not set 1239# CONFIG_DEBUG_BUGVERBOSE is not set
1240# CONFIG_SAMPLES is not set
1323CONFIG_DEBUG_MMRS=y 1241CONFIG_DEBUG_MMRS=y
1324CONFIG_DEBUG_HUNT_FOR_ZERO=y 1242CONFIG_DEBUG_HUNT_FOR_ZERO=y
1325CONFIG_DEBUG_BFIN_HWTRACE_ON=y 1243CONFIG_DEBUG_BFIN_HWTRACE_ON=y
@@ -1339,11 +1257,7 @@ CONFIG_ACCESS_CHECK=y
1339# CONFIG_KEYS is not set 1257# CONFIG_KEYS is not set
1340CONFIG_SECURITY=y 1258CONFIG_SECURITY=y
1341# CONFIG_SECURITY_NETWORK is not set 1259# CONFIG_SECURITY_NETWORK is not set
1342CONFIG_SECURITY_CAPABILITIES=m 1260# CONFIG_SECURITY_CAPABILITIES is not set
1343
1344#
1345# Cryptographic options
1346#
1347# CONFIG_CRYPTO is not set 1261# CONFIG_CRYPTO is not set
1348 1262
1349# 1263#
@@ -1354,6 +1268,7 @@ CONFIG_CRC_CCITT=m
1354# CONFIG_CRC16 is not set 1268# CONFIG_CRC16 is not set
1355# CONFIG_CRC_ITU_T is not set 1269# CONFIG_CRC_ITU_T is not set
1356CONFIG_CRC32=y 1270CONFIG_CRC32=y
1271# CONFIG_CRC7 is not set
1357# CONFIG_LIBCRC32C is not set 1272# CONFIG_LIBCRC32C is not set
1358CONFIG_ZLIB_INFLATE=y 1273CONFIG_ZLIB_INFLATE=y
1359CONFIG_ZLIB_DEFLATE=m 1274CONFIG_ZLIB_DEFLATE=m
diff --git a/arch/blackfin/configs/BF548-EZKIT_defconfig b/arch/blackfin/configs/BF548-EZKIT_defconfig
index 1ff2ff4b49aa..390669e8668e 100644
--- a/arch/blackfin/configs/BF548-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF548-EZKIT_defconfig
@@ -365,7 +365,7 @@ CONFIG_C_AMBEN_ALL=y
365CONFIG_BANK_0=0x7BB0 365CONFIG_BANK_0=0x7BB0
366CONFIG_BANK_1=0x5554 366CONFIG_BANK_1=0x5554
367CONFIG_BANK_2=0x7BB0 367CONFIG_BANK_2=0x7BB0
368CONFIG_BANK_3=0x99B3 368CONFIG_BANK_3=0x99B2
369CONFIG_EBIU_MBSCTLVAL=0x0 369CONFIG_EBIU_MBSCTLVAL=0x0
370CONFIG_EBIU_MODEVAL=0x1 370CONFIG_EBIU_MODEVAL=0x1
371CONFIG_EBIU_FCTLVAL=0x6 371CONFIG_EBIU_FCTLVAL=0x6
@@ -468,7 +468,60 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
468# 468#
469# CONFIG_NET_PKTGEN is not set 469# CONFIG_NET_PKTGEN is not set
470# CONFIG_HAMRADIO is not set 470# CONFIG_HAMRADIO is not set
471# CONFIG_IRDA is not set 471CONFIG_IRDA=m
472
473#
474# IrDA protocols
475#
476CONFIG_IRLAN=m
477CONFIG_IRCOMM=m
478# CONFIG_IRDA_ULTRA is not set
479
480#
481# IrDA options
482#
483# CONFIG_IRDA_CACHE_LAST_LSAP is not set
484# CONFIG_IRDA_FAST_RR is not set
485# CONFIG_IRDA_DEBUG is not set
486
487#
488# Infrared-port device drivers
489#
490
491#
492# SIR device drivers
493#
494CONFIG_IRTTY_SIR=m
495CONFIG_BFIN_SIR=m
496# CONFIG_BFIN_SIR0 is not set
497# CONFIG_BFIN_SIR2 is not set
498CONFIG_BFIN_SIR3=y
499CONFIG_SIR_BFIN_DMA=y
500# CONFIG_SIR_BFIN_PIO is not set
501
502#
503# Dongle support
504#
505# CONFIG_DONGLE is not set
506# CONFIG_KINGSUN_DONGLE is not set
507# CONFIG_KSDAZZLE_DONGLE is not set
508# CONFIG_KS959_DONGLE is not set
509
510#
511# Old SIR device drivers
512#
513# CONFIG_IRPORT_SIR is not set
514
515#
516# Old Serial dongle support
517#
518
519#
520# FIR device drivers
521#
522# CONFIG_USB_IRDA is not set
523# CONFIG_SIGMATEL_FIR is not set
524# CONFIG_MCS_FIR is not set
472# CONFIG_BT is not set 525# CONFIG_BT is not set
473# CONFIG_AF_RXRPC is not set 526# CONFIG_AF_RXRPC is not set
474 527
@@ -575,6 +628,7 @@ CONFIG_MTD_NAND=y
575CONFIG_MTD_NAND_IDS=y 628CONFIG_MTD_NAND_IDS=y
576CONFIG_MTD_NAND_BF5XX=y 629CONFIG_MTD_NAND_BF5XX=y
577CONFIG_MTD_NAND_BF5XX_HWECC=y 630CONFIG_MTD_NAND_BF5XX_HWECC=y
631# CONFIG_MTD_NAND_BF5XX_BOOTROM_ECC is not set
578# CONFIG_MTD_NAND_DISKONCHIP is not set 632# CONFIG_MTD_NAND_DISKONCHIP is not set
579# CONFIG_MTD_NAND_NANDSIM is not set 633# CONFIG_MTD_NAND_NANDSIM is not set
580# CONFIG_MTD_NAND_PLATFORM is not set 634# CONFIG_MTD_NAND_PLATFORM is not set
@@ -766,7 +820,7 @@ CONFIG_BFIN_OTP=y
766# CONFIG_BFIN_SPORT is not set 820# CONFIG_BFIN_SPORT is not set
767# CONFIG_BFIN_TIMER_LATENCY is not set 821# CONFIG_BFIN_TIMER_LATENCY is not set
768# CONFIG_TWI_LCD is not set 822# CONFIG_TWI_LCD is not set
769# CONFIG_SIMPLE_GPIO is not set 823CONFIG_SIMPLE_GPIO=m
770CONFIG_VT=y 824CONFIG_VT=y
771CONFIG_VT_CONSOLE=y 825CONFIG_VT_CONSOLE=y
772CONFIG_HW_CONSOLE=y 826CONFIG_HW_CONSOLE=y
@@ -1071,6 +1125,7 @@ CONFIG_SND_BF5XX_SOC_AC97=y
1071CONFIG_SND_BF5XX_SOC_BF548_EZKIT=y 1125CONFIG_SND_BF5XX_SOC_BF548_EZKIT=y
1072# CONFIG_SND_BF5XX_SOC_WM8750 is not set 1126# CONFIG_SND_BF5XX_SOC_WM8750 is not set
1073# CONFIG_SND_BF5XX_SOC_WM8731 is not set 1127# CONFIG_SND_BF5XX_SOC_WM8731 is not set
1128# CONFIG_SND_BF5XX_SOC_SSM2602 is not set
1074CONFIG_SND_BF5XX_SPORT_NUM=0 1129CONFIG_SND_BF5XX_SPORT_NUM=0
1075CONFIG_SND_BF5XX_HAVE_COLD_RESET=y 1130CONFIG_SND_BF5XX_HAVE_COLD_RESET=y
1076CONFIG_SND_BF5XX_RESET_GPIO_NUM=19 1131CONFIG_SND_BF5XX_RESET_GPIO_NUM=19
@@ -1133,7 +1188,7 @@ CONFIG_USB_MUSB_HOST=y
1133# CONFIG_USB_MUSB_OTG is not set 1188# CONFIG_USB_MUSB_OTG is not set
1134CONFIG_USB_MUSB_HDRC_HCD=y 1189CONFIG_USB_MUSB_HDRC_HCD=y
1135# CONFIG_MUSB_PIO_ONLY is not set 1190# CONFIG_MUSB_PIO_ONLY is not set
1136# CONFIG_USB_INVENTRA_DMA is not set 1191CONFIG_USB_INVENTRA_DMA=y
1137# CONFIG_USB_TI_CPPI_DMA is not set 1192# CONFIG_USB_TI_CPPI_DMA is not set
1138CONFIG_USB_MUSB_LOGLEVEL=0 1193CONFIG_USB_MUSB_LOGLEVEL=0
1139 1194
@@ -1312,7 +1367,7 @@ CONFIG_FS_MBCACHE=y
1312CONFIG_INOTIFY=y 1367CONFIG_INOTIFY=y
1313CONFIG_INOTIFY_USER=y 1368CONFIG_INOTIFY_USER=y
1314# CONFIG_QUOTA is not set 1369# CONFIG_QUOTA is not set
1315CONFIG_DNOTIFY=y 1370# CONFIG_DNOTIFY is not set
1316# CONFIG_AUTOFS_FS is not set 1371# CONFIG_AUTOFS_FS is not set
1317# CONFIG_AUTOFS4_FS is not set 1372# CONFIG_AUTOFS4_FS is not set
1318# CONFIG_FUSE_FS is not set 1373# CONFIG_FUSE_FS is not set
diff --git a/arch/blackfin/configs/BF561-EZKIT_defconfig b/arch/blackfin/configs/BF561-EZKIT_defconfig
index b4a20c890816..976a4d7ba175 100644
--- a/arch/blackfin/configs/BF561-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF561-EZKIT_defconfig
@@ -1,6 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22.16 3# Linux kernel version: 2.6.24.7
4# 4#
5# CONFIG_MMU is not set 5# CONFIG_MMU is not set
6# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -13,35 +13,34 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
13CONFIG_GENERIC_HWEIGHT=y 13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_HARDIRQS=y 14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_IRQ_PROBE=y 15CONFIG_GENERIC_IRQ_PROBE=y
16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_GPIO=y 16CONFIG_GENERIC_GPIO=y
18CONFIG_FORCE_MAX_ZONEORDER=14 17CONFIG_FORCE_MAX_ZONEORDER=14
19CONFIG_GENERIC_CALIBRATE_DELAY=y 18CONFIG_GENERIC_CALIBRATE_DELAY=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21 20
22# 21#
23# Code maturity level options 22# General setup
24# 23#
25CONFIG_EXPERIMENTAL=y 24CONFIG_EXPERIMENTAL=y
26CONFIG_BROKEN_ON_SMP=y 25CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32 26CONFIG_INIT_ENV_ARG_LIMIT=32
28
29#
30# General setup
31#
32CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
33CONFIG_LOCALVERSION_AUTO=y 28CONFIG_LOCALVERSION_AUTO=y
34CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
35# CONFIG_IPC_NS is not set
36CONFIG_SYSVIPC_SYSCTL=y 30CONFIG_SYSVIPC_SYSCTL=y
37# CONFIG_POSIX_MQUEUE is not set 31# CONFIG_POSIX_MQUEUE is not set
38# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
39# CONFIG_TASKSTATS is not set 33# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 34# CONFIG_USER_NS is not set
35# CONFIG_PID_NS is not set
41# CONFIG_AUDIT is not set 36# CONFIG_AUDIT is not set
42CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=14 39CONFIG_LOG_BUF_SHIFT=14
40# CONFIG_CGROUPS is not set
41CONFIG_FAIR_GROUP_SCHED=y
42CONFIG_FAIR_USER_SCHED=y
43# CONFIG_FAIR_CGROUP_SCHED is not set
45CONFIG_SYSFS_DEPRECATED=y 44CONFIG_SYSFS_DEPRECATED=y
46# CONFIG_RELAY is not set 45# CONFIG_RELAY is not set
47CONFIG_BLK_DEV_INITRD=y 46CONFIG_BLK_DEV_INITRD=y
@@ -64,32 +63,24 @@ CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y 63CONFIG_SIGNALFD=y
65CONFIG_EVENTFD=y 64CONFIG_EVENTFD=y
66CONFIG_VM_EVENT_COUNTERS=y 65CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
68# CONFIG_NP2 is not set
69CONFIG_SLAB=y 66CONFIG_SLAB=y
70# CONFIG_SLUB is not set 67# CONFIG_SLUB is not set
71# CONFIG_SLOB is not set 68# CONFIG_SLOB is not set
69CONFIG_SLABINFO=y
72CONFIG_RT_MUTEXES=y 70CONFIG_RT_MUTEXES=y
73CONFIG_TINY_SHMEM=y 71CONFIG_TINY_SHMEM=y
74CONFIG_BASE_SMALL=0 72CONFIG_BASE_SMALL=0
75
76#
77# Loadable module support
78#
79CONFIG_MODULES=y 73CONFIG_MODULES=y
80CONFIG_MODULE_UNLOAD=y 74CONFIG_MODULE_UNLOAD=y
81# CONFIG_MODULE_FORCE_UNLOAD is not set 75# CONFIG_MODULE_FORCE_UNLOAD is not set
82# CONFIG_MODVERSIONS is not set 76# CONFIG_MODVERSIONS is not set
83# CONFIG_MODULE_SRCVERSION_ALL is not set 77# CONFIG_MODULE_SRCVERSION_ALL is not set
84CONFIG_KMOD=y 78CONFIG_KMOD=y
85
86#
87# Block layer
88#
89CONFIG_BLOCK=y 79CONFIG_BLOCK=y
90# CONFIG_LBD is not set 80# CONFIG_LBD is not set
91# CONFIG_BLK_DEV_IO_TRACE is not set 81# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set 82# CONFIG_LSF is not set
83# CONFIG_BLK_DEV_BSG is not set
93 84
94# 85#
95# IO Schedulers 86# IO Schedulers
@@ -140,7 +131,6 @@ CONFIG_BF_REV_0_3=y
140# CONFIG_BF_REV_0_5 is not set 131# CONFIG_BF_REV_0_5 is not set
141# CONFIG_BF_REV_ANY is not set 132# CONFIG_BF_REV_ANY is not set
142# CONFIG_BF_REV_NONE is not set 133# CONFIG_BF_REV_NONE is not set
143CONFIG_BFIN_DUAL_CORE=y
144CONFIG_MEM_MT48LC16M16A2TG_75=y 134CONFIG_MEM_MT48LC16M16A2TG_75=y
145CONFIG_IRQ_PLL_WAKEUP=7 135CONFIG_IRQ_PLL_WAKEUP=7
146CONFIG_IRQ_SPORT0_ERROR=7 136CONFIG_IRQ_SPORT0_ERROR=7
@@ -233,12 +223,14 @@ CONFIG_IRQ_WDTIMER=13
233# Board customizations 223# Board customizations
234# 224#
235# CONFIG_CMDLINE_BOOL is not set 225# CONFIG_CMDLINE_BOOL is not set
226CONFIG_BOOT_LOAD=0x1000
236 227
237# 228#
238# Clock/PLL Setup 229# Clock/PLL Setup
239# 230#
240CONFIG_CLKIN_HZ=30000000 231CONFIG_CLKIN_HZ=30000000
241# CONFIG_BFIN_KERNEL_CLOCK is not set 232# CONFIG_BFIN_KERNEL_CLOCK is not set
233CONFIG_MAX_MEM_SIZE=512
242CONFIG_MAX_VCO_HZ=600000000 234CONFIG_MAX_VCO_HZ=600000000
243CONFIG_MIN_VCO_HZ=50000000 235CONFIG_MIN_VCO_HZ=50000000
244CONFIG_MAX_SCLK_HZ=133333333 236CONFIG_MAX_SCLK_HZ=133333333
@@ -252,13 +244,17 @@ CONFIG_HZ_250=y
252# CONFIG_HZ_300 is not set 244# CONFIG_HZ_300 is not set
253# CONFIG_HZ_1000 is not set 245# CONFIG_HZ_1000 is not set
254CONFIG_HZ=250 246CONFIG_HZ=250
247CONFIG_GENERIC_TIME=y
248CONFIG_GENERIC_CLOCKEVENTS=y
249# CONFIG_CYCLES_CLOCKSOURCE is not set
250CONFIG_TICK_ONESHOT=y
251# CONFIG_NO_HZ is not set
252CONFIG_HIGH_RES_TIMERS=y
253CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
255 254
256# 255#
257# Memory Setup 256# Misc
258# 257#
259CONFIG_MAX_MEM_SIZE=512
260CONFIG_MEM_ADD_WIDTH=9
261CONFIG_BOOT_LOAD=0x1000
262CONFIG_BFIN_SCRATCH_REG_RETN=y 258CONFIG_BFIN_SCRATCH_REG_RETN=y
263# CONFIG_BFIN_SCRATCH_REG_RETE is not set 259# CONFIG_BFIN_SCRATCH_REG_RETE is not set
264# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set 260# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -294,12 +290,14 @@ CONFIG_FLATMEM_MANUAL=y
294CONFIG_FLATMEM=y 290CONFIG_FLATMEM=y
295CONFIG_FLAT_NODE_MEM_MAP=y 291CONFIG_FLAT_NODE_MEM_MAP=y
296# CONFIG_SPARSEMEM_STATIC is not set 292# CONFIG_SPARSEMEM_STATIC is not set
293# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
297CONFIG_SPLIT_PTLOCK_CPUS=4 294CONFIG_SPLIT_PTLOCK_CPUS=4
298# CONFIG_RESOURCES_64BIT is not set 295# CONFIG_RESOURCES_64BIT is not set
299CONFIG_ZONE_DMA_FLAG=1 296CONFIG_ZONE_DMA_FLAG=1
300CONFIG_LARGE_ALLOCS=y 297CONFIG_VIRT_TO_BUS=y
301# CONFIG_BFIN_GPTIMERS is not set 298# CONFIG_BFIN_GPTIMERS is not set
302CONFIG_BFIN_DMA_5XX=y 299CONFIG_BFIN_DMA_5XX=y
300# CONFIG_DMA_UNCACHED_4M is not set
303# CONFIG_DMA_UNCACHED_2M is not set 301# CONFIG_DMA_UNCACHED_2M is not set
304CONFIG_DMA_UNCACHED_1M=y 302CONFIG_DMA_UNCACHED_1M=y
305# CONFIG_DMA_UNCACHED_NONE is not set 303# CONFIG_DMA_UNCACHED_NONE is not set
@@ -341,17 +339,13 @@ CONFIG_C_AMBEN_ALL=y
341CONFIG_BANK_0=0x7BB0 339CONFIG_BANK_0=0x7BB0
342CONFIG_BANK_1=0x7BB0 340CONFIG_BANK_1=0x7BB0
343CONFIG_BANK_2=0x7BB0 341CONFIG_BANK_2=0x7BB0
344CONFIG_BANK_3=0xAAC3 342CONFIG_BANK_3=0xAAC2
345 343
346# 344#
347# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 345# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
348# 346#
349# CONFIG_PCI is not set 347# CONFIG_PCI is not set
350# CONFIG_ARCH_SUPPORTS_MSI is not set 348# CONFIG_ARCH_SUPPORTS_MSI is not set
351
352#
353# PCCARD (PCMCIA/CardBus) support
354#
355# CONFIG_PCCARD is not set 349# CONFIG_PCCARD is not set
356 350
357# 351#
@@ -367,9 +361,15 @@ CONFIG_BINFMT_ZFLAT=y
367# Power management options 361# Power management options
368# 362#
369# CONFIG_PM is not set 363# CONFIG_PM is not set
364CONFIG_SUSPEND_UP_POSSIBLE=y
370# CONFIG_PM_WAKEUP_BY_GPIO is not set 365# CONFIG_PM_WAKEUP_BY_GPIO is not set
371 366
372# 367#
368# CPU Frequency scaling
369#
370# CONFIG_CPU_FREQ is not set
371
372#
373# Networking 373# Networking
374# 374#
375CONFIG_NET=y 375CONFIG_NET=y
@@ -405,6 +405,7 @@ CONFIG_SYN_COOKIES=y
405CONFIG_INET_XFRM_MODE_TRANSPORT=y 405CONFIG_INET_XFRM_MODE_TRANSPORT=y
406CONFIG_INET_XFRM_MODE_TUNNEL=y 406CONFIG_INET_XFRM_MODE_TUNNEL=y
407CONFIG_INET_XFRM_MODE_BEET=y 407CONFIG_INET_XFRM_MODE_BEET=y
408# CONFIG_INET_LRO is not set
408CONFIG_INET_DIAG=y 409CONFIG_INET_DIAG=y
409CONFIG_INET_TCP_DIAG=y 410CONFIG_INET_TCP_DIAG=y
410# CONFIG_TCP_CONG_ADVANCED is not set 411# CONFIG_TCP_CONG_ADVANCED is not set
@@ -431,10 +432,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
431# CONFIG_LAPB is not set 432# CONFIG_LAPB is not set
432# CONFIG_ECONET is not set 433# CONFIG_ECONET is not set
433# CONFIG_WAN_ROUTER is not set 434# CONFIG_WAN_ROUTER is not set
434
435#
436# QoS and/or fair queueing
437#
438# CONFIG_NET_SCHED is not set 435# CONFIG_NET_SCHED is not set
439 436
440# 437#
@@ -466,6 +463,7 @@ CONFIG_IRDA_CACHE_LAST_LSAP=y
466# SIR device drivers 463# SIR device drivers
467# 464#
468CONFIG_IRTTY_SIR=m 465CONFIG_IRTTY_SIR=m
466# CONFIG_BFIN_SIR is not set
469 467
470# 468#
471# Dongle support 469# Dongle support
@@ -495,6 +493,7 @@ CONFIG_IRTTY_SIR=m
495# CONFIG_MAC80211 is not set 493# CONFIG_MAC80211 is not set
496# CONFIG_IEEE80211 is not set 494# CONFIG_IEEE80211 is not set
497# CONFIG_RFKILL is not set 495# CONFIG_RFKILL is not set
496# CONFIG_NET_9P is not set
498 497
499# 498#
500# Device Drivers 499# Device Drivers
@@ -503,14 +502,11 @@ CONFIG_IRTTY_SIR=m
503# 502#
504# Generic Driver Options 503# Generic Driver Options
505# 504#
505CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
506CONFIG_STANDALONE=y 506CONFIG_STANDALONE=y
507CONFIG_PREVENT_FIRMWARE_BUILD=y 507CONFIG_PREVENT_FIRMWARE_BUILD=y
508# CONFIG_FW_LOADER is not set 508# CONFIG_FW_LOADER is not set
509# CONFIG_SYS_HYPERVISOR is not set 509# CONFIG_SYS_HYPERVISOR is not set
510
511#
512# Connector - unified userspace <-> kernelspace linker
513#
514# CONFIG_CONNECTOR is not set 510# CONFIG_CONNECTOR is not set
515CONFIG_MTD=y 511CONFIG_MTD=y
516# CONFIG_MTD_DEBUG is not set 512# CONFIG_MTD_DEBUG is not set
@@ -530,6 +526,7 @@ CONFIG_MTD_BLOCK=y
530# CONFIG_INFTL is not set 526# CONFIG_INFTL is not set
531# CONFIG_RFD_FTL is not set 527# CONFIG_RFD_FTL is not set
532# CONFIG_SSFDC is not set 528# CONFIG_SSFDC is not set
529# CONFIG_MTD_OOPS is not set
533 530
534# 531#
535# RAM/ROM/Flash chip drivers 532# RAM/ROM/Flash chip drivers
@@ -590,20 +587,8 @@ CONFIG_MTD_PHYSMAP_BANKWIDTH=2
590# UBI - Unsorted block images 587# UBI - Unsorted block images
591# 588#
592# CONFIG_MTD_UBI is not set 589# CONFIG_MTD_UBI is not set
593
594#
595# Parallel port support
596#
597# CONFIG_PARPORT is not set 590# CONFIG_PARPORT is not set
598 591CONFIG_BLK_DEV=y
599#
600# Plug and Play support
601#
602# CONFIG_PNPACPI is not set
603
604#
605# Block devices
606#
607# CONFIG_BLK_DEV_COW_COMMON is not set 592# CONFIG_BLK_DEV_COW_COMMON is not set
608# CONFIG_BLK_DEV_LOOP is not set 593# CONFIG_BLK_DEV_LOOP is not set
609# CONFIG_BLK_DEV_NBD is not set 594# CONFIG_BLK_DEV_NBD is not set
@@ -613,10 +598,8 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
613CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 598CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
614# CONFIG_CDROM_PKTCDVD is not set 599# CONFIG_CDROM_PKTCDVD is not set
615# CONFIG_ATA_OVER_ETH is not set 600# CONFIG_ATA_OVER_ETH is not set
616 601CONFIG_MISC_DEVICES=y
617# 602# CONFIG_EEPROM_93CX6 is not set
618# Misc devices
619#
620# CONFIG_IDE is not set 603# CONFIG_IDE is not set
621 604
622# 605#
@@ -624,32 +607,29 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
624# 607#
625# CONFIG_RAID_ATTRS is not set 608# CONFIG_RAID_ATTRS is not set
626# CONFIG_SCSI is not set 609# CONFIG_SCSI is not set
610# CONFIG_SCSI_DMA is not set
627# CONFIG_SCSI_NETLINK is not set 611# CONFIG_SCSI_NETLINK is not set
628# CONFIG_ATA is not set 612# CONFIG_ATA is not set
629
630#
631# Multi-device support (RAID and LVM)
632#
633# CONFIG_MD is not set 613# CONFIG_MD is not set
634
635#
636# Network device support
637#
638CONFIG_NETDEVICES=y 614CONFIG_NETDEVICES=y
615# CONFIG_NETDEVICES_MULTIQUEUE is not set
639# CONFIG_DUMMY is not set 616# CONFIG_DUMMY is not set
640# CONFIG_BONDING is not set 617# CONFIG_BONDING is not set
618# CONFIG_MACVLAN is not set
641# CONFIG_EQUALIZER is not set 619# CONFIG_EQUALIZER is not set
642# CONFIG_TUN is not set 620# CONFIG_TUN is not set
621# CONFIG_VETH is not set
643# CONFIG_PHYLIB is not set 622# CONFIG_PHYLIB is not set
644
645#
646# Ethernet (10 or 100Mbit)
647#
648CONFIG_NET_ETHERNET=y 623CONFIG_NET_ETHERNET=y
649CONFIG_MII=y 624CONFIG_MII=y
650CONFIG_SMC91X=y 625CONFIG_SMC91X=y
651# CONFIG_SMSC911X is not set 626# CONFIG_SMSC911X is not set
652# CONFIG_DM9000 is not set 627# CONFIG_DM9000 is not set
628# CONFIG_IBM_NEW_EMAC_ZMII is not set
629# CONFIG_IBM_NEW_EMAC_RGMII is not set
630# CONFIG_IBM_NEW_EMAC_TAH is not set
631# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
632# CONFIG_B44 is not set
653CONFIG_NETDEV_1000=y 633CONFIG_NETDEV_1000=y
654# CONFIG_AX88180 is not set 634# CONFIG_AX88180 is not set
655CONFIG_NETDEV_10000=y 635CONFIG_NETDEV_10000=y
@@ -666,15 +646,7 @@ CONFIG_NETDEV_10000=y
666# CONFIG_NETCONSOLE is not set 646# CONFIG_NETCONSOLE is not set
667# CONFIG_NETPOLL is not set 647# CONFIG_NETPOLL is not set
668# CONFIG_NET_POLL_CONTROLLER is not set 648# CONFIG_NET_POLL_CONTROLLER is not set
669
670#
671# ISDN subsystem
672#
673# CONFIG_ISDN is not set 649# CONFIG_ISDN is not set
674
675#
676# Telephony Support
677#
678# CONFIG_PHONE is not set 650# CONFIG_PHONE is not set
679 651
680# 652#
@@ -689,7 +661,6 @@ CONFIG_INPUT=m
689# 661#
690# CONFIG_INPUT_MOUSEDEV is not set 662# CONFIG_INPUT_MOUSEDEV is not set
691# CONFIG_INPUT_JOYDEV is not set 663# CONFIG_INPUT_JOYDEV is not set
692# CONFIG_INPUT_TSDEV is not set
693CONFIG_INPUT_EVDEV=m 664CONFIG_INPUT_EVDEV=m
694# CONFIG_INPUT_EVBUG is not set 665# CONFIG_INPUT_EVBUG is not set
695 666
@@ -714,13 +685,12 @@ CONFIG_INPUT_EVDEV=m
714# 685#
715# CONFIG_AD9960 is not set 686# CONFIG_AD9960 is not set
716# CONFIG_SPI_ADC_BF533 is not set 687# CONFIG_SPI_ADC_BF533 is not set
717# CONFIG_BF5xx_PFLAGS is not set
718# CONFIG_BF5xx_PPIFCD is not set 688# CONFIG_BF5xx_PPIFCD is not set
719# CONFIG_BFIN_SIMPLE_TIMER is not set 689# CONFIG_BFIN_SIMPLE_TIMER is not set
720# CONFIG_BF5xx_PPI is not set 690# CONFIG_BF5xx_PPI is not set
721# CONFIG_BFIN_SPORT is not set 691# CONFIG_BFIN_SPORT is not set
722# CONFIG_BFIN_TIMER_LATENCY is not set 692# CONFIG_BFIN_TIMER_LATENCY is not set
723# CONFIG_AD5304 is not set 693CONFIG_SIMPLE_GPIO=m
724# CONFIG_VT is not set 694# CONFIG_VT is not set
725# CONFIG_SERIAL_NONSTANDARD is not set 695# CONFIG_SERIAL_NONSTANDARD is not set
726 696
@@ -748,27 +718,11 @@ CONFIG_UNIX98_PTYS=y
748# CAN, the car bus and industrial fieldbus 718# CAN, the car bus and industrial fieldbus
749# 719#
750# CONFIG_CAN4LINUX is not set 720# CONFIG_CAN4LINUX is not set
751
752#
753# IPMI
754#
755# CONFIG_IPMI_HANDLER is not set 721# CONFIG_IPMI_HANDLER is not set
756CONFIG_WATCHDOG=y
757# CONFIG_WATCHDOG_NOWAYOUT is not set
758
759#
760# Watchdog Device Drivers
761#
762# CONFIG_SOFT_WATCHDOG is not set
763CONFIG_BFIN_WDT=y
764CONFIG_HW_RANDOM=y 722CONFIG_HW_RANDOM=y
765# CONFIG_GEN_RTC is not set 723# CONFIG_GEN_RTC is not set
766# CONFIG_R3964 is not set 724# CONFIG_R3964 is not set
767# CONFIG_RAW_DRIVER is not set 725# CONFIG_RAW_DRIVER is not set
768
769#
770# TPM devices
771#
772# CONFIG_TCG_TPM is not set 726# CONFIG_TCG_TPM is not set
773# CONFIG_I2C is not set 727# CONFIG_I2C is not set
774 728
@@ -789,22 +743,37 @@ CONFIG_SPI_BFIN=y
789# 743#
790# CONFIG_SPI_AT25 is not set 744# CONFIG_SPI_AT25 is not set
791# CONFIG_SPI_SPIDEV is not set 745# CONFIG_SPI_SPIDEV is not set
792 746# CONFIG_SPI_TLE62X0 is not set
793#
794# Dallas's 1-wire bus
795#
796# CONFIG_W1 is not set 747# CONFIG_W1 is not set
748# CONFIG_POWER_SUPPLY is not set
797CONFIG_HWMON=y 749CONFIG_HWMON=y
798# CONFIG_HWMON_VID is not set 750# CONFIG_HWMON_VID is not set
799# CONFIG_SENSORS_ABITUGURU is not set
800# CONFIG_SENSORS_F71805F is not set 751# CONFIG_SENSORS_F71805F is not set
752# CONFIG_SENSORS_F71882FG is not set
753# CONFIG_SENSORS_IT87 is not set
801# CONFIG_SENSORS_LM70 is not set 754# CONFIG_SENSORS_LM70 is not set
755# CONFIG_SENSORS_PC87360 is not set
802# CONFIG_SENSORS_PC87427 is not set 756# CONFIG_SENSORS_PC87427 is not set
803# CONFIG_SENSORS_SMSC47M1 is not set 757# CONFIG_SENSORS_SMSC47M1 is not set
804# CONFIG_SENSORS_SMSC47B397 is not set 758# CONFIG_SENSORS_SMSC47B397 is not set
805# CONFIG_SENSORS_VT1211 is not set 759# CONFIG_SENSORS_VT1211 is not set
806# CONFIG_SENSORS_W83627HF is not set 760# CONFIG_SENSORS_W83627HF is not set
761# CONFIG_SENSORS_W83627EHF is not set
807# CONFIG_HWMON_DEBUG_CHIP is not set 762# CONFIG_HWMON_DEBUG_CHIP is not set
763CONFIG_WATCHDOG=y
764# CONFIG_WATCHDOG_NOWAYOUT is not set
765
766#
767# Watchdog Device Drivers
768#
769# CONFIG_SOFT_WATCHDOG is not set
770CONFIG_BFIN_WDT=y
771
772#
773# Sonics Silicon Backplane
774#
775CONFIG_SSB_POSSIBLE=y
776# CONFIG_SSB is not set
808 777
809# 778#
810# Multifunction device drivers 779# Multifunction device drivers
@@ -821,91 +790,33 @@ CONFIG_DAB=y
821# 790#
822# Graphics support 791# Graphics support
823# 792#
793# CONFIG_VGASTATE is not set
794# CONFIG_VIDEO_OUTPUT_CONTROL is not set
795# CONFIG_FB is not set
824# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 796# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
825 797
826# 798#
827# Display device support 799# Display device support
828# 800#
829# CONFIG_DISPLAY_SUPPORT is not set 801# CONFIG_DISPLAY_SUPPORT is not set
830# CONFIG_VGASTATE is not set
831# CONFIG_FB is not set
832 802
833# 803#
834# Sound 804# Sound
835# 805#
836# CONFIG_SOUND is not set 806# CONFIG_SOUND is not set
837 807CONFIG_HID_SUPPORT=y
838#
839# HID Devices
840#
841CONFIG_HID=m 808CONFIG_HID=m
842# CONFIG_HID_DEBUG is not set 809# CONFIG_HID_DEBUG is not set
843 810# CONFIG_HIDRAW is not set
844# 811# CONFIG_USB_SUPPORT is not set
845# USB support
846#
847CONFIG_USB_ARCH_HAS_HCD=y
848# CONFIG_USB_ARCH_HAS_OHCI is not set
849# CONFIG_USB_ARCH_HAS_EHCI is not set
850# CONFIG_USB is not set
851
852#
853# Enable Host or Gadget support to see Inventra options
854#
855
856#
857# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
858#
859
860#
861# USB Gadget Support
862#
863# CONFIG_USB_GADGET is not set
864# CONFIG_MMC is not set 812# CONFIG_MMC is not set
865
866#
867# LED devices
868#
869# CONFIG_NEW_LEDS is not set 813# CONFIG_NEW_LEDS is not set
870
871#
872# LED drivers
873#
874
875#
876# LED Triggers
877#
878
879#
880# InfiniBand support
881#
882
883#
884# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
885#
886
887#
888# Real Time Clock
889#
890# CONFIG_RTC_CLASS is not set 814# CONFIG_RTC_CLASS is not set
891 815
892# 816#
893# DMA Engine support 817# Userspace I/O
894#
895# CONFIG_DMA_ENGINE is not set
896
897#
898# DMA Clients
899#
900
901#
902# DMA Devices
903# 818#
904 819# CONFIG_UIO is not set
905#
906# PBX support
907#
908# CONFIG_PBX is not set
909 820
910# 821#
911# File systems 822# File systems
@@ -950,7 +861,6 @@ CONFIG_PROC_SYSCTL=y
950CONFIG_SYSFS=y 861CONFIG_SYSFS=y
951# CONFIG_TMPFS is not set 862# CONFIG_TMPFS is not set
952# CONFIG_HUGETLB_PAGE is not set 863# CONFIG_HUGETLB_PAGE is not set
953CONFIG_RAMFS=y
954# CONFIG_CONFIGFS_FS is not set 864# CONFIG_CONFIGFS_FS is not set
955 865
956# 866#
@@ -976,10 +886,12 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
976CONFIG_JFFS2_FS=m 886CONFIG_JFFS2_FS=m
977CONFIG_JFFS2_FS_DEBUG=0 887CONFIG_JFFS2_FS_DEBUG=0
978CONFIG_JFFS2_FS_WRITEBUFFER=y 888CONFIG_JFFS2_FS_WRITEBUFFER=y
889# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
979# CONFIG_JFFS2_SUMMARY is not set 890# CONFIG_JFFS2_SUMMARY is not set
980# CONFIG_JFFS2_FS_XATTR is not set 891# CONFIG_JFFS2_FS_XATTR is not set
981# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 892# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
982CONFIG_JFFS2_ZLIB=y 893CONFIG_JFFS2_ZLIB=y
894# CONFIG_JFFS2_LZO is not set
983CONFIG_JFFS2_RTIME=y 895CONFIG_JFFS2_RTIME=y
984# CONFIG_JFFS2_RUBIN is not set 896# CONFIG_JFFS2_RUBIN is not set
985# CONFIG_CRAMFS is not set 897# CONFIG_CRAMFS is not set
@@ -988,10 +900,7 @@ CONFIG_JFFS2_RTIME=y
988# CONFIG_QNX4FS_FS is not set 900# CONFIG_QNX4FS_FS is not set
989# CONFIG_SYSV_FS is not set 901# CONFIG_SYSV_FS is not set
990# CONFIG_UFS_FS is not set 902# CONFIG_UFS_FS is not set
991 903CONFIG_NETWORK_FILESYSTEMS=y
992#
993# Network File Systems
994#
995CONFIG_NFS_FS=m 904CONFIG_NFS_FS=m
996CONFIG_NFS_V3=y 905CONFIG_NFS_V3=y
997# CONFIG_NFS_V3_ACL is not set 906# CONFIG_NFS_V3_ACL is not set
@@ -1011,17 +920,12 @@ CONFIG_SMB_FS=m
1011# CONFIG_NCP_FS is not set 920# CONFIG_NCP_FS is not set
1012# CONFIG_CODA_FS is not set 921# CONFIG_CODA_FS is not set
1013# CONFIG_AFS_FS is not set 922# CONFIG_AFS_FS is not set
1014# CONFIG_9P_FS is not set
1015 923
1016# 924#
1017# Partition Types 925# Partition Types
1018# 926#
1019# CONFIG_PARTITION_ADVANCED is not set 927# CONFIG_PARTITION_ADVANCED is not set
1020CONFIG_MSDOS_PARTITION=y 928CONFIG_MSDOS_PARTITION=y
1021
1022#
1023# Native Language Support
1024#
1025CONFIG_NLS=m 929CONFIG_NLS=m
1026CONFIG_NLS_DEFAULT="iso8859-1" 930CONFIG_NLS_DEFAULT="iso8859-1"
1027# CONFIG_NLS_CODEPAGE_437 is not set 931# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1062,21 +966,16 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1062# CONFIG_NLS_KOI8_R is not set 966# CONFIG_NLS_KOI8_R is not set
1063# CONFIG_NLS_KOI8_U is not set 967# CONFIG_NLS_KOI8_U is not set
1064# CONFIG_NLS_UTF8 is not set 968# CONFIG_NLS_UTF8 is not set
1065
1066#
1067# Distributed Lock Manager
1068#
1069# CONFIG_DLM is not set 969# CONFIG_DLM is not set
1070 970CONFIG_INSTRUMENTATION=y
1071#
1072# Profiling support
1073#
1074# CONFIG_PROFILING is not set 971# CONFIG_PROFILING is not set
972# CONFIG_MARKERS is not set
1075 973
1076# 974#
1077# Kernel hacking 975# Kernel hacking
1078# 976#
1079# CONFIG_PRINTK_TIME is not set 977# CONFIG_PRINTK_TIME is not set
978CONFIG_ENABLE_WARN_DEPRECATED=y
1080CONFIG_ENABLE_MUST_CHECK=y 979CONFIG_ENABLE_MUST_CHECK=y
1081# CONFIG_MAGIC_SYSRQ is not set 980# CONFIG_MAGIC_SYSRQ is not set
1082# CONFIG_UNUSED_SYMBOLS is not set 981# CONFIG_UNUSED_SYMBOLS is not set
@@ -1084,6 +983,7 @@ CONFIG_DEBUG_FS=y
1084# CONFIG_HEADERS_CHECK is not set 983# CONFIG_HEADERS_CHECK is not set
1085# CONFIG_DEBUG_KERNEL is not set 984# CONFIG_DEBUG_KERNEL is not set
1086# CONFIG_DEBUG_BUGVERBOSE is not set 985# CONFIG_DEBUG_BUGVERBOSE is not set
986# CONFIG_SAMPLES is not set
1087CONFIG_DEBUG_MMRS=y 987CONFIG_DEBUG_MMRS=y
1088CONFIG_DEBUG_HUNT_FOR_ZERO=y 988CONFIG_DEBUG_HUNT_FOR_ZERO=y
1089CONFIG_DEBUG_BFIN_HWTRACE_ON=y 989CONFIG_DEBUG_BFIN_HWTRACE_ON=y
@@ -1104,11 +1004,7 @@ CONFIG_ACCESS_CHECK=y
1104# CONFIG_KEYS is not set 1004# CONFIG_KEYS is not set
1105CONFIG_SECURITY=y 1005CONFIG_SECURITY=y
1106# CONFIG_SECURITY_NETWORK is not set 1006# CONFIG_SECURITY_NETWORK is not set
1107CONFIG_SECURITY_CAPABILITIES=m 1007# CONFIG_SECURITY_CAPABILITIES is not set
1108
1109#
1110# Cryptographic options
1111#
1112# CONFIG_CRYPTO is not set 1008# CONFIG_CRYPTO is not set
1113 1009
1114# 1010#
@@ -1119,6 +1015,7 @@ CONFIG_CRC_CCITT=m
1119# CONFIG_CRC16 is not set 1015# CONFIG_CRC16 is not set
1120# CONFIG_CRC_ITU_T is not set 1016# CONFIG_CRC_ITU_T is not set
1121CONFIG_CRC32=y 1017CONFIG_CRC32=y
1018# CONFIG_CRC7 is not set
1122# CONFIG_LIBCRC32C is not set 1019# CONFIG_LIBCRC32C is not set
1123CONFIG_ZLIB_INFLATE=y 1020CONFIG_ZLIB_INFLATE=y
1124CONFIG_ZLIB_DEFLATE=m 1021CONFIG_ZLIB_DEFLATE=m
diff --git a/arch/blackfin/configs/CM-BF527_defconfig b/arch/blackfin/configs/CM-BF527_defconfig
new file mode 100644
index 000000000000..0799aa9bba9d
--- /dev/null
+++ b/arch/blackfin/configs/CM-BF527_defconfig
@@ -0,0 +1,1185 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24.7
4# Fri Jul 18 18:00:41 2008
5#
6# CONFIG_MMU is not set
7# CONFIG_FPU is not set
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
10CONFIG_BLACKFIN=y
11CONFIG_ZONE_DMA=y
12CONFIG_SEMAPHORE_SLEEPERS=y
13CONFIG_GENERIC_FIND_NEXT_BIT=y
14CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_HARDIRQS=y
16CONFIG_GENERIC_IRQ_PROBE=y
17CONFIG_GENERIC_GPIO=y
18CONFIG_FORCE_MAX_ZONEORDER=14
19CONFIG_GENERIC_CALIBRATE_DELAY=y
20CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
21
22#
23# General setup
24#
25CONFIG_EXPERIMENTAL=y
26CONFIG_BROKEN_ON_SMP=y
27CONFIG_INIT_ENV_ARG_LIMIT=32
28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
30CONFIG_SYSVIPC=y
31CONFIG_SYSVIPC_SYSCTL=y
32# CONFIG_POSIX_MQUEUE is not set
33# CONFIG_BSD_PROCESS_ACCT is not set
34# CONFIG_TASKSTATS is not set
35# CONFIG_USER_NS is not set
36# CONFIG_PID_NS is not set
37# CONFIG_AUDIT is not set
38CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y
40CONFIG_LOG_BUF_SHIFT=14
41# CONFIG_CGROUPS is not set
42CONFIG_FAIR_GROUP_SCHED=y
43CONFIG_FAIR_USER_SCHED=y
44# CONFIG_FAIR_CGROUP_SCHED is not set
45CONFIG_SYSFS_DEPRECATED=y
46# CONFIG_RELAY is not set
47CONFIG_BLK_DEV_INITRD=y
48CONFIG_INITRAMFS_SOURCE=""
49# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
50CONFIG_SYSCTL=y
51CONFIG_EMBEDDED=y
52CONFIG_UID16=y
53CONFIG_SYSCTL_SYSCALL=y
54CONFIG_KALLSYMS=y
55# CONFIG_KALLSYMS_EXTRA_PASS is not set
56CONFIG_HOTPLUG=y
57CONFIG_PRINTK=y
58CONFIG_BUG=y
59CONFIG_ELF_CORE=y
60CONFIG_BASE_FULL=y
61CONFIG_FUTEX=y
62CONFIG_ANON_INODES=y
63CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y
65CONFIG_EVENTFD=y
66CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_SLAB=y
68# CONFIG_SLUB is not set
69# CONFIG_SLOB is not set
70CONFIG_SLABINFO=y
71CONFIG_RT_MUTEXES=y
72CONFIG_TINY_SHMEM=y
73CONFIG_BASE_SMALL=0
74CONFIG_MODULES=y
75CONFIG_MODULE_UNLOAD=y
76# CONFIG_MODULE_FORCE_UNLOAD is not set
77# CONFIG_MODVERSIONS is not set
78# CONFIG_MODULE_SRCVERSION_ALL is not set
79CONFIG_KMOD=y
80CONFIG_BLOCK=y
81# CONFIG_LBD is not set
82# CONFIG_BLK_DEV_IO_TRACE is not set
83# CONFIG_LSF is not set
84# CONFIG_BLK_DEV_BSG is not set
85
86#
87# IO Schedulers
88#
89CONFIG_IOSCHED_NOOP=y
90# CONFIG_IOSCHED_AS is not set
91# CONFIG_IOSCHED_DEADLINE is not set
92CONFIG_IOSCHED_CFQ=y
93# CONFIG_DEFAULT_AS is not set
94# CONFIG_DEFAULT_DEADLINE is not set
95CONFIG_DEFAULT_CFQ=y
96# CONFIG_DEFAULT_NOOP is not set
97CONFIG_DEFAULT_IOSCHED="cfq"
98# CONFIG_PREEMPT_NONE is not set
99CONFIG_PREEMPT_VOLUNTARY=y
100# CONFIG_PREEMPT is not set
101
102#
103# Blackfin Processor Options
104#
105
106#
107# Processor and Board Settings
108#
109# CONFIG_BF522 is not set
110# CONFIG_BF523 is not set
111# CONFIG_BF524 is not set
112# CONFIG_BF525 is not set
113# CONFIG_BF526 is not set
114CONFIG_BF527=y
115# CONFIG_BF531 is not set
116# CONFIG_BF532 is not set
117# CONFIG_BF533 is not set
118# CONFIG_BF534 is not set
119# CONFIG_BF536 is not set
120# CONFIG_BF537 is not set
121# CONFIG_BF542 is not set
122# CONFIG_BF544 is not set
123# CONFIG_BF547 is not set
124# CONFIG_BF548 is not set
125# CONFIG_BF549 is not set
126# CONFIG_BF561 is not set
127# CONFIG_BF_REV_0_0 is not set
128CONFIG_BF_REV_0_1=y
129# CONFIG_BF_REV_0_2 is not set
130# CONFIG_BF_REV_0_3 is not set
131# CONFIG_BF_REV_0_4 is not set
132# CONFIG_BF_REV_0_5 is not set
133# CONFIG_BF_REV_ANY is not set
134# CONFIG_BF_REV_NONE is not set
135CONFIG_BF52x=y
136CONFIG_MEM_MT48LC16M16A2TG_75=y
137# CONFIG_BFIN527_EZKIT is not set
138CONFIG_BFIN527_BLUETECHNIX_CM=y
139
140#
141# BF527 Specific Configuration
142#
143
144#
145# Alternative Multiplexing Scheme
146#
147# CONFIG_BF527_SPORT0_PORTF is not set
148CONFIG_BF527_SPORT0_PORTG=y
149CONFIG_BF527_SPORT0_TSCLK_PG10=y
150# CONFIG_BF527_SPORT0_TSCLK_PG14 is not set
151CONFIG_BF527_UART1_PORTF=y
152# CONFIG_BF527_UART1_PORTG is not set
153# CONFIG_BF527_NAND_D_PORTF is not set
154CONFIG_BF527_NAND_D_PORTH=y
155
156#
157# Interrupt Priority Assignment
158#
159
160#
161# Priority
162#
163CONFIG_IRQ_PLL_WAKEUP=7
164CONFIG_IRQ_DMA0_ERROR=7
165CONFIG_IRQ_DMAR0_BLK=7
166CONFIG_IRQ_DMAR1_BLK=7
167CONFIG_IRQ_DMAR0_OVR=7
168CONFIG_IRQ_DMAR1_OVR=7
169CONFIG_IRQ_PPI_ERROR=7
170CONFIG_IRQ_MAC_ERROR=7
171CONFIG_IRQ_SPORT0_ERROR=7
172CONFIG_IRQ_SPORT1_ERROR=7
173CONFIG_IRQ_UART0_ERROR=7
174CONFIG_IRQ_UART1_ERROR=7
175CONFIG_IRQ_RTC=8
176CONFIG_IRQ_PPI=8
177CONFIG_IRQ_SPORT0_RX=9
178CONFIG_IRQ_SPORT0_TX=9
179CONFIG_IRQ_SPORT1_RX=9
180CONFIG_IRQ_SPORT1_TX=9
181CONFIG_IRQ_TWI=10
182CONFIG_IRQ_SPI=10
183CONFIG_IRQ_UART0_RX=10
184CONFIG_IRQ_UART0_TX=10
185CONFIG_IRQ_UART1_RX=10
186CONFIG_IRQ_UART1_TX=10
187CONFIG_IRQ_OPTSEC=11
188CONFIG_IRQ_CNT=11
189CONFIG_IRQ_MAC_RX=11
190CONFIG_IRQ_PORTH_INTA=11
191CONFIG_IRQ_MAC_TX=11
192CONFIG_IRQ_PORTH_INTB=11
193CONFIG_IRQ_TMR0=12
194CONFIG_IRQ_TMR1=12
195CONFIG_IRQ_TMR2=12
196CONFIG_IRQ_TMR3=12
197CONFIG_IRQ_TMR4=12
198CONFIG_IRQ_TMR5=12
199CONFIG_IRQ_TMR6=12
200CONFIG_IRQ_TMR7=12
201CONFIG_IRQ_PORTG_INTA=12
202CONFIG_IRQ_PORTG_INTB=12
203CONFIG_IRQ_MEM_DMA0=13
204CONFIG_IRQ_MEM_DMA1=13
205CONFIG_IRQ_WATCH=13
206CONFIG_IRQ_PORTF_INTA=13
207CONFIG_IRQ_PORTF_INTB=13
208CONFIG_IRQ_SPI_ERROR=7
209CONFIG_IRQ_NFC_ERROR=7
210CONFIG_IRQ_HDMA_ERROR=7
211CONFIG_IRQ_HDMA=7
212CONFIG_IRQ_USB_EINT=10
213CONFIG_IRQ_USB_INT0=11
214CONFIG_IRQ_USB_INT1=11
215CONFIG_IRQ_USB_INT2=11
216CONFIG_IRQ_USB_DMA=11
217
218#
219# Board customizations
220#
221# CONFIG_CMDLINE_BOOL is not set
222CONFIG_BOOT_LOAD=0x1000
223
224#
225# Clock/PLL Setup
226#
227CONFIG_CLKIN_HZ=25000000
228# CONFIG_BFIN_KERNEL_CLOCK is not set
229CONFIG_MAX_MEM_SIZE=512
230CONFIG_MAX_VCO_HZ=600000000
231CONFIG_MIN_VCO_HZ=50000000
232CONFIG_MAX_SCLK_HZ=133333333
233CONFIG_MIN_SCLK_HZ=27000000
234
235#
236# Kernel Timer/Scheduler
237#
238# CONFIG_HZ_100 is not set
239CONFIG_HZ_250=y
240# CONFIG_HZ_300 is not set
241# CONFIG_HZ_1000 is not set
242CONFIG_HZ=250
243CONFIG_GENERIC_TIME=y
244CONFIG_GENERIC_CLOCKEVENTS=y
245# CONFIG_CYCLES_CLOCKSOURCE is not set
246# CONFIG_TICK_ONESHOT is not set
247# CONFIG_NO_HZ is not set
248# CONFIG_HIGH_RES_TIMERS is not set
249CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
250
251#
252# Misc
253#
254CONFIG_BFIN_SCRATCH_REG_RETN=y
255# CONFIG_BFIN_SCRATCH_REG_RETE is not set
256# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
257
258#
259# Blackfin Kernel Optimizations
260#
261
262#
263# Memory Optimizations
264#
265CONFIG_I_ENTRY_L1=y
266CONFIG_EXCPT_IRQ_SYSC_L1=y
267CONFIG_DO_IRQ_L1=y
268CONFIG_CORE_TIMER_IRQ_L1=y
269CONFIG_IDLE_L1=y
270# CONFIG_SCHEDULE_L1 is not set
271CONFIG_ARITHMETIC_OPS_L1=y
272CONFIG_ACCESS_OK_L1=y
273# CONFIG_MEMSET_L1 is not set
274# CONFIG_MEMCPY_L1 is not set
275# CONFIG_SYS_BFIN_SPINLOCK_L1 is not set
276# CONFIG_IP_CHECKSUM_L1 is not set
277CONFIG_CACHELINE_ALIGNED_L1=y
278# CONFIG_SYSCALL_TAB_L1 is not set
279# CONFIG_CPLB_SWITCH_TAB_L1 is not set
280CONFIG_RAMKERNEL=y
281# CONFIG_ROMKERNEL is not set
282CONFIG_SELECT_MEMORY_MODEL=y
283CONFIG_FLATMEM_MANUAL=y
284# CONFIG_DISCONTIGMEM_MANUAL is not set
285# CONFIG_SPARSEMEM_MANUAL is not set
286CONFIG_FLATMEM=y
287CONFIG_FLAT_NODE_MEM_MAP=y
288# CONFIG_SPARSEMEM_STATIC is not set
289# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
290CONFIG_SPLIT_PTLOCK_CPUS=4
291# CONFIG_RESOURCES_64BIT is not set
292CONFIG_ZONE_DMA_FLAG=1
293CONFIG_VIRT_TO_BUS=y
294CONFIG_BFIN_GPTIMERS=y
295CONFIG_BFIN_DMA_5XX=y
296# CONFIG_DMA_UNCACHED_4M is not set
297# CONFIG_DMA_UNCACHED_2M is not set
298CONFIG_DMA_UNCACHED_1M=y
299# CONFIG_DMA_UNCACHED_NONE is not set
300
301#
302# Cache Support
303#
304CONFIG_BFIN_ICACHE=y
305CONFIG_BFIN_DCACHE=y
306# CONFIG_BFIN_DCACHE_BANKA is not set
307# CONFIG_BFIN_ICACHE_LOCK is not set
308# CONFIG_BFIN_WB is not set
309CONFIG_BFIN_WT=y
310# CONFIG_MPU is not set
311
312#
313# Asynchonous Memory Configuration
314#
315
316#
317# EBIU_AMGCTL Global Control
318#
319CONFIG_C_AMCKEN=y
320CONFIG_C_CDPRIO=y
321# CONFIG_C_AMBEN is not set
322# CONFIG_C_AMBEN_B0 is not set
323# CONFIG_C_AMBEN_B0_B1 is not set
324# CONFIG_C_AMBEN_B0_B1_B2 is not set
325CONFIG_C_AMBEN_ALL=y
326
327#
328# EBIU_AMBCTL Control
329#
330CONFIG_BANK_0=0x7BB0
331CONFIG_BANK_1=0x5554
332CONFIG_BANK_2=0x7BB0
333CONFIG_BANK_3=0xFFC0
334
335#
336# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
337#
338# CONFIG_PCI is not set
339# CONFIG_ARCH_SUPPORTS_MSI is not set
340# CONFIG_PCCARD is not set
341
342#
343# Executable file formats
344#
345CONFIG_BINFMT_ELF_FDPIC=y
346CONFIG_BINFMT_FLAT=y
347CONFIG_BINFMT_ZFLAT=y
348# CONFIG_BINFMT_SHARED_FLAT is not set
349# CONFIG_BINFMT_MISC is not set
350
351#
352# Power management options
353#
354# CONFIG_PM is not set
355CONFIG_SUSPEND_UP_POSSIBLE=y
356# CONFIG_PM_BFIN_SLEEP_DEEPER is not set
357# CONFIG_PM_BFIN_SLEEP is not set
358# CONFIG_PM_WAKEUP_BY_GPIO is not set
359
360#
361# CPU Frequency scaling
362#
363# CONFIG_CPU_FREQ is not set
364
365#
366# Networking
367#
368CONFIG_NET=y
369
370#
371# Networking options
372#
373CONFIG_PACKET=y
374# CONFIG_PACKET_MMAP is not set
375CONFIG_UNIX=y
376CONFIG_XFRM=y
377# CONFIG_XFRM_USER is not set
378# CONFIG_XFRM_SUB_POLICY is not set
379# CONFIG_XFRM_MIGRATE is not set
380# CONFIG_NET_KEY is not set
381CONFIG_INET=y
382# CONFIG_IP_MULTICAST is not set
383# CONFIG_IP_ADVANCED_ROUTER is not set
384CONFIG_IP_FIB_HASH=y
385CONFIG_IP_PNP=y
386# CONFIG_IP_PNP_DHCP is not set
387# CONFIG_IP_PNP_BOOTP is not set
388# CONFIG_IP_PNP_RARP is not set
389# CONFIG_NET_IPIP is not set
390# CONFIG_NET_IPGRE is not set
391# CONFIG_ARPD is not set
392CONFIG_SYN_COOKIES=y
393# CONFIG_INET_AH is not set
394# CONFIG_INET_ESP is not set
395# CONFIG_INET_IPCOMP is not set
396# CONFIG_INET_XFRM_TUNNEL is not set
397# CONFIG_INET_TUNNEL is not set
398CONFIG_INET_XFRM_MODE_TRANSPORT=y
399CONFIG_INET_XFRM_MODE_TUNNEL=y
400CONFIG_INET_XFRM_MODE_BEET=y
401# CONFIG_INET_LRO is not set
402CONFIG_INET_DIAG=y
403CONFIG_INET_TCP_DIAG=y
404# CONFIG_TCP_CONG_ADVANCED is not set
405CONFIG_TCP_CONG_CUBIC=y
406CONFIG_DEFAULT_TCP_CONG="cubic"
407# CONFIG_TCP_MD5SIG is not set
408# CONFIG_IPV6 is not set
409# CONFIG_INET6_XFRM_TUNNEL is not set
410# CONFIG_INET6_TUNNEL is not set
411# CONFIG_NETLABEL is not set
412# CONFIG_NETWORK_SECMARK is not set
413# CONFIG_NETFILTER is not set
414# CONFIG_IP_DCCP is not set
415# CONFIG_IP_SCTP is not set
416# CONFIG_TIPC is not set
417# CONFIG_ATM is not set
418# CONFIG_BRIDGE is not set
419# CONFIG_VLAN_8021Q is not set
420# CONFIG_DECNET is not set
421# CONFIG_LLC2 is not set
422# CONFIG_IPX is not set
423# CONFIG_ATALK is not set
424# CONFIG_X25 is not set
425# CONFIG_LAPB is not set
426# CONFIG_ECONET is not set
427# CONFIG_WAN_ROUTER is not set
428# CONFIG_NET_SCHED is not set
429
430#
431# Network testing
432#
433# CONFIG_NET_PKTGEN is not set
434# CONFIG_HAMRADIO is not set
435# CONFIG_IRDA is not set
436# CONFIG_BT is not set
437# CONFIG_AF_RXRPC is not set
438
439#
440# Wireless
441#
442# CONFIG_CFG80211 is not set
443# CONFIG_WIRELESS_EXT is not set
444# CONFIG_MAC80211 is not set
445# CONFIG_IEEE80211 is not set
446# CONFIG_RFKILL is not set
447# CONFIG_NET_9P is not set
448
449#
450# Device Drivers
451#
452
453#
454# Generic Driver Options
455#
456CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
457CONFIG_STANDALONE=y
458CONFIG_PREVENT_FIRMWARE_BUILD=y
459# CONFIG_FW_LOADER is not set
460# CONFIG_SYS_HYPERVISOR is not set
461# CONFIG_CONNECTOR is not set
462CONFIG_MTD=y
463# CONFIG_MTD_DEBUG is not set
464# CONFIG_MTD_CONCAT is not set
465CONFIG_MTD_PARTITIONS=y
466# CONFIG_MTD_REDBOOT_PARTS is not set
467# CONFIG_MTD_CMDLINE_PARTS is not set
468
469#
470# User Modules And Translation Layers
471#
472CONFIG_MTD_CHAR=m
473CONFIG_MTD_BLKDEVS=y
474CONFIG_MTD_BLOCK=y
475# CONFIG_FTL is not set
476# CONFIG_NFTL is not set
477# CONFIG_INFTL is not set
478# CONFIG_RFD_FTL is not set
479# CONFIG_SSFDC is not set
480# CONFIG_MTD_OOPS is not set
481
482#
483# RAM/ROM/Flash chip drivers
484#
485# CONFIG_MTD_CFI is not set
486CONFIG_MTD_JEDECPROBE=m
487CONFIG_MTD_GEN_PROBE=m
488# CONFIG_MTD_CFI_ADV_OPTIONS is not set
489CONFIG_MTD_MAP_BANK_WIDTH_1=y
490CONFIG_MTD_MAP_BANK_WIDTH_2=y
491CONFIG_MTD_MAP_BANK_WIDTH_4=y
492# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
493# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
494# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
495CONFIG_MTD_CFI_I1=y
496CONFIG_MTD_CFI_I2=y
497# CONFIG_MTD_CFI_I4 is not set
498# CONFIG_MTD_CFI_I8 is not set
499# CONFIG_MTD_CFI_INTELEXT is not set
500# CONFIG_MTD_CFI_AMDSTD is not set
501# CONFIG_MTD_CFI_STAA is not set
502CONFIG_MTD_RAM=y
503CONFIG_MTD_ROM=m
504# CONFIG_MTD_ABSENT is not set
505
506#
507# Mapping drivers for chip access
508#
509CONFIG_MTD_COMPLEX_MAPPINGS=y
510# CONFIG_MTD_PHYSMAP is not set
511# CONFIG_MTD_UCLINUX is not set
512# CONFIG_MTD_PLATRAM is not set
513
514#
515# Self-contained MTD device drivers
516#
517# CONFIG_MTD_DATAFLASH is not set
518# CONFIG_MTD_M25P80 is not set
519# CONFIG_MTD_SLRAM is not set
520# CONFIG_MTD_PHRAM is not set
521# CONFIG_MTD_MTDRAM is not set
522# CONFIG_MTD_BLOCK2MTD is not set
523
524#
525# Disk-On-Chip Device Drivers
526#
527# CONFIG_MTD_DOC2000 is not set
528# CONFIG_MTD_DOC2001 is not set
529# CONFIG_MTD_DOC2001PLUS is not set
530# CONFIG_MTD_NAND is not set
531# CONFIG_MTD_ONENAND is not set
532
533#
534# UBI - Unsorted block images
535#
536# CONFIG_MTD_UBI is not set
537# CONFIG_PARPORT is not set
538CONFIG_BLK_DEV=y
539# CONFIG_BLK_DEV_COW_COMMON is not set
540# CONFIG_BLK_DEV_LOOP is not set
541# CONFIG_BLK_DEV_NBD is not set
542# CONFIG_BLK_DEV_UB is not set
543CONFIG_BLK_DEV_RAM=y
544CONFIG_BLK_DEV_RAM_COUNT=16
545CONFIG_BLK_DEV_RAM_SIZE=4096
546CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
547# CONFIG_CDROM_PKTCDVD is not set
548# CONFIG_ATA_OVER_ETH is not set
549# CONFIG_MISC_DEVICES is not set
550# CONFIG_IDE is not set
551
552#
553# SCSI device support
554#
555# CONFIG_RAID_ATTRS is not set
556# CONFIG_SCSI is not set
557# CONFIG_SCSI_DMA is not set
558# CONFIG_SCSI_NETLINK is not set
559# CONFIG_ATA is not set
560# CONFIG_MD is not set
561CONFIG_NETDEVICES=y
562# CONFIG_NETDEVICES_MULTIQUEUE is not set
563# CONFIG_DUMMY is not set
564# CONFIG_BONDING is not set
565# CONFIG_MACVLAN is not set
566# CONFIG_EQUALIZER is not set
567# CONFIG_TUN is not set
568# CONFIG_VETH is not set
569CONFIG_PHYLIB=y
570
571#
572# MII PHY device drivers
573#
574# CONFIG_MARVELL_PHY is not set
575# CONFIG_DAVICOM_PHY is not set
576# CONFIG_QSEMI_PHY is not set
577# CONFIG_LXT_PHY is not set
578# CONFIG_CICADA_PHY is not set
579# CONFIG_VITESSE_PHY is not set
580# CONFIG_SMSC_PHY is not set
581# CONFIG_BROADCOM_PHY is not set
582# CONFIG_ICPLUS_PHY is not set
583# CONFIG_FIXED_PHY is not set
584# CONFIG_MDIO_BITBANG is not set
585CONFIG_NET_ETHERNET=y
586CONFIG_MII=y
587CONFIG_BFIN_MAC=y
588CONFIG_BFIN_MAC_USE_L1=y
589CONFIG_BFIN_TX_DESC_NUM=10
590CONFIG_BFIN_RX_DESC_NUM=20
591CONFIG_BFIN_MAC_RMII=y
592# CONFIG_SMC91X is not set
593# CONFIG_SMSC911X is not set
594# CONFIG_DM9000 is not set
595# CONFIG_IBM_NEW_EMAC_ZMII is not set
596# CONFIG_IBM_NEW_EMAC_RGMII is not set
597# CONFIG_IBM_NEW_EMAC_TAH is not set
598# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
599# CONFIG_B44 is not set
600# CONFIG_NETDEV_1000 is not set
601# CONFIG_NETDEV_10000 is not set
602
603#
604# Wireless LAN
605#
606# CONFIG_WLAN_PRE80211 is not set
607# CONFIG_WLAN_80211 is not set
608
609#
610# USB Network Adapters
611#
612# CONFIG_USB_CATC is not set
613# CONFIG_USB_KAWETH is not set
614# CONFIG_USB_PEGASUS is not set
615# CONFIG_USB_RTL8150 is not set
616# CONFIG_USB_USBNET is not set
617# CONFIG_WAN is not set
618# CONFIG_PPP is not set
619# CONFIG_SLIP is not set
620# CONFIG_SHAPER is not set
621# CONFIG_NETCONSOLE is not set
622# CONFIG_NETPOLL is not set
623# CONFIG_NET_POLL_CONTROLLER is not set
624# CONFIG_ISDN is not set
625# CONFIG_PHONE is not set
626
627#
628# Input device support
629#
630# CONFIG_INPUT is not set
631
632#
633# Hardware I/O ports
634#
635# CONFIG_SERIO is not set
636# CONFIG_GAMEPORT is not set
637
638#
639# Character devices
640#
641# CONFIG_AD9960 is not set
642# CONFIG_SPI_ADC_BF533 is not set
643# CONFIG_BF5xx_PPIFCD is not set
644# CONFIG_BFIN_SIMPLE_TIMER is not set
645# CONFIG_BF5xx_PPI is not set
646CONFIG_BFIN_OTP=y
647# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
648# CONFIG_BFIN_SPORT is not set
649# CONFIG_BFIN_TIMER_LATENCY is not set
650# CONFIG_TWI_LCD is not set
651CONFIG_SIMPLE_GPIO=m
652# CONFIG_VT is not set
653# CONFIG_SERIAL_NONSTANDARD is not set
654
655#
656# Serial drivers
657#
658# CONFIG_SERIAL_8250 is not set
659
660#
661# Non-8250 serial port support
662#
663CONFIG_SERIAL_BFIN=y
664CONFIG_SERIAL_BFIN_CONSOLE=y
665CONFIG_SERIAL_BFIN_DMA=y
666# CONFIG_SERIAL_BFIN_PIO is not set
667CONFIG_SERIAL_BFIN_UART0=y
668# CONFIG_BFIN_UART0_CTSRTS is not set
669CONFIG_SERIAL_BFIN_UART1=y
670# CONFIG_BFIN_UART1_CTSRTS is not set
671CONFIG_SERIAL_CORE=y
672CONFIG_SERIAL_CORE_CONSOLE=y
673# CONFIG_SERIAL_BFIN_SPORT is not set
674CONFIG_UNIX98_PTYS=y
675# CONFIG_LEGACY_PTYS is not set
676
677#
678# CAN, the car bus and industrial fieldbus
679#
680# CONFIG_CAN4LINUX is not set
681# CONFIG_IPMI_HANDLER is not set
682CONFIG_HW_RANDOM=y
683# CONFIG_GEN_RTC is not set
684# CONFIG_R3964 is not set
685# CONFIG_RAW_DRIVER is not set
686# CONFIG_TCG_TPM is not set
687CONFIG_I2C=y
688CONFIG_I2C_BOARDINFO=y
689CONFIG_I2C_CHARDEV=m
690
691#
692# I2C Algorithms
693#
694# CONFIG_I2C_ALGOBIT is not set
695# CONFIG_I2C_ALGOPCF is not set
696# CONFIG_I2C_ALGOPCA is not set
697
698#
699# I2C Hardware Bus support
700#
701CONFIG_I2C_BLACKFIN_TWI=m
702CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50
703# CONFIG_I2C_GPIO is not set
704# CONFIG_I2C_OCORES is not set
705# CONFIG_I2C_PARPORT_LIGHT is not set
706# CONFIG_I2C_SIMTEC is not set
707# CONFIG_I2C_TAOS_EVM is not set
708# CONFIG_I2C_STUB is not set
709# CONFIG_I2C_TINY_USB is not set
710
711#
712# Miscellaneous I2C Chip support
713#
714# CONFIG_SENSORS_DS1337 is not set
715# CONFIG_SENSORS_DS1374 is not set
716# CONFIG_DS1682 is not set
717# CONFIG_SENSORS_AD5252 is not set
718# CONFIG_SENSORS_EEPROM is not set
719# CONFIG_SENSORS_PCF8574 is not set
720# CONFIG_SENSORS_PCF8575 is not set
721# CONFIG_SENSORS_PCA9539 is not set
722# CONFIG_SENSORS_PCF8591 is not set
723# CONFIG_SENSORS_MAX6875 is not set
724# CONFIG_SENSORS_TSL2550 is not set
725# CONFIG_I2C_DEBUG_CORE is not set
726# CONFIG_I2C_DEBUG_ALGO is not set
727# CONFIG_I2C_DEBUG_BUS is not set
728# CONFIG_I2C_DEBUG_CHIP is not set
729
730#
731# SPI support
732#
733CONFIG_SPI=y
734CONFIG_SPI_MASTER=y
735
736#
737# SPI Master Controller Drivers
738#
739CONFIG_SPI_BFIN=y
740# CONFIG_SPI_BITBANG is not set
741
742#
743# SPI Protocol Masters
744#
745# CONFIG_SPI_AT25 is not set
746# CONFIG_SPI_SPIDEV is not set
747# CONFIG_SPI_TLE62X0 is not set
748# CONFIG_W1 is not set
749# CONFIG_POWER_SUPPLY is not set
750CONFIG_HWMON=y
751# CONFIG_HWMON_VID is not set
752# CONFIG_SENSORS_AD7418 is not set
753# CONFIG_SENSORS_ADM1021 is not set
754# CONFIG_SENSORS_ADM1025 is not set
755# CONFIG_SENSORS_ADM1026 is not set
756# CONFIG_SENSORS_ADM1029 is not set
757# CONFIG_SENSORS_ADM1031 is not set
758# CONFIG_SENSORS_ADM9240 is not set
759# CONFIG_SENSORS_ADT7470 is not set
760# CONFIG_SENSORS_ATXP1 is not set
761# CONFIG_SENSORS_DS1621 is not set
762# CONFIG_SENSORS_F71805F is not set
763# CONFIG_SENSORS_F71882FG is not set
764# CONFIG_SENSORS_F75375S is not set
765# CONFIG_SENSORS_GL518SM is not set
766# CONFIG_SENSORS_GL520SM is not set
767# CONFIG_SENSORS_IT87 is not set
768# CONFIG_SENSORS_LM63 is not set
769# CONFIG_SENSORS_LM70 is not set
770# CONFIG_SENSORS_LM75 is not set
771# CONFIG_SENSORS_LM77 is not set
772# CONFIG_SENSORS_LM78 is not set
773# CONFIG_SENSORS_LM80 is not set
774# CONFIG_SENSORS_LM83 is not set
775# CONFIG_SENSORS_LM85 is not set
776# CONFIG_SENSORS_LM87 is not set
777# CONFIG_SENSORS_LM90 is not set
778# CONFIG_SENSORS_LM92 is not set
779# CONFIG_SENSORS_LM93 is not set
780# CONFIG_SENSORS_MAX1619 is not set
781# CONFIG_SENSORS_MAX6650 is not set
782# CONFIG_SENSORS_PC87360 is not set
783# CONFIG_SENSORS_PC87427 is not set
784# CONFIG_SENSORS_DME1737 is not set
785# CONFIG_SENSORS_SMSC47M1 is not set
786# CONFIG_SENSORS_SMSC47M192 is not set
787# CONFIG_SENSORS_SMSC47B397 is not set
788# CONFIG_SENSORS_THMC50 is not set
789# CONFIG_SENSORS_VT1211 is not set
790# CONFIG_SENSORS_W83781D is not set
791# CONFIG_SENSORS_W83791D is not set
792# CONFIG_SENSORS_W83792D is not set
793# CONFIG_SENSORS_W83793 is not set
794# CONFIG_SENSORS_W83L785TS is not set
795# CONFIG_SENSORS_W83627HF is not set
796# CONFIG_SENSORS_W83627EHF is not set
797# CONFIG_HWMON_DEBUG_CHIP is not set
798CONFIG_WATCHDOG=y
799# CONFIG_WATCHDOG_NOWAYOUT is not set
800
801#
802# Watchdog Device Drivers
803#
804# CONFIG_SOFT_WATCHDOG is not set
805CONFIG_BFIN_WDT=y
806
807#
808# USB-based Watchdog Cards
809#
810# CONFIG_USBPCWATCHDOG is not set
811
812#
813# Sonics Silicon Backplane
814#
815CONFIG_SSB_POSSIBLE=y
816# CONFIG_SSB is not set
817
818#
819# Multifunction device drivers
820#
821# CONFIG_MFD_SM501 is not set
822
823#
824# Multimedia devices
825#
826# CONFIG_VIDEO_DEV is not set
827# CONFIG_DVB_CORE is not set
828# CONFIG_DAB is not set
829
830#
831# Graphics support
832#
833# CONFIG_VGASTATE is not set
834# CONFIG_VIDEO_OUTPUT_CONTROL is not set
835# CONFIG_FB is not set
836# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
837
838#
839# Display device support
840#
841# CONFIG_DISPLAY_SUPPORT is not set
842
843#
844# Sound
845#
846# CONFIG_SOUND is not set
847CONFIG_USB_SUPPORT=y
848CONFIG_USB_ARCH_HAS_HCD=y
849# CONFIG_USB_ARCH_HAS_OHCI is not set
850# CONFIG_USB_ARCH_HAS_EHCI is not set
851CONFIG_USB=y
852# CONFIG_USB_DEBUG is not set
853
854#
855# Miscellaneous USB options
856#
857# CONFIG_USB_DEVICEFS is not set
858CONFIG_USB_DEVICE_CLASS=y
859# CONFIG_USB_DYNAMIC_MINORS is not set
860# CONFIG_USB_OTG is not set
861# CONFIG_USB_OTG_WHITELIST is not set
862CONFIG_USB_OTG_BLACKLIST_HUB=y
863
864#
865# USB Host Controller Drivers
866#
867# CONFIG_USB_ISP116X_HCD is not set
868# CONFIG_USB_ISP1362_HCD is not set
869# CONFIG_USB_ISP1760_HCD is not set
870# CONFIG_USB_SL811_HCD is not set
871# CONFIG_USB_R8A66597_HCD is not set
872CONFIG_USB_MUSB_HDRC=y
873CONFIG_USB_MUSB_SOC=y
874
875#
876# Blackfin high speed USB support
877#
878CONFIG_USB_MUSB_HOST=y
879# CONFIG_USB_MUSB_PERIPHERAL is not set
880# CONFIG_USB_MUSB_OTG is not set
881CONFIG_USB_MUSB_HDRC_HCD=y
882CONFIG_MUSB_PIO_ONLY=y
883CONFIG_USB_MUSB_LOGLEVEL=0
884
885#
886# USB Device Class drivers
887#
888# CONFIG_USB_ACM is not set
889# CONFIG_USB_PRINTER is not set
890
891#
892# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
893#
894
895#
896# may also be needed; see USB_STORAGE Help for more information
897#
898# CONFIG_USB_LIBUSUAL is not set
899
900#
901# USB Imaging devices
902#
903# CONFIG_USB_MDC800 is not set
904CONFIG_USB_MON=y
905
906#
907# USB port drivers
908#
909
910#
911# USB Serial Converter support
912#
913# CONFIG_USB_SERIAL is not set
914
915#
916# USB Miscellaneous drivers
917#
918# CONFIG_USB_EMI62 is not set
919# CONFIG_USB_EMI26 is not set
920# CONFIG_USB_ADUTUX is not set
921# CONFIG_USB_AUERSWALD is not set
922# CONFIG_USB_RIO500 is not set
923# CONFIG_USB_LEGOTOWER is not set
924# CONFIG_USB_LCD is not set
925# CONFIG_USB_BERRY_CHARGE is not set
926# CONFIG_USB_LED is not set
927# CONFIG_USB_CYPRESS_CY7C63 is not set
928# CONFIG_USB_CYTHERM is not set
929# CONFIG_USB_PHIDGET is not set
930# CONFIG_USB_IDMOUSE is not set
931# CONFIG_USB_FTDI_ELAN is not set
932# CONFIG_USB_APPLEDISPLAY is not set
933# CONFIG_USB_SISUSBVGA is not set
934# CONFIG_USB_LD is not set
935# CONFIG_USB_TRANCEVIBRATOR is not set
936# CONFIG_USB_IOWARRIOR is not set
937
938#
939# USB DSL modem support
940#
941
942#
943# USB Gadget Support
944#
945# CONFIG_USB_GADGET is not set
946# CONFIG_MMC is not set
947# CONFIG_NEW_LEDS is not set
948CONFIG_RTC_LIB=y
949CONFIG_RTC_CLASS=y
950CONFIG_RTC_HCTOSYS=y
951CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
952# CONFIG_RTC_DEBUG is not set
953
954#
955# RTC interfaces
956#
957CONFIG_RTC_INTF_SYSFS=y
958CONFIG_RTC_INTF_PROC=y
959CONFIG_RTC_INTF_DEV=y
960# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
961# CONFIG_RTC_DRV_TEST is not set
962
963#
964# I2C RTC drivers
965#
966# CONFIG_RTC_DRV_DS1307 is not set
967# CONFIG_RTC_DRV_DS1374 is not set
968# CONFIG_RTC_DRV_DS1672 is not set
969# CONFIG_RTC_DRV_MAX6900 is not set
970# CONFIG_RTC_DRV_RS5C372 is not set
971# CONFIG_RTC_DRV_ISL1208 is not set
972# CONFIG_RTC_DRV_X1205 is not set
973# CONFIG_RTC_DRV_PCF8563 is not set
974# CONFIG_RTC_DRV_PCF8583 is not set
975# CONFIG_RTC_DRV_M41T80 is not set
976
977#
978# SPI RTC drivers
979#
980# CONFIG_RTC_DRV_RS5C348 is not set
981# CONFIG_RTC_DRV_MAX6902 is not set
982
983#
984# Platform RTC drivers
985#
986# CONFIG_RTC_DRV_DS1553 is not set
987# CONFIG_RTC_DRV_STK17TA8 is not set
988# CONFIG_RTC_DRV_DS1742 is not set
989# CONFIG_RTC_DRV_M48T86 is not set
990# CONFIG_RTC_DRV_M48T59 is not set
991# CONFIG_RTC_DRV_V3020 is not set
992
993#
994# on-CPU RTC drivers
995#
996CONFIG_RTC_DRV_BFIN=y
997
998#
999# Userspace I/O
1000#
1001# CONFIG_UIO is not set
1002
1003#
1004# File systems
1005#
1006# CONFIG_EXT2_FS is not set
1007# CONFIG_EXT3_FS is not set
1008# CONFIG_EXT4DEV_FS is not set
1009# CONFIG_REISERFS_FS is not set
1010# CONFIG_JFS_FS is not set
1011# CONFIG_FS_POSIX_ACL is not set
1012# CONFIG_XFS_FS is not set
1013# CONFIG_GFS2_FS is not set
1014# CONFIG_OCFS2_FS is not set
1015# CONFIG_MINIX_FS is not set
1016# CONFIG_ROMFS_FS is not set
1017CONFIG_INOTIFY=y
1018CONFIG_INOTIFY_USER=y
1019# CONFIG_QUOTA is not set
1020# CONFIG_DNOTIFY is not set
1021# CONFIG_AUTOFS_FS is not set
1022# CONFIG_AUTOFS4_FS is not set
1023# CONFIG_FUSE_FS is not set
1024
1025#
1026# CD-ROM/DVD Filesystems
1027#
1028# CONFIG_ISO9660_FS is not set
1029# CONFIG_UDF_FS is not set
1030
1031#
1032# DOS/FAT/NT Filesystems
1033#
1034# CONFIG_MSDOS_FS is not set
1035# CONFIG_VFAT_FS is not set
1036# CONFIG_NTFS_FS is not set
1037
1038#
1039# Pseudo filesystems
1040#
1041CONFIG_PROC_FS=y
1042CONFIG_PROC_SYSCTL=y
1043CONFIG_SYSFS=y
1044# CONFIG_TMPFS is not set
1045# CONFIG_HUGETLB_PAGE is not set
1046# CONFIG_CONFIGFS_FS is not set
1047
1048#
1049# Miscellaneous filesystems
1050#
1051# CONFIG_ADFS_FS is not set
1052# CONFIG_AFFS_FS is not set
1053# CONFIG_HFS_FS is not set
1054# CONFIG_HFSPLUS_FS is not set
1055# CONFIG_BEFS_FS is not set
1056# CONFIG_BFS_FS is not set
1057# CONFIG_EFS_FS is not set
1058# CONFIG_YAFFS_FS is not set
1059# CONFIG_JFFS2_FS is not set
1060# CONFIG_CRAMFS is not set
1061# CONFIG_VXFS_FS is not set
1062# CONFIG_HPFS_FS is not set
1063# CONFIG_QNX4FS_FS is not set
1064# CONFIG_SYSV_FS is not set
1065# CONFIG_UFS_FS is not set
1066CONFIG_NETWORK_FILESYSTEMS=y
1067CONFIG_NFS_FS=m
1068CONFIG_NFS_V3=y
1069# CONFIG_NFS_V3_ACL is not set
1070# CONFIG_NFS_V4 is not set
1071# CONFIG_NFS_DIRECTIO is not set
1072# CONFIG_NFSD is not set
1073CONFIG_LOCKD=m
1074CONFIG_LOCKD_V4=y
1075CONFIG_NFS_COMMON=y
1076CONFIG_SUNRPC=m
1077# CONFIG_SUNRPC_BIND34 is not set
1078# CONFIG_RPCSEC_GSS_KRB5 is not set
1079# CONFIG_RPCSEC_GSS_SPKM3 is not set
1080CONFIG_SMB_FS=m
1081# CONFIG_SMB_NLS_DEFAULT is not set
1082# CONFIG_CIFS is not set
1083# CONFIG_NCP_FS is not set
1084# CONFIG_CODA_FS is not set
1085# CONFIG_AFS_FS is not set
1086
1087#
1088# Partition Types
1089#
1090# CONFIG_PARTITION_ADVANCED is not set
1091CONFIG_MSDOS_PARTITION=y
1092CONFIG_NLS=m
1093CONFIG_NLS_DEFAULT="iso8859-1"
1094# CONFIG_NLS_CODEPAGE_437 is not set
1095# CONFIG_NLS_CODEPAGE_737 is not set
1096# CONFIG_NLS_CODEPAGE_775 is not set
1097# CONFIG_NLS_CODEPAGE_850 is not set
1098# CONFIG_NLS_CODEPAGE_852 is not set
1099# CONFIG_NLS_CODEPAGE_855 is not set
1100# CONFIG_NLS_CODEPAGE_857 is not set
1101# CONFIG_NLS_CODEPAGE_860 is not set
1102# CONFIG_NLS_CODEPAGE_861 is not set
1103# CONFIG_NLS_CODEPAGE_862 is not set
1104# CONFIG_NLS_CODEPAGE_863 is not set
1105# CONFIG_NLS_CODEPAGE_864 is not set
1106# CONFIG_NLS_CODEPAGE_865 is not set
1107# CONFIG_NLS_CODEPAGE_866 is not set
1108# CONFIG_NLS_CODEPAGE_869 is not set
1109# CONFIG_NLS_CODEPAGE_936 is not set
1110# CONFIG_NLS_CODEPAGE_950 is not set
1111# CONFIG_NLS_CODEPAGE_932 is not set
1112# CONFIG_NLS_CODEPAGE_949 is not set
1113# CONFIG_NLS_CODEPAGE_874 is not set
1114# CONFIG_NLS_ISO8859_8 is not set
1115# CONFIG_NLS_CODEPAGE_1250 is not set
1116# CONFIG_NLS_CODEPAGE_1251 is not set
1117# CONFIG_NLS_ASCII is not set
1118# CONFIG_NLS_ISO8859_1 is not set
1119# CONFIG_NLS_ISO8859_2 is not set
1120# CONFIG_NLS_ISO8859_3 is not set
1121# CONFIG_NLS_ISO8859_4 is not set
1122# CONFIG_NLS_ISO8859_5 is not set
1123# CONFIG_NLS_ISO8859_6 is not set
1124# CONFIG_NLS_ISO8859_7 is not set
1125# CONFIG_NLS_ISO8859_9 is not set
1126# CONFIG_NLS_ISO8859_13 is not set
1127# CONFIG_NLS_ISO8859_14 is not set
1128# CONFIG_NLS_ISO8859_15 is not set
1129# CONFIG_NLS_KOI8_R is not set
1130# CONFIG_NLS_KOI8_U is not set
1131# CONFIG_NLS_UTF8 is not set
1132# CONFIG_DLM is not set
1133# CONFIG_INSTRUMENTATION is not set
1134
1135#
1136# Kernel hacking
1137#
1138# CONFIG_PRINTK_TIME is not set
1139CONFIG_ENABLE_WARN_DEPRECATED=y
1140CONFIG_ENABLE_MUST_CHECK=y
1141# CONFIG_MAGIC_SYSRQ is not set
1142# CONFIG_UNUSED_SYMBOLS is not set
1143CONFIG_DEBUG_FS=y
1144# CONFIG_HEADERS_CHECK is not set
1145# CONFIG_DEBUG_KERNEL is not set
1146# CONFIG_DEBUG_BUGVERBOSE is not set
1147# CONFIG_SAMPLES is not set
1148CONFIG_DEBUG_MMRS=y
1149CONFIG_DEBUG_HUNT_FOR_ZERO=y
1150CONFIG_DEBUG_BFIN_HWTRACE_ON=y
1151CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
1152# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set
1153# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_TWO is not set
1154CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
1155# CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
1156# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
1157CONFIG_EARLY_PRINTK=y
1158# CONFIG_CPLB_INFO is not set
1159CONFIG_ACCESS_CHECK=y
1160
1161#
1162# Security options
1163#
1164# CONFIG_KEYS is not set
1165CONFIG_SECURITY=y
1166# CONFIG_SECURITY_NETWORK is not set
1167# CONFIG_SECURITY_CAPABILITIES is not set
1168# CONFIG_SECURITY_ROOTPLUG is not set
1169# CONFIG_CRYPTO is not set
1170
1171#
1172# Library routines
1173#
1174CONFIG_BITREVERSE=y
1175CONFIG_CRC_CCITT=m
1176# CONFIG_CRC16 is not set
1177# CONFIG_CRC_ITU_T is not set
1178CONFIG_CRC32=y
1179# CONFIG_CRC7 is not set
1180# CONFIG_LIBCRC32C is not set
1181CONFIG_ZLIB_INFLATE=y
1182CONFIG_PLIST=y
1183CONFIG_HAS_IOMEM=y
1184CONFIG_HAS_IOPORT=y
1185CONFIG_HAS_DMA=y
diff --git a/arch/blackfin/configs/CM-BF533_defconfig b/arch/blackfin/configs/CM-BF533_defconfig
index 560890fe0d30..09deea44480b 100644
--- a/arch/blackfin/configs/CM-BF533_defconfig
+++ b/arch/blackfin/configs/CM-BF533_defconfig
@@ -39,7 +39,8 @@ CONFIG_SYSVIPC_SYSCTL=y
39# CONFIG_TASKSTATS is not set 39# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 40# CONFIG_UTS_NS is not set
41# CONFIG_AUDIT is not set 41# CONFIG_AUDIT is not set
42# CONFIG_IKCONFIG is not set 42CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y
43CONFIG_LOG_BUF_SHIFT=14 44CONFIG_LOG_BUF_SHIFT=14
44CONFIG_SYSFS_DEPRECATED=y 45CONFIG_SYSFS_DEPRECATED=y
45# CONFIG_RELAY is not set 46# CONFIG_RELAY is not set
@@ -291,7 +292,7 @@ CONFIG_C_AMBEN_ALL=y
291CONFIG_BANK_0=0x7BB0 292CONFIG_BANK_0=0x7BB0
292CONFIG_BANK_1=0x7BB0 293CONFIG_BANK_1=0x7BB0
293CONFIG_BANK_2=0x7BB0 294CONFIG_BANK_2=0x7BB0
294CONFIG_BANK_3=0xFFC3 295CONFIG_BANK_3=0xFFC2
295 296
296# 297#
297# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 298# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -617,8 +618,7 @@ CONFIG_SERIAL_CORE=y
617CONFIG_SERIAL_CORE_CONSOLE=y 618CONFIG_SERIAL_CORE_CONSOLE=y
618# CONFIG_SERIAL_BFIN_SPORT is not set 619# CONFIG_SERIAL_BFIN_SPORT is not set
619CONFIG_UNIX98_PTYS=y 620CONFIG_UNIX98_PTYS=y
620CONFIG_LEGACY_PTYS=y 621# CONFIG_LEGACY_PTYS is not set
621CONFIG_LEGACY_PTY_COUNT=256
622 622
623# 623#
624# CAN, the car bus and industrial fieldbus 624# CAN, the car bus and industrial fieldbus
@@ -778,7 +778,7 @@ CONFIG_FS_MBCACHE=y
778CONFIG_INOTIFY=y 778CONFIG_INOTIFY=y
779CONFIG_INOTIFY_USER=y 779CONFIG_INOTIFY_USER=y
780# CONFIG_QUOTA is not set 780# CONFIG_QUOTA is not set
781CONFIG_DNOTIFY=y 781# CONFIG_DNOTIFY is not set
782# CONFIG_AUTOFS_FS is not set 782# CONFIG_AUTOFS_FS is not set
783# CONFIG_AUTOFS4_FS is not set 783# CONFIG_AUTOFS4_FS is not set
784# CONFIG_FUSE_FS is not set 784# CONFIG_FUSE_FS is not set
@@ -866,11 +866,11 @@ CONFIG_MSDOS_PARTITION=y
866CONFIG_ENABLE_MUST_CHECK=y 866CONFIG_ENABLE_MUST_CHECK=y
867# CONFIG_MAGIC_SYSRQ is not set 867# CONFIG_MAGIC_SYSRQ is not set
868# CONFIG_UNUSED_SYMBOLS is not set 868# CONFIG_UNUSED_SYMBOLS is not set
869# CONFIG_DEBUG_FS is not set 869CONFIG_DEBUG_FS=y
870# CONFIG_HEADERS_CHECK is not set 870# CONFIG_HEADERS_CHECK is not set
871# CONFIG_DEBUG_KERNEL is not set 871# CONFIG_DEBUG_KERNEL is not set
872# CONFIG_DEBUG_BUGVERBOSE is not set 872# CONFIG_DEBUG_BUGVERBOSE is not set
873# CONFIG_DEBUG_MMRS is not set 873CONFIG_DEBUG_MMRS=y
874CONFIG_DEBUG_HUNT_FOR_ZERO=y 874CONFIG_DEBUG_HUNT_FOR_ZERO=y
875CONFIG_DEBUG_BFIN_HWTRACE_ON=y 875CONFIG_DEBUG_BFIN_HWTRACE_ON=y
876CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 876CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
diff --git a/arch/blackfin/configs/CM-BF537E_defconfig b/arch/blackfin/configs/CM-BF537E_defconfig
index 9f66d2de1007..219fc345a5f5 100644
--- a/arch/blackfin/configs/CM-BF537E_defconfig
+++ b/arch/blackfin/configs/CM-BF537E_defconfig
@@ -39,7 +39,8 @@ CONFIG_SYSVIPC_SYSCTL=y
39# CONFIG_TASKSTATS is not set 39# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 40# CONFIG_UTS_NS is not set
41# CONFIG_AUDIT is not set 41# CONFIG_AUDIT is not set
42# CONFIG_IKCONFIG is not set 42CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y
43CONFIG_LOG_BUF_SHIFT=14 44CONFIG_LOG_BUF_SHIFT=14
44CONFIG_SYSFS_DEPRECATED=y 45CONFIG_SYSFS_DEPRECATED=y
45# CONFIG_RELAY is not set 46# CONFIG_RELAY is not set
@@ -299,7 +300,7 @@ CONFIG_C_AMBEN_ALL=y
299CONFIG_BANK_0=0x7BB0 300CONFIG_BANK_0=0x7BB0
300CONFIG_BANK_1=0x7BB0 301CONFIG_BANK_1=0x7BB0
301CONFIG_BANK_2=0x7BB0 302CONFIG_BANK_2=0x7BB0
302CONFIG_BANK_3=0xFFC3 303CONFIG_BANK_3=0xFFC2
303 304
304# 305#
305# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 306# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -351,7 +352,10 @@ CONFIG_INET=y
351# CONFIG_IP_MULTICAST is not set 352# CONFIG_IP_MULTICAST is not set
352# CONFIG_IP_ADVANCED_ROUTER is not set 353# CONFIG_IP_ADVANCED_ROUTER is not set
353CONFIG_IP_FIB_HASH=y 354CONFIG_IP_FIB_HASH=y
354# CONFIG_IP_PNP is not set 355CONFIG_IP_PNP=y
356# CONFIG_IP_PNP_DHCP is not set
357# CONFIG_IP_PNP_BOOTP is not set
358# CONFIG_IP_PNP_RARP is not set
355# CONFIG_NET_IPIP is not set 359# CONFIG_NET_IPIP is not set
356# CONFIG_NET_IPGRE is not set 360# CONFIG_NET_IPGRE is not set
357# CONFIG_ARPD is not set 361# CONFIG_ARPD is not set
@@ -645,8 +649,7 @@ CONFIG_SERIAL_CORE=y
645CONFIG_SERIAL_CORE_CONSOLE=y 649CONFIG_SERIAL_CORE_CONSOLE=y
646# CONFIG_SERIAL_BFIN_SPORT is not set 650# CONFIG_SERIAL_BFIN_SPORT is not set
647CONFIG_UNIX98_PTYS=y 651CONFIG_UNIX98_PTYS=y
648CONFIG_LEGACY_PTYS=y 652# CONFIG_LEGACY_PTYS is not set
649CONFIG_LEGACY_PTY_COUNT=256
650 653
651# 654#
652# CAN, the car bus and industrial fieldbus 655# CAN, the car bus and industrial fieldbus
@@ -806,7 +809,7 @@ CONFIG_FS_MBCACHE=y
806CONFIG_INOTIFY=y 809CONFIG_INOTIFY=y
807CONFIG_INOTIFY_USER=y 810CONFIG_INOTIFY_USER=y
808# CONFIG_QUOTA is not set 811# CONFIG_QUOTA is not set
809CONFIG_DNOTIFY=y 812# CONFIG_DNOTIFY is not set
810# CONFIG_AUTOFS_FS is not set 813# CONFIG_AUTOFS_FS is not set
811# CONFIG_AUTOFS4_FS is not set 814# CONFIG_AUTOFS4_FS is not set
812# CONFIG_FUSE_FS is not set 815# CONFIG_FUSE_FS is not set
@@ -894,12 +897,12 @@ CONFIG_MSDOS_PARTITION=y
894CONFIG_ENABLE_MUST_CHECK=y 897CONFIG_ENABLE_MUST_CHECK=y
895# CONFIG_MAGIC_SYSRQ is not set 898# CONFIG_MAGIC_SYSRQ is not set
896# CONFIG_UNUSED_SYMBOLS is not set 899# CONFIG_UNUSED_SYMBOLS is not set
897# CONFIG_DEBUG_FS is not set 900CONFIG_DEBUG_FS=y
898# CONFIG_HEADERS_CHECK is not set 901# CONFIG_HEADERS_CHECK is not set
899# CONFIG_DEBUG_KERNEL is not set 902# CONFIG_DEBUG_KERNEL is not set
900# CONFIG_DEBUG_BUGVERBOSE is not set 903# CONFIG_DEBUG_BUGVERBOSE is not set
901# CONFIG_DEBUG_MMRS is not set 904CONFIG_DEBUG_MMRS=y
902# CONFIG_DEBUG_HUNT_FOR_ZERO is not set 905CONFIG_DEBUG_HUNT_FOR_ZERO=y
903CONFIG_DEBUG_BFIN_HWTRACE_ON=y 906CONFIG_DEBUG_BFIN_HWTRACE_ON=y
904CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 907CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
905# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set 908# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set
diff --git a/arch/blackfin/configs/CM-BF537U_defconfig b/arch/blackfin/configs/CM-BF537U_defconfig
index 2694d06c5bde..9873d586fc77 100644
--- a/arch/blackfin/configs/CM-BF537U_defconfig
+++ b/arch/blackfin/configs/CM-BF537U_defconfig
@@ -39,7 +39,8 @@ CONFIG_SYSVIPC_SYSCTL=y
39# CONFIG_TASKSTATS is not set 39# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set 40# CONFIG_UTS_NS is not set
41# CONFIG_AUDIT is not set 41# CONFIG_AUDIT is not set
42# CONFIG_IKCONFIG is not set 42CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y
43CONFIG_LOG_BUF_SHIFT=14 44CONFIG_LOG_BUF_SHIFT=14
44CONFIG_SYSFS_DEPRECATED=y 45CONFIG_SYSFS_DEPRECATED=y
45# CONFIG_RELAY is not set 46# CONFIG_RELAY is not set
@@ -298,8 +299,8 @@ CONFIG_C_AMBEN_ALL=y
298# 299#
299CONFIG_BANK_0=0x7BB0 300CONFIG_BANK_0=0x7BB0
300CONFIG_BANK_1=0x7BB0 301CONFIG_BANK_1=0x7BB0
301CONFIG_BANK_2=0xFFC3 302CONFIG_BANK_2=0xFFC2
302CONFIG_BANK_3=0xFFC3 303CONFIG_BANK_3=0xFFC2
303 304
304# 305#
305# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 306# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -628,8 +629,7 @@ CONFIG_SERIAL_CORE=y
628CONFIG_SERIAL_CORE_CONSOLE=y 629CONFIG_SERIAL_CORE_CONSOLE=y
629# CONFIG_SERIAL_BFIN_SPORT is not set 630# CONFIG_SERIAL_BFIN_SPORT is not set
630CONFIG_UNIX98_PTYS=y 631CONFIG_UNIX98_PTYS=y
631CONFIG_LEGACY_PTYS=y 632# CONFIG_LEGACY_PTYS is not set
632CONFIG_LEGACY_PTY_COUNT=256
633 633
634# 634#
635# CAN, the car bus and industrial fieldbus 635# CAN, the car bus and industrial fieldbus
@@ -806,7 +806,7 @@ CONFIG_FS_MBCACHE=y
806CONFIG_INOTIFY=y 806CONFIG_INOTIFY=y
807CONFIG_INOTIFY_USER=y 807CONFIG_INOTIFY_USER=y
808# CONFIG_QUOTA is not set 808# CONFIG_QUOTA is not set
809CONFIG_DNOTIFY=y 809# CONFIG_DNOTIFY is not set
810# CONFIG_AUTOFS_FS is not set 810# CONFIG_AUTOFS_FS is not set
811# CONFIG_AUTOFS4_FS is not set 811# CONFIG_AUTOFS4_FS is not set
812# CONFIG_FUSE_FS is not set 812# CONFIG_FUSE_FS is not set
@@ -894,12 +894,12 @@ CONFIG_MSDOS_PARTITION=y
894CONFIG_ENABLE_MUST_CHECK=y 894CONFIG_ENABLE_MUST_CHECK=y
895# CONFIG_MAGIC_SYSRQ is not set 895# CONFIG_MAGIC_SYSRQ is not set
896# CONFIG_UNUSED_SYMBOLS is not set 896# CONFIG_UNUSED_SYMBOLS is not set
897# CONFIG_DEBUG_FS is not set 897CONFIG_DEBUG_FS=y
898# CONFIG_HEADERS_CHECK is not set 898# CONFIG_HEADERS_CHECK is not set
899# CONFIG_DEBUG_KERNEL is not set 899# CONFIG_DEBUG_KERNEL is not set
900# CONFIG_DEBUG_BUGVERBOSE is not set 900# CONFIG_DEBUG_BUGVERBOSE is not set
901# CONFIG_DEBUG_MMRS is not set 901CONFIG_DEBUG_MMRS=y
902# CONFIG_DEBUG_HUNT_FOR_ZERO is not set 902CONFIG_DEBUG_HUNT_FOR_ZERO=y
903CONFIG_DEBUG_BFIN_HWTRACE_ON=y 903CONFIG_DEBUG_BFIN_HWTRACE_ON=y
904CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 904CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
905# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set 905# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set
diff --git a/arch/blackfin/configs/CM-BF548_defconfig b/arch/blackfin/configs/CM-BF548_defconfig
index 90207251c533..0e3605fdb7b0 100644
--- a/arch/blackfin/configs/CM-BF548_defconfig
+++ b/arch/blackfin/configs/CM-BF548_defconfig
@@ -363,7 +363,7 @@ CONFIG_C_AMBEN_ALL=y
363CONFIG_BANK_0=0x7BB0 363CONFIG_BANK_0=0x7BB0
364CONFIG_BANK_1=0x5554 364CONFIG_BANK_1=0x5554
365CONFIG_BANK_2=0x7BB0 365CONFIG_BANK_2=0x7BB0
366CONFIG_BANK_3=0x99B3 366CONFIG_BANK_3=0x99B2
367CONFIG_EBIU_MBSCTLVAL=0x0 367CONFIG_EBIU_MBSCTLVAL=0x0
368CONFIG_EBIU_MODEVAL=0x1 368CONFIG_EBIU_MODEVAL=0x1
369CONFIG_EBIU_FCTLVAL=0x6 369CONFIG_EBIU_FCTLVAL=0x6
@@ -744,8 +744,8 @@ CONFIG_BFIN_OTP=y
744# 744#
745CONFIG_SERIAL_BFIN=y 745CONFIG_SERIAL_BFIN=y
746CONFIG_SERIAL_BFIN_CONSOLE=y 746CONFIG_SERIAL_BFIN_CONSOLE=y
747# CONFIG_SERIAL_BFIN_DMA is not set 747CONFIG_SERIAL_BFIN_DMA=y
748CONFIG_SERIAL_BFIN_PIO=y 748# CONFIG_SERIAL_BFIN_PIO is not set
749# CONFIG_SERIAL_BFIN_UART0 is not set 749# CONFIG_SERIAL_BFIN_UART0 is not set
750CONFIG_SERIAL_BFIN_UART1=y 750CONFIG_SERIAL_BFIN_UART1=y
751# CONFIG_BFIN_UART1_CTSRTS is not set 751# CONFIG_BFIN_UART1_CTSRTS is not set
@@ -1149,7 +1149,7 @@ CONFIG_RTC_DRV_BFIN=y
1149CONFIG_INOTIFY=y 1149CONFIG_INOTIFY=y
1150CONFIG_INOTIFY_USER=y 1150CONFIG_INOTIFY_USER=y
1151# CONFIG_QUOTA is not set 1151# CONFIG_QUOTA is not set
1152CONFIG_DNOTIFY=y 1152# CONFIG_DNOTIFY is not set
1153# CONFIG_AUTOFS_FS is not set 1153# CONFIG_AUTOFS_FS is not set
1154# CONFIG_AUTOFS4_FS is not set 1154# CONFIG_AUTOFS4_FS is not set
1155# CONFIG_FUSE_FS is not set 1155# CONFIG_FUSE_FS is not set
@@ -1332,7 +1332,7 @@ CONFIG_DEBUG_FS=y
1332# CONFIG_DEBUG_KERNEL is not set 1332# CONFIG_DEBUG_KERNEL is not set
1333# CONFIG_DEBUG_BUGVERBOSE is not set 1333# CONFIG_DEBUG_BUGVERBOSE is not set
1334# CONFIG_SAMPLES is not set 1334# CONFIG_SAMPLES is not set
1335# CONFIG_DEBUG_MMRS is not set 1335CONFIG_DEBUG_MMRS=y
1336CONFIG_DEBUG_HUNT_FOR_ZERO=y 1336CONFIG_DEBUG_HUNT_FOR_ZERO=y
1337CONFIG_DEBUG_BFIN_HWTRACE_ON=y 1337CONFIG_DEBUG_BFIN_HWTRACE_ON=y
1338CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 1338CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
diff --git a/arch/blackfin/configs/CM-BF561_defconfig b/arch/blackfin/configs/CM-BF561_defconfig
index daf00906c1ef..59c7cdbee904 100644
--- a/arch/blackfin/configs/CM-BF561_defconfig
+++ b/arch/blackfin/configs/CM-BF561_defconfig
@@ -35,7 +35,8 @@ CONFIG_SYSVIPC_SYSCTL=y
35# CONFIG_USER_NS is not set 35# CONFIG_USER_NS is not set
36# CONFIG_PID_NS is not set 36# CONFIG_PID_NS is not set
37# CONFIG_AUDIT is not set 37# CONFIG_AUDIT is not set
38# CONFIG_IKCONFIG is not set 38CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y
39CONFIG_LOG_BUF_SHIFT=14 40CONFIG_LOG_BUF_SHIFT=14
40# CONFIG_CGROUPS is not set 41# CONFIG_CGROUPS is not set
41CONFIG_FAIR_GROUP_SCHED=y 42CONFIG_FAIR_GROUP_SCHED=y
@@ -341,7 +342,7 @@ CONFIG_C_AMBEN_ALL=y
341CONFIG_BANK_0=0x7BB0 342CONFIG_BANK_0=0x7BB0
342CONFIG_BANK_1=0x7BB0 343CONFIG_BANK_1=0x7BB0
343CONFIG_BANK_2=0x7BB0 344CONFIG_BANK_2=0x7BB0
344CONFIG_BANK_3=0xFFC3 345CONFIG_BANK_3=0xFFC2
345 346
346# 347#
347# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 348# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -631,8 +632,7 @@ CONFIG_SERIAL_CORE=y
631CONFIG_SERIAL_CORE_CONSOLE=y 632CONFIG_SERIAL_CORE_CONSOLE=y
632# CONFIG_SERIAL_BFIN_SPORT is not set 633# CONFIG_SERIAL_BFIN_SPORT is not set
633CONFIG_UNIX98_PTYS=y 634CONFIG_UNIX98_PTYS=y
634CONFIG_LEGACY_PTYS=y 635# CONFIG_LEGACY_PTYS is not set
635CONFIG_LEGACY_PTY_COUNT=256
636 636
637# 637#
638# CAN, the car bus and industrial fieldbus 638# CAN, the car bus and industrial fieldbus
@@ -756,7 +756,7 @@ CONFIG_FS_MBCACHE=y
756CONFIG_INOTIFY=y 756CONFIG_INOTIFY=y
757CONFIG_INOTIFY_USER=y 757CONFIG_INOTIFY_USER=y
758# CONFIG_QUOTA is not set 758# CONFIG_QUOTA is not set
759CONFIG_DNOTIFY=y 759# CONFIG_DNOTIFY is not set
760# CONFIG_AUTOFS_FS is not set 760# CONFIG_AUTOFS_FS is not set
761# CONFIG_AUTOFS4_FS is not set 761# CONFIG_AUTOFS4_FS is not set
762# CONFIG_FUSE_FS is not set 762# CONFIG_FUSE_FS is not set
@@ -830,12 +830,12 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
830CONFIG_ENABLE_MUST_CHECK=y 830CONFIG_ENABLE_MUST_CHECK=y
831# CONFIG_MAGIC_SYSRQ is not set 831# CONFIG_MAGIC_SYSRQ is not set
832# CONFIG_UNUSED_SYMBOLS is not set 832# CONFIG_UNUSED_SYMBOLS is not set
833# CONFIG_DEBUG_FS is not set 833CONFIG_DEBUG_FS=y
834# CONFIG_HEADERS_CHECK is not set 834# CONFIG_HEADERS_CHECK is not set
835# CONFIG_DEBUG_KERNEL is not set 835# CONFIG_DEBUG_KERNEL is not set
836# CONFIG_DEBUG_BUGVERBOSE is not set 836# CONFIG_DEBUG_BUGVERBOSE is not set
837# CONFIG_SAMPLES is not set 837# CONFIG_SAMPLES is not set
838# CONFIG_DEBUG_MMRS is not set 838CONFIG_DEBUG_MMRS=y
839CONFIG_DEBUG_HUNT_FOR_ZERO=y 839CONFIG_DEBUG_HUNT_FOR_ZERO=y
840CONFIG_DEBUG_BFIN_HWTRACE_ON=y 840CONFIG_DEBUG_BFIN_HWTRACE_ON=y
841CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 841CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
diff --git a/arch/blackfin/configs/H8606_defconfig b/arch/blackfin/configs/H8606_defconfig
index 679c7483ea71..ba0bee90b7e1 100644
--- a/arch/blackfin/configs/H8606_defconfig
+++ b/arch/blackfin/configs/H8606_defconfig
@@ -967,7 +967,7 @@ CONFIG_FS_MBCACHE=y
967CONFIG_INOTIFY=y 967CONFIG_INOTIFY=y
968CONFIG_INOTIFY_USER=y 968CONFIG_INOTIFY_USER=y
969# CONFIG_QUOTA is not set 969# CONFIG_QUOTA is not set
970CONFIG_DNOTIFY=y 970# CONFIG_DNOTIFY is not set
971# CONFIG_AUTOFS_FS is not set 971# CONFIG_AUTOFS_FS is not set
972# CONFIG_AUTOFS4_FS is not set 972# CONFIG_AUTOFS4_FS is not set
973# CONFIG_FUSE_FS is not set 973# CONFIG_FUSE_FS is not set
diff --git a/arch/blackfin/configs/IP0X_defconfig b/arch/blackfin/configs/IP0X_defconfig
index 4384a670a8b8..285d2241df26 100644
--- a/arch/blackfin/configs/IP0X_defconfig
+++ b/arch/blackfin/configs/IP0X_defconfig
@@ -1066,7 +1066,7 @@ CONFIG_FS_MBCACHE=y
1066CONFIG_INOTIFY=y 1066CONFIG_INOTIFY=y
1067CONFIG_INOTIFY_USER=y 1067CONFIG_INOTIFY_USER=y
1068# CONFIG_QUOTA is not set 1068# CONFIG_QUOTA is not set
1069CONFIG_DNOTIFY=y 1069# CONFIG_DNOTIFY is not set
1070# CONFIG_AUTOFS_FS is not set 1070# CONFIG_AUTOFS_FS is not set
1071# CONFIG_AUTOFS4_FS is not set 1071# CONFIG_AUTOFS4_FS is not set
1072# CONFIG_FUSE_FS is not set 1072# CONFIG_FUSE_FS is not set
diff --git a/arch/blackfin/configs/PNAV-10_defconfig b/arch/blackfin/configs/PNAV-10_defconfig
index 87622ad9df47..bffca7de65d4 100644
--- a/arch/blackfin/configs/PNAV-10_defconfig
+++ b/arch/blackfin/configs/PNAV-10_defconfig
@@ -294,7 +294,7 @@ CONFIG_C_AMBEN_ALL=y
294CONFIG_BANK_0=0x7BB0 294CONFIG_BANK_0=0x7BB0
295CONFIG_BANK_1=0x33B0 295CONFIG_BANK_1=0x33B0
296CONFIG_BANK_2=0x33B0 296CONFIG_BANK_2=0x33B0
297CONFIG_BANK_3=0x99B3 297CONFIG_BANK_3=0x99B2
298 298
299# 299#
300# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 300# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -1080,7 +1080,7 @@ CONFIG_FS_MBCACHE=y
1080CONFIG_INOTIFY=y 1080CONFIG_INOTIFY=y
1081CONFIG_INOTIFY_USER=y 1081CONFIG_INOTIFY_USER=y
1082# CONFIG_QUOTA is not set 1082# CONFIG_QUOTA is not set
1083CONFIG_DNOTIFY=y 1083# CONFIG_DNOTIFY is not set
1084# CONFIG_AUTOFS_FS is not set 1084# CONFIG_AUTOFS_FS is not set
1085# CONFIG_AUTOFS4_FS is not set 1085# CONFIG_AUTOFS4_FS is not set
1086# CONFIG_FUSE_FS is not set 1086# CONFIG_FUSE_FS is not set
diff --git a/arch/blackfin/configs/SRV1_defconfig b/arch/blackfin/configs/SRV1_defconfig
index 951ea0412576..b1309f878fcd 100644
--- a/arch/blackfin/configs/SRV1_defconfig
+++ b/arch/blackfin/configs/SRV1_defconfig
@@ -1067,7 +1067,7 @@ CONFIG_FS_MBCACHE=y
1067CONFIG_INOTIFY=y 1067CONFIG_INOTIFY=y
1068CONFIG_INOTIFY_USER=y 1068CONFIG_INOTIFY_USER=y
1069# CONFIG_QUOTA is not set 1069# CONFIG_QUOTA is not set
1070CONFIG_DNOTIFY=y 1070# CONFIG_DNOTIFY is not set
1071# CONFIG_AUTOFS_FS is not set 1071# CONFIG_AUTOFS_FS is not set
1072# CONFIG_AUTOFS4_FS is not set 1072# CONFIG_AUTOFS4_FS is not set
1073# CONFIG_FUSE_FS is not set 1073# CONFIG_FUSE_FS is not set
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
index 6140cd69c782..606adc78aa85 100644
--- a/arch/blackfin/kernel/Makefile
+++ b/arch/blackfin/kernel/Makefile
@@ -18,6 +18,5 @@ endif
18obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o 18obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o
19obj-$(CONFIG_MODULES) += module.o 19obj-$(CONFIG_MODULES) += module.o
20obj-$(CONFIG_BFIN_DMA_5XX) += bfin_dma_5xx.o 20obj-$(CONFIG_BFIN_DMA_5XX) += bfin_dma_5xx.o
21obj-$(CONFIG_DUAL_CORE_TEST_MODULE) += dualcore_test.o
22obj-$(CONFIG_KGDB) += kgdb.o 21obj-$(CONFIG_KGDB) += kgdb.o
23obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 22obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c
index d54f19085f37..93229b3d6e3e 100644
--- a/arch/blackfin/kernel/bfin_dma_5xx.c
+++ b/arch/blackfin/kernel/bfin_dma_5xx.c
@@ -472,6 +472,40 @@ unsigned long get_dma_curr_addr(unsigned int channel)
472} 472}
473EXPORT_SYMBOL(get_dma_curr_addr); 473EXPORT_SYMBOL(get_dma_curr_addr);
474 474
475#ifdef CONFIG_PM
476int blackfin_dma_suspend(void)
477{
478 int i;
479
480#ifdef CONFIG_BF561 /* IMDMA channels doesn't have a PERIPHERAL_MAP */
481 for (i = 0; i <= CH_MEM_STREAM3_SRC; i++) {
482#else
483 for (i = 0; i < MAX_BLACKFIN_DMA_CHANNEL; i++) {
484#endif
485 if (dma_ch[i].chan_status == DMA_CHANNEL_ENABLED) {
486 printk(KERN_ERR "DMA Channel %d failed to suspend\n", i);
487 return -EBUSY;
488 }
489
490 dma_ch[i].saved_peripheral_map = dma_ch[i].regs->peripheral_map;
491 }
492
493 return 0;
494}
495
496void blackfin_dma_resume(void)
497{
498 int i;
499
500#ifdef CONFIG_BF561 /* IMDMA channels doesn't have a PERIPHERAL_MAP */
501 for (i = 0; i <= CH_MEM_STREAM3_SRC; i++)
502#else
503 for (i = 0; i < MAX_BLACKFIN_DMA_CHANNEL; i++)
504#endif
505 dma_ch[i].regs->peripheral_map = dma_ch[i].saved_peripheral_map;
506}
507#endif
508
475static void *__dma_memcpy(void *dest, const void *src, size_t size) 509static void *__dma_memcpy(void *dest, const void *src, size_t size)
476{ 510{
477 int direction; /* 1 - address decrease, 0 - address increase */ 511 int direction; /* 1 - address decrease, 0 - address increase */
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index b6d89d1644cc..ecbd141e0ef2 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -186,7 +186,10 @@ static struct str_ident {
186 char name[RESOURCE_LABEL_SIZE]; 186 char name[RESOURCE_LABEL_SIZE];
187} str_ident[MAX_RESOURCES]; 187} str_ident[MAX_RESOURCES];
188 188
189#if defined(CONFIG_PM) && !defined(CONFIG_BF54x) 189#if defined(CONFIG_PM)
190#if defined(CONFIG_BF54x)
191static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)];
192#else
190static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 193static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
191static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS]; 194static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
192static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)]; 195static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)];
@@ -206,7 +209,7 @@ static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PORTF_INT
206#ifdef BF561_FAMILY 209#ifdef BF561_FAMILY
207static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB}; 210static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB};
208#endif 211#endif
209 212#endif
210#endif /* CONFIG_PM */ 213#endif /* CONFIG_PM */
211 214
212#if defined(BF548_FAMILY) 215#if defined(BF548_FAMILY)
@@ -667,7 +670,7 @@ static int bfin_gpio_wakeup_type(unsigned gpio, unsigned char type)
667 return 0; 670 return 0;
668} 671}
669 672
670u32 bfin_pm_setup(void) 673u32 bfin_pm_standby_setup(void)
671{ 674{
672 u16 bank, mask, i, gpio; 675 u16 bank, mask, i, gpio;
673 676
@@ -679,7 +682,7 @@ u32 bfin_pm_setup(void)
679 gpio_bankb[bank]->maskb = 0; 682 gpio_bankb[bank]->maskb = 0;
680 683
681 if (mask) { 684 if (mask) {
682#ifdef BF537_FAMILY 685#if defined(BF527_FAMILY) || defined(BF537_FAMILY)
683 gpio_bank_saved[bank].fer = *port_fer[bank]; 686 gpio_bank_saved[bank].fer = *port_fer[bank];
684#endif 687#endif
685 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 688 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen;
@@ -715,7 +718,7 @@ u32 bfin_pm_setup(void)
715 return 0; 718 return 0;
716} 719}
717 720
718void bfin_pm_restore(void) 721void bfin_pm_standby_restore(void)
719{ 722{
720 u16 bank, mask, i; 723 u16 bank, mask, i;
721 724
@@ -724,7 +727,7 @@ void bfin_pm_restore(void)
724 bank = gpio_bank(i); 727 bank = gpio_bank(i);
725 728
726 if (mask) { 729 if (mask) {
727#ifdef BF537_FAMILY 730#if defined(BF527_FAMILY) || defined(BF537_FAMILY)
728 *port_fer[bank] = gpio_bank_saved[bank].fer; 731 *port_fer[bank] = gpio_bank_saved[bank].fer;
729#endif 732#endif
730 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 733 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen;
@@ -743,8 +746,111 @@ void bfin_pm_restore(void)
743 AWA_DUMMY_READ(maskb); 746 AWA_DUMMY_READ(maskb);
744} 747}
745 748
749void bfin_gpio_pm_hibernate_suspend(void)
750{
751 int i, bank;
752
753 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
754 bank = gpio_bank(i);
755
756#if defined(BF527_FAMILY) || defined(BF537_FAMILY)
757 gpio_bank_saved[bank].fer = *port_fer[bank];
758#ifdef BF527_FAMILY
759 gpio_bank_saved[bank].mux = *port_mux[bank];
760#else
761 if (bank == 0)
762 gpio_bank_saved[bank].mux = bfin_read_PORT_MUX();
763#endif
764#endif
765 gpio_bank_saved[bank].data = gpio_bankb[bank]->data;
766 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen;
767 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar;
768 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir;
769 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge;
770 gpio_bank_saved[bank].both = gpio_bankb[bank]->both;
771 gpio_bank_saved[bank].maska = gpio_bankb[bank]->maska;
772 }
773
774 AWA_DUMMY_READ(maska);
775}
776
777void bfin_gpio_pm_hibernate_restore(void)
778{
779 int i, bank;
780
781 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
782 bank = gpio_bank(i);
783
784#if defined(BF527_FAMILY) || defined(BF537_FAMILY)
785#ifdef BF527_FAMILY
786 *port_mux[bank] = gpio_bank_saved[bank].mux;
787#else
788 if (bank == 0)
789 bfin_write_PORT_MUX(gpio_bank_saved[bank].mux);
790#endif
791 *port_fer[bank] = gpio_bank_saved[bank].fer;
792#endif
793 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen;
794 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir;
795 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar;
796 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge;
797 gpio_bankb[bank]->both = gpio_bank_saved[bank].both;
798
799 gpio_bankb[bank]->data_set = gpio_bank_saved[bank].data
800 | gpio_bank_saved[bank].dir;
801
802 gpio_bankb[bank]->maska = gpio_bank_saved[bank].maska;
803 }
804 AWA_DUMMY_READ(maska);
805}
806
807
746#endif 808#endif
747#else /* BF548_FAMILY */ 809#else /* BF548_FAMILY */
810#ifdef CONFIG_PM
811
812u32 bfin_pm_standby_setup(void)
813{
814 return 0;
815}
816
817void bfin_pm_standby_restore(void)
818{
819
820}
821
822void bfin_gpio_pm_hibernate_suspend(void)
823{
824 int i, bank;
825
826 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
827 bank = gpio_bank(i);
828
829 gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer;
830 gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux;
831 gpio_bank_saved[bank].data = gpio_array[bank]->port_data;
832 gpio_bank_saved[bank].data = gpio_array[bank]->port_data;
833 gpio_bank_saved[bank].inen = gpio_array[bank]->port_inen;
834 gpio_bank_saved[bank].dir = gpio_array[bank]->port_dir_set;
835 }
836}
837
838void bfin_gpio_pm_hibernate_restore(void)
839{
840 int i, bank;
841
842 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
843 bank = gpio_bank(i);
844
845 gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux;
846 gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer;
847 gpio_array[bank]->port_inen = gpio_bank_saved[bank].inen;
848 gpio_array[bank]->port_dir_set = gpio_bank_saved[bank].dir;
849 gpio_array[bank]->port_set = gpio_bank_saved[bank].data
850 | gpio_bank_saved[bank].dir;
851 }
852}
853#endif
748 854
749unsigned short get_gpio_dir(unsigned gpio) 855unsigned short get_gpio_dir(unsigned gpio)
750{ 856{
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbhdlr.S b/arch/blackfin/kernel/cplb-nompu/cplbhdlr.S
index 2788532de72b..ecbabc0a1fed 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbhdlr.S
+++ b/arch/blackfin/kernel/cplb-nompu/cplbhdlr.S
@@ -125,6 +125,6 @@ ENTRY(__cplb_hdr)
125 SP += -12; 125 SP += -12;
126 call _panic_cplb_error; 126 call _panic_cplb_error;
127 SP += 12; 127 SP += 12;
128 JUMP _handle_bad_cplb; 128 JUMP.L _handle_bad_cplb;
129 129
130ENDPROC(__cplb_hdr) 130ENDPROC(__cplb_hdr)
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbinit.c b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
index 6be0c50122e8..224e7cc30bc5 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbinit.c
+++ b/arch/blackfin/kernel/cplb-nompu/cplbinit.c
@@ -26,11 +26,7 @@
26#include <asm/cplb.h> 26#include <asm/cplb.h>
27#include <asm/cplbinit.h> 27#include <asm/cplbinit.h>
28 28
29#ifdef CONFIG_MAX_MEM_SIZE 29#define CPLB_MEM CONFIG_MAX_MEM_SIZE
30# define CPLB_MEM CONFIG_MAX_MEM_SIZE
31#else
32# define CPLB_MEM CONFIG_MEM_SIZE
33#endif
34 30
35/* 31/*
36* Number of required data CPLB switchtable entries 32* Number of required data CPLB switchtable entries
diff --git a/arch/blackfin/kernel/dualcore_test.c b/arch/blackfin/kernel/dualcore_test.c
deleted file mode 100644
index 0fcba74840b7..000000000000
--- a/arch/blackfin/kernel/dualcore_test.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * File: arch/blackfin/kernel/dualcore_test.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: Small test code for CoreB on a BF561
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/init.h>
31#include <linux/module.h>
32
33static int *testarg = (int *)0xfeb00000;
34
35static int test_init(void)
36{
37 *testarg = 1;
38 printk(KERN_INFO "Dual core test module inserted: set testarg = [%d]\n @ [%p]\n",
39 *testarg, testarg);
40 return 0;
41}
42
43static void test_exit(void)
44{
45 printk(KERN_INFO "Dual core test module removed: testarg = [%d]\n", *testarg);
46}
47
48module_init(test_init);
49module_exit(test_exit);
diff --git a/arch/blackfin/kernel/entry.S b/arch/blackfin/kernel/entry.S
index 65f4e67a65c4..31bd9bf3efae 100644
--- a/arch/blackfin/kernel/entry.S
+++ b/arch/blackfin/kernel/entry.S
@@ -64,6 +64,11 @@ ENDPROC(_ret_from_fork)
64 64
65ENTRY(_sys_fork) 65ENTRY(_sys_fork)
66 r0 = -EINVAL; 66 r0 = -EINVAL;
67#if (ANOMALY_05000371)
68 nop;
69 nop;
70 nop;
71#endif
67 rts; 72 rts;
68ENDPROC(_sys_fork) 73ENDPROC(_sys_fork)
69 74
diff --git a/arch/blackfin/kernel/kgdb.c b/arch/blackfin/kernel/kgdb.c
index a9c15515bfd7..a1f9641a6425 100644
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -203,6 +203,8 @@ struct hw_breakpoint {
203 203
204int kgdb_arch_init(void) 204int kgdb_arch_init(void)
205{ 205{
206 debugger_step = 0;
207
206 kgdb_remove_all_hw_break(); 208 kgdb_remove_all_hw_break();
207 return 0; 209 return 0;
208} 210}
@@ -368,6 +370,7 @@ int kgdb_arch_handle_exception(int exceptionVector, int signo,
368 char *ptr; 370 char *ptr;
369 int newPC; 371 int newPC;
370 int wp_status; 372 int wp_status;
373 int i;
371 374
372 switch (remcom_in_buffer[0]) { 375 switch (remcom_in_buffer[0]) {
373 case 'c': 376 case 'c':
@@ -392,7 +395,18 @@ int kgdb_arch_handle_exception(int exceptionVector, int signo,
392 /* set the trace bit if we're stepping */ 395 /* set the trace bit if we're stepping */
393 if (remcom_in_buffer[0] == 's') { 396 if (remcom_in_buffer[0] == 's') {
394 linux_regs->syscfg |= 0x1; 397 linux_regs->syscfg |= 0x1;
395 debugger_step = 1; 398 debugger_step = linux_regs->ipend;
399 debugger_step >>= 6;
400 for (i = 10; i > 0; i--, debugger_step >>= 1)
401 if (debugger_step & 1)
402 break;
403 /* i indicate event priority of current stopped instruction
404 * user space instruction is 0, IVG15 is 1, IVTMR is 10.
405 * debugger_step > 0 means in single step mode
406 */
407 debugger_step = i + 1;
408 } else {
409 debugger_step = 0;
396 } 410 }
397 411
398 wp_status = bfin_read_WPSTAT(); 412 wp_status = bfin_read_WPSTAT();
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c
index 14a42848f37f..e1bebc80a5bf 100644
--- a/arch/blackfin/kernel/module.c
+++ b/arch/blackfin/kernel/module.c
@@ -173,7 +173,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
173 for (s = sechdrs; s < sechdrs_end; ++s) { 173 for (s = sechdrs; s < sechdrs_end; ++s) {
174 if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) || 174 if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) ||
175 ((strcmp(".text", secstrings + s->sh_name) == 0) && 175 ((strcmp(".text", secstrings + s->sh_name) == 0) &&
176 (hdr->e_flags & FLG_CODE_IN_L1) && (s->sh_size > 0))) { 176 (hdr->e_flags & EF_BFIN_CODE_IN_L1) && (s->sh_size > 0))) {
177 dest = l1_inst_sram_alloc(s->sh_size); 177 dest = l1_inst_sram_alloc(s->sh_size);
178 mod->arch.text_l1 = dest; 178 mod->arch.text_l1 = dest;
179 if (dest == NULL) { 179 if (dest == NULL) {
@@ -188,7 +188,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
188 } 188 }
189 if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) || 189 if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) ||
190 ((strcmp(".data", secstrings + s->sh_name) == 0) && 190 ((strcmp(".data", secstrings + s->sh_name) == 0) &&
191 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) { 191 (hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) {
192 dest = l1_data_sram_alloc(s->sh_size); 192 dest = l1_data_sram_alloc(s->sh_size);
193 mod->arch.data_a_l1 = dest; 193 mod->arch.data_a_l1 = dest;
194 if (dest == NULL) { 194 if (dest == NULL) {
@@ -203,7 +203,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
203 } 203 }
204 if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 || 204 if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 ||
205 ((strcmp(".bss", secstrings + s->sh_name) == 0) && 205 ((strcmp(".bss", secstrings + s->sh_name) == 0) &&
206 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) { 206 (hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) {
207 dest = l1_data_sram_alloc(s->sh_size); 207 dest = l1_data_sram_alloc(s->sh_size);
208 mod->arch.bss_a_l1 = dest; 208 mod->arch.bss_a_l1 = dest;
209 if (dest == NULL) { 209 if (dest == NULL) {
@@ -242,6 +242,51 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
242 s->sh_flags &= ~SHF_ALLOC; 242 s->sh_flags &= ~SHF_ALLOC;
243 s->sh_addr = (unsigned long)dest; 243 s->sh_addr = (unsigned long)dest;
244 } 244 }
245 if ((strcmp(".l2.text", secstrings + s->sh_name) == 0) ||
246 ((strcmp(".text", secstrings + s->sh_name) == 0) &&
247 (hdr->e_flags & EF_BFIN_CODE_IN_L2) && (s->sh_size > 0))) {
248 dest = l2_sram_alloc(s->sh_size);
249 mod->arch.text_l2 = dest;
250 if (dest == NULL) {
251 printk(KERN_ERR
252 "module %s: L2 SRAM allocation failed\n",
253 mod->name);
254 return -1;
255 }
256 memcpy(dest, (void *)s->sh_addr, s->sh_size);
257 s->sh_flags &= ~SHF_ALLOC;
258 s->sh_addr = (unsigned long)dest;
259 }
260 if ((strcmp(".l2.data", secstrings + s->sh_name) == 0) ||
261 ((strcmp(".data", secstrings + s->sh_name) == 0) &&
262 (hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) {
263 dest = l2_sram_alloc(s->sh_size);
264 mod->arch.data_l2 = dest;
265 if (dest == NULL) {
266 printk(KERN_ERR
267 "module %s: L2 SRAM allocation failed\n",
268 mod->name);
269 return -1;
270 }
271 memcpy(dest, (void *)s->sh_addr, s->sh_size);
272 s->sh_flags &= ~SHF_ALLOC;
273 s->sh_addr = (unsigned long)dest;
274 }
275 if (strcmp(".l2.bss", secstrings + s->sh_name) == 0 ||
276 ((strcmp(".bss", secstrings + s->sh_name) == 0) &&
277 (hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) {
278 dest = l2_sram_alloc(s->sh_size);
279 mod->arch.bss_l2 = dest;
280 if (dest == NULL) {
281 printk(KERN_ERR
282 "module %s: L2 SRAM allocation failed\n",
283 mod->name);
284 return -1;
285 }
286 memset(dest, 0, s->sh_size);
287 s->sh_flags &= ~SHF_ALLOC;
288 s->sh_addr = (unsigned long)dest;
289 }
245 } 290 }
246 return 0; 291 return 0;
247} 292}
@@ -411,9 +456,10 @@ module_finalize(const Elf_Ehdr * hdr,
411 continue; 456 continue;
412 457
413 if ((sechdrs[i].sh_type == SHT_RELA) && 458 if ((sechdrs[i].sh_type == SHT_RELA) &&
414 ((strcmp(".rela.l1.text", secstrings + sechdrs[i].sh_name) == 0) || 459 ((strcmp(".rela.l2.text", secstrings + sechdrs[i].sh_name) == 0) ||
460 (strcmp(".rela.l1.text", secstrings + sechdrs[i].sh_name) == 0) ||
415 ((strcmp(".rela.text", secstrings + sechdrs[i].sh_name) == 0) && 461 ((strcmp(".rela.text", secstrings + sechdrs[i].sh_name) == 0) &&
416 (hdr->e_flags & FLG_CODE_IN_L1)))) { 462 (hdr->e_flags & (EF_BFIN_CODE_IN_L1|EF_BFIN_CODE_IN_L2))))) {
417 apply_relocate_add((Elf_Shdr *) sechdrs, strtab, 463 apply_relocate_add((Elf_Shdr *) sechdrs, strtab,
418 symindex, i, mod); 464 symindex, i, mod);
419 } 465 }
@@ -423,14 +469,12 @@ module_finalize(const Elf_Ehdr * hdr,
423 469
424void module_arch_cleanup(struct module *mod) 470void module_arch_cleanup(struct module *mod)
425{ 471{
426 if (mod->arch.text_l1) 472 l1_inst_sram_free(mod->arch.text_l1);
427 l1_inst_sram_free((void *)mod->arch.text_l1); 473 l1_data_A_sram_free(mod->arch.data_a_l1);
428 if (mod->arch.data_a_l1) 474 l1_data_A_sram_free(mod->arch.bss_a_l1);
429 l1_data_sram_free((void *)mod->arch.data_a_l1); 475 l1_data_B_sram_free(mod->arch.data_b_l1);
430 if (mod->arch.bss_a_l1) 476 l1_data_B_sram_free(mod->arch.bss_b_l1);
431 l1_data_sram_free((void *)mod->arch.bss_a_l1); 477 l2_sram_free(mod->arch.text_l2);
432 if (mod->arch.data_b_l1) 478 l2_sram_free(mod->arch.data_l2);
433 l1_data_B_sram_free((void *)mod->arch.data_b_l1); 479 l2_sram_free(mod->arch.bss_l2);
434 if (mod->arch.bss_b_l1)
435 l1_data_B_sram_free((void *)mod->arch.bss_b_l1);
436} 480}
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index f51ab088098e..bf1a51d8e608 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -220,6 +220,20 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
220 copied = sizeof(tmp); 220 copied = sizeof(tmp);
221 } else 221 } else
222#endif 222#endif
223#if L1_DATA_A_LENGTH != 0
224 if (addr + add >= L1_DATA_A_START
225 && addr + add + sizeof(tmp) <= L1_DATA_A_START + L1_DATA_A_LENGTH) {
226 memcpy(&tmp, (const void *)(addr + add), sizeof(tmp));
227 copied = sizeof(tmp);
228 } else
229#endif
230#if L1_DATA_B_LENGTH != 0
231 if (addr + add >= L1_DATA_B_START
232 && addr + add + sizeof(tmp) <= L1_DATA_B_START + L1_DATA_B_LENGTH) {
233 memcpy(&tmp, (const void *)(addr + add), sizeof(tmp));
234 copied = sizeof(tmp);
235 } else
236#endif
223 if (addr + add >= FIXED_CODE_START 237 if (addr + add >= FIXED_CODE_START
224 && addr + add + sizeof(tmp) <= FIXED_CODE_END) { 238 && addr + add + sizeof(tmp) <= FIXED_CODE_END) {
225 memcpy(&tmp, (const void *)(addr + add), sizeof(tmp)); 239 memcpy(&tmp, (const void *)(addr + add), sizeof(tmp));
@@ -290,6 +304,20 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
290 copied = sizeof(data); 304 copied = sizeof(data);
291 } else 305 } else
292#endif 306#endif
307#if L1_DATA_A_LENGTH != 0
308 if (addr + add >= L1_DATA_A_START
309 && addr + add + sizeof(data) <= L1_DATA_A_START + L1_DATA_A_LENGTH) {
310 memcpy((void *)(addr + add), &data, sizeof(data));
311 copied = sizeof(data);
312 } else
313#endif
314#if L1_DATA_B_LENGTH != 0
315 if (addr + add >= L1_DATA_B_START
316 && addr + add + sizeof(data) <= L1_DATA_B_START + L1_DATA_B_LENGTH) {
317 memcpy((void *)(addr + add), &data, sizeof(data));
318 copied = sizeof(data);
319 } else
320#endif
293 if (addr + add >= FIXED_CODE_START 321 if (addr + add >= FIXED_CODE_START
294 && addr + add + sizeof(data) <= FIXED_CODE_END) { 322 && addr + add + sizeof(data) <= FIXED_CODE_END) {
295 memcpy((void *)(addr + add), &data, sizeof(data)); 323 memcpy((void *)(addr + add), &data, sizeof(data));
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 8efea004aecb..23e637eb78da 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -104,6 +104,7 @@ void __init bf53x_relocate_l1_mem(void)
104 unsigned long l1_code_length; 104 unsigned long l1_code_length;
105 unsigned long l1_data_a_length; 105 unsigned long l1_data_a_length;
106 unsigned long l1_data_b_length; 106 unsigned long l1_data_b_length;
107 unsigned long l2_length;
107 108
108 l1_code_length = _etext_l1 - _stext_l1; 109 l1_code_length = _etext_l1 - _stext_l1;
109 if (l1_code_length > L1_CODE_LENGTH) 110 if (l1_code_length > L1_CODE_LENGTH)
@@ -129,6 +130,15 @@ void __init bf53x_relocate_l1_mem(void)
129 /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */ 130 /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
130 dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + 131 dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
131 l1_data_a_length, l1_data_b_length); 132 l1_data_a_length, l1_data_b_length);
133
134#ifdef L2_LENGTH
135 l2_length = _ebss_l2 - _stext_l2;
136 if (l2_length > L2_LENGTH)
137 panic("L2 SRAM Overflow\n");
138
139 /* Copy _stext_l2 to _edata_l2 to L2 SRAM */
140 dma_memcpy(_stext_l2, _l2_lma_start, l2_length);
141#endif
132} 142}
133 143
134/* add_memory_region to memmap */ 144/* add_memory_region to memmap */
@@ -664,11 +674,8 @@ static __init void setup_bootmem_allocator(void)
664}) 674})
665static inline int __init get_mem_size(void) 675static inline int __init get_mem_size(void)
666{ 676{
667#ifdef CONFIG_MEM_SIZE 677#if defined(EBIU_SDBCTL)
668 return CONFIG_MEM_SIZE; 678# if defined(BF561_FAMILY)
669#else
670# if defined(EBIU_SDBCTL)
671# if defined(BF561_FAMILY)
672 int ret = 0; 679 int ret = 0;
673 u32 sdbctl = bfin_read_EBIU_SDBCTL(); 680 u32 sdbctl = bfin_read_EBIU_SDBCTL();
674 ret += EBSZ_TO_MEG(sdbctl >> 0); 681 ret += EBSZ_TO_MEG(sdbctl >> 0);
@@ -676,10 +683,10 @@ static inline int __init get_mem_size(void)
676 ret += EBSZ_TO_MEG(sdbctl >> 16); 683 ret += EBSZ_TO_MEG(sdbctl >> 16);
677 ret += EBSZ_TO_MEG(sdbctl >> 24); 684 ret += EBSZ_TO_MEG(sdbctl >> 24);
678 return ret; 685 return ret;
679# else 686# else
680 return EBSZ_TO_MEG(bfin_read_EBIU_SDBCTL()); 687 return EBSZ_TO_MEG(bfin_read_EBIU_SDBCTL());
681# endif 688# endif
682# elif defined(EBIU_DDRCTL1) 689#elif defined(EBIU_DDRCTL1)
683 u32 ddrctl = bfin_read_EBIU_DDRCTL1(); 690 u32 ddrctl = bfin_read_EBIU_DDRCTL1();
684 int ret = 0; 691 int ret = 0;
685 switch (ddrctl & 0xc0000) { 692 switch (ddrctl & 0xc0000) {
@@ -693,8 +700,9 @@ static inline int __init get_mem_size(void)
693 case DEVWD_8: ret *= 2; 700 case DEVWD_8: ret *= 2;
694 case DEVWD_16: break; 701 case DEVWD_16: break;
695 } 702 }
703 if ((ddrctl & 0xc000) == 0x4000)
704 ret *= 2;
696 return ret; 705 return ret;
697# endif
698#endif 706#endif
699 BUG(); 707 BUG();
700} 708}
@@ -763,6 +771,9 @@ void __init setup_arch(char **cmdline_p)
763 771
764 _bfin_swrst = bfin_read_SWRST(); 772 _bfin_swrst = bfin_read_SWRST();
765 773
774 /* If we double fault, reset the system - otherwise we hang forever */
775 bfin_write_SWRST(DOUBLE_FAULT);
776
766 if (_bfin_swrst & RESET_DOUBLE) 777 if (_bfin_swrst & RESET_DOUBLE)
767 printk(KERN_INFO "Recovering from Double Fault event\n"); 778 printk(KERN_INFO "Recovering from Double Fault event\n");
768 else if (_bfin_swrst & RESET_WDOG) 779 else if (_bfin_swrst & RESET_WDOG)
@@ -842,38 +853,55 @@ static int __init topology_init(void)
842 853
843subsys_initcall(topology_init); 854subsys_initcall(topology_init);
844 855
856/* Get the voltage input multiplier */
857static u_long cached_vco_pll_ctl, cached_vco;
845static u_long get_vco(void) 858static u_long get_vco(void)
846{ 859{
847 u_long msel; 860 u_long msel;
848 u_long vco;
849 861
850 msel = (bfin_read_PLL_CTL() >> 9) & 0x3F; 862 u_long pll_ctl = bfin_read_PLL_CTL();
863 if (pll_ctl == cached_vco_pll_ctl)
864 return cached_vco;
865 else
866 cached_vco_pll_ctl = pll_ctl;
867
868 msel = (pll_ctl >> 9) & 0x3F;
851 if (0 == msel) 869 if (0 == msel)
852 msel = 64; 870 msel = 64;
853 871
854 vco = CONFIG_CLKIN_HZ; 872 cached_vco = CONFIG_CLKIN_HZ;
855 vco >>= (1 & bfin_read_PLL_CTL()); /* DF bit */ 873 cached_vco >>= (1 & pll_ctl); /* DF bit */
856 vco = msel * vco; 874 cached_vco *= msel;
857 return vco; 875 return cached_vco;
858} 876}
859 877
860/* Get the Core clock */ 878/* Get the Core clock */
879static u_long cached_cclk_pll_div, cached_cclk;
861u_long get_cclk(void) 880u_long get_cclk(void)
862{ 881{
863 u_long csel, ssel; 882 u_long csel, ssel;
883
864 if (bfin_read_PLL_STAT() & 0x1) 884 if (bfin_read_PLL_STAT() & 0x1)
865 return CONFIG_CLKIN_HZ; 885 return CONFIG_CLKIN_HZ;
866 886
867 ssel = bfin_read_PLL_DIV(); 887 ssel = bfin_read_PLL_DIV();
888 if (ssel == cached_cclk_pll_div)
889 return cached_cclk;
890 else
891 cached_cclk_pll_div = ssel;
892
868 csel = ((ssel >> 4) & 0x03); 893 csel = ((ssel >> 4) & 0x03);
869 ssel &= 0xf; 894 ssel &= 0xf;
870 if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */ 895 if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
871 return get_vco() / ssel; 896 cached_cclk = get_vco() / ssel;
872 return get_vco() >> csel; 897 else
898 cached_cclk = get_vco() >> csel;
899 return cached_cclk;
873} 900}
874EXPORT_SYMBOL(get_cclk); 901EXPORT_SYMBOL(get_cclk);
875 902
876/* Get the System clock */ 903/* Get the System clock */
904static u_long cached_sclk_pll_div, cached_sclk;
877u_long get_sclk(void) 905u_long get_sclk(void)
878{ 906{
879 u_long ssel; 907 u_long ssel;
@@ -881,13 +909,20 @@ u_long get_sclk(void)
881 if (bfin_read_PLL_STAT() & 0x1) 909 if (bfin_read_PLL_STAT() & 0x1)
882 return CONFIG_CLKIN_HZ; 910 return CONFIG_CLKIN_HZ;
883 911
884 ssel = (bfin_read_PLL_DIV() & 0xf); 912 ssel = bfin_read_PLL_DIV();
913 if (ssel == cached_sclk_pll_div)
914 return cached_sclk;
915 else
916 cached_sclk_pll_div = ssel;
917
918 ssel &= 0xf;
885 if (0 == ssel) { 919 if (0 == ssel) {
886 printk(KERN_WARNING "Invalid System Clock\n"); 920 printk(KERN_WARNING "Invalid System Clock\n");
887 ssel = 1; 921 ssel = 1;
888 } 922 }
889 923
890 return get_vco() / ssel; 924 cached_sclk = get_vco() / ssel;
925 return cached_sclk;
891} 926}
892EXPORT_SYMBOL(get_sclk); 927EXPORT_SYMBOL(get_sclk);
893 928
@@ -916,7 +951,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
916 uint32_t revid; 951 uint32_t revid;
917 952
918 u_long cclk = 0, sclk = 0; 953 u_long cclk = 0, sclk = 0;
919 u_int dcache_size = 0, dsup_banks = 0; 954 u_int icache_size = BFIN_ICACHESIZE / 1024, dcache_size = 0, dsup_banks = 0;
920 955
921 cpu = CPU; 956 cpu = CPU;
922 mmu = "none"; 957 mmu = "none";
@@ -985,12 +1020,15 @@ static int show_cpuinfo(struct seq_file *m, void *v)
985 } 1020 }
986 1021
987 /* Is it turned on? */ 1022 /* Is it turned on? */
988 if (!((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE))) 1023 if ((bfin_read_DMEM_CONTROL() & (ENDCPLB | DMC_ENABLE)) != (ENDCPLB | DMC_ENABLE))
989 dcache_size = 0; 1024 dcache_size = 0;
990 1025
1026 if ((bfin_read_IMEM_CONTROL() & (IMC | ENICPLB)) == (IMC | ENICPLB))
1027 icache_size = 0;
1028
991 seq_printf(m, "cache size\t: %d KB(L1 icache) " 1029 seq_printf(m, "cache size\t: %d KB(L1 icache) "
992 "%d KB(L1 dcache-%s) %d KB(L2 cache)\n", 1030 "%d KB(L1 dcache-%s) %d KB(L2 cache)\n",
993 BFIN_ICACHESIZE / 1024, dcache_size, 1031 icache_size, dcache_size,
994#if defined CONFIG_BFIN_WB 1032#if defined CONFIG_BFIN_WB
995 "wb" 1033 "wb"
996#elif defined CONFIG_BFIN_WT 1034#elif defined CONFIG_BFIN_WT
@@ -1000,8 +1038,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1000 1038
1001 seq_printf(m, "%s\n", cache); 1039 seq_printf(m, "%s\n", cache);
1002 1040
1003 seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n", 1041 if (icache_size)
1004 BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES); 1042 seq_printf(m, "icache setup\t: %d Sub-banks/%d Ways, %d Lines/Way\n",
1043 BFIN_ISUBBANKS, BFIN_IWAYS, BFIN_ILINES);
1044 else
1045 seq_printf(m, "icache setup\t: off\n");
1046
1005 seq_printf(m, 1047 seq_printf(m,
1006 "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n", 1048 "dcache setup\t: %d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
1007 dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS, 1049 dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS,
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index f061f5181623..ad922ab91543 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -69,8 +69,6 @@ void __init trap_init(void)
69 69
70unsigned long saved_icplb_fault_addr, saved_dcplb_fault_addr; 70unsigned long saved_icplb_fault_addr, saved_dcplb_fault_addr;
71 71
72int kstack_depth_to_print = 48;
73
74static void decode_address(char *buf, unsigned long address) 72static void decode_address(char *buf, unsigned long address)
75{ 73{
76 struct vm_list_struct *vml; 74 struct vm_list_struct *vml;
@@ -163,6 +161,9 @@ static void decode_address(char *buf, unsigned long address)
163 if (!in_atomic) 161 if (!in_atomic)
164 mmput(mm); 162 mmput(mm);
165 163
164 if (!strlen(buf))
165 sprintf(buf, "<0x%p> [ %s ] dynamic memory", (void *)address, name);
166
166 goto done; 167 goto done;
167 } 168 }
168 169
@@ -173,7 +174,7 @@ static void decode_address(char *buf, unsigned long address)
173 } 174 }
174 175
175 /* we were unable to find this address anywhere */ 176 /* we were unable to find this address anywhere */
176 sprintf(buf, "<0x%p> /* unknown address */", (void *)address); 177 sprintf(buf, "<0x%p> /* kernel dynamic memory */", (void *)address);
177 178
178done: 179done:
179 write_unlock_irqrestore(&tasklist_lock, flags); 180 write_unlock_irqrestore(&tasklist_lock, flags);
@@ -494,7 +495,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
494 BUG_ON(sig == 0); 495 BUG_ON(sig == 0);
495 496
496 if (sig != SIGTRAP) { 497 if (sig != SIGTRAP) {
497 unsigned long stack; 498 unsigned long *stack;
498 dump_bfin_process(fp); 499 dump_bfin_process(fp);
499 dump_bfin_mem(fp); 500 dump_bfin_mem(fp);
500 show_regs(fp); 501 show_regs(fp);
@@ -508,14 +509,23 @@ asmlinkage void trap_c(struct pt_regs *fp)
508 else 509 else
509#endif 510#endif
510 dump_bfin_trace_buffer(); 511 dump_bfin_trace_buffer();
511 show_stack(current, &stack); 512
512 if (oops_in_progress) { 513 if (oops_in_progress) {
514 /* Dump the current kernel stack */
515 printk(KERN_NOTICE "\n" KERN_NOTICE "Kernel Stack\n");
516 show_stack(current, NULL);
517
513 print_modules(); 518 print_modules();
514#ifndef CONFIG_ACCESS_CHECK 519#ifndef CONFIG_ACCESS_CHECK
515 printk(KERN_EMERG "Please turn on " 520 printk(KERN_EMERG "Please turn on "
516 "CONFIG_ACCESS_CHECK\n"); 521 "CONFIG_ACCESS_CHECK\n");
517#endif 522#endif
518 panic("Kernel exception"); 523 panic("Kernel exception");
524 } else {
525 /* Dump the user space stack */
526 stack = (unsigned long *)rdusp();
527 printk(KERN_NOTICE "Userspace Stack\n");
528 show_stack(NULL, stack);
519 } 529 }
520 } 530 }
521 531
@@ -532,11 +542,71 @@ asmlinkage void trap_c(struct pt_regs *fp)
532 542
533#define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1) 543#define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
534 544
545/*
546 * Similar to get_user, do some address checking, then dereference
547 * Return true on sucess, false on bad address
548 */
549bool get_instruction(unsigned short *val, unsigned short *address)
550{
551
552 unsigned long addr;
553
554 addr = (unsigned long)address;
555
556 /* Check for odd addresses */
557 if (addr & 0x1)
558 return false;
559
560 /* Check that things do not wrap around */
561 if (addr > (addr + 2))
562 return false;
563
564 /*
565 * Since we are in exception context, we need to do a little address checking
566 * We need to make sure we are only accessing valid memory, and
567 * we don't read something in the async space that can hang forever
568 */
569 if ((addr >= FIXED_CODE_START && (addr + 2) <= physical_mem_end) ||
570#ifdef L2_START
571 (addr >= L2_START && (addr + 2) <= (L2_START + L2_LENGTH)) ||
572#endif
573 (addr >= BOOT_ROM_START && (addr + 2) <= (BOOT_ROM_START + BOOT_ROM_LENGTH)) ||
574#if L1_DATA_A_LENGTH != 0
575 (addr >= L1_DATA_A_START && (addr + 2) <= (L1_DATA_A_START + L1_DATA_A_LENGTH)) ||
576#endif
577#if L1_DATA_B_LENGTH != 0
578 (addr >= L1_DATA_B_START && (addr + 2) <= (L1_DATA_B_START + L1_DATA_B_LENGTH)) ||
579#endif
580 (addr >= L1_SCRATCH_START && (addr + 2) <= (L1_SCRATCH_START + L1_SCRATCH_LENGTH)) ||
581 (!(bfin_read_EBIU_AMBCTL0() & B0RDYEN) &&
582 addr >= ASYNC_BANK0_BASE && (addr + 2) <= (ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE)) ||
583 (!(bfin_read_EBIU_AMBCTL0() & B1RDYEN) &&
584 addr >= ASYNC_BANK1_BASE && (addr + 2) <= (ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE)) ||
585 (!(bfin_read_EBIU_AMBCTL1() & B2RDYEN) &&
586 addr >= ASYNC_BANK2_BASE && (addr + 2) <= (ASYNC_BANK2_BASE + ASYNC_BANK1_SIZE)) ||
587 (!(bfin_read_EBIU_AMBCTL1() & B3RDYEN) &&
588 addr >= ASYNC_BANK3_BASE && (addr + 2) <= (ASYNC_BANK3_BASE + ASYNC_BANK1_SIZE))) {
589 *val = *address;
590 return true;
591 }
592
593#if L1_CODE_LENGTH != 0
594 if (addr >= L1_CODE_START && (addr + 2) <= (L1_CODE_START + L1_CODE_LENGTH)) {
595 dma_memcpy(val, address, 2);
596 return true;
597 }
598#endif
599
600
601 return false;
602}
603
535void dump_bfin_trace_buffer(void) 604void dump_bfin_trace_buffer(void)
536{ 605{
537#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON 606#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
538 int tflags, i = 0; 607 int tflags, i = 0;
539 char buf[150]; 608 char buf[150];
609 unsigned short val = 0, *addr;
540#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND 610#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
541 int j, index; 611 int j, index;
542#endif 612#endif
@@ -549,8 +619,42 @@ void dump_bfin_trace_buffer(void)
549 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { 619 for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
550 decode_address(buf, (unsigned long)bfin_read_TBUF()); 620 decode_address(buf, (unsigned long)bfin_read_TBUF());
551 printk(KERN_NOTICE "%4i Target : %s\n", i, buf); 621 printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
552 decode_address(buf, (unsigned long)bfin_read_TBUF()); 622 addr = (unsigned short *)bfin_read_TBUF();
553 printk(KERN_NOTICE " Source : %s\n", buf); 623 decode_address(buf, (unsigned long)addr);
624 printk(KERN_NOTICE " Source : %s ", buf);
625 if (get_instruction(&val, addr)) {
626 if (val == 0x0010)
627 printk("RTS");
628 else if (val == 0x0011)
629 printk("RTI");
630 else if (val == 0x0012)
631 printk("RTX");
632 else if (val >= 0x0050 && val <= 0x0057)
633 printk("JUMP (P%i)", val & 7);
634 else if (val >= 0x0060 && val <= 0x0067)
635 printk("CALL (P%i)", val & 7);
636 else if (val >= 0x0070 && val <= 0x0077)
637 printk("CALL (PC+P%i)", val & 7);
638 else if (val >= 0x0080 && val <= 0x0087)
639 printk("JUMP (PC+P%i)", val & 7);
640 else if ((val >= 0x1000 && val <= 0x13FF) ||
641 (val >= 0x1800 && val <= 0x1BFF))
642 printk("IF !CC JUMP");
643 else if ((val >= 0x1400 && val <= 0x17ff) ||
644 (val >= 0x1c00 && val <= 0x1fff))
645 printk("IF CC JUMP");
646 else if (val >= 0x2000 && val <= 0x2fff)
647 printk("JUMP.S");
648 else if (val >= 0xe080 && val <= 0xe0ff)
649 printk("LSETUP");
650 else if (val >= 0xe200 && val <= 0xe2ff)
651 printk("JUMP.L");
652 else if (val >= 0xe300 && val <= 0xe3ff)
653 printk("CALL pcrel");
654 else
655 printk("0x%04x", val);
656 }
657 printk("\n");
554 } 658 }
555 } 659 }
556 660
@@ -582,59 +686,151 @@ void dump_bfin_trace_buffer(void)
582} 686}
583EXPORT_SYMBOL(dump_bfin_trace_buffer); 687EXPORT_SYMBOL(dump_bfin_trace_buffer);
584 688
585static void show_trace(struct task_struct *tsk, unsigned long *sp) 689/*
690 * Checks to see if the address pointed to is either a
691 * 16-bit CALL instruction, or a 32-bit CALL instruction
692 */
693bool is_bfin_call(unsigned short *addr)
586{ 694{
587 unsigned long addr; 695 unsigned short opcode = 0, *ins_addr;
696 ins_addr = (unsigned short *)addr;
588 697
589 printk(KERN_NOTICE "\n" KERN_NOTICE "Call Trace:\n"); 698 if (!get_instruction(&opcode, ins_addr))
590 699 return false;
591 while (!kstack_end(sp)) {
592 addr = *sp++;
593 /*
594 * If the address is either in the text segment of the
595 * kernel, or in the region which contains vmalloc'ed
596 * memory, it *may* be the address of a calling
597 * routine; if so, print it so that someone tracing
598 * down the cause of the crash will be able to figure
599 * out the call path that was taken.
600 */
601 if (kernel_text_address(addr))
602 print_ip_sym(addr);
603 }
604 700
605 printk(KERN_NOTICE "\n"); 701 if ((opcode >= 0x0060 && opcode <= 0x0067) ||
606} 702 (opcode >= 0x0070 && opcode <= 0x0077))
703 return true;
704
705 ins_addr--;
706 if (!get_instruction(&opcode, ins_addr))
707 return false;
607 708
709 if (opcode >= 0xE300 && opcode <= 0xE3FF)
710 return true;
711
712 return false;
713
714}
608void show_stack(struct task_struct *task, unsigned long *stack) 715void show_stack(struct task_struct *task, unsigned long *stack)
609{ 716{
610 unsigned long *endstack, addr; 717 unsigned int *addr, *endstack, *fp = 0, *frame;
611 int i; 718 unsigned short *ins_addr;
719 char buf[150];
720 unsigned int i, j, ret_addr, frame_no = 0;
612 721
613 /* Cannot call dump_bfin_trace_buffer() here as show_stack() is 722 /*
614 * called externally in some places in the kernel. 723 * If we have been passed a specific stack, use that one otherwise
724 * if we have been passed a task structure, use that, otherwise
725 * use the stack of where the variable "stack" exists
615 */ 726 */
616 727
617 if (!stack) { 728 if (stack == NULL) {
618 if (task) 729 if (task) {
730 /* We know this is a kernel stack, so this is the start/end */
619 stack = (unsigned long *)task->thread.ksp; 731 stack = (unsigned long *)task->thread.ksp;
620 else 732 endstack = (unsigned int *)(((unsigned int)(stack) & ~(THREAD_SIZE - 1)) + THREAD_SIZE);
733 } else {
734 /* print out the existing stack info */
621 stack = (unsigned long *)&stack; 735 stack = (unsigned long *)&stack;
736 endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack);
737 }
738 } else
739 endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack);
740
741 decode_address(buf, (unsigned int)stack);
742 printk(KERN_NOTICE "Stack info:\n" KERN_NOTICE " SP: [0x%p] %s\n", stack, buf);
743 addr = (unsigned int *)((unsigned int)stack & ~0x3F);
744
745 /* First thing is to look for a frame pointer */
746 for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0;
747 addr < endstack; addr++, i++) {
748 if (*addr & 0x1)
749 continue;
750 ins_addr = (unsigned short *)*addr;
751 ins_addr--;
752 if (is_bfin_call(ins_addr))
753 fp = addr - 1;
754
755 if (fp) {
756 /* Let's check to see if it is a frame pointer */
757 while (fp >= (addr - 1) && fp < endstack && fp)
758 fp = (unsigned int *)*fp;
759 if (fp == 0 || fp == endstack) {
760 fp = addr - 1;
761 break;
762 }
763 fp = 0;
764 }
622 } 765 }
766 if (fp) {
767 frame = fp;
768 printk(" FP: (0x%p)\n", fp);
769 } else
770 frame = 0;
623 771
624 addr = (unsigned long)stack; 772 /*
625 endstack = (unsigned long *)PAGE_ALIGN(addr); 773 * Now that we think we know where things are, we
774 * walk the stack again, this time printing things out
775 * incase there is no frame pointer, we still look for
776 * valid return addresses
777 */
626 778
627 printk(KERN_NOTICE "Stack from %08lx:", (unsigned long)stack); 779 /* First time print out data, next time, print out symbols */
628 for (i = 0; i < kstack_depth_to_print; i++) { 780 for (j = 0; j <= 1; j++) {
629 if (stack + 1 > endstack) 781 if (j)
630 break; 782 printk(KERN_NOTICE "Return addresses in stack:\n");
631 if (i % 8 == 0) 783 else
632 printk("\n" KERN_NOTICE " "); 784 printk(KERN_NOTICE " Memory from 0x%08lx to %p", ((long unsigned int)stack & ~0xF), endstack);
633 printk(" %08lx", *stack++); 785
786 fp = frame;
787 frame_no = 0;
788
789 for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0;
790 addr <= endstack; addr++, i++) {
791
792 ret_addr = 0;
793 if (!j && i % 8 == 0)
794 printk("\n" KERN_NOTICE "%p:",addr);
795
796 /* if it is an odd address, or zero, just skip it */
797 if (*addr & 0x1 || !*addr)
798 goto print;
799
800 ins_addr = (unsigned short *)*addr;
801
802 /* Go back one instruction, and see if it is a CALL */
803 ins_addr--;
804 ret_addr = is_bfin_call(ins_addr);
805 print:
806 if (!j && stack == (unsigned long *)addr)
807 printk("[%08x]", *addr);
808 else if (ret_addr)
809 if (j) {
810 decode_address(buf, (unsigned int)*addr);
811 if (frame == addr) {
812 printk(KERN_NOTICE " frame %2i : %s\n", frame_no, buf);
813 continue;
814 }
815 printk(KERN_NOTICE " address : %s\n", buf);
816 } else
817 printk("<%08x>", *addr);
818 else if (fp == addr) {
819 if (j)
820 frame = addr+1;
821 else
822 printk("(%08x)", *addr);
823
824 fp = (unsigned int *)*addr;
825 frame_no++;
826
827 } else if (!j)
828 printk(" %08x ", *addr);
829 }
830 if (!j)
831 printk("\n");
634 } 832 }
635 printk("\n");
636 833
637 show_trace(task, stack);
638} 834}
639 835
640void dump_stack(void) 836void dump_stack(void)
@@ -715,19 +911,9 @@ void dump_bfin_mem(struct pt_regs *fp)
715 if (!((unsigned long)addr & 0xF)) 911 if (!((unsigned long)addr & 0xF))
716 printk("\n" KERN_NOTICE "0x%p: ", addr); 912 printk("\n" KERN_NOTICE "0x%p: ", addr);
717 913
718 if (get_user(val, addr)) { 914 if (get_instruction(&val, addr)) {
719 if (addr >= (unsigned short *)L1_CODE_START &&
720 addr < (unsigned short *)(L1_CODE_START + L1_CODE_LENGTH)) {
721 dma_memcpy(&val, addr, sizeof(val));
722 sprintf(buf, "%04x", val);
723 } else if (addr >= (unsigned short *)FIXED_CODE_START &&
724 addr <= (unsigned short *)memory_start) {
725 val = bfin_read16(addr);
726 sprintf(buf, "%04x", val);
727 } else {
728 val = 0; 915 val = 0;
729 sprintf(buf, "????"); 916 sprintf(buf, "????");
730 }
731 } else 917 } else
732 sprintf(buf, "%04x", val); 918 sprintf(buf, "%04x", val);
733 919
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index 3ecc64cab3be..0896e38d6108 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -101,6 +101,11 @@ SECTIONS
101#if !L1_DATA_B_LENGTH 101#if !L1_DATA_B_LENGTH
102 *(.l1.data.B) 102 *(.l1.data.B)
103#endif 103#endif
104#ifndef L2_LENGTH
105 . = ALIGN(32);
106 *(.data_l2.cacheline_aligned)
107 *(.l2.data)
108#endif
104 109
105 DATA_DATA 110 DATA_DATA
106 *(.data.*) 111 *(.data.*)
@@ -182,14 +187,13 @@ SECTIONS
182 *(.l1.data) 187 *(.l1.data)
183 __edata_l1 = .; 188 __edata_l1 = .;
184 189
185 . = ALIGN(4);
186 __sbss_l1 = .;
187 *(.l1.bss)
188
189 . = ALIGN(32); 190 . = ALIGN(32);
190 *(.data_l1.cacheline_aligned) 191 *(.data_l1.cacheline_aligned)
191 192
192 . = ALIGN(4); 193 . = ALIGN(4);
194 __sbss_l1 = .;
195 *(.l1.bss)
196 . = ALIGN(4);
193 __ebss_l1 = .; 197 __ebss_l1 = .;
194 } 198 }
195 199
@@ -203,11 +207,37 @@ SECTIONS
203 . = ALIGN(4); 207 . = ALIGN(4);
204 __sbss_b_l1 = .; 208 __sbss_b_l1 = .;
205 *(.l1.bss.B) 209 *(.l1.bss.B)
206
207 . = ALIGN(4); 210 . = ALIGN(4);
208 __ebss_b_l1 = .; 211 __ebss_b_l1 = .;
209 } 212 }
210 213
214#ifdef L2_LENGTH
215 __l2_lma_start = .;
216
217 .text_data_l2 L2_START : AT(LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1))
218 {
219 . = ALIGN(4);
220 __stext_l2 = .;
221 *(.l1.text)
222 . = ALIGN(4);
223 __etext_l2 = .;
224
225 . = ALIGN(4);
226 __sdata_l2 = .;
227 *(.l1.data)
228 __edata_l2 = .;
229
230 . = ALIGN(32);
231 *(.data_l2.cacheline_aligned)
232
233 . = ALIGN(4);
234 __sbss_l2 = .;
235 *(.l1.bss)
236 . = ALIGN(4);
237 __ebss_l2 = .;
238 }
239#endif
240
211 /* Force trailing alignment of our init section so that when we 241 /* Force trailing alignment of our init section so that when we
212 * free our init memory, we don't leave behind a partial page. 242 * free our init memory, we don't leave behind a partial page.
213 */ 243 */
diff --git a/arch/blackfin/mach-bf527/boards/Kconfig b/arch/blackfin/mach-bf527/boards/Kconfig
index 6a570ad03746..8bf9e58f0148 100644
--- a/arch/blackfin/mach-bf527/boards/Kconfig
+++ b/arch/blackfin/mach-bf527/boards/Kconfig
@@ -9,4 +9,9 @@ config BFIN527_EZKIT
9 help 9 help
10 BF527-EZKIT-LITE board support. 10 BF527-EZKIT-LITE board support.
11 11
12config BFIN527_BLUETECHNIX_CM
13 bool "Bluetechnix CM-BF527"
14 help
15 CM-BF527 support for EVAL- and DEV-Board.
16
12endchoice 17endchoice
diff --git a/arch/blackfin/mach-bf527/boards/Makefile b/arch/blackfin/mach-bf527/boards/Makefile
index 7277d35ef111..7ba7d256bbb8 100644
--- a/arch/blackfin/mach-bf527/boards/Makefile
+++ b/arch/blackfin/mach-bf527/boards/Makefile
@@ -3,3 +3,4 @@
3# 3#
4 4
5obj-$(CONFIG_BFIN527_EZKIT) += ezkit.o 5obj-$(CONFIG_BFIN527_EZKIT) += ezkit.o
6obj-$(CONFIG_BFIN527_BLUETECHNIX_CM) += cm_bf527.o
diff --git a/arch/blackfin/mach-bf527/boards/cm_bf527.c b/arch/blackfin/mach-bf527/boards/cm_bf527.c
new file mode 100644
index 000000000000..0b26ae2de5ee
--- /dev/null
+++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c
@@ -0,0 +1,1011 @@
1/*
2 * File: arch/blackfin/mach-bf527/boards/cm-bf527.c
3 * Based on: arch/blackfin/mach-bf537/boards/stamp.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2008 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/mtd/physmap.h>
36#include <linux/spi/spi.h>
37#include <linux/spi/flash.h>
38#include <linux/etherdevice.h>
39#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
40#include <linux/usb/isp1362.h>
41#endif
42#include <linux/pata_platform.h>
43#include <linux/i2c.h>
44#include <linux/irq.h>
45#include <linux/interrupt.h>
46#include <linux/usb/sl811.h>
47#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
48#include <linux/usb/musb.h>
49#endif
50#include <asm/cplb.h>
51#include <asm/dma.h>
52#include <asm/bfin5xx_spi.h>
53#include <asm/reboot.h>
54#include <asm/nand.h>
55#include <asm/portmux.h>
56#include <asm/dpmc.h>
57#include <linux/spi/ad7877.h>
58
59/*
60 * Name the Board for the /proc/cpuinfo
61 */
62const char bfin_board_name[] = "Bluetechnix CM-BF527";
63
64/*
65 * Driver needs to know address, irq and flag pin.
66 */
67
68#define ISP1761_BASE 0x203C0000
69#define ISP1761_IRQ IRQ_PF7
70
71#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
72static struct resource bfin_isp1761_resources[] = {
73 [0] = {
74 .name = "isp1761-regs",
75 .start = ISP1761_BASE + 0x00000000,
76 .end = ISP1761_BASE + 0x000fffff,
77 .flags = IORESOURCE_MEM,
78 },
79 [1] = {
80 .start = ISP1761_IRQ,
81 .end = ISP1761_IRQ,
82 .flags = IORESOURCE_IRQ,
83 },
84};
85
86static struct platform_device bfin_isp1761_device = {
87 .name = "isp1761",
88 .id = 0,
89 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
90 .resource = bfin_isp1761_resources,
91};
92
93static struct platform_device *bfin_isp1761_devices[] = {
94 &bfin_isp1761_device,
95};
96
97int __init bfin_isp1761_init(void)
98{
99 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
100
101 printk(KERN_INFO "%s(): registering device resources\n", __func__);
102 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
103
104 return platform_add_devices(bfin_isp1761_devices, num_devices);
105}
106
107void __exit bfin_isp1761_exit(void)
108{
109 platform_device_unregister(&bfin_isp1761_device);
110}
111
112arch_initcall(bfin_isp1761_init);
113#endif
114
115#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
116static struct resource musb_resources[] = {
117 [0] = {
118 .start = 0xffc03800,
119 .end = 0xffc03cff,
120 .flags = IORESOURCE_MEM,
121 },
122 [1] = { /* general IRQ */
123 .start = IRQ_USB_INT0,
124 .end = IRQ_USB_INT0,
125 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
126 },
127 [2] = { /* DMA IRQ */
128 .start = IRQ_USB_DMA,
129 .end = IRQ_USB_DMA,
130 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
131 },
132};
133
134static struct musb_hdrc_platform_data musb_plat = {
135#if defined(CONFIG_USB_MUSB_OTG)
136 .mode = MUSB_OTG,
137#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
138 .mode = MUSB_HOST,
139#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
140 .mode = MUSB_PERIPHERAL,
141#endif
142 .multipoint = 0,
143};
144
145static u64 musb_dmamask = ~(u32)0;
146
147static struct platform_device musb_device = {
148 .name = "musb_hdrc",
149 .id = 0,
150 .dev = {
151 .dma_mask = &musb_dmamask,
152 .coherent_dma_mask = 0xffffffff,
153 .platform_data = &musb_plat,
154 },
155 .num_resources = ARRAY_SIZE(musb_resources),
156 .resource = musb_resources,
157};
158#endif
159
160#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
161static struct mtd_partition ezkit_partitions[] = {
162 {
163 .name = "Bootloader",
164 .size = 0x40000,
165 .offset = 0,
166 }, {
167 .name = "Kernel",
168 .size = 0x1C0000,
169 .offset = MTDPART_OFS_APPEND,
170 }, {
171 .name = "RootFS",
172 .size = MTDPART_SIZ_FULL,
173 .offset = MTDPART_OFS_APPEND,
174 }
175};
176
177static struct physmap_flash_data ezkit_flash_data = {
178 .width = 2,
179 .parts = ezkit_partitions,
180 .nr_parts = ARRAY_SIZE(ezkit_partitions),
181};
182
183static struct resource ezkit_flash_resource = {
184 .start = 0x20000000,
185 .end = 0x201fffff,
186 .flags = IORESOURCE_MEM,
187};
188
189static struct platform_device ezkit_flash_device = {
190 .name = "physmap-flash",
191 .id = 0,
192 .dev = {
193 .platform_data = &ezkit_flash_data,
194 },
195 .num_resources = 1,
196 .resource = &ezkit_flash_resource,
197};
198#endif
199
200#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
201static struct mtd_partition partition_info[] = {
202 {
203 .name = "Linux Kernel",
204 .offset = 0,
205 .size = 4 * SIZE_1M,
206 },
207 {
208 .name = "File System",
209 .offset = MTDPART_OFS_APPEND,
210 .size = MTDPART_SIZ_FULL,
211 },
212};
213
214static struct bf5xx_nand_platform bf5xx_nand_platform = {
215 .page_size = NFC_PG_SIZE_256,
216 .data_width = NFC_NWIDTH_8,
217 .partitions = partition_info,
218 .nr_partitions = ARRAY_SIZE(partition_info),
219 .rd_dly = 3,
220 .wr_dly = 3,
221};
222
223static struct resource bf5xx_nand_resources[] = {
224 {
225 .start = NFC_CTL,
226 .end = NFC_DATA_RD + 2,
227 .flags = IORESOURCE_MEM,
228 },
229 {
230 .start = CH_NFC,
231 .end = CH_NFC,
232 .flags = IORESOURCE_IRQ,
233 },
234};
235
236static struct platform_device bf5xx_nand_device = {
237 .name = "bf5xx-nand",
238 .id = 0,
239 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
240 .resource = bf5xx_nand_resources,
241 .dev = {
242 .platform_data = &bf5xx_nand_platform,
243 },
244};
245#endif
246
247#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
248static struct resource bfin_pcmcia_cf_resources[] = {
249 {
250 .start = 0x20310000, /* IO PORT */
251 .end = 0x20312000,
252 .flags = IORESOURCE_MEM,
253 }, {
254 .start = 0x20311000, /* Attribute Memory */
255 .end = 0x20311FFF,
256 .flags = IORESOURCE_MEM,
257 }, {
258 .start = IRQ_PF4,
259 .end = IRQ_PF4,
260 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
261 }, {
262 .start = 6, /* Card Detect PF6 */
263 .end = 6,
264 .flags = IORESOURCE_IRQ,
265 },
266};
267
268static struct platform_device bfin_pcmcia_cf_device = {
269 .name = "bfin_cf_pcmcia",
270 .id = -1,
271 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
272 .resource = bfin_pcmcia_cf_resources,
273};
274#endif
275
276#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
277static struct platform_device rtc_device = {
278 .name = "rtc-bfin",
279 .id = -1,
280};
281#endif
282
283#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
284static struct resource smc91x_resources[] = {
285 {
286 .name = "smc91x-regs",
287 .start = 0x20300300,
288 .end = 0x20300300 + 16,
289 .flags = IORESOURCE_MEM,
290 }, {
291
292 .start = IRQ_PF7,
293 .end = IRQ_PF7,
294 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
295 },
296};
297static struct platform_device smc91x_device = {
298 .name = "smc91x",
299 .id = 0,
300 .num_resources = ARRAY_SIZE(smc91x_resources),
301 .resource = smc91x_resources,
302};
303#endif
304
305#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
306static struct resource dm9000_resources[] = {
307 [0] = {
308 .start = 0x203FB800,
309 .end = 0x203FB800 + 8,
310 .flags = IORESOURCE_MEM,
311 },
312 [1] = {
313 .start = IRQ_PF9,
314 .end = IRQ_PF9,
315 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
316 },
317};
318
319static struct platform_device dm9000_device = {
320 .name = "dm9000",
321 .id = -1,
322 .num_resources = ARRAY_SIZE(dm9000_resources),
323 .resource = dm9000_resources,
324};
325#endif
326
327#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
328static struct resource sl811_hcd_resources[] = {
329 {
330 .start = 0x20340000,
331 .end = 0x20340000,
332 .flags = IORESOURCE_MEM,
333 }, {
334 .start = 0x20340004,
335 .end = 0x20340004,
336 .flags = IORESOURCE_MEM,
337 }, {
338 .start = CONFIG_USB_SL811_BFIN_IRQ,
339 .end = CONFIG_USB_SL811_BFIN_IRQ,
340 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
341 },
342};
343
344#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
345void sl811_port_power(struct device *dev, int is_on)
346{
347 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
348 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
349}
350#endif
351
352static struct sl811_platform_data sl811_priv = {
353 .potpg = 10,
354 .power = 250, /* == 500mA */
355#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
356 .port_power = &sl811_port_power,
357#endif
358};
359
360static struct platform_device sl811_hcd_device = {
361 .name = "sl811-hcd",
362 .id = 0,
363 .dev = {
364 .platform_data = &sl811_priv,
365 },
366 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
367 .resource = sl811_hcd_resources,
368};
369#endif
370
371#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
372static struct resource isp1362_hcd_resources[] = {
373 {
374 .start = 0x20360000,
375 .end = 0x20360000,
376 .flags = IORESOURCE_MEM,
377 }, {
378 .start = 0x20360004,
379 .end = 0x20360004,
380 .flags = IORESOURCE_MEM,
381 }, {
382 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
383 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
384 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
385 },
386};
387
388static struct isp1362_platform_data isp1362_priv = {
389 .sel15Kres = 1,
390 .clknotstop = 0,
391 .oc_enable = 0,
392 .int_act_high = 0,
393 .int_edge_triggered = 0,
394 .remote_wakeup_connected = 0,
395 .no_power_switching = 1,
396 .power_switching_mode = 0,
397};
398
399static struct platform_device isp1362_hcd_device = {
400 .name = "isp1362-hcd",
401 .id = 0,
402 .dev = {
403 .platform_data = &isp1362_priv,
404 },
405 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
406 .resource = isp1362_hcd_resources,
407};
408#endif
409
410#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
411static struct platform_device bfin_mac_device = {
412 .name = "bfin_mac",
413};
414#endif
415
416#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
417static struct resource net2272_bfin_resources[] = {
418 {
419 .start = 0x20300000,
420 .end = 0x20300000 + 0x100,
421 .flags = IORESOURCE_MEM,
422 }, {
423 .start = IRQ_PF7,
424 .end = IRQ_PF7,
425 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
426 },
427};
428
429static struct platform_device net2272_bfin_device = {
430 .name = "net2272",
431 .id = -1,
432 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
433 .resource = net2272_bfin_resources,
434};
435#endif
436
437#if defined(CONFIG_MTD_M25P80) \
438 || defined(CONFIG_MTD_M25P80_MODULE)
439static struct mtd_partition bfin_spi_flash_partitions[] = {
440 {
441 .name = "bootloader",
442 .size = 0x00040000,
443 .offset = 0,
444 .mask_flags = MTD_CAP_ROM
445 }, {
446 .name = "linux kernel",
447 .size = MTDPART_SIZ_FULL,
448 .offset = MTDPART_OFS_APPEND,
449 }
450};
451
452static struct flash_platform_data bfin_spi_flash_data = {
453 .name = "m25p80",
454 .parts = bfin_spi_flash_partitions,
455 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
456 .type = "m25p16",
457};
458
459/* SPI flash chip (m25p64) */
460static struct bfin5xx_spi_chip spi_flash_chip_info = {
461 .enable_dma = 0, /* use dma transfer with this chip*/
462 .bits_per_word = 8,
463};
464#endif
465
466#if defined(CONFIG_SPI_ADC_BF533) \
467 || defined(CONFIG_SPI_ADC_BF533_MODULE)
468/* SPI ADC chip */
469static struct bfin5xx_spi_chip spi_adc_chip_info = {
470 .enable_dma = 1, /* use dma transfer with this chip*/
471 .bits_per_word = 16,
472};
473#endif
474
475#if defined(CONFIG_SND_BLACKFIN_AD1836) \
476 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
477static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
478 .enable_dma = 0,
479 .bits_per_word = 16,
480};
481#endif
482
483#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
484static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
485 .enable_dma = 0,
486 .bits_per_word = 16,
487};
488#endif
489
490#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
491static struct bfin5xx_spi_chip spi_mmc_chip_info = {
492 .enable_dma = 1,
493 .bits_per_word = 8,
494};
495#endif
496
497#if defined(CONFIG_PBX)
498static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
499 .ctl_reg = 0x4, /* send zero */
500 .enable_dma = 0,
501 .bits_per_word = 8,
502 .cs_change_per_word = 1,
503};
504#endif
505
506#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
507static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
508 .enable_dma = 0,
509 .bits_per_word = 16,
510};
511
512static const struct ad7877_platform_data bfin_ad7877_ts_info = {
513 .model = 7877,
514 .vref_delay_usecs = 50, /* internal, no capacitor */
515 .x_plate_ohms = 419,
516 .y_plate_ohms = 486,
517 .pressure_max = 1000,
518 .pressure_min = 0,
519 .stopacq_polarity = 1,
520 .first_conversion_delay = 3,
521 .acquisition_time = 1,
522 .averaging = 1,
523 .pen_down_acc_interval = 1,
524};
525#endif
526
527#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
528 && defined(CONFIG_SND_SOC_WM8731_SPI)
529static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
530 .enable_dma = 0,
531 .bits_per_word = 16,
532};
533#endif
534
535#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
536static struct bfin5xx_spi_chip spidev_chip_info = {
537 .enable_dma = 0,
538 .bits_per_word = 8,
539};
540#endif
541
542static struct spi_board_info bfin_spi_board_info[] __initdata = {
543#if defined(CONFIG_MTD_M25P80) \
544 || defined(CONFIG_MTD_M25P80_MODULE)
545 {
546 /* the modalias must be the same as spi device driver name */
547 .modalias = "m25p80", /* Name of spi_driver for this device */
548 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
549 .bus_num = 0, /* Framework bus number */
550 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
551 .platform_data = &bfin_spi_flash_data,
552 .controller_data = &spi_flash_chip_info,
553 .mode = SPI_MODE_3,
554 },
555#endif
556
557#if defined(CONFIG_SPI_ADC_BF533) \
558 || defined(CONFIG_SPI_ADC_BF533_MODULE)
559 {
560 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
561 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
562 .bus_num = 0, /* Framework bus number */
563 .chip_select = 1, /* Framework chip select. */
564 .platform_data = NULL, /* No spi_driver specific config */
565 .controller_data = &spi_adc_chip_info,
566 },
567#endif
568
569#if defined(CONFIG_SND_BLACKFIN_AD1836) \
570 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
571 {
572 .modalias = "ad1836-spi",
573 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
574 .bus_num = 0,
575 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
576 .controller_data = &ad1836_spi_chip_info,
577 },
578#endif
579#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
580 {
581 .modalias = "ad9960-spi",
582 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
583 .bus_num = 0,
584 .chip_select = 1,
585 .controller_data = &ad9960_spi_chip_info,
586 },
587#endif
588#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
589 {
590 .modalias = "spi_mmc_dummy",
591 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
592 .bus_num = 0,
593 .chip_select = 0,
594 .platform_data = NULL,
595 .controller_data = &spi_mmc_chip_info,
596 .mode = SPI_MODE_3,
597 },
598 {
599 .modalias = "spi_mmc",
600 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
601 .bus_num = 0,
602 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
603 .platform_data = NULL,
604 .controller_data = &spi_mmc_chip_info,
605 .mode = SPI_MODE_3,
606 },
607#endif
608#if defined(CONFIG_PBX)
609 {
610 .modalias = "fxs-spi",
611 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
612 .bus_num = 0,
613 .chip_select = 8 - CONFIG_J11_JUMPER,
614 .controller_data = &spi_si3xxx_chip_info,
615 .mode = SPI_MODE_3,
616 },
617 {
618 .modalias = "fxo-spi",
619 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
620 .bus_num = 0,
621 .chip_select = 8 - CONFIG_J19_JUMPER,
622 .controller_data = &spi_si3xxx_chip_info,
623 .mode = SPI_MODE_3,
624 },
625#endif
626#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
627 {
628 .modalias = "ad7877",
629 .platform_data = &bfin_ad7877_ts_info,
630 .irq = IRQ_PF8,
631 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
632 .bus_num = 0,
633 .chip_select = 2,
634 .controller_data = &spi_ad7877_chip_info,
635 },
636#endif
637#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
638 && defined(CONFIG_SND_SOC_WM8731_SPI)
639 {
640 .modalias = "wm8731",
641 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
642 .bus_num = 0,
643 .chip_select = 5,
644 .controller_data = &spi_wm8731_chip_info,
645 .mode = SPI_MODE_0,
646 },
647#endif
648#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
649 {
650 .modalias = "spidev",
651 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
652 .bus_num = 0,
653 .chip_select = 1,
654 .controller_data = &spidev_chip_info,
655 },
656#endif
657};
658
659#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
660/* SPI controller data */
661static struct bfin5xx_spi_master bfin_spi0_info = {
662 .num_chipselect = 8,
663 .enable_dma = 1, /* master has the ability to do dma transfer */
664 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
665};
666
667/* SPI (0) */
668static struct resource bfin_spi0_resource[] = {
669 [0] = {
670 .start = SPI0_REGBASE,
671 .end = SPI0_REGBASE + 0xFF,
672 .flags = IORESOURCE_MEM,
673 },
674 [1] = {
675 .start = CH_SPI,
676 .end = CH_SPI,
677 .flags = IORESOURCE_IRQ,
678 },
679};
680
681static struct platform_device bfin_spi0_device = {
682 .name = "bfin-spi",
683 .id = 0, /* Bus number */
684 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
685 .resource = bfin_spi0_resource,
686 .dev = {
687 .platform_data = &bfin_spi0_info, /* Passed to driver */
688 },
689};
690#endif /* spi master and devices */
691
692#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
693static struct platform_device bfin_fb_adv7393_device = {
694 .name = "bfin-adv7393",
695};
696#endif
697
698#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
699static struct resource bfin_uart_resources[] = {
700#ifdef CONFIG_SERIAL_BFIN_UART0
701 {
702 .start = 0xFFC00400,
703 .end = 0xFFC004FF,
704 .flags = IORESOURCE_MEM,
705 },
706#endif
707#ifdef CONFIG_SERIAL_BFIN_UART1
708 {
709 .start = 0xFFC02000,
710 .end = 0xFFC020FF,
711 .flags = IORESOURCE_MEM,
712 },
713#endif
714};
715
716static struct platform_device bfin_uart_device = {
717 .name = "bfin-uart",
718 .id = 1,
719 .num_resources = ARRAY_SIZE(bfin_uart_resources),
720 .resource = bfin_uart_resources,
721};
722#endif
723
724#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
725static struct resource bfin_sir_resources[] = {
726#ifdef CONFIG_BFIN_SIR0
727 {
728 .start = 0xFFC00400,
729 .end = 0xFFC004FF,
730 .flags = IORESOURCE_MEM,
731 },
732#endif
733#ifdef CONFIG_BFIN_SIR1
734 {
735 .start = 0xFFC02000,
736 .end = 0xFFC020FF,
737 .flags = IORESOURCE_MEM,
738 },
739#endif
740};
741
742static struct platform_device bfin_sir_device = {
743 .name = "bfin_sir",
744 .id = 0,
745 .num_resources = ARRAY_SIZE(bfin_sir_resources),
746 .resource = bfin_sir_resources,
747};
748#endif
749
750#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
751static struct resource bfin_twi0_resource[] = {
752 [0] = {
753 .start = TWI0_REGBASE,
754 .end = TWI0_REGBASE,
755 .flags = IORESOURCE_MEM,
756 },
757 [1] = {
758 .start = IRQ_TWI,
759 .end = IRQ_TWI,
760 .flags = IORESOURCE_IRQ,
761 },
762};
763
764static struct platform_device i2c_bfin_twi_device = {
765 .name = "i2c-bfin-twi",
766 .id = 0,
767 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
768 .resource = bfin_twi0_resource,
769};
770#endif
771
772#ifdef CONFIG_I2C_BOARDINFO
773static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
774#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
775 {
776 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
777 .type = "pcf8574_lcd",
778 },
779#endif
780#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
781 {
782 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
783 .type = "pcf8574_keypad",
784 .irq = IRQ_PF8,
785 },
786#endif
787};
788#endif
789
790#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
791static struct platform_device bfin_sport0_uart_device = {
792 .name = "bfin-sport-uart",
793 .id = 0,
794};
795
796static struct platform_device bfin_sport1_uart_device = {
797 .name = "bfin-sport-uart",
798 .id = 1,
799};
800#endif
801
802#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
803#define PATA_INT 55
804
805static struct pata_platform_info bfin_pata_platform_data = {
806 .ioport_shift = 1,
807 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
808};
809
810static struct resource bfin_pata_resources[] = {
811 {
812 .start = 0x20314020,
813 .end = 0x2031403F,
814 .flags = IORESOURCE_MEM,
815 },
816 {
817 .start = 0x2031401C,
818 .end = 0x2031401F,
819 .flags = IORESOURCE_MEM,
820 },
821 {
822 .start = PATA_INT,
823 .end = PATA_INT,
824 .flags = IORESOURCE_IRQ,
825 },
826};
827
828static struct platform_device bfin_pata_device = {
829 .name = "pata_platform",
830 .id = -1,
831 .num_resources = ARRAY_SIZE(bfin_pata_resources),
832 .resource = bfin_pata_resources,
833 .dev = {
834 .platform_data = &bfin_pata_platform_data,
835 }
836};
837#endif
838
839#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
840#include <linux/input.h>
841#include <linux/gpio_keys.h>
842
843static struct gpio_keys_button bfin_gpio_keys_table[] = {
844 {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
845};
846
847static struct gpio_keys_platform_data bfin_gpio_keys_data = {
848 .buttons = bfin_gpio_keys_table,
849 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
850};
851
852static struct platform_device bfin_device_gpiokeys = {
853 .name = "gpio-keys",
854 .dev = {
855 .platform_data = &bfin_gpio_keys_data,
856 },
857};
858#endif
859
860static struct resource bfin_gpios_resources = {
861 .start = 0,
862 .end = MAX_BLACKFIN_GPIOS - 1,
863 .flags = IORESOURCE_IRQ,
864};
865
866static struct platform_device bfin_gpios_device = {
867 .name = "simple-gpio",
868 .id = -1,
869 .num_resources = 1,
870 .resource = &bfin_gpios_resources,
871};
872
873static const unsigned int cclk_vlev_datasheet[] =
874{
875 VRPAIR(VLEV_100, 400000000),
876 VRPAIR(VLEV_105, 426000000),
877 VRPAIR(VLEV_110, 500000000),
878 VRPAIR(VLEV_115, 533000000),
879 VRPAIR(VLEV_120, 600000000),
880};
881
882static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
883 .tuple_tab = cclk_vlev_datasheet,
884 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
885 .vr_settling_time = 25 /* us */,
886};
887
888static struct platform_device bfin_dpmc = {
889 .name = "bfin dpmc",
890 .dev = {
891 .platform_data = &bfin_dmpc_vreg_data,
892 },
893};
894
895static struct platform_device *stamp_devices[] __initdata = {
896
897 &bfin_dpmc,
898
899#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
900 &bf5xx_nand_device,
901#endif
902
903#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
904 &bfin_pcmcia_cf_device,
905#endif
906
907#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
908 &rtc_device,
909#endif
910
911#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
912 &sl811_hcd_device,
913#endif
914
915#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
916 &isp1362_hcd_device,
917#endif
918
919#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
920 &musb_device,
921#endif
922
923#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
924 &smc91x_device,
925#endif
926
927#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
928 &dm9000_device,
929#endif
930
931#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
932 &bfin_mac_device,
933#endif
934
935#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
936 &net2272_bfin_device,
937#endif
938
939#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
940 &bfin_spi0_device,
941#endif
942
943#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
944 &bfin_fb_adv7393_device,
945#endif
946
947#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
948 &bfin_uart_device,
949#endif
950
951#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
952 &bfin_sir_device,
953#endif
954
955#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
956 &i2c_bfin_twi_device,
957#endif
958
959#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
960 &bfin_sport0_uart_device,
961 &bfin_sport1_uart_device,
962#endif
963
964#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
965 &bfin_pata_device,
966#endif
967
968#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
969 &bfin_device_gpiokeys,
970#endif
971
972#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
973 &ezkit_flash_device,
974#endif
975
976 &bfin_gpios_device,
977};
978
979static int __init stamp_init(void)
980{
981 printk(KERN_INFO "%s(): registering device resources\n", __func__);
982
983#ifdef CONFIG_I2C_BOARDINFO
984 i2c_register_board_info(0, bfin_i2c_board_info,
985 ARRAY_SIZE(bfin_i2c_board_info));
986#endif
987
988 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
989 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
990
991#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
992 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
993#endif
994 return 0;
995}
996
997arch_initcall(stamp_init);
998
999void native_machine_restart(char *cmd)
1000{
1001 /* workaround reboot hang when booting from SPI */
1002 if ((bfin_read_SYSCR() & 0x7) == 0x3)
1003 bfin_gpio_reset_spi0_ssel1();
1004}
1005
1006void bfin_get_ether_addr(char *addr)
1007{
1008 random_ether_addr(addr);
1009 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
1010}
1011EXPORT_SYMBOL(bfin_get_ether_addr);
diff --git a/arch/blackfin/mach-bf527/head.S b/arch/blackfin/mach-bf527/head.S
index 57bdb3ba2fed..fe05cc1ef174 100644
--- a/arch/blackfin/mach-bf527/head.S
+++ b/arch/blackfin/mach-bf527/head.S
@@ -32,7 +32,7 @@
32#include <asm/blackfin.h> 32#include <asm/blackfin.h>
33#include <asm/trace.h> 33#include <asm/trace.h>
34 34
35#if CONFIG_BFIN_KERNEL_CLOCK 35#ifdef CONFIG_BFIN_KERNEL_CLOCK
36#include <asm/mach-common/clocks.h> 36#include <asm/mach-common/clocks.h>
37#include <asm/mach/mem_init.h> 37#include <asm/mach/mem_init.h>
38#endif 38#endif
@@ -185,7 +185,7 @@ ENTRY(__start)
185 185
186 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ 186 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
187 call _bf53x_relocate_l1_mem; 187 call _bf53x_relocate_l1_mem;
188#if CONFIG_BFIN_KERNEL_CLOCK 188#ifdef CONFIG_BFIN_KERNEL_CLOCK
189 call _start_dma_code; 189 call _start_dma_code;
190#endif 190#endif
191 191
@@ -318,7 +318,7 @@ ENDPROC(_real_start)
318__FINIT 318__FINIT
319 319
320.section .l1.text 320.section .l1.text
321#if CONFIG_BFIN_KERNEL_CLOCK 321#ifdef CONFIG_BFIN_KERNEL_CLOCK
322ENTRY(_start_dma_code) 322ENTRY(_start_dma_code)
323 323
324 /* Enable PHY CLK buffer output */ 324 /* Enable PHY CLK buffer output */
@@ -398,12 +398,6 @@ ENTRY(_start_dma_code)
398 w[p0] = r0.l; 398 w[p0] = r0.l;
399 ssync; 399 ssync;
400 400
401 p0.l = LO(EBIU_SDBCTL);
402 p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */
403 r0 = mem_SDBCTL;
404 w[p0] = r0.l;
405 ssync;
406
407 P2.H = hi(EBIU_SDGCTL); 401 P2.H = hi(EBIU_SDGCTL);
408 P2.L = lo(EBIU_SDGCTL); 402 P2.L = lo(EBIU_SDGCTL);
409 R0 = [P2]; 403 R0 = [P2];
diff --git a/arch/blackfin/mach-bf533/head.S b/arch/blackfin/mach-bf533/head.S
index 1295deac00a4..c671e8549b17 100644
--- a/arch/blackfin/mach-bf533/head.S
+++ b/arch/blackfin/mach-bf533/head.S
@@ -31,7 +31,7 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <asm/blackfin.h> 32#include <asm/blackfin.h>
33#include <asm/trace.h> 33#include <asm/trace.h>
34#if CONFIG_BFIN_KERNEL_CLOCK 34#ifdef CONFIG_BFIN_KERNEL_CLOCK
35#include <asm/mach-common/clocks.h> 35#include <asm/mach-common/clocks.h>
36#include <asm/mach/mem_init.h> 36#include <asm/mach/mem_init.h>
37#endif 37#endif
@@ -186,7 +186,7 @@ ENTRY(__start)
186 186
187 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ 187 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
188 call _bf53x_relocate_l1_mem; 188 call _bf53x_relocate_l1_mem;
189#if CONFIG_BFIN_KERNEL_CLOCK 189#ifdef CONFIG_BFIN_KERNEL_CLOCK
190 call _start_dma_code; 190 call _start_dma_code;
191#endif 191#endif
192 192
@@ -319,7 +319,7 @@ ENDPROC(_real_start)
319__FINIT 319__FINIT
320 320
321.section .l1.text 321.section .l1.text
322#if CONFIG_BFIN_KERNEL_CLOCK 322#ifdef CONFIG_BFIN_KERNEL_CLOCK
323ENTRY(_start_dma_code) 323ENTRY(_start_dma_code)
324 p0.h = hi(SIC_IWR); 324 p0.h = hi(SIC_IWR);
325 p0.l = lo(SIC_IWR); 325 p0.l = lo(SIC_IWR);
@@ -390,12 +390,6 @@ ENTRY(_start_dma_code)
390 w[p0] = r0.l; 390 w[p0] = r0.l;
391 ssync; 391 ssync;
392 392
393 p0.l = LO(EBIU_SDBCTL);
394 p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */
395 r0 = mem_SDBCTL;
396 w[p0] = r0.l;
397 ssync;
398
399 P2.H = hi(EBIU_SDGCTL); 393 P2.H = hi(EBIU_SDGCTL);
400 P2.L = lo(EBIU_SDGCTL); 394 P2.L = lo(EBIU_SDGCTL);
401 R0 = [P2]; 395 R0 = [P2];
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 671f9d67f23a..6dbc76fb080b 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -29,9 +29,12 @@
29 */ 29 */
30 30
31#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/kernel.h>
32#include <linux/platform_device.h> 33#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h> 34#include <linux/mtd/mtd.h>
35#include <linux/mtd/nand.h>
34#include <linux/mtd/partitions.h> 36#include <linux/mtd/partitions.h>
37#include <linux/mtd/plat-ram.h>
35#include <linux/mtd/physmap.h> 38#include <linux/mtd/physmap.h>
36#include <linux/spi/spi.h> 39#include <linux/spi/spi.h>
37#include <linux/spi/flash.h> 40#include <linux/spi/flash.h>
@@ -355,6 +358,84 @@ static struct platform_device net2272_bfin_device = {
355}; 358};
356#endif 359#endif
357 360
361#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
362#ifdef CONFIG_MTD_PARTITIONS
363const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
364
365static struct mtd_partition bfin_plat_nand_partitions[] = {
366 {
367 .name = "linux kernel",
368 .size = 0x400000,
369 .offset = 0,
370 }, {
371 .name = "file system",
372 .size = MTDPART_SIZ_FULL,
373 .offset = MTDPART_OFS_APPEND,
374 },
375};
376#endif
377
378#define BFIN_NAND_PLAT_CLE 2
379#define BFIN_NAND_PLAT_ALE 1
380static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
381{
382 struct nand_chip *this = mtd->priv;
383
384 if (cmd == NAND_CMD_NONE)
385 return;
386
387 if (ctrl & NAND_CLE)
388 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
389 else
390 writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
391}
392
393#define BFIN_NAND_PLAT_READY GPIO_PF3
394static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
395{
396 return gpio_get_value(BFIN_NAND_PLAT_READY);
397}
398
399static struct platform_nand_data bfin_plat_nand_data = {
400 .chip = {
401 .chip_delay = 30,
402#ifdef CONFIG_MTD_PARTITIONS
403 .part_probe_types = part_probes,
404 .partitions = bfin_plat_nand_partitions,
405 .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
406#endif
407 },
408 .ctrl = {
409 .cmd_ctrl = bfin_plat_nand_cmd_ctrl,
410 .dev_ready = bfin_plat_nand_dev_ready,
411 },
412};
413
414#define MAX(x, y) (x > y ? x : y)
415static struct resource bfin_plat_nand_resources = {
416 .start = 0x20212000,
417 .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
418 .flags = IORESOURCE_IO,
419};
420
421static struct platform_device bfin_async_nand_device = {
422 .name = "gen_nand",
423 .id = -1,
424 .num_resources = 1,
425 .resource = &bfin_plat_nand_resources,
426 .dev = {
427 .platform_data = &bfin_plat_nand_data,
428 },
429};
430
431static void bfin_plat_nand_init(void)
432{
433 gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
434}
435#else
436static void bfin_plat_nand_init(void) {}
437#endif
438
358#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 439#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
359static struct mtd_partition stamp_partitions[] = { 440static struct mtd_partition stamp_partitions[] = {
360 { 441 {
@@ -780,7 +861,7 @@ static struct platform_device bfin_sport1_uart_device = {
780#endif 861#endif
781 862
782#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 863#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
783#define PATA_INT 55 864#define PATA_INT IRQ_PF5
784 865
785static struct pata_platform_info bfin_pata_platform_data = { 866static struct pata_platform_info bfin_pata_platform_data = {
786 .ioport_shift = 1, 867 .ioport_shift = 1,
@@ -922,6 +1003,10 @@ static struct platform_device *stamp_devices[] __initdata = {
922 1003
923 &bfin_gpios_device, 1004 &bfin_gpios_device,
924 1005
1006#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
1007 &bfin_async_nand_device,
1008#endif
1009
925#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1010#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
926 &stamp_flash_device, 1011 &stamp_flash_device,
927#endif 1012#endif
@@ -936,6 +1021,7 @@ static int __init stamp_init(void)
936 ARRAY_SIZE(bfin_i2c_board_info)); 1021 ARRAY_SIZE(bfin_i2c_board_info));
937#endif 1022#endif
938 1023
1024 bfin_plat_nand_init();
939 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 1025 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
940 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 1026 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
941 1027
diff --git a/arch/blackfin/mach-bf537/head.S b/arch/blackfin/mach-bf537/head.S
index 48cd58a410a0..6b019eaee0b6 100644
--- a/arch/blackfin/mach-bf537/head.S
+++ b/arch/blackfin/mach-bf537/head.S
@@ -32,7 +32,7 @@
32#include <asm/blackfin.h> 32#include <asm/blackfin.h>
33#include <asm/trace.h> 33#include <asm/trace.h>
34 34
35#if CONFIG_BFIN_KERNEL_CLOCK 35#ifdef CONFIG_BFIN_KERNEL_CLOCK
36#include <asm/mach-common/clocks.h> 36#include <asm/mach-common/clocks.h>
37#include <asm/mach/mem_init.h> 37#include <asm/mach/mem_init.h>
38#endif 38#endif
@@ -217,7 +217,7 @@ ENTRY(__start)
217 217
218 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ 218 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
219 call _bf53x_relocate_l1_mem; 219 call _bf53x_relocate_l1_mem;
220#if CONFIG_BFIN_KERNEL_CLOCK 220#ifdef CONFIG_BFIN_KERNEL_CLOCK
221 call _start_dma_code; 221 call _start_dma_code;
222#endif 222#endif
223 223
@@ -350,7 +350,7 @@ ENDPROC(_real_start)
350__FINIT 350__FINIT
351 351
352.section .l1.text 352.section .l1.text
353#if CONFIG_BFIN_KERNEL_CLOCK 353#ifdef CONFIG_BFIN_KERNEL_CLOCK
354ENTRY(_start_dma_code) 354ENTRY(_start_dma_code)
355 355
356 /* Enable PHY CLK buffer output */ 356 /* Enable PHY CLK buffer output */
@@ -430,12 +430,6 @@ ENTRY(_start_dma_code)
430 w[p0] = r0.l; 430 w[p0] = r0.l;
431 ssync; 431 ssync;
432 432
433 p0.l = LO(EBIU_SDBCTL);
434 p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */
435 r0 = mem_SDBCTL;
436 w[p0] = r0.l;
437 ssync;
438
439 P2.H = hi(EBIU_SDGCTL); 433 P2.H = hi(EBIU_SDGCTL);
440 P2.L = lo(EBIU_SDGCTL); 434 P2.L = lo(EBIU_SDGCTL);
441 R0 = [P2]; 435 R0 = [P2];
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index af7c211a580e..166fa2201ee7 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -61,6 +61,49 @@ const char bfin_board_name[] = "ADSP-BF548-EZKIT";
61 * Driver needs to know address, irq and flag pin. 61 * Driver needs to know address, irq and flag pin.
62 */ 62 */
63 63
64#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
65static struct resource bfin_isp1761_resources[] = {
66 [0] = {
67 .name = "isp1761-regs",
68 .start = 0x2C0C0000,
69 .end = 0x2C0C0000 + 0xfffff,
70 .flags = IORESOURCE_MEM,
71 },
72 [1] = {
73 .start = IRQ_PG7,
74 .end = IRQ_PG7,
75 .flags = IORESOURCE_IRQ,
76 },
77};
78
79static struct platform_device bfin_isp1761_device = {
80 .name = "isp1761",
81 .id = 0,
82 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
83 .resource = bfin_isp1761_resources,
84};
85
86static struct platform_device *bfin_isp1761_devices[] = {
87 &bfin_isp1761_device,
88};
89
90int __init bfin_isp1761_init(void)
91{
92 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
93
94 printk(KERN_INFO "%s(): registering device resources\n", __func__);
95 set_irq_type(bfin_isp1761_resources[1].start, IRQF_TRIGGER_FALLING);
96
97 return platform_add_devices(bfin_isp1761_devices, num_devices);
98}
99
100void __exit bfin_isp1761_exit(void)
101{
102 platform_device_unregister(&bfin_isp1761_device);
103}
104arch_initcall(bfin_isp1761_init);
105#endif
106
64#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE) 107#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
65 108
66#include <asm/mach/bf54x-lq043.h> 109#include <asm/mach/bf54x-lq043.h>
@@ -177,6 +220,7 @@ static struct resource bfin_uart_resources[] = {
177 { 220 {
178 .start = 0xFFC03100, 221 .start = 0xFFC03100,
179 .end = 0xFFC031FF, 222 .end = 0xFFC031FF,
223 .flags = IORESOURCE_MEM,
180 }, 224 },
181#endif 225#endif
182}; 226};
diff --git a/arch/blackfin/mach-bf548/head.S b/arch/blackfin/mach-bf548/head.S
index f7191141a3ce..06b9178cfcfe 100644
--- a/arch/blackfin/mach-bf548/head.S
+++ b/arch/blackfin/mach-bf548/head.S
@@ -31,7 +31,7 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <asm/blackfin.h> 32#include <asm/blackfin.h>
33#include <asm/trace.h> 33#include <asm/trace.h>
34#if CONFIG_BFIN_KERNEL_CLOCK 34#ifdef CONFIG_BFIN_KERNEL_CLOCK
35#include <asm/mach-common/clocks.h> 35#include <asm/mach-common/clocks.h>
36#include <asm/mach/mem_init.h> 36#include <asm/mach/mem_init.h>
37#endif 37#endif
@@ -130,7 +130,7 @@ ENTRY(__start)
130 130
131 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ 131 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
132 call _bf53x_relocate_l1_mem; 132 call _bf53x_relocate_l1_mem;
133#if CONFIG_BFIN_KERNEL_CLOCK 133#ifdef CONFIG_BFIN_KERNEL_CLOCK
134 call _start_dma_code; 134 call _start_dma_code;
135#endif 135#endif
136 /* Code for initializing Async memory banks */ 136 /* Code for initializing Async memory banks */
@@ -288,7 +288,7 @@ ENDPROC(_real_start)
288__FINIT 288__FINIT
289 289
290.section .l1.text 290.section .l1.text
291#if CONFIG_BFIN_KERNEL_CLOCK 291#ifdef CONFIG_BFIN_KERNEL_CLOCK
292ENTRY(_start_dma_code) 292ENTRY(_start_dma_code)
293 293
294 /* Enable PHY CLK buffer output */ 294 /* Enable PHY CLK buffer output */
diff --git a/arch/blackfin/mach-bf561/head.S b/arch/blackfin/mach-bf561/head.S
index 5b8bd40851dd..cf1a2dff01e7 100644
--- a/arch/blackfin/mach-bf561/head.S
+++ b/arch/blackfin/mach-bf561/head.S
@@ -377,12 +377,6 @@ ENTRY(_start_dma_code)
377 w[p0] = r0.l; 377 w[p0] = r0.l;
378 ssync; 378 ssync;
379 379
380 p0.l = LO(EBIU_SDBCTL);
381 p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */
382 r0 = mem_SDBCTL;
383 w[p0] = r0.l;
384 ssync;
385
386 P2.H = hi(EBIU_SDGCTL); 380 P2.H = hi(EBIU_SDGCTL);
387 P2.L = lo(EBIU_SDGCTL); 381 P2.L = lo(EBIU_SDGCTL);
388 R0 = [P2]; 382 R0 = [P2];
diff --git a/arch/blackfin/mach-common/arch_checks.c b/arch/blackfin/mach-common/arch_checks.c
index caaab49e9cfa..f9160d83b91f 100644
--- a/arch/blackfin/mach-common/arch_checks.c
+++ b/arch/blackfin/mach-common/arch_checks.c
@@ -53,9 +53,3 @@
53# endif 53# endif
54 54
55#endif /* CONFIG_BFIN_KERNEL_CLOCK */ 55#endif /* CONFIG_BFIN_KERNEL_CLOCK */
56
57#ifdef CONFIG_MEM_SIZE
58#if (CONFIG_MEM_SIZE % 4)
59#error "SDRAM mem size must be multible of 4MB"
60#endif
61#endif
diff --git a/arch/blackfin/mach-common/dpmc_modes.S b/arch/blackfin/mach-common/dpmc_modes.S
index b7981d31c392..5e3f1d8a4fb8 100644
--- a/arch/blackfin/mach-common/dpmc_modes.S
+++ b/arch/blackfin/mach-common/dpmc_modes.S
@@ -7,7 +7,7 @@
7#include <linux/linkage.h> 7#include <linux/linkage.h>
8#include <asm/blackfin.h> 8#include <asm/blackfin.h>
9#include <asm/mach/irq.h> 9#include <asm/mach/irq.h>
10 10#include <asm/dpmc.h>
11 11
12.section .l1.text 12.section .l1.text
13 13
@@ -51,31 +51,32 @@ ENTRY(_sleep_mode)
51 RETS = [SP++]; 51 RETS = [SP++];
52 ( R7:0, P5:0 ) = [SP++]; 52 ( R7:0, P5:0 ) = [SP++];
53 RTS; 53 RTS;
54ENDPROC(_sleep_mode)
54 55
55ENTRY(_hibernate_mode) 56ENTRY(_hibernate_mode)
56 [--SP] = ( R7:0, P5:0 ); 57 [--SP] = ( R7:0, P5:0 );
57 [--SP] = RETS; 58 [--SP] = RETS;
58 59
60 R3 = R0;
61 R0 = IWR_DISABLE_ALL;
62 R1 = IWR_DISABLE_ALL;
63 R2 = IWR_DISABLE_ALL;
59 call _set_sic_iwr; 64 call _set_sic_iwr;
65 call _set_dram_srfs;
66 SSYNC;
60 67
61 R0 = 0xFFFF (Z); 68 R0 = 0xFFFF (Z);
62 call _set_rtc_istat; 69 call _set_rtc_istat;
63 70
64 P0.H = hi(VR_CTL); 71 P0.H = hi(VR_CTL);
65 P0.L = lo(VR_CTL); 72 P0.L = lo(VR_CTL);
66 R1 = W[P0](z);
67 BITSET (R1, 8);
68 BITCLR (R1, 0);
69 BITCLR (R1, 1);
70 W[P0] = R1.L;
71 SSYNC;
72 73
74 W[P0] = R3.L;
73 CLI R2; 75 CLI R2;
74 IDLE; 76 IDLE;
75 77.Lforever:
76 /* Actually, adding anything may not be necessary...SDRAM contents 78 jump .Lforever;
77 * are lost 79ENDPROC(_hibernate_mode)
78 */
79 80
80ENTRY(_deep_sleep) 81ENTRY(_deep_sleep)
81 [--SP] = ( R7:0, P5:0 ); 82 [--SP] = ( R7:0, P5:0 );
@@ -131,6 +132,7 @@ ENTRY(_deep_sleep)
131 RETS = [SP++]; 132 RETS = [SP++];
132 ( R7:0, P5:0 ) = [SP++]; 133 ( R7:0, P5:0 ) = [SP++];
133 RTS; 134 RTS;
135ENDPROC(_deep_sleep)
134 136
135ENTRY(_sleep_deeper) 137ENTRY(_sleep_deeper)
136 [--SP] = ( R7:0, P5:0 ); 138 [--SP] = ( R7:0, P5:0 );
@@ -232,53 +234,73 @@ ENTRY(_sleep_deeper)
232 RETS = [SP++]; 234 RETS = [SP++];
233 ( R7:0, P5:0 ) = [SP++]; 235 ( R7:0, P5:0 ) = [SP++];
234 RTS; 236 RTS;
237ENDPROC(_sleep_deeper)
235 238
236ENTRY(_set_dram_srfs) 239ENTRY(_set_dram_srfs)
237 /* set the dram to self refresh mode */ 240 /* set the dram to self refresh mode */
238#if defined(CONFIG_BF54x) 241 SSYNC;
242#if defined(EBIU_RSTCTL) /* DDR */
239 P0.H = hi(EBIU_RSTCTL); 243 P0.H = hi(EBIU_RSTCTL);
240 P0.L = lo(EBIU_RSTCTL); 244 P0.L = lo(EBIU_RSTCTL);
241 R2 = [P0]; 245 R2 = [P0];
242 R3.H = hi(SRREQ); 246 BITSET(R2, 3); /* SRREQ enter self-refresh mode */
243 R3.L = lo(SRREQ); 247 [P0] = R2;
244#else 248 SSYNC;
245 P0.H = hi(EBIU_SDGCTL); 2491:
250 R2 = [P0];
251 CC = BITTST(R2, 4);
252 if !CC JUMP 1b;
253#else /* SDRAM */
246 P0.L = lo(EBIU_SDGCTL); 254 P0.L = lo(EBIU_SDGCTL);
255 P0.H = hi(EBIU_SDGCTL);
247 R2 = [P0]; 256 R2 = [P0];
248 R3.H = hi(SRFS); 257 BITSET(R2, 24); /* SRFS enter self-refresh mode */
249 R3.L = lo(SRFS);
250#endif
251 R2 = R2|R3;
252 [P0] = R2; 258 [P0] = R2;
253 ssync; 259 SSYNC;
254#if defined(CONFIG_BF54x) 260
255.LSRR_MODE: 261 P0.L = lo(EBIU_SDSTAT);
262 P0.H = hi(EBIU_SDSTAT);
2631:
264 R2 = w[P0];
265 SSYNC;
266 cc = BITTST(R2, 1); /* SDSRA poll self-refresh status */
267 if !cc jump 1b;
268
269 P0.L = lo(EBIU_SDGCTL);
270 P0.H = hi(EBIU_SDGCTL);
256 R2 = [P0]; 271 R2 = [P0];
257 CC = BITTST(R2, 4); 272 BITCLR(R2, 0); /* SCTLE disable CLKOUT */
258 if !CC JUMP .LSRR_MODE; 273 [P0] = R2;
259#endif 274#endif
260 RTS; 275 RTS;
276ENDPROC(_set_dram_srfs)
261 277
262ENTRY(_unset_dram_srfs) 278ENTRY(_unset_dram_srfs)
263 /* set the dram out of self refresh mode */ 279 /* set the dram out of self refresh mode */
264#if defined(CONFIG_BF54x) 280#if defined(EBIU_RSTCTL) /* DDR */
265 P0.H = hi(EBIU_RSTCTL); 281 P0.H = hi(EBIU_RSTCTL);
266 P0.L = lo(EBIU_RSTCTL); 282 P0.L = lo(EBIU_RSTCTL);
267 R2 = [P0]; 283 R2 = [P0];
268 R3.H = hi(SRREQ); 284 BITCLR(R2, 3); /* clear SRREQ bit */
269 R3.L = lo(SRREQ); 285 [P0] = R2;
270#else 286#elif defined(EBIU_SDGCTL) /* SDRAM */
287
288 P0.L = lo(EBIU_SDGCTL); /* release CLKOUT from self-refresh */
289 P0.H = hi(EBIU_SDGCTL);
290 R2 = [P0];
291 BITSET(R2, 0); /* SCTLE enable CLKOUT */
292 [P0] = R2
293 SSYNC;
294
295 P0.L = lo(EBIU_SDGCTL); /* release SDRAM from self-refresh */
271 P0.H = hi(EBIU_SDGCTL); 296 P0.H = hi(EBIU_SDGCTL);
272 P0.L = lo(EBIU_SDGCTL);
273 R2 = [P0]; 297 R2 = [P0];
274 R3.H = hi(SRFS); 298 BITCLR(R2, 24); /* clear SRFS bit */
275 R3.L = lo(SRFS); 299 [P0] = R2
276#endif 300#endif
277 R3 = ~R3; 301 SSYNC;
278 R2 = R2&R3;
279 [P0] = R2;
280 ssync;
281 RTS; 302 RTS;
303ENDPROC(_unset_dram_srfs)
282 304
283ENTRY(_set_sic_iwr) 305ENTRY(_set_sic_iwr)
284#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) 306#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
@@ -300,6 +322,7 @@ ENTRY(_set_sic_iwr)
300 322
301 SSYNC; 323 SSYNC;
302 RTS; 324 RTS;
325ENDPROC(_set_sic_iwr)
303 326
304ENTRY(_set_rtc_istat) 327ENTRY(_set_rtc_istat)
305#ifndef CONFIG_BF561 328#ifndef CONFIG_BF561
@@ -307,8 +330,14 @@ ENTRY(_set_rtc_istat)
307 P0.L = lo(RTC_ISTAT); 330 P0.L = lo(RTC_ISTAT);
308 w[P0] = R0.L; 331 w[P0] = R0.L;
309 SSYNC; 332 SSYNC;
333#elif (ANOMALY_05000371)
334 nop;
335 nop;
336 nop;
337 nop;
310#endif 338#endif
311 RTS; 339 RTS;
340ENDPROC(_set_rtc_istat)
312 341
313ENTRY(_test_pll_locked) 342ENTRY(_test_pll_locked)
314 P0.H = hi(PLL_STAT); 343 P0.H = hi(PLL_STAT);
@@ -318,3 +347,509 @@ ENTRY(_test_pll_locked)
318 CC = BITTST(R0,5); 347 CC = BITTST(R0,5);
319 IF !CC JUMP 1b; 348 IF !CC JUMP 1b;
320 RTS; 349 RTS;
350ENDPROC(_test_pll_locked)
351
352.section .text
353
354ENTRY(_do_hibernate)
355 [--SP] = ( R7:0, P5:0 );
356 [--SP] = RETS;
357 /* Save System MMRs */
358 R2 = R0;
359 P0.H = hi(PLL_CTL);
360 P0.L = lo(PLL_CTL);
361
362#ifdef SIC_IMASK0
363 PM_SYS_PUSH(SIC_IMASK0)
364#endif
365#ifdef SIC_IMASK1
366 PM_SYS_PUSH(SIC_IMASK1)
367#endif
368#ifdef SIC_IMASK2
369 PM_SYS_PUSH(SIC_IMASK2)
370#endif
371#ifdef SIC_IMASK
372 PM_SYS_PUSH(SIC_IMASK)
373#endif
374#ifdef SICA_IMASK0
375 PM_SYS_PUSH(SICA_IMASK0)
376#endif
377#ifdef SICA_IMASK1
378 PM_SYS_PUSH(SICA_IMASK1)
379#endif
380#ifdef SIC_IAR2
381 PM_SYS_PUSH(SIC_IAR0)
382 PM_SYS_PUSH(SIC_IAR1)
383 PM_SYS_PUSH(SIC_IAR2)
384#endif
385#ifdef SIC_IAR3
386 PM_SYS_PUSH(SIC_IAR3)
387#endif
388#ifdef SIC_IAR4
389 PM_SYS_PUSH(SIC_IAR4)
390 PM_SYS_PUSH(SIC_IAR5)
391 PM_SYS_PUSH(SIC_IAR6)
392#endif
393#ifdef SIC_IAR7
394 PM_SYS_PUSH(SIC_IAR7)
395#endif
396#ifdef SIC_IAR8
397 PM_SYS_PUSH(SIC_IAR8)
398 PM_SYS_PUSH(SIC_IAR9)
399 PM_SYS_PUSH(SIC_IAR10)
400 PM_SYS_PUSH(SIC_IAR11)
401#endif
402
403#ifdef SICA_IAR0
404 PM_SYS_PUSH(SICA_IAR0)
405 PM_SYS_PUSH(SICA_IAR1)
406 PM_SYS_PUSH(SICA_IAR2)
407 PM_SYS_PUSH(SICA_IAR3)
408 PM_SYS_PUSH(SICA_IAR4)
409 PM_SYS_PUSH(SICA_IAR5)
410 PM_SYS_PUSH(SICA_IAR6)
411 PM_SYS_PUSH(SICA_IAR7)
412#endif
413
414#ifdef SIC_IWR
415 PM_SYS_PUSH(SIC_IWR)
416#endif
417#ifdef SIC_IWR0
418 PM_SYS_PUSH(SIC_IWR0)
419#endif
420#ifdef SIC_IWR1
421 PM_SYS_PUSH(SIC_IWR1)
422#endif
423#ifdef SIC_IWR2
424 PM_SYS_PUSH(SIC_IWR2)
425#endif
426#ifdef SICA_IWR0
427 PM_SYS_PUSH(SICA_IWR0)
428#endif
429#ifdef SICA_IWR1
430 PM_SYS_PUSH(SICA_IWR1)
431#endif
432
433#ifdef PINT0_ASSIGN
434 PM_SYS_PUSH(PINT0_ASSIGN)
435 PM_SYS_PUSH(PINT1_ASSIGN)
436 PM_SYS_PUSH(PINT2_ASSIGN)
437 PM_SYS_PUSH(PINT3_ASSIGN)
438#endif
439
440 PM_SYS_PUSH(EBIU_AMBCTL0)
441 PM_SYS_PUSH(EBIU_AMBCTL1)
442 PM_SYS_PUSH16(EBIU_AMGCTL)
443
444#ifdef EBIU_FCTL
445 PM_SYS_PUSH(EBIU_MBSCTL)
446 PM_SYS_PUSH(EBIU_MODE)
447 PM_SYS_PUSH(EBIU_FCTL)
448#endif
449
450 PM_SYS_PUSH16(SYSCR)
451
452 /* Save Core MMRs */
453 P0.H = hi(SRAM_BASE_ADDRESS);
454 P0.L = lo(SRAM_BASE_ADDRESS);
455
456 PM_PUSH(DMEM_CONTROL)
457 PM_PUSH(DCPLB_ADDR0)
458 PM_PUSH(DCPLB_ADDR1)
459 PM_PUSH(DCPLB_ADDR2)
460 PM_PUSH(DCPLB_ADDR3)
461 PM_PUSH(DCPLB_ADDR4)
462 PM_PUSH(DCPLB_ADDR5)
463 PM_PUSH(DCPLB_ADDR6)
464 PM_PUSH(DCPLB_ADDR7)
465 PM_PUSH(DCPLB_ADDR8)
466 PM_PUSH(DCPLB_ADDR9)
467 PM_PUSH(DCPLB_ADDR10)
468 PM_PUSH(DCPLB_ADDR11)
469 PM_PUSH(DCPLB_ADDR12)
470 PM_PUSH(DCPLB_ADDR13)
471 PM_PUSH(DCPLB_ADDR14)
472 PM_PUSH(DCPLB_ADDR15)
473 PM_PUSH(DCPLB_DATA0)
474 PM_PUSH(DCPLB_DATA1)
475 PM_PUSH(DCPLB_DATA2)
476 PM_PUSH(DCPLB_DATA3)
477 PM_PUSH(DCPLB_DATA4)
478 PM_PUSH(DCPLB_DATA5)
479 PM_PUSH(DCPLB_DATA6)
480 PM_PUSH(DCPLB_DATA7)
481 PM_PUSH(DCPLB_DATA8)
482 PM_PUSH(DCPLB_DATA9)
483 PM_PUSH(DCPLB_DATA10)
484 PM_PUSH(DCPLB_DATA11)
485 PM_PUSH(DCPLB_DATA12)
486 PM_PUSH(DCPLB_DATA13)
487 PM_PUSH(DCPLB_DATA14)
488 PM_PUSH(DCPLB_DATA15)
489 PM_PUSH(IMEM_CONTROL)
490 PM_PUSH(ICPLB_ADDR0)
491 PM_PUSH(ICPLB_ADDR1)
492 PM_PUSH(ICPLB_ADDR2)
493 PM_PUSH(ICPLB_ADDR3)
494 PM_PUSH(ICPLB_ADDR4)
495 PM_PUSH(ICPLB_ADDR5)
496 PM_PUSH(ICPLB_ADDR6)
497 PM_PUSH(ICPLB_ADDR7)
498 PM_PUSH(ICPLB_ADDR8)
499 PM_PUSH(ICPLB_ADDR9)
500 PM_PUSH(ICPLB_ADDR10)
501 PM_PUSH(ICPLB_ADDR11)
502 PM_PUSH(ICPLB_ADDR12)
503 PM_PUSH(ICPLB_ADDR13)
504 PM_PUSH(ICPLB_ADDR14)
505 PM_PUSH(ICPLB_ADDR15)
506 PM_PUSH(ICPLB_DATA0)
507 PM_PUSH(ICPLB_DATA1)
508 PM_PUSH(ICPLB_DATA2)
509 PM_PUSH(ICPLB_DATA3)
510 PM_PUSH(ICPLB_DATA4)
511 PM_PUSH(ICPLB_DATA5)
512 PM_PUSH(ICPLB_DATA6)
513 PM_PUSH(ICPLB_DATA7)
514 PM_PUSH(ICPLB_DATA8)
515 PM_PUSH(ICPLB_DATA9)
516 PM_PUSH(ICPLB_DATA10)
517 PM_PUSH(ICPLB_DATA11)
518 PM_PUSH(ICPLB_DATA12)
519 PM_PUSH(ICPLB_DATA13)
520 PM_PUSH(ICPLB_DATA14)
521 PM_PUSH(ICPLB_DATA15)
522 PM_PUSH(EVT0)
523 PM_PUSH(EVT1)
524 PM_PUSH(EVT2)
525 PM_PUSH(EVT3)
526 PM_PUSH(EVT4)
527 PM_PUSH(EVT5)
528 PM_PUSH(EVT6)
529 PM_PUSH(EVT7)
530 PM_PUSH(EVT8)
531 PM_PUSH(EVT9)
532 PM_PUSH(EVT10)
533 PM_PUSH(EVT11)
534 PM_PUSH(EVT12)
535 PM_PUSH(EVT13)
536 PM_PUSH(EVT14)
537 PM_PUSH(EVT15)
538 PM_PUSH(IMASK)
539 PM_PUSH(ILAT)
540 PM_PUSH(IPRIO)
541 PM_PUSH(TCNTL)
542 PM_PUSH(TPERIOD)
543 PM_PUSH(TSCALE)
544 PM_PUSH(TCOUNT)
545 PM_PUSH(TBUFCTL)
546
547 /* Save Core Registers */
548 [--sp] = SYSCFG;
549 [--sp] = ( R7:0, P5:0 );
550 [--sp] = fp;
551 [--sp] = usp;
552
553 [--sp] = i0;
554 [--sp] = i1;
555 [--sp] = i2;
556 [--sp] = i3;
557
558 [--sp] = m0;
559 [--sp] = m1;
560 [--sp] = m2;
561 [--sp] = m3;
562
563 [--sp] = l0;
564 [--sp] = l1;
565 [--sp] = l2;
566 [--sp] = l3;
567
568 [--sp] = b0;
569 [--sp] = b1;
570 [--sp] = b2;
571 [--sp] = b3;
572 [--sp] = a0.x;
573 [--sp] = a0.w;
574 [--sp] = a1.x;
575 [--sp] = a1.w;
576
577 [--sp] = LC0;
578 [--sp] = LC1;
579 [--sp] = LT0;
580 [--sp] = LT1;
581 [--sp] = LB0;
582 [--sp] = LB1;
583
584 [--sp] = ASTAT;
585 [--sp] = CYCLES;
586 [--sp] = CYCLES2;
587
588 [--sp] = RETS;
589 r0 = RETI;
590 [--sp] = r0;
591 [--sp] = RETX;
592 [--sp] = RETN;
593 [--sp] = RETE;
594 [--sp] = SEQSTAT;
595
596 /* Save Magic, return address and Stack Pointer */
597 P0.H = 0;
598 P0.L = 0;
599 R0.H = 0xDEAD; /* Hibernate Magic */
600 R0.L = 0xBEEF;
601 [P0++] = R0; /* Store Hibernate Magic */
602 R0.H = .Lpm_resume_here;
603 R0.L = .Lpm_resume_here;
604 [P0++] = R0; /* Save Return Address */
605 [P0++] = SP; /* Save Stack Pointer */
606 P0.H = _hibernate_mode;
607 P0.L = _hibernate_mode;
608 R0 = R2;
609 call (P0); /* Goodbye */
610
611.Lpm_resume_here:
612
613 /* Restore Core Registers */
614 SEQSTAT = [sp++];
615 RETE = [sp++];
616 RETN = [sp++];
617 RETX = [sp++];
618 r0 = [sp++];
619 RETI = r0;
620 RETS = [sp++];
621
622 CYCLES2 = [sp++];
623 CYCLES = [sp++];
624 ASTAT = [sp++];
625
626 LB1 = [sp++];
627 LB0 = [sp++];
628 LT1 = [sp++];
629 LT0 = [sp++];
630 LC1 = [sp++];
631 LC0 = [sp++];
632
633 a1.w = [sp++];
634 a1.x = [sp++];
635 a0.w = [sp++];
636 a0.x = [sp++];
637 b3 = [sp++];
638 b2 = [sp++];
639 b1 = [sp++];
640 b0 = [sp++];
641
642 l3 = [sp++];
643 l2 = [sp++];
644 l1 = [sp++];
645 l0 = [sp++];
646
647 m3 = [sp++];
648 m2 = [sp++];
649 m1 = [sp++];
650 m0 = [sp++];
651
652 i3 = [sp++];
653 i2 = [sp++];
654 i1 = [sp++];
655 i0 = [sp++];
656
657 usp = [sp++];
658 fp = [sp++];
659
660 ( R7 : 0, P5 : 0) = [ SP ++ ];
661 SYSCFG = [sp++];
662
663 /* Restore Core MMRs */
664
665 PM_POP(TBUFCTL)
666 PM_POP(TCOUNT)
667 PM_POP(TSCALE)
668 PM_POP(TPERIOD)
669 PM_POP(TCNTL)
670 PM_POP(IPRIO)
671 PM_POP(ILAT)
672 PM_POP(IMASK)
673 PM_POP(EVT15)
674 PM_POP(EVT14)
675 PM_POP(EVT13)
676 PM_POP(EVT12)
677 PM_POP(EVT11)
678 PM_POP(EVT10)
679 PM_POP(EVT9)
680 PM_POP(EVT8)
681 PM_POP(EVT7)
682 PM_POP(EVT6)
683 PM_POP(EVT5)
684 PM_POP(EVT4)
685 PM_POP(EVT3)
686 PM_POP(EVT2)
687 PM_POP(EVT1)
688 PM_POP(EVT0)
689 PM_POP(ICPLB_DATA15)
690 PM_POP(ICPLB_DATA14)
691 PM_POP(ICPLB_DATA13)
692 PM_POP(ICPLB_DATA12)
693 PM_POP(ICPLB_DATA11)
694 PM_POP(ICPLB_DATA10)
695 PM_POP(ICPLB_DATA9)
696 PM_POP(ICPLB_DATA8)
697 PM_POP(ICPLB_DATA7)
698 PM_POP(ICPLB_DATA6)
699 PM_POP(ICPLB_DATA5)
700 PM_POP(ICPLB_DATA4)
701 PM_POP(ICPLB_DATA3)
702 PM_POP(ICPLB_DATA2)
703 PM_POP(ICPLB_DATA1)
704 PM_POP(ICPLB_DATA0)
705 PM_POP(ICPLB_ADDR15)
706 PM_POP(ICPLB_ADDR14)
707 PM_POP(ICPLB_ADDR13)
708 PM_POP(ICPLB_ADDR12)
709 PM_POP(ICPLB_ADDR11)
710 PM_POP(ICPLB_ADDR10)
711 PM_POP(ICPLB_ADDR9)
712 PM_POP(ICPLB_ADDR8)
713 PM_POP(ICPLB_ADDR7)
714 PM_POP(ICPLB_ADDR6)
715 PM_POP(ICPLB_ADDR5)
716 PM_POP(ICPLB_ADDR4)
717 PM_POP(ICPLB_ADDR3)
718 PM_POP(ICPLB_ADDR2)
719 PM_POP(ICPLB_ADDR1)
720 PM_POP(ICPLB_ADDR0)
721 PM_POP(IMEM_CONTROL)
722 PM_POP(DCPLB_DATA15)
723 PM_POP(DCPLB_DATA14)
724 PM_POP(DCPLB_DATA13)
725 PM_POP(DCPLB_DATA12)
726 PM_POP(DCPLB_DATA11)
727 PM_POP(DCPLB_DATA10)
728 PM_POP(DCPLB_DATA9)
729 PM_POP(DCPLB_DATA8)
730 PM_POP(DCPLB_DATA7)
731 PM_POP(DCPLB_DATA6)
732 PM_POP(DCPLB_DATA5)
733 PM_POP(DCPLB_DATA4)
734 PM_POP(DCPLB_DATA3)
735 PM_POP(DCPLB_DATA2)
736 PM_POP(DCPLB_DATA1)
737 PM_POP(DCPLB_DATA0)
738 PM_POP(DCPLB_ADDR15)
739 PM_POP(DCPLB_ADDR14)
740 PM_POP(DCPLB_ADDR13)
741 PM_POP(DCPLB_ADDR12)
742 PM_POP(DCPLB_ADDR11)
743 PM_POP(DCPLB_ADDR10)
744 PM_POP(DCPLB_ADDR9)
745 PM_POP(DCPLB_ADDR8)
746 PM_POP(DCPLB_ADDR7)
747 PM_POP(DCPLB_ADDR6)
748 PM_POP(DCPLB_ADDR5)
749 PM_POP(DCPLB_ADDR4)
750 PM_POP(DCPLB_ADDR3)
751 PM_POP(DCPLB_ADDR2)
752 PM_POP(DCPLB_ADDR1)
753 PM_POP(DCPLB_ADDR0)
754 PM_POP(DMEM_CONTROL)
755
756 /* Restore System MMRs */
757
758 P0.H = hi(PLL_CTL);
759 P0.L = lo(PLL_CTL);
760 PM_SYS_POP16(SYSCR)
761
762#ifdef EBIU_FCTL
763 PM_SYS_POP(EBIU_FCTL)
764 PM_SYS_POP(EBIU_MODE)
765 PM_SYS_POP(EBIU_MBSCTL)
766#endif
767 PM_SYS_POP16(EBIU_AMGCTL)
768 PM_SYS_POP(EBIU_AMBCTL1)
769 PM_SYS_POP(EBIU_AMBCTL0)
770
771#ifdef PINT0_ASSIGN
772 PM_SYS_POP(PINT3_ASSIGN)
773 PM_SYS_POP(PINT2_ASSIGN)
774 PM_SYS_POP(PINT1_ASSIGN)
775 PM_SYS_POP(PINT0_ASSIGN)
776#endif
777
778#ifdef SICA_IWR1
779 PM_SYS_POP(SICA_IWR1)
780#endif
781#ifdef SICA_IWR0
782 PM_SYS_POP(SICA_IWR0)
783#endif
784#ifdef SIC_IWR2
785 PM_SYS_POP(SIC_IWR2)
786#endif
787#ifdef SIC_IWR1
788 PM_SYS_POP(SIC_IWR1)
789#endif
790#ifdef SIC_IWR0
791 PM_SYS_POP(SIC_IWR0)
792#endif
793#ifdef SIC_IWR
794 PM_SYS_POP(SIC_IWR)
795#endif
796
797#ifdef SICA_IAR0
798 PM_SYS_POP(SICA_IAR7)
799 PM_SYS_POP(SICA_IAR6)
800 PM_SYS_POP(SICA_IAR5)
801 PM_SYS_POP(SICA_IAR4)
802 PM_SYS_POP(SICA_IAR3)
803 PM_SYS_POP(SICA_IAR2)
804 PM_SYS_POP(SICA_IAR1)
805 PM_SYS_POP(SICA_IAR0)
806#endif
807
808#ifdef SIC_IAR8
809 PM_SYS_POP(SIC_IAR11)
810 PM_SYS_POP(SIC_IAR10)
811 PM_SYS_POP(SIC_IAR9)
812 PM_SYS_POP(SIC_IAR8)
813#endif
814#ifdef SIC_IAR7
815 PM_SYS_POP(SIC_IAR7)
816#endif
817#ifdef SIC_IAR6
818 PM_SYS_POP(SIC_IAR6)
819 PM_SYS_POP(SIC_IAR5)
820 PM_SYS_POP(SIC_IAR4)
821#endif
822#ifdef SIC_IAR3
823 PM_SYS_POP(SIC_IAR3)
824#endif
825#ifdef SIC_IAR2
826 PM_SYS_POP(SIC_IAR2)
827 PM_SYS_POP(SIC_IAR1)
828 PM_SYS_POP(SIC_IAR0)
829#endif
830#ifdef SICA_IMASK1
831 PM_SYS_POP(SICA_IMASK1)
832#endif
833#ifdef SICA_IMASK0
834 PM_SYS_POP(SICA_IMASK0)
835#endif
836#ifdef SIC_IMASK
837 PM_SYS_POP(SIC_IMASK)
838#endif
839#ifdef SIC_IMASK2
840 PM_SYS_POP(SIC_IMASK2)
841#endif
842#ifdef SIC_IMASK1
843 PM_SYS_POP(SIC_IMASK1)
844#endif
845#ifdef SIC_IMASK0
846 PM_SYS_POP(SIC_IMASK0)
847#endif
848
849 [--sp] = RETI; /* Clear Global Interrupt Disable */
850 SP += 4;
851
852 RETS = [SP++];
853 ( R7:0, P5:0 ) = [SP++];
854 RTS;
855ENDPROC(_do_hibernate)
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index 038f70e0be65..eceb484d90f9 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -158,23 +158,45 @@ ENTRY(_ex_single_step)
158 cc = r7 == r6; 158 cc = r7 == r6;
159 if cc jump _bfin_return_from_exception; 159 if cc jump _bfin_return_from_exception;
160 160
161 /* Don't do single step in hardware exception handler */
162 p5.l = lo(IPEND);
163 p5.h = hi(IPEND);
164 r6 = [p5];
165 cc = bittst(r6, 5);
166 if cc jump _bfin_return_from_exception;
167
168#ifdef CONFIG_KGDB
169 /* skip single step if current interrupt priority is higher than
170 * that of the first instruction, from which gdb starts single step */
171 r6 >>= 6;
172 r7 = 10;
173.Lfind_priority_start:
174 cc = bittst(r6, 0);
175 if cc jump .Lfind_priority_done;
176 r6 >>= 1;
177 r7 += -1;
178 cc = r7 == 0;
179 if cc jump .Lfind_priority_done;
180 jump.s .Lfind_priority_start;
181.Lfind_priority_done:
182 p4.l = _debugger_step;
183 p4.h = _debugger_step;
184 r6 = [p4];
185 cc = r6 == 0;
186 if cc jump .Ldo_single_step;
187 r6 += -1;
188 cc = r6 < r7;
189 if cc jump _bfin_return_from_exception;
190.Ldo_single_step:
191#endif
192
161 /* If we were in user mode, do the single step normally. */ 193 /* If we were in user mode, do the single step normally. */
162 p5.l = lo(IPEND);
163 p5.h = hi(IPEND);
164 r6 = [p5]; 194 r6 = [p5];
165 r7 = 0xffe0 (z); 195 r7 = 0xffe0 (z);
166 r7 = r7 & r6; 196 r7 = r7 & r6;
167 cc = r7 == 0; 197 cc = r7 == 0;
168 if !cc jump 1f; 198 if cc jump 1f;
169
170 /* Single stepping only a single instruction, so clear the trace
171 * bit here. */
172 r7 = syscfg;
173 bitclr (r7, 0);
174 syscfg = R7;
175 jump _ex_trap_c;
176 199
1771:
178 /* 200 /*
179 * We were in an interrupt handler. By convention, all of them save 201 * We were in an interrupt handler. By convention, all of them save
180 * SYSCFG with their first instruction, so by checking whether our 202 * SYSCFG with their first instruction, so by checking whether our
@@ -202,11 +224,15 @@ ENTRY(_ex_single_step)
202 cc = R7 == R6; 224 cc = R7 == R6;
203 if !cc jump _bfin_return_from_exception; 225 if !cc jump _bfin_return_from_exception;
204 226
2271:
228 /* Single stepping only a single instruction, so clear the trace
229 * bit here. */
205 r7 = syscfg; 230 r7 = syscfg;
206 bitclr (r7, 0); 231 bitclr (r7, 0);
207 syscfg = R7; 232 syscfg = R7;
208 233
209 /* Fall through to _bfin_return_from_exception. */ 234 jump _ex_trap_c;
235
210ENDPROC(_ex_single_step) 236ENDPROC(_ex_single_step)
211 237
212ENTRY(_bfin_return_from_exception) 238ENTRY(_bfin_return_from_exception)
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index f5fd768022ea..64d746114e4b 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -459,6 +459,8 @@ static struct irq_chip bfin_gpio_irqchip = {
459 .mask = bfin_gpio_mask_irq, 459 .mask = bfin_gpio_mask_irq,
460 .mask_ack = bfin_gpio_mask_ack_irq, 460 .mask_ack = bfin_gpio_mask_ack_irq,
461 .unmask = bfin_gpio_unmask_irq, 461 .unmask = bfin_gpio_unmask_irq,
462 .disable = bfin_gpio_mask_irq,
463 .enable = bfin_gpio_unmask_irq,
462 .set_type = bfin_gpio_irq_type, 464 .set_type = bfin_gpio_irq_type,
463 .startup = bfin_gpio_irq_startup, 465 .startup = bfin_gpio_irq_startup,
464 .shutdown = bfin_gpio_irq_shutdown, 466 .shutdown = bfin_gpio_irq_shutdown,
@@ -846,6 +848,8 @@ static struct irq_chip bfin_gpio_irqchip = {
846 .mask = bfin_gpio_mask_irq, 848 .mask = bfin_gpio_mask_irq,
847 .mask_ack = bfin_gpio_mask_ack_irq, 849 .mask_ack = bfin_gpio_mask_ack_irq,
848 .unmask = bfin_gpio_unmask_irq, 850 .unmask = bfin_gpio_unmask_irq,
851 .disable = bfin_gpio_mask_irq,
852 .enable = bfin_gpio_unmask_irq,
849 .set_type = bfin_gpio_irq_type, 853 .set_type = bfin_gpio_irq_type,
850 .startup = bfin_gpio_irq_startup, 854 .startup = bfin_gpio_irq_startup,
851 .shutdown = bfin_gpio_irq_shutdown, 855 .shutdown = bfin_gpio_irq_shutdown,
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index 0be805ca423f..4fe6a2366b13 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -38,8 +38,9 @@
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/irq.h> 39#include <linux/irq.h>
40 40
41#include <asm/dpmc.h>
42#include <asm/gpio.h> 41#include <asm/gpio.h>
42#include <asm/dma.h>
43#include <asm/dpmc.h>
43 44
44#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H 45#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H
45#define WAKEUP_TYPE PM_WAKE_HIGH 46#define WAKEUP_TYPE PM_WAKE_HIGH
@@ -61,16 +62,17 @@
61#define WAKEUP_TYPE PM_WAKE_BOTH_EDGES 62#define WAKEUP_TYPE PM_WAKE_BOTH_EDGES
62#endif 63#endif
63 64
65
64void bfin_pm_suspend_standby_enter(void) 66void bfin_pm_suspend_standby_enter(void)
65{ 67{
68 unsigned long flags;
69
66#ifdef CONFIG_PM_WAKEUP_BY_GPIO 70#ifdef CONFIG_PM_WAKEUP_BY_GPIO
67 gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE); 71 gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE);
68#endif 72#endif
69 73
70 u32 flags;
71
72 local_irq_save(flags); 74 local_irq_save(flags);
73 bfin_pm_setup(); 75 bfin_pm_standby_setup();
74 76
75#ifdef CONFIG_PM_BFIN_SLEEP_DEEPER 77#ifdef CONFIG_PM_BFIN_SLEEP_DEEPER
76 sleep_deeper(bfin_sic_iwr[0], bfin_sic_iwr[1], bfin_sic_iwr[2]); 78 sleep_deeper(bfin_sic_iwr[0], bfin_sic_iwr[1], bfin_sic_iwr[2]);
@@ -78,7 +80,7 @@ void bfin_pm_suspend_standby_enter(void)
78 sleep_mode(bfin_sic_iwr[0], bfin_sic_iwr[1], bfin_sic_iwr[2]); 80 sleep_mode(bfin_sic_iwr[0], bfin_sic_iwr[1], bfin_sic_iwr[2]);
79#endif 81#endif
80 82
81 bfin_pm_restore(); 83 bfin_pm_standby_restore();
82 84
83#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) 85#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
84 bfin_write_SIC_IWR0(IWR_ENABLE_ALL); 86 bfin_write_SIC_IWR0(IWR_ENABLE_ALL);
@@ -93,6 +95,195 @@ void bfin_pm_suspend_standby_enter(void)
93 local_irq_restore(flags); 95 local_irq_restore(flags);
94} 96}
95 97
98int bf53x_suspend_l1_mem(unsigned char *memptr)
99{
100 dma_memcpy(memptr, (const void *) L1_CODE_START, L1_CODE_LENGTH);
101 dma_memcpy(memptr + L1_CODE_LENGTH, (const void *) L1_DATA_A_START,
102 L1_DATA_A_LENGTH);
103 dma_memcpy(memptr + L1_CODE_LENGTH + L1_DATA_A_LENGTH,
104 (const void *) L1_DATA_B_START, L1_DATA_B_LENGTH);
105 memcpy(memptr + L1_CODE_LENGTH + L1_DATA_A_LENGTH +
106 L1_DATA_B_LENGTH, (const void *) L1_SCRATCH_START,
107 L1_SCRATCH_LENGTH);
108
109 return 0;
110}
111
112int bf53x_resume_l1_mem(unsigned char *memptr)
113{
114 dma_memcpy((void *) L1_CODE_START, memptr, L1_CODE_LENGTH);
115 dma_memcpy((void *) L1_DATA_A_START, memptr + L1_CODE_LENGTH,
116 L1_DATA_A_LENGTH);
117 dma_memcpy((void *) L1_DATA_B_START, memptr + L1_CODE_LENGTH +
118 L1_DATA_A_LENGTH, L1_DATA_B_LENGTH);
119 memcpy((void *) L1_SCRATCH_START, memptr + L1_CODE_LENGTH +
120 L1_DATA_A_LENGTH + L1_DATA_B_LENGTH, L1_SCRATCH_LENGTH);
121
122 return 0;
123}
124
125#ifdef CONFIG_BFIN_WB
126static void flushinv_all_dcache(void)
127{
128 u32 way, bank, subbank, set;
129 u32 status, addr;
130 u32 dmem_ctl = bfin_read_DMEM_CONTROL();
131
132 for (bank = 0; bank < 2; ++bank) {
133 if (!(dmem_ctl & (1 << (DMC1_P - bank))))
134 continue;
135
136 for (way = 0; way < 2; ++way)
137 for (subbank = 0; subbank < 4; ++subbank)
138 for (set = 0; set < 64; ++set) {
139
140 bfin_write_DTEST_COMMAND(
141 way << 26 |
142 bank << 23 |
143 subbank << 16 |
144 set << 5
145 );
146 CSYNC();
147 status = bfin_read_DTEST_DATA0();
148
149 /* only worry about valid/dirty entries */
150 if ((status & 0x3) != 0x3)
151 continue;
152
153 /* construct the address using the tag */
154 addr = (status & 0xFFFFC800) | (subbank << 12) | (set << 5);
155
156 /* flush it */
157 __asm__ __volatile__("FLUSHINV[%0];" : : "a"(addr));
158 }
159 }
160}
161#endif
162
163static inline void dcache_disable(void)
164{
165#ifdef CONFIG_BFIN_DCACHE
166 unsigned long ctrl;
167
168#ifdef CONFIG_BFIN_WB
169 flushinv_all_dcache();
170#endif
171 SSYNC();
172 ctrl = bfin_read_DMEM_CONTROL();
173 ctrl &= ~ENDCPLB;
174 bfin_write_DMEM_CONTROL(ctrl);
175 SSYNC();
176#endif
177}
178
179static inline void dcache_enable(void)
180{
181#ifdef CONFIG_BFIN_DCACHE
182 unsigned long ctrl;
183 SSYNC();
184 ctrl = bfin_read_DMEM_CONTROL();
185 ctrl |= ENDCPLB;
186 bfin_write_DMEM_CONTROL(ctrl);
187 SSYNC();
188#endif
189}
190
191static inline void icache_disable(void)
192{
193#ifdef CONFIG_BFIN_ICACHE
194 unsigned long ctrl;
195 SSYNC();
196 ctrl = bfin_read_IMEM_CONTROL();
197 ctrl &= ~ENICPLB;
198 bfin_write_IMEM_CONTROL(ctrl);
199 SSYNC();
200#endif
201}
202
203static inline void icache_enable(void)
204{
205#ifdef CONFIG_BFIN_ICACHE
206 unsigned long ctrl;
207 SSYNC();
208 ctrl = bfin_read_IMEM_CONTROL();
209 ctrl |= ENICPLB;
210 bfin_write_IMEM_CONTROL(ctrl);
211 SSYNC();
212#endif
213}
214
215int bfin_pm_suspend_mem_enter(void)
216{
217 unsigned long flags;
218 int wakeup, ret;
219
220 unsigned char *memptr = kmalloc(L1_CODE_LENGTH + L1_DATA_A_LENGTH
221 + L1_DATA_B_LENGTH + L1_SCRATCH_LENGTH,
222 GFP_KERNEL);
223
224 if (memptr == NULL) {
225 panic("bf53x_suspend_l1_mem malloc failed");
226 return -ENOMEM;
227 }
228
229 wakeup = bfin_read_VR_CTL() & ~FREQ;
230 wakeup |= SCKELOW;
231
232 /* FIXME: merge this somehow with set_irq_wake */
233#ifdef CONFIG_PM_BFIN_WAKE_RTC
234 wakeup |= WAKE;
235#endif
236#ifdef CONFIG_PM_BFIN_WAKE_PH6
237 wakeup |= PHYWE;
238#endif
239#ifdef CONFIG_PM_BFIN_WAKE_CAN
240 wakeup |= CANWE;
241#endif
242#ifdef CONFIG_PM_BFIN_WAKE_GP
243 wakeup |= GPWE;
244#endif
245#ifdef CONFIG_PM_BFIN_WAKE_USB
246 wakeup |= USBWE;
247#endif
248#ifdef CONFIG_PM_BFIN_WAKE_KEYPAD
249 wakeup |= KPADWE;
250#endif
251#ifdef CONFIG_PM_BFIN_WAKE_ROTARY
252 wakeup |= ROTWE;
253#endif
254
255 local_irq_save(flags);
256
257 ret = blackfin_dma_suspend();
258
259 if (ret) {
260 local_irq_restore(flags);
261 kfree(memptr);
262 return ret;
263 }
264
265 bfin_gpio_pm_hibernate_suspend();
266
267 dcache_disable();
268 icache_disable();
269 bf53x_suspend_l1_mem(memptr);
270
271 do_hibernate(wakeup); /* Goodbye */
272
273 bf53x_resume_l1_mem(memptr);
274
275 icache_enable();
276 dcache_enable();
277
278 bfin_gpio_pm_hibernate_restore();
279 blackfin_dma_resume();
280
281 local_irq_restore(flags);
282 kfree(memptr);
283
284 return 0;
285}
286
96/* 287/*
97 * bfin_pm_valid - Tell the PM core that we only support the standby sleep 288 * bfin_pm_valid - Tell the PM core that we only support the standby sleep
98 * state 289 * state
@@ -101,7 +292,24 @@ void bfin_pm_suspend_standby_enter(void)
101 */ 292 */
102static int bfin_pm_valid(suspend_state_t state) 293static int bfin_pm_valid(suspend_state_t state)
103{ 294{
104 return (state == PM_SUSPEND_STANDBY); 295 return (state == PM_SUSPEND_STANDBY
296#ifndef BF533_FAMILY
297 /*
298 * On BF533/2/1:
299 * If we enter Hibernate the SCKE Pin is driven Low,
300 * so that the SDRAM enters Self Refresh Mode.
301 * However when the reset sequence that follows hibernate
302 * state is executed, SCKE is driven High, taking the
303 * SDRAM out of Self Refresh.
304 *
305 * If you reconfigure and access the SDRAM "very quickly",
306 * you are likely to avoid errors, otherwise the SDRAM
307 * start losing its contents.
308 * An external HW workaround is possible using logic gates.
309 */
310 || state == PM_SUSPEND_MEM
311#endif
312 );
105} 313}
106 314
107/* 315/*
@@ -115,10 +323,9 @@ static int bfin_pm_enter(suspend_state_t state)
115 case PM_SUSPEND_STANDBY: 323 case PM_SUSPEND_STANDBY:
116 bfin_pm_suspend_standby_enter(); 324 bfin_pm_suspend_standby_enter();
117 break; 325 break;
118
119 case PM_SUSPEND_MEM: 326 case PM_SUSPEND_MEM:
120 return -ENOTSUPP; 327 bfin_pm_suspend_mem_enter();
121 328 break;
122 default: 329 default:
123 return -EINVAL; 330 return -EINVAL;
124 } 331 }
diff --git a/arch/blackfin/mm/blackfin_sram.c b/arch/blackfin/mm/blackfin_sram.c
index 3246f91c7baa..5af3c31c9365 100644
--- a/arch/blackfin/mm/blackfin_sram.c
+++ b/arch/blackfin/mm/blackfin_sram.c
@@ -41,215 +41,309 @@
41#include <asm/blackfin.h> 41#include <asm/blackfin.h>
42#include "blackfin_sram.h" 42#include "blackfin_sram.h"
43 43
44spinlock_t l1sram_lock, l1_data_sram_lock, l1_inst_sram_lock; 44static spinlock_t l1sram_lock, l1_data_sram_lock, l1_inst_sram_lock;
45 45static spinlock_t l2_sram_lock;
46#if CONFIG_L1_MAX_PIECE < 16
47#undef CONFIG_L1_MAX_PIECE
48#define CONFIG_L1_MAX_PIECE 16
49#endif
50
51#if CONFIG_L1_MAX_PIECE > 1024
52#undef CONFIG_L1_MAX_PIECE
53#define CONFIG_L1_MAX_PIECE 1024
54#endif
55
56#define SRAM_SLT_NULL 0
57#define SRAM_SLT_FREE 1
58#define SRAM_SLT_ALLOCATED 2
59 46
60/* the data structure for L1 scratchpad and DATA SRAM */ 47/* the data structure for L1 scratchpad and DATA SRAM */
61struct l1_sram_piece { 48struct sram_piece {
62 void *paddr; 49 void *paddr;
63 int size; 50 int size;
64 int flag;
65 pid_t pid; 51 pid_t pid;
52 struct sram_piece *next;
66}; 53};
67 54
68static struct l1_sram_piece l1_ssram[CONFIG_L1_MAX_PIECE]; 55static struct sram_piece free_l1_ssram_head, used_l1_ssram_head;
69 56
70#if L1_DATA_A_LENGTH != 0 57#if L1_DATA_A_LENGTH != 0
71static struct l1_sram_piece l1_data_A_sram[CONFIG_L1_MAX_PIECE]; 58static struct sram_piece free_l1_data_A_sram_head, used_l1_data_A_sram_head;
72#endif 59#endif
73 60
74#if L1_DATA_B_LENGTH != 0 61#if L1_DATA_B_LENGTH != 0
75static struct l1_sram_piece l1_data_B_sram[CONFIG_L1_MAX_PIECE]; 62static struct sram_piece free_l1_data_B_sram_head, used_l1_data_B_sram_head;
76#endif 63#endif
77 64
78#if L1_CODE_LENGTH != 0 65#if L1_CODE_LENGTH != 0
79static struct l1_sram_piece l1_inst_sram[CONFIG_L1_MAX_PIECE]; 66static struct sram_piece free_l1_inst_sram_head, used_l1_inst_sram_head;
67#endif
68
69#ifdef L2_LENGTH
70static struct sram_piece free_l2_sram_head, used_l2_sram_head;
80#endif 71#endif
81 72
73static struct kmem_cache *sram_piece_cache;
74
82/* L1 Scratchpad SRAM initialization function */ 75/* L1 Scratchpad SRAM initialization function */
83void __init l1sram_init(void) 76static void __init l1sram_init(void)
84{ 77{
85 printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n", 78 free_l1_ssram_head.next =
86 L1_SCRATCH_LENGTH >> 10); 79 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
80 if (!free_l1_ssram_head.next) {
81 printk(KERN_INFO"Fail to initialize Scratchpad data SRAM.\n");
82 return;
83 }
84
85 free_l1_ssram_head.next->paddr = (void *)L1_SCRATCH_START;
86 free_l1_ssram_head.next->size = L1_SCRATCH_LENGTH;
87 free_l1_ssram_head.next->pid = 0;
88 free_l1_ssram_head.next->next = NULL;
87 89
88 memset(&l1_ssram, 0x00, sizeof(l1_ssram)); 90 used_l1_ssram_head.next = NULL;
89 l1_ssram[0].paddr = (void *)L1_SCRATCH_START;
90 l1_ssram[0].size = L1_SCRATCH_LENGTH;
91 l1_ssram[0].flag = SRAM_SLT_FREE;
92 91
93 /* mutex initialize */ 92 /* mutex initialize */
94 spin_lock_init(&l1sram_lock); 93 spin_lock_init(&l1sram_lock);
94
95 printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n",
96 L1_SCRATCH_LENGTH >> 10);
95} 97}
96 98
97void __init l1_data_sram_init(void) 99static void __init l1_data_sram_init(void)
98{ 100{
99#if L1_DATA_A_LENGTH != 0 101#if L1_DATA_A_LENGTH != 0
100 memset(&l1_data_A_sram, 0x00, sizeof(l1_data_A_sram)); 102 free_l1_data_A_sram_head.next =
101 l1_data_A_sram[0].paddr = (void *)L1_DATA_A_START + 103 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
102 (_ebss_l1 - _sdata_l1); 104 if (!free_l1_data_A_sram_head.next) {
103 l1_data_A_sram[0].size = L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1); 105 printk(KERN_INFO"Fail to initialize L1 Data A SRAM.\n");
104 l1_data_A_sram[0].flag = SRAM_SLT_FREE; 106 return;
105 107 }
106 printk(KERN_INFO "Blackfin Data A SRAM: %d KB (%d KB free)\n", 108
107 L1_DATA_A_LENGTH >> 10, l1_data_A_sram[0].size >> 10); 109 free_l1_data_A_sram_head.next->paddr =
110 (void *)L1_DATA_A_START + (_ebss_l1 - _sdata_l1);
111 free_l1_data_A_sram_head.next->size =
112 L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1);
113 free_l1_data_A_sram_head.next->pid = 0;
114 free_l1_data_A_sram_head.next->next = NULL;
115
116 used_l1_data_A_sram_head.next = NULL;
117
118 printk(KERN_INFO "Blackfin L1 Data A SRAM: %d KB (%d KB free)\n",
119 L1_DATA_A_LENGTH >> 10,
120 free_l1_data_A_sram_head.next->size >> 10);
108#endif 121#endif
109#if L1_DATA_B_LENGTH != 0 122#if L1_DATA_B_LENGTH != 0
110 memset(&l1_data_B_sram, 0x00, sizeof(l1_data_B_sram)); 123 free_l1_data_B_sram_head.next =
111 l1_data_B_sram[0].paddr = (void *)L1_DATA_B_START + 124 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
112 (_ebss_b_l1 - _sdata_b_l1); 125 if (!free_l1_data_B_sram_head.next) {
113 l1_data_B_sram[0].size = L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1); 126 printk(KERN_INFO"Fail to initialize L1 Data B SRAM.\n");
114 l1_data_B_sram[0].flag = SRAM_SLT_FREE; 127 return;
115 128 }
116 printk(KERN_INFO "Blackfin Data B SRAM: %d KB (%d KB free)\n", 129
117 L1_DATA_B_LENGTH >> 10, l1_data_B_sram[0].size >> 10); 130 free_l1_data_B_sram_head.next->paddr =
131 (void *)L1_DATA_B_START + (_ebss_b_l1 - _sdata_b_l1);
132 free_l1_data_B_sram_head.next->size =
133 L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1);
134 free_l1_data_B_sram_head.next->pid = 0;
135 free_l1_data_B_sram_head.next->next = NULL;
136
137 used_l1_data_B_sram_head.next = NULL;
138
139 printk(KERN_INFO "Blackfin L1 Data B SRAM: %d KB (%d KB free)\n",
140 L1_DATA_B_LENGTH >> 10,
141 free_l1_data_B_sram_head.next->size >> 10);
118#endif 142#endif
119 143
120 /* mutex initialize */ 144 /* mutex initialize */
121 spin_lock_init(&l1_data_sram_lock); 145 spin_lock_init(&l1_data_sram_lock);
122} 146}
123 147
124void __init l1_inst_sram_init(void) 148static void __init l1_inst_sram_init(void)
125{ 149{
126#if L1_CODE_LENGTH != 0 150#if L1_CODE_LENGTH != 0
127 memset(&l1_inst_sram, 0x00, sizeof(l1_inst_sram)); 151 free_l1_inst_sram_head.next =
128 l1_inst_sram[0].paddr = (void *)L1_CODE_START + (_etext_l1 - _stext_l1); 152 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
129 l1_inst_sram[0].size = L1_CODE_LENGTH - (_etext_l1 - _stext_l1); 153 if (!free_l1_inst_sram_head.next) {
130 l1_inst_sram[0].flag = SRAM_SLT_FREE; 154 printk(KERN_INFO"Fail to initialize L1 Instruction SRAM.\n");
155 return;
156 }
131 157
132 printk(KERN_INFO "Blackfin Instruction SRAM: %d KB (%d KB free)\n", 158 free_l1_inst_sram_head.next->paddr =
133 L1_CODE_LENGTH >> 10, l1_inst_sram[0].size >> 10); 159 (void *)L1_CODE_START + (_etext_l1 - _stext_l1);
160 free_l1_inst_sram_head.next->size =
161 L1_CODE_LENGTH - (_etext_l1 - _stext_l1);
162 free_l1_inst_sram_head.next->pid = 0;
163 free_l1_inst_sram_head.next->next = NULL;
164
165 used_l1_inst_sram_head.next = NULL;
166
167 printk(KERN_INFO "Blackfin L1 Instruction SRAM: %d KB (%d KB free)\n",
168 L1_CODE_LENGTH >> 10,
169 free_l1_inst_sram_head.next->size >> 10);
134#endif 170#endif
135 171
136 /* mutex initialize */ 172 /* mutex initialize */
137 spin_lock_init(&l1_inst_sram_lock); 173 spin_lock_init(&l1_inst_sram_lock);
138} 174}
139 175
140/* L1 memory allocate function */ 176static void __init l2_sram_init(void)
141static void *_l1_sram_alloc(size_t size, struct l1_sram_piece *pfree, int count)
142{ 177{
143 int i, index = 0; 178#ifdef L2_LENGTH
144 void *addr = NULL; 179 free_l2_sram_head.next =
180 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
181 if (!free_l2_sram_head.next) {
182 printk(KERN_INFO"Fail to initialize L2 SRAM.\n");
183 return;
184 }
145 185
146 if (size <= 0) 186 free_l2_sram_head.next->paddr = (void *)L2_START +
187 (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2);
188 free_l2_sram_head.next->size = L2_LENGTH -
189 (_etext_l2 - _stext_l2) + (_edata_l2 - _sdata_l2);
190 free_l2_sram_head.next->pid = 0;
191 free_l2_sram_head.next->next = NULL;
192
193 used_l2_sram_head.next = NULL;
194
195 printk(KERN_INFO "Blackfin L2 SRAM: %d KB (%d KB free)\n",
196 L2_LENGTH >> 10,
197 free_l2_sram_head.next->size >> 10);
198#endif
199
200 /* mutex initialize */
201 spin_lock_init(&l2_sram_lock);
202}
203void __init bfin_sram_init(void)
204{
205 sram_piece_cache = kmem_cache_create("sram_piece_cache",
206 sizeof(struct sram_piece),
207 0, SLAB_PANIC, NULL);
208
209 l1sram_init();
210 l1_data_sram_init();
211 l1_inst_sram_init();
212 l2_sram_init();
213}
214
215/* SRAM allocate function */
216static void *_sram_alloc(size_t size, struct sram_piece *pfree_head,
217 struct sram_piece *pused_head)
218{
219 struct sram_piece *pslot, *plast, *pavail;
220
221 if (size <= 0 || !pfree_head || !pused_head)
147 return NULL; 222 return NULL;
148 223
149 /* Align the size */ 224 /* Align the size */
150 size = (size + 3) & ~3; 225 size = (size + 3) & ~3;
151 226
152 /* not use the good method to match the best slot !!! */ 227 pslot = pfree_head->next;
153 /* search an available memory slot */ 228 plast = pfree_head;
154 for (i = 0; i < count; i++) { 229
155 if ((pfree[i].flag == SRAM_SLT_FREE) 230 /* search an available piece slot */
156 && (pfree[i].size >= size)) { 231 while (pslot != NULL && size > pslot->size) {
157 addr = pfree[i].paddr; 232 plast = pslot;
158 pfree[i].flag = SRAM_SLT_ALLOCATED; 233 pslot = pslot->next;
159 pfree[i].pid = current->pid;
160 index = i;
161 break;
162 }
163 } 234 }
164 if (i >= count) 235
236 if (!pslot)
165 return NULL; 237 return NULL;
166 238
167 /* updated the NULL memory slot !!! */ 239 if (pslot->size == size) {
168 if (pfree[i].size > size) { 240 plast->next = pslot->next;
169 for (i = 0; i < count; i++) { 241 pavail = pslot;
170 if (pfree[i].flag == SRAM_SLT_NULL) { 242 } else {
171 pfree[i].pid = 0; 243 pavail = kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
172 pfree[i].flag = SRAM_SLT_FREE; 244
173 pfree[i].paddr = addr + size; 245 if (!pavail)
174 pfree[i].size = pfree[index].size - size; 246 return NULL;
175 pfree[index].size = size; 247
176 break; 248 pavail->paddr = pslot->paddr;
177 } 249 pavail->size = size;
178 } 250 pslot->paddr += size;
251 pslot->size -= size;
179 } 252 }
180 253
181 return addr; 254 pavail->pid = current->pid;
255
256 pslot = pused_head->next;
257 plast = pused_head;
258
259 /* insert new piece into used piece list !!! */
260 while (pslot != NULL && pavail->paddr < pslot->paddr) {
261 plast = pslot;
262 pslot = pslot->next;
263 }
264
265 pavail->next = pslot;
266 plast->next = pavail;
267
268 return pavail->paddr;
182} 269}
183 270
184/* Allocate the largest available block. */ 271/* Allocate the largest available block. */
185static void *_l1_sram_alloc_max(struct l1_sram_piece *pfree, int count, 272static void *_sram_alloc_max(struct sram_piece *pfree_head,
273 struct sram_piece *pused_head,
186 unsigned long *psize) 274 unsigned long *psize)
187{ 275{
188 unsigned long best = 0; 276 struct sram_piece *pslot, *pmax;
189 int i, index = -1;
190 void *addr = NULL;
191 277
192 /* search an available memory slot */ 278 if (!pfree_head || !pused_head)
193 for (i = 0; i < count; i++) { 279 return NULL;
194 if (pfree[i].flag == SRAM_SLT_FREE && pfree[i].size > best) { 280
195 addr = pfree[i].paddr; 281 pmax = pslot = pfree_head->next;
196 index = i; 282
197 best = pfree[i].size; 283 /* search an available piece slot */
198 } 284 while (pslot != NULL) {
285 if (pslot->size > pmax->size)
286 pmax = pslot;
287 pslot = pslot->next;
199 } 288 }
200 if (index < 0) 289
290 if (!pmax)
201 return NULL; 291 return NULL;
202 *psize = best;
203 292
204 pfree[index].pid = current->pid; 293 *psize = pmax->size;
205 pfree[index].flag = SRAM_SLT_ALLOCATED; 294
206 return addr; 295 return _sram_alloc(*psize, pfree_head, pused_head);
207} 296}
208 297
209/* L1 memory free function */ 298/* SRAM free function */
210static int _l1_sram_free(const void *addr, 299static int _sram_free(const void *addr,
211 struct l1_sram_piece *pfree, 300 struct sram_piece *pfree_head,
212 int count) 301 struct sram_piece *pused_head)
213{ 302{
214 int i, index = 0; 303 struct sram_piece *pslot, *plast, *pavail;
304
305 if (!pfree_head || !pused_head)
306 return -1;
215 307
216 /* search the relevant memory slot */ 308 /* search the relevant memory slot */
217 for (i = 0; i < count; i++) { 309 pslot = pused_head->next;
218 if (pfree[i].paddr == addr) { 310 plast = pused_head;
219 if (pfree[i].flag != SRAM_SLT_ALLOCATED) { 311
220 /* error log */ 312 /* search an available piece slot */
221 return -1; 313 while (pslot != NULL && pslot->paddr != addr) {
222 } 314 plast = pslot;
223 index = i; 315 pslot = pslot->next;
224 break;
225 }
226 } 316 }
227 if (i >= count) 317
318 if (!pslot)
228 return -1; 319 return -1;
229 320
230 pfree[index].pid = 0; 321 plast->next = pslot->next;
231 pfree[index].flag = SRAM_SLT_FREE; 322 pavail = pslot;
232 323 pavail->pid = 0;
233 /* link the next address slot */ 324
234 for (i = 0; i < count; i++) { 325 /* insert free pieces back to the free list */
235 if (((pfree[index].paddr + pfree[index].size) == pfree[i].paddr) 326 pslot = pfree_head->next;
236 && (pfree[i].flag == SRAM_SLT_FREE)) { 327 plast = pfree_head;
237 pfree[i].pid = 0; 328
238 pfree[i].flag = SRAM_SLT_NULL; 329 while (pslot != NULL && addr > pslot->paddr) {
239 pfree[index].size += pfree[i].size; 330 plast = pslot;
240 pfree[index].flag = SRAM_SLT_FREE; 331 pslot = pslot->next;
241 break; 332 }
242 } 333
334 if (plast != pfree_head && plast->paddr + plast->size == pavail->paddr) {
335 plast->size += pavail->size;
336 kmem_cache_free(sram_piece_cache, pavail);
337 } else {
338 pavail->next = plast;
339 plast->next = pavail;
340 plast = pavail;
243 } 341 }
244 342
245 /* link the last address slot */ 343 if (pslot && plast->paddr + plast->size == pslot->paddr) {
246 for (i = 0; i < count; i++) { 344 plast->size += pslot->size;
247 if (((pfree[i].paddr + pfree[i].size) == pfree[index].paddr) && 345 plast->next = pslot->next;
248 (pfree[i].flag == SRAM_SLT_FREE)) { 346 kmem_cache_free(sram_piece_cache, pslot);
249 pfree[index].flag = SRAM_SLT_NULL;
250 pfree[i].size += pfree[index].size;
251 break;
252 }
253 } 347 }
254 348
255 return 0; 349 return 0;
@@ -273,6 +367,11 @@ int sram_free(const void *addr)
273 && addr < (void *)(L1_DATA_B_START + L1_DATA_B_LENGTH)) 367 && addr < (void *)(L1_DATA_B_START + L1_DATA_B_LENGTH))
274 return l1_data_B_sram_free(addr); 368 return l1_data_B_sram_free(addr);
275#endif 369#endif
370#ifdef L2_LENGTH
371 else if (addr >= (void *)L2_START
372 && addr < (void *)(L2_START + L2_LENGTH))
373 return l2_sram_free(addr);
374#endif
276 else 375 else
277 return -1; 376 return -1;
278} 377}
@@ -287,7 +386,8 @@ void *l1_data_A_sram_alloc(size_t size)
287 spin_lock_irqsave(&l1_data_sram_lock, flags); 386 spin_lock_irqsave(&l1_data_sram_lock, flags);
288 387
289#if L1_DATA_A_LENGTH != 0 388#if L1_DATA_A_LENGTH != 0
290 addr = _l1_sram_alloc(size, l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram)); 389 addr = _sram_alloc(size, &free_l1_data_A_sram_head,
390 &used_l1_data_A_sram_head);
291#endif 391#endif
292 392
293 /* add mutex operation */ 393 /* add mutex operation */
@@ -309,8 +409,8 @@ int l1_data_A_sram_free(const void *addr)
309 spin_lock_irqsave(&l1_data_sram_lock, flags); 409 spin_lock_irqsave(&l1_data_sram_lock, flags);
310 410
311#if L1_DATA_A_LENGTH != 0 411#if L1_DATA_A_LENGTH != 0
312 ret = _l1_sram_free(addr, 412 ret = _sram_free(addr, &free_l1_data_A_sram_head,
313 l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram)); 413 &used_l1_data_A_sram_head);
314#else 414#else
315 ret = -1; 415 ret = -1;
316#endif 416#endif
@@ -331,7 +431,8 @@ void *l1_data_B_sram_alloc(size_t size)
331 /* add mutex operation */ 431 /* add mutex operation */
332 spin_lock_irqsave(&l1_data_sram_lock, flags); 432 spin_lock_irqsave(&l1_data_sram_lock, flags);
333 433
334 addr = _l1_sram_alloc(size, l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram)); 434 addr = _sram_alloc(size, &free_l1_data_B_sram_head,
435 &used_l1_data_B_sram_head);
335 436
336 /* add mutex operation */ 437 /* add mutex operation */
337 spin_unlock_irqrestore(&l1_data_sram_lock, flags); 438 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
@@ -355,7 +456,8 @@ int l1_data_B_sram_free(const void *addr)
355 /* add mutex operation */ 456 /* add mutex operation */
356 spin_lock_irqsave(&l1_data_sram_lock, flags); 457 spin_lock_irqsave(&l1_data_sram_lock, flags);
357 458
358 ret = _l1_sram_free(addr, l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram)); 459 ret = _sram_free(addr, &free_l1_data_B_sram_head,
460 &used_l1_data_B_sram_head);
359 461
360 /* add mutex operation */ 462 /* add mutex operation */
361 spin_unlock_irqrestore(&l1_data_sram_lock, flags); 463 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
@@ -408,7 +510,8 @@ void *l1_inst_sram_alloc(size_t size)
408 /* add mutex operation */ 510 /* add mutex operation */
409 spin_lock_irqsave(&l1_inst_sram_lock, flags); 511 spin_lock_irqsave(&l1_inst_sram_lock, flags);
410 512
411 addr = _l1_sram_alloc(size, l1_inst_sram, ARRAY_SIZE(l1_inst_sram)); 513 addr = _sram_alloc(size, &free_l1_inst_sram_head,
514 &used_l1_inst_sram_head);
412 515
413 /* add mutex operation */ 516 /* add mutex operation */
414 spin_unlock_irqrestore(&l1_inst_sram_lock, flags); 517 spin_unlock_irqrestore(&l1_inst_sram_lock, flags);
@@ -432,7 +535,8 @@ int l1_inst_sram_free(const void *addr)
432 /* add mutex operation */ 535 /* add mutex operation */
433 spin_lock_irqsave(&l1_inst_sram_lock, flags); 536 spin_lock_irqsave(&l1_inst_sram_lock, flags);
434 537
435 ret = _l1_sram_free(addr, l1_inst_sram, ARRAY_SIZE(l1_inst_sram)); 538 ret = _sram_free(addr, &free_l1_inst_sram_head,
539 &used_l1_inst_sram_head);
436 540
437 /* add mutex operation */ 541 /* add mutex operation */
438 spin_unlock_irqrestore(&l1_inst_sram_lock, flags); 542 spin_unlock_irqrestore(&l1_inst_sram_lock, flags);
@@ -453,7 +557,8 @@ void *l1sram_alloc(size_t size)
453 /* add mutex operation */ 557 /* add mutex operation */
454 spin_lock_irqsave(&l1sram_lock, flags); 558 spin_lock_irqsave(&l1sram_lock, flags);
455 559
456 addr = _l1_sram_alloc(size, l1_ssram, ARRAY_SIZE(l1_ssram)); 560 addr = _sram_alloc(size, &free_l1_ssram_head,
561 &used_l1_ssram_head);
457 562
458 /* add mutex operation */ 563 /* add mutex operation */
459 spin_unlock_irqrestore(&l1sram_lock, flags); 564 spin_unlock_irqrestore(&l1sram_lock, flags);
@@ -470,7 +575,8 @@ void *l1sram_alloc_max(size_t *psize)
470 /* add mutex operation */ 575 /* add mutex operation */
471 spin_lock_irqsave(&l1sram_lock, flags); 576 spin_lock_irqsave(&l1sram_lock, flags);
472 577
473 addr = _l1_sram_alloc_max(l1_ssram, ARRAY_SIZE(l1_ssram), psize); 578 addr = _sram_alloc_max(&free_l1_ssram_head,
579 &used_l1_ssram_head, psize);
474 580
475 /* add mutex operation */ 581 /* add mutex operation */
476 spin_unlock_irqrestore(&l1sram_lock, flags); 582 spin_unlock_irqrestore(&l1sram_lock, flags);
@@ -487,7 +593,8 @@ int l1sram_free(const void *addr)
487 /* add mutex operation */ 593 /* add mutex operation */
488 spin_lock_irqsave(&l1sram_lock, flags); 594 spin_lock_irqsave(&l1sram_lock, flags);
489 595
490 ret = _l1_sram_free(addr, l1_ssram, ARRAY_SIZE(l1_ssram)); 596 ret = _sram_free(addr, &free_l1_ssram_head,
597 &used_l1_ssram_head);
491 598
492 /* add mutex operation */ 599 /* add mutex operation */
493 spin_unlock_irqrestore(&l1sram_lock, flags); 600 spin_unlock_irqrestore(&l1sram_lock, flags);
@@ -495,6 +602,64 @@ int l1sram_free(const void *addr)
495 return ret; 602 return ret;
496} 603}
497 604
605void *l2_sram_alloc(size_t size)
606{
607#ifdef L2_LENGTH
608 unsigned flags;
609 void *addr;
610
611 /* add mutex operation */
612 spin_lock_irqsave(&l2_sram_lock, flags);
613
614 addr = _sram_alloc(size, &free_l2_sram_head,
615 &used_l2_sram_head);
616
617 /* add mutex operation */
618 spin_unlock_irqrestore(&l2_sram_lock, flags);
619
620 pr_debug("Allocated address in l2_sram_alloc is 0x%lx+0x%lx\n",
621 (long unsigned int)addr, size);
622
623 return addr;
624#else
625 return NULL;
626#endif
627}
628EXPORT_SYMBOL(l2_sram_alloc);
629
630void *l2_sram_zalloc(size_t size)
631{
632 void *addr = l2_sram_alloc(size);
633
634 if (addr)
635 memset(addr, 0x00, size);
636
637 return addr;
638}
639EXPORT_SYMBOL(l2_sram_zalloc);
640
641int l2_sram_free(const void *addr)
642{
643#ifdef L2_LENGTH
644 unsigned flags;
645 int ret;
646
647 /* add mutex operation */
648 spin_lock_irqsave(&l2_sram_lock, flags);
649
650 ret = _sram_free(addr, &free_l2_sram_head,
651 &used_l2_sram_head);
652
653 /* add mutex operation */
654 spin_unlock_irqrestore(&l2_sram_lock, flags);
655
656 return ret;
657#else
658 return -1;
659#endif
660}
661EXPORT_SYMBOL(l2_sram_free);
662
498int sram_free_with_lsl(const void *addr) 663int sram_free_with_lsl(const void *addr)
499{ 664{
500 struct sram_list_struct *lsl, **tmp; 665 struct sram_list_struct *lsl, **tmp;
@@ -533,6 +698,9 @@ void *sram_alloc_with_lsl(size_t size, unsigned long flags)
533 if (addr == NULL && (flags & L1_DATA_B_SRAM)) 698 if (addr == NULL && (flags & L1_DATA_B_SRAM))
534 addr = l1_data_B_sram_alloc(size); 699 addr = l1_data_B_sram_alloc(size);
535 700
701 if (addr == NULL && (flags & L2_SRAM))
702 addr = l2_sram_alloc(size);
703
536 if (addr == NULL) { 704 if (addr == NULL) {
537 kfree(lsl); 705 kfree(lsl);
538 return NULL; 706 return NULL;
@@ -549,49 +717,80 @@ EXPORT_SYMBOL(sram_alloc_with_lsl);
549/* Once we get a real allocator, we'll throw all of this away. 717/* Once we get a real allocator, we'll throw all of this away.
550 * Until then, we need some sort of visibility into the L1 alloc. 718 * Until then, we need some sort of visibility into the L1 alloc.
551 */ 719 */
552static void _l1sram_proc_read(char *buf, int *len, const char *desc, 720/* Need to keep line of output the same. Currently, that is 44 bytes
553 struct l1_sram_piece *pfree, const int array_size) 721 * (including newline).
722 */
723static int _sram_proc_read(char *buf, int *len, int count, const char *desc,
724 struct sram_piece *pfree_head,
725 struct sram_piece *pused_head)
554{ 726{
555 int i; 727 struct sram_piece *pslot;
556 728
557 *len += sprintf(&buf[*len], "--- L1 %-14s Size PID State\n", desc); 729 if (!pfree_head || !pused_head)
558 for (i = 0; i < array_size; ++i) { 730 return -1;
559 const char *alloc_type; 731
560 switch (pfree[i].flag) { 732 *len += sprintf(&buf[*len], "--- SRAM %-14s Size PID State \n", desc);
561 case SRAM_SLT_NULL: alloc_type = "NULL"; break; 733
562 case SRAM_SLT_FREE: alloc_type = "FREE"; break; 734 /* search the relevant memory slot */
563 case SRAM_SLT_ALLOCATED: alloc_type = "ALLOCATED"; break; 735 pslot = pused_head->next;
564 default: alloc_type = "????"; break; 736
565 } 737 while (pslot != NULL) {
566 *len += sprintf(&buf[*len], "%p-%p %8i %4i %s\n", 738 *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n",
567 pfree[i].paddr, pfree[i].paddr + pfree[i].size, 739 pslot->paddr, pslot->paddr + pslot->size,
568 pfree[i].size, pfree[i].pid, alloc_type); 740 pslot->size, pslot->pid, "ALLOCATED");
741
742 pslot = pslot->next;
569 } 743 }
744
745 pslot = pfree_head->next;
746
747 while (pslot != NULL) {
748 *len += sprintf(&buf[*len], "%p-%p %10i %5i %-10s\n",
749 pslot->paddr, pslot->paddr + pslot->size,
750 pslot->size, pslot->pid, "FREE");
751
752 pslot = pslot->next;
753 }
754
755 return 0;
570} 756}
571static int l1sram_proc_read(char *buf, char **start, off_t offset, int count, 757static int sram_proc_read(char *buf, char **start, off_t offset, int count,
572 int *eof, void *data) 758 int *eof, void *data)
573{ 759{
574 int len = 0; 760 int len = 0;
575 761
576 _l1sram_proc_read(buf, &len, "Scratchpad", 762 if (_sram_proc_read(buf, &len, count, "Scratchpad",
577 l1_ssram, ARRAY_SIZE(l1_ssram)); 763 &free_l1_ssram_head, &used_l1_ssram_head))
764 goto not_done;
578#if L1_DATA_A_LENGTH != 0 765#if L1_DATA_A_LENGTH != 0
579 _l1sram_proc_read(buf, &len, "Data A", 766 if (_sram_proc_read(buf, &len, count, "L1 Data A",
580 l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram)); 767 &free_l1_data_A_sram_head,
768 &used_l1_data_A_sram_head))
769 goto not_done;
581#endif 770#endif
582#if L1_DATA_B_LENGTH != 0 771#if L1_DATA_B_LENGTH != 0
583 _l1sram_proc_read(buf, &len, "Data B", 772 if (_sram_proc_read(buf, &len, count, "L1 Data B",
584 l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram)); 773 &free_l1_data_B_sram_head,
774 &used_l1_data_B_sram_head))
775 goto not_done;
585#endif 776#endif
586#if L1_CODE_LENGTH != 0 777#if L1_CODE_LENGTH != 0
587 _l1sram_proc_read(buf, &len, "Instruction", 778 if (_sram_proc_read(buf, &len, count, "L1 Instruction",
588 l1_inst_sram, ARRAY_SIZE(l1_inst_sram)); 779 &free_l1_inst_sram_head, &used_l1_inst_sram_head))
780 goto not_done;
781#endif
782#ifdef L2_LENGTH
783 if (_sram_proc_read(buf, &len, count, "L2",
784 &free_l2_sram_head, &used_l2_sram_head))
785 goto not_done;
589#endif 786#endif
590 787
788 *eof = 1;
789 not_done:
591 return len; 790 return len;
592} 791}
593 792
594static int __init l1sram_proc_init(void) 793static int __init sram_proc_init(void)
595{ 794{
596 struct proc_dir_entry *ptr; 795 struct proc_dir_entry *ptr;
597 ptr = create_proc_entry("sram", S_IFREG | S_IRUGO, NULL); 796 ptr = create_proc_entry("sram", S_IFREG | S_IRUGO, NULL);
@@ -600,8 +799,8 @@ static int __init l1sram_proc_init(void)
600 return -1; 799 return -1;
601 } 800 }
602 ptr->owner = THIS_MODULE; 801 ptr->owner = THIS_MODULE;
603 ptr->read_proc = l1sram_proc_read; 802 ptr->read_proc = sram_proc_read;
604 return 0; 803 return 0;
605} 804}
606late_initcall(l1sram_proc_init); 805late_initcall(sram_proc_init);
607#endif 806#endif
diff --git a/arch/blackfin/mm/blackfin_sram.h b/arch/blackfin/mm/blackfin_sram.h
index 0fb73b78dd60..8cb0945563f9 100644
--- a/arch/blackfin/mm/blackfin_sram.h
+++ b/arch/blackfin/mm/blackfin_sram.h
@@ -30,9 +30,7 @@
30#ifndef __BLACKFIN_SRAM_H__ 30#ifndef __BLACKFIN_SRAM_H__
31#define __BLACKFIN_SRAM_H__ 31#define __BLACKFIN_SRAM_H__
32 32
33extern void l1sram_init(void); 33extern void bfin_sram_init(void);
34extern void l1_inst_sram_init(void);
35extern void l1_data_sram_init(void);
36extern void *l1sram_alloc(size_t); 34extern void *l1sram_alloc(size_t);
37 35
38#endif 36#endif
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index ec3141fefd20..bc240abb8745 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -53,33 +53,6 @@ static unsigned long empty_bad_page;
53 53
54unsigned long empty_zero_page; 54unsigned long empty_zero_page;
55 55
56void show_mem(void)
57{
58 unsigned long i;
59 int free = 0, total = 0, reserved = 0, shared = 0;
60
61 int cached = 0;
62 printk(KERN_INFO "Mem-info:\n");
63 show_free_areas();
64 i = max_mapnr;
65 while (i-- > 0) {
66 total++;
67 if (PageReserved(mem_map + i))
68 reserved++;
69 else if (PageSwapCache(mem_map + i))
70 cached++;
71 else if (!page_count(mem_map + i))
72 free++;
73 else
74 shared += page_count(mem_map + i) - 1;
75 }
76 printk(KERN_INFO "%d pages of RAM\n", total);
77 printk(KERN_INFO "%d free pages\n", free);
78 printk(KERN_INFO "%d reserved pages\n", reserved);
79 printk(KERN_INFO "%d pages shared\n", shared);
80 printk(KERN_INFO "%d pages swap cached\n", cached);
81}
82
83/* 56/*
84 * paging_init() continues the virtual memory environment setup which 57 * paging_init() continues the virtual memory environment setup which
85 * was begun by the code in arch/head.S. 58 * was begun by the code in arch/head.S.
@@ -164,11 +137,14 @@ void __init mem_init(void)
164 "(%uk init code, %uk kernel code, %uk data, %uk dma, %uk reserved)\n", 137 "(%uk init code, %uk kernel code, %uk data, %uk dma, %uk reserved)\n",
165 (unsigned long) freepages << (PAGE_SHIFT-10), _ramend >> 10, 138 (unsigned long) freepages << (PAGE_SHIFT-10), _ramend >> 10,
166 initk, codek, datak, DMA_UNCACHED_REGION >> 10, (reservedpages << (PAGE_SHIFT-10))); 139 initk, codek, datak, DMA_UNCACHED_REGION >> 10, (reservedpages << (PAGE_SHIFT-10)));
140}
141
142static int __init sram_init(void)
143{
144 unsigned long tmp;
167 145
168 /* Initialize the blackfin L1 Memory. */ 146 /* Initialize the blackfin L1 Memory. */
169 l1sram_init(); 147 bfin_sram_init();
170 l1_data_sram_init();
171 l1_inst_sram_init();
172 148
173 /* Allocate this once; never free it. We assume this gives us a 149 /* Allocate this once; never free it. We assume this gives us a
174 pointer to the start of L1 scratchpad memory; panic if it 150 pointer to the start of L1 scratchpad memory; panic if it
@@ -179,7 +155,10 @@ void __init mem_init(void)
179 tmp, (unsigned long)L1_SCRATCH_TASK_INFO); 155 tmp, (unsigned long)L1_SCRATCH_TASK_INFO);
180 panic("No L1, time to give up\n"); 156 panic("No L1, time to give up\n");
181 } 157 }
158
159 return 0;
182} 160}
161pure_initcall(sram_init);
183 162
184static void __init free_init_pages(const char *what, unsigned long begin, unsigned long end) 163static void __init free_init_pages(const char *what, unsigned long begin, unsigned long end)
185{ 164{
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index a3ca55150745..6fea45f2e40c 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -278,14 +278,6 @@ void putDebugChar (int val);
278 278
279void enableDebugIRQ (void); 279void enableDebugIRQ (void);
280 280
281/* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte,
282 represented by int x. */
283static char highhex (int x);
284
285/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
286 represented by int x. */
287static char lowhex (int x);
288
289/* Returns the integer equivalent of a hexadecimal character. */ 281/* Returns the integer equivalent of a hexadecimal character. */
290static int hex (char ch); 282static int hex (char ch);
291 283
@@ -356,9 +348,6 @@ extern unsigned char executing_task;
356/* Run-length encoding maximum length. Send 64 at most. */ 348/* Run-length encoding maximum length. Send 64 at most. */
357#define RUNLENMAX 64 349#define RUNLENMAX 64
358 350
359/* Definition of all valid hexadecimal characters */
360static const char hexchars[] = "0123456789abcdef";
361
362/* The inbound/outbound buffers used in packet I/O */ 351/* The inbound/outbound buffers used in packet I/O */
363static char remcomInBuffer[BUFMAX]; 352static char remcomInBuffer[BUFMAX];
364static char remcomOutBuffer[BUFMAX]; 353static char remcomOutBuffer[BUFMAX];
@@ -499,8 +488,8 @@ gdb_cris_strtol (const char *s, char **endptr, int base)
499 char *sd; 488 char *sd;
500 int x = 0; 489 int x = 0;
501 490
502 for (s1 = (char*)s; (sd = gdb_cris_memchr(hexchars, *s1, base)) != NULL; ++s1) 491 for (s1 = (char*)s; (sd = gdb_cris_memchr(hex_asc, *s1, base)) != NULL; ++s1)
503 x = x * base + (sd - hexchars); 492 x = x * base + (sd - hex_asc);
504 493
505 if (endptr) 494 if (endptr)
506 { 495 {
@@ -670,22 +659,6 @@ read_register (char regno, unsigned int *valptr)
670} 659}
671 660
672/********************************** Packet I/O ******************************/ 661/********************************** Packet I/O ******************************/
673/* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte,
674 represented by int x. */
675static inline char
676highhex(int x)
677{
678 return hexchars[(x >> 4) & 0xf];
679}
680
681/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
682 represented by int x. */
683static inline char
684lowhex(int x)
685{
686 return hexchars[x & 0xf];
687}
688
689/* Returns the integer equivalent of a hexadecimal character. */ 662/* Returns the integer equivalent of a hexadecimal character. */
690static int 663static int
691hex (char ch) 664hex (char ch)
@@ -721,8 +694,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
721 /* Valid mem address. */ 694 /* Valid mem address. */
722 for (i = 0; i < count; i++) { 695 for (i = 0; i < count; i++) {
723 ch = *mem++; 696 ch = *mem++;
724 *buf++ = highhex (ch); 697 buf = pack_hex_byte(buf, ch);
725 *buf++ = lowhex (ch);
726 } 698 }
727 } 699 }
728 700
@@ -857,9 +829,9 @@ putpacket(char *buffer)
857 src++; 829 src++;
858 } 830 }
859 } 831 }
860 putDebugChar ('#'); 832 putDebugChar('#');
861 putDebugChar (highhex (checksum)); 833 putDebugChar(hex_asc_hi(checksum));
862 putDebugChar (lowhex (checksum)); 834 putDebugChar(hex_asc_lo(checksum));
863 } while(kgdb_started && (getDebugChar() != '+')); 835 } while(kgdb_started && (getDebugChar() != '+'));
864} 836}
865 837
@@ -895,9 +867,8 @@ stub_is_stopped(int sigval)
895 867
896 /* Send trap type (converted to signal) */ 868 /* Send trap type (converted to signal) */
897 869
898 *ptr++ = 'T'; 870 *ptr++ = 'T';
899 *ptr++ = highhex (sigval); 871 ptr = pack_hex_byte(ptr, sigval);
900 *ptr++ = lowhex (sigval);
901 872
902 /* Send register contents. We probably only need to send the 873 /* Send register contents. We probably only need to send the
903 * PC, frame pointer and stack pointer here. Other registers will be 874 * PC, frame pointer and stack pointer here. Other registers will be
@@ -910,9 +881,7 @@ stub_is_stopped(int sigval)
910 status = read_register (regno, &reg_cont); 881 status = read_register (regno, &reg_cont);
911 882
912 if (status == SUCCESS) { 883 if (status == SUCCESS) {
913 884 ptr = pack_hex_byte(ptr, regno);
914 *ptr++ = highhex (regno);
915 *ptr++ = lowhex (regno);
916 *ptr++ = ':'; 885 *ptr++ = ':';
917 886
918 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, 887 ptr = mem2hex(ptr, (unsigned char *)&reg_cont,
@@ -937,8 +906,8 @@ stub_is_stopped(int sigval)
937 /* Store thread:r...; with the executing task TID. */ 906 /* Store thread:r...; with the executing task TID. */
938 gdb_cris_strcpy (&remcomOutBuffer[pos], "thread:"); 907 gdb_cris_strcpy (&remcomOutBuffer[pos], "thread:");
939 pos += gdb_cris_strlen ("thread:"); 908 pos += gdb_cris_strlen ("thread:");
940 remcomOutBuffer[pos++] = highhex (executing_task); 909 remcomOutBuffer[pos++] = hex_asc_hi(executing_task);
941 remcomOutBuffer[pos++] = lowhex (executing_task); 910 remcomOutBuffer[pos++] = hex_asc_lo(executing_task);
942 gdb_cris_strcpy (&remcomOutBuffer[pos], ";"); 911 gdb_cris_strcpy (&remcomOutBuffer[pos], ";");
943#endif 912#endif
944 913
@@ -1126,8 +1095,8 @@ handle_exception (int sigval)
1126 Success: SAA, where AA is the signal number. 1095 Success: SAA, where AA is the signal number.
1127 Failure: void. */ 1096 Failure: void. */
1128 remcomOutBuffer[0] = 'S'; 1097 remcomOutBuffer[0] = 'S';
1129 remcomOutBuffer[1] = highhex (sigval); 1098 remcomOutBuffer[1] = hex_asc_hi(sigval);
1130 remcomOutBuffer[2] = lowhex (sigval); 1099 remcomOutBuffer[2] = hex_asc_lo(sigval);
1131 remcomOutBuffer[3] = 0; 1100 remcomOutBuffer[3] = 0;
1132 break; 1101 break;
1133 1102
@@ -1224,23 +1193,23 @@ handle_exception (int sigval)
1224 case 'C': 1193 case 'C':
1225 /* Identify the remote current thread. */ 1194 /* Identify the remote current thread. */
1226 gdb_cris_strcpy (&remcomOutBuffer[0], "QC"); 1195 gdb_cris_strcpy (&remcomOutBuffer[0], "QC");
1227 remcomOutBuffer[2] = highhex (current_thread_c); 1196 remcomOutBuffer[2] = hex_asc_hi(current_thread_c);
1228 remcomOutBuffer[3] = lowhex (current_thread_c); 1197 remcomOutBuffer[3] = hex_asc_lo(current_thread_c);
1229 remcomOutBuffer[4] = '\0'; 1198 remcomOutBuffer[4] = '\0';
1230 break; 1199 break;
1231 case 'L': 1200 case 'L':
1232 gdb_cris_strcpy (&remcomOutBuffer[0], "QM"); 1201 gdb_cris_strcpy (&remcomOutBuffer[0], "QM");
1233 /* Reply with number of threads. */ 1202 /* Reply with number of threads. */
1234 if (os_is_started()) { 1203 if (os_is_started()) {
1235 remcomOutBuffer[2] = highhex (number_of_tasks); 1204 remcomOutBuffer[2] = hex_asc_hi(number_of_tasks);
1236 remcomOutBuffer[3] = lowhex (number_of_tasks); 1205 remcomOutBuffer[3] = hex_asc_lo(number_of_tasks);
1237 } 1206 }
1238 else { 1207 else {
1239 remcomOutBuffer[2] = highhex (0); 1208 remcomOutBuffer[2] = hex_asc_hi(0);
1240 remcomOutBuffer[3] = lowhex (1); 1209 remcomOutBuffer[3] = hex_asc_lo(1);
1241 } 1210 }
1242 /* Done with the reply. */ 1211 /* Done with the reply. */
1243 remcomOutBuffer[4] = lowhex (1); 1212 remcomOutBuffer[4] = hex_asc_lo(1);
1244 pos = 5; 1213 pos = 5;
1245 /* Expects the argument thread id. */ 1214 /* Expects the argument thread id. */
1246 for (; pos < (5 + HEXCHARS_IN_THREAD_ID); pos++) 1215 for (; pos < (5 + HEXCHARS_IN_THREAD_ID); pos++)
@@ -1251,16 +1220,16 @@ handle_exception (int sigval)
1251 for (thread_id = 0; thread_id < number_of_tasks; thread_id++) { 1220 for (thread_id = 0; thread_id < number_of_tasks; thread_id++) {
1252 nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; 1221 nextpos = pos + HEXCHARS_IN_THREAD_ID - 1;
1253 for (; pos < nextpos; pos ++) 1222 for (; pos < nextpos; pos ++)
1254 remcomOutBuffer[pos] = lowhex (0); 1223 remcomOutBuffer[pos] = hex_asc_lo(0);
1255 remcomOutBuffer[pos++] = lowhex (thread_id); 1224 remcomOutBuffer[pos++] = hex_asc_lo(thread_id);
1256 } 1225 }
1257 } 1226 }
1258 else { 1227 else {
1259 /* Store the thread identifier of the boot task. */ 1228 /* Store the thread identifier of the boot task. */
1260 nextpos = pos + HEXCHARS_IN_THREAD_ID - 1; 1229 nextpos = pos + HEXCHARS_IN_THREAD_ID - 1;
1261 for (; pos < nextpos; pos ++) 1230 for (; pos < nextpos; pos ++)
1262 remcomOutBuffer[pos] = lowhex (0); 1231 remcomOutBuffer[pos] = hex_asc_lo(0);
1263 remcomOutBuffer[pos++] = lowhex (current_thread_c); 1232 remcomOutBuffer[pos++] = hex_asc_lo(current_thread_c);
1264 } 1233 }
1265 remcomOutBuffer[pos] = '\0'; 1234 remcomOutBuffer[pos] = '\0';
1266 break; 1235 break;
diff --git a/arch/cris/arch-v32/drivers/Kconfig b/arch/cris/arch-v32/drivers/Kconfig
index 2a92cb1886ca..7a64fcef9d07 100644
--- a/arch/cris/arch-v32/drivers/Kconfig
+++ b/arch/cris/arch-v32/drivers/Kconfig
@@ -641,6 +641,7 @@ config PCI
641 bool 641 bool
642 depends on ETRAX_CARDBUS 642 depends on ETRAX_CARDBUS
643 default y 643 default y
644 select HAVE_GENERIC_DMA_COHERENT
644 645
645config ETRAX_IOP_FW_LOAD 646config ETRAX_IOP_FW_LOAD
646 tristate "IO-processor hotplug firmware loading support" 647 tristate "IO-processor hotplug firmware loading support"
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c
index e0364654fc44..fbe65954ee6c 100644
--- a/arch/cris/arch-v32/drivers/pci/dma.c
+++ b/arch/cris/arch-v32/drivers/pci/dma.c
@@ -15,35 +15,16 @@
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <asm/io.h> 16#include <asm/io.h>
17 17
18struct dma_coherent_mem {
19 void *virt_base;
20 u32 device_base;
21 int size;
22 int flags;
23 unsigned long *bitmap;
24};
25
26void *dma_alloc_coherent(struct device *dev, size_t size, 18void *dma_alloc_coherent(struct device *dev, size_t size,
27 dma_addr_t *dma_handle, gfp_t gfp) 19 dma_addr_t *dma_handle, gfp_t gfp)
28{ 20{
29 void *ret; 21 void *ret;
30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
31 int order = get_order(size); 22 int order = get_order(size);
32 /* ignore region specifiers */ 23 /* ignore region specifiers */
33 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); 24 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
34 25
35 if (mem) { 26 if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
36 int page = bitmap_find_free_region(mem->bitmap, mem->size, 27 return ret;
37 order);
38 if (page >= 0) {
39 *dma_handle = mem->device_base + (page << PAGE_SHIFT);
40 ret = mem->virt_base + (page << PAGE_SHIFT);
41 memset(ret, 0, size);
42 return ret;
43 }
44 if (mem->flags & DMA_MEMORY_EXCLUSIVE)
45 return NULL;
46 }
47 28
48 if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) 29 if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
49 gfp |= GFP_DMA; 30 gfp |= GFP_DMA;
@@ -60,90 +41,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
60void dma_free_coherent(struct device *dev, size_t size, 41void dma_free_coherent(struct device *dev, size_t size,
61 void *vaddr, dma_addr_t dma_handle) 42 void *vaddr, dma_addr_t dma_handle)
62{ 43{
63 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
64 int order = get_order(size); 44 int order = get_order(size);
65 45
66 if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) { 46 if (!dma_release_from_coherent(dev, order, vaddr))
67 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
68
69 bitmap_release_region(mem->bitmap, page, order);
70 } else
71 free_pages((unsigned long)vaddr, order); 47 free_pages((unsigned long)vaddr, order);
72} 48}
73 49
74int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
75 dma_addr_t device_addr, size_t size, int flags)
76{
77 void __iomem *mem_base;
78 int pages = size >> PAGE_SHIFT;
79 int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
80
81 if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
82 goto out;
83 if (!size)
84 goto out;
85 if (dev->dma_mem)
86 goto out;
87
88 /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
89
90 mem_base = ioremap(bus_addr, size);
91 if (!mem_base)
92 goto out;
93
94 dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
95 if (!dev->dma_mem)
96 goto iounmap_out;
97 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
98 if (!dev->dma_mem->bitmap)
99 goto free1_out;
100
101 dev->dma_mem->virt_base = mem_base;
102 dev->dma_mem->device_base = device_addr;
103 dev->dma_mem->size = pages;
104 dev->dma_mem->flags = flags;
105
106 if (flags & DMA_MEMORY_MAP)
107 return DMA_MEMORY_MAP;
108
109 return DMA_MEMORY_IO;
110
111 free1_out:
112 kfree(dev->dma_mem);
113 iounmap_out:
114 iounmap(mem_base);
115 out:
116 return 0;
117}
118EXPORT_SYMBOL(dma_declare_coherent_memory);
119
120void dma_release_declared_memory(struct device *dev)
121{
122 struct dma_coherent_mem *mem = dev->dma_mem;
123
124 if(!mem)
125 return;
126 dev->dma_mem = NULL;
127 iounmap(mem->virt_base);
128 kfree(mem->bitmap);
129 kfree(mem);
130}
131EXPORT_SYMBOL(dma_release_declared_memory);
132
133void *dma_mark_declared_memory_occupied(struct device *dev,
134 dma_addr_t device_addr, size_t size)
135{
136 struct dma_coherent_mem *mem = dev->dma_mem;
137 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
138 int pos, err;
139
140 if (!mem)
141 return ERR_PTR(-EINVAL);
142
143 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
144 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
145 if (err != 0)
146 return ERR_PTR(err);
147 return mem->virt_base + (pos << PAGE_SHIFT);
148}
149EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
diff --git a/arch/cris/arch-v32/kernel/kgdb.c b/arch/cris/arch-v32/kernel/kgdb.c
index 4e2e2e271efb..8bd5a5bc0dc7 100644
--- a/arch/cris/arch-v32/kernel/kgdb.c
+++ b/arch/cris/arch-v32/kernel/kgdb.c
@@ -398,14 +398,6 @@ void putDebugChar(int val)
398} 398}
399#endif 399#endif
400 400
401/* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte,
402 represented by int x. */
403static char highhex(int x);
404
405/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
406 represented by int x. */
407static char lowhex(int x);
408
409/* Returns the integer equivalent of a hexadecimal character. */ 401/* Returns the integer equivalent of a hexadecimal character. */
410static int hex(char ch); 402static int hex(char ch);
411 403
@@ -464,9 +456,6 @@ void breakpoint(void);
464/* Run-length encoding maximum length. Send 64 at most. */ 456/* Run-length encoding maximum length. Send 64 at most. */
465#define RUNLENMAX 64 457#define RUNLENMAX 64
466 458
467/* Definition of all valid hexadecimal characters */
468static const char hexchars[] = "0123456789abcdef";
469
470/* The inbound/outbound buffers used in packet I/O */ 459/* The inbound/outbound buffers used in packet I/O */
471static char input_buffer[BUFMAX]; 460static char input_buffer[BUFMAX];
472static char output_buffer[BUFMAX]; 461static char output_buffer[BUFMAX];
@@ -550,8 +539,8 @@ gdb_cris_strtol(const char *s, char **endptr, int base)
550 char *sd; 539 char *sd;
551 int x = 0; 540 int x = 0;
552 541
553 for (s1 = (char*)s; (sd = gdb_cris_memchr(hexchars, *s1, base)) != NULL; ++s1) 542 for (s1 = (char*)s; (sd = gdb_cris_memchr(hex_asc, *s1, base)) != NULL; ++s1)
554 x = x * base + (sd - hexchars); 543 x = x * base + (sd - hex_asc);
555 544
556 if (endptr) { 545 if (endptr) {
557 /* Unconverted suffix is stored in endptr unless endptr is NULL. */ 546 /* Unconverted suffix is stored in endptr unless endptr is NULL. */
@@ -655,22 +644,6 @@ read_register(char regno, unsigned int *valptr)
655} 644}
656 645
657/********************************** Packet I/O ******************************/ 646/********************************** Packet I/O ******************************/
658/* Returns the character equivalent of a nibble, bit 7, 6, 5, and 4 of a byte,
659 represented by int x. */
660static inline char
661highhex(int x)
662{
663 return hexchars[(x >> 4) & 0xf];
664}
665
666/* Returns the character equivalent of a nibble, bit 3, 2, 1, and 0 of a byte,
667 represented by int x. */
668static inline char
669lowhex(int x)
670{
671 return hexchars[x & 0xf];
672}
673
674/* Returns the integer equivalent of a hexadecimal character. */ 647/* Returns the integer equivalent of a hexadecimal character. */
675static int 648static int
676hex(char ch) 649hex(char ch)
@@ -704,8 +677,7 @@ mem2hex(char *buf, unsigned char *mem, int count)
704 /* Valid mem address. */ 677 /* Valid mem address. */
705 for (i = 0; i < count; i++) { 678 for (i = 0; i < count; i++) {
706 ch = *mem++; 679 ch = *mem++;
707 *buf++ = highhex (ch); 680 buf = pack_hex_byte(buf, ch);
708 *buf++ = lowhex (ch);
709 } 681 }
710 } 682 }
711 /* Terminate properly. */ 683 /* Terminate properly. */
@@ -723,8 +695,7 @@ mem2hex_nbo(char *buf, unsigned char *mem, int count)
723 mem += count - 1; 695 mem += count - 1;
724 for (i = 0; i < count; i++) { 696 for (i = 0; i < count; i++) {
725 ch = *mem--; 697 ch = *mem--;
726 *buf++ = highhex (ch); 698 buf = pack_hex_byte(buf, ch);
727 *buf++ = lowhex (ch);
728 } 699 }
729 700
730 /* Terminate properly. */ 701 /* Terminate properly. */
@@ -862,8 +833,8 @@ putpacket(char *buffer)
862 } 833 }
863 } 834 }
864 putDebugChar('#'); 835 putDebugChar('#');
865 putDebugChar(highhex (checksum)); 836 putDebugChar(hex_asc_hi(checksum));
866 putDebugChar(lowhex (checksum)); 837 putDebugChar(hex_asc_lo(checksum));
867 } while(kgdb_started && (getDebugChar() != '+')); 838 } while(kgdb_started && (getDebugChar() != '+'));
868} 839}
869 840
@@ -909,8 +880,7 @@ stub_is_stopped(int sigval)
909 /* Send trap type (converted to signal) */ 880 /* Send trap type (converted to signal) */
910 881
911 *ptr++ = 'T'; 882 *ptr++ = 'T';
912 *ptr++ = highhex(sigval); 883 ptr = pack_hex_byte(ptr, sigval);
913 *ptr++ = lowhex(sigval);
914 884
915 if (((reg.exs & 0xff00) >> 8) == 0xc) { 885 if (((reg.exs & 0xff00) >> 8) == 0xc) {
916 886
@@ -1018,30 +988,26 @@ stub_is_stopped(int sigval)
1018 } 988 }
1019 /* Only send PC, frame and stack pointer. */ 989 /* Only send PC, frame and stack pointer. */
1020 read_register(PC, &reg_cont); 990 read_register(PC, &reg_cont);
1021 *ptr++ = highhex(PC); 991 ptr = pack_hex_byte(PC);
1022 *ptr++ = lowhex(PC);
1023 *ptr++ = ':'; 992 *ptr++ = ':';
1024 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]); 993 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[PC]);
1025 *ptr++ = ';'; 994 *ptr++ = ';';
1026 995
1027 read_register(R8, &reg_cont); 996 read_register(R8, &reg_cont);
1028 *ptr++ = highhex(R8); 997 ptr = pack_hex_byte(R8);
1029 *ptr++ = lowhex(R8);
1030 *ptr++ = ':'; 998 *ptr++ = ':';
1031 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]); 999 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[R8]);
1032 *ptr++ = ';'; 1000 *ptr++ = ';';
1033 1001
1034 read_register(SP, &reg_cont); 1002 read_register(SP, &reg_cont);
1035 *ptr++ = highhex(SP); 1003 ptr = pack_hex_byte(SP);
1036 *ptr++ = lowhex(SP);
1037 *ptr++ = ':'; 1004 *ptr++ = ':';
1038 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]); 1005 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[SP]);
1039 *ptr++ = ';'; 1006 *ptr++ = ';';
1040 1007
1041 /* Send ERP as well; this will save us an entire register fetch in some cases. */ 1008 /* Send ERP as well; this will save us an entire register fetch in some cases. */
1042 read_register(ERP, &reg_cont); 1009 read_register(ERP, &reg_cont);
1043 *ptr++ = highhex(ERP); 1010 ptr = pack_hex_byte(ERP);
1044 *ptr++ = lowhex(ERP);
1045 *ptr++ = ':'; 1011 *ptr++ = ':';
1046 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]); 1012 ptr = mem2hex(ptr, (unsigned char *)&reg_cont, register_size[ERP]);
1047 *ptr++ = ';'; 1013 *ptr++ = ';';
@@ -1533,8 +1499,8 @@ handle_exception(int sigval)
1533 Success: SAA, where AA is the signal number. 1499 Success: SAA, where AA is the signal number.
1534 Failure: void. */ 1500 Failure: void. */
1535 output_buffer[0] = 'S'; 1501 output_buffer[0] = 'S';
1536 output_buffer[1] = highhex(sigval); 1502 output_buffer[1] = hex_asc_hi(sigval);
1537 output_buffer[2] = lowhex(sigval); 1503 output_buffer[2] = hex_asc_lo(sigval);
1538 output_buffer[3] = 0; 1504 output_buffer[3] = 0;
1539 break; 1505 break;
1540 1506
diff --git a/arch/cris/mm/init.c b/arch/cris/mm/init.c
index 5b06ffa15e34..2fdd212eb250 100644
--- a/arch/cris/mm/init.c
+++ b/arch/cris/mm/init.c
@@ -19,36 +19,6 @@ unsigned long empty_zero_page;
19extern char _stext, _edata, _etext; /* From linkerscript */ 19extern char _stext, _edata, _etext; /* From linkerscript */
20extern char __init_begin, __init_end; 20extern char __init_begin, __init_end;
21 21
22void
23show_mem(void)
24{
25 int i,free = 0,total = 0,cached = 0, reserved = 0, nonshared = 0;
26 int shared = 0;
27
28 printk("\nMem-info:\n");
29 show_free_areas();
30 i = max_mapnr;
31 while (i-- > 0) {
32 total++;
33 if (PageReserved(mem_map+i))
34 reserved++;
35 else if (PageSwapCache(mem_map+i))
36 cached++;
37 else if (!page_count(mem_map+i))
38 free++;
39 else if (page_count(mem_map+i) == 1)
40 nonshared++;
41 else
42 shared += page_count(mem_map+i) - 1;
43 }
44 printk("%d pages of RAM\n",total);
45 printk("%d free pages\n",free);
46 printk("%d reserved pages\n",reserved);
47 printk("%d pages nonshared\n",nonshared);
48 printk("%d pages shared\n",shared);
49 printk("%d pages swap cached\n",cached);
50}
51
52void __init 22void __init
53mem_init(void) 23mem_init(void)
54{ 24{
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 48a0393e7cee..7ca8a6b19ac9 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -182,8 +182,6 @@ extern volatile u32 __attribute__((section(".bss"))) gdbstub_trace_through_excep
182static char input_buffer[BUFMAX]; 182static char input_buffer[BUFMAX];
183static char output_buffer[BUFMAX]; 183static char output_buffer[BUFMAX];
184 184
185static const char hexchars[] = "0123456789abcdef";
186
187static const char *regnames[] = { 185static const char *regnames[] = {
188 "PSR ", "ISR ", "CCR ", "CCCR", 186 "PSR ", "ISR ", "CCR ", "CCCR",
189 "LR ", "LCR ", "PC ", "_stt", 187 "LR ", "LCR ", "PC ", "_stt",
@@ -383,8 +381,8 @@ static int gdbstub_send_packet(char *buffer)
383 } 381 }
384 382
385 gdbstub_tx_char('#'); 383 gdbstub_tx_char('#');
386 gdbstub_tx_char(hexchars[checksum >> 4]); 384 gdbstub_tx_char(hex_asc_hi(checksum));
387 gdbstub_tx_char(hexchars[checksum & 0xf]); 385 gdbstub_tx_char(hex_asc_lo(checksum));
388 386
389 } while (gdbstub_rx_char(&ch,0), 387 } while (gdbstub_rx_char(&ch,0),
390#ifdef GDBSTUB_DEBUG_PROTOCOL 388#ifdef GDBSTUB_DEBUG_PROTOCOL
@@ -674,8 +672,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
674 if ((uint32_t)mem&1 && count>=1) { 672 if ((uint32_t)mem&1 && count>=1) {
675 if (!gdbstub_read_byte(mem,ch)) 673 if (!gdbstub_read_byte(mem,ch))
676 return NULL; 674 return NULL;
677 *buf++ = hexchars[ch[0] >> 4]; 675 buf = pack_hex_byte(buf, ch[0]);
678 *buf++ = hexchars[ch[0] & 0xf];
679 mem++; 676 mem++;
680 count--; 677 count--;
681 } 678 }
@@ -683,10 +680,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
683 if ((uint32_t)mem&3 && count>=2) { 680 if ((uint32_t)mem&3 && count>=2) {
684 if (!gdbstub_read_word(mem,(uint16_t *)ch)) 681 if (!gdbstub_read_word(mem,(uint16_t *)ch))
685 return NULL; 682 return NULL;
686 *buf++ = hexchars[ch[0] >> 4]; 683 buf = pack_hex_byte(buf, ch[0]);
687 *buf++ = hexchars[ch[0] & 0xf]; 684 buf = pack_hex_byte(buf, ch[1]);
688 *buf++ = hexchars[ch[1] >> 4];
689 *buf++ = hexchars[ch[1] & 0xf];
690 mem += 2; 685 mem += 2;
691 count -= 2; 686 count -= 2;
692 } 687 }
@@ -694,14 +689,10 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
694 while (count>=4) { 689 while (count>=4) {
695 if (!gdbstub_read_dword(mem,(uint32_t *)ch)) 690 if (!gdbstub_read_dword(mem,(uint32_t *)ch))
696 return NULL; 691 return NULL;
697 *buf++ = hexchars[ch[0] >> 4]; 692 buf = pack_hex_byte(buf, ch[0]);
698 *buf++ = hexchars[ch[0] & 0xf]; 693 buf = pack_hex_byte(buf, ch[1]);
699 *buf++ = hexchars[ch[1] >> 4]; 694 buf = pack_hex_byte(buf, ch[2]);
700 *buf++ = hexchars[ch[1] & 0xf]; 695 buf = pack_hex_byte(buf, ch[3]);
701 *buf++ = hexchars[ch[2] >> 4];
702 *buf++ = hexchars[ch[2] & 0xf];
703 *buf++ = hexchars[ch[3] >> 4];
704 *buf++ = hexchars[ch[3] & 0xf];
705 mem += 4; 696 mem += 4;
706 count -= 4; 697 count -= 4;
707 } 698 }
@@ -709,10 +700,8 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
709 if (count>=2) { 700 if (count>=2) {
710 if (!gdbstub_read_word(mem,(uint16_t *)ch)) 701 if (!gdbstub_read_word(mem,(uint16_t *)ch))
711 return NULL; 702 return NULL;
712 *buf++ = hexchars[ch[0] >> 4]; 703 buf = pack_hex_byte(buf, ch[0]);
713 *buf++ = hexchars[ch[0] & 0xf]; 704 buf = pack_hex_byte(buf, ch[1]);
714 *buf++ = hexchars[ch[1] >> 4];
715 *buf++ = hexchars[ch[1] & 0xf];
716 mem += 2; 705 mem += 2;
717 count -= 2; 706 count -= 2;
718 } 707 }
@@ -720,8 +709,7 @@ static unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fa
720 if (count>=1) { 709 if (count>=1) {
721 if (!gdbstub_read_byte(mem,ch)) 710 if (!gdbstub_read_byte(mem,ch))
722 return NULL; 711 return NULL;
723 *buf++ = hexchars[ch[0] >> 4]; 712 buf = pack_hex_byte(buf, ch[0]);
724 *buf++ = hexchars[ch[0] & 0xf];
725 } 713 }
726 714
727 *buf = 0; 715 *buf = 0;
@@ -1471,22 +1459,22 @@ void gdbstub(int sigval)
1471 *ptr++ = 'O'; 1459 *ptr++ = 'O';
1472 ptr = mem2hex(title, ptr, sizeof(title) - 1,0); 1460 ptr = mem2hex(title, ptr, sizeof(title) - 1,0);
1473 1461
1474 hx = hexchars[(brr & 0xf0000000) >> 28]; 1462 hx = hex_asc_hi(brr >> 24);
1475 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1463 ptr = pack_hex_byte(ptr, hx);
1476 hx = hexchars[(brr & 0x0f000000) >> 24]; 1464 hx = hex_asc_lo(brr >> 24);
1477 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1465 ptr = pack_hex_byte(ptr, hx);
1478 hx = hexchars[(brr & 0x00f00000) >> 20]; 1466 hx = hex_asc_hi(brr >> 16);
1479 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1467 ptr = pack_hex_byte(ptr, hx);
1480 hx = hexchars[(brr & 0x000f0000) >> 16]; 1468 hx = hex_asc_lo(brr >> 16);
1481 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1469 ptr = pack_hex_byte(ptr, hx);
1482 hx = hexchars[(brr & 0x0000f000) >> 12]; 1470 hx = hex_asc_hi(brr >> 8);
1483 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1471 ptr = pack_hex_byte(ptr, hx);
1484 hx = hexchars[(brr & 0x00000f00) >> 8]; 1472 hx = hex_asc_lo(brr >> 8);
1485 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1473 ptr = pack_hex_byte(ptr, hx);
1486 hx = hexchars[(brr & 0x000000f0) >> 4]; 1474 hx = hex_asc_hi(brr);
1487 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1475 ptr = pack_hex_byte(ptr, hx);
1488 hx = hexchars[(brr & 0x0000000f)]; 1476 hx = hex_asc_lo(brr);
1489 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1477 ptr = pack_hex_byte(ptr, hx);
1490 1478
1491 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1479 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1492 *ptr = 0; 1480 *ptr = 0;
@@ -1500,12 +1488,10 @@ void gdbstub(int sigval)
1500 1488
1501 /* Send trap type (converted to signal) */ 1489 /* Send trap type (converted to signal) */
1502 *ptr++ = 'T'; 1490 *ptr++ = 'T';
1503 *ptr++ = hexchars[sigval >> 4]; 1491 ptr = pack_hex_byte(ptr, sigval);
1504 *ptr++ = hexchars[sigval & 0xf];
1505 1492
1506 /* Send Error PC */ 1493 /* Send Error PC */
1507 *ptr++ = hexchars[GDB_REG_PC >> 4]; 1494 ptr = pack_hex_byte(ptr, GDB_REG_PC);
1508 *ptr++ = hexchars[GDB_REG_PC & 0xf];
1509 *ptr++ = ':'; 1495 *ptr++ = ':';
1510 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0); 1496 ptr = mem2hex(&__debug_frame->pc, ptr, 4, 0);
1511 *ptr++ = ';'; 1497 *ptr++ = ';';
@@ -1513,8 +1499,7 @@ void gdbstub(int sigval)
1513 /* 1499 /*
1514 * Send frame pointer 1500 * Send frame pointer
1515 */ 1501 */
1516 *ptr++ = hexchars[GDB_REG_FP >> 4]; 1502 ptr = pack_hex_byte(ptr, GDB_REG_FP);
1517 *ptr++ = hexchars[GDB_REG_FP & 0xf];
1518 *ptr++ = ':'; 1503 *ptr++ = ':';
1519 ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0); 1504 ptr = mem2hex(&__debug_frame->fp, ptr, 4, 0);
1520 *ptr++ = ';'; 1505 *ptr++ = ';';
@@ -1522,8 +1507,7 @@ void gdbstub(int sigval)
1522 /* 1507 /*
1523 * Send stack pointer 1508 * Send stack pointer
1524 */ 1509 */
1525 *ptr++ = hexchars[GDB_REG_SP >> 4]; 1510 ptr = pack_hex_byte(ptr, GDB_REG_SP);
1526 *ptr++ = hexchars[GDB_REG_SP & 0xf];
1527 *ptr++ = ':'; 1511 *ptr++ = ':';
1528 ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0); 1512 ptr = mem2hex(&__debug_frame->sp, ptr, 4, 0);
1529 *ptr++ = ';'; 1513 *ptr++ = ';';
@@ -1548,8 +1532,8 @@ void gdbstub(int sigval)
1548 /* request repeat of last signal number */ 1532 /* request repeat of last signal number */
1549 case '?': 1533 case '?':
1550 output_buffer[0] = 'S'; 1534 output_buffer[0] = 'S';
1551 output_buffer[1] = hexchars[sigval >> 4]; 1535 output_buffer[1] = hex_asc_hi(sigval);
1552 output_buffer[2] = hexchars[sigval & 0xf]; 1536 output_buffer[2] = hex_asc_lo(sigval);
1553 output_buffer[3] = 0; 1537 output_buffer[3] = 0;
1554 break; 1538 break;
1555 1539
@@ -2059,8 +2043,8 @@ void gdbstub_exit(int status)
2059 } 2043 }
2060 2044
2061 gdbstub_tx_char('#'); 2045 gdbstub_tx_char('#');
2062 gdbstub_tx_char(hexchars[checksum >> 4]); 2046 gdbstub_tx_char(hex_asc_hi(checksum));
2063 gdbstub_tx_char(hexchars[checksum & 0xf]); 2047 gdbstub_tx_char(hex_asc_lo(checksum));
2064 2048
2065 /* make sure the output is flushed, or else RedBoot might clobber it */ 2049 /* make sure the output is flushed, or else RedBoot might clobber it */
2066 gdbstub_tx_char('-'); 2050 gdbstub_tx_char('-');
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 9af7740f32fb..1b851db34186 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -63,37 +63,6 @@ EXPORT_SYMBOL(empty_zero_page);
63 63
64/*****************************************************************************/ 64/*****************************************************************************/
65/* 65/*
66 *
67 */
68void show_mem(void)
69{
70 unsigned long i;
71 int free = 0, total = 0, reserved = 0, shared = 0;
72
73 printk("\nMem-info:\n");
74 show_free_areas();
75 i = max_mapnr;
76 while (i-- > 0) {
77 struct page *page = &mem_map[i];
78
79 total++;
80 if (PageReserved(page))
81 reserved++;
82 else if (!page_count(page))
83 free++;
84 else
85 shared += page_count(page) - 1;
86 }
87
88 printk("%d pages of RAM\n",total);
89 printk("%d free pages\n",free);
90 printk("%d reserved pages\n",reserved);
91 printk("%d pages shared\n",shared);
92
93} /* end show_mem() */
94
95/*****************************************************************************/
96/*
97 * paging_init() continues the virtual memory environment setup which 66 * paging_init() continues the virtual memory environment setup which
98 * was begun by the code in arch/head.S. 67 * was begun by the code in arch/head.S.
99 * The parameters are pointers to where to stick the starting and ending 68 * The parameters are pointers to where to stick the starting and ending
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index e4f4199f97ab..a1d228f5e4e6 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -64,33 +64,6 @@ unsigned long empty_zero_page;
64 64
65extern unsigned long rom_length; 65extern unsigned long rom_length;
66 66
67void show_mem(void)
68{
69 unsigned long i;
70 int free = 0, total = 0, reserved = 0, shared = 0;
71 int cached = 0;
72
73 printk("\nMem-info:\n");
74 show_free_areas();
75 i = max_mapnr;
76 while (i-- > 0) {
77 total++;
78 if (PageReserved(mem_map+i))
79 reserved++;
80 else if (PageSwapCache(mem_map+i))
81 cached++;
82 else if (!page_count(mem_map+i))
83 free++;
84 else
85 shared += page_count(mem_map+i) - 1;
86 }
87 printk("%d pages of RAM\n",total);
88 printk("%d free pages\n",free);
89 printk("%d reserved pages\n",reserved);
90 printk("%d pages shared\n",shared);
91 printk("%d pages swap cached\n",cached);
92}
93
94extern unsigned long memory_start; 67extern unsigned long memory_start;
95extern unsigned long memory_end; 68extern unsigned long memory_end;
96 69
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 1c44ec2a1d58..88b6e6f3fd88 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -186,9 +186,10 @@ hwsw_dma_supported (struct device *dev, u64 mask)
186} 186}
187 187
188int 188int
189hwsw_dma_mapping_error (dma_addr_t dma_addr) 189hwsw_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
190{ 190{
191 return hwiommu_dma_mapping_error (dma_addr) || swiotlb_dma_mapping_error(dma_addr); 191 return hwiommu_dma_mapping_error(dev, dma_addr) ||
192 swiotlb_dma_mapping_error(dev, dma_addr);
192} 193}
193 194
194EXPORT_SYMBOL(hwsw_dma_mapping_error); 195EXPORT_SYMBOL(hwsw_dma_mapping_error);
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 34421aed1e2a..4956be40d7b5 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2147,7 +2147,7 @@ sba_dma_supported (struct device *dev, u64 mask)
2147} 2147}
2148 2148
2149int 2149int
2150sba_dma_mapping_error (dma_addr_t dma_addr) 2150sba_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
2151{ 2151{
2152 return 0; 2152 return 0;
2153} 2153}
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 19d4493c6193..fc8f3509df27 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2626,7 +2626,7 @@ pfm_task_incompatible(pfm_context_t *ctx, struct task_struct *task)
2626 /* 2626 /*
2627 * make sure the task is off any CPU 2627 * make sure the task is off any CPU
2628 */ 2628 */
2629 wait_task_inactive(task); 2629 wait_task_inactive(task, 0);
2630 2630
2631 /* more to come... */ 2631 /* more to come... */
2632 2632
@@ -4774,7 +4774,7 @@ recheck:
4774 4774
4775 UNPROTECT_CTX(ctx, flags); 4775 UNPROTECT_CTX(ctx, flags);
4776 4776
4777 wait_task_inactive(task); 4777 wait_task_inactive(task, 0);
4778 4778
4779 PROTECT_CTX(ctx, flags); 4779 PROTECT_CTX(ctx, flags);
4780 4780
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 2672f4d278ac..7a37d06376be 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -125,9 +125,9 @@ void kvm_arch_hardware_enable(void *garbage)
125 PAGE_KERNEL)); 125 PAGE_KERNEL));
126 local_irq_save(saved_psr); 126 local_irq_save(saved_psr);
127 slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT); 127 slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
128 local_irq_restore(saved_psr);
128 if (slot < 0) 129 if (slot < 0)
129 return; 130 return;
130 local_irq_restore(saved_psr);
131 131
132 spin_lock(&vp_lock); 132 spin_lock(&vp_lock);
133 status = ia64_pal_vp_init_env(kvm_vsa_base ? 133 status = ia64_pal_vp_init_env(kvm_vsa_base ?
@@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
160 160
161 local_irq_save(saved_psr); 161 local_irq_save(saved_psr);
162 slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT); 162 slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
163 local_irq_restore(saved_psr);
163 if (slot < 0) 164 if (slot < 0)
164 return; 165 return;
165 local_irq_restore(saved_psr);
166 166
167 status = ia64_pal_vp_exit_env(host_iva); 167 status = ia64_pal_vp_exit_env(host_iva);
168 if (status) 168 if (status)
@@ -1253,6 +1253,7 @@ static int vti_vcpu_setup(struct kvm_vcpu *vcpu, int id)
1253uninit: 1253uninit:
1254 kvm_vcpu_uninit(vcpu); 1254 kvm_vcpu_uninit(vcpu);
1255fail: 1255fail:
1256 local_irq_restore(psr);
1256 return r; 1257 return r;
1257} 1258}
1258 1259
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 52175af299a0..53ebb6484495 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -350,7 +350,7 @@ void sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
350} 350}
351EXPORT_SYMBOL(sn_dma_sync_sg_for_device); 351EXPORT_SYMBOL(sn_dma_sync_sg_for_device);
352 352
353int sn_dma_mapping_error(dma_addr_t dma_addr) 353int sn_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
354{ 354{
355 return 0; 355 return 0;
356} 356}
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index 2554eb59cfef..24d429f9358a 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -36,42 +36,6 @@ pgd_t swapper_pg_dir[1024];
36 36
37DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 37DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
38 38
39void show_mem(void)
40{
41 int total = 0, reserved = 0;
42 int shared = 0, cached = 0;
43 int highmem = 0;
44 struct page *page;
45 pg_data_t *pgdat;
46 unsigned long i;
47
48 printk("Mem-info:\n");
49 show_free_areas();
50 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
51 for_each_online_pgdat(pgdat) {
52 unsigned long flags;
53 pgdat_resize_lock(pgdat, &flags);
54 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
55 page = pgdat_page_nr(pgdat, i);
56 total++;
57 if (PageHighMem(page))
58 highmem++;
59 if (PageReserved(page))
60 reserved++;
61 else if (PageSwapCache(page))
62 cached++;
63 else if (page_count(page))
64 shared += page_count(page) - 1;
65 }
66 pgdat_resize_unlock(pgdat, &flags);
67 }
68 printk("%d pages of RAM\n", total);
69 printk("%d pages of HIGHMEM\n",highmem);
70 printk("%d reserved pages\n",reserved);
71 printk("%d pages shared\n",shared);
72 printk("%d pages swap cached\n",cached);
73}
74
75/* 39/*
76 * Cache of MMU context last used. 40 * Cache of MMU context last used.
77 */ 41 */
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 79f5f94d4800..81bb08ceec18 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -69,36 +69,6 @@ void __init m68k_setup_node(int node)
69void *empty_zero_page; 69void *empty_zero_page;
70EXPORT_SYMBOL(empty_zero_page); 70EXPORT_SYMBOL(empty_zero_page);
71 71
72void show_mem(void)
73{
74 pg_data_t *pgdat;
75 int free = 0, total = 0, reserved = 0, shared = 0;
76 int cached = 0;
77 int i;
78
79 printk("\nMem-info:\n");
80 show_free_areas();
81 for_each_online_pgdat(pgdat) {
82 for (i = 0; i < pgdat->node_spanned_pages; i++) {
83 struct page *page = pgdat->node_mem_map + i;
84 total++;
85 if (PageReserved(page))
86 reserved++;
87 else if (PageSwapCache(page))
88 cached++;
89 else if (!page_count(page))
90 free++;
91 else
92 shared += page_count(page) - 1;
93 }
94 }
95 printk("%d pages of RAM\n",total);
96 printk("%d free pages\n",free);
97 printk("%d reserved pages\n",reserved);
98 printk("%d pages shared\n",shared);
99 printk("%d pages swap cached\n",cached);
100}
101
102extern void init_pointer_table(unsigned long ptable); 72extern void init_pointer_table(unsigned long ptable);
103 73
104/* References to section boundaries */ 74/* References to section boundaries */
diff --git a/arch/m68knommu/mm/init.c b/arch/m68knommu/mm/init.c
index 22e2a0d02b81..3bf249c53e41 100644
--- a/arch/m68knommu/mm/init.c
+++ b/arch/m68knommu/mm/init.c
@@ -62,33 +62,6 @@ static unsigned long empty_bad_page;
62 62
63unsigned long empty_zero_page; 63unsigned long empty_zero_page;
64 64
65void show_mem(void)
66{
67 unsigned long i;
68 int free = 0, total = 0, reserved = 0, shared = 0;
69 int cached = 0;
70
71 printk(KERN_INFO "\nMem-info:\n");
72 show_free_areas();
73 i = max_mapnr;
74 while (i-- > 0) {
75 total++;
76 if (PageReserved(mem_map+i))
77 reserved++;
78 else if (PageSwapCache(mem_map+i))
79 cached++;
80 else if (!page_count(mem_map+i))
81 free++;
82 else
83 shared += page_count(mem_map+i) - 1;
84 }
85 printk(KERN_INFO "%d pages of RAM\n",total);
86 printk(KERN_INFO "%d free pages\n",free);
87 printk(KERN_INFO "%d reserved pages\n",reserved);
88 printk(KERN_INFO "%d pages shared\n",shared);
89 printk(KERN_INFO "%d pages swap cached\n",cached);
90}
91
92extern unsigned long memory_start; 65extern unsigned long memory_start;
93extern unsigned long memory_end; 66extern unsigned long memory_end;
94 67
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 48731020ca0e..44e8dd8106bf 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -3,8 +3,7 @@
3# 3#
4 4
5obj-y += cache.o dma-default.o extable.o fault.o \ 5obj-y += cache.o dma-default.o extable.o fault.o \
6 init.o pgtable.o tlbex.o tlbex-fault.o \ 6 init.o tlbex.o tlbex-fault.o uasm.o page.o
7 uasm.o page.o
8 7
9obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o 8obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
10obj-$(CONFIG_64BIT) += pgtable-64.o 9obj-$(CONFIG_64BIT) += pgtable-64.o
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index ae39dd88b9aa..891312f8e5a6 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -348,7 +348,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
348 348
349EXPORT_SYMBOL(dma_sync_sg_for_device); 349EXPORT_SYMBOL(dma_sync_sg_for_device);
350 350
351int dma_mapping_error(dma_addr_t dma_addr) 351int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
352{ 352{
353 return 0; 353 return 0;
354} 354}
diff --git a/arch/mips/mm/pgtable.c b/arch/mips/mm/pgtable.c
deleted file mode 100644
index 7dfa579ab24c..000000000000
--- a/arch/mips/mm/pgtable.c
+++ /dev/null
@@ -1,36 +0,0 @@
1#include <linux/kernel.h>
2#include <linux/mm.h>
3#include <linux/swap.h>
4
5void show_mem(void)
6{
7#ifndef CONFIG_NEED_MULTIPLE_NODES /* XXX(hch): later.. */
8 int pfn, total = 0, reserved = 0;
9 int shared = 0, cached = 0;
10 int highmem = 0;
11 struct page *page;
12
13 printk("Mem-info:\n");
14 show_free_areas();
15 pfn = max_mapnr;
16 while (pfn-- > 0) {
17 if (!pfn_valid(pfn))
18 continue;
19 page = pfn_to_page(pfn);
20 total++;
21 if (PageHighMem(page))
22 highmem++;
23 if (PageReserved(page))
24 reserved++;
25 else if (PageSwapCache(page))
26 cached++;
27 else if (page_count(page))
28 shared += page_count(page) - 1;
29 }
30 printk("%d pages of RAM\n", total);
31 printk("%d pages of HIGHMEM\n", highmem);
32 printk("%d reserved pages\n", reserved);
33 printk("%d pages shared\n", shared);
34 printk("%d pages swap cached\n", cached);
35#endif
36}
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index 21891c71d549..54be6afb5555 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -163,8 +163,6 @@ static char input_buffer[BUFMAX];
163static char output_buffer[BUFMAX]; 163static char output_buffer[BUFMAX];
164static char trans_buffer[BUFMAX]; 164static char trans_buffer[BUFMAX];
165 165
166static const char hexchars[] = "0123456789abcdef";
167
168struct gdbstub_bkpt { 166struct gdbstub_bkpt {
169 u8 *addr; /* address of breakpoint */ 167 u8 *addr; /* address of breakpoint */
170 u8 len; /* size of breakpoint */ 168 u8 len; /* size of breakpoint */
@@ -363,8 +361,8 @@ static int putpacket(char *buffer)
363 } 361 }
364 362
365 gdbstub_io_tx_char('#'); 363 gdbstub_io_tx_char('#');
366 gdbstub_io_tx_char(hexchars[checksum >> 4]); 364 gdbstub_io_tx_char(hex_asc_hi(checksum));
367 gdbstub_io_tx_char(hexchars[checksum & 0xf]); 365 gdbstub_io_tx_char(hex_asc_lo(checksum));
368 366
369 } while (gdbstub_io_rx_char(&ch, 0), 367 } while (gdbstub_io_rx_char(&ch, 0),
370 ch == '-' && (gdbstub_io("### GDB Rx NAK\n"), 0), 368 ch == '-' && (gdbstub_io("### GDB Rx NAK\n"), 0),
@@ -822,8 +820,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
822 if ((u32) mem & 1 && count >= 1) { 820 if ((u32) mem & 1 && count >= 1) {
823 if (gdbstub_read_byte(mem, ch) != 0) 821 if (gdbstub_read_byte(mem, ch) != 0)
824 return 0; 822 return 0;
825 *buf++ = hexchars[ch[0] >> 4]; 823 buf = pack_hex_byte(buf, ch[0]);
826 *buf++ = hexchars[ch[0] & 0xf];
827 mem++; 824 mem++;
828 count--; 825 count--;
829 } 826 }
@@ -831,10 +828,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
831 if ((u32) mem & 3 && count >= 2) { 828 if ((u32) mem & 3 && count >= 2) {
832 if (gdbstub_read_word(mem, ch) != 0) 829 if (gdbstub_read_word(mem, ch) != 0)
833 return 0; 830 return 0;
834 *buf++ = hexchars[ch[0] >> 4]; 831 buf = pack_hex_byte(buf, ch[0]);
835 *buf++ = hexchars[ch[0] & 0xf]; 832 buf = pack_hex_byte(buf, ch[1]);
836 *buf++ = hexchars[ch[1] >> 4];
837 *buf++ = hexchars[ch[1] & 0xf];
838 mem += 2; 833 mem += 2;
839 count -= 2; 834 count -= 2;
840 } 835 }
@@ -842,14 +837,10 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
842 while (count >= 4) { 837 while (count >= 4) {
843 if (gdbstub_read_dword(mem, ch) != 0) 838 if (gdbstub_read_dword(mem, ch) != 0)
844 return 0; 839 return 0;
845 *buf++ = hexchars[ch[0] >> 4]; 840 buf = pack_hex_byte(buf, ch[0]);
846 *buf++ = hexchars[ch[0] & 0xf]; 841 buf = pack_hex_byte(buf, ch[1]);
847 *buf++ = hexchars[ch[1] >> 4]; 842 buf = pack_hex_byte(buf, ch[2]);
848 *buf++ = hexchars[ch[1] & 0xf]; 843 buf = pack_hex_byte(buf, ch[3]);
849 *buf++ = hexchars[ch[2] >> 4];
850 *buf++ = hexchars[ch[2] & 0xf];
851 *buf++ = hexchars[ch[3] >> 4];
852 *buf++ = hexchars[ch[3] & 0xf];
853 mem += 4; 844 mem += 4;
854 count -= 4; 845 count -= 4;
855 } 846 }
@@ -857,10 +848,8 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
857 if (count >= 2) { 848 if (count >= 2) {
858 if (gdbstub_read_word(mem, ch) != 0) 849 if (gdbstub_read_word(mem, ch) != 0)
859 return 0; 850 return 0;
860 *buf++ = hexchars[ch[0] >> 4]; 851 buf = pack_hex_byte(buf, ch[0]);
861 *buf++ = hexchars[ch[0] & 0xf]; 852 buf = pack_hex_byte(buf, ch[1]);
862 *buf++ = hexchars[ch[1] >> 4];
863 *buf++ = hexchars[ch[1] & 0xf];
864 mem += 2; 853 mem += 2;
865 count -= 2; 854 count -= 2;
866 } 855 }
@@ -868,8 +857,7 @@ unsigned char *mem2hex(const void *_mem, char *buf, int count, int may_fault)
868 if (count >= 1) { 857 if (count >= 1) {
869 if (gdbstub_read_byte(mem, ch) != 0) 858 if (gdbstub_read_byte(mem, ch) != 0)
870 return 0; 859 return 0;
871 *buf++ = hexchars[ch[0] >> 4]; 860 buf = pack_hex_byte(buf, ch[0]);
872 *buf++ = hexchars[ch[0] & 0xf];
873 } 861 }
874 862
875 *buf = 0; 863 *buf = 0;
@@ -1304,14 +1292,14 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1304 *ptr++ = 'O'; 1292 *ptr++ = 'O';
1305 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0); 1293 ptr = mem2hex(title, ptr, sizeof(title) - 1, 0);
1306 1294
1307 hx = hexchars[(excep & 0xf000) >> 12]; 1295 hx = hex_asc_hi(excep >> 8);
1308 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1296 ptr = pack_hex_byte(ptr, hx);
1309 hx = hexchars[(excep & 0x0f00) >> 8]; 1297 hx = hex_asc_lo(excep >> 8);
1310 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1298 ptr = pack_hex_byte(ptr, hx);
1311 hx = hexchars[(excep & 0x00f0) >> 4]; 1299 hx = hex_asc_hi(excep);
1312 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1300 ptr = pack_hex_byte(ptr, hx);
1313 hx = hexchars[(excep & 0x000f)]; 1301 hx = hex_asc_lo(excep);
1314 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1302 ptr = pack_hex_byte(ptr, hx);
1315 1303
1316 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1304 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1317 *ptr = 0; 1305 *ptr = 0;
@@ -1322,22 +1310,22 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1322 *ptr++ = 'O'; 1310 *ptr++ = 'O';
1323 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0); 1311 ptr = mem2hex(tbcberr, ptr, sizeof(tbcberr) - 1, 0);
1324 1312
1325 hx = hexchars[(bcberr & 0xf0000000) >> 28]; 1313 hx = hex_asc_hi(bcberr >> 24);
1326 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1314 ptr = pack_hex_byte(ptr, hx);
1327 hx = hexchars[(bcberr & 0x0f000000) >> 24]; 1315 hx = hex_asc_lo(bcberr >> 24);
1328 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1316 ptr = pack_hex_byte(ptr, hx);
1329 hx = hexchars[(bcberr & 0x00f00000) >> 20]; 1317 hx = hex_asc_hi(bcberr >> 16);
1330 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1318 ptr = pack_hex_byte(ptr, hx);
1331 hx = hexchars[(bcberr & 0x000f0000) >> 16]; 1319 hx = hex_asc_lo(bcberr >> 16);
1332 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1320 ptr = pack_hex_byte(ptr, hx);
1333 hx = hexchars[(bcberr & 0x0000f000) >> 12]; 1321 hx = hex_asc_hi(bcberr >> 8);
1334 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1322 ptr = pack_hex_byte(ptr, hx);
1335 hx = hexchars[(bcberr & 0x00000f00) >> 8]; 1323 hx = hex_asc_lo(bcberr >> 8);
1336 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1324 ptr = pack_hex_byte(ptr, hx);
1337 hx = hexchars[(bcberr & 0x000000f0) >> 4]; 1325 hx = hex_asc_hi(bcberr);
1338 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1326 ptr = pack_hex_byte(ptr, hx);
1339 hx = hexchars[(bcberr & 0x0000000f)]; 1327 hx = hex_asc_lo(bcberr);
1340 *ptr++ = hexchars[hx >> 4]; *ptr++ = hexchars[hx & 0xf]; 1328 ptr = pack_hex_byte(ptr, hx);
1341 1329
1342 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0); 1330 ptr = mem2hex(crlf, ptr, sizeof(crlf) - 1, 0);
1343 *ptr = 0; 1331 *ptr = 0;
@@ -1353,14 +1341,12 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1353 * Send trap type (converted to signal) 1341 * Send trap type (converted to signal)
1354 */ 1342 */
1355 *ptr++ = 'T'; 1343 *ptr++ = 'T';
1356 *ptr++ = hexchars[sigval >> 4]; 1344 ptr = pack_hex_byte(ptr, sigval);
1357 *ptr++ = hexchars[sigval & 0xf];
1358 1345
1359 /* 1346 /*
1360 * Send Error PC 1347 * Send Error PC
1361 */ 1348 */
1362 *ptr++ = hexchars[GDB_REGID_PC >> 4]; 1349 ptr = pack_hex_byte(ptr, GDB_REGID_PC);
1363 *ptr++ = hexchars[GDB_REGID_PC & 0xf];
1364 *ptr++ = ':'; 1350 *ptr++ = ':';
1365 ptr = mem2hex(&regs->pc, ptr, 4, 0); 1351 ptr = mem2hex(&regs->pc, ptr, 4, 0);
1366 *ptr++ = ';'; 1352 *ptr++ = ';';
@@ -1368,8 +1354,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1368 /* 1354 /*
1369 * Send frame pointer 1355 * Send frame pointer
1370 */ 1356 */
1371 *ptr++ = hexchars[GDB_REGID_FP >> 4]; 1357 ptr = pack_hex_byte(ptr, GDB_REGID_FP);
1372 *ptr++ = hexchars[GDB_REGID_FP & 0xf];
1373 *ptr++ = ':'; 1358 *ptr++ = ':';
1374 ptr = mem2hex(&regs->a3, ptr, 4, 0); 1359 ptr = mem2hex(&regs->a3, ptr, 4, 0);
1375 *ptr++ = ';'; 1360 *ptr++ = ';';
@@ -1378,8 +1363,7 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1378 * Send stack pointer 1363 * Send stack pointer
1379 */ 1364 */
1380 ssp = (unsigned long) (regs + 1); 1365 ssp = (unsigned long) (regs + 1);
1381 *ptr++ = hexchars[GDB_REGID_SP >> 4]; 1366 ptr = pack_hex_byte(ptr, GDB_REGID_SP);
1382 *ptr++ = hexchars[GDB_REGID_SP & 0xf];
1383 *ptr++ = ':'; 1367 *ptr++ = ':';
1384 ptr = mem2hex(&ssp, ptr, 4, 0); 1368 ptr = mem2hex(&ssp, ptr, 4, 0);
1385 *ptr++ = ';'; 1369 *ptr++ = ';';
@@ -1399,8 +1383,8 @@ packet_waiting:
1399 /* request repeat of last signal number */ 1383 /* request repeat of last signal number */
1400 case '?': 1384 case '?':
1401 output_buffer[0] = 'S'; 1385 output_buffer[0] = 'S';
1402 output_buffer[1] = hexchars[sigval >> 4]; 1386 output_buffer[1] = hex_asc_hi(sigval);
1403 output_buffer[2] = hexchars[sigval & 0xf]; 1387 output_buffer[2] = hex_asc_lo(sigval);
1404 output_buffer[3] = 0; 1388 output_buffer[3] = 0;
1405 break; 1389 break;
1406 1390
@@ -1838,8 +1822,8 @@ void gdbstub_exit(int status)
1838 1822
1839 gdbstub_busy = 1; 1823 gdbstub_busy = 1;
1840 output_buffer[0] = 'W'; 1824 output_buffer[0] = 'W';
1841 output_buffer[1] = hexchars[(status >> 4) & 0x0F]; 1825 output_buffer[1] = hex_asc_hi(status);
1842 output_buffer[2] = hexchars[status & 0x0F]; 1826 output_buffer[2] = hex_asc_lo(status);
1843 output_buffer[3] = 0; 1827 output_buffer[3] = 0;
1844 1828
1845 gdbstub_io_tx_char('$'); 1829 gdbstub_io_tx_char('$');
@@ -1853,8 +1837,8 @@ void gdbstub_exit(int status)
1853 } 1837 }
1854 1838
1855 gdbstub_io_tx_char('#'); 1839 gdbstub_io_tx_char('#');
1856 gdbstub_io_tx_char(hexchars[checksum >> 4]); 1840 gdbstub_io_tx_char(hex_asc_hi(checksum));
1857 gdbstub_io_tx_char(hexchars[checksum & 0xf]); 1841 gdbstub_io_tx_char(hex_asc_lo(checksum));
1858 1842
1859 /* make sure the output is flushed, or else RedBoot might clobber it */ 1843 /* make sure the output is flushed, or else RedBoot might clobber it */
1860 gdbstub_io_tx_flush(); 1844 gdbstub_io_tx_flush();
diff --git a/arch/mn10300/mm/pgtable.c b/arch/mn10300/mm/pgtable.c
index a477038752ba..baffc581e031 100644
--- a/arch/mn10300/mm/pgtable.c
+++ b/arch/mn10300/mm/pgtable.c
@@ -27,33 +27,6 @@
27#include <asm/tlb.h> 27#include <asm/tlb.h>
28#include <asm/tlbflush.h> 28#include <asm/tlbflush.h>
29 29
30void show_mem(void)
31{
32 unsigned long i;
33 int free = 0, total = 0, reserved = 0, shared = 0;
34
35 int cached = 0;
36 printk(KERN_INFO "Mem-info:\n");
37 show_free_areas();
38 i = max_mapnr;
39 while (i-- > 0) {
40 total++;
41 if (PageReserved(mem_map + i))
42 reserved++;
43 else if (PageSwapCache(mem_map + i))
44 cached++;
45 else if (!page_count(mem_map + i))
46 free++;
47 else
48 shared += page_count(mem_map + i) - 1;
49 }
50 printk(KERN_INFO "%d pages of RAM\n", total);
51 printk(KERN_INFO "%d free pages\n", free);
52 printk(KERN_INFO "%d reserved pages\n", reserved);
53 printk(KERN_INFO "%d pages shared\n", shared);
54 printk(KERN_INFO "%d pages swap cached\n", cached);
55}
56
57/* 30/*
58 * Associate a large virtual page frame with a given physical page frame 31 * Associate a large virtual page frame with a given physical page frame
59 * and protection flags for that frame. pfn is for the base of the page, 32 * and protection flags for that frame. pfn is for the base of the page,
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index be255ebb609c..18072e03a019 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -210,19 +210,19 @@ static int vfs_statfs_hpux(struct dentry *dentry, struct hpux_statfs *buf)
210} 210}
211 211
212/* hpux statfs */ 212/* hpux statfs */
213asmlinkage long hpux_statfs(const char __user *path, 213asmlinkage long hpux_statfs(const char __user *pathname,
214 struct hpux_statfs __user *buf) 214 struct hpux_statfs __user *buf)
215{ 215{
216 struct nameidata nd; 216 struct path path;
217 int error; 217 int error;
218 218
219 error = user_path_walk(path, &nd); 219 error = user_path(pathname, &path);
220 if (!error) { 220 if (!error) {
221 struct hpux_statfs tmp; 221 struct hpux_statfs tmp;
222 error = vfs_statfs_hpux(nd.path.dentry, &tmp); 222 error = vfs_statfs_hpux(path.dentry, &tmp);
223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224 error = -EFAULT; 224 error = -EFAULT;
225 path_put(&nd.path); 225 path_put(&path);
226 } 226 }
227 return error; 227 return error;
228} 228}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index fe88418167c5..587da5e0990f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -117,6 +117,7 @@ config PPC
117 select HAVE_KPROBES 117 select HAVE_KPROBES
118 select HAVE_ARCH_KGDB 118 select HAVE_ARCH_KGDB
119 select HAVE_KRETPROBES 119 select HAVE_KRETPROBES
120 select HAVE_ARCH_TRACEHOOK
120 select HAVE_LMB 121 select HAVE_LMB
121 select HAVE_DMA_ATTRS if PPC64 122 select HAVE_DMA_ATTRS if PPC64
122 select USE_GENERIC_SMP_HELPERS if SMP 123 select USE_GENERIC_SMP_HELPERS if SMP
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 81c8324a4a3c..1cbbf7033641 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -148,7 +148,7 @@ transfer_to_handler:
148 /* Check to see if the dbcr0 register is set up to debug. Use the 148 /* Check to see if the dbcr0 register is set up to debug. Use the
149 internal debug mode bit to do this. */ 149 internal debug mode bit to do this. */
150 lwz r12,THREAD_DBCR0(r12) 150 lwz r12,THREAD_DBCR0(r12)
151 andis. r12,r12,(DBCR0_IDM | DBSR_DAC1R | DBSR_DAC1W)@h 151 andis. r12,r12,DBCR0_IDM@h
152 beq+ 3f 152 beq+ 3f
153 /* From user and task is ptraced - load up global dbcr0 */ 153 /* From user and task is ptraced - load up global dbcr0 */
154 li r12,-1 /* clear all pending debug events */ 154 li r12,-1 /* clear all pending debug events */
@@ -292,7 +292,7 @@ syscall_exit_cont:
292 /* If the process has its own DBCR0 value, load it up. The internal 292 /* If the process has its own DBCR0 value, load it up. The internal
293 debug mode bit tells us that dbcr0 should be loaded. */ 293 debug mode bit tells us that dbcr0 should be loaded. */
294 lwz r0,THREAD+THREAD_DBCR0(r2) 294 lwz r0,THREAD+THREAD_DBCR0(r2)
295 andis. r10,r0,(DBCR0_IDM | DBSR_DAC1R | DBSR_DAC1W)@h 295 andis. r10,r0,DBCR0_IDM@h
296 bnel- load_dbcr0 296 bnel- load_dbcr0
297#endif 297#endif
298#ifdef CONFIG_44x 298#ifdef CONFIG_44x
@@ -343,7 +343,12 @@ syscall_dotrace:
343 stw r0,_TRAP(r1) 343 stw r0,_TRAP(r1)
344 addi r3,r1,STACK_FRAME_OVERHEAD 344 addi r3,r1,STACK_FRAME_OVERHEAD
345 bl do_syscall_trace_enter 345 bl do_syscall_trace_enter
346 lwz r0,GPR0(r1) /* Restore original registers */ 346 /*
347 * Restore argument registers possibly just changed.
348 * We use the return value of do_syscall_trace_enter
349 * for call number to look up in the table (r0).
350 */
351 mr r0,r3
347 lwz r3,GPR3(r1) 352 lwz r3,GPR3(r1)
348 lwz r4,GPR4(r1) 353 lwz r4,GPR4(r1)
349 lwz r5,GPR5(r1) 354 lwz r5,GPR5(r1)
@@ -720,7 +725,7 @@ restore_user:
720 /* Check whether this process has its own DBCR0 value. The internal 725 /* Check whether this process has its own DBCR0 value. The internal
721 debug mode bit tells us that dbcr0 should be loaded. */ 726 debug mode bit tells us that dbcr0 should be loaded. */
722 lwz r0,THREAD+THREAD_DBCR0(r2) 727 lwz r0,THREAD+THREAD_DBCR0(r2)
723 andis. r10,r0,(DBCR0_IDM | DBSR_DAC1R | DBSR_DAC1W)@h 728 andis. r10,r0,DBCR0_IDM@h
724 bnel- load_dbcr0 729 bnel- load_dbcr0
725#endif 730#endif
726 731
@@ -1055,8 +1060,8 @@ do_user_signal: /* r10 contains MSR_KERNEL here */
1055 SAVE_NVGPRS(r1) 1060 SAVE_NVGPRS(r1)
1056 rlwinm r3,r3,0,0,30 1061 rlwinm r3,r3,0,0,30
1057 stw r3,_TRAP(r1) 1062 stw r3,_TRAP(r1)
10582: li r3,0 10632: addi r3,r1,STACK_FRAME_OVERHEAD
1059 addi r4,r1,STACK_FRAME_OVERHEAD 1064 mr r4,r9
1060 bl do_signal 1065 bl do_signal
1061 REST_NVGPRS(r1) 1066 REST_NVGPRS(r1)
1062 b recheck 1067 b recheck
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index d7369243ae44..2d802e97097c 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -214,7 +214,12 @@ syscall_dotrace:
214 bl .save_nvgprs 214 bl .save_nvgprs
215 addi r3,r1,STACK_FRAME_OVERHEAD 215 addi r3,r1,STACK_FRAME_OVERHEAD
216 bl .do_syscall_trace_enter 216 bl .do_syscall_trace_enter
217 ld r0,GPR0(r1) /* Restore original registers */ 217 /*
218 * Restore argument registers possibly just changed.
219 * We use the return value of do_syscall_trace_enter
220 * for the call number to look up in the table (r0).
221 */
222 mr r0,r3
218 ld r3,GPR3(r1) 223 ld r3,GPR3(r1)
219 ld r4,GPR4(r1) 224 ld r4,GPR4(r1)
220 ld r5,GPR5(r1) 225 ld r5,GPR5(r1)
@@ -638,8 +643,7 @@ user_work:
638 b .ret_from_except_lite 643 b .ret_from_except_lite
639 644
6401: bl .save_nvgprs 6451: bl .save_nvgprs
641 li r3,0 646 addi r3,r1,STACK_FRAME_OVERHEAD
642 addi r4,r1,STACK_FRAME_OVERHEAD
643 bl .do_signal 647 bl .do_signal
644 b .ret_from_except 648 b .ret_from_except
645 649
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 4d96e1db55ee..9ddfaef1a184 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -493,18 +493,18 @@ static int __init serial_dev_init(void)
493device_initcall(serial_dev_init); 493device_initcall(serial_dev_init);
494 494
495 495
496#ifdef CONFIG_SERIAL_8250_CONSOLE
496/* 497/*
497 * This is called very early, as part of console_init() (typically just after 498 * This is called very early, as part of console_init() (typically just after
498 * time_init()). This function is respondible for trying to find a good 499 * time_init()). This function is respondible for trying to find a good
499 * default console on serial ports. It tries to match the open firmware 500 * default console on serial ports. It tries to match the open firmware
500 * default output with one of the available serial console drivers, either 501 * default output with one of the available serial console drivers that have
501 * one of the platform serial ports that have been probed earlier by 502 * been probed earlier by find_legacy_serial_ports()
502 * find_legacy_serial_ports() or some more platform specific ones.
503 */ 503 */
504static int __init check_legacy_serial_console(void) 504static int __init check_legacy_serial_console(void)
505{ 505{
506 struct device_node *prom_stdout = NULL; 506 struct device_node *prom_stdout = NULL;
507 int speed = 0, offset = 0; 507 int i, speed = 0, offset = 0;
508 const char *name; 508 const char *name;
509 const u32 *spd; 509 const u32 *spd;
510 510
@@ -548,31 +548,20 @@ static int __init check_legacy_serial_console(void)
548 if (spd) 548 if (spd)
549 speed = *spd; 549 speed = *spd;
550 550
551 if (0) 551 if (strcmp(name, "serial") != 0)
552 ; 552 goto not_found;
553#ifdef CONFIG_SERIAL_8250_CONSOLE 553
554 else if (strcmp(name, "serial") == 0) { 554 /* Look for it in probed array */
555 int i; 555 for (i = 0; i < legacy_serial_count; i++) {
556 /* Look for it in probed array */ 556 if (prom_stdout != legacy_serial_infos[i].np)
557 for (i = 0; i < legacy_serial_count; i++) { 557 continue;
558 if (prom_stdout != legacy_serial_infos[i].np) 558 offset = i;
559 continue; 559 speed = legacy_serial_infos[i].speed;
560 offset = i; 560 break;
561 speed = legacy_serial_infos[i].speed;
562 break;
563 }
564 if (i >= legacy_serial_count)
565 goto not_found;
566 } 561 }
567#endif /* CONFIG_SERIAL_8250_CONSOLE */ 562 if (i >= legacy_serial_count)
568#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
569 else if (strcmp(name, "ch-a") == 0)
570 offset = 0;
571 else if (strcmp(name, "ch-b") == 0)
572 offset = 1;
573#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
574 else
575 goto not_found; 563 goto not_found;
564
576 of_node_put(prom_stdout); 565 of_node_put(prom_stdout);
577 566
578 DBG("Found serial console at ttyS%d\n", offset); 567 DBG("Found serial console at ttyS%d\n", offset);
@@ -591,3 +580,4 @@ static int __init check_legacy_serial_console(void)
591} 580}
592console_initcall(check_legacy_serial_console); 581console_initcall(check_legacy_serial_console);
593 582
583#endif /* CONFIG_SERIAL_8250_CONSOLE */
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 29a0e039d436..aab76887a842 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -48,7 +48,7 @@ void machine_kexec_cleanup(struct kimage *image)
48 * Do not allocate memory (or fail in any way) in machine_kexec(). 48 * Do not allocate memory (or fail in any way) in machine_kexec().
49 * We are past the point of no return, committed to rebooting now. 49 * We are past the point of no return, committed to rebooting now.
50 */ 50 */
51NORET_TYPE void machine_kexec(struct kimage *image) 51void machine_kexec(struct kimage *image)
52{ 52{
53 if (ppc_md.machine_kexec) 53 if (ppc_md.machine_kexec)
54 ppc_md.machine_kexec(image); 54 ppc_md.machine_kexec(image);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index db2497ccc111..e030f3bd5024 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -254,7 +254,7 @@ void do_dabr(struct pt_regs *regs, unsigned long address,
254 return; 254 return;
255 255
256 /* Clear the DAC and struct entries. One shot trigger */ 256 /* Clear the DAC and struct entries. One shot trigger */
257#if (defined(CONFIG_44x) || defined(CONFIG_BOOKE)) 257#if defined(CONFIG_BOOKE)
258 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~(DBSR_DAC1R | DBSR_DAC1W 258 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~(DBSR_DAC1R | DBSR_DAC1W
259 | DBCR0_IDM)); 259 | DBCR0_IDM));
260#endif 260#endif
@@ -286,7 +286,7 @@ int set_dabr(unsigned long dabr)
286 mtspr(SPRN_DABR, dabr); 286 mtspr(SPRN_DABR, dabr);
287#endif 287#endif
288 288
289#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 289#if defined(CONFIG_BOOKE)
290 mtspr(SPRN_DAC1, dabr); 290 mtspr(SPRN_DAC1, dabr);
291#endif 291#endif
292 292
@@ -373,7 +373,7 @@ struct task_struct *__switch_to(struct task_struct *prev,
373 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) 373 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr))
374 set_dabr(new->thread.dabr); 374 set_dabr(new->thread.dabr);
375 375
376#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 376#if defined(CONFIG_BOOKE)
377 /* If new thread DAC (HW breakpoint) is the same then leave it */ 377 /* If new thread DAC (HW breakpoint) is the same then leave it */
378 if (new->thread.dabr) 378 if (new->thread.dabr)
379 set_dabr(new->thread.dabr); 379 set_dabr(new->thread.dabr);
@@ -568,7 +568,7 @@ void flush_thread(void)
568 current->thread.dabr = 0; 568 current->thread.dabr = 0;
569 set_dabr(0); 569 set_dabr(0);
570 570
571#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 571#if defined(CONFIG_BOOKE)
572 current->thread.dbcr0 &= ~(DBSR_DAC1R | DBSR_DAC1W); 572 current->thread.dbcr0 &= ~(DBSR_DAC1R | DBSR_DAC1W);
573#endif 573#endif
574 } 574 }
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index c4ab2195b9cb..b72849ac7db3 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -205,8 +205,6 @@ static int __initdata mem_reserve_cnt;
205static cell_t __initdata regbuf[1024]; 205static cell_t __initdata regbuf[1024];
206 206
207 207
208#define MAX_CPU_THREADS 2
209
210/* 208/*
211 * Error results ... some OF calls will return "-1" on error, some 209 * Error results ... some OF calls will return "-1" on error, some
212 * will return 0, some will return either. To simplify, here are 210 * will return 0, some will return either. To simplify, here are
@@ -1339,10 +1337,6 @@ static void __init prom_hold_cpus(void)
1339 unsigned int reg; 1337 unsigned int reg;
1340 phandle node; 1338 phandle node;
1341 char type[64]; 1339 char type[64];
1342 int cpuid = 0;
1343 unsigned int interrupt_server[MAX_CPU_THREADS];
1344 unsigned int cpu_threads, hw_cpu_num;
1345 int propsize;
1346 struct prom_t *_prom = &RELOC(prom); 1340 struct prom_t *_prom = &RELOC(prom);
1347 unsigned long *spinloop 1341 unsigned long *spinloop
1348 = (void *) LOW_ADDR(__secondary_hold_spinloop); 1342 = (void *) LOW_ADDR(__secondary_hold_spinloop);
@@ -1386,7 +1380,6 @@ static void __init prom_hold_cpus(void)
1386 reg = -1; 1380 reg = -1;
1387 prom_getprop(node, "reg", &reg, sizeof(reg)); 1381 prom_getprop(node, "reg", &reg, sizeof(reg));
1388 1382
1389 prom_debug("\ncpuid = 0x%x\n", cpuid);
1390 prom_debug("cpu hw idx = 0x%x\n", reg); 1383 prom_debug("cpu hw idx = 0x%x\n", reg);
1391 1384
1392 /* Init the acknowledge var which will be reset by 1385 /* Init the acknowledge var which will be reset by
@@ -1395,28 +1388,9 @@ static void __init prom_hold_cpus(void)
1395 */ 1388 */
1396 *acknowledge = (unsigned long)-1; 1389 *acknowledge = (unsigned long)-1;
1397 1390
1398 propsize = prom_getprop(node, "ibm,ppc-interrupt-server#s", 1391 if (reg != _prom->cpu) {
1399 &interrupt_server,
1400 sizeof(interrupt_server));
1401 if (propsize < 0) {
1402 /* no property. old hardware has no SMT */
1403 cpu_threads = 1;
1404 interrupt_server[0] = reg; /* fake it with phys id */
1405 } else {
1406 /* We have a threaded processor */
1407 cpu_threads = propsize / sizeof(u32);
1408 if (cpu_threads > MAX_CPU_THREADS) {
1409 prom_printf("SMT: too many threads!\n"
1410 "SMT: found %x, max is %x\n",
1411 cpu_threads, MAX_CPU_THREADS);
1412 cpu_threads = 1; /* ToDo: panic? */
1413 }
1414 }
1415
1416 hw_cpu_num = interrupt_server[0];
1417 if (hw_cpu_num != _prom->cpu) {
1418 /* Primary Thread of non-boot cpu */ 1392 /* Primary Thread of non-boot cpu */
1419 prom_printf("%x : starting cpu hw idx %x... ", cpuid, reg); 1393 prom_printf("starting cpu hw idx %x... ", reg);
1420 call_prom("start-cpu", 3, 0, node, 1394 call_prom("start-cpu", 3, 0, node,
1421 secondary_hold, reg); 1395 secondary_hold, reg);
1422 1396
@@ -1431,17 +1405,10 @@ static void __init prom_hold_cpus(void)
1431 } 1405 }
1432#ifdef CONFIG_SMP 1406#ifdef CONFIG_SMP
1433 else 1407 else
1434 prom_printf("%x : boot cpu %x\n", cpuid, reg); 1408 prom_printf("boot cpu hw idx %x\n", reg);
1435#endif /* CONFIG_SMP */ 1409#endif /* CONFIG_SMP */
1436
1437 /* Reserve cpu #s for secondary threads. They start later. */
1438 cpuid += cpu_threads;
1439 } 1410 }
1440 1411
1441 if (cpuid > NR_CPUS)
1442 prom_printf("WARNING: maximum CPUs (" __stringify(NR_CPUS)
1443 ") exceeded: ignoring extras\n");
1444
1445 prom_debug("prom_hold_cpus: end...\n"); 1412 prom_debug("prom_hold_cpus: end...\n");
1446} 1413}
1447 1414
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index a5d0e78779c8..6b66cd85b433 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -22,6 +22,7 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/ptrace.h> 23#include <linux/ptrace.h>
24#include <linux/regset.h> 24#include <linux/regset.h>
25#include <linux/tracehook.h>
25#include <linux/elf.h> 26#include <linux/elf.h>
26#include <linux/user.h> 27#include <linux/user.h>
27#include <linux/security.h> 28#include <linux/security.h>
@@ -717,7 +718,7 @@ void user_disable_single_step(struct task_struct *task)
717 struct pt_regs *regs = task->thread.regs; 718 struct pt_regs *regs = task->thread.regs;
718 719
719 720
720#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 721#if defined(CONFIG_BOOKE)
721 /* If DAC then do not single step, skip */ 722 /* If DAC then do not single step, skip */
722 if (task->thread.dabr) 723 if (task->thread.dabr)
723 return; 724 return;
@@ -744,10 +745,11 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
744 if (addr > 0) 745 if (addr > 0)
745 return -EINVAL; 746 return -EINVAL;
746 747
748 /* The bottom 3 bits in dabr are flags */
747 if ((data & ~0x7UL) >= TASK_SIZE) 749 if ((data & ~0x7UL) >= TASK_SIZE)
748 return -EIO; 750 return -EIO;
749 751
750#ifdef CONFIG_PPC64 752#ifndef CONFIG_BOOKE
751 753
752 /* For processors using DABR (i.e. 970), the bottom 3 bits are flags. 754 /* For processors using DABR (i.e. 970), the bottom 3 bits are flags.
753 * It was assumed, on previous implementations, that 3 bits were 755 * It was assumed, on previous implementations, that 3 bits were
@@ -769,7 +771,7 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
769 task->thread.dabr = data; 771 task->thread.dabr = data;
770 772
771#endif 773#endif
772#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 774#if defined(CONFIG_BOOKE)
773 775
774 /* As described above, it was assumed 3 bits were passed with the data 776 /* As described above, it was assumed 3 bits were passed with the data
775 * address, but we will assume only the mode bits will be passed 777 * address, but we will assume only the mode bits will be passed
@@ -1013,31 +1015,24 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1013 return ret; 1015 return ret;
1014} 1016}
1015 1017
1016static void do_syscall_trace(void) 1018/*
1019 * We must return the syscall number to actually look up in the table.
1020 * This can be -1L to skip running any syscall at all.
1021 */
1022long do_syscall_trace_enter(struct pt_regs *regs)
1017{ 1023{
1018 /* the 0x80 provides a way for the tracing parent to distinguish 1024 long ret = 0;
1019 between a syscall stop and SIGTRAP delivery */
1020 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1021 ? 0x80 : 0));
1022
1023 /*
1024 * this isn't the same as continuing with a signal, but it will do
1025 * for normal use. strace only continues with a signal if the
1026 * stopping signal is not SIGTRAP. -brl
1027 */
1028 if (current->exit_code) {
1029 send_sig(current->exit_code, current, 1);
1030 current->exit_code = 0;
1031 }
1032}
1033 1025
1034void do_syscall_trace_enter(struct pt_regs *regs)
1035{
1036 secure_computing(regs->gpr[0]); 1026 secure_computing(regs->gpr[0]);
1037 1027
1038 if (test_thread_flag(TIF_SYSCALL_TRACE) 1028 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
1039 && (current->ptrace & PT_PTRACED)) 1029 tracehook_report_syscall_entry(regs))
1040 do_syscall_trace(); 1030 /*
1031 * Tracing decided this syscall should not happen.
1032 * We'll return a bogus call number to get an ENOSYS
1033 * error, but leave the original number in regs->gpr[0].
1034 */
1035 ret = -1L;
1041 1036
1042 if (unlikely(current->audit_context)) { 1037 if (unlikely(current->audit_context)) {
1043#ifdef CONFIG_PPC64 1038#ifdef CONFIG_PPC64
@@ -1055,16 +1050,19 @@ void do_syscall_trace_enter(struct pt_regs *regs)
1055 regs->gpr[5] & 0xffffffff, 1050 regs->gpr[5] & 0xffffffff,
1056 regs->gpr[6] & 0xffffffff); 1051 regs->gpr[6] & 0xffffffff);
1057 } 1052 }
1053
1054 return ret ?: regs->gpr[0];
1058} 1055}
1059 1056
1060void do_syscall_trace_leave(struct pt_regs *regs) 1057void do_syscall_trace_leave(struct pt_regs *regs)
1061{ 1058{
1059 int step;
1060
1062 if (unlikely(current->audit_context)) 1061 if (unlikely(current->audit_context))
1063 audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS, 1062 audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
1064 regs->result); 1063 regs->result);
1065 1064
1066 if ((test_thread_flag(TIF_SYSCALL_TRACE) 1065 step = test_thread_flag(TIF_SINGLESTEP);
1067 || test_thread_flag(TIF_SINGLESTEP)) 1066 if (step || test_thread_flag(TIF_SYSCALL_TRACE))
1068 && (current->ptrace & PT_PTRACED)) 1067 tracehook_report_syscall_exit(regs, step);
1069 do_syscall_trace();
1070} 1068}
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 09ded5c424a9..149cb112cd1a 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -286,7 +286,7 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf,
286} 286}
287 287
288/* constructor for flash_block_cache */ 288/* constructor for flash_block_cache */
289void rtas_block_ctor(struct kmem_cache *cache, void *ptr) 289void rtas_block_ctor(void *ptr)
290{ 290{
291 memset(ptr, 0, RTAS_BLK_SIZE); 291 memset(ptr, 0, RTAS_BLK_SIZE);
292} 292}
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 61a3f4132087..9cc5a52711e5 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -367,7 +367,6 @@ static void __init cpu_init_thread_core_maps(int tpc)
367 * setup_cpu_maps - initialize the following cpu maps: 367 * setup_cpu_maps - initialize the following cpu maps:
368 * cpu_possible_map 368 * cpu_possible_map
369 * cpu_present_map 369 * cpu_present_map
370 * cpu_sibling_map
371 * 370 *
372 * Having the possible map set up early allows us to restrict allocations 371 * Having the possible map set up early allows us to restrict allocations
373 * of things like irqstacks to num_possible_cpus() rather than NR_CPUS. 372 * of things like irqstacks to num_possible_cpus() rather than NR_CPUS.
@@ -475,29 +474,6 @@ void __init smp_setup_cpu_maps(void)
475 */ 474 */
476 cpu_init_thread_core_maps(nthreads); 475 cpu_init_thread_core_maps(nthreads);
477} 476}
478
479/*
480 * Being that cpu_sibling_map is now a per_cpu array, then it cannot
481 * be initialized until the per_cpu areas have been created. This
482 * function is now called from setup_per_cpu_areas().
483 */
484void __init smp_setup_cpu_sibling_map(void)
485{
486#ifdef CONFIG_PPC64
487 int i, cpu, base;
488
489 for_each_possible_cpu(cpu) {
490 DBG("Sibling map for CPU %d:", cpu);
491 base = cpu_first_thread_in_core(cpu);
492 for (i = 0; i < threads_per_core; i++) {
493 cpu_set(base + i, per_cpu(cpu_sibling_map, cpu));
494 DBG(" %d", base + i);
495 }
496 DBG("\n");
497 }
498
499#endif /* CONFIG_PPC64 */
500}
501#endif /* CONFIG_SMP */ 477#endif /* CONFIG_SMP */
502 478
503#ifdef CONFIG_PCSPKR_PLATFORM 479#ifdef CONFIG_PCSPKR_PLATFORM
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 04d8de9f0fc6..8b25f51f03bf 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -611,9 +611,6 @@ void __init setup_per_cpu_areas(void)
611 paca[i].data_offset = ptr - __per_cpu_start; 611 paca[i].data_offset = ptr - __per_cpu_start;
612 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 612 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
613 } 613 }
614
615 /* Now that per_cpu is setup, initialize cpu_sibling_map */
616 smp_setup_cpu_sibling_map();
617} 614}
618#endif 615#endif
619 616
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 7aada783ec6a..a54405ebd7b0 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -9,7 +9,7 @@
9 * this archive for more details. 9 * this archive for more details.
10 */ 10 */
11 11
12#include <linux/ptrace.h> 12#include <linux/tracehook.h>
13#include <linux/signal.h> 13#include <linux/signal.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <asm/unistd.h> 15#include <asm/unistd.h>
@@ -112,7 +112,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
112 } 112 }
113} 113}
114 114
115int do_signal(sigset_t *oldset, struct pt_regs *regs) 115static int do_signal_pending(sigset_t *oldset, struct pt_regs *regs)
116{ 116{
117 siginfo_t info; 117 siginfo_t info;
118 int signr; 118 int signr;
@@ -147,7 +147,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
147 */ 147 */
148 if (current->thread.dabr) { 148 if (current->thread.dabr) {
149 set_dabr(current->thread.dabr); 149 set_dabr(current->thread.dabr);
150#if defined(CONFIG_44x) || defined(CONFIG_BOOKE) 150#if defined(CONFIG_BOOKE)
151 mtspr(SPRN_DBCR0, current->thread.dbcr0); 151 mtspr(SPRN_DBCR0, current->thread.dbcr0);
152#endif 152#endif
153 } 153 }
@@ -177,11 +177,28 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
177 * its frame, and we can clear the TLF_RESTORE_SIGMASK flag. 177 * its frame, and we can clear the TLF_RESTORE_SIGMASK flag.
178 */ 178 */
179 current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK; 179 current_thread_info()->local_flags &= ~_TLF_RESTORE_SIGMASK;
180
181 /*
182 * Let tracing know that we've done the handler setup.
183 */
184 tracehook_signal_handler(signr, &info, &ka, regs,
185 test_thread_flag(TIF_SINGLESTEP));
180 } 186 }
181 187
182 return ret; 188 return ret;
183} 189}
184 190
191void do_signal(struct pt_regs *regs, unsigned long thread_info_flags)
192{
193 if (thread_info_flags & _TIF_SIGPENDING)
194 do_signal_pending(NULL, regs);
195
196 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
197 clear_thread_flag(TIF_NOTIFY_RESUME);
198 tracehook_notify_resume(regs);
199 }
200}
201
185long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 202long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
186 unsigned long r5, unsigned long r6, unsigned long r7, 203 unsigned long r5, unsigned long r6, unsigned long r7,
187 unsigned long r8, struct pt_regs *regs) 204 unsigned long r8, struct pt_regs *regs)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index f5ae9fa222ea..5337ca7bb649 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -41,6 +41,7 @@
41#include <asm/smp.h> 41#include <asm/smp.h>
42#include <asm/time.h> 42#include <asm/time.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/cputhreads.h>
44#include <asm/cputable.h> 45#include <asm/cputable.h>
45#include <asm/system.h> 46#include <asm/system.h>
46#include <asm/mpic.h> 47#include <asm/mpic.h>
@@ -62,10 +63,12 @@ struct thread_info *secondary_ti;
62cpumask_t cpu_possible_map = CPU_MASK_NONE; 63cpumask_t cpu_possible_map = CPU_MASK_NONE;
63cpumask_t cpu_online_map = CPU_MASK_NONE; 64cpumask_t cpu_online_map = CPU_MASK_NONE;
64DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE; 65DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
66DEFINE_PER_CPU(cpumask_t, cpu_core_map) = CPU_MASK_NONE;
65 67
66EXPORT_SYMBOL(cpu_online_map); 68EXPORT_SYMBOL(cpu_online_map);
67EXPORT_SYMBOL(cpu_possible_map); 69EXPORT_SYMBOL(cpu_possible_map);
68EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); 70EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
71EXPORT_PER_CPU_SYMBOL(cpu_core_map);
69 72
70/* SMP operations for this machine */ 73/* SMP operations for this machine */
71struct smp_ops_t *smp_ops; 74struct smp_ops_t *smp_ops;
@@ -228,6 +231,8 @@ void __devinit smp_prepare_boot_cpu(void)
228 BUG_ON(smp_processor_id() != boot_cpuid); 231 BUG_ON(smp_processor_id() != boot_cpuid);
229 232
230 cpu_set(boot_cpuid, cpu_online_map); 233 cpu_set(boot_cpuid, cpu_online_map);
234 cpu_set(boot_cpuid, per_cpu(cpu_sibling_map, boot_cpuid));
235 cpu_set(boot_cpuid, per_cpu(cpu_core_map, boot_cpuid));
231#ifdef CONFIG_PPC64 236#ifdef CONFIG_PPC64
232 paca[boot_cpuid].__current = current; 237 paca[boot_cpuid].__current = current;
233#endif 238#endif
@@ -375,11 +380,60 @@ int __cpuinit __cpu_up(unsigned int cpu)
375 return 0; 380 return 0;
376} 381}
377 382
383/* Return the value of the reg property corresponding to the given
384 * logical cpu.
385 */
386int cpu_to_core_id(int cpu)
387{
388 struct device_node *np;
389 const int *reg;
390 int id = -1;
391
392 np = of_get_cpu_node(cpu, NULL);
393 if (!np)
394 goto out;
395
396 reg = of_get_property(np, "reg", NULL);
397 if (!reg)
398 goto out;
399
400 id = *reg;
401out:
402 of_node_put(np);
403 return id;
404}
405
406/* Must be called when no change can occur to cpu_present_map,
407 * i.e. during cpu online or offline.
408 */
409static struct device_node *cpu_to_l2cache(int cpu)
410{
411 struct device_node *np;
412 const phandle *php;
413 phandle ph;
414
415 if (!cpu_present(cpu))
416 return NULL;
417
418 np = of_get_cpu_node(cpu, NULL);
419 if (np == NULL)
420 return NULL;
421
422 php = of_get_property(np, "l2-cache", NULL);
423 if (php == NULL)
424 return NULL;
425 ph = *php;
426 of_node_put(np);
427
428 return of_find_node_by_phandle(ph);
429}
378 430
379/* Activate a secondary processor. */ 431/* Activate a secondary processor. */
380int __devinit start_secondary(void *unused) 432int __devinit start_secondary(void *unused)
381{ 433{
382 unsigned int cpu = smp_processor_id(); 434 unsigned int cpu = smp_processor_id();
435 struct device_node *l2_cache;
436 int i, base;
383 437
384 atomic_inc(&init_mm.mm_count); 438 atomic_inc(&init_mm.mm_count);
385 current->active_mm = &init_mm; 439 current->active_mm = &init_mm;
@@ -400,6 +454,33 @@ int __devinit start_secondary(void *unused)
400 454
401 ipi_call_lock(); 455 ipi_call_lock();
402 cpu_set(cpu, cpu_online_map); 456 cpu_set(cpu, cpu_online_map);
457 /* Update sibling maps */
458 base = cpu_first_thread_in_core(cpu);
459 for (i = 0; i < threads_per_core; i++) {
460 if (cpu_is_offline(base + i))
461 continue;
462 cpu_set(cpu, per_cpu(cpu_sibling_map, base + i));
463 cpu_set(base + i, per_cpu(cpu_sibling_map, cpu));
464
465 /* cpu_core_map should be a superset of
466 * cpu_sibling_map even if we don't have cache
467 * information, so update the former here, too.
468 */
469 cpu_set(cpu, per_cpu(cpu_core_map, base +i));
470 cpu_set(base + i, per_cpu(cpu_core_map, cpu));
471 }
472 l2_cache = cpu_to_l2cache(cpu);
473 for_each_online_cpu(i) {
474 struct device_node *np = cpu_to_l2cache(i);
475 if (!np)
476 continue;
477 if (np == l2_cache) {
478 cpu_set(cpu, per_cpu(cpu_core_map, i));
479 cpu_set(i, per_cpu(cpu_core_map, cpu));
480 }
481 of_node_put(np);
482 }
483 of_node_put(l2_cache);
403 ipi_call_unlock(); 484 ipi_call_unlock();
404 485
405 local_irq_enable(); 486 local_irq_enable();
@@ -437,10 +518,42 @@ void __init smp_cpus_done(unsigned int max_cpus)
437#ifdef CONFIG_HOTPLUG_CPU 518#ifdef CONFIG_HOTPLUG_CPU
438int __cpu_disable(void) 519int __cpu_disable(void)
439{ 520{
440 if (smp_ops->cpu_disable) 521 struct device_node *l2_cache;
441 return smp_ops->cpu_disable(); 522 int cpu = smp_processor_id();
523 int base, i;
524 int err;
442 525
443 return -ENOSYS; 526 if (!smp_ops->cpu_disable)
527 return -ENOSYS;
528
529 err = smp_ops->cpu_disable();
530 if (err)
531 return err;
532
533 /* Update sibling maps */
534 base = cpu_first_thread_in_core(cpu);
535 for (i = 0; i < threads_per_core; i++) {
536 cpu_clear(cpu, per_cpu(cpu_sibling_map, base + i));
537 cpu_clear(base + i, per_cpu(cpu_sibling_map, cpu));
538 cpu_clear(cpu, per_cpu(cpu_core_map, base +i));
539 cpu_clear(base + i, per_cpu(cpu_core_map, cpu));
540 }
541
542 l2_cache = cpu_to_l2cache(cpu);
543 for_each_present_cpu(i) {
544 struct device_node *np = cpu_to_l2cache(i);
545 if (!np)
546 continue;
547 if (np == l2_cache) {
548 cpu_clear(cpu, per_cpu(cpu_core_map, i));
549 cpu_clear(i, per_cpu(cpu_core_map, cpu));
550 }
551 of_node_put(np);
552 }
553 of_node_put(l2_cache);
554
555
556 return 0;
444} 557}
445 558
446void __cpu_die(unsigned int cpu) 559void __cpu_die(unsigned int cpu)
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index f2589645870a..b0dbb1daa4df 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/stacktrace.h> 15#include <linux/stacktrace.h>
16#include <linux/module.h>
17#include <asm/ptrace.h> 16#include <asm/ptrace.h>
18#include <asm/processor.h> 17#include <asm/processor.h>
19 18
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 800e5e9a087b..56d172d16e56 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -22,6 +22,8 @@
22 22
23static DEFINE_PER_CPU(struct cpu, cpu_devices); 23static DEFINE_PER_CPU(struct cpu, cpu_devices);
24 24
25static DEFINE_PER_CPU(struct kobject *, cache_toplevel);
26
25/* SMT stuff */ 27/* SMT stuff */
26 28
27#ifdef CONFIG_PPC_MULTIPLATFORM 29#ifdef CONFIG_PPC_MULTIPLATFORM
@@ -297,8 +299,289 @@ static struct sysdev_attribute pa6t_attrs[] = {
297#endif /* CONFIG_DEBUG_KERNEL */ 299#endif /* CONFIG_DEBUG_KERNEL */
298}; 300};
299 301
302struct cache_desc {
303 struct kobject kobj;
304 struct cache_desc *next;
305 const char *type; /* Instruction, Data, or Unified */
306 u32 size; /* total cache size in KB */
307 u32 line_size; /* in bytes */
308 u32 nr_sets; /* number of sets */
309 u32 level; /* e.g. 1, 2, 3... */
310 u32 associativity; /* e.g. 8-way... 0 is fully associative */
311};
312
313DEFINE_PER_CPU(struct cache_desc *, cache_desc);
314
315static struct cache_desc *kobj_to_cache_desc(struct kobject *k)
316{
317 return container_of(k, struct cache_desc, kobj);
318}
319
320static void cache_desc_release(struct kobject *k)
321{
322 struct cache_desc *desc = kobj_to_cache_desc(k);
323
324 pr_debug("%s: releasing %s\n", __func__, kobject_name(k));
325
326 if (desc->next)
327 kobject_put(&desc->next->kobj);
328
329 kfree(kobj_to_cache_desc(k));
330}
331
332static ssize_t cache_desc_show(struct kobject *k, struct attribute *attr, char *buf)
333{
334 struct kobj_attribute *kobj_attr;
335
336 kobj_attr = container_of(attr, struct kobj_attribute, attr);
337
338 return kobj_attr->show(k, kobj_attr, buf);
339}
340
341static struct sysfs_ops cache_desc_sysfs_ops = {
342 .show = cache_desc_show,
343};
344
345static struct kobj_type cache_desc_type = {
346 .release = cache_desc_release,
347 .sysfs_ops = &cache_desc_sysfs_ops,
348};
349
350static ssize_t cache_size_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
351{
352 struct cache_desc *cache = kobj_to_cache_desc(k);
353
354 return sprintf(buf, "%uK\n", cache->size);
355}
356
357static struct kobj_attribute cache_size_attr =
358 __ATTR(size, 0444, cache_size_show, NULL);
359
360static ssize_t cache_line_size_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
361{
362 struct cache_desc *cache = kobj_to_cache_desc(k);
363
364 return sprintf(buf, "%u\n", cache->line_size);
365}
366
367static struct kobj_attribute cache_line_size_attr =
368 __ATTR(coherency_line_size, 0444, cache_line_size_show, NULL);
369
370static ssize_t cache_nr_sets_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
371{
372 struct cache_desc *cache = kobj_to_cache_desc(k);
373
374 return sprintf(buf, "%u\n", cache->nr_sets);
375}
376
377static struct kobj_attribute cache_nr_sets_attr =
378 __ATTR(number_of_sets, 0444, cache_nr_sets_show, NULL);
379
380static ssize_t cache_type_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
381{
382 struct cache_desc *cache = kobj_to_cache_desc(k);
383
384 return sprintf(buf, "%s\n", cache->type);
385}
386
387static struct kobj_attribute cache_type_attr =
388 __ATTR(type, 0444, cache_type_show, NULL);
389
390static ssize_t cache_level_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
391{
392 struct cache_desc *cache = kobj_to_cache_desc(k);
393
394 return sprintf(buf, "%u\n", cache->level);
395}
396
397static struct kobj_attribute cache_level_attr =
398 __ATTR(level, 0444, cache_level_show, NULL);
399
400static ssize_t cache_assoc_show(struct kobject *k, struct kobj_attribute *attr, char *buf)
401{
402 struct cache_desc *cache = kobj_to_cache_desc(k);
403
404 return sprintf(buf, "%u\n", cache->associativity);
405}
406
407static struct kobj_attribute cache_assoc_attr =
408 __ATTR(ways_of_associativity, 0444, cache_assoc_show, NULL);
409
410struct cache_desc_info {
411 const char *type;
412 const char *size_prop;
413 const char *line_size_prop;
414 const char *nr_sets_prop;
415};
416
417/* PowerPC Processor binding says the [di]-cache-* must be equal on
418 * unified caches, so just use d-cache properties. */
419static struct cache_desc_info ucache_info = {
420 .type = "Unified",
421 .size_prop = "d-cache-size",
422 .line_size_prop = "d-cache-line-size",
423 .nr_sets_prop = "d-cache-sets",
424};
300 425
301static void register_cpu_online(unsigned int cpu) 426static struct cache_desc_info dcache_info = {
427 .type = "Data",
428 .size_prop = "d-cache-size",
429 .line_size_prop = "d-cache-line-size",
430 .nr_sets_prop = "d-cache-sets",
431};
432
433static struct cache_desc_info icache_info = {
434 .type = "Instruction",
435 .size_prop = "i-cache-size",
436 .line_size_prop = "i-cache-line-size",
437 .nr_sets_prop = "i-cache-sets",
438};
439
440static struct cache_desc * __cpuinit create_cache_desc(struct device_node *np, struct kobject *parent, int index, int level, struct cache_desc_info *info)
441{
442 const u32 *cache_line_size;
443 struct cache_desc *new;
444 const u32 *cache_size;
445 const u32 *nr_sets;
446 int rc;
447
448 new = kzalloc(sizeof(*new), GFP_KERNEL);
449 if (!new)
450 return NULL;
451
452 rc = kobject_init_and_add(&new->kobj, &cache_desc_type, parent,
453 "index%d", index);
454 if (rc)
455 goto err;
456
457 /* type */
458 new->type = info->type;
459 rc = sysfs_create_file(&new->kobj, &cache_type_attr.attr);
460 WARN_ON(rc);
461
462 /* level */
463 new->level = level;
464 rc = sysfs_create_file(&new->kobj, &cache_level_attr.attr);
465 WARN_ON(rc);
466
467 /* size */
468 cache_size = of_get_property(np, info->size_prop, NULL);
469 if (cache_size) {
470 new->size = *cache_size / 1024;
471 rc = sysfs_create_file(&new->kobj,
472 &cache_size_attr.attr);
473 WARN_ON(rc);
474 }
475
476 /* coherency_line_size */
477 cache_line_size = of_get_property(np, info->line_size_prop, NULL);
478 if (cache_line_size) {
479 new->line_size = *cache_line_size;
480 rc = sysfs_create_file(&new->kobj,
481 &cache_line_size_attr.attr);
482 WARN_ON(rc);
483 }
484
485 /* number_of_sets */
486 nr_sets = of_get_property(np, info->nr_sets_prop, NULL);
487 if (nr_sets) {
488 new->nr_sets = *nr_sets;
489 rc = sysfs_create_file(&new->kobj,
490 &cache_nr_sets_attr.attr);
491 WARN_ON(rc);
492 }
493
494 /* ways_of_associativity */
495 if (new->nr_sets == 1) {
496 /* fully associative */
497 new->associativity = 0;
498 goto create_assoc;
499 }
500
501 if (new->nr_sets && new->size && new->line_size) {
502 /* If we have values for all of these we can derive
503 * the associativity. */
504 new->associativity =
505 ((new->size * 1024) / new->nr_sets) / new->line_size;
506create_assoc:
507 rc = sysfs_create_file(&new->kobj,
508 &cache_assoc_attr.attr);
509 WARN_ON(rc);
510 }
511
512 return new;
513err:
514 kfree(new);
515 return NULL;
516}
517
518static bool cache_is_unified(struct device_node *np)
519{
520 return of_get_property(np, "cache-unified", NULL);
521}
522
523static struct cache_desc * __cpuinit create_cache_index_info(struct device_node *np, struct kobject *parent, int index, int level)
524{
525 const phandle *next_cache_phandle;
526 struct device_node *next_cache;
527 struct cache_desc *new, **end;
528
529 pr_debug("%s(node = %s, index = %d)\n", __func__, np->full_name, index);
530
531 if (cache_is_unified(np)) {
532 new = create_cache_desc(np, parent, index, level,
533 &ucache_info);
534 } else {
535 new = create_cache_desc(np, parent, index, level,
536 &dcache_info);
537 if (new) {
538 index++;
539 new->next = create_cache_desc(np, parent, index, level,
540 &icache_info);
541 }
542 }
543 if (!new)
544 return NULL;
545
546 end = &new->next;
547 while (*end)
548 end = &(*end)->next;
549
550 next_cache_phandle = of_get_property(np, "l2-cache", NULL);
551 if (!next_cache_phandle)
552 goto out;
553
554 next_cache = of_find_node_by_phandle(*next_cache_phandle);
555 if (!next_cache)
556 goto out;
557
558 *end = create_cache_index_info(next_cache, parent, ++index, ++level);
559
560 of_node_put(next_cache);
561out:
562 return new;
563}
564
565static void __cpuinit create_cache_info(struct sys_device *sysdev)
566{
567 struct kobject *cache_toplevel;
568 struct device_node *np = NULL;
569 int cpu = sysdev->id;
570
571 cache_toplevel = kobject_create_and_add("cache", &sysdev->kobj);
572 if (!cache_toplevel)
573 return;
574 per_cpu(cache_toplevel, cpu) = cache_toplevel;
575 np = of_get_cpu_node(cpu, NULL);
576 if (np != NULL) {
577 per_cpu(cache_desc, cpu) =
578 create_cache_index_info(np, cache_toplevel, 0, 1);
579 of_node_put(np);
580 }
581 return;
582}
583
584static void __cpuinit register_cpu_online(unsigned int cpu)
302{ 585{
303 struct cpu *c = &per_cpu(cpu_devices, cpu); 586 struct cpu *c = &per_cpu(cpu_devices, cpu);
304 struct sys_device *s = &c->sysdev; 587 struct sys_device *s = &c->sysdev;
@@ -346,9 +629,33 @@ static void register_cpu_online(unsigned int cpu)
346 629
347 if (cpu_has_feature(CPU_FTR_DSCR)) 630 if (cpu_has_feature(CPU_FTR_DSCR))
348 sysdev_create_file(s, &attr_dscr); 631 sysdev_create_file(s, &attr_dscr);
632
633 create_cache_info(s);
349} 634}
350 635
351#ifdef CONFIG_HOTPLUG_CPU 636#ifdef CONFIG_HOTPLUG_CPU
637static void remove_cache_info(struct sys_device *sysdev)
638{
639 struct kobject *cache_toplevel;
640 struct cache_desc *cache_desc;
641 int cpu = sysdev->id;
642
643 cache_desc = per_cpu(cache_desc, cpu);
644 if (cache_desc != NULL) {
645 sysfs_remove_file(&cache_desc->kobj, &cache_size_attr.attr);
646 sysfs_remove_file(&cache_desc->kobj, &cache_line_size_attr.attr);
647 sysfs_remove_file(&cache_desc->kobj, &cache_type_attr.attr);
648 sysfs_remove_file(&cache_desc->kobj, &cache_level_attr.attr);
649 sysfs_remove_file(&cache_desc->kobj, &cache_nr_sets_attr.attr);
650 sysfs_remove_file(&cache_desc->kobj, &cache_assoc_attr.attr);
651
652 kobject_put(&cache_desc->kobj);
653 }
654 cache_toplevel = per_cpu(cache_toplevel, cpu);
655 if (cache_toplevel != NULL)
656 kobject_put(cache_toplevel);
657}
658
352static void unregister_cpu_online(unsigned int cpu) 659static void unregister_cpu_online(unsigned int cpu)
353{ 660{
354 struct cpu *c = &per_cpu(cpu_devices, cpu); 661 struct cpu *c = &per_cpu(cpu_devices, cpu);
@@ -399,6 +706,8 @@ static void unregister_cpu_online(unsigned int cpu)
399 706
400 if (cpu_has_feature(CPU_FTR_DSCR)) 707 if (cpu_has_feature(CPU_FTR_DSCR))
401 sysdev_remove_file(s, &attr_dscr); 708 sysdev_remove_file(s, &attr_dscr);
709
710 remove_cache_info(s);
402} 711}
403#endif /* CONFIG_HOTPLUG_CPU */ 712#endif /* CONFIG_HOTPLUG_CPU */
404 713
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index ade8aeaa2e70..22a3c33fd751 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -530,7 +530,7 @@ static dma_addr_t vio_dma_iommu_map_single(struct device *dev, void *vaddr,
530 } 530 }
531 531
532 ret = dma_iommu_ops.map_single(dev, vaddr, size, direction, attrs); 532 ret = dma_iommu_ops.map_single(dev, vaddr, size, direction, attrs);
533 if (unlikely(dma_mapping_error(ret))) { 533 if (unlikely(dma_mapping_error(dev, ret))) {
534 vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE)); 534 vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE));
535 atomic_inc(&viodev->cmo.allocs_failed); 535 atomic_inc(&viodev->cmo.allocs_failed);
536 } 536 }
@@ -1031,8 +1031,8 @@ void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
1031static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; } 1031static int vio_cmo_bus_probe(struct vio_dev *viodev) { return 0; }
1032static void vio_cmo_bus_remove(struct vio_dev *viodev) {} 1032static void vio_cmo_bus_remove(struct vio_dev *viodev) {}
1033static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {} 1033static void vio_cmo_set_dma_ops(struct vio_dev *viodev) {}
1034static void vio_cmo_bus_init() {} 1034static void vio_cmo_bus_init(void) {}
1035static void vio_cmo_sysfs_init() { } 1035static void vio_cmo_sysfs_init(void) { }
1036#endif /* CONFIG_PPC_SMLPAR */ 1036#endif /* CONFIG_PPC_SMLPAR */
1037EXPORT_SYMBOL(vio_cmo_entitlement_update); 1037EXPORT_SYMBOL(vio_cmo_entitlement_update);
1038EXPORT_SYMBOL(vio_cmo_set_dev_desired); 1038EXPORT_SYMBOL(vio_cmo_set_dev_desired);
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index 75dff7cfa814..5a5602da5091 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -177,7 +177,8 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid,
177 vcpu->arch.msr & MSR_PR); 177 vcpu->arch.msr & MSR_PR);
178} 178}
179 179
180void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, u64 eaddr, u64 asid) 180void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
181 gva_t eend, u32 asid)
181{ 182{
182 unsigned int pid = asid & 0xff; 183 unsigned int pid = asid & 0xff;
183 int i; 184 int i;
@@ -191,7 +192,7 @@ void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, u64 eaddr, u64 asid)
191 if (!get_tlb_v(stlbe)) 192 if (!get_tlb_v(stlbe))
192 continue; 193 continue;
193 194
194 if (eaddr < get_tlb_eaddr(stlbe)) 195 if (eend < get_tlb_eaddr(stlbe))
195 continue; 196 continue;
196 197
197 if (eaddr > get_tlb_end(stlbe)) 198 if (eaddr > get_tlb_end(stlbe))
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 000097461283..8c605d0a5488 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -137,7 +137,7 @@ static int kvmppc_emul_tlbwe(struct kvm_vcpu *vcpu, u32 inst)
137 if (tlbe->word0 & PPC44x_TLB_VALID) { 137 if (tlbe->word0 & PPC44x_TLB_VALID) {
138 eaddr = get_tlb_eaddr(tlbe); 138 eaddr = get_tlb_eaddr(tlbe);
139 asid = (tlbe->word0 & PPC44x_TLB_TS) | tlbe->tid; 139 asid = (tlbe->word0 & PPC44x_TLB_TS) | tlbe->tid;
140 kvmppc_mmu_invalidate(vcpu, eaddr, asid); 140 kvmppc_mmu_invalidate(vcpu, eaddr, get_tlb_end(tlbe), asid);
141 } 141 }
142 142
143 switch (ws) { 143 switch (ws) {
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index fb42c4dd3217..f1c2d55b4377 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -113,7 +113,7 @@ static inline pte_t *hugepte_offset(hugepd_t *hpdp, unsigned long addr,
113static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, 113static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
114 unsigned long address, unsigned int psize) 114 unsigned long address, unsigned int psize)
115{ 115{
116 pte_t *new = kmem_cache_alloc(huge_pgtable_cache(psize), 116 pte_t *new = kmem_cache_zalloc(huge_pgtable_cache(psize),
117 GFP_KERNEL|__GFP_REPEAT); 117 GFP_KERNEL|__GFP_REPEAT);
118 118
119 if (! new) 119 if (! new)
@@ -730,25 +730,27 @@ static int __init hugepage_setup_sz(char *str)
730} 730}
731__setup("hugepagesz=", hugepage_setup_sz); 731__setup("hugepagesz=", hugepage_setup_sz);
732 732
733static void zero_ctor(struct kmem_cache *cache, void *addr)
734{
735 memset(addr, 0, kmem_cache_size(cache));
736}
737
738static int __init hugetlbpage_init(void) 733static int __init hugetlbpage_init(void)
739{ 734{
740 unsigned int psize; 735 unsigned int psize;
741 736
742 if (!cpu_has_feature(CPU_FTR_16M_PAGE)) 737 if (!cpu_has_feature(CPU_FTR_16M_PAGE))
743 return -ENODEV; 738 return -ENODEV;
739
744 /* Add supported huge page sizes. Need to change HUGE_MAX_HSTATE 740 /* Add supported huge page sizes. Need to change HUGE_MAX_HSTATE
745 * and adjust PTE_NONCACHE_NUM if the number of supported huge page 741 * and adjust PTE_NONCACHE_NUM if the number of supported huge page
746 * sizes changes. 742 * sizes changes.
747 */ 743 */
748 set_huge_psize(MMU_PAGE_16M); 744 set_huge_psize(MMU_PAGE_16M);
749 set_huge_psize(MMU_PAGE_64K);
750 set_huge_psize(MMU_PAGE_16G); 745 set_huge_psize(MMU_PAGE_16G);
751 746
747 /* Temporarily disable support for 64K huge pages when 64K SPU local
748 * store support is enabled as the current implementation conflicts.
749 */
750#ifndef CONFIG_SPU_FS_64K_LS
751 set_huge_psize(MMU_PAGE_64K);
752#endif
753
752 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize) { 754 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize) {
753 if (mmu_huge_psizes[psize]) { 755 if (mmu_huge_psizes[psize]) {
754 huge_pgtable_cache(psize) = kmem_cache_create( 756 huge_pgtable_cache(psize) = kmem_cache_create(
@@ -756,7 +758,7 @@ static int __init hugetlbpage_init(void)
756 HUGEPTE_TABLE_SIZE(psize), 758 HUGEPTE_TABLE_SIZE(psize),
757 HUGEPTE_TABLE_SIZE(psize), 759 HUGEPTE_TABLE_SIZE(psize),
758 0, 760 0,
759 zero_ctor); 761 NULL);
760 if (!huge_pgtable_cache(psize)) 762 if (!huge_pgtable_cache(psize))
761 panic("hugetlbpage_init(): could not create %s"\ 763 panic("hugetlbpage_init(): could not create %s"\
762 "\n", HUGEPTE_CACHE_NAME(psize)); 764 "\n", HUGEPTE_CACHE_NAME(psize));
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index a41bc5aa2043..4f7df85129d8 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -136,9 +136,14 @@ static int __init setup_kcore(void)
136module_init(setup_kcore); 136module_init(setup_kcore);
137#endif 137#endif
138 138
139static void zero_ctor(struct kmem_cache *cache, void *addr) 139static void pgd_ctor(void *addr)
140{ 140{
141 memset(addr, 0, kmem_cache_size(cache)); 141 memset(addr, 0, PGD_TABLE_SIZE);
142}
143
144static void pmd_ctor(void *addr)
145{
146 memset(addr, 0, PMD_TABLE_SIZE);
142} 147}
143 148
144static const unsigned int pgtable_cache_size[2] = { 149static const unsigned int pgtable_cache_size[2] = {
@@ -163,19 +168,8 @@ struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
163 168
164void pgtable_cache_init(void) 169void pgtable_cache_init(void)
165{ 170{
166 int i; 171 pgtable_cache[0] = kmem_cache_create(pgtable_cache_name[0], PGD_TABLE_SIZE, PGD_TABLE_SIZE, SLAB_PANIC, pgd_ctor);
167 172 pgtable_cache[1] = kmem_cache_create(pgtable_cache_name[1], PMD_TABLE_SIZE, PMD_TABLE_SIZE, SLAB_PANIC, pmd_ctor);
168 for (i = 0; i < ARRAY_SIZE(pgtable_cache_size); i++) {
169 int size = pgtable_cache_size[i];
170 const char *name = pgtable_cache_name[i];
171
172 pr_debug("Allocating page table cache %s (#%d) "
173 "for size: %08x...\n", name, i, size);
174 pgtable_cache[i] = kmem_cache_create(name,
175 size, size,
176 SLAB_PANIC,
177 zero_ctor);
178 }
179} 173}
180 174
181#ifdef CONFIG_SPARSEMEM_VMEMMAP 175#ifdef CONFIG_SPARSEMEM_VMEMMAP
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 1ca2235f0965..702691cb9e82 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -186,45 +186,6 @@ walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
186} 186}
187EXPORT_SYMBOL_GPL(walk_memory_resource); 187EXPORT_SYMBOL_GPL(walk_memory_resource);
188 188
189void show_mem(void)
190{
191 unsigned long total = 0, reserved = 0;
192 unsigned long shared = 0, cached = 0;
193 unsigned long highmem = 0;
194 struct page *page;
195 pg_data_t *pgdat;
196 unsigned long i;
197
198 printk("Mem-info:\n");
199 show_free_areas();
200 for_each_online_pgdat(pgdat) {
201 unsigned long flags;
202 pgdat_resize_lock(pgdat, &flags);
203 for (i = 0; i < pgdat->node_spanned_pages; i++) {
204 if (!pfn_valid(pgdat->node_start_pfn + i))
205 continue;
206 page = pgdat_page_nr(pgdat, i);
207 total++;
208 if (PageHighMem(page))
209 highmem++;
210 if (PageReserved(page))
211 reserved++;
212 else if (PageSwapCache(page))
213 cached++;
214 else if (page_count(page))
215 shared += page_count(page) - 1;
216 }
217 pgdat_resize_unlock(pgdat, &flags);
218 }
219 printk("%ld pages of RAM\n", total);
220#ifdef CONFIG_HIGHMEM
221 printk("%ld pages of HIGHMEM\n", highmem);
222#endif
223 printk("%ld reserved pages\n", reserved);
224 printk("%ld pages shared\n", shared);
225 printk("%ld pages swap cached\n", cached);
226}
227
228/* 189/*
229 * Initialize the bootmem system and give it all the memory we 190 * Initialize the bootmem system and give it all the memory we
230 * have available. If we are using highmem, we only put the 191 * have available. If we are using highmem, we only put the
diff --git a/arch/powerpc/platforms/cell/celleb_scc_pciex.c b/arch/powerpc/platforms/cell/celleb_scc_pciex.c
index 0e04f8fb152a..3e7e0f1568ef 100644
--- a/arch/powerpc/platforms/cell/celleb_scc_pciex.c
+++ b/arch/powerpc/platforms/cell/celleb_scc_pciex.c
@@ -281,7 +281,7 @@ static int __init scc_pciex_iowa_init(struct iowa_bus *bus, void *data)
281 281
282 dummy_page_da = dma_map_single(bus->phb->parent, dummy_page_va, 282 dummy_page_da = dma_map_single(bus->phb->parent, dummy_page_va,
283 PAGE_SIZE, DMA_FROM_DEVICE); 283 PAGE_SIZE, DMA_FROM_DEVICE);
284 if (dma_mapping_error(dummy_page_da)) { 284 if (dma_mapping_error(bus->phb->parent, dummy_page_da)) {
285 pr_err("PCIEX:Map dummy page failed.\n"); 285 pr_err("PCIEX:Map dummy page failed.\n");
286 kfree(dummy_page_va); 286 kfree(dummy_page_va);
287 return -1; 287 return -1;
diff --git a/arch/powerpc/platforms/cell/spider-pci.c b/arch/powerpc/platforms/cell/spider-pci.c
index 418b605ac35a..5122ec145271 100644
--- a/arch/powerpc/platforms/cell/spider-pci.c
+++ b/arch/powerpc/platforms/cell/spider-pci.c
@@ -111,7 +111,7 @@ static int __init spiderpci_pci_setup_chip(struct pci_controller *phb,
111 111
112 dummy_page_da = dma_map_single(phb->parent, dummy_page_va, 112 dummy_page_da = dma_map_single(phb->parent, dummy_page_va,
113 PAGE_SIZE, DMA_FROM_DEVICE); 113 PAGE_SIZE, DMA_FROM_DEVICE);
114 if (dma_mapping_error(dummy_page_da)) { 114 if (dma_mapping_error(phb->parent, dummy_page_da)) {
115 pr_err("SPIDER-IOWA:Map dummy page filed.\n"); 115 pr_err("SPIDER-IOWA:Map dummy page filed.\n");
116 kfree(dummy_page_va); 116 kfree(dummy_page_va);
117 return -1; 117 return -1;
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 7123472801d9..690ca7b0dcf6 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -78,7 +78,7 @@ spufs_destroy_inode(struct inode *inode)
78} 78}
79 79
80static void 80static void
81spufs_init_once(struct kmem_cache *cachep, void *p) 81spufs_init_once(void *p)
82{ 82{
83 struct spufs_inode_info *ei = p; 83 struct spufs_inode_info *ei = p;
84 84
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index 1dc7295746da..731d7b157749 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -871,7 +871,7 @@ static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
871 count = 256 - off; 871 count = 256 - off;
872 872
873 dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE); 873 dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE);
874 if (dma_mapping_error(dma_addr)) 874 if (dma_mapping_error(NULL, dma_addr))
875 return -ENOMEM; 875 return -ENOMEM;
876 memset(page, 0, off + count); 876 memset(page, 0, off + count);
877 memset(&vsp_cmd, 0, sizeof(vsp_cmd)); 877 memset(&vsp_cmd, 0, sizeof(vsp_cmd));
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 31635446901a..88ccf3a08a9c 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -541,6 +541,78 @@ static int __init pmac_declare_of_platform_devices(void)
541} 541}
542machine_device_initcall(powermac, pmac_declare_of_platform_devices); 542machine_device_initcall(powermac, pmac_declare_of_platform_devices);
543 543
544#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
545/*
546 * This is called very early, as part of console_init() (typically just after
547 * time_init()). This function is respondible for trying to find a good
548 * default console on serial ports. It tries to match the open firmware
549 * default output with one of the available serial console drivers.
550 */
551static int __init check_pmac_serial_console(void)
552{
553 struct device_node *prom_stdout = NULL;
554 int offset = 0;
555 const char *name;
556#ifdef CONFIG_SERIAL_PMACZILOG_TTYS
557 char *devname = "ttyS";
558#else
559 char *devname = "ttyPZ";
560#endif
561
562 pr_debug(" -> check_pmac_serial_console()\n");
563
564 /* The user has requested a console so this is already set up. */
565 if (strstr(boot_command_line, "console=")) {
566 pr_debug(" console was specified !\n");
567 return -EBUSY;
568 }
569
570 if (!of_chosen) {
571 pr_debug(" of_chosen is NULL !\n");
572 return -ENODEV;
573 }
574
575 /* We are getting a weird phandle from OF ... */
576 /* ... So use the full path instead */
577 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
578 if (name == NULL) {
579 pr_debug(" no linux,stdout-path !\n");
580 return -ENODEV;
581 }
582 prom_stdout = of_find_node_by_path(name);
583 if (!prom_stdout) {
584 pr_debug(" can't find stdout package %s !\n", name);
585 return -ENODEV;
586 }
587 pr_debug("stdout is %s\n", prom_stdout->full_name);
588
589 name = of_get_property(prom_stdout, "name", NULL);
590 if (!name) {
591 pr_debug(" stdout package has no name !\n");
592 goto not_found;
593 }
594
595 if (strcmp(name, "ch-a") == 0)
596 offset = 0;
597 else if (strcmp(name, "ch-b") == 0)
598 offset = 1;
599 else
600 goto not_found;
601 of_node_put(prom_stdout);
602
603 pr_debug("Found serial console at %s%d\n", devname, offset);
604
605 return add_preferred_console(devname, offset, NULL);
606
607 not_found:
608 pr_debug("No preferred console found !\n");
609 of_node_put(prom_stdout);
610 return -ENODEV;
611}
612console_initcall(check_pmac_serial_console);
613
614#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
615
544/* 616/*
545 * Called very early, MMU is off, device-tree isn't unflattened 617 * Called very early, MMU is off, device-tree isn't unflattened
546 */ 618 */
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index 47de4d3fc167..572771fd8463 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -125,13 +125,23 @@ void udbg_scc_init(int force_scc)
125 out_8(sccc, 0xc0); 125 out_8(sccc, 0xc0);
126 126
127 /* If SCC was the OF output port, read the BRG value, else 127 /* If SCC was the OF output port, read the BRG value, else
128 * Setup for 57600 8N1 128 * Setup for 38400 or 57600 8N1 depending on the machine
129 */ 129 */
130 if (ch_def != NULL) { 130 if (ch_def != NULL) {
131 out_8(sccc, 13); 131 out_8(sccc, 13);
132 scc_inittab[1] = in_8(sccc); 132 scc_inittab[1] = in_8(sccc);
133 out_8(sccc, 12); 133 out_8(sccc, 12);
134 scc_inittab[3] = in_8(sccc); 134 scc_inittab[3] = in_8(sccc);
135 } else if (machine_is_compatible("RackMac1,1")
136 || machine_is_compatible("RackMac1,2")
137 || machine_is_compatible("MacRISC4")) {
138 /* Xserves and G5s default to 57600 */
139 scc_inittab[1] = 0;
140 scc_inittab[3] = 0;
141 } else {
142 /* Others default to 38400 */
143 scc_inittab[1] = 0;
144 scc_inittab[3] = 1;
135 } 145 }
136 146
137 for (i = 0; i < sizeof(scc_inittab); ++i) 147 for (i = 0; i < sizeof(scc_inittab); ++i)
diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index c6b3be03168b..38fe32a7cc70 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -289,7 +289,9 @@ static int cmm_thread(void *dummy)
289} 289}
290 290
291#define CMM_SHOW(name, format, args...) \ 291#define CMM_SHOW(name, format, args...) \
292 static ssize_t show_##name(struct sys_device *dev, char *buf) \ 292 static ssize_t show_##name(struct sys_device *dev, \
293 struct sysdev_attribute *attr, \
294 char *buf) \
293 { \ 295 { \
294 return sprintf(buf, format, ##args); \ 296 return sprintf(buf, format, ##args); \
295 } \ 297 } \
@@ -298,12 +300,14 @@ static int cmm_thread(void *dummy)
298CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(loaned_pages)); 300CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(loaned_pages));
299CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target)); 301CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target));
300 302
301static ssize_t show_oom_pages(struct sys_device *dev, char *buf) 303static ssize_t show_oom_pages(struct sys_device *dev,
304 struct sysdev_attribute *attr, char *buf)
302{ 305{
303 return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages)); 306 return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages));
304} 307}
305 308
306static ssize_t store_oom_pages(struct sys_device *dev, 309static ssize_t store_oom_pages(struct sys_device *dev,
310 struct sysdev_attribute *attr,
307 const char *buf, size_t count) 311 const char *buf, size_t count)
308{ 312{
309 unsigned long val = simple_strtoul (buf, NULL, 10); 313 unsigned long val = simple_strtoul (buf, NULL, 10);
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 4f82e5b5f879..569079ec4ff0 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -197,7 +197,7 @@ void __kprobes arch_arm_kprobe(struct kprobe *p)
197 args.new = BREAKPOINT_INSTRUCTION; 197 args.new = BREAKPOINT_INSTRUCTION;
198 198
199 kcb->kprobe_status = KPROBE_SWAP_INST; 199 kcb->kprobe_status = KPROBE_SWAP_INST;
200 stop_machine_run(swap_instruction, &args, NR_CPUS); 200 stop_machine(swap_instruction, &args, NULL);
201 kcb->kprobe_status = status; 201 kcb->kprobe_status = status;
202} 202}
203 203
@@ -212,7 +212,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
212 args.new = p->opcode; 212 args.new = p->opcode;
213 213
214 kcb->kprobe_status = KPROBE_SWAP_INST; 214 kcb->kprobe_status = KPROBE_SWAP_INST;
215 stop_machine_run(swap_instruction, &args, NR_CPUS); 215 stop_machine(swap_instruction, &args, NULL);
216 kcb->kprobe_status = status; 216 kcb->kprobe_status = status;
217} 217}
218 218
@@ -331,7 +331,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
331 * No kprobe at this address. The fault has not been 331 * No kprobe at this address. The fault has not been
332 * caused by a kprobe breakpoint. The race of breakpoint 332 * caused by a kprobe breakpoint. The race of breakpoint
333 * vs. kprobe remove does not exist because on s390 we 333 * vs. kprobe remove does not exist because on s390 we
334 * use stop_machine_run to arm/disarm the breakpoints. 334 * use stop_machine to arm/disarm the breakpoints.
335 */ 335 */
336 goto no_kprobe; 336 goto no_kprobe;
337 337
diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index 4e0633c413f3..ed60f3a74a85 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -18,11 +18,11 @@
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19 19
20static inline void __user *__guestaddr_to_user(struct kvm_vcpu *vcpu, 20static inline void __user *__guestaddr_to_user(struct kvm_vcpu *vcpu,
21 u64 guestaddr) 21 unsigned long guestaddr)
22{ 22{
23 u64 prefix = vcpu->arch.sie_block->prefix; 23 unsigned long prefix = vcpu->arch.sie_block->prefix;
24 u64 origin = vcpu->kvm->arch.guest_origin; 24 unsigned long origin = vcpu->kvm->arch.guest_origin;
25 u64 memsize = vcpu->kvm->arch.guest_memsize; 25 unsigned long memsize = vcpu->kvm->arch.guest_memsize;
26 26
27 if (guestaddr < 2 * PAGE_SIZE) 27 if (guestaddr < 2 * PAGE_SIZE)
28 guestaddr += prefix; 28 guestaddr += prefix;
@@ -37,7 +37,7 @@ static inline void __user *__guestaddr_to_user(struct kvm_vcpu *vcpu,
37 return (void __user *) guestaddr; 37 return (void __user *) guestaddr;
38} 38}
39 39
40static inline int get_guest_u64(struct kvm_vcpu *vcpu, u64 guestaddr, 40static inline int get_guest_u64(struct kvm_vcpu *vcpu, unsigned long guestaddr,
41 u64 *result) 41 u64 *result)
42{ 42{
43 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 43 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -47,10 +47,10 @@ static inline int get_guest_u64(struct kvm_vcpu *vcpu, u64 guestaddr,
47 if (IS_ERR((void __force *) uptr)) 47 if (IS_ERR((void __force *) uptr))
48 return PTR_ERR((void __force *) uptr); 48 return PTR_ERR((void __force *) uptr);
49 49
50 return get_user(*result, (u64 __user *) uptr); 50 return get_user(*result, (unsigned long __user *) uptr);
51} 51}
52 52
53static inline int get_guest_u32(struct kvm_vcpu *vcpu, u64 guestaddr, 53static inline int get_guest_u32(struct kvm_vcpu *vcpu, unsigned long guestaddr,
54 u32 *result) 54 u32 *result)
55{ 55{
56 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 56 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -63,7 +63,7 @@ static inline int get_guest_u32(struct kvm_vcpu *vcpu, u64 guestaddr,
63 return get_user(*result, (u32 __user *) uptr); 63 return get_user(*result, (u32 __user *) uptr);
64} 64}
65 65
66static inline int get_guest_u16(struct kvm_vcpu *vcpu, u64 guestaddr, 66static inline int get_guest_u16(struct kvm_vcpu *vcpu, unsigned long guestaddr,
67 u16 *result) 67 u16 *result)
68{ 68{
69 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 69 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -76,7 +76,7 @@ static inline int get_guest_u16(struct kvm_vcpu *vcpu, u64 guestaddr,
76 return get_user(*result, (u16 __user *) uptr); 76 return get_user(*result, (u16 __user *) uptr);
77} 77}
78 78
79static inline int get_guest_u8(struct kvm_vcpu *vcpu, u64 guestaddr, 79static inline int get_guest_u8(struct kvm_vcpu *vcpu, unsigned long guestaddr,
80 u8 *result) 80 u8 *result)
81{ 81{
82 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 82 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -87,7 +87,7 @@ static inline int get_guest_u8(struct kvm_vcpu *vcpu, u64 guestaddr,
87 return get_user(*result, (u8 __user *) uptr); 87 return get_user(*result, (u8 __user *) uptr);
88} 88}
89 89
90static inline int put_guest_u64(struct kvm_vcpu *vcpu, u64 guestaddr, 90static inline int put_guest_u64(struct kvm_vcpu *vcpu, unsigned long guestaddr,
91 u64 value) 91 u64 value)
92{ 92{
93 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 93 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -100,7 +100,7 @@ static inline int put_guest_u64(struct kvm_vcpu *vcpu, u64 guestaddr,
100 return put_user(value, (u64 __user *) uptr); 100 return put_user(value, (u64 __user *) uptr);
101} 101}
102 102
103static inline int put_guest_u32(struct kvm_vcpu *vcpu, u64 guestaddr, 103static inline int put_guest_u32(struct kvm_vcpu *vcpu, unsigned long guestaddr,
104 u32 value) 104 u32 value)
105{ 105{
106 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 106 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -113,7 +113,7 @@ static inline int put_guest_u32(struct kvm_vcpu *vcpu, u64 guestaddr,
113 return put_user(value, (u32 __user *) uptr); 113 return put_user(value, (u32 __user *) uptr);
114} 114}
115 115
116static inline int put_guest_u16(struct kvm_vcpu *vcpu, u64 guestaddr, 116static inline int put_guest_u16(struct kvm_vcpu *vcpu, unsigned long guestaddr,
117 u16 value) 117 u16 value)
118{ 118{
119 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 119 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -126,7 +126,7 @@ static inline int put_guest_u16(struct kvm_vcpu *vcpu, u64 guestaddr,
126 return put_user(value, (u16 __user *) uptr); 126 return put_user(value, (u16 __user *) uptr);
127} 127}
128 128
129static inline int put_guest_u8(struct kvm_vcpu *vcpu, u64 guestaddr, 129static inline int put_guest_u8(struct kvm_vcpu *vcpu, unsigned long guestaddr,
130 u8 value) 130 u8 value)
131{ 131{
132 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr); 132 void __user *uptr = __guestaddr_to_user(vcpu, guestaddr);
@@ -138,7 +138,8 @@ static inline int put_guest_u8(struct kvm_vcpu *vcpu, u64 guestaddr,
138} 138}
139 139
140 140
141static inline int __copy_to_guest_slow(struct kvm_vcpu *vcpu, u64 guestdest, 141static inline int __copy_to_guest_slow(struct kvm_vcpu *vcpu,
142 unsigned long guestdest,
142 const void *from, unsigned long n) 143 const void *from, unsigned long n)
143{ 144{
144 int rc; 145 int rc;
@@ -153,12 +154,12 @@ static inline int __copy_to_guest_slow(struct kvm_vcpu *vcpu, u64 guestdest,
153 return 0; 154 return 0;
154} 155}
155 156
156static inline int copy_to_guest(struct kvm_vcpu *vcpu, u64 guestdest, 157static inline int copy_to_guest(struct kvm_vcpu *vcpu, unsigned long guestdest,
157 const void *from, unsigned long n) 158 const void *from, unsigned long n)
158{ 159{
159 u64 prefix = vcpu->arch.sie_block->prefix; 160 unsigned long prefix = vcpu->arch.sie_block->prefix;
160 u64 origin = vcpu->kvm->arch.guest_origin; 161 unsigned long origin = vcpu->kvm->arch.guest_origin;
161 u64 memsize = vcpu->kvm->arch.guest_memsize; 162 unsigned long memsize = vcpu->kvm->arch.guest_memsize;
162 163
163 if ((guestdest < 2 * PAGE_SIZE) && (guestdest + n > 2 * PAGE_SIZE)) 164 if ((guestdest < 2 * PAGE_SIZE) && (guestdest + n > 2 * PAGE_SIZE))
164 goto slowpath; 165 goto slowpath;
@@ -189,7 +190,8 @@ slowpath:
189} 190}
190 191
191static inline int __copy_from_guest_slow(struct kvm_vcpu *vcpu, void *to, 192static inline int __copy_from_guest_slow(struct kvm_vcpu *vcpu, void *to,
192 u64 guestsrc, unsigned long n) 193 unsigned long guestsrc,
194 unsigned long n)
193{ 195{
194 int rc; 196 int rc;
195 unsigned long i; 197 unsigned long i;
@@ -204,11 +206,11 @@ static inline int __copy_from_guest_slow(struct kvm_vcpu *vcpu, void *to,
204} 206}
205 207
206static inline int copy_from_guest(struct kvm_vcpu *vcpu, void *to, 208static inline int copy_from_guest(struct kvm_vcpu *vcpu, void *to,
207 u64 guestsrc, unsigned long n) 209 unsigned long guestsrc, unsigned long n)
208{ 210{
209 u64 prefix = vcpu->arch.sie_block->prefix; 211 unsigned long prefix = vcpu->arch.sie_block->prefix;
210 u64 origin = vcpu->kvm->arch.guest_origin; 212 unsigned long origin = vcpu->kvm->arch.guest_origin;
211 u64 memsize = vcpu->kvm->arch.guest_memsize; 213 unsigned long memsize = vcpu->kvm->arch.guest_memsize;
212 214
213 if ((guestsrc < 2 * PAGE_SIZE) && (guestsrc + n > 2 * PAGE_SIZE)) 215 if ((guestsrc < 2 * PAGE_SIZE) && (guestsrc + n > 2 * PAGE_SIZE))
214 goto slowpath; 216 goto slowpath;
@@ -238,11 +240,12 @@ slowpath:
238 return __copy_from_guest_slow(vcpu, to, guestsrc, n); 240 return __copy_from_guest_slow(vcpu, to, guestsrc, n);
239} 241}
240 242
241static inline int copy_to_guest_absolute(struct kvm_vcpu *vcpu, u64 guestdest, 243static inline int copy_to_guest_absolute(struct kvm_vcpu *vcpu,
244 unsigned long guestdest,
242 const void *from, unsigned long n) 245 const void *from, unsigned long n)
243{ 246{
244 u64 origin = vcpu->kvm->arch.guest_origin; 247 unsigned long origin = vcpu->kvm->arch.guest_origin;
245 u64 memsize = vcpu->kvm->arch.guest_memsize; 248 unsigned long memsize = vcpu->kvm->arch.guest_memsize;
246 249
247 if (guestdest + n > memsize) 250 if (guestdest + n > memsize)
248 return -EFAULT; 251 return -EFAULT;
@@ -256,10 +259,11 @@ static inline int copy_to_guest_absolute(struct kvm_vcpu *vcpu, u64 guestdest,
256} 259}
257 260
258static inline int copy_from_guest_absolute(struct kvm_vcpu *vcpu, void *to, 261static inline int copy_from_guest_absolute(struct kvm_vcpu *vcpu, void *to,
259 u64 guestsrc, unsigned long n) 262 unsigned long guestsrc,
263 unsigned long n)
260{ 264{
261 u64 origin = vcpu->kvm->arch.guest_origin; 265 unsigned long origin = vcpu->kvm->arch.guest_origin;
262 u64 memsize = vcpu->kvm->arch.guest_memsize; 266 unsigned long memsize = vcpu->kvm->arch.guest_memsize;
263 267
264 if (guestsrc + n > memsize) 268 if (guestsrc + n > memsize)
265 return -EFAULT; 269 return -EFAULT;
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 47a0b642174c..61236102203e 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -20,7 +20,7 @@
20#include "kvm-s390.h" 20#include "kvm-s390.h"
21#include "gaccess.h" 21#include "gaccess.h"
22 22
23static int handle_lctg(struct kvm_vcpu *vcpu) 23static int handle_lctlg(struct kvm_vcpu *vcpu)
24{ 24{
25 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; 25 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
26 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; 26 int reg3 = vcpu->arch.sie_block->ipa & 0x000f;
@@ -30,7 +30,7 @@ static int handle_lctg(struct kvm_vcpu *vcpu)
30 u64 useraddr; 30 u64 useraddr;
31 int reg, rc; 31 int reg, rc;
32 32
33 vcpu->stat.instruction_lctg++; 33 vcpu->stat.instruction_lctlg++;
34 if ((vcpu->arch.sie_block->ipb & 0xff) != 0x2f) 34 if ((vcpu->arch.sie_block->ipb & 0xff) != 0x2f)
35 return -ENOTSUPP; 35 return -ENOTSUPP;
36 36
@@ -38,9 +38,12 @@ static int handle_lctg(struct kvm_vcpu *vcpu)
38 if (base2) 38 if (base2)
39 useraddr += vcpu->arch.guest_gprs[base2]; 39 useraddr += vcpu->arch.guest_gprs[base2];
40 40
41 if (useraddr & 7)
42 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
43
41 reg = reg1; 44 reg = reg1;
42 45
43 VCPU_EVENT(vcpu, 5, "lctg r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2, 46 VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2,
44 disp2); 47 disp2);
45 48
46 do { 49 do {
@@ -74,6 +77,9 @@ static int handle_lctl(struct kvm_vcpu *vcpu)
74 if (base2) 77 if (base2)
75 useraddr += vcpu->arch.guest_gprs[base2]; 78 useraddr += vcpu->arch.guest_gprs[base2];
76 79
80 if (useraddr & 3)
81 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
82
77 VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2, 83 VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2,
78 disp2); 84 disp2);
79 85
@@ -99,7 +105,7 @@ static intercept_handler_t instruction_handlers[256] = {
99 [0xae] = kvm_s390_handle_sigp, 105 [0xae] = kvm_s390_handle_sigp,
100 [0xb2] = kvm_s390_handle_priv, 106 [0xb2] = kvm_s390_handle_priv,
101 [0xb7] = handle_lctl, 107 [0xb7] = handle_lctl,
102 [0xeb] = handle_lctg, 108 [0xeb] = handle_lctlg,
103}; 109};
104 110
105static int handle_noop(struct kvm_vcpu *vcpu) 111static int handle_noop(struct kvm_vcpu *vcpu)
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 11230b0db957..2960702b4824 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -13,6 +13,7 @@
13#include <asm/lowcore.h> 13#include <asm/lowcore.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <linux/kvm_host.h> 15#include <linux/kvm_host.h>
16#include <linux/signal.h>
16#include "kvm-s390.h" 17#include "kvm-s390.h"
17#include "gaccess.h" 18#include "gaccess.h"
18 19
@@ -246,15 +247,10 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
246 default: 247 default:
247 BUG(); 248 BUG();
248 } 249 }
249
250 if (exception) { 250 if (exception) {
251 VCPU_EVENT(vcpu, 1, "%s", "program exception while delivering" 251 printk("kvm: The guest lowcore is not mapped during interrupt "
252 " interrupt"); 252 "delivery, killing userspace\n");
253 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 253 do_exit(SIGKILL);
254 if (inti->type == KVM_S390_PROGRAM_INT) {
255 printk(KERN_WARNING "kvm: recursive program check\n");
256 BUG();
257 }
258 } 254 }
259} 255}
260 256
@@ -277,14 +273,11 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu)
277 __LC_EXT_NEW_PSW, sizeof(psw_t)); 273 __LC_EXT_NEW_PSW, sizeof(psw_t));
278 if (rc == -EFAULT) 274 if (rc == -EFAULT)
279 exception = 1; 275 exception = 1;
280
281 if (exception) { 276 if (exception) {
282 VCPU_EVENT(vcpu, 1, "%s", "program exception while delivering" \ 277 printk("kvm: The guest lowcore is not mapped during interrupt "
283 " ckc interrupt"); 278 "delivery, killing userspace\n");
284 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 279 do_exit(SIGKILL);
285 return 0;
286 } 280 }
287
288 return 1; 281 return 1;
289} 282}
290 283
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 1782cbcd2829..8b00eb2ddf57 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -39,7 +39,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
39 { "exit_instruction", VCPU_STAT(exit_instruction) }, 39 { "exit_instruction", VCPU_STAT(exit_instruction) },
40 { "exit_program_interruption", VCPU_STAT(exit_program_interruption) }, 40 { "exit_program_interruption", VCPU_STAT(exit_program_interruption) },
41 { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) }, 41 { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) },
42 { "instruction_lctg", VCPU_STAT(instruction_lctg) }, 42 { "instruction_lctlg", VCPU_STAT(instruction_lctlg) },
43 { "instruction_lctl", VCPU_STAT(instruction_lctl) }, 43 { "instruction_lctl", VCPU_STAT(instruction_lctl) },
44 { "deliver_emergency_signal", VCPU_STAT(deliver_emergency_signal) }, 44 { "deliver_emergency_signal", VCPU_STAT(deliver_emergency_signal) },
45 { "deliver_service_signal", VCPU_STAT(deliver_service_signal) }, 45 { "deliver_service_signal", VCPU_STAT(deliver_service_signal) },
@@ -112,7 +112,12 @@ long kvm_arch_dev_ioctl(struct file *filp,
112 112
113int kvm_dev_ioctl_check_extension(long ext) 113int kvm_dev_ioctl_check_extension(long ext)
114{ 114{
115 return 0; 115 switch (ext) {
116 case KVM_CAP_USER_MEMORY:
117 return 1;
118 default:
119 return 0;
120 }
116} 121}
117 122
118/* Section: vm related */ 123/* Section: vm related */
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 5a556114eaa5..170392687ce0 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -43,7 +43,8 @@
43#define SIGP_STAT_RECEIVER_CHECK 0x00000001UL 43#define SIGP_STAT_RECEIVER_CHECK 0x00000001UL
44 44
45 45
46static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, u64 *reg) 46static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
47 unsigned long *reg)
47{ 48{
48 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 49 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
49 int rc; 50 int rc;
@@ -167,7 +168,7 @@ static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
167} 168}
168 169
169static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, 170static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
170 u64 *reg) 171 unsigned long *reg)
171{ 172{
172 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 173 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
173 struct kvm_s390_local_interrupt *li; 174 struct kvm_s390_local_interrupt *li;
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 388cc7420055..4993b0f594eb 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -42,38 +42,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
42pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); 42pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
43char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); 43char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
44 44
45void show_mem(void)
46{
47 unsigned long i, total = 0, reserved = 0;
48 unsigned long shared = 0, cached = 0;
49 unsigned long flags;
50 struct page *page;
51 pg_data_t *pgdat;
52
53 printk("Mem-info:\n");
54 show_free_areas();
55 for_each_online_pgdat(pgdat) {
56 pgdat_resize_lock(pgdat, &flags);
57 for (i = 0; i < pgdat->node_spanned_pages; i++) {
58 if (!pfn_valid(pgdat->node_start_pfn + i))
59 continue;
60 page = pfn_to_page(pgdat->node_start_pfn + i);
61 total++;
62 if (PageReserved(page))
63 reserved++;
64 else if (PageSwapCache(page))
65 cached++;
66 else if (page_count(page))
67 shared += page_count(page) - 1;
68 }
69 pgdat_resize_unlock(pgdat, &flags);
70 }
71 printk("%ld pages of RAM\n", total);
72 printk("%ld reserved pages\n", reserved);
73 printk("%ld pages shared\n", shared);
74 printk("%ld pages swap cached\n", cached);
75}
76
77/* 45/*
78 * paging_init() sets up the page tables 46 * paging_init() sets up the page tables
79 */ 47 */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 8879938f3356..0b88dc462d73 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -11,6 +11,7 @@ config SUPERH
11 select HAVE_CLK 11 select HAVE_CLK
12 select HAVE_IDE 12 select HAVE_IDE
13 select HAVE_OPROFILE 13 select HAVE_OPROFILE
14 select HAVE_GENERIC_DMA_COHERENT
14 help 15 help
15 The SuperH is a RISC processor targeted for use in embedded systems 16 The SuperH is a RISC processor targeted for use in embedded systems
16 and consumer electronics; it was also used in the Sega Dreamcast 17 and consumer electronics; it was also used in the Sega Dreamcast
@@ -477,6 +478,10 @@ config SH_RTS7751R2D
477 Select RTS7751R2D if configuring for a Renesas Technology 478 Select RTS7751R2D if configuring for a Renesas Technology
478 Sales SH-Graphics board. 479 Sales SH-Graphics board.
479 480
481config SH_RSK7203
482 bool "RSK7203"
483 depends on CPU_SUBTYPE_SH7203
484
480config SH_SDK7780 485config SH_SDK7780
481 bool "SDK7780R3" 486 bool "SDK7780R3"
482 depends on CPU_SUBTYPE_SH7780 487 depends on CPU_SUBTYPE_SH7780
@@ -491,6 +496,21 @@ config SH_HIGHLANDER
491 select SYS_SUPPORTS_PCI 496 select SYS_SUPPORTS_PCI
492 select IO_TRAPPED 497 select IO_TRAPPED
493 498
499config SH_SH7785LCR
500 bool "SH7785LCR"
501 depends on CPU_SUBTYPE_SH7785
502 select SYS_SUPPORTS_PCI
503 select IO_TRAPPED
504
505config SH_SH7785LCR_29BIT_PHYSMAPS
506 bool "SH7785LCR 29bit physmaps"
507 depends on SH_SH7785LCR
508 default y
509 help
510 This board has 2 physical memory maps. It can be changed with
511 DIP switch(S2-5). If you set the DIP switch for S2-5 = ON,
512 you can access all on-board device in 29bit address mode.
513
494config SH_MIGOR 514config SH_MIGOR
495 bool "Migo-R" 515 bool "Migo-R"
496 depends on CPU_SUBTYPE_SH7722 516 depends on CPU_SUBTYPE_SH7722
@@ -498,6 +518,20 @@ config SH_MIGOR
498 Select Migo-R if configuring for the SH7722 Migo-R platform 518 Select Migo-R if configuring for the SH7722 Migo-R platform
499 by Renesas System Solutions Asia Pte. Ltd. 519 by Renesas System Solutions Asia Pte. Ltd.
500 520
521config SH_AP325RXA
522 bool "AP-325RXA"
523 depends on CPU_SUBTYPE_SH7723
524 help
525 Renesas "AP-325RXA" support.
526 Compatible with ALGO SYSTEM CO.,LTD. "AP-320A"
527
528config SH_SH7763RDP
529 bool "SH7763RDP"
530 depends on CPU_SUBTYPE_SH7763
531 help
532 Select SH7763RDP if configuring for a Renesas SH7763
533 evaluation board.
534
501config SH_EDOSK7705 535config SH_EDOSK7705
502 bool "EDOSK7705" 536 bool "EDOSK7705"
503 depends on CPU_SUBTYPE_SH7705 537 depends on CPU_SUBTYPE_SH7705
@@ -559,6 +593,7 @@ endmenu
559source "arch/sh/boards/renesas/rts7751r2d/Kconfig" 593source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
560source "arch/sh/boards/renesas/r7780rp/Kconfig" 594source "arch/sh/boards/renesas/r7780rp/Kconfig"
561source "arch/sh/boards/renesas/sdk7780/Kconfig" 595source "arch/sh/boards/renesas/sdk7780/Kconfig"
596source "arch/sh/boards/renesas/migor/Kconfig"
562source "arch/sh/boards/magicpanelr2/Kconfig" 597source "arch/sh/boards/magicpanelr2/Kconfig"
563 598
564menu "Timer and clock configuration" 599menu "Timer and clock configuration"
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 0f4549860226..36f4b1f7066d 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -36,7 +36,8 @@ config EARLY_SCIF_CONSOLE_PORT
36 default "0xff804000" if CPU_SUBTYPE_MXG 36 default "0xff804000" if CPU_SUBTYPE_MXG
37 default "0xffc30000" if CPU_SUBTYPE_SHX3 37 default "0xffc30000" if CPU_SUBTYPE_SHX3
38 default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 || \ 38 default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 || \
39 CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366 39 CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366 || \
40 CPU_SUBTYPE_SH7343
40 default "0xffe80000" if CPU_SH4 41 default "0xffe80000" if CPU_SH4
41 default "0xffea0000" if CPU_SUBTYPE_SH7785 42 default "0xffea0000" if CPU_SUBTYPE_SH7785
42 default "0xfffe8000" if CPU_SUBTYPE_SH7203 43 default "0xfffe8000" if CPU_SUBTYPE_SH7203
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index fb7b1b15e392..c627e45c4df7 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -121,6 +121,10 @@ machdir-$(CONFIG_SH_HIGHLANDER) += renesas/r7780rp
121machdir-$(CONFIG_SH_MIGOR) += renesas/migor 121machdir-$(CONFIG_SH_MIGOR) += renesas/migor
122machdir-$(CONFIG_SH_SDK7780) += renesas/sdk7780 122machdir-$(CONFIG_SH_SDK7780) += renesas/sdk7780
123machdir-$(CONFIG_SH_X3PROTO) += renesas/x3proto 123machdir-$(CONFIG_SH_X3PROTO) += renesas/x3proto
124machdir-$(CONFIG_SH_RSK7203) += renesas/rsk7203
125machdir-$(CONFIG_SH_AP325RXA) += renesas/ap325rxa
126machdir-$(CONFIG_SH_SH7763RDP) += renesas/sh7763rdp
127machdir-$(CONFIG_SH_SH7785LCR) += renesas/sh7785lcr
124machdir-$(CONFIG_SH_SH4202_MICRODEV) += superh/microdev 128machdir-$(CONFIG_SH_SH4202_MICRODEV) += superh/microdev
125machdir-$(CONFIG_SH_LANDISK) += landisk 129machdir-$(CONFIG_SH_LANDISK) += landisk
126machdir-$(CONFIG_SH_TITAN) += titan 130machdir-$(CONFIG_SH_TITAN) += titan
diff --git a/arch/sh/boards/dreamcast/rtc.c b/arch/sh/boards/dreamcast/rtc.c
index b3a876a3b859..a7433685798d 100644
--- a/arch/sh/boards/dreamcast/rtc.c
+++ b/arch/sh/boards/dreamcast/rtc.c
@@ -30,7 +30,7 @@
30 * 30 *
31 * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch. 31 * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch.
32 */ 32 */
33void aica_rtc_gettimeofday(struct timespec *ts) 33static void aica_rtc_gettimeofday(struct timespec *ts)
34{ 34{
35 unsigned long val1, val2; 35 unsigned long val1, val2;
36 36
@@ -54,7 +54,7 @@ void aica_rtc_gettimeofday(struct timespec *ts)
54 * 54 *
55 * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. 55 * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.
56 */ 56 */
57int aica_rtc_settimeofday(const time_t secs) 57static int aica_rtc_settimeofday(const time_t secs)
58{ 58{
59 unsigned long val1, val2; 59 unsigned long val1, val2;
60 unsigned long adj = secs + TWENTY_YEARS; 60 unsigned long adj = secs + TWENTY_YEARS;
diff --git a/arch/sh/boards/renesas/ap325rxa/Makefile b/arch/sh/boards/renesas/ap325rxa/Makefile
new file mode 100644
index 000000000000..f663768429f0
--- /dev/null
+++ b/arch/sh/boards/renesas/ap325rxa/Makefile
@@ -0,0 +1 @@
obj-y := setup.o
diff --git a/arch/sh/boards/renesas/ap325rxa/setup.c b/arch/sh/boards/renesas/ap325rxa/setup.c
new file mode 100644
index 000000000000..7fa74462bd9f
--- /dev/null
+++ b/arch/sh/boards/renesas/ap325rxa/setup.c
@@ -0,0 +1,313 @@
1/*
2 * Renesas - AP-325RXA
3 * (Compatible with Algo System ., LTD. - AP-320A)
4 *
5 * Copyright (C) 2008 Renesas Solutions Corp.
6 * Author : Yusuke Goda <goda.yuske@renesas.com>
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/init.h>
14#include <linux/device.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/mtd/physmap.h>
18#include <linux/delay.h>
19#include <linux/i2c.h>
20#include <linux/delay.h>
21#include <linux/smc911x.h>
22#include <media/soc_camera_platform.h>
23#include <media/sh_mobile_ceu.h>
24#include <asm/sh_mobile_lcdc.h>
25#include <asm/io.h>
26#include <asm/clock.h>
27
28static struct smc911x_platdata smc911x_info = {
29 .flags = SMC911X_USE_32BIT,
30 .irq_flags = IRQF_TRIGGER_LOW,
31};
32
33static struct resource smc9118_resources[] = {
34 [0] = {
35 .start = 0xb6080000,
36 .end = 0xb60fffff,
37 .flags = IORESOURCE_MEM,
38 },
39 [1] = {
40 .start = 35,
41 .end = 35,
42 .flags = IORESOURCE_IRQ,
43 }
44};
45
46static struct platform_device smc9118_device = {
47 .name = "smc911x",
48 .id = -1,
49 .num_resources = ARRAY_SIZE(smc9118_resources),
50 .resource = smc9118_resources,
51 .dev = {
52 .platform_data = &smc911x_info,
53 },
54};
55
56static struct mtd_partition ap325rxa_nor_flash_partitions[] = {
57 {
58 .name = "uboot",
59 .offset = 0,
60 .size = (1 * 1024 * 1024),
61 .mask_flags = MTD_WRITEABLE, /* Read-only */
62 }, {
63 .name = "kernel",
64 .offset = MTDPART_OFS_APPEND,
65 .size = (2 * 1024 * 1024),
66 }, {
67 .name = "other",
68 .offset = MTDPART_OFS_APPEND,
69 .size = MTDPART_SIZ_FULL,
70 },
71};
72
73static struct physmap_flash_data ap325rxa_nor_flash_data = {
74 .width = 2,
75 .parts = ap325rxa_nor_flash_partitions,
76 .nr_parts = ARRAY_SIZE(ap325rxa_nor_flash_partitions),
77};
78
79static struct resource ap325rxa_nor_flash_resources[] = {
80 [0] = {
81 .name = "NOR Flash",
82 .start = 0x00000000,
83 .end = 0x00ffffff,
84 .flags = IORESOURCE_MEM,
85 }
86};
87
88static struct platform_device ap325rxa_nor_flash_device = {
89 .name = "physmap-flash",
90 .resource = ap325rxa_nor_flash_resources,
91 .num_resources = ARRAY_SIZE(ap325rxa_nor_flash_resources),
92 .dev = {
93 .platform_data = &ap325rxa_nor_flash_data,
94 },
95};
96
97#define FPGA_LCDREG 0xB4100180
98#define FPGA_BKLREG 0xB4100212
99#define FPGA_LCDREG_VAL 0x0018
100#define PORT_PHCR 0xA405010E
101#define PORT_PLCR 0xA4050114
102#define PORT_PMCR 0xA4050116
103#define PORT_PRCR 0xA405011C
104#define PORT_PSCR 0xA405011E
105#define PORT_PZCR 0xA405014C
106#define PORT_HIZCRA 0xA4050158
107#define PORT_MSELCRB 0xA4050182
108#define PORT_PSDR 0xA405013E
109#define PORT_PZDR 0xA405016C
110#define PORT_PSELD 0xA4050154
111
112static void ap320_wvga_power_on(void *board_data)
113{
114 msleep(100);
115
116 /* ASD AP-320/325 LCD ON */
117 ctrl_outw(FPGA_LCDREG_VAL, FPGA_LCDREG);
118
119 /* backlight */
120 ctrl_outw((ctrl_inw(PORT_PSCR) & ~0x00C0) | 0x40, PORT_PSCR);
121 ctrl_outb(ctrl_inb(PORT_PSDR) & ~0x08, PORT_PSDR);
122 ctrl_outw(0x100, FPGA_BKLREG);
123}
124
125static struct sh_mobile_lcdc_info lcdc_info = {
126 .clock_source = LCDC_CLK_EXTERNAL,
127 .ch[0] = {
128 .chan = LCDC_CHAN_MAINLCD,
129 .bpp = 16,
130 .interface_type = RGB18,
131 .clock_divider = 1,
132 .lcd_cfg = {
133 .name = "LB070WV1",
134 .xres = 800,
135 .yres = 480,
136 .left_margin = 40,
137 .right_margin = 160,
138 .hsync_len = 8,
139 .upper_margin = 63,
140 .lower_margin = 80,
141 .vsync_len = 1,
142 .sync = 0, /* hsync and vsync are active low */
143 },
144 .board_cfg = {
145 .display_on = ap320_wvga_power_on,
146 },
147 }
148};
149
150static struct resource lcdc_resources[] = {
151 [0] = {
152 .name = "LCDC",
153 .start = 0xfe940000, /* P4-only space */
154 .end = 0xfe941fff,
155 .flags = IORESOURCE_MEM,
156 },
157};
158
159static struct platform_device lcdc_device = {
160 .name = "sh_mobile_lcdc_fb",
161 .num_resources = ARRAY_SIZE(lcdc_resources),
162 .resource = lcdc_resources,
163 .dev = {
164 .platform_data = &lcdc_info,
165 },
166};
167
168static unsigned char camera_ncm03j_magic[] =
169{
170 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8,
171 0x1D, 0x00, 0x1E, 0x8A, 0x21, 0x00, 0x33, 0x36,
172 0x36, 0x60, 0x37, 0x08, 0x3B, 0x31, 0x44, 0x0F,
173 0x46, 0xF0, 0x4B, 0x28, 0x4C, 0x21, 0x4D, 0x55,
174 0x4E, 0x1B, 0x4F, 0xC7, 0x50, 0xFC, 0x51, 0x12,
175 0x58, 0x02, 0x66, 0xC0, 0x67, 0x46, 0x6B, 0xA0,
176 0x6C, 0x34, 0x7E, 0x25, 0x7F, 0x25, 0x8D, 0x0F,
177 0x92, 0x40, 0x93, 0x04, 0x94, 0x26, 0x95, 0x0A,
178 0x99, 0x03, 0x9A, 0xF0, 0x9B, 0x14, 0x9D, 0x7A,
179 0xC5, 0x02, 0xD6, 0x07, 0x59, 0x00, 0x5A, 0x1A,
180 0x5B, 0x2A, 0x5C, 0x37, 0x5D, 0x42, 0x5E, 0x56,
181 0xC8, 0x00, 0xC9, 0x1A, 0xCA, 0x2A, 0xCB, 0x37,
182 0xCC, 0x42, 0xCD, 0x56, 0xCE, 0x00, 0xCF, 0x1A,
183 0xD0, 0x2A, 0xD1, 0x37, 0xD2, 0x42, 0xD3, 0x56,
184 0x5F, 0x68, 0x60, 0x87, 0x61, 0xA3, 0x62, 0xBC,
185 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F,
186};
187
188static int camera_set_capture(struct soc_camera_platform_info *info,
189 int enable)
190{
191 struct i2c_adapter *a = i2c_get_adapter(0);
192 struct i2c_msg msg;
193 int ret = 0;
194 int i;
195
196 if (!enable)
197 return 0; /* no disable for now */
198
199 for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) {
200 u_int8_t buf[8];
201
202 msg.addr = 0x6e;
203 msg.buf = buf;
204 msg.len = 2;
205 msg.flags = 0;
206
207 buf[0] = camera_ncm03j_magic[i];
208 buf[1] = camera_ncm03j_magic[i + 1];
209
210 ret = (ret < 0) ? ret : i2c_transfer(a, &msg, 1);
211 }
212
213 return ret;
214}
215
216static struct soc_camera_platform_info camera_info = {
217 .iface = 0,
218 .format_name = "UYVY",
219 .format_depth = 16,
220 .format = {
221 .pixelformat = V4L2_PIX_FMT_UYVY,
222 .colorspace = V4L2_COLORSPACE_SMPTE170M,
223 .width = 640,
224 .height = 480,
225 },
226 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
227 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
228 .set_capture = camera_set_capture,
229};
230
231static struct platform_device camera_device = {
232 .name = "soc_camera_platform",
233 .dev = {
234 .platform_data = &camera_info,
235 },
236};
237
238static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
239 .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
240 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
241};
242
243static struct resource ceu_resources[] = {
244 [0] = {
245 .name = "CEU",
246 .start = 0xfe910000,
247 .end = 0xfe91009f,
248 .flags = IORESOURCE_MEM,
249 },
250 [1] = {
251 .start = 52,
252 .flags = IORESOURCE_IRQ,
253 },
254 [2] = {
255 /* place holder for contiguous memory */
256 },
257};
258
259static struct platform_device ceu_device = {
260 .name = "sh_mobile_ceu",
261 .num_resources = ARRAY_SIZE(ceu_resources),
262 .resource = ceu_resources,
263 .dev = {
264 .platform_data = &sh_mobile_ceu_info,
265 },
266};
267
268static struct platform_device *ap325rxa_devices[] __initdata = {
269 &smc9118_device,
270 &ap325rxa_nor_flash_device,
271 &lcdc_device,
272 &ceu_device,
273 &camera_device,
274};
275
276static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = {
277};
278
279static int __init ap325rxa_devices_setup(void)
280{
281 clk_always_enable("mstp200"); /* LCDC */
282 clk_always_enable("mstp203"); /* CEU */
283
284 platform_resource_setup_memory(&ceu_device, "ceu", 4 << 20);
285
286 i2c_register_board_info(0, ap325rxa_i2c_devices,
287 ARRAY_SIZE(ap325rxa_i2c_devices));
288
289 return platform_add_devices(ap325rxa_devices,
290 ARRAY_SIZE(ap325rxa_devices));
291}
292device_initcall(ap325rxa_devices_setup);
293
294static void __init ap325rxa_setup(char **cmdline_p)
295{
296 /* LCDC configuration */
297 ctrl_outw(ctrl_inw(PORT_PHCR) & ~0xffff, PORT_PHCR);
298 ctrl_outw(ctrl_inw(PORT_PLCR) & ~0xffff, PORT_PLCR);
299 ctrl_outw(ctrl_inw(PORT_PMCR) & ~0xffff, PORT_PMCR);
300 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x03ff, PORT_PRCR);
301 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01C0, PORT_HIZCRA);
302
303 /* CEU */
304 ctrl_outw(ctrl_inw(PORT_MSELCRB) & ~0x0001, PORT_MSELCRB);
305 ctrl_outw(ctrl_inw(PORT_PSELD) & ~0x0003, PORT_PSELD);
306 ctrl_outw((ctrl_inw(PORT_PZCR) & ~0xff00) | 0x5500, PORT_PZCR);
307 ctrl_outb((ctrl_inb(PORT_PZDR) & ~0xf0) | 0x20, PORT_PZDR);
308}
309
310static struct sh_machine_vector mv_ap325rxa __initmv = {
311 .mv_name = "AP-325RXA",
312 .mv_setup = ap325rxa_setup,
313};
diff --git a/arch/sh/boards/renesas/migor/Kconfig b/arch/sh/boards/renesas/migor/Kconfig
new file mode 100644
index 000000000000..a7b3b728ec3c
--- /dev/null
+++ b/arch/sh/boards/renesas/migor/Kconfig
@@ -0,0 +1,15 @@
1if SH_MIGOR
2
3choice
4 prompt "Migo-R LCD Panel Board Selection"
5 default SH_MIGOR_QVGA
6
7config SH_MIGOR_QVGA
8 bool "QVGA (320x240)"
9
10config SH_MIGOR_RTA_WVGA
11 bool "RTA WVGA (800x480)"
12
13endchoice
14
15endif
diff --git a/arch/sh/boards/renesas/migor/Makefile b/arch/sh/boards/renesas/migor/Makefile
index 77037567633b..5f231dd25c0e 100644
--- a/arch/sh/boards/renesas/migor/Makefile
+++ b/arch/sh/boards/renesas/migor/Makefile
@@ -1 +1,2 @@
1obj-y := setup.o 1obj-y := setup.o
2obj-$(CONFIG_SH_MIGOR_QVGA) += lcd_qvga.o
diff --git a/arch/sh/boards/renesas/migor/lcd_qvga.c b/arch/sh/boards/renesas/migor/lcd_qvga.c
new file mode 100644
index 000000000000..6e9609596448
--- /dev/null
+++ b/arch/sh/boards/renesas/migor/lcd_qvga.c
@@ -0,0 +1,165 @@
1/*
2 * Support for SuperH MigoR Quarter VGA LCD Panel
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * Based on lcd_powertip.c from Kenati Technologies Pvt Ltd.
7 * Copyright (c) 2007 Ujjwal Pande <ujjwal@kenati.com>,
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/delay.h>
15#include <linux/err.h>
16#include <linux/fb.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <asm/sh_mobile_lcdc.h>
21#include <asm/migor.h>
22
23/* LCD Module is a PH240320T according to board schematics. This module
24 * is made up of a 240x320 LCD hooked up to a R61505U (or HX8347-A01?)
25 * Driver IC. This IC is connected to the SH7722 built-in LCDC using a
26 * SYS-80 interface configured in 16 bit mode.
27 *
28 * Index 0: "Device Code Read" returns 0x1505.
29 */
30
31static void reset_lcd_module(void)
32{
33 ctrl_outb(ctrl_inb(PORT_PHDR) & ~0x04, PORT_PHDR);
34 mdelay(2);
35 ctrl_outb(ctrl_inb(PORT_PHDR) | 0x04, PORT_PHDR);
36 mdelay(1);
37}
38
39/* DB0-DB7 are connected to D1-D8, and DB8-DB15 to D10-D17 */
40
41static unsigned long adjust_reg18(unsigned short data)
42{
43 unsigned long tmp1, tmp2;
44
45 tmp1 = (data<<1 | 0x00000001) & 0x000001FF;
46 tmp2 = (data<<2 | 0x00000200) & 0x0003FE00;
47 return tmp1 | tmp2;
48}
49
50static void write_reg(void *sys_ops_handle,
51 struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
52 unsigned short reg, unsigned short data)
53{
54 sys_ops->write_index(sys_ops_handle, adjust_reg18(reg << 8 | data));
55}
56
57static void write_reg16(void *sys_ops_handle,
58 struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
59 unsigned short reg, unsigned short data)
60{
61 sys_ops->write_index(sys_ops_handle, adjust_reg18(reg));
62 sys_ops->write_data(sys_ops_handle, adjust_reg18(data));
63}
64
65static unsigned long read_reg16(void *sys_ops_handle,
66 struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
67 unsigned short reg)
68{
69 unsigned long data;
70
71 sys_ops->write_index(sys_ops_handle, adjust_reg18(reg));
72 data = sys_ops->read_data(sys_ops_handle);
73 return ((data >> 1) & 0xff) | ((data >> 2) & 0xff00);
74}
75
76static void migor_lcd_qvga_seq(void *sys_ops_handle,
77 struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
78 unsigned short const *data, int no_data)
79{
80 int i;
81
82 for (i = 0; i < no_data; i += 2)
83 write_reg16(sys_ops_handle, sys_ops, data[i], data[i + 1]);
84}
85
86static const unsigned short sync_data[] = {
87 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
88};
89
90static const unsigned short magic0_data[] = {
91 0x0060, 0x2700, 0x0008, 0x0808, 0x0090, 0x001A, 0x0007, 0x0001,
92 0x0017, 0x0001, 0x0019, 0x0000, 0x0010, 0x17B0, 0x0011, 0x0116,
93 0x0012, 0x0198, 0x0013, 0x1400, 0x0029, 0x000C, 0x0012, 0x01B8,
94};
95
96static const unsigned short magic1_data[] = {
97 0x0030, 0x0307, 0x0031, 0x0303, 0x0032, 0x0603, 0x0033, 0x0202,
98 0x0034, 0x0202, 0x0035, 0x0202, 0x0036, 0x1F1F, 0x0037, 0x0303,
99 0x0038, 0x0303, 0x0039, 0x0603, 0x003A, 0x0202, 0x003B, 0x0102,
100 0x003C, 0x0204, 0x003D, 0x0000, 0x0001, 0x0100, 0x0002, 0x0300,
101 0x0003, 0x5028, 0x0020, 0x00ef, 0x0021, 0x0000, 0x0004, 0x0000,
102 0x0009, 0x0000, 0x000A, 0x0008, 0x000C, 0x0000, 0x000D, 0x0000,
103 0x0015, 0x8000,
104};
105
106static const unsigned short magic2_data[] = {
107 0x0061, 0x0001, 0x0092, 0x0100, 0x0093, 0x0001, 0x0007, 0x0021,
108};
109
110static const unsigned short magic3_data[] = {
111 0x0010, 0x16B0, 0x0011, 0x0111, 0x0007, 0x0061,
112};
113
114int migor_lcd_qvga_setup(void *board_data, void *sohandle,
115 struct sh_mobile_lcdc_sys_bus_ops *so)
116{
117 unsigned long xres = 320;
118 unsigned long yres = 240;
119 int k;
120
121 reset_lcd_module();
122 migor_lcd_qvga_seq(sohandle, so, sync_data, ARRAY_SIZE(sync_data));
123
124 if (read_reg16(sohandle, so, 0) != 0x1505)
125 return -ENODEV;
126
127 pr_info("Migo-R QVGA LCD Module detected.\n");
128
129 migor_lcd_qvga_seq(sohandle, so, sync_data, ARRAY_SIZE(sync_data));
130 write_reg16(sohandle, so, 0x00A4, 0x0001);
131 mdelay(10);
132
133 migor_lcd_qvga_seq(sohandle, so, magic0_data, ARRAY_SIZE(magic0_data));
134 mdelay(100);
135
136 migor_lcd_qvga_seq(sohandle, so, magic1_data, ARRAY_SIZE(magic1_data));
137 write_reg16(sohandle, so, 0x0050, 0xef - (yres - 1));
138 write_reg16(sohandle, so, 0x0051, 0x00ef);
139 write_reg16(sohandle, so, 0x0052, 0x0000);
140 write_reg16(sohandle, so, 0x0053, xres - 1);
141
142 migor_lcd_qvga_seq(sohandle, so, magic2_data, ARRAY_SIZE(magic2_data));
143 mdelay(10);
144
145 migor_lcd_qvga_seq(sohandle, so, magic3_data, ARRAY_SIZE(magic3_data));
146 mdelay(40);
147
148 /* clear GRAM to avoid displaying garbage */
149
150 write_reg16(sohandle, so, 0x0020, 0x0000); /* horiz addr */
151 write_reg16(sohandle, so, 0x0021, 0x0000); /* vert addr */
152
153 for (k = 0; k < (xres * 256); k++) /* yes, 256 words per line */
154 write_reg16(sohandle, so, 0x0022, 0x0000);
155
156 write_reg16(sohandle, so, 0x0020, 0x0000); /* reset horiz addr */
157 write_reg16(sohandle, so, 0x0021, 0x0000); /* reset vert addr */
158 write_reg16(sohandle, so, 0x0007, 0x0173);
159 mdelay(40);
160
161 /* enable display */
162 write_reg(sohandle, so, 0x00, 0x22);
163 mdelay(100);
164 return 0;
165}
diff --git a/arch/sh/boards/renesas/migor/setup.c b/arch/sh/boards/renesas/migor/setup.c
index 963c99322095..7bd365ad2d06 100644
--- a/arch/sh/boards/renesas/migor/setup.c
+++ b/arch/sh/boards/renesas/migor/setup.c
@@ -15,9 +15,15 @@
15#include <linux/mtd/nand.h> 15#include <linux/mtd/nand.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/smc91x.h> 17#include <linux/smc91x.h>
18#include <linux/delay.h>
19#include <linux/clk.h>
20#include <media/soc_camera_platform.h>
21#include <media/sh_mobile_ceu.h>
22#include <asm/clock.h>
18#include <asm/machvec.h> 23#include <asm/machvec.h>
19#include <asm/io.h> 24#include <asm/io.h>
20#include <asm/sh_keysc.h> 25#include <asm/sh_keysc.h>
26#include <asm/sh_mobile_lcdc.h>
21#include <asm/migor.h> 27#include <asm/migor.h>
22 28
23/* Address IRQ Size Bus Description 29/* Address IRQ Size Bus Description
@@ -198,14 +204,237 @@ static struct platform_device migor_nand_flash_device = {
198 } 204 }
199}; 205};
200 206
207static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
208#ifdef CONFIG_SH_MIGOR_RTA_WVGA
209 .clock_source = LCDC_CLK_BUS,
210 .ch[0] = {
211 .chan = LCDC_CHAN_MAINLCD,
212 .bpp = 16,
213 .interface_type = RGB16,
214 .clock_divider = 2,
215 .lcd_cfg = {
216 .name = "LB070WV1",
217 .xres = 800,
218 .yres = 480,
219 .left_margin = 64,
220 .right_margin = 16,
221 .hsync_len = 120,
222 .upper_margin = 1,
223 .lower_margin = 17,
224 .vsync_len = 2,
225 .sync = 0,
226 },
227 }
228#endif
229#ifdef CONFIG_SH_MIGOR_QVGA
230 .clock_source = LCDC_CLK_PERIPHERAL,
231 .ch[0] = {
232 .chan = LCDC_CHAN_MAINLCD,
233 .bpp = 16,
234 .interface_type = SYS16A,
235 .clock_divider = 10,
236 .lcd_cfg = {
237 .name = "PH240320T",
238 .xres = 320,
239 .yres = 240,
240 .left_margin = 0,
241 .right_margin = 16,
242 .hsync_len = 8,
243 .upper_margin = 1,
244 .lower_margin = 17,
245 .vsync_len = 2,
246 .sync = FB_SYNC_HOR_HIGH_ACT,
247 },
248 .board_cfg = {
249 .setup_sys = migor_lcd_qvga_setup,
250 },
251 .sys_bus_cfg = {
252 .ldmt2r = 0x06000a09,
253 .ldmt3r = 0x180e3418,
254 },
255 }
256#endif
257};
258
259static struct resource migor_lcdc_resources[] = {
260 [0] = {
261 .name = "LCDC",
262 .start = 0xfe940000, /* P4-only space */
263 .end = 0xfe941fff,
264 .flags = IORESOURCE_MEM,
265 },
266};
267
268static struct platform_device migor_lcdc_device = {
269 .name = "sh_mobile_lcdc_fb",
270 .num_resources = ARRAY_SIZE(migor_lcdc_resources),
271 .resource = migor_lcdc_resources,
272 .dev = {
273 .platform_data = &sh_mobile_lcdc_info,
274 },
275};
276
277static struct clk *camera_clk;
278
279static void camera_power_on(void)
280{
281 unsigned char value;
282
283 camera_clk = clk_get(NULL, "video_clk");
284 clk_set_rate(camera_clk, 24000000);
285 clk_enable(camera_clk); /* start VIO_CKO */
286
287 mdelay(10);
288 value = ctrl_inb(PORT_PTDR);
289 value &= ~0x09;
290#ifndef CONFIG_SH_MIGOR_RTA_WVGA
291 value |= 0x01;
292#endif
293 ctrl_outb(value, PORT_PTDR);
294 mdelay(10);
295
296 ctrl_outb(value | 8, PORT_PTDR);
297}
298
299static void camera_power_off(void)
300{
301 clk_disable(camera_clk); /* stop VIO_CKO */
302 clk_put(camera_clk);
303
304 ctrl_outb(ctrl_inb(PORT_PTDR) & ~0x08, PORT_PTDR);
305}
306
307static unsigned char camera_ov772x_magic[] =
308{
309 0x09, 0x01, 0x0c, 0x10, 0x0d, 0x41, 0x0e, 0x01,
310 0x12, 0x00, 0x13, 0x8F, 0x14, 0x4A, 0x15, 0x00,
311 0x16, 0x00, 0x17, 0x23, 0x18, 0xa0, 0x19, 0x07,
312 0x1a, 0xf0, 0x1b, 0x40, 0x1f, 0x00, 0x20, 0x10,
313 0x22, 0xff, 0x23, 0x01, 0x28, 0x00, 0x29, 0xa0,
314 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0xf0, 0x2d, 0x00,
315 0x2e, 0x00, 0x30, 0x80, 0x31, 0x60, 0x32, 0x00,
316 0x33, 0x00, 0x34, 0x00, 0x3d, 0x80, 0x3e, 0xe2,
317 0x3f, 0x1f, 0x42, 0x80, 0x43, 0x80, 0x44, 0x80,
318 0x45, 0x80, 0x46, 0x00, 0x47, 0x00, 0x48, 0x00,
319 0x49, 0x50, 0x4a, 0x30, 0x4b, 0x50, 0x4c, 0x50,
320 0x4d, 0x00, 0x4e, 0xef, 0x4f, 0x10, 0x50, 0x60,
321 0x51, 0x00, 0x52, 0x00, 0x53, 0x24, 0x54, 0x7a,
322 0x55, 0xfc, 0x62, 0xff, 0x63, 0xf0, 0x64, 0x1f,
323 0x65, 0x00, 0x66, 0x10, 0x67, 0x00, 0x68, 0x00,
324 0x69, 0x5c, 0x6a, 0x11, 0x6b, 0xa2, 0x6c, 0x01,
325 0x6d, 0x50, 0x6e, 0x80, 0x6f, 0x80, 0x70, 0x0f,
326 0x71, 0x00, 0x72, 0x00, 0x73, 0x0f, 0x74, 0x0f,
327 0x75, 0xff, 0x78, 0x10, 0x79, 0x70, 0x7a, 0x70,
328 0x7b, 0xf0, 0x7c, 0xf0, 0x7d, 0xf0, 0x7e, 0x0e,
329 0x7f, 0x1a, 0x80, 0x31, 0x81, 0x5a, 0x82, 0x69,
330 0x83, 0x75, 0x84, 0x7e, 0x85, 0x88, 0x86, 0x8f,
331 0x87, 0x96, 0x88, 0xa3, 0x89, 0xaf, 0x8a, 0xc4,
332 0x8b, 0xd7, 0x8c, 0xe8, 0x8d, 0x20, 0x8e, 0x00,
333 0x8f, 0x00, 0x90, 0x08, 0x91, 0x10, 0x92, 0x1f,
334 0x93, 0x01, 0x94, 0x2c, 0x95, 0x24, 0x96, 0x08,
335 0x97, 0x14, 0x98, 0x24, 0x99, 0x38, 0x9a, 0x9e,
336 0x9b, 0x00, 0x9c, 0x40, 0x9e, 0x11, 0x9f, 0x02,
337 0xa0, 0x00, 0xa1, 0x40, 0xa2, 0x40, 0xa3, 0x06,
338 0xa4, 0x00, 0xa6, 0x00, 0xa7, 0x40, 0xa8, 0x40,
339 0xa9, 0x80, 0xaa, 0x80, 0xab, 0x06, 0xac, 0xff,
340 0x12, 0x06, 0x64, 0x3f, 0x12, 0x46, 0x17, 0x3f,
341 0x18, 0x50, 0x19, 0x03, 0x1a, 0x78, 0x29, 0x50,
342 0x2c, 0x78,
343};
344
345static int ov772x_set_capture(struct soc_camera_platform_info *info,
346 int enable)
347{
348 struct i2c_adapter *a = i2c_get_adapter(0);
349 struct i2c_msg msg;
350 int ret = 0;
351 int i;
352
353 if (!enable)
354 return 0; /* camera_power_off() is enough */
355
356 for (i = 0; i < ARRAY_SIZE(camera_ov772x_magic); i += 2) {
357 u_int8_t buf[8];
358
359 msg.addr = 0x21;
360 msg.buf = buf;
361 msg.len = 2;
362 msg.flags = 0;
363
364 buf[0] = camera_ov772x_magic[i];
365 buf[1] = camera_ov772x_magic[i + 1];
366
367 ret = (ret < 0) ? ret : i2c_transfer(a, &msg, 1);
368 }
369
370 return ret;
371}
372
373static struct soc_camera_platform_info ov772x_info = {
374 .iface = 0,
375 .format_name = "RGB565",
376 .format_depth = 16,
377 .format = {
378 .pixelformat = V4L2_PIX_FMT_RGB565,
379 .colorspace = V4L2_COLORSPACE_SRGB,
380 .width = 320,
381 .height = 240,
382 },
383 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
384 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
385 .set_capture = ov772x_set_capture,
386};
387
388static struct platform_device migor_camera_device = {
389 .name = "soc_camera_platform",
390 .dev = {
391 .platform_data = &ov772x_info,
392 },
393};
394
395static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
396 .flags = SOCAM_MASTER | SOCAM_DATAWIDTH_8 | SOCAM_PCLK_SAMPLE_RISING \
397 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_HIGH,
398 .enable_camera = camera_power_on,
399 .disable_camera = camera_power_off,
400};
401
402static struct resource migor_ceu_resources[] = {
403 [0] = {
404 .name = "CEU",
405 .start = 0xfe910000,
406 .end = 0xfe91009f,
407 .flags = IORESOURCE_MEM,
408 },
409 [1] = {
410 .start = 52,
411 .flags = IORESOURCE_IRQ,
412 },
413 [2] = {
414 /* place holder for contiguous memory */
415 },
416};
417
418static struct platform_device migor_ceu_device = {
419 .name = "sh_mobile_ceu",
420 .num_resources = ARRAY_SIZE(migor_ceu_resources),
421 .resource = migor_ceu_resources,
422 .dev = {
423 .platform_data = &sh_mobile_ceu_info,
424 },
425};
426
201static struct platform_device *migor_devices[] __initdata = { 427static struct platform_device *migor_devices[] __initdata = {
202 &smc91x_eth_device, 428 &smc91x_eth_device,
203 &sh_keysc_device, 429 &sh_keysc_device,
430 &migor_lcdc_device,
431 &migor_ceu_device,
432 &migor_camera_device,
204 &migor_nor_flash_device, 433 &migor_nor_flash_device,
205 &migor_nand_flash_device, 434 &migor_nand_flash_device,
206}; 435};
207 436
208static struct i2c_board_info __initdata migor_i2c_devices[] = { 437static struct i2c_board_info migor_i2c_devices[] = {
209 { 438 {
210 I2C_BOARD_INFO("rs5c372b", 0x32), 439 I2C_BOARD_INFO("rs5c372b", 0x32),
211 }, 440 },
@@ -217,6 +446,12 @@ static struct i2c_board_info __initdata migor_i2c_devices[] = {
217 446
218static int __init migor_devices_setup(void) 447static int __init migor_devices_setup(void)
219{ 448{
449 clk_always_enable("mstp214"); /* KEYSC */
450 clk_always_enable("mstp200"); /* LCDC */
451 clk_always_enable("mstp203"); /* CEU */
452
453 platform_resource_setup_memory(&migor_ceu_device, "ceu", 4 << 20);
454
220 i2c_register_board_info(0, migor_i2c_devices, 455 i2c_register_board_info(0, migor_i2c_devices,
221 ARRAY_SIZE(migor_i2c_devices)); 456 ARRAY_SIZE(migor_i2c_devices));
222 457
@@ -235,20 +470,51 @@ static void __init migor_setup(char **cmdline_p)
235 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA); 470 ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
236 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA); 471 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
237 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC); 472 ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
238 ctrl_outl(ctrl_inl(MSTPCR2) & ~0x00004000, MSTPCR2);
239 473
240 /* NAND Flash */ 474 /* NAND Flash */
241 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR); 475 ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
242 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200, 476 ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
243 BSC_CS6ABCR); 477 BSC_CS6ABCR);
244 478
245 /* I2C */
246 ctrl_outl(ctrl_inl(MSTPCR1) & ~0x00000200, MSTPCR1);
247
248 /* Touch Panel - Enable IRQ6 */ 479 /* Touch Panel - Enable IRQ6 */
249 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR); 480 ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
250 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA); 481 ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
251 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC); 482 ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
483
484#ifdef CONFIG_SH_MIGOR_RTA_WVGA
485 /* LCDC - WVGA - Enable RGB Interface signals */
486 ctrl_outw(ctrl_inw(PORT_PACR) & ~0x0003, PORT_PACR);
487 ctrl_outw(0x0000, PORT_PHCR);
488 ctrl_outw(0x0000, PORT_PLCR);
489 ctrl_outw(0x0000, PORT_PMCR);
490 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x000f, PORT_PRCR);
491 ctrl_outw((ctrl_inw(PORT_PSELD) & ~0x000d) | 0x0400, PORT_PSELD);
492 ctrl_outw(ctrl_inw(PORT_MSELCRB) & ~0x0100, PORT_MSELCRB);
493 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01e0, PORT_HIZCRA);
494#endif
495#ifdef CONFIG_SH_MIGOR_QVGA
496 /* LCDC - QVGA - Enable SYS Interface signals */
497 ctrl_outw(ctrl_inw(PORT_PACR) & ~0x0003, PORT_PACR);
498 ctrl_outw((ctrl_inw(PORT_PHCR) & ~0xcfff) | 0x0010, PORT_PHCR);
499 ctrl_outw(0x0000, PORT_PLCR);
500 ctrl_outw(0x0000, PORT_PMCR);
501 ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x030f, PORT_PRCR);
502 ctrl_outw((ctrl_inw(PORT_PSELD) & ~0x0001) | 0x0420, PORT_PSELD);
503 ctrl_outw(ctrl_inw(PORT_MSELCRB) | 0x0100, PORT_MSELCRB);
504 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01e0, PORT_HIZCRA);
505#endif
506
507 /* CEU */
508 ctrl_outw((ctrl_inw(PORT_PTCR) & ~0x03c3) | 0x0051, PORT_PTCR);
509 ctrl_outw(ctrl_inw(PORT_PUCR) & ~0x03ff, PORT_PUCR);
510 ctrl_outw(ctrl_inw(PORT_PVCR) & ~0x03ff, PORT_PVCR);
511 ctrl_outw(ctrl_inw(PORT_PWCR) & ~0x3c00, PORT_PWCR);
512 ctrl_outw(ctrl_inw(PORT_PSELC) | 0x0001, PORT_PSELC);
513 ctrl_outw(ctrl_inw(PORT_PSELD) & ~0x2000, PORT_PSELD);
514 ctrl_outw(ctrl_inw(PORT_PSELE) | 0x000f, PORT_PSELE);
515 ctrl_outw(ctrl_inw(PORT_MSELCRB) | 0x2200, PORT_MSELCRB);
516 ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x0a00, PORT_HIZCRA);
517 ctrl_outw(ctrl_inw(PORT_HIZCRB) & ~0x0003, PORT_HIZCRB);
252} 518}
253 519
254static struct sh_machine_vector mv_migor __initmv = { 520static struct sh_machine_vector mv_migor __initmv = {
diff --git a/arch/sh/boards/renesas/rsk7203/Makefile b/arch/sh/boards/renesas/rsk7203/Makefile
new file mode 100644
index 000000000000..f663768429f0
--- /dev/null
+++ b/arch/sh/boards/renesas/rsk7203/Makefile
@@ -0,0 +1 @@
obj-y := setup.o
diff --git a/arch/sh/boards/renesas/rsk7203/setup.c b/arch/sh/boards/renesas/rsk7203/setup.c
new file mode 100644
index 000000000000..0bbda04b03b9
--- /dev/null
+++ b/arch/sh/boards/renesas/rsk7203/setup.c
@@ -0,0 +1,126 @@
1/*
2 * Renesas Technology Europe RSK+ 7203 Support.
3 *
4 * Copyright (C) 2008 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/types.h>
12#include <linux/platform_device.h>
13#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h>
15#include <linux/mtd/physmap.h>
16#include <linux/mtd/map.h>
17#include <asm/machvec.h>
18#include <asm/io.h>
19
20static struct resource smc911x_resources[] = {
21 [0] = {
22 .start = 0x24000000,
23 .end = 0x24000000 + 0x100,
24 .flags = IORESOURCE_MEM,
25 },
26 [1] = {
27 .start = 64,
28 .end = 64,
29 .flags = IORESOURCE_IRQ,
30 },
31};
32
33static struct platform_device smc911x_device = {
34 .name = "smc911x",
35 .id = -1,
36 .num_resources = ARRAY_SIZE(smc911x_resources),
37 .resource = smc911x_resources,
38};
39
40static const char *probes[] = { "cmdlinepart", NULL };
41
42static struct mtd_partition *parsed_partitions;
43
44static struct mtd_partition rsk7203_partitions[] = {
45 {
46 .name = "Bootloader",
47 .offset = 0x00000000,
48 .size = 0x00040000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "Kernel",
52 .offset = MTDPART_OFS_NXTBLK,
53 .size = 0x001c0000,
54 }, {
55 .name = "Flash_FS",
56 .offset = MTDPART_OFS_NXTBLK,
57 .size = MTDPART_SIZ_FULL,
58 }
59};
60
61static struct physmap_flash_data flash_data = {
62 .width = 2,
63};
64
65static struct resource flash_resource = {
66 .start = 0x20000000,
67 .end = 0x20400000,
68 .flags = IORESOURCE_MEM,
69};
70
71static struct platform_device flash_device = {
72 .name = "physmap-flash",
73 .id = -1,
74 .resource = &flash_resource,
75 .num_resources = 1,
76 .dev = {
77 .platform_data = &flash_data,
78 },
79};
80
81static struct mtd_info *flash_mtd;
82
83static struct map_info rsk7203_flash_map = {
84 .name = "RSK+ Flash",
85 .size = 0x400000,
86 .bankwidth = 2,
87};
88
89static void __init set_mtd_partitions(void)
90{
91 int nr_parts = 0;
92
93 simple_map_init(&rsk7203_flash_map);
94 flash_mtd = do_map_probe("cfi_probe", &rsk7203_flash_map);
95 nr_parts = parse_mtd_partitions(flash_mtd, probes,
96 &parsed_partitions, 0);
97 /* If there is no partition table, used the hard coded table */
98 if (nr_parts <= 0) {
99 flash_data.parts = rsk7203_partitions;
100 flash_data.nr_parts = ARRAY_SIZE(rsk7203_partitions);
101 } else {
102 flash_data.nr_parts = nr_parts;
103 flash_data.parts = parsed_partitions;
104 }
105}
106
107
108static struct platform_device *rsk7203_devices[] __initdata = {
109 &smc911x_device,
110 &flash_device,
111};
112
113static int __init rsk7203_devices_setup(void)
114{
115 set_mtd_partitions();
116 return platform_add_devices(rsk7203_devices,
117 ARRAY_SIZE(rsk7203_devices));
118}
119device_initcall(rsk7203_devices_setup);
120
121/*
122 * The Machine Vector
123 */
124static struct sh_machine_vector mv_rsk7203 __initmv = {
125 .mv_name = "RSK+7203",
126};
diff --git a/arch/sh/boards/renesas/sh7763rdp/Makefile b/arch/sh/boards/renesas/sh7763rdp/Makefile
new file mode 100644
index 000000000000..f6c0b55516d2
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7763rdp/Makefile
@@ -0,0 +1 @@
obj-y := setup.o irq.o
diff --git a/arch/sh/boards/renesas/sh7763rdp/irq.c b/arch/sh/boards/renesas/sh7763rdp/irq.c
new file mode 100644
index 000000000000..fd850bad2dec
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7763rdp/irq.c
@@ -0,0 +1,45 @@
1/*
2 * linux/arch/sh/boards/renesas/sh7763rdp/irq.c
3 *
4 * Renesas Solutions SH7763RDP Support.
5 *
6 * Copyright (C) 2008 Renesas Solutions Corp.
7 * Copyright (C) 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <linux/init.h>
15#include <linux/irq.h>
16#include <asm/io.h>
17#include <asm/irq.h>
18#include <asm/sh7763rdp.h>
19
20#define INTC_BASE (0xFFD00000)
21#define INTC_INT2PRI7 (INTC_BASE+0x4001C)
22#define INTC_INT2MSKCR (INTC_BASE+0x4003C)
23#define INTC_INT2MSKCR1 (INTC_BASE+0x400D4)
24
25/*
26 * Initialize IRQ setting
27 */
28void __init init_sh7763rdp_IRQ(void)
29{
30 /* GPIO enabled */
31 ctrl_outl(1 << 25, INTC_INT2MSKCR);
32
33 /* enable GPIO interrupts */
34 ctrl_outl((ctrl_inl(INTC_INT2PRI7) & 0xFF00FFFF) | 0x000F0000,
35 INTC_INT2PRI7);
36
37 /* USBH enabled */
38 ctrl_outl(1 << 17, INTC_INT2MSKCR1);
39
40 /* GETHER enabled */
41 ctrl_outl(1 << 16, INTC_INT2MSKCR1);
42
43 /* DMAC enabled */
44 ctrl_outl(1 << 8, INTC_INT2MSKCR);
45}
diff --git a/arch/sh/boards/renesas/sh7763rdp/setup.c b/arch/sh/boards/renesas/sh7763rdp/setup.c
new file mode 100644
index 000000000000..925f16af7121
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7763rdp/setup.c
@@ -0,0 +1,128 @@
1/*
2 * linux/arch/sh/boards/renesas/sh7763rdp/setup.c
3 *
4 * Renesas Solutions sh7763rdp board
5 *
6 * Copyright (C) 2008 Renesas Solutions Corp.
7 * Copyright (C) 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/interrupt.h>
16#include <linux/input.h>
17#include <linux/mtd/physmap.h>
18#include <asm/io.h>
19#include <asm/sh7763rdp.h>
20
21/* NOR Flash */
22static struct mtd_partition sh7763rdp_nor_flash_partitions[] = {
23 {
24 .name = "U-Boot",
25 .offset = 0,
26 .size = (2 * 128 * 1024),
27 .mask_flags = MTD_WRITEABLE, /* Read-only */
28 }, {
29 .name = "Linux-Kernel",
30 .offset = MTDPART_OFS_APPEND,
31 .size = (20 * 128 * 1024),
32 }, {
33 .name = "Root Filesystem",
34 .offset = MTDPART_OFS_APPEND,
35 .size = MTDPART_SIZ_FULL,
36 },
37};
38
39static struct physmap_flash_data sh7763rdp_nor_flash_data = {
40 .width = 2,
41 .parts = sh7763rdp_nor_flash_partitions,
42 .nr_parts = ARRAY_SIZE(sh7763rdp_nor_flash_partitions),
43};
44
45static struct resource sh7763rdp_nor_flash_resources[] = {
46 [0] = {
47 .name = "NOR Flash",
48 .start = 0,
49 .end = (64 * 1024 * 1024),
50 .flags = IORESOURCE_MEM,
51 },
52};
53
54static struct platform_device sh7763rdp_nor_flash_device = {
55 .name = "physmap-flash",
56 .resource = sh7763rdp_nor_flash_resources,
57 .num_resources = ARRAY_SIZE(sh7763rdp_nor_flash_resources),
58 .dev = {
59 .platform_data = &sh7763rdp_nor_flash_data,
60 },
61};
62
63static struct platform_device *sh7763rdp_devices[] __initdata = {
64 &sh7763rdp_nor_flash_device,
65};
66
67static int __init sh7763rdp_devices_setup(void)
68{
69 return platform_add_devices(sh7763rdp_devices,
70 ARRAY_SIZE(sh7763rdp_devices));
71}
72__initcall(sh7763rdp_devices_setup);
73
74static void __init sh7763rdp_setup(char **cmdline_p)
75{
76 /* Board version check */
77 if (ctrl_inw(CPLD_BOARD_ID_ERV_REG) == 0xECB1)
78 printk(KERN_INFO "RTE Standard Configuration\n");
79 else
80 printk(KERN_INFO "RTA Standard Configuration\n");
81
82 /* USB pin select bits (clear bit 5-2 to 0) */
83 ctrl_outw((ctrl_inw(PORT_PSEL2) & 0xFFC3), PORT_PSEL2);
84 /* USBH setup port I controls to other (clear bits 4-9 to 0) */
85 ctrl_outw(ctrl_inw(PORT_PICR) & 0xFC0F, PORT_PICR);
86
87 /* Select USB Host controller */
88 ctrl_outw(0x00, USB_USBHSC);
89
90 /* For LCD */
91 /* set PTJ7-1, bits 15-2 of PJCR to 0 */
92 ctrl_outw(ctrl_inw(PORT_PJCR) & 0x0003, PORT_PJCR);
93 /* set PTI5, bits 11-10 of PICR to 0 */
94 ctrl_outw(ctrl_inw(PORT_PICR) & 0xF3FF, PORT_PICR);
95 ctrl_outw(0, PORT_PKCR);
96 ctrl_outw(0, PORT_PLCR);
97 /* set PSEL2 bits 14-8, 5-4, of PSEL2 to 0 */
98 ctrl_outw((ctrl_inw(PORT_PSEL2) & 0x00C0), PORT_PSEL2);
99 /* set PSEL3 bits 14-12, 6-4, 2-0 of PSEL3 to 0 */
100 ctrl_outw((ctrl_inw(PORT_PSEL3) & 0x0700), PORT_PSEL3);
101
102 /* For HAC */
103 /* bit3-0 0100:HAC & SSI1 enable */
104 ctrl_outw((ctrl_inw(PORT_PSEL1) & 0xFFF0) | 0x0004, PORT_PSEL1);
105 /* bit14 1:SSI_HAC_CLK enable */
106 ctrl_outw(ctrl_inw(PORT_PSEL4) | 0x4000, PORT_PSEL4);
107
108 /* SH-Ether */
109 ctrl_outw((ctrl_inw(PORT_PSEL1) & ~0xff00) | 0x2400, PORT_PSEL1);
110 ctrl_outw(0x0, PORT_PFCR);
111 ctrl_outw(0x0, PORT_PFCR);
112 ctrl_outw(0x0, PORT_PFCR);
113
114 /* MMC */
115 /*selects SCIF and MMC other functions */
116 ctrl_outw(0x0001, PORT_PSEL0);
117 /* MMC clock operates */
118 ctrl_outl(ctrl_inl(MSTPCR1) & ~0x8, MSTPCR1);
119 ctrl_outw(ctrl_inw(PORT_PACR) & ~0x3000, PORT_PACR);
120 ctrl_outw(ctrl_inw(PORT_PCCR) & ~0xCFC3, PORT_PCCR);
121}
122
123static struct sh_machine_vector mv_sh7763rdp __initmv = {
124 .mv_name = "sh7763drp",
125 .mv_setup = sh7763rdp_setup,
126 .mv_nr_irqs = 112,
127 .mv_init_irq = init_sh7763rdp_IRQ,
128};
diff --git a/arch/sh/boards/renesas/sh7785lcr/Makefile b/arch/sh/boards/renesas/sh7785lcr/Makefile
new file mode 100644
index 000000000000..77037567633b
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7785lcr/Makefile
@@ -0,0 +1 @@
obj-y := setup.o
diff --git a/arch/sh/boards/renesas/sh7785lcr/setup.c b/arch/sh/boards/renesas/sh7785lcr/setup.c
new file mode 100644
index 000000000000..b95d674ee704
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7785lcr/setup.c
@@ -0,0 +1,302 @@
1/*
2 * Renesas Technology Corp. R0P7785LC0011RL Support.
3 *
4 * Copyright (C) 2008 Yoshihiro Shimoda
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <linux/sm501.h>
14#include <linux/sm501-regs.h>
15#include <linux/fb.h>
16#include <linux/mtd/physmap.h>
17#include <linux/delay.h>
18#include <linux/i2c.h>
19#include <linux/i2c-pca-platform.h>
20#include <linux/i2c-algo-pca.h>
21#include <asm/heartbeat.h>
22#include <asm/sh7785lcr.h>
23
24/*
25 * NOTE: This board has 2 physical memory maps.
26 * Please look at include/asm-sh/sh7785lcr.h or hardware manual.
27 */
28static struct resource heartbeat_resources[] = {
29 [0] = {
30 .start = PLD_LEDCR,
31 .end = PLD_LEDCR,
32 .flags = IORESOURCE_MEM,
33 },
34};
35
36static struct heartbeat_data heartbeat_data = {
37 .regsize = 8,
38};
39
40static struct platform_device heartbeat_device = {
41 .name = "heartbeat",
42 .id = -1,
43 .dev = {
44 .platform_data = &heartbeat_data,
45 },
46 .num_resources = ARRAY_SIZE(heartbeat_resources),
47 .resource = heartbeat_resources,
48};
49
50static struct mtd_partition nor_flash_partitions[] = {
51 {
52 .name = "loader",
53 .offset = 0x00000000,
54 .size = 512 * 1024,
55 },
56 {
57 .name = "bootenv",
58 .offset = MTDPART_OFS_APPEND,
59 .size = 512 * 1024,
60 },
61 {
62 .name = "kernel",
63 .offset = MTDPART_OFS_APPEND,
64 .size = 4 * 1024 * 1024,
65 },
66 {
67 .name = "data",
68 .offset = MTDPART_OFS_APPEND,
69 .size = MTDPART_SIZ_FULL,
70 },
71};
72
73static struct physmap_flash_data nor_flash_data = {
74 .width = 4,
75 .parts = nor_flash_partitions,
76 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
77};
78
79static struct resource nor_flash_resources[] = {
80 [0] = {
81 .start = NOR_FLASH_ADDR,
82 .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
83 .flags = IORESOURCE_MEM,
84 }
85};
86
87static struct platform_device nor_flash_device = {
88 .name = "physmap-flash",
89 .dev = {
90 .platform_data = &nor_flash_data,
91 },
92 .num_resources = ARRAY_SIZE(nor_flash_resources),
93 .resource = nor_flash_resources,
94};
95
96static struct resource r8a66597_usb_host_resources[] = {
97 [0] = {
98 .name = "r8a66597_hcd",
99 .start = R8A66597_ADDR,
100 .end = R8A66597_ADDR + R8A66597_SIZE - 1,
101 .flags = IORESOURCE_MEM,
102 },
103 [1] = {
104 .name = "r8a66597_hcd",
105 .start = 2,
106 .end = 2,
107 .flags = IORESOURCE_IRQ,
108 },
109};
110
111static struct platform_device r8a66597_usb_host_device = {
112 .name = "r8a66597_hcd",
113 .id = -1,
114 .dev = {
115 .dma_mask = NULL,
116 .coherent_dma_mask = 0xffffffff,
117 },
118 .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
119 .resource = r8a66597_usb_host_resources,
120};
121
122static struct resource sm501_resources[] = {
123 [0] = {
124 .start = SM107_MEM_ADDR,
125 .end = SM107_MEM_ADDR + SM107_MEM_SIZE - 1,
126 .flags = IORESOURCE_MEM,
127 },
128 [1] = {
129 .start = SM107_REG_ADDR,
130 .end = SM107_REG_ADDR + SM107_REG_SIZE - 1,
131 .flags = IORESOURCE_MEM,
132 },
133 [2] = {
134 .start = 10,
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct fb_videomode sm501_default_mode_crt = {
140 .pixclock = 35714, /* 28MHz */
141 .xres = 640,
142 .yres = 480,
143 .left_margin = 105,
144 .right_margin = 16,
145 .upper_margin = 33,
146 .lower_margin = 10,
147 .hsync_len = 39,
148 .vsync_len = 2,
149 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
150};
151
152static struct fb_videomode sm501_default_mode_pnl = {
153 .pixclock = 40000, /* 25MHz */
154 .xres = 640,
155 .yres = 480,
156 .left_margin = 2,
157 .right_margin = 16,
158 .upper_margin = 33,
159 .lower_margin = 10,
160 .hsync_len = 39,
161 .vsync_len = 2,
162 .sync = 0,
163};
164
165static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
166 .def_bpp = 16,
167 .def_mode = &sm501_default_mode_pnl,
168 .flags = SM501FB_FLAG_USE_INIT_MODE |
169 SM501FB_FLAG_USE_HWCURSOR |
170 SM501FB_FLAG_USE_HWACCEL |
171 SM501FB_FLAG_DISABLE_AT_EXIT |
172 SM501FB_FLAG_PANEL_NO_VBIASEN,
173};
174
175static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
176 .def_bpp = 16,
177 .def_mode = &sm501_default_mode_crt,
178 .flags = SM501FB_FLAG_USE_INIT_MODE |
179 SM501FB_FLAG_USE_HWCURSOR |
180 SM501FB_FLAG_USE_HWACCEL |
181 SM501FB_FLAG_DISABLE_AT_EXIT,
182};
183
184static struct sm501_platdata_fb sm501_fb_pdata = {
185 .fb_route = SM501_FB_OWN,
186 .fb_crt = &sm501_pdata_fbsub_crt,
187 .fb_pnl = &sm501_pdata_fbsub_pnl,
188};
189
190static struct sm501_initdata sm501_initdata = {
191 .gpio_high = {
192 .set = 0x00001fe0,
193 .mask = 0x0,
194 },
195 .devices = 0,
196 .mclk = 84 * 1000000,
197 .m1xclk = 112 * 1000000,
198};
199
200static struct sm501_platdata sm501_platform_data = {
201 .init = &sm501_initdata,
202 .fb = &sm501_fb_pdata,
203};
204
205static struct platform_device sm501_device = {
206 .name = "sm501",
207 .id = -1,
208 .dev = {
209 .platform_data = &sm501_platform_data,
210 },
211 .num_resources = ARRAY_SIZE(sm501_resources),
212 .resource = sm501_resources,
213};
214
215static struct resource i2c_resources[] = {
216 [0] = {
217 .start = PCA9564_ADDR,
218 .end = PCA9564_ADDR + PCA9564_SIZE - 1,
219 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
220 },
221 [1] = {
222 .start = 12,
223 .end = 12,
224 .flags = IORESOURCE_IRQ,
225 },
226};
227
228static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
229 .gpio = 0,
230 .i2c_clock_speed = I2C_PCA_CON_330kHz,
231 .timeout = 100,
232};
233
234static struct platform_device i2c_device = {
235 .name = "i2c-pca-platform",
236 .id = -1,
237 .dev = {
238 .platform_data = &i2c_platform_data,
239 },
240 .num_resources = ARRAY_SIZE(i2c_resources),
241 .resource = i2c_resources,
242};
243
244static struct platform_device *sh7785lcr_devices[] __initdata = {
245 &heartbeat_device,
246 &nor_flash_device,
247 &r8a66597_usb_host_device,
248 &sm501_device,
249 &i2c_device,
250};
251
252static struct i2c_board_info __initdata sh7785lcr_i2c_devices[] = {
253 {
254 I2C_BOARD_INFO("r2025sd", 0x32),
255 },
256};
257
258static int __init sh7785lcr_devices_setup(void)
259{
260 i2c_register_board_info(0, sh7785lcr_i2c_devices,
261 ARRAY_SIZE(sh7785lcr_i2c_devices));
262
263 return platform_add_devices(sh7785lcr_devices,
264 ARRAY_SIZE(sh7785lcr_devices));
265}
266__initcall(sh7785lcr_devices_setup);
267
268/* Initialize IRQ setting */
269void __init init_sh7785lcr_IRQ(void)
270{
271 plat_irq_setup_pins(IRQ_MODE_IRQ7654);
272 plat_irq_setup_pins(IRQ_MODE_IRQ3210);
273}
274
275static void sh7785lcr_power_off(void)
276{
277 ctrl_outb(0x01, P2SEGADDR(PLD_POFCR));
278}
279
280/* Initialize the board */
281static void __init sh7785lcr_setup(char **cmdline_p)
282{
283 void __iomem *sm501_reg;
284
285 printk(KERN_INFO "Renesas Technology Corp. R0P7785LC0011RL support.\n");
286
287 pm_power_off = sh7785lcr_power_off;
288
289 /* sm501 DRAM configuration */
290 sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
291 writel(0x000307c2, sm501_reg);
292}
293
294/*
295 * The Machine Vector
296 */
297static struct sh_machine_vector mv_sh7785lcr __initmv = {
298 .mv_name = "SH7785LCR",
299 .mv_setup = sh7785lcr_setup,
300 .mv_init_irq = init_sh7785lcr_IRQ,
301};
302
diff --git a/arch/sh/boards/se/7343/irq.c b/arch/sh/boards/se/7343/irq.c
index 763f6deba814..1112e86aa93a 100644
--- a/arch/sh/boards/se/7343/irq.c
+++ b/arch/sh/boards/se/7343/irq.c
@@ -1,202 +1,80 @@
1/* 1/*
2 * arch/sh/boards/se/7343/irq.c 2 * linux/arch/sh/boards/se/7343/irq.c
3 * 3 *
4 * Copyright (C) 2008 Yoshihiro Shimoda
5 *
6 * Based on linux/arch/sh/boards/se/7722/irq.c
7 * Copyright (C) 2007 Nobuhiro Iwamatsu
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
4 */ 12 */
5#include <linux/init.h> 13#include <linux/init.h>
6#include <linux/interrupt.h>
7#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/interrupt.h>
8#include <asm/irq.h> 16#include <asm/irq.h>
9#include <asm/io.h> 17#include <asm/io.h>
10#include <asm/mach/se7343.h> 18#include <asm/se7343.h>
11 19
12static void 20static void disable_se7343_irq(unsigned int irq)
13disable_intreq_irq(unsigned int irq)
14{ 21{
15 int bit = irq - OFFCHIP_IRQ_BASE; 22 unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
16 u16 val; 23 ctrl_outw(ctrl_inw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK);
17
18 val = ctrl_inw(PA_CPLD_IMSK);
19 val |= 1 << bit;
20 ctrl_outw(val, PA_CPLD_IMSK);
21} 24}
22 25
23static void 26static void enable_se7343_irq(unsigned int irq)
24enable_intreq_irq(unsigned int irq)
25{ 27{
26 int bit = irq - OFFCHIP_IRQ_BASE; 28 unsigned int bit = irq - SE7343_FPGA_IRQ_BASE;
27 u16 val; 29 ctrl_outw(ctrl_inw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK);
28
29 val = ctrl_inw(PA_CPLD_IMSK);
30 val &= ~(1 << bit);
31 ctrl_outw(val, PA_CPLD_IMSK);
32} 30}
33 31
34static void 32static struct irq_chip se7343_irq_chip __read_mostly = {
35mask_and_ack_intreq_irq(unsigned int irq) 33 .name = "SE7343-FPGA",
36{ 34 .mask = disable_se7343_irq,
37 disable_intreq_irq(irq); 35 .unmask = enable_se7343_irq,
38} 36 .mask_ack = disable_se7343_irq,
39
40static unsigned int
41startup_intreq_irq(unsigned int irq)
42{
43 enable_intreq_irq(irq);
44 return 0;
45}
46
47static void
48shutdown_intreq_irq(unsigned int irq)
49{
50 disable_intreq_irq(irq);
51}
52
53static void
54end_intreq_irq(unsigned int irq)
55{
56 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
57 enable_intreq_irq(irq);
58}
59
60static struct hw_interrupt_type intreq_irq_type = {
61 .typename = "FPGA-IRQ",
62 .startup = startup_intreq_irq,
63 .shutdown = shutdown_intreq_irq,
64 .enable = enable_intreq_irq,
65 .disable = disable_intreq_irq,
66 .ack = mask_and_ack_intreq_irq,
67 .end = end_intreq_irq
68}; 37};
69 38
70static void 39static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
71make_intreq_irq(unsigned int irq)
72{
73 disable_irq_nosync(irq);
74 irq_desc[irq].chip = &intreq_irq_type;
75 disable_intreq_irq(irq);
76}
77
78int
79shmse_irq_demux(int irq)
80{ 40{
81 int bit; 41 unsigned short intv = ctrl_inw(PA_CPLD_ST);
82 volatile u16 val; 42 struct irq_desc *ext_desc;
83 43 unsigned int ext_irq = SE7343_FPGA_IRQ_BASE;
84 if (irq == IRQ5_IRQ) { 44
85 /* Read status Register */ 45 intv &= (1 << SE7343_FPGA_IRQ_NR) - 1;
86 val = ctrl_inw(PA_CPLD_ST); 46
87 bit = ffs(val); 47 while (intv) {
88 if (bit != 0) 48 if (intv & 1) {
89 return OFFCHIP_IRQ_BASE + bit - 1; 49 ext_desc = irq_desc + ext_irq;
50 handle_level_irq(ext_irq, ext_desc);
51 }
52 intv >>= 1;
53 ext_irq++;
90 } 54 }
91 return irq;
92} 55}
93 56
94/* IRQ5 is multiplexed between the following sources:
95 * 1. PC Card socket
96 * 2. Extension slot
97 * 3. USB Controller
98 * 4. Serial Controller
99 *
100 * We configure IRQ5 as a cascade IRQ.
101 */
102static struct irqaction irq5 = {
103 .handler = no_action,
104 .mask = CPU_MASK_NONE,
105 .name = "IRQ5-cascade",
106};
107
108static struct ipr_data se7343_irq5_ipr_map[] = {
109 { IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY },
110};
111static struct ipr_data se7343_siof0_vpu_ipr_map[] = {
112 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
113 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
114};
115static struct ipr_data se7343_other_ipr_map[] = {
116 { DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
117 { DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
118 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
119 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
120 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
121 { DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
122
123 /* I2C block */
124 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
125 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
126 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
127 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
128
129 { IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
130 { IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
131 { IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
132 { IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
133
134 /* SIOF */
135 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
136
137 /* SIU */
138 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
139
140 /* VIO interrupt */
141 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
142 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
143 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
144
145 /*MFI interrupt*/
146
147 { MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY },
148
149 /* LCD controller */
150 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
151};
152
153/* 57/*
154 * Initialize IRQ setting 58 * Initialize IRQ setting
155 */ 59 */
156void __init 60void __init init_7343se_IRQ(void)
157init_7343se_IRQ(void)
158{ 61{
159 /* Setup Multiplexed interrupts */ 62 int i;
160 ctrl_outw(8, PA_CPLD_MODESET); /* Set all CPLD interrupts to active 63
161 * low. 64 ctrl_outw(0, PA_CPLD_IMSK); /* disable all irqs */
162 */ 65 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
163 /* Mask all CPLD controller interrupts */ 66
164 ctrl_outw(0x0fff, PA_CPLD_IMSK); 67 for (i = 0; i < SE7343_FPGA_IRQ_NR; i++)
165 68 set_irq_chip_and_handler_name(SE7343_FPGA_IRQ_BASE + i,
166 /* PC Card interrupts */ 69 &se7343_irq_chip,
167 make_intreq_irq(PC_IRQ0); 70 handle_level_irq, "level");
168 make_intreq_irq(PC_IRQ1); 71
169 make_intreq_irq(PC_IRQ2); 72 set_irq_chained_handler(IRQ0_IRQ, se7343_irq_demux);
170 make_intreq_irq(PC_IRQ3); 73 set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW);
171 74 set_irq_chained_handler(IRQ1_IRQ, se7343_irq_demux);
172 /* Extension Slot Interrupts */ 75 set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW);
173 make_intreq_irq(EXT_IRQ0); 76 set_irq_chained_handler(IRQ4_IRQ, se7343_irq_demux);
174 make_intreq_irq(EXT_IRQ1); 77 set_irq_type(IRQ4_IRQ, IRQ_TYPE_LEVEL_LOW);
175 make_intreq_irq(EXT_IRQ2); 78 set_irq_chained_handler(IRQ5_IRQ, se7343_irq_demux);
176 make_intreq_irq(EXT_IRQ3); 79 set_irq_type(IRQ5_IRQ, IRQ_TYPE_LEVEL_LOW);
177
178 /* USB Controller interrupts */
179 make_intreq_irq(USB_IRQ0);
180 make_intreq_irq(USB_IRQ1);
181
182 /* Serial Controller interrupts */
183 make_intreq_irq(UART_IRQ0);
184 make_intreq_irq(UART_IRQ1);
185
186 /* Setup all external interrupts to be active low */
187 ctrl_outw(0xaaaa, INTC_ICR1);
188
189 make_ipr_irq(se7343_irq5_ipr_map, ARRAY_SIZE(se7343_irq5_ipr_map));
190
191 setup_irq(IRQ5_IRQ, &irq5);
192 /* Set port control to use IRQ5 */
193 *(u16 *)0xA4050108 &= ~0xc;
194
195 make_ipr_irq(se7343_siof0_vpu_ipr_map, ARRAY_SIZE(se7343_siof0_vpu_ipr_map));
196
197 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
198
199 make_ipr_irq(se7343_other_ipr_map, ARRAY_SIZE(se7343_other_ipr_map));
200
201 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
202} 80}
diff --git a/arch/sh/boards/se/7343/setup.c b/arch/sh/boards/se/7343/setup.c
index c9431b3a051b..8ae718d6c710 100644
--- a/arch/sh/boards/se/7343/setup.c
+++ b/arch/sh/boards/se/7343/setup.c
@@ -1,10 +1,11 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/platform_device.h> 2#include <linux/platform_device.h>
3#include <linux/mtd/physmap.h>
3#include <asm/machvec.h> 4#include <asm/machvec.h>
4#include <asm/mach/se7343.h> 5#include <asm/mach/se7343.h>
6#include <asm/heartbeat.h>
5#include <asm/irq.h> 7#include <asm/irq.h>
6 8#include <asm/io.h>
7void init_7343se_IRQ(void);
8 9
9static struct resource smc91x_resources[] = { 10static struct resource smc91x_resources[] = {
10 [0] = { 11 [0] = {
@@ -17,8 +18,8 @@ static struct resource smc91x_resources[] = {
17 * shared with other devices via externel 18 * shared with other devices via externel
18 * interrupt controller in FPGA... 19 * interrupt controller in FPGA...
19 */ 20 */
20 .start = EXT_IRQ2, 21 .start = SMC_IRQ,
21 .end = EXT_IRQ2, 22 .end = SMC_IRQ,
22 .flags = IORESOURCE_IRQ, 23 .flags = IORESOURCE_IRQ,
23 }, 24 },
24}; 25};
@@ -38,16 +39,65 @@ static struct resource heartbeat_resources[] = {
38 }, 39 },
39}; 40};
40 41
42static struct heartbeat_data heartbeat_data = {
43 .regsize = 16,
44};
45
41static struct platform_device heartbeat_device = { 46static struct platform_device heartbeat_device = {
42 .name = "heartbeat", 47 .name = "heartbeat",
43 .id = -1, 48 .id = -1,
49 .dev = {
50 .platform_data = &heartbeat_data,
51 },
44 .num_resources = ARRAY_SIZE(heartbeat_resources), 52 .num_resources = ARRAY_SIZE(heartbeat_resources),
45 .resource = heartbeat_resources, 53 .resource = heartbeat_resources,
46}; 54};
47 55
56static struct mtd_partition nor_flash_partitions[] = {
57 {
58 .name = "loader",
59 .offset = 0x00000000,
60 .size = 128 * 1024,
61 },
62 {
63 .name = "rootfs",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 31 * 1024 * 1024,
66 },
67 {
68 .name = "data",
69 .offset = MTDPART_OFS_APPEND,
70 .size = MTDPART_SIZ_FULL,
71 },
72};
73
74static struct physmap_flash_data nor_flash_data = {
75 .width = 2,
76 .parts = nor_flash_partitions,
77 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
78};
79
80static struct resource nor_flash_resources[] = {
81 [0] = {
82 .start = 0x00000000,
83 .end = 0x01ffffff,
84 .flags = IORESOURCE_MEM,
85 }
86};
87
88static struct platform_device nor_flash_device = {
89 .name = "physmap-flash",
90 .dev = {
91 .platform_data = &nor_flash_data,
92 },
93 .num_resources = ARRAY_SIZE(nor_flash_resources),
94 .resource = nor_flash_resources,
95};
96
48static struct platform_device *sh7343se_platform_devices[] __initdata = { 97static struct platform_device *sh7343se_platform_devices[] __initdata = {
49 &smc91x_device, 98 &smc91x_device,
50 &heartbeat_device, 99 &heartbeat_device,
100 &nor_flash_device,
51}; 101};
52 102
53static int __init sh7343se_devices_setup(void) 103static int __init sh7343se_devices_setup(void)
@@ -55,10 +105,19 @@ static int __init sh7343se_devices_setup(void)
55 return platform_add_devices(sh7343se_platform_devices, 105 return platform_add_devices(sh7343se_platform_devices,
56 ARRAY_SIZE(sh7343se_platform_devices)); 106 ARRAY_SIZE(sh7343se_platform_devices));
57} 107}
108device_initcall(sh7343se_devices_setup);
58 109
110/*
111 * Initialize the board
112 */
59static void __init sh7343se_setup(char **cmdline_p) 113static void __init sh7343se_setup(char **cmdline_p)
60{ 114{
61 device_initcall(sh7343se_devices_setup); 115 ctrl_outw(0xf900, FPGA_OUT); /* FPGA */
116
117 ctrl_outw(0x0002, PORT_PECR); /* PORT E 1 = IRQ5 */
118 ctrl_outw(0x0020, PORT_PSELD);
119
120 printk(KERN_INFO "MS7343CP01 Setup...done\n");
62} 121}
63 122
64/* 123/*
@@ -90,5 +149,4 @@ static struct sh_machine_vector mv_7343se __initmv = {
90 .mv_outsl = sh7343se_outsl, 149 .mv_outsl = sh7343se_outsl,
91 150
92 .mv_init_irq = init_7343se_IRQ, 151 .mv_init_irq = init_7343se_IRQ,
93 .mv_irq_demux = shmse_irq_demux,
94}; 152};
diff --git a/arch/sh/boards/se/770x/io.c b/arch/sh/boards/se/770x/io.c
index c4550473d4c3..b1ec085b8673 100644
--- a/arch/sh/boards/se/770x/io.c
+++ b/arch/sh/boards/se/770x/io.c
@@ -1,25 +1,13 @@
1/* $Id: io.c,v 1.7 2006/02/05 21:55:29 lethal Exp $ 1/*
2 *
3 * linux/arch/sh/kernel/io_se.c
4 *
5 * Copyright (C) 2000 Kazumoto Kojima 2 * Copyright (C) 2000 Kazumoto Kojima
6 * 3 *
7 * I/O routine for Hitachi SolutionEngine. 4 * I/O routine for Hitachi SolutionEngine.
8 *
9 */ 5 */
10
11#include <linux/kernel.h> 6#include <linux/kernel.h>
12#include <linux/types.h> 7#include <linux/types.h>
13#include <asm/io.h> 8#include <asm/io.h>
14#include <asm/se.h> 9#include <asm/se.h>
15 10
16/* SH pcmcia io window base, start and end. */
17int sh_pcic_io_wbase = 0xb8400000;
18int sh_pcic_io_start;
19int sh_pcic_io_stop;
20int sh_pcic_io_type;
21int sh_pcic_io_dummy;
22
23/* MS7750 requires special versions of in*, out* routines, since 11/* MS7750 requires special versions of in*, out* routines, since
24 PC-like io ports are located at upper half byte of 16-bit word which 12 PC-like io ports are located at upper half byte of 16-bit word which
25 can be accessed only with 16-bit wide. */ 13 can be accessed only with 16-bit wide. */
@@ -33,8 +21,6 @@ port2adr(unsigned int port)
33 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); 21 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
34 else if (port >= 0x1000) 22 else if (port >= 0x1000)
35 return (volatile __u16 *) (PA_83902 + (port << 1)); 23 return (volatile __u16 *) (PA_83902 + (port << 1));
36 else if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
37 return (volatile __u16 *) (sh_pcic_io_wbase + (port &~ 1));
38 else 24 else
39 return (volatile __u16 *) (PA_SUPERIO + (port << 1)); 25 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
40} 26}
@@ -51,32 +37,27 @@ shifted_port(unsigned long port)
51 37
52unsigned char se_inb(unsigned long port) 38unsigned char se_inb(unsigned long port)
53{ 39{
54 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) 40 if (shifted_port(port))
55 return *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port); 41 return (*port2adr(port) >> 8);
56 else if (shifted_port(port))
57 return (*port2adr(port) >> 8);
58 else 42 else
59 return (*port2adr(port))&0xff; 43 return (*port2adr(port))&0xff;
60} 44}
61 45
62unsigned char se_inb_p(unsigned long port) 46unsigned char se_inb_p(unsigned long port)
63{ 47{
64 unsigned long v; 48 unsigned long v;
65 49
66 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) 50 if (shifted_port(port))
67 v = *(__u8 *) (sh_pcic_io_wbase + 0x40000 + port); 51 v = (*port2adr(port) >> 8);
68 else if (shifted_port(port))
69 v = (*port2adr(port) >> 8);
70 else 52 else
71 v = (*port2adr(port))&0xff; 53 v = (*port2adr(port))&0xff;
72 ctrl_delay(); 54 ctrl_delay();
73 return v; 55 return v;
74} 56}
75 57
76unsigned short se_inw(unsigned long port) 58unsigned short se_inw(unsigned long port)
77{ 59{
78 if (port >= 0x2000 || 60 if (port >= 0x2000)
79 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
80 return *port2adr(port); 61 return *port2adr(port);
81 else 62 else
82 maybebadio(port); 63 maybebadio(port);
@@ -91,9 +72,7 @@ unsigned int se_inl(unsigned long port)
91 72
92void se_outb(unsigned char value, unsigned long port) 73void se_outb(unsigned char value, unsigned long port)
93{ 74{
94 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) 75 if (shifted_port(port))
95 *(__u8 *)(sh_pcic_io_wbase + port) = value;
96 else if (shifted_port(port))
97 *(port2adr(port)) = value << 8; 76 *(port2adr(port)) = value << 8;
98 else 77 else
99 *(port2adr(port)) = value; 78 *(port2adr(port)) = value;
@@ -101,9 +80,7 @@ void se_outb(unsigned char value, unsigned long port)
101 80
102void se_outb_p(unsigned char value, unsigned long port) 81void se_outb_p(unsigned char value, unsigned long port)
103{ 82{
104 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) 83 if (shifted_port(port))
105 *(__u8 *)(sh_pcic_io_wbase + port) = value;
106 else if (shifted_port(port))
107 *(port2adr(port)) = value << 8; 84 *(port2adr(port)) = value << 8;
108 else 85 else
109 *(port2adr(port)) = value; 86 *(port2adr(port)) = value;
@@ -112,8 +89,7 @@ void se_outb_p(unsigned char value, unsigned long port)
112 89
113void se_outw(unsigned short value, unsigned long port) 90void se_outw(unsigned short value, unsigned long port)
114{ 91{
115 if (port >= 0x2000 || 92 if (port >= 0x2000)
116 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
117 *port2adr(port) = value; 93 *port2adr(port) = value;
118 else 94 else
119 maybebadio(port); 95 maybebadio(port);
@@ -129,11 +105,7 @@ void se_insb(unsigned long port, void *addr, unsigned long count)
129 volatile __u16 *p = port2adr(port); 105 volatile __u16 *p = port2adr(port);
130 __u8 *ap = addr; 106 __u8 *ap = addr;
131 107
132 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) { 108 if (shifted_port(port)) {
133 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + 0x40000 + port);
134 while (count--)
135 *ap++ = *bp;
136 } else if (shifted_port(port)) {
137 while (count--) 109 while (count--)
138 *ap++ = *p >> 8; 110 *ap++ = *p >> 8;
139 } else { 111 } else {
@@ -160,11 +132,7 @@ void se_outsb(unsigned long port, const void *addr, unsigned long count)
160 volatile __u16 *p = port2adr(port); 132 volatile __u16 *p = port2adr(port);
161 const __u8 *ap = addr; 133 const __u8 *ap = addr;
162 134
163 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) { 135 if (shifted_port(port)) {
164 volatile __u8 *bp = (__u8 *) (sh_pcic_io_wbase + port);
165 while (count--)
166 *bp = *ap++;
167 } else if (shifted_port(port)) {
168 while (count--) 136 while (count--)
169 *p = *ap++ << 8; 137 *p = *ap++ << 8;
170 } else { 138 } else {
@@ -177,6 +145,7 @@ void se_outsw(unsigned long port, const void *addr, unsigned long count)
177{ 145{
178 volatile __u16 *p = port2adr(port); 146 volatile __u16 *p = port2adr(port);
179 const __u16 *ap = addr; 147 const __u16 *ap = addr;
148
180 while (count--) 149 while (count--)
181 *p = *ap++; 150 *p = *ap++;
182} 151}
diff --git a/arch/sh/boards/se/770x/setup.c b/arch/sh/boards/se/770x/setup.c
index 318bc8a3969c..cf4a5ba12df4 100644
--- a/arch/sh/boards/se/770x/setup.c
+++ b/arch/sh/boards/se/770x/setup.c
@@ -14,8 +14,6 @@
14#include <asm/smc37c93x.h> 14#include <asm/smc37c93x.h>
15#include <asm/heartbeat.h> 15#include <asm/heartbeat.h>
16 16
17void init_se_IRQ(void);
18
19/* 17/*
20 * Configure the Super I/O chip 18 * Configure the Super I/O chip
21 */ 19 */
@@ -73,7 +71,7 @@ static struct resource cf_ide_resources[] = {
73 }, 71 },
74 [1] = { 72 [1] = {
75 .start = PA_MRSHPC_IO + 0x1f0 + 0x206, 73 .start = PA_MRSHPC_IO + 0x1f0 + 0x206,
76 .end = PA_MRSHPC_IO + 0x1f0 +8 + 0x206 + 8, 74 .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8,
77 .flags = IORESOURCE_MEM, 75 .flags = IORESOURCE_MEM,
78 }, 76 },
79 [2] = { 77 [2] = {
@@ -115,9 +113,58 @@ static struct platform_device heartbeat_device = {
115 .resource = heartbeat_resources, 113 .resource = heartbeat_resources,
116}; 114};
117 115
116/* SH771X Ethernet driver */
117static struct resource sh_eth0_resources[] = {
118 [0] = {
119 .start = SH_ETH0_BASE,
120 .end = SH_ETH0_BASE + 0x1B8,
121 .flags = IORESOURCE_MEM,
122 },
123 [1] = {
124 .start = SH_ETH0_IRQ,
125 .end = SH_ETH0_IRQ,
126 .flags = IORESOURCE_IRQ,
127 },
128};
129
130static struct platform_device sh_eth0_device = {
131 .name = "sh-eth",
132 .id = 0,
133 .dev = {
134 .platform_data = PHY_ID,
135 },
136 .num_resources = ARRAY_SIZE(sh_eth0_resources),
137 .resource = sh_eth0_resources,
138};
139
140static struct resource sh_eth1_resources[] = {
141 [0] = {
142 .start = SH_ETH1_BASE,
143 .end = SH_ETH1_BASE + 0x1B8,
144 .flags = IORESOURCE_MEM,
145 },
146 [1] = {
147 .start = SH_ETH1_IRQ,
148 .end = SH_ETH1_IRQ,
149 .flags = IORESOURCE_IRQ,
150 },
151};
152
153static struct platform_device sh_eth1_device = {
154 .name = "sh-eth",
155 .id = 1,
156 .dev = {
157 .platform_data = PHY_ID,
158 },
159 .num_resources = ARRAY_SIZE(sh_eth1_resources),
160 .resource = sh_eth1_resources,
161};
162
118static struct platform_device *se_devices[] __initdata = { 163static struct platform_device *se_devices[] __initdata = {
119 &heartbeat_device, 164 &heartbeat_device,
120 &cf_ide_device, 165 &cf_ide_device,
166 &sh_eth0_device,
167 &sh_eth1_device,
121}; 168};
122 169
123static int __init se_devices_setup(void) 170static int __init se_devices_setup(void)
diff --git a/arch/sh/boards/se/7722/setup.c b/arch/sh/boards/se/7722/setup.c
index ede3957fc14a..6e228ea59788 100644
--- a/arch/sh/boards/se/7722/setup.c
+++ b/arch/sh/boards/se/7722/setup.c
@@ -16,6 +16,7 @@
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/smc91x.h> 17#include <linux/smc91x.h>
18#include <asm/machvec.h> 18#include <asm/machvec.h>
19#include <asm/clock.h>
19#include <asm/se7722.h> 20#include <asm/se7722.h>
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/heartbeat.h> 22#include <asm/heartbeat.h>
@@ -145,6 +146,8 @@ static struct platform_device *se7722_devices[] __initdata = {
145 146
146static int __init se7722_devices_setup(void) 147static int __init se7722_devices_setup(void)
147{ 148{
149 clk_always_enable("mstp214"); /* KEYSC */
150
148 return platform_add_devices(se7722_devices, 151 return platform_add_devices(se7722_devices,
149 ARRAY_SIZE(se7722_devices)); 152 ARRAY_SIZE(se7722_devices));
150} 153}
@@ -154,11 +157,6 @@ static void __init se7722_setup(char **cmdline_p)
154{ 157{
155 ctrl_outw(0x010D, FPGA_OUT); /* FPGA */ 158 ctrl_outw(0x010D, FPGA_OUT); /* FPGA */
156 159
157 ctrl_outl(0x00051001, MSTPCR0);
158 ctrl_outl(0x00000000, MSTPCR1);
159 /* KEYSC, VOU, BEU, CEU, VEU, VPU, LCDC, USB */
160 ctrl_outl(0xffffb7c0, MSTPCR2);
161
162 ctrl_outw(0x0000, PORT_PECR); /* PORT E 1 = IRQ5 ,E 0 = BS */ 160 ctrl_outw(0x0000, PORT_PECR); /* PORT E 1 = IRQ5 ,E 0 = BS */
163 ctrl_outw(0x1000, PORT_PJCR); /* PORT J 1 = IRQ1,J 0 =IRQ0 */ 161 ctrl_outw(0x1000, PORT_PJCR); /* PORT J 1 = IRQ1,J 0 =IRQ0 */
164 162
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 89b408620dcb..8b37869a8227 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -40,7 +40,7 @@ KERNEL_LOAD := $(shell /bin/bash -c 'printf "0x%08x" \
40KERNEL_ENTRY := $(shell /bin/bash -c 'printf "0x%08x" \ 40KERNEL_ENTRY := $(shell /bin/bash -c 'printf "0x%08x" \
41 $$[$(CONFIG_PAGE_OFFSET) + \ 41 $$[$(CONFIG_PAGE_OFFSET) + \
42 $(CONFIG_MEMORY_START) + \ 42 $(CONFIG_MEMORY_START) + \
43 $(CONFIG_ZERO_PAGE_OFFSET)+0x1000]') 43 $(CONFIG_ZERO_PAGE_OFFSET) + $(CONFIG_ENTRY_OFFSET)]')
44 44
45quiet_cmd_uimage = UIMAGE $@ 45quiet_cmd_uimage = UIMAGE $@
46 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ 46 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \
diff --git a/arch/sh/boot/compressed/Makefile_32 b/arch/sh/boot/compressed/Makefile_32
index c0d25fb1aa60..47685f618ae7 100644
--- a/arch/sh/boot/compressed/Makefile_32
+++ b/arch/sh/boot/compressed/Makefile_32
@@ -35,8 +35,7 @@ $(obj)/vmlinux.bin: vmlinux FORCE
35$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 35$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
36 $(call if_changed,gzip) 36 $(call if_changed,gzip)
37 37
38LDFLAGS_piggy.o := -r --format binary --oformat elf32-sh-linux -T
39OBJCOPYFLAGS += -R .empty_zero_page 38OBJCOPYFLAGS += -R .empty_zero_page
40 39
41$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 40$(obj)/piggy.o: $(obj)/piggy.S $(obj)/vmlinux.bin.gz FORCE
42 $(call if_changed,ld) 41 $(call if_changed,as_o_S)
diff --git a/arch/sh/boot/compressed/Makefile_64 b/arch/sh/boot/compressed/Makefile_64
index 912f3e205a0d..658d4f915556 100644
--- a/arch/sh/boot/compressed/Makefile_64
+++ b/arch/sh/boot/compressed/Makefile_64
@@ -37,8 +37,7 @@ $(obj)/vmlinux.bin: vmlinux FORCE
37$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 37$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
38 $(call if_changed,gzip) 38 $(call if_changed,gzip)
39 39
40LDFLAGS_piggy.o := -r --format binary --oformat elf32-sh64-linux -T
41OBJCOPYFLAGS += -R .empty_zero_page 40OBJCOPYFLAGS += -R .empty_zero_page
42 41
43$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 42$(obj)/piggy.o: $(obj)/piggy.S $(obj)/vmlinux.bin.gz FORCE
44 $(call if_changed,ld) 43 $(call if_changed,as_o_S)
diff --git a/arch/sh/boot/compressed/piggy.S b/arch/sh/boot/compressed/piggy.S
new file mode 100644
index 000000000000..566071926b13
--- /dev/null
+++ b/arch/sh/boot/compressed/piggy.S
@@ -0,0 +1,8 @@
1 .global input_len, input_data
2 .data
3input_len:
4 .long input_data_end - input_data
5input_data:
6 .incbin "arch/sh/boot/compressed/vmlinux.bin.gz"
7input_data_end:
8 .end
diff --git a/arch/sh/boot/compressed/vmlinux.scr b/arch/sh/boot/compressed/vmlinux.scr
deleted file mode 100644
index 1ed9d791f863..000000000000
--- a/arch/sh/boot/compressed/vmlinux.scr
+++ /dev/null
@@ -1,9 +0,0 @@
1SECTIONS
2{
3 .data : {
4 input_len = .;
5 LONG(input_data_end - input_data) input_data = .;
6 *(.data)
7 input_data_end = .;
8 }
9}
diff --git a/arch/sh/configs/ap325rxa_defconfig b/arch/sh/configs/ap325rxa_defconfig
new file mode 100644
index 000000000000..5471df53753c
--- /dev/null
+++ b/arch/sh/configs/ap325rxa_defconfig
@@ -0,0 +1,947 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.26-rc4
4# Wed Jun 4 17:30:00 2008
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_BUG=y
10CONFIG_GENERIC_FIND_NEXT_BIT=y
11CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_HARDIRQS=y
13CONFIG_GENERIC_IRQ_PROBE=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_TIME=y
16CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_STACKTRACE_SUPPORT=y
18CONFIG_LOCKDEP_SUPPORT=y
19# CONFIG_ARCH_HAS_ILOG2_U32 is not set
20# CONFIG_ARCH_HAS_ILOG2_U64 is not set
21CONFIG_ARCH_NO_VIRT_TO_BUS=y
22CONFIG_ARCH_SUPPORTS_AOUT=y
23CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
24
25#
26# General setup
27#
28CONFIG_EXPERIMENTAL=y
29CONFIG_BROKEN_ON_SMP=y
30CONFIG_LOCK_KERNEL=y
31CONFIG_INIT_ENV_ARG_LIMIT=32
32CONFIG_LOCALVERSION=""
33# CONFIG_LOCALVERSION_AUTO is not set
34CONFIG_SWAP=y
35CONFIG_SYSVIPC=y
36CONFIG_SYSVIPC_SYSCTL=y
37# CONFIG_POSIX_MQUEUE is not set
38CONFIG_BSD_PROCESS_ACCT=y
39# CONFIG_BSD_PROCESS_ACCT_V3 is not set
40# CONFIG_TASKSTATS is not set
41# CONFIG_AUDIT is not set
42# CONFIG_IKCONFIG is not set
43CONFIG_LOG_BUF_SHIFT=14
44# CONFIG_CGROUPS is not set
45CONFIG_GROUP_SCHED=y
46CONFIG_FAIR_GROUP_SCHED=y
47# CONFIG_RT_GROUP_SCHED is not set
48CONFIG_USER_SCHED=y
49# CONFIG_CGROUP_SCHED is not set
50CONFIG_SYSFS_DEPRECATED=y
51CONFIG_SYSFS_DEPRECATED_V2=y
52# CONFIG_RELAY is not set
53# CONFIG_NAMESPACES is not set
54# CONFIG_BLK_DEV_INITRD is not set
55CONFIG_CC_OPTIMIZE_FOR_SIZE=y
56CONFIG_SYSCTL=y
57CONFIG_EMBEDDED=y
58CONFIG_UID16=y
59CONFIG_SYSCTL_SYSCALL=y
60CONFIG_SYSCTL_SYSCALL_CHECK=y
61# CONFIG_KALLSYMS is not set
62CONFIG_HOTPLUG=y
63CONFIG_PRINTK=y
64CONFIG_BUG=y
65CONFIG_ELF_CORE=y
66CONFIG_COMPAT_BRK=y
67CONFIG_BASE_FULL=y
68CONFIG_FUTEX=y
69CONFIG_ANON_INODES=y
70CONFIG_EPOLL=y
71CONFIG_SIGNALFD=y
72CONFIG_TIMERFD=y
73CONFIG_EVENTFD=y
74CONFIG_SHMEM=y
75CONFIG_VM_EVENT_COUNTERS=y
76CONFIG_SLAB=y
77# CONFIG_SLUB is not set
78# CONFIG_SLOB is not set
79# CONFIG_PROFILING is not set
80# CONFIG_MARKERS is not set
81CONFIG_HAVE_OPROFILE=y
82# CONFIG_HAVE_KPROBES is not set
83# CONFIG_HAVE_KRETPROBES is not set
84# CONFIG_HAVE_DMA_ATTRS is not set
85CONFIG_PROC_PAGE_MONITOR=y
86CONFIG_SLABINFO=y
87CONFIG_RT_MUTEXES=y
88# CONFIG_TINY_SHMEM is not set
89CONFIG_BASE_SMALL=0
90CONFIG_MODULES=y
91# CONFIG_MODULE_FORCE_LOAD is not set
92CONFIG_MODULE_UNLOAD=y
93# CONFIG_MODULE_FORCE_UNLOAD is not set
94# CONFIG_MODVERSIONS is not set
95# CONFIG_MODULE_SRCVERSION_ALL is not set
96CONFIG_KMOD=y
97CONFIG_BLOCK=y
98# CONFIG_LBD is not set
99# CONFIG_BLK_DEV_IO_TRACE is not set
100# CONFIG_LSF is not set
101# CONFIG_BLK_DEV_BSG is not set
102
103#
104# IO Schedulers
105#
106CONFIG_IOSCHED_NOOP=y
107CONFIG_IOSCHED_AS=y
108CONFIG_IOSCHED_DEADLINE=y
109CONFIG_IOSCHED_CFQ=y
110# CONFIG_DEFAULT_AS is not set
111# CONFIG_DEFAULT_DEADLINE is not set
112CONFIG_DEFAULT_CFQ=y
113# CONFIG_DEFAULT_NOOP is not set
114CONFIG_DEFAULT_IOSCHED="cfq"
115CONFIG_CLASSIC_RCU=y
116
117#
118# System type
119#
120CONFIG_CPU_SH4=y
121CONFIG_CPU_SH4A=y
122CONFIG_CPU_SHX2=y
123# CONFIG_CPU_SUBTYPE_SH7619 is not set
124# CONFIG_CPU_SUBTYPE_SH7203 is not set
125# CONFIG_CPU_SUBTYPE_SH7206 is not set
126# CONFIG_CPU_SUBTYPE_SH7263 is not set
127# CONFIG_CPU_SUBTYPE_MXG is not set
128# CONFIG_CPU_SUBTYPE_SH7705 is not set
129# CONFIG_CPU_SUBTYPE_SH7706 is not set
130# CONFIG_CPU_SUBTYPE_SH7707 is not set
131# CONFIG_CPU_SUBTYPE_SH7708 is not set
132# CONFIG_CPU_SUBTYPE_SH7709 is not set
133# CONFIG_CPU_SUBTYPE_SH7710 is not set
134# CONFIG_CPU_SUBTYPE_SH7712 is not set
135# CONFIG_CPU_SUBTYPE_SH7720 is not set
136# CONFIG_CPU_SUBTYPE_SH7721 is not set
137# CONFIG_CPU_SUBTYPE_SH7750 is not set
138# CONFIG_CPU_SUBTYPE_SH7091 is not set
139# CONFIG_CPU_SUBTYPE_SH7750R is not set
140# CONFIG_CPU_SUBTYPE_SH7750S is not set
141# CONFIG_CPU_SUBTYPE_SH7751 is not set
142# CONFIG_CPU_SUBTYPE_SH7751R is not set
143# CONFIG_CPU_SUBTYPE_SH7760 is not set
144# CONFIG_CPU_SUBTYPE_SH4_202 is not set
145CONFIG_CPU_SUBTYPE_SH7723=y
146# CONFIG_CPU_SUBTYPE_SH7763 is not set
147# CONFIG_CPU_SUBTYPE_SH7770 is not set
148# CONFIG_CPU_SUBTYPE_SH7780 is not set
149# CONFIG_CPU_SUBTYPE_SH7785 is not set
150# CONFIG_CPU_SUBTYPE_SHX3 is not set
151# CONFIG_CPU_SUBTYPE_SH7343 is not set
152# CONFIG_CPU_SUBTYPE_SH7722 is not set
153# CONFIG_CPU_SUBTYPE_SH7366 is not set
154# CONFIG_CPU_SUBTYPE_SH5_101 is not set
155# CONFIG_CPU_SUBTYPE_SH5_103 is not set
156
157#
158# Memory management options
159#
160CONFIG_QUICKLIST=y
161CONFIG_MMU=y
162CONFIG_PAGE_OFFSET=0x80000000
163CONFIG_MEMORY_START=0x08000000
164CONFIG_MEMORY_SIZE=0x08000000
165CONFIG_29BIT=y
166# CONFIG_X2TLB is not set
167CONFIG_VSYSCALL=y
168CONFIG_ARCH_FLATMEM_ENABLE=y
169CONFIG_ARCH_SPARSEMEM_ENABLE=y
170CONFIG_ARCH_SPARSEMEM_DEFAULT=y
171CONFIG_MAX_ACTIVE_REGIONS=1
172CONFIG_ARCH_POPULATES_NODE_MAP=y
173CONFIG_ARCH_SELECT_MEMORY_MODEL=y
174CONFIG_PAGE_SIZE_4KB=y
175# CONFIG_PAGE_SIZE_8KB is not set
176# CONFIG_PAGE_SIZE_16KB is not set
177# CONFIG_PAGE_SIZE_64KB is not set
178CONFIG_SELECT_MEMORY_MODEL=y
179CONFIG_FLATMEM_MANUAL=y
180# CONFIG_DISCONTIGMEM_MANUAL is not set
181# CONFIG_SPARSEMEM_MANUAL is not set
182CONFIG_FLATMEM=y
183CONFIG_FLAT_NODE_MEM_MAP=y
184CONFIG_SPARSEMEM_STATIC=y
185# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
186CONFIG_PAGEFLAGS_EXTENDED=y
187CONFIG_SPLIT_PTLOCK_CPUS=4
188# CONFIG_RESOURCES_64BIT is not set
189CONFIG_ZONE_DMA_FLAG=0
190CONFIG_NR_QUICK=2
191
192#
193# Cache configuration
194#
195# CONFIG_SH_DIRECT_MAPPED is not set
196CONFIG_CACHE_WRITEBACK=y
197# CONFIG_CACHE_WRITETHROUGH is not set
198# CONFIG_CACHE_OFF is not set
199
200#
201# Processor features
202#
203CONFIG_CPU_LITTLE_ENDIAN=y
204# CONFIG_CPU_BIG_ENDIAN is not set
205CONFIG_SH_FPU=y
206# CONFIG_SH_STORE_QUEUES is not set
207CONFIG_CPU_HAS_INTEVT=y
208CONFIG_CPU_HAS_SR_RB=y
209CONFIG_CPU_HAS_PTEA=y
210CONFIG_CPU_HAS_FPU=y
211
212#
213# Board support
214#
215CONFIG_SH_AP325RXA=y
216
217#
218# Timer and clock configuration
219#
220CONFIG_SH_TMU=y
221CONFIG_SH_TIMER_IRQ=16
222CONFIG_SH_PCLK_FREQ=33333333
223CONFIG_TICK_ONESHOT=y
224# CONFIG_NO_HZ is not set
225CONFIG_HIGH_RES_TIMERS=y
226CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
227
228#
229# CPU Frequency scaling
230#
231# CONFIG_CPU_FREQ is not set
232
233#
234# DMA support
235#
236# CONFIG_SH_DMA is not set
237
238#
239# Companion Chips
240#
241
242#
243# Additional SuperH Device Drivers
244#
245# CONFIG_HEARTBEAT is not set
246# CONFIG_PUSH_SWITCH is not set
247
248#
249# Kernel features
250#
251# CONFIG_HZ_100 is not set
252CONFIG_HZ_250=y
253# CONFIG_HZ_300 is not set
254# CONFIG_HZ_1000 is not set
255CONFIG_HZ=250
256# CONFIG_SCHED_HRTICK is not set
257# CONFIG_KEXEC is not set
258# CONFIG_CRASH_DUMP is not set
259# CONFIG_PREEMPT_NONE is not set
260# CONFIG_PREEMPT_VOLUNTARY is not set
261CONFIG_PREEMPT=y
262# CONFIG_PREEMPT_RCU is not set
263CONFIG_GUSA=y
264
265#
266# Boot options
267#
268CONFIG_ZERO_PAGE_OFFSET=0x00001000
269CONFIG_BOOT_LINK_OFFSET=0x00800000
270CONFIG_CMDLINE_BOOL=y
271CONFIG_CMDLINE="console=tty1 console=ttySC5,38400 root=/dev/nfs ip=dhcp"
272
273#
274# Bus options
275#
276# CONFIG_ARCH_SUPPORTS_MSI is not set
277# CONFIG_PCCARD is not set
278
279#
280# Executable file formats
281#
282CONFIG_BINFMT_ELF=y
283# CONFIG_BINFMT_MISC is not set
284
285#
286# Networking
287#
288CONFIG_NET=y
289
290#
291# Networking options
292#
293CONFIG_PACKET=y
294# CONFIG_PACKET_MMAP is not set
295CONFIG_UNIX=y
296# CONFIG_NET_KEY is not set
297CONFIG_INET=y
298# CONFIG_IP_MULTICAST is not set
299CONFIG_IP_ADVANCED_ROUTER=y
300CONFIG_ASK_IP_FIB_HASH=y
301# CONFIG_IP_FIB_TRIE is not set
302CONFIG_IP_FIB_HASH=y
303# CONFIG_IP_MULTIPLE_TABLES is not set
304# CONFIG_IP_ROUTE_MULTIPATH is not set
305# CONFIG_IP_ROUTE_VERBOSE is not set
306CONFIG_IP_PNP=y
307CONFIG_IP_PNP_DHCP=y
308# CONFIG_IP_PNP_BOOTP is not set
309# CONFIG_IP_PNP_RARP is not set
310# CONFIG_NET_IPIP is not set
311# CONFIG_NET_IPGRE is not set
312# CONFIG_ARPD is not set
313# CONFIG_SYN_COOKIES is not set
314# CONFIG_INET_AH is not set
315# CONFIG_INET_ESP is not set
316# CONFIG_INET_IPCOMP is not set
317# CONFIG_INET_XFRM_TUNNEL is not set
318# CONFIG_INET_TUNNEL is not set
319# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
320# CONFIG_INET_XFRM_MODE_TUNNEL is not set
321# CONFIG_INET_XFRM_MODE_BEET is not set
322# CONFIG_INET_LRO is not set
323CONFIG_INET_DIAG=y
324CONFIG_INET_TCP_DIAG=y
325# CONFIG_TCP_CONG_ADVANCED is not set
326CONFIG_TCP_CONG_CUBIC=y
327CONFIG_DEFAULT_TCP_CONG="cubic"
328# CONFIG_TCP_MD5SIG is not set
329# CONFIG_IPV6 is not set
330# CONFIG_NETWORK_SECMARK is not set
331# CONFIG_NETFILTER is not set
332# CONFIG_IP_DCCP is not set
333# CONFIG_IP_SCTP is not set
334# CONFIG_TIPC is not set
335# CONFIG_ATM is not set
336# CONFIG_BRIDGE is not set
337# CONFIG_VLAN_8021Q is not set
338# CONFIG_DECNET is not set
339# CONFIG_LLC2 is not set
340# CONFIG_IPX is not set
341# CONFIG_ATALK is not set
342# CONFIG_X25 is not set
343# CONFIG_LAPB is not set
344# CONFIG_ECONET is not set
345# CONFIG_WAN_ROUTER is not set
346# CONFIG_NET_SCHED is not set
347
348#
349# Network testing
350#
351# CONFIG_NET_PKTGEN is not set
352# CONFIG_HAMRADIO is not set
353# CONFIG_CAN is not set
354# CONFIG_IRDA is not set
355# CONFIG_BT is not set
356# CONFIG_AF_RXRPC is not set
357
358#
359# Wireless
360#
361# CONFIG_CFG80211 is not set
362# CONFIG_WIRELESS_EXT is not set
363# CONFIG_MAC80211 is not set
364# CONFIG_IEEE80211 is not set
365# CONFIG_RFKILL is not set
366# CONFIG_NET_9P is not set
367
368#
369# Device Drivers
370#
371
372#
373# Generic Driver Options
374#
375CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
376CONFIG_STANDALONE=y
377CONFIG_PREVENT_FIRMWARE_BUILD=y
378CONFIG_FW_LOADER=y
379# CONFIG_SYS_HYPERVISOR is not set
380# CONFIG_CONNECTOR is not set
381CONFIG_MTD=y
382# CONFIG_MTD_DEBUG is not set
383CONFIG_MTD_CONCAT=y
384CONFIG_MTD_PARTITIONS=y
385# CONFIG_MTD_REDBOOT_PARTS is not set
386CONFIG_MTD_CMDLINE_PARTS=y
387# CONFIG_MTD_AR7_PARTS is not set
388
389#
390# User Modules And Translation Layers
391#
392CONFIG_MTD_CHAR=y
393CONFIG_MTD_BLKDEVS=y
394CONFIG_MTD_BLOCK=y
395# CONFIG_FTL is not set
396# CONFIG_NFTL is not set
397# CONFIG_INFTL is not set
398# CONFIG_RFD_FTL is not set
399# CONFIG_SSFDC is not set
400# CONFIG_MTD_OOPS is not set
401
402#
403# RAM/ROM/Flash chip drivers
404#
405CONFIG_MTD_CFI=y
406# CONFIG_MTD_JEDECPROBE is not set
407CONFIG_MTD_GEN_PROBE=y
408# CONFIG_MTD_CFI_ADV_OPTIONS is not set
409CONFIG_MTD_MAP_BANK_WIDTH_1=y
410CONFIG_MTD_MAP_BANK_WIDTH_2=y
411CONFIG_MTD_MAP_BANK_WIDTH_4=y
412# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
413# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
414# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
415CONFIG_MTD_CFI_I1=y
416CONFIG_MTD_CFI_I2=y
417# CONFIG_MTD_CFI_I4 is not set
418# CONFIG_MTD_CFI_I8 is not set
419# CONFIG_MTD_CFI_INTELEXT is not set
420CONFIG_MTD_CFI_AMDSTD=y
421# CONFIG_MTD_CFI_STAA is not set
422CONFIG_MTD_CFI_UTIL=y
423# CONFIG_MTD_RAM is not set
424# CONFIG_MTD_ROM is not set
425# CONFIG_MTD_ABSENT is not set
426
427#
428# Mapping drivers for chip access
429#
430# CONFIG_MTD_COMPLEX_MAPPINGS is not set
431CONFIG_MTD_PHYSMAP=y
432CONFIG_MTD_PHYSMAP_START=0xffffffff
433CONFIG_MTD_PHYSMAP_LEN=0
434CONFIG_MTD_PHYSMAP_BANKWIDTH=0
435# CONFIG_MTD_PLATRAM is not set
436
437#
438# Self-contained MTD device drivers
439#
440# CONFIG_MTD_SLRAM is not set
441# CONFIG_MTD_PHRAM is not set
442# CONFIG_MTD_MTDRAM is not set
443# CONFIG_MTD_BLOCK2MTD is not set
444
445#
446# Disk-On-Chip Device Drivers
447#
448# CONFIG_MTD_DOC2000 is not set
449# CONFIG_MTD_DOC2001 is not set
450# CONFIG_MTD_DOC2001PLUS is not set
451# CONFIG_MTD_NAND is not set
452# CONFIG_MTD_ONENAND is not set
453
454#
455# UBI - Unsorted block images
456#
457# CONFIG_MTD_UBI is not set
458# CONFIG_PARPORT is not set
459CONFIG_BLK_DEV=y
460# CONFIG_BLK_DEV_COW_COMMON is not set
461# CONFIG_BLK_DEV_LOOP is not set
462# CONFIG_BLK_DEV_NBD is not set
463CONFIG_BLK_DEV_RAM=y
464CONFIG_BLK_DEV_RAM_COUNT=4
465CONFIG_BLK_DEV_RAM_SIZE=4096
466# CONFIG_BLK_DEV_XIP is not set
467# CONFIG_CDROM_PKTCDVD is not set
468# CONFIG_ATA_OVER_ETH is not set
469CONFIG_MISC_DEVICES=y
470# CONFIG_EEPROM_93CX6 is not set
471# CONFIG_ENCLOSURE_SERVICES is not set
472CONFIG_HAVE_IDE=y
473# CONFIG_IDE is not set
474
475#
476# SCSI device support
477#
478# CONFIG_RAID_ATTRS is not set
479CONFIG_SCSI=y
480CONFIG_SCSI_DMA=y
481# CONFIG_SCSI_TGT is not set
482# CONFIG_SCSI_NETLINK is not set
483CONFIG_SCSI_PROC_FS=y
484
485#
486# SCSI support type (disk, tape, CD-ROM)
487#
488CONFIG_BLK_DEV_SD=y
489# CONFIG_CHR_DEV_ST is not set
490# CONFIG_CHR_DEV_OSST is not set
491# CONFIG_BLK_DEV_SR is not set
492# CONFIG_CHR_DEV_SG is not set
493# CONFIG_CHR_DEV_SCH is not set
494
495#
496# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
497#
498# CONFIG_SCSI_MULTI_LUN is not set
499# CONFIG_SCSI_CONSTANTS is not set
500# CONFIG_SCSI_LOGGING is not set
501# CONFIG_SCSI_SCAN_ASYNC is not set
502CONFIG_SCSI_WAIT_SCAN=m
503
504#
505# SCSI Transports
506#
507# CONFIG_SCSI_SPI_ATTRS is not set
508# CONFIG_SCSI_FC_ATTRS is not set
509# CONFIG_SCSI_ISCSI_ATTRS is not set
510# CONFIG_SCSI_SAS_LIBSAS is not set
511# CONFIG_SCSI_SRP_ATTRS is not set
512CONFIG_SCSI_LOWLEVEL=y
513# CONFIG_ISCSI_TCP is not set
514# CONFIG_SCSI_DEBUG is not set
515# CONFIG_ATA is not set
516# CONFIG_MD is not set
517CONFIG_NETDEVICES=y
518# CONFIG_NETDEVICES_MULTIQUEUE is not set
519# CONFIG_DUMMY is not set
520# CONFIG_BONDING is not set
521# CONFIG_MACVLAN is not set
522# CONFIG_EQUALIZER is not set
523# CONFIG_TUN is not set
524# CONFIG_VETH is not set
525# CONFIG_PHYLIB is not set
526CONFIG_NET_ETHERNET=y
527CONFIG_MII=y
528# CONFIG_AX88796 is not set
529# CONFIG_STNIC is not set
530# CONFIG_SMC91X is not set
531CONFIG_SMC911X=y
532# CONFIG_IBM_NEW_EMAC_ZMII is not set
533# CONFIG_IBM_NEW_EMAC_RGMII is not set
534# CONFIG_IBM_NEW_EMAC_TAH is not set
535# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
536# CONFIG_B44 is not set
537# CONFIG_NETDEV_1000 is not set
538# CONFIG_NETDEV_10000 is not set
539
540#
541# Wireless LAN
542#
543# CONFIG_WLAN_PRE80211 is not set
544# CONFIG_WLAN_80211 is not set
545# CONFIG_IWLWIFI_LEDS is not set
546# CONFIG_WAN is not set
547# CONFIG_PPP is not set
548# CONFIG_SLIP is not set
549# CONFIG_NETCONSOLE is not set
550# CONFIG_NETPOLL is not set
551# CONFIG_NET_POLL_CONTROLLER is not set
552# CONFIG_ISDN is not set
553# CONFIG_PHONE is not set
554
555#
556# Input device support
557#
558CONFIG_INPUT=y
559# CONFIG_INPUT_FF_MEMLESS is not set
560# CONFIG_INPUT_POLLDEV is not set
561
562#
563# Userland interfaces
564#
565# CONFIG_INPUT_MOUSEDEV is not set
566# CONFIG_INPUT_JOYDEV is not set
567# CONFIG_INPUT_EVDEV is not set
568# CONFIG_INPUT_EVBUG is not set
569
570#
571# Input Device Drivers
572#
573# CONFIG_INPUT_KEYBOARD is not set
574# CONFIG_INPUT_MOUSE is not set
575# CONFIG_INPUT_JOYSTICK is not set
576# CONFIG_INPUT_TABLET is not set
577# CONFIG_INPUT_TOUCHSCREEN is not set
578# CONFIG_INPUT_MISC is not set
579
580#
581# Hardware I/O ports
582#
583# CONFIG_SERIO is not set
584# CONFIG_GAMEPORT is not set
585
586#
587# Character devices
588#
589CONFIG_VT=y
590CONFIG_VT_CONSOLE=y
591CONFIG_HW_CONSOLE=y
592CONFIG_VT_HW_CONSOLE_BINDING=y
593CONFIG_DEVKMEM=y
594# CONFIG_SERIAL_NONSTANDARD is not set
595
596#
597# Serial drivers
598#
599# CONFIG_SERIAL_8250 is not set
600
601#
602# Non-8250 serial port support
603#
604CONFIG_SERIAL_SH_SCI=y
605CONFIG_SERIAL_SH_SCI_NR_UARTS=6
606CONFIG_SERIAL_SH_SCI_CONSOLE=y
607CONFIG_SERIAL_CORE=y
608CONFIG_SERIAL_CORE_CONSOLE=y
609CONFIG_UNIX98_PTYS=y
610CONFIG_LEGACY_PTYS=y
611CONFIG_LEGACY_PTY_COUNT=256
612# CONFIG_IPMI_HANDLER is not set
613CONFIG_HW_RANDOM=y
614# CONFIG_R3964 is not set
615# CONFIG_RAW_DRIVER is not set
616# CONFIG_TCG_TPM is not set
617# CONFIG_I2C is not set
618# CONFIG_SPI is not set
619# CONFIG_W1 is not set
620# CONFIG_POWER_SUPPLY is not set
621# CONFIG_HWMON is not set
622# CONFIG_THERMAL is not set
623# CONFIG_WATCHDOG is not set
624
625#
626# Sonics Silicon Backplane
627#
628CONFIG_SSB_POSSIBLE=y
629# CONFIG_SSB is not set
630
631#
632# Multifunction device drivers
633#
634# CONFIG_MFD_SM501 is not set
635# CONFIG_HTC_PASIC3 is not set
636
637#
638# Multimedia devices
639#
640
641#
642# Multimedia core support
643#
644# CONFIG_VIDEO_DEV is not set
645# CONFIG_DVB_CORE is not set
646# CONFIG_VIDEO_MEDIA is not set
647
648#
649# Multimedia drivers
650#
651# CONFIG_DAB is not set
652
653#
654# Graphics support
655#
656# CONFIG_VGASTATE is not set
657# CONFIG_VIDEO_OUTPUT_CONTROL is not set
658# CONFIG_FB is not set
659# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
660
661#
662# Display device support
663#
664# CONFIG_DISPLAY_SUPPORT is not set
665
666#
667# Console display driver support
668#
669CONFIG_DUMMY_CONSOLE=y
670
671#
672# Sound
673#
674# CONFIG_SOUND is not set
675# CONFIG_HID_SUPPORT is not set
676# CONFIG_USB_SUPPORT is not set
677# CONFIG_MMC is not set
678# CONFIG_MEMSTICK is not set
679# CONFIG_NEW_LEDS is not set
680# CONFIG_ACCESSIBILITY is not set
681# CONFIG_RTC_CLASS is not set
682# CONFIG_UIO is not set
683
684#
685# File systems
686#
687CONFIG_EXT2_FS=y
688CONFIG_EXT2_FS_XATTR=y
689CONFIG_EXT2_FS_POSIX_ACL=y
690CONFIG_EXT2_FS_SECURITY=y
691# CONFIG_EXT2_FS_XIP is not set
692CONFIG_EXT3_FS=y
693CONFIG_EXT3_FS_XATTR=y
694CONFIG_EXT3_FS_POSIX_ACL=y
695CONFIG_EXT3_FS_SECURITY=y
696# CONFIG_EXT4DEV_FS is not set
697CONFIG_JBD=y
698CONFIG_FS_MBCACHE=y
699# CONFIG_REISERFS_FS is not set
700# CONFIG_JFS_FS is not set
701CONFIG_FS_POSIX_ACL=y
702# CONFIG_XFS_FS is not set
703# CONFIG_OCFS2_FS is not set
704CONFIG_DNOTIFY=y
705CONFIG_INOTIFY=y
706CONFIG_INOTIFY_USER=y
707# CONFIG_QUOTA is not set
708# CONFIG_AUTOFS_FS is not set
709# CONFIG_AUTOFS4_FS is not set
710# CONFIG_FUSE_FS is not set
711
712#
713# CD-ROM/DVD Filesystems
714#
715# CONFIG_ISO9660_FS is not set
716# CONFIG_UDF_FS is not set
717
718#
719# DOS/FAT/NT Filesystems
720#
721CONFIG_FAT_FS=y
722# CONFIG_MSDOS_FS is not set
723CONFIG_VFAT_FS=y
724CONFIG_FAT_DEFAULT_CODEPAGE=437
725CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
726# CONFIG_NTFS_FS is not set
727
728#
729# Pseudo filesystems
730#
731CONFIG_PROC_FS=y
732CONFIG_PROC_KCORE=y
733CONFIG_PROC_SYSCTL=y
734CONFIG_SYSFS=y
735CONFIG_TMPFS=y
736# CONFIG_TMPFS_POSIX_ACL is not set
737# CONFIG_HUGETLBFS is not set
738# CONFIG_HUGETLB_PAGE is not set
739# CONFIG_CONFIGFS_FS is not set
740
741#
742# Miscellaneous filesystems
743#
744# CONFIG_ADFS_FS is not set
745# CONFIG_AFFS_FS is not set
746# CONFIG_HFS_FS is not set
747# CONFIG_HFSPLUS_FS is not set
748# CONFIG_BEFS_FS is not set
749# CONFIG_BFS_FS is not set
750# CONFIG_EFS_FS is not set
751# CONFIG_JFFS2_FS is not set
752# CONFIG_CRAMFS is not set
753# CONFIG_VXFS_FS is not set
754# CONFIG_MINIX_FS is not set
755# CONFIG_HPFS_FS is not set
756# CONFIG_QNX4FS_FS is not set
757# CONFIG_ROMFS_FS is not set
758# CONFIG_SYSV_FS is not set
759# CONFIG_UFS_FS is not set
760CONFIG_NETWORK_FILESYSTEMS=y
761CONFIG_NFS_FS=y
762CONFIG_NFS_V3=y
763# CONFIG_NFS_V3_ACL is not set
764# CONFIG_NFS_V4 is not set
765CONFIG_NFSD=y
766CONFIG_NFSD_V3=y
767# CONFIG_NFSD_V3_ACL is not set
768# CONFIG_NFSD_V4 is not set
769CONFIG_ROOT_NFS=y
770CONFIG_LOCKD=y
771CONFIG_LOCKD_V4=y
772CONFIG_EXPORTFS=y
773CONFIG_NFS_COMMON=y
774CONFIG_SUNRPC=y
775# CONFIG_SUNRPC_BIND34 is not set
776# CONFIG_RPCSEC_GSS_KRB5 is not set
777# CONFIG_RPCSEC_GSS_SPKM3 is not set
778# CONFIG_SMB_FS is not set
779# CONFIG_CIFS is not set
780# CONFIG_NCP_FS is not set
781# CONFIG_CODA_FS is not set
782# CONFIG_AFS_FS is not set
783
784#
785# Partition Types
786#
787# CONFIG_PARTITION_ADVANCED is not set
788CONFIG_MSDOS_PARTITION=y
789CONFIG_NLS=y
790CONFIG_NLS_DEFAULT="iso8859-1"
791CONFIG_NLS_CODEPAGE_437=y
792# CONFIG_NLS_CODEPAGE_737 is not set
793# CONFIG_NLS_CODEPAGE_775 is not set
794# CONFIG_NLS_CODEPAGE_850 is not set
795# CONFIG_NLS_CODEPAGE_852 is not set
796# CONFIG_NLS_CODEPAGE_855 is not set
797# CONFIG_NLS_CODEPAGE_857 is not set
798# CONFIG_NLS_CODEPAGE_860 is not set
799# CONFIG_NLS_CODEPAGE_861 is not set
800# CONFIG_NLS_CODEPAGE_862 is not set
801# CONFIG_NLS_CODEPAGE_863 is not set
802# CONFIG_NLS_CODEPAGE_864 is not set
803# CONFIG_NLS_CODEPAGE_865 is not set
804# CONFIG_NLS_CODEPAGE_866 is not set
805# CONFIG_NLS_CODEPAGE_869 is not set
806# CONFIG_NLS_CODEPAGE_936 is not set
807# CONFIG_NLS_CODEPAGE_950 is not set
808CONFIG_NLS_CODEPAGE_932=y
809# CONFIG_NLS_CODEPAGE_949 is not set
810# CONFIG_NLS_CODEPAGE_874 is not set
811# CONFIG_NLS_ISO8859_8 is not set
812# CONFIG_NLS_CODEPAGE_1250 is not set
813# CONFIG_NLS_CODEPAGE_1251 is not set
814# CONFIG_NLS_ASCII is not set
815CONFIG_NLS_ISO8859_1=y
816# CONFIG_NLS_ISO8859_2 is not set
817# CONFIG_NLS_ISO8859_3 is not set
818# CONFIG_NLS_ISO8859_4 is not set
819# CONFIG_NLS_ISO8859_5 is not set
820# CONFIG_NLS_ISO8859_6 is not set
821# CONFIG_NLS_ISO8859_7 is not set
822# CONFIG_NLS_ISO8859_9 is not set
823# CONFIG_NLS_ISO8859_13 is not set
824# CONFIG_NLS_ISO8859_14 is not set
825# CONFIG_NLS_ISO8859_15 is not set
826# CONFIG_NLS_KOI8_R is not set
827# CONFIG_NLS_KOI8_U is not set
828# CONFIG_NLS_UTF8 is not set
829# CONFIG_DLM is not set
830
831#
832# Kernel hacking
833#
834CONFIG_TRACE_IRQFLAGS_SUPPORT=y
835# CONFIG_PRINTK_TIME is not set
836CONFIG_ENABLE_WARN_DEPRECATED=y
837# CONFIG_ENABLE_MUST_CHECK is not set
838CONFIG_FRAME_WARN=1024
839# CONFIG_MAGIC_SYSRQ is not set
840# CONFIG_UNUSED_SYMBOLS is not set
841# CONFIG_DEBUG_FS is not set
842# CONFIG_HEADERS_CHECK is not set
843# CONFIG_DEBUG_KERNEL is not set
844# CONFIG_DEBUG_BUGVERBOSE is not set
845# CONFIG_SAMPLES is not set
846# CONFIG_SH_STANDARD_BIOS is not set
847# CONFIG_EARLY_SCIF_CONSOLE is not set
848# CONFIG_SH_KGDB is not set
849
850#
851# Security options
852#
853# CONFIG_KEYS is not set
854# CONFIG_SECURITY is not set
855# CONFIG_SECURITY_FILE_CAPABILITIES is not set
856CONFIG_CRYPTO=y
857
858#
859# Crypto core or helper
860#
861CONFIG_CRYPTO_ALGAPI=y
862CONFIG_CRYPTO_BLKCIPHER=y
863CONFIG_CRYPTO_MANAGER=y
864# CONFIG_CRYPTO_GF128MUL is not set
865# CONFIG_CRYPTO_NULL is not set
866# CONFIG_CRYPTO_CRYPTD is not set
867# CONFIG_CRYPTO_AUTHENC is not set
868# CONFIG_CRYPTO_TEST is not set
869
870#
871# Authenticated Encryption with Associated Data
872#
873# CONFIG_CRYPTO_CCM is not set
874# CONFIG_CRYPTO_GCM is not set
875# CONFIG_CRYPTO_SEQIV is not set
876
877#
878# Block modes
879#
880CONFIG_CRYPTO_CBC=y
881# CONFIG_CRYPTO_CTR is not set
882# CONFIG_CRYPTO_CTS is not set
883# CONFIG_CRYPTO_ECB is not set
884# CONFIG_CRYPTO_LRW is not set
885# CONFIG_CRYPTO_PCBC is not set
886# CONFIG_CRYPTO_XTS is not set
887
888#
889# Hash modes
890#
891# CONFIG_CRYPTO_HMAC is not set
892# CONFIG_CRYPTO_XCBC is not set
893
894#
895# Digest
896#
897# CONFIG_CRYPTO_CRC32C is not set
898# CONFIG_CRYPTO_MD4 is not set
899# CONFIG_CRYPTO_MD5 is not set
900# CONFIG_CRYPTO_MICHAEL_MIC is not set
901# CONFIG_CRYPTO_SHA1 is not set
902# CONFIG_CRYPTO_SHA256 is not set
903# CONFIG_CRYPTO_SHA512 is not set
904# CONFIG_CRYPTO_TGR192 is not set
905# CONFIG_CRYPTO_WP512 is not set
906
907#
908# Ciphers
909#
910# CONFIG_CRYPTO_AES is not set
911# CONFIG_CRYPTO_ANUBIS is not set
912# CONFIG_CRYPTO_ARC4 is not set
913# CONFIG_CRYPTO_BLOWFISH is not set
914# CONFIG_CRYPTO_CAMELLIA is not set
915# CONFIG_CRYPTO_CAST5 is not set
916# CONFIG_CRYPTO_CAST6 is not set
917# CONFIG_CRYPTO_DES is not set
918# CONFIG_CRYPTO_FCRYPT is not set
919# CONFIG_CRYPTO_KHAZAD is not set
920# CONFIG_CRYPTO_SALSA20 is not set
921# CONFIG_CRYPTO_SEED is not set
922# CONFIG_CRYPTO_SERPENT is not set
923# CONFIG_CRYPTO_TEA is not set
924# CONFIG_CRYPTO_TWOFISH is not set
925
926#
927# Compression
928#
929# CONFIG_CRYPTO_DEFLATE is not set
930# CONFIG_CRYPTO_LZO is not set
931CONFIG_CRYPTO_HW=y
932
933#
934# Library routines
935#
936CONFIG_BITREVERSE=y
937# CONFIG_GENERIC_FIND_FIRST_BIT is not set
938# CONFIG_CRC_CCITT is not set
939# CONFIG_CRC16 is not set
940# CONFIG_CRC_ITU_T is not set
941CONFIG_CRC32=y
942# CONFIG_CRC7 is not set
943# CONFIG_LIBCRC32C is not set
944CONFIG_PLIST=y
945CONFIG_HAS_IOMEM=y
946CONFIG_HAS_IOPORT=y
947CONFIG_HAS_DMA=y
diff --git a/arch/sh/configs/se7343_defconfig b/arch/sh/configs/se7343_defconfig
index 84c0075e2ad4..7b7273638447 100644
--- a/arch/sh/configs/se7343_defconfig
+++ b/arch/sh/configs/se7343_defconfig
@@ -1,40 +1,55 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.26-rc8
4# Tue Oct 3 11:46:17 2006 4# Mon Jul 7 13:12:45 2008
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_BUG=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y 10CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y 11CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 12CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 13CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_TIME=y
16CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_STACKTRACE_SUPPORT=y
18CONFIG_LOCKDEP_SUPPORT=y
19# CONFIG_ARCH_HAS_ILOG2_U32 is not set
20# CONFIG_ARCH_HAS_ILOG2_U64 is not set
21CONFIG_ARCH_NO_VIRT_TO_BUS=y
22CONFIG_ARCH_SUPPORTS_AOUT=y
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 23CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14 24
15# 25#
16# Code maturity level options 26# General setup
17# 27#
18CONFIG_EXPERIMENTAL=y 28CONFIG_EXPERIMENTAL=y
19CONFIG_BROKEN_ON_SMP=y 29CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32 30CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION="" 31CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y 32CONFIG_LOCALVERSION_AUTO=y
27# CONFIG_SWAP is not set 33# CONFIG_SWAP is not set
28CONFIG_SYSVIPC=y 34CONFIG_SYSVIPC=y
29# CONFIG_IPC_NS is not set 35CONFIG_SYSVIPC_SYSCTL=y
30CONFIG_POSIX_MQUEUE=y 36CONFIG_POSIX_MQUEUE=y
31# CONFIG_BSD_PROCESS_ACCT is not set 37# CONFIG_BSD_PROCESS_ACCT is not set
32# CONFIG_TASKSTATS is not set 38# CONFIG_TASKSTATS is not set
33# CONFIG_UTS_NS is not set
34# CONFIG_AUDIT is not set 39# CONFIG_AUDIT is not set
35# CONFIG_IKCONFIG is not set 40# CONFIG_IKCONFIG is not set
41CONFIG_LOG_BUF_SHIFT=14
42# CONFIG_CGROUPS is not set
43CONFIG_GROUP_SCHED=y
44CONFIG_FAIR_GROUP_SCHED=y
45# CONFIG_RT_GROUP_SCHED is not set
46CONFIG_USER_SCHED=y
47# CONFIG_CGROUP_SCHED is not set
48CONFIG_SYSFS_DEPRECATED=y
49CONFIG_SYSFS_DEPRECATED_V2=y
36# CONFIG_RELAY is not set 50# CONFIG_RELAY is not set
37CONFIG_INITRAMFS_SOURCE="" 51# CONFIG_NAMESPACES is not set
52# CONFIG_BLK_DEV_INITRD is not set
38CONFIG_CC_OPTIMIZE_FOR_SIZE=y 53CONFIG_CC_OPTIMIZE_FOR_SIZE=y
39CONFIG_SYSCTL=y 54CONFIG_SYSCTL=y
40CONFIG_EMBEDDED=y 55CONFIG_EMBEDDED=y
@@ -46,33 +61,41 @@ CONFIG_HOTPLUG=y
46CONFIG_PRINTK=y 61CONFIG_PRINTK=y
47CONFIG_BUG=y 62CONFIG_BUG=y
48CONFIG_ELF_CORE=y 63CONFIG_ELF_CORE=y
64CONFIG_COMPAT_BRK=y
49CONFIG_BASE_FULL=y 65CONFIG_BASE_FULL=y
50# CONFIG_FUTEX is not set 66# CONFIG_FUTEX is not set
67CONFIG_ANON_INODES=y
51# CONFIG_EPOLL is not set 68# CONFIG_EPOLL is not set
69CONFIG_SIGNALFD=y
70CONFIG_TIMERFD=y
71CONFIG_EVENTFD=y
52# CONFIG_SHMEM is not set 72# CONFIG_SHMEM is not set
53CONFIG_SLAB=y
54CONFIG_VM_EVENT_COUNTERS=y 73CONFIG_VM_EVENT_COUNTERS=y
74CONFIG_SLAB=y
75# CONFIG_SLUB is not set
76# CONFIG_SLOB is not set
77# CONFIG_PROFILING is not set
78# CONFIG_MARKERS is not set
79CONFIG_HAVE_OPROFILE=y
80# CONFIG_HAVE_KPROBES is not set
81# CONFIG_HAVE_KRETPROBES is not set
82# CONFIG_HAVE_DMA_ATTRS is not set
83CONFIG_PROC_PAGE_MONITOR=y
84CONFIG_SLABINFO=y
55CONFIG_TINY_SHMEM=y 85CONFIG_TINY_SHMEM=y
56CONFIG_BASE_SMALL=0 86CONFIG_BASE_SMALL=0
57# CONFIG_SLOB is not set
58
59#
60# Loadable module support
61#
62CONFIG_MODULES=y 87CONFIG_MODULES=y
88# CONFIG_MODULE_FORCE_LOAD is not set
63CONFIG_MODULE_UNLOAD=y 89CONFIG_MODULE_UNLOAD=y
64CONFIG_MODULE_FORCE_UNLOAD=y 90CONFIG_MODULE_FORCE_UNLOAD=y
65# CONFIG_MODVERSIONS is not set 91# CONFIG_MODVERSIONS is not set
66# CONFIG_MODULE_SRCVERSION_ALL is not set 92# CONFIG_MODULE_SRCVERSION_ALL is not set
67# CONFIG_KMOD is not set 93# CONFIG_KMOD is not set
68
69#
70# Block layer
71#
72CONFIG_BLOCK=y 94CONFIG_BLOCK=y
73# CONFIG_LBD is not set 95# CONFIG_LBD is not set
74# CONFIG_BLK_DEV_IO_TRACE is not set 96# CONFIG_BLK_DEV_IO_TRACE is not set
75# CONFIG_LSF is not set 97# CONFIG_LSF is not set
98# CONFIG_BLK_DEV_BSG is not set
76 99
77# 100#
78# IO Schedulers 101# IO Schedulers
@@ -86,62 +109,28 @@ CONFIG_DEFAULT_DEADLINE=y
86# CONFIG_DEFAULT_CFQ is not set 109# CONFIG_DEFAULT_CFQ is not set
87# CONFIG_DEFAULT_NOOP is not set 110# CONFIG_DEFAULT_NOOP is not set
88CONFIG_DEFAULT_IOSCHED="deadline" 111CONFIG_DEFAULT_IOSCHED="deadline"
112CONFIG_CLASSIC_RCU=y
89 113
90# 114#
91# System type 115# System type
92# 116#
93CONFIG_SOLUTION_ENGINE=y
94# CONFIG_SH_SOLUTION_ENGINE is not set
95# CONFIG_SH_7751_SOLUTION_ENGINE is not set
96# CONFIG_SH_7300_SOLUTION_ENGINE is not set
97CONFIG_SH_7343_SOLUTION_ENGINE=y
98# CONFIG_SH_73180_SOLUTION_ENGINE is not set
99# CONFIG_SH_7751_SYSTEMH is not set
100# CONFIG_SH_HP6XX is not set
101# CONFIG_SH_EC3104 is not set
102# CONFIG_SH_SATURN is not set
103# CONFIG_SH_DREAMCAST is not set
104# CONFIG_SH_BIGSUR is not set
105# CONFIG_SH_MPC1211 is not set
106# CONFIG_SH_SH03 is not set
107# CONFIG_SH_SECUREEDGE5410 is not set
108# CONFIG_SH_HS7751RVOIP is not set
109# CONFIG_SH_7710VOIPGW is not set
110# CONFIG_SH_RTS7751R2D is not set
111# CONFIG_SH_R7780RP is not set
112# CONFIG_SH_EDOSK7705 is not set
113# CONFIG_SH_SH4202_MICRODEV is not set
114# CONFIG_SH_LANDISK is not set
115# CONFIG_SH_TITAN is not set
116# CONFIG_SH_SHMIN is not set
117# CONFIG_SH_UNKNOWN is not set
118
119#
120# Processor selection
121#
122CONFIG_CPU_SH4=y 117CONFIG_CPU_SH4=y
123CONFIG_CPU_SH4A=y 118CONFIG_CPU_SH4A=y
124CONFIG_CPU_SH4AL_DSP=y 119CONFIG_CPU_SH4AL_DSP=y
125 120# CONFIG_CPU_SUBTYPE_SH7619 is not set
126# 121# CONFIG_CPU_SUBTYPE_SH7203 is not set
127# SH-2 Processor Support 122# CONFIG_CPU_SUBTYPE_SH7206 is not set
128# 123# CONFIG_CPU_SUBTYPE_SH7263 is not set
129# CONFIG_CPU_SUBTYPE_SH7604 is not set 124# CONFIG_CPU_SUBTYPE_MXG is not set
130
131#
132# SH-3 Processor Support
133#
134# CONFIG_CPU_SUBTYPE_SH7300 is not set
135# CONFIG_CPU_SUBTYPE_SH7705 is not set 125# CONFIG_CPU_SUBTYPE_SH7705 is not set
136# CONFIG_CPU_SUBTYPE_SH7706 is not set 126# CONFIG_CPU_SUBTYPE_SH7706 is not set
137# CONFIG_CPU_SUBTYPE_SH7707 is not set 127# CONFIG_CPU_SUBTYPE_SH7707 is not set
138# CONFIG_CPU_SUBTYPE_SH7708 is not set 128# CONFIG_CPU_SUBTYPE_SH7708 is not set
139# CONFIG_CPU_SUBTYPE_SH7709 is not set 129# CONFIG_CPU_SUBTYPE_SH7709 is not set
140# CONFIG_CPU_SUBTYPE_SH7710 is not set 130# CONFIG_CPU_SUBTYPE_SH7710 is not set
141 131# CONFIG_CPU_SUBTYPE_SH7712 is not set
142# 132# CONFIG_CPU_SUBTYPE_SH7720 is not set
143# SH-4 Processor Support 133# CONFIG_CPU_SUBTYPE_SH7721 is not set
144#
145# CONFIG_CPU_SUBTYPE_SH7750 is not set 134# CONFIG_CPU_SUBTYPE_SH7750 is not set
146# CONFIG_CPU_SUBTYPE_SH7091 is not set 135# CONFIG_CPU_SUBTYPE_SH7091 is not set
147# CONFIG_CPU_SUBTYPE_SH7750R is not set 136# CONFIG_CPU_SUBTYPE_SH7750R is not set
@@ -150,67 +139,88 @@ CONFIG_CPU_SH4AL_DSP=y
150# CONFIG_CPU_SUBTYPE_SH7751R is not set 139# CONFIG_CPU_SUBTYPE_SH7751R is not set
151# CONFIG_CPU_SUBTYPE_SH7760 is not set 140# CONFIG_CPU_SUBTYPE_SH7760 is not set
152# CONFIG_CPU_SUBTYPE_SH4_202 is not set 141# CONFIG_CPU_SUBTYPE_SH4_202 is not set
153 142# CONFIG_CPU_SUBTYPE_SH7723 is not set
154# 143# CONFIG_CPU_SUBTYPE_SH7763 is not set
155# ST40 Processor Support
156#
157# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
158# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
159
160#
161# SH-4A Processor Support
162#
163# CONFIG_CPU_SUBTYPE_SH7770 is not set 144# CONFIG_CPU_SUBTYPE_SH7770 is not set
164# CONFIG_CPU_SUBTYPE_SH7780 is not set 145# CONFIG_CPU_SUBTYPE_SH7780 is not set
165 146# CONFIG_CPU_SUBTYPE_SH7785 is not set
166# 147# CONFIG_CPU_SUBTYPE_SHX3 is not set
167# SH4AL-DSP Processor Support
168#
169# CONFIG_CPU_SUBTYPE_SH73180 is not set
170CONFIG_CPU_SUBTYPE_SH7343=y 148CONFIG_CPU_SUBTYPE_SH7343=y
149# CONFIG_CPU_SUBTYPE_SH7722 is not set
150# CONFIG_CPU_SUBTYPE_SH7366 is not set
151# CONFIG_CPU_SUBTYPE_SH5_101 is not set
152# CONFIG_CPU_SUBTYPE_SH5_103 is not set
171 153
172# 154#
173# Memory management options 155# Memory management options
174# 156#
157CONFIG_QUICKLIST=y
175CONFIG_MMU=y 158CONFIG_MMU=y
176CONFIG_PAGE_OFFSET=0x80000000 159CONFIG_PAGE_OFFSET=0x80000000
177CONFIG_MEMORY_START=0x0c000000 160CONFIG_MEMORY_START=0x0c000000
178CONFIG_MEMORY_SIZE=0x01000000 161CONFIG_MEMORY_SIZE=0x01000000
179CONFIG_32BIT=y 162CONFIG_29BIT=y
180CONFIG_VSYSCALL=y 163CONFIG_VSYSCALL=y
164CONFIG_ARCH_FLATMEM_ENABLE=y
165CONFIG_ARCH_SPARSEMEM_ENABLE=y
166CONFIG_ARCH_SPARSEMEM_DEFAULT=y
167CONFIG_MAX_ACTIVE_REGIONS=1
168CONFIG_ARCH_POPULATES_NODE_MAP=y
169CONFIG_ARCH_SELECT_MEMORY_MODEL=y
170CONFIG_PAGE_SIZE_4KB=y
171# CONFIG_PAGE_SIZE_8KB is not set
172# CONFIG_PAGE_SIZE_16KB is not set
173# CONFIG_PAGE_SIZE_64KB is not set
181CONFIG_SELECT_MEMORY_MODEL=y 174CONFIG_SELECT_MEMORY_MODEL=y
182CONFIG_FLATMEM_MANUAL=y 175CONFIG_FLATMEM_MANUAL=y
183# CONFIG_DISCONTIGMEM_MANUAL is not set 176# CONFIG_DISCONTIGMEM_MANUAL is not set
184# CONFIG_SPARSEMEM_MANUAL is not set 177# CONFIG_SPARSEMEM_MANUAL is not set
185CONFIG_FLATMEM=y 178CONFIG_FLATMEM=y
186CONFIG_FLAT_NODE_MEM_MAP=y 179CONFIG_FLAT_NODE_MEM_MAP=y
187# CONFIG_SPARSEMEM_STATIC is not set 180CONFIG_SPARSEMEM_STATIC=y
181# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
182CONFIG_PAGEFLAGS_EXTENDED=y
188CONFIG_SPLIT_PTLOCK_CPUS=4 183CONFIG_SPLIT_PTLOCK_CPUS=4
189# CONFIG_RESOURCES_64BIT is not set 184# CONFIG_RESOURCES_64BIT is not set
185CONFIG_ZONE_DMA_FLAG=0
186CONFIG_NR_QUICK=2
190 187
191# 188#
192# Cache configuration 189# Cache configuration
193# 190#
194# CONFIG_SH_DIRECT_MAPPED is not set 191# CONFIG_SH_DIRECT_MAPPED is not set
195# CONFIG_SH_WRITETHROUGH is not set 192CONFIG_CACHE_WRITEBACK=y
196# CONFIG_SH_OCRAM is not set 193# CONFIG_CACHE_WRITETHROUGH is not set
194# CONFIG_CACHE_OFF is not set
197 195
198# 196#
199# Processor features 197# Processor features
200# 198#
201CONFIG_CPU_LITTLE_ENDIAN=y 199CONFIG_CPU_LITTLE_ENDIAN=y
202# CONFIG_SH_FPU is not set 200# CONFIG_CPU_BIG_ENDIAN is not set
203# CONFIG_SH_FPU_EMU is not set 201# CONFIG_SH_FPU_EMU is not set
204CONFIG_SH_DSP=y 202CONFIG_SH_DSP=y
205# CONFIG_SH_STORE_QUEUES is not set 203# CONFIG_SH_STORE_QUEUES is not set
206CONFIG_CPU_HAS_INTEVT=y 204CONFIG_CPU_HAS_INTEVT=y
207CONFIG_CPU_HAS_SR_RB=y 205CONFIG_CPU_HAS_SR_RB=y
206CONFIG_CPU_HAS_DSP=y
207
208#
209# Board support
210#
211CONFIG_SOLUTION_ENGINE=y
212CONFIG_SH_7343_SOLUTION_ENGINE=y
208 213
209# 214#
210# Timer support 215# Timer and clock configuration
211# 216#
212CONFIG_SH_TMU=y 217CONFIG_SH_TMU=y
218CONFIG_SH_TIMER_IRQ=16
213CONFIG_SH_PCLK_FREQ=27000000 219CONFIG_SH_PCLK_FREQ=27000000
220# CONFIG_TICK_ONESHOT is not set
221# CONFIG_NO_HZ is not set
222# CONFIG_HIGH_RES_TIMERS is not set
223CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
214 224
215# 225#
216# CPU Frequency scaling 226# CPU Frequency scaling
@@ -225,57 +235,50 @@ CONFIG_SH_PCLK_FREQ=27000000
225# 235#
226# Companion Chips 236# Companion Chips
227# 237#
228# CONFIG_HD6446X_SERIES is not set 238
239#
240# Additional SuperH Device Drivers
241#
229CONFIG_HEARTBEAT=y 242CONFIG_HEARTBEAT=y
243# CONFIG_PUSH_SWITCH is not set
230 244
231# 245#
232# Kernel features 246# Kernel features
233# 247#
234# CONFIG_HZ_100 is not set 248# CONFIG_HZ_100 is not set
235CONFIG_HZ_250=y 249CONFIG_HZ_250=y
250# CONFIG_HZ_300 is not set
236# CONFIG_HZ_1000 is not set 251# CONFIG_HZ_1000 is not set
237CONFIG_HZ=250 252CONFIG_HZ=250
253# CONFIG_SCHED_HRTICK is not set
238# CONFIG_KEXEC is not set 254# CONFIG_KEXEC is not set
239# CONFIG_SMP is not set 255# CONFIG_CRASH_DUMP is not set
240CONFIG_PREEMPT_NONE=y 256CONFIG_PREEMPT_NONE=y
241# CONFIG_PREEMPT_VOLUNTARY is not set 257# CONFIG_PREEMPT_VOLUNTARY is not set
242# CONFIG_PREEMPT is not set 258# CONFIG_PREEMPT is not set
259CONFIG_GUSA=y
243 260
244# 261#
245# Boot options 262# Boot options
246# 263#
247CONFIG_ZERO_PAGE_OFFSET=0x00001000 264CONFIG_ZERO_PAGE_OFFSET=0x00001000
248CONFIG_BOOT_LINK_OFFSET=0x00800000 265CONFIG_BOOT_LINK_OFFSET=0x00800000
249# CONFIG_UBC_WAKEUP is not set
250# CONFIG_CMDLINE_BOOL is not set 266# CONFIG_CMDLINE_BOOL is not set
251 267
252# 268#
253# Bus options 269# Bus options
254# 270#
255# CONFIG_PCI is not set 271# CONFIG_CF_ENABLER is not set
256 272# CONFIG_ARCH_SUPPORTS_MSI is not set
257#
258# PCCARD (PCMCIA/CardBus) support
259#
260# CONFIG_PCCARD is not set 273# CONFIG_PCCARD is not set
261 274
262# 275#
263# PCI Hotplug Support
264#
265
266#
267# Executable file formats 276# Executable file formats
268# 277#
269CONFIG_BINFMT_ELF=y 278CONFIG_BINFMT_ELF=y
270# CONFIG_BINFMT_FLAT is not set
271# CONFIG_BINFMT_MISC is not set 279# CONFIG_BINFMT_MISC is not set
272 280
273# 281#
274# Power management options (EXPERIMENTAL)
275#
276# CONFIG_PM is not set
277
278#
279# Networking 282# Networking
280# 283#
281CONFIG_NET=y 284CONFIG_NET=y
@@ -283,22 +286,20 @@ CONFIG_NET=y
283# 286#
284# Networking options 287# Networking options
285# 288#
286# CONFIG_NETDEBUG is not set
287CONFIG_PACKET=y 289CONFIG_PACKET=y
288CONFIG_PACKET_MMAP=y 290CONFIG_PACKET_MMAP=y
289CONFIG_UNIX=y 291CONFIG_UNIX=y
290CONFIG_XFRM=y 292CONFIG_XFRM=y
291# CONFIG_XFRM_USER is not set 293# CONFIG_XFRM_USER is not set
292# CONFIG_XFRM_SUB_POLICY is not set 294# CONFIG_XFRM_SUB_POLICY is not set
295# CONFIG_XFRM_MIGRATE is not set
296# CONFIG_XFRM_STATISTICS is not set
293# CONFIG_NET_KEY is not set 297# CONFIG_NET_KEY is not set
294CONFIG_INET=y 298CONFIG_INET=y
295# CONFIG_IP_MULTICAST is not set 299# CONFIG_IP_MULTICAST is not set
296# CONFIG_IP_ADVANCED_ROUTER is not set 300# CONFIG_IP_ADVANCED_ROUTER is not set
297CONFIG_IP_FIB_HASH=y 301CONFIG_IP_FIB_HASH=y
298CONFIG_IP_PNP=y 302# CONFIG_IP_PNP is not set
299CONFIG_IP_PNP_DHCP=y
300# CONFIG_IP_PNP_BOOTP is not set
301# CONFIG_IP_PNP_RARP is not set
302# CONFIG_NET_IPIP is not set 303# CONFIG_NET_IPIP is not set
303# CONFIG_NET_IPGRE is not set 304# CONFIG_NET_IPGRE is not set
304# CONFIG_ARPD is not set 305# CONFIG_ARPD is not set
@@ -310,29 +311,18 @@ CONFIG_SYN_COOKIES=y
310# CONFIG_INET_TUNNEL is not set 311# CONFIG_INET_TUNNEL is not set
311CONFIG_INET_XFRM_MODE_TRANSPORT=y 312CONFIG_INET_XFRM_MODE_TRANSPORT=y
312CONFIG_INET_XFRM_MODE_TUNNEL=y 313CONFIG_INET_XFRM_MODE_TUNNEL=y
314CONFIG_INET_XFRM_MODE_BEET=y
315# CONFIG_INET_LRO is not set
313# CONFIG_INET_DIAG is not set 316# CONFIG_INET_DIAG is not set
314# CONFIG_TCP_CONG_ADVANCED is not set 317# CONFIG_TCP_CONG_ADVANCED is not set
315CONFIG_TCP_CONG_CUBIC=y 318CONFIG_TCP_CONG_CUBIC=y
316CONFIG_DEFAULT_TCP_CONG="cubic" 319CONFIG_DEFAULT_TCP_CONG="cubic"
320# CONFIG_TCP_MD5SIG is not set
317# CONFIG_IPV6 is not set 321# CONFIG_IPV6 is not set
318# CONFIG_INET6_XFRM_TUNNEL is not set
319# CONFIG_INET6_TUNNEL is not set
320# CONFIG_NETWORK_SECMARK is not set 322# CONFIG_NETWORK_SECMARK is not set
321# CONFIG_NETFILTER is not set 323# CONFIG_NETFILTER is not set
322
323#
324# DCCP Configuration (EXPERIMENTAL)
325#
326# CONFIG_IP_DCCP is not set 324# CONFIG_IP_DCCP is not set
327
328#
329# SCTP Configuration (EXPERIMENTAL)
330#
331# CONFIG_IP_SCTP is not set 325# CONFIG_IP_SCTP is not set
332
333#
334# TIPC Configuration (EXPERIMENTAL)
335#
336# CONFIG_TIPC is not set 326# CONFIG_TIPC is not set
337# CONFIG_ATM is not set 327# CONFIG_ATM is not set
338# CONFIG_BRIDGE is not set 328# CONFIG_BRIDGE is not set
@@ -345,10 +335,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
345# CONFIG_LAPB is not set 335# CONFIG_LAPB is not set
346# CONFIG_ECONET is not set 336# CONFIG_ECONET is not set
347# CONFIG_WAN_ROUTER is not set 337# CONFIG_WAN_ROUTER is not set
348
349#
350# QoS and/or fair queueing
351#
352# CONFIG_NET_SCHED is not set 338# CONFIG_NET_SCHED is not set
353 339
354# 340#
@@ -356,9 +342,20 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
356# 342#
357# CONFIG_NET_PKTGEN is not set 343# CONFIG_NET_PKTGEN is not set
358# CONFIG_HAMRADIO is not set 344# CONFIG_HAMRADIO is not set
345# CONFIG_CAN is not set
359# CONFIG_IRDA is not set 346# CONFIG_IRDA is not set
360# CONFIG_BT is not set 347# CONFIG_BT is not set
348# CONFIG_AF_RXRPC is not set
349
350#
351# Wireless
352#
353# CONFIG_CFG80211 is not set
354# CONFIG_WIRELESS_EXT is not set
355# CONFIG_MAC80211 is not set
361# CONFIG_IEEE80211 is not set 356# CONFIG_IEEE80211 is not set
357# CONFIG_RFKILL is not set
358# CONFIG_NET_9P is not set
362 359
363# 360#
364# Device Drivers 361# Device Drivers
@@ -367,36 +364,32 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
367# 364#
368# Generic Driver Options 365# Generic Driver Options
369# 366#
367CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
370CONFIG_STANDALONE=y 368CONFIG_STANDALONE=y
371CONFIG_PREVENT_FIRMWARE_BUILD=y 369CONFIG_PREVENT_FIRMWARE_BUILD=y
372CONFIG_FW_LOADER=y 370CONFIG_FW_LOADER=y
373# CONFIG_SYS_HYPERVISOR is not set 371# CONFIG_SYS_HYPERVISOR is not set
374
375#
376# Connector - unified userspace <-> kernelspace linker
377#
378# CONFIG_CONNECTOR is not set 372# CONFIG_CONNECTOR is not set
379
380#
381# Memory Technology Devices (MTD)
382#
383CONFIG_MTD=y 373CONFIG_MTD=y
384# CONFIG_MTD_DEBUG is not set 374# CONFIG_MTD_DEBUG is not set
385CONFIG_MTD_CONCAT=y 375CONFIG_MTD_CONCAT=y
386CONFIG_MTD_PARTITIONS=y 376CONFIG_MTD_PARTITIONS=y
387# CONFIG_MTD_REDBOOT_PARTS is not set 377# CONFIG_MTD_REDBOOT_PARTS is not set
388# CONFIG_MTD_CMDLINE_PARTS is not set 378# CONFIG_MTD_CMDLINE_PARTS is not set
379# CONFIG_MTD_AR7_PARTS is not set
389 380
390# 381#
391# User Modules And Translation Layers 382# User Modules And Translation Layers
392# 383#
393CONFIG_MTD_CHAR=y 384CONFIG_MTD_CHAR=y
385CONFIG_MTD_BLKDEVS=y
394CONFIG_MTD_BLOCK=y 386CONFIG_MTD_BLOCK=y
395# CONFIG_FTL is not set 387# CONFIG_FTL is not set
396# CONFIG_NFTL is not set 388# CONFIG_NFTL is not set
397# CONFIG_INFTL is not set 389# CONFIG_INFTL is not set
398# CONFIG_RFD_FTL is not set 390# CONFIG_RFD_FTL is not set
399# CONFIG_SSFDC is not set 391# CONFIG_SSFDC is not set
392# CONFIG_MTD_OOPS is not set
400 393
401# 394#
402# RAM/ROM/Flash chip drivers 395# RAM/ROM/Flash chip drivers
@@ -422,13 +415,15 @@ CONFIG_MTD_CFI_UTIL=y
422CONFIG_MTD_RAM=y 415CONFIG_MTD_RAM=y
423# CONFIG_MTD_ROM is not set 416# CONFIG_MTD_ROM is not set
424# CONFIG_MTD_ABSENT is not set 417# CONFIG_MTD_ABSENT is not set
425# CONFIG_MTD_OBSOLETE_CHIPS is not set
426 418
427# 419#
428# Mapping drivers for chip access 420# Mapping drivers for chip access
429# 421#
430# CONFIG_MTD_COMPLEX_MAPPINGS is not set 422# CONFIG_MTD_COMPLEX_MAPPINGS is not set
431# CONFIG_MTD_PHYSMAP is not set 423CONFIG_MTD_PHYSMAP=y
424CONFIG_MTD_PHYSMAP_START=0x0
425CONFIG_MTD_PHYSMAP_LEN=0
426CONFIG_MTD_PHYSMAP_BANKWIDTH=0
432# CONFIG_MTD_PLATRAM is not set 427# CONFIG_MTD_PLATRAM is not set
433 428
434# 429#
@@ -445,130 +440,101 @@ CONFIG_MTD_RAM=y
445# CONFIG_MTD_DOC2000 is not set 440# CONFIG_MTD_DOC2000 is not set
446# CONFIG_MTD_DOC2001 is not set 441# CONFIG_MTD_DOC2001 is not set
447# CONFIG_MTD_DOC2001PLUS is not set 442# CONFIG_MTD_DOC2001PLUS is not set
448
449#
450# NAND Flash Device Drivers
451#
452# CONFIG_MTD_NAND is not set 443# CONFIG_MTD_NAND is not set
453
454#
455# OneNAND Flash Device Drivers
456#
457# CONFIG_MTD_ONENAND is not set 444# CONFIG_MTD_ONENAND is not set
458 445
459# 446#
460# Parallel port support 447# UBI - Unsorted block images
461# 448#
449# CONFIG_MTD_UBI is not set
462# CONFIG_PARPORT is not set 450# CONFIG_PARPORT is not set
463 451CONFIG_BLK_DEV=y
464#
465# Plug and Play support
466#
467
468#
469# Block devices
470#
471# CONFIG_BLK_DEV_COW_COMMON is not set 452# CONFIG_BLK_DEV_COW_COMMON is not set
472# CONFIG_BLK_DEV_LOOP is not set 453# CONFIG_BLK_DEV_LOOP is not set
473# CONFIG_BLK_DEV_NBD is not set 454# CONFIG_BLK_DEV_NBD is not set
474# CONFIG_BLK_DEV_RAM is not set 455# CONFIG_BLK_DEV_RAM is not set
475# CONFIG_BLK_DEV_INITRD is not set
476# CONFIG_CDROM_PKTCDVD is not set 456# CONFIG_CDROM_PKTCDVD is not set
477# CONFIG_ATA_OVER_ETH is not set 457# CONFIG_ATA_OVER_ETH is not set
478 458# CONFIG_MISC_DEVICES is not set
479# 459CONFIG_HAVE_IDE=y
480# ATA/ATAPI/MFM/RLL support
481#
482# CONFIG_IDE is not set 460# CONFIG_IDE is not set
483 461
484# 462#
485# SCSI device support 463# SCSI device support
486# 464#
487# CONFIG_RAID_ATTRS is not set 465# CONFIG_RAID_ATTRS is not set
488# CONFIG_SCSI is not set 466CONFIG_SCSI=y
467CONFIG_SCSI_DMA=y
468# CONFIG_SCSI_TGT is not set
489# CONFIG_SCSI_NETLINK is not set 469# CONFIG_SCSI_NETLINK is not set
470CONFIG_SCSI_PROC_FS=y
490 471
491# 472#
492# Serial ATA (prod) and Parallel ATA (experimental) drivers 473# SCSI support type (disk, tape, CD-ROM)
493#
494# CONFIG_ATA is not set
495
496#
497# Multi-device support (RAID and LVM)
498#
499# CONFIG_MD is not set
500
501#
502# Fusion MPT device support
503#
504# CONFIG_FUSION is not set
505
506#
507# IEEE 1394 (FireWire) support
508# 474#
475# CONFIG_BLK_DEV_SD is not set
476# CONFIG_CHR_DEV_ST is not set
477# CONFIG_CHR_DEV_OSST is not set
478# CONFIG_BLK_DEV_SR is not set
479# CONFIG_CHR_DEV_SG is not set
480# CONFIG_CHR_DEV_SCH is not set
509 481
510# 482#
511# I2O device support 483# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
512# 484#
485CONFIG_SCSI_MULTI_LUN=y
486# CONFIG_SCSI_CONSTANTS is not set
487# CONFIG_SCSI_LOGGING is not set
488# CONFIG_SCSI_SCAN_ASYNC is not set
489CONFIG_SCSI_WAIT_SCAN=m
513 490
514# 491#
515# Network device support 492# SCSI Transports
516# 493#
494# CONFIG_SCSI_SPI_ATTRS is not set
495# CONFIG_SCSI_FC_ATTRS is not set
496# CONFIG_SCSI_ISCSI_ATTRS is not set
497# CONFIG_SCSI_SAS_LIBSAS is not set
498# CONFIG_SCSI_SRP_ATTRS is not set
499# CONFIG_SCSI_LOWLEVEL is not set
500# CONFIG_ATA is not set
501# CONFIG_MD is not set
517CONFIG_NETDEVICES=y 502CONFIG_NETDEVICES=y
503# CONFIG_NETDEVICES_MULTIQUEUE is not set
518# CONFIG_DUMMY is not set 504# CONFIG_DUMMY is not set
519# CONFIG_BONDING is not set 505# CONFIG_BONDING is not set
506# CONFIG_MACVLAN is not set
520# CONFIG_EQUALIZER is not set 507# CONFIG_EQUALIZER is not set
521# CONFIG_TUN is not set 508# CONFIG_TUN is not set
522 509# CONFIG_VETH is not set
523#
524# PHY device support
525#
526# CONFIG_PHYLIB is not set 510# CONFIG_PHYLIB is not set
527
528#
529# Ethernet (10 or 100Mbit)
530#
531CONFIG_NET_ETHERNET=y 511CONFIG_NET_ETHERNET=y
532CONFIG_MII=y 512CONFIG_MII=y
513# CONFIG_AX88796 is not set
533# CONFIG_STNIC is not set 514# CONFIG_STNIC is not set
534CONFIG_SMC91X=y 515CONFIG_SMC91X=y
516# CONFIG_IBM_NEW_EMAC_ZMII is not set
517# CONFIG_IBM_NEW_EMAC_RGMII is not set
518# CONFIG_IBM_NEW_EMAC_TAH is not set
519# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
520# CONFIG_B44 is not set
521CONFIG_NETDEV_1000=y
522# CONFIG_E1000E_ENABLED is not set
523CONFIG_NETDEV_10000=y
535 524
536# 525#
537# Ethernet (1000 Mbit) 526# Wireless LAN
538#
539
540#
541# Ethernet (10000 Mbit)
542#
543
544#
545# Token Ring devices
546#
547
548#
549# Wireless LAN (non-hamradio)
550#
551# CONFIG_NET_RADIO is not set
552
553#
554# Wan interfaces
555# 527#
528# CONFIG_WLAN_PRE80211 is not set
529# CONFIG_WLAN_80211 is not set
530# CONFIG_IWLWIFI_LEDS is not set
556# CONFIG_WAN is not set 531# CONFIG_WAN is not set
557# CONFIG_PPP is not set 532# CONFIG_PPP is not set
558# CONFIG_SLIP is not set 533# CONFIG_SLIP is not set
559# CONFIG_SHAPER is not set
560# CONFIG_NETCONSOLE is not set 534# CONFIG_NETCONSOLE is not set
561# CONFIG_NETPOLL is not set 535# CONFIG_NETPOLL is not set
562# CONFIG_NET_POLL_CONTROLLER is not set 536# CONFIG_NET_POLL_CONTROLLER is not set
563
564#
565# ISDN subsystem
566#
567# CONFIG_ISDN is not set 537# CONFIG_ISDN is not set
568
569#
570# Telephony Support
571#
572# CONFIG_PHONE is not set 538# CONFIG_PHONE is not set
573 539
574# 540#
@@ -576,13 +542,13 @@ CONFIG_SMC91X=y
576# 542#
577CONFIG_INPUT=y 543CONFIG_INPUT=y
578# CONFIG_INPUT_FF_MEMLESS is not set 544# CONFIG_INPUT_FF_MEMLESS is not set
545# CONFIG_INPUT_POLLDEV is not set
579 546
580# 547#
581# Userland interfaces 548# Userland interfaces
582# 549#
583# CONFIG_INPUT_MOUSEDEV is not set 550# CONFIG_INPUT_MOUSEDEV is not set
584# CONFIG_INPUT_JOYDEV is not set 551# CONFIG_INPUT_JOYDEV is not set
585# CONFIG_INPUT_TSDEV is not set
586# CONFIG_INPUT_EVDEV is not set 552# CONFIG_INPUT_EVDEV is not set
587# CONFIG_INPUT_EVBUG is not set 553# CONFIG_INPUT_EVBUG is not set
588 554
@@ -592,6 +558,7 @@ CONFIG_INPUT=y
592# CONFIG_INPUT_KEYBOARD is not set 558# CONFIG_INPUT_KEYBOARD is not set
593# CONFIG_INPUT_MOUSE is not set 559# CONFIG_INPUT_MOUSE is not set
594# CONFIG_INPUT_JOYSTICK is not set 560# CONFIG_INPUT_JOYSTICK is not set
561# CONFIG_INPUT_TABLET is not set
595# CONFIG_INPUT_TOUCHSCREEN is not set 562# CONFIG_INPUT_TOUCHSCREEN is not set
596# CONFIG_INPUT_MISC is not set 563# CONFIG_INPUT_MISC is not set
597 564
@@ -608,6 +575,7 @@ CONFIG_VT=y
608CONFIG_VT_CONSOLE=y 575CONFIG_VT_CONSOLE=y
609CONFIG_HW_CONSOLE=y 576CONFIG_HW_CONSOLE=y
610# CONFIG_VT_HW_CONSOLE_BINDING is not set 577# CONFIG_VT_HW_CONSOLE_BINDING is not set
578CONFIG_DEVKMEM=y
611# CONFIG_SERIAL_NONSTANDARD is not set 579# CONFIG_SERIAL_NONSTANDARD is not set
612 580
613# 581#
@@ -626,147 +594,102 @@ CONFIG_SERIAL_CORE_CONSOLE=y
626# CONFIG_UNIX98_PTYS is not set 594# CONFIG_UNIX98_PTYS is not set
627CONFIG_LEGACY_PTYS=y 595CONFIG_LEGACY_PTYS=y
628CONFIG_LEGACY_PTY_COUNT=256 596CONFIG_LEGACY_PTY_COUNT=256
629
630#
631# IPMI
632#
633# CONFIG_IPMI_HANDLER is not set 597# CONFIG_IPMI_HANDLER is not set
634
635#
636# Watchdog Cards
637#
638# CONFIG_WATCHDOG is not set
639CONFIG_HW_RANDOM=y 598CONFIG_HW_RANDOM=y
640# CONFIG_GEN_RTC is not set
641# CONFIG_DTLK is not set
642# CONFIG_R3964 is not set 599# CONFIG_R3964 is not set
643
644#
645# Ftape, the floppy tape device driver
646#
647# CONFIG_RAW_DRIVER is not set 600# CONFIG_RAW_DRIVER is not set
648
649#
650# TPM devices
651#
652# CONFIG_TCG_TPM is not set 601# CONFIG_TCG_TPM is not set
653# CONFIG_TELCLOCK is not set 602# CONFIG_I2C is not set
654
655#
656# I2C support
657#
658CONFIG_I2C=y
659CONFIG_I2C_CHARDEV=y
660
661#
662# I2C Algorithms
663#
664# CONFIG_I2C_ALGOBIT is not set
665# CONFIG_I2C_ALGOPCF is not set
666# CONFIG_I2C_ALGOPCA is not set
667
668#
669# I2C Hardware Bus support
670#
671# CONFIG_I2C_OCORES is not set
672# CONFIG_I2C_PARPORT_LIGHT is not set
673# CONFIG_I2C_STUB is not set
674# CONFIG_I2C_PCA_ISA is not set
675
676#
677# Miscellaneous I2C Chip support
678#
679# CONFIG_SENSORS_DS1337 is not set
680# CONFIG_SENSORS_DS1374 is not set
681# CONFIG_SENSORS_EEPROM is not set
682# CONFIG_SENSORS_PCF8574 is not set
683# CONFIG_SENSORS_PCA9539 is not set
684# CONFIG_SENSORS_PCF8591 is not set
685# CONFIG_SENSORS_MAX6875 is not set
686# CONFIG_I2C_DEBUG_CORE is not set
687# CONFIG_I2C_DEBUG_ALGO is not set
688# CONFIG_I2C_DEBUG_BUS is not set
689# CONFIG_I2C_DEBUG_CHIP is not set
690
691#
692# SPI support
693#
694# CONFIG_SPI is not set 603# CONFIG_SPI is not set
695# CONFIG_SPI_MASTER is not set 604# CONFIG_W1 is not set
605# CONFIG_POWER_SUPPLY is not set
606# CONFIG_HWMON is not set
607# CONFIG_THERMAL is not set
608# CONFIG_THERMAL_HWMON is not set
609# CONFIG_WATCHDOG is not set
696 610
697# 611#
698# Dallas's 1-wire bus 612# Sonics Silicon Backplane
699# 613#
614CONFIG_SSB_POSSIBLE=y
615# CONFIG_SSB is not set
700 616
701# 617#
702# Hardware Monitoring support 618# Multifunction device drivers
703# 619#
704# CONFIG_HWMON is not set 620# CONFIG_MFD_SM501 is not set
705# CONFIG_HWMON_VID is not set 621# CONFIG_HTC_PASIC3 is not set
706 622
707# 623#
708# Misc devices 624# Multimedia devices
709# 625#
710 626
711# 627#
712# Multimedia devices 628# Multimedia core support
713# 629#
714CONFIG_VIDEO_DEV=y 630CONFIG_VIDEO_DEV=y
715CONFIG_VIDEO_V4L1=y 631CONFIG_VIDEO_V4L2_COMMON=y
632CONFIG_VIDEO_ALLOW_V4L1=y
716CONFIG_VIDEO_V4L1_COMPAT=y 633CONFIG_VIDEO_V4L1_COMPAT=y
717CONFIG_VIDEO_V4L2=y 634# CONFIG_DVB_CORE is not set
718 635CONFIG_VIDEO_MEDIA=y
719#
720# Video Capture Adapters
721#
722 636
723# 637#
724# Video Capture Adapters 638# Multimedia drivers
725# 639#
640# CONFIG_MEDIA_ATTACH is not set
641CONFIG_VIDEO_V4L2=y
642CONFIG_VIDEO_V4L1=y
643CONFIG_VIDEO_CAPTURE_DRIVERS=y
726# CONFIG_VIDEO_ADV_DEBUG is not set 644# CONFIG_VIDEO_ADV_DEBUG is not set
727CONFIG_VIDEO_HELPER_CHIPS_AUTO=y 645CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
728# CONFIG_VIDEO_VIVI is not set 646# CONFIG_VIDEO_VIVI is not set
729# CONFIG_VIDEO_CPIA is not set 647# CONFIG_VIDEO_CPIA is not set
730# CONFIG_VIDEO_SAA5246A is not set 648# CONFIG_SOC_CAMERA is not set
731# CONFIG_VIDEO_SAA5249 is not set 649CONFIG_RADIO_ADAPTERS=y
732# CONFIG_TUNER_3036 is not set 650# CONFIG_DAB is not set
733
734#
735# Radio Adapters
736#
737
738#
739# Digital Video Broadcasting Devices
740#
741# CONFIG_DVB is not set
742 651
743# 652#
744# Graphics support 653# Graphics support
745# 654#
746CONFIG_FIRMWARE_EDID=y 655# CONFIG_VGASTATE is not set
656# CONFIG_VIDEO_OUTPUT_CONTROL is not set
747CONFIG_FB=y 657CONFIG_FB=y
658CONFIG_FIRMWARE_EDID=y
659# CONFIG_FB_DDC is not set
748# CONFIG_FB_CFB_FILLRECT is not set 660# CONFIG_FB_CFB_FILLRECT is not set
749# CONFIG_FB_CFB_COPYAREA is not set 661# CONFIG_FB_CFB_COPYAREA is not set
750# CONFIG_FB_CFB_IMAGEBLIT is not set 662# CONFIG_FB_CFB_IMAGEBLIT is not set
663# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
664# CONFIG_FB_SYS_FILLRECT is not set
665# CONFIG_FB_SYS_COPYAREA is not set
666# CONFIG_FB_SYS_IMAGEBLIT is not set
667# CONFIG_FB_FOREIGN_ENDIAN is not set
668# CONFIG_FB_SYS_FOPS is not set
669# CONFIG_FB_SVGALIB is not set
751# CONFIG_FB_MACMODES is not set 670# CONFIG_FB_MACMODES is not set
752# CONFIG_FB_BACKLIGHT is not set 671# CONFIG_FB_BACKLIGHT is not set
753# CONFIG_FB_MODE_HELPERS is not set 672# CONFIG_FB_MODE_HELPERS is not set
754# CONFIG_FB_TILEBLITTING is not set 673# CONFIG_FB_TILEBLITTING is not set
755# CONFIG_FB_EPSON1355 is not set 674
675#
676# Frame buffer hardware drivers
677#
756# CONFIG_FB_S1D13XXX is not set 678# CONFIG_FB_S1D13XXX is not set
757# CONFIG_FB_VIRTUAL is not set 679# CONFIG_FB_VIRTUAL is not set
680# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
758 681
759# 682#
760# Console display driver support 683# Display device support
761# 684#
762CONFIG_DUMMY_CONSOLE=y 685# CONFIG_DISPLAY_SUPPORT is not set
763# CONFIG_FRAMEBUFFER_CONSOLE is not set
764 686
765# 687#
766# Logo configuration 688# Console display driver support
767# 689#
690CONFIG_DUMMY_CONSOLE=y
691# CONFIG_FRAMEBUFFER_CONSOLE is not set
768# CONFIG_LOGO is not set 692# CONFIG_LOGO is not set
769# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
770 693
771# 694#
772# Sound 695# Sound
@@ -802,85 +725,63 @@ CONFIG_SND_VERBOSE_PROCFS=y
802# CONFIG_SND_MPU401 is not set 725# CONFIG_SND_MPU401 is not set
803 726
804# 727#
805# Open Sound System 728# SUPERH devices
806# 729#
807# CONFIG_SOUND_PRIME is not set
808 730
809# 731#
810# USB support 732# System on Chip audio support
811# 733#
812# CONFIG_USB_ARCH_HAS_HCD is not set 734# CONFIG_SND_SOC is not set
813# CONFIG_USB_ARCH_HAS_OHCI is not set
814# CONFIG_USB_ARCH_HAS_EHCI is not set
815 735
816# 736#
817# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 737# SoC Audio support for SuperH
818# 738#
819 739
820# 740#
821# USB Gadget Support 741# ALSA SoC audio for Freescale SOCs
822# 742#
823# CONFIG_USB_GADGET is not set
824 743
825# 744#
826# MMC/SD Card support 745# SoC Audio for the Texas Instruments OMAP
827# 746#
828# CONFIG_MMC is not set
829 747
830# 748#
831# LED devices 749# Open Sound System
832# 750#
751# CONFIG_SOUND_PRIME is not set
752CONFIG_HID_SUPPORT=y
753CONFIG_HID=y
754# CONFIG_HID_DEBUG is not set
755# CONFIG_HIDRAW is not set
756# CONFIG_USB_SUPPORT is not set
757# CONFIG_MMC is not set
758# CONFIG_MEMSTICK is not set
833# CONFIG_NEW_LEDS is not set 759# CONFIG_NEW_LEDS is not set
834 760# CONFIG_ACCESSIBILITY is not set
835#
836# LED drivers
837#
838
839#
840# LED Triggers
841#
842
843#
844# InfiniBand support
845#
846
847#
848# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
849#
850
851#
852# Real Time Clock
853#
854# CONFIG_RTC_CLASS is not set 761# CONFIG_RTC_CLASS is not set
855 762# CONFIG_UIO is not set
856#
857# DMA Engine support
858#
859# CONFIG_DMA_ENGINE is not set
860
861#
862# DMA Clients
863#
864
865#
866# DMA Devices
867#
868 763
869# 764#
870# File systems 765# File systems
871# 766#
872# CONFIG_EXT2_FS is not set 767CONFIG_EXT2_FS=y
873# CONFIG_EXT3_FS is not set 768# CONFIG_EXT2_FS_XATTR is not set
769# CONFIG_EXT2_FS_XIP is not set
770CONFIG_EXT3_FS=y
771CONFIG_EXT3_FS_XATTR=y
772# CONFIG_EXT3_FS_POSIX_ACL is not set
773# CONFIG_EXT3_FS_SECURITY is not set
774# CONFIG_EXT4DEV_FS is not set
775CONFIG_JBD=y
776CONFIG_FS_MBCACHE=y
874# CONFIG_REISERFS_FS is not set 777# CONFIG_REISERFS_FS is not set
875# CONFIG_JFS_FS is not set 778# CONFIG_JFS_FS is not set
876# CONFIG_FS_POSIX_ACL is not set 779# CONFIG_FS_POSIX_ACL is not set
877# CONFIG_XFS_FS is not set 780# CONFIG_XFS_FS is not set
878# CONFIG_OCFS2_FS is not set 781# CONFIG_OCFS2_FS is not set
879# CONFIG_MINIX_FS is not set 782# CONFIG_DNOTIFY is not set
880# CONFIG_ROMFS_FS is not set
881# CONFIG_INOTIFY is not set 783# CONFIG_INOTIFY is not set
882# CONFIG_QUOTA is not set 784# CONFIG_QUOTA is not set
883# CONFIG_DNOTIFY is not set
884# CONFIG_AUTOFS_FS is not set 785# CONFIG_AUTOFS_FS is not set
885# CONFIG_AUTOFS4_FS is not set 786# CONFIG_AUTOFS4_FS is not set
886# CONFIG_FUSE_FS is not set 787# CONFIG_FUSE_FS is not set
@@ -909,7 +810,6 @@ CONFIG_TMPFS=y
909# CONFIG_TMPFS_POSIX_ACL is not set 810# CONFIG_TMPFS_POSIX_ACL is not set
910# CONFIG_HUGETLBFS is not set 811# CONFIG_HUGETLBFS is not set
911# CONFIG_HUGETLB_PAGE is not set 812# CONFIG_HUGETLB_PAGE is not set
912CONFIG_RAMFS=y
913# CONFIG_CONFIGFS_FS is not set 813# CONFIG_CONFIGFS_FS is not set
914 814
915# 815#
@@ -922,40 +822,39 @@ CONFIG_RAMFS=y
922# CONFIG_BEFS_FS is not set 822# CONFIG_BEFS_FS is not set
923# CONFIG_BFS_FS is not set 823# CONFIG_BFS_FS is not set
924# CONFIG_EFS_FS is not set 824# CONFIG_EFS_FS is not set
925# CONFIG_JFFS_FS is not set
926CONFIG_JFFS2_FS=y 825CONFIG_JFFS2_FS=y
927CONFIG_JFFS2_FS_DEBUG=0 826CONFIG_JFFS2_FS_DEBUG=0
928CONFIG_JFFS2_FS_WRITEBUFFER=y 827CONFIG_JFFS2_FS_WRITEBUFFER=y
828# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
929# CONFIG_JFFS2_SUMMARY is not set 829# CONFIG_JFFS2_SUMMARY is not set
930# CONFIG_JFFS2_FS_XATTR is not set 830# CONFIG_JFFS2_FS_XATTR is not set
931# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 831# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
932CONFIG_JFFS2_ZLIB=y 832CONFIG_JFFS2_ZLIB=y
833# CONFIG_JFFS2_LZO is not set
933CONFIG_JFFS2_RTIME=y 834CONFIG_JFFS2_RTIME=y
934# CONFIG_JFFS2_RUBIN is not set 835# CONFIG_JFFS2_RUBIN is not set
935# CONFIG_CRAMFS is not set 836CONFIG_CRAMFS=y
936# CONFIG_VXFS_FS is not set 837# CONFIG_VXFS_FS is not set
838# CONFIG_MINIX_FS is not set
937# CONFIG_HPFS_FS is not set 839# CONFIG_HPFS_FS is not set
938# CONFIG_QNX4FS_FS is not set 840# CONFIG_QNX4FS_FS is not set
841# CONFIG_ROMFS_FS is not set
939# CONFIG_SYSV_FS is not set 842# CONFIG_SYSV_FS is not set
940# CONFIG_UFS_FS is not set 843# CONFIG_UFS_FS is not set
941 844CONFIG_NETWORK_FILESYSTEMS=y
942#
943# Network File Systems
944#
945CONFIG_NFS_FS=y 845CONFIG_NFS_FS=y
946CONFIG_NFS_V3=y 846CONFIG_NFS_V3=y
947# CONFIG_NFS_V3_ACL is not set 847# CONFIG_NFS_V3_ACL is not set
948# CONFIG_NFS_V4 is not set 848# CONFIG_NFS_V4 is not set
949# CONFIG_NFS_DIRECTIO is not set
950CONFIG_NFSD=y 849CONFIG_NFSD=y
951# CONFIG_NFSD_V3 is not set 850# CONFIG_NFSD_V3 is not set
952# CONFIG_NFSD_TCP is not set 851# CONFIG_NFSD_V4 is not set
953CONFIG_ROOT_NFS=y
954CONFIG_LOCKD=y 852CONFIG_LOCKD=y
955CONFIG_LOCKD_V4=y 853CONFIG_LOCKD_V4=y
956CONFIG_EXPORTFS=y 854CONFIG_EXPORTFS=y
957CONFIG_NFS_COMMON=y 855CONFIG_NFS_COMMON=y
958CONFIG_SUNRPC=y 856CONFIG_SUNRPC=y
857# CONFIG_SUNRPC_BIND34 is not set
959# CONFIG_RPCSEC_GSS_KRB5 is not set 858# CONFIG_RPCSEC_GSS_KRB5 is not set
960# CONFIG_RPCSEC_GSS_SPKM3 is not set 859# CONFIG_RPCSEC_GSS_SPKM3 is not set
961# CONFIG_SMB_FS is not set 860# CONFIG_SMB_FS is not set
@@ -963,56 +862,130 @@ CONFIG_SUNRPC=y
963# CONFIG_NCP_FS is not set 862# CONFIG_NCP_FS is not set
964# CONFIG_CODA_FS is not set 863# CONFIG_CODA_FS is not set
965# CONFIG_AFS_FS is not set 864# CONFIG_AFS_FS is not set
966# CONFIG_9P_FS is not set
967 865
968# 866#
969# Partition Types 867# Partition Types
970# 868#
971# CONFIG_PARTITION_ADVANCED is not set 869# CONFIG_PARTITION_ADVANCED is not set
972CONFIG_MSDOS_PARTITION=y 870CONFIG_MSDOS_PARTITION=y
973
974#
975# Native Language Support
976#
977# CONFIG_NLS is not set 871# CONFIG_NLS is not set
978 872# CONFIG_DLM is not set
979#
980# Profiling support
981#
982# CONFIG_PROFILING is not set
983 873
984# 874#
985# Kernel hacking 875# Kernel hacking
986# 876#
877CONFIG_TRACE_IRQFLAGS_SUPPORT=y
987# CONFIG_PRINTK_TIME is not set 878# CONFIG_PRINTK_TIME is not set
879CONFIG_ENABLE_WARN_DEPRECATED=y
988CONFIG_ENABLE_MUST_CHECK=y 880CONFIG_ENABLE_MUST_CHECK=y
881CONFIG_FRAME_WARN=1024
989# CONFIG_MAGIC_SYSRQ is not set 882# CONFIG_MAGIC_SYSRQ is not set
990# CONFIG_UNUSED_SYMBOLS is not set 883# CONFIG_UNUSED_SYMBOLS is not set
884# CONFIG_DEBUG_FS is not set
885# CONFIG_HEADERS_CHECK is not set
991# CONFIG_DEBUG_KERNEL is not set 886# CONFIG_DEBUG_KERNEL is not set
992CONFIG_LOG_BUF_SHIFT=14
993# CONFIG_DEBUG_BUGVERBOSE is not set 887# CONFIG_DEBUG_BUGVERBOSE is not set
994# CONFIG_DEBUG_FS is not set 888# CONFIG_SAMPLES is not set
995# CONFIG_SH_STANDARD_BIOS is not set 889# CONFIG_SH_STANDARD_BIOS is not set
996# CONFIG_EARLY_SCIF_CONSOLE is not set 890CONFIG_EARLY_SCIF_CONSOLE=y
997# CONFIG_KGDB is not set 891CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe00000
892CONFIG_EARLY_PRINTK=y
893# CONFIG_SH_KGDB is not set
998 894
999# 895#
1000# Security options 896# Security options
1001# 897#
1002# CONFIG_KEYS is not set 898# CONFIG_KEYS is not set
1003# CONFIG_SECURITY is not set 899# CONFIG_SECURITY is not set
900# CONFIG_SECURITY_FILE_CAPABILITIES is not set
901CONFIG_CRYPTO=y
902
903#
904# Crypto core or helper
905#
906# CONFIG_CRYPTO_MANAGER is not set
907# CONFIG_CRYPTO_GF128MUL is not set
908# CONFIG_CRYPTO_NULL is not set
909# CONFIG_CRYPTO_CRYPTD is not set
910# CONFIG_CRYPTO_AUTHENC is not set
911# CONFIG_CRYPTO_TEST is not set
912
913#
914# Authenticated Encryption with Associated Data
915#
916# CONFIG_CRYPTO_CCM is not set
917# CONFIG_CRYPTO_GCM is not set
918# CONFIG_CRYPTO_SEQIV is not set
919
920#
921# Block modes
922#
923# CONFIG_CRYPTO_CBC is not set
924# CONFIG_CRYPTO_CTR is not set
925# CONFIG_CRYPTO_CTS is not set
926# CONFIG_CRYPTO_ECB is not set
927# CONFIG_CRYPTO_LRW is not set
928# CONFIG_CRYPTO_PCBC is not set
929# CONFIG_CRYPTO_XTS is not set
930
931#
932# Hash modes
933#
934# CONFIG_CRYPTO_HMAC is not set
935# CONFIG_CRYPTO_XCBC is not set
936
937#
938# Digest
939#
940# CONFIG_CRYPTO_CRC32C is not set
941# CONFIG_CRYPTO_MD4 is not set
942# CONFIG_CRYPTO_MD5 is not set
943# CONFIG_CRYPTO_MICHAEL_MIC is not set
944# CONFIG_CRYPTO_SHA1 is not set
945# CONFIG_CRYPTO_SHA256 is not set
946# CONFIG_CRYPTO_SHA512 is not set
947# CONFIG_CRYPTO_TGR192 is not set
948# CONFIG_CRYPTO_WP512 is not set
949
950#
951# Ciphers
952#
953# CONFIG_CRYPTO_AES is not set
954# CONFIG_CRYPTO_ANUBIS is not set
955# CONFIG_CRYPTO_ARC4 is not set
956# CONFIG_CRYPTO_BLOWFISH is not set
957# CONFIG_CRYPTO_CAMELLIA is not set
958# CONFIG_CRYPTO_CAST5 is not set
959# CONFIG_CRYPTO_CAST6 is not set
960# CONFIG_CRYPTO_DES is not set
961# CONFIG_CRYPTO_FCRYPT is not set
962# CONFIG_CRYPTO_KHAZAD is not set
963# CONFIG_CRYPTO_SALSA20 is not set
964# CONFIG_CRYPTO_SEED is not set
965# CONFIG_CRYPTO_SERPENT is not set
966# CONFIG_CRYPTO_TEA is not set
967# CONFIG_CRYPTO_TWOFISH is not set
1004 968
1005# 969#
1006# Cryptographic options 970# Compression
1007# 971#
1008# CONFIG_CRYPTO is not set 972# CONFIG_CRYPTO_DEFLATE is not set
973# CONFIG_CRYPTO_LZO is not set
974CONFIG_CRYPTO_HW=y
1009 975
1010# 976#
1011# Library routines 977# Library routines
1012# 978#
979CONFIG_BITREVERSE=y
980# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1013# CONFIG_CRC_CCITT is not set 981# CONFIG_CRC_CCITT is not set
1014# CONFIG_CRC16 is not set 982# CONFIG_CRC16 is not set
983# CONFIG_CRC_ITU_T is not set
1015CONFIG_CRC32=y 984CONFIG_CRC32=y
985# CONFIG_CRC7 is not set
1016# CONFIG_LIBCRC32C is not set 986# CONFIG_LIBCRC32C is not set
1017CONFIG_ZLIB_INFLATE=y 987CONFIG_ZLIB_INFLATE=y
1018CONFIG_ZLIB_DEFLATE=y 988CONFIG_ZLIB_DEFLATE=y
989CONFIG_HAS_IOMEM=y
990CONFIG_HAS_IOPORT=y
991CONFIG_HAS_DMA=y
diff --git a/arch/sh/configs/se7712_defconfig b/arch/sh/configs/se7712_defconfig
index 2dd83af988f0..7be79cd04eb0 100644
--- a/arch/sh/configs/se7712_defconfig
+++ b/arch/sh/configs/se7712_defconfig
@@ -1,53 +1,57 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc4 3# Linux kernel version: 2.6.26-rc6
4# Wed Mar 28 10:19:02 2007 4# Wed Jun 18 16:36:08 2008
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y 9CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y 10CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 11CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 12CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 13CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set 14CONFIG_GENERIC_TIME=y
15CONFIG_GENERIC_CLOCKEVENTS=y
14CONFIG_STACKTRACE_SUPPORT=y 16CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_LOCKDEP_SUPPORT=y 17CONFIG_LOCKDEP_SUPPORT=y
16# CONFIG_ARCH_HAS_ILOG2_U32 is not set 18# CONFIG_ARCH_HAS_ILOG2_U32 is not set
17# CONFIG_ARCH_HAS_ILOG2_U64 is not set 19# CONFIG_ARCH_HAS_ILOG2_U64 is not set
20CONFIG_ARCH_NO_VIRT_TO_BUS=y
21CONFIG_ARCH_SUPPORTS_AOUT=y
18CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
19 23
20# 24#
21# Code maturity level options 25# General setup
22# 26#
23CONFIG_EXPERIMENTAL=y 27CONFIG_EXPERIMENTAL=y
24CONFIG_BROKEN_ON_SMP=y 28CONFIG_BROKEN_ON_SMP=y
25CONFIG_INIT_ENV_ARG_LIMIT=32 29CONFIG_INIT_ENV_ARG_LIMIT=32
26
27#
28# General setup
29#
30CONFIG_LOCALVERSION="" 30CONFIG_LOCALVERSION=""
31# CONFIG_LOCALVERSION_AUTO is not set 31# CONFIG_LOCALVERSION_AUTO is not set
32# CONFIG_SWAP is not set 32# CONFIG_SWAP is not set
33CONFIG_SYSVIPC=y 33CONFIG_SYSVIPC=y
34# CONFIG_IPC_NS is not set
35CONFIG_SYSVIPC_SYSCTL=y 34CONFIG_SYSVIPC_SYSCTL=y
36CONFIG_POSIX_MQUEUE=y 35CONFIG_POSIX_MQUEUE=y
37CONFIG_BSD_PROCESS_ACCT=y 36CONFIG_BSD_PROCESS_ACCT=y
38# CONFIG_BSD_PROCESS_ACCT_V3 is not set 37# CONFIG_BSD_PROCESS_ACCT_V3 is not set
39# CONFIG_TASKSTATS is not set 38# CONFIG_TASKSTATS is not set
40# CONFIG_UTS_NS is not set
41# CONFIG_AUDIT is not set 39# CONFIG_AUDIT is not set
42# CONFIG_IKCONFIG is not set 40# CONFIG_IKCONFIG is not set
41CONFIG_LOG_BUF_SHIFT=14
42# CONFIG_CGROUPS is not set
43# CONFIG_GROUP_SCHED is not set
43CONFIG_SYSFS_DEPRECATED=y 44CONFIG_SYSFS_DEPRECATED=y
45CONFIG_SYSFS_DEPRECATED_V2=y
44# CONFIG_RELAY is not set 46# CONFIG_RELAY is not set
47# CONFIG_NAMESPACES is not set
45# CONFIG_BLK_DEV_INITRD is not set 48# CONFIG_BLK_DEV_INITRD is not set
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 49# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SYSCTL=y 50CONFIG_SYSCTL=y
48CONFIG_EMBEDDED=y 51CONFIG_EMBEDDED=y
49CONFIG_UID16=y 52CONFIG_UID16=y
50CONFIG_SYSCTL_SYSCALL=y 53CONFIG_SYSCTL_SYSCALL=y
54CONFIG_SYSCTL_SYSCALL_CHECK=y
51CONFIG_KALLSYMS=y 55CONFIG_KALLSYMS=y
52CONFIG_KALLSYMS_ALL=y 56CONFIG_KALLSYMS_ALL=y
53# CONFIG_KALLSYMS_EXTRA_PASS is not set 57# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -55,33 +59,41 @@ CONFIG_HOTPLUG=y
55CONFIG_PRINTK=y 59CONFIG_PRINTK=y
56# CONFIG_BUG is not set 60# CONFIG_BUG is not set
57CONFIG_ELF_CORE=y 61CONFIG_ELF_CORE=y
62CONFIG_COMPAT_BRK=y
58# CONFIG_BASE_FULL is not set 63# CONFIG_BASE_FULL is not set
59CONFIG_FUTEX=y 64CONFIG_FUTEX=y
65CONFIG_ANON_INODES=y
60CONFIG_EPOLL=y 66CONFIG_EPOLL=y
67CONFIG_SIGNALFD=y
68CONFIG_TIMERFD=y
69CONFIG_EVENTFD=y
61# CONFIG_SHMEM is not set 70# CONFIG_SHMEM is not set
62CONFIG_SLAB=y
63CONFIG_VM_EVENT_COUNTERS=y 71CONFIG_VM_EVENT_COUNTERS=y
72CONFIG_SLAB=y
73# CONFIG_SLUB is not set
74# CONFIG_SLOB is not set
75# CONFIG_PROFILING is not set
76# CONFIG_MARKERS is not set
77CONFIG_HAVE_OPROFILE=y
78# CONFIG_HAVE_KPROBES is not set
79# CONFIG_HAVE_KRETPROBES is not set
80# CONFIG_HAVE_DMA_ATTRS is not set
81CONFIG_PROC_PAGE_MONITOR=y
82CONFIG_SLABINFO=y
64CONFIG_RT_MUTEXES=y 83CONFIG_RT_MUTEXES=y
65CONFIG_TINY_SHMEM=y 84CONFIG_TINY_SHMEM=y
66CONFIG_BASE_SMALL=1 85CONFIG_BASE_SMALL=1
67# CONFIG_SLOB is not set
68
69#
70# Loadable module support
71#
72CONFIG_MODULES=y 86CONFIG_MODULES=y
87# CONFIG_MODULE_FORCE_LOAD is not set
73# CONFIG_MODULE_UNLOAD is not set 88# CONFIG_MODULE_UNLOAD is not set
74# CONFIG_MODVERSIONS is not set 89# CONFIG_MODVERSIONS is not set
75# CONFIG_MODULE_SRCVERSION_ALL is not set 90# CONFIG_MODULE_SRCVERSION_ALL is not set
76# CONFIG_KMOD is not set 91# CONFIG_KMOD is not set
77
78#
79# Block layer
80#
81CONFIG_BLOCK=y 92CONFIG_BLOCK=y
82# CONFIG_LBD is not set 93# CONFIG_LBD is not set
83# CONFIG_BLK_DEV_IO_TRACE is not set 94# CONFIG_BLK_DEV_IO_TRACE is not set
84# CONFIG_LSF is not set 95# CONFIG_LSF is not set
96# CONFIG_BLK_DEV_BSG is not set
85 97
86# 98#
87# IO Schedulers 99# IO Schedulers
@@ -95,57 +107,17 @@ CONFIG_IOSCHED_NOOP=y
95# CONFIG_DEFAULT_CFQ is not set 107# CONFIG_DEFAULT_CFQ is not set
96CONFIG_DEFAULT_NOOP=y 108CONFIG_DEFAULT_NOOP=y
97CONFIG_DEFAULT_IOSCHED="noop" 109CONFIG_DEFAULT_IOSCHED="noop"
110CONFIG_CLASSIC_RCU=y
98 111
99# 112#
100# System type 113# System type
101# 114#
102CONFIG_SOLUTION_ENGINE=y
103CONFIG_SH_SOLUTION_ENGINE=y
104# CONFIG_SH_7751_SOLUTION_ENGINE is not set
105# CONFIG_SH_7300_SOLUTION_ENGINE is not set
106# CONFIG_SH_7343_SOLUTION_ENGINE is not set
107# CONFIG_SH_73180_SOLUTION_ENGINE is not set
108# CONFIG_SH_7751_SYSTEMH is not set
109# CONFIG_SH_HP6XX is not set
110# CONFIG_SH_SATURN is not set
111# CONFIG_SH_DREAMCAST is not set
112# CONFIG_SH_MPC1211 is not set
113# CONFIG_SH_SH03 is not set
114# CONFIG_SH_SECUREEDGE5410 is not set
115# CONFIG_SH_HS7751RVOIP is not set
116# CONFIG_SH_7710VOIPGW is not set
117# CONFIG_SH_RTS7751R2D is not set
118# CONFIG_SH_HIGHLANDER is not set
119# CONFIG_SH_EDOSK7705 is not set
120# CONFIG_SH_SH4202_MICRODEV is not set
121# CONFIG_SH_LANDISK is not set
122# CONFIG_SH_TITAN is not set
123# CONFIG_SH_SHMIN is not set
124# CONFIG_SH_7206_SOLUTION_ENGINE is not set
125# CONFIG_SH_7619_SOLUTION_ENGINE is not set
126# CONFIG_SH_LBOX_RE2 is not set
127# CONFIG_SH_UNKNOWN is not set
128
129#
130# Processor selection
131#
132CONFIG_CPU_SH3=y 115CONFIG_CPU_SH3=y
133
134#
135# SH-2 Processor Support
136#
137# CONFIG_CPU_SUBTYPE_SH7604 is not set
138# CONFIG_CPU_SUBTYPE_SH7619 is not set 116# CONFIG_CPU_SUBTYPE_SH7619 is not set
139 117# CONFIG_CPU_SUBTYPE_SH7203 is not set
140#
141# SH-2A Processor Support
142#
143# CONFIG_CPU_SUBTYPE_SH7206 is not set 118# CONFIG_CPU_SUBTYPE_SH7206 is not set
144 119# CONFIG_CPU_SUBTYPE_SH7263 is not set
145# 120# CONFIG_CPU_SUBTYPE_MXG is not set
146# SH-3 Processor Support
147#
148# CONFIG_CPU_SUBTYPE_SH7300 is not set
149# CONFIG_CPU_SUBTYPE_SH7705 is not set 121# CONFIG_CPU_SUBTYPE_SH7705 is not set
150# CONFIG_CPU_SUBTYPE_SH7706 is not set 122# CONFIG_CPU_SUBTYPE_SH7706 is not set
151# CONFIG_CPU_SUBTYPE_SH7707 is not set 123# CONFIG_CPU_SUBTYPE_SH7707 is not set
@@ -153,10 +125,8 @@ CONFIG_CPU_SH3=y
153# CONFIG_CPU_SUBTYPE_SH7709 is not set 125# CONFIG_CPU_SUBTYPE_SH7709 is not set
154# CONFIG_CPU_SUBTYPE_SH7710 is not set 126# CONFIG_CPU_SUBTYPE_SH7710 is not set
155CONFIG_CPU_SUBTYPE_SH7712=y 127CONFIG_CPU_SUBTYPE_SH7712=y
156 128# CONFIG_CPU_SUBTYPE_SH7720 is not set
157# 129# CONFIG_CPU_SUBTYPE_SH7721 is not set
158# SH-4 Processor Support
159#
160# CONFIG_CPU_SUBTYPE_SH7750 is not set 130# CONFIG_CPU_SUBTYPE_SH7750 is not set
161# CONFIG_CPU_SUBTYPE_SH7091 is not set 131# CONFIG_CPU_SUBTYPE_SH7091 is not set
162# CONFIG_CPU_SUBTYPE_SH7750R is not set 132# CONFIG_CPU_SUBTYPE_SH7750R is not set
@@ -165,37 +135,37 @@ CONFIG_CPU_SUBTYPE_SH7712=y
165# CONFIG_CPU_SUBTYPE_SH7751R is not set 135# CONFIG_CPU_SUBTYPE_SH7751R is not set
166# CONFIG_CPU_SUBTYPE_SH7760 is not set 136# CONFIG_CPU_SUBTYPE_SH7760 is not set
167# CONFIG_CPU_SUBTYPE_SH4_202 is not set 137# CONFIG_CPU_SUBTYPE_SH4_202 is not set
168 138# CONFIG_CPU_SUBTYPE_SH7723 is not set
169# 139# CONFIG_CPU_SUBTYPE_SH7763 is not set
170# ST40 Processor Support
171#
172# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
173# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
174
175#
176# SH-4A Processor Support
177#
178# CONFIG_CPU_SUBTYPE_SH7770 is not set 140# CONFIG_CPU_SUBTYPE_SH7770 is not set
179# CONFIG_CPU_SUBTYPE_SH7780 is not set 141# CONFIG_CPU_SUBTYPE_SH7780 is not set
180# CONFIG_CPU_SUBTYPE_SH7785 is not set 142# CONFIG_CPU_SUBTYPE_SH7785 is not set
181 143# CONFIG_CPU_SUBTYPE_SHX3 is not set
182#
183# SH4AL-DSP Processor Support
184#
185# CONFIG_CPU_SUBTYPE_SH73180 is not set
186# CONFIG_CPU_SUBTYPE_SH7343 is not set 144# CONFIG_CPU_SUBTYPE_SH7343 is not set
187# CONFIG_CPU_SUBTYPE_SH7722 is not set 145# CONFIG_CPU_SUBTYPE_SH7722 is not set
146# CONFIG_CPU_SUBTYPE_SH7366 is not set
147# CONFIG_CPU_SUBTYPE_SH5_101 is not set
148# CONFIG_CPU_SUBTYPE_SH5_103 is not set
188 149
189# 150#
190# Memory management options 151# Memory management options
191# 152#
153CONFIG_QUICKLIST=y
192CONFIG_MMU=y 154CONFIG_MMU=y
193CONFIG_PAGE_OFFSET=0x80000000 155CONFIG_PAGE_OFFSET=0x80000000
194CONFIG_MEMORY_START=0x0c000000 156CONFIG_MEMORY_START=0x0c000000
195CONFIG_MEMORY_SIZE=0x02000000 157CONFIG_MEMORY_SIZE=0x02000000
158CONFIG_29BIT=y
196CONFIG_VSYSCALL=y 159CONFIG_VSYSCALL=y
160CONFIG_ARCH_FLATMEM_ENABLE=y
161CONFIG_ARCH_SPARSEMEM_ENABLE=y
162CONFIG_ARCH_SPARSEMEM_DEFAULT=y
163CONFIG_MAX_ACTIVE_REGIONS=1
164CONFIG_ARCH_POPULATES_NODE_MAP=y
165CONFIG_ARCH_SELECT_MEMORY_MODEL=y
197CONFIG_PAGE_SIZE_4KB=y 166CONFIG_PAGE_SIZE_4KB=y
198# CONFIG_PAGE_SIZE_8KB is not set 167# CONFIG_PAGE_SIZE_8KB is not set
168# CONFIG_PAGE_SIZE_16KB is not set
199# CONFIG_PAGE_SIZE_64KB is not set 169# CONFIG_PAGE_SIZE_64KB is not set
200CONFIG_SELECT_MEMORY_MODEL=y 170CONFIG_SELECT_MEMORY_MODEL=y
201CONFIG_FLATMEM_MANUAL=y 171CONFIG_FLATMEM_MANUAL=y
@@ -203,21 +173,21 @@ CONFIG_FLATMEM_MANUAL=y
203# CONFIG_SPARSEMEM_MANUAL is not set 173# CONFIG_SPARSEMEM_MANUAL is not set
204CONFIG_FLATMEM=y 174CONFIG_FLATMEM=y
205CONFIG_FLAT_NODE_MEM_MAP=y 175CONFIG_FLAT_NODE_MEM_MAP=y
206# CONFIG_SPARSEMEM_STATIC is not set 176CONFIG_SPARSEMEM_STATIC=y
177# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
178CONFIG_PAGEFLAGS_EXTENDED=y
207CONFIG_SPLIT_PTLOCK_CPUS=4 179CONFIG_SPLIT_PTLOCK_CPUS=4
208# CONFIG_RESOURCES_64BIT is not set 180# CONFIG_RESOURCES_64BIT is not set
209CONFIG_ZONE_DMA_FLAG=0 181CONFIG_ZONE_DMA_FLAG=0
182CONFIG_NR_QUICK=2
210 183
211# 184#
212# Cache configuration 185# Cache configuration
213# 186#
214# CONFIG_SH_DIRECT_MAPPED is not set 187# CONFIG_SH_DIRECT_MAPPED is not set
215# CONFIG_SH_WRITETHROUGH is not set 188CONFIG_CACHE_WRITEBACK=y
216# CONFIG_SH_OCRAM is not set 189# CONFIG_CACHE_WRITETHROUGH is not set
217CONFIG_CF_ENABLER=y 190# CONFIG_CACHE_OFF is not set
218# CONFIG_CF_AREA5 is not set
219CONFIG_CF_AREA6=y
220CONFIG_CF_BASE_ADDR=0xb8000000
221 191
222# 192#
223# Processor features 193# Processor features
@@ -230,6 +200,14 @@ CONFIG_CPU_LITTLE_ENDIAN=y
230CONFIG_CPU_HAS_INTEVT=y 200CONFIG_CPU_HAS_INTEVT=y
231CONFIG_CPU_HAS_IPR_IRQ=y 201CONFIG_CPU_HAS_IPR_IRQ=y
232CONFIG_CPU_HAS_SR_RB=y 202CONFIG_CPU_HAS_SR_RB=y
203CONFIG_CPU_HAS_DSP=y
204
205#
206# Board support
207#
208CONFIG_SOLUTION_ENGINE=y
209CONFIG_SH_SOLUTION_ENGINE=y
210# CONFIG_SH_AP325RXA is not set
233 211
234# 212#
235# Timer and clock configuration 213# Timer and clock configuration
@@ -237,6 +215,10 @@ CONFIG_CPU_HAS_SR_RB=y
237CONFIG_SH_TMU=y 215CONFIG_SH_TMU=y
238CONFIG_SH_TIMER_IRQ=16 216CONFIG_SH_TIMER_IRQ=16
239CONFIG_SH_PCLK_FREQ=66666666 217CONFIG_SH_PCLK_FREQ=66666666
218# CONFIG_TICK_ONESHOT is not set
219# CONFIG_NO_HZ is not set
220# CONFIG_HIGH_RES_TIMERS is not set
221CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
240 222
241# 223#
242# CPU Frequency scaling 224# CPU Frequency scaling
@@ -251,7 +233,6 @@ CONFIG_SH_PCLK_FREQ=66666666
251# 233#
252# Companion Chips 234# Companion Chips
253# 235#
254# CONFIG_HD6446X_SERIES is not set
255 236
256# 237#
257# Additional SuperH Device Drivers 238# Additional SuperH Device Drivers
@@ -267,48 +248,40 @@ CONFIG_HZ_250=y
267# CONFIG_HZ_300 is not set 248# CONFIG_HZ_300 is not set
268# CONFIG_HZ_1000 is not set 249# CONFIG_HZ_1000 is not set
269CONFIG_HZ=250 250CONFIG_HZ=250
251# CONFIG_SCHED_HRTICK is not set
270# CONFIG_KEXEC is not set 252# CONFIG_KEXEC is not set
271# CONFIG_SMP is not set 253# CONFIG_CRASH_DUMP is not set
272# CONFIG_PREEMPT_NONE is not set 254# CONFIG_PREEMPT_NONE is not set
273CONFIG_PREEMPT_VOLUNTARY=y 255CONFIG_PREEMPT_VOLUNTARY=y
274# CONFIG_PREEMPT is not set 256# CONFIG_PREEMPT is not set
257CONFIG_GUSA=y
258# CONFIG_GUSA_RB is not set
275 259
276# 260#
277# Boot options 261# Boot options
278# 262#
279CONFIG_ZERO_PAGE_OFFSET=0x00001000 263CONFIG_ZERO_PAGE_OFFSET=0x00001000
280CONFIG_BOOT_LINK_OFFSET=0x00800000 264CONFIG_BOOT_LINK_OFFSET=0x00800000
281# CONFIG_UBC_WAKEUP is not set
282CONFIG_CMDLINE_BOOL=y 265CONFIG_CMDLINE_BOOL=y
283CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1" 266CONFIG_CMDLINE="console=ttySC0,115200 root=/dev/sda1"
284 267
285# 268#
286# Bus options 269# Bus options
287# 270#
288# CONFIG_PCI is not set 271CONFIG_CF_ENABLER=y
289 272# CONFIG_CF_AREA5 is not set
290# 273CONFIG_CF_AREA6=y
291# PCCARD (PCMCIA/CardBus) support 274CONFIG_CF_BASE_ADDR=0xb8000000
292# 275# CONFIG_ARCH_SUPPORTS_MSI is not set
293# CONFIG_PCCARD is not set 276# CONFIG_PCCARD is not set
294 277
295# 278#
296# PCI Hotplug Support
297#
298
299#
300# Executable file formats 279# Executable file formats
301# 280#
302CONFIG_BINFMT_ELF=y 281CONFIG_BINFMT_ELF=y
303# CONFIG_BINFMT_FLAT is not set
304# CONFIG_BINFMT_MISC is not set 282# CONFIG_BINFMT_MISC is not set
305 283
306# 284#
307# Power management options (EXPERIMENTAL)
308#
309# CONFIG_PM is not set
310
311#
312# Networking 285# Networking
313# 286#
314CONFIG_NET=y 287CONFIG_NET=y
@@ -316,7 +289,6 @@ CONFIG_NET=y
316# 289#
317# Networking options 290# Networking options
318# 291#
319# CONFIG_NETDEBUG is not set
320CONFIG_PACKET=y 292CONFIG_PACKET=y
321CONFIG_PACKET_MMAP=y 293CONFIG_PACKET_MMAP=y
322CONFIG_UNIX=y 294CONFIG_UNIX=y
@@ -324,6 +296,7 @@ CONFIG_XFRM=y
324# CONFIG_XFRM_USER is not set 296# CONFIG_XFRM_USER is not set
325# CONFIG_XFRM_SUB_POLICY is not set 297# CONFIG_XFRM_SUB_POLICY is not set
326# CONFIG_XFRM_MIGRATE is not set 298# CONFIG_XFRM_MIGRATE is not set
299# CONFIG_XFRM_STATISTICS is not set
327CONFIG_NET_KEY=y 300CONFIG_NET_KEY=y
328# CONFIG_NET_KEY_MIGRATE is not set 301# CONFIG_NET_KEY_MIGRATE is not set
329CONFIG_INET=y 302CONFIG_INET=y
@@ -334,11 +307,10 @@ CONFIG_ASK_IP_FIB_HASH=y
334CONFIG_IP_FIB_HASH=y 307CONFIG_IP_FIB_HASH=y
335CONFIG_IP_MULTIPLE_TABLES=y 308CONFIG_IP_MULTIPLE_TABLES=y
336CONFIG_IP_ROUTE_MULTIPATH=y 309CONFIG_IP_ROUTE_MULTIPATH=y
337# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
338CONFIG_IP_ROUTE_VERBOSE=y 310CONFIG_IP_ROUTE_VERBOSE=y
339CONFIG_IP_PNP=y 311CONFIG_IP_PNP=y
340CONFIG_IP_PNP_DHCP=y 312CONFIG_IP_PNP_DHCP=y
341# CONFIG_IP_PNP_BOOTP is not set 313CONFIG_IP_PNP_BOOTP=y
342# CONFIG_IP_PNP_RARP is not set 314# CONFIG_IP_PNP_RARP is not set
343# CONFIG_NET_IPIP is not set 315# CONFIG_NET_IPIP is not set
344# CONFIG_NET_IPGRE is not set 316# CONFIG_NET_IPGRE is not set
@@ -355,30 +327,17 @@ CONFIG_INET_TUNNEL=y
355CONFIG_INET_XFRM_MODE_TRANSPORT=y 327CONFIG_INET_XFRM_MODE_TRANSPORT=y
356CONFIG_INET_XFRM_MODE_TUNNEL=y 328CONFIG_INET_XFRM_MODE_TUNNEL=y
357CONFIG_INET_XFRM_MODE_BEET=y 329CONFIG_INET_XFRM_MODE_BEET=y
330# CONFIG_INET_LRO is not set
358# CONFIG_INET_DIAG is not set 331# CONFIG_INET_DIAG is not set
359# CONFIG_TCP_CONG_ADVANCED is not set 332# CONFIG_TCP_CONG_ADVANCED is not set
360CONFIG_TCP_CONG_CUBIC=y 333CONFIG_TCP_CONG_CUBIC=y
361CONFIG_DEFAULT_TCP_CONG="cubic" 334CONFIG_DEFAULT_TCP_CONG="cubic"
362# CONFIG_TCP_MD5SIG is not set 335# CONFIG_TCP_MD5SIG is not set
363# CONFIG_IPV6 is not set 336# CONFIG_IPV6 is not set
364# CONFIG_INET6_XFRM_TUNNEL is not set
365# CONFIG_INET6_TUNNEL is not set
366# CONFIG_NETWORK_SECMARK is not set 337# CONFIG_NETWORK_SECMARK is not set
367# CONFIG_NETFILTER is not set 338# CONFIG_NETFILTER is not set
368
369#
370# DCCP Configuration (EXPERIMENTAL)
371#
372# CONFIG_IP_DCCP is not set 339# CONFIG_IP_DCCP is not set
373
374#
375# SCTP Configuration (EXPERIMENTAL)
376#
377# CONFIG_IP_SCTP is not set 340# CONFIG_IP_SCTP is not set
378
379#
380# TIPC Configuration (EXPERIMENTAL)
381#
382# CONFIG_TIPC is not set 341# CONFIG_TIPC is not set
383# CONFIG_ATM is not set 342# CONFIG_ATM is not set
384# CONFIG_BRIDGE is not set 343# CONFIG_BRIDGE is not set
@@ -391,15 +350,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
391# CONFIG_LAPB is not set 350# CONFIG_LAPB is not set
392# CONFIG_ECONET is not set 351# CONFIG_ECONET is not set
393# CONFIG_WAN_ROUTER is not set 352# CONFIG_WAN_ROUTER is not set
394
395#
396# QoS and/or fair queueing
397#
398CONFIG_NET_SCHED=y 353CONFIG_NET_SCHED=y
399CONFIG_NET_SCH_FIFO=y
400CONFIG_NET_SCH_CLK_JIFFIES=y
401# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
402# CONFIG_NET_SCH_CLK_CPU is not set
403 354
404# 355#
405# Queueing/Scheduling 356# Queueing/Scheduling
@@ -408,6 +359,7 @@ CONFIG_NET_SCH_CBQ=y
408CONFIG_NET_SCH_HTB=y 359CONFIG_NET_SCH_HTB=y
409CONFIG_NET_SCH_HFSC=y 360CONFIG_NET_SCH_HFSC=y
410CONFIG_NET_SCH_PRIO=y 361CONFIG_NET_SCH_PRIO=y
362# CONFIG_NET_SCH_RR is not set
411CONFIG_NET_SCH_RED=y 363CONFIG_NET_SCH_RED=y
412CONFIG_NET_SCH_SFQ=y 364CONFIG_NET_SCH_SFQ=y
413CONFIG_NET_SCH_TEQL=y 365CONFIG_NET_SCH_TEQL=y
@@ -415,7 +367,6 @@ CONFIG_NET_SCH_TBF=y
415CONFIG_NET_SCH_GRED=y 367CONFIG_NET_SCH_GRED=y
416CONFIG_NET_SCH_DSMARK=y 368CONFIG_NET_SCH_DSMARK=y
417CONFIG_NET_SCH_NETEM=y 369CONFIG_NET_SCH_NETEM=y
418CONFIG_NET_SCH_INGRESS=y
419 370
420# 371#
421# Classification 372# Classification
@@ -429,50 +380,55 @@ CONFIG_NET_CLS_FW=y
429# CONFIG_NET_CLS_U32 is not set 380# CONFIG_NET_CLS_U32 is not set
430# CONFIG_NET_CLS_RSVP is not set 381# CONFIG_NET_CLS_RSVP is not set
431# CONFIG_NET_CLS_RSVP6 is not set 382# CONFIG_NET_CLS_RSVP6 is not set
383# CONFIG_NET_CLS_FLOW is not set
432# CONFIG_NET_EMATCH is not set 384# CONFIG_NET_EMATCH is not set
433# CONFIG_NET_CLS_ACT is not set 385# CONFIG_NET_CLS_ACT is not set
434# CONFIG_NET_CLS_POLICE is not set
435CONFIG_NET_CLS_IND=y 386CONFIG_NET_CLS_IND=y
436CONFIG_NET_ESTIMATOR=y 387CONFIG_NET_SCH_FIFO=y
437 388
438# 389#
439# Network testing 390# Network testing
440# 391#
441# CONFIG_NET_PKTGEN is not set 392# CONFIG_NET_PKTGEN is not set
442# CONFIG_HAMRADIO is not set 393# CONFIG_HAMRADIO is not set
394# CONFIG_CAN is not set
443# CONFIG_IRDA is not set 395# CONFIG_IRDA is not set
444# CONFIG_BT is not set 396# CONFIG_BT is not set
445# CONFIG_IEEE80211 is not set 397# CONFIG_AF_RXRPC is not set
446CONFIG_FIB_RULES=y 398CONFIG_FIB_RULES=y
447 399
448# 400#
401# Wireless
402#
403# CONFIG_CFG80211 is not set
404# CONFIG_WIRELESS_EXT is not set
405# CONFIG_MAC80211 is not set
406# CONFIG_IEEE80211 is not set
407# CONFIG_RFKILL is not set
408# CONFIG_NET_9P is not set
409
410#
449# Device Drivers 411# Device Drivers
450# 412#
451 413
452# 414#
453# Generic Driver Options 415# Generic Driver Options
454# 416#
417CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
455CONFIG_STANDALONE=y 418CONFIG_STANDALONE=y
456CONFIG_PREVENT_FIRMWARE_BUILD=y 419CONFIG_PREVENT_FIRMWARE_BUILD=y
457CONFIG_FW_LOADER=y 420CONFIG_FW_LOADER=y
458# CONFIG_DEBUG_DRIVER is not set 421# CONFIG_DEBUG_DRIVER is not set
459# CONFIG_DEBUG_DEVRES is not set 422# CONFIG_DEBUG_DEVRES is not set
460# CONFIG_SYS_HYPERVISOR is not set 423# CONFIG_SYS_HYPERVISOR is not set
461
462#
463# Connector - unified userspace <-> kernelspace linker
464#
465# CONFIG_CONNECTOR is not set 424# CONFIG_CONNECTOR is not set
466
467#
468# Memory Technology Devices (MTD)
469#
470CONFIG_MTD=y 425CONFIG_MTD=y
471# CONFIG_MTD_DEBUG is not set 426# CONFIG_MTD_DEBUG is not set
472CONFIG_MTD_CONCAT=y 427CONFIG_MTD_CONCAT=y
473CONFIG_MTD_PARTITIONS=y 428CONFIG_MTD_PARTITIONS=y
474# CONFIG_MTD_REDBOOT_PARTS is not set 429# CONFIG_MTD_REDBOOT_PARTS is not set
475# CONFIG_MTD_CMDLINE_PARTS is not set 430# CONFIG_MTD_CMDLINE_PARTS is not set
431# CONFIG_MTD_AR7_PARTS is not set
476 432
477# 433#
478# User Modules And Translation Layers 434# User Modules And Translation Layers
@@ -485,6 +441,7 @@ CONFIG_MTD_BLOCK=y
485# CONFIG_INFTL is not set 441# CONFIG_INFTL is not set
486# CONFIG_RFD_FTL is not set 442# CONFIG_RFD_FTL is not set
487# CONFIG_SSFDC is not set 443# CONFIG_SSFDC is not set
444# CONFIG_MTD_OOPS is not set
488 445
489# 446#
490# RAM/ROM/Flash chip drivers 447# RAM/ROM/Flash chip drivers
@@ -510,7 +467,6 @@ CONFIG_MTD_CFI_UTIL=y
510# CONFIG_MTD_RAM is not set 467# CONFIG_MTD_RAM is not set
511# CONFIG_MTD_ROM is not set 468# CONFIG_MTD_ROM is not set
512# CONFIG_MTD_ABSENT is not set 469# CONFIG_MTD_ABSENT is not set
513# CONFIG_MTD_OBSOLETE_CHIPS is not set
514 470
515# 471#
516# Mapping drivers for chip access 472# Mapping drivers for chip access
@@ -533,44 +489,25 @@ CONFIG_MTD_CFI_UTIL=y
533# CONFIG_MTD_DOC2000 is not set 489# CONFIG_MTD_DOC2000 is not set
534# CONFIG_MTD_DOC2001 is not set 490# CONFIG_MTD_DOC2001 is not set
535# CONFIG_MTD_DOC2001PLUS is not set 491# CONFIG_MTD_DOC2001PLUS is not set
536
537#
538# NAND Flash Device Drivers
539#
540# CONFIG_MTD_NAND is not set 492# CONFIG_MTD_NAND is not set
541
542#
543# OneNAND Flash Device Drivers
544#
545# CONFIG_MTD_ONENAND is not set 493# CONFIG_MTD_ONENAND is not set
546 494
547# 495#
548# Parallel port support 496# UBI - Unsorted block images
549# 497#
498# CONFIG_MTD_UBI is not set
550# CONFIG_PARPORT is not set 499# CONFIG_PARPORT is not set
551 500CONFIG_BLK_DEV=y
552#
553# Plug and Play support
554#
555# CONFIG_PNPACPI is not set
556
557#
558# Block devices
559#
560# CONFIG_BLK_DEV_COW_COMMON is not set 501# CONFIG_BLK_DEV_COW_COMMON is not set
561# CONFIG_BLK_DEV_LOOP is not set 502# CONFIG_BLK_DEV_LOOP is not set
562# CONFIG_BLK_DEV_NBD is not set 503# CONFIG_BLK_DEV_NBD is not set
563# CONFIG_BLK_DEV_RAM is not set 504# CONFIG_BLK_DEV_RAM is not set
564# CONFIG_CDROM_PKTCDVD is not set 505# CONFIG_CDROM_PKTCDVD is not set
565# CONFIG_ATA_OVER_ETH is not set 506# CONFIG_ATA_OVER_ETH is not set
566 507CONFIG_MISC_DEVICES=y
567# 508# CONFIG_EEPROM_93CX6 is not set
568# Misc devices 509# CONFIG_ENCLOSURE_SERVICES is not set
569# 510CONFIG_HAVE_IDE=y
570
571#
572# ATA/ATAPI/MFM/RLL support
573#
574# CONFIG_IDE is not set 511# CONFIG_IDE is not set
575 512
576# 513#
@@ -578,6 +515,7 @@ CONFIG_MTD_CFI_UTIL=y
578# 515#
579# CONFIG_RAID_ATTRS is not set 516# CONFIG_RAID_ATTRS is not set
580CONFIG_SCSI=y 517CONFIG_SCSI=y
518CONFIG_SCSI_DMA=y
581# CONFIG_SCSI_TGT is not set 519# CONFIG_SCSI_TGT is not set
582# CONFIG_SCSI_NETLINK is not set 520# CONFIG_SCSI_NETLINK is not set
583CONFIG_SCSI_PROC_FS=y 521CONFIG_SCSI_PROC_FS=y
@@ -599,6 +537,7 @@ CONFIG_BLK_DEV_SD=y
599# CONFIG_SCSI_CONSTANTS is not set 537# CONFIG_SCSI_CONSTANTS is not set
600# CONFIG_SCSI_LOGGING is not set 538# CONFIG_SCSI_LOGGING is not set
601# CONFIG_SCSI_SCAN_ASYNC is not set 539# CONFIG_SCSI_SCAN_ASYNC is not set
540CONFIG_SCSI_WAIT_SCAN=m
602 541
603# 542#
604# SCSI Transports 543# SCSI Transports
@@ -606,94 +545,72 @@ CONFIG_BLK_DEV_SD=y
606# CONFIG_SCSI_SPI_ATTRS is not set 545# CONFIG_SCSI_SPI_ATTRS is not set
607# CONFIG_SCSI_FC_ATTRS is not set 546# CONFIG_SCSI_FC_ATTRS is not set
608# CONFIG_SCSI_ISCSI_ATTRS is not set 547# CONFIG_SCSI_ISCSI_ATTRS is not set
609# CONFIG_SCSI_SAS_ATTRS is not set
610# CONFIG_SCSI_SAS_LIBSAS is not set 548# CONFIG_SCSI_SAS_LIBSAS is not set
611 549# CONFIG_SCSI_SRP_ATTRS is not set
612# 550CONFIG_SCSI_LOWLEVEL=y
613# SCSI low-level drivers
614#
615# CONFIG_ISCSI_TCP is not set 551# CONFIG_ISCSI_TCP is not set
616# CONFIG_SCSI_DEBUG is not set 552# CONFIG_SCSI_DEBUG is not set
617
618#
619# Serial ATA (prod) and Parallel ATA (experimental) drivers
620#
621CONFIG_ATA=y 553CONFIG_ATA=y
622# CONFIG_ATA_NONSTANDARD is not set 554# CONFIG_ATA_NONSTANDARD is not set
555CONFIG_SATA_PMP=y
556CONFIG_ATA_SFF=y
557# CONFIG_SATA_MV is not set
623CONFIG_PATA_PLATFORM=y 558CONFIG_PATA_PLATFORM=y
624
625#
626# Multi-device support (RAID and LVM)
627#
628# CONFIG_MD is not set 559# CONFIG_MD is not set
629
630#
631# Fusion MPT device support
632#
633# CONFIG_FUSION is not set
634
635#
636# IEEE 1394 (FireWire) support
637#
638
639#
640# I2O device support
641#
642
643#
644# Network device support
645#
646CONFIG_NETDEVICES=y 560CONFIG_NETDEVICES=y
561# CONFIG_NETDEVICES_MULTIQUEUE is not set
647# CONFIG_DUMMY is not set 562# CONFIG_DUMMY is not set
648# CONFIG_BONDING is not set 563# CONFIG_BONDING is not set
564# CONFIG_MACVLAN is not set
649# CONFIG_EQUALIZER is not set 565# CONFIG_EQUALIZER is not set
650# CONFIG_TUN is not set 566# CONFIG_TUN is not set
651 567# CONFIG_VETH is not set
652# 568CONFIG_PHYLIB=y
653# PHY device support 569
654# 570#
655 571# MII PHY device drivers
656# 572#
657# Ethernet (10 or 100Mbit) 573# CONFIG_MARVELL_PHY is not set
658# 574# CONFIG_DAVICOM_PHY is not set
659# CONFIG_NET_ETHERNET is not set 575# CONFIG_QSEMI_PHY is not set
660 576# CONFIG_LXT_PHY is not set
661# 577# CONFIG_CICADA_PHY is not set
662# Ethernet (1000 Mbit) 578# CONFIG_VITESSE_PHY is not set
663# 579# CONFIG_SMSC_PHY is not set
664 580# CONFIG_BROADCOM_PHY is not set
665# 581# CONFIG_ICPLUS_PHY is not set
666# Ethernet (10000 Mbit) 582# CONFIG_REALTEK_PHY is not set
667# 583# CONFIG_FIXED_PHY is not set
668 584CONFIG_MDIO_BITBANG=y
669# 585CONFIG_NET_ETHERNET=y
670# Token Ring devices 586CONFIG_MII=y
671# 587# CONFIG_AX88796 is not set
672 588# CONFIG_STNIC is not set
673# 589CONFIG_SH_ETH=y
674# Wireless LAN (non-hamradio) 590# CONFIG_SMC91X is not set
675# 591# CONFIG_SMC911X is not set
676# CONFIG_NET_RADIO is not set 592# CONFIG_IBM_NEW_EMAC_ZMII is not set
677 593# CONFIG_IBM_NEW_EMAC_RGMII is not set
678# 594# CONFIG_IBM_NEW_EMAC_TAH is not set
679# Wan interfaces 595# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
680# 596# CONFIG_B44 is not set
597CONFIG_NETDEV_1000=y
598# CONFIG_E1000E_ENABLED is not set
599CONFIG_NETDEV_10000=y
600
601#
602# Wireless LAN
603#
604# CONFIG_WLAN_PRE80211 is not set
605# CONFIG_WLAN_80211 is not set
606# CONFIG_IWLWIFI_LEDS is not set
681# CONFIG_WAN is not set 607# CONFIG_WAN is not set
682# CONFIG_PPP is not set 608# CONFIG_PPP is not set
683# CONFIG_SLIP is not set 609# CONFIG_SLIP is not set
684# CONFIG_SHAPER is not set
685# CONFIG_NETCONSOLE is not set 610# CONFIG_NETCONSOLE is not set
686# CONFIG_NETPOLL is not set 611# CONFIG_NETPOLL is not set
687# CONFIG_NET_POLL_CONTROLLER is not set 612# CONFIG_NET_POLL_CONTROLLER is not set
688
689#
690# ISDN subsystem
691#
692# CONFIG_ISDN is not set 613# CONFIG_ISDN is not set
693
694#
695# Telephony Support
696#
697# CONFIG_PHONE is not set 614# CONFIG_PHONE is not set
698 615
699# 616#
@@ -711,6 +628,7 @@ CONFIG_NETDEVICES=y
711# Character devices 628# Character devices
712# 629#
713# CONFIG_VT is not set 630# CONFIG_VT is not set
631CONFIG_DEVKMEM=y
714# CONFIG_SERIAL_NONSTANDARD is not set 632# CONFIG_SERIAL_NONSTANDARD is not set
715 633
716# 634#
@@ -728,99 +646,78 @@ CONFIG_SERIAL_CORE=y
728CONFIG_SERIAL_CORE_CONSOLE=y 646CONFIG_SERIAL_CORE_CONSOLE=y
729CONFIG_UNIX98_PTYS=y 647CONFIG_UNIX98_PTYS=y
730# CONFIG_LEGACY_PTYS is not set 648# CONFIG_LEGACY_PTYS is not set
731
732#
733# IPMI
734#
735# CONFIG_IPMI_HANDLER is not set 649# CONFIG_IPMI_HANDLER is not set
736
737#
738# Watchdog Cards
739#
740# CONFIG_WATCHDOG is not set
741CONFIG_HW_RANDOM=m 650CONFIG_HW_RANDOM=m
742# CONFIG_GEN_RTC is not set
743# CONFIG_DTLK is not set
744# CONFIG_R3964 is not set 651# CONFIG_R3964 is not set
745# CONFIG_RAW_DRIVER is not set 652# CONFIG_RAW_DRIVER is not set
746
747#
748# TPM devices
749#
750# CONFIG_TCG_TPM is not set 653# CONFIG_TCG_TPM is not set
751
752#
753# I2C support
754#
755# CONFIG_I2C is not set 654# CONFIG_I2C is not set
756
757#
758# SPI support
759#
760# CONFIG_SPI is not set 655# CONFIG_SPI is not set
761# CONFIG_SPI_MASTER is not set
762
763#
764# Dallas's 1-wire bus
765#
766# CONFIG_W1 is not set 656# CONFIG_W1 is not set
657# CONFIG_POWER_SUPPLY is not set
658# CONFIG_HWMON is not set
659# CONFIG_THERMAL is not set
660# CONFIG_WATCHDOG is not set
767 661
768# 662#
769# Hardware Monitoring support 663# Sonics Silicon Backplane
770# 664#
771# CONFIG_HWMON is not set 665CONFIG_SSB_POSSIBLE=y
772# CONFIG_HWMON_VID is not set 666# CONFIG_SSB is not set
773 667
774# 668#
775# Multifunction device drivers 669# Multifunction device drivers
776# 670#
777# CONFIG_MFD_SM501 is not set 671# CONFIG_MFD_SM501 is not set
672# CONFIG_HTC_PASIC3 is not set
778 673
779# 674#
780# Multimedia devices 675# Multimedia devices
781# 676#
677
678#
679# Multimedia core support
680#
782# CONFIG_VIDEO_DEV is not set 681# CONFIG_VIDEO_DEV is not set
682# CONFIG_DVB_CORE is not set
683# CONFIG_VIDEO_MEDIA is not set
783 684
784# 685#
785# Digital Video Broadcasting Devices 686# Multimedia drivers
786# 687#
787# CONFIG_DVB is not set 688# CONFIG_DAB is not set
788 689
789# 690#
790# Graphics support 691# Graphics support
791# 692#
792# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 693# CONFIG_VGASTATE is not set
694# CONFIG_VIDEO_OUTPUT_CONTROL is not set
793# CONFIG_FB is not set 695# CONFIG_FB is not set
696# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
794 697
795# 698#
796# Sound 699# Display device support
797# 700#
798# CONFIG_SOUND is not set 701# CONFIG_DISPLAY_SUPPORT is not set
799 702
800# 703#
801# USB support 704# Sound
802# 705#
803# CONFIG_USB_ARCH_HAS_HCD is not set 706# CONFIG_SOUND is not set
707CONFIG_USB_SUPPORT=y
708CONFIG_USB_ARCH_HAS_HCD=y
804# CONFIG_USB_ARCH_HAS_OHCI is not set 709# CONFIG_USB_ARCH_HAS_OHCI is not set
805# CONFIG_USB_ARCH_HAS_EHCI is not set 710# CONFIG_USB_ARCH_HAS_EHCI is not set
711# CONFIG_USB is not set
712# CONFIG_USB_OTG_WHITELIST is not set
713# CONFIG_USB_OTG_BLACKLIST_HUB is not set
806 714
807# 715#
808# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 716# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
809# 717#
810
811#
812# USB Gadget Support
813#
814# CONFIG_USB_GADGET is not set 718# CONFIG_USB_GADGET is not set
815
816#
817# MMC/SD Card support
818#
819# CONFIG_MMC is not set 719# CONFIG_MMC is not set
820 720# CONFIG_MEMSTICK is not set
821#
822# LED devices
823#
824CONFIG_NEW_LEDS=y 721CONFIG_NEW_LEDS=y
825CONFIG_LEDS_CLASS=y 722CONFIG_LEDS_CLASS=y
826 723
@@ -834,40 +731,10 @@ CONFIG_LEDS_CLASS=y
834CONFIG_LEDS_TRIGGERS=y 731CONFIG_LEDS_TRIGGERS=y
835# CONFIG_LEDS_TRIGGER_TIMER is not set 732# CONFIG_LEDS_TRIGGER_TIMER is not set
836# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set 733# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
837 734# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
838# 735# CONFIG_ACCESSIBILITY is not set
839# InfiniBand support
840#
841
842#
843# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
844#
845
846#
847# Real Time Clock
848#
849# CONFIG_RTC_CLASS is not set 736# CONFIG_RTC_CLASS is not set
850 737# CONFIG_UIO is not set
851#
852# DMA Engine support
853#
854# CONFIG_DMA_ENGINE is not set
855
856#
857# DMA Clients
858#
859
860#
861# DMA Devices
862#
863
864#
865# Auxiliary Display support
866#
867
868#
869# Virtualization
870#
871 738
872# 739#
873# File systems 740# File systems
@@ -877,20 +744,21 @@ CONFIG_EXT2_FS_XATTR=y
877CONFIG_EXT2_FS_POSIX_ACL=y 744CONFIG_EXT2_FS_POSIX_ACL=y
878CONFIG_EXT2_FS_SECURITY=y 745CONFIG_EXT2_FS_SECURITY=y
879# CONFIG_EXT2_FS_XIP is not set 746# CONFIG_EXT2_FS_XIP is not set
880# CONFIG_EXT3_FS is not set 747CONFIG_EXT3_FS=y
748CONFIG_EXT3_FS_XATTR=y
749# CONFIG_EXT3_FS_POSIX_ACL is not set
750# CONFIG_EXT3_FS_SECURITY is not set
881# CONFIG_EXT4DEV_FS is not set 751# CONFIG_EXT4DEV_FS is not set
752CONFIG_JBD=y
882CONFIG_FS_MBCACHE=y 753CONFIG_FS_MBCACHE=y
883# CONFIG_REISERFS_FS is not set 754# CONFIG_REISERFS_FS is not set
884# CONFIG_JFS_FS is not set 755# CONFIG_JFS_FS is not set
885CONFIG_FS_POSIX_ACL=y 756CONFIG_FS_POSIX_ACL=y
886# CONFIG_XFS_FS is not set 757# CONFIG_XFS_FS is not set
887# CONFIG_GFS2_FS is not set
888# CONFIG_OCFS2_FS is not set 758# CONFIG_OCFS2_FS is not set
889# CONFIG_MINIX_FS is not set 759# CONFIG_DNOTIFY is not set
890# CONFIG_ROMFS_FS is not set
891# CONFIG_INOTIFY is not set 760# CONFIG_INOTIFY is not set
892# CONFIG_QUOTA is not set 761# CONFIG_QUOTA is not set
893# CONFIG_DNOTIFY is not set
894# CONFIG_AUTOFS_FS is not set 762# CONFIG_AUTOFS_FS is not set
895# CONFIG_AUTOFS4_FS is not set 763# CONFIG_AUTOFS4_FS is not set
896# CONFIG_FUSE_FS is not set 764# CONFIG_FUSE_FS is not set
@@ -919,7 +787,6 @@ CONFIG_TMPFS=y
919# CONFIG_TMPFS_POSIX_ACL is not set 787# CONFIG_TMPFS_POSIX_ACL is not set
920# CONFIG_HUGETLBFS is not set 788# CONFIG_HUGETLBFS is not set
921# CONFIG_HUGETLB_PAGE is not set 789# CONFIG_HUGETLB_PAGE is not set
922CONFIG_RAMFS=y
923# CONFIG_CONFIGFS_FS is not set 790# CONFIG_CONFIGFS_FS is not set
924 791
925# 792#
@@ -935,68 +802,67 @@ CONFIG_RAMFS=y
935CONFIG_JFFS2_FS=y 802CONFIG_JFFS2_FS=y
936CONFIG_JFFS2_FS_DEBUG=0 803CONFIG_JFFS2_FS_DEBUG=0
937CONFIG_JFFS2_FS_WRITEBUFFER=y 804CONFIG_JFFS2_FS_WRITEBUFFER=y
805# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
938# CONFIG_JFFS2_SUMMARY is not set 806# CONFIG_JFFS2_SUMMARY is not set
939# CONFIG_JFFS2_FS_XATTR is not set 807# CONFIG_JFFS2_FS_XATTR is not set
940# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 808# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
941CONFIG_JFFS2_ZLIB=y 809CONFIG_JFFS2_ZLIB=y
810# CONFIG_JFFS2_LZO is not set
942CONFIG_JFFS2_RTIME=y 811CONFIG_JFFS2_RTIME=y
943# CONFIG_JFFS2_RUBIN is not set 812# CONFIG_JFFS2_RUBIN is not set
944CONFIG_CRAMFS=y 813CONFIG_CRAMFS=y
945# CONFIG_VXFS_FS is not set 814# CONFIG_VXFS_FS is not set
815# CONFIG_MINIX_FS is not set
946# CONFIG_HPFS_FS is not set 816# CONFIG_HPFS_FS is not set
947# CONFIG_QNX4FS_FS is not set 817# CONFIG_QNX4FS_FS is not set
818# CONFIG_ROMFS_FS is not set
948# CONFIG_SYSV_FS is not set 819# CONFIG_SYSV_FS is not set
949# CONFIG_UFS_FS is not set 820# CONFIG_UFS_FS is not set
950 821CONFIG_NETWORK_FILESYSTEMS=y
951# 822CONFIG_NFS_FS=y
952# Network File Systems 823# CONFIG_NFS_V3 is not set
953# 824# CONFIG_NFS_V4 is not set
954# CONFIG_NFS_FS is not set
955# CONFIG_NFSD is not set 825# CONFIG_NFSD is not set
826CONFIG_ROOT_NFS=y
827CONFIG_LOCKD=y
828CONFIG_NFS_COMMON=y
829CONFIG_SUNRPC=y
830# CONFIG_SUNRPC_BIND34 is not set
831# CONFIG_RPCSEC_GSS_KRB5 is not set
832# CONFIG_RPCSEC_GSS_SPKM3 is not set
956# CONFIG_SMB_FS is not set 833# CONFIG_SMB_FS is not set
957# CONFIG_CIFS is not set 834# CONFIG_CIFS is not set
958# CONFIG_NCP_FS is not set 835# CONFIG_NCP_FS is not set
959# CONFIG_CODA_FS is not set 836# CONFIG_CODA_FS is not set
960# CONFIG_AFS_FS is not set 837# CONFIG_AFS_FS is not set
961# CONFIG_9P_FS is not set
962 838
963# 839#
964# Partition Types 840# Partition Types
965# 841#
966# CONFIG_PARTITION_ADVANCED is not set 842# CONFIG_PARTITION_ADVANCED is not set
967CONFIG_MSDOS_PARTITION=y 843CONFIG_MSDOS_PARTITION=y
968
969#
970# Native Language Support
971#
972# CONFIG_NLS is not set 844# CONFIG_NLS is not set
973
974#
975# Distributed Lock Manager
976#
977# CONFIG_DLM is not set 845# CONFIG_DLM is not set
978 846
979# 847#
980# Profiling support
981#
982# CONFIG_PROFILING is not set
983
984#
985# Kernel hacking 848# Kernel hacking
986# 849#
987CONFIG_TRACE_IRQFLAGS_SUPPORT=y 850CONFIG_TRACE_IRQFLAGS_SUPPORT=y
988# CONFIG_PRINTK_TIME is not set 851# CONFIG_PRINTK_TIME is not set
852CONFIG_ENABLE_WARN_DEPRECATED=y
989CONFIG_ENABLE_MUST_CHECK=y 853CONFIG_ENABLE_MUST_CHECK=y
854CONFIG_FRAME_WARN=1024
990# CONFIG_MAGIC_SYSRQ is not set 855# CONFIG_MAGIC_SYSRQ is not set
991# CONFIG_UNUSED_SYMBOLS is not set 856# CONFIG_UNUSED_SYMBOLS is not set
992# CONFIG_DEBUG_FS is not set 857# CONFIG_DEBUG_FS is not set
993# CONFIG_HEADERS_CHECK is not set 858# CONFIG_HEADERS_CHECK is not set
994CONFIG_DEBUG_KERNEL=y 859CONFIG_DEBUG_KERNEL=y
995# CONFIG_DEBUG_SHIRQ is not set 860# CONFIG_DEBUG_SHIRQ is not set
996CONFIG_LOG_BUF_SHIFT=14
997# CONFIG_DETECT_SOFTLOCKUP is not set 861# CONFIG_DETECT_SOFTLOCKUP is not set
862CONFIG_SCHED_DEBUG=y
998# CONFIG_SCHEDSTATS is not set 863# CONFIG_SCHEDSTATS is not set
999# CONFIG_TIMER_STATS is not set 864# CONFIG_TIMER_STATS is not set
865# CONFIG_DEBUG_OBJECTS is not set
1000# CONFIG_DEBUG_SLAB is not set 866# CONFIG_DEBUG_SLAB is not set
1001# CONFIG_DEBUG_RT_MUTEXES is not set 867# CONFIG_DEBUG_RT_MUTEXES is not set
1002# CONFIG_RT_MUTEX_TESTER is not set 868# CONFIG_RT_MUTEX_TESTER is not set
@@ -1004,21 +870,28 @@ CONFIG_LOG_BUF_SHIFT=14
1004# CONFIG_DEBUG_MUTEXES is not set 870# CONFIG_DEBUG_MUTEXES is not set
1005# CONFIG_DEBUG_LOCK_ALLOC is not set 871# CONFIG_DEBUG_LOCK_ALLOC is not set
1006# CONFIG_PROVE_LOCKING is not set 872# CONFIG_PROVE_LOCKING is not set
873# CONFIG_LOCK_STAT is not set
1007# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 874# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1008# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 875# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1009# CONFIG_DEBUG_KOBJECT is not set 876# CONFIG_DEBUG_KOBJECT is not set
1010CONFIG_DEBUG_INFO=y 877CONFIG_DEBUG_INFO=y
1011# CONFIG_DEBUG_VM is not set 878# CONFIG_DEBUG_VM is not set
879# CONFIG_DEBUG_WRITECOUNT is not set
1012# CONFIG_DEBUG_LIST is not set 880# CONFIG_DEBUG_LIST is not set
881# CONFIG_DEBUG_SG is not set
1013CONFIG_FRAME_POINTER=y 882CONFIG_FRAME_POINTER=y
1014# CONFIG_FORCED_INLINING is not set 883# CONFIG_BOOT_PRINTK_DELAY is not set
1015# CONFIG_RCU_TORTURE_TEST is not set 884# CONFIG_RCU_TORTURE_TEST is not set
885# CONFIG_BACKTRACE_SELF_TEST is not set
1016# CONFIG_FAULT_INJECTION is not set 886# CONFIG_FAULT_INJECTION is not set
887# CONFIG_SAMPLES is not set
1017# CONFIG_SH_STANDARD_BIOS is not set 888# CONFIG_SH_STANDARD_BIOS is not set
1018# CONFIG_EARLY_SCIF_CONSOLE is not set 889# CONFIG_EARLY_SCIF_CONSOLE is not set
890# CONFIG_DEBUG_BOOTMEM is not set
1019# CONFIG_DEBUG_STACKOVERFLOW is not set 891# CONFIG_DEBUG_STACKOVERFLOW is not set
1020# CONFIG_DEBUG_STACK_USAGE is not set 892# CONFIG_DEBUG_STACK_USAGE is not set
1021# CONFIG_4KSTACKS is not set 893# CONFIG_4KSTACKS is not set
894# CONFIG_IRQSTACKS is not set
1022# CONFIG_SH_KGDB is not set 895# CONFIG_SH_KGDB is not set
1023 896
1024# 897#
@@ -1026,62 +899,100 @@ CONFIG_FRAME_POINTER=y
1026# 899#
1027# CONFIG_KEYS is not set 900# CONFIG_KEYS is not set
1028# CONFIG_SECURITY is not set 901# CONFIG_SECURITY is not set
902# CONFIG_SECURITY_FILE_CAPABILITIES is not set
903CONFIG_CRYPTO=y
1029 904
1030# 905#
1031# Cryptographic options 906# Crypto core or helper
1032# 907#
1033CONFIG_CRYPTO=y
1034CONFIG_CRYPTO_ALGAPI=y 908CONFIG_CRYPTO_ALGAPI=y
909CONFIG_CRYPTO_AEAD=y
1035CONFIG_CRYPTO_BLKCIPHER=y 910CONFIG_CRYPTO_BLKCIPHER=y
1036CONFIG_CRYPTO_HASH=y 911CONFIG_CRYPTO_HASH=y
1037CONFIG_CRYPTO_MANAGER=y 912CONFIG_CRYPTO_MANAGER=y
913# CONFIG_CRYPTO_GF128MUL is not set
914# CONFIG_CRYPTO_NULL is not set
915# CONFIG_CRYPTO_CRYPTD is not set
916CONFIG_CRYPTO_AUTHENC=y
917# CONFIG_CRYPTO_TEST is not set
918
919#
920# Authenticated Encryption with Associated Data
921#
922# CONFIG_CRYPTO_CCM is not set
923# CONFIG_CRYPTO_GCM is not set
924# CONFIG_CRYPTO_SEQIV is not set
925
926#
927# Block modes
928#
929CONFIG_CRYPTO_CBC=y
930# CONFIG_CRYPTO_CTR is not set
931# CONFIG_CRYPTO_CTS is not set
932CONFIG_CRYPTO_ECB=m
933# CONFIG_CRYPTO_LRW is not set
934CONFIG_CRYPTO_PCBC=m
935# CONFIG_CRYPTO_XTS is not set
936
937#
938# Hash modes
939#
1038CONFIG_CRYPTO_HMAC=y 940CONFIG_CRYPTO_HMAC=y
1039# CONFIG_CRYPTO_XCBC is not set 941# CONFIG_CRYPTO_XCBC is not set
1040# CONFIG_CRYPTO_NULL is not set 942
943#
944# Digest
945#
946# CONFIG_CRYPTO_CRC32C is not set
1041# CONFIG_CRYPTO_MD4 is not set 947# CONFIG_CRYPTO_MD4 is not set
1042CONFIG_CRYPTO_MD5=y 948CONFIG_CRYPTO_MD5=y
949# CONFIG_CRYPTO_MICHAEL_MIC is not set
1043CONFIG_CRYPTO_SHA1=y 950CONFIG_CRYPTO_SHA1=y
1044# CONFIG_CRYPTO_SHA256 is not set 951# CONFIG_CRYPTO_SHA256 is not set
1045# CONFIG_CRYPTO_SHA512 is not set 952# CONFIG_CRYPTO_SHA512 is not set
1046# CONFIG_CRYPTO_WP512 is not set
1047# CONFIG_CRYPTO_TGR192 is not set 953# CONFIG_CRYPTO_TGR192 is not set
1048# CONFIG_CRYPTO_GF128MUL is not set 954# CONFIG_CRYPTO_WP512 is not set
1049CONFIG_CRYPTO_ECB=m 955
1050CONFIG_CRYPTO_CBC=y 956#
1051CONFIG_CRYPTO_PCBC=m 957# Ciphers
1052# CONFIG_CRYPTO_LRW is not set 958#
1053CONFIG_CRYPTO_DES=y
1054# CONFIG_CRYPTO_FCRYPT is not set
1055# CONFIG_CRYPTO_BLOWFISH is not set
1056# CONFIG_CRYPTO_TWOFISH is not set
1057# CONFIG_CRYPTO_SERPENT is not set
1058# CONFIG_CRYPTO_AES is not set 959# CONFIG_CRYPTO_AES is not set
960# CONFIG_CRYPTO_ANUBIS is not set
961# CONFIG_CRYPTO_ARC4 is not set
962# CONFIG_CRYPTO_BLOWFISH is not set
963# CONFIG_CRYPTO_CAMELLIA is not set
1059# CONFIG_CRYPTO_CAST5 is not set 964# CONFIG_CRYPTO_CAST5 is not set
1060# CONFIG_CRYPTO_CAST6 is not set 965# CONFIG_CRYPTO_CAST6 is not set
1061# CONFIG_CRYPTO_TEA is not set 966CONFIG_CRYPTO_DES=y
1062# CONFIG_CRYPTO_ARC4 is not set 967# CONFIG_CRYPTO_FCRYPT is not set
1063# CONFIG_CRYPTO_KHAZAD is not set 968# CONFIG_CRYPTO_KHAZAD is not set
1064# CONFIG_CRYPTO_ANUBIS is not set 969# CONFIG_CRYPTO_SALSA20 is not set
1065CONFIG_CRYPTO_DEFLATE=y 970# CONFIG_CRYPTO_SEED is not set
1066# CONFIG_CRYPTO_MICHAEL_MIC is not set 971# CONFIG_CRYPTO_SERPENT is not set
1067# CONFIG_CRYPTO_CRC32C is not set 972# CONFIG_CRYPTO_TEA is not set
1068# CONFIG_CRYPTO_CAMELLIA is not set 973# CONFIG_CRYPTO_TWOFISH is not set
1069# CONFIG_CRYPTO_TEST is not set
1070 974
1071# 975#
1072# Hardware crypto devices 976# Compression
1073# 977#
978CONFIG_CRYPTO_DEFLATE=y
979# CONFIG_CRYPTO_LZO is not set
980CONFIG_CRYPTO_HW=y
1074 981
1075# 982#
1076# Library routines 983# Library routines
1077# 984#
1078CONFIG_BITREVERSE=y 985CONFIG_BITREVERSE=y
986# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1079CONFIG_CRC_CCITT=y 987CONFIG_CRC_CCITT=y
1080# CONFIG_CRC16 is not set 988# CONFIG_CRC16 is not set
989# CONFIG_CRC_ITU_T is not set
1081CONFIG_CRC32=y 990CONFIG_CRC32=y
991# CONFIG_CRC7 is not set
1082# CONFIG_LIBCRC32C is not set 992# CONFIG_LIBCRC32C is not set
1083CONFIG_ZLIB_INFLATE=y 993CONFIG_ZLIB_INFLATE=y
1084CONFIG_ZLIB_DEFLATE=y 994CONFIG_ZLIB_DEFLATE=y
1085CONFIG_PLIST=y 995CONFIG_PLIST=y
1086CONFIG_HAS_IOMEM=y 996CONFIG_HAS_IOMEM=y
1087CONFIG_HAS_IOPORT=y 997CONFIG_HAS_IOPORT=y
998CONFIG_HAS_DMA=y
diff --git a/arch/sh/configs/sh7763rdp_defconfig b/arch/sh/configs/sh7763rdp_defconfig
new file mode 100644
index 000000000000..83f3fe5db3e5
--- /dev/null
+++ b/arch/sh/configs/sh7763rdp_defconfig
@@ -0,0 +1,1052 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.26-rc4
4# Fri Jun 6 12:20:17 2008
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_BUG=y
10CONFIG_GENERIC_FIND_NEXT_BIT=y
11CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_HARDIRQS=y
13CONFIG_GENERIC_IRQ_PROBE=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_TIME=y
16CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_STACKTRACE_SUPPORT=y
18CONFIG_LOCKDEP_SUPPORT=y
19# CONFIG_ARCH_HAS_ILOG2_U32 is not set
20# CONFIG_ARCH_HAS_ILOG2_U64 is not set
21CONFIG_ARCH_NO_VIRT_TO_BUS=y
22CONFIG_ARCH_SUPPORTS_AOUT=y
23CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
24
25#
26# General setup
27#
28CONFIG_EXPERIMENTAL=y
29CONFIG_BROKEN_ON_SMP=y
30CONFIG_INIT_ENV_ARG_LIMIT=32
31CONFIG_LOCALVERSION=""
32CONFIG_LOCALVERSION_AUTO=y
33CONFIG_SWAP=y
34CONFIG_SYSVIPC=y
35CONFIG_SYSVIPC_SYSCTL=y
36# CONFIG_POSIX_MQUEUE is not set
37# CONFIG_BSD_PROCESS_ACCT is not set
38# CONFIG_TASKSTATS is not set
39# CONFIG_AUDIT is not set
40CONFIG_IKCONFIG=y
41CONFIG_IKCONFIG_PROC=y
42CONFIG_LOG_BUF_SHIFT=14
43# CONFIG_CGROUPS is not set
44CONFIG_GROUP_SCHED=y
45CONFIG_FAIR_GROUP_SCHED=y
46# CONFIG_RT_GROUP_SCHED is not set
47CONFIG_USER_SCHED=y
48# CONFIG_CGROUP_SCHED is not set
49CONFIG_SYSFS_DEPRECATED=y
50CONFIG_SYSFS_DEPRECATED_V2=y
51# CONFIG_RELAY is not set
52CONFIG_NAMESPACES=y
53CONFIG_UTS_NS=y
54CONFIG_IPC_NS=y
55# CONFIG_USER_NS is not set
56# CONFIG_PID_NS is not set
57# CONFIG_BLK_DEV_INITRD is not set
58CONFIG_CC_OPTIMIZE_FOR_SIZE=y
59CONFIG_SYSCTL=y
60CONFIG_EMBEDDED=y
61CONFIG_UID16=y
62# CONFIG_SYSCTL_SYSCALL is not set
63CONFIG_KALLSYMS=y
64# CONFIG_KALLSYMS_EXTRA_PASS is not set
65CONFIG_HOTPLUG=y
66CONFIG_PRINTK=y
67CONFIG_BUG=y
68CONFIG_ELF_CORE=y
69CONFIG_COMPAT_BRK=y
70CONFIG_BASE_FULL=y
71CONFIG_FUTEX=y
72CONFIG_ANON_INODES=y
73CONFIG_EPOLL=y
74CONFIG_SIGNALFD=y
75CONFIG_TIMERFD=y
76CONFIG_EVENTFD=y
77CONFIG_SHMEM=y
78CONFIG_VM_EVENT_COUNTERS=y
79CONFIG_SLAB=y
80# CONFIG_SLUB is not set
81# CONFIG_SLOB is not set
82CONFIG_PROFILING=y
83# CONFIG_MARKERS is not set
84CONFIG_OPROFILE=y
85CONFIG_HAVE_OPROFILE=y
86# CONFIG_HAVE_KPROBES is not set
87# CONFIG_HAVE_KRETPROBES is not set
88# CONFIG_HAVE_DMA_ATTRS is not set
89CONFIG_PROC_PAGE_MONITOR=y
90CONFIG_SLABINFO=y
91CONFIG_RT_MUTEXES=y
92# CONFIG_TINY_SHMEM is not set
93CONFIG_BASE_SMALL=0
94CONFIG_MODULES=y
95# CONFIG_MODULE_FORCE_LOAD is not set
96# CONFIG_MODULE_UNLOAD is not set
97# CONFIG_MODVERSIONS is not set
98# CONFIG_MODULE_SRCVERSION_ALL is not set
99# CONFIG_KMOD is not set
100CONFIG_BLOCK=y
101# CONFIG_LBD is not set
102# CONFIG_BLK_DEV_IO_TRACE is not set
103# CONFIG_LSF is not set
104# CONFIG_BLK_DEV_BSG is not set
105
106#
107# IO Schedulers
108#
109CONFIG_IOSCHED_NOOP=y
110CONFIG_IOSCHED_AS=y
111CONFIG_IOSCHED_DEADLINE=y
112CONFIG_IOSCHED_CFQ=y
113CONFIG_DEFAULT_AS=y
114# CONFIG_DEFAULT_DEADLINE is not set
115# CONFIG_DEFAULT_CFQ is not set
116# CONFIG_DEFAULT_NOOP is not set
117CONFIG_DEFAULT_IOSCHED="anticipatory"
118CONFIG_CLASSIC_RCU=y
119
120#
121# System type
122#
123CONFIG_CPU_SH4=y
124CONFIG_CPU_SH4A=y
125# CONFIG_CPU_SUBTYPE_SH7619 is not set
126# CONFIG_CPU_SUBTYPE_SH7203 is not set
127# CONFIG_CPU_SUBTYPE_SH7206 is not set
128# CONFIG_CPU_SUBTYPE_SH7263 is not set
129# CONFIG_CPU_SUBTYPE_MXG is not set
130# CONFIG_CPU_SUBTYPE_SH7705 is not set
131# CONFIG_CPU_SUBTYPE_SH7706 is not set
132# CONFIG_CPU_SUBTYPE_SH7707 is not set
133# CONFIG_CPU_SUBTYPE_SH7708 is not set
134# CONFIG_CPU_SUBTYPE_SH7709 is not set
135# CONFIG_CPU_SUBTYPE_SH7710 is not set
136# CONFIG_CPU_SUBTYPE_SH7712 is not set
137# CONFIG_CPU_SUBTYPE_SH7720 is not set
138# CONFIG_CPU_SUBTYPE_SH7721 is not set
139# CONFIG_CPU_SUBTYPE_SH7750 is not set
140# CONFIG_CPU_SUBTYPE_SH7091 is not set
141# CONFIG_CPU_SUBTYPE_SH7750R is not set
142# CONFIG_CPU_SUBTYPE_SH7750S is not set
143# CONFIG_CPU_SUBTYPE_SH7751 is not set
144# CONFIG_CPU_SUBTYPE_SH7751R is not set
145# CONFIG_CPU_SUBTYPE_SH7760 is not set
146# CONFIG_CPU_SUBTYPE_SH4_202 is not set
147# CONFIG_CPU_SUBTYPE_SH7723 is not set
148CONFIG_CPU_SUBTYPE_SH7763=y
149# CONFIG_CPU_SUBTYPE_SH7770 is not set
150# CONFIG_CPU_SUBTYPE_SH7780 is not set
151# CONFIG_CPU_SUBTYPE_SH7785 is not set
152# CONFIG_CPU_SUBTYPE_SHX3 is not set
153# CONFIG_CPU_SUBTYPE_SH7343 is not set
154# CONFIG_CPU_SUBTYPE_SH7722 is not set
155# CONFIG_CPU_SUBTYPE_SH7366 is not set
156# CONFIG_CPU_SUBTYPE_SH5_101 is not set
157# CONFIG_CPU_SUBTYPE_SH5_103 is not set
158
159#
160# Memory management options
161#
162CONFIG_QUICKLIST=y
163CONFIG_MMU=y
164CONFIG_PAGE_OFFSET=0x80000000
165CONFIG_MEMORY_START=0x0c000000
166CONFIG_MEMORY_SIZE=0x04000000
167CONFIG_29BIT=y
168CONFIG_VSYSCALL=y
169CONFIG_ARCH_FLATMEM_ENABLE=y
170CONFIG_ARCH_SPARSEMEM_ENABLE=y
171CONFIG_ARCH_SPARSEMEM_DEFAULT=y
172CONFIG_MAX_ACTIVE_REGIONS=1
173CONFIG_ARCH_POPULATES_NODE_MAP=y
174CONFIG_ARCH_SELECT_MEMORY_MODEL=y
175CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
176CONFIG_PAGE_SIZE_4KB=y
177# CONFIG_PAGE_SIZE_8KB is not set
178# CONFIG_PAGE_SIZE_16KB is not set
179# CONFIG_PAGE_SIZE_64KB is not set
180CONFIG_SELECT_MEMORY_MODEL=y
181# CONFIG_FLATMEM_MANUAL is not set
182# CONFIG_DISCONTIGMEM_MANUAL is not set
183CONFIG_SPARSEMEM_MANUAL=y
184CONFIG_SPARSEMEM=y
185CONFIG_HAVE_MEMORY_PRESENT=y
186CONFIG_SPARSEMEM_STATIC=y
187# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
188# CONFIG_MEMORY_HOTPLUG is not set
189CONFIG_PAGEFLAGS_EXTENDED=y
190CONFIG_SPLIT_PTLOCK_CPUS=4
191# CONFIG_RESOURCES_64BIT is not set
192CONFIG_ZONE_DMA_FLAG=0
193CONFIG_NR_QUICK=2
194
195#
196# Cache configuration
197#
198# CONFIG_SH_DIRECT_MAPPED is not set
199CONFIG_CACHE_WRITEBACK=y
200# CONFIG_CACHE_WRITETHROUGH is not set
201# CONFIG_CACHE_OFF is not set
202
203#
204# Processor features
205#
206CONFIG_CPU_LITTLE_ENDIAN=y
207# CONFIG_CPU_BIG_ENDIAN is not set
208CONFIG_SH_FPU=y
209# CONFIG_SH_STORE_QUEUES is not set
210CONFIG_CPU_HAS_INTEVT=y
211CONFIG_CPU_HAS_SR_RB=y
212CONFIG_CPU_HAS_FPU=y
213
214#
215# Board support
216#
217CONFIG_SH_SH7763RDP=y
218
219#
220# Timer and clock configuration
221#
222CONFIG_SH_TMU=y
223CONFIG_SH_TIMER_IRQ=28
224CONFIG_SH_PCLK_FREQ=66666666
225# CONFIG_TICK_ONESHOT is not set
226# CONFIG_NO_HZ is not set
227# CONFIG_HIGH_RES_TIMERS is not set
228CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
229
230#
231# CPU Frequency scaling
232#
233# CONFIG_CPU_FREQ is not set
234
235#
236# DMA support
237#
238# CONFIG_SH_DMA is not set
239
240#
241# Companion Chips
242#
243
244#
245# Additional SuperH Device Drivers
246#
247# CONFIG_HEARTBEAT is not set
248# CONFIG_PUSH_SWITCH is not set
249
250#
251# Kernel features
252#
253# CONFIG_HZ_100 is not set
254CONFIG_HZ_250=y
255# CONFIG_HZ_300 is not set
256# CONFIG_HZ_1000 is not set
257CONFIG_HZ=250
258# CONFIG_SCHED_HRTICK is not set
259# CONFIG_KEXEC is not set
260# CONFIG_CRASH_DUMP is not set
261CONFIG_PREEMPT_NONE=y
262# CONFIG_PREEMPT_VOLUNTARY is not set
263# CONFIG_PREEMPT is not set
264CONFIG_GUSA=y
265
266#
267# Boot options
268#
269CONFIG_ZERO_PAGE_OFFSET=0x00001000
270CONFIG_BOOT_LINK_OFFSET=0x00800000
271CONFIG_CMDLINE_BOOL=y
272CONFIG_CMDLINE="console=ttySC2,115200 root=/dev/sda1 rootdelay=10"
273
274#
275# Bus options
276#
277# CONFIG_ARCH_SUPPORTS_MSI is not set
278# CONFIG_PCCARD is not set
279
280#
281# Executable file formats
282#
283CONFIG_BINFMT_ELF=y
284# CONFIG_BINFMT_MISC is not set
285
286#
287# Networking
288#
289CONFIG_NET=y
290
291#
292# Networking options
293#
294CONFIG_PACKET=y
295# CONFIG_PACKET_MMAP is not set
296CONFIG_UNIX=y
297CONFIG_XFRM=y
298# CONFIG_XFRM_USER is not set
299# CONFIG_XFRM_SUB_POLICY is not set
300# CONFIG_XFRM_MIGRATE is not set
301# CONFIG_XFRM_STATISTICS is not set
302# CONFIG_NET_KEY is not set
303CONFIG_INET=y
304# CONFIG_IP_MULTICAST is not set
305# CONFIG_IP_ADVANCED_ROUTER is not set
306CONFIG_IP_FIB_HASH=y
307CONFIG_IP_PNP=y
308CONFIG_IP_PNP_DHCP=y
309CONFIG_IP_PNP_BOOTP=y
310# CONFIG_IP_PNP_RARP is not set
311# CONFIG_NET_IPIP is not set
312# CONFIG_NET_IPGRE is not set
313# CONFIG_ARPD is not set
314# CONFIG_SYN_COOKIES is not set
315# CONFIG_INET_AH is not set
316# CONFIG_INET_ESP is not set
317# CONFIG_INET_IPCOMP is not set
318# CONFIG_INET_XFRM_TUNNEL is not set
319# CONFIG_INET_TUNNEL is not set
320CONFIG_INET_XFRM_MODE_TRANSPORT=y
321CONFIG_INET_XFRM_MODE_TUNNEL=y
322CONFIG_INET_XFRM_MODE_BEET=y
323# CONFIG_INET_LRO is not set
324CONFIG_INET_DIAG=y
325CONFIG_INET_TCP_DIAG=y
326# CONFIG_TCP_CONG_ADVANCED is not set
327CONFIG_TCP_CONG_CUBIC=y
328CONFIG_DEFAULT_TCP_CONG="cubic"
329# CONFIG_TCP_MD5SIG is not set
330# CONFIG_IPV6 is not set
331# CONFIG_NETWORK_SECMARK is not set
332# CONFIG_NETFILTER is not set
333# CONFIG_IP_DCCP is not set
334# CONFIG_IP_SCTP is not set
335# CONFIG_TIPC is not set
336# CONFIG_ATM is not set
337# CONFIG_BRIDGE is not set
338# CONFIG_VLAN_8021Q is not set
339# CONFIG_DECNET is not set
340# CONFIG_LLC2 is not set
341# CONFIG_IPX is not set
342# CONFIG_ATALK is not set
343# CONFIG_X25 is not set
344# CONFIG_LAPB is not set
345# CONFIG_ECONET is not set
346# CONFIG_WAN_ROUTER is not set
347# CONFIG_NET_SCHED is not set
348
349#
350# Network testing
351#
352# CONFIG_NET_PKTGEN is not set
353# CONFIG_HAMRADIO is not set
354# CONFIG_CAN is not set
355# CONFIG_IRDA is not set
356# CONFIG_BT is not set
357# CONFIG_AF_RXRPC is not set
358
359#
360# Wireless
361#
362# CONFIG_CFG80211 is not set
363CONFIG_WIRELESS_EXT=y
364# CONFIG_MAC80211 is not set
365# CONFIG_IEEE80211 is not set
366# CONFIG_RFKILL is not set
367# CONFIG_NET_9P is not set
368
369#
370# Device Drivers
371#
372
373#
374# Generic Driver Options
375#
376CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
377CONFIG_STANDALONE=y
378CONFIG_PREVENT_FIRMWARE_BUILD=y
379CONFIG_FW_LOADER=y
380# CONFIG_SYS_HYPERVISOR is not set
381# CONFIG_CONNECTOR is not set
382CONFIG_MTD=y
383# CONFIG_MTD_DEBUG is not set
384# CONFIG_MTD_CONCAT is not set
385CONFIG_MTD_PARTITIONS=y
386# CONFIG_MTD_REDBOOT_PARTS is not set
387CONFIG_MTD_CMDLINE_PARTS=y
388# CONFIG_MTD_AR7_PARTS is not set
389
390#
391# User Modules And Translation Layers
392#
393# CONFIG_MTD_CHAR is not set
394CONFIG_MTD_BLKDEVS=y
395# CONFIG_MTD_BLOCK is not set
396# CONFIG_MTD_BLOCK_RO is not set
397# CONFIG_FTL is not set
398# CONFIG_NFTL is not set
399# CONFIG_INFTL is not set
400# CONFIG_RFD_FTL is not set
401# CONFIG_SSFDC is not set
402# CONFIG_MTD_OOPS is not set
403
404#
405# RAM/ROM/Flash chip drivers
406#
407CONFIG_MTD_CFI=y
408CONFIG_MTD_JEDECPROBE=y
409CONFIG_MTD_GEN_PROBE=y
410CONFIG_MTD_CFI_ADV_OPTIONS=y
411CONFIG_MTD_CFI_NOSWAP=y
412# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
413# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
414CONFIG_MTD_CFI_GEOMETRY=y
415CONFIG_MTD_MAP_BANK_WIDTH_1=y
416CONFIG_MTD_MAP_BANK_WIDTH_2=y
417# CONFIG_MTD_MAP_BANK_WIDTH_4 is not set
418# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
419# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
420# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
421CONFIG_MTD_CFI_I1=y
422CONFIG_MTD_CFI_I2=y
423# CONFIG_MTD_CFI_I4 is not set
424# CONFIG_MTD_CFI_I8 is not set
425# CONFIG_MTD_OTP is not set
426CONFIG_MTD_CFI_INTELEXT=y
427CONFIG_MTD_CFI_AMDSTD=y
428CONFIG_MTD_CFI_STAA=y
429CONFIG_MTD_CFI_UTIL=y
430# CONFIG_MTD_RAM is not set
431# CONFIG_MTD_ROM is not set
432# CONFIG_MTD_ABSENT is not set
433
434#
435# Mapping drivers for chip access
436#
437CONFIG_MTD_COMPLEX_MAPPINGS=y
438CONFIG_MTD_PHYSMAP=y
439CONFIG_MTD_PHYSMAP_START=0x8000000
440CONFIG_MTD_PHYSMAP_LEN=0
441CONFIG_MTD_PHYSMAP_BANKWIDTH=2
442# CONFIG_MTD_PLATRAM is not set
443
444#
445# Self-contained MTD device drivers
446#
447# CONFIG_MTD_SLRAM is not set
448# CONFIG_MTD_PHRAM is not set
449# CONFIG_MTD_MTDRAM is not set
450# CONFIG_MTD_BLOCK2MTD is not set
451
452#
453# Disk-On-Chip Device Drivers
454#
455# CONFIG_MTD_DOC2000 is not set
456# CONFIG_MTD_DOC2001 is not set
457# CONFIG_MTD_DOC2001PLUS is not set
458# CONFIG_MTD_NAND is not set
459# CONFIG_MTD_ONENAND is not set
460
461#
462# UBI - Unsorted block images
463#
464# CONFIG_MTD_UBI is not set
465# CONFIG_PARPORT is not set
466CONFIG_BLK_DEV=y
467# CONFIG_BLK_DEV_COW_COMMON is not set
468# CONFIG_BLK_DEV_LOOP is not set
469# CONFIG_BLK_DEV_NBD is not set
470# CONFIG_BLK_DEV_UB is not set
471# CONFIG_BLK_DEV_RAM is not set
472# CONFIG_CDROM_PKTCDVD is not set
473# CONFIG_ATA_OVER_ETH is not set
474# CONFIG_MISC_DEVICES is not set
475CONFIG_HAVE_IDE=y
476# CONFIG_IDE is not set
477
478#
479# SCSI device support
480#
481# CONFIG_RAID_ATTRS is not set
482CONFIG_SCSI=y
483CONFIG_SCSI_DMA=y
484# CONFIG_SCSI_TGT is not set
485# CONFIG_SCSI_NETLINK is not set
486CONFIG_SCSI_PROC_FS=y
487
488#
489# SCSI support type (disk, tape, CD-ROM)
490#
491CONFIG_BLK_DEV_SD=y
492# CONFIG_CHR_DEV_ST is not set
493# CONFIG_CHR_DEV_OSST is not set
494# CONFIG_BLK_DEV_SR is not set
495# CONFIG_CHR_DEV_SG is not set
496# CONFIG_CHR_DEV_SCH is not set
497
498#
499# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
500#
501# CONFIG_SCSI_MULTI_LUN is not set
502# CONFIG_SCSI_CONSTANTS is not set
503# CONFIG_SCSI_LOGGING is not set
504# CONFIG_SCSI_SCAN_ASYNC is not set
505CONFIG_SCSI_WAIT_SCAN=m
506
507#
508# SCSI Transports
509#
510# CONFIG_SCSI_SPI_ATTRS is not set
511# CONFIG_SCSI_FC_ATTRS is not set
512# CONFIG_SCSI_ISCSI_ATTRS is not set
513# CONFIG_SCSI_SAS_LIBSAS is not set
514# CONFIG_SCSI_SRP_ATTRS is not set
515CONFIG_SCSI_LOWLEVEL=y
516# CONFIG_ISCSI_TCP is not set
517# CONFIG_SCSI_DEBUG is not set
518# CONFIG_ATA is not set
519# CONFIG_MD is not set
520CONFIG_NETDEVICES=y
521# CONFIG_NETDEVICES_MULTIQUEUE is not set
522# CONFIG_DUMMY is not set
523# CONFIG_BONDING is not set
524# CONFIG_MACVLAN is not set
525# CONFIG_EQUALIZER is not set
526# CONFIG_TUN is not set
527# CONFIG_VETH is not set
528CONFIG_PHYLIB=y
529
530#
531# MII PHY device drivers
532#
533# CONFIG_MARVELL_PHY is not set
534# CONFIG_DAVICOM_PHY is not set
535# CONFIG_QSEMI_PHY is not set
536# CONFIG_LXT_PHY is not set
537# CONFIG_CICADA_PHY is not set
538# CONFIG_VITESSE_PHY is not set
539# CONFIG_SMSC_PHY is not set
540# CONFIG_BROADCOM_PHY is not set
541# CONFIG_ICPLUS_PHY is not set
542# CONFIG_REALTEK_PHY is not set
543# CONFIG_FIXED_PHY is not set
544CONFIG_MDIO_BITBANG=y
545CONFIG_NET_ETHERNET=y
546CONFIG_MII=y
547# CONFIG_AX88796 is not set
548# CONFIG_STNIC is not set
549# CONFIG_SMC91X is not set
550# CONFIG_IBM_NEW_EMAC_ZMII is not set
551# CONFIG_IBM_NEW_EMAC_RGMII is not set
552# CONFIG_IBM_NEW_EMAC_TAH is not set
553# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
554# CONFIG_B44 is not set
555# CONFIG_NETDEV_1000 is not set
556# CONFIG_NETDEV_10000 is not set
557
558#
559# Wireless LAN
560#
561# CONFIG_WLAN_PRE80211 is not set
562# CONFIG_WLAN_80211 is not set
563# CONFIG_IWLWIFI_LEDS is not set
564
565#
566# USB Network Adapters
567#
568# CONFIG_USB_CATC is not set
569# CONFIG_USB_KAWETH is not set
570# CONFIG_USB_PEGASUS is not set
571# CONFIG_USB_RTL8150 is not set
572# CONFIG_USB_USBNET is not set
573# CONFIG_WAN is not set
574# CONFIG_PPP is not set
575# CONFIG_SLIP is not set
576# CONFIG_NETCONSOLE is not set
577# CONFIG_NETPOLL is not set
578# CONFIG_NET_POLL_CONTROLLER is not set
579# CONFIG_ISDN is not set
580# CONFIG_PHONE is not set
581
582#
583# Input device support
584#
585CONFIG_INPUT=y
586# CONFIG_INPUT_FF_MEMLESS is not set
587# CONFIG_INPUT_POLLDEV is not set
588
589#
590# Userland interfaces
591#
592# CONFIG_INPUT_MOUSEDEV is not set
593# CONFIG_INPUT_JOYDEV is not set
594# CONFIG_INPUT_EVDEV is not set
595# CONFIG_INPUT_EVBUG is not set
596
597#
598# Input Device Drivers
599#
600# CONFIG_INPUT_KEYBOARD is not set
601# CONFIG_INPUT_MOUSE is not set
602# CONFIG_INPUT_JOYSTICK is not set
603# CONFIG_INPUT_TABLET 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
617CONFIG_DEVKMEM=y
618# CONFIG_SERIAL_NONSTANDARD is not set
619
620#
621# Serial drivers
622#
623# CONFIG_SERIAL_8250 is not set
624
625#
626# Non-8250 serial port support
627#
628CONFIG_SERIAL_SH_SCI=y
629CONFIG_SERIAL_SH_SCI_NR_UARTS=3
630CONFIG_SERIAL_SH_SCI_CONSOLE=y
631CONFIG_SERIAL_CORE=y
632CONFIG_SERIAL_CORE_CONSOLE=y
633CONFIG_UNIX98_PTYS=y
634CONFIG_LEGACY_PTYS=y
635CONFIG_LEGACY_PTY_COUNT=256
636# CONFIG_IPMI_HANDLER is not set
637CONFIG_HW_RANDOM=y
638# CONFIG_R3964 is not set
639# CONFIG_RAW_DRIVER is not set
640# CONFIG_TCG_TPM is not set
641# CONFIG_I2C is not set
642# CONFIG_SPI is not set
643# CONFIG_W1 is not set
644# CONFIG_POWER_SUPPLY is not set
645# CONFIG_HWMON is not set
646# CONFIG_THERMAL is not set
647# CONFIG_WATCHDOG is not set
648
649#
650# Sonics Silicon Backplane
651#
652CONFIG_SSB_POSSIBLE=y
653# CONFIG_SSB is not set
654
655#
656# Multifunction device drivers
657#
658# CONFIG_MFD_SM501 is not set
659# CONFIG_HTC_PASIC3 is not set
660
661#
662# Multimedia devices
663#
664
665#
666# Multimedia core support
667#
668# CONFIG_VIDEO_DEV is not set
669# CONFIG_DVB_CORE is not set
670# CONFIG_VIDEO_MEDIA is not set
671
672#
673# Multimedia drivers
674#
675# CONFIG_DAB is not set
676
677#
678# Graphics support
679#
680# CONFIG_VGASTATE is not set
681# CONFIG_VIDEO_OUTPUT_CONTROL is not set
682# CONFIG_FB is not set
683# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
684
685#
686# Display device support
687#
688# CONFIG_DISPLAY_SUPPORT is not set
689
690#
691# Sound
692#
693# CONFIG_SOUND is not set
694# CONFIG_HID_SUPPORT is not set
695CONFIG_USB_SUPPORT=y
696CONFIG_USB_ARCH_HAS_HCD=y
697CONFIG_USB_ARCH_HAS_OHCI=y
698# CONFIG_USB_ARCH_HAS_EHCI is not set
699CONFIG_USB=y
700# CONFIG_USB_DEBUG is not set
701# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
702
703#
704# Miscellaneous USB options
705#
706# CONFIG_USB_DEVICEFS is not set
707CONFIG_USB_DEVICE_CLASS=y
708# CONFIG_USB_DYNAMIC_MINORS is not set
709# CONFIG_USB_OTG is not set
710# CONFIG_USB_OTG_WHITELIST is not set
711# CONFIG_USB_OTG_BLACKLIST_HUB is not set
712
713#
714# USB Host Controller Drivers
715#
716# CONFIG_USB_C67X00_HCD is not set
717# CONFIG_USB_ISP116X_HCD is not set
718# CONFIG_USB_ISP1760_HCD is not set
719CONFIG_USB_OHCI_HCD=y
720# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
721# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
722CONFIG_USB_OHCI_LITTLE_ENDIAN=y
723# CONFIG_USB_SL811_HCD is not set
724# CONFIG_USB_R8A66597_HCD is not set
725
726#
727# USB Device Class drivers
728#
729# CONFIG_USB_ACM is not set
730# CONFIG_USB_PRINTER is not set
731# CONFIG_USB_WDM is not set
732
733#
734# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
735#
736
737#
738# may also be needed; see USB_STORAGE Help for more information
739#
740CONFIG_USB_STORAGE=y
741# CONFIG_USB_STORAGE_DEBUG is not set
742# CONFIG_USB_STORAGE_DATAFAB is not set
743# CONFIG_USB_STORAGE_FREECOM is not set
744# CONFIG_USB_STORAGE_ISD200 is not set
745# CONFIG_USB_STORAGE_DPCM is not set
746# CONFIG_USB_STORAGE_USBAT is not set
747# CONFIG_USB_STORAGE_SDDR09 is not set
748# CONFIG_USB_STORAGE_SDDR55 is not set
749# CONFIG_USB_STORAGE_JUMPSHOT is not set
750# CONFIG_USB_STORAGE_ALAUDA is not set
751# CONFIG_USB_STORAGE_ONETOUCH is not set
752# CONFIG_USB_STORAGE_KARMA is not set
753# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
754# CONFIG_USB_LIBUSUAL is not set
755
756#
757# USB Imaging devices
758#
759# CONFIG_USB_MDC800 is not set
760# CONFIG_USB_MICROTEK is not set
761CONFIG_USB_MON=y
762
763#
764# USB port drivers
765#
766# CONFIG_USB_SERIAL is not set
767
768#
769# USB Miscellaneous drivers
770#
771# CONFIG_USB_EMI62 is not set
772# CONFIG_USB_EMI26 is not set
773# CONFIG_USB_ADUTUX is not set
774# CONFIG_USB_AUERSWALD is not set
775# CONFIG_USB_RIO500 is not set
776# CONFIG_USB_LEGOTOWER is not set
777# CONFIG_USB_LCD is not set
778# CONFIG_USB_BERRY_CHARGE is not set
779# CONFIG_USB_LED is not set
780# CONFIG_USB_CYPRESS_CY7C63 is not set
781# CONFIG_USB_CYTHERM is not set
782# CONFIG_USB_PHIDGET is not set
783# CONFIG_USB_IDMOUSE is not set
784# CONFIG_USB_FTDI_ELAN is not set
785# CONFIG_USB_APPLEDISPLAY is not set
786# CONFIG_USB_LD is not set
787# CONFIG_USB_TRANCEVIBRATOR is not set
788# CONFIG_USB_IOWARRIOR is not set
789# CONFIG_USB_ISIGHTFW is not set
790# CONFIG_USB_GADGET is not set
791# CONFIG_MMC is not set
792# CONFIG_MEMSTICK is not set
793# CONFIG_NEW_LEDS is not set
794# CONFIG_ACCESSIBILITY is not set
795# CONFIG_RTC_CLASS is not set
796# CONFIG_UIO is not set
797
798#
799# File systems
800#
801CONFIG_EXT2_FS=y
802# CONFIG_EXT2_FS_XATTR is not set
803# CONFIG_EXT2_FS_XIP is not set
804CONFIG_EXT3_FS=y
805CONFIG_EXT3_FS_XATTR=y
806# CONFIG_EXT3_FS_POSIX_ACL is not set
807# CONFIG_EXT3_FS_SECURITY is not set
808# CONFIG_EXT4DEV_FS is not set
809CONFIG_JBD=y
810CONFIG_FS_MBCACHE=y
811# CONFIG_REISERFS_FS is not set
812# CONFIG_JFS_FS is not set
813CONFIG_FS_POSIX_ACL=y
814# CONFIG_XFS_FS is not set
815# CONFIG_OCFS2_FS is not set
816CONFIG_DNOTIFY=y
817CONFIG_INOTIFY=y
818CONFIG_INOTIFY_USER=y
819# CONFIG_QUOTA is not set
820CONFIG_AUTOFS_FS=y
821CONFIG_AUTOFS4_FS=y
822# CONFIG_FUSE_FS is not set
823CONFIG_GENERIC_ACL=y
824
825#
826# CD-ROM/DVD Filesystems
827#
828# CONFIG_ISO9660_FS is not set
829# CONFIG_UDF_FS is not set
830
831#
832# DOS/FAT/NT Filesystems
833#
834CONFIG_FAT_FS=y
835CONFIG_MSDOS_FS=y
836CONFIG_VFAT_FS=y
837CONFIG_FAT_DEFAULT_CODEPAGE=437
838CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
839# CONFIG_NTFS_FS is not set
840
841#
842# Pseudo filesystems
843#
844CONFIG_PROC_FS=y
845CONFIG_PROC_KCORE=y
846CONFIG_PROC_SYSCTL=y
847CONFIG_SYSFS=y
848CONFIG_TMPFS=y
849CONFIG_TMPFS_POSIX_ACL=y
850# CONFIG_HUGETLBFS is not set
851# CONFIG_HUGETLB_PAGE is not set
852# CONFIG_CONFIGFS_FS is not set
853
854#
855# Miscellaneous filesystems
856#
857# CONFIG_ADFS_FS is not set
858# CONFIG_AFFS_FS is not set
859# CONFIG_HFS_FS is not set
860# CONFIG_HFSPLUS_FS is not set
861# CONFIG_BEFS_FS is not set
862# CONFIG_BFS_FS is not set
863# CONFIG_EFS_FS is not set
864# CONFIG_JFFS2_FS is not set
865# CONFIG_CRAMFS is not set
866# CONFIG_VXFS_FS is not set
867# CONFIG_MINIX_FS is not set
868# CONFIG_HPFS_FS is not set
869# CONFIG_QNX4FS_FS is not set
870# CONFIG_ROMFS_FS is not set
871# CONFIG_SYSV_FS is not set
872# CONFIG_UFS_FS is not set
873CONFIG_NETWORK_FILESYSTEMS=y
874CONFIG_NFS_FS=y
875# CONFIG_NFS_V3 is not set
876# CONFIG_NFS_V4 is not set
877# CONFIG_NFSD is not set
878CONFIG_ROOT_NFS=y
879CONFIG_LOCKD=y
880CONFIG_NFS_COMMON=y
881CONFIG_SUNRPC=y
882# CONFIG_SUNRPC_BIND34 is not set
883# CONFIG_RPCSEC_GSS_KRB5 is not set
884# CONFIG_RPCSEC_GSS_SPKM3 is not set
885# CONFIG_SMB_FS is not set
886# CONFIG_CIFS is not set
887# CONFIG_NCP_FS is not set
888# CONFIG_CODA_FS is not set
889# CONFIG_AFS_FS is not set
890
891#
892# Partition Types
893#
894# CONFIG_PARTITION_ADVANCED is not set
895CONFIG_MSDOS_PARTITION=y
896CONFIG_NLS=y
897CONFIG_NLS_DEFAULT="iso8859-1"
898CONFIG_NLS_CODEPAGE_437=y
899CONFIG_NLS_CODEPAGE_737=y
900CONFIG_NLS_CODEPAGE_775=y
901CONFIG_NLS_CODEPAGE_850=y
902CONFIG_NLS_CODEPAGE_852=y
903CONFIG_NLS_CODEPAGE_855=y
904CONFIG_NLS_CODEPAGE_857=y
905CONFIG_NLS_CODEPAGE_860=y
906CONFIG_NLS_CODEPAGE_861=y
907CONFIG_NLS_CODEPAGE_862=y
908CONFIG_NLS_CODEPAGE_863=y
909CONFIG_NLS_CODEPAGE_864=y
910CONFIG_NLS_CODEPAGE_865=y
911CONFIG_NLS_CODEPAGE_866=y
912CONFIG_NLS_CODEPAGE_869=y
913CONFIG_NLS_CODEPAGE_936=y
914CONFIG_NLS_CODEPAGE_950=y
915CONFIG_NLS_CODEPAGE_932=y
916CONFIG_NLS_CODEPAGE_949=y
917CONFIG_NLS_CODEPAGE_874=y
918CONFIG_NLS_ISO8859_8=y
919CONFIG_NLS_CODEPAGE_1250=y
920CONFIG_NLS_CODEPAGE_1251=y
921CONFIG_NLS_ASCII=y
922CONFIG_NLS_ISO8859_1=y
923CONFIG_NLS_ISO8859_2=y
924CONFIG_NLS_ISO8859_3=y
925CONFIG_NLS_ISO8859_4=y
926CONFIG_NLS_ISO8859_5=y
927CONFIG_NLS_ISO8859_6=y
928CONFIG_NLS_ISO8859_7=y
929CONFIG_NLS_ISO8859_9=y
930CONFIG_NLS_ISO8859_13=y
931CONFIG_NLS_ISO8859_14=y
932CONFIG_NLS_ISO8859_15=y
933CONFIG_NLS_KOI8_R=y
934CONFIG_NLS_KOI8_U=y
935CONFIG_NLS_UTF8=y
936# CONFIG_DLM is not set
937
938#
939# Kernel hacking
940#
941CONFIG_TRACE_IRQFLAGS_SUPPORT=y
942# CONFIG_PRINTK_TIME is not set
943# CONFIG_ENABLE_WARN_DEPRECATED is not set
944# CONFIG_ENABLE_MUST_CHECK is not set
945CONFIG_FRAME_WARN=1024
946# CONFIG_MAGIC_SYSRQ is not set
947# CONFIG_UNUSED_SYMBOLS is not set
948# CONFIG_DEBUG_FS is not set
949# CONFIG_HEADERS_CHECK is not set
950# CONFIG_DEBUG_KERNEL is not set
951# CONFIG_DEBUG_BUGVERBOSE is not set
952# CONFIG_SAMPLES is not set
953# CONFIG_SH_STANDARD_BIOS is not set
954# CONFIG_EARLY_SCIF_CONSOLE is not set
955# CONFIG_SH_KGDB is not set
956
957#
958# Security options
959#
960# CONFIG_KEYS is not set
961# CONFIG_SECURITY is not set
962# CONFIG_SECURITY_FILE_CAPABILITIES is not set
963CONFIG_CRYPTO=y
964
965#
966# Crypto core or helper
967#
968# CONFIG_CRYPTO_MANAGER is not set
969# CONFIG_CRYPTO_GF128MUL is not set
970# CONFIG_CRYPTO_NULL is not set
971# CONFIG_CRYPTO_CRYPTD is not set
972# CONFIG_CRYPTO_AUTHENC is not set
973# CONFIG_CRYPTO_TEST is not set
974
975#
976# Authenticated Encryption with Associated Data
977#
978# CONFIG_CRYPTO_CCM is not set
979# CONFIG_CRYPTO_GCM is not set
980# CONFIG_CRYPTO_SEQIV is not set
981
982#
983# Block modes
984#
985# CONFIG_CRYPTO_CBC is not set
986# CONFIG_CRYPTO_CTR is not set
987# CONFIG_CRYPTO_CTS is not set
988# CONFIG_CRYPTO_ECB is not set
989# CONFIG_CRYPTO_LRW is not set
990# CONFIG_CRYPTO_PCBC is not set
991# CONFIG_CRYPTO_XTS is not set
992
993#
994# Hash modes
995#
996# CONFIG_CRYPTO_HMAC is not set
997# CONFIG_CRYPTO_XCBC is not set
998
999#
1000# Digest
1001#
1002# CONFIG_CRYPTO_CRC32C is not set
1003# CONFIG_CRYPTO_MD4 is not set
1004# CONFIG_CRYPTO_MD5 is not set
1005# CONFIG_CRYPTO_MICHAEL_MIC is not set
1006# CONFIG_CRYPTO_SHA1 is not set
1007# CONFIG_CRYPTO_SHA256 is not set
1008# CONFIG_CRYPTO_SHA512 is not set
1009# CONFIG_CRYPTO_TGR192 is not set
1010# CONFIG_CRYPTO_WP512 is not set
1011
1012#
1013# Ciphers
1014#
1015# CONFIG_CRYPTO_AES is not set
1016# CONFIG_CRYPTO_ANUBIS is not set
1017# CONFIG_CRYPTO_ARC4 is not set
1018# CONFIG_CRYPTO_BLOWFISH is not set
1019# CONFIG_CRYPTO_CAMELLIA is not set
1020# CONFIG_CRYPTO_CAST5 is not set
1021# CONFIG_CRYPTO_CAST6 is not set
1022# CONFIG_CRYPTO_DES is not set
1023# CONFIG_CRYPTO_FCRYPT is not set
1024# CONFIG_CRYPTO_KHAZAD is not set
1025# CONFIG_CRYPTO_SALSA20 is not set
1026# CONFIG_CRYPTO_SEED is not set
1027# CONFIG_CRYPTO_SERPENT is not set
1028# CONFIG_CRYPTO_TEA is not set
1029# CONFIG_CRYPTO_TWOFISH is not set
1030
1031#
1032# Compression
1033#
1034# CONFIG_CRYPTO_DEFLATE is not set
1035# CONFIG_CRYPTO_LZO is not set
1036CONFIG_CRYPTO_HW=y
1037
1038#
1039# Library routines
1040#
1041CONFIG_BITREVERSE=y
1042# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1043# CONFIG_CRC_CCITT is not set
1044# CONFIG_CRC16 is not set
1045# CONFIG_CRC_ITU_T is not set
1046CONFIG_CRC32=y
1047# CONFIG_CRC7 is not set
1048# CONFIG_LIBCRC32C is not set
1049CONFIG_PLIST=y
1050CONFIG_HAS_IOMEM=y
1051CONFIG_HAS_IOPORT=y
1052CONFIG_HAS_DMA=y
diff --git a/arch/sh/configs/sh7785lcr_defconfig b/arch/sh/configs/sh7785lcr_defconfig
new file mode 100644
index 000000000000..ff72697365d1
--- /dev/null
+++ b/arch/sh/configs/sh7785lcr_defconfig
@@ -0,0 +1,1388 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.26-rc8
4# Tue Jul 15 21:37:59 2008
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_BUG=y
10CONFIG_GENERIC_FIND_NEXT_BIT=y
11CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_HARDIRQS=y
13CONFIG_GENERIC_IRQ_PROBE=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_TIME=y
16CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_SYS_SUPPORTS_NUMA=y
18CONFIG_SYS_SUPPORTS_PCI=y
19CONFIG_STACKTRACE_SUPPORT=y
20CONFIG_LOCKDEP_SUPPORT=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_ARCH_NO_VIRT_TO_BUS=y
24CONFIG_ARCH_SUPPORTS_AOUT=y
25CONFIG_IO_TRAPPED=y
26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
27
28#
29# General setup
30#
31CONFIG_EXPERIMENTAL=y
32CONFIG_BROKEN_ON_SMP=y
33CONFIG_LOCK_KERNEL=y
34CONFIG_INIT_ENV_ARG_LIMIT=32
35CONFIG_LOCALVERSION=""
36CONFIG_LOCALVERSION_AUTO=y
37CONFIG_SWAP=y
38CONFIG_SYSVIPC=y
39CONFIG_SYSVIPC_SYSCTL=y
40# CONFIG_POSIX_MQUEUE is not set
41CONFIG_BSD_PROCESS_ACCT=y
42# CONFIG_BSD_PROCESS_ACCT_V3 is not set
43# CONFIG_TASKSTATS is not set
44# CONFIG_AUDIT is not set
45CONFIG_IKCONFIG=y
46CONFIG_IKCONFIG_PROC=y
47CONFIG_LOG_BUF_SHIFT=14
48# CONFIG_CGROUPS is not set
49CONFIG_GROUP_SCHED=y
50CONFIG_FAIR_GROUP_SCHED=y
51# CONFIG_RT_GROUP_SCHED is not set
52CONFIG_USER_SCHED=y
53# CONFIG_CGROUP_SCHED is not set
54CONFIG_SYSFS_DEPRECATED=y
55CONFIG_SYSFS_DEPRECATED_V2=y
56# CONFIG_RELAY is not set
57# CONFIG_NAMESPACES is not set
58# CONFIG_BLK_DEV_INITRD is not set
59CONFIG_CC_OPTIMIZE_FOR_SIZE=y
60CONFIG_SYSCTL=y
61CONFIG_EMBEDDED=y
62CONFIG_UID16=y
63CONFIG_SYSCTL_SYSCALL=y
64CONFIG_SYSCTL_SYSCALL_CHECK=y
65CONFIG_KALLSYMS=y
66# CONFIG_KALLSYMS_ALL is not set
67# CONFIG_KALLSYMS_EXTRA_PASS is not set
68CONFIG_HOTPLUG=y
69CONFIG_PRINTK=y
70CONFIG_BUG=y
71CONFIG_ELF_CORE=y
72CONFIG_COMPAT_BRK=y
73CONFIG_BASE_FULL=y
74CONFIG_FUTEX=y
75CONFIG_ANON_INODES=y
76CONFIG_EPOLL=y
77CONFIG_SIGNALFD=y
78CONFIG_TIMERFD=y
79CONFIG_EVENTFD=y
80CONFIG_SHMEM=y
81CONFIG_VM_EVENT_COUNTERS=y
82CONFIG_SLAB=y
83# CONFIG_SLUB is not set
84# CONFIG_SLOB is not set
85CONFIG_PROFILING=y
86# CONFIG_MARKERS is not set
87# CONFIG_OPROFILE is not set
88CONFIG_HAVE_OPROFILE=y
89# CONFIG_HAVE_KPROBES is not set
90# CONFIG_HAVE_KRETPROBES is not set
91# CONFIG_HAVE_DMA_ATTRS is not set
92CONFIG_PROC_PAGE_MONITOR=y
93CONFIG_SLABINFO=y
94CONFIG_RT_MUTEXES=y
95# CONFIG_TINY_SHMEM is not set
96CONFIG_BASE_SMALL=0
97CONFIG_MODULES=y
98# CONFIG_MODULE_FORCE_LOAD is not set
99CONFIG_MODULE_UNLOAD=y
100# CONFIG_MODULE_FORCE_UNLOAD is not set
101# CONFIG_MODVERSIONS is not set
102# CONFIG_MODULE_SRCVERSION_ALL is not set
103CONFIG_KMOD=y
104CONFIG_BLOCK=y
105# CONFIG_LBD is not set
106# CONFIG_BLK_DEV_IO_TRACE is not set
107# CONFIG_LSF is not set
108# CONFIG_BLK_DEV_BSG is not set
109
110#
111# IO Schedulers
112#
113CONFIG_IOSCHED_NOOP=y
114CONFIG_IOSCHED_AS=y
115CONFIG_IOSCHED_DEADLINE=y
116CONFIG_IOSCHED_CFQ=y
117# CONFIG_DEFAULT_AS is not set
118# CONFIG_DEFAULT_DEADLINE is not set
119CONFIG_DEFAULT_CFQ=y
120# CONFIG_DEFAULT_NOOP is not set
121CONFIG_DEFAULT_IOSCHED="cfq"
122CONFIG_CLASSIC_RCU=y
123
124#
125# System type
126#
127CONFIG_CPU_SH4=y
128CONFIG_CPU_SH4A=y
129CONFIG_CPU_SHX2=y
130# CONFIG_CPU_SUBTYPE_SH7619 is not set
131# CONFIG_CPU_SUBTYPE_SH7203 is not set
132# CONFIG_CPU_SUBTYPE_SH7206 is not set
133# CONFIG_CPU_SUBTYPE_SH7263 is not set
134# CONFIG_CPU_SUBTYPE_MXG is not set
135# CONFIG_CPU_SUBTYPE_SH7705 is not set
136# CONFIG_CPU_SUBTYPE_SH7706 is not set
137# CONFIG_CPU_SUBTYPE_SH7707 is not set
138# CONFIG_CPU_SUBTYPE_SH7708 is not set
139# CONFIG_CPU_SUBTYPE_SH7709 is not set
140# CONFIG_CPU_SUBTYPE_SH7710 is not set
141# CONFIG_CPU_SUBTYPE_SH7712 is not set
142# CONFIG_CPU_SUBTYPE_SH7720 is not set
143# CONFIG_CPU_SUBTYPE_SH7721 is not set
144# CONFIG_CPU_SUBTYPE_SH7750 is not set
145# CONFIG_CPU_SUBTYPE_SH7091 is not set
146# CONFIG_CPU_SUBTYPE_SH7750R is not set
147# CONFIG_CPU_SUBTYPE_SH7750S is not set
148# CONFIG_CPU_SUBTYPE_SH7751 is not set
149# CONFIG_CPU_SUBTYPE_SH7751R is not set
150# CONFIG_CPU_SUBTYPE_SH7760 is not set
151# CONFIG_CPU_SUBTYPE_SH4_202 is not set
152# CONFIG_CPU_SUBTYPE_SH7723 is not set
153# CONFIG_CPU_SUBTYPE_SH7763 is not set
154# CONFIG_CPU_SUBTYPE_SH7770 is not set
155# CONFIG_CPU_SUBTYPE_SH7780 is not set
156CONFIG_CPU_SUBTYPE_SH7785=y
157# CONFIG_CPU_SUBTYPE_SHX3 is not set
158# CONFIG_CPU_SUBTYPE_SH7343 is not set
159# CONFIG_CPU_SUBTYPE_SH7722 is not set
160# CONFIG_CPU_SUBTYPE_SH7366 is not set
161# CONFIG_CPU_SUBTYPE_SH5_101 is not set
162# CONFIG_CPU_SUBTYPE_SH5_103 is not set
163
164#
165# Memory management options
166#
167CONFIG_QUICKLIST=y
168CONFIG_MMU=y
169CONFIG_PAGE_OFFSET=0x80000000
170CONFIG_MEMORY_START=0x08000000
171CONFIG_MEMORY_SIZE=0x08000000
172CONFIG_29BIT=y
173# CONFIG_PMB is not set
174# CONFIG_X2TLB is not set
175CONFIG_VSYSCALL=y
176# CONFIG_NUMA is not set
177CONFIG_ARCH_FLATMEM_ENABLE=y
178CONFIG_ARCH_SPARSEMEM_ENABLE=y
179CONFIG_ARCH_SPARSEMEM_DEFAULT=y
180CONFIG_MAX_ACTIVE_REGIONS=2
181CONFIG_ARCH_POPULATES_NODE_MAP=y
182CONFIG_ARCH_SELECT_MEMORY_MODEL=y
183CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
184CONFIG_PAGE_SIZE_4KB=y
185# CONFIG_PAGE_SIZE_8KB is not set
186# CONFIG_PAGE_SIZE_16KB is not set
187# CONFIG_PAGE_SIZE_64KB is not set
188CONFIG_SELECT_MEMORY_MODEL=y
189# CONFIG_FLATMEM_MANUAL is not set
190# CONFIG_DISCONTIGMEM_MANUAL is not set
191CONFIG_SPARSEMEM_MANUAL=y
192CONFIG_SPARSEMEM=y
193CONFIG_HAVE_MEMORY_PRESENT=y
194CONFIG_SPARSEMEM_STATIC=y
195# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
196# CONFIG_MEMORY_HOTPLUG is not set
197CONFIG_PAGEFLAGS_EXTENDED=y
198CONFIG_SPLIT_PTLOCK_CPUS=4
199# CONFIG_RESOURCES_64BIT is not set
200CONFIG_ZONE_DMA_FLAG=0
201CONFIG_NR_QUICK=2
202
203#
204# Cache configuration
205#
206# CONFIG_SH_DIRECT_MAPPED is not set
207CONFIG_CACHE_WRITEBACK=y
208# CONFIG_CACHE_WRITETHROUGH is not set
209# CONFIG_CACHE_OFF is not set
210
211#
212# Processor features
213#
214CONFIG_CPU_LITTLE_ENDIAN=y
215# CONFIG_CPU_BIG_ENDIAN is not set
216CONFIG_SH_FPU=y
217CONFIG_SH_STORE_QUEUES=y
218CONFIG_CPU_HAS_INTEVT=y
219CONFIG_CPU_HAS_SR_RB=y
220CONFIG_CPU_HAS_PTEA=y
221CONFIG_CPU_HAS_FPU=y
222
223#
224# Board support
225#
226# CONFIG_SH_HIGHLANDER is not set
227CONFIG_SH_SH7785LCR=y
228CONFIG_SH_SH7785LCR_29BIT_PHYSMAPS=y
229
230#
231# Timer and clock configuration
232#
233CONFIG_SH_TMU=y
234CONFIG_SH_TIMER_IRQ=28
235CONFIG_SH_PCLK_FREQ=50000000
236CONFIG_TICK_ONESHOT=y
237# CONFIG_NO_HZ is not set
238CONFIG_HIGH_RES_TIMERS=y
239CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
240
241#
242# CPU Frequency scaling
243#
244# CONFIG_CPU_FREQ is not set
245
246#
247# DMA support
248#
249# CONFIG_SH_DMA is not set
250
251#
252# Companion Chips
253#
254
255#
256# Additional SuperH Device Drivers
257#
258CONFIG_HEARTBEAT=y
259# CONFIG_PUSH_SWITCH is not set
260
261#
262# Kernel features
263#
264# CONFIG_HZ_100 is not set
265CONFIG_HZ_250=y
266# CONFIG_HZ_300 is not set
267# CONFIG_HZ_1000 is not set
268CONFIG_HZ=250
269# CONFIG_SCHED_HRTICK is not set
270CONFIG_KEXEC=y
271# CONFIG_CRASH_DUMP is not set
272# CONFIG_PREEMPT_NONE is not set
273# CONFIG_PREEMPT_VOLUNTARY is not set
274CONFIG_PREEMPT=y
275# CONFIG_PREEMPT_RCU is not set
276CONFIG_GUSA=y
277
278#
279# Boot options
280#
281CONFIG_ZERO_PAGE_OFFSET=0x00001000
282CONFIG_BOOT_LINK_OFFSET=0x00800000
283# CONFIG_CMDLINE_BOOL is not set
284
285#
286# Bus options
287#
288CONFIG_PCI=y
289CONFIG_SH_PCIDMA_NONCOHERENT=y
290CONFIG_PCI_AUTO=y
291CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
292# CONFIG_ARCH_SUPPORTS_MSI is not set
293CONFIG_PCI_LEGACY=y
294# CONFIG_PCI_DEBUG is not set
295# CONFIG_PCCARD is not set
296# CONFIG_HOTPLUG_PCI is not set
297
298#
299# Executable file formats
300#
301CONFIG_BINFMT_ELF=y
302# CONFIG_BINFMT_MISC is not set
303
304#
305# Networking
306#
307CONFIG_NET=y
308
309#
310# Networking options
311#
312CONFIG_PACKET=y
313# CONFIG_PACKET_MMAP is not set
314CONFIG_UNIX=y
315CONFIG_XFRM=y
316# CONFIG_XFRM_USER is not set
317# CONFIG_XFRM_SUB_POLICY is not set
318# CONFIG_XFRM_MIGRATE is not set
319# CONFIG_XFRM_STATISTICS is not set
320# CONFIG_NET_KEY is not set
321CONFIG_INET=y
322# CONFIG_IP_MULTICAST is not set
323CONFIG_IP_ADVANCED_ROUTER=y
324CONFIG_ASK_IP_FIB_HASH=y
325# CONFIG_IP_FIB_TRIE is not set
326CONFIG_IP_FIB_HASH=y
327# CONFIG_IP_MULTIPLE_TABLES is not set
328# CONFIG_IP_ROUTE_MULTIPATH is not set
329# CONFIG_IP_ROUTE_VERBOSE is not set
330CONFIG_IP_PNP=y
331CONFIG_IP_PNP_DHCP=y
332# CONFIG_IP_PNP_BOOTP is not set
333# CONFIG_IP_PNP_RARP is not set
334# CONFIG_NET_IPIP is not set
335# CONFIG_NET_IPGRE is not set
336# CONFIG_ARPD is not set
337# CONFIG_SYN_COOKIES is not set
338# CONFIG_INET_AH is not set
339# CONFIG_INET_ESP is not set
340# CONFIG_INET_IPCOMP is not set
341# CONFIG_INET_XFRM_TUNNEL is not set
342# CONFIG_INET_TUNNEL is not set
343CONFIG_INET_XFRM_MODE_TRANSPORT=y
344CONFIG_INET_XFRM_MODE_TUNNEL=y
345CONFIG_INET_XFRM_MODE_BEET=y
346# CONFIG_INET_LRO is not set
347CONFIG_INET_DIAG=y
348CONFIG_INET_TCP_DIAG=y
349# CONFIG_TCP_CONG_ADVANCED is not set
350CONFIG_TCP_CONG_CUBIC=y
351CONFIG_DEFAULT_TCP_CONG="cubic"
352# CONFIG_TCP_MD5SIG is not set
353# CONFIG_IPV6 is not set
354# CONFIG_NETWORK_SECMARK is not set
355# CONFIG_NETFILTER is not set
356# CONFIG_IP_DCCP is not set
357# CONFIG_IP_SCTP is not set
358# CONFIG_TIPC is not set
359# CONFIG_ATM is not set
360# CONFIG_BRIDGE is not set
361# CONFIG_VLAN_8021Q is not set
362# CONFIG_DECNET is not set
363# CONFIG_LLC2 is not set
364# CONFIG_IPX is not set
365# CONFIG_ATALK is not set
366# CONFIG_X25 is not set
367# CONFIG_LAPB is not set
368# CONFIG_ECONET is not set
369# CONFIG_WAN_ROUTER is not set
370# CONFIG_NET_SCHED is not set
371
372#
373# Network testing
374#
375# CONFIG_NET_PKTGEN is not set
376# CONFIG_HAMRADIO is not set
377# CONFIG_CAN is not set
378# CONFIG_IRDA is not set
379# CONFIG_BT is not set
380# CONFIG_AF_RXRPC is not set
381
382#
383# Wireless
384#
385# CONFIG_CFG80211 is not set
386CONFIG_WIRELESS_EXT=y
387# CONFIG_MAC80211 is not set
388# CONFIG_IEEE80211 is not set
389# CONFIG_RFKILL is not set
390# CONFIG_NET_9P is not set
391
392#
393# Device Drivers
394#
395
396#
397# Generic Driver Options
398#
399CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
400CONFIG_STANDALONE=y
401CONFIG_PREVENT_FIRMWARE_BUILD=y
402# CONFIG_FW_LOADER is not set
403# CONFIG_DEBUG_DRIVER is not set
404# CONFIG_DEBUG_DEVRES is not set
405# CONFIG_SYS_HYPERVISOR is not set
406# CONFIG_CONNECTOR is not set
407CONFIG_MTD=y
408# CONFIG_MTD_DEBUG is not set
409CONFIG_MTD_CONCAT=y
410CONFIG_MTD_PARTITIONS=y
411# CONFIG_MTD_REDBOOT_PARTS is not set
412# CONFIG_MTD_CMDLINE_PARTS is not set
413# CONFIG_MTD_AR7_PARTS is not set
414
415#
416# User Modules And Translation Layers
417#
418CONFIG_MTD_CHAR=y
419CONFIG_MTD_BLKDEVS=y
420CONFIG_MTD_BLOCK=y
421# CONFIG_FTL is not set
422# CONFIG_NFTL is not set
423# CONFIG_INFTL is not set
424# CONFIG_RFD_FTL is not set
425# CONFIG_SSFDC is not set
426# CONFIG_MTD_OOPS is not set
427
428#
429# RAM/ROM/Flash chip drivers
430#
431CONFIG_MTD_CFI=y
432# CONFIG_MTD_JEDECPROBE is not set
433CONFIG_MTD_GEN_PROBE=y
434# CONFIG_MTD_CFI_ADV_OPTIONS is not set
435CONFIG_MTD_MAP_BANK_WIDTH_1=y
436CONFIG_MTD_MAP_BANK_WIDTH_2=y
437CONFIG_MTD_MAP_BANK_WIDTH_4=y
438# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
439# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
440# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
441CONFIG_MTD_CFI_I1=y
442CONFIG_MTD_CFI_I2=y
443# CONFIG_MTD_CFI_I4 is not set
444# CONFIG_MTD_CFI_I8 is not set
445# CONFIG_MTD_CFI_INTELEXT is not set
446CONFIG_MTD_CFI_AMDSTD=y
447# CONFIG_MTD_CFI_STAA is not set
448CONFIG_MTD_CFI_UTIL=y
449# CONFIG_MTD_RAM is not set
450# CONFIG_MTD_ROM is not set
451# CONFIG_MTD_ABSENT is not set
452
453#
454# Mapping drivers for chip access
455#
456# CONFIG_MTD_COMPLEX_MAPPINGS is not set
457CONFIG_MTD_PHYSMAP=y
458CONFIG_MTD_PHYSMAP_START=0x00000000
459CONFIG_MTD_PHYSMAP_LEN=0x0
460CONFIG_MTD_PHYSMAP_BANKWIDTH=0
461# CONFIG_MTD_INTEL_VR_NOR is not set
462# CONFIG_MTD_PLATRAM is not set
463
464#
465# Self-contained MTD device drivers
466#
467# CONFIG_MTD_PMC551 is not set
468# CONFIG_MTD_SLRAM is not set
469# CONFIG_MTD_PHRAM is not set
470# CONFIG_MTD_MTDRAM is not set
471# CONFIG_MTD_BLOCK2MTD is not set
472
473#
474# Disk-On-Chip Device Drivers
475#
476# CONFIG_MTD_DOC2000 is not set
477# CONFIG_MTD_DOC2001 is not set
478# CONFIG_MTD_DOC2001PLUS is not set
479# CONFIG_MTD_NAND is not set
480# CONFIG_MTD_ONENAND is not set
481
482#
483# UBI - Unsorted block images
484#
485# CONFIG_MTD_UBI is not set
486# CONFIG_PARPORT is not set
487CONFIG_BLK_DEV=y
488# CONFIG_BLK_CPQ_CISS_DA is not set
489# CONFIG_BLK_DEV_DAC960 is not set
490# CONFIG_BLK_DEV_UMEM is not set
491# CONFIG_BLK_DEV_COW_COMMON is not set
492# CONFIG_BLK_DEV_LOOP is not set
493# CONFIG_BLK_DEV_NBD is not set
494# CONFIG_BLK_DEV_SX8 is not set
495# CONFIG_BLK_DEV_UB is not set
496CONFIG_BLK_DEV_RAM=y
497CONFIG_BLK_DEV_RAM_COUNT=16
498CONFIG_BLK_DEV_RAM_SIZE=4096
499# CONFIG_BLK_DEV_XIP is not set
500# CONFIG_CDROM_PKTCDVD is not set
501# CONFIG_ATA_OVER_ETH is not set
502# CONFIG_MISC_DEVICES is not set
503CONFIG_HAVE_IDE=y
504# CONFIG_IDE is not set
505
506#
507# SCSI device support
508#
509# CONFIG_RAID_ATTRS is not set
510CONFIG_SCSI=y
511CONFIG_SCSI_DMA=y
512# CONFIG_SCSI_TGT is not set
513# CONFIG_SCSI_NETLINK is not set
514CONFIG_SCSI_PROC_FS=y
515
516#
517# SCSI support type (disk, tape, CD-ROM)
518#
519CONFIG_BLK_DEV_SD=y
520# CONFIG_CHR_DEV_ST is not set
521# CONFIG_CHR_DEV_OSST is not set
522# CONFIG_BLK_DEV_SR is not set
523# CONFIG_CHR_DEV_SG is not set
524# CONFIG_CHR_DEV_SCH is not set
525
526#
527# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
528#
529# CONFIG_SCSI_MULTI_LUN is not set
530# CONFIG_SCSI_CONSTANTS is not set
531# CONFIG_SCSI_LOGGING is not set
532# CONFIG_SCSI_SCAN_ASYNC is not set
533CONFIG_SCSI_WAIT_SCAN=m
534
535#
536# SCSI Transports
537#
538# CONFIG_SCSI_SPI_ATTRS is not set
539# CONFIG_SCSI_FC_ATTRS is not set
540# CONFIG_SCSI_ISCSI_ATTRS is not set
541# CONFIG_SCSI_SAS_LIBSAS is not set
542# CONFIG_SCSI_SRP_ATTRS is not set
543# CONFIG_SCSI_LOWLEVEL is not set
544CONFIG_ATA=y
545# CONFIG_ATA_NONSTANDARD is not set
546CONFIG_SATA_PMP=y
547# CONFIG_SATA_AHCI is not set
548# CONFIG_SATA_SIL24 is not set
549CONFIG_ATA_SFF=y
550# CONFIG_SATA_SVW is not set
551# CONFIG_ATA_PIIX is not set
552# CONFIG_SATA_MV is not set
553# CONFIG_SATA_NV is not set
554# CONFIG_PDC_ADMA is not set
555# CONFIG_SATA_QSTOR is not set
556# CONFIG_SATA_PROMISE is not set
557# CONFIG_SATA_SX4 is not set
558CONFIG_SATA_SIL=y
559# CONFIG_SATA_SIS is not set
560# CONFIG_SATA_ULI is not set
561# CONFIG_SATA_VIA is not set
562# CONFIG_SATA_VITESSE is not set
563# CONFIG_SATA_INIC162X is not set
564# CONFIG_PATA_ALI is not set
565# CONFIG_PATA_AMD is not set
566# CONFIG_PATA_ARTOP is not set
567# CONFIG_PATA_ATIIXP is not set
568# CONFIG_PATA_CMD640_PCI is not set
569# CONFIG_PATA_CMD64X is not set
570# CONFIG_PATA_CS5520 is not set
571# CONFIG_PATA_CS5530 is not set
572# CONFIG_PATA_CYPRESS is not set
573# CONFIG_PATA_EFAR is not set
574# CONFIG_ATA_GENERIC is not set
575# CONFIG_PATA_HPT366 is not set
576# CONFIG_PATA_HPT37X is not set
577# CONFIG_PATA_HPT3X2N is not set
578# CONFIG_PATA_HPT3X3 is not set
579# CONFIG_PATA_IT821X is not set
580# CONFIG_PATA_IT8213 is not set
581# CONFIG_PATA_JMICRON is not set
582# CONFIG_PATA_TRIFLEX is not set
583# CONFIG_PATA_MARVELL is not set
584# CONFIG_PATA_MPIIX is not set
585# CONFIG_PATA_OLDPIIX is not set
586# CONFIG_PATA_NETCELL is not set
587# CONFIG_PATA_NINJA32 is not set
588# CONFIG_PATA_NS87410 is not set
589# CONFIG_PATA_NS87415 is not set
590# CONFIG_PATA_OPTI is not set
591# CONFIG_PATA_OPTIDMA is not set
592# CONFIG_PATA_PDC_OLD is not set
593# CONFIG_PATA_RADISYS is not set
594# CONFIG_PATA_RZ1000 is not set
595# CONFIG_PATA_SC1200 is not set
596# CONFIG_PATA_SERVERWORKS is not set
597# CONFIG_PATA_PDC2027X is not set
598# CONFIG_PATA_SIL680 is not set
599# CONFIG_PATA_SIS is not set
600# CONFIG_PATA_VIA is not set
601# CONFIG_PATA_WINBOND is not set
602# CONFIG_PATA_PLATFORM is not set
603# CONFIG_PATA_SCH is not set
604# CONFIG_MD is not set
605# CONFIG_FUSION is not set
606
607#
608# IEEE 1394 (FireWire) support
609#
610
611#
612# Enable only one of the two stacks, unless you know what you are doing
613#
614# CONFIG_FIREWIRE is not set
615# CONFIG_IEEE1394 is not set
616# CONFIG_I2O is not set
617CONFIG_NETDEVICES=y
618# CONFIG_NETDEVICES_MULTIQUEUE is not set
619# CONFIG_DUMMY is not set
620# CONFIG_BONDING is not set
621# CONFIG_MACVLAN is not set
622# CONFIG_EQUALIZER is not set
623# CONFIG_TUN is not set
624# CONFIG_VETH is not set
625# CONFIG_ARCNET is not set
626# CONFIG_NET_ETHERNET is not set
627CONFIG_NETDEV_1000=y
628# CONFIG_ACENIC is not set
629# CONFIG_DL2K is not set
630# CONFIG_E1000 is not set
631# CONFIG_E1000E is not set
632# CONFIG_E1000E_ENABLED is not set
633# CONFIG_IP1000 is not set
634# CONFIG_IGB is not set
635# CONFIG_NS83820 is not set
636# CONFIG_HAMACHI is not set
637# CONFIG_YELLOWFIN is not set
638CONFIG_R8169=y
639# CONFIG_R8169_NAPI is not set
640# CONFIG_SIS190 is not set
641# CONFIG_SKGE is not set
642# CONFIG_SKY2 is not set
643# CONFIG_VIA_VELOCITY is not set
644# CONFIG_TIGON3 is not set
645# CONFIG_BNX2 is not set
646# CONFIG_QLA3XXX is not set
647# CONFIG_ATL1 is not set
648# CONFIG_NETDEV_10000 is not set
649# CONFIG_TR is not set
650
651#
652# Wireless LAN
653#
654# CONFIG_WLAN_PRE80211 is not set
655# CONFIG_WLAN_80211 is not set
656# CONFIG_IWLWIFI_LEDS is not set
657
658#
659# USB Network Adapters
660#
661# CONFIG_USB_CATC is not set
662# CONFIG_USB_KAWETH is not set
663# CONFIG_USB_PEGASUS is not set
664# CONFIG_USB_RTL8150 is not set
665# CONFIG_USB_USBNET is not set
666# CONFIG_WAN is not set
667# CONFIG_FDDI is not set
668# CONFIG_HIPPI is not set
669# CONFIG_PPP is not set
670# CONFIG_SLIP is not set
671# CONFIG_NET_FC is not set
672# CONFIG_NETCONSOLE is not set
673# CONFIG_NETPOLL is not set
674# CONFIG_NET_POLL_CONTROLLER is not set
675# CONFIG_ISDN is not set
676# CONFIG_PHONE is not set
677
678#
679# Input device support
680#
681CONFIG_INPUT=y
682# CONFIG_INPUT_FF_MEMLESS is not set
683# CONFIG_INPUT_POLLDEV is not set
684
685#
686# Userland interfaces
687#
688CONFIG_INPUT_MOUSEDEV=y
689# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
690CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
691CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
692# CONFIG_INPUT_JOYDEV is not set
693# CONFIG_INPUT_EVDEV is not set
694# CONFIG_INPUT_EVBUG is not set
695
696#
697# Input Device Drivers
698#
699CONFIG_INPUT_KEYBOARD=y
700# CONFIG_KEYBOARD_ATKBD is not set
701# CONFIG_KEYBOARD_SUNKBD is not set
702# CONFIG_KEYBOARD_LKKBD is not set
703# CONFIG_KEYBOARD_XTKBD is not set
704# CONFIG_KEYBOARD_NEWTON is not set
705# CONFIG_KEYBOARD_STOWAWAY is not set
706# CONFIG_KEYBOARD_SH_KEYSC is not set
707# CONFIG_INPUT_MOUSE is not set
708# CONFIG_INPUT_JOYSTICK is not set
709# CONFIG_INPUT_TABLET is not set
710# CONFIG_INPUT_TOUCHSCREEN is not set
711# CONFIG_INPUT_MISC is not set
712
713#
714# Hardware I/O ports
715#
716# CONFIG_SERIO is not set
717# CONFIG_GAMEPORT is not set
718
719#
720# Character devices
721#
722CONFIG_VT=y
723CONFIG_VT_CONSOLE=y
724CONFIG_HW_CONSOLE=y
725CONFIG_VT_HW_CONSOLE_BINDING=y
726CONFIG_DEVKMEM=y
727# CONFIG_SERIAL_NONSTANDARD is not set
728# CONFIG_NOZOMI is not set
729
730#
731# Serial drivers
732#
733# CONFIG_SERIAL_8250 is not set
734
735#
736# Non-8250 serial port support
737#
738CONFIG_SERIAL_SH_SCI=y
739CONFIG_SERIAL_SH_SCI_NR_UARTS=6
740CONFIG_SERIAL_SH_SCI_CONSOLE=y
741CONFIG_SERIAL_CORE=y
742CONFIG_SERIAL_CORE_CONSOLE=y
743# CONFIG_SERIAL_JSM is not set
744CONFIG_UNIX98_PTYS=y
745CONFIG_LEGACY_PTYS=y
746CONFIG_LEGACY_PTY_COUNT=256
747# CONFIG_IPMI_HANDLER is not set
748CONFIG_HW_RANDOM=y
749# CONFIG_R3964 is not set
750# CONFIG_APPLICOM is not set
751# CONFIG_RAW_DRIVER is not set
752# CONFIG_TCG_TPM is not set
753CONFIG_DEVPORT=y
754CONFIG_I2C=y
755CONFIG_I2C_BOARDINFO=y
756# CONFIG_I2C_CHARDEV is not set
757CONFIG_I2C_ALGOPCA=y
758
759#
760# I2C Hardware Bus support
761#
762# CONFIG_I2C_ALI1535 is not set
763# CONFIG_I2C_ALI1563 is not set
764# CONFIG_I2C_ALI15X3 is not set
765# CONFIG_I2C_AMD756 is not set
766# CONFIG_I2C_AMD8111 is not set
767# CONFIG_I2C_I801 is not set
768# CONFIG_I2C_I810 is not set
769# CONFIG_I2C_PIIX4 is not set
770# CONFIG_I2C_NFORCE2 is not set
771# CONFIG_I2C_OCORES is not set
772# CONFIG_I2C_PARPORT_LIGHT is not set
773# CONFIG_I2C_PROSAVAGE is not set
774# CONFIG_I2C_SAVAGE4 is not set
775# CONFIG_I2C_SIMTEC is not set
776# CONFIG_I2C_SIS5595 is not set
777# CONFIG_I2C_SIS630 is not set
778# CONFIG_I2C_SIS96X is not set
779# CONFIG_I2C_TAOS_EVM is not set
780# CONFIG_I2C_STUB is not set
781# CONFIG_I2C_TINY_USB is not set
782# CONFIG_I2C_VIA is not set
783# CONFIG_I2C_VIAPRO is not set
784# CONFIG_I2C_VOODOO3 is not set
785CONFIG_I2C_PCA_PLATFORM=y
786# CONFIG_I2C_SH_MOBILE is not set
787
788#
789# Miscellaneous I2C Chip support
790#
791# CONFIG_DS1682 is not set
792# CONFIG_SENSORS_EEPROM is not set
793# CONFIG_SENSORS_PCF8574 is not set
794# CONFIG_PCF8575 is not set
795# CONFIG_SENSORS_PCF8591 is not set
796# CONFIG_SENSORS_MAX6875 is not set
797# CONFIG_SENSORS_TSL2550 is not set
798# CONFIG_I2C_DEBUG_CORE is not set
799# CONFIG_I2C_DEBUG_ALGO is not set
800# CONFIG_I2C_DEBUG_BUS is not set
801# CONFIG_I2C_DEBUG_CHIP is not set
802# CONFIG_SPI is not set
803# CONFIG_W1 is not set
804# CONFIG_POWER_SUPPLY is not set
805# CONFIG_HWMON is not set
806# CONFIG_THERMAL is not set
807# CONFIG_THERMAL_HWMON is not set
808# CONFIG_WATCHDOG is not set
809
810#
811# Sonics Silicon Backplane
812#
813CONFIG_SSB_POSSIBLE=y
814# CONFIG_SSB is not set
815
816#
817# Multifunction device drivers
818#
819CONFIG_MFD_SM501=y
820# CONFIG_HTC_PASIC3 is not set
821
822#
823# Multimedia devices
824#
825
826#
827# Multimedia core support
828#
829# CONFIG_VIDEO_DEV is not set
830# CONFIG_DVB_CORE is not set
831# CONFIG_VIDEO_MEDIA is not set
832
833#
834# Multimedia drivers
835#
836# CONFIG_DAB is not set
837
838#
839# Graphics support
840#
841# CONFIG_DRM is not set
842# CONFIG_VGASTATE is not set
843# CONFIG_VIDEO_OUTPUT_CONTROL is not set
844CONFIG_FB=y
845# CONFIG_FIRMWARE_EDID is not set
846# CONFIG_FB_DDC is not set
847CONFIG_FB_CFB_FILLRECT=y
848CONFIG_FB_CFB_COPYAREA=y
849CONFIG_FB_CFB_IMAGEBLIT=y
850# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
851# CONFIG_FB_SYS_FILLRECT is not set
852# CONFIG_FB_SYS_COPYAREA is not set
853# CONFIG_FB_SYS_IMAGEBLIT is not set
854# CONFIG_FB_FOREIGN_ENDIAN is not set
855# CONFIG_FB_SYS_FOPS is not set
856# CONFIG_FB_SVGALIB is not set
857# CONFIG_FB_MACMODES is not set
858# CONFIG_FB_BACKLIGHT is not set
859# CONFIG_FB_MODE_HELPERS is not set
860# CONFIG_FB_TILEBLITTING is not set
861
862#
863# Frame buffer hardware drivers
864#
865# CONFIG_FB_CIRRUS is not set
866# CONFIG_FB_PM2 is not set
867# CONFIG_FB_CYBER2000 is not set
868# CONFIG_FB_ASILIANT is not set
869# CONFIG_FB_IMSTT is not set
870# CONFIG_FB_S1D13XXX is not set
871# CONFIG_FB_NVIDIA is not set
872# CONFIG_FB_RIVA is not set
873# CONFIG_FB_MATROX is not set
874# CONFIG_FB_RADEON is not set
875# CONFIG_FB_ATY128 is not set
876# CONFIG_FB_ATY is not set
877# CONFIG_FB_S3 is not set
878# CONFIG_FB_SAVAGE is not set
879# CONFIG_FB_SIS is not set
880# CONFIG_FB_NEOMAGIC is not set
881# CONFIG_FB_KYRO is not set
882# CONFIG_FB_3DFX is not set
883# CONFIG_FB_VOODOO1 is not set
884# CONFIG_FB_VT8623 is not set
885# CONFIG_FB_TRIDENT is not set
886# CONFIG_FB_ARK is not set
887# CONFIG_FB_PM3 is not set
888CONFIG_FB_SM501=y
889# CONFIG_FB_VIRTUAL is not set
890# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
891
892#
893# Display device support
894#
895# CONFIG_DISPLAY_SUPPORT is not set
896
897#
898# Console display driver support
899#
900CONFIG_DUMMY_CONSOLE=y
901CONFIG_FRAMEBUFFER_CONSOLE=y
902# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
903# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
904# CONFIG_FONTS is not set
905CONFIG_FONT_8x8=y
906CONFIG_FONT_8x16=y
907CONFIG_LOGO=y
908# CONFIG_LOGO_LINUX_MONO is not set
909# CONFIG_LOGO_LINUX_VGA16 is not set
910CONFIG_LOGO_LINUX_CLUT224=y
911# CONFIG_LOGO_SUPERH_MONO is not set
912# CONFIG_LOGO_SUPERH_VGA16 is not set
913# CONFIG_LOGO_SUPERH_CLUT224 is not set
914
915#
916# Sound
917#
918# CONFIG_SOUND is not set
919CONFIG_HID_SUPPORT=y
920CONFIG_HID=y
921# CONFIG_HID_DEBUG is not set
922# CONFIG_HIDRAW is not set
923
924#
925# USB Input Devices
926#
927CONFIG_USB_HID=y
928# CONFIG_USB_HIDINPUT_POWERBOOK is not set
929# CONFIG_HID_FF is not set
930# CONFIG_USB_HIDDEV is not set
931CONFIG_USB_SUPPORT=y
932CONFIG_USB_ARCH_HAS_HCD=y
933CONFIG_USB_ARCH_HAS_OHCI=y
934CONFIG_USB_ARCH_HAS_EHCI=y
935CONFIG_USB=y
936# CONFIG_USB_DEBUG is not set
937# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
938
939#
940# Miscellaneous USB options
941#
942CONFIG_USB_DEVICEFS=y
943CONFIG_USB_DEVICE_CLASS=y
944# CONFIG_USB_DYNAMIC_MINORS is not set
945# CONFIG_USB_OTG is not set
946# CONFIG_USB_OTG_WHITELIST is not set
947# CONFIG_USB_OTG_BLACKLIST_HUB is not set
948
949#
950# USB Host Controller Drivers
951#
952# CONFIG_USB_C67X00_HCD is not set
953CONFIG_USB_EHCI_HCD=m
954# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
955# CONFIG_USB_EHCI_TT_NEWSCHED is not set
956# CONFIG_USB_ISP116X_HCD is not set
957# CONFIG_USB_ISP1760_HCD is not set
958CONFIG_USB_OHCI_HCD=m
959# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
960# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
961CONFIG_USB_OHCI_LITTLE_ENDIAN=y
962# CONFIG_USB_UHCI_HCD is not set
963# CONFIG_USB_SL811_HCD is not set
964CONFIG_USB_R8A66597_HCD=y
965
966#
967# USB Device Class drivers
968#
969# CONFIG_USB_ACM is not set
970# CONFIG_USB_PRINTER is not set
971# CONFIG_USB_WDM is not set
972
973#
974# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
975#
976
977#
978# may also be needed; see USB_STORAGE Help for more information
979#
980CONFIG_USB_STORAGE=y
981# CONFIG_USB_STORAGE_DEBUG is not set
982# CONFIG_USB_STORAGE_DATAFAB is not set
983# CONFIG_USB_STORAGE_FREECOM is not set
984# CONFIG_USB_STORAGE_ISD200 is not set
985# CONFIG_USB_STORAGE_DPCM is not set
986# CONFIG_USB_STORAGE_USBAT is not set
987# CONFIG_USB_STORAGE_SDDR09 is not set
988# CONFIG_USB_STORAGE_SDDR55 is not set
989# CONFIG_USB_STORAGE_JUMPSHOT is not set
990# CONFIG_USB_STORAGE_ALAUDA is not set
991# CONFIG_USB_STORAGE_ONETOUCH is not set
992# CONFIG_USB_STORAGE_KARMA is not set
993# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
994# CONFIG_USB_LIBUSUAL is not set
995
996#
997# USB Imaging devices
998#
999# CONFIG_USB_MDC800 is not set
1000# CONFIG_USB_MICROTEK is not set
1001CONFIG_USB_MON=y
1002
1003#
1004# USB port drivers
1005#
1006# CONFIG_USB_SERIAL is not set
1007
1008#
1009# USB Miscellaneous drivers
1010#
1011# CONFIG_USB_EMI62 is not set
1012# CONFIG_USB_EMI26 is not set
1013# CONFIG_USB_ADUTUX is not set
1014# CONFIG_USB_AUERSWALD is not set
1015# CONFIG_USB_RIO500 is not set
1016# CONFIG_USB_LEGOTOWER is not set
1017# CONFIG_USB_LCD is not set
1018# CONFIG_USB_BERRY_CHARGE is not set
1019# CONFIG_USB_LED is not set
1020# CONFIG_USB_CYPRESS_CY7C63 is not set
1021# CONFIG_USB_CYTHERM is not set
1022# CONFIG_USB_PHIDGET is not set
1023# CONFIG_USB_IDMOUSE is not set
1024# CONFIG_USB_FTDI_ELAN is not set
1025# CONFIG_USB_APPLEDISPLAY is not set
1026# CONFIG_USB_SISUSBVGA is not set
1027# CONFIG_USB_LD is not set
1028# CONFIG_USB_TRANCEVIBRATOR is not set
1029# CONFIG_USB_IOWARRIOR is not set
1030CONFIG_USB_TEST=m
1031# CONFIG_USB_ISIGHTFW is not set
1032# CONFIG_USB_GADGET is not set
1033# CONFIG_MMC is not set
1034# CONFIG_MEMSTICK is not set
1035# CONFIG_NEW_LEDS is not set
1036# CONFIG_ACCESSIBILITY is not set
1037# CONFIG_INFINIBAND is not set
1038CONFIG_RTC_LIB=y
1039CONFIG_RTC_CLASS=y
1040CONFIG_RTC_HCTOSYS=y
1041CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1042# CONFIG_RTC_DEBUG is not set
1043
1044#
1045# RTC interfaces
1046#
1047CONFIG_RTC_INTF_SYSFS=y
1048CONFIG_RTC_INTF_PROC=y
1049CONFIG_RTC_INTF_DEV=y
1050# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1051# CONFIG_RTC_DRV_TEST is not set
1052
1053#
1054# I2C RTC drivers
1055#
1056# CONFIG_RTC_DRV_DS1307 is not set
1057# CONFIG_RTC_DRV_DS1374 is not set
1058# CONFIG_RTC_DRV_DS1672 is not set
1059# CONFIG_RTC_DRV_MAX6900 is not set
1060CONFIG_RTC_DRV_RS5C372=y
1061# CONFIG_RTC_DRV_ISL1208 is not set
1062# CONFIG_RTC_DRV_X1205 is not set
1063# CONFIG_RTC_DRV_PCF8563 is not set
1064# CONFIG_RTC_DRV_PCF8583 is not set
1065# CONFIG_RTC_DRV_M41T80 is not set
1066# CONFIG_RTC_DRV_S35390A is not set
1067# CONFIG_RTC_DRV_FM3130 is not set
1068
1069#
1070# SPI RTC drivers
1071#
1072
1073#
1074# Platform RTC drivers
1075#
1076# CONFIG_RTC_DRV_DS1511 is not set
1077# CONFIG_RTC_DRV_DS1553 is not set
1078# CONFIG_RTC_DRV_DS1742 is not set
1079# CONFIG_RTC_DRV_STK17TA8 is not set
1080# CONFIG_RTC_DRV_M48T86 is not set
1081# CONFIG_RTC_DRV_M48T59 is not set
1082# CONFIG_RTC_DRV_V3020 is not set
1083
1084#
1085# on-CPU RTC drivers
1086#
1087# CONFIG_RTC_DRV_SH is not set
1088# CONFIG_UIO is not set
1089
1090#
1091# File systems
1092#
1093CONFIG_EXT2_FS=y
1094# CONFIG_EXT2_FS_XATTR is not set
1095# CONFIG_EXT2_FS_XIP is not set
1096CONFIG_EXT3_FS=y
1097CONFIG_EXT3_FS_XATTR=y
1098# CONFIG_EXT3_FS_POSIX_ACL is not set
1099# CONFIG_EXT3_FS_SECURITY is not set
1100# CONFIG_EXT4DEV_FS is not set
1101CONFIG_JBD=y
1102CONFIG_FS_MBCACHE=y
1103# CONFIG_REISERFS_FS is not set
1104# CONFIG_JFS_FS is not set
1105CONFIG_FS_POSIX_ACL=y
1106# CONFIG_XFS_FS is not set
1107# CONFIG_OCFS2_FS is not set
1108CONFIG_DNOTIFY=y
1109CONFIG_INOTIFY=y
1110CONFIG_INOTIFY_USER=y
1111# CONFIG_QUOTA is not set
1112# CONFIG_AUTOFS_FS is not set
1113# CONFIG_AUTOFS4_FS is not set
1114# CONFIG_FUSE_FS is not set
1115
1116#
1117# CD-ROM/DVD Filesystems
1118#
1119# CONFIG_ISO9660_FS is not set
1120# CONFIG_UDF_FS is not set
1121
1122#
1123# DOS/FAT/NT Filesystems
1124#
1125CONFIG_FAT_FS=y
1126CONFIG_MSDOS_FS=y
1127CONFIG_VFAT_FS=y
1128CONFIG_FAT_DEFAULT_CODEPAGE=437
1129CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1130CONFIG_NTFS_FS=y
1131# CONFIG_NTFS_DEBUG is not set
1132CONFIG_NTFS_RW=y
1133
1134#
1135# Pseudo filesystems
1136#
1137CONFIG_PROC_FS=y
1138CONFIG_PROC_KCORE=y
1139CONFIG_PROC_SYSCTL=y
1140CONFIG_SYSFS=y
1141CONFIG_TMPFS=y
1142# CONFIG_TMPFS_POSIX_ACL is not set
1143# CONFIG_HUGETLBFS is not set
1144# CONFIG_HUGETLB_PAGE is not set
1145# CONFIG_CONFIGFS_FS is not set
1146
1147#
1148# Miscellaneous filesystems
1149#
1150# CONFIG_ADFS_FS is not set
1151# CONFIG_AFFS_FS is not set
1152# CONFIG_HFS_FS is not set
1153# CONFIG_HFSPLUS_FS is not set
1154# CONFIG_BEFS_FS is not set
1155# CONFIG_BFS_FS is not set
1156# CONFIG_EFS_FS is not set
1157# CONFIG_JFFS2_FS is not set
1158# CONFIG_CRAMFS is not set
1159# CONFIG_VXFS_FS is not set
1160CONFIG_MINIX_FS=y
1161# CONFIG_HPFS_FS is not set
1162# CONFIG_QNX4FS_FS is not set
1163# CONFIG_ROMFS_FS is not set
1164# CONFIG_SYSV_FS is not set
1165# CONFIG_UFS_FS is not set
1166CONFIG_NETWORK_FILESYSTEMS=y
1167CONFIG_NFS_FS=y
1168CONFIG_NFS_V3=y
1169# CONFIG_NFS_V3_ACL is not set
1170CONFIG_NFS_V4=y
1171CONFIG_NFSD=y
1172CONFIG_NFSD_V3=y
1173# CONFIG_NFSD_V3_ACL is not set
1174CONFIG_NFSD_V4=y
1175CONFIG_ROOT_NFS=y
1176CONFIG_LOCKD=y
1177CONFIG_LOCKD_V4=y
1178CONFIG_EXPORTFS=y
1179CONFIG_NFS_COMMON=y
1180CONFIG_SUNRPC=y
1181CONFIG_SUNRPC_GSS=y
1182# CONFIG_SUNRPC_BIND34 is not set
1183CONFIG_RPCSEC_GSS_KRB5=y
1184# CONFIG_RPCSEC_GSS_SPKM3 is not set
1185# CONFIG_SMB_FS is not set
1186# CONFIG_CIFS is not set
1187# CONFIG_NCP_FS is not set
1188# CONFIG_CODA_FS is not set
1189# CONFIG_AFS_FS is not set
1190
1191#
1192# Partition Types
1193#
1194# CONFIG_PARTITION_ADVANCED is not set
1195CONFIG_MSDOS_PARTITION=y
1196CONFIG_NLS=y
1197CONFIG_NLS_DEFAULT="iso8859-1"
1198CONFIG_NLS_CODEPAGE_437=y
1199# CONFIG_NLS_CODEPAGE_737 is not set
1200# CONFIG_NLS_CODEPAGE_775 is not set
1201# CONFIG_NLS_CODEPAGE_850 is not set
1202# CONFIG_NLS_CODEPAGE_852 is not set
1203# CONFIG_NLS_CODEPAGE_855 is not set
1204# CONFIG_NLS_CODEPAGE_857 is not set
1205# CONFIG_NLS_CODEPAGE_860 is not set
1206# CONFIG_NLS_CODEPAGE_861 is not set
1207# CONFIG_NLS_CODEPAGE_862 is not set
1208# CONFIG_NLS_CODEPAGE_863 is not set
1209# CONFIG_NLS_CODEPAGE_864 is not set
1210# CONFIG_NLS_CODEPAGE_865 is not set
1211# CONFIG_NLS_CODEPAGE_866 is not set
1212# CONFIG_NLS_CODEPAGE_869 is not set
1213# CONFIG_NLS_CODEPAGE_936 is not set
1214# CONFIG_NLS_CODEPAGE_950 is not set
1215CONFIG_NLS_CODEPAGE_932=y
1216# CONFIG_NLS_CODEPAGE_949 is not set
1217# CONFIG_NLS_CODEPAGE_874 is not set
1218# CONFIG_NLS_ISO8859_8 is not set
1219# CONFIG_NLS_CODEPAGE_1250 is not set
1220# CONFIG_NLS_CODEPAGE_1251 is not set
1221# CONFIG_NLS_ASCII is not set
1222CONFIG_NLS_ISO8859_1=y
1223# CONFIG_NLS_ISO8859_2 is not set
1224# CONFIG_NLS_ISO8859_3 is not set
1225# CONFIG_NLS_ISO8859_4 is not set
1226# CONFIG_NLS_ISO8859_5 is not set
1227# CONFIG_NLS_ISO8859_6 is not set
1228# CONFIG_NLS_ISO8859_7 is not set
1229# CONFIG_NLS_ISO8859_9 is not set
1230# CONFIG_NLS_ISO8859_13 is not set
1231# CONFIG_NLS_ISO8859_14 is not set
1232# CONFIG_NLS_ISO8859_15 is not set
1233# CONFIG_NLS_KOI8_R is not set
1234# CONFIG_NLS_KOI8_U is not set
1235# CONFIG_NLS_UTF8 is not set
1236# CONFIG_DLM is not set
1237
1238#
1239# Kernel hacking
1240#
1241CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1242# CONFIG_PRINTK_TIME is not set
1243# CONFIG_ENABLE_WARN_DEPRECATED is not set
1244# CONFIG_ENABLE_MUST_CHECK is not set
1245CONFIG_FRAME_WARN=1024
1246# CONFIG_MAGIC_SYSRQ is not set
1247# CONFIG_UNUSED_SYMBOLS is not set
1248# CONFIG_DEBUG_FS is not set
1249# CONFIG_HEADERS_CHECK is not set
1250CONFIG_DEBUG_KERNEL=y
1251# CONFIG_DEBUG_SHIRQ is not set
1252CONFIG_DETECT_SOFTLOCKUP=y
1253CONFIG_SCHED_DEBUG=y
1254# CONFIG_SCHEDSTATS is not set
1255# CONFIG_TIMER_STATS is not set
1256# CONFIG_DEBUG_OBJECTS is not set
1257# CONFIG_DEBUG_SLAB is not set
1258CONFIG_DEBUG_PREEMPT=y
1259# CONFIG_DEBUG_RT_MUTEXES is not set
1260# CONFIG_RT_MUTEX_TESTER is not set
1261# CONFIG_DEBUG_SPINLOCK is not set
1262# CONFIG_DEBUG_MUTEXES is not set
1263# CONFIG_DEBUG_LOCK_ALLOC is not set
1264# CONFIG_PROVE_LOCKING is not set
1265# CONFIG_LOCK_STAT is not set
1266# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1267# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1268# CONFIG_DEBUG_KOBJECT is not set
1269# CONFIG_DEBUG_BUGVERBOSE is not set
1270# CONFIG_DEBUG_INFO is not set
1271# CONFIG_DEBUG_VM is not set
1272# CONFIG_DEBUG_WRITECOUNT is not set
1273# CONFIG_DEBUG_LIST is not set
1274# CONFIG_DEBUG_SG is not set
1275# CONFIG_FRAME_POINTER is not set
1276# CONFIG_BOOT_PRINTK_DELAY is not set
1277# CONFIG_RCU_TORTURE_TEST is not set
1278# CONFIG_BACKTRACE_SELF_TEST is not set
1279# CONFIG_FAULT_INJECTION is not set
1280# CONFIG_SAMPLES is not set
1281# CONFIG_SH_STANDARD_BIOS is not set
1282# CONFIG_EARLY_SCIF_CONSOLE is not set
1283# CONFIG_DEBUG_BOOTMEM is not set
1284# CONFIG_DEBUG_STACKOVERFLOW is not set
1285# CONFIG_DEBUG_STACK_USAGE is not set
1286# CONFIG_4KSTACKS is not set
1287# CONFIG_IRQSTACKS is not set
1288# CONFIG_SH_KGDB is not set
1289
1290#
1291# Security options
1292#
1293# CONFIG_KEYS is not set
1294# CONFIG_SECURITY is not set
1295# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1296CONFIG_CRYPTO=y
1297
1298#
1299# Crypto core or helper
1300#
1301CONFIG_CRYPTO_ALGAPI=y
1302CONFIG_CRYPTO_BLKCIPHER=y
1303CONFIG_CRYPTO_HASH=y
1304CONFIG_CRYPTO_MANAGER=y
1305# CONFIG_CRYPTO_GF128MUL is not set
1306# CONFIG_CRYPTO_NULL is not set
1307# CONFIG_CRYPTO_CRYPTD is not set
1308# CONFIG_CRYPTO_AUTHENC is not set
1309# CONFIG_CRYPTO_TEST is not set
1310
1311#
1312# Authenticated Encryption with Associated Data
1313#
1314# CONFIG_CRYPTO_CCM is not set
1315# CONFIG_CRYPTO_GCM is not set
1316# CONFIG_CRYPTO_SEQIV is not set
1317
1318#
1319# Block modes
1320#
1321CONFIG_CRYPTO_CBC=y
1322# CONFIG_CRYPTO_CTR is not set
1323# CONFIG_CRYPTO_CTS is not set
1324# CONFIG_CRYPTO_ECB is not set
1325# CONFIG_CRYPTO_LRW is not set
1326# CONFIG_CRYPTO_PCBC is not set
1327# CONFIG_CRYPTO_XTS is not set
1328
1329#
1330# Hash modes
1331#
1332CONFIG_CRYPTO_HMAC=y
1333# CONFIG_CRYPTO_XCBC is not set
1334
1335#
1336# Digest
1337#
1338# CONFIG_CRYPTO_CRC32C is not set
1339# CONFIG_CRYPTO_MD4 is not set
1340CONFIG_CRYPTO_MD5=y
1341# CONFIG_CRYPTO_MICHAEL_MIC is not set
1342# CONFIG_CRYPTO_SHA1 is not set
1343# CONFIG_CRYPTO_SHA256 is not set
1344# CONFIG_CRYPTO_SHA512 is not set
1345# CONFIG_CRYPTO_TGR192 is not set
1346# CONFIG_CRYPTO_WP512 is not set
1347
1348#
1349# Ciphers
1350#
1351# CONFIG_CRYPTO_AES is not set
1352# CONFIG_CRYPTO_ANUBIS is not set
1353# CONFIG_CRYPTO_ARC4 is not set
1354# CONFIG_CRYPTO_BLOWFISH is not set
1355# CONFIG_CRYPTO_CAMELLIA is not set
1356# CONFIG_CRYPTO_CAST5 is not set
1357# CONFIG_CRYPTO_CAST6 is not set
1358CONFIG_CRYPTO_DES=y
1359# CONFIG_CRYPTO_FCRYPT is not set
1360# CONFIG_CRYPTO_KHAZAD is not set
1361# CONFIG_CRYPTO_SALSA20 is not set
1362# CONFIG_CRYPTO_SEED is not set
1363# CONFIG_CRYPTO_SERPENT is not set
1364# CONFIG_CRYPTO_TEA is not set
1365# CONFIG_CRYPTO_TWOFISH is not set
1366
1367#
1368# Compression
1369#
1370# CONFIG_CRYPTO_DEFLATE is not set
1371# CONFIG_CRYPTO_LZO is not set
1372# CONFIG_CRYPTO_HW is not set
1373
1374#
1375# Library routines
1376#
1377CONFIG_BITREVERSE=y
1378# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1379# CONFIG_CRC_CCITT is not set
1380# CONFIG_CRC16 is not set
1381# CONFIG_CRC_ITU_T is not set
1382CONFIG_CRC32=y
1383# CONFIG_CRC7 is not set
1384# CONFIG_LIBCRC32C is not set
1385CONFIG_PLIST=y
1386CONFIG_HAS_IOMEM=y
1387CONFIG_HAS_IOPORT=y
1388CONFIG_HAS_DMA=y
diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 0718805774e8..847e90894d1b 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_SH_LANDISK) += ops-landisk.o
23obj-$(CONFIG_SH_LBOX_RE2) += ops-lboxre2.o fixups-lboxre2.o 23obj-$(CONFIG_SH_LBOX_RE2) += ops-lboxre2.o fixups-lboxre2.o
24obj-$(CONFIG_SH_7780_SOLUTION_ENGINE) += ops-se7780.o fixups-se7780.o 24obj-$(CONFIG_SH_7780_SOLUTION_ENGINE) += ops-se7780.o fixups-se7780.o
25obj-$(CONFIG_SH_CAYMAN) += ops-cayman.o 25obj-$(CONFIG_SH_CAYMAN) += ops-cayman.o
26obj-$(CONFIG_SH_SH7785LCR) += ops-sh7785lcr.o fixups-sh7785lcr.o
diff --git a/arch/sh/drivers/pci/fixups-sh7785lcr.c b/arch/sh/drivers/pci/fixups-sh7785lcr.c
new file mode 100644
index 000000000000..4949e601387a
--- /dev/null
+++ b/arch/sh/drivers/pci/fixups-sh7785lcr.c
@@ -0,0 +1,46 @@
1/*
2 * arch/sh/drivers/pci/fixups-sh7785lcr.c
3 *
4 * R0P7785LC0011RL PCI fixups
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * Based on arch/sh/drivers/pci/fixups-r7780rp.c
8 * Copyright (C) 2003 Lineo uSolutions, Inc.
9 * Copyright (C) 2004 - 2006 Paul Mundt
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/pci.h>
16#include "pci-sh4.h"
17
18int pci_fixup_pcic(void)
19{
20 pci_write_reg(0x000043ff, SH4_PCIINTM);
21 pci_write_reg(0x0000380f, SH4_PCIAINTM);
22
23 pci_write_reg(0xfbb00047, SH7780_PCICMD);
24 pci_write_reg(0x00000000, SH7780_PCIIBAR);
25
26 pci_write_reg(0x00011912, SH7780_PCISVID);
27 pci_write_reg(0x08000000, SH7780_PCICSCR0);
28 pci_write_reg(0x0000001b, SH7780_PCICSAR0);
29 pci_write_reg(0xfd000000, SH7780_PCICSCR1);
30 pci_write_reg(0x0000000f, SH7780_PCICSAR1);
31
32 pci_write_reg(0xfd000000, SH7780_PCIMBR0);
33 pci_write_reg(0x00fc0000, SH7780_PCIMBMR0);
34
35#ifdef CONFIG_32BIT
36 pci_write_reg(0xc0000000, SH7780_PCIMBR2);
37 pci_write_reg(0x20000000 - SH7780_PCI_IO_SIZE, SH7780_PCIMBMR2);
38#endif
39
40 /* Set IOBR for windows containing area specified in pci.h */
41 pci_write_reg((PCIBIOS_MIN_IO & ~(SH7780_PCI_IO_SIZE - 1)),
42 SH7780_PCIIOBR);
43 pci_write_reg(((SH7780_PCI_IO_SIZE - 1) & (7 << 18)), SH7780_PCIIOBMR);
44
45 return 0;
46}
diff --git a/arch/sh/drivers/pci/ops-dreamcast.c b/arch/sh/drivers/pci/ops-dreamcast.c
index e1284fc69361..f54c291db37b 100644
--- a/arch/sh/drivers/pci/ops-dreamcast.c
+++ b/arch/sh/drivers/pci/ops-dreamcast.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/module.h>
25 26
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/irq.h> 28#include <asm/irq.h>
@@ -48,6 +49,7 @@ struct pci_channel board_pci_channels[] = {
48 &gapspci_mem_resource, 0, 1 }, 49 &gapspci_mem_resource, 0, 1 },
49 { 0, } 50 { 0, }
50}; 51};
52EXPORT_SYMBOL(board_pci_channels);
51 53
52/* 54/*
53 * The !gapspci_config_access case really shouldn't happen, ever, unless 55 * The !gapspci_config_access case really shouldn't happen, ever, unless
diff --git a/arch/sh/drivers/pci/ops-sh7785lcr.c b/arch/sh/drivers/pci/ops-sh7785lcr.c
new file mode 100644
index 000000000000..b3bd68702059
--- /dev/null
+++ b/arch/sh/drivers/pci/ops-sh7785lcr.c
@@ -0,0 +1,66 @@
1/*
2 * Author: Ian DaSilva (idasilva@mvista.com)
3 *
4 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * PCI initialization for the Renesas R0P7785LC0011RL board
10 * Based on arch/sh/drivers/pci/ops-r7780rp.c
11 *
12 */
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/pci.h>
18#include "pci-sh4.h"
19
20static char irq_tab[] __initdata = {
21 65, 66, 67, 68,
22};
23
24int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
25{
26 return irq_tab[slot];
27}
28
29static struct resource sh7785_io_resource = {
30 .name = "SH7785_IO",
31 .start = SH7780_PCI_IO_BASE,
32 .end = SH7780_PCI_IO_BASE + SH7780_PCI_IO_SIZE - 1,
33 .flags = IORESOURCE_IO
34};
35
36static struct resource sh7785_mem_resource = {
37 .name = "SH7785_mem",
38 .start = SH7780_PCI_MEMORY_BASE,
39 .end = SH7780_PCI_MEMORY_BASE + SH7780_PCI_MEM_SIZE - 1,
40 .flags = IORESOURCE_MEM
41};
42
43struct pci_channel board_pci_channels[] = {
44 { &sh4_pci_ops, &sh7785_io_resource, &sh7785_mem_resource, 0, 0xff },
45 { NULL, NULL, NULL, 0, 0 },
46};
47EXPORT_SYMBOL(board_pci_channels);
48
49static struct sh4_pci_address_map sh7785_pci_map = {
50 .window0 = {
51 .base = SH7780_CS2_BASE_ADDR,
52 .size = 0x04000000,
53 },
54
55 .window1 = {
56 .base = SH7780_CS3_BASE_ADDR,
57 .size = 0x04000000,
58 },
59
60 .flags = SH4_PCIC_NO_RESET,
61};
62
63int __init pcibios_init_platform(void)
64{
65 return sh7780_pcic_init(&sh7785_pci_map);
66}
diff --git a/arch/sh/drivers/pci/pci-auto.c b/arch/sh/drivers/pci/pci-auto.c
index ea404704ace8..cf48b12ee58c 100644
--- a/arch/sh/drivers/pci/pci-auto.c
+++ b/arch/sh/drivers/pci/pci-auto.c
@@ -78,7 +78,7 @@ static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
78} 78}
79 79
80#define EARLY_PCI_OP(rw, size, type) \ 80#define EARLY_PCI_OP(rw, size, type) \
81int early_##rw##_config_##size(struct pci_channel *hose, \ 81static int early_##rw##_config_##size(struct pci_channel *hose, \
82 int top_bus, int bus, int devfn, int offset, type value) \ 82 int top_bus, int bus, int devfn, int offset, type value) \
83{ \ 83{ \
84 return pci_##rw##_config_##size( \ 84 return pci_##rw##_config_##size( \
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index f57095a2617c..d3839e609aac 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -135,7 +135,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
135 * If we set up a device for bus mastering, we need to check and set 135 * If we set up a device for bus mastering, we need to check and set
136 * the latency timer as it may not be properly set. 136 * the latency timer as it may not be properly set.
137 */ 137 */
138unsigned int pcibios_max_latency = 255; 138static unsigned int pcibios_max_latency = 255;
139 139
140void pcibios_set_master(struct pci_dev *dev) 140void pcibios_set_master(struct pci_dev *dev)
141{ 141{
diff --git a/arch/sh/kernel/Makefile_32 b/arch/sh/kernel/Makefile_32
index 4bbdce36b92b..0e6905fe9fec 100644
--- a/arch/sh/kernel/Makefile_32
+++ b/arch/sh/kernel/Makefile_32
@@ -21,7 +21,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
21obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 21obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
22obj-$(CONFIG_PM) += pm.o 22obj-$(CONFIG_PM) += pm.o
23obj-$(CONFIG_STACKTRACE) += stacktrace.o 23obj-$(CONFIG_STACKTRACE) += stacktrace.o
24obj-$(CONFIG_BINFMT_ELF) += dump_task.o 24obj-$(CONFIG_ELF_CORE) += dump_task.o
25obj-$(CONFIG_IO_TRAPPED) += io_trapped.o 25obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
26 26
27EXTRA_CFLAGS += -Werror 27EXTRA_CFLAGS += -Werror
diff --git a/arch/sh/kernel/cf-enabler.c b/arch/sh/kernel/cf-enabler.c
index 01ff4d05aab0..d3d9f3204230 100644
--- a/arch/sh/kernel/cf-enabler.c
+++ b/arch/sh/kernel/cf-enabler.c
@@ -157,7 +157,7 @@ static int __init cf_init_se(void)
157} 157}
158#endif 158#endif
159 159
160int __init cf_init(void) 160static int __init cf_init(void)
161{ 161{
162 if (mach_is_se() || mach_is_7722se() || mach_is_7721se()) 162 if (mach_is_se() || mach_is_7722se() || mach_is_7721se())
163 return cf_init_se(); 163 return cf_init_se();
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index b5f1e23ed57c..f5eb56e6bc59 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -88,7 +88,7 @@ static void propagate_rate(struct clk *clk)
88 } 88 }
89} 89}
90 90
91int __clk_enable(struct clk *clk) 91static int __clk_enable(struct clk *clk)
92{ 92{
93 /* 93 /*
94 * See if this is the first time we're enabling the clock, some 94 * See if this is the first time we're enabling the clock, some
@@ -111,7 +111,6 @@ int __clk_enable(struct clk *clk)
111 111
112 return 0; 112 return 0;
113} 113}
114EXPORT_SYMBOL_GPL(__clk_enable);
115 114
116int clk_enable(struct clk *clk) 115int clk_enable(struct clk *clk)
117{ 116{
@@ -131,7 +130,7 @@ static void clk_kref_release(struct kref *kref)
131 /* Nothing to do */ 130 /* Nothing to do */
132} 131}
133 132
134void __clk_disable(struct clk *clk) 133static void __clk_disable(struct clk *clk)
135{ 134{
136 int count = kref_put(&clk->kref, clk_kref_release); 135 int count = kref_put(&clk->kref, clk_kref_release);
137 136
@@ -143,7 +142,6 @@ void __clk_disable(struct clk *clk)
143 clk->ops->disable(clk); 142 clk->ops->disable(clk);
144 } 143 }
145} 144}
146EXPORT_SYMBOL_GPL(__clk_disable);
147 145
148void clk_disable(struct clk *clk) 146void clk_disable(struct clk *clk)
149{ 147{
@@ -310,15 +308,11 @@ static int show_clocks(char *buf, char **start, off_t off,
310 list_for_each_entry_reverse(clk, &clock_list, node) { 308 list_for_each_entry_reverse(clk, &clock_list, node) {
311 unsigned long rate = clk_get_rate(clk); 309 unsigned long rate = clk_get_rate(clk);
312 310
313 /* 311 p += sprintf(p, "%-12s\t: %ld.%02ldMHz\t%s\n", clk->name,
314 * Don't bother listing dummy clocks with no ancestry 312 rate / 1000000, (rate % 1000000) / 10000,
315 * that only support enable and disable ops. 313 ((clk->flags & CLK_ALWAYS_ENABLED) ||
316 */ 314 (atomic_read(&clk->kref.refcount) != 1)) ?
317 if (unlikely(!rate && !clk->parent)) 315 "enabled" : "disabled");
318 continue;
319
320 p += sprintf(p, "%-12s\t: %ld.%02ldMHz\n", clk->name,
321 rate / 1000000, (rate % 1000000) / 10000);
322 } 316 }
323 317
324 return p - buf; 318 return p - buf;
diff --git a/arch/sh/kernel/cpu/irq/intc.c b/arch/sh/kernel/cpu/irq/intc.c
index da5dae787888..8c70e201bde0 100644
--- a/arch/sh/kernel/cpu/irq/intc.c
+++ b/arch/sh/kernel/cpu/irq/intc.c
@@ -62,7 +62,7 @@ struct intc_desc_int {
62#endif 62#endif
63 63
64static unsigned int intc_prio_level[NR_IRQS]; /* for now */ 64static unsigned int intc_prio_level[NR_IRQS]; /* for now */
65#ifdef CONFIG_CPU_SH3 65#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
66static unsigned long ack_handle[NR_IRQS]; 66static unsigned long ack_handle[NR_IRQS];
67#endif 67#endif
68 68
@@ -231,7 +231,7 @@ static void intc_disable(unsigned int irq)
231 } 231 }
232} 232}
233 233
234#ifdef CONFIG_CPU_SH3 234#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
235static void intc_mask_ack(unsigned int irq) 235static void intc_mask_ack(unsigned int irq)
236{ 236{
237 struct intc_desc_int *d = get_intc_desc(irq); 237 struct intc_desc_int *d = get_intc_desc(irq);
@@ -244,8 +244,23 @@ static void intc_mask_ack(unsigned int irq)
244 244
245 if (handle) { 245 if (handle) {
246 addr = INTC_REG(d, _INTC_ADDR_D(handle), 0); 246 addr = INTC_REG(d, _INTC_ADDR_D(handle), 0);
247 ctrl_inb(addr); 247 switch (_INTC_FN(handle)) {
248 ctrl_outb(0x3f ^ set_field(0, 1, handle), addr); 248 case REG_FN_MODIFY_BASE + 0: /* 8bit */
249 ctrl_inb(addr);
250 ctrl_outb(0xff ^ set_field(0, 1, handle), addr);
251 break;
252 case REG_FN_MODIFY_BASE + 1: /* 16bit */
253 ctrl_inw(addr);
254 ctrl_outw(0xffff ^ set_field(0, 1, handle), addr);
255 break;
256 case REG_FN_MODIFY_BASE + 3: /* 32bit */
257 ctrl_inl(addr);
258 ctrl_outl(0xffffffff ^ set_field(0, 1, handle), addr);
259 break;
260 default:
261 BUG();
262 break;
263 }
249 } 264 }
250} 265}
251#endif 266#endif
@@ -466,7 +481,7 @@ static unsigned int __init intc_prio_data(struct intc_desc *desc,
466 return 0; 481 return 0;
467} 482}
468 483
469#ifdef CONFIG_CPU_SH3 484#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
470static unsigned int __init intc_ack_data(struct intc_desc *desc, 485static unsigned int __init intc_ack_data(struct intc_desc *desc,
471 struct intc_desc_int *d, 486 struct intc_desc_int *d,
472 intc_enum enum_id) 487 intc_enum enum_id)
@@ -601,7 +616,7 @@ static void __init intc_register_irq(struct intc_desc *desc,
601 /* irq should be disabled by default */ 616 /* irq should be disabled by default */
602 d->chip.mask(irq); 617 d->chip.mask(irq);
603 618
604#ifdef CONFIG_CPU_SH3 619#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
605 if (desc->ack_regs) 620 if (desc->ack_regs)
606 ack_handle[irq] = intc_ack_data(desc, d, enum_id); 621 ack_handle[irq] = intc_ack_data(desc, d, enum_id);
607#endif 622#endif
@@ -635,7 +650,7 @@ void __init register_intc_controller(struct intc_desc *desc)
635 d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; 650 d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0;
636 d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; 651 d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0;
637 652
638#ifdef CONFIG_CPU_SH3 653#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
639 d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0; 654 d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0;
640#endif 655#endif
641 d->reg = alloc_bootmem(d->nr_reg * sizeof(*d->reg)); 656 d->reg = alloc_bootmem(d->nr_reg * sizeof(*d->reg));
@@ -676,7 +691,7 @@ void __init register_intc_controller(struct intc_desc *desc)
676 d->chip.mask_ack = intc_disable; 691 d->chip.mask_ack = intc_disable;
677 d->chip.set_type = intc_set_sense; 692 d->chip.set_type = intc_set_sense;
678 693
679#ifdef CONFIG_CPU_SH3 694#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
680 if (desc->ack_regs) { 695 if (desc->ack_regs) {
681 for (i = 0; i < desc->nr_ack_regs; i++) 696 for (i = 0; i < desc->nr_ack_regs; i++)
682 k += save_reg(d, k, desc->ack_regs[i].set_reg, 0); 697 k += save_reg(d, k, desc->ack_regs[i].set_reg, 0);
diff --git a/arch/sh/kernel/cpu/sh2/entry.S b/arch/sh/kernel/cpu/sh2/entry.S
index 0fc89069d8c7..ee894e5a45e7 100644
--- a/arch/sh/kernel/cpu/sh2/entry.S
+++ b/arch/sh/kernel/cpu/sh2/entry.S
@@ -3,7 +3,7 @@
3 * 3 *
4 * The SH-2 exception entry 4 * The SH-2 exception entry
5 * 5 *
6 * Copyright (C) 2005,2006 Yoshinori Sato 6 * Copyright (C) 2005-2008 Yoshinori Sato
7 * Copyright (C) 2005 AXE,Inc. 7 * Copyright (C) 2005 AXE,Inc.
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
@@ -36,43 +36,41 @@ OFF_TRA = (16*4+6*4)
36#include <asm/entry-macros.S> 36#include <asm/entry-macros.S>
37 37
38ENTRY(exception_handler) 38ENTRY(exception_handler)
39 ! already saved r0/r1 39 ! stack
40 ! r0 <- point sp
41 ! r1
42 ! pc
43 ! sr
44 ! r0 = temporary
45 ! r1 = vector (pseudo EXPEVT / INTEVT / TRA)
40 mov.l r2,@-sp 46 mov.l r2,@-sp
41 mov.l r3,@-sp 47 mov.l r3,@-sp
42 mov r0,r1
43 cli 48 cli
44 mov.l $cpu_mode,r2 49 mov.l $cpu_mode,r2
45 mov.l @r2,r0 50 mov.l @r2,r0
46 mov.l @(5*4,r15),r3 ! previous SR 51 mov.l @(5*4,r15),r3 ! previous SR
47 shll2 r3 ! set "S" flag 52 or r0,r3 ! set MD
48 rotl r0 ! T <- "S" flag 53 tst r0,r0
49 rotl r0 ! "S" flag is LSB 54 bf/s 1f ! previous mode check
50 rotcr r3 ! T -> r3:b30 55 mov.l r3,@(5*4,r15) ! update SR
51 shlr r3
52 shlr r0
53 bt/s 1f
54 mov.l r3,@(5*4,r15) ! copy cpu mode to SR
55 ! switch to kernel mode 56 ! switch to kernel mode
56 mov #1,r0 57 mov.l __md_bit,r0
57 rotr r0
58 rotr r0
59 mov.l r0,@r2 ! enter kernel mode 58 mov.l r0,@r2 ! enter kernel mode
60 mov.l $current_thread_info,r2 59 mov.l $current_thread_info,r2
61 mov.l @r2,r2 60 mov.l @r2,r2
62 mov #0x20,r0 61 mov #(THREAD_SIZE >> 8),r0
63 shll8 r0 62 shll8 r0
64 add r2,r0 63 add r2,r0
65 mov r15,r2 ! r2 = user stack top 64 mov r15,r2 ! r2 = user stack top
66 mov r0,r15 ! switch kernel stack 65 mov r0,r15 ! switch kernel stack
67 add #-4,r15 ! dummy
68 mov.l r1,@-r15 ! TRA 66 mov.l r1,@-r15 ! TRA
69 sts.l macl, @-r15 67 sts.l macl, @-r15
70 sts.l mach, @-r15 68 sts.l mach, @-r15
71 stc.l gbr, @-r15 69 stc.l gbr, @-r15
72 mov.l @(4*4,r2),r0 70 mov.l @(5*4,r2),r0
73 mov.l @(5*4,r2),r1 71 mov.l r0,@-r15 ! original SR
74 mov.l r1,@-r15 ! original SR
75 sts.l pr,@-r15 72 sts.l pr,@-r15
73 mov.l @(4*4,r2),r0
76 mov.l r0,@-r15 ! original PC 74 mov.l r0,@-r15 ! original PC
77 mov r2,r3 75 mov r2,r3
78 add #(4+2)*4,r3 ! rewind r0 - r3 + exception frame 76 add #(4+2)*4,r3 ! rewind r0 - r3 + exception frame
@@ -88,14 +86,15 @@ ENTRY(exception_handler)
88 mov.l r6,@-r15 86 mov.l r6,@-r15
89 mov.l r5,@-r15 87 mov.l r5,@-r15
90 mov.l r4,@-r15 88 mov.l r4,@-r15
89 mov r1,r9 ! save TRA
91 mov r2,r8 ! copy user -> kernel stack 90 mov r2,r8 ! copy user -> kernel stack
92 mov.l @r8+,r3 91 mov.l @(0,r8),r3
93 mov.l r3,@-r15 92 mov.l r3,@-r15
94 mov.l @r8+,r2 93 mov.l @(4,r8),r2
95 mov.l r2,@-r15 94 mov.l r2,@-r15
96 mov.l @r8+,r1 95 mov.l @(12,r8),r1
97 mov.l r1,@-r15 96 mov.l r1,@-r15
98 mov.l @r8+,r0 97 mov.l @(8,r8),r0
99 bra 2f 98 bra 2f
100 mov.l r0,@-r15 99 mov.l r0,@-r15
1011: 1001:
@@ -107,10 +106,11 @@ ENTRY(exception_handler)
107 mov.l r0,@-r15 106 mov.l r0,@-r15
108 mov.l @r2+,r0 ! old R2 107 mov.l @r2+,r0 ! old R2
109 mov.l r0,@-r15 108 mov.l r0,@-r15
110 mov.l @r2+,r0 ! old R1 109 mov.l @(4,r2),r0 ! old R1
111 mov.l r0,@-r15
112 mov.l @r2+,r0 ! old R0
113 mov.l r0,@-r15 110 mov.l r0,@-r15
111 mov.l @r2,r0 ! old R0
112 mov.l r0,@-r15
113 add #8,r2
114 mov.l @r2+,r3 ! old PC 114 mov.l @r2+,r3 ! old PC
115 mov.l @r2+,r0 ! old SR 115 mov.l @r2+,r0 ! old SR
116 add #-4,r2 ! exception frame stub (sr) 116 add #-4,r2 ! exception frame stub (sr)
@@ -135,14 +135,12 @@ ENTRY(exception_handler)
135 mov.l r6,@-r2 135 mov.l r6,@-r2
136 mov.l r5,@-r2 136 mov.l r5,@-r2
137 mov.l r4,@-r2 137 mov.l r4,@-r2
138 mov r1,r9
138 mov.l @(OFF_R0,r15),r0 139 mov.l @(OFF_R0,r15),r0
139 mov.l @(OFF_R1,r15),r1 140 mov.l @(OFF_R1,r15),r1
140 mov.l @(OFF_R2,r15),r2 141 mov.l @(OFF_R2,r15),r2
141 mov.l @(OFF_R3,r15),r3 142 mov.l @(OFF_R3,r15),r3
1422: 1432:
143 mov #OFF_TRA,r8
144 add r15,r8
145 mov.l @r8,r9
146 mov #64,r8 144 mov #64,r8
147 cmp/hs r8,r9 145 cmp/hs r8,r9
148 bt interrupt_entry ! vec >= 64 is interrupt 146 bt interrupt_entry ! vec >= 64 is interrupt
@@ -150,26 +148,14 @@ ENTRY(exception_handler)
150 cmp/hs r8,r9 148 cmp/hs r8,r9
151 bt trap_entry ! 64 > vec >= 32 is trap 149 bt trap_entry ! 64 > vec >= 32 is trap
152 150
153#if defined(CONFIG_SH_FPU)
154 mov #13,r8
155 cmp/eq r8,r9
156 bt 10f ! fpu
157 nop
158#endif
159
160 mov.l 4f,r8 151 mov.l 4f,r8
161 mov r9,r4 152 mov r9,r4
162 shll2 r9 153 shll2 r9
163 add r9,r8 154 add r9,r8
164 mov.l @r8,r8 155 mov.l @r8,r8 ! exception handler address
165 mov #0,r9 156 tst r8,r8
166 cmp/eq r9,r8
167 bf 3f 157 bf 3f
168 mov.l 8f,r8 ! unhandled exception 158 mov.l 8f,r8 ! unhandled exception
169#if defined(CONFIG_SH_FPU)
17010:
171 mov.l 9f, r8 ! unhandled exception
172#endif
1733: 1593:
174 mov.l 5f,r10 160 mov.l 5f,r10
175 jmp @r8 161 jmp @r8
@@ -188,10 +174,7 @@ interrupt_entry:
1885: .long ret_from_exception 1745: .long ret_from_exception
1896: .long ret_from_irq 1756: .long ret_from_irq
1907: .long do_IRQ 1767: .long do_IRQ
1918: .long do_exception_error 1778: .long exception_error
192#ifdef CONFIG_SH_FPU
1939: .long fpu_error_trap_handler
194#endif
195 178
196trap_entry: 179trap_entry:
197 mov #0x30,r8 180 mov #0x30,r8
@@ -200,24 +183,9 @@ trap_entry:
200 add #-0x10,r9 ! convert SH2 to SH3/4 ABI 183 add #-0x10,r9 ! convert SH2 to SH3/4 ABI
2011: 1841:
202 shll2 r9 ! TRA 185 shll2 r9 ! TRA
203 mov #OFF_TRA,r8 186 bra system_call ! jump common systemcall entry
204 add r15,r8 187 mov r9,r8
205 mov.l r9,@r8
206 mov r9,r8
207#ifdef CONFIG_TRACE_IRQFLAGS
208 mov.l 2f, r9
209 jsr @r9
210 nop
211#endif
212 sti
213 bra system_call
214 nop
215 188
216 .align 2
217#ifdef CONFIG_TRACE_IRQFLAGS
2182: .long trace_hardirqs_on
219#endif
220
221#if defined(CONFIG_SH_STANDARD_BIOS) 189#if defined(CONFIG_SH_STANDARD_BIOS)
222 /* Unwind the stack and jmp to the debug entry */ 190 /* Unwind the stack and jmp to the debug entry */
223ENTRY(sh_bios_handler) 191ENTRY(sh_bios_handler)
@@ -240,7 +208,7 @@ ENTRY(sh_bios_handler)
240 mov.l @r2,r2 208 mov.l @r2,r2
241 stc sr,r3 209 stc sr,r3
242 mov.l r2,@r0 210 mov.l r2,@r0
243 mov.l r3,@r0 211 mov.l r3,@(4,r0)
244 mov.l r1,@(8,r0) 212 mov.l r1,@(8,r0)
245 mov.l @r15+, r0 213 mov.l @r15+, r0
246 mov.l @r15+, r1 214 mov.l @r15+, r1
@@ -272,22 +240,30 @@ ENTRY(address_error_trap_handler)
272 mov.l 1f,r0 240 mov.l 1f,r0
273 jmp @r0 241 jmp @r0
274 mov #0,r5 ! writeaccess is unknown 242 mov #0,r5 ! writeaccess is unknown
275 .align 2
276 243
244 .align 2
2771: .long do_address_error 2451: .long do_address_error
278 246
279restore_all: 247restore_all:
280 cli 248 stc sr,r0
281#ifdef CONFIG_TRACE_IRQFLAGS 249 or #0xf0,r0
282 mov.l 1f, r0 250 ldc r0,sr ! all interrupt block (same BL = 1)
283 jsr @r0 251 ! restore special register
284 nop 252 ! overlap exception frame
285#endif 253 mov r15,r0
254 add #17*4,r0
255 lds.l @r0+,pr
256 add #4,r0
257 ldc.l @r0+,gbr
258 lds.l @r0+,mach
259 lds.l @r0+,macl
286 mov r15,r0 260 mov r15,r0
287 mov.l $cpu_mode,r2 261 mov.l $cpu_mode,r2
288 mov #OFF_SR,r3 262 mov #OFF_SR,r3
289 mov.l @(r0,r3),r1 263 mov.l @(r0,r3),r1
290 mov.l r1,@r2 264 mov.l __md_bit,r3
265 and r1,r3 ! copy MD bit
266 mov.l r3,@r2
291 shll2 r1 ! clear MD bit 267 shll2 r1 ! clear MD bit
292 shlr2 r1 268 shlr2 r1
293 mov.l @(OFF_SP,r0),r2 269 mov.l @(OFF_SP,r0),r2
@@ -297,12 +273,6 @@ restore_all:
297 mov #OFF_PC,r3 273 mov #OFF_PC,r3
298 mov.l @(r0,r3),r1 274 mov.l @(r0,r3),r1
299 mov.l r1,@r2 ! set pc 275 mov.l r1,@r2 ! set pc
300 add #4*16+4,r0
301 lds.l @r0+,pr
302 add #4,r0 ! skip sr
303 ldc.l @r0+,gbr
304 lds.l @r0+,mach
305 lds.l @r0+,macl
306 get_current_thread_info r0, r1 276 get_current_thread_info r0, r1
307 mov.l $current_thread_info,r1 277 mov.l $current_thread_info,r1
308 mov.l r0,@r1 278 mov.l r0,@r1
@@ -326,9 +296,8 @@ restore_all:
326 nop 296 nop
327 297
328 .align 2 298 .align 2
329#ifdef CONFIG_TRACE_IRQFLAGS 299__md_bit:
3301: .long trace_hardirqs_off 300 .long 0x40000000
331#endif
332$current_thread_info: 301$current_thread_info:
333 .long __current_thread_info 302 .long __current_thread_info
334$cpu_mode: 303$cpu_mode:
diff --git a/arch/sh/kernel/cpu/sh2/ex.S b/arch/sh/kernel/cpu/sh2/ex.S
index 6d285af7846c..85b0bf81fc1d 100644
--- a/arch/sh/kernel/cpu/sh2/ex.S
+++ b/arch/sh/kernel/cpu/sh2/ex.S
@@ -18,16 +18,17 @@
18exception_entry: 18exception_entry:
19no = 0 19no = 0
20 .rept 256 20 .rept 256
21 mov.l r0,@-sp 21 mov.l r1,@-sp
22 mov #no,r0
23 bra exception_trampoline 22 bra exception_trampoline
24 and #0xff,r0 23 mov #no,r1
25no = no + 1 24no = no + 1
26 .endr 25 .endr
27exception_trampoline: 26exception_trampoline:
28 mov.l r1,@-sp 27 mov.l r0,@-sp
29 mov.l $exception_handler,r1 28 mov.l $exception_handler,r0
30 jmp @r1 29 extu.b r1,r1
30 jmp @r0
31 extu.w r1,r1
31 32
32 .align 2 33 .align 2
33$exception_entry: 34$exception_entry:
@@ -41,6 +42,6 @@ $exception_handler:
41ENTRY(vbr_base) 42ENTRY(vbr_base)
42vector = 0 43vector = 0
43 .rept 256 44 .rept 256
44 .long exception_entry + vector * 8 45 .long exception_entry + vector * 6
45vector = vector + 1 46vector = vector + 1
46 .endr 47 .endr
diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
index cc530f4d84d6..56e5878e5516 100644
--- a/arch/sh/kernel/cpu/sh2/setup-sh7619.c
+++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
@@ -96,8 +96,32 @@ static struct platform_device sci_device = {
96 }, 96 },
97}; 97};
98 98
99static struct resource eth_resources[] = {
100 [0] = {
101 .start = 0xfb000000,
102 .end = 0xfb0001c8,
103 .flags = IORESOURCE_MEM,
104 },
105 [1] = {
106 .start = 85,
107 .end = 85,
108 .flags = IORESOURCE_IRQ,
109 },
110};
111
112static struct platform_device eth_device = {
113 .name = "sh-eth",
114 .id = -1,
115 .dev = {
116 .platform_data = (void *)1,
117 },
118 .num_resources = ARRAY_SIZE(eth_resources),
119 .resource = eth_resources,
120};
121
99static struct platform_device *sh7619_devices[] __initdata = { 122static struct platform_device *sh7619_devices[] __initdata = {
100 &sci_device, 123 &sci_device,
124 &eth_device,
101}; 125};
102 126
103static int __init sh7619_devices_setup(void) 127static int __init sh7619_devices_setup(void)
diff --git a/arch/sh/kernel/cpu/sh2a/Makefile b/arch/sh/kernel/cpu/sh2a/Makefile
index 7e2b90cfa7bf..1ab1ecf4c768 100644
--- a/arch/sh/kernel/cpu/sh2a/Makefile
+++ b/arch/sh/kernel/cpu/sh2a/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-y := common.o probe.o opcode_helper.o 5obj-y := common.o probe.o opcode_helper.o
6 6
7common-y += $(addprefix ../sh2/, ex.o entry.o) 7common-y += ex.o entry.o
8 8
9obj-$(CONFIG_SH_FPU) += fpu.o 9obj-$(CONFIG_SH_FPU) += fpu.o
10 10
diff --git a/arch/sh/kernel/cpu/sh2a/entry.S b/arch/sh/kernel/cpu/sh2a/entry.S
new file mode 100644
index 000000000000..47096dc3d206
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/entry.S
@@ -0,0 +1,249 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/entry.S
3 *
4 * The SH-2A exception entry
5 *
6 * Copyright (C) 2008 Yoshinori Sato
7 * Based on arch/sh/kernel/cpu/sh2/entry.S
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <linux/linkage.h>
15#include <asm/asm-offsets.h>
16#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/unistd.h>
19#include <asm/errno.h>
20#include <asm/page.h>
21
22/* Offsets to the stack */
23OFF_R0 = 0 /* Return value. New ABI also arg4 */
24OFF_R1 = 4 /* New ABI: arg5 */
25OFF_R2 = 8 /* New ABI: arg6 */
26OFF_R3 = 12 /* New ABI: syscall_nr */
27OFF_R4 = 16 /* New ABI: arg0 */
28OFF_R5 = 20 /* New ABI: arg1 */
29OFF_R6 = 24 /* New ABI: arg2 */
30OFF_R7 = 28 /* New ABI: arg3 */
31OFF_SP = (15*4)
32OFF_PC = (16*4)
33OFF_SR = (16*4+2*4)
34OFF_TRA = (16*4+6*4)
35
36#include <asm/entry-macros.S>
37
38ENTRY(exception_handler)
39 ! stack
40 ! r0 <- point sp
41 ! r1
42 ! pc
43 ! sr
44 ! r0 = temporary
45 ! r1 = vector (pseudo EXPEVT / INTEVT / TRA)
46 mov.l r2,@-sp
47 cli
48 mov.l $cpu_mode,r2
49 bld.b #6,@(0,r2) !previus SR.MD
50 bst.b #6,@(4*4,r15) !set cpu mode to SR.MD
51 bt 1f
52 ! switch to kernel mode
53 bset.b #6,@(0,r2) !set SR.MD
54 mov.l $current_thread_info,r2
55 mov.l @r2,r2
56 mov #(THREAD_SIZE >> 8),r0
57 shll8 r0
58 add r2,r0 ! r0 = kernel stack tail
59 mov r15,r2 ! r2 = user stack top
60 mov r0,r15 ! switch kernel stack
61 mov.l r1,@-r15 ! TRA
62 sts.l macl, @-r15
63 sts.l mach, @-r15
64 stc.l gbr, @-r15
65 mov.l @(4*4,r2),r0
66 mov.l r0,@-r15 ! original SR
67 sts.l pr,@-r15
68 mov.l @(3*4,r2),r0
69 mov.l r0,@-r15 ! original PC
70 mov r2,r0
71 add #(3+2)*4,r0 ! rewind r0 - r3 + exception frame
72 lds r0,pr ! pr = original SP
73 movmu.l r3,@-r15 ! save regs
74 mov r2,r8 ! r8 = previus stack top
75 mov r1,r9 ! r9 = interrupt vector
76 ! restore previous stack
77 mov.l @r8+,r2
78 mov.l @r8+,r0
79 mov.l @r8+,r1
80 bra 2f
81 movml.l r2,@-r15
821:
83 ! in kernel exception
84 mov r15,r2
85 add #-((OFF_TRA + 4) - OFF_PC) + 5*4,r15
86 movmu.l r3,@-r15
87 mov r2,r8 ! r8 = previous stack top
88 mov r1,r9 ! r9 = interrupt vector
89 ! restore exception frame & regs
90 mov.l @r8+,r2 ! old R2
91 mov.l @r8+,r0 ! old R0
92 mov.l @r8+,r1 ! old R1
93 mov.l @r8+,r10 ! old PC
94 mov.l @r8+,r11 ! old SR
95 movml.l r2,@-r15
96 mov.l r10,@(OFF_PC,r15)
97 mov.l r11,@(OFF_SR,r15)
98 mov.l r8,@(OFF_SP,r15) ! save old sp
99 mov r15,r8
100 add #OFF_TRA + 4,r8
101 mov.l r9,@-r8
102 sts.l macl,@-r8
103 sts.l mach,@-r8
104 stc.l gbr,@-r8
105 add #-4,r8
106 sts.l pr,@-r8
1072:
108 ! dispatch exception / interrupt
109 mov #64,r8
110 cmp/hs r8,r9
111 bt interrupt_entry ! vec >= 64 is interrupt
112 mov #32,r8
113 cmp/hs r8,r9
114 bt trap_entry ! 64 > vec >= 32 is trap
115
116 mov.l 4f,r8
117 mov r9,r4
118 shll2 r9
119 add r9,r8
120 mov.l @r8,r8 ! exception handler address
121 tst r8,r8
122 bf 3f
123 mov.l 8f,r8 ! unhandled exception
1243:
125 mov.l 5f,r10
126 jmp @r8
127 lds r10,pr
128
129interrupt_entry:
130 mov r9,r4
131 mov r15,r5
132 mov.l 7f,r8
133 mov.l 6f,r9
134 jmp @r8
135 lds r9,pr
136
137 .align 2
1384: .long exception_handling_table
1395: .long ret_from_exception
1406: .long ret_from_irq
1417: .long do_IRQ
1428: .long exception_error
143
144trap_entry:
145 mov #0x30,r8
146 cmp/ge r8,r9 ! vector 0x20-0x2f is systemcall
147 bt 1f
148 add #-0x10,r9 ! convert SH2 to SH3/4 ABI
1491:
150 shll2 r9 ! TRA
151 bra system_call ! jump common systemcall entry
152 mov r9,r8
153
154#if defined(CONFIG_SH_STANDARD_BIOS)
155 /* Unwind the stack and jmp to the debug entry */
156ENTRY(sh_bios_handler)
157 mov r15,r0
158 add #(22-4)*4-4,r0
159 ldc.l @r0+,gbr
160 lds.l @r0+,mach
161 lds.l @r0+,macl
162 mov r15,r0
163 mov.l @(OFF_SP,r0),r1
164 mov.l @(OFF_SR,r2),r3
165 mov.l r3,@-r1
166 mov.l @(OFF_SP,r2),r3
167 mov.l r3,@-r1
168 mov r15,r0
169 add #(22-4)*4-8,r0
170 mov.l 1f,r2
171 mov.l @r2,r2
172 stc sr,r3
173 mov.l r2,@r0
174 mov.l r3,@(4,r0)
175 mov.l r1,@(8,r0)
176 movml.l @r15+,r14
177 add #8,r15
178 lds.l @r15+, pr
179 rte
180 mov.l @r15+,r15
181 .align 2
1821: .long gdb_vbr_vector
183#endif /* CONFIG_SH_STANDARD_BIOS */
184
185ENTRY(address_error_trap_handler)
186 mov r15,r4 ! regs
187 mov.l @(OFF_PC,r15),r6 ! pc
188 mov.l 1f,r0
189 jmp @r0
190 mov #0,r5 ! writeaccess is unknown
191
192 .align 2
1931: .long do_address_error
194
195restore_all:
196 stc sr,r0
197 or #0xf0,r0
198 ldc r0,sr ! all interrupt block (same BL = 1)
199 ! restore special register
200 ! overlap exception frame
201 mov r15,r0
202 add #17*4,r0
203 lds.l @r0+,pr
204 add #4,r0
205 ldc.l @r0+,gbr
206 lds.l @r0+,mach
207 lds.l @r0+,macl
208 mov r15,r0
209 mov.l $cpu_mode,r2
210 bld.b #6,@(OFF_SR,r15)
211 bst.b #6,@(0,r2) ! save CPU mode
212 mov.l @(OFF_SR,r0),r1
213 shll2 r1
214 shlr2 r1 ! clear MD bit
215 mov.l @(OFF_SP,r0),r2
216 add #-8,r2
217 mov.l r2,@(OFF_SP,r0) ! point exception frame top
218 mov.l r1,@(4,r2) ! set sr
219 mov.l @(OFF_PC,r0),r1
220 mov.l r1,@r2 ! set pc
221 get_current_thread_info r0, r1
222 mov.l $current_thread_info,r1
223 mov.l r0,@r1
224 movml.l @r15+,r14
225 mov.l @r15,r15
226 rte
227 nop
228
229 .align 2
230$current_thread_info:
231 .long __current_thread_info
232$cpu_mode:
233 .long __cpu_mode
234
235! common exception handler
236#include "../../entry-common.S"
237
238 .data
239! cpu operation mode
240! bit30 = MD (compatible SH3/4)
241__cpu_mode:
242 .long 0x40000000
243
244 .section .bss
245__current_thread_info:
246 .long 0
247
248ENTRY(exception_handling_table)
249 .space 4*32
diff --git a/arch/sh/kernel/cpu/sh2a/ex.S b/arch/sh/kernel/cpu/sh2a/ex.S
new file mode 100644
index 000000000000..3ead9e63965a
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/ex.S
@@ -0,0 +1,72 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/ex.S
3 *
4 * The SH-2A exception vector table
5 *
6 * Copyright (C) 2008 Yoshinori Sato
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/linkage.h>
14
15!
16! convert Exception Vector to Exception Number
17!
18
19! exception no 0 to 255
20exception_entry0:
21no = 0
22 .rept 256
23 mov.l r1,@-sp
24 bra exception_trampoline0
25 mov #no,r1
26no = no + 1
27 .endr
28exception_trampoline0:
29 mov.l r0,@-sp
30 mov.l 1f,r0
31 extu.b r1,r1
32 jmp @r0
33 extu.w r1,r1
34
35 .align 2
361: .long exception_handler
37
38! exception no 256 to 511
39exception_entry1:
40no = 0
41 .rept 256
42 mov.l r1,@-sp
43 bra exception_trampoline1
44 mov #no,r1
45no = no + 1
46 .endr
47exception_trampoline1:
48 mov.l r0,@-sp
49 extu.b r1,r1
50 movi20 #0x100,r0
51 add r0,r1
52 mov.l 1f,r0
53 jmp @r0
54 extu.w r1,r1
55
56 .align 2
571: .long exception_handler
58
59 !
60! Exception Vector Base
61!
62 .align 2
63ENTRY(vbr_base)
64vector = 0
65 .rept 256
66 .long exception_entry0 + vector * 6
67vector = vector + 1
68 .endr
69 .rept 256
70 .long exception_entry1 + vector * 6
71vector = vector + 1
72 .endr
diff --git a/arch/sh/kernel/cpu/sh3/ex.S b/arch/sh/kernel/cpu/sh3/ex.S
index 11b6d9c6edae..dac429726899 100644
--- a/arch/sh/kernel/cpu/sh3/ex.S
+++ b/arch/sh/kernel/cpu/sh3/ex.S
@@ -4,7 +4,7 @@
4 * The SH-3 and SH-4 exception vector table. 4 * The SH-3 and SH-4 exception vector table.
5 5
6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
7 * Copyright (C) 2003 - 2006 Paul Mundt 7 * Copyright (C) 2003 - 2008 Paul Mundt
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -12,13 +12,30 @@
12 */ 12 */
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14 14
15#if !defined(CONFIG_MMU)
16#define tlb_miss_load exception_error
17#define tlb_miss_store exception_error
18#define initial_page_write exception_error
19#define tlb_protection_violation_load exception_error
20#define tlb_protection_violation_store exception_error
21#define address_error_load exception_error
22#define address_error_store exception_error
23#endif
24
25#if !defined(CONFIG_SH_FPU)
26#define fpu_error_trap_handler exception_error
27#endif
28
29#if !defined(CONFIG_KGDB_NMI)
30#define kgdb_handle_exception exception_error
31#endif
32
15 .align 2 33 .align 2
16 .data 34 .data
17 35
18ENTRY(exception_handling_table) 36ENTRY(exception_handling_table)
19 .long exception_error /* 000 */ 37 .long exception_error /* 000 */
20 .long exception_error 38 .long exception_error
21#if defined(CONFIG_MMU)
22 .long tlb_miss_load /* 040 */ 39 .long tlb_miss_load /* 040 */
23 .long tlb_miss_store 40 .long tlb_miss_store
24 .long initial_page_write 41 .long initial_page_write
@@ -26,30 +43,13 @@ ENTRY(exception_handling_table)
26 .long tlb_protection_violation_store 43 .long tlb_protection_violation_store
27 .long address_error_load 44 .long address_error_load
28 .long address_error_store /* 100 */ 45 .long address_error_store /* 100 */
29#else
30 .long exception_error ! tlb miss load /* 040 */
31 .long exception_error ! tlb miss store
32 .long exception_error ! initial page write
33 .long exception_error ! tlb prot violation load
34 .long exception_error ! tlb prot violation store
35 .long exception_error ! address error load
36 .long exception_error ! address error store /* 100 */
37#endif
38#if defined(CONFIG_SH_FPU)
39 .long fpu_error_trap_handler /* 120 */ 46 .long fpu_error_trap_handler /* 120 */
40#else
41 .long exception_error /* 120 */
42#endif
43 .long exception_error /* 140 */ 47 .long exception_error /* 140 */
44 .long system_call ! Unconditional Trap /* 160 */ 48 .long system_call ! Unconditional Trap /* 160 */
45 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */ 49 .long exception_error ! reserved_instruction (filled by trap_init) /* 180 */
46 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/ 50 .long exception_error ! illegal_slot_instruction (filled by trap_init) /*1A0*/
47ENTRY(nmi_slot) 51ENTRY(nmi_slot)
48#if defined (CONFIG_KGDB_NMI)
49 .long kgdb_handle_exception /* 1C0 */ ! Allow trap to debugger 52 .long kgdb_handle_exception /* 1C0 */ ! Allow trap to debugger
50#else
51 .long exception_none /* 1C0 */ ! Not implemented yet
52#endif
53ENTRY(user_break_point_trap) 53ENTRY(user_break_point_trap)
54 .long break_point_trap /* 1E0 */ 54 .long break_point_trap /* 1E0 */
55 55
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index be4926969181..2e42572b1b11 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -50,14 +50,18 @@ int __init detect_cpu_and_cache_system(void)
50 boot_cpu_data.dcache.ways = 1; 50 boot_cpu_data.dcache.ways = 1;
51 boot_cpu_data.dcache.linesz = L1_CACHE_BYTES; 51 boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
52 52
53 /* We don't know the chip cut */
54 boot_cpu_data.cut_major = boot_cpu_data.cut_minor = -1;
55
53 /* 56 /*
54 * Setup some generic flags we can probe on SH-4A parts 57 * Setup some generic flags we can probe on SH-4A parts
55 */ 58 */
56 if (((pvr >> 24) & 0xff) == 0x10) { 59 if (((pvr >> 16) & 0xff) == 0x10) {
57 if ((cvr & 0x10000000) == 0) 60 if ((cvr & 0x10000000) == 0)
58 boot_cpu_data.flags |= CPU_HAS_DSP; 61 boot_cpu_data.flags |= CPU_HAS_DSP;
59 62
60 boot_cpu_data.flags |= CPU_HAS_LLSC; 63 boot_cpu_data.flags |= CPU_HAS_LLSC;
64 boot_cpu_data.cut_major = pvr & 0x7f;
61 } 65 }
62 66
63 /* FPU detection works for everyone */ 67 /* FPU detection works for everyone */
diff --git a/arch/sh/kernel/cpu/sh4a/Makefile b/arch/sh/kernel/cpu/sh4a/Makefile
index a880e7968750..9381ad8da263 100644
--- a/arch/sh/kernel/cpu/sh4a/Makefile
+++ b/arch/sh/kernel/cpu/sh4a/Makefile
@@ -21,7 +21,7 @@ clock-$(CONFIG_CPU_SUBTYPE_SH7763) := clock-sh7763.o
21clock-$(CONFIG_CPU_SUBTYPE_SH7770) := clock-sh7770.o 21clock-$(CONFIG_CPU_SUBTYPE_SH7770) := clock-sh7770.o
22clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o 22clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o
23clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o 23clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o
24clock-$(CONFIG_CPU_SUBTYPE_SH7343) := clock-sh7343.o 24clock-$(CONFIG_CPU_SUBTYPE_SH7343) := clock-sh7722.o
25clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o 25clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o
26clock-$(CONFIG_CPU_SUBTYPE_SH7723) := clock-sh7722.o 26clock-$(CONFIG_CPU_SUBTYPE_SH7723) := clock-sh7722.o
27clock-$(CONFIG_CPU_SUBTYPE_SH7366) := clock-sh7722.o 27clock-$(CONFIG_CPU_SUBTYPE_SH7366) := clock-sh7722.o
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
deleted file mode 100644
index 7adc4f16e95a..000000000000
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7343.c
3 *
4 * SH7343/SH7722 support for the clock framework
5 *
6 * Copyright (C) 2006 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/io.h>
15#include <asm/clock.h>
16#include <asm/freq.h>
17
18/*
19 * SH7343/SH7722 uses a common set of multipliers and divisors, so this
20 * is quite simple..
21 */
22static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
23static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
24
25#define pll_calc() (((ctrl_inl(FRQCR) >> 24) & 0x1f) + 1)
26
27static void master_clk_init(struct clk *clk)
28{
29 clk->parent = clk_get(NULL, "cpu_clk");
30}
31
32static void master_clk_recalc(struct clk *clk)
33{
34 int idx = (ctrl_inl(FRQCR) & 0x000f);
35 clk->rate *= clk->parent->rate * multipliers[idx] / divisors[idx];
36}
37
38static struct clk_ops sh7343_master_clk_ops = {
39 .init = master_clk_init,
40 .recalc = master_clk_recalc,
41};
42
43static void module_clk_init(struct clk *clk)
44{
45 clk->parent = NULL;
46 clk->rate = CONFIG_SH_PCLK_FREQ;
47}
48
49static struct clk_ops sh7343_module_clk_ops = {
50 .init = module_clk_init,
51};
52
53static void bus_clk_init(struct clk *clk)
54{
55 clk->parent = clk_get(NULL, "cpu_clk");
56}
57
58static void bus_clk_recalc(struct clk *clk)
59{
60 int idx = (ctrl_inl(FRQCR) >> 8) & 0x000f;
61 clk->rate = clk->parent->rate * multipliers[idx] / divisors[idx];
62}
63
64static struct clk_ops sh7343_bus_clk_ops = {
65 .init = bus_clk_init,
66 .recalc = bus_clk_recalc,
67};
68
69static void cpu_clk_init(struct clk *clk)
70{
71 clk->parent = clk_get(NULL, "module_clk");
72 clk->flags |= CLK_RATE_PROPAGATES;
73 clk_set_rate(clk, clk_get_rate(clk));
74}
75
76static void cpu_clk_recalc(struct clk *clk)
77{
78 int idx = (ctrl_inl(FRQCR) >> 20) & 0x000f;
79 clk->rate = clk->parent->rate * pll_calc() *
80 multipliers[idx] / divisors[idx];
81}
82
83static struct clk_ops sh7343_cpu_clk_ops = {
84 .init = cpu_clk_init,
85 .recalc = cpu_clk_recalc,
86};
87
88static struct clk_ops *sh7343_clk_ops[] = {
89 &sh7343_master_clk_ops,
90 &sh7343_module_clk_ops,
91 &sh7343_bus_clk_ops,
92 &sh7343_cpu_clk_ops,
93};
94
95void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
96{
97 if (idx < ARRAY_SIZE(sh7343_clk_ops))
98 *ops = sh7343_clk_ops[idx];
99}
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 299138ebe160..db913855c2fd 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c 2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c
3 * 3 *
4 * SH7722 & SH7366 support for the clock framework 4 * SH7343, SH7722, SH7723 & SH7366 support for the clock framework
5 * 5 *
6 * Copyright (c) 2006-2007 Nomad Global Solutions Inc 6 * Copyright (c) 2006-2007 Nomad Global Solutions Inc
7 * Based on code for sh7343 by Paul Mundt 7 * Based on code for sh7343 by Paul Mundt
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/stringify.h>
17#include <asm/clock.h> 18#include <asm/clock.h>
18#include <asm/freq.h> 19#include <asm/freq.h>
19 20
@@ -411,40 +412,40 @@ static struct clk_ops sh7722_frqcr_clk_ops = {
411 * clock ops methods for SIU A/B and IrDA clock 412 * clock ops methods for SIU A/B and IrDA clock
412 * 413 *
413 */ 414 */
414static int sh7722_siu_which(struct clk *clk) 415
416#ifndef CONFIG_CPU_SUBTYPE_SH7343
417
418static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
415{ 419{
416 if (!strcmp(clk->name, "siu_a_clk")) 420 unsigned long r;
417 return 0; 421 int div;
418 if (!strcmp(clk->name, "siu_b_clk")) 422
419 return 1; 423 r = ctrl_inl(clk->arch_flags);
420#if defined(CONFIG_CPU_SUBTYPE_SH7722) 424 div = sh7722_find_divisors(clk->parent->rate, rate);
421 if (!strcmp(clk->name, "irda_clk")) 425 if (div < 0)
422 return 2; 426 return div;
423#endif 427 r = (r & ~0xF) | div;
424 return -EINVAL; 428 ctrl_outl(r, clk->arch_flags);
429 return 0;
425} 430}
426 431
427static unsigned long sh7722_siu_regs[] = { 432static void sh7722_siu_recalc(struct clk *clk)
428 [0] = SCLKACR, 433{
429 [1] = SCLKBCR, 434 unsigned long r;
430#if defined(CONFIG_CPU_SUBTYPE_SH7722) 435
431 [2] = IrDACLKCR, 436 r = ctrl_inl(clk->arch_flags);
432#endif 437 clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF];
433}; 438}
434 439
435static int sh7722_siu_start_stop(struct clk *clk, int enable) 440static int sh7722_siu_start_stop(struct clk *clk, int enable)
436{ 441{
437 int siu = sh7722_siu_which(clk);
438 unsigned long r; 442 unsigned long r;
439 443
440 if (siu < 0) 444 r = ctrl_inl(clk->arch_flags);
441 return siu;
442 BUG_ON(siu > 2);
443 r = ctrl_inl(sh7722_siu_regs[siu]);
444 if (enable) 445 if (enable)
445 ctrl_outl(r & ~(1 << 8), sh7722_siu_regs[siu]); 446 ctrl_outl(r & ~(1 << 8), clk->arch_flags);
446 else 447 else
447 ctrl_outl(r | (1 << 8), sh7722_siu_regs[siu]); 448 ctrl_outl(r | (1 << 8), clk->arch_flags);
448 return 0; 449 return 0;
449} 450}
450 451
@@ -458,6 +459,15 @@ static void sh7722_siu_disable(struct clk *clk)
458 sh7722_siu_start_stop(clk, 0); 459 sh7722_siu_start_stop(clk, 0);
459} 460}
460 461
462static struct clk_ops sh7722_siu_clk_ops = {
463 .recalc = sh7722_siu_recalc,
464 .set_rate = sh7722_siu_set_rate,
465 .enable = sh7722_siu_enable,
466 .disable = sh7722_siu_disable,
467};
468
469#endif /* CONFIG_CPU_SUBTYPE_SH7343 */
470
461static void sh7722_video_enable(struct clk *clk) 471static void sh7722_video_enable(struct clk *clk)
462{ 472{
463 unsigned long r; 473 unsigned long r;
@@ -494,43 +504,6 @@ static void sh7722_video_recalc(struct clk *clk)
494 clk->rate = clk->parent->rate / ((r & 0x3F) + 1); 504 clk->rate = clk->parent->rate / ((r & 0x3F) + 1);
495} 505}
496 506
497static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
498{
499 int siu = sh7722_siu_which(clk);
500 unsigned long r;
501 int div;
502
503 if (siu < 0)
504 return siu;
505 BUG_ON(siu > 2);
506 r = ctrl_inl(sh7722_siu_regs[siu]);
507 div = sh7722_find_divisors(clk->parent->rate, rate);
508 if (div < 0)
509 return div;
510 r = (r & ~0xF) | div;
511 ctrl_outl(r, sh7722_siu_regs[siu]);
512 return 0;
513}
514
515static void sh7722_siu_recalc(struct clk *clk)
516{
517 int siu = sh7722_siu_which(clk);
518 unsigned long r;
519
520 if (siu < 0)
521 return /* siu */ ;
522 BUG_ON(siu > 2);
523 r = ctrl_inl(sh7722_siu_regs[siu]);
524 clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF];
525}
526
527static struct clk_ops sh7722_siu_clk_ops = {
528 .recalc = sh7722_siu_recalc,
529 .set_rate = sh7722_siu_set_rate,
530 .enable = sh7722_siu_enable,
531 .disable = sh7722_siu_disable,
532};
533
534static struct clk_ops sh7722_video_clk_ops = { 507static struct clk_ops sh7722_video_clk_ops = {
535 .recalc = sh7722_video_recalc, 508 .recalc = sh7722_video_recalc,
536 .set_rate = sh7722_video_set_rate, 509 .set_rate = sh7722_video_set_rate,
@@ -560,6 +533,9 @@ static struct clk sh7722_sdram_clock = {
560 .ops = &sh7722_frqcr_clk_ops, 533 .ops = &sh7722_frqcr_clk_ops,
561}; 534};
562 535
536
537#ifndef CONFIG_CPU_SUBTYPE_SH7343
538
563/* 539/*
564 * these three clocks - SIU A, SIU B, IrDA - share the same clk_ops 540 * these three clocks - SIU A, SIU B, IrDA - share the same clk_ops
565 * methods of clk_ops determine which register they should access by 541 * methods of clk_ops determine which register they should access by
@@ -567,36 +543,151 @@ static struct clk sh7722_sdram_clock = {
567 */ 543 */
568static struct clk sh7722_siu_a_clock = { 544static struct clk sh7722_siu_a_clock = {
569 .name = "siu_a_clk", 545 .name = "siu_a_clk",
546 .arch_flags = SCLKACR,
570 .ops = &sh7722_siu_clk_ops, 547 .ops = &sh7722_siu_clk_ops,
571}; 548};
572 549
573static struct clk sh7722_siu_b_clock = { 550static struct clk sh7722_siu_b_clock = {
574 .name = "siu_b_clk", 551 .name = "siu_b_clk",
552 .arch_flags = SCLKBCR,
575 .ops = &sh7722_siu_clk_ops, 553 .ops = &sh7722_siu_clk_ops,
576}; 554};
577 555
578#if defined(CONFIG_CPU_SUBTYPE_SH7722) 556#if defined(CONFIG_CPU_SUBTYPE_SH7722)
579static struct clk sh7722_irda_clock = { 557static struct clk sh7722_irda_clock = {
580 .name = "irda_clk", 558 .name = "irda_clk",
559 .arch_flags = IrDACLKCR,
581 .ops = &sh7722_siu_clk_ops, 560 .ops = &sh7722_siu_clk_ops,
582}; 561};
583#endif 562#endif
563#endif /* CONFIG_CPU_SUBTYPE_SH7343 */
584 564
585static struct clk sh7722_video_clock = { 565static struct clk sh7722_video_clock = {
586 .name = "video_clk", 566 .name = "video_clk",
587 .ops = &sh7722_video_clk_ops, 567 .ops = &sh7722_video_clk_ops,
588}; 568};
589 569
570static int sh7722_mstpcr_start_stop(struct clk *clk, unsigned long reg,
571 int enable)
572{
573 unsigned long bit = clk->arch_flags;
574 unsigned long r;
575
576 r = ctrl_inl(reg);
577
578 if (enable)
579 r &= ~(1 << bit);
580 else
581 r |= (1 << bit);
582
583 ctrl_outl(r, reg);
584 return 0;
585}
586
587static void sh7722_mstpcr0_enable(struct clk *clk)
588{
589 sh7722_mstpcr_start_stop(clk, MSTPCR0, 1);
590}
591
592static void sh7722_mstpcr0_disable(struct clk *clk)
593{
594 sh7722_mstpcr_start_stop(clk, MSTPCR0, 0);
595}
596
597static void sh7722_mstpcr1_enable(struct clk *clk)
598{
599 sh7722_mstpcr_start_stop(clk, MSTPCR1, 1);
600}
601
602static void sh7722_mstpcr1_disable(struct clk *clk)
603{
604 sh7722_mstpcr_start_stop(clk, MSTPCR1, 0);
605}
606
607static void sh7722_mstpcr2_enable(struct clk *clk)
608{
609 sh7722_mstpcr_start_stop(clk, MSTPCR2, 1);
610}
611
612static void sh7722_mstpcr2_disable(struct clk *clk)
613{
614 sh7722_mstpcr_start_stop(clk, MSTPCR2, 0);
615}
616
617static struct clk_ops sh7722_mstpcr0_clk_ops = {
618 .enable = sh7722_mstpcr0_enable,
619 .disable = sh7722_mstpcr0_disable,
620};
621
622static struct clk_ops sh7722_mstpcr1_clk_ops = {
623 .enable = sh7722_mstpcr1_enable,
624 .disable = sh7722_mstpcr1_disable,
625};
626
627static struct clk_ops sh7722_mstpcr2_clk_ops = {
628 .enable = sh7722_mstpcr2_enable,
629 .disable = sh7722_mstpcr2_disable,
630};
631
632#define DECLARE_MSTPCRN(regnr, bitnr, bitstr) \
633{ \
634 .name = "mstp" __stringify(regnr) bitstr, \
635 .arch_flags = bitnr, \
636 .ops = &sh7722_mstpcr ## regnr ## _clk_ops, \
637}
638
639#define DECLARE_MSTPCR(regnr) \
640 DECLARE_MSTPCRN(regnr, 31, "31"), \
641 DECLARE_MSTPCRN(regnr, 30, "30"), \
642 DECLARE_MSTPCRN(regnr, 29, "29"), \
643 DECLARE_MSTPCRN(regnr, 28, "28"), \
644 DECLARE_MSTPCRN(regnr, 27, "27"), \
645 DECLARE_MSTPCRN(regnr, 26, "26"), \
646 DECLARE_MSTPCRN(regnr, 25, "25"), \
647 DECLARE_MSTPCRN(regnr, 24, "24"), \
648 DECLARE_MSTPCRN(regnr, 23, "23"), \
649 DECLARE_MSTPCRN(regnr, 22, "22"), \
650 DECLARE_MSTPCRN(regnr, 21, "21"), \
651 DECLARE_MSTPCRN(regnr, 20, "20"), \
652 DECLARE_MSTPCRN(regnr, 19, "19"), \
653 DECLARE_MSTPCRN(regnr, 18, "18"), \
654 DECLARE_MSTPCRN(regnr, 17, "17"), \
655 DECLARE_MSTPCRN(regnr, 16, "16"), \
656 DECLARE_MSTPCRN(regnr, 15, "15"), \
657 DECLARE_MSTPCRN(regnr, 14, "14"), \
658 DECLARE_MSTPCRN(regnr, 13, "13"), \
659 DECLARE_MSTPCRN(regnr, 12, "12"), \
660 DECLARE_MSTPCRN(regnr, 11, "11"), \
661 DECLARE_MSTPCRN(regnr, 10, "10"), \
662 DECLARE_MSTPCRN(regnr, 9, "09"), \
663 DECLARE_MSTPCRN(regnr, 8, "08"), \
664 DECLARE_MSTPCRN(regnr, 7, "07"), \
665 DECLARE_MSTPCRN(regnr, 6, "06"), \
666 DECLARE_MSTPCRN(regnr, 5, "05"), \
667 DECLARE_MSTPCRN(regnr, 4, "04"), \
668 DECLARE_MSTPCRN(regnr, 3, "03"), \
669 DECLARE_MSTPCRN(regnr, 2, "02"), \
670 DECLARE_MSTPCRN(regnr, 1, "01"), \
671 DECLARE_MSTPCRN(regnr, 0, "00")
672
673static struct clk sh7722_mstpcr[] = {
674 DECLARE_MSTPCR(0),
675 DECLARE_MSTPCR(1),
676 DECLARE_MSTPCR(2),
677};
678
590static struct clk *sh7722_clocks[] = { 679static struct clk *sh7722_clocks[] = {
591 &sh7722_umem_clock, 680 &sh7722_umem_clock,
592 &sh7722_sh_clock, 681 &sh7722_sh_clock,
593 &sh7722_peripheral_clock, 682 &sh7722_peripheral_clock,
594 &sh7722_sdram_clock, 683 &sh7722_sdram_clock,
684#ifndef CONFIG_CPU_SUBTYPE_SH7343
595 &sh7722_siu_a_clock, 685 &sh7722_siu_a_clock,
596 &sh7722_siu_b_clock, 686 &sh7722_siu_b_clock,
597#if defined(CONFIG_CPU_SUBTYPE_SH7722) 687#if defined(CONFIG_CPU_SUBTYPE_SH7722)
598 &sh7722_irda_clock, 688 &sh7722_irda_clock,
599#endif 689#endif
690#endif
600 &sh7722_video_clock, 691 &sh7722_video_clock,
601}; 692};
602 693
@@ -629,5 +720,11 @@ int __init arch_clk_init(void)
629 clk_register(sh7722_clocks[i]); 720 clk_register(sh7722_clocks[i]);
630 } 721 }
631 clk_put(master); 722 clk_put(master);
723
724 for (i = 0; i < ARRAY_SIZE(sh7722_mstpcr); i++) {
725 pr_debug( "Registering mstpcr '%s'\n", sh7722_mstpcr[i].name);
726 clk_register(&sh7722_mstpcr[i]);
727 }
728
632 return 0; 729 return 0;
633} 730}
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
index 6d4f50cd4aaf..78881b4214da 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
@@ -11,6 +11,104 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h> 13#include <linux/serial_sci.h>
14#include <linux/uio_driver.h>
15#include <asm/clock.h>
16
17static struct resource iic0_resources[] = {
18 [0] = {
19 .name = "IIC0",
20 .start = 0x04470000,
21 .end = 0x04470017,
22 .flags = IORESOURCE_MEM,
23 },
24 [1] = {
25 .start = 96,
26 .end = 99,
27 .flags = IORESOURCE_IRQ,
28 },
29};
30
31static struct platform_device iic0_device = {
32 .name = "i2c-sh_mobile",
33 .num_resources = ARRAY_SIZE(iic0_resources),
34 .resource = iic0_resources,
35};
36
37static struct resource iic1_resources[] = {
38 [0] = {
39 .name = "IIC1",
40 .start = 0x04750000,
41 .end = 0x04750017,
42 .flags = IORESOURCE_MEM,
43 },
44 [1] = {
45 .start = 44,
46 .end = 47,
47 .flags = IORESOURCE_IRQ,
48 },
49};
50
51static struct platform_device iic1_device = {
52 .name = "i2c-sh_mobile",
53 .num_resources = ARRAY_SIZE(iic1_resources),
54 .resource = iic1_resources,
55};
56
57static struct uio_info vpu_platform_data = {
58 .name = "VPU4",
59 .version = "0",
60 .irq = 60,
61};
62
63static struct resource vpu_resources[] = {
64 [0] = {
65 .name = "VPU",
66 .start = 0xfe900000,
67 .end = 0xfe9022eb,
68 .flags = IORESOURCE_MEM,
69 },
70 [1] = {
71 /* place holder for contiguous memory */
72 },
73};
74
75static struct platform_device vpu_device = {
76 .name = "uio_pdrv_genirq",
77 .id = 0,
78 .dev = {
79 .platform_data = &vpu_platform_data,
80 },
81 .resource = vpu_resources,
82 .num_resources = ARRAY_SIZE(vpu_resources),
83};
84
85static struct uio_info veu_platform_data = {
86 .name = "VEU",
87 .version = "0",
88 .irq = 54,
89};
90
91static struct resource veu_resources[] = {
92 [0] = {
93 .name = "VEU",
94 .start = 0xfe920000,
95 .end = 0xfe9200b7,
96 .flags = IORESOURCE_MEM,
97 },
98 [1] = {
99 /* place holder for contiguous memory */
100 },
101};
102
103static struct platform_device veu_device = {
104 .name = "uio_pdrv_genirq",
105 .id = 1,
106 .dev = {
107 .platform_data = &veu_platform_data,
108 },
109 .resource = veu_resources,
110 .num_resources = ARRAY_SIZE(veu_resources),
111};
14 112
15static struct plat_sci_port sci_platform_data[] = { 113static struct plat_sci_port sci_platform_data[] = {
16 { 114 {
@@ -32,16 +130,171 @@ static struct platform_device sci_device = {
32}; 130};
33 131
34static struct platform_device *sh7343_devices[] __initdata = { 132static struct platform_device *sh7343_devices[] __initdata = {
133 &iic0_device,
134 &iic1_device,
35 &sci_device, 135 &sci_device,
136 &vpu_device,
137 &veu_device,
36}; 138};
37 139
38static int __init sh7343_devices_setup(void) 140static int __init sh7343_devices_setup(void)
39{ 141{
142 clk_always_enable("mstp031"); /* TLB */
143 clk_always_enable("mstp030"); /* IC */
144 clk_always_enable("mstp029"); /* OC */
145 clk_always_enable("mstp028"); /* URAM */
146 clk_always_enable("mstp026"); /* XYMEM */
147 clk_always_enable("mstp023"); /* INTC3 */
148 clk_always_enable("mstp022"); /* INTC */
149 clk_always_enable("mstp020"); /* SuperHyway */
150 clk_always_enable("mstp109"); /* I2C0 */
151 clk_always_enable("mstp108"); /* I2C1 */
152 clk_always_enable("mstp202"); /* VEU */
153 clk_always_enable("mstp201"); /* VPU */
154
155 platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20);
156 platform_resource_setup_memory(&veu_device, "veu", 2 << 20);
157
40 return platform_add_devices(sh7343_devices, 158 return platform_add_devices(sh7343_devices,
41 ARRAY_SIZE(sh7343_devices)); 159 ARRAY_SIZE(sh7343_devices));
42} 160}
43__initcall(sh7343_devices_setup); 161__initcall(sh7343_devices_setup);
44 162
163enum {
164 UNUSED = 0,
165
166 /* interrupt sources */
167 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
168 DMAC0, DMAC1, DMAC2, DMAC3,
169 VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU,
170 MFI, VPU, TPU, Z3D4, USBI0, USBI1,
171 MMC_ERR, MMC_TRAN, MMC_FSTAT, MMC_FRDY,
172 DMAC4, DMAC5, DMAC_DADERR,
173 KEYSC,
174 SCIF, SCIF1, SCIF2, SCIF3, SCIF4,
175 SIOF0, SIOF1, SIO,
176 FLCTL_FLSTEI, FLCTL_FLENDI, FLCTL_FLTREQ0I, FLCTL_FLTREQ1I,
177 I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI,
178 I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI,
179 SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI,
180 IRDA,
181 SDHI0, SDHI1, SDHI2, SDHI3,
182 CMT, TSIF, SIU,
183 TMU0, TMU1, TMU2,
184 JPU, LCDC,
185
186 /* interrupt groups */
187
188 DMAC0123, VIOVOU, MMC, DMAC45, FLCTL, I2C0, I2C1, SIM, SDHI, USB,
189};
190
191static struct intc_vect vectors[] __initdata = {
192 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
193 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
194 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
195 INTC_VECT(IRQ6, 0x6c0), INTC_VECT(IRQ7, 0x6e0),
196 INTC_VECT(I2C1_ALI, 0x780), INTC_VECT(I2C1_TACKI, 0x7a0),
197 INTC_VECT(I2C1_WAITI, 0x7c0), INTC_VECT(I2C1_DTEI, 0x7e0),
198 INTC_VECT(DMAC0, 0x800), INTC_VECT(DMAC1, 0x820),
199 INTC_VECT(DMAC2, 0x840), INTC_VECT(DMAC3, 0x860),
200 INTC_VECT(VIO_CEUI, 0x880), INTC_VECT(VIO_BEUI, 0x8a0),
201 INTC_VECT(VIO_VEUI, 0x8c0), INTC_VECT(VOU, 0x8e0),
202 INTC_VECT(MFI, 0x900), INTC_VECT(VPU, 0x980),
203 INTC_VECT(TPU, 0x9a0), INTC_VECT(Z3D4, 0x9e0),
204 INTC_VECT(USBI0, 0xa20), INTC_VECT(USBI1, 0xa40),
205 INTC_VECT(MMC_ERR, 0xb00), INTC_VECT(MMC_TRAN, 0xb20),
206 INTC_VECT(MMC_FSTAT, 0xb40), INTC_VECT(MMC_FRDY, 0xb60),
207 INTC_VECT(DMAC4, 0xb80), INTC_VECT(DMAC5, 0xba0),
208 INTC_VECT(DMAC_DADERR, 0xbc0), INTC_VECT(KEYSC, 0xbe0),
209 INTC_VECT(SCIF, 0xc00), INTC_VECT(SCIF1, 0xc20),
210 INTC_VECT(SCIF2, 0xc40), INTC_VECT(SCIF3, 0xc60),
211 INTC_VECT(SIOF0, 0xc80), INTC_VECT(SIOF1, 0xca0),
212 INTC_VECT(SIO, 0xd00),
213 INTC_VECT(FLCTL_FLSTEI, 0xd80), INTC_VECT(FLCTL_FLENDI, 0xda0),
214 INTC_VECT(FLCTL_FLTREQ0I, 0xdc0), INTC_VECT(FLCTL_FLTREQ1I, 0xde0),
215 INTC_VECT(I2C0_ALI, 0xe00), INTC_VECT(I2C0_TACKI, 0xe20),
216 INTC_VECT(I2C0_WAITI, 0xe40), INTC_VECT(I2C0_DTEI, 0xe60),
217 INTC_VECT(SDHI0, 0xe80), INTC_VECT(SDHI1, 0xea0),
218 INTC_VECT(SDHI2, 0xec0), INTC_VECT(SDHI3, 0xee0),
219 INTC_VECT(CMT, 0xf00), INTC_VECT(TSIF, 0xf20),
220 INTC_VECT(SIU, 0xf80),
221 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
222 INTC_VECT(TMU2, 0x440),
223 INTC_VECT(JPU, 0x560), INTC_VECT(LCDC, 0x580),
224};
225
226static struct intc_group groups[] __initdata = {
227 INTC_GROUP(DMAC0123, DMAC0, DMAC1, DMAC2, DMAC3),
228 INTC_GROUP(VIOVOU, VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU),
229 INTC_GROUP(MMC, MMC_FRDY, MMC_FSTAT, MMC_TRAN, MMC_ERR),
230 INTC_GROUP(DMAC45, DMAC4, DMAC5, DMAC_DADERR),
231 INTC_GROUP(FLCTL, FLCTL_FLSTEI, FLCTL_FLENDI,
232 FLCTL_FLTREQ0I, FLCTL_FLTREQ1I),
233 INTC_GROUP(I2C0, I2C0_ALI, I2C0_TACKI, I2C0_WAITI, I2C0_DTEI),
234 INTC_GROUP(I2C1, I2C1_ALI, I2C1_TACKI, I2C1_WAITI, I2C1_DTEI),
235 INTC_GROUP(SIM, SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI),
236 INTC_GROUP(SDHI, SDHI0, SDHI1, SDHI2, SDHI3),
237 INTC_GROUP(USB, USBI0, USBI1),
238};
239
240static struct intc_mask_reg mask_registers[] __initdata = {
241 { 0xa4080084, 0xa40800c4, 8, /* IMR1 / IMCR1 */
242 { VOU, VIO_VEUI, VIO_BEUI, VIO_CEUI, DMAC3, DMAC2, DMAC1, DMAC0 } },
243 { 0xa4080088, 0xa40800c8, 8, /* IMR2 / IMCR2 */
244 { 0, 0, 0, VPU, 0, 0, 0, MFI } },
245 { 0xa408008c, 0xa40800cc, 8, /* IMR3 / IMCR3 */
246 { SIM_TEI, SIM_TXI, SIM_RXI, SIM_ERI, 0, 0, 0, IRDA } },
247 { 0xa4080090, 0xa40800d0, 8, /* IMR4 / IMCR4 */
248 { 0, TMU2, TMU1, TMU0, JPU, 0, 0, LCDC } },
249 { 0xa4080094, 0xa40800d4, 8, /* IMR5 / IMCR5 */
250 { KEYSC, DMAC_DADERR, DMAC5, DMAC4, SCIF3, SCIF2, SCIF1, SCIF } },
251 { 0xa4080098, 0xa40800d8, 8, /* IMR6 / IMCR6 */
252 { 0, 0, 0, SIO, Z3D4, 0, SIOF1, SIOF0 } },
253 { 0xa408009c, 0xa40800dc, 8, /* IMR7 / IMCR7 */
254 { I2C0_DTEI, I2C0_WAITI, I2C0_TACKI, I2C0_ALI,
255 FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } },
256 { 0xa40800a0, 0xa40800e0, 8, /* IMR8 / IMCR8 */
257 { SDHI3, SDHI2, SDHI1, SDHI0, 0, 0, 0, SIU } },
258 { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */
259 { 0, 0, 0, CMT, 0, USBI1, USBI0 } },
260 { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
261 { MMC_FRDY, MMC_FSTAT, MMC_TRAN, MMC_ERR } },
262 { 0xa40800ac, 0xa40800ec, 8, /* IMR11 / IMCR11 */
263 { I2C1_DTEI, I2C1_WAITI, I2C1_TACKI, I2C1_ALI, TPU, 0, 0, TSIF } },
264 { 0xa4140044, 0xa4140064, 8, /* INTMSK00 / INTMSKCLR00 */
265 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
266};
267
268static struct intc_prio_reg prio_registers[] __initdata = {
269 { 0xa4080000, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2 } },
270 { 0xa4080004, 0, 16, 4, /* IPRB */ { JPU, LCDC, SIM } },
271 { 0xa4080010, 0, 16, 4, /* IPRE */ { DMAC0123, VIOVOU, MFI, VPU } },
272 { 0xa4080014, 0, 16, 4, /* IPRF */ { KEYSC, DMAC45, USB, CMT } },
273 { 0xa4080018, 0, 16, 4, /* IPRG */ { SCIF, SCIF1, SCIF2, SCIF3 } },
274 { 0xa408001c, 0, 16, 4, /* IPRH */ { SIOF0, SIOF1, FLCTL, I2C0 } },
275 { 0xa4080020, 0, 16, 4, /* IPRI */ { SIO, 0, TSIF, I2C1 } },
276 { 0xa4080024, 0, 16, 4, /* IPRJ */ { Z3D4, 0, SIU } },
277 { 0xa4080028, 0, 16, 4, /* IPRK */ { 0, MMC, 0, SDHI } },
278 { 0xa408002c, 0, 16, 4, /* IPRL */ { 0, 0, TPU } },
279 { 0xa4140010, 0, 32, 4, /* INTPRI00 */
280 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
281};
282
283static struct intc_sense_reg sense_registers[] __initdata = {
284 { 0xa414001c, 16, 2, /* ICR1 */
285 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
286};
287
288static struct intc_mask_reg ack_registers[] __initdata = {
289 { 0xa4140024, 0, 8, /* INTREQ00 */
290 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
291};
292
293static DECLARE_INTC_DESC_ACK(intc_desc, "sh7343", vectors, groups,
294 mask_registers, prio_registers, sense_registers,
295 ack_registers);
296
45void __init plat_irq_setup(void) 297void __init plat_irq_setup(void)
46{ 298{
299 register_intc_controller(&intc_desc);
47} 300}
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
index f26b5cdad0d1..6851dba02f31 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
@@ -13,6 +13,112 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <linux/serial_sci.h> 15#include <linux/serial_sci.h>
16#include <linux/uio_driver.h>
17#include <asm/clock.h>
18
19static struct resource iic_resources[] = {
20 [0] = {
21 .name = "IIC",
22 .start = 0x04470000,
23 .end = 0x04470017,
24 .flags = IORESOURCE_MEM,
25 },
26 [1] = {
27 .start = 96,
28 .end = 99,
29 .flags = IORESOURCE_IRQ,
30 },
31};
32
33static struct platform_device iic_device = {
34 .name = "i2c-sh_mobile",
35 .num_resources = ARRAY_SIZE(iic_resources),
36 .resource = iic_resources,
37};
38
39static struct uio_info vpu_platform_data = {
40 .name = "VPU5",
41 .version = "0",
42 .irq = 60,
43};
44
45static struct resource vpu_resources[] = {
46 [0] = {
47 .name = "VPU",
48 .start = 0xfe900000,
49 .end = 0xfe902807,
50 .flags = IORESOURCE_MEM,
51 },
52 [1] = {
53 /* place holder for contiguous memory */
54 },
55};
56
57static struct platform_device vpu_device = {
58 .name = "uio_pdrv_genirq",
59 .id = 0,
60 .dev = {
61 .platform_data = &vpu_platform_data,
62 },
63 .resource = vpu_resources,
64 .num_resources = ARRAY_SIZE(vpu_resources),
65};
66
67static struct uio_info veu0_platform_data = {
68 .name = "VEU",
69 .version = "0",
70 .irq = 54,
71};
72
73static struct resource veu0_resources[] = {
74 [0] = {
75 .name = "VEU(1)",
76 .start = 0xfe920000,
77 .end = 0xfe9200b7,
78 .flags = IORESOURCE_MEM,
79 },
80 [1] = {
81 /* place holder for contiguous memory */
82 },
83};
84
85static struct platform_device veu0_device = {
86 .name = "uio_pdrv_genirq",
87 .id = 1,
88 .dev = {
89 .platform_data = &veu0_platform_data,
90 },
91 .resource = veu0_resources,
92 .num_resources = ARRAY_SIZE(veu0_resources),
93};
94
95static struct uio_info veu1_platform_data = {
96 .name = "VEU",
97 .version = "0",
98 .irq = 27,
99};
100
101static struct resource veu1_resources[] = {
102 [0] = {
103 .name = "VEU(2)",
104 .start = 0xfe924000,
105 .end = 0xfe9240b7,
106 .flags = IORESOURCE_MEM,
107 },
108 [1] = {
109 /* place holder for contiguous memory */
110 },
111};
112
113static struct platform_device veu1_device = {
114 .name = "uio_pdrv_genirq",
115 .id = 2,
116 .dev = {
117 .platform_data = &veu1_platform_data,
118 },
119 .resource = veu1_resources,
120 .num_resources = ARRAY_SIZE(veu1_resources),
121};
16 122
17static struct plat_sci_port sci_platform_data[] = { 123static struct plat_sci_port sci_platform_data[] = {
18 { 124 {
@@ -34,11 +140,32 @@ static struct platform_device sci_device = {
34}; 140};
35 141
36static struct platform_device *sh7366_devices[] __initdata = { 142static struct platform_device *sh7366_devices[] __initdata = {
143 &iic_device,
37 &sci_device, 144 &sci_device,
145 &vpu_device,
146 &veu0_device,
147 &veu1_device,
38}; 148};
39 149
40static int __init sh7366_devices_setup(void) 150static int __init sh7366_devices_setup(void)
41{ 151{
152 clk_always_enable("mstp031"); /* TLB */
153 clk_always_enable("mstp030"); /* IC */
154 clk_always_enable("mstp029"); /* OC */
155 clk_always_enable("mstp028"); /* RSMEM */
156 clk_always_enable("mstp026"); /* XYMEM */
157 clk_always_enable("mstp023"); /* INTC3 */
158 clk_always_enable("mstp022"); /* INTC */
159 clk_always_enable("mstp020"); /* SuperHyway */
160 clk_always_enable("mstp109"); /* I2C */
161 clk_always_enable("mstp207"); /* VEU-2 */
162 clk_always_enable("mstp202"); /* VEU-1 */
163 clk_always_enable("mstp201"); /* VPU */
164
165 platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20);
166 platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20);
167 platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
168
42 return platform_add_devices(sh7366_devices, 169 return platform_add_devices(sh7366_devices,
43 ARRAY_SIZE(sh7366_devices)); 170 ARRAY_SIZE(sh7366_devices));
44} 171}
@@ -97,7 +224,7 @@ static struct intc_vect vectors[] __initdata = {
97 INTC_VECT(SIU, 0xf80), 224 INTC_VECT(SIU, 0xf80),
98 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 225 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
99 INTC_VECT(TMU2, 0x440), 226 INTC_VECT(TMU2, 0x440),
100 INTC_VECT(VEU2, 0x580), INTC_VECT(LCDC, 0x580), 227 INTC_VECT(VEU2, 0x560), INTC_VECT(LCDC, 0x580),
101}; 228};
102 229
103static struct intc_group groups[] __initdata = { 230static struct intc_group groups[] __initdata = {
@@ -163,8 +290,14 @@ static struct intc_sense_reg sense_registers[] __initdata = {
163 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } }, 290 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
164}; 291};
165 292
166static DECLARE_INTC_DESC(intc_desc, "sh7366", vectors, groups, 293static struct intc_mask_reg ack_registers[] __initdata = {
167 mask_registers, prio_registers, sense_registers); 294 { 0xa4140024, 0, 8, /* INTREQ00 */
295 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
296};
297
298static DECLARE_INTC_DESC_ACK(intc_desc, "sh7366", vectors, groups,
299 mask_registers, prio_registers, sense_registers,
300 ack_registers);
168 301
169void __init plat_irq_setup(void) 302void __init plat_irq_setup(void)
170{ 303{
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index 62ebccf18b3c..de1ede92176e 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -12,6 +12,8 @@
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h> 13#include <linux/serial_sci.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/uio_driver.h>
16#include <asm/clock.h>
15#include <asm/mmzone.h> 17#include <asm/mmzone.h>
16 18
17static struct resource usbf_resources[] = { 19static struct resource usbf_resources[] = {
@@ -59,6 +61,62 @@ static struct platform_device iic_device = {
59 .resource = iic_resources, 61 .resource = iic_resources,
60}; 62};
61 63
64static struct uio_info vpu_platform_data = {
65 .name = "VPU4",
66 .version = "0",
67 .irq = 60,
68};
69
70static struct resource vpu_resources[] = {
71 [0] = {
72 .name = "VPU",
73 .start = 0xfe900000,
74 .end = 0xfe9022eb,
75 .flags = IORESOURCE_MEM,
76 },
77 [1] = {
78 /* place holder for contiguous memory */
79 },
80};
81
82static struct platform_device vpu_device = {
83 .name = "uio_pdrv_genirq",
84 .id = 0,
85 .dev = {
86 .platform_data = &vpu_platform_data,
87 },
88 .resource = vpu_resources,
89 .num_resources = ARRAY_SIZE(vpu_resources),
90};
91
92static struct uio_info veu_platform_data = {
93 .name = "VEU",
94 .version = "0",
95 .irq = 54,
96};
97
98static struct resource veu_resources[] = {
99 [0] = {
100 .name = "VEU",
101 .start = 0xfe920000,
102 .end = 0xfe9200b7,
103 .flags = IORESOURCE_MEM,
104 },
105 [1] = {
106 /* place holder for contiguous memory */
107 },
108};
109
110static struct platform_device veu_device = {
111 .name = "uio_pdrv_genirq",
112 .id = 1,
113 .dev = {
114 .platform_data = &veu_platform_data,
115 },
116 .resource = veu_resources,
117 .num_resources = ARRAY_SIZE(veu_resources),
118};
119
62static struct plat_sci_port sci_platform_data[] = { 120static struct plat_sci_port sci_platform_data[] = {
63 { 121 {
64 .mapbase = 0xffe00000, 122 .mapbase = 0xffe00000,
@@ -95,10 +153,27 @@ static struct platform_device *sh7722_devices[] __initdata = {
95 &usbf_device, 153 &usbf_device,
96 &iic_device, 154 &iic_device,
97 &sci_device, 155 &sci_device,
156 &vpu_device,
157 &veu_device,
98}; 158};
99 159
100static int __init sh7722_devices_setup(void) 160static int __init sh7722_devices_setup(void)
101{ 161{
162 clk_always_enable("mstp031"); /* TLB */
163 clk_always_enable("mstp030"); /* IC */
164 clk_always_enable("mstp029"); /* OC */
165 clk_always_enable("mstp028"); /* URAM */
166 clk_always_enable("mstp026"); /* XYMEM */
167 clk_always_enable("mstp022"); /* INTC */
168 clk_always_enable("mstp020"); /* SuperHyway */
169 clk_always_enable("mstp109"); /* I2C */
170 clk_always_enable("mstp211"); /* USB */
171 clk_always_enable("mstp202"); /* VEU */
172 clk_always_enable("mstp201"); /* VPU */
173
174 platform_resource_setup_memory(&vpu_device, "vpu", 1 << 20);
175 platform_resource_setup_memory(&veu_device, "veu", 2 << 20);
176
102 return platform_add_devices(sh7722_devices, 177 return platform_add_devices(sh7722_devices,
103 ARRAY_SIZE(sh7722_devices)); 178 ARRAY_SIZE(sh7722_devices));
104} 179}
@@ -229,8 +304,14 @@ static struct intc_sense_reg sense_registers[] __initdata = {
229 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } }, 304 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
230}; 305};
231 306
232static DECLARE_INTC_DESC(intc_desc, "sh7722", vectors, groups, 307static struct intc_mask_reg ack_registers[] __initdata = {
233 mask_registers, prio_registers, sense_registers); 308 { 0xa4140024, 0, 8, /* INTREQ00 */
309 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
310};
311
312static DECLARE_INTC_DESC_ACK(intc_desc, "sh7722", vectors, groups,
313 mask_registers, prio_registers, sense_registers,
314 ack_registers);
234 315
235void __init plat_irq_setup(void) 316void __init plat_irq_setup(void)
236{ 317{
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
index a0470f2f5479..cd6baffdc896 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
@@ -12,8 +12,94 @@
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/serial_sci.h> 14#include <linux/serial_sci.h>
15#include <linux/uio_driver.h>
16#include <asm/clock.h>
15#include <asm/mmzone.h> 17#include <asm/mmzone.h>
16 18
19static struct uio_info vpu_platform_data = {
20 .name = "VPU5",
21 .version = "0",
22 .irq = 60,
23};
24
25static struct resource vpu_resources[] = {
26 [0] = {
27 .name = "VPU",
28 .start = 0xfe900000,
29 .end = 0xfe902807,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 /* place holder for contiguous memory */
34 },
35};
36
37static struct platform_device vpu_device = {
38 .name = "uio_pdrv_genirq",
39 .id = 0,
40 .dev = {
41 .platform_data = &vpu_platform_data,
42 },
43 .resource = vpu_resources,
44 .num_resources = ARRAY_SIZE(vpu_resources),
45};
46
47static struct uio_info veu0_platform_data = {
48 .name = "VEU",
49 .version = "0",
50 .irq = 54,
51};
52
53static struct resource veu0_resources[] = {
54 [0] = {
55 .name = "VEU2H0",
56 .start = 0xfe920000,
57 .end = 0xfe92027b,
58 .flags = IORESOURCE_MEM,
59 },
60 [1] = {
61 /* place holder for contiguous memory */
62 },
63};
64
65static struct platform_device veu0_device = {
66 .name = "uio_pdrv_genirq",
67 .id = 1,
68 .dev = {
69 .platform_data = &veu0_platform_data,
70 },
71 .resource = veu0_resources,
72 .num_resources = ARRAY_SIZE(veu0_resources),
73};
74
75static struct uio_info veu1_platform_data = {
76 .name = "VEU",
77 .version = "0",
78 .irq = 27,
79};
80
81static struct resource veu1_resources[] = {
82 [0] = {
83 .name = "VEU2H1",
84 .start = 0xfe924000,
85 .end = 0xfe92427b,
86 .flags = IORESOURCE_MEM,
87 },
88 [1] = {
89 /* place holder for contiguous memory */
90 },
91};
92
93static struct platform_device veu1_device = {
94 .name = "uio_pdrv_genirq",
95 .id = 2,
96 .dev = {
97 .platform_data = &veu1_platform_data,
98 },
99 .resource = veu1_resources,
100 .num_resources = ARRAY_SIZE(veu1_resources),
101};
102
17static struct plat_sci_port sci_platform_data[] = { 103static struct plat_sci_port sci_platform_data[] = {
18 { 104 {
19 .mapbase = 0xffe00000, 105 .mapbase = 0xffe00000,
@@ -113,14 +199,56 @@ static struct platform_device sh7723_usb_host_device = {
113 .resource = sh7723_usb_host_resources, 199 .resource = sh7723_usb_host_resources,
114}; 200};
115 201
202static struct resource iic_resources[] = {
203 [0] = {
204 .name = "IIC",
205 .start = 0x04470000,
206 .end = 0x04470017,
207 .flags = IORESOURCE_MEM,
208 },
209 [1] = {
210 .start = 96,
211 .end = 99,
212 .flags = IORESOURCE_IRQ,
213 },
214};
215
216static struct platform_device iic_device = {
217 .name = "i2c-sh_mobile",
218 .num_resources = ARRAY_SIZE(iic_resources),
219 .resource = iic_resources,
220};
221
116static struct platform_device *sh7723_devices[] __initdata = { 222static struct platform_device *sh7723_devices[] __initdata = {
117 &sci_device, 223 &sci_device,
118 &rtc_device, 224 &rtc_device,
225 &iic_device,
119 &sh7723_usb_host_device, 226 &sh7723_usb_host_device,
227 &vpu_device,
228 &veu0_device,
229 &veu1_device,
120}; 230};
121 231
122static int __init sh7723_devices_setup(void) 232static int __init sh7723_devices_setup(void)
123{ 233{
234 clk_always_enable("mstp031"); /* TLB */
235 clk_always_enable("mstp030"); /* IC */
236 clk_always_enable("mstp029"); /* OC */
237 clk_always_enable("mstp024"); /* FPU */
238 clk_always_enable("mstp022"); /* INTC */
239 clk_always_enable("mstp020"); /* SuperHyway */
240 clk_always_enable("mstp000"); /* MERAM */
241 clk_always_enable("mstp109"); /* I2C */
242 clk_always_enable("mstp108"); /* RTC */
243 clk_always_enable("mstp211"); /* USB */
244 clk_always_enable("mstp206"); /* VEU2H1 */
245 clk_always_enable("mstp202"); /* VEU2H0 */
246 clk_always_enable("mstp201"); /* VPU */
247
248 platform_resource_setup_memory(&vpu_device, "vpu", 2 << 20);
249 platform_resource_setup_memory(&veu0_device, "veu0", 2 << 20);
250 platform_resource_setup_memory(&veu1_device, "veu1", 2 << 20);
251
124 return platform_add_devices(sh7723_devices, 252 return platform_add_devices(sh7723_devices,
125 ARRAY_SIZE(sh7723_devices)); 253 ARRAY_SIZE(sh7723_devices));
126} 254}
@@ -326,8 +454,14 @@ static struct intc_sense_reg sense_registers[] __initdata = {
326 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } }, 454 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
327}; 455};
328 456
329static DECLARE_INTC_DESC(intc_desc, "sh7723", vectors, groups, 457static struct intc_mask_reg ack_registers[] __initdata = {
330 mask_registers, prio_registers, sense_registers); 458 { 0xa4140024, 0, 8, /* INTREQ00 */
459 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
460};
461
462static DECLARE_INTC_DESC_ACK(intc_desc, "sh7723", vectors, groups,
463 mask_registers, prio_registers, sense_registers,
464 ack_registers);
331 465
332void __init plat_irq_setup(void) 466void __init plat_irq_setup(void)
333{ 467{
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
index f189a559462b..3c5b629887a8 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2006 Paul Mundt 4 * Copyright (C) 2006 Paul Mundt
5 * Copyright (C) 2007 Yoshihiro Shimoda 5 * Copyright (C) 2007 Yoshihiro Shimoda
6 * Copyright (C) 2008 Nobuhiro Iwamatsu
6 * 7 *
7 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -56,6 +57,11 @@ static struct plat_sci_port sci_platform_data[] = {
56 .type = PORT_SCIF, 57 .type = PORT_SCIF,
57 .irqs = { 76, 77, 79, 78 }, 58 .irqs = { 76, 77, 79, 78 },
58 }, { 59 }, {
60 .mapbase = 0xffe10000,
61 .flags = UPF_BOOT_AUTOCONF,
62 .type = PORT_SCIF,
63 .irqs = { 104, 105, 107, 106 },
64 }, {
59 .flags = 0, 65 .flags = 0,
60 } 66 }
61}; 67};
@@ -208,8 +214,8 @@ static struct intc_vect vectors[] __initdata = {
208 INTC_VECT(TMU5, 0xe40), INTC_VECT(ADC, 0xe60), 214 INTC_VECT(TMU5, 0xe40), INTC_VECT(ADC, 0xe60),
209 INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0), 215 INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0),
210 INTC_VECT(SSI2, 0xec0), INTC_VECT(SSI3, 0xee0), 216 INTC_VECT(SSI2, 0xec0), INTC_VECT(SSI3, 0xee0),
211 INTC_VECT(SCIF1_ERI, 0xf00), INTC_VECT(SCIF1_RXI, 0xf20), 217 INTC_VECT(SCIF2_ERI, 0xf00), INTC_VECT(SCIF2_RXI, 0xf20),
212 INTC_VECT(SCIF1_BRI, 0xf40), INTC_VECT(SCIF1_TXI, 0xf60), 218 INTC_VECT(SCIF2_BRI, 0xf40), INTC_VECT(SCIF2_TXI, 0xf60),
213 INTC_VECT(GPIO_CH0, 0xf80), INTC_VECT(GPIO_CH1, 0xfa0), 219 INTC_VECT(GPIO_CH0, 0xf80), INTC_VECT(GPIO_CH1, 0xfa0),
214 INTC_VECT(GPIO_CH2, 0xfc0), INTC_VECT(GPIO_CH3, 0xfe0), 220 INTC_VECT(GPIO_CH2, 0xfc0), INTC_VECT(GPIO_CH3, 0xfe0),
215}; 221};
@@ -290,9 +296,14 @@ static struct intc_sense_reg irq_sense_registers[] __initdata = {
290 IRQ4, IRQ5, IRQ6, IRQ7 } }, 296 IRQ4, IRQ5, IRQ6, IRQ7 } },
291}; 297};
292 298
293static DECLARE_INTC_DESC(intc_irq_desc, "sh7763-irq", irq_vectors, 299static struct intc_mask_reg irq_ack_registers[] __initdata = {
294 NULL, irq_mask_registers, irq_prio_registers, 300 { 0xffd00024, 0, 32, /* INTREQ */
295 irq_sense_registers); 301 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
302};
303
304static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7763-irq", irq_vectors,
305 NULL, irq_mask_registers, irq_prio_registers,
306 irq_sense_registers, irq_ack_registers);
296 307
297 308
298/* External interrupt pins in IRL mode */ 309/* External interrupt pins in IRL mode */
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
index 18dbbe23fea1..fb8200cc7440 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
@@ -217,9 +217,14 @@ static struct intc_sense_reg irq_sense_registers[] __initdata = {
217 IRQ4, IRQ5, IRQ6, IRQ7 } }, 217 IRQ4, IRQ5, IRQ6, IRQ7 } },
218}; 218};
219 219
220static DECLARE_INTC_DESC(intc_irq_desc, "sh7780-irq", irq_vectors, 220static struct intc_mask_reg irq_ack_registers[] __initdata = {
221 NULL, irq_mask_registers, irq_prio_registers, 221 { 0xffd00024, 0, 32, /* INTREQ */
222 irq_sense_registers); 222 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
223};
224
225static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7780-irq", irq_vectors,
226 NULL, irq_mask_registers, irq_prio_registers,
227 irq_sense_registers, irq_ack_registers);
223 228
224/* External interrupt pins in IRL mode */ 229/* External interrupt pins in IRL mode */
225 230
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
index 621e7329ec63..30baa63b24c8 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
@@ -238,13 +238,18 @@ static struct intc_sense_reg sense_registers[] __initdata = {
238 IRQ4, IRQ5, IRQ6, IRQ7 } }, 238 IRQ4, IRQ5, IRQ6, IRQ7 } },
239}; 239};
240 240
241static DECLARE_INTC_DESC(intc_desc_irq0123, "sh7785-irq0123", vectors_irq0123, 241static struct intc_mask_reg ack_registers[] __initdata = {
242 NULL, mask_registers, prio_registers, 242 { 0xffd00024, 0, 32, /* INTREQ */
243 sense_registers); 243 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
244};
245
246static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7785-irq0123",
247 vectors_irq0123, NULL, mask_registers,
248 prio_registers, sense_registers, ack_registers);
244 249
245static DECLARE_INTC_DESC(intc_desc_irq4567, "sh7785-irq4567", vectors_irq4567, 250static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7785-irq4567",
246 NULL, mask_registers, prio_registers, 251 vectors_irq4567, NULL, mask_registers,
247 sense_registers); 252 prio_registers, sense_registers, ack_registers);
248 253
249/* External interrupt pins in IRL mode */ 254/* External interrupt pins in IRL mode */
250 255
diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S
index 718bd2356b34..5e0dd1933847 100644
--- a/arch/sh/kernel/entry-common.S
+++ b/arch/sh/kernel/entry-common.S
@@ -192,7 +192,7 @@ work_resched:
192 .align 2 192 .align 2
1931: .long schedule 1931: .long schedule
1942: .long do_notify_resume 1942: .long do_notify_resume
1953: .long restore_all 1953: .long resume_userspace
196#ifdef CONFIG_TRACE_IRQFLAGS 196#ifdef CONFIG_TRACE_IRQFLAGS
1974: .long trace_hardirqs_on 1974: .long trace_hardirqs_on
1985: .long trace_hardirqs_off 1985: .long trace_hardirqs_off
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 5c17de51987e..ec1eadce4aaa 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -70,7 +70,7 @@ static void kexec_info(struct kimage *image)
70 * Do not allocate memory (or fail in any way) in machine_kexec(). 70 * Do not allocate memory (or fail in any way) in machine_kexec().
71 * We are past the point of no return, committed to rebooting now. 71 * We are past the point of no return, committed to rebooting now.
72 */ 72 */
73NORET_TYPE void machine_kexec(struct kimage *image) 73void machine_kexec(struct kimage *image)
74{ 74{
75 75
76 unsigned long page_list; 76 unsigned long page_list;
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index 921892c351da..3326a45749d9 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -34,18 +34,6 @@ void (*pm_idle)(void);
34void (*pm_power_off)(void); 34void (*pm_power_off)(void);
35EXPORT_SYMBOL(pm_power_off); 35EXPORT_SYMBOL(pm_power_off);
36 36
37void disable_hlt(void)
38{
39 hlt_counter++;
40}
41EXPORT_SYMBOL(disable_hlt);
42
43void enable_hlt(void)
44{
45 hlt_counter--;
46}
47EXPORT_SYMBOL(enable_hlt);
48
49static int __init nohlt_setup(char *__unused) 37static int __init nohlt_setup(char *__unused)
50{ 38{
51 hlt_counter = 1; 39 hlt_counter = 1;
@@ -60,7 +48,7 @@ static int __init hlt_setup(char *__unused)
60} 48}
61__setup("hlt", hlt_setup); 49__setup("hlt", hlt_setup);
62 50
63void default_idle(void) 51static void default_idle(void)
64{ 52{
65 if (!hlt_counter) { 53 if (!hlt_counter) {
66 clear_thread_flag(TIF_POLLING_NRFLAG); 54 clear_thread_flag(TIF_POLLING_NRFLAG);
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c
index 0283d8133075..b9dbd2d3b4a5 100644
--- a/arch/sh/kernel/process_64.c
+++ b/arch/sh/kernel/process_64.c
@@ -36,16 +36,6 @@ static int hlt_counter = 1;
36 36
37#define HARD_IDLE_TIMEOUT (HZ / 3) 37#define HARD_IDLE_TIMEOUT (HZ / 3)
38 38
39void disable_hlt(void)
40{
41 hlt_counter++;
42}
43
44void enable_hlt(void)
45{
46 hlt_counter--;
47}
48
49static int __init nohlt_setup(char *__unused) 39static int __init nohlt_setup(char *__unused)
50{ 40{
51 hlt_counter = 1; 41 hlt_counter = 1;
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index fddb547f3c2b..2bc72def5cf8 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -241,6 +241,29 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
241 break; 241 break;
242 } 242 }
243#endif 243#endif
244#ifdef CONFIG_BINFMT_ELF_FDPIC
245 case PTRACE_GETFDPIC: {
246 unsigned long tmp = 0;
247
248 switch (addr) {
249 case PTRACE_GETFDPIC_EXEC:
250 tmp = child->mm->context.exec_fdpic_loadmap;
251 break;
252 case PTRACE_GETFDPIC_INTERP:
253 tmp = child->mm->context.interp_fdpic_loadmap;
254 break;
255 default:
256 break;
257 }
258
259 ret = 0;
260 if (put_user(tmp, (unsigned long *) data)) {
261 ret = -EFAULT;
262 break;
263 }
264 break;
265 }
266#endif
244 default: 267 default:
245 ret = ptrace_request(child, request, addr, data); 268 ret = ptrace_request(child, request, addr, data);
246 break; 269 break;
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index bca2bbc575db..6339d0c95715 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -398,6 +398,7 @@ const char *get_cpu_subtype(struct sh_cpuinfo *c)
398{ 398{
399 return cpu_name[c->type]; 399 return cpu_name[c->type];
400} 400}
401EXPORT_SYMBOL(get_cpu_subtype);
401 402
402#ifdef CONFIG_PROC_FS 403#ifdef CONFIG_PROC_FS
403/* Symbolic CPU flags, keep in sync with asm/cpu-features.h */ 404/* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
@@ -452,6 +453,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
452 seq_printf(m, "processor\t: %d\n", cpu); 453 seq_printf(m, "processor\t: %d\n", cpu);
453 seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine); 454 seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine);
454 seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c)); 455 seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c));
456 if (c->cut_major == -1)
457 seq_printf(m, "cut\t\t: unknown\n");
458 else if (c->cut_minor == -1)
459 seq_printf(m, "cut\t\t: %d.x\n", c->cut_major);
460 else
461 seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor);
455 462
456 show_cpuflags(m, c); 463 show_cpuflags(m, c);
457 464
diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c
index f311551d9a05..4bbbde895a53 100644
--- a/arch/sh/kernel/signal_32.c
+++ b/arch/sh/kernel/signal_32.c
@@ -33,6 +33,11 @@
33 33
34#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 34#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
35 35
36struct fdpic_func_descriptor {
37 unsigned long text;
38 unsigned long GOT;
39};
40
36/* 41/*
37 * Atomically swap in the new signal mask, and wait for a signal. 42 * Atomically swap in the new signal mask, and wait for a signal.
38 */ 43 */
@@ -368,6 +373,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
368 err |= __put_user(OR_R0_R0, &frame->retcode[6]); 373 err |= __put_user(OR_R0_R0, &frame->retcode[6]);
369 err |= __put_user((__NR_sigreturn), &frame->retcode[7]); 374 err |= __put_user((__NR_sigreturn), &frame->retcode[7]);
370 regs->pr = (unsigned long) frame->retcode; 375 regs->pr = (unsigned long) frame->retcode;
376 flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
371 } 377 }
372 378
373 if (err) 379 if (err)
@@ -378,18 +384,21 @@ static int setup_frame(int sig, struct k_sigaction *ka,
378 regs->regs[4] = signal; /* Arg for signal handler */ 384 regs->regs[4] = signal; /* Arg for signal handler */
379 regs->regs[5] = 0; 385 regs->regs[5] = 0;
380 regs->regs[6] = (unsigned long) &frame->sc; 386 regs->regs[6] = (unsigned long) &frame->sc;
381 regs->pc = (unsigned long) ka->sa.sa_handler; 387
388 if (current->personality & FDPIC_FUNCPTRS) {
389 struct fdpic_func_descriptor __user *funcptr =
390 (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
391
392 __get_user(regs->pc, &funcptr->text);
393 __get_user(regs->regs[12], &funcptr->GOT);
394 } else
395 regs->pc = (unsigned long)ka->sa.sa_handler;
382 396
383 set_fs(USER_DS); 397 set_fs(USER_DS);
384 398
385 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n", 399 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
386 current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); 400 current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
387 401
388 flush_cache_sigtramp(regs->pr);
389
390 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
391 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
392
393 return 0; 402 return 0;
394 403
395give_sigsegv: 404give_sigsegv:
@@ -458,17 +467,22 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
458 regs->regs[4] = signal; /* Arg for signal handler */ 467 regs->regs[4] = signal; /* Arg for signal handler */
459 regs->regs[5] = (unsigned long) &frame->info; 468 regs->regs[5] = (unsigned long) &frame->info;
460 regs->regs[6] = (unsigned long) &frame->uc; 469 regs->regs[6] = (unsigned long) &frame->uc;
461 regs->pc = (unsigned long) ka->sa.sa_handler; 470
471 if (current->personality & FDPIC_FUNCPTRS) {
472 struct fdpic_func_descriptor __user *funcptr =
473 (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
474
475 __get_user(regs->pc, &funcptr->text);
476 __get_user(regs->regs[12], &funcptr->GOT);
477 } else
478 regs->pc = (unsigned long)ka->sa.sa_handler;
462 479
463 set_fs(USER_DS); 480 set_fs(USER_DS);
464 481
465 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n", 482 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
466 current->comm, task_pid_nr(current), frame, regs->pc, regs->pr); 483 current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
467 484
468 flush_cache_sigtramp(regs->pr); 485 flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
469
470 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
471 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
472 486
473 return 0; 487 return 0;
474 488
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index a46cc3a41148..0af693e65764 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -343,3 +343,9 @@ ENTRY(sys_call_table)
343 .long sys_fallocate 343 .long sys_fallocate
344 .long sys_timerfd_settime /* 325 */ 344 .long sys_timerfd_settime /* 325 */
345 .long sys_timerfd_gettime 345 .long sys_timerfd_gettime
346 .long sys_signalfd4
347 .long sys_eventfd2
348 .long sys_epoll_create1
349 .long sys_dup3 /* 330 */
350 .long sys_pipe2
351 .long sys_inotify_init1
diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S
index d5d7843aad94..0b436aa3cad7 100644
--- a/arch/sh/kernel/syscalls_64.S
+++ b/arch/sh/kernel/syscalls_64.S
@@ -381,3 +381,9 @@ sys_call_table:
381 .long sys_fallocate 381 .long sys_fallocate
382 .long sys_timerfd_settime 382 .long sys_timerfd_settime
383 .long sys_timerfd_gettime 383 .long sys_timerfd_gettime
384 .long sys_signalfd4 /* 355 */
385 .long sys_eventfd2
386 .long sys_epoll_create1
387 .long sys_dup3
388 .long sys_pipe2
389 .long sys_inotify_init1 /* 360 */
diff --git a/arch/sh/kernel/time_32.c b/arch/sh/kernel/time_32.c
index 7281342c044d..0758b5ee8180 100644
--- a/arch/sh/kernel/time_32.c
+++ b/arch/sh/kernel/time_32.c
@@ -211,7 +211,7 @@ unsigned long sh_hpt_frequency = 0;
211 211
212#define NSEC_PER_CYC_SHIFT 10 212#define NSEC_PER_CYC_SHIFT 10
213 213
214struct clocksource clocksource_sh = { 214static struct clocksource clocksource_sh = {
215 .name = "SuperH", 215 .name = "SuperH",
216 .rating = 200, 216 .rating = 200,
217 .mask = CLOCKSOURCE_MASK(32), 217 .mask = CLOCKSOURCE_MASK(32),
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 8935570008d2..1ca9ad49b541 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -209,7 +209,7 @@ static int tmu_timer_init(void)
209 return 0; 209 return 0;
210} 210}
211 211
212struct sys_timer_ops tmu_timer_ops = { 212static struct sys_timer_ops tmu_timer_ops = {
213 .init = tmu_timer_init, 213 .init = tmu_timer_init,
214 .start = tmu_timer_start, 214 .start = tmu_timer_start,
215 .stop = tmu_timer_stop, 215 .stop = tmu_timer_stop,
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index e08b3bfeb656..511a9426cec5 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -43,6 +43,7 @@
43# define TRAP_ILLEGAL_SLOT_INST 6 43# define TRAP_ILLEGAL_SLOT_INST 6
44# define TRAP_ADDRESS_ERROR 9 44# define TRAP_ADDRESS_ERROR 9
45# ifdef CONFIG_CPU_SH2A 45# ifdef CONFIG_CPU_SH2A
46# define TRAP_FPU_ERROR 13
46# define TRAP_DIVZERO_ERROR 17 47# define TRAP_DIVZERO_ERROR 17
47# define TRAP_DIVOVF_ERROR 18 48# define TRAP_DIVOVF_ERROR 18
48# endif 49# endif
@@ -851,6 +852,9 @@ void __init trap_init(void)
851#ifdef CONFIG_CPU_SH2A 852#ifdef CONFIG_CPU_SH2A
852 set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error); 853 set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error);
853 set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error); 854 set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error);
855#ifdef CONFIG_SH_FPU
856 set_exception_table_vec(TRAP_FPU_ERROR, fpu_error_trap_handler);
857#endif
854#endif 858#endif
855 859
856 /* Setup VBR for boot cpu */ 860 /* Setup VBR for boot cpu */
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index ebb55d1149f5..8596cc78e18d 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -2,9 +2,11 @@
2# Makefile for SuperH-specific library files.. 2# Makefile for SuperH-specific library files..
3# 3#
4 4
5lib-y = delay.o io.o memset.o memmove.o memchr.o \ 5lib-y = delay.o memset.o memmove.o memchr.o \
6 checksum.o strlen.o div64.o div64-generic.o 6 checksum.o strlen.o div64.o div64-generic.o
7 7
8obj-y += io.o
9
8memcpy-y := memcpy.o 10memcpy-y := memcpy.o
9memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o 11memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o
10 12
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 5fd218430b19..56d0a7daa34b 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -145,25 +145,39 @@ choice
145 145
146config PAGE_SIZE_4KB 146config PAGE_SIZE_4KB
147 bool "4kB" 147 bool "4kB"
148 depends on !X2TLB 148 depends on !MMU || !X2TLB
149 help 149 help
150 This is the default page size used by all SuperH CPUs. 150 This is the default page size used by all SuperH CPUs.
151 151
152config PAGE_SIZE_8KB 152config PAGE_SIZE_8KB
153 bool "8kB" 153 bool "8kB"
154 depends on X2TLB 154 depends on !MMU || X2TLB
155 help 155 help
156 This enables 8kB pages as supported by SH-X2 and later MMUs. 156 This enables 8kB pages as supported by SH-X2 and later MMUs.
157 157
158config PAGE_SIZE_16KB
159 bool "16kB"
160 depends on !MMU
161 help
162 This enables 16kB pages on MMU-less SH systems.
163
158config PAGE_SIZE_64KB 164config PAGE_SIZE_64KB
159 bool "64kB" 165 bool "64kB"
160 depends on CPU_SH4 || CPU_SH5 166 depends on !MMU || CPU_SH4 || CPU_SH5
161 help 167 help
162 This enables support for 64kB pages, possible on all SH-4 168 This enables support for 64kB pages, possible on all SH-4
163 CPUs and later. 169 CPUs and later.
164 170
165endchoice 171endchoice
166 172
173config ENTRY_OFFSET
174 hex
175 default "0x00001000" if PAGE_SIZE_4KB
176 default "0x00002000" if PAGE_SIZE_8KB
177 default "0x00004000" if PAGE_SIZE_16KB
178 default "0x00010000" if PAGE_SIZE_64KB
179 default "0x00000000"
180
167choice 181choice
168 prompt "HugeTLB page size" 182 prompt "HugeTLB page size"
169 depends on HUGETLB_PAGE && (CPU_SH4 || CPU_SH5) && MMU 183 depends on HUGETLB_PAGE && (CPU_SH4 || CPU_SH5) && MMU
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index c5b56d52b7d2..0e189ccd4a77 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -120,7 +120,7 @@ static const struct file_operations cache_debugfs_fops = {
120 .open = cache_debugfs_open, 120 .open = cache_debugfs_open,
121 .read = seq_read, 121 .read = seq_read,
122 .llseek = seq_lseek, 122 .llseek = seq_lseek,
123 .release = seq_release, 123 .release = single_release,
124}; 124};
125 125
126static int __init cache_debugfs_init(void) 126static int __init cache_debugfs_init(void)
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 43d7ff6b6ec7..1fdc8d90254a 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2001 - 2007 Paul Mundt 5 * Copyright (C) 2001 - 2007 Paul Mundt
6 * Copyright (C) 2003 Richard Curnow 6 * Copyright (C) 2003 Richard Curnow
7 * Copyright (c) 2007 STMicroelectronics (R&D) Ltd.
7 * 8 *
8 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -22,6 +23,7 @@
22 * entirety. 23 * entirety.
23 */ 24 */
24#define MAX_DCACHE_PAGES 64 /* XXX: Tune for ways */ 25#define MAX_DCACHE_PAGES 64 /* XXX: Tune for ways */
26#define MAX_ICACHE_PAGES 32
25 27
26static void __flush_dcache_segment_1way(unsigned long start, 28static void __flush_dcache_segment_1way(unsigned long start,
27 unsigned long extent); 29 unsigned long extent);
@@ -178,42 +180,45 @@ void __flush_invalidate_region(void *start, int size)
178/* 180/*
179 * Write back the range of D-cache, and purge the I-cache. 181 * Write back the range of D-cache, and purge the I-cache.
180 * 182 *
181 * Called from kernel/module.c:sys_init_module and routine for a.out format. 183 * Called from kernel/module.c:sys_init_module and routine for a.out format,
184 * signal handler code and kprobes code
182 */ 185 */
183void flush_icache_range(unsigned long start, unsigned long end) 186void flush_icache_range(unsigned long start, unsigned long end)
184{ 187{
185 flush_cache_all(); 188 int icacheaddr;
186} 189 unsigned long flags, v;
187
188/*
189 * Write back the D-cache and purge the I-cache for signal trampoline.
190 * .. which happens to be the same behavior as flush_icache_range().
191 * So, we simply flush out a line.
192 */
193void __uses_jump_to_uncached flush_cache_sigtramp(unsigned long addr)
194{
195 unsigned long v, index;
196 unsigned long flags;
197 int i; 190 int i;
198 191
199 v = addr & ~(L1_CACHE_BYTES-1); 192 /* If there are too many pages then just blow the caches */
200 asm volatile("ocbwb %0" 193 if (((end - start) >> PAGE_SHIFT) >= MAX_ICACHE_PAGES) {
201 : /* no output */ 194 flush_cache_all();
202 : "m" (__m(v))); 195 } else {
203 196 /* selectively flush d-cache then invalidate the i-cache */
204 index = CACHE_IC_ADDRESS_ARRAY | 197 /* this is inefficient, so only use for small ranges */
205 (v & boot_cpu_data.icache.entry_mask); 198 start &= ~(L1_CACHE_BYTES-1);
206 199 end += L1_CACHE_BYTES-1;
207 local_irq_save(flags); 200 end &= ~(L1_CACHE_BYTES-1);
208 jump_to_uncached(); 201
209 202 local_irq_save(flags);
210 for (i = 0; i < boot_cpu_data.icache.ways; 203 jump_to_uncached();
211 i++, index += boot_cpu_data.icache.way_incr) 204
212 ctrl_outl(0, index); /* Clear out Valid-bit */ 205 for (v = start; v < end; v+=L1_CACHE_BYTES) {
213 206 asm volatile("ocbwb %0"
214 back_to_cached(); 207 : /* no output */
215 wmb(); 208 : "m" (__m(v)));
216 local_irq_restore(flags); 209
210 icacheaddr = CACHE_IC_ADDRESS_ARRAY | (
211 v & cpu_data->icache.entry_mask);
212
213 for (i = 0; i < cpu_data->icache.ways;
214 i++, icacheaddr += cpu_data->icache.way_incr)
215 /* Clear i-cache line valid-bit */
216 ctrl_outl(0, icacheaddr);
217 }
218
219 back_to_cached();
220 local_irq_restore(flags);
221 }
217} 222}
218 223
219static inline void flush_cache_4096(unsigned long start, 224static inline void flush_cache_4096(unsigned long start,
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index d3c33fc5b1c2..b2ce014401b5 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -10,6 +10,7 @@
10 * for more details. 10 * for more details.
11 */ 11 */
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/platform_device.h>
13#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
14#include <asm/cacheflush.h> 15#include <asm/cacheflush.h>
15#include <asm/addrspace.h> 16#include <asm/addrspace.h>
@@ -27,21 +28,10 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
27 dma_addr_t *dma_handle, gfp_t gfp) 28 dma_addr_t *dma_handle, gfp_t gfp)
28{ 29{
29 void *ret, *ret_nocache; 30 void *ret, *ret_nocache;
30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
31 int order = get_order(size); 31 int order = get_order(size);
32 32
33 if (mem) { 33 if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
34 int page = bitmap_find_free_region(mem->bitmap, mem->size, 34 return ret;
35 order);
36 if (page >= 0) {
37 *dma_handle = mem->device_base + (page << PAGE_SHIFT);
38 ret = mem->virt_base + (page << PAGE_SHIFT);
39 memset(ret, 0, size);
40 return ret;
41 }
42 if (mem->flags & DMA_MEMORY_EXCLUSIVE)
43 return NULL;
44 }
45 35
46 ret = (void *)__get_free_pages(gfp, order); 36 ret = (void *)__get_free_pages(gfp, order);
47 if (!ret) 37 if (!ret)
@@ -71,11 +61,7 @@ void dma_free_coherent(struct device *dev, size_t size,
71 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; 61 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
72 int order = get_order(size); 62 int order = get_order(size);
73 63
74 if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) { 64 if (!dma_release_from_coherent(dev, order, vaddr)) {
75 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
76
77 bitmap_release_region(mem->bitmap, page, order);
78 } else {
79 WARN_ON(irqs_disabled()); /* for portability */ 65 WARN_ON(irqs_disabled()); /* for portability */
80 BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE); 66 BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE);
81 free_pages((unsigned long)phys_to_virt(dma_handle), order); 67 free_pages((unsigned long)phys_to_virt(dma_handle), order);
@@ -84,83 +70,6 @@ void dma_free_coherent(struct device *dev, size_t size,
84} 70}
85EXPORT_SYMBOL(dma_free_coherent); 71EXPORT_SYMBOL(dma_free_coherent);
86 72
87int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
88 dma_addr_t device_addr, size_t size, int flags)
89{
90 void __iomem *mem_base = NULL;
91 int pages = size >> PAGE_SHIFT;
92 int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
93
94 if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
95 goto out;
96 if (!size)
97 goto out;
98 if (dev->dma_mem)
99 goto out;
100
101 /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
102
103 mem_base = ioremap_nocache(bus_addr, size);
104 if (!mem_base)
105 goto out;
106
107 dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
108 if (!dev->dma_mem)
109 goto out;
110 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
111 if (!dev->dma_mem->bitmap)
112 goto free1_out;
113
114 dev->dma_mem->virt_base = mem_base;
115 dev->dma_mem->device_base = device_addr;
116 dev->dma_mem->size = pages;
117 dev->dma_mem->flags = flags;
118
119 if (flags & DMA_MEMORY_MAP)
120 return DMA_MEMORY_MAP;
121
122 return DMA_MEMORY_IO;
123
124 free1_out:
125 kfree(dev->dma_mem);
126 out:
127 if (mem_base)
128 iounmap(mem_base);
129 return 0;
130}
131EXPORT_SYMBOL(dma_declare_coherent_memory);
132
133void dma_release_declared_memory(struct device *dev)
134{
135 struct dma_coherent_mem *mem = dev->dma_mem;
136
137 if (!mem)
138 return;
139 dev->dma_mem = NULL;
140 iounmap(mem->virt_base);
141 kfree(mem->bitmap);
142 kfree(mem);
143}
144EXPORT_SYMBOL(dma_release_declared_memory);
145
146void *dma_mark_declared_memory_occupied(struct device *dev,
147 dma_addr_t device_addr, size_t size)
148{
149 struct dma_coherent_mem *mem = dev->dma_mem;
150 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
151 int pos, err;
152
153 if (!mem)
154 return ERR_PTR(-EINVAL);
155
156 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
157 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
158 if (err != 0)
159 return ERR_PTR(err);
160 return mem->virt_base + (pos << PAGE_SHIFT);
161}
162EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
163
164void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 73void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
165 enum dma_data_direction direction) 74 enum dma_data_direction direction)
166{ 75{
@@ -185,3 +94,32 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
185 } 94 }
186} 95}
187EXPORT_SYMBOL(dma_cache_sync); 96EXPORT_SYMBOL(dma_cache_sync);
97
98int platform_resource_setup_memory(struct platform_device *pdev,
99 char *name, unsigned long memsize)
100{
101 struct resource *r;
102 dma_addr_t dma_handle;
103 void *buf;
104
105 r = pdev->resource + pdev->num_resources - 1;
106 if (r->flags) {
107 pr_warning("%s: unable to find empty space for resource\n",
108 name);
109 return -EINVAL;
110 }
111
112 buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL);
113 if (!buf) {
114 pr_warning("%s: unable to allocate memory\n", name);
115 return -ENOMEM;
116 }
117
118 memset(buf, 0, memsize);
119
120 r->flags = IORESOURCE_MEM;
121 r->start = dma_handle;
122 r->end = r->start + memsize - 1;
123 r->name = name;
124 return 0;
125}
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c
index d1fa27594c6e..0c776fdfbdda 100644
--- a/arch/sh/mm/fault_32.c
+++ b/arch/sh/mm/fault_32.c
@@ -37,16 +37,12 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
37 int fault; 37 int fault;
38 siginfo_t info; 38 siginfo_t info;
39 39
40 trace_hardirqs_on();
41 local_irq_enable();
42
43#ifdef CONFIG_SH_KGDB 40#ifdef CONFIG_SH_KGDB
44 if (kgdb_nofault && kgdb_bus_err_hook) 41 if (kgdb_nofault && kgdb_bus_err_hook)
45 kgdb_bus_err_hook(); 42 kgdb_bus_err_hook();
46#endif 43#endif
47 44
48 tsk = current; 45 tsk = current;
49 mm = tsk->mm;
50 si_code = SEGV_MAPERR; 46 si_code = SEGV_MAPERR;
51 47
52 if (unlikely(address >= TASK_SIZE)) { 48 if (unlikely(address >= TASK_SIZE)) {
@@ -88,6 +84,14 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
88 return; 84 return;
89 } 85 }
90 86
87 /* Only enable interrupts if they were on before the fault */
88 if ((regs->sr & SR_IMASK) != SR_IMASK) {
89 trace_hardirqs_on();
90 local_irq_enable();
91 }
92
93 mm = tsk->mm;
94
91 /* 95 /*
92 * If we're in an interrupt or have no user 96 * If we're in an interrupt or have no user
93 * context, we must not take the fault.. 97 * context, we must not take the fault..
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index d652d375eb1e..b75a7acd62fb 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -25,47 +25,6 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
25pgd_t swapper_pg_dir[PTRS_PER_PGD]; 25pgd_t swapper_pg_dir[PTRS_PER_PGD];
26unsigned long cached_to_uncached = 0; 26unsigned long cached_to_uncached = 0;
27 27
28void show_mem(void)
29{
30 int total = 0, reserved = 0, free = 0;
31 int shared = 0, cached = 0, slab = 0;
32 pg_data_t *pgdat;
33
34 printk("Mem-info:\n");
35 show_free_areas();
36
37 for_each_online_pgdat(pgdat) {
38 unsigned long flags, i;
39
40 pgdat_resize_lock(pgdat, &flags);
41 for (i = 0; i < pgdat->node_spanned_pages; i++) {
42 struct page *page = pgdat_page_nr(pgdat, i);
43 total++;
44 if (PageReserved(page))
45 reserved++;
46 else if (PageSwapCache(page))
47 cached++;
48 else if (PageSlab(page))
49 slab++;
50 else if (!page_count(page))
51 free++;
52 else
53 shared += page_count(page) - 1;
54 }
55 pgdat_resize_unlock(pgdat, &flags);
56 }
57
58 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
59 printk("%d pages of RAM\n", total);
60 printk("%d free pages\n", free);
61 printk("%d reserved pages\n", reserved);
62 printk("%d slab pages\n", slab);
63 printk("%d pages shared\n", shared);
64 printk("%d pages swap cached\n", cached);
65 printk(KERN_INFO "Total of %ld pages in page table cache\n",
66 quicklist_total_size());
67}
68
69#ifdef CONFIG_MMU 28#ifdef CONFIG_MMU
70static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) 29static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
71{ 30{
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index 8c7a9ca79879..38870e0fc182 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -111,7 +111,7 @@ EXPORT_SYMBOL(copy_user_highpage);
111/* 111/*
112 * For SH-4, we have our own implementation for ptep_get_and_clear 112 * For SH-4, we have our own implementation for ptep_get_and_clear
113 */ 113 */
114inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 114pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
115{ 115{
116 pte_t pte = *ptep; 116 pte_t pte = *ptep;
117 117
diff --git a/arch/sh/mm/pg-sh7705.c b/arch/sh/mm/pg-sh7705.c
index 7f885b7f8aff..eaf25147194c 100644
--- a/arch/sh/mm/pg-sh7705.c
+++ b/arch/sh/mm/pg-sh7705.c
@@ -118,7 +118,7 @@ void copy_user_page(void *to, void *from, unsigned long address, struct page *pg
118 * For SH7705, we have our own implementation for ptep_get_and_clear 118 * For SH7705, we have our own implementation for ptep_get_and_clear
119 * Copied from pg-sh4.c 119 * Copied from pg-sh4.c
120 */ 120 */
121inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 121pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
122{ 122{
123 pte_t pte = *ptep; 123 pte_t pte = *ptep;
124 124
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 0b0ec6e04753..cef727669c87 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -293,7 +293,7 @@ void pmb_unmap(unsigned long addr)
293 } while (pmbe); 293 } while (pmbe);
294} 294}
295 295
296static void pmb_cache_ctor(struct kmem_cache *cachep, void *pmb) 296static void pmb_cache_ctor(void *pmb)
297{ 297{
298 struct pmb_entry *pmbe = pmb; 298 struct pmb_entry *pmbe = pmb;
299 299
@@ -385,7 +385,7 @@ static const struct file_operations pmb_debugfs_fops = {
385 .open = pmb_debugfs_open, 385 .open = pmb_debugfs_open,
386 .read = seq_read, 386 .read = seq_read,
387 .llseek = seq_lseek, 387 .llseek = seq_lseek,
388 .release = seq_release, 388 .release = single_release,
389}; 389};
390 390
391static int __init pmb_debugfs_init(void) 391static int __init pmb_debugfs_init(void)
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index 1bba7d36be90..0a11cc08f0a5 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -46,3 +46,7 @@ R2D_1 RTS7751R2D_1
46CAYMAN SH_CAYMAN 46CAYMAN SH_CAYMAN
47SDK7780 SH_SDK7780 47SDK7780 SH_SDK7780
48MIGOR SH_MIGOR 48MIGOR SH_MIGOR
49RSK7203 SH_RSK7203
50AP325RXA SH_AP325RXA
51SH7763RDP SH_SH7763RDP
52SH7785LCR SH_SH7785LCR
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 375de7c6d082..a214002114ed 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -68,6 +68,7 @@ config SPARC
68 select HAVE_IDE 68 select HAVE_IDE
69 select HAVE_OPROFILE 69 select HAVE_OPROFILE
70 select HAVE_ARCH_KGDB if !SMP 70 select HAVE_ARCH_KGDB if !SMP
71 select HAVE_ARCH_TRACEHOOK
71 72
72# Identify this as a Sparc32 build 73# Identify this as a Sparc32 build
73config SPARC32 74config SPARC32
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
new file mode 100644
index 000000000000..a5f0ce734ff7
--- /dev/null
+++ b/arch/sparc/include/asm/Kbuild
@@ -0,0 +1,45 @@
1# User exported sparc header files
2include include/asm-generic/Kbuild.asm
3
4header-y += ipcbuf_32.h
5header-y += ipcbuf_64.h
6header-y += posix_types_32.h
7header-y += posix_types_64.h
8header-y += ptrace_32.h
9header-y += ptrace_64.h
10header-y += sigcontext_32.h
11header-y += sigcontext_64.h
12header-y += siginfo_32.h
13header-y += siginfo_64.h
14header-y += signal_32.h
15header-y += signal_64.h
16header-y += stat_32.h
17header-y += stat_64.h
18header-y += statfs_32.h
19header-y += statfs_64.h
20header-y += unistd_32.h
21header-y += unistd_64.h
22
23header-y += apc.h
24header-y += asi.h
25header-y += bpp.h
26header-y += display7seg.h
27header-y += envctrl.h
28header-y += fbio.h
29header-y += jsflash.h
30header-y += openprom.h
31header-y += openprom_32.h
32header-y += openprom_64.h
33header-y += openpromio.h
34header-y += perfctr.h
35header-y += psrcompat.h
36header-y += psr.h
37header-y += pstate.h
38header-y += reg.h
39header-y += reg_32.h
40header-y += reg_64.h
41header-y += traps.h
42header-y += uctx.h
43header-y += utrap.h
44header-y += vfc_ioctls.h
45header-y += watchdog.h
diff --git a/include/asm-sparc/agp.h b/arch/sparc/include/asm/agp.h
index c2456870b05c..c2456870b05c 100644
--- a/include/asm-sparc/agp.h
+++ b/arch/sparc/include/asm/agp.h
diff --git a/include/asm-sparc/apb.h b/arch/sparc/include/asm/apb.h
index 8f3b57db810f..8f3b57db810f 100644
--- a/include/asm-sparc/apb.h
+++ b/arch/sparc/include/asm/apb.h
diff --git a/include/asm-sparc/apc.h b/arch/sparc/include/asm/apc.h
index 24e9a7d4d97e..24e9a7d4d97e 100644
--- a/include/asm-sparc/apc.h
+++ b/arch/sparc/include/asm/apc.h
diff --git a/include/asm-sparc/asi.h b/arch/sparc/include/asm/asi.h
index 74703c5ef985..74703c5ef985 100644
--- a/include/asm-sparc/asi.h
+++ b/arch/sparc/include/asm/asi.h
diff --git a/include/asm-sparc/asmmacro.h b/arch/sparc/include/asm/asmmacro.h
index a619a4d97aae..a619a4d97aae 100644
--- a/include/asm-sparc/asmmacro.h
+++ b/arch/sparc/include/asm/asmmacro.h
diff --git a/include/asm-sparc/atomic.h b/arch/sparc/include/asm/atomic.h
index 66d8166ec1d7..8ff83d8cc33f 100644
--- a/include/asm-sparc/atomic.h
+++ b/arch/sparc/include/asm/atomic.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_ATOMIC_H 1#ifndef ___ASM_SPARC_ATOMIC_H
2#define ___ASM_SPARC_ATOMIC_H 2#define ___ASM_SPARC_ATOMIC_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/atomic_64.h> 4#include <asm/atomic_64.h>
5#else 5#else
6#include <asm-sparc/atomic_32.h> 6#include <asm/atomic_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/atomic_32.h b/arch/sparc/include/asm/atomic_32.h
index 5c944b5a8040..5c944b5a8040 100644
--- a/include/asm-sparc/atomic_32.h
+++ b/arch/sparc/include/asm/atomic_32.h
diff --git a/include/asm-sparc/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
index 2c71ec4a3b18..2c71ec4a3b18 100644
--- a/include/asm-sparc/atomic_64.h
+++ b/arch/sparc/include/asm/atomic_64.h
diff --git a/include/asm-sparc/auxio.h b/arch/sparc/include/asm/auxio.h
index 24c6f3c0f577..13dc67f03011 100644
--- a/include/asm-sparc/auxio.h
+++ b/arch/sparc/include/asm/auxio.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_AUXIO_H 1#ifndef ___ASM_SPARC_AUXIO_H
2#define ___ASM_SPARC_AUXIO_H 2#define ___ASM_SPARC_AUXIO_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/auxio_64.h> 4#include <asm/auxio_64.h>
5#else 5#else
6#include <asm-sparc/auxio_32.h> 6#include <asm/auxio_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/auxio_32.h b/arch/sparc/include/asm/auxio_32.h
index 4db8f23db20f..e03e088be95f 100644
--- a/include/asm-sparc/auxio_32.h
+++ b/arch/sparc/include/asm/auxio_32.h
@@ -36,7 +36,7 @@
36 * understand the hardware you are querying! 36 * understand the hardware you are querying!
37 */ 37 */
38extern void set_auxio(unsigned char bits_on, unsigned char bits_off); 38extern void set_auxio(unsigned char bits_on, unsigned char bits_off);
39extern unsigned char get_auxio(void); /* .../asm-sparc/floppy.h */ 39extern unsigned char get_auxio(void); /* .../asm/floppy.h */
40 40
41/* 41/*
42 * The following routines are provided for driver-compatibility 42 * The following routines are provided for driver-compatibility
diff --git a/include/asm-sparc/auxio_64.h b/arch/sparc/include/asm/auxio_64.h
index f61cd1e3e395..f61cd1e3e395 100644
--- a/include/asm-sparc/auxio_64.h
+++ b/arch/sparc/include/asm/auxio_64.h
diff --git a/include/asm-sparc/auxvec.h b/arch/sparc/include/asm/auxvec.h
index ad6f360261f6..ad6f360261f6 100644
--- a/include/asm-sparc/auxvec.h
+++ b/arch/sparc/include/asm/auxvec.h
diff --git a/include/asm-sparc/backoff.h b/arch/sparc/include/asm/backoff.h
index fa1fdf67e350..fa1fdf67e350 100644
--- a/include/asm-sparc/backoff.h
+++ b/arch/sparc/include/asm/backoff.h
diff --git a/include/asm-sparc/bbc.h b/arch/sparc/include/asm/bbc.h
index 423a85800aae..423a85800aae 100644
--- a/include/asm-sparc/bbc.h
+++ b/arch/sparc/include/asm/bbc.h
diff --git a/include/asm-sparc/bitext.h b/arch/sparc/include/asm/bitext.h
index 297b2f2fcb49..297b2f2fcb49 100644
--- a/include/asm-sparc/bitext.h
+++ b/arch/sparc/include/asm/bitext.h
diff --git a/include/asm-sparc/bitops.h b/arch/sparc/include/asm/bitops.h
index 1a2949d0193f..b1edd94bd64f 100644
--- a/include/asm-sparc/bitops.h
+++ b/arch/sparc/include/asm/bitops.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_BITOPS_H 1#ifndef ___ASM_SPARC_BITOPS_H
2#define ___ASM_SPARC_BITOPS_H 2#define ___ASM_SPARC_BITOPS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/bitops_64.h> 4#include <asm/bitops_64.h>
5#else 5#else
6#include <asm-sparc/bitops_32.h> 6#include <asm/bitops_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/bitops_32.h b/arch/sparc/include/asm/bitops_32.h
index 68b98a7e6454..68b98a7e6454 100644
--- a/include/asm-sparc/bitops_32.h
+++ b/arch/sparc/include/asm/bitops_32.h
diff --git a/include/asm-sparc/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index bb87b8080220..bb87b8080220 100644
--- a/include/asm-sparc/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
diff --git a/include/asm-sparc/bpp.h b/arch/sparc/include/asm/bpp.h
index 31f515e499a7..31f515e499a7 100644
--- a/include/asm-sparc/bpp.h
+++ b/arch/sparc/include/asm/bpp.h
diff --git a/include/asm-sparc/btfixup.h b/arch/sparc/include/asm/btfixup.h
index 08277e6fb4cd..797722cf69f2 100644
--- a/include/asm-sparc/btfixup.h
+++ b/arch/sparc/include/asm/btfixup.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * asm-sparc/btfixup.h: Macros for boot time linking. 2 * asm/btfixup.h: Macros for boot time linking.
3 * 3 *
4 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 4 * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */ 5 */
diff --git a/include/asm-sparc/bug.h b/arch/sparc/include/asm/bug.h
index 8a59e5a8c217..8a59e5a8c217 100644
--- a/include/asm-sparc/bug.h
+++ b/arch/sparc/include/asm/bug.h
diff --git a/include/asm-sparc/bugs.h b/arch/sparc/include/asm/bugs.h
index 2dfc07bc8e54..e179bc12f64a 100644
--- a/include/asm-sparc/bugs.h
+++ b/arch/sparc/include/asm/bugs.h
@@ -1,4 +1,4 @@
1/* include/asm-sparc/bugs.h: Sparc probes for various bugs. 1/* include/asm/bugs.h: Sparc probes for various bugs.
2 * 2 *
3 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net)
4 */ 4 */
diff --git a/include/asm-sparc/byteorder.h b/arch/sparc/include/asm/byteorder.h
index bcd83aa351c5..bcd83aa351c5 100644
--- a/include/asm-sparc/byteorder.h
+++ b/arch/sparc/include/asm/byteorder.h
diff --git a/include/asm-sparc/cache.h b/arch/sparc/include/asm/cache.h
index 41f85ae4bd4a..41f85ae4bd4a 100644
--- a/include/asm-sparc/cache.h
+++ b/arch/sparc/include/asm/cache.h
diff --git a/include/asm-sparc/cacheflush.h b/arch/sparc/include/asm/cacheflush.h
index 2b6a37957c2d..049168087b19 100644
--- a/include/asm-sparc/cacheflush.h
+++ b/arch/sparc/include/asm/cacheflush.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_CACHEFLUSH_H 1#ifndef ___ASM_SPARC_CACHEFLUSH_H
2#define ___ASM_SPARC_CACHEFLUSH_H 2#define ___ASM_SPARC_CACHEFLUSH_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/cacheflush_64.h> 4#include <asm/cacheflush_64.h>
5#else 5#else
6#include <asm-sparc/cacheflush_32.h> 6#include <asm/cacheflush_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/cacheflush_32.h b/arch/sparc/include/asm/cacheflush_32.h
index 68ac10910271..68ac10910271 100644
--- a/include/asm-sparc/cacheflush_32.h
+++ b/arch/sparc/include/asm/cacheflush_32.h
diff --git a/include/asm-sparc/cacheflush_64.h b/arch/sparc/include/asm/cacheflush_64.h
index c43321729b3b..c43321729b3b 100644
--- a/include/asm-sparc/cacheflush_64.h
+++ b/arch/sparc/include/asm/cacheflush_64.h
diff --git a/include/asm-sparc/chafsr.h b/arch/sparc/include/asm/chafsr.h
index 85c69b38220b..85c69b38220b 100644
--- a/include/asm-sparc/chafsr.h
+++ b/arch/sparc/include/asm/chafsr.h
diff --git a/include/asm-sparc/checksum.h b/arch/sparc/include/asm/checksum.h
index 4e3553d4f6e1..7ac0d7497bc5 100644
--- a/include/asm-sparc/checksum.h
+++ b/arch/sparc/include/asm/checksum.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_CHECKSUM_H 1#ifndef ___ASM_SPARC_CHECKSUM_H
2#define ___ASM_SPARC_CHECKSUM_H 2#define ___ASM_SPARC_CHECKSUM_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/checksum_64.h> 4#include <asm/checksum_64.h>
5#else 5#else
6#include <asm-sparc/checksum_32.h> 6#include <asm/checksum_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/checksum_32.h b/arch/sparc/include/asm/checksum_32.h
index bdbda1453aa9..bdbda1453aa9 100644
--- a/include/asm-sparc/checksum_32.h
+++ b/arch/sparc/include/asm/checksum_32.h
diff --git a/include/asm-sparc/checksum_64.h b/arch/sparc/include/asm/checksum_64.h
index 019b9615e43c..019b9615e43c 100644
--- a/include/asm-sparc/checksum_64.h
+++ b/arch/sparc/include/asm/checksum_64.h
diff --git a/include/asm-sparc/chmctrl.h b/arch/sparc/include/asm/chmctrl.h
index 859b4a4b0d30..859b4a4b0d30 100644
--- a/include/asm-sparc/chmctrl.h
+++ b/arch/sparc/include/asm/chmctrl.h
diff --git a/include/asm-sparc/clock.h b/arch/sparc/include/asm/clock.h
index 2cf99dadec56..2cf99dadec56 100644
--- a/include/asm-sparc/clock.h
+++ b/arch/sparc/include/asm/clock.h
diff --git a/include/asm-sparc/cmt.h b/arch/sparc/include/asm/cmt.h
index 870db5928577..870db5928577 100644
--- a/include/asm-sparc/cmt.h
+++ b/arch/sparc/include/asm/cmt.h
diff --git a/include/asm-sparc/compat.h b/arch/sparc/include/asm/compat.h
index f260b58f5ce9..f260b58f5ce9 100644
--- a/include/asm-sparc/compat.h
+++ b/arch/sparc/include/asm/compat.h
diff --git a/include/asm-sparc/compat_signal.h b/arch/sparc/include/asm/compat_signal.h
index b759eab9b51c..b759eab9b51c 100644
--- a/include/asm-sparc/compat_signal.h
+++ b/arch/sparc/include/asm/compat_signal.h
diff --git a/include/asm-sparc/contregs.h b/arch/sparc/include/asm/contregs.h
index 48fa8a4ef357..48fa8a4ef357 100644
--- a/include/asm-sparc/contregs.h
+++ b/arch/sparc/include/asm/contregs.h
diff --git a/include/asm-sparc/cpudata.h b/arch/sparc/include/asm/cpudata.h
index b76fac0c8d8f..b5976de7cacd 100644
--- a/include/asm-sparc/cpudata.h
+++ b/arch/sparc/include/asm/cpudata.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_CPUDATA_H 1#ifndef ___ASM_SPARC_CPUDATA_H
2#define ___ASM_SPARC_CPUDATA_H 2#define ___ASM_SPARC_CPUDATA_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/cpudata_64.h> 4#include <asm/cpudata_64.h>
5#else 5#else
6#include <asm-sparc/cpudata_32.h> 6#include <asm/cpudata_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/cpudata_32.h b/arch/sparc/include/asm/cpudata_32.h
index a2c4d51d36c4..31d48a0e32c7 100644
--- a/include/asm-sparc/cpudata_32.h
+++ b/arch/sparc/include/asm/cpudata_32.h
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright (C) 2004 Keith M Wesolowski (wesolows@foobazco.org) 3 * Copyright (C) 2004 Keith M Wesolowski (wesolows@foobazco.org)
4 * 4 *
5 * Based on include/asm-sparc64/cpudata.h and Linux 2.4 smp.h 5 * Based on include/asm/cpudata.h and Linux 2.4 smp.h
6 * both (C) David S. Miller. 6 * both (C) David S. Miller.
7 */ 7 */
8 8
diff --git a/include/asm-sparc/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index 532975ecfe10..532975ecfe10 100644
--- a/include/asm-sparc/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
diff --git a/include/asm-sparc/cputime.h b/arch/sparc/include/asm/cputime.h
index 1a642b81e019..1a642b81e019 100644
--- a/include/asm-sparc/cputime.h
+++ b/arch/sparc/include/asm/cputime.h
diff --git a/include/asm-sparc/current.h b/arch/sparc/include/asm/current.h
index 8a1d9d6643b0..10a0df55a574 100644
--- a/include/asm-sparc/current.h
+++ b/arch/sparc/include/asm/current.h
@@ -1,4 +1,4 @@
1/* include/asm-sparc/current.h 1/* include/asm/current.h
2 * 2 *
3 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 3 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
4 * Copyright (C) 2002 Pete Zaitcev (zaitcev@yahoo.com) 4 * Copyright (C) 2002 Pete Zaitcev (zaitcev@yahoo.com)
diff --git a/include/asm-sparc/cypress.h b/arch/sparc/include/asm/cypress.h
index 95e9772ea394..95e9772ea394 100644
--- a/include/asm-sparc/cypress.h
+++ b/arch/sparc/include/asm/cypress.h
diff --git a/include/asm-sparc/dcr.h b/arch/sparc/include/asm/dcr.h
index 620c9ba642e9..620c9ba642e9 100644
--- a/include/asm-sparc/dcr.h
+++ b/arch/sparc/include/asm/dcr.h
diff --git a/include/asm-sparc/dcu.h b/arch/sparc/include/asm/dcu.h
index 0f704e106a1b..0f704e106a1b 100644
--- a/include/asm-sparc/dcu.h
+++ b/arch/sparc/include/asm/dcu.h
diff --git a/include/asm-sparc/delay.h b/arch/sparc/include/asm/delay.h
index 6210a3ce9751..467caa2a97a0 100644
--- a/include/asm-sparc/delay.h
+++ b/arch/sparc/include/asm/delay.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_DELAY_H 1#ifndef ___ASM_SPARC_DELAY_H
2#define ___ASM_SPARC_DELAY_H 2#define ___ASM_SPARC_DELAY_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/delay_64.h> 4#include <asm/delay_64.h>
5#else 5#else
6#include <asm-sparc/delay_32.h> 6#include <asm/delay_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/delay_32.h b/arch/sparc/include/asm/delay_32.h
index bc9aba2bead6..bc9aba2bead6 100644
--- a/include/asm-sparc/delay_32.h
+++ b/arch/sparc/include/asm/delay_32.h
diff --git a/include/asm-sparc/delay_64.h b/arch/sparc/include/asm/delay_64.h
index a77aa622d762..a77aa622d762 100644
--- a/include/asm-sparc/delay_64.h
+++ b/arch/sparc/include/asm/delay_64.h
diff --git a/include/asm-sparc/device.h b/arch/sparc/include/asm/device.h
index 19790eb99cc6..19790eb99cc6 100644
--- a/include/asm-sparc/device.h
+++ b/arch/sparc/include/asm/device.h
diff --git a/include/asm-sparc/display7seg.h b/arch/sparc/include/asm/display7seg.h
index 86d4a901df24..86d4a901df24 100644
--- a/include/asm-sparc/display7seg.h
+++ b/arch/sparc/include/asm/display7seg.h
diff --git a/include/asm-sparc/div64.h b/arch/sparc/include/asm/div64.h
index 6cd978cefb28..6cd978cefb28 100644
--- a/include/asm-sparc/div64.h
+++ b/arch/sparc/include/asm/div64.h
diff --git a/include/asm-sparc/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 7483504259ce..0f4150e26619 100644
--- a/include/asm-sparc/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_DMA_MAPPING_H 1#ifndef ___ASM_SPARC_DMA_MAPPING_H
2#define ___ASM_SPARC_DMA_MAPPING_H 2#define ___ASM_SPARC_DMA_MAPPING_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/dma-mapping_64.h> 4#include <asm/dma-mapping_64.h>
5#else 5#else
6#include <asm-sparc/dma-mapping_32.h> 6#include <asm/dma-mapping_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/dma-mapping_32.h b/arch/sparc/include/asm/dma-mapping_32.h
index f3a641e6b2c8..f3a641e6b2c8 100644
--- a/include/asm-sparc/dma-mapping_32.h
+++ b/arch/sparc/include/asm/dma-mapping_32.h
diff --git a/include/asm-sparc/dma-mapping_64.h b/arch/sparc/include/asm/dma-mapping_64.h
index 38cbec76a33f..bfa64f9702d5 100644
--- a/include/asm-sparc/dma-mapping_64.h
+++ b/arch/sparc/include/asm/dma-mapping_64.h
@@ -135,7 +135,7 @@ static inline void dma_sync_sg_for_device(struct device *dev,
135 /* No flushing needed to sync cpu writes to the device. */ 135 /* No flushing needed to sync cpu writes to the device. */
136} 136}
137 137
138static inline int dma_mapping_error(dma_addr_t dma_addr) 138static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
139{ 139{
140 return (dma_addr == DMA_ERROR_CODE); 140 return (dma_addr == DMA_ERROR_CODE);
141} 141}
diff --git a/include/asm-sparc/dma.h b/arch/sparc/include/asm/dma.h
index 8cc69bfaae2a..aa1d90ac04c5 100644
--- a/include/asm-sparc/dma.h
+++ b/arch/sparc/include/asm/dma.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_DMA_H 1#ifndef ___ASM_SPARC_DMA_H
2#define ___ASM_SPARC_DMA_H 2#define ___ASM_SPARC_DMA_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/dma_64.h> 4#include <asm/dma_64.h>
5#else 5#else
6#include <asm-sparc/dma_32.h> 6#include <asm/dma_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/dma_32.h b/arch/sparc/include/asm/dma_32.h
index 959d6c8a71ae..cf7189c0079b 100644
--- a/include/asm-sparc/dma_32.h
+++ b/arch/sparc/include/asm/dma_32.h
@@ -1,4 +1,4 @@
1/* include/asm-sparc/dma.h 1/* include/asm/dma.h
2 * 2 *
3 * Copyright 1995 (C) David S. Miller (davem@davemloft.net) 3 * Copyright 1995 (C) David S. Miller (davem@davemloft.net)
4 */ 4 */
diff --git a/include/asm-sparc/dma_64.h b/arch/sparc/include/asm/dma_64.h
index 9d4c024bd3b3..46a8aecffc02 100644
--- a/include/asm-sparc/dma_64.h
+++ b/arch/sparc/include/asm/dma_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc64/dma.h 2 * include/asm/dma.h
3 * 3 *
4 * Copyright 1996 (C) David S. Miller (davem@caip.rutgers.edu) 4 * Copyright 1996 (C) David S. Miller (davem@caip.rutgers.edu)
5 */ 5 */
diff --git a/include/asm-sparc/ebus.h b/arch/sparc/include/asm/ebus.h
index a5da2d00cd18..83a6d16c22e6 100644
--- a/include/asm-sparc/ebus.h
+++ b/arch/sparc/include/asm/ebus.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_EBUS_H 1#ifndef ___ASM_SPARC_EBUS_H
2#define ___ASM_SPARC_EBUS_H 2#define ___ASM_SPARC_EBUS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/ebus_64.h> 4#include <asm/ebus_64.h>
5#else 5#else
6#include <asm-sparc/ebus_32.h> 6#include <asm/ebus_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/ebus_32.h b/arch/sparc/include/asm/ebus_32.h
index 29cb7dfc6b79..29cb7dfc6b79 100644
--- a/include/asm-sparc/ebus_32.h
+++ b/arch/sparc/include/asm/ebus_32.h
diff --git a/include/asm-sparc/ebus_64.h b/arch/sparc/include/asm/ebus_64.h
index fcc62b97ced5..fcc62b97ced5 100644
--- a/include/asm-sparc/ebus_64.h
+++ b/arch/sparc/include/asm/ebus_64.h
diff --git a/include/asm-sparc/ecc.h b/arch/sparc/include/asm/ecc.h
index ccb84b66fef1..ccb84b66fef1 100644
--- a/include/asm-sparc/ecc.h
+++ b/arch/sparc/include/asm/ecc.h
diff --git a/include/asm-sparc/eeprom.h b/arch/sparc/include/asm/eeprom.h
index e17beeceb405..e17beeceb405 100644
--- a/include/asm-sparc/eeprom.h
+++ b/arch/sparc/include/asm/eeprom.h
diff --git a/include/asm-sparc/elf.h b/arch/sparc/include/asm/elf.h
index f035c45d7b5e..0a2816c50b07 100644
--- a/include/asm-sparc/elf.h
+++ b/arch/sparc/include/asm/elf.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_ELF_H 1#ifndef ___ASM_SPARC_ELF_H
2#define ___ASM_SPARC_ELF_H 2#define ___ASM_SPARC_ELF_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/elf_64.h> 4#include <asm/elf_64.h>
5#else 5#else
6#include <asm-sparc/elf_32.h> 6#include <asm/elf_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/elf_32.h b/arch/sparc/include/asm/elf_32.h
index d043f80bc2fd..d043f80bc2fd 100644
--- a/include/asm-sparc/elf_32.h
+++ b/arch/sparc/include/asm/elf_32.h
diff --git a/include/asm-sparc/elf_64.h b/arch/sparc/include/asm/elf_64.h
index 0818a1308f4e..0818a1308f4e 100644
--- a/include/asm-sparc/elf_64.h
+++ b/arch/sparc/include/asm/elf_64.h
diff --git a/include/asm-sparc/emergency-restart.h b/arch/sparc/include/asm/emergency-restart.h
index 108d8c48e42e..108d8c48e42e 100644
--- a/include/asm-sparc/emergency-restart.h
+++ b/arch/sparc/include/asm/emergency-restart.h
diff --git a/include/asm-sparc/envctrl.h b/arch/sparc/include/asm/envctrl.h
index 624fa7e2da8e..624fa7e2da8e 100644
--- a/include/asm-sparc/envctrl.h
+++ b/arch/sparc/include/asm/envctrl.h
diff --git a/include/asm-sparc/errno.h b/arch/sparc/include/asm/errno.h
index a9ef172977de..a9ef172977de 100644
--- a/include/asm-sparc/errno.h
+++ b/arch/sparc/include/asm/errno.h
diff --git a/include/asm-sparc/estate.h b/arch/sparc/include/asm/estate.h
index 520c08560d1b..520c08560d1b 100644
--- a/include/asm-sparc/estate.h
+++ b/arch/sparc/include/asm/estate.h
diff --git a/include/asm-sparc/fb.h b/arch/sparc/include/asm/fb.h
index b83e44729655..b83e44729655 100644
--- a/include/asm-sparc/fb.h
+++ b/arch/sparc/include/asm/fb.h
diff --git a/include/asm-sparc/fbio.h b/arch/sparc/include/asm/fbio.h
index b9215a0907d3..b9215a0907d3 100644
--- a/include/asm-sparc/fbio.h
+++ b/arch/sparc/include/asm/fbio.h
diff --git a/include/asm-sparc/fcntl.h b/arch/sparc/include/asm/fcntl.h
index d4d9c9d852c3..d4d9c9d852c3 100644
--- a/include/asm-sparc/fcntl.h
+++ b/arch/sparc/include/asm/fcntl.h
diff --git a/include/asm-sparc/fhc.h b/arch/sparc/include/asm/fhc.h
index 788cbc46a116..788cbc46a116 100644
--- a/include/asm-sparc/fhc.h
+++ b/arch/sparc/include/asm/fhc.h
diff --git a/include/asm-sparc/fixmap.h b/arch/sparc/include/asm/fixmap.h
index f18fc0755adf..f18fc0755adf 100644
--- a/include/asm-sparc/fixmap.h
+++ b/arch/sparc/include/asm/fixmap.h
diff --git a/include/asm-sparc/floppy.h b/arch/sparc/include/asm/floppy.h
index 6c628ba15a8d..faebd335b600 100644
--- a/include/asm-sparc/floppy.h
+++ b/arch/sparc/include/asm/floppy.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_FLOPPY_H 1#ifndef ___ASM_SPARC_FLOPPY_H
2#define ___ASM_SPARC_FLOPPY_H 2#define ___ASM_SPARC_FLOPPY_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/floppy_64.h> 4#include <asm/floppy_64.h>
5#else 5#else
6#include <asm-sparc/floppy_32.h> 6#include <asm/floppy_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/floppy_32.h b/arch/sparc/include/asm/floppy_32.h
index acdd06eafe59..ae3f00bf22ff 100644
--- a/include/asm-sparc/floppy_32.h
+++ b/arch/sparc/include/asm/floppy_32.h
@@ -1,4 +1,4 @@
1/* asm-sparc/floppy.h: Sparc specific parts of the Floppy driver. 1/* asm/floppy.h: Sparc specific parts of the Floppy driver.
2 * 2 *
3 * Copyright (C) 1995 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
4 */ 4 */
diff --git a/include/asm-sparc/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
index c39db1060bc7..c39db1060bc7 100644
--- a/include/asm-sparc/floppy_64.h
+++ b/arch/sparc/include/asm/floppy_64.h
diff --git a/include/asm-sparc/fpumacro.h b/arch/sparc/include/asm/fpumacro.h
index cc463fec806f..cc463fec806f 100644
--- a/include/asm-sparc/fpumacro.h
+++ b/arch/sparc/include/asm/fpumacro.h
diff --git a/include/asm-sparc64/ftrace.h b/arch/sparc/include/asm/ftrace.h
index d27716cd38c1..d27716cd38c1 100644
--- a/include/asm-sparc64/ftrace.h
+++ b/arch/sparc/include/asm/ftrace.h
diff --git a/include/asm-sparc/futex.h b/arch/sparc/include/asm/futex.h
index c6a9f038c531..736335f36713 100644
--- a/include/asm-sparc/futex.h
+++ b/arch/sparc/include/asm/futex.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_FUTEX_H 1#ifndef ___ASM_SPARC_FUTEX_H
2#define ___ASM_SPARC_FUTEX_H 2#define ___ASM_SPARC_FUTEX_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/futex_64.h> 4#include <asm/futex_64.h>
5#else 5#else
6#include <asm-sparc/futex_32.h> 6#include <asm/futex_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/futex_32.h b/arch/sparc/include/asm/futex_32.h
index 6a332a9f099c..6a332a9f099c 100644
--- a/include/asm-sparc/futex_32.h
+++ b/arch/sparc/include/asm/futex_32.h
diff --git a/include/asm-sparc/futex_64.h b/arch/sparc/include/asm/futex_64.h
index d8378935ae90..d8378935ae90 100644
--- a/include/asm-sparc/futex_64.h
+++ b/arch/sparc/include/asm/futex_64.h
diff --git a/include/asm-sparc/hardirq.h b/arch/sparc/include/asm/hardirq.h
index 156478773100..44d4e2345148 100644
--- a/include/asm-sparc/hardirq.h
+++ b/arch/sparc/include/asm/hardirq.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_HARDIRQ_H 1#ifndef ___ASM_SPARC_HARDIRQ_H
2#define ___ASM_SPARC_HARDIRQ_H 2#define ___ASM_SPARC_HARDIRQ_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/hardirq_64.h> 4#include <asm/hardirq_64.h>
5#else 5#else
6#include <asm-sparc/hardirq_32.h> 6#include <asm/hardirq_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/hardirq_32.h b/arch/sparc/include/asm/hardirq_32.h
index 4f63ed8df551..4f63ed8df551 100644
--- a/include/asm-sparc/hardirq_32.h
+++ b/arch/sparc/include/asm/hardirq_32.h
diff --git a/include/asm-sparc/hardirq_64.h b/arch/sparc/include/asm/hardirq_64.h
index 7c29fd1a87aa..7c29fd1a87aa 100644
--- a/include/asm-sparc/hardirq_64.h
+++ b/arch/sparc/include/asm/hardirq_64.h
diff --git a/include/asm-sparc/head.h b/arch/sparc/include/asm/head.h
index 14652abdea31..be8f03f3e731 100644
--- a/include/asm-sparc/head.h
+++ b/arch/sparc/include/asm/head.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_HEAD_H 1#ifndef ___ASM_SPARC_HEAD_H
2#define ___ASM_SPARC_HEAD_H 2#define ___ASM_SPARC_HEAD_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/head_64.h> 4#include <asm/head_64.h>
5#else 5#else
6#include <asm-sparc/head_32.h> 6#include <asm/head_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/head_32.h b/arch/sparc/include/asm/head_32.h
index 7c35491a8b53..7c35491a8b53 100644
--- a/include/asm-sparc/head_32.h
+++ b/arch/sparc/include/asm/head_32.h
diff --git a/include/asm-sparc/head_64.h b/arch/sparc/include/asm/head_64.h
index 10e9dabc4c41..10e9dabc4c41 100644
--- a/include/asm-sparc/head_64.h
+++ b/arch/sparc/include/asm/head_64.h
diff --git a/include/asm-sparc/highmem.h b/arch/sparc/include/asm/highmem.h
index 3de42e776274..3de42e776274 100644
--- a/include/asm-sparc/highmem.h
+++ b/arch/sparc/include/asm/highmem.h
diff --git a/include/asm-sparc/hugetlb.h b/arch/sparc/include/asm/hugetlb.h
index 177061064ee6..177061064ee6 100644
--- a/include/asm-sparc/hugetlb.h
+++ b/arch/sparc/include/asm/hugetlb.h
diff --git a/include/asm-sparc/hvtramp.h b/arch/sparc/include/asm/hvtramp.h
index b2b9b947b3a4..b2b9b947b3a4 100644
--- a/include/asm-sparc/hvtramp.h
+++ b/arch/sparc/include/asm/hvtramp.h
diff --git a/include/asm-sparc/hw_irq.h b/arch/sparc/include/asm/hw_irq.h
index 8d30a7694be2..8d30a7694be2 100644
--- a/include/asm-sparc/hw_irq.h
+++ b/arch/sparc/include/asm/hw_irq.h
diff --git a/include/asm-sparc/hypervisor.h b/arch/sparc/include/asm/hypervisor.h
index 109ae24ba242..109ae24ba242 100644
--- a/include/asm-sparc/hypervisor.h
+++ b/arch/sparc/include/asm/hypervisor.h
diff --git a/include/asm-sparc/ide.h b/arch/sparc/include/asm/ide.h
index b7af3d658239..b7af3d658239 100644
--- a/include/asm-sparc/ide.h
+++ b/arch/sparc/include/asm/ide.h
diff --git a/include/asm-sparc/idprom.h b/arch/sparc/include/asm/idprom.h
index 6976aa2439c6..6976aa2439c6 100644
--- a/include/asm-sparc/idprom.h
+++ b/arch/sparc/include/asm/idprom.h
diff --git a/include/asm-sparc/intr_queue.h b/arch/sparc/include/asm/intr_queue.h
index 206077dedc2a..206077dedc2a 100644
--- a/include/asm-sparc/intr_queue.h
+++ b/arch/sparc/include/asm/intr_queue.h
diff --git a/include/asm-sparc/io-unit.h b/arch/sparc/include/asm/io-unit.h
index 96823b47fd45..96823b47fd45 100644
--- a/include/asm-sparc/io-unit.h
+++ b/arch/sparc/include/asm/io-unit.h
diff --git a/include/asm-sparc/io.h b/arch/sparc/include/asm/io.h
index fc9024d3dfc3..a34b2994937a 100644
--- a/include/asm-sparc/io.h
+++ b/arch/sparc/include/asm/io.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_IO_H 1#ifndef ___ASM_SPARC_IO_H
2#define ___ASM_SPARC_IO_H 2#define ___ASM_SPARC_IO_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/io_64.h> 4#include <asm/io_64.h>
5#else 5#else
6#include <asm-sparc/io_32.h> 6#include <asm/io_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/io_32.h b/arch/sparc/include/asm/io_32.h
index 10d7da450070..10d7da450070 100644
--- a/include/asm-sparc/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
diff --git a/include/asm-sparc/io_64.h b/arch/sparc/include/asm/io_64.h
index 0bff078ffdd0..0bff078ffdd0 100644
--- a/include/asm-sparc/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
diff --git a/include/asm-sparc/ioctl.h b/arch/sparc/include/asm/ioctl.h
index 7d6bd51321b9..7d6bd51321b9 100644
--- a/include/asm-sparc/ioctl.h
+++ b/arch/sparc/include/asm/ioctl.h
diff --git a/include/asm-sparc/ioctls.h b/arch/sparc/include/asm/ioctls.h
index 1fe6855c5c18..1fe6855c5c18 100644
--- a/include/asm-sparc/ioctls.h
+++ b/arch/sparc/include/asm/ioctls.h
diff --git a/include/asm-sparc/iommu.h b/arch/sparc/include/asm/iommu.h
index 91b072b0d7a0..e650965b4a8d 100644
--- a/include/asm-sparc/iommu.h
+++ b/arch/sparc/include/asm/iommu.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_IOMMU_H 1#ifndef ___ASM_SPARC_IOMMU_H
2#define ___ASM_SPARC_IOMMU_H 2#define ___ASM_SPARC_IOMMU_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/iommu_64.h> 4#include <asm/iommu_64.h>
5#else 5#else
6#include <asm-sparc/iommu_32.h> 6#include <asm/iommu_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/iommu_32.h b/arch/sparc/include/asm/iommu_32.h
index 70c589c05a10..70c589c05a10 100644
--- a/include/asm-sparc/iommu_32.h
+++ b/arch/sparc/include/asm/iommu_32.h
diff --git a/include/asm-sparc/iommu_64.h b/arch/sparc/include/asm/iommu_64.h
index d7b9afcba08b..d7b9afcba08b 100644
--- a/include/asm-sparc/iommu_64.h
+++ b/arch/sparc/include/asm/iommu_64.h
diff --git a/include/asm-sparc/ipcbuf.h b/arch/sparc/include/asm/ipcbuf.h
index 037605d986e2..17d6ef7b23a4 100644
--- a/include/asm-sparc/ipcbuf.h
+++ b/arch/sparc/include/asm/ipcbuf.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_IPCBUF_H 1#ifndef ___ASM_SPARC_IPCBUF_H
2#define ___ASM_SPARC_IPCBUF_H 2#define ___ASM_SPARC_IPCBUF_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/ipcbuf_64.h> 4#include <asm/ipcbuf_64.h>
5#else 5#else
6#include <asm-sparc/ipcbuf_32.h> 6#include <asm/ipcbuf_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/ipcbuf_32.h b/arch/sparc/include/asm/ipcbuf_32.h
index 6387209518f2..6387209518f2 100644
--- a/include/asm-sparc/ipcbuf_32.h
+++ b/arch/sparc/include/asm/ipcbuf_32.h
diff --git a/include/asm-sparc/ipcbuf_64.h b/arch/sparc/include/asm/ipcbuf_64.h
index a44b855b98db..a44b855b98db 100644
--- a/include/asm-sparc/ipcbuf_64.h
+++ b/arch/sparc/include/asm/ipcbuf_64.h
diff --git a/include/asm-sparc/irq.h b/arch/sparc/include/asm/irq.h
index 7af6bb4aa09c..3b44a6a14074 100644
--- a/include/asm-sparc/irq.h
+++ b/arch/sparc/include/asm/irq.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_IRQ_H 1#ifndef ___ASM_SPARC_IRQ_H
2#define ___ASM_SPARC_IRQ_H 2#define ___ASM_SPARC_IRQ_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/irq_64.h> 4#include <asm/irq_64.h>
5#else 5#else
6#include <asm-sparc/irq_32.h> 6#include <asm/irq_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/irq_32.h b/arch/sparc/include/asm/irq_32.h
index fe205cc444b8..fe205cc444b8 100644
--- a/include/asm-sparc/irq_32.h
+++ b/arch/sparc/include/asm/irq_32.h
diff --git a/include/asm-sparc/irq_64.h b/arch/sparc/include/asm/irq_64.h
index 0bb9bf531745..0bb9bf531745 100644
--- a/include/asm-sparc/irq_64.h
+++ b/arch/sparc/include/asm/irq_64.h
diff --git a/include/asm-sparc/irq_regs.h b/arch/sparc/include/asm/irq_regs.h
index 3dd9c0b70270..3dd9c0b70270 100644
--- a/include/asm-sparc/irq_regs.h
+++ b/arch/sparc/include/asm/irq_regs.h
diff --git a/include/asm-sparc/irqflags.h b/arch/sparc/include/asm/irqflags.h
index c6402b187e23..1e138632bd3f 100644
--- a/include/asm-sparc/irqflags.h
+++ b/arch/sparc/include/asm/irqflags.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_IRQFLAGS_H 1#ifndef ___ASM_SPARC_IRQFLAGS_H
2#define ___ASM_SPARC_IRQFLAGS_H 2#define ___ASM_SPARC_IRQFLAGS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/irqflags_64.h> 4#include <asm/irqflags_64.h>
5#else 5#else
6#include <asm-sparc/irqflags_32.h> 6#include <asm/irqflags_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/irqflags_32.h b/arch/sparc/include/asm/irqflags_32.h
index db398fb32826..0fca9d97d44f 100644
--- a/include/asm-sparc/irqflags_32.h
+++ b/arch/sparc/include/asm/irqflags_32.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc/irqflags.h 2 * include/asm/irqflags.h
3 * 3 *
4 * IRQ flags handling 4 * IRQ flags handling
5 * 5 *
diff --git a/include/asm-sparc/irqflags_64.h b/arch/sparc/include/asm/irqflags_64.h
index 024fc54d0682..bb42e59162aa 100644
--- a/include/asm-sparc/irqflags_64.h
+++ b/arch/sparc/include/asm/irqflags_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc64/irqflags.h 2 * include/asm/irqflags.h
3 * 3 *
4 * IRQ flags handling 4 * IRQ flags handling
5 * 5 *
diff --git a/include/asm-sparc/jsflash.h b/arch/sparc/include/asm/jsflash.h
index 3457f29bd73b..3457f29bd73b 100644
--- a/include/asm-sparc/jsflash.h
+++ b/arch/sparc/include/asm/jsflash.h
diff --git a/include/asm-sparc/kdebug.h b/arch/sparc/include/asm/kdebug.h
index fe07d00d0534..8d12581ca386 100644
--- a/include/asm-sparc/kdebug.h
+++ b/arch/sparc/include/asm/kdebug.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_KDEBUG_H 1#ifndef ___ASM_SPARC_KDEBUG_H
2#define ___ASM_SPARC_KDEBUG_H 2#define ___ASM_SPARC_KDEBUG_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/kdebug_64.h> 4#include <asm/kdebug_64.h>
5#else 5#else
6#include <asm-sparc/kdebug_32.h> 6#include <asm/kdebug_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/kdebug_32.h b/arch/sparc/include/asm/kdebug_32.h
index f69fe7d84b3c..f69fe7d84b3c 100644
--- a/include/asm-sparc/kdebug_32.h
+++ b/arch/sparc/include/asm/kdebug_32.h
diff --git a/include/asm-sparc/kdebug_64.h b/arch/sparc/include/asm/kdebug_64.h
index f905b773235a..f905b773235a 100644
--- a/include/asm-sparc/kdebug_64.h
+++ b/arch/sparc/include/asm/kdebug_64.h
diff --git a/include/asm-sparc/kgdb.h b/arch/sparc/include/asm/kgdb.h
index b6ef301d05bf..b6ef301d05bf 100644
--- a/include/asm-sparc/kgdb.h
+++ b/arch/sparc/include/asm/kgdb.h
diff --git a/include/asm-sparc/kmap_types.h b/arch/sparc/include/asm/kmap_types.h
index 602f5e034f7a..602f5e034f7a 100644
--- a/include/asm-sparc/kmap_types.h
+++ b/arch/sparc/include/asm/kmap_types.h
diff --git a/include/asm-sparc/kprobes.h b/arch/sparc/include/asm/kprobes.h
index 5879d71afdaa..5879d71afdaa 100644
--- a/include/asm-sparc/kprobes.h
+++ b/arch/sparc/include/asm/kprobes.h
diff --git a/include/asm-sparc/ldc.h b/arch/sparc/include/asm/ldc.h
index bdb524a7b814..bdb524a7b814 100644
--- a/include/asm-sparc/ldc.h
+++ b/arch/sparc/include/asm/ldc.h
diff --git a/include/asm-sparc/linkage.h b/arch/sparc/include/asm/linkage.h
index 291c2d01c44f..291c2d01c44f 100644
--- a/include/asm-sparc/linkage.h
+++ b/arch/sparc/include/asm/linkage.h
diff --git a/include/asm-sparc/lmb.h b/arch/sparc/include/asm/lmb.h
index 6a352cbcf520..6a352cbcf520 100644
--- a/include/asm-sparc/lmb.h
+++ b/arch/sparc/include/asm/lmb.h
diff --git a/include/asm-sparc/local.h b/arch/sparc/include/asm/local.h
index bc80815a435c..bc80815a435c 100644
--- a/include/asm-sparc/local.h
+++ b/arch/sparc/include/asm/local.h
diff --git a/include/asm-sparc/lsu.h b/arch/sparc/include/asm/lsu.h
index 7190f8de90a0..7190f8de90a0 100644
--- a/include/asm-sparc/lsu.h
+++ b/arch/sparc/include/asm/lsu.h
diff --git a/include/asm-sparc/machines.h b/arch/sparc/include/asm/machines.h
index c28c2f248794..c28c2f248794 100644
--- a/include/asm-sparc/machines.h
+++ b/arch/sparc/include/asm/machines.h
diff --git a/include/asm-sparc/mbus.h b/arch/sparc/include/asm/mbus.h
index 69f07a022ee6..69f07a022ee6 100644
--- a/include/asm-sparc/mbus.h
+++ b/arch/sparc/include/asm/mbus.h
diff --git a/include/asm-sparc/mc146818rtc.h b/arch/sparc/include/asm/mc146818rtc.h
index 9ab65c21e9e4..67ed9e3a0235 100644
--- a/include/asm-sparc/mc146818rtc.h
+++ b/arch/sparc/include/asm/mc146818rtc.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_MC146818RTC_H 1#ifndef ___ASM_SPARC_MC146818RTC_H
2#define ___ASM_SPARC_MC146818RTC_H 2#define ___ASM_SPARC_MC146818RTC_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/mc146818rtc_64.h> 4#include <asm/mc146818rtc_64.h>
5#else 5#else
6#include <asm-sparc/mc146818rtc_32.h> 6#include <asm/mc146818rtc_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/mc146818rtc_32.h b/arch/sparc/include/asm/mc146818rtc_32.h
index fa7eac926582..fa7eac926582 100644
--- a/include/asm-sparc/mc146818rtc_32.h
+++ b/arch/sparc/include/asm/mc146818rtc_32.h
diff --git a/include/asm-sparc/mc146818rtc_64.h b/arch/sparc/include/asm/mc146818rtc_64.h
index e9c0fcc25c6f..e9c0fcc25c6f 100644
--- a/include/asm-sparc/mc146818rtc_64.h
+++ b/arch/sparc/include/asm/mc146818rtc_64.h
diff --git a/include/asm-sparc/mdesc.h b/arch/sparc/include/asm/mdesc.h
index 1acc7272e537..1acc7272e537 100644
--- a/include/asm-sparc/mdesc.h
+++ b/arch/sparc/include/asm/mdesc.h
diff --git a/include/asm-sparc/memreg.h b/arch/sparc/include/asm/memreg.h
index 845ad2b39183..845ad2b39183 100644
--- a/include/asm-sparc/memreg.h
+++ b/arch/sparc/include/asm/memreg.h
diff --git a/include/asm-sparc/mman.h b/arch/sparc/include/asm/mman.h
index fdfbbf0a4736..fdfbbf0a4736 100644
--- a/include/asm-sparc/mman.h
+++ b/arch/sparc/include/asm/mman.h
diff --git a/include/asm-sparc/mmu.h b/arch/sparc/include/asm/mmu.h
index ee66bf6dcbd6..88fa313887db 100644
--- a/include/asm-sparc/mmu.h
+++ b/arch/sparc/include/asm/mmu.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_MMU_H 1#ifndef ___ASM_SPARC_MMU_H
2#define ___ASM_SPARC_MMU_H 2#define ___ASM_SPARC_MMU_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/mmu_64.h> 4#include <asm/mmu_64.h>
5#else 5#else
6#include <asm-sparc/mmu_32.h> 6#include <asm/mmu_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/mmu_32.h b/arch/sparc/include/asm/mmu_32.h
index ccd36d26615a..ccd36d26615a 100644
--- a/include/asm-sparc/mmu_32.h
+++ b/arch/sparc/include/asm/mmu_32.h
diff --git a/include/asm-sparc/mmu_64.h b/arch/sparc/include/asm/mmu_64.h
index 9067dc500535..9067dc500535 100644
--- a/include/asm-sparc/mmu_64.h
+++ b/arch/sparc/include/asm/mmu_64.h
diff --git a/include/asm-sparc/mmu_context.h b/arch/sparc/include/asm/mmu_context.h
index e14efb9532ff..5531346c64f9 100644
--- a/include/asm-sparc/mmu_context.h
+++ b/arch/sparc/include/asm/mmu_context.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_MMU_CONTEXT_H 1#ifndef ___ASM_SPARC_MMU_CONTEXT_H
2#define ___ASM_SPARC_MMU_CONTEXT_H 2#define ___ASM_SPARC_MMU_CONTEXT_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/mmu_context_64.h> 4#include <asm/mmu_context_64.h>
5#else 5#else
6#include <asm-sparc/mmu_context_32.h> 6#include <asm/mmu_context_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/mmu_context_32.h b/arch/sparc/include/asm/mmu_context_32.h
index 671a997b9e69..671a997b9e69 100644
--- a/include/asm-sparc/mmu_context_32.h
+++ b/arch/sparc/include/asm/mmu_context_32.h
diff --git a/include/asm-sparc/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h
index 5693ab482606..5693ab482606 100644
--- a/include/asm-sparc/mmu_context_64.h
+++ b/arch/sparc/include/asm/mmu_context_64.h
diff --git a/include/asm-sparc/mmzone.h b/arch/sparc/include/asm/mmzone.h
index ebf5986c12ed..ebf5986c12ed 100644
--- a/include/asm-sparc/mmzone.h
+++ b/arch/sparc/include/asm/mmzone.h
diff --git a/include/asm-sparc/module.h b/arch/sparc/include/asm/module.h
index 516138fe681a..e82cf9a3e60e 100644
--- a/include/asm-sparc/module.h
+++ b/arch/sparc/include/asm/module.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_MODULE_H 1#ifndef ___ASM_SPARC_MODULE_H
2#define ___ASM_SPARC_MODULE_H 2#define ___ASM_SPARC_MODULE_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/module_64.h> 4#include <asm/module_64.h>
5#else 5#else
6#include <asm-sparc/module_32.h> 6#include <asm/module_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/module_32.h b/arch/sparc/include/asm/module_32.h
index cbd9e67b0c0b..cbd9e67b0c0b 100644
--- a/include/asm-sparc/module_32.h
+++ b/arch/sparc/include/asm/module_32.h
diff --git a/include/asm-sparc/module_64.h b/arch/sparc/include/asm/module_64.h
index 3d77ba465783..3d77ba465783 100644
--- a/include/asm-sparc/module_64.h
+++ b/arch/sparc/include/asm/module_64.h
diff --git a/include/asm-sparc/mostek.h b/arch/sparc/include/asm/mostek.h
index 5b9f7fec7ee7..433be3e0a69b 100644
--- a/include/asm-sparc/mostek.h
+++ b/arch/sparc/include/asm/mostek.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_MOSTEK_H 1#ifndef ___ASM_SPARC_MOSTEK_H
2#define ___ASM_SPARC_MOSTEK_H 2#define ___ASM_SPARC_MOSTEK_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/mostek_64.h> 4#include <asm/mostek_64.h>
5#else 5#else
6#include <asm-sparc/mostek_32.h> 6#include <asm/mostek_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/mostek_32.h b/arch/sparc/include/asm/mostek_32.h
index a99590c4c507..a99590c4c507 100644
--- a/include/asm-sparc/mostek_32.h
+++ b/arch/sparc/include/asm/mostek_32.h
diff --git a/include/asm-sparc/mostek_64.h b/arch/sparc/include/asm/mostek_64.h
index c5652de2ace2..c5652de2ace2 100644
--- a/include/asm-sparc/mostek_64.h
+++ b/arch/sparc/include/asm/mostek_64.h
diff --git a/include/asm-sparc/mpmbox.h b/arch/sparc/include/asm/mpmbox.h
index f8423039b242..f8423039b242 100644
--- a/include/asm-sparc/mpmbox.h
+++ b/arch/sparc/include/asm/mpmbox.h
diff --git a/include/asm-sparc/msgbuf.h b/arch/sparc/include/asm/msgbuf.h
index efc7cbe9788f..efc7cbe9788f 100644
--- a/include/asm-sparc/msgbuf.h
+++ b/arch/sparc/include/asm/msgbuf.h
diff --git a/include/asm-sparc/msi.h b/arch/sparc/include/asm/msi.h
index 724ca5667052..724ca5667052 100644
--- a/include/asm-sparc/msi.h
+++ b/arch/sparc/include/asm/msi.h
diff --git a/include/asm-sparc/mutex.h b/arch/sparc/include/asm/mutex.h
index 458c1f7fbc18..458c1f7fbc18 100644
--- a/include/asm-sparc/mutex.h
+++ b/arch/sparc/include/asm/mutex.h
diff --git a/include/asm-sparc/mxcc.h b/arch/sparc/include/asm/mxcc.h
index c0517bd05bde..c0517bd05bde 100644
--- a/include/asm-sparc/mxcc.h
+++ b/arch/sparc/include/asm/mxcc.h
diff --git a/include/asm-sparc/ns87303.h b/arch/sparc/include/asm/ns87303.h
index 686defe6aaa0..686defe6aaa0 100644
--- a/include/asm-sparc/ns87303.h
+++ b/arch/sparc/include/asm/ns87303.h
diff --git a/include/asm-sparc/obio.h b/arch/sparc/include/asm/obio.h
index 1a7544ceb574..1a7544ceb574 100644
--- a/include/asm-sparc/obio.h
+++ b/arch/sparc/include/asm/obio.h
diff --git a/include/asm-sparc/of_device.h b/arch/sparc/include/asm/of_device.h
index e5f5aedc2293..e5f5aedc2293 100644
--- a/include/asm-sparc/of_device.h
+++ b/arch/sparc/include/asm/of_device.h
diff --git a/include/asm-sparc/of_platform.h b/arch/sparc/include/asm/of_platform.h
index 851eb84d737e..aa699775ffba 100644
--- a/include/asm-sparc/of_platform.h
+++ b/arch/sparc/include/asm/of_platform.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_OF_PLATFORM_H 1#ifndef ___ASM_SPARC_OF_PLATFORM_H
2#define ___ASM_SPARC_OF_PLATFORM_H 2#define ___ASM_SPARC_OF_PLATFORM_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/of_platform_64.h> 4#include <asm/of_platform_64.h>
5#else 5#else
6#include <asm-sparc/of_platform_32.h> 6#include <asm/of_platform_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/of_platform_32.h b/arch/sparc/include/asm/of_platform_32.h
index 38334351c36b..723f7c9b7411 100644
--- a/include/asm-sparc/of_platform_32.h
+++ b/arch/sparc/include/asm/of_platform_32.h
@@ -3,7 +3,7 @@
3/* 3/*
4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. 4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org> 5 * <benh@kernel.crashing.org>
6 * Modified for Sparc by merging parts of asm-sparc/of_device.h 6 * Modified for Sparc by merging parts of asm/of_device.h
7 * by Stephen Rothwell 7 * by Stephen Rothwell
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/include/asm-sparc/of_platform_64.h b/arch/sparc/include/asm/of_platform_64.h
index 78aa032b674c..4f66a5f6342d 100644
--- a/include/asm-sparc/of_platform_64.h
+++ b/arch/sparc/include/asm/of_platform_64.h
@@ -3,7 +3,7 @@
3/* 3/*
4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp. 4 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org> 5 * <benh@kernel.crashing.org>
6 * Modified for Sparc by merging parts of asm-sparc/of_device.h 6 * Modified for Sparc by merging parts of asm/of_device.h
7 * by Stephen Rothwell 7 * by Stephen Rothwell
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/include/asm-sparc/openprom.h b/arch/sparc/include/asm/openprom.h
index 8c349f061994..aaeae905ed3f 100644
--- a/include/asm-sparc/openprom.h
+++ b/arch/sparc/include/asm/openprom.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_OPENPROM_H 1#ifndef ___ASM_SPARC_OPENPROM_H
2#define ___ASM_SPARC_OPENPROM_H 2#define ___ASM_SPARC_OPENPROM_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/openprom_64.h> 4#include <asm/openprom_64.h>
5#else 5#else
6#include <asm-sparc/openprom_32.h> 6#include <asm/openprom_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/openprom_32.h b/arch/sparc/include/asm/openprom_32.h
index 8b1649f29ed9..8b1649f29ed9 100644
--- a/include/asm-sparc/openprom_32.h
+++ b/arch/sparc/include/asm/openprom_32.h
diff --git a/include/asm-sparc/openprom_64.h b/arch/sparc/include/asm/openprom_64.h
index b69e4a8c9170..b69e4a8c9170 100644
--- a/include/asm-sparc/openprom_64.h
+++ b/arch/sparc/include/asm/openprom_64.h
diff --git a/include/asm-sparc/openpromio.h b/arch/sparc/include/asm/openpromio.h
index 917fb8e9c633..917fb8e9c633 100644
--- a/include/asm-sparc/openpromio.h
+++ b/arch/sparc/include/asm/openpromio.h
diff --git a/include/asm-sparc/oplib.h b/arch/sparc/include/asm/oplib.h
index e88d7c04a292..72e04e13a6b4 100644
--- a/include/asm-sparc/oplib.h
+++ b/arch/sparc/include/asm/oplib.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_OPLIB_H 1#ifndef ___ASM_SPARC_OPLIB_H
2#define ___ASM_SPARC_OPLIB_H 2#define ___ASM_SPARC_OPLIB_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/oplib_64.h> 4#include <asm/oplib_64.h>
5#else 5#else
6#include <asm-sparc/oplib_32.h> 6#include <asm/oplib_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/oplib_32.h b/arch/sparc/include/asm/oplib_32.h
index b2631da259e0..b2631da259e0 100644
--- a/include/asm-sparc/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
diff --git a/include/asm-sparc/oplib_64.h b/arch/sparc/include/asm/oplib_64.h
index 6d2c2ca98039..6d2c2ca98039 100644
--- a/include/asm-sparc/oplib_64.h
+++ b/arch/sparc/include/asm/oplib_64.h
diff --git a/include/asm-sparc/page.h b/arch/sparc/include/asm/page.h
index f32f49fcf75c..f21de0349025 100644
--- a/include/asm-sparc/page.h
+++ b/arch/sparc/include/asm/page.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PAGE_H 1#ifndef ___ASM_SPARC_PAGE_H
2#define ___ASM_SPARC_PAGE_H 2#define ___ASM_SPARC_PAGE_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/page_64.h> 4#include <asm/page_64.h>
5#else 5#else
6#include <asm-sparc/page_32.h> 6#include <asm/page_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/page_32.h b/arch/sparc/include/asm/page_32.h
index cf5fb70ca1c1..cf5fb70ca1c1 100644
--- a/include/asm-sparc/page_32.h
+++ b/arch/sparc/include/asm/page_32.h
diff --git a/include/asm-sparc/page_64.h b/arch/sparc/include/asm/page_64.h
index b579b910ef51..b579b910ef51 100644
--- a/include/asm-sparc/page_64.h
+++ b/arch/sparc/include/asm/page_64.h
diff --git a/include/asm-sparc/param.h b/arch/sparc/include/asm/param.h
index 9836d9a3cb9a..9836d9a3cb9a 100644
--- a/include/asm-sparc/param.h
+++ b/arch/sparc/include/asm/param.h
diff --git a/include/asm-sparc/parport.h b/arch/sparc/include/asm/parport.h
index 7818b2523b8d..7818b2523b8d 100644
--- a/include/asm-sparc/parport.h
+++ b/arch/sparc/include/asm/parport.h
diff --git a/include/asm-sparc/pbm.h b/arch/sparc/include/asm/pbm.h
index 458a4916d14d..458a4916d14d 100644
--- a/include/asm-sparc/pbm.h
+++ b/arch/sparc/include/asm/pbm.h
diff --git a/include/asm-sparc/pci.h b/arch/sparc/include/asm/pci.h
index b807d52a4809..6e14fd179335 100644
--- a/include/asm-sparc/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PCI_H 1#ifndef ___ASM_SPARC_PCI_H
2#define ___ASM_SPARC_PCI_H 2#define ___ASM_SPARC_PCI_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/pci_64.h> 4#include <asm/pci_64.h>
5#else 5#else
6#include <asm-sparc/pci_32.h> 6#include <asm/pci_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/pci_32.h b/arch/sparc/include/asm/pci_32.h
index b93b6c79e08f..0ee949d220c0 100644
--- a/include/asm-sparc/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -154,7 +154,8 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
154 154
155#define PCI_DMA_ERROR_CODE (~(dma_addr_t)0x0) 155#define PCI_DMA_ERROR_CODE (~(dma_addr_t)0x0)
156 156
157static inline int pci_dma_mapping_error(dma_addr_t dma_addr) 157static inline int pci_dma_mapping_error(struct pci_dev *pdev,
158 dma_addr_t dma_addr)
158{ 159{
159 return (dma_addr == PCI_DMA_ERROR_CODE); 160 return (dma_addr == PCI_DMA_ERROR_CODE);
160} 161}
diff --git a/include/asm-sparc/pci_64.h b/arch/sparc/include/asm/pci_64.h
index f59f2571295b..4f79a54948f6 100644
--- a/include/asm-sparc/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -140,9 +140,10 @@ extern int pci_dma_supported(struct pci_dev *hwdev, u64 mask);
140#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0) 140#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0)
141#define PCI64_ADDR_BASE 0xfffc000000000000UL 141#define PCI64_ADDR_BASE 0xfffc000000000000UL
142 142
143static inline int pci_dma_mapping_error(dma_addr_t dma_addr) 143static inline int pci_dma_mapping_error(struct pci_dev *pdev,
144 dma_addr_t dma_addr)
144{ 145{
145 return dma_mapping_error(dma_addr); 146 return dma_mapping_error(&pdev->dev, dma_addr);
146} 147}
147 148
148#ifdef CONFIG_PCI 149#ifdef CONFIG_PCI
diff --git a/include/asm-sparc/pcic.h b/arch/sparc/include/asm/pcic.h
index f20ef562b265..f20ef562b265 100644
--- a/include/asm-sparc/pcic.h
+++ b/arch/sparc/include/asm/pcic.h
diff --git a/include/asm-sparc/percpu.h b/arch/sparc/include/asm/percpu.h
index d98ed6cf2e36..bfb1d19ff1bf 100644
--- a/include/asm-sparc/percpu.h
+++ b/arch/sparc/include/asm/percpu.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PERCPU_H 1#ifndef ___ASM_SPARC_PERCPU_H
2#define ___ASM_SPARC_PERCPU_H 2#define ___ASM_SPARC_PERCPU_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/percpu_64.h> 4#include <asm/percpu_64.h>
5#else 5#else
6#include <asm-sparc/percpu_32.h> 6#include <asm/percpu_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/percpu_32.h b/arch/sparc/include/asm/percpu_32.h
index 06066a7aaec3..06066a7aaec3 100644
--- a/include/asm-sparc/percpu_32.h
+++ b/arch/sparc/include/asm/percpu_32.h
diff --git a/include/asm-sparc/percpu_64.h b/arch/sparc/include/asm/percpu_64.h
index bee64593023e..bee64593023e 100644
--- a/include/asm-sparc/percpu_64.h
+++ b/arch/sparc/include/asm/percpu_64.h
diff --git a/include/asm-sparc/perfctr.h b/arch/sparc/include/asm/perfctr.h
index 836873002b75..836873002b75 100644
--- a/include/asm-sparc/perfctr.h
+++ b/arch/sparc/include/asm/perfctr.h
diff --git a/include/asm-sparc/pgalloc.h b/arch/sparc/include/asm/pgalloc.h
index 7fa02b53d392..b6db1f7cdcab 100644
--- a/include/asm-sparc/pgalloc.h
+++ b/arch/sparc/include/asm/pgalloc.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PGALLOC_H 1#ifndef ___ASM_SPARC_PGALLOC_H
2#define ___ASM_SPARC_PGALLOC_H 2#define ___ASM_SPARC_PGALLOC_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/pgalloc_64.h> 4#include <asm/pgalloc_64.h>
5#else 5#else
6#include <asm-sparc/pgalloc_32.h> 6#include <asm/pgalloc_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
index 681582d26969..681582d26969 100644
--- a/include/asm-sparc/pgalloc_32.h
+++ b/arch/sparc/include/asm/pgalloc_32.h
diff --git a/include/asm-sparc/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
index 5bdfa2c6e400..5bdfa2c6e400 100644
--- a/include/asm-sparc/pgalloc_64.h
+++ b/arch/sparc/include/asm/pgalloc_64.h
diff --git a/include/asm-sparc/pgtable.h b/arch/sparc/include/asm/pgtable.h
index 63cdef53bc52..59ba6f620732 100644
--- a/include/asm-sparc/pgtable.h
+++ b/arch/sparc/include/asm/pgtable.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PGTABLE_H 1#ifndef ___ASM_SPARC_PGTABLE_H
2#define ___ASM_SPARC_PGTABLE_H 2#define ___ASM_SPARC_PGTABLE_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/pgtable_64.h> 4#include <asm/pgtable_64.h>
5#else 5#else
6#include <asm-sparc/pgtable_32.h> 6#include <asm/pgtable_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 781bd4694a1c..08237fda8874 100644
--- a/include/asm-sparc/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -1,7 +1,7 @@
1#ifndef _SPARC_PGTABLE_H 1#ifndef _SPARC_PGTABLE_H
2#define _SPARC_PGTABLE_H 2#define _SPARC_PGTABLE_H
3 3
4/* asm-sparc/pgtable.h: Defines and functions used to work 4/* asm/pgtable.h: Defines and functions used to work
5 * with Sparc page tables. 5 * with Sparc page tables.
6 * 6 *
7 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 7 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
diff --git a/include/asm-sparc/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index bb9ec2cce355..bb9ec2cce355 100644
--- a/include/asm-sparc/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
diff --git a/include/asm-sparc/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
index 808555fc1d58..808555fc1d58 100644
--- a/include/asm-sparc/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
diff --git a/include/asm-sparc/pgtsun4.h b/arch/sparc/include/asm/pgtsun4.h
index 5a0d661fb82e..5a0d661fb82e 100644
--- a/include/asm-sparc/pgtsun4.h
+++ b/arch/sparc/include/asm/pgtsun4.h
diff --git a/include/asm-sparc/pgtsun4c.h b/arch/sparc/include/asm/pgtsun4c.h
index aeb25e912179..aeb25e912179 100644
--- a/include/asm-sparc/pgtsun4c.h
+++ b/arch/sparc/include/asm/pgtsun4c.h
diff --git a/include/asm-sparc/pil.h b/arch/sparc/include/asm/pil.h
index 71819bb943fc..71819bb943fc 100644
--- a/include/asm-sparc/pil.h
+++ b/arch/sparc/include/asm/pil.h
diff --git a/include/asm-sparc/poll.h b/arch/sparc/include/asm/poll.h
index 091d3ad2e830..091d3ad2e830 100644
--- a/include/asm-sparc/poll.h
+++ b/arch/sparc/include/asm/poll.h
diff --git a/include/asm-sparc/posix_types.h b/arch/sparc/include/asm/posix_types.h
index 58c820d75e83..03a0e091a884 100644
--- a/include/asm-sparc/posix_types.h
+++ b/arch/sparc/include/asm/posix_types.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_POSIX_TYPES_H 1#ifndef ___ASM_SPARC_POSIX_TYPES_H
2#define ___ASM_SPARC_POSIX_TYPES_H 2#define ___ASM_SPARC_POSIX_TYPES_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/posix_types_64.h> 4#include <asm/posix_types_64.h>
5#else 5#else
6#include <asm-sparc/posix_types_32.h> 6#include <asm/posix_types_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/posix_types_32.h b/arch/sparc/include/asm/posix_types_32.h
index 6bb6eb1ca0f2..6bb6eb1ca0f2 100644
--- a/include/asm-sparc/posix_types_32.h
+++ b/arch/sparc/include/asm/posix_types_32.h
diff --git a/include/asm-sparc/posix_types_64.h b/arch/sparc/include/asm/posix_types_64.h
index ba8f93295763..ba8f93295763 100644
--- a/include/asm-sparc/posix_types_64.h
+++ b/arch/sparc/include/asm/posix_types_64.h
diff --git a/include/asm-sparc/processor.h b/arch/sparc/include/asm/processor.h
index 11a66bb02eaa..9da9646bf6c6 100644
--- a/include/asm-sparc/processor.h
+++ b/arch/sparc/include/asm/processor.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PROCESSOR_H 1#ifndef ___ASM_SPARC_PROCESSOR_H
2#define ___ASM_SPARC_PROCESSOR_H 2#define ___ASM_SPARC_PROCESSOR_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/processor_64.h> 4#include <asm/processor_64.h>
5#else 5#else
6#include <asm-sparc/processor_32.h> 6#include <asm/processor_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/processor_32.h b/arch/sparc/include/asm/processor_32.h
index 562c0d69c537..2ae67a2e7f3a 100644
--- a/include/asm-sparc/processor_32.h
+++ b/arch/sparc/include/asm/processor_32.h
@@ -1,4 +1,4 @@
1/* include/asm-sparc/processor.h 1/* include/asm/processor.h
2 * 2 *
3 * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
4 */ 4 */
@@ -114,6 +114,7 @@ extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
114 114
115extern unsigned long get_wchan(struct task_struct *); 115extern unsigned long get_wchan(struct task_struct *);
116 116
117#define task_pt_regs(tsk) ((tsk)->thread.kregs)
117#define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc) 118#define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc)
118#define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP]) 119#define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP])
119 120
diff --git a/include/asm-sparc/processor_64.h b/arch/sparc/include/asm/processor_64.h
index 70d42801a0d2..137a6bd72fc8 100644
--- a/include/asm-sparc/processor_64.h
+++ b/arch/sparc/include/asm/processor_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc64/processor.h 2 * include/asm/processor.h
3 * 3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */ 5 */
diff --git a/include/asm-sparc/prom.h b/arch/sparc/include/asm/prom.h
index fd55522481cd..fd55522481cd 100644
--- a/include/asm-sparc/prom.h
+++ b/arch/sparc/include/asm/prom.h
diff --git a/include/asm-sparc/psr.h b/arch/sparc/include/asm/psr.h
index b8c0e5f0a66b..b8c0e5f0a66b 100644
--- a/include/asm-sparc/psr.h
+++ b/arch/sparc/include/asm/psr.h
diff --git a/include/asm-sparc/psrcompat.h b/arch/sparc/include/asm/psrcompat.h
index 44b6327dbbf5..44b6327dbbf5 100644
--- a/include/asm-sparc/psrcompat.h
+++ b/arch/sparc/include/asm/psrcompat.h
diff --git a/include/asm-sparc/pstate.h b/arch/sparc/include/asm/pstate.h
index a26a53777bb0..a26a53777bb0 100644
--- a/include/asm-sparc/pstate.h
+++ b/arch/sparc/include/asm/pstate.h
diff --git a/include/asm-sparc/ptrace.h b/arch/sparc/include/asm/ptrace.h
index f36ab6c30ff3..6dcbe2eed2e2 100644
--- a/include/asm-sparc/ptrace.h
+++ b/arch/sparc/include/asm/ptrace.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_PTRACE_H 1#ifndef ___ASM_SPARC_PTRACE_H
2#define ___ASM_SPARC_PTRACE_H 2#define ___ASM_SPARC_PTRACE_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/ptrace_64.h> 4#include <asm/ptrace_64.h>
5#else 5#else
6#include <asm-sparc/ptrace_32.h> 6#include <asm/ptrace_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/ptrace_32.h b/arch/sparc/include/asm/ptrace_32.h
index 0401cc7ec38e..d43c88b86834 100644
--- a/include/asm-sparc/ptrace_32.h
+++ b/arch/sparc/include/asm/ptrace_32.h
@@ -74,6 +74,7 @@ struct sparc_stackf {
74 74
75#define user_mode(regs) (!((regs)->psr & PSR_PS)) 75#define user_mode(regs) (!((regs)->psr & PSR_PS))
76#define instruction_pointer(regs) ((regs)->pc) 76#define instruction_pointer(regs) ((regs)->pc)
77#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
77unsigned long profile_pc(struct pt_regs *); 78unsigned long profile_pc(struct pt_regs *);
78extern void show_regs(struct pt_regs *); 79extern void show_regs(struct pt_regs *);
79#endif 80#endif
diff --git a/include/asm-sparc/ptrace_64.h b/arch/sparc/include/asm/ptrace_64.h
index a682e66d5c4a..ec6d45c84cd0 100644
--- a/include/asm-sparc/ptrace_64.h
+++ b/arch/sparc/include/asm/ptrace_64.h
@@ -146,6 +146,7 @@ do { current_thread_info()->syscall_noerror = 1; \
146} while (0) 146} while (0)
147#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) 147#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
148#define instruction_pointer(regs) ((regs)->tpc) 148#define instruction_pointer(regs) ((regs)->tpc)
149#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
149#define regs_return_value(regs) ((regs)->u_regs[UREG_I0]) 150#define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
150#ifdef CONFIG_SMP 151#ifdef CONFIG_SMP
151extern unsigned long profile_pc(struct pt_regs *); 152extern unsigned long profile_pc(struct pt_regs *);
diff --git a/include/asm-sparc/reboot.h b/arch/sparc/include/asm/reboot.h
index 3f3f43f5be5e..3f3f43f5be5e 100644
--- a/include/asm-sparc/reboot.h
+++ b/arch/sparc/include/asm/reboot.h
diff --git a/include/asm-sparc/reg.h b/arch/sparc/include/asm/reg.h
index cb34b0a49aad..0c16e19cae4d 100644
--- a/include/asm-sparc/reg.h
+++ b/arch/sparc/include/asm/reg.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_REG_H 1#ifndef ___ASM_SPARC_REG_H
2#define ___ASM_SPARC_REG_H 2#define ___ASM_SPARC_REG_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/reg_64.h> 4#include <asm/reg_64.h>
5#else 5#else
6#include <asm-sparc/reg_32.h> 6#include <asm/reg_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/reg_32.h b/arch/sparc/include/asm/reg_32.h
index 42fecfcd97e7..1efb056fb3d1 100644
--- a/include/asm-sparc/reg_32.h
+++ b/arch/sparc/include/asm/reg_32.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-sparc/reg.h 2 * linux/include/asm/reg.h
3 * Layout of the registers as expected by gdb on the Sparc 3 * Layout of the registers as expected by gdb on the Sparc
4 * we should replace the user.h definitions with those in 4 * we should replace the user.h definitions with those in
5 * this file, we don't even use the other 5 * this file, we don't even use the other
diff --git a/include/asm-sparc/reg_64.h b/arch/sparc/include/asm/reg_64.h
index eb24a07ff4d5..6f277d7c7d88 100644
--- a/include/asm-sparc/reg_64.h
+++ b/arch/sparc/include/asm/reg_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/asm-sparc64/reg.h 2 * linux/asm/reg.h
3 * Layout of the registers as expected by gdb on the Sparc 3 * Layout of the registers as expected by gdb on the Sparc
4 * we should replace the user.h definitions with those in 4 * we should replace the user.h definitions with those in
5 * this file, we don't even use the other 5 * this file, we don't even use the other
diff --git a/include/asm-sparc/resource.h b/arch/sparc/include/asm/resource.h
index fe163cafb4c7..fe163cafb4c7 100644
--- a/include/asm-sparc/resource.h
+++ b/arch/sparc/include/asm/resource.h
diff --git a/include/asm-sparc/ross.h b/arch/sparc/include/asm/ross.h
index ecb6e81786a6..ecb6e81786a6 100644
--- a/include/asm-sparc/ross.h
+++ b/arch/sparc/include/asm/ross.h
diff --git a/include/asm-sparc/rtc.h b/arch/sparc/include/asm/rtc.h
index f9ecb1fe2ecd..f9ecb1fe2ecd 100644
--- a/include/asm-sparc/rtc.h
+++ b/arch/sparc/include/asm/rtc.h
diff --git a/include/asm-sparc/rwsem-const.h b/arch/sparc/include/asm/rwsem-const.h
index a303c9d64d84..a303c9d64d84 100644
--- a/include/asm-sparc/rwsem-const.h
+++ b/arch/sparc/include/asm/rwsem-const.h
diff --git a/include/asm-sparc/rwsem.h b/arch/sparc/include/asm/rwsem.h
index 1dc129ac2feb..1dc129ac2feb 100644
--- a/include/asm-sparc/rwsem.h
+++ b/arch/sparc/include/asm/rwsem.h
diff --git a/include/asm-sparc/sbi.h b/arch/sparc/include/asm/sbi.h
index 5eb7f1965d33..5eb7f1965d33 100644
--- a/include/asm-sparc/sbi.h
+++ b/arch/sparc/include/asm/sbi.h
diff --git a/include/asm-sparc/sbus.h b/arch/sparc/include/asm/sbus.h
index 8f29a1979665..f82481ab44db 100644
--- a/include/asm-sparc/sbus.h
+++ b/arch/sparc/include/asm/sbus.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SBUS_H 1#ifndef ___ASM_SPARC_SBUS_H
2#define ___ASM_SPARC_SBUS_H 2#define ___ASM_SPARC_SBUS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/sbus_64.h> 4#include <asm/sbus_64.h>
5#else 5#else
6#include <asm-sparc/sbus_32.h> 6#include <asm/sbus_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/sbus_32.h b/arch/sparc/include/asm/sbus_32.h
index 77b5d3aadc99..77b5d3aadc99 100644
--- a/include/asm-sparc/sbus_32.h
+++ b/arch/sparc/include/asm/sbus_32.h
diff --git a/include/asm-sparc/sbus_64.h b/arch/sparc/include/asm/sbus_64.h
index 0e16b6dd7e96..0e16b6dd7e96 100644
--- a/include/asm-sparc/sbus_64.h
+++ b/arch/sparc/include/asm/sbus_64.h
diff --git a/include/asm-sparc/scatterlist.h b/arch/sparc/include/asm/scatterlist.h
index b1a0e316c2b6..ec21a4517641 100644
--- a/include/asm-sparc/scatterlist.h
+++ b/arch/sparc/include/asm/scatterlist.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SCATTERLIST_H 1#ifndef ___ASM_SPARC_SCATTERLIST_H
2#define ___ASM_SPARC_SCATTERLIST_H 2#define ___ASM_SPARC_SCATTERLIST_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/scatterlist_64.h> 4#include <asm/scatterlist_64.h>
5#else 5#else
6#include <asm-sparc/scatterlist_32.h> 6#include <asm/scatterlist_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/scatterlist_32.h b/arch/sparc/include/asm/scatterlist_32.h
index c82609ca1d0f..c82609ca1d0f 100644
--- a/include/asm-sparc/scatterlist_32.h
+++ b/arch/sparc/include/asm/scatterlist_32.h
diff --git a/include/asm-sparc/scatterlist_64.h b/arch/sparc/include/asm/scatterlist_64.h
index 81bd058f9382..81bd058f9382 100644
--- a/include/asm-sparc/scatterlist_64.h
+++ b/arch/sparc/include/asm/scatterlist_64.h
diff --git a/include/asm-sparc/scratchpad.h b/arch/sparc/include/asm/scratchpad.h
index 5e8b01fb3343..5e8b01fb3343 100644
--- a/include/asm-sparc/scratchpad.h
+++ b/arch/sparc/include/asm/scratchpad.h
diff --git a/include/asm-sparc/seccomp.h b/arch/sparc/include/asm/seccomp.h
index 7fcd9968192b..7fcd9968192b 100644
--- a/include/asm-sparc/seccomp.h
+++ b/arch/sparc/include/asm/seccomp.h
diff --git a/include/asm-sparc/sections.h b/arch/sparc/include/asm/sections.h
index cbd019162425..c7c69b00967f 100644
--- a/include/asm-sparc/sections.h
+++ b/arch/sparc/include/asm/sections.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SECTIONS_H 1#ifndef ___ASM_SPARC_SECTIONS_H
2#define ___ASM_SPARC_SECTIONS_H 2#define ___ASM_SPARC_SECTIONS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/sections_64.h> 4#include <asm/sections_64.h>
5#else 5#else
6#include <asm-sparc/sections_32.h> 6#include <asm/sections_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/sections_32.h b/arch/sparc/include/asm/sections_32.h
index 6832841df051..6832841df051 100644
--- a/include/asm-sparc/sections_32.h
+++ b/arch/sparc/include/asm/sections_32.h
diff --git a/include/asm-sparc/sections_64.h b/arch/sparc/include/asm/sections_64.h
index 3f4b9fdc28d0..3f4b9fdc28d0 100644
--- a/include/asm-sparc/sections_64.h
+++ b/arch/sparc/include/asm/sections_64.h
diff --git a/include/asm-sparc/sembuf.h b/arch/sparc/include/asm/sembuf.h
index faee1be08d67..faee1be08d67 100644
--- a/include/asm-sparc/sembuf.h
+++ b/arch/sparc/include/asm/sembuf.h
diff --git a/include/asm-sparc/setup.h b/arch/sparc/include/asm/setup.h
index 2643c62f4ac0..2643c62f4ac0 100644
--- a/include/asm-sparc/setup.h
+++ b/arch/sparc/include/asm/setup.h
diff --git a/include/asm-sparc/sfafsr.h b/arch/sparc/include/asm/sfafsr.h
index e96137b04a4f..e96137b04a4f 100644
--- a/include/asm-sparc/sfafsr.h
+++ b/arch/sparc/include/asm/sfafsr.h
diff --git a/include/asm-sparc/sfp-machine.h b/arch/sparc/include/asm/sfp-machine.h
index c676fcc2dd27..4ebc3823ed4f 100644
--- a/include/asm-sparc/sfp-machine.h
+++ b/arch/sparc/include/asm/sfp-machine.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SFP_MACHINE_H 1#ifndef ___ASM_SPARC_SFP_MACHINE_H
2#define ___ASM_SPARC_SFP_MACHINE_H 2#define ___ASM_SPARC_SFP_MACHINE_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/sfp-machine_64.h> 4#include <asm/sfp-machine_64.h>
5#else 5#else
6#include <asm-sparc/sfp-machine_32.h> 6#include <asm/sfp-machine_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/sfp-machine_32.h b/arch/sparc/include/asm/sfp-machine_32.h
index 01d9c3b5a73b..01d9c3b5a73b 100644
--- a/include/asm-sparc/sfp-machine_32.h
+++ b/arch/sparc/include/asm/sfp-machine_32.h
diff --git a/include/asm-sparc/sfp-machine_64.h b/arch/sparc/include/asm/sfp-machine_64.h
index ca913ef40bd5..ca913ef40bd5 100644
--- a/include/asm-sparc/sfp-machine_64.h
+++ b/arch/sparc/include/asm/sfp-machine_64.h
diff --git a/include/asm-sparc/shmbuf.h b/arch/sparc/include/asm/shmbuf.h
index 83a16055363f..83a16055363f 100644
--- a/include/asm-sparc/shmbuf.h
+++ b/arch/sparc/include/asm/shmbuf.h
diff --git a/include/asm-sparc/shmparam.h b/arch/sparc/include/asm/shmparam.h
index 16fda7e9acc8..8bf0cfe0694f 100644
--- a/include/asm-sparc/shmparam.h
+++ b/arch/sparc/include/asm/shmparam.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SHMPARAM_H 1#ifndef ___ASM_SPARC_SHMPARAM_H
2#define ___ASM_SPARC_SHMPARAM_H 2#define ___ASM_SPARC_SHMPARAM_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/shmparam_64.h> 4#include <asm/shmparam_64.h>
5#else 5#else
6#include <asm-sparc/shmparam_32.h> 6#include <asm/shmparam_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/shmparam_32.h b/arch/sparc/include/asm/shmparam_32.h
index 59a1243c12f3..59a1243c12f3 100644
--- a/include/asm-sparc/shmparam_32.h
+++ b/arch/sparc/include/asm/shmparam_32.h
diff --git a/include/asm-sparc/shmparam_64.h b/arch/sparc/include/asm/shmparam_64.h
index 1ed0d6701a9b..1ed0d6701a9b 100644
--- a/include/asm-sparc/shmparam_64.h
+++ b/arch/sparc/include/asm/shmparam_64.h
diff --git a/include/asm-sparc/sigcontext.h b/arch/sparc/include/asm/sigcontext.h
index 82fc7d54a4fa..e92de7e286b5 100644
--- a/include/asm-sparc/sigcontext.h
+++ b/arch/sparc/include/asm/sigcontext.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SIGCONTEXT_H 1#ifndef ___ASM_SPARC_SIGCONTEXT_H
2#define ___ASM_SPARC_SIGCONTEXT_H 2#define ___ASM_SPARC_SIGCONTEXT_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/sigcontext_64.h> 4#include <asm/sigcontext_64.h>
5#else 5#else
6#include <asm-sparc/sigcontext_32.h> 6#include <asm/sigcontext_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/sigcontext_32.h b/arch/sparc/include/asm/sigcontext_32.h
index c5fb60dcbd75..c5fb60dcbd75 100644
--- a/include/asm-sparc/sigcontext_32.h
+++ b/arch/sparc/include/asm/sigcontext_32.h
diff --git a/include/asm-sparc/sigcontext_64.h b/arch/sparc/include/asm/sigcontext_64.h
index 1c868d680cfc..1c868d680cfc 100644
--- a/include/asm-sparc/sigcontext_64.h
+++ b/arch/sparc/include/asm/sigcontext_64.h
diff --git a/include/asm-sparc/siginfo.h b/arch/sparc/include/asm/siginfo.h
index 2c9fccf4ce18..bd81f8d7f5ce 100644
--- a/include/asm-sparc/siginfo.h
+++ b/arch/sparc/include/asm/siginfo.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SIGINFO_H 1#ifndef ___ASM_SPARC_SIGINFO_H
2#define ___ASM_SPARC_SIGINFO_H 2#define ___ASM_SPARC_SIGINFO_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/siginfo_64.h> 4#include <asm/siginfo_64.h>
5#else 5#else
6#include <asm-sparc/siginfo_32.h> 6#include <asm/siginfo_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/siginfo_32.h b/arch/sparc/include/asm/siginfo_32.h
index 3c71af135c52..3c71af135c52 100644
--- a/include/asm-sparc/siginfo_32.h
+++ b/arch/sparc/include/asm/siginfo_32.h
diff --git a/include/asm-sparc/siginfo_64.h b/arch/sparc/include/asm/siginfo_64.h
index c96e6c30f8b0..c96e6c30f8b0 100644
--- a/include/asm-sparc/siginfo_64.h
+++ b/arch/sparc/include/asm/siginfo_64.h
diff --git a/include/asm-sparc/signal.h b/arch/sparc/include/asm/signal.h
index 36f5f9e482f7..27ab05dc203e 100644
--- a/include/asm-sparc/signal.h
+++ b/arch/sparc/include/asm/signal.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SIGNAL_H 1#ifndef ___ASM_SPARC_SIGNAL_H
2#define ___ASM_SPARC_SIGNAL_H 2#define ___ASM_SPARC_SIGNAL_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/signal_64.h> 4#include <asm/signal_64.h>
5#else 5#else
6#include <asm-sparc/signal_32.h> 6#include <asm/signal_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/signal_32.h b/arch/sparc/include/asm/signal_32.h
index 96a60ab03ca1..96a60ab03ca1 100644
--- a/include/asm-sparc/signal_32.h
+++ b/arch/sparc/include/asm/signal_32.h
diff --git a/include/asm-sparc/signal_64.h b/arch/sparc/include/asm/signal_64.h
index ab1509a101c5..ab1509a101c5 100644
--- a/include/asm-sparc/signal_64.h
+++ b/arch/sparc/include/asm/signal_64.h
diff --git a/include/asm-sparc/smp.h b/arch/sparc/include/asm/smp.h
index 1f9dedfbabd8..b59672d0e19b 100644
--- a/include/asm-sparc/smp.h
+++ b/arch/sparc/include/asm/smp.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SMP_H 1#ifndef ___ASM_SPARC_SMP_H
2#define ___ASM_SPARC_SMP_H 2#define ___ASM_SPARC_SMP_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/smp_64.h> 4#include <asm/smp_64.h>
5#else 5#else
6#include <asm-sparc/smp_32.h> 6#include <asm/smp_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/smp_32.h b/arch/sparc/include/asm/smp_32.h
index 7201752cf934..7201752cf934 100644
--- a/include/asm-sparc/smp_32.h
+++ b/arch/sparc/include/asm/smp_32.h
diff --git a/include/asm-sparc/smp_64.h b/arch/sparc/include/asm/smp_64.h
index 57224dd37b3a..57224dd37b3a 100644
--- a/include/asm-sparc/smp_64.h
+++ b/arch/sparc/include/asm/smp_64.h
diff --git a/include/asm-sparc/smpprim.h b/arch/sparc/include/asm/smpprim.h
index eb849d862c64..eb849d862c64 100644
--- a/include/asm-sparc/smpprim.h
+++ b/arch/sparc/include/asm/smpprim.h
diff --git a/include/asm-sparc/socket.h b/arch/sparc/include/asm/socket.h
index bf50d0c2d583..bf50d0c2d583 100644
--- a/include/asm-sparc/socket.h
+++ b/arch/sparc/include/asm/socket.h
diff --git a/include/asm-sparc/sockios.h b/arch/sparc/include/asm/sockios.h
index 990ea746486b..990ea746486b 100644
--- a/include/asm-sparc/sockios.h
+++ b/arch/sparc/include/asm/sockios.h
diff --git a/include/asm-sparc/sparsemem.h b/arch/sparc/include/asm/sparsemem.h
index b99d4e4b6d28..b99d4e4b6d28 100644
--- a/include/asm-sparc/sparsemem.h
+++ b/arch/sparc/include/asm/sparsemem.h
diff --git a/include/asm-sparc/spinlock.h b/arch/sparc/include/asm/spinlock.h
index 3b71c50b72eb..f276b0036b2c 100644
--- a/include/asm-sparc/spinlock.h
+++ b/arch/sparc/include/asm/spinlock.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SPINLOCK_H 1#ifndef ___ASM_SPARC_SPINLOCK_H
2#define ___ASM_SPARC_SPINLOCK_H 2#define ___ASM_SPARC_SPINLOCK_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/spinlock_64.h> 4#include <asm/spinlock_64.h>
5#else 5#else
6#include <asm-sparc/spinlock_32.h> 6#include <asm/spinlock_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/spinlock_32.h b/arch/sparc/include/asm/spinlock_32.h
index de2249b267c6..de2249b267c6 100644
--- a/include/asm-sparc/spinlock_32.h
+++ b/arch/sparc/include/asm/spinlock_32.h
diff --git a/include/asm-sparc/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
index 0006fe9f8c7a..0006fe9f8c7a 100644
--- a/include/asm-sparc/spinlock_64.h
+++ b/arch/sparc/include/asm/spinlock_64.h
diff --git a/include/asm-sparc/spinlock_types.h b/arch/sparc/include/asm/spinlock_types.h
index 37cbe01c585b..37cbe01c585b 100644
--- a/include/asm-sparc/spinlock_types.h
+++ b/arch/sparc/include/asm/spinlock_types.h
diff --git a/include/asm-sparc/spitfire.h b/arch/sparc/include/asm/spitfire.h
index 985ea7e31992..985ea7e31992 100644
--- a/include/asm-sparc/spitfire.h
+++ b/arch/sparc/include/asm/spitfire.h
diff --git a/include/asm-sparc/sstate.h b/arch/sparc/include/asm/sstate.h
index a7c35dbcb281..a7c35dbcb281 100644
--- a/include/asm-sparc/sstate.h
+++ b/arch/sparc/include/asm/sstate.h
diff --git a/include/asm-sparc/stacktrace.h b/arch/sparc/include/asm/stacktrace.h
index 6cee39adf6d6..6cee39adf6d6 100644
--- a/include/asm-sparc/stacktrace.h
+++ b/arch/sparc/include/asm/stacktrace.h
diff --git a/include/asm-sparc/starfire.h b/arch/sparc/include/asm/starfire.h
index 07bafd31e33c..07bafd31e33c 100644
--- a/include/asm-sparc/starfire.h
+++ b/arch/sparc/include/asm/starfire.h
diff --git a/include/asm-sparc/stat.h b/arch/sparc/include/asm/stat.h
index 9fdcaf8c9cd3..d8153013df72 100644
--- a/include/asm-sparc/stat.h
+++ b/arch/sparc/include/asm/stat.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_STAT_H 1#ifndef ___ASM_SPARC_STAT_H
2#define ___ASM_SPARC_STAT_H 2#define ___ASM_SPARC_STAT_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/stat_64.h> 4#include <asm/stat_64.h>
5#else 5#else
6#include <asm-sparc/stat_32.h> 6#include <asm/stat_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/stat_32.h b/arch/sparc/include/asm/stat_32.h
index 2299e1d5d94c..2299e1d5d94c 100644
--- a/include/asm-sparc/stat_32.h
+++ b/arch/sparc/include/asm/stat_32.h
diff --git a/include/asm-sparc/stat_64.h b/arch/sparc/include/asm/stat_64.h
index 9650fdea847f..9650fdea847f 100644
--- a/include/asm-sparc/stat_64.h
+++ b/arch/sparc/include/asm/stat_64.h
diff --git a/include/asm-sparc/statfs.h b/arch/sparc/include/asm/statfs.h
index a70cc52e7018..5e937a73743d 100644
--- a/include/asm-sparc/statfs.h
+++ b/arch/sparc/include/asm/statfs.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_STATFS_H 1#ifndef ___ASM_SPARC_STATFS_H
2#define ___ASM_SPARC_STATFS_H 2#define ___ASM_SPARC_STATFS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/statfs_64.h> 4#include <asm/statfs_64.h>
5#else 5#else
6#include <asm-sparc/statfs_32.h> 6#include <asm/statfs_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/statfs_32.h b/arch/sparc/include/asm/statfs_32.h
index 304520fa8863..304520fa8863 100644
--- a/include/asm-sparc/statfs_32.h
+++ b/arch/sparc/include/asm/statfs_32.h
diff --git a/include/asm-sparc/statfs_64.h b/arch/sparc/include/asm/statfs_64.h
index 79b3c890a5fa..79b3c890a5fa 100644
--- a/include/asm-sparc/statfs_64.h
+++ b/arch/sparc/include/asm/statfs_64.h
diff --git a/include/asm-sparc/string.h b/arch/sparc/include/asm/string.h
index 14c04c7697a5..98b72a0c8e6e 100644
--- a/include/asm-sparc/string.h
+++ b/arch/sparc/include/asm/string.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_STRING_H 1#ifndef ___ASM_SPARC_STRING_H
2#define ___ASM_SPARC_STRING_H 2#define ___ASM_SPARC_STRING_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/string_64.h> 4#include <asm/string_64.h>
5#else 5#else
6#include <asm-sparc/string_32.h> 6#include <asm/string_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/string_32.h b/arch/sparc/include/asm/string_32.h
index 6c5fddb7e6b5..6c5fddb7e6b5 100644
--- a/include/asm-sparc/string_32.h
+++ b/arch/sparc/include/asm/string_32.h
diff --git a/include/asm-sparc/string_64.h b/arch/sparc/include/asm/string_64.h
index 43161f2d17eb..43161f2d17eb 100644
--- a/include/asm-sparc/string_64.h
+++ b/arch/sparc/include/asm/string_64.h
diff --git a/include/asm-sparc/sun4paddr.h b/arch/sparc/include/asm/sun4paddr.h
index d52985f19f42..d52985f19f42 100644
--- a/include/asm-sparc/sun4paddr.h
+++ b/arch/sparc/include/asm/sun4paddr.h
diff --git a/include/asm-sparc/sun4prom.h b/arch/sparc/include/asm/sun4prom.h
index 9c8b4cbf629a..9c8b4cbf629a 100644
--- a/include/asm-sparc/sun4prom.h
+++ b/arch/sparc/include/asm/sun4prom.h
diff --git a/include/asm-sparc/sunbpp.h b/arch/sparc/include/asm/sunbpp.h
index 92ee1a8ff3a2..d81a02eaf78b 100644
--- a/include/asm-sparc/sunbpp.h
+++ b/arch/sparc/include/asm/sunbpp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc/sunbpp.h 2 * include/asm/sunbpp.h
3 */ 3 */
4 4
5#ifndef _ASM_SPARC_SUNBPP_H 5#ifndef _ASM_SPARC_SUNBPP_H
diff --git a/include/asm-sparc/swift.h b/arch/sparc/include/asm/swift.h
index e535061bf755..e535061bf755 100644
--- a/include/asm-sparc/swift.h
+++ b/arch/sparc/include/asm/swift.h
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h
new file mode 100644
index 000000000000..7486c605e23c
--- /dev/null
+++ b/arch/sparc/include/asm/syscall.h
@@ -0,0 +1,120 @@
1#ifndef __ASM_SPARC_SYSCALL_H
2#define __ASM_SPARC_SYSCALL_H
3
4#include <linux/kernel.h>
5#include <linux/sched.h>
6#include <asm/ptrace.h>
7
8/* The system call number is given by the user in %g1 */
9static inline long syscall_get_nr(struct task_struct *task,
10 struct pt_regs *regs)
11{
12 int syscall_p = pt_regs_is_syscall(regs);
13
14 return (syscall_p ? regs->u_regs[UREG_G1] : -1L);
15}
16
17static inline void syscall_rollback(struct task_struct *task,
18 struct pt_regs *regs)
19{
20 /* XXX This needs some thought. On Sparc we don't
21 * XXX save away the original %o0 value somewhere.
22 * XXX Instead we hold it in register %l5 at the top
23 * XXX level trap frame and pass this down to the signal
24 * XXX dispatch code which is the only place that value
25 * XXX ever was needed.
26 */
27}
28
29#ifdef CONFIG_SPARC32
30static inline bool syscall_has_error(struct pt_regs *regs)
31{
32 return (regs->psr & PSR_C) ? true : false;
33}
34static inline void syscall_set_error(struct pt_regs *regs)
35{
36 regs->psr |= PSR_C;
37}
38static inline void syscall_clear_error(struct pt_regs *regs)
39{
40 regs->psr &= ~PSR_C;
41}
42#else
43static inline bool syscall_has_error(struct pt_regs *regs)
44{
45 return (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)) ? true : false;
46}
47static inline void syscall_set_error(struct pt_regs *regs)
48{
49 regs->tstate |= (TSTATE_XCARRY | TSTATE_ICARRY);
50}
51static inline void syscall_clear_error(struct pt_regs *regs)
52{
53 regs->tstate &= ~(TSTATE_XCARRY | TSTATE_ICARRY);
54}
55#endif
56
57static inline long syscall_get_error(struct task_struct *task,
58 struct pt_regs *regs)
59{
60 long val = regs->u_regs[UREG_I0];
61
62 return (syscall_has_error(regs) ? -val : 0);
63}
64
65static inline long syscall_get_return_value(struct task_struct *task,
66 struct pt_regs *regs)
67{
68 long val = regs->u_regs[UREG_I0];
69
70 return val;
71}
72
73static inline void syscall_set_return_value(struct task_struct *task,
74 struct pt_regs *regs,
75 int error, long val)
76{
77 if (error) {
78 syscall_set_error(regs);
79 regs->u_regs[UREG_I0] = -error;
80 } else {
81 syscall_clear_error(regs);
82 regs->u_regs[UREG_I0] = val;
83 }
84}
85
86static inline void syscall_get_arguments(struct task_struct *task,
87 struct pt_regs *regs,
88 unsigned int i, unsigned int n,
89 unsigned long *args)
90{
91 int zero_extend = 0;
92 unsigned int j;
93
94#ifdef CONFIG_SPARC64
95 if (test_tsk_thread_flag(task, TIF_32BIT))
96 zero_extend = 1;
97#endif
98
99 for (j = 0; j < n; j++) {
100 unsigned long val = regs->u_regs[UREG_I0 + i + j];
101
102 if (zero_extend)
103 args[j] = (u32) val;
104 else
105 args[j] = val;
106 }
107}
108
109static inline void syscall_set_arguments(struct task_struct *task,
110 struct pt_regs *regs,
111 unsigned int i, unsigned int n,
112 const unsigned long *args)
113{
114 unsigned int j;
115
116 for (j = 0; j < n; j++)
117 regs->u_regs[UREG_I0 + i + j] = args[j];
118}
119
120#endif /* __ASM_SPARC_SYSCALL_H */
diff --git a/include/asm-sparc/syscalls.h b/arch/sparc/include/asm/syscalls.h
index 45a43f637a14..45a43f637a14 100644
--- a/include/asm-sparc/syscalls.h
+++ b/arch/sparc/include/asm/syscalls.h
diff --git a/include/asm-sparc/sysen.h b/arch/sparc/include/asm/sysen.h
index 6af34abde6e7..6af34abde6e7 100644
--- a/include/asm-sparc/sysen.h
+++ b/arch/sparc/include/asm/sysen.h
diff --git a/include/asm-sparc/system.h b/arch/sparc/include/asm/system.h
index 15e2a3bc4f61..7944a7cfc996 100644
--- a/include/asm-sparc/system.h
+++ b/arch/sparc/include/asm/system.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_SYSTEM_H 1#ifndef ___ASM_SPARC_SYSTEM_H
2#define ___ASM_SPARC_SYSTEM_H 2#define ___ASM_SPARC_SYSTEM_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/system_64.h> 4#include <asm/system_64.h>
5#else 5#else
6#include <asm-sparc/system_32.h> 6#include <asm/system_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/system_32.h b/arch/sparc/include/asm/system_32.h
index b4b024445fc9..b4b024445fc9 100644
--- a/include/asm-sparc/system_32.h
+++ b/arch/sparc/include/asm/system_32.h
diff --git a/include/asm-sparc/system_64.h b/arch/sparc/include/asm/system_64.h
index db9e742a406a..db9e742a406a 100644
--- a/include/asm-sparc/system_64.h
+++ b/arch/sparc/include/asm/system_64.h
diff --git a/include/asm-sparc/termbits.h b/arch/sparc/include/asm/termbits.h
index d6ca3e2754f5..d6ca3e2754f5 100644
--- a/include/asm-sparc/termbits.h
+++ b/arch/sparc/include/asm/termbits.h
diff --git a/include/asm-sparc/termios.h b/arch/sparc/include/asm/termios.h
index e8ba95399643..e8ba95399643 100644
--- a/include/asm-sparc/termios.h
+++ b/arch/sparc/include/asm/termios.h
diff --git a/include/asm-sparc/thread_info.h b/arch/sparc/include/asm/thread_info.h
index 64155cf89f37..122d7acc07e6 100644
--- a/include/asm-sparc/thread_info.h
+++ b/arch/sparc/include/asm/thread_info.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_THREAD_INFO_H 1#ifndef ___ASM_SPARC_THREAD_INFO_H
2#define ___ASM_SPARC_THREAD_INFO_H 2#define ___ASM_SPARC_THREAD_INFO_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/thread_info_64.h> 4#include <asm/thread_info_64.h>
5#else 5#else
6#include <asm-sparc/thread_info_32.h> 6#include <asm/thread_info_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index 2cf9db044055..cbb892d0dff0 100644
--- a/include/asm-sparc/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -130,7 +130,7 @@ BTFIXUPDEF_CALL(void, free_thread_info, struct thread_info *)
130 * thread information flag bit numbers 130 * thread information flag bit numbers
131 */ 131 */
132#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 132#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
133/* flag bit 1 is available */ 133#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
134#define TIF_SIGPENDING 2 /* signal pending */ 134#define TIF_SIGPENDING 2 /* signal pending */
135#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 135#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
136#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ 136#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
@@ -142,12 +142,17 @@ BTFIXUPDEF_CALL(void, free_thread_info, struct thread_info *)
142 142
143/* as above, but as bit values */ 143/* as above, but as bit values */
144#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 144#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
145#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
145#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 146#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
146#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 147#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
147#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 148#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
148#define _TIF_USEDFPU (1<<TIF_USEDFPU) 149#define _TIF_USEDFPU (1<<TIF_USEDFPU)
149#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 150#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
150 151
152#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \
153 _TIF_SIGPENDING | \
154 _TIF_RESTORE_SIGMASK)
155
151#endif /* __KERNEL__ */ 156#endif /* __KERNEL__ */
152 157
153#endif /* _ASM_THREAD_INFO_H */ 158#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-sparc/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 960969d5ad06..c0a737d7292c 100644
--- a/include/asm-sparc/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -219,7 +219,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
219 * nop 219 * nop
220 */ 220 */
221#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 221#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
222/* flags bit 1 is available */ 222#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
223#define TIF_SIGPENDING 2 /* signal pending */ 223#define TIF_SIGPENDING 2 /* signal pending */
224#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 224#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
225#define TIF_PERFCTR 4 /* performance counters active */ 225#define TIF_PERFCTR 4 /* performance counters active */
@@ -239,6 +239,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
239#define TIF_POLLING_NRFLAG 14 239#define TIF_POLLING_NRFLAG 14
240 240
241#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 241#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
242#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
242#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 243#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
243#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 244#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
244#define _TIF_PERFCTR (1<<TIF_PERFCTR) 245#define _TIF_PERFCTR (1<<TIF_PERFCTR)
@@ -250,8 +251,9 @@ register struct thread_info *current_thread_info_reg asm("g6");
250#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 251#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
251 252
252#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \ 253#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
253 (_TIF_SIGPENDING | \ 254 _TIF_DO_NOTIFY_RESUME_MASK | \
254 _TIF_NEED_RESCHED | _TIF_PERFCTR)) 255 _TIF_NEED_RESCHED | _TIF_PERFCTR)
256#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
255 257
256/* 258/*
257 * Thread-synchronous status. 259 * Thread-synchronous status.
diff --git a/include/asm-sparc/timer.h b/arch/sparc/include/asm/timer.h
index 475baa05a96e..612fd2779d9e 100644
--- a/include/asm-sparc/timer.h
+++ b/arch/sparc/include/asm/timer.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_TIMER_H 1#ifndef ___ASM_SPARC_TIMER_H
2#define ___ASM_SPARC_TIMER_H 2#define ___ASM_SPARC_TIMER_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/timer_64.h> 4#include <asm/timer_64.h>
5#else 5#else
6#include <asm-sparc/timer_32.h> 6#include <asm/timer_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/timer_32.h b/arch/sparc/include/asm/timer_32.h
index 361e53898dd7..361e53898dd7 100644
--- a/include/asm-sparc/timer_32.h
+++ b/arch/sparc/include/asm/timer_32.h
diff --git a/include/asm-sparc/timer_64.h b/arch/sparc/include/asm/timer_64.h
index 5b779fd1f788..5b779fd1f788 100644
--- a/include/asm-sparc/timer_64.h
+++ b/arch/sparc/include/asm/timer_64.h
diff --git a/include/asm-sparc/timex.h b/arch/sparc/include/asm/timex.h
index 01d9f199d452..70cc37b73827 100644
--- a/include/asm-sparc/timex.h
+++ b/arch/sparc/include/asm/timex.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_TIMEX_H 1#ifndef ___ASM_SPARC_TIMEX_H
2#define ___ASM_SPARC_TIMEX_H 2#define ___ASM_SPARC_TIMEX_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/timex_64.h> 4#include <asm/timex_64.h>
5#else 5#else
6#include <asm-sparc/timex_32.h> 6#include <asm/timex_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/timex_32.h b/arch/sparc/include/asm/timex_32.h
index 71b45c90ccae..b6ccdb0d6f7d 100644
--- a/include/asm-sparc/timex_32.h
+++ b/arch/sparc/include/asm/timex_32.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-sparc/timex.h 2 * linux/include/asm/timex.h
3 * 3 *
4 * sparc architecture timex specifications 4 * sparc architecture timex specifications
5 */ 5 */
diff --git a/include/asm-sparc/timex_64.h b/arch/sparc/include/asm/timex_64.h
index c622535c4560..18b30bc9823b 100644
--- a/include/asm-sparc/timex_64.h
+++ b/arch/sparc/include/asm/timex_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-sparc64/timex.h 2 * linux/include/asm/timex.h
3 * 3 *
4 * sparc64 architecture timex specifications 4 * sparc64 architecture timex specifications
5 */ 5 */
diff --git a/include/asm-sparc/tlb.h b/arch/sparc/include/asm/tlb.h
index a821057327c4..92d0393bbcdc 100644
--- a/include/asm-sparc/tlb.h
+++ b/arch/sparc/include/asm/tlb.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_TLB_H 1#ifndef ___ASM_SPARC_TLB_H
2#define ___ASM_SPARC_TLB_H 2#define ___ASM_SPARC_TLB_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/tlb_64.h> 4#include <asm/tlb_64.h>
5#else 5#else
6#include <asm-sparc/tlb_32.h> 6#include <asm/tlb_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/tlb_32.h b/arch/sparc/include/asm/tlb_32.h
index 6d02d1ce53f3..6d02d1ce53f3 100644
--- a/include/asm-sparc/tlb_32.h
+++ b/arch/sparc/include/asm/tlb_32.h
diff --git a/include/asm-sparc/tlb_64.h b/arch/sparc/include/asm/tlb_64.h
index ec81cdedef2c..ec81cdedef2c 100644
--- a/include/asm-sparc/tlb_64.h
+++ b/arch/sparc/include/asm/tlb_64.h
diff --git a/include/asm-sparc/tlbflush.h b/arch/sparc/include/asm/tlbflush.h
index 6e6bc12227b8..2c9629fad1e2 100644
--- a/include/asm-sparc/tlbflush.h
+++ b/arch/sparc/include/asm/tlbflush.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_TLBFLUSH_H 1#ifndef ___ASM_SPARC_TLBFLUSH_H
2#define ___ASM_SPARC_TLBFLUSH_H 2#define ___ASM_SPARC_TLBFLUSH_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/tlbflush_64.h> 4#include <asm/tlbflush_64.h>
5#else 5#else
6#include <asm-sparc/tlbflush_32.h> 6#include <asm/tlbflush_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/tlbflush_32.h b/arch/sparc/include/asm/tlbflush_32.h
index fe0a71abc9bb..fe0a71abc9bb 100644
--- a/include/asm-sparc/tlbflush_32.h
+++ b/arch/sparc/include/asm/tlbflush_32.h
diff --git a/include/asm-sparc/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h
index fbb675dbe0c9..fbb675dbe0c9 100644
--- a/include/asm-sparc/tlbflush_64.h
+++ b/arch/sparc/include/asm/tlbflush_64.h
diff --git a/include/asm-sparc/topology.h b/arch/sparc/include/asm/topology.h
index ed13630f32e2..ee4f191d394a 100644
--- a/include/asm-sparc/topology.h
+++ b/arch/sparc/include/asm/topology.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_TOPOLOGY_H 1#ifndef ___ASM_SPARC_TOPOLOGY_H
2#define ___ASM_SPARC_TOPOLOGY_H 2#define ___ASM_SPARC_TOPOLOGY_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/topology_64.h> 4#include <asm/topology_64.h>
5#else 5#else
6#include <asm-sparc/topology_32.h> 6#include <asm/topology_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/topology_32.h b/arch/sparc/include/asm/topology_32.h
index ee5ac9c9da28..ee5ac9c9da28 100644
--- a/include/asm-sparc/topology_32.h
+++ b/arch/sparc/include/asm/topology_32.h
diff --git a/include/asm-sparc/topology_64.h b/arch/sparc/include/asm/topology_64.h
index 001c04027c82..001c04027c82 100644
--- a/include/asm-sparc/topology_64.h
+++ b/arch/sparc/include/asm/topology_64.h
diff --git a/include/asm-sparc/traps.h b/arch/sparc/include/asm/traps.h
index bebdbf8f43a8..bebdbf8f43a8 100644
--- a/include/asm-sparc/traps.h
+++ b/arch/sparc/include/asm/traps.h
diff --git a/include/asm-sparc/tsb.h b/arch/sparc/include/asm/tsb.h
index 76e4299dd9bc..76e4299dd9bc 100644
--- a/include/asm-sparc/tsb.h
+++ b/arch/sparc/include/asm/tsb.h
diff --git a/include/asm-sparc/tsunami.h b/arch/sparc/include/asm/tsunami.h
index 5bbd1d523baa..5bbd1d523baa 100644
--- a/include/asm-sparc/tsunami.h
+++ b/arch/sparc/include/asm/tsunami.h
diff --git a/include/asm-sparc/ttable.h b/arch/sparc/include/asm/ttable.h
index 5708ba2719fb..5708ba2719fb 100644
--- a/include/asm-sparc/ttable.h
+++ b/arch/sparc/include/asm/ttable.h
diff --git a/include/asm-sparc/turbosparc.h b/arch/sparc/include/asm/turbosparc.h
index 17c73282db0a..17c73282db0a 100644
--- a/include/asm-sparc/turbosparc.h
+++ b/arch/sparc/include/asm/turbosparc.h
diff --git a/include/asm-sparc/types.h b/arch/sparc/include/asm/types.h
index 8c28fde5eaa2..8c28fde5eaa2 100644
--- a/include/asm-sparc/types.h
+++ b/arch/sparc/include/asm/types.h
diff --git a/include/asm-sparc/uaccess.h b/arch/sparc/include/asm/uaccess.h
index 424facce5238..e88fbe5c0457 100644
--- a/include/asm-sparc/uaccess.h
+++ b/arch/sparc/include/asm/uaccess.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_UACCESS_H 1#ifndef ___ASM_SPARC_UACCESS_H
2#define ___ASM_SPARC_UACCESS_H 2#define ___ASM_SPARC_UACCESS_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/uaccess_64.h> 4#include <asm/uaccess_64.h>
5#else 5#else
6#include <asm-sparc/uaccess_32.h> 6#include <asm/uaccess_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 47d5619d43fa..47d5619d43fa 100644
--- a/include/asm-sparc/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
diff --git a/include/asm-sparc/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index 296ef30e05c8..296ef30e05c8 100644
--- a/include/asm-sparc/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
diff --git a/include/asm-sparc/uctx.h b/arch/sparc/include/asm/uctx.h
index dc937c75ffdd..dc937c75ffdd 100644
--- a/include/asm-sparc/uctx.h
+++ b/arch/sparc/include/asm/uctx.h
diff --git a/include/asm-sparc/unaligned.h b/arch/sparc/include/asm/unaligned.h
index 11d2d5fb5902..11d2d5fb5902 100644
--- a/include/asm-sparc/unaligned.h
+++ b/arch/sparc/include/asm/unaligned.h
diff --git a/include/asm-sparc/unistd.h b/arch/sparc/include/asm/unistd.h
index 3c2609618a09..4207fb362da0 100644
--- a/include/asm-sparc/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_UNISTD_H 1#ifndef ___ASM_SPARC_UNISTD_H
2#define ___ASM_SPARC_UNISTD_H 2#define ___ASM_SPARC_UNISTD_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/unistd_64.h> 4#include <asm/unistd_64.h>
5#else 5#else
6#include <asm-sparc/unistd_32.h> 6#include <asm/unistd_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/unistd_32.h b/arch/sparc/include/asm/unistd_32.h
index 648643a9f139..648643a9f139 100644
--- a/include/asm-sparc/unistd_32.h
+++ b/arch/sparc/include/asm/unistd_32.h
diff --git a/include/asm-sparc/unistd_64.h b/arch/sparc/include/asm/unistd_64.h
index c5cc0e052321..c5cc0e052321 100644
--- a/include/asm-sparc/unistd_64.h
+++ b/arch/sparc/include/asm/unistd_64.h
diff --git a/include/asm-sparc/upa.h b/arch/sparc/include/asm/upa.h
index 5b1633223f92..5b1633223f92 100644
--- a/include/asm-sparc/upa.h
+++ b/arch/sparc/include/asm/upa.h
diff --git a/include/asm-sparc/user.h b/arch/sparc/include/asm/user.h
index 3400ea87f148..3400ea87f148 100644
--- a/include/asm-sparc/user.h
+++ b/arch/sparc/include/asm/user.h
diff --git a/include/asm-sparc/utrap.h b/arch/sparc/include/asm/utrap.h
index 9da37babbe5b..b10e527c22d9 100644
--- a/include/asm-sparc/utrap.h
+++ b/arch/sparc/include/asm/utrap.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc64/utrap.h 2 * include/asm/utrap.h
3 * 3 *
4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 */ 5 */
diff --git a/include/asm-sparc/vac-ops.h b/arch/sparc/include/asm/vac-ops.h
index d10527611f11..d10527611f11 100644
--- a/include/asm-sparc/vac-ops.h
+++ b/arch/sparc/include/asm/vac-ops.h
diff --git a/include/asm-sparc/vaddrs.h b/arch/sparc/include/asm/vaddrs.h
index a22fed5a3c6b..541e13755cec 100644
--- a/include/asm-sparc/vaddrs.h
+++ b/arch/sparc/include/asm/vaddrs.h
@@ -4,7 +4,7 @@
4#include <asm/head.h> 4#include <asm/head.h>
5 5
6/* 6/*
7 * asm-sparc/vaddrs.h: Here we define the virtual addresses at 7 * asm/vaddrs.h: Here we define the virtual addresses at
8 * which important things will be mapped. 8 * which important things will be mapped.
9 * 9 *
10 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 10 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
diff --git a/include/asm-sparc/vfc_ioctls.h b/arch/sparc/include/asm/vfc_ioctls.h
index af8b69007b22..af8b69007b22 100644
--- a/include/asm-sparc/vfc_ioctls.h
+++ b/arch/sparc/include/asm/vfc_ioctls.h
diff --git a/include/asm-sparc/vga.h b/arch/sparc/include/asm/vga.h
index c69d5b2ba19a..c69d5b2ba19a 100644
--- a/include/asm-sparc/vga.h
+++ b/arch/sparc/include/asm/vga.h
diff --git a/include/asm-sparc/viking.h b/arch/sparc/include/asm/viking.h
index 989930aeb093..989930aeb093 100644
--- a/include/asm-sparc/viking.h
+++ b/arch/sparc/include/asm/viking.h
diff --git a/include/asm-sparc/vio.h b/arch/sparc/include/asm/vio.h
index d4de32f0f8af..d4de32f0f8af 100644
--- a/include/asm-sparc/vio.h
+++ b/arch/sparc/include/asm/vio.h
diff --git a/include/asm-sparc/visasm.h b/arch/sparc/include/asm/visasm.h
index de797b9bf552..de797b9bf552 100644
--- a/include/asm-sparc/visasm.h
+++ b/arch/sparc/include/asm/visasm.h
diff --git a/include/asm-sparc/watchdog.h b/arch/sparc/include/asm/watchdog.h
index 5baf2d3919cf..5baf2d3919cf 100644
--- a/include/asm-sparc/watchdog.h
+++ b/arch/sparc/include/asm/watchdog.h
diff --git a/include/asm-sparc/winmacro.h b/arch/sparc/include/asm/winmacro.h
index 5b0a06dc3bcb..5b0a06dc3bcb 100644
--- a/include/asm-sparc/winmacro.h
+++ b/arch/sparc/include/asm/winmacro.h
diff --git a/include/asm-sparc/xor.h b/arch/sparc/include/asm/xor.h
index 35089a838c3f..8ed591c7db2d 100644
--- a/include/asm-sparc/xor.h
+++ b/arch/sparc/include/asm/xor.h
@@ -1,8 +1,8 @@
1#ifndef ___ASM_SPARC_XOR_H 1#ifndef ___ASM_SPARC_XOR_H
2#define ___ASM_SPARC_XOR_H 2#define ___ASM_SPARC_XOR_H
3#if defined(__sparc__) && defined(__arch64__) 3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/xor_64.h> 4#include <asm/xor_64.h>
5#else 5#else
6#include <asm-sparc/xor_32.h> 6#include <asm/xor_32.h>
7#endif 7#endif
8#endif 8#endif
diff --git a/include/asm-sparc/xor_32.h b/arch/sparc/include/asm/xor_32.h
index f34b2cfa8206..44bfa0787f3f 100644
--- a/include/asm-sparc/xor_32.h
+++ b/arch/sparc/include/asm/xor_32.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc/xor.h 2 * include/asm/xor.h
3 * 3 *
4 * Optimized RAID-5 checksumming functions for 32-bit Sparc. 4 * Optimized RAID-5 checksumming functions for 32-bit Sparc.
5 * 5 *
diff --git a/include/asm-sparc/xor_64.h b/arch/sparc/include/asm/xor_64.h
index a0233884fc94..bee4bf4be3af 100644
--- a/include/asm-sparc/xor_64.h
+++ b/arch/sparc/include/asm/xor_64.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-sparc64/xor.h 2 * include/asm/xor.h
3 * 3 *
4 * High speed xor_block operation for RAID4/5 utilizing the 4 * High speed xor_block operation for RAID4/5 utilizing the
5 * UltraSparc Visual Instruction Set and Niagara block-init 5 * UltraSparc Visual Instruction Set and Niagara block-init
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 2f96256dc515..e8cdf715a546 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -1196,8 +1196,9 @@ sys_rt_sigreturn:
1196 be 1f 1196 be 1f
1197 nop 1197 nop
1198 1198
1199 add %sp, STACKFRAME_SZ, %o0
1199 call syscall_trace 1200 call syscall_trace
1200 nop 1201 mov 1, %o1
1201 1202
12021: 12031:
1203 /* We are returning to a signal handler. */ 1204 /* We are returning to a signal handler. */
@@ -1287,8 +1288,12 @@ linux_fast_syscall:
1287 mov %i3, %o3 1288 mov %i3, %o3
1288 1289
1289linux_syscall_trace: 1290linux_syscall_trace:
1291 add %sp, STACKFRAME_SZ, %o0
1290 call syscall_trace 1292 call syscall_trace
1291 nop 1293 mov 0, %o1
1294 cmp %o0, 0
1295 bne 3f
1296 mov -ENOSYS, %o0
1292 mov %i0, %o0 1297 mov %i0, %o0
1293 mov %i1, %o1 1298 mov %i1, %o1
1294 mov %i2, %o2 1299 mov %i2, %o2
@@ -1337,6 +1342,7 @@ syscall_is_too_hard:
1337 call %l7 1342 call %l7
1338 mov %i5, %o5 1343 mov %i5, %o5
1339 1344
13453:
1340 st %o0, [%sp + STACKFRAME_SZ + PT_I0] 1346 st %o0, [%sp + STACKFRAME_SZ + PT_I0]
1341 1347
1342ret_sys_call: 1348ret_sys_call:
@@ -1374,6 +1380,8 @@ ret_sys_call:
1374 st %l2, [%sp + STACKFRAME_SZ + PT_NPC] 1380 st %l2, [%sp + STACKFRAME_SZ + PT_NPC]
1375 1381
1376linux_syscall_trace2: 1382linux_syscall_trace2:
1383 add %sp, STACKFRAME_SZ, %o0
1384 mov 1, %o1
1377 call syscall_trace 1385 call syscall_trace
1378 add %l1, 0x4, %l2 /* npc = npc+4 */ 1386 add %l1, 0x4, %l2 /* npc = npc+4 */
1379 st %l1, [%sp + STACKFRAME_SZ + PT_PC] 1387 st %l1, [%sp + STACKFRAME_SZ + PT_PC]
diff --git a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
index 81f3b929743f..20699c701412 100644
--- a/arch/sparc/kernel/ptrace.c
+++ b/arch/sparc/kernel/ptrace.c
@@ -21,6 +21,7 @@
21#include <linux/signal.h> 21#include <linux/signal.h>
22#include <linux/regset.h> 22#include <linux/regset.h>
23#include <linux/elf.h> 23#include <linux/elf.h>
24#include <linux/tracehook.h>
24 25
25#include <asm/pgtable.h> 26#include <asm/pgtable.h>
26#include <asm/system.h> 27#include <asm/system.h>
@@ -450,21 +451,16 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
450 return ret; 451 return ret;
451} 452}
452 453
453asmlinkage void syscall_trace(void) 454asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
454{ 455{
455 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 456 int ret = 0;
456 return; 457
457 if (!(current->ptrace & PT_PTRACED)) 458 if (test_thread_flag(TIF_SYSCALL_TRACE)) {
458 return; 459 if (syscall_exit_p)
459 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) 460 tracehook_report_syscall_exit(regs, 0);
460 ? 0x80 : 0)); 461 else
461 /* 462 ret = tracehook_report_syscall_entry(regs);
462 * this isn't the same as continuing with a signal, but it will do
463 * for normal use. strace only continues with a signal if the
464 * stopping signal is not SIGTRAP. -brl
465 */
466 if (current->exit_code) {
467 send_sig (current->exit_code, current, 1);
468 current->exit_code = 0;
469 } 463 }
464
465 return ret;
470} 466}
diff --git a/arch/sparc/kernel/rtrap.S b/arch/sparc/kernel/rtrap.S
index 891f460b7b96..4da2e1f66290 100644
--- a/arch/sparc/kernel/rtrap.S
+++ b/arch/sparc/kernel/rtrap.S
@@ -69,12 +69,13 @@ ret_trap_lockless_ipi:
69 69
70 ld [%curptr + TI_FLAGS], %g2 70 ld [%curptr + TI_FLAGS], %g2
71signal_p: 71signal_p:
72 andcc %g2, (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK), %g0 72 andcc %g2, _TIF_DO_NOTIFY_RESUME_MASK, %g0
73 bz,a ret_trap_continue 73 bz,a ret_trap_continue
74 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr 74 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr
75 75
76 mov %g2, %o2
76 mov %l5, %o1 77 mov %l5, %o1
77 call do_signal 78 call do_notify_resume
78 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr 79 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr
79 80
80 /* Fall through. */ 81 /* Fall through. */
diff --git a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
index 3fd1df9f9ba7..c94f91c8b6e0 100644
--- a/arch/sparc/kernel/signal.c
+++ b/arch/sparc/kernel/signal.c
@@ -18,6 +18,7 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/binfmts.h> /* do_coredum */ 19#include <linux/binfmts.h> /* do_coredum */
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21#include <linux/tracehook.h>
21 22
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/ptrace.h> 24#include <asm/ptrace.h>
@@ -513,7 +514,7 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
513 * want to handle. Thus you cannot kill init even with a SIGKILL even by 514 * want to handle. Thus you cannot kill init even with a SIGKILL even by
514 * mistake. 515 * mistake.
515 */ 516 */
516asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0) 517static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
517{ 518{
518 struct k_sigaction ka; 519 struct k_sigaction ka;
519 int restart_syscall; 520 int restart_syscall;
@@ -552,6 +553,8 @@ asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0)
552 */ 553 */
553 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 554 if (test_thread_flag(TIF_RESTORE_SIGMASK))
554 clear_thread_flag(TIF_RESTORE_SIGMASK); 555 clear_thread_flag(TIF_RESTORE_SIGMASK);
556
557 tracehook_signal_handler(signr, &info, &ka, regs, 0);
555 return; 558 return;
556 } 559 }
557 if (restart_syscall && 560 if (restart_syscall &&
@@ -579,6 +582,17 @@ asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0)
579 } 582 }
580} 583}
581 584
585void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
586 unsigned long thread_info_flags)
587{
588 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
589 do_signal(regs, orig_i0);
590 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
591 clear_thread_flag(TIF_NOTIFY_RESUME);
592 tracehook_notify_resume(regs);
593 }
594}
595
582asmlinkage int 596asmlinkage int
583do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr, 597do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr,
584 unsigned long sp) 598 unsigned long sp)
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 7c88263256af..923a98959fa7 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -17,6 +17,7 @@ config SPARC64
17 select HAVE_LMB 17 select HAVE_LMB
18 select HAVE_ARCH_KGDB 18 select HAVE_ARCH_KGDB
19 select USE_GENERIC_SMP_HELPERS if SMP 19 select USE_GENERIC_SMP_HELPERS if SMP
20 select HAVE_ARCH_TRACEHOOK
20 21
21config GENERIC_TIME 22config GENERIC_TIME
22 bool 23 bool
diff --git a/arch/sparc64/kernel/compat_audit.c b/arch/sparc64/kernel/compat_audit.c
index c1979482aa92..c831b0a4e660 100644
--- a/arch/sparc64/kernel/compat_audit.c
+++ b/arch/sparc64/kernel/compat_audit.c
@@ -1,4 +1,4 @@
1#include <asm-sparc/unistd.h> 1#include <asm/unistd_32.h>
2 2
3unsigned sparc32_dir_class[] = { 3unsigned sparc32_dir_class[] = {
4#include <asm-generic/audit_dir_write.h> 4#include <asm-generic/audit_dir_write.h>
diff --git a/arch/sparc64/kernel/entry.h b/arch/sparc64/kernel/entry.h
index 32fbab620852..fc294a292899 100644
--- a/arch/sparc64/kernel/entry.h
+++ b/arch/sparc64/kernel/entry.h
@@ -22,8 +22,7 @@ extern void do_notify_resume(struct pt_regs *regs,
22 unsigned long orig_i0, 22 unsigned long orig_i0,
23 unsigned long thread_info_flags); 23 unsigned long thread_info_flags);
24 24
25extern asmlinkage void syscall_trace(struct pt_regs *regs, 25extern asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p);
26 int syscall_exit_p);
27 26
28extern void bad_trap_tl1(struct pt_regs *regs, long lvl); 27extern void bad_trap_tl1(struct pt_regs *regs, long lvl);
29 28
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index f6c9fc92921d..bd578cc4856d 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -23,6 +23,7 @@
23#include <linux/audit.h> 23#include <linux/audit.h>
24#include <linux/signal.h> 24#include <linux/signal.h>
25#include <linux/regset.h> 25#include <linux/regset.h>
26#include <linux/tracehook.h>
26#include <linux/compat.h> 27#include <linux/compat.h>
27#include <linux/elf.h> 28#include <linux/elf.h>
28 29
@@ -1049,8 +1050,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1049 return ret; 1050 return ret;
1050} 1051}
1051 1052
1052asmlinkage void syscall_trace(struct pt_regs *regs, int syscall_exit_p) 1053asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
1053{ 1054{
1055 int ret = 0;
1056
1054 /* do the secure computing check first */ 1057 /* do the secure computing check first */
1055 secure_computing(regs->u_regs[UREG_G1]); 1058 secure_computing(regs->u_regs[UREG_G1]);
1056 1059
@@ -1064,27 +1067,14 @@ asmlinkage void syscall_trace(struct pt_regs *regs, int syscall_exit_p)
1064 audit_syscall_exit(result, regs->u_regs[UREG_I0]); 1067 audit_syscall_exit(result, regs->u_regs[UREG_I0]);
1065 } 1068 }
1066 1069
1067 if (!(current->ptrace & PT_PTRACED)) 1070 if (test_thread_flag(TIF_SYSCALL_TRACE)) {
1068 goto out; 1071 if (syscall_exit_p)
1069 1072 tracehook_report_syscall_exit(regs, 0);
1070 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 1073 else
1071 goto out; 1074 ret = tracehook_report_syscall_entry(regs);
1072
1073 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1074 ? 0x80 : 0));
1075
1076 /*
1077 * this isn't the same as continuing with a signal, but it will do
1078 * for normal use. strace only continues with a signal if the
1079 * stopping signal is not SIGTRAP. -brl
1080 */
1081 if (current->exit_code) {
1082 send_sig(current->exit_code, current, 1);
1083 current->exit_code = 0;
1084 } 1075 }
1085 1076
1086out: 1077 if (unlikely(current->audit_context) && !syscall_exit_p && !ret)
1087 if (unlikely(current->audit_context) && !syscall_exit_p)
1088 audit_syscall_entry((test_thread_flag(TIF_32BIT) ? 1078 audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
1089 AUDIT_ARCH_SPARC : 1079 AUDIT_ARCH_SPARC :
1090 AUDIT_ARCH_SPARC64), 1080 AUDIT_ARCH_SPARC64),
@@ -1093,4 +1083,6 @@ out:
1093 regs->u_regs[UREG_I1], 1083 regs->u_regs[UREG_I1],
1094 regs->u_regs[UREG_I2], 1084 regs->u_regs[UREG_I2],
1095 regs->u_regs[UREG_I3]); 1085 regs->u_regs[UREG_I3]);
1086
1087 return ret;
1096} 1088}
diff --git a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S
index c6fc695fe1fe..97a993c1f7f3 100644
--- a/arch/sparc64/kernel/rtrap.S
+++ b/arch/sparc64/kernel/rtrap.S
@@ -46,7 +46,7 @@ __handle_user_windows:
46 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 46 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
47 ldx [%g6 + TI_FLAGS], %l0 47 ldx [%g6 + TI_FLAGS], %l0
48 48
491: andcc %l0, _TIF_SIGPENDING, %g0 491: andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0
50 be,pt %xcc, __handle_user_windows_continue 50 be,pt %xcc, __handle_user_windows_continue
51 nop 51 nop
52 mov %l5, %o1 52 mov %l5, %o1
@@ -86,7 +86,7 @@ __handle_perfctrs:
86 wrpr %g0, RTRAP_PSTATE, %pstate 86 wrpr %g0, RTRAP_PSTATE, %pstate
87 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 87 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
88 ldx [%g6 + TI_FLAGS], %l0 88 ldx [%g6 + TI_FLAGS], %l0
891: andcc %l0, _TIF_SIGPENDING, %g0 891: andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0
90 90
91 be,pt %xcc, __handle_perfctrs_continue 91 be,pt %xcc, __handle_perfctrs_continue
92 sethi %hi(TSTATE_PEF), %o0 92 sethi %hi(TSTATE_PEF), %o0
@@ -195,7 +195,7 @@ __handle_preemption_continue:
195 andcc %l1, %o0, %g0 195 andcc %l1, %o0, %g0
196 andcc %l0, _TIF_NEED_RESCHED, %g0 196 andcc %l0, _TIF_NEED_RESCHED, %g0
197 bne,pn %xcc, __handle_preemption 197 bne,pn %xcc, __handle_preemption
198 andcc %l0, _TIF_SIGPENDING, %g0 198 andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0
199 bne,pn %xcc, __handle_signal 199 bne,pn %xcc, __handle_signal
200__handle_signal_continue: 200__handle_signal_continue:
201 ldub [%g6 + TI_WSAVED], %o2 201 ldub [%g6 + TI_WSAVED], %o2
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index 9667e96fd513..d1b84456a9ee 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -17,11 +17,13 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/wait.h> 18#include <linux/wait.h>
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/tracehook.h>
20#include <linux/unistd.h> 21#include <linux/unistd.h>
21#include <linux/mm.h> 22#include <linux/mm.h>
22#include <linux/tty.h> 23#include <linux/tty.h>
23#include <linux/binfmts.h> 24#include <linux/binfmts.h>
24#include <linux/bitops.h> 25#include <linux/bitops.h>
26#include <linux/tracehook.h>
25 27
26#include <asm/uaccess.h> 28#include <asm/uaccess.h>
27#include <asm/ptrace.h> 29#include <asm/ptrace.h>
@@ -574,6 +576,8 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
574 * clear the TS_RESTORE_SIGMASK flag. 576 * clear the TS_RESTORE_SIGMASK flag.
575 */ 577 */
576 current_thread_info()->status &= ~TS_RESTORE_SIGMASK; 578 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
579
580 tracehook_signal_handler(signr, &info, &ka, regs, 0);
577 return; 581 return;
578 } 582 }
579 if (restart_syscall && 583 if (restart_syscall &&
@@ -605,4 +609,8 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long
605{ 609{
606 if (thread_info_flags & _TIF_SIGPENDING) 610 if (thread_info_flags & _TIF_SIGPENDING)
607 do_signal(regs, orig_i0); 611 do_signal(regs, orig_i0);
612 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
613 clear_thread_flag(TIF_NOTIFY_RESUME);
614 tracehook_notify_resume(regs);
615 }
608} 616}
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index 97cdd1bf4a10..ba5b09ad6666 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -19,6 +19,7 @@
19#include <linux/binfmts.h> 19#include <linux/binfmts.h>
20#include <linux/compat.h> 20#include <linux/compat.h>
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/tracehook.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/ptrace.h> 25#include <asm/ptrace.h>
@@ -794,6 +795,8 @@ void do_signal32(sigset_t *oldset, struct pt_regs * regs,
794 * clear the TS_RESTORE_SIGMASK flag. 795 * clear the TS_RESTORE_SIGMASK flag.
795 */ 796 */
796 current_thread_info()->status &= ~TS_RESTORE_SIGMASK; 797 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
798
799 tracehook_signal_handler(signr, &info, &ka, regs, 0);
797 return; 800 return;
798 } 801 }
799 if (restart_syscall && 802 if (restart_syscall &&
diff --git a/arch/sparc64/kernel/syscalls.S b/arch/sparc64/kernel/syscalls.S
index db19ed67acf6..a2f24270ed8a 100644
--- a/arch/sparc64/kernel/syscalls.S
+++ b/arch/sparc64/kernel/syscalls.S
@@ -162,6 +162,8 @@ linux_syscall_trace32:
162 add %sp, PTREGS_OFF, %o0 162 add %sp, PTREGS_OFF, %o0
163 call syscall_trace 163 call syscall_trace
164 clr %o1 164 clr %o1
165 brnz,pn %o0, 3f
166 mov -ENOSYS, %o0
165 srl %i0, 0, %o0 167 srl %i0, 0, %o0
166 srl %i4, 0, %o4 168 srl %i4, 0, %o4
167 srl %i1, 0, %o1 169 srl %i1, 0, %o1
@@ -173,6 +175,8 @@ linux_syscall_trace:
173 add %sp, PTREGS_OFF, %o0 175 add %sp, PTREGS_OFF, %o0
174 call syscall_trace 176 call syscall_trace
175 clr %o1 177 clr %o1
178 brnz,pn %o0, 3f
179 mov -ENOSYS, %o0
176 mov %i0, %o0 180 mov %i0, %o0
177 mov %i1, %o1 181 mov %i1, %o1
178 mov %i2, %o2 182 mov %i2, %o2
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 713297473951..4e821b3ecb03 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -392,51 +392,6 @@ void __kprobes flush_icache_range(unsigned long start, unsigned long end)
392 } 392 }
393} 393}
394 394
395void show_mem(void)
396{
397 unsigned long total = 0, reserved = 0;
398 unsigned long shared = 0, cached = 0;
399 pg_data_t *pgdat;
400
401 printk(KERN_INFO "Mem-info:\n");
402 show_free_areas();
403 printk(KERN_INFO "Free swap: %6ldkB\n",
404 nr_swap_pages << (PAGE_SHIFT-10));
405 for_each_online_pgdat(pgdat) {
406 unsigned long i, flags;
407
408 pgdat_resize_lock(pgdat, &flags);
409 for (i = 0; i < pgdat->node_spanned_pages; i++) {
410 struct page *page = pgdat_page_nr(pgdat, i);
411 total++;
412 if (PageReserved(page))
413 reserved++;
414 else if (PageSwapCache(page))
415 cached++;
416 else if (page_count(page))
417 shared += page_count(page) - 1;
418 }
419 pgdat_resize_unlock(pgdat, &flags);
420 }
421
422 printk(KERN_INFO "%lu pages of RAM\n", total);
423 printk(KERN_INFO "%lu reserved pages\n", reserved);
424 printk(KERN_INFO "%lu pages shared\n", shared);
425 printk(KERN_INFO "%lu pages swap cached\n", cached);
426
427 printk(KERN_INFO "%lu pages dirty\n",
428 global_page_state(NR_FILE_DIRTY));
429 printk(KERN_INFO "%lu pages writeback\n",
430 global_page_state(NR_WRITEBACK));
431 printk(KERN_INFO "%lu pages mapped\n",
432 global_page_state(NR_FILE_MAPPED));
433 printk(KERN_INFO "%lu pages slab\n",
434 global_page_state(NR_SLAB_RECLAIMABLE) +
435 global_page_state(NR_SLAB_UNRECLAIMABLE));
436 printk(KERN_INFO "%lu pages pagetables\n",
437 global_page_state(NR_PAGETABLE));
438}
439
440void mmu_info(struct seq_file *m) 395void mmu_info(struct seq_file *m)
441{ 396{
442 if (tlb_type == cheetah) 397 if (tlb_type == cheetah)
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index e2274ef3155d..61d7e6138ff5 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -264,37 +264,6 @@ void free_initrd_mem(unsigned long start, unsigned long end)
264} 264}
265#endif 265#endif
266 266
267void show_mem(void)
268{
269 int pfn, total = 0, reserved = 0;
270 int shared = 0, cached = 0;
271 int high_mem = 0;
272 struct page *page;
273
274 printk(KERN_INFO "Mem-info:\n");
275 show_free_areas();
276 printk(KERN_INFO "Free swap: %6ldkB\n",
277 nr_swap_pages<<(PAGE_SHIFT-10));
278 pfn = max_mapnr;
279 while (pfn-- > 0) {
280 page = pfn_to_page(pfn);
281 total++;
282 if (PageHighMem(page))
283 high_mem++;
284 if (PageReserved(page))
285 reserved++;
286 else if (PageSwapCache(page))
287 cached++;
288 else if (page_count(page))
289 shared += page_count(page) - 1;
290 }
291 printk(KERN_INFO "%d pages of RAM\n", total);
292 printk(KERN_INFO "%d pages of HIGHMEM\n", high_mem);
293 printk(KERN_INFO "%d reserved pages\n", reserved);
294 printk(KERN_INFO "%d pages shared\n", shared);
295 printk(KERN_INFO "%d pages swap cached\n", cached);
296}
297
298/* Allocate and free page tables. */ 267/* Allocate and free page tables. */
299 268
300pgd_t *pgd_alloc(struct mm_struct *mm) 269pgd_t *pgd_alloc(struct mm_struct *mm)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 97e97ee96628..608a12ff483a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -22,6 +22,7 @@ config X86
22 select HAVE_IDE 22 select HAVE_IDE
23 select HAVE_OPROFILE 23 select HAVE_OPROFILE
24 select HAVE_IOREMAP_PROT 24 select HAVE_IOREMAP_PROT
25 select HAVE_GET_USER_PAGES_FAST
25 select HAVE_KPROBES 26 select HAVE_KPROBES
26 select ARCH_WANT_OPTIONAL_GPIOLIB 27 select ARCH_WANT_OPTIONAL_GPIOLIB
27 select HAVE_KRETPROBES 28 select HAVE_KRETPROBES
@@ -29,6 +30,7 @@ config X86
29 select HAVE_FTRACE 30 select HAVE_FTRACE
30 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) 31 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
31 select HAVE_ARCH_KGDB if !X86_VOYAGER 32 select HAVE_ARCH_KGDB if !X86_VOYAGER
33 select HAVE_GENERIC_DMA_COHERENT if X86_32
32 select HAVE_EFFICIENT_UNALIGNED_ACCESS 34 select HAVE_EFFICIENT_UNALIGNED_ACCESS
33 35
34config ARCH_DEFCONFIG 36config ARCH_DEFCONFIG
@@ -1275,6 +1277,14 @@ config CRASH_DUMP
1275 (CONFIG_RELOCATABLE=y). 1277 (CONFIG_RELOCATABLE=y).
1276 For more details see Documentation/kdump/kdump.txt 1278 For more details see Documentation/kdump/kdump.txt
1277 1279
1280config KEXEC_JUMP
1281 bool "kexec jump (EXPERIMENTAL)"
1282 depends on EXPERIMENTAL
1283 depends on KEXEC && HIBERNATION && X86_32
1284 help
1285 Jump between original kernel and kexeced kernel and invoke
1286 code in physical address mode via KEXEC
1287
1278config PHYSICAL_START 1288config PHYSICAL_START
1279 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 1289 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
1280 default "0x1000000" if X86_NUMAQ 1290 default "0x1000000" if X86_NUMAQ
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 58cccb6483b0..a0e1dbe67dc1 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -441,12 +441,6 @@ beyond_if:
441 regs->r8 = regs->r9 = regs->r10 = regs->r11 = 441 regs->r8 = regs->r9 = regs->r10 = regs->r11 =
442 regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0; 442 regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
443 set_fs(USER_DS); 443 set_fs(USER_DS);
444 if (unlikely(current->ptrace & PT_PTRACED)) {
445 if (current->ptrace & PT_TRACE_EXEC)
446 ptrace_notify((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
447 else
448 send_sig(SIGTRAP, current, 0);
449 }
450 return 0; 444 return 0;
451} 445}
452 446
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index 9220cf46aa10..c2502eb9aa83 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -73,7 +73,6 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
73 struct cpuinfo_x86 *c = &cpu_data(cpu); 73 struct cpuinfo_x86 *c = &cpu_data(cpu);
74 74
75 cpumask_t saved_mask; 75 cpumask_t saved_mask;
76 cpumask_of_cpu_ptr(new_mask, cpu);
77 int retval; 76 int retval;
78 unsigned int eax, ebx, ecx, edx; 77 unsigned int eax, ebx, ecx, edx;
79 unsigned int edx_part; 78 unsigned int edx_part;
@@ -92,7 +91,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
92 91
93 /* Make sure we are running on right CPU */ 92 /* Make sure we are running on right CPU */
94 saved_mask = current->cpus_allowed; 93 saved_mask = current->cpus_allowed;
95 retval = set_cpus_allowed_ptr(current, new_mask); 94 retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
96 if (retval) 95 if (retval)
97 return -1; 96 return -1;
98 97
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 74697408576f..22d7d050905d 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -29,9 +29,6 @@
29 29
30#define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) 30#define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28))
31 31
32#define to_pages(addr, size) \
33 (round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
34
35#define EXIT_LOOP_COUNT 10000000 32#define EXIT_LOOP_COUNT 10000000
36 33
37static DEFINE_RWLOCK(amd_iommu_devtable_lock); 34static DEFINE_RWLOCK(amd_iommu_devtable_lock);
@@ -185,7 +182,7 @@ static int iommu_flush_pages(struct amd_iommu *iommu, u16 domid,
185 u64 address, size_t size) 182 u64 address, size_t size)
186{ 183{
187 int s = 0; 184 int s = 0;
188 unsigned pages = to_pages(address, size); 185 unsigned pages = iommu_num_pages(address, size);
189 186
190 address &= PAGE_MASK; 187 address &= PAGE_MASK;
191 188
@@ -557,8 +554,8 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu,
557 if (iommu->exclusion_start && 554 if (iommu->exclusion_start &&
558 iommu->exclusion_start < dma_dom->aperture_size) { 555 iommu->exclusion_start < dma_dom->aperture_size) {
559 unsigned long startpage = iommu->exclusion_start >> PAGE_SHIFT; 556 unsigned long startpage = iommu->exclusion_start >> PAGE_SHIFT;
560 int pages = to_pages(iommu->exclusion_start, 557 int pages = iommu_num_pages(iommu->exclusion_start,
561 iommu->exclusion_length); 558 iommu->exclusion_length);
562 dma_ops_reserve_addresses(dma_dom, startpage, pages); 559 dma_ops_reserve_addresses(dma_dom, startpage, pages);
563 } 560 }
564 561
@@ -767,7 +764,7 @@ static dma_addr_t __map_single(struct device *dev,
767 unsigned int pages; 764 unsigned int pages;
768 int i; 765 int i;
769 766
770 pages = to_pages(paddr, size); 767 pages = iommu_num_pages(paddr, size);
771 paddr &= PAGE_MASK; 768 paddr &= PAGE_MASK;
772 769
773 address = dma_ops_alloc_addresses(dev, dma_dom, pages); 770 address = dma_ops_alloc_addresses(dev, dma_dom, pages);
@@ -802,7 +799,7 @@ static void __unmap_single(struct amd_iommu *iommu,
802 if ((dma_addr == 0) || (dma_addr + size > dma_dom->aperture_size)) 799 if ((dma_addr == 0) || (dma_addr + size > dma_dom->aperture_size))
803 return; 800 return;
804 801
805 pages = to_pages(dma_addr, size); 802 pages = iommu_num_pages(dma_addr, size);
806 dma_addr &= PAGE_MASK; 803 dma_addr &= PAGE_MASK;
807 start = dma_addr; 804 start = dma_addr;
808 805
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index ff2fff56f0a8..dd097b835839 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -200,12 +200,10 @@ static void drv_read(struct drv_cmd *cmd)
200static void drv_write(struct drv_cmd *cmd) 200static void drv_write(struct drv_cmd *cmd)
201{ 201{
202 cpumask_t saved_mask = current->cpus_allowed; 202 cpumask_t saved_mask = current->cpus_allowed;
203 cpumask_of_cpu_ptr_declare(cpu_mask);
204 unsigned int i; 203 unsigned int i;
205 204
206 for_each_cpu_mask_nr(i, cmd->mask) { 205 for_each_cpu_mask_nr(i, cmd->mask) {
207 cpumask_of_cpu_ptr_next(cpu_mask, i); 206 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
208 set_cpus_allowed_ptr(current, cpu_mask);
209 do_drv_write(cmd); 207 do_drv_write(cmd);
210 } 208 }
211 209
@@ -269,12 +267,11 @@ static unsigned int get_measured_perf(unsigned int cpu)
269 } aperf_cur, mperf_cur; 267 } aperf_cur, mperf_cur;
270 268
271 cpumask_t saved_mask; 269 cpumask_t saved_mask;
272 cpumask_of_cpu_ptr(cpu_mask, cpu);
273 unsigned int perf_percent; 270 unsigned int perf_percent;
274 unsigned int retval; 271 unsigned int retval;
275 272
276 saved_mask = current->cpus_allowed; 273 saved_mask = current->cpus_allowed;
277 set_cpus_allowed_ptr(current, cpu_mask); 274 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
278 if (get_cpu() != cpu) { 275 if (get_cpu() != cpu) {
279 /* We were not able to run on requested processor */ 276 /* We were not able to run on requested processor */
280 put_cpu(); 277 put_cpu();
@@ -340,7 +337,6 @@ static unsigned int get_measured_perf(unsigned int cpu)
340 337
341static unsigned int get_cur_freq_on_cpu(unsigned int cpu) 338static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
342{ 339{
343 cpumask_of_cpu_ptr(cpu_mask, cpu);
344 struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); 340 struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu);
345 unsigned int freq; 341 unsigned int freq;
346 unsigned int cached_freq; 342 unsigned int cached_freq;
@@ -353,7 +349,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
353 } 349 }
354 350
355 cached_freq = data->freq_table[data->acpi_data->state].frequency; 351 cached_freq = data->freq_table[data->acpi_data->state].frequency;
356 freq = extract_freq(get_cur_val(cpu_mask), data); 352 freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data);
357 if (freq != cached_freq) { 353 if (freq != cached_freq) {
358 /* 354 /*
359 * The dreaded BIOS frequency change behind our back. 355 * The dreaded BIOS frequency change behind our back.
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 53c7b6936973..c45ca6d4dce1 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -479,12 +479,11 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi
479static int check_supported_cpu(unsigned int cpu) 479static int check_supported_cpu(unsigned int cpu)
480{ 480{
481 cpumask_t oldmask; 481 cpumask_t oldmask;
482 cpumask_of_cpu_ptr(cpu_mask, cpu);
483 u32 eax, ebx, ecx, edx; 482 u32 eax, ebx, ecx, edx;
484 unsigned int rc = 0; 483 unsigned int rc = 0;
485 484
486 oldmask = current->cpus_allowed; 485 oldmask = current->cpus_allowed;
487 set_cpus_allowed_ptr(current, cpu_mask); 486 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
488 487
489 if (smp_processor_id() != cpu) { 488 if (smp_processor_id() != cpu) {
490 printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); 489 printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu);
@@ -1017,7 +1016,6 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i
1017static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) 1016static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation)
1018{ 1017{
1019 cpumask_t oldmask; 1018 cpumask_t oldmask;
1020 cpumask_of_cpu_ptr(cpu_mask, pol->cpu);
1021 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); 1019 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
1022 u32 checkfid; 1020 u32 checkfid;
1023 u32 checkvid; 1021 u32 checkvid;
@@ -1032,7 +1030,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
1032 1030
1033 /* only run on specific CPU from here on */ 1031 /* only run on specific CPU from here on */
1034 oldmask = current->cpus_allowed; 1032 oldmask = current->cpus_allowed;
1035 set_cpus_allowed_ptr(current, cpu_mask); 1033 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
1036 1034
1037 if (smp_processor_id() != pol->cpu) { 1035 if (smp_processor_id() != pol->cpu) {
1038 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); 1036 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1107,7 +1105,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1107{ 1105{
1108 struct powernow_k8_data *data; 1106 struct powernow_k8_data *data;
1109 cpumask_t oldmask; 1107 cpumask_t oldmask;
1110 cpumask_of_cpu_ptr_declare(newmask);
1111 int rc; 1108 int rc;
1112 1109
1113 if (!cpu_online(pol->cpu)) 1110 if (!cpu_online(pol->cpu))
@@ -1159,8 +1156,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1159 1156
1160 /* only run on specific CPU from here on */ 1157 /* only run on specific CPU from here on */
1161 oldmask = current->cpus_allowed; 1158 oldmask = current->cpus_allowed;
1162 cpumask_of_cpu_ptr_next(newmask, pol->cpu); 1159 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
1163 set_cpus_allowed_ptr(current, newmask);
1164 1160
1165 if (smp_processor_id() != pol->cpu) { 1161 if (smp_processor_id() != pol->cpu) {
1166 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); 1162 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1182,7 +1178,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1182 set_cpus_allowed_ptr(current, &oldmask); 1178 set_cpus_allowed_ptr(current, &oldmask);
1183 1179
1184 if (cpu_family == CPU_HW_PSTATE) 1180 if (cpu_family == CPU_HW_PSTATE)
1185 pol->cpus = *newmask; 1181 pol->cpus = cpumask_of_cpu(pol->cpu);
1186 else 1182 else
1187 pol->cpus = per_cpu(cpu_core_map, pol->cpu); 1183 pol->cpus = per_cpu(cpu_core_map, pol->cpu);
1188 data->available_cores = &(pol->cpus); 1184 data->available_cores = &(pol->cpus);
@@ -1248,7 +1244,6 @@ static unsigned int powernowk8_get (unsigned int cpu)
1248{ 1244{
1249 struct powernow_k8_data *data; 1245 struct powernow_k8_data *data;
1250 cpumask_t oldmask = current->cpus_allowed; 1246 cpumask_t oldmask = current->cpus_allowed;
1251 cpumask_of_cpu_ptr(newmask, cpu);
1252 unsigned int khz = 0; 1247 unsigned int khz = 0;
1253 unsigned int first; 1248 unsigned int first;
1254 1249
@@ -1258,7 +1253,7 @@ static unsigned int powernowk8_get (unsigned int cpu)
1258 if (!data) 1253 if (!data)
1259 return -EINVAL; 1254 return -EINVAL;
1260 1255
1261 set_cpus_allowed_ptr(current, newmask); 1256 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
1262 if (smp_processor_id() != cpu) { 1257 if (smp_processor_id() != cpu) {
1263 printk(KERN_ERR PFX 1258 printk(KERN_ERR PFX
1264 "limiting to CPU %d failed in powernowk8_get\n", cpu); 1259 "limiting to CPU %d failed in powernowk8_get\n", cpu);
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index ca2ac13b7af2..15e13c01cc36 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -324,10 +324,9 @@ static unsigned int get_cur_freq(unsigned int cpu)
324 unsigned l, h; 324 unsigned l, h;
325 unsigned clock_freq; 325 unsigned clock_freq;
326 cpumask_t saved_mask; 326 cpumask_t saved_mask;
327 cpumask_of_cpu_ptr(new_mask, cpu);
328 327
329 saved_mask = current->cpus_allowed; 328 saved_mask = current->cpus_allowed;
330 set_cpus_allowed_ptr(current, new_mask); 329 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
331 if (smp_processor_id() != cpu) 330 if (smp_processor_id() != cpu)
332 return 0; 331 return 0;
333 332
@@ -585,15 +584,12 @@ static int centrino_target (struct cpufreq_policy *policy,
585 * Best effort undo.. 584 * Best effort undo..
586 */ 585 */
587 586
588 if (!cpus_empty(*covered_cpus)) { 587 if (!cpus_empty(*covered_cpus))
589 cpumask_of_cpu_ptr_declare(new_mask);
590
591 for_each_cpu_mask_nr(j, *covered_cpus) { 588 for_each_cpu_mask_nr(j, *covered_cpus) {
592 cpumask_of_cpu_ptr_next(new_mask, j); 589 set_cpus_allowed_ptr(current,
593 set_cpus_allowed_ptr(current, new_mask); 590 &cpumask_of_cpu(j));
594 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); 591 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
595 } 592 }
596 }
597 593
598 tmp = freqs.new; 594 tmp = freqs.new;
599 freqs.new = freqs.old; 595 freqs.new = freqs.old;
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
index 2f3728dc24f6..191f7263c61d 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
@@ -244,8 +244,7 @@ static unsigned int _speedstep_get(const cpumask_t *cpus)
244 244
245static unsigned int speedstep_get(unsigned int cpu) 245static unsigned int speedstep_get(unsigned int cpu)
246{ 246{
247 cpumask_of_cpu_ptr(newmask, cpu); 247 return _speedstep_get(&cpumask_of_cpu(cpu));
248 return _speedstep_get(newmask);
249} 248}
250 249
251/** 250/**
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 650d40f7912b..6b0a10b002f1 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -516,7 +516,6 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
516 unsigned long j; 516 unsigned long j;
517 int retval; 517 int retval;
518 cpumask_t oldmask; 518 cpumask_t oldmask;
519 cpumask_of_cpu_ptr(newmask, cpu);
520 519
521 if (num_cache_leaves == 0) 520 if (num_cache_leaves == 0)
522 return -ENOENT; 521 return -ENOENT;
@@ -527,7 +526,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
527 return -ENOMEM; 526 return -ENOMEM;
528 527
529 oldmask = current->cpus_allowed; 528 oldmask = current->cpus_allowed;
530 retval = set_cpus_allowed_ptr(current, newmask); 529 retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
531 if (retval) 530 if (retval)
532 goto out; 531 goto out;
533 532
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index f67e93441caf..a7010c3a377a 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -456,9 +456,6 @@ is386: movl $2,%ecx # set MP
4561: 4561:
457#endif /* CONFIG_SMP */ 457#endif /* CONFIG_SMP */
458 jmp *(initial_code) 458 jmp *(initial_code)
459.align 4
460ENTRY(initial_code)
461 .long i386_start_kernel
462 459
463/* 460/*
464 * We depend on ET to be correct. This checks for 287/387. 461 * We depend on ET to be correct. This checks for 287/387.
@@ -601,6 +598,11 @@ ignore_int:
601#endif 598#endif
602 iret 599 iret
603 600
601.section .cpuinit.data,"wa"
602.align 4
603ENTRY(initial_code)
604 .long i386_start_kernel
605
604.section .text 606.section .text
605/* 607/*
606 * Real beginning of normal "text" segment 608 * Real beginning of normal "text" segment
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 3fee2aa50f3f..b68e21f06f4f 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -62,12 +62,10 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
62 62
63 if (reload) { 63 if (reload) {
64#ifdef CONFIG_SMP 64#ifdef CONFIG_SMP
65 cpumask_of_cpu_ptr_declare(mask);
66
67 preempt_disable(); 65 preempt_disable();
68 load_LDT(pc); 66 load_LDT(pc);
69 cpumask_of_cpu_ptr_next(mask, smp_processor_id()); 67 if (!cpus_equal(current->mm->cpu_vm_mask,
70 if (!cpus_equal(current->mm->cpu_vm_mask, *mask)) 68 cpumask_of_cpu(smp_processor_id())))
71 smp_call_function(flush_ldt, current->mm, 1); 69 smp_call_function(flush_ldt, current->mm, 1);
72 preempt_enable(); 70 preempt_enable();
73#else 71#else
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 8864230d55af..9fe478d98406 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -22,6 +22,7 @@
22#include <asm/cpufeature.h> 22#include <asm/cpufeature.h>
23#include <asm/desc.h> 23#include <asm/desc.h>
24#include <asm/system.h> 24#include <asm/system.h>
25#include <asm/cacheflush.h>
25 26
26#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE))) 27#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
27static u32 kexec_pgd[1024] PAGE_ALIGNED; 28static u32 kexec_pgd[1024] PAGE_ALIGNED;
@@ -85,10 +86,12 @@ static void load_segments(void)
85 * reboot code buffer to allow us to avoid allocations 86 * reboot code buffer to allow us to avoid allocations
86 * later. 87 * later.
87 * 88 *
88 * Currently nothing. 89 * Make control page executable.
89 */ 90 */
90int machine_kexec_prepare(struct kimage *image) 91int machine_kexec_prepare(struct kimage *image)
91{ 92{
93 if (nx_enabled)
94 set_pages_x(image->control_code_page, 1);
92 return 0; 95 return 0;
93} 96}
94 97
@@ -98,27 +101,48 @@ int machine_kexec_prepare(struct kimage *image)
98 */ 101 */
99void machine_kexec_cleanup(struct kimage *image) 102void machine_kexec_cleanup(struct kimage *image)
100{ 103{
104 if (nx_enabled)
105 set_pages_nx(image->control_code_page, 1);
101} 106}
102 107
103/* 108/*
104 * Do not allocate memory (or fail in any way) in machine_kexec(). 109 * Do not allocate memory (or fail in any way) in machine_kexec().
105 * We are past the point of no return, committed to rebooting now. 110 * We are past the point of no return, committed to rebooting now.
106 */ 111 */
107NORET_TYPE void machine_kexec(struct kimage *image) 112void machine_kexec(struct kimage *image)
108{ 113{
109 unsigned long page_list[PAGES_NR]; 114 unsigned long page_list[PAGES_NR];
110 void *control_page; 115 void *control_page;
116 asmlinkage unsigned long
117 (*relocate_kernel_ptr)(unsigned long indirection_page,
118 unsigned long control_page,
119 unsigned long start_address,
120 unsigned int has_pae,
121 unsigned int preserve_context);
111 122
112 tracer_disable(); 123 tracer_disable();
113 124
114 /* Interrupts aren't acceptable while we reboot */ 125 /* Interrupts aren't acceptable while we reboot */
115 local_irq_disable(); 126 local_irq_disable();
116 127
128 if (image->preserve_context) {
129#ifdef CONFIG_X86_IO_APIC
130 /* We need to put APICs in legacy mode so that we can
131 * get timer interrupts in second kernel. kexec/kdump
132 * paths already have calls to disable_IO_APIC() in
133 * one form or other. kexec jump path also need
134 * one.
135 */
136 disable_IO_APIC();
137#endif
138 }
139
117 control_page = page_address(image->control_code_page); 140 control_page = page_address(image->control_code_page);
118 memcpy(control_page, relocate_kernel, PAGE_SIZE); 141 memcpy(control_page, relocate_kernel, PAGE_SIZE/2);
119 142
143 relocate_kernel_ptr = control_page;
120 page_list[PA_CONTROL_PAGE] = __pa(control_page); 144 page_list[PA_CONTROL_PAGE] = __pa(control_page);
121 page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel; 145 page_list[VA_CONTROL_PAGE] = (unsigned long)control_page;
122 page_list[PA_PGD] = __pa(kexec_pgd); 146 page_list[PA_PGD] = __pa(kexec_pgd);
123 page_list[VA_PGD] = (unsigned long)kexec_pgd; 147 page_list[VA_PGD] = (unsigned long)kexec_pgd;
124#ifdef CONFIG_X86_PAE 148#ifdef CONFIG_X86_PAE
@@ -131,6 +155,7 @@ NORET_TYPE void machine_kexec(struct kimage *image)
131 page_list[VA_PTE_0] = (unsigned long)kexec_pte0; 155 page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
132 page_list[PA_PTE_1] = __pa(kexec_pte1); 156 page_list[PA_PTE_1] = __pa(kexec_pte1);
133 page_list[VA_PTE_1] = (unsigned long)kexec_pte1; 157 page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
158 page_list[PA_SWAP_PAGE] = (page_to_pfn(image->swap_page) << PAGE_SHIFT);
134 159
135 /* The segment registers are funny things, they have both a 160 /* The segment registers are funny things, they have both a
136 * visible and an invisible part. Whenever the visible part is 161 * visible and an invisible part. Whenever the visible part is
@@ -149,8 +174,10 @@ NORET_TYPE void machine_kexec(struct kimage *image)
149 set_idt(phys_to_virt(0),0); 174 set_idt(phys_to_virt(0),0);
150 175
151 /* now call it */ 176 /* now call it */
152 relocate_kernel((unsigned long)image->head, (unsigned long)page_list, 177 image->start = relocate_kernel_ptr((unsigned long)image->head,
153 image->start, cpu_has_pae); 178 (unsigned long)page_list,
179 image->start, cpu_has_pae,
180 image->preserve_context);
154} 181}
155 182
156void arch_crash_save_vmcoreinfo(void) 183void arch_crash_save_vmcoreinfo(void)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 9dd9262693a3..c43caa3a91f3 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -181,7 +181,7 @@ void machine_kexec_cleanup(struct kimage *image)
181 * Do not allocate memory (or fail in any way) in machine_kexec(). 181 * Do not allocate memory (or fail in any way) in machine_kexec().
182 * We are past the point of no return, committed to rebooting now. 182 * We are past the point of no return, committed to rebooting now.
183 */ 183 */
184NORET_TYPE void machine_kexec(struct kimage *image) 184void machine_kexec(struct kimage *image)
185{ 185{
186 unsigned long page_list[PAGES_NR]; 186 unsigned long page_list[PAGES_NR];
187 void *control_page; 187 void *control_page;
diff --git a/arch/x86/kernel/microcode.c b/arch/x86/kernel/microcode.c
index 6994c751590e..652fa5c38ebe 100644
--- a/arch/x86/kernel/microcode.c
+++ b/arch/x86/kernel/microcode.c
@@ -388,7 +388,6 @@ static int do_microcode_update (void)
388 void *new_mc = NULL; 388 void *new_mc = NULL;
389 int cpu; 389 int cpu;
390 cpumask_t old; 390 cpumask_t old;
391 cpumask_of_cpu_ptr_declare(newmask);
392 391
393 old = current->cpus_allowed; 392 old = current->cpus_allowed;
394 393
@@ -405,8 +404,7 @@ static int do_microcode_update (void)
405 404
406 if (!uci->valid) 405 if (!uci->valid)
407 continue; 406 continue;
408 cpumask_of_cpu_ptr_next(newmask, cpu); 407 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
409 set_cpus_allowed_ptr(current, newmask);
410 error = get_maching_microcode(new_mc, cpu); 408 error = get_maching_microcode(new_mc, cpu);
411 if (error < 0) 409 if (error < 0)
412 goto out; 410 goto out;
@@ -576,7 +574,6 @@ static int apply_microcode_check_cpu(int cpu)
576 struct cpuinfo_x86 *c = &cpu_data(cpu); 574 struct cpuinfo_x86 *c = &cpu_data(cpu);
577 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 575 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
578 cpumask_t old; 576 cpumask_t old;
579 cpumask_of_cpu_ptr(newmask, cpu);
580 unsigned int val[2]; 577 unsigned int val[2];
581 int err = 0; 578 int err = 0;
582 579
@@ -585,7 +582,7 @@ static int apply_microcode_check_cpu(int cpu)
585 return 0; 582 return 0;
586 583
587 old = current->cpus_allowed; 584 old = current->cpus_allowed;
588 set_cpus_allowed_ptr(current, newmask); 585 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
589 586
590 /* Check if the microcode we have in memory matches the CPU */ 587 /* Check if the microcode we have in memory matches the CPU */
591 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || 588 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
@@ -623,12 +620,11 @@ static int apply_microcode_check_cpu(int cpu)
623static void microcode_init_cpu(int cpu, int resume) 620static void microcode_init_cpu(int cpu, int resume)
624{ 621{
625 cpumask_t old; 622 cpumask_t old;
626 cpumask_of_cpu_ptr(newmask, cpu);
627 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 623 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
628 624
629 old = current->cpus_allowed; 625 old = current->cpus_allowed;
630 626
631 set_cpus_allowed_ptr(current, newmask); 627 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
632 mutex_lock(&microcode_mutex); 628 mutex_lock(&microcode_mutex);
633 collect_cpu_info(cpu); 629 collect_cpu_info(cpu);
634 if (uci->valid && system_state == SYSTEM_RUNNING && !resume) 630 if (uci->valid && system_state == SYSTEM_RUNNING && !resume)
@@ -661,13 +657,10 @@ static ssize_t reload_store(struct sys_device *dev,
661 if (end == buf) 657 if (end == buf)
662 return -EINVAL; 658 return -EINVAL;
663 if (val == 1) { 659 if (val == 1) {
664 cpumask_t old; 660 cpumask_t old = current->cpus_allowed;
665 cpumask_of_cpu_ptr(newmask, cpu);
666
667 old = current->cpus_allowed;
668 661
669 get_online_cpus(); 662 get_online_cpus();
670 set_cpus_allowed_ptr(current, newmask); 663 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
671 664
672 mutex_lock(&microcode_mutex); 665 mutex_lock(&microcode_mutex);
673 if (uci->valid) 666 if (uci->valid)
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 19e7fc7c2c4f..b67a4b1d4eae 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -37,6 +37,7 @@
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/scatterlist.h> 38#include <linux/scatterlist.h>
39#include <linux/iommu-helper.h> 39#include <linux/iommu-helper.h>
40
40#include <asm/iommu.h> 41#include <asm/iommu.h>
41#include <asm/calgary.h> 42#include <asm/calgary.h>
42#include <asm/tce.h> 43#include <asm/tce.h>
@@ -413,22 +414,6 @@ static void calgary_unmap_sg(struct device *dev,
413 } 414 }
414} 415}
415 416
416static int calgary_nontranslate_map_sg(struct device* dev,
417 struct scatterlist *sg, int nelems, int direction)
418{
419 struct scatterlist *s;
420 int i;
421
422 for_each_sg(sg, s, nelems, i) {
423 struct page *p = sg_page(s);
424
425 BUG_ON(!p);
426 s->dma_address = virt_to_bus(sg_virt(s));
427 s->dma_length = s->length;
428 }
429 return nelems;
430}
431
432static int calgary_map_sg(struct device *dev, struct scatterlist *sg, 417static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
433 int nelems, int direction) 418 int nelems, int direction)
434{ 419{
@@ -439,9 +424,6 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
439 unsigned long entry; 424 unsigned long entry;
440 int i; 425 int i;
441 426
442 if (!translation_enabled(tbl))
443 return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
444
445 for_each_sg(sg, s, nelems, i) { 427 for_each_sg(sg, s, nelems, i) {
446 BUG_ON(!sg_page(s)); 428 BUG_ON(!sg_page(s));
447 429
@@ -477,7 +459,6 @@ error:
477static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr, 459static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr,
478 size_t size, int direction) 460 size_t size, int direction)
479{ 461{
480 dma_addr_t dma_handle = bad_dma_address;
481 void *vaddr = phys_to_virt(paddr); 462 void *vaddr = phys_to_virt(paddr);
482 unsigned long uaddr; 463 unsigned long uaddr;
483 unsigned int npages; 464 unsigned int npages;
@@ -486,12 +467,7 @@ static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr,
486 uaddr = (unsigned long)vaddr; 467 uaddr = (unsigned long)vaddr;
487 npages = num_dma_pages(uaddr, size); 468 npages = num_dma_pages(uaddr, size);
488 469
489 if (translation_enabled(tbl)) 470 return iommu_alloc(dev, tbl, vaddr, npages, direction);
490 dma_handle = iommu_alloc(dev, tbl, vaddr, npages, direction);
491 else
492 dma_handle = virt_to_bus(vaddr);
493
494 return dma_handle;
495} 471}
496 472
497static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, 473static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
@@ -500,9 +476,6 @@ static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
500 struct iommu_table *tbl = find_iommu_table(dev); 476 struct iommu_table *tbl = find_iommu_table(dev);
501 unsigned int npages; 477 unsigned int npages;
502 478
503 if (!translation_enabled(tbl))
504 return;
505
506 npages = num_dma_pages(dma_handle, size); 479 npages = num_dma_pages(dma_handle, size);
507 iommu_free(tbl, dma_handle, npages); 480 iommu_free(tbl, dma_handle, npages);
508} 481}
@@ -525,18 +498,12 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
525 goto error; 498 goto error;
526 memset(ret, 0, size); 499 memset(ret, 0, size);
527 500
528 if (translation_enabled(tbl)) { 501 /* set up tces to cover the allocated range */
529 /* set up tces to cover the allocated range */ 502 mapping = iommu_alloc(dev, tbl, ret, npages, DMA_BIDIRECTIONAL);
530 mapping = iommu_alloc(dev, tbl, ret, npages, DMA_BIDIRECTIONAL); 503 if (mapping == bad_dma_address)
531 if (mapping == bad_dma_address) 504 goto free;
532 goto free; 505 *dma_handle = mapping;
533
534 *dma_handle = mapping;
535 } else /* non translated slot */
536 *dma_handle = virt_to_bus(ret);
537
538 return ret; 506 return ret;
539
540free: 507free:
541 free_pages((unsigned long)ret, get_order(size)); 508 free_pages((unsigned long)ret, get_order(size));
542 ret = NULL; 509 ret = NULL;
@@ -544,7 +511,7 @@ error:
544 return ret; 511 return ret;
545} 512}
546 513
547static const struct dma_mapping_ops calgary_dma_ops = { 514static struct dma_mapping_ops calgary_dma_ops = {
548 .alloc_coherent = calgary_alloc_coherent, 515 .alloc_coherent = calgary_alloc_coherent,
549 .map_single = calgary_map_single, 516 .map_single = calgary_map_single,
550 .unmap_single = calgary_unmap_single, 517 .unmap_single = calgary_unmap_single,
@@ -1241,6 +1208,16 @@ static int __init calgary_init(void)
1241 goto error; 1208 goto error;
1242 } while (1); 1209 } while (1);
1243 1210
1211 dev = NULL;
1212 for_each_pci_dev(dev) {
1213 struct iommu_table *tbl;
1214
1215 tbl = find_iommu_table(&dev->dev);
1216
1217 if (translation_enabled(tbl))
1218 dev->dev.archdata.dma_ops = &calgary_dma_ops;
1219 }
1220
1244 return ret; 1221 return ret;
1245 1222
1246error: 1223error:
@@ -1262,6 +1239,7 @@ error:
1262 calgary_disable_translation(dev); 1239 calgary_disable_translation(dev);
1263 calgary_free_bus(dev); 1240 calgary_free_bus(dev);
1264 pci_dev_put(dev); /* Undo calgary_init_one()'s pci_dev_get() */ 1241 pci_dev_put(dev); /* Undo calgary_init_one()'s pci_dev_get() */
1242 dev->dev.archdata.dma_ops = NULL;
1265 } while (1); 1243 } while (1);
1266 1244
1267 return ret; 1245 return ret;
@@ -1503,6 +1481,10 @@ void __init detect_calgary(void)
1503 printk(KERN_INFO "PCI-DMA: Calgary TCE table spec is %d, " 1481 printk(KERN_INFO "PCI-DMA: Calgary TCE table spec is %d, "
1504 "CONFIG_IOMMU_DEBUG is %s.\n", specified_table_size, 1482 "CONFIG_IOMMU_DEBUG is %s.\n", specified_table_size,
1505 debugging ? "enabled" : "disabled"); 1483 debugging ? "enabled" : "disabled");
1484
1485 /* swiotlb for devices that aren't behind the Calgary. */
1486 if (max_pfn > MAX_DMA32_PFN)
1487 swiotlb = 1;
1506 } 1488 }
1507 return; 1489 return;
1508 1490
@@ -1519,7 +1501,7 @@ int __init calgary_iommu_init(void)
1519{ 1501{
1520 int ret; 1502 int ret;
1521 1503
1522 if (no_iommu || swiotlb) 1504 if (no_iommu || (swiotlb && !calgary_detected))
1523 return -ENODEV; 1505 return -ENODEV;
1524 1506
1525 if (!calgary_detected) 1507 if (!calgary_detected)
@@ -1532,15 +1514,14 @@ int __init calgary_iommu_init(void)
1532 if (ret) { 1514 if (ret) {
1533 printk(KERN_ERR "PCI-DMA: Calgary init failed %d, " 1515 printk(KERN_ERR "PCI-DMA: Calgary init failed %d, "
1534 "falling back to no_iommu\n", ret); 1516 "falling back to no_iommu\n", ret);
1535 if (max_pfn > MAX_DMA32_PFN)
1536 printk(KERN_ERR "WARNING more than 4GB of memory, "
1537 "32bit PCI may malfunction.\n");
1538 return ret; 1517 return ret;
1539 } 1518 }
1540 1519
1541 force_iommu = 1; 1520 force_iommu = 1;
1542 bad_dma_address = 0x0; 1521 bad_dma_address = 0x0;
1543 dma_ops = &calgary_dma_ops; 1522 /* dma_ops is set to swiotlb or nommu */
1523 if (!dma_ops)
1524 dma_ops = &nommu_dma_ops;
1544 1525
1545 return 0; 1526 return 0;
1546} 1527}
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index cbecb05551bb..8dbffb846de9 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -11,7 +11,7 @@
11 11
12static int forbid_dac __read_mostly; 12static int forbid_dac __read_mostly;
13 13
14const struct dma_mapping_ops *dma_ops; 14struct dma_mapping_ops *dma_ops;
15EXPORT_SYMBOL(dma_ops); 15EXPORT_SYMBOL(dma_ops);
16 16
17static int iommu_sac_force __read_mostly; 17static int iommu_sac_force __read_mostly;
@@ -192,126 +192,10 @@ static __init int iommu_setup(char *p)
192} 192}
193early_param("iommu", iommu_setup); 193early_param("iommu", iommu_setup);
194 194
195#ifdef CONFIG_X86_32
196int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
197 dma_addr_t device_addr, size_t size, int flags)
198{
199 void __iomem *mem_base = NULL;
200 int pages = size >> PAGE_SHIFT;
201 int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
202
203 if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
204 goto out;
205 if (!size)
206 goto out;
207 if (dev->dma_mem)
208 goto out;
209
210 /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
211
212 mem_base = ioremap(bus_addr, size);
213 if (!mem_base)
214 goto out;
215
216 dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
217 if (!dev->dma_mem)
218 goto out;
219 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
220 if (!dev->dma_mem->bitmap)
221 goto free1_out;
222
223 dev->dma_mem->virt_base = mem_base;
224 dev->dma_mem->device_base = device_addr;
225 dev->dma_mem->size = pages;
226 dev->dma_mem->flags = flags;
227
228 if (flags & DMA_MEMORY_MAP)
229 return DMA_MEMORY_MAP;
230
231 return DMA_MEMORY_IO;
232
233 free1_out:
234 kfree(dev->dma_mem);
235 out:
236 if (mem_base)
237 iounmap(mem_base);
238 return 0;
239}
240EXPORT_SYMBOL(dma_declare_coherent_memory);
241
242void dma_release_declared_memory(struct device *dev)
243{
244 struct dma_coherent_mem *mem = dev->dma_mem;
245
246 if (!mem)
247 return;
248 dev->dma_mem = NULL;
249 iounmap(mem->virt_base);
250 kfree(mem->bitmap);
251 kfree(mem);
252}
253EXPORT_SYMBOL(dma_release_declared_memory);
254
255void *dma_mark_declared_memory_occupied(struct device *dev,
256 dma_addr_t device_addr, size_t size)
257{
258 struct dma_coherent_mem *mem = dev->dma_mem;
259 int pos, err;
260 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1);
261
262 pages >>= PAGE_SHIFT;
263
264 if (!mem)
265 return ERR_PTR(-EINVAL);
266
267 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
268 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
269 if (err != 0)
270 return ERR_PTR(err);
271 return mem->virt_base + (pos << PAGE_SHIFT);
272}
273EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
274
275static int dma_alloc_from_coherent_mem(struct device *dev, ssize_t size,
276 dma_addr_t *dma_handle, void **ret)
277{
278 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
279 int order = get_order(size);
280
281 if (mem) {
282 int page = bitmap_find_free_region(mem->bitmap, mem->size,
283 order);
284 if (page >= 0) {
285 *dma_handle = mem->device_base + (page << PAGE_SHIFT);
286 *ret = mem->virt_base + (page << PAGE_SHIFT);
287 memset(*ret, 0, size);
288 }
289 if (mem->flags & DMA_MEMORY_EXCLUSIVE)
290 *ret = NULL;
291 }
292 return (mem != NULL);
293}
294
295static int dma_release_coherent(struct device *dev, int order, void *vaddr)
296{
297 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
298
299 if (mem && vaddr >= mem->virt_base && vaddr <
300 (mem->virt_base + (mem->size << PAGE_SHIFT))) {
301 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
302
303 bitmap_release_region(mem->bitmap, page, order);
304 return 1;
305 }
306 return 0;
307}
308#else
309#define dma_alloc_from_coherent_mem(dev, size, handle, ret) (0)
310#define dma_release_coherent(dev, order, vaddr) (0)
311#endif /* CONFIG_X86_32 */
312
313int dma_supported(struct device *dev, u64 mask) 195int dma_supported(struct device *dev, u64 mask)
314{ 196{
197 struct dma_mapping_ops *ops = get_dma_ops(dev);
198
315#ifdef CONFIG_PCI 199#ifdef CONFIG_PCI
316 if (mask > 0xffffffff && forbid_dac > 0) { 200 if (mask > 0xffffffff && forbid_dac > 0) {
317 dev_info(dev, "PCI: Disallowing DAC for device\n"); 201 dev_info(dev, "PCI: Disallowing DAC for device\n");
@@ -319,8 +203,8 @@ int dma_supported(struct device *dev, u64 mask)
319 } 203 }
320#endif 204#endif
321 205
322 if (dma_ops->dma_supported) 206 if (ops->dma_supported)
323 return dma_ops->dma_supported(dev, mask); 207 return ops->dma_supported(dev, mask);
324 208
325 /* Copied from i386. Doesn't make much sense, because it will 209 /* Copied from i386. Doesn't make much sense, because it will
326 only work for pci_alloc_coherent. 210 only work for pci_alloc_coherent.
@@ -367,6 +251,7 @@ void *
367dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 251dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
368 gfp_t gfp) 252 gfp_t gfp)
369{ 253{
254 struct dma_mapping_ops *ops = get_dma_ops(dev);
370 void *memory = NULL; 255 void *memory = NULL;
371 struct page *page; 256 struct page *page;
372 unsigned long dma_mask = 0; 257 unsigned long dma_mask = 0;
@@ -376,7 +261,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
376 /* ignore region specifiers */ 261 /* ignore region specifiers */
377 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32); 262 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
378 263
379 if (dma_alloc_from_coherent_mem(dev, size, dma_handle, &memory)) 264 if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
380 return memory; 265 return memory;
381 266
382 if (!dev) { 267 if (!dev) {
@@ -435,8 +320,8 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
435 /* Let low level make its own zone decisions */ 320 /* Let low level make its own zone decisions */
436 gfp &= ~(GFP_DMA32|GFP_DMA); 321 gfp &= ~(GFP_DMA32|GFP_DMA);
437 322
438 if (dma_ops->alloc_coherent) 323 if (ops->alloc_coherent)
439 return dma_ops->alloc_coherent(dev, size, 324 return ops->alloc_coherent(dev, size,
440 dma_handle, gfp); 325 dma_handle, gfp);
441 return NULL; 326 return NULL;
442 } 327 }
@@ -448,14 +333,14 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
448 } 333 }
449 } 334 }
450 335
451 if (dma_ops->alloc_coherent) { 336 if (ops->alloc_coherent) {
452 free_pages((unsigned long)memory, get_order(size)); 337 free_pages((unsigned long)memory, get_order(size));
453 gfp &= ~(GFP_DMA|GFP_DMA32); 338 gfp &= ~(GFP_DMA|GFP_DMA32);
454 return dma_ops->alloc_coherent(dev, size, dma_handle, gfp); 339 return ops->alloc_coherent(dev, size, dma_handle, gfp);
455 } 340 }
456 341
457 if (dma_ops->map_simple) { 342 if (ops->map_simple) {
458 *dma_handle = dma_ops->map_simple(dev, virt_to_phys(memory), 343 *dma_handle = ops->map_simple(dev, virt_to_phys(memory),
459 size, 344 size,
460 PCI_DMA_BIDIRECTIONAL); 345 PCI_DMA_BIDIRECTIONAL);
461 if (*dma_handle != bad_dma_address) 346 if (*dma_handle != bad_dma_address)
@@ -477,12 +362,14 @@ EXPORT_SYMBOL(dma_alloc_coherent);
477void dma_free_coherent(struct device *dev, size_t size, 362void dma_free_coherent(struct device *dev, size_t size,
478 void *vaddr, dma_addr_t bus) 363 void *vaddr, dma_addr_t bus)
479{ 364{
365 struct dma_mapping_ops *ops = get_dma_ops(dev);
366
480 int order = get_order(size); 367 int order = get_order(size);
481 WARN_ON(irqs_disabled()); /* for portability */ 368 WARN_ON(irqs_disabled()); /* for portability */
482 if (dma_release_coherent(dev, order, vaddr)) 369 if (dma_release_from_coherent(dev, order, vaddr))
483 return; 370 return;
484 if (dma_ops->unmap_single) 371 if (ops->unmap_single)
485 dma_ops->unmap_single(dev, bus, size, 0); 372 ops->unmap_single(dev, bus, size, 0);
486 free_pages((unsigned long)vaddr, order); 373 free_pages((unsigned long)vaddr, order);
487} 374}
488EXPORT_SYMBOL(dma_free_coherent); 375EXPORT_SYMBOL(dma_free_coherent);
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index df5f142657d2..49285f8fd4d5 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -67,9 +67,6 @@ static u32 gart_unmapped_entry;
67 (((x) & 0xfffff000) | (((x) >> 32) << 4) | GPTE_VALID | GPTE_COHERENT) 67 (((x) & 0xfffff000) | (((x) >> 32) << 4) | GPTE_VALID | GPTE_COHERENT)
68#define GPTE_DECODE(x) (((x) & 0xfffff000) | (((u64)(x) & 0xff0) << 28)) 68#define GPTE_DECODE(x) (((x) & 0xfffff000) | (((u64)(x) & 0xff0) << 28))
69 69
70#define to_pages(addr, size) \
71 (round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
72
73#define EMERGENCY_PAGES 32 /* = 128KB */ 70#define EMERGENCY_PAGES 32 /* = 128KB */
74 71
75#ifdef CONFIG_AGP 72#ifdef CONFIG_AGP
@@ -241,7 +238,7 @@ nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
241static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem, 238static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
242 size_t size, int dir) 239 size_t size, int dir)
243{ 240{
244 unsigned long npages = to_pages(phys_mem, size); 241 unsigned long npages = iommu_num_pages(phys_mem, size);
245 unsigned long iommu_page = alloc_iommu(dev, npages); 242 unsigned long iommu_page = alloc_iommu(dev, npages);
246 int i; 243 int i;
247 244
@@ -304,7 +301,7 @@ static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
304 return; 301 return;
305 302
306 iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT; 303 iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT;
307 npages = to_pages(dma_addr, size); 304 npages = iommu_num_pages(dma_addr, size);
308 for (i = 0; i < npages; i++) { 305 for (i = 0; i < npages; i++) {
309 iommu_gatt_base[iommu_page + i] = gart_unmapped_entry; 306 iommu_gatt_base[iommu_page + i] = gart_unmapped_entry;
310 CLEAR_LEAK(iommu_page + i); 307 CLEAR_LEAK(iommu_page + i);
@@ -387,7 +384,7 @@ static int __dma_map_cont(struct device *dev, struct scatterlist *start,
387 } 384 }
388 385
389 addr = phys_addr; 386 addr = phys_addr;
390 pages = to_pages(s->offset, s->length); 387 pages = iommu_num_pages(s->offset, s->length);
391 while (pages--) { 388 while (pages--) {
392 iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr); 389 iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr);
393 SET_LEAK(iommu_page); 390 SET_LEAK(iommu_page);
@@ -470,7 +467,7 @@ gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
470 467
471 seg_size += s->length; 468 seg_size += s->length;
472 need = nextneed; 469 need = nextneed;
473 pages += to_pages(s->offset, s->length); 470 pages += iommu_num_pages(s->offset, s->length);
474 ps = s; 471 ps = s;
475 } 472 }
476 if (dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0) 473 if (dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0)
@@ -692,8 +689,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
692 689
693extern int agp_amd64_init(void); 690extern int agp_amd64_init(void);
694 691
695static const struct dma_mapping_ops gart_dma_ops = { 692static struct dma_mapping_ops gart_dma_ops = {
696 .mapping_error = NULL,
697 .map_single = gart_map_single, 693 .map_single = gart_map_single,
698 .map_simple = gart_map_simple, 694 .map_simple = gart_map_simple,
699 .unmap_single = gart_unmap_single, 695 .unmap_single = gart_unmap_single,
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 792b9179eff3..3f91f71cdc3e 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -72,21 +72,9 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
72 return nents; 72 return nents;
73} 73}
74 74
75/* Make sure we keep the same behaviour */ 75struct dma_mapping_ops nommu_dma_ops = {
76static int nommu_mapping_error(dma_addr_t dma_addr)
77{
78#ifdef CONFIG_X86_32
79 return 0;
80#else
81 return (dma_addr == bad_dma_address);
82#endif
83}
84
85
86const struct dma_mapping_ops nommu_dma_ops = {
87 .map_single = nommu_map_single, 76 .map_single = nommu_map_single,
88 .map_sg = nommu_map_sg, 77 .map_sg = nommu_map_sg,
89 .mapping_error = nommu_mapping_error,
90 .is_phys = 1, 78 .is_phys = 1,
91}; 79};
92 80
diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index 20df839b9c20..c4ce0332759e 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -18,7 +18,7 @@ swiotlb_map_single_phys(struct device *hwdev, phys_addr_t paddr, size_t size,
18 return swiotlb_map_single(hwdev, phys_to_virt(paddr), size, direction); 18 return swiotlb_map_single(hwdev, phys_to_virt(paddr), size, direction);
19} 19}
20 20
21const struct dma_mapping_ops swiotlb_dma_ops = { 21struct dma_mapping_ops swiotlb_dma_ops = {
22 .mapping_error = swiotlb_dma_mapping_error, 22 .mapping_error = swiotlb_dma_mapping_error,
23 .alloc_coherent = swiotlb_alloc_coherent, 23 .alloc_coherent = swiotlb_alloc_coherent,
24 .free_coherent = swiotlb_free_coherent, 24 .free_coherent = swiotlb_free_coherent,
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 06a9f643817e..724adfc63cb9 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -414,25 +414,20 @@ void native_machine_shutdown(void)
414 414
415 /* The boot cpu is always logical cpu 0 */ 415 /* The boot cpu is always logical cpu 0 */
416 int reboot_cpu_id = 0; 416 int reboot_cpu_id = 0;
417 cpumask_of_cpu_ptr(newmask, reboot_cpu_id);
418 417
419#ifdef CONFIG_X86_32 418#ifdef CONFIG_X86_32
420 /* See if there has been given a command line override */ 419 /* See if there has been given a command line override */
421 if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && 420 if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) &&
422 cpu_online(reboot_cpu)) { 421 cpu_online(reboot_cpu))
423 reboot_cpu_id = reboot_cpu; 422 reboot_cpu_id = reboot_cpu;
424 cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id);
425 }
426#endif 423#endif
427 424
428 /* Make certain the cpu I'm about to reboot on is online */ 425 /* Make certain the cpu I'm about to reboot on is online */
429 if (!cpu_online(reboot_cpu_id)) { 426 if (!cpu_online(reboot_cpu_id))
430 reboot_cpu_id = smp_processor_id(); 427 reboot_cpu_id = smp_processor_id();
431 cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id);
432 }
433 428
434 /* Make certain I only run on the appropriate processor */ 429 /* Make certain I only run on the appropriate processor */
435 set_cpus_allowed_ptr(current, newmask); 430 set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id));
436 431
437 /* O.K Now that I'm on the appropriate processor, 432 /* O.K Now that I'm on the appropriate processor,
438 * stop all of the others. 433 * stop all of the others.
diff --git a/arch/x86/kernel/relocate_kernel_32.S b/arch/x86/kernel/relocate_kernel_32.S
index c30fe25d470d..703310a99023 100644
--- a/arch/x86/kernel/relocate_kernel_32.S
+++ b/arch/x86/kernel/relocate_kernel_32.S
@@ -20,11 +20,44 @@
20#define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 20#define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
21#define PAE_PGD_ATTR (_PAGE_PRESENT) 21#define PAE_PGD_ATTR (_PAGE_PRESENT)
22 22
23/* control_page + PAGE_SIZE/2 ~ control_page + PAGE_SIZE * 3/4 are
24 * used to save some data for jumping back
25 */
26#define DATA(offset) (PAGE_SIZE/2+(offset))
27
28/* Minimal CPU state */
29#define ESP DATA(0x0)
30#define CR0 DATA(0x4)
31#define CR3 DATA(0x8)
32#define CR4 DATA(0xc)
33
34/* other data */
35#define CP_VA_CONTROL_PAGE DATA(0x10)
36#define CP_PA_PGD DATA(0x14)
37#define CP_PA_SWAP_PAGE DATA(0x18)
38#define CP_PA_BACKUP_PAGES_MAP DATA(0x1c)
39
23 .text 40 .text
24 .align PAGE_SIZE 41 .align PAGE_SIZE
25 .globl relocate_kernel 42 .globl relocate_kernel
26relocate_kernel: 43relocate_kernel:
27 movl 8(%esp), %ebp /* list of pages */ 44 /* Save the CPU context, used for jumping back */
45
46 pushl %ebx
47 pushl %esi
48 pushl %edi
49 pushl %ebp
50 pushf
51
52 movl 20+8(%esp), %ebp /* list of pages */
53 movl PTR(VA_CONTROL_PAGE)(%ebp), %edi
54 movl %esp, ESP(%edi)
55 movl %cr0, %eax
56 movl %eax, CR0(%edi)
57 movl %cr3, %eax
58 movl %eax, CR3(%edi)
59 movl %cr4, %eax
60 movl %eax, CR4(%edi)
28 61
29#ifdef CONFIG_X86_PAE 62#ifdef CONFIG_X86_PAE
30 /* map the control page at its virtual address */ 63 /* map the control page at its virtual address */
@@ -138,15 +171,25 @@ relocate_kernel:
138 171
139relocate_new_kernel: 172relocate_new_kernel:
140 /* read the arguments and say goodbye to the stack */ 173 /* read the arguments and say goodbye to the stack */
141 movl 4(%esp), %ebx /* page_list */ 174 movl 20+4(%esp), %ebx /* page_list */
142 movl 8(%esp), %ebp /* list of pages */ 175 movl 20+8(%esp), %ebp /* list of pages */
143 movl 12(%esp), %edx /* start address */ 176 movl 20+12(%esp), %edx /* start address */
144 movl 16(%esp), %ecx /* cpu_has_pae */ 177 movl 20+16(%esp), %ecx /* cpu_has_pae */
178 movl 20+20(%esp), %esi /* preserve_context */
145 179
146 /* zero out flags, and disable interrupts */ 180 /* zero out flags, and disable interrupts */
147 pushl $0 181 pushl $0
148 popfl 182 popfl
149 183
184 /* save some information for jumping back */
185 movl PTR(VA_CONTROL_PAGE)(%ebp), %edi
186 movl %edi, CP_VA_CONTROL_PAGE(%edi)
187 movl PTR(PA_PGD)(%ebp), %eax
188 movl %eax, CP_PA_PGD(%edi)
189 movl PTR(PA_SWAP_PAGE)(%ebp), %eax
190 movl %eax, CP_PA_SWAP_PAGE(%edi)
191 movl %ebx, CP_PA_BACKUP_PAGES_MAP(%edi)
192
150 /* get physical address of control page now */ 193 /* get physical address of control page now */
151 /* this is impossible after page table switch */ 194 /* this is impossible after page table switch */
152 movl PTR(PA_CONTROL_PAGE)(%ebp), %edi 195 movl PTR(PA_CONTROL_PAGE)(%ebp), %edi
@@ -197,8 +240,90 @@ identity_mapped:
197 xorl %eax, %eax 240 xorl %eax, %eax
198 movl %eax, %cr3 241 movl %eax, %cr3
199 242
243 movl CP_PA_SWAP_PAGE(%edi), %eax
244 pushl %eax
245 pushl %ebx
246 call swap_pages
247 addl $8, %esp
248
249 /* To be certain of avoiding problems with self-modifying code
250 * I need to execute a serializing instruction here.
251 * So I flush the TLB, it's handy, and not processor dependent.
252 */
253 xorl %eax, %eax
254 movl %eax, %cr3
255
256 /* set all of the registers to known values */
257 /* leave %esp alone */
258
259 testl %esi, %esi
260 jnz 1f
261 xorl %edi, %edi
262 xorl %eax, %eax
263 xorl %ebx, %ebx
264 xorl %ecx, %ecx
265 xorl %edx, %edx
266 xorl %esi, %esi
267 xorl %ebp, %ebp
268 ret
2691:
270 popl %edx
271 movl CP_PA_SWAP_PAGE(%edi), %esp
272 addl $PAGE_SIZE, %esp
2732:
274 call *%edx
275
276 /* get the re-entry point of the peer system */
277 movl 0(%esp), %ebp
278 call 1f
2791:
280 popl %ebx
281 subl $(1b - relocate_kernel), %ebx
282 movl CP_VA_CONTROL_PAGE(%ebx), %edi
283 lea PAGE_SIZE(%ebx), %esp
284 movl CP_PA_SWAP_PAGE(%ebx), %eax
285 movl CP_PA_BACKUP_PAGES_MAP(%ebx), %edx
286 pushl %eax
287 pushl %edx
288 call swap_pages
289 addl $8, %esp
290 movl CP_PA_PGD(%ebx), %eax
291 movl %eax, %cr3
292 movl %cr0, %eax
293 orl $(1<<31), %eax
294 movl %eax, %cr0
295 lea PAGE_SIZE(%edi), %esp
296 movl %edi, %eax
297 addl $(virtual_mapped - relocate_kernel), %eax
298 pushl %eax
299 ret
300
301virtual_mapped:
302 movl CR4(%edi), %eax
303 movl %eax, %cr4
304 movl CR3(%edi), %eax
305 movl %eax, %cr3
306 movl CR0(%edi), %eax
307 movl %eax, %cr0
308 movl ESP(%edi), %esp
309 movl %ebp, %eax
310
311 popf
312 popl %ebp
313 popl %edi
314 popl %esi
315 popl %ebx
316 ret
317
200 /* Do the copies */ 318 /* Do the copies */
201 movl %ebx, %ecx 319swap_pages:
320 movl 8(%esp), %edx
321 movl 4(%esp), %ecx
322 pushl %ebp
323 pushl %ebx
324 pushl %edi
325 pushl %esi
326 movl %ecx, %ebx
202 jmp 1f 327 jmp 1f
203 328
2040: /* top, read another word from the indirection page */ 3290: /* top, read another word from the indirection page */
@@ -226,27 +351,28 @@ identity_mapped:
226 movl %ecx, %esi /* For every source page do a copy */ 351 movl %ecx, %esi /* For every source page do a copy */
227 andl $0xfffff000, %esi 352 andl $0xfffff000, %esi
228 353
354 movl %edi, %eax
355 movl %esi, %ebp
356
357 movl %edx, %edi
229 movl $1024, %ecx 358 movl $1024, %ecx
230 rep ; movsl 359 rep ; movsl
231 jmp 0b
232 360
2333: 361 movl %ebp, %edi
234 362 movl %eax, %esi
235 /* To be certain of avoiding problems with self-modifying code 363 movl $1024, %ecx
236 * I need to execute a serializing instruction here. 364 rep ; movsl
237 * So I flush the TLB, it's handy, and not processor dependent.
238 */
239 xorl %eax, %eax
240 movl %eax, %cr3
241 365
242 /* set all of the registers to known values */ 366 movl %eax, %edi
243 /* leave %esp alone */ 367 movl %edx, %esi
368 movl $1024, %ecx
369 rep ; movsl
244 370
245 xorl %eax, %eax 371 lea PAGE_SIZE(%ebp), %esi
246 xorl %ebx, %ebx 372 jmp 0b
247 xorl %ecx, %ecx 3733:
248 xorl %edx, %edx 374 popl %esi
249 xorl %esi, %esi 375 popl %edi
250 xorl %edi, %edi 376 popl %ebx
251 xorl %ebp, %ebp 377 popl %ebp
252 ret 378 ret
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index f7745f94c006..76e305e064f9 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -80,24 +80,6 @@ static void __init setup_per_cpu_maps(void)
80#endif 80#endif
81} 81}
82 82
83#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
84cpumask_t *cpumask_of_cpu_map __read_mostly;
85EXPORT_SYMBOL(cpumask_of_cpu_map);
86
87/* requires nr_cpu_ids to be initialized */
88static void __init setup_cpumask_of_cpu(void)
89{
90 int i;
91
92 /* alloc_bootmem zeroes memory */
93 cpumask_of_cpu_map = alloc_bootmem_low(sizeof(cpumask_t) * nr_cpu_ids);
94 for (i = 0; i < nr_cpu_ids; i++)
95 cpu_set(i, cpumask_of_cpu_map[i]);
96}
97#else
98static inline void setup_cpumask_of_cpu(void) { }
99#endif
100
101#ifdef CONFIG_X86_32 83#ifdef CONFIG_X86_32
102/* 84/*
103 * Great future not-so-futuristic plan: make i386 and x86_64 do it 85 * Great future not-so-futuristic plan: make i386 and x86_64 do it
@@ -197,9 +179,6 @@ void __init setup_per_cpu_areas(void)
197 179
198 /* Setup node to cpumask map */ 180 /* Setup node to cpumask map */
199 setup_node_to_cpumask_map(); 181 setup_node_to_cpumask_map();
200
201 /* Setup cpumask_of_cpu map */
202 setup_cpumask_of_cpu();
203} 182}
204 183
205#endif 184#endif
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 8d45fabc5f3b..ce3251ce5504 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -21,6 +21,7 @@ config KVM
21 tristate "Kernel-based Virtual Machine (KVM) support" 21 tristate "Kernel-based Virtual Machine (KVM) support"
22 depends on HAVE_KVM 22 depends on HAVE_KVM
23 select PREEMPT_NOTIFIERS 23 select PREEMPT_NOTIFIERS
24 select MMU_NOTIFIER
24 select ANON_INODES 25 select ANON_INODES
25 ---help--- 26 ---help---
26 Support hosting fully virtualized guest machines using hardware 27 Support hosting fully virtualized guest machines using hardware
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index b0e4ddca6c18..2fa231923cf7 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1814,6 +1814,7 @@ int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
1814 spin_unlock(&vcpu->kvm->mmu_lock); 1814 spin_unlock(&vcpu->kvm->mmu_lock);
1815 return r; 1815 return r;
1816} 1816}
1817EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page_virt);
1817 1818
1818void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) 1819void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
1819{ 1820{
@@ -1870,6 +1871,12 @@ void kvm_enable_tdp(void)
1870} 1871}
1871EXPORT_SYMBOL_GPL(kvm_enable_tdp); 1872EXPORT_SYMBOL_GPL(kvm_enable_tdp);
1872 1873
1874void kvm_disable_tdp(void)
1875{
1876 tdp_enabled = false;
1877}
1878EXPORT_SYMBOL_GPL(kvm_disable_tdp);
1879
1873static void free_mmu_pages(struct kvm_vcpu *vcpu) 1880static void free_mmu_pages(struct kvm_vcpu *vcpu)
1874{ 1881{
1875 struct kvm_mmu_page *sp; 1882 struct kvm_mmu_page *sp;
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index b756e876dce3..e2ee264740c7 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -453,7 +453,8 @@ static __init int svm_hardware_setup(void)
453 if (npt_enabled) { 453 if (npt_enabled) {
454 printk(KERN_INFO "kvm: Nested Paging enabled\n"); 454 printk(KERN_INFO "kvm: Nested Paging enabled\n");
455 kvm_enable_tdp(); 455 kvm_enable_tdp();
456 } 456 } else
457 kvm_disable_tdp();
457 458
458 return 0; 459 return 0;
459 460
@@ -1007,10 +1008,13 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1007 struct kvm *kvm = svm->vcpu.kvm; 1008 struct kvm *kvm = svm->vcpu.kvm;
1008 u64 fault_address; 1009 u64 fault_address;
1009 u32 error_code; 1010 u32 error_code;
1011 bool event_injection = false;
1010 1012
1011 if (!irqchip_in_kernel(kvm) && 1013 if (!irqchip_in_kernel(kvm) &&
1012 is_external_interrupt(exit_int_info)) 1014 is_external_interrupt(exit_int_info)) {
1015 event_injection = true;
1013 push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK); 1016 push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK);
1017 }
1014 1018
1015 fault_address = svm->vmcb->control.exit_info_2; 1019 fault_address = svm->vmcb->control.exit_info_2;
1016 error_code = svm->vmcb->control.exit_info_1; 1020 error_code = svm->vmcb->control.exit_info_1;
@@ -1024,6 +1028,8 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1024 (u32)fault_address, (u32)(fault_address >> 32), 1028 (u32)fault_address, (u32)(fault_address >> 32),
1025 handler); 1029 handler);
1026 1030
1031 if (event_injection)
1032 kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address);
1027 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code); 1033 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
1028} 1034}
1029 1035
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0cac63701719..2a69773e3b26 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2298,6 +2298,8 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
2298 cr2 = vmcs_readl(EXIT_QUALIFICATION); 2298 cr2 = vmcs_readl(EXIT_QUALIFICATION);
2299 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2, 2299 KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2,
2300 (u32)((u64)cr2 >> 32), handler); 2300 (u32)((u64)cr2 >> 32), handler);
2301 if (vect_info & VECTORING_INFO_VALID_MASK)
2302 kvm_mmu_unprotect_page_virt(vcpu, cr2);
2301 return kvm_mmu_page_fault(vcpu, cr2, error_code); 2303 return kvm_mmu_page_fault(vcpu, cr2, error_code);
2302 } 2304 }
2303 2305
@@ -3116,15 +3118,6 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
3116 return ERR_PTR(-ENOMEM); 3118 return ERR_PTR(-ENOMEM);
3117 3119
3118 allocate_vpid(vmx); 3120 allocate_vpid(vmx);
3119 if (id == 0 && vm_need_ept()) {
3120 kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK |
3121 VMX_EPT_WRITABLE_MASK |
3122 VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT);
3123 kvm_mmu_set_mask_ptes(0ull, VMX_EPT_FAKE_ACCESSED_MASK,
3124 VMX_EPT_FAKE_DIRTY_MASK, 0ull,
3125 VMX_EPT_EXECUTABLE_MASK);
3126 kvm_enable_tdp();
3127 }
3128 3121
3129 err = kvm_vcpu_init(&vmx->vcpu, kvm, id); 3122 err = kvm_vcpu_init(&vmx->vcpu, kvm, id);
3130 if (err) 3123 if (err)
@@ -3303,8 +3296,17 @@ static int __init vmx_init(void)
3303 vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_ESP); 3296 vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_ESP);
3304 vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_EIP); 3297 vmx_disable_intercept_for_msr(vmx_msr_bitmap, MSR_IA32_SYSENTER_EIP);
3305 3298
3306 if (cpu_has_vmx_ept()) 3299 if (vm_need_ept()) {
3307 bypass_guest_pf = 0; 3300 bypass_guest_pf = 0;
3301 kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK |
3302 VMX_EPT_WRITABLE_MASK |
3303 VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT);
3304 kvm_mmu_set_mask_ptes(0ull, VMX_EPT_FAKE_ACCESSED_MASK,
3305 VMX_EPT_FAKE_DIRTY_MASK, 0ull,
3306 VMX_EPT_EXECUTABLE_MASK);
3307 kvm_enable_tdp();
3308 } else
3309 kvm_disable_tdp();
3308 3310
3309 if (bypass_guest_pf) 3311 if (bypass_guest_pf)
3310 kvm_mmu_set_nonpresent_ptes(~0xffeull, 0ull); 3312 kvm_mmu_set_nonpresent_ptes(~0xffeull, 0ull);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9f1cdb011cff..5916191420c7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3184,6 +3184,10 @@ static void seg_desct_to_kvm_desct(struct desc_struct *seg_desc, u16 selector,
3184 kvm_desct->base |= seg_desc->base2 << 24; 3184 kvm_desct->base |= seg_desc->base2 << 24;
3185 kvm_desct->limit = seg_desc->limit0; 3185 kvm_desct->limit = seg_desc->limit0;
3186 kvm_desct->limit |= seg_desc->limit << 16; 3186 kvm_desct->limit |= seg_desc->limit << 16;
3187 if (seg_desc->g) {
3188 kvm_desct->limit <<= 12;
3189 kvm_desct->limit |= 0xfff;
3190 }
3187 kvm_desct->selector = selector; 3191 kvm_desct->selector = selector;
3188 kvm_desct->type = seg_desc->type; 3192 kvm_desct->type = seg_desc->type;
3189 kvm_desct->present = seg_desc->p; 3193 kvm_desct->present = seg_desc->p;
@@ -3223,6 +3227,7 @@ static void get_segment_descritptor_dtable(struct kvm_vcpu *vcpu,
3223static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, 3227static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3224 struct desc_struct *seg_desc) 3228 struct desc_struct *seg_desc)
3225{ 3229{
3230 gpa_t gpa;
3226 struct descriptor_table dtable; 3231 struct descriptor_table dtable;
3227 u16 index = selector >> 3; 3232 u16 index = selector >> 3;
3228 3233
@@ -3232,13 +3237,16 @@ static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3232 kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc); 3237 kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc);
3233 return 1; 3238 return 1;
3234 } 3239 }
3235 return kvm_read_guest(vcpu->kvm, dtable.base + index * 8, seg_desc, 8); 3240 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base);
3241 gpa += index * 8;
3242 return kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8);
3236} 3243}
3237 3244
3238/* allowed just for 8 bytes segments */ 3245/* allowed just for 8 bytes segments */
3239static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, 3246static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3240 struct desc_struct *seg_desc) 3247 struct desc_struct *seg_desc)
3241{ 3248{
3249 gpa_t gpa;
3242 struct descriptor_table dtable; 3250 struct descriptor_table dtable;
3243 u16 index = selector >> 3; 3251 u16 index = selector >> 3;
3244 3252
@@ -3246,7 +3254,9 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
3246 3254
3247 if (dtable.limit < index * 8 + 7) 3255 if (dtable.limit < index * 8 + 7)
3248 return 1; 3256 return 1;
3249 return kvm_write_guest(vcpu->kvm, dtable.base + index * 8, seg_desc, 8); 3257 gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base);
3258 gpa += index * 8;
3259 return kvm_write_guest(vcpu->kvm, gpa, seg_desc, 8);
3250} 3260}
3251 3261
3252static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, 3262static u32 get_tss_base_addr(struct kvm_vcpu *vcpu,
@@ -3258,55 +3268,7 @@ static u32 get_tss_base_addr(struct kvm_vcpu *vcpu,
3258 base_addr |= (seg_desc->base1 << 16); 3268 base_addr |= (seg_desc->base1 << 16);
3259 base_addr |= (seg_desc->base2 << 24); 3269 base_addr |= (seg_desc->base2 << 24);
3260 3270
3261 return base_addr; 3271 return vcpu->arch.mmu.gva_to_gpa(vcpu, base_addr);
3262}
3263
3264static int load_tss_segment32(struct kvm_vcpu *vcpu,
3265 struct desc_struct *seg_desc,
3266 struct tss_segment_32 *tss)
3267{
3268 u32 base_addr;
3269
3270 base_addr = get_tss_base_addr(vcpu, seg_desc);
3271
3272 return kvm_read_guest(vcpu->kvm, base_addr, tss,
3273 sizeof(struct tss_segment_32));
3274}
3275
3276static int save_tss_segment32(struct kvm_vcpu *vcpu,
3277 struct desc_struct *seg_desc,
3278 struct tss_segment_32 *tss)
3279{
3280 u32 base_addr;
3281
3282 base_addr = get_tss_base_addr(vcpu, seg_desc);
3283
3284 return kvm_write_guest(vcpu->kvm, base_addr, tss,
3285 sizeof(struct tss_segment_32));
3286}
3287
3288static int load_tss_segment16(struct kvm_vcpu *vcpu,
3289 struct desc_struct *seg_desc,
3290 struct tss_segment_16 *tss)
3291{
3292 u32 base_addr;
3293
3294 base_addr = get_tss_base_addr(vcpu, seg_desc);
3295
3296 return kvm_read_guest(vcpu->kvm, base_addr, tss,
3297 sizeof(struct tss_segment_16));
3298}
3299
3300static int save_tss_segment16(struct kvm_vcpu *vcpu,
3301 struct desc_struct *seg_desc,
3302 struct tss_segment_16 *tss)
3303{
3304 u32 base_addr;
3305
3306 base_addr = get_tss_base_addr(vcpu, seg_desc);
3307
3308 return kvm_write_guest(vcpu->kvm, base_addr, tss,
3309 sizeof(struct tss_segment_16));
3310} 3272}
3311 3273
3312static u16 get_segment_selector(struct kvm_vcpu *vcpu, int seg) 3274static u16 get_segment_selector(struct kvm_vcpu *vcpu, int seg)
@@ -3466,20 +3428,26 @@ static int load_state_from_tss16(struct kvm_vcpu *vcpu,
3466} 3428}
3467 3429
3468static int kvm_task_switch_16(struct kvm_vcpu *vcpu, u16 tss_selector, 3430static int kvm_task_switch_16(struct kvm_vcpu *vcpu, u16 tss_selector,
3469 struct desc_struct *cseg_desc, 3431 u32 old_tss_base,
3470 struct desc_struct *nseg_desc) 3432 struct desc_struct *nseg_desc)
3471{ 3433{
3472 struct tss_segment_16 tss_segment_16; 3434 struct tss_segment_16 tss_segment_16;
3473 int ret = 0; 3435 int ret = 0;
3474 3436
3475 if (load_tss_segment16(vcpu, cseg_desc, &tss_segment_16)) 3437 if (kvm_read_guest(vcpu->kvm, old_tss_base, &tss_segment_16,
3438 sizeof tss_segment_16))
3476 goto out; 3439 goto out;
3477 3440
3478 save_state_to_tss16(vcpu, &tss_segment_16); 3441 save_state_to_tss16(vcpu, &tss_segment_16);
3479 save_tss_segment16(vcpu, cseg_desc, &tss_segment_16);
3480 3442
3481 if (load_tss_segment16(vcpu, nseg_desc, &tss_segment_16)) 3443 if (kvm_write_guest(vcpu->kvm, old_tss_base, &tss_segment_16,
3444 sizeof tss_segment_16))
3482 goto out; 3445 goto out;
3446
3447 if (kvm_read_guest(vcpu->kvm, get_tss_base_addr(vcpu, nseg_desc),
3448 &tss_segment_16, sizeof tss_segment_16))
3449 goto out;
3450
3483 if (load_state_from_tss16(vcpu, &tss_segment_16)) 3451 if (load_state_from_tss16(vcpu, &tss_segment_16))
3484 goto out; 3452 goto out;
3485 3453
@@ -3489,20 +3457,26 @@ out:
3489} 3457}
3490 3458
3491static int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16 tss_selector, 3459static int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16 tss_selector,
3492 struct desc_struct *cseg_desc, 3460 u32 old_tss_base,
3493 struct desc_struct *nseg_desc) 3461 struct desc_struct *nseg_desc)
3494{ 3462{
3495 struct tss_segment_32 tss_segment_32; 3463 struct tss_segment_32 tss_segment_32;
3496 int ret = 0; 3464 int ret = 0;
3497 3465
3498 if (load_tss_segment32(vcpu, cseg_desc, &tss_segment_32)) 3466 if (kvm_read_guest(vcpu->kvm, old_tss_base, &tss_segment_32,
3467 sizeof tss_segment_32))
3499 goto out; 3468 goto out;
3500 3469
3501 save_state_to_tss32(vcpu, &tss_segment_32); 3470 save_state_to_tss32(vcpu, &tss_segment_32);
3502 save_tss_segment32(vcpu, cseg_desc, &tss_segment_32);
3503 3471
3504 if (load_tss_segment32(vcpu, nseg_desc, &tss_segment_32)) 3472 if (kvm_write_guest(vcpu->kvm, old_tss_base, &tss_segment_32,
3473 sizeof tss_segment_32))
3474 goto out;
3475
3476 if (kvm_read_guest(vcpu->kvm, get_tss_base_addr(vcpu, nseg_desc),
3477 &tss_segment_32, sizeof tss_segment_32))
3505 goto out; 3478 goto out;
3479
3506 if (load_state_from_tss32(vcpu, &tss_segment_32)) 3480 if (load_state_from_tss32(vcpu, &tss_segment_32))
3507 goto out; 3481 goto out;
3508 3482
@@ -3517,16 +3491,20 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3517 struct desc_struct cseg_desc; 3491 struct desc_struct cseg_desc;
3518 struct desc_struct nseg_desc; 3492 struct desc_struct nseg_desc;
3519 int ret = 0; 3493 int ret = 0;
3494 u32 old_tss_base = get_segment_base(vcpu, VCPU_SREG_TR);
3495 u16 old_tss_sel = get_segment_selector(vcpu, VCPU_SREG_TR);
3520 3496
3521 kvm_get_segment(vcpu, &tr_seg, VCPU_SREG_TR); 3497 old_tss_base = vcpu->arch.mmu.gva_to_gpa(vcpu, old_tss_base);
3522 3498
3499 /* FIXME: Handle errors. Failure to read either TSS or their
3500 * descriptors should generate a pagefault.
3501 */
3523 if (load_guest_segment_descriptor(vcpu, tss_selector, &nseg_desc)) 3502 if (load_guest_segment_descriptor(vcpu, tss_selector, &nseg_desc))
3524 goto out; 3503 goto out;
3525 3504
3526 if (load_guest_segment_descriptor(vcpu, tr_seg.selector, &cseg_desc)) 3505 if (load_guest_segment_descriptor(vcpu, old_tss_sel, &cseg_desc))
3527 goto out; 3506 goto out;
3528 3507
3529
3530 if (reason != TASK_SWITCH_IRET) { 3508 if (reason != TASK_SWITCH_IRET) {
3531 int cpl; 3509 int cpl;
3532 3510
@@ -3544,8 +3522,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3544 3522
3545 if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) { 3523 if (reason == TASK_SWITCH_IRET || reason == TASK_SWITCH_JMP) {
3546 cseg_desc.type &= ~(1 << 1); //clear the B flag 3524 cseg_desc.type &= ~(1 << 1); //clear the B flag
3547 save_guest_segment_descriptor(vcpu, tr_seg.selector, 3525 save_guest_segment_descriptor(vcpu, old_tss_sel, &cseg_desc);
3548 &cseg_desc);
3549 } 3526 }
3550 3527
3551 if (reason == TASK_SWITCH_IRET) { 3528 if (reason == TASK_SWITCH_IRET) {
@@ -3557,10 +3534,10 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
3557 kvm_x86_ops->cache_regs(vcpu); 3534 kvm_x86_ops->cache_regs(vcpu);
3558 3535
3559 if (nseg_desc.type & 8) 3536 if (nseg_desc.type & 8)
3560 ret = kvm_task_switch_32(vcpu, tss_selector, &cseg_desc, 3537 ret = kvm_task_switch_32(vcpu, tss_selector, old_tss_base,
3561 &nseg_desc); 3538 &nseg_desc);
3562 else 3539 else
3563 ret = kvm_task_switch_16(vcpu, tss_selector, &cseg_desc, 3540 ret = kvm_task_switch_16(vcpu, tss_selector, old_tss_base,
3564 &nseg_desc); 3541 &nseg_desc);
3565 3542
3566 if (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE) { 3543 if (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE) {
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 756fc489652b..65f0b8a47bed 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1044,6 +1044,9 @@ __init void lguest_init(void)
1044 init_pg_tables_start = __pa(pg0); 1044 init_pg_tables_start = __pa(pg0);
1045 init_pg_tables_end = __pa(pg0); 1045 init_pg_tables_end = __pa(pg0);
1046 1046
1047 /* As described in head_32.S, we map the first 128M of memory. */
1048 max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT;
1049
1047 /* Load the %fs segment register (the per-cpu segment register) with 1050 /* Load the %fs segment register (the per-cpu segment register) with
1048 * the normal data segment to get through booting. */ 1051 * the normal data segment to get through booting. */
1049 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory"); 1052 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory");
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index 1fbb844c3d7a..2977ea37791f 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -1,6 +1,7 @@
1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ 1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
2 pat.o pgtable.o 2 pat.o pgtable.o
3 3
4obj-$(CONFIG_HAVE_GET_USER_PAGES_FAST) += gup.o
4obj-$(CONFIG_X86_32) += pgtable_32.o 5obj-$(CONFIG_X86_32) += pgtable_32.o
5 6
6obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
new file mode 100644
index 000000000000..007bb06c7504
--- /dev/null
+++ b/arch/x86/mm/gup.c
@@ -0,0 +1,298 @@
1/*
2 * Lockless get_user_pages_fast for x86
3 *
4 * Copyright (C) 2008 Nick Piggin
5 * Copyright (C) 2008 Novell Inc.
6 */
7#include <linux/sched.h>
8#include <linux/mm.h>
9#include <linux/vmstat.h>
10#include <linux/highmem.h>
11
12#include <asm/pgtable.h>
13
14static inline pte_t gup_get_pte(pte_t *ptep)
15{
16#ifndef CONFIG_X86_PAE
17 return *ptep;
18#else
19 /*
20 * With get_user_pages_fast, we walk down the pagetables without taking
21 * any locks. For this we would like to load the pointers atoimcally,
22 * but that is not possible (without expensive cmpxchg8b) on PAE. What
23 * we do have is the guarantee that a pte will only either go from not
24 * present to present, or present to not present or both -- it will not
25 * switch to a completely different present page without a TLB flush in
26 * between; something that we are blocking by holding interrupts off.
27 *
28 * Setting ptes from not present to present goes:
29 * ptep->pte_high = h;
30 * smp_wmb();
31 * ptep->pte_low = l;
32 *
33 * And present to not present goes:
34 * ptep->pte_low = 0;
35 * smp_wmb();
36 * ptep->pte_high = 0;
37 *
38 * We must ensure here that the load of pte_low sees l iff pte_high
39 * sees h. We load pte_high *after* loading pte_low, which ensures we
40 * don't see an older value of pte_high. *Then* we recheck pte_low,
41 * which ensures that we haven't picked up a changed pte high. We might
42 * have got rubbish values from pte_low and pte_high, but we are
43 * guaranteed that pte_low will not have the present bit set *unless*
44 * it is 'l'. And get_user_pages_fast only operates on present ptes, so
45 * we're safe.
46 *
47 * gup_get_pte should not be used or copied outside gup.c without being
48 * very careful -- it does not atomically load the pte or anything that
49 * is likely to be useful for you.
50 */
51 pte_t pte;
52
53retry:
54 pte.pte_low = ptep->pte_low;
55 smp_rmb();
56 pte.pte_high = ptep->pte_high;
57 smp_rmb();
58 if (unlikely(pte.pte_low != ptep->pte_low))
59 goto retry;
60
61 return pte;
62#endif
63}
64
65/*
66 * The performance critical leaf functions are made noinline otherwise gcc
67 * inlines everything into a single function which results in too much
68 * register pressure.
69 */
70static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
71 unsigned long end, int write, struct page **pages, int *nr)
72{
73 unsigned long mask;
74 pte_t *ptep;
75
76 mask = _PAGE_PRESENT|_PAGE_USER;
77 if (write)
78 mask |= _PAGE_RW;
79
80 ptep = pte_offset_map(&pmd, addr);
81 do {
82 pte_t pte = gup_get_pte(ptep);
83 struct page *page;
84
85 if ((pte_val(pte) & (mask | _PAGE_SPECIAL)) != mask) {
86 pte_unmap(ptep);
87 return 0;
88 }
89 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
90 page = pte_page(pte);
91 get_page(page);
92 pages[*nr] = page;
93 (*nr)++;
94
95 } while (ptep++, addr += PAGE_SIZE, addr != end);
96 pte_unmap(ptep - 1);
97
98 return 1;
99}
100
101static inline void get_head_page_multiple(struct page *page, int nr)
102{
103 VM_BUG_ON(page != compound_head(page));
104 VM_BUG_ON(page_count(page) == 0);
105 atomic_add(nr, &page->_count);
106}
107
108static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,
109 unsigned long end, int write, struct page **pages, int *nr)
110{
111 unsigned long mask;
112 pte_t pte = *(pte_t *)&pmd;
113 struct page *head, *page;
114 int refs;
115
116 mask = _PAGE_PRESENT|_PAGE_USER;
117 if (write)
118 mask |= _PAGE_RW;
119 if ((pte_val(pte) & mask) != mask)
120 return 0;
121 /* hugepages are never "special" */
122 VM_BUG_ON(pte_val(pte) & _PAGE_SPECIAL);
123 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
124
125 refs = 0;
126 head = pte_page(pte);
127 page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
128 do {
129 VM_BUG_ON(compound_head(page) != head);
130 pages[*nr] = page;
131 (*nr)++;
132 page++;
133 refs++;
134 } while (addr += PAGE_SIZE, addr != end);
135 get_head_page_multiple(head, refs);
136
137 return 1;
138}
139
140static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
141 int write, struct page **pages, int *nr)
142{
143 unsigned long next;
144 pmd_t *pmdp;
145
146 pmdp = pmd_offset(&pud, addr);
147 do {
148 pmd_t pmd = *pmdp;
149
150 next = pmd_addr_end(addr, end);
151 if (pmd_none(pmd))
152 return 0;
153 if (unlikely(pmd_large(pmd))) {
154 if (!gup_huge_pmd(pmd, addr, next, write, pages, nr))
155 return 0;
156 } else {
157 if (!gup_pte_range(pmd, addr, next, write, pages, nr))
158 return 0;
159 }
160 } while (pmdp++, addr = next, addr != end);
161
162 return 1;
163}
164
165static noinline int gup_huge_pud(pud_t pud, unsigned long addr,
166 unsigned long end, int write, struct page **pages, int *nr)
167{
168 unsigned long mask;
169 pte_t pte = *(pte_t *)&pud;
170 struct page *head, *page;
171 int refs;
172
173 mask = _PAGE_PRESENT|_PAGE_USER;
174 if (write)
175 mask |= _PAGE_RW;
176 if ((pte_val(pte) & mask) != mask)
177 return 0;
178 /* hugepages are never "special" */
179 VM_BUG_ON(pte_val(pte) & _PAGE_SPECIAL);
180 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
181
182 refs = 0;
183 head = pte_page(pte);
184 page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
185 do {
186 VM_BUG_ON(compound_head(page) != head);
187 pages[*nr] = page;
188 (*nr)++;
189 page++;
190 refs++;
191 } while (addr += PAGE_SIZE, addr != end);
192 get_head_page_multiple(head, refs);
193
194 return 1;
195}
196
197static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
198 int write, struct page **pages, int *nr)
199{
200 unsigned long next;
201 pud_t *pudp;
202
203 pudp = pud_offset(&pgd, addr);
204 do {
205 pud_t pud = *pudp;
206
207 next = pud_addr_end(addr, end);
208 if (pud_none(pud))
209 return 0;
210 if (unlikely(pud_large(pud))) {
211 if (!gup_huge_pud(pud, addr, next, write, pages, nr))
212 return 0;
213 } else {
214 if (!gup_pmd_range(pud, addr, next, write, pages, nr))
215 return 0;
216 }
217 } while (pudp++, addr = next, addr != end);
218
219 return 1;
220}
221
222int get_user_pages_fast(unsigned long start, int nr_pages, int write,
223 struct page **pages)
224{
225 struct mm_struct *mm = current->mm;
226 unsigned long addr, len, end;
227 unsigned long next;
228 pgd_t *pgdp;
229 int nr = 0;
230
231 start &= PAGE_MASK;
232 addr = start;
233 len = (unsigned long) nr_pages << PAGE_SHIFT;
234 end = start + len;
235 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
236 start, len)))
237 goto slow_irqon;
238
239 /*
240 * XXX: batch / limit 'nr', to avoid large irq off latency
241 * needs some instrumenting to determine the common sizes used by
242 * important workloads (eg. DB2), and whether limiting the batch size
243 * will decrease performance.
244 *
245 * It seems like we're in the clear for the moment. Direct-IO is
246 * the main guy that batches up lots of get_user_pages, and even
247 * they are limited to 64-at-a-time which is not so many.
248 */
249 /*
250 * This doesn't prevent pagetable teardown, but does prevent
251 * the pagetables and pages from being freed on x86.
252 *
253 * So long as we atomically load page table pointers versus teardown
254 * (which we do on x86, with the above PAE exception), we can follow the
255 * address down to the the page and take a ref on it.
256 */
257 local_irq_disable();
258 pgdp = pgd_offset(mm, addr);
259 do {
260 pgd_t pgd = *pgdp;
261
262 next = pgd_addr_end(addr, end);
263 if (pgd_none(pgd))
264 goto slow;
265 if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
266 goto slow;
267 } while (pgdp++, addr = next, addr != end);
268 local_irq_enable();
269
270 VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT);
271 return nr;
272
273 {
274 int ret;
275
276slow:
277 local_irq_enable();
278slow_irqon:
279 /* Try to get the remaining pages with get_user_pages */
280 start += nr << PAGE_SHIFT;
281 pages += nr;
282
283 down_read(&mm->mmap_sem);
284 ret = get_user_pages(current, mm, start,
285 (end - start) >> PAGE_SHIFT, write, 0, pages, NULL);
286 up_read(&mm->mmap_sem);
287
288 /* Have to be a bit careful with return values */
289 if (nr > 0) {
290 if (ret < 0)
291 ret = nr;
292 else
293 ret += nr;
294 }
295
296 return ret;
297 }
298}
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ec37121f6709..129618ca0ea2 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -86,43 +86,6 @@ early_param("gbpages", parse_direct_gbpages_on);
86 * around without checking the pgd every time. 86 * around without checking the pgd every time.
87 */ 87 */
88 88
89void show_mem(void)
90{
91 long i, total = 0, reserved = 0;
92 long shared = 0, cached = 0;
93 struct page *page;
94 pg_data_t *pgdat;
95
96 printk(KERN_INFO "Mem-info:\n");
97 show_free_areas();
98 for_each_online_pgdat(pgdat) {
99 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
100 /*
101 * This loop can take a while with 256 GB and
102 * 4k pages so defer the NMI watchdog:
103 */
104 if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
105 touch_nmi_watchdog();
106
107 if (!pfn_valid(pgdat->node_start_pfn + i))
108 continue;
109
110 page = pfn_to_page(pgdat->node_start_pfn + i);
111 total++;
112 if (PageReserved(page))
113 reserved++;
114 else if (PageSwapCache(page))
115 cached++;
116 else if (page_count(page))
117 shared += page_count(page) - 1;
118 }
119 }
120 printk(KERN_INFO "%lu pages of RAM\n", total);
121 printk(KERN_INFO "%lu reserved pages\n", reserved);
122 printk(KERN_INFO "%lu pages shared\n", shared);
123 printk(KERN_INFO "%lu pages swap cached\n", cached);
124}
125
126int after_bootmem; 89int after_bootmem;
127 90
128static __init void *spp_getpage(void) 91static __init void *spp_getpage(void)
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index b4becbf8c570..cab0abbd1ebe 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -20,53 +20,6 @@
20#include <asm/tlb.h> 20#include <asm/tlb.h>
21#include <asm/tlbflush.h> 21#include <asm/tlbflush.h>
22 22
23void show_mem(void)
24{
25 int total = 0, reserved = 0;
26 int shared = 0, cached = 0;
27 int highmem = 0;
28 struct page *page;
29 pg_data_t *pgdat;
30 unsigned long i;
31 unsigned long flags;
32
33 printk(KERN_INFO "Mem-info:\n");
34 show_free_areas();
35 for_each_online_pgdat(pgdat) {
36 pgdat_resize_lock(pgdat, &flags);
37 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
38 if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
39 touch_nmi_watchdog();
40 page = pgdat_page_nr(pgdat, i);
41 total++;
42 if (PageHighMem(page))
43 highmem++;
44 if (PageReserved(page))
45 reserved++;
46 else if (PageSwapCache(page))
47 cached++;
48 else if (page_count(page))
49 shared += page_count(page) - 1;
50 }
51 pgdat_resize_unlock(pgdat, &flags);
52 }
53 printk(KERN_INFO "%d pages of RAM\n", total);
54 printk(KERN_INFO "%d pages of HIGHMEM\n", highmem);
55 printk(KERN_INFO "%d reserved pages\n", reserved);
56 printk(KERN_INFO "%d pages shared\n", shared);
57 printk(KERN_INFO "%d pages swap cached\n", cached);
58
59 printk(KERN_INFO "%lu pages dirty\n", global_page_state(NR_FILE_DIRTY));
60 printk(KERN_INFO "%lu pages writeback\n",
61 global_page_state(NR_WRITEBACK));
62 printk(KERN_INFO "%lu pages mapped\n", global_page_state(NR_FILE_MAPPED));
63 printk(KERN_INFO "%lu pages slab\n",
64 global_page_state(NR_SLAB_RECLAIMABLE) +
65 global_page_state(NR_SLAB_UNRECLAIMABLE));
66 printk(KERN_INFO "%lu pages pagetables\n",
67 global_page_state(NR_PAGETABLE));
68}
69
70/* 23/*
71 * Associate a virtual page frame with a given physical page frame 24 * Associate a virtual page frame with a given physical page frame
72 * and protection flags for that frame. 25 * and protection flags for that frame.
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index ff3a6a336342..4bdaa590375d 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -23,7 +23,8 @@ static void __devinit pci_fixup_i450nx(struct pci_dev *d)
23 pci_read_config_byte(d, reg++, &busno); 23 pci_read_config_byte(d, reg++, &busno);
24 pci_read_config_byte(d, reg++, &suba); 24 pci_read_config_byte(d, reg++, &suba);
25 pci_read_config_byte(d, reg++, &subb); 25 pci_read_config_byte(d, reg++, &subb);
26 DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb); 26 dev_dbg(&d->dev, "i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno,
27 suba, subb);
27 if (busno) 28 if (busno)
28 pci_scan_bus_with_sysdata(busno); /* Bus A */ 29 pci_scan_bus_with_sysdata(busno); /* Bus A */
29 if (suba < subb) 30 if (suba < subb)
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index a09505806b82..5807d1bc73f7 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -128,10 +128,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
128 pr = pci_find_parent_resource(dev, r); 128 pr = pci_find_parent_resource(dev, r);
129 if (!r->start || !pr || 129 if (!r->start || !pr ||
130 request_resource(pr, r) < 0) { 130 request_resource(pr, r) < 0) {
131 printk(KERN_ERR "PCI: Cannot allocate " 131 dev_err(&dev->dev, "BAR %d: can't "
132 "resource region %d " 132 "allocate resource\n", idx);
133 "of bridge %s\n",
134 idx, pci_name(dev));
135 /* 133 /*
136 * Something is wrong with the region. 134 * Something is wrong with the region.
137 * Invalidate the resource to prevent 135 * Invalidate the resource to prevent
@@ -166,15 +164,15 @@ static void __init pcibios_allocate_resources(int pass)
166 else 164 else
167 disabled = !(command & PCI_COMMAND_MEMORY); 165 disabled = !(command & PCI_COMMAND_MEMORY);
168 if (pass == disabled) { 166 if (pass == disabled) {
169 DBG("PCI: Resource %08lx-%08lx " 167 dev_dbg(&dev->dev, "resource %#08llx-%#08llx "
170 "(f=%lx, d=%d, p=%d)\n", 168 "(f=%lx, d=%d, p=%d)\n",
171 r->start, r->end, r->flags, disabled, pass); 169 (unsigned long long) r->start,
170 (unsigned long long) r->end,
171 r->flags, disabled, pass);
172 pr = pci_find_parent_resource(dev, r); 172 pr = pci_find_parent_resource(dev, r);
173 if (!pr || request_resource(pr, r) < 0) { 173 if (!pr || request_resource(pr, r) < 0) {
174 printk(KERN_ERR "PCI: Cannot allocate " 174 dev_err(&dev->dev, "BAR %d: can't "
175 "resource region %d " 175 "allocate resource\n", idx);
176 "of device %s\n",
177 idx, pci_name(dev));
178 /* We'll assign a new address later */ 176 /* We'll assign a new address later */
179 r->end -= r->start; 177 r->end -= r->start;
180 r->start = 0; 178 r->start = 0;
@@ -187,8 +185,7 @@ static void __init pcibios_allocate_resources(int pass)
187 /* Turn the ROM off, leave the resource region, 185 /* Turn the ROM off, leave the resource region,
188 * but keep it unregistered. */ 186 * but keep it unregistered. */
189 u32 reg; 187 u32 reg;
190 DBG("PCI: Switching off ROM of %s\n", 188 dev_dbg(&dev->dev, "disabling ROM\n");
191 pci_name(dev));
192 r->flags &= ~IORESOURCE_ROM_ENABLE; 189 r->flags &= ~IORESOURCE_ROM_ENABLE;
193 pci_read_config_dword(dev, 190 pci_read_config_dword(dev,
194 dev->rom_base_reg, &reg); 191 dev->rom_base_reg, &reg);
@@ -257,8 +254,7 @@ void pcibios_set_master(struct pci_dev *dev)
257 lat = pcibios_max_latency; 254 lat = pcibios_max_latency;
258 else 255 else
259 return; 256 return;
260 printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", 257 dev_printk(KERN_DEBUG, &dev->dev, "setting latency timer to %d\n", lat);
261 pci_name(dev), lat);
262 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); 258 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
263} 259}
264 260
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index 6a06a2eb0597..fec0123b33a9 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -436,7 +436,7 @@ static int pirq_vlsi_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
436{ 436{
437 WARN_ON_ONCE(pirq >= 9); 437 WARN_ON_ONCE(pirq >= 9);
438 if (pirq > 8) { 438 if (pirq > 8) {
439 printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq); 439 dev_info(&dev->dev, "VLSI router PIRQ escape (%d)\n", pirq);
440 return 0; 440 return 0;
441 } 441 }
442 return read_config_nybble(router, 0x74, pirq-1); 442 return read_config_nybble(router, 0x74, pirq-1);
@@ -446,7 +446,7 @@ static int pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq,
446{ 446{
447 WARN_ON_ONCE(pirq >= 9); 447 WARN_ON_ONCE(pirq >= 9);
448 if (pirq > 8) { 448 if (pirq > 8) {
449 printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq); 449 dev_info(&dev->dev, "VLSI router PIRQ escape (%d)\n", pirq);
450 return 0; 450 return 0;
451 } 451 }
452 write_config_nybble(router, 0x74, pirq-1, irq); 452 write_config_nybble(router, 0x74, pirq-1, irq);
@@ -492,15 +492,17 @@ static int pirq_amd756_get(struct pci_dev *router, struct pci_dev *dev, int pirq
492 irq = 0; 492 irq = 0;
493 if (pirq <= 4) 493 if (pirq <= 4)
494 irq = read_config_nybble(router, 0x56, pirq - 1); 494 irq = read_config_nybble(router, 0x56, pirq - 1);
495 printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d get irq : %2d\n", 495 dev_info(&dev->dev,
496 dev->vendor, dev->device, pirq, irq); 496 "AMD756: dev [%04x/%04x], router PIRQ %d get IRQ %d\n",
497 dev->vendor, dev->device, pirq, irq);
497 return irq; 498 return irq;
498} 499}
499 500
500static int pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq) 501static int pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
501{ 502{
502 printk(KERN_INFO "AMD756: dev %04x:%04x, router pirq : %d SET irq : %2d\n", 503 dev_info(&dev->dev,
503 dev->vendor, dev->device, pirq, irq); 504 "AMD756: dev [%04x/%04x], router PIRQ %d set IRQ %d\n",
505 dev->vendor, dev->device, pirq, irq);
504 if (pirq <= 4) 506 if (pirq <= 4)
505 write_config_nybble(router, 0x56, pirq - 1, irq); 507 write_config_nybble(router, 0x56, pirq - 1, irq);
506 return 1; 508 return 1;
@@ -730,7 +732,6 @@ static __init int ali_router_probe(struct irq_router *r, struct pci_dev *router,
730 switch (device) { 732 switch (device) {
731 case PCI_DEVICE_ID_AL_M1533: 733 case PCI_DEVICE_ID_AL_M1533:
732 case PCI_DEVICE_ID_AL_M1563: 734 case PCI_DEVICE_ID_AL_M1563:
733 printk(KERN_DEBUG "PCI: Using ALI IRQ Router\n");
734 r->name = "ALI"; 735 r->name = "ALI";
735 r->get = pirq_ali_get; 736 r->get = pirq_ali_get;
736 r->set = pirq_ali_set; 737 r->set = pirq_ali_set;
@@ -840,11 +841,9 @@ static void __init pirq_find_router(struct irq_router *r)
840 h->probe(r, pirq_router_dev, pirq_router_dev->device)) 841 h->probe(r, pirq_router_dev, pirq_router_dev->device))
841 break; 842 break;
842 } 843 }
843 printk(KERN_INFO "PCI: Using IRQ router %s [%04x/%04x] at %s\n", 844 dev_info(&pirq_router_dev->dev, "%s IRQ router [%04x/%04x]\n",
844 pirq_router.name, 845 pirq_router.name,
845 pirq_router_dev->vendor, 846 pirq_router_dev->vendor, pirq_router_dev->device);
846 pirq_router_dev->device,
847 pci_name(pirq_router_dev));
848 847
849 /* The device remains referenced for the kernel lifetime */ 848 /* The device remains referenced for the kernel lifetime */
850} 849}
@@ -877,7 +876,7 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
877 /* Find IRQ pin */ 876 /* Find IRQ pin */
878 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 877 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
879 if (!pin) { 878 if (!pin) {
880 DBG(KERN_DEBUG " -> no interrupt pin\n"); 879 dev_dbg(&dev->dev, "no interrupt pin\n");
881 return 0; 880 return 0;
882 } 881 }
883 pin = pin - 1; 882 pin = pin - 1;
@@ -887,20 +886,20 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
887 if (!pirq_table) 886 if (!pirq_table)
888 return 0; 887 return 0;
889 888
890 DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin);
891 info = pirq_get_info(dev); 889 info = pirq_get_info(dev);
892 if (!info) { 890 if (!info) {
893 DBG(" -> not found in routing table\n" KERN_DEBUG); 891 dev_dbg(&dev->dev, "PCI INT %c not found in routing table\n",
892 'A' + pin);
894 return 0; 893 return 0;
895 } 894 }
896 pirq = info->irq[pin].link; 895 pirq = info->irq[pin].link;
897 mask = info->irq[pin].bitmap; 896 mask = info->irq[pin].bitmap;
898 if (!pirq) { 897 if (!pirq) {
899 DBG(" -> not routed\n" KERN_DEBUG); 898 dev_dbg(&dev->dev, "PCI INT %c not routed\n", 'A' + pin);
900 return 0; 899 return 0;
901 } 900 }
902 DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask, 901 dev_dbg(&dev->dev, "PCI INT %c -> PIRQ %02x, mask %04x, excl %04x",
903 pirq_table->exclusive_irqs); 902 'A' + pin, pirq, mask, pirq_table->exclusive_irqs);
904 mask &= pcibios_irq_mask; 903 mask &= pcibios_irq_mask;
905 904
906 /* Work around broken HP Pavilion Notebooks which assign USB to 905 /* Work around broken HP Pavilion Notebooks which assign USB to
@@ -930,10 +929,8 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
930 if (pci_probe & PCI_USE_PIRQ_MASK) 929 if (pci_probe & PCI_USE_PIRQ_MASK)
931 newirq = 0; 930 newirq = 0;
932 else 931 else
933 printk("\n" KERN_WARNING 932 dev_warn(&dev->dev, "IRQ %d doesn't match PIRQ mask "
934 "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n" 933 "%#x; try pci=usepirqmask\n", newirq, mask);
935 KERN_DEBUG, newirq,
936 pci_name(dev));
937 } 934 }
938 if (!newirq && assign) { 935 if (!newirq && assign) {
939 for (i = 0; i < 16; i++) { 936 for (i = 0; i < 16; i++) {
@@ -944,39 +941,35 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
944 newirq = i; 941 newirq = i;
945 } 942 }
946 } 943 }
947 DBG(" -> newirq=%d", newirq); 944 dev_dbg(&dev->dev, "PCI INT %c -> newirq %d", 'A' + pin, newirq);
948 945
949 /* Check if it is hardcoded */ 946 /* Check if it is hardcoded */
950 if ((pirq & 0xf0) == 0xf0) { 947 if ((pirq & 0xf0) == 0xf0) {
951 irq = pirq & 0xf; 948 irq = pirq & 0xf;
952 DBG(" -> hardcoded IRQ %d\n", irq); 949 msg = "hardcoded";
953 msg = "Hardcoded";
954 } else if (r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \ 950 } else if (r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \
955 ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask))) { 951 ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask))) {
956 DBG(" -> got IRQ %d\n", irq); 952 msg = "found";
957 msg = "Found";
958 eisa_set_level_irq(irq); 953 eisa_set_level_irq(irq);
959 } else if (newirq && r->set && 954 } else if (newirq && r->set &&
960 (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) { 955 (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) {
961 DBG(" -> assigning IRQ %d", newirq);
962 if (r->set(pirq_router_dev, dev, pirq, newirq)) { 956 if (r->set(pirq_router_dev, dev, pirq, newirq)) {
963 eisa_set_level_irq(newirq); 957 eisa_set_level_irq(newirq);
964 DBG(" ... OK\n"); 958 msg = "assigned";
965 msg = "Assigned";
966 irq = newirq; 959 irq = newirq;
967 } 960 }
968 } 961 }
969 962
970 if (!irq) { 963 if (!irq) {
971 DBG(" ... failed\n");
972 if (newirq && mask == (1 << newirq)) { 964 if (newirq && mask == (1 << newirq)) {
973 msg = "Guessed"; 965 msg = "guessed";
974 irq = newirq; 966 irq = newirq;
975 } else 967 } else {
968 dev_dbg(&dev->dev, "can't route interrupt\n");
976 return 0; 969 return 0;
970 }
977 } 971 }
978 printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, 972 dev_info(&dev->dev, "%s PCI INT %c -> IRQ %d\n", msg, 'A' + pin, irq);
979 pci_name(dev));
980 973
981 /* Update IRQ for all devices with the same pirq value */ 974 /* Update IRQ for all devices with the same pirq value */
982 while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) { 975 while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
@@ -996,17 +989,17 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
996 (!(pci_probe & PCI_USE_PIRQ_MASK) || \ 989 (!(pci_probe & PCI_USE_PIRQ_MASK) || \
997 ((1 << dev2->irq) & mask))) { 990 ((1 << dev2->irq) & mask))) {
998#ifndef CONFIG_PCI_MSI 991#ifndef CONFIG_PCI_MSI
999 printk(KERN_INFO "IRQ routing conflict for %s, have irq %d, want irq %d\n", 992 dev_info(&dev2->dev, "IRQ routing conflict: "
1000 pci_name(dev2), dev2->irq, irq); 993 "have IRQ %d, want IRQ %d\n",
994 dev2->irq, irq);
1001#endif 995#endif
1002 continue; 996 continue;
1003 } 997 }
1004 dev2->irq = irq; 998 dev2->irq = irq;
1005 pirq_penalty[irq]++; 999 pirq_penalty[irq]++;
1006 if (dev != dev2) 1000 if (dev != dev2)
1007 printk(KERN_INFO 1001 dev_info(&dev->dev, "sharing IRQ %d with %s\n",
1008 "PCI: Sharing IRQ %d with %s\n", 1002 irq, pci_name(dev2));
1009 irq, pci_name(dev2));
1010 } 1003 }
1011 } 1004 }
1012 return 1; 1005 return 1;
@@ -1025,8 +1018,7 @@ static void __init pcibios_fixup_irqs(void)
1025 * already in use. 1018 * already in use.
1026 */ 1019 */
1027 if (dev->irq >= 16) { 1020 if (dev->irq >= 16) {
1028 DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n", 1021 dev_dbg(&dev->dev, "ignoring bogus IRQ %d\n", dev->irq);
1029 pci_name(dev), dev->irq);
1030 dev->irq = 0; 1022 dev->irq = 0;
1031 } 1023 }
1032 /* 1024 /*
@@ -1070,12 +1062,12 @@ static void __init pcibios_fixup_irqs(void)
1070 irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, 1062 irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
1071 PCI_SLOT(bridge->devfn), pin); 1063 PCI_SLOT(bridge->devfn), pin);
1072 if (irq >= 0) 1064 if (irq >= 0)
1073 printk(KERN_WARNING "PCI: using PPB %s[%c] to get irq %d\n", 1065 dev_warn(&dev->dev, "using bridge %s INT %c to get IRQ %d\n",
1074 pci_name(bridge), 'A' + pin, irq); 1066 pci_name(bridge),
1067 'A' + pin, irq);
1075 } 1068 }
1076 if (irq >= 0) { 1069 if (irq >= 0) {
1077 printk(KERN_INFO "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", 1070 dev_info(&dev->dev, "PCI->APIC IRQ transform: INT %c -> IRQ %d\n", 'A' + pin, irq);
1078 pci_name(dev), 'A' + pin, irq);
1079 dev->irq = irq; 1071 dev->irq = irq;
1080 } 1072 }
1081 } 1073 }
@@ -1231,25 +1223,24 @@ static int pirq_enable_irq(struct pci_dev *dev)
1231 irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number, 1223 irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
1232 PCI_SLOT(bridge->devfn), pin); 1224 PCI_SLOT(bridge->devfn), pin);
1233 if (irq >= 0) 1225 if (irq >= 0)
1234 printk(KERN_WARNING 1226 dev_warn(&dev->dev, "using bridge %s "
1235 "PCI: using PPB %s[%c] to get irq %d\n", 1227 "INT %c to get IRQ %d\n",
1236 pci_name(bridge), 1228 pci_name(bridge), 'A' + pin,
1237 'A' + pin, irq); 1229 irq);
1238 dev = bridge; 1230 dev = bridge;
1239 } 1231 }
1240 dev = temp_dev; 1232 dev = temp_dev;
1241 if (irq >= 0) { 1233 if (irq >= 0) {
1242 printk(KERN_INFO 1234 dev_info(&dev->dev, "PCI->APIC IRQ transform: "
1243 "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n", 1235 "INT %c -> IRQ %d\n", 'A' + pin, irq);
1244 pci_name(dev), 'A' + pin, irq);
1245 dev->irq = irq; 1236 dev->irq = irq;
1246 return 0; 1237 return 0;
1247 } else 1238 } else
1248 msg = " Probably buggy MP table."; 1239 msg = "; probably buggy MP table";
1249 } else if (pci_probe & PCI_BIOS_IRQ_SCAN) 1240 } else if (pci_probe & PCI_BIOS_IRQ_SCAN)
1250 msg = ""; 1241 msg = "";
1251 else 1242 else
1252 msg = " Please try using pci=biosirq."; 1243 msg = "; please try using pci=biosirq";
1253 1244
1254 /* 1245 /*
1255 * With IDE legacy devices the IRQ lookup failure is not 1246 * With IDE legacy devices the IRQ lookup failure is not
@@ -1259,9 +1250,8 @@ static int pirq_enable_irq(struct pci_dev *dev)
1259 !(dev->class & 0x5)) 1250 !(dev->class & 0x5))
1260 return 0; 1251 return 0;
1261 1252
1262 printk(KERN_WARNING 1253 dev_warn(&dev->dev, "can't find IRQ for PCI INT %c%s\n",
1263 "PCI: No IRQ known for interrupt pin %c of device %s.%s\n", 1254 'A' + pin, msg);
1264 'A' + pin, pci_name(dev), msg);
1265 } 1255 }
1266 return 0; 1256 return 0;
1267} 1257}
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index f4b16dc11dad..1177845d3186 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -131,13 +131,14 @@ static void __devinit pci_fixup_i450nx(struct pci_dev *d)
131 u8 busno, suba, subb; 131 u8 busno, suba, subb;
132 int quad = BUS2QUAD(d->bus->number); 132 int quad = BUS2QUAD(d->bus->number);
133 133
134 printk("PCI: Searching for i450NX host bridges on %s\n", pci_name(d)); 134 dev_info(&d->dev, "searching for i450NX host bridges\n");
135 reg = 0xd0; 135 reg = 0xd0;
136 for(pxb=0; pxb<2; pxb++) { 136 for(pxb=0; pxb<2; pxb++) {
137 pci_read_config_byte(d, reg++, &busno); 137 pci_read_config_byte(d, reg++, &busno);
138 pci_read_config_byte(d, reg++, &suba); 138 pci_read_config_byte(d, reg++, &suba);
139 pci_read_config_byte(d, reg++, &subb); 139 pci_read_config_byte(d, reg++, &subb);
140 DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb); 140 dev_dbg(&d->dev, "i450NX PXB %d: %02x/%02x/%02x\n",
141 pxb, busno, suba, subb);
141 if (busno) { 142 if (busno) {
142 /* Bus A */ 143 /* Bus A */
143 pci_scan_bus_with_sysdata(QUADLOCAL2BUS(quad, busno)); 144 pci_scan_bus_with_sysdata(QUADLOCAL2BUS(quad, busno));
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 81d0560eaea2..34163cfaaffc 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -280,36 +280,9 @@ void free_initmem(void)
280 (&__init_end - &__init_begin) >> 10); 280 (&__init_end - &__init_begin) >> 10);
281} 281}
282 282
283void show_mem(void)
284{
285 int i, free = 0, total = 0, reserved = 0;
286 int shared = 0, cached = 0;
287
288 printk("Mem-info:\n");
289 show_free_areas();
290 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
291 i = max_mapnr;
292 while (i-- > 0) {
293 total++;
294 if (PageReserved(mem_map+i))
295 reserved++;
296 else if (PageSwapCache(mem_map+i))
297 cached++;
298 else if (!page_count(mem_map + i))
299 free++;
300 else
301 shared += page_count(mem_map + i) - 1;
302 }
303 printk("%d pages of RAM\n", total);
304 printk("%d reserved pages\n", reserved);
305 printk("%d pages shared\n", shared);
306 printk("%d pages swap cached\n",cached);
307 printk("%d free pages\n", free);
308}
309
310struct kmem_cache *pgtable_cache __read_mostly; 283struct kmem_cache *pgtable_cache __read_mostly;
311 284
312static void pgd_ctor(struct kmem_cache *cache, void* addr) 285static void pgd_ctor(void* addr)
313{ 286{
314 pte_t* ptep = (pte_t*)addr; 287 pte_t* ptep = (pte_t*)addr;
315 int i; 288 int i;
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 9735acb5b4f5..cf4eb0eefbbf 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -837,8 +837,7 @@ static void as_completed_request(struct request_queue *q, struct request *rq)
837 WARN_ON(!list_empty(&rq->queuelist)); 837 WARN_ON(!list_empty(&rq->queuelist));
838 838
839 if (RQ_STATE(rq) != AS_RQ_REMOVED) { 839 if (RQ_STATE(rq) != AS_RQ_REMOVED) {
840 printk("rq->state %d\n", RQ_STATE(rq)); 840 WARN(1, "rq->state %d\n", RQ_STATE(rq));
841 WARN_ON(1);
842 goto out; 841 goto out;
843 } 842 }
844 843
diff --git a/block/blk-map.c b/block/blk-map.c
index ddd96fb11a7d..af37e4ae62f5 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -269,7 +269,6 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
269 int reading = rq_data_dir(rq) == READ; 269 int reading = rq_data_dir(rq) == READ;
270 int do_copy = 0; 270 int do_copy = 0;
271 struct bio *bio; 271 struct bio *bio;
272 unsigned long stack_mask = ~(THREAD_SIZE - 1);
273 272
274 if (len > (q->max_hw_sectors << 9)) 273 if (len > (q->max_hw_sectors << 9))
275 return -EINVAL; 274 return -EINVAL;
@@ -278,11 +277,8 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
278 277
279 kaddr = (unsigned long)kbuf; 278 kaddr = (unsigned long)kbuf;
280 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 279 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
281 do_copy = ((kaddr & alignment) || (len & alignment)); 280 do_copy = ((kaddr & alignment) || (len & alignment) ||
282 281 object_is_on_stack(kbuf));
283 if (!((kaddr & stack_mask) ^
284 ((unsigned long)current->stack & stack_mask)))
285 do_copy = 1;
286 282
287 if (do_copy) 283 if (do_copy)
288 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading); 284 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index dd376f7ad090..d5b4ef898879 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -76,9 +76,9 @@ static struct acpi_pci_driver acpi_pci_slot_driver = {
76}; 76};
77 77
78static int 78static int
79check_slot(acpi_handle handle, int *device, unsigned long *sun) 79check_slot(acpi_handle handle, unsigned long *sun)
80{ 80{
81 int retval = 0; 81 int device = -1;
82 unsigned long adr, sta; 82 unsigned long adr, sta;
83 acpi_status status; 83 acpi_status status;
84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -89,32 +89,27 @@ check_slot(acpi_handle handle, int *device, unsigned long *sun)
89 if (check_sta_before_sun) { 89 if (check_sta_before_sun) {
90 /* If SxFy doesn't have _STA, we just assume it's there */ 90 /* If SxFy doesn't have _STA, we just assume it's there */
91 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 91 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
92 if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT)) { 92 if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT))
93 retval = -1;
94 goto out; 93 goto out;
95 }
96 } 94 }
97 95
98 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 96 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
99 if (ACPI_FAILURE(status)) { 97 if (ACPI_FAILURE(status)) {
100 dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer); 98 dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer);
101 retval = -1;
102 goto out; 99 goto out;
103 } 100 }
104 101
105 *device = (adr >> 16) & 0xffff;
106
107 /* No _SUN == not a slot == bail */ 102 /* No _SUN == not a slot == bail */
108 status = acpi_evaluate_integer(handle, "_SUN", NULL, sun); 103 status = acpi_evaluate_integer(handle, "_SUN", NULL, sun);
109 if (ACPI_FAILURE(status)) { 104 if (ACPI_FAILURE(status)) {
110 dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer); 105 dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer);
111 retval = -1;
112 goto out; 106 goto out;
113 } 107 }
114 108
109 device = (adr >> 16) & 0xffff;
115out: 110out:
116 kfree(buffer.pointer); 111 kfree(buffer.pointer);
117 return retval; 112 return device;
118} 113}
119 114
120struct callback_args { 115struct callback_args {
@@ -144,7 +139,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
144 struct callback_args *parent_context = context; 139 struct callback_args *parent_context = context;
145 struct pci_bus *pci_bus = parent_context->pci_bus; 140 struct pci_bus *pci_bus = parent_context->pci_bus;
146 141
147 if (check_slot(handle, &device, &sun)) 142 device = check_slot(handle, &sun);
143 if (device < 0)
148 return AE_OK; 144 return AE_OK;
149 145
150 slot = kmalloc(sizeof(*slot), GFP_KERNEL); 146 slot = kmalloc(sizeof(*slot), GFP_KERNEL);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index d592dbb1d12a..283c08f5f4d4 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -272,6 +272,8 @@ static atomic_t c3_cpu_count;
272/* Common C-state entry for C2, C3, .. */ 272/* Common C-state entry for C2, C3, .. */
273static void acpi_cstate_enter(struct acpi_processor_cx *cstate) 273static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
274{ 274{
275 /* Don't trace irqs off for idle */
276 stop_critical_timings();
275 if (cstate->entry_method == ACPI_CSTATE_FFH) { 277 if (cstate->entry_method == ACPI_CSTATE_FFH) {
276 /* Call into architectural FFH based C-state */ 278 /* Call into architectural FFH based C-state */
277 acpi_processor_ffh_cstate_enter(cstate); 279 acpi_processor_ffh_cstate_enter(cstate);
@@ -284,6 +286,7 @@ static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
284 gets asserted in time to freeze execution properly. */ 286 gets asserted in time to freeze execution properly. */
285 unused = inl(acpi_gbl_FADT.xpm_timer_block.address); 287 unused = inl(acpi_gbl_FADT.xpm_timer_block.address);
286 } 288 }
289 start_critical_timings();
287} 290}
288#endif /* !CONFIG_CPU_IDLE */ 291#endif /* !CONFIG_CPU_IDLE */
289 292
@@ -1329,9 +1332,15 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1329 if (!pr->flags.power_setup_done) 1332 if (!pr->flags.power_setup_done)
1330 return -ENODEV; 1333 return -ENODEV;
1331 1334
1332 /* Fall back to the default idle loop */ 1335 /*
1333 pm_idle = pm_idle_save; 1336 * Fall back to the default idle loop, when pm_idle_save had
1334 synchronize_sched(); /* Relies on interrupts forcing exit from idle. */ 1337 * been initialized.
1338 */
1339 if (pm_idle_save) {
1340 pm_idle = pm_idle_save;
1341 /* Relies on interrupts forcing exit from idle. */
1342 synchronize_sched();
1343 }
1335 1344
1336 pr->flags.power = 0; 1345 pr->flags.power = 0;
1337 result = acpi_processor_get_power_info(pr); 1346 result = acpi_processor_get_power_info(pr);
@@ -1418,6 +1427,8 @@ static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr,
1418 */ 1427 */
1419static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx) 1428static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx)
1420{ 1429{
1430 /* Don't trace irqs off for idle */
1431 stop_critical_timings();
1421 if (cx->entry_method == ACPI_CSTATE_FFH) { 1432 if (cx->entry_method == ACPI_CSTATE_FFH) {
1422 /* Call into architectural FFH based C-state */ 1433 /* Call into architectural FFH based C-state */
1423 acpi_processor_ffh_cstate_enter(cx); 1434 acpi_processor_ffh_cstate_enter(cx);
@@ -1432,6 +1443,7 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx)
1432 gets asserted in time to freeze execution properly. */ 1443 gets asserted in time to freeze execution properly. */
1433 unused = inl(acpi_gbl_FADT.xpm_timer_block.address); 1444 unused = inl(acpi_gbl_FADT.xpm_timer_block.address);
1434 } 1445 }
1446 start_critical_timings();
1435} 1447}
1436 1448
1437/** 1449/**
@@ -1890,7 +1902,8 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1890 1902
1891 /* Unregister the idle handler when processor #0 is removed. */ 1903 /* Unregister the idle handler when processor #0 is removed. */
1892 if (pr->id == 0) { 1904 if (pr->id == 0) {
1893 pm_idle = pm_idle_save; 1905 if (pm_idle_save)
1906 pm_idle = pm_idle_save;
1894 1907
1895 /* 1908 /*
1896 * We are about to unload the current idle thread pm callback 1909 * We are about to unload the current idle thread pm callback
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index a2c3f9cfa549..a56fc6c4394b 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -827,7 +827,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
827static int acpi_processor_get_throttling(struct acpi_processor *pr) 827static int acpi_processor_get_throttling(struct acpi_processor *pr)
828{ 828{
829 cpumask_t saved_mask; 829 cpumask_t saved_mask;
830 cpumask_of_cpu_ptr_declare(new_mask);
831 int ret; 830 int ret;
832 831
833 if (!pr) 832 if (!pr)
@@ -839,8 +838,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
839 * Migrate task to the cpu pointed by pr. 838 * Migrate task to the cpu pointed by pr.
840 */ 839 */
841 saved_mask = current->cpus_allowed; 840 saved_mask = current->cpus_allowed;
842 cpumask_of_cpu_ptr_next(new_mask, pr->id); 841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
843 set_cpus_allowed_ptr(current, new_mask);
844 ret = pr->throttling.acpi_processor_get_throttling(pr); 842 ret = pr->throttling.acpi_processor_get_throttling(pr);
845 /* restore the previous state */ 843 /* restore the previous state */
846 set_cpus_allowed_ptr(current, &saved_mask); 844 set_cpus_allowed_ptr(current, &saved_mask);
@@ -989,7 +987,6 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
989int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 987int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
990{ 988{
991 cpumask_t saved_mask; 989 cpumask_t saved_mask;
992 cpumask_of_cpu_ptr_declare(new_mask);
993 int ret = 0; 990 int ret = 0;
994 unsigned int i; 991 unsigned int i;
995 struct acpi_processor *match_pr; 992 struct acpi_processor *match_pr;
@@ -1028,8 +1025,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1028 * it can be called only for the cpu pointed by pr. 1025 * it can be called only for the cpu pointed by pr.
1029 */ 1026 */
1030 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1031 cpumask_of_cpu_ptr_next(new_mask, pr->id); 1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
1032 set_cpus_allowed_ptr(current, new_mask);
1033 ret = p_throttling->acpi_processor_set_throttling(pr, 1029 ret = p_throttling->acpi_processor_set_throttling(pr,
1034 t_state.target_state); 1030 t_state.target_state);
1035 } else { 1031 } else {
@@ -1060,8 +1056,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1060 continue; 1056 continue;
1061 } 1057 }
1062 t_state.cpu = i; 1058 t_state.cpu = i;
1063 cpumask_of_cpu_ptr_next(new_mask, i); 1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
1064 set_cpus_allowed_ptr(current, new_mask);
1065 ret = match_pr->throttling. 1060 ret = match_pr->throttling.
1066 acpi_processor_set_throttling( 1061 acpi_processor_set_throttling(
1067 match_pr, t_state.target_state); 1062 match_pr, t_state.target_state);
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index de8d186f5abf..2014253f6c88 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -169,7 +169,7 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
169 169
170 irq = platform_get_irq(pdev, 0); 170 irq = platform_get_irq(pdev, 0);
171 if (irq) 171 if (irq)
172 set_irq_type(irq, IRQT_RISING); 172 set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
173 173
174 /* Setup expansion bus chip selects */ 174 /* Setup expansion bus chip selects */
175 *data->cs0_cfg = data->cs0_bits; 175 *data->cs0_cfg = data->cs0_bits;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7d5c63c81a59..068aa1c9538c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -116,12 +116,10 @@ static void device_release(struct kobject *kobj)
116 dev->type->release(dev); 116 dev->type->release(dev);
117 else if (dev->class && dev->class->dev_release) 117 else if (dev->class && dev->class->dev_release)
118 dev->class->dev_release(dev); 118 dev->class->dev_release(dev);
119 else { 119 else
120 printk(KERN_ERR "Device '%s' does not have a release() " 120 WARN(1, KERN_ERR "Device '%s' does not have a release() "
121 "function, it is broken and must be fixed.\n", 121 "function, it is broken and must be fixed.\n",
122 dev->bus_id); 122 dev->bus_id);
123 WARN_ON(1);
124 }
125} 123}
126 124
127static struct kobj_type device_ktype = { 125static struct kobj_type device_ktype = {
diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index d2222397a401..efd577574948 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -7,6 +7,7 @@
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/dma-mapping.h>
10#include <linux/isa.h> 11#include <linux/isa.h>
11 12
12static struct device isa_bus = { 13static struct device isa_bus = {
@@ -141,6 +142,9 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev)
141 isa_dev->dev.release = isa_dev_release; 142 isa_dev->dev.release = isa_dev_release;
142 isa_dev->id = id; 143 isa_dev->id = id;
143 144
145 isa_dev->dev.coherent_dma_mask = DMA_24BIT_MASK;
146 isa_dev->dev.dma_mask = &isa_dev->dev.coherent_dma_mask;
147
144 error = device_register(&isa_dev->dev); 148 error = device_register(&isa_dev->dev);
145 if (error) { 149 if (error) {
146 put_device(&isa_dev->dev); 150 put_device(&isa_dev->dev);
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 855ed1a9f97b..af0d175c025d 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -103,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev,
103/* 103/*
104 * Show whether the section of memory is likely to be hot-removable 104 * Show whether the section of memory is likely to be hot-removable
105 */ 105 */
106static ssize_t show_mem_removable(struct sys_device *dev, char *buf) 106static ssize_t show_mem_removable(struct sys_device *dev,
107 struct sysdev_attribute *attr, char *buf)
107{ 108{
108 unsigned long start_pfn; 109 unsigned long start_pfn;
109 int ret; 110 int ret;
@@ -204,9 +205,8 @@ memory_block_action(struct memory_block *mem, unsigned long action)
204 } 205 }
205 break; 206 break;
206 default: 207 default:
207 printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", 208 WARN(1, KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
208 __func__, mem, action, action); 209 __func__, mem, action, action);
209 WARN_ON(1);
210 ret = -EINVAL; 210 ret = -EINVAL;
211 } 211 }
212 212
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 40fc14f03540..75dd6e22faff 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -168,19 +168,16 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
168 int err = 0; 168 int err = 0;
169 169
170 if (!cls) { 170 if (!cls) {
171 printk(KERN_WARNING "sysdev: invalid class passed to " 171 WARN(1, KERN_WARNING "sysdev: invalid class passed to "
172 "sysdev_driver_register!\n"); 172 "sysdev_driver_register!\n");
173 WARN_ON(1);
174 return -EINVAL; 173 return -EINVAL;
175 } 174 }
176 175
177 /* Check whether this driver has already been added to a class. */ 176 /* Check whether this driver has already been added to a class. */
178 if (drv->entry.next && !list_empty(&drv->entry)) { 177 if (drv->entry.next && !list_empty(&drv->entry))
179 printk(KERN_WARNING "sysdev: class %s: driver (%p) has already" 178 WARN(1, KERN_WARNING "sysdev: class %s: driver (%p) has already"
180 " been registered to a class, something is wrong, but " 179 " been registered to a class, something is wrong, but "
181 "will forge on!\n", cls->name, drv); 180 "will forge on!\n", cls->name, drv);
182 WARN_ON(1);
183 }
184 181
185 mutex_lock(&sysdev_drivers_lock); 182 mutex_lock(&sysdev_drivers_lock);
186 if (cls && kset_get(&cls->kset)) { 183 if (cls && kset_get(&cls->kset)) {
@@ -194,8 +191,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
194 } 191 }
195 } else { 192 } else {
196 err = -EINVAL; 193 err = -EINVAL;
197 printk(KERN_ERR "%s: invalid device class\n", __func__); 194 WARN(1, KERN_ERR "%s: invalid device class\n", __func__);
198 WARN_ON(1);
199 } 195 }
200 mutex_unlock(&sysdev_drivers_lock); 196 mutex_unlock(&sysdev_drivers_lock);
201 return err; 197 return err;
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 19b88504e960..ca7c72a486b2 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -304,9 +304,9 @@ static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t co
304} 304}
305 305
306static long dsp56k_ioctl(struct file *file, unsigned int cmd, 306static long dsp56k_ioctl(struct file *file, unsigned int cmd,
307 unsigned long arg) 307 unsigned long arg)
308{ 308{
309 int dev = iminor(inode) & 0x0f; 309 int dev = iminor(file->f_path.dentry->d_inode) & 0x0f;
310 void __user *argp = (void __user *)arg; 310 void __user *argp = (void __user *)arg;
311 311
312 switch(dev) 312 switch(dev)
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index 27fdc0866496..8a2fce0756ec 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -241,7 +241,7 @@ static int __init intel_rng_hw_init(void *_intel_rng_hw)
241 struct intel_rng_hw *intel_rng_hw = _intel_rng_hw; 241 struct intel_rng_hw *intel_rng_hw = _intel_rng_hw;
242 u8 mfc, dvc; 242 u8 mfc, dvc;
243 243
244 /* interrupts disabled in stop_machine_run call */ 244 /* interrupts disabled in stop_machine call */
245 245
246 if (!(intel_rng_hw->fwh_dec_en1_val & FWH_F8_EN_MASK)) 246 if (!(intel_rng_hw->fwh_dec_en1_val & FWH_F8_EN_MASK))
247 pci_write_config_byte(intel_rng_hw->dev, 247 pci_write_config_byte(intel_rng_hw->dev,
@@ -365,10 +365,10 @@ static int __init mod_init(void)
365 * location with the Read ID command, all activity on the system 365 * location with the Read ID command, all activity on the system
366 * must be stopped until the state is back to normal. 366 * must be stopped until the state is back to normal.
367 * 367 *
368 * Use stop_machine_run because IPIs can be blocked by disabling 368 * Use stop_machine because IPIs can be blocked by disabling
369 * interrupts. 369 * interrupts.
370 */ 370 */
371 err = stop_machine_run(intel_rng_hw_init, intel_rng_hw, NR_CPUS); 371 err = stop_machine(intel_rng_hw_init, intel_rng_hw, NULL);
372 pci_dev_put(dev); 372 pci_dev_put(dev);
373 iounmap(intel_rng_hw->mem); 373 iounmap(intel_rng_hw->mem);
374 kfree(intel_rng_hw); 374 kfree(intel_rng_hw);
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index f9f72a211292..006be92ee3f3 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -125,15 +125,15 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
125 ssize_t ret; 125 ssize_t ret;
126 126
127 if (flashdebug) 127 if (flashdebug)
128 printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " 128 printk(KERN_DEBUG "flash_read: flash_read: offset=0x%llx, "
129 "buffer=%p, count=0x%X.\n", p, buf, count); 129 "buffer=%p, count=0x%zx.\n", *ppos, buf, size);
130 /* 130 /*
131 * We now lock against reads and writes. --rmk 131 * We now lock against reads and writes. --rmk
132 */ 132 */
133 if (mutex_lock_interruptible(&nwflash_mutex)) 133 if (mutex_lock_interruptible(&nwflash_mutex))
134 return -ERESTARTSYS; 134 return -ERESTARTSYS;
135 135
136 ret = simple_read_from_buffer(buf, size, ppos, FLASH_BASE, gbFlashSize); 136 ret = simple_read_from_buffer(buf, size, ppos, (void *)FLASH_BASE, gbFlashSize);
137 mutex_unlock(&nwflash_mutex); 137 mutex_unlock(&nwflash_mutex);
138 138
139 return ret; 139 return ret;
diff --git a/drivers/char/pcmcia/ipwireless/hardware.c b/drivers/char/pcmcia/ipwireless/hardware.c
index 929101ecbae2..4c1820cad712 100644
--- a/drivers/char/pcmcia/ipwireless/hardware.c
+++ b/drivers/char/pcmcia/ipwireless/hardware.c
@@ -30,11 +30,11 @@
30static void ipw_send_setup_packet(struct ipw_hardware *hw); 30static void ipw_send_setup_packet(struct ipw_hardware *hw);
31static void handle_received_SETUP_packet(struct ipw_hardware *ipw, 31static void handle_received_SETUP_packet(struct ipw_hardware *ipw,
32 unsigned int address, 32 unsigned int address,
33 unsigned char *data, int len, 33 const unsigned char *data, int len,
34 int is_last); 34 int is_last);
35static void ipwireless_setup_timer(unsigned long data); 35static void ipwireless_setup_timer(unsigned long data);
36static void handle_received_CTRL_packet(struct ipw_hardware *hw, 36static void handle_received_CTRL_packet(struct ipw_hardware *hw,
37 unsigned int channel_idx, unsigned char *data, int len); 37 unsigned int channel_idx, const unsigned char *data, int len);
38 38
39/*#define TIMING_DIAGNOSTICS*/ 39/*#define TIMING_DIAGNOSTICS*/
40 40
@@ -79,8 +79,7 @@ static void report_timing(void)
79 timing_stats.last_report_time = jiffies; 79 timing_stats.last_report_time = jiffies;
80 if (!first) 80 if (!first)
81 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 81 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
82 ": %u us elapsed - read %lu bytes in %u us, " 82 ": %u us elapsed - read %lu bytes in %u us, wrote %lu bytes in %u us\n",
83 "wrote %lu bytes in %u us\n",
84 jiffies_to_usecs(since), 83 jiffies_to_usecs(since),
85 timing_stats.read_bytes, 84 timing_stats.read_bytes,
86 jiffies_to_usecs(timing_stats.read_time), 85 jiffies_to_usecs(timing_stats.read_time),
@@ -133,29 +132,17 @@ enum {
133#define NL_FOLLOWING_PACKET_HEADER_SIZE 1 132#define NL_FOLLOWING_PACKET_HEADER_SIZE 1
134 133
135struct nl_first_packet_header { 134struct nl_first_packet_header {
136#if defined(__BIG_ENDIAN_BITFIELD)
137 unsigned char packet_rank:2;
138 unsigned char address:3;
139 unsigned char protocol:3;
140#else
141 unsigned char protocol:3; 135 unsigned char protocol:3;
142 unsigned char address:3; 136 unsigned char address:3;
143 unsigned char packet_rank:2; 137 unsigned char packet_rank:2;
144#endif
145 unsigned char length_lsb; 138 unsigned char length_lsb;
146 unsigned char length_msb; 139 unsigned char length_msb;
147}; 140};
148 141
149struct nl_packet_header { 142struct nl_packet_header {
150#if defined(__BIG_ENDIAN_BITFIELD)
151 unsigned char packet_rank:2;
152 unsigned char address:3;
153 unsigned char protocol:3;
154#else
155 unsigned char protocol:3; 143 unsigned char protocol:3;
156 unsigned char address:3; 144 unsigned char address:3;
157 unsigned char packet_rank:2; 145 unsigned char packet_rank:2;
158#endif
159}; 146};
160 147
161/* Value of 'packet_rank' above */ 148/* Value of 'packet_rank' above */
@@ -227,15 +214,12 @@ struct MEMINFREG {
227 unsigned short memreg_tx_new; /* TX2 (new) Register (R/W) */ 214 unsigned short memreg_tx_new; /* TX2 (new) Register (R/W) */
228}; 215};
229 216
230#define IODMADPR 0x00 /* DMA Data Port Register (R/W) */
231
232#define CARD_PRESENT_VALUE (0xBEEFCAFEUL) 217#define CARD_PRESENT_VALUE (0xBEEFCAFEUL)
233 218
234#define MEMTX_TX 0x0001 219#define MEMTX_TX 0x0001
235#define MEMRX_RX 0x0001 220#define MEMRX_RX 0x0001
236#define MEMRX_RX_DONE 0x0001 221#define MEMRX_RX_DONE 0x0001
237#define MEMRX_PCINTACKK 0x0001 222#define MEMRX_PCINTACKK 0x0001
238#define MEMRX_MEMSPURIOUSINT 0x0001
239 223
240#define NL_NUM_OF_PRIORITIES 3 224#define NL_NUM_OF_PRIORITIES 3
241#define NL_NUM_OF_PROTOCOLS 3 225#define NL_NUM_OF_PROTOCOLS 3
@@ -245,7 +229,7 @@ struct ipw_hardware {
245 unsigned int base_port; 229 unsigned int base_port;
246 short hw_version; 230 short hw_version;
247 unsigned short ll_mtu; 231 unsigned short ll_mtu;
248 spinlock_t spinlock; 232 spinlock_t lock;
249 233
250 int initializing; 234 int initializing;
251 int init_loops; 235 int init_loops;
@@ -386,26 +370,52 @@ static void dump_data_bytes(const char *type, const unsigned char *data,
386 length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES); 370 length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES);
387} 371}
388 372
389static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data, 373static void swap_packet_bitfield_to_le(unsigned char *data)
374{
375#ifdef __BIG_ENDIAN_BITFIELD
376 unsigned char tmp = *data, ret = 0;
377
378 /*
379 * transform bits from aa.bbb.ccc to ccc.bbb.aa
380 */
381 ret |= tmp & 0xc0 >> 6;
382 ret |= tmp & 0x38 >> 1;
383 ret |= tmp & 0x07 << 5;
384 *data = ret & 0xff;
385#endif
386}
387
388static void swap_packet_bitfield_from_le(unsigned char *data)
389{
390#ifdef __BIG_ENDIAN_BITFIELD
391 unsigned char tmp = *data, ret = 0;
392
393 /*
394 * transform bits from ccc.bbb.aa to aa.bbb.ccc
395 */
396 ret |= tmp & 0xe0 >> 5;
397 ret |= tmp & 0x1c << 1;
398 ret |= tmp & 0x03 << 6;
399 *data = ret & 0xff;
400#endif
401}
402
403static void do_send_fragment(struct ipw_hardware *hw, unsigned char *data,
390 unsigned length) 404 unsigned length)
391{ 405{
392 int i; 406 unsigned i;
393 unsigned long flags; 407 unsigned long flags;
394 408
395 start_timing(); 409 start_timing();
396 410 BUG_ON(length > hw->ll_mtu);
397 if (length == 0)
398 return 0;
399
400 if (length > hw->ll_mtu)
401 return -1;
402 411
403 if (ipwireless_debug) 412 if (ipwireless_debug)
404 dump_data_bytes("send", data, length); 413 dump_data_bytes("send", data, length);
405 414
406 spin_lock_irqsave(&hw->spinlock, flags); 415 spin_lock_irqsave(&hw->lock, flags);
407 416
408 hw->tx_ready = 0; 417 hw->tx_ready = 0;
418 swap_packet_bitfield_to_le(data);
409 419
410 if (hw->hw_version == HW_VERSION_1) { 420 if (hw->hw_version == HW_VERSION_1) {
411 outw((unsigned short) length, hw->base_port + IODWR); 421 outw((unsigned short) length, hw->base_port + IODWR);
@@ -414,7 +424,7 @@ static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data,
414 unsigned short d = data[i]; 424 unsigned short d = data[i];
415 __le16 raw_data; 425 __le16 raw_data;
416 426
417 if (likely(i + 1 < length)) 427 if (i + 1 < length)
418 d |= data[i + 1] << 8; 428 d |= data[i + 1] << 8;
419 raw_data = cpu_to_le16(d); 429 raw_data = cpu_to_le16(d);
420 outw(raw_data, hw->base_port + IODWR); 430 outw(raw_data, hw->base_port + IODWR);
@@ -422,32 +432,30 @@ static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data,
422 432
423 outw(DCR_TXDONE, hw->base_port + IODCR); 433 outw(DCR_TXDONE, hw->base_port + IODCR);
424 } else if (hw->hw_version == HW_VERSION_2) { 434 } else if (hw->hw_version == HW_VERSION_2) {
425 outw((unsigned short) length, hw->base_port + IODMADPR); 435 outw((unsigned short) length, hw->base_port);
426 436
427 for (i = 0; i < length; i += 2) { 437 for (i = 0; i < length; i += 2) {
428 unsigned short d = data[i]; 438 unsigned short d = data[i];
429 __le16 raw_data; 439 __le16 raw_data;
430 440
431 if ((i + 1 < length)) 441 if (i + 1 < length)
432 d |= data[i + 1] << 8; 442 d |= data[i + 1] << 8;
433 raw_data = cpu_to_le16(d); 443 raw_data = cpu_to_le16(d);
434 outw(raw_data, hw->base_port + IODMADPR); 444 outw(raw_data, hw->base_port);
435 } 445 }
436 while ((i & 3) != 2) { 446 while ((i & 3) != 2) {
437 outw((unsigned short) 0xDEAD, hw->base_port + IODMADPR); 447 outw((unsigned short) 0xDEAD, hw->base_port);
438 i += 2; 448 i += 2;
439 } 449 }
440 writew(MEMRX_RX, &hw->memory_info_regs->memreg_rx); 450 writew(MEMRX_RX, &hw->memory_info_regs->memreg_rx);
441 } 451 }
442 452
443 spin_unlock_irqrestore(&hw->spinlock, flags); 453 spin_unlock_irqrestore(&hw->lock, flags);
444 454
445 end_write_timing(length); 455 end_write_timing(length);
446
447 return 0;
448} 456}
449 457
450static int do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet) 458static void do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet)
451{ 459{
452 unsigned short fragment_data_len; 460 unsigned short fragment_data_len;
453 unsigned short data_left = packet->length - packet->offset; 461 unsigned short data_left = packet->length - packet->offset;
@@ -462,6 +470,10 @@ static int do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet)
462 if (data_left < fragment_data_len) 470 if (data_left < fragment_data_len)
463 fragment_data_len = data_left; 471 fragment_data_len = data_left;
464 472
473 /*
474 * hdr_first is now in machine bitfield order, which will be swapped
475 * to le just before it goes to hw
476 */
465 pkt.hdr_first.protocol = packet->protocol; 477 pkt.hdr_first.protocol = packet->protocol;
466 pkt.hdr_first.address = packet->dest_addr; 478 pkt.hdr_first.address = packet->dest_addr;
467 pkt.hdr_first.packet_rank = 0; 479 pkt.hdr_first.packet_rank = 0;
@@ -493,25 +505,23 @@ static int do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet)
493 */ 505 */
494 unsigned long flags; 506 unsigned long flags;
495 507
496 spin_lock_irqsave(&hw->spinlock, flags); 508 spin_lock_irqsave(&hw->lock, flags);
497 list_add(&packet->queue, &hw->tx_queue[0]); 509 list_add(&packet->queue, &hw->tx_queue[0]);
498 hw->tx_queued++; 510 hw->tx_queued++;
499 spin_unlock_irqrestore(&hw->spinlock, flags); 511 spin_unlock_irqrestore(&hw->lock, flags);
500 } else { 512 } else {
501 if (packet->packet_callback) 513 if (packet->packet_callback)
502 packet->packet_callback(packet->callback_data, 514 packet->packet_callback(packet->callback_data,
503 packet->length); 515 packet->length);
504 kfree(packet); 516 kfree(packet);
505 } 517 }
506
507 return 0;
508} 518}
509 519
510static void ipw_setup_hardware(struct ipw_hardware *hw) 520static void ipw_setup_hardware(struct ipw_hardware *hw)
511{ 521{
512 unsigned long flags; 522 unsigned long flags;
513 523
514 spin_lock_irqsave(&hw->spinlock, flags); 524 spin_lock_irqsave(&hw->lock, flags);
515 if (hw->hw_version == HW_VERSION_1) { 525 if (hw->hw_version == HW_VERSION_1) {
516 /* Reset RX FIFO */ 526 /* Reset RX FIFO */
517 outw(DCR_RXRESET, hw->base_port + IODCR); 527 outw(DCR_RXRESET, hw->base_port + IODCR);
@@ -530,7 +540,7 @@ static void ipw_setup_hardware(struct ipw_hardware *hw)
530 csr |= 1; 540 csr |= 1;
531 writew(csr, &hw->memregs_CCR->reg_config_and_status); 541 writew(csr, &hw->memregs_CCR->reg_config_and_status);
532 } 542 }
533 spin_unlock_irqrestore(&hw->spinlock, flags); 543 spin_unlock_irqrestore(&hw->lock, flags);
534} 544}
535 545
536/* 546/*
@@ -549,28 +559,23 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
549 if (!packet) { 559 if (!packet) {
550 unsigned long flags; 560 unsigned long flags;
551 561
552 /* 562 spin_lock_irqsave(&hw->lock, flags);
553 * If this is the first fragment, then we will need to fetch a
554 * packet to put it in.
555 */
556 spin_lock_irqsave(&hw->spinlock, flags);
557 /* If we have one in our pool, then pull it out. */
558 if (!list_empty(&hw->rx_pool)) { 563 if (!list_empty(&hw->rx_pool)) {
559 packet = list_first_entry(&hw->rx_pool, 564 packet = list_first_entry(&hw->rx_pool,
560 struct ipw_rx_packet, queue); 565 struct ipw_rx_packet, queue);
561 list_del(&packet->queue);
562 hw->rx_pool_size--; 566 hw->rx_pool_size--;
563 spin_unlock_irqrestore(&hw->spinlock, flags); 567 spin_unlock_irqrestore(&hw->lock, flags);
568 list_del(&packet->queue);
564 } else { 569 } else {
565 /* Otherwise allocate a new one. */ 570 const int min_capacity =
566 static int min_capacity = 256; 571 ipwireless_ppp_mru(hw->network) + 2;
567 int new_capacity; 572 int new_capacity;
568 573
569 spin_unlock_irqrestore(&hw->spinlock, flags); 574 spin_unlock_irqrestore(&hw->lock, flags);
570 new_capacity = 575 new_capacity =
571 minimum_free_space > min_capacity 576 (minimum_free_space > min_capacity
572 ? minimum_free_space 577 ? minimum_free_space
573 : min_capacity; 578 : min_capacity);
574 packet = kmalloc(sizeof(struct ipw_rx_packet) 579 packet = kmalloc(sizeof(struct ipw_rx_packet)
575 + new_capacity, GFP_ATOMIC); 580 + new_capacity, GFP_ATOMIC);
576 if (!packet) 581 if (!packet)
@@ -580,10 +585,6 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
580 packet->length = 0; 585 packet->length = 0;
581 } 586 }
582 587
583 /*
584 * If this packet does not have sufficient capacity for the data we
585 * want to add, then make it bigger.
586 */
587 if (packet->length + minimum_free_space > packet->capacity) { 588 if (packet->length + minimum_free_space > packet->capacity) {
588 struct ipw_rx_packet *old_packet = packet; 589 struct ipw_rx_packet *old_packet = packet;
589 590
@@ -610,13 +611,15 @@ static void pool_free(struct ipw_hardware *hw, struct ipw_rx_packet *packet)
610 kfree(packet); 611 kfree(packet);
611 else { 612 else {
612 hw->rx_pool_size++; 613 hw->rx_pool_size++;
613 list_add_tail(&packet->queue, &hw->rx_pool); 614 list_add(&packet->queue, &hw->rx_pool);
614 } 615 }
615} 616}
616 617
617static void queue_received_packet(struct ipw_hardware *hw, 618static void queue_received_packet(struct ipw_hardware *hw,
618 unsigned int protocol, unsigned int address, 619 unsigned int protocol,
619 unsigned char *data, int length, int is_last) 620 unsigned int address,
621 const unsigned char *data, int length,
622 int is_last)
620{ 623{
621 unsigned int channel_idx = address - 1; 624 unsigned int channel_idx = address - 1;
622 struct ipw_rx_packet *packet = NULL; 625 struct ipw_rx_packet *packet = NULL;
@@ -658,9 +661,9 @@ static void queue_received_packet(struct ipw_hardware *hw,
658 packet = *assem; 661 packet = *assem;
659 *assem = NULL; 662 *assem = NULL;
660 /* Count queued DATA bytes only */ 663 /* Count queued DATA bytes only */
661 spin_lock_irqsave(&hw->spinlock, flags); 664 spin_lock_irqsave(&hw->lock, flags);
662 hw->rx_bytes_queued += packet->length; 665 hw->rx_bytes_queued += packet->length;
663 spin_unlock_irqrestore(&hw->spinlock, flags); 666 spin_unlock_irqrestore(&hw->lock, flags);
664 } 667 }
665 } else { 668 } else {
666 /* If it's a CTRL packet, don't assemble, just queue it. */ 669 /* If it's a CTRL packet, don't assemble, just queue it. */
@@ -682,13 +685,13 @@ static void queue_received_packet(struct ipw_hardware *hw,
682 * network layer. 685 * network layer.
683 */ 686 */
684 if (packet) { 687 if (packet) {
685 spin_lock_irqsave(&hw->spinlock, flags); 688 spin_lock_irqsave(&hw->lock, flags);
686 list_add_tail(&packet->queue, &hw->rx_queue); 689 list_add_tail(&packet->queue, &hw->rx_queue);
687 /* Block reception of incoming packets if queue is full. */ 690 /* Block reception of incoming packets if queue is full. */
688 hw->blocking_rx = 691 hw->blocking_rx =
689 hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE; 692 (hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE);
690 693
691 spin_unlock_irqrestore(&hw->spinlock, flags); 694 spin_unlock_irqrestore(&hw->lock, flags);
692 schedule_work(&hw->work_rx); 695 schedule_work(&hw->work_rx);
693 } 696 }
694} 697}
@@ -702,7 +705,7 @@ static void ipw_receive_data_work(struct work_struct *work_rx)
702 container_of(work_rx, struct ipw_hardware, work_rx); 705 container_of(work_rx, struct ipw_hardware, work_rx);
703 unsigned long flags; 706 unsigned long flags;
704 707
705 spin_lock_irqsave(&hw->spinlock, flags); 708 spin_lock_irqsave(&hw->lock, flags);
706 while (!list_empty(&hw->rx_queue)) { 709 while (!list_empty(&hw->rx_queue)) {
707 struct ipw_rx_packet *packet = 710 struct ipw_rx_packet *packet =
708 list_first_entry(&hw->rx_queue, 711 list_first_entry(&hw->rx_queue,
@@ -720,7 +723,7 @@ static void ipw_receive_data_work(struct work_struct *work_rx)
720 if (packet->protocol == TL_PROTOCOLID_COM_DATA) { 723 if (packet->protocol == TL_PROTOCOLID_COM_DATA) {
721 if (hw->network != NULL) { 724 if (hw->network != NULL) {
722 /* If the network hasn't been disconnected. */ 725 /* If the network hasn't been disconnected. */
723 spin_unlock_irqrestore(&hw->spinlock, flags); 726 spin_unlock_irqrestore(&hw->lock, flags);
724 /* 727 /*
725 * This must run unlocked due to tty processing 728 * This must run unlocked due to tty processing
726 * and mutex locking 729 * and mutex locking
@@ -731,7 +734,7 @@ static void ipw_receive_data_work(struct work_struct *work_rx)
731 (unsigned char *)packet 734 (unsigned char *)packet
732 + sizeof(struct ipw_rx_packet), 735 + sizeof(struct ipw_rx_packet),
733 packet->length); 736 packet->length);
734 spin_lock_irqsave(&hw->spinlock, flags); 737 spin_lock_irqsave(&hw->lock, flags);
735 } 738 }
736 /* Count queued DATA bytes only */ 739 /* Count queued DATA bytes only */
737 hw->rx_bytes_queued -= packet->length; 740 hw->rx_bytes_queued -= packet->length;
@@ -755,15 +758,15 @@ static void ipw_receive_data_work(struct work_struct *work_rx)
755 if (hw->shutting_down) 758 if (hw->shutting_down)
756 break; 759 break;
757 } 760 }
758 spin_unlock_irqrestore(&hw->spinlock, flags); 761 spin_unlock_irqrestore(&hw->lock, flags);
759} 762}
760 763
761static void handle_received_CTRL_packet(struct ipw_hardware *hw, 764static void handle_received_CTRL_packet(struct ipw_hardware *hw,
762 unsigned int channel_idx, 765 unsigned int channel_idx,
763 unsigned char *data, int len) 766 const unsigned char *data, int len)
764{ 767{
765 struct ipw_control_packet_body *body = 768 const struct ipw_control_packet_body *body =
766 (struct ipw_control_packet_body *) data; 769 (const struct ipw_control_packet_body *) data;
767 unsigned int changed_mask; 770 unsigned int changed_mask;
768 771
769 if (len != sizeof(struct ipw_control_packet_body)) { 772 if (len != sizeof(struct ipw_control_packet_body)) {
@@ -805,13 +808,13 @@ static void handle_received_CTRL_packet(struct ipw_hardware *hw,
805} 808}
806 809
807static void handle_received_packet(struct ipw_hardware *hw, 810static void handle_received_packet(struct ipw_hardware *hw,
808 union nl_packet *packet, 811 const union nl_packet *packet,
809 unsigned short len) 812 unsigned short len)
810{ 813{
811 unsigned int protocol = packet->hdr.protocol; 814 unsigned int protocol = packet->hdr.protocol;
812 unsigned int address = packet->hdr.address; 815 unsigned int address = packet->hdr.address;
813 unsigned int header_length; 816 unsigned int header_length;
814 unsigned char *data; 817 const unsigned char *data;
815 unsigned int data_len; 818 unsigned int data_len;
816 int is_last = packet->hdr.packet_rank & NL_LAST_PACKET; 819 int is_last = packet->hdr.packet_rank & NL_LAST_PACKET;
817 820
@@ -850,7 +853,7 @@ static void acknowledge_data_read(struct ipw_hardware *hw)
850static void do_receive_packet(struct ipw_hardware *hw) 853static void do_receive_packet(struct ipw_hardware *hw)
851{ 854{
852 unsigned len; 855 unsigned len;
853 unsigned int i; 856 unsigned i;
854 unsigned char pkt[LL_MTU_MAX]; 857 unsigned char pkt[LL_MTU_MAX];
855 858
856 start_timing(); 859 start_timing();
@@ -859,8 +862,7 @@ static void do_receive_packet(struct ipw_hardware *hw)
859 len = inw(hw->base_port + IODRR); 862 len = inw(hw->base_port + IODRR);
860 if (len > hw->ll_mtu) { 863 if (len > hw->ll_mtu) {
861 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 864 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
862 ": received a packet of %u bytes - " 865 ": received a packet of %u bytes - longer than the MTU!\n", len);
863 "longer than the MTU!\n", len);
864 outw(DCR_RXDONE | DCR_RXRESET, hw->base_port + IODCR); 866 outw(DCR_RXDONE | DCR_RXRESET, hw->base_port + IODCR);
865 return; 867 return;
866 } 868 }
@@ -873,18 +875,17 @@ static void do_receive_packet(struct ipw_hardware *hw)
873 pkt[i + 1] = (unsigned char) (data >> 8); 875 pkt[i + 1] = (unsigned char) (data >> 8);
874 } 876 }
875 } else { 877 } else {
876 len = inw(hw->base_port + IODMADPR); 878 len = inw(hw->base_port);
877 if (len > hw->ll_mtu) { 879 if (len > hw->ll_mtu) {
878 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 880 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
879 ": received a packet of %u bytes - " 881 ": received a packet of %u bytes - longer than the MTU!\n", len);
880 "longer than the MTU!\n", len);
881 writew(MEMRX_PCINTACKK, 882 writew(MEMRX_PCINTACKK,
882 &hw->memory_info_regs->memreg_pc_interrupt_ack); 883 &hw->memory_info_regs->memreg_pc_interrupt_ack);
883 return; 884 return;
884 } 885 }
885 886
886 for (i = 0; i < len; i += 2) { 887 for (i = 0; i < len; i += 2) {
887 __le16 raw_data = inw(hw->base_port + IODMADPR); 888 __le16 raw_data = inw(hw->base_port);
888 unsigned short data = le16_to_cpu(raw_data); 889 unsigned short data = le16_to_cpu(raw_data);
889 890
890 pkt[i] = (unsigned char) data; 891 pkt[i] = (unsigned char) data;
@@ -892,13 +893,15 @@ static void do_receive_packet(struct ipw_hardware *hw)
892 } 893 }
893 894
894 while ((i & 3) != 2) { 895 while ((i & 3) != 2) {
895 inw(hw->base_port + IODMADPR); 896 inw(hw->base_port);
896 i += 2; 897 i += 2;
897 } 898 }
898 } 899 }
899 900
900 acknowledge_data_read(hw); 901 acknowledge_data_read(hw);
901 902
903 swap_packet_bitfield_from_le(pkt);
904
902 if (ipwireless_debug) 905 if (ipwireless_debug)
903 dump_data_bytes("recv", pkt, len); 906 dump_data_bytes("recv", pkt, len);
904 907
@@ -916,8 +919,7 @@ static int get_current_packet_priority(struct ipw_hardware *hw)
916 * until setup is complete. 919 * until setup is complete.
917 */ 920 */
918 return (hw->to_setup || hw->initializing 921 return (hw->to_setup || hw->initializing
919 ? PRIO_SETUP + 1 : 922 ? PRIO_SETUP + 1 : NL_NUM_OF_PRIORITIES);
920 NL_NUM_OF_PRIORITIES);
921} 923}
922 924
923/* 925/*
@@ -928,17 +930,17 @@ static int get_packets_from_hw(struct ipw_hardware *hw)
928 int received = 0; 930 int received = 0;
929 unsigned long flags; 931 unsigned long flags;
930 932
931 spin_lock_irqsave(&hw->spinlock, flags); 933 spin_lock_irqsave(&hw->lock, flags);
932 while (hw->rx_ready && !hw->blocking_rx) { 934 while (hw->rx_ready && !hw->blocking_rx) {
933 received = 1; 935 received = 1;
934 hw->rx_ready--; 936 hw->rx_ready--;
935 spin_unlock_irqrestore(&hw->spinlock, flags); 937 spin_unlock_irqrestore(&hw->lock, flags);
936 938
937 do_receive_packet(hw); 939 do_receive_packet(hw);
938 940
939 spin_lock_irqsave(&hw->spinlock, flags); 941 spin_lock_irqsave(&hw->lock, flags);
940 } 942 }
941 spin_unlock_irqrestore(&hw->spinlock, flags); 943 spin_unlock_irqrestore(&hw->lock, flags);
942 944
943 return received; 945 return received;
944} 946}
@@ -954,7 +956,7 @@ static int send_pending_packet(struct ipw_hardware *hw, int priority_limit)
954 int more_to_send = 0; 956 int more_to_send = 0;
955 unsigned long flags; 957 unsigned long flags;
956 958
957 spin_lock_irqsave(&hw->spinlock, flags); 959 spin_lock_irqsave(&hw->lock, flags);
958 if (hw->tx_queued && hw->tx_ready) { 960 if (hw->tx_queued && hw->tx_ready) {
959 int priority; 961 int priority;
960 struct ipw_tx_packet *packet = NULL; 962 struct ipw_tx_packet *packet = NULL;
@@ -975,17 +977,17 @@ static int send_pending_packet(struct ipw_hardware *hw, int priority_limit)
975 } 977 }
976 if (!packet) { 978 if (!packet) {
977 hw->tx_queued = 0; 979 hw->tx_queued = 0;
978 spin_unlock_irqrestore(&hw->spinlock, flags); 980 spin_unlock_irqrestore(&hw->lock, flags);
979 return 0; 981 return 0;
980 } 982 }
981 983
982 spin_unlock_irqrestore(&hw->spinlock, flags); 984 spin_unlock_irqrestore(&hw->lock, flags);
983 985
984 /* Send */ 986 /* Send */
985 do_send_packet(hw, packet); 987 do_send_packet(hw, packet);
986 988
987 /* Check if more to send */ 989 /* Check if more to send */
988 spin_lock_irqsave(&hw->spinlock, flags); 990 spin_lock_irqsave(&hw->lock, flags);
989 for (priority = 0; priority < priority_limit; priority++) 991 for (priority = 0; priority < priority_limit; priority++)
990 if (!list_empty(&hw->tx_queue[priority])) { 992 if (!list_empty(&hw->tx_queue[priority])) {
991 more_to_send = 1; 993 more_to_send = 1;
@@ -995,7 +997,7 @@ static int send_pending_packet(struct ipw_hardware *hw, int priority_limit)
995 if (!more_to_send) 997 if (!more_to_send)
996 hw->tx_queued = 0; 998 hw->tx_queued = 0;
997 } 999 }
998 spin_unlock_irqrestore(&hw->spinlock, flags); 1000 spin_unlock_irqrestore(&hw->lock, flags);
999 1001
1000 return more_to_send; 1002 return more_to_send;
1001} 1003}
@@ -1008,9 +1010,9 @@ static void ipwireless_do_tasklet(unsigned long hw_)
1008 struct ipw_hardware *hw = (struct ipw_hardware *) hw_; 1010 struct ipw_hardware *hw = (struct ipw_hardware *) hw_;
1009 unsigned long flags; 1011 unsigned long flags;
1010 1012
1011 spin_lock_irqsave(&hw->spinlock, flags); 1013 spin_lock_irqsave(&hw->lock, flags);
1012 if (hw->shutting_down) { 1014 if (hw->shutting_down) {
1013 spin_unlock_irqrestore(&hw->spinlock, flags); 1015 spin_unlock_irqrestore(&hw->lock, flags);
1014 return; 1016 return;
1015 } 1017 }
1016 1018
@@ -1019,7 +1021,7 @@ static void ipwireless_do_tasklet(unsigned long hw_)
1019 * Initial setup data sent to hardware 1021 * Initial setup data sent to hardware
1020 */ 1022 */
1021 hw->to_setup = 2; 1023 hw->to_setup = 2;
1022 spin_unlock_irqrestore(&hw->spinlock, flags); 1024 spin_unlock_irqrestore(&hw->lock, flags);
1023 1025
1024 ipw_setup_hardware(hw); 1026 ipw_setup_hardware(hw);
1025 ipw_send_setup_packet(hw); 1027 ipw_send_setup_packet(hw);
@@ -1030,7 +1032,7 @@ static void ipwireless_do_tasklet(unsigned long hw_)
1030 int priority_limit = get_current_packet_priority(hw); 1032 int priority_limit = get_current_packet_priority(hw);
1031 int again; 1033 int again;
1032 1034
1033 spin_unlock_irqrestore(&hw->spinlock, flags); 1035 spin_unlock_irqrestore(&hw->lock, flags);
1034 1036
1035 do { 1037 do {
1036 again = send_pending_packet(hw, priority_limit); 1038 again = send_pending_packet(hw, priority_limit);
@@ -1068,16 +1070,16 @@ static irqreturn_t ipwireless_handle_v1_interrupt(int irq,
1068 /* Transmit complete. */ 1070 /* Transmit complete. */
1069 if (irqn & IR_TXINTR) { 1071 if (irqn & IR_TXINTR) {
1070 ack |= IR_TXINTR; 1072 ack |= IR_TXINTR;
1071 spin_lock_irqsave(&hw->spinlock, flags); 1073 spin_lock_irqsave(&hw->lock, flags);
1072 hw->tx_ready = 1; 1074 hw->tx_ready = 1;
1073 spin_unlock_irqrestore(&hw->spinlock, flags); 1075 spin_unlock_irqrestore(&hw->lock, flags);
1074 } 1076 }
1075 /* Received data */ 1077 /* Received data */
1076 if (irqn & IR_RXINTR) { 1078 if (irqn & IR_RXINTR) {
1077 ack |= IR_RXINTR; 1079 ack |= IR_RXINTR;
1078 spin_lock_irqsave(&hw->spinlock, flags); 1080 spin_lock_irqsave(&hw->lock, flags);
1079 hw->rx_ready++; 1081 hw->rx_ready++;
1080 spin_unlock_irqrestore(&hw->spinlock, flags); 1082 spin_unlock_irqrestore(&hw->lock, flags);
1081 } 1083 }
1082 if (ack != 0) { 1084 if (ack != 0) {
1083 outw(ack, hw->base_port + IOIR); 1085 outw(ack, hw->base_port + IOIR);
@@ -1128,9 +1130,8 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1128 } else { 1130 } else {
1129 return IRQ_NONE; 1131 return IRQ_NONE;
1130 } 1132 }
1131 } else { 1133 } else
1132 return IRQ_NONE; 1134 return IRQ_NONE;
1133 }
1134 } 1135 }
1135 1136
1136 /* 1137 /*
@@ -1149,9 +1150,9 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1149 if (hw->serial_number_detected) { 1150 if (hw->serial_number_detected) {
1150 if (memtx_serial != hw->last_memtx_serial) { 1151 if (memtx_serial != hw->last_memtx_serial) {
1151 hw->last_memtx_serial = memtx_serial; 1152 hw->last_memtx_serial = memtx_serial;
1152 spin_lock_irqsave(&hw->spinlock, flags); 1153 spin_lock_irqsave(&hw->lock, flags);
1153 hw->rx_ready++; 1154 hw->rx_ready++;
1154 spin_unlock_irqrestore(&hw->spinlock, flags); 1155 spin_unlock_irqrestore(&hw->lock, flags);
1155 rx = 1; 1156 rx = 1;
1156 } else 1157 } else
1157 /* Ignore 'Timer Recovery' duplicates. */ 1158 /* Ignore 'Timer Recovery' duplicates. */
@@ -1166,18 +1167,18 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1166 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME 1167 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
1167 ": memreg_tx serial num detected\n"); 1168 ": memreg_tx serial num detected\n");
1168 1169
1169 spin_lock_irqsave(&hw->spinlock, flags); 1170 spin_lock_irqsave(&hw->lock, flags);
1170 hw->rx_ready++; 1171 hw->rx_ready++;
1171 spin_unlock_irqrestore(&hw->spinlock, flags); 1172 spin_unlock_irqrestore(&hw->lock, flags);
1172 } 1173 }
1173 rx = 1; 1174 rx = 1;
1174 } 1175 }
1175 } 1176 }
1176 if (memrxdone & MEMRX_RX_DONE) { 1177 if (memrxdone & MEMRX_RX_DONE) {
1177 writew(0, &hw->memory_info_regs->memreg_rx_done); 1178 writew(0, &hw->memory_info_regs->memreg_rx_done);
1178 spin_lock_irqsave(&hw->spinlock, flags); 1179 spin_lock_irqsave(&hw->lock, flags);
1179 hw->tx_ready = 1; 1180 hw->tx_ready = 1;
1180 spin_unlock_irqrestore(&hw->spinlock, flags); 1181 spin_unlock_irqrestore(&hw->lock, flags);
1181 tx = 1; 1182 tx = 1;
1182 } 1183 }
1183 if (tx) 1184 if (tx)
@@ -1195,8 +1196,7 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1195 ": spurious interrupt - new_tx mode\n"); 1196 ": spurious interrupt - new_tx mode\n");
1196 else { 1197 else {
1197 printk(KERN_WARNING IPWIRELESS_PCCARD_NAME 1198 printk(KERN_WARNING IPWIRELESS_PCCARD_NAME
1198 ": no valid memreg_tx value - " 1199 ": no valid memreg_tx value - switching to the old memreg_tx\n");
1199 "switching to the old memreg_tx\n");
1200 hw->memreg_tx = 1200 hw->memreg_tx =
1201 &hw->memory_info_regs->memreg_tx_old; 1201 &hw->memory_info_regs->memreg_tx_old;
1202 try_mem_tx_old = 1; 1202 try_mem_tx_old = 1;
@@ -1211,7 +1211,7 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1211 return IRQ_HANDLED; 1211 return IRQ_HANDLED;
1212} 1212}
1213 1213
1214irqreturn_t ipwireless_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1214irqreturn_t ipwireless_interrupt(int irq, void *dev_id)
1215{ 1215{
1216 struct ipw_hardware *hw = dev_id; 1216 struct ipw_hardware *hw = dev_id;
1217 1217
@@ -1226,9 +1226,9 @@ static void flush_packets_to_hw(struct ipw_hardware *hw)
1226 int priority_limit; 1226 int priority_limit;
1227 unsigned long flags; 1227 unsigned long flags;
1228 1228
1229 spin_lock_irqsave(&hw->spinlock, flags); 1229 spin_lock_irqsave(&hw->lock, flags);
1230 priority_limit = get_current_packet_priority(hw); 1230 priority_limit = get_current_packet_priority(hw);
1231 spin_unlock_irqrestore(&hw->spinlock, flags); 1231 spin_unlock_irqrestore(&hw->lock, flags);
1232 1232
1233 while (send_pending_packet(hw, priority_limit)); 1233 while (send_pending_packet(hw, priority_limit));
1234} 1234}
@@ -1238,10 +1238,10 @@ static void send_packet(struct ipw_hardware *hw, int priority,
1238{ 1238{
1239 unsigned long flags; 1239 unsigned long flags;
1240 1240
1241 spin_lock_irqsave(&hw->spinlock, flags); 1241 spin_lock_irqsave(&hw->lock, flags);
1242 list_add_tail(&packet->queue, &hw->tx_queue[priority]); 1242 list_add_tail(&packet->queue, &hw->tx_queue[priority]);
1243 hw->tx_queued++; 1243 hw->tx_queued++;
1244 spin_unlock_irqrestore(&hw->spinlock, flags); 1244 spin_unlock_irqrestore(&hw->lock, flags);
1245 1245
1246 flush_packets_to_hw(hw); 1246 flush_packets_to_hw(hw);
1247} 1247}
@@ -1291,21 +1291,20 @@ static void *alloc_ctrl_packet(int header_size,
1291} 1291}
1292 1292
1293int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx, 1293int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx,
1294 unsigned char *data, unsigned int length, 1294 const unsigned char *data, unsigned int length,
1295 void (*callback) (void *cb, unsigned int length), 1295 void (*callback) (void *cb, unsigned int length),
1296 void *callback_data) 1296 void *callback_data)
1297{ 1297{
1298 struct ipw_tx_packet *packet; 1298 struct ipw_tx_packet *packet;
1299 1299
1300 packet = alloc_data_packet(length, 1300 packet = alloc_data_packet(length, (channel_idx + 1),
1301 (unsigned char) (channel_idx + 1), 1301 TL_PROTOCOLID_COM_DATA);
1302 TL_PROTOCOLID_COM_DATA);
1303 if (!packet) 1302 if (!packet)
1304 return -ENOMEM; 1303 return -ENOMEM;
1305 packet->packet_callback = callback; 1304 packet->packet_callback = callback;
1306 packet->callback_data = callback_data; 1305 packet->callback_data = callback_data;
1307 memcpy((unsigned char *) packet + 1306 memcpy((unsigned char *) packet + sizeof(struct ipw_tx_packet), data,
1308 sizeof(struct ipw_tx_packet), data, length); 1307 length);
1309 1308
1310 send_packet(hw, PRIO_DATA, packet); 1309 send_packet(hw, PRIO_DATA, packet);
1311 return 0; 1310 return 0;
@@ -1321,12 +1320,11 @@ static int set_control_line(struct ipw_hardware *hw, int prio,
1321 protocolid = TL_PROTOCOLID_SETUP; 1320 protocolid = TL_PROTOCOLID_SETUP;
1322 1321
1323 packet = alloc_ctrl_packet(sizeof(struct ipw_control_packet), 1322 packet = alloc_ctrl_packet(sizeof(struct ipw_control_packet),
1324 (unsigned char) (channel_idx + 1), 1323 (channel_idx + 1), protocolid, line);
1325 protocolid, line);
1326 if (!packet) 1324 if (!packet)
1327 return -ENOMEM; 1325 return -ENOMEM;
1328 packet->header.length = sizeof(struct ipw_control_packet_body); 1326 packet->header.length = sizeof(struct ipw_control_packet_body);
1329 packet->body.value = (unsigned char) (state == 0 ? 0 : 1); 1327 packet->body.value = (state == 0 ? 0 : 1);
1330 send_packet(hw, prio, &packet->header); 1328 send_packet(hw, prio, &packet->header);
1331 return 0; 1329 return 0;
1332} 1330}
@@ -1504,8 +1502,7 @@ static void handle_setup_get_version_rsp(struct ipw_hardware *hw,
1504 if (vers_no == TL_SETUP_VERSION) 1502 if (vers_no == TL_SETUP_VERSION)
1505 __handle_setup_get_version_rsp(hw); 1503 __handle_setup_get_version_rsp(hw);
1506 else 1504 else
1507 printk(KERN_ERR 1505 printk(KERN_ERR IPWIRELESS_PCCARD_NAME
1508 IPWIRELESS_PCCARD_NAME
1509 ": invalid hardware version no %u\n", 1506 ": invalid hardware version no %u\n",
1510 (unsigned int) vers_no); 1507 (unsigned int) vers_no);
1511} 1508}
@@ -1528,10 +1525,10 @@ static void ipw_send_setup_packet(struct ipw_hardware *hw)
1528 1525
1529static void handle_received_SETUP_packet(struct ipw_hardware *hw, 1526static void handle_received_SETUP_packet(struct ipw_hardware *hw,
1530 unsigned int address, 1527 unsigned int address,
1531 unsigned char *data, int len, 1528 const unsigned char *data, int len,
1532 int is_last) 1529 int is_last)
1533{ 1530{
1534 union ipw_setup_rx_msg *rx_msg = (union ipw_setup_rx_msg *) data; 1531 const union ipw_setup_rx_msg *rx_msg = (const union ipw_setup_rx_msg *) data;
1535 1532
1536 if (address != ADDR_SETUP_PROT) { 1533 if (address != ADDR_SETUP_PROT) {
1537 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 1534 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
@@ -1629,7 +1626,7 @@ struct ipw_hardware *ipwireless_hardware_create(void)
1629 1626
1630 INIT_LIST_HEAD(&hw->rx_queue); 1627 INIT_LIST_HEAD(&hw->rx_queue);
1631 INIT_LIST_HEAD(&hw->rx_pool); 1628 INIT_LIST_HEAD(&hw->rx_pool);
1632 spin_lock_init(&hw->spinlock); 1629 spin_lock_init(&hw->lock);
1633 tasklet_init(&hw->tasklet, ipwireless_do_tasklet, (unsigned long) hw); 1630 tasklet_init(&hw->tasklet, ipwireless_do_tasklet, (unsigned long) hw);
1634 INIT_WORK(&hw->work_rx, ipw_receive_data_work); 1631 INIT_WORK(&hw->work_rx, ipw_receive_data_work);
1635 setup_timer(&hw->setup_timer, ipwireless_setup_timer, 1632 setup_timer(&hw->setup_timer, ipwireless_setup_timer,
@@ -1651,8 +1648,8 @@ void ipwireless_init_hardware_v1(struct ipw_hardware *hw,
1651 enable_irq(hw->irq); 1648 enable_irq(hw->irq);
1652 } 1649 }
1653 hw->base_port = base_port; 1650 hw->base_port = base_port;
1654 hw->hw_version = is_v2_card ? HW_VERSION_2 : HW_VERSION_1; 1651 hw->hw_version = (is_v2_card ? HW_VERSION_2 : HW_VERSION_1);
1655 hw->ll_mtu = hw->hw_version == HW_VERSION_1 ? LL_MTU_V1 : LL_MTU_V2; 1652 hw->ll_mtu = (hw->hw_version == HW_VERSION_1 ? LL_MTU_V1 : LL_MTU_V2);
1656 hw->memregs_CCR = (struct MEMCCR __iomem *) 1653 hw->memregs_CCR = (struct MEMCCR __iomem *)
1657 ((unsigned short __iomem *) attr_memory + 0x200); 1654 ((unsigned short __iomem *) attr_memory + 0x200);
1658 hw->memory_info_regs = (struct MEMINFREG __iomem *) common_memory; 1655 hw->memory_info_regs = (struct MEMINFREG __iomem *) common_memory;
@@ -1695,10 +1692,10 @@ static void ipwireless_setup_timer(unsigned long data)
1695 if (is_card_present(hw)) { 1692 if (is_card_present(hw)) {
1696 unsigned long flags; 1693 unsigned long flags;
1697 1694
1698 spin_lock_irqsave(&hw->spinlock, flags); 1695 spin_lock_irqsave(&hw->lock, flags);
1699 hw->to_setup = 1; 1696 hw->to_setup = 1;
1700 hw->tx_ready = 1; 1697 hw->tx_ready = 1;
1701 spin_unlock_irqrestore(&hw->spinlock, flags); 1698 spin_unlock_irqrestore(&hw->lock, flags);
1702 tasklet_schedule(&hw->tasklet); 1699 tasklet_schedule(&hw->tasklet);
1703 } 1700 }
1704 1701
diff --git a/drivers/char/pcmcia/ipwireless/hardware.h b/drivers/char/pcmcia/ipwireless/hardware.h
index 19ce5eb266b1..90a8590e43b0 100644
--- a/drivers/char/pcmcia/ipwireless/hardware.h
+++ b/drivers/char/pcmcia/ipwireless/hardware.h
@@ -34,14 +34,14 @@ struct ipw_network;
34 34
35struct ipw_hardware *ipwireless_hardware_create(void); 35struct ipw_hardware *ipwireless_hardware_create(void);
36void ipwireless_hardware_free(struct ipw_hardware *hw); 36void ipwireless_hardware_free(struct ipw_hardware *hw);
37irqreturn_t ipwireless_interrupt(int irq, void *dev_id, struct pt_regs *regs); 37irqreturn_t ipwireless_interrupt(int irq, void *dev_id);
38int ipwireless_set_DTR(struct ipw_hardware *hw, unsigned int channel_idx, 38int ipwireless_set_DTR(struct ipw_hardware *hw, unsigned int channel_idx,
39 int state); 39 int state);
40int ipwireless_set_RTS(struct ipw_hardware *hw, unsigned int channel_idx, 40int ipwireless_set_RTS(struct ipw_hardware *hw, unsigned int channel_idx,
41 int state); 41 int state);
42int ipwireless_send_packet(struct ipw_hardware *hw, 42int ipwireless_send_packet(struct ipw_hardware *hw,
43 unsigned int channel_idx, 43 unsigned int channel_idx,
44 unsigned char *data, 44 const unsigned char *data,
45 unsigned int length, 45 unsigned int length,
46 void (*packet_sent_callback) (void *cb, 46 void (*packet_sent_callback) (void *cb,
47 unsigned int length), 47 unsigned int length),
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c
index cc7dcea2d283..5eca7a99afe6 100644
--- a/drivers/char/pcmcia/ipwireless/main.c
+++ b/drivers/char/pcmcia/ipwireless/main.c
@@ -49,7 +49,7 @@ static void ipwireless_detach(struct pcmcia_device *link);
49/* Debug mode: more verbose, print sent/recv bytes */ 49/* Debug mode: more verbose, print sent/recv bytes */
50int ipwireless_debug; 50int ipwireless_debug;
51int ipwireless_loopback; 51int ipwireless_loopback;
52int ipwireless_out_queue = 1; 52int ipwireless_out_queue = 10;
53 53
54module_param_named(debug, ipwireless_debug, int, 0); 54module_param_named(debug, ipwireless_debug, int, 0);
55module_param_named(loopback, ipwireless_loopback, int, 0); 55module_param_named(loopback, ipwireless_loopback, int, 0);
@@ -57,7 +57,7 @@ module_param_named(out_queue, ipwireless_out_queue, int, 0);
57MODULE_PARM_DESC(debug, "switch on debug messages [0]"); 57MODULE_PARM_DESC(debug, "switch on debug messages [0]");
58MODULE_PARM_DESC(loopback, 58MODULE_PARM_DESC(loopback,
59 "debug: enable ras_raw channel [0]"); 59 "debug: enable ras_raw channel [0]");
60MODULE_PARM_DESC(out_queue, "debug: set size of outgoing queue [1]"); 60MODULE_PARM_DESC(out_queue, "debug: set size of outgoing PPP queue [10]");
61 61
62/* Executes in process context. */ 62/* Executes in process context. */
63static void signalled_reboot_work(struct work_struct *work_reboot) 63static void signalled_reboot_work(struct work_struct *work_reboot)
@@ -88,8 +88,6 @@ static int config_ipwireless(struct ipw_dev *ipw)
88 unsigned short buf[64]; 88 unsigned short buf[64];
89 cisparse_t parse; 89 cisparse_t parse;
90 unsigned short cor_value; 90 unsigned short cor_value;
91 win_req_t request_attr_memory;
92 win_req_t request_common_memory;
93 memreq_t memreq_attr_memory; 91 memreq_t memreq_attr_memory;
94 memreq_t memreq_common_memory; 92 memreq_t memreq_common_memory;
95 93
@@ -188,6 +186,9 @@ static int config_ipwireless(struct ipw_dev *ipw)
188 goto exit0; 186 goto exit0;
189 } 187 }
190 188
189 request_region(link->io.BasePort1, link->io.NumPorts1,
190 IPWIRELESS_PCCARD_NAME);
191
191 /* memory settings */ 192 /* memory settings */
192 193
193 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 194 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
@@ -214,16 +215,16 @@ static int config_ipwireless(struct ipw_dev *ipw)
214 } 215 }
215 216
216 if (parse.cftable_entry.mem.nwin > 0) { 217 if (parse.cftable_entry.mem.nwin > 0) {
217 request_common_memory.Attributes = 218 ipw->request_common_memory.Attributes =
218 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; 219 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE;
219 request_common_memory.Base = 220 ipw->request_common_memory.Base =
220 parse.cftable_entry.mem.win[0].host_addr; 221 parse.cftable_entry.mem.win[0].host_addr;
221 request_common_memory.Size = parse.cftable_entry.mem.win[0].len; 222 ipw->request_common_memory.Size = parse.cftable_entry.mem.win[0].len;
222 if (request_common_memory.Size < 0x1000) 223 if (ipw->request_common_memory.Size < 0x1000)
223 request_common_memory.Size = 0x1000; 224 ipw->request_common_memory.Size = 0x1000;
224 request_common_memory.AccessSpeed = 0; 225 ipw->request_common_memory.AccessSpeed = 0;
225 226
226 ret = pcmcia_request_window(&link, &request_common_memory, 227 ret = pcmcia_request_window(&link, &ipw->request_common_memory,
227 &ipw->handle_common_memory); 228 &ipw->handle_common_memory);
228 229
229 if (ret != CS_SUCCESS) { 230 if (ret != CS_SUCCESS) {
@@ -246,16 +247,18 @@ static int config_ipwireless(struct ipw_dev *ipw)
246 ipw->is_v2_card = 247 ipw->is_v2_card =
247 parse.cftable_entry.mem.win[0].len == 0x100; 248 parse.cftable_entry.mem.win[0].len == 0x100;
248 249
249 ipw->common_memory = ioremap(request_common_memory.Base, 250 ipw->common_memory = ioremap(ipw->request_common_memory.Base,
250 request_common_memory.Size); 251 ipw->request_common_memory.Size);
252 request_mem_region(ipw->request_common_memory.Base,
253 ipw->request_common_memory.Size, IPWIRELESS_PCCARD_NAME);
251 254
252 request_attr_memory.Attributes = 255 ipw->request_attr_memory.Attributes =
253 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | WIN_ENABLE; 256 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | WIN_ENABLE;
254 request_attr_memory.Base = 0; 257 ipw->request_attr_memory.Base = 0;
255 request_attr_memory.Size = 0; /* this used to be 0x1000 */ 258 ipw->request_attr_memory.Size = 0; /* this used to be 0x1000 */
256 request_attr_memory.AccessSpeed = 0; 259 ipw->request_attr_memory.AccessSpeed = 0;
257 260
258 ret = pcmcia_request_window(&link, &request_attr_memory, 261 ret = pcmcia_request_window(&link, &ipw->request_attr_memory,
259 &ipw->handle_attr_memory); 262 &ipw->handle_attr_memory);
260 263
261 if (ret != CS_SUCCESS) { 264 if (ret != CS_SUCCESS) {
@@ -274,8 +277,10 @@ static int config_ipwireless(struct ipw_dev *ipw)
274 goto exit2; 277 goto exit2;
275 } 278 }
276 279
277 ipw->attr_memory = ioremap(request_attr_memory.Base, 280 ipw->attr_memory = ioremap(ipw->request_attr_memory.Base,
278 request_attr_memory.Size); 281 ipw->request_attr_memory.Size);
282 request_mem_region(ipw->request_attr_memory.Base, ipw->request_attr_memory.Size,
283 IPWIRELESS_PCCARD_NAME);
279 } 284 }
280 285
281 INIT_WORK(&ipw->work_reboot, signalled_reboot_work); 286 INIT_WORK(&ipw->work_reboot, signalled_reboot_work);
@@ -311,14 +316,13 @@ static int config_ipwireless(struct ipw_dev *ipw)
311 (unsigned int) link->irq.AssignedIRQ); 316 (unsigned int) link->irq.AssignedIRQ);
312 if (ipw->attr_memory && ipw->common_memory) 317 if (ipw->attr_memory && ipw->common_memory)
313 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 318 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
314 ": attr memory 0x%08lx-0x%08lx, " 319 ": attr memory 0x%08lx-0x%08lx, common memory 0x%08lx-0x%08lx\n",
315 "common memory 0x%08lx-0x%08lx\n", 320 ipw->request_attr_memory.Base,
316 request_attr_memory.Base, 321 ipw->request_attr_memory.Base
317 request_attr_memory.Base 322 + ipw->request_attr_memory.Size - 1,
318 + request_attr_memory.Size - 1, 323 ipw->request_common_memory.Base,
319 request_common_memory.Base, 324 ipw->request_common_memory.Base
320 request_common_memory.Base 325 + ipw->request_common_memory.Size - 1);
321 + request_common_memory.Size - 1);
322 326
323 ipw->network = ipwireless_network_create(ipw->hardware); 327 ipw->network = ipwireless_network_create(ipw->hardware);
324 if (!ipw->network) 328 if (!ipw->network)
@@ -350,12 +354,16 @@ exit4:
350 pcmcia_disable_device(link); 354 pcmcia_disable_device(link);
351exit3: 355exit3:
352 if (ipw->attr_memory) { 356 if (ipw->attr_memory) {
357 release_mem_region(ipw->request_attr_memory.Base,
358 ipw->request_attr_memory.Size);
353 iounmap(ipw->attr_memory); 359 iounmap(ipw->attr_memory);
354 pcmcia_release_window(ipw->handle_attr_memory); 360 pcmcia_release_window(ipw->handle_attr_memory);
355 pcmcia_disable_device(link); 361 pcmcia_disable_device(link);
356 } 362 }
357exit2: 363exit2:
358 if (ipw->common_memory) { 364 if (ipw->common_memory) {
365 release_mem_region(ipw->request_common_memory.Base,
366 ipw->request_common_memory.Size);
359 iounmap(ipw->common_memory); 367 iounmap(ipw->common_memory);
360 pcmcia_release_window(ipw->handle_common_memory); 368 pcmcia_release_window(ipw->handle_common_memory);
361 } 369 }
@@ -367,19 +375,25 @@ exit0:
367 375
368static void release_ipwireless(struct ipw_dev *ipw) 376static void release_ipwireless(struct ipw_dev *ipw)
369{ 377{
370 struct pcmcia_device *link = ipw->link; 378 pcmcia_disable_device(ipw->link);
371
372 pcmcia_disable_device(link);
373 379
374 if (ipw->common_memory) 380 if (ipw->common_memory) {
381 release_mem_region(ipw->request_common_memory.Base,
382 ipw->request_common_memory.Size);
375 iounmap(ipw->common_memory); 383 iounmap(ipw->common_memory);
376 if (ipw->attr_memory) 384 }
385 if (ipw->attr_memory) {
386 release_mem_region(ipw->request_attr_memory.Base,
387 ipw->request_attr_memory.Size);
377 iounmap(ipw->attr_memory); 388 iounmap(ipw->attr_memory);
389 }
378 if (ipw->common_memory) 390 if (ipw->common_memory)
379 pcmcia_release_window(ipw->handle_common_memory); 391 pcmcia_release_window(ipw->handle_common_memory);
380 if (ipw->attr_memory) 392 if (ipw->attr_memory)
381 pcmcia_release_window(ipw->handle_attr_memory); 393 pcmcia_release_window(ipw->handle_attr_memory);
382 pcmcia_disable_device(link); 394
395 /* Break the link with Card Services */
396 pcmcia_disable_device(ipw->link);
383} 397}
384 398
385/* 399/*
@@ -437,10 +451,6 @@ static void ipwireless_detach(struct pcmcia_device *link)
437 451
438 release_ipwireless(ipw); 452 release_ipwireless(ipw);
439 453
440 /* Break the link with Card Services */
441 if (link)
442 pcmcia_disable_device(link);
443
444 if (ipw->tty != NULL) 454 if (ipw->tty != NULL)
445 ipwireless_tty_free(ipw->tty); 455 ipwireless_tty_free(ipw->tty);
446 if (ipw->network != NULL) 456 if (ipw->network != NULL)
diff --git a/drivers/char/pcmcia/ipwireless/main.h b/drivers/char/pcmcia/ipwireless/main.h
index 1bfdcc8d47d6..0e0363af9ab2 100644
--- a/drivers/char/pcmcia/ipwireless/main.h
+++ b/drivers/char/pcmcia/ipwireless/main.h
@@ -45,10 +45,15 @@ struct ipw_tty;
45struct ipw_dev { 45struct ipw_dev {
46 struct pcmcia_device *link; 46 struct pcmcia_device *link;
47 int is_v2_card; 47 int is_v2_card;
48
48 window_handle_t handle_attr_memory; 49 window_handle_t handle_attr_memory;
49 void __iomem *attr_memory; 50 void __iomem *attr_memory;
51 win_req_t request_attr_memory;
52
50 window_handle_t handle_common_memory; 53 window_handle_t handle_common_memory;
51 void __iomem *common_memory; 54 void __iomem *common_memory;
55 win_req_t request_common_memory;
56
52 dev_node_t nodes[2]; 57 dev_node_t nodes[2];
53 /* Reference to attribute memory, containing CIS data */ 58 /* Reference to attribute memory, containing CIS data */
54 void *attribute_memory; 59 void *attribute_memory;
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c
index fe914d34f7f6..590762a7f217 100644
--- a/drivers/char/pcmcia/ipwireless/network.c
+++ b/drivers/char/pcmcia/ipwireless/network.c
@@ -29,7 +29,6 @@
29#include "main.h" 29#include "main.h"
30#include "tty.h" 30#include "tty.h"
31 31
32#define MAX_OUTGOING_PACKETS_QUEUED ipwireless_out_queue
33#define MAX_ASSOCIATED_TTYS 2 32#define MAX_ASSOCIATED_TTYS 2
34 33
35#define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP) 34#define SC_RCV_BITS (SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP)
@@ -46,7 +45,7 @@ struct ipw_network {
46 /* Number of packets queued up in hardware module. */ 45 /* Number of packets queued up in hardware module. */
47 int outgoing_packets_queued; 46 int outgoing_packets_queued;
48 /* Spinlock to avoid interrupts during shutdown */ 47 /* Spinlock to avoid interrupts during shutdown */
49 spinlock_t spinlock; 48 spinlock_t lock;
50 struct mutex close_lock; 49 struct mutex close_lock;
51 50
52 /* PPP ioctl data, not actually used anywere */ 51 /* PPP ioctl data, not actually used anywere */
@@ -68,20 +67,20 @@ static void notify_packet_sent(void *callback_data, unsigned int packet_length)
68 struct ipw_network *network = callback_data; 67 struct ipw_network *network = callback_data;
69 unsigned long flags; 68 unsigned long flags;
70 69
71 spin_lock_irqsave(&network->spinlock, flags); 70 spin_lock_irqsave(&network->lock, flags);
72 network->outgoing_packets_queued--; 71 network->outgoing_packets_queued--;
73 if (network->ppp_channel != NULL) { 72 if (network->ppp_channel != NULL) {
74 if (network->ppp_blocked) { 73 if (network->ppp_blocked) {
75 network->ppp_blocked = 0; 74 network->ppp_blocked = 0;
76 spin_unlock_irqrestore(&network->spinlock, flags); 75 spin_unlock_irqrestore(&network->lock, flags);
77 ppp_output_wakeup(network->ppp_channel); 76 ppp_output_wakeup(network->ppp_channel);
78 if (ipwireless_debug) 77 if (ipwireless_debug)
79 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 78 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
80 ": ppp unblocked\n"); 79 ": ppp unblocked\n");
81 } else 80 } else
82 spin_unlock_irqrestore(&network->spinlock, flags); 81 spin_unlock_irqrestore(&network->lock, flags);
83 } else 82 } else
84 spin_unlock_irqrestore(&network->spinlock, flags); 83 spin_unlock_irqrestore(&network->lock, flags);
85} 84}
86 85
87/* 86/*
@@ -93,8 +92,8 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
93 struct ipw_network *network = ppp_channel->private; 92 struct ipw_network *network = ppp_channel->private;
94 unsigned long flags; 93 unsigned long flags;
95 94
96 spin_lock_irqsave(&network->spinlock, flags); 95 spin_lock_irqsave(&network->lock, flags);
97 if (network->outgoing_packets_queued < MAX_OUTGOING_PACKETS_QUEUED) { 96 if (network->outgoing_packets_queued < ipwireless_out_queue) {
98 unsigned char *buf; 97 unsigned char *buf;
99 static unsigned char header[] = { 98 static unsigned char header[] = {
100 PPP_ALLSTATIONS, /* 0xff */ 99 PPP_ALLSTATIONS, /* 0xff */
@@ -103,7 +102,7 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
103 int ret; 102 int ret;
104 103
105 network->outgoing_packets_queued++; 104 network->outgoing_packets_queued++;
106 spin_unlock_irqrestore(&network->spinlock, flags); 105 spin_unlock_irqrestore(&network->lock, flags);
107 106
108 /* 107 /*
109 * If we have the requested amount of headroom in the skb we 108 * If we have the requested amount of headroom in the skb we
@@ -144,7 +143,9 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel,
144 * needs to be unblocked once we are ready to send. 143 * needs to be unblocked once we are ready to send.
145 */ 144 */
146 network->ppp_blocked = 1; 145 network->ppp_blocked = 1;
147 spin_unlock_irqrestore(&network->spinlock, flags); 146 spin_unlock_irqrestore(&network->lock, flags);
147 if (ipwireless_debug)
148 printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME ": ppp blocked\n");
148 return 0; 149 return 0;
149 } 150 }
150} 151}
@@ -249,11 +250,11 @@ static void do_go_online(struct work_struct *work_go_online)
249 work_go_online); 250 work_go_online);
250 unsigned long flags; 251 unsigned long flags;
251 252
252 spin_lock_irqsave(&network->spinlock, flags); 253 spin_lock_irqsave(&network->lock, flags);
253 if (!network->ppp_channel) { 254 if (!network->ppp_channel) {
254 struct ppp_channel *channel; 255 struct ppp_channel *channel;
255 256
256 spin_unlock_irqrestore(&network->spinlock, flags); 257 spin_unlock_irqrestore(&network->lock, flags);
257 channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL); 258 channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL);
258 if (!channel) { 259 if (!channel) {
259 printk(KERN_ERR IPWIRELESS_PCCARD_NAME 260 printk(KERN_ERR IPWIRELESS_PCCARD_NAME
@@ -273,10 +274,10 @@ static void do_go_online(struct work_struct *work_go_online)
273 network->xaccm[3] = 0x60000000U; 274 network->xaccm[3] = 0x60000000U;
274 network->raccm = ~0U; 275 network->raccm = ~0U;
275 ppp_register_channel(channel); 276 ppp_register_channel(channel);
276 spin_lock_irqsave(&network->spinlock, flags); 277 spin_lock_irqsave(&network->lock, flags);
277 network->ppp_channel = channel; 278 network->ppp_channel = channel;
278 } 279 }
279 spin_unlock_irqrestore(&network->spinlock, flags); 280 spin_unlock_irqrestore(&network->lock, flags);
280} 281}
281 282
282static void do_go_offline(struct work_struct *work_go_offline) 283static void do_go_offline(struct work_struct *work_go_offline)
@@ -287,16 +288,16 @@ static void do_go_offline(struct work_struct *work_go_offline)
287 unsigned long flags; 288 unsigned long flags;
288 289
289 mutex_lock(&network->close_lock); 290 mutex_lock(&network->close_lock);
290 spin_lock_irqsave(&network->spinlock, flags); 291 spin_lock_irqsave(&network->lock, flags);
291 if (network->ppp_channel != NULL) { 292 if (network->ppp_channel != NULL) {
292 struct ppp_channel *channel = network->ppp_channel; 293 struct ppp_channel *channel = network->ppp_channel;
293 294
294 network->ppp_channel = NULL; 295 network->ppp_channel = NULL;
295 spin_unlock_irqrestore(&network->spinlock, flags); 296 spin_unlock_irqrestore(&network->lock, flags);
296 mutex_unlock(&network->close_lock); 297 mutex_unlock(&network->close_lock);
297 ppp_unregister_channel(channel); 298 ppp_unregister_channel(channel);
298 } else { 299 } else {
299 spin_unlock_irqrestore(&network->spinlock, flags); 300 spin_unlock_irqrestore(&network->lock, flags);
300 mutex_unlock(&network->close_lock); 301 mutex_unlock(&network->close_lock);
301 } 302 }
302} 303}
@@ -381,18 +382,18 @@ void ipwireless_network_packet_received(struct ipw_network *network,
381 * the PPP layer. 382 * the PPP layer.
382 */ 383 */
383 mutex_lock(&network->close_lock); 384 mutex_lock(&network->close_lock);
384 spin_lock_irqsave(&network->spinlock, flags); 385 spin_lock_irqsave(&network->lock, flags);
385 if (network->ppp_channel != NULL) { 386 if (network->ppp_channel != NULL) {
386 struct sk_buff *skb; 387 struct sk_buff *skb;
387 388
388 spin_unlock_irqrestore(&network->spinlock, 389 spin_unlock_irqrestore(&network->lock,
389 flags); 390 flags);
390 391
391 /* Send the data to the ppp_generic module. */ 392 /* Send the data to the ppp_generic module. */
392 skb = ipw_packet_received_skb(data, length); 393 skb = ipw_packet_received_skb(data, length);
393 ppp_input(network->ppp_channel, skb); 394 ppp_input(network->ppp_channel, skb);
394 } else 395 } else
395 spin_unlock_irqrestore(&network->spinlock, 396 spin_unlock_irqrestore(&network->lock,
396 flags); 397 flags);
397 mutex_unlock(&network->close_lock); 398 mutex_unlock(&network->close_lock);
398 } 399 }
@@ -410,7 +411,7 @@ struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw)
410 if (!network) 411 if (!network)
411 return NULL; 412 return NULL;
412 413
413 spin_lock_init(&network->spinlock); 414 spin_lock_init(&network->lock);
414 mutex_init(&network->close_lock); 415 mutex_init(&network->close_lock);
415 416
416 network->hardware = hw; 417 network->hardware = hw;
@@ -478,10 +479,10 @@ int ipwireless_ppp_channel_index(struct ipw_network *network)
478 int ret = -1; 479 int ret = -1;
479 unsigned long flags; 480 unsigned long flags;
480 481
481 spin_lock_irqsave(&network->spinlock, flags); 482 spin_lock_irqsave(&network->lock, flags);
482 if (network->ppp_channel != NULL) 483 if (network->ppp_channel != NULL)
483 ret = ppp_channel_index(network->ppp_channel); 484 ret = ppp_channel_index(network->ppp_channel);
484 spin_unlock_irqrestore(&network->spinlock, flags); 485 spin_unlock_irqrestore(&network->lock, flags);
485 486
486 return ret; 487 return ret;
487} 488}
@@ -491,10 +492,15 @@ int ipwireless_ppp_unit_number(struct ipw_network *network)
491 int ret = -1; 492 int ret = -1;
492 unsigned long flags; 493 unsigned long flags;
493 494
494 spin_lock_irqsave(&network->spinlock, flags); 495 spin_lock_irqsave(&network->lock, flags);
495 if (network->ppp_channel != NULL) 496 if (network->ppp_channel != NULL)
496 ret = ppp_unit_number(network->ppp_channel); 497 ret = ppp_unit_number(network->ppp_channel);
497 spin_unlock_irqrestore(&network->spinlock, flags); 498 spin_unlock_irqrestore(&network->lock, flags);
498 499
499 return ret; 500 return ret;
500} 501}
502
503int ipwireless_ppp_mru(const struct ipw_network *network)
504{
505 return network->mru;
506}
diff --git a/drivers/char/pcmcia/ipwireless/network.h b/drivers/char/pcmcia/ipwireless/network.h
index ccacd26fc7ef..561f765b3334 100644
--- a/drivers/char/pcmcia/ipwireless/network.h
+++ b/drivers/char/pcmcia/ipwireless/network.h
@@ -48,5 +48,6 @@ void ipwireless_ppp_open(struct ipw_network *net);
48void ipwireless_ppp_close(struct ipw_network *net); 48void ipwireless_ppp_close(struct ipw_network *net);
49int ipwireless_ppp_channel_index(struct ipw_network *net); 49int ipwireless_ppp_channel_index(struct ipw_network *net);
50int ipwireless_ppp_unit_number(struct ipw_network *net); 50int ipwireless_ppp_unit_number(struct ipw_network *net);
51int ipwireless_ppp_mru(const struct ipw_network *net);
51 52
52#endif 53#endif
diff --git a/drivers/char/pcmcia/ipwireless/tty.c b/drivers/char/pcmcia/ipwireless/tty.c
index 42f3815c5ce3..b1414507997c 100644
--- a/drivers/char/pcmcia/ipwireless/tty.c
+++ b/drivers/char/pcmcia/ipwireless/tty.c
@@ -259,7 +259,7 @@ static int ipw_write(struct tty_struct *linux_tty,
259 } 259 }
260 260
261 ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS, 261 ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS,
262 (unsigned char *) buf, count, 262 buf, count,
263 ipw_write_packet_sent_callback, tty); 263 ipw_write_packet_sent_callback, tty);
264 if (ret == -1) { 264 if (ret == -1) {
265 mutex_unlock(&tty->ipw_tty_mutex); 265 mutex_unlock(&tty->ipw_tty_mutex);
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index dbefbb30ed44..d9799e2bcfbf 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -144,6 +144,7 @@ static ssize_t rtc_read(struct file *file, char __user *buf,
144 size_t count, loff_t *ppos); 144 size_t count, loff_t *ppos);
145 145
146static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 146static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
147static void rtc_get_rtc_time(struct rtc_time *rtc_tm);
147 148
148#ifdef RTC_IRQ 149#ifdef RTC_IRQ
149static unsigned int rtc_poll(struct file *file, poll_table *wait); 150static unsigned int rtc_poll(struct file *file, poll_table *wait);
@@ -235,7 +236,7 @@ static inline unsigned char rtc_is_updating(void)
235 * (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.) 236 * (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
236 */ 237 */
237 238
238irqreturn_t rtc_interrupt(int irq, void *dev_id) 239static irqreturn_t rtc_interrupt(int irq, void *dev_id)
239{ 240{
240 /* 241 /*
241 * Can be an alarm interrupt, update complete interrupt, 242 * Can be an alarm interrupt, update complete interrupt,
@@ -1303,7 +1304,7 @@ static int rtc_proc_open(struct inode *inode, struct file *file)
1303} 1304}
1304#endif 1305#endif
1305 1306
1306void rtc_get_rtc_time(struct rtc_time *rtc_tm) 1307static void rtc_get_rtc_time(struct rtc_time *rtc_tm)
1307{ 1308{
1308 unsigned long uip_watchdog = jiffies, flags; 1309 unsigned long uip_watchdog = jiffies, flags;
1309 unsigned char ctrl; 1310 unsigned char ctrl;
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index 4ba3aec9e1cd..7b0c35207d9b 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -192,7 +192,7 @@ static inline void a2232_receive_char(struct a2232_port *port, int ch, int err)
192 Maybe one could implement a more efficient version by not only 192 Maybe one could implement a more efficient version by not only
193 transferring one character at a time. 193 transferring one character at a time.
194*/ 194*/
195 struct tty_struct *tty = port->gs.tty; 195 struct tty_struct *tty = port->gs.port.tty;
196 196
197#if 0 197#if 0
198 switch(err) { 198 switch(err) {
@@ -226,7 +226,7 @@ static void a2232_disable_tx_interrupts(void *ptr)
226 226
227 /* Does this here really have to be? */ 227 /* Does this here really have to be? */
228 local_irq_save(flags); 228 local_irq_save(flags);
229 port->gs.flags &= ~GS_TX_INTEN; 229 port->gs.port.flags &= ~GS_TX_INTEN;
230 local_irq_restore(flags); 230 local_irq_restore(flags);
231} 231}
232 232
@@ -242,7 +242,7 @@ static void a2232_enable_tx_interrupts(void *ptr)
242 242
243 /* Does this here really have to be? */ 243 /* Does this here really have to be? */
244 local_irq_save(flags); 244 local_irq_save(flags);
245 port->gs.flags |= GS_TX_INTEN; 245 port->gs.port.flags |= GS_TX_INTEN;
246 local_irq_restore(flags); 246 local_irq_restore(flags);
247} 247}
248 248
@@ -276,9 +276,9 @@ static void a2232_shutdown_port(void *ptr)
276 276
277 local_irq_save(flags); 277 local_irq_save(flags);
278 278
279 port->gs.flags &= ~GS_ACTIVE; 279 port->gs.port.flags &= ~GS_ACTIVE;
280 280
281 if (port->gs.tty && port->gs.tty->termios->c_cflag & HUPCL) { 281 if (port->gs.port.tty && port->gs.port.tty->termios->c_cflag & HUPCL) {
282 /* Set DTR and RTS to Low, flush output. 282 /* Set DTR and RTS to Low, flush output.
283 The NetBSD driver "msc.c" does it this way. */ 283 The NetBSD driver "msc.c" does it this way. */
284 stat->Command = ( (stat->Command & ~A2232CMD_CMask) | 284 stat->Command = ( (stat->Command & ~A2232CMD_CMask) |
@@ -309,7 +309,7 @@ static int a2232_set_real_termios(void *ptr)
309 volatile struct a2232status *status; 309 volatile struct a2232status *status;
310 volatile struct a2232memory *mem; 310 volatile struct a2232memory *mem;
311 311
312 if (!port->gs.tty || !port->gs.tty->termios) return 0; 312 if (!port->gs.port.tty || !port->gs.port.tty->termios) return 0;
313 313
314 status = a2232stat(port->which_a2232, port->which_port_on_a2232); 314 status = a2232stat(port->which_a2232, port->which_port_on_a2232);
315 mem = a2232mem(port->which_a2232); 315 mem = a2232mem(port->which_a2232);
@@ -345,7 +345,7 @@ static int a2232_set_real_termios(void *ptr)
345 } 345 }
346 a2232_param |= rate; 346 a2232_param |= rate;
347 347
348 cflag = port->gs.tty->termios->c_cflag; 348 cflag = port->gs.port.tty->termios->c_cflag;
349 349
350 // get character size 350 // get character size
351 chsize = cflag & CSIZE; 351 chsize = cflag & CSIZE;
@@ -382,7 +382,7 @@ static int a2232_set_real_termios(void *ptr)
382 the conventional way of inserting START/STOP characters 382 the conventional way of inserting START/STOP characters
383 by hand in throttle()/unthrottle(). 383 by hand in throttle()/unthrottle().
384 */ 384 */
385 softflow = !!( port->gs.tty->termios->c_iflag & IXOFF ); 385 softflow = !!( port->gs.port.tty->termios->c_iflag & IXOFF );
386 386
387 // get Parity (Enabled/Disabled? If Enabled, Odd or Even?) 387 // get Parity (Enabled/Disabled? If Enabled, Odd or Even?)
388 parity = cflag & (PARENB | PARODD); 388 parity = cflag & (PARENB | PARODD);
@@ -400,9 +400,9 @@ static int a2232_set_real_termios(void *ptr)
400 /* Hmm. Maybe an own a2232_port structure 400 /* Hmm. Maybe an own a2232_port structure
401 member would be cleaner? */ 401 member would be cleaner? */
402 if (cflag & CLOCAL) 402 if (cflag & CLOCAL)
403 port->gs.flags &= ~ASYNC_CHECK_CD; 403 port->gs.port.flags &= ~ASYNC_CHECK_CD;
404 else 404 else
405 port->gs.flags |= ASYNC_CHECK_CD; 405 port->gs.port.flags |= ASYNC_CHECK_CD;
406 406
407 407
408 /* Now we have all parameters and can go to set them: */ 408 /* Now we have all parameters and can go to set them: */
@@ -482,18 +482,18 @@ static int a2232_open(struct tty_struct * tty, struct file * filp)
482 port = &a2232_ports[line]; 482 port = &a2232_ports[line];
483 483
484 tty->driver_data = port; 484 tty->driver_data = port;
485 port->gs.tty = tty; 485 port->gs.port.tty = tty;
486 port->gs.count++; 486 port->gs.port.count++;
487 retval = gs_init_port(&port->gs); 487 retval = gs_init_port(&port->gs);
488 if (retval) { 488 if (retval) {
489 port->gs.count--; 489 port->gs.port.count--;
490 return retval; 490 return retval;
491 } 491 }
492 port->gs.flags |= GS_ACTIVE; 492 port->gs.port.flags |= GS_ACTIVE;
493 retval = gs_block_til_ready(port, filp); 493 retval = gs_block_til_ready(port, filp);
494 494
495 if (retval) { 495 if (retval) {
496 port->gs.count--; 496 port->gs.port.count--;
497 return retval; 497 return retval;
498 } 498 }
499 499
@@ -522,7 +522,7 @@ int ch, err, n, p;
522 for (p = 0; p < NUMLINES; p++){ /* for every port on this board */ 522 for (p = 0; p < NUMLINES; p++){ /* for every port on this board */
523 err = 0; 523 err = 0;
524 port = &a2232_ports[n*NUMLINES+p]; 524 port = &a2232_ports[n*NUMLINES+p];
525 if ( port->gs.flags & GS_ACTIVE ){ /* if the port is used */ 525 if ( port->gs.port.flags & GS_ACTIVE ){ /* if the port is used */
526 526
527 status = a2232stat(n,p); 527 status = a2232stat(n,p);
528 528
@@ -577,8 +577,8 @@ int ch, err, n, p;
577 obuf = mem->OutBuf[p]; 577 obuf = mem->OutBuf[p];
578 bufpos = status->OutHead; 578 bufpos = status->OutHead;
579 while ( (port->gs.xmit_cnt > 0) && 579 while ( (port->gs.xmit_cnt > 0) &&
580 (!port->gs.tty->stopped) && 580 (!port->gs.port.tty->stopped) &&
581 (!port->gs.tty->hw_stopped) ){ /* While there are chars to transmit */ 581 (!port->gs.port.tty->hw_stopped) ){ /* While there are chars to transmit */
582 if (((bufpos+1) & A2232_IOBUFLENMASK) != status->OutTail) { /* If the A2232 buffer is not full */ 582 if (((bufpos+1) & A2232_IOBUFLENMASK) != status->OutTail) { /* If the A2232 buffer is not full */
583 ch = port->gs.xmit_buf[port->gs.xmit_tail]; /* get the next char to transmit */ 583 ch = port->gs.xmit_buf[port->gs.xmit_tail]; /* get the next char to transmit */
584 port->gs.xmit_tail = (port->gs.xmit_tail+1) & (SERIAL_XMIT_SIZE-1); /* modulo-addition for the gs.xmit_buf ring-buffer */ 584 port->gs.xmit_tail = (port->gs.xmit_tail+1) & (SERIAL_XMIT_SIZE-1); /* modulo-addition for the gs.xmit_buf ring-buffer */
@@ -592,8 +592,8 @@ int ch, err, n, p;
592 status->OutHead = bufpos; 592 status->OutHead = bufpos;
593 593
594 /* WakeUp if output buffer runs low */ 594 /* WakeUp if output buffer runs low */
595 if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) { 595 if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.port.tty) {
596 tty_wakeup(port->gs.tty); 596 tty_wakeup(port->gs.port.tty);
597 } 597 }
598 } // if the port is used 598 } // if the port is used
599 } // for every port on the board 599 } // for every port on the board
@@ -613,16 +613,16 @@ int ch, err, n, p;
613 struct a2232_port *port = &a2232_ports[n*7+p]; 613 struct a2232_port *port = &a2232_ports[n*7+p];
614 port->cd_status = !(ncd & 1); /* ncd&1 <=> CD is now off */ 614 port->cd_status = !(ncd & 1); /* ncd&1 <=> CD is now off */
615 615
616 if (!(port->gs.flags & ASYNC_CHECK_CD)) 616 if (!(port->gs.port.flags & ASYNC_CHECK_CD))
617 ; /* Don't report DCD changes */ 617 ; /* Don't report DCD changes */
618 else if (port->cd_status) { // if DCD on: DCD went UP! 618 else if (port->cd_status) { // if DCD on: DCD went UP!
619 619
620 /* Are we blocking in open?*/ 620 /* Are we blocking in open?*/
621 wake_up_interruptible(&port->gs.open_wait); 621 wake_up_interruptible(&port->gs.port.open_wait);
622 } 622 }
623 else { // if DCD off: DCD went DOWN! 623 else { // if DCD off: DCD went DOWN!
624 if (port->gs.tty) 624 if (port->gs.port.tty)
625 tty_hangup (port->gs.tty); 625 tty_hangup (port->gs.port.tty);
626 } 626 }
627 627
628 } // if CD changed for this port 628 } // if CD changed for this port
@@ -655,8 +655,8 @@ static void a2232_init_portstructs(void)
655#ifdef NEW_WRITE_LOCKING 655#ifdef NEW_WRITE_LOCKING
656 mutex_init(&(port->gs.port_write_mutex)); 656 mutex_init(&(port->gs.port_write_mutex));
657#endif 657#endif
658 init_waitqueue_head(&port->gs.open_wait); 658 init_waitqueue_head(&port->gs.port.open_wait);
659 init_waitqueue_head(&port->gs.close_wait); 659 init_waitqueue_head(&port->gs.port.close_wait);
660 } 660 }
661} 661}
662 662
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index e1fc193d9396..ae766d868454 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -580,91 +580,133 @@ void tpm_continue_selftest(struct tpm_chip *chip)
580} 580}
581EXPORT_SYMBOL_GPL(tpm_continue_selftest); 581EXPORT_SYMBOL_GPL(tpm_continue_selftest);
582 582
583#define TPM_INTERNAL_RESULT_SIZE 200
584
583ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr, 585ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr,
584 char *buf) 586 char *buf)
585{ 587{
586 u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)]; 588 u8 *data;
587 ssize_t rc; 589 ssize_t rc;
588 590
589 struct tpm_chip *chip = dev_get_drvdata(dev); 591 struct tpm_chip *chip = dev_get_drvdata(dev);
590 if (chip == NULL) 592 if (chip == NULL)
591 return -ENODEV; 593 return -ENODEV;
592 594
595 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
596 if (!data)
597 return -ENOMEM;
598
593 memcpy(data, tpm_cap, sizeof(tpm_cap)); 599 memcpy(data, tpm_cap, sizeof(tpm_cap));
594 data[TPM_CAP_IDX] = TPM_CAP_FLAG; 600 data[TPM_CAP_IDX] = TPM_CAP_FLAG;
595 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM; 601 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
596 602
597 rc = transmit_cmd(chip, data, sizeof(data), 603 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
598 "attemtping to determine the permanent state"); 604 "attemtping to determine the permanent enabled state");
599 if (rc) 605 if (rc) {
606 kfree(data);
600 return 0; 607 return 0;
601 return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_DISABLE_IDX]); 608 }
609
610 rc = sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_DISABLE_IDX]);
611
612 kfree(data);
613 return rc;
602} 614}
603EXPORT_SYMBOL_GPL(tpm_show_enabled); 615EXPORT_SYMBOL_GPL(tpm_show_enabled);
604 616
605ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr, 617ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr,
606 char *buf) 618 char *buf)
607{ 619{
608 u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)]; 620 u8 *data;
609 ssize_t rc; 621 ssize_t rc;
610 622
611 struct tpm_chip *chip = dev_get_drvdata(dev); 623 struct tpm_chip *chip = dev_get_drvdata(dev);
612 if (chip == NULL) 624 if (chip == NULL)
613 return -ENODEV; 625 return -ENODEV;
614 626
627 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
628 if (!data)
629 return -ENOMEM;
630
615 memcpy(data, tpm_cap, sizeof(tpm_cap)); 631 memcpy(data, tpm_cap, sizeof(tpm_cap));
616 data[TPM_CAP_IDX] = TPM_CAP_FLAG; 632 data[TPM_CAP_IDX] = TPM_CAP_FLAG;
617 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM; 633 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM;
618 634
619 rc = transmit_cmd(chip, data, sizeof(data), 635 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
620 "attemtping to determine the permanent state"); 636 "attemtping to determine the permanent active state");
621 if (rc) 637 if (rc) {
638 kfree(data);
622 return 0; 639 return 0;
623 return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_INACTIVE_IDX]); 640 }
641
642 rc = sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_INACTIVE_IDX]);
643
644 kfree(data);
645 return rc;
624} 646}
625EXPORT_SYMBOL_GPL(tpm_show_active); 647EXPORT_SYMBOL_GPL(tpm_show_active);
626 648
627ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr, 649ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr,
628 char *buf) 650 char *buf)
629{ 651{
630 u8 data[sizeof(tpm_cap)]; 652 u8 *data;
631 ssize_t rc; 653 ssize_t rc;
632 654
633 struct tpm_chip *chip = dev_get_drvdata(dev); 655 struct tpm_chip *chip = dev_get_drvdata(dev);
634 if (chip == NULL) 656 if (chip == NULL)
635 return -ENODEV; 657 return -ENODEV;
636 658
659 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
660 if (!data)
661 return -ENOMEM;
662
637 memcpy(data, tpm_cap, sizeof(tpm_cap)); 663 memcpy(data, tpm_cap, sizeof(tpm_cap));
638 data[TPM_CAP_IDX] = TPM_CAP_PROP; 664 data[TPM_CAP_IDX] = TPM_CAP_PROP;
639 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_OWNER; 665 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_OWNER;
640 666
641 rc = transmit_cmd(chip, data, sizeof(data), 667 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
642 "attempting to determine the owner state"); 668 "attempting to determine the owner state");
643 if (rc) 669 if (rc) {
670 kfree(data);
644 return 0; 671 return 0;
645 return sprintf(buf, "%d\n", data[TPM_GET_CAP_RET_BOOL_1_IDX]); 672 }
673
674 rc = sprintf(buf, "%d\n", data[TPM_GET_CAP_RET_BOOL_1_IDX]);
675
676 kfree(data);
677 return rc;
646} 678}
647EXPORT_SYMBOL_GPL(tpm_show_owned); 679EXPORT_SYMBOL_GPL(tpm_show_owned);
648 680
649ssize_t tpm_show_temp_deactivated(struct device * dev, 681ssize_t tpm_show_temp_deactivated(struct device * dev,
650 struct device_attribute * attr, char *buf) 682 struct device_attribute * attr, char *buf)
651{ 683{
652 u8 data[sizeof(tpm_cap)]; 684 u8 *data;
653 ssize_t rc; 685 ssize_t rc;
654 686
655 struct tpm_chip *chip = dev_get_drvdata(dev); 687 struct tpm_chip *chip = dev_get_drvdata(dev);
656 if (chip == NULL) 688 if (chip == NULL)
657 return -ENODEV; 689 return -ENODEV;
658 690
691 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
692 if (!data)
693 return -ENOMEM;
694
659 memcpy(data, tpm_cap, sizeof(tpm_cap)); 695 memcpy(data, tpm_cap, sizeof(tpm_cap));
660 data[TPM_CAP_IDX] = TPM_CAP_FLAG; 696 data[TPM_CAP_IDX] = TPM_CAP_FLAG;
661 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_VOL; 697 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_VOL;
662 698
663 rc = transmit_cmd(chip, data, sizeof(data), 699 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
664 "attempting to determine the temporary state"); 700 "attempting to determine the temporary state");
665 if (rc) 701 if (rc) {
702 kfree(data);
666 return 0; 703 return 0;
667 return sprintf(buf, "%d\n", data[TPM_GET_CAP_TEMP_INACTIVE_IDX]); 704 }
705
706 rc = sprintf(buf, "%d\n", data[TPM_GET_CAP_TEMP_INACTIVE_IDX]);
707
708 kfree(data);
709 return rc;
668} 710}
669EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); 711EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
670 712
@@ -678,7 +720,7 @@ static const u8 pcrread[] = {
678ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, 720ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
679 char *buf) 721 char *buf)
680{ 722{
681 u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(pcrread)), 30)]; 723 u8 *data;
682 ssize_t rc; 724 ssize_t rc;
683 int i, j, num_pcrs; 725 int i, j, num_pcrs;
684 __be32 index; 726 __be32 index;
@@ -688,21 +730,27 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
688 if (chip == NULL) 730 if (chip == NULL)
689 return -ENODEV; 731 return -ENODEV;
690 732
733 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
734 if (!data)
735 return -ENOMEM;
736
691 memcpy(data, tpm_cap, sizeof(tpm_cap)); 737 memcpy(data, tpm_cap, sizeof(tpm_cap));
692 data[TPM_CAP_IDX] = TPM_CAP_PROP; 738 data[TPM_CAP_IDX] = TPM_CAP_PROP;
693 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_PCR; 739 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_PCR;
694 740
695 rc = transmit_cmd(chip, data, sizeof(data), 741 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
696 "attempting to determine the number of PCRS"); 742 "attempting to determine the number of PCRS");
697 if (rc) 743 if (rc) {
744 kfree(data);
698 return 0; 745 return 0;
746 }
699 747
700 num_pcrs = be32_to_cpu(*((__be32 *) (data + 14))); 748 num_pcrs = be32_to_cpu(*((__be32 *) (data + 14)));
701 for (i = 0; i < num_pcrs; i++) { 749 for (i = 0; i < num_pcrs; i++) {
702 memcpy(data, pcrread, sizeof(pcrread)); 750 memcpy(data, pcrread, sizeof(pcrread));
703 index = cpu_to_be32(i); 751 index = cpu_to_be32(i);
704 memcpy(data + 10, &index, 4); 752 memcpy(data + 10, &index, 4);
705 rc = transmit_cmd(chip, data, sizeof(data), 753 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
706 "attempting to read a PCR"); 754 "attempting to read a PCR");
707 if (rc) 755 if (rc)
708 goto out; 756 goto out;
@@ -712,6 +760,7 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
712 str += sprintf(str, "\n"); 760 str += sprintf(str, "\n");
713 } 761 }
714out: 762out:
763 kfree(data);
715 return str - buf; 764 return str - buf;
716} 765}
717EXPORT_SYMBOL_GPL(tpm_show_pcrs); 766EXPORT_SYMBOL_GPL(tpm_show_pcrs);
@@ -795,7 +844,7 @@ static const u8 cap_version[] = {
795ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, 844ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
796 char *buf) 845 char *buf)
797{ 846{
798 u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)]; 847 u8 *data;
799 ssize_t rc; 848 ssize_t rc;
800 char *str = buf; 849 char *str = buf;
801 850
@@ -803,21 +852,27 @@ ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
803 if (chip == NULL) 852 if (chip == NULL)
804 return -ENODEV; 853 return -ENODEV;
805 854
855 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
856 if (!data)
857 return -ENOMEM;
858
806 memcpy(data, tpm_cap, sizeof(tpm_cap)); 859 memcpy(data, tpm_cap, sizeof(tpm_cap));
807 data[TPM_CAP_IDX] = TPM_CAP_PROP; 860 data[TPM_CAP_IDX] = TPM_CAP_PROP;
808 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER; 861 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
809 862
810 rc = transmit_cmd(chip, data, sizeof(data), 863 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
811 "attempting to determine the manufacturer"); 864 "attempting to determine the manufacturer");
812 if (rc) 865 if (rc) {
866 kfree(data);
813 return 0; 867 return 0;
868 }
814 869
815 str += sprintf(str, "Manufacturer: 0x%x\n", 870 str += sprintf(str, "Manufacturer: 0x%x\n",
816 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)))); 871 be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))));
817 872
818 memcpy(data, cap_version, sizeof(cap_version)); 873 memcpy(data, cap_version, sizeof(cap_version));
819 data[CAP_VERSION_IDX] = CAP_VERSION_1_1; 874 data[CAP_VERSION_IDX] = CAP_VERSION_1_1;
820 rc = transmit_cmd(chip, data, sizeof(data), 875 rc = transmit_cmd(chip, data, TPM_INTERNAL_RESULT_SIZE,
821 "attempting to determine the 1.1 version"); 876 "attempting to determine the 1.1 version");
822 if (rc) 877 if (rc)
823 goto out; 878 goto out;
@@ -828,6 +883,7 @@ ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
828 (int) data[17]); 883 (int) data[17]);
829 884
830out: 885out:
886 kfree(data);
831 return str - buf; 887 return str - buf;
832} 888}
833EXPORT_SYMBOL_GPL(tpm_show_caps); 889EXPORT_SYMBOL_GPL(tpm_show_caps);
@@ -835,7 +891,7 @@ EXPORT_SYMBOL_GPL(tpm_show_caps);
835ssize_t tpm_show_caps_1_2(struct device * dev, 891ssize_t tpm_show_caps_1_2(struct device * dev,
836 struct device_attribute * attr, char *buf) 892 struct device_attribute * attr, char *buf)
837{ 893{
838 u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)]; 894 u8 *data;
839 ssize_t len; 895 ssize_t len;
840 char *str = buf; 896 char *str = buf;
841 897
@@ -843,15 +899,20 @@ ssize_t tpm_show_caps_1_2(struct device * dev,
843 if (chip == NULL) 899 if (chip == NULL)
844 return -ENODEV; 900 return -ENODEV;
845 901
902 data = kzalloc(TPM_INTERNAL_RESULT_SIZE, GFP_KERNEL);
903 if (!data)
904 return -ENOMEM;
905
846 memcpy(data, tpm_cap, sizeof(tpm_cap)); 906 memcpy(data, tpm_cap, sizeof(tpm_cap));
847 data[TPM_CAP_IDX] = TPM_CAP_PROP; 907 data[TPM_CAP_IDX] = TPM_CAP_PROP;
848 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER; 908 data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER;
849 909
850 if ((len = tpm_transmit(chip, data, sizeof(data))) <= 910 len = tpm_transmit(chip, data, TPM_INTERNAL_RESULT_SIZE);
851 TPM_ERROR_SIZE) { 911 if (len <= TPM_ERROR_SIZE) {
852 dev_dbg(chip->dev, "A TPM error (%d) occurred " 912 dev_dbg(chip->dev, "A TPM error (%d) occurred "
853 "attempting to determine the manufacturer\n", 913 "attempting to determine the manufacturer\n",
854 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX)))); 914 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
915 kfree(data);
855 return 0; 916 return 0;
856 } 917 }
857 918
@@ -861,8 +922,8 @@ ssize_t tpm_show_caps_1_2(struct device * dev,
861 memcpy(data, cap_version, sizeof(cap_version)); 922 memcpy(data, cap_version, sizeof(cap_version));
862 data[CAP_VERSION_IDX] = CAP_VERSION_1_2; 923 data[CAP_VERSION_IDX] = CAP_VERSION_1_2;
863 924
864 if ((len = tpm_transmit(chip, data, sizeof(data))) <= 925 len = tpm_transmit(chip, data, TPM_INTERNAL_RESULT_SIZE);
865 TPM_ERROR_SIZE) { 926 if (len <= TPM_ERROR_SIZE) {
866 dev_err(chip->dev, "A TPM error (%d) occurred " 927 dev_err(chip->dev, "A TPM error (%d) occurred "
867 "attempting to determine the 1.2 version\n", 928 "attempting to determine the 1.2 version\n",
868 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX)))); 929 be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))));
@@ -874,6 +935,7 @@ ssize_t tpm_show_caps_1_2(struct device * dev,
874 (int) data[19]); 935 (int) data[19]);
875 936
876out: 937out:
938 kfree(data);
877 return str - buf; 939 return str - buf;
878} 940}
879EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); 941EXPORT_SYMBOL_GPL(tpm_show_caps_1_2);
@@ -966,7 +1028,7 @@ ssize_t tpm_write(struct file *file, const char __user *buf,
966 size_t size, loff_t *off) 1028 size_t size, loff_t *off)
967{ 1029{
968 struct tpm_chip *chip = file->private_data; 1030 struct tpm_chip *chip = file->private_data;
969 int in_size = size, out_size; 1031 size_t in_size = size, out_size;
970 1032
971 /* cannot perform a write until the read has cleared 1033 /* cannot perform a write until the read has cleared
972 either via tpm_read or a user_read_timer timeout */ 1034 either via tpm_read or a user_read_timer timeout */
@@ -1001,7 +1063,7 @@ ssize_t tpm_read(struct file *file, char __user *buf,
1001 size_t size, loff_t *off) 1063 size_t size, loff_t *off)
1002{ 1064{
1003 struct tpm_chip *chip = file->private_data; 1065 struct tpm_chip *chip = file->private_data;
1004 int ret_size; 1066 ssize_t ret_size;
1005 1067
1006 del_singleshot_timer_sync(&chip->user_read_timer); 1068 del_singleshot_timer_sync(&chip->user_read_timer);
1007 flush_scheduled_work(); 1069 flush_scheduled_work();
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index 60a2d2630e36..68f052b42ed7 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -448,7 +448,7 @@ out_free:
448 goto out; 448 goto out;
449} 449}
450 450
451const struct file_operations tpm_ascii_bios_measurements_ops = { 451static const struct file_operations tpm_ascii_bios_measurements_ops = {
452 .open = tpm_ascii_bios_measurements_open, 452 .open = tpm_ascii_bios_measurements_open,
453 .read = seq_read, 453 .read = seq_read,
454 .llseek = seq_lseek, 454 .llseek = seq_lseek,
@@ -486,7 +486,7 @@ out_free:
486 goto out; 486 goto out;
487} 487}
488 488
489const struct file_operations tpm_binary_bios_measurements_ops = { 489static const struct file_operations tpm_binary_bios_measurements_ops = {
490 .open = tpm_binary_bios_measurements_open, 490 .open = tpm_binary_bios_measurements_open,
491 .read = seq_read, 491 .read = seq_read,
492 .llseek = seq_lseek, 492 .llseek = seq_lseek,
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index c7a977bc03e8..ed1879c0dd8d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -622,6 +622,7 @@ static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = {
622 {"ATM1200", 0}, /* Atmel */ 622 {"ATM1200", 0}, /* Atmel */
623 {"IFX0102", 0}, /* Infineon */ 623 {"IFX0102", 0}, /* Infineon */
624 {"BCM0101", 0}, /* Broadcom */ 624 {"BCM0101", 0}, /* Broadcom */
625 {"BCM0102", 0}, /* Broadcom */
625 {"NSC1200", 0}, /* National */ 626 {"NSC1200", 0}, /* National */
626 {"ICO0102", 0}, /* Intel */ 627 {"ICO0102", 0}, /* Intel */
627 /* Add new here */ 628 /* Add new here */
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 69c5afe97f19..1718b3c481db 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -183,8 +183,8 @@ static void scc_init_portstructs(void)
183#ifdef NEW_WRITE_LOCKING 183#ifdef NEW_WRITE_LOCKING
184 port->gs.port_write_mutex = MUTEX; 184 port->gs.port_write_mutex = MUTEX;
185#endif 185#endif
186 init_waitqueue_head(&port->gs.open_wait); 186 init_waitqueue_head(&port->gs.port.open_wait);
187 init_waitqueue_head(&port->gs.close_wait); 187 init_waitqueue_head(&port->gs.port.close_wait);
188 } 188 }
189} 189}
190 190
@@ -422,7 +422,7 @@ static irqreturn_t scc_rx_int(int irq, void *data)
422{ 422{
423 unsigned char ch; 423 unsigned char ch;
424 struct scc_port *port = data; 424 struct scc_port *port = data;
425 struct tty_struct *tty = port->gs.tty; 425 struct tty_struct *tty = port->gs.port.tty;
426 SCC_ACCESS_INIT(port); 426 SCC_ACCESS_INIT(port);
427 427
428 ch = SCCread_NB(RX_DATA_REG); 428 ch = SCCread_NB(RX_DATA_REG);
@@ -453,7 +453,7 @@ static irqreturn_t scc_rx_int(int irq, void *data)
453static irqreturn_t scc_spcond_int(int irq, void *data) 453static irqreturn_t scc_spcond_int(int irq, void *data)
454{ 454{
455 struct scc_port *port = data; 455 struct scc_port *port = data;
456 struct tty_struct *tty = port->gs.tty; 456 struct tty_struct *tty = port->gs.port.tty;
457 unsigned char stat, ch, err; 457 unsigned char stat, ch, err;
458 int int_pending_mask = port->channel == CHANNEL_A ? 458 int int_pending_mask = port->channel == CHANNEL_A ?
459 IPR_A_RX : IPR_B_RX; 459 IPR_A_RX : IPR_B_RX;
@@ -500,7 +500,7 @@ static irqreturn_t scc_tx_int(int irq, void *data)
500 struct scc_port *port = data; 500 struct scc_port *port = data;
501 SCC_ACCESS_INIT(port); 501 SCC_ACCESS_INIT(port);
502 502
503 if (!port->gs.tty) { 503 if (!port->gs.port.tty) {
504 printk(KERN_WARNING "scc_tx_int with NULL tty!\n"); 504 printk(KERN_WARNING "scc_tx_int with NULL tty!\n");
505 SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0); 505 SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
506 SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET); 506 SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET);
@@ -512,8 +512,9 @@ static irqreturn_t scc_tx_int(int irq, void *data)
512 SCCwrite(TX_DATA_REG, port->x_char); 512 SCCwrite(TX_DATA_REG, port->x_char);
513 port->x_char = 0; 513 port->x_char = 0;
514 } 514 }
515 else if ((port->gs.xmit_cnt <= 0) || port->gs.tty->stopped || 515 else if ((port->gs.xmit_cnt <= 0) ||
516 port->gs.tty->hw_stopped) 516 port->gs.port.tty->stopped ||
517 port->gs.port.tty->hw_stopped)
517 break; 518 break;
518 else { 519 else {
519 SCCwrite(TX_DATA_REG, port->gs.xmit_buf[port->gs.xmit_tail++]); 520 SCCwrite(TX_DATA_REG, port->gs.xmit_buf[port->gs.xmit_tail++]);
@@ -522,15 +523,15 @@ static irqreturn_t scc_tx_int(int irq, void *data)
522 break; 523 break;
523 } 524 }
524 } 525 }
525 if ((port->gs.xmit_cnt <= 0) || port->gs.tty->stopped || 526 if ((port->gs.xmit_cnt <= 0) || port->gs.port.tty->stopped ||
526 port->gs.tty->hw_stopped) { 527 port->gs.port.tty->hw_stopped) {
527 /* disable tx interrupts */ 528 /* disable tx interrupts */
528 SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0); 529 SCCmod (INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
529 SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET); /* disable tx_int on next tx underrun? */ 530 SCCwrite(COMMAND_REG, CR_TX_PENDING_RESET); /* disable tx_int on next tx underrun? */
530 port->gs.flags &= ~GS_TX_INTEN; 531 port->gs.port.flags &= ~GS_TX_INTEN;
531 } 532 }
532 if (port->gs.tty && port->gs.xmit_cnt <= port->gs.wakeup_chars) 533 if (port->gs.port.tty && port->gs.xmit_cnt <= port->gs.wakeup_chars)
533 tty_wakeup(port->gs.tty); 534 tty_wakeup(port->gs.port.tty);
534 535
535 SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET); 536 SCCwrite_NB(COMMAND_REG, CR_HIGHEST_IUS_RESET);
536 return IRQ_HANDLED; 537 return IRQ_HANDLED;
@@ -550,14 +551,14 @@ static irqreturn_t scc_stat_int(int irq, void *data)
550 551
551 if (changed & SR_DCD) { 552 if (changed & SR_DCD) {
552 port->c_dcd = !!(sr & SR_DCD); 553 port->c_dcd = !!(sr & SR_DCD);
553 if (!(port->gs.flags & ASYNC_CHECK_CD)) 554 if (!(port->gs.port.flags & ASYNC_CHECK_CD))
554 ; /* Don't report DCD changes */ 555 ; /* Don't report DCD changes */
555 else if (port->c_dcd) { 556 else if (port->c_dcd) {
556 wake_up_interruptible(&port->gs.open_wait); 557 wake_up_interruptible(&port->gs.port.open_wait);
557 } 558 }
558 else { 559 else {
559 if (port->gs.tty) 560 if (port->gs.port.tty)
560 tty_hangup (port->gs.tty); 561 tty_hangup (port->gs.port.tty);
561 } 562 }
562 } 563 }
563 SCCwrite(COMMAND_REG, CR_EXTSTAT_RESET); 564 SCCwrite(COMMAND_REG, CR_EXTSTAT_RESET);
@@ -578,7 +579,7 @@ static void scc_disable_tx_interrupts(void *ptr)
578 579
579 local_irq_save(flags); 580 local_irq_save(flags);
580 SCCmod(INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0); 581 SCCmod(INT_AND_DMA_REG, ~IDR_TX_INT_ENAB, 0);
581 port->gs.flags &= ~GS_TX_INTEN; 582 port->gs.port.flags &= ~GS_TX_INTEN;
582 local_irq_restore(flags); 583 local_irq_restore(flags);
583} 584}
584 585
@@ -636,8 +637,8 @@ static void scc_shutdown_port(void *ptr)
636{ 637{
637 struct scc_port *port = ptr; 638 struct scc_port *port = ptr;
638 639
639 port->gs.flags &= ~ GS_ACTIVE; 640 port->gs.port.flags &= ~ GS_ACTIVE;
640 if (port->gs.tty && port->gs.tty->termios->c_cflag & HUPCL) { 641 if (port->gs.port.tty && port->gs.port.tty->termios->c_cflag & HUPCL) {
641 scc_setsignals (port, 0, 0); 642 scc_setsignals (port, 0, 0);
642 } 643 }
643} 644}
@@ -652,14 +653,14 @@ static int scc_set_real_termios (void *ptr)
652 struct scc_port *port = ptr; 653 struct scc_port *port = ptr;
653 SCC_ACCESS_INIT(port); 654 SCC_ACCESS_INIT(port);
654 655
655 if (!port->gs.tty || !port->gs.tty->termios) return 0; 656 if (!port->gs.port.tty || !port->gs.port.tty->termios) return 0;
656 657
657 channel = port->channel; 658 channel = port->channel;
658 659
659 if (channel == CHANNEL_A) 660 if (channel == CHANNEL_A)
660 return 0; /* Settings controlled by boot PROM */ 661 return 0; /* Settings controlled by boot PROM */
661 662
662 cflag = port->gs.tty->termios->c_cflag; 663 cflag = port->gs.port.tty->termios->c_cflag;
663 baud = port->gs.baud; 664 baud = port->gs.baud;
664 chsize = (cflag & CSIZE) >> 4; 665 chsize = (cflag & CSIZE) >> 4;
665 666
@@ -678,9 +679,9 @@ static int scc_set_real_termios (void *ptr)
678 } 679 }
679 680
680 if (cflag & CLOCAL) 681 if (cflag & CLOCAL)
681 port->gs.flags &= ~ASYNC_CHECK_CD; 682 port->gs.port.flags &= ~ASYNC_CHECK_CD;
682 else 683 else
683 port->gs.flags |= ASYNC_CHECK_CD; 684 port->gs.port.flags |= ASYNC_CHECK_CD;
684 685
685#ifdef CONFIG_MVME147_SCC 686#ifdef CONFIG_MVME147_SCC
686 if (MACH_IS_MVME147) 687 if (MACH_IS_MVME147)
@@ -856,7 +857,7 @@ static int scc_open (struct tty_struct * tty, struct file * filp)
856 { COMMAND_REG, CR_EXTSTAT_RESET }, 857 { COMMAND_REG, CR_EXTSTAT_RESET },
857 }; 858 };
858#endif 859#endif
859 if (!(port->gs.flags & ASYNC_INITIALIZED)) { 860 if (!(port->gs.port.flags & ASYNC_INITIALIZED)) {
860 local_irq_save(flags); 861 local_irq_save(flags);
861#if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC) 862#if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC)
862 if (MACH_IS_MVME147 || MACH_IS_MVME16x) { 863 if (MACH_IS_MVME147 || MACH_IS_MVME16x) {
@@ -880,18 +881,18 @@ static int scc_open (struct tty_struct * tty, struct file * filp)
880 } 881 }
881 882
882 tty->driver_data = port; 883 tty->driver_data = port;
883 port->gs.tty = tty; 884 port->gs.port.tty = tty;
884 port->gs.count++; 885 port->gs.port.count++;
885 retval = gs_init_port(&port->gs); 886 retval = gs_init_port(&port->gs);
886 if (retval) { 887 if (retval) {
887 port->gs.count--; 888 port->gs.port.count--;
888 return retval; 889 return retval;
889 } 890 }
890 port->gs.flags |= GS_ACTIVE; 891 port->gs.port.flags |= GS_ACTIVE;
891 retval = gs_block_til_ready(port, filp); 892 retval = gs_block_til_ready(port, filp);
892 893
893 if (retval) { 894 if (retval) {
894 port->gs.count--; 895 port->gs.port.count--;
895 return retval; 896 return retval;
896 } 897 }
897 898
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 5405769020a1..5ce07b517c58 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -94,7 +94,7 @@ void cpuidle_install_idle_handler(void)
94 */ 94 */
95void cpuidle_uninstall_idle_handler(void) 95void cpuidle_uninstall_idle_handler(void)
96{ 96{
97 if (enabled_devices && (pm_idle != pm_idle_old)) { 97 if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) {
98 pm_idle = pm_idle_old; 98 pm_idle = pm_idle_old;
99 cpuidle_kick_cpus(); 99 cpuidle_kick_cpus();
100 } 100 }
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index b11943dadefd..681c15f42083 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -99,6 +99,9 @@ struct talitos_private {
99 /* next channel to be assigned next incoming descriptor */ 99 /* next channel to be assigned next incoming descriptor */
100 atomic_t last_chan; 100 atomic_t last_chan;
101 101
102 /* per-channel number of requests pending in channel h/w fifo */
103 atomic_t *submit_count;
104
102 /* per-channel request fifo */ 105 /* per-channel request fifo */
103 struct talitos_request **fifo; 106 struct talitos_request **fifo;
104 107
@@ -263,15 +266,15 @@ static int talitos_submit(struct device *dev, struct talitos_desc *desc,
263 266
264 spin_lock_irqsave(&priv->head_lock[ch], flags); 267 spin_lock_irqsave(&priv->head_lock[ch], flags);
265 268
266 head = priv->head[ch]; 269 if (!atomic_inc_not_zero(&priv->submit_count[ch])) {
267 request = &priv->fifo[ch][head]; 270 /* h/w fifo is full */
268
269 if (request->desc) {
270 /* request queue is full */
271 spin_unlock_irqrestore(&priv->head_lock[ch], flags); 271 spin_unlock_irqrestore(&priv->head_lock[ch], flags);
272 return -EAGAIN; 272 return -EAGAIN;
273 } 273 }
274 274
275 head = priv->head[ch];
276 request = &priv->fifo[ch][head];
277
275 /* map descriptor and save caller data */ 278 /* map descriptor and save caller data */
276 request->dma_desc = dma_map_single(dev, desc, sizeof(*desc), 279 request->dma_desc = dma_map_single(dev, desc, sizeof(*desc),
277 DMA_BIDIRECTIONAL); 280 DMA_BIDIRECTIONAL);
@@ -335,6 +338,9 @@ static void flush_channel(struct device *dev, int ch, int error, int reset_ch)
335 priv->tail[ch] = (tail + 1) & (priv->fifo_len - 1); 338 priv->tail[ch] = (tail + 1) & (priv->fifo_len - 1);
336 339
337 spin_unlock_irqrestore(&priv->tail_lock[ch], flags); 340 spin_unlock_irqrestore(&priv->tail_lock[ch], flags);
341
342 atomic_dec(&priv->submit_count[ch]);
343
338 saved_req.callback(dev, saved_req.desc, saved_req.context, 344 saved_req.callback(dev, saved_req.desc, saved_req.context,
339 status); 345 status);
340 /* channel may resume processing in single desc error case */ 346 /* channel may resume processing in single desc error case */
@@ -842,7 +848,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
842 848
843 /* adjust (decrease) last one (or two) entry's len to cryptlen */ 849 /* adjust (decrease) last one (or two) entry's len to cryptlen */
844 link_tbl_ptr--; 850 link_tbl_ptr--;
845 while (link_tbl_ptr->len <= (-cryptlen)) { 851 while (be16_to_cpu(link_tbl_ptr->len) <= (-cryptlen)) {
846 /* Empty this entry, and move to previous one */ 852 /* Empty this entry, and move to previous one */
847 cryptlen += be16_to_cpu(link_tbl_ptr->len); 853 cryptlen += be16_to_cpu(link_tbl_ptr->len);
848 link_tbl_ptr->len = 0; 854 link_tbl_ptr->len = 0;
@@ -874,7 +880,7 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
874 unsigned int cryptlen = areq->cryptlen; 880 unsigned int cryptlen = areq->cryptlen;
875 unsigned int authsize = ctx->authsize; 881 unsigned int authsize = ctx->authsize;
876 unsigned int ivsize; 882 unsigned int ivsize;
877 int sg_count; 883 int sg_count, ret;
878 884
879 /* hmac key */ 885 /* hmac key */
880 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, 886 map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key,
@@ -978,7 +984,12 @@ static int ipsec_esp(struct ipsec_esp_edesc *edesc, struct aead_request *areq,
978 map_single_talitos_ptr(dev, &desc->ptr[6], ivsize, ctx->iv, 0, 984 map_single_talitos_ptr(dev, &desc->ptr[6], ivsize, ctx->iv, 0,
979 DMA_FROM_DEVICE); 985 DMA_FROM_DEVICE);
980 986
981 return talitos_submit(dev, desc, callback, areq); 987 ret = talitos_submit(dev, desc, callback, areq);
988 if (ret != -EINPROGRESS) {
989 ipsec_esp_unmap(dev, edesc, areq);
990 kfree(edesc);
991 }
992 return ret;
982} 993}
983 994
984 995
@@ -1009,6 +1020,8 @@ static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
1009 struct talitos_ctx *ctx = crypto_aead_ctx(authenc); 1020 struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
1010 struct ipsec_esp_edesc *edesc; 1021 struct ipsec_esp_edesc *edesc;
1011 int src_nents, dst_nents, alloc_len, dma_len; 1022 int src_nents, dst_nents, alloc_len, dma_len;
1023 gfp_t flags = areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
1024 GFP_ATOMIC;
1012 1025
1013 if (areq->cryptlen + ctx->authsize > TALITOS_MAX_DATA_LEN) { 1026 if (areq->cryptlen + ctx->authsize > TALITOS_MAX_DATA_LEN) {
1014 dev_err(ctx->dev, "cryptlen exceeds h/w max limit\n"); 1027 dev_err(ctx->dev, "cryptlen exceeds h/w max limit\n");
@@ -1022,7 +1035,7 @@ static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
1022 dst_nents = src_nents; 1035 dst_nents = src_nents;
1023 } else { 1036 } else {
1024 dst_nents = sg_count(areq->dst, areq->cryptlen + ctx->authsize); 1037 dst_nents = sg_count(areq->dst, areq->cryptlen + ctx->authsize);
1025 dst_nents = (dst_nents == 1) ? 0 : src_nents; 1038 dst_nents = (dst_nents == 1) ? 0 : dst_nents;
1026 } 1039 }
1027 1040
1028 /* 1041 /*
@@ -1040,7 +1053,7 @@ static struct ipsec_esp_edesc *ipsec_esp_edesc_alloc(struct aead_request *areq,
1040 alloc_len += icv_stashing ? ctx->authsize : 0; 1053 alloc_len += icv_stashing ? ctx->authsize : 0;
1041 } 1054 }
1042 1055
1043 edesc = kmalloc(alloc_len, GFP_DMA); 1056 edesc = kmalloc(alloc_len, GFP_DMA | flags);
1044 if (!edesc) { 1057 if (!edesc) {
1045 dev_err(ctx->dev, "could not allocate edescriptor\n"); 1058 dev_err(ctx->dev, "could not allocate edescriptor\n");
1046 return ERR_PTR(-ENOMEM); 1059 return ERR_PTR(-ENOMEM);
@@ -1337,6 +1350,7 @@ static int __devexit talitos_remove(struct of_device *ofdev)
1337 if (hw_supports(dev, DESC_HDR_SEL0_RNG)) 1350 if (hw_supports(dev, DESC_HDR_SEL0_RNG))
1338 talitos_unregister_rng(dev); 1351 talitos_unregister_rng(dev);
1339 1352
1353 kfree(priv->submit_count);
1340 kfree(priv->tail); 1354 kfree(priv->tail);
1341 kfree(priv->head); 1355 kfree(priv->head);
1342 1356
@@ -1466,9 +1480,6 @@ static int talitos_probe(struct of_device *ofdev,
1466 goto err_out; 1480 goto err_out;
1467 } 1481 }
1468 1482
1469 of_node_put(np);
1470 np = NULL;
1471
1472 priv->head_lock = kmalloc(sizeof(spinlock_t) * priv->num_channels, 1483 priv->head_lock = kmalloc(sizeof(spinlock_t) * priv->num_channels,
1473 GFP_KERNEL); 1484 GFP_KERNEL);
1474 priv->tail_lock = kmalloc(sizeof(spinlock_t) * priv->num_channels, 1485 priv->tail_lock = kmalloc(sizeof(spinlock_t) * priv->num_channels,
@@ -1504,6 +1515,16 @@ static int talitos_probe(struct of_device *ofdev,
1504 } 1515 }
1505 } 1516 }
1506 1517
1518 priv->submit_count = kmalloc(sizeof(atomic_t) * priv->num_channels,
1519 GFP_KERNEL);
1520 if (!priv->submit_count) {
1521 dev_err(dev, "failed to allocate fifo submit count space\n");
1522 err = -ENOMEM;
1523 goto err_out;
1524 }
1525 for (i = 0; i < priv->num_channels; i++)
1526 atomic_set(&priv->submit_count[i], -priv->chfifo_len);
1527
1507 priv->head = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL); 1528 priv->head = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL);
1508 priv->tail = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL); 1529 priv->tail = kzalloc(sizeof(int) * priv->num_channels, GFP_KERNEL);
1509 if (!priv->head || !priv->tail) { 1530 if (!priv->head || !priv->tail) {
@@ -1559,8 +1580,6 @@ static int talitos_probe(struct of_device *ofdev,
1559 1580
1560err_out: 1581err_out:
1561 talitos_remove(ofdev); 1582 talitos_remove(ofdev);
1562 if (np)
1563 of_node_put(np);
1564 1583
1565 return err; 1584 return err;
1566} 1585}
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
index 76f26710fc16..fa6d6abefd4d 100644
--- a/drivers/firewire/Kconfig
+++ b/drivers/firewire/Kconfig
@@ -16,8 +16,13 @@ config FIREWIRE
16 enable the new stack. 16 enable the new stack.
17 17
18 To compile this driver as a module, say M here: the module will be 18 To compile this driver as a module, say M here: the module will be
19 called firewire-core. It functionally replaces ieee1394, raw1394, 19 called firewire-core.
20 and video1394. 20
21 This module functionally replaces ieee1394, raw1394, and video1394.
22 To access it from application programs, you generally need at least
23 libraw1394 version 2. IIDC/DCAM applications also need libdc1394
24 version 2. No libraries are required to access storage devices
25 through the firewire-sbp2 driver.
21 26
22config FIREWIRE_OHCI 27config FIREWIRE_OHCI
23 tristate "OHCI-1394 controllers" 28 tristate "OHCI-1394 controllers"
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index da873d795aad..bbd73a406e53 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -539,7 +539,7 @@ fw_core_remove_card(struct fw_card *card)
539 wait_for_completion(&card->done); 539 wait_for_completion(&card->done);
540 540
541 cancel_delayed_work_sync(&card->work); 541 cancel_delayed_work_sync(&card->work);
542 fw_flush_transactions(card); 542 WARN_ON(!list_empty(&card->transaction_list));
543 del_timer_sync(&card->flush_timer); 543 del_timer_sync(&card->flush_timer);
544} 544}
545EXPORT_SYMBOL(fw_core_remove_card); 545EXPORT_SYMBOL(fw_core_remove_card);
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index c639915fc3cb..bc81d6fcd2fd 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -382,9 +382,9 @@ complete_transaction(struct fw_card *card, int rcode,
382 382
383 response->response.type = FW_CDEV_EVENT_RESPONSE; 383 response->response.type = FW_CDEV_EVENT_RESPONSE;
384 response->response.rcode = rcode; 384 response->response.rcode = rcode;
385 queue_event(client, &response->event, 385 queue_event(client, &response->event, &response->response,
386 &response->response, sizeof(response->response), 386 sizeof(response->response) + response->response.length,
387 response->response.data, response->response.length); 387 NULL, 0);
388} 388}
389 389
390static int ioctl_send_request(struct client *client, void *buffer) 390static int ioctl_send_request(struct client *client, void *buffer)
diff --git a/drivers/firewire/fw-iso.c b/drivers/firewire/fw-iso.c
index bcbe794a3ea5..e14c03dc0065 100644
--- a/drivers/firewire/fw-iso.c
+++ b/drivers/firewire/fw-iso.c
@@ -50,7 +50,7 @@ fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
50 50
51 address = dma_map_page(card->device, buffer->pages[i], 51 address = dma_map_page(card->device, buffer->pages[i],
52 0, PAGE_SIZE, direction); 52 0, PAGE_SIZE, direction);
53 if (dma_mapping_error(address)) { 53 if (dma_mapping_error(card->device, address)) {
54 __free_page(buffer->pages[i]); 54 __free_page(buffer->pages[i]);
55 goto out_pages; 55 goto out_pages;
56 } 56 }
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 333b12544dd1..251416f2148f 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -171,7 +171,6 @@ struct iso_context {
171struct fw_ohci { 171struct fw_ohci {
172 struct fw_card card; 172 struct fw_card card;
173 173
174 u32 version;
175 __iomem char *registers; 174 __iomem char *registers;
176 dma_addr_t self_id_bus; 175 dma_addr_t self_id_bus;
177 __le32 *self_id_cpu; 176 __le32 *self_id_cpu;
@@ -180,6 +179,8 @@ struct fw_ohci {
180 int generation; 179 int generation;
181 int request_generation; /* for timestamping incoming requests */ 180 int request_generation; /* for timestamping incoming requests */
182 u32 bus_seconds; 181 u32 bus_seconds;
182
183 bool use_dualbuffer;
183 bool old_uninorth; 184 bool old_uninorth;
184 bool bus_reset_packet_quirk; 185 bool bus_reset_packet_quirk;
185 186
@@ -953,7 +954,7 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
953 payload_bus = 954 payload_bus =
954 dma_map_single(ohci->card.device, packet->payload, 955 dma_map_single(ohci->card.device, packet->payload,
955 packet->payload_length, DMA_TO_DEVICE); 956 packet->payload_length, DMA_TO_DEVICE);
956 if (dma_mapping_error(payload_bus)) { 957 if (dma_mapping_error(ohci->card.device, payload_bus)) {
957 packet->ack = RCODE_SEND_ERROR; 958 packet->ack = RCODE_SEND_ERROR;
958 return -1; 959 return -1;
959 } 960 }
@@ -1885,7 +1886,7 @@ ohci_allocate_iso_context(struct fw_card *card, int type, size_t header_size)
1885 } else { 1886 } else {
1886 mask = &ohci->ir_context_mask; 1887 mask = &ohci->ir_context_mask;
1887 list = ohci->ir_context_list; 1888 list = ohci->ir_context_list;
1888 if (ohci->version >= OHCI_VERSION_1_1) 1889 if (ohci->use_dualbuffer)
1889 callback = handle_ir_dualbuffer_packet; 1890 callback = handle_ir_dualbuffer_packet;
1890 else 1891 else
1891 callback = handle_ir_packet_per_buffer; 1892 callback = handle_ir_packet_per_buffer;
@@ -1949,7 +1950,7 @@ static int ohci_start_iso(struct fw_iso_context *base,
1949 } else { 1950 } else {
1950 index = ctx - ohci->ir_context_list; 1951 index = ctx - ohci->ir_context_list;
1951 control = IR_CONTEXT_ISOCH_HEADER; 1952 control = IR_CONTEXT_ISOCH_HEADER;
1952 if (ohci->version >= OHCI_VERSION_1_1) 1953 if (ohci->use_dualbuffer)
1953 control |= IR_CONTEXT_DUAL_BUFFER_MODE; 1954 control |= IR_CONTEXT_DUAL_BUFFER_MODE;
1954 match = (tags << 28) | (sync << 8) | ctx->base.channel; 1955 match = (tags << 28) | (sync << 8) | ctx->base.channel;
1955 if (cycle >= 0) { 1956 if (cycle >= 0) {
@@ -2279,7 +2280,7 @@ ohci_queue_iso(struct fw_iso_context *base,
2279 spin_lock_irqsave(&ctx->context.ohci->lock, flags); 2280 spin_lock_irqsave(&ctx->context.ohci->lock, flags);
2280 if (base->type == FW_ISO_CONTEXT_TRANSMIT) 2281 if (base->type == FW_ISO_CONTEXT_TRANSMIT)
2281 retval = ohci_queue_iso_transmit(base, packet, buffer, payload); 2282 retval = ohci_queue_iso_transmit(base, packet, buffer, payload);
2282 else if (ctx->context.ohci->version >= OHCI_VERSION_1_1) 2283 else if (ctx->context.ohci->use_dualbuffer)
2283 retval = ohci_queue_iso_receive_dualbuffer(base, packet, 2284 retval = ohci_queue_iso_receive_dualbuffer(base, packet,
2284 buffer, payload); 2285 buffer, payload);
2285 else 2286 else
@@ -2341,7 +2342,7 @@ static int __devinit
2341pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) 2342pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2342{ 2343{
2343 struct fw_ohci *ohci; 2344 struct fw_ohci *ohci;
2344 u32 bus_options, max_receive, link_speed; 2345 u32 bus_options, max_receive, link_speed, version;
2345 u64 guid; 2346 u64 guid;
2346 int err; 2347 int err;
2347 size_t size; 2348 size_t size;
@@ -2366,12 +2367,6 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2366 pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0); 2367 pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0);
2367 pci_set_drvdata(dev, ohci); 2368 pci_set_drvdata(dev, ohci);
2368 2369
2369#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
2370 ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
2371 dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
2372#endif
2373 ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
2374
2375 spin_lock_init(&ohci->lock); 2370 spin_lock_init(&ohci->lock);
2376 2371
2377 tasklet_init(&ohci->bus_reset_tasklet, 2372 tasklet_init(&ohci->bus_reset_tasklet,
@@ -2390,6 +2385,23 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2390 goto fail_iomem; 2385 goto fail_iomem;
2391 } 2386 }
2392 2387
2388 version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
2389 ohci->use_dualbuffer = version >= OHCI_VERSION_1_1;
2390
2391/* x86-32 currently doesn't use highmem for dma_alloc_coherent */
2392#if !defined(CONFIG_X86_32)
2393 /* dual-buffer mode is broken with descriptor addresses above 2G */
2394 if (dev->vendor == PCI_VENDOR_ID_TI &&
2395 dev->device == PCI_DEVICE_ID_TI_TSB43AB22)
2396 ohci->use_dualbuffer = false;
2397#endif
2398
2399#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
2400 ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
2401 dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
2402#endif
2403 ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
2404
2393 ar_context_init(&ohci->ar_request_ctx, ohci, 2405 ar_context_init(&ohci->ar_request_ctx, ohci,
2394 OHCI1394_AsReqRcvContextControlSet); 2406 OHCI1394_AsReqRcvContextControlSet);
2395 2407
@@ -2441,9 +2453,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2441 if (err < 0) 2453 if (err < 0)
2442 goto fail_self_id; 2454 goto fail_self_id;
2443 2455
2444 ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
2445 fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", 2456 fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n",
2446 dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); 2457 dev->dev.bus_id, version >> 16, version & 0xff);
2447 return 0; 2458 return 0;
2448 2459
2449 fail_self_id: 2460 fail_self_id:
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 53fc5a641e6d..aaff50ebba1d 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -543,7 +543,7 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
543 orb->response_bus = 543 orb->response_bus =
544 dma_map_single(device->card->device, &orb->response, 544 dma_map_single(device->card->device, &orb->response,
545 sizeof(orb->response), DMA_FROM_DEVICE); 545 sizeof(orb->response), DMA_FROM_DEVICE);
546 if (dma_mapping_error(orb->response_bus)) 546 if (dma_mapping_error(device->card->device, orb->response_bus))
547 goto fail_mapping_response; 547 goto fail_mapping_response;
548 548
549 orb->request.response.high = 0; 549 orb->request.response.high = 0;
@@ -577,7 +577,7 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
577 orb->base.request_bus = 577 orb->base.request_bus =
578 dma_map_single(device->card->device, &orb->request, 578 dma_map_single(device->card->device, &orb->request,
579 sizeof(orb->request), DMA_TO_DEVICE); 579 sizeof(orb->request), DMA_TO_DEVICE);
580 if (dma_mapping_error(orb->base.request_bus)) 580 if (dma_mapping_error(device->card->device, orb->base.request_bus))
581 goto fail_mapping_request; 581 goto fail_mapping_request;
582 582
583 sbp2_send_orb(&orb->base, lu, node_id, generation, 583 sbp2_send_orb(&orb->base, lu, node_id, generation,
@@ -1424,7 +1424,7 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device,
1424 orb->page_table_bus = 1424 orb->page_table_bus =
1425 dma_map_single(device->card->device, orb->page_table, 1425 dma_map_single(device->card->device, orb->page_table,
1426 sizeof(orb->page_table), DMA_TO_DEVICE); 1426 sizeof(orb->page_table), DMA_TO_DEVICE);
1427 if (dma_mapping_error(orb->page_table_bus)) 1427 if (dma_mapping_error(device->card->device, orb->page_table_bus))
1428 goto fail_page_table; 1428 goto fail_page_table;
1429 1429
1430 /* 1430 /*
@@ -1509,7 +1509,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1509 orb->base.request_bus = 1509 orb->base.request_bus =
1510 dma_map_single(device->card->device, &orb->request, 1510 dma_map_single(device->card->device, &orb->request,
1511 sizeof(orb->request), DMA_TO_DEVICE); 1511 sizeof(orb->request), DMA_TO_DEVICE);
1512 if (dma_mapping_error(orb->base.request_bus)) 1512 if (dma_mapping_error(device->card->device, orb->base.request_bus))
1513 goto out; 1513 goto out;
1514 1514
1515 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, lu->generation, 1515 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, lu->generation,
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index 213b0ff8f3d6..c1b81077c4a8 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -510,8 +510,6 @@ fw_core_handle_bus_reset(struct fw_card *card,
510 struct fw_node *local_node; 510 struct fw_node *local_node;
511 unsigned long flags; 511 unsigned long flags;
512 512
513 fw_flush_transactions(card);
514
515 spin_lock_irqsave(&card->lock, flags); 513 spin_lock_irqsave(&card->lock, flags);
516 514
517 /* 515 /*
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 40db80752272..e5d1a0b64fcf 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/kref.h> 23#include <linux/kref.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mutex.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27#include <linux/pci.h> 28#include <linux/pci.h>
@@ -151,7 +152,7 @@ transmit_complete_callback(struct fw_packet *packet,
151 152
152static void 153static void
153fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, 154fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
154 int node_id, int source_id, int generation, int speed, 155 int destination_id, int source_id, int generation, int speed,
155 unsigned long long offset, void *payload, size_t length) 156 unsigned long long offset, void *payload, size_t length)
156{ 157{
157 int ext_tcode; 158 int ext_tcode;
@@ -166,7 +167,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
166 HEADER_RETRY(RETRY_X) | 167 HEADER_RETRY(RETRY_X) |
167 HEADER_TLABEL(tlabel) | 168 HEADER_TLABEL(tlabel) |
168 HEADER_TCODE(tcode) | 169 HEADER_TCODE(tcode) |
169 HEADER_DESTINATION(node_id); 170 HEADER_DESTINATION(destination_id);
170 packet->header[1] = 171 packet->header[1] =
171 HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id); 172 HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id);
172 packet->header[2] = 173 packet->header[2] =
@@ -252,7 +253,7 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
252 fw_transaction_callback_t callback, void *callback_data) 253 fw_transaction_callback_t callback, void *callback_data)
253{ 254{
254 unsigned long flags; 255 unsigned long flags;
255 int tlabel, source; 256 int tlabel;
256 257
257 /* 258 /*
258 * Bump the flush timer up 100ms first of all so we 259 * Bump the flush timer up 100ms first of all so we
@@ -268,7 +269,6 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
268 269
269 spin_lock_irqsave(&card->lock, flags); 270 spin_lock_irqsave(&card->lock, flags);
270 271
271 source = card->node_id;
272 tlabel = card->current_tlabel; 272 tlabel = card->current_tlabel;
273 if (card->tlabel_mask & (1 << tlabel)) { 273 if (card->tlabel_mask & (1 << tlabel)) {
274 spin_unlock_irqrestore(&card->lock, flags); 274 spin_unlock_irqrestore(&card->lock, flags);
@@ -279,77 +279,58 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f; 279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
280 card->tlabel_mask |= (1 << tlabel); 280 card->tlabel_mask |= (1 << tlabel);
281 281
282 list_add_tail(&t->link, &card->transaction_list);
283
284 spin_unlock_irqrestore(&card->lock, flags);
285
286 /* Initialize rest of transaction, fill out packet and send it. */
287 t->node_id = node_id; 282 t->node_id = node_id;
288 t->tlabel = tlabel; 283 t->tlabel = tlabel;
289 t->callback = callback; 284 t->callback = callback;
290 t->callback_data = callback_data; 285 t->callback_data = callback_data;
291 286
292 fw_fill_request(&t->packet, tcode, t->tlabel, 287 fw_fill_request(&t->packet, tcode, t->tlabel, node_id, card->node_id,
293 node_id, source, generation, 288 generation, speed, offset, payload, length);
294 speed, offset, payload, length);
295 t->packet.callback = transmit_complete_callback; 289 t->packet.callback = transmit_complete_callback;
296 290
291 list_add_tail(&t->link, &card->transaction_list);
292
293 spin_unlock_irqrestore(&card->lock, flags);
294
297 card->driver->send_request(card, &t->packet); 295 card->driver->send_request(card, &t->packet);
298} 296}
299EXPORT_SYMBOL(fw_send_request); 297EXPORT_SYMBOL(fw_send_request);
300 298
301struct fw_phy_packet { 299static DEFINE_MUTEX(phy_config_mutex);
302 struct fw_packet packet; 300static DECLARE_COMPLETION(phy_config_done);
303 struct completion done;
304 struct kref kref;
305};
306
307static void phy_packet_release(struct kref *kref)
308{
309 struct fw_phy_packet *p =
310 container_of(kref, struct fw_phy_packet, kref);
311 kfree(p);
312}
313 301
314static void transmit_phy_packet_callback(struct fw_packet *packet, 302static void transmit_phy_packet_callback(struct fw_packet *packet,
315 struct fw_card *card, int status) 303 struct fw_card *card, int status)
316{ 304{
317 struct fw_phy_packet *p = 305 complete(&phy_config_done);
318 container_of(packet, struct fw_phy_packet, packet);
319
320 complete(&p->done);
321 kref_put(&p->kref, phy_packet_release);
322} 306}
323 307
308static struct fw_packet phy_config_packet = {
309 .header_length = 8,
310 .payload_length = 0,
311 .speed = SCODE_100,
312 .callback = transmit_phy_packet_callback,
313};
314
324void fw_send_phy_config(struct fw_card *card, 315void fw_send_phy_config(struct fw_card *card,
325 int node_id, int generation, int gap_count) 316 int node_id, int generation, int gap_count)
326{ 317{
327 struct fw_phy_packet *p;
328 long timeout = DIV_ROUND_UP(HZ, 10); 318 long timeout = DIV_ROUND_UP(HZ, 10);
329 u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | 319 u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
330 PHY_CONFIG_ROOT_ID(node_id) | 320 PHY_CONFIG_ROOT_ID(node_id) |
331 PHY_CONFIG_GAP_COUNT(gap_count); 321 PHY_CONFIG_GAP_COUNT(gap_count);
332 322
333 p = kmalloc(sizeof(*p), GFP_KERNEL); 323 mutex_lock(&phy_config_mutex);
334 if (p == NULL) 324
335 return; 325 phy_config_packet.header[0] = data;
326 phy_config_packet.header[1] = ~data;
327 phy_config_packet.generation = generation;
328 INIT_COMPLETION(phy_config_done);
329
330 card->driver->send_request(card, &phy_config_packet);
331 wait_for_completion_timeout(&phy_config_done, timeout);
336 332
337 p->packet.header[0] = data; 333 mutex_unlock(&phy_config_mutex);
338 p->packet.header[1] = ~data;
339 p->packet.header_length = 8;
340 p->packet.payload_length = 0;
341 p->packet.speed = SCODE_100;
342 p->packet.generation = generation;
343 p->packet.callback = transmit_phy_packet_callback;
344 init_completion(&p->done);
345 kref_set(&p->kref, 2);
346
347 card->driver->send_request(card, &p->packet);
348 timeout = wait_for_completion_timeout(&p->done, timeout);
349 kref_put(&p->kref, phy_packet_release);
350
351 /* will leak p if the callback is never executed */
352 WARN_ON(timeout == 0);
353} 334}
354 335
355void fw_flush_transactions(struct fw_card *card) 336void fw_flush_transactions(struct fw_card *card)
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index c66817e7717b..50a071f1c945 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -245,7 +245,6 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
245static int smi_request(struct smi_cmd *smi_cmd) 245static int smi_request(struct smi_cmd *smi_cmd)
246{ 246{
247 cpumask_t old_mask; 247 cpumask_t old_mask;
248 cpumask_of_cpu_ptr(new_mask, 0);
249 int ret = 0; 248 int ret = 0;
250 249
251 if (smi_cmd->magic != SMI_CMD_MAGIC) { 250 if (smi_cmd->magic != SMI_CMD_MAGIC) {
@@ -256,7 +255,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
256 255
257 /* SMI requires CPU 0 */ 256 /* SMI requires CPU 0 */
258 old_mask = current->cpus_allowed; 257 old_mask = current->cpus_allowed;
259 set_cpus_allowed_ptr(current, new_mask); 258 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0));
260 if (smp_processor_id() != 0) { 259 if (smp_processor_id() != 0) {
261 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 260 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
262 __func__); 261 __func__);
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index e23399c7f773..001622eb86f9 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -153,12 +153,14 @@ int __init firmware_map_add_early(resource_size_t start, resource_size_t end,
153 153
154static ssize_t start_show(struct firmware_map_entry *entry, char *buf) 154static ssize_t start_show(struct firmware_map_entry *entry, char *buf)
155{ 155{
156 return snprintf(buf, PAGE_SIZE, "0x%llx\n", entry->start); 156 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
157 (unsigned long long)entry->start);
157} 158}
158 159
159static ssize_t end_show(struct firmware_map_entry *entry, char *buf) 160static ssize_t end_show(struct firmware_map_entry *entry, char *buf)
160{ 161{
161 return snprintf(buf, PAGE_SIZE, "0x%llx\n", entry->end); 162 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
163 (unsigned long long)entry->end);
162} 164}
163 165
164static ssize_t type_show(struct firmware_map_entry *entry, char *buf) 166static ssize_t type_show(struct firmware_map_entry *entry, char *buf)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 564138714bb5..452c2d866ec5 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -318,7 +318,7 @@ static void drm_cleanup(struct drm_device * dev)
318 DRM_ERROR("Cannot unload module\n"); 318 DRM_ERROR("Cannot unload module\n");
319} 319}
320 320
321int drm_minors_cleanup(int id, void *ptr, void *data) 321static int drm_minors_cleanup(int id, void *ptr, void *data)
322{ 322{
323 struct drm_minor *minor = ptr; 323 struct drm_minor *minor = ptr;
324 struct drm_device *dev; 324 struct drm_device *dev;
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 48d084bdf7c8..3c855ff2992f 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -49,6 +49,8 @@ struct bfin_twi_iface {
49 struct i2c_msg *pmsg; 49 struct i2c_msg *pmsg;
50 int msg_num; 50 int msg_num;
51 int cur_msg; 51 int cur_msg;
52 u16 saved_clkdiv;
53 u16 saved_control;
52 void __iomem *regs_base; 54 void __iomem *regs_base;
53}; 55};
54 56
@@ -565,32 +567,43 @@ static u32 bfin_twi_functionality(struct i2c_adapter *adap)
565 I2C_FUNC_I2C; 567 I2C_FUNC_I2C;
566} 568}
567 569
568
569static struct i2c_algorithm bfin_twi_algorithm = { 570static struct i2c_algorithm bfin_twi_algorithm = {
570 .master_xfer = bfin_twi_master_xfer, 571 .master_xfer = bfin_twi_master_xfer,
571 .smbus_xfer = bfin_twi_smbus_xfer, 572 .smbus_xfer = bfin_twi_smbus_xfer,
572 .functionality = bfin_twi_functionality, 573 .functionality = bfin_twi_functionality,
573}; 574};
574 575
575 576static int i2c_bfin_twi_suspend(struct platform_device *pdev, pm_message_t state)
576static int i2c_bfin_twi_suspend(struct platform_device *dev, pm_message_t state)
577{ 577{
578 struct bfin_twi_iface *iface = platform_get_drvdata(dev); 578 struct bfin_twi_iface *iface = platform_get_drvdata(pdev);
579
580 iface->saved_clkdiv = read_CLKDIV(iface);
581 iface->saved_control = read_CONTROL(iface);
582
583 free_irq(iface->irq, iface);
579 584
580 /* Disable TWI */ 585 /* Disable TWI */
581 write_CONTROL(iface, read_CONTROL(iface) & ~TWI_ENA); 586 write_CONTROL(iface, iface->saved_control & ~TWI_ENA);
582 SSYNC();
583 587
584 return 0; 588 return 0;
585} 589}
586 590
587static int i2c_bfin_twi_resume(struct platform_device *dev) 591static int i2c_bfin_twi_resume(struct platform_device *pdev)
588{ 592{
589 struct bfin_twi_iface *iface = platform_get_drvdata(dev); 593 struct bfin_twi_iface *iface = platform_get_drvdata(pdev);
590 594
591 /* Enable TWI */ 595 int rc = request_irq(iface->irq, bfin_twi_interrupt_entry,
592 write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); 596 IRQF_DISABLED, pdev->name, iface);
593 SSYNC(); 597 if (rc) {
598 dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq);
599 return -ENODEV;
600 }
601
602 /* Resume TWI interface clock as specified */
603 write_CLKDIV(iface, iface->saved_clkdiv);
604
605 /* Resume TWI */
606 write_CONTROL(iface, iface->saved_control);
594 607
595 return 0; 608 return 0;
596} 609}
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 79b455a1f090..32104eac8d3d 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -77,7 +77,7 @@ static int i2c_gpio_getscl(void *data)
77 return gpio_get_value(pdata->scl_pin); 77 return gpio_get_value(pdata->scl_pin);
78} 78}
79 79
80static int __init i2c_gpio_probe(struct platform_device *pdev) 80static int __devinit i2c_gpio_probe(struct platform_device *pdev)
81{ 81{
82 struct i2c_gpio_platform_data *pdata; 82 struct i2c_gpio_platform_data *pdata;
83 struct i2c_algo_bit_data *bit_data; 83 struct i2c_algo_bit_data *bit_data;
@@ -174,7 +174,7 @@ err_alloc_adap:
174 return ret; 174 return ret;
175} 175}
176 176
177static int __exit i2c_gpio_remove(struct platform_device *pdev) 177static int __devexit i2c_gpio_remove(struct platform_device *pdev)
178{ 178{
179 struct i2c_gpio_platform_data *pdata; 179 struct i2c_gpio_platform_data *pdata;
180 struct i2c_adapter *adap; 180 struct i2c_adapter *adap;
@@ -196,14 +196,15 @@ static struct platform_driver i2c_gpio_driver = {
196 .name = "i2c-gpio", 196 .name = "i2c-gpio",
197 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
198 }, 198 },
199 .remove = __exit_p(i2c_gpio_remove), 199 .probe = i2c_gpio_probe,
200 .remove = __devexit_p(i2c_gpio_remove),
200}; 201};
201 202
202static int __init i2c_gpio_init(void) 203static int __init i2c_gpio_init(void)
203{ 204{
204 int ret; 205 int ret;
205 206
206 ret = platform_driver_probe(&i2c_gpio_driver, i2c_gpio_probe); 207 ret = platform_driver_register(&i2c_gpio_driver);
207 if (ret) 208 if (ret)
208 printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); 209 printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret);
209 210
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 007390ad9810..4864723c7425 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -33,6 +33,7 @@
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/cpufreq.h>
36 37
37#include <asm/hardware.h> 38#include <asm/hardware.h>
38#include <asm/irq.h> 39#include <asm/irq.h>
@@ -64,6 +65,7 @@ struct s3c24xx_i2c {
64 unsigned int tx_setup; 65 unsigned int tx_setup;
65 66
66 enum s3c24xx_i2c_state state; 67 enum s3c24xx_i2c_state state;
68 unsigned long clkrate;
67 69
68 void __iomem *regs; 70 void __iomem *regs;
69 struct clk *clk; 71 struct clk *clk;
@@ -71,6 +73,10 @@ struct s3c24xx_i2c {
71 struct resource *irq; 73 struct resource *irq;
72 struct resource *ioarea; 74 struct resource *ioarea;
73 struct i2c_adapter adap; 75 struct i2c_adapter adap;
76
77#ifdef CONFIG_CPU_FREQ
78 struct notifier_block freq_transition;
79#endif
74}; 80};
75 81
76/* default platform data to use if not supplied in the platform_device 82/* default platform data to use if not supplied in the platform_device
@@ -501,6 +507,9 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
501 unsigned long timeout; 507 unsigned long timeout;
502 int ret; 508 int ret;
503 509
510 if (!readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN)
511 return -EIO;
512
504 ret = s3c24xx_i2c_set_master(i2c); 513 ret = s3c24xx_i2c_set_master(i2c);
505 if (ret != 0) { 514 if (ret != 0) {
506 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); 515 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret);
@@ -636,27 +645,28 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
636 return (diff >= -2 && diff <= 2); 645 return (diff >= -2 && diff <= 2);
637} 646}
638 647
639/* s3c24xx_i2c_getdivisor 648/* s3c24xx_i2c_clockrate
640 * 649 *
641 * work out a divisor for the user requested frequency setting, 650 * work out a divisor for the user requested frequency setting,
642 * either by the requested frequency, or scanning the acceptable 651 * either by the requested frequency, or scanning the acceptable
643 * range of frequencies until something is found 652 * range of frequencies until something is found
644*/ 653*/
645 654
646static int s3c24xx_i2c_getdivisor(struct s3c24xx_i2c *i2c, 655static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
647 struct s3c2410_platform_i2c *pdata,
648 unsigned long *iicon,
649 unsigned int *got)
650{ 656{
657 struct s3c2410_platform_i2c *pdata;
651 unsigned long clkin = clk_get_rate(i2c->clk); 658 unsigned long clkin = clk_get_rate(i2c->clk);
652
653 unsigned int divs, div1; 659 unsigned int divs, div1;
660 u32 iiccon;
654 int freq; 661 int freq;
655 int start, end; 662 int start, end;
656 663
664 i2c->clkrate = clkin;
665
666 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
657 clkin /= 1000; /* clkin now in KHz */ 667 clkin /= 1000; /* clkin now in KHz */
658 668
659 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", 669 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
660 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); 670 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
661 671
662 if (pdata->bus_freq != 0) { 672 if (pdata->bus_freq != 0) {
@@ -688,11 +698,79 @@ static int s3c24xx_i2c_getdivisor(struct s3c24xx_i2c *i2c,
688 698
689 found: 699 found:
690 *got = freq; 700 *got = freq;
691 *iicon |= (divs-1); 701
692 *iicon |= (div1 == 512) ? S3C2410_IICCON_TXDIV_512 : 0; 702 iiccon = readl(i2c->regs + S3C2410_IICCON);
703 iiccon &= ~(S3C2410_IICCON_SCALEMASK | S3C2410_IICCON_TXDIV_512);
704 iiccon |= (divs-1);
705
706 if (div1 == 512)
707 iiccon |= S3C2410_IICCON_TXDIV_512;
708
709 writel(iiccon, i2c->regs + S3C2410_IICCON);
710
711 return 0;
712}
713
714#ifdef CONFIG_CPU_FREQ
715
716#define freq_to_i2c(_n) container_of(_n, struct s3c24xx_i2c, freq_transition)
717
718static int s3c24xx_i2c_cpufreq_transition(struct notifier_block *nb,
719 unsigned long val, void *data)
720{
721 struct s3c24xx_i2c *i2c = freq_to_i2c(nb);
722 unsigned long flags;
723 unsigned int got;
724 int delta_f;
725 int ret;
726
727 delta_f = clk_get_rate(i2c->clk) - i2c->clkrate;
728
729 /* if we're post-change and the input clock has slowed down
730 * or at pre-change and the clock is about to speed up, then
731 * adjust our clock rate. <0 is slow, >0 speedup.
732 */
733
734 if ((val == CPUFREQ_POSTCHANGE && delta_f < 0) ||
735 (val == CPUFREQ_PRECHANGE && delta_f > 0)) {
736 spin_lock_irqsave(&i2c->lock, flags);
737 ret = s3c24xx_i2c_clockrate(i2c, &got);
738 spin_unlock_irqrestore(&i2c->lock, flags);
739
740 if (ret < 0)
741 dev_err(i2c->dev, "cannot find frequency\n");
742 else
743 dev_info(i2c->dev, "setting freq %d\n", got);
744 }
745
746 return 0;
747}
748
749static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c)
750{
751 i2c->freq_transition.notifier_call = s3c24xx_i2c_cpufreq_transition;
752
753 return cpufreq_register_notifier(&i2c->freq_transition,
754 CPUFREQ_TRANSITION_NOTIFIER);
755}
756
757static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
758{
759 cpufreq_unregister_notifier(&i2c->freq_transition,
760 CPUFREQ_TRANSITION_NOTIFIER);
761}
762
763#else
764static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c)
765{
693 return 0; 766 return 0;
694} 767}
695 768
769static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
770{
771}
772#endif
773
696/* s3c24xx_i2c_init 774/* s3c24xx_i2c_init
697 * 775 *
698 * initialise the controller, set the IO lines and frequency 776 * initialise the controller, set the IO lines and frequency
@@ -719,9 +797,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
719 797
720 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); 798 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
721 799
800 writel(iicon, i2c->regs + S3C2410_IICCON);
801
722 /* we need to work out the divisors for the clock... */ 802 /* we need to work out the divisors for the clock... */
723 803
724 if (s3c24xx_i2c_getdivisor(i2c, pdata, &iicon, &freq) != 0) { 804 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) {
805 writel(0, i2c->regs + S3C2410_IICCON);
725 dev_err(i2c->dev, "cannot meet bus frequency required\n"); 806 dev_err(i2c->dev, "cannot meet bus frequency required\n");
726 return -EINVAL; 807 return -EINVAL;
727 } 808 }
@@ -730,8 +811,6 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
730 811
731 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); 812 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq);
732 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon); 813 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon);
733
734 writel(iicon, i2c->regs + S3C2410_IICCON);
735 814
736 /* check for s3c2440 i2c controller */ 815 /* check for s3c2440 i2c controller */
737 816
@@ -752,9 +831,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
752static int s3c24xx_i2c_probe(struct platform_device *pdev) 831static int s3c24xx_i2c_probe(struct platform_device *pdev)
753{ 832{
754 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 833 struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
834 struct s3c2410_platform_i2c *pdata;
755 struct resource *res; 835 struct resource *res;
756 int ret; 836 int ret;
757 837
838 pdata = s3c24xx_i2c_get_platformdata(&pdev->dev);
839
758 /* find the clock and enable it */ 840 /* find the clock and enable it */
759 841
760 i2c->dev = &pdev->dev; 842 i2c->dev = &pdev->dev;
@@ -832,17 +914,34 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
832 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res, 914 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
833 (unsigned long)res->start); 915 (unsigned long)res->start);
834 916
835 ret = i2c_add_adapter(&i2c->adap); 917 ret = s3c24xx_i2c_register_cpufreq(i2c);
836 if (ret < 0) { 918 if (ret < 0) {
837 dev_err(&pdev->dev, "failed to add bus to i2c core\n"); 919 dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
838 goto err_irq; 920 goto err_irq;
839 } 921 }
840 922
923 /* Note, previous versions of the driver used i2c_add_adapter()
924 * to add the bus at any number. We now pass the bus number via
925 * the platform data, so if unset it will now default to always
926 * being bus 0.
927 */
928
929 i2c->adap.nr = pdata->bus_num;
930
931 ret = i2c_add_numbered_adapter(&i2c->adap);
932 if (ret < 0) {
933 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
934 goto err_cpufreq;
935 }
936
841 platform_set_drvdata(pdev, i2c); 937 platform_set_drvdata(pdev, i2c);
842 938
843 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 939 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
844 return 0; 940 return 0;
845 941
942 err_cpufreq:
943 s3c24xx_i2c_deregister_cpufreq(i2c);
944
846 err_irq: 945 err_irq:
847 free_irq(i2c->irq->start, i2c); 946 free_irq(i2c->irq->start, i2c);
848 947
@@ -870,6 +969,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
870{ 969{
871 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); 970 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
872 971
972 s3c24xx_i2c_deregister_cpufreq(i2c);
973
873 i2c_del_adapter(&i2c->adap); 974 i2c_del_adapter(&i2c->adap);
874 free_irq(i2c->irq->start, i2c); 975 free_irq(i2c->irq->start, i2c);
875 976
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 9494005d1c9a..e603736682bf 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -43,7 +43,6 @@
43#include <linux/cdev.h> 43#include <linux/cdev.h>
44#include <linux/idr.h> 44#include <linux/idr.h>
45#include <linux/mutex.h> 45#include <linux/mutex.h>
46#include <linux/smp_lock.h>
47 46
48#include <asm/uaccess.h> 47#include <asm/uaccess.h>
49 48
@@ -1154,11 +1153,18 @@ static unsigned int ib_ucm_poll(struct file *filp,
1154 return mask; 1153 return mask;
1155} 1154}
1156 1155
1156/*
1157 * ib_ucm_open() does not need the BKL:
1158 *
1159 * - no global state is referred to;
1160 * - there is no ioctl method to race against;
1161 * - no further module initialization is required for open to work
1162 * after the device is registered.
1163 */
1157static int ib_ucm_open(struct inode *inode, struct file *filp) 1164static int ib_ucm_open(struct inode *inode, struct file *filp)
1158{ 1165{
1159 struct ib_ucm_file *file; 1166 struct ib_ucm_file *file;
1160 1167
1161 cycle_kernel_lock();
1162 file = kmalloc(sizeof(*file), GFP_KERNEL); 1168 file = kmalloc(sizeof(*file), GFP_KERNEL);
1163 if (!file) 1169 if (!file)
1164 return -ENOMEM; 1170 return -ENOMEM;
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 195f97302fe5..b41dd26bbfa1 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -38,7 +38,6 @@
38#include <linux/in.h> 38#include <linux/in.h>
39#include <linux/in6.h> 39#include <linux/in6.h>
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/smp_lock.h>
42 41
43#include <rdma/rdma_user_cm.h> 42#include <rdma/rdma_user_cm.h>
44#include <rdma/ib_marshall.h> 43#include <rdma/ib_marshall.h>
@@ -1149,6 +1148,14 @@ static unsigned int ucma_poll(struct file *filp, struct poll_table_struct *wait)
1149 return mask; 1148 return mask;
1150} 1149}
1151 1150
1151/*
1152 * ucma_open() does not need the BKL:
1153 *
1154 * - no global state is referred to;
1155 * - there is no ioctl method to race against;
1156 * - no further module initialization is required for open to work
1157 * after the device is registered.
1158 */
1152static int ucma_open(struct inode *inode, struct file *filp) 1159static int ucma_open(struct inode *inode, struct file *filp)
1153{ 1160{
1154 struct ucma_file *file; 1161 struct ucma_file *file;
@@ -1157,7 +1164,6 @@ static int ucma_open(struct inode *inode, struct file *filp)
1157 if (!file) 1164 if (!file)
1158 return -ENOMEM; 1165 return -ENOMEM;
1159 1166
1160 lock_kernel();
1161 INIT_LIST_HEAD(&file->event_list); 1167 INIT_LIST_HEAD(&file->event_list);
1162 INIT_LIST_HEAD(&file->ctx_list); 1168 INIT_LIST_HEAD(&file->ctx_list);
1163 init_waitqueue_head(&file->poll_wait); 1169 init_waitqueue_head(&file->poll_wait);
@@ -1165,7 +1171,6 @@ static int ucma_open(struct inode *inode, struct file *filp)
1165 1171
1166 filp->private_data = file; 1172 filp->private_data = file;
1167 file->filp = filp; 1173 file->filp = filp;
1168 unlock_kernel();
1169 return 0; 1174 return 0;
1170} 1175}
1171 1176
diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
index eaba03273e4f..284c9bca517e 100644
--- a/drivers/infiniband/hw/ipath/ipath_sdma.c
+++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
@@ -698,7 +698,7 @@ retry:
698 698
699 addr = dma_map_single(&dd->pcidev->dev, tx->txreq.map_addr, 699 addr = dma_map_single(&dd->pcidev->dev, tx->txreq.map_addr,
700 tx->map_len, DMA_TO_DEVICE); 700 tx->map_len, DMA_TO_DEVICE);
701 if (dma_mapping_error(addr)) { 701 if (dma_mapping_error(&dd->pcidev->dev, addr)) {
702 ret = -EIO; 702 ret = -EIO;
703 goto unlock; 703 goto unlock;
704 } 704 }
diff --git a/drivers/infiniband/hw/ipath/ipath_user_sdma.c b/drivers/infiniband/hw/ipath/ipath_user_sdma.c
index 86e016916cd1..82d9a0b5ca2f 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_sdma.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_sdma.c
@@ -206,7 +206,7 @@ static int ipath_user_sdma_coalesce(const struct ipath_devdata *dd,
206 206
207 dma_addr = dma_map_page(&dd->pcidev->dev, page, 0, len, 207 dma_addr = dma_map_page(&dd->pcidev->dev, page, 0, len,
208 DMA_TO_DEVICE); 208 DMA_TO_DEVICE);
209 if (dma_mapping_error(dma_addr)) { 209 if (dma_mapping_error(&dd->pcidev->dev, dma_addr)) {
210 ret = -ENOMEM; 210 ret = -ENOMEM;
211 goto free_unmap; 211 goto free_unmap;
212 } 212 }
@@ -301,7 +301,7 @@ static int ipath_user_sdma_pin_pages(const struct ipath_devdata *dd,
301 pages[j], 0, flen, DMA_TO_DEVICE); 301 pages[j], 0, flen, DMA_TO_DEVICE);
302 unsigned long fofs = addr & ~PAGE_MASK; 302 unsigned long fofs = addr & ~PAGE_MASK;
303 303
304 if (dma_mapping_error(dma_addr)) { 304 if (dma_mapping_error(&dd->pcidev->dev, dma_addr)) {
305 ret = -ENOMEM; 305 ret = -ENOMEM;
306 goto done; 306 goto done;
307 } 307 }
@@ -508,7 +508,7 @@ static int ipath_user_sdma_queue_pkts(const struct ipath_devdata *dd,
508 if (page) { 508 if (page) {
509 dma_addr = dma_map_page(&dd->pcidev->dev, 509 dma_addr = dma_map_page(&dd->pcidev->dev,
510 page, 0, len, DMA_TO_DEVICE); 510 page, 0, len, DMA_TO_DEVICE);
511 if (dma_mapping_error(dma_addr)) { 511 if (dma_mapping_error(&dd->pcidev->dev, dma_addr)) {
512 ret = -ENOMEM; 512 ret = -ENOMEM;
513 goto free_pbc; 513 goto free_pbc;
514 } 514 }
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 0b191a4842ce..a1464574bfdd 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 38d6907ab521..a3c2851c0545 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index d26a91317d4d..6e2b0dc21b61 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index db2086faa4ed..a4cdb465cd1d 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 02a99bc4442e..f7bc7dd8578a 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
index 12d6bc6f8007..d42565258fb7 100644
--- a/drivers/infiniband/hw/mlx4/srq.c
+++ b/drivers/infiniband/hw/mlx4/srq.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mlx4/user.h b/drivers/infiniband/hw/mlx4/user.h
index e2d11be4525c..13beedeeef9f 100644
--- a/drivers/infiniband/hw/mlx4/user.h
+++ b/drivers/infiniband/hw/mlx4/user.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 4e36aa7cb3d2..cc6858f0b65b 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -780,7 +780,7 @@ int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt)
780 return -ENOMEM; 780 return -ENOMEM;
781 dev->eq_table.icm_dma = pci_map_page(dev->pdev, dev->eq_table.icm_page, 0, 781 dev->eq_table.icm_dma = pci_map_page(dev->pdev, dev->eq_table.icm_page, 0,
782 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 782 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
783 if (pci_dma_mapping_error(dev->eq_table.icm_dma)) { 783 if (pci_dma_mapping_error(dev->pdev, dev->eq_table.icm_dma)) {
784 __free_page(dev->eq_table.icm_page); 784 __free_page(dev->eq_table.icm_page);
785 return -ENOMEM; 785 return -ENOMEM;
786 } 786 }
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index d2884e778098..b0cab64e5e3d 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -276,6 +276,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
276 } 276 }
277 nes_free_resource(nesadapter, nesadapter->allocated_qps, nesqp->hwqp.qp_id); 277 nes_free_resource(nesadapter, nesadapter->allocated_qps, nesqp->hwqp.qp_id);
278 278
279 nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL;
279 kfree(nesqp->allocated_buffer); 280 kfree(nesqp->allocated_buffer);
280 281
281} 282}
@@ -289,7 +290,6 @@ void nes_rem_ref(struct ib_qp *ibqp)
289 struct nes_qp *nesqp; 290 struct nes_qp *nesqp;
290 struct nes_vnic *nesvnic = to_nesvnic(ibqp->device); 291 struct nes_vnic *nesvnic = to_nesvnic(ibqp->device);
291 struct nes_device *nesdev = nesvnic->nesdev; 292 struct nes_device *nesdev = nesvnic->nesdev;
292 struct nes_adapter *nesadapter = nesdev->nesadapter;
293 struct nes_hw_cqp_wqe *cqp_wqe; 293 struct nes_hw_cqp_wqe *cqp_wqe;
294 struct nes_cqp_request *cqp_request; 294 struct nes_cqp_request *cqp_request;
295 u32 opcode; 295 u32 opcode;
@@ -303,8 +303,6 @@ void nes_rem_ref(struct ib_qp *ibqp)
303 } 303 }
304 304
305 if (atomic_dec_and_test(&nesqp->refcount)) { 305 if (atomic_dec_and_test(&nesqp->refcount)) {
306 nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL;
307
308 /* Destroy the QP */ 306 /* Destroy the QP */
309 cqp_request = nes_get_cqp_request(nesdev); 307 cqp_request = nes_get_cqp_request(nesdev);
310 if (cqp_request == NULL) { 308 if (cqp_request == NULL) {
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 6aa531d5276d..9f0b964b2c99 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -74,36 +74,59 @@ atomic_t cm_nodes_destroyed;
74atomic_t cm_accel_dropped_pkts; 74atomic_t cm_accel_dropped_pkts;
75atomic_t cm_resets_recvd; 75atomic_t cm_resets_recvd;
76 76
77static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *); 77static inline int mini_cm_accelerated(struct nes_cm_core *,
78 struct nes_cm_node *);
78static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, 79static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *,
79 struct nes_vnic *, struct nes_cm_info *); 80 struct nes_vnic *, struct nes_cm_info *);
80static int add_ref_cm_node(struct nes_cm_node *);
81static int rem_ref_cm_node(struct nes_cm_core *, struct nes_cm_node *);
82static int mini_cm_del_listen(struct nes_cm_core *, struct nes_cm_listener *); 81static int mini_cm_del_listen(struct nes_cm_core *, struct nes_cm_listener *);
83static struct sk_buff *form_cm_frame(struct sk_buff *, struct nes_cm_node *,
84 void *, u32, void *, u32, u8);
85static struct sk_buff *get_free_pkt(struct nes_cm_node *cm_node);
86
87static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *, 82static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *,
88 struct nes_vnic *, 83 struct nes_vnic *, u16, void *, struct nes_cm_info *);
89 struct ietf_mpa_frame *, 84static int mini_cm_close(struct nes_cm_core *, struct nes_cm_node *);
90 struct nes_cm_info *);
91static int mini_cm_accept(struct nes_cm_core *, struct ietf_mpa_frame *, 85static int mini_cm_accept(struct nes_cm_core *, struct ietf_mpa_frame *,
92 struct nes_cm_node *); 86 struct nes_cm_node *);
93static int mini_cm_reject(struct nes_cm_core *, struct ietf_mpa_frame *, 87static int mini_cm_reject(struct nes_cm_core *, struct ietf_mpa_frame *,
94 struct nes_cm_node *); 88 struct nes_cm_node *);
95static int mini_cm_close(struct nes_cm_core *, struct nes_cm_node *); 89static void mini_cm_recv_pkt(struct nes_cm_core *, struct nes_vnic *,
96static int mini_cm_recv_pkt(struct nes_cm_core *, struct nes_vnic *, 90 struct sk_buff *);
97 struct sk_buff *);
98static int mini_cm_dealloc_core(struct nes_cm_core *); 91static int mini_cm_dealloc_core(struct nes_cm_core *);
99static int mini_cm_get(struct nes_cm_core *); 92static int mini_cm_get(struct nes_cm_core *);
100static int mini_cm_set(struct nes_cm_core *, u32, u32); 93static int mini_cm_set(struct nes_cm_core *, u32, u32);
94
95static struct sk_buff *form_cm_frame(struct sk_buff *, struct nes_cm_node *,
96 void *, u32, void *, u32, u8);
97static struct sk_buff *get_free_pkt(struct nes_cm_node *cm_node);
98static int add_ref_cm_node(struct nes_cm_node *);
99static int rem_ref_cm_node(struct nes_cm_core *, struct nes_cm_node *);
100
101static int nes_cm_disconn_true(struct nes_qp *); 101static int nes_cm_disconn_true(struct nes_qp *);
102static int nes_cm_post_event(struct nes_cm_event *event); 102static int nes_cm_post_event(struct nes_cm_event *event);
103static int nes_disconnect(struct nes_qp *nesqp, int abrupt); 103static int nes_disconnect(struct nes_qp *nesqp, int abrupt);
104static void nes_disconnect_worker(struct work_struct *work); 104static void nes_disconnect_worker(struct work_struct *work);
105static int send_ack(struct nes_cm_node *cm_node); 105
106static int send_mpa_request(struct nes_cm_node *, struct sk_buff *);
107static int send_syn(struct nes_cm_node *, u32, struct sk_buff *);
108static int send_reset(struct nes_cm_node *, struct sk_buff *);
109static int send_ack(struct nes_cm_node *cm_node, struct sk_buff *skb);
106static int send_fin(struct nes_cm_node *cm_node, struct sk_buff *skb); 110static int send_fin(struct nes_cm_node *cm_node, struct sk_buff *skb);
111static void process_packet(struct nes_cm_node *, struct sk_buff *,
112 struct nes_cm_core *);
113
114static void active_open_err(struct nes_cm_node *, struct sk_buff *, int);
115static void passive_open_err(struct nes_cm_node *, struct sk_buff *, int);
116static void cleanup_retrans_entry(struct nes_cm_node *);
117static void handle_rcv_mpa(struct nes_cm_node *, struct sk_buff *,
118 enum nes_cm_event_type);
119static void free_retrans_entry(struct nes_cm_node *cm_node);
120static int handle_tcp_options(struct nes_cm_node *cm_node, struct tcphdr *tcph,
121 struct sk_buff *skb, int optionsize, int passive);
122
123/* CM event handler functions */
124static void cm_event_connected(struct nes_cm_event *);
125static void cm_event_connect_error(struct nes_cm_event *);
126static void cm_event_reset(struct nes_cm_event *);
127static void cm_event_mpa_req(struct nes_cm_event *);
128
129static void print_core(struct nes_cm_core *core);
107 130
108/* External CM API Interface */ 131/* External CM API Interface */
109/* instance of function pointers for client API */ 132/* instance of function pointers for client API */
@@ -158,11 +181,11 @@ static struct nes_cm_event *create_event(struct nes_cm_node *cm_node,
158 event->cm_info.loc_port = cm_node->loc_port; 181 event->cm_info.loc_port = cm_node->loc_port;
159 event->cm_info.cm_id = cm_node->cm_id; 182 event->cm_info.cm_id = cm_node->cm_id;
160 183
161 nes_debug(NES_DBG_CM, "Created event=%p, type=%u, dst_addr=%08x[%x]," 184 nes_debug(NES_DBG_CM, "cm_node=%p Created event=%p, type=%u, "
162 " src_addr=%08x[%x]\n", 185 "dst_addr=%08x[%x], src_addr=%08x[%x]\n",
163 event, type, 186 cm_node, event, type, event->cm_info.loc_addr,
164 event->cm_info.loc_addr, event->cm_info.loc_port, 187 event->cm_info.loc_port, event->cm_info.rem_addr,
165 event->cm_info.rem_addr, event->cm_info.rem_port); 188 event->cm_info.rem_port);
166 189
167 nes_cm_post_event(event); 190 nes_cm_post_event(event);
168 return event; 191 return event;
@@ -172,14 +195,11 @@ static struct nes_cm_event *create_event(struct nes_cm_node *cm_node,
172/** 195/**
173 * send_mpa_request 196 * send_mpa_request
174 */ 197 */
175static int send_mpa_request(struct nes_cm_node *cm_node) 198static int send_mpa_request(struct nes_cm_node *cm_node, struct sk_buff *skb)
176{ 199{
177 struct sk_buff *skb;
178 int ret; 200 int ret;
179
180 skb = get_free_pkt(cm_node);
181 if (!skb) { 201 if (!skb) {
182 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 202 nes_debug(NES_DBG_CM, "skb set to NULL\n");
183 return -1; 203 return -1;
184 } 204 }
185 205
@@ -188,9 +208,8 @@ static int send_mpa_request(struct nes_cm_node *cm_node)
188 cm_node->mpa_frame_size, SET_ACK); 208 cm_node->mpa_frame_size, SET_ACK);
189 209
190 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 1, 0); 210 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 1, 0);
191 if (ret < 0) { 211 if (ret < 0)
192 return ret; 212 return ret;
193 }
194 213
195 return 0; 214 return 0;
196} 215}
@@ -229,46 +248,12 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 len)
229 248
230 249
231/** 250/**
232 * handle_exception_pkt - process an exception packet.
233 * We have been in a TSA state, and we have now received SW
234 * TCP/IP traffic should be a FIN request or IP pkt with options
235 */
236static int handle_exception_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb)
237{
238 int ret = 0;
239 struct tcphdr *tcph = tcp_hdr(skb);
240
241 /* first check to see if this a FIN pkt */
242 if (tcph->fin) {
243 /* we need to ACK the FIN request */
244 send_ack(cm_node);
245
246 /* check which side we are (client/server) and set next state accordingly */
247 if (cm_node->tcp_cntxt.client)
248 cm_node->state = NES_CM_STATE_CLOSING;
249 else {
250 /* we are the server side */
251 cm_node->state = NES_CM_STATE_CLOSE_WAIT;
252 /* since this is a self contained CM we don't wait for */
253 /* an APP to close us, just send final FIN immediately */
254 ret = send_fin(cm_node, NULL);
255 cm_node->state = NES_CM_STATE_LAST_ACK;
256 }
257 } else {
258 ret = -EINVAL;
259 }
260
261 return ret;
262}
263
264
265/**
266 * form_cm_frame - get a free packet and build empty frame Use 251 * form_cm_frame - get a free packet and build empty frame Use
267 * node info to build. 252 * node info to build.
268 */ 253 */
269static struct sk_buff *form_cm_frame(struct sk_buff *skb, struct nes_cm_node *cm_node, 254static struct sk_buff *form_cm_frame(struct sk_buff *skb,
270 void *options, u32 optionsize, void *data, 255 struct nes_cm_node *cm_node, void *options, u32 optionsize,
271 u32 datasize, u8 flags) 256 void *data, u32 datasize, u8 flags)
272{ 257{
273 struct tcphdr *tcph; 258 struct tcphdr *tcph;
274 struct iphdr *iph; 259 struct iphdr *iph;
@@ -332,10 +317,12 @@ static struct sk_buff *form_cm_frame(struct sk_buff *skb, struct nes_cm_node *cm
332 cm_node->tcp_cntxt.loc_seq_num++; 317 cm_node->tcp_cntxt.loc_seq_num++;
333 tcph->syn = 1; 318 tcph->syn = 1;
334 } else 319 } else
335 cm_node->tcp_cntxt.loc_seq_num += datasize; /* data (no headers) */ 320 cm_node->tcp_cntxt.loc_seq_num += datasize;
336 321
337 if (flags & SET_FIN) 322 if (flags & SET_FIN) {
323 cm_node->tcp_cntxt.loc_seq_num++;
338 tcph->fin = 1; 324 tcph->fin = 1;
325 }
339 326
340 if (flags & SET_RST) 327 if (flags & SET_RST)
341 tcph->rst = 1; 328 tcph->rst = 1;
@@ -389,7 +376,7 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb,
389 int close_when_complete) 376 int close_when_complete)
390{ 377{
391 unsigned long flags; 378 unsigned long flags;
392 struct nes_cm_core *cm_core; 379 struct nes_cm_core *cm_core = cm_node->cm_core;
393 struct nes_timer_entry *new_send; 380 struct nes_timer_entry *new_send;
394 int ret = 0; 381 int ret = 0;
395 u32 was_timer_set; 382 u32 was_timer_set;
@@ -411,7 +398,7 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb,
411 new_send->close_when_complete = close_when_complete; 398 new_send->close_when_complete = close_when_complete;
412 399
413 if (type == NES_TIMER_TYPE_CLOSE) { 400 if (type == NES_TIMER_TYPE_CLOSE) {
414 new_send->timetosend += (HZ/2); /* TODO: decide on the correct value here */ 401 new_send->timetosend += (HZ/10);
415 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 402 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
416 list_add_tail(&new_send->list, &cm_node->recv_list); 403 list_add_tail(&new_send->list, &cm_node->recv_list);
417 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 404 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags);
@@ -420,36 +407,28 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb,
420 if (type == NES_TIMER_TYPE_SEND) { 407 if (type == NES_TIMER_TYPE_SEND) {
421 new_send->seq_num = ntohl(tcp_hdr(skb)->seq); 408 new_send->seq_num = ntohl(tcp_hdr(skb)->seq);
422 atomic_inc(&new_send->skb->users); 409 atomic_inc(&new_send->skb->users);
410 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
411 cm_node->send_entry = new_send;
412 add_ref_cm_node(cm_node);
413 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
414 new_send->timetosend = jiffies + NES_RETRY_TIMEOUT;
423 415
424 ret = nes_nic_cm_xmit(new_send->skb, cm_node->netdev); 416 ret = nes_nic_cm_xmit(new_send->skb, cm_node->netdev);
425 if (ret != NETDEV_TX_OK) { 417 if (ret != NETDEV_TX_OK) {
426 nes_debug(NES_DBG_CM, "Error sending packet %p (jiffies = %lu)\n", 418 nes_debug(NES_DBG_CM, "Error sending packet %p "
427 new_send, jiffies); 419 "(jiffies = %lu)\n", new_send, jiffies);
428 atomic_dec(&new_send->skb->users); 420 atomic_dec(&new_send->skb->users);
429 new_send->timetosend = jiffies; 421 new_send->timetosend = jiffies;
430 } else { 422 } else {
431 cm_packets_sent++; 423 cm_packets_sent++;
432 if (!send_retrans) { 424 if (!send_retrans) {
425 cleanup_retrans_entry(cm_node);
433 if (close_when_complete) 426 if (close_when_complete)
434 rem_ref_cm_node(cm_node->cm_core, cm_node); 427 rem_ref_cm_node(cm_core, cm_node);
435 dev_kfree_skb_any(new_send->skb);
436 kfree(new_send);
437 return ret; 428 return ret;
438 } 429 }
439 new_send->timetosend = jiffies + NES_RETRY_TIMEOUT;
440 } 430 }
441 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
442 list_add_tail(&new_send->list, &cm_node->retrans_list);
443 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
444 }
445 if (type == NES_TIMER_TYPE_RECV) {
446 new_send->seq_num = ntohl(tcp_hdr(skb)->seq);
447 new_send->timetosend = jiffies;
448 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
449 list_add_tail(&new_send->list, &cm_node->recv_list);
450 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags);
451 } 431 }
452 cm_core = cm_node->cm_core;
453 432
454 was_timer_set = timer_pending(&cm_core->tcp_timer); 433 was_timer_set = timer_pending(&cm_core->tcp_timer);
455 434
@@ -476,23 +455,27 @@ static void nes_cm_timer_tick(unsigned long pass)
476 struct list_head *list_node, *list_node_temp; 455 struct list_head *list_node, *list_node_temp;
477 struct nes_cm_core *cm_core = g_cm_core; 456 struct nes_cm_core *cm_core = g_cm_core;
478 struct nes_qp *nesqp; 457 struct nes_qp *nesqp;
479 struct sk_buff *skb;
480 u32 settimer = 0; 458 u32 settimer = 0;
481 int ret = NETDEV_TX_OK; 459 int ret = NETDEV_TX_OK;
482 int node_done; 460 enum nes_cm_node_state last_state;
483 461
484 spin_lock_irqsave(&cm_core->ht_lock, flags); 462 spin_lock_irqsave(&cm_core->ht_lock, flags);
485 463
486 list_for_each_safe(list_node, list_core_temp, &cm_core->connected_nodes) { 464 list_for_each_safe(list_node, list_core_temp,
465 &cm_core->connected_nodes) {
487 cm_node = container_of(list_node, struct nes_cm_node, list); 466 cm_node = container_of(list_node, struct nes_cm_node, list);
488 add_ref_cm_node(cm_node); 467 add_ref_cm_node(cm_node);
489 spin_unlock_irqrestore(&cm_core->ht_lock, flags); 468 spin_unlock_irqrestore(&cm_core->ht_lock, flags);
490 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 469 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
491 list_for_each_safe(list_core, list_node_temp, &cm_node->recv_list) { 470 list_for_each_safe(list_core, list_node_temp,
492 recv_entry = container_of(list_core, struct nes_timer_entry, list); 471 &cm_node->recv_list) {
493 if ((time_after(recv_entry->timetosend, jiffies)) && 472 recv_entry = container_of(list_core,
494 (recv_entry->type == NES_TIMER_TYPE_CLOSE)) { 473 struct nes_timer_entry, list);
495 if (nexttimeout > recv_entry->timetosend || !settimer) { 474 if (!recv_entry)
475 break;
476 if (time_after(recv_entry->timetosend, jiffies)) {
477 if (nexttimeout > recv_entry->timetosend ||
478 !settimer) {
496 nexttimeout = recv_entry->timetosend; 479 nexttimeout = recv_entry->timetosend;
497 settimer = 1; 480 settimer = 1;
498 } 481 }
@@ -501,157 +484,143 @@ static void nes_cm_timer_tick(unsigned long pass)
501 list_del(&recv_entry->list); 484 list_del(&recv_entry->list);
502 cm_id = cm_node->cm_id; 485 cm_id = cm_node->cm_id;
503 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 486 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags);
504 if (recv_entry->type == NES_TIMER_TYPE_CLOSE) { 487 nesqp = (struct nes_qp *)recv_entry->skb;
505 nesqp = (struct nes_qp *)recv_entry->skb; 488 spin_lock_irqsave(&nesqp->lock, qplockflags);
506 spin_lock_irqsave(&nesqp->lock, qplockflags); 489 if (nesqp->cm_id) {
507 if (nesqp->cm_id) { 490 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, "
508 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, refcount = %d: " 491 "refcount = %d: HIT A "
509 "****** HIT A NES_TIMER_TYPE_CLOSE" 492 "NES_TIMER_TYPE_CLOSE with something "
510 " with something to do!!! ******\n", 493 "to do!!!\n", nesqp->hwqp.qp_id, cm_id,
511 nesqp->hwqp.qp_id, cm_id, 494 atomic_read(&nesqp->refcount));
512 atomic_read(&nesqp->refcount)); 495 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED;
513 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 496 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT;
514 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 497 nesqp->ibqp_state = IB_QPS_ERR;
515 nesqp->ibqp_state = IB_QPS_ERR; 498 spin_unlock_irqrestore(&nesqp->lock,
516 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 499 qplockflags);
517 nes_cm_disconn(nesqp); 500 nes_cm_disconn(nesqp);
518 } else { 501 } else {
519 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 502 spin_unlock_irqrestore(&nesqp->lock,
520 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, refcount = %d:" 503 qplockflags);
521 " ****** HIT A NES_TIMER_TYPE_CLOSE" 504 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p, "
522 " with nothing to do!!! ******\n", 505 "refcount = %d: HIT A "
523 nesqp->hwqp.qp_id, cm_id, 506 "NES_TIMER_TYPE_CLOSE with nothing "
524 atomic_read(&nesqp->refcount)); 507 "to do!!!\n", nesqp->hwqp.qp_id, cm_id,
525 nes_rem_ref(&nesqp->ibqp); 508 atomic_read(&nesqp->refcount));
526 }
527 if (cm_id)
528 cm_id->rem_ref(cm_id);
529 } 509 }
510 if (cm_id)
511 cm_id->rem_ref(cm_id);
512
530 kfree(recv_entry); 513 kfree(recv_entry);
531 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 514 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
532 } 515 }
533 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 516 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags);
534 517
535 spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 518 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
536 node_done = 0; 519 do {
537 list_for_each_safe(list_core, list_node_temp, &cm_node->retrans_list) { 520 send_entry = cm_node->send_entry;
538 if (node_done) { 521 if (!send_entry)
539 break; 522 continue;
540 }
541 send_entry = container_of(list_core, struct nes_timer_entry, list);
542 if (time_after(send_entry->timetosend, jiffies)) { 523 if (time_after(send_entry->timetosend, jiffies)) {
543 if (cm_node->state != NES_CM_STATE_TSA) { 524 if (cm_node->state != NES_CM_STATE_TSA) {
544 if ((nexttimeout > send_entry->timetosend) || !settimer) { 525 if ((nexttimeout >
545 nexttimeout = send_entry->timetosend; 526 send_entry->timetosend) ||
527 !settimer) {
528 nexttimeout =
529 send_entry->timetosend;
546 settimer = 1; 530 settimer = 1;
531 continue;
547 } 532 }
548 node_done = 1;
549 continue;
550 } else { 533 } else {
551 list_del(&send_entry->list); 534 free_retrans_entry(cm_node);
552 skb = send_entry->skb;
553 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
554 dev_kfree_skb_any(skb);
555 kfree(send_entry);
556 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
557 continue; 535 continue;
558 } 536 }
559 } 537 }
560 if (send_entry->type == NES_TIMER_NODE_CLEANUP) { 538
561 list_del(&send_entry->list); 539 if ((cm_node->state == NES_CM_STATE_TSA) ||
562 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 540 (cm_node->state == NES_CM_STATE_CLOSED)) {
563 kfree(send_entry); 541 free_retrans_entry(cm_node);
564 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
565 continue;
566 }
567 if ((send_entry->seq_num < cm_node->tcp_cntxt.rem_ack_num) ||
568 (cm_node->state == NES_CM_STATE_TSA) ||
569 (cm_node->state == NES_CM_STATE_CLOSED)) {
570 skb = send_entry->skb;
571 list_del(&send_entry->list);
572 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
573 kfree(send_entry);
574 dev_kfree_skb_any(skb);
575 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
576 continue; 542 continue;
577 } 543 }
578 544
579 if (!send_entry->retranscount || !send_entry->retrycount) { 545 if (!send_entry->retranscount ||
546 !send_entry->retrycount) {
580 cm_packets_dropped++; 547 cm_packets_dropped++;
581 skb = send_entry->skb; 548 last_state = cm_node->state;
582 list_del(&send_entry->list); 549 cm_node->state = NES_CM_STATE_CLOSED;
583 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 550 free_retrans_entry(cm_node);
584 dev_kfree_skb_any(skb); 551 spin_unlock_irqrestore(
585 kfree(send_entry); 552 &cm_node->retrans_list_lock, flags);
586 if (cm_node->state == NES_CM_STATE_SYN_RCVD) { 553 if (last_state == NES_CM_STATE_SYN_RCVD)
587 /* this node never even generated an indication up to the cm */
588 rem_ref_cm_node(cm_core, cm_node); 554 rem_ref_cm_node(cm_core, cm_node);
589 } else { 555 else
590 cm_node->state = NES_CM_STATE_CLOSED; 556 create_event(cm_node,
591 create_event(cm_node, NES_CM_EVENT_ABORTED); 557 NES_CM_EVENT_ABORTED);
592 } 558 spin_lock_irqsave(&cm_node->retrans_list_lock,
593 spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 559 flags);
594 continue; 560 continue;
595 } 561 }
596 /* this seems like the correct place, but leave send entry unprotected */
597 /* spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); */
598 atomic_inc(&send_entry->skb->users); 562 atomic_inc(&send_entry->skb->users);
599 cm_packets_retrans++; 563 cm_packets_retrans++;
600 nes_debug(NES_DBG_CM, "Retransmitting send_entry %p for node %p," 564 nes_debug(NES_DBG_CM, "Retransmitting send_entry %p "
601 " jiffies = %lu, time to send = %lu, retranscount = %u, " 565 "for node %p, jiffies = %lu, time to send = "
602 "send_entry->seq_num = 0x%08X, cm_node->tcp_cntxt.rem_ack_num = 0x%08X\n", 566 "%lu, retranscount = %u, send_entry->seq_num = "
603 send_entry, cm_node, jiffies, send_entry->timetosend, send_entry->retranscount, 567 "0x%08X, cm_node->tcp_cntxt.rem_ack_num = "
604 send_entry->seq_num, cm_node->tcp_cntxt.rem_ack_num); 568 "0x%08X\n", send_entry, cm_node, jiffies,
605 569 send_entry->timetosend,
606 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 570 send_entry->retranscount,
571 send_entry->seq_num,
572 cm_node->tcp_cntxt.rem_ack_num);
573
574 spin_unlock_irqrestore(&cm_node->retrans_list_lock,
575 flags);
607 ret = nes_nic_cm_xmit(send_entry->skb, cm_node->netdev); 576 ret = nes_nic_cm_xmit(send_entry->skb, cm_node->netdev);
577 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
608 if (ret != NETDEV_TX_OK) { 578 if (ret != NETDEV_TX_OK) {
579 nes_debug(NES_DBG_CM, "rexmit failed for "
580 "node=%p\n", cm_node);
609 cm_packets_bounced++; 581 cm_packets_bounced++;
610 atomic_dec(&send_entry->skb->users); 582 atomic_dec(&send_entry->skb->users);
611 send_entry->retrycount--; 583 send_entry->retrycount--;
612 nexttimeout = jiffies + NES_SHORT_TIME; 584 nexttimeout = jiffies + NES_SHORT_TIME;
613 settimer = 1; 585 settimer = 1;
614 node_done = 1;
615 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
616 continue; 586 continue;
617 } else { 587 } else {
618 cm_packets_sent++; 588 cm_packets_sent++;
619 } 589 }
620 spin_lock_irqsave(&cm_node->retrans_list_lock, flags); 590 nes_debug(NES_DBG_CM, "Packet Sent: retrans count = "
621 list_del(&send_entry->list); 591 "%u, retry count = %u.\n",
622 nes_debug(NES_DBG_CM, "Packet Sent: retrans count = %u, retry count = %u.\n", 592 send_entry->retranscount,
623 send_entry->retranscount, send_entry->retrycount); 593 send_entry->retrycount);
624 if (send_entry->send_retrans) { 594 if (send_entry->send_retrans) {
625 send_entry->retranscount--; 595 send_entry->retranscount--;
626 send_entry->timetosend = jiffies + NES_RETRY_TIMEOUT; 596 send_entry->timetosend = jiffies +
627 if (nexttimeout > send_entry->timetosend || !settimer) { 597 NES_RETRY_TIMEOUT;
598 if (nexttimeout > send_entry->timetosend ||
599 !settimer) {
628 nexttimeout = send_entry->timetosend; 600 nexttimeout = send_entry->timetosend;
629 settimer = 1; 601 settimer = 1;
630 } 602 }
631 list_add(&send_entry->list, &cm_node->retrans_list);
632 continue;
633 } else { 603 } else {
634 int close_when_complete; 604 int close_when_complete;
635 skb = send_entry->skb; 605 close_when_complete =
636 close_when_complete = send_entry->close_when_complete; 606 send_entry->close_when_complete;
637 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); 607 nes_debug(NES_DBG_CM, "cm_node=%p state=%d\n",
638 if (close_when_complete) { 608 cm_node, cm_node->state);
639 BUG_ON(atomic_read(&cm_node->ref_count) == 1); 609 free_retrans_entry(cm_node);
640 rem_ref_cm_node(cm_core, cm_node); 610 if (close_when_complete)
641 } 611 rem_ref_cm_node(cm_node->cm_core,
642 dev_kfree_skb_any(skb); 612 cm_node);
643 kfree(send_entry);
644 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
645 continue;
646 } 613 }
647 } 614 } while (0);
648 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
649
650 rem_ref_cm_node(cm_core, cm_node);
651 615
616 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
617 rem_ref_cm_node(cm_node->cm_core, cm_node);
652 spin_lock_irqsave(&cm_core->ht_lock, flags); 618 spin_lock_irqsave(&cm_core->ht_lock, flags);
653 if (ret != NETDEV_TX_OK) 619 if (ret != NETDEV_TX_OK) {
620 nes_debug(NES_DBG_CM, "rexmit failed for cm_node=%p\n",
621 cm_node);
654 break; 622 break;
623 }
655 } 624 }
656 spin_unlock_irqrestore(&cm_core->ht_lock, flags); 625 spin_unlock_irqrestore(&cm_core->ht_lock, flags);
657 626
@@ -667,14 +636,14 @@ static void nes_cm_timer_tick(unsigned long pass)
667/** 636/**
668 * send_syn 637 * send_syn
669 */ 638 */
670static int send_syn(struct nes_cm_node *cm_node, u32 sendack) 639static int send_syn(struct nes_cm_node *cm_node, u32 sendack,
640 struct sk_buff *skb)
671{ 641{
672 int ret; 642 int ret;
673 int flags = SET_SYN; 643 int flags = SET_SYN;
674 struct sk_buff *skb;
675 char optionsbuffer[sizeof(struct option_mss) + 644 char optionsbuffer[sizeof(struct option_mss) +
676 sizeof(struct option_windowscale) + 645 sizeof(struct option_windowscale) + sizeof(struct option_base) +
677 sizeof(struct option_base) + 1]; 646 TCP_OPTIONS_PADDING];
678 647
679 int optionssize = 0; 648 int optionssize = 0;
680 /* Sending MSS option */ 649 /* Sending MSS option */
@@ -695,8 +664,7 @@ static int send_syn(struct nes_cm_node *cm_node, u32 sendack)
695 options->as_windowscale.shiftcount = cm_node->tcp_cntxt.rcv_wscale; 664 options->as_windowscale.shiftcount = cm_node->tcp_cntxt.rcv_wscale;
696 optionssize += sizeof(struct option_windowscale); 665 optionssize += sizeof(struct option_windowscale);
697 666
698 if (sendack && !(NES_DRV_OPT_SUPRESS_OPTION_BC & nes_drv_opt) 667 if (sendack && !(NES_DRV_OPT_SUPRESS_OPTION_BC & nes_drv_opt)) {
699 ) {
700 options = (union all_known_options *)&optionsbuffer[optionssize]; 668 options = (union all_known_options *)&optionsbuffer[optionssize];
701 options->as_base.optionnum = OPTION_NUMBER_WRITE0; 669 options->as_base.optionnum = OPTION_NUMBER_WRITE0;
702 options->as_base.length = sizeof(struct option_base); 670 options->as_base.length = sizeof(struct option_base);
@@ -714,7 +682,8 @@ static int send_syn(struct nes_cm_node *cm_node, u32 sendack)
714 options->as_end = OPTION_NUMBER_END; 682 options->as_end = OPTION_NUMBER_END;
715 optionssize += 1; 683 optionssize += 1;
716 684
717 skb = get_free_pkt(cm_node); 685 if (!skb)
686 skb = get_free_pkt(cm_node);
718 if (!skb) { 687 if (!skb) {
719 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 688 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n");
720 return -1; 689 return -1;
@@ -733,18 +702,18 @@ static int send_syn(struct nes_cm_node *cm_node, u32 sendack)
733/** 702/**
734 * send_reset 703 * send_reset
735 */ 704 */
736static int send_reset(struct nes_cm_node *cm_node) 705static int send_reset(struct nes_cm_node *cm_node, struct sk_buff *skb)
737{ 706{
738 int ret; 707 int ret;
739 struct sk_buff *skb = get_free_pkt(cm_node);
740 int flags = SET_RST | SET_ACK; 708 int flags = SET_RST | SET_ACK;
741 709
710 if (!skb)
711 skb = get_free_pkt(cm_node);
742 if (!skb) { 712 if (!skb) {
743 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 713 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n");
744 return -1; 714 return -1;
745 } 715 }
746 716
747 add_ref_cm_node(cm_node);
748 form_cm_frame(skb, cm_node, NULL, 0, NULL, 0, flags); 717 form_cm_frame(skb, cm_node, NULL, 0, NULL, 0, flags);
749 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 0, 1); 718 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 0, 1);
750 719
@@ -755,10 +724,12 @@ static int send_reset(struct nes_cm_node *cm_node)
755/** 724/**
756 * send_ack 725 * send_ack
757 */ 726 */
758static int send_ack(struct nes_cm_node *cm_node) 727static int send_ack(struct nes_cm_node *cm_node, struct sk_buff *skb)
759{ 728{
760 int ret; 729 int ret;
761 struct sk_buff *skb = get_free_pkt(cm_node); 730
731 if (!skb)
732 skb = get_free_pkt(cm_node);
762 733
763 if (!skb) { 734 if (!skb) {
764 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n"); 735 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n");
@@ -922,7 +893,8 @@ static int add_hte_node(struct nes_cm_core *cm_core, struct nes_cm_node *cm_node
922 if (!cm_node || !cm_core) 893 if (!cm_node || !cm_core)
923 return -EINVAL; 894 return -EINVAL;
924 895
925 nes_debug(NES_DBG_CM, "Adding Node to Active Connection HT\n"); 896 nes_debug(NES_DBG_CM, "Adding Node %p to Active Connection HT\n",
897 cm_node);
926 898
927 /* first, make an index into our hash table */ 899 /* first, make an index into our hash table */
928 hashkey = make_hashkey(cm_node->loc_port, cm_node->loc_addr, 900 hashkey = make_hashkey(cm_node->loc_port, cm_node->loc_addr,
@@ -946,10 +918,35 @@ static int add_hte_node(struct nes_cm_core *cm_core, struct nes_cm_node *cm_node
946 * mini_cm_dec_refcnt_listen 918 * mini_cm_dec_refcnt_listen
947 */ 919 */
948static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core, 920static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
949 struct nes_cm_listener *listener, int free_hanging_nodes) 921 struct nes_cm_listener *listener, int free_hanging_nodes)
950{ 922{
951 int ret = 1; 923 int ret = 1;
952 unsigned long flags; 924 unsigned long flags;
925 struct list_head *list_pos = NULL;
926 struct list_head *list_temp = NULL;
927 struct nes_cm_node *cm_node = NULL;
928
929 nes_debug(NES_DBG_CM, "attempting listener= %p free_nodes= %d, "
930 "refcnt=%d\n", listener, free_hanging_nodes,
931 atomic_read(&listener->ref_count));
932 /* free non-accelerated child nodes for this listener */
933 if (free_hanging_nodes) {
934 spin_lock_irqsave(&cm_core->ht_lock, flags);
935 list_for_each_safe(list_pos, list_temp,
936 &g_cm_core->connected_nodes) {
937 cm_node = container_of(list_pos, struct nes_cm_node,
938 list);
939 if ((cm_node->listener == listener) &&
940 (!cm_node->accelerated)) {
941 cleanup_retrans_entry(cm_node);
942 spin_unlock_irqrestore(&cm_core->ht_lock,
943 flags);
944 send_reset(cm_node, NULL);
945 spin_lock_irqsave(&cm_core->ht_lock, flags);
946 }
947 }
948 spin_unlock_irqrestore(&cm_core->ht_lock, flags);
949 }
953 spin_lock_irqsave(&cm_core->listen_list_lock, flags); 950 spin_lock_irqsave(&cm_core->listen_list_lock, flags);
954 if (!atomic_dec_return(&listener->ref_count)) { 951 if (!atomic_dec_return(&listener->ref_count)) {
955 list_del(&listener->list); 952 list_del(&listener->list);
@@ -1067,18 +1064,18 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
1067 cm_node->loc_port = cm_info->loc_port; 1064 cm_node->loc_port = cm_info->loc_port;
1068 cm_node->rem_port = cm_info->rem_port; 1065 cm_node->rem_port = cm_info->rem_port;
1069 cm_node->send_write0 = send_first; 1066 cm_node->send_write0 = send_first;
1070 nes_debug(NES_DBG_CM, "Make node addresses : loc = " NIPQUAD_FMT ":%x, rem = " NIPQUAD_FMT ":%x\n", 1067 nes_debug(NES_DBG_CM, "Make node addresses : loc = " NIPQUAD_FMT
1071 HIPQUAD(cm_node->loc_addr), cm_node->loc_port, 1068 ":%x, rem = " NIPQUAD_FMT ":%x\n",
1072 HIPQUAD(cm_node->rem_addr), cm_node->rem_port); 1069 HIPQUAD(cm_node->loc_addr), cm_node->loc_port,
1070 HIPQUAD(cm_node->rem_addr), cm_node->rem_port);
1073 cm_node->listener = listener; 1071 cm_node->listener = listener;
1074 cm_node->netdev = nesvnic->netdev; 1072 cm_node->netdev = nesvnic->netdev;
1075 cm_node->cm_id = cm_info->cm_id; 1073 cm_node->cm_id = cm_info->cm_id;
1076 memcpy(cm_node->loc_mac, nesvnic->netdev->dev_addr, ETH_ALEN); 1074 memcpy(cm_node->loc_mac, nesvnic->netdev->dev_addr, ETH_ALEN);
1077 1075
1078 nes_debug(NES_DBG_CM, "listener=%p, cm_id=%p\n", 1076 nes_debug(NES_DBG_CM, "listener=%p, cm_id=%p\n", cm_node->listener,
1079 cm_node->listener, cm_node->cm_id); 1077 cm_node->cm_id);
1080 1078
1081 INIT_LIST_HEAD(&cm_node->retrans_list);
1082 spin_lock_init(&cm_node->retrans_list_lock); 1079 spin_lock_init(&cm_node->retrans_list_lock);
1083 INIT_LIST_HEAD(&cm_node->recv_list); 1080 INIT_LIST_HEAD(&cm_node->recv_list);
1084 spin_lock_init(&cm_node->recv_list_lock); 1081 spin_lock_init(&cm_node->recv_list_lock);
@@ -1142,10 +1139,9 @@ static int add_ref_cm_node(struct nes_cm_node *cm_node)
1142 * rem_ref_cm_node - destroy an instance of a cm node 1139 * rem_ref_cm_node - destroy an instance of a cm node
1143 */ 1140 */
1144static int rem_ref_cm_node(struct nes_cm_core *cm_core, 1141static int rem_ref_cm_node(struct nes_cm_core *cm_core,
1145 struct nes_cm_node *cm_node) 1142 struct nes_cm_node *cm_node)
1146{ 1143{
1147 unsigned long flags, qplockflags; 1144 unsigned long flags, qplockflags;
1148 struct nes_timer_entry *send_entry;
1149 struct nes_timer_entry *recv_entry; 1145 struct nes_timer_entry *recv_entry;
1150 struct iw_cm_id *cm_id; 1146 struct iw_cm_id *cm_id;
1151 struct list_head *list_core, *list_node_temp; 1147 struct list_head *list_core, *list_node_temp;
@@ -1169,48 +1165,33 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
1169 atomic_dec(&cm_node->listener->pend_accepts_cnt); 1165 atomic_dec(&cm_node->listener->pend_accepts_cnt);
1170 BUG_ON(atomic_read(&cm_node->listener->pend_accepts_cnt) < 0); 1166 BUG_ON(atomic_read(&cm_node->listener->pend_accepts_cnt) < 0);
1171 } 1167 }
1172 1168 BUG_ON(cm_node->send_entry);
1173 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
1174 list_for_each_safe(list_core, list_node_temp, &cm_node->retrans_list) {
1175 send_entry = container_of(list_core, struct nes_timer_entry, list);
1176 list_del(&send_entry->list);
1177 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
1178 dev_kfree_skb_any(send_entry->skb);
1179 kfree(send_entry);
1180 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
1181 continue;
1182 }
1183 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
1184
1185 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 1169 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
1186 list_for_each_safe(list_core, list_node_temp, &cm_node->recv_list) { 1170 list_for_each_safe(list_core, list_node_temp, &cm_node->recv_list) {
1187 recv_entry = container_of(list_core, struct nes_timer_entry, list); 1171 recv_entry = container_of(list_core, struct nes_timer_entry,
1172 list);
1188 list_del(&recv_entry->list); 1173 list_del(&recv_entry->list);
1189 cm_id = cm_node->cm_id; 1174 cm_id = cm_node->cm_id;
1190 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags); 1175 spin_unlock_irqrestore(&cm_node->recv_list_lock, flags);
1191 if (recv_entry->type == NES_TIMER_TYPE_CLOSE) { 1176 nesqp = (struct nes_qp *)recv_entry->skb;
1192 nesqp = (struct nes_qp *)recv_entry->skb; 1177 spin_lock_irqsave(&nesqp->lock, qplockflags);
1193 spin_lock_irqsave(&nesqp->lock, qplockflags); 1178 if (nesqp->cm_id) {
1194 if (nesqp->cm_id) { 1179 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: HIT A "
1195 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: ****** HIT A NES_TIMER_TYPE_CLOSE" 1180 "NES_TIMER_TYPE_CLOSE with something to do!\n",
1196 " with something to do!!! ******\n", 1181 nesqp->hwqp.qp_id, cm_id);
1197 nesqp->hwqp.qp_id, cm_id); 1182 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED;
1198 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 1183 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT;
1199 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 1184 nesqp->ibqp_state = IB_QPS_ERR;
1200 nesqp->ibqp_state = IB_QPS_ERR; 1185 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
1201 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1186 nes_cm_disconn(nesqp);
1202 nes_cm_disconn(nesqp); 1187 } else {
1203 } else { 1188 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
1204 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 1189 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: HIT A "
1205 nes_debug(NES_DBG_CM, "QP%u: cm_id = %p: ****** HIT A NES_TIMER_TYPE_CLOSE" 1190 "NES_TIMER_TYPE_CLOSE with nothing to do!\n",
1206 " with nothing to do!!! ******\n", 1191 nesqp->hwqp.qp_id, cm_id);
1207 nesqp->hwqp.qp_id, cm_id);
1208 nes_rem_ref(&nesqp->ibqp);
1209 }
1210 cm_id->rem_ref(cm_id);
1211 } else if (recv_entry->type == NES_TIMER_TYPE_RECV) {
1212 dev_kfree_skb_any(recv_entry->skb);
1213 } 1192 }
1193 cm_id->rem_ref(cm_id);
1194
1214 kfree(recv_entry); 1195 kfree(recv_entry);
1215 spin_lock_irqsave(&cm_node->recv_list_lock, flags); 1196 spin_lock_irqsave(&cm_node->recv_list_lock, flags);
1216 } 1197 }
@@ -1221,23 +1202,31 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
1221 } else { 1202 } else {
1222 if (cm_node->apbvt_set && cm_node->nesvnic) { 1203 if (cm_node->apbvt_set && cm_node->nesvnic) {
1223 nes_manage_apbvt(cm_node->nesvnic, cm_node->loc_port, 1204 nes_manage_apbvt(cm_node->nesvnic, cm_node->loc_port,
1224 PCI_FUNC(cm_node->nesvnic->nesdev->pcidev->devfn), 1205 PCI_FUNC(
1225 NES_MANAGE_APBVT_DEL); 1206 cm_node->nesvnic->nesdev->pcidev->devfn),
1207 NES_MANAGE_APBVT_DEL);
1226 } 1208 }
1227 } 1209 }
1228 1210
1229 kfree(cm_node);
1230 atomic_dec(&cm_core->node_cnt); 1211 atomic_dec(&cm_core->node_cnt);
1231 atomic_inc(&cm_nodes_destroyed); 1212 atomic_inc(&cm_nodes_destroyed);
1213 nesqp = cm_node->nesqp;
1214 if (nesqp) {
1215 nesqp->cm_node = NULL;
1216 nes_rem_ref(&nesqp->ibqp);
1217 cm_node->nesqp = NULL;
1218 }
1232 1219
1220 cm_node->freed = 1;
1221 kfree(cm_node);
1233 return 0; 1222 return 0;
1234} 1223}
1235 1224
1236
1237/** 1225/**
1238 * process_options 1226 * process_options
1239 */ 1227 */
1240static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 optionsize, u32 syn_packet) 1228static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
1229 u32 optionsize, u32 syn_packet)
1241{ 1230{
1242 u32 tmp; 1231 u32 tmp;
1243 u32 offset = 0; 1232 u32 offset = 0;
@@ -1247,35 +1236,37 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 opti
1247 while (offset < optionsize) { 1236 while (offset < optionsize) {
1248 all_options = (union all_known_options *)(optionsloc + offset); 1237 all_options = (union all_known_options *)(optionsloc + offset);
1249 switch (all_options->as_base.optionnum) { 1238 switch (all_options->as_base.optionnum) {
1250 case OPTION_NUMBER_END: 1239 case OPTION_NUMBER_END:
1251 offset = optionsize; 1240 offset = optionsize;
1252 break; 1241 break;
1253 case OPTION_NUMBER_NONE: 1242 case OPTION_NUMBER_NONE:
1254 offset += 1; 1243 offset += 1;
1255 continue; 1244 continue;
1256 case OPTION_NUMBER_MSS: 1245 case OPTION_NUMBER_MSS:
1257 nes_debug(NES_DBG_CM, "%s: MSS Length: %d Offset: %d Size: %d\n", 1246 nes_debug(NES_DBG_CM, "%s: MSS Length: %d Offset: %d "
1258 __func__, 1247 "Size: %d\n", __func__,
1259 all_options->as_mss.length, offset, optionsize); 1248 all_options->as_mss.length, offset, optionsize);
1260 got_mss_option = 1; 1249 got_mss_option = 1;
1261 if (all_options->as_mss.length != 4) { 1250 if (all_options->as_mss.length != 4) {
1262 return 1; 1251 return 1;
1263 } else { 1252 } else {
1264 tmp = ntohs(all_options->as_mss.mss); 1253 tmp = ntohs(all_options->as_mss.mss);
1265 if (tmp > 0 && tmp < cm_node->tcp_cntxt.mss) 1254 if (tmp > 0 && tmp <
1266 cm_node->tcp_cntxt.mss = tmp; 1255 cm_node->tcp_cntxt.mss)
1267 } 1256 cm_node->tcp_cntxt.mss = tmp;
1268 break; 1257 }
1269 case OPTION_NUMBER_WINDOW_SCALE: 1258 break;
1270 cm_node->tcp_cntxt.snd_wscale = all_options->as_windowscale.shiftcount; 1259 case OPTION_NUMBER_WINDOW_SCALE:
1271 break; 1260 cm_node->tcp_cntxt.snd_wscale =
1272 case OPTION_NUMBER_WRITE0: 1261 all_options->as_windowscale.shiftcount;
1273 cm_node->send_write0 = 1; 1262 break;
1274 break; 1263 case OPTION_NUMBER_WRITE0:
1275 default: 1264 cm_node->send_write0 = 1;
1276 nes_debug(NES_DBG_CM, "TCP Option not understood: %x\n", 1265 break;
1277 all_options->as_base.optionnum); 1266 default:
1278 break; 1267 nes_debug(NES_DBG_CM, "TCP Option not understood: %x\n",
1268 all_options->as_base.optionnum);
1269 break;
1279 } 1270 }
1280 offset += all_options->as_base.length; 1271 offset += all_options->as_base.length;
1281 } 1272 }
@@ -1284,300 +1275,491 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 opti
1284 return 0; 1275 return 0;
1285} 1276}
1286 1277
1278static void drop_packet(struct sk_buff *skb)
1279{
1280 atomic_inc(&cm_accel_dropped_pkts);
1281 dev_kfree_skb_any(skb);
1282}
1287 1283
1288/** 1284static void handle_fin_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
1289 * process_packet 1285 struct tcphdr *tcph)
1290 */
1291static int process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb,
1292 struct nes_cm_core *cm_core)
1293{ 1286{
1294 int optionsize; 1287 atomic_inc(&cm_resets_recvd);
1295 int datasize; 1288 nes_debug(NES_DBG_CM, "Received FIN, cm_node = %p, state = %u. "
1296 int ret = 0; 1289 "refcnt=%d\n", cm_node, cm_node->state,
1297 struct tcphdr *tcph = tcp_hdr(skb); 1290 atomic_read(&cm_node->ref_count));
1298 u32 inc_sequence; 1291 cm_node->tcp_cntxt.rcv_nxt++;
1299 if (cm_node->state == NES_CM_STATE_SYN_SENT && tcph->syn) { 1292 cleanup_retrans_entry(cm_node);
1300 inc_sequence = ntohl(tcph->seq); 1293 switch (cm_node->state) {
1301 cm_node->tcp_cntxt.rcv_nxt = inc_sequence; 1294 case NES_CM_STATE_SYN_RCVD:
1295 case NES_CM_STATE_SYN_SENT:
1296 case NES_CM_STATE_ESTABLISHED:
1297 case NES_CM_STATE_MPAREQ_SENT:
1298 cm_node->state = NES_CM_STATE_LAST_ACK;
1299 send_fin(cm_node, skb);
1300 break;
1301 case NES_CM_STATE_FIN_WAIT1:
1302 cm_node->state = NES_CM_STATE_CLOSING;
1303 send_ack(cm_node, skb);
1304 break;
1305 case NES_CM_STATE_FIN_WAIT2:
1306 cm_node->state = NES_CM_STATE_TIME_WAIT;
1307 send_ack(cm_node, skb);
1308 cm_node->state = NES_CM_STATE_CLOSED;
1309 break;
1310 case NES_CM_STATE_TSA:
1311 default:
1312 nes_debug(NES_DBG_CM, "Error Rcvd FIN for node-%p state = %d\n",
1313 cm_node, cm_node->state);
1314 drop_packet(skb);
1315 break;
1302 } 1316 }
1317}
1303 1318
1304 if ((!tcph) || (cm_node->state == NES_CM_STATE_TSA)) {
1305 BUG_ON(!tcph);
1306 atomic_inc(&cm_accel_dropped_pkts);
1307 return -1;
1308 }
1309 1319
1310 if (tcph->rst) { 1320static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
1311 atomic_inc(&cm_resets_recvd); 1321 struct tcphdr *tcph)
1312 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u. refcnt=%d\n", 1322{
1313 cm_node, cm_node->state, atomic_read(&cm_node->ref_count));
1314 switch (cm_node->state) {
1315 case NES_CM_STATE_LISTENING:
1316 rem_ref_cm_node(cm_core, cm_node);
1317 break;
1318 case NES_CM_STATE_TSA:
1319 case NES_CM_STATE_CLOSED:
1320 break;
1321 case NES_CM_STATE_SYN_RCVD:
1322 nes_debug(NES_DBG_CM, "Received a reset for local 0x%08X:%04X,"
1323 " remote 0x%08X:%04X, node state = %u\n",
1324 cm_node->loc_addr, cm_node->loc_port,
1325 cm_node->rem_addr, cm_node->rem_port,
1326 cm_node->state);
1327 rem_ref_cm_node(cm_core, cm_node);
1328 break;
1329 case NES_CM_STATE_ONE_SIDE_ESTABLISHED:
1330 case NES_CM_STATE_ESTABLISHED:
1331 case NES_CM_STATE_MPAREQ_SENT:
1332 default:
1333 nes_debug(NES_DBG_CM, "Received a reset for local 0x%08X:%04X,"
1334 " remote 0x%08X:%04X, node state = %u refcnt=%d\n",
1335 cm_node->loc_addr, cm_node->loc_port,
1336 cm_node->rem_addr, cm_node->rem_port,
1337 cm_node->state, atomic_read(&cm_node->ref_count));
1338 /* create event */
1339 cm_node->state = NES_CM_STATE_CLOSED;
1340 1323
1341 create_event(cm_node, NES_CM_EVENT_ABORTED); 1324 int reset = 0; /* whether to send reset in case of err.. */
1342 break; 1325 atomic_inc(&cm_resets_recvd);
1326 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
1327 " refcnt=%d\n", cm_node, cm_node->state,
1328 atomic_read(&cm_node->ref_count));
1329 cleanup_retrans_entry(cm_node);
1330 switch (cm_node->state) {
1331 case NES_CM_STATE_SYN_SENT:
1332 case NES_CM_STATE_MPAREQ_SENT:
1333 nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p "
1334 "listener=%p state=%d\n", __func__, __LINE__, cm_node,
1335 cm_node->listener, cm_node->state);
1336 active_open_err(cm_node, skb, reset);
1337 break;
1338 /* For PASSIVE open states, remove the cm_node event */
1339 case NES_CM_STATE_ESTABLISHED:
1340 case NES_CM_STATE_SYN_RCVD:
1341 case NES_CM_STATE_LISTENING:
1342 nes_debug(NES_DBG_CM, "Bad state %s[%u]\n", __func__, __LINE__);
1343 passive_open_err(cm_node, skb, reset);
1344 break;
1345 case NES_CM_STATE_TSA:
1346 default:
1347 break;
1348 }
1349}
1343 1350
1351static void handle_rcv_mpa(struct nes_cm_node *cm_node, struct sk_buff *skb,
1352 enum nes_cm_event_type type)
1353{
1354
1355 int ret;
1356 int datasize = skb->len;
1357 u8 *dataloc = skb->data;
1358 ret = parse_mpa(cm_node, dataloc, datasize);
1359 if (ret < 0) {
1360 nes_debug(NES_DBG_CM, "didn't like MPA Request\n");
1361 if (type == NES_CM_EVENT_CONNECTED) {
1362 nes_debug(NES_DBG_CM, "%s[%u] create abort for "
1363 "cm_node=%p listener=%p state=%d\n", __func__,
1364 __LINE__, cm_node, cm_node->listener,
1365 cm_node->state);
1366 active_open_err(cm_node, skb, 1);
1367 } else {
1368 passive_open_err(cm_node, skb, 1);
1344 } 1369 }
1345 return -1; 1370 } else {
1371 cleanup_retrans_entry(cm_node);
1372 dev_kfree_skb_any(skb);
1373 if (type == NES_CM_EVENT_CONNECTED)
1374 cm_node->state = NES_CM_STATE_TSA;
1375 create_event(cm_node, type);
1376
1377 }
1378 return ;
1379}
1380
1381static void indicate_pkt_err(struct nes_cm_node *cm_node, struct sk_buff *skb)
1382{
1383 switch (cm_node->state) {
1384 case NES_CM_STATE_SYN_SENT:
1385 case NES_CM_STATE_MPAREQ_SENT:
1386 nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p "
1387 "listener=%p state=%d\n", __func__, __LINE__, cm_node,
1388 cm_node->listener, cm_node->state);
1389 active_open_err(cm_node, skb, 1);
1390 break;
1391 case NES_CM_STATE_ESTABLISHED:
1392 case NES_CM_STATE_SYN_RCVD:
1393 passive_open_err(cm_node, skb, 1);
1394 break;
1395 case NES_CM_STATE_TSA:
1396 default:
1397 drop_packet(skb);
1346 } 1398 }
1399}
1400
1401static int check_syn(struct nes_cm_node *cm_node, struct tcphdr *tcph,
1402 struct sk_buff *skb)
1403{
1404 int err;
1405
1406 err = ((ntohl(tcph->ack_seq) == cm_node->tcp_cntxt.loc_seq_num))? 0 : 1;
1407 if (err)
1408 active_open_err(cm_node, skb, 1);
1409
1410 return err;
1411}
1412
1413static int check_seq(struct nes_cm_node *cm_node, struct tcphdr *tcph,
1414 struct sk_buff *skb)
1415{
1416 int err = 0;
1417 u32 seq;
1418 u32 ack_seq;
1419 u32 loc_seq_num = cm_node->tcp_cntxt.loc_seq_num;
1420 u32 rcv_nxt = cm_node->tcp_cntxt.rcv_nxt;
1421 u32 rcv_wnd;
1422 seq = ntohl(tcph->seq);
1423 ack_seq = ntohl(tcph->ack_seq);
1424 rcv_wnd = cm_node->tcp_cntxt.rcv_wnd;
1425 if (ack_seq != loc_seq_num)
1426 err = 1;
1427 else if ((seq + rcv_wnd) < rcv_nxt)
1428 err = 1;
1429 if (err) {
1430 nes_debug(NES_DBG_CM, "%s[%u] create abort for cm_node=%p "
1431 "listener=%p state=%d\n", __func__, __LINE__, cm_node,
1432 cm_node->listener, cm_node->state);
1433 indicate_pkt_err(cm_node, skb);
1434 nes_debug(NES_DBG_CM, "seq ERROR cm_node =%p seq=0x%08X "
1435 "rcv_nxt=0x%08X rcv_wnd=0x%x\n", cm_node, seq, rcv_nxt,
1436 rcv_wnd);
1437 }
1438 return err;
1439}
1440
1441/*
1442 * handle_syn_pkt() is for Passive node. The syn packet is received when a node
1443 * is created with a listener or it may comein as rexmitted packet which in
1444 * that case will be just dropped.
1445 */
1446
1447static void handle_syn_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
1448 struct tcphdr *tcph)
1449{
1450 int ret;
1451 u32 inc_sequence;
1452 int optionsize;
1347 1453
1348 optionsize = (tcph->doff << 2) - sizeof(struct tcphdr); 1454 optionsize = (tcph->doff << 2) - sizeof(struct tcphdr);
1455 skb_pull(skb, tcph->doff << 2);
1456 inc_sequence = ntohl(tcph->seq);
1349 1457
1350 skb_pull(skb, ip_hdr(skb)->ihl << 2); 1458 switch (cm_node->state) {
1459 case NES_CM_STATE_SYN_SENT:
1460 case NES_CM_STATE_MPAREQ_SENT:
1461 /* Rcvd syn on active open connection*/
1462 active_open_err(cm_node, skb, 1);
1463 break;
1464 case NES_CM_STATE_LISTENING:
1465 /* Passive OPEN */
1466 cm_node->accept_pend = 1;
1467 atomic_inc(&cm_node->listener->pend_accepts_cnt);
1468 if (atomic_read(&cm_node->listener->pend_accepts_cnt) >
1469 cm_node->listener->backlog) {
1470 nes_debug(NES_DBG_CM, "drop syn due to backlog "
1471 "pressure \n");
1472 cm_backlog_drops++;
1473 passive_open_err(cm_node, skb, 0);
1474 break;
1475 }
1476 ret = handle_tcp_options(cm_node, tcph, skb, optionsize,
1477 1);
1478 if (ret) {
1479 passive_open_err(cm_node, skb, 0);
1480 /* drop pkt */
1481 break;
1482 }
1483 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1;
1484 BUG_ON(cm_node->send_entry);
1485 cm_node->state = NES_CM_STATE_SYN_RCVD;
1486 send_syn(cm_node, 1, skb);
1487 break;
1488 case NES_CM_STATE_TSA:
1489 case NES_CM_STATE_ESTABLISHED:
1490 case NES_CM_STATE_FIN_WAIT1:
1491 case NES_CM_STATE_FIN_WAIT2:
1492 case NES_CM_STATE_MPAREQ_RCVD:
1493 case NES_CM_STATE_LAST_ACK:
1494 case NES_CM_STATE_CLOSING:
1495 case NES_CM_STATE_UNKNOWN:
1496 case NES_CM_STATE_CLOSED:
1497 default:
1498 drop_packet(skb);
1499 break;
1500 }
1501}
1502
1503static void handle_synack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
1504 struct tcphdr *tcph)
1505{
1506
1507 int ret;
1508 u32 inc_sequence;
1509 int optionsize;
1510
1511 optionsize = (tcph->doff << 2) - sizeof(struct tcphdr);
1351 skb_pull(skb, tcph->doff << 2); 1512 skb_pull(skb, tcph->doff << 2);
1513 inc_sequence = ntohl(tcph->seq);
1514 switch (cm_node->state) {
1515 case NES_CM_STATE_SYN_SENT:
1516 /* active open */
1517 if (check_syn(cm_node, tcph, skb))
1518 return;
1519 cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);
1520 /* setup options */
1521 ret = handle_tcp_options(cm_node, tcph, skb, optionsize, 0);
1522 if (ret) {
1523 nes_debug(NES_DBG_CM, "cm_node=%p tcp_options failed\n",
1524 cm_node);
1525 break;
1526 }
1527 cleanup_retrans_entry(cm_node);
1528 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + 1;
1529 send_mpa_request(cm_node, skb);
1530 cm_node->state = NES_CM_STATE_MPAREQ_SENT;
1531 break;
1532 case NES_CM_STATE_MPAREQ_RCVD:
1533 /* passive open, so should not be here */
1534 passive_open_err(cm_node, skb, 1);
1535 break;
1536 case NES_CM_STATE_ESTABLISHED:
1537 case NES_CM_STATE_FIN_WAIT1:
1538 case NES_CM_STATE_FIN_WAIT2:
1539 case NES_CM_STATE_LAST_ACK:
1540 case NES_CM_STATE_TSA:
1541 case NES_CM_STATE_CLOSING:
1542 case NES_CM_STATE_UNKNOWN:
1543 case NES_CM_STATE_CLOSED:
1544 case NES_CM_STATE_MPAREQ_SENT:
1545 default:
1546 drop_packet(skb);
1547 break;
1548 }
1549}
1352 1550
1353 datasize = skb->len; 1551static void handle_ack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
1552 struct tcphdr *tcph)
1553{
1554 int datasize = 0;
1555 u32 inc_sequence;
1556 u32 rem_seq_ack;
1557 u32 rem_seq;
1558 if (check_seq(cm_node, tcph, skb))
1559 return;
1560
1561 skb_pull(skb, tcph->doff << 2);
1354 inc_sequence = ntohl(tcph->seq); 1562 inc_sequence = ntohl(tcph->seq);
1355 nes_debug(NES_DBG_CM, "datasize = %u, sequence = 0x%08X, ack_seq = 0x%08X," 1563 rem_seq = ntohl(tcph->seq);
1356 " rcv_nxt = 0x%08X Flags: %s %s.\n", 1564 rem_seq_ack = ntohl(tcph->ack_seq);
1357 datasize, inc_sequence, ntohl(tcph->ack_seq), 1565 datasize = skb->len;
1358 cm_node->tcp_cntxt.rcv_nxt, (tcph->syn ? "SYN":""), 1566
1359 (tcph->ack ? "ACK":"")); 1567 switch (cm_node->state) {
1360 1568 case NES_CM_STATE_SYN_RCVD:
1361 if (!tcph->syn && (inc_sequence != cm_node->tcp_cntxt.rcv_nxt) 1569 /* Passive OPEN */
1362 ) { 1570 cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);
1363 nes_debug(NES_DBG_CM, "dropping packet, datasize = %u, sequence = 0x%08X," 1571 cm_node->state = NES_CM_STATE_ESTABLISHED;
1364 " ack_seq = 0x%08X, rcv_nxt = 0x%08X Flags: %s.\n", 1572 if (datasize) {
1365 datasize, inc_sequence, ntohl(tcph->ack_seq), 1573 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;
1366 cm_node->tcp_cntxt.rcv_nxt, (tcph->ack ? "ACK":"")); 1574 cm_node->state = NES_CM_STATE_MPAREQ_RCVD;
1367 if (cm_node->state == NES_CM_STATE_LISTENING) { 1575 handle_rcv_mpa(cm_node, skb, NES_CM_EVENT_MPA_REQ);
1368 rem_ref_cm_node(cm_core, cm_node); 1576 } else { /* rcvd ACK only */
1577 dev_kfree_skb_any(skb);
1578 cleanup_retrans_entry(cm_node);
1579 }
1580 break;
1581 case NES_CM_STATE_ESTABLISHED:
1582 /* Passive OPEN */
1583 /* We expect mpa frame to be received only */
1584 if (datasize) {
1585 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;
1586 cm_node->state = NES_CM_STATE_MPAREQ_RCVD;
1587 handle_rcv_mpa(cm_node, skb,
1588 NES_CM_EVENT_MPA_REQ);
1589 } else
1590 drop_packet(skb);
1591 break;
1592 case NES_CM_STATE_MPAREQ_SENT:
1593 cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq);
1594 if (datasize) {
1595 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;
1596 handle_rcv_mpa(cm_node, skb, NES_CM_EVENT_CONNECTED);
1597 } else { /* Could be just an ack pkt.. */
1598 cleanup_retrans_entry(cm_node);
1599 dev_kfree_skb_any(skb);
1369 } 1600 }
1370 return -1; 1601 break;
1602 case NES_CM_STATE_FIN_WAIT1:
1603 case NES_CM_STATE_SYN_SENT:
1604 case NES_CM_STATE_FIN_WAIT2:
1605 case NES_CM_STATE_TSA:
1606 case NES_CM_STATE_CLOSED:
1607 case NES_CM_STATE_MPAREQ_RCVD:
1608 case NES_CM_STATE_LAST_ACK:
1609 case NES_CM_STATE_CLOSING:
1610 case NES_CM_STATE_UNKNOWN:
1611 default:
1612 drop_packet(skb);
1613 break;
1371 } 1614 }
1615}
1372 1616
1373 cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;
1374 1617
1375 1618
1619static int handle_tcp_options(struct nes_cm_node *cm_node, struct tcphdr *tcph,
1620 struct sk_buff *skb, int optionsize, int passive)
1621{
1622 u8 *optionsloc = (u8 *)&tcph[1];
1376 if (optionsize) { 1623 if (optionsize) {
1377 u8 *optionsloc = (u8 *)&tcph[1]; 1624 if (process_options(cm_node, optionsloc, optionsize,
1378 if (process_options(cm_node, optionsloc, optionsize, (u32)tcph->syn)) { 1625 (u32)tcph->syn)) {
1379 nes_debug(NES_DBG_CM, "%s: Node %p, Sending RESET\n", __func__, cm_node); 1626 nes_debug(NES_DBG_CM, "%s: Node %p, Sending RESET\n",
1380 send_reset(cm_node); 1627 __func__, cm_node);
1381 if (cm_node->state != NES_CM_STATE_SYN_SENT) 1628 if (passive)
1382 rem_ref_cm_node(cm_core, cm_node); 1629 passive_open_err(cm_node, skb, 0);
1383 return 0; 1630 else
1631 active_open_err(cm_node, skb, 0);
1632 return 1;
1384 } 1633 }
1385 } else if (tcph->syn) 1634 }
1386 cm_node->tcp_cntxt.mss = NES_CM_DEFAULT_MSS;
1387 1635
1388 cm_node->tcp_cntxt.snd_wnd = ntohs(tcph->window) << 1636 cm_node->tcp_cntxt.snd_wnd = ntohs(tcph->window) <<
1389 cm_node->tcp_cntxt.snd_wscale; 1637 cm_node->tcp_cntxt.snd_wscale;
1390 1638
1391 if (cm_node->tcp_cntxt.snd_wnd > cm_node->tcp_cntxt.max_snd_wnd) { 1639 if (cm_node->tcp_cntxt.snd_wnd > cm_node->tcp_cntxt.max_snd_wnd)
1392 cm_node->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.snd_wnd; 1640 cm_node->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.snd_wnd;
1393 } 1641 return 0;
1642}
1394 1643
1395 if (tcph->ack) { 1644/*
1396 cm_node->tcp_cntxt.rem_ack_num = ntohl(tcph->ack_seq); 1645 * active_open_err() will send reset() if flag set..
1397 switch (cm_node->state) { 1646 * It will also send ABORT event.
1398 case NES_CM_STATE_SYN_RCVD: 1647 */
1399 case NES_CM_STATE_SYN_SENT:
1400 /* read and stash current sequence number */
1401 if (cm_node->tcp_cntxt.rem_ack_num != cm_node->tcp_cntxt.loc_seq_num) {
1402 nes_debug(NES_DBG_CM, "ERROR - cm_node->tcp_cntxt.rem_ack_num !="
1403 " cm_node->tcp_cntxt.loc_seq_num\n");
1404 send_reset(cm_node);
1405 return 0;
1406 }
1407 if (cm_node->state == NES_CM_STATE_SYN_SENT)
1408 cm_node->state = NES_CM_STATE_ONE_SIDE_ESTABLISHED;
1409 else {
1410 cm_node->state = NES_CM_STATE_ESTABLISHED;
1411 }
1412 break;
1413 case NES_CM_STATE_LAST_ACK:
1414 cm_node->state = NES_CM_STATE_CLOSED;
1415 break;
1416 case NES_CM_STATE_FIN_WAIT1:
1417 cm_node->state = NES_CM_STATE_FIN_WAIT2;
1418 break;
1419 case NES_CM_STATE_CLOSING:
1420 cm_node->state = NES_CM_STATE_TIME_WAIT;
1421 /* need to schedule this to happen in 2MSL timeouts */
1422 cm_node->state = NES_CM_STATE_CLOSED;
1423 break;
1424 case NES_CM_STATE_ONE_SIDE_ESTABLISHED:
1425 case NES_CM_STATE_ESTABLISHED:
1426 case NES_CM_STATE_MPAREQ_SENT:
1427 case NES_CM_STATE_CLOSE_WAIT:
1428 case NES_CM_STATE_TIME_WAIT:
1429 case NES_CM_STATE_CLOSED:
1430 break;
1431 case NES_CM_STATE_LISTENING:
1432 nes_debug(NES_DBG_CM, "Received an ACK on a listening port (SYN %d)\n", tcph->syn);
1433 cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);
1434 send_reset(cm_node);
1435 /* send_reset bumps refcount, this should have been a new node */
1436 rem_ref_cm_node(cm_core, cm_node);
1437 return -1;
1438 break;
1439 case NES_CM_STATE_TSA:
1440 nes_debug(NES_DBG_CM, "Received a packet with the ack bit set while in TSA state\n");
1441 break;
1442 case NES_CM_STATE_UNKNOWN:
1443 case NES_CM_STATE_INITED:
1444 case NES_CM_STATE_ACCEPTING:
1445 case NES_CM_STATE_FIN_WAIT2:
1446 default:
1447 nes_debug(NES_DBG_CM, "Received ack from unknown state: %x\n",
1448 cm_node->state);
1449 send_reset(cm_node);
1450 break;
1451 }
1452 }
1453 1648
1454 if (tcph->syn) { 1649static void active_open_err(struct nes_cm_node *cm_node, struct sk_buff *skb,
1455 if (cm_node->state == NES_CM_STATE_LISTENING) { 1650 int reset)
1456 /* do not exceed backlog */ 1651{
1457 atomic_inc(&cm_node->listener->pend_accepts_cnt); 1652 cleanup_retrans_entry(cm_node);
1458 if (atomic_read(&cm_node->listener->pend_accepts_cnt) > 1653 if (reset) {
1459 cm_node->listener->backlog) { 1654 nes_debug(NES_DBG_CM, "ERROR active err called for cm_node=%p, "
1460 nes_debug(NES_DBG_CM, "drop syn due to backlog pressure \n"); 1655 "state=%d\n", cm_node, cm_node->state);
1461 cm_backlog_drops++; 1656 add_ref_cm_node(cm_node);
1462 atomic_dec(&cm_node->listener->pend_accepts_cnt); 1657 send_reset(cm_node, skb);
1463 rem_ref_cm_node(cm_core, cm_node); 1658 } else
1464 return 0; 1659 dev_kfree_skb_any(skb);
1465 }
1466 cm_node->accept_pend = 1;
1467 1660
1468 } 1661 cm_node->state = NES_CM_STATE_CLOSED;
1469 if (datasize == 0) 1662 create_event(cm_node, NES_CM_EVENT_ABORTED);
1470 cm_node->tcp_cntxt.rcv_nxt ++; 1663}
1471 1664
1472 if (cm_node->state == NES_CM_STATE_LISTENING) { 1665/*
1473 cm_node->state = NES_CM_STATE_SYN_RCVD; 1666 * passive_open_err() will either do a reset() or will free up the skb and
1474 send_syn(cm_node, 1); 1667 * remove the cm_node.
1475 } 1668 */
1476 if (cm_node->state == NES_CM_STATE_ONE_SIDE_ESTABLISHED) {
1477 cm_node->state = NES_CM_STATE_ESTABLISHED;
1478 /* send final handshake ACK */
1479 ret = send_ack(cm_node);
1480 if (ret < 0)
1481 return ret;
1482 1669
1483 cm_node->state = NES_CM_STATE_MPAREQ_SENT; 1670static void passive_open_err(struct nes_cm_node *cm_node, struct sk_buff *skb,
1484 ret = send_mpa_request(cm_node); 1671 int reset)
1485 if (ret < 0) 1672{
1486 return ret; 1673 cleanup_retrans_entry(cm_node);
1487 } 1674 cm_node->state = NES_CM_STATE_CLOSED;
1675 if (reset) {
1676 nes_debug(NES_DBG_CM, "passive_open_err sending RST for "
1677 "cm_node=%p state =%d\n", cm_node, cm_node->state);
1678 send_reset(cm_node, skb);
1679 } else {
1680 dev_kfree_skb_any(skb);
1681 rem_ref_cm_node(cm_node->cm_core, cm_node);
1488 } 1682 }
1683}
1489 1684
1490 if (tcph->fin) { 1685/*
1491 cm_node->tcp_cntxt.rcv_nxt++; 1686 * free_retrans_entry() routines assumes that the retrans_list_lock has
1492 switch (cm_node->state) { 1687 * been acquired before calling.
1493 case NES_CM_STATE_SYN_RCVD: 1688 */
1494 case NES_CM_STATE_SYN_SENT: 1689static void free_retrans_entry(struct nes_cm_node *cm_node)
1495 case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1690{
1496 case NES_CM_STATE_ESTABLISHED: 1691 struct nes_timer_entry *send_entry;
1497 case NES_CM_STATE_ACCEPTING: 1692 send_entry = cm_node->send_entry;
1498 case NES_CM_STATE_MPAREQ_SENT: 1693 if (send_entry) {
1499 cm_node->state = NES_CM_STATE_CLOSE_WAIT; 1694 cm_node->send_entry = NULL;
1500 cm_node->state = NES_CM_STATE_LAST_ACK; 1695 dev_kfree_skb_any(send_entry->skb);
1501 ret = send_fin(cm_node, NULL); 1696 kfree(send_entry);
1502 break; 1697 rem_ref_cm_node(cm_node->cm_core, cm_node);
1503 case NES_CM_STATE_FIN_WAIT1:
1504 cm_node->state = NES_CM_STATE_CLOSING;
1505 ret = send_ack(cm_node);
1506 break;
1507 case NES_CM_STATE_FIN_WAIT2:
1508 cm_node->state = NES_CM_STATE_TIME_WAIT;
1509 cm_node->tcp_cntxt.loc_seq_num ++;
1510 ret = send_ack(cm_node);
1511 /* need to schedule this to happen in 2MSL timeouts */
1512 cm_node->state = NES_CM_STATE_CLOSED;
1513 break;
1514 case NES_CM_STATE_CLOSE_WAIT:
1515 case NES_CM_STATE_LAST_ACK:
1516 case NES_CM_STATE_CLOSING:
1517 case NES_CM_STATE_TSA:
1518 default:
1519 nes_debug(NES_DBG_CM, "Received a fin while in %x state\n",
1520 cm_node->state);
1521 ret = -EINVAL;
1522 break;
1523 }
1524 } 1698 }
1699}
1525 1700
1526 if (datasize) { 1701static void cleanup_retrans_entry(struct nes_cm_node *cm_node)
1527 u8 *dataloc = skb->data; 1702{
1528 /* figure out what state we are in and handle transition to next state */ 1703 unsigned long flags;
1529 switch (cm_node->state) {
1530 case NES_CM_STATE_LISTENING:
1531 case NES_CM_STATE_SYN_RCVD:
1532 case NES_CM_STATE_SYN_SENT:
1533 case NES_CM_STATE_FIN_WAIT1:
1534 case NES_CM_STATE_FIN_WAIT2:
1535 case NES_CM_STATE_CLOSE_WAIT:
1536 case NES_CM_STATE_LAST_ACK:
1537 case NES_CM_STATE_CLOSING:
1538 break;
1539 case NES_CM_STATE_MPAREQ_SENT:
1540 /* recv the mpa res frame, ret=frame len (incl priv data) */
1541 ret = parse_mpa(cm_node, dataloc, datasize);
1542 if (ret < 0)
1543 break;
1544 /* set the req frame payload len in skb */
1545 /* we are done handling this state, set node to a TSA state */
1546 cm_node->state = NES_CM_STATE_TSA;
1547 send_ack(cm_node);
1548 create_event(cm_node, NES_CM_EVENT_CONNECTED);
1549 break;
1550
1551 case NES_CM_STATE_ESTABLISHED:
1552 /* we are expecting an MPA req frame */
1553 ret = parse_mpa(cm_node, dataloc, datasize);
1554 if (ret < 0) {
1555 break;
1556 }
1557 cm_node->state = NES_CM_STATE_TSA;
1558 send_ack(cm_node);
1559 /* we got a valid MPA request, create an event */
1560 create_event(cm_node, NES_CM_EVENT_MPA_REQ);
1561 break;
1562 case NES_CM_STATE_TSA:
1563 handle_exception_pkt(cm_node, skb);
1564 break;
1565 case NES_CM_STATE_UNKNOWN:
1566 case NES_CM_STATE_INITED:
1567 default:
1568 ret = -1;
1569 }
1570 }
1571 1704
1572 return ret; 1705 spin_lock_irqsave(&cm_node->retrans_list_lock, flags);
1706 free_retrans_entry(cm_node);
1707 spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags);
1573} 1708}
1574 1709
1710/**
1711 * process_packet
1712 * Returns skb if to be freed, else it will return NULL if already used..
1713 */
1714static void process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb,
1715 struct nes_cm_core *cm_core)
1716{
1717 enum nes_tcpip_pkt_type pkt_type = NES_PKT_TYPE_UNKNOWN;
1718 struct tcphdr *tcph = tcp_hdr(skb);
1719 skb_pull(skb, ip_hdr(skb)->ihl << 2);
1720
1721 nes_debug(NES_DBG_CM, "process_packet: cm_node=%p state =%d syn=%d "
1722 "ack=%d rst=%d fin=%d\n", cm_node, cm_node->state, tcph->syn,
1723 tcph->ack, tcph->rst, tcph->fin);
1724
1725 if (tcph->rst)
1726 pkt_type = NES_PKT_TYPE_RST;
1727 else if (tcph->syn) {
1728 pkt_type = NES_PKT_TYPE_SYN;
1729 if (tcph->ack)
1730 pkt_type = NES_PKT_TYPE_SYNACK;
1731 } else if (tcph->fin)
1732 pkt_type = NES_PKT_TYPE_FIN;
1733 else if (tcph->ack)
1734 pkt_type = NES_PKT_TYPE_ACK;
1735
1736 switch (pkt_type) {
1737 case NES_PKT_TYPE_SYN:
1738 handle_syn_pkt(cm_node, skb, tcph);
1739 break;
1740 case NES_PKT_TYPE_SYNACK:
1741 handle_synack_pkt(cm_node, skb, tcph);
1742 break;
1743 case NES_PKT_TYPE_ACK:
1744 handle_ack_pkt(cm_node, skb, tcph);
1745 break;
1746 case NES_PKT_TYPE_RST:
1747 handle_rst_pkt(cm_node, skb, tcph);
1748 break;
1749 case NES_PKT_TYPE_FIN:
1750 handle_fin_pkt(cm_node, skb, tcph);
1751 break;
1752 default:
1753 drop_packet(skb);
1754 break;
1755 }
1756}
1575 1757
1576/** 1758/**
1577 * mini_cm_listen - create a listen node with params 1759 * mini_cm_listen - create a listen node with params
1578 */ 1760 */
1579static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core, 1761static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
1580 struct nes_vnic *nesvnic, struct nes_cm_info *cm_info) 1762 struct nes_vnic *nesvnic, struct nes_cm_info *cm_info)
1581{ 1763{
1582 struct nes_cm_listener *listener; 1764 struct nes_cm_listener *listener;
1583 unsigned long flags; 1765 unsigned long flags;
@@ -1644,37 +1826,36 @@ static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
1644/** 1826/**
1645 * mini_cm_connect - make a connection node with params 1827 * mini_cm_connect - make a connection node with params
1646 */ 1828 */
1647static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core, 1829struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
1648 struct nes_vnic *nesvnic, 1830 struct nes_vnic *nesvnic, u16 private_data_len,
1649 struct ietf_mpa_frame *mpa_frame, 1831 void *private_data, struct nes_cm_info *cm_info)
1650 struct nes_cm_info *cm_info)
1651{ 1832{
1652 int ret = 0; 1833 int ret = 0;
1653 struct nes_cm_node *cm_node; 1834 struct nes_cm_node *cm_node;
1654 struct nes_cm_listener *loopbackremotelistener; 1835 struct nes_cm_listener *loopbackremotelistener;
1655 struct nes_cm_node *loopbackremotenode; 1836 struct nes_cm_node *loopbackremotenode;
1656 struct nes_cm_info loopback_cm_info; 1837 struct nes_cm_info loopback_cm_info;
1657 1838 u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) + private_data_len;
1658 u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) + 1839 struct ietf_mpa_frame *mpa_frame = NULL;
1659 ntohs(mpa_frame->priv_data_len);
1660
1661 cm_info->loc_addr = htonl(cm_info->loc_addr);
1662 cm_info->rem_addr = htonl(cm_info->rem_addr);
1663 cm_info->loc_port = htons(cm_info->loc_port);
1664 cm_info->rem_port = htons(cm_info->rem_port);
1665 1840
1666 /* create a CM connection node */ 1841 /* create a CM connection node */
1667 cm_node = make_cm_node(cm_core, nesvnic, cm_info, NULL); 1842 cm_node = make_cm_node(cm_core, nesvnic, cm_info, NULL);
1668 if (!cm_node) 1843 if (!cm_node)
1669 return NULL; 1844 return NULL;
1845 mpa_frame = &cm_node->mpa_frame;
1846 strcpy(mpa_frame->key, IEFT_MPA_KEY_REQ);
1847 mpa_frame->flags = IETF_MPA_FLAGS_CRC;
1848 mpa_frame->rev = IETF_MPA_VERSION;
1849 mpa_frame->priv_data_len = htons(private_data_len);
1670 1850
1671 /* set our node side to client (active) side */ 1851 /* set our node side to client (active) side */
1672 cm_node->tcp_cntxt.client = 1; 1852 cm_node->tcp_cntxt.client = 1;
1673 cm_node->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE; 1853 cm_node->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE;
1674 1854
1675 if (cm_info->loc_addr == cm_info->rem_addr) { 1855 if (cm_info->loc_addr == cm_info->rem_addr) {
1676 loopbackremotelistener = find_listener(cm_core, cm_node->rem_addr, 1856 loopbackremotelistener = find_listener(cm_core,
1677 cm_node->rem_port, NES_CM_LISTENER_ACTIVE_STATE); 1857 ntohl(nesvnic->local_ipaddr), cm_node->rem_port,
1858 NES_CM_LISTENER_ACTIVE_STATE);
1678 if (loopbackremotelistener == NULL) { 1859 if (loopbackremotelistener == NULL) {
1679 create_event(cm_node, NES_CM_EVENT_ABORTED); 1860 create_event(cm_node, NES_CM_EVENT_ABORTED);
1680 } else { 1861 } else {
@@ -1683,26 +1864,35 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
1683 loopback_cm_info.loc_port = cm_info->rem_port; 1864 loopback_cm_info.loc_port = cm_info->rem_port;
1684 loopback_cm_info.rem_port = cm_info->loc_port; 1865 loopback_cm_info.rem_port = cm_info->loc_port;
1685 loopback_cm_info.cm_id = loopbackremotelistener->cm_id; 1866 loopback_cm_info.cm_id = loopbackremotelistener->cm_id;
1686 loopbackremotenode = make_cm_node(cm_core, nesvnic, &loopback_cm_info, 1867 loopbackremotenode = make_cm_node(cm_core, nesvnic,
1687 loopbackremotelistener); 1868 &loopback_cm_info, loopbackremotelistener);
1688 loopbackremotenode->loopbackpartner = cm_node; 1869 loopbackremotenode->loopbackpartner = cm_node;
1689 loopbackremotenode->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE; 1870 loopbackremotenode->tcp_cntxt.rcv_wscale =
1871 NES_CM_DEFAULT_RCV_WND_SCALE;
1690 cm_node->loopbackpartner = loopbackremotenode; 1872 cm_node->loopbackpartner = loopbackremotenode;
1691 memcpy(loopbackremotenode->mpa_frame_buf, &mpa_frame->priv_data, 1873 memcpy(loopbackremotenode->mpa_frame_buf, private_data,
1692 mpa_frame_size); 1874 private_data_len);
1693 loopbackremotenode->mpa_frame_size = mpa_frame_size - 1875 loopbackremotenode->mpa_frame_size = private_data_len;
1694 sizeof(struct ietf_mpa_frame);
1695 1876
1696 /* we are done handling this state, set node to a TSA state */ 1877 /* we are done handling this state. */
1878 /* set node to a TSA state */
1697 cm_node->state = NES_CM_STATE_TSA; 1879 cm_node->state = NES_CM_STATE_TSA;
1698 cm_node->tcp_cntxt.rcv_nxt = loopbackremotenode->tcp_cntxt.loc_seq_num; 1880 cm_node->tcp_cntxt.rcv_nxt =
1699 loopbackremotenode->tcp_cntxt.rcv_nxt = cm_node->tcp_cntxt.loc_seq_num; 1881 loopbackremotenode->tcp_cntxt.loc_seq_num;
1700 cm_node->tcp_cntxt.max_snd_wnd = loopbackremotenode->tcp_cntxt.rcv_wnd; 1882 loopbackremotenode->tcp_cntxt.rcv_nxt =
1701 loopbackremotenode->tcp_cntxt.max_snd_wnd = cm_node->tcp_cntxt.rcv_wnd; 1883 cm_node->tcp_cntxt.loc_seq_num;
1702 cm_node->tcp_cntxt.snd_wnd = loopbackremotenode->tcp_cntxt.rcv_wnd; 1884 cm_node->tcp_cntxt.max_snd_wnd =
1703 loopbackremotenode->tcp_cntxt.snd_wnd = cm_node->tcp_cntxt.rcv_wnd; 1885 loopbackremotenode->tcp_cntxt.rcv_wnd;
1704 cm_node->tcp_cntxt.snd_wscale = loopbackremotenode->tcp_cntxt.rcv_wscale; 1886 loopbackremotenode->tcp_cntxt.max_snd_wnd =
1705 loopbackremotenode->tcp_cntxt.snd_wscale = cm_node->tcp_cntxt.rcv_wscale; 1887 cm_node->tcp_cntxt.rcv_wnd;
1888 cm_node->tcp_cntxt.snd_wnd =
1889 loopbackremotenode->tcp_cntxt.rcv_wnd;
1890 loopbackremotenode->tcp_cntxt.snd_wnd =
1891 cm_node->tcp_cntxt.rcv_wnd;
1892 cm_node->tcp_cntxt.snd_wscale =
1893 loopbackremotenode->tcp_cntxt.rcv_wscale;
1894 loopbackremotenode->tcp_cntxt.snd_wscale =
1895 cm_node->tcp_cntxt.rcv_wscale;
1706 1896
1707 create_event(loopbackremotenode, NES_CM_EVENT_MPA_REQ); 1897 create_event(loopbackremotenode, NES_CM_EVENT_MPA_REQ);
1708 } 1898 }
@@ -1712,16 +1902,29 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
1712 /* set our node side to client (active) side */ 1902 /* set our node side to client (active) side */
1713 cm_node->tcp_cntxt.client = 1; 1903 cm_node->tcp_cntxt.client = 1;
1714 /* init our MPA frame ptr */ 1904 /* init our MPA frame ptr */
1715 memcpy(&cm_node->mpa_frame, mpa_frame, mpa_frame_size); 1905 memcpy(mpa_frame->priv_data, private_data, private_data_len);
1906
1716 cm_node->mpa_frame_size = mpa_frame_size; 1907 cm_node->mpa_frame_size = mpa_frame_size;
1717 1908
1718 /* send a syn and goto syn sent state */ 1909 /* send a syn and goto syn sent state */
1719 cm_node->state = NES_CM_STATE_SYN_SENT; 1910 cm_node->state = NES_CM_STATE_SYN_SENT;
1720 ret = send_syn(cm_node, 0); 1911 ret = send_syn(cm_node, 0, NULL);
1912
1913 if (ret) {
1914 /* error in sending the syn free up the cm_node struct */
1915 nes_debug(NES_DBG_CM, "Api - connect() FAILED: dest "
1916 "addr=0x%08X, port=0x%04x, cm_node=%p, cm_id = %p.\n",
1917 cm_node->rem_addr, cm_node->rem_port, cm_node,
1918 cm_node->cm_id);
1919 rem_ref_cm_node(cm_node->cm_core, cm_node);
1920 cm_node = NULL;
1921 }
1721 1922
1722 nes_debug(NES_DBG_CM, "Api - connect(): dest addr=0x%08X, port=0x%04x," 1923 if (cm_node)
1723 " cm_node=%p, cm_id = %p.\n", 1924 nes_debug(NES_DBG_CM, "Api - connect(): dest addr=0x%08X,"
1724 cm_node->rem_addr, cm_node->rem_port, cm_node, cm_node->cm_id); 1925 "port=0x%04x, cm_node=%p, cm_id = %p.\n",
1926 cm_node->rem_addr, cm_node->rem_port, cm_node,
1927 cm_node->cm_id);
1725 1928
1726 return cm_node; 1929 return cm_node;
1727} 1930}
@@ -1731,8 +1934,8 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
1731 * mini_cm_accept - accept a connection 1934 * mini_cm_accept - accept a connection
1732 * This function is never called 1935 * This function is never called
1733 */ 1936 */
1734static int mini_cm_accept(struct nes_cm_core *cm_core, struct ietf_mpa_frame *mpa_frame, 1937static int mini_cm_accept(struct nes_cm_core *cm_core,
1735 struct nes_cm_node *cm_node) 1938 struct ietf_mpa_frame *mpa_frame, struct nes_cm_node *cm_node)
1736{ 1939{
1737 return 0; 1940 return 0;
1738} 1941}
@@ -1742,32 +1945,26 @@ static int mini_cm_accept(struct nes_cm_core *cm_core, struct ietf_mpa_frame *mp
1742 * mini_cm_reject - reject and teardown a connection 1945 * mini_cm_reject - reject and teardown a connection
1743 */ 1946 */
1744static int mini_cm_reject(struct nes_cm_core *cm_core, 1947static int mini_cm_reject(struct nes_cm_core *cm_core,
1745 struct ietf_mpa_frame *mpa_frame, 1948 struct ietf_mpa_frame *mpa_frame, struct nes_cm_node *cm_node)
1746 struct nes_cm_node *cm_node)
1747{ 1949{
1748 int ret = 0; 1950 int ret = 0;
1749 struct sk_buff *skb;
1750 u16 mpa_frame_size = sizeof(struct ietf_mpa_frame) +
1751 ntohs(mpa_frame->priv_data_len);
1752 1951
1753 skb = get_free_pkt(cm_node); 1952 nes_debug(NES_DBG_CM, "%s cm_node=%p type=%d state=%d\n",
1754 if (!skb) { 1953 __func__, cm_node, cm_node->tcp_cntxt.client, cm_node->state);
1755 nes_debug(NES_DBG_CM, "Failed to get a Free pkt\n");
1756 return -1;
1757 }
1758
1759 /* send an MPA Request frame */
1760 form_cm_frame(skb, cm_node, NULL, 0, mpa_frame, mpa_frame_size, SET_ACK | SET_FIN);
1761 ret = schedule_nes_timer(cm_node, skb, NES_TIMER_TYPE_SEND, 1, 0);
1762 1954
1955 if (cm_node->tcp_cntxt.client)
1956 return ret;
1957 cleanup_retrans_entry(cm_node);
1763 cm_node->state = NES_CM_STATE_CLOSED; 1958 cm_node->state = NES_CM_STATE_CLOSED;
1764 ret = send_fin(cm_node, NULL); 1959 ret = send_fin(cm_node, NULL);
1765 1960
1766 if (ret < 0) { 1961 if (cm_node->accept_pend) {
1767 printk(KERN_INFO PFX "failed to send MPA Reply (reject)\n"); 1962 BUG_ON(!cm_node->listener);
1768 return ret; 1963 atomic_dec(&cm_node->listener->pend_accepts_cnt);
1964 BUG_ON(atomic_read(&cm_node->listener->pend_accepts_cnt) < 0);
1769 } 1965 }
1770 1966
1967 ret = send_reset(cm_node, NULL);
1771 return ret; 1968 return ret;
1772} 1969}
1773 1970
@@ -1783,35 +1980,39 @@ static int mini_cm_close(struct nes_cm_core *cm_core, struct nes_cm_node *cm_nod
1783 return -EINVAL; 1980 return -EINVAL;
1784 1981
1785 switch (cm_node->state) { 1982 switch (cm_node->state) {
1786 /* if passed in node is null, create a reference key node for node search */ 1983 case NES_CM_STATE_SYN_RCVD:
1787 /* check if we found an owner node for this pkt */ 1984 case NES_CM_STATE_SYN_SENT:
1788 case NES_CM_STATE_SYN_RCVD: 1985 case NES_CM_STATE_ONE_SIDE_ESTABLISHED:
1789 case NES_CM_STATE_SYN_SENT: 1986 case NES_CM_STATE_ESTABLISHED:
1790 case NES_CM_STATE_ONE_SIDE_ESTABLISHED: 1987 case NES_CM_STATE_ACCEPTING:
1791 case NES_CM_STATE_ESTABLISHED: 1988 case NES_CM_STATE_MPAREQ_SENT:
1792 case NES_CM_STATE_ACCEPTING: 1989 case NES_CM_STATE_MPAREQ_RCVD:
1793 case NES_CM_STATE_MPAREQ_SENT: 1990 cleanup_retrans_entry(cm_node);
1794 cm_node->state = NES_CM_STATE_FIN_WAIT1; 1991 send_reset(cm_node, NULL);
1795 send_fin(cm_node, NULL); 1992 break;
1796 break; 1993 case NES_CM_STATE_CLOSE_WAIT:
1797 case NES_CM_STATE_CLOSE_WAIT: 1994 cm_node->state = NES_CM_STATE_LAST_ACK;
1798 cm_node->state = NES_CM_STATE_LAST_ACK; 1995 send_fin(cm_node, NULL);
1799 send_fin(cm_node, NULL); 1996 break;
1800 break; 1997 case NES_CM_STATE_FIN_WAIT1:
1801 case NES_CM_STATE_FIN_WAIT1: 1998 case NES_CM_STATE_FIN_WAIT2:
1802 case NES_CM_STATE_FIN_WAIT2: 1999 case NES_CM_STATE_LAST_ACK:
1803 case NES_CM_STATE_LAST_ACK: 2000 case NES_CM_STATE_TIME_WAIT:
1804 case NES_CM_STATE_TIME_WAIT: 2001 case NES_CM_STATE_CLOSING:
1805 case NES_CM_STATE_CLOSING: 2002 ret = -1;
1806 ret = -1; 2003 break;
1807 break; 2004 case NES_CM_STATE_LISTENING:
1808 case NES_CM_STATE_LISTENING: 2005 case NES_CM_STATE_UNKNOWN:
1809 case NES_CM_STATE_UNKNOWN: 2006 case NES_CM_STATE_INITED:
1810 case NES_CM_STATE_INITED: 2007 case NES_CM_STATE_CLOSED:
1811 case NES_CM_STATE_CLOSED: 2008 ret = rem_ref_cm_node(cm_core, cm_node);
1812 case NES_CM_STATE_TSA: 2009 break;
1813 ret = rem_ref_cm_node(cm_core, cm_node); 2010 case NES_CM_STATE_TSA:
1814 break; 2011 if (cm_node->send_entry)
2012 printk(KERN_ERR "ERROR Close got called from STATE_TSA "
2013 "send_entry=%p\n", cm_node->send_entry);
2014 ret = rem_ref_cm_node(cm_core, cm_node);
2015 break;
1815 } 2016 }
1816 cm_node->cm_id = NULL; 2017 cm_node->cm_id = NULL;
1817 return ret; 2018 return ret;
@@ -1822,25 +2023,30 @@ static int mini_cm_close(struct nes_cm_core *cm_core, struct nes_cm_node *cm_nod
1822 * recv_pkt - recv an ETHERNET packet, and process it through CM 2023 * recv_pkt - recv an ETHERNET packet, and process it through CM
1823 * node state machine 2024 * node state machine
1824 */ 2025 */
1825static int mini_cm_recv_pkt(struct nes_cm_core *cm_core, struct nes_vnic *nesvnic, 2026static void mini_cm_recv_pkt(struct nes_cm_core *cm_core,
1826 struct sk_buff *skb) 2027 struct nes_vnic *nesvnic, struct sk_buff *skb)
1827{ 2028{
1828 struct nes_cm_node *cm_node = NULL; 2029 struct nes_cm_node *cm_node = NULL;
1829 struct nes_cm_listener *listener = NULL; 2030 struct nes_cm_listener *listener = NULL;
1830 struct iphdr *iph; 2031 struct iphdr *iph;
1831 struct tcphdr *tcph; 2032 struct tcphdr *tcph;
1832 struct nes_cm_info nfo; 2033 struct nes_cm_info nfo;
1833 int ret = 0;
1834 2034
1835 if (!skb || skb->len < sizeof(struct iphdr) + sizeof(struct tcphdr)) { 2035 if (!skb)
1836 ret = -EINVAL; 2036 return;
1837 goto out; 2037 if (skb->len < sizeof(struct iphdr) + sizeof(struct tcphdr)) {
2038 dev_kfree_skb_any(skb);
2039 return;
1838 } 2040 }
1839 2041
1840 iph = (struct iphdr *)skb->data; 2042 iph = (struct iphdr *)skb->data;
1841 tcph = (struct tcphdr *)(skb->data + sizeof(struct iphdr)); 2043 tcph = (struct tcphdr *)(skb->data + sizeof(struct iphdr));
1842 skb_reset_network_header(skb); 2044 skb_reset_network_header(skb);
1843 skb_set_transport_header(skb, sizeof(*tcph)); 2045 skb_set_transport_header(skb, sizeof(*tcph));
2046 if (!tcph) {
2047 dev_kfree_skb_any(skb);
2048 return;
2049 }
1844 skb->len = ntohs(iph->tot_len); 2050 skb->len = ntohs(iph->tot_len);
1845 2051
1846 nfo.loc_addr = ntohl(iph->daddr); 2052 nfo.loc_addr = ntohl(iph->daddr);
@@ -1853,61 +2059,60 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core, struct nes_vnic *nesvni
1853 NIPQUAD(iph->daddr), tcph->dest, 2059 NIPQUAD(iph->daddr), tcph->dest,
1854 NIPQUAD(iph->saddr), tcph->source); 2060 NIPQUAD(iph->saddr), tcph->source);
1855 2061
1856 /* note: this call is going to increment cm_node ref count */ 2062 do {
1857 cm_node = find_node(cm_core, 2063 cm_node = find_node(cm_core,
1858 nfo.rem_port, nfo.rem_addr, 2064 nfo.rem_port, nfo.rem_addr,
1859 nfo.loc_port, nfo.loc_addr); 2065 nfo.loc_port, nfo.loc_addr);
1860 2066
1861 if (!cm_node) {
1862 listener = find_listener(cm_core, nfo.loc_addr, nfo.loc_port,
1863 NES_CM_LISTENER_ACTIVE_STATE);
1864 if (listener) {
1865 nfo.cm_id = listener->cm_id;
1866 nfo.conn_type = listener->conn_type;
1867 } else {
1868 nfo.cm_id = NULL;
1869 nfo.conn_type = 0;
1870 }
1871
1872 cm_node = make_cm_node(cm_core, nesvnic, &nfo, listener);
1873 if (!cm_node) { 2067 if (!cm_node) {
1874 nes_debug(NES_DBG_CM, "Unable to allocate node\n"); 2068 /* Only type of packet accepted are for */
2069 /* the PASSIVE open (syn only) */
2070 if ((!tcph->syn) || (tcph->ack)) {
2071 cm_packets_dropped++;
2072 break;
2073 }
2074 listener = find_listener(cm_core, nfo.loc_addr,
2075 nfo.loc_port,
2076 NES_CM_LISTENER_ACTIVE_STATE);
1875 if (listener) { 2077 if (listener) {
1876 nes_debug(NES_DBG_CM, "unable to allocate node and decrementing listener refcount\n"); 2078 nfo.cm_id = listener->cm_id;
2079 nfo.conn_type = listener->conn_type;
2080 } else {
2081 nes_debug(NES_DBG_CM, "Unable to find listener "
2082 "for the pkt\n");
2083 cm_packets_dropped++;
2084 dev_kfree_skb_any(skb);
2085 break;
2086 }
2087
2088 cm_node = make_cm_node(cm_core, nesvnic, &nfo,
2089 listener);
2090 if (!cm_node) {
2091 nes_debug(NES_DBG_CM, "Unable to allocate "
2092 "node\n");
2093 cm_packets_dropped++;
1877 atomic_dec(&listener->ref_count); 2094 atomic_dec(&listener->ref_count);
2095 dev_kfree_skb_any(skb);
2096 break;
1878 } 2097 }
1879 ret = -1; 2098 if (!tcph->rst && !tcph->fin) {
1880 goto out; 2099 cm_node->state = NES_CM_STATE_LISTENING;
1881 } 2100 } else {
1882 if (!listener) { 2101 cm_packets_dropped++;
1883 nes_debug(NES_DBG_CM, "Packet found for unknown port %x refcnt=%d\n", 2102 rem_ref_cm_node(cm_core, cm_node);
1884 nfo.loc_port, atomic_read(&cm_node->ref_count)); 2103 dev_kfree_skb_any(skb);
1885 if (!tcph->rst) { 2104 break;
1886 nes_debug(NES_DBG_CM, "Packet found for unknown port=%d"
1887 " rem_port=%d refcnt=%d\n",
1888 nfo.loc_port, nfo.rem_port, atomic_read(&cm_node->ref_count));
1889
1890 cm_node->tcp_cntxt.rcv_nxt = ntohl(tcph->seq);
1891 cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);
1892 send_reset(cm_node);
1893 } 2105 }
2106 add_ref_cm_node(cm_node);
2107 } else if (cm_node->state == NES_CM_STATE_TSA) {
1894 rem_ref_cm_node(cm_core, cm_node); 2108 rem_ref_cm_node(cm_core, cm_node);
1895 ret = -1; 2109 atomic_inc(&cm_accel_dropped_pkts);
1896 goto out; 2110 dev_kfree_skb_any(skb);
2111 break;
1897 } 2112 }
1898 add_ref_cm_node(cm_node); 2113 process_packet(cm_node, skb, cm_core);
1899 cm_node->state = NES_CM_STATE_LISTENING; 2114 rem_ref_cm_node(cm_core, cm_node);
1900 } 2115 } while (0);
1901
1902 nes_debug(NES_DBG_CM, "Processing Packet for node %p, data = (%p):\n",
1903 cm_node, skb->data);
1904 process_packet(cm_node, skb, cm_core);
1905
1906 rem_ref_cm_node(cm_core, cm_node);
1907 out:
1908 if (skb)
1909 dev_kfree_skb_any(skb);
1910 return ret;
1911} 2116}
1912 2117
1913 2118
@@ -2107,15 +2312,12 @@ int nes_cm_disconn(struct nes_qp *nesqp)
2107 if (nesqp->disconn_pending == 0) { 2312 if (nesqp->disconn_pending == 0) {
2108 nesqp->disconn_pending++; 2313 nesqp->disconn_pending++;
2109 spin_unlock_irqrestore(&nesqp->lock, flags); 2314 spin_unlock_irqrestore(&nesqp->lock, flags);
2110 /* nes_add_ref(&nesqp->ibqp); */
2111 /* init our disconnect work element, to */ 2315 /* init our disconnect work element, to */
2112 INIT_WORK(&nesqp->disconn_work, nes_disconnect_worker); 2316 INIT_WORK(&nesqp->disconn_work, nes_disconnect_worker);
2113 2317
2114 queue_work(g_cm_core->disconn_wq, &nesqp->disconn_work); 2318 queue_work(g_cm_core->disconn_wq, &nesqp->disconn_work);
2115 } else { 2319 } else
2116 spin_unlock_irqrestore(&nesqp->lock, flags); 2320 spin_unlock_irqrestore(&nesqp->lock, flags);
2117 nes_rem_ref(&nesqp->ibqp);
2118 }
2119 2321
2120 return 0; 2322 return 0;
2121} 2323}
@@ -2161,7 +2363,6 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
2161 nes_debug(NES_DBG_CM, "QP%u disconnect_worker cmid is NULL\n", 2363 nes_debug(NES_DBG_CM, "QP%u disconnect_worker cmid is NULL\n",
2162 nesqp->hwqp.qp_id); 2364 nesqp->hwqp.qp_id);
2163 spin_unlock_irqrestore(&nesqp->lock, flags); 2365 spin_unlock_irqrestore(&nesqp->lock, flags);
2164 nes_rem_ref(&nesqp->ibqp);
2165 return -1; 2366 return -1;
2166 } 2367 }
2167 2368
@@ -2182,30 +2383,31 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
2182 atomic_inc(&cm_disconnects); 2383 atomic_inc(&cm_disconnects);
2183 cm_event.event = IW_CM_EVENT_DISCONNECT; 2384 cm_event.event = IW_CM_EVENT_DISCONNECT;
2184 if (last_ae == NES_AEQE_AEID_LLP_CONNECTION_RESET) { 2385 if (last_ae == NES_AEQE_AEID_LLP_CONNECTION_RESET) {
2185 issued_disconnect_reset = 1;
2186 cm_event.status = IW_CM_EVENT_STATUS_RESET; 2386 cm_event.status = IW_CM_EVENT_STATUS_RESET;
2187 nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event (status reset) for " 2387 nes_debug(NES_DBG_CM, "Generating a CM "
2188 " QP%u, cm_id = %p. \n", 2388 "Disconnect Event (status reset) for "
2189 nesqp->hwqp.qp_id, cm_id); 2389 "QP%u, cm_id = %p. \n",
2190 } else { 2390 nesqp->hwqp.qp_id, cm_id);
2391 } else
2191 cm_event.status = IW_CM_EVENT_STATUS_OK; 2392 cm_event.status = IW_CM_EVENT_STATUS_OK;
2192 }
2193 2393
2194 cm_event.local_addr = cm_id->local_addr; 2394 cm_event.local_addr = cm_id->local_addr;
2195 cm_event.remote_addr = cm_id->remote_addr; 2395 cm_event.remote_addr = cm_id->remote_addr;
2196 cm_event.private_data = NULL; 2396 cm_event.private_data = NULL;
2197 cm_event.private_data_len = 0; 2397 cm_event.private_data_len = 0;
2198 2398
2199 nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event for " 2399 nes_debug(NES_DBG_CM, "Generating a CM Disconnect Event"
2200 " QP%u, SQ Head = %u, SQ Tail = %u. cm_id = %p, refcount = %u.\n", 2400 " for QP%u, SQ Head = %u, SQ Tail = %u. "
2201 nesqp->hwqp.qp_id, 2401 "cm_id = %p, refcount = %u.\n",
2202 nesqp->hwqp.sq_head, nesqp->hwqp.sq_tail, cm_id, 2402 nesqp->hwqp.qp_id, nesqp->hwqp.sq_head,
2203 atomic_read(&nesqp->refcount)); 2403 nesqp->hwqp.sq_tail, cm_id,
2404 atomic_read(&nesqp->refcount));
2204 2405
2205 spin_unlock_irqrestore(&nesqp->lock, flags); 2406 spin_unlock_irqrestore(&nesqp->lock, flags);
2206 ret = cm_id->event_handler(cm_id, &cm_event); 2407 ret = cm_id->event_handler(cm_id, &cm_event);
2207 if (ret) 2408 if (ret)
2208 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 2409 nes_debug(NES_DBG_CM, "OFA CM event_handler "
2410 "returned, ret=%d\n", ret);
2209 spin_lock_irqsave(&nesqp->lock, flags); 2411 spin_lock_irqsave(&nesqp->lock, flags);
2210 } 2412 }
2211 2413
@@ -2247,31 +2449,24 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
2247 if (nesqp->flush_issued == 0) { 2449 if (nesqp->flush_issued == 0) {
2248 nesqp->flush_issued = 1; 2450 nesqp->flush_issued = 1;
2249 spin_unlock_irqrestore(&nesqp->lock, flags); 2451 spin_unlock_irqrestore(&nesqp->lock, flags);
2250 flush_wqes(nesvnic->nesdev, nesqp, NES_CQP_FLUSH_RQ, 1); 2452 flush_wqes(nesvnic->nesdev, nesqp,
2251 } else { 2453 NES_CQP_FLUSH_RQ, 1);
2454 } else
2252 spin_unlock_irqrestore(&nesqp->lock, flags); 2455 spin_unlock_irqrestore(&nesqp->lock, flags);
2253 }
2254
2255 /* This reference is from either ModifyQP or the AE processing,
2256 there is still a race here with modifyqp */
2257 nes_rem_ref(&nesqp->ibqp);
2258
2259 } else { 2456 } else {
2260 cm_id = nesqp->cm_id; 2457 cm_id = nesqp->cm_id;
2261 spin_unlock_irqrestore(&nesqp->lock, flags); 2458 spin_unlock_irqrestore(&nesqp->lock, flags);
2262 /* check to see if the inbound reset beat the outbound reset */ 2459 /* check to see if the inbound reset beat the outbound reset */
2263 if ((!cm_id) && (last_ae==NES_AEQE_AEID_RESET_SENT)) { 2460 if ((!cm_id) && (last_ae==NES_AEQE_AEID_RESET_SENT)) {
2264 nes_debug(NES_DBG_CM, "QP%u: Decing refcount due to inbound reset" 2461 nes_debug(NES_DBG_CM, "QP%u: Decing refcount "
2265 " beating the outbound reset.\n", 2462 "due to inbound reset beating the "
2266 nesqp->hwqp.qp_id); 2463 "outbound reset.\n", nesqp->hwqp.qp_id);
2267 nes_rem_ref(&nesqp->ibqp);
2268 } 2464 }
2269 } 2465 }
2270 } else { 2466 } else {
2271 nesqp->disconn_pending = 0; 2467 nesqp->disconn_pending = 0;
2272 spin_unlock_irqrestore(&nesqp->lock, flags); 2468 spin_unlock_irqrestore(&nesqp->lock, flags);
2273 } 2469 }
2274 nes_rem_ref(&nesqp->ibqp);
2275 2470
2276 return 0; 2471 return 0;
2277} 2472}
@@ -2349,71 +2544,82 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2349 nesdev = nesvnic->nesdev; 2544 nesdev = nesvnic->nesdev;
2350 adapter = nesdev->nesadapter; 2545 adapter = nesdev->nesadapter;
2351 2546
2352 nes_debug(NES_DBG_CM, "nesvnic=%p, netdev=%p, %s\n",
2353 nesvnic, nesvnic->netdev, nesvnic->netdev->name);
2354
2355 /* since this is from a listen, we were able to put node handle into cm_id */
2356 cm_node = (struct nes_cm_node *)cm_id->provider_data; 2547 cm_node = (struct nes_cm_node *)cm_id->provider_data;
2548 nes_debug(NES_DBG_CM, "nes_accept: cm_node= %p nesvnic=%p, netdev=%p,"
2549 "%s\n", cm_node, nesvnic, nesvnic->netdev,
2550 nesvnic->netdev->name);
2357 2551
2358 /* associate the node with the QP */ 2552 /* associate the node with the QP */
2359 nesqp->cm_node = (void *)cm_node; 2553 nesqp->cm_node = (void *)cm_node;
2554 cm_node->nesqp = nesqp;
2555 nes_add_ref(&nesqp->ibqp);
2360 2556
2361 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu\n", 2557 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
2362 nesqp->hwqp.qp_id, cm_node, jiffies); 2558 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
2363 atomic_inc(&cm_accepts); 2559 atomic_inc(&cm_accepts);
2364 2560
2365 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n", 2561 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
2366 atomic_read(&nesvnic->netdev->refcnt)); 2562 atomic_read(&nesvnic->netdev->refcnt));
2367 2563
2368 /* allocate the ietf frame and space for private data */ 2564 /* allocate the ietf frame and space for private data */
2369 nesqp->ietf_frame = pci_alloc_consistent(nesdev->pcidev, 2565 nesqp->ietf_frame = pci_alloc_consistent(nesdev->pcidev,
2370 sizeof(struct ietf_mpa_frame) + conn_param->private_data_len, 2566 sizeof(struct ietf_mpa_frame) + conn_param->private_data_len,
2371 &nesqp->ietf_frame_pbase); 2567 &nesqp->ietf_frame_pbase);
2372
2373 if (!nesqp->ietf_frame) {
2374 nes_debug(NES_DBG_CM, "Unable to allocate memory for private data\n");
2375 return -ENOMEM;
2376 }
2377 2568
2569 if (!nesqp->ietf_frame) {
2570 nes_debug(NES_DBG_CM, "Unable to allocate memory for private "
2571 "data\n");
2572 return -ENOMEM;
2573 }
2378 2574
2379 /* setup the MPA frame */
2380 nesqp->private_data_len = conn_param->private_data_len;
2381 memcpy(nesqp->ietf_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE);
2382 2575
2383 memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data, 2576 /* setup the MPA frame */
2384 conn_param->private_data_len); 2577 nesqp->private_data_len = conn_param->private_data_len;
2578 memcpy(nesqp->ietf_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE);
2385 2579
2386 nesqp->ietf_frame->priv_data_len = cpu_to_be16(conn_param->private_data_len); 2580 memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data,
2387 nesqp->ietf_frame->rev = mpa_version; 2581 conn_param->private_data_len);
2388 nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC;
2389 2582
2390 /* setup our first outgoing iWarp send WQE (the IETF frame response) */ 2583 nesqp->ietf_frame->priv_data_len =
2391 wqe = &nesqp->hwqp.sq_vbase[0]; 2584 cpu_to_be16(conn_param->private_data_len);
2585 nesqp->ietf_frame->rev = mpa_version;
2586 nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC;
2392 2587
2393 if (cm_id->remote_addr.sin_addr.s_addr != cm_id->local_addr.sin_addr.s_addr) { 2588 /* setup our first outgoing iWarp send WQE (the IETF frame response) */
2394 u64temp = (unsigned long)nesqp; 2589 wqe = &nesqp->hwqp.sq_vbase[0];
2395 u64temp |= NES_SW_CONTEXT_ALIGN>>1; 2590
2396 set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 2591 if (cm_id->remote_addr.sin_addr.s_addr !=
2397 u64temp); 2592 cm_id->local_addr.sin_addr.s_addr) {
2398 wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = 2593 u64temp = (unsigned long)nesqp;
2399 cpu_to_le32(NES_IWARP_SQ_WQE_STREAMING | NES_IWARP_SQ_WQE_WRPDU); 2594 u64temp |= NES_SW_CONTEXT_ALIGN>>1;
2400 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 2595 set_wqe_64bit_value(wqe->wqe_words,
2401 cpu_to_le32(conn_param->private_data_len + sizeof(struct ietf_mpa_frame)); 2596 NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX,
2402 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 2597 u64temp);
2403 cpu_to_le32((u32)nesqp->ietf_frame_pbase); 2598 wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] =
2404 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 2599 cpu_to_le32(NES_IWARP_SQ_WQE_STREAMING |
2405 cpu_to_le32((u32)((u64)nesqp->ietf_frame_pbase >> 32)); 2600 NES_IWARP_SQ_WQE_WRPDU);
2406 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 2601 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] =
2407 cpu_to_le32(conn_param->private_data_len + sizeof(struct ietf_mpa_frame)); 2602 cpu_to_le32(conn_param->private_data_len +
2408 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 2603 sizeof(struct ietf_mpa_frame));
2409 2604 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] =
2410 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32( 2605 cpu_to_le32((u32)nesqp->ietf_frame_pbase);
2411 NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | NES_QPCONTEXT_ORDIRD_WRPDU); 2606 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] =
2412 } else { 2607 cpu_to_le32((u32)((u64)nesqp->ietf_frame_pbase >> 32));
2413 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 2608 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] =
2414 NES_QPCONTEXT_ORDIRD_WRPDU | NES_QPCONTEXT_ORDIRD_ALSMM)); 2609 cpu_to_le32(conn_param->private_data_len +
2415 } 2610 sizeof(struct ietf_mpa_frame));
2416 nesqp->skip_lsmm = 1; 2611 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0;
2612
2613 nesqp->nesqp_context->ird_ord_sizes |=
2614 cpu_to_le32(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
2615 NES_QPCONTEXT_ORDIRD_WRPDU);
2616 } else {
2617 nesqp->nesqp_context->ird_ord_sizes |=
2618 cpu_to_le32((NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
2619 NES_QPCONTEXT_ORDIRD_WRPDU |
2620 NES_QPCONTEXT_ORDIRD_ALSMM));
2621 }
2622 nesqp->skip_lsmm = 1;
2417 2623
2418 2624
2419 /* Cache the cm_id in the qp */ 2625 /* Cache the cm_id in the qp */
@@ -2424,55 +2630,75 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2424 cm_id->provider_data = nesqp; 2630 cm_id->provider_data = nesqp;
2425 nesqp->active_conn = 0; 2631 nesqp->active_conn = 0;
2426 2632
2633 if (cm_node->state == NES_CM_STATE_TSA)
2634 nes_debug(NES_DBG_CM, "Already state = TSA for cm_node=%p\n",
2635 cm_node);
2636
2427 nes_cm_init_tsa_conn(nesqp, cm_node); 2637 nes_cm_init_tsa_conn(nesqp, cm_node);
2428 2638
2429 nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 2639 nesqp->nesqp_context->tcpPorts[0] =
2430 nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 2640 cpu_to_le16(ntohs(cm_id->local_addr.sin_port));
2431 nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 2641 nesqp->nesqp_context->tcpPorts[1] =
2642 cpu_to_le16(ntohs(cm_id->remote_addr.sin_port));
2643
2644 if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr))
2645 nesqp->nesqp_context->ip0 =
2646 cpu_to_le32(ntohl(nesvnic->local_ipaddr));
2647 else
2648 nesqp->nesqp_context->ip0 =
2649 cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr));
2432 2650
2433 nesqp->nesqp_context->misc2 |= cpu_to_le32( 2651 nesqp->nesqp_context->misc2 |= cpu_to_le32(
2434 (u32)PCI_FUNC(nesdev->pcidev->devfn) << NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 2652 (u32)PCI_FUNC(nesdev->pcidev->devfn) <<
2653 NES_QPCONTEXT_MISC2_SRC_IP_SHIFT);
2435 2654
2436 nesqp->nesqp_context->arp_index_vlan |= cpu_to_le32( 2655 nesqp->nesqp_context->arp_index_vlan |=
2437 nes_arp_table(nesdev, le32_to_cpu(nesqp->nesqp_context->ip0), NULL, 2656 cpu_to_le32(nes_arp_table(nesdev,
2657 le32_to_cpu(nesqp->nesqp_context->ip0), NULL,
2438 NES_ARP_RESOLVE) << 16); 2658 NES_ARP_RESOLVE) << 16);
2439 2659
2440 nesqp->nesqp_context->ts_val_delta = cpu_to_le32( 2660 nesqp->nesqp_context->ts_val_delta = cpu_to_le32(
2441 jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW)); 2661 jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW));
2442 2662
2443 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id); 2663 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id);
2444 2664
2445 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32( 2665 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32(
2446 ((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT)); 2666 ((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT));
2447 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((u32)conn_param->ord); 2667 nesqp->nesqp_context->ird_ord_sizes |=
2668 cpu_to_le32((u32)conn_param->ord);
2448 2669
2449 memset(&nes_quad, 0, sizeof(nes_quad)); 2670 memset(&nes_quad, 0, sizeof(nes_quad));
2450 nes_quad.DstIpAdrIndex = cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 2671 nes_quad.DstIpAdrIndex =
2451 nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 2672 cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24);
2452 nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; 2673 if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr))
2453 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2674 nes_quad.SrcIpadr = nesvnic->local_ipaddr;
2675 else
2676 nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr;
2677 nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port;
2678 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2454 2679
2455 /* Produce hash key */ 2680 /* Produce hash key */
2456 crc_value = get_crc_value(&nes_quad); 2681 crc_value = get_crc_value(&nes_quad);
2457 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff); 2682 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
2458 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n", 2683 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n",
2459 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask); 2684 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask);
2460 2685
2461 nesqp->hte_index &= adapter->hte_index_mask; 2686 nesqp->hte_index &= adapter->hte_index_mask;
2462 nesqp->nesqp_context->hte_index = cpu_to_le32(nesqp->hte_index); 2687 nesqp->nesqp_context->hte_index = cpu_to_le32(nesqp->hte_index);
2463 2688
2464 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node); 2689 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node);
2465 2690
2466 nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = 0x%08X:0x%04X," 2691 nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = "
2467 " rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + private data length=%zu.\n", 2692 "0x%08X:0x%04X, rcv_nxt=0x%08X, snd_nxt=0x%08X, mpa + "
2468 nesqp->hwqp.qp_id, 2693 "private data length=%zu.\n", nesqp->hwqp.qp_id,
2469 ntohl(cm_id->remote_addr.sin_addr.s_addr), 2694 ntohl(cm_id->remote_addr.sin_addr.s_addr),
2470 ntohs(cm_id->remote_addr.sin_port), 2695 ntohs(cm_id->remote_addr.sin_port),
2471 ntohl(cm_id->local_addr.sin_addr.s_addr), 2696 ntohl(cm_id->local_addr.sin_addr.s_addr),
2472 ntohs(cm_id->local_addr.sin_port), 2697 ntohs(cm_id->local_addr.sin_port),
2473 le32_to_cpu(nesqp->nesqp_context->rcv_nxt), 2698 le32_to_cpu(nesqp->nesqp_context->rcv_nxt),
2474 le32_to_cpu(nesqp->nesqp_context->snd_nxt), 2699 le32_to_cpu(nesqp->nesqp_context->snd_nxt),
2475 conn_param->private_data_len+sizeof(struct ietf_mpa_frame)); 2700 conn_param->private_data_len +
2701 sizeof(struct ietf_mpa_frame));
2476 2702
2477 attr.qp_state = IB_QPS_RTS; 2703 attr.qp_state = IB_QPS_RTS;
2478 nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL); 2704 nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL);
@@ -2489,15 +2715,16 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2489 cm_event.private_data_len = 0; 2715 cm_event.private_data_len = 0;
2490 ret = cm_id->event_handler(cm_id, &cm_event); 2716 ret = cm_id->event_handler(cm_id, &cm_event);
2491 if (cm_node->loopbackpartner) { 2717 if (cm_node->loopbackpartner) {
2492 cm_node->loopbackpartner->mpa_frame_size = nesqp->private_data_len; 2718 cm_node->loopbackpartner->mpa_frame_size =
2719 nesqp->private_data_len;
2493 /* copy entire MPA frame to our cm_node's frame */ 2720 /* copy entire MPA frame to our cm_node's frame */
2494 memcpy(cm_node->loopbackpartner->mpa_frame_buf, nesqp->ietf_frame->priv_data, 2721 memcpy(cm_node->loopbackpartner->mpa_frame_buf,
2495 nesqp->private_data_len); 2722 nesqp->ietf_frame->priv_data, nesqp->private_data_len);
2496 create_event(cm_node->loopbackpartner, NES_CM_EVENT_CONNECTED); 2723 create_event(cm_node->loopbackpartner, NES_CM_EVENT_CONNECTED);
2497 } 2724 }
2498 if (ret) 2725 if (ret)
2499 printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 2726 printk(KERN_ERR "%s[%u] OFA CM event_handler returned, "
2500 __func__, __LINE__, ret); 2727 "ret=%d\n", __func__, __LINE__, ret);
2501 2728
2502 return 0; 2729 return 0;
2503} 2730}
@@ -2555,74 +2782,61 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2555 if (!nesdev) 2782 if (!nesdev)
2556 return -EINVAL; 2783 return -EINVAL;
2557 2784
2558 atomic_inc(&cm_connects); 2785 nes_debug(NES_DBG_CM, "QP%u, current IP = 0x%08X, Destination IP = "
2559 2786 "0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", nesqp->hwqp.qp_id,
2560 nesqp->ietf_frame = kzalloc(sizeof(struct ietf_mpa_frame) + 2787 ntohl(nesvnic->local_ipaddr),
2561 conn_param->private_data_len, GFP_KERNEL); 2788 ntohl(cm_id->remote_addr.sin_addr.s_addr),
2562 if (!nesqp->ietf_frame) 2789 ntohs(cm_id->remote_addr.sin_port),
2563 return -ENOMEM; 2790 ntohl(cm_id->local_addr.sin_addr.s_addr),
2791 ntohs(cm_id->local_addr.sin_port));
2564 2792
2565 /* set qp as having an active connection */ 2793 atomic_inc(&cm_connects);
2566 nesqp->active_conn = 1; 2794 nesqp->active_conn = 1;
2567 2795
2568 nes_debug(NES_DBG_CM, "QP%u, Destination IP = 0x%08X:0x%04X, local = 0x%08X:0x%04X.\n",
2569 nesqp->hwqp.qp_id,
2570 ntohl(cm_id->remote_addr.sin_addr.s_addr),
2571 ntohs(cm_id->remote_addr.sin_port),
2572 ntohl(cm_id->local_addr.sin_addr.s_addr),
2573 ntohs(cm_id->local_addr.sin_port));
2574
2575 /* cache the cm_id in the qp */ 2796 /* cache the cm_id in the qp */
2576 nesqp->cm_id = cm_id; 2797 nesqp->cm_id = cm_id;
2577 2798
2578 cm_id->provider_data = nesqp; 2799 cm_id->provider_data = nesqp;
2579 2800
2580 /* copy the private data */
2581 if (conn_param->private_data_len) {
2582 memcpy(nesqp->ietf_frame->priv_data, conn_param->private_data,
2583 conn_param->private_data_len);
2584 }
2585
2586 nesqp->private_data_len = conn_param->private_data_len; 2801 nesqp->private_data_len = conn_param->private_data_len;
2587 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((u32)conn_param->ord); 2802 nesqp->nesqp_context->ird_ord_sizes |= cpu_to_le32((u32)conn_param->ord);
2588 nes_debug(NES_DBG_CM, "requested ord = 0x%08X.\n", (u32)conn_param->ord); 2803 nes_debug(NES_DBG_CM, "requested ord = 0x%08X.\n", (u32)conn_param->ord);
2589 nes_debug(NES_DBG_CM, "mpa private data len =%u\n", conn_param->private_data_len); 2804 nes_debug(NES_DBG_CM, "mpa private data len =%u\n",
2590 2805 conn_param->private_data_len);
2591 strcpy(&nesqp->ietf_frame->key[0], IEFT_MPA_KEY_REQ);
2592 nesqp->ietf_frame->flags = IETF_MPA_FLAGS_CRC;
2593 nesqp->ietf_frame->rev = IETF_MPA_VERSION;
2594 nesqp->ietf_frame->priv_data_len = htons(conn_param->private_data_len);
2595 2806
2596 if (cm_id->local_addr.sin_addr.s_addr != cm_id->remote_addr.sin_addr.s_addr) 2807 if (cm_id->local_addr.sin_addr.s_addr !=
2808 cm_id->remote_addr.sin_addr.s_addr)
2597 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2809 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port),
2598 PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); 2810 PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD);
2599 2811
2600 /* set up the connection params for the node */ 2812 /* set up the connection params for the node */
2601 cm_info.loc_addr = (cm_id->local_addr.sin_addr.s_addr); 2813 cm_info.loc_addr = htonl(cm_id->local_addr.sin_addr.s_addr);
2602 cm_info.loc_port = (cm_id->local_addr.sin_port); 2814 cm_info.loc_port = htons(cm_id->local_addr.sin_port);
2603 cm_info.rem_addr = (cm_id->remote_addr.sin_addr.s_addr); 2815 cm_info.rem_addr = htonl(cm_id->remote_addr.sin_addr.s_addr);
2604 cm_info.rem_port = (cm_id->remote_addr.sin_port); 2816 cm_info.rem_port = htons(cm_id->remote_addr.sin_port);
2605 cm_info.cm_id = cm_id; 2817 cm_info.cm_id = cm_id;
2606 cm_info.conn_type = NES_CM_IWARP_CONN_TYPE; 2818 cm_info.conn_type = NES_CM_IWARP_CONN_TYPE;
2607 2819
2608 cm_id->add_ref(cm_id); 2820 cm_id->add_ref(cm_id);
2609 nes_add_ref(&nesqp->ibqp);
2610 2821
2611 /* create a connect CM node connection */ 2822 /* create a connect CM node connection */
2612 cm_node = g_cm_core->api->connect(g_cm_core, nesvnic, nesqp->ietf_frame, &cm_info); 2823 cm_node = g_cm_core->api->connect(g_cm_core, nesvnic,
2824 conn_param->private_data_len, (void *)conn_param->private_data,
2825 &cm_info);
2613 if (!cm_node) { 2826 if (!cm_node) {
2614 if (cm_id->local_addr.sin_addr.s_addr != cm_id->remote_addr.sin_addr.s_addr) 2827 if (cm_id->local_addr.sin_addr.s_addr !=
2828 cm_id->remote_addr.sin_addr.s_addr)
2615 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2829 nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port),
2616 PCI_FUNC(nesdev->pcidev->devfn), NES_MANAGE_APBVT_DEL); 2830 PCI_FUNC(nesdev->pcidev->devfn),
2617 nes_rem_ref(&nesqp->ibqp); 2831 NES_MANAGE_APBVT_DEL);
2618 kfree(nesqp->ietf_frame); 2832
2619 nesqp->ietf_frame = NULL;
2620 cm_id->rem_ref(cm_id); 2833 cm_id->rem_ref(cm_id);
2621 return -ENOMEM; 2834 return -ENOMEM;
2622 } 2835 }
2623 2836
2624 cm_node->apbvt_set = 1; 2837 cm_node->apbvt_set = 1;
2625 nesqp->cm_node = cm_node; 2838 nesqp->cm_node = cm_node;
2839 cm_node->nesqp = nesqp;
2626 2840
2627 return 0; 2841 return 0;
2628} 2842}
@@ -2664,7 +2878,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
2664 2878
2665 cm_node = g_cm_core->api->listen(g_cm_core, nesvnic, &cm_info); 2879 cm_node = g_cm_core->api->listen(g_cm_core, nesvnic, &cm_info);
2666 if (!cm_node) { 2880 if (!cm_node) {
2667 printk("%s[%u] Error returned from listen API call\n", 2881 printk(KERN_ERR "%s[%u] Error returned from listen API call\n",
2668 __func__, __LINE__); 2882 __func__, __LINE__);
2669 return -ENOMEM; 2883 return -ENOMEM;
2670 } 2884 }
@@ -2672,10 +2886,13 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
2672 cm_id->provider_data = cm_node; 2886 cm_id->provider_data = cm_node;
2673 2887
2674 if (!cm_node->reused_node) { 2888 if (!cm_node->reused_node) {
2675 err = nes_manage_apbvt(nesvnic, ntohs(cm_id->local_addr.sin_port), 2889 err = nes_manage_apbvt(nesvnic,
2676 PCI_FUNC(nesvnic->nesdev->pcidev->devfn), NES_MANAGE_APBVT_ADD); 2890 ntohs(cm_id->local_addr.sin_port),
2891 PCI_FUNC(nesvnic->nesdev->pcidev->devfn),
2892 NES_MANAGE_APBVT_ADD);
2677 if (err) { 2893 if (err) {
2678 printk("nes_manage_apbvt call returned %d.\n", err); 2894 printk(KERN_ERR "nes_manage_apbvt call returned %d.\n",
2895 err);
2679 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node); 2896 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
2680 return err; 2897 return err;
2681 } 2898 }
@@ -2795,53 +3012,70 @@ static void cm_event_connected(struct nes_cm_event *event)
2795 nes_cm_init_tsa_conn(nesqp, cm_node); 3012 nes_cm_init_tsa_conn(nesqp, cm_node);
2796 3013
2797 /* set the QP tsa context */ 3014 /* set the QP tsa context */
2798 nesqp->nesqp_context->tcpPorts[0] = cpu_to_le16(ntohs(cm_id->local_addr.sin_port)); 3015 nesqp->nesqp_context->tcpPorts[0] =
2799 nesqp->nesqp_context->tcpPorts[1] = cpu_to_le16(ntohs(cm_id->remote_addr.sin_port)); 3016 cpu_to_le16(ntohs(cm_id->local_addr.sin_port));
2800 nesqp->nesqp_context->ip0 = cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr)); 3017 nesqp->nesqp_context->tcpPorts[1] =
3018 cpu_to_le16(ntohs(cm_id->remote_addr.sin_port));
3019 if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr))
3020 nesqp->nesqp_context->ip0 =
3021 cpu_to_le32(ntohl(nesvnic->local_ipaddr));
3022 else
3023 nesqp->nesqp_context->ip0 =
3024 cpu_to_le32(ntohl(cm_id->remote_addr.sin_addr.s_addr));
2801 3025
2802 nesqp->nesqp_context->misc2 |= cpu_to_le32( 3026 nesqp->nesqp_context->misc2 |= cpu_to_le32(
2803 (u32)PCI_FUNC(nesdev->pcidev->devfn) << NES_QPCONTEXT_MISC2_SRC_IP_SHIFT); 3027 (u32)PCI_FUNC(nesdev->pcidev->devfn) <<
3028 NES_QPCONTEXT_MISC2_SRC_IP_SHIFT);
2804 nesqp->nesqp_context->arp_index_vlan |= cpu_to_le32( 3029 nesqp->nesqp_context->arp_index_vlan |= cpu_to_le32(
2805 nes_arp_table(nesdev, le32_to_cpu(nesqp->nesqp_context->ip0), 3030 nes_arp_table(nesdev,
3031 le32_to_cpu(nesqp->nesqp_context->ip0),
2806 NULL, NES_ARP_RESOLVE) << 16); 3032 NULL, NES_ARP_RESOLVE) << 16);
2807 nesqp->nesqp_context->ts_val_delta = cpu_to_le32( 3033 nesqp->nesqp_context->ts_val_delta = cpu_to_le32(
2808 jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW)); 3034 jiffies - nes_read_indexed(nesdev, NES_IDX_TCP_NOW));
2809 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id); 3035 nesqp->nesqp_context->ird_index = cpu_to_le32(nesqp->hwqp.qp_id);
2810 nesqp->nesqp_context->ird_ord_sizes |= 3036 nesqp->nesqp_context->ird_ord_sizes |=
2811 cpu_to_le32((u32)1 << NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT); 3037 cpu_to_le32((u32)1 <<
3038 NES_QPCONTEXT_ORDIRD_IWARP_MODE_SHIFT);
2812 3039
2813 /* Adjust tail for not having a LSMM */ 3040 /* Adjust tail for not having a LSMM */
2814 nesqp->hwqp.sq_tail = 1; 3041 nesqp->hwqp.sq_tail = 1;
2815 3042
2816#if defined(NES_SEND_FIRST_WRITE) 3043#if defined(NES_SEND_FIRST_WRITE)
2817 if (cm_node->send_write0) { 3044 if (cm_node->send_write0) {
2818 nes_debug(NES_DBG_CM, "Sending first write.\n"); 3045 nes_debug(NES_DBG_CM, "Sending first write.\n");
2819 wqe = &nesqp->hwqp.sq_vbase[0]; 3046 wqe = &nesqp->hwqp.sq_vbase[0];
2820 u64temp = (unsigned long)nesqp; 3047 u64temp = (unsigned long)nesqp;
2821 u64temp |= NES_SW_CONTEXT_ALIGN>>1; 3048 u64temp |= NES_SW_CONTEXT_ALIGN>>1;
2822 set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, 3049 set_wqe_64bit_value(wqe->wqe_words,
2823 u64temp); 3050 NES_IWARP_SQ_WQE_COMP_CTX_LOW_IDX, u64temp);
2824 wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = cpu_to_le32(NES_IWARP_SQ_OP_RDMAW); 3051 wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] =
2825 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 0; 3052 cpu_to_le32(NES_IWARP_SQ_OP_RDMAW);
2826 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 0; 3053 wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX] = 0;
2827 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 0; 3054 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_LOW_IDX] = 0;
2828 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 0; 3055 wqe->wqe_words[NES_IWARP_SQ_WQE_FRAG0_HIGH_IDX] = 0;
2829 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0; 3056 wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 0;
2830 3057 wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0;
2831 /* use the reserved spot on the WQ for the extra first WQE */ 3058
2832 nesqp->nesqp_context->ird_ord_sizes &= cpu_to_le32(~(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT | 3059 /* use the reserved spot on the WQ for the extra first WQE */
2833 NES_QPCONTEXT_ORDIRD_WRPDU | NES_QPCONTEXT_ORDIRD_ALSMM)); 3060 nesqp->nesqp_context->ird_ord_sizes &=
2834 nesqp->skip_lsmm = 1; 3061 cpu_to_le32(~(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
2835 nesqp->hwqp.sq_tail = 0; 3062 NES_QPCONTEXT_ORDIRD_WRPDU |
2836 nes_write32(nesdev->regs + NES_WQE_ALLOC, 3063 NES_QPCONTEXT_ORDIRD_ALSMM));
2837 (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id); 3064 nesqp->skip_lsmm = 1;
2838 } 3065 nesqp->hwqp.sq_tail = 0;
3066 nes_write32(nesdev->regs + NES_WQE_ALLOC,
3067 (1 << 24) | 0x00800000 | nesqp->hwqp.qp_id);
3068 }
2839#endif 3069#endif
2840 3070
2841 memset(&nes_quad, 0, sizeof(nes_quad)); 3071 memset(&nes_quad, 0, sizeof(nes_quad));
2842 3072
2843 nes_quad.DstIpAdrIndex = cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24); 3073 nes_quad.DstIpAdrIndex =
2844 nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr; 3074 cpu_to_le32((u32)PCI_FUNC(nesdev->pcidev->devfn) << 24);
3075 if (ipv4_is_loopback(cm_id->remote_addr.sin_addr.s_addr))
3076 nes_quad.SrcIpadr = nesvnic->local_ipaddr;
3077 else
3078 nes_quad.SrcIpadr = cm_id->remote_addr.sin_addr.s_addr;
2845 nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port; 3079 nes_quad.TcpPorts[0] = cm_id->remote_addr.sin_port;
2846 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 3080 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2847 3081
@@ -2858,10 +3092,6 @@ static void cm_event_connected(struct nes_cm_event *event)
2858 nesqp->private_data_len = (u8) cm_node->mpa_frame_size; 3092 nesqp->private_data_len = (u8) cm_node->mpa_frame_size;
2859 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node); 3093 cm_node->cm_core->api->accelerated(cm_node->cm_core, cm_node);
2860 3094
2861 /* modify QP state to rts */
2862 attr.qp_state = IB_QPS_RTS;
2863 nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL);
2864
2865 /* notify OF layer we successfully created the requested connection */ 3095 /* notify OF layer we successfully created the requested connection */
2866 cm_event.event = IW_CM_EVENT_CONNECT_REPLY; 3096 cm_event.event = IW_CM_EVENT_CONNECT_REPLY;
2867 cm_event.status = IW_CM_EVENT_STATUS_ACCEPTED; 3097 cm_event.status = IW_CM_EVENT_STATUS_ACCEPTED;
@@ -2870,20 +3100,21 @@ static void cm_event_connected(struct nes_cm_event *event)
2870 cm_event.local_addr.sin_port = cm_id->local_addr.sin_port; 3100 cm_event.local_addr.sin_port = cm_id->local_addr.sin_port;
2871 cm_event.remote_addr = cm_id->remote_addr; 3101 cm_event.remote_addr = cm_id->remote_addr;
2872 3102
2873 cm_event.private_data = (void *)event->cm_node->mpa_frame_buf; 3103 cm_event.private_data = (void *)event->cm_node->mpa_frame_buf;
2874 cm_event.private_data_len = (u8) event->cm_node->mpa_frame_size; 3104 cm_event.private_data_len = (u8) event->cm_node->mpa_frame_size;
2875 3105
2876 cm_event.local_addr.sin_addr.s_addr = event->cm_info.rem_addr; 3106 cm_event.local_addr.sin_addr.s_addr = event->cm_info.rem_addr;
2877 ret = cm_id->event_handler(cm_id, &cm_event); 3107 ret = cm_id->event_handler(cm_id, &cm_event);
2878 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 3108 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret);
2879 3109
2880 if (ret) 3110 if (ret)
2881 printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 3111 printk(KERN_ERR "%s[%u] OFA CM event_handler returned, "
2882 __func__, __LINE__, ret); 3112 "ret=%d\n", __func__, __LINE__, ret);
2883 nes_debug(NES_DBG_CM, "Exiting connect thread for QP%u. jiffies = %lu\n", 3113 attr.qp_state = IB_QPS_RTS;
2884 nesqp->hwqp.qp_id, jiffies ); 3114 nes_modify_qp(&nesqp->ibqp, &attr, IB_QP_STATE, NULL);
2885 3115
2886 nes_rem_ref(&nesqp->ibqp); 3116 nes_debug(NES_DBG_CM, "Exiting connect thread for QP%u. jiffies = "
3117 "%lu\n", nesqp->hwqp.qp_id, jiffies);
2887 3118
2888 return; 3119 return;
2889} 3120}
@@ -2927,17 +3158,19 @@ static void cm_event_connect_error(struct nes_cm_event *event)
2927 cm_event.private_data = NULL; 3158 cm_event.private_data = NULL;
2928 cm_event.private_data_len = 0; 3159 cm_event.private_data_len = 0;
2929 3160
2930 nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, remove_addr=%08x\n", 3161 nes_debug(NES_DBG_CM, "call CM_EVENT REJECTED, local_addr=%08x, "
2931 cm_event.local_addr.sin_addr.s_addr, cm_event.remote_addr.sin_addr.s_addr); 3162 "remove_addr=%08x\n", cm_event.local_addr.sin_addr.s_addr,
3163 cm_event.remote_addr.sin_addr.s_addr);
2932 3164
2933 ret = cm_id->event_handler(cm_id, &cm_event); 3165 ret = cm_id->event_handler(cm_id, &cm_event);
2934 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret); 3166 nes_debug(NES_DBG_CM, "OFA CM event_handler returned, ret=%d\n", ret);
2935 if (ret) 3167 if (ret)
2936 printk("%s[%u] OFA CM event_handler returned, ret=%d\n", 3168 printk(KERN_ERR "%s[%u] OFA CM event_handler returned, "
2937 __func__, __LINE__, ret); 3169 "ret=%d\n", __func__, __LINE__, ret);
2938 nes_rem_ref(&nesqp->ibqp); 3170 nes_rem_ref(&nesqp->ibqp);
2939 cm_id->rem_ref(cm_id); 3171 cm_id->rem_ref(cm_id);
2940 3172
3173 rem_ref_cm_node(event->cm_node->cm_core, event->cm_node);
2941 return; 3174 return;
2942} 3175}
2943 3176
@@ -3040,7 +3273,8 @@ static int nes_cm_post_event(struct nes_cm_event *event)
3040 add_ref_cm_node(event->cm_node); 3273 add_ref_cm_node(event->cm_node);
3041 event->cm_info.cm_id->add_ref(event->cm_info.cm_id); 3274 event->cm_info.cm_id->add_ref(event->cm_info.cm_id);
3042 INIT_WORK(&event->event_work, nes_cm_event_handler); 3275 INIT_WORK(&event->event_work, nes_cm_event_handler);
3043 nes_debug(NES_DBG_CM, "queue_work, event=%p\n", event); 3276 nes_debug(NES_DBG_CM, "cm_node=%p queue_work, event=%p\n",
3277 event->cm_node, event);
3044 3278
3045 queue_work(event->cm_node->cm_core->event_wq, &event->event_work); 3279 queue_work(event->cm_node->cm_core->event_wq, &event->event_work);
3046 3280
@@ -3056,46 +3290,48 @@ static int nes_cm_post_event(struct nes_cm_event *event)
3056 */ 3290 */
3057static void nes_cm_event_handler(struct work_struct *work) 3291static void nes_cm_event_handler(struct work_struct *work)
3058{ 3292{
3059 struct nes_cm_event *event = container_of(work, struct nes_cm_event, event_work); 3293 struct nes_cm_event *event = container_of(work, struct nes_cm_event,
3294 event_work);
3060 struct nes_cm_core *cm_core; 3295 struct nes_cm_core *cm_core;
3061 3296
3062 if ((!event) || (!event->cm_node) || (!event->cm_node->cm_core)) { 3297 if ((!event) || (!event->cm_node) || (!event->cm_node->cm_core))
3063 return; 3298 return;
3064 } 3299
3065 cm_core = event->cm_node->cm_core; 3300 cm_core = event->cm_node->cm_core;
3066 nes_debug(NES_DBG_CM, "event=%p, event->type=%u, events posted=%u\n", 3301 nes_debug(NES_DBG_CM, "event=%p, event->type=%u, events posted=%u\n",
3067 event, event->type, atomic_read(&cm_core->events_posted)); 3302 event, event->type, atomic_read(&cm_core->events_posted));
3068 3303
3069 switch (event->type) { 3304 switch (event->type) {
3070 case NES_CM_EVENT_MPA_REQ: 3305 case NES_CM_EVENT_MPA_REQ:
3071 cm_event_mpa_req(event); 3306 cm_event_mpa_req(event);
3072 nes_debug(NES_DBG_CM, "CM Event: MPA REQUEST\n"); 3307 nes_debug(NES_DBG_CM, "cm_node=%p CM Event: MPA REQUEST\n",
3073 break; 3308 event->cm_node);
3074 case NES_CM_EVENT_RESET: 3309 break;
3075 nes_debug(NES_DBG_CM, "CM Event: RESET\n"); 3310 case NES_CM_EVENT_RESET:
3076 cm_event_reset(event); 3311 nes_debug(NES_DBG_CM, "cm_node = %p CM Event: RESET\n",
3077 break; 3312 event->cm_node);
3078 case NES_CM_EVENT_CONNECTED: 3313 cm_event_reset(event);
3079 if ((!event->cm_node->cm_id) || 3314 break;
3080 (event->cm_node->state != NES_CM_STATE_TSA)) { 3315 case NES_CM_EVENT_CONNECTED:
3081 break; 3316 if ((!event->cm_node->cm_id) ||
3082 } 3317 (event->cm_node->state != NES_CM_STATE_TSA))
3083 cm_event_connected(event);
3084 nes_debug(NES_DBG_CM, "CM Event: CONNECTED\n");
3085 break; 3318 break;
3086 case NES_CM_EVENT_ABORTED: 3319 cm_event_connected(event);
3087 if ((!event->cm_node->cm_id) || (event->cm_node->state == NES_CM_STATE_TSA)) { 3320 nes_debug(NES_DBG_CM, "CM Event: CONNECTED\n");
3088 break; 3321 break;
3089 } 3322 case NES_CM_EVENT_ABORTED:
3090 cm_event_connect_error(event); 3323 if ((!event->cm_node->cm_id) ||
3091 nes_debug(NES_DBG_CM, "CM Event: ABORTED\n"); 3324 (event->cm_node->state == NES_CM_STATE_TSA))
3092 break;
3093 case NES_CM_EVENT_DROPPED_PKT:
3094 nes_debug(NES_DBG_CM, "CM Event: DROPPED PKT\n");
3095 break;
3096 default:
3097 nes_debug(NES_DBG_CM, "CM Event: UNKNOWN EVENT TYPE\n");
3098 break; 3325 break;
3326 cm_event_connect_error(event);
3327 nes_debug(NES_DBG_CM, "CM Event: ABORTED\n");
3328 break;
3329 case NES_CM_EVENT_DROPPED_PKT:
3330 nes_debug(NES_DBG_CM, "CM Event: DROPPED PKT\n");
3331 break;
3332 default:
3333 nes_debug(NES_DBG_CM, "CM Event: UNKNOWN EVENT TYPE\n");
3334 break;
3099 } 3335 }
3100 3336
3101 atomic_dec(&cm_core->events_posted); 3337 atomic_dec(&cm_core->events_posted);
diff --git a/drivers/infiniband/hw/nes/nes_cm.h b/drivers/infiniband/hw/nes/nes_cm.h
index 7717cb2ab500..367b3d290140 100644
--- a/drivers/infiniband/hw/nes/nes_cm.h
+++ b/drivers/infiniband/hw/nes/nes_cm.h
@@ -83,6 +83,8 @@ enum nes_timer_type {
83#define SET_FIN 4 83#define SET_FIN 4
84#define SET_RST 8 84#define SET_RST 8
85 85
86#define TCP_OPTIONS_PADDING 3
87
86struct option_base { 88struct option_base {
87 u8 optionnum; 89 u8 optionnum;
88 u8 length; 90 u8 length;
@@ -177,6 +179,7 @@ enum nes_cm_node_state {
177 NES_CM_STATE_ESTABLISHED, 179 NES_CM_STATE_ESTABLISHED,
178 NES_CM_STATE_ACCEPTING, 180 NES_CM_STATE_ACCEPTING,
179 NES_CM_STATE_MPAREQ_SENT, 181 NES_CM_STATE_MPAREQ_SENT,
182 NES_CM_STATE_MPAREQ_RCVD,
180 NES_CM_STATE_TSA, 183 NES_CM_STATE_TSA,
181 NES_CM_STATE_FIN_WAIT1, 184 NES_CM_STATE_FIN_WAIT1,
182 NES_CM_STATE_FIN_WAIT2, 185 NES_CM_STATE_FIN_WAIT2,
@@ -187,6 +190,16 @@ enum nes_cm_node_state {
187 NES_CM_STATE_CLOSED 190 NES_CM_STATE_CLOSED
188}; 191};
189 192
193enum nes_tcpip_pkt_type {
194 NES_PKT_TYPE_UNKNOWN,
195 NES_PKT_TYPE_SYN,
196 NES_PKT_TYPE_SYNACK,
197 NES_PKT_TYPE_ACK,
198 NES_PKT_TYPE_FIN,
199 NES_PKT_TYPE_RST
200};
201
202
190/* type of nes connection */ 203/* type of nes connection */
191enum nes_cm_conn_type { 204enum nes_cm_conn_type {
192 NES_CM_IWARP_CONN_TYPE, 205 NES_CM_IWARP_CONN_TYPE,
@@ -257,7 +270,9 @@ struct nes_cm_node {
257 struct net_device *netdev; 270 struct net_device *netdev;
258 271
259 struct nes_cm_node *loopbackpartner; 272 struct nes_cm_node *loopbackpartner;
260 struct list_head retrans_list; 273
274 struct nes_timer_entry *send_entry;
275
261 spinlock_t retrans_list_lock; 276 spinlock_t retrans_list_lock;
262 struct list_head recv_list; 277 struct list_head recv_list;
263 spinlock_t recv_list_lock; 278 spinlock_t recv_list_lock;
@@ -276,6 +291,8 @@ struct nes_cm_node {
276 struct nes_vnic *nesvnic; 291 struct nes_vnic *nesvnic;
277 int apbvt_set; 292 int apbvt_set;
278 int accept_pend; 293 int accept_pend;
294 int freed;
295 struct nes_qp *nesqp;
279}; 296};
280 297
281/* structure for client or CM to fill when making CM api calls. */ 298/* structure for client or CM to fill when making CM api calls. */
@@ -366,14 +383,14 @@ struct nes_cm_ops {
366 struct nes_cm_info *); 383 struct nes_cm_info *);
367 int (*stop_listener)(struct nes_cm_core *, struct nes_cm_listener *); 384 int (*stop_listener)(struct nes_cm_core *, struct nes_cm_listener *);
368 struct nes_cm_node * (*connect)(struct nes_cm_core *, 385 struct nes_cm_node * (*connect)(struct nes_cm_core *,
369 struct nes_vnic *, struct ietf_mpa_frame *, 386 struct nes_vnic *, u16, void *,
370 struct nes_cm_info *); 387 struct nes_cm_info *);
371 int (*close)(struct nes_cm_core *, struct nes_cm_node *); 388 int (*close)(struct nes_cm_core *, struct nes_cm_node *);
372 int (*accept)(struct nes_cm_core *, struct ietf_mpa_frame *, 389 int (*accept)(struct nes_cm_core *, struct ietf_mpa_frame *,
373 struct nes_cm_node *); 390 struct nes_cm_node *);
374 int (*reject)(struct nes_cm_core *, struct ietf_mpa_frame *, 391 int (*reject)(struct nes_cm_core *, struct ietf_mpa_frame *,
375 struct nes_cm_node *); 392 struct nes_cm_node *);
376 int (*recv_pkt)(struct nes_cm_core *, struct nes_vnic *, 393 void (*recv_pkt)(struct nes_cm_core *, struct nes_vnic *,
377 struct sk_buff *); 394 struct sk_buff *);
378 int (*destroy_cm_core)(struct nes_cm_core *); 395 int (*destroy_cm_core)(struct nes_cm_core *);
379 int (*get)(struct nes_cm_core *); 396 int (*get)(struct nes_cm_core *);
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 85f26d19a32b..1513d4066f1b 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -2814,7 +2814,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2814 nesqp = *((struct nes_qp **)&context); 2814 nesqp = *((struct nes_qp **)&context);
2815 if (atomic_inc_return(&nesqp->close_timer_started) == 1) { 2815 if (atomic_inc_return(&nesqp->close_timer_started) == 1) {
2816 nesqp->cm_id->add_ref(nesqp->cm_id); 2816 nesqp->cm_id->add_ref(nesqp->cm_id);
2817 nes_add_ref(&nesqp->ibqp);
2818 schedule_nes_timer(nesqp->cm_node, (struct sk_buff *)nesqp, 2817 schedule_nes_timer(nesqp->cm_node, (struct sk_buff *)nesqp,
2819 NES_TIMER_TYPE_CLOSE, 1, 0); 2818 NES_TIMER_TYPE_CLOSE, 1, 0);
2820 nes_debug(NES_DBG_AEQ, "QP%u Not decrementing QP refcount (%d)," 2819 nes_debug(NES_DBG_AEQ, "QP%u Not decrementing QP refcount (%d),"
@@ -2838,7 +2837,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2838 if (async_event_id == NES_AEQE_AEID_RESET_SENT) { 2837 if (async_event_id == NES_AEQE_AEID_RESET_SENT) {
2839 tcp_state = NES_AEQE_TCP_STATE_CLOSED; 2838 tcp_state = NES_AEQE_TCP_STATE_CLOSED;
2840 } 2839 }
2841 nes_add_ref(&nesqp->ibqp);
2842 spin_lock_irqsave(&nesqp->lock, flags); 2840 spin_lock_irqsave(&nesqp->lock, flags);
2843 nesqp->hw_iwarp_state = iwarp_state; 2841 nesqp->hw_iwarp_state = iwarp_state;
2844 nesqp->hw_tcp_state = tcp_state; 2842 nesqp->hw_tcp_state = tcp_state;
@@ -2876,7 +2874,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2876 } 2874 }
2877 spin_unlock_irqrestore(&nesqp->lock, flags); 2875 spin_unlock_irqrestore(&nesqp->lock, flags);
2878 if (next_iwarp_state) { 2876 if (next_iwarp_state) {
2879 nes_add_ref(&nesqp->ibqp);
2880 nes_debug(NES_DBG_AEQ, "issuing hw modifyqp for QP%u. next state = 0x%08X," 2877 nes_debug(NES_DBG_AEQ, "issuing hw modifyqp for QP%u. next state = 0x%08X,"
2881 " also added another reference\n", 2878 " also added another reference\n",
2882 nesqp->hwqp.qp_id, next_iwarp_state); 2879 nesqp->hwqp.qp_id, next_iwarp_state);
@@ -2888,7 +2885,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2888 /* FIN Received but ib state not RTS, 2885 /* FIN Received but ib state not RTS,
2889 close complete will be on its way */ 2886 close complete will be on its way */
2890 spin_unlock_irqrestore(&nesqp->lock, flags); 2887 spin_unlock_irqrestore(&nesqp->lock, flags);
2891 nes_rem_ref(&nesqp->ibqp);
2892 return; 2888 return;
2893 } 2889 }
2894 spin_unlock_irqrestore(&nesqp->lock, flags); 2890 spin_unlock_irqrestore(&nesqp->lock, flags);
@@ -2922,7 +2918,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2922 if ((tcp_state == NES_AEQE_TCP_STATE_CLOSE_WAIT) || 2918 if ((tcp_state == NES_AEQE_TCP_STATE_CLOSE_WAIT) ||
2923 ((nesqp->ibqp_state == IB_QPS_RTS)&& 2919 ((nesqp->ibqp_state == IB_QPS_RTS)&&
2924 (async_event_id == NES_AEQE_AEID_LLP_CONNECTION_RESET))) { 2920 (async_event_id == NES_AEQE_AEID_LLP_CONNECTION_RESET))) {
2925 nes_add_ref(&nesqp->ibqp);
2926 nes_cm_disconn(nesqp); 2921 nes_cm_disconn(nesqp);
2927 } else { 2922 } else {
2928 nesqp->in_disconnect = 0; 2923 nesqp->in_disconnect = 0;
@@ -2931,7 +2926,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2931 break; 2926 break;
2932 case NES_AEQE_AEID_LLP_TOO_MANY_RETRIES: 2927 case NES_AEQE_AEID_LLP_TOO_MANY_RETRIES:
2933 nesqp = *((struct nes_qp **)&context); 2928 nesqp = *((struct nes_qp **)&context);
2934 nes_add_ref(&nesqp->ibqp);
2935 spin_lock_irqsave(&nesqp->lock, flags); 2929 spin_lock_irqsave(&nesqp->lock, flags);
2936 nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_ERROR; 2930 nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_ERROR;
2937 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 2931 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED;
@@ -3042,7 +3036,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3042 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3036 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context);
3043 } 3037 }
3044 /* tell cm to disconnect, cm will queue work to thread */ 3038 /* tell cm to disconnect, cm will queue work to thread */
3045 nes_add_ref(&nesqp->ibqp);
3046 nes_cm_disconn(nesqp); 3039 nes_cm_disconn(nesqp);
3047 break; 3040 break;
3048 case NES_AEQE_AEID_DDP_UBE_INVALID_MSN_NO_BUFFER_AVAILABLE: 3041 case NES_AEQE_AEID_DDP_UBE_INVALID_MSN_NO_BUFFER_AVAILABLE:
@@ -3062,7 +3055,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3062 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3055 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context);
3063 } 3056 }
3064 /* tell cm to disconnect, cm will queue work to thread */ 3057 /* tell cm to disconnect, cm will queue work to thread */
3065 nes_add_ref(&nesqp->ibqp);
3066 nes_cm_disconn(nesqp); 3058 nes_cm_disconn(nesqp);
3067 break; 3059 break;
3068 case NES_AEQE_AEID_LLP_RECEIVED_MPA_CRC_ERROR: 3060 case NES_AEQE_AEID_LLP_RECEIVED_MPA_CRC_ERROR:
@@ -3082,7 +3074,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
3082 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context); 3074 nesqp->ibqp.event_handler(&ibevent, nesqp->ibqp.qp_context);
3083 } 3075 }
3084 /* tell cm to disconnect, cm will queue work to thread */ 3076 /* tell cm to disconnect, cm will queue work to thread */
3085 nes_add_ref(&nesqp->ibqp);
3086 nes_cm_disconn(nesqp); 3077 nes_cm_disconn(nesqp);
3087 break; 3078 break;
3088 /* TODO: additional AEs need to be here */ 3079 /* TODO: additional AEs need to be here */
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index e3939d13484e..d79942e84979 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -2867,7 +2867,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2867 nesqp->hwqp.qp_id, attr->qp_state, nesqp->ibqp_state, 2867 nesqp->hwqp.qp_id, attr->qp_state, nesqp->ibqp_state,
2868 nesqp->iwarp_state, atomic_read(&nesqp->refcount)); 2868 nesqp->iwarp_state, atomic_read(&nesqp->refcount));
2869 2869
2870 nes_add_ref(&nesqp->ibqp);
2871 spin_lock_irqsave(&nesqp->lock, qplockflags); 2870 spin_lock_irqsave(&nesqp->lock, qplockflags);
2872 2871
2873 nes_debug(NES_DBG_MOD_QP, "QP%u: hw_iwarp_state=0x%X, hw_tcp_state=0x%X," 2872 nes_debug(NES_DBG_MOD_QP, "QP%u: hw_iwarp_state=0x%X, hw_tcp_state=0x%X,"
@@ -2882,7 +2881,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2882 nesqp->hwqp.qp_id); 2881 nesqp->hwqp.qp_id);
2883 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_IDLE) { 2882 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_IDLE) {
2884 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2883 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2885 nes_rem_ref(&nesqp->ibqp);
2886 return -EINVAL; 2884 return -EINVAL;
2887 } 2885 }
2888 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE; 2886 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE;
@@ -2893,7 +2891,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2893 nesqp->hwqp.qp_id); 2891 nesqp->hwqp.qp_id);
2894 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_IDLE) { 2892 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_IDLE) {
2895 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2893 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2896 nes_rem_ref(&nesqp->ibqp);
2897 return -EINVAL; 2894 return -EINVAL;
2898 } 2895 }
2899 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE; 2896 next_iwarp_state = NES_CQP_QP_IWARP_STATE_IDLE;
@@ -2904,14 +2901,12 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2904 nesqp->hwqp.qp_id); 2901 nesqp->hwqp.qp_id);
2905 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_RTS) { 2902 if (nesqp->iwarp_state>(u32)NES_CQP_QP_IWARP_STATE_RTS) {
2906 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2903 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2907 nes_rem_ref(&nesqp->ibqp);
2908 return -EINVAL; 2904 return -EINVAL;
2909 } 2905 }
2910 if (nesqp->cm_id == NULL) { 2906 if (nesqp->cm_id == NULL) {
2911 nes_debug(NES_DBG_MOD_QP, "QP%u: Failing attempt to move QP to RTS without a CM_ID. \n", 2907 nes_debug(NES_DBG_MOD_QP, "QP%u: Failing attempt to move QP to RTS without a CM_ID. \n",
2912 nesqp->hwqp.qp_id ); 2908 nesqp->hwqp.qp_id );
2913 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2909 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2914 nes_rem_ref(&nesqp->ibqp);
2915 return -EINVAL; 2910 return -EINVAL;
2916 } 2911 }
2917 next_iwarp_state = NES_CQP_QP_IWARP_STATE_RTS; 2912 next_iwarp_state = NES_CQP_QP_IWARP_STATE_RTS;
@@ -2929,7 +2924,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2929 nesqp->hwqp.qp_id, nesqp->hwqp.sq_head, nesqp->hwqp.sq_tail); 2924 nesqp->hwqp.qp_id, nesqp->hwqp.sq_head, nesqp->hwqp.sq_tail);
2930 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_CLOSING) { 2925 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_CLOSING) {
2931 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2926 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2932 nes_rem_ref(&nesqp->ibqp);
2933 return 0; 2927 return 0;
2934 } else { 2928 } else {
2935 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_CLOSING) { 2929 if (nesqp->iwarp_state > (u32)NES_CQP_QP_IWARP_STATE_CLOSING) {
@@ -2937,7 +2931,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2937 " ignored due to current iWARP state\n", 2931 " ignored due to current iWARP state\n",
2938 nesqp->hwqp.qp_id); 2932 nesqp->hwqp.qp_id);
2939 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2933 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2940 nes_rem_ref(&nesqp->ibqp);
2941 return -EINVAL; 2934 return -EINVAL;
2942 } 2935 }
2943 if (nesqp->hw_iwarp_state != NES_AEQE_IWARP_STATE_RTS) { 2936 if (nesqp->hw_iwarp_state != NES_AEQE_IWARP_STATE_RTS) {
@@ -2969,7 +2962,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2969 nesqp->hwqp.qp_id); 2962 nesqp->hwqp.qp_id);
2970 if (nesqp->iwarp_state>=(u32)NES_CQP_QP_IWARP_STATE_TERMINATE) { 2963 if (nesqp->iwarp_state>=(u32)NES_CQP_QP_IWARP_STATE_TERMINATE) {
2971 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2964 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2972 nes_rem_ref(&nesqp->ibqp);
2973 return -EINVAL; 2965 return -EINVAL;
2974 } 2966 }
2975 /* next_iwarp_state = (NES_CQP_QP_IWARP_STATE_TERMINATE | 0x02000000); */ 2967 /* next_iwarp_state = (NES_CQP_QP_IWARP_STATE_TERMINATE | 0x02000000); */
@@ -2982,7 +2974,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2982 case IB_QPS_RESET: 2974 case IB_QPS_RESET:
2983 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_ERROR) { 2975 if (nesqp->iwarp_state == (u32)NES_CQP_QP_IWARP_STATE_ERROR) {
2984 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 2976 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
2985 nes_rem_ref(&nesqp->ibqp);
2986 return -EINVAL; 2977 return -EINVAL;
2987 } 2978 }
2988 nes_debug(NES_DBG_MOD_QP, "QP%u: new state = error\n", 2979 nes_debug(NES_DBG_MOD_QP, "QP%u: new state = error\n",
@@ -3008,7 +2999,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3008 break; 2999 break;
3009 default: 3000 default:
3010 spin_unlock_irqrestore(&nesqp->lock, qplockflags); 3001 spin_unlock_irqrestore(&nesqp->lock, qplockflags);
3011 nes_rem_ref(&nesqp->ibqp);
3012 return -EINVAL; 3002 return -EINVAL;
3013 break; 3003 break;
3014 } 3004 }
@@ -3088,7 +3078,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3088 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3078 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount),
3089 original_last_aeq, nesqp->last_aeq); 3079 original_last_aeq, nesqp->last_aeq);
3090 /* this one is for the cm_disconnect thread */ 3080 /* this one is for the cm_disconnect thread */
3091 nes_add_ref(&nesqp->ibqp);
3092 spin_lock_irqsave(&nesqp->lock, qplockflags); 3081 spin_lock_irqsave(&nesqp->lock, qplockflags);
3093 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED; 3082 nesqp->hw_tcp_state = NES_AEQE_TCP_STATE_CLOSED;
3094 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT; 3083 nesqp->last_aeq = NES_AEQE_AEID_RESET_SENT;
@@ -3097,14 +3086,12 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3097 } else { 3086 } else {
3098 nes_debug(NES_DBG_MOD_QP, "QP%u No fake disconnect, QP refcount=%d\n", 3087 nes_debug(NES_DBG_MOD_QP, "QP%u No fake disconnect, QP refcount=%d\n",
3099 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount)); 3088 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount));
3100 nes_rem_ref(&nesqp->ibqp);
3101 } 3089 }
3102 } else { 3090 } else {
3103 spin_lock_irqsave(&nesqp->lock, qplockflags); 3091 spin_lock_irqsave(&nesqp->lock, qplockflags);
3104 if (nesqp->cm_id) { 3092 if (nesqp->cm_id) {
3105 /* These two are for the timer thread */ 3093 /* These two are for the timer thread */
3106 if (atomic_inc_return(&nesqp->close_timer_started) == 1) { 3094 if (atomic_inc_return(&nesqp->close_timer_started) == 1) {
3107 nes_add_ref(&nesqp->ibqp);
3108 nesqp->cm_id->add_ref(nesqp->cm_id); 3095 nesqp->cm_id->add_ref(nesqp->cm_id);
3109 nes_debug(NES_DBG_MOD_QP, "QP%u Not decrementing QP refcount (%d)," 3096 nes_debug(NES_DBG_MOD_QP, "QP%u Not decrementing QP refcount (%d),"
3110 " need ae to finish up, original_last_aeq = 0x%04X." 3097 " need ae to finish up, original_last_aeq = 0x%04X."
@@ -3128,14 +3115,12 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
3128 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n", 3115 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n",
3129 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3116 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount),
3130 original_last_aeq, nesqp->last_aeq); 3117 original_last_aeq, nesqp->last_aeq);
3131 nes_rem_ref(&nesqp->ibqp);
3132 } 3118 }
3133 } else { 3119 } else {
3134 nes_debug(NES_DBG_MOD_QP, "QP%u Decrementing QP refcount (%d), No ae to finish up," 3120 nes_debug(NES_DBG_MOD_QP, "QP%u Decrementing QP refcount (%d), No ae to finish up,"
3135 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n", 3121 " original_last_aeq = 0x%04X. last_aeq = 0x%04X.\n",
3136 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount), 3122 nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount),
3137 original_last_aeq, nesqp->last_aeq); 3123 original_last_aeq, nesqp->last_aeq);
3138 nes_rem_ref(&nesqp->ibqp);
3139 } 3124 }
3140 3125
3141 err = 0; 3126 err = 0;
diff --git a/drivers/infiniband/ulp/ipoib/Kconfig b/drivers/infiniband/ulp/ipoib/Kconfig
index 691525cf394a..9d9a9dc51f18 100644
--- a/drivers/infiniband/ulp/ipoib/Kconfig
+++ b/drivers/infiniband/ulp/ipoib/Kconfig
@@ -11,16 +11,17 @@ config INFINIBAND_IPOIB
11 11
12config INFINIBAND_IPOIB_CM 12config INFINIBAND_IPOIB_CM
13 bool "IP-over-InfiniBand Connected Mode support" 13 bool "IP-over-InfiniBand Connected Mode support"
14 depends on INFINIBAND_IPOIB && EXPERIMENTAL 14 depends on INFINIBAND_IPOIB
15 default n 15 default n
16 ---help--- 16 ---help---
17 This option enables experimental support for IPoIB connected mode. 17 This option enables support for IPoIB connected mode. After
18 After enabling this option, you need to switch to connected mode through 18 enabling this option, you need to switch to connected mode
19 /sys/class/net/ibXXX/mode to actually create connections, and then increase 19 through /sys/class/net/ibXXX/mode to actually create
20 the interface MTU with e.g. ifconfig ib0 mtu 65520. 20 connections, and then increase the interface MTU with
21 e.g. ifconfig ib0 mtu 65520.
21 22
22 WARNING: Enabling connected mode will trigger some 23 WARNING: Enabling connected mode will trigger some packet
23 packet drops for multicast and UD mode traffic from this interface, 24 drops for multicast and UD mode traffic from this interface,
24 unless you limit mtu for these destinations to 2044. 25 unless you limit mtu for these destinations to 2044.
25 26
26config INFINIBAND_IPOIB_DEBUG 27config INFINIBAND_IPOIB_DEBUG
@@ -33,9 +34,10 @@ config INFINIBAND_IPOIB_DEBUG
33 debug_level and mcast_debug_level module parameters (which 34 debug_level and mcast_debug_level module parameters (which
34 can also be set after the driver is loaded through sysfs). 35 can also be set after the driver is loaded through sysfs).
35 36
36 This option also creates an "ipoib_debugfs," which can be 37 This option also creates a directory tree under ipoib/ in
37 mounted to expose debugging information about IB multicast 38 debugfs, which contains files that expose debugging
38 groups used by the IPoIB driver. 39 information about IB multicast groups used by the IPoIB
40 driver.
39 41
40config INFINIBAND_IPOIB_DEBUG_DATA 42config INFINIBAND_IPOIB_DEBUG_DATA
41 bool "IP-over-InfiniBand data path debugging" 43 bool "IP-over-InfiniBand data path debugging"
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 8486abc457ed..c600ab7f93e8 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -158,25 +158,18 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
158 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); 158 memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata));
159 pdata = &priv->pdata; 159 pdata = &priv->pdata;
160 160
161 res = request_mem_region(res->start, res_size(res), pdev->name);
162 if (res == NULL) {
163 dev_err(&pdev->dev, "failed to request I/O memory\n");
164 error = -EBUSY;
165 goto err1;
166 }
167
168 priv->iomem_base = ioremap_nocache(res->start, res_size(res)); 161 priv->iomem_base = ioremap_nocache(res->start, res_size(res));
169 if (priv->iomem_base == NULL) { 162 if (priv->iomem_base == NULL) {
170 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 163 dev_err(&pdev->dev, "failed to remap I/O memory\n");
171 error = -ENXIO; 164 error = -ENXIO;
172 goto err2; 165 goto err1;
173 } 166 }
174 167
175 priv->input = input_allocate_device(); 168 priv->input = input_allocate_device();
176 if (!priv->input) { 169 if (!priv->input) {
177 dev_err(&pdev->dev, "failed to allocate input device\n"); 170 dev_err(&pdev->dev, "failed to allocate input device\n");
178 error = -ENOMEM; 171 error = -ENOMEM;
179 goto err3; 172 goto err2;
180 } 173 }
181 174
182 input = priv->input; 175 input = priv->input;
@@ -194,7 +187,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
194 error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); 187 error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev);
195 if (error) { 188 if (error) {
196 dev_err(&pdev->dev, "failed to request IRQ\n"); 189 dev_err(&pdev->dev, "failed to request IRQ\n");
197 goto err4; 190 goto err3;
198 } 191 }
199 192
200 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { 193 for (i = 0; i < SH_KEYSC_MAXKEYS; i++) {
@@ -206,7 +199,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
206 error = input_register_device(input); 199 error = input_register_device(input);
207 if (error) { 200 if (error) {
208 dev_err(&pdev->dev, "failed to register input device\n"); 201 dev_err(&pdev->dev, "failed to register input device\n");
209 goto err5; 202 goto err4;
210 } 203 }
211 204
212 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | 205 iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) |
@@ -214,14 +207,12 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
214 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); 207 iowrite16(0, priv->iomem_base + KYOUTDR_OFFS);
215 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); 208 iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS);
216 return 0; 209 return 0;
217 err5:
218 free_irq(irq, pdev);
219 err4: 210 err4:
220 input_free_device(input); 211 free_irq(irq, pdev);
221 err3: 212 err3:
222 iounmap(priv->iomem_base); 213 input_free_device(input);
223 err2: 214 err2:
224 release_mem_region(res->start, res_size(res)); 215 iounmap(priv->iomem_base);
225 err1: 216 err1:
226 platform_set_drvdata(pdev, NULL); 217 platform_set_drvdata(pdev, NULL);
227 kfree(priv); 218 kfree(priv);
@@ -232,7 +223,6 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
232static int __devexit sh_keysc_remove(struct platform_device *pdev) 223static int __devexit sh_keysc_remove(struct platform_device *pdev)
233{ 224{
234 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 225 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
235 struct resource *res;
236 226
237 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS); 227 iowrite16(KYCR2_IRQ_DISABLED, priv->iomem_base + KYCR2_OFFS);
238 228
@@ -240,9 +230,6 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev)
240 free_irq(platform_get_irq(pdev, 0), pdev); 230 free_irq(platform_get_irq(pdev, 0), pdev);
241 iounmap(priv->iomem_base); 231 iounmap(priv->iomem_base);
242 232
243 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244 release_mem_region(res->start, res_size(res));
245
246 platform_set_drvdata(pdev, NULL); 233 platform_set_drvdata(pdev, NULL);
247 kfree(priv); 234 kfree(priv);
248 return 0; 235 return 0;
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 2bcfa0b35061..223d56d5555b 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -37,7 +37,6 @@
37#include <linux/fs.h> 37#include <linux/fs.h>
38#include <linux/miscdevice.h> 38#include <linux/miscdevice.h>
39#include <linux/uinput.h> 39#include <linux/uinput.h>
40#include <linux/smp_lock.h>
41 40
42static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 41static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
43{ 42{
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 78f2abb5c11b..2f12d60eee3b 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -63,8 +63,9 @@ static LIST_HEAD(serio_list);
63static struct bus_type serio_bus; 63static struct bus_type serio_bus;
64 64
65static void serio_add_port(struct serio *serio); 65static void serio_add_port(struct serio *serio);
66static void serio_reconnect_port(struct serio *serio); 66static int serio_reconnect_port(struct serio *serio);
67static void serio_disconnect_port(struct serio *serio); 67static void serio_disconnect_port(struct serio *serio);
68static void serio_reconnect_chain(struct serio *serio);
68static void serio_attach_driver(struct serio_driver *drv); 69static void serio_attach_driver(struct serio_driver *drv);
69 70
70static int serio_connect_driver(struct serio *serio, struct serio_driver *drv) 71static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
@@ -161,6 +162,7 @@ static void serio_find_driver(struct serio *serio)
161enum serio_event_type { 162enum serio_event_type {
162 SERIO_RESCAN_PORT, 163 SERIO_RESCAN_PORT,
163 SERIO_RECONNECT_PORT, 164 SERIO_RECONNECT_PORT,
165 SERIO_RECONNECT_CHAIN,
164 SERIO_REGISTER_PORT, 166 SERIO_REGISTER_PORT,
165 SERIO_ATTACH_DRIVER, 167 SERIO_ATTACH_DRIVER,
166}; 168};
@@ -315,6 +317,10 @@ static void serio_handle_event(void)
315 serio_find_driver(event->object); 317 serio_find_driver(event->object);
316 break; 318 break;
317 319
320 case SERIO_RECONNECT_CHAIN:
321 serio_reconnect_chain(event->object);
322 break;
323
318 case SERIO_ATTACH_DRIVER: 324 case SERIO_ATTACH_DRIVER:
319 serio_attach_driver(event->object); 325 serio_attach_driver(event->object);
320 break; 326 break;
@@ -470,7 +476,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
470 if (!strncmp(buf, "none", count)) { 476 if (!strncmp(buf, "none", count)) {
471 serio_disconnect_port(serio); 477 serio_disconnect_port(serio);
472 } else if (!strncmp(buf, "reconnect", count)) { 478 } else if (!strncmp(buf, "reconnect", count)) {
473 serio_reconnect_port(serio); 479 serio_reconnect_chain(serio);
474 } else if (!strncmp(buf, "rescan", count)) { 480 } else if (!strncmp(buf, "rescan", count)) {
475 serio_disconnect_port(serio); 481 serio_disconnect_port(serio);
476 serio_find_driver(serio); 482 serio_find_driver(serio);
@@ -620,14 +626,30 @@ static void serio_destroy_port(struct serio *serio)
620} 626}
621 627
622/* 628/*
629 * Reconnect serio port (re-initialize attached device).
630 * If reconnect fails (old device is no longer attached or
631 * there was no device to begin with) we do full rescan in
632 * hope of finding a driver for the port.
633 */
634static int serio_reconnect_port(struct serio *serio)
635{
636 int error = serio_reconnect_driver(serio);
637
638 if (error) {
639 serio_disconnect_port(serio);
640 serio_find_driver(serio);
641 }
642
643 return error;
644}
645
646/*
623 * Reconnect serio port and all its children (re-initialize attached devices) 647 * Reconnect serio port and all its children (re-initialize attached devices)
624 */ 648 */
625static void serio_reconnect_port(struct serio *serio) 649static void serio_reconnect_chain(struct serio *serio)
626{ 650{
627 do { 651 do {
628 if (serio_reconnect_driver(serio)) { 652 if (serio_reconnect_port(serio)) {
629 serio_disconnect_port(serio);
630 serio_find_driver(serio);
631 /* Ok, old children are now gone, we are done */ 653 /* Ok, old children are now gone, we are done */
632 break; 654 break;
633 } 655 }
@@ -673,7 +695,7 @@ void serio_rescan(struct serio *serio)
673 695
674void serio_reconnect(struct serio *serio) 696void serio_reconnect(struct serio *serio)
675{ 697{
676 serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); 698 serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);
677} 699}
678 700
679/* 701/*
@@ -927,19 +949,16 @@ static int serio_suspend(struct device *dev, pm_message_t state)
927 949
928static int serio_resume(struct device *dev) 950static int serio_resume(struct device *dev)
929{ 951{
930 struct serio *serio = to_serio_port(dev); 952 /*
931 953 * Driver reconnect can take a while, so better let kseriod
932 if (dev->power.power_state.event != PM_EVENT_ON && 954 * deal with it.
933 serio_reconnect_driver(serio)) { 955 */
934 /* 956 if (dev->power.power_state.event != PM_EVENT_ON) {
935 * Driver re-probing can take a while, so better let kseriod 957 dev->power.power_state = PMSG_ON;
936 * deal with it. 958 serio_queue_event(to_serio_port(dev), NULL,
937 */ 959 SERIO_RECONNECT_PORT);
938 serio_rescan(serio);
939 } 960 }
940 961
941 dev->power.power_state = PMSG_ON;
942
943 return 0; 962 return 0;
944} 963}
945#endif /* CONFIG_PM */ 964#endif /* CONFIG_PM */
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index e57366521572..6e60a97a234c 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -205,6 +205,18 @@ config TOUCHSCREEN_TOUCHWIN
205 To compile this driver as a module, choose M here: the 205 To compile this driver as a module, choose M here: the
206 module will be called touchwin. 206 module will be called touchwin.
207 207
208config TOUCHSCREEN_ATMEL_TSADCC
209 tristate "Atmel Touchscreen Interface"
210 depends on ARCH_AT91SAM9RL
211 help
212 Say Y here if you have a 4-wire touchscreen connected to the
213 ADC Controller on your Atmel SoC (such as the AT91SAM9RL).
214
215 If unsure, say N.
216
217 To compile this driver as a module, choose M here: the
218 module will be called atmel_tsadcc.
219
208config TOUCHSCREEN_UCB1400 220config TOUCHSCREEN_UCB1400
209 tristate "Philips UCB1400 touchscreen" 221 tristate "Philips UCB1400 touchscreen"
210 select AC97_BUS 222 select AC97_BUS
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 39a804cd80f1..15cf29079489 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -7,6 +7,7 @@
7wm97xx-ts-y := wm97xx-core.o 7wm97xx-ts-y := wm97xx-core.o
8 8
9obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 9obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
10obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
10obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 11obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
11obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o 12obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
12obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 13obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 907a45fe9d40..ce6f48c695f5 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -517,7 +517,9 @@ static void ads7846_rx(void *ads)
517 if (x == MAX_12BIT) 517 if (x == MAX_12BIT)
518 x = 0; 518 x = 0;
519 519
520 if (likely(x && z1)) { 520 if (ts->model == 7843) {
521 Rt = ts->pressure_max / 2;
522 } else if (likely(x && z1)) {
521 /* compute touch pressure resistance using equation #2 */ 523 /* compute touch pressure resistance using equation #2 */
522 Rt = z2; 524 Rt = z2;
523 Rt -= z1; 525 Rt -= z1;
@@ -525,11 +527,9 @@ static void ads7846_rx(void *ads)
525 Rt *= ts->x_plate_ohms; 527 Rt *= ts->x_plate_ohms;
526 Rt /= z1; 528 Rt /= z1;
527 Rt = (Rt + 2047) >> 12; 529 Rt = (Rt + 2047) >> 12;
528 } else 530 } else {
529 Rt = 0; 531 Rt = 0;
530 532 }
531 if (ts->model == 7843)
532 Rt = ts->pressure_max / 2;
533 533
534 /* Sample found inconsistent by debouncing or pressure is beyond 534 /* Sample found inconsistent by debouncing or pressure is beyond
535 * the maximum. Don't report it to user space, repeat at least 535 * the maximum. Don't report it to user space, repeat at least
@@ -633,19 +633,17 @@ static void ads7846_rx_val(void *ads)
633 struct ads7846 *ts = ads; 633 struct ads7846 *ts = ads;
634 struct spi_message *m; 634 struct spi_message *m;
635 struct spi_transfer *t; 635 struct spi_transfer *t;
636 u16 *rx_val;
637 int val; 636 int val;
638 int action; 637 int action;
639 int status; 638 int status;
640 639
641 m = &ts->msg[ts->msg_idx]; 640 m = &ts->msg[ts->msg_idx];
642 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 641 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
643 rx_val = t->rx_buf;
644 642
645 /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding; 643 /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
646 * built from two 8 bit values written msb-first. 644 * built from two 8 bit values written msb-first.
647 */ 645 */
648 val = be16_to_cpu(*rx_val) >> 3; 646 val = be16_to_cpup((__be16 *)t->rx_buf) >> 3;
649 647
650 action = ts->filter(ts->filter_data, ts->msg_idx, &val); 648 action = ts->filter(ts->filter_data, ts->msg_idx, &val);
651 switch (action) { 649 switch (action) {
@@ -659,7 +657,7 @@ static void ads7846_rx_val(void *ads)
659 m = ts->last_msg; 657 m = ts->last_msg;
660 break; 658 break;
661 case ADS7846_FILTER_OK: 659 case ADS7846_FILTER_OK:
662 *rx_val = val; 660 *(u16 *)t->rx_buf = val;
663 ts->tc.ignore = 0; 661 ts->tc.ignore = 0;
664 m = &ts->msg[++ts->msg_idx]; 662 m = &ts->msg[++ts->msg_idx];
665 break; 663 break;
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
new file mode 100644
index 000000000000..eee126b19e8b
--- /dev/null
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -0,0 +1,332 @@
1/*
2 * Atmel Touch Screen Driver
3 *
4 * Copyright (c) 2008 ATMEL
5 * Copyright (c) 2008 Dan Liang
6 * Copyright (c) 2008 TimeSys Corporation
7 * Copyright (c) 2008 Justin Waters
8 *
9 * Based on touchscreen code from Atmel Corporation.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15#include <linux/init.h>
16#include <linux/err.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/input.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h>
22#include <linux/clk.h>
23#include <linux/platform_device.h>
24#include <linux/io.h>
25
26/* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */
27
28#define ATMEL_TSADCC_CR 0x00 /* Control register */
29#define ATMEL_TSADCC_SWRST (1 << 0) /* Software Reset*/
30#define ATMEL_TSADCC_START (1 << 1) /* Start conversion */
31
32#define ATMEL_TSADCC_MR 0x04 /* Mode register */
33#define ATMEL_TSADCC_TSAMOD (3 << 0) /* ADC mode */
34#define ATMEL_TSADCC_TSAMOD_ADC_ONLY_MODE (0x0) /* ADC Mode */
35#define ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE (0x1) /* Touch Screen Only Mode */
36#define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */
37#define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */
38#define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */
39#define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */
40#define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */
41#define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */
42#define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */
43
44#define ATMEL_TSADCC_TRGR 0x08 /* Trigger register */
45#define ATMEL_TSADCC_TRGMOD (7 << 0) /* Trigger mode */
46#define ATMEL_TSADCC_TRGMOD_NONE (0 << 0)
47#define ATMEL_TSADCC_TRGMOD_EXT_RISING (1 << 0)
48#define ATMEL_TSADCC_TRGMOD_EXT_FALLING (2 << 0)
49#define ATMEL_TSADCC_TRGMOD_EXT_ANY (3 << 0)
50#define ATMEL_TSADCC_TRGMOD_PENDET (4 << 0)
51#define ATMEL_TSADCC_TRGMOD_PERIOD (5 << 0)
52#define ATMEL_TSADCC_TRGMOD_CONTINUOUS (6 << 0)
53#define ATMEL_TSADCC_TRGPER (0xffff << 16) /* Trigger period */
54
55#define ATMEL_TSADCC_TSR 0x0C /* Touch Screen register */
56#define ATMEL_TSADCC_TSFREQ (0xf << 0) /* TS Frequency in Interleaved mode */
57#define ATMEL_TSADCC_TSSHTIM (0xf << 24) /* Sample & Hold time */
58
59#define ATMEL_TSADCC_CHER 0x10 /* Channel Enable register */
60#define ATMEL_TSADCC_CHDR 0x14 /* Channel Disable register */
61#define ATMEL_TSADCC_CHSR 0x18 /* Channel Status register */
62#define ATMEL_TSADCC_CH(n) (1 << (n)) /* Channel number */
63
64#define ATMEL_TSADCC_SR 0x1C /* Status register */
65#define ATMEL_TSADCC_EOC(n) (1 << ((n)+0)) /* End of conversion for channel N */
66#define ATMEL_TSADCC_OVRE(n) (1 << ((n)+8)) /* Overrun error for channel N */
67#define ATMEL_TSADCC_DRDY (1 << 16) /* Data Ready */
68#define ATMEL_TSADCC_GOVRE (1 << 17) /* General Overrun Error */
69#define ATMEL_TSADCC_ENDRX (1 << 18) /* End of RX Buffer */
70#define ATMEL_TSADCC_RXBUFF (1 << 19) /* TX Buffer full */
71#define ATMEL_TSADCC_PENCNT (1 << 20) /* Pen contact */
72#define ATMEL_TSADCC_NOCNT (1 << 21) /* No contact */
73
74#define ATMEL_TSADCC_LCDR 0x20 /* Last Converted Data register */
75#define ATMEL_TSADCC_DATA (0x3ff << 0) /* Channel data */
76
77#define ATMEL_TSADCC_IER 0x24 /* Interrupt Enable register */
78#define ATMEL_TSADCC_IDR 0x28 /* Interrupt Disable register */
79#define ATMEL_TSADCC_IMR 0x2C /* Interrupt Mask register */
80#define ATMEL_TSADCC_CDR0 0x30 /* Channel Data 0 */
81#define ATMEL_TSADCC_CDR1 0x34 /* Channel Data 1 */
82#define ATMEL_TSADCC_CDR2 0x38 /* Channel Data 2 */
83#define ATMEL_TSADCC_CDR3 0x3C /* Channel Data 3 */
84#define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */
85#define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */
86
87#define ADC_CLOCK 1000000
88
89struct atmel_tsadcc {
90 struct input_dev *input;
91 char phys[32];
92 struct clk *clk;
93 int irq;
94};
95
96static void __iomem *tsc_base;
97
98#define atmel_tsadcc_read(reg) __raw_readl(tsc_base + (reg))
99#define atmel_tsadcc_write(reg, val) __raw_writel((val), tsc_base + (reg))
100
101static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
102{
103 struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input;
104
105 unsigned int absx;
106 unsigned int absy;
107 unsigned int status;
108 unsigned int reg;
109
110 status = atmel_tsadcc_read(ATMEL_TSADCC_SR);
111 status &= atmel_tsadcc_read(ATMEL_TSADCC_IMR);
112
113 if (status & ATMEL_TSADCC_NOCNT) {
114 /* Contact lost */
115 reg = atmel_tsadcc_read(ATMEL_TSADCC_MR) | ATMEL_TSADCC_PENDBC;
116
117 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
118 atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
119 atmel_tsadcc_write(ATMEL_TSADCC_IDR,
120 ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
121 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
122
123 input_report_key(input_dev, BTN_TOUCH, 0);
124 input_sync(input_dev);
125
126 } else if (status & ATMEL_TSADCC_PENCNT) {
127 /* Pen detected */
128 reg = atmel_tsadcc_read(ATMEL_TSADCC_MR);
129 reg &= ~ATMEL_TSADCC_PENDBC;
130
131 atmel_tsadcc_write(ATMEL_TSADCC_IDR, ATMEL_TSADCC_PENCNT);
132 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
133 atmel_tsadcc_write(ATMEL_TSADCC_IER,
134 ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
135 atmel_tsadcc_write(ATMEL_TSADCC_TRGR,
136 ATMEL_TSADCC_TRGMOD_PERIOD | (0x0FFF << 16));
137
138 } else if (status & ATMEL_TSADCC_EOC(3)) {
139 /* Conversion finished */
140
141 absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10;
142 absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2);
143
144 absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10;
145 absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0);
146
147 input_report_abs(input_dev, ABS_X, absx);
148 input_report_abs(input_dev, ABS_Y, absy);
149 input_report_key(input_dev, BTN_TOUCH, 1);
150 input_sync(input_dev);
151 }
152
153 return IRQ_HANDLED;
154}
155
156/*
157 * The functions for inserting/removing us as a module.
158 */
159
160static int __devinit atmel_tsadcc_probe(struct platform_device *pdev)
161{
162 struct atmel_tsadcc *ts_dev;
163 struct input_dev *input_dev;
164 struct resource *res;
165 int err = 0;
166 unsigned int prsc;
167 unsigned int reg;
168
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
170 if (!res) {
171 dev_err(&pdev->dev, "no mmio resource defined.\n");
172 return -ENXIO;
173 }
174
175 /* Allocate memory for device */
176 ts_dev = kzalloc(sizeof(struct atmel_tsadcc), GFP_KERNEL);
177 if (!ts_dev) {
178 dev_err(&pdev->dev, "failed to allocate memory.\n");
179 return -ENOMEM;
180 }
181 platform_set_drvdata(pdev, ts_dev);
182
183 input_dev = input_allocate_device();
184 if (!input_dev) {
185 dev_err(&pdev->dev, "failed to allocate input device.\n");
186 err = -EBUSY;
187 goto err_free_mem;
188 }
189
190 ts_dev->irq = platform_get_irq(pdev, 0);
191 if (ts_dev->irq < 0) {
192 dev_err(&pdev->dev, "no irq ID is designated.\n");
193 err = -ENODEV;
194 goto err_free_dev;
195 }
196
197 if (!request_mem_region(res->start, res->end - res->start + 1,
198 "atmel tsadcc regs")) {
199 dev_err(&pdev->dev, "resources is unavailable.\n");
200 err = -EBUSY;
201 goto err_free_dev;
202 }
203
204 tsc_base = ioremap(res->start, res->end - res->start + 1);
205 if (!tsc_base) {
206 dev_err(&pdev->dev, "failed to map registers.\n");
207 err = -ENOMEM;
208 goto err_release_mem;
209 }
210
211 err = request_irq(ts_dev->irq, atmel_tsadcc_interrupt, IRQF_DISABLED,
212 pdev->dev.driver->name, ts_dev);
213 if (err) {
214 dev_err(&pdev->dev, "failed to allocate irq.\n");
215 goto err_unmap_regs;
216 }
217
218 ts_dev->clk = clk_get(&pdev->dev, "tsc_clk");
219 if (IS_ERR(ts_dev->clk)) {
220 dev_err(&pdev->dev, "failed to get ts_clk\n");
221 err = PTR_ERR(ts_dev->clk);
222 goto err_free_irq;
223 }
224
225 ts_dev->input = input_dev;
226
227 snprintf(ts_dev->phys, sizeof(ts_dev->phys),
228 "%s/input0", pdev->dev.bus_id);
229
230 input_dev->name = "atmel touch screen controller";
231 input_dev->phys = ts_dev->phys;
232 input_dev->dev.parent = &pdev->dev;
233
234 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
235 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
236
237 input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0);
238 input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0);
239
240 /* clk_enable() always returns 0, no need to check it */
241 clk_enable(ts_dev->clk);
242
243 prsc = clk_get_rate(ts_dev->clk);
244 dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc);
245
246 prsc = prsc / ADC_CLOCK / 2 - 1;
247
248 reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE |
249 ((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */
250 ((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */
251 ((prsc << 8) & ATMEL_TSADCC_PRESCAL) | /* PRESCAL */
252 ((0x13 << 16) & ATMEL_TSADCC_STARTUP) | /* STARTUP */
253 ((0x0F << 28) & ATMEL_TSADCC_PENDBC); /* PENDBC */
254
255 atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST);
256 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
257 atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
258 atmel_tsadcc_write(ATMEL_TSADCC_TSR, (0x3 << 24) & ATMEL_TSADCC_TSSHTIM);
259
260 atmel_tsadcc_read(ATMEL_TSADCC_SR);
261 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
262
263 /* All went ok, so register to the input system */
264 err = input_register_device(input_dev);
265 if (err)
266 goto err_fail;
267
268 return 0;
269
270err_fail:
271 clk_disable(ts_dev->clk);
272 clk_put(ts_dev->clk);
273err_free_irq:
274 free_irq(ts_dev->irq, ts_dev);
275err_unmap_regs:
276 iounmap(tsc_base);
277err_release_mem:
278 release_mem_region(res->start, res->end - res->start + 1);
279err_free_dev:
280 input_free_device(ts_dev->input);
281err_free_mem:
282 kfree(ts_dev);
283 return err;
284}
285
286static int __devexit atmel_tsadcc_remove(struct platform_device *pdev)
287{
288 struct atmel_tsadcc *ts_dev = dev_get_drvdata(&pdev->dev);
289 struct resource *res;
290
291 free_irq(ts_dev->irq, ts_dev);
292
293 input_unregister_device(ts_dev->input);
294
295 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
296 iounmap(tsc_base);
297 release_mem_region(res->start, res->end - res->start + 1);
298
299 clk_disable(ts_dev->clk);
300 clk_put(ts_dev->clk);
301
302 kfree(ts_dev);
303
304 return 0;
305}
306
307static struct platform_driver atmel_tsadcc_driver = {
308 .probe = atmel_tsadcc_probe,
309 .remove = __devexit_p(atmel_tsadcc_remove),
310 .driver = {
311 .name = "atmel_tsadcc",
312 },
313};
314
315static int __init atmel_tsadcc_init(void)
316{
317 return platform_driver_register(&atmel_tsadcc_driver);
318}
319
320static void __exit atmel_tsadcc_exit(void)
321{
322 platform_driver_unregister(&atmel_tsadcc_driver);
323}
324
325module_init(atmel_tsadcc_init);
326module_exit(atmel_tsadcc_exit);
327
328
329MODULE_LICENSE("GPL");
330MODULE_DESCRIPTION("Atmel TouchScreen Driver");
331MODULE_AUTHOR("Dan Liang <dan.liang@atmel.com>");
332
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 4e9d8eece2e0..d0e13fc4a88c 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -195,7 +195,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
195{ 195{
196 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) { 196 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
197 /* Disable Interrupt */ 197 /* Disable Interrupt */
198 set_irq_type(corgi_ts->irq_gpio, IRQT_NOEDGE); 198 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_NONE);
199 if (read_xydata(corgi_ts)) { 199 if (read_xydata(corgi_ts)) {
200 corgi_ts->pendown = 1; 200 corgi_ts->pendown = 1;
201 new_data(corgi_ts); 201 new_data(corgi_ts);
@@ -214,7 +214,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
214 } 214 }
215 215
216 /* Enable Falling Edge */ 216 /* Enable Falling Edge */
217 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 217 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
218 corgi_ts->pendown = 0; 218 corgi_ts->pendown = 0;
219 } 219 }
220} 220}
@@ -258,7 +258,7 @@ static int corgits_resume(struct platform_device *dev)
258 258
259 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 259 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
260 /* Enable Falling Edge */ 260 /* Enable Falling Edge */
261 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 261 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
262 corgi_ts->power_mode = PWR_MODE_ACTIVE; 262 corgi_ts->power_mode = PWR_MODE_ACTIVE;
263 263
264 return 0; 264 return 0;
@@ -333,7 +333,7 @@ static int __init corgits_probe(struct platform_device *pdev)
333 corgi_ts->power_mode = PWR_MODE_ACTIVE; 333 corgi_ts->power_mode = PWR_MODE_ACTIVE;
334 334
335 /* Enable Falling Edge */ 335 /* Enable Falling Edge */
336 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 336 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
337 337
338 return 0; 338 return 0;
339 339
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index a79f029b91c0..590a1379aa32 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -198,7 +198,7 @@ static int wm97xx_acc_startup(struct wm97xx *wm)
198 switch (wm->id) { 198 switch (wm->id) {
199 case WM9705_ID2: 199 case WM9705_ID2:
200 wm->pen_irq = IRQ_GPIO(4); 200 wm->pen_irq = IRQ_GPIO(4);
201 set_irq_type(IRQ_GPIO(4), IRQT_BOTHEDGE); 201 set_irq_type(IRQ_GPIO(4), IRQ_TYPE_EDGE_BOTH);
202 break; 202 break;
203 case WM9712_ID2: 203 case WM9712_ID2:
204 case WM9713_ID2: 204 case WM9713_ID2:
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
index 66f946aa30b3..3d113c6e4a70 100644
--- a/drivers/isdn/Kconfig
+++ b/drivers/isdn/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5menuconfig ISDN 5menuconfig ISDN
6 tristate "ISDN support" 6 bool "ISDN support"
7 depends on NET 7 depends on NET
8 depends on !S390 8 depends on !S390
9 ---help--- 9 ---help---
@@ -21,6 +21,8 @@ menuconfig ISDN
21 21
22if ISDN 22if ISDN
23 23
24source "drivers/isdn/mISDN/Kconfig"
25
24menuconfig ISDN_I4L 26menuconfig ISDN_I4L
25 tristate "Old ISDN4Linux (deprecated)" 27 tristate "Old ISDN4Linux (deprecated)"
26 ---help--- 28 ---help---
diff --git a/drivers/isdn/Makefile b/drivers/isdn/Makefile
index 988142c30a6d..8380a4568d11 100644
--- a/drivers/isdn/Makefile
+++ b/drivers/isdn/Makefile
@@ -4,6 +4,7 @@
4 4
5obj-$(CONFIG_ISDN_I4L) += i4l/ 5obj-$(CONFIG_ISDN_I4L) += i4l/
6obj-$(CONFIG_ISDN_CAPI) += capi/ 6obj-$(CONFIG_ISDN_CAPI) += capi/
7obj-$(CONFIG_MISDN) += mISDN/
7obj-$(CONFIG_ISDN_CAPI) += hardware/ 8obj-$(CONFIG_ISDN_CAPI) += hardware/
8obj-$(CONFIG_ISDN_DIVERSION) += divert/ 9obj-$(CONFIG_ISDN_DIVERSION) += divert/
9obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/ 10obj-$(CONFIG_ISDN_DRV_HISAX) += hisax/
diff --git a/drivers/isdn/hardware/Makefile b/drivers/isdn/hardware/Makefile
index 11c8a183948c..a5d8fce4c4c4 100644
--- a/drivers/isdn/hardware/Makefile
+++ b/drivers/isdn/hardware/Makefile
@@ -4,3 +4,4 @@
4 4
5obj-$(CONFIG_CAPI_AVM) += avm/ 5obj-$(CONFIG_CAPI_AVM) += avm/
6obj-$(CONFIG_CAPI_EICON) += eicon/ 6obj-$(CONFIG_CAPI_EICON) += eicon/
7obj-$(CONFIG_MISDN) += mISDN/
diff --git a/drivers/isdn/hardware/mISDN/Kconfig b/drivers/isdn/hardware/mISDN/Kconfig
new file mode 100644
index 000000000000..14793480c453
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/Kconfig
@@ -0,0 +1,25 @@
1#
2# Hardware for mISDN
3#
4comment "mISDN hardware drivers"
5
6config MISDN_HFCPCI
7 tristate "Support for HFC PCI cards"
8 depends on MISDN
9 depends on PCI
10 help
11 Enable support for cards with Cologne Chip AG's
12 HFC PCI chip.
13
14config MISDN_HFCMULTI
15 tristate "Support for HFC multiport cards (HFC-4S/8S/E1)"
16 depends on PCI
17 depends on MISDN
18 help
19 Enable support for cards with Cologne Chip AG's HFC multiport
20 chip. There are three types of chips that are quite similar,
21 but the interface is different:
22 * HFC-4S (4 S/T interfaces on one chip)
23 * HFC-8S (8 S/T interfaces on one chip)
24 * HFC-E1 (E1 interface for 2Mbit ISDN)
25
diff --git a/drivers/isdn/hardware/mISDN/Makefile b/drivers/isdn/hardware/mISDN/Makefile
new file mode 100644
index 000000000000..1e7ca5332ad7
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the modular ISDN hardware drivers
3#
4#
5
6obj-$(CONFIG_MISDN_HFCPCI) += hfcpci.o
7obj-$(CONFIG_MISDN_HFCMULTI) += hfcmulti.o
diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h
new file mode 100644
index 000000000000..a33d87afc843
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfc_multi.h
@@ -0,0 +1,1204 @@
1/*
2 * see notice in hfc_multi.c
3 */
4
5extern void ztdummy_extern_interrupt(void);
6extern void ztdummy_register_interrupt(void);
7extern int ztdummy_unregister_interrupt(void);
8
9#define DEBUG_HFCMULTI_FIFO 0x00010000
10#define DEBUG_HFCMULTI_CRC 0x00020000
11#define DEBUG_HFCMULTI_INIT 0x00040000
12#define DEBUG_HFCMULTI_PLXSD 0x00080000
13#define DEBUG_HFCMULTI_MODE 0x00100000
14#define DEBUG_HFCMULTI_MSG 0x00200000
15#define DEBUG_HFCMULTI_STATE 0x00400000
16#define DEBUG_HFCMULTI_SYNC 0x01000000
17#define DEBUG_HFCMULTI_DTMF 0x02000000
18#define DEBUG_HFCMULTI_LOCK 0x80000000
19
20#define PCI_ENA_REGIO 0x01
21#define PCI_ENA_MEMIO 0x02
22
23/*
24 * NOTE: some registers are assigned multiple times due to different modes
25 * also registers are assigned differen for HFC-4s/8s and HFC-E1
26 */
27
28/*
29#define MAX_FRAME_SIZE 2048
30*/
31
32struct hfc_chan {
33 struct dchannel *dch; /* link if channel is a D-channel */
34 struct bchannel *bch; /* link if channel is a B-channel */
35 int port; /* the interface port this */
36 /* channel is associated with */
37 int nt_timer; /* -1 if off, 0 if elapsed, >0 if running */
38 int los, ais, slip_tx, slip_rx, rdi; /* current alarms */
39 int jitter;
40 u_long cfg; /* port configuration */
41 int sync; /* sync state (used by E1) */
42 u_int protocol; /* current protocol */
43 int slot_tx; /* current pcm slot */
44 int bank_tx; /* current pcm bank */
45 int slot_rx;
46 int bank_rx;
47 int conf; /* conference setting of TX slot */
48 int txpending; /* if there is currently data in */
49 /* the FIFO 0=no, 1=yes, 2=splloop */
50 int rx_off; /* set to turn fifo receive off */
51 int coeff_count; /* curren coeff block */
52 s32 *coeff; /* memory pointer to 8 coeff blocks */
53};
54
55
56struct hfcm_hw {
57 u_char r_ctrl;
58 u_char r_irq_ctrl;
59 u_char r_cirm;
60 u_char r_ram_sz;
61 u_char r_pcm_md0;
62 u_char r_irqmsk_misc;
63 u_char r_dtmf;
64 u_char r_st_sync;
65 u_char r_sci_msk;
66 u_char r_tx0, r_tx1;
67 u_char a_st_ctrl0[8];
68 timer_t timer;
69};
70
71
72/* for each stack these flags are used (cfg) */
73#define HFC_CFG_NONCAP_TX 1 /* S/T TX interface has less capacity */
74#define HFC_CFG_DIS_ECHANNEL 2 /* disable E-channel processing */
75#define HFC_CFG_REG_ECHANNEL 3 /* register E-channel */
76#define HFC_CFG_OPTICAL 4 /* the E1 interface is optical */
77#define HFC_CFG_REPORT_LOS 5 /* the card should report loss of signal */
78#define HFC_CFG_REPORT_AIS 6 /* the card should report alarm ind. sign. */
79#define HFC_CFG_REPORT_SLIP 7 /* the card should report bit slips */
80#define HFC_CFG_REPORT_RDI 8 /* the card should report remote alarm */
81#define HFC_CFG_DTMF 9 /* enable DTMF-detection */
82#define HFC_CFG_CRC4 10 /* disable CRC-4 Multiframe mode, */
83 /* use double frame instead. */
84
85#define HFC_CHIP_EXRAM_128 0 /* external ram 128k */
86#define HFC_CHIP_EXRAM_512 1 /* external ram 256k */
87#define HFC_CHIP_REVISION0 2 /* old fifo handling */
88#define HFC_CHIP_PCM_SLAVE 3 /* PCM is slave */
89#define HFC_CHIP_PCM_MASTER 4 /* PCM is master */
90#define HFC_CHIP_RX_SYNC 5 /* disable pll sync for pcm */
91#define HFC_CHIP_DTMF 6 /* DTMF decoding is enabled */
92#define HFC_CHIP_ULAW 7 /* ULAW mode */
93#define HFC_CHIP_CLOCK2 8 /* double clock mode */
94#define HFC_CHIP_E1CLOCK_GET 9 /* always get clock from E1 interface */
95#define HFC_CHIP_E1CLOCK_PUT 10 /* always put clock from E1 interface */
96#define HFC_CHIP_WATCHDOG 11 /* whether we should send signals */
97 /* to the watchdog */
98#define HFC_CHIP_B410P 12 /* whether we have a b410p with echocan in */
99 /* hw */
100#define HFC_CHIP_PLXSD 13 /* whether we have a Speech-Design PLX */
101
102#define HFC_IO_MODE_PCIMEM 0x00 /* normal memory mapped IO */
103#define HFC_IO_MODE_REGIO 0x01 /* PCI io access */
104#define HFC_IO_MODE_PLXSD 0x02 /* access HFC via PLX9030 */
105
106/* table entry in the PCI devices list */
107struct hm_map {
108 char *vendor_name;
109 char *card_name;
110 int type;
111 int ports;
112 int clock2;
113 int leds;
114 int opticalsupport;
115 int dip_type;
116 int io_mode;
117};
118
119struct hfc_multi {
120 struct list_head list;
121 struct hm_map *mtyp;
122 int id;
123 int pcm; /* id of pcm bus */
124 int type;
125 int ports;
126
127 u_int irq; /* irq used by card */
128 u_int irqcnt;
129 struct pci_dev *pci_dev;
130 int io_mode; /* selects mode */
131#ifdef HFC_REGISTER_DEBUG
132 void (*HFC_outb)(struct hfc_multi *hc, u_char reg,
133 u_char val, const char *function, int line);
134 void (*HFC_outb_nodebug)(struct hfc_multi *hc, u_char reg,
135 u_char val, const char *function, int line);
136 u_char (*HFC_inb)(struct hfc_multi *hc, u_char reg,
137 const char *function, int line);
138 u_char (*HFC_inb_nodebug)(struct hfc_multi *hc, u_char reg,
139 const char *function, int line);
140 u_short (*HFC_inw)(struct hfc_multi *hc, u_char reg,
141 const char *function, int line);
142 u_short (*HFC_inw_nodebug)(struct hfc_multi *hc, u_char reg,
143 const char *function, int line);
144 void (*HFC_wait)(struct hfc_multi *hc,
145 const char *function, int line);
146 void (*HFC_wait_nodebug)(struct hfc_multi *hc,
147 const char *function, int line);
148#else
149 void (*HFC_outb)(struct hfc_multi *hc, u_char reg,
150 u_char val);
151 void (*HFC_outb_nodebug)(struct hfc_multi *hc, u_char reg,
152 u_char val);
153 u_char (*HFC_inb)(struct hfc_multi *hc, u_char reg);
154 u_char (*HFC_inb_nodebug)(struct hfc_multi *hc, u_char reg);
155 u_short (*HFC_inw)(struct hfc_multi *hc, u_char reg);
156 u_short (*HFC_inw_nodebug)(struct hfc_multi *hc, u_char reg);
157 void (*HFC_wait)(struct hfc_multi *hc);
158 void (*HFC_wait_nodebug)(struct hfc_multi *hc);
159#endif
160 void (*read_fifo)(struct hfc_multi *hc, u_char *data,
161 int len);
162 void (*write_fifo)(struct hfc_multi *hc, u_char *data,
163 int len);
164 u_long pci_origmembase, plx_origmembase, dsp_origmembase;
165 u_char *pci_membase; /* PCI memory (MUST BE BYTE POINTER) */
166 u_char *plx_membase; /* PLX memory */
167 u_char *dsp_membase; /* DSP on PLX */
168 u_long pci_iobase; /* PCI IO */
169 struct hfcm_hw hw; /* remember data of write-only-registers */
170
171 u_long chip; /* chip configuration */
172 int masterclk; /* port that provides master clock -1=off */
173 int dtmf; /* flag that dtmf is currently in process */
174 int Flen; /* F-buffer size */
175 int Zlen; /* Z-buffer size (must be int for calculation)*/
176 int max_trans; /* maximum transparent fifo fill */
177 int Zmin; /* Z-buffer offset */
178 int DTMFbase; /* base address of DTMF coefficients */
179
180 u_int slots; /* number of PCM slots */
181 u_int leds; /* type of leds */
182 u_int ledcount; /* used to animate leds */
183 u_long ledstate; /* save last state of leds */
184 int opticalsupport; /* has the e1 board */
185 /* an optical Interface */
186 int dslot; /* channel # of d-channel (E1) default 16 */
187
188 u_long wdcount; /* every 500 ms we need to */
189 /* send the watchdog a signal */
190 u_char wdbyte; /* watchdog toggle byte */
191 u_int activity[8]; /* if there is any action on this */
192 /* port (will be cleared after */
193 /* showing led-states) */
194 int e1_state; /* keep track of last state */
195 int e1_getclock; /* if sync is retrieved from interface */
196 int syncronized; /* keep track of existing sync interface */
197 int e1_resync; /* resync jobs */
198
199 spinlock_t lock; /* the lock */
200
201 /*
202 * the channel index is counted from 0, regardless where the channel
203 * is located on the hfc-channel.
204 * the bch->channel is equvalent to the hfc-channel
205 */
206 struct hfc_chan chan[32];
207 u_char created[8]; /* what port is created */
208 signed char slot_owner[256]; /* owner channel of slot */
209};
210
211/* PLX GPIOs */
212#define PLX_GPIO4_DIR_BIT 13
213#define PLX_GPIO4_BIT 14
214#define PLX_GPIO5_DIR_BIT 16
215#define PLX_GPIO5_BIT 17
216#define PLX_GPIO6_DIR_BIT 19
217#define PLX_GPIO6_BIT 20
218#define PLX_GPIO7_DIR_BIT 22
219#define PLX_GPIO7_BIT 23
220#define PLX_GPIO8_DIR_BIT 25
221#define PLX_GPIO8_BIT 26
222
223#define PLX_GPIO4 (1 << PLX_GPIO4_BIT)
224#define PLX_GPIO5 (1 << PLX_GPIO5_BIT)
225#define PLX_GPIO6 (1 << PLX_GPIO6_BIT)
226#define PLX_GPIO7 (1 << PLX_GPIO7_BIT)
227#define PLX_GPIO8 (1 << PLX_GPIO8_BIT)
228
229#define PLX_GPIO4_DIR (1 << PLX_GPIO4_DIR_BIT)
230#define PLX_GPIO5_DIR (1 << PLX_GPIO5_DIR_BIT)
231#define PLX_GPIO6_DIR (1 << PLX_GPIO6_DIR_BIT)
232#define PLX_GPIO7_DIR (1 << PLX_GPIO7_DIR_BIT)
233#define PLX_GPIO8_DIR (1 << PLX_GPIO8_DIR_BIT)
234
235#define PLX_TERM_ON PLX_GPIO7
236#define PLX_SLAVE_EN_N PLX_GPIO5
237#define PLX_MASTER_EN PLX_GPIO6
238#define PLX_SYNC_O_EN PLX_GPIO4
239#define PLX_DSP_RES_N PLX_GPIO8
240/* GPIO4..8 Enable & Set to OUT, SLAVE_EN_N = 1 */
241#define PLX_GPIOC_INIT (PLX_GPIO4_DIR | PLX_GPIO5_DIR | PLX_GPIO6_DIR \
242 | PLX_GPIO7_DIR | PLX_GPIO8_DIR | PLX_SLAVE_EN_N)
243
244/* PLX Interrupt Control/STATUS */
245#define PLX_INTCSR_LINTI1_ENABLE 0x01
246#define PLX_INTCSR_LINTI1_STATUS 0x04
247#define PLX_INTCSR_LINTI2_ENABLE 0x08
248#define PLX_INTCSR_LINTI2_STATUS 0x20
249#define PLX_INTCSR_PCIINT_ENABLE 0x40
250
251/* PLX Registers */
252#define PLX_INTCSR 0x4c
253#define PLX_CNTRL 0x50
254#define PLX_GPIOC 0x54
255
256
257/*
258 * REGISTER SETTING FOR HFC-4S/8S AND HFC-E1
259 */
260
261/* write only registers */
262#define R_CIRM 0x00
263#define R_CTRL 0x01
264#define R_BRG_PCM_CFG 0x02
265#define R_RAM_ADDR0 0x08
266#define R_RAM_ADDR1 0x09
267#define R_RAM_ADDR2 0x0A
268#define R_FIRST_FIFO 0x0B
269#define R_RAM_SZ 0x0C
270#define R_FIFO_MD 0x0D
271#define R_INC_RES_FIFO 0x0E
272#define R_FSM_IDX 0x0F
273#define R_FIFO 0x0F
274#define R_SLOT 0x10
275#define R_IRQMSK_MISC 0x11
276#define R_SCI_MSK 0x12
277#define R_IRQ_CTRL 0x13
278#define R_PCM_MD0 0x14
279#define R_PCM_MD1 0x15
280#define R_PCM_MD2 0x15
281#define R_SH0H 0x15
282#define R_SH1H 0x15
283#define R_SH0L 0x15
284#define R_SH1L 0x15
285#define R_SL_SEL0 0x15
286#define R_SL_SEL1 0x15
287#define R_SL_SEL2 0x15
288#define R_SL_SEL3 0x15
289#define R_SL_SEL4 0x15
290#define R_SL_SEL5 0x15
291#define R_SL_SEL6 0x15
292#define R_SL_SEL7 0x15
293#define R_ST_SEL 0x16
294#define R_ST_SYNC 0x17
295#define R_CONF_EN 0x18
296#define R_TI_WD 0x1A
297#define R_BERT_WD_MD 0x1B
298#define R_DTMF 0x1C
299#define R_DTMF_N 0x1D
300#define R_E1_WR_STA 0x20
301#define R_E1_RD_STA 0x20
302#define R_LOS0 0x22
303#define R_LOS1 0x23
304#define R_RX0 0x24
305#define R_RX_FR0 0x25
306#define R_RX_FR1 0x26
307#define R_TX0 0x28
308#define R_TX1 0x29
309#define R_TX_FR0 0x2C
310
311#define R_TX_FR1 0x2D
312#define R_TX_FR2 0x2E
313#define R_JATT_ATT 0x2F /* undocumented */
314#define A_ST_RD_STATE 0x30
315#define A_ST_WR_STATE 0x30
316#define R_RX_OFF 0x30
317#define A_ST_CTRL0 0x31
318#define R_SYNC_OUT 0x31
319#define A_ST_CTRL1 0x32
320#define A_ST_CTRL2 0x33
321#define A_ST_SQ_WR 0x34
322#define R_TX_OFF 0x34
323#define R_SYNC_CTRL 0x35
324#define A_ST_CLK_DLY 0x37
325#define R_PWM0 0x38
326#define R_PWM1 0x39
327#define A_ST_B1_TX 0x3C
328#define A_ST_B2_TX 0x3D
329#define A_ST_D_TX 0x3E
330#define R_GPIO_OUT0 0x40
331#define R_GPIO_OUT1 0x41
332#define R_GPIO_EN0 0x42
333#define R_GPIO_EN1 0x43
334#define R_GPIO_SEL 0x44
335#define R_BRG_CTRL 0x45
336#define R_PWM_MD 0x46
337#define R_BRG_MD 0x47
338#define R_BRG_TIM0 0x48
339#define R_BRG_TIM1 0x49
340#define R_BRG_TIM2 0x4A
341#define R_BRG_TIM3 0x4B
342#define R_BRG_TIM_SEL01 0x4C
343#define R_BRG_TIM_SEL23 0x4D
344#define R_BRG_TIM_SEL45 0x4E
345#define R_BRG_TIM_SEL67 0x4F
346#define A_SL_CFG 0xD0
347#define A_CONF 0xD1
348#define A_CH_MSK 0xF4
349#define A_CON_HDLC 0xFA
350#define A_SUBCH_CFG 0xFB
351#define A_CHANNEL 0xFC
352#define A_FIFO_SEQ 0xFD
353#define A_IRQ_MSK 0xFF
354
355/* read only registers */
356#define A_Z12 0x04
357#define A_Z1L 0x04
358#define A_Z1 0x04
359#define A_Z1H 0x05
360#define A_Z2L 0x06
361#define A_Z2 0x06
362#define A_Z2H 0x07
363#define A_F1 0x0C
364#define A_F12 0x0C
365#define A_F2 0x0D
366#define R_IRQ_OVIEW 0x10
367#define R_IRQ_MISC 0x11
368#define R_IRQ_STATECH 0x12
369#define R_CONF_OFLOW 0x14
370#define R_RAM_USE 0x15
371#define R_CHIP_ID 0x16
372#define R_BERT_STA 0x17
373#define R_F0_CNTL 0x18
374#define R_F0_CNTH 0x19
375#define R_BERT_EC 0x1A
376#define R_BERT_ECL 0x1A
377#define R_BERT_ECH 0x1B
378#define R_STATUS 0x1C
379#define R_CHIP_RV 0x1F
380#define R_STATE 0x20
381#define R_SYNC_STA 0x24
382#define R_RX_SL0_0 0x25
383#define R_RX_SL0_1 0x26
384#define R_RX_SL0_2 0x27
385#define R_JATT_DIR 0x2b /* undocumented */
386#define R_SLIP 0x2c
387#define A_ST_RD_STA 0x30
388#define R_FAS_EC 0x30
389#define R_FAS_ECL 0x30
390#define R_FAS_ECH 0x31
391#define R_VIO_EC 0x32
392#define R_VIO_ECL 0x32
393#define R_VIO_ECH 0x33
394#define A_ST_SQ_RD 0x34
395#define R_CRC_EC 0x34
396#define R_CRC_ECL 0x34
397#define R_CRC_ECH 0x35
398#define R_E_EC 0x36
399#define R_E_ECL 0x36
400#define R_E_ECH 0x37
401#define R_SA6_SA13_EC 0x38
402#define R_SA6_SA13_ECL 0x38
403#define R_SA6_SA13_ECH 0x39
404#define R_SA6_SA23_EC 0x3A
405#define R_SA6_SA23_ECL 0x3A
406#define R_SA6_SA23_ECH 0x3B
407#define A_ST_B1_RX 0x3C
408#define A_ST_B2_RX 0x3D
409#define A_ST_D_RX 0x3E
410#define A_ST_E_RX 0x3F
411#define R_GPIO_IN0 0x40
412#define R_GPIO_IN1 0x41
413#define R_GPI_IN0 0x44
414#define R_GPI_IN1 0x45
415#define R_GPI_IN2 0x46
416#define R_GPI_IN3 0x47
417#define R_INT_DATA 0x88
418#define R_IRQ_FIFO_BL0 0xC8
419#define R_IRQ_FIFO_BL1 0xC9
420#define R_IRQ_FIFO_BL2 0xCA
421#define R_IRQ_FIFO_BL3 0xCB
422#define R_IRQ_FIFO_BL4 0xCC
423#define R_IRQ_FIFO_BL5 0xCD
424#define R_IRQ_FIFO_BL6 0xCE
425#define R_IRQ_FIFO_BL7 0xCF
426
427/* read and write registers */
428#define A_FIFO_DATA0 0x80
429#define A_FIFO_DATA1 0x80
430#define A_FIFO_DATA2 0x80
431#define A_FIFO_DATA0_NOINC 0x84
432#define A_FIFO_DATA1_NOINC 0x84
433#define A_FIFO_DATA2_NOINC 0x84
434#define R_RAM_DATA 0xC0
435
436
437/*
438 * BIT SETTING FOR HFC-4S/8S AND HFC-E1
439 */
440
441/* chapter 2: universal bus interface */
442/* R_CIRM */
443#define V_IRQ_SEL 0x01
444#define V_SRES 0x08
445#define V_HFCRES 0x10
446#define V_PCMRES 0x20
447#define V_STRES 0x40
448#define V_ETRES 0x40
449#define V_RLD_EPR 0x80
450/* R_CTRL */
451#define V_FIFO_LPRIO 0x02
452#define V_SLOW_RD 0x04
453#define V_EXT_RAM 0x08
454#define V_CLK_OFF 0x20
455#define V_ST_CLK 0x40
456/* R_RAM_ADDR0 */
457#define V_RAM_ADDR2 0x01
458#define V_ADDR_RES 0x40
459#define V_ADDR_INC 0x80
460/* R_RAM_SZ */
461#define V_RAM_SZ 0x01
462#define V_PWM0_16KHZ 0x10
463#define V_PWM1_16KHZ 0x20
464#define V_FZ_MD 0x80
465/* R_CHIP_ID */
466#define V_PNP_IRQ 0x01
467#define V_CHIP_ID 0x10
468
469/* chapter 3: data flow */
470/* R_FIRST_FIFO */
471#define V_FIRST_FIRO_DIR 0x01
472#define V_FIRST_FIFO_NUM 0x02
473/* R_FIFO_MD */
474#define V_FIFO_MD 0x01
475#define V_CSM_MD 0x04
476#define V_FSM_MD 0x08
477#define V_FIFO_SZ 0x10
478/* R_FIFO */
479#define V_FIFO_DIR 0x01
480#define V_FIFO_NUM 0x02
481#define V_REV 0x80
482/* R_SLOT */
483#define V_SL_DIR 0x01
484#define V_SL_NUM 0x02
485/* A_SL_CFG */
486#define V_CH_DIR 0x01
487#define V_CH_SEL 0x02
488#define V_ROUTING 0x40
489/* A_CON_HDLC */
490#define V_IFF 0x01
491#define V_HDLC_TRP 0x02
492#define V_TRP_IRQ 0x04
493#define V_DATA_FLOW 0x20
494/* A_SUBCH_CFG */
495#define V_BIT_CNT 0x01
496#define V_START_BIT 0x08
497#define V_LOOP_FIFO 0x40
498#define V_INV_DATA 0x80
499/* A_CHANNEL */
500#define V_CH_DIR0 0x01
501#define V_CH_NUM0 0x02
502/* A_FIFO_SEQ */
503#define V_NEXT_FIFO_DIR 0x01
504#define V_NEXT_FIFO_NUM 0x02
505#define V_SEQ_END 0x40
506
507/* chapter 4: FIFO handling and HDLC controller */
508/* R_INC_RES_FIFO */
509#define V_INC_F 0x01
510#define V_RES_F 0x02
511#define V_RES_LOST 0x04
512
513/* chapter 5: S/T interface */
514/* R_SCI_MSK */
515#define V_SCI_MSK_ST0 0x01
516#define V_SCI_MSK_ST1 0x02
517#define V_SCI_MSK_ST2 0x04
518#define V_SCI_MSK_ST3 0x08
519#define V_SCI_MSK_ST4 0x10
520#define V_SCI_MSK_ST5 0x20
521#define V_SCI_MSK_ST6 0x40
522#define V_SCI_MSK_ST7 0x80
523/* R_ST_SEL */
524#define V_ST_SEL 0x01
525#define V_MULT_ST 0x08
526/* R_ST_SYNC */
527#define V_SYNC_SEL 0x01
528#define V_AUTO_SYNC 0x08
529/* A_ST_WR_STA */
530#define V_ST_SET_STA 0x01
531#define V_ST_LD_STA 0x10
532#define V_ST_ACT 0x20
533#define V_SET_G2_G3 0x80
534/* A_ST_CTRL0 */
535#define V_B1_EN 0x01
536#define V_B2_EN 0x02
537#define V_ST_MD 0x04
538#define V_D_PRIO 0x08
539#define V_SQ_EN 0x10
540#define V_96KHZ 0x20
541#define V_TX_LI 0x40
542#define V_ST_STOP 0x80
543/* A_ST_CTRL1 */
544#define V_G2_G3_EN 0x01
545#define V_D_HI 0x04
546#define V_E_IGNO 0x08
547#define V_E_LO 0x10
548#define V_B12_SWAP 0x80
549/* A_ST_CTRL2 */
550#define V_B1_RX_EN 0x01
551#define V_B2_RX_EN 0x02
552#define V_ST_TRIS 0x40
553/* A_ST_CLK_DLY */
554#define V_ST_CK_DLY 0x01
555#define V_ST_SMPL 0x10
556/* A_ST_D_TX */
557#define V_ST_D_TX 0x40
558/* R_IRQ_STATECH */
559#define V_SCI_ST0 0x01
560#define V_SCI_ST1 0x02
561#define V_SCI_ST2 0x04
562#define V_SCI_ST3 0x08
563#define V_SCI_ST4 0x10
564#define V_SCI_ST5 0x20
565#define V_SCI_ST6 0x40
566#define V_SCI_ST7 0x80
567/* A_ST_RD_STA */
568#define V_ST_STA 0x01
569#define V_FR_SYNC_ST 0x10
570#define V_TI2_EXP 0x20
571#define V_INFO0 0x40
572#define V_G2_G3 0x80
573/* A_ST_SQ_RD */
574#define V_ST_SQ 0x01
575#define V_MF_RX_RDY 0x10
576#define V_MF_TX_RDY 0x80
577/* A_ST_D_RX */
578#define V_ST_D_RX 0x40
579/* A_ST_E_RX */
580#define V_ST_E_RX 0x40
581
582/* chapter 5: E1 interface */
583/* R_E1_WR_STA */
584/* R_E1_RD_STA */
585#define V_E1_SET_STA 0x01
586#define V_E1_LD_STA 0x10
587/* R_RX0 */
588#define V_RX_CODE 0x01
589#define V_RX_FBAUD 0x04
590#define V_RX_CMI 0x08
591#define V_RX_INV_CMI 0x10
592#define V_RX_INV_CLK 0x20
593#define V_RX_INV_DATA 0x40
594#define V_AIS_ITU 0x80
595/* R_RX_FR0 */
596#define V_NO_INSYNC 0x01
597#define V_AUTO_RESYNC 0x02
598#define V_AUTO_RECO 0x04
599#define V_SWORD_COND 0x08
600#define V_SYNC_LOSS 0x10
601#define V_XCRC_SYNC 0x20
602#define V_MF_RESYNC 0x40
603#define V_RESYNC 0x80
604/* R_RX_FR1 */
605#define V_RX_MF 0x01
606#define V_RX_MF_SYNC 0x02
607#define V_RX_SL0_RAM 0x04
608#define V_ERR_SIM 0x20
609#define V_RES_NMF 0x40
610/* R_TX0 */
611#define V_TX_CODE 0x01
612#define V_TX_FBAUD 0x04
613#define V_TX_CMI_CODE 0x08
614#define V_TX_INV_CMI_CODE 0x10
615#define V_TX_INV_CLK 0x20
616#define V_TX_INV_DATA 0x40
617#define V_OUT_EN 0x80
618/* R_TX1 */
619#define V_INV_CLK 0x01
620#define V_EXCHG_DATA_LI 0x02
621#define V_AIS_OUT 0x04
622#define V_ATX 0x20
623#define V_NTRI 0x40
624#define V_AUTO_ERR_RES 0x80
625/* R_TX_FR0 */
626#define V_TRP_FAS 0x01
627#define V_TRP_NFAS 0x02
628#define V_TRP_RAL 0x04
629#define V_TRP_SA 0x08
630/* R_TX_FR1 */
631#define V_TX_FAS 0x01
632#define V_TX_NFAS 0x02
633#define V_TX_RAL 0x04
634#define V_TX_SA 0x08
635/* R_TX_FR2 */
636#define V_TX_MF 0x01
637#define V_TRP_SL0 0x02
638#define V_TX_SL0_RAM 0x04
639#define V_TX_E 0x10
640#define V_NEG_E 0x20
641#define V_XS12_ON 0x40
642#define V_XS15_ON 0x80
643/* R_RX_OFF */
644#define V_RX_SZ 0x01
645#define V_RX_INIT 0x04
646/* R_SYNC_OUT */
647#define V_SYNC_E1_RX 0x01
648#define V_IPATS0 0x20
649#define V_IPATS1 0x40
650#define V_IPATS2 0x80
651/* R_TX_OFF */
652#define V_TX_SZ 0x01
653#define V_TX_INIT 0x04
654/* R_SYNC_CTRL */
655#define V_EXT_CLK_SYNC 0x01
656#define V_SYNC_OFFS 0x02
657#define V_PCM_SYNC 0x04
658#define V_NEG_CLK 0x08
659#define V_HCLK 0x10
660/*
661#define V_JATT_AUTO_DEL 0x20
662#define V_JATT_AUTO 0x40
663*/
664#define V_JATT_OFF 0x80
665/* R_STATE */
666#define V_E1_STA 0x01
667#define V_ALT_FR_RX 0x40
668#define V_ALT_FR_TX 0x80
669/* R_SYNC_STA */
670#define V_RX_STA 0x01
671#define V_FR_SYNC_E1 0x04
672#define V_SIG_LOS 0x08
673#define V_MFA_STA 0x10
674#define V_AIS 0x40
675#define V_NO_MF_SYNC 0x80
676/* R_RX_SL0_0 */
677#define V_SI_FAS 0x01
678#define V_SI_NFAS 0x02
679#define V_A 0x04
680#define V_CRC_OK 0x08
681#define V_TX_E1 0x10
682#define V_TX_E2 0x20
683#define V_RX_E1 0x40
684#define V_RX_E2 0x80
685/* R_SLIP */
686#define V_SLIP_RX 0x01
687#define V_FOSLIP_RX 0x08
688#define V_SLIP_TX 0x10
689#define V_FOSLIP_TX 0x80
690
691/* chapter 6: PCM interface */
692/* R_PCM_MD0 */
693#define V_PCM_MD 0x01
694#define V_C4_POL 0x02
695#define V_F0_NEG 0x04
696#define V_F0_LEN 0x08
697#define V_PCM_ADDR 0x10
698/* R_SL_SEL0 */
699#define V_SL_SEL0 0x01
700#define V_SH_SEL0 0x80
701/* R_SL_SEL1 */
702#define V_SL_SEL1 0x01
703#define V_SH_SEL1 0x80
704/* R_SL_SEL2 */
705#define V_SL_SEL2 0x01
706#define V_SH_SEL2 0x80
707/* R_SL_SEL3 */
708#define V_SL_SEL3 0x01
709#define V_SH_SEL3 0x80
710/* R_SL_SEL4 */
711#define V_SL_SEL4 0x01
712#define V_SH_SEL4 0x80
713/* R_SL_SEL5 */
714#define V_SL_SEL5 0x01
715#define V_SH_SEL5 0x80
716/* R_SL_SEL6 */
717#define V_SL_SEL6 0x01
718#define V_SH_SEL6 0x80
719/* R_SL_SEL7 */
720#define V_SL_SEL7 0x01
721#define V_SH_SEL7 0x80
722/* R_PCM_MD1 */
723#define V_ODEC_CON 0x01
724#define V_PLL_ADJ 0x04
725#define V_PCM_DR 0x10
726#define V_PCM_LOOP 0x40
727/* R_PCM_MD2 */
728#define V_SYNC_PLL 0x02
729#define V_SYNC_SRC 0x04
730#define V_SYNC_OUT 0x08
731#define V_ICR_FR_TIME 0x40
732#define V_EN_PLL 0x80
733
734/* chapter 7: pulse width modulation */
735/* R_PWM_MD */
736#define V_EXT_IRQ_EN 0x08
737#define V_PWM0_MD 0x10
738#define V_PWM1_MD 0x40
739
740/* chapter 8: multiparty audio conferences */
741/* R_CONF_EN */
742#define V_CONF_EN 0x01
743#define V_ULAW 0x80
744/* A_CONF */
745#define V_CONF_NUM 0x01
746#define V_NOISE_SUPPR 0x08
747#define V_ATT_LEV 0x20
748#define V_CONF_SL 0x80
749/* R_CONF_OFLOW */
750#define V_CONF_OFLOW0 0x01
751#define V_CONF_OFLOW1 0x02
752#define V_CONF_OFLOW2 0x04
753#define V_CONF_OFLOW3 0x08
754#define V_CONF_OFLOW4 0x10
755#define V_CONF_OFLOW5 0x20
756#define V_CONF_OFLOW6 0x40
757#define V_CONF_OFLOW7 0x80
758
759/* chapter 9: DTMF contoller */
760/* R_DTMF0 */
761#define V_DTMF_EN 0x01
762#define V_HARM_SEL 0x02
763#define V_DTMF_RX_CH 0x04
764#define V_DTMF_STOP 0x08
765#define V_CHBL_SEL 0x10
766#define V_RST_DTMF 0x40
767#define V_ULAW_SEL 0x80
768
769/* chapter 10: BERT */
770/* R_BERT_WD_MD */
771#define V_PAT_SEQ 0x01
772#define V_BERT_ERR 0x08
773#define V_AUTO_WD_RES 0x20
774#define V_WD_RES 0x80
775/* R_BERT_STA */
776#define V_BERT_SYNC_SRC 0x01
777#define V_BERT_SYNC 0x10
778#define V_BERT_INV_DATA 0x20
779
780/* chapter 11: auxiliary interface */
781/* R_BRG_PCM_CFG */
782#define V_BRG_EN 0x01
783#define V_BRG_MD 0x02
784#define V_PCM_CLK 0x20
785#define V_ADDR_WRDLY 0x40
786/* R_BRG_CTRL */
787#define V_BRG_CS 0x01
788#define V_BRG_ADDR 0x08
789#define V_BRG_CS_SRC 0x80
790/* R_BRG_MD */
791#define V_BRG_MD0 0x01
792#define V_BRG_MD1 0x02
793#define V_BRG_MD2 0x04
794#define V_BRG_MD3 0x08
795#define V_BRG_MD4 0x10
796#define V_BRG_MD5 0x20
797#define V_BRG_MD6 0x40
798#define V_BRG_MD7 0x80
799/* R_BRG_TIM0 */
800#define V_BRG_TIM0_IDLE 0x01
801#define V_BRG_TIM0_CLK 0x10
802/* R_BRG_TIM1 */
803#define V_BRG_TIM1_IDLE 0x01
804#define V_BRG_TIM1_CLK 0x10
805/* R_BRG_TIM2 */
806#define V_BRG_TIM2_IDLE 0x01
807#define V_BRG_TIM2_CLK 0x10
808/* R_BRG_TIM3 */
809#define V_BRG_TIM3_IDLE 0x01
810#define V_BRG_TIM3_CLK 0x10
811/* R_BRG_TIM_SEL01 */
812#define V_BRG_WR_SEL0 0x01
813#define V_BRG_RD_SEL0 0x04
814#define V_BRG_WR_SEL1 0x10
815#define V_BRG_RD_SEL1 0x40
816/* R_BRG_TIM_SEL23 */
817#define V_BRG_WR_SEL2 0x01
818#define V_BRG_RD_SEL2 0x04
819#define V_BRG_WR_SEL3 0x10
820#define V_BRG_RD_SEL3 0x40
821/* R_BRG_TIM_SEL45 */
822#define V_BRG_WR_SEL4 0x01
823#define V_BRG_RD_SEL4 0x04
824#define V_BRG_WR_SEL5 0x10
825#define V_BRG_RD_SEL5 0x40
826/* R_BRG_TIM_SEL67 */
827#define V_BRG_WR_SEL6 0x01
828#define V_BRG_RD_SEL6 0x04
829#define V_BRG_WR_SEL7 0x10
830#define V_BRG_RD_SEL7 0x40
831
832/* chapter 12: clock, reset, interrupt, timer and watchdog */
833/* R_IRQMSK_MISC */
834#define V_STA_IRQMSK 0x01
835#define V_TI_IRQMSK 0x02
836#define V_PROC_IRQMSK 0x04
837#define V_DTMF_IRQMSK 0x08
838#define V_IRQ1S_MSK 0x10
839#define V_SA6_IRQMSK 0x20
840#define V_RX_EOMF_MSK 0x40
841#define V_TX_EOMF_MSK 0x80
842/* R_IRQ_CTRL */
843#define V_FIFO_IRQ 0x01
844#define V_GLOB_IRQ_EN 0x08
845#define V_IRQ_POL 0x10
846/* R_TI_WD */
847#define V_EV_TS 0x01
848#define V_WD_TS 0x10
849/* A_IRQ_MSK */
850#define V_IRQ 0x01
851#define V_BERT_EN 0x02
852#define V_MIX_IRQ 0x04
853/* R_IRQ_OVIEW */
854#define V_IRQ_FIFO_BL0 0x01
855#define V_IRQ_FIFO_BL1 0x02
856#define V_IRQ_FIFO_BL2 0x04
857#define V_IRQ_FIFO_BL3 0x08
858#define V_IRQ_FIFO_BL4 0x10
859#define V_IRQ_FIFO_BL5 0x20
860#define V_IRQ_FIFO_BL6 0x40
861#define V_IRQ_FIFO_BL7 0x80
862/* R_IRQ_MISC */
863#define V_STA_IRQ 0x01
864#define V_TI_IRQ 0x02
865#define V_IRQ_PROC 0x04
866#define V_DTMF_IRQ 0x08
867#define V_IRQ1S 0x10
868#define V_SA6_IRQ 0x20
869#define V_RX_EOMF 0x40
870#define V_TX_EOMF 0x80
871/* R_STATUS */
872#define V_BUSY 0x01
873#define V_PROC 0x02
874#define V_DTMF_STA 0x04
875#define V_LOST_STA 0x08
876#define V_SYNC_IN 0x10
877#define V_EXT_IRQSTA 0x20
878#define V_MISC_IRQSTA 0x40
879#define V_FR_IRQSTA 0x80
880/* R_IRQ_FIFO_BL0 */
881#define V_IRQ_FIFO0_TX 0x01
882#define V_IRQ_FIFO0_RX 0x02
883#define V_IRQ_FIFO1_TX 0x04
884#define V_IRQ_FIFO1_RX 0x08
885#define V_IRQ_FIFO2_TX 0x10
886#define V_IRQ_FIFO2_RX 0x20
887#define V_IRQ_FIFO3_TX 0x40
888#define V_IRQ_FIFO3_RX 0x80
889/* R_IRQ_FIFO_BL1 */
890#define V_IRQ_FIFO4_TX 0x01
891#define V_IRQ_FIFO4_RX 0x02
892#define V_IRQ_FIFO5_TX 0x04
893#define V_IRQ_FIFO5_RX 0x08
894#define V_IRQ_FIFO6_TX 0x10
895#define V_IRQ_FIFO6_RX 0x20
896#define V_IRQ_FIFO7_TX 0x40
897#define V_IRQ_FIFO7_RX 0x80
898/* R_IRQ_FIFO_BL2 */
899#define V_IRQ_FIFO8_TX 0x01
900#define V_IRQ_FIFO8_RX 0x02
901#define V_IRQ_FIFO9_TX 0x04
902#define V_IRQ_FIFO9_RX 0x08
903#define V_IRQ_FIFO10_TX 0x10
904#define V_IRQ_FIFO10_RX 0x20
905#define V_IRQ_FIFO11_TX 0x40
906#define V_IRQ_FIFO11_RX 0x80
907/* R_IRQ_FIFO_BL3 */
908#define V_IRQ_FIFO12_TX 0x01
909#define V_IRQ_FIFO12_RX 0x02
910#define V_IRQ_FIFO13_TX 0x04
911#define V_IRQ_FIFO13_RX 0x08
912#define V_IRQ_FIFO14_TX 0x10
913#define V_IRQ_FIFO14_RX 0x20
914#define V_IRQ_FIFO15_TX 0x40
915#define V_IRQ_FIFO15_RX 0x80
916/* R_IRQ_FIFO_BL4 */
917#define V_IRQ_FIFO16_TX 0x01
918#define V_IRQ_FIFO16_RX 0x02
919#define V_IRQ_FIFO17_TX 0x04
920#define V_IRQ_FIFO17_RX 0x08
921#define V_IRQ_FIFO18_TX 0x10
922#define V_IRQ_FIFO18_RX 0x20
923#define V_IRQ_FIFO19_TX 0x40
924#define V_IRQ_FIFO19_RX 0x80
925/* R_IRQ_FIFO_BL5 */
926#define V_IRQ_FIFO20_TX 0x01
927#define V_IRQ_FIFO20_RX 0x02
928#define V_IRQ_FIFO21_TX 0x04
929#define V_IRQ_FIFO21_RX 0x08
930#define V_IRQ_FIFO22_TX 0x10
931#define V_IRQ_FIFO22_RX 0x20
932#define V_IRQ_FIFO23_TX 0x40
933#define V_IRQ_FIFO23_RX 0x80
934/* R_IRQ_FIFO_BL6 */
935#define V_IRQ_FIFO24_TX 0x01
936#define V_IRQ_FIFO24_RX 0x02
937#define V_IRQ_FIFO25_TX 0x04
938#define V_IRQ_FIFO25_RX 0x08
939#define V_IRQ_FIFO26_TX 0x10
940#define V_IRQ_FIFO26_RX 0x20
941#define V_IRQ_FIFO27_TX 0x40
942#define V_IRQ_FIFO27_RX 0x80
943/* R_IRQ_FIFO_BL7 */
944#define V_IRQ_FIFO28_TX 0x01
945#define V_IRQ_FIFO28_RX 0x02
946#define V_IRQ_FIFO29_TX 0x04
947#define V_IRQ_FIFO29_RX 0x08
948#define V_IRQ_FIFO30_TX 0x10
949#define V_IRQ_FIFO30_RX 0x20
950#define V_IRQ_FIFO31_TX 0x40
951#define V_IRQ_FIFO31_RX 0x80
952
953/* chapter 13: general purpose I/O pins (GPIO) and input pins (GPI) */
954/* R_GPIO_OUT0 */
955#define V_GPIO_OUT0 0x01
956#define V_GPIO_OUT1 0x02
957#define V_GPIO_OUT2 0x04
958#define V_GPIO_OUT3 0x08
959#define V_GPIO_OUT4 0x10
960#define V_GPIO_OUT5 0x20
961#define V_GPIO_OUT6 0x40
962#define V_GPIO_OUT7 0x80
963/* R_GPIO_OUT1 */
964#define V_GPIO_OUT8 0x01
965#define V_GPIO_OUT9 0x02
966#define V_GPIO_OUT10 0x04
967#define V_GPIO_OUT11 0x08
968#define V_GPIO_OUT12 0x10
969#define V_GPIO_OUT13 0x20
970#define V_GPIO_OUT14 0x40
971#define V_GPIO_OUT15 0x80
972/* R_GPIO_EN0 */
973#define V_GPIO_EN0 0x01
974#define V_GPIO_EN1 0x02
975#define V_GPIO_EN2 0x04
976#define V_GPIO_EN3 0x08
977#define V_GPIO_EN4 0x10
978#define V_GPIO_EN5 0x20
979#define V_GPIO_EN6 0x40
980#define V_GPIO_EN7 0x80
981/* R_GPIO_EN1 */
982#define V_GPIO_EN8 0x01
983#define V_GPIO_EN9 0x02
984#define V_GPIO_EN10 0x04
985#define V_GPIO_EN11 0x08
986#define V_GPIO_EN12 0x10
987#define V_GPIO_EN13 0x20
988#define V_GPIO_EN14 0x40
989#define V_GPIO_EN15 0x80
990/* R_GPIO_SEL */
991#define V_GPIO_SEL0 0x01
992#define V_GPIO_SEL1 0x02
993#define V_GPIO_SEL2 0x04
994#define V_GPIO_SEL3 0x08
995#define V_GPIO_SEL4 0x10
996#define V_GPIO_SEL5 0x20
997#define V_GPIO_SEL6 0x40
998#define V_GPIO_SEL7 0x80
999/* R_GPIO_IN0 */
1000#define V_GPIO_IN0 0x01
1001#define V_GPIO_IN1 0x02
1002#define V_GPIO_IN2 0x04
1003#define V_GPIO_IN3 0x08
1004#define V_GPIO_IN4 0x10
1005#define V_GPIO_IN5 0x20
1006#define V_GPIO_IN6 0x40
1007#define V_GPIO_IN7 0x80
1008/* R_GPIO_IN1 */
1009#define V_GPIO_IN8 0x01
1010#define V_GPIO_IN9 0x02
1011#define V_GPIO_IN10 0x04
1012#define V_GPIO_IN11 0x08
1013#define V_GPIO_IN12 0x10
1014#define V_GPIO_IN13 0x20
1015#define V_GPIO_IN14 0x40
1016#define V_GPIO_IN15 0x80
1017/* R_GPI_IN0 */
1018#define V_GPI_IN0 0x01
1019#define V_GPI_IN1 0x02
1020#define V_GPI_IN2 0x04
1021#define V_GPI_IN3 0x08
1022#define V_GPI_IN4 0x10
1023#define V_GPI_IN5 0x20
1024#define V_GPI_IN6 0x40
1025#define V_GPI_IN7 0x80
1026/* R_GPI_IN1 */
1027#define V_GPI_IN8 0x01
1028#define V_GPI_IN9 0x02
1029#define V_GPI_IN10 0x04
1030#define V_GPI_IN11 0x08
1031#define V_GPI_IN12 0x10
1032#define V_GPI_IN13 0x20
1033#define V_GPI_IN14 0x40
1034#define V_GPI_IN15 0x80
1035/* R_GPI_IN2 */
1036#define V_GPI_IN16 0x01
1037#define V_GPI_IN17 0x02
1038#define V_GPI_IN18 0x04
1039#define V_GPI_IN19 0x08
1040#define V_GPI_IN20 0x10
1041#define V_GPI_IN21 0x20
1042#define V_GPI_IN22 0x40
1043#define V_GPI_IN23 0x80
1044/* R_GPI_IN3 */
1045#define V_GPI_IN24 0x01
1046#define V_GPI_IN25 0x02
1047#define V_GPI_IN26 0x04
1048#define V_GPI_IN27 0x08
1049#define V_GPI_IN28 0x10
1050#define V_GPI_IN29 0x20
1051#define V_GPI_IN30 0x40
1052#define V_GPI_IN31 0x80
1053
1054/* map of all registers, used for debugging */
1055
1056#ifdef HFC_REGISTER_DEBUG
1057struct hfc_register_names {
1058 char *name;
1059 u_char reg;
1060} hfc_register_names[] = {
1061 /* write registers */
1062 {"R_CIRM", 0x00},
1063 {"R_CTRL", 0x01},
1064 {"R_BRG_PCM_CFG ", 0x02},
1065 {"R_RAM_ADDR0", 0x08},
1066 {"R_RAM_ADDR1", 0x09},
1067 {"R_RAM_ADDR2", 0x0A},
1068 {"R_FIRST_FIFO", 0x0B},
1069 {"R_RAM_SZ", 0x0C},
1070 {"R_FIFO_MD", 0x0D},
1071 {"R_INC_RES_FIFO", 0x0E},
1072 {"R_FIFO / R_FSM_IDX", 0x0F},
1073 {"R_SLOT", 0x10},
1074 {"R_IRQMSK_MISC", 0x11},
1075 {"R_SCI_MSK", 0x12},
1076 {"R_IRQ_CTRL", 0x13},
1077 {"R_PCM_MD0", 0x14},
1078 {"R_0x15", 0x15},
1079 {"R_ST_SEL", 0x16},
1080 {"R_ST_SYNC", 0x17},
1081 {"R_CONF_EN", 0x18},
1082 {"R_TI_WD", 0x1A},
1083 {"R_BERT_WD_MD", 0x1B},
1084 {"R_DTMF", 0x1C},
1085 {"R_DTMF_N", 0x1D},
1086 {"R_E1_XX_STA", 0x20},
1087 {"R_LOS0", 0x22},
1088 {"R_LOS1", 0x23},
1089 {"R_RX0", 0x24},
1090 {"R_RX_FR0", 0x25},
1091 {"R_RX_FR1", 0x26},
1092 {"R_TX0", 0x28},
1093 {"R_TX1", 0x29},
1094 {"R_TX_FR0", 0x2C},
1095 {"R_TX_FR1", 0x2D},
1096 {"R_TX_FR2", 0x2E},
1097 {"R_JATT_ATT", 0x2F},
1098 {"A_ST_xx_STA/R_RX_OFF", 0x30},
1099 {"A_ST_CTRL0/R_SYNC_OUT", 0x31},
1100 {"A_ST_CTRL1", 0x32},
1101 {"A_ST_CTRL2", 0x33},
1102 {"A_ST_SQ_WR", 0x34},
1103 {"R_TX_OFF", 0x34},
1104 {"R_SYNC_CTRL", 0x35},
1105 {"A_ST_CLK_DLY", 0x37},
1106 {"R_PWM0", 0x38},
1107 {"R_PWM1", 0x39},
1108 {"A_ST_B1_TX", 0x3C},
1109 {"A_ST_B2_TX", 0x3D},
1110 {"A_ST_D_TX", 0x3E},
1111 {"R_GPIO_OUT0", 0x40},
1112 {"R_GPIO_OUT1", 0x41},
1113 {"R_GPIO_EN0", 0x42},
1114 {"R_GPIO_EN1", 0x43},
1115 {"R_GPIO_SEL", 0x44},
1116 {"R_BRG_CTRL", 0x45},
1117 {"R_PWM_MD", 0x46},
1118 {"R_BRG_MD", 0x47},
1119 {"R_BRG_TIM0", 0x48},
1120 {"R_BRG_TIM1", 0x49},
1121 {"R_BRG_TIM2", 0x4A},
1122 {"R_BRG_TIM3", 0x4B},
1123 {"R_BRG_TIM_SEL01", 0x4C},
1124 {"R_BRG_TIM_SEL23", 0x4D},
1125 {"R_BRG_TIM_SEL45", 0x4E},
1126 {"R_BRG_TIM_SEL67", 0x4F},
1127 {"A_FIFO_DATA0-2", 0x80},
1128 {"A_FIFO_DATA0-2_NOINC", 0x84},
1129 {"R_RAM_DATA", 0xC0},
1130 {"A_SL_CFG", 0xD0},
1131 {"A_CONF", 0xD1},
1132 {"A_CH_MSK", 0xF4},
1133 {"A_CON_HDLC", 0xFA},
1134 {"A_SUBCH_CFG", 0xFB},
1135 {"A_CHANNEL", 0xFC},
1136 {"A_FIFO_SEQ", 0xFD},
1137 {"A_IRQ_MSK", 0xFF},
1138 {NULL, 0},
1139
1140 /* read registers */
1141 {"A_Z1", 0x04},
1142 {"A_Z1H", 0x05},
1143 {"A_Z2", 0x06},
1144 {"A_Z2H", 0x07},
1145 {"A_F1", 0x0C},
1146 {"A_F2", 0x0D},
1147 {"R_IRQ_OVIEW", 0x10},
1148 {"R_IRQ_MISC", 0x11},
1149 {"R_IRQ_STATECH", 0x12},
1150 {"R_CONF_OFLOW", 0x14},
1151 {"R_RAM_USE", 0x15},
1152 {"R_CHIP_ID", 0x16},
1153 {"R_BERT_STA", 0x17},
1154 {"R_F0_CNTL", 0x18},
1155 {"R_F0_CNTH", 0x19},
1156 {"R_BERT_ECL", 0x1A},
1157 {"R_BERT_ECH", 0x1B},
1158 {"R_STATUS", 0x1C},
1159 {"R_CHIP_RV", 0x1F},
1160 {"R_STATE", 0x20},
1161 {"R_SYNC_STA", 0x24},
1162 {"R_RX_SL0_0", 0x25},
1163 {"R_RX_SL0_1", 0x26},
1164 {"R_RX_SL0_2", 0x27},
1165 {"R_JATT_DIR", 0x2b},
1166 {"R_SLIP", 0x2c},
1167 {"A_ST_RD_STA", 0x30},
1168 {"R_FAS_ECL", 0x30},
1169 {"R_FAS_ECH", 0x31},
1170 {"R_VIO_ECL", 0x32},
1171 {"R_VIO_ECH", 0x33},
1172 {"R_CRC_ECL / A_ST_SQ_RD", 0x34},
1173 {"R_CRC_ECH", 0x35},
1174 {"R_E_ECL", 0x36},
1175 {"R_E_ECH", 0x37},
1176 {"R_SA6_SA13_ECL", 0x38},
1177 {"R_SA6_SA13_ECH", 0x39},
1178 {"R_SA6_SA23_ECL", 0x3A},
1179 {"R_SA6_SA23_ECH", 0x3B},
1180 {"A_ST_B1_RX", 0x3C},
1181 {"A_ST_B2_RX", 0x3D},
1182 {"A_ST_D_RX", 0x3E},
1183 {"A_ST_E_RX", 0x3F},
1184 {"R_GPIO_IN0", 0x40},
1185 {"R_GPIO_IN1", 0x41},
1186 {"R_GPI_IN0", 0x44},
1187 {"R_GPI_IN1", 0x45},
1188 {"R_GPI_IN2", 0x46},
1189 {"R_GPI_IN3", 0x47},
1190 {"A_FIFO_DATA0-2", 0x80},
1191 {"A_FIFO_DATA0-2_NOINC", 0x84},
1192 {"R_INT_DATA", 0x88},
1193 {"R_RAM_DATA", 0xC0},
1194 {"R_IRQ_FIFO_BL0", 0xC8},
1195 {"R_IRQ_FIFO_BL1", 0xC9},
1196 {"R_IRQ_FIFO_BL2", 0xCA},
1197 {"R_IRQ_FIFO_BL3", 0xCB},
1198 {"R_IRQ_FIFO_BL4", 0xCC},
1199 {"R_IRQ_FIFO_BL5", 0xCD},
1200 {"R_IRQ_FIFO_BL6", 0xCE},
1201 {"R_IRQ_FIFO_BL7", 0xCF},
1202};
1203#endif /* HFC_REGISTER_DEBUG */
1204
diff --git a/drivers/isdn/hardware/mISDN/hfc_pci.h b/drivers/isdn/hardware/mISDN/hfc_pci.h
new file mode 100644
index 000000000000..fd2c9be6d849
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfc_pci.h
@@ -0,0 +1,228 @@
1/*
2 * specific defines for CCD's HFC 2BDS0 PCI chips
3 *
4 * Author Werner Cornelius (werner@isdn4linux.de)
5 *
6 * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de)
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, or (at your option)
11 * any later version.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24/*
25 * thresholds for transparent B-channel mode
26 * change mask and threshold simultaneously
27 */
28#define HFCPCI_BTRANS_THRESHOLD 128
29#define HFCPCI_BTRANS_MAX 256
30#define HFCPCI_BTRANS_THRESMASK 0x00
31
32/* defines for PCI config */
33#define PCI_ENA_MEMIO 0x02
34#define PCI_ENA_MASTER 0x04
35
36/* GCI/IOM bus monitor registers */
37#define HCFPCI_C_I 0x08
38#define HFCPCI_TRxR 0x0C
39#define HFCPCI_MON1_D 0x28
40#define HFCPCI_MON2_D 0x2C
41
42/* GCI/IOM bus timeslot registers */
43#define HFCPCI_B1_SSL 0x80
44#define HFCPCI_B2_SSL 0x84
45#define HFCPCI_AUX1_SSL 0x88
46#define HFCPCI_AUX2_SSL 0x8C
47#define HFCPCI_B1_RSL 0x90
48#define HFCPCI_B2_RSL 0x94
49#define HFCPCI_AUX1_RSL 0x98
50#define HFCPCI_AUX2_RSL 0x9C
51
52/* GCI/IOM bus data registers */
53#define HFCPCI_B1_D 0xA0
54#define HFCPCI_B2_D 0xA4
55#define HFCPCI_AUX1_D 0xA8
56#define HFCPCI_AUX2_D 0xAC
57
58/* GCI/IOM bus configuration registers */
59#define HFCPCI_MST_EMOD 0xB4
60#define HFCPCI_MST_MODE 0xB8
61#define HFCPCI_CONNECT 0xBC
62
63
64/* Interrupt and status registers */
65#define HFCPCI_FIFO_EN 0x44
66#define HFCPCI_TRM 0x48
67#define HFCPCI_B_MODE 0x4C
68#define HFCPCI_CHIP_ID 0x58
69#define HFCPCI_CIRM 0x60
70#define HFCPCI_CTMT 0x64
71#define HFCPCI_INT_M1 0x68
72#define HFCPCI_INT_M2 0x6C
73#define HFCPCI_INT_S1 0x78
74#define HFCPCI_INT_S2 0x7C
75#define HFCPCI_STATUS 0x70
76
77/* S/T section registers */
78#define HFCPCI_STATES 0xC0
79#define HFCPCI_SCTRL 0xC4
80#define HFCPCI_SCTRL_E 0xC8
81#define HFCPCI_SCTRL_R 0xCC
82#define HFCPCI_SQ 0xD0
83#define HFCPCI_CLKDEL 0xDC
84#define HFCPCI_B1_REC 0xF0
85#define HFCPCI_B1_SEND 0xF0
86#define HFCPCI_B2_REC 0xF4
87#define HFCPCI_B2_SEND 0xF4
88#define HFCPCI_D_REC 0xF8
89#define HFCPCI_D_SEND 0xF8
90#define HFCPCI_E_REC 0xFC
91
92
93/* bits in status register (READ) */
94#define HFCPCI_PCI_PROC 0x02
95#define HFCPCI_NBUSY 0x04
96#define HFCPCI_TIMER_ELAP 0x10
97#define HFCPCI_STATINT 0x20
98#define HFCPCI_FRAMEINT 0x40
99#define HFCPCI_ANYINT 0x80
100
101/* bits in CTMT (Write) */
102#define HFCPCI_CLTIMER 0x80
103#define HFCPCI_TIM3_125 0x04
104#define HFCPCI_TIM25 0x10
105#define HFCPCI_TIM50 0x14
106#define HFCPCI_TIM400 0x18
107#define HFCPCI_TIM800 0x1C
108#define HFCPCI_AUTO_TIMER 0x20
109#define HFCPCI_TRANSB2 0x02
110#define HFCPCI_TRANSB1 0x01
111
112/* bits in CIRM (Write) */
113#define HFCPCI_AUX_MSK 0x07
114#define HFCPCI_RESET 0x08
115#define HFCPCI_B1_REV 0x40
116#define HFCPCI_B2_REV 0x80
117
118/* bits in INT_M1 and INT_S1 */
119#define HFCPCI_INTS_B1TRANS 0x01
120#define HFCPCI_INTS_B2TRANS 0x02
121#define HFCPCI_INTS_DTRANS 0x04
122#define HFCPCI_INTS_B1REC 0x08
123#define HFCPCI_INTS_B2REC 0x10
124#define HFCPCI_INTS_DREC 0x20
125#define HFCPCI_INTS_L1STATE 0x40
126#define HFCPCI_INTS_TIMER 0x80
127
128/* bits in INT_M2 */
129#define HFCPCI_PROC_TRANS 0x01
130#define HFCPCI_GCI_I_CHG 0x02
131#define HFCPCI_GCI_MON_REC 0x04
132#define HFCPCI_IRQ_ENABLE 0x08
133#define HFCPCI_PMESEL 0x80
134
135/* bits in STATES */
136#define HFCPCI_STATE_MSK 0x0F
137#define HFCPCI_LOAD_STATE 0x10
138#define HFCPCI_ACTIVATE 0x20
139#define HFCPCI_DO_ACTION 0x40
140#define HFCPCI_NT_G2_G3 0x80
141
142/* bits in HFCD_MST_MODE */
143#define HFCPCI_MASTER 0x01
144#define HFCPCI_SLAVE 0x00
145#define HFCPCI_F0IO_POSITIV 0x02
146#define HFCPCI_F0_NEGATIV 0x04
147#define HFCPCI_F0_2C4 0x08
148/* remaining bits are for codecs control */
149
150/* bits in HFCD_SCTRL */
151#define SCTRL_B1_ENA 0x01
152#define SCTRL_B2_ENA 0x02
153#define SCTRL_MODE_TE 0x00
154#define SCTRL_MODE_NT 0x04
155#define SCTRL_LOW_PRIO 0x08
156#define SCTRL_SQ_ENA 0x10
157#define SCTRL_TEST 0x20
158#define SCTRL_NONE_CAP 0x40
159#define SCTRL_PWR_DOWN 0x80
160
161/* bits in SCTRL_E */
162#define HFCPCI_AUTO_AWAKE 0x01
163#define HFCPCI_DBIT_1 0x04
164#define HFCPCI_IGNORE_COL 0x08
165#define HFCPCI_CHG_B1_B2 0x80
166
167/* bits in FIFO_EN register */
168#define HFCPCI_FIFOEN_B1 0x03
169#define HFCPCI_FIFOEN_B2 0x0C
170#define HFCPCI_FIFOEN_DTX 0x10
171#define HFCPCI_FIFOEN_B1TX 0x01
172#define HFCPCI_FIFOEN_B1RX 0x02
173#define HFCPCI_FIFOEN_B2TX 0x04
174#define HFCPCI_FIFOEN_B2RX 0x08
175
176
177/* definitions of fifo memory area */
178#define MAX_D_FRAMES 15
179#define MAX_B_FRAMES 31
180#define B_SUB_VAL 0x200
181#define B_FIFO_SIZE (0x2000 - B_SUB_VAL)
182#define D_FIFO_SIZE 512
183#define D_FREG_MASK 0xF
184
185struct zt {
186 unsigned short z1; /* Z1 pointer 16 Bit */
187 unsigned short z2; /* Z2 pointer 16 Bit */
188};
189
190struct dfifo {
191 u_char data[D_FIFO_SIZE]; /* FIFO data space */
192 u_char fill1[0x20A0-D_FIFO_SIZE]; /* reserved, do not use */
193 u_char f1, f2; /* f pointers */
194 u_char fill2[0x20C0-0x20A2]; /* reserved, do not use */
195 /* mask index with D_FREG_MASK for access */
196 struct zt za[MAX_D_FRAMES+1];
197 u_char fill3[0x4000-0x2100]; /* align 16K */
198};
199
200struct bzfifo {
201 struct zt za[MAX_B_FRAMES+1]; /* only range 0x0..0x1F allowed */
202 u_char f1, f2; /* f pointers */
203 u_char fill[0x2100-0x2082]; /* alignment */
204};
205
206
207union fifo_area {
208 struct {
209 struct dfifo d_tx; /* D-send channel */
210 struct dfifo d_rx; /* D-receive channel */
211 } d_chan;
212 struct {
213 u_char fill1[0x200];
214 u_char txdat_b1[B_FIFO_SIZE];
215 struct bzfifo txbz_b1;
216 struct bzfifo txbz_b2;
217 u_char txdat_b2[B_FIFO_SIZE];
218 u_char fill2[D_FIFO_SIZE];
219 u_char rxdat_b1[B_FIFO_SIZE];
220 struct bzfifo rxbz_b1;
221 struct bzfifo rxbz_b2;
222 u_char rxdat_b2[B_FIFO_SIZE];
223 } b_chans;
224 u_char fill[32768];
225};
226
227#define Write_hfc(a, b, c) (writeb(c, (a->hw.pci_io)+b))
228#define Read_hfc(a, b) (readb((a->hw.pci_io)+b))
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
new file mode 100644
index 000000000000..2649ea55a9e8
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -0,0 +1,5320 @@
1/*
2 * hfcmulti.c low level driver for hfc-4s/hfc-8s/hfc-e1 based cards
3 *
4 * Author Andreas Eversberg (jolly@eversberg.eu)
5 * ported to mqueue mechanism:
6 * Peter Sprenger (sprengermoving-bytes.de)
7 *
8 * inspired by existing hfc-pci driver:
9 * Copyright 1999 by Werner Cornelius (werner@isdn-development.de)
10 * Copyright 2008 by Karsten Keil (kkeil@suse.de)
11 * Copyright 2008 by Andreas Eversberg (jolly@eversberg.eu)
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 *
28 * Thanks to Cologne Chip AG for this great controller!
29 */
30
31/*
32 * module parameters:
33 * type:
34 * By default (0), the card is automatically detected.
35 * Or use the following combinations:
36 * Bit 0-7 = 0x00001 = HFC-E1 (1 port)
37 * or Bit 0-7 = 0x00004 = HFC-4S (4 ports)
38 * or Bit 0-7 = 0x00008 = HFC-8S (8 ports)
39 * Bit 8 = 0x00100 = uLaw (instead of aLaw)
40 * Bit 9 = 0x00200 = Disable DTMF detect on all B-channels via hardware
41 * Bit 10 = spare
42 * Bit 11 = 0x00800 = Force PCM bus into slave mode. (otherwhise auto)
43 * or Bit 12 = 0x01000 = Force PCM bus into master mode. (otherwhise auto)
44 * Bit 13 = spare
45 * Bit 14 = 0x04000 = Use external ram (128K)
46 * Bit 15 = 0x08000 = Use external ram (512K)
47 * Bit 16 = 0x10000 = Use 64 timeslots instead of 32
48 * or Bit 17 = 0x20000 = Use 128 timeslots instead of anything else
49 * Bit 18 = spare
50 * Bit 19 = 0x80000 = Send the Watchdog a Signal (Dual E1 with Watchdog)
51 * (all other bits are reserved and shall be 0)
52 * example: 0x20204 one HFC-4S with dtmf detection and 128 timeslots on PCM
53 * bus (PCM master)
54 *
55 * port: (optional or required for all ports on all installed cards)
56 * HFC-4S/HFC-8S only bits:
57 * Bit 0 = 0x001 = Use master clock for this S/T interface
58 * (ony once per chip).
59 * Bit 1 = 0x002 = transmitter line setup (non capacitive mode)
60 * Don't use this unless you know what you are doing!
61 * Bit 2 = 0x004 = Disable E-channel. (No E-channel processing)
62 * example: 0x0001,0x0000,0x0000,0x0000 one HFC-4S with master clock
63 * received from port 1
64 *
65 * HFC-E1 only bits:
66 * Bit 0 = 0x0001 = interface: 0=copper, 1=optical
67 * Bit 1 = 0x0002 = reserved (later for 32 B-channels transparent mode)
68 * Bit 2 = 0x0004 = Report LOS
69 * Bit 3 = 0x0008 = Report AIS
70 * Bit 4 = 0x0010 = Report SLIP
71 * Bit 5 = 0x0020 = Report RDI
72 * Bit 8 = 0x0100 = Turn off CRC-4 Multiframe Mode, use double frame
73 * mode instead.
74 * Bit 9 = 0x0200 = Force get clock from interface, even in NT mode.
75 * or Bit 10 = 0x0400 = Force put clock to interface, even in TE mode.
76 * Bit 11 = 0x0800 = Use direct RX clock for PCM sync rather than PLL.
77 * (E1 only)
78 * Bit 12-13 = 0xX000 = elastic jitter buffer (1-3), Set both bits to 0
79 * for default.
80 * (all other bits are reserved and shall be 0)
81 *
82 * debug:
83 * NOTE: only one debug value must be given for all cards
84 * enable debugging (see hfc_multi.h for debug options)
85 *
86 * poll:
87 * NOTE: only one poll value must be given for all cards
88 * Give the number of samples for each fifo process.
89 * By default 128 is used. Decrease to reduce delay, increase to
90 * reduce cpu load. If unsure, don't mess with it!
91 * Valid is 8, 16, 32, 64, 128, 256.
92 *
93 * pcm:
94 * NOTE: only one pcm value must be given for every card.
95 * The PCM bus id tells the mISDNdsp module about the connected PCM bus.
96 * By default (0), the PCM bus id is 100 for the card that is PCM master.
97 * If multiple cards are PCM master (because they are not interconnected),
98 * each card with PCM master will have increasing PCM id.
99 * All PCM busses with the same ID are expected to be connected and have
100 * common time slots slots.
101 * Only one chip of the PCM bus must be master, the others slave.
102 * -1 means no support of PCM bus not even.
103 * Omit this value, if all cards are interconnected or none is connected.
104 * If unsure, don't give this parameter.
105 *
106 * dslot:
107 * NOTE: only one poll value must be given for every card.
108 * Also this value must be given for non-E1 cards. If omitted, the E1
109 * card has D-channel on time slot 16, which is default.
110 * If 1..15 or 17..31, an alternate time slot is used for D-channel.
111 * In this case, the application must be able to handle this.
112 * If -1 is given, the D-channel is disabled and all 31 slots can be used
113 * for B-channel. (only for specific applications)
114 * If you don't know how to use it, you don't need it!
115 *
116 * iomode:
117 * NOTE: only one mode value must be given for every card.
118 * -> See hfc_multi.h for HFC_IO_MODE_* values
119 * By default, the IO mode is pci memory IO (MEMIO).
120 * Some cards requre specific IO mode, so it cannot be changed.
121 * It may be usefull to set IO mode to register io (REGIO) to solve
122 * PCI bridge problems.
123 * If unsure, don't give this parameter.
124 *
125 * clockdelay_nt:
126 * NOTE: only one clockdelay_nt value must be given once for all cards.
127 * Give the value of the clock control register (A_ST_CLK_DLY)
128 * of the S/T interfaces in NT mode.
129 * This register is needed for the TBR3 certification, so don't change it.
130 *
131 * clockdelay_te:
132 * NOTE: only one clockdelay_te value must be given once
133 * Give the value of the clock control register (A_ST_CLK_DLY)
134 * of the S/T interfaces in TE mode.
135 * This register is needed for the TBR3 certification, so don't change it.
136 */
137
138/*
139 * debug register access (never use this, it will flood your system log)
140 * #define HFC_REGISTER_DEBUG
141 */
142
143static const char *hfcmulti_revision = "2.00";
144
145#include <linux/module.h>
146#include <linux/pci.h>
147#include <linux/delay.h>
148#include <linux/mISDNhw.h>
149#include <linux/mISDNdsp.h>
150
151/*
152#define IRQCOUNT_DEBUG
153#define IRQ_DEBUG
154*/
155
156#include "hfc_multi.h"
157#ifdef ECHOPREP
158#include "gaintab.h"
159#endif
160
161#define MAX_CARDS 8
162#define MAX_PORTS (8 * MAX_CARDS)
163
164static LIST_HEAD(HFClist);
165static spinlock_t HFClock; /* global hfc list lock */
166
167static void ph_state_change(struct dchannel *);
168static void (*hfc_interrupt)(void);
169static void (*register_interrupt)(void);
170static int (*unregister_interrupt)(void);
171static int interrupt_registered;
172
173static struct hfc_multi *syncmaster;
174int plxsd_master; /* if we have a master card (yet) */
175static spinlock_t plx_lock; /* may not acquire other lock inside */
176EXPORT_SYMBOL(plx_lock);
177
178#define TYP_E1 1
179#define TYP_4S 4
180#define TYP_8S 8
181
182static int poll_timer = 6; /* default = 128 samples = 16ms */
183/* number of POLL_TIMER interrupts for G2 timeout (ca 1s) */
184static int nt_t1_count[] = { 3840, 1920, 960, 480, 240, 120, 60, 30 };
185#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
186#define CLKDEL_NT 0x6c /* CLKDEL in NT mode
187 (0x60 MUST be included!) */
188static u_char silence = 0xff; /* silence by LAW */
189
190#define DIP_4S 0x1 /* DIP Switches for Beronet 1S/2S/4S cards */
191#define DIP_8S 0x2 /* DIP Switches for Beronet 8S+ cards */
192#define DIP_E1 0x3 /* DIP Switches for Beronet E1 cards */
193
194/*
195 * module stuff
196 */
197
198static uint type[MAX_CARDS];
199static uint pcm[MAX_CARDS];
200static uint dslot[MAX_CARDS];
201static uint iomode[MAX_CARDS];
202static uint port[MAX_PORTS];
203static uint debug;
204static uint poll;
205static uint timer;
206static uint clockdelay_te = CLKDEL_TE;
207static uint clockdelay_nt = CLKDEL_NT;
208
209static int HFC_cnt, Port_cnt, PCM_cnt = 99;
210
211MODULE_AUTHOR("Andreas Eversberg");
212MODULE_LICENSE("GPL");
213module_param(debug, uint, S_IRUGO | S_IWUSR);
214module_param(poll, uint, S_IRUGO | S_IWUSR);
215module_param(timer, uint, S_IRUGO | S_IWUSR);
216module_param(clockdelay_te, uint, S_IRUGO | S_IWUSR);
217module_param(clockdelay_nt, uint, S_IRUGO | S_IWUSR);
218module_param_array(type, uint, NULL, S_IRUGO | S_IWUSR);
219module_param_array(pcm, uint, NULL, S_IRUGO | S_IWUSR);
220module_param_array(dslot, uint, NULL, S_IRUGO | S_IWUSR);
221module_param_array(iomode, uint, NULL, S_IRUGO | S_IWUSR);
222module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR);
223
224#ifdef HFC_REGISTER_DEBUG
225#define HFC_outb(hc, reg, val) \
226 (hc->HFC_outb(hc, reg, val, __func__, __LINE__))
227#define HFC_outb_nodebug(hc, reg, val) \
228 (hc->HFC_outb_nodebug(hc, reg, val, __func__, __LINE__))
229#define HFC_inb(hc, reg) \
230 (hc->HFC_inb(hc, reg, __func__, __LINE__))
231#define HFC_inb_nodebug(hc, reg) \
232 (hc->HFC_inb_nodebug(hc, reg, __func__, __LINE__))
233#define HFC_inw(hc, reg) \
234 (hc->HFC_inw(hc, reg, __func__, __LINE__))
235#define HFC_inw_nodebug(hc, reg) \
236 (hc->HFC_inw_nodebug(hc, reg, __func__, __LINE__))
237#define HFC_wait(hc) \
238 (hc->HFC_wait(hc, __func__, __LINE__))
239#define HFC_wait_nodebug(hc) \
240 (hc->HFC_wait_nodebug(hc, __func__, __LINE__))
241#else
242#define HFC_outb(hc, reg, val) (hc->HFC_outb(hc, reg, val))
243#define HFC_outb_nodebug(hc, reg, val) (hc->HFC_outb_nodebug(hc, reg, val))
244#define HFC_inb(hc, reg) (hc->HFC_inb(hc, reg))
245#define HFC_inb_nodebug(hc, reg) (hc->HFC_inb_nodebug(hc, reg))
246#define HFC_inw(hc, reg) (hc->HFC_inw(hc, reg))
247#define HFC_inw_nodebug(hc, reg) (hc->HFC_inw_nodebug(hc, reg))
248#define HFC_wait(hc) (hc->HFC_wait(hc))
249#define HFC_wait_nodebug(hc) (hc->HFC_wait_nodebug(hc))
250#endif
251
252/* HFC_IO_MODE_PCIMEM */
253static void
254#ifdef HFC_REGISTER_DEBUG
255HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val,
256 const char *function, int line)
257#else
258HFC_outb_pcimem(struct hfc_multi *hc, u_char reg, u_char val)
259#endif
260{
261 writeb(val, (hc->pci_membase)+reg);
262}
263static u_char
264#ifdef HFC_REGISTER_DEBUG
265HFC_inb_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line)
266#else
267HFC_inb_pcimem(struct hfc_multi *hc, u_char reg)
268#endif
269{
270 return readb((hc->pci_membase)+reg);
271}
272static u_short
273#ifdef HFC_REGISTER_DEBUG
274HFC_inw_pcimem(struct hfc_multi *hc, u_char reg, const char *function, int line)
275#else
276HFC_inw_pcimem(struct hfc_multi *hc, u_char reg)
277#endif
278{
279 return readw((hc->pci_membase)+reg);
280}
281static void
282#ifdef HFC_REGISTER_DEBUG
283HFC_wait_pcimem(struct hfc_multi *hc, const char *function, int line)
284#else
285HFC_wait_pcimem(struct hfc_multi *hc)
286#endif
287{
288 while (readb((hc->pci_membase)+R_STATUS) & V_BUSY);
289}
290
291/* HFC_IO_MODE_REGIO */
292static void
293#ifdef HFC_REGISTER_DEBUG
294HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val,
295 const char *function, int line)
296#else
297HFC_outb_regio(struct hfc_multi *hc, u_char reg, u_char val)
298#endif
299{
300 outb(reg, (hc->pci_iobase)+4);
301 outb(val, hc->pci_iobase);
302}
303static u_char
304#ifdef HFC_REGISTER_DEBUG
305HFC_inb_regio(struct hfc_multi *hc, u_char reg, const char *function, int line)
306#else
307HFC_inb_regio(struct hfc_multi *hc, u_char reg)
308#endif
309{
310 outb(reg, (hc->pci_iobase)+4);
311 return inb(hc->pci_iobase);
312}
313static u_short
314#ifdef HFC_REGISTER_DEBUG
315HFC_inw_regio(struct hfc_multi *hc, u_char reg, const char *function, int line)
316#else
317HFC_inw_regio(struct hfc_multi *hc, u_char reg)
318#endif
319{
320 outb(reg, (hc->pci_iobase)+4);
321 return inw(hc->pci_iobase);
322}
323static void
324#ifdef HFC_REGISTER_DEBUG
325HFC_wait_regio(struct hfc_multi *hc, const char *function, int line)
326#else
327HFC_wait_regio(struct hfc_multi *hc)
328#endif
329{
330 outb(R_STATUS, (hc->pci_iobase)+4);
331 while (inb(hc->pci_iobase) & V_BUSY);
332}
333
334#ifdef HFC_REGISTER_DEBUG
335static void
336HFC_outb_debug(struct hfc_multi *hc, u_char reg, u_char val,
337 const char *function, int line)
338{
339 char regname[256] = "", bits[9] = "xxxxxxxx";
340 int i;
341
342 i = -1;
343 while (hfc_register_names[++i].name) {
344 if (hfc_register_names[i].reg == reg)
345 strcat(regname, hfc_register_names[i].name);
346 }
347 if (regname[0] == '\0')
348 strcpy(regname, "register");
349
350 bits[7] = '0'+(!!(val&1));
351 bits[6] = '0'+(!!(val&2));
352 bits[5] = '0'+(!!(val&4));
353 bits[4] = '0'+(!!(val&8));
354 bits[3] = '0'+(!!(val&16));
355 bits[2] = '0'+(!!(val&32));
356 bits[1] = '0'+(!!(val&64));
357 bits[0] = '0'+(!!(val&128));
358 printk(KERN_DEBUG
359 "HFC_outb(chip %d, %02x=%s, 0x%02x=%s); in %s() line %d\n",
360 hc->id, reg, regname, val, bits, function, line);
361 HFC_outb_nodebug(hc, reg, val);
362}
363static u_char
364HFC_inb_debug(struct hfc_multi *hc, u_char reg, const char *function, int line)
365{
366 char regname[256] = "", bits[9] = "xxxxxxxx";
367 u_char val = HFC_inb_nodebug(hc, reg);
368 int i;
369
370 i = 0;
371 while (hfc_register_names[i++].name)
372 ;
373 while (hfc_register_names[++i].name) {
374 if (hfc_register_names[i].reg == reg)
375 strcat(regname, hfc_register_names[i].name);
376 }
377 if (regname[0] == '\0')
378 strcpy(regname, "register");
379
380 bits[7] = '0'+(!!(val&1));
381 bits[6] = '0'+(!!(val&2));
382 bits[5] = '0'+(!!(val&4));
383 bits[4] = '0'+(!!(val&8));
384 bits[3] = '0'+(!!(val&16));
385 bits[2] = '0'+(!!(val&32));
386 bits[1] = '0'+(!!(val&64));
387 bits[0] = '0'+(!!(val&128));
388 printk(KERN_DEBUG
389 "HFC_inb(chip %d, %02x=%s) = 0x%02x=%s; in %s() line %d\n",
390 hc->id, reg, regname, val, bits, function, line);
391 return val;
392}
393static u_short
394HFC_inw_debug(struct hfc_multi *hc, u_char reg, const char *function, int line)
395{
396 char regname[256] = "";
397 u_short val = HFC_inw_nodebug(hc, reg);
398 int i;
399
400 i = 0;
401 while (hfc_register_names[i++].name)
402 ;
403 while (hfc_register_names[++i].name) {
404 if (hfc_register_names[i].reg == reg)
405 strcat(regname, hfc_register_names[i].name);
406 }
407 if (regname[0] == '\0')
408 strcpy(regname, "register");
409
410 printk(KERN_DEBUG
411 "HFC_inw(chip %d, %02x=%s) = 0x%04x; in %s() line %d\n",
412 hc->id, reg, regname, val, function, line);
413 return val;
414}
415static void
416HFC_wait_debug(struct hfc_multi *hc, const char *function, int line)
417{
418 printk(KERN_DEBUG "HFC_wait(chip %d); in %s() line %d\n",
419 hc->id, function, line);
420 HFC_wait_nodebug(hc);
421}
422#endif
423
424/* write fifo data (REGIO) */
425void
426write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
427{
428 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
429 while (len>>2) {
430 outl(*(u32 *)data, hc->pci_iobase);
431 data += 4;
432 len -= 4;
433 }
434 while (len>>1) {
435 outw(*(u16 *)data, hc->pci_iobase);
436 data += 2;
437 len -= 2;
438 }
439 while (len) {
440 outb(*data, hc->pci_iobase);
441 data++;
442 len--;
443 }
444}
445/* write fifo data (PCIMEM) */
446void
447write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
448{
449 while (len>>2) {
450 writel(*(u32 *)data, (hc->pci_membase)+A_FIFO_DATA0);
451 data += 4;
452 len -= 4;
453 }
454 while (len>>1) {
455 writew(*(u16 *)data, (hc->pci_membase)+A_FIFO_DATA0);
456 data += 2;
457 len -= 2;
458 }
459 while (len) {
460 writeb(*data, (hc->pci_membase)+A_FIFO_DATA0);
461 data++;
462 len--;
463 }
464}
465/* read fifo data (REGIO) */
466void
467read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
468{
469 outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
470 while (len>>2) {
471 *(u32 *)data = inl(hc->pci_iobase);
472 data += 4;
473 len -= 4;
474 }
475 while (len>>1) {
476 *(u16 *)data = inw(hc->pci_iobase);
477 data += 2;
478 len -= 2;
479 }
480 while (len) {
481 *data = inb(hc->pci_iobase);
482 data++;
483 len--;
484 }
485}
486
487/* read fifo data (PCIMEM) */
488void
489read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
490{
491 while (len>>2) {
492 *(u32 *)data =
493 readl((hc->pci_membase)+A_FIFO_DATA0);
494 data += 4;
495 len -= 4;
496 }
497 while (len>>1) {
498 *(u16 *)data =
499 readw((hc->pci_membase)+A_FIFO_DATA0);
500 data += 2;
501 len -= 2;
502 }
503 while (len) {
504 *data = readb((hc->pci_membase)+A_FIFO_DATA0);
505 data++;
506 len--;
507 }
508}
509
510
511static void
512enable_hwirq(struct hfc_multi *hc)
513{
514 hc->hw.r_irq_ctrl |= V_GLOB_IRQ_EN;
515 HFC_outb(hc, R_IRQ_CTRL, hc->hw.r_irq_ctrl);
516}
517
518static void
519disable_hwirq(struct hfc_multi *hc)
520{
521 hc->hw.r_irq_ctrl &= ~((u_char)V_GLOB_IRQ_EN);
522 HFC_outb(hc, R_IRQ_CTRL, hc->hw.r_irq_ctrl);
523}
524
525#define NUM_EC 2
526#define MAX_TDM_CHAN 32
527
528
529inline void
530enablepcibridge(struct hfc_multi *c)
531{
532 HFC_outb(c, R_BRG_PCM_CFG, (0x0 << 6) | 0x3); /* was _io before */
533}
534
535inline void
536disablepcibridge(struct hfc_multi *c)
537{
538 HFC_outb(c, R_BRG_PCM_CFG, (0x0 << 6) | 0x2); /* was _io before */
539}
540
541inline unsigned char
542readpcibridge(struct hfc_multi *hc, unsigned char address)
543{
544 unsigned short cipv;
545 unsigned char data;
546
547 if (!hc->pci_iobase)
548 return 0;
549
550 /* slow down a PCI read access by 1 PCI clock cycle */
551 HFC_outb(hc, R_CTRL, 0x4); /*was _io before*/
552
553 if (address == 0)
554 cipv = 0x4000;
555 else
556 cipv = 0x5800;
557
558 /* select local bridge port address by writing to CIP port */
559 /* data = HFC_inb(c, cipv); * was _io before */
560 outw(cipv, hc->pci_iobase + 4);
561 data = inb(hc->pci_iobase);
562
563 /* restore R_CTRL for normal PCI read cycle speed */
564 HFC_outb(hc, R_CTRL, 0x0); /* was _io before */
565
566 return data;
567}
568
569inline void
570writepcibridge(struct hfc_multi *hc, unsigned char address, unsigned char data)
571{
572 unsigned short cipv;
573 unsigned int datav;
574
575 if (!hc->pci_iobase)
576 return;
577
578 if (address == 0)
579 cipv = 0x4000;
580 else
581 cipv = 0x5800;
582
583 /* select local bridge port address by writing to CIP port */
584 outw(cipv, hc->pci_iobase + 4);
585 /* define a 32 bit dword with 4 identical bytes for write sequence */
586 datav = data | ((__u32) data << 8) | ((__u32) data << 16) |
587 ((__u32) data << 24);
588
589 /*
590 * write this 32 bit dword to the bridge data port
591 * this will initiate a write sequence of up to 4 writes to the same
592 * address on the local bus interface the number of write accesses
593 * is undefined but >=1 and depends on the next PCI transaction
594 * during write sequence on the local bus
595 */
596 outl(datav, hc->pci_iobase);
597}
598
599inline void
600cpld_set_reg(struct hfc_multi *hc, unsigned char reg)
601{
602 /* Do data pin read low byte */
603 HFC_outb(hc, R_GPIO_OUT1, reg);
604}
605
606inline void
607cpld_write_reg(struct hfc_multi *hc, unsigned char reg, unsigned char val)
608{
609 cpld_set_reg(hc, reg);
610
611 enablepcibridge(hc);
612 writepcibridge(hc, 1, val);
613 disablepcibridge(hc);
614
615 return;
616}
617
618inline unsigned char
619cpld_read_reg(struct hfc_multi *hc, unsigned char reg)
620{
621 unsigned char bytein;
622
623 cpld_set_reg(hc, reg);
624
625 /* Do data pin read low byte */
626 HFC_outb(hc, R_GPIO_OUT1, reg);
627
628 enablepcibridge(hc);
629 bytein = readpcibridge(hc, 1);
630 disablepcibridge(hc);
631
632 return bytein;
633}
634
635inline void
636vpm_write_address(struct hfc_multi *hc, unsigned short addr)
637{
638 cpld_write_reg(hc, 0, 0xff & addr);
639 cpld_write_reg(hc, 1, 0x01 & (addr >> 8));
640}
641
642inline unsigned short
643vpm_read_address(struct hfc_multi *c)
644{
645 unsigned short addr;
646 unsigned short highbit;
647
648 addr = cpld_read_reg(c, 0);
649 highbit = cpld_read_reg(c, 1);
650
651 addr = addr | (highbit << 8);
652
653 return addr & 0x1ff;
654}
655
656inline unsigned char
657vpm_in(struct hfc_multi *c, int which, unsigned short addr)
658{
659 unsigned char res;
660
661 vpm_write_address(c, addr);
662
663 if (!which)
664 cpld_set_reg(c, 2);
665 else
666 cpld_set_reg(c, 3);
667
668 enablepcibridge(c);
669 res = readpcibridge(c, 1);
670 disablepcibridge(c);
671
672 cpld_set_reg(c, 0);
673
674 return res;
675}
676
677inline void
678vpm_out(struct hfc_multi *c, int which, unsigned short addr,
679 unsigned char data)
680{
681 vpm_write_address(c, addr);
682
683 enablepcibridge(c);
684
685 if (!which)
686 cpld_set_reg(c, 2);
687 else
688 cpld_set_reg(c, 3);
689
690 writepcibridge(c, 1, data);
691
692 cpld_set_reg(c, 0);
693
694 disablepcibridge(c);
695
696 {
697 unsigned char regin;
698 regin = vpm_in(c, which, addr);
699 if (regin != data)
700 printk(KERN_DEBUG "Wrote 0x%x to register 0x%x but got back "
701 "0x%x\n", data, addr, regin);
702 }
703
704}
705
706
707void
708vpm_init(struct hfc_multi *wc)
709{
710 unsigned char reg;
711 unsigned int mask;
712 unsigned int i, x, y;
713 unsigned int ver;
714
715 for (x = 0; x < NUM_EC; x++) {
716 /* Setup GPIO's */
717 if (!x) {
718 ver = vpm_in(wc, x, 0x1a0);
719 printk(KERN_DEBUG "VPM: Chip %d: ver %02x\n", x, ver);
720 }
721
722 for (y = 0; y < 4; y++) {
723 vpm_out(wc, x, 0x1a8 + y, 0x00); /* GPIO out */
724 vpm_out(wc, x, 0x1ac + y, 0x00); /* GPIO dir */
725 vpm_out(wc, x, 0x1b0 + y, 0x00); /* GPIO sel */
726 }
727
728 /* Setup TDM path - sets fsync and tdm_clk as inputs */
729 reg = vpm_in(wc, x, 0x1a3); /* misc_con */
730 vpm_out(wc, x, 0x1a3, reg & ~2);
731
732 /* Setup Echo length (256 taps) */
733 vpm_out(wc, x, 0x022, 1);
734 vpm_out(wc, x, 0x023, 0xff);
735
736 /* Setup timeslots */
737 vpm_out(wc, x, 0x02f, 0x00);
738 mask = 0x02020202 << (x * 4);
739
740 /* Setup the tdm channel masks for all chips */
741 for (i = 0; i < 4; i++)
742 vpm_out(wc, x, 0x33 - i, (mask >> (i << 3)) & 0xff);
743
744 /* Setup convergence rate */
745 printk(KERN_DEBUG "VPM: A-law mode\n");
746 reg = 0x00 | 0x10 | 0x01;
747 vpm_out(wc, x, 0x20, reg);
748 printk(KERN_DEBUG "VPM reg 0x20 is %x\n", reg);
749 /*vpm_out(wc, x, 0x20, (0x00 | 0x08 | 0x20 | 0x10)); */
750
751 vpm_out(wc, x, 0x24, 0x02);
752 reg = vpm_in(wc, x, 0x24);
753 printk(KERN_DEBUG "NLP Thresh is set to %d (0x%x)\n", reg, reg);
754
755 /* Initialize echo cans */
756 for (i = 0; i < MAX_TDM_CHAN; i++) {
757 if (mask & (0x00000001 << i))
758 vpm_out(wc, x, i, 0x00);
759 }
760
761 /*
762 * ARM arch at least disallows a udelay of
763 * more than 2ms... it gives a fake "__bad_udelay"
764 * reference at link-time.
765 * long delays in kernel code are pretty sucky anyway
766 * for now work around it using 5 x 2ms instead of 1 x 10ms
767 */
768
769 udelay(2000);
770 udelay(2000);
771 udelay(2000);
772 udelay(2000);
773 udelay(2000);
774
775 /* Put in bypass mode */
776 for (i = 0; i < MAX_TDM_CHAN; i++) {
777 if (mask & (0x00000001 << i))
778 vpm_out(wc, x, i, 0x01);
779 }
780
781 /* Enable bypass */
782 for (i = 0; i < MAX_TDM_CHAN; i++) {
783 if (mask & (0x00000001 << i))
784 vpm_out(wc, x, 0x78 + i, 0x01);
785 }
786
787 }
788}
789
790void
791vpm_check(struct hfc_multi *hctmp)
792{
793 unsigned char gpi2;
794
795 gpi2 = HFC_inb(hctmp, R_GPI_IN2);
796
797 if ((gpi2 & 0x3) != 0x3)
798 printk(KERN_DEBUG "Got interrupt 0x%x from VPM!\n", gpi2);
799}
800
801
802/*
803 * Interface to enable/disable the HW Echocan
804 *
805 * these functions are called within a spin_lock_irqsave on
806 * the channel instance lock, so we are not disturbed by irqs
807 *
808 * we can later easily change the interface to make other
809 * things configurable, for now we configure the taps
810 *
811 */
812
813void
814vpm_echocan_on(struct hfc_multi *hc, int ch, int taps)
815{
816 unsigned int timeslot;
817 unsigned int unit;
818 struct bchannel *bch = hc->chan[ch].bch;
819#ifdef TXADJ
820 int txadj = -4;
821 struct sk_buff *skb;
822#endif
823 if (hc->chan[ch].protocol != ISDN_P_B_RAW)
824 return;
825
826 if (!bch)
827 return;
828
829#ifdef TXADJ
830 skb = _alloc_mISDN_skb(PH_CONTROL_IND, HFC_VOL_CHANGE_TX,
831 sizeof(int), &txadj, GFP_ATOMIC);
832 if (skb)
833 recv_Bchannel_skb(bch, skb);
834#endif
835
836 timeslot = ((ch/4)*8) + ((ch%4)*4) + 1;
837 unit = ch % 4;
838
839 printk(KERN_NOTICE "vpm_echocan_on called taps [%d] on timeslot %d\n",
840 taps, timeslot);
841
842 vpm_out(hc, unit, timeslot, 0x7e);
843}
844
845void
846vpm_echocan_off(struct hfc_multi *hc, int ch)
847{
848 unsigned int timeslot;
849 unsigned int unit;
850 struct bchannel *bch = hc->chan[ch].bch;
851#ifdef TXADJ
852 int txadj = 0;
853 struct sk_buff *skb;
854#endif
855
856 if (hc->chan[ch].protocol != ISDN_P_B_RAW)
857 return;
858
859 if (!bch)
860 return;
861
862#ifdef TXADJ
863 skb = _alloc_mISDN_skb(PH_CONTROL_IND, HFC_VOL_CHANGE_TX,
864 sizeof(int), &txadj, GFP_ATOMIC);
865 if (skb)
866 recv_Bchannel_skb(bch, skb);
867#endif
868
869 timeslot = ((ch/4)*8) + ((ch%4)*4) + 1;
870 unit = ch % 4;
871
872 printk(KERN_NOTICE "vpm_echocan_off called on timeslot %d\n",
873 timeslot);
874 /* FILLME */
875 vpm_out(hc, unit, timeslot, 0x01);
876}
877
878
879/*
880 * Speech Design resync feature
881 * NOTE: This is called sometimes outside interrupt handler.
882 * We must lock irqsave, so no other interrupt (other card) will occurr!
883 * Also multiple interrupts may nest, so must lock each access (lists, card)!
884 */
885static inline void
886hfcmulti_resync(struct hfc_multi *locked, struct hfc_multi *newmaster, int rm)
887{
888 struct hfc_multi *hc, *next, *pcmmaster = 0;
889 u_int *plx_acc_32, pv;
890 u_long flags;
891
892 spin_lock_irqsave(&HFClock, flags);
893 spin_lock(&plx_lock); /* must be locked inside other locks */
894
895 if (debug & DEBUG_HFCMULTI_PLXSD)
896 printk(KERN_DEBUG "%s: RESYNC(syncmaster=0x%p)\n",
897 __func__, syncmaster);
898
899 /* select new master */
900 if (newmaster) {
901 if (debug & DEBUG_HFCMULTI_PLXSD)
902 printk(KERN_DEBUG "using provided controller\n");
903 } else {
904 list_for_each_entry_safe(hc, next, &HFClist, list) {
905 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
906 if (hc->syncronized) {
907 newmaster = hc;
908 break;
909 }
910 }
911 }
912 }
913
914 /* Disable sync of all cards */
915 list_for_each_entry_safe(hc, next, &HFClist, list) {
916 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
917 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
918 pv = readl(plx_acc_32);
919 pv &= ~PLX_SYNC_O_EN;
920 writel(pv, plx_acc_32);
921 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) {
922 pcmmaster = hc;
923 if (hc->type == 1) {
924 if (debug & DEBUG_HFCMULTI_PLXSD)
925 printk(KERN_DEBUG
926 "Schedule SYNC_I\n");
927 hc->e1_resync |= 1; /* get SYNC_I */
928 }
929 }
930 }
931 }
932
933 if (newmaster) {
934 hc = newmaster;
935 if (debug & DEBUG_HFCMULTI_PLXSD)
936 printk(KERN_DEBUG "id=%d (0x%p) = syncronized with "
937 "interface.\n", hc->id, hc);
938 /* Enable new sync master */
939 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
940 pv = readl(plx_acc_32);
941 pv |= PLX_SYNC_O_EN;
942 writel(pv, plx_acc_32);
943 /* switch to jatt PLL, if not disabled by RX_SYNC */
944 if (hc->type == 1 && !test_bit(HFC_CHIP_RX_SYNC, &hc->chip)) {
945 if (debug & DEBUG_HFCMULTI_PLXSD)
946 printk(KERN_DEBUG "Schedule jatt PLL\n");
947 hc->e1_resync |= 2; /* switch to jatt */
948 }
949 } else {
950 if (pcmmaster) {
951 hc = pcmmaster;
952 if (debug & DEBUG_HFCMULTI_PLXSD)
953 printk(KERN_DEBUG
954 "id=%d (0x%p) = PCM master syncronized "
955 "with QUARTZ\n", hc->id, hc);
956 if (hc->type == 1) {
957 /* Use the crystal clock for the PCM
958 master card */
959 if (debug & DEBUG_HFCMULTI_PLXSD)
960 printk(KERN_DEBUG
961 "Schedule QUARTZ for HFC-E1\n");
962 hc->e1_resync |= 4; /* switch quartz */
963 } else {
964 if (debug & DEBUG_HFCMULTI_PLXSD)
965 printk(KERN_DEBUG
966 "QUARTZ is automatically "
967 "enabled by HFC-%dS\n", hc->type);
968 }
969 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
970 pv = readl(plx_acc_32);
971 pv |= PLX_SYNC_O_EN;
972 writel(pv, plx_acc_32);
973 } else
974 if (!rm)
975 printk(KERN_ERR "%s no pcm master, this MUST "
976 "not happen!\n", __func__);
977 }
978 syncmaster = newmaster;
979
980 spin_unlock(&plx_lock);
981 spin_unlock_irqrestore(&HFClock, flags);
982}
983
984/* This must be called AND hc must be locked irqsave!!! */
985inline void
986plxsd_checksync(struct hfc_multi *hc, int rm)
987{
988 if (hc->syncronized) {
989 if (syncmaster == NULL) {
990 if (debug & DEBUG_HFCMULTI_PLXSD)
991 printk(KERN_WARNING "%s: GOT sync on card %d"
992 " (id=%d)\n", __func__, hc->id + 1,
993 hc->id);
994 hfcmulti_resync(hc, hc, rm);
995 }
996 } else {
997 if (syncmaster == hc) {
998 if (debug & DEBUG_HFCMULTI_PLXSD)
999 printk(KERN_WARNING "%s: LOST sync on card %d"
1000 " (id=%d)\n", __func__, hc->id + 1,
1001 hc->id);
1002 hfcmulti_resync(hc, NULL, rm);
1003 }
1004 }
1005}
1006
1007
1008/*
1009 * free hardware resources used by driver
1010 */
1011static void
1012release_io_hfcmulti(struct hfc_multi *hc)
1013{
1014 u_int *plx_acc_32, pv;
1015 u_long plx_flags;
1016
1017 if (debug & DEBUG_HFCMULTI_INIT)
1018 printk(KERN_DEBUG "%s: entered\n", __func__);
1019
1020 /* soft reset also masks all interrupts */
1021 hc->hw.r_cirm |= V_SRES;
1022 HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
1023 udelay(1000);
1024 hc->hw.r_cirm &= ~V_SRES;
1025 HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
1026 udelay(1000); /* instead of 'wait' that may cause locking */
1027
1028 /* release Speech Design card, if PLX was initialized */
1029 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) && hc->plx_membase) {
1030 if (debug & DEBUG_HFCMULTI_PLXSD)
1031 printk(KERN_DEBUG "%s: release PLXSD card %d\n",
1032 __func__, hc->id + 1);
1033 spin_lock_irqsave(&plx_lock, plx_flags);
1034 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
1035 writel(PLX_GPIOC_INIT, plx_acc_32);
1036 pv = readl(plx_acc_32);
1037 /* Termination off */
1038 pv &= ~PLX_TERM_ON;
1039 /* Disconnect the PCM */
1040 pv |= PLX_SLAVE_EN_N;
1041 pv &= ~PLX_MASTER_EN;
1042 pv &= ~PLX_SYNC_O_EN;
1043 /* Put the DSP in Reset */
1044 pv &= ~PLX_DSP_RES_N;
1045 writel(pv, plx_acc_32);
1046 if (debug & DEBUG_HFCMULTI_INIT)
1047 printk(KERN_WARNING "%s: PCM off: PLX_GPIO=%x\n",
1048 __func__, pv);
1049 spin_unlock_irqrestore(&plx_lock, plx_flags);
1050 }
1051
1052 /* disable memory mapped ports / io ports */
1053 test_and_clear_bit(HFC_CHIP_PLXSD, &hc->chip); /* prevent resync */
1054 pci_write_config_word(hc->pci_dev, PCI_COMMAND, 0);
1055 if (hc->pci_membase)
1056 iounmap((void *)hc->pci_membase);
1057 if (hc->plx_membase)
1058 iounmap((void *)hc->plx_membase);
1059 if (hc->pci_iobase)
1060 release_region(hc->pci_iobase, 8);
1061
1062 if (hc->pci_dev) {
1063 pci_disable_device(hc->pci_dev);
1064 pci_set_drvdata(hc->pci_dev, NULL);
1065 }
1066 if (debug & DEBUG_HFCMULTI_INIT)
1067 printk(KERN_DEBUG "%s: done\n", __func__);
1068}
1069
1070/*
1071 * function called to reset the HFC chip. A complete software reset of chip
1072 * and fifos is done. All configuration of the chip is done.
1073 */
1074
1075static int
1076init_chip(struct hfc_multi *hc)
1077{
1078 u_long flags, val, val2 = 0, rev;
1079 int i, err = 0;
1080 u_char r_conf_en, rval;
1081 u_int *plx_acc_32, pv;
1082 u_long plx_flags, hfc_flags;
1083 int plx_count;
1084 struct hfc_multi *pos, *next, *plx_last_hc;
1085
1086 spin_lock_irqsave(&hc->lock, flags);
1087 /* reset all registers */
1088 memset(&hc->hw, 0, sizeof(struct hfcm_hw));
1089
1090 /* revision check */
1091 if (debug & DEBUG_HFCMULTI_INIT)
1092 printk(KERN_DEBUG "%s: entered\n", __func__);
1093 val = HFC_inb(hc, R_CHIP_ID)>>4;
1094 if (val != 0x8 && val != 0xc && val != 0xe) {
1095 printk(KERN_INFO "HFC_multi: unknown CHIP_ID:%x\n", (u_int)val);
1096 err = -EIO;
1097 goto out;
1098 }
1099 rev = HFC_inb(hc, R_CHIP_RV);
1100 printk(KERN_INFO
1101 "HFC_multi: detected HFC with chip ID=0x%lx revision=%ld%s\n",
1102 val, rev, (rev == 0) ? " (old FIFO handling)" : "");
1103 if (rev == 0) {
1104 test_and_set_bit(HFC_CHIP_REVISION0, &hc->chip);
1105 printk(KERN_WARNING
1106 "HFC_multi: NOTE: Your chip is revision 0, "
1107 "ask Cologne Chip for update. Newer chips "
1108 "have a better FIFO handling. Old chips "
1109 "still work but may have slightly lower "
1110 "HDLC transmit performance.\n");
1111 }
1112 if (rev > 1) {
1113 printk(KERN_WARNING "HFC_multi: WARNING: This driver doesn't "
1114 "consider chip revision = %ld. The chip / "
1115 "bridge may not work.\n", rev);
1116 }
1117
1118 /* set s-ram size */
1119 hc->Flen = 0x10;
1120 hc->Zmin = 0x80;
1121 hc->Zlen = 384;
1122 hc->DTMFbase = 0x1000;
1123 if (test_bit(HFC_CHIP_EXRAM_128, &hc->chip)) {
1124 if (debug & DEBUG_HFCMULTI_INIT)
1125 printk(KERN_DEBUG "%s: changing to 128K extenal RAM\n",
1126 __func__);
1127 hc->hw.r_ctrl |= V_EXT_RAM;
1128 hc->hw.r_ram_sz = 1;
1129 hc->Flen = 0x20;
1130 hc->Zmin = 0xc0;
1131 hc->Zlen = 1856;
1132 hc->DTMFbase = 0x2000;
1133 }
1134 if (test_bit(HFC_CHIP_EXRAM_512, &hc->chip)) {
1135 if (debug & DEBUG_HFCMULTI_INIT)
1136 printk(KERN_DEBUG "%s: changing to 512K extenal RAM\n",
1137 __func__);
1138 hc->hw.r_ctrl |= V_EXT_RAM;
1139 hc->hw.r_ram_sz = 2;
1140 hc->Flen = 0x20;
1141 hc->Zmin = 0xc0;
1142 hc->Zlen = 8000;
1143 hc->DTMFbase = 0x2000;
1144 }
1145 hc->max_trans = poll << 1;
1146 if (hc->max_trans > hc->Zlen)
1147 hc->max_trans = hc->Zlen;
1148
1149 /* Speech Design PLX bridge */
1150 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
1151 if (debug & DEBUG_HFCMULTI_PLXSD)
1152 printk(KERN_DEBUG "%s: initializing PLXSD card %d\n",
1153 __func__, hc->id + 1);
1154 spin_lock_irqsave(&plx_lock, plx_flags);
1155 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
1156 writel(PLX_GPIOC_INIT, plx_acc_32);
1157 pv = readl(plx_acc_32);
1158 /* The first and the last cards are terminating the PCM bus */
1159 pv |= PLX_TERM_ON; /* hc is currently the last */
1160 /* Disconnect the PCM */
1161 pv |= PLX_SLAVE_EN_N;
1162 pv &= ~PLX_MASTER_EN;
1163 pv &= ~PLX_SYNC_O_EN;
1164 /* Put the DSP in Reset */
1165 pv &= ~PLX_DSP_RES_N;
1166 writel(pv, plx_acc_32);
1167 spin_unlock_irqrestore(&plx_lock, plx_flags);
1168 if (debug & DEBUG_HFCMULTI_INIT)
1169 printk(KERN_WARNING "%s: slave/term: PLX_GPIO=%x\n",
1170 __func__, pv);
1171 /*
1172 * If we are the 3rd PLXSD card or higher, we must turn
1173 * termination of last PLXSD card off.
1174 */
1175 spin_lock_irqsave(&HFClock, hfc_flags);
1176 plx_count = 0;
1177 plx_last_hc = NULL;
1178 list_for_each_entry_safe(pos, next, &HFClist, list) {
1179 if (test_bit(HFC_CHIP_PLXSD, &pos->chip)) {
1180 plx_count++;
1181 if (pos != hc)
1182 plx_last_hc = pos;
1183 }
1184 }
1185 if (plx_count >= 3) {
1186 if (debug & DEBUG_HFCMULTI_PLXSD)
1187 printk(KERN_DEBUG "%s: card %d is between, so "
1188 "we disable termination\n",
1189 __func__, plx_last_hc->id + 1);
1190 spin_lock_irqsave(&plx_lock, plx_flags);
1191 plx_acc_32 = (u_int *)(plx_last_hc->plx_membase
1192 + PLX_GPIOC);
1193 pv = readl(plx_acc_32);
1194 pv &= ~PLX_TERM_ON;
1195 writel(pv, plx_acc_32);
1196 spin_unlock_irqrestore(&plx_lock, plx_flags);
1197 if (debug & DEBUG_HFCMULTI_INIT)
1198 printk(KERN_WARNING "%s: term off: PLX_GPIO=%x\n",
1199 __func__, pv);
1200 }
1201 spin_unlock_irqrestore(&HFClock, hfc_flags);
1202 hc->hw.r_pcm_md0 = V_F0_LEN; /* shift clock for DSP */
1203 }
1204
1205 /* we only want the real Z2 read-pointer for revision > 0 */
1206 if (!test_bit(HFC_CHIP_REVISION0, &hc->chip))
1207 hc->hw.r_ram_sz |= V_FZ_MD;
1208
1209 /* select pcm mode */
1210 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) {
1211 if (debug & DEBUG_HFCMULTI_INIT)
1212 printk(KERN_DEBUG "%s: setting PCM into slave mode\n",
1213 __func__);
1214 } else
1215 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip) && !plxsd_master) {
1216 if (debug & DEBUG_HFCMULTI_INIT)
1217 printk(KERN_DEBUG "%s: setting PCM into master mode\n",
1218 __func__);
1219 hc->hw.r_pcm_md0 |= V_PCM_MD;
1220 } else {
1221 if (debug & DEBUG_HFCMULTI_INIT)
1222 printk(KERN_DEBUG "%s: performing PCM auto detect\n",
1223 __func__);
1224 }
1225
1226 /* soft reset */
1227 HFC_outb(hc, R_CTRL, hc->hw.r_ctrl);
1228 HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
1229 HFC_outb(hc, R_FIFO_MD, 0);
1230 hc->hw.r_cirm = V_SRES | V_HFCRES | V_PCMRES | V_STRES | V_RLD_EPR;
1231 HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
1232 udelay(100);
1233 hc->hw.r_cirm = 0;
1234 HFC_outb(hc, R_CIRM, hc->hw.r_cirm);
1235 udelay(100);
1236 HFC_outb(hc, R_RAM_SZ, hc->hw.r_ram_sz);
1237
1238 /* Speech Design PLX bridge pcm and sync mode */
1239 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
1240 spin_lock_irqsave(&plx_lock, plx_flags);
1241 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
1242 pv = readl(plx_acc_32);
1243 /* Connect PCM */
1244 if (hc->hw.r_pcm_md0 & V_PCM_MD) {
1245 pv |= PLX_MASTER_EN | PLX_SLAVE_EN_N;
1246 pv |= PLX_SYNC_O_EN;
1247 if (debug & DEBUG_HFCMULTI_INIT)
1248 printk(KERN_WARNING "%s: master: PLX_GPIO=%x\n",
1249 __func__, pv);
1250 } else {
1251 pv &= ~(PLX_MASTER_EN | PLX_SLAVE_EN_N);
1252 pv &= ~PLX_SYNC_O_EN;
1253 if (debug & DEBUG_HFCMULTI_INIT)
1254 printk(KERN_WARNING "%s: slave: PLX_GPIO=%x\n",
1255 __func__, pv);
1256 }
1257 writel(pv, plx_acc_32);
1258 spin_unlock_irqrestore(&plx_lock, plx_flags);
1259 }
1260
1261 /* PCM setup */
1262 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x90);
1263 if (hc->slots == 32)
1264 HFC_outb(hc, R_PCM_MD1, 0x00);
1265 if (hc->slots == 64)
1266 HFC_outb(hc, R_PCM_MD1, 0x10);
1267 if (hc->slots == 128)
1268 HFC_outb(hc, R_PCM_MD1, 0x20);
1269 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0xa0);
1270 if (test_bit(HFC_CHIP_PLXSD, &hc->chip))
1271 HFC_outb(hc, R_PCM_MD2, V_SYNC_SRC); /* sync via SYNC_I / O */
1272 else
1273 HFC_outb(hc, R_PCM_MD2, 0x00); /* sync from interface */
1274 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00);
1275 for (i = 0; i < 256; i++) {
1276 HFC_outb_nodebug(hc, R_SLOT, i);
1277 HFC_outb_nodebug(hc, A_SL_CFG, 0);
1278 HFC_outb_nodebug(hc, A_CONF, 0);
1279 hc->slot_owner[i] = -1;
1280 }
1281
1282 /* set clock speed */
1283 if (test_bit(HFC_CHIP_CLOCK2, &hc->chip)) {
1284 if (debug & DEBUG_HFCMULTI_INIT)
1285 printk(KERN_DEBUG
1286 "%s: setting double clock\n", __func__);
1287 HFC_outb(hc, R_BRG_PCM_CFG, V_PCM_CLK);
1288 }
1289
1290 /* B410P GPIO */
1291 if (test_bit(HFC_CHIP_B410P, &hc->chip)) {
1292 printk(KERN_NOTICE "Setting GPIOs\n");
1293 HFC_outb(hc, R_GPIO_SEL, 0x30);
1294 HFC_outb(hc, R_GPIO_EN1, 0x3);
1295 udelay(1000);
1296 printk(KERN_NOTICE "calling vpm_init\n");
1297 vpm_init(hc);
1298 }
1299
1300 /* check if R_F0_CNT counts (8 kHz frame count) */
1301 val = HFC_inb(hc, R_F0_CNTL);
1302 val += HFC_inb(hc, R_F0_CNTH) << 8;
1303 if (debug & DEBUG_HFCMULTI_INIT)
1304 printk(KERN_DEBUG
1305 "HFC_multi F0_CNT %ld after reset\n", val);
1306 spin_unlock_irqrestore(&hc->lock, flags);
1307 set_current_state(TASK_UNINTERRUPTIBLE);
1308 schedule_timeout((HZ/100)?:1); /* Timeout minimum 10ms */
1309 spin_lock_irqsave(&hc->lock, flags);
1310 val2 = HFC_inb(hc, R_F0_CNTL);
1311 val2 += HFC_inb(hc, R_F0_CNTH) << 8;
1312 if (debug & DEBUG_HFCMULTI_INIT)
1313 printk(KERN_DEBUG
1314 "HFC_multi F0_CNT %ld after 10 ms (1st try)\n",
1315 val2);
1316 if (val2 >= val+8) { /* 1 ms */
1317 /* it counts, so we keep the pcm mode */
1318 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip))
1319 printk(KERN_INFO "controller is PCM bus MASTER\n");
1320 else
1321 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip))
1322 printk(KERN_INFO "controller is PCM bus SLAVE\n");
1323 else {
1324 test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
1325 printk(KERN_INFO "controller is PCM bus SLAVE "
1326 "(auto detected)\n");
1327 }
1328 } else {
1329 /* does not count */
1330 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)) {
1331controller_fail:
1332 printk(KERN_ERR "HFC_multi ERROR, getting no 125us "
1333 "pulse. Seems that controller fails.\n");
1334 err = -EIO;
1335 goto out;
1336 }
1337 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) {
1338 printk(KERN_INFO "controller is PCM bus SLAVE "
1339 "(ignoring missing PCM clock)\n");
1340 } else {
1341 /* only one pcm master */
1342 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)
1343 && plxsd_master) {
1344 printk(KERN_ERR "HFC_multi ERROR, no clock "
1345 "on another Speech Design card found. "
1346 "Please be sure to connect PCM cable.\n");
1347 err = -EIO;
1348 goto out;
1349 }
1350 /* retry with master clock */
1351 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
1352 spin_lock_irqsave(&plx_lock, plx_flags);
1353 plx_acc_32 = (u_int *)(hc->plx_membase +
1354 PLX_GPIOC);
1355 pv = readl(plx_acc_32);
1356 pv |= PLX_MASTER_EN | PLX_SLAVE_EN_N;
1357 pv |= PLX_SYNC_O_EN;
1358 writel(pv, plx_acc_32);
1359 spin_unlock_irqrestore(&plx_lock, plx_flags);
1360 if (debug & DEBUG_HFCMULTI_INIT)
1361 printk(KERN_WARNING "%s: master: PLX_GPIO"
1362 "=%x\n", __func__, pv);
1363 }
1364 hc->hw.r_pcm_md0 |= V_PCM_MD;
1365 HFC_outb(hc, R_PCM_MD0, hc->hw.r_pcm_md0 | 0x00);
1366 spin_unlock_irqrestore(&hc->lock, flags);
1367 set_current_state(TASK_UNINTERRUPTIBLE);
1368 schedule_timeout((HZ/100)?:1); /* Timeout min. 10ms */
1369 spin_lock_irqsave(&hc->lock, flags);
1370 val2 = HFC_inb(hc, R_F0_CNTL);
1371 val2 += HFC_inb(hc, R_F0_CNTH) << 8;
1372 if (debug & DEBUG_HFCMULTI_INIT)
1373 printk(KERN_DEBUG "HFC_multi F0_CNT %ld after "
1374 "10 ms (2nd try)\n", val2);
1375 if (val2 >= val+8) { /* 1 ms */
1376 test_and_set_bit(HFC_CHIP_PCM_MASTER,
1377 &hc->chip);
1378 printk(KERN_INFO "controller is PCM bus MASTER "
1379 "(auto detected)\n");
1380 } else
1381 goto controller_fail;
1382 }
1383 }
1384
1385 /* Release the DSP Reset */
1386 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
1387 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip))
1388 plxsd_master = 1;
1389 spin_lock_irqsave(&plx_lock, plx_flags);
1390 plx_acc_32 = (u_int *)(hc->plx_membase+PLX_GPIOC);
1391 pv = readl(plx_acc_32);
1392 pv |= PLX_DSP_RES_N;
1393 writel(pv, plx_acc_32);
1394 spin_unlock_irqrestore(&plx_lock, plx_flags);
1395 if (debug & DEBUG_HFCMULTI_INIT)
1396 printk(KERN_WARNING "%s: reset off: PLX_GPIO=%x\n",
1397 __func__, pv);
1398 }
1399
1400 /* pcm id */
1401 if (hc->pcm)
1402 printk(KERN_INFO "controller has given PCM BUS ID %d\n",
1403 hc->pcm);
1404 else {
1405 if (test_bit(HFC_CHIP_PCM_MASTER, &hc->chip)
1406 || test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
1407 PCM_cnt++; /* SD has proprietary bridging */
1408 }
1409 hc->pcm = PCM_cnt;
1410 printk(KERN_INFO "controller has PCM BUS ID %d "
1411 "(auto selected)\n", hc->pcm);
1412 }
1413
1414 /* set up timer */
1415 HFC_outb(hc, R_TI_WD, poll_timer);
1416 hc->hw.r_irqmsk_misc |= V_TI_IRQMSK;
1417
1418 /*
1419 * set up 125us interrupt, only if function pointer is available
1420 * and module parameter timer is set
1421 */
1422 if (timer && hfc_interrupt && register_interrupt) {
1423 /* only one chip should use this interrupt */
1424 timer = 0;
1425 interrupt_registered = 1;
1426 hc->hw.r_irqmsk_misc |= V_PROC_IRQMSK;
1427 /* deactivate other interrupts in ztdummy */
1428 register_interrupt();
1429 }
1430
1431 /* set E1 state machine IRQ */
1432 if (hc->type == 1)
1433 hc->hw.r_irqmsk_misc |= V_STA_IRQMSK;
1434
1435 /* set DTMF detection */
1436 if (test_bit(HFC_CHIP_DTMF, &hc->chip)) {
1437 if (debug & DEBUG_HFCMULTI_INIT)
1438 printk(KERN_DEBUG "%s: enabling DTMF detection "
1439 "for all B-channel\n", __func__);
1440 hc->hw.r_dtmf = V_DTMF_EN | V_DTMF_STOP;
1441 if (test_bit(HFC_CHIP_ULAW, &hc->chip))
1442 hc->hw.r_dtmf |= V_ULAW_SEL;
1443 HFC_outb(hc, R_DTMF_N, 102 - 1);
1444 hc->hw.r_irqmsk_misc |= V_DTMF_IRQMSK;
1445 }
1446
1447 /* conference engine */
1448 if (test_bit(HFC_CHIP_ULAW, &hc->chip))
1449 r_conf_en = V_CONF_EN | V_ULAW;
1450 else
1451 r_conf_en = V_CONF_EN;
1452 HFC_outb(hc, R_CONF_EN, r_conf_en);
1453
1454 /* setting leds */
1455 switch (hc->leds) {
1456 case 1: /* HFC-E1 OEM */
1457 if (test_bit(HFC_CHIP_WATCHDOG, &hc->chip))
1458 HFC_outb(hc, R_GPIO_SEL, 0x32);
1459 else
1460 HFC_outb(hc, R_GPIO_SEL, 0x30);
1461
1462 HFC_outb(hc, R_GPIO_EN1, 0x0f);
1463 HFC_outb(hc, R_GPIO_OUT1, 0x00);
1464
1465 HFC_outb(hc, R_GPIO_EN0, V_GPIO_EN2 | V_GPIO_EN3);
1466 break;
1467
1468 case 2: /* HFC-4S OEM */
1469 case 3:
1470 HFC_outb(hc, R_GPIO_SEL, 0xf0);
1471 HFC_outb(hc, R_GPIO_EN1, 0xff);
1472 HFC_outb(hc, R_GPIO_OUT1, 0x00);
1473 break;
1474 }
1475
1476 /* set master clock */
1477 if (hc->masterclk >= 0) {
1478 if (debug & DEBUG_HFCMULTI_INIT)
1479 printk(KERN_DEBUG "%s: setting ST master clock "
1480 "to port %d (0..%d)\n",
1481 __func__, hc->masterclk, hc->ports-1);
1482 hc->hw.r_st_sync = hc->masterclk | V_AUTO_SYNC;
1483 HFC_outb(hc, R_ST_SYNC, hc->hw.r_st_sync);
1484 }
1485
1486 /* setting misc irq */
1487 HFC_outb(hc, R_IRQMSK_MISC, hc->hw.r_irqmsk_misc);
1488 if (debug & DEBUG_HFCMULTI_INIT)
1489 printk(KERN_DEBUG "r_irqmsk_misc.2: 0x%x\n",
1490 hc->hw.r_irqmsk_misc);
1491
1492 /* RAM access test */
1493 HFC_outb(hc, R_RAM_ADDR0, 0);
1494 HFC_outb(hc, R_RAM_ADDR1, 0);
1495 HFC_outb(hc, R_RAM_ADDR2, 0);
1496 for (i = 0; i < 256; i++) {
1497 HFC_outb_nodebug(hc, R_RAM_ADDR0, i);
1498 HFC_outb_nodebug(hc, R_RAM_DATA, ((i*3)&0xff));
1499 }
1500 for (i = 0; i < 256; i++) {
1501 HFC_outb_nodebug(hc, R_RAM_ADDR0, i);
1502 HFC_inb_nodebug(hc, R_RAM_DATA);
1503 rval = HFC_inb_nodebug(hc, R_INT_DATA);
1504 if (rval != ((i * 3) & 0xff)) {
1505 printk(KERN_DEBUG
1506 "addr:%x val:%x should:%x\n", i, rval,
1507 (i * 3) & 0xff);
1508 err++;
1509 }
1510 }
1511 if (err) {
1512 printk(KERN_DEBUG "aborting - %d RAM access errors\n", err);
1513 err = -EIO;
1514 goto out;
1515 }
1516
1517 if (debug & DEBUG_HFCMULTI_INIT)
1518 printk(KERN_DEBUG "%s: done\n", __func__);
1519out:
1520 spin_unlock_irqrestore(&hc->lock, flags);
1521 return err;
1522}
1523
1524
1525/*
1526 * control the watchdog
1527 */
1528static void
1529hfcmulti_watchdog(struct hfc_multi *hc)
1530{
1531 hc->wdcount++;
1532
1533 if (hc->wdcount > 10) {
1534 hc->wdcount = 0;
1535 hc->wdbyte = hc->wdbyte == V_GPIO_OUT2 ?
1536 V_GPIO_OUT3 : V_GPIO_OUT2;
1537
1538 /* printk("Sending Watchdog Kill %x\n",hc->wdbyte); */
1539 HFC_outb(hc, R_GPIO_EN0, V_GPIO_EN2 | V_GPIO_EN3);
1540 HFC_outb(hc, R_GPIO_OUT0, hc->wdbyte);
1541 }
1542}
1543
1544
1545
1546/*
1547 * output leds
1548 */
1549static void
1550hfcmulti_leds(struct hfc_multi *hc)
1551{
1552 unsigned long lled;
1553 unsigned long leddw;
1554 int i, state, active, leds;
1555 struct dchannel *dch;
1556 int led[4];
1557
1558 hc->ledcount += poll;
1559 if (hc->ledcount > 4096) {
1560 hc->ledcount -= 4096;
1561 hc->ledstate = 0xAFFEAFFE;
1562 }
1563
1564 switch (hc->leds) {
1565 case 1: /* HFC-E1 OEM */
1566 /* 2 red blinking: NT mode deactivate
1567 * 2 red steady: TE mode deactivate
1568 * left green: L1 active
1569 * left red: frame sync, but no L1
1570 * right green: L2 active
1571 */
1572 if (hc->chan[hc->dslot].sync != 2) { /* no frame sync */
1573 if (hc->chan[hc->dslot].dch->dev.D.protocol
1574 != ISDN_P_NT_E1) {
1575 led[0] = 1;
1576 led[1] = 1;
1577 } else if (hc->ledcount>>11) {
1578 led[0] = 1;
1579 led[1] = 1;
1580 } else {
1581 led[0] = 0;
1582 led[1] = 0;
1583 }
1584 led[2] = 0;
1585 led[3] = 0;
1586 } else { /* with frame sync */
1587 /* TODO make it work */
1588 led[0] = 0;
1589 led[1] = 0;
1590 led[2] = 0;
1591 led[3] = 1;
1592 }
1593 leds = (led[0] | (led[1]<<2) | (led[2]<<1) | (led[3]<<3))^0xF;
1594 /* leds are inverted */
1595 if (leds != (int)hc->ledstate) {
1596 HFC_outb_nodebug(hc, R_GPIO_OUT1, leds);
1597 hc->ledstate = leds;
1598 }
1599 break;
1600
1601 case 2: /* HFC-4S OEM */
1602 /* red blinking = PH_DEACTIVATE NT Mode
1603 * red steady = PH_DEACTIVATE TE Mode
1604 * green steady = PH_ACTIVATE
1605 */
1606 for (i = 0; i < 4; i++) {
1607 state = 0;
1608 active = -1;
1609 dch = hc->chan[(i << 2) | 2].dch;
1610 if (dch) {
1611 state = dch->state;
1612 if (dch->dev.D.protocol == ISDN_P_NT_S0)
1613 active = 3;
1614 else
1615 active = 7;
1616 }
1617 if (state) {
1618 if (state == active) {
1619 led[i] = 1; /* led green */
1620 } else
1621 if (dch->dev.D.protocol == ISDN_P_TE_S0)
1622 /* TE mode: led red */
1623 led[i] = 2;
1624 else
1625 if (hc->ledcount>>11)
1626 /* led red */
1627 led[i] = 2;
1628 else
1629 /* led off */
1630 led[i] = 0;
1631 } else
1632 led[i] = 0; /* led off */
1633 }
1634 if (test_bit(HFC_CHIP_B410P, &hc->chip)) {
1635 leds = 0;
1636 for (i = 0; i < 4; i++) {
1637 if (led[i] == 1) {
1638 /*green*/
1639 leds |= (0x2 << (i * 2));
1640 } else if (led[i] == 2) {
1641 /*red*/
1642 leds |= (0x1 << (i * 2));
1643 }
1644 }
1645 if (leds != (int)hc->ledstate) {
1646 vpm_out(hc, 0, 0x1a8 + 3, leds);
1647 hc->ledstate = leds;
1648 }
1649 } else {
1650 leds = ((led[3] > 0) << 0) | ((led[1] > 0) << 1) |
1651 ((led[0] > 0) << 2) | ((led[2] > 0) << 3) |
1652 ((led[3] & 1) << 4) | ((led[1] & 1) << 5) |
1653 ((led[0] & 1) << 6) | ((led[2] & 1) << 7);
1654 if (leds != (int)hc->ledstate) {
1655 HFC_outb_nodebug(hc, R_GPIO_EN1, leds & 0x0F);
1656 HFC_outb_nodebug(hc, R_GPIO_OUT1, leds >> 4);
1657 hc->ledstate = leds;
1658 }
1659 }
1660 break;
1661
1662 case 3: /* HFC 1S/2S Beronet */
1663 /* red blinking = PH_DEACTIVATE NT Mode
1664 * red steady = PH_DEACTIVATE TE Mode
1665 * green steady = PH_ACTIVATE
1666 */
1667 for (i = 0; i < 2; i++) {
1668 state = 0;
1669 active = -1;
1670 dch = hc->chan[(i << 2) | 2].dch;
1671 if (dch) {
1672 state = dch->state;
1673 if (dch->dev.D.protocol == ISDN_P_NT_S0)
1674 active = 3;
1675 else
1676 active = 7;
1677 }
1678 if (state) {
1679 if (state == active) {
1680 led[i] = 1; /* led green */
1681 } else
1682 if (dch->dev.D.protocol == ISDN_P_TE_S0)
1683 /* TE mode: led red */
1684 led[i] = 2;
1685 else
1686 if (hc->ledcount >> 11)
1687 /* led red */
1688 led[i] = 2;
1689 else
1690 /* led off */
1691 led[i] = 0;
1692 } else
1693 led[i] = 0; /* led off */
1694 }
1695
1696
1697 leds = (led[0] > 0) | ((led[1] > 0)<<1) | ((led[0]&1)<<2)
1698 | ((led[1]&1)<<3);
1699 if (leds != (int)hc->ledstate) {
1700 HFC_outb_nodebug(hc, R_GPIO_EN1,
1701 ((led[0] > 0) << 2) | ((led[1] > 0) << 3));
1702 HFC_outb_nodebug(hc, R_GPIO_OUT1,
1703 ((led[0] & 1) << 2) | ((led[1] & 1) << 3));
1704 hc->ledstate = leds;
1705 }
1706 break;
1707 case 8: /* HFC 8S+ Beronet */
1708 lled = 0;
1709
1710 for (i = 0; i < 8; i++) {
1711 state = 0;
1712 active = -1;
1713 dch = hc->chan[(i << 2) | 2].dch;
1714 if (dch) {
1715 state = dch->state;
1716 if (dch->dev.D.protocol == ISDN_P_NT_S0)
1717 active = 3;
1718 else
1719 active = 7;
1720 }
1721 if (state) {
1722 if (state == active) {
1723 lled |= 0 << i;
1724 } else
1725 if (hc->ledcount >> 11)
1726 lled |= 0 << i;
1727 else
1728 lled |= 1 << i;
1729 } else
1730 lled |= 1 << i;
1731 }
1732 leddw = lled << 24 | lled << 16 | lled << 8 | lled;
1733 if (leddw != hc->ledstate) {
1734 /* HFC_outb(hc, R_BRG_PCM_CFG, 1);
1735 HFC_outb(c, R_BRG_PCM_CFG, (0x0 << 6) | 0x3); */
1736 /* was _io before */
1737 HFC_outb_nodebug(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK);
1738 outw(0x4000, hc->pci_iobase + 4);
1739 outl(leddw, hc->pci_iobase);
1740 HFC_outb_nodebug(hc, R_BRG_PCM_CFG, V_PCM_CLK);
1741 hc->ledstate = leddw;
1742 }
1743 break;
1744 }
1745}
1746/*
1747 * read dtmf coefficients
1748 */
1749
1750static void
1751hfcmulti_dtmf(struct hfc_multi *hc)
1752{
1753 s32 *coeff;
1754 u_int mantissa;
1755 int co, ch;
1756 struct bchannel *bch = NULL;
1757 u8 exponent;
1758 int dtmf = 0;
1759 int addr;
1760 u16 w_float;
1761 struct sk_buff *skb;
1762 struct mISDNhead *hh;
1763
1764 if (debug & DEBUG_HFCMULTI_DTMF)
1765 printk(KERN_DEBUG "%s: dtmf detection irq\n", __func__);
1766 for (ch = 0; ch <= 31; ch++) {
1767 /* only process enabled B-channels */
1768 bch = hc->chan[ch].bch;
1769 if (!bch)
1770 continue;
1771 if (!hc->created[hc->chan[ch].port])
1772 continue;
1773 if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
1774 continue;
1775 if (debug & DEBUG_HFCMULTI_DTMF)
1776 printk(KERN_DEBUG "%s: dtmf channel %d:",
1777 __func__, ch);
1778 coeff = &(hc->chan[ch].coeff[hc->chan[ch].coeff_count * 16]);
1779 dtmf = 1;
1780 for (co = 0; co < 8; co++) {
1781 /* read W(n-1) coefficient */
1782 addr = hc->DTMFbase + ((co<<7) | (ch<<2));
1783 HFC_outb_nodebug(hc, R_RAM_ADDR0, addr);
1784 HFC_outb_nodebug(hc, R_RAM_ADDR1, addr>>8);
1785 HFC_outb_nodebug(hc, R_RAM_ADDR2, (addr>>16)
1786 | V_ADDR_INC);
1787 w_float = HFC_inb_nodebug(hc, R_RAM_DATA);
1788 w_float |= (HFC_inb_nodebug(hc, R_RAM_DATA) << 8);
1789 if (debug & DEBUG_HFCMULTI_DTMF)
1790 printk(" %04x", w_float);
1791
1792 /* decode float (see chip doc) */
1793 mantissa = w_float & 0x0fff;
1794 if (w_float & 0x8000)
1795 mantissa |= 0xfffff000;
1796 exponent = (w_float>>12) & 0x7;
1797 if (exponent) {
1798 mantissa ^= 0x1000;
1799 mantissa <<= (exponent-1);
1800 }
1801
1802 /* store coefficient */
1803 coeff[co<<1] = mantissa;
1804
1805 /* read W(n) coefficient */
1806 w_float = HFC_inb_nodebug(hc, R_RAM_DATA);
1807 w_float |= (HFC_inb_nodebug(hc, R_RAM_DATA) << 8);
1808 if (debug & DEBUG_HFCMULTI_DTMF)
1809 printk(" %04x", w_float);
1810
1811 /* decode float (see chip doc) */
1812 mantissa = w_float & 0x0fff;
1813 if (w_float & 0x8000)
1814 mantissa |= 0xfffff000;
1815 exponent = (w_float>>12) & 0x7;
1816 if (exponent) {
1817 mantissa ^= 0x1000;
1818 mantissa <<= (exponent-1);
1819 }
1820
1821 /* store coefficient */
1822 coeff[(co<<1)|1] = mantissa;
1823 }
1824 if (debug & DEBUG_HFCMULTI_DTMF)
1825 printk("%s: DTMF ready %08x %08x %08x %08x "
1826 "%08x %08x %08x %08x\n", __func__,
1827 coeff[0], coeff[1], coeff[2], coeff[3],
1828 coeff[4], coeff[5], coeff[6], coeff[7]);
1829 hc->chan[ch].coeff_count++;
1830 if (hc->chan[ch].coeff_count == 8) {
1831 hc->chan[ch].coeff_count = 0;
1832 skb = mI_alloc_skb(512, GFP_ATOMIC);
1833 if (!skb) {
1834 printk(KERN_WARNING "%s: No memory for skb\n",
1835 __func__);
1836 continue;
1837 }
1838 hh = mISDN_HEAD_P(skb);
1839 hh->prim = PH_CONTROL_IND;
1840 hh->id = DTMF_HFC_COEF;
1841 memcpy(skb_put(skb, 512), hc->chan[ch].coeff, 512);
1842 recv_Bchannel_skb(bch, skb);
1843 }
1844 }
1845
1846 /* restart DTMF processing */
1847 hc->dtmf = dtmf;
1848 if (dtmf)
1849 HFC_outb_nodebug(hc, R_DTMF, hc->hw.r_dtmf | V_RST_DTMF);
1850}
1851
1852
1853/*
1854 * fill fifo as much as possible
1855 */
1856
1857static void
1858hfcmulti_tx(struct hfc_multi *hc, int ch)
1859{
1860 int i, ii, temp, len = 0;
1861 int Zspace, z1, z2; /* must be int for calculation */
1862 int Fspace, f1, f2;
1863 u_char *d;
1864 int *txpending, slot_tx;
1865 struct bchannel *bch;
1866 struct dchannel *dch;
1867 struct sk_buff **sp = NULL;
1868 int *idxp;
1869
1870 bch = hc->chan[ch].bch;
1871 dch = hc->chan[ch].dch;
1872 if ((!dch) && (!bch))
1873 return;
1874
1875 txpending = &hc->chan[ch].txpending;
1876 slot_tx = hc->chan[ch].slot_tx;
1877 if (dch) {
1878 if (!test_bit(FLG_ACTIVE, &dch->Flags))
1879 return;
1880 sp = &dch->tx_skb;
1881 idxp = &dch->tx_idx;
1882 } else {
1883 if (!test_bit(FLG_ACTIVE, &bch->Flags))
1884 return;
1885 sp = &bch->tx_skb;
1886 idxp = &bch->tx_idx;
1887 }
1888 if (*sp)
1889 len = (*sp)->len;
1890
1891 if ((!len) && *txpending != 1)
1892 return; /* no data */
1893
1894 if (test_bit(HFC_CHIP_B410P, &hc->chip) &&
1895 (hc->chan[ch].protocol == ISDN_P_B_RAW) &&
1896 (hc->chan[ch].slot_rx < 0) &&
1897 (hc->chan[ch].slot_tx < 0))
1898 HFC_outb_nodebug(hc, R_FIFO, 0x20 | (ch << 1));
1899 else
1900 HFC_outb_nodebug(hc, R_FIFO, ch << 1);
1901 HFC_wait_nodebug(hc);
1902
1903 if (*txpending == 2) {
1904 /* reset fifo */
1905 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F);
1906 HFC_wait_nodebug(hc);
1907 HFC_outb(hc, A_SUBCH_CFG, 0);
1908 *txpending = 1;
1909 }
1910next_frame:
1911 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
1912 f1 = HFC_inb_nodebug(hc, A_F1);
1913 f2 = HFC_inb_nodebug(hc, A_F2);
1914 while (f2 != (temp = HFC_inb_nodebug(hc, A_F2))) {
1915 if (debug & DEBUG_HFCMULTI_FIFO)
1916 printk(KERN_DEBUG
1917 "%s(card %d): reread f2 because %d!=%d\n",
1918 __func__, hc->id + 1, temp, f2);
1919 f2 = temp; /* repeat until F2 is equal */
1920 }
1921 Fspace = f2 - f1 - 1;
1922 if (Fspace < 0)
1923 Fspace += hc->Flen;
1924 /*
1925 * Old FIFO handling doesn't give us the current Z2 read
1926 * pointer, so we cannot send the next frame before the fifo
1927 * is empty. It makes no difference except for a slightly
1928 * lower performance.
1929 */
1930 if (test_bit(HFC_CHIP_REVISION0, &hc->chip)) {
1931 if (f1 != f2)
1932 Fspace = 0;
1933 else
1934 Fspace = 1;
1935 }
1936 /* one frame only for ST D-channels, to allow resending */
1937 if (hc->type != 1 && dch) {
1938 if (f1 != f2)
1939 Fspace = 0;
1940 }
1941 /* F-counter full condition */
1942 if (Fspace == 0)
1943 return;
1944 }
1945 z1 = HFC_inw_nodebug(hc, A_Z1) - hc->Zmin;
1946 z2 = HFC_inw_nodebug(hc, A_Z2) - hc->Zmin;
1947 while (z2 != (temp = (HFC_inw_nodebug(hc, A_Z2) - hc->Zmin))) {
1948 if (debug & DEBUG_HFCMULTI_FIFO)
1949 printk(KERN_DEBUG "%s(card %d): reread z2 because "
1950 "%d!=%d\n", __func__, hc->id + 1, temp, z2);
1951 z2 = temp; /* repeat unti Z2 is equal */
1952 }
1953 Zspace = z2 - z1;
1954 if (Zspace <= 0)
1955 Zspace += hc->Zlen;
1956 Zspace -= 4; /* keep not too full, so pointers will not overrun */
1957 /* fill transparent data only to maxinum transparent load (minus 4) */
1958 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags))
1959 Zspace = Zspace - hc->Zlen + hc->max_trans;
1960 if (Zspace <= 0) /* no space of 4 bytes */
1961 return;
1962
1963 /* if no data */
1964 if (!len) {
1965 if (z1 == z2) { /* empty */
1966 /* if done with FIFO audio data during PCM connection */
1967 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) &&
1968 *txpending && slot_tx >= 0) {
1969 if (debug & DEBUG_HFCMULTI_MODE)
1970 printk(KERN_DEBUG
1971 "%s: reconnecting PCM due to no "
1972 "more FIFO data: channel %d "
1973 "slot_tx %d\n",
1974 __func__, ch, slot_tx);
1975 /* connect slot */
1976 HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
1977 V_HDLC_TRP | V_IFF);
1978 HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1);
1979 HFC_wait_nodebug(hc);
1980 HFC_outb(hc, A_CON_HDLC, 0xc0 | 0x00 |
1981 V_HDLC_TRP | V_IFF);
1982 HFC_outb_nodebug(hc, R_FIFO, ch<<1);
1983 HFC_wait_nodebug(hc);
1984 }
1985 *txpending = 0;
1986 }
1987 return; /* no data */
1988 }
1989
1990 /* if audio data and connected slot */
1991 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && (!*txpending)
1992 && slot_tx >= 0) {
1993 if (debug & DEBUG_HFCMULTI_MODE)
1994 printk(KERN_DEBUG "%s: disconnecting PCM due to "
1995 "FIFO data: channel %d slot_tx %d\n",
1996 __func__, ch, slot_tx);
1997 /* disconnect slot */
1998 HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | V_HDLC_TRP | V_IFF);
1999 HFC_outb_nodebug(hc, R_FIFO, ch<<1 | 1);
2000 HFC_wait_nodebug(hc);
2001 HFC_outb(hc, A_CON_HDLC, 0x80 | 0x00 | V_HDLC_TRP | V_IFF);
2002 HFC_outb_nodebug(hc, R_FIFO, ch<<1);
2003 HFC_wait_nodebug(hc);
2004 }
2005 *txpending = 1;
2006
2007 /* show activity */
2008 hc->activity[hc->chan[ch].port] = 1;
2009
2010 /* fill fifo to what we have left */
2011 ii = len;
2012 if (dch || test_bit(FLG_HDLC, &bch->Flags))
2013 temp = 1;
2014 else
2015 temp = 0;
2016 i = *idxp;
2017 d = (*sp)->data + i;
2018 if (ii - i > Zspace)
2019 ii = Zspace + i;
2020 if (debug & DEBUG_HFCMULTI_FIFO)
2021 printk(KERN_DEBUG "%s(card %d): fifo(%d) has %d bytes space "
2022 "left (z1=%04x, z2=%04x) sending %d of %d bytes %s\n",
2023 __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i,
2024 temp ? "HDLC":"TRANS");
2025
2026
2027 /* Have to prep the audio data */
2028 hc->write_fifo(hc, d, ii - i);
2029 *idxp = ii;
2030
2031 /* if not all data has been written */
2032 if (ii != len) {
2033 /* NOTE: fifo is started by the calling function */
2034 return;
2035 }
2036
2037 /* if all data has been written, terminate frame */
2038 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
2039 /* increment f-counter */
2040 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_INC_F);
2041 HFC_wait_nodebug(hc);
2042 }
2043
2044 /* send confirm, since get_net_bframe will not do it with trans */
2045 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags))
2046 confirm_Bsend(bch);
2047
2048 /* check for next frame */
2049 dev_kfree_skb(*sp);
2050 if (bch && get_next_bframe(bch)) { /* hdlc is confirmed here */
2051 len = (*sp)->len;
2052 goto next_frame;
2053 }
2054 if (dch && get_next_dframe(dch)) {
2055 len = (*sp)->len;
2056 goto next_frame;
2057 }
2058
2059 /*
2060 * now we have no more data, so in case of transparent,
2061 * we set the last byte in fifo to 'silence' in case we will get
2062 * no more data at all. this prevents sending an undefined value.
2063 */
2064 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags))
2065 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence);
2066}
2067
2068
2069/* NOTE: only called if E1 card is in active state */
2070static void
2071hfcmulti_rx(struct hfc_multi *hc, int ch)
2072{
2073 int temp;
2074 int Zsize, z1, z2 = 0; /* = 0, to make GCC happy */
2075 int f1 = 0, f2 = 0; /* = 0, to make GCC happy */
2076 int again = 0;
2077 struct bchannel *bch;
2078 struct dchannel *dch;
2079 struct sk_buff *skb, **sp = NULL;
2080 int maxlen;
2081
2082 bch = hc->chan[ch].bch;
2083 dch = hc->chan[ch].dch;
2084 if ((!dch) && (!bch))
2085 return;
2086 if (dch) {
2087 if (!test_bit(FLG_ACTIVE, &dch->Flags))
2088 return;
2089 sp = &dch->rx_skb;
2090 maxlen = dch->maxlen;
2091 } else {
2092 if (!test_bit(FLG_ACTIVE, &bch->Flags))
2093 return;
2094 sp = &bch->rx_skb;
2095 maxlen = bch->maxlen;
2096 }
2097next_frame:
2098 /* on first AND before getting next valid frame, R_FIFO must be written
2099 to. */
2100 if (test_bit(HFC_CHIP_B410P, &hc->chip) &&
2101 (hc->chan[ch].protocol == ISDN_P_B_RAW) &&
2102 (hc->chan[ch].slot_rx < 0) &&
2103 (hc->chan[ch].slot_tx < 0))
2104 HFC_outb_nodebug(hc, R_FIFO, 0x20 | (ch<<1) | 1);
2105 else
2106 HFC_outb_nodebug(hc, R_FIFO, (ch<<1)|1);
2107 HFC_wait_nodebug(hc);
2108
2109 /* ignore if rx is off BUT change fifo (above) to start pending TX */
2110 if (hc->chan[ch].rx_off)
2111 return;
2112
2113 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
2114 f1 = HFC_inb_nodebug(hc, A_F1);
2115 while (f1 != (temp = HFC_inb_nodebug(hc, A_F1))) {
2116 if (debug & DEBUG_HFCMULTI_FIFO)
2117 printk(KERN_DEBUG
2118 "%s(card %d): reread f1 because %d!=%d\n",
2119 __func__, hc->id + 1, temp, f1);
2120 f1 = temp; /* repeat until F1 is equal */
2121 }
2122 f2 = HFC_inb_nodebug(hc, A_F2);
2123 }
2124 z1 = HFC_inw_nodebug(hc, A_Z1) - hc->Zmin;
2125 while (z1 != (temp = (HFC_inw_nodebug(hc, A_Z1) - hc->Zmin))) {
2126 if (debug & DEBUG_HFCMULTI_FIFO)
2127 printk(KERN_DEBUG "%s(card %d): reread z2 because "
2128 "%d!=%d\n", __func__, hc->id + 1, temp, z2);
2129 z1 = temp; /* repeat until Z1 is equal */
2130 }
2131 z2 = HFC_inw_nodebug(hc, A_Z2) - hc->Zmin;
2132 Zsize = z1 - z2;
2133 if ((dch || test_bit(FLG_HDLC, &bch->Flags)) && f1 != f2)
2134 /* complete hdlc frame */
2135 Zsize++;
2136 if (Zsize < 0)
2137 Zsize += hc->Zlen;
2138 /* if buffer is empty */
2139 if (Zsize <= 0)
2140 return;
2141
2142 if (*sp == NULL) {
2143 *sp = mI_alloc_skb(maxlen + 3, GFP_ATOMIC);
2144 if (*sp == NULL) {
2145 printk(KERN_DEBUG "%s: No mem for rx_skb\n",
2146 __func__);
2147 return;
2148 }
2149 }
2150 /* show activity */
2151 hc->activity[hc->chan[ch].port] = 1;
2152
2153 /* empty fifo with what we have */
2154 if (dch || test_bit(FLG_HDLC, &bch->Flags)) {
2155 if (debug & DEBUG_HFCMULTI_FIFO)
2156 printk(KERN_DEBUG "%s(card %d): fifo(%d) reading %d "
2157 "bytes (z1=%04x, z2=%04x) HDLC %s (f1=%d, f2=%d) "
2158 "got=%d (again %d)\n", __func__, hc->id + 1, ch,
2159 Zsize, z1, z2, (f1 == f2) ? "fragment" : "COMPLETE",
2160 f1, f2, Zsize + (*sp)->len, again);
2161 /* HDLC */
2162 if ((Zsize + (*sp)->len) > (maxlen + 3)) {
2163 if (debug & DEBUG_HFCMULTI_FIFO)
2164 printk(KERN_DEBUG
2165 "%s(card %d): hdlc-frame too large.\n",
2166 __func__, hc->id + 1);
2167 skb_trim(*sp, 0);
2168 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F);
2169 HFC_wait_nodebug(hc);
2170 return;
2171 }
2172
2173 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize);
2174
2175 if (f1 != f2) {
2176 /* increment Z2,F2-counter */
2177 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_INC_F);
2178 HFC_wait_nodebug(hc);
2179 /* check size */
2180 if ((*sp)->len < 4) {
2181 if (debug & DEBUG_HFCMULTI_FIFO)
2182 printk(KERN_DEBUG
2183 "%s(card %d): Frame below minimum "
2184 "size\n", __func__, hc->id + 1);
2185 skb_trim(*sp, 0);
2186 goto next_frame;
2187 }
2188 /* there is at least one complete frame, check crc */
2189 if ((*sp)->data[(*sp)->len - 1]) {
2190 if (debug & DEBUG_HFCMULTI_CRC)
2191 printk(KERN_DEBUG
2192 "%s: CRC-error\n", __func__);
2193 skb_trim(*sp, 0);
2194 goto next_frame;
2195 }
2196 skb_trim(*sp, (*sp)->len - 3);
2197 if ((*sp)->len < MISDN_COPY_SIZE) {
2198 skb = *sp;
2199 *sp = mI_alloc_skb(skb->len, GFP_ATOMIC);
2200 if (*sp) {
2201 memcpy(skb_put(*sp, skb->len),
2202 skb->data, skb->len);
2203 skb_trim(skb, 0);
2204 } else {
2205 printk(KERN_DEBUG "%s: No mem\n",
2206 __func__);
2207 *sp = skb;
2208 skb = NULL;
2209 }
2210 } else {
2211 skb = NULL;
2212 }
2213 if (debug & DEBUG_HFCMULTI_FIFO) {
2214 printk(KERN_DEBUG "%s(card %d):",
2215 __func__, hc->id + 1);
2216 temp = 0;
2217 while (temp < (*sp)->len)
2218 printk(" %02x", (*sp)->data[temp++]);
2219 printk("\n");
2220 }
2221 if (dch)
2222 recv_Dchannel(dch);
2223 else
2224 recv_Bchannel(bch);
2225 *sp = skb;
2226 again++;
2227 goto next_frame;
2228 }
2229 /* there is an incomplete frame */
2230 } else {
2231 /* transparent */
2232 if (Zsize > skb_tailroom(*sp))
2233 Zsize = skb_tailroom(*sp);
2234 hc->read_fifo(hc, skb_put(*sp, Zsize), Zsize);
2235 if (((*sp)->len) < MISDN_COPY_SIZE) {
2236 skb = *sp;
2237 *sp = mI_alloc_skb(skb->len, GFP_ATOMIC);
2238 if (*sp) {
2239 memcpy(skb_put(*sp, skb->len),
2240 skb->data, skb->len);
2241 skb_trim(skb, 0);
2242 } else {
2243 printk(KERN_DEBUG "%s: No mem\n", __func__);
2244 *sp = skb;
2245 skb = NULL;
2246 }
2247 } else {
2248 skb = NULL;
2249 }
2250 if (debug & DEBUG_HFCMULTI_FIFO)
2251 printk(KERN_DEBUG
2252 "%s(card %d): fifo(%d) reading %d bytes "
2253 "(z1=%04x, z2=%04x) TRANS\n",
2254 __func__, hc->id + 1, ch, Zsize, z1, z2);
2255 /* only bch is transparent */
2256 recv_Bchannel(bch);
2257 *sp = skb;
2258 }
2259}
2260
2261
2262/*
2263 * Interrupt handler
2264 */
2265static void
2266signal_state_up(struct dchannel *dch, int info, char *msg)
2267{
2268 struct sk_buff *skb;
2269 int id, data = info;
2270
2271 if (debug & DEBUG_HFCMULTI_STATE)
2272 printk(KERN_DEBUG "%s: %s\n", __func__, msg);
2273
2274 id = TEI_SAPI | (GROUP_TEI << 8); /* manager address */
2275
2276 skb = _alloc_mISDN_skb(MPH_INFORMATION_IND, id, sizeof(data), &data,
2277 GFP_ATOMIC);
2278 if (!skb)
2279 return;
2280 recv_Dchannel_skb(dch, skb);
2281}
2282
2283static inline void
2284handle_timer_irq(struct hfc_multi *hc)
2285{
2286 int ch, temp;
2287 struct dchannel *dch;
2288 u_long flags;
2289
2290 /* process queued resync jobs */
2291 if (hc->e1_resync) {
2292 /* lock, so e1_resync gets not changed */
2293 spin_lock_irqsave(&HFClock, flags);
2294 if (hc->e1_resync & 1) {
2295 if (debug & DEBUG_HFCMULTI_PLXSD)
2296 printk(KERN_DEBUG "Enable SYNC_I\n");
2297 HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC);
2298 /* disable JATT, if RX_SYNC is set */
2299 if (test_bit(HFC_CHIP_RX_SYNC, &hc->chip))
2300 HFC_outb(hc, R_SYNC_OUT, V_SYNC_E1_RX);
2301 }
2302 if (hc->e1_resync & 2) {
2303 if (debug & DEBUG_HFCMULTI_PLXSD)
2304 printk(KERN_DEBUG "Enable jatt PLL\n");
2305 HFC_outb(hc, R_SYNC_CTRL, V_SYNC_OFFS);
2306 }
2307 if (hc->e1_resync & 4) {
2308 if (debug & DEBUG_HFCMULTI_PLXSD)
2309 printk(KERN_DEBUG
2310 "Enable QUARTZ for HFC-E1\n");
2311 /* set jatt to quartz */
2312 HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC
2313 | V_JATT_OFF);
2314 /* switch to JATT, in case it is not already */
2315 HFC_outb(hc, R_SYNC_OUT, 0);
2316 }
2317 hc->e1_resync = 0;
2318 spin_unlock_irqrestore(&HFClock, flags);
2319 }
2320
2321 if (hc->type != 1 || hc->e1_state == 1)
2322 for (ch = 0; ch <= 31; ch++) {
2323 if (hc->created[hc->chan[ch].port]) {
2324 hfcmulti_tx(hc, ch);
2325 /* fifo is started when switching to rx-fifo */
2326 hfcmulti_rx(hc, ch);
2327 if (hc->chan[ch].dch &&
2328 hc->chan[ch].nt_timer > -1) {
2329 dch = hc->chan[ch].dch;
2330 if (!(--hc->chan[ch].nt_timer)) {
2331 schedule_event(dch,
2332 FLG_PHCHANGE);
2333 if (debug &
2334 DEBUG_HFCMULTI_STATE)
2335 printk(KERN_DEBUG
2336 "%s: nt_timer at "
2337 "state %x\n",
2338 __func__,
2339 dch->state);
2340 }
2341 }
2342 }
2343 }
2344 if (hc->type == 1 && hc->created[0]) {
2345 dch = hc->chan[hc->dslot].dch;
2346 if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
2347 /* LOS */
2348 temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_SIG_LOS;
2349 if (!temp && hc->chan[hc->dslot].los)
2350 signal_state_up(dch, L1_SIGNAL_LOS_ON,
2351 "LOS detected");
2352 if (temp && !hc->chan[hc->dslot].los)
2353 signal_state_up(dch, L1_SIGNAL_LOS_OFF,
2354 "LOS gone");
2355 hc->chan[hc->dslot].los = temp;
2356 }
2357 if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dslot].cfg)) {
2358 /* AIS */
2359 temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_AIS;
2360 if (!temp && hc->chan[hc->dslot].ais)
2361 signal_state_up(dch, L1_SIGNAL_AIS_ON,
2362 "AIS detected");
2363 if (temp && !hc->chan[hc->dslot].ais)
2364 signal_state_up(dch, L1_SIGNAL_AIS_OFF,
2365 "AIS gone");
2366 hc->chan[hc->dslot].ais = temp;
2367 }
2368 if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dslot].cfg)) {
2369 /* SLIP */
2370 temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_RX;
2371 if (!temp && hc->chan[hc->dslot].slip_rx)
2372 signal_state_up(dch, L1_SIGNAL_SLIP_RX,
2373 " bit SLIP detected RX");
2374 hc->chan[hc->dslot].slip_rx = temp;
2375 temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_TX;
2376 if (!temp && hc->chan[hc->dslot].slip_tx)
2377 signal_state_up(dch, L1_SIGNAL_SLIP_TX,
2378 " bit SLIP detected TX");
2379 hc->chan[hc->dslot].slip_tx = temp;
2380 }
2381 if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dslot].cfg)) {
2382 /* RDI */
2383 temp = HFC_inb_nodebug(hc, R_RX_SL0_0) & V_A;
2384 if (!temp && hc->chan[hc->dslot].rdi)
2385 signal_state_up(dch, L1_SIGNAL_RDI_ON,
2386 "RDI detected");
2387 if (temp && !hc->chan[hc->dslot].rdi)
2388 signal_state_up(dch, L1_SIGNAL_RDI_OFF,
2389 "RDI gone");
2390 hc->chan[hc->dslot].rdi = temp;
2391 }
2392 temp = HFC_inb_nodebug(hc, R_JATT_DIR);
2393 switch (hc->chan[hc->dslot].sync) {
2394 case 0:
2395 if ((temp & 0x60) == 0x60) {
2396 if (debug & DEBUG_HFCMULTI_SYNC)
2397 printk(KERN_DEBUG
2398 "%s: (id=%d) E1 now "
2399 "in clock sync\n",
2400 __func__, hc->id);
2401 HFC_outb(hc, R_RX_OFF,
2402 hc->chan[hc->dslot].jitter | V_RX_INIT);
2403 HFC_outb(hc, R_TX_OFF,
2404 hc->chan[hc->dslot].jitter | V_RX_INIT);
2405 hc->chan[hc->dslot].sync = 1;
2406 goto check_framesync;
2407 }
2408 break;
2409 case 1:
2410 if ((temp & 0x60) != 0x60) {
2411 if (debug & DEBUG_HFCMULTI_SYNC)
2412 printk(KERN_DEBUG
2413 "%s: (id=%d) E1 "
2414 "lost clock sync\n",
2415 __func__, hc->id);
2416 hc->chan[hc->dslot].sync = 0;
2417 break;
2418 }
2419check_framesync:
2420 temp = HFC_inb_nodebug(hc, R_SYNC_STA);
2421 if (temp == 0x27) {
2422 if (debug & DEBUG_HFCMULTI_SYNC)
2423 printk(KERN_DEBUG
2424 "%s: (id=%d) E1 "
2425 "now in frame sync\n",
2426 __func__, hc->id);
2427 hc->chan[hc->dslot].sync = 2;
2428 }
2429 break;
2430 case 2:
2431 if ((temp & 0x60) != 0x60) {
2432 if (debug & DEBUG_HFCMULTI_SYNC)
2433 printk(KERN_DEBUG
2434 "%s: (id=%d) E1 lost "
2435 "clock & frame sync\n",
2436 __func__, hc->id);
2437 hc->chan[hc->dslot].sync = 0;
2438 break;
2439 }
2440 temp = HFC_inb_nodebug(hc, R_SYNC_STA);
2441 if (temp != 0x27) {
2442 if (debug & DEBUG_HFCMULTI_SYNC)
2443 printk(KERN_DEBUG
2444 "%s: (id=%d) E1 "
2445 "lost frame sync\n",
2446 __func__, hc->id);
2447 hc->chan[hc->dslot].sync = 1;
2448 }
2449 break;
2450 }
2451 }
2452
2453 if (test_bit(HFC_CHIP_WATCHDOG, &hc->chip))
2454 hfcmulti_watchdog(hc);
2455
2456 if (hc->leds)
2457 hfcmulti_leds(hc);
2458}
2459
2460static void
2461ph_state_irq(struct hfc_multi *hc, u_char r_irq_statech)
2462{
2463 struct dchannel *dch;
2464 int ch;
2465 int active;
2466 u_char st_status, temp;
2467
2468 /* state machine */
2469 for (ch = 0; ch <= 31; ch++) {
2470 if (hc->chan[ch].dch) {
2471 dch = hc->chan[ch].dch;
2472 if (r_irq_statech & 1) {
2473 HFC_outb_nodebug(hc, R_ST_SEL,
2474 hc->chan[ch].port);
2475 /* undocumented: delay after R_ST_SEL */
2476 udelay(1);
2477 /* undocumented: status changes during read */
2478 st_status = HFC_inb_nodebug(hc, A_ST_RD_STATE);
2479 while (st_status != (temp =
2480 HFC_inb_nodebug(hc, A_ST_RD_STATE))) {
2481 if (debug & DEBUG_HFCMULTI_STATE)
2482 printk(KERN_DEBUG "%s: reread "
2483 "STATE because %d!=%d\n",
2484 __func__, temp,
2485 st_status);
2486 st_status = temp; /* repeat */
2487 }
2488
2489 /* Speech Design TE-sync indication */
2490 if (test_bit(HFC_CHIP_PLXSD, &hc->chip) &&
2491 dch->dev.D.protocol == ISDN_P_TE_S0) {
2492 if (st_status & V_FR_SYNC_ST)
2493 hc->syncronized |=
2494 (1 << hc->chan[ch].port);
2495 else
2496 hc->syncronized &=
2497 ~(1 << hc->chan[ch].port);
2498 }
2499 dch->state = st_status & 0x0f;
2500 if (dch->dev.D.protocol == ISDN_P_NT_S0)
2501 active = 3;
2502 else
2503 active = 7;
2504 if (dch->state == active) {
2505 HFC_outb_nodebug(hc, R_FIFO,
2506 (ch << 1) | 1);
2507 HFC_wait_nodebug(hc);
2508 HFC_outb_nodebug(hc,
2509 R_INC_RES_FIFO, V_RES_F);
2510 HFC_wait_nodebug(hc);
2511 dch->tx_idx = 0;
2512 }
2513 schedule_event(dch, FLG_PHCHANGE);
2514 if (debug & DEBUG_HFCMULTI_STATE)
2515 printk(KERN_DEBUG
2516 "%s: S/T newstate %x port %d\n",
2517 __func__, dch->state,
2518 hc->chan[ch].port);
2519 }
2520 r_irq_statech >>= 1;
2521 }
2522 }
2523 if (test_bit(HFC_CHIP_PLXSD, &hc->chip))
2524 plxsd_checksync(hc, 0);
2525}
2526
2527static void
2528fifo_irq(struct hfc_multi *hc, int block)
2529{
2530 int ch, j;
2531 struct dchannel *dch;
2532 struct bchannel *bch;
2533 u_char r_irq_fifo_bl;
2534
2535 r_irq_fifo_bl = HFC_inb_nodebug(hc, R_IRQ_FIFO_BL0 + block);
2536 j = 0;
2537 while (j < 8) {
2538 ch = (block << 2) + (j >> 1);
2539 dch = hc->chan[ch].dch;
2540 bch = hc->chan[ch].bch;
2541 if (((!dch) && (!bch)) || (!hc->created[hc->chan[ch].port])) {
2542 j += 2;
2543 continue;
2544 }
2545 if (dch && (r_irq_fifo_bl & (1 << j)) &&
2546 test_bit(FLG_ACTIVE, &dch->Flags)) {
2547 hfcmulti_tx(hc, ch);
2548 /* start fifo */
2549 HFC_outb_nodebug(hc, R_FIFO, 0);
2550 HFC_wait_nodebug(hc);
2551 }
2552 if (bch && (r_irq_fifo_bl & (1 << j)) &&
2553 test_bit(FLG_ACTIVE, &bch->Flags)) {
2554 hfcmulti_tx(hc, ch);
2555 /* start fifo */
2556 HFC_outb_nodebug(hc, R_FIFO, 0);
2557 HFC_wait_nodebug(hc);
2558 }
2559 j++;
2560 if (dch && (r_irq_fifo_bl & (1 << j)) &&
2561 test_bit(FLG_ACTIVE, &dch->Flags)) {
2562 hfcmulti_rx(hc, ch);
2563 }
2564 if (bch && (r_irq_fifo_bl & (1 << j)) &&
2565 test_bit(FLG_ACTIVE, &bch->Flags)) {
2566 hfcmulti_rx(hc, ch);
2567 }
2568 j++;
2569 }
2570}
2571
2572#ifdef IRQ_DEBUG
2573int irqsem;
2574#endif
2575static irqreturn_t
2576hfcmulti_interrupt(int intno, void *dev_id)
2577{
2578#ifdef IRQCOUNT_DEBUG
2579 static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0,
2580 iq5 = 0, iq6 = 0, iqcnt = 0;
2581#endif
2582 static int count;
2583 struct hfc_multi *hc = dev_id;
2584 struct dchannel *dch;
2585 u_char r_irq_statech, status, r_irq_misc, r_irq_oview;
2586 int i;
2587 u_short *plx_acc, wval;
2588 u_char e1_syncsta, temp;
2589 u_long flags;
2590
2591 if (!hc) {
2592 printk(KERN_ERR "HFC-multi: Spurious interrupt!\n");
2593 return IRQ_NONE;
2594 }
2595
2596 spin_lock(&hc->lock);
2597
2598#ifdef IRQ_DEBUG
2599 if (irqsem)
2600 printk(KERN_ERR "irq for card %d during irq from "
2601 "card %d, this is no bug.\n", hc->id + 1, irqsem);
2602 irqsem = hc->id + 1;
2603#endif
2604
2605 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
2606 spin_lock_irqsave(&plx_lock, flags);
2607 plx_acc = (u_short *)(hc->plx_membase + PLX_INTCSR);
2608 wval = readw(plx_acc);
2609 spin_unlock_irqrestore(&plx_lock, flags);
2610 if (!(wval & PLX_INTCSR_LINTI1_STATUS))
2611 goto irq_notforus;
2612 }
2613
2614 status = HFC_inb_nodebug(hc, R_STATUS);
2615 r_irq_statech = HFC_inb_nodebug(hc, R_IRQ_STATECH);
2616#ifdef IRQCOUNT_DEBUG
2617 if (r_irq_statech)
2618 iq1++;
2619 if (status & V_DTMF_STA)
2620 iq2++;
2621 if (status & V_LOST_STA)
2622 iq3++;
2623 if (status & V_EXT_IRQSTA)
2624 iq4++;
2625 if (status & V_MISC_IRQSTA)
2626 iq5++;
2627 if (status & V_FR_IRQSTA)
2628 iq6++;
2629 if (iqcnt++ > 5000) {
2630 printk(KERN_ERR "iq1:%x iq2:%x iq3:%x iq4:%x iq5:%x iq6:%x\n",
2631 iq1, iq2, iq3, iq4, iq5, iq6);
2632 iqcnt = 0;
2633 }
2634#endif
2635 if (!r_irq_statech &&
2636 !(status & (V_DTMF_STA | V_LOST_STA | V_EXT_IRQSTA |
2637 V_MISC_IRQSTA | V_FR_IRQSTA))) {
2638 /* irq is not for us */
2639 goto irq_notforus;
2640 }
2641 hc->irqcnt++;
2642 if (r_irq_statech) {
2643 if (hc->type != 1)
2644 ph_state_irq(hc, r_irq_statech);
2645 }
2646 if (status & V_EXT_IRQSTA)
2647 ; /* external IRQ */
2648 if (status & V_LOST_STA) {
2649 /* LOST IRQ */
2650 HFC_outb(hc, R_INC_RES_FIFO, V_RES_LOST); /* clear irq! */
2651 }
2652 if (status & V_MISC_IRQSTA) {
2653 /* misc IRQ */
2654 r_irq_misc = HFC_inb_nodebug(hc, R_IRQ_MISC);
2655 if (r_irq_misc & V_STA_IRQ) {
2656 if (hc->type == 1) {
2657 /* state machine */
2658 dch = hc->chan[hc->dslot].dch;
2659 e1_syncsta = HFC_inb_nodebug(hc, R_SYNC_STA);
2660 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)
2661 && hc->e1_getclock) {
2662 if (e1_syncsta & V_FR_SYNC_E1)
2663 hc->syncronized = 1;
2664 else
2665 hc->syncronized = 0;
2666 }
2667 /* undocumented: status changes during read */
2668 dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA);
2669 while (dch->state != (temp =
2670 HFC_inb_nodebug(hc, R_E1_RD_STA))) {
2671 if (debug & DEBUG_HFCMULTI_STATE)
2672 printk(KERN_DEBUG "%s: reread "
2673 "STATE because %d!=%d\n",
2674 __func__, temp,
2675 dch->state);
2676 dch->state = temp; /* repeat */
2677 }
2678 dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA)
2679 & 0x7;
2680 schedule_event(dch, FLG_PHCHANGE);
2681 if (debug & DEBUG_HFCMULTI_STATE)
2682 printk(KERN_DEBUG
2683 "%s: E1 (id=%d) newstate %x\n",
2684 __func__, hc->id, dch->state);
2685 if (test_bit(HFC_CHIP_PLXSD, &hc->chip))
2686 plxsd_checksync(hc, 0);
2687 }
2688 }
2689 if (r_irq_misc & V_TI_IRQ)
2690 handle_timer_irq(hc);
2691
2692 if (r_irq_misc & V_DTMF_IRQ) {
2693 /* -> DTMF IRQ */
2694 hfcmulti_dtmf(hc);
2695 }
2696 /* TODO: REPLACE !!!! 125 us Interrupts are not acceptable */
2697 if (r_irq_misc & V_IRQ_PROC) {
2698 /* IRQ every 125us */
2699 count++;
2700 /* generate 1kHz signal */
2701 if (count == 8) {
2702 if (hfc_interrupt)
2703 hfc_interrupt();
2704 count = 0;
2705 }
2706 }
2707
2708 }
2709 if (status & V_FR_IRQSTA) {
2710 /* FIFO IRQ */
2711 r_irq_oview = HFC_inb_nodebug(hc, R_IRQ_OVIEW);
2712 for (i = 0; i < 8; i++) {
2713 if (r_irq_oview & (1 << i))
2714 fifo_irq(hc, i);
2715 }
2716 }
2717
2718#ifdef IRQ_DEBUG
2719 irqsem = 0;
2720#endif
2721 spin_unlock(&hc->lock);
2722 return IRQ_HANDLED;
2723
2724irq_notforus:
2725#ifdef IRQ_DEBUG
2726 irqsem = 0;
2727#endif
2728 spin_unlock(&hc->lock);
2729 return IRQ_NONE;
2730}
2731
2732
2733/*
2734 * timer callback for D-chan busy resolution. Currently no function
2735 */
2736
2737static void
2738hfcmulti_dbusy_timer(struct hfc_multi *hc)
2739{
2740}
2741
2742
2743/*
2744 * activate/deactivate hardware for selected channels and mode
2745 *
2746 * configure B-channel with the given protocol
2747 * ch eqals to the HFC-channel (0-31)
2748 * ch is the number of channel (0-4,4-7,8-11,12-15,16-19,20-23,24-27,28-31
2749 * for S/T, 1-31 for E1)
2750 * the hdlc interrupts will be set/unset
2751 */
2752static int
2753mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
2754 int bank_tx, int slot_rx, int bank_rx)
2755{
2756 int flow_tx = 0, flow_rx = 0, routing = 0;
2757 int oslot_tx, oslot_rx;
2758 int conf;
2759
2760 if (ch < 0 || ch > 31)
2761 return EINVAL;
2762 oslot_tx = hc->chan[ch].slot_tx;
2763 oslot_rx = hc->chan[ch].slot_rx;
2764 conf = hc->chan[ch].conf;
2765
2766 if (debug & DEBUG_HFCMULTI_MODE)
2767 printk(KERN_DEBUG
2768 "%s: card %d channel %d protocol %x slot old=%d new=%d "
2769 "bank new=%d (TX) slot old=%d new=%d bank new=%d (RX)\n",
2770 __func__, hc->id, ch, protocol, oslot_tx, slot_tx,
2771 bank_tx, oslot_rx, slot_rx, bank_rx);
2772
2773 if (oslot_tx >= 0 && slot_tx != oslot_tx) {
2774 /* remove from slot */
2775 if (debug & DEBUG_HFCMULTI_MODE)
2776 printk(KERN_DEBUG "%s: remove from slot %d (TX)\n",
2777 __func__, oslot_tx);
2778 if (hc->slot_owner[oslot_tx<<1] == ch) {
2779 HFC_outb(hc, R_SLOT, oslot_tx << 1);
2780 HFC_outb(hc, A_SL_CFG, 0);
2781 HFC_outb(hc, A_CONF, 0);
2782 hc->slot_owner[oslot_tx<<1] = -1;
2783 } else {
2784 if (debug & DEBUG_HFCMULTI_MODE)
2785 printk(KERN_DEBUG
2786 "%s: we are not owner of this tx slot "
2787 "anymore, channel %d is.\n",
2788 __func__, hc->slot_owner[oslot_tx<<1]);
2789 }
2790 }
2791
2792 if (oslot_rx >= 0 && slot_rx != oslot_rx) {
2793 /* remove from slot */
2794 if (debug & DEBUG_HFCMULTI_MODE)
2795 printk(KERN_DEBUG
2796 "%s: remove from slot %d (RX)\n",
2797 __func__, oslot_rx);
2798 if (hc->slot_owner[(oslot_rx << 1) | 1] == ch) {
2799 HFC_outb(hc, R_SLOT, (oslot_rx << 1) | V_SL_DIR);
2800 HFC_outb(hc, A_SL_CFG, 0);
2801 hc->slot_owner[(oslot_rx << 1) | 1] = -1;
2802 } else {
2803 if (debug & DEBUG_HFCMULTI_MODE)
2804 printk(KERN_DEBUG
2805 "%s: we are not owner of this rx slot "
2806 "anymore, channel %d is.\n",
2807 __func__,
2808 hc->slot_owner[(oslot_rx << 1) | 1]);
2809 }
2810 }
2811
2812 if (slot_tx < 0) {
2813 flow_tx = 0x80; /* FIFO->ST */
2814 /* disable pcm slot */
2815 hc->chan[ch].slot_tx = -1;
2816 hc->chan[ch].bank_tx = 0;
2817 } else {
2818 /* set pcm slot */
2819 if (hc->chan[ch].txpending)
2820 flow_tx = 0x80; /* FIFO->ST */
2821 else
2822 flow_tx = 0xc0; /* PCM->ST */
2823 /* put on slot */
2824 routing = bank_tx ? 0xc0 : 0x80;
2825 if (conf >= 0 || bank_tx > 1)
2826 routing = 0x40; /* loop */
2827 if (debug & DEBUG_HFCMULTI_MODE)
2828 printk(KERN_DEBUG "%s: put channel %d to slot %d bank"
2829 " %d flow %02x routing %02x conf %d (TX)\n",
2830 __func__, ch, slot_tx, bank_tx,
2831 flow_tx, routing, conf);
2832 HFC_outb(hc, R_SLOT, slot_tx << 1);
2833 HFC_outb(hc, A_SL_CFG, (ch<<1) | routing);
2834 HFC_outb(hc, A_CONF, (conf < 0) ? 0 : (conf | V_CONF_SL));
2835 hc->slot_owner[slot_tx << 1] = ch;
2836 hc->chan[ch].slot_tx = slot_tx;
2837 hc->chan[ch].bank_tx = bank_tx;
2838 }
2839 if (slot_rx < 0) {
2840 /* disable pcm slot */
2841 flow_rx = 0x80; /* ST->FIFO */
2842 hc->chan[ch].slot_rx = -1;
2843 hc->chan[ch].bank_rx = 0;
2844 } else {
2845 /* set pcm slot */
2846 if (hc->chan[ch].txpending)
2847 flow_rx = 0x80; /* ST->FIFO */
2848 else
2849 flow_rx = 0xc0; /* ST->(FIFO,PCM) */
2850 /* put on slot */
2851 routing = bank_rx?0x80:0xc0; /* reversed */
2852 if (conf >= 0 || bank_rx > 1)
2853 routing = 0x40; /* loop */
2854 if (debug & DEBUG_HFCMULTI_MODE)
2855 printk(KERN_DEBUG "%s: put channel %d to slot %d bank"
2856 " %d flow %02x routing %02x conf %d (RX)\n",
2857 __func__, ch, slot_rx, bank_rx,
2858 flow_rx, routing, conf);
2859 HFC_outb(hc, R_SLOT, (slot_rx<<1) | V_SL_DIR);
2860 HFC_outb(hc, A_SL_CFG, (ch<<1) | V_CH_DIR | routing);
2861 hc->slot_owner[(slot_rx<<1)|1] = ch;
2862 hc->chan[ch].slot_rx = slot_rx;
2863 hc->chan[ch].bank_rx = bank_rx;
2864 }
2865
2866 switch (protocol) {
2867 case (ISDN_P_NONE):
2868 /* disable TX fifo */
2869 HFC_outb(hc, R_FIFO, ch << 1);
2870 HFC_wait(hc);
2871 HFC_outb(hc, A_CON_HDLC, flow_tx | 0x00 | V_IFF);
2872 HFC_outb(hc, A_SUBCH_CFG, 0);
2873 HFC_outb(hc, A_IRQ_MSK, 0);
2874 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2875 HFC_wait(hc);
2876 /* disable RX fifo */
2877 HFC_outb(hc, R_FIFO, (ch<<1)|1);
2878 HFC_wait(hc);
2879 HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00);
2880 HFC_outb(hc, A_SUBCH_CFG, 0);
2881 HFC_outb(hc, A_IRQ_MSK, 0);
2882 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2883 HFC_wait(hc);
2884 if (hc->chan[ch].bch && hc->type != 1) {
2885 hc->hw.a_st_ctrl0[hc->chan[ch].port] &=
2886 ((ch & 0x3) == 0)? ~V_B1_EN: ~V_B2_EN;
2887 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
2888 /* undocumented: delay after R_ST_SEL */
2889 udelay(1);
2890 HFC_outb(hc, A_ST_CTRL0,
2891 hc->hw.a_st_ctrl0[hc->chan[ch].port]);
2892 }
2893 if (hc->chan[ch].bch) {
2894 test_and_clear_bit(FLG_HDLC, &hc->chan[ch].bch->Flags);
2895 test_and_clear_bit(FLG_TRANSPARENT,
2896 &hc->chan[ch].bch->Flags);
2897 }
2898 break;
2899 case (ISDN_P_B_RAW): /* B-channel */
2900
2901 if (test_bit(HFC_CHIP_B410P, &hc->chip) &&
2902 (hc->chan[ch].slot_rx < 0) &&
2903 (hc->chan[ch].slot_tx < 0)) {
2904
2905 printk(KERN_DEBUG
2906 "Setting B-channel %d to echo cancelable "
2907 "state on PCM slot %d\n", ch,
2908 ((ch / 4) * 8) + ((ch % 4) * 4) + 1);
2909 printk(KERN_DEBUG
2910 "Enabling pass through for channel\n");
2911 vpm_out(hc, ch, ((ch / 4) * 8) +
2912 ((ch % 4) * 4) + 1, 0x01);
2913 /* rx path */
2914 /* S/T -> PCM */
2915 HFC_outb(hc, R_FIFO, (ch << 1));
2916 HFC_wait(hc);
2917 HFC_outb(hc, A_CON_HDLC, 0xc0 | V_HDLC_TRP | V_IFF);
2918 HFC_outb(hc, R_SLOT, (((ch / 4) * 8) +
2919 ((ch % 4) * 4) + 1) << 1);
2920 HFC_outb(hc, A_SL_CFG, 0x80 | (ch << 1));
2921
2922 /* PCM -> FIFO */
2923 HFC_outb(hc, R_FIFO, 0x20 | (ch << 1) | 1);
2924 HFC_wait(hc);
2925 HFC_outb(hc, A_CON_HDLC, 0x20 | V_HDLC_TRP | V_IFF);
2926 HFC_outb(hc, A_SUBCH_CFG, 0);
2927 HFC_outb(hc, A_IRQ_MSK, 0);
2928 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2929 HFC_wait(hc);
2930 HFC_outb(hc, R_SLOT, ((((ch / 4) * 8) +
2931 ((ch % 4) * 4) + 1) << 1) | 1);
2932 HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1) | 1);
2933
2934 /* tx path */
2935 /* PCM -> S/T */
2936 HFC_outb(hc, R_FIFO, (ch << 1) | 1);
2937 HFC_wait(hc);
2938 HFC_outb(hc, A_CON_HDLC, 0xc0 | V_HDLC_TRP | V_IFF);
2939 HFC_outb(hc, R_SLOT, ((((ch / 4) * 8) +
2940 ((ch % 4) * 4)) << 1) | 1);
2941 HFC_outb(hc, A_SL_CFG, 0x80 | 0x40 | (ch << 1) | 1);
2942
2943 /* FIFO -> PCM */
2944 HFC_outb(hc, R_FIFO, 0x20 | (ch << 1));
2945 HFC_wait(hc);
2946 HFC_outb(hc, A_CON_HDLC, 0x20 | V_HDLC_TRP | V_IFF);
2947 HFC_outb(hc, A_SUBCH_CFG, 0);
2948 HFC_outb(hc, A_IRQ_MSK, 0);
2949 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2950 HFC_wait(hc);
2951 /* tx silence */
2952 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence);
2953 HFC_outb(hc, R_SLOT, (((ch / 4) * 8) +
2954 ((ch % 4) * 4)) << 1);
2955 HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1));
2956 } else {
2957 /* enable TX fifo */
2958 HFC_outb(hc, R_FIFO, ch << 1);
2959 HFC_wait(hc);
2960 HFC_outb(hc, A_CON_HDLC, flow_tx | 0x00 |
2961 V_HDLC_TRP | V_IFF);
2962 HFC_outb(hc, A_SUBCH_CFG, 0);
2963 HFC_outb(hc, A_IRQ_MSK, 0);
2964 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2965 HFC_wait(hc);
2966 /* tx silence */
2967 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence);
2968 /* enable RX fifo */
2969 HFC_outb(hc, R_FIFO, (ch<<1)|1);
2970 HFC_wait(hc);
2971 HFC_outb(hc, A_CON_HDLC, flow_rx | 0x00 | V_HDLC_TRP);
2972 HFC_outb(hc, A_SUBCH_CFG, 0);
2973 HFC_outb(hc, A_IRQ_MSK, 0);
2974 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2975 HFC_wait(hc);
2976 }
2977 if (hc->type != 1) {
2978 hc->hw.a_st_ctrl0[hc->chan[ch].port] |=
2979 ((ch & 0x3) == 0) ? V_B1_EN : V_B2_EN;
2980 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
2981 /* undocumented: delay after R_ST_SEL */
2982 udelay(1);
2983 HFC_outb(hc, A_ST_CTRL0,
2984 hc->hw.a_st_ctrl0[hc->chan[ch].port]);
2985 }
2986 if (hc->chan[ch].bch)
2987 test_and_set_bit(FLG_TRANSPARENT,
2988 &hc->chan[ch].bch->Flags);
2989 break;
2990 case (ISDN_P_B_HDLC): /* B-channel */
2991 case (ISDN_P_TE_S0): /* D-channel */
2992 case (ISDN_P_NT_S0):
2993 case (ISDN_P_TE_E1):
2994 case (ISDN_P_NT_E1):
2995 /* enable TX fifo */
2996 HFC_outb(hc, R_FIFO, ch<<1);
2997 HFC_wait(hc);
2998 if (hc->type == 1 || hc->chan[ch].bch) {
2999 /* E1 or B-channel */
3000 HFC_outb(hc, A_CON_HDLC, flow_tx | 0x04);
3001 HFC_outb(hc, A_SUBCH_CFG, 0);
3002 } else {
3003 /* D-Channel without HDLC fill flags */
3004 HFC_outb(hc, A_CON_HDLC, flow_tx | 0x04 | V_IFF);
3005 HFC_outb(hc, A_SUBCH_CFG, 2);
3006 }
3007 HFC_outb(hc, A_IRQ_MSK, V_IRQ);
3008 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
3009 HFC_wait(hc);
3010 /* enable RX fifo */
3011 HFC_outb(hc, R_FIFO, (ch<<1)|1);
3012 HFC_wait(hc);
3013 HFC_outb(hc, A_CON_HDLC, flow_rx | 0x04);
3014 if (hc->type == 1 || hc->chan[ch].bch)
3015 HFC_outb(hc, A_SUBCH_CFG, 0); /* full 8 bits */
3016 else
3017 HFC_outb(hc, A_SUBCH_CFG, 2); /* 2 bits dchannel */
3018 HFC_outb(hc, A_IRQ_MSK, V_IRQ);
3019 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
3020 HFC_wait(hc);
3021 if (hc->chan[ch].bch) {
3022 test_and_set_bit(FLG_HDLC, &hc->chan[ch].bch->Flags);
3023 if (hc->type != 1) {
3024 hc->hw.a_st_ctrl0[hc->chan[ch].port] |=
3025 ((ch&0x3) == 0) ? V_B1_EN : V_B2_EN;
3026 HFC_outb(hc, R_ST_SEL, hc->chan[ch].port);
3027 /* undocumented: delay after R_ST_SEL */
3028 udelay(1);
3029 HFC_outb(hc, A_ST_CTRL0,
3030 hc->hw.a_st_ctrl0[hc->chan[ch].port]);
3031 }
3032 }
3033 break;
3034 default:
3035 printk(KERN_DEBUG "%s: protocol not known %x\n",
3036 __func__, protocol);
3037 hc->chan[ch].protocol = ISDN_P_NONE;
3038 return -ENOPROTOOPT;
3039 }
3040 hc->chan[ch].protocol = protocol;
3041 return 0;
3042}
3043
3044
3045/*
3046 * connect/disconnect PCM
3047 */
3048
3049static void
3050hfcmulti_pcm(struct hfc_multi *hc, int ch, int slot_tx, int bank_tx,
3051 int slot_rx, int bank_rx)
3052{
3053 if (slot_rx < 0 || slot_rx < 0 || bank_tx < 0 || bank_rx < 0) {
3054 /* disable PCM */
3055 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, -1, 0, -1, 0);
3056 return;
3057 }
3058
3059 /* enable pcm */
3060 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, slot_tx, bank_tx,
3061 slot_rx, bank_rx);
3062}
3063
3064/*
3065 * set/disable conference
3066 */
3067
3068static void
3069hfcmulti_conf(struct hfc_multi *hc, int ch, int num)
3070{
3071 if (num >= 0 && num <= 7)
3072 hc->chan[ch].conf = num;
3073 else
3074 hc->chan[ch].conf = -1;
3075 mode_hfcmulti(hc, ch, hc->chan[ch].protocol, hc->chan[ch].slot_tx,
3076 hc->chan[ch].bank_tx, hc->chan[ch].slot_rx,
3077 hc->chan[ch].bank_rx);
3078}
3079
3080
3081/*
3082 * set/disable sample loop
3083 */
3084
3085/* NOTE: this function is experimental and therefore disabled */
3086
3087/*
3088 * Layer 1 callback function
3089 */
3090static int
3091hfcm_l1callback(struct dchannel *dch, u_int cmd)
3092{
3093 struct hfc_multi *hc = dch->hw;
3094 u_long flags;
3095
3096 switch (cmd) {
3097 case INFO3_P8:
3098 case INFO3_P10:
3099 break;
3100 case HW_RESET_REQ:
3101 /* start activation */
3102 spin_lock_irqsave(&hc->lock, flags);
3103 if (hc->type == 1) {
3104 if (debug & DEBUG_HFCMULTI_MSG)
3105 printk(KERN_DEBUG
3106 "%s: HW_RESET_REQ no BRI\n",
3107 __func__);
3108 } else {
3109 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port);
3110 /* undocumented: delay after R_ST_SEL */
3111 udelay(1);
3112 HFC_outb(hc, A_ST_WR_STATE, V_ST_LD_STA | 3); /* F3 */
3113 udelay(6); /* wait at least 5,21us */
3114 HFC_outb(hc, A_ST_WR_STATE, 3);
3115 HFC_outb(hc, A_ST_WR_STATE, 3 | (V_ST_ACT*3));
3116 /* activate */
3117 }
3118 spin_unlock_irqrestore(&hc->lock, flags);
3119 l1_event(dch->l1, HW_POWERUP_IND);
3120 break;
3121 case HW_DEACT_REQ:
3122 /* start deactivation */
3123 spin_lock_irqsave(&hc->lock, flags);
3124 if (hc->type == 1) {
3125 if (debug & DEBUG_HFCMULTI_MSG)
3126 printk(KERN_DEBUG
3127 "%s: HW_DEACT_REQ no BRI\n",
3128 __func__);
3129 } else {
3130 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port);
3131 /* undocumented: delay after R_ST_SEL */
3132 udelay(1);
3133 HFC_outb(hc, A_ST_WR_STATE, V_ST_ACT*2);
3134 /* deactivate */
3135 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
3136 hc->syncronized &=
3137 ~(1 << hc->chan[dch->slot].port);
3138 plxsd_checksync(hc, 0);
3139 }
3140 }
3141 skb_queue_purge(&dch->squeue);
3142 if (dch->tx_skb) {
3143 dev_kfree_skb(dch->tx_skb);
3144 dch->tx_skb = NULL;
3145 }
3146 dch->tx_idx = 0;
3147 if (dch->rx_skb) {
3148 dev_kfree_skb(dch->rx_skb);
3149 dch->rx_skb = NULL;
3150 }
3151 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
3152 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags))
3153 del_timer(&dch->timer);
3154 spin_unlock_irqrestore(&hc->lock, flags);
3155 break;
3156 case HW_POWERUP_REQ:
3157 spin_lock_irqsave(&hc->lock, flags);
3158 if (hc->type == 1) {
3159 if (debug & DEBUG_HFCMULTI_MSG)
3160 printk(KERN_DEBUG
3161 "%s: HW_POWERUP_REQ no BRI\n",
3162 __func__);
3163 } else {
3164 HFC_outb(hc, R_ST_SEL, hc->chan[dch->slot].port);
3165 /* undocumented: delay after R_ST_SEL */
3166 udelay(1);
3167 HFC_outb(hc, A_ST_WR_STATE, 3 | 0x10); /* activate */
3168 udelay(6); /* wait at least 5,21us */
3169 HFC_outb(hc, A_ST_WR_STATE, 3); /* activate */
3170 }
3171 spin_unlock_irqrestore(&hc->lock, flags);
3172 break;
3173 case PH_ACTIVATE_IND:
3174 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
3175 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
3176 GFP_ATOMIC);
3177 break;
3178 case PH_DEACTIVATE_IND:
3179 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
3180 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
3181 GFP_ATOMIC);
3182 break;
3183 default:
3184 if (dch->debug & DEBUG_HW)
3185 printk(KERN_DEBUG "%s: unknown command %x\n",
3186 __func__, cmd);
3187 return -1;
3188 }
3189 return 0;
3190}
3191
3192/*
3193 * Layer2 -> Layer 1 Transfer
3194 */
3195
3196static int
3197handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
3198{
3199 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
3200 struct dchannel *dch = container_of(dev, struct dchannel, dev);
3201 struct hfc_multi *hc = dch->hw;
3202 struct mISDNhead *hh = mISDN_HEAD_P(skb);
3203 int ret = -EINVAL;
3204 unsigned int id;
3205 u_long flags;
3206
3207 switch (hh->prim) {
3208 case PH_DATA_REQ:
3209 if (skb->len < 1)
3210 break;
3211 spin_lock_irqsave(&hc->lock, flags);
3212 ret = dchannel_senddata(dch, skb);
3213 if (ret > 0) { /* direct TX */
3214 id = hh->id; /* skb can be freed */
3215 hfcmulti_tx(hc, dch->slot);
3216 ret = 0;
3217 /* start fifo */
3218 HFC_outb(hc, R_FIFO, 0);
3219 HFC_wait(hc);
3220 spin_unlock_irqrestore(&hc->lock, flags);
3221 queue_ch_frame(ch, PH_DATA_CNF, id, NULL);
3222 } else
3223 spin_unlock_irqrestore(&hc->lock, flags);
3224 return ret;
3225 case PH_ACTIVATE_REQ:
3226 if (dch->dev.D.protocol != ISDN_P_TE_S0) {
3227 spin_lock_irqsave(&hc->lock, flags);
3228 ret = 0;
3229 if (debug & DEBUG_HFCMULTI_MSG)
3230 printk(KERN_DEBUG
3231 "%s: PH_ACTIVATE port %d (0..%d)\n",
3232 __func__, hc->chan[dch->slot].port,
3233 hc->ports-1);
3234 /* start activation */
3235 if (hc->type == 1) {
3236 ph_state_change(dch);
3237 if (debug & DEBUG_HFCMULTI_STATE)
3238 printk(KERN_DEBUG
3239 "%s: E1 report state %x \n",
3240 __func__, dch->state);
3241 } else {
3242 HFC_outb(hc, R_ST_SEL,
3243 hc->chan[dch->slot].port);
3244 /* undocumented: delay after R_ST_SEL */
3245 udelay(1);
3246 HFC_outb(hc, A_ST_WR_STATE, V_ST_LD_STA | 1);
3247 /* G1 */
3248 udelay(6); /* wait at least 5,21us */
3249 HFC_outb(hc, A_ST_WR_STATE, 1);
3250 HFC_outb(hc, A_ST_WR_STATE, 1 |
3251 (V_ST_ACT*3)); /* activate */
3252 dch->state = 1;
3253 }
3254 spin_unlock_irqrestore(&hc->lock, flags);
3255 } else
3256 ret = l1_event(dch->l1, hh->prim);
3257 break;
3258 case PH_DEACTIVATE_REQ:
3259 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
3260 if (dch->dev.D.protocol != ISDN_P_TE_S0) {
3261 spin_lock_irqsave(&hc->lock, flags);
3262 if (debug & DEBUG_HFCMULTI_MSG)
3263 printk(KERN_DEBUG
3264 "%s: PH_DEACTIVATE port %d (0..%d)\n",
3265 __func__, hc->chan[dch->slot].port,
3266 hc->ports-1);
3267 /* start deactivation */
3268 if (hc->type == 1) {
3269 if (debug & DEBUG_HFCMULTI_MSG)
3270 printk(KERN_DEBUG
3271 "%s: PH_DEACTIVATE no BRI\n",
3272 __func__);
3273 } else {
3274 HFC_outb(hc, R_ST_SEL,
3275 hc->chan[dch->slot].port);
3276 /* undocumented: delay after R_ST_SEL */
3277 udelay(1);
3278 HFC_outb(hc, A_ST_WR_STATE, V_ST_ACT * 2);
3279 /* deactivate */
3280 dch->state = 1;
3281 }
3282 skb_queue_purge(&dch->squeue);
3283 if (dch->tx_skb) {
3284 dev_kfree_skb(dch->tx_skb);
3285 dch->tx_skb = NULL;
3286 }
3287 dch->tx_idx = 0;
3288 if (dch->rx_skb) {
3289 dev_kfree_skb(dch->rx_skb);
3290 dch->rx_skb = NULL;
3291 }
3292 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
3293 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags))
3294 del_timer(&dch->timer);
3295#ifdef FIXME
3296 if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags))
3297 dchannel_sched_event(&hc->dch, D_CLEARBUSY);
3298#endif
3299 ret = 0;
3300 spin_unlock_irqrestore(&hc->lock, flags);
3301 } else
3302 ret = l1_event(dch->l1, hh->prim);
3303 break;
3304 }
3305 if (!ret)
3306 dev_kfree_skb(skb);
3307 return ret;
3308}
3309
3310static void
3311deactivate_bchannel(struct bchannel *bch)
3312{
3313 struct hfc_multi *hc = bch->hw;
3314 u_long flags;
3315
3316 spin_lock_irqsave(&hc->lock, flags);
3317 if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
3318 dev_kfree_skb(bch->next_skb);
3319 bch->next_skb = NULL;
3320 }
3321 if (bch->tx_skb) {
3322 dev_kfree_skb(bch->tx_skb);
3323 bch->tx_skb = NULL;
3324 }
3325 bch->tx_idx = 0;
3326 if (bch->rx_skb) {
3327 dev_kfree_skb(bch->rx_skb);
3328 bch->rx_skb = NULL;
3329 }
3330 hc->chan[bch->slot].coeff_count = 0;
3331 test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
3332 test_and_clear_bit(FLG_TX_BUSY, &bch->Flags);
3333 hc->chan[bch->slot].rx_off = 0;
3334 hc->chan[bch->slot].conf = -1;
3335 mode_hfcmulti(hc, bch->slot, ISDN_P_NONE, -1, 0, -1, 0);
3336 spin_unlock_irqrestore(&hc->lock, flags);
3337}
3338
3339static int
3340handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
3341{
3342 struct bchannel *bch = container_of(ch, struct bchannel, ch);
3343 struct hfc_multi *hc = bch->hw;
3344 int ret = -EINVAL;
3345 struct mISDNhead *hh = mISDN_HEAD_P(skb);
3346 unsigned int id;
3347 u_long flags;
3348
3349 switch (hh->prim) {
3350 case PH_DATA_REQ:
3351 if (!skb->len)
3352 break;
3353 spin_lock_irqsave(&hc->lock, flags);
3354 ret = bchannel_senddata(bch, skb);
3355 if (ret > 0) { /* direct TX */
3356 id = hh->id; /* skb can be freed */
3357 hfcmulti_tx(hc, bch->slot);
3358 ret = 0;
3359 /* start fifo */
3360 HFC_outb_nodebug(hc, R_FIFO, 0);
3361 HFC_wait_nodebug(hc);
3362 if (!test_bit(FLG_TRANSPARENT, &bch->Flags)) {
3363 spin_unlock_irqrestore(&hc->lock, flags);
3364 queue_ch_frame(ch, PH_DATA_CNF, id, NULL);
3365 } else
3366 spin_unlock_irqrestore(&hc->lock, flags);
3367 } else
3368 spin_unlock_irqrestore(&hc->lock, flags);
3369 return ret;
3370 case PH_ACTIVATE_REQ:
3371 if (debug & DEBUG_HFCMULTI_MSG)
3372 printk(KERN_DEBUG "%s: PH_ACTIVATE ch %d (0..32)\n",
3373 __func__, bch->slot);
3374 spin_lock_irqsave(&hc->lock, flags);
3375 /* activate B-channel if not already activated */
3376 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags)) {
3377 hc->chan[bch->slot].txpending = 0;
3378 ret = mode_hfcmulti(hc, bch->slot,
3379 ch->protocol,
3380 hc->chan[bch->slot].slot_tx,
3381 hc->chan[bch->slot].bank_tx,
3382 hc->chan[bch->slot].slot_rx,
3383 hc->chan[bch->slot].bank_rx);
3384 if (!ret) {
3385 if (ch->protocol == ISDN_P_B_RAW && !hc->dtmf
3386 && test_bit(HFC_CHIP_DTMF, &hc->chip)) {
3387 /* start decoder */
3388 hc->dtmf = 1;
3389 if (debug & DEBUG_HFCMULTI_DTMF)
3390 printk(KERN_DEBUG
3391 "%s: start dtmf decoder\n",
3392 __func__);
3393 HFC_outb(hc, R_DTMF, hc->hw.r_dtmf |
3394 V_RST_DTMF);
3395 }
3396 }
3397 } else
3398 ret = 0;
3399 spin_unlock_irqrestore(&hc->lock, flags);
3400 if (!ret)
3401 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0, NULL,
3402 GFP_KERNEL);
3403 break;
3404 case PH_CONTROL_REQ:
3405 spin_lock_irqsave(&hc->lock, flags);
3406 switch (hh->id) {
3407 case HFC_SPL_LOOP_ON: /* set sample loop */
3408 if (debug & DEBUG_HFCMULTI_MSG)
3409 printk(KERN_DEBUG
3410 "%s: HFC_SPL_LOOP_ON (len = %d)\n",
3411 __func__, skb->len);
3412 ret = 0;
3413 break;
3414 case HFC_SPL_LOOP_OFF: /* set silence */
3415 if (debug & DEBUG_HFCMULTI_MSG)
3416 printk(KERN_DEBUG "%s: HFC_SPL_LOOP_OFF\n",
3417 __func__);
3418 ret = 0;
3419 break;
3420 default:
3421 printk(KERN_ERR
3422 "%s: unknown PH_CONTROL_REQ info %x\n",
3423 __func__, hh->id);
3424 ret = -EINVAL;
3425 }
3426 spin_unlock_irqrestore(&hc->lock, flags);
3427 break;
3428 case PH_DEACTIVATE_REQ:
3429 deactivate_bchannel(bch); /* locked there */
3430 _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0, NULL,
3431 GFP_KERNEL);
3432 ret = 0;
3433 break;
3434 }
3435 if (!ret)
3436 dev_kfree_skb(skb);
3437 return ret;
3438}
3439
3440/*
3441 * bchannel control function
3442 */
3443static int
3444channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
3445{
3446 int ret = 0;
3447 struct dsp_features *features =
3448 (struct dsp_features *)(*((u_long *)&cq->p1));
3449 struct hfc_multi *hc = bch->hw;
3450 int slot_tx;
3451 int bank_tx;
3452 int slot_rx;
3453 int bank_rx;
3454 int num;
3455
3456 switch (cq->op) {
3457 case MISDN_CTRL_GETOP:
3458 cq->op = MISDN_CTRL_HFC_OP | MISDN_CTRL_HW_FEATURES_OP
3459 | MISDN_CTRL_RX_OFF;
3460 break;
3461 case MISDN_CTRL_RX_OFF: /* turn off / on rx stream */
3462 hc->chan[bch->slot].rx_off = !!cq->p1;
3463 if (!hc->chan[bch->slot].rx_off) {
3464 /* reset fifo on rx on */
3465 HFC_outb_nodebug(hc, R_FIFO, (bch->slot << 1) | 1);
3466 HFC_wait_nodebug(hc);
3467 HFC_outb_nodebug(hc, R_INC_RES_FIFO, V_RES_F);
3468 HFC_wait_nodebug(hc);
3469 }
3470 if (debug & DEBUG_HFCMULTI_MSG)
3471 printk(KERN_DEBUG "%s: RX_OFF request (nr=%d off=%d)\n",
3472 __func__, bch->nr, hc->chan[bch->slot].rx_off);
3473 break;
3474 case MISDN_CTRL_HW_FEATURES: /* fill features structure */
3475 if (debug & DEBUG_HFCMULTI_MSG)
3476 printk(KERN_DEBUG "%s: HW_FEATURE request\n",
3477 __func__);
3478 /* create confirm */
3479 features->hfc_id = hc->id;
3480 if (test_bit(HFC_CHIP_DTMF, &hc->chip))
3481 features->hfc_dtmf = 1;
3482 features->hfc_loops = 0;
3483 if (test_bit(HFC_CHIP_B410P, &hc->chip)) {
3484 features->hfc_echocanhw = 1;
3485 } else {
3486 features->pcm_id = hc->pcm;
3487 features->pcm_slots = hc->slots;
3488 features->pcm_banks = 2;
3489 }
3490 break;
3491 case MISDN_CTRL_HFC_PCM_CONN: /* connect to pcm timeslot (0..N) */
3492 slot_tx = cq->p1 & 0xff;
3493 bank_tx = cq->p1 >> 8;
3494 slot_rx = cq->p2 & 0xff;
3495 bank_rx = cq->p2 >> 8;
3496 if (debug & DEBUG_HFCMULTI_MSG)
3497 printk(KERN_DEBUG
3498 "%s: HFC_PCM_CONN slot %d bank %d (TX) "
3499 "slot %d bank %d (RX)\n",
3500 __func__, slot_tx, bank_tx,
3501 slot_rx, bank_rx);
3502 if (slot_tx < hc->slots && bank_tx <= 2 &&
3503 slot_rx < hc->slots && bank_rx <= 2)
3504 hfcmulti_pcm(hc, bch->slot,
3505 slot_tx, bank_tx, slot_rx, bank_rx);
3506 else {
3507 printk(KERN_WARNING
3508 "%s: HFC_PCM_CONN slot %d bank %d (TX) "
3509 "slot %d bank %d (RX) out of range\n",
3510 __func__, slot_tx, bank_tx,
3511 slot_rx, bank_rx);
3512 ret = -EINVAL;
3513 }
3514 break;
3515 case MISDN_CTRL_HFC_PCM_DISC: /* release interface from pcm timeslot */
3516 if (debug & DEBUG_HFCMULTI_MSG)
3517 printk(KERN_DEBUG "%s: HFC_PCM_DISC\n",
3518 __func__);
3519 hfcmulti_pcm(hc, bch->slot, -1, 0, -1, 0);
3520 break;
3521 case MISDN_CTRL_HFC_CONF_JOIN: /* join conference (0..7) */
3522 num = cq->p1 & 0xff;
3523 if (debug & DEBUG_HFCMULTI_MSG)
3524 printk(KERN_DEBUG "%s: HFC_CONF_JOIN conf %d\n",
3525 __func__, num);
3526 if (num <= 7)
3527 hfcmulti_conf(hc, bch->slot, num);
3528 else {
3529 printk(KERN_WARNING
3530 "%s: HW_CONF_JOIN conf %d out of range\n",
3531 __func__, num);
3532 ret = -EINVAL;
3533 }
3534 break;
3535 case MISDN_CTRL_HFC_CONF_SPLIT: /* split conference */
3536 if (debug & DEBUG_HFCMULTI_MSG)
3537 printk(KERN_DEBUG "%s: HFC_CONF_SPLIT\n", __func__);
3538 hfcmulti_conf(hc, bch->slot, -1);
3539 break;
3540 case MISDN_CTRL_HFC_ECHOCAN_ON:
3541 if (debug & DEBUG_HFCMULTI_MSG)
3542 printk(KERN_DEBUG "%s: HFC_ECHOCAN_ON\n", __func__);
3543 if (test_bit(HFC_CHIP_B410P, &hc->chip))
3544 vpm_echocan_on(hc, bch->slot, cq->p1);
3545 else
3546 ret = -EINVAL;
3547 break;
3548
3549 case MISDN_CTRL_HFC_ECHOCAN_OFF:
3550 if (debug & DEBUG_HFCMULTI_MSG)
3551 printk(KERN_DEBUG "%s: HFC_ECHOCAN_OFF\n",
3552 __func__);
3553 if (test_bit(HFC_CHIP_B410P, &hc->chip))
3554 vpm_echocan_off(hc, bch->slot);
3555 else
3556 ret = -EINVAL;
3557 break;
3558 default:
3559 printk(KERN_WARNING "%s: unknown Op %x\n",
3560 __func__, cq->op);
3561 ret = -EINVAL;
3562 break;
3563 }
3564 return ret;
3565}
3566
3567static int
3568hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
3569{
3570 struct bchannel *bch = container_of(ch, struct bchannel, ch);
3571 struct hfc_multi *hc = bch->hw;
3572 int err = -EINVAL;
3573 u_long flags;
3574
3575 if (bch->debug & DEBUG_HW)
3576 printk(KERN_DEBUG "%s: cmd:%x %p\n",
3577 __func__, cmd, arg);
3578 switch (cmd) {
3579 case CLOSE_CHANNEL:
3580 test_and_clear_bit(FLG_OPEN, &bch->Flags);
3581 if (test_bit(FLG_ACTIVE, &bch->Flags))
3582 deactivate_bchannel(bch); /* locked there */
3583 ch->protocol = ISDN_P_NONE;
3584 ch->peer = NULL;
3585 module_put(THIS_MODULE);
3586 err = 0;
3587 break;
3588 case CONTROL_CHANNEL:
3589 spin_lock_irqsave(&hc->lock, flags);
3590 err = channel_bctrl(bch, arg);
3591 spin_unlock_irqrestore(&hc->lock, flags);
3592 break;
3593 default:
3594 printk(KERN_WARNING "%s: unknown prim(%x)\n",
3595 __func__, cmd);
3596 }
3597 return err;
3598}
3599
3600/*
3601 * handle D-channel events
3602 *
3603 * handle state change event
3604 */
3605static void
3606ph_state_change(struct dchannel *dch)
3607{
3608 struct hfc_multi *hc = dch->hw;
3609 int ch, i;
3610
3611 if (!dch) {
3612 printk(KERN_WARNING "%s: ERROR given dch is NULL\n",
3613 __func__);
3614 return;
3615 }
3616 ch = dch->slot;
3617
3618 if (hc->type == 1) {
3619 if (dch->dev.D.protocol == ISDN_P_TE_E1) {
3620 if (debug & DEBUG_HFCMULTI_STATE)
3621 printk(KERN_DEBUG
3622 "%s: E1 TE (id=%d) newstate %x\n",
3623 __func__, hc->id, dch->state);
3624 } else {
3625 if (debug & DEBUG_HFCMULTI_STATE)
3626 printk(KERN_DEBUG
3627 "%s: E1 NT (id=%d) newstate %x\n",
3628 __func__, hc->id, dch->state);
3629 }
3630 switch (dch->state) {
3631 case (1):
3632 if (hc->e1_state != 1) {
3633 for (i = 1; i <= 31; i++) {
3634 /* reset fifos on e1 activation */
3635 HFC_outb_nodebug(hc, R_FIFO, (i << 1) | 1);
3636 HFC_wait_nodebug(hc);
3637 HFC_outb_nodebug(hc,
3638 R_INC_RES_FIFO, V_RES_F);
3639 HFC_wait_nodebug(hc);
3640 }
3641 }
3642 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
3643 _queue_data(&dch->dev.D, PH_ACTIVATE_IND,
3644 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
3645 break;
3646
3647 default:
3648 if (hc->e1_state != 1)
3649 return;
3650 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
3651 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND,
3652 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
3653 }
3654 hc->e1_state = dch->state;
3655 } else {
3656 if (dch->dev.D.protocol == ISDN_P_TE_S0) {
3657 if (debug & DEBUG_HFCMULTI_STATE)
3658 printk(KERN_DEBUG
3659 "%s: S/T TE newstate %x\n",
3660 __func__, dch->state);
3661 switch (dch->state) {
3662 case (0):
3663 l1_event(dch->l1, HW_RESET_IND);
3664 break;
3665 case (3):
3666 l1_event(dch->l1, HW_DEACT_IND);
3667 break;
3668 case (5):
3669 case (8):
3670 l1_event(dch->l1, ANYSIGNAL);
3671 break;
3672 case (6):
3673 l1_event(dch->l1, INFO2);
3674 break;
3675 case (7):
3676 l1_event(dch->l1, INFO4_P8);
3677 break;
3678 }
3679 } else {
3680 if (debug & DEBUG_HFCMULTI_STATE)
3681 printk(KERN_DEBUG "%s: S/T NT newstate %x\n",
3682 __func__, dch->state);
3683 switch (dch->state) {
3684 case (2):
3685 if (hc->chan[ch].nt_timer == 0) {
3686 hc->chan[ch].nt_timer = -1;
3687 HFC_outb(hc, R_ST_SEL,
3688 hc->chan[ch].port);
3689 /* undocumented: delay after R_ST_SEL */
3690 udelay(1);
3691 HFC_outb(hc, A_ST_WR_STATE, 4 |
3692 V_ST_LD_STA); /* G4 */
3693 udelay(6); /* wait at least 5,21us */
3694 HFC_outb(hc, A_ST_WR_STATE, 4);
3695 dch->state = 4;
3696 } else {
3697 /* one extra count for the next event */
3698 hc->chan[ch].nt_timer =
3699 nt_t1_count[poll_timer] + 1;
3700 HFC_outb(hc, R_ST_SEL,
3701 hc->chan[ch].port);
3702 /* undocumented: delay after R_ST_SEL */
3703 udelay(1);
3704 /* allow G2 -> G3 transition */
3705 HFC_outb(hc, A_ST_WR_STATE, 2 |
3706 V_SET_G2_G3);
3707 }
3708 break;
3709 case (1):
3710 hc->chan[ch].nt_timer = -1;
3711 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
3712 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND,
3713 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
3714 break;
3715 case (4):
3716 hc->chan[ch].nt_timer = -1;
3717 break;
3718 case (3):
3719 hc->chan[ch].nt_timer = -1;
3720 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
3721 _queue_data(&dch->dev.D, PH_ACTIVATE_IND,
3722 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
3723 break;
3724 }
3725 }
3726 }
3727}
3728
3729/*
3730 * called for card mode init message
3731 */
3732
3733static void
3734hfcmulti_initmode(struct dchannel *dch)
3735{
3736 struct hfc_multi *hc = dch->hw;
3737 u_char a_st_wr_state, r_e1_wr_sta;
3738 int i, pt;
3739
3740 if (debug & DEBUG_HFCMULTI_INIT)
3741 printk(KERN_DEBUG "%s: entered\n", __func__);
3742
3743 if (hc->type == 1) {
3744 hc->chan[hc->dslot].slot_tx = -1;
3745 hc->chan[hc->dslot].slot_rx = -1;
3746 hc->chan[hc->dslot].conf = -1;
3747 if (hc->dslot) {
3748 mode_hfcmulti(hc, hc->dslot, dch->dev.D.protocol,
3749 -1, 0, -1, 0);
3750 dch->timer.function = (void *) hfcmulti_dbusy_timer;
3751 dch->timer.data = (long) dch;
3752 init_timer(&dch->timer);
3753 }
3754 for (i = 1; i <= 31; i++) {
3755 if (i == hc->dslot)
3756 continue;
3757 hc->chan[i].slot_tx = -1;
3758 hc->chan[i].slot_rx = -1;
3759 hc->chan[i].conf = -1;
3760 mode_hfcmulti(hc, i, ISDN_P_NONE, -1, 0, -1, 0);
3761 }
3762 /* E1 */
3763 if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
3764 HFC_outb(hc, R_LOS0, 255); /* 2 ms */
3765 HFC_outb(hc, R_LOS1, 255); /* 512 ms */
3766 }
3767 if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dslot].cfg)) {
3768 HFC_outb(hc, R_RX0, 0);
3769 hc->hw.r_tx0 = 0 | V_OUT_EN;
3770 } else {
3771 HFC_outb(hc, R_RX0, 1);
3772 hc->hw.r_tx0 = 1 | V_OUT_EN;
3773 }
3774 hc->hw.r_tx1 = V_ATX | V_NTRI;
3775 HFC_outb(hc, R_TX0, hc->hw.r_tx0);
3776 HFC_outb(hc, R_TX1, hc->hw.r_tx1);
3777 HFC_outb(hc, R_TX_FR0, 0x00);
3778 HFC_outb(hc, R_TX_FR1, 0xf8);
3779
3780 if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
3781 HFC_outb(hc, R_TX_FR2, V_TX_MF | V_TX_E | V_NEG_E);
3782
3783 HFC_outb(hc, R_RX_FR0, V_AUTO_RESYNC | V_AUTO_RECO | 0);
3784
3785 if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
3786 HFC_outb(hc, R_RX_FR1, V_RX_MF | V_RX_MF_SYNC);
3787
3788 if (dch->dev.D.protocol == ISDN_P_NT_E1) {
3789 if (debug & DEBUG_HFCMULTI_INIT)
3790 printk(KERN_DEBUG "%s: E1 port is NT-mode\n",
3791 __func__);
3792 r_e1_wr_sta = 0; /* G0 */
3793 hc->e1_getclock = 0;
3794 } else {
3795 if (debug & DEBUG_HFCMULTI_INIT)
3796 printk(KERN_DEBUG "%s: E1 port is TE-mode\n",
3797 __func__);
3798 r_e1_wr_sta = 0; /* F0 */
3799 hc->e1_getclock = 1;
3800 }
3801 if (test_bit(HFC_CHIP_RX_SYNC, &hc->chip))
3802 HFC_outb(hc, R_SYNC_OUT, V_SYNC_E1_RX);
3803 else
3804 HFC_outb(hc, R_SYNC_OUT, 0);
3805 if (test_bit(HFC_CHIP_E1CLOCK_GET, &hc->chip))
3806 hc->e1_getclock = 1;
3807 if (test_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip))
3808 hc->e1_getclock = 0;
3809 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) {
3810 /* SLAVE (clock master) */
3811 if (debug & DEBUG_HFCMULTI_INIT)
3812 printk(KERN_DEBUG
3813 "%s: E1 port is clock master "
3814 "(clock from PCM)\n", __func__);
3815 HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC | V_PCM_SYNC);
3816 } else {
3817 if (hc->e1_getclock) {
3818 /* MASTER (clock slave) */
3819 if (debug & DEBUG_HFCMULTI_INIT)
3820 printk(KERN_DEBUG
3821 "%s: E1 port is clock slave "
3822 "(clock to PCM)\n", __func__);
3823 HFC_outb(hc, R_SYNC_CTRL, V_SYNC_OFFS);
3824 } else {
3825 /* MASTER (clock master) */
3826 if (debug & DEBUG_HFCMULTI_INIT)
3827 printk(KERN_DEBUG "%s: E1 port is "
3828 "clock master "
3829 "(clock from QUARTZ)\n",
3830 __func__);
3831 HFC_outb(hc, R_SYNC_CTRL, V_EXT_CLK_SYNC |
3832 V_PCM_SYNC | V_JATT_OFF);
3833 HFC_outb(hc, R_SYNC_OUT, 0);
3834 }
3835 }
3836 HFC_outb(hc, R_JATT_ATT, 0x9c); /* undoc register */
3837 HFC_outb(hc, R_PWM_MD, V_PWM0_MD);
3838 HFC_outb(hc, R_PWM0, 0x50);
3839 HFC_outb(hc, R_PWM1, 0xff);
3840 /* state machine setup */
3841 HFC_outb(hc, R_E1_WR_STA, r_e1_wr_sta | V_E1_LD_STA);
3842 udelay(6); /* wait at least 5,21us */
3843 HFC_outb(hc, R_E1_WR_STA, r_e1_wr_sta);
3844 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
3845 hc->syncronized = 0;
3846 plxsd_checksync(hc, 0);
3847 }
3848 } else {
3849 i = dch->slot;
3850 hc->chan[i].slot_tx = -1;
3851 hc->chan[i].slot_rx = -1;
3852 hc->chan[i].conf = -1;
3853 mode_hfcmulti(hc, i, dch->dev.D.protocol, -1, 0, -1, 0);
3854 dch->timer.function = (void *)hfcmulti_dbusy_timer;
3855 dch->timer.data = (long) dch;
3856 init_timer(&dch->timer);
3857 hc->chan[i - 2].slot_tx = -1;
3858 hc->chan[i - 2].slot_rx = -1;
3859 hc->chan[i - 2].conf = -1;
3860 mode_hfcmulti(hc, i - 2, ISDN_P_NONE, -1, 0, -1, 0);
3861 hc->chan[i - 1].slot_tx = -1;
3862 hc->chan[i - 1].slot_rx = -1;
3863 hc->chan[i - 1].conf = -1;
3864 mode_hfcmulti(hc, i - 1, ISDN_P_NONE, -1, 0, -1, 0);
3865 /* ST */
3866 pt = hc->chan[i].port;
3867 /* select interface */
3868 HFC_outb(hc, R_ST_SEL, pt);
3869 /* undocumented: delay after R_ST_SEL */
3870 udelay(1);
3871 if (dch->dev.D.protocol == ISDN_P_NT_S0) {
3872 if (debug & DEBUG_HFCMULTI_INIT)
3873 printk(KERN_DEBUG
3874 "%s: ST port %d is NT-mode\n",
3875 __func__, pt);
3876 /* clock delay */
3877 HFC_outb(hc, A_ST_CLK_DLY, clockdelay_nt);
3878 a_st_wr_state = 1; /* G1 */
3879 hc->hw.a_st_ctrl0[pt] = V_ST_MD;
3880 } else {
3881 if (debug & DEBUG_HFCMULTI_INIT)
3882 printk(KERN_DEBUG
3883 "%s: ST port %d is TE-mode\n",
3884 __func__, pt);
3885 /* clock delay */
3886 HFC_outb(hc, A_ST_CLK_DLY, clockdelay_te);
3887 a_st_wr_state = 2; /* F2 */
3888 hc->hw.a_st_ctrl0[pt] = 0;
3889 }
3890 if (!test_bit(HFC_CFG_NONCAP_TX, &hc->chan[i].cfg))
3891 hc->hw.a_st_ctrl0[pt] |= V_TX_LI;
3892 /* line setup */
3893 HFC_outb(hc, A_ST_CTRL0, hc->hw.a_st_ctrl0[pt]);
3894 /* disable E-channel */
3895 if ((dch->dev.D.protocol == ISDN_P_NT_S0) ||
3896 test_bit(HFC_CFG_DIS_ECHANNEL, &hc->chan[i].cfg))
3897 HFC_outb(hc, A_ST_CTRL1, V_E_IGNO);
3898 else
3899 HFC_outb(hc, A_ST_CTRL1, 0);
3900 /* enable B-channel receive */
3901 HFC_outb(hc, A_ST_CTRL2, V_B1_RX_EN | V_B2_RX_EN);
3902 /* state machine setup */
3903 HFC_outb(hc, A_ST_WR_STATE, a_st_wr_state | V_ST_LD_STA);
3904 udelay(6); /* wait at least 5,21us */
3905 HFC_outb(hc, A_ST_WR_STATE, a_st_wr_state);
3906 hc->hw.r_sci_msk |= 1 << pt;
3907 /* state machine interrupts */
3908 HFC_outb(hc, R_SCI_MSK, hc->hw.r_sci_msk);
3909 /* unset sync on port */
3910 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
3911 hc->syncronized &=
3912 ~(1 << hc->chan[dch->slot].port);
3913 plxsd_checksync(hc, 0);
3914 }
3915 }
3916 if (debug & DEBUG_HFCMULTI_INIT)
3917 printk("%s: done\n", __func__);
3918}
3919
3920
3921static int
3922open_dchannel(struct hfc_multi *hc, struct dchannel *dch,
3923 struct channel_req *rq)
3924{
3925 int err = 0;
3926 u_long flags;
3927
3928 if (debug & DEBUG_HW_OPEN)
3929 printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__,
3930 dch->dev.id, __builtin_return_address(0));
3931 if (rq->protocol == ISDN_P_NONE)
3932 return -EINVAL;
3933 if ((dch->dev.D.protocol != ISDN_P_NONE) &&
3934 (dch->dev.D.protocol != rq->protocol)) {
3935 if (debug & DEBUG_HFCMULTI_MODE)
3936 printk(KERN_WARNING "%s: change protocol %x to %x\n",
3937 __func__, dch->dev.D.protocol, rq->protocol);
3938 }
3939 if ((dch->dev.D.protocol == ISDN_P_TE_S0)
3940 && (rq->protocol != ISDN_P_TE_S0))
3941 l1_event(dch->l1, CLOSE_CHANNEL);
3942 if (dch->dev.D.protocol != rq->protocol) {
3943 if (rq->protocol == ISDN_P_TE_S0) {
3944 err = create_l1(dch, hfcm_l1callback);
3945 if (err)
3946 return err;
3947 }
3948 dch->dev.D.protocol = rq->protocol;
3949 spin_lock_irqsave(&hc->lock, flags);
3950 hfcmulti_initmode(dch);
3951 spin_unlock_irqrestore(&hc->lock, flags);
3952 }
3953
3954 if (((rq->protocol == ISDN_P_NT_S0) && (dch->state == 3)) ||
3955 ((rq->protocol == ISDN_P_TE_S0) && (dch->state == 7)) ||
3956 ((rq->protocol == ISDN_P_NT_E1) && (dch->state == 1)) ||
3957 ((rq->protocol == ISDN_P_TE_E1) && (dch->state == 1))) {
3958 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY,
3959 0, NULL, GFP_KERNEL);
3960 }
3961 rq->ch = &dch->dev.D;
3962 if (!try_module_get(THIS_MODULE))
3963 printk(KERN_WARNING "%s:cannot get module\n", __func__);
3964 return 0;
3965}
3966
3967static int
3968open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
3969 struct channel_req *rq)
3970{
3971 struct bchannel *bch;
3972 int ch;
3973
3974 if (!test_bit(rq->adr.channel, &dch->dev.channelmap[0]))
3975 return -EINVAL;
3976 if (rq->protocol == ISDN_P_NONE)
3977 return -EINVAL;
3978 if (hc->type == 1)
3979 ch = rq->adr.channel;
3980 else
3981 ch = (rq->adr.channel - 1) + (dch->slot - 2);
3982 bch = hc->chan[ch].bch;
3983 if (!bch) {
3984 printk(KERN_ERR "%s:internal error ch %d has no bch\n",
3985 __func__, ch);
3986 return -EINVAL;
3987 }
3988 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
3989 return -EBUSY; /* b-channel can be only open once */
3990 bch->ch.protocol = rq->protocol;
3991 hc->chan[ch].rx_off = 0;
3992 rq->ch = &bch->ch;
3993 if (!try_module_get(THIS_MODULE))
3994 printk(KERN_WARNING "%s:cannot get module\n", __func__);
3995 return 0;
3996}
3997
3998/*
3999 * device control function
4000 */
4001static int
4002channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq)
4003{
4004 int ret = 0;
4005
4006 switch (cq->op) {
4007 case MISDN_CTRL_GETOP:
4008 cq->op = 0;
4009 break;
4010 default:
4011 printk(KERN_WARNING "%s: unknown Op %x\n",
4012 __func__, cq->op);
4013 ret = -EINVAL;
4014 break;
4015 }
4016 return ret;
4017}
4018
4019static int
4020hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
4021{
4022 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
4023 struct dchannel *dch = container_of(dev, struct dchannel, dev);
4024 struct hfc_multi *hc = dch->hw;
4025 struct channel_req *rq;
4026 int err = 0;
4027 u_long flags;
4028
4029 if (dch->debug & DEBUG_HW)
4030 printk(KERN_DEBUG "%s: cmd:%x %p\n",
4031 __func__, cmd, arg);
4032 switch (cmd) {
4033 case OPEN_CHANNEL:
4034 rq = arg;
4035 switch (rq->protocol) {
4036 case ISDN_P_TE_S0:
4037 case ISDN_P_NT_S0:
4038 if (hc->type == 1) {
4039 err = -EINVAL;
4040 break;
4041 }
4042 err = open_dchannel(hc, dch, rq); /* locked there */
4043 break;
4044 case ISDN_P_TE_E1:
4045 case ISDN_P_NT_E1:
4046 if (hc->type != 1) {
4047 err = -EINVAL;
4048 break;
4049 }
4050 err = open_dchannel(hc, dch, rq); /* locked there */
4051 break;
4052 default:
4053 spin_lock_irqsave(&hc->lock, flags);
4054 err = open_bchannel(hc, dch, rq);
4055 spin_unlock_irqrestore(&hc->lock, flags);
4056 }
4057 break;
4058 case CLOSE_CHANNEL:
4059 if (debug & DEBUG_HW_OPEN)
4060 printk(KERN_DEBUG "%s: dev(%d) close from %p\n",
4061 __func__, dch->dev.id,
4062 __builtin_return_address(0));
4063 module_put(THIS_MODULE);
4064 break;
4065 case CONTROL_CHANNEL:
4066 spin_lock_irqsave(&hc->lock, flags);
4067 err = channel_dctrl(dch, arg);
4068 spin_unlock_irqrestore(&hc->lock, flags);
4069 break;
4070 default:
4071 if (dch->debug & DEBUG_HW)
4072 printk(KERN_DEBUG "%s: unknown command %x\n",
4073 __func__, cmd);
4074 err = -EINVAL;
4075 }
4076 return err;
4077}
4078
4079/*
4080 * initialize the card
4081 */
4082
4083/*
4084 * start timer irq, wait some time and check if we have interrupts.
4085 * if not, reset chip and try again.
4086 */
4087static int
4088init_card(struct hfc_multi *hc)
4089{
4090 int err = -EIO;
4091 u_long flags;
4092 u_short *plx_acc;
4093 u_long plx_flags;
4094
4095 if (debug & DEBUG_HFCMULTI_INIT)
4096 printk(KERN_DEBUG "%s: entered\n", __func__);
4097
4098 spin_lock_irqsave(&hc->lock, flags);
4099 /* set interrupts but leave global interrupt disabled */
4100 hc->hw.r_irq_ctrl = V_FIFO_IRQ;
4101 disable_hwirq(hc);
4102 spin_unlock_irqrestore(&hc->lock, flags);
4103
4104 if (request_irq(hc->pci_dev->irq, hfcmulti_interrupt, IRQF_SHARED,
4105 "HFC-multi", hc)) {
4106 printk(KERN_WARNING "mISDN: Could not get interrupt %d.\n",
4107 hc->pci_dev->irq);
4108 return -EIO;
4109 }
4110 hc->irq = hc->pci_dev->irq;
4111
4112 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
4113 spin_lock_irqsave(&plx_lock, plx_flags);
4114 plx_acc = (u_short *)(hc->plx_membase+PLX_INTCSR);
4115 writew((PLX_INTCSR_PCIINT_ENABLE | PLX_INTCSR_LINTI1_ENABLE),
4116 plx_acc); /* enable PCI & LINT1 irq */
4117 spin_unlock_irqrestore(&plx_lock, plx_flags);
4118 }
4119
4120 if (debug & DEBUG_HFCMULTI_INIT)
4121 printk(KERN_DEBUG "%s: IRQ %d count %d\n",
4122 __func__, hc->irq, hc->irqcnt);
4123 err = init_chip(hc);
4124 if (err)
4125 goto error;
4126 /*
4127 * Finally enable IRQ output
4128 * this is only allowed, if an IRQ routine is allready
4129 * established for this HFC, so don't do that earlier
4130 */
4131 spin_lock_irqsave(&hc->lock, flags);
4132 enable_hwirq(hc);
4133 spin_unlock_irqrestore(&hc->lock, flags);
4134 /* printk(KERN_DEBUG "no master irq set!!!\n"); */
4135 set_current_state(TASK_UNINTERRUPTIBLE);
4136 schedule_timeout((100*HZ)/1000); /* Timeout 100ms */
4137 /* turn IRQ off until chip is completely initialized */
4138 spin_lock_irqsave(&hc->lock, flags);
4139 disable_hwirq(hc);
4140 spin_unlock_irqrestore(&hc->lock, flags);
4141 if (debug & DEBUG_HFCMULTI_INIT)
4142 printk(KERN_DEBUG "%s: IRQ %d count %d\n",
4143 __func__, hc->irq, hc->irqcnt);
4144 if (hc->irqcnt) {
4145 if (debug & DEBUG_HFCMULTI_INIT)
4146 printk(KERN_DEBUG "%s: done\n", __func__);
4147
4148 return 0;
4149 }
4150 if (test_bit(HFC_CHIP_PCM_SLAVE, &hc->chip)) {
4151 printk(KERN_INFO "ignoring missing interrupts\n");
4152 return 0;
4153 }
4154
4155 printk(KERN_ERR "HFC PCI: IRQ(%d) getting no interrupts during init.\n",
4156 hc->irq);
4157
4158 err = -EIO;
4159
4160error:
4161 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
4162 spin_lock_irqsave(&plx_lock, plx_flags);
4163 plx_acc = (u_short *)(hc->plx_membase+PLX_INTCSR);
4164 writew(0x00, plx_acc); /*disable IRQs*/
4165 spin_unlock_irqrestore(&plx_lock, plx_flags);
4166 }
4167
4168 if (debug & DEBUG_HFCMULTI_INIT)
4169 printk(KERN_WARNING "%s: free irq %d\n", __func__, hc->irq);
4170 if (hc->irq) {
4171 free_irq(hc->irq, hc);
4172 hc->irq = 0;
4173 }
4174
4175 if (debug & DEBUG_HFCMULTI_INIT)
4176 printk(KERN_DEBUG "%s: done (err=%d)\n", __func__, err);
4177 return err;
4178}
4179
4180/*
4181 * find pci device and set it up
4182 */
4183
4184static int
4185setup_pci(struct hfc_multi *hc, struct pci_dev *pdev,
4186 const struct pci_device_id *ent)
4187{
4188 struct hm_map *m = (struct hm_map *)ent->driver_data;
4189
4190 printk(KERN_INFO
4191 "HFC-multi: card manufacturer: '%s' card name: '%s' clock: %s\n",
4192 m->vendor_name, m->card_name, m->clock2 ? "double" : "normal");
4193
4194 hc->pci_dev = pdev;
4195 if (m->clock2)
4196 test_and_set_bit(HFC_CHIP_CLOCK2, &hc->chip);
4197
4198 if (ent->device == 0xB410) {
4199 test_and_set_bit(HFC_CHIP_B410P, &hc->chip);
4200 test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip);
4201 test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
4202 hc->slots = 32;
4203 }
4204
4205 if (hc->pci_dev->irq <= 0) {
4206 printk(KERN_WARNING "HFC-multi: No IRQ for PCI card found.\n");
4207 return -EIO;
4208 }
4209 if (pci_enable_device(hc->pci_dev)) {
4210 printk(KERN_WARNING "HFC-multi: Error enabling PCI card.\n");
4211 return -EIO;
4212 }
4213 hc->leds = m->leds;
4214 hc->ledstate = 0xAFFEAFFE;
4215 hc->opticalsupport = m->opticalsupport;
4216
4217 /* set memory access methods */
4218 if (m->io_mode) /* use mode from card config */
4219 hc->io_mode = m->io_mode;
4220 switch (hc->io_mode) {
4221 case HFC_IO_MODE_PLXSD:
4222 test_and_set_bit(HFC_CHIP_PLXSD, &hc->chip);
4223 hc->slots = 128; /* required */
4224 /* fall through */
4225 case HFC_IO_MODE_PCIMEM:
4226 hc->HFC_outb = HFC_outb_pcimem;
4227 hc->HFC_inb = HFC_inb_pcimem;
4228 hc->HFC_inw = HFC_inw_pcimem;
4229 hc->HFC_wait = HFC_wait_pcimem;
4230 hc->read_fifo = read_fifo_pcimem;
4231 hc->write_fifo = write_fifo_pcimem;
4232 break;
4233 case HFC_IO_MODE_REGIO:
4234 hc->HFC_outb = HFC_outb_regio;
4235 hc->HFC_inb = HFC_inb_regio;
4236 hc->HFC_inw = HFC_inw_regio;
4237 hc->HFC_wait = HFC_wait_regio;
4238 hc->read_fifo = read_fifo_regio;
4239 hc->write_fifo = write_fifo_regio;
4240 break;
4241 default:
4242 printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");
4243 pci_disable_device(hc->pci_dev);
4244 return -EIO;
4245 }
4246 hc->HFC_outb_nodebug = hc->HFC_outb;
4247 hc->HFC_inb_nodebug = hc->HFC_inb;
4248 hc->HFC_inw_nodebug = hc->HFC_inw;
4249 hc->HFC_wait_nodebug = hc->HFC_wait;
4250#ifdef HFC_REGISTER_DEBUG
4251 hc->HFC_outb = HFC_outb_debug;
4252 hc->HFC_inb = HFC_inb_debug;
4253 hc->HFC_inw = HFC_inw_debug;
4254 hc->HFC_wait = HFC_wait_debug;
4255#endif
4256 hc->pci_iobase = 0;
4257 hc->pci_membase = NULL;
4258 hc->plx_membase = NULL;
4259
4260 switch (hc->io_mode) {
4261 case HFC_IO_MODE_PLXSD:
4262 hc->plx_origmembase = hc->pci_dev->resource[0].start;
4263 /* MEMBASE 1 is PLX PCI Bridge */
4264
4265 if (!hc->plx_origmembase) {
4266 printk(KERN_WARNING
4267 "HFC-multi: No IO-Memory for PCI PLX bridge found\n");
4268 pci_disable_device(hc->pci_dev);
4269 return -EIO;
4270 }
4271
4272 hc->plx_membase = ioremap(hc->plx_origmembase, 0x80);
4273 if (!hc->plx_membase) {
4274 printk(KERN_WARNING
4275 "HFC-multi: failed to remap plx address space. "
4276 "(internal error)\n");
4277 pci_disable_device(hc->pci_dev);
4278 return -EIO;
4279 }
4280 printk(KERN_INFO
4281 "HFC-multi: plx_membase:%#lx plx_origmembase:%#lx\n",
4282 (u_long)hc->plx_membase, hc->plx_origmembase);
4283
4284 hc->pci_origmembase = hc->pci_dev->resource[2].start;
4285 /* MEMBASE 1 is PLX PCI Bridge */
4286 if (!hc->pci_origmembase) {
4287 printk(KERN_WARNING
4288 "HFC-multi: No IO-Memory for PCI card found\n");
4289 pci_disable_device(hc->pci_dev);
4290 return -EIO;
4291 }
4292
4293 hc->pci_membase = ioremap(hc->pci_origmembase, 0x400);
4294 if (!hc->pci_membase) {
4295 printk(KERN_WARNING "HFC-multi: failed to remap io "
4296 "address space. (internal error)\n");
4297 pci_disable_device(hc->pci_dev);
4298 return -EIO;
4299 }
4300
4301 printk(KERN_INFO
4302 "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d HZ %d "
4303 "leds-type %d\n",
4304 hc->id, (u_long)hc->pci_membase, hc->pci_origmembase,
4305 hc->pci_dev->irq, HZ, hc->leds);
4306 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO);
4307 break;
4308 case HFC_IO_MODE_PCIMEM:
4309 hc->pci_origmembase = hc->pci_dev->resource[1].start;
4310 if (!hc->pci_origmembase) {
4311 printk(KERN_WARNING
4312 "HFC-multi: No IO-Memory for PCI card found\n");
4313 pci_disable_device(hc->pci_dev);
4314 return -EIO;
4315 }
4316
4317 hc->pci_membase = ioremap(hc->pci_origmembase, 256);
4318 if (!hc->pci_membase) {
4319 printk(KERN_WARNING
4320 "HFC-multi: failed to remap io address space. "
4321 "(internal error)\n");
4322 pci_disable_device(hc->pci_dev);
4323 return -EIO;
4324 }
4325 printk(KERN_INFO "card %d: defined at MEMBASE %#lx (%#lx) IRQ %d "
4326 "HZ %d leds-type %d\n", hc->id, (u_long)hc->pci_membase,
4327 hc->pci_origmembase, hc->pci_dev->irq, HZ, hc->leds);
4328 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_MEMIO);
4329 break;
4330 case HFC_IO_MODE_REGIO:
4331 hc->pci_iobase = (u_int) hc->pci_dev->resource[0].start;
4332 if (!hc->pci_iobase) {
4333 printk(KERN_WARNING
4334 "HFC-multi: No IO for PCI card found\n");
4335 pci_disable_device(hc->pci_dev);
4336 return -EIO;
4337 }
4338
4339 if (!request_region(hc->pci_iobase, 8, "hfcmulti")) {
4340 printk(KERN_WARNING "HFC-multi: failed to request "
4341 "address space at 0x%08lx (internal error)\n",
4342 hc->pci_iobase);
4343 pci_disable_device(hc->pci_dev);
4344 return -EIO;
4345 }
4346
4347 printk(KERN_INFO
4348 "%s %s: defined at IOBASE %#x IRQ %d HZ %d leds-type %d\n",
4349 m->vendor_name, m->card_name, (u_int) hc->pci_iobase,
4350 hc->pci_dev->irq, HZ, hc->leds);
4351 pci_write_config_word(hc->pci_dev, PCI_COMMAND, PCI_ENA_REGIO);
4352 break;
4353 default:
4354 printk(KERN_WARNING "HFC-multi: Invalid IO mode.\n");
4355 pci_disable_device(hc->pci_dev);
4356 return -EIO;
4357 }
4358
4359 pci_set_drvdata(hc->pci_dev, hc);
4360
4361 /* At this point the needed PCI config is done */
4362 /* fifos are still not enabled */
4363 return 0;
4364}
4365
4366
4367/*
4368 * remove port
4369 */
4370
4371static void
4372release_port(struct hfc_multi *hc, struct dchannel *dch)
4373{
4374 int pt, ci, i = 0;
4375 u_long flags;
4376 struct bchannel *pb;
4377
4378 ci = dch->slot;
4379 pt = hc->chan[ci].port;
4380
4381 if (debug & DEBUG_HFCMULTI_INIT)
4382 printk(KERN_DEBUG "%s: entered for port %d\n",
4383 __func__, pt + 1);
4384
4385 if (pt >= hc->ports) {
4386 printk(KERN_WARNING "%s: ERROR port out of range (%d).\n",
4387 __func__, pt + 1);
4388 return;
4389 }
4390
4391 if (debug & DEBUG_HFCMULTI_INIT)
4392 printk(KERN_DEBUG "%s: releasing port=%d\n",
4393 __func__, pt + 1);
4394
4395 if (dch->dev.D.protocol == ISDN_P_TE_S0)
4396 l1_event(dch->l1, CLOSE_CHANNEL);
4397
4398 hc->chan[ci].dch = NULL;
4399
4400 if (hc->created[pt]) {
4401 hc->created[pt] = 0;
4402 mISDN_unregister_device(&dch->dev);
4403 }
4404
4405 spin_lock_irqsave(&hc->lock, flags);
4406
4407 if (dch->timer.function) {
4408 del_timer(&dch->timer);
4409 dch->timer.function = NULL;
4410 }
4411
4412 if (hc->type == 1) { /* E1 */
4413 /* remove sync */
4414 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
4415 hc->syncronized = 0;
4416 plxsd_checksync(hc, 1);
4417 }
4418 /* free channels */
4419 for (i = 0; i <= 31; i++) {
4420 if (hc->chan[i].bch) {
4421 if (debug & DEBUG_HFCMULTI_INIT)
4422 printk(KERN_DEBUG
4423 "%s: free port %d channel %d\n",
4424 __func__, hc->chan[i].port+1, i);
4425 pb = hc->chan[i].bch;
4426 hc->chan[i].bch = NULL;
4427 spin_unlock_irqrestore(&hc->lock, flags);
4428 mISDN_freebchannel(pb);
4429 kfree(pb);
4430 kfree(hc->chan[i].coeff);
4431 spin_lock_irqsave(&hc->lock, flags);
4432 }
4433 }
4434 } else {
4435 /* remove sync */
4436 if (test_bit(HFC_CHIP_PLXSD, &hc->chip)) {
4437 hc->syncronized &=
4438 ~(1 << hc->chan[ci].port);
4439 plxsd_checksync(hc, 1);
4440 }
4441 /* free channels */
4442 if (hc->chan[ci - 2].bch) {
4443 if (debug & DEBUG_HFCMULTI_INIT)
4444 printk(KERN_DEBUG
4445 "%s: free port %d channel %d\n",
4446 __func__, hc->chan[ci - 2].port+1,
4447 ci - 2);
4448 pb = hc->chan[ci - 2].bch;
4449 hc->chan[ci - 2].bch = NULL;
4450 spin_unlock_irqrestore(&hc->lock, flags);
4451 mISDN_freebchannel(pb);
4452 kfree(pb);
4453 kfree(hc->chan[ci - 2].coeff);
4454 spin_lock_irqsave(&hc->lock, flags);
4455 }
4456 if (hc->chan[ci - 1].bch) {
4457 if (debug & DEBUG_HFCMULTI_INIT)
4458 printk(KERN_DEBUG
4459 "%s: free port %d channel %d\n",
4460 __func__, hc->chan[ci - 1].port+1,
4461 ci - 1);
4462 pb = hc->chan[ci - 1].bch;
4463 hc->chan[ci - 1].bch = NULL;
4464 spin_unlock_irqrestore(&hc->lock, flags);
4465 mISDN_freebchannel(pb);
4466 kfree(pb);
4467 kfree(hc->chan[ci - 1].coeff);
4468 spin_lock_irqsave(&hc->lock, flags);
4469 }
4470 }
4471
4472 spin_unlock_irqrestore(&hc->lock, flags);
4473
4474 if (debug & DEBUG_HFCMULTI_INIT)
4475 printk(KERN_DEBUG "%s: free port %d channel D\n", __func__, pt);
4476 mISDN_freedchannel(dch);
4477 kfree(dch);
4478
4479 if (debug & DEBUG_HFCMULTI_INIT)
4480 printk(KERN_DEBUG "%s: done!\n", __func__);
4481}
4482
4483static void
4484release_card(struct hfc_multi *hc)
4485{
4486 u_long flags;
4487 int ch;
4488
4489 if (debug & DEBUG_HFCMULTI_INIT)
4490 printk(KERN_WARNING "%s: release card (%d) entered\n",
4491 __func__, hc->id);
4492
4493 spin_lock_irqsave(&hc->lock, flags);
4494 disable_hwirq(hc);
4495 spin_unlock_irqrestore(&hc->lock, flags);
4496
4497 udelay(1000);
4498
4499 /* dimm leds */
4500 if (hc->leds)
4501 hfcmulti_leds(hc);
4502
4503 /* disable D-channels & B-channels */
4504 if (debug & DEBUG_HFCMULTI_INIT)
4505 printk(KERN_DEBUG "%s: disable all channels (d and b)\n",
4506 __func__);
4507 for (ch = 0; ch <= 31; ch++) {
4508 if (hc->chan[ch].dch)
4509 release_port(hc, hc->chan[ch].dch);
4510 }
4511
4512 /* release hardware & irq */
4513 if (hc->irq) {
4514 if (debug & DEBUG_HFCMULTI_INIT)
4515 printk(KERN_WARNING "%s: free irq %d\n",
4516 __func__, hc->irq);
4517 free_irq(hc->irq, hc);
4518 hc->irq = 0;
4519
4520 }
4521 release_io_hfcmulti(hc);
4522
4523 if (debug & DEBUG_HFCMULTI_INIT)
4524 printk(KERN_WARNING "%s: remove instance from list\n",
4525 __func__);
4526 list_del(&hc->list);
4527
4528 if (debug & DEBUG_HFCMULTI_INIT)
4529 printk(KERN_WARNING "%s: delete instance\n", __func__);
4530 if (hc == syncmaster)
4531 syncmaster = NULL;
4532 kfree(hc);
4533 if (debug & DEBUG_HFCMULTI_INIT)
4534 printk(KERN_WARNING "%s: card successfully removed\n",
4535 __func__);
4536}
4537
4538static int
4539init_e1_port(struct hfc_multi *hc, struct hm_map *m)
4540{
4541 struct dchannel *dch;
4542 struct bchannel *bch;
4543 int ch, ret = 0;
4544 char name[MISDN_MAX_IDLEN];
4545
4546 dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL);
4547 if (!dch)
4548 return -ENOMEM;
4549 dch->debug = debug;
4550 mISDN_initdchannel(dch, MAX_DFRAME_LEN_L1, ph_state_change);
4551 dch->hw = hc;
4552 dch->dev.Dprotocols = (1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1);
4553 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
4554 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
4555 dch->dev.D.send = handle_dmsg;
4556 dch->dev.D.ctrl = hfcm_dctrl;
4557 dch->dev.nrbchan = (hc->dslot)?30:31;
4558 dch->slot = hc->dslot;
4559 hc->chan[hc->dslot].dch = dch;
4560 hc->chan[hc->dslot].port = 0;
4561 hc->chan[hc->dslot].nt_timer = -1;
4562 for (ch = 1; ch <= 31; ch++) {
4563 if (ch == hc->dslot) /* skip dchannel */
4564 continue;
4565 bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL);
4566 if (!bch) {
4567 printk(KERN_ERR "%s: no memory for bchannel\n",
4568 __func__);
4569 ret = -ENOMEM;
4570 goto free_chan;
4571 }
4572 hc->chan[ch].coeff = kzalloc(512, GFP_KERNEL);
4573 if (!hc->chan[ch].coeff) {
4574 printk(KERN_ERR "%s: no memory for coeffs\n",
4575 __func__);
4576 ret = -ENOMEM;
4577 goto free_chan;
4578 }
4579 bch->nr = ch;
4580 bch->slot = ch;
4581 bch->debug = debug;
4582 mISDN_initbchannel(bch, MAX_DATA_MEM);
4583 bch->hw = hc;
4584 bch->ch.send = handle_bmsg;
4585 bch->ch.ctrl = hfcm_bctrl;
4586 bch->ch.nr = ch;
4587 list_add(&bch->ch.list, &dch->dev.bchannels);
4588 hc->chan[ch].bch = bch;
4589 hc->chan[ch].port = 0;
4590 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]);
4591 }
4592 /* set optical line type */
4593 if (port[Port_cnt] & 0x001) {
4594 if (!m->opticalsupport) {
4595 printk(KERN_INFO
4596 "This board has no optical "
4597 "support\n");
4598 } else {
4599 if (debug & DEBUG_HFCMULTI_INIT)
4600 printk(KERN_DEBUG
4601 "%s: PORT set optical "
4602 "interfacs: card(%d) "
4603 "port(%d)\n",
4604 __func__,
4605 HFC_cnt + 1, 1);
4606 test_and_set_bit(HFC_CFG_OPTICAL,
4607 &hc->chan[hc->dslot].cfg);
4608 }
4609 }
4610 /* set LOS report */
4611 if (port[Port_cnt] & 0x004) {
4612 if (debug & DEBUG_HFCMULTI_INIT)
4613 printk(KERN_DEBUG "%s: PORT set "
4614 "LOS report: card(%d) port(%d)\n",
4615 __func__, HFC_cnt + 1, 1);
4616 test_and_set_bit(HFC_CFG_REPORT_LOS,
4617 &hc->chan[hc->dslot].cfg);
4618 }
4619 /* set AIS report */
4620 if (port[Port_cnt] & 0x008) {
4621 if (debug & DEBUG_HFCMULTI_INIT)
4622 printk(KERN_DEBUG "%s: PORT set "
4623 "AIS report: card(%d) port(%d)\n",
4624 __func__, HFC_cnt + 1, 1);
4625 test_and_set_bit(HFC_CFG_REPORT_AIS,
4626 &hc->chan[hc->dslot].cfg);
4627 }
4628 /* set SLIP report */
4629 if (port[Port_cnt] & 0x010) {
4630 if (debug & DEBUG_HFCMULTI_INIT)
4631 printk(KERN_DEBUG
4632 "%s: PORT set SLIP report: "
4633 "card(%d) port(%d)\n",
4634 __func__, HFC_cnt + 1, 1);
4635 test_and_set_bit(HFC_CFG_REPORT_SLIP,
4636 &hc->chan[hc->dslot].cfg);
4637 }
4638 /* set RDI report */
4639 if (port[Port_cnt] & 0x020) {
4640 if (debug & DEBUG_HFCMULTI_INIT)
4641 printk(KERN_DEBUG
4642 "%s: PORT set RDI report: "
4643 "card(%d) port(%d)\n",
4644 __func__, HFC_cnt + 1, 1);
4645 test_and_set_bit(HFC_CFG_REPORT_RDI,
4646 &hc->chan[hc->dslot].cfg);
4647 }
4648 /* set CRC-4 Mode */
4649 if (!(port[Port_cnt] & 0x100)) {
4650 if (debug & DEBUG_HFCMULTI_INIT)
4651 printk(KERN_DEBUG "%s: PORT turn on CRC4 report:"
4652 " card(%d) port(%d)\n",
4653 __func__, HFC_cnt + 1, 1);
4654 test_and_set_bit(HFC_CFG_CRC4,
4655 &hc->chan[hc->dslot].cfg);
4656 } else {
4657 if (debug & DEBUG_HFCMULTI_INIT)
4658 printk(KERN_DEBUG "%s: PORT turn off CRC4"
4659 " report: card(%d) port(%d)\n",
4660 __func__, HFC_cnt + 1, 1);
4661 }
4662 /* set forced clock */
4663 if (port[Port_cnt] & 0x0200) {
4664 if (debug & DEBUG_HFCMULTI_INIT)
4665 printk(KERN_DEBUG "%s: PORT force getting clock from "
4666 "E1: card(%d) port(%d)\n",
4667 __func__, HFC_cnt + 1, 1);
4668 test_and_set_bit(HFC_CHIP_E1CLOCK_GET, &hc->chip);
4669 } else
4670 if (port[Port_cnt] & 0x0400) {
4671 if (debug & DEBUG_HFCMULTI_INIT)
4672 printk(KERN_DEBUG "%s: PORT force putting clock to "
4673 "E1: card(%d) port(%d)\n",
4674 __func__, HFC_cnt + 1, 1);
4675 test_and_set_bit(HFC_CHIP_E1CLOCK_PUT, &hc->chip);
4676 }
4677 /* set JATT PLL */
4678 if (port[Port_cnt] & 0x0800) {
4679 if (debug & DEBUG_HFCMULTI_INIT)
4680 printk(KERN_DEBUG "%s: PORT disable JATT PLL on "
4681 "E1: card(%d) port(%d)\n",
4682 __func__, HFC_cnt + 1, 1);
4683 test_and_set_bit(HFC_CHIP_RX_SYNC, &hc->chip);
4684 }
4685 /* set elastic jitter buffer */
4686 if (port[Port_cnt] & 0x3000) {
4687 hc->chan[hc->dslot].jitter = (port[Port_cnt]>>12) & 0x3;
4688 if (debug & DEBUG_HFCMULTI_INIT)
4689 printk(KERN_DEBUG
4690 "%s: PORT set elastic "
4691 "buffer to %d: card(%d) port(%d)\n",
4692 __func__, hc->chan[hc->dslot].jitter,
4693 HFC_cnt + 1, 1);
4694 } else
4695 hc->chan[hc->dslot].jitter = 2; /* default */
4696 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
4697 ret = mISDN_register_device(&dch->dev, name);
4698 if (ret)
4699 goto free_chan;
4700 hc->created[0] = 1;
4701 return ret;
4702free_chan:
4703 release_port(hc, dch);
4704 return ret;
4705}
4706
4707static int
4708init_multi_port(struct hfc_multi *hc, int pt)
4709{
4710 struct dchannel *dch;
4711 struct bchannel *bch;
4712 int ch, i, ret = 0;
4713 char name[MISDN_MAX_IDLEN];
4714
4715 dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL);
4716 if (!dch)
4717 return -ENOMEM;
4718 dch->debug = debug;
4719 mISDN_initdchannel(dch, MAX_DFRAME_LEN_L1, ph_state_change);
4720 dch->hw = hc;
4721 dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
4722 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
4723 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
4724 dch->dev.D.send = handle_dmsg;
4725 dch->dev.D.ctrl = hfcm_dctrl;
4726 dch->dev.nrbchan = 2;
4727 i = pt << 2;
4728 dch->slot = i + 2;
4729 hc->chan[i + 2].dch = dch;
4730 hc->chan[i + 2].port = pt;
4731 hc->chan[i + 2].nt_timer = -1;
4732 for (ch = 0; ch < dch->dev.nrbchan; ch++) {
4733 bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL);
4734 if (!bch) {
4735 printk(KERN_ERR "%s: no memory for bchannel\n",
4736 __func__);
4737 ret = -ENOMEM;
4738 goto free_chan;
4739 }
4740 hc->chan[i + ch].coeff = kzalloc(512, GFP_KERNEL);
4741 if (!hc->chan[i + ch].coeff) {
4742 printk(KERN_ERR "%s: no memory for coeffs\n",
4743 __func__);
4744 ret = -ENOMEM;
4745 goto free_chan;
4746 }
4747 bch->nr = ch + 1;
4748 bch->slot = i + ch;
4749 bch->debug = debug;
4750 mISDN_initbchannel(bch, MAX_DATA_MEM);
4751 bch->hw = hc;
4752 bch->ch.send = handle_bmsg;
4753 bch->ch.ctrl = hfcm_bctrl;
4754 bch->ch.nr = ch + 1;
4755 list_add(&bch->ch.list, &dch->dev.bchannels);
4756 hc->chan[i + ch].bch = bch;
4757 hc->chan[i + ch].port = pt;
4758 test_and_set_bit(bch->nr, &dch->dev.channelmap[0]);
4759 }
4760 /* set master clock */
4761 if (port[Port_cnt] & 0x001) {
4762 if (debug & DEBUG_HFCMULTI_INIT)
4763 printk(KERN_DEBUG
4764 "%s: PROTOCOL set master clock: "
4765 "card(%d) port(%d)\n",
4766 __func__, HFC_cnt + 1, pt + 1);
4767 if (dch->dev.D.protocol != ISDN_P_TE_S0) {
4768 printk(KERN_ERR "Error: Master clock "
4769 "for port(%d) of card(%d) is only"
4770 " possible with TE-mode\n",
4771 pt + 1, HFC_cnt + 1);
4772 ret = -EINVAL;
4773 goto free_chan;
4774 }
4775 if (hc->masterclk >= 0) {
4776 printk(KERN_ERR "Error: Master clock "
4777 "for port(%d) of card(%d) already "
4778 "defined for port(%d)\n",
4779 pt + 1, HFC_cnt + 1, hc->masterclk+1);
4780 ret = -EINVAL;
4781 goto free_chan;
4782 }
4783 hc->masterclk = pt;
4784 }
4785 /* set transmitter line to non capacitive */
4786 if (port[Port_cnt] & 0x002) {
4787 if (debug & DEBUG_HFCMULTI_INIT)
4788 printk(KERN_DEBUG
4789 "%s: PROTOCOL set non capacitive "
4790 "transmitter: card(%d) port(%d)\n",
4791 __func__, HFC_cnt + 1, pt + 1);
4792 test_and_set_bit(HFC_CFG_NONCAP_TX,
4793 &hc->chan[i + 2].cfg);
4794 }
4795 /* disable E-channel */
4796 if (port[Port_cnt] & 0x004) {
4797 if (debug & DEBUG_HFCMULTI_INIT)
4798 printk(KERN_DEBUG
4799 "%s: PROTOCOL disable E-channel: "
4800 "card(%d) port(%d)\n",
4801 __func__, HFC_cnt + 1, pt + 1);
4802 test_and_set_bit(HFC_CFG_DIS_ECHANNEL,
4803 &hc->chan[i + 2].cfg);
4804 }
4805 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d/%d",
4806 hc->type, HFC_cnt + 1, pt + 1);
4807 ret = mISDN_register_device(&dch->dev, name);
4808 if (ret)
4809 goto free_chan;
4810 hc->created[pt] = 1;
4811 return ret;
4812free_chan:
4813 release_port(hc, dch);
4814 return ret;
4815}
4816
4817static int
4818hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4819{
4820 struct hm_map *m = (struct hm_map *)ent->driver_data;
4821 int ret_err = 0;
4822 int pt;
4823 struct hfc_multi *hc;
4824 u_long flags;
4825 u_char dips = 0, pmj = 0; /* dip settings, port mode Jumpers */
4826
4827 if (HFC_cnt >= MAX_CARDS) {
4828 printk(KERN_ERR "too many cards (max=%d).\n",
4829 MAX_CARDS);
4830 return -EINVAL;
4831 }
4832 if ((type[HFC_cnt] & 0xff) && (type[HFC_cnt] & 0xff) != m->type) {
4833 printk(KERN_WARNING "HFC-MULTI: Card '%s:%s' type %d found but "
4834 "type[%d] %d was supplied as module parameter\n",
4835 m->vendor_name, m->card_name, m->type, HFC_cnt,
4836 type[HFC_cnt] & 0xff);
4837 printk(KERN_WARNING "HFC-MULTI: Load module without parameters "
4838 "first, to see cards and their types.");
4839 return -EINVAL;
4840 }
4841 if (debug & DEBUG_HFCMULTI_INIT)
4842 printk(KERN_DEBUG "%s: Registering %s:%s chip type %d (0x%x)\n",
4843 __func__, m->vendor_name, m->card_name, m->type,
4844 type[HFC_cnt]);
4845
4846 /* allocate card+fifo structure */
4847 hc = kzalloc(sizeof(struct hfc_multi), GFP_KERNEL);
4848 if (!hc) {
4849 printk(KERN_ERR "No kmem for HFC-Multi card\n");
4850 return -ENOMEM;
4851 }
4852 spin_lock_init(&hc->lock);
4853 hc->mtyp = m;
4854 hc->type = m->type;
4855 hc->ports = m->ports;
4856 hc->id = HFC_cnt;
4857 hc->pcm = pcm[HFC_cnt];
4858 hc->io_mode = iomode[HFC_cnt];
4859 if (dslot[HFC_cnt] < 0) {
4860 hc->dslot = 0;
4861 printk(KERN_INFO "HFC-E1 card has disabled D-channel, but "
4862 "31 B-channels\n");
4863 } if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32) {
4864 hc->dslot = dslot[HFC_cnt];
4865 printk(KERN_INFO "HFC-E1 card has alternating D-channel on "
4866 "time slot %d\n", dslot[HFC_cnt]);
4867 } else
4868 hc->dslot = 16;
4869
4870 /* set chip specific features */
4871 hc->masterclk = -1;
4872 if (type[HFC_cnt] & 0x100) {
4873 test_and_set_bit(HFC_CHIP_ULAW, &hc->chip);
4874 silence = 0xff; /* ulaw silence */
4875 } else
4876 silence = 0x2a; /* alaw silence */
4877 if (!(type[HFC_cnt] & 0x200))
4878 test_and_set_bit(HFC_CHIP_DTMF, &hc->chip);
4879
4880 if (type[HFC_cnt] & 0x800)
4881 test_and_set_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
4882 if (type[HFC_cnt] & 0x1000) {
4883 test_and_set_bit(HFC_CHIP_PCM_MASTER, &hc->chip);
4884 test_and_clear_bit(HFC_CHIP_PCM_SLAVE, &hc->chip);
4885 }
4886 if (type[HFC_cnt] & 0x4000)
4887 test_and_set_bit(HFC_CHIP_EXRAM_128, &hc->chip);
4888 if (type[HFC_cnt] & 0x8000)
4889 test_and_set_bit(HFC_CHIP_EXRAM_512, &hc->chip);
4890 hc->slots = 32;
4891 if (type[HFC_cnt] & 0x10000)
4892 hc->slots = 64;
4893 if (type[HFC_cnt] & 0x20000)
4894 hc->slots = 128;
4895 if (type[HFC_cnt] & 0x80000) {
4896 test_and_set_bit(HFC_CHIP_WATCHDOG, &hc->chip);
4897 hc->wdcount = 0;
4898 hc->wdbyte = V_GPIO_OUT2;
4899 printk(KERN_NOTICE "Watchdog enabled\n");
4900 }
4901
4902 /* setup pci, hc->slots may change due to PLXSD */
4903 ret_err = setup_pci(hc, pdev, ent);
4904 if (ret_err) {
4905 if (hc == syncmaster)
4906 syncmaster = NULL;
4907 kfree(hc);
4908 return ret_err;
4909 }
4910
4911 /* crate channels */
4912 for (pt = 0; pt < hc->ports; pt++) {
4913 if (Port_cnt >= MAX_PORTS) {
4914 printk(KERN_ERR "too many ports (max=%d).\n",
4915 MAX_PORTS);
4916 ret_err = -EINVAL;
4917 goto free_card;
4918 }
4919 if (hc->type == 1)
4920 ret_err = init_e1_port(hc, m);
4921 else
4922 ret_err = init_multi_port(hc, pt);
4923 if (debug & DEBUG_HFCMULTI_INIT)
4924 printk(KERN_DEBUG
4925 "%s: Registering D-channel, card(%d) port(%d)"
4926 "result %d\n",
4927 __func__, HFC_cnt + 1, pt, ret_err);
4928
4929 if (ret_err) {
4930 while (pt) { /* release already registered ports */
4931 pt--;
4932 release_port(hc, hc->chan[(pt << 2) + 2].dch);
4933 }
4934 goto free_card;
4935 }
4936 Port_cnt++;
4937 }
4938
4939 /* disp switches */
4940 switch (m->dip_type) {
4941 case DIP_4S:
4942 /*
4943 * get DIP Setting for beroNet 1S/2S/4S cards
4944 * check if Port Jumper config matches
4945 * module param 'protocol'
4946 * DIP Setting: (collect GPIO 13/14/15 (R_GPIO_IN1) +
4947 * GPI 19/23 (R_GPI_IN2))
4948 */
4949 dips = ((~HFC_inb(hc, R_GPIO_IN1) & 0xE0) >> 5) |
4950 ((~HFC_inb(hc, R_GPI_IN2) & 0x80) >> 3) |
4951 (~HFC_inb(hc, R_GPI_IN2) & 0x08);
4952
4953 /* Port mode (TE/NT) jumpers */
4954 pmj = ((HFC_inb(hc, R_GPI_IN3) >> 4) & 0xf);
4955
4956 if (test_bit(HFC_CHIP_B410P, &hc->chip))
4957 pmj = ~pmj & 0xf;
4958
4959 printk(KERN_INFO "%s: %s DIPs(0x%x) jumpers(0x%x)\n",
4960 m->vendor_name, m->card_name, dips, pmj);
4961 break;
4962 case DIP_8S:
4963 /*
4964 * get DIP Setting for beroNet 8S0+ cards
4965 *
4966 * enable PCI auxbridge function
4967 */
4968 HFC_outb(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK);
4969 /* prepare access to auxport */
4970 outw(0x4000, hc->pci_iobase + 4);
4971 /*
4972 * some dummy reads are required to
4973 * read valid DIP switch data
4974 */
4975 dips = inb(hc->pci_iobase);
4976 dips = inb(hc->pci_iobase);
4977 dips = inb(hc->pci_iobase);
4978 dips = ~inb(hc->pci_iobase) & 0x3F;
4979 outw(0x0, hc->pci_iobase + 4);
4980 /* disable PCI auxbridge function */
4981 HFC_outb(hc, R_BRG_PCM_CFG, V_PCM_CLK);
4982 printk(KERN_INFO "%s: %s DIPs(0x%x)\n",
4983 m->vendor_name, m->card_name, dips);
4984 break;
4985 case DIP_E1:
4986 /*
4987 * get DIP Setting for beroNet E1 cards
4988 * DIP Setting: collect GPI 4/5/6/7 (R_GPI_IN0)
4989 */
4990 dips = (~HFC_inb(hc, R_GPI_IN0) & 0xF0)>>4;
4991 printk(KERN_INFO "%s: %s DIPs(0x%x)\n",
4992 m->vendor_name, m->card_name, dips);
4993 break;
4994 }
4995
4996 /* add to list */
4997 spin_lock_irqsave(&HFClock, flags);
4998 list_add_tail(&hc->list, &HFClist);
4999 spin_unlock_irqrestore(&HFClock, flags);
5000
5001 /* initialize hardware */
5002 ret_err = init_card(hc);
5003 if (ret_err) {
5004 printk(KERN_ERR "init card returns %d\n", ret_err);
5005 release_card(hc);
5006 return ret_err;
5007 }
5008
5009 /* start IRQ and return */
5010 spin_lock_irqsave(&hc->lock, flags);
5011 enable_hwirq(hc);
5012 spin_unlock_irqrestore(&hc->lock, flags);
5013 return 0;
5014
5015free_card:
5016 release_io_hfcmulti(hc);
5017 if (hc == syncmaster)
5018 syncmaster = NULL;
5019 kfree(hc);
5020 return ret_err;
5021}
5022
5023static void __devexit hfc_remove_pci(struct pci_dev *pdev)
5024{
5025 struct hfc_multi *card = pci_get_drvdata(pdev);
5026 u_long flags;
5027
5028 if (debug)
5029 printk(KERN_INFO "removing hfc_multi card vendor:%x "
5030 "device:%x subvendor:%x subdevice:%x\n",
5031 pdev->vendor, pdev->device,
5032 pdev->subsystem_vendor, pdev->subsystem_device);
5033
5034 if (card) {
5035 spin_lock_irqsave(&HFClock, flags);
5036 release_card(card);
5037 spin_unlock_irqrestore(&HFClock, flags);
5038 } else {
5039 if (debug)
5040 printk(KERN_WARNING "%s: drvdata allready removed\n",
5041 __func__);
5042 }
5043}
5044
5045#define VENDOR_CCD "Cologne Chip AG"
5046#define VENDOR_BN "beroNet GmbH"
5047#define VENDOR_DIG "Digium Inc."
5048#define VENDOR_JH "Junghanns.NET GmbH"
5049#define VENDOR_PRIM "PrimuX"
5050
5051static const struct hm_map hfcm_map[] = {
5052/*0*/ {VENDOR_BN, "HFC-1S Card (mini PCI)", 4, 1, 1, 3, 0, DIP_4S, 0},
5053/*1*/ {VENDOR_BN, "HFC-2S Card", 4, 2, 1, 3, 0, DIP_4S},
5054/*2*/ {VENDOR_BN, "HFC-2S Card (mini PCI)", 4, 2, 1, 3, 0, DIP_4S, 0},
5055/*3*/ {VENDOR_BN, "HFC-4S Card", 4, 4, 1, 2, 0, DIP_4S, 0},
5056/*4*/ {VENDOR_BN, "HFC-4S Card (mini PCI)", 4, 4, 1, 2, 0, 0, 0},
5057/*5*/ {VENDOR_CCD, "HFC-4S Eval (old)", 4, 4, 0, 0, 0, 0, 0},
5058/*6*/ {VENDOR_CCD, "HFC-4S IOB4ST", 4, 4, 1, 2, 0, 0, 0},
5059/*7*/ {VENDOR_CCD, "HFC-4S", 4, 4, 1, 2, 0, 0, 0},
5060/*8*/ {VENDOR_DIG, "HFC-4S Card", 4, 4, 0, 2, 0, 0, HFC_IO_MODE_REGIO},
5061/*9*/ {VENDOR_CCD, "HFC-4S Swyx 4xS0 SX2 QuadBri", 4, 4, 1, 2, 0, 0, 0},
5062/*10*/ {VENDOR_JH, "HFC-4S (junghanns 2.0)", 4, 4, 1, 2, 0, 0, 0},
5063/*11*/ {VENDOR_PRIM, "HFC-2S Primux Card", 4, 2, 0, 0, 0, 0, 0},
5064
5065/*12*/ {VENDOR_BN, "HFC-8S Card", 8, 8, 1, 0, 0, 0, 0},
5066/*13*/ {VENDOR_BN, "HFC-8S Card (+)", 8, 8, 1, 8, 0, DIP_8S,
5067 HFC_IO_MODE_REGIO},
5068/*14*/ {VENDOR_CCD, "HFC-8S Eval (old)", 8, 8, 0, 0, 0, 0, 0},
5069/*15*/ {VENDOR_CCD, "HFC-8S IOB4ST Recording", 8, 8, 1, 0, 0, 0, 0},
5070
5071/*16*/ {VENDOR_CCD, "HFC-8S IOB8ST", 8, 8, 1, 0, 0, 0, 0},
5072/*17*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0},
5073/*18*/ {VENDOR_CCD, "HFC-8S", 8, 8, 1, 0, 0, 0, 0},
5074
5075/*19*/ {VENDOR_BN, "HFC-E1 Card", 1, 1, 0, 1, 0, DIP_E1, 0},
5076/*20*/ {VENDOR_BN, "HFC-E1 Card (mini PCI)", 1, 1, 0, 1, 0, 0, 0},
5077/*21*/ {VENDOR_BN, "HFC-E1+ Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0},
5078/*22*/ {VENDOR_BN, "HFC-E1 Card (Dual)", 1, 1, 0, 1, 0, DIP_E1, 0},
5079
5080/*23*/ {VENDOR_CCD, "HFC-E1 Eval (old)", 1, 1, 0, 0, 0, 0, 0},
5081/*24*/ {VENDOR_CCD, "HFC-E1 IOB1E1", 1, 1, 0, 1, 0, 0, 0},
5082/*25*/ {VENDOR_CCD, "HFC-E1", 1, 1, 0, 1, 0, 0, 0},
5083
5084/*26*/ {VENDOR_CCD, "HFC-4S Speech Design", 4, 4, 0, 0, 0, 0,
5085 HFC_IO_MODE_PLXSD},
5086/*27*/ {VENDOR_CCD, "HFC-E1 Speech Design", 1, 1, 0, 0, 0, 0,
5087 HFC_IO_MODE_PLXSD},
5088/*28*/ {VENDOR_CCD, "HFC-4S OpenVox", 4, 4, 1, 0, 0, 0, 0},
5089/*29*/ {VENDOR_CCD, "HFC-2S OpenVox", 4, 2, 1, 0, 0, 0, 0},
5090/*30*/ {VENDOR_CCD, "HFC-8S OpenVox", 8, 8, 1, 0, 0, 0, 0},
5091};
5092
5093#undef H
5094#define H(x) ((unsigned long)&hfcm_map[x])
5095static struct pci_device_id hfmultipci_ids[] __devinitdata = {
5096
5097 /* Cards with HFC-4S Chip */
5098 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5099 PCI_SUBDEVICE_ID_CCD_BN1SM, 0, 0, H(0)}, /* BN1S mini PCI */
5100 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5101 PCI_SUBDEVICE_ID_CCD_BN2S, 0, 0, H(1)}, /* BN2S */
5102 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5103 PCI_SUBDEVICE_ID_CCD_BN2SM, 0, 0, H(2)}, /* BN2S mini PCI */
5104 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5105 PCI_SUBDEVICE_ID_CCD_BN4S, 0, 0, H(3)}, /* BN4S */
5106 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5107 PCI_SUBDEVICE_ID_CCD_BN4SM, 0, 0, H(4)}, /* BN4S mini PCI */
5108 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5109 PCI_DEVICE_ID_CCD_HFC4S, 0, 0, H(5)}, /* Old Eval */
5110 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5111 PCI_SUBDEVICE_ID_CCD_IOB4ST, 0, 0, H(6)}, /* IOB4ST */
5112 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5113 PCI_SUBDEVICE_ID_CCD_HFC4S, 0, 0, H(7)}, /* 4S */
5114 { PCI_VENDOR_ID_DIGIUM, PCI_DEVICE_ID_DIGIUM_HFC4S,
5115 PCI_VENDOR_ID_DIGIUM, PCI_DEVICE_ID_DIGIUM_HFC4S, 0, 0, H(8)},
5116 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5117 PCI_SUBDEVICE_ID_CCD_SWYX4S, 0, 0, H(9)}, /* 4S Swyx */
5118 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5119 PCI_SUBDEVICE_ID_CCD_JH4S20, 0, 0, H(10)},
5120 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5121 PCI_SUBDEVICE_ID_CCD_PMX2S, 0, 0, H(11)}, /* Primux */
5122 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5123 PCI_SUBDEVICE_ID_CCD_OV4S, 0, 0, H(28)}, /* OpenVox 4 */
5124 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD,
5125 PCI_SUBDEVICE_ID_CCD_OV2S, 0, 0, H(29)}, /* OpenVox 2 */
5126
5127 /* Cards with HFC-8S Chip */
5128 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5129 PCI_SUBDEVICE_ID_CCD_BN8S, 0, 0, H(12)}, /* BN8S */
5130 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5131 PCI_SUBDEVICE_ID_CCD_BN8SP, 0, 0, H(13)}, /* BN8S+ */
5132 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5133 PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */
5134 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5135 PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)},
5136 /* IOB8ST Recording */
5137 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5138 PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST */
5139 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5140 PCI_SUBDEVICE_ID_CCD_IOB8ST_1, 0, 0, H(17)}, /* IOB8ST */
5141 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5142 PCI_SUBDEVICE_ID_CCD_HFC8S, 0, 0, H(18)}, /* 8S */
5143 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5144 PCI_SUBDEVICE_ID_CCD_OV8S, 0, 0, H(30)}, /* OpenVox 8 */
5145
5146
5147 /* Cards with HFC-E1 Chip */
5148 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5149 PCI_SUBDEVICE_ID_CCD_BNE1, 0, 0, H(19)}, /* BNE1 */
5150 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5151 PCI_SUBDEVICE_ID_CCD_BNE1M, 0, 0, H(20)}, /* BNE1 mini PCI */
5152 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5153 PCI_SUBDEVICE_ID_CCD_BNE1DP, 0, 0, H(21)}, /* BNE1 + (Dual) */
5154 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5155 PCI_SUBDEVICE_ID_CCD_BNE1D, 0, 0, H(22)}, /* BNE1 (Dual) */
5156
5157 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5158 PCI_DEVICE_ID_CCD_HFCE1, 0, 0, H(23)}, /* Old Eval */
5159 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5160 PCI_SUBDEVICE_ID_CCD_IOB1E1, 0, 0, H(24)}, /* IOB1E1 */
5161 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_VENDOR_ID_CCD,
5162 PCI_SUBDEVICE_ID_CCD_HFCE1, 0, 0, H(25)}, /* E1 */
5163
5164 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_CCD,
5165 PCI_SUBDEVICE_ID_CCD_SPD4S, 0, 0, H(26)}, /* PLX PCI Bridge */
5166 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_CCD,
5167 PCI_SUBDEVICE_ID_CCD_SPDE1, 0, 0, H(27)}, /* PLX PCI Bridge */
5168 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_ANY_ID, PCI_ANY_ID,
5169 0, 0, 0},
5170 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_ANY_ID, PCI_ANY_ID,
5171 0, 0, 0},
5172 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFCE1, PCI_ANY_ID, PCI_ANY_ID,
5173 0, 0, 0},
5174 {0, }
5175};
5176#undef H
5177
5178MODULE_DEVICE_TABLE(pci, hfmultipci_ids);
5179
5180static int
5181hfcmulti_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5182{
5183 struct hm_map *m = (struct hm_map *)ent->driver_data;
5184 int ret;
5185
5186 if (m == NULL) {
5187 if (ent->vendor == PCI_VENDOR_ID_CCD)
5188 if (ent->device == PCI_DEVICE_ID_CCD_HFC4S ||
5189 ent->device == PCI_DEVICE_ID_CCD_HFC8S ||
5190 ent->device == PCI_DEVICE_ID_CCD_HFCE1)
5191 printk(KERN_ERR
5192 "unknown HFC multiport controller "
5193 "(vendor:%x device:%x subvendor:%x "
5194 "subdevice:%x) Please contact the "
5195 "driver maintainer for support.\n",
5196 ent->vendor, ent->device,
5197 ent->subvendor, ent->subdevice);
5198 return -ENODEV;
5199 }
5200 ret = hfcmulti_init(pdev, ent);
5201 if (ret)
5202 return ret;
5203 HFC_cnt++;
5204 printk(KERN_INFO "%d devices registered\n", HFC_cnt);
5205 return 0;
5206}
5207
5208static struct pci_driver hfcmultipci_driver = {
5209 .name = "hfc_multi",
5210 .probe = hfcmulti_probe,
5211 .remove = __devexit_p(hfc_remove_pci),
5212 .id_table = hfmultipci_ids,
5213};
5214
5215static void __exit
5216HFCmulti_cleanup(void)
5217{
5218 struct hfc_multi *card, *next;
5219
5220 /* unload interrupt function symbol */
5221 if (hfc_interrupt)
5222 symbol_put(ztdummy_extern_interrupt);
5223 if (register_interrupt)
5224 symbol_put(ztdummy_register_interrupt);
5225 if (unregister_interrupt) {
5226 if (interrupt_registered) {
5227 interrupt_registered = 0;
5228 unregister_interrupt();
5229 }
5230 symbol_put(ztdummy_unregister_interrupt);
5231 }
5232
5233 list_for_each_entry_safe(card, next, &HFClist, list)
5234 release_card(card);
5235 /* get rid of all devices of this driver */
5236 pci_unregister_driver(&hfcmultipci_driver);
5237}
5238
5239static int __init
5240HFCmulti_init(void)
5241{
5242 int err;
5243
5244#ifdef IRQ_DEBUG
5245 printk(KERN_ERR "%s: IRQ_DEBUG IS ENABLED!\n", __func__);
5246#endif
5247
5248 spin_lock_init(&HFClock);
5249 spin_lock_init(&plx_lock);
5250
5251 if (debug & DEBUG_HFCMULTI_INIT)
5252 printk(KERN_DEBUG "%s: init entered\n", __func__);
5253
5254#ifdef __BIG_ENDIAN
5255#error "not running on big endian machines now"
5256#endif
5257 hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
5258 register_interrupt = symbol_get(ztdummy_register_interrupt);
5259 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
5260 printk(KERN_INFO "mISDN: HFC-multi driver %s\n",
5261 hfcmulti_revision);
5262
5263 switch (poll) {
5264 case 0:
5265 poll_timer = 6;
5266 poll = 128;
5267 break;
5268 /*
5269 * wenn dieses break nochmal verschwindet,
5270 * gibt es heisse ohren :-)
5271 * "without the break you will get hot ears ???"
5272 */
5273 case 8:
5274 poll_timer = 2;
5275 break;
5276 case 16:
5277 poll_timer = 3;
5278 break;
5279 case 32:
5280 poll_timer = 4;
5281 break;
5282 case 64:
5283 poll_timer = 5;
5284 break;
5285 case 128:
5286 poll_timer = 6;
5287 break;
5288 case 256:
5289 poll_timer = 7;
5290 break;
5291 default:
5292 printk(KERN_ERR
5293 "%s: Wrong poll value (%d).\n", __func__, poll);
5294 err = -EINVAL;
5295 return err;
5296
5297 }
5298
5299 err = pci_register_driver(&hfcmultipci_driver);
5300 if (err < 0) {
5301 printk(KERN_ERR "error registering pci driver: %x\n", err);
5302 if (hfc_interrupt)
5303 symbol_put(ztdummy_extern_interrupt);
5304 if (register_interrupt)
5305 symbol_put(ztdummy_register_interrupt);
5306 if (unregister_interrupt) {
5307 if (interrupt_registered) {
5308 interrupt_registered = 0;
5309 unregister_interrupt();
5310 }
5311 symbol_put(ztdummy_unregister_interrupt);
5312 }
5313 return err;
5314 }
5315 return 0;
5316}
5317
5318
5319module_init(HFCmulti_init);
5320module_exit(HFCmulti_cleanup);
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
new file mode 100644
index 000000000000..3231814e7efa
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -0,0 +1,2255 @@
1/*
2 *
3 * hfcpci.c low level driver for CCD's hfc-pci based cards
4 *
5 * Author Werner Cornelius (werner@isdn4linux.de)
6 * based on existing driver for CCD hfc ISA cards
7 * type approval valid for HFC-S PCI A based card
8 *
9 * Copyright 1999 by Werner Cornelius (werner@isdn-development.de)
10 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 */
27
28#include <linux/module.h>
29#include <linux/pci.h>
30#include <linux/delay.h>
31#include <linux/mISDNhw.h>
32
33#include "hfc_pci.h"
34
35static const char *hfcpci_revision = "2.0";
36
37#define MAX_CARDS 8
38static int HFC_cnt;
39static uint debug;
40
41MODULE_AUTHOR("Karsten Keil");
42MODULE_LICENSE("GPL");
43module_param(debug, uint, 0);
44
45static LIST_HEAD(HFClist);
46DEFINE_RWLOCK(HFClock);
47
48enum {
49 HFC_CCD_2BD0,
50 HFC_CCD_B000,
51 HFC_CCD_B006,
52 HFC_CCD_B007,
53 HFC_CCD_B008,
54 HFC_CCD_B009,
55 HFC_CCD_B00A,
56 HFC_CCD_B00B,
57 HFC_CCD_B00C,
58 HFC_CCD_B100,
59 HFC_CCD_B700,
60 HFC_CCD_B701,
61 HFC_ASUS_0675,
62 HFC_BERKOM_A1T,
63 HFC_BERKOM_TCONCEPT,
64 HFC_ANIGMA_MC145575,
65 HFC_ZOLTRIX_2BD0,
66 HFC_DIGI_DF_M_IOM2_E,
67 HFC_DIGI_DF_M_E,
68 HFC_DIGI_DF_M_IOM2_A,
69 HFC_DIGI_DF_M_A,
70 HFC_ABOCOM_2BD1,
71 HFC_SITECOM_DC105V2,
72};
73
74struct hfcPCI_hw {
75 unsigned char cirm;
76 unsigned char ctmt;
77 unsigned char clkdel;
78 unsigned char states;
79 unsigned char conn;
80 unsigned char mst_m;
81 unsigned char int_m1;
82 unsigned char int_m2;
83 unsigned char sctrl;
84 unsigned char sctrl_r;
85 unsigned char sctrl_e;
86 unsigned char trm;
87 unsigned char fifo_en;
88 unsigned char bswapped;
89 unsigned char protocol;
90 int nt_timer;
91 unsigned char *pci_io; /* start of PCI IO memory */
92 dma_addr_t dmahandle;
93 void *fifos; /* FIFO memory */
94 int last_bfifo_cnt[2];
95 /* marker saving last b-fifo frame count */
96 struct timer_list timer;
97};
98
99#define HFC_CFG_MASTER 1
100#define HFC_CFG_SLAVE 2
101#define HFC_CFG_PCM 3
102#define HFC_CFG_2HFC 4
103#define HFC_CFG_SLAVEHFC 5
104#define HFC_CFG_NEG_F0 6
105#define HFC_CFG_SW_DD_DU 7
106
107#define FLG_HFC_TIMER_T1 16
108#define FLG_HFC_TIMER_T3 17
109
110#define NT_T1_COUNT 1120 /* number of 3.125ms interrupts (3.5s) */
111#define NT_T3_COUNT 31 /* number of 3.125ms interrupts (97 ms) */
112#define CLKDEL_TE 0x0e /* CLKDEL in TE mode */
113#define CLKDEL_NT 0x6c /* CLKDEL in NT mode */
114
115
116struct hfc_pci {
117 struct list_head list;
118 u_char subtype;
119 u_char chanlimit;
120 u_char initdone;
121 u_long cfg;
122 u_int irq;
123 u_int irqcnt;
124 struct pci_dev *pdev;
125 struct hfcPCI_hw hw;
126 spinlock_t lock; /* card lock */
127 struct dchannel dch;
128 struct bchannel bch[2];
129};
130
131/* Interface functions */
132static void
133enable_hwirq(struct hfc_pci *hc)
134{
135 hc->hw.int_m2 |= HFCPCI_IRQ_ENABLE;
136 Write_hfc(hc, HFCPCI_INT_M2, hc->hw.int_m2);
137}
138
139static void
140disable_hwirq(struct hfc_pci *hc)
141{
142 hc->hw.int_m2 &= ~((u_char)HFCPCI_IRQ_ENABLE);
143 Write_hfc(hc, HFCPCI_INT_M2, hc->hw.int_m2);
144}
145
146/*
147 * free hardware resources used by driver
148 */
149static void
150release_io_hfcpci(struct hfc_pci *hc)
151{
152 /* disable memory mapped ports + busmaster */
153 pci_write_config_word(hc->pdev, PCI_COMMAND, 0);
154 del_timer(&hc->hw.timer);
155 pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos, hc->hw.dmahandle);
156 iounmap((void *)hc->hw.pci_io);
157}
158
159/*
160 * set mode (NT or TE)
161 */
162static void
163hfcpci_setmode(struct hfc_pci *hc)
164{
165 if (hc->hw.protocol == ISDN_P_NT_S0) {
166 hc->hw.clkdel = CLKDEL_NT; /* ST-Bit delay for NT-Mode */
167 hc->hw.sctrl |= SCTRL_MODE_NT; /* NT-MODE */
168 hc->hw.states = 1; /* G1 */
169 } else {
170 hc->hw.clkdel = CLKDEL_TE; /* ST-Bit delay for TE-Mode */
171 hc->hw.sctrl &= ~SCTRL_MODE_NT; /* TE-MODE */
172 hc->hw.states = 2; /* F2 */
173 }
174 Write_hfc(hc, HFCPCI_CLKDEL, hc->hw.clkdel);
175 Write_hfc(hc, HFCPCI_STATES, HFCPCI_LOAD_STATE | hc->hw.states);
176 udelay(10);
177 Write_hfc(hc, HFCPCI_STATES, hc->hw.states | 0x40); /* Deactivate */
178 Write_hfc(hc, HFCPCI_SCTRL, hc->hw.sctrl);
179}
180
181/*
182 * function called to reset the HFC PCI chip. A complete software reset of chip
183 * and fifos is done.
184 */
185static void
186reset_hfcpci(struct hfc_pci *hc)
187{
188 u_char val;
189 int cnt = 0;
190
191 printk(KERN_DEBUG "reset_hfcpci: entered\n");
192 val = Read_hfc(hc, HFCPCI_CHIP_ID);
193 printk(KERN_INFO "HFC_PCI: resetting HFC ChipId(%x)\n", val);
194 /* enable memory mapped ports, disable busmaster */
195 pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
196 disable_hwirq(hc);
197 /* enable memory ports + busmaster */
198 pci_write_config_word(hc->pdev, PCI_COMMAND,
199 PCI_ENA_MEMIO + PCI_ENA_MASTER);
200 val = Read_hfc(hc, HFCPCI_STATUS);
201 printk(KERN_DEBUG "HFC-PCI status(%x) before reset\n", val);
202 hc->hw.cirm = HFCPCI_RESET; /* Reset On */
203 Write_hfc(hc, HFCPCI_CIRM, hc->hw.cirm);
204 set_current_state(TASK_UNINTERRUPTIBLE);
205 mdelay(10); /* Timeout 10ms */
206 hc->hw.cirm = 0; /* Reset Off */
207 Write_hfc(hc, HFCPCI_CIRM, hc->hw.cirm);
208 val = Read_hfc(hc, HFCPCI_STATUS);
209 printk(KERN_DEBUG "HFC-PCI status(%x) after reset\n", val);
210 while (cnt < 50000) { /* max 50000 us */
211 udelay(5);
212 cnt += 5;
213 val = Read_hfc(hc, HFCPCI_STATUS);
214 if (!(val & 2))
215 break;
216 }
217 printk(KERN_DEBUG "HFC-PCI status(%x) after %dus\n", val, cnt);
218
219 hc->hw.fifo_en = 0x30; /* only D fifos enabled */
220
221 hc->hw.bswapped = 0; /* no exchange */
222 hc->hw.ctmt = HFCPCI_TIM3_125 | HFCPCI_AUTO_TIMER;
223 hc->hw.trm = HFCPCI_BTRANS_THRESMASK; /* no echo connect , threshold */
224 hc->hw.sctrl = 0x40; /* set tx_lo mode, error in datasheet ! */
225 hc->hw.sctrl_r = 0;
226 hc->hw.sctrl_e = HFCPCI_AUTO_AWAKE; /* S/T Auto awake */
227 hc->hw.mst_m = 0;
228 if (test_bit(HFC_CFG_MASTER, &hc->cfg))
229 hc->hw.mst_m |= HFCPCI_MASTER; /* HFC Master Mode */
230 if (test_bit(HFC_CFG_NEG_F0, &hc->cfg))
231 hc->hw.mst_m |= HFCPCI_F0_NEGATIV;
232 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
233 Write_hfc(hc, HFCPCI_TRM, hc->hw.trm);
234 Write_hfc(hc, HFCPCI_SCTRL_E, hc->hw.sctrl_e);
235 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt);
236
237 hc->hw.int_m1 = HFCPCI_INTS_DTRANS | HFCPCI_INTS_DREC |
238 HFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER;
239 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
240
241 /* Clear already pending ints */
242 if (Read_hfc(hc, HFCPCI_INT_S1));
243
244 /* set NT/TE mode */
245 hfcpci_setmode(hc);
246
247 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
248 Write_hfc(hc, HFCPCI_SCTRL_R, hc->hw.sctrl_r);
249
250 /*
251 * Init GCI/IOM2 in master mode
252 * Slots 0 and 1 are set for B-chan 1 and 2
253 * D- and monitor/CI channel are not enabled
254 * STIO1 is used as output for data, B1+B2 from ST->IOM+HFC
255 * STIO2 is used as data input, B1+B2 from IOM->ST
256 * ST B-channel send disabled -> continous 1s
257 * The IOM slots are always enabled
258 */
259 if (test_bit(HFC_CFG_PCM, &hc->cfg)) {
260 /* set data flow directions: connect B1,B2: HFC to/from PCM */
261 hc->hw.conn = 0x09;
262 } else {
263 hc->hw.conn = 0x36; /* set data flow directions */
264 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg)) {
265 Write_hfc(hc, HFCPCI_B1_SSL, 0xC0);
266 Write_hfc(hc, HFCPCI_B2_SSL, 0xC1);
267 Write_hfc(hc, HFCPCI_B1_RSL, 0xC0);
268 Write_hfc(hc, HFCPCI_B2_RSL, 0xC1);
269 } else {
270 Write_hfc(hc, HFCPCI_B1_SSL, 0x80);
271 Write_hfc(hc, HFCPCI_B2_SSL, 0x81);
272 Write_hfc(hc, HFCPCI_B1_RSL, 0x80);
273 Write_hfc(hc, HFCPCI_B2_RSL, 0x81);
274 }
275 }
276 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
277 val = Read_hfc(hc, HFCPCI_INT_S2);
278}
279
280/*
281 * Timer function called when kernel timer expires
282 */
283static void
284hfcpci_Timer(struct hfc_pci *hc)
285{
286 hc->hw.timer.expires = jiffies + 75;
287 /* WD RESET */
288/*
289 * WriteReg(hc, HFCD_DATA, HFCD_CTMT, hc->hw.ctmt | 0x80);
290 * add_timer(&hc->hw.timer);
291 */
292}
293
294
295/*
296 * select a b-channel entry matching and active
297 */
298static struct bchannel *
299Sel_BCS(struct hfc_pci *hc, int channel)
300{
301 if (test_bit(FLG_ACTIVE, &hc->bch[0].Flags) &&
302 (hc->bch[0].nr & channel))
303 return &hc->bch[0];
304 else if (test_bit(FLG_ACTIVE, &hc->bch[1].Flags) &&
305 (hc->bch[1].nr & channel))
306 return &hc->bch[1];
307 else
308 return NULL;
309}
310
311/*
312 * clear the desired B-channel rx fifo
313 */
314static void
315hfcpci_clear_fifo_rx(struct hfc_pci *hc, int fifo)
316{
317 u_char fifo_state;
318 struct bzfifo *bzr;
319
320 if (fifo) {
321 bzr = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
322 fifo_state = hc->hw.fifo_en & HFCPCI_FIFOEN_B2RX;
323 } else {
324 bzr = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1;
325 fifo_state = hc->hw.fifo_en & HFCPCI_FIFOEN_B1RX;
326 }
327 if (fifo_state)
328 hc->hw.fifo_en ^= fifo_state;
329 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
330 hc->hw.last_bfifo_cnt[fifo] = 0;
331 bzr->f1 = MAX_B_FRAMES;
332 bzr->f2 = bzr->f1; /* init F pointers to remain constant */
333 bzr->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1);
334 bzr->za[MAX_B_FRAMES].z2 = cpu_to_le16(
335 le16_to_cpu(bzr->za[MAX_B_FRAMES].z1));
336 if (fifo_state)
337 hc->hw.fifo_en |= fifo_state;
338 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
339}
340
341/*
342 * clear the desired B-channel tx fifo
343 */
344static void hfcpci_clear_fifo_tx(struct hfc_pci *hc, int fifo)
345{
346 u_char fifo_state;
347 struct bzfifo *bzt;
348
349 if (fifo) {
350 bzt = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2;
351 fifo_state = hc->hw.fifo_en & HFCPCI_FIFOEN_B2TX;
352 } else {
353 bzt = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b1;
354 fifo_state = hc->hw.fifo_en & HFCPCI_FIFOEN_B1TX;
355 }
356 if (fifo_state)
357 hc->hw.fifo_en ^= fifo_state;
358 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
359 if (hc->bch[fifo].debug & DEBUG_HW_BCHANNEL)
360 printk(KERN_DEBUG "hfcpci_clear_fifo_tx%d f1(%x) f2(%x) "
361 "z1(%x) z2(%x) state(%x)\n",
362 fifo, bzt->f1, bzt->f2,
363 le16_to_cpu(bzt->za[MAX_B_FRAMES].z1),
364 le16_to_cpu(bzt->za[MAX_B_FRAMES].z2),
365 fifo_state);
366 bzt->f2 = MAX_B_FRAMES;
367 bzt->f1 = bzt->f2; /* init F pointers to remain constant */
368 bzt->za[MAX_B_FRAMES].z1 = cpu_to_le16(B_FIFO_SIZE + B_SUB_VAL - 1);
369 bzt->za[MAX_B_FRAMES].z2 = cpu_to_le16(
370 le16_to_cpu(bzt->za[MAX_B_FRAMES].z1 - 1));
371 if (fifo_state)
372 hc->hw.fifo_en |= fifo_state;
373 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
374 if (hc->bch[fifo].debug & DEBUG_HW_BCHANNEL)
375 printk(KERN_DEBUG
376 "hfcpci_clear_fifo_tx%d f1(%x) f2(%x) z1(%x) z2(%x)\n",
377 fifo, bzt->f1, bzt->f2,
378 le16_to_cpu(bzt->za[MAX_B_FRAMES].z1),
379 le16_to_cpu(bzt->za[MAX_B_FRAMES].z2));
380}
381
382/*
383 * read a complete B-frame out of the buffer
384 */
385static void
386hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz,
387 u_char *bdata, int count)
388{
389 u_char *ptr, *ptr1, new_f2;
390 int total, maxlen, new_z2;
391 struct zt *zp;
392
393 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO))
394 printk(KERN_DEBUG "hfcpci_empty_fifo\n");
395 zp = &bz->za[bz->f2]; /* point to Z-Regs */
396 new_z2 = le16_to_cpu(zp->z2) + count; /* new position in fifo */
397 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
398 new_z2 -= B_FIFO_SIZE; /* buffer wrap */
399 new_f2 = (bz->f2 + 1) & MAX_B_FRAMES;
400 if ((count > MAX_DATA_SIZE + 3) || (count < 4) ||
401 (*(bdata + (le16_to_cpu(zp->z1) - B_SUB_VAL)))) {
402 if (bch->debug & DEBUG_HW)
403 printk(KERN_DEBUG "hfcpci_empty_fifo: incoming packet "
404 "invalid length %d or crc\n", count);
405#ifdef ERROR_STATISTIC
406 bch->err_inv++;
407#endif
408 bz->za[new_f2].z2 = cpu_to_le16(new_z2);
409 bz->f2 = new_f2; /* next buffer */
410 } else {
411 bch->rx_skb = mI_alloc_skb(count - 3, GFP_ATOMIC);
412 if (!bch->rx_skb) {
413 printk(KERN_WARNING "HFCPCI: receive out of memory\n");
414 return;
415 }
416 total = count;
417 count -= 3;
418 ptr = skb_put(bch->rx_skb, count);
419
420 if (le16_to_cpu(zp->z2) + count <= B_FIFO_SIZE + B_SUB_VAL)
421 maxlen = count; /* complete transfer */
422 else
423 maxlen = B_FIFO_SIZE + B_SUB_VAL -
424 le16_to_cpu(zp->z2); /* maximum */
425
426 ptr1 = bdata + (le16_to_cpu(zp->z2) - B_SUB_VAL);
427 /* start of data */
428 memcpy(ptr, ptr1, maxlen); /* copy data */
429 count -= maxlen;
430
431 if (count) { /* rest remaining */
432 ptr += maxlen;
433 ptr1 = bdata; /* start of buffer */
434 memcpy(ptr, ptr1, count); /* rest */
435 }
436 bz->za[new_f2].z2 = cpu_to_le16(new_z2);
437 bz->f2 = new_f2; /* next buffer */
438 recv_Bchannel(bch);
439 }
440}
441
442/*
443 * D-channel receive procedure
444 */
445static int
446receive_dmsg(struct hfc_pci *hc)
447{
448 struct dchannel *dch = &hc->dch;
449 int maxlen;
450 int rcnt, total;
451 int count = 5;
452 u_char *ptr, *ptr1;
453 struct dfifo *df;
454 struct zt *zp;
455
456 df = &((union fifo_area *)(hc->hw.fifos))->d_chan.d_rx;
457 while (((df->f1 & D_FREG_MASK) != (df->f2 & D_FREG_MASK)) && count--) {
458 zp = &df->za[df->f2 & D_FREG_MASK];
459 rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2);
460 if (rcnt < 0)
461 rcnt += D_FIFO_SIZE;
462 rcnt++;
463 if (dch->debug & DEBUG_HW_DCHANNEL)
464 printk(KERN_DEBUG
465 "hfcpci recd f1(%d) f2(%d) z1(%x) z2(%x) cnt(%d)\n",
466 df->f1, df->f2,
467 le16_to_cpu(zp->z1),
468 le16_to_cpu(zp->z2),
469 rcnt);
470
471 if ((rcnt > MAX_DFRAME_LEN + 3) || (rcnt < 4) ||
472 (df->data[le16_to_cpu(zp->z1)])) {
473 if (dch->debug & DEBUG_HW)
474 printk(KERN_DEBUG
475 "empty_fifo hfcpci paket inv. len "
476 "%d or crc %d\n",
477 rcnt,
478 df->data[le16_to_cpu(zp->z1)]);
479#ifdef ERROR_STATISTIC
480 cs->err_rx++;
481#endif
482 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) |
483 (MAX_D_FRAMES + 1); /* next buffer */
484 df->za[df->f2 & D_FREG_MASK].z2 =
485 cpu_to_le16((zp->z2 + rcnt) & (D_FIFO_SIZE - 1));
486 } else {
487 dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC);
488 if (!dch->rx_skb) {
489 printk(KERN_WARNING
490 "HFC-PCI: D receive out of memory\n");
491 break;
492 }
493 total = rcnt;
494 rcnt -= 3;
495 ptr = skb_put(dch->rx_skb, rcnt);
496
497 if (le16_to_cpu(zp->z2) + rcnt <= D_FIFO_SIZE)
498 maxlen = rcnt; /* complete transfer */
499 else
500 maxlen = D_FIFO_SIZE - le16_to_cpu(zp->z2);
501 /* maximum */
502
503 ptr1 = df->data + le16_to_cpu(zp->z2);
504 /* start of data */
505 memcpy(ptr, ptr1, maxlen); /* copy data */
506 rcnt -= maxlen;
507
508 if (rcnt) { /* rest remaining */
509 ptr += maxlen;
510 ptr1 = df->data; /* start of buffer */
511 memcpy(ptr, ptr1, rcnt); /* rest */
512 }
513 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) |
514 (MAX_D_FRAMES + 1); /* next buffer */
515 df->za[df->f2 & D_FREG_MASK].z2 = cpu_to_le16((
516 le16_to_cpu(zp->z2) + total) & (D_FIFO_SIZE - 1));
517 recv_Dchannel(dch);
518 }
519 }
520 return 1;
521}
522
523/*
524 * check for transparent receive data and read max one threshold size if avail
525 */
526int
527hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
528{
529 unsigned short *z1r, *z2r;
530 int new_z2, fcnt, maxlen;
531 u_char *ptr, *ptr1;
532
533 z1r = &bz->za[MAX_B_FRAMES].z1; /* pointer to z reg */
534 z2r = z1r + 1;
535
536 fcnt = le16_to_cpu(*z1r) - le16_to_cpu(*z2r);
537 if (!fcnt)
538 return 0; /* no data avail */
539
540 if (fcnt <= 0)
541 fcnt += B_FIFO_SIZE; /* bytes actually buffered */
542 if (fcnt > HFCPCI_BTRANS_THRESHOLD)
543 fcnt = HFCPCI_BTRANS_THRESHOLD; /* limit size */
544
545 new_z2 = le16_to_cpu(*z2r) + fcnt; /* new position in fifo */
546 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
547 new_z2 -= B_FIFO_SIZE; /* buffer wrap */
548
549 bch->rx_skb = mI_alloc_skb(fcnt, GFP_ATOMIC);
550 if (bch->rx_skb) {
551 ptr = skb_put(bch->rx_skb, fcnt);
552 if (le16_to_cpu(*z2r) + fcnt <= B_FIFO_SIZE + B_SUB_VAL)
553 maxlen = fcnt; /* complete transfer */
554 else
555 maxlen = B_FIFO_SIZE + B_SUB_VAL - le16_to_cpu(*z2r);
556 /* maximum */
557
558 ptr1 = bdata + (le16_to_cpu(*z2r) - B_SUB_VAL);
559 /* start of data */
560 memcpy(ptr, ptr1, maxlen); /* copy data */
561 fcnt -= maxlen;
562
563 if (fcnt) { /* rest remaining */
564 ptr += maxlen;
565 ptr1 = bdata; /* start of buffer */
566 memcpy(ptr, ptr1, fcnt); /* rest */
567 }
568 recv_Bchannel(bch);
569 } else
570 printk(KERN_WARNING "HFCPCI: receive out of memory\n");
571
572 *z2r = cpu_to_le16(new_z2); /* new position */
573 return 1;
574}
575
576/*
577 * B-channel main receive routine
578 */
579void
580main_rec_hfcpci(struct bchannel *bch)
581{
582 struct hfc_pci *hc = bch->hw;
583 int rcnt, real_fifo;
584 int receive, count = 5;
585 struct bzfifo *bz;
586 u_char *bdata;
587 struct zt *zp;
588
589
590 if ((bch->nr & 2) && (!hc->hw.bswapped)) {
591 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
592 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2;
593 real_fifo = 1;
594 } else {
595 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1;
596 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b1;
597 real_fifo = 0;
598 }
599Begin:
600 count--;
601 if (bz->f1 != bz->f2) {
602 if (bch->debug & DEBUG_HW_BCHANNEL)
603 printk(KERN_DEBUG "hfcpci rec ch(%x) f1(%d) f2(%d)\n",
604 bch->nr, bz->f1, bz->f2);
605 zp = &bz->za[bz->f2];
606
607 rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2);
608 if (rcnt < 0)
609 rcnt += B_FIFO_SIZE;
610 rcnt++;
611 if (bch->debug & DEBUG_HW_BCHANNEL)
612 printk(KERN_DEBUG
613 "hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n",
614 bch->nr, le16_to_cpu(zp->z1),
615 le16_to_cpu(zp->z2), rcnt);
616 hfcpci_empty_bfifo(bch, bz, bdata, rcnt);
617 rcnt = bz->f1 - bz->f2;
618 if (rcnt < 0)
619 rcnt += MAX_B_FRAMES + 1;
620 if (hc->hw.last_bfifo_cnt[real_fifo] > rcnt + 1) {
621 rcnt = 0;
622 hfcpci_clear_fifo_rx(hc, real_fifo);
623 }
624 hc->hw.last_bfifo_cnt[real_fifo] = rcnt;
625 if (rcnt > 1)
626 receive = 1;
627 else
628 receive = 0;
629 } else if (test_bit(FLG_TRANSPARENT, &bch->Flags))
630 receive = hfcpci_empty_fifo_trans(bch, bz, bdata);
631 else
632 receive = 0;
633 if (count && receive)
634 goto Begin;
635
636}
637
638/*
639 * D-channel send routine
640 */
641static void
642hfcpci_fill_dfifo(struct hfc_pci *hc)
643{
644 struct dchannel *dch = &hc->dch;
645 int fcnt;
646 int count, new_z1, maxlen;
647 struct dfifo *df;
648 u_char *src, *dst, new_f1;
649
650 if ((dch->debug & DEBUG_HW_DCHANNEL) && !(dch->debug & DEBUG_HW_DFIFO))
651 printk(KERN_DEBUG "%s\n", __func__);
652
653 if (!dch->tx_skb)
654 return;
655 count = dch->tx_skb->len - dch->tx_idx;
656 if (count <= 0)
657 return;
658 df = &((union fifo_area *) (hc->hw.fifos))->d_chan.d_tx;
659
660 if (dch->debug & DEBUG_HW_DFIFO)
661 printk(KERN_DEBUG "%s:f1(%d) f2(%d) z1(f1)(%x)\n", __func__,
662 df->f1, df->f2,
663 le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1));
664 fcnt = df->f1 - df->f2; /* frame count actually buffered */
665 if (fcnt < 0)
666 fcnt += (MAX_D_FRAMES + 1); /* if wrap around */
667 if (fcnt > (MAX_D_FRAMES - 1)) {
668 if (dch->debug & DEBUG_HW_DCHANNEL)
669 printk(KERN_DEBUG
670 "hfcpci_fill_Dfifo more as 14 frames\n");
671#ifdef ERROR_STATISTIC
672 cs->err_tx++;
673#endif
674 return;
675 }
676 /* now determine free bytes in FIFO buffer */
677 maxlen = le16_to_cpu(df->za[df->f2 & D_FREG_MASK].z2) -
678 le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1) - 1;
679 if (maxlen <= 0)
680 maxlen += D_FIFO_SIZE; /* count now contains available bytes */
681
682 if (dch->debug & DEBUG_HW_DCHANNEL)
683 printk(KERN_DEBUG "hfcpci_fill_Dfifo count(%d/%d)\n",
684 count, maxlen);
685 if (count > maxlen) {
686 if (dch->debug & DEBUG_HW_DCHANNEL)
687 printk(KERN_DEBUG "hfcpci_fill_Dfifo no fifo mem\n");
688 return;
689 }
690 new_z1 = (le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1) + count) &
691 (D_FIFO_SIZE - 1);
692 new_f1 = ((df->f1 + 1) & D_FREG_MASK) | (D_FREG_MASK + 1);
693 src = dch->tx_skb->data + dch->tx_idx; /* source pointer */
694 dst = df->data + le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1);
695 maxlen = D_FIFO_SIZE - le16_to_cpu(df->za[df->f1 & D_FREG_MASK].z1);
696 /* end fifo */
697 if (maxlen > count)
698 maxlen = count; /* limit size */
699 memcpy(dst, src, maxlen); /* first copy */
700
701 count -= maxlen; /* remaining bytes */
702 if (count) {
703 dst = df->data; /* start of buffer */
704 src += maxlen; /* new position */
705 memcpy(dst, src, count);
706 }
707 df->za[new_f1 & D_FREG_MASK].z1 = cpu_to_le16(new_z1);
708 /* for next buffer */
709 df->za[df->f1 & D_FREG_MASK].z1 = cpu_to_le16(new_z1);
710 /* new pos actual buffer */
711 df->f1 = new_f1; /* next frame */
712 dch->tx_idx = dch->tx_skb->len;
713}
714
715/*
716 * B-channel send routine
717 */
718static void
719hfcpci_fill_fifo(struct bchannel *bch)
720{
721 struct hfc_pci *hc = bch->hw;
722 int maxlen, fcnt;
723 int count, new_z1;
724 struct bzfifo *bz;
725 u_char *bdata;
726 u_char new_f1, *src, *dst;
727 unsigned short *z1t, *z2t;
728
729 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO))
730 printk(KERN_DEBUG "%s\n", __func__);
731 if ((!bch->tx_skb) || bch->tx_skb->len <= 0)
732 return;
733 count = bch->tx_skb->len - bch->tx_idx;
734 if ((bch->nr & 2) && (!hc->hw.bswapped)) {
735 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2;
736 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.txdat_b2;
737 } else {
738 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b1;
739 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.txdat_b1;
740 }
741
742 if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
743 z1t = &bz->za[MAX_B_FRAMES].z1;
744 z2t = z1t + 1;
745 if (bch->debug & DEBUG_HW_BCHANNEL)
746 printk(KERN_DEBUG "hfcpci_fill_fifo_trans ch(%x) "
747 "cnt(%d) z1(%x) z2(%x)\n", bch->nr, count,
748 le16_to_cpu(*z1t), le16_to_cpu(*z2t));
749 fcnt = le16_to_cpu(*z2t) - le16_to_cpu(*z1t);
750 if (fcnt <= 0)
751 fcnt += B_FIFO_SIZE;
752 /* fcnt contains available bytes in fifo */
753 fcnt = B_FIFO_SIZE - fcnt;
754 /* remaining bytes to send (bytes in fifo) */
755next_t_frame:
756 count = bch->tx_skb->len - bch->tx_idx;
757 /* maximum fill shall be HFCPCI_BTRANS_MAX */
758 if (count > HFCPCI_BTRANS_MAX - fcnt)
759 count = HFCPCI_BTRANS_MAX - fcnt;
760 if (count <= 0)
761 return;
762 /* data is suitable for fifo */
763 new_z1 = le16_to_cpu(*z1t) + count;
764 /* new buffer Position */
765 if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL))
766 new_z1 -= B_FIFO_SIZE; /* buffer wrap */
767 src = bch->tx_skb->data + bch->tx_idx;
768 /* source pointer */
769 dst = bdata + (le16_to_cpu(*z1t) - B_SUB_VAL);
770 maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(*z1t);
771 /* end of fifo */
772 if (bch->debug & DEBUG_HW_BFIFO)
773 printk(KERN_DEBUG "hfcpci_FFt fcnt(%d) "
774 "maxl(%d) nz1(%x) dst(%p)\n",
775 fcnt, maxlen, new_z1, dst);
776 fcnt += count;
777 bch->tx_idx += count;
778 if (maxlen > count)
779 maxlen = count; /* limit size */
780 memcpy(dst, src, maxlen); /* first copy */
781 count -= maxlen; /* remaining bytes */
782 if (count) {
783 dst = bdata; /* start of buffer */
784 src += maxlen; /* new position */
785 memcpy(dst, src, count);
786 }
787 *z1t = cpu_to_le16(new_z1); /* now send data */
788 if (bch->tx_idx < bch->tx_skb->len)
789 return;
790 /* send confirm, on trans, free on hdlc. */
791 if (test_bit(FLG_TRANSPARENT, &bch->Flags))
792 confirm_Bsend(bch);
793 dev_kfree_skb(bch->tx_skb);
794 if (get_next_bframe(bch))
795 goto next_t_frame;
796 return;
797 }
798 if (bch->debug & DEBUG_HW_BCHANNEL)
799 printk(KERN_DEBUG
800 "%s: ch(%x) f1(%d) f2(%d) z1(f1)(%x)\n",
801 __func__, bch->nr, bz->f1, bz->f2,
802 bz->za[bz->f1].z1);
803 fcnt = bz->f1 - bz->f2; /* frame count actually buffered */
804 if (fcnt < 0)
805 fcnt += (MAX_B_FRAMES + 1); /* if wrap around */
806 if (fcnt > (MAX_B_FRAMES - 1)) {
807 if (bch->debug & DEBUG_HW_BCHANNEL)
808 printk(KERN_DEBUG
809 "hfcpci_fill_Bfifo more as 14 frames\n");
810 return;
811 }
812 /* now determine free bytes in FIFO buffer */
813 maxlen = le16_to_cpu(bz->za[bz->f2].z2) -
814 le16_to_cpu(bz->za[bz->f1].z1) - 1;
815 if (maxlen <= 0)
816 maxlen += B_FIFO_SIZE; /* count now contains available bytes */
817
818 if (bch->debug & DEBUG_HW_BCHANNEL)
819 printk(KERN_DEBUG "hfcpci_fill_fifo ch(%x) count(%d/%d)\n",
820 bch->nr, count, maxlen);
821
822 if (maxlen < count) {
823 if (bch->debug & DEBUG_HW_BCHANNEL)
824 printk(KERN_DEBUG "hfcpci_fill_fifo no fifo mem\n");
825 return;
826 }
827 new_z1 = le16_to_cpu(bz->za[bz->f1].z1) + count;
828 /* new buffer Position */
829 if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL))
830 new_z1 -= B_FIFO_SIZE; /* buffer wrap */
831
832 new_f1 = ((bz->f1 + 1) & MAX_B_FRAMES);
833 src = bch->tx_skb->data + bch->tx_idx; /* source pointer */
834 dst = bdata + (le16_to_cpu(bz->za[bz->f1].z1) - B_SUB_VAL);
835 maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(bz->za[bz->f1].z1);
836 /* end fifo */
837 if (maxlen > count)
838 maxlen = count; /* limit size */
839 memcpy(dst, src, maxlen); /* first copy */
840
841 count -= maxlen; /* remaining bytes */
842 if (count) {
843 dst = bdata; /* start of buffer */
844 src += maxlen; /* new position */
845 memcpy(dst, src, count);
846 }
847 bz->za[new_f1].z1 = cpu_to_le16(new_z1); /* for next buffer */
848 bz->f1 = new_f1; /* next frame */
849 dev_kfree_skb(bch->tx_skb);
850 get_next_bframe(bch);
851}
852
853
854
855/*
856 * handle L1 state changes TE
857 */
858
859static void
860ph_state_te(struct dchannel *dch)
861{
862 if (dch->debug)
863 printk(KERN_DEBUG "%s: TE newstate %x\n",
864 __func__, dch->state);
865 switch (dch->state) {
866 case 0:
867 l1_event(dch->l1, HW_RESET_IND);
868 break;
869 case 3:
870 l1_event(dch->l1, HW_DEACT_IND);
871 break;
872 case 5:
873 case 8:
874 l1_event(dch->l1, ANYSIGNAL);
875 break;
876 case 6:
877 l1_event(dch->l1, INFO2);
878 break;
879 case 7:
880 l1_event(dch->l1, INFO4_P8);
881 break;
882 }
883}
884
885/*
886 * handle L1 state changes NT
887 */
888
889static void
890handle_nt_timer3(struct dchannel *dch) {
891 struct hfc_pci *hc = dch->hw;
892
893 test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags);
894 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
895 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
896 hc->hw.nt_timer = 0;
897 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
898 if (test_bit(HFC_CFG_MASTER, &hc->cfg))
899 hc->hw.mst_m |= HFCPCI_MASTER;
900 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
901 _queue_data(&dch->dev.D, PH_ACTIVATE_IND,
902 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
903}
904
905static void
906ph_state_nt(struct dchannel *dch)
907{
908 struct hfc_pci *hc = dch->hw;
909
910 if (dch->debug)
911 printk(KERN_DEBUG "%s: NT newstate %x\n",
912 __func__, dch->state);
913 switch (dch->state) {
914 case 2:
915 if (hc->hw.nt_timer < 0) {
916 hc->hw.nt_timer = 0;
917 test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags);
918 test_and_clear_bit(FLG_HFC_TIMER_T1, &dch->Flags);
919 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
920 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
921 /* Clear already pending ints */
922 if (Read_hfc(hc, HFCPCI_INT_S1));
923 Write_hfc(hc, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE);
924 udelay(10);
925 Write_hfc(hc, HFCPCI_STATES, 4);
926 dch->state = 4;
927 } else if (hc->hw.nt_timer == 0) {
928 hc->hw.int_m1 |= HFCPCI_INTS_TIMER;
929 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
930 hc->hw.nt_timer = NT_T1_COUNT;
931 hc->hw.ctmt &= ~HFCPCI_AUTO_TIMER;
932 hc->hw.ctmt |= HFCPCI_TIM3_125;
933 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt |
934 HFCPCI_CLTIMER);
935 test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags);
936 test_and_set_bit(FLG_HFC_TIMER_T1, &dch->Flags);
937 /* allow G2 -> G3 transition */
938 Write_hfc(hc, HFCPCI_STATES, 2 | HFCPCI_NT_G2_G3);
939 } else {
940 Write_hfc(hc, HFCPCI_STATES, 2 | HFCPCI_NT_G2_G3);
941 }
942 break;
943 case 1:
944 hc->hw.nt_timer = 0;
945 test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags);
946 test_and_clear_bit(FLG_HFC_TIMER_T1, &dch->Flags);
947 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
948 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
949 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
950 hc->hw.mst_m &= ~HFCPCI_MASTER;
951 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
952 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
953 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND,
954 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
955 break;
956 case 4:
957 hc->hw.nt_timer = 0;
958 test_and_clear_bit(FLG_HFC_TIMER_T3, &dch->Flags);
959 test_and_clear_bit(FLG_HFC_TIMER_T1, &dch->Flags);
960 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
961 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
962 break;
963 case 3:
964 if (!test_and_set_bit(FLG_HFC_TIMER_T3, &dch->Flags)) {
965 if (!test_and_clear_bit(FLG_L2_ACTIVATED,
966 &dch->Flags)) {
967 handle_nt_timer3(dch);
968 break;
969 }
970 test_and_clear_bit(FLG_HFC_TIMER_T1, &dch->Flags);
971 hc->hw.int_m1 |= HFCPCI_INTS_TIMER;
972 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
973 hc->hw.nt_timer = NT_T3_COUNT;
974 hc->hw.ctmt &= ~HFCPCI_AUTO_TIMER;
975 hc->hw.ctmt |= HFCPCI_TIM3_125;
976 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt |
977 HFCPCI_CLTIMER);
978 }
979 break;
980 }
981}
982
983static void
984ph_state(struct dchannel *dch)
985{
986 struct hfc_pci *hc = dch->hw;
987
988 if (hc->hw.protocol == ISDN_P_NT_S0) {
989 if (test_bit(FLG_HFC_TIMER_T3, &dch->Flags) &&
990 hc->hw.nt_timer < 0)
991 handle_nt_timer3(dch);
992 else
993 ph_state_nt(dch);
994 } else
995 ph_state_te(dch);
996}
997
998/*
999 * Layer 1 callback function
1000 */
1001static int
1002hfc_l1callback(struct dchannel *dch, u_int cmd)
1003{
1004 struct hfc_pci *hc = dch->hw;
1005
1006 switch (cmd) {
1007 case INFO3_P8:
1008 case INFO3_P10:
1009 if (test_bit(HFC_CFG_MASTER, &hc->cfg))
1010 hc->hw.mst_m |= HFCPCI_MASTER;
1011 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1012 break;
1013 case HW_RESET_REQ:
1014 Write_hfc(hc, HFCPCI_STATES, HFCPCI_LOAD_STATE | 3);
1015 /* HFC ST 3 */
1016 udelay(6);
1017 Write_hfc(hc, HFCPCI_STATES, 3); /* HFC ST 2 */
1018 if (test_bit(HFC_CFG_MASTER, &hc->cfg))
1019 hc->hw.mst_m |= HFCPCI_MASTER;
1020 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1021 Write_hfc(hc, HFCPCI_STATES, HFCPCI_ACTIVATE |
1022 HFCPCI_DO_ACTION);
1023 l1_event(dch->l1, HW_POWERUP_IND);
1024 break;
1025 case HW_DEACT_REQ:
1026 hc->hw.mst_m &= ~HFCPCI_MASTER;
1027 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1028 skb_queue_purge(&dch->squeue);
1029 if (dch->tx_skb) {
1030 dev_kfree_skb(dch->tx_skb);
1031 dch->tx_skb = NULL;
1032 }
1033 dch->tx_idx = 0;
1034 if (dch->rx_skb) {
1035 dev_kfree_skb(dch->rx_skb);
1036 dch->rx_skb = NULL;
1037 }
1038 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
1039 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags))
1040 del_timer(&dch->timer);
1041 break;
1042 case HW_POWERUP_REQ:
1043 Write_hfc(hc, HFCPCI_STATES, HFCPCI_DO_ACTION);
1044 break;
1045 case PH_ACTIVATE_IND:
1046 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
1047 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
1048 GFP_ATOMIC);
1049 break;
1050 case PH_DEACTIVATE_IND:
1051 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
1052 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
1053 GFP_ATOMIC);
1054 break;
1055 default:
1056 if (dch->debug & DEBUG_HW)
1057 printk(KERN_DEBUG "%s: unknown command %x\n",
1058 __func__, cmd);
1059 return -1;
1060 }
1061 return 0;
1062}
1063
1064/*
1065 * Interrupt handler
1066 */
1067static inline void
1068tx_birq(struct bchannel *bch)
1069{
1070 if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len)
1071 hfcpci_fill_fifo(bch);
1072 else {
1073 if (bch->tx_skb)
1074 dev_kfree_skb(bch->tx_skb);
1075 if (get_next_bframe(bch))
1076 hfcpci_fill_fifo(bch);
1077 }
1078}
1079
1080static inline void
1081tx_dirq(struct dchannel *dch)
1082{
1083 if (dch->tx_skb && dch->tx_idx < dch->tx_skb->len)
1084 hfcpci_fill_dfifo(dch->hw);
1085 else {
1086 if (dch->tx_skb)
1087 dev_kfree_skb(dch->tx_skb);
1088 if (get_next_dframe(dch))
1089 hfcpci_fill_dfifo(dch->hw);
1090 }
1091}
1092
1093static irqreturn_t
1094hfcpci_int(int intno, void *dev_id)
1095{
1096 struct hfc_pci *hc = dev_id;
1097 u_char exval;
1098 struct bchannel *bch;
1099 u_char val, stat;
1100
1101 spin_lock(&hc->lock);
1102 if (!(hc->hw.int_m2 & 0x08)) {
1103 spin_unlock(&hc->lock);
1104 return IRQ_NONE; /* not initialised */
1105 }
1106 stat = Read_hfc(hc, HFCPCI_STATUS);
1107 if (HFCPCI_ANYINT & stat) {
1108 val = Read_hfc(hc, HFCPCI_INT_S1);
1109 if (hc->dch.debug & DEBUG_HW_DCHANNEL)
1110 printk(KERN_DEBUG
1111 "HFC-PCI: stat(%02x) s1(%02x)\n", stat, val);
1112 } else {
1113 /* shared */
1114 spin_unlock(&hc->lock);
1115 return IRQ_NONE;
1116 }
1117 hc->irqcnt++;
1118
1119 if (hc->dch.debug & DEBUG_HW_DCHANNEL)
1120 printk(KERN_DEBUG "HFC-PCI irq %x\n", val);
1121 val &= hc->hw.int_m1;
1122 if (val & 0x40) { /* state machine irq */
1123 exval = Read_hfc(hc, HFCPCI_STATES) & 0xf;
1124 if (hc->dch.debug & DEBUG_HW_DCHANNEL)
1125 printk(KERN_DEBUG "ph_state chg %d->%d\n",
1126 hc->dch.state, exval);
1127 hc->dch.state = exval;
1128 schedule_event(&hc->dch, FLG_PHCHANGE);
1129 val &= ~0x40;
1130 }
1131 if (val & 0x80) { /* timer irq */
1132 if (hc->hw.protocol == ISDN_P_NT_S0) {
1133 if ((--hc->hw.nt_timer) < 0)
1134 schedule_event(&hc->dch, FLG_PHCHANGE);
1135 }
1136 val &= ~0x80;
1137 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | HFCPCI_CLTIMER);
1138 }
1139 if (val & 0x08) {
1140 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
1141 if (bch)
1142 main_rec_hfcpci(bch);
1143 else if (hc->dch.debug)
1144 printk(KERN_DEBUG "hfcpci spurious 0x08 IRQ\n");
1145 }
1146 if (val & 0x10) {
1147 bch = Sel_BCS(hc, 2);
1148 if (bch)
1149 main_rec_hfcpci(bch);
1150 else if (hc->dch.debug)
1151 printk(KERN_DEBUG "hfcpci spurious 0x10 IRQ\n");
1152 }
1153 if (val & 0x01) {
1154 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
1155 if (bch)
1156 tx_birq(bch);
1157 else if (hc->dch.debug)
1158 printk(KERN_DEBUG "hfcpci spurious 0x01 IRQ\n");
1159 }
1160 if (val & 0x02) {
1161 bch = Sel_BCS(hc, 2);
1162 if (bch)
1163 tx_birq(bch);
1164 else if (hc->dch.debug)
1165 printk(KERN_DEBUG "hfcpci spurious 0x02 IRQ\n");
1166 }
1167 if (val & 0x20)
1168 receive_dmsg(hc);
1169 if (val & 0x04) { /* dframe transmitted */
1170 if (test_and_clear_bit(FLG_BUSY_TIMER, &hc->dch.Flags))
1171 del_timer(&hc->dch.timer);
1172 tx_dirq(&hc->dch);
1173 }
1174 spin_unlock(&hc->lock);
1175 return IRQ_HANDLED;
1176}
1177
1178/*
1179 * timer callback for D-chan busy resolution. Currently no function
1180 */
1181static void
1182hfcpci_dbusy_timer(struct hfc_pci *hc)
1183{
1184}
1185
1186/*
1187 * activate/deactivate hardware for selected channels and mode
1188 */
1189static int
1190mode_hfcpci(struct bchannel *bch, int bc, int protocol)
1191{
1192 struct hfc_pci *hc = bch->hw;
1193 int fifo2;
1194 u_char rx_slot = 0, tx_slot = 0, pcm_mode;
1195
1196 if (bch->debug & DEBUG_HW_BCHANNEL)
1197 printk(KERN_DEBUG
1198 "HFCPCI bchannel protocol %x-->%x ch %x-->%x\n",
1199 bch->state, protocol, bch->nr, bc);
1200
1201 fifo2 = bc;
1202 pcm_mode = (bc>>24) & 0xff;
1203 if (pcm_mode) { /* PCM SLOT USE */
1204 if (!test_bit(HFC_CFG_PCM, &hc->cfg))
1205 printk(KERN_WARNING
1206 "%s: pcm channel id without HFC_CFG_PCM\n",
1207 __func__);
1208 rx_slot = (bc>>8) & 0xff;
1209 tx_slot = (bc>>16) & 0xff;
1210 bc = bc & 0xff;
1211 } else if (test_bit(HFC_CFG_PCM, &hc->cfg) &&
1212 (protocol > ISDN_P_NONE))
1213 printk(KERN_WARNING "%s: no pcm channel id but HFC_CFG_PCM\n",
1214 __func__);
1215 if (hc->chanlimit > 1) {
1216 hc->hw.bswapped = 0; /* B1 and B2 normal mode */
1217 hc->hw.sctrl_e &= ~0x80;
1218 } else {
1219 if (bc & 2) {
1220 if (protocol != ISDN_P_NONE) {
1221 hc->hw.bswapped = 1; /* B1 and B2 exchanged */
1222 hc->hw.sctrl_e |= 0x80;
1223 } else {
1224 hc->hw.bswapped = 0; /* B1 and B2 normal mode */
1225 hc->hw.sctrl_e &= ~0x80;
1226 }
1227 fifo2 = 1;
1228 } else {
1229 hc->hw.bswapped = 0; /* B1 and B2 normal mode */
1230 hc->hw.sctrl_e &= ~0x80;
1231 }
1232 }
1233 switch (protocol) {
1234 case (-1): /* used for init */
1235 bch->state = -1;
1236 bch->nr = bc;
1237 case (ISDN_P_NONE):
1238 if (bch->state == ISDN_P_NONE)
1239 return 0;
1240 if (bc & 2) {
1241 hc->hw.sctrl &= ~SCTRL_B2_ENA;
1242 hc->hw.sctrl_r &= ~SCTRL_B2_ENA;
1243 } else {
1244 hc->hw.sctrl &= ~SCTRL_B1_ENA;
1245 hc->hw.sctrl_r &= ~SCTRL_B1_ENA;
1246 }
1247 if (fifo2 & 2) {
1248 hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B2;
1249 hc->hw.int_m1 &= ~(HFCPCI_INTS_B2TRANS +
1250 HFCPCI_INTS_B2REC);
1251 } else {
1252 hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B1;
1253 hc->hw.int_m1 &= ~(HFCPCI_INTS_B1TRANS +
1254 HFCPCI_INTS_B1REC);
1255 }
1256#ifdef REVERSE_BITORDER
1257 if (bch->nr & 2)
1258 hc->hw.cirm &= 0x7f;
1259 else
1260 hc->hw.cirm &= 0xbf;
1261#endif
1262 bch->state = ISDN_P_NONE;
1263 bch->nr = bc;
1264 test_and_clear_bit(FLG_HDLC, &bch->Flags);
1265 test_and_clear_bit(FLG_TRANSPARENT, &bch->Flags);
1266 break;
1267 case (ISDN_P_B_RAW):
1268 bch->state = protocol;
1269 bch->nr = bc;
1270 hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0);
1271 hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0);
1272 if (bc & 2) {
1273 hc->hw.sctrl |= SCTRL_B2_ENA;
1274 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1275#ifdef REVERSE_BITORDER
1276 hc->hw.cirm |= 0x80;
1277#endif
1278 } else {
1279 hc->hw.sctrl |= SCTRL_B1_ENA;
1280 hc->hw.sctrl_r |= SCTRL_B1_ENA;
1281#ifdef REVERSE_BITORDER
1282 hc->hw.cirm |= 0x40;
1283#endif
1284 }
1285 if (fifo2 & 2) {
1286 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2;
1287 hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS +
1288 HFCPCI_INTS_B2REC);
1289 hc->hw.ctmt |= 2;
1290 hc->hw.conn &= ~0x18;
1291 } else {
1292 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1;
1293 hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS +
1294 HFCPCI_INTS_B1REC);
1295 hc->hw.ctmt |= 1;
1296 hc->hw.conn &= ~0x03;
1297 }
1298 test_and_set_bit(FLG_TRANSPARENT, &bch->Flags);
1299 break;
1300 case (ISDN_P_B_HDLC):
1301 bch->state = protocol;
1302 bch->nr = bc;
1303 hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0);
1304 hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0);
1305 if (bc & 2) {
1306 hc->hw.sctrl |= SCTRL_B2_ENA;
1307 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1308 } else {
1309 hc->hw.sctrl |= SCTRL_B1_ENA;
1310 hc->hw.sctrl_r |= SCTRL_B1_ENA;
1311 }
1312 if (fifo2 & 2) {
1313 hc->hw.last_bfifo_cnt[1] = 0;
1314 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2;
1315 hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS +
1316 HFCPCI_INTS_B2REC);
1317 hc->hw.ctmt &= ~2;
1318 hc->hw.conn &= ~0x18;
1319 } else {
1320 hc->hw.last_bfifo_cnt[0] = 0;
1321 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1;
1322 hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS +
1323 HFCPCI_INTS_B1REC);
1324 hc->hw.ctmt &= ~1;
1325 hc->hw.conn &= ~0x03;
1326 }
1327 test_and_set_bit(FLG_HDLC, &bch->Flags);
1328 break;
1329 default:
1330 printk(KERN_DEBUG "prot not known %x\n", protocol);
1331 return -ENOPROTOOPT;
1332 }
1333 if (test_bit(HFC_CFG_PCM, &hc->cfg)) {
1334 if ((protocol == ISDN_P_NONE) ||
1335 (protocol == -1)) { /* init case */
1336 rx_slot = 0;
1337 tx_slot = 0;
1338 } else {
1339 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg)) {
1340 rx_slot |= 0xC0;
1341 tx_slot |= 0xC0;
1342 } else {
1343 rx_slot |= 0x80;
1344 tx_slot |= 0x80;
1345 }
1346 }
1347 if (bc & 2) {
1348 hc->hw.conn &= 0xc7;
1349 hc->hw.conn |= 0x08;
1350 printk(KERN_DEBUG "%s: Write_hfc: B2_SSL 0x%x\n",
1351 __func__, tx_slot);
1352 printk(KERN_DEBUG "%s: Write_hfc: B2_RSL 0x%x\n",
1353 __func__, rx_slot);
1354 Write_hfc(hc, HFCPCI_B2_SSL, tx_slot);
1355 Write_hfc(hc, HFCPCI_B2_RSL, rx_slot);
1356 } else {
1357 hc->hw.conn &= 0xf8;
1358 hc->hw.conn |= 0x01;
1359 printk(KERN_DEBUG "%s: Write_hfc: B1_SSL 0x%x\n",
1360 __func__, tx_slot);
1361 printk(KERN_DEBUG "%s: Write_hfc: B1_RSL 0x%x\n",
1362 __func__, rx_slot);
1363 Write_hfc(hc, HFCPCI_B1_SSL, tx_slot);
1364 Write_hfc(hc, HFCPCI_B1_RSL, rx_slot);
1365 }
1366 }
1367 Write_hfc(hc, HFCPCI_SCTRL_E, hc->hw.sctrl_e);
1368 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
1369 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
1370 Write_hfc(hc, HFCPCI_SCTRL, hc->hw.sctrl);
1371 Write_hfc(hc, HFCPCI_SCTRL_R, hc->hw.sctrl_r);
1372 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt);
1373 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1374#ifdef REVERSE_BITORDER
1375 Write_hfc(hc, HFCPCI_CIRM, hc->hw.cirm);
1376#endif
1377 return 0;
1378}
1379
1380static int
1381set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
1382{
1383 struct hfc_pci *hc = bch->hw;
1384
1385 if (bch->debug & DEBUG_HW_BCHANNEL)
1386 printk(KERN_DEBUG
1387 "HFCPCI bchannel test rx protocol %x-->%x ch %x-->%x\n",
1388 bch->state, protocol, bch->nr, chan);
1389 if (bch->nr != chan) {
1390 printk(KERN_DEBUG
1391 "HFCPCI rxtest wrong channel parameter %x/%x\n",
1392 bch->nr, chan);
1393 return -EINVAL;
1394 }
1395 switch (protocol) {
1396 case (ISDN_P_B_RAW):
1397 bch->state = protocol;
1398 hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0);
1399 if (chan & 2) {
1400 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1401 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX;
1402 hc->hw.int_m1 |= HFCPCI_INTS_B2REC;
1403 hc->hw.ctmt |= 2;
1404 hc->hw.conn &= ~0x18;
1405#ifdef REVERSE_BITORDER
1406 hc->hw.cirm |= 0x80;
1407#endif
1408 } else {
1409 hc->hw.sctrl_r |= SCTRL_B1_ENA;
1410 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1RX;
1411 hc->hw.int_m1 |= HFCPCI_INTS_B1REC;
1412 hc->hw.ctmt |= 1;
1413 hc->hw.conn &= ~0x03;
1414#ifdef REVERSE_BITORDER
1415 hc->hw.cirm |= 0x40;
1416#endif
1417 }
1418 break;
1419 case (ISDN_P_B_HDLC):
1420 bch->state = protocol;
1421 hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0);
1422 if (chan & 2) {
1423 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1424 hc->hw.last_bfifo_cnt[1] = 0;
1425 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX;
1426 hc->hw.int_m1 |= HFCPCI_INTS_B2REC;
1427 hc->hw.ctmt &= ~2;
1428 hc->hw.conn &= ~0x18;
1429 } else {
1430 hc->hw.sctrl_r |= SCTRL_B1_ENA;
1431 hc->hw.last_bfifo_cnt[0] = 0;
1432 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1RX;
1433 hc->hw.int_m1 |= HFCPCI_INTS_B1REC;
1434 hc->hw.ctmt &= ~1;
1435 hc->hw.conn &= ~0x03;
1436 }
1437 break;
1438 default:
1439 printk(KERN_DEBUG "prot not known %x\n", protocol);
1440 return -ENOPROTOOPT;
1441 }
1442 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
1443 Write_hfc(hc, HFCPCI_FIFO_EN, hc->hw.fifo_en);
1444 Write_hfc(hc, HFCPCI_SCTRL_R, hc->hw.sctrl_r);
1445 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt);
1446 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1447#ifdef REVERSE_BITORDER
1448 Write_hfc(hc, HFCPCI_CIRM, hc->hw.cirm);
1449#endif
1450 return 0;
1451}
1452
1453static void
1454deactivate_bchannel(struct bchannel *bch)
1455{
1456 struct hfc_pci *hc = bch->hw;
1457 u_long flags;
1458
1459 spin_lock_irqsave(&hc->lock, flags);
1460 if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
1461 dev_kfree_skb(bch->next_skb);
1462 bch->next_skb = NULL;
1463 }
1464 if (bch->tx_skb) {
1465 dev_kfree_skb(bch->tx_skb);
1466 bch->tx_skb = NULL;
1467 }
1468 bch->tx_idx = 0;
1469 if (bch->rx_skb) {
1470 dev_kfree_skb(bch->rx_skb);
1471 bch->rx_skb = NULL;
1472 }
1473 mode_hfcpci(bch, bch->nr, ISDN_P_NONE);
1474 test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
1475 test_and_clear_bit(FLG_TX_BUSY, &bch->Flags);
1476 spin_unlock_irqrestore(&hc->lock, flags);
1477}
1478
1479/*
1480 * Layer 1 B-channel hardware access
1481 */
1482static int
1483channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
1484{
1485 int ret = 0;
1486
1487 switch (cq->op) {
1488 case MISDN_CTRL_GETOP:
1489 cq->op = 0;
1490 break;
1491 default:
1492 printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op);
1493 ret = -EINVAL;
1494 break;
1495 }
1496 return ret;
1497}
1498static int
1499hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1500{
1501 struct bchannel *bch = container_of(ch, struct bchannel, ch);
1502 struct hfc_pci *hc = bch->hw;
1503 int ret = -EINVAL;
1504 u_long flags;
1505
1506 if (bch->debug & DEBUG_HW)
1507 printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
1508 switch (cmd) {
1509 case HW_TESTRX_RAW:
1510 spin_lock_irqsave(&hc->lock, flags);
1511 ret = set_hfcpci_rxtest(bch, ISDN_P_B_RAW, (int)(long)arg);
1512 spin_unlock_irqrestore(&hc->lock, flags);
1513 break;
1514 case HW_TESTRX_HDLC:
1515 spin_lock_irqsave(&hc->lock, flags);
1516 ret = set_hfcpci_rxtest(bch, ISDN_P_B_HDLC, (int)(long)arg);
1517 spin_unlock_irqrestore(&hc->lock, flags);
1518 break;
1519 case HW_TESTRX_OFF:
1520 spin_lock_irqsave(&hc->lock, flags);
1521 mode_hfcpci(bch, bch->nr, ISDN_P_NONE);
1522 spin_unlock_irqrestore(&hc->lock, flags);
1523 ret = 0;
1524 break;
1525 case CLOSE_CHANNEL:
1526 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1527 if (test_bit(FLG_ACTIVE, &bch->Flags))
1528 deactivate_bchannel(bch);
1529 ch->protocol = ISDN_P_NONE;
1530 ch->peer = NULL;
1531 module_put(THIS_MODULE);
1532 ret = 0;
1533 break;
1534 case CONTROL_CHANNEL:
1535 ret = channel_bctrl(bch, arg);
1536 break;
1537 default:
1538 printk(KERN_WARNING "%s: unknown prim(%x)\n",
1539 __func__, cmd);
1540 }
1541 return ret;
1542}
1543
1544/*
1545 * Layer2 -> Layer 1 Dchannel data
1546 */
1547static int
1548hfcpci_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
1549{
1550 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
1551 struct dchannel *dch = container_of(dev, struct dchannel, dev);
1552 struct hfc_pci *hc = dch->hw;
1553 int ret = -EINVAL;
1554 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1555 unsigned int id;
1556 u_long flags;
1557
1558 switch (hh->prim) {
1559 case PH_DATA_REQ:
1560 spin_lock_irqsave(&hc->lock, flags);
1561 ret = dchannel_senddata(dch, skb);
1562 if (ret > 0) { /* direct TX */
1563 id = hh->id; /* skb can be freed */
1564 hfcpci_fill_dfifo(dch->hw);
1565 ret = 0;
1566 spin_unlock_irqrestore(&hc->lock, flags);
1567 queue_ch_frame(ch, PH_DATA_CNF, id, NULL);
1568 } else
1569 spin_unlock_irqrestore(&hc->lock, flags);
1570 return ret;
1571 case PH_ACTIVATE_REQ:
1572 spin_lock_irqsave(&hc->lock, flags);
1573 if (hc->hw.protocol == ISDN_P_NT_S0) {
1574 ret = 0;
1575 if (test_bit(HFC_CFG_MASTER, &hc->cfg))
1576 hc->hw.mst_m |= HFCPCI_MASTER;
1577 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1578 if (test_bit(FLG_ACTIVE, &dch->Flags)) {
1579 spin_unlock_irqrestore(&hc->lock, flags);
1580 _queue_data(&dch->dev.D, PH_ACTIVATE_IND,
1581 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
1582 break;
1583 }
1584 test_and_set_bit(FLG_L2_ACTIVATED, &dch->Flags);
1585 Write_hfc(hc, HFCPCI_STATES, HFCPCI_ACTIVATE |
1586 HFCPCI_DO_ACTION | 1);
1587 } else
1588 ret = l1_event(dch->l1, hh->prim);
1589 spin_unlock_irqrestore(&hc->lock, flags);
1590 break;
1591 case PH_DEACTIVATE_REQ:
1592 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
1593 spin_lock_irqsave(&hc->lock, flags);
1594 if (hc->hw.protocol == ISDN_P_NT_S0) {
1595 /* prepare deactivation */
1596 Write_hfc(hc, HFCPCI_STATES, 0x40);
1597 skb_queue_purge(&dch->squeue);
1598 if (dch->tx_skb) {
1599 dev_kfree_skb(dch->tx_skb);
1600 dch->tx_skb = NULL;
1601 }
1602 dch->tx_idx = 0;
1603 if (dch->rx_skb) {
1604 dev_kfree_skb(dch->rx_skb);
1605 dch->rx_skb = NULL;
1606 }
1607 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
1608 if (test_and_clear_bit(FLG_BUSY_TIMER, &dch->Flags))
1609 del_timer(&dch->timer);
1610#ifdef FIXME
1611 if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags))
1612 dchannel_sched_event(&hc->dch, D_CLEARBUSY);
1613#endif
1614 hc->hw.mst_m &= ~HFCPCI_MASTER;
1615 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1616 ret = 0;
1617 } else {
1618 ret = l1_event(dch->l1, hh->prim);
1619 }
1620 spin_unlock_irqrestore(&hc->lock, flags);
1621 break;
1622 }
1623 if (!ret)
1624 dev_kfree_skb(skb);
1625 return ret;
1626}
1627
1628/*
1629 * Layer2 -> Layer 1 Bchannel data
1630 */
1631static int
1632hfcpci_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
1633{
1634 struct bchannel *bch = container_of(ch, struct bchannel, ch);
1635 struct hfc_pci *hc = bch->hw;
1636 int ret = -EINVAL;
1637 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1638 unsigned int id;
1639 u_long flags;
1640
1641 switch (hh->prim) {
1642 case PH_DATA_REQ:
1643 spin_lock_irqsave(&hc->lock, flags);
1644 ret = bchannel_senddata(bch, skb);
1645 if (ret > 0) { /* direct TX */
1646 id = hh->id; /* skb can be freed */
1647 hfcpci_fill_fifo(bch);
1648 ret = 0;
1649 spin_unlock_irqrestore(&hc->lock, flags);
1650 if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
1651 queue_ch_frame(ch, PH_DATA_CNF, id, NULL);
1652 } else
1653 spin_unlock_irqrestore(&hc->lock, flags);
1654 return ret;
1655 case PH_ACTIVATE_REQ:
1656 spin_lock_irqsave(&hc->lock, flags);
1657 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
1658 ret = mode_hfcpci(bch, bch->nr, ch->protocol);
1659 else
1660 ret = 0;
1661 spin_unlock_irqrestore(&hc->lock, flags);
1662 if (!ret)
1663 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
1664 NULL, GFP_KERNEL);
1665 break;
1666 case PH_DEACTIVATE_REQ:
1667 deactivate_bchannel(bch);
1668 _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
1669 NULL, GFP_KERNEL);
1670 ret = 0;
1671 break;
1672 }
1673 if (!ret)
1674 dev_kfree_skb(skb);
1675 return ret;
1676}
1677
1678/*
1679 * called for card init message
1680 */
1681
1682void
1683inithfcpci(struct hfc_pci *hc)
1684{
1685 printk(KERN_DEBUG "inithfcpci: entered\n");
1686 hc->dch.timer.function = (void *) hfcpci_dbusy_timer;
1687 hc->dch.timer.data = (long) &hc->dch;
1688 init_timer(&hc->dch.timer);
1689 hc->chanlimit = 2;
1690 mode_hfcpci(&hc->bch[0], 1, -1);
1691 mode_hfcpci(&hc->bch[1], 2, -1);
1692}
1693
1694
1695static int
1696init_card(struct hfc_pci *hc)
1697{
1698 int cnt = 3;
1699 u_long flags;
1700
1701 printk(KERN_DEBUG "init_card: entered\n");
1702
1703
1704 spin_lock_irqsave(&hc->lock, flags);
1705 disable_hwirq(hc);
1706 spin_unlock_irqrestore(&hc->lock, flags);
1707 if (request_irq(hc->irq, hfcpci_int, IRQF_SHARED, "HFC PCI", hc)) {
1708 printk(KERN_WARNING
1709 "mISDN: couldn't get interrupt %d\n", hc->irq);
1710 return -EIO;
1711 }
1712 spin_lock_irqsave(&hc->lock, flags);
1713 reset_hfcpci(hc);
1714 while (cnt) {
1715 inithfcpci(hc);
1716 /*
1717 * Finally enable IRQ output
1718 * this is only allowed, if an IRQ routine is allready
1719 * established for this HFC, so don't do that earlier
1720 */
1721 enable_hwirq(hc);
1722 spin_unlock_irqrestore(&hc->lock, flags);
1723 /* Timeout 80ms */
1724 current->state = TASK_UNINTERRUPTIBLE;
1725 schedule_timeout((80*HZ)/1000);
1726 printk(KERN_INFO "HFC PCI: IRQ %d count %d\n",
1727 hc->irq, hc->irqcnt);
1728 /* now switch timer interrupt off */
1729 spin_lock_irqsave(&hc->lock, flags);
1730 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
1731 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
1732 /* reinit mode reg */
1733 Write_hfc(hc, HFCPCI_MST_MODE, hc->hw.mst_m);
1734 if (!hc->irqcnt) {
1735 printk(KERN_WARNING
1736 "HFC PCI: IRQ(%d) getting no interrupts "
1737 "during init %d\n", hc->irq, 4 - cnt);
1738 if (cnt == 1) {
1739 spin_unlock_irqrestore(&hc->lock, flags);
1740 return -EIO;
1741 } else {
1742 reset_hfcpci(hc);
1743 cnt--;
1744 }
1745 } else {
1746 spin_unlock_irqrestore(&hc->lock, flags);
1747 hc->initdone = 1;
1748 return 0;
1749 }
1750 }
1751 disable_hwirq(hc);
1752 spin_unlock_irqrestore(&hc->lock, flags);
1753 free_irq(hc->irq, hc);
1754 return -EIO;
1755}
1756
1757static int
1758channel_ctrl(struct hfc_pci *hc, struct mISDN_ctrl_req *cq)
1759{
1760 int ret = 0;
1761 u_char slot;
1762
1763 switch (cq->op) {
1764 case MISDN_CTRL_GETOP:
1765 cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_CONNECT |
1766 MISDN_CTRL_DISCONNECT;
1767 break;
1768 case MISDN_CTRL_LOOP:
1769 /* channel 0 disabled loop */
1770 if (cq->channel < 0 || cq->channel > 2) {
1771 ret = -EINVAL;
1772 break;
1773 }
1774 if (cq->channel & 1) {
1775 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg))
1776 slot = 0xC0;
1777 else
1778 slot = 0x80;
1779 printk(KERN_DEBUG "%s: Write_hfc: B1_SSL/RSL 0x%x\n",
1780 __func__, slot);
1781 Write_hfc(hc, HFCPCI_B1_SSL, slot);
1782 Write_hfc(hc, HFCPCI_B1_RSL, slot);
1783 hc->hw.conn = (hc->hw.conn & ~7) | 6;
1784 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1785 }
1786 if (cq->channel & 2) {
1787 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg))
1788 slot = 0xC1;
1789 else
1790 slot = 0x81;
1791 printk(KERN_DEBUG "%s: Write_hfc: B2_SSL/RSL 0x%x\n",
1792 __func__, slot);
1793 Write_hfc(hc, HFCPCI_B2_SSL, slot);
1794 Write_hfc(hc, HFCPCI_B2_RSL, slot);
1795 hc->hw.conn = (hc->hw.conn & ~0x38) | 0x30;
1796 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1797 }
1798 if (cq->channel & 3)
1799 hc->hw.trm |= 0x80; /* enable IOM-loop */
1800 else {
1801 hc->hw.conn = (hc->hw.conn & ~0x3f) | 0x09;
1802 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1803 hc->hw.trm &= 0x7f; /* disable IOM-loop */
1804 }
1805 Write_hfc(hc, HFCPCI_TRM, hc->hw.trm);
1806 break;
1807 case MISDN_CTRL_CONNECT:
1808 if (cq->channel == cq->p1) {
1809 ret = -EINVAL;
1810 break;
1811 }
1812 if (cq->channel < 1 || cq->channel > 2 ||
1813 cq->p1 < 1 || cq->p1 > 2) {
1814 ret = -EINVAL;
1815 break;
1816 }
1817 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg))
1818 slot = 0xC0;
1819 else
1820 slot = 0x80;
1821 printk(KERN_DEBUG "%s: Write_hfc: B1_SSL/RSL 0x%x\n",
1822 __func__, slot);
1823 Write_hfc(hc, HFCPCI_B1_SSL, slot);
1824 Write_hfc(hc, HFCPCI_B2_RSL, slot);
1825 if (test_bit(HFC_CFG_SW_DD_DU, &hc->cfg))
1826 slot = 0xC1;
1827 else
1828 slot = 0x81;
1829 printk(KERN_DEBUG "%s: Write_hfc: B2_SSL/RSL 0x%x\n",
1830 __func__, slot);
1831 Write_hfc(hc, HFCPCI_B2_SSL, slot);
1832 Write_hfc(hc, HFCPCI_B1_RSL, slot);
1833 hc->hw.conn = (hc->hw.conn & ~0x3f) | 0x36;
1834 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1835 hc->hw.trm |= 0x80;
1836 Write_hfc(hc, HFCPCI_TRM, hc->hw.trm);
1837 break;
1838 case MISDN_CTRL_DISCONNECT:
1839 hc->hw.conn = (hc->hw.conn & ~0x3f) | 0x09;
1840 Write_hfc(hc, HFCPCI_CONNECT, hc->hw.conn);
1841 hc->hw.trm &= 0x7f; /* disable IOM-loop */
1842 break;
1843 default:
1844 printk(KERN_WARNING "%s: unknown Op %x\n",
1845 __func__, cq->op);
1846 ret = -EINVAL;
1847 break;
1848 }
1849 return ret;
1850}
1851
1852static int
1853open_dchannel(struct hfc_pci *hc, struct mISDNchannel *ch,
1854 struct channel_req *rq)
1855{
1856 int err = 0;
1857
1858 if (debug & DEBUG_HW_OPEN)
1859 printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__,
1860 hc->dch.dev.id, __builtin_return_address(0));
1861 if (rq->protocol == ISDN_P_NONE)
1862 return -EINVAL;
1863 if (!hc->initdone) {
1864 if (rq->protocol == ISDN_P_TE_S0) {
1865 err = create_l1(&hc->dch, hfc_l1callback);
1866 if (err)
1867 return err;
1868 }
1869 hc->hw.protocol = rq->protocol;
1870 ch->protocol = rq->protocol;
1871 err = init_card(hc);
1872 if (err)
1873 return err;
1874 } else {
1875 if (rq->protocol != ch->protocol) {
1876 if (hc->hw.protocol == ISDN_P_TE_S0)
1877 l1_event(hc->dch.l1, CLOSE_CHANNEL);
1878 hc->hw.protocol = rq->protocol;
1879 ch->protocol = rq->protocol;
1880 hfcpci_setmode(hc);
1881 }
1882 }
1883
1884 if (((ch->protocol == ISDN_P_NT_S0) && (hc->dch.state == 3)) ||
1885 ((ch->protocol == ISDN_P_TE_S0) && (hc->dch.state == 7))) {
1886 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY,
1887 0, NULL, GFP_KERNEL);
1888 }
1889 rq->ch = ch;
1890 if (!try_module_get(THIS_MODULE))
1891 printk(KERN_WARNING "%s:cannot get module\n", __func__);
1892 return 0;
1893}
1894
1895static int
1896open_bchannel(struct hfc_pci *hc, struct channel_req *rq)
1897{
1898 struct bchannel *bch;
1899
1900 if (rq->adr.channel > 2)
1901 return -EINVAL;
1902 if (rq->protocol == ISDN_P_NONE)
1903 return -EINVAL;
1904 bch = &hc->bch[rq->adr.channel - 1];
1905 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
1906 return -EBUSY; /* b-channel can be only open once */
1907 bch->ch.protocol = rq->protocol;
1908 rq->ch = &bch->ch; /* TODO: E-channel */
1909 if (!try_module_get(THIS_MODULE))
1910 printk(KERN_WARNING "%s:cannot get module\n", __func__);
1911 return 0;
1912}
1913
1914/*
1915 * device control function
1916 */
1917static int
1918hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1919{
1920 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
1921 struct dchannel *dch = container_of(dev, struct dchannel, dev);
1922 struct hfc_pci *hc = dch->hw;
1923 struct channel_req *rq;
1924 int err = 0;
1925
1926 if (dch->debug & DEBUG_HW)
1927 printk(KERN_DEBUG "%s: cmd:%x %p\n",
1928 __func__, cmd, arg);
1929 switch (cmd) {
1930 case OPEN_CHANNEL:
1931 rq = arg;
1932 if (rq->adr.channel == 0)
1933 err = open_dchannel(hc, ch, rq);
1934 else
1935 err = open_bchannel(hc, rq);
1936 break;
1937 case CLOSE_CHANNEL:
1938 if (debug & DEBUG_HW_OPEN)
1939 printk(KERN_DEBUG "%s: dev(%d) close from %p\n",
1940 __func__, hc->dch.dev.id,
1941 __builtin_return_address(0));
1942 module_put(THIS_MODULE);
1943 break;
1944 case CONTROL_CHANNEL:
1945 err = channel_ctrl(hc, arg);
1946 break;
1947 default:
1948 if (dch->debug & DEBUG_HW)
1949 printk(KERN_DEBUG "%s: unknown command %x\n",
1950 __func__, cmd);
1951 return -EINVAL;
1952 }
1953 return err;
1954}
1955
1956static int
1957setup_hw(struct hfc_pci *hc)
1958{
1959 void *buffer;
1960
1961 printk(KERN_INFO "mISDN: HFC-PCI driver %s\n", hfcpci_revision);
1962 hc->hw.cirm = 0;
1963 hc->dch.state = 0;
1964 pci_set_master(hc->pdev);
1965 if (!hc->irq) {
1966 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
1967 return 1;
1968 }
1969 hc->hw.pci_io = (char *)(ulong)hc->pdev->resource[1].start;
1970
1971 if (!hc->hw.pci_io) {
1972 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
1973 return 1;
1974 }
1975 /* Allocate memory for FIFOS */
1976 /* the memory needs to be on a 32k boundary within the first 4G */
1977 pci_set_dma_mask(hc->pdev, 0xFFFF8000);
1978 buffer = pci_alloc_consistent(hc->pdev, 0x8000, &hc->hw.dmahandle);
1979 /* We silently assume the address is okay if nonzero */
1980 if (!buffer) {
1981 printk(KERN_WARNING
1982 "HFC-PCI: Error allocating memory for FIFO!\n");
1983 return 1;
1984 }
1985 hc->hw.fifos = buffer;
1986 pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle);
1987 hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256);
1988 printk(KERN_INFO
1989 "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n",
1990 (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos,
1991 (u_long) hc->hw.dmahandle, hc->irq, HZ);
1992 /* enable memory mapped ports, disable busmaster */
1993 pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
1994 hc->hw.int_m2 = 0;
1995 disable_hwirq(hc);
1996 hc->hw.int_m1 = 0;
1997 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
1998 /* At this point the needed PCI config is done */
1999 /* fifos are still not enabled */
2000 hc->hw.timer.function = (void *) hfcpci_Timer;
2001 hc->hw.timer.data = (long) hc;
2002 init_timer(&hc->hw.timer);
2003 /* default PCM master */
2004 test_and_set_bit(HFC_CFG_MASTER, &hc->cfg);
2005 return 0;
2006}
2007
2008static void
2009release_card(struct hfc_pci *hc) {
2010 u_long flags;
2011
2012 spin_lock_irqsave(&hc->lock, flags);
2013 hc->hw.int_m2 = 0; /* interrupt output off ! */
2014 disable_hwirq(hc);
2015 mode_hfcpci(&hc->bch[0], 1, ISDN_P_NONE);
2016 mode_hfcpci(&hc->bch[1], 2, ISDN_P_NONE);
2017 if (hc->dch.timer.function != NULL) {
2018 del_timer(&hc->dch.timer);
2019 hc->dch.timer.function = NULL;
2020 }
2021 spin_unlock_irqrestore(&hc->lock, flags);
2022 if (hc->hw.protocol == ISDN_P_TE_S0)
2023 l1_event(hc->dch.l1, CLOSE_CHANNEL);
2024 if (hc->initdone)
2025 free_irq(hc->irq, hc);
2026 release_io_hfcpci(hc); /* must release after free_irq! */
2027 mISDN_unregister_device(&hc->dch.dev);
2028 mISDN_freebchannel(&hc->bch[1]);
2029 mISDN_freebchannel(&hc->bch[0]);
2030 mISDN_freedchannel(&hc->dch);
2031 list_del(&hc->list);
2032 pci_set_drvdata(hc->pdev, NULL);
2033 kfree(hc);
2034}
2035
2036static int
2037setup_card(struct hfc_pci *card)
2038{
2039 int err = -EINVAL;
2040 u_int i;
2041 u_long flags;
2042 char name[MISDN_MAX_IDLEN];
2043
2044 if (HFC_cnt >= MAX_CARDS)
2045 return -EINVAL; /* maybe better value */
2046
2047 card->dch.debug = debug;
2048 spin_lock_init(&card->lock);
2049 mISDN_initdchannel(&card->dch, MAX_DFRAME_LEN_L1, ph_state);
2050 card->dch.hw = card;
2051 card->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
2052 card->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
2053 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
2054 card->dch.dev.D.send = hfcpci_l2l1D;
2055 card->dch.dev.D.ctrl = hfc_dctrl;
2056 card->dch.dev.nrbchan = 2;
2057 for (i = 0; i < 2; i++) {
2058 card->bch[i].nr = i + 1;
2059 test_and_set_bit(i + 1, &card->dch.dev.channelmap[0]);
2060 card->bch[i].debug = debug;
2061 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM);
2062 card->bch[i].hw = card;
2063 card->bch[i].ch.send = hfcpci_l2l1B;
2064 card->bch[i].ch.ctrl = hfc_bctrl;
2065 card->bch[i].ch.nr = i + 1;
2066 list_add(&card->bch[i].ch.list, &card->dch.dev.bchannels);
2067 }
2068 err = setup_hw(card);
2069 if (err)
2070 goto error;
2071 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-pci.%d", HFC_cnt + 1);
2072 err = mISDN_register_device(&card->dch.dev, name);
2073 if (err)
2074 goto error;
2075 HFC_cnt++;
2076 write_lock_irqsave(&HFClock, flags);
2077 list_add_tail(&card->list, &HFClist);
2078 write_unlock_irqrestore(&HFClock, flags);
2079 printk(KERN_INFO "HFC %d cards installed\n", HFC_cnt);
2080 return 0;
2081error:
2082 mISDN_freebchannel(&card->bch[1]);
2083 mISDN_freebchannel(&card->bch[0]);
2084 mISDN_freedchannel(&card->dch);
2085 kfree(card);
2086 return err;
2087}
2088
2089/* private data in the PCI devices list */
2090struct _hfc_map {
2091 u_int subtype;
2092 u_int flag;
2093 char *name;
2094};
2095
2096static const struct _hfc_map hfc_map[] =
2097{
2098 {HFC_CCD_2BD0, 0, "CCD/Billion/Asuscom 2BD0"},
2099 {HFC_CCD_B000, 0, "Billion B000"},
2100 {HFC_CCD_B006, 0, "Billion B006"},
2101 {HFC_CCD_B007, 0, "Billion B007"},
2102 {HFC_CCD_B008, 0, "Billion B008"},
2103 {HFC_CCD_B009, 0, "Billion B009"},
2104 {HFC_CCD_B00A, 0, "Billion B00A"},
2105 {HFC_CCD_B00B, 0, "Billion B00B"},
2106 {HFC_CCD_B00C, 0, "Billion B00C"},
2107 {HFC_CCD_B100, 0, "Seyeon B100"},
2108 {HFC_CCD_B700, 0, "Primux II S0 B700"},
2109 {HFC_CCD_B701, 0, "Primux II S0 NT B701"},
2110 {HFC_ABOCOM_2BD1, 0, "Abocom/Magitek 2BD1"},
2111 {HFC_ASUS_0675, 0, "Asuscom/Askey 675"},
2112 {HFC_BERKOM_TCONCEPT, 0, "German telekom T-Concept"},
2113 {HFC_BERKOM_A1T, 0, "German telekom A1T"},
2114 {HFC_ANIGMA_MC145575, 0, "Motorola MC145575"},
2115 {HFC_ZOLTRIX_2BD0, 0, "Zoltrix 2BD0"},
2116 {HFC_DIGI_DF_M_IOM2_E, 0,
2117 "Digi International DataFire Micro V IOM2 (Europe)"},
2118 {HFC_DIGI_DF_M_E, 0,
2119 "Digi International DataFire Micro V (Europe)"},
2120 {HFC_DIGI_DF_M_IOM2_A, 0,
2121 "Digi International DataFire Micro V IOM2 (North America)"},
2122 {HFC_DIGI_DF_M_A, 0,
2123 "Digi International DataFire Micro V (North America)"},
2124 {HFC_SITECOM_DC105V2, 0, "Sitecom Connectivity DC-105 ISDN TA"},
2125 {},
2126};
2127
2128static struct pci_device_id hfc_ids[] =
2129{
2130 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0,
2131 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[0]},
2132 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B000,
2133 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[1]},
2134 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B006,
2135 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[2]},
2136 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B007,
2137 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[3]},
2138 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B008,
2139 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[4]},
2140 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B009,
2141 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[5]},
2142 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00A,
2143 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[6]},
2144 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B,
2145 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[7]},
2146 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C,
2147 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[8]},
2148 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100,
2149 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[9]},
2150 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B700,
2151 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[10]},
2152 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B701,
2153 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[11]},
2154 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1,
2155 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[12]},
2156 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675,
2157 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[13]},
2158 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT,
2159 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[14]},
2160 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T,
2161 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[15]},
2162 {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575,
2163 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[16]},
2164 {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0,
2165 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[17]},
2166 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E,
2167 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[18]},
2168 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E,
2169 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[19]},
2170 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A,
2171 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[20]},
2172 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A,
2173 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[21]},
2174 {PCI_VENDOR_ID_SITECOM, PCI_DEVICE_ID_SITECOM_DC105V2,
2175 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &hfc_map[22]},
2176 {},
2177};
2178
2179static int __devinit
2180hfc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2181{
2182 int err = -ENOMEM;
2183 struct hfc_pci *card;
2184 struct _hfc_map *m = (struct _hfc_map *)ent->driver_data;
2185
2186 card = kzalloc(sizeof(struct hfc_pci), GFP_ATOMIC);
2187 if (!card) {
2188 printk(KERN_ERR "No kmem for HFC card\n");
2189 return err;
2190 }
2191 card->pdev = pdev;
2192 card->subtype = m->subtype;
2193 err = pci_enable_device(pdev);
2194 if (err) {
2195 kfree(card);
2196 return err;
2197 }
2198
2199 printk(KERN_INFO "mISDN_hfcpci: found adapter %s at %s\n",
2200 m->name, pci_name(pdev));
2201
2202 card->irq = pdev->irq;
2203 pci_set_drvdata(pdev, card);
2204 err = setup_card(card);
2205 if (err)
2206 pci_set_drvdata(pdev, NULL);
2207 return err;
2208}
2209
2210static void __devexit
2211hfc_remove_pci(struct pci_dev *pdev)
2212{
2213 struct hfc_pci *card = pci_get_drvdata(pdev);
2214 u_long flags;
2215
2216 if (card) {
2217 write_lock_irqsave(&HFClock, flags);
2218 release_card(card);
2219 write_unlock_irqrestore(&HFClock, flags);
2220 } else
2221 if (debug)
2222 printk(KERN_WARNING "%s: drvdata allready removed\n",
2223 __func__);
2224}
2225
2226
2227static struct pci_driver hfc_driver = {
2228 .name = "hfcpci",
2229 .probe = hfc_probe,
2230 .remove = __devexit_p(hfc_remove_pci),
2231 .id_table = hfc_ids,
2232};
2233
2234static int __init
2235HFC_init(void)
2236{
2237 int err;
2238
2239 err = pci_register_driver(&hfc_driver);
2240 return err;
2241}
2242
2243static void __exit
2244HFC_cleanup(void)
2245{
2246 struct hfc_pci *card, *next;
2247
2248 list_for_each_entry_safe(card, next, &HFClist, list) {
2249 release_card(card);
2250 }
2251 pci_unregister_driver(&hfc_driver);
2252}
2253
2254module_init(HFC_init);
2255module_exit(HFC_cleanup);
diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c
index c0b4db2f8364..1925118122f8 100644
--- a/drivers/isdn/hisax/hisax_fcpcipnp.c
+++ b/drivers/isdn/hisax/hisax_fcpcipnp.c
@@ -974,8 +974,6 @@ static struct pnp_driver fcpnp_driver = {
974 .remove = __devexit_p(fcpnp_remove), 974 .remove = __devexit_p(fcpnp_remove),
975 .id_table = fcpnp_ids, 975 .id_table = fcpnp_ids,
976}; 976};
977#else
978static struct pnp_driver fcpnp_driver;
979#endif 977#endif
980 978
981static void __devexit fcpci_remove(struct pci_dev *pdev) 979static void __devexit fcpci_remove(struct pci_dev *pdev)
diff --git a/drivers/isdn/mISDN/Kconfig b/drivers/isdn/mISDN/Kconfig
new file mode 100644
index 000000000000..4938355c4072
--- /dev/null
+++ b/drivers/isdn/mISDN/Kconfig
@@ -0,0 +1,44 @@
1#
2# modularer ISDN driver
3#
4
5menuconfig MISDN
6 tristate "Modular ISDN driver"
7 help
8 Enable support for the modular ISDN driver.
9
10if MISDN != n
11
12config MISDN_DSP
13 tristate "Digital Audio Processing of transparent data"
14 depends on MISDN
15 help
16 Enable support for digital audio processing capability.
17 This module may be used for special applications that require
18 cross connecting of bchannels, conferencing, dtmf decoding
19 echo cancelation, tone generation, and Blowfish encryption and
20 decryption.
21 It may use hardware features if available.
22 E.g. it is required for PBX4Linux. Go to http://isdn.eversberg.eu
23 and get more informations about this module and it's usage.
24 If unsure, say 'N'.
25
26config MISDN_L1OIP
27 tristate "ISDN over IP tunnel"
28 depends on MISDN
29 help
30 Enable support for ISDN over IP tunnel.
31
32 It features:
33 - dynamic IP exchange, if one or both peers have dynamic IPs
34 - BRI (S0) and PRI (S2M) interface
35 - layer 1 control via network keepalive frames
36 - direct tunneling of physical interface via IP
37
38 NOTE: This protocol is called 'Layer 1 over IP' and is not
39 compatible with ISDNoIP (Agfeo) or TDMoIP. Protocol description is
40 provided in the source code.
41
42source "drivers/isdn/hardware/mISDN/Kconfig"
43
44endif #MISDN
diff --git a/drivers/isdn/mISDN/Makefile b/drivers/isdn/mISDN/Makefile
new file mode 100644
index 000000000000..1cb5e633cf75
--- /dev/null
+++ b/drivers/isdn/mISDN/Makefile
@@ -0,0 +1,13 @@
1#
2# Makefile for the modular ISDN driver
3#
4
5obj-$(CONFIG_MISDN) += mISDN_core.o
6obj-$(CONFIG_MISDN_DSP) += mISDN_dsp.o
7obj-$(CONFIG_MISDN_L1OIP) += l1oip.o
8
9# multi objects
10
11mISDN_core-objs := core.o fsm.o socket.o hwchannel.o stack.o layer1.o layer2.o tei.o timerdev.o
12mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o dsp_pipeline.o dsp_hwec.o
13l1oip-objs := l1oip_core.o l1oip_codec.o
diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
new file mode 100644
index 000000000000..33068177b7c9
--- /dev/null
+++ b/drivers/isdn/mISDN/core.c
@@ -0,0 +1,244 @@
1/*
2 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/types.h>
16#include <linux/stddef.h>
17#include <linux/module.h>
18#include <linux/spinlock.h>
19#include <linux/mISDNif.h>
20#include "core.h"
21
22static u_int debug;
23
24MODULE_AUTHOR("Karsten Keil");
25MODULE_LICENSE("GPL");
26module_param(debug, uint, S_IRUGO | S_IWUSR);
27
28static LIST_HEAD(devices);
29DEFINE_RWLOCK(device_lock);
30static u64 device_ids;
31#define MAX_DEVICE_ID 63
32
33static LIST_HEAD(Bprotocols);
34DEFINE_RWLOCK(bp_lock);
35
36struct mISDNdevice
37*get_mdevice(u_int id)
38{
39 struct mISDNdevice *dev;
40
41 read_lock(&device_lock);
42 list_for_each_entry(dev, &devices, D.list)
43 if (dev->id == id) {
44 read_unlock(&device_lock);
45 return dev;
46 }
47 read_unlock(&device_lock);
48 return NULL;
49}
50
51int
52get_mdevice_count(void)
53{
54 struct mISDNdevice *dev;
55 int cnt = 0;
56
57 read_lock(&device_lock);
58 list_for_each_entry(dev, &devices, D.list)
59 cnt++;
60 read_unlock(&device_lock);
61 return cnt;
62}
63
64static int
65get_free_devid(void)
66{
67 u_int i;
68
69 for (i = 0; i <= MAX_DEVICE_ID; i++)
70 if (!test_and_set_bit(i, (u_long *)&device_ids))
71 return i;
72 return -1;
73}
74
75int
76mISDN_register_device(struct mISDNdevice *dev, char *name)
77{
78 u_long flags;
79 int err;
80
81 dev->id = get_free_devid();
82 if (dev->id < 0)
83 return -EBUSY;
84 if (name && name[0])
85 strcpy(dev->name, name);
86 else
87 sprintf(dev->name, "mISDN%d", dev->id);
88 if (debug & DEBUG_CORE)
89 printk(KERN_DEBUG "mISDN_register %s %d\n",
90 dev->name, dev->id);
91 err = create_stack(dev);
92 if (err)
93 return err;
94 write_lock_irqsave(&device_lock, flags);
95 list_add_tail(&dev->D.list, &devices);
96 write_unlock_irqrestore(&device_lock, flags);
97 return 0;
98}
99EXPORT_SYMBOL(mISDN_register_device);
100
101void
102mISDN_unregister_device(struct mISDNdevice *dev) {
103 u_long flags;
104
105 if (debug & DEBUG_CORE)
106 printk(KERN_DEBUG "mISDN_unregister %s %d\n",
107 dev->name, dev->id);
108 write_lock_irqsave(&device_lock, flags);
109 list_del(&dev->D.list);
110 write_unlock_irqrestore(&device_lock, flags);
111 test_and_clear_bit(dev->id, (u_long *)&device_ids);
112 delete_stack(dev);
113}
114EXPORT_SYMBOL(mISDN_unregister_device);
115
116u_int
117get_all_Bprotocols(void)
118{
119 struct Bprotocol *bp;
120 u_int m = 0;
121
122 read_lock(&bp_lock);
123 list_for_each_entry(bp, &Bprotocols, list)
124 m |= bp->Bprotocols;
125 read_unlock(&bp_lock);
126 return m;
127}
128
129struct Bprotocol *
130get_Bprotocol4mask(u_int m)
131{
132 struct Bprotocol *bp;
133
134 read_lock(&bp_lock);
135 list_for_each_entry(bp, &Bprotocols, list)
136 if (bp->Bprotocols & m) {
137 read_unlock(&bp_lock);
138 return bp;
139 }
140 read_unlock(&bp_lock);
141 return NULL;
142}
143
144struct Bprotocol *
145get_Bprotocol4id(u_int id)
146{
147 u_int m;
148
149 if (id < ISDN_P_B_START || id > 63) {
150 printk(KERN_WARNING "%s id not in range %d\n",
151 __func__, id);
152 return NULL;
153 }
154 m = 1 << (id & ISDN_P_B_MASK);
155 return get_Bprotocol4mask(m);
156}
157
158int
159mISDN_register_Bprotocol(struct Bprotocol *bp)
160{
161 u_long flags;
162 struct Bprotocol *old;
163
164 if (debug & DEBUG_CORE)
165 printk(KERN_DEBUG "%s: %s/%x\n", __func__,
166 bp->name, bp->Bprotocols);
167 old = get_Bprotocol4mask(bp->Bprotocols);
168 if (old) {
169 printk(KERN_WARNING
170 "register duplicate protocol old %s/%x new %s/%x\n",
171 old->name, old->Bprotocols, bp->name, bp->Bprotocols);
172 return -EBUSY;
173 }
174 write_lock_irqsave(&bp_lock, flags);
175 list_add_tail(&bp->list, &Bprotocols);
176 write_unlock_irqrestore(&bp_lock, flags);
177 return 0;
178}
179EXPORT_SYMBOL(mISDN_register_Bprotocol);
180
181void
182mISDN_unregister_Bprotocol(struct Bprotocol *bp)
183{
184 u_long flags;
185
186 if (debug & DEBUG_CORE)
187 printk(KERN_DEBUG "%s: %s/%x\n", __func__, bp->name,
188 bp->Bprotocols);
189 write_lock_irqsave(&bp_lock, flags);
190 list_del(&bp->list);
191 write_unlock_irqrestore(&bp_lock, flags);
192}
193EXPORT_SYMBOL(mISDN_unregister_Bprotocol);
194
195int
196mISDNInit(void)
197{
198 int err;
199
200 printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n",
201 MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE);
202 mISDN_initstack(&debug);
203 err = mISDN_inittimer(&debug);
204 if (err)
205 goto error;
206 err = l1_init(&debug);
207 if (err) {
208 mISDN_timer_cleanup();
209 goto error;
210 }
211 err = Isdnl2_Init(&debug);
212 if (err) {
213 mISDN_timer_cleanup();
214 l1_cleanup();
215 goto error;
216 }
217 err = misdn_sock_init(&debug);
218 if (err) {
219 mISDN_timer_cleanup();
220 l1_cleanup();
221 Isdnl2_cleanup();
222 }
223error:
224 return err;
225}
226
227void mISDN_cleanup(void)
228{
229 misdn_sock_cleanup();
230 mISDN_timer_cleanup();
231 l1_cleanup();
232 Isdnl2_cleanup();
233
234 if (!list_empty(&devices))
235 printk(KERN_ERR "%s devices still registered\n", __func__);
236
237 if (!list_empty(&Bprotocols))
238 printk(KERN_ERR "%s Bprotocols still registered\n", __func__);
239 printk(KERN_DEBUG "mISDNcore unloaded\n");
240}
241
242module_init(mISDNInit);
243module_exit(mISDN_cleanup);
244
diff --git a/drivers/isdn/mISDN/core.h b/drivers/isdn/mISDN/core.h
new file mode 100644
index 000000000000..7da7233b4c1a
--- /dev/null
+++ b/drivers/isdn/mISDN/core.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef mISDN_CORE_H
16#define mISDN_CORE_H
17
18extern struct mISDNdevice *get_mdevice(u_int);
19extern int get_mdevice_count(void);
20
21/* stack status flag */
22#define mISDN_STACK_ACTION_MASK 0x0000ffff
23#define mISDN_STACK_COMMAND_MASK 0x000f0000
24#define mISDN_STACK_STATUS_MASK 0xfff00000
25/* action bits 0-15 */
26#define mISDN_STACK_WORK 0
27#define mISDN_STACK_SETUP 1
28#define mISDN_STACK_CLEARING 2
29#define mISDN_STACK_RESTART 3
30#define mISDN_STACK_WAKEUP 4
31#define mISDN_STACK_ABORT 15
32/* command bits 16-19 */
33#define mISDN_STACK_STOPPED 16
34#define mISDN_STACK_INIT 17
35#define mISDN_STACK_THREADSTART 18
36/* status bits 20-31 */
37#define mISDN_STACK_BCHANNEL 20
38#define mISDN_STACK_ACTIVE 29
39#define mISDN_STACK_RUNNING 30
40#define mISDN_STACK_KILLED 31
41
42
43/* manager options */
44#define MGR_OPT_USER 24
45#define MGR_OPT_NETWORK 25
46
47extern int connect_Bstack(struct mISDNdevice *, struct mISDNchannel *,
48 u_int, struct sockaddr_mISDN *);
49extern int connect_layer1(struct mISDNdevice *, struct mISDNchannel *,
50 u_int, struct sockaddr_mISDN *);
51extern int create_l2entity(struct mISDNdevice *, struct mISDNchannel *,
52 u_int, struct sockaddr_mISDN *);
53
54extern int create_stack(struct mISDNdevice *);
55extern int create_teimanager(struct mISDNdevice *);
56extern void delete_teimanager(struct mISDNchannel *);
57extern void delete_channel(struct mISDNchannel *);
58extern void delete_stack(struct mISDNdevice *);
59extern void mISDN_initstack(u_int *);
60extern int misdn_sock_init(u_int *);
61extern void misdn_sock_cleanup(void);
62extern void add_layer2(struct mISDNchannel *, struct mISDNstack *);
63extern void __add_layer2(struct mISDNchannel *, struct mISDNstack *);
64
65extern u_int get_all_Bprotocols(void);
66struct Bprotocol *get_Bprotocol4mask(u_int);
67struct Bprotocol *get_Bprotocol4id(u_int);
68
69extern int mISDN_inittimer(u_int *);
70extern void mISDN_timer_cleanup(void);
71
72extern int l1_init(u_int *);
73extern void l1_cleanup(void);
74extern int Isdnl2_Init(u_int *);
75extern void Isdnl2_cleanup(void);
76
77#endif
diff --git a/drivers/isdn/mISDN/dsp.h b/drivers/isdn/mISDN/dsp.h
new file mode 100644
index 000000000000..6c3fed6b8d4f
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp.h
@@ -0,0 +1,263 @@
1/*
2 * Audio support data for ISDN4Linux.
3 *
4 * Copyright 2002/2003 by Andreas Eversberg (jolly@eversberg.eu)
5 *
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
8 *
9 */
10
11#define DEBUG_DSP_CTRL 0x0001
12#define DEBUG_DSP_CORE 0x0002
13#define DEBUG_DSP_DTMF 0x0004
14#define DEBUG_DSP_CMX 0x0010
15#define DEBUG_DSP_TONE 0x0020
16#define DEBUG_DSP_BLOWFISH 0x0040
17#define DEBUG_DSP_DELAY 0x0100
18#define DEBUG_DSP_DTMFCOEFF 0x8000 /* heavy output */
19
20/* options may be:
21 *
22 * bit 0 = use ulaw instead of alaw
23 * bit 1 = enable hfc hardware accelleration for all channels
24 *
25 */
26#define DSP_OPT_ULAW (1<<0)
27#define DSP_OPT_NOHARDWARE (1<<1)
28
29#include <linux/timer.h>
30#include <linux/workqueue.h>
31
32#include "dsp_ecdis.h"
33
34extern int dsp_options;
35extern int dsp_debug;
36extern int dsp_poll;
37extern int dsp_tics;
38extern spinlock_t dsp_lock;
39extern struct work_struct dsp_workq;
40extern u32 dsp_poll_diff; /* calculated fix-comma corrected poll value */
41
42/***************
43 * audio stuff *
44 ***************/
45
46extern s32 dsp_audio_alaw_to_s32[256];
47extern s32 dsp_audio_ulaw_to_s32[256];
48extern s32 *dsp_audio_law_to_s32;
49extern u8 dsp_audio_s16_to_law[65536];
50extern u8 dsp_audio_alaw_to_ulaw[256];
51extern u8 dsp_audio_mix_law[65536];
52extern u8 dsp_audio_seven2law[128];
53extern u8 dsp_audio_law2seven[256];
54extern void dsp_audio_generate_law_tables(void);
55extern void dsp_audio_generate_s2law_table(void);
56extern void dsp_audio_generate_seven(void);
57extern void dsp_audio_generate_mix_table(void);
58extern void dsp_audio_generate_ulaw_samples(void);
59extern void dsp_audio_generate_volume_changes(void);
60extern u8 dsp_silence;
61
62
63/*************
64 * cmx stuff *
65 *************/
66
67#define MAX_POLL 256 /* maximum number of send-chunks */
68
69#define CMX_BUFF_SIZE 0x8000 /* must be 2**n (0x1000 about 1/2 second) */
70#define CMX_BUFF_HALF 0x4000 /* CMX_BUFF_SIZE / 2 */
71#define CMX_BUFF_MASK 0x7fff /* CMX_BUFF_SIZE - 1 */
72
73/* how many seconds will we check the lowest delay until the jitter buffer
74 is reduced by that delay */
75#define MAX_SECONDS_JITTER_CHECK 5
76
77extern struct timer_list dsp_spl_tl;
78extern u32 dsp_spl_jiffies;
79
80/* the structure of conferences:
81 *
82 * each conference has a unique number, given by user space.
83 * the conferences are linked in a chain.
84 * each conference has members linked in a chain.
85 * each dsplayer points to a member, each member points to a dsplayer.
86 */
87
88/* all members within a conference (this is linked 1:1 with the dsp) */
89struct dsp;
90struct dsp_conf_member {
91 struct list_head list;
92 struct dsp *dsp;
93};
94
95/* the list of all conferences */
96struct dsp_conf {
97 struct list_head list;
98 u32 id;
99 /* all cmx stacks with the same ID are
100 connected */
101 struct list_head mlist;
102 int software; /* conf is processed by software */
103 int hardware; /* conf is processed by hardware */
104 /* note: if both unset, has only one member */
105};
106
107
108/**************
109 * DTMF stuff *
110 **************/
111
112#define DSP_DTMF_NPOINTS 102
113
114#define ECHOCAN_BUFLEN (4*128)
115
116struct dsp_dtmf {
117 int treshold; /* above this is dtmf (square of) */
118 int software; /* dtmf uses software decoding */
119 int hardware; /* dtmf uses hardware decoding */
120 int size; /* number of bytes in buffer */
121 signed short buffer[DSP_DTMF_NPOINTS];
122 /* buffers one full dtmf frame */
123 u8 lastwhat, lastdigit;
124 int count;
125 u8 digits[16]; /* just the dtmf result */
126};
127
128
129/******************
130 * pipeline stuff *
131 ******************/
132struct dsp_pipeline {
133 rwlock_t lock;
134 struct list_head list;
135 int inuse;
136};
137
138/***************
139 * tones stuff *
140 ***************/
141
142struct dsp_tone {
143 int software; /* tones are generated by software */
144 int hardware; /* tones are generated by hardware */
145 int tone;
146 void *pattern;
147 int count;
148 int index;
149 struct timer_list tl;
150};
151
152/*****************
153 * general stuff *
154 *****************/
155
156struct dsp {
157 struct list_head list;
158 struct mISDNchannel ch;
159 struct mISDNchannel *up;
160 unsigned char name[64];
161 int b_active;
162 int echo; /* echo is enabled */
163 int rx_disabled; /* what the user wants */
164 int rx_is_off; /* what the card is */
165 int tx_mix;
166 struct dsp_tone tone;
167 struct dsp_dtmf dtmf;
168 int tx_volume, rx_volume;
169
170 /* queue for sending frames */
171 struct work_struct workq;
172 struct sk_buff_head sendq;
173 int hdlc; /* if mode is hdlc */
174 int data_pending; /* currently an unconfirmed frame */
175
176 /* conference stuff */
177 u32 conf_id;
178 struct dsp_conf *conf;
179 struct dsp_conf_member
180 *member;
181
182 /* buffer stuff */
183 int rx_W; /* current write pos for data without timestamp */
184 int rx_R; /* current read pos for transmit clock */
185 int rx_init; /* if set, pointers will be adjusted first */
186 int tx_W; /* current write pos for transmit data */
187 int tx_R; /* current read pos for transmit clock */
188 int rx_delay[MAX_SECONDS_JITTER_CHECK];
189 int tx_delay[MAX_SECONDS_JITTER_CHECK];
190 u8 tx_buff[CMX_BUFF_SIZE];
191 u8 rx_buff[CMX_BUFF_SIZE];
192 int last_tx; /* if set, we transmitted last poll interval */
193 int cmx_delay; /* initial delay of buffers,
194 or 0 for dynamic jitter buffer */
195 int tx_dejitter; /* if set, dejitter tx buffer */
196 int tx_data; /* enables tx-data of CMX to upper layer */
197
198 /* hardware stuff */
199 struct dsp_features features;
200 int features_rx_off; /* set if rx_off is featured */
201 int pcm_slot_rx; /* current PCM slot (or -1) */
202 int pcm_bank_rx;
203 int pcm_slot_tx;
204 int pcm_bank_tx;
205 int hfc_conf; /* unique id of current conference (or -1) */
206
207 /* encryption stuff */
208 int bf_enable;
209 u32 bf_p[18];
210 u32 bf_s[1024];
211 int bf_crypt_pos;
212 u8 bf_data_in[9];
213 u8 bf_crypt_out[9];
214 int bf_decrypt_in_pos;
215 int bf_decrypt_out_pos;
216 u8 bf_crypt_inring[16];
217 u8 bf_data_out[9];
218 int bf_sync;
219
220 struct dsp_pipeline
221 pipeline;
222};
223
224/* functions */
225
226extern void dsp_change_volume(struct sk_buff *skb, int volume);
227
228extern struct list_head dsp_ilist;
229extern struct list_head conf_ilist;
230extern void dsp_cmx_debug(struct dsp *dsp);
231extern void dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp);
232extern int dsp_cmx_conf(struct dsp *dsp, u32 conf_id);
233extern void dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb);
234extern void dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb);
235extern void dsp_cmx_send(void *arg);
236extern void dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb);
237extern int dsp_cmx_del_conf_member(struct dsp *dsp);
238extern int dsp_cmx_del_conf(struct dsp_conf *conf);
239
240extern void dsp_dtmf_goertzel_init(struct dsp *dsp);
241extern void dsp_dtmf_hardware(struct dsp *dsp);
242extern u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len,
243 int fmt);
244
245extern int dsp_tone(struct dsp *dsp, int tone);
246extern void dsp_tone_copy(struct dsp *dsp, u8 *data, int len);
247extern void dsp_tone_timeout(void *arg);
248
249extern void dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len);
250extern void dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len);
251extern int dsp_bf_init(struct dsp *dsp, const u8 *key, unsigned int keylen);
252extern void dsp_bf_cleanup(struct dsp *dsp);
253
254extern int dsp_pipeline_module_init(void);
255extern void dsp_pipeline_module_exit(void);
256extern int dsp_pipeline_init(struct dsp_pipeline *pipeline);
257extern void dsp_pipeline_destroy(struct dsp_pipeline *pipeline);
258extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg);
259extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data,
260 int len);
261extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data,
262 int len);
263
diff --git a/drivers/isdn/mISDN/dsp_audio.c b/drivers/isdn/mISDN/dsp_audio.c
new file mode 100644
index 000000000000..1c2dd5694773
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_audio.c
@@ -0,0 +1,434 @@
1/*
2 * Audio support data for mISDN_dsp.
3 *
4 * Copyright 2002/2003 by Andreas Eversberg (jolly@eversberg.eu)
5 * Rewritten by Peter
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#include <linux/delay.h>
13#include <linux/mISDNif.h>
14#include <linux/mISDNdsp.h>
15#include "core.h"
16#include "dsp.h"
17
18/* ulaw[unsigned char] -> signed 16-bit */
19s32 dsp_audio_ulaw_to_s32[256];
20/* alaw[unsigned char] -> signed 16-bit */
21s32 dsp_audio_alaw_to_s32[256];
22
23s32 *dsp_audio_law_to_s32;
24EXPORT_SYMBOL(dsp_audio_law_to_s32);
25
26/* signed 16-bit -> law */
27u8 dsp_audio_s16_to_law[65536];
28EXPORT_SYMBOL(dsp_audio_s16_to_law);
29
30/* alaw -> ulaw */
31u8 dsp_audio_alaw_to_ulaw[256];
32/* ulaw -> alaw */
33u8 dsp_audio_ulaw_to_alaw[256];
34u8 dsp_silence;
35
36
37/*****************************************************
38 * generate table for conversion of s16 to alaw/ulaw *
39 *****************************************************/
40
41#define AMI_MASK 0x55
42
43static inline unsigned char linear2alaw(short int linear)
44{
45 int mask;
46 int seg;
47 int pcm_val;
48 static int seg_end[8] = {
49 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
50 };
51
52 pcm_val = linear;
53 if (pcm_val >= 0) {
54 /* Sign (7th) bit = 1 */
55 mask = AMI_MASK | 0x80;
56 } else {
57 /* Sign bit = 0 */
58 mask = AMI_MASK;
59 pcm_val = -pcm_val;
60 }
61
62 /* Convert the scaled magnitude to segment number. */
63 for (seg = 0; seg < 8; seg++) {
64 if (pcm_val <= seg_end[seg])
65 break;
66 }
67 /* Combine the sign, segment, and quantization bits. */
68 return ((seg << 4) |
69 ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;
70}
71
72
73static inline short int alaw2linear(unsigned char alaw)
74{
75 int i;
76 int seg;
77
78 alaw ^= AMI_MASK;
79 i = ((alaw & 0x0F) << 4) + 8 /* rounding error */;
80 seg = (((int) alaw & 0x70) >> 4);
81 if (seg)
82 i = (i + 0x100) << (seg - 1);
83 return (short int) ((alaw & 0x80) ? i : -i);
84}
85
86static inline short int ulaw2linear(unsigned char ulaw)
87{
88 short mu, e, f, y;
89 static short etab[] = {0, 132, 396, 924, 1980, 4092, 8316, 16764};
90
91 mu = 255 - ulaw;
92 e = (mu & 0x70) / 16;
93 f = mu & 0x0f;
94 y = f * (1 << (e + 3));
95 y += etab[e];
96 if (mu & 0x80)
97 y = -y;
98 return y;
99}
100
101#define BIAS 0x84 /*!< define the add-in bias for 16 bit samples */
102
103static unsigned char linear2ulaw(short sample)
104{
105 static int exp_lut[256] = {
106 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
107 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
108 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
109 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
110 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
111 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
112 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
113 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
114 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
115 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
116 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
117 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
118 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
119 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
120 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
121 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};
122 int sign, exponent, mantissa;
123 unsigned char ulawbyte;
124
125 /* Get the sample into sign-magnitude. */
126 sign = (sample >> 8) & 0x80; /* set aside the sign */
127 if (sign != 0)
128 sample = -sample; /* get magnitude */
129
130 /* Convert from 16 bit linear to ulaw. */
131 sample = sample + BIAS;
132 exponent = exp_lut[(sample >> 7) & 0xFF];
133 mantissa = (sample >> (exponent + 3)) & 0x0F;
134 ulawbyte = ~(sign | (exponent << 4) | mantissa);
135
136 return ulawbyte;
137}
138
139static int reverse_bits(int i)
140{
141 int z, j;
142 z = 0;
143
144 for (j = 0; j < 8; j++) {
145 if ((i & (1 << j)) != 0)
146 z |= 1 << (7 - j);
147 }
148 return z;
149}
150
151
152void dsp_audio_generate_law_tables(void)
153{
154 int i;
155 for (i = 0; i < 256; i++)
156 dsp_audio_alaw_to_s32[i] = alaw2linear(reverse_bits(i));
157
158 for (i = 0; i < 256; i++)
159 dsp_audio_ulaw_to_s32[i] = ulaw2linear(reverse_bits(i));
160
161 for (i = 0; i < 256; i++) {
162 dsp_audio_alaw_to_ulaw[i] =
163 linear2ulaw(dsp_audio_alaw_to_s32[i]);
164 dsp_audio_ulaw_to_alaw[i] =
165 linear2alaw(dsp_audio_ulaw_to_s32[i]);
166 }
167}
168
169void
170dsp_audio_generate_s2law_table(void)
171{
172 int i;
173
174 if (dsp_options & DSP_OPT_ULAW) {
175 /* generating ulaw-table */
176 for (i = -32768; i < 32768; i++) {
177 dsp_audio_s16_to_law[i & 0xffff] =
178 reverse_bits(linear2ulaw(i));
179 }
180 } else {
181 /* generating alaw-table */
182 for (i = -32768; i < 32768; i++) {
183 dsp_audio_s16_to_law[i & 0xffff] =
184 reverse_bits(linear2alaw(i));
185 }
186 }
187}
188
189
190/*
191 * the seven bit sample is the number of every second alaw-sample ordered by
192 * aplitude. 0x00 is negative, 0x7f is positive amplitude.
193 */
194u8 dsp_audio_seven2law[128];
195u8 dsp_audio_law2seven[256];
196
197/********************************************************************
198 * generate table for conversion law from/to 7-bit alaw-like sample *
199 ********************************************************************/
200
201void
202dsp_audio_generate_seven(void)
203{
204 int i, j, k;
205 u8 spl;
206 u8 sorted_alaw[256];
207
208 /* generate alaw table, sorted by the linear value */
209 for (i = 0; i < 256; i++) {
210 j = 0;
211 for (k = 0; k < 256; k++) {
212 if (dsp_audio_alaw_to_s32[k]
213 < dsp_audio_alaw_to_s32[i]) {
214 j++;
215 }
216 }
217 sorted_alaw[j] = i;
218 }
219
220 /* generate tabels */
221 for (i = 0; i < 256; i++) {
222 /* spl is the source: the law-sample (converted to alaw) */
223 spl = i;
224 if (dsp_options & DSP_OPT_ULAW)
225 spl = dsp_audio_ulaw_to_alaw[i];
226 /* find the 7-bit-sample */
227 for (j = 0; j < 256; j++) {
228 if (sorted_alaw[j] == spl)
229 break;
230 }
231 /* write 7-bit audio value */
232 dsp_audio_law2seven[i] = j >> 1;
233 }
234 for (i = 0; i < 128; i++) {
235 spl = sorted_alaw[i << 1];
236 if (dsp_options & DSP_OPT_ULAW)
237 spl = dsp_audio_alaw_to_ulaw[spl];
238 dsp_audio_seven2law[i] = spl;
239 }
240}
241
242
243/* mix 2*law -> law */
244u8 dsp_audio_mix_law[65536];
245
246/******************************************************
247 * generate mix table to mix two law samples into one *
248 ******************************************************/
249
250void
251dsp_audio_generate_mix_table(void)
252{
253 int i, j;
254 s32 sample;
255
256 i = 0;
257 while (i < 256) {
258 j = 0;
259 while (j < 256) {
260 sample = dsp_audio_law_to_s32[i];
261 sample += dsp_audio_law_to_s32[j];
262 if (sample > 32767)
263 sample = 32767;
264 if (sample < -32768)
265 sample = -32768;
266 dsp_audio_mix_law[(i<<8)|j] =
267 dsp_audio_s16_to_law[sample & 0xffff];
268 j++;
269 }
270 i++;
271 }
272}
273
274
275/*************************************
276 * generate different volume changes *
277 *************************************/
278
279static u8 dsp_audio_reduce8[256];
280static u8 dsp_audio_reduce7[256];
281static u8 dsp_audio_reduce6[256];
282static u8 dsp_audio_reduce5[256];
283static u8 dsp_audio_reduce4[256];
284static u8 dsp_audio_reduce3[256];
285static u8 dsp_audio_reduce2[256];
286static u8 dsp_audio_reduce1[256];
287static u8 dsp_audio_increase1[256];
288static u8 dsp_audio_increase2[256];
289static u8 dsp_audio_increase3[256];
290static u8 dsp_audio_increase4[256];
291static u8 dsp_audio_increase5[256];
292static u8 dsp_audio_increase6[256];
293static u8 dsp_audio_increase7[256];
294static u8 dsp_audio_increase8[256];
295
296static u8 *dsp_audio_volume_change[16] = {
297 dsp_audio_reduce8,
298 dsp_audio_reduce7,
299 dsp_audio_reduce6,
300 dsp_audio_reduce5,
301 dsp_audio_reduce4,
302 dsp_audio_reduce3,
303 dsp_audio_reduce2,
304 dsp_audio_reduce1,
305 dsp_audio_increase1,
306 dsp_audio_increase2,
307 dsp_audio_increase3,
308 dsp_audio_increase4,
309 dsp_audio_increase5,
310 dsp_audio_increase6,
311 dsp_audio_increase7,
312 dsp_audio_increase8,
313};
314
315void
316dsp_audio_generate_volume_changes(void)
317{
318 register s32 sample;
319 int i;
320 int num[] = { 110, 125, 150, 175, 200, 300, 400, 500 };
321 int denum[] = { 100, 100, 100, 100, 100, 100, 100, 100 };
322
323 i = 0;
324 while (i < 256) {
325 dsp_audio_reduce8[i] = dsp_audio_s16_to_law[
326 (dsp_audio_law_to_s32[i] * denum[7] / num[7]) & 0xffff];
327 dsp_audio_reduce7[i] = dsp_audio_s16_to_law[
328 (dsp_audio_law_to_s32[i] * denum[6] / num[6]) & 0xffff];
329 dsp_audio_reduce6[i] = dsp_audio_s16_to_law[
330 (dsp_audio_law_to_s32[i] * denum[5] / num[5]) & 0xffff];
331 dsp_audio_reduce5[i] = dsp_audio_s16_to_law[
332 (dsp_audio_law_to_s32[i] * denum[4] / num[4]) & 0xffff];
333 dsp_audio_reduce4[i] = dsp_audio_s16_to_law[
334 (dsp_audio_law_to_s32[i] * denum[3] / num[3]) & 0xffff];
335 dsp_audio_reduce3[i] = dsp_audio_s16_to_law[
336 (dsp_audio_law_to_s32[i] * denum[2] / num[2]) & 0xffff];
337 dsp_audio_reduce2[i] = dsp_audio_s16_to_law[
338 (dsp_audio_law_to_s32[i] * denum[1] / num[1]) & 0xffff];
339 dsp_audio_reduce1[i] = dsp_audio_s16_to_law[
340 (dsp_audio_law_to_s32[i] * denum[0] / num[0]) & 0xffff];
341 sample = dsp_audio_law_to_s32[i] * num[0] / denum[0];
342 if (sample < -32768)
343 sample = -32768;
344 else if (sample > 32767)
345 sample = 32767;
346 dsp_audio_increase1[i] = dsp_audio_s16_to_law[sample & 0xffff];
347 sample = dsp_audio_law_to_s32[i] * num[1] / denum[1];
348 if (sample < -32768)
349 sample = -32768;
350 else if (sample > 32767)
351 sample = 32767;
352 dsp_audio_increase2[i] = dsp_audio_s16_to_law[sample & 0xffff];
353 sample = dsp_audio_law_to_s32[i] * num[2] / denum[2];
354 if (sample < -32768)
355 sample = -32768;
356 else if (sample > 32767)
357 sample = 32767;
358 dsp_audio_increase3[i] = dsp_audio_s16_to_law[sample & 0xffff];
359 sample = dsp_audio_law_to_s32[i] * num[3] / denum[3];
360 if (sample < -32768)
361 sample = -32768;
362 else if (sample > 32767)
363 sample = 32767;
364 dsp_audio_increase4[i] = dsp_audio_s16_to_law[sample & 0xffff];
365 sample = dsp_audio_law_to_s32[i] * num[4] / denum[4];
366 if (sample < -32768)
367 sample = -32768;
368 else if (sample > 32767)
369 sample = 32767;
370 dsp_audio_increase5[i] = dsp_audio_s16_to_law[sample & 0xffff];
371 sample = dsp_audio_law_to_s32[i] * num[5] / denum[5];
372 if (sample < -32768)
373 sample = -32768;
374 else if (sample > 32767)
375 sample = 32767;
376 dsp_audio_increase6[i] = dsp_audio_s16_to_law[sample & 0xffff];
377 sample = dsp_audio_law_to_s32[i] * num[6] / denum[6];
378 if (sample < -32768)
379 sample = -32768;
380 else if (sample > 32767)
381 sample = 32767;
382 dsp_audio_increase7[i] = dsp_audio_s16_to_law[sample & 0xffff];
383 sample = dsp_audio_law_to_s32[i] * num[7] / denum[7];
384 if (sample < -32768)
385 sample = -32768;
386 else if (sample > 32767)
387 sample = 32767;
388 dsp_audio_increase8[i] = dsp_audio_s16_to_law[sample & 0xffff];
389
390 i++;
391 }
392}
393
394
395/**************************************
396 * change the volume of the given skb *
397 **************************************/
398
399/* this is a helper function for changing volume of skb. the range may be
400 * -8 to 8, which is a shift to the power of 2. 0 == no volume, 3 == volume*8
401 */
402void
403dsp_change_volume(struct sk_buff *skb, int volume)
404{
405 u8 *volume_change;
406 int i, ii;
407 u8 *p;
408 int shift;
409
410 if (volume == 0)
411 return;
412
413 /* get correct conversion table */
414 if (volume < 0) {
415 shift = volume + 8;
416 if (shift < 0)
417 shift = 0;
418 } else {
419 shift = volume + 7;
420 if (shift > 15)
421 shift = 15;
422 }
423 volume_change = dsp_audio_volume_change[shift];
424 i = 0;
425 ii = skb->len;
426 p = skb->data;
427 /* change volume */
428 while (i < ii) {
429 *p = volume_change[*p];
430 p++;
431 i++;
432 }
433}
434
diff --git a/drivers/isdn/mISDN/dsp_biquad.h b/drivers/isdn/mISDN/dsp_biquad.h
new file mode 100644
index 000000000000..038191bc45f5
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_biquad.h
@@ -0,0 +1,65 @@
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * biquad.h - General telephony bi-quad section routines (currently this just
5 * handles canonic/type 2 form)
6 *
7 * Written by Steve Underwood <steveu@coppice.org>
8 *
9 * Copyright (C) 2001 Steve Underwood
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 */
28
29struct biquad2_state {
30 int32_t gain;
31 int32_t a1;
32 int32_t a2;
33 int32_t b1;
34 int32_t b2;
35
36 int32_t z1;
37 int32_t z2;
38};
39
40static inline void biquad2_init(struct biquad2_state *bq,
41 int32_t gain, int32_t a1, int32_t a2, int32_t b1, int32_t b2)
42{
43 bq->gain = gain;
44 bq->a1 = a1;
45 bq->a2 = a2;
46 bq->b1 = b1;
47 bq->b2 = b2;
48
49 bq->z1 = 0;
50 bq->z2 = 0;
51}
52
53static inline int16_t biquad2(struct biquad2_state *bq, int16_t sample)
54{
55 int32_t y;
56 int32_t z0;
57
58 z0 = sample*bq->gain + bq->z1*bq->a1 + bq->z2*bq->a2;
59 y = z0 + bq->z1*bq->b1 + bq->z2*bq->b2;
60
61 bq->z2 = bq->z1;
62 bq->z1 = z0 >> 15;
63 y >>= 15;
64 return y;
65}
diff --git a/drivers/isdn/mISDN/dsp_blowfish.c b/drivers/isdn/mISDN/dsp_blowfish.c
new file mode 100644
index 000000000000..18e411e95bba
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_blowfish.c
@@ -0,0 +1,672 @@
1/*
2 * Blowfish encryption/decryption for mISDN_dsp.
3 *
4 * Copyright Andreas Eversberg (jolly@eversberg.eu)
5 *
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
8 *
9 */
10
11#include <linux/mISDNif.h>
12#include <linux/mISDNdsp.h>
13#include "core.h"
14#include "dsp.h"
15
16/*
17 * how to encode a sample stream to 64-bit blocks that will be encryped
18 *
19 * first of all, data is collected until a block of 9 samples are received.
20 * of course, a packet may have much more than 9 sample, but is may have
21 * not excacly the multiple of 9 samples. if there is a rest, the next
22 * received data will complete the block.
23 *
24 * the block is then converted to 9 uLAW samples without the least sigificant
25 * bit. the result is a 7-bit encoded sample.
26 *
27 * the samples will be reoganised to form 8 bytes of data:
28 * (5(6) means: encoded sample no. 5, bit 6)
29 *
30 * 0(6) 0(5) 0(4) 0(3) 0(2) 0(1) 0(0) 1(6)
31 * 1(5) 1(4) 1(3) 1(2) 1(1) 1(0) 2(6) 2(5)
32 * 2(4) 2(3) 2(2) 2(1) 2(0) 3(6) 3(5) 3(4)
33 * 3(3) 3(2) 3(1) 3(0) 4(6) 4(5) 4(4) 4(3)
34 * 4(2) 4(1) 4(0) 5(6) 5(5) 5(4) 5(3) 5(2)
35 * 5(1) 5(0) 6(6) 6(5) 6(4) 6(3) 6(2) 6(1)
36 * 6(0) 7(6) 7(5) 7(4) 7(3) 7(2) 7(1) 7(0)
37 * 8(6) 8(5) 8(4) 8(3) 8(2) 8(1) 8(0)
38 *
39 * the missing bit 0 of the last byte is filled with some
40 * random noise, to fill all 8 bytes.
41 *
42 * the 8 bytes will be encrypted using blowfish.
43 *
44 * the result will be converted into 9 bytes. the bit 7 is used for
45 * checksumme (CS) for sync (0, 1) and for the last bit:
46 * (5(6) means: crypted byte 5, bit 6)
47 *
48 * 1 0(7) 0(6) 0(5) 0(4) 0(3) 0(2) 0(1)
49 * 0 0(0) 1(7) 1(6) 1(5) 1(4) 1(3) 1(2)
50 * 0 1(1) 1(0) 2(7) 2(6) 2(5) 2(4) 2(3)
51 * 0 2(2) 2(1) 2(0) 3(7) 3(6) 3(5) 3(4)
52 * 0 3(3) 3(2) 3(1) 3(0) 4(7) 4(6) 4(5)
53 * CS 4(4) 4(3) 4(2) 4(1) 4(0) 5(7) 5(6)
54 * CS 5(5) 5(4) 5(3) 5(2) 5(1) 5(0) 6(7)
55 * CS 6(6) 6(5) 6(4) 6(3) 6(2) 6(1) 6(0)
56 * 7(0) 7(6) 7(5) 7(4) 7(3) 7(2) 7(1) 7(0)
57 *
58 * the checksum is used to detect transmission errors and frame drops.
59 *
60 * synchronisation of received block is done by shifting the upper bit of each
61 * byte (bit 7) to a shift register. if the rigister has the first five bits
62 * (10000), this is used to find the sync. only if sync has been found, the
63 * current block of 9 received bytes are decrypted. before that the check
64 * sum is calculated. if it is incorrect the block is dropped.
65 * this will avoid loud noise due to corrupt encrypted data.
66 *
67 * if the last block is corrupt, the current decoded block is repeated
68 * until a valid block has been received.
69 */
70
71/*
72 * some blowfish parts are taken from the
73 * crypto-api for faster implementation
74 */
75
76struct bf_ctx {
77 u32 p[18];
78 u32 s[1024];
79};
80
81static const u32 bf_pbox[16 + 2] = {
82 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
83 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
84 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
85 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
86 0x9216d5d9, 0x8979fb1b,
87};
88
89static const u32 bf_sbox[256 * 4] = {
90 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
91 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
92 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
93 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
94 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
95 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
96 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
97 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
98 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
99 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
100 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
101 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
102 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
103 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
104 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
105 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
106 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
107 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
108 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
109 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
110 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
111 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
112 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
113 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
114 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
115 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
116 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
117 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
118 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
119 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
120 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
121 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
122 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
123 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
124 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
125 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
126 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
127 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
128 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
129 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
130 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
131 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
132 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
133 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
134 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
135 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
136 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
137 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
138 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
139 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
140 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
141 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
142 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
143 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
144 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
145 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
146 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
147 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
148 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
149 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
150 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
151 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
152 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
153 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
154 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
155 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
156 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
157 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
158 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
159 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
160 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
161 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
162 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
163 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
164 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
165 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
166 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
167 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
168 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
169 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
170 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
171 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
172 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
173 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
174 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
175 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
176 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
177 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
178 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
179 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
180 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
181 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
182 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
183 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
184 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
185 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
186 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
187 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
188 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
189 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
190 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
191 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
192 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
193 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
194 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
195 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
196 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
197 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
198 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
199 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
200 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
201 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
202 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
203 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
204 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
205 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
206 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
207 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
208 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
209 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
210 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
211 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
212 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
213 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
214 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
215 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
216 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
217 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
218 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
219 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
220 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
221 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
222 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
223 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
224 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
225 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
226 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
227 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
228 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
229 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
230 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
231 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
232 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
233 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
234 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
235 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
236 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
237 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
238 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
239 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
240 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
241 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
242 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
243 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
244 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
245 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
246 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
247 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
248 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
249 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
250 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
251 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
252 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
253 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
254 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
255 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
256 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
257 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
258 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
259 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
260 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
261 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
262 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
263 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
264 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
265 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
266 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
267 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
268 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
269 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
270 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
271 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
272 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
273 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
274 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
275 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
276 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
277 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
278 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
279 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
280 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
281 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
282 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
283 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
284 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
285 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
286 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
287 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
288 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
289 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
290 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
291 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
292 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
293 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
294 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
295 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
296 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
297 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
298 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
299 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
300 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
301 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
302 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
303 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
304 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
305 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
306 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
307 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
308 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
309 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
310 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
311 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
312 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
313 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
314 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
315 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
316 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
317 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
318 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
319 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
320 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
321 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
322 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
323 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
324 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
325 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
326 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
327 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
328 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
329 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
330 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
331 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
332 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
333 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
334 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
335 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
336 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
337 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
338 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
339 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
340 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
341 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
342 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
343 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
344 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
345 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
346};
347
348/*
349 * Round loop unrolling macros, S is a pointer to a S-Box array
350 * organized in 4 unsigned longs at a row.
351 */
352#define GET32_3(x) (((x) & 0xff))
353#define GET32_2(x) (((x) >> (8)) & (0xff))
354#define GET32_1(x) (((x) >> (16)) & (0xff))
355#define GET32_0(x) (((x) >> (24)) & (0xff))
356
357#define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \
358 S[512 + GET32_2(x)]) + S[768 + GET32_3(x)])
359
360#define EROUND(a, b, n) do { b ^= P[n]; a ^= bf_F(b); } while (0)
361#define DROUND(a, b, n) do { a ^= bf_F(b); b ^= P[n]; } while (0)
362
363
364/*
365 * encrypt isdn data frame
366 * every block with 9 samples is encrypted
367 */
368void
369dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len)
370{
371 int i = 0, j = dsp->bf_crypt_pos;
372 u8 *bf_data_in = dsp->bf_data_in;
373 u8 *bf_crypt_out = dsp->bf_crypt_out;
374 u32 *P = dsp->bf_p;
375 u32 *S = dsp->bf_s;
376 u32 yl, yr;
377 u32 cs;
378 u8 nibble;
379
380 while (i < len) {
381 /* collect a block of 9 samples */
382 if (j < 9) {
383 bf_data_in[j] = *data;
384 *data++ = bf_crypt_out[j++];
385 i++;
386 continue;
387 }
388 j = 0;
389 /* transcode 9 samples xlaw to 8 bytes */
390 yl = dsp_audio_law2seven[bf_data_in[0]];
391 yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[1]];
392 yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[2]];
393 yl = (yl<<7) | dsp_audio_law2seven[bf_data_in[3]];
394 nibble = dsp_audio_law2seven[bf_data_in[4]];
395 yr = nibble;
396 yl = (yl<<4) | (nibble>>3);
397 yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[5]];
398 yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[6]];
399 yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[7]];
400 yr = (yr<<7) | dsp_audio_law2seven[bf_data_in[8]];
401 yr = (yr<<1) | (bf_data_in[0] & 1);
402
403 /* fill unused bit with random noise of audio input */
404 /* encrypt */
405
406 EROUND(yr, yl, 0);
407 EROUND(yl, yr, 1);
408 EROUND(yr, yl, 2);
409 EROUND(yl, yr, 3);
410 EROUND(yr, yl, 4);
411 EROUND(yl, yr, 5);
412 EROUND(yr, yl, 6);
413 EROUND(yl, yr, 7);
414 EROUND(yr, yl, 8);
415 EROUND(yl, yr, 9);
416 EROUND(yr, yl, 10);
417 EROUND(yl, yr, 11);
418 EROUND(yr, yl, 12);
419 EROUND(yl, yr, 13);
420 EROUND(yr, yl, 14);
421 EROUND(yl, yr, 15);
422 yl ^= P[16];
423 yr ^= P[17];
424
425 /* calculate 3-bit checksumme */
426 cs = yl ^ (yl>>3) ^ (yl>>6) ^ (yl>>9) ^ (yl>>12) ^ (yl>>15)
427 ^ (yl>>18) ^ (yl>>21) ^ (yl>>24) ^ (yl>>27) ^ (yl>>30)
428 ^ (yr<<2) ^ (yr>>1) ^ (yr>>4) ^ (yr>>7) ^ (yr>>10)
429 ^ (yr>>13) ^ (yr>>16) ^ (yr>>19) ^ (yr>>22) ^ (yr>>25)
430 ^ (yr>>28) ^ (yr>>31);
431
432 /*
433 * transcode 8 crypted bytes to 9 data bytes with sync
434 * and checksum information
435 */
436 bf_crypt_out[0] = (yl>>25) | 0x80;
437 bf_crypt_out[1] = (yl>>18) & 0x7f;
438 bf_crypt_out[2] = (yl>>11) & 0x7f;
439 bf_crypt_out[3] = (yl>>4) & 0x7f;
440 bf_crypt_out[4] = ((yl<<3) & 0x78) | ((yr>>29) & 0x07);
441 bf_crypt_out[5] = ((yr>>22) & 0x7f) | ((cs<<5) & 0x80);
442 bf_crypt_out[6] = ((yr>>15) & 0x7f) | ((cs<<6) & 0x80);
443 bf_crypt_out[7] = ((yr>>8) & 0x7f) | (cs<<7);
444 bf_crypt_out[8] = yr;
445 }
446
447 /* write current count */
448 dsp->bf_crypt_pos = j;
449
450}
451
452
453/*
454 * decrypt isdn data frame
455 * every block with 9 bytes is decrypted
456 */
457void
458dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len)
459{
460 int i = 0;
461 u8 j = dsp->bf_decrypt_in_pos;
462 u8 k = dsp->bf_decrypt_out_pos;
463 u8 *bf_crypt_inring = dsp->bf_crypt_inring;
464 u8 *bf_data_out = dsp->bf_data_out;
465 u16 sync = dsp->bf_sync;
466 u32 *P = dsp->bf_p;
467 u32 *S = dsp->bf_s;
468 u32 yl, yr;
469 u8 nibble;
470 u8 cs, cs0, cs1, cs2;
471
472 while (i < len) {
473 /*
474 * shift upper bit and rotate data to buffer ring
475 * send current decrypted data
476 */
477 sync = (sync<<1) | ((*data)>>7);
478 bf_crypt_inring[j++ & 15] = *data;
479 *data++ = bf_data_out[k++];
480 i++;
481 if (k == 9)
482 k = 0; /* repeat if no sync has been found */
483 /* check if not in sync */
484 if ((sync&0x1f0) != 0x100)
485 continue;
486 j -= 9;
487 /* transcode receive data to 64 bit block of encrypted data */
488 yl = bf_crypt_inring[j++ & 15];
489 yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */
490 yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */
491 yl = (yl<<7) | bf_crypt_inring[j++ & 15]; /* bit7 = 0 */
492 nibble = bf_crypt_inring[j++ & 15]; /* bit7 = 0 */
493 yr = nibble;
494 yl = (yl<<4) | (nibble>>3);
495 cs2 = bf_crypt_inring[j++ & 15];
496 yr = (yr<<7) | (cs2 & 0x7f);
497 cs1 = bf_crypt_inring[j++ & 15];
498 yr = (yr<<7) | (cs1 & 0x7f);
499 cs0 = bf_crypt_inring[j++ & 15];
500 yr = (yr<<7) | (cs0 & 0x7f);
501 yr = (yr<<8) | bf_crypt_inring[j++ & 15];
502
503 /* calculate 3-bit checksumme */
504 cs = yl ^ (yl>>3) ^ (yl>>6) ^ (yl>>9) ^ (yl>>12) ^ (yl>>15)
505 ^ (yl>>18) ^ (yl>>21) ^ (yl>>24) ^ (yl>>27) ^ (yl>>30)
506 ^ (yr<<2) ^ (yr>>1) ^ (yr>>4) ^ (yr>>7) ^ (yr>>10)
507 ^ (yr>>13) ^ (yr>>16) ^ (yr>>19) ^ (yr>>22) ^ (yr>>25)
508 ^ (yr>>28) ^ (yr>>31);
509
510 /* check if frame is valid */
511 if ((cs&0x7) != (((cs2>>5)&4) | ((cs1>>6)&2) | (cs0 >> 7))) {
512 if (dsp_debug & DEBUG_DSP_BLOWFISH)
513 printk(KERN_DEBUG
514 "DSP BLOWFISH: received corrupt frame, "
515 "checksumme is not correct\n");
516 continue;
517 }
518
519 /* decrypt */
520 yr ^= P[17];
521 yl ^= P[16];
522 DROUND(yl, yr, 15);
523 DROUND(yr, yl, 14);
524 DROUND(yl, yr, 13);
525 DROUND(yr, yl, 12);
526 DROUND(yl, yr, 11);
527 DROUND(yr, yl, 10);
528 DROUND(yl, yr, 9);
529 DROUND(yr, yl, 8);
530 DROUND(yl, yr, 7);
531 DROUND(yr, yl, 6);
532 DROUND(yl, yr, 5);
533 DROUND(yr, yl, 4);
534 DROUND(yl, yr, 3);
535 DROUND(yr, yl, 2);
536 DROUND(yl, yr, 1);
537 DROUND(yr, yl, 0);
538
539 /* transcode 8 crypted bytes to 9 sample bytes */
540 bf_data_out[0] = dsp_audio_seven2law[(yl>>25) & 0x7f];
541 bf_data_out[1] = dsp_audio_seven2law[(yl>>18) & 0x7f];
542 bf_data_out[2] = dsp_audio_seven2law[(yl>>11) & 0x7f];
543 bf_data_out[3] = dsp_audio_seven2law[(yl>>4) & 0x7f];
544 bf_data_out[4] = dsp_audio_seven2law[((yl<<3) & 0x78) |
545 ((yr>>29) & 0x07)];
546
547 bf_data_out[5] = dsp_audio_seven2law[(yr>>22) & 0x7f];
548 bf_data_out[6] = dsp_audio_seven2law[(yr>>15) & 0x7f];
549 bf_data_out[7] = dsp_audio_seven2law[(yr>>8) & 0x7f];
550 bf_data_out[8] = dsp_audio_seven2law[(yr>>1) & 0x7f];
551 k = 0; /* start with new decoded frame */
552 }
553
554 /* write current count and sync */
555 dsp->bf_decrypt_in_pos = j;
556 dsp->bf_decrypt_out_pos = k;
557 dsp->bf_sync = sync;
558}
559
560
561/* used to encrypt S and P boxes */
562static inline void
563encrypt_block(const u32 *P, const u32 *S, u32 *dst, u32 *src)
564{
565 u32 yl = src[0];
566 u32 yr = src[1];
567
568 EROUND(yr, yl, 0);
569 EROUND(yl, yr, 1);
570 EROUND(yr, yl, 2);
571 EROUND(yl, yr, 3);
572 EROUND(yr, yl, 4);
573 EROUND(yl, yr, 5);
574 EROUND(yr, yl, 6);
575 EROUND(yl, yr, 7);
576 EROUND(yr, yl, 8);
577 EROUND(yl, yr, 9);
578 EROUND(yr, yl, 10);
579 EROUND(yl, yr, 11);
580 EROUND(yr, yl, 12);
581 EROUND(yl, yr, 13);
582 EROUND(yr, yl, 14);
583 EROUND(yl, yr, 15);
584
585 yl ^= P[16];
586 yr ^= P[17];
587
588 dst[0] = yr;
589 dst[1] = yl;
590}
591
592/*
593 * initialize the dsp for encryption and decryption using the same key
594 * Calculates the blowfish S and P boxes for encryption and decryption.
595 * The margin of keylen must be 4-56 bytes.
596 * returns 0 if ok.
597 */
598int
599dsp_bf_init(struct dsp *dsp, const u8 *key, uint keylen)
600{
601 short i, j, count;
602 u32 data[2], temp;
603 u32 *P = (u32 *)dsp->bf_p;
604 u32 *S = (u32 *)dsp->bf_s;
605
606 if (keylen < 4 || keylen > 56)
607 return 1;
608
609 /* Set dsp states */
610 i = 0;
611 while (i < 9) {
612 dsp->bf_crypt_out[i] = 0xff;
613 dsp->bf_data_out[i] = dsp_silence;
614 i++;
615 }
616 dsp->bf_crypt_pos = 0;
617 dsp->bf_decrypt_in_pos = 0;
618 dsp->bf_decrypt_out_pos = 0;
619 dsp->bf_sync = 0x1ff;
620 dsp->bf_enable = 1;
621
622 /* Copy the initialization s-boxes */
623 for (i = 0, count = 0; i < 256; i++)
624 for (j = 0; j < 4; j++, count++)
625 S[count] = bf_sbox[count];
626
627 /* Set the p-boxes */
628 for (i = 0; i < 16 + 2; i++)
629 P[i] = bf_pbox[i];
630
631 /* Actual subkey generation */
632 for (j = 0, i = 0; i < 16 + 2; i++) {
633 temp = (((u32)key[j] << 24) |
634 ((u32)key[(j + 1) % keylen] << 16) |
635 ((u32)key[(j + 2) % keylen] << 8) |
636 ((u32)key[(j + 3) % keylen]));
637
638 P[i] = P[i] ^ temp;
639 j = (j + 4) % keylen;
640 }
641
642 data[0] = 0x00000000;
643 data[1] = 0x00000000;
644
645 for (i = 0; i < 16 + 2; i += 2) {
646 encrypt_block(P, S, data, data);
647
648 P[i] = data[0];
649 P[i + 1] = data[1];
650 }
651
652 for (i = 0; i < 4; i++) {
653 for (j = 0, count = i * 256; j < 256; j += 2, count += 2) {
654 encrypt_block(P, S, data, data);
655
656 S[count] = data[0];
657 S[count + 1] = data[1];
658 }
659 }
660
661 return 0;
662}
663
664
665/*
666 * turn encryption off
667 */
668void
669dsp_bf_cleanup(struct dsp *dsp)
670{
671 dsp->bf_enable = 0;
672}
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
new file mode 100644
index 000000000000..e92b1ba4b45e
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -0,0 +1,1886 @@
1/*
2 * Audio crossconnecting/conferrencing (hardware level).
3 *
4 * Copyright 2002 by Andreas Eversberg (jolly@eversberg.eu)
5 *
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
8 *
9 */
10
11/*
12 * The process of adding and removing parties to/from a conference:
13 *
14 * There is a chain of struct dsp_conf which has one or more members in a chain
15 * of struct dsp_conf_member.
16 *
17 * After a party is added, the conference is checked for hardware capability.
18 * Also if a party is removed, the conference is checked again.
19 *
20 * There are 3 different solutions: -1 = software, 0 = hardware-crossconnect
21 * 1-n = hardware-conference. The n will give the conference number.
22 *
23 * Depending on the change after removal or insertion of a party, hardware
24 * commands are given.
25 *
26 * The current solution is stored within the struct dsp_conf entry.
27 */
28
29/*
30 * HOW THE CMX WORKS:
31 *
32 * There are 3 types of interaction: One member is alone, in this case only
33 * data flow from upper to lower layer is done.
34 * Two members will also exchange their data so they are crossconnected.
35 * Three or more members will be added in a conference and will hear each
36 * other but will not receive their own speech (echo) if not enabled.
37 *
38 * Features of CMX are:
39 * - Crossconnecting or even conference, if more than two members are together.
40 * - Force mixing of transmit data with other crossconnect/conference members.
41 * - Echo generation to benchmark the delay of audio processing.
42 * - Use hardware to minimize cpu load, disable FIFO load and minimize delay.
43 * - Dejittering and clock generation.
44 *
45 * There are 2 buffers:
46 *
47 *
48 * RX-Buffer
49 * R W
50 * | |
51 * ----------------+-------------+-------------------
52 *
53 * The rx-buffer is a ring buffer used to store the received data for each
54 * individual member. This is only the case if data needs to be dejittered
55 * or in case of a conference where different clocks require reclocking.
56 * The transmit-clock (R) will read the buffer.
57 * If the clock overruns the write-pointer, we will have a buffer underrun.
58 * If the write pointer always has a certain distance from the transmit-
59 * clock, we will have a delay. The delay will dynamically be increased and
60 * reduced.
61 *
62 *
63 * TX-Buffer
64 * R W
65 * | |
66 * -----------------+--------+-----------------------
67 *
68 * The tx-buffer is a ring buffer to queue the transmit data from user space
69 * until it will be mixed or sent. There are two pointers, R and W. If the write
70 * pointer W would reach or overrun R, the buffer would overrun. In this case
71 * (some) data is dropped so that it will not overrun.
72 * Additionally a dynamic dejittering can be enabled. this allows data from
73 * user space that have jitter and different clock source.
74 *
75 *
76 * Clock:
77 *
78 * A Clock is not required, if the data source has exactly one clock. In this
79 * case the data source is forwarded to the destination.
80 *
81 * A Clock is required, because the data source
82 * - has multiple clocks.
83 * - has no usable clock due to jitter or packet loss (VoIP).
84 * In this case the system's clock is used. The clock resolution depends on
85 * the jiffie resolution.
86 *
87 * If a member joins a conference:
88 *
89 * - If a member joins, its rx_buff is set to silence and change read pointer
90 * to transmit clock.
91 *
92 * The procedure of received data from card is explained in cmx_receive.
93 * The procedure of received data from user space is explained in cmx_transmit.
94 * The procedure of transmit data to card is cmx_send.
95 *
96 *
97 * Interaction with other features:
98 *
99 * DTMF:
100 * DTMF decoding is done before the data is crossconnected.
101 *
102 * Volume change:
103 * Changing rx-volume is done before the data is crossconnected. The tx-volume
104 * must be changed whenever data is transmitted to the card by the cmx.
105 *
106 * Tones:
107 * If a tone is enabled, it will be processed whenever data is transmitted to
108 * the card. It will replace the tx-data from the user space.
109 * If tones are generated by hardware, this conference member is removed for
110 * this time.
111 *
112 * Disable rx-data:
113 * If cmx is realized in hardware, rx data will be disabled if requested by
114 * the upper layer. If dtmf decoding is done by software and enabled, rx data
115 * will not be diabled but blocked to the upper layer.
116 *
117 * HFC conference engine:
118 * If it is possible to realize all features using hardware, hardware will be
119 * used if not forbidden by control command. Disabling rx-data provides
120 * absolutely traffic free audio processing. (except for the quick 1-frame
121 * upload of a tone loop, only once for a new tone)
122 *
123 */
124
125/* delay.h is required for hw_lock.h */
126
127#include <linux/delay.h>
128#include <linux/mISDNif.h>
129#include <linux/mISDNdsp.h>
130#include "core.h"
131#include "dsp.h"
132/*
133 * debugging of multi party conference,
134 * by using conference even with two members
135 */
136
137/* #define CMX_CONF_DEBUG */
138
139/*#define CMX_DEBUG * massive read/write pointer output */
140/*#define CMX_TX_DEBUG * massive read/write on tx-buffer with content */
141
142static inline int
143count_list_member(struct list_head *head)
144{
145 int cnt = 0;
146 struct list_head *m;
147
148 list_for_each(m, head)
149 cnt++;
150 return cnt;
151}
152
153/*
154 * debug cmx memory structure
155 */
156void
157dsp_cmx_debug(struct dsp *dsp)
158{
159 struct dsp_conf *conf;
160 struct dsp_conf_member *member;
161 struct dsp *odsp;
162
163 printk(KERN_DEBUG "-----Current DSP\n");
164 list_for_each_entry(odsp, &dsp_ilist, list) {
165 printk(KERN_DEBUG "* %s echo=%d txmix=%d",
166 odsp->name, odsp->echo, odsp->tx_mix);
167 if (odsp->conf)
168 printk(" (Conf %d)", odsp->conf->id);
169 if (dsp == odsp)
170 printk(" *this*");
171 printk("\n");
172 }
173 printk(KERN_DEBUG "-----Current Conf:\n");
174 list_for_each_entry(conf, &conf_ilist, list) {
175 printk(KERN_DEBUG "* Conf %d (%p)\n", conf->id, conf);
176 list_for_each_entry(member, &conf->mlist, list) {
177 printk(KERN_DEBUG
178 " - member = %s (slot_tx %d, bank_tx %d, "
179 "slot_rx %d, bank_rx %d hfc_conf %d)%s\n",
180 member->dsp->name, member->dsp->pcm_slot_tx,
181 member->dsp->pcm_bank_tx, member->dsp->pcm_slot_rx,
182 member->dsp->pcm_bank_rx, member->dsp->hfc_conf,
183 (member->dsp == dsp) ? " *this*" : "");
184 }
185 }
186 printk(KERN_DEBUG "-----end\n");
187}
188
189/*
190 * search conference
191 */
192static struct dsp_conf *
193dsp_cmx_search_conf(u32 id)
194{
195 struct dsp_conf *conf;
196
197 if (!id) {
198 printk(KERN_WARNING "%s: conference ID is 0.\n", __func__);
199 return NULL;
200 }
201
202 /* search conference */
203 list_for_each_entry(conf, &conf_ilist, list)
204 if (conf->id == id)
205 return conf;
206
207 return NULL;
208}
209
210
211/*
212 * add member to conference
213 */
214static int
215dsp_cmx_add_conf_member(struct dsp *dsp, struct dsp_conf *conf)
216{
217 struct dsp_conf_member *member;
218
219 if (!conf || !dsp) {
220 printk(KERN_WARNING "%s: conf or dsp is 0.\n", __func__);
221 return -EINVAL;
222 }
223 if (dsp->member) {
224 printk(KERN_WARNING "%s: dsp is already member in a conf.\n",
225 __func__);
226 return -EINVAL;
227 }
228
229 if (dsp->conf) {
230 printk(KERN_WARNING "%s: dsp is already in a conf.\n",
231 __func__);
232 return -EINVAL;
233 }
234
235 member = kzalloc(sizeof(struct dsp_conf_member), GFP_ATOMIC);
236 if (!member) {
237 printk(KERN_ERR "kmalloc struct dsp_conf_member failed\n");
238 return -ENOMEM;
239 }
240 member->dsp = dsp;
241 /* clear rx buffer */
242 memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff));
243 dsp->rx_init = 1; /* rx_W and rx_R will be adjusted on first frame */
244 dsp->rx_W = 0;
245 dsp->rx_R = 0;
246
247 list_add_tail(&member->list, &conf->mlist);
248
249 dsp->conf = conf;
250 dsp->member = member;
251
252 return 0;
253}
254
255
256/*
257 * del member from conference
258 */
259int
260dsp_cmx_del_conf_member(struct dsp *dsp)
261{
262 struct dsp_conf_member *member;
263
264 if (!dsp) {
265 printk(KERN_WARNING "%s: dsp is 0.\n",
266 __func__);
267 return -EINVAL;
268 }
269
270 if (!dsp->conf) {
271 printk(KERN_WARNING "%s: dsp is not in a conf.\n",
272 __func__);
273 return -EINVAL;
274 }
275
276 if (list_empty(&dsp->conf->mlist)) {
277 printk(KERN_WARNING "%s: dsp has linked an empty conf.\n",
278 __func__);
279 return -EINVAL;
280 }
281
282 /* find us in conf */
283 list_for_each_entry(member, &dsp->conf->mlist, list) {
284 if (member->dsp == dsp) {
285 list_del(&member->list);
286 dsp->conf = NULL;
287 dsp->member = NULL;
288 kfree(member);
289 return 0;
290 }
291 }
292 printk(KERN_WARNING
293 "%s: dsp is not present in its own conf_meber list.\n",
294 __func__);
295
296 return -EINVAL;
297}
298
299
300/*
301 * new conference
302 */
303static struct dsp_conf
304*dsp_cmx_new_conf(u32 id)
305{
306 struct dsp_conf *conf;
307
308 if (!id) {
309 printk(KERN_WARNING "%s: id is 0.\n",
310 __func__);
311 return NULL;
312 }
313
314 conf = kzalloc(sizeof(struct dsp_conf), GFP_ATOMIC);
315 if (!conf) {
316 printk(KERN_ERR "kmalloc struct dsp_conf failed\n");
317 return NULL;
318 }
319 INIT_LIST_HEAD(&conf->mlist);
320 conf->id = id;
321
322 list_add_tail(&conf->list, &conf_ilist);
323
324 return conf;
325}
326
327
328/*
329 * del conference
330 */
331int
332dsp_cmx_del_conf(struct dsp_conf *conf)
333{
334 if (!conf) {
335 printk(KERN_WARNING "%s: conf is null.\n",
336 __func__);
337 return -EINVAL;
338 }
339
340 if (!list_empty(&conf->mlist)) {
341 printk(KERN_WARNING "%s: conf not empty.\n",
342 __func__);
343 return -EINVAL;
344 }
345 list_del(&conf->list);
346 kfree(conf);
347
348 return 0;
349}
350
351
352/*
353 * send HW message to hfc card
354 */
355static void
356dsp_cmx_hw_message(struct dsp *dsp, u32 message, u32 param1, u32 param2,
357 u32 param3, u32 param4)
358{
359 struct mISDN_ctrl_req cq;
360
361 memset(&cq, 0, sizeof(cq));
362 cq.op = message;
363 cq.p1 = param1 | (param2 << 8);
364 cq.p2 = param3 | (param4 << 8);
365 if (dsp->ch.peer)
366 dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq);
367}
368
369
370/*
371 * do hardware update and set the software/hardware flag
372 *
373 * either a conference or a dsp instance can be given
374 * if only dsp instance is given, the instance is not associated with a conf
375 * and therefore removed. if a conference is given, the dsp is expected to
376 * be member of that conference.
377 */
378void
379dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp)
380{
381 struct dsp_conf_member *member, *nextm;
382 struct dsp *finddsp;
383 int memb = 0, i, ii, i1, i2;
384 int freeunits[8];
385 u_char freeslots[256];
386 int same_hfc = -1, same_pcm = -1, current_conf = -1,
387 all_conf = 1;
388
389 /* dsp gets updated (no conf) */
390 if (!conf) {
391 if (!dsp)
392 return;
393 if (dsp_debug & DEBUG_DSP_CMX)
394 printk(KERN_DEBUG "%s checking dsp %s\n",
395 __func__, dsp->name);
396one_member:
397 /* remove HFC conference if enabled */
398 if (dsp->hfc_conf >= 0) {
399 if (dsp_debug & DEBUG_DSP_CMX)
400 printk(KERN_DEBUG
401 "%s removing %s from HFC conf %d "
402 "because dsp is split\n", __func__,
403 dsp->name, dsp->hfc_conf);
404 dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_CONF_SPLIT,
405 0, 0, 0, 0);
406 dsp->hfc_conf = -1;
407 }
408 /* process hw echo */
409 if (dsp->features.pcm_banks < 1)
410 return;
411 if (!dsp->echo) {
412 /* NO ECHO: remove PCM slot if assigned */
413 if (dsp->pcm_slot_tx >= 0 || dsp->pcm_slot_rx >= 0) {
414 if (dsp_debug & DEBUG_DSP_CMX)
415 printk(KERN_DEBUG "%s removing %s from"
416 " PCM slot %d (TX) %d (RX) because"
417 " dsp is split (no echo)\n",
418 __func__, dsp->name,
419 dsp->pcm_slot_tx, dsp->pcm_slot_rx);
420 dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_DISC,
421 0, 0, 0, 0);
422 dsp->pcm_slot_tx = -1;
423 dsp->pcm_bank_tx = -1;
424 dsp->pcm_slot_rx = -1;
425 dsp->pcm_bank_rx = -1;
426 }
427 return;
428 }
429 /* ECHO: already echo */
430 if (dsp->pcm_slot_tx >= 0 && dsp->pcm_slot_rx < 0 &&
431 dsp->pcm_bank_tx == 2 && dsp->pcm_bank_rx == 2)
432 return;
433 /* ECHO: if slot already assigned */
434 if (dsp->pcm_slot_tx >= 0) {
435 dsp->pcm_slot_rx = dsp->pcm_slot_tx;
436 dsp->pcm_bank_tx = 2; /* 2 means loop */
437 dsp->pcm_bank_rx = 2;
438 if (dsp_debug & DEBUG_DSP_CMX)
439 printk(KERN_DEBUG
440 "%s refresh %s for echo using slot %d\n",
441 __func__, dsp->name,
442 dsp->pcm_slot_tx);
443 dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN,
444 dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2);
445 return;
446 }
447 /* ECHO: find slot */
448 dsp->pcm_slot_tx = -1;
449 dsp->pcm_slot_rx = -1;
450 memset(freeslots, 1, sizeof(freeslots));
451 list_for_each_entry(finddsp, &dsp_ilist, list) {
452 if (finddsp->features.pcm_id == dsp->features.pcm_id) {
453 if (finddsp->pcm_slot_rx >= 0 &&
454 finddsp->pcm_slot_rx < sizeof(freeslots))
455 freeslots[finddsp->pcm_slot_tx] = 0;
456 if (finddsp->pcm_slot_tx >= 0 &&
457 finddsp->pcm_slot_tx < sizeof(freeslots))
458 freeslots[finddsp->pcm_slot_rx] = 0;
459 }
460 }
461 i = 0;
462 ii = dsp->features.pcm_slots;
463 while (i < ii) {
464 if (freeslots[i])
465 break;
466 i++;
467 }
468 if (i == ii) {
469 if (dsp_debug & DEBUG_DSP_CMX)
470 printk(KERN_DEBUG
471 "%s no slot available for echo\n",
472 __func__);
473 /* no more slots available */
474 return;
475 }
476 /* assign free slot */
477 dsp->pcm_slot_tx = i;
478 dsp->pcm_slot_rx = i;
479 dsp->pcm_bank_tx = 2; /* loop */
480 dsp->pcm_bank_rx = 2;
481 if (dsp_debug & DEBUG_DSP_CMX)
482 printk(KERN_DEBUG
483 "%s assign echo for %s using slot %d\n",
484 __func__, dsp->name, dsp->pcm_slot_tx);
485 dsp_cmx_hw_message(dsp, MISDN_CTRL_HFC_PCM_CONN,
486 dsp->pcm_slot_tx, 2, dsp->pcm_slot_rx, 2);
487 return;
488 }
489
490 /* conf gets updated (all members) */
491 if (dsp_debug & DEBUG_DSP_CMX)
492 printk(KERN_DEBUG "%s checking conference %d\n",
493 __func__, conf->id);
494
495 if (list_empty(&conf->mlist)) {
496 printk(KERN_ERR "%s: conference whithout members\n",
497 __func__);
498 return;
499 }
500 member = list_entry(conf->mlist.next, struct dsp_conf_member, list);
501 same_hfc = member->dsp->features.hfc_id;
502 same_pcm = member->dsp->features.pcm_id;
503 /* check all members in our conference */
504 list_for_each_entry(member, &conf->mlist, list) {
505 /* check if member uses mixing */
506 if (member->dsp->tx_mix) {
507 if (dsp_debug & DEBUG_DSP_CMX)
508 printk(KERN_DEBUG
509 "%s dsp %s cannot form a conf, because "
510 "tx_mix is turned on\n", __func__,
511 member->dsp->name);
512conf_software:
513 list_for_each_entry(member, &conf->mlist, list) {
514 dsp = member->dsp;
515 /* remove HFC conference if enabled */
516 if (dsp->hfc_conf >= 0) {
517 if (dsp_debug & DEBUG_DSP_CMX)
518 printk(KERN_DEBUG
519 "%s removing %s from HFC "
520 "conf %d because not "
521 "possible with hardware\n",
522 __func__,
523 dsp->name,
524 dsp->hfc_conf);
525 dsp_cmx_hw_message(dsp,
526 MISDN_CTRL_HFC_CONF_SPLIT,
527 0, 0, 0, 0);
528 dsp->hfc_conf = -1;
529 }
530 /* remove PCM slot if assigned */
531 if (dsp->pcm_slot_tx >= 0 ||
532 dsp->pcm_slot_rx >= 0) {
533 if (dsp_debug & DEBUG_DSP_CMX)
534 printk(KERN_DEBUG "%s removing "
535 "%s from PCM slot %d (TX)"
536 " slot %d (RX) because not"
537 " possible with hardware\n",
538 __func__,
539 dsp->name,
540 dsp->pcm_slot_tx,
541 dsp->pcm_slot_rx);
542 dsp_cmx_hw_message(dsp,
543 MISDN_CTRL_HFC_PCM_DISC,
544 0, 0, 0, 0);
545 dsp->pcm_slot_tx = -1;
546 dsp->pcm_bank_tx = -1;
547 dsp->pcm_slot_rx = -1;
548 dsp->pcm_bank_rx = -1;
549 }
550 }
551 conf->hardware = 0;
552 conf->software = 1;
553 return;
554 }
555 /* check if member has echo turned on */
556 if (member->dsp->echo) {
557 if (dsp_debug & DEBUG_DSP_CMX)
558 printk(KERN_DEBUG
559 "%s dsp %s cannot form a conf, because "
560 "echo is turned on\n", __func__,
561 member->dsp->name);
562 goto conf_software;
563 }
564 /* check if member has tx_mix turned on */
565 if (member->dsp->tx_mix) {
566 if (dsp_debug & DEBUG_DSP_CMX)
567 printk(KERN_DEBUG
568 "%s dsp %s cannot form a conf, because "
569 "tx_mix is turned on\n",
570 __func__, member->dsp->name);
571 goto conf_software;
572 }
573 /* check if member changes volume at an not suppoted level */
574 if (member->dsp->tx_volume) {
575 if (dsp_debug & DEBUG_DSP_CMX)
576 printk(KERN_DEBUG
577 "%s dsp %s cannot form a conf, because "
578 "tx_volume is changed\n",
579 __func__, member->dsp->name);
580 goto conf_software;
581 }
582 if (member->dsp->rx_volume) {
583 if (dsp_debug & DEBUG_DSP_CMX)
584 printk(KERN_DEBUG
585 "%s dsp %s cannot form a conf, because "
586 "rx_volume is changed\n",
587 __func__, member->dsp->name);
588 goto conf_software;
589 }
590 /* check if tx-data turned on */
591 if (member->dsp->tx_data) {
592 if (dsp_debug & DEBUG_DSP_CMX)
593 printk(KERN_DEBUG
594 "%s dsp %s cannot form a conf, because "
595 "tx_data is turned on\n",
596 __func__, member->dsp->name);
597 goto conf_software;
598 }
599 /* check if pipeline exists */
600 if (member->dsp->pipeline.inuse) {
601 if (dsp_debug & DEBUG_DSP_CMX)
602 printk(KERN_DEBUG
603 "%s dsp %s cannot form a conf, because "
604 "pipeline exists\n", __func__,
605 member->dsp->name);
606 goto conf_software;
607 }
608 /* check if encryption is enabled */
609 if (member->dsp->bf_enable) {
610 if (dsp_debug & DEBUG_DSP_CMX)
611 printk(KERN_DEBUG "%s dsp %s cannot form a "
612 "conf, because encryption is enabled\n",
613 __func__, member->dsp->name);
614 goto conf_software;
615 }
616 /* check if member is on a card with PCM support */
617 if (member->dsp->features.pcm_id < 0) {
618 if (dsp_debug & DEBUG_DSP_CMX)
619 printk(KERN_DEBUG
620 "%s dsp %s cannot form a conf, because "
621 "dsp has no PCM bus\n",
622 __func__, member->dsp->name);
623 goto conf_software;
624 }
625 /* check if relations are on the same PCM bus */
626 if (member->dsp->features.pcm_id != same_pcm) {
627 if (dsp_debug & DEBUG_DSP_CMX)
628 printk(KERN_DEBUG
629 "%s dsp %s cannot form a conf, because "
630 "dsp is on a different PCM bus than the "
631 "first dsp\n",
632 __func__, member->dsp->name);
633 goto conf_software;
634 }
635 /* determine if members are on the same hfc chip */
636 if (same_hfc != member->dsp->features.hfc_id)
637 same_hfc = -1;
638 /* if there are members already in a conference */
639 if (current_conf < 0 && member->dsp->hfc_conf >= 0)
640 current_conf = member->dsp->hfc_conf;
641 /* if any member is not in a conference */
642 if (member->dsp->hfc_conf < 0)
643 all_conf = 0;
644
645 memb++;
646 }
647
648 /* if no member, this is an error */
649 if (memb < 1)
650 return;
651
652 /* one member */
653 if (memb == 1) {
654 if (dsp_debug & DEBUG_DSP_CMX)
655 printk(KERN_DEBUG
656 "%s conf %d cannot form a HW conference, "
657 "because dsp is alone\n", __func__, conf->id);
658 conf->hardware = 0;
659 conf->software = 0;
660 member = list_entry(conf->mlist.next, struct dsp_conf_member,
661 list);
662 dsp = member->dsp;
663 goto one_member;
664 }
665
666 /*
667 * ok, now we are sure that all members are on the same pcm.
668 * now we will see if we have only two members, so we can do
669 * crossconnections, which don't have any limitations.
670 */
671
672 /* if we have only two members */
673 if (memb == 2) {
674 member = list_entry(conf->mlist.next, struct dsp_conf_member,
675 list);
676 nextm = list_entry(member->list.next, struct dsp_conf_member,
677 list);
678 /* remove HFC conference if enabled */
679 if (member->dsp->hfc_conf >= 0) {
680 if (dsp_debug & DEBUG_DSP_CMX)
681 printk(KERN_DEBUG
682 "%s removing %s from HFC conf %d because "
683 "two parties require only a PCM slot\n",
684 __func__, member->dsp->name,
685 member->dsp->hfc_conf);
686 dsp_cmx_hw_message(member->dsp,
687 MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0);
688 member->dsp->hfc_conf = -1;
689 }
690 if (nextm->dsp->hfc_conf >= 0) {
691 if (dsp_debug & DEBUG_DSP_CMX)
692 printk(KERN_DEBUG
693 "%s removing %s from HFC conf %d because "
694 "two parties require only a PCM slot\n",
695 __func__, nextm->dsp->name,
696 nextm->dsp->hfc_conf);
697 dsp_cmx_hw_message(nextm->dsp,
698 MISDN_CTRL_HFC_CONF_SPLIT, 0, 0, 0, 0);
699 nextm->dsp->hfc_conf = -1;
700 }
701 /* if members have two banks (and not on the same chip) */
702 if (member->dsp->features.pcm_banks > 1 &&
703 nextm->dsp->features.pcm_banks > 1 &&
704 member->dsp->features.hfc_id !=
705 nextm->dsp->features.hfc_id) {
706 /* if both members have same slots with crossed banks */
707 if (member->dsp->pcm_slot_tx >= 0 &&
708 member->dsp->pcm_slot_rx >= 0 &&
709 nextm->dsp->pcm_slot_tx >= 0 &&
710 nextm->dsp->pcm_slot_rx >= 0 &&
711 nextm->dsp->pcm_slot_tx ==
712 member->dsp->pcm_slot_rx &&
713 nextm->dsp->pcm_slot_rx ==
714 member->dsp->pcm_slot_tx &&
715 nextm->dsp->pcm_slot_tx ==
716 member->dsp->pcm_slot_tx &&
717 member->dsp->pcm_bank_tx !=
718 member->dsp->pcm_bank_rx &&
719 nextm->dsp->pcm_bank_tx !=
720 nextm->dsp->pcm_bank_rx) {
721 /* all members have same slot */
722 if (dsp_debug & DEBUG_DSP_CMX)
723 printk(KERN_DEBUG
724 "%s dsp %s & %s stay joined on "
725 "PCM slot %d bank %d (TX) bank %d "
726 "(RX) (on different chips)\n",
727 __func__,
728 member->dsp->name,
729 nextm->dsp->name,
730 member->dsp->pcm_slot_tx,
731 member->dsp->pcm_bank_tx,
732 member->dsp->pcm_bank_rx);
733 conf->hardware = 0;
734 conf->software = 1;
735 return;
736 }
737 /* find a new slot */
738 memset(freeslots, 1, sizeof(freeslots));
739 list_for_each_entry(dsp, &dsp_ilist, list) {
740 if (dsp != member->dsp &&
741 dsp != nextm->dsp &&
742 member->dsp->features.pcm_id ==
743 dsp->features.pcm_id) {
744 if (dsp->pcm_slot_rx >= 0 &&
745 dsp->pcm_slot_rx <
746 sizeof(freeslots))
747 freeslots[dsp->pcm_slot_tx] = 0;
748 if (dsp->pcm_slot_tx >= 0 &&
749 dsp->pcm_slot_tx <
750 sizeof(freeslots))
751 freeslots[dsp->pcm_slot_rx] = 0;
752 }
753 }
754 i = 0;
755 ii = member->dsp->features.pcm_slots;
756 while (i < ii) {
757 if (freeslots[i])
758 break;
759 i++;
760 }
761 if (i == ii) {
762 if (dsp_debug & DEBUG_DSP_CMX)
763 printk(KERN_DEBUG
764 "%s no slot available for "
765 "%s & %s\n", __func__,
766 member->dsp->name,
767 nextm->dsp->name);
768 /* no more slots available */
769 goto conf_software;
770 }
771 /* assign free slot */
772 member->dsp->pcm_slot_tx = i;
773 member->dsp->pcm_slot_rx = i;
774 nextm->dsp->pcm_slot_tx = i;
775 nextm->dsp->pcm_slot_rx = i;
776 member->dsp->pcm_bank_rx = 0;
777 member->dsp->pcm_bank_tx = 1;
778 nextm->dsp->pcm_bank_rx = 1;
779 nextm->dsp->pcm_bank_tx = 0;
780 if (dsp_debug & DEBUG_DSP_CMX)
781 printk(KERN_DEBUG
782 "%s adding %s & %s to new PCM slot %d "
783 "(TX and RX on different chips) because "
784 "both members have not same slots\n",
785 __func__,
786 member->dsp->name,
787 nextm->dsp->name,
788 member->dsp->pcm_slot_tx);
789 dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN,
790 member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx,
791 member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx);
792 dsp_cmx_hw_message(nextm->dsp, MISDN_CTRL_HFC_PCM_CONN,
793 nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx,
794 nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx);
795 conf->hardware = 1;
796 conf->software = 0;
797 return;
798 /* if members have one bank (or on the same chip) */
799 } else {
800 /* if both members have different crossed slots */
801 if (member->dsp->pcm_slot_tx >= 0 &&
802 member->dsp->pcm_slot_rx >= 0 &&
803 nextm->dsp->pcm_slot_tx >= 0 &&
804 nextm->dsp->pcm_slot_rx >= 0 &&
805 nextm->dsp->pcm_slot_tx ==
806 member->dsp->pcm_slot_rx &&
807 nextm->dsp->pcm_slot_rx ==
808 member->dsp->pcm_slot_tx &&
809 member->dsp->pcm_slot_tx !=
810 member->dsp->pcm_slot_rx &&
811 member->dsp->pcm_bank_tx == 0 &&
812 member->dsp->pcm_bank_rx == 0 &&
813 nextm->dsp->pcm_bank_tx == 0 &&
814 nextm->dsp->pcm_bank_rx == 0) {
815 /* all members have same slot */
816 if (dsp_debug & DEBUG_DSP_CMX)
817 printk(KERN_DEBUG
818 "%s dsp %s & %s stay joined on PCM "
819 "slot %d (TX) %d (RX) on same chip "
820 "or one bank PCM)\n", __func__,
821 member->dsp->name,
822 nextm->dsp->name,
823 member->dsp->pcm_slot_tx,
824 member->dsp->pcm_slot_rx);
825 conf->hardware = 0;
826 conf->software = 1;
827 return;
828 }
829 /* find two new slot */
830 memset(freeslots, 1, sizeof(freeslots));
831 list_for_each_entry(dsp, &dsp_ilist, list) {
832 if (dsp != member->dsp &&
833 dsp != nextm->dsp &&
834 member->dsp->features.pcm_id ==
835 dsp->features.pcm_id) {
836 if (dsp->pcm_slot_rx >= 0 &&
837 dsp->pcm_slot_rx <
838 sizeof(freeslots))
839 freeslots[dsp->pcm_slot_tx] = 0;
840 if (dsp->pcm_slot_tx >= 0 &&
841 dsp->pcm_slot_tx <
842 sizeof(freeslots))
843 freeslots[dsp->pcm_slot_rx] = 0;
844 }
845 }
846 i1 = 0;
847 ii = member->dsp->features.pcm_slots;
848 while (i1 < ii) {
849 if (freeslots[i1])
850 break;
851 i1++;
852 }
853 if (i1 == ii) {
854 if (dsp_debug & DEBUG_DSP_CMX)
855 printk(KERN_DEBUG
856 "%s no slot available "
857 "for %s & %s\n", __func__,
858 member->dsp->name,
859 nextm->dsp->name);
860 /* no more slots available */
861 goto conf_software;
862 }
863 i2 = i1+1;
864 while (i2 < ii) {
865 if (freeslots[i2])
866 break;
867 i2++;
868 }
869 if (i2 == ii) {
870 if (dsp_debug & DEBUG_DSP_CMX)
871 printk(KERN_DEBUG
872 "%s no slot available "
873 "for %s & %s\n",
874 __func__,
875 member->dsp->name,
876 nextm->dsp->name);
877 /* no more slots available */
878 goto conf_software;
879 }
880 /* assign free slots */
881 member->dsp->pcm_slot_tx = i1;
882 member->dsp->pcm_slot_rx = i2;
883 nextm->dsp->pcm_slot_tx = i2;
884 nextm->dsp->pcm_slot_rx = i1;
885 member->dsp->pcm_bank_rx = 0;
886 member->dsp->pcm_bank_tx = 0;
887 nextm->dsp->pcm_bank_rx = 0;
888 nextm->dsp->pcm_bank_tx = 0;
889 if (dsp_debug & DEBUG_DSP_CMX)
890 printk(KERN_DEBUG
891 "%s adding %s & %s to new PCM slot %d "
892 "(TX) %d (RX) on same chip or one bank "
893 "PCM, because both members have not "
894 "crossed slots\n", __func__,
895 member->dsp->name,
896 nextm->dsp->name,
897 member->dsp->pcm_slot_tx,
898 member->dsp->pcm_slot_rx);
899 dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN,
900 member->dsp->pcm_slot_tx, member->dsp->pcm_bank_tx,
901 member->dsp->pcm_slot_rx, member->dsp->pcm_bank_rx);
902 dsp_cmx_hw_message(nextm->dsp, MISDN_CTRL_HFC_PCM_CONN,
903 nextm->dsp->pcm_slot_tx, nextm->dsp->pcm_bank_tx,
904 nextm->dsp->pcm_slot_rx, nextm->dsp->pcm_bank_rx);
905 conf->hardware = 1;
906 conf->software = 0;
907 return;
908 }
909 }
910
911 /*
912 * if we have more than two, we may check if we have a conference
913 * unit available on the chip. also all members must be on the same
914 */
915
916 /* if not the same HFC chip */
917 if (same_hfc < 0) {
918 if (dsp_debug & DEBUG_DSP_CMX)
919 printk(KERN_DEBUG
920 "%s conference %d cannot be formed, because "
921 "members are on different chips or not "
922 "on HFC chip\n",
923 __func__, conf->id);
924 goto conf_software;
925 }
926
927 /* for more than two members.. */
928
929 /* in case of hdlc, we change to software */
930 if (dsp->hdlc)
931 goto conf_software;
932
933 /* if all members already have the same conference */
934 if (all_conf)
935 return;
936
937 /*
938 * if there is an existing conference, but not all members have joined
939 */
940 if (current_conf >= 0) {
941join_members:
942 list_for_each_entry(member, &conf->mlist, list) {
943 /* join to current conference */
944 if (member->dsp->hfc_conf == current_conf)
945 continue;
946 /* get a free timeslot first */
947 memset(freeslots, 1, sizeof(freeslots));
948 list_for_each_entry(dsp, &dsp_ilist, list) {
949 /*
950 * not checking current member, because
951 * slot will be overwritten.
952 */
953 if (
954 dsp != member->dsp &&
955 /* dsp must be on the same PCM */
956 member->dsp->features.pcm_id ==
957 dsp->features.pcm_id) {
958 /* dsp must be on a slot */
959 if (dsp->pcm_slot_tx >= 0 &&
960 dsp->pcm_slot_tx <
961 sizeof(freeslots))
962 freeslots[dsp->pcm_slot_tx] = 0;
963 if (dsp->pcm_slot_rx >= 0 &&
964 dsp->pcm_slot_rx <
965 sizeof(freeslots))
966 freeslots[dsp->pcm_slot_rx] = 0;
967 }
968 }
969 i = 0;
970 ii = member->dsp->features.pcm_slots;
971 while (i < ii) {
972 if (freeslots[i])
973 break;
974 i++;
975 }
976 if (i == ii) {
977 /* no more slots available */
978 if (dsp_debug & DEBUG_DSP_CMX)
979 printk(KERN_DEBUG
980 "%s conference %d cannot be formed,"
981 " because no slot free\n",
982 __func__, conf->id);
983 goto conf_software;
984 }
985 if (dsp_debug & DEBUG_DSP_CMX)
986 printk(KERN_DEBUG
987 "%s changing dsp %s to HW conference "
988 "%d slot %d\n", __func__,
989 member->dsp->name, current_conf, i);
990 /* assign free slot & set PCM & join conf */
991 member->dsp->pcm_slot_tx = i;
992 member->dsp->pcm_slot_rx = i;
993 member->dsp->pcm_bank_tx = 2; /* loop */
994 member->dsp->pcm_bank_rx = 2;
995 member->dsp->hfc_conf = current_conf;
996 dsp_cmx_hw_message(member->dsp, MISDN_CTRL_HFC_PCM_CONN,
997 i, 2, i, 2);
998 dsp_cmx_hw_message(member->dsp,
999 MISDN_CTRL_HFC_CONF_JOIN, current_conf, 0, 0, 0);
1000 }
1001 return;
1002 }
1003
1004 /*
1005 * no member is in a conference yet, so we find a free one
1006 */
1007 memset(freeunits, 1, sizeof(freeunits));
1008 list_for_each_entry(dsp, &dsp_ilist, list) {
1009 /* dsp must be on the same chip */
1010 if (dsp->features.hfc_id == same_hfc &&
1011 /* dsp must have joined a HW conference */
1012 dsp->hfc_conf >= 0 &&
1013 /* slot must be within range */
1014 dsp->hfc_conf < 8)
1015 freeunits[dsp->hfc_conf] = 0;
1016 }
1017 i = 0;
1018 ii = 8;
1019 while (i < ii) {
1020 if (freeunits[i])
1021 break;
1022 i++;
1023 }
1024 if (i == ii) {
1025 /* no more conferences available */
1026 if (dsp_debug & DEBUG_DSP_CMX)
1027 printk(KERN_DEBUG
1028 "%s conference %d cannot be formed, because "
1029 "no conference number free\n",
1030 __func__, conf->id);
1031 goto conf_software;
1032 }
1033 /* join all members */
1034 current_conf = i;
1035 goto join_members;
1036}
1037
1038
1039/*
1040 * conf_id != 0: join or change conference
1041 * conf_id == 0: split from conference if not already
1042 */
1043int
1044dsp_cmx_conf(struct dsp *dsp, u32 conf_id)
1045{
1046 int err;
1047 struct dsp_conf *conf;
1048 struct dsp_conf_member *member;
1049
1050 /* if conference doesn't change */
1051 if (dsp->conf_id == conf_id)
1052 return 0;
1053
1054 /* first remove us from current conf */
1055 if (dsp->conf_id) {
1056 if (dsp_debug & DEBUG_DSP_CMX)
1057 printk(KERN_DEBUG "removing us from conference %d\n",
1058 dsp->conf->id);
1059 /* remove us from conf */
1060 conf = dsp->conf;
1061 err = dsp_cmx_del_conf_member(dsp);
1062 if (err)
1063 return err;
1064 dsp->conf_id = 0;
1065
1066 /* update hardware */
1067 dsp_cmx_hardware(NULL, dsp);
1068
1069 /* conf now empty? */
1070 if (list_empty(&conf->mlist)) {
1071 if (dsp_debug & DEBUG_DSP_CMX)
1072 printk(KERN_DEBUG
1073 "conference is empty, so we remove it.\n");
1074 err = dsp_cmx_del_conf(conf);
1075 if (err)
1076 return err;
1077 } else {
1078 /* update members left on conf */
1079 dsp_cmx_hardware(conf, NULL);
1080 }
1081 }
1082
1083 /* if split */
1084 if (!conf_id)
1085 return 0;
1086
1087 /* now add us to conf */
1088 if (dsp_debug & DEBUG_DSP_CMX)
1089 printk(KERN_DEBUG "searching conference %d\n",
1090 conf_id);
1091 conf = dsp_cmx_search_conf(conf_id);
1092 if (!conf) {
1093 if (dsp_debug & DEBUG_DSP_CMX)
1094 printk(KERN_DEBUG
1095 "conference doesn't exist yet, creating.\n");
1096 /* the conference doesn't exist, so we create */
1097 conf = dsp_cmx_new_conf(conf_id);
1098 if (!conf)
1099 return -EINVAL;
1100 } else if (!list_empty(&conf->mlist)) {
1101 member = list_entry(conf->mlist.next, struct dsp_conf_member,
1102 list);
1103 if (dsp->hdlc && !member->dsp->hdlc) {
1104 if (dsp_debug & DEBUG_DSP_CMX)
1105 printk(KERN_DEBUG
1106 "cannot join transparent conference.\n");
1107 return -EINVAL;
1108 }
1109 if (!dsp->hdlc && member->dsp->hdlc) {
1110 if (dsp_debug & DEBUG_DSP_CMX)
1111 printk(KERN_DEBUG
1112 "cannot join hdlc conference.\n");
1113 return -EINVAL;
1114 }
1115 }
1116 /* add conference member */
1117 err = dsp_cmx_add_conf_member(dsp, conf);
1118 if (err)
1119 return err;
1120 dsp->conf_id = conf_id;
1121
1122 /* if we are alone, we do nothing! */
1123 if (list_empty(&conf->mlist)) {
1124 if (dsp_debug & DEBUG_DSP_CMX)
1125 printk(KERN_DEBUG
1126 "we are alone in this conference, so exit.\n");
1127 /* update hardware */
1128 dsp_cmx_hardware(NULL, dsp);
1129 return 0;
1130 }
1131
1132 /* update members on conf */
1133 dsp_cmx_hardware(conf, NULL);
1134
1135 return 0;
1136}
1137
1138
1139/*
1140 * audio data is received from card
1141 */
1142void
1143dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb)
1144{
1145 u8 *d, *p;
1146 int len = skb->len;
1147 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1148 int w, i, ii;
1149
1150 /* check if we have sompen */
1151 if (len < 1)
1152 return;
1153
1154 /* half of the buffer should be larger than maximum packet size */
1155 if (len >= CMX_BUFF_HALF) {
1156 printk(KERN_ERR
1157 "%s line %d: packet from card is too large (%d bytes). "
1158 "please make card send smaller packets OR increase "
1159 "CMX_BUFF_SIZE\n", __FILE__, __LINE__, len);
1160 return;
1161 }
1162
1163 /*
1164 * initialize pointers if not already -
1165 * also add delay if requested by PH_SIGNAL
1166 */
1167 if (dsp->rx_init) {
1168 dsp->rx_init = 0;
1169 if (dsp->features.unordered) {
1170 dsp->rx_R = (hh->id & CMX_BUFF_MASK);
1171 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1172 & CMX_BUFF_MASK;
1173 } else {
1174 dsp->rx_R = 0;
1175 dsp->rx_W = dsp->cmx_delay;
1176 }
1177 }
1178 /* if frame contains time code, write directly */
1179 if (dsp->features.unordered) {
1180 dsp->rx_W = (hh->id & CMX_BUFF_MASK);
1181 /* printk(KERN_DEBUG "%s %08x\n", dsp->name, hh->id); */
1182 }
1183 /*
1184 * if we underrun (or maybe overrun),
1185 * we set our new read pointer, and write silence to buffer
1186 */
1187 if (((dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK) >= CMX_BUFF_HALF) {
1188 if (dsp_debug & DEBUG_DSP_CMX)
1189 printk(KERN_DEBUG
1190 "cmx_receive(dsp=%lx): UNDERRUN (or overrun the "
1191 "maximum delay), adjusting read pointer! "
1192 "(inst %s)\n", (u_long)dsp, dsp->name);
1193 /* flush buffer */
1194 if (dsp->features.unordered) {
1195 dsp->rx_R = (hh->id & CMX_BUFF_MASK);
1196 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1197 & CMX_BUFF_MASK;
1198 } else {
1199 dsp->rx_R = 0;
1200 dsp->rx_W = dsp->cmx_delay;
1201 }
1202 memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff));
1203 }
1204 /* if we have reached double delay, jump back to middle */
1205 if (dsp->cmx_delay)
1206 if (((dsp->rx_W - dsp->rx_R) & CMX_BUFF_MASK) >=
1207 (dsp->cmx_delay << 1)) {
1208 if (dsp_debug & DEBUG_DSP_CMX)
1209 printk(KERN_DEBUG
1210 "cmx_receive(dsp=%lx): OVERRUN (because "
1211 "twice the delay is reached), adjusting "
1212 "read pointer! (inst %s)\n",
1213 (u_long)dsp, dsp->name);
1214 /* flush buffer */
1215 if (dsp->features.unordered) {
1216 dsp->rx_R = (hh->id & CMX_BUFF_MASK);
1217 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1218 & CMX_BUFF_MASK;
1219 } else {
1220 dsp->rx_R = 0;
1221 dsp->rx_W = dsp->cmx_delay;
1222 }
1223 memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff));
1224 }
1225
1226 /* show where to write */
1227#ifdef CMX_DEBUG
1228 printk(KERN_DEBUG
1229 "cmx_receive(dsp=%lx): rx_R(dsp)=%05x rx_W(dsp)=%05x len=%d %s\n",
1230 (u_long)dsp, dsp->rx_R, dsp->rx_W, len, dsp->name);
1231#endif
1232
1233 /* write data into rx_buffer */
1234 p = skb->data;
1235 d = dsp->rx_buff;
1236 w = dsp->rx_W;
1237 i = 0;
1238 ii = len;
1239 while (i < ii) {
1240 d[w++ & CMX_BUFF_MASK] = *p++;
1241 i++;
1242 }
1243
1244 /* increase write-pointer */
1245 dsp->rx_W = ((dsp->rx_W+len) & CMX_BUFF_MASK);
1246}
1247
1248
1249/*
1250 * send (mixed) audio data to card and control jitter
1251 */
1252static void
1253dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
1254{
1255 struct dsp_conf *conf = dsp->conf;
1256 struct dsp *member, *other;
1257 register s32 sample;
1258 u8 *d, *p, *q, *o_q;
1259 struct sk_buff *nskb, *txskb;
1260 int r, rr, t, tt, o_r, o_rr;
1261 int preload = 0;
1262 struct mISDNhead *hh, *thh;
1263
1264 /* don't process if: */
1265 if (!dsp->b_active) { /* if not active */
1266 dsp->last_tx = 0;
1267 return;
1268 }
1269 if (dsp->pcm_slot_tx >= 0 && /* connected to pcm slot */
1270 dsp->tx_R == dsp->tx_W && /* AND no tx-data */
1271 !(dsp->tone.tone && dsp->tone.software)) { /* AND not soft tones */
1272 dsp->last_tx = 0;
1273 return;
1274 }
1275
1276#ifdef CMX_DEBUG
1277 printk(KERN_DEBUG
1278 "SEND members=%d dsp=%s, conf=%p, rx_R=%05x rx_W=%05x\n",
1279 members, dsp->name, conf, dsp->rx_R, dsp->rx_W);
1280#endif
1281
1282 /* preload if we have delay set */
1283 if (dsp->cmx_delay && !dsp->last_tx) {
1284 preload = len;
1285 if (preload < 128)
1286 preload = 128;
1287 }
1288
1289 /* PREPARE RESULT */
1290 nskb = mI_alloc_skb(len + preload, GFP_ATOMIC);
1291 if (!nskb) {
1292 printk(KERN_ERR
1293 "FATAL ERROR in mISDN_dsp.o: cannot alloc %d bytes\n",
1294 len + preload);
1295 return;
1296 }
1297 hh = mISDN_HEAD_P(nskb);
1298 hh->prim = PH_DATA_REQ;
1299 hh->id = 0;
1300 dsp->last_tx = 1;
1301
1302 /* set pointers, indexes and stuff */
1303 member = dsp;
1304 p = dsp->tx_buff; /* transmit data */
1305 q = dsp->rx_buff; /* received data */
1306 d = skb_put(nskb, preload + len); /* result */
1307 t = dsp->tx_R; /* tx-pointers */
1308 tt = dsp->tx_W;
1309 r = dsp->rx_R; /* rx-pointers */
1310 rr = (r + len) & CMX_BUFF_MASK;
1311
1312 /* preload with silence, if required */
1313 if (preload) {
1314 memset(d, dsp_silence, preload);
1315 d += preload;
1316 }
1317
1318 /* PROCESS TONES/TX-DATA ONLY */
1319 if (dsp->tone.tone && dsp->tone.software) {
1320 /* -> copy tone */
1321 dsp_tone_copy(dsp, d, len);
1322 dsp->tx_R = 0; /* clear tx buffer */
1323 dsp->tx_W = 0;
1324 goto send_packet;
1325 }
1326 /* if we have tx-data but do not use mixing */
1327 if (!dsp->tx_mix && t != tt) {
1328 /* -> send tx-data and continue when not enough */
1329#ifdef CMX_TX_DEBUG
1330 sprintf(debugbuf, "TX sending (%04x-%04x)%p: ", t, tt, p);
1331#endif
1332 while (r != rr && t != tt) {
1333#ifdef CMX_TX_DEBUG
1334 if (strlen(debugbuf) < 48)
1335 sprintf(debugbuf+strlen(debugbuf), " %02x", p[t]);
1336#endif
1337 *d++ = p[t]; /* write tx_buff */
1338 t = (t+1) & CMX_BUFF_MASK;
1339 r = (r+1) & CMX_BUFF_MASK;
1340 }
1341 if (r == rr) {
1342 dsp->tx_R = t;
1343#ifdef CMX_TX_DEBUG
1344 printk(KERN_DEBUG "%s\n", debugbuf);
1345#endif
1346 goto send_packet;
1347 }
1348 }
1349#ifdef CMX_TX_DEBUG
1350 printk(KERN_DEBUG "%s\n", debugbuf);
1351#endif
1352
1353 /* PROCESS DATA (one member / no conf) */
1354 if (!conf || members <= 1) {
1355 /* -> if echo is NOT enabled */
1356 if (!dsp->echo) {
1357 /* -> send tx-data if available or use 0-volume */
1358 while (r != rr && t != tt) {
1359 *d++ = p[t]; /* write tx_buff */
1360 t = (t+1) & CMX_BUFF_MASK;
1361 r = (r+1) & CMX_BUFF_MASK;
1362 }
1363 if (r != rr)
1364 memset(d, dsp_silence, (rr-r)&CMX_BUFF_MASK);
1365 /* -> if echo is enabled */
1366 } else {
1367 /*
1368 * -> mix tx-data with echo if available,
1369 * or use echo only
1370 */
1371 while (r != rr && t != tt) {
1372 *d++ = dsp_audio_mix_law[(p[t]<<8)|q[r]];
1373 t = (t+1) & CMX_BUFF_MASK;
1374 r = (r+1) & CMX_BUFF_MASK;
1375 }
1376 while (r != rr) {
1377 *d++ = q[r]; /* echo */
1378 r = (r+1) & CMX_BUFF_MASK;
1379 }
1380 }
1381 dsp->tx_R = t;
1382 goto send_packet;
1383 }
1384 /* PROCESS DATA (two members) */
1385#ifdef CMX_CONF_DEBUG
1386 if (0) {
1387#else
1388 if (members == 2) {
1389#endif
1390 /* "other" becomes other party */
1391 other = (list_entry(conf->mlist.next,
1392 struct dsp_conf_member, list))->dsp;
1393 if (other == member)
1394 other = (list_entry(conf->mlist.prev,
1395 struct dsp_conf_member, list))->dsp;
1396 o_q = other->rx_buff; /* received data */
1397 o_rr = (other->rx_R + len) & CMX_BUFF_MASK;
1398 /* end of rx-pointer */
1399 o_r = (o_rr - rr + r) & CMX_BUFF_MASK;
1400 /* start rx-pointer at current read position*/
1401 /* -> if echo is NOT enabled */
1402 if (!dsp->echo) {
1403 /*
1404 * -> copy other member's rx-data,
1405 * if tx-data is available, mix
1406 */
1407 while (o_r != o_rr && t != tt) {
1408 *d++ = dsp_audio_mix_law[(p[t]<<8)|o_q[o_r]];
1409 t = (t+1) & CMX_BUFF_MASK;
1410 o_r = (o_r+1) & CMX_BUFF_MASK;
1411 }
1412 while (o_r != o_rr) {
1413 *d++ = o_q[o_r];
1414 o_r = (o_r+1) & CMX_BUFF_MASK;
1415 }
1416 /* -> if echo is enabled */
1417 } else {
1418 /*
1419 * -> mix other member's rx-data with echo,
1420 * if tx-data is available, mix
1421 */
1422 while (r != rr && t != tt) {
1423 sample = dsp_audio_law_to_s32[p[t]] +
1424 dsp_audio_law_to_s32[q[r]] +
1425 dsp_audio_law_to_s32[o_q[o_r]];
1426 if (sample < -32768)
1427 sample = -32768;
1428 else if (sample > 32767)
1429 sample = 32767;
1430 *d++ = dsp_audio_s16_to_law[sample & 0xffff];
1431 /* tx-data + rx_data + echo */
1432 t = (t+1) & CMX_BUFF_MASK;
1433 r = (r+1) & CMX_BUFF_MASK;
1434 o_r = (o_r+1) & CMX_BUFF_MASK;
1435 }
1436 while (r != rr) {
1437 *d++ = dsp_audio_mix_law[(q[r]<<8)|o_q[o_r]];
1438 r = (r+1) & CMX_BUFF_MASK;
1439 o_r = (o_r+1) & CMX_BUFF_MASK;
1440 }
1441 }
1442 dsp->tx_R = t;
1443 goto send_packet;
1444 }
1445#ifdef DSP_NEVER_DEFINED
1446 }
1447#endif
1448 /* PROCESS DATA (three or more members) */
1449 /* -> if echo is NOT enabled */
1450 if (!dsp->echo) {
1451 /*
1452 * -> substract rx-data from conf-data,
1453 * if tx-data is available, mix
1454 */
1455 while (r != rr && t != tt) {
1456 sample = dsp_audio_law_to_s32[p[t]] + *c++ -
1457 dsp_audio_law_to_s32[q[r]];
1458 if (sample < -32768)
1459 sample = -32768;
1460 else if (sample > 32767)
1461 sample = 32767;
1462 *d++ = dsp_audio_s16_to_law[sample & 0xffff];
1463 /* conf-rx+tx */
1464 r = (r+1) & CMX_BUFF_MASK;
1465 t = (t+1) & CMX_BUFF_MASK;
1466 }
1467 while (r != rr) {
1468 sample = *c++ - dsp_audio_law_to_s32[q[r]];
1469 if (sample < -32768)
1470 sample = -32768;
1471 else if (sample > 32767)
1472 sample = 32767;
1473 *d++ = dsp_audio_s16_to_law[sample & 0xffff];
1474 /* conf-rx */
1475 r = (r+1) & CMX_BUFF_MASK;
1476 }
1477 /* -> if echo is enabled */
1478 } else {
1479 /*
1480 * -> encode conf-data, if tx-data
1481 * is available, mix
1482 */
1483 while (r != rr && t != tt) {
1484 sample = dsp_audio_law_to_s32[p[t]] + *c++;
1485 if (sample < -32768)
1486 sample = -32768;
1487 else if (sample > 32767)
1488 sample = 32767;
1489 *d++ = dsp_audio_s16_to_law[sample & 0xffff];
1490 /* conf(echo)+tx */
1491 t = (t+1) & CMX_BUFF_MASK;
1492 r = (r+1) & CMX_BUFF_MASK;
1493 }
1494 while (r != rr) {
1495 sample = *c++;
1496 if (sample < -32768)
1497 sample = -32768;
1498 else if (sample > 32767)
1499 sample = 32767;
1500 *d++ = dsp_audio_s16_to_law[sample & 0xffff];
1501 /* conf(echo) */
1502 r = (r+1) & CMX_BUFF_MASK;
1503 }
1504 }
1505 dsp->tx_R = t;
1506 goto send_packet;
1507
1508send_packet:
1509 /*
1510 * send tx-data if enabled - don't filter,
1511 * becuase we want what we send, not what we filtered
1512 */
1513 if (dsp->tx_data) {
1514 /* PREPARE RESULT */
1515 txskb = mI_alloc_skb(len, GFP_ATOMIC);
1516 if (!txskb) {
1517 printk(KERN_ERR
1518 "FATAL ERROR in mISDN_dsp.o: "
1519 "cannot alloc %d bytes\n", len);
1520 } else {
1521 thh = mISDN_HEAD_P(txskb);
1522 thh->prim = DL_DATA_REQ;
1523 thh->id = 0;
1524 memcpy(skb_put(txskb, len), nskb->data+preload, len);
1525 /* queue (trigger later) */
1526 skb_queue_tail(&dsp->sendq, txskb);
1527 }
1528 }
1529 /* adjust volume */
1530 if (dsp->tx_volume)
1531 dsp_change_volume(nskb, dsp->tx_volume);
1532 /* pipeline */
1533 if (dsp->pipeline.inuse)
1534 dsp_pipeline_process_tx(&dsp->pipeline, nskb->data, nskb->len);
1535 /* crypt */
1536 if (dsp->bf_enable)
1537 dsp_bf_encrypt(dsp, nskb->data, nskb->len);
1538 /* queue and trigger */
1539 skb_queue_tail(&dsp->sendq, nskb);
1540 schedule_work(&dsp->workq);
1541}
1542
1543u32 samplecount;
1544struct timer_list dsp_spl_tl;
1545u32 dsp_spl_jiffies; /* calculate the next time to fire */
1546u32 dsp_start_jiffies; /* jiffies at the time, the calculation begins */
1547struct timeval dsp_start_tv; /* time at start of calculation */
1548
1549void
1550dsp_cmx_send(void *arg)
1551{
1552 struct dsp_conf *conf;
1553 struct dsp_conf_member *member;
1554 struct dsp *dsp;
1555 int mustmix, members;
1556 s32 mixbuffer[MAX_POLL+100], *c;
1557 u8 *p, *q;
1558 int r, rr;
1559 int jittercheck = 0, delay, i;
1560 u_long flags;
1561 struct timeval tv;
1562 u32 elapsed;
1563 s16 length;
1564
1565 /* lock */
1566 spin_lock_irqsave(&dsp_lock, flags);
1567
1568 if (!dsp_start_tv.tv_sec) {
1569 do_gettimeofday(&dsp_start_tv);
1570 length = dsp_poll;
1571 } else {
1572 do_gettimeofday(&tv);
1573 elapsed = ((tv.tv_sec - dsp_start_tv.tv_sec) * 8000)
1574 + ((s32)(tv.tv_usec / 125) - (dsp_start_tv.tv_usec / 125));
1575 dsp_start_tv.tv_sec = tv.tv_sec;
1576 dsp_start_tv.tv_usec = tv.tv_usec;
1577 length = elapsed;
1578 }
1579 if (length > MAX_POLL + 100)
1580 length = MAX_POLL + 100;
1581/* printk(KERN_DEBUG "len=%d dsp_count=0x%x.%04x dsp_poll_diff=0x%x.%04x\n",
1582 length, dsp_count >> 16, dsp_count & 0xffff, dsp_poll_diff >> 16,
1583 dsp_poll_diff & 0xffff);
1584 */
1585
1586 /*
1587 * check if jitter needs to be checked
1588 * (this is about every second = 8192 samples)
1589 */
1590 samplecount += length;
1591 if ((samplecount & 8191) < length)
1592 jittercheck = 1;
1593
1594 /* loop all members that do not require conference mixing */
1595 list_for_each_entry(dsp, &dsp_ilist, list) {
1596 if (dsp->hdlc)
1597 continue;
1598 conf = dsp->conf;
1599 mustmix = 0;
1600 members = 0;
1601 if (conf) {
1602 members = count_list_member(&conf->mlist);
1603#ifdef CMX_CONF_DEBUG
1604 if (conf->software && members > 1)
1605#else
1606 if (conf->software && members > 2)
1607#endif
1608 mustmix = 1;
1609 }
1610
1611 /* transmission required */
1612 if (!mustmix) {
1613 dsp_cmx_send_member(dsp, length, mixbuffer, members);
1614
1615 /*
1616 * unused mixbuffer is given to prevent a
1617 * potential null-pointer-bug
1618 */
1619 }
1620 }
1621
1622 /* loop all members that require conference mixing */
1623 list_for_each_entry(conf, &conf_ilist, list) {
1624 /* count members and check hardware */
1625 members = count_list_member(&conf->mlist);
1626#ifdef CMX_CONF_DEBUG
1627 if (conf->software && members > 1) {
1628#else
1629 if (conf->software && members > 2) {
1630#endif
1631 /* check for hdlc conf */
1632 member = list_entry(conf->mlist.next,
1633 struct dsp_conf_member, list);
1634 if (member->dsp->hdlc)
1635 continue;
1636 /* mix all data */
1637 memset(mixbuffer, 0, length*sizeof(s32));
1638 list_for_each_entry(member, &conf->mlist, list) {
1639 dsp = member->dsp;
1640 /* get range of data to mix */
1641 c = mixbuffer;
1642 q = dsp->rx_buff;
1643 r = dsp->rx_R;
1644 rr = (r + length) & CMX_BUFF_MASK;
1645 /* add member's data */
1646 while (r != rr) {
1647 *c++ += dsp_audio_law_to_s32[q[r]];
1648 r = (r+1) & CMX_BUFF_MASK;
1649 }
1650 }
1651
1652 /* process each member */
1653 list_for_each_entry(member, &conf->mlist, list) {
1654 /* transmission */
1655 dsp_cmx_send_member(member->dsp, length,
1656 mixbuffer, members);
1657 }
1658 }
1659 }
1660
1661 /* delete rx-data, increment buffers, change pointers */
1662 list_for_each_entry(dsp, &dsp_ilist, list) {
1663 if (dsp->hdlc)
1664 continue;
1665 p = dsp->rx_buff;
1666 q = dsp->tx_buff;
1667 r = dsp->rx_R;
1668 /* move receive pointer when receiving */
1669 if (!dsp->rx_is_off) {
1670 rr = (r + length) & CMX_BUFF_MASK;
1671 /* delete rx-data */
1672 while (r != rr) {
1673 p[r] = dsp_silence;
1674 r = (r+1) & CMX_BUFF_MASK;
1675 }
1676 /* increment rx-buffer pointer */
1677 dsp->rx_R = r; /* write incremented read pointer */
1678 }
1679
1680 /* check current rx_delay */
1681 delay = (dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK;
1682 if (delay >= CMX_BUFF_HALF)
1683 delay = 0; /* will be the delay before next write */
1684 /* check for lower delay */
1685 if (delay < dsp->rx_delay[0])
1686 dsp->rx_delay[0] = delay;
1687 /* check current tx_delay */
1688 delay = (dsp->tx_W-dsp->tx_R) & CMX_BUFF_MASK;
1689 if (delay >= CMX_BUFF_HALF)
1690 delay = 0; /* will be the delay before next write */
1691 /* check for lower delay */
1692 if (delay < dsp->tx_delay[0])
1693 dsp->tx_delay[0] = delay;
1694 if (jittercheck) {
1695 /* find the lowest of all rx_delays */
1696 delay = dsp->rx_delay[0];
1697 i = 1;
1698 while (i < MAX_SECONDS_JITTER_CHECK) {
1699 if (delay > dsp->rx_delay[i])
1700 delay = dsp->rx_delay[i];
1701 i++;
1702 }
1703 /*
1704 * remove rx_delay only if we have delay AND we
1705 * have not preset cmx_delay
1706 */
1707 if (delay && !dsp->cmx_delay) {
1708 if (dsp_debug & DEBUG_DSP_CMX)
1709 printk(KERN_DEBUG
1710 "%s lowest rx_delay of %d bytes for"
1711 " dsp %s are now removed.\n",
1712 __func__, delay,
1713 dsp->name);
1714 r = dsp->rx_R;
1715 rr = (r + delay) & CMX_BUFF_MASK;
1716 /* delete rx-data */
1717 while (r != rr) {
1718 p[r] = dsp_silence;
1719 r = (r+1) & CMX_BUFF_MASK;
1720 }
1721 /* increment rx-buffer pointer */
1722 dsp->rx_R = r;
1723 /* write incremented read pointer */
1724 }
1725 /* find the lowest of all tx_delays */
1726 delay = dsp->tx_delay[0];
1727 i = 1;
1728 while (i < MAX_SECONDS_JITTER_CHECK) {
1729 if (delay > dsp->tx_delay[i])
1730 delay = dsp->tx_delay[i];
1731 i++;
1732 }
1733 /*
1734 * remove delay only if we have delay AND we
1735 * have enabled tx_dejitter
1736 */
1737 if (delay && dsp->tx_dejitter) {
1738 if (dsp_debug & DEBUG_DSP_CMX)
1739 printk(KERN_DEBUG
1740 "%s lowest tx_delay of %d bytes for"
1741 " dsp %s are now removed.\n",
1742 __func__, delay,
1743 dsp->name);
1744 r = dsp->tx_R;
1745 rr = (r + delay) & CMX_BUFF_MASK;
1746 /* delete tx-data */
1747 while (r != rr) {
1748 q[r] = dsp_silence;
1749 r = (r+1) & CMX_BUFF_MASK;
1750 }
1751 /* increment rx-buffer pointer */
1752 dsp->tx_R = r;
1753 /* write incremented read pointer */
1754 }
1755 /* scroll up delays */
1756 i = MAX_SECONDS_JITTER_CHECK - 1;
1757 while (i) {
1758 dsp->rx_delay[i] = dsp->rx_delay[i-1];
1759 dsp->tx_delay[i] = dsp->tx_delay[i-1];
1760 i--;
1761 }
1762 dsp->tx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */
1763 dsp->rx_delay[0] = CMX_BUFF_HALF; /* (infinite) delay */
1764 }
1765 }
1766
1767 /* if next event would be in the past ... */
1768 if ((s32)(dsp_spl_jiffies+dsp_tics-jiffies) <= 0)
1769 dsp_spl_jiffies = jiffies + 1;
1770 else
1771 dsp_spl_jiffies += dsp_tics;
1772
1773 dsp_spl_tl.expires = dsp_spl_jiffies;
1774 add_timer(&dsp_spl_tl);
1775
1776 /* unlock */
1777 spin_unlock_irqrestore(&dsp_lock, flags);
1778}
1779
1780/*
1781 * audio data is transmitted from upper layer to the dsp
1782 */
1783void
1784dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb)
1785{
1786 u_int w, ww;
1787 u8 *d, *p;
1788 int space; /* todo: , l = skb->len; */
1789#ifdef CMX_TX_DEBUG
1790 char debugbuf[256] = "";
1791#endif
1792
1793 /* check if there is enough space, and then copy */
1794 w = dsp->tx_W;
1795 ww = dsp->tx_R;
1796 p = dsp->tx_buff;
1797 d = skb->data;
1798 space = ww-w;
1799 if (space <= 0)
1800 space += CMX_BUFF_SIZE;
1801 /* write-pointer should not overrun nor reach read pointer */
1802 if (space-1 < skb->len)
1803 /* write to the space we have left */
1804 ww = (ww - 1) & CMX_BUFF_MASK;
1805 else
1806 /* write until all byte are copied */
1807 ww = (w + skb->len) & CMX_BUFF_MASK;
1808 dsp->tx_W = ww;
1809
1810 /* show current buffer */
1811#ifdef CMX_DEBUG
1812 printk(KERN_DEBUG
1813 "cmx_transmit(dsp=%lx) %d bytes to 0x%x-0x%x. %s\n",
1814 (u_long)dsp, (ww-w)&CMX_BUFF_MASK, w, ww, dsp->name);
1815#endif
1816
1817 /* copy transmit data to tx-buffer */
1818#ifdef CMX_TX_DEBUG
1819 sprintf(debugbuf, "TX getting (%04x-%04x)%p: ", w, ww, p);
1820#endif
1821 while (w != ww) {
1822#ifdef CMX_TX_DEBUG
1823 if (strlen(debugbuf) < 48)
1824 sprintf(debugbuf+strlen(debugbuf), " %02x", *d);
1825#endif
1826 p[w] = *d++;
1827 w = (w+1) & CMX_BUFF_MASK;
1828 }
1829#ifdef CMX_TX_DEBUG
1830 printk(KERN_DEBUG "%s\n", debugbuf);
1831#endif
1832
1833}
1834
1835/*
1836 * hdlc data is received from card and sent to all members.
1837 */
1838void
1839dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1840{
1841 struct sk_buff *nskb = NULL;
1842 struct dsp_conf_member *member;
1843 struct mISDNhead *hh;
1844
1845 /* not if not active */
1846 if (!dsp->b_active)
1847 return;
1848
1849 /* check if we have sompen */
1850 if (skb->len < 1)
1851 return;
1852
1853 /* no conf */
1854 if (!dsp->conf) {
1855 /* in case of hardware (echo) */
1856 if (dsp->pcm_slot_tx >= 0)
1857 return;
1858 if (dsp->echo)
1859 nskb = skb_clone(skb, GFP_ATOMIC);
1860 if (nskb) {
1861 hh = mISDN_HEAD_P(nskb);
1862 hh->prim = PH_DATA_REQ;
1863 hh->id = 0;
1864 skb_queue_tail(&dsp->sendq, nskb);
1865 schedule_work(&dsp->workq);
1866 }
1867 return;
1868 }
1869 /* in case of hardware conference */
1870 if (dsp->conf->hardware)
1871 return;
1872 list_for_each_entry(member, &dsp->conf->mlist, list) {
1873 if (dsp->echo || member->dsp != dsp) {
1874 nskb = skb_clone(skb, GFP_ATOMIC);
1875 if (nskb) {
1876 hh = mISDN_HEAD_P(nskb);
1877 hh->prim = PH_DATA_REQ;
1878 hh->id = 0;
1879 skb_queue_tail(&member->dsp->sendq, nskb);
1880 schedule_work(&member->dsp->workq);
1881 }
1882 }
1883 }
1884}
1885
1886
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
new file mode 100644
index 000000000000..2f10ed82c0db
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -0,0 +1,1191 @@
1/*
2 * Author Andreas Eversberg (jolly@eversberg.eu)
3 * Based on source code structure by
4 * Karsten Keil (keil@isdn4linux.de)
5 *
6 * This file is (c) under GNU PUBLIC LICENSE
7 * For changes and modifications please read
8 * ../../../Documentation/isdn/mISDN.cert
9 *
10 * Thanks to Karsten Keil (great drivers)
11 * Cologne Chip (great chips)
12 *
13 * This module does:
14 * Real-time tone generation
15 * DTMF detection
16 * Real-time cross-connection and conferrence
17 * Compensate jitter due to system load and hardware fault.
18 * All features are done in kernel space and will be realized
19 * using hardware, if available and supported by chip set.
20 * Blowfish encryption/decryption
21 */
22
23/* STRUCTURE:
24 *
25 * The dsp module provides layer 2 for b-channels (64kbit). It provides
26 * transparent audio forwarding with special digital signal processing:
27 *
28 * - (1) generation of tones
29 * - (2) detection of dtmf tones
30 * - (3) crossconnecting and conferences (clocking)
31 * - (4) echo generation for delay test
32 * - (5) volume control
33 * - (6) disable receive data
34 * - (7) pipeline
35 * - (8) encryption/decryption
36 *
37 * Look:
38 * TX RX
39 * ------upper layer------
40 * | ^
41 * | |(6)
42 * v |
43 * +-----+-------------+-----+
44 * |(3)(4) |
45 * | CMX |
46 * | |
47 * | +-------------+
48 * | | ^
49 * | | |
50 * |+---------+| +----+----+
51 * ||(1) || |(2) |
52 * || || | |
53 * || Tones || | DTMF |
54 * || || | |
55 * || || | |
56 * |+----+----+| +----+----+
57 * +-----+-----+ ^
58 * | |
59 * v |
60 * +----+----+ +----+----+
61 * |(5) | |(5) |
62 * | | | |
63 * |TX Volume| |RX Volume|
64 * | | | |
65 * | | | |
66 * +----+----+ +----+----+
67 * | ^
68 * | |
69 * v |
70 * +----+-------------+----+
71 * |(7) |
72 * | |
73 * | Pipeline Processing |
74 * | |
75 * | |
76 * +----+-------------+----+
77 * | ^
78 * | |
79 * v |
80 * +----+----+ +----+----+
81 * |(8) | |(8) |
82 * | | | |
83 * | Encrypt | | Decrypt |
84 * | | | |
85 * | | | |
86 * +----+----+ +----+----+
87 * | ^
88 * | |
89 * v |
90 * ------card layer------
91 * TX RX
92 *
93 * Above you can see the logical data flow. If software is used to do the
94 * process, it is actually the real data flow. If hardware is used, data
95 * may not flow, but hardware commands to the card, to provide the data flow
96 * as shown.
97 *
98 * NOTE: The channel must be activated in order to make dsp work, even if
99 * no data flow to the upper layer is intended. Activation can be done
100 * after and before controlling the setting using PH_CONTROL requests.
101 *
102 * DTMF: Will be detected by hardware if possible. It is done before CMX
103 * processing.
104 *
105 * Tones: Will be generated via software if endless looped audio fifos are
106 * not supported by hardware. Tones will override all data from CMX.
107 * It is not required to join a conference to use tones at any time.
108 *
109 * CMX: Is transparent when not used. When it is used, it will do
110 * crossconnections and conferences via software if not possible through
111 * hardware. If hardware capability is available, hardware is used.
112 *
113 * Echo: Is generated by CMX and is used to check performane of hard and
114 * software CMX.
115 *
116 * The CMX has special functions for conferences with one, two and more
117 * members. It will allow different types of data flow. Receive and transmit
118 * data to/form upper layer may be swithed on/off individually without loosing
119 * features of CMX, Tones and DTMF.
120 *
121 * Echo Cancellation: Sometimes we like to cancel echo from the interface.
122 * Note that a VoIP call may not have echo caused by the IP phone. The echo
123 * is generated by the telephone line connected to it. Because the delay
124 * is high, it becomes an echo. RESULT: Echo Cachelation is required if
125 * both echo AND delay is applied to an interface.
126 * Remember that software CMX always generates a more or less delay.
127 *
128 * If all used features can be realized in hardware, and if transmit and/or
129 * receive data ist disabled, the card may not send/receive any data at all.
130 * Not receiving is usefull if only announcements are played. Not sending is
131 * usefull if an answering machine records audio. Not sending and receiving is
132 * usefull during most states of the call. If supported by hardware, tones
133 * will be played without cpu load. Small PBXs and NT-Mode applications will
134 * not need expensive hardware when processing calls.
135 *
136 *
137 * LOCKING:
138 *
139 * When data is received from upper or lower layer (card), the complete dsp
140 * module is locked by a global lock. This lock MUST lock irq, because it
141 * must lock timer events by DSP poll timer.
142 * When data is ready to be transmitted down, the data is queued and sent
143 * outside lock and timer event.
144 * PH_CONTROL must not change any settings, join or split conference members
145 * during process of data.
146 *
147 * HDLC:
148 *
149 * It works quite the same as transparent, except that HDLC data is forwarded
150 * to all other conference members if no hardware bridging is possible.
151 * Send data will be writte to sendq. Sendq will be sent if confirm is received.
152 * Conference cannot join, if one member is not hdlc.
153 *
154 */
155
156#include <linux/delay.h>
157#include <linux/mISDNif.h>
158#include <linux/mISDNdsp.h>
159#include <linux/module.h>
160#include <linux/vmalloc.h>
161#include "core.h"
162#include "dsp.h"
163
164const char *mISDN_dsp_revision = "2.0";
165
166static int debug;
167static int options;
168static int poll;
169static int dtmfthreshold = 100;
170
171MODULE_AUTHOR("Andreas Eversberg");
172module_param(debug, uint, S_IRUGO | S_IWUSR);
173module_param(options, uint, S_IRUGO | S_IWUSR);
174module_param(poll, uint, S_IRUGO | S_IWUSR);
175module_param(dtmfthreshold, uint, S_IRUGO | S_IWUSR);
176MODULE_LICENSE("GPL");
177
178/*int spinnest = 0;*/
179
180spinlock_t dsp_lock; /* global dsp lock */
181struct list_head dsp_ilist;
182struct list_head conf_ilist;
183int dsp_debug;
184int dsp_options;
185int dsp_poll, dsp_tics;
186
187/* check if rx may be turned off or must be turned on */
188static void
189dsp_rx_off_member(struct dsp *dsp)
190{
191 struct mISDN_ctrl_req cq;
192 int rx_off = 1;
193
194 if (!dsp->features_rx_off)
195 return;
196
197 /* not disabled */
198 if (!dsp->rx_disabled)
199 rx_off = 0;
200 /* software dtmf */
201 else if (dsp->dtmf.software)
202 rx_off = 0;
203 /* echo in software */
204 else if (dsp->echo && dsp->pcm_slot_tx < 0)
205 rx_off = 0;
206 /* bridge in software */
207 else if (dsp->conf) {
208 if (dsp->conf->software)
209 rx_off = 0;
210 }
211
212 if (rx_off == dsp->rx_is_off)
213 return;
214
215 if (!dsp->ch.peer) {
216 if (dsp_debug & DEBUG_DSP_CORE)
217 printk(KERN_DEBUG "%s: no peer, no rx_off\n",
218 __func__);
219 return;
220 }
221 cq.op = MISDN_CTRL_RX_OFF;
222 cq.p1 = rx_off;
223 if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) {
224 printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n",
225 __func__);
226 return;
227 }
228 dsp->rx_is_off = rx_off;
229 if (dsp_debug & DEBUG_DSP_CORE)
230 printk(KERN_DEBUG "%s: %s set rx_off = %d\n",
231 __func__, dsp->name, rx_off);
232}
233static void
234dsp_rx_off(struct dsp *dsp)
235{
236 struct dsp_conf_member *member;
237
238 if (dsp_options & DSP_OPT_NOHARDWARE)
239 return;
240
241 /* no conf */
242 if (!dsp->conf) {
243 dsp_rx_off_member(dsp);
244 return;
245 }
246 /* check all members in conf */
247 list_for_each_entry(member, &dsp->conf->mlist, list) {
248 dsp_rx_off_member(member->dsp);
249 }
250}
251
252static int
253dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
254{
255 struct sk_buff *nskb;
256 int ret = 0;
257 int cont;
258 u8 *data;
259 int len;
260
261 if (skb->len < sizeof(int))
262 printk(KERN_ERR "%s: PH_CONTROL message too short\n", __func__);
263 cont = *((int *)skb->data);
264 len = skb->len - sizeof(int);
265 data = skb->data + sizeof(int);
266
267 switch (cont) {
268 case DTMF_TONE_START: /* turn on DTMF */
269 if (dsp->hdlc) {
270 ret = -EINVAL;
271 break;
272 }
273 if (dsp_debug & DEBUG_DSP_CORE)
274 printk(KERN_DEBUG "%s: start dtmf\n", __func__);
275 if (len == sizeof(int)) {
276 printk(KERN_NOTICE "changing DTMF Threshold "
277 "to %d\n", *((int *)data));
278 dsp->dtmf.treshold = (*(int *)data) * 10000;
279 }
280 /* init goertzel */
281 dsp_dtmf_goertzel_init(dsp);
282
283 /* check dtmf hardware */
284 dsp_dtmf_hardware(dsp);
285 break;
286 case DTMF_TONE_STOP: /* turn off DTMF */
287 if (dsp_debug & DEBUG_DSP_CORE)
288 printk(KERN_DEBUG "%s: stop dtmf\n", __func__);
289 dsp->dtmf.hardware = 0;
290 dsp->dtmf.software = 0;
291 break;
292 case DSP_CONF_JOIN: /* join / update conference */
293 if (len < sizeof(int)) {
294 ret = -EINVAL;
295 break;
296 }
297 if (*((u32 *)data) == 0)
298 goto conf_split;
299 if (dsp_debug & DEBUG_DSP_CORE)
300 printk(KERN_DEBUG "%s: join conference %d\n",
301 __func__, *((u32 *)data));
302 ret = dsp_cmx_conf(dsp, *((u32 *)data));
303 /* dsp_cmx_hardware will also be called here */
304 dsp_rx_off(dsp);
305 if (dsp_debug & DEBUG_DSP_CMX)
306 dsp_cmx_debug(dsp);
307 break;
308 case DSP_CONF_SPLIT: /* remove from conference */
309conf_split:
310 if (dsp_debug & DEBUG_DSP_CORE)
311 printk(KERN_DEBUG "%s: release conference\n", __func__);
312 ret = dsp_cmx_conf(dsp, 0);
313 /* dsp_cmx_hardware will also be called here */
314 if (dsp_debug & DEBUG_DSP_CMX)
315 dsp_cmx_debug(dsp);
316 dsp_rx_off(dsp);
317 break;
318 case DSP_TONE_PATT_ON: /* play tone */
319 if (dsp->hdlc) {
320 ret = -EINVAL;
321 break;
322 }
323 if (len < sizeof(int)) {
324 ret = -EINVAL;
325 break;
326 }
327 if (dsp_debug & DEBUG_DSP_CORE)
328 printk(KERN_DEBUG "%s: turn tone 0x%x on\n",
329 __func__, *((int *)skb->data));
330 ret = dsp_tone(dsp, *((int *)data));
331 if (!ret) {
332 dsp_cmx_hardware(dsp->conf, dsp);
333 dsp_rx_off(dsp);
334 }
335 if (!dsp->tone.tone)
336 goto tone_off;
337 break;
338 case DSP_TONE_PATT_OFF: /* stop tone */
339 if (dsp->hdlc) {
340 ret = -EINVAL;
341 break;
342 }
343 if (dsp_debug & DEBUG_DSP_CORE)
344 printk(KERN_DEBUG "%s: turn tone off\n", __func__);
345 dsp_tone(dsp, 0);
346 dsp_cmx_hardware(dsp->conf, dsp);
347 dsp_rx_off(dsp);
348 /* reset tx buffers (user space data) */
349tone_off:
350 dsp->rx_W = 0;
351 dsp->rx_R = 0;
352 break;
353 case DSP_VOL_CHANGE_TX: /* change volume */
354 if (dsp->hdlc) {
355 ret = -EINVAL;
356 break;
357 }
358 if (len < sizeof(int)) {
359 ret = -EINVAL;
360 break;
361 }
362 dsp->tx_volume = *((int *)data);
363 if (dsp_debug & DEBUG_DSP_CORE)
364 printk(KERN_DEBUG "%s: change tx vol to %d\n",
365 __func__, dsp->tx_volume);
366 dsp_cmx_hardware(dsp->conf, dsp);
367 dsp_dtmf_hardware(dsp);
368 dsp_rx_off(dsp);
369 break;
370 case DSP_VOL_CHANGE_RX: /* change volume */
371 if (dsp->hdlc) {
372 ret = -EINVAL;
373 break;
374 }
375 if (len < sizeof(int)) {
376 ret = -EINVAL;
377 break;
378 }
379 dsp->rx_volume = *((int *)data);
380 if (dsp_debug & DEBUG_DSP_CORE)
381 printk(KERN_DEBUG "%s: change rx vol to %d\n",
382 __func__, dsp->tx_volume);
383 dsp_cmx_hardware(dsp->conf, dsp);
384 dsp_dtmf_hardware(dsp);
385 dsp_rx_off(dsp);
386 break;
387 case DSP_ECHO_ON: /* enable echo */
388 dsp->echo = 1; /* soft echo */
389 if (dsp_debug & DEBUG_DSP_CORE)
390 printk(KERN_DEBUG "%s: enable cmx-echo\n", __func__);
391 dsp_cmx_hardware(dsp->conf, dsp);
392 dsp_rx_off(dsp);
393 if (dsp_debug & DEBUG_DSP_CMX)
394 dsp_cmx_debug(dsp);
395 break;
396 case DSP_ECHO_OFF: /* disable echo */
397 dsp->echo = 0;
398 if (dsp_debug & DEBUG_DSP_CORE)
399 printk(KERN_DEBUG "%s: disable cmx-echo\n", __func__);
400 dsp_cmx_hardware(dsp->conf, dsp);
401 dsp_rx_off(dsp);
402 if (dsp_debug & DEBUG_DSP_CMX)
403 dsp_cmx_debug(dsp);
404 break;
405 case DSP_RECEIVE_ON: /* enable receive to user space */
406 if (dsp_debug & DEBUG_DSP_CORE)
407 printk(KERN_DEBUG "%s: enable receive to user "
408 "space\n", __func__);
409 dsp->rx_disabled = 0;
410 dsp_rx_off(dsp);
411 break;
412 case DSP_RECEIVE_OFF: /* disable receive to user space */
413 if (dsp_debug & DEBUG_DSP_CORE)
414 printk(KERN_DEBUG "%s: disable receive to "
415 "user space\n", __func__);
416 dsp->rx_disabled = 1;
417 dsp_rx_off(dsp);
418 break;
419 case DSP_MIX_ON: /* enable mixing of tx data */
420 if (dsp->hdlc) {
421 ret = -EINVAL;
422 break;
423 }
424 if (dsp_debug & DEBUG_DSP_CORE)
425 printk(KERN_DEBUG "%s: enable mixing of "
426 "tx-data with conf mebers\n", __func__);
427 dsp->tx_mix = 1;
428 dsp_cmx_hardware(dsp->conf, dsp);
429 dsp_rx_off(dsp);
430 if (dsp_debug & DEBUG_DSP_CMX)
431 dsp_cmx_debug(dsp);
432 break;
433 case DSP_MIX_OFF: /* disable mixing of tx data */
434 if (dsp->hdlc) {
435 ret = -EINVAL;
436 break;
437 }
438 if (dsp_debug & DEBUG_DSP_CORE)
439 printk(KERN_DEBUG "%s: disable mixing of "
440 "tx-data with conf mebers\n", __func__);
441 dsp->tx_mix = 0;
442 dsp_cmx_hardware(dsp->conf, dsp);
443 dsp_rx_off(dsp);
444 if (dsp_debug & DEBUG_DSP_CMX)
445 dsp_cmx_debug(dsp);
446 break;
447 case DSP_TXDATA_ON: /* enable txdata */
448 dsp->tx_data = 1;
449 if (dsp_debug & DEBUG_DSP_CORE)
450 printk(KERN_DEBUG "%s: enable tx-data\n", __func__);
451 dsp_cmx_hardware(dsp->conf, dsp);
452 dsp_rx_off(dsp);
453 if (dsp_debug & DEBUG_DSP_CMX)
454 dsp_cmx_debug(dsp);
455 break;
456 case DSP_TXDATA_OFF: /* disable txdata */
457 dsp->tx_data = 0;
458 if (dsp_debug & DEBUG_DSP_CORE)
459 printk(KERN_DEBUG "%s: disable tx-data\n", __func__);
460 dsp_cmx_hardware(dsp->conf, dsp);
461 dsp_rx_off(dsp);
462 if (dsp_debug & DEBUG_DSP_CMX)
463 dsp_cmx_debug(dsp);
464 break;
465 case DSP_DELAY: /* use delay algorithm instead of dynamic
466 jitter algorithm */
467 if (dsp->hdlc) {
468 ret = -EINVAL;
469 break;
470 }
471 if (len < sizeof(int)) {
472 ret = -EINVAL;
473 break;
474 }
475 dsp->cmx_delay = (*((int *)data)) << 3;
476 /* miliseconds to samples */
477 if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1))
478 /* clip to half of maximum usable buffer
479 (half of half buffer) */
480 dsp->cmx_delay = (CMX_BUFF_HALF>>1) - 1;
481 if (dsp_debug & DEBUG_DSP_CORE)
482 printk(KERN_DEBUG "%s: use delay algorithm to "
483 "compensate jitter (%d samples)\n",
484 __func__, dsp->cmx_delay);
485 break;
486 case DSP_JITTER: /* use dynamic jitter algorithm instead of
487 delay algorithm */
488 if (dsp->hdlc) {
489 ret = -EINVAL;
490 break;
491 }
492 dsp->cmx_delay = 0;
493 if (dsp_debug & DEBUG_DSP_CORE)
494 printk(KERN_DEBUG "%s: use jitter algorithm to "
495 "compensate jitter\n", __func__);
496 break;
497 case DSP_TX_DEJITTER: /* use dynamic jitter algorithm for tx-buffer */
498 if (dsp->hdlc) {
499 ret = -EINVAL;
500 break;
501 }
502 dsp->tx_dejitter = 1;
503 if (dsp_debug & DEBUG_DSP_CORE)
504 printk(KERN_DEBUG "%s: use dejitter on TX "
505 "buffer\n", __func__);
506 break;
507 case DSP_TX_DEJ_OFF: /* use tx-buffer without dejittering*/
508 if (dsp->hdlc) {
509 ret = -EINVAL;
510 break;
511 }
512 dsp->tx_dejitter = 0;
513 if (dsp_debug & DEBUG_DSP_CORE)
514 printk(KERN_DEBUG "%s: use TX buffer without "
515 "dejittering\n", __func__);
516 break;
517 case DSP_PIPELINE_CFG:
518 if (dsp->hdlc) {
519 ret = -EINVAL;
520 break;
521 }
522 if (len > 0 && ((char *)data)[len - 1]) {
523 printk(KERN_DEBUG "%s: pipeline config string "
524 "is not NULL terminated!\n", __func__);
525 ret = -EINVAL;
526 } else {
527 dsp->pipeline.inuse = 1;
528 dsp_cmx_hardware(dsp->conf, dsp);
529 ret = dsp_pipeline_build(&dsp->pipeline,
530 len > 0 ? (char *)data : NULL);
531 dsp_cmx_hardware(dsp->conf, dsp);
532 dsp_rx_off(dsp);
533 }
534 break;
535 case DSP_BF_ENABLE_KEY: /* turn blowfish on */
536 if (dsp->hdlc) {
537 ret = -EINVAL;
538 break;
539 }
540 if (len < 4 || len > 56) {
541 ret = -EINVAL;
542 break;
543 }
544 if (dsp_debug & DEBUG_DSP_CORE)
545 printk(KERN_DEBUG "%s: turn blowfish on (key "
546 "not shown)\n", __func__);
547 ret = dsp_bf_init(dsp, (u8 *)data, len);
548 /* set new cont */
549 if (!ret)
550 cont = DSP_BF_ACCEPT;
551 else
552 cont = DSP_BF_REJECT;
553 /* send indication if it worked to set it */
554 nskb = _alloc_mISDN_skb(PH_CONTROL_IND, MISDN_ID_ANY,
555 sizeof(int), &cont, GFP_ATOMIC);
556 if (nskb) {
557 if (dsp->up) {
558 if (dsp->up->send(dsp->up, nskb))
559 dev_kfree_skb(nskb);
560 } else
561 dev_kfree_skb(nskb);
562 }
563 if (!ret) {
564 dsp_cmx_hardware(dsp->conf, dsp);
565 dsp_dtmf_hardware(dsp);
566 dsp_rx_off(dsp);
567 }
568 break;
569 case DSP_BF_DISABLE: /* turn blowfish off */
570 if (dsp->hdlc) {
571 ret = -EINVAL;
572 break;
573 }
574 if (dsp_debug & DEBUG_DSP_CORE)
575 printk(KERN_DEBUG "%s: turn blowfish off\n", __func__);
576 dsp_bf_cleanup(dsp);
577 dsp_cmx_hardware(dsp->conf, dsp);
578 dsp_dtmf_hardware(dsp);
579 dsp_rx_off(dsp);
580 break;
581 default:
582 if (dsp_debug & DEBUG_DSP_CORE)
583 printk(KERN_DEBUG "%s: ctrl req %x unhandled\n",
584 __func__, cont);
585 ret = -EINVAL;
586 }
587 return ret;
588}
589
590static void
591get_features(struct mISDNchannel *ch)
592{
593 struct dsp *dsp = container_of(ch, struct dsp, ch);
594 struct mISDN_ctrl_req cq;
595
596 if (dsp_options & DSP_OPT_NOHARDWARE)
597 return;
598 if (!ch->peer) {
599 if (dsp_debug & DEBUG_DSP_CORE)
600 printk(KERN_DEBUG "%s: no peer, no features\n",
601 __func__);
602 return;
603 }
604 memset(&cq, 0, sizeof(cq));
605 cq.op = MISDN_CTRL_GETOP;
606 if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq) < 0) {
607 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
608 __func__);
609 return;
610 }
611 if (cq.op & MISDN_CTRL_RX_OFF)
612 dsp->features_rx_off = 1;
613 if ((cq.op & MISDN_CTRL_HW_FEATURES_OP)) {
614 cq.op = MISDN_CTRL_HW_FEATURES;
615 *((u_long *)&cq.p1) = (u_long)&dsp->features;
616 if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq)) {
617 printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n",
618 __func__);
619 }
620 } else
621 if (dsp_debug & DEBUG_DSP_CORE)
622 printk(KERN_DEBUG "%s: features not supported for %s\n",
623 __func__, dsp->name);
624}
625
626static int
627dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
628{
629 struct dsp *dsp = container_of(ch, struct dsp, ch);
630 struct mISDNhead *hh;
631 int ret = 0;
632 u8 *digits;
633 int cont;
634 struct sk_buff *nskb;
635 u_long flags;
636
637 hh = mISDN_HEAD_P(skb);
638 switch (hh->prim) {
639 /* FROM DOWN */
640 case (PH_DATA_CNF):
641 dsp->data_pending = 0;
642 /* trigger next hdlc frame, if any */
643 if (dsp->hdlc) {
644 spin_lock_irqsave(&dsp_lock, flags);
645 if (dsp->b_active)
646 schedule_work(&dsp->workq);
647 spin_unlock_irqrestore(&dsp_lock, flags);
648 }
649 break;
650 case (PH_DATA_IND):
651 case (DL_DATA_IND):
652 if (skb->len < 1) {
653 ret = -EINVAL;
654 break;
655 }
656 if (dsp->rx_is_off) {
657 if (dsp_debug & DEBUG_DSP_CORE)
658 printk(KERN_DEBUG "%s: rx-data during rx_off"
659 " for %s\n",
660 __func__, dsp->name);
661 }
662 if (dsp->hdlc) {
663 /* hdlc */
664 spin_lock_irqsave(&dsp_lock, flags);
665 dsp_cmx_hdlc(dsp, skb);
666 spin_unlock_irqrestore(&dsp_lock, flags);
667 if (dsp->rx_disabled) {
668 /* if receive is not allowed */
669 break;
670 }
671 hh->prim = DL_DATA_IND;
672 if (dsp->up)
673 return dsp->up->send(dsp->up, skb);
674 break;
675 }
676
677 /* decrypt if enabled */
678 if (dsp->bf_enable)
679 dsp_bf_decrypt(dsp, skb->data, skb->len);
680 /* pipeline */
681 if (dsp->pipeline.inuse)
682 dsp_pipeline_process_rx(&dsp->pipeline, skb->data,
683 skb->len);
684 /* change volume if requested */
685 if (dsp->rx_volume)
686 dsp_change_volume(skb, dsp->rx_volume);
687
688 /* check if dtmf soft decoding is turned on */
689 if (dsp->dtmf.software) {
690 digits = dsp_dtmf_goertzel_decode(dsp, skb->data,
691 skb->len, (dsp_options&DSP_OPT_ULAW)?1:0);
692 while (*digits) {
693 if (dsp_debug & DEBUG_DSP_DTMF)
694 printk(KERN_DEBUG "%s: digit"
695 "(%c) to layer %s\n",
696 __func__, *digits, dsp->name);
697 cont = DTMF_TONE_VAL | *digits;
698 nskb = _alloc_mISDN_skb(PH_CONTROL_IND,
699 MISDN_ID_ANY, sizeof(int), &cont,
700 GFP_ATOMIC);
701 if (nskb) {
702 if (dsp->up) {
703 if (dsp->up->send(
704 dsp->up, nskb))
705 dev_kfree_skb(nskb);
706 } else
707 dev_kfree_skb(nskb);
708 }
709 digits++;
710 }
711 }
712 /* we need to process receive data if software */
713 spin_lock_irqsave(&dsp_lock, flags);
714 if (dsp->pcm_slot_tx < 0 && dsp->pcm_slot_rx < 0) {
715 /* process data from card at cmx */
716 dsp_cmx_receive(dsp, skb);
717 }
718 spin_unlock_irqrestore(&dsp_lock, flags);
719
720 if (dsp->rx_disabled) {
721 /* if receive is not allowed */
722 break;
723 }
724 hh->prim = DL_DATA_IND;
725 if (dsp->up)
726 return dsp->up->send(dsp->up, skb);
727 break;
728 case (PH_CONTROL_IND):
729 if (dsp_debug & DEBUG_DSP_DTMFCOEFF)
730 printk(KERN_DEBUG "%s: PH_CONTROL INDICATION "
731 "received: %x (len %d) %s\n", __func__,
732 hh->id, skb->len, dsp->name);
733 switch (hh->id) {
734 case (DTMF_HFC_COEF): /* getting coefficients */
735 if (!dsp->dtmf.hardware) {
736 if (dsp_debug & DEBUG_DSP_DTMFCOEFF)
737 printk(KERN_DEBUG "%s: ignoring DTMF "
738 "coefficients from HFC\n",
739 __func__);
740 break;
741 }
742 digits = dsp_dtmf_goertzel_decode(dsp, skb->data,
743 skb->len, 2);
744 while (*digits) {
745 int k;
746 struct sk_buff *nskb;
747 if (dsp_debug & DEBUG_DSP_DTMF)
748 printk(KERN_DEBUG "%s: digit"
749 "(%c) to layer %s\n",
750 __func__, *digits, dsp->name);
751 k = *digits | DTMF_TONE_VAL;
752 nskb = _alloc_mISDN_skb(PH_CONTROL_IND,
753 MISDN_ID_ANY, sizeof(int), &k,
754 GFP_ATOMIC);
755 if (nskb) {
756 if (dsp->up) {
757 if (dsp->up->send(
758 dsp->up, nskb))
759 dev_kfree_skb(nskb);
760 } else
761 dev_kfree_skb(nskb);
762 }
763 digits++;
764 }
765 break;
766 case (HFC_VOL_CHANGE_TX): /* change volume */
767 if (skb->len != sizeof(int)) {
768 ret = -EINVAL;
769 break;
770 }
771 spin_lock_irqsave(&dsp_lock, flags);
772 dsp->tx_volume = *((int *)skb->data);
773 if (dsp_debug & DEBUG_DSP_CORE)
774 printk(KERN_DEBUG "%s: change tx volume to "
775 "%d\n", __func__, dsp->tx_volume);
776 dsp_cmx_hardware(dsp->conf, dsp);
777 dsp_dtmf_hardware(dsp);
778 dsp_rx_off(dsp);
779 spin_unlock_irqrestore(&dsp_lock, flags);
780 break;
781 default:
782 if (dsp_debug & DEBUG_DSP_CORE)
783 printk(KERN_DEBUG "%s: ctrl ind %x unhandled "
784 "%s\n", __func__, hh->id, dsp->name);
785 ret = -EINVAL;
786 }
787 break;
788 case (PH_ACTIVATE_IND):
789 case (PH_ACTIVATE_CNF):
790 if (dsp_debug & DEBUG_DSP_CORE)
791 printk(KERN_DEBUG "%s: b_channel is now active %s\n",
792 __func__, dsp->name);
793 /* bchannel now active */
794 spin_lock_irqsave(&dsp_lock, flags);
795 dsp->b_active = 1;
796 dsp->data_pending = 0;
797 dsp->rx_init = 1;
798 /* rx_W and rx_R will be adjusted on first frame */
799 dsp->rx_W = 0;
800 dsp->rx_R = 0;
801 memset(dsp->rx_buff, 0, sizeof(dsp->rx_buff));
802 dsp_cmx_hardware(dsp->conf, dsp);
803 dsp_dtmf_hardware(dsp);
804 dsp_rx_off(dsp);
805 spin_unlock_irqrestore(&dsp_lock, flags);
806 if (dsp_debug & DEBUG_DSP_CORE)
807 printk(KERN_DEBUG "%s: done with activation, sending "
808 "confirm to user space. %s\n", __func__,
809 dsp->name);
810 /* send activation to upper layer */
811 hh->prim = DL_ESTABLISH_CNF;
812 if (dsp->up)
813 return dsp->up->send(dsp->up, skb);
814 break;
815 case (PH_DEACTIVATE_IND):
816 case (PH_DEACTIVATE_CNF):
817 if (dsp_debug & DEBUG_DSP_CORE)
818 printk(KERN_DEBUG "%s: b_channel is now inactive %s\n",
819 __func__, dsp->name);
820 /* bchannel now inactive */
821 spin_lock_irqsave(&dsp_lock, flags);
822 dsp->b_active = 0;
823 dsp->data_pending = 0;
824 dsp_cmx_hardware(dsp->conf, dsp);
825 dsp_rx_off(dsp);
826 spin_unlock_irqrestore(&dsp_lock, flags);
827 hh->prim = DL_RELEASE_CNF;
828 if (dsp->up)
829 return dsp->up->send(dsp->up, skb);
830 break;
831 /* FROM UP */
832 case (DL_DATA_REQ):
833 case (PH_DATA_REQ):
834 if (skb->len < 1) {
835 ret = -EINVAL;
836 break;
837 }
838 if (dsp->hdlc) {
839 /* hdlc */
840 spin_lock_irqsave(&dsp_lock, flags);
841 if (dsp->b_active) {
842 skb_queue_tail(&dsp->sendq, skb);
843 schedule_work(&dsp->workq);
844 }
845 spin_unlock_irqrestore(&dsp_lock, flags);
846 return 0;
847 }
848 /* send data to tx-buffer (if no tone is played) */
849 if (!dsp->tone.tone) {
850 spin_lock_irqsave(&dsp_lock, flags);
851 dsp_cmx_transmit(dsp, skb);
852 spin_unlock_irqrestore(&dsp_lock, flags);
853 }
854 break;
855 case (PH_CONTROL_REQ):
856 spin_lock_irqsave(&dsp_lock, flags);
857 ret = dsp_control_req(dsp, hh, skb);
858 spin_unlock_irqrestore(&dsp_lock, flags);
859 break;
860 case (DL_ESTABLISH_REQ):
861 case (PH_ACTIVATE_REQ):
862 if (dsp_debug & DEBUG_DSP_CORE)
863 printk(KERN_DEBUG "%s: activating b_channel %s\n",
864 __func__, dsp->name);
865 if (dsp->dtmf.hardware || dsp->dtmf.software)
866 dsp_dtmf_goertzel_init(dsp);
867 get_features(ch);
868 /* send ph_activate */
869 hh->prim = PH_ACTIVATE_REQ;
870 if (ch->peer)
871 return ch->recv(ch->peer, skb);
872 break;
873 case (DL_RELEASE_REQ):
874 case (PH_DEACTIVATE_REQ):
875 if (dsp_debug & DEBUG_DSP_CORE)
876 printk(KERN_DEBUG "%s: releasing b_channel %s\n",
877 __func__, dsp->name);
878 spin_lock_irqsave(&dsp_lock, flags);
879 dsp->tone.tone = 0;
880 dsp->tone.hardware = 0;
881 dsp->tone.software = 0;
882 if (timer_pending(&dsp->tone.tl))
883 del_timer(&dsp->tone.tl);
884 if (dsp->conf)
885 dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be
886 called here */
887 skb_queue_purge(&dsp->sendq);
888 spin_unlock_irqrestore(&dsp_lock, flags);
889 hh->prim = PH_DEACTIVATE_REQ;
890 if (ch->peer)
891 return ch->recv(ch->peer, skb);
892 break;
893 default:
894 if (dsp_debug & DEBUG_DSP_CORE)
895 printk(KERN_DEBUG "%s: msg %x unhandled %s\n",
896 __func__, hh->prim, dsp->name);
897 ret = -EINVAL;
898 }
899 if (!ret)
900 dev_kfree_skb(skb);
901 return ret;
902}
903
904static int
905dsp_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
906{
907 struct dsp *dsp = container_of(ch, struct dsp, ch);
908 u_long flags;
909 int err = 0;
910
911 if (debug & DEBUG_DSP_CTRL)
912 printk(KERN_DEBUG "%s:(%x)\n", __func__, cmd);
913
914 switch (cmd) {
915 case OPEN_CHANNEL:
916 break;
917 case CLOSE_CHANNEL:
918 if (dsp->ch.peer)
919 dsp->ch.peer->ctrl(dsp->ch.peer, CLOSE_CHANNEL, NULL);
920
921 /* wait until workqueue has finished,
922 * must lock here, or we may hit send-process currently
923 * queueing. */
924 spin_lock_irqsave(&dsp_lock, flags);
925 dsp->b_active = 0;
926 spin_unlock_irqrestore(&dsp_lock, flags);
927 /* MUST not be locked, because it waits until queue is done. */
928 cancel_work_sync(&dsp->workq);
929 spin_lock_irqsave(&dsp_lock, flags);
930 if (timer_pending(&dsp->tone.tl))
931 del_timer(&dsp->tone.tl);
932 skb_queue_purge(&dsp->sendq);
933 if (dsp_debug & DEBUG_DSP_CTRL)
934 printk(KERN_DEBUG "%s: releasing member %s\n",
935 __func__, dsp->name);
936 dsp->b_active = 0;
937 dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be called
938 here */
939 dsp_pipeline_destroy(&dsp->pipeline);
940
941 if (dsp_debug & DEBUG_DSP_CTRL)
942 printk(KERN_DEBUG "%s: remove & destroy object %s\n",
943 __func__, dsp->name);
944 list_del(&dsp->list);
945 spin_unlock_irqrestore(&dsp_lock, flags);
946
947 if (dsp_debug & DEBUG_DSP_CTRL)
948 printk(KERN_DEBUG "%s: dsp instance released\n",
949 __func__);
950 vfree(dsp);
951 module_put(THIS_MODULE);
952 break;
953 }
954 return err;
955}
956
957static void
958dsp_send_bh(struct work_struct *work)
959{
960 struct dsp *dsp = container_of(work, struct dsp, workq);
961 struct sk_buff *skb;
962 struct mISDNhead *hh;
963
964 if (dsp->hdlc && dsp->data_pending)
965 return; /* wait until data has been acknowledged */
966
967 /* send queued data */
968 while ((skb = skb_dequeue(&dsp->sendq))) {
969 /* in locked date, we must have still data in queue */
970 if (dsp->data_pending) {
971 if (dsp_debug & DEBUG_DSP_CORE)
972 printk(KERN_DEBUG "%s: fifo full %s, this is "
973 "no bug!\n", __func__, dsp->name);
974 /* flush transparent data, if not acked */
975 dev_kfree_skb(skb);
976 continue;
977 }
978 hh = mISDN_HEAD_P(skb);
979 if (hh->prim == DL_DATA_REQ) {
980 /* send packet up */
981 if (dsp->up) {
982 if (dsp->up->send(dsp->up, skb))
983 dev_kfree_skb(skb);
984 } else
985 dev_kfree_skb(skb);
986 } else {
987 /* send packet down */
988 if (dsp->ch.peer) {
989 dsp->data_pending = 1;
990 if (dsp->ch.recv(dsp->ch.peer, skb)) {
991 dev_kfree_skb(skb);
992 dsp->data_pending = 0;
993 }
994 } else
995 dev_kfree_skb(skb);
996 }
997 }
998}
999
1000static int
1001dspcreate(struct channel_req *crq)
1002{
1003 struct dsp *ndsp;
1004 u_long flags;
1005
1006 if (crq->protocol != ISDN_P_B_L2DSP
1007 && crq->protocol != ISDN_P_B_L2DSPHDLC)
1008 return -EPROTONOSUPPORT;
1009 ndsp = vmalloc(sizeof(struct dsp));
1010 if (!ndsp) {
1011 printk(KERN_ERR "%s: vmalloc struct dsp failed\n", __func__);
1012 return -ENOMEM;
1013 }
1014 memset(ndsp, 0, sizeof(struct dsp));
1015 if (dsp_debug & DEBUG_DSP_CTRL)
1016 printk(KERN_DEBUG "%s: creating new dsp instance\n", __func__);
1017
1018 /* default enabled */
1019 INIT_WORK(&ndsp->workq, (void *)dsp_send_bh);
1020 skb_queue_head_init(&ndsp->sendq);
1021 ndsp->ch.send = dsp_function;
1022 ndsp->ch.ctrl = dsp_ctrl;
1023 ndsp->up = crq->ch;
1024 crq->ch = &ndsp->ch;
1025 if (crq->protocol == ISDN_P_B_L2DSP) {
1026 crq->protocol = ISDN_P_B_RAW;
1027 ndsp->hdlc = 0;
1028 } else {
1029 crq->protocol = ISDN_P_B_HDLC;
1030 ndsp->hdlc = 1;
1031 }
1032 if (!try_module_get(THIS_MODULE))
1033 printk(KERN_WARNING "%s:cannot get module\n",
1034 __func__);
1035
1036 sprintf(ndsp->name, "DSP_C%x(0x%p)",
1037 ndsp->up->st->dev->id + 1, ndsp);
1038 /* set frame size to start */
1039 ndsp->features.hfc_id = -1; /* current PCM id */
1040 ndsp->features.pcm_id = -1; /* current PCM id */
1041 ndsp->pcm_slot_rx = -1; /* current CPM slot */
1042 ndsp->pcm_slot_tx = -1;
1043 ndsp->pcm_bank_rx = -1;
1044 ndsp->pcm_bank_tx = -1;
1045 ndsp->hfc_conf = -1; /* current conference number */
1046 /* set tone timer */
1047 ndsp->tone.tl.function = (void *)dsp_tone_timeout;
1048 ndsp->tone.tl.data = (long) ndsp;
1049 init_timer(&ndsp->tone.tl);
1050
1051 if (dtmfthreshold < 20 || dtmfthreshold > 500)
1052 dtmfthreshold = 200;
1053 ndsp->dtmf.treshold = dtmfthreshold*10000;
1054
1055 /* init pipeline append to list */
1056 spin_lock_irqsave(&dsp_lock, flags);
1057 dsp_pipeline_init(&ndsp->pipeline);
1058 list_add_tail(&ndsp->list, &dsp_ilist);
1059 spin_unlock_irqrestore(&dsp_lock, flags);
1060
1061 return 0;
1062}
1063
1064
1065static struct Bprotocol DSP = {
1066 .Bprotocols = (1 << (ISDN_P_B_L2DSP & ISDN_P_B_MASK))
1067 | (1 << (ISDN_P_B_L2DSPHDLC & ISDN_P_B_MASK)),
1068 .name = "dsp",
1069 .create = dspcreate
1070};
1071
1072static int dsp_init(void)
1073{
1074 int err;
1075 int tics;
1076
1077 printk(KERN_INFO "DSP modul %s\n", mISDN_dsp_revision);
1078
1079 dsp_options = options;
1080 dsp_debug = debug;
1081
1082 /* set packet size */
1083 dsp_poll = poll;
1084 if (dsp_poll) {
1085 if (dsp_poll > MAX_POLL) {
1086 printk(KERN_ERR "%s: Wrong poll value (%d), use %d "
1087 "maximum.\n", __func__, poll, MAX_POLL);
1088 err = -EINVAL;
1089 return err;
1090 }
1091 if (dsp_poll < 8) {
1092 printk(KERN_ERR "%s: Wrong poll value (%d), use 8 "
1093 "minimum.\n", __func__, dsp_poll);
1094 err = -EINVAL;
1095 return err;
1096 }
1097 dsp_tics = poll * HZ / 8000;
1098 if (dsp_tics * 8000 != poll * HZ) {
1099 printk(KERN_INFO "mISDN_dsp: Cannot clock every %d "
1100 "samples (0,125 ms). It is not a multiple of "
1101 "%d HZ.\n", poll, HZ);
1102 err = -EINVAL;
1103 return err;
1104 }
1105 } else {
1106 poll = 8;
1107 while (poll <= MAX_POLL) {
1108 tics = poll * HZ / 8000;
1109 if (tics * 8000 == poll * HZ) {
1110 dsp_tics = tics;
1111 dsp_poll = poll;
1112 if (poll >= 64)
1113 break;
1114 }
1115 poll++;
1116 }
1117 }
1118 if (dsp_poll == 0) {
1119 printk(KERN_INFO "mISDN_dsp: There is no multiple of kernel "
1120 "clock that equals exactly the duration of 8-256 "
1121 "samples. (Choose kernel clock speed like 100, 250, "
1122 "300, 1000)\n");
1123 err = -EINVAL;
1124 return err;
1125 }
1126 printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals "
1127 "%d jiffies.\n", dsp_poll, dsp_tics);
1128
1129 spin_lock_init(&dsp_lock);
1130 INIT_LIST_HEAD(&dsp_ilist);
1131 INIT_LIST_HEAD(&conf_ilist);
1132
1133 /* init conversion tables */
1134 dsp_audio_generate_law_tables();
1135 dsp_silence = (dsp_options&DSP_OPT_ULAW)?0xff:0x2a;
1136 dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW)?dsp_audio_ulaw_to_s32:
1137 dsp_audio_alaw_to_s32;
1138 dsp_audio_generate_s2law_table();
1139 dsp_audio_generate_seven();
1140 dsp_audio_generate_mix_table();
1141 if (dsp_options & DSP_OPT_ULAW)
1142 dsp_audio_generate_ulaw_samples();
1143 dsp_audio_generate_volume_changes();
1144
1145 err = dsp_pipeline_module_init();
1146 if (err) {
1147 printk(KERN_ERR "mISDN_dsp: Can't initialize pipeline, "
1148 "error(%d)\n", err);
1149 return err;
1150 }
1151
1152 err = mISDN_register_Bprotocol(&DSP);
1153 if (err) {
1154 printk(KERN_ERR "Can't register %s error(%d)\n", DSP.name, err);
1155 return err;
1156 }
1157
1158 /* set sample timer */
1159 dsp_spl_tl.function = (void *)dsp_cmx_send;
1160 dsp_spl_tl.data = 0;
1161 init_timer(&dsp_spl_tl);
1162 dsp_spl_tl.expires = jiffies + dsp_tics;
1163 dsp_spl_jiffies = dsp_spl_tl.expires;
1164 add_timer(&dsp_spl_tl);
1165
1166 return 0;
1167}
1168
1169
1170static void dsp_cleanup(void)
1171{
1172 mISDN_unregister_Bprotocol(&DSP);
1173
1174 if (timer_pending(&dsp_spl_tl))
1175 del_timer(&dsp_spl_tl);
1176
1177 if (!list_empty(&dsp_ilist)) {
1178 printk(KERN_ERR "mISDN_dsp: Audio DSP object inst list not "
1179 "empty.\n");
1180 }
1181 if (!list_empty(&conf_ilist)) {
1182 printk(KERN_ERR "mISDN_dsp: Conference list not empty. Not "
1183 "all memory freed.\n");
1184 }
1185
1186 dsp_pipeline_module_exit();
1187}
1188
1189module_init(dsp_init);
1190module_exit(dsp_cleanup);
1191
diff --git a/drivers/isdn/mISDN/dsp_dtmf.c b/drivers/isdn/mISDN/dsp_dtmf.c
new file mode 100644
index 000000000000..efc371c1f0dc
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_dtmf.c
@@ -0,0 +1,303 @@
1/*
2 * DTMF decoder.
3 *
4 * Copyright by Andreas Eversberg (jolly@eversberg.eu)
5 * based on different decoders such as ISDN4Linux
6 *
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#include <linux/mISDNif.h>
13#include <linux/mISDNdsp.h>
14#include "core.h"
15#include "dsp.h"
16
17#define NCOEFF 8 /* number of frequencies to be analyzed */
18
19/* For DTMF recognition:
20 * 2 * cos(2 * PI * k / N) precalculated for all k
21 */
22static u64 cos2pik[NCOEFF] =
23{
24 /* k << 15 (source: hfc-4s/8s documentation (www.colognechip.de)) */
25 55960, 53912, 51402, 48438, 38146, 32650, 26170, 18630
26};
27
28/* digit matrix */
29static char dtmf_matrix[4][4] =
30{
31 {'1', '2', '3', 'A'},
32 {'4', '5', '6', 'B'},
33 {'7', '8', '9', 'C'},
34 {'*', '0', '#', 'D'}
35};
36
37/* dtmf detection using goertzel algorithm
38 * init function
39 */
40void dsp_dtmf_goertzel_init(struct dsp *dsp)
41{
42 dsp->dtmf.size = 0;
43 dsp->dtmf.lastwhat = '\0';
44 dsp->dtmf.lastdigit = '\0';
45 dsp->dtmf.count = 0;
46}
47
48/* check for hardware or software features
49 */
50void dsp_dtmf_hardware(struct dsp *dsp)
51{
52 int hardware = 1;
53
54 if (!dsp->features.hfc_dtmf)
55 hardware = 0;
56
57 /* check for volume change */
58 if (dsp->tx_volume) {
59 if (dsp_debug & DEBUG_DSP_DTMF)
60 printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, "
61 "because tx_volume is changed\n",
62 __func__, dsp->name);
63 hardware = 0;
64 }
65 if (dsp->rx_volume) {
66 if (dsp_debug & DEBUG_DSP_DTMF)
67 printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, "
68 "because rx_volume is changed\n",
69 __func__, dsp->name);
70 hardware = 0;
71 }
72 /* check if encryption is enabled */
73 if (dsp->bf_enable) {
74 if (dsp_debug & DEBUG_DSP_DTMF)
75 printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, "
76 "because encryption is enabled\n",
77 __func__, dsp->name);
78 hardware = 0;
79 }
80 /* check if pipeline exists */
81 if (dsp->pipeline.inuse) {
82 if (dsp_debug & DEBUG_DSP_DTMF)
83 printk(KERN_DEBUG "%s dsp %s cannot do hardware DTMF, "
84 "because pipeline exists.\n",
85 __func__, dsp->name);
86 hardware = 0;
87 }
88
89 dsp->dtmf.hardware = hardware;
90 dsp->dtmf.software = !hardware;
91}
92
93
94/*************************************************************
95 * calculate the coefficients of the given sample and decode *
96 *************************************************************/
97
98/* the given sample is decoded. if the sample is not long enough for a
99 * complete frame, the decoding is finished and continued with the next
100 * call of this function.
101 *
102 * the algorithm is very good for detection with a minimum of errors. i
103 * tested it allot. it even works with very short tones (40ms). the only
104 * disadvantage is, that it doesn't work good with different volumes of both
105 * tones. this will happen, if accoustically coupled dialers are used.
106 * it sometimes detects tones during speach, which is normal for decoders.
107 * use sequences to given commands during calls.
108 *
109 * dtmf - points to a structure of the current dtmf state
110 * spl and len - the sample
111 * fmt - 0 = alaw, 1 = ulaw, 2 = coefficients from HFC DTMF hw-decoder
112 */
113
114u8
115*dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len, int fmt)
116{
117 u8 what;
118 int size;
119 signed short *buf;
120 s32 sk, sk1, sk2;
121 int k, n, i;
122 s32 *hfccoeff;
123 s32 result[NCOEFF], tresh, treshl;
124 int lowgroup, highgroup;
125 s64 cos2pik_;
126
127 dsp->dtmf.digits[0] = '\0';
128
129 /* Note: The function will loop until the buffer has not enough samples
130 * left to decode a full frame.
131 */
132again:
133 /* convert samples */
134 size = dsp->dtmf.size;
135 buf = dsp->dtmf.buffer;
136 switch (fmt) {
137 case 0: /* alaw */
138 case 1: /* ulaw */
139 while (size < DSP_DTMF_NPOINTS && len) {
140 buf[size++] = dsp_audio_law_to_s32[*data++];
141 len--;
142 }
143 break;
144
145 case 2: /* HFC coefficients */
146 default:
147 if (len < 64) {
148 if (len > 0)
149 printk(KERN_ERR "%s: coefficients have invalid "
150 "size. (is=%d < must=%d)\n",
151 __func__, len, 64);
152 return dsp->dtmf.digits;
153 }
154 hfccoeff = (s32 *)data;
155 for (k = 0; k < NCOEFF; k++) {
156 sk2 = (*hfccoeff++)>>4;
157 sk = (*hfccoeff++)>>4;
158 if (sk > 32767 || sk < -32767 || sk2 > 32767
159 || sk2 < -32767)
160 printk(KERN_WARNING
161 "DTMF-Detection overflow\n");
162 /* compute |X(k)|**2 */
163 result[k] =
164 (sk * sk) -
165 (((cos2pik[k] * sk) >> 15) * sk2) +
166 (sk2 * sk2);
167 }
168 data += 64;
169 len -= 64;
170 goto coefficients;
171 break;
172 }
173 dsp->dtmf.size = size;
174
175 if (size < DSP_DTMF_NPOINTS)
176 return dsp->dtmf.digits;
177
178 dsp->dtmf.size = 0;
179
180 /* now we have a full buffer of signed long samples - we do goertzel */
181 for (k = 0; k < NCOEFF; k++) {
182 sk = 0;
183 sk1 = 0;
184 sk2 = 0;
185 buf = dsp->dtmf.buffer;
186 cos2pik_ = cos2pik[k];
187 for (n = 0; n < DSP_DTMF_NPOINTS; n++) {
188 sk = ((cos2pik_*sk1)>>15) - sk2 + (*buf++);
189 sk2 = sk1;
190 sk1 = sk;
191 }
192 sk >>= 8;
193 sk2 >>= 8;
194 if (sk > 32767 || sk < -32767 || sk2 > 32767 || sk2 < -32767)
195 printk(KERN_WARNING "DTMF-Detection overflow\n");
196 /* compute |X(k)|**2 */
197 result[k] =
198 (sk * sk) -
199 (((cos2pik[k] * sk) >> 15) * sk2) +
200 (sk2 * sk2);
201 }
202
203 /* our (squared) coefficients have been calculated, we need to process
204 * them.
205 */
206coefficients:
207 tresh = 0;
208 for (i = 0; i < NCOEFF; i++) {
209 if (result[i] < 0)
210 result[i] = 0;
211 if (result[i] > dsp->dtmf.treshold) {
212 if (result[i] > tresh)
213 tresh = result[i];
214 }
215 }
216
217 if (tresh == 0) {
218 what = 0;
219 goto storedigit;
220 }
221
222 if (dsp_debug & DEBUG_DSP_DTMFCOEFF)
223 printk(KERN_DEBUG "a %3d %3d %3d %3d %3d %3d %3d %3d"
224 " tr:%3d r %3d %3d %3d %3d %3d %3d %3d %3d\n",
225 result[0]/10000, result[1]/10000, result[2]/10000,
226 result[3]/10000, result[4]/10000, result[5]/10000,
227 result[6]/10000, result[7]/10000, tresh/10000,
228 result[0]/(tresh/100), result[1]/(tresh/100),
229 result[2]/(tresh/100), result[3]/(tresh/100),
230 result[4]/(tresh/100), result[5]/(tresh/100),
231 result[6]/(tresh/100), result[7]/(tresh/100));
232
233 /* calc digit (lowgroup/highgroup) */
234 lowgroup = -1;
235 highgroup = -1;
236 treshl = tresh >> 3; /* tones which are not on, must be below 9 dB */
237 tresh = tresh >> 2; /* touchtones must match within 6 dB */
238 for (i = 0; i < NCOEFF; i++) {
239 if (result[i] < treshl)
240 continue; /* ignore */
241 if (result[i] < tresh) {
242 lowgroup = -1;
243 highgroup = -1;
244 break; /* noise inbetween */
245 }
246 /* good level found. This is allowed only one time per group */
247 if (i < NCOEFF/2) {
248 /* lowgroup */
249 if (lowgroup >= 0) {
250 /* Bad. Another tone found. */
251 lowgroup = -1;
252 break;
253 } else
254 lowgroup = i;
255 } else {
256 /* higroup */
257 if (highgroup >= 0) {
258 /* Bad. Another tone found. */
259 highgroup = -1;
260 break;
261 } else
262 highgroup = i-(NCOEFF/2);
263 }
264 }
265
266 /* get digit or null */
267 what = 0;
268 if (lowgroup >= 0 && highgroup >= 0)
269 what = dtmf_matrix[lowgroup][highgroup];
270
271storedigit:
272 if (what && (dsp_debug & DEBUG_DSP_DTMF))
273 printk(KERN_DEBUG "DTMF what: %c\n", what);
274
275 if (dsp->dtmf.lastwhat != what)
276 dsp->dtmf.count = 0;
277
278 /* the tone (or no tone) must remain 3 times without change */
279 if (dsp->dtmf.count == 2) {
280 if (dsp->dtmf.lastdigit != what) {
281 dsp->dtmf.lastdigit = what;
282 if (what) {
283 if (dsp_debug & DEBUG_DSP_DTMF)
284 printk(KERN_DEBUG "DTMF digit: %c\n",
285 what);
286 if ((strlen(dsp->dtmf.digits)+1)
287 < sizeof(dsp->dtmf.digits)) {
288 dsp->dtmf.digits[strlen(
289 dsp->dtmf.digits)+1] = '\0';
290 dsp->dtmf.digits[strlen(
291 dsp->dtmf.digits)] = what;
292 }
293 }
294 }
295 } else
296 dsp->dtmf.count++;
297
298 dsp->dtmf.lastwhat = what;
299
300 goto again;
301}
302
303
diff --git a/drivers/isdn/mISDN/dsp_ecdis.h b/drivers/isdn/mISDN/dsp_ecdis.h
new file mode 100644
index 000000000000..8a20af43308b
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_ecdis.h
@@ -0,0 +1,110 @@
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * ec_disable_detector.h - A detector which should eventually meet the
5 * G.164/G.165 requirements for detecting the
6 * 2100Hz echo cancellor disable tone.
7 *
8 * Written by Steve Underwood <steveu@coppice.org>
9 *
10 * Copyright (C) 2001 Steve Underwood
11 *
12 * All rights reserved.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 */
29
30#include "dsp_biquad.h"
31
32struct ec_disable_detector_state {
33 struct biquad2_state notch;
34 int notch_level;
35 int channel_level;
36 int tone_present;
37 int tone_cycle_duration;
38 int good_cycles;
39 int hit;
40};
41
42
43#define FALSE 0
44#define TRUE (!FALSE)
45
46static inline void
47echo_can_disable_detector_init(struct ec_disable_detector_state *det)
48{
49 /* Elliptic notch */
50 /* This is actually centred at 2095Hz, but gets the balance we want, due
51 to the asymmetric walls of the notch */
52 biquad2_init(&det->notch,
53 (int32_t) (-0.7600000*32768.0),
54 (int32_t) (-0.1183852*32768.0),
55 (int32_t) (-0.5104039*32768.0),
56 (int32_t) (0.1567596*32768.0),
57 (int32_t) (1.0000000*32768.0));
58
59 det->channel_level = 0;
60 det->notch_level = 0;
61 det->tone_present = FALSE;
62 det->tone_cycle_duration = 0;
63 det->good_cycles = 0;
64 det->hit = 0;
65}
66/*- End of function --------------------------------------------------------*/
67
68static inline int
69echo_can_disable_detector_update(struct ec_disable_detector_state *det,
70int16_t amp)
71{
72 int16_t notched;
73
74 notched = biquad2(&det->notch, amp);
75 /* Estimate the overall energy in the channel, and the energy in
76 the notch (i.e. overall channel energy - tone energy => noise).
77 Use abs instead of multiply for speed (is it really faster?).
78 Damp the overall energy a little more for a stable result.
79 Damp the notch energy a little less, so we don't damp out the
80 blip every time the phase reverses */
81 det->channel_level += ((abs(amp) - det->channel_level) >> 5);
82 det->notch_level += ((abs(notched) - det->notch_level) >> 4);
83 if (det->channel_level > 280) {
84 /* There is adequate energy in the channel.
85 Is it mostly at 2100Hz? */
86 if (det->notch_level*6 < det->channel_level) {
87 /* The notch says yes, so we have the tone. */
88 if (!det->tone_present) {
89 /* Do we get a kick every 450+-25ms? */
90 if (det->tone_cycle_duration >= 425*8
91 && det->tone_cycle_duration <= 475*8) {
92 det->good_cycles++;
93 if (det->good_cycles > 2)
94 det->hit = TRUE;
95 }
96 det->tone_cycle_duration = 0;
97 }
98 det->tone_present = TRUE;
99 } else
100 det->tone_present = FALSE;
101 det->tone_cycle_duration++;
102 } else {
103 det->tone_present = FALSE;
104 det->tone_cycle_duration = 0;
105 det->good_cycles = 0;
106 }
107 return det->hit;
108}
109/*- End of function --------------------------------------------------------*/
110/*- End of file ------------------------------------------------------------*/
diff --git a/drivers/isdn/mISDN/dsp_hwec.c b/drivers/isdn/mISDN/dsp_hwec.c
new file mode 100644
index 000000000000..eb892d9dd5c6
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_hwec.c
@@ -0,0 +1,138 @@
1/*
2 * dsp_hwec.c:
3 * builtin mISDN dsp pipeline element for enabling the hw echocanceller
4 *
5 * Copyright (C) 2007, Nadi Sarrar
6 *
7 * Nadi Sarrar <nadi@beronet.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 * The full GNU General Public License is included in this distribution in the
24 * file called LICENSE.
25 *
26 */
27
28#include <linux/kernel.h>
29#include <linux/string.h>
30#include <linux/mISDNdsp.h>
31#include <linux/mISDNif.h>
32#include "core.h"
33#include "dsp.h"
34#include "dsp_hwec.h"
35
36static struct mISDN_dsp_element_arg args[] = {
37 { "deftaps", "128", "Set the number of taps of cancellation." },
38};
39
40static struct mISDN_dsp_element dsp_hwec_p = {
41 .name = "hwec",
42 .new = NULL,
43 .free = NULL,
44 .process_tx = NULL,
45 .process_rx = NULL,
46 .num_args = sizeof(args) / sizeof(struct mISDN_dsp_element_arg),
47 .args = args,
48};
49struct mISDN_dsp_element *dsp_hwec = &dsp_hwec_p;
50
51void dsp_hwec_enable(struct dsp *dsp, const char *arg)
52{
53 int deftaps = 128,
54 len;
55 struct mISDN_ctrl_req cq;
56
57 if (!dsp) {
58 printk(KERN_ERR "%s: failed to enable hwec: dsp is NULL\n",
59 __func__);
60 return;
61 }
62
63 if (!arg)
64 goto _do;
65
66 len = strlen(arg);
67 if (!len)
68 goto _do;
69
70 {
71 char _dup[len + 1];
72 char *dup, *tok, *name, *val;
73 int tmp;
74
75 strcpy(_dup, arg);
76 dup = _dup;
77
78 while ((tok = strsep(&dup, ","))) {
79 if (!strlen(tok))
80 continue;
81 name = strsep(&tok, "=");
82 val = tok;
83
84 if (!val)
85 continue;
86
87 if (!strcmp(name, "deftaps")) {
88 if (sscanf(val, "%d", &tmp) == 1)
89 deftaps = tmp;
90 }
91 }
92 }
93
94_do:
95 printk(KERN_DEBUG "%s: enabling hwec with deftaps=%d\n",
96 __func__, deftaps);
97 memset(&cq, 0, sizeof(cq));
98 cq.op = MISDN_CTRL_HFC_ECHOCAN_ON;
99 cq.p1 = deftaps;
100 if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) {
101 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
102 __func__);
103 return;
104 }
105}
106
107void dsp_hwec_disable(struct dsp *dsp)
108{
109 struct mISDN_ctrl_req cq;
110
111 if (!dsp) {
112 printk(KERN_ERR "%s: failed to disable hwec: dsp is NULL\n",
113 __func__);
114 return;
115 }
116
117 printk(KERN_DEBUG "%s: disabling hwec\n", __func__);
118 memset(&cq, 0, sizeof(cq));
119 cq.op = MISDN_CTRL_HFC_ECHOCAN_OFF;
120 if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) {
121 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
122 __func__);
123 return;
124 }
125}
126
127int dsp_hwec_init(void)
128{
129 mISDN_dsp_element_register(dsp_hwec);
130
131 return 0;
132}
133
134void dsp_hwec_exit(void)
135{
136 mISDN_dsp_element_unregister(dsp_hwec);
137}
138
diff --git a/drivers/isdn/mISDN/dsp_hwec.h b/drivers/isdn/mISDN/dsp_hwec.h
new file mode 100644
index 000000000000..eebe80c3f713
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_hwec.h
@@ -0,0 +1,10 @@
1/*
2 * dsp_hwec.h
3 */
4
5extern struct mISDN_dsp_element *dsp_hwec;
6extern void dsp_hwec_enable(struct dsp *dsp, const char *arg);
7extern void dsp_hwec_disable(struct dsp *dsp);
8extern int dsp_hwec_init(void);
9extern void dsp_hwec_exit(void);
10
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
new file mode 100644
index 000000000000..850260ab57d0
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -0,0 +1,348 @@
1/*
2 * dsp_pipeline.c: pipelined audio processing
3 *
4 * Copyright (C) 2007, Nadi Sarrar
5 *
6 * Nadi Sarrar <nadi@beronet.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59
20 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 * The full GNU General Public License is included in this distribution in the
23 * file called LICENSE.
24 *
25 */
26
27#include <linux/kernel.h>
28#include <linux/list.h>
29#include <linux/string.h>
30#include <linux/mISDNif.h>
31#include <linux/mISDNdsp.h>
32#include "dsp.h"
33#include "dsp_hwec.h"
34
35/* uncomment for debugging */
36/*#define PIPELINE_DEBUG*/
37
38struct dsp_pipeline_entry {
39 struct mISDN_dsp_element *elem;
40 void *p;
41 struct list_head list;
42};
43struct dsp_element_entry {
44 struct mISDN_dsp_element *elem;
45 struct device dev;
46 struct list_head list;
47};
48
49static LIST_HEAD(dsp_elements);
50
51/* sysfs */
52static struct class *elements_class;
53
54static ssize_t
55attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
56{
57 struct mISDN_dsp_element *elem = dev_get_drvdata(dev);
58 ssize_t len = 0;
59 int i = 0;
60
61 *buf = 0;
62 for (; i < elem->num_args; ++i)
63 len = sprintf(buf, "%sName: %s\n%s%s%sDescription: %s\n"
64 "\n", buf,
65 elem->args[i].name,
66 elem->args[i].def ? "Default: " : "",
67 elem->args[i].def ? elem->args[i].def : "",
68 elem->args[i].def ? "\n" : "",
69 elem->args[i].desc);
70
71 return len;
72}
73
74static struct device_attribute element_attributes[] = {
75 __ATTR(args, 0444, attr_show_args, NULL),
76};
77
78int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
79{
80 struct dsp_element_entry *entry;
81 int ret, i;
82
83 if (!elem)
84 return -EINVAL;
85
86 entry = kzalloc(sizeof(struct dsp_element_entry), GFP_KERNEL);
87 if (!entry)
88 return -ENOMEM;
89
90 entry->elem = elem;
91
92 entry->dev.class = elements_class;
93 dev_set_drvdata(&entry->dev, elem);
94 snprintf(entry->dev.bus_id, BUS_ID_SIZE, elem->name);
95 ret = device_register(&entry->dev);
96 if (ret) {
97 printk(KERN_ERR "%s: failed to register %s\n",
98 __func__, elem->name);
99 goto err1;
100 }
101
102 for (i = 0; i < (sizeof(element_attributes)
103 / sizeof(struct device_attribute)); ++i)
104 ret = device_create_file(&entry->dev,
105 &element_attributes[i]);
106 if (ret) {
107 printk(KERN_ERR "%s: failed to create device file\n",
108 __func__);
109 goto err2;
110 }
111
112 list_add_tail(&entry->list, &dsp_elements);
113
114 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
115
116 return 0;
117
118err2:
119 device_unregister(&entry->dev);
120err1:
121 kfree(entry);
122 return ret;
123}
124EXPORT_SYMBOL(mISDN_dsp_element_register);
125
126void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem)
127{
128 struct dsp_element_entry *entry, *n;
129
130 if (!elem)
131 return;
132
133 list_for_each_entry_safe(entry, n, &dsp_elements, list)
134 if (entry->elem == elem) {
135 list_del(&entry->list);
136 device_unregister(&entry->dev);
137 kfree(entry);
138 printk(KERN_DEBUG "%s: %s unregistered\n",
139 __func__, elem->name);
140 return;
141 }
142 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
143}
144EXPORT_SYMBOL(mISDN_dsp_element_unregister);
145
146int dsp_pipeline_module_init(void)
147{
148 elements_class = class_create(THIS_MODULE, "dsp_pipeline");
149 if (IS_ERR(elements_class))
150 return PTR_ERR(elements_class);
151
152#ifdef PIPELINE_DEBUG
153 printk(KERN_DEBUG "%s: dsp pipeline module initialized\n", __func__);
154#endif
155
156 dsp_hwec_init();
157
158 return 0;
159}
160
161void dsp_pipeline_module_exit(void)
162{
163 struct dsp_element_entry *entry, *n;
164
165 dsp_hwec_exit();
166
167 class_destroy(elements_class);
168
169 list_for_each_entry_safe(entry, n, &dsp_elements, list) {
170 list_del(&entry->list);
171 printk(KERN_WARNING "%s: element was still registered: %s\n",
172 __func__, entry->elem->name);
173 kfree(entry);
174 }
175
176 printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
177}
178
179int dsp_pipeline_init(struct dsp_pipeline *pipeline)
180{
181 if (!pipeline)
182 return -EINVAL;
183
184 INIT_LIST_HEAD(&pipeline->list);
185
186#ifdef PIPELINE_DEBUG
187 printk(KERN_DEBUG "%s: dsp pipeline ready\n", __func__);
188#endif
189
190 return 0;
191}
192
193static inline void _dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
194{
195 struct dsp_pipeline_entry *entry, *n;
196
197 list_for_each_entry_safe(entry, n, &pipeline->list, list) {
198 list_del(&entry->list);
199 if (entry->elem == dsp_hwec)
200 dsp_hwec_disable(container_of(pipeline, struct dsp,
201 pipeline));
202 else
203 entry->elem->free(entry->p);
204 kfree(entry);
205 }
206}
207
208void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
209{
210
211 if (!pipeline)
212 return;
213
214 _dsp_pipeline_destroy(pipeline);
215
216#ifdef PIPELINE_DEBUG
217 printk(KERN_DEBUG "%s: dsp pipeline destroyed\n", __func__);
218#endif
219}
220
221int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
222{
223 int len, incomplete = 0, found = 0;
224 char *dup, *tok, *name, *args;
225 struct dsp_element_entry *entry, *n;
226 struct dsp_pipeline_entry *pipeline_entry;
227 struct mISDN_dsp_element *elem;
228
229 if (!pipeline)
230 return -EINVAL;
231
232 if (!list_empty(&pipeline->list))
233 _dsp_pipeline_destroy(pipeline);
234
235 if (!cfg)
236 return 0;
237
238 len = strlen(cfg);
239 if (!len)
240 return 0;
241
242 dup = kmalloc(len + 1, GFP_KERNEL);
243 if (!dup)
244 return 0;
245 strcpy(dup, cfg);
246 while ((tok = strsep(&dup, "|"))) {
247 if (!strlen(tok))
248 continue;
249 name = strsep(&tok, "(");
250 args = strsep(&tok, ")");
251 if (args && !*args)
252 args = 0;
253
254 list_for_each_entry_safe(entry, n, &dsp_elements, list)
255 if (!strcmp(entry->elem->name, name)) {
256 elem = entry->elem;
257
258 pipeline_entry = kmalloc(sizeof(struct
259 dsp_pipeline_entry), GFP_KERNEL);
260 if (!pipeline_entry) {
261 printk(KERN_DEBUG "%s: failed to add "
262 "entry to pipeline: %s (out of "
263 "memory)\n", __func__, elem->name);
264 incomplete = 1;
265 goto _out;
266 }
267 pipeline_entry->elem = elem;
268
269 if (elem == dsp_hwec) {
270 /* This is a hack to make the hwec
271 available as a pipeline module */
272 dsp_hwec_enable(container_of(pipeline,
273 struct dsp, pipeline), args);
274 list_add_tail(&pipeline_entry->list,
275 &pipeline->list);
276 } else {
277 pipeline_entry->p = elem->new(args);
278 if (pipeline_entry->p) {
279 list_add_tail(&pipeline_entry->
280 list, &pipeline->list);
281#ifdef PIPELINE_DEBUG
282 printk(KERN_DEBUG "%s: created "
283 "instance of %s%s%s\n",
284 __func__, name, args ?
285 " with args " : "", args ?
286 args : "");
287#endif
288 } else {
289 printk(KERN_DEBUG "%s: failed "
290 "to add entry to pipeline: "
291 "%s (new() returned NULL)\n",
292 __func__, elem->name);
293 kfree(pipeline_entry);
294 incomplete = 1;
295 }
296 }
297 found = 1;
298 break;
299 }
300
301 if (found)
302 found = 0;
303 else {
304 printk(KERN_DEBUG "%s: element not found, skipping: "
305 "%s\n", __func__, name);
306 incomplete = 1;
307 }
308 }
309
310_out:
311 if (!list_empty(&pipeline->list))
312 pipeline->inuse = 1;
313 else
314 pipeline->inuse = 0;
315
316#ifdef PIPELINE_DEBUG
317 printk(KERN_DEBUG "%s: dsp pipeline built%s: %s\n",
318 __func__, incomplete ? " incomplete" : "", cfg);
319#endif
320 kfree(dup);
321 return 0;
322}
323
324void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data, int len)
325{
326 struct dsp_pipeline_entry *entry;
327
328 if (!pipeline)
329 return;
330
331 list_for_each_entry(entry, &pipeline->list, list)
332 if (entry->elem->process_tx)
333 entry->elem->process_tx(entry->p, data, len);
334}
335
336void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len)
337{
338 struct dsp_pipeline_entry *entry;
339
340 if (!pipeline)
341 return;
342
343 list_for_each_entry_reverse(entry, &pipeline->list, list)
344 if (entry->elem->process_rx)
345 entry->elem->process_rx(entry->p, data, len);
346}
347
348
diff --git a/drivers/isdn/mISDN/dsp_tones.c b/drivers/isdn/mISDN/dsp_tones.c
new file mode 100644
index 000000000000..23dd0dd21524
--- /dev/null
+++ b/drivers/isdn/mISDN/dsp_tones.c
@@ -0,0 +1,551 @@
1/*
2 * Audio support data for ISDN4Linux.
3 *
4 * Copyright Andreas Eversberg (jolly@eversberg.eu)
5 *
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
8 *
9 */
10
11#include <linux/mISDNif.h>
12#include <linux/mISDNdsp.h>
13#include "core.h"
14#include "dsp.h"
15
16
17#define DATA_S sample_silence
18#define SIZE_S (&sizeof_silence)
19#define DATA_GA sample_german_all
20#define SIZE_GA (&sizeof_german_all)
21#define DATA_GO sample_german_old
22#define SIZE_GO (&sizeof_german_old)
23#define DATA_DT sample_american_dialtone
24#define SIZE_DT (&sizeof_american_dialtone)
25#define DATA_RI sample_american_ringing
26#define SIZE_RI (&sizeof_american_ringing)
27#define DATA_BU sample_american_busy
28#define SIZE_BU (&sizeof_american_busy)
29#define DATA_S1 sample_special1
30#define SIZE_S1 (&sizeof_special1)
31#define DATA_S2 sample_special2
32#define SIZE_S2 (&sizeof_special2)
33#define DATA_S3 sample_special3
34#define SIZE_S3 (&sizeof_special3)
35
36/***************/
37/* tones loops */
38/***************/
39
40/* all tones are alaw encoded */
41/* the last sample+1 is in phase with the first sample. the error is low */
42
43static u8 sample_german_all[] = {
44 0x80, 0xab, 0x81, 0x6d, 0xfd, 0xdd, 0x5d, 0x9d,
45 0x4d, 0xd1, 0x89, 0x88, 0xd0, 0x4c, 0x9c, 0x5c,
46 0xdc, 0xfc, 0x6c,
47 0x80, 0xab, 0x81, 0x6d, 0xfd, 0xdd, 0x5d, 0x9d,
48 0x4d, 0xd1, 0x89, 0x88, 0xd0, 0x4c, 0x9c, 0x5c,
49 0xdc, 0xfc, 0x6c,
50 0x80, 0xab, 0x81, 0x6d, 0xfd, 0xdd, 0x5d, 0x9d,
51 0x4d, 0xd1, 0x89, 0x88, 0xd0, 0x4c, 0x9c, 0x5c,
52 0xdc, 0xfc, 0x6c,
53 0x80, 0xab, 0x81, 0x6d, 0xfd, 0xdd, 0x5d, 0x9d,
54 0x4d, 0xd1, 0x89, 0x88, 0xd0, 0x4c, 0x9c, 0x5c,
55 0xdc, 0xfc, 0x6c,
56};
57static u32 sizeof_german_all = sizeof(sample_german_all);
58
59static u8 sample_german_old[] = {
60 0xec, 0x68, 0xe1, 0x6d, 0x6d, 0x91, 0x51, 0xed,
61 0x6d, 0x01, 0x1e, 0x10, 0x0c, 0x90, 0x60, 0x70,
62 0x8c,
63 0xec, 0x68, 0xe1, 0x6d, 0x6d, 0x91, 0x51, 0xed,
64 0x6d, 0x01, 0x1e, 0x10, 0x0c, 0x90, 0x60, 0x70,
65 0x8c,
66 0xec, 0x68, 0xe1, 0x6d, 0x6d, 0x91, 0x51, 0xed,
67 0x6d, 0x01, 0x1e, 0x10, 0x0c, 0x90, 0x60, 0x70,
68 0x8c,
69 0xec, 0x68, 0xe1, 0x6d, 0x6d, 0x91, 0x51, 0xed,
70 0x6d, 0x01, 0x1e, 0x10, 0x0c, 0x90, 0x60, 0x70,
71 0x8c,
72};
73static u32 sizeof_german_old = sizeof(sample_german_old);
74
75static u8 sample_american_dialtone[] = {
76 0x2a, 0x18, 0x90, 0x6c, 0x4c, 0xbc, 0x4c, 0x6c,
77 0x10, 0x58, 0x32, 0xb9, 0x31, 0x2d, 0x8d, 0x0d,
78 0x8d, 0x2d, 0x31, 0x99, 0x0f, 0x28, 0x60, 0xf0,
79 0xd0, 0x50, 0xd0, 0x30, 0x60, 0x08, 0x8e, 0x67,
80 0x09, 0x19, 0x21, 0xe1, 0xd9, 0xb9, 0x29, 0x67,
81 0x83, 0x02, 0xce, 0xbe, 0xee, 0x1a, 0x1b, 0xef,
82 0xbf, 0xcf, 0x03, 0x82, 0x66, 0x28, 0xb8, 0xd8,
83 0xe0, 0x20, 0x18, 0x08, 0x66, 0x8f, 0x09, 0x61,
84 0x31, 0xd1, 0x51, 0xd1, 0xf1, 0x61, 0x29, 0x0e,
85 0x98, 0x30, 0x2c, 0x8c, 0x0c, 0x8c, 0x2c, 0x30,
86 0xb8, 0x33, 0x59, 0x11, 0x6d, 0x4d, 0xbd, 0x4d,
87 0x6d, 0x91, 0x19,
88};
89static u32 sizeof_american_dialtone = sizeof(sample_american_dialtone);
90
91static u8 sample_american_ringing[] = {
92 0x2a, 0xe0, 0xac, 0x0c, 0xbc, 0x4c, 0x8c, 0x90,
93 0x48, 0xc7, 0xc1, 0xed, 0xcd, 0x4d, 0xcd, 0xed,
94 0xc1, 0xb7, 0x08, 0x30, 0xec, 0xcc, 0xcc, 0x8c,
95 0x10, 0x58, 0x1a, 0x99, 0x71, 0xed, 0x8d, 0x8d,
96 0x2d, 0x41, 0x89, 0x9e, 0x20, 0x70, 0x2c, 0xec,
97 0x2c, 0x70, 0x20, 0x86, 0x77, 0xe1, 0x31, 0x11,
98 0xd1, 0xf1, 0x81, 0x09, 0xa3, 0x56, 0x58, 0x00,
99 0x40, 0xc0, 0x60, 0x38, 0x46, 0x43, 0x57, 0x39,
100 0xd9, 0x59, 0x99, 0xc9, 0x77, 0x2f, 0x2e, 0xc6,
101 0xd6, 0x28, 0xd6, 0x36, 0x26, 0x2e, 0x8a, 0xa3,
102 0x43, 0x63, 0x4b, 0x4a, 0x62, 0x42, 0xa2, 0x8b,
103 0x2f, 0x27, 0x37, 0xd7, 0x29, 0xd7, 0xc7, 0x2f,
104 0x2e, 0x76, 0xc8, 0x98, 0x58, 0xd8, 0x38, 0x56,
105 0x42, 0x47, 0x39, 0x61, 0xc1, 0x41, 0x01, 0x59,
106 0x57, 0xa2, 0x08, 0x80, 0xf0, 0xd0, 0x10, 0x30,
107 0xe0, 0x76, 0x87, 0x21, 0x71, 0x2d, 0xed, 0x2d,
108 0x71, 0x21, 0x9f, 0x88, 0x40, 0x2c, 0x8c, 0x8c,
109 0xec, 0x70, 0x98, 0x1b, 0x59, 0x11, 0x8d, 0xcd,
110 0xcd, 0xed, 0x31, 0x09, 0xb6, 0xc0, 0xec, 0xcc,
111 0x4c, 0xcc, 0xec, 0xc0, 0xc6, 0x49, 0x91, 0x8d,
112 0x4d, 0xbd, 0x0d, 0xad, 0xe1,
113};
114static u32 sizeof_american_ringing = sizeof(sample_american_ringing);
115
116static u8 sample_american_busy[] = {
117 0x2a, 0x00, 0x6c, 0x4c, 0x4c, 0x6c, 0xb0, 0x66,
118 0x99, 0x11, 0x6d, 0x8d, 0x2d, 0x41, 0xd7, 0x96,
119 0x60, 0xf0, 0x70, 0x40, 0x58, 0xf6, 0x53, 0x57,
120 0x09, 0x89, 0xd7, 0x5f, 0xe3, 0x2a, 0xe3, 0x5f,
121 0xd7, 0x89, 0x09, 0x57, 0x53, 0xf6, 0x58, 0x40,
122 0x70, 0xf0, 0x60, 0x96, 0xd7, 0x41, 0x2d, 0x8d,
123 0x6d, 0x11, 0x99, 0x66, 0xb0, 0x6c, 0x4c, 0x4c,
124 0x6c, 0x00, 0x2a, 0x01, 0x6d, 0x4d, 0x4d, 0x6d,
125 0xb1, 0x67, 0x98, 0x10, 0x6c, 0x8c, 0x2c, 0x40,
126 0xd6, 0x97, 0x61, 0xf1, 0x71, 0x41, 0x59, 0xf7,
127 0x52, 0x56, 0x08, 0x88, 0xd6, 0x5e, 0xe2, 0x2a,
128 0xe2, 0x5e, 0xd6, 0x88, 0x08, 0x56, 0x52, 0xf7,
129 0x59, 0x41, 0x71, 0xf1, 0x61, 0x97, 0xd6, 0x40,
130 0x2c, 0x8c, 0x6c, 0x10, 0x98, 0x67, 0xb1, 0x6d,
131 0x4d, 0x4d, 0x6d, 0x01,
132};
133static u32 sizeof_american_busy = sizeof(sample_american_busy);
134
135static u8 sample_special1[] = {
136 0x2a, 0x2c, 0xbc, 0x6c, 0xd6, 0x71, 0xbd, 0x0d,
137 0xd9, 0x80, 0xcc, 0x4c, 0x40, 0x39, 0x0d, 0xbd,
138 0x11, 0x86, 0xec, 0xbc, 0xec, 0x0e, 0x51, 0xbd,
139 0x8d, 0x89, 0x30, 0x4c, 0xcc, 0xe0, 0xe1, 0xcd,
140 0x4d, 0x31, 0x88, 0x8c, 0xbc, 0x50, 0x0f, 0xed,
141 0xbd, 0xed, 0x87, 0x10, 0xbc, 0x0c, 0x38, 0x41,
142 0x4d, 0xcd, 0x81, 0xd8, 0x0c, 0xbc, 0x70, 0xd7,
143 0x6d, 0xbd, 0x2d,
144};
145static u32 sizeof_special1 = sizeof(sample_special1);
146
147static u8 sample_special2[] = {
148 0x2a, 0xcc, 0x8c, 0xd7, 0x4d, 0x2d, 0x18, 0xbc,
149 0x10, 0xc1, 0xbd, 0xc1, 0x10, 0xbc, 0x18, 0x2d,
150 0x4d, 0xd7, 0x8c, 0xcc, 0x2a, 0xcd, 0x8d, 0xd6,
151 0x4c, 0x2c, 0x19, 0xbd, 0x11, 0xc0, 0xbc, 0xc0,
152 0x11, 0xbd, 0x19, 0x2c, 0x4c, 0xd6, 0x8d, 0xcd,
153 0x2a, 0xcc, 0x8c, 0xd7, 0x4d, 0x2d, 0x18, 0xbc,
154 0x10, 0xc1, 0xbd, 0xc1, 0x10, 0xbc, 0x18, 0x2d,
155 0x4d, 0xd7, 0x8c, 0xcc, 0x2a, 0xcd, 0x8d, 0xd6,
156 0x4c, 0x2c, 0x19, 0xbd, 0x11, 0xc0, 0xbc, 0xc0,
157 0x11, 0xbd, 0x19, 0x2c, 0x4c, 0xd6, 0x8d, 0xcd,
158};
159static u32 sizeof_special2 = sizeof(sample_special2);
160
161static u8 sample_special3[] = {
162 0x2a, 0xbc, 0x18, 0xcd, 0x11, 0x2c, 0x8c, 0xc1,
163 0x4d, 0xd6, 0xbc, 0xd6, 0x4d, 0xc1, 0x8c, 0x2c,
164 0x11, 0xcd, 0x18, 0xbc, 0x2a, 0xbd, 0x19, 0xcc,
165 0x10, 0x2d, 0x8d, 0xc0, 0x4c, 0xd7, 0xbd, 0xd7,
166 0x4c, 0xc0, 0x8d, 0x2d, 0x10, 0xcc, 0x19, 0xbd,
167 0x2a, 0xbc, 0x18, 0xcd, 0x11, 0x2c, 0x8c, 0xc1,
168 0x4d, 0xd6, 0xbc, 0xd6, 0x4d, 0xc1, 0x8c, 0x2c,
169 0x11, 0xcd, 0x18, 0xbc, 0x2a, 0xbd, 0x19, 0xcc,
170 0x10, 0x2d, 0x8d, 0xc0, 0x4c, 0xd7, 0xbd, 0xd7,
171 0x4c, 0xc0, 0x8d, 0x2d, 0x10, 0xcc, 0x19, 0xbd,
172};
173static u32 sizeof_special3 = sizeof(sample_special3);
174
175static u8 sample_silence[] = {
176 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
177 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
178 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
179 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
180 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
181 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
182 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
183 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
184 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
185 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
186 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
187 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
188};
189static u32 sizeof_silence = sizeof(sample_silence);
190
191struct tones_samples {
192 u32 *len;
193 u8 *data;
194};
195static struct
196tones_samples samples[] = {
197 {&sizeof_german_all, sample_german_all},
198 {&sizeof_german_old, sample_german_old},
199 {&sizeof_american_dialtone, sample_american_dialtone},
200 {&sizeof_american_ringing, sample_american_ringing},
201 {&sizeof_american_busy, sample_american_busy},
202 {&sizeof_special1, sample_special1},
203 {&sizeof_special2, sample_special2},
204 {&sizeof_special3, sample_special3},
205 {NULL, NULL},
206};
207
208/***********************************
209 * generate ulaw from alaw samples *
210 ***********************************/
211
212void
213dsp_audio_generate_ulaw_samples(void)
214{
215 int i, j;
216
217 i = 0;
218 while (samples[i].len) {
219 j = 0;
220 while (j < (*samples[i].len)) {
221 samples[i].data[j] =
222 dsp_audio_alaw_to_ulaw[samples[i].data[j]];
223 j++;
224 }
225 i++;
226 }
227}
228
229
230/****************************
231 * tone sequence definition *
232 ****************************/
233
234struct pattern {
235 int tone;
236 u8 *data[10];
237 u32 *siz[10];
238 u32 seq[10];
239} pattern[] = {
240 {TONE_GERMAN_DIALTONE,
241 {DATA_GA, 0, 0, 0, 0, 0, 0, 0, 0, 0},
242 {SIZE_GA, 0, 0, 0, 0, 0, 0, 0, 0, 0},
243 {1900, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
244
245 {TONE_GERMAN_OLDDIALTONE,
246 {DATA_GO, 0, 0, 0, 0, 0, 0, 0, 0, 0},
247 {SIZE_GO, 0, 0, 0, 0, 0, 0, 0, 0, 0},
248 {1998, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
249
250 {TONE_AMERICAN_DIALTONE,
251 {DATA_DT, 0, 0, 0, 0, 0, 0, 0, 0, 0},
252 {SIZE_DT, 0, 0, 0, 0, 0, 0, 0, 0, 0},
253 {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
254
255 {TONE_GERMAN_DIALPBX,
256 {DATA_GA, DATA_S, DATA_GA, DATA_S, DATA_GA, DATA_S, 0, 0, 0, 0},
257 {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, 0, 0, 0, 0},
258 {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
259
260 {TONE_GERMAN_OLDDIALPBX,
261 {DATA_GO, DATA_S, DATA_GO, DATA_S, DATA_GO, DATA_S, 0, 0, 0, 0},
262 {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, 0, 0, 0, 0},
263 {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
264
265 {TONE_AMERICAN_DIALPBX,
266 {DATA_DT, DATA_S, DATA_DT, DATA_S, DATA_DT, DATA_S, 0, 0, 0, 0},
267 {SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, SIZE_DT, SIZE_S, 0, 0, 0, 0},
268 {2000, 2000, 2000, 2000, 2000, 12000, 0, 0, 0, 0} },
269
270 {TONE_GERMAN_RINGING,
271 {DATA_GA, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
272 {SIZE_GA, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
273 {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} },
274
275 {TONE_GERMAN_OLDRINGING,
276 {DATA_GO, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
277 {SIZE_GO, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
278 {8000, 40000, 0, 0, 0, 0, 0, 0, 0, 0} },
279
280 {TONE_AMERICAN_RINGING,
281 {DATA_RI, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
282 {SIZE_RI, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
283 {8000, 32000, 0, 0, 0, 0, 0, 0, 0, 0} },
284
285 {TONE_GERMAN_RINGPBX,
286 {DATA_GA, DATA_S, DATA_GA, DATA_S, 0, 0, 0, 0, 0, 0},
287 {SIZE_GA, SIZE_S, SIZE_GA, SIZE_S, 0, 0, 0, 0, 0, 0},
288 {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} },
289
290 {TONE_GERMAN_OLDRINGPBX,
291 {DATA_GO, DATA_S, DATA_GO, DATA_S, 0, 0, 0, 0, 0, 0},
292 {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, 0, 0, 0, 0, 0, 0},
293 {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} },
294
295 {TONE_AMERICAN_RINGPBX,
296 {DATA_RI, DATA_S, DATA_RI, DATA_S, 0, 0, 0, 0, 0, 0},
297 {SIZE_RI, SIZE_S, SIZE_RI, SIZE_S, 0, 0, 0, 0, 0, 0},
298 {4000, 4000, 4000, 28000, 0, 0, 0, 0, 0, 0} },
299
300 {TONE_GERMAN_BUSY,
301 {DATA_GA, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
302 {SIZE_GA, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
303 {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} },
304
305 {TONE_GERMAN_OLDBUSY,
306 {DATA_GO, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
307 {SIZE_GO, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
308 {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} },
309
310 {TONE_AMERICAN_BUSY,
311 {DATA_BU, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
312 {SIZE_BU, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
313 {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} },
314
315 {TONE_GERMAN_HANGUP,
316 {DATA_GA, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
317 {SIZE_GA, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
318 {4000, 4000, 0, 0, 0, 0, 0, 0, 0, 0} },
319
320 {TONE_GERMAN_OLDHANGUP,
321 {DATA_GO, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
322 {SIZE_GO, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
323 {1000, 5000, 0, 0, 0, 0, 0, 0, 0, 0} },
324
325 {TONE_AMERICAN_HANGUP,
326 {DATA_DT, 0, 0, 0, 0, 0, 0, 0, 0, 0},
327 {SIZE_DT, 0, 0, 0, 0, 0, 0, 0, 0, 0},
328 {8000, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
329
330 {TONE_SPECIAL_INFO,
331 {DATA_S1, DATA_S2, DATA_S3, DATA_S, 0, 0, 0, 0, 0, 0},
332 {SIZE_S1, SIZE_S2, SIZE_S3, SIZE_S, 0, 0, 0, 0, 0, 0},
333 {2666, 2666, 2666, 8002, 0, 0, 0, 0, 0, 0} },
334
335 {TONE_GERMAN_GASSENBESETZT,
336 {DATA_GA, DATA_S, 0, 0, 0, 0, 0, 0, 0, 0},
337 {SIZE_GA, SIZE_S, 0, 0, 0, 0, 0, 0, 0, 0},
338 {2000, 2000, 0, 0, 0, 0, 0, 0, 0, 0} },
339
340 {TONE_GERMAN_AUFSCHALTTON,
341 {DATA_GO, DATA_S, DATA_GO, DATA_S, 0, 0, 0, 0, 0, 0},
342 {SIZE_GO, SIZE_S, SIZE_GO, SIZE_S, 0, 0, 0, 0, 0, 0},
343 {1000, 5000, 1000, 17000, 0, 0, 0, 0, 0, 0} },
344
345 {0,
346 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
347 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
348 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
349};
350
351/******************
352 * copy tone data *
353 ******************/
354
355/* an sk_buff is generated from the number of samples needed.
356 * the count will be changed and may begin from 0 each pattern period.
357 * the clue is to precalculate the pointers and legths to use only one
358 * memcpy per function call, or two memcpy if the tone sequence changes.
359 *
360 * pattern - the type of the pattern
361 * count - the sample from the beginning of the pattern (phase)
362 * len - the number of bytes
363 *
364 * return - the sk_buff with the sample
365 *
366 * if tones has finished (e.g. knocking tone), dsp->tones is turned off
367 */
368void dsp_tone_copy(struct dsp *dsp, u8 *data, int len)
369{
370 int index, count, start, num;
371 struct pattern *pat;
372 struct dsp_tone *tone = &dsp->tone;
373
374 /* if we have no tone, we copy silence */
375 if (!tone->tone) {
376 memset(data, dsp_silence, len);
377 return;
378 }
379
380 /* process pattern */
381 pat = (struct pattern *)tone->pattern;
382 /* points to the current pattern */
383 index = tone->index; /* gives current sequence index */
384 count = tone->count; /* gives current sample */
385
386 /* copy sample */
387 while (len) {
388 /* find sample to start with */
389 while (42) {
390 /* warp arround */
391 if (!pat->seq[index]) {
392 count = 0;
393 index = 0;
394 }
395 /* check if we are currently playing this tone */
396 if (count < pat->seq[index])
397 break;
398 if (dsp_debug & DEBUG_DSP_TONE)
399 printk(KERN_DEBUG "%s: reaching next sequence "
400 "(index=%d)\n", __func__, index);
401 count -= pat->seq[index];
402 index++;
403 }
404 /* calculate start and number of samples */
405 start = count % (*(pat->siz[index]));
406 num = len;
407 if (num+count > pat->seq[index])
408 num = pat->seq[index] - count;
409 if (num+start > (*(pat->siz[index])))
410 num = (*(pat->siz[index])) - start;
411 /* copy memory */
412 memcpy(data, pat->data[index]+start, num);
413 /* reduce length */
414 data += num;
415 count += num;
416 len -= num;
417 }
418 tone->index = index;
419 tone->count = count;
420
421 /* return sk_buff */
422 return;
423}
424
425
426/*******************************
427 * send HW message to hfc card *
428 *******************************/
429
430static void
431dsp_tone_hw_message(struct dsp *dsp, u8 *sample, int len)
432{
433 struct sk_buff *nskb;
434
435 /* unlocking is not required, because we don't expect a response */
436 nskb = _alloc_mISDN_skb(PH_CONTROL_REQ,
437 (len)?HFC_SPL_LOOP_ON:HFC_SPL_LOOP_OFF, len, sample,
438 GFP_ATOMIC);
439 if (nskb) {
440 if (dsp->ch.peer) {
441 if (dsp->ch.recv(dsp->ch.peer, nskb))
442 dev_kfree_skb(nskb);
443 } else
444 dev_kfree_skb(nskb);
445 }
446}
447
448
449/*****************
450 * timer expires *
451 *****************/
452void
453dsp_tone_timeout(void *arg)
454{
455 struct dsp *dsp = arg;
456 struct dsp_tone *tone = &dsp->tone;
457 struct pattern *pat = (struct pattern *)tone->pattern;
458 int index = tone->index;
459
460 if (!tone->tone)
461 return;
462
463 index++;
464 if (!pat->seq[index])
465 index = 0;
466 tone->index = index;
467
468 /* set next tone */
469 if (pat->data[index] == DATA_S)
470 dsp_tone_hw_message(dsp, 0, 0);
471 else
472 dsp_tone_hw_message(dsp, pat->data[index], *(pat->siz[index]));
473 /* set timer */
474 init_timer(&tone->tl);
475 tone->tl.expires = jiffies + (pat->seq[index] * HZ) / 8000;
476 add_timer(&tone->tl);
477}
478
479
480/********************
481 * set/release tone *
482 ********************/
483
484/*
485 * tones are relaized by streaming or by special loop commands if supported
486 * by hardware. when hardware is used, the patterns will be controlled by
487 * timers.
488 */
489int
490dsp_tone(struct dsp *dsp, int tone)
491{
492 struct pattern *pat;
493 int i;
494 struct dsp_tone *tonet = &dsp->tone;
495
496 tonet->software = 0;
497 tonet->hardware = 0;
498
499 /* we turn off the tone */
500 if (!tone) {
501 if (dsp->features.hfc_loops)
502 if (timer_pending(&tonet->tl))
503 del_timer(&tonet->tl);
504 if (dsp->features.hfc_loops)
505 dsp_tone_hw_message(dsp, NULL, 0);
506 tonet->tone = 0;
507 return 0;
508 }
509
510 pat = NULL;
511 i = 0;
512 while (pattern[i].tone) {
513 if (pattern[i].tone == tone) {
514 pat = &pattern[i];
515 break;
516 }
517 i++;
518 }
519 if (!pat) {
520 printk(KERN_WARNING "dsp: given tone 0x%x is invalid\n", tone);
521 return -EINVAL;
522 }
523 if (dsp_debug & DEBUG_DSP_TONE)
524 printk(KERN_DEBUG "%s: now starting tone %d (index=%d)\n",
525 __func__, tone, 0);
526 tonet->tone = tone;
527 tonet->pattern = pat;
528 tonet->index = 0;
529 tonet->count = 0;
530
531 if (dsp->features.hfc_loops) {
532 tonet->hardware = 1;
533 /* set first tone */
534 dsp_tone_hw_message(dsp, pat->data[0], *(pat->siz[0]));
535 /* set timer */
536 if (timer_pending(&tonet->tl))
537 del_timer(&tonet->tl);
538 init_timer(&tonet->tl);
539 tonet->tl.expires = jiffies + (pat->seq[0] * HZ) / 8000;
540 add_timer(&tonet->tl);
541 } else {
542 tonet->software = 1;
543 }
544
545 return 0;
546}
547
548
549
550
551
diff --git a/drivers/isdn/mISDN/fsm.c b/drivers/isdn/mISDN/fsm.c
new file mode 100644
index 000000000000..b5d6553f2dc8
--- /dev/null
+++ b/drivers/isdn/mISDN/fsm.c
@@ -0,0 +1,183 @@
1/*
2 * finite state machine implementation
3 *
4 * Author Karsten Keil <kkeil@novell.com>
5 *
6 * Thanks to Jan den Ouden
7 * Fritz Elfert
8 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
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 * 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 */
20
21#include <linux/kernel.h>
22#include <linux/slab.h>
23#include <linux/module.h>
24#include <linux/string.h>
25#include "fsm.h"
26
27#define FSM_TIMER_DEBUG 0
28
29void
30mISDN_FsmNew(struct Fsm *fsm,
31 struct FsmNode *fnlist, int fncount)
32{
33 int i;
34
35 fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
36 fsm->event_count, GFP_KERNEL);
37
38 for (i = 0; i < fncount; i++)
39 if ((fnlist[i].state >= fsm->state_count) ||
40 (fnlist[i].event >= fsm->event_count)) {
41 printk(KERN_ERR
42 "mISDN_FsmNew Error: %d st(%ld/%ld) ev(%ld/%ld)\n",
43 i, (long)fnlist[i].state, (long)fsm->state_count,
44 (long)fnlist[i].event, (long)fsm->event_count);
45 } else
46 fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
47 fnlist[i].state] = (FSMFNPTR) fnlist[i].routine;
48}
49EXPORT_SYMBOL(mISDN_FsmNew);
50
51void
52mISDN_FsmFree(struct Fsm *fsm)
53{
54 kfree((void *) fsm->jumpmatrix);
55}
56EXPORT_SYMBOL(mISDN_FsmFree);
57
58int
59mISDN_FsmEvent(struct FsmInst *fi, int event, void *arg)
60{
61 FSMFNPTR r;
62
63 if ((fi->state >= fi->fsm->state_count) ||
64 (event >= fi->fsm->event_count)) {
65 printk(KERN_ERR
66 "mISDN_FsmEvent Error st(%ld/%ld) ev(%d/%ld)\n",
67 (long)fi->state, (long)fi->fsm->state_count, event,
68 (long)fi->fsm->event_count);
69 return 1;
70 }
71 r = fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state];
72 if (r) {
73 if (fi->debug)
74 fi->printdebug(fi, "State %s Event %s",
75 fi->fsm->strState[fi->state],
76 fi->fsm->strEvent[event]);
77 r(fi, event, arg);
78 return 0;
79 } else {
80 if (fi->debug)
81 fi->printdebug(fi, "State %s Event %s no action",
82 fi->fsm->strState[fi->state],
83 fi->fsm->strEvent[event]);
84 return 1;
85 }
86}
87EXPORT_SYMBOL(mISDN_FsmEvent);
88
89void
90mISDN_FsmChangeState(struct FsmInst *fi, int newstate)
91{
92 fi->state = newstate;
93 if (fi->debug)
94 fi->printdebug(fi, "ChangeState %s",
95 fi->fsm->strState[newstate]);
96}
97EXPORT_SYMBOL(mISDN_FsmChangeState);
98
99static void
100FsmExpireTimer(struct FsmTimer *ft)
101{
102#if FSM_TIMER_DEBUG
103 if (ft->fi->debug)
104 ft->fi->printdebug(ft->fi, "FsmExpireTimer %lx", (long) ft);
105#endif
106 mISDN_FsmEvent(ft->fi, ft->event, ft->arg);
107}
108
109void
110mISDN_FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft)
111{
112 ft->fi = fi;
113 ft->tl.function = (void *) FsmExpireTimer;
114 ft->tl.data = (long) ft;
115#if FSM_TIMER_DEBUG
116 if (ft->fi->debug)
117 ft->fi->printdebug(ft->fi, "mISDN_FsmInitTimer %lx", (long) ft);
118#endif
119 init_timer(&ft->tl);
120}
121EXPORT_SYMBOL(mISDN_FsmInitTimer);
122
123void
124mISDN_FsmDelTimer(struct FsmTimer *ft, int where)
125{
126#if FSM_TIMER_DEBUG
127 if (ft->fi->debug)
128 ft->fi->printdebug(ft->fi, "mISDN_FsmDelTimer %lx %d",
129 (long) ft, where);
130#endif
131 del_timer(&ft->tl);
132}
133EXPORT_SYMBOL(mISDN_FsmDelTimer);
134
135int
136mISDN_FsmAddTimer(struct FsmTimer *ft,
137 int millisec, int event, void *arg, int where)
138{
139
140#if FSM_TIMER_DEBUG
141 if (ft->fi->debug)
142 ft->fi->printdebug(ft->fi, "mISDN_FsmAddTimer %lx %d %d",
143 (long) ft, millisec, where);
144#endif
145
146 if (timer_pending(&ft->tl)) {
147 if (ft->fi->debug) {
148 printk(KERN_WARNING
149 "mISDN_FsmAddTimer: timer already active!\n");
150 ft->fi->printdebug(ft->fi,
151 "mISDN_FsmAddTimer already active!");
152 }
153 return -1;
154 }
155 init_timer(&ft->tl);
156 ft->event = event;
157 ft->arg = arg;
158 ft->tl.expires = jiffies + (millisec * HZ) / 1000;
159 add_timer(&ft->tl);
160 return 0;
161}
162EXPORT_SYMBOL(mISDN_FsmAddTimer);
163
164void
165mISDN_FsmRestartTimer(struct FsmTimer *ft,
166 int millisec, int event, void *arg, int where)
167{
168
169#if FSM_TIMER_DEBUG
170 if (ft->fi->debug)
171 ft->fi->printdebug(ft->fi, "mISDN_FsmRestartTimer %lx %d %d",
172 (long) ft, millisec, where);
173#endif
174
175 if (timer_pending(&ft->tl))
176 del_timer(&ft->tl);
177 init_timer(&ft->tl);
178 ft->event = event;
179 ft->arg = arg;
180 ft->tl.expires = jiffies + (millisec * HZ) / 1000;
181 add_timer(&ft->tl);
182}
183EXPORT_SYMBOL(mISDN_FsmRestartTimer);
diff --git a/drivers/isdn/mISDN/fsm.h b/drivers/isdn/mISDN/fsm.h
new file mode 100644
index 000000000000..928f5be192c1
--- /dev/null
+++ b/drivers/isdn/mISDN/fsm.h
@@ -0,0 +1,67 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Thanks to Jan den Ouden
6 * Fritz Elfert
7 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * 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 */
19
20#ifndef _MISDN_FSM_H
21#define _MISDN_FSM_H
22
23#include <linux/timer.h>
24
25/* Statemachine */
26
27struct FsmInst;
28
29typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
30
31struct Fsm {
32 FSMFNPTR *jumpmatrix;
33 int state_count, event_count;
34 char **strEvent, **strState;
35};
36
37struct FsmInst {
38 struct Fsm *fsm;
39 int state;
40 int debug;
41 void *userdata;
42 int userint;
43 void (*printdebug) (struct FsmInst *, char *, ...);
44};
45
46struct FsmNode {
47 int state, event;
48 void (*routine) (struct FsmInst *, int, void *);
49};
50
51struct FsmTimer {
52 struct FsmInst *fi;
53 struct timer_list tl;
54 int event;
55 void *arg;
56};
57
58extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
59extern void mISDN_FsmFree(struct Fsm *);
60extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
61extern void mISDN_FsmChangeState(struct FsmInst *, int);
62extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *);
63extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int);
64extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
65extern void mISDN_FsmDelTimer(struct FsmTimer *, int);
66
67#endif
diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c
new file mode 100644
index 000000000000..2596fba4e614
--- /dev/null
+++ b/drivers/isdn/mISDN/hwchannel.c
@@ -0,0 +1,365 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18#include <linux/module.h>
19#include <linux/mISDNhw.h>
20
21static void
22dchannel_bh(struct work_struct *ws)
23{
24 struct dchannel *dch = container_of(ws, struct dchannel, workq);
25 struct sk_buff *skb;
26 int err;
27
28 if (test_and_clear_bit(FLG_RECVQUEUE, &dch->Flags)) {
29 while ((skb = skb_dequeue(&dch->rqueue))) {
30 if (likely(dch->dev.D.peer)) {
31 err = dch->dev.D.recv(dch->dev.D.peer, skb);
32 if (err)
33 dev_kfree_skb(skb);
34 } else
35 dev_kfree_skb(skb);
36 }
37 }
38 if (test_and_clear_bit(FLG_PHCHANGE, &dch->Flags)) {
39 if (dch->phfunc)
40 dch->phfunc(dch);
41 }
42}
43
44static void
45bchannel_bh(struct work_struct *ws)
46{
47 struct bchannel *bch = container_of(ws, struct bchannel, workq);
48 struct sk_buff *skb;
49 int err;
50
51 if (test_and_clear_bit(FLG_RECVQUEUE, &bch->Flags)) {
52 while ((skb = skb_dequeue(&bch->rqueue))) {
53 if (bch->rcount >= 64)
54 printk(KERN_WARNING "B-channel %p receive "
55 "queue if full, but empties...\n", bch);
56 bch->rcount--;
57 if (likely(bch->ch.peer)) {
58 err = bch->ch.recv(bch->ch.peer, skb);
59 if (err)
60 dev_kfree_skb(skb);
61 } else
62 dev_kfree_skb(skb);
63 }
64 }
65}
66
67int
68mISDN_initdchannel(struct dchannel *ch, int maxlen, void *phf)
69{
70 test_and_set_bit(FLG_HDLC, &ch->Flags);
71 ch->maxlen = maxlen;
72 ch->hw = NULL;
73 ch->rx_skb = NULL;
74 ch->tx_skb = NULL;
75 ch->tx_idx = 0;
76 ch->phfunc = phf;
77 skb_queue_head_init(&ch->squeue);
78 skb_queue_head_init(&ch->rqueue);
79 INIT_LIST_HEAD(&ch->dev.bchannels);
80 INIT_WORK(&ch->workq, dchannel_bh);
81 return 0;
82}
83EXPORT_SYMBOL(mISDN_initdchannel);
84
85int
86mISDN_initbchannel(struct bchannel *ch, int maxlen)
87{
88 ch->Flags = 0;
89 ch->maxlen = maxlen;
90 ch->hw = NULL;
91 ch->rx_skb = NULL;
92 ch->tx_skb = NULL;
93 ch->tx_idx = 0;
94 skb_queue_head_init(&ch->rqueue);
95 ch->rcount = 0;
96 ch->next_skb = NULL;
97 INIT_WORK(&ch->workq, bchannel_bh);
98 return 0;
99}
100EXPORT_SYMBOL(mISDN_initbchannel);
101
102int
103mISDN_freedchannel(struct dchannel *ch)
104{
105 if (ch->tx_skb) {
106 dev_kfree_skb(ch->tx_skb);
107 ch->tx_skb = NULL;
108 }
109 if (ch->rx_skb) {
110 dev_kfree_skb(ch->rx_skb);
111 ch->rx_skb = NULL;
112 }
113 skb_queue_purge(&ch->squeue);
114 skb_queue_purge(&ch->rqueue);
115 flush_scheduled_work();
116 return 0;
117}
118EXPORT_SYMBOL(mISDN_freedchannel);
119
120int
121mISDN_freebchannel(struct bchannel *ch)
122{
123 if (ch->tx_skb) {
124 dev_kfree_skb(ch->tx_skb);
125 ch->tx_skb = NULL;
126 }
127 if (ch->rx_skb) {
128 dev_kfree_skb(ch->rx_skb);
129 ch->rx_skb = NULL;
130 }
131 if (ch->next_skb) {
132 dev_kfree_skb(ch->next_skb);
133 ch->next_skb = NULL;
134 }
135 skb_queue_purge(&ch->rqueue);
136 ch->rcount = 0;
137 flush_scheduled_work();
138 return 0;
139}
140EXPORT_SYMBOL(mISDN_freebchannel);
141
142static inline u_int
143get_sapi_tei(u_char *p)
144{
145 u_int sapi, tei;
146
147 sapi = *p >> 2;
148 tei = p[1] >> 1;
149 return sapi | (tei << 8);
150}
151
152void
153recv_Dchannel(struct dchannel *dch)
154{
155 struct mISDNhead *hh;
156
157 if (dch->rx_skb->len < 2) { /* at least 2 for sapi / tei */
158 dev_kfree_skb(dch->rx_skb);
159 dch->rx_skb = NULL;
160 return;
161 }
162 hh = mISDN_HEAD_P(dch->rx_skb);
163 hh->prim = PH_DATA_IND;
164 hh->id = get_sapi_tei(dch->rx_skb->data);
165 skb_queue_tail(&dch->rqueue, dch->rx_skb);
166 dch->rx_skb = NULL;
167 schedule_event(dch, FLG_RECVQUEUE);
168}
169EXPORT_SYMBOL(recv_Dchannel);
170
171void
172recv_Bchannel(struct bchannel *bch)
173{
174 struct mISDNhead *hh;
175
176 hh = mISDN_HEAD_P(bch->rx_skb);
177 hh->prim = PH_DATA_IND;
178 hh->id = MISDN_ID_ANY;
179 if (bch->rcount >= 64) {
180 dev_kfree_skb(bch->rx_skb);
181 bch->rx_skb = NULL;
182 return;
183 }
184 bch->rcount++;
185 skb_queue_tail(&bch->rqueue, bch->rx_skb);
186 bch->rx_skb = NULL;
187 schedule_event(bch, FLG_RECVQUEUE);
188}
189EXPORT_SYMBOL(recv_Bchannel);
190
191void
192recv_Dchannel_skb(struct dchannel *dch, struct sk_buff *skb)
193{
194 skb_queue_tail(&dch->rqueue, skb);
195 schedule_event(dch, FLG_RECVQUEUE);
196}
197EXPORT_SYMBOL(recv_Dchannel_skb);
198
199void
200recv_Bchannel_skb(struct bchannel *bch, struct sk_buff *skb)
201{
202 if (bch->rcount >= 64) {
203 dev_kfree_skb(skb);
204 return;
205 }
206 bch->rcount++;
207 skb_queue_tail(&bch->rqueue, skb);
208 schedule_event(bch, FLG_RECVQUEUE);
209}
210EXPORT_SYMBOL(recv_Bchannel_skb);
211
212static void
213confirm_Dsend(struct dchannel *dch)
214{
215 struct sk_buff *skb;
216
217 skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(dch->tx_skb),
218 0, NULL, GFP_ATOMIC);
219 if (!skb) {
220 printk(KERN_ERR "%s: no skb id %x\n", __func__,
221 mISDN_HEAD_ID(dch->tx_skb));
222 return;
223 }
224 skb_queue_tail(&dch->rqueue, skb);
225 schedule_event(dch, FLG_RECVQUEUE);
226}
227
228int
229get_next_dframe(struct dchannel *dch)
230{
231 dch->tx_idx = 0;
232 dch->tx_skb = skb_dequeue(&dch->squeue);
233 if (dch->tx_skb) {
234 confirm_Dsend(dch);
235 return 1;
236 }
237 dch->tx_skb = NULL;
238 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
239 return 0;
240}
241EXPORT_SYMBOL(get_next_dframe);
242
243void
244confirm_Bsend(struct bchannel *bch)
245{
246 struct sk_buff *skb;
247
248 if (bch->rcount >= 64)
249 return;
250 skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(bch->tx_skb),
251 0, NULL, GFP_ATOMIC);
252 if (!skb) {
253 printk(KERN_ERR "%s: no skb id %x\n", __func__,
254 mISDN_HEAD_ID(bch->tx_skb));
255 return;
256 }
257 bch->rcount++;
258 skb_queue_tail(&bch->rqueue, skb);
259 schedule_event(bch, FLG_RECVQUEUE);
260}
261EXPORT_SYMBOL(confirm_Bsend);
262
263int
264get_next_bframe(struct bchannel *bch)
265{
266 bch->tx_idx = 0;
267 if (test_bit(FLG_TX_NEXT, &bch->Flags)) {
268 bch->tx_skb = bch->next_skb;
269 if (bch->tx_skb) {
270 bch->next_skb = NULL;
271 test_and_clear_bit(FLG_TX_NEXT, &bch->Flags);
272 if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
273 confirm_Bsend(bch); /* not for transparent */
274 return 1;
275 } else {
276 test_and_clear_bit(FLG_TX_NEXT, &bch->Flags);
277 printk(KERN_WARNING "B TX_NEXT without skb\n");
278 }
279 }
280 bch->tx_skb = NULL;
281 test_and_clear_bit(FLG_TX_BUSY, &bch->Flags);
282 return 0;
283}
284EXPORT_SYMBOL(get_next_bframe);
285
286void
287queue_ch_frame(struct mISDNchannel *ch, u_int pr, int id, struct sk_buff *skb)
288{
289 struct mISDNhead *hh;
290
291 if (!skb) {
292 _queue_data(ch, pr, id, 0, NULL, GFP_ATOMIC);
293 } else {
294 if (ch->peer) {
295 hh = mISDN_HEAD_P(skb);
296 hh->prim = pr;
297 hh->id = id;
298 if (!ch->recv(ch->peer, skb))
299 return;
300 }
301 dev_kfree_skb(skb);
302 }
303}
304EXPORT_SYMBOL(queue_ch_frame);
305
306int
307dchannel_senddata(struct dchannel *ch, struct sk_buff *skb)
308{
309 /* check oversize */
310 if (skb->len <= 0) {
311 printk(KERN_WARNING "%s: skb too small\n", __func__);
312 return -EINVAL;
313 }
314 if (skb->len > ch->maxlen) {
315 printk(KERN_WARNING "%s: skb too large(%d/%d)\n",
316 __func__, skb->len, ch->maxlen);
317 return -EINVAL;
318 }
319 /* HW lock must be obtained */
320 if (test_and_set_bit(FLG_TX_BUSY, &ch->Flags)) {
321 skb_queue_tail(&ch->squeue, skb);
322 return 0;
323 } else {
324 /* write to fifo */
325 ch->tx_skb = skb;
326 ch->tx_idx = 0;
327 return 1;
328 }
329}
330EXPORT_SYMBOL(dchannel_senddata);
331
332int
333bchannel_senddata(struct bchannel *ch, struct sk_buff *skb)
334{
335
336 /* check oversize */
337 if (skb->len <= 0) {
338 printk(KERN_WARNING "%s: skb too small\n", __func__);
339 return -EINVAL;
340 }
341 if (skb->len > ch->maxlen) {
342 printk(KERN_WARNING "%s: skb too large(%d/%d)\n",
343 __func__, skb->len, ch->maxlen);
344 return -EINVAL;
345 }
346 /* HW lock must be obtained */
347 /* check for pending next_skb */
348 if (ch->next_skb) {
349 printk(KERN_WARNING
350 "%s: next_skb exist ERROR (skb->len=%d next_skb->len=%d)\n",
351 __func__, skb->len, ch->next_skb->len);
352 return -EBUSY;
353 }
354 if (test_and_set_bit(FLG_TX_BUSY, &ch->Flags)) {
355 test_and_set_bit(FLG_TX_NEXT, &ch->Flags);
356 ch->next_skb = skb;
357 return 0;
358 } else {
359 /* write to fifo */
360 ch->tx_skb = skb;
361 ch->tx_idx = 0;
362 return 1;
363 }
364}
365EXPORT_SYMBOL(bchannel_senddata);
diff --git a/drivers/isdn/mISDN/l1oip.h b/drivers/isdn/mISDN/l1oip.h
new file mode 100644
index 000000000000..a23d575449f6
--- /dev/null
+++ b/drivers/isdn/mISDN/l1oip.h
@@ -0,0 +1,91 @@
1/*
2 * see notice in l1oip.c
3 */
4
5/* debugging */
6#define DEBUG_L1OIP_INIT 0x00010000
7#define DEBUG_L1OIP_SOCKET 0x00020000
8#define DEBUG_L1OIP_MGR 0x00040000
9#define DEBUG_L1OIP_MSG 0x00080000
10
11/* enable to disorder received bchannels by sequence 2143658798... */
12/*
13#define REORDER_DEBUG
14*/
15
16/* frames */
17#define L1OIP_MAX_LEN 2048 /* max packet size form l2 */
18#define L1OIP_MAX_PERFRAME 1400 /* max data size in one frame */
19
20
21/* timers */
22#define L1OIP_KEEPALIVE 15
23#define L1OIP_TIMEOUT 65
24
25
26/* socket */
27#define L1OIP_DEFAULTPORT 931
28
29
30/* channel structure */
31struct l1oip_chan {
32 struct dchannel *dch;
33 struct bchannel *bch;
34 u32 tx_counter; /* counts xmit bytes/packets */
35 u32 rx_counter; /* counts recv bytes/packets */
36 u32 codecstate; /* used by codec to save data */
37#ifdef REORDER_DEBUG
38 int disorder_flag;
39 struct sk_buff *disorder_skb;
40 u32 disorder_cnt;
41#endif
42};
43
44
45/* card structure */
46struct l1oip {
47 struct list_head list;
48
49 /* card */
50 int registered; /* if registered with mISDN */
51 char name[MISDN_MAX_IDLEN];
52 int idx; /* card index */
53 int pri; /* 1=pri, 0=bri */
54 int d_idx; /* current dchannel number */
55 int b_num; /* number of bchannels */
56 u32 id; /* id of connection */
57 int ondemand; /* if transmis. is on demand */
58 int bundle; /* bundle channels in one frm */
59 int codec; /* codec to use for transmis. */
60 int limit; /* limit number of bchannels */
61
62 /* timer */
63 struct timer_list keep_tl;
64 struct timer_list timeout_tl;
65 int timeout_on;
66 struct work_struct workq;
67
68 /* socket */
69 struct socket *socket; /* if set, socket is created */
70 struct completion socket_complete;/* completion of sock thread */
71 struct task_struct *socket_thread;
72 spinlock_t socket_lock; /* access sock outside thread */
73 u32 remoteip; /* if all set, ip is assigned */
74 u16 localport; /* must always be set */
75 u16 remoteport; /* must always be set */
76 struct sockaddr_in sin_local; /* local socket name */
77 struct sockaddr_in sin_remote; /* remote socket name */
78 struct msghdr sendmsg; /* ip message to send */
79 struct iovec sendiov; /* iov for message */
80
81 /* frame */
82 struct l1oip_chan chan[128]; /* channel instances */
83};
84
85extern int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state);
86extern int l1oip_4bit_to_law(u8 *data, int len, u8 *result);
87extern int l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result);
88extern int l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result);
89extern void l1oip_4bit_free(void);
90extern int l1oip_4bit_alloc(int ulaw);
91
diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
new file mode 100644
index 000000000000..a2dc4570ef43
--- /dev/null
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -0,0 +1,374 @@
1/*
2
3 * l1oip_codec.c generic codec using lookup table
4 * -> conversion from a-Law to u-Law
5 * -> conversion from u-Law to a-Law
6 * -> compression by reducing the number of sample resolution to 4
7 *
8 * NOTE: It is not compatible with any standard codec like ADPCM.
9 *
10 * Author Andreas Eversberg (jolly@eversberg.eu)
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
26 */
27
28/*
29
30How the codec works:
31--------------------
32
33The volume is increased to increase the dynamic range of the audio signal.
34Each sample is converted to a-LAW with only 16 steps of level resolution.
35A pair of two samples are stored in one byte.
36
37The first byte is stored in the upper bits, the second byte is stored in the
38lower bits.
39
40To speed up compression and decompression, two lookup tables are formed:
41
42- 16 bits index for two samples (law encoded) with 8 bit compressed result.
43- 8 bits index for one compressed data with 16 bits decompressed result.
44
45NOTE: The bytes are handled as they are law-encoded.
46
47*/
48
49#include <linux/vmalloc.h>
50#include <linux/mISDNif.h>
51#include "core.h"
52
53/* definitions of codec. don't use calculations, code may run slower. */
54
55static u8 *table_com;
56static u16 *table_dec;
57
58
59/* alaw -> ulaw */
60static u8 alaw_to_ulaw[256] =
61{
62 0xab, 0x2b, 0xe3, 0x63, 0x8b, 0x0b, 0xc9, 0x49,
63 0xba, 0x3a, 0xf6, 0x76, 0x9b, 0x1b, 0xd7, 0x57,
64 0xa3, 0x23, 0xdd, 0x5d, 0x83, 0x03, 0xc1, 0x41,
65 0xb2, 0x32, 0xeb, 0x6b, 0x93, 0x13, 0xcf, 0x4f,
66 0xaf, 0x2f, 0xe7, 0x67, 0x8f, 0x0f, 0xcd, 0x4d,
67 0xbe, 0x3e, 0xfe, 0x7e, 0x9f, 0x1f, 0xdb, 0x5b,
68 0xa7, 0x27, 0xdf, 0x5f, 0x87, 0x07, 0xc5, 0x45,
69 0xb6, 0x36, 0xef, 0x6f, 0x97, 0x17, 0xd3, 0x53,
70 0xa9, 0x29, 0xe1, 0x61, 0x89, 0x09, 0xc7, 0x47,
71 0xb8, 0x38, 0xf2, 0x72, 0x99, 0x19, 0xd5, 0x55,
72 0xa1, 0x21, 0xdc, 0x5c, 0x81, 0x01, 0xbf, 0x3f,
73 0xb0, 0x30, 0xe9, 0x69, 0x91, 0x11, 0xce, 0x4e,
74 0xad, 0x2d, 0xe5, 0x65, 0x8d, 0x0d, 0xcb, 0x4b,
75 0xbc, 0x3c, 0xfa, 0x7a, 0x9d, 0x1d, 0xd9, 0x59,
76 0xa5, 0x25, 0xde, 0x5e, 0x85, 0x05, 0xc3, 0x43,
77 0xb4, 0x34, 0xed, 0x6d, 0x95, 0x15, 0xd1, 0x51,
78 0xac, 0x2c, 0xe4, 0x64, 0x8c, 0x0c, 0xca, 0x4a,
79 0xbb, 0x3b, 0xf8, 0x78, 0x9c, 0x1c, 0xd8, 0x58,
80 0xa4, 0x24, 0xde, 0x5e, 0x84, 0x04, 0xc2, 0x42,
81 0xb3, 0x33, 0xec, 0x6c, 0x94, 0x14, 0xd0, 0x50,
82 0xb0, 0x30, 0xe8, 0x68, 0x90, 0x10, 0xce, 0x4e,
83 0xbf, 0x3f, 0xfe, 0x7e, 0xa0, 0x20, 0xdc, 0x5c,
84 0xa8, 0x28, 0xe0, 0x60, 0x88, 0x08, 0xc6, 0x46,
85 0xb7, 0x37, 0xf0, 0x70, 0x98, 0x18, 0xd4, 0x54,
86 0xaa, 0x2a, 0xe2, 0x62, 0x8a, 0x0a, 0xc8, 0x48,
87 0xb9, 0x39, 0xf4, 0x74, 0x9a, 0x1a, 0xd6, 0x56,
88 0xa2, 0x22, 0xdd, 0x5d, 0x82, 0x02, 0xc0, 0x40,
89 0xb1, 0x31, 0xea, 0x6a, 0x92, 0x12, 0xcf, 0x4f,
90 0xae, 0x2e, 0xe6, 0x66, 0x8e, 0x0e, 0xcc, 0x4c,
91 0xbd, 0x3d, 0xfc, 0x7c, 0x9e, 0x1e, 0xda, 0x5a,
92 0xa6, 0x26, 0xdf, 0x5f, 0x86, 0x06, 0xc4, 0x44,
93 0xb5, 0x35, 0xee, 0x6e, 0x96, 0x16, 0xd2, 0x52
94};
95
96/* ulaw -> alaw */
97static u8 ulaw_to_alaw[256] =
98{
99 0xab, 0x55, 0xd5, 0x15, 0x95, 0x75, 0xf5, 0x35,
100 0xb5, 0x45, 0xc5, 0x05, 0x85, 0x65, 0xe5, 0x25,
101 0xa5, 0x5d, 0xdd, 0x1d, 0x9d, 0x7d, 0xfd, 0x3d,
102 0xbd, 0x4d, 0xcd, 0x0d, 0x8d, 0x6d, 0xed, 0x2d,
103 0xad, 0x51, 0xd1, 0x11, 0x91, 0x71, 0xf1, 0x31,
104 0xb1, 0x41, 0xc1, 0x01, 0x81, 0x61, 0xe1, 0x21,
105 0x59, 0xd9, 0x19, 0x99, 0x79, 0xf9, 0x39, 0xb9,
106 0x49, 0xc9, 0x09, 0x89, 0x69, 0xe9, 0x29, 0xa9,
107 0xd7, 0x17, 0x97, 0x77, 0xf7, 0x37, 0xb7, 0x47,
108 0xc7, 0x07, 0x87, 0x67, 0xe7, 0x27, 0xa7, 0xdf,
109 0x9f, 0x7f, 0xff, 0x3f, 0xbf, 0x4f, 0xcf, 0x0f,
110 0x8f, 0x6f, 0xef, 0x2f, 0x53, 0x13, 0x73, 0x33,
111 0xb3, 0x43, 0xc3, 0x03, 0x83, 0x63, 0xe3, 0x23,
112 0xa3, 0x5b, 0xdb, 0x1b, 0x9b, 0x7b, 0xfb, 0x3b,
113 0xbb, 0xbb, 0x4b, 0x4b, 0xcb, 0xcb, 0x0b, 0x0b,
114 0x8b, 0x8b, 0x6b, 0x6b, 0xeb, 0xeb, 0x2b, 0x2b,
115 0xab, 0x54, 0xd4, 0x14, 0x94, 0x74, 0xf4, 0x34,
116 0xb4, 0x44, 0xc4, 0x04, 0x84, 0x64, 0xe4, 0x24,
117 0xa4, 0x5c, 0xdc, 0x1c, 0x9c, 0x7c, 0xfc, 0x3c,
118 0xbc, 0x4c, 0xcc, 0x0c, 0x8c, 0x6c, 0xec, 0x2c,
119 0xac, 0x50, 0xd0, 0x10, 0x90, 0x70, 0xf0, 0x30,
120 0xb0, 0x40, 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x20,
121 0x58, 0xd8, 0x18, 0x98, 0x78, 0xf8, 0x38, 0xb8,
122 0x48, 0xc8, 0x08, 0x88, 0x68, 0xe8, 0x28, 0xa8,
123 0xd6, 0x16, 0x96, 0x76, 0xf6, 0x36, 0xb6, 0x46,
124 0xc6, 0x06, 0x86, 0x66, 0xe6, 0x26, 0xa6, 0xde,
125 0x9e, 0x7e, 0xfe, 0x3e, 0xbe, 0x4e, 0xce, 0x0e,
126 0x8e, 0x6e, 0xee, 0x2e, 0x52, 0x12, 0x72, 0x32,
127 0xb2, 0x42, 0xc2, 0x02, 0x82, 0x62, 0xe2, 0x22,
128 0xa2, 0x5a, 0xda, 0x1a, 0x9a, 0x7a, 0xfa, 0x3a,
129 0xba, 0xba, 0x4a, 0x4a, 0xca, 0xca, 0x0a, 0x0a,
130 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a, 0x2a
131};
132
133/* alaw -> 4bit compression */
134static u8 alaw_to_4bit[256] = {
135 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
136 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
137 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
138 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
139 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
140 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
141 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
142 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
143 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
144 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
145 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0d, 0x02,
146 0x0e, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
147 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
148 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
149 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
150 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
151 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
152 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
153 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
154 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
155 0x0e, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
156 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x01, 0x0a, 0x05,
157 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
158 0x0d, 0x02, 0x09, 0x07, 0x0f, 0x00, 0x0b, 0x04,
159 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
160 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
161 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
162 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
163 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
164 0x0d, 0x02, 0x08, 0x07, 0x0f, 0x00, 0x0b, 0x04,
165 0x0e, 0x01, 0x0a, 0x05, 0x0f, 0x00, 0x0c, 0x03,
166 0x0d, 0x02, 0x09, 0x06, 0x0f, 0x00, 0x0b, 0x04,
167};
168
169/* 4bit -> alaw decompression */
170static u8 _4bit_to_alaw[16] = {
171 0x5d, 0x51, 0xd9, 0xd7, 0x5f, 0x53, 0xa3, 0x4b,
172 0x2a, 0x3a, 0x22, 0x2e, 0x26, 0x56, 0x20, 0x2c,
173};
174
175/* ulaw -> 4bit compression */
176static u8 ulaw_to_4bit[256] = {
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
182 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
183 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
184 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
185 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
186 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
187 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
188 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05,
189 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
190 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
191 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
192 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08,
193 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
194 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
195 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
196 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
197 0x0f, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
198 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e,
199 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
200 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
201 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
202 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0b, 0x0b,
203 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
204 0x0b, 0x0b, 0x0b, 0x0b, 0x0a, 0x0a, 0x0a, 0x0a,
205 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
206 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
207 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
208 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
209};
210
211/* 4bit -> ulaw decompression */
212static u8 _4bit_to_ulaw[16] = {
213 0x11, 0x21, 0x31, 0x40, 0x4e, 0x5c, 0x68, 0x71,
214 0xfe, 0xef, 0xe7, 0xdb, 0xcd, 0xbf, 0xaf, 0x9f,
215};
216
217
218/*
219 * Compresses data to the result buffer
220 * The result size must be at least half of the input buffer.
221 * The number of samples also must be even!
222 */
223int
224l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state)
225{
226 int ii, i = 0, o = 0;
227
228 if (!len)
229 return 0;
230
231 /* send saved byte and first input byte */
232 if (*state) {
233 *result++ = table_com[(((*state)<<8)&0xff00) | (*data++)];
234 len--;
235 o++;
236 }
237
238 ii = len >> 1;
239
240 while (i < ii) {
241 *result++ = table_com[(data[0]<<8) | (data[1])];
242 data += 2;
243 i++;
244 o++;
245 }
246
247 /* if len has an odd number, we save byte for next call */
248 if (len & 1)
249 *state = 0x100 + *data;
250 else
251 *state = 0;
252
253 return o;
254}
255
256/* Decompress data to the result buffer
257 * The result size must be the number of sample in packet. (2 * input data)
258 * The number of samples in the result are even!
259 */
260int
261l1oip_4bit_to_law(u8 *data, int len, u8 *result)
262{
263 int i = 0;
264 u16 r;
265
266 while (i < len) {
267 r = table_dec[*data++];
268 *result++ = r>>8;
269 *result++ = r;
270 i++;
271 }
272
273 return len << 1;
274}
275
276
277/*
278 * law conversion
279 */
280int
281l1oip_alaw_to_ulaw(u8 *data, int len, u8 *result)
282{
283 int i = 0;
284
285 while (i < len) {
286 *result++ = alaw_to_ulaw[*data++];
287 i++;
288 }
289
290 return len;
291}
292
293int
294l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
295{
296 int i = 0;
297
298 while (i < len) {
299 *result++ = ulaw_to_alaw[*data++];
300 i++;
301 }
302
303 return len;
304}
305
306
307/*
308 * generate/free compression and decompression table
309 */
310void
311l1oip_4bit_free(void)
312{
313 if (table_dec)
314 vfree(table_dec);
315 if (table_com)
316 vfree(table_com);
317 table_com = NULL;
318 table_dec = NULL;
319}
320
321int
322l1oip_4bit_alloc(int ulaw)
323{
324 int i1, i2, c, sample;
325
326 /* in case, it is called again */
327 if (table_dec)
328 return 0;
329
330 /* alloc conversion tables */
331 table_com = vmalloc(65536);
332 table_dec = vmalloc(512);
333 if (!table_com | !table_dec) {
334 l1oip_4bit_free();
335 return -ENOMEM;
336 }
337 memset(table_com, 0, 65536);
338 memset(table_dec, 0, 512);
339 /* generate compression table */
340 i1 = 0;
341 while (i1 < 256) {
342 if (ulaw)
343 c = ulaw_to_4bit[i1];
344 else
345 c = alaw_to_4bit[i1];
346 i2 = 0;
347 while (i2 < 256) {
348 table_com[(i1<<8) | i2] |= (c<<4);
349 table_com[(i2<<8) | i1] |= c;
350 i2++;
351 }
352 i1++;
353 }
354
355 /* generate decompression table */
356 i1 = 0;
357 while (i1 < 16) {
358 if (ulaw)
359 sample = _4bit_to_ulaw[i1];
360 else
361 sample = _4bit_to_alaw[i1];
362 i2 = 0;
363 while (i2 < 16) {
364 table_dec[(i1<<4) | i2] |= (sample<<8);
365 table_dec[(i2<<4) | i1] |= sample;
366 i2++;
367 }
368 i1++;
369 }
370
371 return 0;
372}
373
374
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
new file mode 100644
index 000000000000..155b99780c4f
--- /dev/null
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -0,0 +1,1518 @@
1/*
2
3 * l1oip.c low level driver for tunneling layer 1 over IP
4 *
5 * NOTE: It is not compatible with TDMoIP nor "ISDN over IP".
6 *
7 * Author Andreas Eversberg (jolly@eversberg.eu)
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/* module parameters:
26 * type:
27 Value 1 = BRI
28 Value 2 = PRI
29 Value 3 = BRI (multi channel frame, not supported yet)
30 Value 4 = PRI (multi channel frame, not supported yet)
31 A multi channel frame reduces overhead to a single frame for all
32 b-channels, but increases delay.
33 (NOTE: Multi channel frames are not implemented yet.)
34
35 * codec:
36 Value 0 = transparent (default)
37 Value 1 = transfer ALAW
38 Value 2 = transfer ULAW
39 Value 3 = transfer generic 4 bit compression.
40
41 * ulaw:
42 0 = we use a-Law (default)
43 1 = we use u-Law
44
45 * limit:
46 limitation of B-channels to control bandwidth (1...126)
47 BRI: 1 or 2
48 PRI: 1-30, 31-126 (126, because dchannel ist not counted here)
49 Also limited ressources are used for stack, resulting in less channels.
50 It is possible to have more channels than 30 in PRI mode, this must
51 be supported by the application.
52
53 * ip:
54 byte representation of remote ip address (127.0.0.1 -> 127,0,0,1)
55 If not given or four 0, no remote address is set.
56 For multiple interfaces, concat ip addresses. (127,0,0,1,127,0,0,1)
57
58 * port:
59 port number (local interface)
60 If not given or 0, port 931 is used for fist instance, 932 for next...
61 For multiple interfaces, different ports must be given.
62
63 * remoteport:
64 port number (remote interface)
65 If not given or 0, remote port equals local port
66 For multiple interfaces on equal sites, different ports must be given.
67
68 * ondemand:
69 0 = fixed (always transmit packets, even when remote side timed out)
70 1 = on demand (only transmit packets, when remote side is detected)
71 the default is 0
72 NOTE: ID must also be set for on demand.
73
74 * id:
75 optional value to identify frames. This value must be equal on both
76 peers and should be random. If omitted or 0, no ID is transmitted.
77
78 * debug:
79 NOTE: only one debug value must be given for all cards
80 enable debugging (see l1oip.h for debug options)
81
82
83Special mISDN controls:
84
85 op = MISDN_CTRL_SETPEER*
86 p1 = bytes 0-3 : remote IP address in network order (left element first)
87 p2 = bytes 1-2 : remote port in network order (high byte first)
88 optional:
89 p2 = bytes 3-4 : local port in network order (high byte first)
90
91 op = MISDN_CTRL_UNSETPEER*
92
93 * Use l1oipctrl for comfortable setting or removing ip address.
94 (Layer 1 Over IP CTRL)
95
96
97L1oIP-Protocol
98--------------
99
100Frame Header:
101
102 7 6 5 4 3 2 1 0
103+---------------+
104|Ver|T|I|Coding |
105+---------------+
106| ID byte 3 * |
107+---------------+
108| ID byte 2 * |
109+---------------+
110| ID byte 1 * |
111+---------------+
112| ID byte 0 * |
113+---------------+
114|M| Channel |
115+---------------+
116| Length * |
117+---------------+
118| Time Base MSB |
119+---------------+
120| Time Base LSB |
121+---------------+
122| Data.... |
123
124...
125
126| |
127+---------------+
128|M| Channel |
129+---------------+
130| Length * |
131+---------------+
132| Time Base MSB |
133+---------------+
134| Time Base LSB |
135+---------------+
136| Data.... |
137
138...
139
140
141* Only included in some cases.
142
143- Ver = Version
144If version is missmatch, the frame must be ignored.
145
146- T = Type of interface
147Must be 0 for S0 or 1 for E1.
148
149- I = Id present
150If bit is set, four ID bytes are included in frame.
151
152- ID = Connection ID
153Additional ID to prevent Denial of Service attacs. Also it prevents hijacking
154connections with dynamic IP. The ID should be random and must not be 0.
155
156- Coding = Type of codec
157Must be 0 for no transcoding. Also for D-channel and other HDLC frames.
158 1 and 2 are reserved for explicitly use of a-LAW or u-LAW codec.
159 3 is used for generic table compressor.
160
161- M = More channels to come. If this flag is 1, the following byte contains
162the length of the channel data. After the data block, the next channel will
163be defined. The flag for the last channel block (or if only one channel is
164transmitted), must be 0 and no length is given.
165
166- Channel = Channel number
1670 reserved
1681-3 channel data for S0 (3 is D-channel)
1691-31 channel data for E1 (16 is D-channel)
17032-127 channel data for extended E1 (16 is D-channel)
171
172- The length is used if the M-flag is 1. It is used to find the next channel
173inside frame.
174NOTE: A value of 0 equals 256 bytes of data.
175 -> For larger data blocks, a single frame must be used.
176 -> For larger streams, a single frame or multiple blocks with same channel ID
177 must be used.
178
179- Time Base = Timestamp of first sample in frame
180The "Time Base" is used to rearange packets and to detect packet loss.
181The 16 bits are sent in network order (MSB first) and count 1/8000 th of a
182second. This causes a wrap arround each 8,192 seconds. There is no requirement
183for the initial "Time Base", but 0 should be used for the first packet.
184In case of HDLC data, this timestamp counts the packet or byte number.
185
186
187Two Timers:
188
189After initialisation, a timer of 15 seconds is started. Whenever a packet is
190transmitted, the timer is reset to 15 seconds again. If the timer expires, an
191empty packet is transmitted. This keep the connection alive.
192
193When a valid packet is received, a timer 65 seconds is started. The interface
194become ACTIVE. If the timer expires, the interface becomes INACTIVE.
195
196
197Dynamic IP handling:
198
199To allow dynamic IP, the ID must be non 0. In this case, any packet with the
200correct port number and ID will be accepted. If the remote side changes its IP
201the new IP is used for all transmitted packets until it changes again.
202
203
204On Demand:
205
206If the ondemand parameter is given, the remote IP is set to 0 on timeout.
207This will stop keepalive traffic to remote. If the remote is online again,
208traffic will continue to the remote address. This is usefull for road warriors.
209This feature only works with ID set, otherwhise it is highly unsecure.
210
211
212Socket and Thread
213-----------------
214
215The complete socket opening and closing is done by a thread.
216When the thread opened a socket, the hc->socket descriptor is set. Whenever a
217packet shall be sent to the socket, the hc->socket must be checked wheter not
218NULL. To prevent change in socket descriptor, the hc->socket_lock must be used.
219To change the socket, a recall of l1oip_socket_open() will safely kill the
220socket process and create a new one.
221
222*/
223
224#define L1OIP_VERSION 0 /* 0...3 */
225
226#include <linux/module.h>
227#include <linux/delay.h>
228#include <linux/mISDNif.h>
229#include <linux/mISDNhw.h>
230#include <linux/mISDNdsp.h>
231#include <linux/init.h>
232#include <linux/in.h>
233#include <linux/inet.h>
234#include <linux/workqueue.h>
235#include <linux/kthread.h>
236#include <net/sock.h>
237#include "core.h"
238#include "l1oip.h"
239
240static const char *l1oip_revision = "2.00";
241
242static int l1oip_cnt;
243static spinlock_t l1oip_lock;
244static struct list_head l1oip_ilist;
245
246#define MAX_CARDS 16
247static u_int type[MAX_CARDS];
248static u_int codec[MAX_CARDS];
249static u_int ip[MAX_CARDS*4];
250static u_int port[MAX_CARDS];
251static u_int remoteport[MAX_CARDS];
252static u_int ondemand[MAX_CARDS];
253static u_int limit[MAX_CARDS];
254static u_int id[MAX_CARDS];
255static int debug;
256static int ulaw;
257
258MODULE_AUTHOR("Andreas Eversberg");
259MODULE_LICENSE("GPL");
260module_param_array(type, uint, NULL, S_IRUGO | S_IWUSR);
261module_param_array(codec, uint, NULL, S_IRUGO | S_IWUSR);
262module_param_array(ip, uint, NULL, S_IRUGO | S_IWUSR);
263module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR);
264module_param_array(remoteport, uint, NULL, S_IRUGO | S_IWUSR);
265module_param_array(ondemand, uint, NULL, S_IRUGO | S_IWUSR);
266module_param_array(limit, uint, NULL, S_IRUGO | S_IWUSR);
267module_param_array(id, uint, NULL, S_IRUGO | S_IWUSR);
268module_param(ulaw, uint, S_IRUGO | S_IWUSR);
269module_param(debug, uint, S_IRUGO | S_IWUSR);
270
271/*
272 * send a frame via socket, if open and restart timer
273 */
274static int
275l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask,
276 u16 timebase, u8 *buf, int len)
277{
278 u8 *p;
279 int multi = 0;
280 u8 frame[len+32];
281 struct socket *socket = NULL;
282 mm_segment_t oldfs;
283
284 if (debug & DEBUG_L1OIP_MSG)
285 printk(KERN_DEBUG "%s: sending data to socket (len = %d)\n",
286 __func__, len);
287
288 p = frame;
289
290 /* restart timer */
291 if ((int)(hc->keep_tl.expires-jiffies) < 5*HZ) {
292 del_timer(&hc->keep_tl);
293 hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE*HZ;
294 add_timer(&hc->keep_tl);
295 } else
296 hc->keep_tl.expires = jiffies + L1OIP_KEEPALIVE*HZ;
297
298 if (debug & DEBUG_L1OIP_MSG)
299 printk(KERN_DEBUG "%s: resetting timer\n", __func__);
300
301 /* drop if we have no remote ip or port */
302 if (!hc->sin_remote.sin_addr.s_addr || !hc->sin_remote.sin_port) {
303 if (debug & DEBUG_L1OIP_MSG)
304 printk(KERN_DEBUG "%s: dropping frame, because remote "
305 "IP is not set.\n", __func__);
306 return len;
307 }
308
309 /* assemble frame */
310 *p++ = (L1OIP_VERSION<<6) /* version and coding */
311 | (hc->pri?0x20:0x00) /* type */
312 | (hc->id?0x10:0x00) /* id */
313 | localcodec;
314 if (hc->id) {
315 *p++ = hc->id>>24; /* id */
316 *p++ = hc->id>>16;
317 *p++ = hc->id>>8;
318 *p++ = hc->id;
319 }
320 *p++ = (multi == 1)?0x80:0x00 + channel; /* m-flag, channel */
321 if (multi == 1)
322 *p++ = len; /* length */
323 *p++ = timebase>>8; /* time base */
324 *p++ = timebase;
325
326 if (buf && len) { /* add data to frame */
327 if (localcodec == 1 && ulaw)
328 l1oip_ulaw_to_alaw(buf, len, p);
329 else if (localcodec == 2 && !ulaw)
330 l1oip_alaw_to_ulaw(buf, len, p);
331 else if (localcodec == 3)
332 len = l1oip_law_to_4bit(buf, len, p,
333 &hc->chan[channel].codecstate);
334 else
335 memcpy(p, buf, len);
336 }
337 len += p - frame;
338
339 /* check for socket in safe condition */
340 spin_lock(&hc->socket_lock);
341 if (!hc->socket) {
342 spin_unlock(&hc->socket_lock);
343 return 0;
344 }
345 /* seize socket */
346 socket = hc->socket;
347 hc->socket = NULL;
348 spin_unlock(&hc->socket_lock);
349 /* send packet */
350 if (debug & DEBUG_L1OIP_MSG)
351 printk(KERN_DEBUG "%s: sending packet to socket (len "
352 "= %d)\n", __func__, len);
353 hc->sendiov.iov_base = frame;
354 hc->sendiov.iov_len = len;
355 oldfs = get_fs();
356 set_fs(KERNEL_DS);
357 len = sock_sendmsg(socket, &hc->sendmsg, len);
358 set_fs(oldfs);
359 /* give socket back */
360 hc->socket = socket; /* no locking required */
361
362 return len;
363}
364
365
366/*
367 * receive channel data from socket
368 */
369static void
370l1oip_socket_recv(struct l1oip *hc, u8 remotecodec, u8 channel, u16 timebase,
371 u8 *buf, int len)
372{
373 struct sk_buff *nskb;
374 struct bchannel *bch;
375 struct dchannel *dch;
376 u8 *p;
377 u32 rx_counter;
378
379 if (len == 0) {
380 if (debug & DEBUG_L1OIP_MSG)
381 printk(KERN_DEBUG "%s: received empty keepalive data, "
382 "ignoring\n", __func__);
383 return;
384 }
385
386 if (debug & DEBUG_L1OIP_MSG)
387 printk(KERN_DEBUG "%s: received data, sending to mISDN (%d)\n",
388 __func__, len);
389
390 if (channel < 1 || channel > 127) {
391 printk(KERN_WARNING "%s: packet error - channel %d out of "
392 "range\n", __func__, channel);
393 return;
394 }
395 dch = hc->chan[channel].dch;
396 bch = hc->chan[channel].bch;
397 if (!dch && !bch) {
398 printk(KERN_WARNING "%s: packet error - channel %d not in "
399 "stack\n", __func__, channel);
400 return;
401 }
402
403 /* prepare message */
404 nskb = mI_alloc_skb((remotecodec == 3)?(len<<1):len, GFP_ATOMIC);
405 if (!nskb) {
406 printk(KERN_ERR "%s: No mem for skb.\n", __func__);
407 return;
408 }
409 p = skb_put(nskb, (remotecodec == 3)?(len<<1):len);
410
411 if (remotecodec == 1 && ulaw)
412 l1oip_alaw_to_ulaw(buf, len, p);
413 else if (remotecodec == 2 && !ulaw)
414 l1oip_ulaw_to_alaw(buf, len, p);
415 else if (remotecodec == 3)
416 len = l1oip_4bit_to_law(buf, len, p);
417 else
418 memcpy(p, buf, len);
419
420 /* send message up */
421 if (dch && len >= 2) {
422 dch->rx_skb = nskb;
423 recv_Dchannel(dch);
424 }
425 if (bch) {
426 /* expand 16 bit sequence number to 32 bit sequence number */
427 rx_counter = hc->chan[channel].rx_counter;
428 if (((s16)(timebase - rx_counter)) >= 0) {
429 /* time has changed forward */
430 if (timebase >= (rx_counter & 0xffff))
431 rx_counter =
432 (rx_counter & 0xffff0000) | timebase;
433 else
434 rx_counter = ((rx_counter & 0xffff0000)+0x10000)
435 | timebase;
436 } else {
437 /* time has changed backwards */
438 if (timebase < (rx_counter & 0xffff))
439 rx_counter =
440 (rx_counter & 0xffff0000) | timebase;
441 else
442 rx_counter = ((rx_counter & 0xffff0000)-0x10000)
443 | timebase;
444 }
445 hc->chan[channel].rx_counter = rx_counter;
446
447#ifdef REORDER_DEBUG
448 if (hc->chan[channel].disorder_flag) {
449 struct sk_buff *skb;
450 int cnt;
451 skb = hc->chan[channel].disorder_skb;
452 hc->chan[channel].disorder_skb = nskb;
453 nskb = skb;
454 cnt = hc->chan[channel].disorder_cnt;
455 hc->chan[channel].disorder_cnt = rx_counter;
456 rx_counter = cnt;
457 }
458 hc->chan[channel].disorder_flag ^= 1;
459 if (nskb)
460#endif
461 queue_ch_frame(&bch->ch, PH_DATA_IND, rx_counter, nskb);
462 }
463}
464
465
466/*
467 * parse frame and extract channel data
468 */
469static void
470l1oip_socket_parse(struct l1oip *hc, struct sockaddr_in *sin, u8 *buf, int len)
471{
472 u32 id;
473 u8 channel;
474 u8 remotecodec;
475 u16 timebase;
476 int m, mlen;
477 int len_start = len; /* initial frame length */
478 struct dchannel *dch = hc->chan[hc->d_idx].dch;
479
480 if (debug & DEBUG_L1OIP_MSG)
481 printk(KERN_DEBUG "%s: received frame, parsing... (%d)\n",
482 __func__, len);
483
484 /* check lenght */
485 if (len < 1+1+2) {
486 printk(KERN_WARNING "%s: packet error - length %d below "
487 "4 bytes\n", __func__, len);
488 return;
489 }
490
491 /* check version */
492 if (((*buf)>>6) != L1OIP_VERSION) {
493 printk(KERN_WARNING "%s: packet error - unknown version %d\n",
494 __func__, buf[0]>>6);
495 return;
496 }
497
498 /* check type */
499 if (((*buf)&0x20) && !hc->pri) {
500 printk(KERN_WARNING "%s: packet error - received E1 packet "
501 "on S0 interface\n", __func__);
502 return;
503 }
504 if (!((*buf)&0x20) && hc->pri) {
505 printk(KERN_WARNING "%s: packet error - received S0 packet "
506 "on E1 interface\n", __func__);
507 return;
508 }
509
510 /* get id flag */
511 id = (*buf>>4)&1;
512
513 /* check coding */
514 remotecodec = (*buf) & 0x0f;
515 if (remotecodec > 3) {
516 printk(KERN_WARNING "%s: packet error - remotecodec %d "
517 "unsupported\n", __func__, remotecodec);
518 return;
519 }
520 buf++;
521 len--;
522
523 /* check id */
524 if (id) {
525 if (!hc->id) {
526 printk(KERN_WARNING "%s: packet error - packet has id "
527 "0x%x, but we have not\n", __func__, id);
528 return;
529 }
530 if (len < 4) {
531 printk(KERN_WARNING "%s: packet error - packet too "
532 "short for ID value\n", __func__);
533 return;
534 }
535 id = (*buf++) << 24;
536 id += (*buf++) << 16;
537 id += (*buf++) << 8;
538 id += (*buf++);
539 len -= 4;
540
541 if (id != hc->id) {
542 printk(KERN_WARNING "%s: packet error - ID mismatch, "
543 "got 0x%x, we 0x%x\n",
544 __func__, id, hc->id);
545 return;
546 }
547 } else {
548 if (hc->id) {
549 printk(KERN_WARNING "%s: packet error - packet has no "
550 "ID, but we have\n", __func__);
551 return;
552 }
553 }
554
555multiframe:
556 if (len < 1) {
557 printk(KERN_WARNING "%s: packet error - packet too short, "
558 "channel expected at position %d.\n",
559 __func__, len-len_start+1);
560 return;
561 }
562
563 /* get channel and multiframe flag */
564 channel = *buf&0x7f;
565 m = *buf >> 7;
566 buf++;
567 len--;
568
569 /* check length on multiframe */
570 if (m) {
571 if (len < 1) {
572 printk(KERN_WARNING "%s: packet error - packet too "
573 "short, length expected at position %d.\n",
574 __func__, len_start-len-1);
575 return;
576 }
577
578 mlen = *buf++;
579 len--;
580 if (mlen == 0)
581 mlen = 256;
582 if (len < mlen+3) {
583 printk(KERN_WARNING "%s: packet error - length %d at "
584 "position %d exceeds total length %d.\n",
585 __func__, mlen, len_start-len-1, len_start);
586 return;
587 }
588 if (len == mlen+3) {
589 printk(KERN_WARNING "%s: packet error - length %d at "
590 "position %d will not allow additional "
591 "packet.\n",
592 __func__, mlen, len_start-len+1);
593 return;
594 }
595 } else
596 mlen = len-2; /* single frame, substract timebase */
597
598 if (len < 2) {
599 printk(KERN_WARNING "%s: packet error - packet too short, time "
600 "base expected at position %d.\n",
601 __func__, len-len_start+1);
602 return;
603 }
604
605 /* get time base */
606 timebase = (*buf++) << 8;
607 timebase |= (*buf++);
608 len -= 2;
609
610 /* if inactive, we send up a PH_ACTIVATE and activate */
611 if (!test_bit(FLG_ACTIVE, &dch->Flags)) {
612 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
613 printk(KERN_DEBUG "%s: interface become active due to "
614 "received packet\n", __func__);
615 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
616 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
617 NULL, GFP_ATOMIC);
618 }
619
620 /* distribute packet */
621 l1oip_socket_recv(hc, remotecodec, channel, timebase, buf, mlen);
622 buf += mlen;
623 len -= mlen;
624
625 /* multiframe */
626 if (m)
627 goto multiframe;
628
629 /* restart timer */
630 if ((int)(hc->timeout_tl.expires-jiffies) < 5*HZ || !hc->timeout_on) {
631 hc->timeout_on = 1;
632 del_timer(&hc->timeout_tl);
633 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT*HZ;
634 add_timer(&hc->timeout_tl);
635 } else /* only adjust timer */
636 hc->timeout_tl.expires = jiffies + L1OIP_TIMEOUT*HZ;
637
638 /* if ip or source port changes */
639 if ((hc->sin_remote.sin_addr.s_addr != sin->sin_addr.s_addr)
640 || (hc->sin_remote.sin_port != sin->sin_port)) {
641 if (debug & DEBUG_L1OIP_SOCKET)
642 printk(KERN_DEBUG "%s: remote address changes from "
643 "0x%08x to 0x%08x (port %d to %d)\n", __func__,
644 ntohl(hc->sin_remote.sin_addr.s_addr),
645 ntohl(sin->sin_addr.s_addr),
646 ntohs(hc->sin_remote.sin_port),
647 ntohs(sin->sin_port));
648 hc->sin_remote.sin_addr.s_addr = sin->sin_addr.s_addr;
649 hc->sin_remote.sin_port = sin->sin_port;
650 }
651}
652
653
654/*
655 * socket stuff
656 */
657static int
658l1oip_socket_thread(void *data)
659{
660 struct l1oip *hc = (struct l1oip *)data;
661 int ret = 0;
662 struct msghdr msg;
663 struct iovec iov;
664 mm_segment_t oldfs;
665 struct sockaddr_in sin_rx;
666 unsigned char recvbuf[1500];
667 int recvlen;
668 struct socket *socket = NULL;
669 DECLARE_COMPLETION(wait);
670
671 /* make daemon */
672 allow_signal(SIGTERM);
673
674 /* create socket */
675 if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) {
676 printk(KERN_ERR "%s: Failed to create socket.\n", __func__);
677 return -EIO;
678 }
679
680 /* set incoming address */
681 hc->sin_local.sin_family = AF_INET;
682 hc->sin_local.sin_addr.s_addr = INADDR_ANY;
683 hc->sin_local.sin_port = htons((unsigned short)hc->localport);
684
685 /* set outgoing address */
686 hc->sin_remote.sin_family = AF_INET;
687 hc->sin_remote.sin_addr.s_addr = htonl(hc->remoteip);
688 hc->sin_remote.sin_port = htons((unsigned short)hc->remoteport);
689
690 /* bind to incomming port */
691 if (socket->ops->bind(socket, (struct sockaddr *)&hc->sin_local,
692 sizeof(hc->sin_local))) {
693 printk(KERN_ERR "%s: Failed to bind socket to port %d.\n",
694 __func__, hc->localport);
695 ret = -EINVAL;
696 goto fail;
697 }
698
699 /* check sk */
700 if (socket->sk == NULL) {
701 printk(KERN_ERR "%s: socket->sk == NULL\n", __func__);
702 ret = -EIO;
703 goto fail;
704 }
705
706 /* build receive message */
707 msg.msg_name = &sin_rx;
708 msg.msg_namelen = sizeof(sin_rx);
709 msg.msg_control = NULL;
710 msg.msg_controllen = 0;
711 msg.msg_iov = &iov;
712 msg.msg_iovlen = 1;
713
714 /* build send message */
715 hc->sendmsg.msg_name = &hc->sin_remote;
716 hc->sendmsg.msg_namelen = sizeof(hc->sin_remote);
717 hc->sendmsg.msg_control = NULL;
718 hc->sendmsg.msg_controllen = 0;
719 hc->sendmsg.msg_iov = &hc->sendiov;
720 hc->sendmsg.msg_iovlen = 1;
721
722 /* give away socket */
723 spin_lock(&hc->socket_lock);
724 hc->socket = socket;
725 spin_unlock(&hc->socket_lock);
726
727 /* read loop */
728 if (debug & DEBUG_L1OIP_SOCKET)
729 printk(KERN_DEBUG "%s: socket created and open\n",
730 __func__);
731 while (!signal_pending(current)) {
732 iov.iov_base = recvbuf;
733 iov.iov_len = sizeof(recvbuf);
734 oldfs = get_fs();
735 set_fs(KERNEL_DS);
736 recvlen = sock_recvmsg(socket, &msg, sizeof(recvbuf), 0);
737 set_fs(oldfs);
738 if (recvlen > 0) {
739 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
740 } else {
741 if (debug & DEBUG_L1OIP_SOCKET)
742 printk(KERN_WARNING "%s: broken pipe on socket\n",
743 __func__);
744 }
745 }
746
747 /* get socket back, check first if in use, maybe by send function */
748 spin_lock(&hc->socket_lock);
749 /* if hc->socket is NULL, it is in use until it is given back */
750 while (!hc->socket) {
751 spin_unlock(&hc->socket_lock);
752 schedule_timeout(HZ/10);
753 spin_lock(&hc->socket_lock);
754 }
755 hc->socket = NULL;
756 spin_unlock(&hc->socket_lock);
757
758 if (debug & DEBUG_L1OIP_SOCKET)
759 printk(KERN_DEBUG "%s: socket thread terminating\n",
760 __func__);
761
762fail:
763 /* close socket */
764 if (socket)
765 sock_release(socket);
766
767 /* if we got killed, signal completion */
768 complete(&hc->socket_complete);
769 hc->socket_thread = NULL; /* show termination of thread */
770
771 if (debug & DEBUG_L1OIP_SOCKET)
772 printk(KERN_DEBUG "%s: socket thread terminated\n",
773 __func__);
774 return ret;
775}
776
777static void
778l1oip_socket_close(struct l1oip *hc)
779{
780 /* kill thread */
781 if (hc->socket_thread) {
782 if (debug & DEBUG_L1OIP_SOCKET)
783 printk(KERN_DEBUG "%s: socket thread exists, "
784 "killing...\n", __func__);
785 send_sig(SIGTERM, hc->socket_thread, 0);
786 wait_for_completion(&hc->socket_complete);
787 }
788}
789
790static int
791l1oip_socket_open(struct l1oip *hc)
792{
793 /* in case of reopen, we need to close first */
794 l1oip_socket_close(hc);
795
796 init_completion(&hc->socket_complete);
797
798 /* create receive process */
799 hc->socket_thread = kthread_run(l1oip_socket_thread, hc, "l1oip_%s",
800 hc->name);
801 if (IS_ERR(hc->socket_thread)) {
802 int err = PTR_ERR(hc->socket_thread);
803 printk(KERN_ERR "%s: Failed (%d) to create socket process.\n",
804 __func__, err);
805 hc->socket_thread = NULL;
806 sock_release(hc->socket);
807 return err;
808 }
809 if (debug & DEBUG_L1OIP_SOCKET)
810 printk(KERN_DEBUG "%s: socket thread created\n", __func__);
811
812 return 0;
813}
814
815
816static void
817l1oip_send_bh(struct work_struct *work)
818{
819 struct l1oip *hc = container_of(work, struct l1oip, workq);
820
821 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
822 printk(KERN_DEBUG "%s: keepalive timer expired, sending empty "
823 "frame on dchannel\n", __func__);
824
825 /* send an empty l1oip frame at D-channel */
826 l1oip_socket_send(hc, 0, hc->d_idx, 0, 0, NULL, 0);
827}
828
829
830/*
831 * timer stuff
832 */
833static void
834l1oip_keepalive(void *data)
835{
836 struct l1oip *hc = (struct l1oip *)data;
837
838 schedule_work(&hc->workq);
839}
840
841static void
842l1oip_timeout(void *data)
843{
844 struct l1oip *hc = (struct l1oip *)data;
845 struct dchannel *dch = hc->chan[hc->d_idx].dch;
846
847 if (debug & DEBUG_L1OIP_MSG)
848 printk(KERN_DEBUG "%s: timeout timer expired, turn layer one "
849 "down.\n", __func__);
850
851 hc->timeout_on = 0; /* state that timer must be initialized next time */
852
853 /* if timeout, we send up a PH_DEACTIVATE and deactivate */
854 if (test_bit(FLG_ACTIVE, &dch->Flags)) {
855 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
856 printk(KERN_DEBUG "%s: interface become deactivated "
857 "due to timeout\n", __func__);
858 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
859 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
860 NULL, GFP_ATOMIC);
861 }
862
863 /* if we have ondemand set, we remove ip address */
864 if (hc->ondemand) {
865 if (debug & DEBUG_L1OIP_MSG)
866 printk(KERN_DEBUG "%s: on demand causes ip address to "
867 "be removed\n", __func__);
868 hc->sin_remote.sin_addr.s_addr = 0;
869 }
870}
871
872
873/*
874 * message handling
875 */
876static int
877handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb)
878{
879 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
880 struct dchannel *dch = container_of(dev, struct dchannel, dev);
881 struct l1oip *hc = dch->hw;
882 struct mISDNhead *hh = mISDN_HEAD_P(skb);
883 int ret = -EINVAL;
884 int l, ll;
885 unsigned char *p;
886
887 switch (hh->prim) {
888 case PH_DATA_REQ:
889 if (skb->len < 1) {
890 printk(KERN_WARNING "%s: skb too small\n",
891 __func__);
892 break;
893 }
894 if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) {
895 printk(KERN_WARNING "%s: skb too large\n",
896 __func__);
897 break;
898 }
899 /* send frame */
900 p = skb->data;
901 l = skb->len;
902 while (l) {
903 ll = (l < L1OIP_MAX_PERFRAME)?l:L1OIP_MAX_PERFRAME;
904 l1oip_socket_send(hc, 0, dch->slot, 0,
905 hc->chan[dch->slot].tx_counter++, p, ll);
906 p += ll;
907 l -= ll;
908 }
909 skb_trim(skb, 0);
910 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb);
911 return 0;
912 case PH_ACTIVATE_REQ:
913 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
914 printk(KERN_DEBUG "%s: PH_ACTIVATE channel %d (1..%d)\n"
915 , __func__, dch->slot, hc->b_num+1);
916 skb_trim(skb, 0);
917 if (test_bit(FLG_ACTIVE, &dch->Flags))
918 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb);
919 else
920 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb);
921 return 0;
922 case PH_DEACTIVATE_REQ:
923 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
924 printk(KERN_DEBUG "%s: PH_DEACTIVATE channel %d "
925 "(1..%d)\n", __func__, dch->slot,
926 hc->b_num+1);
927 skb_trim(skb, 0);
928 if (test_bit(FLG_ACTIVE, &dch->Flags))
929 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb);
930 else
931 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb);
932 return 0;
933 }
934 if (!ret)
935 dev_kfree_skb(skb);
936 return ret;
937}
938
939static int
940channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq)
941{
942 int ret = 0;
943 struct l1oip *hc = dch->hw;
944
945 switch (cq->op) {
946 case MISDN_CTRL_GETOP:
947 cq->op = MISDN_CTRL_SETPEER | MISDN_CTRL_UNSETPEER;
948 break;
949 case MISDN_CTRL_SETPEER:
950 hc->remoteip = (u32)cq->p1;
951 hc->remoteport = cq->p2 & 0xffff;
952 hc->localport = cq->p2 >> 16;
953 if (!hc->remoteport)
954 hc->remoteport = hc->localport;
955 if (debug & DEBUG_L1OIP_SOCKET)
956 printk(KERN_DEBUG "%s: got new ip address from user "
957 "space.\n", __func__);
958 l1oip_socket_open(hc);
959 break;
960 case MISDN_CTRL_UNSETPEER:
961 if (debug & DEBUG_L1OIP_SOCKET)
962 printk(KERN_DEBUG "%s: removing ip address.\n",
963 __func__);
964 hc->remoteip = 0;
965 l1oip_socket_open(hc);
966 break;
967 default:
968 printk(KERN_WARNING "%s: unknown Op %x\n",
969 __func__, cq->op);
970 ret = -EINVAL;
971 break;
972 }
973 return ret;
974}
975
976static int
977open_dchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq)
978{
979 if (debug & DEBUG_HW_OPEN)
980 printk(KERN_DEBUG "%s: dev(%d) open from %p\n", __func__,
981 dch->dev.id, __builtin_return_address(0));
982 if (rq->protocol == ISDN_P_NONE)
983 return -EINVAL;
984 if ((dch->dev.D.protocol != ISDN_P_NONE) &&
985 (dch->dev.D.protocol != rq->protocol)) {
986 if (debug & DEBUG_HW_OPEN)
987 printk(KERN_WARNING "%s: change protocol %x to %x\n",
988 __func__, dch->dev.D.protocol, rq->protocol);
989 }
990 if (dch->dev.D.protocol != rq->protocol)
991 dch->dev.D.protocol = rq->protocol;
992
993 if (test_bit(FLG_ACTIVE, &dch->Flags)) {
994 _queue_data(&dch->dev.D, PH_ACTIVATE_IND, MISDN_ID_ANY,
995 0, NULL, GFP_KERNEL);
996 }
997 rq->ch = &dch->dev.D;
998 if (!try_module_get(THIS_MODULE))
999 printk(KERN_WARNING "%s:cannot get module\n", __func__);
1000 return 0;
1001}
1002
1003static int
1004open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq)
1005{
1006 struct bchannel *bch;
1007 int ch;
1008
1009 if (!test_bit(rq->adr.channel & 0x1f,
1010 &dch->dev.channelmap[rq->adr.channel >> 5]))
1011 return -EINVAL;
1012 if (rq->protocol == ISDN_P_NONE)
1013 return -EINVAL;
1014 ch = rq->adr.channel; /* BRI: 1=B1 2=B2 PRI: 1..15,17.. */
1015 bch = hc->chan[ch].bch;
1016 if (!bch) {
1017 printk(KERN_ERR "%s:internal error ch %d has no bch\n",
1018 __func__, ch);
1019 return -EINVAL;
1020 }
1021 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
1022 return -EBUSY; /* b-channel can be only open once */
1023 bch->ch.protocol = rq->protocol;
1024 rq->ch = &bch->ch;
1025 if (!try_module_get(THIS_MODULE))
1026 printk(KERN_WARNING "%s:cannot get module\n", __func__);
1027 return 0;
1028}
1029
1030static int
1031l1oip_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1032{
1033 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
1034 struct dchannel *dch = container_of(dev, struct dchannel, dev);
1035 struct l1oip *hc = dch->hw;
1036 struct channel_req *rq;
1037 int err = 0;
1038
1039 if (dch->debug & DEBUG_HW)
1040 printk(KERN_DEBUG "%s: cmd:%x %p\n",
1041 __func__, cmd, arg);
1042 switch (cmd) {
1043 case OPEN_CHANNEL:
1044 rq = arg;
1045 switch (rq->protocol) {
1046 case ISDN_P_TE_S0:
1047 case ISDN_P_NT_S0:
1048 if (hc->pri) {
1049 err = -EINVAL;
1050 break;
1051 }
1052 err = open_dchannel(hc, dch, rq);
1053 break;
1054 case ISDN_P_TE_E1:
1055 case ISDN_P_NT_E1:
1056 if (!hc->pri) {
1057 err = -EINVAL;
1058 break;
1059 }
1060 err = open_dchannel(hc, dch, rq);
1061 break;
1062 default:
1063 err = open_bchannel(hc, dch, rq);
1064 }
1065 break;
1066 case CLOSE_CHANNEL:
1067 if (debug & DEBUG_HW_OPEN)
1068 printk(KERN_DEBUG "%s: dev(%d) close from %p\n",
1069 __func__, dch->dev.id,
1070 __builtin_return_address(0));
1071 module_put(THIS_MODULE);
1072 break;
1073 case CONTROL_CHANNEL:
1074 err = channel_dctrl(dch, arg);
1075 break;
1076 default:
1077 if (dch->debug & DEBUG_HW)
1078 printk(KERN_DEBUG "%s: unknown command %x\n",
1079 __func__, cmd);
1080 err = -EINVAL;
1081 }
1082 return err;
1083}
1084
1085static int
1086handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
1087{
1088 struct bchannel *bch = container_of(ch, struct bchannel, ch);
1089 struct l1oip *hc = bch->hw;
1090 int ret = -EINVAL;
1091 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1092 int l, ll, i;
1093 unsigned char *p;
1094
1095 switch (hh->prim) {
1096 case PH_DATA_REQ:
1097 if (skb->len <= 0) {
1098 printk(KERN_WARNING "%s: skb too small\n",
1099 __func__);
1100 break;
1101 }
1102 if (skb->len > MAX_DFRAME_LEN_L1 || skb->len > L1OIP_MAX_LEN) {
1103 printk(KERN_WARNING "%s: skb too large\n",
1104 __func__);
1105 break;
1106 }
1107 /* check for AIS / ulaw-silence */
1108 p = skb->data;
1109 l = skb->len;
1110 for (i = 0; i < l; i++) {
1111 if (*p++ != 0xff)
1112 break;
1113 }
1114 if (i == l) {
1115 if (debug & DEBUG_L1OIP_MSG)
1116 printk(KERN_DEBUG "%s: got AIS, not sending, "
1117 "but counting\n", __func__);
1118 hc->chan[bch->slot].tx_counter += l;
1119 skb_trim(skb, 0);
1120 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb);
1121 return 0;
1122 }
1123 /* check for silence */
1124 p = skb->data;
1125 l = skb->len;
1126 for (i = 0; i < l; i++) {
1127 if (*p++ != 0x2a)
1128 break;
1129 }
1130 if (i == l) {
1131 if (debug & DEBUG_L1OIP_MSG)
1132 printk(KERN_DEBUG "%s: got silence, not sending"
1133 ", but counting\n", __func__);
1134 hc->chan[bch->slot].tx_counter += l;
1135 skb_trim(skb, 0);
1136 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb);
1137 return 0;
1138 }
1139
1140 /* send frame */
1141 p = skb->data;
1142 l = skb->len;
1143 while (l) {
1144 ll = (l < L1OIP_MAX_PERFRAME)?l:L1OIP_MAX_PERFRAME;
1145 l1oip_socket_send(hc, hc->codec, bch->slot, 0,
1146 hc->chan[bch->slot].tx_counter, p, ll);
1147 hc->chan[bch->slot].tx_counter += ll;
1148 p += ll;
1149 l -= ll;
1150 }
1151 skb_trim(skb, 0);
1152 queue_ch_frame(ch, PH_DATA_CNF, hh->id, skb);
1153 return 0;
1154 case PH_ACTIVATE_REQ:
1155 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
1156 printk(KERN_DEBUG "%s: PH_ACTIVATE channel %d (1..%d)\n"
1157 , __func__, bch->slot, hc->b_num+1);
1158 hc->chan[bch->slot].codecstate = 0;
1159 test_and_set_bit(FLG_ACTIVE, &bch->Flags);
1160 skb_trim(skb, 0);
1161 queue_ch_frame(ch, PH_ACTIVATE_IND, hh->id, skb);
1162 return 0;
1163 case PH_DEACTIVATE_REQ:
1164 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
1165 printk(KERN_DEBUG "%s: PH_DEACTIVATE channel %d "
1166 "(1..%d)\n", __func__, bch->slot,
1167 hc->b_num+1);
1168 test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
1169 skb_trim(skb, 0);
1170 queue_ch_frame(ch, PH_DEACTIVATE_IND, hh->id, skb);
1171 return 0;
1172 }
1173 if (!ret)
1174 dev_kfree_skb(skb);
1175 return ret;
1176}
1177
1178static int
1179channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
1180{
1181 int ret = 0;
1182 struct dsp_features *features =
1183 (struct dsp_features *)(*((u_long *)&cq->p1));
1184
1185 switch (cq->op) {
1186 case MISDN_CTRL_GETOP:
1187 cq->op = MISDN_CTRL_HW_FEATURES_OP;
1188 break;
1189 case MISDN_CTRL_HW_FEATURES: /* fill features structure */
1190 if (debug & DEBUG_L1OIP_MSG)
1191 printk(KERN_DEBUG "%s: HW_FEATURE request\n",
1192 __func__);
1193 /* create confirm */
1194 features->unclocked = 1;
1195 features->unordered = 1;
1196 break;
1197 default:
1198 printk(KERN_WARNING "%s: unknown Op %x\n",
1199 __func__, cq->op);
1200 ret = -EINVAL;
1201 break;
1202 }
1203 return ret;
1204}
1205
1206static int
1207l1oip_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1208{
1209 struct bchannel *bch = container_of(ch, struct bchannel, ch);
1210 int err = -EINVAL;
1211
1212 if (bch->debug & DEBUG_HW)
1213 printk(KERN_DEBUG "%s: cmd:%x %p\n",
1214 __func__, cmd, arg);
1215 switch (cmd) {
1216 case CLOSE_CHANNEL:
1217 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1218 test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
1219 ch->protocol = ISDN_P_NONE;
1220 ch->peer = NULL;
1221 module_put(THIS_MODULE);
1222 err = 0;
1223 break;
1224 case CONTROL_CHANNEL:
1225 err = channel_bctrl(bch, arg);
1226 break;
1227 default:
1228 printk(KERN_WARNING "%s: unknown prim(%x)\n",
1229 __func__, cmd);
1230 }
1231 return err;
1232}
1233
1234
1235/*
1236 * cleanup module and stack
1237 */
1238static void
1239release_card(struct l1oip *hc)
1240{
1241 int ch;
1242
1243 if (timer_pending(&hc->keep_tl))
1244 del_timer(&hc->keep_tl);
1245
1246 if (timer_pending(&hc->timeout_tl))
1247 del_timer(&hc->timeout_tl);
1248
1249 if (hc->socket_thread)
1250 l1oip_socket_close(hc);
1251
1252 if (hc->registered && hc->chan[hc->d_idx].dch)
1253 mISDN_unregister_device(&hc->chan[hc->d_idx].dch->dev);
1254 for (ch = 0; ch < 128; ch++) {
1255 if (hc->chan[ch].dch) {
1256 mISDN_freedchannel(hc->chan[ch].dch);
1257 kfree(hc->chan[ch].dch);
1258 }
1259 if (hc->chan[ch].bch) {
1260 mISDN_freebchannel(hc->chan[ch].bch);
1261 kfree(hc->chan[ch].bch);
1262#ifdef REORDER_DEBUG
1263 if (hc->chan[ch].disorder_skb)
1264 dev_kfree_skb(hc->chan[ch].disorder_skb);
1265#endif
1266 }
1267 }
1268
1269 spin_lock(&l1oip_lock);
1270 list_del(&hc->list);
1271 spin_unlock(&l1oip_lock);
1272
1273 kfree(hc);
1274}
1275
1276static void
1277l1oip_cleanup(void)
1278{
1279 struct l1oip *hc, *next;
1280
1281 list_for_each_entry_safe(hc, next, &l1oip_ilist, list)
1282 release_card(hc);
1283
1284 l1oip_4bit_free();
1285}
1286
1287
1288/*
1289 * module and stack init
1290 */
1291static int
1292init_card(struct l1oip *hc, int pri, int bundle)
1293{
1294 struct dchannel *dch;
1295 struct bchannel *bch;
1296 int ret;
1297 int i, ch;
1298
1299 spin_lock_init(&hc->socket_lock);
1300 hc->idx = l1oip_cnt;
1301 hc->pri = pri;
1302 hc->d_idx = pri?16:3;
1303 hc->b_num = pri?30:2;
1304 hc->bundle = bundle;
1305 if (hc->pri)
1306 sprintf(hc->name, "l1oip-e1.%d", l1oip_cnt + 1);
1307 else
1308 sprintf(hc->name, "l1oip-s0.%d", l1oip_cnt + 1);
1309
1310 switch (codec[l1oip_cnt]) {
1311 case 0: /* as is */
1312 case 1: /* alaw */
1313 case 2: /* ulaw */
1314 case 3: /* 4bit */
1315 break;
1316 default:
1317 printk(KERN_ERR "Codec(%d) not supported.\n",
1318 codec[l1oip_cnt]);
1319 return -EINVAL;
1320 }
1321 hc->codec = codec[l1oip_cnt];
1322 if (debug & DEBUG_L1OIP_INIT)
1323 printk(KERN_DEBUG "%s: using codec %d\n",
1324 __func__, hc->codec);
1325
1326 if (id[l1oip_cnt] == 0) {
1327 printk(KERN_WARNING "Warning: No 'id' value given or "
1328 "0, this is highly unsecure. Please use 32 "
1329 "bit randmom number 0x...\n");
1330 }
1331 hc->id = id[l1oip_cnt];
1332 if (debug & DEBUG_L1OIP_INIT)
1333 printk(KERN_DEBUG "%s: using id 0x%x\n", __func__, hc->id);
1334
1335 hc->ondemand = ondemand[l1oip_cnt];
1336 if (hc->ondemand && !hc->id) {
1337 printk(KERN_ERR "%s: ondemand option only allowed in "
1338 "conjunction with non 0 ID\n", __func__);
1339 return -EINVAL;
1340 }
1341
1342 if (limit[l1oip_cnt])
1343 hc->b_num = limit[l1oip_cnt];
1344 if (!pri && hc->b_num > 2) {
1345 printk(KERN_ERR "Maximum limit for BRI interface is 2 "
1346 "channels.\n");
1347 return -EINVAL;
1348 }
1349 if (pri && hc->b_num > 126) {
1350 printk(KERN_ERR "Maximum limit for PRI interface is 126 "
1351 "channels.\n");
1352 return -EINVAL;
1353 }
1354 if (pri && hc->b_num > 30) {
1355 printk(KERN_WARNING "Maximum limit for BRI interface is 30 "
1356 "channels.\n");
1357 printk(KERN_WARNING "Your selection of %d channels must be "
1358 "supported by application.\n", hc->limit);
1359 }
1360
1361 hc->remoteip = ip[l1oip_cnt<<2] << 24
1362 | ip[(l1oip_cnt<<2)+1] << 16
1363 | ip[(l1oip_cnt<<2)+2] << 8
1364 | ip[(l1oip_cnt<<2)+3];
1365 hc->localport = port[l1oip_cnt]?:(L1OIP_DEFAULTPORT+l1oip_cnt);
1366 if (remoteport[l1oip_cnt])
1367 hc->remoteport = remoteport[l1oip_cnt];
1368 else
1369 hc->remoteport = hc->localport;
1370 if (debug & DEBUG_L1OIP_INIT)
1371 printk(KERN_DEBUG "%s: using local port %d remote ip "
1372 "%d.%d.%d.%d port %d ondemand %d\n", __func__,
1373 hc->localport, hc->remoteip >> 24,
1374 (hc->remoteip >> 16) & 0xff,
1375 (hc->remoteip >> 8) & 0xff, hc->remoteip & 0xff,
1376 hc->remoteport, hc->ondemand);
1377
1378 dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL);
1379 if (!dch)
1380 return -ENOMEM;
1381 dch->debug = debug;
1382 mISDN_initdchannel(dch, MAX_DFRAME_LEN_L1, NULL);
1383 dch->hw = hc;
1384 if (pri)
1385 dch->dev.Dprotocols = (1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1);
1386 else
1387 dch->dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
1388 dch->dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
1389 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
1390 dch->dev.D.send = handle_dmsg;
1391 dch->dev.D.ctrl = l1oip_dctrl;
1392 dch->dev.nrbchan = hc->b_num;
1393 dch->slot = hc->d_idx;
1394 hc->chan[hc->d_idx].dch = dch;
1395 i = 1;
1396 for (ch = 0; ch < dch->dev.nrbchan; ch++) {
1397 if (ch == 15)
1398 i++;
1399 bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL);
1400 if (!bch) {
1401 printk(KERN_ERR "%s: no memory for bchannel\n",
1402 __func__);
1403 return -ENOMEM;
1404 }
1405 bch->nr = i + ch;
1406 bch->slot = i + ch;
1407 bch->debug = debug;
1408 mISDN_initbchannel(bch, MAX_DATA_MEM);
1409 bch->hw = hc;
1410 bch->ch.send = handle_bmsg;
1411 bch->ch.ctrl = l1oip_bctrl;
1412 bch->ch.nr = i + ch;
1413 list_add(&bch->ch.list, &dch->dev.bchannels);
1414 hc->chan[i + ch].bch = bch;
1415 test_and_set_bit(bch->nr & 0x1f,
1416 &dch->dev.channelmap[bch->nr >> 5]);
1417 }
1418 ret = mISDN_register_device(&dch->dev, hc->name);
1419 if (ret)
1420 return ret;
1421 hc->registered = 1;
1422
1423 if (debug & DEBUG_L1OIP_INIT)
1424 printk(KERN_DEBUG "%s: Setting up network card(%d)\n",
1425 __func__, l1oip_cnt + 1);
1426 ret = l1oip_socket_open(hc);
1427 if (ret)
1428 return ret;
1429
1430 hc->keep_tl.function = (void *)l1oip_keepalive;
1431 hc->keep_tl.data = (ulong)hc;
1432 init_timer(&hc->keep_tl);
1433 hc->keep_tl.expires = jiffies + 2*HZ; /* two seconds first time */
1434 add_timer(&hc->keep_tl);
1435
1436 hc->timeout_tl.function = (void *)l1oip_timeout;
1437 hc->timeout_tl.data = (ulong)hc;
1438 init_timer(&hc->timeout_tl);
1439 hc->timeout_on = 0; /* state that we have timer off */
1440
1441 return 0;
1442}
1443
1444static int __init
1445l1oip_init(void)
1446{
1447 int pri, bundle;
1448 struct l1oip *hc;
1449 int ret;
1450
1451 printk(KERN_INFO "mISDN: Layer-1-over-IP driver Rev. %s\n",
1452 l1oip_revision);
1453
1454 INIT_LIST_HEAD(&l1oip_ilist);
1455 spin_lock_init(&l1oip_lock);
1456
1457 if (l1oip_4bit_alloc(ulaw))
1458 return -ENOMEM;
1459
1460 l1oip_cnt = 0;
1461 while (type[l1oip_cnt] && l1oip_cnt < MAX_CARDS) {
1462 switch (type[l1oip_cnt] & 0xff) {
1463 case 1:
1464 pri = 0;
1465 bundle = 0;
1466 break;
1467 case 2:
1468 pri = 1;
1469 bundle = 0;
1470 break;
1471 case 3:
1472 pri = 0;
1473 bundle = 1;
1474 break;
1475 case 4:
1476 pri = 1;
1477 bundle = 1;
1478 break;
1479 default:
1480 printk(KERN_ERR "Card type(%d) not supported.\n",
1481 type[l1oip_cnt] & 0xff);
1482 l1oip_cleanup();
1483 return -EINVAL;
1484 }
1485
1486 if (debug & DEBUG_L1OIP_INIT)
1487 printk(KERN_DEBUG "%s: interface %d is %s with %s.\n",
1488 __func__, l1oip_cnt, pri?"PRI":"BRI",
1489 bundle?"bundled IP packet for all B-channels"
1490 :"seperate IP packets for every B-channel");
1491
1492 hc = kzalloc(sizeof(struct l1oip), GFP_ATOMIC);
1493 if (!hc) {
1494 printk(KERN_ERR "No kmem for L1-over-IP driver.\n");
1495 l1oip_cleanup();
1496 return -ENOMEM;
1497 }
1498 INIT_WORK(&hc->workq, (void *)l1oip_send_bh);
1499
1500 spin_lock(&l1oip_lock);
1501 list_add_tail(&hc->list, &l1oip_ilist);
1502 spin_unlock(&l1oip_lock);
1503
1504 ret = init_card(hc, pri, bundle);
1505 if (ret) {
1506 l1oip_cleanup();
1507 return ret;
1508 }
1509
1510 l1oip_cnt++;
1511 }
1512 printk(KERN_INFO "%d virtual devices registered\n", l1oip_cnt);
1513 return 0;
1514}
1515
1516module_init(l1oip_init);
1517module_exit(l1oip_cleanup);
1518
diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c
new file mode 100644
index 000000000000..fced1a2755f8
--- /dev/null
+++ b/drivers/isdn/mISDN/layer1.c
@@ -0,0 +1,403 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18
19#include <linux/module.h>
20#include <linux/mISDNhw.h>
21#include "layer1.h"
22#include "fsm.h"
23
24static int *debug;
25
26struct layer1 {
27 u_long Flags;
28 struct FsmInst l1m;
29 struct FsmTimer timer;
30 int delay;
31 struct dchannel *dch;
32 dchannel_l1callback *dcb;
33};
34
35#define TIMER3_VALUE 7000
36
37static
38struct Fsm l1fsm_s = {NULL, 0, 0, NULL, NULL};
39
40enum {
41 ST_L1_F2,
42 ST_L1_F3,
43 ST_L1_F4,
44 ST_L1_F5,
45 ST_L1_F6,
46 ST_L1_F7,
47 ST_L1_F8,
48};
49
50#define L1S_STATE_COUNT (ST_L1_F8+1)
51
52static char *strL1SState[] =
53{
54 "ST_L1_F2",
55 "ST_L1_F3",
56 "ST_L1_F4",
57 "ST_L1_F5",
58 "ST_L1_F6",
59 "ST_L1_F7",
60 "ST_L1_F8",
61};
62
63enum {
64 EV_PH_ACTIVATE,
65 EV_PH_DEACTIVATE,
66 EV_RESET_IND,
67 EV_DEACT_CNF,
68 EV_DEACT_IND,
69 EV_POWER_UP,
70 EV_ANYSIG_IND,
71 EV_INFO2_IND,
72 EV_INFO4_IND,
73 EV_TIMER_DEACT,
74 EV_TIMER_ACT,
75 EV_TIMER3,
76};
77
78#define L1_EVENT_COUNT (EV_TIMER3 + 1)
79
80static char *strL1Event[] =
81{
82 "EV_PH_ACTIVATE",
83 "EV_PH_DEACTIVATE",
84 "EV_RESET_IND",
85 "EV_DEACT_CNF",
86 "EV_DEACT_IND",
87 "EV_POWER_UP",
88 "EV_ANYSIG_IND",
89 "EV_INFO2_IND",
90 "EV_INFO4_IND",
91 "EV_TIMER_DEACT",
92 "EV_TIMER_ACT",
93 "EV_TIMER3",
94};
95
96static void
97l1m_debug(struct FsmInst *fi, char *fmt, ...)
98{
99 struct layer1 *l1 = fi->userdata;
100 va_list va;
101
102 va_start(va, fmt);
103 printk(KERN_DEBUG "%s: ", l1->dch->dev.name);
104 vprintk(fmt, va);
105 printk("\n");
106 va_end(va);
107}
108
109static void
110l1_reset(struct FsmInst *fi, int event, void *arg)
111{
112 mISDN_FsmChangeState(fi, ST_L1_F3);
113}
114
115static void
116l1_deact_cnf(struct FsmInst *fi, int event, void *arg)
117{
118 struct layer1 *l1 = fi->userdata;
119
120 mISDN_FsmChangeState(fi, ST_L1_F3);
121 if (test_bit(FLG_L1_ACTIVATING, &l1->Flags))
122 l1->dcb(l1->dch, HW_POWERUP_REQ);
123}
124
125static void
126l1_deact_req_s(struct FsmInst *fi, int event, void *arg)
127{
128 struct layer1 *l1 = fi->userdata;
129
130 mISDN_FsmChangeState(fi, ST_L1_F3);
131 mISDN_FsmRestartTimer(&l1->timer, 550, EV_TIMER_DEACT, NULL, 2);
132 test_and_set_bit(FLG_L1_DEACTTIMER, &l1->Flags);
133}
134
135static void
136l1_power_up_s(struct FsmInst *fi, int event, void *arg)
137{
138 struct layer1 *l1 = fi->userdata;
139
140 if (test_bit(FLG_L1_ACTIVATING, &l1->Flags)) {
141 mISDN_FsmChangeState(fi, ST_L1_F4);
142 l1->dcb(l1->dch, INFO3_P8);
143 } else
144 mISDN_FsmChangeState(fi, ST_L1_F3);
145}
146
147static void
148l1_go_F5(struct FsmInst *fi, int event, void *arg)
149{
150 mISDN_FsmChangeState(fi, ST_L1_F5);
151}
152
153static void
154l1_go_F8(struct FsmInst *fi, int event, void *arg)
155{
156 mISDN_FsmChangeState(fi, ST_L1_F8);
157}
158
159static void
160l1_info2_ind(struct FsmInst *fi, int event, void *arg)
161{
162 struct layer1 *l1 = fi->userdata;
163
164 mISDN_FsmChangeState(fi, ST_L1_F6);
165 l1->dcb(l1->dch, INFO3_P8);
166}
167
168static void
169l1_info4_ind(struct FsmInst *fi, int event, void *arg)
170{
171 struct layer1 *l1 = fi->userdata;
172
173 mISDN_FsmChangeState(fi, ST_L1_F7);
174 l1->dcb(l1->dch, INFO3_P8);
175 if (test_and_clear_bit(FLG_L1_DEACTTIMER, &l1->Flags))
176 mISDN_FsmDelTimer(&l1->timer, 4);
177 if (!test_bit(FLG_L1_ACTIVATED, &l1->Flags)) {
178 if (test_and_clear_bit(FLG_L1_T3RUN, &l1->Flags))
179 mISDN_FsmDelTimer(&l1->timer, 3);
180 mISDN_FsmRestartTimer(&l1->timer, 110, EV_TIMER_ACT, NULL, 2);
181 test_and_set_bit(FLG_L1_ACTTIMER, &l1->Flags);
182 }
183}
184
185static void
186l1_timer3(struct FsmInst *fi, int event, void *arg)
187{
188 struct layer1 *l1 = fi->userdata;
189
190 test_and_clear_bit(FLG_L1_T3RUN, &l1->Flags);
191 if (test_and_clear_bit(FLG_L1_ACTIVATING, &l1->Flags)) {
192 if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
193 l1->dcb(l1->dch, HW_D_NOBLOCKED);
194 l1->dcb(l1->dch, PH_DEACTIVATE_IND);
195 }
196 if (l1->l1m.state != ST_L1_F6) {
197 mISDN_FsmChangeState(fi, ST_L1_F3);
198 l1->dcb(l1->dch, HW_POWERUP_REQ);
199 }
200}
201
202static void
203l1_timer_act(struct FsmInst *fi, int event, void *arg)
204{
205 struct layer1 *l1 = fi->userdata;
206
207 test_and_clear_bit(FLG_L1_ACTTIMER, &l1->Flags);
208 test_and_set_bit(FLG_L1_ACTIVATED, &l1->Flags);
209 l1->dcb(l1->dch, PH_ACTIVATE_IND);
210}
211
212static void
213l1_timer_deact(struct FsmInst *fi, int event, void *arg)
214{
215 struct layer1 *l1 = fi->userdata;
216
217 test_and_clear_bit(FLG_L1_DEACTTIMER, &l1->Flags);
218 test_and_clear_bit(FLG_L1_ACTIVATED, &l1->Flags);
219 if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
220 l1->dcb(l1->dch, HW_D_NOBLOCKED);
221 l1->dcb(l1->dch, PH_DEACTIVATE_IND);
222 l1->dcb(l1->dch, HW_DEACT_REQ);
223}
224
225static void
226l1_activate_s(struct FsmInst *fi, int event, void *arg)
227{
228 struct layer1 *l1 = fi->userdata;
229
230 mISDN_FsmRestartTimer(&l1->timer, TIMER3_VALUE, EV_TIMER3, NULL, 2);
231 test_and_set_bit(FLG_L1_T3RUN, &l1->Flags);
232 l1->dcb(l1->dch, HW_RESET_REQ);
233}
234
235static void
236l1_activate_no(struct FsmInst *fi, int event, void *arg)
237{
238 struct layer1 *l1 = fi->userdata;
239
240 if ((!test_bit(FLG_L1_DEACTTIMER, &l1->Flags)) &&
241 (!test_bit(FLG_L1_T3RUN, &l1->Flags))) {
242 test_and_clear_bit(FLG_L1_ACTIVATING, &l1->Flags);
243 if (test_and_clear_bit(FLG_L1_DBLOCKED, &l1->Flags))
244 l1->dcb(l1->dch, HW_D_NOBLOCKED);
245 l1->dcb(l1->dch, PH_DEACTIVATE_IND);
246 }
247}
248
249static struct FsmNode L1SFnList[] =
250{
251 {ST_L1_F3, EV_PH_ACTIVATE, l1_activate_s},
252 {ST_L1_F6, EV_PH_ACTIVATE, l1_activate_no},
253 {ST_L1_F8, EV_PH_ACTIVATE, l1_activate_no},
254 {ST_L1_F3, EV_RESET_IND, l1_reset},
255 {ST_L1_F4, EV_RESET_IND, l1_reset},
256 {ST_L1_F5, EV_RESET_IND, l1_reset},
257 {ST_L1_F6, EV_RESET_IND, l1_reset},
258 {ST_L1_F7, EV_RESET_IND, l1_reset},
259 {ST_L1_F8, EV_RESET_IND, l1_reset},
260 {ST_L1_F3, EV_DEACT_CNF, l1_deact_cnf},
261 {ST_L1_F4, EV_DEACT_CNF, l1_deact_cnf},
262 {ST_L1_F5, EV_DEACT_CNF, l1_deact_cnf},
263 {ST_L1_F6, EV_DEACT_CNF, l1_deact_cnf},
264 {ST_L1_F7, EV_DEACT_CNF, l1_deact_cnf},
265 {ST_L1_F8, EV_DEACT_CNF, l1_deact_cnf},
266 {ST_L1_F6, EV_DEACT_IND, l1_deact_req_s},
267 {ST_L1_F7, EV_DEACT_IND, l1_deact_req_s},
268 {ST_L1_F8, EV_DEACT_IND, l1_deact_req_s},
269 {ST_L1_F3, EV_POWER_UP, l1_power_up_s},
270 {ST_L1_F4, EV_ANYSIG_IND, l1_go_F5},
271 {ST_L1_F6, EV_ANYSIG_IND, l1_go_F8},
272 {ST_L1_F7, EV_ANYSIG_IND, l1_go_F8},
273 {ST_L1_F3, EV_INFO2_IND, l1_info2_ind},
274 {ST_L1_F4, EV_INFO2_IND, l1_info2_ind},
275 {ST_L1_F5, EV_INFO2_IND, l1_info2_ind},
276 {ST_L1_F7, EV_INFO2_IND, l1_info2_ind},
277 {ST_L1_F8, EV_INFO2_IND, l1_info2_ind},
278 {ST_L1_F3, EV_INFO4_IND, l1_info4_ind},
279 {ST_L1_F4, EV_INFO4_IND, l1_info4_ind},
280 {ST_L1_F5, EV_INFO4_IND, l1_info4_ind},
281 {ST_L1_F6, EV_INFO4_IND, l1_info4_ind},
282 {ST_L1_F8, EV_INFO4_IND, l1_info4_ind},
283 {ST_L1_F3, EV_TIMER3, l1_timer3},
284 {ST_L1_F4, EV_TIMER3, l1_timer3},
285 {ST_L1_F5, EV_TIMER3, l1_timer3},
286 {ST_L1_F6, EV_TIMER3, l1_timer3},
287 {ST_L1_F8, EV_TIMER3, l1_timer3},
288 {ST_L1_F7, EV_TIMER_ACT, l1_timer_act},
289 {ST_L1_F3, EV_TIMER_DEACT, l1_timer_deact},
290 {ST_L1_F4, EV_TIMER_DEACT, l1_timer_deact},
291 {ST_L1_F5, EV_TIMER_DEACT, l1_timer_deact},
292 {ST_L1_F6, EV_TIMER_DEACT, l1_timer_deact},
293 {ST_L1_F7, EV_TIMER_DEACT, l1_timer_deact},
294 {ST_L1_F8, EV_TIMER_DEACT, l1_timer_deact},
295};
296
297static void
298release_l1(struct layer1 *l1) {
299 mISDN_FsmDelTimer(&l1->timer, 0);
300 if (l1->dch)
301 l1->dch->l1 = NULL;
302 module_put(THIS_MODULE);
303 kfree(l1);
304}
305
306int
307l1_event(struct layer1 *l1, u_int event)
308{
309 int err = 0;
310
311 if (!l1)
312 return -EINVAL;
313 switch (event) {
314 case HW_RESET_IND:
315 mISDN_FsmEvent(&l1->l1m, EV_RESET_IND, NULL);
316 break;
317 case HW_DEACT_IND:
318 mISDN_FsmEvent(&l1->l1m, EV_DEACT_IND, NULL);
319 break;
320 case HW_POWERUP_IND:
321 mISDN_FsmEvent(&l1->l1m, EV_POWER_UP, NULL);
322 break;
323 case HW_DEACT_CNF:
324 mISDN_FsmEvent(&l1->l1m, EV_DEACT_CNF, NULL);
325 break;
326 case ANYSIGNAL:
327 mISDN_FsmEvent(&l1->l1m, EV_ANYSIG_IND, NULL);
328 break;
329 case LOSTFRAMING:
330 mISDN_FsmEvent(&l1->l1m, EV_ANYSIG_IND, NULL);
331 break;
332 case INFO2:
333 mISDN_FsmEvent(&l1->l1m, EV_INFO2_IND, NULL);
334 break;
335 case INFO4_P8:
336 mISDN_FsmEvent(&l1->l1m, EV_INFO4_IND, NULL);
337 break;
338 case INFO4_P10:
339 mISDN_FsmEvent(&l1->l1m, EV_INFO4_IND, NULL);
340 break;
341 case PH_ACTIVATE_REQ:
342 if (test_bit(FLG_L1_ACTIVATED, &l1->Flags))
343 l1->dcb(l1->dch, PH_ACTIVATE_IND);
344 else {
345 test_and_set_bit(FLG_L1_ACTIVATING, &l1->Flags);
346 mISDN_FsmEvent(&l1->l1m, EV_PH_ACTIVATE, NULL);
347 }
348 break;
349 case CLOSE_CHANNEL:
350 release_l1(l1);
351 break;
352 default:
353 if (*debug & DEBUG_L1)
354 printk(KERN_DEBUG "%s %x unhandled\n",
355 __func__, event);
356 err = -EINVAL;
357 }
358 return err;
359}
360EXPORT_SYMBOL(l1_event);
361
362int
363create_l1(struct dchannel *dch, dchannel_l1callback *dcb) {
364 struct layer1 *nl1;
365
366 nl1 = kzalloc(sizeof(struct layer1), GFP_ATOMIC);
367 if (!nl1) {
368 printk(KERN_ERR "kmalloc struct layer1 failed\n");
369 return -ENOMEM;
370 }
371 nl1->l1m.fsm = &l1fsm_s;
372 nl1->l1m.state = ST_L1_F3;
373 nl1->Flags = 0;
374 nl1->l1m.debug = *debug & DEBUG_L1_FSM;
375 nl1->l1m.userdata = nl1;
376 nl1->l1m.userint = 0;
377 nl1->l1m.printdebug = l1m_debug;
378 nl1->dch = dch;
379 nl1->dcb = dcb;
380 mISDN_FsmInitTimer(&nl1->l1m, &nl1->timer);
381 __module_get(THIS_MODULE);
382 dch->l1 = nl1;
383 return 0;
384}
385EXPORT_SYMBOL(create_l1);
386
387int
388l1_init(u_int *deb)
389{
390 debug = deb;
391 l1fsm_s.state_count = L1S_STATE_COUNT;
392 l1fsm_s.event_count = L1_EVENT_COUNT;
393 l1fsm_s.strEvent = strL1Event;
394 l1fsm_s.strState = strL1SState;
395 mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
396 return 0;
397}
398
399void
400l1_cleanup(void)
401{
402 mISDN_FsmFree(&l1fsm_s);
403}
diff --git a/drivers/isdn/mISDN/layer1.h b/drivers/isdn/mISDN/layer1.h
new file mode 100644
index 000000000000..9c8125fd89af
--- /dev/null
+++ b/drivers/isdn/mISDN/layer1.h
@@ -0,0 +1,26 @@
1/*
2 *
3 * Layer 1 defines
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18#define FLG_L1_ACTIVATING 1
19#define FLG_L1_ACTIVATED 2
20#define FLG_L1_DEACTTIMER 3
21#define FLG_L1_ACTTIMER 4
22#define FLG_L1_T3RUN 5
23#define FLG_L1_PULL_REQ 6
24#define FLG_L1_UINT 7
25#define FLG_L1_DBLOCKED 8
26
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c
new file mode 100644
index 000000000000..a7915a156c04
--- /dev/null
+++ b/drivers/isdn/mISDN/layer2.c
@@ -0,0 +1,2216 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18#include "fsm.h"
19#include "layer2.h"
20
21static int *debug;
22
23static
24struct Fsm l2fsm = {NULL, 0, 0, NULL, NULL};
25
26static char *strL2State[] =
27{
28 "ST_L2_1",
29 "ST_L2_2",
30 "ST_L2_3",
31 "ST_L2_4",
32 "ST_L2_5",
33 "ST_L2_6",
34 "ST_L2_7",
35 "ST_L2_8",
36};
37
38enum {
39 EV_L2_UI,
40 EV_L2_SABME,
41 EV_L2_DISC,
42 EV_L2_DM,
43 EV_L2_UA,
44 EV_L2_FRMR,
45 EV_L2_SUPER,
46 EV_L2_I,
47 EV_L2_DL_DATA,
48 EV_L2_ACK_PULL,
49 EV_L2_DL_UNITDATA,
50 EV_L2_DL_ESTABLISH_REQ,
51 EV_L2_DL_RELEASE_REQ,
52 EV_L2_MDL_ASSIGN,
53 EV_L2_MDL_REMOVE,
54 EV_L2_MDL_ERROR,
55 EV_L1_DEACTIVATE,
56 EV_L2_T200,
57 EV_L2_T203,
58 EV_L2_SET_OWN_BUSY,
59 EV_L2_CLEAR_OWN_BUSY,
60 EV_L2_FRAME_ERROR,
61};
62
63#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR+1)
64
65static char *strL2Event[] =
66{
67 "EV_L2_UI",
68 "EV_L2_SABME",
69 "EV_L2_DISC",
70 "EV_L2_DM",
71 "EV_L2_UA",
72 "EV_L2_FRMR",
73 "EV_L2_SUPER",
74 "EV_L2_I",
75 "EV_L2_DL_DATA",
76 "EV_L2_ACK_PULL",
77 "EV_L2_DL_UNITDATA",
78 "EV_L2_DL_ESTABLISH_REQ",
79 "EV_L2_DL_RELEASE_REQ",
80 "EV_L2_MDL_ASSIGN",
81 "EV_L2_MDL_REMOVE",
82 "EV_L2_MDL_ERROR",
83 "EV_L1_DEACTIVATE",
84 "EV_L2_T200",
85 "EV_L2_T203",
86 "EV_L2_SET_OWN_BUSY",
87 "EV_L2_CLEAR_OWN_BUSY",
88 "EV_L2_FRAME_ERROR",
89};
90
91static void
92l2m_debug(struct FsmInst *fi, char *fmt, ...)
93{
94 struct layer2 *l2 = fi->userdata;
95 va_list va;
96
97 if (!(*debug & DEBUG_L2_FSM))
98 return;
99 va_start(va, fmt);
100 printk(KERN_DEBUG "l2 (tei %d): ", l2->tei);
101 vprintk(fmt, va);
102 printk("\n");
103 va_end(va);
104}
105
106inline u_int
107l2headersize(struct layer2 *l2, int ui)
108{
109 return ((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) +
110 (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1);
111}
112
113inline u_int
114l2addrsize(struct layer2 *l2)
115{
116 return test_bit(FLG_LAPD, &l2->flag) ? 2 : 1;
117}
118
119static u_int
120l2_newid(struct layer2 *l2)
121{
122 u_int id;
123
124 id = l2->next_id++;
125 if (id == 0x7fff)
126 l2->next_id = 1;
127 id <<= 16;
128 id |= l2->tei << 8;
129 id |= l2->sapi;
130 return id;
131}
132
133static void
134l2up(struct layer2 *l2, u_int prim, struct sk_buff *skb)
135{
136 int err;
137
138 if (!l2->up)
139 return;
140 mISDN_HEAD_PRIM(skb) = prim;
141 mISDN_HEAD_ID(skb) = (l2->ch.nr << 16) | l2->ch.addr;
142 err = l2->up->send(l2->up, skb);
143 if (err) {
144 printk(KERN_WARNING "%s: err=%d\n", __func__, err);
145 dev_kfree_skb(skb);
146 }
147}
148
149static void
150l2up_create(struct layer2 *l2, u_int prim, int len, void *arg)
151{
152 struct sk_buff *skb;
153 struct mISDNhead *hh;
154 int err;
155
156 if (!l2->up)
157 return;
158 skb = mI_alloc_skb(len, GFP_ATOMIC);
159 if (!skb)
160 return;
161 hh = mISDN_HEAD_P(skb);
162 hh->prim = prim;
163 hh->id = (l2->ch.nr << 16) | l2->ch.addr;
164 if (len)
165 memcpy(skb_put(skb, len), arg, len);
166 err = l2->up->send(l2->up, skb);
167 if (err) {
168 printk(KERN_WARNING "%s: err=%d\n", __func__, err);
169 dev_kfree_skb(skb);
170 }
171}
172
173static int
174l2down_skb(struct layer2 *l2, struct sk_buff *skb) {
175 int ret;
176
177 ret = l2->ch.recv(l2->ch.peer, skb);
178 if (ret && (*debug & DEBUG_L2_RECV))
179 printk(KERN_DEBUG "l2down_skb: ret(%d)\n", ret);
180 return ret;
181}
182
183static int
184l2down_raw(struct layer2 *l2, struct sk_buff *skb)
185{
186 struct mISDNhead *hh = mISDN_HEAD_P(skb);
187
188 if (hh->prim == PH_DATA_REQ) {
189 if (test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) {
190 skb_queue_tail(&l2->down_queue, skb);
191 return 0;
192 }
193 l2->down_id = mISDN_HEAD_ID(skb);
194 }
195 return l2down_skb(l2, skb);
196}
197
198static int
199l2down(struct layer2 *l2, u_int prim, u_int id, struct sk_buff *skb)
200{
201 struct mISDNhead *hh = mISDN_HEAD_P(skb);
202
203 hh->prim = prim;
204 hh->id = id;
205 return l2down_raw(l2, skb);
206}
207
208static int
209l2down_create(struct layer2 *l2, u_int prim, u_int id, int len, void *arg)
210{
211 struct sk_buff *skb;
212 int err;
213 struct mISDNhead *hh;
214
215 skb = mI_alloc_skb(len, GFP_ATOMIC);
216 if (!skb)
217 return -ENOMEM;
218 hh = mISDN_HEAD_P(skb);
219 hh->prim = prim;
220 hh->id = id;
221 if (len)
222 memcpy(skb_put(skb, len), arg, len);
223 err = l2down_raw(l2, skb);
224 if (err)
225 dev_kfree_skb(skb);
226 return err;
227}
228
229static int
230ph_data_confirm(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) {
231 struct sk_buff *nskb = skb;
232 int ret = -EAGAIN;
233
234 if (test_bit(FLG_L1_NOTREADY, &l2->flag)) {
235 if (hh->id == l2->down_id) {
236 nskb = skb_dequeue(&l2->down_queue);
237 if (nskb) {
238 l2->down_id = mISDN_HEAD_ID(nskb);
239 if (l2down_skb(l2, nskb)) {
240 dev_kfree_skb(nskb);
241 l2->down_id = MISDN_ID_NONE;
242 }
243 } else
244 l2->down_id = MISDN_ID_NONE;
245 if (ret) {
246 dev_kfree_skb(skb);
247 ret = 0;
248 }
249 if (l2->down_id == MISDN_ID_NONE) {
250 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag);
251 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL);
252 }
253 }
254 }
255 if (!test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) {
256 nskb = skb_dequeue(&l2->down_queue);
257 if (nskb) {
258 l2->down_id = mISDN_HEAD_ID(nskb);
259 if (l2down_skb(l2, nskb)) {
260 dev_kfree_skb(nskb);
261 l2->down_id = MISDN_ID_NONE;
262 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag);
263 }
264 } else
265 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag);
266 }
267 return ret;
268}
269
270static int
271l2mgr(struct layer2 *l2, u_int prim, void *arg) {
272 long c = (long)arg;
273
274 printk(KERN_WARNING
275 "l2mgr: addr:%x prim %x %c\n", l2->id, prim, (char)c);
276 if (test_bit(FLG_LAPD, &l2->flag) &&
277 !test_bit(FLG_FIXED_TEI, &l2->flag)) {
278 switch (c) {
279 case 'C':
280 case 'D':
281 case 'G':
282 case 'H':
283 l2_tei(l2, prim, (u_long)arg);
284 break;
285 }
286 }
287 return 0;
288}
289
290static void
291set_peer_busy(struct layer2 *l2) {
292 test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
293 if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue))
294 test_and_set_bit(FLG_L2BLOCK, &l2->flag);
295}
296
297static void
298clear_peer_busy(struct layer2 *l2) {
299 if (test_and_clear_bit(FLG_PEER_BUSY, &l2->flag))
300 test_and_clear_bit(FLG_L2BLOCK, &l2->flag);
301}
302
303static void
304InitWin(struct layer2 *l2)
305{
306 int i;
307
308 for (i = 0; i < MAX_WINDOW; i++)
309 l2->windowar[i] = NULL;
310}
311
312static int
313freewin(struct layer2 *l2)
314{
315 int i, cnt = 0;
316
317 for (i = 0; i < MAX_WINDOW; i++) {
318 if (l2->windowar[i]) {
319 cnt++;
320 dev_kfree_skb(l2->windowar[i]);
321 l2->windowar[i] = NULL;
322 }
323 }
324 return cnt;
325}
326
327static void
328ReleaseWin(struct layer2 *l2)
329{
330 int cnt = freewin(l2);
331
332 if (cnt)
333 printk(KERN_WARNING
334 "isdnl2 freed %d skbuffs in release\n", cnt);
335}
336
337inline unsigned int
338cansend(struct layer2 *l2)
339{
340 unsigned int p1;
341
342 if (test_bit(FLG_MOD128, &l2->flag))
343 p1 = (l2->vs - l2->va) % 128;
344 else
345 p1 = (l2->vs - l2->va) % 8;
346 return (p1 < l2->window) && !test_bit(FLG_PEER_BUSY, &l2->flag);
347}
348
349inline void
350clear_exception(struct layer2 *l2)
351{
352 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
353 test_and_clear_bit(FLG_REJEXC, &l2->flag);
354 test_and_clear_bit(FLG_OWN_BUSY, &l2->flag);
355 clear_peer_busy(l2);
356}
357
358static int
359sethdraddr(struct layer2 *l2, u_char *header, int rsp)
360{
361 u_char *ptr = header;
362 int crbit = rsp;
363
364 if (test_bit(FLG_LAPD, &l2->flag)) {
365 if (test_bit(FLG_LAPD_NET, &l2->flag))
366 crbit = !crbit;
367 *ptr++ = (l2->sapi << 2) | (crbit ? 2 : 0);
368 *ptr++ = (l2->tei << 1) | 1;
369 return 2;
370 } else {
371 if (test_bit(FLG_ORIG, &l2->flag))
372 crbit = !crbit;
373 if (crbit)
374 *ptr++ = l2->addr.B;
375 else
376 *ptr++ = l2->addr.A;
377 return 1;
378 }
379}
380
381static inline void
382enqueue_super(struct layer2 *l2, struct sk_buff *skb)
383{
384 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb))
385 dev_kfree_skb(skb);
386}
387
388static inline void
389enqueue_ui(struct layer2 *l2, struct sk_buff *skb)
390{
391 if (l2->tm)
392 l2_tei(l2, MDL_STATUS_UI_IND, 0);
393 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb))
394 dev_kfree_skb(skb);
395}
396
397inline int
398IsUI(u_char *data)
399{
400 return (data[0] & 0xef) == UI;
401}
402
403inline int
404IsUA(u_char *data)
405{
406 return (data[0] & 0xef) == UA;
407}
408
409inline int
410IsDM(u_char *data)
411{
412 return (data[0] & 0xef) == DM;
413}
414
415inline int
416IsDISC(u_char *data)
417{
418 return (data[0] & 0xef) == DISC;
419}
420
421inline int
422IsRR(u_char *data, struct layer2 *l2)
423{
424 if (test_bit(FLG_MOD128, &l2->flag))
425 return data[0] == RR;
426 else
427 return (data[0] & 0xf) == 1;
428}
429
430inline int
431IsSFrame(u_char *data, struct layer2 *l2)
432{
433 register u_char d = *data;
434
435 if (!test_bit(FLG_MOD128, &l2->flag))
436 d &= 0xf;
437 return ((d & 0xf3) == 1) && ((d & 0x0c) != 0x0c);
438}
439
440inline int
441IsSABME(u_char *data, struct layer2 *l2)
442{
443 u_char d = data[0] & ~0x10;
444
445 return test_bit(FLG_MOD128, &l2->flag) ? d == SABME : d == SABM;
446}
447
448inline int
449IsREJ(u_char *data, struct layer2 *l2)
450{
451 return test_bit(FLG_MOD128, &l2->flag) ?
452 data[0] == REJ : (data[0] & 0xf) == REJ;
453}
454
455inline int
456IsFRMR(u_char *data)
457{
458 return (data[0] & 0xef) == FRMR;
459}
460
461inline int
462IsRNR(u_char *data, struct layer2 *l2)
463{
464 return test_bit(FLG_MOD128, &l2->flag) ?
465 data[0] == RNR : (data[0] & 0xf) == RNR;
466}
467
468int
469iframe_error(struct layer2 *l2, struct sk_buff *skb)
470{
471 u_int i;
472 int rsp = *skb->data & 0x2;
473
474 i = l2addrsize(l2) + (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1);
475 if (test_bit(FLG_ORIG, &l2->flag))
476 rsp = !rsp;
477 if (rsp)
478 return 'L';
479 if (skb->len < i)
480 return 'N';
481 if ((skb->len - i) > l2->maxlen)
482 return 'O';
483 return 0;
484}
485
486int
487super_error(struct layer2 *l2, struct sk_buff *skb)
488{
489 if (skb->len != l2addrsize(l2) +
490 (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1))
491 return 'N';
492 return 0;
493}
494
495int
496unnum_error(struct layer2 *l2, struct sk_buff *skb, int wantrsp)
497{
498 int rsp = (*skb->data & 0x2) >> 1;
499 if (test_bit(FLG_ORIG, &l2->flag))
500 rsp = !rsp;
501 if (rsp != wantrsp)
502 return 'L';
503 if (skb->len != l2addrsize(l2) + 1)
504 return 'N';
505 return 0;
506}
507
508int
509UI_error(struct layer2 *l2, struct sk_buff *skb)
510{
511 int rsp = *skb->data & 0x2;
512 if (test_bit(FLG_ORIG, &l2->flag))
513 rsp = !rsp;
514 if (rsp)
515 return 'L';
516 if (skb->len > l2->maxlen + l2addrsize(l2) + 1)
517 return 'O';
518 return 0;
519}
520
521int
522FRMR_error(struct layer2 *l2, struct sk_buff *skb)
523{
524 u_int headers = l2addrsize(l2) + 1;
525 u_char *datap = skb->data + headers;
526 int rsp = *skb->data & 0x2;
527
528 if (test_bit(FLG_ORIG, &l2->flag))
529 rsp = !rsp;
530 if (!rsp)
531 return 'L';
532 if (test_bit(FLG_MOD128, &l2->flag)) {
533 if (skb->len < headers + 5)
534 return 'N';
535 else if (*debug & DEBUG_L2)
536 l2m_debug(&l2->l2m,
537 "FRMR information %2x %2x %2x %2x %2x",
538 datap[0], datap[1], datap[2], datap[3], datap[4]);
539 } else {
540 if (skb->len < headers + 3)
541 return 'N';
542 else if (*debug & DEBUG_L2)
543 l2m_debug(&l2->l2m,
544 "FRMR information %2x %2x %2x",
545 datap[0], datap[1], datap[2]);
546 }
547 return 0;
548}
549
550static unsigned int
551legalnr(struct layer2 *l2, unsigned int nr)
552{
553 if (test_bit(FLG_MOD128, &l2->flag))
554 return ((nr - l2->va) % 128) <= ((l2->vs - l2->va) % 128);
555 else
556 return ((nr - l2->va) % 8) <= ((l2->vs - l2->va) % 8);
557}
558
559static void
560setva(struct layer2 *l2, unsigned int nr)
561{
562 struct sk_buff *skb;
563
564 while (l2->va != nr) {
565 l2->va++;
566 if (test_bit(FLG_MOD128, &l2->flag))
567 l2->va %= 128;
568 else
569 l2->va %= 8;
570 if (l2->windowar[l2->sow]) {
571 skb_trim(l2->windowar[l2->sow], 0);
572 skb_queue_tail(&l2->tmp_queue, l2->windowar[l2->sow]);
573 l2->windowar[l2->sow] = NULL;
574 }
575 l2->sow = (l2->sow + 1) % l2->window;
576 }
577 skb = skb_dequeue(&l2->tmp_queue);
578 while (skb) {
579 dev_kfree_skb(skb);
580 skb = skb_dequeue(&l2->tmp_queue);
581 }
582}
583
584static void
585send_uframe(struct layer2 *l2, struct sk_buff *skb, u_char cmd, u_char cr)
586{
587 u_char tmp[MAX_L2HEADER_LEN];
588 int i;
589
590 i = sethdraddr(l2, tmp, cr);
591 tmp[i++] = cmd;
592 if (skb)
593 skb_trim(skb, 0);
594 else {
595 skb = mI_alloc_skb(i, GFP_ATOMIC);
596 if (!skb) {
597 printk(KERN_WARNING "%s: can't alloc skbuff\n",
598 __func__);
599 return;
600 }
601 }
602 memcpy(skb_put(skb, i), tmp, i);
603 enqueue_super(l2, skb);
604}
605
606
607inline u_char
608get_PollFlag(struct layer2 *l2, struct sk_buff *skb)
609{
610 return skb->data[l2addrsize(l2)] & 0x10;
611}
612
613inline u_char
614get_PollFlagFree(struct layer2 *l2, struct sk_buff *skb)
615{
616 u_char PF;
617
618 PF = get_PollFlag(l2, skb);
619 dev_kfree_skb(skb);
620 return PF;
621}
622
623inline void
624start_t200(struct layer2 *l2, int i)
625{
626 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i);
627 test_and_set_bit(FLG_T200_RUN, &l2->flag);
628}
629
630inline void
631restart_t200(struct layer2 *l2, int i)
632{
633 mISDN_FsmRestartTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i);
634 test_and_set_bit(FLG_T200_RUN, &l2->flag);
635}
636
637inline void
638stop_t200(struct layer2 *l2, int i)
639{
640 if (test_and_clear_bit(FLG_T200_RUN, &l2->flag))
641 mISDN_FsmDelTimer(&l2->t200, i);
642}
643
644inline void
645st5_dl_release_l2l3(struct layer2 *l2)
646{
647 int pr;
648
649 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag))
650 pr = DL_RELEASE_CNF;
651 else
652 pr = DL_RELEASE_IND;
653 l2up_create(l2, pr, 0, NULL);
654}
655
656inline void
657lapb_dl_release_l2l3(struct layer2 *l2, int f)
658{
659 if (test_bit(FLG_LAPB, &l2->flag))
660 l2down_create(l2, PH_DEACTIVATE_REQ, l2_newid(l2), 0, NULL);
661 l2up_create(l2, f, 0, NULL);
662}
663
664static void
665establishlink(struct FsmInst *fi)
666{
667 struct layer2 *l2 = fi->userdata;
668 u_char cmd;
669
670 clear_exception(l2);
671 l2->rc = 0;
672 cmd = (test_bit(FLG_MOD128, &l2->flag) ? SABME : SABM) | 0x10;
673 send_uframe(l2, NULL, cmd, CMD);
674 mISDN_FsmDelTimer(&l2->t203, 1);
675 restart_t200(l2, 1);
676 test_and_clear_bit(FLG_PEND_REL, &l2->flag);
677 freewin(l2);
678 mISDN_FsmChangeState(fi, ST_L2_5);
679}
680
681static void
682l2_mdl_error_ua(struct FsmInst *fi, int event, void *arg)
683{
684 struct sk_buff *skb = arg;
685 struct layer2 *l2 = fi->userdata;
686
687 if (get_PollFlagFree(l2, skb))
688 l2mgr(l2, MDL_ERROR_IND, (void *) 'C');
689 else
690 l2mgr(l2, MDL_ERROR_IND, (void *) 'D');
691
692}
693
694static void
695l2_mdl_error_dm(struct FsmInst *fi, int event, void *arg)
696{
697 struct sk_buff *skb = arg;
698 struct layer2 *l2 = fi->userdata;
699
700 if (get_PollFlagFree(l2, skb))
701 l2mgr(l2, MDL_ERROR_IND, (void *) 'B');
702 else {
703 l2mgr(l2, MDL_ERROR_IND, (void *) 'E');
704 establishlink(fi);
705 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
706 }
707}
708
709static void
710l2_st8_mdl_error_dm(struct FsmInst *fi, int event, void *arg)
711{
712 struct sk_buff *skb = arg;
713 struct layer2 *l2 = fi->userdata;
714
715 if (get_PollFlagFree(l2, skb))
716 l2mgr(l2, MDL_ERROR_IND, (void *) 'B');
717 else
718 l2mgr(l2, MDL_ERROR_IND, (void *) 'E');
719 establishlink(fi);
720 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
721}
722
723static void
724l2_go_st3(struct FsmInst *fi, int event, void *arg)
725{
726 dev_kfree_skb((struct sk_buff *)arg);
727 mISDN_FsmChangeState(fi, ST_L2_3);
728}
729
730static void
731l2_mdl_assign(struct FsmInst *fi, int event, void *arg)
732{
733 struct layer2 *l2 = fi->userdata;
734
735 mISDN_FsmChangeState(fi, ST_L2_3);
736 dev_kfree_skb((struct sk_buff *)arg);
737 l2_tei(l2, MDL_ASSIGN_IND, 0);
738}
739
740static void
741l2_queue_ui_assign(struct FsmInst *fi, int event, void *arg)
742{
743 struct layer2 *l2 = fi->userdata;
744 struct sk_buff *skb = arg;
745
746 skb_queue_tail(&l2->ui_queue, skb);
747 mISDN_FsmChangeState(fi, ST_L2_2);
748 l2_tei(l2, MDL_ASSIGN_IND, 0);
749}
750
751static void
752l2_queue_ui(struct FsmInst *fi, int event, void *arg)
753{
754 struct layer2 *l2 = fi->userdata;
755 struct sk_buff *skb = arg;
756
757 skb_queue_tail(&l2->ui_queue, skb);
758}
759
760static void
761tx_ui(struct layer2 *l2)
762{
763 struct sk_buff *skb;
764 u_char header[MAX_L2HEADER_LEN];
765 int i;
766
767 i = sethdraddr(l2, header, CMD);
768 if (test_bit(FLG_LAPD_NET, &l2->flag))
769 header[1] = 0xff; /* tei 127 */
770 header[i++] = UI;
771 while ((skb = skb_dequeue(&l2->ui_queue))) {
772 memcpy(skb_push(skb, i), header, i);
773 enqueue_ui(l2, skb);
774 }
775}
776
777static void
778l2_send_ui(struct FsmInst *fi, int event, void *arg)
779{
780 struct layer2 *l2 = fi->userdata;
781 struct sk_buff *skb = arg;
782
783 skb_queue_tail(&l2->ui_queue, skb);
784 tx_ui(l2);
785}
786
787static void
788l2_got_ui(struct FsmInst *fi, int event, void *arg)
789{
790 struct layer2 *l2 = fi->userdata;
791 struct sk_buff *skb = arg;
792
793 skb_pull(skb, l2headersize(l2, 1));
794/*
795 * in states 1-3 for broadcast
796 */
797
798 if (l2->tm)
799 l2_tei(l2, MDL_STATUS_UI_IND, 0);
800 l2up(l2, DL_UNITDATA_IND, skb);
801}
802
803static void
804l2_establish(struct FsmInst *fi, int event, void *arg)
805{
806 struct sk_buff *skb = arg;
807 struct layer2 *l2 = fi->userdata;
808
809 establishlink(fi);
810 test_and_set_bit(FLG_L3_INIT, &l2->flag);
811 dev_kfree_skb(skb);
812}
813
814static void
815l2_discard_i_setl3(struct FsmInst *fi, int event, void *arg)
816{
817 struct sk_buff *skb = arg;
818 struct layer2 *l2 = fi->userdata;
819
820 skb_queue_purge(&l2->i_queue);
821 test_and_set_bit(FLG_L3_INIT, &l2->flag);
822 test_and_clear_bit(FLG_PEND_REL, &l2->flag);
823 dev_kfree_skb(skb);
824}
825
826static void
827l2_l3_reestablish(struct FsmInst *fi, int event, void *arg)
828{
829 struct sk_buff *skb = arg;
830 struct layer2 *l2 = fi->userdata;
831
832 skb_queue_purge(&l2->i_queue);
833 establishlink(fi);
834 test_and_set_bit(FLG_L3_INIT, &l2->flag);
835 dev_kfree_skb(skb);
836}
837
838static void
839l2_release(struct FsmInst *fi, int event, void *arg)
840{
841 struct layer2 *l2 = fi->userdata;
842 struct sk_buff *skb = arg;
843
844 skb_trim(skb, 0);
845 l2up(l2, DL_RELEASE_CNF, skb);
846}
847
848static void
849l2_pend_rel(struct FsmInst *fi, int event, void *arg)
850{
851 struct sk_buff *skb = arg;
852 struct layer2 *l2 = fi->userdata;
853
854 test_and_set_bit(FLG_PEND_REL, &l2->flag);
855 dev_kfree_skb(skb);
856}
857
858static void
859l2_disconnect(struct FsmInst *fi, int event, void *arg)
860{
861 struct layer2 *l2 = fi->userdata;
862 struct sk_buff *skb = arg;
863
864 skb_queue_purge(&l2->i_queue);
865 freewin(l2);
866 mISDN_FsmChangeState(fi, ST_L2_6);
867 l2->rc = 0;
868 send_uframe(l2, NULL, DISC | 0x10, CMD);
869 mISDN_FsmDelTimer(&l2->t203, 1);
870 restart_t200(l2, 2);
871 if (skb)
872 dev_kfree_skb(skb);
873}
874
875static void
876l2_start_multi(struct FsmInst *fi, int event, void *arg)
877{
878 struct layer2 *l2 = fi->userdata;
879 struct sk_buff *skb = arg;
880
881 l2->vs = 0;
882 l2->va = 0;
883 l2->vr = 0;
884 l2->sow = 0;
885 clear_exception(l2);
886 send_uframe(l2, NULL, UA | get_PollFlag(l2, skb), RSP);
887 mISDN_FsmChangeState(fi, ST_L2_7);
888 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3);
889 skb_trim(skb, 0);
890 l2up(l2, DL_ESTABLISH_IND, skb);
891 if (l2->tm)
892 l2_tei(l2, MDL_STATUS_UP_IND, 0);
893}
894
895static void
896l2_send_UA(struct FsmInst *fi, int event, void *arg)
897{
898 struct layer2 *l2 = fi->userdata;
899 struct sk_buff *skb = arg;
900
901 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP);
902}
903
904static void
905l2_send_DM(struct FsmInst *fi, int event, void *arg)
906{
907 struct layer2 *l2 = fi->userdata;
908 struct sk_buff *skb = arg;
909
910 send_uframe(l2, skb, DM | get_PollFlag(l2, skb), RSP);
911}
912
913static void
914l2_restart_multi(struct FsmInst *fi, int event, void *arg)
915{
916 struct layer2 *l2 = fi->userdata;
917 struct sk_buff *skb = arg;
918 int est = 0;
919
920 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP);
921
922 l2mgr(l2, MDL_ERROR_IND, (void *) 'F');
923
924 if (l2->vs != l2->va) {
925 skb_queue_purge(&l2->i_queue);
926 est = 1;
927 }
928
929 clear_exception(l2);
930 l2->vs = 0;
931 l2->va = 0;
932 l2->vr = 0;
933 l2->sow = 0;
934 mISDN_FsmChangeState(fi, ST_L2_7);
935 stop_t200(l2, 3);
936 mISDN_FsmRestartTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3);
937
938 if (est)
939 l2up_create(l2, DL_ESTABLISH_IND, 0, NULL);
940/* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST,
941 * MGR_SHORTSTATUS | INDICATION, SSTATUS_L2_ESTABLISHED,
942 * 0, NULL, 0);
943 */
944 if (skb_queue_len(&l2->i_queue) && cansend(l2))
945 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
946}
947
948static void
949l2_stop_multi(struct FsmInst *fi, int event, void *arg)
950{
951 struct layer2 *l2 = fi->userdata;
952 struct sk_buff *skb = arg;
953
954 mISDN_FsmChangeState(fi, ST_L2_4);
955 mISDN_FsmDelTimer(&l2->t203, 3);
956 stop_t200(l2, 4);
957
958 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP);
959 skb_queue_purge(&l2->i_queue);
960 freewin(l2);
961 lapb_dl_release_l2l3(l2, DL_RELEASE_IND);
962 if (l2->tm)
963 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
964}
965
966static void
967l2_connected(struct FsmInst *fi, int event, void *arg)
968{
969 struct layer2 *l2 = fi->userdata;
970 struct sk_buff *skb = arg;
971 int pr = -1;
972
973 if (!get_PollFlag(l2, skb)) {
974 l2_mdl_error_ua(fi, event, arg);
975 return;
976 }
977 dev_kfree_skb(skb);
978 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag))
979 l2_disconnect(fi, event, NULL);
980 if (test_and_clear_bit(FLG_L3_INIT, &l2->flag)) {
981 pr = DL_ESTABLISH_CNF;
982 } else if (l2->vs != l2->va) {
983 skb_queue_purge(&l2->i_queue);
984 pr = DL_ESTABLISH_IND;
985 }
986 stop_t200(l2, 5);
987 l2->vr = 0;
988 l2->vs = 0;
989 l2->va = 0;
990 l2->sow = 0;
991 mISDN_FsmChangeState(fi, ST_L2_7);
992 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 4);
993 if (pr != -1)
994 l2up_create(l2, pr, 0, NULL);
995
996 if (skb_queue_len(&l2->i_queue) && cansend(l2))
997 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
998
999 if (l2->tm)
1000 l2_tei(l2, MDL_STATUS_UP_IND, 0);
1001}
1002
1003static void
1004l2_released(struct FsmInst *fi, int event, void *arg)
1005{
1006 struct layer2 *l2 = fi->userdata;
1007 struct sk_buff *skb = arg;
1008
1009 if (!get_PollFlag(l2, skb)) {
1010 l2_mdl_error_ua(fi, event, arg);
1011 return;
1012 }
1013 dev_kfree_skb(skb);
1014 stop_t200(l2, 6);
1015 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF);
1016 mISDN_FsmChangeState(fi, ST_L2_4);
1017 if (l2->tm)
1018 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1019}
1020
1021static void
1022l2_reestablish(struct FsmInst *fi, int event, void *arg)
1023{
1024 struct layer2 *l2 = fi->userdata;
1025 struct sk_buff *skb = arg;
1026
1027 if (!get_PollFlagFree(l2, skb)) {
1028 establishlink(fi);
1029 test_and_set_bit(FLG_L3_INIT, &l2->flag);
1030 }
1031}
1032
1033static void
1034l2_st5_dm_release(struct FsmInst *fi, int event, void *arg)
1035{
1036 struct layer2 *l2 = fi->userdata;
1037 struct sk_buff *skb = arg;
1038
1039 if (get_PollFlagFree(l2, skb)) {
1040 stop_t200(l2, 7);
1041 if (!test_bit(FLG_L3_INIT, &l2->flag))
1042 skb_queue_purge(&l2->i_queue);
1043 if (test_bit(FLG_LAPB, &l2->flag))
1044 l2down_create(l2, PH_DEACTIVATE_REQ,
1045 l2_newid(l2), 0, NULL);
1046 st5_dl_release_l2l3(l2);
1047 mISDN_FsmChangeState(fi, ST_L2_4);
1048 if (l2->tm)
1049 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1050 }
1051}
1052
1053static void
1054l2_st6_dm_release(struct FsmInst *fi, int event, void *arg)
1055{
1056 struct layer2 *l2 = fi->userdata;
1057 struct sk_buff *skb = arg;
1058
1059 if (get_PollFlagFree(l2, skb)) {
1060 stop_t200(l2, 8);
1061 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF);
1062 mISDN_FsmChangeState(fi, ST_L2_4);
1063 if (l2->tm)
1064 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1065 }
1066}
1067
1068void
1069enquiry_cr(struct layer2 *l2, u_char typ, u_char cr, u_char pf)
1070{
1071 struct sk_buff *skb;
1072 u_char tmp[MAX_L2HEADER_LEN];
1073 int i;
1074
1075 i = sethdraddr(l2, tmp, cr);
1076 if (test_bit(FLG_MOD128, &l2->flag)) {
1077 tmp[i++] = typ;
1078 tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0);
1079 } else
1080 tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0);
1081 skb = mI_alloc_skb(i, GFP_ATOMIC);
1082 if (!skb) {
1083 printk(KERN_WARNING
1084 "isdnl2 can't alloc sbbuff for enquiry_cr\n");
1085 return;
1086 }
1087 memcpy(skb_put(skb, i), tmp, i);
1088 enqueue_super(l2, skb);
1089}
1090
1091inline void
1092enquiry_response(struct layer2 *l2)
1093{
1094 if (test_bit(FLG_OWN_BUSY, &l2->flag))
1095 enquiry_cr(l2, RNR, RSP, 1);
1096 else
1097 enquiry_cr(l2, RR, RSP, 1);
1098 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1099}
1100
1101inline void
1102transmit_enquiry(struct layer2 *l2)
1103{
1104 if (test_bit(FLG_OWN_BUSY, &l2->flag))
1105 enquiry_cr(l2, RNR, CMD, 1);
1106 else
1107 enquiry_cr(l2, RR, CMD, 1);
1108 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1109 start_t200(l2, 9);
1110}
1111
1112
1113static void
1114nrerrorrecovery(struct FsmInst *fi)
1115{
1116 struct layer2 *l2 = fi->userdata;
1117
1118 l2mgr(l2, MDL_ERROR_IND, (void *) 'J');
1119 establishlink(fi);
1120 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
1121}
1122
1123static void
1124invoke_retransmission(struct layer2 *l2, unsigned int nr)
1125{
1126 u_int p1;
1127
1128 if (l2->vs != nr) {
1129 while (l2->vs != nr) {
1130 (l2->vs)--;
1131 if (test_bit(FLG_MOD128, &l2->flag)) {
1132 l2->vs %= 128;
1133 p1 = (l2->vs - l2->va) % 128;
1134 } else {
1135 l2->vs %= 8;
1136 p1 = (l2->vs - l2->va) % 8;
1137 }
1138 p1 = (p1 + l2->sow) % l2->window;
1139 if (l2->windowar[p1])
1140 skb_queue_head(&l2->i_queue, l2->windowar[p1]);
1141 else
1142 printk(KERN_WARNING
1143 "%s: windowar[%d] is NULL\n",
1144 __func__, p1);
1145 l2->windowar[p1] = NULL;
1146 }
1147 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL);
1148 }
1149}
1150
1151static void
1152l2_st7_got_super(struct FsmInst *fi, int event, void *arg)
1153{
1154 struct layer2 *l2 = fi->userdata;
1155 struct sk_buff *skb = arg;
1156 int PollFlag, rsp, typ = RR;
1157 unsigned int nr;
1158
1159 rsp = *skb->data & 0x2;
1160 if (test_bit(FLG_ORIG, &l2->flag))
1161 rsp = !rsp;
1162
1163 skb_pull(skb, l2addrsize(l2));
1164 if (IsRNR(skb->data, l2)) {
1165 set_peer_busy(l2);
1166 typ = RNR;
1167 } else
1168 clear_peer_busy(l2);
1169 if (IsREJ(skb->data, l2))
1170 typ = REJ;
1171
1172 if (test_bit(FLG_MOD128, &l2->flag)) {
1173 PollFlag = (skb->data[1] & 0x1) == 0x1;
1174 nr = skb->data[1] >> 1;
1175 } else {
1176 PollFlag = (skb->data[0] & 0x10);
1177 nr = (skb->data[0] >> 5) & 0x7;
1178 }
1179 dev_kfree_skb(skb);
1180
1181 if (PollFlag) {
1182 if (rsp)
1183 l2mgr(l2, MDL_ERROR_IND, (void *) 'A');
1184 else
1185 enquiry_response(l2);
1186 }
1187 if (legalnr(l2, nr)) {
1188 if (typ == REJ) {
1189 setva(l2, nr);
1190 invoke_retransmission(l2, nr);
1191 stop_t200(l2, 10);
1192 if (mISDN_FsmAddTimer(&l2->t203, l2->T203,
1193 EV_L2_T203, NULL, 6))
1194 l2m_debug(&l2->l2m, "Restart T203 ST7 REJ");
1195 } else if ((nr == l2->vs) && (typ == RR)) {
1196 setva(l2, nr);
1197 stop_t200(l2, 11);
1198 mISDN_FsmRestartTimer(&l2->t203, l2->T203,
1199 EV_L2_T203, NULL, 7);
1200 } else if ((l2->va != nr) || (typ == RNR)) {
1201 setva(l2, nr);
1202 if (typ != RR)
1203 mISDN_FsmDelTimer(&l2->t203, 9);
1204 restart_t200(l2, 12);
1205 }
1206 if (skb_queue_len(&l2->i_queue) && (typ == RR))
1207 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
1208 } else
1209 nrerrorrecovery(fi);
1210}
1211
1212static void
1213l2_feed_i_if_reest(struct FsmInst *fi, int event, void *arg)
1214{
1215 struct layer2 *l2 = fi->userdata;
1216 struct sk_buff *skb = arg;
1217
1218 if (!test_bit(FLG_L3_INIT, &l2->flag))
1219 skb_queue_tail(&l2->i_queue, skb);
1220 else
1221 dev_kfree_skb(skb);
1222}
1223
1224static void
1225l2_feed_i_pull(struct FsmInst *fi, int event, void *arg)
1226{
1227 struct layer2 *l2 = fi->userdata;
1228 struct sk_buff *skb = arg;
1229
1230 skb_queue_tail(&l2->i_queue, skb);
1231 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
1232}
1233
1234static void
1235l2_feed_iqueue(struct FsmInst *fi, int event, void *arg)
1236{
1237 struct layer2 *l2 = fi->userdata;
1238 struct sk_buff *skb = arg;
1239
1240 skb_queue_tail(&l2->i_queue, skb);
1241}
1242
1243static void
1244l2_got_iframe(struct FsmInst *fi, int event, void *arg)
1245{
1246 struct layer2 *l2 = fi->userdata;
1247 struct sk_buff *skb = arg;
1248 int PollFlag, i;
1249 u_int ns, nr;
1250
1251 i = l2addrsize(l2);
1252 if (test_bit(FLG_MOD128, &l2->flag)) {
1253 PollFlag = ((skb->data[i + 1] & 0x1) == 0x1);
1254 ns = skb->data[i] >> 1;
1255 nr = (skb->data[i + 1] >> 1) & 0x7f;
1256 } else {
1257 PollFlag = (skb->data[i] & 0x10);
1258 ns = (skb->data[i] >> 1) & 0x7;
1259 nr = (skb->data[i] >> 5) & 0x7;
1260 }
1261 if (test_bit(FLG_OWN_BUSY, &l2->flag)) {
1262 dev_kfree_skb(skb);
1263 if (PollFlag)
1264 enquiry_response(l2);
1265 } else {
1266 if (l2->vr == ns) {
1267 l2->vr++;
1268 if (test_bit(FLG_MOD128, &l2->flag))
1269 l2->vr %= 128;
1270 else
1271 l2->vr %= 8;
1272 test_and_clear_bit(FLG_REJEXC, &l2->flag);
1273 if (PollFlag)
1274 enquiry_response(l2);
1275 else
1276 test_and_set_bit(FLG_ACK_PEND, &l2->flag);
1277 skb_pull(skb, l2headersize(l2, 0));
1278 l2up(l2, DL_DATA_IND, skb);
1279 } else {
1280 /* n(s)!=v(r) */
1281 dev_kfree_skb(skb);
1282 if (test_and_set_bit(FLG_REJEXC, &l2->flag)) {
1283 if (PollFlag)
1284 enquiry_response(l2);
1285 } else {
1286 enquiry_cr(l2, REJ, RSP, PollFlag);
1287 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1288 }
1289 }
1290 }
1291 if (legalnr(l2, nr)) {
1292 if (!test_bit(FLG_PEER_BUSY, &l2->flag) &&
1293 (fi->state == ST_L2_7)) {
1294 if (nr == l2->vs) {
1295 stop_t200(l2, 13);
1296 mISDN_FsmRestartTimer(&l2->t203, l2->T203,
1297 EV_L2_T203, NULL, 7);
1298 } else if (nr != l2->va)
1299 restart_t200(l2, 14);
1300 }
1301 setva(l2, nr);
1302 } else {
1303 nrerrorrecovery(fi);
1304 return;
1305 }
1306 if (skb_queue_len(&l2->i_queue) && (fi->state == ST_L2_7))
1307 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
1308 if (test_and_clear_bit(FLG_ACK_PEND, &l2->flag))
1309 enquiry_cr(l2, RR, RSP, 0);
1310}
1311
1312static void
1313l2_got_tei(struct FsmInst *fi, int event, void *arg)
1314{
1315 struct layer2 *l2 = fi->userdata;
1316 u_int info;
1317
1318 l2->tei = (signed char)(long)arg;
1319 set_channel_address(&l2->ch, l2->sapi, l2->tei);
1320 info = DL_INFO_L2_CONNECT;
1321 l2up_create(l2, DL_INFORMATION_IND, sizeof(info), &info);
1322 if (fi->state == ST_L2_3) {
1323 establishlink(fi);
1324 test_and_set_bit(FLG_L3_INIT, &l2->flag);
1325 } else
1326 mISDN_FsmChangeState(fi, ST_L2_4);
1327 if (skb_queue_len(&l2->ui_queue))
1328 tx_ui(l2);
1329}
1330
1331static void
1332l2_st5_tout_200(struct FsmInst *fi, int event, void *arg)
1333{
1334 struct layer2 *l2 = fi->userdata;
1335
1336 if (test_bit(FLG_LAPD, &l2->flag) &&
1337 test_bit(FLG_DCHAN_BUSY, &l2->flag)) {
1338 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9);
1339 } else if (l2->rc == l2->N200) {
1340 mISDN_FsmChangeState(fi, ST_L2_4);
1341 test_and_clear_bit(FLG_T200_RUN, &l2->flag);
1342 skb_queue_purge(&l2->i_queue);
1343 l2mgr(l2, MDL_ERROR_IND, (void *) 'G');
1344 if (test_bit(FLG_LAPB, &l2->flag))
1345 l2down_create(l2, PH_DEACTIVATE_REQ,
1346 l2_newid(l2), 0, NULL);
1347 st5_dl_release_l2l3(l2);
1348 if (l2->tm)
1349 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1350 } else {
1351 l2->rc++;
1352 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9);
1353 send_uframe(l2, NULL, (test_bit(FLG_MOD128, &l2->flag) ?
1354 SABME : SABM) | 0x10, CMD);
1355 }
1356}
1357
1358static void
1359l2_st6_tout_200(struct FsmInst *fi, int event, void *arg)
1360{
1361 struct layer2 *l2 = fi->userdata;
1362
1363 if (test_bit(FLG_LAPD, &l2->flag) &&
1364 test_bit(FLG_DCHAN_BUSY, &l2->flag)) {
1365 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9);
1366 } else if (l2->rc == l2->N200) {
1367 mISDN_FsmChangeState(fi, ST_L2_4);
1368 test_and_clear_bit(FLG_T200_RUN, &l2->flag);
1369 l2mgr(l2, MDL_ERROR_IND, (void *) 'H');
1370 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF);
1371 if (l2->tm)
1372 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1373 } else {
1374 l2->rc++;
1375 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200,
1376 NULL, 9);
1377 send_uframe(l2, NULL, DISC | 0x10, CMD);
1378 }
1379}
1380
1381static void
1382l2_st7_tout_200(struct FsmInst *fi, int event, void *arg)
1383{
1384 struct layer2 *l2 = fi->userdata;
1385
1386 if (test_bit(FLG_LAPD, &l2->flag) &&
1387 test_bit(FLG_DCHAN_BUSY, &l2->flag)) {
1388 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9);
1389 return;
1390 }
1391 test_and_clear_bit(FLG_T200_RUN, &l2->flag);
1392 l2->rc = 0;
1393 mISDN_FsmChangeState(fi, ST_L2_8);
1394 transmit_enquiry(l2);
1395 l2->rc++;
1396}
1397
1398static void
1399l2_st8_tout_200(struct FsmInst *fi, int event, void *arg)
1400{
1401 struct layer2 *l2 = fi->userdata;
1402
1403 if (test_bit(FLG_LAPD, &l2->flag) &&
1404 test_bit(FLG_DCHAN_BUSY, &l2->flag)) {
1405 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9);
1406 return;
1407 }
1408 test_and_clear_bit(FLG_T200_RUN, &l2->flag);
1409 if (l2->rc == l2->N200) {
1410 l2mgr(l2, MDL_ERROR_IND, (void *) 'I');
1411 establishlink(fi);
1412 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
1413 } else {
1414 transmit_enquiry(l2);
1415 l2->rc++;
1416 }
1417}
1418
1419static void
1420l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
1421{
1422 struct layer2 *l2 = fi->userdata;
1423
1424 if (test_bit(FLG_LAPD, &l2->flag) &&
1425 test_bit(FLG_DCHAN_BUSY, &l2->flag)) {
1426 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 9);
1427 return;
1428 }
1429 mISDN_FsmChangeState(fi, ST_L2_8);
1430 transmit_enquiry(l2);
1431 l2->rc = 0;
1432}
1433
1434static void
1435l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
1436{
1437 struct layer2 *l2 = fi->userdata;
1438 struct sk_buff *skb, *nskb, *oskb;
1439 u_char header[MAX_L2HEADER_LEN];
1440 u_int i, p1;
1441
1442 if (!cansend(l2))
1443 return;
1444
1445 skb = skb_dequeue(&l2->i_queue);
1446 if (!skb)
1447 return;
1448
1449 if (test_bit(FLG_MOD128, &l2->flag))
1450 p1 = (l2->vs - l2->va) % 128;
1451 else
1452 p1 = (l2->vs - l2->va) % 8;
1453 p1 = (p1 + l2->sow) % l2->window;
1454 if (l2->windowar[p1]) {
1455 printk(KERN_WARNING "isdnl2 try overwrite ack queue entry %d\n",
1456 p1);
1457 dev_kfree_skb(l2->windowar[p1]);
1458 }
1459 l2->windowar[p1] = skb;
1460 i = sethdraddr(l2, header, CMD);
1461 if (test_bit(FLG_MOD128, &l2->flag)) {
1462 header[i++] = l2->vs << 1;
1463 header[i++] = l2->vr << 1;
1464 l2->vs = (l2->vs + 1) % 128;
1465 } else {
1466 header[i++] = (l2->vr << 5) | (l2->vs << 1);
1467 l2->vs = (l2->vs + 1) % 8;
1468 }
1469
1470 nskb = skb_clone(skb, GFP_ATOMIC);
1471 p1 = skb_headroom(nskb);
1472 if (p1 >= i)
1473 memcpy(skb_push(nskb, i), header, i);
1474 else {
1475 printk(KERN_WARNING
1476 "isdnl2 pull_iqueue skb header(%d/%d) too short\n", i, p1);
1477 oskb = nskb;
1478 nskb = mI_alloc_skb(oskb->len + i, GFP_ATOMIC);
1479 if (!nskb) {
1480 dev_kfree_skb(oskb);
1481 printk(KERN_WARNING "%s: no skb mem\n", __func__);
1482 return;
1483 }
1484 memcpy(skb_put(nskb, i), header, i);
1485 memcpy(skb_put(nskb, oskb->len), oskb->data, oskb->len);
1486 dev_kfree_skb(oskb);
1487 }
1488 l2down(l2, PH_DATA_REQ, l2_newid(l2), nskb);
1489 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1490 if (!test_and_set_bit(FLG_T200_RUN, &l2->flag)) {
1491 mISDN_FsmDelTimer(&l2->t203, 13);
1492 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 11);
1493 }
1494}
1495
1496static void
1497l2_st8_got_super(struct FsmInst *fi, int event, void *arg)
1498{
1499 struct layer2 *l2 = fi->userdata;
1500 struct sk_buff *skb = arg;
1501 int PollFlag, rsp, rnr = 0;
1502 unsigned int nr;
1503
1504 rsp = *skb->data & 0x2;
1505 if (test_bit(FLG_ORIG, &l2->flag))
1506 rsp = !rsp;
1507
1508 skb_pull(skb, l2addrsize(l2));
1509
1510 if (IsRNR(skb->data, l2)) {
1511 set_peer_busy(l2);
1512 rnr = 1;
1513 } else
1514 clear_peer_busy(l2);
1515
1516 if (test_bit(FLG_MOD128, &l2->flag)) {
1517 PollFlag = (skb->data[1] & 0x1) == 0x1;
1518 nr = skb->data[1] >> 1;
1519 } else {
1520 PollFlag = (skb->data[0] & 0x10);
1521 nr = (skb->data[0] >> 5) & 0x7;
1522 }
1523 dev_kfree_skb(skb);
1524 if (rsp && PollFlag) {
1525 if (legalnr(l2, nr)) {
1526 if (rnr) {
1527 restart_t200(l2, 15);
1528 } else {
1529 stop_t200(l2, 16);
1530 mISDN_FsmAddTimer(&l2->t203, l2->T203,
1531 EV_L2_T203, NULL, 5);
1532 setva(l2, nr);
1533 }
1534 invoke_retransmission(l2, nr);
1535 mISDN_FsmChangeState(fi, ST_L2_7);
1536 if (skb_queue_len(&l2->i_queue) && cansend(l2))
1537 mISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);
1538 } else
1539 nrerrorrecovery(fi);
1540 } else {
1541 if (!rsp && PollFlag)
1542 enquiry_response(l2);
1543 if (legalnr(l2, nr))
1544 setva(l2, nr);
1545 else
1546 nrerrorrecovery(fi);
1547 }
1548}
1549
1550static void
1551l2_got_FRMR(struct FsmInst *fi, int event, void *arg)
1552{
1553 struct layer2 *l2 = fi->userdata;
1554 struct sk_buff *skb = arg;
1555
1556 skb_pull(skb, l2addrsize(l2) + 1);
1557
1558 if (!(skb->data[0] & 1) || ((skb->data[0] & 3) == 1) || /* I or S */
1559 (IsUA(skb->data) && (fi->state == ST_L2_7))) {
1560 l2mgr(l2, MDL_ERROR_IND, (void *) 'K');
1561 establishlink(fi);
1562 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
1563 }
1564 dev_kfree_skb(skb);
1565}
1566
1567static void
1568l2_st24_tei_remove(struct FsmInst *fi, int event, void *arg)
1569{
1570 struct layer2 *l2 = fi->userdata;
1571
1572 skb_queue_purge(&l2->ui_queue);
1573 l2->tei = GROUP_TEI;
1574 mISDN_FsmChangeState(fi, ST_L2_1);
1575}
1576
1577static void
1578l2_st3_tei_remove(struct FsmInst *fi, int event, void *arg)
1579{
1580 struct layer2 *l2 = fi->userdata;
1581
1582 skb_queue_purge(&l2->ui_queue);
1583 l2->tei = GROUP_TEI;
1584 l2up_create(l2, DL_RELEASE_IND, 0, NULL);
1585 mISDN_FsmChangeState(fi, ST_L2_1);
1586}
1587
1588static void
1589l2_st5_tei_remove(struct FsmInst *fi, int event, void *arg)
1590{
1591 struct layer2 *l2 = fi->userdata;
1592
1593 skb_queue_purge(&l2->i_queue);
1594 skb_queue_purge(&l2->ui_queue);
1595 freewin(l2);
1596 l2->tei = GROUP_TEI;
1597 stop_t200(l2, 17);
1598 st5_dl_release_l2l3(l2);
1599 mISDN_FsmChangeState(fi, ST_L2_1);
1600}
1601
1602static void
1603l2_st6_tei_remove(struct FsmInst *fi, int event, void *arg)
1604{
1605 struct layer2 *l2 = fi->userdata;
1606
1607 skb_queue_purge(&l2->ui_queue);
1608 l2->tei = GROUP_TEI;
1609 stop_t200(l2, 18);
1610 l2up_create(l2, DL_RELEASE_IND, 0, NULL);
1611 mISDN_FsmChangeState(fi, ST_L2_1);
1612}
1613
1614static void
1615l2_tei_remove(struct FsmInst *fi, int event, void *arg)
1616{
1617 struct layer2 *l2 = fi->userdata;
1618
1619 skb_queue_purge(&l2->i_queue);
1620 skb_queue_purge(&l2->ui_queue);
1621 freewin(l2);
1622 l2->tei = GROUP_TEI;
1623 stop_t200(l2, 17);
1624 mISDN_FsmDelTimer(&l2->t203, 19);
1625 l2up_create(l2, DL_RELEASE_IND, 0, NULL);
1626/* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST,
1627 * MGR_SHORTSTATUS_IND, SSTATUS_L2_RELEASED,
1628 * 0, NULL, 0);
1629 */
1630 mISDN_FsmChangeState(fi, ST_L2_1);
1631}
1632
1633static void
1634l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg)
1635{
1636 struct layer2 *l2 = fi->userdata;
1637 struct sk_buff *skb = arg;
1638
1639 skb_queue_purge(&l2->i_queue);
1640 skb_queue_purge(&l2->ui_queue);
1641 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag))
1642 l2up(l2, DL_RELEASE_IND, skb);
1643 else
1644 dev_kfree_skb(skb);
1645}
1646
1647static void
1648l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg)
1649{
1650 struct layer2 *l2 = fi->userdata;
1651 struct sk_buff *skb = arg;
1652
1653 skb_queue_purge(&l2->i_queue);
1654 skb_queue_purge(&l2->ui_queue);
1655 freewin(l2);
1656 stop_t200(l2, 19);
1657 st5_dl_release_l2l3(l2);
1658 mISDN_FsmChangeState(fi, ST_L2_4);
1659 if (l2->tm)
1660 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1661 dev_kfree_skb(skb);
1662}
1663
1664static void
1665l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg)
1666{
1667 struct layer2 *l2 = fi->userdata;
1668 struct sk_buff *skb = arg;
1669
1670 skb_queue_purge(&l2->ui_queue);
1671 stop_t200(l2, 20);
1672 l2up(l2, DL_RELEASE_CNF, skb);
1673 mISDN_FsmChangeState(fi, ST_L2_4);
1674 if (l2->tm)
1675 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1676}
1677
1678static void
1679l2_persistant_da(struct FsmInst *fi, int event, void *arg)
1680{
1681 struct layer2 *l2 = fi->userdata;
1682 struct sk_buff *skb = arg;
1683
1684 skb_queue_purge(&l2->i_queue);
1685 skb_queue_purge(&l2->ui_queue);
1686 freewin(l2);
1687 stop_t200(l2, 19);
1688 mISDN_FsmDelTimer(&l2->t203, 19);
1689 l2up(l2, DL_RELEASE_IND, skb);
1690 mISDN_FsmChangeState(fi, ST_L2_4);
1691 if (l2->tm)
1692 l2_tei(l2, MDL_STATUS_DOWN_IND, 0);
1693}
1694
1695static void
1696l2_set_own_busy(struct FsmInst *fi, int event, void *arg)
1697{
1698 struct layer2 *l2 = fi->userdata;
1699 struct sk_buff *skb = arg;
1700
1701 if (!test_and_set_bit(FLG_OWN_BUSY, &l2->flag)) {
1702 enquiry_cr(l2, RNR, RSP, 0);
1703 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1704 }
1705 if (skb)
1706 dev_kfree_skb(skb);
1707}
1708
1709static void
1710l2_clear_own_busy(struct FsmInst *fi, int event, void *arg)
1711{
1712 struct layer2 *l2 = fi->userdata;
1713 struct sk_buff *skb = arg;
1714
1715 if (!test_and_clear_bit(FLG_OWN_BUSY, &l2->flag)) {
1716 enquiry_cr(l2, RR, RSP, 0);
1717 test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
1718 }
1719 if (skb)
1720 dev_kfree_skb(skb);
1721}
1722
1723static void
1724l2_frame_error(struct FsmInst *fi, int event, void *arg)
1725{
1726 struct layer2 *l2 = fi->userdata;
1727
1728 l2mgr(l2, MDL_ERROR_IND, arg);
1729}
1730
1731static void
1732l2_frame_error_reest(struct FsmInst *fi, int event, void *arg)
1733{
1734 struct layer2 *l2 = fi->userdata;
1735
1736 l2mgr(l2, MDL_ERROR_IND, arg);
1737 establishlink(fi);
1738 test_and_clear_bit(FLG_L3_INIT, &l2->flag);
1739}
1740
1741static struct FsmNode L2FnList[] =
1742{
1743 {ST_L2_1, EV_L2_DL_ESTABLISH_REQ, l2_mdl_assign},
1744 {ST_L2_2, EV_L2_DL_ESTABLISH_REQ, l2_go_st3},
1745 {ST_L2_4, EV_L2_DL_ESTABLISH_REQ, l2_establish},
1746 {ST_L2_5, EV_L2_DL_ESTABLISH_REQ, l2_discard_i_setl3},
1747 {ST_L2_7, EV_L2_DL_ESTABLISH_REQ, l2_l3_reestablish},
1748 {ST_L2_8, EV_L2_DL_ESTABLISH_REQ, l2_l3_reestablish},
1749 {ST_L2_4, EV_L2_DL_RELEASE_REQ, l2_release},
1750 {ST_L2_5, EV_L2_DL_RELEASE_REQ, l2_pend_rel},
1751 {ST_L2_7, EV_L2_DL_RELEASE_REQ, l2_disconnect},
1752 {ST_L2_8, EV_L2_DL_RELEASE_REQ, l2_disconnect},
1753 {ST_L2_5, EV_L2_DL_DATA, l2_feed_i_if_reest},
1754 {ST_L2_7, EV_L2_DL_DATA, l2_feed_i_pull},
1755 {ST_L2_8, EV_L2_DL_DATA, l2_feed_iqueue},
1756 {ST_L2_1, EV_L2_DL_UNITDATA, l2_queue_ui_assign},
1757 {ST_L2_2, EV_L2_DL_UNITDATA, l2_queue_ui},
1758 {ST_L2_3, EV_L2_DL_UNITDATA, l2_queue_ui},
1759 {ST_L2_4, EV_L2_DL_UNITDATA, l2_send_ui},
1760 {ST_L2_5, EV_L2_DL_UNITDATA, l2_send_ui},
1761 {ST_L2_6, EV_L2_DL_UNITDATA, l2_send_ui},
1762 {ST_L2_7, EV_L2_DL_UNITDATA, l2_send_ui},
1763 {ST_L2_8, EV_L2_DL_UNITDATA, l2_send_ui},
1764 {ST_L2_1, EV_L2_MDL_ASSIGN, l2_got_tei},
1765 {ST_L2_2, EV_L2_MDL_ASSIGN, l2_got_tei},
1766 {ST_L2_3, EV_L2_MDL_ASSIGN, l2_got_tei},
1767 {ST_L2_2, EV_L2_MDL_ERROR, l2_st24_tei_remove},
1768 {ST_L2_3, EV_L2_MDL_ERROR, l2_st3_tei_remove},
1769 {ST_L2_4, EV_L2_MDL_REMOVE, l2_st24_tei_remove},
1770 {ST_L2_5, EV_L2_MDL_REMOVE, l2_st5_tei_remove},
1771 {ST_L2_6, EV_L2_MDL_REMOVE, l2_st6_tei_remove},
1772 {ST_L2_7, EV_L2_MDL_REMOVE, l2_tei_remove},
1773 {ST_L2_8, EV_L2_MDL_REMOVE, l2_tei_remove},
1774 {ST_L2_4, EV_L2_SABME, l2_start_multi},
1775 {ST_L2_5, EV_L2_SABME, l2_send_UA},
1776 {ST_L2_6, EV_L2_SABME, l2_send_DM},
1777 {ST_L2_7, EV_L2_SABME, l2_restart_multi},
1778 {ST_L2_8, EV_L2_SABME, l2_restart_multi},
1779 {ST_L2_4, EV_L2_DISC, l2_send_DM},
1780 {ST_L2_5, EV_L2_DISC, l2_send_DM},
1781 {ST_L2_6, EV_L2_DISC, l2_send_UA},
1782 {ST_L2_7, EV_L2_DISC, l2_stop_multi},
1783 {ST_L2_8, EV_L2_DISC, l2_stop_multi},
1784 {ST_L2_4, EV_L2_UA, l2_mdl_error_ua},
1785 {ST_L2_5, EV_L2_UA, l2_connected},
1786 {ST_L2_6, EV_L2_UA, l2_released},
1787 {ST_L2_7, EV_L2_UA, l2_mdl_error_ua},
1788 {ST_L2_8, EV_L2_UA, l2_mdl_error_ua},
1789 {ST_L2_4, EV_L2_DM, l2_reestablish},
1790 {ST_L2_5, EV_L2_DM, l2_st5_dm_release},
1791 {ST_L2_6, EV_L2_DM, l2_st6_dm_release},
1792 {ST_L2_7, EV_L2_DM, l2_mdl_error_dm},
1793 {ST_L2_8, EV_L2_DM, l2_st8_mdl_error_dm},
1794 {ST_L2_1, EV_L2_UI, l2_got_ui},
1795 {ST_L2_2, EV_L2_UI, l2_got_ui},
1796 {ST_L2_3, EV_L2_UI, l2_got_ui},
1797 {ST_L2_4, EV_L2_UI, l2_got_ui},
1798 {ST_L2_5, EV_L2_UI, l2_got_ui},
1799 {ST_L2_6, EV_L2_UI, l2_got_ui},
1800 {ST_L2_7, EV_L2_UI, l2_got_ui},
1801 {ST_L2_8, EV_L2_UI, l2_got_ui},
1802 {ST_L2_7, EV_L2_FRMR, l2_got_FRMR},
1803 {ST_L2_8, EV_L2_FRMR, l2_got_FRMR},
1804 {ST_L2_7, EV_L2_SUPER, l2_st7_got_super},
1805 {ST_L2_8, EV_L2_SUPER, l2_st8_got_super},
1806 {ST_L2_7, EV_L2_I, l2_got_iframe},
1807 {ST_L2_8, EV_L2_I, l2_got_iframe},
1808 {ST_L2_5, EV_L2_T200, l2_st5_tout_200},
1809 {ST_L2_6, EV_L2_T200, l2_st6_tout_200},
1810 {ST_L2_7, EV_L2_T200, l2_st7_tout_200},
1811 {ST_L2_8, EV_L2_T200, l2_st8_tout_200},
1812 {ST_L2_7, EV_L2_T203, l2_st7_tout_203},
1813 {ST_L2_7, EV_L2_ACK_PULL, l2_pull_iqueue},
1814 {ST_L2_7, EV_L2_SET_OWN_BUSY, l2_set_own_busy},
1815 {ST_L2_8, EV_L2_SET_OWN_BUSY, l2_set_own_busy},
1816 {ST_L2_7, EV_L2_CLEAR_OWN_BUSY, l2_clear_own_busy},
1817 {ST_L2_8, EV_L2_CLEAR_OWN_BUSY, l2_clear_own_busy},
1818 {ST_L2_4, EV_L2_FRAME_ERROR, l2_frame_error},
1819 {ST_L2_5, EV_L2_FRAME_ERROR, l2_frame_error},
1820 {ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error},
1821 {ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1822 {ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1823 {ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistant_da},
1824 {ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove},
1825 {ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove},
1826 {ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistant_da},
1827 {ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistant_da},
1828 {ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistant_da},
1829 {ST_L2_7, EV_L1_DEACTIVATE, l2_persistant_da},
1830 {ST_L2_8, EV_L1_DEACTIVATE, l2_persistant_da},
1831};
1832
1833#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
1834
1835static int
1836ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb)
1837{
1838 u_char *datap = skb->data;
1839 int ret = -EINVAL;
1840 int psapi, ptei;
1841 u_int l;
1842 int c = 0;
1843
1844 l = l2addrsize(l2);
1845 if (skb->len <= l) {
1846 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *) 'N');
1847 return ret;
1848 }
1849 if (test_bit(FLG_LAPD, &l2->flag)) { /* Maybe not needed */
1850 psapi = *datap++;
1851 ptei = *datap++;
1852 if ((psapi & 1) || !(ptei & 1)) {
1853 printk(KERN_WARNING
1854 "l2 D-channel frame wrong EA0/EA1\n");
1855 return ret;
1856 }
1857 psapi >>= 2;
1858 ptei >>= 1;
1859 if (psapi != l2->sapi) {
1860 /* not our bussiness
1861 * printk(KERN_DEBUG "%s: sapi %d/%d sapi mismatch\n",
1862 * __func__,
1863 * psapi, l2->sapi);
1864 */
1865 dev_kfree_skb(skb);
1866 return 0;
1867 }
1868 if ((ptei != l2->tei) && (ptei != GROUP_TEI)) {
1869 /* not our bussiness
1870 * printk(KERN_DEBUG "%s: tei %d/%d sapi %d mismatch\n",
1871 * __func__,
1872 * ptei, l2->tei, psapi);
1873 */
1874 dev_kfree_skb(skb);
1875 return 0;
1876 }
1877 } else
1878 datap += l;
1879 if (!(*datap & 1)) { /* I-Frame */
1880 c = iframe_error(l2, skb);
1881 if (!c)
1882 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_I, skb);
1883 } else if (IsSFrame(datap, l2)) { /* S-Frame */
1884 c = super_error(l2, skb);
1885 if (!c)
1886 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SUPER, skb);
1887 } else if (IsUI(datap)) {
1888 c = UI_error(l2, skb);
1889 if (!c)
1890 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UI, skb);
1891 } else if (IsSABME(datap, l2)) {
1892 c = unnum_error(l2, skb, CMD);
1893 if (!c)
1894 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SABME, skb);
1895 } else if (IsUA(datap)) {
1896 c = unnum_error(l2, skb, RSP);
1897 if (!c)
1898 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UA, skb);
1899 } else if (IsDISC(datap)) {
1900 c = unnum_error(l2, skb, CMD);
1901 if (!c)
1902 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DISC, skb);
1903 } else if (IsDM(datap)) {
1904 c = unnum_error(l2, skb, RSP);
1905 if (!c)
1906 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DM, skb);
1907 } else if (IsFRMR(datap)) {
1908 c = FRMR_error(l2, skb);
1909 if (!c)
1910 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_FRMR, skb);
1911 } else
1912 c = 'L';
1913 if (c) {
1914 printk(KERN_WARNING "l2 D-channel frame error %c\n", c);
1915 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *)(long)c);
1916 }
1917 return ret;
1918}
1919
1920static int
1921l2_send(struct mISDNchannel *ch, struct sk_buff *skb)
1922{
1923 struct layer2 *l2 = container_of(ch, struct layer2, ch);
1924 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1925 int ret = -EINVAL;
1926
1927 if (*debug & DEBUG_L2_RECV)
1928 printk(KERN_DEBUG "%s: prim(%x) id(%x) tei(%d)\n",
1929 __func__, hh->prim, hh->id, l2->tei);
1930 switch (hh->prim) {
1931 case PH_DATA_IND:
1932 ret = ph_data_indication(l2, hh, skb);
1933 break;
1934 case PH_DATA_CNF:
1935 ret = ph_data_confirm(l2, hh, skb);
1936 break;
1937 case PH_ACTIVATE_IND:
1938 test_and_set_bit(FLG_L1_ACTIV, &l2->flag);
1939 l2up_create(l2, MPH_ACTIVATE_IND, 0, NULL);
1940 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag))
1941 ret = mISDN_FsmEvent(&l2->l2m,
1942 EV_L2_DL_ESTABLISH_REQ, skb);
1943 break;
1944 case PH_DEACTIVATE_IND:
1945 test_and_clear_bit(FLG_L1_ACTIV, &l2->flag);
1946 l2up_create(l2, MPH_DEACTIVATE_IND, 0, NULL);
1947 ret = mISDN_FsmEvent(&l2->l2m, EV_L1_DEACTIVATE, skb);
1948 break;
1949 case MPH_INFORMATION_IND:
1950 if (!l2->up)
1951 break;
1952 ret = l2->up->send(l2->up, skb);
1953 break;
1954 case DL_DATA_REQ:
1955 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_DATA, skb);
1956 break;
1957 case DL_UNITDATA_REQ:
1958 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_UNITDATA, skb);
1959 break;
1960 case DL_ESTABLISH_REQ:
1961 if (test_bit(FLG_LAPB, &l2->flag))
1962 test_and_set_bit(FLG_ORIG, &l2->flag);
1963 if (test_bit(FLG_L1_ACTIV, &l2->flag)) {
1964 if (test_bit(FLG_LAPD, &l2->flag) ||
1965 test_bit(FLG_ORIG, &l2->flag))
1966 ret = mISDN_FsmEvent(&l2->l2m,
1967 EV_L2_DL_ESTABLISH_REQ, skb);
1968 } else {
1969 if (test_bit(FLG_LAPD, &l2->flag) ||
1970 test_bit(FLG_ORIG, &l2->flag)) {
1971 test_and_set_bit(FLG_ESTAB_PEND,
1972 &l2->flag);
1973 }
1974 ret = l2down(l2, PH_ACTIVATE_REQ, l2_newid(l2),
1975 skb);
1976 }
1977 break;
1978 case DL_RELEASE_REQ:
1979 if (test_bit(FLG_LAPB, &l2->flag))
1980 l2down_create(l2, PH_DEACTIVATE_REQ,
1981 l2_newid(l2), 0, NULL);
1982 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_RELEASE_REQ,
1983 skb);
1984 break;
1985 default:
1986 if (*debug & DEBUG_L2)
1987 l2m_debug(&l2->l2m, "l2 unknown pr %04x",
1988 hh->prim);
1989 }
1990 if (ret) {
1991 dev_kfree_skb(skb);
1992 ret = 0;
1993 }
1994 return ret;
1995}
1996
1997int
1998tei_l2(struct layer2 *l2, u_int cmd, u_long arg)
1999{
2000 int ret = -EINVAL;
2001
2002 if (*debug & DEBUG_L2_TEI)
2003 printk(KERN_DEBUG "%s: cmd(%x)\n", __func__, cmd);
2004 switch (cmd) {
2005 case (MDL_ASSIGN_REQ):
2006 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ASSIGN, (void *)arg);
2007 break;
2008 case (MDL_REMOVE_REQ):
2009 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_REMOVE, NULL);
2010 break;
2011 case (MDL_ERROR_IND):
2012 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL);
2013 break;
2014 case (MDL_ERROR_RSP):
2015 /* ETS 300-125 5.3.2.1 Test: TC13010 */
2016 printk(KERN_NOTICE "MDL_ERROR|REQ (tei_l2)\n");
2017 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL);
2018 break;
2019 }
2020 return ret;
2021}
2022
2023static void
2024release_l2(struct layer2 *l2)
2025{
2026 mISDN_FsmDelTimer(&l2->t200, 21);
2027 mISDN_FsmDelTimer(&l2->t203, 16);
2028 skb_queue_purge(&l2->i_queue);
2029 skb_queue_purge(&l2->ui_queue);
2030 skb_queue_purge(&l2->down_queue);
2031 ReleaseWin(l2);
2032 if (test_bit(FLG_LAPD, &l2->flag)) {
2033 TEIrelease(l2);
2034 if (l2->ch.st)
2035 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D,
2036 CLOSE_CHANNEL, NULL);
2037 }
2038 kfree(l2);
2039}
2040
2041static int
2042l2_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
2043{
2044 struct layer2 *l2 = container_of(ch, struct layer2, ch);
2045 u_int info;
2046
2047 if (*debug & DEBUG_L2_CTRL)
2048 printk(KERN_DEBUG "%s:(%x)\n", __func__, cmd);
2049
2050 switch (cmd) {
2051 case OPEN_CHANNEL:
2052 if (test_bit(FLG_LAPD, &l2->flag)) {
2053 set_channel_address(&l2->ch, l2->sapi, l2->tei);
2054 info = DL_INFO_L2_CONNECT;
2055 l2up_create(l2, DL_INFORMATION_IND,
2056 sizeof(info), &info);
2057 }
2058 break;
2059 case CLOSE_CHANNEL:
2060 if (l2->ch.peer)
2061 l2->ch.peer->ctrl(l2->ch.peer, CLOSE_CHANNEL, NULL);
2062 release_l2(l2);
2063 break;
2064 }
2065 return 0;
2066}
2067
2068struct layer2 *
2069create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
2070{
2071 struct layer2 *l2;
2072 struct channel_req rq;
2073
2074 l2 = kzalloc(sizeof(struct layer2), GFP_KERNEL);
2075 if (!l2) {
2076 printk(KERN_ERR "kzalloc layer2 failed\n");
2077 return NULL;
2078 }
2079 l2->next_id = 1;
2080 l2->down_id = MISDN_ID_NONE;
2081 l2->up = ch;
2082 l2->ch.st = ch->st;
2083 l2->ch.send = l2_send;
2084 l2->ch.ctrl = l2_ctrl;
2085 switch (protocol) {
2086 case ISDN_P_LAPD_NT:
2087 test_and_set_bit(FLG_LAPD, &l2->flag);
2088 test_and_set_bit(FLG_LAPD_NET, &l2->flag);
2089 test_and_set_bit(FLG_MOD128, &l2->flag);
2090 l2->sapi = 0;
2091 l2->maxlen = MAX_DFRAME_LEN;
2092 if (test_bit(OPTION_L2_PMX, &options))
2093 l2->window = 7;
2094 else
2095 l2->window = 1;
2096 if (test_bit(OPTION_L2_PTP, &options))
2097 test_and_set_bit(FLG_PTP, &l2->flag);
2098 if (test_bit(OPTION_L2_FIXEDTEI, &options))
2099 test_and_set_bit(FLG_FIXED_TEI, &l2->flag);
2100 l2->tei = (u_int)arg;
2101 l2->T200 = 1000;
2102 l2->N200 = 3;
2103 l2->T203 = 10000;
2104 if (test_bit(OPTION_L2_PMX, &options))
2105 rq.protocol = ISDN_P_NT_E1;
2106 else
2107 rq.protocol = ISDN_P_NT_S0;
2108 rq.adr.channel = 0;
2109 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq);
2110 break;
2111 case ISDN_P_LAPD_TE:
2112 test_and_set_bit(FLG_LAPD, &l2->flag);
2113 test_and_set_bit(FLG_MOD128, &l2->flag);
2114 test_and_set_bit(FLG_ORIG, &l2->flag);
2115 l2->sapi = 0;
2116 l2->maxlen = MAX_DFRAME_LEN;
2117 if (test_bit(OPTION_L2_PMX, &options))
2118 l2->window = 7;
2119 else
2120 l2->window = 1;
2121 if (test_bit(OPTION_L2_PTP, &options))
2122 test_and_set_bit(FLG_PTP, &l2->flag);
2123 if (test_bit(OPTION_L2_FIXEDTEI, &options))
2124 test_and_set_bit(FLG_FIXED_TEI, &l2->flag);
2125 l2->tei = (u_int)arg;
2126 l2->T200 = 1000;
2127 l2->N200 = 3;
2128 l2->T203 = 10000;
2129 if (test_bit(OPTION_L2_PMX, &options))
2130 rq.protocol = ISDN_P_TE_E1;
2131 else
2132 rq.protocol = ISDN_P_TE_S0;
2133 rq.adr.channel = 0;
2134 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq);
2135 break;
2136 case ISDN_P_B_X75SLP:
2137 test_and_set_bit(FLG_LAPB, &l2->flag);
2138 l2->window = 7;
2139 l2->maxlen = MAX_DATA_SIZE;
2140 l2->T200 = 1000;
2141 l2->N200 = 4;
2142 l2->T203 = 5000;
2143 l2->addr.A = 3;
2144 l2->addr.B = 1;
2145 break;
2146 default:
2147 printk(KERN_ERR "layer2 create failed prt %x\n",
2148 protocol);
2149 kfree(l2);
2150 return NULL;
2151 }
2152 skb_queue_head_init(&l2->i_queue);
2153 skb_queue_head_init(&l2->ui_queue);
2154 skb_queue_head_init(&l2->down_queue);
2155 skb_queue_head_init(&l2->tmp_queue);
2156 InitWin(l2);
2157 l2->l2m.fsm = &l2fsm;
2158 if (test_bit(FLG_LAPB, &l2->flag) ||
2159 test_bit(FLG_PTP, &l2->flag) ||
2160 test_bit(FLG_LAPD_NET, &l2->flag))
2161 l2->l2m.state = ST_L2_4;
2162 else
2163 l2->l2m.state = ST_L2_1;
2164 l2->l2m.debug = *debug;
2165 l2->l2m.userdata = l2;
2166 l2->l2m.userint = 0;
2167 l2->l2m.printdebug = l2m_debug;
2168
2169 mISDN_FsmInitTimer(&l2->l2m, &l2->t200);
2170 mISDN_FsmInitTimer(&l2->l2m, &l2->t203);
2171 return l2;
2172}
2173
2174static int
2175x75create(struct channel_req *crq)
2176{
2177 struct layer2 *l2;
2178
2179 if (crq->protocol != ISDN_P_B_X75SLP)
2180 return -EPROTONOSUPPORT;
2181 l2 = create_l2(crq->ch, crq->protocol, 0, 0);
2182 if (!l2)
2183 return -ENOMEM;
2184 crq->ch = &l2->ch;
2185 crq->protocol = ISDN_P_B_HDLC;
2186 return 0;
2187}
2188
2189static struct Bprotocol X75SLP = {
2190 .Bprotocols = (1 << (ISDN_P_B_X75SLP & ISDN_P_B_MASK)),
2191 .name = "X75SLP",
2192 .create = x75create
2193};
2194
2195int
2196Isdnl2_Init(u_int *deb)
2197{
2198 debug = deb;
2199 mISDN_register_Bprotocol(&X75SLP);
2200 l2fsm.state_count = L2_STATE_COUNT;
2201 l2fsm.event_count = L2_EVENT_COUNT;
2202 l2fsm.strEvent = strL2Event;
2203 l2fsm.strState = strL2State;
2204 mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
2205 TEIInit(deb);
2206 return 0;
2207}
2208
2209void
2210Isdnl2_cleanup(void)
2211{
2212 mISDN_unregister_Bprotocol(&X75SLP);
2213 TEIFree();
2214 mISDN_FsmFree(&l2fsm);
2215}
2216
diff --git a/drivers/isdn/mISDN/layer2.h b/drivers/isdn/mISDN/layer2.h
new file mode 100644
index 000000000000..6293f80dc2d3
--- /dev/null
+++ b/drivers/isdn/mISDN/layer2.h
@@ -0,0 +1,140 @@
1/*
2 * Layer 2 defines
3 *
4 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
8 * published by the Free Software Foundation.
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 */
16
17#include <linux/mISDNif.h>
18#include <linux/skbuff.h>
19#include "fsm.h"
20
21#define MAX_WINDOW 8
22
23struct manager {
24 struct mISDNchannel ch;
25 struct mISDNchannel bcast;
26 u_long options;
27 struct list_head layer2;
28 rwlock_t lock;
29 struct FsmInst deact;
30 struct FsmTimer datimer;
31 struct sk_buff_head sendq;
32 struct mISDNchannel *up;
33 u_int nextid;
34 u_int lastid;
35};
36
37struct teimgr {
38 int ri;
39 int rcnt;
40 struct FsmInst tei_m;
41 struct FsmTimer timer;
42 int tval, nval;
43 struct layer2 *l2;
44 struct manager *mgr;
45};
46
47struct laddr {
48 u_char A;
49 u_char B;
50};
51
52struct layer2 {
53 struct list_head list;
54 struct mISDNchannel ch;
55 u_long flag;
56 int id;
57 struct mISDNchannel *up;
58 signed char sapi;
59 signed char tei;
60 struct laddr addr;
61 u_int maxlen;
62 struct teimgr *tm;
63 u_int vs, va, vr;
64 int rc;
65 u_int window;
66 u_int sow;
67 struct FsmInst l2m;
68 struct FsmTimer t200, t203;
69 int T200, N200, T203;
70 u_int next_id;
71 u_int down_id;
72 struct sk_buff *windowar[MAX_WINDOW];
73 struct sk_buff_head i_queue;
74 struct sk_buff_head ui_queue;
75 struct sk_buff_head down_queue;
76 struct sk_buff_head tmp_queue;
77};
78
79enum {
80 ST_L2_1,
81 ST_L2_2,
82 ST_L2_3,
83 ST_L2_4,
84 ST_L2_5,
85 ST_L2_6,
86 ST_L2_7,
87 ST_L2_8,
88};
89
90#define L2_STATE_COUNT (ST_L2_8+1)
91
92extern struct layer2 *create_l2(struct mISDNchannel *, u_int,
93 u_long, u_long);
94extern int tei_l2(struct layer2 *, u_int, u_long arg);
95
96
97/* from tei.c */
98extern int l2_tei(struct layer2 *, u_int, u_long arg);
99extern void TEIrelease(struct layer2 *);
100extern int TEIInit(u_int *);
101extern void TEIFree(void);
102
103#define MAX_L2HEADER_LEN 4
104
105#define RR 0x01
106#define RNR 0x05
107#define REJ 0x09
108#define SABME 0x6f
109#define SABM 0x2f
110#define DM 0x0f
111#define UI 0x03
112#define DISC 0x43
113#define UA 0x63
114#define FRMR 0x87
115#define XID 0xaf
116
117#define CMD 0
118#define RSP 1
119
120#define LC_FLUSH_WAIT 1
121
122#define FLG_LAPB 0
123#define FLG_LAPD 1
124#define FLG_ORIG 2
125#define FLG_MOD128 3
126#define FLG_PEND_REL 4
127#define FLG_L3_INIT 5
128#define FLG_T200_RUN 6
129#define FLG_ACK_PEND 7
130#define FLG_REJEXC 8
131#define FLG_OWN_BUSY 9
132#define FLG_PEER_BUSY 10
133#define FLG_DCHAN_BUSY 11
134#define FLG_L1_ACTIV 12
135#define FLG_ESTAB_PEND 13
136#define FLG_PTP 14
137#define FLG_FIXED_TEI 15
138#define FLG_L2BLOCK 16
139#define FLG_L1_NOTREADY 17
140#define FLG_LAPD_NET 18
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
new file mode 100644
index 000000000000..4ba4cc364c9e
--- /dev/null
+++ b/drivers/isdn/mISDN/socket.c
@@ -0,0 +1,781 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18#include <linux/mISDNif.h>
19#include "core.h"
20
21static int *debug;
22
23static struct proto mISDN_proto = {
24 .name = "misdn",
25 .owner = THIS_MODULE,
26 .obj_size = sizeof(struct mISDN_sock)
27};
28
29#define _pms(sk) ((struct mISDN_sock *)sk)
30
31static struct mISDN_sock_list data_sockets = {
32 .lock = __RW_LOCK_UNLOCKED(data_sockets.lock)
33};
34
35static struct mISDN_sock_list base_sockets = {
36 .lock = __RW_LOCK_UNLOCKED(base_sockets.lock)
37};
38
39#define L2_HEADER_LEN 4
40
41static inline struct sk_buff *
42_l2_alloc_skb(unsigned int len, gfp_t gfp_mask)
43{
44 struct sk_buff *skb;
45
46 skb = alloc_skb(len + L2_HEADER_LEN, gfp_mask);
47 if (likely(skb))
48 skb_reserve(skb, L2_HEADER_LEN);
49 return skb;
50}
51
52static void
53mISDN_sock_link(struct mISDN_sock_list *l, struct sock *sk)
54{
55 write_lock_bh(&l->lock);
56 sk_add_node(sk, &l->head);
57 write_unlock_bh(&l->lock);
58}
59
60static void mISDN_sock_unlink(struct mISDN_sock_list *l, struct sock *sk)
61{
62 write_lock_bh(&l->lock);
63 sk_del_node_init(sk);
64 write_unlock_bh(&l->lock);
65}
66
67static int
68mISDN_send(struct mISDNchannel *ch, struct sk_buff *skb)
69{
70 struct mISDN_sock *msk;
71 int err;
72
73 msk = container_of(ch, struct mISDN_sock, ch);
74 if (*debug & DEBUG_SOCKET)
75 printk(KERN_DEBUG "%s len %d %p\n", __func__, skb->len, skb);
76 if (msk->sk.sk_state == MISDN_CLOSED)
77 return -EUNATCH;
78 __net_timestamp(skb);
79 err = sock_queue_rcv_skb(&msk->sk, skb);
80 if (err)
81 printk(KERN_WARNING "%s: error %d\n", __func__, err);
82 return err;
83}
84
85static int
86mISDN_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
87{
88 struct mISDN_sock *msk;
89
90 msk = container_of(ch, struct mISDN_sock, ch);
91 if (*debug & DEBUG_SOCKET)
92 printk(KERN_DEBUG "%s(%p, %x, %p)\n", __func__, ch, cmd, arg);
93 switch (cmd) {
94 case CLOSE_CHANNEL:
95 msk->sk.sk_state = MISDN_CLOSED;
96 break;
97 }
98 return 0;
99}
100
101static inline void
102mISDN_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
103{
104 struct timeval tv;
105
106 if (_pms(sk)->cmask & MISDN_TIME_STAMP) {
107 skb_get_timestamp(skb, &tv);
108 put_cmsg(msg, SOL_MISDN, MISDN_TIME_STAMP, sizeof(tv), &tv);
109 }
110}
111
112static int
113mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
114 struct msghdr *msg, size_t len, int flags)
115{
116 struct sk_buff *skb;
117 struct sock *sk = sock->sk;
118 struct sockaddr_mISDN *maddr;
119
120 int copied, err;
121
122 if (*debug & DEBUG_SOCKET)
123 printk(KERN_DEBUG "%s: len %d, flags %x ch.nr %d, proto %x\n",
124 __func__, (int)len, flags, _pms(sk)->ch.nr,
125 sk->sk_protocol);
126 if (flags & (MSG_OOB))
127 return -EOPNOTSUPP;
128
129 if (sk->sk_state == MISDN_CLOSED)
130 return 0;
131
132 skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);
133 if (!skb)
134 return err;
135
136 if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) {
137 msg->msg_namelen = sizeof(struct sockaddr_mISDN);
138 maddr = (struct sockaddr_mISDN *)msg->msg_name;
139 maddr->family = AF_ISDN;
140 maddr->dev = _pms(sk)->dev->id;
141 if ((sk->sk_protocol == ISDN_P_LAPD_TE) ||
142 (sk->sk_protocol == ISDN_P_LAPD_NT)) {
143 maddr->channel = (mISDN_HEAD_ID(skb) >> 16) & 0xff;
144 maddr->tei = (mISDN_HEAD_ID(skb) >> 8) & 0xff;
145 maddr->sapi = mISDN_HEAD_ID(skb) & 0xff;
146 } else {
147 maddr->channel = _pms(sk)->ch.nr;
148 maddr->sapi = _pms(sk)->ch.addr & 0xFF;
149 maddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF;
150 }
151 } else {
152 if (msg->msg_namelen)
153 printk(KERN_WARNING "%s: too small namelen %d\n",
154 __func__, msg->msg_namelen);
155 msg->msg_namelen = 0;
156 }
157
158 copied = skb->len + MISDN_HEADER_LEN;
159 if (len < copied) {
160 if (flags & MSG_PEEK)
161 atomic_dec(&skb->users);
162 else
163 skb_queue_head(&sk->sk_receive_queue, skb);
164 return -ENOSPC;
165 }
166 memcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb),
167 MISDN_HEADER_LEN);
168
169 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
170
171 mISDN_sock_cmsg(sk, msg, skb);
172
173 skb_free_datagram(sk, skb);
174
175 return err ? : copied;
176}
177
178static int
179mISDN_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
180 struct msghdr *msg, size_t len)
181{
182 struct sock *sk = sock->sk;
183 struct sk_buff *skb;
184 int err = -ENOMEM;
185 struct sockaddr_mISDN *maddr;
186
187 if (*debug & DEBUG_SOCKET)
188 printk(KERN_DEBUG "%s: len %d flags %x ch %d proto %x\n",
189 __func__, (int)len, msg->msg_flags, _pms(sk)->ch.nr,
190 sk->sk_protocol);
191
192 if (msg->msg_flags & MSG_OOB)
193 return -EOPNOTSUPP;
194
195 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE))
196 return -EINVAL;
197
198 if (len < MISDN_HEADER_LEN)
199 return -EINVAL;
200
201 if (sk->sk_state != MISDN_BOUND)
202 return -EBADFD;
203
204 lock_sock(sk);
205
206 skb = _l2_alloc_skb(len, GFP_KERNEL);
207 if (!skb)
208 goto done;
209
210 if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
211 err = -EFAULT;
212 goto drop;
213 }
214
215 memcpy(mISDN_HEAD_P(skb), skb->data, MISDN_HEADER_LEN);
216 skb_pull(skb, MISDN_HEADER_LEN);
217
218 if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) {
219 /* if we have a address, we use it */
220 maddr = (struct sockaddr_mISDN *)msg->msg_name;
221 mISDN_HEAD_ID(skb) = maddr->channel;
222 } else { /* use default for L2 messages */
223 if ((sk->sk_protocol == ISDN_P_LAPD_TE) ||
224 (sk->sk_protocol == ISDN_P_LAPD_NT))
225 mISDN_HEAD_ID(skb) = _pms(sk)->ch.nr;
226 }
227
228 if (*debug & DEBUG_SOCKET)
229 printk(KERN_DEBUG "%s: ID:%x\n",
230 __func__, mISDN_HEAD_ID(skb));
231
232 err = -ENODEV;
233 if (!_pms(sk)->ch.peer ||
234 (err = _pms(sk)->ch.recv(_pms(sk)->ch.peer, skb)))
235 goto drop;
236
237 err = len;
238
239done:
240 release_sock(sk);
241 return err;
242
243drop:
244 kfree_skb(skb);
245 goto done;
246}
247
248static int
249data_sock_release(struct socket *sock)
250{
251 struct sock *sk = sock->sk;
252
253 if (*debug & DEBUG_SOCKET)
254 printk(KERN_DEBUG "%s(%p) sk=%p\n", __func__, sock, sk);
255 if (!sk)
256 return 0;
257 switch (sk->sk_protocol) {
258 case ISDN_P_TE_S0:
259 case ISDN_P_NT_S0:
260 case ISDN_P_TE_E1:
261 case ISDN_P_NT_E1:
262 if (sk->sk_state == MISDN_BOUND)
263 delete_channel(&_pms(sk)->ch);
264 else
265 mISDN_sock_unlink(&data_sockets, sk);
266 break;
267 case ISDN_P_LAPD_TE:
268 case ISDN_P_LAPD_NT:
269 case ISDN_P_B_RAW:
270 case ISDN_P_B_HDLC:
271 case ISDN_P_B_X75SLP:
272 case ISDN_P_B_L2DTMF:
273 case ISDN_P_B_L2DSP:
274 case ISDN_P_B_L2DSPHDLC:
275 delete_channel(&_pms(sk)->ch);
276 mISDN_sock_unlink(&data_sockets, sk);
277 break;
278 }
279
280 lock_sock(sk);
281
282 sock_orphan(sk);
283 skb_queue_purge(&sk->sk_receive_queue);
284
285 release_sock(sk);
286 sock_put(sk);
287
288 return 0;
289}
290
291static int
292data_sock_ioctl_bound(struct sock *sk, unsigned int cmd, void __user *p)
293{
294 struct mISDN_ctrl_req cq;
295 int err = -EINVAL, val;
296 struct mISDNchannel *bchan, *next;
297
298 lock_sock(sk);
299 if (!_pms(sk)->dev) {
300 err = -ENODEV;
301 goto done;
302 }
303 switch (cmd) {
304 case IMCTRLREQ:
305 if (copy_from_user(&cq, p, sizeof(cq))) {
306 err = -EFAULT;
307 break;
308 }
309 if ((sk->sk_protocol & ~ISDN_P_B_MASK) == ISDN_P_B_START) {
310 list_for_each_entry_safe(bchan, next,
311 &_pms(sk)->dev->bchannels, list) {
312 if (bchan->nr == cq.channel) {
313 err = bchan->ctrl(bchan,
314 CONTROL_CHANNEL, &cq);
315 break;
316 }
317 }
318 } else
319 err = _pms(sk)->dev->D.ctrl(&_pms(sk)->dev->D,
320 CONTROL_CHANNEL, &cq);
321 if (err)
322 break;
323 if (copy_to_user(p, &cq, sizeof(cq)))
324 err = -EFAULT;
325 break;
326 case IMCLEAR_L2:
327 if (sk->sk_protocol != ISDN_P_LAPD_NT) {
328 err = -EINVAL;
329 break;
330 }
331 if (get_user(val, (int __user *)p)) {
332 err = -EFAULT;
333 break;
334 }
335 err = _pms(sk)->dev->teimgr->ctrl(_pms(sk)->dev->teimgr,
336 CONTROL_CHANNEL, &val);
337 break;
338 default:
339 err = -EINVAL;
340 break;
341 }
342done:
343 release_sock(sk);
344 return err;
345}
346
347static int
348data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
349{
350 int err = 0, id;
351 struct sock *sk = sock->sk;
352 struct mISDNdevice *dev;
353 struct mISDNversion ver;
354
355 switch (cmd) {
356 case IMGETVERSION:
357 ver.major = MISDN_MAJOR_VERSION;
358 ver.minor = MISDN_MINOR_VERSION;
359 ver.release = MISDN_RELEASE;
360 if (copy_to_user((void __user *)arg, &ver, sizeof(ver)))
361 err = -EFAULT;
362 break;
363 case IMGETCOUNT:
364 id = get_mdevice_count();
365 if (put_user(id, (int __user *)arg))
366 err = -EFAULT;
367 break;
368 case IMGETDEVINFO:
369 if (get_user(id, (int __user *)arg)) {
370 err = -EFAULT;
371 break;
372 }
373 dev = get_mdevice(id);
374 if (dev) {
375 struct mISDN_devinfo di;
376
377 di.id = dev->id;
378 di.Dprotocols = dev->Dprotocols;
379 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
380 di.protocol = dev->D.protocol;
381 memcpy(di.channelmap, dev->channelmap,
382 MISDN_CHMAP_SIZE * 4);
383 di.nrbchan = dev->nrbchan;
384 strcpy(di.name, dev->name);
385 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
386 err = -EFAULT;
387 } else
388 err = -ENODEV;
389 break;
390 default:
391 if (sk->sk_state == MISDN_BOUND)
392 err = data_sock_ioctl_bound(sk, cmd,
393 (void __user *)arg);
394 else
395 err = -ENOTCONN;
396 }
397 return err;
398}
399
400static int data_sock_setsockopt(struct socket *sock, int level, int optname,
401 char __user *optval, int len)
402{
403 struct sock *sk = sock->sk;
404 int err = 0, opt = 0;
405
406 if (*debug & DEBUG_SOCKET)
407 printk(KERN_DEBUG "%s(%p, %d, %x, %p, %d)\n", __func__, sock,
408 level, optname, optval, len);
409
410 lock_sock(sk);
411
412 switch (optname) {
413 case MISDN_TIME_STAMP:
414 if (get_user(opt, (int __user *)optval)) {
415 err = -EFAULT;
416 break;
417 }
418
419 if (opt)
420 _pms(sk)->cmask |= MISDN_TIME_STAMP;
421 else
422 _pms(sk)->cmask &= ~MISDN_TIME_STAMP;
423 break;
424 default:
425 err = -ENOPROTOOPT;
426 break;
427 }
428 release_sock(sk);
429 return err;
430}
431
432static int data_sock_getsockopt(struct socket *sock, int level, int optname,
433 char __user *optval, int __user *optlen)
434{
435 struct sock *sk = sock->sk;
436 int len, opt;
437
438 if (get_user(len, optlen))
439 return -EFAULT;
440
441 switch (optname) {
442 case MISDN_TIME_STAMP:
443 if (_pms(sk)->cmask & MISDN_TIME_STAMP)
444 opt = 1;
445 else
446 opt = 0;
447
448 if (put_user(opt, optval))
449 return -EFAULT;
450 break;
451 default:
452 return -ENOPROTOOPT;
453 }
454
455 return 0;
456}
457
458static int
459data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
460{
461 struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr;
462 struct sock *sk = sock->sk;
463 int err = 0;
464
465 if (*debug & DEBUG_SOCKET)
466 printk(KERN_DEBUG "%s(%p) sk=%p\n", __func__, sock, sk);
467 if (addr_len != sizeof(struct sockaddr_mISDN))
468 return -EINVAL;
469 if (!maddr || maddr->family != AF_ISDN)
470 return -EINVAL;
471
472 lock_sock(sk);
473
474 if (_pms(sk)->dev) {
475 err = -EALREADY;
476 goto done;
477 }
478 _pms(sk)->dev = get_mdevice(maddr->dev);
479 if (!_pms(sk)->dev) {
480 err = -ENODEV;
481 goto done;
482 }
483 _pms(sk)->ch.send = mISDN_send;
484 _pms(sk)->ch.ctrl = mISDN_ctrl;
485
486 switch (sk->sk_protocol) {
487 case ISDN_P_TE_S0:
488 case ISDN_P_NT_S0:
489 case ISDN_P_TE_E1:
490 case ISDN_P_NT_E1:
491 mISDN_sock_unlink(&data_sockets, sk);
492 err = connect_layer1(_pms(sk)->dev, &_pms(sk)->ch,
493 sk->sk_protocol, maddr);
494 if (err)
495 mISDN_sock_link(&data_sockets, sk);
496 break;
497 case ISDN_P_LAPD_TE:
498 case ISDN_P_LAPD_NT:
499 err = create_l2entity(_pms(sk)->dev, &_pms(sk)->ch,
500 sk->sk_protocol, maddr);
501 break;
502 case ISDN_P_B_RAW:
503 case ISDN_P_B_HDLC:
504 case ISDN_P_B_X75SLP:
505 case ISDN_P_B_L2DTMF:
506 case ISDN_P_B_L2DSP:
507 case ISDN_P_B_L2DSPHDLC:
508 err = connect_Bstack(_pms(sk)->dev, &_pms(sk)->ch,
509 sk->sk_protocol, maddr);
510 break;
511 default:
512 err = -EPROTONOSUPPORT;
513 }
514 if (err)
515 goto done;
516 sk->sk_state = MISDN_BOUND;
517 _pms(sk)->ch.protocol = sk->sk_protocol;
518
519done:
520 release_sock(sk);
521 return err;
522}
523
524static int
525data_sock_getname(struct socket *sock, struct sockaddr *addr,
526 int *addr_len, int peer)
527{
528 struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr;
529 struct sock *sk = sock->sk;
530
531 if (!_pms(sk)->dev)
532 return -EBADFD;
533
534 lock_sock(sk);
535
536 *addr_len = sizeof(*maddr);
537 maddr->dev = _pms(sk)->dev->id;
538 maddr->channel = _pms(sk)->ch.nr;
539 maddr->sapi = _pms(sk)->ch.addr & 0xff;
540 maddr->tei = (_pms(sk)->ch.addr >> 8) & 0xff;
541 release_sock(sk);
542 return 0;
543}
544
545static const struct proto_ops data_sock_ops = {
546 .family = PF_ISDN,
547 .owner = THIS_MODULE,
548 .release = data_sock_release,
549 .ioctl = data_sock_ioctl,
550 .bind = data_sock_bind,
551 .getname = data_sock_getname,
552 .sendmsg = mISDN_sock_sendmsg,
553 .recvmsg = mISDN_sock_recvmsg,
554 .poll = datagram_poll,
555 .listen = sock_no_listen,
556 .shutdown = sock_no_shutdown,
557 .setsockopt = data_sock_setsockopt,
558 .getsockopt = data_sock_getsockopt,
559 .connect = sock_no_connect,
560 .socketpair = sock_no_socketpair,
561 .accept = sock_no_accept,
562 .mmap = sock_no_mmap
563};
564
565static int
566data_sock_create(struct net *net, struct socket *sock, int protocol)
567{
568 struct sock *sk;
569
570 if (sock->type != SOCK_DGRAM)
571 return -ESOCKTNOSUPPORT;
572
573 sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
574 if (!sk)
575 return -ENOMEM;
576
577 sock_init_data(sock, sk);
578
579 sock->ops = &data_sock_ops;
580 sock->state = SS_UNCONNECTED;
581 sock_reset_flag(sk, SOCK_ZAPPED);
582
583 sk->sk_protocol = protocol;
584 sk->sk_state = MISDN_OPEN;
585 mISDN_sock_link(&data_sockets, sk);
586
587 return 0;
588}
589
590static int
591base_sock_release(struct socket *sock)
592{
593 struct sock *sk = sock->sk;
594
595 printk(KERN_DEBUG "%s(%p) sk=%p\n", __func__, sock, sk);
596 if (!sk)
597 return 0;
598
599 mISDN_sock_unlink(&base_sockets, sk);
600 sock_orphan(sk);
601 sock_put(sk);
602
603 return 0;
604}
605
606static int
607base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
608{
609 int err = 0, id;
610 struct mISDNdevice *dev;
611 struct mISDNversion ver;
612
613 switch (cmd) {
614 case IMGETVERSION:
615 ver.major = MISDN_MAJOR_VERSION;
616 ver.minor = MISDN_MINOR_VERSION;
617 ver.release = MISDN_RELEASE;
618 if (copy_to_user((void __user *)arg, &ver, sizeof(ver)))
619 err = -EFAULT;
620 break;
621 case IMGETCOUNT:
622 id = get_mdevice_count();
623 if (put_user(id, (int __user *)arg))
624 err = -EFAULT;
625 break;
626 case IMGETDEVINFO:
627 if (get_user(id, (int __user *)arg)) {
628 err = -EFAULT;
629 break;
630 }
631 dev = get_mdevice(id);
632 if (dev) {
633 struct mISDN_devinfo di;
634
635 di.id = dev->id;
636 di.Dprotocols = dev->Dprotocols;
637 di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
638 di.protocol = dev->D.protocol;
639 memcpy(di.channelmap, dev->channelmap,
640 MISDN_CHMAP_SIZE * 4);
641 di.nrbchan = dev->nrbchan;
642 strcpy(di.name, dev->name);
643 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
644 err = -EFAULT;
645 } else
646 err = -ENODEV;
647 break;
648 default:
649 err = -EINVAL;
650 }
651 return err;
652}
653
654static int
655base_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
656{
657 struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr;
658 struct sock *sk = sock->sk;
659 int err = 0;
660
661 if (!maddr || maddr->family != AF_ISDN)
662 return -EINVAL;
663
664 lock_sock(sk);
665
666 if (_pms(sk)->dev) {
667 err = -EALREADY;
668 goto done;
669 }
670
671 _pms(sk)->dev = get_mdevice(maddr->dev);
672 if (!_pms(sk)->dev) {
673 err = -ENODEV;
674 goto done;
675 }
676 sk->sk_state = MISDN_BOUND;
677
678done:
679 release_sock(sk);
680 return err;
681}
682
683static const struct proto_ops base_sock_ops = {
684 .family = PF_ISDN,
685 .owner = THIS_MODULE,
686 .release = base_sock_release,
687 .ioctl = base_sock_ioctl,
688 .bind = base_sock_bind,
689 .getname = sock_no_getname,
690 .sendmsg = sock_no_sendmsg,
691 .recvmsg = sock_no_recvmsg,
692 .poll = sock_no_poll,
693 .listen = sock_no_listen,
694 .shutdown = sock_no_shutdown,
695 .setsockopt = sock_no_setsockopt,
696 .getsockopt = sock_no_getsockopt,
697 .connect = sock_no_connect,
698 .socketpair = sock_no_socketpair,
699 .accept = sock_no_accept,
700 .mmap = sock_no_mmap
701};
702
703
704static int
705base_sock_create(struct net *net, struct socket *sock, int protocol)
706{
707 struct sock *sk;
708
709 if (sock->type != SOCK_RAW)
710 return -ESOCKTNOSUPPORT;
711
712 sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
713 if (!sk)
714 return -ENOMEM;
715
716 sock_init_data(sock, sk);
717 sock->ops = &base_sock_ops;
718 sock->state = SS_UNCONNECTED;
719 sock_reset_flag(sk, SOCK_ZAPPED);
720 sk->sk_protocol = protocol;
721 sk->sk_state = MISDN_OPEN;
722 mISDN_sock_link(&base_sockets, sk);
723
724 return 0;
725}
726
727static int
728mISDN_sock_create(struct net *net, struct socket *sock, int proto)
729{
730 int err = -EPROTONOSUPPORT;
731
732 switch (proto) {
733 case ISDN_P_BASE:
734 err = base_sock_create(net, sock, proto);
735 break;
736 case ISDN_P_TE_S0:
737 case ISDN_P_NT_S0:
738 case ISDN_P_TE_E1:
739 case ISDN_P_NT_E1:
740 case ISDN_P_LAPD_TE:
741 case ISDN_P_LAPD_NT:
742 case ISDN_P_B_RAW:
743 case ISDN_P_B_HDLC:
744 case ISDN_P_B_X75SLP:
745 case ISDN_P_B_L2DTMF:
746 case ISDN_P_B_L2DSP:
747 case ISDN_P_B_L2DSPHDLC:
748 err = data_sock_create(net, sock, proto);
749 break;
750 default:
751 return err;
752 }
753
754 return err;
755}
756
757static struct
758net_proto_family mISDN_sock_family_ops = {
759 .owner = THIS_MODULE,
760 .family = PF_ISDN,
761 .create = mISDN_sock_create,
762};
763
764int
765misdn_sock_init(u_int *deb)
766{
767 int err;
768
769 debug = deb;
770 err = sock_register(&mISDN_sock_family_ops);
771 if (err)
772 printk(KERN_ERR "%s: error(%d)\n", __func__, err);
773 return err;
774}
775
776void
777misdn_sock_cleanup(void)
778{
779 sock_unregister(PF_ISDN);
780}
781
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
new file mode 100644
index 000000000000..54cfddcc4784
--- /dev/null
+++ b/drivers/isdn/mISDN/stack.c
@@ -0,0 +1,674 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17
18#include <linux/mISDNif.h>
19#include <linux/kthread.h>
20#include "core.h"
21
22static u_int *debug;
23
24static inline void
25_queue_message(struct mISDNstack *st, struct sk_buff *skb)
26{
27 struct mISDNhead *hh = mISDN_HEAD_P(skb);
28
29 if (*debug & DEBUG_QUEUE_FUNC)
30 printk(KERN_DEBUG "%s prim(%x) id(%x) %p\n",
31 __func__, hh->prim, hh->id, skb);
32 skb_queue_tail(&st->msgq, skb);
33 if (likely(!test_bit(mISDN_STACK_STOPPED, &st->status))) {
34 test_and_set_bit(mISDN_STACK_WORK, &st->status);
35 wake_up_interruptible(&st->workq);
36 }
37}
38
39int
40mISDN_queue_message(struct mISDNchannel *ch, struct sk_buff *skb)
41{
42 _queue_message(ch->st, skb);
43 return 0;
44}
45
46static struct mISDNchannel *
47get_channel4id(struct mISDNstack *st, u_int id)
48{
49 struct mISDNchannel *ch;
50
51 mutex_lock(&st->lmutex);
52 list_for_each_entry(ch, &st->layer2, list) {
53 if (id == ch->nr)
54 goto unlock;
55 }
56 ch = NULL;
57unlock:
58 mutex_unlock(&st->lmutex);
59 return ch;
60}
61
62static void
63send_socklist(struct mISDN_sock_list *sl, struct sk_buff *skb)
64{
65 struct hlist_node *node;
66 struct sock *sk;
67 struct sk_buff *cskb = NULL;
68
69 read_lock(&sl->lock);
70 sk_for_each(sk, node, &sl->head) {
71 if (sk->sk_state != MISDN_BOUND)
72 continue;
73 if (!cskb)
74 cskb = skb_copy(skb, GFP_KERNEL);
75 if (!cskb) {
76 printk(KERN_WARNING "%s no skb\n", __func__);
77 break;
78 }
79 if (!sock_queue_rcv_skb(sk, cskb))
80 cskb = NULL;
81 }
82 read_unlock(&sl->lock);
83 if (cskb)
84 dev_kfree_skb(cskb);
85}
86
87static void
88send_layer2(struct mISDNstack *st, struct sk_buff *skb)
89{
90 struct sk_buff *cskb;
91 struct mISDNhead *hh = mISDN_HEAD_P(skb);
92 struct mISDNchannel *ch;
93 int ret;
94
95 if (!st)
96 return;
97 mutex_lock(&st->lmutex);
98 if ((hh->id & MISDN_ID_ADDR_MASK) == MISDN_ID_ANY) { /* L2 for all */
99 list_for_each_entry(ch, &st->layer2, list) {
100 if (list_is_last(&ch->list, &st->layer2)) {
101 cskb = skb;
102 skb = NULL;
103 } else {
104 cskb = skb_copy(skb, GFP_KERNEL);
105 }
106 if (cskb) {
107 ret = ch->send(ch, cskb);
108 if (ret) {
109 if (*debug & DEBUG_SEND_ERR)
110 printk(KERN_DEBUG
111 "%s ch%d prim(%x) addr(%x)"
112 " err %d\n",
113 __func__, ch->nr,
114 hh->prim, ch->addr, ret);
115 dev_kfree_skb(cskb);
116 }
117 } else {
118 printk(KERN_WARNING "%s ch%d addr %x no mem\n",
119 __func__, ch->nr, ch->addr);
120 goto out;
121 }
122 }
123 } else {
124 list_for_each_entry(ch, &st->layer2, list) {
125 if ((hh->id & MISDN_ID_ADDR_MASK) == ch->addr) {
126 ret = ch->send(ch, skb);
127 if (!ret)
128 skb = NULL;
129 goto out;
130 }
131 }
132 ret = st->dev->teimgr->ctrl(st->dev->teimgr, CHECK_DATA, skb);
133 if (!ret)
134 skb = NULL;
135 else if (*debug & DEBUG_SEND_ERR)
136 printk(KERN_DEBUG
137 "%s ch%d mgr prim(%x) addr(%x) err %d\n",
138 __func__, ch->nr, hh->prim, ch->addr, ret);
139 }
140out:
141 mutex_unlock(&st->lmutex);
142 if (skb)
143 dev_kfree_skb(skb);
144}
145
146static inline int
147send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb)
148{
149 struct mISDNhead *hh = mISDN_HEAD_P(skb);
150 struct mISDNchannel *ch;
151 int lm;
152
153 lm = hh->prim & MISDN_LAYERMASK;
154 if (*debug & DEBUG_QUEUE_FUNC)
155 printk(KERN_DEBUG "%s prim(%x) id(%x) %p\n",
156 __func__, hh->prim, hh->id, skb);
157 if (lm == 0x1) {
158 if (!hlist_empty(&st->l1sock.head)) {
159 __net_timestamp(skb);
160 send_socklist(&st->l1sock, skb);
161 }
162 return st->layer1->send(st->layer1, skb);
163 } else if (lm == 0x2) {
164 if (!hlist_empty(&st->l1sock.head))
165 send_socklist(&st->l1sock, skb);
166 send_layer2(st, skb);
167 return 0;
168 } else if (lm == 0x4) {
169 ch = get_channel4id(st, hh->id);
170 if (ch)
171 return ch->send(ch, skb);
172 else
173 printk(KERN_WARNING
174 "%s: dev(%s) prim(%x) id(%x) no channel\n",
175 __func__, st->dev->name, hh->prim, hh->id);
176 } else if (lm == 0x8) {
177 WARN_ON(lm == 0x8);
178 ch = get_channel4id(st, hh->id);
179 if (ch)
180 return ch->send(ch, skb);
181 else
182 printk(KERN_WARNING
183 "%s: dev(%s) prim(%x) id(%x) no channel\n",
184 __func__, st->dev->name, hh->prim, hh->id);
185 } else {
186 /* broadcast not handled yet */
187 printk(KERN_WARNING "%s: dev(%s) prim %x not delivered\n",
188 __func__, st->dev->name, hh->prim);
189 }
190 return -ESRCH;
191}
192
193static void
194do_clear_stack(struct mISDNstack *st)
195{
196}
197
198static int
199mISDNStackd(void *data)
200{
201 struct mISDNstack *st = data;
202 int err = 0;
203
204#ifdef CONFIG_SMP
205 lock_kernel();
206#endif
207 sigfillset(&current->blocked);
208#ifdef CONFIG_SMP
209 unlock_kernel();
210#endif
211 if (*debug & DEBUG_MSG_THREAD)
212 printk(KERN_DEBUG "mISDNStackd %s started\n", st->dev->name);
213
214 if (st->notify != NULL) {
215 complete(st->notify);
216 st->notify = NULL;
217 }
218
219 for (;;) {
220 struct sk_buff *skb;
221
222 if (unlikely(test_bit(mISDN_STACK_STOPPED, &st->status))) {
223 test_and_clear_bit(mISDN_STACK_WORK, &st->status);
224 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
225 } else
226 test_and_set_bit(mISDN_STACK_RUNNING, &st->status);
227 while (test_bit(mISDN_STACK_WORK, &st->status)) {
228 skb = skb_dequeue(&st->msgq);
229 if (!skb) {
230 test_and_clear_bit(mISDN_STACK_WORK,
231 &st->status);
232 /* test if a race happens */
233 skb = skb_dequeue(&st->msgq);
234 if (!skb)
235 continue;
236 test_and_set_bit(mISDN_STACK_WORK,
237 &st->status);
238 }
239#ifdef MISDN_MSG_STATS
240 st->msg_cnt++;
241#endif
242 err = send_msg_to_layer(st, skb);
243 if (unlikely(err)) {
244 if (*debug & DEBUG_SEND_ERR)
245 printk(KERN_DEBUG
246 "%s: %s prim(%x) id(%x) "
247 "send call(%d)\n",
248 __func__, st->dev->name,
249 mISDN_HEAD_PRIM(skb),
250 mISDN_HEAD_ID(skb), err);
251 dev_kfree_skb(skb);
252 continue;
253 }
254 if (unlikely(test_bit(mISDN_STACK_STOPPED,
255 &st->status))) {
256 test_and_clear_bit(mISDN_STACK_WORK,
257 &st->status);
258 test_and_clear_bit(mISDN_STACK_RUNNING,
259 &st->status);
260 break;
261 }
262 }
263 if (test_bit(mISDN_STACK_CLEARING, &st->status)) {
264 test_and_set_bit(mISDN_STACK_STOPPED, &st->status);
265 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
266 do_clear_stack(st);
267 test_and_clear_bit(mISDN_STACK_CLEARING, &st->status);
268 test_and_set_bit(mISDN_STACK_RESTART, &st->status);
269 }
270 if (test_and_clear_bit(mISDN_STACK_RESTART, &st->status)) {
271 test_and_clear_bit(mISDN_STACK_STOPPED, &st->status);
272 test_and_set_bit(mISDN_STACK_RUNNING, &st->status);
273 if (!skb_queue_empty(&st->msgq))
274 test_and_set_bit(mISDN_STACK_WORK,
275 &st->status);
276 }
277 if (test_bit(mISDN_STACK_ABORT, &st->status))
278 break;
279 if (st->notify != NULL) {
280 complete(st->notify);
281 st->notify = NULL;
282 }
283#ifdef MISDN_MSG_STATS
284 st->sleep_cnt++;
285#endif
286 test_and_clear_bit(mISDN_STACK_ACTIVE, &st->status);
287 wait_event_interruptible(st->workq, (st->status &
288 mISDN_STACK_ACTION_MASK));
289 if (*debug & DEBUG_MSG_THREAD)
290 printk(KERN_DEBUG "%s: %s wake status %08lx\n",
291 __func__, st->dev->name, st->status);
292 test_and_set_bit(mISDN_STACK_ACTIVE, &st->status);
293
294 test_and_clear_bit(mISDN_STACK_WAKEUP, &st->status);
295
296 if (test_bit(mISDN_STACK_STOPPED, &st->status)) {
297 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
298#ifdef MISDN_MSG_STATS
299 st->stopped_cnt++;
300#endif
301 }
302 }
303#ifdef MISDN_MSG_STATS
304 printk(KERN_DEBUG "mISDNStackd daemon for %s proceed %d "
305 "msg %d sleep %d stopped\n",
306 st->dev->name, st->msg_cnt, st->sleep_cnt, st->stopped_cnt);
307 printk(KERN_DEBUG
308 "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n",
309 st->dev->name, st->thread->utime, st->thread->stime);
310 printk(KERN_DEBUG
311 "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n",
312 st->dev->name, st->thread->nvcsw, st->thread->nivcsw);
313 printk(KERN_DEBUG "mISDNStackd daemon for %s killed now\n",
314 st->dev->name);
315#endif
316 test_and_set_bit(mISDN_STACK_KILLED, &st->status);
317 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
318 test_and_clear_bit(mISDN_STACK_ACTIVE, &st->status);
319 test_and_clear_bit(mISDN_STACK_ABORT, &st->status);
320 skb_queue_purge(&st->msgq);
321 st->thread = NULL;
322 if (st->notify != NULL) {
323 complete(st->notify);
324 st->notify = NULL;
325 }
326 return 0;
327}
328
329static int
330l1_receive(struct mISDNchannel *ch, struct sk_buff *skb)
331{
332 if (!ch->st)
333 return -ENODEV;
334 __net_timestamp(skb);
335 _queue_message(ch->st, skb);
336 return 0;
337}
338
339void
340set_channel_address(struct mISDNchannel *ch, u_int sapi, u_int tei)
341{
342 ch->addr = sapi | (tei << 8);
343}
344
345void
346__add_layer2(struct mISDNchannel *ch, struct mISDNstack *st)
347{
348 list_add_tail(&ch->list, &st->layer2);
349}
350
351void
352add_layer2(struct mISDNchannel *ch, struct mISDNstack *st)
353{
354 mutex_lock(&st->lmutex);
355 __add_layer2(ch, st);
356 mutex_unlock(&st->lmutex);
357}
358
359static int
360st_own_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
361{
362 if (!ch->st || ch->st->layer1)
363 return -EINVAL;
364 return ch->st->layer1->ctrl(ch->st->layer1, cmd, arg);
365}
366
367int
368create_stack(struct mISDNdevice *dev)
369{
370 struct mISDNstack *newst;
371 int err;
372 DECLARE_COMPLETION_ONSTACK(done);
373
374 newst = kzalloc(sizeof(struct mISDNstack), GFP_KERNEL);
375 if (!newst) {
376 printk(KERN_ERR "kmalloc mISDN_stack failed\n");
377 return -ENOMEM;
378 }
379 newst->dev = dev;
380 INIT_LIST_HEAD(&newst->layer2);
381 INIT_HLIST_HEAD(&newst->l1sock.head);
382 rwlock_init(&newst->l1sock.lock);
383 init_waitqueue_head(&newst->workq);
384 skb_queue_head_init(&newst->msgq);
385 mutex_init(&newst->lmutex);
386 dev->D.st = newst;
387 err = create_teimanager(dev);
388 if (err) {
389 printk(KERN_ERR "kmalloc teimanager failed\n");
390 kfree(newst);
391 return err;
392 }
393 dev->teimgr->peer = &newst->own;
394 dev->teimgr->recv = mISDN_queue_message;
395 dev->teimgr->st = newst;
396 newst->layer1 = &dev->D;
397 dev->D.recv = l1_receive;
398 dev->D.peer = &newst->own;
399 newst->own.st = newst;
400 newst->own.ctrl = st_own_ctrl;
401 newst->own.send = mISDN_queue_message;
402 newst->own.recv = mISDN_queue_message;
403 if (*debug & DEBUG_CORE_FUNC)
404 printk(KERN_DEBUG "%s: st(%s)\n", __func__, newst->dev->name);
405 newst->notify = &done;
406 newst->thread = kthread_run(mISDNStackd, (void *)newst, "mISDN_%s",
407 newst->dev->name);
408 if (IS_ERR(newst->thread)) {
409 err = PTR_ERR(newst->thread);
410 printk(KERN_ERR
411 "mISDN:cannot create kernel thread for %s (%d)\n",
412 newst->dev->name, err);
413 delete_teimanager(dev->teimgr);
414 kfree(newst);
415 } else
416 wait_for_completion(&done);
417 return err;
418}
419
420int
421connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch,
422 u_int protocol, struct sockaddr_mISDN *adr)
423{
424 struct mISDN_sock *msk = container_of(ch, struct mISDN_sock, ch);
425 struct channel_req rq;
426 int err;
427
428
429 if (*debug & DEBUG_CORE_FUNC)
430 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
431 __func__, dev->name, protocol, adr->dev, adr->channel,
432 adr->sapi, adr->tei);
433 switch (protocol) {
434 case ISDN_P_NT_S0:
435 case ISDN_P_NT_E1:
436 case ISDN_P_TE_S0:
437 case ISDN_P_TE_E1:
438#ifdef PROTOCOL_CHECK
439 /* this should be enhanced */
440 if (!list_empty(&dev->D.st->layer2)
441 && dev->D.protocol != protocol)
442 return -EBUSY;
443 if (!hlist_empty(&dev->D.st->l1sock.head)
444 && dev->D.protocol != protocol)
445 return -EBUSY;
446#endif
447 ch->recv = mISDN_queue_message;
448 ch->peer = &dev->D.st->own;
449 ch->st = dev->D.st;
450 rq.protocol = protocol;
451 rq.adr.channel = 0;
452 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq);
453 printk(KERN_DEBUG "%s: ret 1 %d\n", __func__, err);
454 if (err)
455 return err;
456 write_lock_bh(&dev->D.st->l1sock.lock);
457 sk_add_node(&msk->sk, &dev->D.st->l1sock.head);
458 write_unlock_bh(&dev->D.st->l1sock.lock);
459 break;
460 default:
461 return -ENOPROTOOPT;
462 }
463 return 0;
464}
465
466int
467connect_Bstack(struct mISDNdevice *dev, struct mISDNchannel *ch,
468 u_int protocol, struct sockaddr_mISDN *adr)
469{
470 struct channel_req rq, rq2;
471 int pmask, err;
472 struct Bprotocol *bp;
473
474 if (*debug & DEBUG_CORE_FUNC)
475 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
476 __func__, dev->name, protocol,
477 adr->dev, adr->channel, adr->sapi,
478 adr->tei);
479 ch->st = dev->D.st;
480 pmask = 1 << (protocol & ISDN_P_B_MASK);
481 if (pmask & dev->Bprotocols) {
482 rq.protocol = protocol;
483 rq.adr = *adr;
484 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq);
485 if (err)
486 return err;
487 ch->recv = rq.ch->send;
488 ch->peer = rq.ch;
489 rq.ch->recv = ch->send;
490 rq.ch->peer = ch;
491 rq.ch->st = dev->D.st;
492 } else {
493 bp = get_Bprotocol4mask(pmask);
494 if (!bp)
495 return -ENOPROTOOPT;
496 rq2.protocol = protocol;
497 rq2.adr = *adr;
498 rq2.ch = ch;
499 err = bp->create(&rq2);
500 if (err)
501 return err;
502 ch->recv = rq2.ch->send;
503 ch->peer = rq2.ch;
504 rq2.ch->st = dev->D.st;
505 rq.protocol = rq2.protocol;
506 rq.adr = *adr;
507 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq);
508 if (err) {
509 rq2.ch->ctrl(rq2.ch, CLOSE_CHANNEL, NULL);
510 return err;
511 }
512 rq2.ch->recv = rq.ch->send;
513 rq2.ch->peer = rq.ch;
514 rq.ch->recv = rq2.ch->send;
515 rq.ch->peer = rq2.ch;
516 rq.ch->st = dev->D.st;
517 }
518 ch->protocol = protocol;
519 ch->nr = rq.ch->nr;
520 return 0;
521}
522
523int
524create_l2entity(struct mISDNdevice *dev, struct mISDNchannel *ch,
525 u_int protocol, struct sockaddr_mISDN *adr)
526{
527 struct channel_req rq;
528 int err;
529
530 if (*debug & DEBUG_CORE_FUNC)
531 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
532 __func__, dev->name, protocol,
533 adr->dev, adr->channel, adr->sapi,
534 adr->tei);
535 rq.protocol = ISDN_P_TE_S0;
536 if (dev->Dprotocols & (1 << ISDN_P_TE_E1))
537 rq.protocol = ISDN_P_TE_E1;
538 switch (protocol) {
539 case ISDN_P_LAPD_NT:
540 rq.protocol = ISDN_P_NT_S0;
541 if (dev->Dprotocols & (1 << ISDN_P_NT_E1))
542 rq.protocol = ISDN_P_NT_E1;
543 case ISDN_P_LAPD_TE:
544#ifdef PROTOCOL_CHECK
545 /* this should be enhanced */
546 if (!list_empty(&dev->D.st->layer2)
547 && dev->D.protocol != protocol)
548 return -EBUSY;
549 if (!hlist_empty(&dev->D.st->l1sock.head)
550 && dev->D.protocol != protocol)
551 return -EBUSY;
552#endif
553 ch->recv = mISDN_queue_message;
554 ch->peer = &dev->D.st->own;
555 ch->st = dev->D.st;
556 rq.adr.channel = 0;
557 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq);
558 printk(KERN_DEBUG "%s: ret 1 %d\n", __func__, err);
559 if (err)
560 break;
561 rq.protocol = protocol;
562 rq.adr = *adr;
563 rq.ch = ch;
564 err = dev->teimgr->ctrl(dev->teimgr, OPEN_CHANNEL, &rq);
565 printk(KERN_DEBUG "%s: ret 2 %d\n", __func__, err);
566 if (!err) {
567 if ((protocol == ISDN_P_LAPD_NT) && !rq.ch)
568 break;
569 add_layer2(rq.ch, dev->D.st);
570 rq.ch->recv = mISDN_queue_message;
571 rq.ch->peer = &dev->D.st->own;
572 rq.ch->ctrl(rq.ch, OPEN_CHANNEL, NULL); /* can't fail */
573 }
574 break;
575 default:
576 err = -EPROTONOSUPPORT;
577 }
578 return err;
579}
580
581void
582delete_channel(struct mISDNchannel *ch)
583{
584 struct mISDN_sock *msk = container_of(ch, struct mISDN_sock, ch);
585 struct mISDNchannel *pch;
586
587 if (!ch->st) {
588 printk(KERN_WARNING "%s: no stack\n", __func__);
589 return;
590 }
591 if (*debug & DEBUG_CORE_FUNC)
592 printk(KERN_DEBUG "%s: st(%s) protocol(%x)\n", __func__,
593 ch->st->dev->name, ch->protocol);
594 if (ch->protocol >= ISDN_P_B_START) {
595 if (ch->peer) {
596 ch->peer->ctrl(ch->peer, CLOSE_CHANNEL, NULL);
597 ch->peer = NULL;
598 }
599 return;
600 }
601 switch (ch->protocol) {
602 case ISDN_P_NT_S0:
603 case ISDN_P_TE_S0:
604 case ISDN_P_NT_E1:
605 case ISDN_P_TE_E1:
606 write_lock_bh(&ch->st->l1sock.lock);
607 sk_del_node_init(&msk->sk);
608 write_unlock_bh(&ch->st->l1sock.lock);
609 ch->st->dev->D.ctrl(&ch->st->dev->D, CLOSE_CHANNEL, NULL);
610 break;
611 case ISDN_P_LAPD_TE:
612 pch = get_channel4id(ch->st, ch->nr);
613 if (pch) {
614 mutex_lock(&ch->st->lmutex);
615 list_del(&pch->list);
616 mutex_unlock(&ch->st->lmutex);
617 pch->ctrl(pch, CLOSE_CHANNEL, NULL);
618 pch = ch->st->dev->teimgr;
619 pch->ctrl(pch, CLOSE_CHANNEL, NULL);
620 } else
621 printk(KERN_WARNING "%s: no l2 channel\n",
622 __func__);
623 break;
624 case ISDN_P_LAPD_NT:
625 pch = ch->st->dev->teimgr;
626 if (pch) {
627 pch->ctrl(pch, CLOSE_CHANNEL, NULL);
628 } else
629 printk(KERN_WARNING "%s: no l2 channel\n",
630 __func__);
631 break;
632 default:
633 break;
634 }
635 return;
636}
637
638void
639delete_stack(struct mISDNdevice *dev)
640{
641 struct mISDNstack *st = dev->D.st;
642 DECLARE_COMPLETION_ONSTACK(done);
643
644 if (*debug & DEBUG_CORE_FUNC)
645 printk(KERN_DEBUG "%s: st(%s)\n", __func__,
646 st->dev->name);
647 if (dev->teimgr)
648 delete_teimanager(dev->teimgr);
649 if (st->thread) {
650 if (st->notify) {
651 printk(KERN_WARNING "%s: notifier in use\n",
652 __func__);
653 complete(st->notify);
654 }
655 st->notify = &done;
656 test_and_set_bit(mISDN_STACK_ABORT, &st->status);
657 test_and_set_bit(mISDN_STACK_WAKEUP, &st->status);
658 wake_up_interruptible(&st->workq);
659 wait_for_completion(&done);
660 }
661 if (!list_empty(&st->layer2))
662 printk(KERN_WARNING "%s: layer2 list not empty\n",
663 __func__);
664 if (!hlist_empty(&st->l1sock.head))
665 printk(KERN_WARNING "%s: layer1 list not empty\n",
666 __func__);
667 kfree(st);
668}
669
670void
671mISDN_initstack(u_int *dp)
672{
673 debug = dp;
674}
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
new file mode 100644
index 000000000000..6fbae42127bf
--- /dev/null
+++ b/drivers/isdn/mISDN/tei.c
@@ -0,0 +1,1340 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.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 version 2 as
9 * published by the Free Software Foundation.
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 */
17#include "layer2.h"
18#include <linux/random.h>
19#include "core.h"
20
21#define ID_REQUEST 1
22#define ID_ASSIGNED 2
23#define ID_DENIED 3
24#define ID_CHK_REQ 4
25#define ID_CHK_RES 5
26#define ID_REMOVE 6
27#define ID_VERIFY 7
28
29#define TEI_ENTITY_ID 0xf
30
31#define MGR_PH_ACTIVE 16
32#define MGR_PH_NOTREADY 17
33
34#define DATIMER_VAL 10000
35
36static u_int *debug;
37
38static struct Fsm deactfsm = {NULL, 0, 0, NULL, NULL};
39static struct Fsm teifsmu = {NULL, 0, 0, NULL, NULL};
40static struct Fsm teifsmn = {NULL, 0, 0, NULL, NULL};
41
42enum {
43 ST_L1_DEACT,
44 ST_L1_DEACT_PENDING,
45 ST_L1_ACTIV,
46};
47#define DEACT_STATE_COUNT (ST_L1_ACTIV+1)
48
49static char *strDeactState[] =
50{
51 "ST_L1_DEACT",
52 "ST_L1_DEACT_PENDING",
53 "ST_L1_ACTIV",
54};
55
56enum {
57 EV_ACTIVATE,
58 EV_ACTIVATE_IND,
59 EV_DEACTIVATE,
60 EV_DEACTIVATE_IND,
61 EV_UI,
62 EV_DATIMER,
63};
64
65#define DEACT_EVENT_COUNT (EV_DATIMER+1)
66
67static char *strDeactEvent[] =
68{
69 "EV_ACTIVATE",
70 "EV_ACTIVATE_IND",
71 "EV_DEACTIVATE",
72 "EV_DEACTIVATE_IND",
73 "EV_UI",
74 "EV_DATIMER",
75};
76
77static void
78da_debug(struct FsmInst *fi, char *fmt, ...)
79{
80 struct manager *mgr = fi->userdata;
81 va_list va;
82
83 if (!(*debug & DEBUG_L2_TEIFSM))
84 return;
85 va_start(va, fmt);
86 printk(KERN_DEBUG "mgr(%d): ", mgr->ch.st->dev->id);
87 vprintk(fmt, va);
88 printk("\n");
89 va_end(va);
90}
91
92static void
93da_activate(struct FsmInst *fi, int event, void *arg)
94{
95 struct manager *mgr = fi->userdata;
96
97 if (fi->state == ST_L1_DEACT_PENDING)
98 mISDN_FsmDelTimer(&mgr->datimer, 1);
99 mISDN_FsmChangeState(fi, ST_L1_ACTIV);
100}
101
102static void
103da_deactivate_ind(struct FsmInst *fi, int event, void *arg)
104{
105 mISDN_FsmChangeState(fi, ST_L1_DEACT);
106}
107
108static void
109da_deactivate(struct FsmInst *fi, int event, void *arg)
110{
111 struct manager *mgr = fi->userdata;
112 struct layer2 *l2;
113 u_long flags;
114
115 read_lock_irqsave(&mgr->lock, flags);
116 list_for_each_entry(l2, &mgr->layer2, list) {
117 if (l2->l2m.state > ST_L2_4) {
118 /* have still activ TEI */
119 read_unlock_irqrestore(&mgr->lock, flags);
120 return;
121 }
122 }
123 read_unlock_irqrestore(&mgr->lock, flags);
124 /* All TEI are inactiv */
125 mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, NULL, 1);
126 mISDN_FsmChangeState(fi, ST_L1_DEACT_PENDING);
127}
128
129static void
130da_ui(struct FsmInst *fi, int event, void *arg)
131{
132 struct manager *mgr = fi->userdata;
133
134 /* restart da timer */
135 mISDN_FsmDelTimer(&mgr->datimer, 2);
136 mISDN_FsmAddTimer(&mgr->datimer, DATIMER_VAL, EV_DATIMER, NULL, 2);
137
138}
139
140static void
141da_timer(struct FsmInst *fi, int event, void *arg)
142{
143 struct manager *mgr = fi->userdata;
144 struct layer2 *l2;
145 u_long flags;
146
147 /* check again */
148 read_lock_irqsave(&mgr->lock, flags);
149 list_for_each_entry(l2, &mgr->layer2, list) {
150 if (l2->l2m.state > ST_L2_4) {
151 /* have still activ TEI */
152 read_unlock_irqrestore(&mgr->lock, flags);
153 mISDN_FsmChangeState(fi, ST_L1_ACTIV);
154 return;
155 }
156 }
157 read_unlock_irqrestore(&mgr->lock, flags);
158 /* All TEI are inactiv */
159 mISDN_FsmChangeState(fi, ST_L1_DEACT);
160 _queue_data(&mgr->ch, PH_DEACTIVATE_REQ, MISDN_ID_ANY, 0, NULL,
161 GFP_ATOMIC);
162}
163
164static struct FsmNode DeactFnList[] =
165{
166 {ST_L1_DEACT, EV_ACTIVATE_IND, da_activate},
167 {ST_L1_ACTIV, EV_DEACTIVATE_IND, da_deactivate_ind},
168 {ST_L1_ACTIV, EV_DEACTIVATE, da_deactivate},
169 {ST_L1_DEACT_PENDING, EV_ACTIVATE, da_activate},
170 {ST_L1_DEACT_PENDING, EV_UI, da_ui},
171 {ST_L1_DEACT_PENDING, EV_DATIMER, da_timer},
172};
173
174enum {
175 ST_TEI_NOP,
176 ST_TEI_IDREQ,
177 ST_TEI_IDVERIFY,
178};
179
180#define TEI_STATE_COUNT (ST_TEI_IDVERIFY+1)
181
182static char *strTeiState[] =
183{
184 "ST_TEI_NOP",
185 "ST_TEI_IDREQ",
186 "ST_TEI_IDVERIFY",
187};
188
189enum {
190 EV_IDREQ,
191 EV_ASSIGN,
192 EV_ASSIGN_REQ,
193 EV_DENIED,
194 EV_CHKREQ,
195 EV_CHKRESP,
196 EV_REMOVE,
197 EV_VERIFY,
198 EV_TIMER,
199};
200
201#define TEI_EVENT_COUNT (EV_TIMER+1)
202
203static char *strTeiEvent[] =
204{
205 "EV_IDREQ",
206 "EV_ASSIGN",
207 "EV_ASSIGN_REQ",
208 "EV_DENIED",
209 "EV_CHKREQ",
210 "EV_CHKRESP",
211 "EV_REMOVE",
212 "EV_VERIFY",
213 "EV_TIMER",
214};
215
216static void
217tei_debug(struct FsmInst *fi, char *fmt, ...)
218{
219 struct teimgr *tm = fi->userdata;
220 va_list va;
221
222 if (!(*debug & DEBUG_L2_TEIFSM))
223 return;
224 va_start(va, fmt);
225 printk(KERN_DEBUG "tei(%d): ", tm->l2->tei);
226 vprintk(fmt, va);
227 printk("\n");
228 va_end(va);
229}
230
231
232
233static int
234get_free_id(struct manager *mgr)
235{
236 u64 ids = 0;
237 int i;
238 struct layer2 *l2;
239
240 list_for_each_entry(l2, &mgr->layer2, list) {
241 if (l2->ch.nr > 63) {
242 printk(KERN_WARNING
243 "%s: more as 63 layer2 for one device\n",
244 __func__);
245 return -EBUSY;
246 }
247 test_and_set_bit(l2->ch.nr, (u_long *)&ids);
248 }
249 for (i = 1; i < 64; i++)
250 if (!test_bit(i, (u_long *)&ids))
251 return i;
252 printk(KERN_WARNING "%s: more as 63 layer2 for one device\n",
253 __func__);
254 return -EBUSY;
255}
256
257static int
258get_free_tei(struct manager *mgr)
259{
260 u64 ids = 0;
261 int i;
262 struct layer2 *l2;
263
264 list_for_each_entry(l2, &mgr->layer2, list) {
265 if (l2->ch.nr == 0)
266 continue;
267 if ((l2->ch.addr & 0xff) != 0)
268 continue;
269 i = l2->ch.addr >> 8;
270 if (i < 64)
271 continue;
272 i -= 64;
273
274 test_and_set_bit(i, (u_long *)&ids);
275 }
276 for (i = 0; i < 64; i++)
277 if (!test_bit(i, (u_long *)&ids))
278 return i + 64;
279 printk(KERN_WARNING "%s: more as 63 dynamic tei for one device\n",
280 __func__);
281 return -1;
282}
283
284static void
285teiup_create(struct manager *mgr, u_int prim, int len, void *arg)
286{
287 struct sk_buff *skb;
288 struct mISDNhead *hh;
289 int err;
290
291 skb = mI_alloc_skb(len, GFP_ATOMIC);
292 if (!skb)
293 return;
294 hh = mISDN_HEAD_P(skb);
295 hh->prim = prim;
296 hh->id = (mgr->ch.nr << 16) | mgr->ch.addr;
297 if (len)
298 memcpy(skb_put(skb, len), arg, len);
299 err = mgr->up->send(mgr->up, skb);
300 if (err) {
301 printk(KERN_WARNING "%s: err=%d\n", __func__, err);
302 dev_kfree_skb(skb);
303 }
304}
305
306static u_int
307new_id(struct manager *mgr)
308{
309 u_int id;
310
311 id = mgr->nextid++;
312 if (id == 0x7fff)
313 mgr->nextid = 1;
314 id <<= 16;
315 id |= GROUP_TEI << 8;
316 id |= TEI_SAPI;
317 return id;
318}
319
320static void
321do_send(struct manager *mgr)
322{
323 if (!test_bit(MGR_PH_ACTIVE, &mgr->options))
324 return;
325
326 if (!test_and_set_bit(MGR_PH_NOTREADY, &mgr->options)) {
327 struct sk_buff *skb = skb_dequeue(&mgr->sendq);
328
329 if (!skb) {
330 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options);
331 return;
332 }
333 mgr->lastid = mISDN_HEAD_ID(skb);
334 mISDN_FsmEvent(&mgr->deact, EV_UI, NULL);
335 if (mgr->ch.recv(mgr->ch.peer, skb)) {
336 dev_kfree_skb(skb);
337 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options);
338 mgr->lastid = MISDN_ID_NONE;
339 }
340 }
341}
342
343static void
344do_ack(struct manager *mgr, u_int id)
345{
346 if (test_bit(MGR_PH_NOTREADY, &mgr->options)) {
347 if (id == mgr->lastid) {
348 if (test_bit(MGR_PH_ACTIVE, &mgr->options)) {
349 struct sk_buff *skb;
350
351 skb = skb_dequeue(&mgr->sendq);
352 if (skb) {
353 mgr->lastid = mISDN_HEAD_ID(skb);
354 if (!mgr->ch.recv(mgr->ch.peer, skb))
355 return;
356 dev_kfree_skb(skb);
357 }
358 }
359 mgr->lastid = MISDN_ID_NONE;
360 test_and_clear_bit(MGR_PH_NOTREADY, &mgr->options);
361 }
362 }
363}
364
365static void
366mgr_send_down(struct manager *mgr, struct sk_buff *skb)
367{
368 skb_queue_tail(&mgr->sendq, skb);
369 if (!test_bit(MGR_PH_ACTIVE, &mgr->options)) {
370 _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0,
371 NULL, GFP_KERNEL);
372 } else {
373 do_send(mgr);
374 }
375}
376
377static int
378dl_unit_data(struct manager *mgr, struct sk_buff *skb)
379{
380 if (!test_bit(MGR_OPT_NETWORK, &mgr->options)) /* only net send UI */
381 return -EINVAL;
382 if (!test_bit(MGR_PH_ACTIVE, &mgr->options))
383 _queue_data(&mgr->ch, PH_ACTIVATE_REQ, MISDN_ID_ANY, 0,
384 NULL, GFP_KERNEL);
385 skb_push(skb, 3);
386 skb->data[0] = 0x02; /* SAPI 0 C/R = 1 */
387 skb->data[1] = 0xff; /* TEI 127 */
388 skb->data[2] = UI; /* UI frame */
389 mISDN_HEAD_PRIM(skb) = PH_DATA_REQ;
390 mISDN_HEAD_ID(skb) = new_id(mgr);
391 skb_queue_tail(&mgr->sendq, skb);
392 do_send(mgr);
393 return 0;
394}
395
396unsigned int
397random_ri(void)
398{
399 u16 x;
400
401 get_random_bytes(&x, sizeof(x));
402 return x;
403}
404
405static struct layer2 *
406findtei(struct manager *mgr, int tei)
407{
408 struct layer2 *l2;
409 u_long flags;
410
411 read_lock_irqsave(&mgr->lock, flags);
412 list_for_each_entry(l2, &mgr->layer2, list) {
413 if ((l2->sapi == 0) && (l2->tei > 0) &&
414 (l2->tei != GROUP_TEI) && (l2->tei == tei))
415 goto done;
416 }
417 l2 = NULL;
418done:
419 read_unlock_irqrestore(&mgr->lock, flags);
420 return l2;
421}
422
423static void
424put_tei_msg(struct manager *mgr, u_char m_id, unsigned int ri, u_char tei)
425{
426 struct sk_buff *skb;
427 u_char bp[8];
428
429 bp[0] = (TEI_SAPI << 2);
430 if (test_bit(MGR_OPT_NETWORK, &mgr->options))
431 bp[0] |= 2; /* CR:=1 for net command */
432 bp[1] = (GROUP_TEI << 1) | 0x1;
433 bp[2] = UI;
434 bp[3] = TEI_ENTITY_ID;
435 bp[4] = ri >> 8;
436 bp[5] = ri & 0xff;
437 bp[6] = m_id;
438 bp[7] = (tei << 1) | 1;
439 skb = _alloc_mISDN_skb(PH_DATA_REQ, new_id(mgr),
440 8, bp, GFP_ATOMIC);
441 if (!skb) {
442 printk(KERN_WARNING "%s: no skb for tei msg\n", __func__);
443 return;
444 }
445 mgr_send_down(mgr, skb);
446}
447
448static void
449tei_id_request(struct FsmInst *fi, int event, void *arg)
450{
451 struct teimgr *tm = fi->userdata;
452
453 if (tm->l2->tei != GROUP_TEI) {
454 tm->tei_m.printdebug(&tm->tei_m,
455 "assign request for allready assigned tei %d",
456 tm->l2->tei);
457 return;
458 }
459 tm->ri = random_ri();
460 if (*debug & DEBUG_L2_TEI)
461 tm->tei_m.printdebug(&tm->tei_m,
462 "assign request ri %d", tm->ri);
463 put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI);
464 mISDN_FsmChangeState(fi, ST_TEI_IDREQ);
465 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 1);
466 tm->nval = 3;
467}
468
469static void
470tei_id_assign(struct FsmInst *fi, int event, void *arg)
471{
472 struct teimgr *tm = fi->userdata;
473 struct layer2 *l2;
474 u_char *dp = arg;
475 int ri, tei;
476
477 ri = ((unsigned int) *dp++ << 8);
478 ri += *dp++;
479 dp++;
480 tei = *dp >> 1;
481 if (*debug & DEBUG_L2_TEI)
482 tm->tei_m.printdebug(fi, "identity assign ri %d tei %d",
483 ri, tei);
484 l2 = findtei(tm->mgr, tei);
485 if (l2) { /* same tei is in use */
486 if (ri != l2->tm->ri) {
487 tm->tei_m.printdebug(fi,
488 "possible duplicate assignment tei %d", tei);
489 tei_l2(l2, MDL_ERROR_RSP, 0);
490 }
491 } else if (ri == tm->ri) {
492 mISDN_FsmDelTimer(&tm->timer, 1);
493 mISDN_FsmChangeState(fi, ST_TEI_NOP);
494 tei_l2(tm->l2, MDL_ASSIGN_REQ, tei);
495 }
496}
497
498static void
499tei_id_test_dup(struct FsmInst *fi, int event, void *arg)
500{
501 struct teimgr *tm = fi->userdata;
502 struct layer2 *l2;
503 u_char *dp = arg;
504 int tei, ri;
505
506 ri = ((unsigned int) *dp++ << 8);
507 ri += *dp++;
508 dp++;
509 tei = *dp >> 1;
510 if (*debug & DEBUG_L2_TEI)
511 tm->tei_m.printdebug(fi, "foreign identity assign ri %d tei %d",
512 ri, tei);
513 l2 = findtei(tm->mgr, tei);
514 if (l2) { /* same tei is in use */
515 if (ri != l2->tm->ri) { /* and it wasn't our request */
516 tm->tei_m.printdebug(fi,
517 "possible duplicate assignment tei %d", tei);
518 mISDN_FsmEvent(&l2->tm->tei_m, EV_VERIFY, NULL);
519 }
520 }
521}
522
523static void
524tei_id_denied(struct FsmInst *fi, int event, void *arg)
525{
526 struct teimgr *tm = fi->userdata;
527 u_char *dp = arg;
528 int ri, tei;
529
530 ri = ((unsigned int) *dp++ << 8);
531 ri += *dp++;
532 dp++;
533 tei = *dp >> 1;
534 if (*debug & DEBUG_L2_TEI)
535 tm->tei_m.printdebug(fi, "identity denied ri %d tei %d",
536 ri, tei);
537}
538
539static void
540tei_id_chk_req(struct FsmInst *fi, int event, void *arg)
541{
542 struct teimgr *tm = fi->userdata;
543 u_char *dp = arg;
544 int tei;
545
546 tei = *(dp+3) >> 1;
547 if (*debug & DEBUG_L2_TEI)
548 tm->tei_m.printdebug(fi, "identity check req tei %d", tei);
549 if ((tm->l2->tei != GROUP_TEI) && ((tei == GROUP_TEI) ||
550 (tei == tm->l2->tei))) {
551 mISDN_FsmDelTimer(&tm->timer, 4);
552 mISDN_FsmChangeState(&tm->tei_m, ST_TEI_NOP);
553 put_tei_msg(tm->mgr, ID_CHK_RES, random_ri(), tm->l2->tei);
554 }
555}
556
557static void
558tei_id_remove(struct FsmInst *fi, int event, void *arg)
559{
560 struct teimgr *tm = fi->userdata;
561 u_char *dp = arg;
562 int tei;
563
564 tei = *(dp+3) >> 1;
565 if (*debug & DEBUG_L2_TEI)
566 tm->tei_m.printdebug(fi, "identity remove tei %d", tei);
567 if ((tm->l2->tei != GROUP_TEI) &&
568 ((tei == GROUP_TEI) || (tei == tm->l2->tei))) {
569 mISDN_FsmDelTimer(&tm->timer, 5);
570 mISDN_FsmChangeState(&tm->tei_m, ST_TEI_NOP);
571 tei_l2(tm->l2, MDL_REMOVE_REQ, 0);
572 }
573}
574
575static void
576tei_id_verify(struct FsmInst *fi, int event, void *arg)
577{
578 struct teimgr *tm = fi->userdata;
579
580 if (*debug & DEBUG_L2_TEI)
581 tm->tei_m.printdebug(fi, "id verify request for tei %d",
582 tm->l2->tei);
583 put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei);
584 mISDN_FsmChangeState(&tm->tei_m, ST_TEI_IDVERIFY);
585 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 2);
586 tm->nval = 2;
587}
588
589static void
590tei_id_req_tout(struct FsmInst *fi, int event, void *arg)
591{
592 struct teimgr *tm = fi->userdata;
593
594 if (--tm->nval) {
595 tm->ri = random_ri();
596 if (*debug & DEBUG_L2_TEI)
597 tm->tei_m.printdebug(fi, "assign req(%d) ri %d",
598 4 - tm->nval, tm->ri);
599 put_tei_msg(tm->mgr, ID_REQUEST, tm->ri, GROUP_TEI);
600 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 3);
601 } else {
602 tm->tei_m.printdebug(fi, "assign req failed");
603 tei_l2(tm->l2, MDL_ERROR_RSP, 0);
604 mISDN_FsmChangeState(fi, ST_TEI_NOP);
605 }
606}
607
608static void
609tei_id_ver_tout(struct FsmInst *fi, int event, void *arg)
610{
611 struct teimgr *tm = fi->userdata;
612
613 if (--tm->nval) {
614 if (*debug & DEBUG_L2_TEI)
615 tm->tei_m.printdebug(fi,
616 "id verify req(%d) for tei %d",
617 3 - tm->nval, tm->l2->tei);
618 put_tei_msg(tm->mgr, ID_VERIFY, 0, tm->l2->tei);
619 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 4);
620 } else {
621 tm->tei_m.printdebug(fi, "verify req for tei %d failed",
622 tm->l2->tei);
623 tei_l2(tm->l2, MDL_REMOVE_REQ, 0);
624 mISDN_FsmChangeState(fi, ST_TEI_NOP);
625 }
626}
627
628static struct FsmNode TeiFnListUser[] =
629{
630 {ST_TEI_NOP, EV_IDREQ, tei_id_request},
631 {ST_TEI_NOP, EV_ASSIGN, tei_id_test_dup},
632 {ST_TEI_NOP, EV_VERIFY, tei_id_verify},
633 {ST_TEI_NOP, EV_REMOVE, tei_id_remove},
634 {ST_TEI_NOP, EV_CHKREQ, tei_id_chk_req},
635 {ST_TEI_IDREQ, EV_TIMER, tei_id_req_tout},
636 {ST_TEI_IDREQ, EV_ASSIGN, tei_id_assign},
637 {ST_TEI_IDREQ, EV_DENIED, tei_id_denied},
638 {ST_TEI_IDVERIFY, EV_TIMER, tei_id_ver_tout},
639 {ST_TEI_IDVERIFY, EV_REMOVE, tei_id_remove},
640 {ST_TEI_IDVERIFY, EV_CHKREQ, tei_id_chk_req},
641};
642
643static void
644tei_l2remove(struct layer2 *l2)
645{
646 put_tei_msg(l2->tm->mgr, ID_REMOVE, 0, l2->tei);
647 tei_l2(l2, MDL_REMOVE_REQ, 0);
648 list_del(&l2->ch.list);
649 l2->ch.ctrl(&l2->ch, CLOSE_CHANNEL, NULL);
650}
651
652static void
653tei_assign_req(struct FsmInst *fi, int event, void *arg)
654{
655 struct teimgr *tm = fi->userdata;
656 u_char *dp = arg;
657
658 if (tm->l2->tei == GROUP_TEI) {
659 tm->tei_m.printdebug(&tm->tei_m,
660 "net tei assign request without tei");
661 return;
662 }
663 tm->ri = ((unsigned int) *dp++ << 8);
664 tm->ri += *dp++;
665 if (*debug & DEBUG_L2_TEI)
666 tm->tei_m.printdebug(&tm->tei_m,
667 "net assign request ri %d teim %d", tm->ri, *dp);
668 put_tei_msg(tm->mgr, ID_ASSIGNED, tm->ri, tm->l2->tei);
669 mISDN_FsmChangeState(fi, ST_TEI_NOP);
670}
671
672static void
673tei_id_chk_req_net(struct FsmInst *fi, int event, void *arg)
674{
675 struct teimgr *tm = fi->userdata;
676
677 if (*debug & DEBUG_L2_TEI)
678 tm->tei_m.printdebug(fi, "id check request for tei %d",
679 tm->l2->tei);
680 tm->rcnt = 0;
681 put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei);
682 mISDN_FsmChangeState(&tm->tei_m, ST_TEI_IDVERIFY);
683 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 2);
684 tm->nval = 2;
685}
686
687static void
688tei_id_chk_resp(struct FsmInst *fi, int event, void *arg)
689{
690 struct teimgr *tm = fi->userdata;
691 u_char *dp = arg;
692 int tei;
693
694 tei = dp[3] >> 1;
695 if (*debug & DEBUG_L2_TEI)
696 tm->tei_m.printdebug(fi, "identity check resp tei %d", tei);
697 if (tei == tm->l2->tei)
698 tm->rcnt++;
699}
700
701static void
702tei_id_verify_net(struct FsmInst *fi, int event, void *arg)
703{
704 struct teimgr *tm = fi->userdata;
705 u_char *dp = arg;
706 int tei;
707
708 tei = dp[3] >> 1;
709 if (*debug & DEBUG_L2_TEI)
710 tm->tei_m.printdebug(fi, "identity verify req tei %d/%d",
711 tei, tm->l2->tei);
712 if (tei == tm->l2->tei)
713 tei_id_chk_req_net(fi, event, arg);
714}
715
716static void
717tei_id_ver_tout_net(struct FsmInst *fi, int event, void *arg)
718{
719 struct teimgr *tm = fi->userdata;
720
721 if (tm->rcnt == 1) {
722 if (*debug & DEBUG_L2_TEI)
723 tm->tei_m.printdebug(fi,
724 "check req for tei %d sucessful\n", tm->l2->tei);
725 mISDN_FsmChangeState(fi, ST_TEI_NOP);
726 } else if (tm->rcnt > 1) {
727 /* duplicate assignment; remove */
728 tei_l2remove(tm->l2);
729 } else if (--tm->nval) {
730 if (*debug & DEBUG_L2_TEI)
731 tm->tei_m.printdebug(fi,
732 "id check req(%d) for tei %d",
733 3 - tm->nval, tm->l2->tei);
734 put_tei_msg(tm->mgr, ID_CHK_REQ, 0, tm->l2->tei);
735 mISDN_FsmAddTimer(&tm->timer, tm->tval, EV_TIMER, NULL, 4);
736 } else {
737 tm->tei_m.printdebug(fi, "check req for tei %d failed",
738 tm->l2->tei);
739 mISDN_FsmChangeState(fi, ST_TEI_NOP);
740 tei_l2remove(tm->l2);
741 }
742}
743
744static struct FsmNode TeiFnListNet[] =
745{
746 {ST_TEI_NOP, EV_ASSIGN_REQ, tei_assign_req},
747 {ST_TEI_NOP, EV_VERIFY, tei_id_verify_net},
748 {ST_TEI_NOP, EV_CHKREQ, tei_id_chk_req_net},
749 {ST_TEI_IDVERIFY, EV_TIMER, tei_id_ver_tout_net},
750 {ST_TEI_IDVERIFY, EV_CHKRESP, tei_id_chk_resp},
751};
752
753static void
754tei_ph_data_ind(struct teimgr *tm, u_int mt, u_char *dp, int len)
755{
756 if (test_bit(FLG_FIXED_TEI, &tm->l2->flag))
757 return;
758 if (*debug & DEBUG_L2_TEI)
759 tm->tei_m.printdebug(&tm->tei_m, "tei handler mt %x", mt);
760 if (mt == ID_ASSIGNED)
761 mISDN_FsmEvent(&tm->tei_m, EV_ASSIGN, dp);
762 else if (mt == ID_DENIED)
763 mISDN_FsmEvent(&tm->tei_m, EV_DENIED, dp);
764 else if (mt == ID_CHK_REQ)
765 mISDN_FsmEvent(&tm->tei_m, EV_CHKREQ, dp);
766 else if (mt == ID_REMOVE)
767 mISDN_FsmEvent(&tm->tei_m, EV_REMOVE, dp);
768 else if (mt == ID_VERIFY)
769 mISDN_FsmEvent(&tm->tei_m, EV_VERIFY, dp);
770 else if (mt == ID_CHK_RES)
771 mISDN_FsmEvent(&tm->tei_m, EV_CHKRESP, dp);
772}
773
774static struct layer2 *
775create_new_tei(struct manager *mgr, int tei)
776{
777 u_long opt = 0;
778 u_long flags;
779 int id;
780 struct layer2 *l2;
781
782 if (!mgr->up)
783 return NULL;
784 if (tei < 64)
785 test_and_set_bit(OPTION_L2_FIXEDTEI, &opt);
786 if (mgr->ch.st->dev->Dprotocols
787 & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1)))
788 test_and_set_bit(OPTION_L2_PMX, &opt);
789 l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, (u_int)opt, (u_long)tei);
790 if (!l2) {
791 printk(KERN_WARNING "%s:no memory for layer2\n", __func__);
792 return NULL;
793 }
794 l2->tm = kzalloc(sizeof(struct teimgr), GFP_KERNEL);
795 if (!l2->tm) {
796 kfree(l2);
797 printk(KERN_WARNING "%s:no memory for teimgr\n", __func__);
798 return NULL;
799 }
800 l2->tm->mgr = mgr;
801 l2->tm->l2 = l2;
802 l2->tm->tei_m.debug = *debug & DEBUG_L2_TEIFSM;
803 l2->tm->tei_m.userdata = l2->tm;
804 l2->tm->tei_m.printdebug = tei_debug;
805 l2->tm->tei_m.fsm = &teifsmn;
806 l2->tm->tei_m.state = ST_TEI_NOP;
807 l2->tm->tval = 2000; /* T202 2 sec */
808 mISDN_FsmInitTimer(&l2->tm->tei_m, &l2->tm->timer);
809 write_lock_irqsave(&mgr->lock, flags);
810 id = get_free_id(mgr);
811 list_add_tail(&l2->list, &mgr->layer2);
812 write_unlock_irqrestore(&mgr->lock, flags);
813 if (id < 0) {
814 l2->ch.ctrl(&l2->ch, CLOSE_CHANNEL, NULL);
815 printk(KERN_WARNING "%s:no free id\n", __func__);
816 return NULL;
817 } else {
818 l2->ch.nr = id;
819 __add_layer2(&l2->ch, mgr->ch.st);
820 l2->ch.recv = mgr->ch.recv;
821 l2->ch.peer = mgr->ch.peer;
822 l2->ch.ctrl(&l2->ch, OPEN_CHANNEL, NULL);
823 }
824 return l2;
825}
826
827static void
828new_tei_req(struct manager *mgr, u_char *dp)
829{
830 int tei, ri;
831 struct layer2 *l2;
832
833 ri = dp[0] << 8;
834 ri += dp[1];
835 if (!mgr->up)
836 goto denied;
837 tei = get_free_tei(mgr);
838 if (tei < 0) {
839 printk(KERN_WARNING "%s:No free tei\n", __func__);
840 goto denied;
841 }
842 l2 = create_new_tei(mgr, tei);
843 if (!l2)
844 goto denied;
845 else
846 mISDN_FsmEvent(&l2->tm->tei_m, EV_ASSIGN_REQ, dp);
847 return;
848denied:
849 put_tei_msg(mgr, ID_DENIED, ri, GROUP_TEI);
850}
851
852static int
853ph_data_ind(struct manager *mgr, struct sk_buff *skb)
854{
855 int ret = -EINVAL;
856 struct layer2 *l2;
857 u_long flags;
858 u_char mt;
859
860 if (skb->len < 8) {
861 if (*debug & DEBUG_L2_TEI)
862 printk(KERN_DEBUG "%s: short mgr frame %d/8\n",
863 __func__, skb->len);
864 goto done;
865 }
866 if (*debug & DEBUG_L2_TEI)
867
868 if ((skb->data[0] >> 2) != TEI_SAPI) /* not for us */
869 goto done;
870 if (skb->data[0] & 1) /* EA0 formal error */
871 goto done;
872 if (!(skb->data[1] & 1)) /* EA1 formal error */
873 goto done;
874 if ((skb->data[1] >> 1) != GROUP_TEI) /* not for us */
875 goto done;
876 if ((skb->data[2] & 0xef) != UI) /* not UI */
877 goto done;
878 if (skb->data[3] != TEI_ENTITY_ID) /* not tei entity */
879 goto done;
880 mt = skb->data[6];
881 switch (mt) {
882 case ID_REQUEST:
883 case ID_CHK_RES:
884 case ID_VERIFY:
885 if (!test_bit(MGR_OPT_NETWORK, &mgr->options))
886 goto done;
887 break;
888 case ID_ASSIGNED:
889 case ID_DENIED:
890 case ID_CHK_REQ:
891 case ID_REMOVE:
892 if (test_bit(MGR_OPT_NETWORK, &mgr->options))
893 goto done;
894 break;
895 default:
896 goto done;
897 }
898 ret = 0;
899 if (mt == ID_REQUEST) {
900 new_tei_req(mgr, &skb->data[4]);
901 goto done;
902 }
903 read_lock_irqsave(&mgr->lock, flags);
904 list_for_each_entry(l2, &mgr->layer2, list) {
905 tei_ph_data_ind(l2->tm, mt, &skb->data[4], skb->len - 4);
906 }
907 read_unlock_irqrestore(&mgr->lock, flags);
908done:
909 return ret;
910}
911
912int
913l2_tei(struct layer2 *l2, u_int cmd, u_long arg)
914{
915 struct teimgr *tm = l2->tm;
916
917 if (test_bit(FLG_FIXED_TEI, &l2->flag))
918 return 0;
919 if (*debug & DEBUG_L2_TEI)
920 printk(KERN_DEBUG "%s: cmd(%x)\n", __func__, cmd);
921 switch (cmd) {
922 case MDL_ASSIGN_IND:
923 mISDN_FsmEvent(&tm->tei_m, EV_IDREQ, NULL);
924 break;
925 case MDL_ERROR_IND:
926 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options))
927 mISDN_FsmEvent(&tm->tei_m, EV_CHKREQ, &l2->tei);
928 if (test_bit(MGR_OPT_USER, &tm->mgr->options))
929 mISDN_FsmEvent(&tm->tei_m, EV_VERIFY, NULL);
930 break;
931 case MDL_STATUS_UP_IND:
932 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options))
933 mISDN_FsmEvent(&tm->mgr->deact, EV_ACTIVATE, NULL);
934 break;
935 case MDL_STATUS_DOWN_IND:
936 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options))
937 mISDN_FsmEvent(&tm->mgr->deact, EV_DEACTIVATE, NULL);
938 break;
939 case MDL_STATUS_UI_IND:
940 if (test_bit(MGR_OPT_NETWORK, &tm->mgr->options))
941 mISDN_FsmEvent(&tm->mgr->deact, EV_UI, NULL);
942 break;
943 }
944 return 0;
945}
946
947void
948TEIrelease(struct layer2 *l2)
949{
950 struct teimgr *tm = l2->tm;
951 u_long flags;
952
953 mISDN_FsmDelTimer(&tm->timer, 1);
954 write_lock_irqsave(&tm->mgr->lock, flags);
955 list_del(&l2->list);
956 write_unlock_irqrestore(&tm->mgr->lock, flags);
957 l2->tm = NULL;
958 kfree(tm);
959}
960
961static int
962create_teimgr(struct manager *mgr, struct channel_req *crq)
963{
964 struct layer2 *l2;
965 u_long opt = 0;
966 u_long flags;
967 int id;
968
969 if (*debug & DEBUG_L2_TEI)
970 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
971 __func__, mgr->ch.st->dev->name, crq->protocol,
972 crq->adr.dev, crq->adr.channel, crq->adr.sapi,
973 crq->adr.tei);
974 if (crq->adr.sapi != 0) /* not supported yet */
975 return -EINVAL;
976 if (crq->adr.tei > GROUP_TEI)
977 return -EINVAL;
978 if (crq->adr.tei < 64)
979 test_and_set_bit(OPTION_L2_FIXEDTEI, &opt);
980 if (crq->adr.tei == 0)
981 test_and_set_bit(OPTION_L2_PTP, &opt);
982 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) {
983 if (crq->protocol == ISDN_P_LAPD_TE)
984 return -EPROTONOSUPPORT;
985 if ((crq->adr.tei != 0) && (crq->adr.tei != 127))
986 return -EINVAL;
987 if (mgr->up) {
988 printk(KERN_WARNING
989 "%s: only one network manager is allowed\n",
990 __func__);
991 return -EBUSY;
992 }
993 } else if (test_bit(MGR_OPT_USER, &mgr->options)) {
994 if (crq->protocol == ISDN_P_LAPD_NT)
995 return -EPROTONOSUPPORT;
996 if ((crq->adr.tei >= 64) && (crq->adr.tei < GROUP_TEI))
997 return -EINVAL; /* dyn tei */
998 } else {
999 if (crq->protocol == ISDN_P_LAPD_NT)
1000 test_and_set_bit(MGR_OPT_NETWORK, &mgr->options);
1001 if (crq->protocol == ISDN_P_LAPD_TE)
1002 test_and_set_bit(MGR_OPT_USER, &mgr->options);
1003 }
1004 if (mgr->ch.st->dev->Dprotocols
1005 & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1)))
1006 test_and_set_bit(OPTION_L2_PMX, &opt);
1007 if ((crq->protocol == ISDN_P_LAPD_NT) && (crq->adr.tei == 127)) {
1008 mgr->up = crq->ch;
1009 id = DL_INFO_L2_CONNECT;
1010 teiup_create(mgr, DL_INFORMATION_IND, sizeof(id), &id);
1011 crq->ch = NULL;
1012 if (!list_empty(&mgr->layer2)) {
1013 read_lock_irqsave(&mgr->lock, flags);
1014 list_for_each_entry(l2, &mgr->layer2, list) {
1015 l2->up = mgr->up;
1016 l2->ch.ctrl(&l2->ch, OPEN_CHANNEL, NULL);
1017 }
1018 read_unlock_irqrestore(&mgr->lock, flags);
1019 }
1020 return 0;
1021 }
1022 l2 = create_l2(crq->ch, crq->protocol, (u_int)opt,
1023 (u_long)crq->adr.tei);
1024 if (!l2)
1025 return -ENOMEM;
1026 l2->tm = kzalloc(sizeof(struct teimgr), GFP_KERNEL);
1027 if (!l2->tm) {
1028 kfree(l2);
1029 printk(KERN_ERR "kmalloc teimgr failed\n");
1030 return -ENOMEM;
1031 }
1032 l2->tm->mgr = mgr;
1033 l2->tm->l2 = l2;
1034 l2->tm->tei_m.debug = *debug & DEBUG_L2_TEIFSM;
1035 l2->tm->tei_m.userdata = l2->tm;
1036 l2->tm->tei_m.printdebug = tei_debug;
1037 if (crq->protocol == ISDN_P_LAPD_TE) {
1038 l2->tm->tei_m.fsm = &teifsmu;
1039 l2->tm->tei_m.state = ST_TEI_NOP;
1040 l2->tm->tval = 1000; /* T201 1 sec */
1041 } else {
1042 l2->tm->tei_m.fsm = &teifsmn;
1043 l2->tm->tei_m.state = ST_TEI_NOP;
1044 l2->tm->tval = 2000; /* T202 2 sec */
1045 }
1046 mISDN_FsmInitTimer(&l2->tm->tei_m, &l2->tm->timer);
1047 write_lock_irqsave(&mgr->lock, flags);
1048 id = get_free_id(mgr);
1049 list_add_tail(&l2->list, &mgr->layer2);
1050 write_unlock_irqrestore(&mgr->lock, flags);
1051 if (id < 0) {
1052 l2->ch.ctrl(&l2->ch, CLOSE_CHANNEL, NULL);
1053 } else {
1054 l2->ch.nr = id;
1055 l2->up->nr = id;
1056 crq->ch = &l2->ch;
1057 id = 0;
1058 }
1059 return id;
1060}
1061
1062static int
1063mgr_send(struct mISDNchannel *ch, struct sk_buff *skb)
1064{
1065 struct manager *mgr;
1066 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1067 int ret = -EINVAL;
1068
1069 mgr = container_of(ch, struct manager, ch);
1070 if (*debug & DEBUG_L2_RECV)
1071 printk(KERN_DEBUG "%s: prim(%x) id(%x)\n",
1072 __func__, hh->prim, hh->id);
1073 switch (hh->prim) {
1074 case PH_DATA_IND:
1075 mISDN_FsmEvent(&mgr->deact, EV_UI, NULL);
1076 ret = ph_data_ind(mgr, skb);
1077 break;
1078 case PH_DATA_CNF:
1079 do_ack(mgr, hh->id);
1080 ret = 0;
1081 break;
1082 case PH_ACTIVATE_IND:
1083 test_and_set_bit(MGR_PH_ACTIVE, &mgr->options);
1084 mISDN_FsmEvent(&mgr->deact, EV_ACTIVATE_IND, NULL);
1085 do_send(mgr);
1086 ret = 0;
1087 break;
1088 case PH_DEACTIVATE_IND:
1089 test_and_clear_bit(MGR_PH_ACTIVE, &mgr->options);
1090 mISDN_FsmEvent(&mgr->deact, EV_DEACTIVATE_IND, NULL);
1091 ret = 0;
1092 break;
1093 case DL_UNITDATA_REQ:
1094 return dl_unit_data(mgr, skb);
1095 }
1096 if (!ret)
1097 dev_kfree_skb(skb);
1098 return ret;
1099}
1100
1101static int
1102free_teimanager(struct manager *mgr)
1103{
1104 struct layer2 *l2, *nl2;
1105
1106 if (test_bit(MGR_OPT_NETWORK, &mgr->options)) {
1107 /* not locked lock is taken in release tei */
1108 mgr->up = NULL;
1109 if (test_bit(OPTION_L2_CLEANUP, &mgr->options)) {
1110 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) {
1111 put_tei_msg(mgr, ID_REMOVE, 0, l2->tei);
1112 mutex_lock(&mgr->ch.st->lmutex);
1113 list_del(&l2->ch.list);
1114 mutex_unlock(&mgr->ch.st->lmutex);
1115 l2->ch.ctrl(&l2->ch, CLOSE_CHANNEL, NULL);
1116 }
1117 test_and_clear_bit(MGR_OPT_NETWORK, &mgr->options);
1118 } else {
1119 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) {
1120 l2->up = NULL;
1121 }
1122 }
1123 }
1124 if (test_bit(MGR_OPT_USER, &mgr->options)) {
1125 if (list_empty(&mgr->layer2))
1126 test_and_clear_bit(MGR_OPT_USER, &mgr->options);
1127 }
1128 mgr->ch.st->dev->D.ctrl(&mgr->ch.st->dev->D, CLOSE_CHANNEL, NULL);
1129 return 0;
1130}
1131
1132static int
1133ctrl_teimanager(struct manager *mgr, void *arg)
1134{
1135 /* currently we only have one option */
1136 int clean = *((int *)arg);
1137
1138 if (clean)
1139 test_and_set_bit(OPTION_L2_CLEANUP, &mgr->options);
1140 else
1141 test_and_clear_bit(OPTION_L2_CLEANUP, &mgr->options);
1142 return 0;
1143}
1144
1145/* This function does create a L2 for fixed TEI in NT Mode */
1146static int
1147check_data(struct manager *mgr, struct sk_buff *skb)
1148{
1149 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1150 int ret, tei;
1151 struct layer2 *l2;
1152
1153 if (*debug & DEBUG_L2_CTRL)
1154 printk(KERN_DEBUG "%s: prim(%x) id(%x)\n",
1155 __func__, hh->prim, hh->id);
1156 if (test_bit(MGR_OPT_USER, &mgr->options))
1157 return -ENOTCONN;
1158 if (hh->prim != PH_DATA_IND)
1159 return -ENOTCONN;
1160 if (skb->len != 3)
1161 return -ENOTCONN;
1162 if (skb->data[0] != 0)
1163 /* only SAPI 0 command */
1164 return -ENOTCONN;
1165 if (!(skb->data[1] & 1)) /* invalid EA1 */
1166 return -EINVAL;
1167 tei = skb->data[1] >> 0;
1168 if (tei > 63) /* not a fixed tei */
1169 return -ENOTCONN;
1170 if ((skb->data[2] & ~0x10) != SABME)
1171 return -ENOTCONN;
1172 /* We got a SABME for a fixed TEI */
1173 l2 = create_new_tei(mgr, tei);
1174 if (!l2)
1175 return -ENOMEM;
1176 ret = l2->ch.send(&l2->ch, skb);
1177 return ret;
1178}
1179
1180void
1181delete_teimanager(struct mISDNchannel *ch)
1182{
1183 struct manager *mgr;
1184 struct layer2 *l2, *nl2;
1185
1186 mgr = container_of(ch, struct manager, ch);
1187 /* not locked lock is taken in release tei */
1188 list_for_each_entry_safe(l2, nl2, &mgr->layer2, list) {
1189 mutex_lock(&mgr->ch.st->lmutex);
1190 list_del(&l2->ch.list);
1191 mutex_unlock(&mgr->ch.st->lmutex);
1192 l2->ch.ctrl(&l2->ch, CLOSE_CHANNEL, NULL);
1193 }
1194 list_del(&mgr->ch.list);
1195 list_del(&mgr->bcast.list);
1196 skb_queue_purge(&mgr->sendq);
1197 kfree(mgr);
1198}
1199
1200static int
1201mgr_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1202{
1203 struct manager *mgr;
1204 int ret = -EINVAL;
1205
1206 mgr = container_of(ch, struct manager, ch);
1207 if (*debug & DEBUG_L2_CTRL)
1208 printk(KERN_DEBUG "%s(%x, %p)\n", __func__, cmd, arg);
1209 switch (cmd) {
1210 case OPEN_CHANNEL:
1211 ret = create_teimgr(mgr, arg);
1212 break;
1213 case CLOSE_CHANNEL:
1214 ret = free_teimanager(mgr);
1215 break;
1216 case CONTROL_CHANNEL:
1217 ret = ctrl_teimanager(mgr, arg);
1218 break;
1219 case CHECK_DATA:
1220 ret = check_data(mgr, arg);
1221 break;
1222 }
1223 return ret;
1224}
1225
1226static int
1227mgr_bcast(struct mISDNchannel *ch, struct sk_buff *skb)
1228{
1229 struct manager *mgr = container_of(ch, struct manager, bcast);
1230 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1231 struct sk_buff *cskb = NULL;
1232 struct layer2 *l2;
1233 u_long flags;
1234 int ret;
1235
1236 read_lock_irqsave(&mgr->lock, flags);
1237 list_for_each_entry(l2, &mgr->layer2, list) {
1238 if ((hh->id & MISDN_ID_SAPI_MASK) ==
1239 (l2->ch.addr & MISDN_ID_SAPI_MASK)) {
1240 if (list_is_last(&l2->list, &mgr->layer2)) {
1241 cskb = skb;
1242 skb = NULL;
1243 } else {
1244 if (!cskb)
1245 cskb = skb_copy(skb, GFP_KERNEL);
1246 }
1247 if (cskb) {
1248 ret = l2->ch.send(&l2->ch, cskb);
1249 if (ret) {
1250 if (*debug & DEBUG_SEND_ERR)
1251 printk(KERN_DEBUG
1252 "%s ch%d prim(%x) addr(%x)"
1253 " err %d\n",
1254 __func__, l2->ch.nr,
1255 hh->prim, l2->ch.addr, ret);
1256 } else
1257 cskb = NULL;
1258 } else {
1259 printk(KERN_WARNING "%s ch%d addr %x no mem\n",
1260 __func__, ch->nr, ch->addr);
1261 goto out;
1262 }
1263 }
1264 }
1265out:
1266 read_unlock_irqrestore(&mgr->lock, flags);
1267 if (cskb)
1268 dev_kfree_skb(cskb);
1269 if (skb)
1270 dev_kfree_skb(skb);
1271 return 0;
1272}
1273
1274static int
1275mgr_bcast_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1276{
1277
1278 return -EINVAL;
1279}
1280
1281int
1282create_teimanager(struct mISDNdevice *dev)
1283{
1284 struct manager *mgr;
1285
1286 mgr = kzalloc(sizeof(struct manager), GFP_KERNEL);
1287 if (!mgr)
1288 return -ENOMEM;
1289 INIT_LIST_HEAD(&mgr->layer2);
1290 mgr->lock = __RW_LOCK_UNLOCKED(mgr->lock);
1291 skb_queue_head_init(&mgr->sendq);
1292 mgr->nextid = 1;
1293 mgr->lastid = MISDN_ID_NONE;
1294 mgr->ch.send = mgr_send;
1295 mgr->ch.ctrl = mgr_ctrl;
1296 mgr->ch.st = dev->D.st;
1297 set_channel_address(&mgr->ch, TEI_SAPI, GROUP_TEI);
1298 add_layer2(&mgr->ch, dev->D.st);
1299 mgr->bcast.send = mgr_bcast;
1300 mgr->bcast.ctrl = mgr_bcast_ctrl;
1301 mgr->bcast.st = dev->D.st;
1302 set_channel_address(&mgr->bcast, 0, GROUP_TEI);
1303 add_layer2(&mgr->bcast, dev->D.st);
1304 mgr->deact.debug = *debug & DEBUG_MANAGER;
1305 mgr->deact.userdata = mgr;
1306 mgr->deact.printdebug = da_debug;
1307 mgr->deact.fsm = &deactfsm;
1308 mgr->deact.state = ST_L1_DEACT;
1309 mISDN_FsmInitTimer(&mgr->deact, &mgr->datimer);
1310 dev->teimgr = &mgr->ch;
1311 return 0;
1312}
1313
1314int TEIInit(u_int *deb)
1315{
1316 debug = deb;
1317 teifsmu.state_count = TEI_STATE_COUNT;
1318 teifsmu.event_count = TEI_EVENT_COUNT;
1319 teifsmu.strEvent = strTeiEvent;
1320 teifsmu.strState = strTeiState;
1321 mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
1322 teifsmn.state_count = TEI_STATE_COUNT;
1323 teifsmn.event_count = TEI_EVENT_COUNT;
1324 teifsmn.strEvent = strTeiEvent;
1325 teifsmn.strState = strTeiState;
1326 mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
1327 deactfsm.state_count = DEACT_STATE_COUNT;
1328 deactfsm.event_count = DEACT_EVENT_COUNT;
1329 deactfsm.strEvent = strDeactEvent;
1330 deactfsm.strState = strDeactState;
1331 mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
1332 return 0;
1333}
1334
1335void TEIFree(void)
1336{
1337 mISDN_FsmFree(&teifsmu);
1338 mISDN_FsmFree(&teifsmn);
1339 mISDN_FsmFree(&deactfsm);
1340}
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
new file mode 100644
index 000000000000..b5fabc7019d8
--- /dev/null
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -0,0 +1,301 @@
1/*
2 *
3 * general timer device for using in ISDN stacks
4 *
5 * Author Karsten Keil <kkeil@novell.com>
6 *
7 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * 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 */
19
20#include <linux/poll.h>
21#include <linux/vmalloc.h>
22#include <linux/timer.h>
23#include <linux/miscdevice.h>
24#include <linux/module.h>
25#include <linux/mISDNif.h>
26
27static int *debug;
28
29
30struct mISDNtimerdev {
31 int next_id;
32 struct list_head pending;
33 struct list_head expired;
34 wait_queue_head_t wait;
35 u_int work;
36 spinlock_t lock; /* protect lists */
37};
38
39struct mISDNtimer {
40 struct list_head list;
41 struct mISDNtimerdev *dev;
42 struct timer_list tl;
43 int id;
44};
45
46static int
47mISDN_open(struct inode *ino, struct file *filep)
48{
49 struct mISDNtimerdev *dev;
50
51 if (*debug & DEBUG_TIMER)
52 printk(KERN_DEBUG "%s(%p,%p)\n", __func__, ino, filep);
53 dev = kmalloc(sizeof(struct mISDNtimerdev) , GFP_KERNEL);
54 if (!dev)
55 return -ENOMEM;
56 dev->next_id = 1;
57 INIT_LIST_HEAD(&dev->pending);
58 INIT_LIST_HEAD(&dev->expired);
59 spin_lock_init(&dev->lock);
60 dev->work = 0;
61 init_waitqueue_head(&dev->wait);
62 filep->private_data = dev;
63 __module_get(THIS_MODULE);
64 return 0;
65}
66
67static int
68mISDN_close(struct inode *ino, struct file *filep)
69{
70 struct mISDNtimerdev *dev = filep->private_data;
71 struct mISDNtimer *timer, *next;
72
73 if (*debug & DEBUG_TIMER)
74 printk(KERN_DEBUG "%s(%p,%p)\n", __func__, ino, filep);
75 list_for_each_entry_safe(timer, next, &dev->pending, list) {
76 del_timer(&timer->tl);
77 kfree(timer);
78 }
79 list_for_each_entry_safe(timer, next, &dev->expired, list) {
80 kfree(timer);
81 }
82 kfree(dev);
83 module_put(THIS_MODULE);
84 return 0;
85}
86
87static ssize_t
88mISDN_read(struct file *filep, char *buf, size_t count, loff_t *off)
89{
90 struct mISDNtimerdev *dev = filep->private_data;
91 struct mISDNtimer *timer;
92 u_long flags;
93 int ret = 0;
94
95 if (*debug & DEBUG_TIMER)
96 printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__,
97 filep, buf, (int)count, off);
98 if (*off != filep->f_pos)
99 return -ESPIPE;
100
101 if (list_empty(&dev->expired) && (dev->work == 0)) {
102 if (filep->f_flags & O_NONBLOCK)
103 return -EAGAIN;
104 wait_event_interruptible(dev->wait, (dev->work ||
105 !list_empty(&dev->expired)));
106 if (signal_pending(current))
107 return -ERESTARTSYS;
108 }
109 if (count < sizeof(int))
110 return -ENOSPC;
111 if (dev->work)
112 dev->work = 0;
113 if (!list_empty(&dev->expired)) {
114 spin_lock_irqsave(&dev->lock, flags);
115 timer = (struct mISDNtimer *)dev->expired.next;
116 list_del(&timer->list);
117 spin_unlock_irqrestore(&dev->lock, flags);
118 if (put_user(timer->id, (int *)buf))
119 ret = -EFAULT;
120 else
121 ret = sizeof(int);
122 kfree(timer);
123 }
124 return ret;
125}
126
127static loff_t
128mISDN_llseek(struct file *filep, loff_t offset, int orig)
129{
130 return -ESPIPE;
131}
132
133static ssize_t
134mISDN_write(struct file *filep, const char *buf, size_t count, loff_t *off)
135{
136 return -EOPNOTSUPP;
137}
138
139static unsigned int
140mISDN_poll(struct file *filep, poll_table *wait)
141{
142 struct mISDNtimerdev *dev = filep->private_data;
143 unsigned int mask = POLLERR;
144
145 if (*debug & DEBUG_TIMER)
146 printk(KERN_DEBUG "%s(%p, %p)\n", __func__, filep, wait);
147 if (dev) {
148 poll_wait(filep, &dev->wait, wait);
149 mask = 0;
150 if (dev->work || !list_empty(&dev->expired))
151 mask |= (POLLIN | POLLRDNORM);
152 if (*debug & DEBUG_TIMER)
153 printk(KERN_DEBUG "%s work(%d) empty(%d)\n", __func__,
154 dev->work, list_empty(&dev->expired));
155 }
156 return mask;
157}
158
159static void
160dev_expire_timer(struct mISDNtimer *timer)
161{
162 u_long flags;
163
164 spin_lock_irqsave(&timer->dev->lock, flags);
165 list_del(&timer->list);
166 list_add_tail(&timer->list, &timer->dev->expired);
167 spin_unlock_irqrestore(&timer->dev->lock, flags);
168 wake_up_interruptible(&timer->dev->wait);
169}
170
171static int
172misdn_add_timer(struct mISDNtimerdev *dev, int timeout)
173{
174 int id;
175 u_long flags;
176 struct mISDNtimer *timer;
177
178 if (!timeout) {
179 dev->work = 1;
180 wake_up_interruptible(&dev->wait);
181 id = 0;
182 } else {
183 timer = kzalloc(sizeof(struct mISDNtimer), GFP_KERNEL);
184 if (!timer)
185 return -ENOMEM;
186 spin_lock_irqsave(&dev->lock, flags);
187 timer->id = dev->next_id++;
188 if (dev->next_id < 0)
189 dev->next_id = 1;
190 list_add_tail(&timer->list, &dev->pending);
191 spin_unlock_irqrestore(&dev->lock, flags);
192 timer->dev = dev;
193 timer->tl.data = (long)timer;
194 timer->tl.function = (void *) dev_expire_timer;
195 init_timer(&timer->tl);
196 timer->tl.expires = jiffies + ((HZ * (u_long)timeout) / 1000);
197 add_timer(&timer->tl);
198 id = timer->id;
199 }
200 return id;
201}
202
203static int
204misdn_del_timer(struct mISDNtimerdev *dev, int id)
205{
206 u_long flags;
207 struct mISDNtimer *timer;
208 int ret = 0;
209
210 spin_lock_irqsave(&dev->lock, flags);
211 list_for_each_entry(timer, &dev->pending, list) {
212 if (timer->id == id) {
213 list_del_init(&timer->list);
214 del_timer(&timer->tl);
215 ret = timer->id;
216 kfree(timer);
217 goto unlock;
218 }
219 }
220unlock:
221 spin_unlock_irqrestore(&dev->lock, flags);
222 return ret;
223}
224
225static int
226mISDN_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
227 unsigned long arg)
228{
229 struct mISDNtimerdev *dev = filep->private_data;
230 int id, tout, ret = 0;
231
232
233 if (*debug & DEBUG_TIMER)
234 printk(KERN_DEBUG "%s(%p, %x, %lx)\n", __func__,
235 filep, cmd, arg);
236 switch (cmd) {
237 case IMADDTIMER:
238 if (get_user(tout, (int __user *)arg)) {
239 ret = -EFAULT;
240 break;
241 }
242 id = misdn_add_timer(dev, tout);
243 if (*debug & DEBUG_TIMER)
244 printk(KERN_DEBUG "%s add %d id %d\n", __func__,
245 tout, id);
246 if (id < 0) {
247 ret = id;
248 break;
249 }
250 if (put_user(id, (int __user *)arg))
251 ret = -EFAULT;
252 break;
253 case IMDELTIMER:
254 if (get_user(id, (int __user *)arg)) {
255 ret = -EFAULT;
256 break;
257 }
258 if (*debug & DEBUG_TIMER)
259 printk(KERN_DEBUG "%s del id %d\n", __func__, id);
260 id = misdn_del_timer(dev, id);
261 if (put_user(id, (int __user *)arg))
262 ret = -EFAULT;
263 break;
264 default:
265 ret = -EINVAL;
266 }
267 return ret;
268}
269
270static struct file_operations mISDN_fops = {
271 .llseek = mISDN_llseek,
272 .read = mISDN_read,
273 .write = mISDN_write,
274 .poll = mISDN_poll,
275 .ioctl = mISDN_ioctl,
276 .open = mISDN_open,
277 .release = mISDN_close,
278};
279
280static struct miscdevice mISDNtimer = {
281 .minor = MISC_DYNAMIC_MINOR,
282 .name = "mISDNtimer",
283 .fops = &mISDN_fops,
284};
285
286int
287mISDN_inittimer(int *deb)
288{
289 int err;
290
291 debug = deb;
292 err = misc_register(&mISDNtimer);
293 if (err)
294 printk(KERN_WARNING "mISDN: Could not register timer device\n");
295 return err;
296}
297
298void mISDN_timer_cleanup(void)
299{
300 misc_deregister(&mISDNtimer);
301}
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 5eea4356d703..90663e01a56e 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -135,6 +135,7 @@ static void unmap_switcher(void)
135 /* Now we just need to free the pages we copied the switcher into */ 135 /* Now we just need to free the pages we copied the switcher into */
136 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) 136 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++)
137 __free_pages(switcher_page[i], 0); 137 __free_pages(switcher_page[i], 0);
138 kfree(switcher_page);
138} 139}
139 140
140/*H:032 141/*H:032
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 0414ddf87587..a1039068f95c 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -406,7 +406,8 @@ void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int num, u32 lo, u32 hi)
406 * deliver_trap() to bounce it back into the Guest. */ 406 * deliver_trap() to bounce it back into the Guest. */
407static void default_idt_entry(struct desc_struct *idt, 407static void default_idt_entry(struct desc_struct *idt,
408 int trap, 408 int trap,
409 const unsigned long handler) 409 const unsigned long handler,
410 const struct desc_struct *base)
410{ 411{
411 /* A present interrupt gate. */ 412 /* A present interrupt gate. */
412 u32 flags = 0x8e00; 413 u32 flags = 0x8e00;
@@ -415,6 +416,10 @@ static void default_idt_entry(struct desc_struct *idt,
415 * the Guest to use the "int" instruction to trigger it. */ 416 * the Guest to use the "int" instruction to trigger it. */
416 if (trap == LGUEST_TRAP_ENTRY) 417 if (trap == LGUEST_TRAP_ENTRY)
417 flags |= (GUEST_PL << 13); 418 flags |= (GUEST_PL << 13);
419 else if (base)
420 /* Copy priv. level from what Guest asked for. This allows
421 * debug (int 3) traps from Guest userspace, for example. */
422 flags |= (base->b & 0x6000);
418 423
419 /* Now pack it into the IDT entry in its weird format. */ 424 /* Now pack it into the IDT entry in its weird format. */
420 idt->a = (LGUEST_CS<<16) | (handler&0x0000FFFF); 425 idt->a = (LGUEST_CS<<16) | (handler&0x0000FFFF);
@@ -428,7 +433,7 @@ void setup_default_idt_entries(struct lguest_ro_state *state,
428 unsigned int i; 433 unsigned int i;
429 434
430 for (i = 0; i < ARRAY_SIZE(state->guest_idt); i++) 435 for (i = 0; i < ARRAY_SIZE(state->guest_idt); i++)
431 default_idt_entry(&state->guest_idt[i], i, def[i]); 436 default_idt_entry(&state->guest_idt[i], i, def[i], NULL);
432} 437}
433 438
434/*H:240 We don't use the IDT entries in the "struct lguest" directly, instead 439/*H:240 We don't use the IDT entries in the "struct lguest" directly, instead
@@ -442,6 +447,8 @@ void copy_traps(const struct lg_cpu *cpu, struct desc_struct *idt,
442 /* We can simply copy the direct traps, otherwise we use the default 447 /* We can simply copy the direct traps, otherwise we use the default
443 * ones in the Switcher: they will return to the Host. */ 448 * ones in the Switcher: they will return to the Host. */
444 for (i = 0; i < ARRAY_SIZE(cpu->arch.idt); i++) { 449 for (i = 0; i < ARRAY_SIZE(cpu->arch.idt); i++) {
450 const struct desc_struct *gidt = &cpu->arch.idt[i];
451
445 /* If no Guest can ever override this trap, leave it alone. */ 452 /* If no Guest can ever override this trap, leave it alone. */
446 if (!direct_trap(i)) 453 if (!direct_trap(i))
447 continue; 454 continue;
@@ -449,12 +456,15 @@ void copy_traps(const struct lg_cpu *cpu, struct desc_struct *idt,
449 /* Only trap gates (type 15) can go direct to the Guest. 456 /* Only trap gates (type 15) can go direct to the Guest.
450 * Interrupt gates (type 14) disable interrupts as they are 457 * Interrupt gates (type 14) disable interrupts as they are
451 * entered, which we never let the Guest do. Not present 458 * entered, which we never let the Guest do. Not present
452 * entries (type 0x0) also can't go direct, of course. */ 459 * entries (type 0x0) also can't go direct, of course.
453 if (idt_type(cpu->arch.idt[i].a, cpu->arch.idt[i].b) == 0xF) 460 *
454 idt[i] = cpu->arch.idt[i]; 461 * If it can't go direct, we still need to copy the priv. level:
462 * they might want to give userspace access to a software
463 * interrupt. */
464 if (idt_type(gidt->a, gidt->b) == 0xF)
465 idt[i] = *gidt;
455 else 466 else
456 /* Reset it to the default. */ 467 default_idt_entry(&idt[i], i, def[i], gidt);
457 default_idt_entry(&idt[i], i, def[i]);
458 } 468 }
459} 469}
460 470
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 95dfda52b4f9..bf7942327bda 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -480,7 +480,7 @@ void __init lguest_arch_host_init(void)
480 * bit on its CPU, depending on the argument (0 == unset). */ 480 * bit on its CPU, depending on the argument (0 == unset). */
481 on_each_cpu(adjust_pge, (void *)0, 1); 481 on_each_cpu(adjust_pge, (void *)0, 1);
482 /* Turn off the feature in the global feature set. */ 482 /* Turn off the feature in the global feature set. */
483 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 483 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_PGE);
484 } 484 }
485 put_online_cpus(); 485 put_online_cpus();
486}; 486};
@@ -491,7 +491,7 @@ void __exit lguest_arch_host_fini(void)
491 /* If we had PGE before we started, turn it back on now. */ 491 /* If we had PGE before we started, turn it back on now. */
492 get_online_cpus(); 492 get_online_cpus();
493 if (cpu_had_pge) { 493 if (cpu_had_pge) {
494 set_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 494 set_cpu_cap(&boot_cpu_data, X86_FEATURE_PGE);
495 /* adjust_pge's argument "1" means set PGE. */ 495 /* adjust_pge's argument "1" means set PGE. */
496 on_each_cpu(adjust_pge, (void *)1, 1); 496 on_each_cpu(adjust_pge, (void *)1, 1);
497 } 497 }
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index fea966d66f98..71dd65aa31b6 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -147,9 +147,12 @@ static struct priority_group *alloc_priority_group(void)
147static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti) 147static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
148{ 148{
149 struct pgpath *pgpath, *tmp; 149 struct pgpath *pgpath, *tmp;
150 struct multipath *m = ti->private;
150 151
151 list_for_each_entry_safe(pgpath, tmp, pgpaths, list) { 152 list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
152 list_del(&pgpath->list); 153 list_del(&pgpath->list);
154 if (m->hw_handler_name)
155 scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev));
153 dm_put_device(ti, pgpath->path.dev); 156 dm_put_device(ti, pgpath->path.dev);
154 free_pgpath(pgpath); 157 free_pgpath(pgpath);
155 } 158 }
@@ -548,6 +551,7 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
548{ 551{
549 int r; 552 int r;
550 struct pgpath *p; 553 struct pgpath *p;
554 struct multipath *m = ti->private;
551 555
552 /* we need at least a path arg */ 556 /* we need at least a path arg */
553 if (as->argc < 1) { 557 if (as->argc < 1) {
@@ -566,6 +570,15 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
566 goto bad; 570 goto bad;
567 } 571 }
568 572
573 if (m->hw_handler_name) {
574 r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
575 m->hw_handler_name);
576 if (r < 0) {
577 dm_put_device(ti, p->path.dev);
578 goto bad;
579 }
580 }
581
569 r = ps->type->add_path(ps, &p->path, as->argc, as->argv, &ti->error); 582 r = ps->type->add_path(ps, &p->path, as->argc, as->argv, &ti->error);
570 if (r) { 583 if (r) {
571 dm_put_device(ti, p->path.dev); 584 dm_put_device(ti, p->path.dev);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 171afe7da6b6..cf6a817d5059 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -563,7 +563,7 @@ int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev
563 563
564 DEB_EE(("dev:%p\n",dev)); 564 DEB_EE(("dev:%p\n",dev));
565 565
566 if( VFL_TYPE_GRABBER == (*vid)->type ) { 566 if ((*vid)->vfl_type == VFL_TYPE_GRABBER) {
567 vv->video_minor = -1; 567 vv->video_minor = -1;
568 } else { 568 } else {
569 vv->vbi_minor = -1; 569 vv->vbi_minor = -1;
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index a5e62750eea3..e8bc7abf2409 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -656,7 +656,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
656 656
657 /* if we have a user buffer, the first page may not be 657 /* if we have a user buffer, the first page may not be
658 aligned to a page boundary. */ 658 aligned to a page boundary. */
659 pt1->offset = list->offset; 659 pt1->offset = dma->sglist->offset;
660 pt2->offset = pt1->offset+o1; 660 pt2->offset = pt1->offset+o1;
661 pt3->offset = pt1->offset+o2; 661 pt3->offset = pt1->offset+o2;
662 662
@@ -958,21 +958,18 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
958 case VIDIOC_ENUM_FMT: 958 case VIDIOC_ENUM_FMT:
959 { 959 {
960 struct v4l2_fmtdesc *f = arg; 960 struct v4l2_fmtdesc *f = arg;
961 int index;
962 961
963 switch (f->type) { 962 switch (f->type) {
964 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 963 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
965 case V4L2_BUF_TYPE_VIDEO_OVERLAY: { 964 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
966 index = f->index; 965 if (f->index >= NUM_FORMATS)
967 if (index < 0 || index >= NUM_FORMATS) {
968 return -EINVAL; 966 return -EINVAL;
969 } 967 strlcpy((char *)f->description, formats[f->index].name,
970 memset(f,0,sizeof(*f)); 968 sizeof(f->description));
971 f->index = index; 969 f->pixelformat = formats[f->index].pixelformat;
972 strlcpy((char *)f->description,formats[index].name,sizeof(f->description)); 970 f->flags = 0;
973 f->pixelformat = formats[index].pixelformat; 971 memset(f->reserved, 0, sizeof(f->reserved));
974 break; 972 break;
975 }
976 default: 973 default:
977 return -EINVAL; 974 return -EINVAL;
978 } 975 }
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index 850d5689b14d..6f92beaa5ac8 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -21,9 +21,8 @@ config MEDIA_TUNER
21 tristate 21 tristate
22 default VIDEO_MEDIA && I2C 22 default VIDEO_MEDIA && I2C
23 depends on VIDEO_MEDIA && I2C 23 depends on VIDEO_MEDIA && I2C
24 select FW_LOADER if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG 24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE
25 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG 25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE
26 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
27 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE 26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE
28 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE 27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE
29 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE 28 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE
@@ -138,8 +137,6 @@ config MEDIA_TUNER_QT1010
138config MEDIA_TUNER_XC2028 137config MEDIA_TUNER_XC2028
139 tristate "XCeive xc2028/xc3028 tuners" 138 tristate "XCeive xc2028/xc3028 tuners"
140 depends on VIDEO_MEDIA && I2C 139 depends on VIDEO_MEDIA && I2C
141 depends on HOTPLUG
142 select FW_LOADER
143 default m if MEDIA_TUNER_CUSTOMIZE 140 default m if MEDIA_TUNER_CUSTOMIZE
144 help 141 help
145 Say Y here to include support for the xc2028/xc3028 tuners. 142 Say Y here to include support for the xc2028/xc3028 tuners.
@@ -147,8 +144,6 @@ config MEDIA_TUNER_XC2028
147config MEDIA_TUNER_XC5000 144config MEDIA_TUNER_XC5000
148 tristate "Xceive XC5000 silicon tuner" 145 tristate "Xceive XC5000 silicon tuner"
149 depends on VIDEO_MEDIA && I2C 146 depends on VIDEO_MEDIA && I2C
150 depends on HOTPLUG
151 select FW_LOADER
152 default m if DVB_FE_CUSTOMISE 147 default m if DVB_FE_CUSTOMISE
153 help 148 help
154 A driver for the silicon tuner XC5000 from Xceive. 149 A driver for the silicon tuner XC5000 from Xceive.
@@ -162,4 +157,11 @@ config MEDIA_TUNER_MXL5005S
162 help 157 help
163 A driver for the silicon tuner MXL5005S from MaxLinear. 158 A driver for the silicon tuner MXL5005S from MaxLinear.
164 159
160config MEDIA_TUNER_MXL5007T
161 tristate "MaxLinear MxL5007T silicon tuner"
162 depends on VIDEO_MEDIA && I2C
163 default m if DVB_FE_CUSTOMISE
164 help
165 A driver for the silicon tuner MxL5007T from MaxLinear.
166
165endif # MEDIA_TUNER_CUSTOMIZE 167endif # MEDIA_TUNER_CUSTOMIZE
diff --git a/drivers/media/common/tuners/Makefile b/drivers/media/common/tuners/Makefile
index 55f7e6706297..4dfbe5b8264f 100644
--- a/drivers/media/common/tuners/Makefile
+++ b/drivers/media/common/tuners/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o
21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o 21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o
22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o 22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o
23obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o 23obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o
24obj-$(CONFIG_MEDIA_TUNER_MXL5007T) += mxl5007t.o
24 25
25EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 26EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
26EXTRA_CFLAGS += -Idrivers/media/dvb/frontends 27EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
diff --git a/drivers/media/common/tuners/mt20xx.c b/drivers/media/common/tuners/mt20xx.c
index fbcb28233737..35b763a16d53 100644
--- a/drivers/media/common/tuners/mt20xx.c
+++ b/drivers/media/common/tuners/mt20xx.c
@@ -148,7 +148,8 @@ static int mt2032_compute_freq(struct dvb_frontend *fe,
148 tuner_dbg("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n", 148 tuner_dbg("mt2032: rfin=%d lo2=%d lo2n=%d lo2a=%d num=%d lo2freq=%d\n",
149 rfin,lo2,lo2n,lo2a,lo2num,lo2freq); 149 rfin,lo2,lo2n,lo2a,lo2num,lo2freq);
150 150
151 if(lo1a<0 || lo1a>7 || lo1n<17 ||lo1n>48 || lo2a<0 ||lo2a >7 ||lo2n<17 || lo2n>30) { 151 if (lo1a > 7 || lo1n < 17 || lo1n > 48 || lo2a > 7 || lo2n < 17 ||
152 lo2n > 30) {
152 tuner_info("mt2032: frequency parameters out of range: %d %d %d %d\n", 153 tuner_info("mt2032: frequency parameters out of range: %d %d %d %d\n",
153 lo1a, lo1n, lo2a,lo2n); 154 lo1a, lo1n, lo2a,lo2n);
154 return(-1); 155 return(-1);
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c
new file mode 100644
index 000000000000..cb25e43502fe
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5007t.c
@@ -0,0 +1,1030 @@
1/*
2 * mxl5007t.c - driver for the MaxLinear MxL5007T silicon tuner
3 *
4 * Copyright (C) 2008 Michael Krufky <mkrufky@linuxtv.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/i2c.h>
22#include <linux/types.h>
23#include <linux/videodev2.h>
24#include "tuner-i2c.h"
25#include "mxl5007t.h"
26
27static DEFINE_MUTEX(mxl5007t_list_mutex);
28static LIST_HEAD(hybrid_tuner_instance_list);
29
30static int mxl5007t_debug;
31module_param_named(debug, mxl5007t_debug, int, 0644);
32MODULE_PARM_DESC(debug, "set debug level");
33
34/* ------------------------------------------------------------------------- */
35
36#define mxl_printk(kern, fmt, arg...) \
37 printk(kern "%s: " fmt "\n", __func__, ##arg)
38
39#define mxl_err(fmt, arg...) \
40 mxl_printk(KERN_ERR, "%d: " fmt, __LINE__, ##arg)
41
42#define mxl_warn(fmt, arg...) \
43 mxl_printk(KERN_WARNING, fmt, ##arg)
44
45#define mxl_info(fmt, arg...) \
46 mxl_printk(KERN_INFO, fmt, ##arg)
47
48#define mxl_debug(fmt, arg...) \
49({ \
50 if (mxl5007t_debug) \
51 mxl_printk(KERN_DEBUG, fmt, ##arg); \
52})
53
54#define mxl_fail(ret) \
55({ \
56 int __ret; \
57 __ret = (ret < 0); \
58 if (__ret) \
59 mxl_printk(KERN_ERR, "error %d on line %d", \
60 ret, __LINE__); \
61 __ret; \
62})
63
64/* ------------------------------------------------------------------------- */
65
66#define MHz 1000000
67
68enum mxl5007t_mode {
69 MxL_MODE_OTA_DVBT_ATSC = 0,
70 MxL_MODE_OTA_NTSC_PAL_GH = 1,
71 MxL_MODE_OTA_PAL_IB = 2,
72 MxL_MODE_OTA_PAL_D_SECAM_KL = 3,
73 MxL_MODE_OTA_ISDBT = 4,
74 MxL_MODE_CABLE_DIGITAL = 0x10,
75 MxL_MODE_CABLE_NTSC_PAL_GH = 0x11,
76 MxL_MODE_CABLE_PAL_IB = 0x12,
77 MxL_MODE_CABLE_PAL_D_SECAM_KL = 0x13,
78 MxL_MODE_CABLE_SCTE40 = 0x14,
79};
80
81enum mxl5007t_chip_version {
82 MxL_UNKNOWN_ID = 0x00,
83 MxL_5007_V1_F1 = 0x11,
84 MxL_5007_V1_F2 = 0x12,
85 MxL_5007_V2_100_F1 = 0x21,
86 MxL_5007_V2_100_F2 = 0x22,
87 MxL_5007_V2_200_F1 = 0x23,
88 MxL_5007_V2_200_F2 = 0x24,
89};
90
91struct reg_pair_t {
92 u8 reg;
93 u8 val;
94};
95
96/* ------------------------------------------------------------------------- */
97
98static struct reg_pair_t init_tab[] = {
99 { 0x0b, 0x44 }, /* XTAL */
100 { 0x0c, 0x60 }, /* IF */
101 { 0x10, 0x00 }, /* MISC */
102 { 0x12, 0xca }, /* IDAC */
103 { 0x16, 0x90 }, /* MODE */
104 { 0x32, 0x38 }, /* MODE Analog/Digital */
105 { 0xd8, 0x18 }, /* CLK_OUT_ENABLE */
106 { 0x2c, 0x34 }, /* OVERRIDE */
107 { 0x4d, 0x40 }, /* OVERRIDE */
108 { 0x7f, 0x02 }, /* OVERRIDE */
109 { 0x9a, 0x52 }, /* OVERRIDE */
110 { 0x48, 0x5a }, /* OVERRIDE */
111 { 0x76, 0x1a }, /* OVERRIDE */
112 { 0x6a, 0x48 }, /* OVERRIDE */
113 { 0x64, 0x28 }, /* OVERRIDE */
114 { 0x66, 0xe6 }, /* OVERRIDE */
115 { 0x35, 0x0e }, /* OVERRIDE */
116 { 0x7e, 0x01 }, /* OVERRIDE */
117 { 0x83, 0x00 }, /* OVERRIDE */
118 { 0x04, 0x0b }, /* OVERRIDE */
119 { 0x05, 0x01 }, /* TOP_MASTER_ENABLE */
120 { 0, 0 }
121};
122
123static struct reg_pair_t init_tab_cable[] = {
124 { 0x0b, 0x44 }, /* XTAL */
125 { 0x0c, 0x60 }, /* IF */
126 { 0x10, 0x00 }, /* MISC */
127 { 0x12, 0xca }, /* IDAC */
128 { 0x16, 0x90 }, /* MODE */
129 { 0x32, 0x38 }, /* MODE A/D */
130 { 0x71, 0x3f }, /* TOP1 */
131 { 0x72, 0x3f }, /* TOP2 */
132 { 0x74, 0x3f }, /* TOP3 */
133 { 0xd8, 0x18 }, /* CLK_OUT_ENABLE */
134 { 0x2c, 0x34 }, /* OVERRIDE */
135 { 0x4d, 0x40 }, /* OVERRIDE */
136 { 0x7f, 0x02 }, /* OVERRIDE */
137 { 0x9a, 0x52 }, /* OVERRIDE */
138 { 0x48, 0x5a }, /* OVERRIDE */
139 { 0x76, 0x1a }, /* OVERRIDE */
140 { 0x6a, 0x48 }, /* OVERRIDE */
141 { 0x64, 0x28 }, /* OVERRIDE */
142 { 0x66, 0xe6 }, /* OVERRIDE */
143 { 0x35, 0x0e }, /* OVERRIDE */
144 { 0x7e, 0x01 }, /* OVERRIDE */
145 { 0x04, 0x0b }, /* OVERRIDE */
146 { 0x68, 0xb4 }, /* OVERRIDE */
147 { 0x36, 0x00 }, /* OVERRIDE */
148 { 0x05, 0x01 }, /* TOP_MASTER_ENABLE */
149 { 0, 0 }
150};
151
152/* ------------------------------------------------------------------------- */
153
154static struct reg_pair_t reg_pair_rftune[] = {
155 { 0x11, 0x00 }, /* abort tune */
156 { 0x13, 0x15 },
157 { 0x14, 0x40 },
158 { 0x15, 0x0e },
159 { 0x11, 0x02 }, /* start tune */
160 { 0, 0 }
161};
162
163/* ------------------------------------------------------------------------- */
164
165struct mxl5007t_state {
166 struct list_head hybrid_tuner_instance_list;
167 struct tuner_i2c_props i2c_props;
168
169 struct mutex lock;
170
171 struct mxl5007t_config *config;
172
173 enum mxl5007t_chip_version chip_id;
174
175 struct reg_pair_t tab_init[ARRAY_SIZE(init_tab)];
176 struct reg_pair_t tab_init_cable[ARRAY_SIZE(init_tab_cable)];
177 struct reg_pair_t tab_rftune[ARRAY_SIZE(reg_pair_rftune)];
178
179 u32 frequency;
180 u32 bandwidth;
181};
182
183/* ------------------------------------------------------------------------- */
184
185/* called by _init and _rftun to manipulate the register arrays */
186
187static void set_reg_bits(struct reg_pair_t *reg_pair, u8 reg, u8 mask, u8 val)
188{
189 unsigned int i = 0;
190
191 while (reg_pair[i].reg || reg_pair[i].val) {
192 if (reg_pair[i].reg == reg) {
193 reg_pair[i].val &= ~mask;
194 reg_pair[i].val |= val;
195 }
196 i++;
197
198 }
199 return;
200}
201
202static void copy_reg_bits(struct reg_pair_t *reg_pair1,
203 struct reg_pair_t *reg_pair2)
204{
205 unsigned int i, j;
206
207 i = j = 0;
208
209 while (reg_pair1[i].reg || reg_pair1[i].val) {
210 while (reg_pair2[j].reg || reg_pair2[j].reg) {
211 if (reg_pair1[i].reg != reg_pair2[j].reg) {
212 j++;
213 continue;
214 }
215 reg_pair2[j].val = reg_pair1[i].val;
216 break;
217 }
218 i++;
219 }
220 return;
221}
222
223/* ------------------------------------------------------------------------- */
224
225static void mxl5007t_set_mode_bits(struct mxl5007t_state *state,
226 enum mxl5007t_mode mode,
227 s32 if_diff_out_level)
228{
229 switch (mode) {
230 case MxL_MODE_OTA_DVBT_ATSC:
231 set_reg_bits(state->tab_init, 0x32, 0x0f, 0x06);
232 set_reg_bits(state->tab_init, 0x35, 0xff, 0x0e);
233 break;
234 case MxL_MODE_OTA_ISDBT:
235 set_reg_bits(state->tab_init, 0x32, 0x0f, 0x06);
236 set_reg_bits(state->tab_init, 0x35, 0xff, 0x12);
237 break;
238 case MxL_MODE_OTA_NTSC_PAL_GH:
239 set_reg_bits(state->tab_init, 0x16, 0x70, 0x00);
240 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
241 break;
242 case MxL_MODE_OTA_PAL_IB:
243 set_reg_bits(state->tab_init, 0x16, 0x70, 0x10);
244 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
245 break;
246 case MxL_MODE_OTA_PAL_D_SECAM_KL:
247 set_reg_bits(state->tab_init, 0x16, 0x70, 0x20);
248 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
249 break;
250 case MxL_MODE_CABLE_DIGITAL:
251 set_reg_bits(state->tab_init_cable, 0x71, 0xff, 0x01);
252 set_reg_bits(state->tab_init_cable, 0x72, 0xff,
253 8 - if_diff_out_level);
254 set_reg_bits(state->tab_init_cable, 0x74, 0xff, 0x17);
255 break;
256 case MxL_MODE_CABLE_NTSC_PAL_GH:
257 set_reg_bits(state->tab_init, 0x16, 0x70, 0x00);
258 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
259 set_reg_bits(state->tab_init_cable, 0x71, 0xff, 0x01);
260 set_reg_bits(state->tab_init_cable, 0x72, 0xff,
261 8 - if_diff_out_level);
262 set_reg_bits(state->tab_init_cable, 0x74, 0xff, 0x17);
263 break;
264 case MxL_MODE_CABLE_PAL_IB:
265 set_reg_bits(state->tab_init, 0x16, 0x70, 0x10);
266 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
267 set_reg_bits(state->tab_init_cable, 0x71, 0xff, 0x01);
268 set_reg_bits(state->tab_init_cable, 0x72, 0xff,
269 8 - if_diff_out_level);
270 set_reg_bits(state->tab_init_cable, 0x74, 0xff, 0x17);
271 break;
272 case MxL_MODE_CABLE_PAL_D_SECAM_KL:
273 set_reg_bits(state->tab_init, 0x16, 0x70, 0x20);
274 set_reg_bits(state->tab_init, 0x32, 0xff, 0x85);
275 set_reg_bits(state->tab_init_cable, 0x71, 0xff, 0x01);
276 set_reg_bits(state->tab_init_cable, 0x72, 0xff,
277 8 - if_diff_out_level);
278 set_reg_bits(state->tab_init_cable, 0x74, 0xff, 0x17);
279 break;
280 case MxL_MODE_CABLE_SCTE40:
281 set_reg_bits(state->tab_init_cable, 0x36, 0xff, 0x08);
282 set_reg_bits(state->tab_init_cable, 0x68, 0xff, 0xbc);
283 set_reg_bits(state->tab_init_cable, 0x71, 0xff, 0x01);
284 set_reg_bits(state->tab_init_cable, 0x72, 0xff,
285 8 - if_diff_out_level);
286 set_reg_bits(state->tab_init_cable, 0x74, 0xff, 0x17);
287 break;
288 default:
289 mxl_fail(-EINVAL);
290 }
291 return;
292}
293
294static void mxl5007t_set_if_freq_bits(struct mxl5007t_state *state,
295 enum mxl5007t_if_freq if_freq,
296 int invert_if)
297{
298 u8 val;
299
300 switch (if_freq) {
301 case MxL_IF_4_MHZ:
302 val = 0x00;
303 break;
304 case MxL_IF_4_5_MHZ:
305 val = 0x20;
306 break;
307 case MxL_IF_4_57_MHZ:
308 val = 0x30;
309 break;
310 case MxL_IF_5_MHZ:
311 val = 0x40;
312 break;
313 case MxL_IF_5_38_MHZ:
314 val = 0x50;
315 break;
316 case MxL_IF_6_MHZ:
317 val = 0x60;
318 break;
319 case MxL_IF_6_28_MHZ:
320 val = 0x70;
321 break;
322 case MxL_IF_9_1915_MHZ:
323 val = 0x80;
324 break;
325 case MxL_IF_35_25_MHZ:
326 val = 0x90;
327 break;
328 case MxL_IF_36_15_MHZ:
329 val = 0xa0;
330 break;
331 case MxL_IF_44_MHZ:
332 val = 0xb0;
333 break;
334 default:
335 mxl_fail(-EINVAL);
336 return;
337 }
338 set_reg_bits(state->tab_init, 0x0c, 0xf0, val);
339
340 /* set inverted IF or normal IF */
341 set_reg_bits(state->tab_init, 0x0c, 0x08, invert_if ? 0x08 : 0x00);
342
343 return;
344}
345
346static void mxl5007t_set_xtal_freq_bits(struct mxl5007t_state *state,
347 enum mxl5007t_xtal_freq xtal_freq)
348{
349 u8 val;
350
351 switch (xtal_freq) {
352 case MxL_XTAL_16_MHZ:
353 val = 0x00; /* select xtal freq & Ref Freq */
354 break;
355 case MxL_XTAL_20_MHZ:
356 val = 0x11;
357 break;
358 case MxL_XTAL_20_25_MHZ:
359 val = 0x22;
360 break;
361 case MxL_XTAL_20_48_MHZ:
362 val = 0x33;
363 break;
364 case MxL_XTAL_24_MHZ:
365 val = 0x44;
366 break;
367 case MxL_XTAL_25_MHZ:
368 val = 0x55;
369 break;
370 case MxL_XTAL_25_14_MHZ:
371 val = 0x66;
372 break;
373 case MxL_XTAL_27_MHZ:
374 val = 0x77;
375 break;
376 case MxL_XTAL_28_8_MHZ:
377 val = 0x88;
378 break;
379 case MxL_XTAL_32_MHZ:
380 val = 0x99;
381 break;
382 case MxL_XTAL_40_MHZ:
383 val = 0xaa;
384 break;
385 case MxL_XTAL_44_MHZ:
386 val = 0xbb;
387 break;
388 case MxL_XTAL_48_MHZ:
389 val = 0xcc;
390 break;
391 case MxL_XTAL_49_3811_MHZ:
392 val = 0xdd;
393 break;
394 default:
395 mxl_fail(-EINVAL);
396 return;
397 }
398 set_reg_bits(state->tab_init, 0x0b, 0xff, val);
399
400 return;
401}
402
403static struct reg_pair_t *mxl5007t_calc_init_regs(struct mxl5007t_state *state,
404 enum mxl5007t_mode mode)
405{
406 struct mxl5007t_config *cfg = state->config;
407
408 memcpy(&state->tab_init, &init_tab, sizeof(init_tab));
409 memcpy(&state->tab_init_cable, &init_tab_cable, sizeof(init_tab_cable));
410
411 mxl5007t_set_mode_bits(state, mode, cfg->if_diff_out_level);
412 mxl5007t_set_if_freq_bits(state, cfg->if_freq_hz, cfg->invert_if);
413 mxl5007t_set_xtal_freq_bits(state, cfg->xtal_freq_hz);
414
415 set_reg_bits(state->tab_init, 0x10, 0x40, cfg->loop_thru_enable << 6);
416
417 set_reg_bits(state->tab_init, 0xd8, 0x08, cfg->clk_out_enable << 3);
418
419 set_reg_bits(state->tab_init, 0x10, 0x07, cfg->clk_out_amp);
420
421 /* set IDAC to automatic mode control by AGC */
422 set_reg_bits(state->tab_init, 0x12, 0x80, 0x00);
423
424 if (mode >= MxL_MODE_CABLE_DIGITAL) {
425 copy_reg_bits(state->tab_init, state->tab_init_cable);
426 return state->tab_init_cable;
427 } else
428 return state->tab_init;
429}
430
431/* ------------------------------------------------------------------------- */
432
433enum mxl5007t_bw_mhz {
434 MxL_BW_6MHz = 6,
435 MxL_BW_7MHz = 7,
436 MxL_BW_8MHz = 8,
437};
438
439static void mxl5007t_set_bw_bits(struct mxl5007t_state *state,
440 enum mxl5007t_bw_mhz bw)
441{
442 u8 val;
443
444 switch (bw) {
445 case MxL_BW_6MHz:
446 val = 0x15; /* set DIG_MODEINDEX, DIG_MODEINDEX_A,
447 * and DIG_MODEINDEX_CSF */
448 break;
449 case MxL_BW_7MHz:
450 val = 0x21;
451 break;
452 case MxL_BW_8MHz:
453 val = 0x3f;
454 break;
455 default:
456 mxl_fail(-EINVAL);
457 return;
458 }
459 set_reg_bits(state->tab_rftune, 0x13, 0x3f, val);
460
461 return;
462}
463
464static struct
465reg_pair_t *mxl5007t_calc_rf_tune_regs(struct mxl5007t_state *state,
466 u32 rf_freq, enum mxl5007t_bw_mhz bw)
467{
468 u32 dig_rf_freq = 0;
469 u32 temp;
470 u32 frac_divider = 1000000;
471 unsigned int i;
472
473 memcpy(&state->tab_rftune, &reg_pair_rftune, sizeof(reg_pair_rftune));
474
475 mxl5007t_set_bw_bits(state, bw);
476
477 /* Convert RF frequency into 16 bits =>
478 * 10 bit integer (MHz) + 6 bit fraction */
479 dig_rf_freq = rf_freq / MHz;
480
481 temp = rf_freq % MHz;
482
483 for (i = 0; i < 6; i++) {
484 dig_rf_freq <<= 1;
485 frac_divider /= 2;
486 if (temp > frac_divider) {
487 temp -= frac_divider;
488 dig_rf_freq++;
489 }
490 }
491
492 /* add to have shift center point by 7.8124 kHz */
493 if (temp > 7812)
494 dig_rf_freq++;
495
496 set_reg_bits(state->tab_rftune, 0x14, 0xff, (u8)dig_rf_freq);
497 set_reg_bits(state->tab_rftune, 0x15, 0xff, (u8)(dig_rf_freq >> 8));
498
499 return state->tab_rftune;
500}
501
502/* ------------------------------------------------------------------------- */
503
504static int mxl5007t_write_reg(struct mxl5007t_state *state, u8 reg, u8 val)
505{
506 u8 buf[] = { reg, val };
507 struct i2c_msg msg = { .addr = state->i2c_props.addr, .flags = 0,
508 .buf = buf, .len = 2 };
509 int ret;
510
511 ret = i2c_transfer(state->i2c_props.adap, &msg, 1);
512 if (ret != 1) {
513 mxl_err("failed!");
514 return -EREMOTEIO;
515 }
516 return 0;
517}
518
519static int mxl5007t_write_regs(struct mxl5007t_state *state,
520 struct reg_pair_t *reg_pair)
521{
522 unsigned int i = 0;
523 int ret = 0;
524
525 while ((ret == 0) && (reg_pair[i].reg || reg_pair[i].val)) {
526 ret = mxl5007t_write_reg(state,
527 reg_pair[i].reg, reg_pair[i].val);
528 i++;
529 }
530 return ret;
531}
532
533static int mxl5007t_read_reg(struct mxl5007t_state *state, u8 reg, u8 *val)
534{
535 struct i2c_msg msg[] = {
536 { .addr = state->i2c_props.addr, .flags = 0,
537 .buf = &reg, .len = 1 },
538 { .addr = state->i2c_props.addr, .flags = I2C_M_RD,
539 .buf = val, .len = 1 },
540 };
541 int ret;
542
543 ret = i2c_transfer(state->i2c_props.adap, msg, 2);
544 if (ret != 2) {
545 mxl_err("failed!");
546 return -EREMOTEIO;
547 }
548 return 0;
549}
550
551static int mxl5007t_soft_reset(struct mxl5007t_state *state)
552{
553 u8 d = 0xff;
554 struct i2c_msg msg = { .addr = state->i2c_props.addr, .flags = 0,
555 .buf = &d, .len = 1 };
556
557 int ret = i2c_transfer(state->i2c_props.adap, &msg, 1);
558
559 if (ret != 1) {
560 mxl_err("failed!");
561 return -EREMOTEIO;
562 }
563 return 0;
564}
565
566static int mxl5007t_tuner_init(struct mxl5007t_state *state,
567 enum mxl5007t_mode mode)
568{
569 struct reg_pair_t *init_regs;
570 int ret;
571
572 ret = mxl5007t_soft_reset(state);
573 if (mxl_fail(ret))
574 goto fail;
575
576 /* calculate initialization reg array */
577 init_regs = mxl5007t_calc_init_regs(state, mode);
578
579 ret = mxl5007t_write_regs(state, init_regs);
580 if (mxl_fail(ret))
581 goto fail;
582 mdelay(1);
583
584 ret = mxl5007t_write_reg(state, 0x2c, 0x35);
585 mxl_fail(ret);
586fail:
587 return ret;
588}
589
590static int mxl5007t_tuner_rf_tune(struct mxl5007t_state *state, u32 rf_freq_hz,
591 enum mxl5007t_bw_mhz bw)
592{
593 struct reg_pair_t *rf_tune_regs;
594 int ret;
595
596 /* calculate channel change reg array */
597 rf_tune_regs = mxl5007t_calc_rf_tune_regs(state, rf_freq_hz, bw);
598
599 ret = mxl5007t_write_regs(state, rf_tune_regs);
600 if (mxl_fail(ret))
601 goto fail;
602 msleep(3);
603fail:
604 return ret;
605}
606
607/* ------------------------------------------------------------------------- */
608
609static int mxl5007t_synth_lock_status(struct mxl5007t_state *state,
610 int *rf_locked, int *ref_locked)
611{
612 u8 d;
613 int ret;
614
615 *rf_locked = 0;
616 *ref_locked = 0;
617
618 ret = mxl5007t_read_reg(state, 0xcf, &d);
619 if (mxl_fail(ret))
620 goto fail;
621
622 if ((d & 0x0c) == 0x0c)
623 *rf_locked = 1;
624
625 if ((d & 0x03) == 0x03)
626 *ref_locked = 1;
627fail:
628 return ret;
629}
630
631static int mxl5007t_check_rf_input_power(struct mxl5007t_state *state,
632 s32 *rf_input_level)
633{
634 u8 d1, d2;
635 int ret;
636
637 ret = mxl5007t_read_reg(state, 0xb7, &d1);
638 if (mxl_fail(ret))
639 goto fail;
640
641 ret = mxl5007t_read_reg(state, 0xbf, &d2);
642 if (mxl_fail(ret))
643 goto fail;
644
645 d2 = d2 >> 4;
646 if (d2 > 7)
647 d2 += 0xf0;
648
649 *rf_input_level = (s32)(d1 + d2 - 113);
650fail:
651 return ret;
652}
653
654/* ------------------------------------------------------------------------- */
655
656static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status)
657{
658 struct mxl5007t_state *state = fe->tuner_priv;
659 int rf_locked, ref_locked;
660 s32 rf_input_level;
661 int ret;
662
663 if (fe->ops.i2c_gate_ctrl)
664 fe->ops.i2c_gate_ctrl(fe, 1);
665
666 ret = mxl5007t_synth_lock_status(state, &rf_locked, &ref_locked);
667 if (mxl_fail(ret))
668 goto fail;
669 mxl_debug("%s%s", rf_locked ? "rf locked " : "",
670 ref_locked ? "ref locked" : "");
671
672 ret = mxl5007t_check_rf_input_power(state, &rf_input_level);
673 if (mxl_fail(ret))
674 goto fail;
675 mxl_debug("rf input power: %d", rf_input_level);
676fail:
677 if (fe->ops.i2c_gate_ctrl)
678 fe->ops.i2c_gate_ctrl(fe, 0);
679
680 return ret;
681}
682
683/* ------------------------------------------------------------------------- */
684
685static int mxl5007t_set_params(struct dvb_frontend *fe,
686 struct dvb_frontend_parameters *params)
687{
688 struct mxl5007t_state *state = fe->tuner_priv;
689 enum mxl5007t_bw_mhz bw;
690 enum mxl5007t_mode mode;
691 int ret;
692 u32 freq = params->frequency;
693
694 if (fe->ops.info.type == FE_ATSC) {
695 switch (params->u.vsb.modulation) {
696 case VSB_8:
697 case VSB_16:
698 mode = MxL_MODE_OTA_DVBT_ATSC;
699 break;
700 case QAM_64:
701 case QAM_256:
702 mode = MxL_MODE_CABLE_DIGITAL;
703 break;
704 default:
705 mxl_err("modulation not set!");
706 return -EINVAL;
707 }
708 bw = MxL_BW_6MHz;
709 } else if (fe->ops.info.type == FE_OFDM) {
710 switch (params->u.ofdm.bandwidth) {
711 case BANDWIDTH_6_MHZ:
712 bw = MxL_BW_6MHz;
713 break;
714 case BANDWIDTH_7_MHZ:
715 bw = MxL_BW_7MHz;
716 break;
717 case BANDWIDTH_8_MHZ:
718 bw = MxL_BW_8MHz;
719 break;
720 default:
721 mxl_err("bandwidth not set!");
722 return -EINVAL;
723 }
724 mode = MxL_MODE_OTA_DVBT_ATSC;
725 } else {
726 mxl_err("modulation type not supported!");
727 return -EINVAL;
728 }
729
730 if (fe->ops.i2c_gate_ctrl)
731 fe->ops.i2c_gate_ctrl(fe, 1);
732
733 mutex_lock(&state->lock);
734
735 ret = mxl5007t_tuner_init(state, mode);
736 if (mxl_fail(ret))
737 goto fail;
738
739 ret = mxl5007t_tuner_rf_tune(state, freq, bw);
740 if (mxl_fail(ret))
741 goto fail;
742
743 state->frequency = freq;
744 state->bandwidth = (fe->ops.info.type == FE_OFDM) ?
745 params->u.ofdm.bandwidth : 0;
746fail:
747 mutex_unlock(&state->lock);
748
749 if (fe->ops.i2c_gate_ctrl)
750 fe->ops.i2c_gate_ctrl(fe, 0);
751
752 return ret;
753}
754
755static int mxl5007t_set_analog_params(struct dvb_frontend *fe,
756 struct analog_parameters *params)
757{
758 struct mxl5007t_state *state = fe->tuner_priv;
759 enum mxl5007t_bw_mhz bw = 0; /* FIXME */
760 enum mxl5007t_mode cbl_mode;
761 enum mxl5007t_mode ota_mode;
762 char *mode_name;
763 int ret;
764 u32 freq = params->frequency * 62500;
765
766#define cable 1
767 if (params->std & V4L2_STD_MN) {
768 cbl_mode = MxL_MODE_CABLE_NTSC_PAL_GH;
769 ota_mode = MxL_MODE_OTA_NTSC_PAL_GH;
770 mode_name = "MN";
771 } else if (params->std & V4L2_STD_B) {
772 cbl_mode = MxL_MODE_CABLE_PAL_IB;
773 ota_mode = MxL_MODE_OTA_PAL_IB;
774 mode_name = "B";
775 } else if (params->std & V4L2_STD_GH) {
776 cbl_mode = MxL_MODE_CABLE_NTSC_PAL_GH;
777 ota_mode = MxL_MODE_OTA_NTSC_PAL_GH;
778 mode_name = "GH";
779 } else if (params->std & V4L2_STD_PAL_I) {
780 cbl_mode = MxL_MODE_CABLE_PAL_IB;
781 ota_mode = MxL_MODE_OTA_PAL_IB;
782 mode_name = "I";
783 } else if (params->std & V4L2_STD_DK) {
784 cbl_mode = MxL_MODE_CABLE_PAL_D_SECAM_KL;
785 ota_mode = MxL_MODE_OTA_PAL_D_SECAM_KL;
786 mode_name = "DK";
787 } else if (params->std & V4L2_STD_SECAM_L) {
788 cbl_mode = MxL_MODE_CABLE_PAL_D_SECAM_KL;
789 ota_mode = MxL_MODE_OTA_PAL_D_SECAM_KL;
790 mode_name = "L";
791 } else if (params->std & V4L2_STD_SECAM_LC) {
792 cbl_mode = MxL_MODE_CABLE_PAL_D_SECAM_KL;
793 ota_mode = MxL_MODE_OTA_PAL_D_SECAM_KL;
794 mode_name = "L'";
795 } else {
796 mode_name = "xx";
797 /* FIXME */
798 cbl_mode = MxL_MODE_CABLE_NTSC_PAL_GH;
799 ota_mode = MxL_MODE_OTA_NTSC_PAL_GH;
800 }
801 mxl_debug("setting mxl5007 to system %s", mode_name);
802
803 if (fe->ops.i2c_gate_ctrl)
804 fe->ops.i2c_gate_ctrl(fe, 1);
805
806 mutex_lock(&state->lock);
807
808 ret = mxl5007t_tuner_init(state, cable ? cbl_mode : ota_mode);
809 if (mxl_fail(ret))
810 goto fail;
811
812 ret = mxl5007t_tuner_rf_tune(state, freq, bw);
813 if (mxl_fail(ret))
814 goto fail;
815
816 state->frequency = freq;
817 state->bandwidth = 0;
818fail:
819 mutex_unlock(&state->lock);
820
821 if (fe->ops.i2c_gate_ctrl)
822 fe->ops.i2c_gate_ctrl(fe, 0);
823
824 return ret;
825}
826
827/* ------------------------------------------------------------------------- */
828
829static int mxl5007t_init(struct dvb_frontend *fe)
830{
831 struct mxl5007t_state *state = fe->tuner_priv;
832 int ret;
833 u8 d;
834
835 if (fe->ops.i2c_gate_ctrl)
836 fe->ops.i2c_gate_ctrl(fe, 1);
837
838 ret = mxl5007t_read_reg(state, 0x05, &d);
839 if (mxl_fail(ret))
840 goto fail;
841
842 ret = mxl5007t_write_reg(state, 0x05, d | 0x01);
843 mxl_fail(ret);
844fail:
845 if (fe->ops.i2c_gate_ctrl)
846 fe->ops.i2c_gate_ctrl(fe, 0);
847
848 return ret;
849}
850
851static int mxl5007t_sleep(struct dvb_frontend *fe)
852{
853 struct mxl5007t_state *state = fe->tuner_priv;
854 int ret;
855 u8 d;
856
857 if (fe->ops.i2c_gate_ctrl)
858 fe->ops.i2c_gate_ctrl(fe, 1);
859
860 ret = mxl5007t_read_reg(state, 0x05, &d);
861 if (mxl_fail(ret))
862 goto fail;
863
864 ret = mxl5007t_write_reg(state, 0x05, d & ~0x01);
865 mxl_fail(ret);
866fail:
867 if (fe->ops.i2c_gate_ctrl)
868 fe->ops.i2c_gate_ctrl(fe, 0);
869
870 return ret;
871}
872
873/* ------------------------------------------------------------------------- */
874
875static int mxl5007t_get_frequency(struct dvb_frontend *fe, u32 *frequency)
876{
877 struct mxl5007t_state *state = fe->tuner_priv;
878 *frequency = state->frequency;
879 return 0;
880}
881
882static int mxl5007t_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
883{
884 struct mxl5007t_state *state = fe->tuner_priv;
885 *bandwidth = state->bandwidth;
886 return 0;
887}
888
889static int mxl5007t_release(struct dvb_frontend *fe)
890{
891 struct mxl5007t_state *state = fe->tuner_priv;
892
893 mutex_lock(&mxl5007t_list_mutex);
894
895 if (state)
896 hybrid_tuner_release_state(state);
897
898 mutex_unlock(&mxl5007t_list_mutex);
899
900 fe->tuner_priv = NULL;
901
902 return 0;
903}
904
905/* ------------------------------------------------------------------------- */
906
907static struct dvb_tuner_ops mxl5007t_tuner_ops = {
908 .info = {
909 .name = "MaxLinear MxL5007T",
910 },
911 .init = mxl5007t_init,
912 .sleep = mxl5007t_sleep,
913 .set_params = mxl5007t_set_params,
914 .set_analog_params = mxl5007t_set_analog_params,
915 .get_status = mxl5007t_get_status,
916 .get_frequency = mxl5007t_get_frequency,
917 .get_bandwidth = mxl5007t_get_bandwidth,
918 .release = mxl5007t_release,
919};
920
921static int mxl5007t_get_chip_id(struct mxl5007t_state *state)
922{
923 char *name;
924 int ret;
925 u8 id;
926
927 ret = mxl5007t_read_reg(state, 0xd3, &id);
928 if (mxl_fail(ret))
929 goto fail;
930
931 switch (id) {
932 case MxL_5007_V1_F1:
933 name = "MxL5007.v1.f1";
934 break;
935 case MxL_5007_V1_F2:
936 name = "MxL5007.v1.f2";
937 break;
938 case MxL_5007_V2_100_F1:
939 name = "MxL5007.v2.100.f1";
940 break;
941 case MxL_5007_V2_100_F2:
942 name = "MxL5007.v2.100.f2";
943 break;
944 case MxL_5007_V2_200_F1:
945 name = "MxL5007.v2.200.f1";
946 break;
947 case MxL_5007_V2_200_F2:
948 name = "MxL5007.v2.200.f2";
949 break;
950 default:
951 name = "MxL5007T";
952 id = MxL_UNKNOWN_ID;
953 }
954 state->chip_id = id;
955 mxl_info("%s detected @ %d-%04x", name,
956 i2c_adapter_id(state->i2c_props.adap),
957 state->i2c_props.addr);
958 return 0;
959fail:
960 mxl_warn("unable to identify device @ %d-%04x",
961 i2c_adapter_id(state->i2c_props.adap),
962 state->i2c_props.addr);
963
964 state->chip_id = MxL_UNKNOWN_ID;
965 return ret;
966}
967
968struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,
969 struct i2c_adapter *i2c, u8 addr,
970 struct mxl5007t_config *cfg)
971{
972 struct mxl5007t_state *state = NULL;
973 int instance, ret;
974
975 mutex_lock(&mxl5007t_list_mutex);
976 instance = hybrid_tuner_request_state(struct mxl5007t_state, state,
977 hybrid_tuner_instance_list,
978 i2c, addr, "mxl5007");
979 switch (instance) {
980 case 0:
981 goto fail;
982 break;
983 case 1:
984 /* new tuner instance */
985 state->config = cfg;
986
987 mutex_init(&state->lock);
988
989 if (fe->ops.i2c_gate_ctrl)
990 fe->ops.i2c_gate_ctrl(fe, 1);
991
992 ret = mxl5007t_get_chip_id(state);
993
994 if (fe->ops.i2c_gate_ctrl)
995 fe->ops.i2c_gate_ctrl(fe, 0);
996
997 /* check return value of mxl5007t_get_chip_id */
998 if (mxl_fail(ret))
999 goto fail;
1000 break;
1001 default:
1002 /* existing tuner instance */
1003 break;
1004 }
1005 fe->tuner_priv = state;
1006 mutex_unlock(&mxl5007t_list_mutex);
1007
1008 memcpy(&fe->ops.tuner_ops, &mxl5007t_tuner_ops,
1009 sizeof(struct dvb_tuner_ops));
1010
1011 return fe;
1012fail:
1013 mutex_unlock(&mxl5007t_list_mutex);
1014
1015 mxl5007t_release(fe);
1016 return NULL;
1017}
1018EXPORT_SYMBOL_GPL(mxl5007t_attach);
1019MODULE_DESCRIPTION("MaxLinear MxL5007T Silicon IC tuner driver");
1020MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
1021MODULE_LICENSE("GPL");
1022MODULE_VERSION("0.1");
1023
1024/*
1025 * Overrides for Emacs so that we follow Linus's tabbing style.
1026 * ---------------------------------------------------------------------------
1027 * Local variables:
1028 * c-basic-offset: 8
1029 * End:
1030 */
diff --git a/drivers/media/common/tuners/mxl5007t.h b/drivers/media/common/tuners/mxl5007t.h
new file mode 100644
index 000000000000..aa3eea0b5262
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5007t.h
@@ -0,0 +1,104 @@
1/*
2 * mxl5007t.h - driver for the MaxLinear MxL5007T silicon tuner
3 *
4 * Copyright (C) 2008 Michael Krufky <mkrufky@linuxtv.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef __MXL5007T_H__
22#define __MXL5007T_H__
23
24#include "dvb_frontend.h"
25
26/* ------------------------------------------------------------------------- */
27
28enum mxl5007t_if_freq {
29 MxL_IF_4_MHZ, /* 4000000 */
30 MxL_IF_4_5_MHZ, /* 4500000 */
31 MxL_IF_4_57_MHZ, /* 4570000 */
32 MxL_IF_5_MHZ, /* 5000000 */
33 MxL_IF_5_38_MHZ, /* 5380000 */
34 MxL_IF_6_MHZ, /* 6000000 */
35 MxL_IF_6_28_MHZ, /* 6280000 */
36 MxL_IF_9_1915_MHZ, /* 9191500 */
37 MxL_IF_35_25_MHZ, /* 35250000 */
38 MxL_IF_36_15_MHZ, /* 36150000 */
39 MxL_IF_44_MHZ, /* 44000000 */
40};
41
42enum mxl5007t_xtal_freq {
43 MxL_XTAL_16_MHZ, /* 16000000 */
44 MxL_XTAL_20_MHZ, /* 20000000 */
45 MxL_XTAL_20_25_MHZ, /* 20250000 */
46 MxL_XTAL_20_48_MHZ, /* 20480000 */
47 MxL_XTAL_24_MHZ, /* 24000000 */
48 MxL_XTAL_25_MHZ, /* 25000000 */
49 MxL_XTAL_25_14_MHZ, /* 25140000 */
50 MxL_XTAL_27_MHZ, /* 27000000 */
51 MxL_XTAL_28_8_MHZ, /* 28800000 */
52 MxL_XTAL_32_MHZ, /* 32000000 */
53 MxL_XTAL_40_MHZ, /* 40000000 */
54 MxL_XTAL_44_MHZ, /* 44000000 */
55 MxL_XTAL_48_MHZ, /* 48000000 */
56 MxL_XTAL_49_3811_MHZ, /* 49381100 */
57};
58
59enum mxl5007t_clkout_amp {
60 MxL_CLKOUT_AMP_0_94V = 0,
61 MxL_CLKOUT_AMP_0_53V = 1,
62 MxL_CLKOUT_AMP_0_37V = 2,
63 MxL_CLKOUT_AMP_0_28V = 3,
64 MxL_CLKOUT_AMP_0_23V = 4,
65 MxL_CLKOUT_AMP_0_20V = 5,
66 MxL_CLKOUT_AMP_0_17V = 6,
67 MxL_CLKOUT_AMP_0_15V = 7,
68};
69
70struct mxl5007t_config {
71 s32 if_diff_out_level;
72 enum mxl5007t_clkout_amp clk_out_amp;
73 enum mxl5007t_xtal_freq xtal_freq_hz;
74 enum mxl5007t_if_freq if_freq_hz;
75 unsigned int invert_if:1;
76 unsigned int loop_thru_enable:1;
77 unsigned int clk_out_enable:1;
78};
79
80#if defined(CONFIG_MEDIA_TUNER_MXL5007T) || (defined(CONFIG_MEDIA_TUNER_MXL5007T_MODULE) && defined(MODULE))
81extern struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,
82 struct i2c_adapter *i2c, u8 addr,
83 struct mxl5007t_config *cfg);
84#else
85static inline struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,
86 struct i2c_adapter *i2c,
87 u8 addr,
88 struct mxl5007t_config *cfg)
89{
90 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
91 return NULL;
92}
93#endif
94
95#endif /* __MXL5007T_H__ */
96
97/*
98 * Overrides for Emacs so that we follow Linus's tabbing style.
99 * ---------------------------------------------------------------------------
100 * Local variables:
101 * c-basic-offset: 8
102 * End:
103 */
104
diff --git a/drivers/media/common/tuners/tda9887.c b/drivers/media/common/tuners/tda9887.c
index a0545ba957b0..72abf0b73486 100644
--- a/drivers/media/common/tuners/tda9887.c
+++ b/drivers/media/common/tuners/tda9887.c
@@ -6,7 +6,7 @@
6#include <linux/errno.h> 6#include <linux/errno.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/videodev.h> 9#include <linux/videodev2.h>
10#include <media/v4l2-common.h> 10#include <media/v4l2-common.h>
11#include <media/tuner.h> 11#include <media/tuner.h>
12#include "tuner-i2c.h" 12#include "tuner-i2c.h"
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index 266c255cf0d8..597e47f5d69c 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -6,7 +6,7 @@
6 */ 6 */
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/i2c.h> 8#include <linux/i2c.h>
9#include <linux/videodev.h> 9#include <linux/videodev2.h>
10#include <media/tuner.h> 10#include <media/tuner.h>
11#include <media/v4l2-common.h> 11#include <media/v4l2-common.h>
12#include <media/tuner-types.h> 12#include <media/tuner-types.h>
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index 7588db1319d0..7e9c090fc04e 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -1,7 +1,6 @@
1config DVB_BT8XX 1config DVB_BT8XX
2 tristate "BT8xx based PCI cards" 2 tristate "BT8xx based PCI cards"
3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848 3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848
4 depends on HOTPLUG # due to FW_LOADER
5 select DVB_MT352 if !DVB_FE_CUSTOMISE 4 select DVB_MT352 if !DVB_FE_CUSTOMISE
6 select DVB_SP887X if !DVB_FE_CUSTOMISE 5 select DVB_SP887X if !DVB_FE_CUSTOMISE
7 select DVB_NXT6000 if !DVB_FE_CUSTOMISE 6 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
@@ -10,7 +9,6 @@ config DVB_BT8XX
10 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 9 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
11 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 10 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE 11 select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE
13 select FW_LOADER
14 help 12 help
15 Support for PCI cards based on the Bt8xx PCI bridge. Examples are 13 Support for PCI cards based on the Bt8xx PCI bridge. Examples are
16 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards, 14 the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards,
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index a577c0f89f67..e84152b7576d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,8 +1,6 @@
1config DVB_USB 1config DVB_USB
2 tristate "Support for various USB DVB devices" 2 tristate "Support for various USB DVB devices"
3 depends on DVB_CORE && USB && I2C && INPUT 3 depends on DVB_CORE && USB && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER
5 select FW_LOADER
6 help 4 help
7 By enabling this you will be able to choose the various supported 5 By enabling this you will be able to choose the various supported
8 USB1.1 and USB2.0 DVB devices. 6 USB1.1 and USB2.0 DVB devices.
@@ -246,6 +244,14 @@ config DVB_USB_AF9005_REMOTE
246 Say Y here to support the default remote control decoding for the 244 Say Y here to support the default remote control decoding for the
247 Afatech AF9005 based receiver. 245 Afatech AF9005 based receiver.
248 246
247config DVB_USB_DW2102
248 tristate "DvbWorld 2102 DVB-S USB2.0 receiver"
249 depends on DVB_USB
250 select DVB_STV0299 if !DVB_FE_CUSTOMISE
251 select DVB_PLL if !DVB_FE_CUSTOMISE
252 help
253 Say Y here to support the DvbWorld 2102 DVB-S USB2.0 receiver.
254
249config DVB_USB_ANYSEE 255config DVB_USB_ANYSEE
250 tristate "Anysee DVB-T/C USB2.0 support" 256 tristate "Anysee DVB-T/C USB2.0 support"
251 depends on DVB_USB 257 depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 44c11e45e564..e206f1ea0027 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -64,6 +64,9 @@ obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
64dvb-usb-anysee-objs = anysee.o 64dvb-usb-anysee-objs = anysee.o
65obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o 65obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o
66 66
67dvb-usb-dw2102-objs = dw2102.o
68obj-$(CONFIG_DVB_USB_DW2102) += dvb-usb-dw2102.o
69
67EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 70EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
68# due to tuner-xc3028 71# due to tuner-xc3028
69EXTRA_CFLAGS += -Idrivers/media/common/tuners 72EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index adfd4fc82efd..2f408d2e1ef3 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -43,7 +43,7 @@ module_param_named(debug, dvb_usb_anysee_debug, int, 0644);
43MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); 43MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
44DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 44DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
45 45
46struct mutex anysee_usb_mutex; 46static struct mutex anysee_usb_mutex;
47 47
48static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, 48static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen,
49 u8 *rbuf, u8 rlen) 49 u8 *rbuf, u8 rlen)
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index e5238b31e946..029b437caf9a 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -204,5 +204,6 @@
204#define USB_PID_ASUS_U3000 0x171f 204#define USB_PID_ASUS_U3000 0x171f
205#define USB_PID_ASUS_U3100 0x173f 205#define USB_PID_ASUS_U3100 0x173f
206#define USB_PID_YUAN_EC372S 0x1edc 206#define USB_PID_YUAN_EC372S 0x1edc
207#define USB_PID_DW2102 0x2102
207 208
208#endif 209#endif
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
new file mode 100644
index 000000000000..a4d898b44e55
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -0,0 +1,425 @@
1/* DVB USB framework compliant Linux driver for the DVBWorld DVB-S 2102 Card
2*
3* Copyright (C) 2008 Igor M. Liplianin (liplianin@me.by)
4*
5* This program is free software; you can redistribute it and/or modify it
6* under the terms of the GNU General Public License as published by the
7* Free Software Foundation, version 2.
8*
9* see Documentation/dvb/README.dvb-usb for more information
10*/
11#include <linux/version.h>
12#include "dw2102.h"
13#include "stv0299.h"
14#include "z0194a.h"
15
16#ifndef USB_PID_DW2102
17#define USB_PID_DW2102 0x2102
18#endif
19
20#define DW2102_READ_MSG 0
21#define DW2102_WRITE_MSG 1
22
23#define REG_1F_SYMBOLRATE_BYTE0 0x1f
24#define REG_20_SYMBOLRATE_BYTE1 0x20
25#define REG_21_SYMBOLRATE_BYTE2 0x21
26
27#define DW2102_VOLTAGE_CTRL (0x1800)
28#define DW2102_RC_QUERY (0x1a00)
29
30struct dw2102_state {
31 u32 last_key_pressed;
32};
33struct dw2102_rc_keys {
34 u32 keycode;
35 u32 event;
36};
37
38DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
39
40static int dw2102_op_rw(struct usb_device *dev, u8 request, u16 value,
41 u8 *data, u16 len, int flags)
42{
43 int ret;
44 u8 u8buf[len];
45
46 unsigned int pipe = (flags == DW2102_READ_MSG) ?
47 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
48 u8 request_type = (flags == DW2102_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
49
50 if (flags == DW2102_WRITE_MSG)
51 memcpy(u8buf, data, len);
52 ret = usb_control_msg(dev, pipe, request,
53 request_type | USB_TYPE_VENDOR, value, 0 , u8buf, len, 2000);
54
55 if (flags == DW2102_READ_MSG)
56 memcpy(data, u8buf, len);
57 return ret;
58}
59
60/* I2C */
61
62static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
63 int num)
64{
65struct dvb_usb_device *d = i2c_get_adapdata(adap);
66 int i = 0, ret = 0;
67 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
68 u8 request;
69 u16 value;
70
71 if (!d)
72 return -ENODEV;
73 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
74 return -EAGAIN;
75
76 switch (num) {
77 case 2:
78 /* read stv0299 register */
79 request = 0xb5;
80 value = msg[0].buf[0];/* register */
81 for (i = 0; i < msg[1].len; i++) {
82 value = value + i;
83 ret = dw2102_op_rw(d->udev, 0xb5,
84 value, buf6, 2, DW2102_READ_MSG);
85 msg[1].buf[i] = buf6[0];
86
87 }
88 break;
89 case 1:
90 switch (msg[0].addr) {
91 case 0x68:
92 /* write to stv0299 register */
93 buf6[0] = 0x2a;
94 buf6[1] = msg[0].buf[0];
95 buf6[2] = msg[0].buf[1];
96 ret = dw2102_op_rw(d->udev, 0xb2,
97 0, buf6, 3, DW2102_WRITE_MSG);
98 break;
99 case 0x60:
100 if (msg[0].flags == 0) {
101 /* write to tuner pll */
102 buf6[0] = 0x2c;
103 buf6[1] = 5;
104 buf6[2] = 0xc0;
105 buf6[3] = msg[0].buf[0];
106 buf6[4] = msg[0].buf[1];
107 buf6[5] = msg[0].buf[2];
108 buf6[6] = msg[0].buf[3];
109 ret = dw2102_op_rw(d->udev, 0xb2,
110 0, buf6, 7, DW2102_WRITE_MSG);
111 } else {
112 /* write to tuner pll */
113 ret = dw2102_op_rw(d->udev, 0xb5,
114 0, buf6, 1, DW2102_READ_MSG);
115 msg[0].buf[0] = buf6[0];
116 }
117 break;
118 case (DW2102_RC_QUERY):
119 ret = dw2102_op_rw(d->udev, 0xb8,
120 0, buf6, 2, DW2102_READ_MSG);
121 msg[0].buf[0] = buf6[0];
122 msg[0].buf[1] = buf6[1];
123 break;
124 case (DW2102_VOLTAGE_CTRL):
125 buf6[0] = 0x30;
126 buf6[1] = msg[0].buf[0];
127 ret = dw2102_op_rw(d->udev, 0xb2,
128 0, buf6, 2, DW2102_WRITE_MSG);
129 break;
130 }
131
132 break;
133 }
134
135 mutex_unlock(&d->i2c_mutex);
136 return num;
137}
138
139static u32 dw2102_i2c_func(struct i2c_adapter *adapter)
140{
141 return I2C_FUNC_I2C;
142}
143
144static struct i2c_algorithm dw2102_i2c_algo = {
145 .master_xfer = dw2102_i2c_transfer,
146 .functionality = dw2102_i2c_func,
147};
148
149static int dw2102_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
150{
151 static u8 command_13v[1] = {0x00};
152 static u8 command_18v[1] = {0x01};
153 struct i2c_msg msg[] = {
154 {.addr = DW2102_VOLTAGE_CTRL, .flags = 0,
155 .buf = command_13v, .len = 1},
156 };
157
158 struct dvb_usb_adapter *udev_adap =
159 (struct dvb_usb_adapter *)(fe->dvb->priv);
160 if (voltage == SEC_VOLTAGE_18)
161 msg[0].buf = command_18v;
162 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
163 return 0;
164}
165
166static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
167{
168 d->fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
169 &d->dev->i2c_adap);
170 if (d->fe != NULL) {
171 d->fe->ops.set_voltage = dw2102_set_voltage;
172 info("Attached stv0299!\n");
173 return 0;
174 }
175 return -EIO;
176}
177
178static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
179{
180 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
181 &adap->dev->i2c_adap, DVB_PLL_OPERA1);
182 return 0;
183}
184
185static struct dvb_usb_rc_key dw2102_rc_keys[] = {
186 { 0xf8, 0x0a, KEY_Q }, /*power*/
187 { 0xf8, 0x0c, KEY_M }, /*mute*/
188 { 0xf8, 0x11, KEY_1 },
189 { 0xf8, 0x12, KEY_2 },
190 { 0xf8, 0x13, KEY_3 },
191 { 0xf8, 0x14, KEY_4 },
192 { 0xf8, 0x15, KEY_5 },
193 { 0xf8, 0x16, KEY_6 },
194 { 0xf8, 0x17, KEY_7 },
195 { 0xf8, 0x18, KEY_8 },
196 { 0xf8, 0x19, KEY_9 },
197 { 0xf8, 0x10, KEY_0 },
198 { 0xf8, 0x1c, KEY_PAGEUP }, /*ch+*/
199 { 0xf8, 0x0f, KEY_PAGEDOWN }, /*ch-*/
200 { 0xf8, 0x1a, KEY_O }, /*vol+*/
201 { 0xf8, 0x0e, KEY_Z }, /*vol-*/
202 { 0xf8, 0x04, KEY_R }, /*rec*/
203 { 0xf8, 0x09, KEY_D }, /*fav*/
204 { 0xf8, 0x08, KEY_BACKSPACE }, /*rewind*/
205 { 0xf8, 0x07, KEY_A }, /*fast*/
206 { 0xf8, 0x0b, KEY_P }, /*pause*/
207 { 0xf8, 0x02, KEY_ESC }, /*cancel*/
208 { 0xf8, 0x03, KEY_G }, /*tab*/
209 { 0xf8, 0x00, KEY_UP }, /*up*/
210 { 0xf8, 0x1f, KEY_ENTER }, /*ok*/
211 { 0xf8, 0x01, KEY_DOWN }, /*down*/
212 { 0xf8, 0x05, KEY_C }, /*cap*/
213 { 0xf8, 0x06, KEY_S }, /*stop*/
214 { 0xf8, 0x40, KEY_F }, /*full*/
215 { 0xf8, 0x1e, KEY_W }, /*tvmode*/
216 { 0xf8, 0x1b, KEY_B }, /*recall*/
217
218};
219
220
221
222static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
223{
224 struct dw2102_state *st = d->priv;
225 u8 key[2];
226 struct i2c_msg msg[] = {
227 {.addr = DW2102_RC_QUERY, .flags = I2C_M_RD, .buf = key,
228 .len = 2},
229 };
230 int i;
231
232 *state = REMOTE_NO_KEY_PRESSED;
233 if (dw2102_i2c_transfer(&d->i2c_adap, msg, 1) == 1) {
234 for (i = 0; i < ARRAY_SIZE(dw2102_rc_keys); i++) {
235 if (dw2102_rc_keys[i].data == msg[0].buf[0]) {
236 *state = REMOTE_KEY_PRESSED;
237 *event = dw2102_rc_keys[i].event;
238 st->last_key_pressed =
239 dw2102_rc_keys[i].event;
240 break;
241 }
242 st->last_key_pressed = 0;
243 }
244 }
245 /* info("key: %x %x\n",key[0],key[1]); */
246 return 0;
247}
248
249static struct usb_device_id dw2102_table[] = {
250 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
251 {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
252 { }
253};
254
255MODULE_DEVICE_TABLE(usb, dw2102_table);
256
257static int dw2102_load_firmware(struct usb_device *dev,
258 const struct firmware *frmwr)
259{
260 u8 *b, *p;
261 int ret = 0, i;
262 u8 reset;
263 u8 reset16 [] = {0, 0, 0, 0, 0, 0, 0};
264 const struct firmware *fw;
265 const char *filename = "dvb-usb-dw2101.fw";
266 switch (dev->descriptor.idProduct) {
267 case 0x2101:
268 ret = request_firmware(&fw, filename, &dev->dev);
269 if (ret != 0) {
270 err("did not find the firmware file. (%s) "
271 "Please see linux/Documentation/dvb/ for more details "
272 "on firmware-problems.", filename);
273 return ret;
274 }
275 break;
276 case USB_PID_DW2102:
277 fw = frmwr;
278 break;
279 }
280 info("start downloading DW2102 firmware");
281 p = kmalloc(fw->size, GFP_KERNEL);
282 reset = 1;
283 /*stop the CPU*/
284 dw2102_op_rw(dev, 0xa0, 0x7f92, &reset, 1, DW2102_WRITE_MSG);
285 dw2102_op_rw(dev, 0xa0, 0xe600, &reset, 1, DW2102_WRITE_MSG);
286
287 if (p != NULL) {
288 memcpy(p, fw->data, fw->size);
289 for (i = 0; i < fw->size; i += 0x40) {
290 b = (u8 *) p + i;
291 if (dw2102_op_rw
292 (dev, 0xa0, i, b , 0x40,
293 DW2102_WRITE_MSG) != 0x40
294 ) {
295 err("error while transferring firmware");
296 ret = -EINVAL;
297 break;
298 }
299 }
300 /* restart the CPU */
301 reset = 0;
302 if (ret || dw2102_op_rw
303 (dev, 0xa0, 0x7f92, &reset, 1,
304 DW2102_WRITE_MSG) != 1) {
305 err("could not restart the USB controller CPU.");
306 ret = -EINVAL;
307 }
308 if (ret || dw2102_op_rw
309 (dev, 0xa0, 0xe600, &reset, 1,
310 DW2102_WRITE_MSG) != 1) {
311 err("could not restart the USB controller CPU.");
312 ret = -EINVAL;
313 }
314 /* init registers */
315 switch (dev->descriptor.idProduct) {
316 case USB_PID_DW2102:
317 dw2102_op_rw
318 (dev, 0xbf, 0x0040, &reset, 0,
319 DW2102_WRITE_MSG);
320 dw2102_op_rw
321 (dev, 0xb9, 0x0000, &reset16[0], 2,
322 DW2102_READ_MSG);
323 break;
324 case 0x2101:
325 dw2102_op_rw
326 (dev, 0xbc, 0x0030, &reset16[0], 2,
327 DW2102_READ_MSG);
328 dw2102_op_rw
329 (dev, 0xba, 0x0000, &reset16[0], 7,
330 DW2102_READ_MSG);
331 dw2102_op_rw
332 (dev, 0xba, 0x0000, &reset16[0], 7,
333 DW2102_READ_MSG);
334 dw2102_op_rw
335 (dev, 0xb9, 0x0000, &reset16[0], 2,
336 DW2102_READ_MSG);
337 break;
338 }
339 kfree(p);
340 }
341 return ret;
342}
343
344static struct dvb_usb_device_properties dw2102_properties = {
345 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
346 .usb_ctrl = DEVICE_SPECIFIC,
347 .firmware = "dvb-usb-dw2102.fw",
348 .size_of_priv = sizeof(struct dw2102_state),
349 .no_reconnect = 1,
350
351 .i2c_algo = &dw2102_i2c_algo,
352 .rc_key_map = dw2102_rc_keys,
353 .rc_key_map_size = ARRAY_SIZE(dw2102_rc_keys),
354 .rc_interval = 150,
355 .rc_query = dw2102_rc_query,
356
357 .generic_bulk_ctrl_endpoint = 0x81,
358 /* parameter for the MPEG2-data transfer */
359 .num_adapters = 1,
360 .download_firmware = dw2102_load_firmware,
361 .adapter = {
362 {
363 .frontend_attach = dw2102_frontend_attach,
364 .streaming_ctrl = NULL,
365 .tuner_attach = dw2102_tuner_attach,
366 .stream = {
367 .type = USB_BULK,
368 .count = 8,
369 .endpoint = 0x82,
370 .u = {
371 .bulk = {
372 .buffersize = 4096,
373 }
374 }
375 },
376 }
377 },
378 .num_device_descs = 2,
379 .devices = {
380 {"DVBWorld DVB-S 2102 USB2.0",
381 {&dw2102_table[0], NULL},
382 {NULL},
383 },
384 {"DVBWorld DVB-S 2101 USB2.0",
385 {&dw2102_table[1], NULL},
386 {NULL},
387 },
388 }
389};
390
391static int dw2102_probe(struct usb_interface *intf,
392 const struct usb_device_id *id)
393{
394 return dvb_usb_device_init(intf, &dw2102_properties,
395 THIS_MODULE, NULL, adapter_nr);
396}
397
398static struct usb_driver dw2102_driver = {
399 .name = "dw2102",
400 .probe = dw2102_probe,
401 .disconnect = dvb_usb_device_exit,
402 .id_table = dw2102_table,
403};
404
405static int __init dw2102_module_init(void)
406{
407 int ret = usb_register(&dw2102_driver);
408 if (ret)
409 err("usb_register failed. Error number %d", ret);
410
411 return ret;
412}
413
414static void __exit dw2102_module_exit(void)
415{
416 usb_deregister(&dw2102_driver);
417}
418
419module_init(dw2102_module_init);
420module_exit(dw2102_module_exit);
421
422MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
423MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101 2102 USB2.0 device");
424MODULE_VERSION("0.1");
425MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dw2102.h b/drivers/media/dvb/dvb-usb/dw2102.h
new file mode 100644
index 000000000000..7a310f906837
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dw2102.h
@@ -0,0 +1,9 @@
1#ifndef _DW2102_H_
2#define _DW2102_H_
3
4#define DVB_USB_LOG_PREFIX "dw2102"
5#include "dvb-usb.h"
6
7extern int dvb_usb_dw2102_debug;
8#define deb_xfer(args...) dprintk(dvb_usb_dw2102_debug, 0x02, args)
9#endif
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index c20553c4da1f..574dffe91b68 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -97,9 +97,8 @@ comment "DVB-T (terrestrial) frontends"
97 97
98config DVB_SP8870 98config DVB_SP8870
99 tristate "Spase sp8870 based" 99 tristate "Spase sp8870 based"
100 depends on DVB_CORE && I2C && HOTPLUG 100 depends on DVB_CORE && I2C
101 default m if DVB_FE_CUSTOMISE 101 default m if DVB_FE_CUSTOMISE
102 select FW_LOADER
103 help 102 help
104 A DVB-T tuner module. Say Y when you want to support this frontend. 103 A DVB-T tuner module. Say Y when you want to support this frontend.
105 104
@@ -110,9 +109,8 @@ config DVB_SP8870
110 109
111config DVB_SP887X 110config DVB_SP887X
112 tristate "Spase sp887x based" 111 tristate "Spase sp887x based"
113 depends on DVB_CORE && I2C && HOTPLUG 112 depends on DVB_CORE && I2C
114 default m if DVB_FE_CUSTOMISE 113 default m if DVB_FE_CUSTOMISE
115 select FW_LOADER
116 help 114 help
117 A DVB-T tuner module. Say Y when you want to support this frontend. 115 A DVB-T tuner module. Say Y when you want to support this frontend.
118 116
@@ -135,6 +133,20 @@ config DVB_CX22702
135 help 133 help
136 A DVB-T tuner module. Say Y when you want to support this frontend. 134 A DVB-T tuner module. Say Y when you want to support this frontend.
137 135
136config DVB_DRX397XD
137 tristate "Micronas DRX3975D/DRX3977D based"
138 depends on DVB_CORE && I2C && HOTPLUG
139 default m if DVB_FE_CUSTOMISE
140 select FW_LOADER
141 help
142 A DVB-T tuner module. Say Y when you want to support this frontend.
143
144 TODO:
145 This driver needs external firmware. Please use the command
146 "<kerneldir>/Documentation/dvb/get_dvb_firmware drx397xD" to
147 download/extract them, and then copy them to /usr/lib/hotplug/firmware
148 or /lib/firmware (depending on configuration of firmware hotplug).
149
138config DVB_L64781 150config DVB_L64781
139 tristate "LSI L64781" 151 tristate "LSI L64781"
140 depends on DVB_CORE && I2C 152 depends on DVB_CORE && I2C
@@ -144,9 +156,8 @@ config DVB_L64781
144 156
145config DVB_TDA1004X 157config DVB_TDA1004X
146 tristate "Philips TDA10045H/TDA10046H based" 158 tristate "Philips TDA10045H/TDA10046H based"
147 depends on DVB_CORE && I2C && HOTPLUG 159 depends on DVB_CORE && I2C
148 default m if DVB_FE_CUSTOMISE 160 default m if DVB_FE_CUSTOMISE
149 select FW_LOADER
150 help 161 help
151 A DVB-T tuner module. Say Y when you want to support this frontend. 162 A DVB-T tuner module. Say Y when you want to support this frontend.
152 163
@@ -211,9 +222,8 @@ config DVB_DIB7000P
211 222
212config DVB_TDA10048 223config DVB_TDA10048
213 tristate "Philips TDA10048HN based" 224 tristate "Philips TDA10048HN based"
214 depends on DVB_CORE && I2C && HOTPLUG 225 depends on DVB_CORE && I2C
215 default m if DVB_FE_CUSTOMISE 226 default m if DVB_FE_CUSTOMISE
216 select FW_LOADER
217 help 227 help
218 A DVB-T tuner module. Say Y when you want to support this frontend. 228 A DVB-T tuner module. Say Y when you want to support this frontend.
219 229
@@ -253,9 +263,8 @@ comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends"
253 263
254config DVB_NXT200X 264config DVB_NXT200X
255 tristate "NxtWave Communications NXT2002/NXT2004 based" 265 tristate "NxtWave Communications NXT2002/NXT2004 based"
256 depends on DVB_CORE && I2C && HOTPLUG 266 depends on DVB_CORE && I2C
257 default m if DVB_FE_CUSTOMISE 267 default m if DVB_FE_CUSTOMISE
258 select FW_LOADER
259 help 268 help
260 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 269 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
261 to support this frontend. 270 to support this frontend.
@@ -268,9 +277,8 @@ config DVB_NXT200X
268 277
269config DVB_OR51211 278config DVB_OR51211
270 tristate "Oren OR51211 based" 279 tristate "Oren OR51211 based"
271 depends on DVB_CORE && I2C && HOTPLUG 280 depends on DVB_CORE && I2C
272 default m if DVB_FE_CUSTOMISE 281 default m if DVB_FE_CUSTOMISE
273 select FW_LOADER
274 help 282 help
275 An ATSC 8VSB tuner module. Say Y when you want to support this frontend. 283 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
276 284
@@ -281,9 +289,8 @@ config DVB_OR51211
281 289
282config DVB_OR51132 290config DVB_OR51132
283 tristate "Oren OR51132 based" 291 tristate "Oren OR51132 based"
284 depends on DVB_CORE && I2C && HOTPLUG 292 depends on DVB_CORE && I2C
285 default m if DVB_FE_CUSTOMISE 293 default m if DVB_FE_CUSTOMISE
286 select FW_LOADER
287 help 294 help
288 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 295 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
289 to support this frontend. 296 to support this frontend.
@@ -297,9 +304,8 @@ config DVB_OR51132
297 304
298config DVB_BCM3510 305config DVB_BCM3510
299 tristate "Broadcom BCM3510" 306 tristate "Broadcom BCM3510"
300 depends on DVB_CORE && I2C && HOTPLUG 307 depends on DVB_CORE && I2C
301 default m if DVB_FE_CUSTOMISE 308 default m if DVB_FE_CUSTOMISE
302 select FW_LOADER
303 help 309 help
304 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to 310 An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to
305 support this frontend. 311 support this frontend.
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index a89dc0fc4c6f..028da55611c0 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
25obj-$(CONFIG_DVB_MT352) += mt352.o 25obj-$(CONFIG_DVB_MT352) += mt352.o
26obj-$(CONFIG_DVB_ZL10353) += zl10353.o 26obj-$(CONFIG_DVB_ZL10353) += zl10353.o
27obj-$(CONFIG_DVB_CX22702) += cx22702.o 27obj-$(CONFIG_DVB_CX22702) += cx22702.o
28obj-$(CONFIG_DVB_DRX397XD) += drx397xD.o
28obj-$(CONFIG_DVB_TDA10021) += tda10021.o 29obj-$(CONFIG_DVB_TDA10021) += tda10021.o
29obj-$(CONFIG_DVB_TDA10023) += tda10023.o 30obj-$(CONFIG_DVB_TDA10023) += tda10023.o
30obj-$(CONFIG_DVB_STV0297) += stv0297.o 31obj-$(CONFIG_DVB_STV0297) += stv0297.o
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
new file mode 100644
index 000000000000..3cbed874a6f8
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -0,0 +1,1504 @@
1/*
2 * Driver for Micronas drx397xD demodulator
3 *
4 * Copyright (C) 2007 Henk Vergonet <Henk.Vergonet@gmail.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, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#define DEBUG /* uncomment if you want debugging output */
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/moduleparam.h>
24#include <linux/init.h>
25#include <linux/device.h>
26#include <linux/delay.h>
27#include <linux/string.h>
28#include <linux/firmware.h>
29#include <asm/div64.h>
30
31#include "dvb_frontend.h"
32#include "drx397xD.h"
33
34static const char mod_name[] = "drx397xD";
35
36#define MAX_CLOCK_DRIFT 200 /* maximal 200 PPM allowed */
37
38#define F_SET_0D0h 1
39#define F_SET_0D4h 2
40
41typedef enum fw_ix {
42#define _FW_ENTRY(a, b) b
43#include "drx397xD_fw.h"
44} fw_ix_t;
45
46/* chip specifics */
47struct drx397xD_state {
48 struct i2c_adapter *i2c;
49 struct dvb_frontend frontend;
50 struct drx397xD_config config;
51 fw_ix_t chip_rev;
52 int flags;
53 u32 bandwidth_parm; /* internal bandwidth conversions */
54 u32 f_osc; /* w90: actual osc frequency [Hz] */
55};
56
57/*******************************************************************************
58 * Firmware
59 ******************************************************************************/
60
61static const char *blob_name[] = {
62#define _BLOB_ENTRY(a, b) a
63#include "drx397xD_fw.h"
64};
65
66typedef enum blob_ix {
67#define _BLOB_ENTRY(a, b) b
68#include "drx397xD_fw.h"
69} blob_ix_t;
70
71static struct {
72 const char *name;
73 const struct firmware *file;
74 rwlock_t lock;
75 int refcnt;
76 const u8 *data[ARRAY_SIZE(blob_name)];
77} fw[] = {
78#define _FW_ENTRY(a, b) { \
79 .name = a, \
80 .file = 0, \
81 .lock = RW_LOCK_UNLOCKED, \
82 .refcnt = 0, \
83 .data = { } }
84#include "drx397xD_fw.h"
85};
86
87/* use only with writer lock aquired */
88static void _drx_release_fw(struct drx397xD_state *s, fw_ix_t ix)
89{
90 memset(&fw[ix].data[0], 0, sizeof(fw[0].data));
91 if (fw[ix].file)
92 release_firmware(fw[ix].file);
93}
94
95static void drx_release_fw(struct drx397xD_state *s)
96{
97 fw_ix_t ix = s->chip_rev;
98
99 pr_debug("%s\n", __FUNCTION__);
100
101 write_lock(&fw[ix].lock);
102 if (fw[ix].refcnt) {
103 fw[ix].refcnt--;
104 if (fw[ix].refcnt == 0)
105 _drx_release_fw(s, ix);
106 }
107 write_unlock(&fw[ix].lock);
108}
109
110static int drx_load_fw(struct drx397xD_state *s, fw_ix_t ix)
111{
112 const u8 *data;
113 size_t size, len;
114 int i = 0, j, rc = -EINVAL;
115
116 pr_debug("%s\n", __FUNCTION__);
117
118 if (ix < 0 || ix >= ARRAY_SIZE(fw))
119 return -EINVAL;
120 s->chip_rev = ix;
121
122 write_lock(&fw[ix].lock);
123 if (fw[ix].file) {
124 rc = 0;
125 goto exit_ok;
126 }
127 memset(&fw[ix].data[0], 0, sizeof(fw[0].data));
128
129 if (request_firmware(&fw[ix].file, fw[ix].name, &s->i2c->dev) != 0) {
130 printk(KERN_ERR "%s: Firmware \"%s\" not available\n",
131 mod_name, fw[ix].name);
132 rc = -ENOENT;
133 goto exit_err;
134 }
135
136 if (!fw[ix].file->data || fw[ix].file->size < 10)
137 goto exit_corrupt;
138
139 data = fw[ix].file->data;
140 size = fw[ix].file->size;
141
142 if (data[i++] != 2) /* check firmware version */
143 goto exit_corrupt;
144
145 do {
146 switch (data[i++]) {
147 case 0x00: /* bytecode */
148 if (i >= size)
149 break;
150 i += data[i];
151 case 0x01: /* reset */
152 case 0x02: /* sleep */
153 i++;
154 break;
155 case 0xfe: /* name */
156 len = strnlen(&data[i], size - i);
157 if (i + len + 1 >= size)
158 goto exit_corrupt;
159 if (data[i + len + 1] != 0)
160 goto exit_corrupt;
161 for (j = 0; j < ARRAY_SIZE(blob_name); j++) {
162 if (strcmp(blob_name[j], &data[i]) == 0) {
163 fw[ix].data[j] = &data[i + len + 1];
164 pr_debug("Loading %s\n", blob_name[j]);
165 }
166 }
167 i += len + 1;
168 break;
169 case 0xff: /* file terminator */
170 if (i == size) {
171 rc = 0;
172 goto exit_ok;
173 }
174 default:
175 goto exit_corrupt;
176 }
177 } while (i < size);
178 exit_corrupt:
179 printk(KERN_ERR "%s: Firmware is corrupt\n", mod_name);
180 exit_err:
181 _drx_release_fw(s, ix);
182 fw[ix].refcnt--;
183 exit_ok:
184 fw[ix].refcnt++;
185 write_unlock(&fw[ix].lock);
186 return rc;
187}
188
189/*******************************************************************************
190 * i2c bus IO
191 ******************************************************************************/
192
193static int write_fw(struct drx397xD_state *s, blob_ix_t ix)
194{
195 struct i2c_msg msg = {.addr = s->config.demod_address,.flags = 0 };
196 const u8 *data;
197 int len, rc = 0, i = 0;
198
199 if (ix < 0 || ix >= ARRAY_SIZE(blob_name)) {
200 pr_debug("%s drx_fw_ix_t out of range\n", __FUNCTION__);
201 return -EINVAL;
202 }
203 pr_debug("%s %s\n", __FUNCTION__, blob_name[ix]);
204
205 read_lock(&fw[s->chip_rev].lock);
206 data = fw[s->chip_rev].data[ix];
207 if (!data) {
208 rc = -EINVAL;
209 goto exit_rc;
210 }
211
212 for (;;) {
213 switch (data[i++]) {
214 case 0: /* bytecode */
215 len = data[i++];
216 msg.len = len;
217 msg.buf = (__u8 *) &data[i];
218 if (i2c_transfer(s->i2c, &msg, 1) != 1) {
219 rc = -EIO;
220 goto exit_rc;
221 }
222 i += len;
223 break;
224 case 1: /* reset */
225 case 2: /* sleep */
226 i++;
227 break;
228 default:
229 goto exit_rc;
230 }
231 }
232 exit_rc:
233 read_unlock(&fw[s->chip_rev].lock);
234 return 0;
235}
236
237/* Function is not endian safe, use the RD16 wrapper below */
238static int _read16(struct drx397xD_state *s, u32 i2c_adr)
239{
240 int rc;
241 u8 a[4];
242 u16 v;
243 struct i2c_msg msg[2] = {
244 {
245 .addr = s->config.demod_address,
246 .flags = 0,
247 .buf = a,
248 .len = sizeof(a)
249 }
250 , {
251 .addr = s->config.demod_address,
252 .flags = I2C_M_RD,
253 .buf = (u8 *) & v,
254 .len = sizeof(v)
255 }
256 };
257
258 *(u32 *) a = i2c_adr;
259
260 rc = i2c_transfer(s->i2c, msg, 2);
261 if (rc != 2)
262 return -EIO;
263
264 return le16_to_cpu(v);
265}
266
267/* Function is not endian safe, use the WR16.. wrappers below */
268static int _write16(struct drx397xD_state *s, u32 i2c_adr, u16 val)
269{
270 u8 a[6];
271 int rc;
272 struct i2c_msg msg = {
273 .addr = s->config.demod_address,
274 .flags = 0,
275 .buf = a,
276 .len = sizeof(a)
277 };
278
279 *(u32 *) a = i2c_adr;
280 *(u16 *) & a[4] = val;
281
282 rc = i2c_transfer(s->i2c, &msg, 1);
283 if (rc != 1)
284 return -EIO;
285 return 0;
286}
287
288#define WR16(ss,adr, val) \
289 _write16(ss, I2C_ADR_C0(adr), cpu_to_le16(val))
290#define WR16_E0(ss,adr, val) \
291 _write16(ss, I2C_ADR_E0(adr), cpu_to_le16(val))
292#define RD16(ss,adr) \
293 _read16(ss, I2C_ADR_C0(adr))
294
295#define EXIT_RC( cmd ) if ( (rc = (cmd)) < 0) goto exit_rc
296
297/*******************************************************************************
298 * Tuner callback
299 ******************************************************************************/
300
301static int PLL_Set(struct drx397xD_state *s,
302 struct dvb_frontend_parameters *fep, int *df_tuner)
303{
304 struct dvb_frontend *fe = &s->frontend;
305 u32 f_tuner, f = fep->frequency;
306 int rc;
307
308 pr_debug("%s\n", __FUNCTION__);
309
310 if ((f > s->frontend.ops.tuner_ops.info.frequency_max) ||
311 (f < s->frontend.ops.tuner_ops.info.frequency_min))
312 return -EINVAL;
313
314 *df_tuner = 0;
315 if (!s->frontend.ops.tuner_ops.set_params ||
316 !s->frontend.ops.tuner_ops.get_frequency)
317 return -ENOSYS;
318
319 rc = s->frontend.ops.tuner_ops.set_params(fe, fep);
320 if (rc < 0)
321 return rc;
322
323 rc = s->frontend.ops.tuner_ops.get_frequency(fe, &f_tuner);
324 if (rc < 0)
325 return rc;
326
327 *df_tuner = f_tuner - f;
328 pr_debug("%s requested %d [Hz] tuner %d [Hz]\n", __FUNCTION__, f,
329 f_tuner);
330
331 return 0;
332}
333
334/*******************************************************************************
335 * Demodulator helper functions
336 ******************************************************************************/
337
338static int SC_WaitForReady(struct drx397xD_state *s)
339{
340 int cnt = 1000;
341 int rc;
342
343 pr_debug("%s\n", __FUNCTION__);
344
345 while (cnt--) {
346 rc = RD16(s, 0x820043);
347 if (rc == 0)
348 return 0;
349 }
350 return -1;
351}
352
353static int SC_SendCommand(struct drx397xD_state *s, int cmd)
354{
355 int rc;
356
357 pr_debug("%s\n", __FUNCTION__);
358
359 WR16(s, 0x820043, cmd);
360 SC_WaitForReady(s);
361 rc = RD16(s, 0x820042);
362 if ((rc & 0xffff) == 0xffff)
363 return -1;
364 return 0;
365}
366
367static int HI_Command(struct drx397xD_state *s, u16 cmd)
368{
369 int rc, cnt = 1000;
370
371 pr_debug("%s\n", __FUNCTION__);
372
373 rc = WR16(s, 0x420032, cmd);
374 if (rc < 0)
375 return rc;
376
377 do {
378 rc = RD16(s, 0x420032);
379 if (rc == 0) {
380 rc = RD16(s, 0x420031);
381 return rc;
382 }
383 if (rc < 0)
384 return rc;
385 } while (--cnt);
386 return rc;
387}
388
389static int HI_CfgCommand(struct drx397xD_state *s)
390{
391
392 pr_debug("%s\n", __FUNCTION__);
393
394 WR16(s, 0x420033, 0x3973);
395 WR16(s, 0x420034, s->config.w50); // code 4, log 4
396 WR16(s, 0x420035, s->config.w52); // code 15, log 9
397 WR16(s, 0x420036, s->config.demod_address << 1);
398 WR16(s, 0x420037, s->config.w56); // code (set_i2c ?? initX 1 ), log 1
399// WR16(s, 0x420033, 0x3973);
400 if ((s->config.w56 & 8) == 0)
401 return HI_Command(s, 3);
402 return WR16(s, 0x420032, 0x3);
403}
404
405static const u8 fastIncrDecLUT_15273[] = {
406 0x0e, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x12, 0x13, 0x14,
407 0x15, 0x16, 0x17, 0x18, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f
408};
409
410static const u8 slowIncrDecLUT_15272[] = {
411 3, 4, 4, 5, 6
412};
413
414static int SetCfgIfAgc(struct drx397xD_state *s, struct drx397xD_CfgIfAgc *agc)
415{
416 u16 w06 = agc->w06;
417 u16 w08 = agc->w08;
418 u16 w0A = agc->w0A;
419 u16 w0C = agc->w0C;
420 int quot, rem, i, rc = -EINVAL;
421
422 pr_debug("%s\n", __FUNCTION__);
423
424 if (agc->w04 > 0x3ff)
425 goto exit_rc;
426
427 if (agc->d00 == 1) {
428 EXIT_RC(RD16(s, 0x0c20010));
429 rc &= ~0x10;
430 EXIT_RC(WR16(s, 0x0c20010, rc));
431 return WR16(s, 0x0c20030, agc->w04 & 0x7ff);
432 }
433
434 if (agc->d00 != 0)
435 goto exit_rc;
436 if (w0A < w08)
437 goto exit_rc;
438 if (w0A > 0x3ff)
439 goto exit_rc;
440 if (w0C > 0x3ff)
441 goto exit_rc;
442 if (w06 > 0x3ff)
443 goto exit_rc;
444
445 EXIT_RC(RD16(s, 0x0c20010));
446 rc |= 0x10;
447 EXIT_RC(WR16(s, 0x0c20010, rc));
448
449 EXIT_RC(WR16(s, 0x0c20025, (w06 >> 1) & 0x1ff));
450 EXIT_RC(WR16(s, 0x0c20031, (w0A - w08) >> 1));
451 EXIT_RC(WR16(s, 0x0c20032, ((w0A + w08) >> 1) - 0x1ff));
452
453 quot = w0C / 113;
454 rem = w0C % 113;
455 if (quot <= 8) {
456 quot = 8 - quot;
457 } else {
458 quot = 0;
459 rem += 113;
460 }
461
462 EXIT_RC(WR16(s, 0x0c20024, quot));
463
464 i = fastIncrDecLUT_15273[rem / 8];
465 EXIT_RC(WR16(s, 0x0c2002d, i));
466 EXIT_RC(WR16(s, 0x0c2002e, i));
467
468 i = slowIncrDecLUT_15272[rem / 28];
469 EXIT_RC(WR16(s, 0x0c2002b, i));
470 rc = WR16(s, 0x0c2002c, i);
471 exit_rc:
472 return rc;
473}
474
475static int SetCfgRfAgc(struct drx397xD_state *s, struct drx397xD_CfgRfAgc *agc)
476{
477 u16 w04 = agc->w04;
478 u16 w06 = agc->w06;
479 int rc = -1;
480
481 pr_debug("%s %d 0x%x 0x%x\n", __FUNCTION__, agc->d00, w04, w06);
482
483 if (w04 > 0x3ff)
484 goto exit_rc;
485
486 switch (agc->d00) {
487 case 1:
488 if (w04 == 0x3ff)
489 w04 = 0x400;
490
491 EXIT_RC(WR16(s, 0x0c20036, w04));
492 s->config.w9C &= ~2;
493 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
494 EXIT_RC(RD16(s, 0x0c20010));
495 rc &= 0xbfdf;
496 EXIT_RC(WR16(s, 0x0c20010, rc));
497 EXIT_RC(RD16(s, 0x0c20013));
498 rc &= ~2;
499 break;
500 case 0:
501 // loc_8000659
502 s->config.w9C &= ~2;
503 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
504 EXIT_RC(RD16(s, 0x0c20010));
505 rc &= 0xbfdf;
506 rc |= 0x4000;
507 EXIT_RC(WR16(s, 0x0c20010, rc));
508 EXIT_RC(WR16(s, 0x0c20051, (w06 >> 4) & 0x3f));
509 EXIT_RC(RD16(s, 0x0c20013));
510 rc &= ~2;
511 break;
512 default:
513 s->config.w9C |= 2;
514 EXIT_RC(WR16(s, 0x0c20015, s->config.w9C));
515 EXIT_RC(RD16(s, 0x0c20010));
516 rc &= 0xbfdf;
517 EXIT_RC(WR16(s, 0x0c20010, rc));
518
519 EXIT_RC(WR16(s, 0x0c20036, 0));
520
521 EXIT_RC(RD16(s, 0x0c20013));
522 rc |= 2;
523 }
524 rc = WR16(s, 0x0c20013, rc);
525 exit_rc:
526 return rc;
527}
528
529static int GetLockStatus(struct drx397xD_state *s, int *lockstat)
530{
531 int rc;
532
533 *lockstat = 0;
534
535 rc = RD16(s, 0x082004b);
536 if (rc < 0)
537 return rc;
538
539 if (s->config.d60 != 2)
540 return 0;
541
542 if ((rc & 7) == 7)
543 *lockstat |= 1;
544 if ((rc & 3) == 3)
545 *lockstat |= 2;
546 if (rc & 1)
547 *lockstat |= 4;
548 return 0;
549}
550
551static int CorrectSysClockDeviation(struct drx397xD_state *s)
552{
553 int rc = -EINVAL;
554 int lockstat;
555 u32 clk, clk_limit;
556
557 pr_debug("%s\n", __FUNCTION__);
558
559 if (s->config.d5C == 0) {
560 EXIT_RC(WR16(s, 0x08200e8, 0x010));
561 EXIT_RC(WR16(s, 0x08200e9, 0x113));
562 s->config.d5C = 1;
563 return rc;
564 }
565 if (s->config.d5C != 1)
566 goto exit_rc;
567
568 rc = RD16(s, 0x0820048);
569
570 rc = GetLockStatus(s, &lockstat);
571 if (rc < 0)
572 goto exit_rc;
573 if ((lockstat & 1) == 0)
574 goto exit_rc;
575
576 EXIT_RC(WR16(s, 0x0420033, 0x200));
577 EXIT_RC(WR16(s, 0x0420034, 0xc5));
578 EXIT_RC(WR16(s, 0x0420035, 0x10));
579 EXIT_RC(WR16(s, 0x0420036, 0x1));
580 EXIT_RC(WR16(s, 0x0420037, 0xa));
581 EXIT_RC(HI_Command(s, 6));
582 EXIT_RC(RD16(s, 0x0420040));
583 clk = rc;
584 EXIT_RC(RD16(s, 0x0420041));
585 clk |= rc << 16;
586
587 if (clk <= 0x26ffff)
588 goto exit_rc;
589 if (clk > 0x610000)
590 goto exit_rc;
591
592 if (!s->bandwidth_parm)
593 return -EINVAL;
594
595 /* round & convert to Hz */
596 clk = ((u64) (clk + 0x800000) * s->bandwidth_parm + (1 << 20)) >> 21;
597 clk_limit = s->config.f_osc * MAX_CLOCK_DRIFT / 1000;
598
599 if (clk - s->config.f_osc * 1000 + clk_limit <= 2 * clk_limit) {
600 s->f_osc = clk;
601 pr_debug("%s: osc %d %d [Hz]\n", __FUNCTION__,
602 s->config.f_osc * 1000, clk - s->config.f_osc * 1000);
603 }
604 rc = WR16(s, 0x08200e8, 0);
605 exit_rc:
606 return rc;
607}
608
609static int ConfigureMPEGOutput(struct drx397xD_state *s, int type)
610{
611 int rc, si, bp;
612
613 pr_debug("%s\n", __FUNCTION__);
614
615 si = s->config.wA0;
616 if (s->config.w98 == 0) {
617 si |= 1;
618 bp = 0;
619 } else {
620 si &= ~1;
621 bp = 0x200;
622 }
623 if (s->config.w9A == 0) {
624 si |= 0x80;
625 } else {
626 si &= ~0x80;
627 }
628
629 EXIT_RC(WR16(s, 0x2150045, 0));
630 EXIT_RC(WR16(s, 0x2150010, si));
631 EXIT_RC(WR16(s, 0x2150011, bp));
632 rc = WR16(s, 0x2150012, (type == 0 ? 0xfff : 0));
633 exit_rc:
634 return rc;
635}
636
637static int drx_tune(struct drx397xD_state *s,
638 struct dvb_frontend_parameters *fep)
639{
640 u16 v22 = 0;
641 u16 v1C = 0;
642 u16 v1A = 0;
643 u16 v18 = 0;
644 u32 edi = 0, ebx = 0, ebp = 0, edx = 0;
645 u16 v20 = 0, v1E = 0, v16 = 0, v14 = 0, v12 = 0, v10 = 0, v0E = 0;
646
647 int rc, df_tuner;
648 int a, b, c, d;
649 pr_debug("%s %d\n", __FUNCTION__, s->config.d60);
650
651 if (s->config.d60 != 2)
652 goto set_tuner;
653 rc = CorrectSysClockDeviation(s);
654 if (rc < 0)
655 goto set_tuner;
656
657 s->config.d60 = 1;
658 rc = ConfigureMPEGOutput(s, 0);
659 if (rc < 0)
660 goto set_tuner;
661 set_tuner:
662
663 rc = PLL_Set(s, fep, &df_tuner);
664 if (rc < 0) {
665 printk(KERN_ERR "Error in pll_set\n");
666 goto exit_rc;
667 }
668 msleep(200);
669
670 a = rc = RD16(s, 0x2150016);
671 if (rc < 0)
672 goto exit_rc;
673 b = rc = RD16(s, 0x2150010);
674 if (rc < 0)
675 goto exit_rc;
676 c = rc = RD16(s, 0x2150034);
677 if (rc < 0)
678 goto exit_rc;
679 d = rc = RD16(s, 0x2150035);
680 if (rc < 0)
681 goto exit_rc;
682 rc = WR16(s, 0x2150014, c);
683 rc = WR16(s, 0x2150015, d);
684 rc = WR16(s, 0x2150010, 0);
685 rc = WR16(s, 0x2150000, 2);
686 rc = WR16(s, 0x2150036, 0x0fff);
687 rc = WR16(s, 0x2150016, a);
688
689 rc = WR16(s, 0x2150010, 2);
690 rc = WR16(s, 0x2150007, 0);
691 rc = WR16(s, 0x2150000, 1);
692 rc = WR16(s, 0x2110000, 0);
693 rc = WR16(s, 0x0800000, 0);
694 rc = WR16(s, 0x2800000, 0);
695 rc = WR16(s, 0x2110010, 0x664);
696
697 rc = write_fw(s, DRXD_ResetECRAM);
698 rc = WR16(s, 0x2110000, 1);
699
700 rc = write_fw(s, DRXD_InitSC);
701 if (rc < 0)
702 goto exit_rc;
703
704 rc = SetCfgIfAgc(s, &s->config.ifagc);
705 if (rc < 0)
706 goto exit_rc;
707
708 rc = SetCfgRfAgc(s, &s->config.rfagc);
709 if (rc < 0)
710 goto exit_rc;
711
712 if (fep->u.ofdm.transmission_mode != TRANSMISSION_MODE_2K)
713 v22 = 1;
714 switch (fep->u.ofdm.transmission_mode) {
715 case TRANSMISSION_MODE_8K:
716 edi = 1;
717 if (s->chip_rev == DRXD_FW_B1)
718 break;
719
720 rc = WR16(s, 0x2010010, 0);
721 if (rc < 0)
722 break;
723 v1C = 0x63;
724 v1A = 0x53;
725 v18 = 0x43;
726 break;
727 default:
728 edi = 0;
729 if (s->chip_rev == DRXD_FW_B1)
730 break;
731
732 rc = WR16(s, 0x2010010, 1);
733 if (rc < 0)
734 break;
735
736 v1C = 0x61;
737 v1A = 0x47;
738 v18 = 0x41;
739 }
740
741 switch (fep->u.ofdm.guard_interval) {
742 case GUARD_INTERVAL_1_4:
743 edi |= 0x0c;
744 break;
745 case GUARD_INTERVAL_1_8:
746 edi |= 0x08;
747 break;
748 case GUARD_INTERVAL_1_16:
749 edi |= 0x04;
750 break;
751 case GUARD_INTERVAL_1_32:
752 break;
753 default:
754 v22 |= 2;
755 }
756
757 ebx = 0;
758 ebp = 0;
759 v20 = 0;
760 v1E = 0;
761 v16 = 0;
762 v14 = 0;
763 v12 = 0;
764 v10 = 0;
765 v0E = 0;
766
767 switch (fep->u.ofdm.hierarchy_information) {
768 case HIERARCHY_1:
769 edi |= 0x40;
770 if (s->chip_rev == DRXD_FW_B1)
771 break;
772 rc = WR16(s, 0x1c10047, 1);
773 if (rc < 0)
774 goto exit_rc;
775 rc = WR16(s, 0x2010012, 1);
776 if (rc < 0)
777 goto exit_rc;
778 ebx = 0x19f;
779 ebp = 0x1fb;
780 v20 = 0x0c0;
781 v1E = 0x195;
782 v16 = 0x1d6;
783 v14 = 0x1ef;
784 v12 = 4;
785 v10 = 5;
786 v0E = 5;
787 break;
788 case HIERARCHY_2:
789 edi |= 0x80;
790 if (s->chip_rev == DRXD_FW_B1)
791 break;
792 rc = WR16(s, 0x1c10047, 2);
793 if (rc < 0)
794 goto exit_rc;
795 rc = WR16(s, 0x2010012, 2);
796 if (rc < 0)
797 goto exit_rc;
798 ebx = 0x08f;
799 ebp = 0x12f;
800 v20 = 0x0c0;
801 v1E = 0x11e;
802 v16 = 0x1d6;
803 v14 = 0x15e;
804 v12 = 4;
805 v10 = 5;
806 v0E = 5;
807 break;
808 case HIERARCHY_4:
809 edi |= 0xc0;
810 if (s->chip_rev == DRXD_FW_B1)
811 break;
812 rc = WR16(s, 0x1c10047, 3);
813 if (rc < 0)
814 goto exit_rc;
815 rc = WR16(s, 0x2010012, 3);
816 if (rc < 0)
817 goto exit_rc;
818 ebx = 0x14d;
819 ebp = 0x197;
820 v20 = 0x0c0;
821 v1E = 0x1ce;
822 v16 = 0x1d6;
823 v14 = 0x11a;
824 v12 = 4;
825 v10 = 6;
826 v0E = 5;
827 break;
828 default:
829 v22 |= 8;
830 if (s->chip_rev == DRXD_FW_B1)
831 break;
832 rc = WR16(s, 0x1c10047, 0);
833 if (rc < 0)
834 goto exit_rc;
835 rc = WR16(s, 0x2010012, 0);
836 if (rc < 0)
837 goto exit_rc;
838 // QPSK QAM16 QAM64
839 ebx = 0x19f; // 62
840 ebp = 0x1fb; // 15
841 v20 = 0x16a; // 62
842 v1E = 0x195; // 62
843 v16 = 0x1bb; // 15
844 v14 = 0x1ef; // 15
845 v12 = 5; // 16
846 v10 = 5; // 16
847 v0E = 5; // 16
848 }
849
850 switch (fep->u.ofdm.constellation) {
851 default:
852 v22 |= 4;
853 case QPSK:
854 if (s->chip_rev == DRXD_FW_B1)
855 break;
856
857 rc = WR16(s, 0x1c10046, 0);
858 if (rc < 0)
859 goto exit_rc;
860 rc = WR16(s, 0x2010011, 0);
861 if (rc < 0)
862 goto exit_rc;
863 rc = WR16(s, 0x201001a, 0x10);
864 if (rc < 0)
865 goto exit_rc;
866 rc = WR16(s, 0x201001b, 0);
867 if (rc < 0)
868 goto exit_rc;
869 rc = WR16(s, 0x201001c, 0);
870 if (rc < 0)
871 goto exit_rc;
872 rc = WR16(s, 0x1c10062, v20);
873 if (rc < 0)
874 goto exit_rc;
875 rc = WR16(s, 0x1c1002a, v1C);
876 if (rc < 0)
877 goto exit_rc;
878 rc = WR16(s, 0x1c10015, v16);
879 if (rc < 0)
880 goto exit_rc;
881 rc = WR16(s, 0x1c10016, v12);
882 if (rc < 0)
883 goto exit_rc;
884 break;
885 case QAM_16:
886 edi |= 0x10;
887 if (s->chip_rev == DRXD_FW_B1)
888 break;
889
890 rc = WR16(s, 0x1c10046, 1);
891 if (rc < 0)
892 goto exit_rc;
893 rc = WR16(s, 0x2010011, 1);
894 if (rc < 0)
895 goto exit_rc;
896 rc = WR16(s, 0x201001a, 0x10);
897 if (rc < 0)
898 goto exit_rc;
899 rc = WR16(s, 0x201001b, 4);
900 if (rc < 0)
901 goto exit_rc;
902 rc = WR16(s, 0x201001c, 0);
903 if (rc < 0)
904 goto exit_rc;
905 rc = WR16(s, 0x1c10062, v1E);
906 if (rc < 0)
907 goto exit_rc;
908 rc = WR16(s, 0x1c1002a, v1A);
909 if (rc < 0)
910 goto exit_rc;
911 rc = WR16(s, 0x1c10015, v14);
912 if (rc < 0)
913 goto exit_rc;
914 rc = WR16(s, 0x1c10016, v10);
915 if (rc < 0)
916 goto exit_rc;
917 break;
918 case QAM_64:
919 edi |= 0x20;
920 rc = WR16(s, 0x1c10046, 2);
921 if (rc < 0)
922 goto exit_rc;
923 rc = WR16(s, 0x2010011, 2);
924 if (rc < 0)
925 goto exit_rc;
926 rc = WR16(s, 0x201001a, 0x20);
927 if (rc < 0)
928 goto exit_rc;
929 rc = WR16(s, 0x201001b, 8);
930 if (rc < 0)
931 goto exit_rc;
932 rc = WR16(s, 0x201001c, 2);
933 if (rc < 0)
934 goto exit_rc;
935 rc = WR16(s, 0x1c10062, ebx);
936 if (rc < 0)
937 goto exit_rc;
938 rc = WR16(s, 0x1c1002a, v18);
939 if (rc < 0)
940 goto exit_rc;
941 rc = WR16(s, 0x1c10015, ebp);
942 if (rc < 0)
943 goto exit_rc;
944 rc = WR16(s, 0x1c10016, v0E);
945 if (rc < 0)
946 goto exit_rc;
947 break;
948 }
949
950 if (s->config.s20d24 == 1) {
951 rc = WR16(s, 0x2010013, 0);
952 } else {
953 rc = WR16(s, 0x2010013, 1);
954 edi |= 0x1000;
955 }
956
957 switch (fep->u.ofdm.code_rate_HP) {
958 default:
959 v22 |= 0x10;
960 case FEC_1_2:
961 if (s->chip_rev == DRXD_FW_B1)
962 break;
963 rc = WR16(s, 0x2090011, 0);
964 break;
965 case FEC_2_3:
966 edi |= 0x200;
967 if (s->chip_rev == DRXD_FW_B1)
968 break;
969 rc = WR16(s, 0x2090011, 1);
970 break;
971 case FEC_3_4:
972 edi |= 0x400;
973 if (s->chip_rev == DRXD_FW_B1)
974 break;
975 rc = WR16(s, 0x2090011, 2);
976 break;
977 case FEC_5_6: /* 5 */
978 edi |= 0x600;
979 if (s->chip_rev == DRXD_FW_B1)
980 break;
981 rc = WR16(s, 0x2090011, 3);
982 break;
983 case FEC_7_8: /* 7 */
984 edi |= 0x800;
985 if (s->chip_rev == DRXD_FW_B1)
986 break;
987 rc = WR16(s, 0x2090011, 4);
988 break;
989 };
990 if (rc < 0)
991 goto exit_rc;
992
993 switch (fep->u.ofdm.bandwidth) {
994 default:
995 rc = -EINVAL;
996 goto exit_rc;
997 case BANDWIDTH_8_MHZ: /* 0 */
998 case BANDWIDTH_AUTO:
999 rc = WR16(s, 0x0c2003f, 0x32);
1000 s->bandwidth_parm = ebx = 0x8b8249; // 9142857
1001 edx = 0;
1002 break;
1003 case BANDWIDTH_7_MHZ:
1004 rc = WR16(s, 0x0c2003f, 0x3b);
1005 s->bandwidth_parm = ebx = 0x7a1200; // 8000000
1006 edx = 0x4807;
1007 break;
1008 case BANDWIDTH_6_MHZ:
1009 rc = WR16(s, 0x0c2003f, 0x47);
1010 s->bandwidth_parm = ebx = 0x68a1b6; // 6857142
1011 edx = 0x0f07;
1012 break;
1013 };
1014
1015 if (rc < 0)
1016 goto exit_rc;
1017
1018 rc = WR16(s, 0x08200ec, edx);
1019 if (rc < 0)
1020 goto exit_rc;
1021
1022 rc = RD16(s, 0x0820050);
1023 if (rc < 0)
1024 goto exit_rc;
1025 rc = WR16(s, 0x0820050, rc);
1026
1027 {
1028 /* Configure bandwidth specific factor */
1029 ebx = div64_u64(((u64) (s->f_osc) << 21) + (ebx >> 1),
1030 (u64)ebx) - 0x800000;
1031 EXIT_RC(WR16(s, 0x0c50010, ebx & 0xffff));
1032 EXIT_RC(WR16(s, 0x0c50011, ebx >> 16));
1033
1034 /* drx397xD oscillator calibration */
1035 ebx = div64_u64(((u64) (s->config.f_if + df_tuner) << 28) +
1036 (s->f_osc >> 1), (u64)s->f_osc);
1037 }
1038 ebx &= 0xfffffff;
1039 if (fep->inversion == INVERSION_ON)
1040 ebx = 0x10000000 - ebx;
1041
1042 EXIT_RC(WR16(s, 0x0c30010, ebx & 0xffff));
1043 EXIT_RC(WR16(s, 0x0c30011, ebx >> 16));
1044
1045 EXIT_RC(WR16(s, 0x0800000, 1));
1046 EXIT_RC(RD16(s, 0x0800000));
1047
1048
1049 EXIT_RC(SC_WaitForReady(s));
1050 EXIT_RC(WR16(s, 0x0820042, 0));
1051 EXIT_RC(WR16(s, 0x0820041, v22));
1052 EXIT_RC(WR16(s, 0x0820040, edi));
1053 EXIT_RC(SC_SendCommand(s, 3));
1054
1055 rc = RD16(s, 0x0800000);
1056
1057 SC_WaitForReady(s);
1058 WR16(s, 0x0820042, 0);
1059 WR16(s, 0x0820041, 1);
1060 WR16(s, 0x0820040, 1);
1061 SC_SendCommand(s, 1);
1062
1063// rc = WR16(s, 0x2150000, 1);
1064// if (rc < 0) goto exit_rc;
1065
1066 rc = WR16(s, 0x2150000, 2);
1067 rc = WR16(s, 0x2150016, a);
1068 rc = WR16(s, 0x2150010, 4);
1069 rc = WR16(s, 0x2150036, 0);
1070 rc = WR16(s, 0x2150000, 1);
1071 s->config.d60 = 2;
1072 exit_rc:
1073 return rc;
1074}
1075
1076/*******************************************************************************
1077 * DVB interface
1078 ******************************************************************************/
1079
1080static int drx397x_init(struct dvb_frontend *fe)
1081{
1082 struct drx397xD_state *s = fe->demodulator_priv;
1083 int rc;
1084
1085 pr_debug("%s\n", __FUNCTION__);
1086
1087 s->config.rfagc.d00 = 2; /* 0x7c */
1088 s->config.rfagc.w04 = 0;
1089 s->config.rfagc.w06 = 0x3ff;
1090
1091 s->config.ifagc.d00 = 0; /* 0x68 */
1092 s->config.ifagc.w04 = 0;
1093 s->config.ifagc.w06 = 140;
1094 s->config.ifagc.w08 = 0;
1095 s->config.ifagc.w0A = 0x3ff;
1096 s->config.ifagc.w0C = 0x388;
1097
1098 /* for signal strenght calculations */
1099 s->config.ss76 = 820;
1100 s->config.ss78 = 2200;
1101 s->config.ss7A = 150;
1102
1103 /* HI_CfgCommand */
1104 s->config.w50 = 4;
1105 s->config.w52 = 9; // 0xf;
1106
1107 s->config.f_if = 42800000; /* d14: intermediate frequency [Hz] */
1108 s->config.f_osc = 48000; /* s66 : oscillator frequency [kHz] */
1109 s->config.w92 = 12000; // 20000;
1110
1111 s->config.w9C = 0x000e;
1112 s->config.w9E = 0x0000;
1113
1114 /* ConfigureMPEGOutput params */
1115 s->config.wA0 = 4;
1116 s->config.w98 = 1; // 0;
1117 s->config.w9A = 1;
1118
1119 /* get chip revision */
1120 rc = RD16(s, 0x2410019);
1121 if (rc < 0)
1122 return -ENODEV;
1123
1124 if (rc == 0) {
1125 printk(KERN_INFO "%s: chip revision A2\n", mod_name);
1126 rc = drx_load_fw(s, DRXD_FW_A2);
1127 } else {
1128
1129 rc = (rc >> 12) - 3;
1130 switch (rc) {
1131 case 1:
1132 s->flags |= F_SET_0D4h;
1133 case 0:
1134 case 4:
1135 s->flags |= F_SET_0D0h;
1136 break;
1137 case 2:
1138 case 5:
1139 break;
1140 case 3:
1141 s->flags |= F_SET_0D4h;
1142 break;
1143 default:
1144 return -ENODEV;
1145 };
1146 printk(KERN_INFO "%s: chip revision B1.%d\n", mod_name, rc);
1147 rc = drx_load_fw(s, DRXD_FW_B1);
1148 }
1149 if (rc < 0)
1150 goto error;
1151
1152 rc = WR16(s, 0x0420033, 0x3973);
1153 if (rc < 0)
1154 goto error;
1155
1156 rc = HI_Command(s, 2);
1157
1158 msleep(1);
1159
1160 if (s->chip_rev == DRXD_FW_A2) {
1161 rc = WR16(s, 0x043012d, 0x47F);
1162 if (rc < 0)
1163 goto error;
1164 }
1165 rc = WR16_E0(s, 0x0400000, 0);
1166 if (rc < 0)
1167 goto error;
1168
1169 if (s->config.w92 > 20000 || s->config.w92 % 4000) {
1170 printk(KERN_ERR "%s: invalid osc frequency\n", mod_name);
1171 rc = -1;
1172 goto error;
1173 }
1174
1175 rc = WR16(s, 0x2410010, 1);
1176 if (rc < 0)
1177 goto error;
1178 rc = WR16(s, 0x2410011, 0x15);
1179 if (rc < 0)
1180 goto error;
1181 rc = WR16(s, 0x2410012, s->config.w92 / 4000);
1182 if (rc < 0)
1183 goto error;
1184#ifdef ORIG_FW
1185 rc = WR16(s, 0x2410015, 2);
1186 if (rc < 0)
1187 goto error;
1188#endif
1189 rc = WR16(s, 0x2410017, 0x3973);
1190 if (rc < 0)
1191 goto error;
1192
1193 s->f_osc = s->config.f_osc * 1000; /* initial estimator */
1194
1195 s->config.w56 = 1;
1196
1197 rc = HI_CfgCommand(s);
1198 if (rc < 0)
1199 goto error;
1200
1201 rc = write_fw(s, DRXD_InitAtomicRead);
1202 if (rc < 0)
1203 goto error;
1204
1205 if (s->chip_rev == DRXD_FW_A2) {
1206 rc = WR16(s, 0x2150013, 0);
1207 if (rc < 0)
1208 goto error;
1209 }
1210
1211 rc = WR16_E0(s, 0x0400002, 0);
1212 if (rc < 0)
1213 goto error;
1214 rc = WR16(s, 0x0400002, 0);
1215 if (rc < 0)
1216 goto error;
1217
1218 if (s->chip_rev == DRXD_FW_A2) {
1219 rc = write_fw(s, DRXD_ResetCEFR);
1220 if (rc < 0)
1221 goto error;
1222 }
1223 rc = write_fw(s, DRXD_microcode);
1224 if (rc < 0)
1225 goto error;
1226
1227 s->config.w9C = 0x0e;
1228 if (s->flags & F_SET_0D0h) {
1229 s->config.w9C = 0;
1230 rc = RD16(s, 0x0c20010);
1231 if (rc < 0)
1232 goto write_DRXD_InitFE_1;
1233
1234 rc &= ~0x1000;
1235 rc = WR16(s, 0x0c20010, rc);
1236 if (rc < 0)
1237 goto write_DRXD_InitFE_1;
1238
1239 rc = RD16(s, 0x0c20011);
1240 if (rc < 0)
1241 goto write_DRXD_InitFE_1;
1242
1243 rc &= ~0x8;
1244 rc = WR16(s, 0x0c20011, rc);
1245 if (rc < 0)
1246 goto write_DRXD_InitFE_1;
1247
1248 rc = WR16(s, 0x0c20012, 1);
1249 }
1250
1251 write_DRXD_InitFE_1:
1252
1253 rc = write_fw(s, DRXD_InitFE_1);
1254 if (rc < 0)
1255 goto error;
1256
1257 rc = 1;
1258 if (s->chip_rev == DRXD_FW_B1) {
1259 if (s->flags & F_SET_0D0h)
1260 rc = 0;
1261 } else {
1262 if (s->flags & F_SET_0D0h)
1263 rc = 4;
1264 }
1265
1266 rc = WR16(s, 0x0C20012, rc);
1267 if (rc < 0)
1268 goto error;
1269
1270 rc = WR16(s, 0x0C20013, s->config.w9E);
1271 if (rc < 0)
1272 goto error;
1273 rc = WR16(s, 0x0C20015, s->config.w9C);
1274 if (rc < 0)
1275 goto error;
1276
1277 rc = write_fw(s, DRXD_InitFE_2);
1278 if (rc < 0)
1279 goto error;
1280 rc = write_fw(s, DRXD_InitFT);
1281 if (rc < 0)
1282 goto error;
1283 rc = write_fw(s, DRXD_InitCP);
1284 if (rc < 0)
1285 goto error;
1286 rc = write_fw(s, DRXD_InitCE);
1287 if (rc < 0)
1288 goto error;
1289 rc = write_fw(s, DRXD_InitEQ);
1290 if (rc < 0)
1291 goto error;
1292 rc = write_fw(s, DRXD_InitEC);
1293 if (rc < 0)
1294 goto error;
1295 rc = write_fw(s, DRXD_InitSC);
1296 if (rc < 0)
1297 goto error;
1298
1299 rc = SetCfgIfAgc(s, &s->config.ifagc);
1300 if (rc < 0)
1301 goto error;
1302
1303 rc = SetCfgRfAgc(s, &s->config.rfagc);
1304 if (rc < 0)
1305 goto error;
1306
1307 rc = ConfigureMPEGOutput(s, 1);
1308 rc = WR16(s, 0x08201fe, 0x0017);
1309 rc = WR16(s, 0x08201ff, 0x0101);
1310
1311 s->config.d5C = 0;
1312 s->config.d60 = 1;
1313 s->config.d48 = 1;
1314 error:
1315 return rc;
1316}
1317
1318static int drx397x_get_frontend(struct dvb_frontend *fe,
1319 struct dvb_frontend_parameters *params)
1320{
1321 return 0;
1322}
1323
1324static int drx397x_set_frontend(struct dvb_frontend *fe,
1325 struct dvb_frontend_parameters *params)
1326{
1327 struct drx397xD_state *s = fe->demodulator_priv;
1328
1329 s->config.s20d24 = 1; // 0;
1330 return drx_tune(s, params);
1331}
1332
1333static int drx397x_get_tune_settings(struct dvb_frontend *fe,
1334 struct dvb_frontend_tune_settings
1335 *fe_tune_settings)
1336{
1337 fe_tune_settings->min_delay_ms = 10000;
1338 fe_tune_settings->step_size = 0;
1339 fe_tune_settings->max_drift = 0;
1340 return 0;
1341}
1342
1343static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t * status)
1344{
1345 struct drx397xD_state *s = fe->demodulator_priv;
1346 int lockstat;
1347
1348 GetLockStatus(s, &lockstat);
1349 /* TODO */
1350// if (lockstat & 1)
1351// CorrectSysClockDeviation(s);
1352
1353 *status = 0;
1354 if (lockstat & 2) {
1355 CorrectSysClockDeviation(s);
1356 ConfigureMPEGOutput(s, 1);
1357 *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI;
1358 }
1359 if (lockstat & 4) {
1360 *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL;
1361 }
1362
1363 return 0;
1364}
1365
1366static int drx397x_read_ber(struct dvb_frontend *fe, unsigned int *ber)
1367{
1368 *ber = 0;
1369 return 0;
1370}
1371
1372static int drx397x_read_snr(struct dvb_frontend *fe, u16 * snr)
1373{
1374 *snr = 0;
1375 return 0;
1376}
1377
1378static int drx397x_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
1379{
1380 struct drx397xD_state *s = fe->demodulator_priv;
1381 int rc;
1382
1383 if (s->config.ifagc.d00 == 2) {
1384 *strength = 0xffff;
1385 return 0;
1386 }
1387 rc = RD16(s, 0x0c20035);
1388 if (rc < 0) {
1389 *strength = 0;
1390 return 0;
1391 }
1392 rc &= 0x3ff;
1393 /* Signal strength is calculated using the following formula:
1394 *
1395 * a = 2200 * 150 / (2200 + 150);
1396 * a = a * 3300 / (a + 820);
1397 * b = 2200 * 3300 / (2200 + 820);
1398 * c = (((b-a) * rc) >> 10 + a) << 4;
1399 * strength = ~c & 0xffff;
1400 *
1401 * The following does the same but with less rounding errors:
1402 */
1403 *strength = ~(7720 + (rc * 30744 >> 10));
1404 return 0;
1405}
1406
1407static int drx397x_read_ucblocks(struct dvb_frontend *fe,
1408 unsigned int *ucblocks)
1409{
1410 *ucblocks = 0;
1411 return 0;
1412}
1413
1414static int drx397x_sleep(struct dvb_frontend *fe)
1415{
1416 return 0;
1417}
1418
1419static void drx397x_release(struct dvb_frontend *fe)
1420{
1421 struct drx397xD_state *s = fe->demodulator_priv;
1422 printk(KERN_INFO "%s: release demodulator\n", mod_name);
1423 if (s) {
1424 drx_release_fw(s);
1425 kfree(s);
1426 }
1427
1428}
1429
1430static struct dvb_frontend_ops drx397x_ops = {
1431
1432 .info = {
1433 .name = "Micronas DRX397xD DVB-T Frontend",
1434 .type = FE_OFDM,
1435 .frequency_min = 47125000,
1436 .frequency_max = 855250000,
1437 .frequency_stepsize = 166667,
1438 .frequency_tolerance = 0,
1439 .caps = /* 0x0C01B2EAE */
1440 FE_CAN_FEC_1_2 | // = 0x2,
1441 FE_CAN_FEC_2_3 | // = 0x4,
1442 FE_CAN_FEC_3_4 | // = 0x8,
1443 FE_CAN_FEC_5_6 | // = 0x20,
1444 FE_CAN_FEC_7_8 | // = 0x80,
1445 FE_CAN_FEC_AUTO | // = 0x200,
1446 FE_CAN_QPSK | // = 0x400,
1447 FE_CAN_QAM_16 | // = 0x800,
1448 FE_CAN_QAM_64 | // = 0x2000,
1449 FE_CAN_QAM_AUTO | // = 0x10000,
1450 FE_CAN_TRANSMISSION_MODE_AUTO | // = 0x20000,
1451 FE_CAN_GUARD_INTERVAL_AUTO | // = 0x80000,
1452 FE_CAN_HIERARCHY_AUTO | // = 0x100000,
1453 FE_CAN_RECOVER | // = 0x40000000,
1454 FE_CAN_MUTE_TS // = 0x80000000
1455 },
1456
1457 .release = drx397x_release,
1458 .init = drx397x_init,
1459 .sleep = drx397x_sleep,
1460
1461 .set_frontend = drx397x_set_frontend,
1462 .get_tune_settings = drx397x_get_tune_settings,
1463 .get_frontend = drx397x_get_frontend,
1464
1465 .read_status = drx397x_read_status,
1466 .read_snr = drx397x_read_snr,
1467 .read_signal_strength = drx397x_read_signal_strength,
1468 .read_ber = drx397x_read_ber,
1469 .read_ucblocks = drx397x_read_ucblocks,
1470};
1471
1472struct dvb_frontend *drx397xD_attach(const struct drx397xD_config *config,
1473 struct i2c_adapter *i2c)
1474{
1475 struct drx397xD_state *s = NULL;
1476
1477 /* allocate memory for the internal state */
1478 s = kzalloc(sizeof(struct drx397xD_state), GFP_KERNEL);
1479 if (s == NULL)
1480 goto error;
1481
1482 /* setup the state */
1483 s->i2c = i2c;
1484 memcpy(&s->config, config, sizeof(struct drx397xD_config));
1485
1486 /* check if the demod is there */
1487 if (RD16(s, 0x2410019) < 0)
1488 goto error;
1489
1490 /* create dvb_frontend */
1491 memcpy(&s->frontend.ops, &drx397x_ops, sizeof(struct dvb_frontend_ops));
1492 s->frontend.demodulator_priv = s;
1493
1494 return &s->frontend;
1495 error:
1496 kfree(s);
1497 return NULL;
1498}
1499
1500MODULE_DESCRIPTION("Micronas DRX397xD DVB-T Frontend");
1501MODULE_AUTHOR("Henk Vergonet");
1502MODULE_LICENSE("GPL");
1503
1504EXPORT_SYMBOL(drx397xD_attach);
diff --git a/drivers/media/dvb/frontends/drx397xD.h b/drivers/media/dvb/frontends/drx397xD.h
new file mode 100644
index 000000000000..ddc7a07971b7
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD.h
@@ -0,0 +1,130 @@
1/*
2 * Driver for Micronas DVB-T drx397xD demodulator
3 *
4 * Copyright (C) 2007 Henk vergonet <Henk.Vergonet@gmail.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, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef _DRX397XD_H_INCLUDED
23#define _DRX397XD_H_INCLUDED
24
25#include <linux/dvb/frontend.h>
26
27#define DRX_F_STEPSIZE 166667
28#define DRX_F_OFFSET 36000000
29
30#define I2C_ADR_C0(x) \
31( (u32)cpu_to_le32( \
32 (u32)( \
33 (((u32)(x) & (u32)0x000000ffUL) ) | \
34 (((u32)(x) & (u32)0x0000ff00UL) << 16) | \
35 (((u32)(x) & (u32)0x0fff0000UL) >> 8) | \
36 ( (u32)0x00c00000UL) \
37 )) \
38)
39
40#define I2C_ADR_E0(x) \
41( (u32)cpu_to_le32( \
42 (u32)( \
43 (((u32)(x) & (u32)0x000000ffUL) ) | \
44 (((u32)(x) & (u32)0x0000ff00UL) << 16) | \
45 (((u32)(x) & (u32)0x0fff0000UL) >> 8) | \
46 ( (u32)0x00e00000UL) \
47 )) \
48)
49
50struct drx397xD_CfgRfAgc /* 0x7c */
51{
52 int d00; /* 2 */
53 u16 w04;
54 u16 w06;
55};
56
57struct drx397xD_CfgIfAgc /* 0x68 */
58{
59 int d00; /* 0 */
60 u16 w04; /* 0 */
61 u16 w06;
62 u16 w08;
63 u16 w0A;
64 u16 w0C;
65};
66
67struct drx397xD_s20 {
68 int d04;
69 u32 d18;
70 u32 d1C;
71 u32 d20;
72 u32 d14;
73 u32 d24;
74 u32 d0C;
75 u32 d08;
76};
77
78struct drx397xD_config
79{
80 /* demodulator's I2C address */
81 u8 demod_address; /* 0x0f */
82
83 struct drx397xD_CfgIfAgc ifagc; /* 0x68 */
84 struct drx397xD_CfgRfAgc rfagc; /* 0x7c */
85 u32 s20d24;
86
87 /* HI_CfgCommand parameters */
88 u16 w50, w52, /* w54, */ w56;
89
90 int d5C;
91 int d60;
92 int d48;
93 int d28;
94
95 u32 f_if; /* d14: intermediate frequency [Hz] */
96 /* 36000000 on Cinergy 2400i DT */
97 /* 42800000 on Pinnacle Hybrid PRO 330e */
98
99 u16 f_osc; /* s66: 48000 oscillator frequency [kHz] */
100
101 u16 w92; /* 20000 */
102
103 u16 wA0;
104 u16 w98;
105 u16 w9A;
106
107 u16 w9C; /* 0xe0 */
108 u16 w9E; /* 0x00 */
109
110 /* used for signal strength calculations in
111 drx397x_read_signal_strength
112 */
113 u16 ss78; // 2200
114 u16 ss7A; // 150
115 u16 ss76; // 820
116};
117
118#if defined(CONFIG_DVB_DRX397XD) || (defined(CONFIG_DVB_DRX397XD_MODULE) && defined(MODULE))
119extern struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
120 struct i2c_adapter *i2c);
121#else
122static inline struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
123 struct i2c_adapter *i2c)
124{
125 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
126 return NULL;
127}
128#endif /* CONFIG_DVB_DRX397XD */
129
130#endif /* _DRX397XD_H_INCLUDED */
diff --git a/drivers/media/dvb/frontends/drx397xD_fw.h b/drivers/media/dvb/frontends/drx397xD_fw.h
new file mode 100644
index 000000000000..01de02a81cd4
--- /dev/null
+++ b/drivers/media/dvb/frontends/drx397xD_fw.h
@@ -0,0 +1,40 @@
1/*
2 * Firmware definitions for Micronas drx397xD
3 *
4 * Copyright (C) 2007 Henk Vergonet <Henk.Vergonet@gmail.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, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifdef _FW_ENTRY
21 _FW_ENTRY("drx397xD.A2.fw", DRXD_FW_A2 = 0 ),
22 _FW_ENTRY("drx397xD.B1.fw", DRXD_FW_B1 ),
23#undef _FW_ENTRY
24#endif /* _FW_ENTRY */
25
26#ifdef _BLOB_ENTRY
27 _BLOB_ENTRY("InitAtomicRead", DRXD_InitAtomicRead = 0 ),
28 _BLOB_ENTRY("InitCE", DRXD_InitCE ),
29 _BLOB_ENTRY("InitCP", DRXD_InitCP ),
30 _BLOB_ENTRY("InitEC", DRXD_InitEC ),
31 _BLOB_ENTRY("InitEQ", DRXD_InitEQ ),
32 _BLOB_ENTRY("InitFE_1", DRXD_InitFE_1 ),
33 _BLOB_ENTRY("InitFE_2", DRXD_InitFE_2 ),
34 _BLOB_ENTRY("InitFT", DRXD_InitFT ),
35 _BLOB_ENTRY("InitSC", DRXD_InitSC ),
36 _BLOB_ENTRY("ResetCEFR", DRXD_ResetCEFR ),
37 _BLOB_ENTRY("ResetECRAM", DRXD_ResetECRAM ),
38 _BLOB_ENTRY("microcode", DRXD_microcode ),
39#undef _BLOB_ENTRY
40#endif /* _BLOB_ENTRY */
diff --git a/drivers/media/dvb/frontends/z0194a.h b/drivers/media/dvb/frontends/z0194a.h
new file mode 100644
index 000000000000..d2876d2e1769
--- /dev/null
+++ b/drivers/media/dvb/frontends/z0194a.h
@@ -0,0 +1,97 @@
1/* z0194a.h Sharp z0194a tuner support
2*
3* Copyright (C) 2008 Igor M. Liplianin (liplianin@me.by)
4*
5* This program is free software; you can redistribute it and/or modify it
6* under the terms of the GNU General Public License as published by the
7* Free Software Foundation, version 2.
8*
9* see Documentation/dvb/README.dvb-usb for more information
10*/
11
12#ifndef Z0194A
13#define Z0194A
14
15static int sharp_z0194a__set_symbol_rate(struct dvb_frontend *fe,
16 u32 srate, u32 ratio)
17{
18 u8 aclk = 0;
19 u8 bclk = 0;
20
21 if (srate < 1500000) {
22 aclk = 0xb7; bclk = 0x47; }
23 else if (srate < 3000000) {
24 aclk = 0xb7; bclk = 0x4b; }
25 else if (srate < 7000000) {
26 aclk = 0xb7; bclk = 0x4f; }
27 else if (srate < 14000000) {
28 aclk = 0xb7; bclk = 0x53; }
29 else if (srate < 30000000) {
30 aclk = 0xb6; bclk = 0x53; }
31 else if (srate < 45000000) {
32 aclk = 0xb4; bclk = 0x51; }
33
34 stv0299_writereg(fe, 0x13, aclk);
35 stv0299_writereg(fe, 0x14, bclk);
36 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
37 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
38 stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
39
40 return 0;
41}
42
43static u8 sharp_z0194a__inittab[] = {
44 0x01, 0x15,
45 0x02, 0x00,
46 0x03, 0x00,
47 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
48 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
49 0x06, 0x40, /* DAC not used, set to high impendance mode */
50 0x07, 0x00, /* DAC LSB */
51 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
52 0x09, 0x00, /* FIFO */
53 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
54 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
55 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
56 0x10, 0x3f, /* AGC2 0x3d */
57 0x11, 0x84,
58 0x12, 0xb9,
59 0x15, 0xc9, /* lock detector threshold */
60 0x16, 0x00,
61 0x17, 0x00,
62 0x18, 0x00,
63 0x19, 0x00,
64 0x1a, 0x00,
65 0x1f, 0x50,
66 0x20, 0x00,
67 0x21, 0x00,
68 0x22, 0x00,
69 0x23, 0x00,
70 0x28, 0x00, /* out imp: normal out type: parallel FEC mode:0 */
71 0x29, 0x1e, /* 1/2 threshold */
72 0x2a, 0x14, /* 2/3 threshold */
73 0x2b, 0x0f, /* 3/4 threshold */
74 0x2c, 0x09, /* 5/6 threshold */
75 0x2d, 0x05, /* 7/8 threshold */
76 0x2e, 0x01,
77 0x31, 0x1f, /* test all FECs */
78 0x32, 0x19, /* viterbi and synchro search */
79 0x33, 0xfc, /* rs control */
80 0x34, 0x93, /* error control */
81 0x0f, 0x52,
82 0xff, 0xff
83};
84
85static struct stv0299_config sharp_z0194a_config = {
86 .demod_address = 0x68,
87 .inittab = sharp_z0194a__inittab,
88 .mclk = 88000000UL,
89 .invert = 1,
90 .skip_reinit = 0,
91 .lock_output = STV0299_LOCKOUTPUT_1,
92 .volt13_op0_op1 = STV0299_VOLT13_OP1,
93 .min_delay_ms = 100,
94 .set_symbol_rate = sharp_z0194a__set_symbol_rate,
95};
96
97#endif
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 1360403b88b6..a9653c63f4db 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -242,7 +242,7 @@ static int __devinit pluto_dma_map(struct pluto *pluto)
242 pluto->dma_addr = pci_map_single(pluto->pdev, pluto->dma_buf, 242 pluto->dma_addr = pci_map_single(pluto->pdev, pluto->dma_buf,
243 TS_DMA_BYTES, PCI_DMA_FROMDEVICE); 243 TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
244 244
245 return pci_dma_mapping_error(pluto->dma_addr); 245 return pci_dma_mapping_error(pluto->pdev, pluto->dma_addr);
246} 246}
247 247
248static void pluto_dma_unmap(struct pluto *pluto) 248static void pluto_dma_unmap(struct pluto *pluto)
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index b4b8ed795c95..c5f45fed69dc 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -110,12 +110,12 @@ struct smscore_registry_entry_t {
110 enum sms_device_type_st type; 110 enum sms_device_type_st type;
111}; 111};
112 112
113struct list_head g_smscore_notifyees; 113static struct list_head g_smscore_notifyees;
114struct list_head g_smscore_devices; 114static struct list_head g_smscore_devices;
115struct mutex g_smscore_deviceslock; 115static struct mutex g_smscore_deviceslock;
116 116
117struct list_head g_smscore_registry; 117static struct list_head g_smscore_registry;
118struct mutex g_smscore_registrylock; 118static struct mutex g_smscore_registrylock;
119 119
120static int default_mode = 4; 120static int default_mode = 4;
121 121
@@ -1187,7 +1187,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
1187} 1187}
1188 1188
1189 1189
1190int smscore_module_init(void) 1190static int __init smscore_module_init(void)
1191{ 1191{
1192 int rc = 0; 1192 int rc = 0;
1193 1193
@@ -1209,7 +1209,7 @@ int smscore_module_init(void)
1209 return rc; 1209 return rc;
1210} 1210}
1211 1211
1212void smscore_module_exit(void) 1212static void __exit smscore_module_exit(void)
1213{ 1213{
1214 1214
1215 kmutex_lock(&g_smscore_deviceslock); 1215 kmutex_lock(&g_smscore_deviceslock);
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 6f9c18563867..229274a14110 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -27,8 +27,8 @@
27 27
28DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 28DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
29 29
30struct list_head g_smsdvb_clients; 30static struct list_head g_smsdvb_clients;
31struct mutex g_smsdvb_clientslock; 31static struct mutex g_smsdvb_clientslock;
32 32
33static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) 33static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
34{ 34{
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 87c973ac668b..41b5a988b619 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -5,8 +5,6 @@ config TTPCI_EEPROM
5config DVB_AV7110 5config DVB_AV7110
6 tristate "AV7110 cards" 6 tristate "AV7110 cards"
7 depends on DVB_CORE && PCI && I2C 7 depends on DVB_CORE && PCI && I2C
8 depends on HOTPLUG
9 select FW_LOADER if !DVB_AV7110_FIRMWARE
10 select TTPCI_EEPROM 8 select TTPCI_EEPROM
11 select VIDEO_SAA7146_VV 9 select VIDEO_SAA7146_VV
12 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV 10 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV
@@ -127,14 +125,12 @@ config DVB_BUDGET_AV
127 depends on DVB_BUDGET_CORE && I2C 125 depends on DVB_BUDGET_CORE && I2C
128 select VIDEO_SAA7146_VV 126 select VIDEO_SAA7146_VV
129 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV 127 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV
130 depends on HOTPLUG # dependency of FW_LOADER
131 select DVB_PLL if !DVB_FE_CUSTOMISE 128 select DVB_PLL if !DVB_FE_CUSTOMISE
132 select DVB_STV0299 if !DVB_FE_CUSTOMISE 129 select DVB_STV0299 if !DVB_FE_CUSTOMISE
133 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 130 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
134 select DVB_TDA10021 if !DVB_FE_CUSTOMISE 131 select DVB_TDA10021 if !DVB_FE_CUSTOMISE
135 select DVB_TDA10023 if !DVB_FE_CUSTOMISE 132 select DVB_TDA10023 if !DVB_FE_CUSTOMISE
136 select DVB_TUA6100 if !DVB_FE_CUSTOMISE 133 select DVB_TUA6100 if !DVB_FE_CUSTOMISE
137 select FW_LOADER
138 help 134 help
139 Support for simple SAA7146 based DVB cards 135 Support for simple SAA7146 based DVB cards
140 (so called Budget- or Nova-PCI cards) without onboard 136 (so called Budget- or Nova-PCI cards) without onboard
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
index a23cc0aa17d3..d5f48a3102bd 100644
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ b/drivers/media/dvb/ttusb-dec/Kconfig
@@ -1,8 +1,6 @@
1config DVB_TTUSB_DEC 1config DVB_TTUSB_DEC
2 tristate "Technotrend/Hauppauge USB DEC devices" 2 tristate "Technotrend/Hauppauge USB DEC devices"
3 depends on DVB_CORE && USB && INPUT 3 depends on DVB_CORE && USB && INPUT
4 depends on HOTPLUG # due to FW_LOADER
5 select FW_LOADER
6 select CRC32 4 select CRC32
7 help 5 help
8 Support for external USB adapters designed by Technotrend and 6 Support for external USB adapters designed by Technotrend and
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 4e3f83e4e48f..1ed88f3abe61 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -85,6 +85,7 @@
85#include <linux/input.h> 85#include <linux/input.h>
86#include <linux/videodev2.h> 86#include <linux/videodev2.h>
87#include <media/v4l2-common.h> 87#include <media/v4l2-common.h>
88#include <media/v4l2-ioctl.h>
88#include <linux/usb.h> 89#include <linux/usb.h>
89 90
90/* 91/*
@@ -444,14 +445,7 @@ static const struct file_operations usb_dsbr100_fops = {
444 .llseek = no_llseek, 445 .llseek = no_llseek,
445}; 446};
446 447
447/* V4L2 interface */ 448static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = {
448static struct video_device dsbr100_videodev_template =
449{
450 .owner = THIS_MODULE,
451 .name = "D-Link DSB-R 100",
452 .type = VID_TYPE_TUNER,
453 .fops = &usb_dsbr100_fops,
454 .release = video_device_release,
455 .vidioc_querycap = vidioc_querycap, 449 .vidioc_querycap = vidioc_querycap,
456 .vidioc_g_tuner = vidioc_g_tuner, 450 .vidioc_g_tuner = vidioc_g_tuner,
457 .vidioc_s_tuner = vidioc_s_tuner, 451 .vidioc_s_tuner = vidioc_s_tuner,
@@ -466,6 +460,14 @@ static struct video_device dsbr100_videodev_template =
466 .vidioc_s_input = vidioc_s_input, 460 .vidioc_s_input = vidioc_s_input,
467}; 461};
468 462
463/* V4L2 interface */
464static struct video_device dsbr100_videodev_template = {
465 .name = "D-Link DSB-R 100",
466 .fops = &usb_dsbr100_fops,
467 .ioctl_ops = &usb_dsbr100_ioctl_ops,
468 .release = video_device_release,
469};
470
469/* check if the device is present and register with v4l and 471/* check if the device is present and register with v4l and
470usb if it is */ 472usb if it is */
471static int usb_dsbr100_probe(struct usb_interface *intf, 473static int usb_dsbr100_probe(struct usb_interface *intf,
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c
index 09fe6f1cdf14..7fd7ee2d32c1 100644
--- a/drivers/media/radio/miropcm20-radio.c
+++ b/drivers/media/radio/miropcm20-radio.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/videodev.h> 24#include <linux/videodev.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26#include "oss/aci.h" 27#include "oss/aci.h"
27#include "miropcm20-rds-core.h" 28#include "miropcm20-rds-core.h"
28 29
@@ -228,9 +229,7 @@ static const struct file_operations pcm20_fops = {
228}; 229};
229 230
230static struct video_device pcm20_radio = { 231static struct video_device pcm20_radio = {
231 .owner = THIS_MODULE,
232 .name = "Miro PCM 20 radio", 232 .name = "Miro PCM 20 radio",
233 .type = VID_TYPE_TUNER,
234 .fops = &pcm20_fops, 233 .fops = &pcm20_fops,
235 .priv = &pcm20_unit 234 .priv = &pcm20_unit
236}; 235};
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 1ec18ed1a733..eba9209b3024 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -36,6 +36,7 @@
36#include <asm/uaccess.h> /* copy to/from user */ 36#include <asm/uaccess.h> /* copy to/from user */
37#include <linux/videodev2.h> /* kernel radio structs */ 37#include <linux/videodev2.h> /* kernel radio structs */
38#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <media/v4l2-ioctl.h>
39 40
40#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 41#include <linux/version.h> /* for KERNEL_VERSION MACRO */
41#define RADIO_VERSION KERNEL_VERSION(0,0,2) 42#define RADIO_VERSION KERNEL_VERSION(0,0,2)
@@ -388,12 +389,7 @@ static const struct file_operations rtrack_fops = {
388 .llseek = no_llseek, 389 .llseek = no_llseek,
389}; 390};
390 391
391static struct video_device rtrack_radio= 392static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
392{
393 .owner = THIS_MODULE,
394 .name = "RadioTrack radio",
395 .type = VID_TYPE_TUNER,
396 .fops = &rtrack_fops,
397 .vidioc_querycap = vidioc_querycap, 393 .vidioc_querycap = vidioc_querycap,
398 .vidioc_g_tuner = vidioc_g_tuner, 394 .vidioc_g_tuner = vidioc_g_tuner,
399 .vidioc_s_tuner = vidioc_s_tuner, 395 .vidioc_s_tuner = vidioc_s_tuner,
@@ -408,6 +404,12 @@ static struct video_device rtrack_radio=
408 .vidioc_s_ctrl = vidioc_s_ctrl, 404 .vidioc_s_ctrl = vidioc_s_ctrl,
409}; 405};
410 406
407static struct video_device rtrack_radio = {
408 .name = "RadioTrack radio",
409 .fops = &rtrack_fops,
410 .ioctl_ops = &rtrack_ioctl_ops,
411};
412
411static int __init rtrack_init(void) 413static int __init rtrack_init(void)
412{ 414{
413 if(io==-1) 415 if(io==-1)
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 46cdb549eac7..3fe5504428c5 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -33,6 +33,7 @@
33#include <asm/uaccess.h> /* copy to/from user */ 33#include <asm/uaccess.h> /* copy to/from user */
34#include <linux/videodev2.h> /* kernel radio structs */ 34#include <linux/videodev2.h> /* kernel radio structs */
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36 37
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 38#include <linux/version.h> /* for KERNEL_VERSION MACRO */
38#define RADIO_VERSION KERNEL_VERSION(0,0,2) 39#define RADIO_VERSION KERNEL_VERSION(0,0,2)
@@ -352,12 +353,7 @@ static const struct file_operations aztech_fops = {
352 .llseek = no_llseek, 353 .llseek = no_llseek,
353}; 354};
354 355
355static struct video_device aztech_radio= 356static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
356{
357 .owner = THIS_MODULE,
358 .name = "Aztech radio",
359 .type = VID_TYPE_TUNER,
360 .fops = &aztech_fops,
361 .vidioc_querycap = vidioc_querycap, 357 .vidioc_querycap = vidioc_querycap,
362 .vidioc_g_tuner = vidioc_g_tuner, 358 .vidioc_g_tuner = vidioc_g_tuner,
363 .vidioc_s_tuner = vidioc_s_tuner, 359 .vidioc_s_tuner = vidioc_s_tuner,
@@ -372,6 +368,12 @@ static struct video_device aztech_radio=
372 .vidioc_s_ctrl = vidioc_s_ctrl, 368 .vidioc_s_ctrl = vidioc_s_ctrl,
373}; 369};
374 370
371static struct video_device aztech_radio = {
372 .name = "Aztech radio",
373 .fops = &aztech_fops,
374 .ioctl_ops = &aztech_ioctl_ops,
375};
376
375module_param_named(debug,aztech_radio.debug, int, 0644); 377module_param_named(debug,aztech_radio.debug, int, 0644);
376MODULE_PARM_DESC(debug,"activates debug info"); 378MODULE_PARM_DESC(debug,"activates debug info");
377 379
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index b14db53ea456..6166e726ed72 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -39,6 +39,7 @@
39#include <asm/uaccess.h> /* copy to/from user */ 39#include <asm/uaccess.h> /* copy to/from user */
40#include <linux/videodev2.h> /* V4L2 API defs */ 40#include <linux/videodev2.h> /* V4L2 API defs */
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h>
42#include <linux/param.h> 43#include <linux/param.h>
43#include <linux/pnp.h> 44#include <linux/pnp.h>
44 45
@@ -569,12 +570,7 @@ static const struct file_operations cadet_fops = {
569 .llseek = no_llseek, 570 .llseek = no_llseek,
570}; 571};
571 572
572static struct video_device cadet_radio= 573static const struct v4l2_ioctl_ops cadet_ioctl_ops = {
573{
574 .owner = THIS_MODULE,
575 .name = "Cadet radio",
576 .type = VID_TYPE_TUNER,
577 .fops = &cadet_fops,
578 .vidioc_querycap = vidioc_querycap, 574 .vidioc_querycap = vidioc_querycap,
579 .vidioc_g_tuner = vidioc_g_tuner, 575 .vidioc_g_tuner = vidioc_g_tuner,
580 .vidioc_s_tuner = vidioc_s_tuner, 576 .vidioc_s_tuner = vidioc_s_tuner,
@@ -589,6 +585,12 @@ static struct video_device cadet_radio=
589 .vidioc_s_input = vidioc_s_input, 585 .vidioc_s_input = vidioc_s_input,
590}; 586};
591 587
588static struct video_device cadet_radio = {
589 .name = "Cadet radio",
590 .fops = &cadet_fops,
591 .ioctl_ops = &cadet_ioctl_ops,
592};
593
592#ifdef CONFIG_PNP 594#ifdef CONFIG_PNP
593 595
594static struct pnp_device_id cadet_pnp_devices[] = { 596static struct pnp_device_id cadet_pnp_devices[] = {
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index de49be971480..36e754e3ffb2 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -46,6 +46,7 @@
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/videodev2.h> 47#include <linux/videodev2.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/errno.h> 50#include <linux/errno.h>
50 51
51#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 52#include <linux/version.h> /* for KERNEL_VERSION MACRO */
@@ -374,11 +375,7 @@ static const struct file_operations gemtek_pci_fops = {
374 .llseek = no_llseek, 375 .llseek = no_llseek,
375}; 376};
376 377
377static struct video_device vdev_template = { 378static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
378 .owner = THIS_MODULE,
379 .name = "Gemtek PCI Radio",
380 .type = VID_TYPE_TUNER,
381 .fops = &gemtek_pci_fops,
382 .vidioc_querycap = vidioc_querycap, 379 .vidioc_querycap = vidioc_querycap,
383 .vidioc_g_tuner = vidioc_g_tuner, 380 .vidioc_g_tuner = vidioc_g_tuner,
384 .vidioc_s_tuner = vidioc_s_tuner, 381 .vidioc_s_tuner = vidioc_s_tuner,
@@ -393,6 +390,12 @@ static struct video_device vdev_template = {
393 .vidioc_s_ctrl = vidioc_s_ctrl, 390 .vidioc_s_ctrl = vidioc_s_ctrl,
394}; 391};
395 392
393static struct video_device vdev_template = {
394 .name = "Gemtek PCI Radio",
395 .fops = &gemtek_pci_fops,
396 .ioctl_ops = &gemtek_pci_ioctl_ops,
397};
398
396static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id ) 399static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id )
397{ 400{
398 struct gemtek_pci_card *card; 401 struct gemtek_pci_card *card;
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 81f6aeb1cd11..2b1a6221de6d 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -23,6 +23,7 @@
23#include <asm/io.h> /* outb, outb_p */ 23#include <asm/io.h> /* outb, outb_p */
24#include <asm/uaccess.h> /* copy to/from user */ 24#include <asm/uaccess.h> /* copy to/from user */
25#include <linux/videodev2.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
26#include <media/v4l2-ioctl.h>
26#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
27#include <linux/spinlock.h> 28#include <linux/spinlock.h>
28 29
@@ -552,11 +553,7 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
552 return 0; 553 return 0;
553} 554}
554 555
555static struct video_device gemtek_radio = { 556static const struct v4l2_ioctl_ops gemtek_ioctl_ops = {
556 .owner = THIS_MODULE,
557 .name = "GemTek Radio card",
558 .type = VID_TYPE_TUNER,
559 .fops = &gemtek_fops,
560 .vidioc_querycap = vidioc_querycap, 557 .vidioc_querycap = vidioc_querycap,
561 .vidioc_g_tuner = vidioc_g_tuner, 558 .vidioc_g_tuner = vidioc_g_tuner,
562 .vidioc_s_tuner = vidioc_s_tuner, 559 .vidioc_s_tuner = vidioc_s_tuner,
@@ -571,6 +568,12 @@ static struct video_device gemtek_radio = {
571 .vidioc_s_ctrl = vidioc_s_ctrl 568 .vidioc_s_ctrl = vidioc_s_ctrl
572}; 569};
573 570
571static struct video_device gemtek_radio = {
572 .name = "GemTek Radio card",
573 .fops = &gemtek_fops,
574 .ioctl_ops = &gemtek_ioctl_ops,
575};
576
574/* 577/*
575 * Initialization / cleanup related stuff. 578 * Initialization / cleanup related stuff.
576 */ 579 */
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index bddd3c409aa9..0ada1c697e8a 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/videodev2.h> 28#include <linux/videodev2.h>
29#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
30#include <media/v4l2-ioctl.h>
30 31
31#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 32#include <linux/version.h> /* for KERNEL_VERSION MACRO */
32#define RADIO_VERSION KERNEL_VERSION(0,0,6) 33#define RADIO_VERSION KERNEL_VERSION(0,0,6)
@@ -354,10 +355,7 @@ static u16 __devinit radio_power_on(struct radio_device *dev)
354 return (ofreq == radio_bits_get(dev)); 355 return (ofreq == radio_bits_get(dev));
355} 356}
356 357
357static struct video_device maestro_radio = { 358static const struct v4l2_ioctl_ops maestro_ioctl_ops = {
358 .name = "Maestro radio",
359 .type = VID_TYPE_TUNER,
360 .fops = &maestro_fops,
361 .vidioc_querycap = vidioc_querycap, 359 .vidioc_querycap = vidioc_querycap,
362 .vidioc_g_tuner = vidioc_g_tuner, 360 .vidioc_g_tuner = vidioc_g_tuner,
363 .vidioc_s_tuner = vidioc_s_tuner, 361 .vidioc_s_tuner = vidioc_s_tuner,
@@ -372,6 +370,12 @@ static struct video_device maestro_radio = {
372 .vidioc_s_ctrl = vidioc_s_ctrl, 370 .vidioc_s_ctrl = vidioc_s_ctrl,
373}; 371};
374 372
373static struct video_device maestro_radio = {
374 .name = "Maestro radio",
375 .fops = &maestro_fops,
376 .ioctl_ops = &maestro_ioctl_ops,
377};
378
375static int __devinit maestro_probe(struct pci_dev *pdev, 379static int __devinit maestro_probe(struct pci_dev *pdev,
376 const struct pci_device_id *ent) 380 const struct pci_device_id *ent)
377{ 381{
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 0133ecf3e040..43c75497dc49 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -44,6 +44,7 @@
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/videodev2.h> 45#include <linux/videodev2.h>
46#include <media/v4l2-common.h> 46#include <media/v4l2-common.h>
47#include <media/v4l2-ioctl.h>
47 48
48#define DRIVER_VERSION "0.77" 49#define DRIVER_VERSION "0.77"
49 50
@@ -373,13 +374,7 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
373 return -EINVAL; 374 return -EINVAL;
374} 375}
375 376
376static struct video_device maxiradio_radio = 377static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
377{
378 .owner = THIS_MODULE,
379 .name = "Maxi Radio FM2000 radio",
380 .type = VID_TYPE_TUNER,
381 .fops = &maxiradio_fops,
382
383 .vidioc_querycap = vidioc_querycap, 378 .vidioc_querycap = vidioc_querycap,
384 .vidioc_g_tuner = vidioc_g_tuner, 379 .vidioc_g_tuner = vidioc_g_tuner,
385 .vidioc_s_tuner = vidioc_s_tuner, 380 .vidioc_s_tuner = vidioc_s_tuner,
@@ -394,6 +389,12 @@ static struct video_device maxiradio_radio =
394 .vidioc_s_ctrl = vidioc_s_ctrl, 389 .vidioc_s_ctrl = vidioc_s_ctrl,
395}; 390};
396 391
392static struct video_device maxiradio_radio = {
393 .name = "Maxi Radio FM2000 radio",
394 .fops = &maxiradio_fops,
395 .ioctl_ops = &maxiradio_ioctl_ops,
396};
397
397static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 398static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
398{ 399{
399 if(!request_region(pci_resource_start(pdev, 0), 400 if(!request_region(pci_resource_start(pdev, 0),
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 070802103dc3..e2dde0807268 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -17,6 +17,7 @@
17#include <asm/uaccess.h> /* copy to/from user */ 17#include <asm/uaccess.h> /* copy to/from user */
18#include <linux/videodev2.h> /* kernel radio structs */ 18#include <linux/videodev2.h> /* kernel radio structs */
19#include <media/v4l2-common.h> 19#include <media/v4l2-common.h>
20#include <media/v4l2-ioctl.h>
20#include <linux/spinlock.h> 21#include <linux/spinlock.h>
21 22
22#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 23#include <linux/version.h> /* for KERNEL_VERSION MACRO */
@@ -294,12 +295,7 @@ static const struct file_operations rtrack2_fops = {
294 .llseek = no_llseek, 295 .llseek = no_llseek,
295}; 296};
296 297
297static struct video_device rtrack2_radio= 298static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
298{
299 .owner = THIS_MODULE,
300 .name = "RadioTrack II radio",
301 .type = VID_TYPE_TUNER,
302 .fops = &rtrack2_fops,
303 .vidioc_querycap = vidioc_querycap, 299 .vidioc_querycap = vidioc_querycap,
304 .vidioc_g_tuner = vidioc_g_tuner, 300 .vidioc_g_tuner = vidioc_g_tuner,
305 .vidioc_s_tuner = vidioc_s_tuner, 301 .vidioc_s_tuner = vidioc_s_tuner,
@@ -314,6 +310,12 @@ static struct video_device rtrack2_radio=
314 .vidioc_s_input = vidioc_s_input, 310 .vidioc_s_input = vidioc_s_input,
315}; 311};
316 312
313static struct video_device rtrack2_radio = {
314 .name = "RadioTrack II radio",
315 .fops = &rtrack2_fops,
316 .ioctl_ops = &rtrack2_ioctl_ops,
317};
318
317static int __init rtrack2_init(void) 319static int __init rtrack2_init(void)
318{ 320{
319 if(io==-1) 321 if(io==-1)
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 66e052fd3909..bb5d92f104af 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> /* udelay */ 24#include <linux/delay.h> /* udelay */
25#include <linux/videodev2.h> /* kernel radio structs */ 25#include <linux/videodev2.h> /* kernel radio structs */
26#include <media/v4l2-common.h> 26#include <media/v4l2-common.h>
27#include <media/v4l2-ioctl.h>
27#include <linux/isapnp.h> 28#include <linux/isapnp.h>
28#include <asm/io.h> /* outb, outb_p */ 29#include <asm/io.h> /* outb, outb_p */
29#include <asm/uaccess.h> /* copy to/from user */ 30#include <asm/uaccess.h> /* copy to/from user */
@@ -294,12 +295,7 @@ static const struct file_operations fmi_fops = {
294 .llseek = no_llseek, 295 .llseek = no_llseek,
295}; 296};
296 297
297static struct video_device fmi_radio= 298static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
298{
299 .owner = THIS_MODULE,
300 .name = "SF16FMx radio",
301 .type = VID_TYPE_TUNER,
302 .fops = &fmi_fops,
303 .vidioc_querycap = vidioc_querycap, 299 .vidioc_querycap = vidioc_querycap,
304 .vidioc_g_tuner = vidioc_g_tuner, 300 .vidioc_g_tuner = vidioc_g_tuner,
305 .vidioc_s_tuner = vidioc_s_tuner, 301 .vidioc_s_tuner = vidioc_s_tuner,
@@ -314,6 +310,12 @@ static struct video_device fmi_radio=
314 .vidioc_s_ctrl = vidioc_s_ctrl, 310 .vidioc_s_ctrl = vidioc_s_ctrl,
315}; 311};
316 312
313static struct video_device fmi_radio = {
314 .name = "SF16FMx radio",
315 .fops = &fmi_fops,
316 .ioctl_ops = &fmi_ioctl_ops,
317};
318
317/* ladis: this is my card. does any other types exist? */ 319/* ladis: this is my card. does any other types exist? */
318static struct isapnp_device_id id_table[] __devinitdata = { 320static struct isapnp_device_id id_table[] __devinitdata = {
319 { ISAPNP_ANY_ID, ISAPNP_ANY_ID, 321 { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index b0ccf7cb5952..6290553d24be 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -22,6 +22,7 @@
22#include <asm/uaccess.h> /* copy to/from user */ 22#include <asm/uaccess.h> /* copy to/from user */
23#include <linux/videodev2.h> /* kernel radio structs */ 23#include <linux/videodev2.h> /* kernel radio structs */
24#include <media/v4l2-common.h> 24#include <media/v4l2-common.h>
25#include <media/v4l2-ioctl.h>
25#include <linux/mutex.h> 26#include <linux/mutex.h>
26 27
27static struct mutex lock; 28static struct mutex lock;
@@ -410,12 +411,7 @@ static const struct file_operations fmr2_fops = {
410 .llseek = no_llseek, 411 .llseek = no_llseek,
411}; 412};
412 413
413static struct video_device fmr2_radio= 414static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
414{
415 .owner = THIS_MODULE,
416 .name = "SF16FMR2 radio",
417 . type = VID_TYPE_TUNER,
418 .fops = &fmr2_fops,
419 .vidioc_querycap = vidioc_querycap, 415 .vidioc_querycap = vidioc_querycap,
420 .vidioc_g_tuner = vidioc_g_tuner, 416 .vidioc_g_tuner = vidioc_g_tuner,
421 .vidioc_s_tuner = vidioc_s_tuner, 417 .vidioc_s_tuner = vidioc_s_tuner,
@@ -430,6 +426,12 @@ static struct video_device fmr2_radio=
430 .vidioc_s_ctrl = vidioc_s_ctrl, 426 .vidioc_s_ctrl = vidioc_s_ctrl,
431}; 427};
432 428
429static struct video_device fmr2_radio = {
430 .name = "SF16FMR2 radio",
431 .fops = &fmr2_fops,
432 .ioctl_ops = &fmr2_ioctl_ops,
433};
434
433static int __init fmr2_init(void) 435static int __init fmr2_init(void)
434{ 436{
435 fmr2_unit.port = io; 437 fmr2_unit.port = io;
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index dc93a882b385..a4984ff87c9c 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -133,6 +133,7 @@
133#include <linux/videodev2.h> 133#include <linux/videodev2.h>
134#include <linux/mutex.h> 134#include <linux/mutex.h>
135#include <media/v4l2-common.h> 135#include <media/v4l2-common.h>
136#include <media/v4l2-ioctl.h>
136#include <media/rds.h> 137#include <media/rds.h>
137#include <asm/unaligned.h> 138#include <asm/unaligned.h>
138 139
@@ -1585,15 +1586,7 @@ done:
1585 return retval; 1586 return retval;
1586} 1587}
1587 1588
1588 1589static const struct v4l2_ioctl_ops si470x_ioctl_ops = {
1589/*
1590 * si470x_viddev_tamples - video device interface
1591 */
1592static struct video_device si470x_viddev_template = {
1593 .fops = &si470x_fops,
1594 .name = DRIVER_NAME,
1595 .type = VID_TYPE_TUNER,
1596 .release = video_device_release,
1597 .vidioc_querycap = si470x_vidioc_querycap, 1590 .vidioc_querycap = si470x_vidioc_querycap,
1598 .vidioc_g_input = si470x_vidioc_g_input, 1591 .vidioc_g_input = si470x_vidioc_g_input,
1599 .vidioc_s_input = si470x_vidioc_s_input, 1592 .vidioc_s_input = si470x_vidioc_s_input,
@@ -1607,7 +1600,16 @@ static struct video_device si470x_viddev_template = {
1607 .vidioc_g_frequency = si470x_vidioc_g_frequency, 1600 .vidioc_g_frequency = si470x_vidioc_g_frequency,
1608 .vidioc_s_frequency = si470x_vidioc_s_frequency, 1601 .vidioc_s_frequency = si470x_vidioc_s_frequency,
1609 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek, 1602 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek,
1610 .owner = THIS_MODULE, 1603};
1604
1605/*
1606 * si470x_viddev_tamples - video device interface
1607 */
1608static struct video_device si470x_viddev_template = {
1609 .fops = &si470x_fops,
1610 .ioctl_ops = &si470x_ioctl_ops,
1611 .name = DRIVER_NAME,
1612 .release = video_device_release,
1611}; 1613};
1612 1614
1613 1615
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index acc32080e9bd..cefa44fc5aed 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -32,6 +32,7 @@
32#include <asm/uaccess.h> /* copy to/from user */ 32#include <asm/uaccess.h> /* copy to/from user */
33#include <linux/videodev2.h> /* kernel radio structs */ 33#include <linux/videodev2.h> /* kernel radio structs */
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h>
35#include <linux/spinlock.h> 36#include <linux/spinlock.h>
36 37
37#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 38#include <linux/version.h> /* for KERNEL_VERSION MACRO */
@@ -366,12 +367,7 @@ static const struct file_operations terratec_fops = {
366 .llseek = no_llseek, 367 .llseek = no_llseek,
367}; 368};
368 369
369static struct video_device terratec_radio= 370static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
370{
371 .owner = THIS_MODULE,
372 .name = "TerraTec ActiveRadio",
373 .type = VID_TYPE_TUNER,
374 .fops = &terratec_fops,
375 .vidioc_querycap = vidioc_querycap, 371 .vidioc_querycap = vidioc_querycap,
376 .vidioc_g_tuner = vidioc_g_tuner, 372 .vidioc_g_tuner = vidioc_g_tuner,
377 .vidioc_s_tuner = vidioc_s_tuner, 373 .vidioc_s_tuner = vidioc_s_tuner,
@@ -386,6 +382,12 @@ static struct video_device terratec_radio=
386 .vidioc_s_input = vidioc_s_input, 382 .vidioc_s_input = vidioc_s_input,
387}; 383};
388 384
385static struct video_device terratec_radio = {
386 .name = "TerraTec ActiveRadio",
387 .fops = &terratec_fops,
388 .ioctl_ops = &terratec_ioctl_ops,
389};
390
389static int __init terratec_init(void) 391static int __init terratec_init(void)
390{ 392{
391 if(io==-1) 393 if(io==-1)
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 4ebdfbadeb9c..d70172d23edb 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -23,6 +23,7 @@
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26 27
27#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 28#include <linux/version.h> /* for KERNEL_VERSION MACRO */
28#define RADIO_VERSION KERNEL_VERSION(0,0,2) 29#define RADIO_VERSION KERNEL_VERSION(0,0,2)
@@ -346,12 +347,7 @@ static const struct file_operations trust_fops = {
346 .llseek = no_llseek, 347 .llseek = no_llseek,
347}; 348};
348 349
349static struct video_device trust_radio= 350static const struct v4l2_ioctl_ops trust_ioctl_ops = {
350{
351 .owner = THIS_MODULE,
352 .name = "Trust FM Radio",
353 .type = VID_TYPE_TUNER,
354 .fops = &trust_fops,
355 .vidioc_querycap = vidioc_querycap, 351 .vidioc_querycap = vidioc_querycap,
356 .vidioc_g_tuner = vidioc_g_tuner, 352 .vidioc_g_tuner = vidioc_g_tuner,
357 .vidioc_s_tuner = vidioc_s_tuner, 353 .vidioc_s_tuner = vidioc_s_tuner,
@@ -366,6 +362,12 @@ static struct video_device trust_radio=
366 .vidioc_s_input = vidioc_s_input, 362 .vidioc_s_input = vidioc_s_input,
367}; 363};
368 364
365static struct video_device trust_radio = {
366 .name = "Trust FM Radio",
367 .fops = &trust_fops,
368 .ioctl_ops = &trust_ioctl_ops,
369};
370
369static int __init trust_init(void) 371static int __init trust_init(void)
370{ 372{
371 if(io == -1) { 373 if(io == -1) {
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 18f2abd7e255..f8d62cfea774 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -40,6 +40,7 @@
40#include <asm/uaccess.h> /* copy to/from user */ 40#include <asm/uaccess.h> /* copy to/from user */
41#include <linux/videodev2.h> /* kernel radio structs */ 41#include <linux/videodev2.h> /* kernel radio structs */
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h>
43 44
44#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 45#include <linux/version.h> /* for KERNEL_VERSION MACRO */
45#define RADIO_VERSION KERNEL_VERSION(0,1,1) 46#define RADIO_VERSION KERNEL_VERSION(0,1,1)
@@ -344,12 +345,7 @@ static const struct file_operations typhoon_fops = {
344 .llseek = no_llseek, 345 .llseek = no_llseek,
345}; 346};
346 347
347static struct video_device typhoon_radio = 348static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
348{
349 .owner = THIS_MODULE,
350 .name = "Typhoon Radio",
351 .type = VID_TYPE_TUNER,
352 .fops = &typhoon_fops,
353 .vidioc_querycap = vidioc_querycap, 349 .vidioc_querycap = vidioc_querycap,
354 .vidioc_g_tuner = vidioc_g_tuner, 350 .vidioc_g_tuner = vidioc_g_tuner,
355 .vidioc_s_tuner = vidioc_s_tuner, 351 .vidioc_s_tuner = vidioc_s_tuner,
@@ -364,6 +360,12 @@ static struct video_device typhoon_radio =
364 .vidioc_s_ctrl = vidioc_s_ctrl, 360 .vidioc_s_ctrl = vidioc_s_ctrl,
365}; 361};
366 362
363static struct video_device typhoon_radio = {
364 .name = "Typhoon Radio",
365 .fops = &typhoon_fops,
366 .ioctl_ops = &typhoon_ioctl_ops,
367};
368
367#ifdef CONFIG_RADIO_TYPHOON_PROC_FS 369#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
368 370
369static int typhoon_proc_show(struct seq_file *m, void *v) 371static int typhoon_proc_show(struct seq_file *m, void *v)
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 43773c56c62f..9f17a332fa11 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -37,6 +37,7 @@
37#include <asm/uaccess.h> /* copy to/from user */ 37#include <asm/uaccess.h> /* copy to/from user */
38#include <linux/videodev2.h> /* kernel radio structs */ 38#include <linux/videodev2.h> /* kernel radio structs */
39#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
40#include <media/v4l2-ioctl.h>
40 41
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 42#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42#define RADIO_VERSION KERNEL_VERSION(0,0,2) 43#define RADIO_VERSION KERNEL_VERSION(0,0,2)
@@ -407,12 +408,7 @@ static const struct file_operations zoltrix_fops =
407 .llseek = no_llseek, 408 .llseek = no_llseek,
408}; 409};
409 410
410static struct video_device zoltrix_radio = 411static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = {
411{
412 .owner = THIS_MODULE,
413 .name = "Zoltrix Radio Plus",
414 .type = VID_TYPE_TUNER,
415 .fops = &zoltrix_fops,
416 .vidioc_querycap = vidioc_querycap, 412 .vidioc_querycap = vidioc_querycap,
417 .vidioc_g_tuner = vidioc_g_tuner, 413 .vidioc_g_tuner = vidioc_g_tuner,
418 .vidioc_s_tuner = vidioc_s_tuner, 414 .vidioc_s_tuner = vidioc_s_tuner,
@@ -427,6 +423,12 @@ static struct video_device zoltrix_radio =
427 .vidioc_s_ctrl = vidioc_s_ctrl, 423 .vidioc_s_ctrl = vidioc_s_ctrl,
428}; 424};
429 425
426static struct video_device zoltrix_radio = {
427 .name = "Zoltrix Radio Plus",
428 .fops = &zoltrix_fops,
429 .ioctl_ops = &zoltrix_ioctl_ops,
430};
431
430static int __init zoltrix_init(void) 432static int __init zoltrix_init(void)
431{ 433{
432 if (io == -1) { 434 if (io == -1) {
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f606d2951fde..d4a6e56a7135 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -487,17 +487,6 @@ config VIDEO_PMS
487 To compile this driver as a module, choose M here: the 487 To compile this driver as a module, choose M here: the
488 module will be called pms. 488 module will be called pms.
489 489
490config VIDEO_PLANB
491 tristate "PlanB Video-In on PowerMac"
492 depends on PPC_PMAC && VIDEO_V4L1 && BROKEN
493 help
494 PlanB is the V4L driver for the PowerMac 7x00/8x00 series video
495 input hardware. If you want to experiment with this, say Y.
496 Otherwise, or if you don't understand a word, say N. See
497 <http://www.cpu.lu/~mlan/linux/dev/planb.html> for more info.
498
499 Saying M will compile this driver as a module (planb).
500
501config VIDEO_BWQCAM 490config VIDEO_BWQCAM
502 tristate "Quickcam BW Video For Linux" 491 tristate "Quickcam BW Video For Linux"
503 depends on PARPORT && VIDEO_V4L1 492 depends on PARPORT && VIDEO_V4L1
@@ -806,13 +795,7 @@ menuconfig V4L_USB_DRIVERS
806 795
807if V4L_USB_DRIVERS && USB 796if V4L_USB_DRIVERS && USB
808 797
809config USB_VIDEO_CLASS 798source "drivers/media/video/uvc/Kconfig"
810 tristate "USB Video Class (UVC)"
811 ---help---
812 Support for the USB Video Class (UVC). Currently only video
813 input devices, such as webcams, are supported.
814
815 For more information see: <http://linux-uvc.berlios.de/>
816 799
817source "drivers/media/video/gspca/Kconfig" 800source "drivers/media/video/gspca/Kconfig"
818 801
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 45d5db5abb1e..bbc6f8b82297 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -10,6 +10,8 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
10 10
11stkwebcam-objs := stk-webcam.o stk-sensor.o 11stkwebcam-objs := stk-webcam.o stk-sensor.o
12 12
13videodev-objs := v4l2-dev.o v4l2-ioctl.o
14
13obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o 15obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o
14 16
15obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o 17obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o
@@ -55,7 +57,6 @@ obj-$(CONFIG_VIDEO_ZORAN_DC30) += zr36050.o zr36016.o
55obj-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o 57obj-$(CONFIG_VIDEO_ZORAN_ZR36060) += zr36060.o
56 58
57obj-$(CONFIG_VIDEO_PMS) += pms.o 59obj-$(CONFIG_VIDEO_PMS) += pms.o
58obj-$(CONFIG_VIDEO_PLANB) += planb.o
59obj-$(CONFIG_VIDEO_VINO) += vino.o indycam.o 60obj-$(CONFIG_VIDEO_VINO) += vino.o indycam.o
60obj-$(CONFIG_VIDEO_STRADIS) += stradis.o 61obj-$(CONFIG_VIDEO_STRADIS) += stradis.o
61obj-$(CONFIG_VIDEO_CPIA) += cpia.o 62obj-$(CONFIG_VIDEO_CPIA) += cpia.o
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 8c7d1958856b..56ebfd5ef6fa 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -754,7 +754,6 @@ static const struct file_operations ar_fops = {
754}; 754};
755 755
756static struct video_device ar_template = { 756static struct video_device ar_template = {
757 .owner = THIS_MODULE,
758 .name = "Colour AR VGA", 757 .name = "Colour AR VGA",
759 .type = VID_TYPE_CAPTURE, 758 .type = VID_TYPE_CAPTURE,
760 .fops = &ar_fops, 759 .fops = &ar_fops,
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig
index 52b2491581a8..ed9a50f189fc 100644
--- a/drivers/media/video/au0828/Kconfig
+++ b/drivers/media/video/au0828/Kconfig
@@ -6,6 +6,7 @@ config VIDEO_AU0828
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE 7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE
8 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE 8 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
9 select MEDIA_TUNER_MXL5007T if !DVB_FE_CUSTOMIZE
9 ---help--- 10 ---help---
10 This is a video4linux driver for Auvitek's USB device. 11 This is a video4linux driver for Auvitek's USB device.
11 12
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c
index 898e12395e7c..443e59009762 100644
--- a/drivers/media/video/au0828/au0828-cards.c
+++ b/drivers/media/video/au0828/au0828-cards.c
@@ -32,6 +32,9 @@ struct au0828_board au0828_boards[] = {
32 [AU0828_BOARD_HAUPPAUGE_HVR950Q] = { 32 [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
33 .name = "Hauppauge HVR950Q", 33 .name = "Hauppauge HVR950Q",
34 }, 34 },
35 [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = {
36 .name = "Hauppauge HVR950Q rev xxF8",
37 },
35 [AU0828_BOARD_DVICO_FUSIONHDTV7] = { 38 [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
36 .name = "DViCO FusionHDTV USB", 39 .name = "DViCO FusionHDTV USB",
37 }, 40 },
@@ -49,6 +52,7 @@ int au0828_tuner_callback(void *priv, int command, int arg)
49 switch (dev->board) { 52 switch (dev->board) {
50 case AU0828_BOARD_HAUPPAUGE_HVR850: 53 case AU0828_BOARD_HAUPPAUGE_HVR850:
51 case AU0828_BOARD_HAUPPAUGE_HVR950Q: 54 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
55 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
52 case AU0828_BOARD_DVICO_FUSIONHDTV7: 56 case AU0828_BOARD_DVICO_FUSIONHDTV7:
53 if (command == 0) { 57 if (command == 0) {
54 /* Tuner Reset Command from xc5000 */ 58 /* Tuner Reset Command from xc5000 */
@@ -110,6 +114,7 @@ void au0828_card_setup(struct au0828_dev *dev)
110 switch (dev->board) { 114 switch (dev->board) {
111 case AU0828_BOARD_HAUPPAUGE_HVR850: 115 case AU0828_BOARD_HAUPPAUGE_HVR850:
112 case AU0828_BOARD_HAUPPAUGE_HVR950Q: 116 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
117 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
113 if (dev->i2c_rc == 0) 118 if (dev->i2c_rc == 0)
114 hauppauge_eeprom(dev, eeprom+0xa0); 119 hauppauge_eeprom(dev, eeprom+0xa0);
115 break; 120 break;
@@ -128,6 +133,7 @@ void au0828_gpio_setup(struct au0828_dev *dev)
128 switch (dev->board) { 133 switch (dev->board) {
129 case AU0828_BOARD_HAUPPAUGE_HVR850: 134 case AU0828_BOARD_HAUPPAUGE_HVR850:
130 case AU0828_BOARD_HAUPPAUGE_HVR950Q: 135 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
136 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
131 /* GPIO's 137 /* GPIO's
132 * 4 - CS5340 138 * 4 - CS5340
133 * 5 - AU8522 Demodulator 139 * 5 - AU8522 Demodulator
@@ -193,6 +199,12 @@ struct usb_device_id au0828_usb_id_table [] = {
193 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 199 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
194 { USB_DEVICE(0x0fd9, 0x0008), 200 { USB_DEVICE(0x0fd9, 0x0008),
195 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, 201 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
202 { USB_DEVICE(0x2040, 0x7201),
203 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
204 { USB_DEVICE(0x2040, 0x7211),
205 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
206 { USB_DEVICE(0x2040, 0x7281),
207 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
196 { }, 208 { },
197}; 209};
198 210
diff --git a/drivers/media/video/au0828/au0828-cards.h b/drivers/media/video/au0828/au0828-cards.h
index e26f54a961d0..c37f5fd0fa80 100644
--- a/drivers/media/video/au0828/au0828-cards.h
+++ b/drivers/media/video/au0828/au0828-cards.h
@@ -23,3 +23,4 @@
23#define AU0828_BOARD_HAUPPAUGE_HVR950Q 1 23#define AU0828_BOARD_HAUPPAUGE_HVR950Q 1
24#define AU0828_BOARD_HAUPPAUGE_HVR850 2 24#define AU0828_BOARD_HAUPPAUGE_HVR850 2
25#define AU0828_BOARD_DVICO_FUSIONHDTV7 3 25#define AU0828_BOARD_DVICO_FUSIONHDTV7 3
26#define AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL 4
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index c6d470590380..584a83a94a2a 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -28,6 +28,7 @@
28#include "au0828.h" 28#include "au0828.h"
29#include "au8522.h" 29#include "au8522.h"
30#include "xc5000.h" 30#include "xc5000.h"
31#include "mxl5007t.h"
31 32
32DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 33DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
33 34
@@ -45,6 +46,11 @@ static struct xc5000_config hauppauge_hvr950q_tunerconfig = {
45 .tuner_callback = au0828_tuner_callback 46 .tuner_callback = au0828_tuner_callback
46}; 47};
47 48
49static struct mxl5007t_config mxl5007t_hvr950q_config = {
50 .xtal_freq_hz = MxL_XTAL_24_MHZ,
51 .if_freq_hz = MxL_IF_6_MHZ,
52};
53
48/*-------------------------------------------------------------------*/ 54/*-------------------------------------------------------------------*/
49static void urb_completion(struct urb *purb) 55static void urb_completion(struct urb *purb)
50{ 56{
@@ -342,6 +348,15 @@ int au0828_dvb_register(struct au0828_dev *dev)
342 &dev->i2c_adap, 348 &dev->i2c_adap,
343 &hauppauge_hvr950q_tunerconfig, dev); 349 &hauppauge_hvr950q_tunerconfig, dev);
344 break; 350 break;
351 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
352 dvb->frontend = dvb_attach(au8522_attach,
353 &hauppauge_hvr950q_config,
354 &dev->i2c_adap);
355 if (dvb->frontend != NULL)
356 dvb_attach(mxl5007t_attach, dvb->frontend,
357 &dev->i2c_adap, 0x60,
358 &mxl5007t_hvr950q_config);
359 break;
345 default: 360 default:
346 printk(KERN_WARNING "The frontend of your DVB/ATSC card " 361 printk(KERN_WARNING "The frontend of your DVB/ATSC card "
347 "isn't supported yet\n"); 362 "isn't supported yet\n");
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 24a34fc1f2b3..ce71e8e7b835 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,9 +1,7 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT
4 depends on HOTPLUG # due to FW_LOADER
5 select I2C_ALGOBIT 4 select I2C_ALGOBIT
6 select FW_LOADER
7 select VIDEO_BTCX 5 select VIDEO_BTCX
8 select VIDEOBUF_DMA_SG 6 select VIDEOBUF_DMA_SG
9 select VIDEO_IR 7 select VIDEO_IR
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 0ea559a7fe59..85bf31ab8789 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -45,6 +45,7 @@
45#include <linux/kdev_t.h> 45#include <linux/kdev_t.h>
46#include "bttvp.h" 46#include "bttvp.h"
47#include <media/v4l2-common.h> 47#include <media/v4l2-common.h>
48#include <media/v4l2-ioctl.h>
48#include <media/tvaudio.h> 49#include <media/tvaudio.h>
49#include <media/msp3400.h> 50#include <media/msp3400.h>
50 51
@@ -163,8 +164,8 @@ MODULE_LICENSE("GPL");
163static ssize_t show_card(struct device *cd, 164static ssize_t show_card(struct device *cd,
164 struct device_attribute *attr, char *buf) 165 struct device_attribute *attr, char *buf)
165{ 166{
166 struct video_device *vfd = container_of(cd, struct video_device, class_dev); 167 struct video_device *vfd = container_of(cd, struct video_device, dev);
167 struct bttv *btv = dev_get_drvdata(vfd->dev); 168 struct bttv *btv = dev_get_drvdata(vfd->parent);
168 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); 169 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
169} 170}
170static DEVICE_ATTR(card, S_IRUGO, show_card, NULL); 171static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
@@ -3357,10 +3358,7 @@ static const struct file_operations bttv_fops =
3357 .poll = bttv_poll, 3358 .poll = bttv_poll,
3358}; 3359};
3359 3360
3360static struct video_device bttv_video_template = 3361static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3361{
3362 .fops = &bttv_fops,
3363 .minor = -1,
3364 .vidioc_querycap = bttv_querycap, 3362 .vidioc_querycap = bttv_querycap,
3365 .vidioc_enum_fmt_vid_cap = bttv_enum_fmt_vid_cap, 3363 .vidioc_enum_fmt_vid_cap = bttv_enum_fmt_vid_cap,
3366 .vidioc_g_fmt_vid_cap = bttv_g_fmt_vid_cap, 3364 .vidioc_g_fmt_vid_cap = bttv_g_fmt_vid_cap,
@@ -3411,8 +3409,14 @@ static struct video_device bttv_video_template =
3411 .vidioc_g_register = bttv_g_register, 3409 .vidioc_g_register = bttv_g_register,
3412 .vidioc_s_register = bttv_s_register, 3410 .vidioc_s_register = bttv_s_register,
3413#endif 3411#endif
3414 .tvnorms = BTTV_NORMS, 3412};
3415 .current_norm = V4L2_STD_PAL, 3413
3414static struct video_device bttv_video_template = {
3415 .fops = &bttv_fops,
3416 .minor = -1,
3417 .ioctl_ops = &bttv_ioctl_ops,
3418 .tvnorms = BTTV_NORMS,
3419 .current_norm = V4L2_STD_PAL,
3416}; 3420};
3417 3421
3418/* ----------------------------------------------------------------------- */ 3422/* ----------------------------------------------------------------------- */
@@ -3635,10 +3639,7 @@ static const struct file_operations radio_fops =
3635 .poll = radio_poll, 3639 .poll = radio_poll,
3636}; 3640};
3637 3641
3638static struct video_device radio_template = 3642static const struct v4l2_ioctl_ops radio_ioctl_ops = {
3639{
3640 .fops = &radio_fops,
3641 .minor = -1,
3642 .vidioc_querycap = radio_querycap, 3643 .vidioc_querycap = radio_querycap,
3643 .vidioc_g_tuner = radio_g_tuner, 3644 .vidioc_g_tuner = radio_g_tuner,
3644 .vidioc_enum_input = radio_enum_input, 3645 .vidioc_enum_input = radio_enum_input,
@@ -3655,6 +3656,12 @@ static struct video_device radio_template =
3655 .vidioc_s_frequency = bttv_s_frequency, 3656 .vidioc_s_frequency = bttv_s_frequency,
3656}; 3657};
3657 3658
3659static struct video_device radio_template = {
3660 .fops = &radio_fops,
3661 .minor = -1,
3662 .ioctl_ops = &radio_ioctl_ops,
3663};
3664
3658/* ----------------------------------------------------------------------- */ 3665/* ----------------------------------------------------------------------- */
3659/* some debug code */ 3666/* some debug code */
3660 3667
@@ -4175,8 +4182,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
4175 4182
4176static struct video_device *vdev_init(struct bttv *btv, 4183static struct video_device *vdev_init(struct bttv *btv,
4177 const struct video_device *template, 4184 const struct video_device *template,
4178 const char *type_name, 4185 const char *type_name)
4179 const int type)
4180{ 4186{
4181 struct video_device *vfd; 4187 struct video_device *vfd;
4182 4188
@@ -4185,9 +4191,8 @@ static struct video_device *vdev_init(struct bttv *btv,
4185 return NULL; 4191 return NULL;
4186 *vfd = *template; 4192 *vfd = *template;
4187 vfd->minor = -1; 4193 vfd->minor = -1;
4188 vfd->dev = &btv->c.pci->dev; 4194 vfd->parent = &btv->c.pci->dev;
4189 vfd->release = video_device_release; 4195 vfd->release = video_device_release;
4190 vfd->type = type;
4191 vfd->debug = bttv_debug; 4196 vfd->debug = bttv_debug;
4192 snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)", 4197 snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)",
4193 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", 4198 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "",
@@ -4223,20 +4228,11 @@ static void bttv_unregister_video(struct bttv *btv)
4223/* register video4linux devices */ 4228/* register video4linux devices */
4224static int __devinit bttv_register_video(struct bttv *btv) 4229static int __devinit bttv_register_video(struct bttv *btv)
4225{ 4230{
4226 int video_type = VID_TYPE_CAPTURE | 4231 if (no_overlay > 0)
4227 VID_TYPE_TUNER |
4228 VID_TYPE_CLIPPING|
4229 VID_TYPE_SCALES;
4230
4231 if (no_overlay <= 0) {
4232 bttv_video_template.type |= VID_TYPE_OVERLAY;
4233 } else {
4234 printk("bttv: Overlay support disabled.\n"); 4232 printk("bttv: Overlay support disabled.\n");
4235 }
4236 4233
4237 /* video */ 4234 /* video */
4238 btv->video_dev = vdev_init(btv, &bttv_video_template, 4235 btv->video_dev = vdev_init(btv, &bttv_video_template, "video");
4239 "video", video_type);
4240 4236
4241 if (NULL == btv->video_dev) 4237 if (NULL == btv->video_dev)
4242 goto err; 4238 goto err;
@@ -4244,7 +4240,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4244 goto err; 4240 goto err;
4245 printk(KERN_INFO "bttv%d: registered device video%d\n", 4241 printk(KERN_INFO "bttv%d: registered device video%d\n",
4246 btv->c.nr,btv->video_dev->minor & 0x1f); 4242 btv->c.nr,btv->video_dev->minor & 0x1f);
4247 if (device_create_file(&btv->video_dev->class_dev, 4243 if (device_create_file(&btv->video_dev->dev,
4248 &dev_attr_card)<0) { 4244 &dev_attr_card)<0) {
4249 printk(KERN_ERR "bttv%d: device_create_file 'card' " 4245 printk(KERN_ERR "bttv%d: device_create_file 'card' "
4250 "failed\n", btv->c.nr); 4246 "failed\n", btv->c.nr);
@@ -4252,8 +4248,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4252 } 4248 }
4253 4249
4254 /* vbi */ 4250 /* vbi */
4255 btv->vbi_dev = vdev_init(btv, &bttv_video_template, 4251 btv->vbi_dev = vdev_init(btv, &bttv_video_template, "vbi");
4256 "vbi", VID_TYPE_TUNER | VID_TYPE_TELETEXT);
4257 4252
4258 if (NULL == btv->vbi_dev) 4253 if (NULL == btv->vbi_dev)
4259 goto err; 4254 goto err;
@@ -4265,8 +4260,7 @@ static int __devinit bttv_register_video(struct bttv *btv)
4265 if (!btv->has_radio) 4260 if (!btv->has_radio)
4266 return 0; 4261 return 0;
4267 /* radio */ 4262 /* radio */
4268 btv->radio_dev = vdev_init(btv, &radio_template, 4263 btv->radio_dev = vdev_init(btv, &radio_template, "radio");
4269 "radio", VID_TYPE_TUNER);
4270 if (NULL == btv->radio_dev) 4264 if (NULL == btv->radio_dev)
4271 goto err; 4265 goto err;
4272 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,radio_nr)<0) 4266 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,radio_nr)<0)
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index 0af586876e72..649682aac1ac 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <asm/page.h> 32#include <asm/page.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <media/v4l2-ioctl.h>
34 35
35#include "bttvp.h" 36#include "bttvp.h"
36 37
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 68f28e5fa040..6819e21a3773 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/kdev_t.h> 31#include <linux/kdev_t.h>
32#include <media/v4l2-ioctl.h>
32#include <asm/io.h> 33#include <asm/io.h>
33#include "bttvp.h" 34#include "bttvp.h"
34 35
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index b364adaae78d..d3b3268bace8 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -74,6 +74,7 @@ OTHER DEALINGS IN THE SOFTWARE.
74#include <linux/sched.h> 74#include <linux/sched.h>
75#include <linux/videodev.h> 75#include <linux/videodev.h>
76#include <media/v4l2-common.h> 76#include <media/v4l2-common.h>
77#include <media/v4l2-ioctl.h>
77#include <linux/mutex.h> 78#include <linux/mutex.h>
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
79 80
@@ -906,9 +907,7 @@ static const struct file_operations qcam_fops = {
906}; 907};
907static struct video_device qcam_template= 908static struct video_device qcam_template=
908{ 909{
909 .owner = THIS_MODULE,
910 .name = "Connectix Quickcam", 910 .name = "Connectix Quickcam",
911 .type = VID_TYPE_CAPTURE,
912 .fops = &qcam_fops, 911 .fops = &qcam_fops,
913}; 912};
914 913
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index fe1e67bb1ca8..fe9379b282d3 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -35,6 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/videodev.h> 36#include <linux/videodev.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38#include <linux/mutex.h> 39#include <linux/mutex.h>
39#include <linux/jiffies.h> 40#include <linux/jiffies.h>
40 41
@@ -701,9 +702,7 @@ static const struct file_operations qcam_fops = {
701 702
702static struct video_device qcam_template= 703static struct video_device qcam_template=
703{ 704{
704 .owner = THIS_MODULE,
705 .name = "Colour QuickCam", 705 .name = "Colour QuickCam",
706 .type = VID_TYPE_CAPTURE,
707 .fops = &qcam_fops, 706 .fops = &qcam_fops,
708}; 707};
709 708
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index d99453faaab7..c149b7d712e5 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -25,6 +25,7 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <media/v4l2-chip-ident.h> 29#include <media/v4l2-chip-ident.h>
29#include <linux/device.h> 30#include <linux/device.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
@@ -1768,17 +1769,7 @@ static const struct file_operations cafe_v4l_fops = {
1768 .llseek = no_llseek, 1769 .llseek = no_llseek,
1769}; 1770};
1770 1771
1771static struct video_device cafe_v4l_template = { 1772static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
1772 .name = "cafe",
1773 .type = VFL_TYPE_GRABBER,
1774 .type2 = VID_TYPE_CAPTURE,
1775 .minor = -1, /* Get one dynamically */
1776 .tvnorms = V4L2_STD_NTSC_M,
1777 .current_norm = V4L2_STD_NTSC_M, /* make mplayer happy */
1778
1779 .fops = &cafe_v4l_fops,
1780 .release = cafe_v4l_dev_release,
1781
1782 .vidioc_querycap = cafe_vidioc_querycap, 1773 .vidioc_querycap = cafe_vidioc_querycap,
1783 .vidioc_enum_fmt_vid_cap = cafe_vidioc_enum_fmt_vid_cap, 1774 .vidioc_enum_fmt_vid_cap = cafe_vidioc_enum_fmt_vid_cap,
1784 .vidioc_try_fmt_vid_cap = cafe_vidioc_try_fmt_vid_cap, 1775 .vidioc_try_fmt_vid_cap = cafe_vidioc_try_fmt_vid_cap,
@@ -1801,6 +1792,17 @@ static struct video_device cafe_v4l_template = {
1801 .vidioc_s_parm = cafe_vidioc_s_parm, 1792 .vidioc_s_parm = cafe_vidioc_s_parm,
1802}; 1793};
1803 1794
1795static struct video_device cafe_v4l_template = {
1796 .name = "cafe",
1797 .minor = -1, /* Get one dynamically */
1798 .tvnorms = V4L2_STD_NTSC_M,
1799 .current_norm = V4L2_STD_NTSC_M, /* make mplayer happy */
1800
1801 .fops = &cafe_v4l_fops,
1802 .ioctl_ops = &cafe_v4l_ioctl_ops,
1803 .release = cafe_v4l_dev_release,
1804};
1805
1804 1806
1805 1807
1806 1808
@@ -2157,7 +2159,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2157 cam->v4ldev = cafe_v4l_template; 2159 cam->v4ldev = cafe_v4l_template;
2158 cam->v4ldev.debug = 0; 2160 cam->v4ldev.debug = 0;
2159// cam->v4ldev.debug = V4L2_DEBUG_IOCTL_ARG; 2161// cam->v4ldev.debug = V4L2_DEBUG_IOCTL_ARG;
2160 cam->v4ldev.dev = &pdev->dev; 2162 cam->v4ldev.parent = &pdev->dev;
2161 ret = video_register_device(&cam->v4ldev, VFL_TYPE_GRABBER, -1); 2163 ret = video_register_device(&cam->v4ldev, VFL_TYPE_GRABBER, -1);
2162 if (ret) 2164 if (ret)
2163 goto out_smbus; 2165 goto out_smbus;
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index 54de0cd482e9..bd5d9de5a008 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -17,7 +17,7 @@
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <media/v4l2-common.h> 20#include <media/v4l2-ioctl.h>
21 21
22#ifdef CONFIG_COMPAT 22#ifdef CONFIG_COMPAT
23 23
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 2a81376ef503..dc8cc6115e2f 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -3799,9 +3799,7 @@ static const struct file_operations cpia_fops = {
3799}; 3799};
3800 3800
3801static struct video_device cpia_template = { 3801static struct video_device cpia_template = {
3802 .owner = THIS_MODULE,
3803 .name = "CPiA Camera", 3802 .name = "CPiA Camera",
3804 .type = VID_TYPE_CAPTURE,
3805 .fops = &cpia_fops, 3803 .fops = &cpia_fops,
3806}; 3804};
3807 3805
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index 5096058bf579..8f0cfee4b8a1 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -46,6 +46,7 @@
46#include <asm/uaccess.h> 46#include <asm/uaccess.h>
47#include <linux/videodev.h> 47#include <linux/videodev.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/list.h> 50#include <linux/list.h>
50#include <linux/mutex.h> 51#include <linux/mutex.h>
51 52
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c
index f2e8b1c82c66..af8b9ec8e358 100644
--- a/drivers/media/video/cpia2/cpia2_core.c
+++ b/drivers/media/video/cpia2/cpia2_core.c
@@ -32,6 +32,7 @@
32#include "cpia2.h" 32#include "cpia2.h"
33 33
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/mm.h>
35#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
36#include <linux/firmware.h> 37#include <linux/firmware.h>
37 38
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 7ce2789fa976..515c8b57a60d 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -37,6 +37,7 @@
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <media/v4l2-ioctl.h>
40 41
41#include "cpia2.h" 42#include "cpia2.h"
42#include "cpia2dev.h" 43#include "cpia2dev.h"
@@ -1935,11 +1936,7 @@ static const struct file_operations fops_template = {
1935 1936
1936static struct video_device cpia2_template = { 1937static struct video_device cpia2_template = {
1937 /* I could not find any place for the old .initialize initializer?? */ 1938 /* I could not find any place for the old .initialize initializer?? */
1938 .owner= THIS_MODULE,
1939 .name= "CPiA2 Camera", 1939 .name= "CPiA2 Camera",
1940 .type= VID_TYPE_CAPTURE,
1941 .type2 = V4L2_CAP_VIDEO_CAPTURE |
1942 V4L2_CAP_STREAMING,
1943 .minor= -1, 1940 .minor= -1,
1944 .fops= &fops_template, 1941 .fops= &fops_template,
1945 .release= video_device_release, 1942 .release= video_device_release,
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 1c3fa3a7470a..61d14d26686f 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -111,7 +111,7 @@ static int cs5345_command(struct i2c_client *client, unsigned cmd, void *arg)
111 if (cmd == VIDIOC_DBG_G_REGISTER) 111 if (cmd == VIDIOC_DBG_G_REGISTER)
112 reg->val = cs5345_read(client, reg->reg & 0x1f); 112 reg->val = cs5345_read(client, reg->reg & 0x1f);
113 else 113 else
114 cs5345_write(client, reg->reg & 0x1f, reg->val & 0x1f); 114 cs5345_write(client, reg->reg & 0x1f, reg->val & 0xff);
115 break; 115 break;
116 } 116 }
117#endif 117#endif
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 645b339152d3..e30a589c0e18 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -26,7 +26,7 @@
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c-id.h> 28#include <linux/i2c-id.h>
29#include <linux/videodev.h> 29#include <linux/videodev2.h>
30#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
31#include <media/v4l2-chip-ident.h> 31#include <media/v4l2-chip-ident.h>
32#include <media/v4l2-i2c-drv-legacy.h> 32#include <media/v4l2-i2c-drv-legacy.h>
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig
index 9aefdc5ea79a..ef48565de7f1 100644
--- a/drivers/media/video/cx18/Kconfig
+++ b/drivers/media/video/cx18/Kconfig
@@ -2,9 +2,7 @@ config VIDEO_CX18
2 tristate "Conexant cx23418 MPEG encoder support" 2 tristate "Conexant cx23418 MPEG encoder support"
3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR 4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
6 select I2C_ALGOBIT 5 select I2C_ALGOBIT
7 select FW_LOADER
8 select VIDEO_IR 6 select VIDEO_IR
9 select VIDEO_TUNER 7 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/cx18/cx18-av-audio.c b/drivers/media/video/cx18/cx18-av-audio.c
index c40a286de1b9..0b55837880a7 100644
--- a/drivers/media/video/cx18/cx18-av-audio.c
+++ b/drivers/media/video/cx18/cx18-av-audio.c
@@ -30,7 +30,6 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
30 if (freq != 32000 && freq != 44100 && freq != 48000) 30 if (freq != 32000 && freq != 44100 && freq != 48000)
31 return -EINVAL; 31 return -EINVAL;
32 32
33 /* common for all inputs and rates */
34 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ 33 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
35 cx18_av_write(cx, 0x127, 0x50); 34 cx18_av_write(cx, 0x127, 0x50);
36 35
@@ -38,15 +37,30 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
38 switch (freq) { 37 switch (freq) {
39 case 32000: 38 case 32000:
40 /* VID_PLL and AUX_PLL */ 39 /* VID_PLL and AUX_PLL */
41 cx18_av_write4(cx, 0x108, 0x1006040f); 40 cx18_av_write4(cx, 0x108, 0x1408040f);
42 41
43 /* AUX_PLL_FRAC */ 42 /* AUX_PLL_FRAC */
44 cx18_av_write4(cx, 0x110, 0x01bb39ee); 43 /* 0x8.9504318a * 28,636,363.636 / 0x14 = 32000 * 384 */
44 cx18_av_write4(cx, 0x110, 0x012a0863);
45 45
46 /* src3/4/6_ctl = 0x0801f77f */ 46 /* src3/4/6_ctl */
47 /* 0x1.f77f = (4 * 15734.26) / 32000 */
47 cx18_av_write4(cx, 0x900, 0x0801f77f); 48 cx18_av_write4(cx, 0x900, 0x0801f77f);
48 cx18_av_write4(cx, 0x904, 0x0801f77f); 49 cx18_av_write4(cx, 0x904, 0x0801f77f);
49 cx18_av_write4(cx, 0x90c, 0x0801f77f); 50 cx18_av_write4(cx, 0x90c, 0x0801f77f);
51
52 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
53 cx18_av_write(cx, 0x127, 0x54);
54
55 /* AUD_COUNT = 0x2fff = 8 samples * 4 * 384 - 1 */
56 cx18_av_write4(cx, 0x12c, 0x11202fff);
57
58 /*
59 * EN_AV_LOCK = 1
60 * VID_COUNT = 0x0d2ef8 = 107999.000 * 8 =
61 * ((8 samples/32,000) * (13,500,000 * 8) * 4 - 1) * 8
62 */
63 cx18_av_write4(cx, 0x128, 0xa10d2ef8);
50 break; 64 break;
51 65
52 case 44100: 66 case 44100:
@@ -54,12 +68,24 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
54 cx18_av_write4(cx, 0x108, 0x1009040f); 68 cx18_av_write4(cx, 0x108, 0x1009040f);
55 69
56 /* AUX_PLL_FRAC */ 70 /* AUX_PLL_FRAC */
57 cx18_av_write4(cx, 0x110, 0x00ec6bd6); 71 /* 0x9.7635e7 * 28,636,363.63 / 0x10 = 44100 * 384 */
72 cx18_av_write4(cx, 0x110, 0x00ec6bce);
58 73
59 /* src3/4/6_ctl = 0x08016d59 */ 74 /* src3/4/6_ctl */
75 /* 0x1.6d59 = (4 * 15734.26) / 44100 */
60 cx18_av_write4(cx, 0x900, 0x08016d59); 76 cx18_av_write4(cx, 0x900, 0x08016d59);
61 cx18_av_write4(cx, 0x904, 0x08016d59); 77 cx18_av_write4(cx, 0x904, 0x08016d59);
62 cx18_av_write4(cx, 0x90c, 0x08016d59); 78 cx18_av_write4(cx, 0x90c, 0x08016d59);
79
80 /* AUD_COUNT = 0x92ff = 49 samples * 2 * 384 - 1 */
81 cx18_av_write4(cx, 0x12c, 0x112092ff);
82
83 /*
84 * EN_AV_LOCK = 1
85 * VID_COUNT = 0x1d4bf8 = 239999.000 * 8 =
86 * ((49 samples/44,100) * (13,500,000 * 8) * 2 - 1) * 8
87 */
88 cx18_av_write4(cx, 0x128, 0xa11d4bf8);
63 break; 89 break;
64 90
65 case 48000: 91 case 48000:
@@ -67,12 +93,24 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
67 cx18_av_write4(cx, 0x108, 0x100a040f); 93 cx18_av_write4(cx, 0x108, 0x100a040f);
68 94
69 /* AUX_PLL_FRAC */ 95 /* AUX_PLL_FRAC */
70 cx18_av_write4(cx, 0x110, 0x0098d6e5); 96 /* 0xa.4c6b6ea * 28,636,363.63 / 0x10 = 48000 * 384 */
97 cx18_av_write4(cx, 0x110, 0x0098d6dd);
71 98
72 /* src3/4/6_ctl = 0x08014faa */ 99 /* src3/4/6_ctl */
100 /* 0x1.4faa = (4 * 15734.26) / 48000 */
73 cx18_av_write4(cx, 0x900, 0x08014faa); 101 cx18_av_write4(cx, 0x900, 0x08014faa);
74 cx18_av_write4(cx, 0x904, 0x08014faa); 102 cx18_av_write4(cx, 0x904, 0x08014faa);
75 cx18_av_write4(cx, 0x90c, 0x08014faa); 103 cx18_av_write4(cx, 0x90c, 0x08014faa);
104
105 /* AUD_COUNT = 0x5fff = 4 samples * 16 * 384 - 1 */
106 cx18_av_write4(cx, 0x12c, 0x11205fff);
107
108 /*
109 * EN_AV_LOCK = 1
110 * VID_COUNT = 0x1193f8 = 143999.000 * 8 =
111 * ((4 samples/48,000) * (13,500,000 * 8) * 16 - 1) * 8
112 */
113 cx18_av_write4(cx, 0x128, 0xa11193f8);
76 break; 114 break;
77 } 115 }
78 } else { 116 } else {
@@ -82,18 +120,31 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
82 cx18_av_write4(cx, 0x108, 0x1e08040f); 120 cx18_av_write4(cx, 0x108, 0x1e08040f);
83 121
84 /* AUX_PLL_FRAC */ 122 /* AUX_PLL_FRAC */
85 cx18_av_write4(cx, 0x110, 0x012a0869); 123 /* 0x8.9504318 * 28,636,363.63 / 0x1e = 32000 * 256 */
124 cx18_av_write4(cx, 0x110, 0x012a0863);
86 125
87 /* src1_ctl = 0x08010000 */ 126 /* src1_ctl */
127 /* 0x1.0000 = 32000/32000 */
88 cx18_av_write4(cx, 0x8f8, 0x08010000); 128 cx18_av_write4(cx, 0x8f8, 0x08010000);
89 129
90 /* src3/4/6_ctl = 0x08020000 */ 130 /* src3/4/6_ctl */
131 /* 0x2.0000 = 2 * (32000/32000) */
91 cx18_av_write4(cx, 0x900, 0x08020000); 132 cx18_av_write4(cx, 0x900, 0x08020000);
92 cx18_av_write4(cx, 0x904, 0x08020000); 133 cx18_av_write4(cx, 0x904, 0x08020000);
93 cx18_av_write4(cx, 0x90c, 0x08020000); 134 cx18_av_write4(cx, 0x90c, 0x08020000);
94 135
95 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */ 136 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
96 cx18_av_write(cx, 0x127, 0x54); 137 cx18_av_write(cx, 0x127, 0x54);
138
139 /* AUD_COUNT = 0x1fff = 8 samples * 4 * 256 - 1 */
140 cx18_av_write4(cx, 0x12c, 0x11201fff);
141
142 /*
143 * EN_AV_LOCK = 1
144 * VID_COUNT = 0x0d2ef8 = 107999.000 * 8 =
145 * ((8 samples/32,000) * (13,500,000 * 8) * 4 - 1) * 8
146 */
147 cx18_av_write4(cx, 0x128, 0xa10d2ef8);
97 break; 148 break;
98 149
99 case 44100: 150 case 44100:
@@ -101,15 +152,28 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
101 cx18_av_write4(cx, 0x108, 0x1809040f); 152 cx18_av_write4(cx, 0x108, 0x1809040f);
102 153
103 /* AUX_PLL_FRAC */ 154 /* AUX_PLL_FRAC */
104 cx18_av_write4(cx, 0x110, 0x00ec6bd6); 155 /* 0x9.7635e74 * 28,636,363.63 / 0x18 = 44100 * 256 */
156 cx18_av_write4(cx, 0x110, 0x00ec6bce);
105 157
106 /* src1_ctl = 0x08010000 */ 158 /* src1_ctl */
159 /* 0x1.60cd = 44100/32000 */
107 cx18_av_write4(cx, 0x8f8, 0x080160cd); 160 cx18_av_write4(cx, 0x8f8, 0x080160cd);
108 161
109 /* src3/4/6_ctl = 0x08020000 */ 162 /* src3/4/6_ctl */
163 /* 0x1.7385 = 2 * (32000/44100) */
110 cx18_av_write4(cx, 0x900, 0x08017385); 164 cx18_av_write4(cx, 0x900, 0x08017385);
111 cx18_av_write4(cx, 0x904, 0x08017385); 165 cx18_av_write4(cx, 0x904, 0x08017385);
112 cx18_av_write4(cx, 0x90c, 0x08017385); 166 cx18_av_write4(cx, 0x90c, 0x08017385);
167
168 /* AUD_COUNT = 0x61ff = 49 samples * 2 * 256 - 1 */
169 cx18_av_write4(cx, 0x12c, 0x112061ff);
170
171 /*
172 * EN_AV_LOCK = 1
173 * VID_COUNT = 0x1d4bf8 = 239999.000 * 8 =
174 * ((49 samples/44,100) * (13,500,000 * 8) * 2 - 1) * 8
175 */
176 cx18_av_write4(cx, 0x128, 0xa11d4bf8);
113 break; 177 break;
114 178
115 case 48000: 179 case 48000:
@@ -117,15 +181,28 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
117 cx18_av_write4(cx, 0x108, 0x180a040f); 181 cx18_av_write4(cx, 0x108, 0x180a040f);
118 182
119 /* AUX_PLL_FRAC */ 183 /* AUX_PLL_FRAC */
120 cx18_av_write4(cx, 0x110, 0x0098d6e5); 184 /* 0xa.4c6b6ea * 28,636,363.63 / 0x18 = 48000 * 256 */
185 cx18_av_write4(cx, 0x110, 0x0098d6dd);
121 186
122 /* src1_ctl = 0x08010000 */ 187 /* src1_ctl */
188 /* 0x1.8000 = 48000/32000 */
123 cx18_av_write4(cx, 0x8f8, 0x08018000); 189 cx18_av_write4(cx, 0x8f8, 0x08018000);
124 190
125 /* src3/4/6_ctl = 0x08020000 */ 191 /* src3/4/6_ctl */
192 /* 0x1.5555 = 2 * (32000/48000) */
126 cx18_av_write4(cx, 0x900, 0x08015555); 193 cx18_av_write4(cx, 0x900, 0x08015555);
127 cx18_av_write4(cx, 0x904, 0x08015555); 194 cx18_av_write4(cx, 0x904, 0x08015555);
128 cx18_av_write4(cx, 0x90c, 0x08015555); 195 cx18_av_write4(cx, 0x90c, 0x08015555);
196
197 /* AUD_COUNT = 0x3fff = 4 samples * 16 * 256 - 1 */
198 cx18_av_write4(cx, 0x12c, 0x11203fff);
199
200 /*
201 * EN_AV_LOCK = 1
202 * VID_COUNT = 0x1193f8 = 143999.000 * 8 =
203 * ((4 samples/48,000) * (13,500,000 * 8) * 16 - 1) * 8
204 */
205 cx18_av_write4(cx, 0x128, 0xa11193f8);
129 break; 206 break;
130 } 207 }
131 } 208 }
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 45e31b04730e..4801bc7fb5b2 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -46,6 +46,7 @@
46#include <linux/dvb/video.h> 46#include <linux/dvb/video.h>
47#include <linux/dvb/audio.h> 47#include <linux/dvb/audio.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <media/tuner.h> 50#include <media/tuner.h>
50#include "cx18-mailbox.h" 51#include "cx18-mailbox.h"
51#include "cx18-av-core.h" 52#include "cx18-av-core.h"
diff --git a/drivers/media/video/cx18/cx18-firmware.c b/drivers/media/video/cx18/cx18-firmware.c
index 2d630d9f7496..78fadd2ada5d 100644
--- a/drivers/media/video/cx18/cx18-firmware.c
+++ b/drivers/media/video/cx18/cx18-firmware.c
@@ -86,10 +86,6 @@
86 86
87#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 87#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
88 88
89/* Encoder/decoder firmware sizes */
90#define CX18_FW_CPU_SIZE (158332)
91#define CX18_FW_APU_SIZE (141200)
92
93#define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */ 89#define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */
94#define APU_ROM_SYNC2 0x72646548 /* "rdeH" */ 90#define APU_ROM_SYNC2 0x72646548 /* "rdeH" */
95 91
@@ -100,35 +96,22 @@ struct cx18_apu_rom_seghdr {
100 u32 size; 96 u32 size;
101}; 97};
102 98
103static int load_cpu_fw_direct(const char *fn, u8 __iomem *mem, struct cx18 *cx, long size) 99static int load_cpu_fw_direct(const char *fn, u8 __iomem *mem, struct cx18 *cx)
104{ 100{
105 const struct firmware *fw = NULL; 101 const struct firmware *fw = NULL;
106 int retries = 3;
107 int i, j; 102 int i, j;
103 unsigned size;
108 u32 __iomem *dst = (u32 __iomem *)mem; 104 u32 __iomem *dst = (u32 __iomem *)mem;
109 const u32 *src; 105 const u32 *src;
110 106
111retry: 107 if (request_firmware(&fw, fn, &cx->dev->dev)) {
112 if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { 108 CX18_ERR("Unable to open firmware %s\n", fn);
113 CX18_ERR("Unable to open firmware %s (must be %ld bytes)\n",
114 fn, size);
115 CX18_ERR("Did you put the firmware in the hotplug firmware directory?\n"); 109 CX18_ERR("Did you put the firmware in the hotplug firmware directory?\n");
116 return -ENOMEM; 110 return -ENOMEM;
117 } 111 }
118 112
119 src = (const u32 *)fw->data; 113 src = (const u32 *)fw->data;
120 114
121 if (fw->size != size) {
122 /* Due to race conditions in firmware loading (esp. with
123 udev <0.95) the wrong file was sometimes loaded. So we check
124 filesizes to see if at least the right-sized file was
125 loaded. If not, then we retry. */
126 CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n",
127 fn, size, fw->size);
128 release_firmware(fw);
129 retries--;
130 goto retry;
131 }
132 for (i = 0; i < fw->size; i += 4096) { 115 for (i = 0; i < fw->size; i += 4096) {
133 setup_page(i); 116 setup_page(i);
134 for (j = i; j < fw->size && j < i + 4096; j += 4) { 117 for (j = i; j < fw->size && j < i + 4096; j += 4) {
@@ -145,15 +128,16 @@ retry:
145 } 128 }
146 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) 129 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags))
147 CX18_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size); 130 CX18_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size);
131 size = fw->size;
148 release_firmware(fw); 132 release_firmware(fw);
149 return size; 133 return size;
150} 134}
151 135
152static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx, long size) 136static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx)
153{ 137{
154 const struct firmware *fw = NULL; 138 const struct firmware *fw = NULL;
155 int retries = 3;
156 int i, j; 139 int i, j;
140 unsigned size;
157 const u32 *src; 141 const u32 *src;
158 struct cx18_apu_rom_seghdr seghdr; 142 struct cx18_apu_rom_seghdr seghdr;
159 const u8 *vers; 143 const u8 *vers;
@@ -161,10 +145,8 @@ static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx,
161 u32 apu_version = 0; 145 u32 apu_version = 0;
162 int sz; 146 int sz;
163 147
164retry: 148 if (request_firmware(&fw, fn, &cx->dev->dev)) {
165 if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { 149 CX18_ERR("unable to open firmware %s\n", fn);
166 CX18_ERR("unable to open firmware %s (must be %ld bytes)\n",
167 fn, size);
168 CX18_ERR("did you put the firmware in the hotplug firmware directory?\n"); 150 CX18_ERR("did you put the firmware in the hotplug firmware directory?\n");
169 return -ENOMEM; 151 return -ENOMEM;
170 } 152 }
@@ -173,19 +155,8 @@ retry:
173 vers = fw->data + sizeof(seghdr); 155 vers = fw->data + sizeof(seghdr);
174 sz = fw->size; 156 sz = fw->size;
175 157
176 if (fw->size != size) {
177 /* Due to race conditions in firmware loading (esp. with
178 udev <0.95) the wrong file was sometimes loaded. So we check
179 filesizes to see if at least the right-sized file was
180 loaded. If not, then we retry. */
181 CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n",
182 fn, size, fw->size);
183 release_firmware(fw);
184 retries--;
185 goto retry;
186 }
187 apu_version = (vers[0] << 24) | (vers[4] << 16) | vers[32]; 158 apu_version = (vers[0] << 24) | (vers[4] << 16) | vers[32];
188 while (offset + sizeof(seghdr) < size) { 159 while (offset + sizeof(seghdr) < fw->size) {
189 /* TODO: byteswapping */ 160 /* TODO: byteswapping */
190 memcpy(&seghdr, src + offset / 4, sizeof(seghdr)); 161 memcpy(&seghdr, src + offset / 4, sizeof(seghdr));
191 offset += sizeof(seghdr); 162 offset += sizeof(seghdr);
@@ -215,6 +186,7 @@ retry:
215 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) 186 if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags))
216 CX18_INFO("loaded %s firmware V%08x (%zd bytes)\n", 187 CX18_INFO("loaded %s firmware V%08x (%zd bytes)\n",
217 fn, apu_version, fw->size); 188 fn, apu_version, fw->size);
189 size = fw->size;
218 release_firmware(fw); 190 release_firmware(fw);
219 /* Clear bit0 for APU to start from 0 */ 191 /* Clear bit0 for APU to start from 0 */
220 write_reg(read_reg(0xc72030) & ~1, 0xc72030); 192 write_reg(read_reg(0xc72030) & ~1, 0xc72030);
@@ -340,7 +312,7 @@ int cx18_firmware_init(struct cx18 *cx)
340 /* Only if the processor is not running */ 312 /* Only if the processor is not running */
341 if (read_reg(CX18_PROC_SOFT_RESET) & 8) { 313 if (read_reg(CX18_PROC_SOFT_RESET) & 8) {
342 int sz = load_apu_fw_direct("v4l-cx23418-apu.fw", 314 int sz = load_apu_fw_direct("v4l-cx23418-apu.fw",
343 cx->enc_mem, cx, CX18_FW_APU_SIZE); 315 cx->enc_mem, cx);
344 316
345 write_enc(0xE51FF004, 0); 317 write_enc(0xE51FF004, 0);
346 write_enc(0xa00000, 4); /* todo: not hardcoded */ 318 write_enc(0xa00000, 4); /* todo: not hardcoded */
@@ -348,7 +320,7 @@ int cx18_firmware_init(struct cx18 *cx)
348 cx18_msleep_timeout(500, 0); 320 cx18_msleep_timeout(500, 0);
349 321
350 sz = sz <= 0 ? sz : load_cpu_fw_direct("v4l-cx23418-cpu.fw", 322 sz = sz <= 0 ? sz : load_cpu_fw_direct("v4l-cx23418-cpu.fw",
351 cx->enc_mem, cx, CX18_FW_CPU_SIZE); 323 cx->enc_mem, cx);
352 324
353 if (sz > 0) { 325 if (sz > 0) {
354 int retries = 0; 326 int retries = 0;
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index 0d74e59e503e..a7f839631d6a 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -787,50 +787,54 @@ int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
787 return res; 787 return res;
788} 788}
789 789
790void cx18_set_funcs(struct video_device *vdev) 790static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
791{ 791 .vidioc_querycap = cx18_querycap,
792 vdev->vidioc_querycap = cx18_querycap; 792 .vidioc_g_priority = cx18_g_priority,
793 vdev->vidioc_g_priority = cx18_g_priority; 793 .vidioc_s_priority = cx18_s_priority,
794 vdev->vidioc_s_priority = cx18_s_priority; 794 .vidioc_s_audio = cx18_s_audio,
795 vdev->vidioc_s_audio = cx18_s_audio; 795 .vidioc_g_audio = cx18_g_audio,
796 vdev->vidioc_g_audio = cx18_g_audio; 796 .vidioc_enumaudio = cx18_enumaudio,
797 vdev->vidioc_enumaudio = cx18_enumaudio; 797 .vidioc_enum_input = cx18_enum_input,
798 vdev->vidioc_enum_input = cx18_enum_input; 798 .vidioc_cropcap = cx18_cropcap,
799 vdev->vidioc_cropcap = cx18_cropcap; 799 .vidioc_s_crop = cx18_s_crop,
800 vdev->vidioc_s_crop = cx18_s_crop; 800 .vidioc_g_crop = cx18_g_crop,
801 vdev->vidioc_g_crop = cx18_g_crop; 801 .vidioc_g_input = cx18_g_input,
802 vdev->vidioc_g_input = cx18_g_input; 802 .vidioc_s_input = cx18_s_input,
803 vdev->vidioc_s_input = cx18_s_input; 803 .vidioc_g_frequency = cx18_g_frequency,
804 vdev->vidioc_g_frequency = cx18_g_frequency; 804 .vidioc_s_frequency = cx18_s_frequency,
805 vdev->vidioc_s_frequency = cx18_s_frequency; 805 .vidioc_s_tuner = cx18_s_tuner,
806 vdev->vidioc_s_tuner = cx18_s_tuner; 806 .vidioc_g_tuner = cx18_g_tuner,
807 vdev->vidioc_g_tuner = cx18_g_tuner; 807 .vidioc_g_enc_index = cx18_g_enc_index,
808 vdev->vidioc_g_enc_index = cx18_g_enc_index; 808 .vidioc_g_std = cx18_g_std,
809 vdev->vidioc_g_std = cx18_g_std; 809 .vidioc_s_std = cx18_s_std,
810 vdev->vidioc_s_std = cx18_s_std; 810 .vidioc_log_status = cx18_log_status,
811 vdev->vidioc_log_status = cx18_log_status; 811 .vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap,
812 vdev->vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap; 812 .vidioc_encoder_cmd = cx18_encoder_cmd,
813 vdev->vidioc_encoder_cmd = cx18_encoder_cmd; 813 .vidioc_try_encoder_cmd = cx18_try_encoder_cmd,
814 vdev->vidioc_try_encoder_cmd = cx18_try_encoder_cmd; 814 .vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap,
815 vdev->vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap; 815 .vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap,
816 vdev->vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap; 816 .vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap,
817 vdev->vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap; 817 .vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap,
818 vdev->vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap; 818 .vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap,
819 vdev->vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap; 819 .vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap,
820 vdev->vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap; 820 .vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap,
821 vdev->vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap; 821 .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap,
822 vdev->vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap; 822 .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap,
823 vdev->vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap; 823 .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap,
824 vdev->vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap; 824 .vidioc_g_chip_ident = cx18_g_chip_ident,
825 vdev->vidioc_g_chip_ident = cx18_g_chip_ident;
826#ifdef CONFIG_VIDEO_ADV_DEBUG 825#ifdef CONFIG_VIDEO_ADV_DEBUG
827 vdev->vidioc_g_register = cx18_g_register; 826 .vidioc_g_register = cx18_g_register,
828 vdev->vidioc_s_register = cx18_s_register; 827 .vidioc_s_register = cx18_s_register,
829#endif 828#endif
830 vdev->vidioc_default = cx18_default; 829 .vidioc_default = cx18_default,
831 vdev->vidioc_queryctrl = cx18_queryctrl; 830 .vidioc_queryctrl = cx18_queryctrl,
832 vdev->vidioc_querymenu = cx18_querymenu; 831 .vidioc_querymenu = cx18_querymenu,
833 vdev->vidioc_g_ext_ctrls = cx18_g_ext_ctrls; 832 .vidioc_g_ext_ctrls = cx18_g_ext_ctrls,
834 vdev->vidioc_s_ext_ctrls = cx18_s_ext_ctrls; 833 .vidioc_s_ext_ctrls = cx18_s_ext_ctrls,
835 vdev->vidioc_try_ext_ctrls = cx18_try_ext_ctrls; 834 .vidioc_try_ext_ctrls = cx18_try_ext_ctrls,
835};
836
837void cx18_set_funcs(struct video_device *vdev)
838{
839 vdev->ioctl_ops = &cx18_ioctl_ops;
836} 840}
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 1728b1d832a9..0da57f583bf7 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -187,14 +187,11 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
187 return -ENOMEM; 187 return -ENOMEM;
188 } 188 }
189 189
190 s->v4l2dev->type =
191 VID_TYPE_CAPTURE | VID_TYPE_TUNER | VID_TYPE_TELETEXT |
192 VID_TYPE_CLIPPING | VID_TYPE_SCALES | VID_TYPE_MPEG_ENCODER;
193 snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "cx18-%d", 190 snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "cx18-%d",
194 cx->num); 191 cx->num);
195 192
196 s->v4l2dev->minor = minor; 193 s->v4l2dev->minor = minor;
197 s->v4l2dev->dev = &cx->dev->dev; 194 s->v4l2dev->parent = &cx->dev->dev;
198 s->v4l2dev->fops = cx18_stream_info[type].fops; 195 s->v4l2dev->fops = cx18_stream_info[type].fops;
199 s->v4l2dev->release = video_device_release; 196 s->v4l2dev->release = video_device_release;
200 s->v4l2dev->tvnorms = V4L2_STD_ALL; 197 s->v4l2dev->tvnorms = V4L2_STD_ALL;
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index 5cfb46bbdaa9..e60bd31b51a3 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -1,9 +1,7 @@
1config VIDEO_CX23885 1config VIDEO_CX23885
2 tristate "Conexant cx23885 (2388x successor) support" 2 tristate "Conexant cx23885 (2388x successor) support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER
5 select I2C_ALGOBIT 4 select I2C_ALGOBIT
6 select FW_LOADER
7 select VIDEO_BTCX 5 select VIDEO_BTCX
8 select VIDEO_TUNER 6 select VIDEO_TUNER
9 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index e7ef093265af..8118091568fc 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/firmware.h> 33#include <linux/firmware.h>
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h>
35#include <media/cx2341x.h> 36#include <media/cx2341x.h>
36 37
37#include "cx23885.h" 38#include "cx23885.h"
@@ -1699,14 +1700,7 @@ static struct file_operations mpeg_fops = {
1699 .llseek = no_llseek, 1700 .llseek = no_llseek,
1700}; 1701};
1701 1702
1702static struct video_device cx23885_mpeg_template = { 1703static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1703 .name = "cx23885",
1704 .type = VID_TYPE_CAPTURE |
1705 VID_TYPE_TUNER |
1706 VID_TYPE_SCALES |
1707 VID_TYPE_MPEG_ENCODER,
1708 .fops = &mpeg_fops,
1709 .minor = -1,
1710 .vidioc_s_std = vidioc_s_std, 1704 .vidioc_s_std = vidioc_s_std,
1711 .vidioc_enum_input = vidioc_enum_input, 1705 .vidioc_enum_input = vidioc_enum_input,
1712 .vidioc_g_input = vidioc_g_input, 1706 .vidioc_g_input = vidioc_g_input,
@@ -1735,6 +1729,13 @@ static struct video_device cx23885_mpeg_template = {
1735 .vidioc_queryctrl = vidioc_queryctrl, 1729 .vidioc_queryctrl = vidioc_queryctrl,
1736}; 1730};
1737 1731
1732static struct video_device cx23885_mpeg_template = {
1733 .name = "cx23885",
1734 .fops = &mpeg_fops,
1735 .ioctl_ops = &mpeg_ioctl_ops,
1736 .minor = -1,
1737};
1738
1738void cx23885_417_unregister(struct cx23885_dev *dev) 1739void cx23885_417_unregister(struct cx23885_dev *dev)
1739{ 1740{
1740 dprintk(1, "%s()\n", __func__); 1741 dprintk(1, "%s()\n", __func__);
@@ -1766,7 +1767,7 @@ static struct video_device *cx23885_video_dev_alloc(
1766 vfd->minor = -1; 1767 vfd->minor = -1;
1767 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, 1768 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name,
1768 type, cx23885_boards[tsport->dev->board].name); 1769 type, cx23885_boards[tsport->dev->board].name);
1769 vfd->dev = &pci->dev; 1770 vfd->parent = &pci->dev;
1770 vfd->release = video_device_release; 1771 vfd->release = video_device_release;
1771 return vfd; 1772 return vfd;
1772} 1773}
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index fd7112c11d35..a19de850955d 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -145,6 +145,7 @@ struct cx23885_board cx23885_boards[] = {
145 }, 145 },
146 [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = { 146 [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = {
147 .name = "DViCO FusionHDTV7 Dual Express", 147 .name = "DViCO FusionHDTV7 Dual Express",
148 .portb = CX23885_MPEG_DVB,
148 .portc = CX23885_MPEG_DVB, 149 .portc = CX23885_MPEG_DVB,
149 }, 150 },
150}; 151};
@@ -325,25 +326,41 @@ int cx23885_tuner_callback(void *priv, int command, int arg)
325{ 326{
326 struct cx23885_i2c *bus = priv; 327 struct cx23885_i2c *bus = priv;
327 struct cx23885_dev *dev = bus->dev; 328 struct cx23885_dev *dev = bus->dev;
329 u32 bitmask = 0;
330
331 if (command != 0) {
332 printk(KERN_ERR "%s(): Unknown command 0x%x.\n",
333 __func__, command);
334 return -EINVAL;
335 }
328 336
329 switch(dev->board) { 337 switch(dev->board) {
330 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 338 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
331 if(command == 0) { /* Tuner Reset Command from xc5000 */ 339 /* Tuner Reset Command from xc5000 */
332 /* Drive the tuner into reset and out */ 340 if (command == 0)
333 cx_clear(GP0_IO, 0x00000004); 341 bitmask = 0x04;
334 mdelay(200); 342 break;
335 cx_set(GP0_IO, 0x00000004); 343 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
336 return 0; 344 if (command == 0) {
337 } 345
338 else { 346 /* Two identical tuners on two different i2c buses,
339 printk(KERN_ERR 347 * we need to reset the correct gpio. */
340 "%s(): Unknow command.\n", __func__); 348 if (bus->nr == 0)
341 return -EINVAL; 349 bitmask = 0x01;
350 else if (bus->nr == 1)
351 bitmask = 0x04;
342 } 352 }
343 break; 353 break;
344 } 354 }
345 355
346 return 0; /* Should never be here */ 356 if (bitmask) {
357 /* Drive the tuner into reset and back out */
358 cx_clear(GP0_IO, bitmask);
359 mdelay(200);
360 cx_set(GP0_IO, bitmask);
361 }
362
363 return 0;
347} 364}
348 365
349void cx23885_gpio_setup(struct cx23885_dev *dev) 366void cx23885_gpio_setup(struct cx23885_dev *dev)
@@ -435,6 +452,19 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
435 mdelay(20); 452 mdelay(20);
436 cx_set(GP0_IO, 0x00050005); 453 cx_set(GP0_IO, 0x00050005);
437 break; 454 break;
455 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
456 /* GPIO-0 xc5000 tuner reset i2c bus 0 */
457 /* GPIO-1 s5h1409 demod reset i2c bus 0 */
458 /* GPIO-2 xc5000 tuner reset i2c bus 1 */
459 /* GPIO-3 s5h1409 demod reset i2c bus 0 */
460
461 /* Put the parts into reset and back */
462 cx_set(GP0_IO, 0x000f0000);
463 mdelay(20);
464 cx_clear(GP0_IO, 0x0000000f);
465 mdelay(20);
466 cx_set(GP0_IO, 0x000f000f);
467 break;
438 } 468 }
439} 469}
440 470
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index d17343ea0d33..6286a9cf957e 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -76,6 +76,117 @@ LIST_HEAD(cx23885_devlist);
76 * 0x00010ea0 0x00010xxx Free 76 * 0x00010ea0 0x00010xxx Free
77 */ 77 */
78 78
79static struct sram_channel cx23885_sram_channels[] = {
80 [SRAM_CH01] = {
81 .name = "VID A",
82 .cmds_start = 0x10000,
83 .ctrl_start = 0x10380,
84 .cdt = 0x104c0,
85 .fifo_start = 0x40,
86 .fifo_size = 0x2800,
87 .ptr1_reg = DMA1_PTR1,
88 .ptr2_reg = DMA1_PTR2,
89 .cnt1_reg = DMA1_CNT1,
90 .cnt2_reg = DMA1_CNT2,
91 },
92 [SRAM_CH02] = {
93 .name = "ch2",
94 .cmds_start = 0x0,
95 .ctrl_start = 0x0,
96 .cdt = 0x0,
97 .fifo_start = 0x0,
98 .fifo_size = 0x0,
99 .ptr1_reg = DMA2_PTR1,
100 .ptr2_reg = DMA2_PTR2,
101 .cnt1_reg = DMA2_CNT1,
102 .cnt2_reg = DMA2_CNT2,
103 },
104 [SRAM_CH03] = {
105 .name = "TS1 B",
106 .cmds_start = 0x100A0,
107 .ctrl_start = 0x10400,
108 .cdt = 0x10580,
109 .fifo_start = 0x5000,
110 .fifo_size = 0x1000,
111 .ptr1_reg = DMA3_PTR1,
112 .ptr2_reg = DMA3_PTR2,
113 .cnt1_reg = DMA3_CNT1,
114 .cnt2_reg = DMA3_CNT2,
115 },
116 [SRAM_CH04] = {
117 .name = "ch4",
118 .cmds_start = 0x0,
119 .ctrl_start = 0x0,
120 .cdt = 0x0,
121 .fifo_start = 0x0,
122 .fifo_size = 0x0,
123 .ptr1_reg = DMA4_PTR1,
124 .ptr2_reg = DMA4_PTR2,
125 .cnt1_reg = DMA4_CNT1,
126 .cnt2_reg = DMA4_CNT2,
127 },
128 [SRAM_CH05] = {
129 .name = "ch5",
130 .cmds_start = 0x0,
131 .ctrl_start = 0x0,
132 .cdt = 0x0,
133 .fifo_start = 0x0,
134 .fifo_size = 0x0,
135 .ptr1_reg = DMA5_PTR1,
136 .ptr2_reg = DMA5_PTR2,
137 .cnt1_reg = DMA5_CNT1,
138 .cnt2_reg = DMA5_CNT2,
139 },
140 [SRAM_CH06] = {
141 .name = "TS2 C",
142 .cmds_start = 0x10140,
143 .ctrl_start = 0x10440,
144 .cdt = 0x105e0,
145 .fifo_start = 0x6000,
146 .fifo_size = 0x1000,
147 .ptr1_reg = DMA5_PTR1,
148 .ptr2_reg = DMA5_PTR2,
149 .cnt1_reg = DMA5_CNT1,
150 .cnt2_reg = DMA5_CNT2,
151 },
152 [SRAM_CH07] = {
153 .name = "ch7",
154 .cmds_start = 0x0,
155 .ctrl_start = 0x0,
156 .cdt = 0x0,
157 .fifo_start = 0x0,
158 .fifo_size = 0x0,
159 .ptr1_reg = DMA6_PTR1,
160 .ptr2_reg = DMA6_PTR2,
161 .cnt1_reg = DMA6_CNT1,
162 .cnt2_reg = DMA6_CNT2,
163 },
164 [SRAM_CH08] = {
165 .name = "ch8",
166 .cmds_start = 0x0,
167 .ctrl_start = 0x0,
168 .cdt = 0x0,
169 .fifo_start = 0x0,
170 .fifo_size = 0x0,
171 .ptr1_reg = DMA7_PTR1,
172 .ptr2_reg = DMA7_PTR2,
173 .cnt1_reg = DMA7_CNT1,
174 .cnt2_reg = DMA7_CNT2,
175 },
176 [SRAM_CH09] = {
177 .name = "ch9",
178 .cmds_start = 0x0,
179 .ctrl_start = 0x0,
180 .cdt = 0x0,
181 .fifo_start = 0x0,
182 .fifo_size = 0x0,
183 .ptr1_reg = DMA8_PTR1,
184 .ptr2_reg = DMA8_PTR2,
185 .cnt1_reg = DMA8_CNT1,
186 .cnt2_reg = DMA8_CNT2,
187 },
188};
189
79static struct sram_channel cx23887_sram_channels[] = { 190static struct sram_channel cx23887_sram_channels[] = {
80 [SRAM_CH01] = { 191 [SRAM_CH01] = {
81 .name = "VID A", 192 .name = "VID A",
@@ -104,8 +215,8 @@ static struct sram_channel cx23887_sram_channels[] = {
104 [SRAM_CH03] = { 215 [SRAM_CH03] = {
105 .name = "TS1 B", 216 .name = "TS1 B",
106 .cmds_start = 0x100A0, 217 .cmds_start = 0x100A0,
107 .ctrl_start = 0x10780, 218 .ctrl_start = 0x10630,
108 .cdt = 0x10400, 219 .cdt = 0x10870,
109 .fifo_start = 0x5000, 220 .fifo_start = 0x5000,
110 .fifo_size = 0x1000, 221 .fifo_size = 0x1000,
111 .ptr1_reg = DMA3_PTR1, 222 .ptr1_reg = DMA3_PTR1,
@@ -140,7 +251,7 @@ static struct sram_channel cx23887_sram_channels[] = {
140 [SRAM_CH06] = { 251 [SRAM_CH06] = {
141 .name = "TS2 C", 252 .name = "TS2 C",
142 .cmds_start = 0x10140, 253 .cmds_start = 0x10140,
143 .ctrl_start = 0x10680, 254 .ctrl_start = 0x10670,
144 .cdt = 0x108d0, 255 .cdt = 0x108d0,
145 .fifo_start = 0x6000, 256 .fifo_start = 0x6000,
146 .fifo_size = 0x1000, 257 .fifo_size = 0x1000,
@@ -460,6 +571,7 @@ static void cx23885_reset(struct cx23885_dev *dev)
460 cx_write(AUDIO_INT_INT_STAT, 0xffffffff); 571 cx_write(AUDIO_INT_INT_STAT, 0xffffffff);
461 cx_write(AUDIO_EXT_INT_STAT, 0xffffffff); 572 cx_write(AUDIO_EXT_INT_STAT, 0xffffffff);
462 cx_write(CLK_DELAY, cx_read(CLK_DELAY) & 0x80000000); 573 cx_write(CLK_DELAY, cx_read(CLK_DELAY) & 0x80000000);
574 cx_write(PAD_CTRL, 0x00500300);
463 575
464 mdelay(100); 576 mdelay(100);
465 577
@@ -625,7 +737,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
625 atomic_inc(&dev->refcount); 737 atomic_inc(&dev->refcount);
626 738
627 dev->nr = cx23885_devcount++; 739 dev->nr = cx23885_devcount++;
628 dev->sram_channels = cx23887_sram_channels;
629 sprintf(dev->name, "cx23885[%d]", dev->nr); 740 sprintf(dev->name, "cx23885[%d]", dev->nr);
630 741
631 mutex_lock(&devlist); 742 mutex_lock(&devlist);
@@ -637,11 +748,13 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
637 dev->bridge = CX23885_BRIDGE_887; 748 dev->bridge = CX23885_BRIDGE_887;
638 /* Apply a sensible clock frequency for the PCIe bridge */ 749 /* Apply a sensible clock frequency for the PCIe bridge */
639 dev->clk_freq = 25000000; 750 dev->clk_freq = 25000000;
751 dev->sram_channels = cx23887_sram_channels;
640 } else 752 } else
641 if(dev->pci->device == 0x8852) { 753 if(dev->pci->device == 0x8852) {
642 dev->bridge = CX23885_BRIDGE_885; 754 dev->bridge = CX23885_BRIDGE_885;
643 /* Apply a sensible clock frequency for the PCIe bridge */ 755 /* Apply a sensible clock frequency for the PCIe bridge */
644 dev->clk_freq = 28000000; 756 dev->clk_freq = 28000000;
757 dev->sram_channels = cx23885_sram_channels;
645 } else 758 } else
646 BUG(); 759 BUG();
647 760
@@ -1010,8 +1123,9 @@ static void cx23885_tsport_reg_dump(struct cx23885_tsport *port)
1010 port->reg_gpcnt_ctl, cx_read(port->reg_gpcnt_ctl)); 1123 port->reg_gpcnt_ctl, cx_read(port->reg_gpcnt_ctl));
1011 dprintk(1, "%s() dma_ctl(0x%08X) 0x%08x\n", __func__, 1124 dprintk(1, "%s() dma_ctl(0x%08X) 0x%08x\n", __func__,
1012 port->reg_dma_ctl, cx_read(port->reg_dma_ctl)); 1125 port->reg_dma_ctl, cx_read(port->reg_dma_ctl));
1013 dprintk(1, "%s() src_sel(0x%08X) 0x%08x\n", __func__, 1126 if (port->reg_src_sel)
1014 port->reg_src_sel, cx_read(port->reg_src_sel)); 1127 dprintk(1, "%s() src_sel(0x%08X) 0x%08x\n", __func__,
1128 port->reg_src_sel, cx_read(port->reg_src_sel));
1015 dprintk(1, "%s() lngth(0x%08X) 0x%08x\n", __func__, 1129 dprintk(1, "%s() lngth(0x%08X) 0x%08x\n", __func__,
1016 port->reg_lngth, cx_read(port->reg_lngth)); 1130 port->reg_lngth, cx_read(port->reg_lngth));
1017 dprintk(1, "%s() hw_sop_ctrl(0x%08X) 0x%08x\n", __func__, 1131 dprintk(1, "%s() hw_sop_ctrl(0x%08X) 0x%08x\n", __func__,
@@ -1042,6 +1156,9 @@ static int cx23885_start_dma(struct cx23885_tsport *port,
1042 dprintk(1, "%s() w: %d, h: %d, f: %d\n", __func__, 1156 dprintk(1, "%s() w: %d, h: %d, f: %d\n", __func__,
1043 buf->vb.width, buf->vb.height, buf->vb.field); 1157 buf->vb.width, buf->vb.height, buf->vb.field);
1044 1158
1159 /* Stop the fifo and risc engine for this port */
1160 cx_clear(port->reg_dma_ctl, port->dma_ctl_val);
1161
1045 /* setup fifo + format */ 1162 /* setup fifo + format */
1046 cx23885_sram_channel_setup(dev, 1163 cx23885_sram_channel_setup(dev,
1047 &dev->sram_channels[ port->sram_chno ], 1164 &dev->sram_channels[ port->sram_chno ],
@@ -1083,7 +1200,21 @@ static int cx23885_start_dma(struct cx23885_tsport *port,
1083 cx_write(port->reg_gpcnt_ctl, 3); 1200 cx_write(port->reg_gpcnt_ctl, 3);
1084 q->count = 1; 1201 q->count = 1;
1085 1202
1086 if (cx23885_boards[dev->board].portb & CX23885_MPEG_ENCODER) { 1203 /* Set VIDB pins to input */
1204 if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) {
1205 reg = cx_read(PAD_CTRL);
1206 reg &= ~0x3; /* Clear TS1_OE & TS1_SOP_OE */
1207 cx_write(PAD_CTRL, reg);
1208 }
1209
1210 /* Set VIDC pins to input */
1211 if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) {
1212 reg = cx_read(PAD_CTRL);
1213 reg &= ~0x4; /* Clear TS2_SOP_OE */
1214 cx_write(PAD_CTRL, reg);
1215 }
1216
1217 if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) {
1087 1218
1088 reg = cx_read(PAD_CTRL); 1219 reg = cx_read(PAD_CTRL);
1089 reg = reg & ~0x1; /* Clear TS1_OE */ 1220 reg = reg & ~0x1; /* Clear TS1_OE */
@@ -1133,7 +1264,7 @@ static int cx23885_stop_dma(struct cx23885_tsport *port)
1133 cx_clear(port->reg_ts_int_msk, port->ts_int_msk_val); 1264 cx_clear(port->reg_ts_int_msk, port->ts_int_msk_val);
1134 cx_clear(port->reg_dma_ctl, port->dma_ctl_val); 1265 cx_clear(port->reg_dma_ctl, port->dma_ctl_val);
1135 1266
1136 if (cx23885_boards[dev->board].portb & CX23885_MPEG_ENCODER) { 1267 if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) {
1137 1268
1138 reg = cx_read(PAD_CTRL); 1269 reg = cx_read(PAD_CTRL);
1139 1270
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 043fc4e5c586..ad2235dab5b1 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -33,6 +33,7 @@
33 33
34#include "cx23885.h" 34#include "cx23885.h"
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36 37
37#ifdef CONFIG_VIDEO_V4L1_COMPAT 38#ifdef CONFIG_VIDEO_V4L1_COMPAT
38/* Include V4L1 specific functions. Should be removed soon */ 39/* Include V4L1 specific functions. Should be removed soon */
@@ -326,7 +327,7 @@ struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
326 return NULL; 327 return NULL;
327 *vfd = *template; 328 *vfd = *template;
328 vfd->minor = -1; 329 vfd->minor = -1;
329 vfd->dev = &pci->dev; 330 vfd->parent = &pci->dev;
330 vfd->release = video_device_release; 331 vfd->release = video_device_release;
331 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 332 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
332 dev->name, type, cx23885_boards[dev->board].name); 333 dev->name, type, cx23885_boards[dev->board].name);
@@ -1433,12 +1434,7 @@ static const struct file_operations video_fops = {
1433 .llseek = no_llseek, 1434 .llseek = no_llseek,
1434}; 1435};
1435 1436
1436static struct video_device cx23885_vbi_template; 1437static const struct v4l2_ioctl_ops video_ioctl_ops = {
1437static struct video_device cx23885_video_template = {
1438 .name = "cx23885-video",
1439 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
1440 .fops = &video_fops,
1441 .minor = -1,
1442 .vidioc_querycap = vidioc_querycap, 1438 .vidioc_querycap = vidioc_querycap,
1443 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1439 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1444 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1440 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1471,6 +1467,14 @@ static struct video_device cx23885_video_template = {
1471 .vidioc_g_register = vidioc_g_register, 1467 .vidioc_g_register = vidioc_g_register,
1472 .vidioc_s_register = vidioc_s_register, 1468 .vidioc_s_register = vidioc_s_register,
1473#endif 1469#endif
1470};
1471
1472static struct video_device cx23885_vbi_template;
1473static struct video_device cx23885_video_template = {
1474 .name = "cx23885-video",
1475 .fops = &video_fops,
1476 .minor = -1,
1477 .ioctl_ops = &video_ioctl_ops,
1474 .tvnorms = CX23885_NORMS, 1478 .tvnorms = CX23885_NORMS,
1475 .current_norm = V4L2_STD_NTSC_M, 1479 .current_norm = V4L2_STD_NTSC_M,
1476}; 1480};
@@ -1512,7 +1516,6 @@ int cx23885_video_register(struct cx23885_dev *dev)
1512 memcpy(&cx23885_vbi_template, &cx23885_video_template, 1516 memcpy(&cx23885_vbi_template, &cx23885_video_template,
1513 sizeof(cx23885_vbi_template)); 1517 sizeof(cx23885_vbi_template));
1514 strcpy(cx23885_vbi_template.name, "cx23885-vbi"); 1518 strcpy(cx23885_vbi_template.name, "cx23885-vbi");
1515 cx23885_vbi_template.type = VID_TYPE_TELETEXT|VID_TYPE_TUNER;
1516 1519
1517 dev->tvnorm = cx23885_video_template.current_norm; 1520 dev->tvnorm = cx23885_video_template.current_norm;
1518 1521
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig
index 448f4cd0ce34..de515dadadc2 100644
--- a/drivers/media/video/cx25840/Kconfig
+++ b/drivers/media/video/cx25840/Kconfig
@@ -1,8 +1,6 @@
1config VIDEO_CX25840 1config VIDEO_CX25840
2 tristate "Conexant CX2584x audio/video decoders" 2 tristate "Conexant CX2584x audio/video decoders"
3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 depends on HOTPLUG # due to FW_LOADER
5 select FW_LOADER
6 ---help--- 4 ---help---
7 Support for the Conexant CX2584x audio/video decoders. 5 Support for the Conexant CX2584x audio/video decoders.
8 6
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index e7bf4f4c1319..209d3bcb5dbb 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -50,7 +50,7 @@ MODULE_LICENSE("GPL");
50 50
51static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 51static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
52 52
53int cx25840_debug; 53static int cx25840_debug;
54 54
55module_param_named(debug,cx25840_debug, int, 0644); 55module_param_named(debug,cx25840_debug, int, 0644);
56 56
diff --git a/drivers/media/video/cx25840/cx25840-core.h b/drivers/media/video/cx25840/cx25840-core.h
index 72916ba975a8..b87337e590b4 100644
--- a/drivers/media/video/cx25840/cx25840-core.h
+++ b/drivers/media/video/cx25840/cx25840-core.h
@@ -24,8 +24,6 @@
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26 26
27extern int cx25840_debug;
28
29/* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is 27/* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is
30 present in Hauppauge PVR-150 (and possibly PVR-500) cards that have 28 present in Hauppauge PVR-150 (and possibly PVR-500) cards that have
31 certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The 29 certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 10e20d8196dc..9dd7bdf659b9 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -33,9 +33,8 @@ config VIDEO_CX88_ALSA
33 33
34config VIDEO_CX88_BLACKBIRD 34config VIDEO_CX88_BLACKBIRD
35 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" 35 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)"
36 depends on VIDEO_CX88 && HOTPLUG 36 depends on VIDEO_CX88
37 select VIDEO_CX2341X 37 select VIDEO_CX2341X
38 select FW_LOADER
39 ---help--- 38 ---help---
40 This adds support for MPEG encoder cards based on the 39 This adds support for MPEG encoder cards based on the
41 Blackbird reference design, using the Conexant 2388x 40 Blackbird reference design, using the Conexant 2388x
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index bfdca5847764..9a1374a38ec7 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h>
36#include <media/cx2341x.h> 37#include <media/cx2341x.h>
37 38
38#include "cx88.h" 39#include "cx88.h"
@@ -1174,12 +1175,7 @@ static const struct file_operations mpeg_fops =
1174 .llseek = no_llseek, 1175 .llseek = no_llseek,
1175}; 1176};
1176 1177
1177static struct video_device cx8802_mpeg_template = 1178static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1178{
1179 .name = "cx8802",
1180 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES|VID_TYPE_MPEG_ENCODER,
1181 .fops = &mpeg_fops,
1182 .minor = -1,
1183 .vidioc_querymenu = vidioc_querymenu, 1179 .vidioc_querymenu = vidioc_querymenu,
1184 .vidioc_querycap = vidioc_querycap, 1180 .vidioc_querycap = vidioc_querycap,
1185 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1181 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
@@ -1207,6 +1203,13 @@ static struct video_device cx8802_mpeg_template =
1207 .vidioc_g_tuner = vidioc_g_tuner, 1203 .vidioc_g_tuner = vidioc_g_tuner,
1208 .vidioc_s_tuner = vidioc_s_tuner, 1204 .vidioc_s_tuner = vidioc_s_tuner,
1209 .vidioc_s_std = vidioc_s_std, 1205 .vidioc_s_std = vidioc_s_std,
1206};
1207
1208static struct video_device cx8802_mpeg_template = {
1209 .name = "cx8802",
1210 .fops = &mpeg_fops,
1211 .ioctl_ops = &mpeg_ioctl_ops,
1212 .minor = -1,
1210 .tvnorms = CX88_NORMS, 1213 .tvnorms = CX88_NORMS,
1211 .current_norm = V4L2_STD_NTSC_M, 1214 .current_norm = V4L2_STD_NTSC_M,
1212}; 1215};
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index fa6d398e97b9..de199a206a15 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1348,7 +1348,7 @@ static const struct cx88_board cx88_boards[] = {
1348 .tuner_addr = ADDR_UNSET, 1348 .tuner_addr = ADDR_UNSET,
1349 .radio_addr = ADDR_UNSET, 1349 .radio_addr = ADDR_UNSET,
1350 .tda9887_conf = TDA9887_PRESENT, 1350 .tda9887_conf = TDA9887_PRESENT,
1351 .audio_chip = AUDIO_CHIP_WM8775, 1351 .audio_chip = V4L2_IDENT_WM8775,
1352 .input = {{ 1352 .input = {{
1353 .type = CX88_VMUX_TELEVISION, 1353 .type = CX88_VMUX_TELEVISION,
1354 .vmux = 0, 1354 .vmux = 0,
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 60eeda3057e9..d656fec59010 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -40,6 +40,7 @@
40 40
41#include "cx88.h" 41#include "cx88.h"
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/v4l2-ioctl.h>
43 44
44MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); 45MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
45MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 46MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
@@ -1006,7 +1007,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core,
1006 return NULL; 1007 return NULL;
1007 *vfd = *template; 1008 *vfd = *template;
1008 vfd->minor = -1; 1009 vfd->minor = -1;
1009 vfd->dev = &pci->dev; 1010 vfd->parent = &pci->dev;
1010 vfd->release = video_device_release; 1011 vfd->release = video_device_release;
1011 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 1012 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
1012 core->name, type, core->board.name); 1013 core->name, type, core->board.name);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 0fed5cd2ccea..ef4d56ea0027 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -39,6 +39,7 @@
39 39
40#include "cx88.h" 40#include "cx88.h"
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42#include <media/v4l2-ioctl.h>
42 43
43#ifdef CONFIG_VIDEO_V4L1_COMPAT 44#ifdef CONFIG_VIDEO_V4L1_COMPAT
44/* Include V4L1 specific functions. Should be removed soon */ 45/* Include V4L1 specific functions. Should be removed soon */
@@ -447,7 +448,7 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
447 the initialization. Some boards may use different 448 the initialization. Some boards may use different
448 routes for different inputs. HVR-1300 surely does */ 449 routes for different inputs. HVR-1300 surely does */
449 if (core->board.audio_chip && 450 if (core->board.audio_chip &&
450 core->board.audio_chip == AUDIO_CHIP_WM8775) { 451 core->board.audio_chip == V4L2_IDENT_WM8775) {
451 struct v4l2_routing route; 452 struct v4l2_routing route;
452 453
453 route.input = INPUT(input).audioroute; 454 route.input = INPUT(input).audioroute;
@@ -1682,13 +1683,7 @@ static const struct file_operations video_fops =
1682 .llseek = no_llseek, 1683 .llseek = no_llseek,
1683}; 1684};
1684 1685
1685static struct video_device cx8800_vbi_template; 1686static const struct v4l2_ioctl_ops video_ioctl_ops = {
1686static struct video_device cx8800_video_template =
1687{
1688 .name = "cx8800-video",
1689 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
1690 .fops = &video_fops,
1691 .minor = -1,
1692 .vidioc_querycap = vidioc_querycap, 1687 .vidioc_querycap = vidioc_querycap,
1693 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1688 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1694 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1689 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1721,6 +1716,15 @@ static struct video_device cx8800_video_template =
1721 .vidioc_g_register = vidioc_g_register, 1716 .vidioc_g_register = vidioc_g_register,
1722 .vidioc_s_register = vidioc_s_register, 1717 .vidioc_s_register = vidioc_s_register,
1723#endif 1718#endif
1719};
1720
1721static struct video_device cx8800_vbi_template;
1722
1723static struct video_device cx8800_video_template = {
1724 .name = "cx8800-video",
1725 .fops = &video_fops,
1726 .minor = -1,
1727 .ioctl_ops = &video_ioctl_ops,
1724 .tvnorms = CX88_NORMS, 1728 .tvnorms = CX88_NORMS,
1725 .current_norm = V4L2_STD_NTSC_M, 1729 .current_norm = V4L2_STD_NTSC_M,
1726}; 1730};
@@ -1735,12 +1739,7 @@ static const struct file_operations radio_fops =
1735 .llseek = no_llseek, 1739 .llseek = no_llseek,
1736}; 1740};
1737 1741
1738static struct video_device cx8800_radio_template = 1742static const struct v4l2_ioctl_ops radio_ioctl_ops = {
1739{
1740 .name = "cx8800-radio",
1741 .type = VID_TYPE_TUNER,
1742 .fops = &radio_fops,
1743 .minor = -1,
1744 .vidioc_querycap = radio_querycap, 1743 .vidioc_querycap = radio_querycap,
1745 .vidioc_g_tuner = radio_g_tuner, 1744 .vidioc_g_tuner = radio_g_tuner,
1746 .vidioc_enum_input = radio_enum_input, 1745 .vidioc_enum_input = radio_enum_input,
@@ -1759,6 +1758,13 @@ static struct video_device cx8800_radio_template =
1759#endif 1758#endif
1760}; 1759};
1761 1760
1761static struct video_device cx8800_radio_template = {
1762 .name = "cx8800-radio",
1763 .fops = &radio_fops,
1764 .minor = -1,
1765 .ioctl_ops = &radio_ioctl_ops,
1766};
1767
1762/* ----------------------------------------------------------- */ 1768/* ----------------------------------------------------------- */
1763 1769
1764static void cx8800_unregister_video(struct cx8800_dev *dev) 1770static void cx8800_unregister_video(struct cx8800_dev *dev)
@@ -1830,7 +1836,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1830 memcpy( &cx8800_vbi_template, &cx8800_video_template, 1836 memcpy( &cx8800_vbi_template, &cx8800_video_template,
1831 sizeof(cx8800_vbi_template) ); 1837 sizeof(cx8800_vbi_template) );
1832 strcpy(cx8800_vbi_template.name,"cx8800-vbi"); 1838 strcpy(cx8800_vbi_template.name,"cx8800-vbi");
1833 cx8800_vbi_template.type = VID_TYPE_TELETEXT|VID_TYPE_TUNER;
1834 1839
1835 /* initialize driver struct */ 1840 /* initialize driver struct */
1836 spin_lock_init(&dev->slock); 1841 spin_lock_init(&dev->slock);
@@ -1866,7 +1871,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1866 1871
1867 /* load and configure helper modules */ 1872 /* load and configure helper modules */
1868 1873
1869 if (core->board.audio_chip == AUDIO_CHIP_WM8775) 1874 if (core->board.audio_chip == V4L2_IDENT_WM8775)
1870 request_module("wm8775"); 1875 request_module("wm8775");
1871 1876
1872 switch (core->boardnr) { 1877 switch (core->boardnr) {
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 14ac173f4071..54fe65094711 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -29,8 +29,8 @@
29#include <media/tuner.h> 29#include <media/tuner.h>
30#include <media/tveeprom.h> 30#include <media/tveeprom.h>
31#include <media/videobuf-dma-sg.h> 31#include <media/videobuf-dma-sg.h>
32#include <media/v4l2-chip-ident.h>
32#include <media/cx2341x.h> 33#include <media/cx2341x.h>
33#include <media/audiochip.h>
34#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 34#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
35#include <media/videobuf-dvb.h> 35#include <media/videobuf-dvb.h>
36#endif 36#endif
@@ -252,7 +252,7 @@ struct cx88_board {
252 struct cx88_input input[MAX_CX88_INPUT]; 252 struct cx88_input input[MAX_CX88_INPUT];
253 struct cx88_input radio; 253 struct cx88_input radio;
254 enum cx88_board_type mpeg; 254 enum cx88_board_type mpeg;
255 enum audiochip audio_chip; 255 unsigned int audio_chip;
256}; 256};
257 257
258struct cx88_subid { 258struct cx88_subid {
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 05f0d5a15058..476ae44a62d2 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -32,8 +32,8 @@
32#include <media/saa7115.h> 32#include <media/saa7115.h>
33#include <media/tvp5150.h> 33#include <media/tvp5150.h>
34#include <media/tveeprom.h> 34#include <media/tveeprom.h>
35#include <media/audiochip.h>
36#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-chip-ident.h>
37 37
38#include "em28xx.h" 38#include "em28xx.h"
39 39
@@ -52,6 +52,15 @@ struct em28xx_hash_table {
52}; 52};
53 53
54struct em28xx_board em28xx_boards[] = { 54struct em28xx_board em28xx_boards[] = {
55 [EM2750_BOARD_UNKNOWN] = {
56 .name = "Unknown EM2750/EM2751 webcam grabber",
57 .vchannels = 1,
58 .input = { {
59 .type = EM28XX_VMUX_COMPOSITE1,
60 .vmux = 0,
61 .amux = 0,
62 } },
63 },
55 [EM2800_BOARD_UNKNOWN] = { 64 [EM2800_BOARD_UNKNOWN] = {
56 .name = "Unknown EM2800 video grabber", 65 .name = "Unknown EM2800 video grabber",
57 .is_em2800 = 1, 66 .is_em2800 = 1,
@@ -73,6 +82,39 @@ struct em28xx_board em28xx_boards[] = {
73 .is_em2800 = 0, 82 .is_em2800 = 0,
74 .tuner_type = TUNER_ABSENT, 83 .tuner_type = TUNER_ABSENT,
75 }, 84 },
85 [EM2750_BOARD_DLCW_130] = {
86 /* Beijing Huaqi Information Digital Technology Co., Ltd */
87 .name = "Huaqi DLCW-130",
88 .valid = EM28XX_BOARD_NOT_VALIDATED,
89 .vchannels = 1,
90 .input = { {
91 .type = EM28XX_VMUX_COMPOSITE1,
92 .vmux = 0,
93 .amux = 0,
94 } },
95 },
96 [EM2800_BOARD_KWORLD_USB2800] = {
97 .name = "Kworld USB2800",
98 .valid = EM28XX_BOARD_NOT_VALIDATED,
99 .is_em2800 = 1,
100 .vchannels = 3,
101 .tuner_type = TUNER_PHILIPS_FCV1236D,
102 .tda9887_conf = TDA9887_PRESENT,
103 .decoder = EM28XX_SAA7113,
104 .input = { {
105 .type = EM28XX_VMUX_TELEVISION,
106 .vmux = SAA7115_COMPOSITE2,
107 .amux = 0,
108 }, {
109 .type = EM28XX_VMUX_COMPOSITE1,
110 .vmux = SAA7115_COMPOSITE0,
111 .amux = 1,
112 }, {
113 .type = EM28XX_VMUX_SVIDEO,
114 .vmux = SAA7115_SVIDEO3,
115 .amux = 1,
116 } },
117 },
76 [EM2820_BOARD_KWORLD_PVRTV2800RF] = { 118 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
77 .name = "Kworld PVR TV 2800 RF", 119 .name = "Kworld PVR TV 2800 RF",
78 .is_em2800 = 0, 120 .is_em2800 = 0,
@@ -151,6 +193,376 @@ struct em28xx_board em28xx_boards[] = {
151 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART), 193 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
152 } }, 194 } },
153 }, 195 },
196 [EM2820_BOARD_DLINK_USB_TV] = {
197 .name = "D-Link DUB-T210 TV Tuner",
198 .valid = EM28XX_BOARD_NOT_VALIDATED,
199 .vchannels = 3,
200 .is_em2800 = 0,
201 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
202 .tda9887_conf = TDA9887_PRESENT,
203 .decoder = EM28XX_SAA7113,
204 .input = { {
205 .type = EM28XX_VMUX_TELEVISION,
206 .vmux = SAA7115_COMPOSITE2,
207 .amux = 1,
208 }, {
209 .type = EM28XX_VMUX_COMPOSITE1,
210 .vmux = SAA7115_COMPOSITE0,
211 .amux = 1,
212 }, {
213 .type = EM28XX_VMUX_SVIDEO,
214 .vmux = SAA7115_SVIDEO3,
215 .amux = 1,
216 } },
217 },
218 [EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
219 .name = "Hercules Smart TV USB 2.0",
220 .valid = EM28XX_BOARD_NOT_VALIDATED,
221 .vchannels = 3,
222 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
223 .tda9887_conf = TDA9887_PRESENT,
224 .decoder = EM28XX_SAA7113,
225 .input = { {
226 .type = EM28XX_VMUX_TELEVISION,
227 .vmux = SAA7115_COMPOSITE2,
228 .amux = 1,
229 }, {
230 .type = EM28XX_VMUX_COMPOSITE1,
231 .vmux = SAA7115_COMPOSITE0,
232 .amux = 1,
233 }, {
234 .type = EM28XX_VMUX_SVIDEO,
235 .vmux = SAA7115_SVIDEO3,
236 .amux = 1,
237 } },
238 },
239 [EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
240 .name = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
241 .valid = EM28XX_BOARD_NOT_VALIDATED,
242 .vchannels = 3,
243 .is_em2800 = 0,
244 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
245 .tda9887_conf = TDA9887_PRESENT,
246 .decoder = EM28XX_SAA7113,
247 .input = { {
248 .type = EM28XX_VMUX_TELEVISION,
249 .vmux = SAA7115_COMPOSITE2,
250 .amux = 0,
251 }, {
252 .type = EM28XX_VMUX_COMPOSITE1,
253 .vmux = SAA7115_COMPOSITE0,
254 .amux = 1,
255 }, {
256 .type = EM28XX_VMUX_SVIDEO,
257 .vmux = SAA7115_SVIDEO3,
258 .amux = 1,
259 } },
260 },
261 [EM2820_BOARD_GADMEI_UTV310] = {
262 .name = "Gadmei UTV310",
263 .valid = EM28XX_BOARD_NOT_VALIDATED,
264 .vchannels = 3,
265 .tuner_type = TUNER_TNF_5335MF,
266 .tda9887_conf = TDA9887_PRESENT,
267 .decoder = EM28XX_SAA7113,
268 .input = { {
269 .type = EM28XX_VMUX_TELEVISION,
270 .vmux = SAA7115_COMPOSITE1,
271 .amux = 1,
272 }, {
273 .type = EM28XX_VMUX_COMPOSITE1,
274 .vmux = SAA7115_COMPOSITE0,
275 .amux = 1,
276 }, {
277 .type = EM28XX_VMUX_SVIDEO,
278 .vmux = SAA7115_SVIDEO3,
279 .amux = 1,
280 } },
281 },
282 [EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
283 .name = "Leadtek Winfast USB II Deluxe",
284 .valid = EM28XX_BOARD_NOT_VALIDATED,
285 .vchannels = 3,
286 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
287 .tda9887_conf = TDA9887_PRESENT,
288 .decoder = EM28XX_SAA7114,
289 .input = { {
290 .type = EM28XX_VMUX_TELEVISION,
291 .vmux = 2,
292 .amux = 0,
293 }, {
294 .type = EM28XX_VMUX_COMPOSITE1,
295 .vmux = 0,
296 .amux = 1,
297 }, {
298 .type = EM28XX_VMUX_SVIDEO,
299 .vmux = 9,
300 .amux = 1,
301 } },
302 },
303 [EM2820_BOARD_PINNACLE_DVC_100] = {
304 .name = "Pinnacle Dazzle DVC 100",
305 .valid = EM28XX_BOARD_NOT_VALIDATED,
306 .vchannels = 3,
307 .decoder = EM28XX_SAA7113,
308 .input = { {
309 .type = EM28XX_VMUX_COMPOSITE1,
310 .vmux = SAA7115_COMPOSITE0,
311 .amux = 1,
312 }, {
313 .type = EM28XX_VMUX_SVIDEO,
314 .vmux = SAA7115_SVIDEO3,
315 .amux = 1,
316 } },
317 },
318 [EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
319 .name = "Videology 20K14XUSB USB2.0",
320 .valid = EM28XX_BOARD_NOT_VALIDATED,
321 .vchannels = 1,
322 .input = { {
323 .type = EM28XX_VMUX_COMPOSITE1,
324 .vmux = 0,
325 .amux = 0,
326 } },
327 },
328 [EM2821_BOARD_PROLINK_PLAYTV_USB2] = {
329 .name = "SIIG AVTuner-PVR/Prolink PlayTV USB 2.0",
330 .valid = EM28XX_BOARD_NOT_VALIDATED,
331 .vchannels = 3,
332 .is_em2800 = 0,
333 .tuner_type = TUNER_LG_PAL_NEW_TAPC, /* unknown? */
334 .tda9887_conf = TDA9887_PRESENT, /* unknown? */
335 .decoder = EM28XX_SAA7113,
336 .input = { {
337 .type = EM28XX_VMUX_TELEVISION,
338 .vmux = SAA7115_COMPOSITE2,
339 .amux = 1,
340 }, {
341 .type = EM28XX_VMUX_COMPOSITE1,
342 .vmux = SAA7115_COMPOSITE0,
343 .amux = 1,
344 }, {
345 .type = EM28XX_VMUX_SVIDEO,
346 .vmux = SAA7115_SVIDEO3,
347 .amux = 1,
348 } },
349 },
350 [EM2821_BOARD_SUPERCOMP_USB_2] = {
351 .name = "Supercomp USB 2.0 TV",
352 .valid = EM28XX_BOARD_NOT_VALIDATED,
353 .vchannels = 3,
354 .is_em2800 = 0,
355 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
356 .tda9887_conf = TDA9887_PRESENT |
357 TDA9887_PORT1_ACTIVE |
358 TDA9887_PORT2_ACTIVE,
359 .decoder = EM28XX_SAA7113,
360 .input = { {
361 .type = EM28XX_VMUX_TELEVISION,
362 .vmux = SAA7115_COMPOSITE2,
363 .amux = 1,
364 }, {
365 .type = EM28XX_VMUX_COMPOSITE1,
366 .vmux = SAA7115_COMPOSITE0,
367 .amux = 0,
368 }, {
369 .type = EM28XX_VMUX_SVIDEO,
370 .vmux = SAA7115_SVIDEO3,
371 .amux = 1,
372 } },
373 },
374 [EM2821_BOARD_USBGEAR_VD204] = {
375 .name = "Usbgear VD204v9",
376 .valid = EM28XX_BOARD_NOT_VALIDATED,
377 .vchannels = 2,
378 .decoder = EM28XX_SAA7113,
379 .input = { {
380 .type = EM28XX_VMUX_COMPOSITE1,
381 .vmux = SAA7115_COMPOSITE0,
382 .amux = 1,
383 }, {
384 .type = EM28XX_VMUX_SVIDEO,
385 .vmux = SAA7115_SVIDEO3,
386 .amux = 1,
387 } },
388 },
389 [EM2860_BOARD_NETGMBH_CAM] = {
390 /* Beijing Huaqi Information Digital Technology Co., Ltd */
391 .name = "NetGMBH Cam",
392 .valid = EM28XX_BOARD_NOT_VALIDATED,
393 .vchannels = 1,
394 .input = { {
395 .type = EM28XX_VMUX_COMPOSITE1,
396 .vmux = 0,
397 .amux = 0,
398 } },
399 },
400 [EM2860_BOARD_TYPHOON_DVD_MAKER] = {
401 .name = "Typhoon DVD Maker",
402 .valid = EM28XX_BOARD_NOT_VALIDATED,
403 .vchannels = 2,
404 .decoder = EM28XX_SAA7113,
405 .input = { {
406 .type = EM28XX_VMUX_COMPOSITE1,
407 .vmux = SAA7115_COMPOSITE0,
408 .amux = 1,
409 }, {
410 .type = EM28XX_VMUX_SVIDEO,
411 .vmux = SAA7115_SVIDEO3,
412 .amux = 1,
413 } },
414 },
415 [EM2860_BOARD_GADMEI_UTV330] = {
416 .name = "Gadmei UTV330",
417 .valid = EM28XX_BOARD_NOT_VALIDATED,
418 .vchannels = 3,
419 .tuner_type = TUNER_TNF_5335MF,
420 .tda9887_conf = TDA9887_PRESENT,
421 .decoder = EM28XX_SAA7113,
422 .input = { {
423 .type = EM28XX_VMUX_TELEVISION,
424 .vmux = SAA7115_COMPOSITE2,
425 .amux = 0,
426 }, {
427 .type = EM28XX_VMUX_COMPOSITE1,
428 .vmux = SAA7115_COMPOSITE0,
429 .amux = 1,
430 }, {
431 .type = EM28XX_VMUX_SVIDEO,
432 .vmux = SAA7115_SVIDEO3,
433 .amux = 1,
434 } },
435 },
436 [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
437 .name = "Terratec Cinergy A Hybrid XS",
438 .valid = EM28XX_BOARD_NOT_VALIDATED,
439 .vchannels = 3,
440 .tuner_type = TUNER_XC2028,
441 .decoder = EM28XX_TVP5150,
442 .input = { {
443 .type = EM28XX_VMUX_TELEVISION,
444 .vmux = TVP5150_COMPOSITE0,
445 .amux = 0,
446 }, {
447 .type = EM28XX_VMUX_COMPOSITE1,
448 .vmux = TVP5150_COMPOSITE1,
449 .amux = 1,
450 }, {
451 .type = EM28XX_VMUX_SVIDEO,
452 .vmux = TVP5150_SVIDEO,
453 .amux = 1,
454 } },
455 },
456 [EM2861_BOARD_KWORLD_PVRTV_300U] = {
457 .name = "KWorld PVRTV 300U",
458 .valid = EM28XX_BOARD_NOT_VALIDATED,
459 .vchannels = 3,
460 .tuner_type = TUNER_XC2028,
461 .decoder = EM28XX_TVP5150,
462 .input = { {
463 .type = EM28XX_VMUX_TELEVISION,
464 .vmux = TVP5150_COMPOSITE0,
465 .amux = 0,
466 }, {
467 .type = EM28XX_VMUX_COMPOSITE1,
468 .vmux = TVP5150_COMPOSITE1,
469 .amux = 1,
470 }, {
471 .type = EM28XX_VMUX_SVIDEO,
472 .vmux = TVP5150_SVIDEO,
473 .amux = 1,
474 } },
475 },
476 [EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
477 .name = "Yakumo MovieMixer",
478 .valid = EM28XX_BOARD_NOT_VALIDATED,
479 .vchannels = 1,
480 .decoder = EM28XX_TVP5150,
481 .input = { {
482 .type = EM28XX_VMUX_TELEVISION,
483 .vmux = TVP5150_COMPOSITE0,
484 .amux = 0,
485 }, {
486 .type = EM28XX_VMUX_COMPOSITE1,
487 .vmux = TVP5150_COMPOSITE1,
488 .amux = 1,
489 }, {
490 .type = EM28XX_VMUX_SVIDEO,
491 .vmux = TVP5150_SVIDEO,
492 .amux = 1,
493 } },
494 },
495 [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
496 .name = "Plextor ConvertX PX-TV100U",
497 .valid = EM28XX_BOARD_NOT_VALIDATED,
498 .vchannels = 3,
499 .tuner_type = TUNER_TNF_5335MF,
500 .tda9887_conf = TDA9887_PRESENT,
501 .decoder = EM28XX_TVP5150,
502 .input = { {
503 .type = EM28XX_VMUX_TELEVISION,
504 .vmux = TVP5150_COMPOSITE0,
505 .amux = 1,
506 }, {
507 .type = EM28XX_VMUX_COMPOSITE1,
508 .vmux = TVP5150_COMPOSITE1,
509 .amux = 1,
510 }, {
511 .type = EM28XX_VMUX_SVIDEO,
512 .vmux = TVP5150_SVIDEO,
513 .amux = 1,
514 } },
515 },
516 [EM2870_BOARD_TERRATEC_XS] = {
517 .name = "Terratec Cinergy T XS",
518 .valid = EM28XX_BOARD_NOT_VALIDATED,
519 .tuner_type = TUNER_XC2028,
520 },
521 [EM2870_BOARD_TERRATEC_XS_MT2060] = {
522 .name = "Terratec Cinergy T XS (MT2060)",
523 .valid = EM28XX_BOARD_NOT_VALIDATED,
524 .tuner_type = TUNER_ABSENT, /* MT2060 */
525 },
526 [EM2870_BOARD_KWORLD_350U] = {
527 .name = "Kworld 350 U DVB-T",
528 .valid = EM28XX_BOARD_NOT_VALIDATED,
529 .tuner_type = TUNER_XC2028,
530 },
531 [EM2870_BOARD_KWORLD_355U] = {
532 .name = "Kworld 355 U DVB-T",
533 .valid = EM28XX_BOARD_NOT_VALIDATED,
534 },
535 [EM2870_BOARD_PINNACLE_PCTV_DVB] = {
536 .name = "Pinnacle PCTV DVB-T",
537 .valid = EM28XX_BOARD_NOT_VALIDATED,
538 .tuner_type = TUNER_ABSENT, /* MT2060 */
539 },
540 [EM2870_BOARD_COMPRO_VIDEOMATE] = {
541 .name = "Compro, VideoMate U3",
542 .valid = EM28XX_BOARD_NOT_VALIDATED,
543 .tuner_type = TUNER_ABSENT, /* MT2060 */
544 },
545 [EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
546 .name = "Terratec Hybrid XS Secam",
547 .valid = EM28XX_BOARD_NOT_VALIDATED,
548 .vchannels = 3,
549 .has_msp34xx = 1,
550 .tuner_type = TUNER_XC2028,
551 .decoder = EM28XX_TVP5150,
552 .input = { {
553 .type = EM28XX_VMUX_TELEVISION,
554 .vmux = TVP5150_COMPOSITE0,
555 .amux = 0,
556 }, {
557 .type = EM28XX_VMUX_COMPOSITE1,
558 .vmux = TVP5150_COMPOSITE1,
559 .amux = 1,
560 }, {
561 .type = EM28XX_VMUX_SVIDEO,
562 .vmux = TVP5150_SVIDEO,
563 .amux = 1,
564 } },
565 },
154 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = { 566 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
155 .name = "Hauppauge WinTV HVR 900", 567 .name = "Hauppauge WinTV HVR 900",
156 .vchannels = 3, 568 .vchannels = 3,
@@ -194,7 +606,7 @@ struct em28xx_board em28xx_boards[] = {
194 .amux = 1, 606 .amux = 1,
195 } }, 607 } },
196 }, 608 },
197 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = { 609 [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
198 .name = "Hauppauge WinTV HVR 950", 610 .name = "Hauppauge WinTV HVR 950",
199 .vchannels = 3, 611 .vchannels = 3,
200 .tda9887_conf = TDA9887_PRESENT, 612 .tda9887_conf = TDA9887_PRESENT,
@@ -240,12 +652,36 @@ struct em28xx_board em28xx_boards[] = {
240 .amux = 1, 652 .amux = 1,
241 } }, 653 } },
242 }, 654 },
655 [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
656 .name = "AMD ATI TV Wonder HD 600",
657 .vchannels = 3,
658 .tda9887_conf = TDA9887_PRESENT,
659 .tuner_type = TUNER_XC2028,
660 .mts_firmware = 1,
661 .has_12mhz_i2s = 1,
662 .has_dvb = 1,
663 .decoder = EM28XX_TVP5150,
664 .input = { {
665 .type = EM28XX_VMUX_TELEVISION,
666 .vmux = TVP5150_COMPOSITE0,
667 .amux = 0,
668 }, {
669 .type = EM28XX_VMUX_COMPOSITE1,
670 .vmux = TVP5150_COMPOSITE1,
671 .amux = 1,
672 }, {
673 .type = EM28XX_VMUX_SVIDEO,
674 .vmux = TVP5150_SVIDEO,
675 .amux = 1,
676 } },
677 },
243 [EM2880_BOARD_TERRATEC_HYBRID_XS] = { 678 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
244 .name = "Terratec Hybrid XS", 679 .name = "Terratec Hybrid XS",
245 .vchannels = 3, 680 .vchannels = 3,
246 .tda9887_conf = TDA9887_PRESENT, 681 .tda9887_conf = TDA9887_PRESENT,
247 .tuner_type = TUNER_XC2028, 682 .tuner_type = TUNER_XC2028,
248 .decoder = EM28XX_TVP5150, 683 .decoder = EM28XX_TVP5150,
684 .has_dvb = 1,
249 .input = { { 685 .input = { {
250 .type = EM28XX_VMUX_TELEVISION, 686 .type = EM28XX_VMUX_TELEVISION,
251 .vmux = TVP5150_COMPOSITE0, 687 .vmux = TVP5150_COMPOSITE0,
@@ -328,6 +764,21 @@ struct em28xx_board em28xx_boards[] = {
328 .amux = 1, 764 .amux = 1,
329 } }, 765 } },
330 }, 766 },
767 [EM2800_BOARD_GRABBEEX_USB2800] = {
768 .name = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
769 .is_em2800 = 1,
770 .vchannels = 2,
771 .decoder = EM28XX_SAA7113,
772 .input = { {
773 .type = EM28XX_VMUX_COMPOSITE1,
774 .vmux = SAA7115_COMPOSITE0,
775 .amux = 1,
776 }, {
777 .type = EM28XX_VMUX_SVIDEO,
778 .vmux = SAA7115_SVIDEO3,
779 .amux = 1,
780 } },
781 },
331 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = { 782 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
332 .name = "Leadtek Winfast USB II", 783 .name = "Leadtek Winfast USB II",
333 .is_em2800 = 1, 784 .is_em2800 = 1,
@@ -439,13 +890,232 @@ struct em28xx_board em28xx_boards[] = {
439 .amux = 0, 890 .amux = 0,
440 } }, 891 } },
441 }, 892 },
893 [EM2880_BOARD_MSI_DIGIVOX_AD] = {
894 .name = "MSI DigiVox A/D",
895 .valid = EM28XX_BOARD_NOT_VALIDATED,
896 .vchannels = 3,
897 .tuner_type = TUNER_XC2028,
898 .decoder = EM28XX_TVP5150,
899 .input = { {
900 .type = EM28XX_VMUX_TELEVISION,
901 .vmux = TVP5150_COMPOSITE0,
902 .amux = 0,
903 }, {
904 .type = EM28XX_VMUX_COMPOSITE1,
905 .vmux = TVP5150_COMPOSITE1,
906 .amux = 1,
907 }, {
908 .type = EM28XX_VMUX_SVIDEO,
909 .vmux = TVP5150_SVIDEO,
910 .amux = 1,
911 } },
912 },
913 [EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
914 .name = "MSI DigiVox A/D II",
915 .valid = EM28XX_BOARD_NOT_VALIDATED,
916 .vchannels = 3,
917 .tuner_type = TUNER_XC2028,
918 .decoder = EM28XX_TVP5150,
919 .input = { {
920 .type = EM28XX_VMUX_TELEVISION,
921 .vmux = TVP5150_COMPOSITE0,
922 .amux = 0,
923 }, {
924 .type = EM28XX_VMUX_COMPOSITE1,
925 .vmux = TVP5150_COMPOSITE1,
926 .amux = 1,
927 }, {
928 .type = EM28XX_VMUX_SVIDEO,
929 .vmux = TVP5150_SVIDEO,
930 .amux = 1,
931 } },
932 },
933 [EM2880_BOARD_KWORLD_DVB_305U] = {
934 .name = "KWorld DVB-T 305U",
935 .valid = EM28XX_BOARD_NOT_VALIDATED,
936 .vchannels = 3,
937 .tuner_type = TUNER_XC2028,
938 .decoder = EM28XX_TVP5150,
939 .input = { {
940 .type = EM28XX_VMUX_TELEVISION,
941 .vmux = TVP5150_COMPOSITE0,
942 .amux = 0,
943 }, {
944 .type = EM28XX_VMUX_COMPOSITE1,
945 .vmux = TVP5150_COMPOSITE1,
946 .amux = 1,
947 }, {
948 .type = EM28XX_VMUX_SVIDEO,
949 .vmux = TVP5150_SVIDEO,
950 .amux = 1,
951 } },
952 },
953 [EM2880_BOARD_KWORLD_DVB_310U] = {
954 .name = "KWorld DVB-T 310U",
955 .valid = EM28XX_BOARD_NOT_VALIDATED,
956 .vchannels = 3,
957 .tuner_type = TUNER_XC2028,
958 .decoder = EM28XX_TVP5150,
959 .input = { {
960 .type = EM28XX_VMUX_TELEVISION,
961 .vmux = TVP5150_COMPOSITE0,
962 .amux = 0,
963 }, {
964 .type = EM28XX_VMUX_COMPOSITE1,
965 .vmux = TVP5150_COMPOSITE1,
966 .amux = 1,
967 }, {
968 .type = EM28XX_VMUX_SVIDEO,
969 .vmux = TVP5150_SVIDEO,
970 .amux = 1,
971 } },
972 },
973 [EM2881_BOARD_DNT_DA2_HYBRID] = {
974 .name = "DNT DA2 Hybrid",
975 .valid = EM28XX_BOARD_NOT_VALIDATED,
976 .vchannels = 3,
977 .tuner_type = TUNER_XC2028,
978 .decoder = EM28XX_TVP5150,
979 .input = { {
980 .type = EM28XX_VMUX_TELEVISION,
981 .vmux = TVP5150_COMPOSITE0,
982 .amux = 0,
983 }, {
984 .type = EM28XX_VMUX_COMPOSITE1,
985 .vmux = TVP5150_COMPOSITE1,
986 .amux = 1,
987 }, {
988 .type = EM28XX_VMUX_SVIDEO,
989 .vmux = TVP5150_SVIDEO,
990 .amux = 1,
991 } },
992 },
993 [EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
994 .name = "Pinnacle Hybrid Pro",
995 .valid = EM28XX_BOARD_NOT_VALIDATED,
996 .vchannels = 3,
997 .tuner_type = TUNER_XC2028,
998 .decoder = EM28XX_TVP5150,
999 .input = { {
1000 .type = EM28XX_VMUX_TELEVISION,
1001 .vmux = TVP5150_COMPOSITE0,
1002 .amux = 0,
1003 }, {
1004 .type = EM28XX_VMUX_COMPOSITE1,
1005 .vmux = TVP5150_COMPOSITE1,
1006 .amux = 1,
1007 }, {
1008 .type = EM28XX_VMUX_SVIDEO,
1009 .vmux = TVP5150_SVIDEO,
1010 .amux = 1,
1011 } },
1012 },
1013 [EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
1014 .name = "Pinnacle Hybrid Pro (2)",
1015 .valid = EM28XX_BOARD_NOT_VALIDATED,
1016 .vchannels = 3,
1017 .tuner_type = TUNER_XC2028,
1018 .decoder = EM28XX_TVP5150,
1019 .input = { {
1020 .type = EM28XX_VMUX_TELEVISION,
1021 .vmux = TVP5150_COMPOSITE0,
1022 .amux = 0,
1023 }, {
1024 .type = EM28XX_VMUX_COMPOSITE1,
1025 .vmux = TVP5150_COMPOSITE1,
1026 .amux = 1,
1027 }, {
1028 .type = EM28XX_VMUX_SVIDEO,
1029 .vmux = TVP5150_SVIDEO,
1030 .amux = 1,
1031 } },
1032 },
1033 [EM2882_BOARD_KWORLD_VS_DVBT] = {
1034 .name = "Kworld VS-DVB-T 323UR",
1035 .valid = EM28XX_BOARD_NOT_VALIDATED,
1036 .vchannels = 3,
1037 .tuner_type = TUNER_XC2028,
1038 .decoder = EM28XX_TVP5150,
1039 .input = { {
1040 .type = EM28XX_VMUX_TELEVISION,
1041 .vmux = TVP5150_COMPOSITE0,
1042 .amux = 0,
1043 }, {
1044 .type = EM28XX_VMUX_COMPOSITE1,
1045 .vmux = TVP5150_COMPOSITE1,
1046 .amux = 1,
1047 }, {
1048 .type = EM28XX_VMUX_SVIDEO,
1049 .vmux = TVP5150_SVIDEO,
1050 .amux = 1,
1051 } },
1052 },
1053 [EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1054 .name = "Terratec Hybrid XS (em2882)",
1055 .valid = EM28XX_BOARD_NOT_VALIDATED,
1056 .vchannels = 3,
1057 .tuner_type = TUNER_XC2028,
1058 .decoder = EM28XX_TVP5150,
1059 .input = { {
1060 .type = EM28XX_VMUX_TELEVISION,
1061 .vmux = TVP5150_COMPOSITE0,
1062 .amux = 0,
1063 }, {
1064 .type = EM28XX_VMUX_COMPOSITE1,
1065 .vmux = TVP5150_COMPOSITE1,
1066 .amux = 1,
1067 }, {
1068 .type = EM28XX_VMUX_SVIDEO,
1069 .vmux = TVP5150_SVIDEO,
1070 .amux = 1,
1071 } },
1072 },
1073 [EM2883_BOARD_KWORLD_HYBRID_A316] = {
1074 .name = "Kworld PlusTV HD Hybrid 330",
1075 .valid = EM28XX_BOARD_NOT_VALIDATED,
1076 .vchannels = 3,
1077 .is_em2800 = 0,
1078 .tuner_type = TUNER_XC2028,
1079 .decoder = EM28XX_TVP5150,
1080 .input = { {
1081 .type = EM28XX_VMUX_TELEVISION,
1082 .vmux = TVP5150_COMPOSITE0,
1083 .amux = 0,
1084 }, {
1085 .type = EM28XX_VMUX_COMPOSITE1,
1086 .vmux = TVP5150_COMPOSITE1,
1087 .amux = 1,
1088 }, {
1089 .type = EM28XX_VMUX_SVIDEO,
1090 .vmux = TVP5150_SVIDEO,
1091 .amux = 1,
1092 } },
1093 },
1094 [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1095 .name = "Compro VideoMate ForYou/Stereo",
1096 .vchannels = 2,
1097 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
1098 .tda9887_conf = TDA9887_PRESENT,
1099 .decoder = EM28XX_TVP5150,
1100 .input = { {
1101 .type = EM28XX_VMUX_TELEVISION,
1102 .vmux = TVP5150_COMPOSITE0,
1103 .amux = EM28XX_AMUX_LINE_IN,
1104 }, {
1105 .type = EM28XX_VMUX_SVIDEO,
1106 .vmux = TVP5150_SVIDEO,
1107 .amux = EM28XX_AMUX_LINE_IN,
1108 } },
1109 },
442}; 1110};
443const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); 1111const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
444 1112
445/* table of devices that work with this driver */ 1113/* table of devices that work with this driver */
446struct usb_device_id em28xx_id_table [] = { 1114struct usb_device_id em28xx_id_table [] = {
447 { USB_DEVICE(0xeb1a, 0x2750), 1115 { USB_DEVICE(0xeb1a, 0x2750),
448 .driver_info = EM2820_BOARD_UNKNOWN }, 1116 .driver_info = EM2750_BOARD_UNKNOWN },
1117 { USB_DEVICE(0xeb1a, 0x2751),
1118 .driver_info = EM2750_BOARD_UNKNOWN },
449 { USB_DEVICE(0xeb1a, 0x2800), 1119 { USB_DEVICE(0xeb1a, 0x2800),
450 .driver_info = EM2800_BOARD_UNKNOWN }, 1120 .driver_info = EM2800_BOARD_UNKNOWN },
451 { USB_DEVICE(0xeb1a, 0x2820), 1121 { USB_DEVICE(0xeb1a, 0x2820),
@@ -462,36 +1132,78 @@ struct usb_device_id em28xx_id_table [] = {
462 .driver_info = EM2820_BOARD_UNKNOWN }, 1132 .driver_info = EM2820_BOARD_UNKNOWN },
463 { USB_DEVICE(0xeb1a, 0x2883), 1133 { USB_DEVICE(0xeb1a, 0x2883),
464 .driver_info = EM2820_BOARD_UNKNOWN }, 1134 .driver_info = EM2820_BOARD_UNKNOWN },
1135 { USB_DEVICE(0xeb1a, 0xe300),
1136 .driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
1137 { USB_DEVICE(0xeb1a, 0xe305),
1138 .driver_info = EM2880_BOARD_KWORLD_DVB_305U },
1139 { USB_DEVICE(0xeb1a, 0xe310),
1140 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
1141 { USB_DEVICE(0xeb1a, 0xa316),
1142 .driver_info = EM2883_BOARD_KWORLD_HYBRID_A316 },
1143 { USB_DEVICE(0xeb1a, 0xe320),
1144 .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
1145 { USB_DEVICE(0xeb1a, 0xe323),
1146 .driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
1147 { USB_DEVICE(0xeb1a, 0xe350),
1148 .driver_info = EM2870_BOARD_KWORLD_350U },
1149 { USB_DEVICE(0xeb1a, 0xe355),
1150 .driver_info = EM2870_BOARD_KWORLD_355U },
1151 { USB_DEVICE(0xeb1a, 0x2801),
1152 .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
1153 { USB_DEVICE(0xeb1a, 0xe357),
1154 .driver_info = EM2870_BOARD_KWORLD_355U },
465 { USB_DEVICE(0x0ccd, 0x0036), 1155 { USB_DEVICE(0x0ccd, 0x0036),
466 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 }, 1156 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
467 { USB_DEVICE(0x2304, 0x0208), 1157 { USB_DEVICE(0x0ccd, 0x004c),
468 .driver_info = EM2820_BOARD_PINNACLE_USB_2 }, 1158 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
1159 { USB_DEVICE(0x0ccd, 0x004f),
1160 .driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
1161 { USB_DEVICE(0x0ccd, 0x005e),
1162 .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
1163 { USB_DEVICE(0x0ccd, 0x0042),
1164 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
1165 { USB_DEVICE(0x0ccd, 0x0043),
1166 .driver_info = EM2870_BOARD_TERRATEC_XS },
1167 { USB_DEVICE(0x0ccd, 0x0047),
1168 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
1169 { USB_DEVICE(0x185b, 0x2870),
1170 .driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
1171 { USB_DEVICE(0x185b, 0x2041),
1172 .driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
469 { USB_DEVICE(0x2040, 0x4200), 1173 { USB_DEVICE(0x2040, 0x4200),
470 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 }, 1174 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
471 { USB_DEVICE(0x2040, 0x4201), 1175 { USB_DEVICE(0x2040, 0x4201),
472 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 }, 1176 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
473 { USB_DEVICE(0x2304, 0x0207),
474 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
475 { USB_DEVICE(0x2304, 0x021a),
476 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
477 { USB_DEVICE(0x2304, 0x0227),
478 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
479 { USB_DEVICE(0x2040, 0x6500), 1177 { USB_DEVICE(0x2040, 0x6500),
480 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 1178 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
481 { USB_DEVICE(0x2040, 0x6502), 1179 { USB_DEVICE(0x2040, 0x6502),
482 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 }, 1180 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
483 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */ 1181 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
484 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 1182 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
485 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */ 1183 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
486 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 1184 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
487 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */ 1185 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
488 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 1186 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
489 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */ 1187 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
490 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 1188 .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
491 { USB_DEVICE(0x0ccd, 0x0042), 1189 { USB_DEVICE(0x0438, 0xb002),
492 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, 1190 .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
493 { USB_DEVICE(0x0ccd, 0x0047), 1191 { USB_DEVICE(0x2001, 0xf112),
494 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS }, 1192 .driver_info = EM2820_BOARD_DLINK_USB_TV },
1193 { USB_DEVICE(0x2304, 0x0207),
1194 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1195 { USB_DEVICE(0x2304, 0x0208),
1196 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
1197 { USB_DEVICE(0x2304, 0x021a),
1198 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1199 { USB_DEVICE(0x2304, 0x0226),
1200 .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO },
1201 { USB_DEVICE(0x2304, 0x0227),
1202 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
1203 { USB_DEVICE(0x0413, 0x6023),
1204 .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
1205 { USB_DEVICE(0x093b, 0xa005),
1206 .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
495 { }, 1207 { },
496}; 1208};
497MODULE_DEVICE_TABLE(usb, em28xx_id_table); 1209MODULE_DEVICE_TABLE(usb, em28xx_id_table);
@@ -500,6 +1212,18 @@ MODULE_DEVICE_TABLE(usb, em28xx_id_table);
500 * Reset sequences for analog/digital modes 1212 * Reset sequences for analog/digital modes
501 */ 1213 */
502 1214
1215/* Reset for the most [analog] boards */
1216static struct em28xx_reg_seq default_analog[] = {
1217 {EM28XX_R08_GPIO, 0x6d, ~EM_GPIO_4, 10},
1218 { -1, -1, -1, -1},
1219};
1220
1221/* Reset for the most [digital] boards */
1222static struct em28xx_reg_seq default_digital[] = {
1223 {EM28XX_R08_GPIO, 0x6e, ~EM_GPIO_4, 10},
1224 { -1, -1, -1, -1},
1225};
1226
503/* Board Hauppauge WinTV HVR 900 analog */ 1227/* Board Hauppauge WinTV HVR 900 analog */
504static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = { 1228static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
505 {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10}, 1229 {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10},
@@ -515,14 +1239,42 @@ static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
515 { -1, -1, -1, -1}, 1239 { -1, -1, -1, -1},
516}; 1240};
517 1241
518/* Board Hauppauge WinTV HVR 900 tuner_callback */ 1242/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
519static struct em28xx_reg_seq hauppauge_wintv_hvr_900_tuner_callback[] = { 1243static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
1244 {EM28XX_R08_GPIO, 0x69, ~EM_GPIO_4, 10},
1245 { -1, -1, -1, -1},
1246};
1247
1248/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
1249static struct em28xx_reg_seq em2880_msi_digivox_ad_digital[] = {
1250 {EM28XX_R08_GPIO, 0x6a, ~EM_GPIO_4, 10},
1251 { -1, -1, -1, -1},
1252};
1253
1254/* Board - EM2870 Kworld 355u
1255 Analog - No input analog */
1256static struct em28xx_reg_seq em2870_kworld_355u_digital[] = {
1257 {EM2880_R04_GPO, 0x01, 0xff, 10},
1258 { -1, -1, -1, -1},
1259};
1260
1261/* Callback for the most boards */
1262static struct em28xx_reg_seq default_callback[] = {
520 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, 1263 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
521 {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10}, 1264 {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10},
522 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, 1265 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
523 { -1, -1, -1, -1}, 1266 { -1, -1, -1, -1},
524}; 1267};
525 1268
1269/* Callback for EM2882 TERRATEC HYBRID XS */
1270static struct em28xx_reg_seq em2882_terratec_hybrid_xs_digital[] = {
1271 {EM28XX_R08_GPIO, 0x2e, 0xff, 6},
1272 {EM28XX_R08_GPIO, 0x3e, ~EM_GPIO_4, 6},
1273 {EM2880_R04_GPO, 0x04, 0xff, 10},
1274 {EM2880_R04_GPO, 0x0c, 0xff, 10},
1275 { -1, -1, -1, -1},
1276};
1277
526/* 1278/*
527 * EEPROM hash table for devices with generic USB IDs 1279 * EEPROM hash table for devices with generic USB IDs
528 */ 1280 */
@@ -569,6 +1321,7 @@ static void em28xx_set_model(struct em28xx *dev)
569 dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; 1321 dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
570 dev->has_dvb = em28xx_boards[dev->model].has_dvb; 1322 dev->has_dvb = em28xx_boards[dev->model].has_dvb;
571 dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button; 1323 dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button;
1324 dev->valid = em28xx_boards[dev->model].valid;
572} 1325}
573 1326
574/* Since em28xx_pre_card_setup() requires a proper dev->model, 1327/* Since em28xx_pre_card_setup() requires a proper dev->model,
@@ -604,19 +1357,171 @@ void em28xx_pre_card_setup(struct em28xx *dev)
604 case EM2880_BOARD_TERRATEC_PRODIGY_XS: 1357 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
605 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 1358 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
606 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 1359 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
607 case EM2880_BOARD_TERRATEC_HYBRID_XS: 1360 case EM2860_BOARD_TERRATEC_HYBRID_XS:
608 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: 1361 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
609 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 1362 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1363 case EM2882_BOARD_PINNACLE_HYBRID_PRO:
1364 case EM2883_BOARD_KWORLD_HYBRID_A316:
1365 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1366 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1367 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1368 msleep(50);
1369
1370 /* Sets GPO/GPIO sequences for this device */
1371 dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
1372 dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
1373 dev->tun_analog_gpio = default_callback;
1374 dev->tun_digital_gpio = default_callback;
1375 break;
1376
1377 case EM2882_BOARD_TERRATEC_HYBRID_XS:
610 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1); 1378 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
611 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1); 1379 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
612 msleep(50); 1380 msleep(50);
613 1381
1382 /* should be added ir_codes here */
1383
614 /* Sets GPO/GPIO sequences for this device */ 1384 /* Sets GPO/GPIO sequences for this device */
615 dev->analog_gpio = hauppauge_wintv_hvr_900_analog; 1385 dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
616 dev->digital_gpio = hauppauge_wintv_hvr_900_digital; 1386 dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
617 dev->tun_analog_gpio = hauppauge_wintv_hvr_900_tuner_callback; 1387 dev->tun_analog_gpio = default_callback;
618 dev->tun_digital_gpio = hauppauge_wintv_hvr_900_tuner_callback; 1388 dev->tun_digital_gpio = em2882_terratec_hybrid_xs_digital;
1389 break;
1390
1391 case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
1392 case EM2880_BOARD_TERRATEC_HYBRID_XS:
1393 case EM2870_BOARD_TERRATEC_XS:
1394 case EM2881_BOARD_PINNACLE_HYBRID_PRO:
1395 case EM2880_BOARD_KWORLD_DVB_310U:
1396 case EM2870_BOARD_KWORLD_350U:
1397 case EM2881_BOARD_DNT_DA2_HYBRID:
1398 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1399 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1400 msleep(50);
1401
1402 /* NOTE: EM2881_DNT_DA2_HYBRID spend 140 msleep for digital
1403 and analog commands. If this commands doesn't work,
1404 add this timer. */
619 1405
1406 /* Sets GPO/GPIO sequences for this device */
1407 dev->analog_gpio = default_analog;
1408 dev->digital_gpio = default_digital;
1409 dev->tun_analog_gpio = default_callback;
1410 dev->tun_digital_gpio = default_callback;
1411 break;
1412
1413 case EM2880_BOARD_MSI_DIGIVOX_AD:
1414 case EM2880_BOARD_MSI_DIGIVOX_AD_II:
1415 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1416 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1417 msleep(50);
1418
1419 /* Sets GPO/GPIO sequences for this device */
1420 dev->analog_gpio = em2880_msi_digivox_ad_analog;
1421 dev->digital_gpio = em2880_msi_digivox_ad_digital;
1422 dev->tun_analog_gpio = default_callback;
1423 dev->tun_digital_gpio = default_callback;
1424 break;
1425
1426 case EM2750_BOARD_UNKNOWN:
1427 case EM2750_BOARD_DLCW_130:
1428 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x0a", 1);
1429 break;
1430
1431 case EM2861_BOARD_PLEXTOR_PX_TV100U:
1432 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1433 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1434 /* FIXME guess */
1435 /* Turn on analog audio output */
1436 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1437 break;
1438
1439 case EM2861_BOARD_KWORLD_PVRTV_300U:
1440 case EM2880_BOARD_KWORLD_DVB_305U:
1441 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1442 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x4c", 1);
1443 msleep(10);
1444 em28xx_write_regs(dev, 0x08, "\x6d", 1);
1445 msleep(10);
1446 em28xx_write_regs(dev, 0x08, "\x7d", 1);
1447 msleep(10);
1448 break;
1449
1450 case EM2870_BOARD_KWORLD_355U:
1451 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1452 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1453 msleep(50);
1454
1455 /* Sets GPO/GPIO sequences for this device */
1456 dev->digital_gpio = em2870_kworld_355u_digital;
1457 break;
1458
1459 case EM2870_BOARD_COMPRO_VIDEOMATE:
1460 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1461 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1462 /* TODO: someone can do some cleanup here...
1463 not everything's needed */
1464 em28xx_write_regs(dev, 0x04, "\x00", 1);
1465 msleep(10);
1466 em28xx_write_regs(dev, 0x04, "\x01", 1);
1467 msleep(10);
1468 em28xx_write_regs(dev, 0x08, "\xfd", 1);
1469 mdelay(70);
1470 em28xx_write_regs(dev, 0x08, "\xfc", 1);
1471 mdelay(70);
1472 em28xx_write_regs(dev, 0x08, "\xdc", 1);
1473 mdelay(70);
1474 em28xx_write_regs(dev, 0x08, "\xfc", 1);
1475 mdelay(70);
1476 break;
1477
1478 case EM2870_BOARD_TERRATEC_XS_MT2060:
1479 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1480 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1481 /* this device needs some gpio writes to get the DVB-T
1482 demod work */
1483 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1484 mdelay(70);
1485 em28xx_write_regs(dev, 0x08, "\xde", 1);
1486 mdelay(70);
1487 dev->em28xx_write_regs(dev, 0x08, "\xfe", 1);
1488 mdelay(70);
1489 break;
1490
1491 case EM2870_BOARD_PINNACLE_PCTV_DVB:
1492 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1493 /* this device needs some gpio writes to get the
1494 DVB-T demod work */
1495 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1496 mdelay(70);
1497 em28xx_write_regs(dev, 0x08, "\xde", 1);
1498 mdelay(70);
1499 em28xx_write_regs(dev, 0x08, "\xfe", 1);
1500 mdelay(70);
1501 /* switch em2880 rc protocol */
1502 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x22", 1);
1503 /* should be added ir_codes here */
1504 break;
1505
1506 case EM2820_BOARD_GADMEI_UTV310:
1507 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1508 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1509 /* Turn on analog audio output */
1510 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
1511 break;
1512
1513 case EM2860_BOARD_GADMEI_UTV330:
1514 /* Turn on IR */
1515 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
1516 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1517 /* should be added ir_codes here */
1518 break;
1519
1520 case EM2820_BOARD_MSI_VOX_USB_2:
1521 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
1522 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
1523 /* enables audio for that device */
1524 em28xx_write_regs_req(dev, 0x00, 0x08, "\xfd", 1);
620 break; 1525 break;
621 } 1526 }
622 1527
@@ -639,12 +1544,16 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
639 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 1544 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
640 ctl->demod = XC3028_FE_ZARLINK456; 1545 ctl->demod = XC3028_FE_ZARLINK456;
641 break; 1546 break;
1547 case EM2880_BOARD_TERRATEC_HYBRID_XS:
1548 ctl->demod = XC3028_FE_ZARLINK456;
1549 break;
642 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 1550 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
643 /* djh - Not sure which demod we need here */ 1551 /* djh - Not sure which demod we need here */
644 ctl->demod = XC3028_FE_DEFAULT; 1552 ctl->demod = XC3028_FE_DEFAULT;
645 break; 1553 break;
646 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: 1554 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
647 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 1555 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1556 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
648 /* FIXME: Better to specify the needed IF */ 1557 /* FIXME: Better to specify the needed IF */
649 ctl->demod = XC3028_FE_DEFAULT; 1558 ctl->demod = XC3028_FE_DEFAULT;
650 break; 1559 break;
@@ -809,6 +1718,8 @@ void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
809 break; 1718 break;
810 case (EM2800_BOARD_KWORLD_USB2800): 1719 case (EM2800_BOARD_KWORLD_USB2800):
811 break; 1720 break;
1721 case (EM2800_BOARD_GRABBEEX_USB2800):
1722 break;
812 } 1723 }
813} 1724}
814 1725
@@ -823,7 +1734,7 @@ void em28xx_card_setup(struct em28xx *dev)
823 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: 1734 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
824 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 1735 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
825 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 1736 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
826 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: 1737 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
827 { 1738 {
828 struct tveeprom tv; 1739 struct tveeprom tv;
829#ifdef CONFIG_MODULES 1740#ifdef CONFIG_MODULES
@@ -836,7 +1747,7 @@ void em28xx_card_setup(struct em28xx *dev)
836 1747
837 dev->tuner_type = tv.tuner_type; 1748 dev->tuner_type = tv.tuner_type;
838 1749
839 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) { 1750 if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
840 dev->i2s_speed = 2048000; 1751 dev->i2s_speed = 2048000;
841 dev->has_msp34xx = 1; 1752 dev->has_msp34xx = 1;
842 } 1753 }
@@ -854,11 +1765,21 @@ void em28xx_card_setup(struct em28xx *dev)
854 case EM2800_BOARD_UNKNOWN: 1765 case EM2800_BOARD_UNKNOWN:
855 if (!em28xx_hint_board(dev)) 1766 if (!em28xx_hint_board(dev))
856 em28xx_set_model(dev); 1767 em28xx_set_model(dev);
1768 break;
857 } 1769 }
858 1770
859 if (dev->has_snapshot_button) 1771 if (dev->has_snapshot_button)
860 em28xx_register_snapshot_button(dev); 1772 em28xx_register_snapshot_button(dev);
861 1773
1774 if (dev->valid == EM28XX_BOARD_NOT_VALIDATED) {
1775 em28xx_errdev("\n\n");
1776 em28xx_errdev("The support for this board weren't "
1777 "valid yet.\n");
1778 em28xx_errdev("Please send a report of having this working\n");
1779 em28xx_errdev("not to V4L mailing list (and/or to other "
1780 "addresses)\n\n");
1781 }
1782
862 /* Allow override tuner type by a module parameter */ 1783 /* Allow override tuner type by a module parameter */
863 if (tuner >= 0) 1784 if (tuner >= 0)
864 dev->tuner_type = tuner; 1785 dev->tuner_type = tuner;
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index cc61cfb23a4a..4b992bc0083c 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -6,6 +6,7 @@
6 (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com> 6 (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com>
7 - Fixes for the driver to properly work with HVR-950 7 - Fixes for the driver to properly work with HVR-950
8 - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick 8 - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick
9 - Fixes for the driver to properly work with AMD ATI TV Wonder HD 600
9 10
10 (c) 2008 Aidan Thornton <makosoft@googlemail.com> 11 (c) 2008 Aidan Thornton <makosoft@googlemail.com>
11 12
@@ -409,8 +410,9 @@ static int dvb_init(struct em28xx *dev)
409 em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 410 em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
410 /* init frontend */ 411 /* init frontend */
411 switch (dev->model) { 412 switch (dev->model) {
412 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: 413 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
413 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 414 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
415 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
414 dvb->frontend = dvb_attach(lgdt330x_attach, 416 dvb->frontend = dvb_attach(lgdt330x_attach,
415 &em2880_lgdt3303_dev, 417 &em2880_lgdt3303_dev,
416 &dev->i2c_adap); 418 &dev->i2c_adap);
@@ -441,6 +443,15 @@ static int dvb_init(struct em28xx *dev)
441 } 443 }
442 break; 444 break;
443#endif 445#endif
446 case EM2880_BOARD_TERRATEC_HYBRID_XS:
447 dvb->frontend = dvb_attach(zl10353_attach,
448 &em28xx_zl10353_with_xc3028,
449 &dev->i2c_adap);
450 if (attach_xc3028(0x61, dev) < 0) {
451 result = -EINVAL;
452 goto out_free;
453 }
454 break;
444 default: 455 default:
445 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" 456 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
446 " isn't supported yet\n", 457 " isn't supported yet\n",
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2d9f14d2a00b..49ab0629702e 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -38,6 +38,7 @@
38 38
39#include "em28xx.h" 39#include "em28xx.h"
40#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
41#include <media/v4l2-ioctl.h>
41#include <media/msp3400.h> 42#include <media/msp3400.h>
42#include <media/tuner.h> 43#include <media/tuner.h>
43 44
@@ -1763,20 +1764,7 @@ static const struct file_operations em28xx_v4l_fops = {
1763 .compat_ioctl = v4l_compat_ioctl32, 1764 .compat_ioctl = v4l_compat_ioctl32,
1764}; 1765};
1765 1766
1766static const struct file_operations radio_fops = { 1767static const struct v4l2_ioctl_ops video_ioctl_ops = {
1767 .owner = THIS_MODULE,
1768 .open = em28xx_v4l2_open,
1769 .release = em28xx_v4l2_close,
1770 .ioctl = video_ioctl2,
1771 .compat_ioctl = v4l_compat_ioctl32,
1772 .llseek = no_llseek,
1773};
1774
1775static const struct video_device em28xx_video_template = {
1776 .fops = &em28xx_v4l_fops,
1777 .release = video_device_release,
1778
1779 .minor = -1,
1780 .vidioc_querycap = vidioc_querycap, 1768 .vidioc_querycap = vidioc_querycap,
1781 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1769 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1782 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1770 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1814,16 +1802,29 @@ static const struct video_device em28xx_video_template = {
1814#ifdef CONFIG_VIDEO_V4L1_COMPAT 1802#ifdef CONFIG_VIDEO_V4L1_COMPAT
1815 .vidiocgmbuf = vidiocgmbuf, 1803 .vidiocgmbuf = vidiocgmbuf,
1816#endif 1804#endif
1805};
1806
1807static const struct video_device em28xx_video_template = {
1808 .fops = &em28xx_v4l_fops,
1809 .release = video_device_release,
1810 .ioctl_ops = &video_ioctl_ops,
1811
1812 .minor = -1,
1817 1813
1818 .tvnorms = V4L2_STD_ALL, 1814 .tvnorms = V4L2_STD_ALL,
1819 .current_norm = V4L2_STD_PAL, 1815 .current_norm = V4L2_STD_PAL,
1820}; 1816};
1821 1817
1822static struct video_device em28xx_radio_template = { 1818static const struct file_operations radio_fops = {
1823 .name = "em28xx-radio", 1819 .owner = THIS_MODULE,
1824 .type = VID_TYPE_TUNER, 1820 .open = em28xx_v4l2_open,
1825 .fops = &radio_fops, 1821 .release = em28xx_v4l2_close,
1826 .minor = -1, 1822 .ioctl = video_ioctl2,
1823 .compat_ioctl = v4l_compat_ioctl32,
1824 .llseek = no_llseek,
1825};
1826
1827static const struct v4l2_ioctl_ops radio_ioctl_ops = {
1827 .vidioc_querycap = radio_querycap, 1828 .vidioc_querycap = radio_querycap,
1828 .vidioc_g_tuner = radio_g_tuner, 1829 .vidioc_g_tuner = radio_g_tuner,
1829 .vidioc_enum_input = radio_enum_input, 1830 .vidioc_enum_input = radio_enum_input,
@@ -1842,6 +1843,13 @@ static struct video_device em28xx_radio_template = {
1842#endif 1843#endif
1843}; 1844};
1844 1845
1846static struct video_device em28xx_radio_template = {
1847 .name = "em28xx-radio",
1848 .fops = &radio_fops,
1849 .ioctl_ops = &radio_ioctl_ops,
1850 .minor = -1,
1851};
1852
1845/******************************** usb interface ******************************/ 1853/******************************** usb interface ******************************/
1846 1854
1847 1855
@@ -1882,7 +1890,6 @@ EXPORT_SYMBOL(em28xx_unregister_extension);
1882 1890
1883static struct video_device *em28xx_vdev_init(struct em28xx *dev, 1891static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1884 const struct video_device *template, 1892 const struct video_device *template,
1885 const int type,
1886 const char *type_name) 1893 const char *type_name)
1887{ 1894{
1888 struct video_device *vfd; 1895 struct video_device *vfd;
@@ -1892,9 +1899,8 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1892 return NULL; 1899 return NULL;
1893 *vfd = *template; 1900 *vfd = *template;
1894 vfd->minor = -1; 1901 vfd->minor = -1;
1895 vfd->dev = &dev->udev->dev; 1902 vfd->parent = &dev->udev->dev;
1896 vfd->release = video_device_release; 1903 vfd->release = video_device_release;
1897 vfd->type = type;
1898 vfd->debug = video_debug; 1904 vfd->debug = video_debug;
1899 1905
1900 snprintf(vfd->name, sizeof(vfd->name), "%s %s", 1906 snprintf(vfd->name, sizeof(vfd->name), "%s %s",
@@ -1972,14 +1978,11 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1972 list_add_tail(&dev->devlist, &em28xx_devlist); 1978 list_add_tail(&dev->devlist, &em28xx_devlist);
1973 1979
1974 /* allocate and fill video video_device struct */ 1980 /* allocate and fill video video_device struct */
1975 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, 1981 dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
1976 VID_TYPE_CAPTURE, "video");
1977 if (NULL == dev->vdev) { 1982 if (NULL == dev->vdev) {
1978 em28xx_errdev("cannot allocate video_device.\n"); 1983 em28xx_errdev("cannot allocate video_device.\n");
1979 goto fail_unreg; 1984 goto fail_unreg;
1980 } 1985 }
1981 if (dev->tuner_type != TUNER_ABSENT)
1982 dev->vdev->type |= VID_TYPE_TUNER;
1983 1986
1984 /* register v4l2 video video_device */ 1987 /* register v4l2 video video_device */
1985 retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, 1988 retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
@@ -1991,8 +1994,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1991 } 1994 }
1992 1995
1993 /* Allocate and fill vbi video_device struct */ 1996 /* Allocate and fill vbi video_device struct */
1994 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, 1997 dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi");
1995 VFL_TYPE_VBI, "vbi");
1996 /* register v4l2 vbi video_device */ 1998 /* register v4l2 vbi video_device */
1997 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI, 1999 if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI,
1998 vbi_nr[dev->devno]) < 0) { 2000 vbi_nr[dev->devno]) < 0) {
@@ -2002,8 +2004,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2002 } 2004 }
2003 2005
2004 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) { 2006 if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) {
2005 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, 2007 dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio");
2006 VFL_TYPE_RADIO, "radio");
2007 if (NULL == dev->radio_dev) { 2008 if (NULL == dev->radio_dev) {
2008 em28xx_errdev("cannot allocate video_device.\n"); 2009 em28xx_errdev("cannot allocate video_device.\n");
2009 goto fail_unreg; 2010 goto fail_unreg;
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 89842c5d64a1..9a3310748685 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -54,15 +54,58 @@
54#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 54#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13
55#define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 55#define EM2820_BOARD_PROLINK_PLAYTV_USB2 14
56#define EM2800_BOARD_VGEAR_POCKETTV 15 56#define EM2800_BOARD_VGEAR_POCKETTV 15
57#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 57#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 16
58#define EM2880_BOARD_PINNACLE_PCTV_HD_PRO 17 58#define EM2880_BOARD_PINNACLE_PCTV_HD_PRO 17
59#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 18 59#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 18
60#define EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA 19 60#define EM2860_BOARD_POINTNIX_INTRAORAL_CAMERA 19
61#define EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 20
62#define EM2800_BOARD_GRABBEEX_USB2800 21
63#define EM2750_BOARD_UNKNOWN 22
64#define EM2750_BOARD_DLCW_130 23
65#define EM2820_BOARD_DLINK_USB_TV 24
66#define EM2820_BOARD_GADMEI_UTV310 25
67#define EM2820_BOARD_HERCULES_SMART_TV_USB2 26
68#define EM2820_BOARD_PINNACLE_USB_2_FM1216ME 27
69#define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28
70#define EM2820_BOARD_PINNACLE_DVC_100 29
71#define EM2820_BOARD_VIDEOLOGY_20K14XUSB 30
72#define EM2821_BOARD_USBGEAR_VD204 31
73#define EM2821_BOARD_SUPERCOMP_USB_2 32
74#define EM2821_BOARD_PROLINK_PLAYTV_USB2 33
75#define EM2860_BOARD_TERRATEC_HYBRID_XS 34
76#define EM2860_BOARD_TYPHOON_DVD_MAKER 35
77#define EM2860_BOARD_NETGMBH_CAM 36
78#define EM2860_BOARD_GADMEI_UTV330 37
79#define EM2861_BOARD_YAKUMO_MOVIE_MIXER 38
80#define EM2861_BOARD_KWORLD_PVRTV_300U 39
81#define EM2861_BOARD_PLEXTOR_PX_TV100U 40
82#define EM2870_BOARD_KWORLD_350U 41
83#define EM2870_BOARD_KWORLD_355U 42
84#define EM2870_BOARD_TERRATEC_XS 43
85#define EM2870_BOARD_TERRATEC_XS_MT2060 44
86#define EM2870_BOARD_PINNACLE_PCTV_DVB 45
87#define EM2870_BOARD_COMPRO_VIDEOMATE 46
88#define EM2880_BOARD_KWORLD_DVB_305U 47
89#define EM2880_BOARD_KWORLD_DVB_310U 48
90#define EM2880_BOARD_MSI_DIGIVOX_AD 49
91#define EM2880_BOARD_MSI_DIGIVOX_AD_II 50
92#define EM2880_BOARD_TERRATEC_HYBRID_XS_FR 51
93#define EM2881_BOARD_DNT_DA2_HYBRID 52
94#define EM2881_BOARD_PINNACLE_HYBRID_PRO 53
95#define EM2882_BOARD_KWORLD_VS_DVBT 54
96#define EM2882_BOARD_TERRATEC_HYBRID_XS 55
97#define EM2882_BOARD_PINNACLE_HYBRID_PRO 56
98#define EM2883_BOARD_KWORLD_HYBRID_A316 57
99#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58
61 100
62/* Limits minimum and default number of buffers */ 101/* Limits minimum and default number of buffers */
63#define EM28XX_MIN_BUF 4 102#define EM28XX_MIN_BUF 4
64#define EM28XX_DEF_BUF 8 103#define EM28XX_DEF_BUF 8
65 104
105/* Params for validated field */
106#define EM28XX_BOARD_NOT_VALIDATED 1
107#define EM28XX_BOARD_VALIDATED 0
108
66/* maximum number of em28xx boards */ 109/* maximum number of em28xx boards */
67#define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ 110#define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */
68 111
@@ -251,6 +294,7 @@ struct em28xx_board {
251 unsigned int max_range_640_480:1; 294 unsigned int max_range_640_480:1;
252 unsigned int has_dvb:1; 295 unsigned int has_dvb:1;
253 unsigned int has_snapshot_button:1; 296 unsigned int has_snapshot_button:1;
297 unsigned int valid:1;
254 298
255 enum em28xx_decoder decoder; 299 enum em28xx_decoder decoder;
256 300
@@ -331,6 +375,7 @@ struct em28xx {
331 unsigned int max_range_640_480:1; 375 unsigned int max_range_640_480:1;
332 unsigned int has_dvb:1; 376 unsigned int has_dvb:1;
333 unsigned int has_snapshot_button:1; 377 unsigned int has_snapshot_button:1;
378 unsigned int valid:1; /* report for validated boards */
334 379
335 /* Some older em28xx chips needs a waiting time after writing */ 380 /* Some older em28xx chips needs a waiting time after writing */
336 unsigned int wait_after_write; 381 unsigned int wait_after_write;
@@ -360,7 +405,7 @@ struct em28xx {
360 v4l2_std_id norm; /* selected tv norm */ 405 v4l2_std_id norm; /* selected tv norm */
361 int ctl_freq; /* selected frequency */ 406 int ctl_freq; /* selected frequency */
362 unsigned int ctl_input; /* selected input */ 407 unsigned int ctl_input; /* selected input */
363 unsigned int ctl_ainput; /* slected audio input */ 408 unsigned int ctl_ainput;/* selected audio input */
364 int mute; 409 int mute;
365 int volume; 410 int volume;
366 /* frame properties */ 411 /* frame properties */
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 15d037ae25c5..2d170d101c21 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -34,6 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/page-flags.h> 36#include <linux/page-flags.h>
37#include <media/v4l2-ioctl.h>
37#include <asm/byteorder.h> 38#include <asm/byteorder.h>
38#include <asm/page.h> 39#include <asm/page.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
@@ -985,7 +986,7 @@ static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
985 986
986static int et61x251_create_sysfs(struct et61x251_device* cam) 987static int et61x251_create_sysfs(struct et61x251_device* cam)
987{ 988{
988 struct device *classdev = &(cam->v4ldev->class_dev); 989 struct device *classdev = &(cam->v4ldev->dev);
989 int err = 0; 990 int err = 0;
990 991
991 if ((err = device_create_file(classdev, &dev_attr_reg))) 992 if ((err = device_create_file(classdev, &dev_attr_reg)))
@@ -2584,8 +2585,6 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2584 } 2585 }
2585 2586
2586 strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera"); 2587 strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera");
2587 cam->v4ldev->owner = THIS_MODULE;
2588 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
2589 cam->v4ldev->fops = &et61x251_fops; 2588 cam->v4ldev->fops = &et61x251_fops;
2590 cam->v4ldev->minor = video_nr[dev_nr]; 2589 cam->v4ldev->minor = video_nr[dev_nr];
2591 cam->v4ldev->release = video_device_release; 2590 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 013d593b0c67..44b0bffeb20e 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -25,9 +25,6 @@
25#define CONEX_CAM 1 /* special JPEG header */ 25#define CONEX_CAM 1 /* special JPEG header */
26#include "jpeg.h" 26#include "jpeg.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
29static const char version[] = "2.1.7";
30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); 29MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver");
33MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -818,7 +815,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
818 struct cam *cam; 815 struct cam *cam;
819 816
820 cam = &gspca_dev->cam; 817 cam = &gspca_dev->cam;
821 cam->dev_name = (char *) id->driver_info;
822 cam->epaddr = 0x01; 818 cam->epaddr = 0x01;
823 cam->cam_mode = vga_mode; 819 cam->cam_mode = vga_mode;
824 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 820 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
@@ -1011,9 +1007,8 @@ static struct sd_desc sd_desc = {
1011}; 1007};
1012 1008
1013/* -- module initialisation -- */ 1009/* -- module initialisation -- */
1014#define DVNM(name) .driver_info = (kernel_ulong_t) name
1015static __devinitdata struct usb_device_id device_table[] = { 1010static __devinitdata struct usb_device_id device_table[] = {
1016 {USB_DEVICE(0x0572, 0x0041), DVNM("Creative Notebook cx11646")}, 1011 {USB_DEVICE(0x0572, 0x0041)},
1017 {} 1012 {}
1018}; 1013};
1019MODULE_DEVICE_TABLE(usb, device_table); 1014MODULE_DEVICE_TABLE(usb, device_table);
@@ -1038,7 +1033,7 @@ static int __init sd_mod_init(void)
1038{ 1033{
1039 if (usb_register(&sd_driver) < 0) 1034 if (usb_register(&sd_driver) < 0)
1040 return -1; 1035 return -1;
1041 PDEBUG(D_PROBE, "v%s registered", version); 1036 PDEBUG(D_PROBE, "registered");
1042 return 0; 1037 return 0;
1043} 1038}
1044static void __exit sd_mod_exit(void) 1039static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index 8ab4ea7201a9..c8c2f02fcf00 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("Etoms USB Camera Driver"); 26MODULE_DESCRIPTION("Etoms USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -602,26 +599,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
602{ 599{
603 struct sd *sd = (struct sd *) gspca_dev; 600 struct sd *sd = (struct sd *) gspca_dev;
604 struct cam *cam; 601 struct cam *cam;
605 __u16 vendor; 602
606 __u16 product;
607
608 vendor = id->idVendor;
609 product = id->idProduct;
610/* switch (vendor) { */
611/* case 0x102c: * Etoms */
612 switch (product) {
613 case 0x6151:
614 sd->sensor = SENSOR_PAS106; /* Etoms61x151 */
615 break;
616 case 0x6251:
617 sd->sensor = SENSOR_TAS5130CXX; /* Etoms61x251 */
618 break;
619/* } */
620/* break; */
621 }
622 cam = &gspca_dev->cam; 603 cam = &gspca_dev->cam;
623 cam->dev_name = (char *) id->driver_info;
624 cam->epaddr = 1; 604 cam->epaddr = 1;
605 sd->sensor = id->driver_info;
625 if (sd->sensor == SENSOR_PAS106) { 606 if (sd->sensor == SENSOR_PAS106) {
626 cam->cam_mode = sif_mode; 607 cam->cam_mode = sif_mode;
627 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 608 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
@@ -911,12 +892,11 @@ static struct sd_desc sd_desc = {
911}; 892};
912 893
913/* -- module initialisation -- */ 894/* -- module initialisation -- */
914#define DVNM(name) .driver_info = (kernel_ulong_t) name
915static __devinitdata struct usb_device_id device_table[] = { 895static __devinitdata struct usb_device_id device_table[] = {
916#ifndef CONFIG_USB_ET61X251 896#ifndef CONFIG_USB_ET61X251
917 {USB_DEVICE(0x102c, 0x6151), DVNM("Qcam Sangha CIF")}, 897 {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106},
918#endif 898#endif
919 {USB_DEVICE(0x102c, 0x6251), DVNM("Qcam xxxxxx VGA")}, 899 {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX},
920 {} 900 {}
921}; 901};
922 902
@@ -942,7 +922,7 @@ static int __init sd_mod_init(void)
942{ 922{
943 if (usb_register(&sd_driver) < 0) 923 if (usb_register(&sd_driver) < 0)
944 return -1; 924 return -1;
945 PDEBUG(D_PROBE, "v%s registered", version); 925 PDEBUG(D_PROBE, "registered");
946 return 0; 926 return 0;
947} 927}
948 928
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 16e367cec760..3a051c925ff6 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -32,6 +32,7 @@
32#include <asm/page.h> 32#include <asm/page.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/jiffies.h> 34#include <linux/jiffies.h>
35#include <media/v4l2-ioctl.h>
35 36
36#include "gspca.h" 37#include "gspca.h"
37 38
@@ -42,8 +43,7 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
42MODULE_DESCRIPTION("GSPCA USB Camera Driver"); 43MODULE_DESCRIPTION("GSPCA USB Camera Driver");
43MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
44 45
45#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) 46#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 2, 0)
46static const char version[] = "2.1.7";
47 47
48static int video_nr = -1; 48static int video_nr = -1;
49 49
@@ -209,6 +209,8 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
209 &frame->v4l2_buf.timestamp); 209 &frame->v4l2_buf.timestamp);
210 frame->v4l2_buf.sequence = ++gspca_dev->sequence; 210 frame->v4l2_buf.sequence = ++gspca_dev->sequence;
211 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) { 211 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) {
212 if (packet_type == LAST_PACKET)
213 gspca_dev->last_packet_type = packet_type;
212 return frame; 214 return frame;
213 } 215 }
214 216
@@ -399,7 +401,7 @@ static struct usb_host_endpoint *alt_isoc(struct usb_host_interface *alt,
399 * This routine may be called many times when the bandwidth is too small 401 * This routine may be called many times when the bandwidth is too small
400 * (the bandwidth is checked on urb submit). 402 * (the bandwidth is checked on urb submit).
401 */ 403 */
402struct usb_host_endpoint *get_isoc_ep(struct gspca_dev *gspca_dev) 404static struct usb_host_endpoint *get_isoc_ep(struct gspca_dev *gspca_dev)
403{ 405{
404 struct usb_interface *intf; 406 struct usb_interface *intf;
405 struct usb_host_endpoint *ep; 407 struct usb_host_endpoint *ep;
@@ -832,7 +834,16 @@ static int vidioc_querycap(struct file *file, void *priv,
832 834
833 memset(cap, 0, sizeof *cap); 835 memset(cap, 0, sizeof *cap);
834 strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver); 836 strncpy(cap->driver, gspca_dev->sd_desc->name, sizeof cap->driver);
835 strncpy(cap->card, gspca_dev->cam.dev_name, sizeof cap->card); 837/* strncpy(cap->card, gspca_dev->cam.dev_name, sizeof cap->card); */
838 if (gspca_dev->dev->product != NULL) {
839 strncpy(cap->card, gspca_dev->dev->product,
840 sizeof cap->card);
841 } else {
842 snprintf(cap->card, sizeof cap->card,
843 "USB Camera (%04x:%04x)",
844 le16_to_cpu(gspca_dev->dev->descriptor.idVendor),
845 le16_to_cpu(gspca_dev->dev->descriptor.idProduct));
846 }
836 strncpy(cap->bus_info, gspca_dev->dev->bus->bus_name, 847 strncpy(cap->bus_info, gspca_dev->dev->bus->bus_name,
837 sizeof cap->bus_info); 848 sizeof cap->bus_info);
838 cap->version = DRIVER_VERSION_NUMBER; 849 cap->version = DRIVER_VERSION_NUMBER;
@@ -1649,12 +1660,7 @@ static struct file_operations dev_fops = {
1649 .poll = dev_poll, 1660 .poll = dev_poll,
1650}; 1661};
1651 1662
1652static struct video_device gspca_template = { 1663static const struct v4l2_ioctl_ops dev_ioctl_ops = {
1653 .name = "gspca main driver",
1654 .type = VID_TYPE_CAPTURE,
1655 .fops = &dev_fops,
1656 .release = dev_release, /* mandatory */
1657 .minor = -1,
1658 .vidioc_querycap = vidioc_querycap, 1664 .vidioc_querycap = vidioc_querycap,
1659 .vidioc_dqbuf = vidioc_dqbuf, 1665 .vidioc_dqbuf = vidioc_dqbuf,
1660 .vidioc_qbuf = vidioc_qbuf, 1666 .vidioc_qbuf = vidioc_qbuf,
@@ -1683,6 +1689,14 @@ static struct video_device gspca_template = {
1683#endif 1689#endif
1684}; 1690};
1685 1691
1692static struct video_device gspca_template = {
1693 .name = "gspca main driver",
1694 .fops = &dev_fops,
1695 .ioctl_ops = &dev_ioctl_ops,
1696 .release = dev_release, /* mandatory */
1697 .minor = -1,
1698};
1699
1686/* 1700/*
1687 * probe and create a new gspca device 1701 * probe and create a new gspca device
1688 * 1702 *
@@ -1740,10 +1754,11 @@ int gspca_dev_probe(struct usb_interface *intf,
1740 1754
1741 /* init video stuff */ 1755 /* init video stuff */
1742 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); 1756 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template);
1743 gspca_dev->vdev.dev = &dev->dev; 1757 gspca_dev->vdev.parent = &dev->dev;
1744 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); 1758 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops);
1745 gspca_dev->vdev.fops = &gspca_dev->fops; 1759 gspca_dev->vdev.fops = &gspca_dev->fops;
1746 gspca_dev->fops.owner = module; /* module protection */ 1760 gspca_dev->fops.owner = module; /* module protection */
1761 gspca_dev->present = 1;
1747 ret = video_register_device(&gspca_dev->vdev, 1762 ret = video_register_device(&gspca_dev->vdev,
1748 VFL_TYPE_GRABBER, 1763 VFL_TYPE_GRABBER,
1749 video_nr); 1764 video_nr);
@@ -1752,7 +1767,6 @@ int gspca_dev_probe(struct usb_interface *intf,
1752 goto out; 1767 goto out;
1753 } 1768 }
1754 1769
1755 gspca_dev->present = 1;
1756 usb_set_intfdata(intf, gspca_dev); 1770 usb_set_intfdata(intf, gspca_dev);
1757 PDEBUG(D_PROBE, "probe ok"); 1771 PDEBUG(D_PROBE, "probe ok");
1758 return 0; 1772 return 0;
@@ -1885,7 +1899,10 @@ EXPORT_SYMBOL(gspca_auto_gain_n_exposure);
1885/* -- module insert / remove -- */ 1899/* -- module insert / remove -- */
1886static int __init gspca_init(void) 1900static int __init gspca_init(void)
1887{ 1901{
1888 info("main v%s registered", version); 1902 info("main v%d.%d.%d registered",
1903 (DRIVER_VERSION_NUMBER >> 16) & 0xff,
1904 (DRIVER_VERSION_NUMBER >> 8) & 0xff,
1905 DRIVER_VERSION_NUMBER & 0xff);
1889 return 0; 1906 return 0;
1890} 1907}
1891static void __exit gspca_exit(void) 1908static void __exit gspca_exit(void)
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index 88c2b02f380a..21c4ee56a10a 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -140,7 +137,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
140 struct cam *cam; 137 struct cam *cam;
141 138
142 cam = &gspca_dev->cam; 139 cam = &gspca_dev->cam;
143 cam->dev_name = (char *) id->driver_info;
144 cam->epaddr = 0x01; 140 cam->epaddr = 0x01;
145 cam->cam_mode = vga_mode; 141 cam->cam_mode = vga_mode;
146 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 142 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
@@ -424,9 +420,8 @@ static const struct sd_desc sd_desc = {
424}; 420};
425 421
426/* -- module initialisation -- */ 422/* -- module initialisation -- */
427#define DVNM(name) .driver_info = (kernel_ulong_t) name
428static const __devinitdata struct usb_device_id device_table[] = { 423static const __devinitdata struct usb_device_id device_table[] = {
429 {USB_DEVICE(0x093a, 0x050f), DVNM("Mars-Semi Pc-Camera")}, 424 {USB_DEVICE(0x093a, 0x050f)},
430 {} 425 {}
431}; 426};
432MODULE_DEVICE_TABLE(usb, device_table); 427MODULE_DEVICE_TABLE(usb, device_table);
@@ -451,7 +446,7 @@ static int __init sd_mod_init(void)
451{ 446{
452 if (usb_register(&sd_driver) < 0) 447 if (usb_register(&sd_driver) < 0)
453 return -1; 448 return -1;
454 PDEBUG(D_PROBE, "v%s registered", version); 449 PDEBUG(D_PROBE, "registered");
455 return 0; 450 return 0;
456} 451}
457static void __exit sd_mod_exit(void) 452static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index 08d99c3b78e2..83139efc4629 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 27MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("OV519 USB Camera Driver"); 28MODULE_DESCRIPTION("OV519 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1375,7 +1372,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
1375 cam->cam_mode = sif_mode; 1372 cam->cam_mode = sif_mode;
1376 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 1373 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
1377 } 1374 }
1378 cam->dev_name = (char *) id->driver_info;
1379 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 1375 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
1380 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 1376 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
1381 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; 1377 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
@@ -2129,21 +2125,20 @@ static const struct sd_desc sd_desc = {
2129}; 2125};
2130 2126
2131/* -- module initialisation -- */ 2127/* -- module initialisation -- */
2132#define DVNM(name) .driver_info = (kernel_ulong_t) name
2133static const __devinitdata struct usb_device_id device_table[] = { 2128static const __devinitdata struct usb_device_id device_table[] = {
2134 {USB_DEVICE(0x041e, 0x4052), DVNM("Creative Live! VISTA IM")}, 2129 {USB_DEVICE(0x041e, 0x4052)},
2135 {USB_DEVICE(0x041e, 0x405f), DVNM("Creative Live! VISTA VF0330")}, 2130 {USB_DEVICE(0x041e, 0x405f)},
2136 {USB_DEVICE(0x041e, 0x4060), DVNM("Creative Live! VISTA VF0350")}, 2131 {USB_DEVICE(0x041e, 0x4060)},
2137 {USB_DEVICE(0x041e, 0x4061), DVNM("Creative Live! VISTA VF0400")}, 2132 {USB_DEVICE(0x041e, 0x4061)},
2138 {USB_DEVICE(0x041e, 0x4064), DVNM("Creative Live! VISTA VF0420")}, 2133 {USB_DEVICE(0x041e, 0x4064)},
2139 {USB_DEVICE(0x041e, 0x4068), DVNM("Creative Live! VISTA VF0470")}, 2134 {USB_DEVICE(0x041e, 0x4068)},
2140 {USB_DEVICE(0x045e, 0x028c), DVNM("Microsoft xbox cam")}, 2135 {USB_DEVICE(0x045e, 0x028c)},
2141 {USB_DEVICE(0x054c, 0x0154), DVNM("Sonny toy4")}, 2136 {USB_DEVICE(0x054c, 0x0154)},
2142 {USB_DEVICE(0x054c, 0x0155), DVNM("Sonny toy5")}, 2137 {USB_DEVICE(0x054c, 0x0155)},
2143 {USB_DEVICE(0x05a9, 0x0519), DVNM("OmniVision")}, 2138 {USB_DEVICE(0x05a9, 0x0519)},
2144 {USB_DEVICE(0x05a9, 0x0530), DVNM("OmniVision")}, 2139 {USB_DEVICE(0x05a9, 0x0530)},
2145 {USB_DEVICE(0x05a9, 0x4519), DVNM("OmniVision")}, 2140 {USB_DEVICE(0x05a9, 0x4519)},
2146 {USB_DEVICE(0x05a9, 0x8519), DVNM("OmniVision")}, 2141 {USB_DEVICE(0x05a9, 0x8519)},
2147 {} 2142 {}
2148}; 2143};
2149#undef DVNAME 2144#undef DVNAME
@@ -2169,7 +2164,7 @@ static int __init sd_mod_init(void)
2169{ 2164{
2170 if (usb_register(&sd_driver) < 0) 2165 if (usb_register(&sd_driver) < 0)
2171 return -1; 2166 return -1;
2172 PDEBUG(D_PROBE, "v%s registered", version); 2167 PDEBUG(D_PROBE, "registered");
2173 return 0; 2168 return 0;
2174} 2169}
2175static void __exit sd_mod_exit(void) 2170static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index fa7abc411090..7ef18d578811 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -27,9 +27,6 @@
27 27
28#include "gspca.h" 28#include "gspca.h"
29 29
30#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
31static const char version[] = "2.1.7";
32
33MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); 30MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>");
34MODULE_DESCRIPTION("Pixart PAC207"); 31MODULE_DESCRIPTION("Pixart PAC207");
35MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
@@ -208,7 +205,7 @@ static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
208} 205}
209 206
210 207
211int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value) 208static int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
212{ 209{
213 struct usb_device *udev = gspca_dev->dev; 210 struct usb_device *udev = gspca_dev->dev;
214 int err; 211 int err;
@@ -223,8 +220,7 @@ int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
223 return err; 220 return err;
224} 221}
225 222
226 223static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
227int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
228{ 224{
229 struct usb_device *udev = gspca_dev->dev; 225 struct usb_device *udev = gspca_dev->dev;
230 int res; 226 int res;
@@ -574,17 +570,16 @@ static const struct sd_desc sd_desc = {
574}; 570};
575 571
576/* -- module initialisation -- */ 572/* -- module initialisation -- */
577#define DVNM(name) .driver_info = (kernel_ulong_t) name
578static const __devinitdata struct usb_device_id device_table[] = { 573static const __devinitdata struct usb_device_id device_table[] = {
579 {USB_DEVICE(0x041e, 0x4028), DVNM("Creative Webcam Vista Plus")}, 574 {USB_DEVICE(0x041e, 0x4028)},
580 {USB_DEVICE(0x093a, 0x2460), DVNM("Q-Tec Webcam 100")}, 575 {USB_DEVICE(0x093a, 0x2460)},
581 {USB_DEVICE(0x093a, 0x2463), DVNM("Philips spc200nc pac207")}, 576 {USB_DEVICE(0x093a, 0x2463)},
582 {USB_DEVICE(0x093a, 0x2464), DVNM("Labtec Webcam 1200")}, 577 {USB_DEVICE(0x093a, 0x2464)},
583 {USB_DEVICE(0x093a, 0x2468), DVNM("PAC207")}, 578 {USB_DEVICE(0x093a, 0x2468)},
584 {USB_DEVICE(0x093a, 0x2470), DVNM("Genius GF112")}, 579 {USB_DEVICE(0x093a, 0x2470)},
585 {USB_DEVICE(0x093a, 0x2471), DVNM("Genius VideoCam GE111")}, 580 {USB_DEVICE(0x093a, 0x2471)},
586 {USB_DEVICE(0x093a, 0x2472), DVNM("Genius VideoCam GE110")}, 581 {USB_DEVICE(0x093a, 0x2472)},
587 {USB_DEVICE(0x2001, 0xf115), DVNM("D-Link DSB-C120")}, 582 {USB_DEVICE(0x2001, 0xf115)},
588 {} 583 {}
589}; 584};
590MODULE_DEVICE_TABLE(usb, device_table); 585MODULE_DEVICE_TABLE(usb, device_table);
@@ -609,7 +604,7 @@ static int __init sd_mod_init(void)
609{ 604{
610 if (usb_register(&sd_driver) < 0) 605 if (usb_register(&sd_driver) < 0)
611 return -1; 606 return -1;
612 PDEBUG(D_PROBE, "v%s registered", version); 607 PDEBUG(D_PROBE, "registered");
613 return 0; 608 return 0;
614} 609}
615static void __exit sd_mod_exit(void) 610static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 5c052e31be4a..ea3d7021f401 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); 26MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
30MODULE_DESCRIPTION("Pixart PAC7311"); 27MODULE_DESCRIPTION("Pixart PAC7311");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -266,7 +263,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
266 reg_w(gspca_dev, 0x3e, 0x20); 263 reg_w(gspca_dev, 0x3e, 0x20);
267 264
268 cam = &gspca_dev->cam; 265 cam = &gspca_dev->cam;
269 cam->dev_name = (char *) id->driver_info;
270 cam->epaddr = 0x05; 266 cam->epaddr = 0x05;
271 cam->cam_mode = vga_mode; 267 cam->cam_mode = vga_mode;
272 cam->nmodes = ARRAY_SIZE(vga_mode); 268 cam->nmodes = ARRAY_SIZE(vga_mode);
@@ -713,16 +709,14 @@ static struct sd_desc sd_desc = {
713}; 709};
714 710
715/* -- module initialisation -- */ 711/* -- module initialisation -- */
716#define DVNM(name) .driver_info = (kernel_ulong_t) name
717static __devinitdata struct usb_device_id device_table[] = { 712static __devinitdata struct usb_device_id device_table[] = {
718 {USB_DEVICE(0x093a, 0x2600), DVNM("Typhoon")}, 713 {USB_DEVICE(0x093a, 0x2600)},
719 {USB_DEVICE(0x093a, 0x2601), DVNM("Philips SPC610NC")}, 714 {USB_DEVICE(0x093a, 0x2601)},
720 {USB_DEVICE(0x093a, 0x2603), DVNM("PAC7312")}, 715 {USB_DEVICE(0x093a, 0x2603)},
721 {USB_DEVICE(0x093a, 0x2608), DVNM("Trust WB-3300p")}, 716 {USB_DEVICE(0x093a, 0x2608)},
722 {USB_DEVICE(0x093a, 0x260e), DVNM("Gigaware VGA PC Camera")}, 717 {USB_DEVICE(0x093a, 0x260e)},
723 /* and also ', Trust WB-3350p, SIGMA cam 2350' */ 718 {USB_DEVICE(0x093a, 0x260f)},
724 {USB_DEVICE(0x093a, 0x260f), DVNM("SnakeCam")}, 719 {USB_DEVICE(0x093a, 0x2621)},
725 {USB_DEVICE(0x093a, 0x2621), DVNM("PAC731x")},
726 {} 720 {}
727}; 721};
728MODULE_DEVICE_TABLE(usb, device_table); 722MODULE_DEVICE_TABLE(usb, device_table);
@@ -747,7 +741,7 @@ static int __init sd_mod_init(void)
747{ 741{
748 if (usb_register(&sd_driver) < 0) 742 if (usb_register(&sd_driver) < 0)
749 return -1; 743 return -1;
750 PDEBUG(D_PROBE, "v%s registered", version); 744 PDEBUG(D_PROBE, "registered");
751 return 0; 745 return 0;
752} 746}
753static void __exit sd_mod_exit(void) 747static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index dbeebe8625c5..e18748c5a14d 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 8)
28static const char version[] = "2.1.8";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -44,25 +41,29 @@ struct sd {
44 unsigned char brightness; 41 unsigned char brightness;
45 unsigned char autogain; 42 unsigned char autogain;
46 unsigned char autogain_ignore_frames; 43 unsigned char autogain_ignore_frames;
44 unsigned char frames_to_drop;
47 unsigned char freq; /* light freq filter setting */ 45 unsigned char freq; /* light freq filter setting */
48 unsigned char saturation;
49 unsigned char hue;
50 unsigned char contrast;
51 46
52 unsigned char fr_h_sz; /* size of frame header */ 47 unsigned char fr_h_sz; /* size of frame header */
53 char sensor; /* Type of image sensor chip */ 48 char sensor; /* Type of image sensor chip */
54#define SENSOR_HV7131R 0 49#define SENSOR_HV7131R 0
55#define SENSOR_OV6650 1 50#define SENSOR_OV6650 1
56#define SENSOR_OV7630 2 51#define SENSOR_OV7630 2
57#define SENSOR_OV7630_3 3 52#define SENSOR_PAS106 3
58#define SENSOR_PAS106 4 53#define SENSOR_PAS202 4
59#define SENSOR_PAS202 5 54#define SENSOR_TAS5110 5
60#define SENSOR_TAS5110 6 55#define SENSOR_TAS5130CXX 6
61#define SENSOR_TAS5130CXX 7
62 char sensor_has_gain; 56 char sensor_has_gain;
63 __u8 sensor_addr; 57 __u8 sensor_addr;
58 __u8 reg11;
64}; 59};
65 60
61/* flags used in the device id table */
62#define F_GAIN 0x01 /* has gain */
63#define F_AUTO 0x02 /* has autogain */
64#define F_SIF 0x04 /* sif or vga */
65#define F_H18 0x08 /* long (18 b) or short (12 b) frame header */
66
66#define COMP2 0x8f 67#define COMP2 0x8f
67#define COMP 0xc7 /* 0x87 //0x07 */ 68#define COMP 0xc7 /* 0x87 //0x07 */
68#define COMP1 0xc9 /* 0x89 //0x09 */ 69#define COMP1 0xc9 /* 0x89 //0x09 */
@@ -92,12 +93,6 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
92static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 93static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
93static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); 94static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
94static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 95static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
95static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val);
97static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val);
99static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
100static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
101 96
102static struct ctrl sd_ctrls[] = { 97static struct ctrl sd_ctrls[] = {
103 { 98 {
@@ -174,48 +169,6 @@ static struct ctrl sd_ctrls[] = {
174 .set = sd_setfreq, 169 .set = sd_setfreq,
175 .get = sd_getfreq, 170 .get = sd_getfreq,
176 }, 171 },
177 {
178 {
179 .id = V4L2_CID_SATURATION,
180 .type = V4L2_CTRL_TYPE_INTEGER,
181 .name = "Saturation",
182 .minimum = 0,
183 .maximum = 255,
184 .step = 1,
185#define SATURATION_DEF 127
186 .default_value = SATURATION_DEF,
187 },
188 .set = sd_setsaturation,
189 .get = sd_getsaturation,
190 },
191 {
192 {
193 .id = V4L2_CID_HUE,
194 .type = V4L2_CTRL_TYPE_INTEGER,
195 .name = "Hue",
196 .minimum = 0,
197 .maximum = 255,
198 .step = 1,
199#define HUE_DEF 127
200 .default_value = HUE_DEF,
201 },
202 .set = sd_sethue,
203 .get = sd_gethue,
204 },
205 {
206 {
207 .id = V4L2_CID_CONTRAST,
208 .type = V4L2_CTRL_TYPE_INTEGER,
209 .name = "Contrast",
210 .minimum = 0,
211 .maximum = 255,
212 .step = 1,
213#define CONTRAST_DEF 127
214 .default_value = CONTRAST_DEF,
215 },
216 .set = sd_setcontrast,
217 .get = sd_getcontrast,
218 },
219}; 172};
220 173
221static struct v4l2_pix_format vga_mode[] = { 174static struct v4l2_pix_format vga_mode[] = {
@@ -248,8 +201,6 @@ static struct v4l2_pix_format sif_mode[] = {
248 .priv = 0}, 201 .priv = 0},
249}; 202};
250 203
251static const __u8 probe_ov7630[] = {0x08, 0x44};
252
253static const __u8 initHv7131[] = { 204static const __u8 initHv7131[] = {
254 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 205 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00,
255 0x00, 0x00, 206 0x00, 0x00,
@@ -321,7 +272,7 @@ static const __u8 initOv7630_3[] = {
321 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */ 272 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */
322 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */ 273 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */
323}; 274};
324static const __u8 ov7630_sensor_init_com[][8] = { 275static const __u8 ov7630_sensor_init[][8] = {
325 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, 276 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
326 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10}, 277 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10},
327/* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */ 278/* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */
@@ -342,17 +293,6 @@ static const __u8 ov7630_sensor_init_com[][8] = {
342 {0xa0, 0x21, 0x7d, 0xf7, 0x8e, 0x00, 0x30, 0x10}, 293 {0xa0, 0x21, 0x7d, 0xf7, 0x8e, 0x00, 0x30, 0x10},
343 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, 294 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10},
344}; 295};
345static const __u8 ov7630_sensor_init[][8] = {
346 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 200ms */
347 {0xa0, 0x21, 0x11, 0x01, 0xbd, 0x06, 0xf6, 0x10}, /* jfm */
348 {0xa0, 0x21, 0x10, 0x57, 0xbd, 0x06, 0xf6, 0x16},
349 {0xa0, 0x21, 0x76, 0x02, 0xbd, 0x06, 0xf6, 0x16},
350 {0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15}, /* gain */
351};
352static const __u8 ov7630_sensor_init_3[][8] = {
353 {0xa0, 0x21, 0x2a, 0xa0, 0x00, 0x00, 0x00, 0x10},
354 {0xa0, 0x21, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x10},
355};
356 296
357static const __u8 initPas106[] = { 297static const __u8 initPas106[] = {
358 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, 298 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00,
@@ -542,7 +482,6 @@ static void setbrightness(struct gspca_dev *gspca_dev)
542 482
543 switch (sd->sensor) { 483 switch (sd->sensor) {
544 case SENSOR_OV6650: 484 case SENSOR_OV6650:
545 case SENSOR_OV7630_3:
546 case SENSOR_OV7630: { 485 case SENSOR_OV7630: {
547 __u8 i2cOV[] = 486 __u8 i2cOV[] =
548 {0xa0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}; 487 {0xa0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10};
@@ -635,7 +574,7 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
635 case SENSOR_OV6650: 574 case SENSOR_OV6650:
636 gain >>= 1; 575 gain >>= 1;
637 /* fall thru */ 576 /* fall thru */
638 case SENSOR_OV7630_3: { 577 case SENSOR_OV7630: {
639 __u8 i2c[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; 578 __u8 i2c[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10};
640 579
641 i2c[1] = sd->sensor_addr; 580 i2c[1] = sd->sensor_addr;
@@ -690,7 +629,7 @@ static void setexposure(struct gspca_dev *gspca_dev)
690 break; 629 break;
691 } 630 }
692 case SENSOR_OV6650: 631 case SENSOR_OV6650:
693 case SENSOR_OV7630_3: { 632 case SENSOR_OV7630: {
694 /* The ov6650 / ov7630 have 2 registers which both influence 633 /* The ov6650 / ov7630 have 2 registers which both influence
695 exposure, register 11, whose low nibble sets the nr off fps 634 exposure, register 11, whose low nibble sets the nr off fps
696 according to: fps = 30 / (low_nibble + 1) 635 according to: fps = 30 / (low_nibble + 1)
@@ -705,16 +644,20 @@ static void setexposure(struct gspca_dev *gspca_dev)
705 The code maps our 0 - 510 ms exposure ctrl to these 2 644 The code maps our 0 - 510 ms exposure ctrl to these 2
706 registers, trying to keep fps as high as possible. 645 registers, trying to keep fps as high as possible.
707 */ 646 */
708 __u8 i2c[] = {0xb0, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x00, 0x10}; 647 __u8 i2c[] = {0xb0, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10};
709 int reg10, reg11; 648 int reg10, reg11, reg10_max;
649
710 /* ov6645 datasheet says reg10_max is 9a, but that uses 650 /* ov6645 datasheet says reg10_max is 9a, but that uses
711 tline * 2 * reg10 as formula for calculating texpo, the 651 tline * 2 * reg10 as formula for calculating texpo, the
712 ov6650 probably uses the same formula as the 7730 which uses 652 ov6650 probably uses the same formula as the 7730 which uses
713 tline * 4 * reg10, which explains why the reg10max we've 653 tline * 4 * reg10, which explains why the reg10max we've
714 found experimentally for the ov6650 is exactly half that of 654 found experimentally for the ov6650 is exactly half that of
715 the ov6645. The ov7630 datasheet says the max is 0x41. */ 655 the ov6645. The ov7630 datasheet says the max is 0x41. */
716 const int reg10_max = (sd->sensor == SENSOR_OV6650) 656 if (sd->sensor == SENSOR_OV6650) {
717 ? 0x4d : 0x41; 657 reg10_max = 0x4d;
658 i2c[4] = 0xc0; /* OV6650 needs non default vsync pol */
659 } else
660 reg10_max = 0x41;
718 661
719 reg11 = (60 * sd->exposure + 999) / 1000; 662 reg11 = (60 * sd->exposure + 999) / 1000;
720 if (reg11 < 1) 663 if (reg11 < 1)
@@ -735,20 +678,23 @@ static void setexposure(struct gspca_dev *gspca_dev)
735 else if (reg10 > reg10_max) 678 else if (reg10 > reg10_max)
736 reg10 = reg10_max; 679 reg10 = reg10_max;
737 680
681 /* In 640x480, if the reg11 has less than 3, the image is
682 unstable (not enough bandwidth). */
683 if (gspca_dev->width == 640 && reg11 < 3)
684 reg11 = 3;
685
738 /* Write reg 10 and reg11 low nibble */ 686 /* Write reg 10 and reg11 low nibble */
739 i2c[1] = sd->sensor_addr; 687 i2c[1] = sd->sensor_addr;
740 i2c[3] = reg10; 688 i2c[3] = reg10;
741 i2c[4] |= reg11 - 1; 689 i2c[4] |= reg11 - 1;
742 if (sd->sensor == SENSOR_OV7630_3) { 690
743 __u8 reg76 = reg10 & 0x03; 691 /* If register 11 didn't change, don't change it */
744 __u8 i2c_reg76[] = {0xa0, 0x21, 0x76, 0x00, 692 if (sd->reg11 == reg11 )
745 0x00, 0x00, 0x00, 0x10}; 693 i2c[0] = 0xa0;
746 reg10 >>= 2; 694
747 i2c_reg76[3] = reg76; 695 if (i2c_w(gspca_dev, i2c) == 0)
748 if (i2c_w(gspca_dev, i2c_reg76) < 0) 696 sd->reg11 = reg11;
749 PDEBUG(D_ERR, "i2c error exposure"); 697 else
750 }
751 if (i2c_w(gspca_dev, i2c) < 0)
752 PDEBUG(D_ERR, "i2c error exposure"); 698 PDEBUG(D_ERR, "i2c error exposure");
753 break; 699 break;
754 } 700 }
@@ -761,11 +707,11 @@ static void setfreq(struct gspca_dev *gspca_dev)
761 707
762 switch (sd->sensor) { 708 switch (sd->sensor) {
763 case SENSOR_OV6650: 709 case SENSOR_OV6650:
764 case SENSOR_OV7630_3: { 710 case SENSOR_OV7630: {
765 /* Framerate adjust register for artificial light 50 hz flicker 711 /* Framerate adjust register for artificial light 50 hz flicker
766 compensation, identical to ov6630 0x2b register, see ov6630 712 compensation, for the ov6650 this is identical to ov6630
767 datasheet. 713 0x2b register, see ov6630 datasheet.
768 0x4f -> (30 fps -> 25 fps), 0x00 -> no adjustment */ 714 0x4f / 0x8a -> (30 fps -> 25 fps), 0x00 -> no adjustment */
769 __u8 i2c[] = {0xa0, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}; 715 __u8 i2c[] = {0xa0, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10};
770 switch (sd->freq) { 716 switch (sd->freq) {
771 default: 717 default:
@@ -786,69 +732,6 @@ static void setfreq(struct gspca_dev *gspca_dev)
786 } 732 }
787} 733}
788 734
789static void setsaturation(struct gspca_dev *gspca_dev)
790{
791 struct sd *sd = (struct sd *) gspca_dev;
792
793 switch (sd->sensor) {
794/* case SENSOR_OV6650: */
795 case SENSOR_OV7630_3:
796 case SENSOR_OV7630: {
797 __u8 i2c[] = {0xa0, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10};
798 i2c[1] = sd->sensor_addr;
799 i2c[3] = sd->saturation & 0xf0;
800 if (i2c_w(gspca_dev, i2c) < 0)
801 PDEBUG(D_ERR, "i2c error setsaturation");
802 else
803 PDEBUG(D_CONF, "saturation set to: %d",
804 (int)sd->saturation);
805 break;
806 }
807 }
808}
809
810static void sethue(struct gspca_dev *gspca_dev)
811{
812 struct sd *sd = (struct sd *) gspca_dev;
813
814 switch (sd->sensor) {
815/* case SENSOR_OV6650: */
816 case SENSOR_OV7630_3:
817 case SENSOR_OV7630: {
818 __u8 i2c[] = {0xa0, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10};
819 i2c[1] = sd->sensor_addr;
820 i2c[3] = 0x20 | (sd->hue >> 3);
821 if (i2c_w(gspca_dev, i2c) < 0)
822 PDEBUG(D_ERR, "i2c error setsaturation");
823 else
824 PDEBUG(D_CONF, "hue set to: %d", (int)sd->hue);
825 break;
826 }
827 }
828}
829
830static void setcontrast(struct gspca_dev *gspca_dev)
831{
832 struct sd *sd = (struct sd *) gspca_dev;
833
834 switch (sd->sensor) {
835/* case SENSOR_OV6650: */
836 case SENSOR_OV7630_3:
837 case SENSOR_OV7630: {
838 __u8 i2c[] = {0xa0, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10};
839 i2c[1] = sd->sensor_addr;
840 i2c[3] = 0x20 | (sd->contrast >> 3);
841 if (i2c_w(gspca_dev, i2c) < 0)
842 PDEBUG(D_ERR, "i2c error setcontrast");
843 else
844 PDEBUG(D_CONF, "contrast set to: %d",
845 (int)sd->contrast);
846 break;
847 }
848 }
849}
850
851
852static void do_autogain(struct gspca_dev *gspca_dev) 735static void do_autogain(struct gspca_dev *gspca_dev)
853{ 736{
854 struct sd *sd = (struct sd *) gspca_dev; 737 struct sd *sd = (struct sd *) gspca_dev;
@@ -874,88 +757,32 @@ static int sd_config(struct gspca_dev *gspca_dev,
874{ 757{
875 struct sd *sd = (struct sd *) gspca_dev; 758 struct sd *sd = (struct sd *) gspca_dev;
876 struct cam *cam; 759 struct cam *cam;
877 __u16 product;
878 int sif = 0; 760 int sif = 0;
879 761
880 /* nctrls depends upon the sensor, so we use a per cam copy */ 762 /* nctrls depends upon the sensor, so we use a per cam copy */
881 memcpy(&sd->sd_desc, gspca_dev->sd_desc, sizeof(struct sd_desc)); 763 memcpy(&sd->sd_desc, gspca_dev->sd_desc, sizeof(struct sd_desc));
882 gspca_dev->sd_desc = &sd->sd_desc; 764 gspca_dev->sd_desc = &sd->sd_desc;
883 765
884 sd->fr_h_sz = 12; /* default size of the frame header */ 766 /* copy the webcam info from the device id */
885 sd->sd_desc.nctrls = 2; /* default nb of ctrls */ 767 sd->sensor = (id->driver_info >> 24) & 0xff;
886 sd->autogain = AUTOGAIN_DEF; /* default is autogain active */ 768 if (id->driver_info & (F_GAIN << 16))
887 769 sd->sensor_has_gain = 1;
888 product = id->idProduct; 770 if (id->driver_info & (F_AUTO << 16))
889/* switch (id->idVendor) { */ 771 sd->sd_desc.dq_callback = do_autogain;
890/* case 0x0c45: * Sonix */ 772 if (id->driver_info & (F_SIF << 16))
891 switch (product) { 773 sif = 1;
892 case 0x6001: /* SN9C102 */ 774 if (id->driver_info & (F_H18 << 16))
893 case 0x6005: /* SN9C101 */ 775 sd->fr_h_sz = 18; /* size of frame header */
894 case 0x6007: /* SN9C101 */ 776 else
895 sd->sensor = SENSOR_TAS5110; 777 sd->fr_h_sz = 12;
896 sd->sensor_has_gain = 1; 778 sd->sd_desc.nctrls = (id->driver_info >> 8) & 0xff;
897 sd->sd_desc.nctrls = 4; 779 sd->sensor_addr = id->driver_info & 0xff;
898 sd->sd_desc.dq_callback = do_autogain;
899 sif = 1;
900 break;
901 case 0x6009: /* SN9C101 */
902 case 0x600d: /* SN9C101 */
903 case 0x6029: /* SN9C101 */
904 sd->sensor = SENSOR_PAS106;
905 sif = 1;
906 break;
907 case 0x6011: /* SN9C101 - SN9C101G */
908 sd->sensor = SENSOR_OV6650;
909 sd->sensor_has_gain = 1;
910 sd->sensor_addr = 0x60;
911 sd->sd_desc.nctrls = 5;
912 sd->sd_desc.dq_callback = do_autogain;
913 sif = 1;
914 break;
915 case 0x6019: /* SN9C101 */
916 case 0x602c: /* SN9C102 */
917 case 0x602e: /* SN9C102 */
918 sd->sensor = SENSOR_OV7630;
919 sd->sensor_addr = 0x21;
920 break;
921 case 0x60b0: /* SN9C103 */
922 sd->sensor = SENSOR_OV7630_3;
923 sd->sensor_addr = 0x21;
924 sd->fr_h_sz = 18; /* size of frame header */
925 sd->sensor_has_gain = 1;
926 sd->sd_desc.nctrls = 8;
927 sd->sd_desc.dq_callback = do_autogain;
928 sd->autogain = 0;
929 break;
930 case 0x6024: /* SN9C102 */
931 case 0x6025: /* SN9C102 */
932 sd->sensor = SENSOR_TAS5130CXX;
933 break;
934 case 0x6028: /* SN9C102 */
935 sd->sensor = SENSOR_PAS202;
936 break;
937 case 0x602d: /* SN9C102 */
938 sd->sensor = SENSOR_HV7131R;
939 break;
940 case 0x60af: /* SN9C103 */
941 sd->sensor = SENSOR_PAS202;
942 sd->fr_h_sz = 18; /* size of frame header (?) */
943 break;
944 }
945/* break; */
946/* } */
947 780
948 cam = &gspca_dev->cam; 781 cam = &gspca_dev->cam;
949 cam->dev_name = (char *) id->driver_info;
950 cam->epaddr = 0x01; 782 cam->epaddr = 0x01;
951 if (!sif) { 783 if (!sif) {
952 cam->cam_mode = vga_mode; 784 cam->cam_mode = vga_mode;
953 cam->nmodes = ARRAY_SIZE(vga_mode); 785 cam->nmodes = ARRAY_SIZE(vga_mode);
954 if (sd->sensor == SENSOR_OV7630_3) {
955 /* We only have 320x240 & 640x480 */
956 cam->cam_mode++;
957 cam->nmodes--;
958 }
959 } else { 786 } else {
960 cam->cam_mode = sif_mode; 787 cam->cam_mode = sif_mode;
961 cam->nmodes = ARRAY_SIZE(sif_mode); 788 cam->nmodes = ARRAY_SIZE(sif_mode);
@@ -963,12 +790,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
963 sd->brightness = BRIGHTNESS_DEF; 790 sd->brightness = BRIGHTNESS_DEF;
964 sd->gain = GAIN_DEF; 791 sd->gain = GAIN_DEF;
965 sd->exposure = EXPOSURE_DEF; 792 sd->exposure = EXPOSURE_DEF;
793 sd->autogain = AUTOGAIN_DEF;
966 sd->freq = FREQ_DEF; 794 sd->freq = FREQ_DEF;
967 sd->contrast = CONTRAST_DEF; 795
968 sd->saturation = SATURATION_DEF;
969 sd->hue = HUE_DEF;
970 if (sd->sensor == SENSOR_OV7630_3) /* jfm: from win trace */
971 reg_w(gspca_dev, 0x01, probe_ov7630, sizeof probe_ov7630);
972 return 0; 796 return 0;
973} 797}
974 798
@@ -1002,9 +826,8 @@ static void pas106_i2cinit(struct gspca_dev *gspca_dev)
1002static void sd_start(struct gspca_dev *gspca_dev) 826static void sd_start(struct gspca_dev *gspca_dev)
1003{ 827{
1004 struct sd *sd = (struct sd *) gspca_dev; 828 struct sd *sd = (struct sd *) gspca_dev;
1005 int mode, l; 829 int mode, l = 0x1f;
1006 const __u8 *sn9c10x; 830 const __u8 *sn9c10x;
1007 __u8 reg01, reg17;
1008 __u8 reg17_19[3]; 831 __u8 reg17_19[3];
1009 832
1010 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 833 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
@@ -1022,13 +845,11 @@ static void sd_start(struct gspca_dev *gspca_dev)
1022 reg17_19[2] = 0x20; 845 reg17_19[2] = 0x20;
1023 break; 846 break;
1024 case SENSOR_OV7630: 847 case SENSOR_OV7630:
1025 sn9c10x = initOv7630; 848 if (sd->fr_h_sz == 18) { /* SN9C103 */
1026 reg17_19[0] = 0x68; 849 sn9c10x = initOv7630_3;
1027 reg17_19[1] = (mode << 4) | COMP2; 850 l = sizeof initOv7630_3;
1028 reg17_19[2] = MCK_INIT1; 851 } else
1029 break; 852 sn9c10x = initOv7630;
1030 case SENSOR_OV7630_3:
1031 sn9c10x = initOv7630_3;
1032 reg17_19[0] = 0x68; 853 reg17_19[0] = 0x68;
1033 reg17_19[1] = (mode << 4) | COMP2; 854 reg17_19[1] = (mode << 4) | COMP2;
1034 reg17_19[2] = MCK_INIT1; 855 reg17_19[2] = MCK_INIT1;
@@ -1059,30 +880,11 @@ static void sd_start(struct gspca_dev *gspca_dev)
1059 reg17_19[2] = mode ? 0x23 : 0x43; 880 reg17_19[2] = mode ? 0x23 : 0x43;
1060 break; 881 break;
1061 } 882 }
1062 switch (sd->sensor) {
1063 case SENSOR_OV7630:
1064 reg01 = 0x06;
1065 reg17 = 0x29;
1066 l = sizeof initOv7630;
1067 break;
1068 case SENSOR_OV7630_3:
1069 reg01 = 0x44;
1070 reg17 = 0x68;
1071 l = sizeof initOv7630_3;
1072 break;
1073 default:
1074 reg01 = sn9c10x[0];
1075 reg17 = sn9c10x[0x17 - 1];
1076 l = 0x1f;
1077 break;
1078 }
1079 883
1080 /* reg 0x01 bit 2 video transfert on */ 884 /* reg 0x01 bit 2 video transfert on */
1081 reg_w(gspca_dev, 0x01, &reg01, 1); 885 reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1);
1082 /* reg 0x17 SensorClk enable inv Clk 0x60 */ 886 /* reg 0x17 SensorClk enable inv Clk 0x60 */
1083 reg_w(gspca_dev, 0x17, &reg17, 1); 887 reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1);
1084/*fixme: for ov7630 102
1085 reg_w(gspca_dev, 0x01, {0x06, sn9c10x[1]}, 2); */
1086 /* Set the registers from the template */ 888 /* Set the registers from the template */
1087 reg_w_big(gspca_dev, 0x01, sn9c10x, l); 889 reg_w_big(gspca_dev, 0x01, sn9c10x, l);
1088 switch (sd->sensor) { 890 switch (sd->sensor) {
@@ -1095,17 +897,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
1095 sizeof ov6650_sensor_init); 897 sizeof ov6650_sensor_init);
1096 break; 898 break;
1097 case SENSOR_OV7630: 899 case SENSOR_OV7630:
1098 i2c_w_vector(gspca_dev, ov7630_sensor_init_com,
1099 sizeof ov7630_sensor_init_com);
1100 msleep(200);
1101 i2c_w_vector(gspca_dev, ov7630_sensor_init, 900 i2c_w_vector(gspca_dev, ov7630_sensor_init,
1102 sizeof ov7630_sensor_init); 901 sizeof ov7630_sensor_init);
1103 break; 902 if (sd->fr_h_sz == 18) { /* SN9C103 */
1104 case SENSOR_OV7630_3: 903 const __u8 i2c[] = { 0xa0, 0x21, 0x13, 0x80, 0x00,
1105 i2c_w_vector(gspca_dev, ov7630_sensor_init_com, 904 0x00, 0x00, 0x10 };
1106 sizeof ov7630_sensor_init_com); 905 i2c_w(gspca_dev, i2c);
1107 msleep(200); 906 }
1108 i2c_w(gspca_dev, ov7630_sensor_init_3[mode]);
1109 break; 907 break;
1110 case SENSOR_PAS106: 908 case SENSOR_PAS106:
1111 pas106_i2cinit(gspca_dev); 909 pas106_i2cinit(gspca_dev);
@@ -1145,14 +943,14 @@ static void sd_start(struct gspca_dev *gspca_dev)
1145 reg_w(gspca_dev, 0x18, &reg17_19[1], 2); 943 reg_w(gspca_dev, 0x18, &reg17_19[1], 2);
1146 msleep(20); 944 msleep(20);
1147 945
946 sd->reg11 = -1;
947
1148 setgain(gspca_dev); 948 setgain(gspca_dev);
1149 setbrightness(gspca_dev); 949 setbrightness(gspca_dev);
1150 setexposure(gspca_dev); 950 setexposure(gspca_dev);
1151 setfreq(gspca_dev); 951 setfreq(gspca_dev);
1152 setsaturation(gspca_dev);
1153 sethue(gspca_dev);
1154 setcontrast(gspca_dev);
1155 952
953 sd->frames_to_drop = 0;
1156 sd->autogain_ignore_frames = 0; 954 sd->autogain_ignore_frames = 0;
1157 atomic_set(&sd->avg_lum, -1); 955 atomic_set(&sd->avg_lum, -1);
1158} 956}
@@ -1198,21 +996,31 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1198 && data[3 + i] == 0xc4 996 && data[3 + i] == 0xc4
1199 && data[4 + i] == 0xc4 997 && data[4 + i] == 0xc4
1200 && data[5 + i] == 0x96) { /* start of frame */ 998 && data[5 + i] == 0x96) { /* start of frame */
1201 frame = gspca_frame_add(gspca_dev, LAST_PACKET, 999 int lum = -1;
1202 frame, data, 0); 1000 int pkt_type = LAST_PACKET;
1001
1203 if (len - i < sd->fr_h_sz) { 1002 if (len - i < sd->fr_h_sz) {
1204 atomic_set(&sd->avg_lum, -1);
1205 PDEBUG(D_STREAM, "packet too short to" 1003 PDEBUG(D_STREAM, "packet too short to"
1206 " get avg brightness"); 1004 " get avg brightness");
1207 } else if (sd->fr_h_sz == 12) { 1005 } else if (sd->fr_h_sz == 12) {
1208 atomic_set(&sd->avg_lum, 1006 lum = data[i + 8] + (data[i + 9] << 8);
1209 data[i + 8] +
1210 (data[i + 9] << 8));
1211 } else { 1007 } else {
1212 atomic_set(&sd->avg_lum, 1008 lum = data[i + 9] +
1213 data[i + 9] + 1009 (data[i + 10] << 8);
1214 (data[i + 10] << 8)); 1010 }
1011 if (lum == 0) {
1012 lum = -1;
1013 sd->frames_to_drop = 2;
1014 }
1015 atomic_set(&sd->avg_lum, lum);
1016
1017 if (sd->frames_to_drop) {
1018 sd->frames_to_drop--;
1019 pkt_type = DISCARD_PACKET;
1215 } 1020 }
1021
1022 frame = gspca_frame_add(gspca_dev, pkt_type,
1023 frame, data, 0);
1216 data += i + sd->fr_h_sz; 1024 data += i + sd->fr_h_sz;
1217 len -= i + sd->fr_h_sz; 1025 len -= i + sd->fr_h_sz;
1218 gspca_frame_add(gspca_dev, FIRST_PACKET, 1026 gspca_frame_add(gspca_dev, FIRST_PACKET,
@@ -1327,60 +1135,6 @@ static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
1327 return 0; 1135 return 0;
1328} 1136}
1329 1137
1330static int sd_setsaturation(struct gspca_dev *gspca_dev, __s32 val)
1331{
1332 struct sd *sd = (struct sd *) gspca_dev;
1333
1334 sd->saturation = val;
1335 if (gspca_dev->streaming)
1336 setsaturation(gspca_dev);
1337 return 0;
1338}
1339
1340static int sd_getsaturation(struct gspca_dev *gspca_dev, __s32 *val)
1341{
1342 struct sd *sd = (struct sd *) gspca_dev;
1343
1344 *val = sd->saturation;
1345 return 0;
1346}
1347
1348static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val)
1349{
1350 struct sd *sd = (struct sd *) gspca_dev;
1351
1352 sd->hue = val;
1353 if (gspca_dev->streaming)
1354 sethue(gspca_dev);
1355 return 0;
1356}
1357
1358static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val)
1359{
1360 struct sd *sd = (struct sd *) gspca_dev;
1361
1362 *val = sd->hue;
1363 return 0;
1364}
1365
1366static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
1367{
1368 struct sd *sd = (struct sd *) gspca_dev;
1369
1370 sd->contrast = val;
1371 if (gspca_dev->streaming)
1372 setcontrast(gspca_dev);
1373 return 0;
1374}
1375
1376static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
1377{
1378 struct sd *sd = (struct sd *) gspca_dev;
1379
1380 *val = sd->contrast;
1381 return 0;
1382}
1383
1384static int sd_querymenu(struct gspca_dev *gspca_dev, 1138static int sd_querymenu(struct gspca_dev *gspca_dev,
1385 struct v4l2_querymenu *menu) 1139 struct v4l2_querymenu *menu)
1386{ 1140{
@@ -1418,27 +1172,47 @@ static const struct sd_desc sd_desc = {
1418}; 1172};
1419 1173
1420/* -- module initialisation -- */ 1174/* -- module initialisation -- */
1421#define DVNM(name) .driver_info = (kernel_ulong_t) name 1175#define SFCI(sensor, flags, nctrls, i2c_addr) \
1176 .driver_info = (SENSOR_ ## sensor << 24) \
1177 | ((flags) << 16) \
1178 | ((nctrls) << 8) \
1179 | (i2c_addr)
1422static __devinitdata struct usb_device_id device_table[] = { 1180static __devinitdata struct usb_device_id device_table[] = {
1423#ifndef CONFIG_USB_SN9C102 1181#ifndef CONFIG_USB_SN9C102
1424 {USB_DEVICE(0x0c45, 0x6001), DVNM("Genius VideoCAM NB")}, 1182 {USB_DEVICE(0x0c45, 0x6001), /* SN9C102 */
1425 {USB_DEVICE(0x0c45, 0x6005), DVNM("Sweex Tas5110")}, 1183 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)},
1426 {USB_DEVICE(0x0c45, 0x6007), DVNM("Sonix sn9c101 + Tas5110D")}, 1184 {USB_DEVICE(0x0c45, 0x6005), /* SN9C101 */
1427 {USB_DEVICE(0x0c45, 0x6009), DVNM("spcaCam@120")}, 1185 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)},
1428 {USB_DEVICE(0x0c45, 0x600d), DVNM("spcaCam@120")}, 1186 {USB_DEVICE(0x0c45, 0x6007), /* SN9C101 */
1187 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)},
1188 {USB_DEVICE(0x0c45, 0x6009), /* SN9C101 */
1189 SFCI(PAS106, F_SIF, 2, 0)},
1190 {USB_DEVICE(0x0c45, 0x600d), /* SN9C101 */
1191 SFCI(PAS106, F_SIF, 2, 0)},
1429#endif 1192#endif
1430 {USB_DEVICE(0x0c45, 0x6011), DVNM("MAX Webcam Microdia")}, 1193 {USB_DEVICE(0x0c45, 0x6011), /* SN9C101 - SN9C101G */
1194 SFCI(OV6650, F_GAIN|F_AUTO|F_SIF, 5, 0x60)},
1431#ifndef CONFIG_USB_SN9C102 1195#ifndef CONFIG_USB_SN9C102
1432 {USB_DEVICE(0x0c45, 0x6019), DVNM("Generic Sonix OV7630")}, 1196 {USB_DEVICE(0x0c45, 0x6019), /* SN9C101 */
1433 {USB_DEVICE(0x0c45, 0x6024), DVNM("Generic Sonix Tas5130c")}, 1197 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)},
1434 {USB_DEVICE(0x0c45, 0x6025), DVNM("Xcam Shanga")}, 1198 {USB_DEVICE(0x0c45, 0x6024), /* SN9C102 */
1435 {USB_DEVICE(0x0c45, 0x6028), DVNM("Sonix Btc Pc380")}, 1199 SFCI(TAS5130CXX, 0, 2, 0)},
1436 {USB_DEVICE(0x0c45, 0x6029), DVNM("spcaCam@150")}, 1200 {USB_DEVICE(0x0c45, 0x6025), /* SN9C102 */
1437 {USB_DEVICE(0x0c45, 0x602c), DVNM("Generic Sonix OV7630")}, 1201 SFCI(TAS5130CXX, 0, 2, 0)},
1438 {USB_DEVICE(0x0c45, 0x602d), DVNM("LIC-200 LG")}, 1202 {USB_DEVICE(0x0c45, 0x6028), /* SN9C102 */
1439 {USB_DEVICE(0x0c45, 0x602e), DVNM("Genius VideoCam Messenger")}, 1203 SFCI(PAS202, 0, 2, 0)},
1440 {USB_DEVICE(0x0c45, 0x60af), DVNM("Trust WB3100P")}, 1204 {USB_DEVICE(0x0c45, 0x6029), /* SN9C101 */
1441 {USB_DEVICE(0x0c45, 0x60b0), DVNM("Genius VideoCam Look")}, 1205 SFCI(PAS106, F_SIF, 2, 0)},
1206 {USB_DEVICE(0x0c45, 0x602c), /* SN9C102 */
1207 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)},
1208 {USB_DEVICE(0x0c45, 0x602d), /* SN9C102 */
1209 SFCI(HV7131R, 0, 2, 0)},
1210 {USB_DEVICE(0x0c45, 0x602e), /* SN9C102 */
1211 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)},
1212 {USB_DEVICE(0x0c45, 0x60af), /* SN9C103 */
1213 SFCI(PAS202, F_H18, 2, 0)},
1214 {USB_DEVICE(0x0c45, 0x60b0), /* SN9C103 */
1215 SFCI(OV7630, F_GAIN|F_AUTO|F_H18, 5, 0x21)},
1442#endif 1216#endif
1443 {} 1217 {}
1444}; 1218};
@@ -1464,7 +1238,7 @@ static int __init sd_mod_init(void)
1464{ 1238{
1465 if (usb_register(&sd_driver) < 0) 1239 if (usb_register(&sd_driver) < 0)
1466 return -1; 1240 return -1;
1467 PDEBUG(D_PROBE, "v%s registered", version); 1241 PDEBUG(D_PROBE, "registered");
1468 return 0; 1242 return 0;
1469} 1243}
1470static void __exit sd_mod_exit(void) 1244static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 3e68b9926956..33a3df1f6915 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -361,6 +358,7 @@ static const __u8 mo4000_sensor_init[][8] = {
361}; 358};
362static const __u8 ov7660_sensor_init[][8] = { 359static const __u8 ov7660_sensor_init[][8] = {
363 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ 360 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
361/* (delay 20ms) */
364 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 362 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
365 /* Outformat ?? rawRGB */ 363 /* Outformat ?? rawRGB */
366 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 364 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
@@ -539,13 +537,31 @@ static void reg_r(struct gspca_dev *gspca_dev,
539 value, 0, 537 value, 0,
540 gspca_dev->usb_buf, len, 538 gspca_dev->usb_buf, len,
541 500); 539 500);
540 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
542} 541}
543 542
543static void reg_w1(struct gspca_dev *gspca_dev,
544 __u16 value,
545 __u8 data)
546{
547 PDEBUG(D_USBO, "reg_w1 [%02x] = %02x", value, data);
548 gspca_dev->usb_buf[0] = data;
549 usb_control_msg(gspca_dev->dev,
550 usb_sndctrlpipe(gspca_dev->dev, 0),
551 0x08,
552 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
553 value,
554 0,
555 gspca_dev->usb_buf, 1,
556 500);
557}
544static void reg_w(struct gspca_dev *gspca_dev, 558static void reg_w(struct gspca_dev *gspca_dev,
545 __u16 value, 559 __u16 value,
546 const __u8 *buffer, 560 const __u8 *buffer,
547 int len) 561 int len)
548{ 562{
563 PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..",
564 value, buffer[0], buffer[1]);
549 if (len <= sizeof gspca_dev->usb_buf) { 565 if (len <= sizeof gspca_dev->usb_buf) {
550 memcpy(gspca_dev->usb_buf, buffer, len); 566 memcpy(gspca_dev->usb_buf, buffer, len);
551 usb_control_msg(gspca_dev->dev, 567 usb_control_msg(gspca_dev->dev,
@@ -571,31 +587,42 @@ static void reg_w(struct gspca_dev *gspca_dev,
571 } 587 }
572} 588}
573 589
574/* I2C write 2 bytes */ 590/* I2C write 1 byte */
575static void i2c_w2(struct gspca_dev *gspca_dev, 591static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val)
576 const __u8 *buffer)
577{ 592{
578 struct sd *sd = (struct sd *) gspca_dev; 593 struct sd *sd = (struct sd *) gspca_dev;
579 __u8 mode[8];
580 594
581 /* is i2c ready */ 595 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
582 mode[0] = 0x81 | (2 << 4); 596 gspca_dev->usb_buf[0] = 0x81 | (2 << 4); /* = a1 */
583 mode[1] = sd->i2c_base; 597 gspca_dev->usb_buf[1] = sd->i2c_base;
584 mode[2] = buffer[0]; 598 gspca_dev->usb_buf[2] = reg;
585 mode[3] = buffer[1]; 599 gspca_dev->usb_buf[3] = val;
586 mode[4] = 0; 600 gspca_dev->usb_buf[4] = 0;
587 mode[5] = 0; 601 gspca_dev->usb_buf[5] = 0;
588 mode[6] = 0; 602 gspca_dev->usb_buf[6] = 0;
589 mode[7] = 0x10; 603 gspca_dev->usb_buf[7] = 0x10;
590 reg_w(gspca_dev, 0x08, mode, 8); 604 usb_control_msg(gspca_dev->dev,
605 usb_sndctrlpipe(gspca_dev->dev, 0),
606 0x08,
607 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
608 0x08, /* value = i2c */
609 0,
610 gspca_dev->usb_buf, 8,
611 500);
591} 612}
592 613
593/* I2C write 8 bytes */ 614/* I2C write 8 bytes */
594static void i2c_w8(struct gspca_dev *gspca_dev, 615static void i2c_w8(struct gspca_dev *gspca_dev,
595 const __u8 *buffer) 616 const __u8 *buffer)
596{ 617{
597 reg_w(gspca_dev, 0x08, buffer, 8); 618 memcpy(gspca_dev->usb_buf, buffer, 8);
598 msleep(1); 619 usb_control_msg(gspca_dev->dev,
620 usb_sndctrlpipe(gspca_dev->dev, 0),
621 0x08,
622 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
623 0x08, 0, /* value, index */
624 gspca_dev->usb_buf, 8,
625 500);
599} 626}
600 627
601/* read 5 bytes in gspca_dev->usb_buf */ 628/* read 5 bytes in gspca_dev->usb_buf */
@@ -613,24 +640,21 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
613 mode[6] = 0; 640 mode[6] = 0;
614 mode[7] = 0x10; 641 mode[7] = 0x10;
615 i2c_w8(gspca_dev, mode); 642 i2c_w8(gspca_dev, mode);
643 msleep(2);
616 mode[0] = 0x81 | (5 << 4) | 0x02; 644 mode[0] = 0x81 | (5 << 4) | 0x02;
617 mode[2] = 0; 645 mode[2] = 0;
618 i2c_w8(gspca_dev, mode); 646 i2c_w8(gspca_dev, mode);
647 msleep(2);
619 reg_r(gspca_dev, 0x0a, 5); 648 reg_r(gspca_dev, 0x0a, 5);
620} 649}
621 650
622static int probesensor(struct gspca_dev *gspca_dev) 651static int probesensor(struct gspca_dev *gspca_dev)
623{ 652{
624 struct sd *sd = (struct sd *) gspca_dev; 653 struct sd *sd = (struct sd *) gspca_dev;
625 __u8 reg02;
626 static const __u8 datasend[] = { 2, 0 };
627 /* reg val1 val2 val3 val4 */
628 654
629 i2c_w2(gspca_dev, datasend); 655 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
630/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */
631 msleep(10); 656 msleep(10);
632 reg02 = 0x66; 657 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
633 reg_w(gspca_dev, 0x02, &reg02, 1); /* Gpio on */
634 msleep(10); 658 msleep(10);
635 i2c_r5(gspca_dev, 0); /* read sensor id */ 659 i2c_r5(gspca_dev, 0); /* read sensor id */
636 if (gspca_dev->usb_buf[0] == 0x02 660 if (gspca_dev->usb_buf[0] == 0x02
@@ -642,7 +666,7 @@ static int probesensor(struct gspca_dev *gspca_dev)
642 sd->sensor = SENSOR_HV7131R; 666 sd->sensor = SENSOR_HV7131R;
643 return SENSOR_HV7131R; 667 return SENSOR_HV7131R;
644 } 668 }
645 PDEBUG(D_PROBE, "Find Sensor %d %d %d", 669 PDEBUG(D_PROBE, "Find Sensor 0x%02x 0x%02x 0x%02x",
646 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], 670 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
647 gspca_dev->usb_buf[2]); 671 gspca_dev->usb_buf[2]);
648 PDEBUG(D_PROBE, "Sensor sn9c102P Not found"); 672 PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
@@ -653,8 +677,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
653 const __u8 *sn9c1xx) 677 const __u8 *sn9c1xx)
654{ 678{
655 struct sd *sd = (struct sd *) gspca_dev; 679 struct sd *sd = (struct sd *) gspca_dev;
656 __u8 data;
657 __u8 regF1;
658 const __u8 *reg9a; 680 const __u8 *reg9a;
659 static const __u8 reg9a_def[] = 681 static const __u8 reg9a_def[] =
660 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; 682 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04};
@@ -663,15 +685,13 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
663 static const __u8 reg9a_sn9c325[] = 685 static const __u8 reg9a_sn9c325[] =
664 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; 686 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20};
665 687
666 688 reg_w1(gspca_dev, 0xf1, 0x00);
667 regF1 = 0x00; 689 reg_w1(gspca_dev, 0x01, sn9c1xx[0]); /*fixme:jfm was [1] en v1*/
668 reg_w(gspca_dev, 0xf1, &regF1, 1);
669 reg_w(gspca_dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/
670 690
671 /* configure gpio */ 691 /* configure gpio */
672 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); 692 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
673 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); 693 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
674 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm was 3 */ 694 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
675 switch (sd->bridge) { 695 switch (sd->bridge) {
676 case BRIDGE_SN9C325: 696 case BRIDGE_SN9C325:
677 reg9a = reg9a_sn9c325; 697 reg9a = reg9a_sn9c325;
@@ -685,35 +705,25 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
685 } 705 }
686 reg_w(gspca_dev, 0x9a, reg9a, 6); 706 reg_w(gspca_dev, 0x9a, reg9a, 6);
687 707
688 data = 0x60; /*fixme:jfm 60 00 00 (3) */ 708 reg_w1(gspca_dev, 0xd4, 0x60); /*fixme:jfm 60 00 00 (3) ? */
689 reg_w(gspca_dev, 0xd4, &data, 1);
690 709
691 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); 710 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
692 711
693 switch (sd->bridge) { 712 switch (sd->bridge) {
694 case BRIDGE_SN9C120: /* from win trace */ 713 case BRIDGE_SN9C120: /* from win trace */
695 data = 0x61; 714 reg_w1(gspca_dev, 0x01, 0x61);
696 reg_w(gspca_dev, 0x01, &data, 1); 715 reg_w1(gspca_dev, 0x17, 0x20);
697 data = 0x20; 716 reg_w1(gspca_dev, 0x01, 0x60);
698 reg_w(gspca_dev, 0x17, &data, 1);
699 data = 0x60;
700 reg_w(gspca_dev, 0x01, &data, 1);
701 break; 717 break;
702 case BRIDGE_SN9C325: 718 case BRIDGE_SN9C325:
703 data = 0x43; 719 reg_w1(gspca_dev, 0x01, 0x43);
704 reg_w(gspca_dev, 0x01, &data, 1); 720 reg_w1(gspca_dev, 0x17, 0xae);
705 data = 0xae; 721 reg_w1(gspca_dev, 0x01, 0x42);
706 reg_w(gspca_dev, 0x17, &data, 1);
707 data = 0x42;
708 reg_w(gspca_dev, 0x01, &data, 1);
709 break; 722 break;
710 default: 723 default:
711 data = 0x43; 724 reg_w1(gspca_dev, 0x01, 0x43);
712 reg_w(gspca_dev, 0x01, &data, 1); 725 reg_w1(gspca_dev, 0x17, 0x61);
713 data = 0x61; 726 reg_w1(gspca_dev, 0x01, 0x42);
714 reg_w(gspca_dev, 0x17, &data, 1);
715 data = 0x42;
716 reg_w(gspca_dev, 0x01, &data, 1);
717 } 727 }
718 728
719 if (sd->sensor == SENSOR_HV7131R) { 729 if (sd->sensor == SENSOR_HV7131R) {
@@ -770,6 +780,9 @@ static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
770{ 780{
771 int i = 0; 781 int i = 0;
772 782
783 i2c_w8(gspca_dev, ov7660_sensor_init[i]); /* reset SCCB */
784 i++;
785 msleep(20);
773 while (ov7660_sensor_init[i][0]) { 786 while (ov7660_sensor_init[i][0]) {
774 i2c_w8(gspca_dev, ov7660_sensor_init[i]); 787 i2c_w8(gspca_dev, ov7660_sensor_init[i]);
775 i++; 788 i++;
@@ -782,194 +795,16 @@ static int sd_config(struct gspca_dev *gspca_dev,
782{ 795{
783 struct sd *sd = (struct sd *) gspca_dev; 796 struct sd *sd = (struct sd *) gspca_dev;
784 struct cam *cam; 797 struct cam *cam;
785 __u16 vendor;
786 __u16 product;
787
788 vendor = id->idVendor;
789 product = id->idProduct;
790 sd->sensor = -1;
791 switch (vendor) {
792 case 0x0458: /* Genius */
793/* switch (product) {
794 case 0x7025: */
795 sd->bridge = BRIDGE_SN9C120;
796 sd->sensor = SENSOR_MI0360;
797 sd->i2c_base = 0x5d;
798/* break;
799 } */
800 break;
801 case 0x045e:
802/* switch (product) {
803 case 0x00f5:
804 case 0x00f7: */
805 sd->bridge = BRIDGE_SN9C105;
806 sd->sensor = SENSOR_OV7660;
807 sd->i2c_base = 0x21;
808/* break;
809 } */
810 break;
811 case 0x0471: /* Philips */
812/* switch (product) {
813 case 0x0327:
814 case 0x0328:
815 case 0x0330: */
816 sd->bridge = BRIDGE_SN9C105;
817 sd->sensor = SENSOR_MI0360;
818 sd->i2c_base = 0x5d;
819/* break;
820 } */
821 break;
822 case 0x0c45: /* Sonix */
823 switch (product) {
824 case 0x6040:
825 sd->bridge = BRIDGE_SN9C102P;
826/* sd->sensor = SENSOR_MI0360; * from BW600.inf */
827/*fixme: MI0360 base=5d ? */
828 sd->sensor = SENSOR_HV7131R; /* gspcav1 value */
829 sd->i2c_base = 0x11;
830 break;
831/* case 0x607a: * from BW600.inf
832 sd->bridge = BRIDGE_SN9C102P;
833 sd->sensor = SENSOR_OV7648;
834 sd->i2c_base = 0x??;
835 break; */
836 case 0x607c:
837 sd->bridge = BRIDGE_SN9C102P;
838 sd->sensor = SENSOR_HV7131R;
839 sd->i2c_base = 0x11;
840 break;
841/* case 0x607e: * from BW600.inf
842 sd->bridge = BRIDGE_SN9C102P;
843 sd->sensor = SENSOR_OV7630;
844 sd->i2c_base = 0x??;
845 break; */
846 case 0x60c0:
847 sd->bridge = BRIDGE_SN9C105;
848 sd->sensor = SENSOR_MI0360;
849 sd->i2c_base = 0x5d;
850 break;
851/* case 0x60c8: * from BW600.inf
852 sd->bridge = BRIDGE_SN9C105;
853 sd->sensor = SENSOR_OM6801;
854 sd->i2c_base = 0x??;
855 break; */
856/* case 0x60cc: * from BW600.inf
857 sd->bridge = BRIDGE_SN9C105;
858 sd->sensor = SENSOR_HV7131GP;
859 sd->i2c_base = 0x??;
860 break; */
861 case 0x60ec:
862 sd->bridge = BRIDGE_SN9C105;
863 sd->sensor = SENSOR_MO4000;
864 sd->i2c_base = 0x21;
865 break;
866/* case 0x60ef: * from BW600.inf
867 sd->bridge = BRIDGE_SN9C105;
868 sd->sensor = SENSOR_ICM105C;
869 sd->i2c_base = 0x??;
870 break; */
871/* case 0x60fa: * from BW600.inf
872 sd->bridge = BRIDGE_SN9C105;
873 sd->sensor = SENSOR_OV7648;
874 sd->i2c_base = 0x??;
875 break; */
876 case 0x60fb:
877 sd->bridge = BRIDGE_SN9C105;
878 sd->sensor = SENSOR_OV7660;
879 sd->i2c_base = 0x21;
880 break;
881 case 0x60fc:
882 sd->bridge = BRIDGE_SN9C105;
883 sd->sensor = SENSOR_HV7131R;
884 sd->i2c_base = 0x11;
885 break;
886/* case 0x60fe: * from BW600.inf
887 sd->bridge = BRIDGE_SN9C105;
888 sd->sensor = SENSOR_OV7630;
889 sd->i2c_base = 0x??;
890 break; */
891/* case 0x6108: * from BW600.inf
892 sd->bridge = BRIDGE_SN9C120;
893 sd->sensor = SENSOR_OM6801;
894 sd->i2c_base = 0x??;
895 break; */
896/* case 0x6122: * from BW600.inf
897 sd->bridge = BRIDGE_SN9C110;
898 sd->sensor = SENSOR_ICM105C;
899 sd->i2c_base = 0x??;
900 break; */
901 case 0x612a:
902/* sd->bridge = BRIDGE_SN9C110; * in BW600.inf */
903 sd->bridge = BRIDGE_SN9C325;
904 sd->sensor = SENSOR_OV7648;
905 sd->i2c_base = 0x21;
906/*fixme: sensor_init has base = 00 et 6e!*/
907 break;
908/* case 0x6123: * from BW600.inf
909 sd->bridge = BRIDGE_SN9C110;
910 sd->sensor = SENSOR_SanyoCCD;
911 sd->i2c_base = 0x??;
912 break; */
913 case 0x612c:
914 sd->bridge = BRIDGE_SN9C110;
915 sd->sensor = SENSOR_MO4000;
916 sd->i2c_base = 0x21;
917 break;
918/* case 0x612e: * from BW600.inf
919 sd->bridge = BRIDGE_SN9C110;
920 sd->sensor = SENSOR_OV7630;
921 sd->i2c_base = 0x??;
922 break; */
923/* case 0x612f: * from BW600.inf
924 sd->bridge = BRIDGE_SN9C110;
925 sd->sensor = SENSOR_ICM105C;
926 sd->i2c_base = 0x??;
927 break; */
928 case 0x6130:
929 sd->bridge = BRIDGE_SN9C120;
930 sd->sensor = SENSOR_MI0360;
931 sd->i2c_base = 0x5d;
932 break;
933 case 0x6138:
934 sd->bridge = BRIDGE_SN9C120;
935 sd->sensor = SENSOR_MO4000;
936 sd->i2c_base = 0x21;
937 break;
938/* case 0x613a: * from BW600.inf
939 sd->bridge = BRIDGE_SN9C120;
940 sd->sensor = SENSOR_OV7648;
941 sd->i2c_base = 0x??;
942 break; */
943 case 0x613b:
944 sd->bridge = BRIDGE_SN9C120;
945 sd->sensor = SENSOR_OV7660;
946 sd->i2c_base = 0x21;
947 break;
948 case 0x613c:
949 sd->bridge = BRIDGE_SN9C120;
950 sd->sensor = SENSOR_HV7131R;
951 sd->i2c_base = 0x11;
952 break;
953/* case 0x613e: * from BW600.inf
954 sd->bridge = BRIDGE_SN9C120;
955 sd->sensor = SENSOR_OV7630;
956 sd->i2c_base = 0x??;
957 break; */
958 }
959 break;
960 }
961 if (sd->sensor < 0) {
962 PDEBUG(D_ERR, "Invalid vendor/product %04x:%04x",
963 vendor, product);
964 return -EINVAL;
965 }
966 798
967 cam = &gspca_dev->cam; 799 cam = &gspca_dev->cam;
968 cam->dev_name = (char *) id->driver_info;
969 cam->epaddr = 0x01; 800 cam->epaddr = 0x01;
970 cam->cam_mode = vga_mode; 801 cam->cam_mode = vga_mode;
971 cam->nmodes = ARRAY_SIZE(vga_mode); 802 cam->nmodes = ARRAY_SIZE(vga_mode);
972 803
804 sd->bridge = id->driver_info >> 16;
805 sd->sensor = id->driver_info >> 8;
806 sd->i2c_base = id->driver_info;
807
973 sd->qindex = 4; /* set the quantization table */ 808 sd->qindex = 4; /* set the quantization table */
974 sd->brightness = BRIGHTNESS_DEF; 809 sd->brightness = BRIGHTNESS_DEF;
975 sd->contrast = CONTRAST_DEF; 810 sd->contrast = CONTRAST_DEF;
@@ -983,34 +818,26 @@ static int sd_open(struct gspca_dev *gspca_dev)
983{ 818{
984 struct sd *sd = (struct sd *) gspca_dev; 819 struct sd *sd = (struct sd *) gspca_dev;
985/* const __u8 *sn9c1xx; */ 820/* const __u8 *sn9c1xx; */
986 __u8 regF1;
987 __u8 regGpio[] = { 0x29, 0x74 }; 821 __u8 regGpio[] = { 0x29, 0x74 };
822 __u8 regF1;
988 823
989 /* setup a selector by bridge */ 824 /* setup a selector by bridge */
990 regF1 = 0x01; 825 reg_w1(gspca_dev, 0xf1, 0x01);
991 reg_w(gspca_dev, 0xf1, &regF1, 1);
992 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */ 826 reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */
993 regF1 = gspca_dev->usb_buf[0]; 827 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
994 reg_w(gspca_dev, 0xf1, &regF1, 1);
995 reg_r(gspca_dev, 0x00, 1); 828 reg_r(gspca_dev, 0x00, 1);
996 regF1 = gspca_dev->usb_buf[0]; 829 regF1 = gspca_dev->usb_buf[0];
997 switch (sd->bridge) { 830 switch (sd->bridge) {
998 case BRIDGE_SN9C102P: 831 case BRIDGE_SN9C102P:
999 if (regF1 != 0x11) 832 if (regF1 != 0x11)
1000 return -ENODEV; 833 return -ENODEV;
1001 reg_w(gspca_dev, 0x02, &regGpio[1], 1); 834 reg_w1(gspca_dev, 0x02, regGpio[1]);
1002 break; 835 break;
1003 case BRIDGE_SN9C105: 836 case BRIDGE_SN9C105:
1004 if (regF1 != 0x11) 837 if (regF1 != 0x11)
1005 return -ENODEV; 838 return -ENODEV;
1006 reg_w(gspca_dev, 0x02, regGpio, 2); 839 reg_w(gspca_dev, 0x02, regGpio, 2);
1007 break; 840 break;
1008 case BRIDGE_SN9C110:
1009 if (regF1 != 0x12)
1010 return -ENODEV;
1011 regGpio[1] = 0x62;
1012 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1013 break;
1014 case BRIDGE_SN9C120: 841 case BRIDGE_SN9C120:
1015 if (regF1 != 0x12) 842 if (regF1 != 0x12)
1016 return -ENODEV; 843 return -ENODEV;
@@ -1018,16 +845,15 @@ static int sd_open(struct gspca_dev *gspca_dev)
1018 reg_w(gspca_dev, 0x02, regGpio, 2); 845 reg_w(gspca_dev, 0x02, regGpio, 2);
1019 break; 846 break;
1020 default: 847 default:
848/* case BRIDGE_SN9C110: */
1021/* case BRIDGE_SN9C325: */ 849/* case BRIDGE_SN9C325: */
1022 if (regF1 != 0x12) 850 if (regF1 != 0x12)
1023 return -ENODEV; 851 return -ENODEV;
1024 regGpio[1] = 0x62; 852 reg_w1(gspca_dev, 0x02, 0x62);
1025 reg_w(gspca_dev, 0x02, &regGpio[1], 1);
1026 break; 853 break;
1027 } 854 }
1028 855
1029 regF1 = 0x01; 856 reg_w1(gspca_dev, 0xf1, 0x01);
1030 reg_w(gspca_dev, 0xf1, &regF1, 1);
1031 857
1032 return 0; 858 return 0;
1033} 859}
@@ -1123,7 +949,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
1123 } 949 }
1124 950
1125 k2 = sd->brightness >> 10; 951 k2 = sd->brightness >> 10;
1126 reg_w(gspca_dev, 0x96, &k2, 1); 952 reg_w1(gspca_dev, 0x96, k2);
1127} 953}
1128 954
1129static void setcontrast(struct gspca_dev *gspca_dev) 955static void setcontrast(struct gspca_dev *gspca_dev)
@@ -1152,7 +978,7 @@ static void setcolors(struct gspca_dev *gspca_dev)
1152 data = (colour + 32) & 0x7f; /* blue */ 978 data = (colour + 32) & 0x7f; /* blue */
1153 else 979 else
1154 data = (-colour + 32) & 0x7f; /* red */ 980 data = (-colour + 32) & 0x7f; /* red */
1155 reg_w(gspca_dev, 0x05, &data, 1); 981 reg_w1(gspca_dev, 0x05, data);
1156} 982}
1157 983
1158/* -- start the camera -- */ 984/* -- start the camera -- */
@@ -1165,7 +991,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
1165 __u8 reg17; 991 __u8 reg17;
1166 const __u8 *sn9c1xx; 992 const __u8 *sn9c1xx;
1167 int mode; 993 int mode;
1168 static const __u8 DC29[] = { 0x6a, 0x50, 0x00, 0x00, 0x50, 0x3c };
1169 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 994 static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1170 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 995 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1171 static const __u8 CA_sn9c120[] = 996 static const __u8 CA_sn9c120[] =
@@ -1179,21 +1004,20 @@ static void sd_start(struct gspca_dev *gspca_dev)
1179 1004
1180/*fixme:jfm this sequence should appear at end of sd_start */ 1005/*fixme:jfm this sequence should appear at end of sd_start */
1181/* with 1006/* with
1182 data = 0x44; 1007 reg_w1(gspca_dev, 0x01, 0x44); */
1183 reg_w(gspca_dev, 0x01, &data, 1); */ 1008 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1184 reg_w(gspca_dev, 0x15, &sn9c1xx[0x15], 1); 1009 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1185 reg_w(gspca_dev, 0x16, &sn9c1xx[0x16], 1); 1010 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1186 reg_w(gspca_dev, 0x12, &sn9c1xx[0x12], 1); 1011 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1187 reg_w(gspca_dev, 0x13, &sn9c1xx[0x13], 1); 1012 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1188 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1013 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1189 reg_w(gspca_dev, 0xd2, &DC29[0], 1); 1014 reg_w1(gspca_dev, 0xd3, 0x50);
1190 reg_w(gspca_dev, 0xd3, &DC29[1], 1); 1015 reg_w1(gspca_dev, 0xc6, 0x00);
1191 reg_w(gspca_dev, 0xc6, &DC29[2], 1); 1016 reg_w1(gspca_dev, 0xc7, 0x00);
1192 reg_w(gspca_dev, 0xc7, &DC29[3], 1); 1017 reg_w1(gspca_dev, 0xc8, 0x50);
1193 reg_w(gspca_dev, 0xc8, &DC29[4], 1); 1018 reg_w1(gspca_dev, 0xc9, 0x3c);
1194 reg_w(gspca_dev, 0xc9, &DC29[5], 1);
1195/*fixme:jfm end of ending sequence */ 1019/*fixme:jfm end of ending sequence */
1196 reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1); 1020 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1197 switch (sd->bridge) { 1021 switch (sd->bridge) {
1198 case BRIDGE_SN9C325: 1022 case BRIDGE_SN9C325:
1199 data = 0xae; 1023 data = 0xae;
@@ -1205,11 +1029,11 @@ static void sd_start(struct gspca_dev *gspca_dev)
1205 data = 0x60; 1029 data = 0x60;
1206 break; 1030 break;
1207 } 1031 }
1208 reg_w(gspca_dev, 0x17, &data, 1); 1032 reg_w1(gspca_dev, 0x17, data);
1209 reg_w(gspca_dev, 0x05, &sn9c1xx[5], 1); 1033 reg_w1(gspca_dev, 0x05, sn9c1xx[5]);
1210 reg_w(gspca_dev, 0x07, &sn9c1xx[7], 1); 1034 reg_w1(gspca_dev, 0x07, sn9c1xx[7]);
1211 reg_w(gspca_dev, 0x06, &sn9c1xx[6], 1); 1035 reg_w1(gspca_dev, 0x06, sn9c1xx[6]);
1212 reg_w(gspca_dev, 0x14, &sn9c1xx[0x14], 1); 1036 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1213 switch (sd->bridge) { 1037 switch (sd->bridge) {
1214 case BRIDGE_SN9C325: 1038 case BRIDGE_SN9C325:
1215 reg_w(gspca_dev, 0x20, regsn20_sn9c325, 1039 reg_w(gspca_dev, 0x20, regsn20_sn9c325,
@@ -1217,10 +1041,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
1217 for (i = 0; i < 8; i++) 1041 for (i = 0; i < 8; i++)
1218 reg_w(gspca_dev, 0x84, reg84_sn9c325, 1042 reg_w(gspca_dev, 0x84, reg84_sn9c325,
1219 sizeof reg84_sn9c325); 1043 sizeof reg84_sn9c325);
1220 data = 0x0a; 1044 reg_w1(gspca_dev, 0x9a, 0x0a);
1221 reg_w(gspca_dev, 0x9a, &data, 1); 1045 reg_w1(gspca_dev, 0x99, 0x60);
1222 data = 0x60;
1223 reg_w(gspca_dev, 0x99, &data, 1);
1224 break; 1046 break;
1225 case BRIDGE_SN9C120: 1047 case BRIDGE_SN9C120:
1226 reg_w(gspca_dev, 0x20, regsn20_sn9c120, 1048 reg_w(gspca_dev, 0x20, regsn20_sn9c120,
@@ -1233,39 +1055,30 @@ static void sd_start(struct gspca_dev *gspca_dev)
1233 sizeof reg84_sn9c120_2); 1055 sizeof reg84_sn9c120_2);
1234 reg_w(gspca_dev, 0x84, reg84_sn9c120_3, 1056 reg_w(gspca_dev, 0x84, reg84_sn9c120_3,
1235 sizeof reg84_sn9c120_3); 1057 sizeof reg84_sn9c120_3);
1236 data = 0x05; 1058 reg_w1(gspca_dev, 0x9a, 0x05);
1237 reg_w(gspca_dev, 0x9a, &data, 1); 1059 reg_w1(gspca_dev, 0x99, 0x5b);
1238 data = 0x5b;
1239 reg_w(gspca_dev, 0x99, &data, 1);
1240 break; 1060 break;
1241 default: 1061 default:
1242 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20); 1062 reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20);
1243 for (i = 0; i < 8; i++) 1063 for (i = 0; i < 8; i++)
1244 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1064 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1245 data = 0x08; 1065 reg_w1(gspca_dev, 0x9a, 0x08);
1246 reg_w(gspca_dev, 0x9a, &data, 1); 1066 reg_w1(gspca_dev, 0x99, 0x59);
1247 data = 0x59;
1248 reg_w(gspca_dev, 0x99, &data, 1);
1249 break; 1067 break;
1250 } 1068 }
1251 1069
1252 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1070 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1253 reg1 = 0x02; 1071 if (mode)
1072 reg1 = 0x46; /* 320 clk 48Mhz */
1073 else
1074 reg1 = 0x06; /* 640 clk 24Mz */
1254 reg17 = 0x61; 1075 reg17 = 0x61;
1255 switch (sd->sensor) { 1076 switch (sd->sensor) {
1256 case SENSOR_HV7131R: 1077 case SENSOR_HV7131R:
1257 hv7131R_InitSensor(gspca_dev); 1078 hv7131R_InitSensor(gspca_dev);
1258 if (mode)
1259 reg1 = 0x46; /* 320 clk 48Mhz */
1260 else
1261 reg1 = 0x06; /* 640 clk 24Mz */
1262 break; 1079 break;
1263 case SENSOR_MI0360: 1080 case SENSOR_MI0360:
1264 mi0360_InitSensor(gspca_dev); 1081 mi0360_InitSensor(gspca_dev);
1265 if (mode)
1266 reg1 = 0x46; /* 320 clk 48Mhz */
1267 else
1268 reg1 = 0x06; /* 640 clk 24Mz */
1269 break; 1082 break;
1270 case SENSOR_MO4000: 1083 case SENSOR_MO4000:
1271 mo4000_InitSensor(gspca_dev); 1084 mo4000_InitSensor(gspca_dev);
@@ -1274,13 +1087,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
1274 reg1 = 0x06; /* clk 24Mz */ 1087 reg1 = 0x06; /* clk 24Mz */
1275 } else { 1088 } else {
1276 reg17 = 0x22; /* 640 MCKSIZE */ 1089 reg17 = 0x22; /* 640 MCKSIZE */
1277 reg1 = 0x06; /* 640 clk 24Mz */ 1090/* reg1 = 0x06; * 640 clk 24Mz (done) */
1278 } 1091 }
1279 break; 1092 break;
1280 case SENSOR_OV7648: 1093 case SENSOR_OV7648:
1094 ov7648_InitSensor(gspca_dev);
1281 reg17 = 0xa2; 1095 reg17 = 0xa2;
1282 reg1 = 0x44; 1096 reg1 = 0x44;
1283 ov7648_InitSensor(gspca_dev);
1284/* if (mode) 1097/* if (mode)
1285 ; * 320x2... 1098 ; * 320x2...
1286 else 1099 else
@@ -1292,7 +1105,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1292 if (mode) { 1105 if (mode) {
1293/* reg17 = 0x21; * 320 */ 1106/* reg17 = 0x21; * 320 */
1294/* reg1 = 0x44; */ 1107/* reg1 = 0x44; */
1295 reg1 = 0x46; 1108/* reg1 = 0x46; (done) */
1296 } else { 1109 } else {
1297 reg17 = 0xa2; /* 640 */ 1110 reg17 = 0xa2; /* 640 */
1298 reg1 = 0x40; 1111 reg1 = 0x40;
@@ -1321,16 +1134,16 @@ static void sd_start(struct gspca_dev *gspca_dev)
1321 1134
1322 /* here change size mode 0 -> VGA; 1 -> CIF */ 1135 /* here change size mode 0 -> VGA; 1 -> CIF */
1323 data = 0x40 | sn9c1xx[0x18] | (mode << 4); 1136 data = 0x40 | sn9c1xx[0x18] | (mode << 4);
1324 reg_w(gspca_dev, 0x18, &data, 1); 1137 reg_w1(gspca_dev, 0x18, data);
1325 1138
1326 reg_w(gspca_dev, 0x100, qtable4, 0x40); 1139 reg_w(gspca_dev, 0x100, qtable4, 0x40);
1327 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40); 1140 reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
1328 1141
1329 data = sn9c1xx[0x18] | (mode << 4); 1142 data = sn9c1xx[0x18] | (mode << 4);
1330 reg_w(gspca_dev, 0x18, &data, 1); 1143 reg_w1(gspca_dev, 0x18, data);
1331 1144
1332 reg_w(gspca_dev, 0x17, &reg17, 1); 1145 reg_w1(gspca_dev, 0x17, reg17);
1333 reg_w(gspca_dev, 0x01, &reg1, 1); 1146 reg_w1(gspca_dev, 0x01, reg1);
1334 setbrightness(gspca_dev); 1147 setbrightness(gspca_dev);
1335 setcontrast(gspca_dev); 1148 setcontrast(gspca_dev);
1336} 1149}
@@ -1342,7 +1155,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1342 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; 1155 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1343 static const __u8 stopmi0360[] = 1156 static const __u8 stopmi0360[] =
1344 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; 1157 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1345 __u8 regF1;
1346 __u8 data; 1158 __u8 data;
1347 const __u8 *sn9c1xx; 1159 const __u8 *sn9c1xx;
1348 1160
@@ -1366,12 +1178,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1366 break; 1178 break;
1367 } 1179 }
1368 sn9c1xx = sn_tb[(int) sd->sensor]; 1180 sn9c1xx = sn_tb[(int) sd->sensor];
1369 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1181 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1370 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 1); 1182 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1371 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1); 1183 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1372 reg_w(gspca_dev, 0x01, &data, 1); 1184 reg_w1(gspca_dev, 0x01, data);
1373 regF1 = 0x01; 1185 reg_w1(gspca_dev, 0xf1, 0x01);
1374 reg_w(gspca_dev, 0xf1, &regF1, 1);
1375} 1186}
1376 1187
1377static void sd_stop0(struct gspca_dev *gspca_dev) 1188static void sd_stop0(struct gspca_dev *gspca_dev)
@@ -1610,30 +1421,53 @@ static const struct sd_desc sd_desc = {
1610}; 1421};
1611 1422
1612/* -- module initialisation -- */ 1423/* -- module initialisation -- */
1613#define DVNM(name) .driver_info = (kernel_ulong_t) name 1424#define BSI(bridge, sensor, i2c_addr) \
1425 .driver_info = (BRIDGE_ ## bridge << 16) \
1426 | (SENSOR_ ## sensor << 8) \
1427 | (i2c_addr)
1614static const __devinitdata struct usb_device_id device_table[] = { 1428static const __devinitdata struct usb_device_id device_table[] = {
1615#ifndef CONFIG_USB_SN9C102 1429#ifndef CONFIG_USB_SN9C102
1616 {USB_DEVICE(0x0458, 0x7025), DVNM("Genius Eye 311Q")}, 1430 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
1617 {USB_DEVICE(0x045e, 0x00f5), DVNM("MicroSoft VX3000")}, 1431 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
1618 {USB_DEVICE(0x045e, 0x00f7), DVNM("MicroSoft VX1000")}, 1432 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
1619 {USB_DEVICE(0x0471, 0x0327), DVNM("Philips SPC 600 NC")}, 1433 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
1620 {USB_DEVICE(0x0471, 0x0328), DVNM("Philips SPC 700 NC")}, 1434 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
1621#endif 1435#endif
1622 {USB_DEVICE(0x0471, 0x0330), DVNM("Philips SPC 710NC")}, 1436 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
1623 {USB_DEVICE(0x0c45, 0x6040), DVNM("Speed NVC 350K")}, 1437 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
1624 {USB_DEVICE(0x0c45, 0x607c), DVNM("Sonix sn9c102p Hv7131R")}, 1438/* bw600.inf:
1625 {USB_DEVICE(0x0c45, 0x60c0), DVNM("Sangha Sn535")}, 1439 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
1626 {USB_DEVICE(0x0c45, 0x60ec), DVNM("SN9C105+MO4000")}, 1440/* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
1627 {USB_DEVICE(0x0c45, 0x60fb), DVNM("Surfer NoName")}, 1441/* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
1628 {USB_DEVICE(0x0c45, 0x60fc), DVNM("LG-LIC300")}, 1442 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
1629 {USB_DEVICE(0x0c45, 0x612a), DVNM("Avant Camera")}, 1443/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
1630 {USB_DEVICE(0x0c45, 0x612c), DVNM("Typhoon Rasy Cam 1.3MPix")}, 1444 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
1445/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
1446/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
1447 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
1448/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
1449/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
1450 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
1451 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
1452/* {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x??)}, */
1453/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
1454/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
1455/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
1456 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C325, OV7648, 0x21)},
1457/* bw600.inf:
1458 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C110, OV7648, 0x21)}, */
1459 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
1460/* {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x??)}, */
1461/* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
1631#ifndef CONFIG_USB_SN9C102 1462#ifndef CONFIG_USB_SN9C102
1632 {USB_DEVICE(0x0c45, 0x6130), DVNM("Sonix Pccam")}, 1463 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
1633 {USB_DEVICE(0x0c45, 0x6138), DVNM("Sn9c120 Mo4000")}, 1464 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
1634 {USB_DEVICE(0x0c45, 0x613b), DVNM("Surfer SN-206")}, 1465/* {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x??)}, */
1635 {USB_DEVICE(0x0c45, 0x613c), DVNM("Sonix Pccam168")}, 1466 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
1467 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
1468/* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */
1636#endif 1469#endif
1470 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, MI0360, 0x5d)},
1637 {} 1471 {}
1638}; 1472};
1639MODULE_DEVICE_TABLE(usb, device_table); 1473MODULE_DEVICE_TABLE(usb, device_table);
@@ -1658,7 +1492,7 @@ static int __init sd_mod_init(void)
1658{ 1492{
1659 if (usb_register(&sd_driver) < 0) 1493 if (usb_register(&sd_driver) < 0)
1660 return -1; 1494 return -1;
1661 info("v%s registered", version); 1495 info("registered");
1662 return 0; 1496 return 0;
1663} 1497}
1664static void __exit sd_mod_exit(void) 1498static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index 156206118795..17fe2c2a440d 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -630,109 +627,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
630{ 627{
631 struct sd *sd = (struct sd *) gspca_dev; 628 struct sd *sd = (struct sd *) gspca_dev;
632 struct cam *cam; 629 struct cam *cam;
633 __u16 vendor; 630
634 __u16 product;
635
636 vendor = id->idVendor;
637 product = id->idProduct;
638 switch (vendor) {
639 case 0x040a: /* Kodak cameras */
640/* switch (product) { */
641/* case 0x0300: */
642 sd->subtype = KodakEZ200;
643/* break; */
644/* } */
645 break;
646 case 0x041e: /* Creative cameras */
647/* switch (product) { */
648/* case 0x400a: */
649 sd->subtype = CreativePCCam300;
650/* break; */
651/* } */
652 break;
653 case 0x046d: /* Logitech Labtec */
654 switch (product) {
655 case 0x0890:
656 sd->subtype = LogitechTraveler;
657 break;
658 case 0x0900:
659 sd->subtype = LogitechClickSmart310;
660 break;
661 case 0x0901:
662 sd->subtype = LogitechClickSmart510;
663 break;
664 }
665 break;
666 case 0x04a5: /* Benq */
667/* switch (product) { */
668/* case 0x300c: */
669 sd->subtype = BenqDC1016;
670/* break; */
671/* } */
672 break;
673 case 0x04fc: /* SunPlus */
674/* switch (product) { */
675/* case 0x7333: */
676 sd->subtype = PalmPixDC85;
677/* break; */
678/* } */
679 break;
680 case 0x055f: /* Mustek cameras */
681 switch (product) {
682 case 0xc200:
683 sd->subtype = MustekGsmart300;
684 break;
685 case 0xc220:
686 sd->subtype = Gsmartmini;
687 break;
688 }
689 break;
690 case 0x06bd: /* Agfa Cl20 */
691/* switch (product) { */
692/* case 0x0404: */
693 sd->subtype = AgfaCl20;
694/* break; */
695/* } */
696 break;
697 case 0x06be: /* Optimedia */
698/* switch (product) { */
699/* case 0x0800: */
700 sd->subtype = Optimedia;
701/* break; */
702/* } */
703 break;
704 case 0x084d: /* D-Link / Minton */
705/* switch (product) { */
706/* case 0x0003: * DSC-350 / S-Cam F5 */
707 sd->subtype = DLinkDSC350;
708/* break; */
709/* } */
710 break;
711 case 0x08ca: /* Aiptek */
712/* switch (product) { */
713/* case 0x0103: */
714 sd->subtype = AiptekPocketDV;
715/* break; */
716/* } */
717 break;
718 case 0x2899: /* ToptroIndustrial */
719/* switch (product) { */
720/* case 0x012c: */
721 sd->subtype = ToptroIndus;
722/* break; */
723/* } */
724 break;
725 case 0x8086: /* Intel */
726/* switch (product) { */
727/* case 0x0630: * Pocket PC Camera */
728 sd->subtype = IntelPocketPCCamera;
729/* break; */
730/* } */
731 break;
732 }
733 cam = &gspca_dev->cam; 631 cam = &gspca_dev->cam;
734 cam->dev_name = (char *) id->driver_info;
735 cam->epaddr = 0x01; 632 cam->epaddr = 0x01;
633 sd->subtype = id->driver_info;
736 if (sd->subtype != LogitechClickSmart310) { 634 if (sd->subtype != LogitechClickSmart310) {
737 cam->cam_mode = vga_mode; 635 cam->cam_mode = vga_mode;
738 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 636 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
@@ -1162,23 +1060,22 @@ static struct sd_desc sd_desc = {
1162}; 1060};
1163 1061
1164/* -- module initialisation -- */ 1062/* -- module initialisation -- */
1165#define DVNM(name) .driver_info = (kernel_ulong_t) name
1166static const __devinitdata struct usb_device_id device_table[] = { 1063static const __devinitdata struct usb_device_id device_table[] = {
1167 {USB_DEVICE(0x040a, 0x0300), DVNM("Kodak EZ200")}, 1064 {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200},
1168 {USB_DEVICE(0x041e, 0x400a), DVNM("Creative PC-CAM 300")}, 1065 {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300},
1169 {USB_DEVICE(0x046d, 0x0890), DVNM("Logitech QuickCam traveler")}, 1066 {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler},
1170 {USB_DEVICE(0x046d, 0x0900), DVNM("Logitech Inc. ClickSmart 310")}, 1067 {USB_DEVICE(0x046d, 0x0900), .driver_info = LogitechClickSmart310},
1171 {USB_DEVICE(0x046d, 0x0901), DVNM("Logitech Inc. ClickSmart 510")}, 1068 {USB_DEVICE(0x046d, 0x0901), .driver_info = LogitechClickSmart510},
1172 {USB_DEVICE(0x04a5, 0x300c), DVNM("Benq DC1016")}, 1069 {USB_DEVICE(0x04a5, 0x300c), .driver_info = BenqDC1016},
1173 {USB_DEVICE(0x04fc, 0x7333), DVNM("PalmPixDC85")}, 1070 {USB_DEVICE(0x04fc, 0x7333), .driver_info = PalmPixDC85},
1174 {USB_DEVICE(0x055f, 0xc200), DVNM("Mustek Gsmart 300")}, 1071 {USB_DEVICE(0x055f, 0xc200), .driver_info = MustekGsmart300},
1175 {USB_DEVICE(0x055f, 0xc220), DVNM("Gsmart Mini")}, 1072 {USB_DEVICE(0x055f, 0xc220), .driver_info = Gsmartmini},
1176 {USB_DEVICE(0x06bd, 0x0404), DVNM("Agfa CL20")}, 1073 {USB_DEVICE(0x06bd, 0x0404), .driver_info = AgfaCl20},
1177 {USB_DEVICE(0x06be, 0x0800), DVNM("Optimedia")}, 1074 {USB_DEVICE(0x06be, 0x0800), .driver_info = Optimedia},
1178 {USB_DEVICE(0x084d, 0x0003), DVNM("D-Link DSC-350")}, 1075 {USB_DEVICE(0x084d, 0x0003), .driver_info = DLinkDSC350},
1179 {USB_DEVICE(0x08ca, 0x0103), DVNM("Aiptek PocketDV")}, 1076 {USB_DEVICE(0x08ca, 0x0103), .driver_info = AiptekPocketDV},
1180 {USB_DEVICE(0x2899, 0x012c), DVNM("Toptro Industrial")}, 1077 {USB_DEVICE(0x2899, 0x012c), .driver_info = ToptroIndus},
1181 {USB_DEVICE(0x8086, 0x0630), DVNM("Intel Pocket PC Camera")}, 1078 {USB_DEVICE(0x8086, 0x0630), .driver_info = IntelPocketPCCamera},
1182 {} 1079 {}
1183}; 1080};
1184MODULE_DEVICE_TABLE(usb, device_table); 1081MODULE_DEVICE_TABLE(usb, device_table);
@@ -1203,7 +1100,7 @@ static int __init sd_mod_init(void)
1203{ 1100{
1204 if (usb_register(&sd_driver) < 0) 1101 if (usb_register(&sd_driver) < 0)
1205 return -1; 1102 return -1;
1206 PDEBUG(D_PROBE, "v%s registered", version); 1103 PDEBUG(D_PROBE, "registered");
1207 return 0; 1104 return 0;
1208} 1105}
1209static void __exit sd_mod_exit(void) 1106static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index 50e929de0203..51a3c3429ef0 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 26MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30MODULE_DESCRIPTION("GSPCA/SPCA501 USB Camera Driver"); 27MODULE_DESCRIPTION("GSPCA/SPCA501 USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -1923,63 +1920,12 @@ static int sd_config(struct gspca_dev *gspca_dev,
1923{ 1920{
1924 struct sd *sd = (struct sd *) gspca_dev; 1921 struct sd *sd = (struct sd *) gspca_dev;
1925 struct cam *cam; 1922 struct cam *cam;
1926 __u16 vendor; 1923
1927 __u16 product;
1928
1929 vendor = id->idVendor;
1930 product = id->idProduct;
1931 switch (vendor) {
1932 case 0x0000: /* Unknow Camera */
1933/* switch (product) { */
1934/* case 0x0000: */
1935 sd->subtype = MystFromOriUnknownCamera;
1936/* break; */
1937/* } */
1938 break;
1939 case 0x040a: /* Kodak cameras */
1940/* switch (product) { */
1941/* case 0x0002: */
1942 sd->subtype = KodakDVC325;
1943/* break; */
1944/* } */
1945 break;
1946 case 0x0497: /* Smile International */
1947/* switch (product) { */
1948/* case 0xc001: */
1949 sd->subtype = SmileIntlCamera;
1950/* break; */
1951/* } */
1952 break;
1953 case 0x0506: /* 3COM cameras */
1954/* switch (product) { */
1955/* case 0x00df: */
1956 sd->subtype = ThreeComHomeConnectLite;
1957/* break; */
1958/* } */
1959 break;
1960 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
1961 switch (product) {
1962 case 0x0401:
1963 sd->subtype = IntelCreateAndShare;
1964 break;
1965 case 0x0402:
1966 sd->subtype = ViewQuestM318B;
1967 break;
1968 }
1969 break;
1970 case 0x1776: /* Arowana */
1971/* switch (product) { */
1972/* case 0x501c: */
1973 sd->subtype = Arowana300KCMOSCamera;
1974/* break; */
1975/* } */
1976 break;
1977 }
1978 cam = &gspca_dev->cam; 1924 cam = &gspca_dev->cam;
1979 cam->dev_name = (char *) id->driver_info;
1980 cam->epaddr = 0x01; 1925 cam->epaddr = 0x01;
1981 cam->cam_mode = vga_mode; 1926 cam->cam_mode = vga_mode;
1982 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 1927 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
1928 sd->subtype = id->driver_info;
1983 sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value; 1929 sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value;
1984 sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value; 1930 sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value;
1985 sd->colors = sd_ctrls[MY_COLOR].qctrl.default_value; 1931 sd->colors = sd_ctrls[MY_COLOR].qctrl.default_value;
@@ -2183,15 +2129,14 @@ static const struct sd_desc sd_desc = {
2183}; 2129};
2184 2130
2185/* -- module initialisation -- */ 2131/* -- module initialisation -- */
2186#define DVNM(name) .driver_info = (kernel_ulong_t) name
2187static const __devinitdata struct usb_device_id device_table[] = { 2132static const __devinitdata struct usb_device_id device_table[] = {
2188 {USB_DEVICE(0x040a, 0x0002), DVNM("Kodak DVC-325")}, 2133 {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325},
2189 {USB_DEVICE(0x0497, 0xc001), DVNM("Smile International")}, 2134 {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera},
2190 {USB_DEVICE(0x0506, 0x00df), DVNM("3Com HomeConnect Lite")}, 2135 {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite},
2191 {USB_DEVICE(0x0733, 0x0401), DVNM("Intel Create and Share")}, 2136 {USB_DEVICE(0x0733, 0x0401), .driver_info = IntelCreateAndShare},
2192 {USB_DEVICE(0x0733, 0x0402), DVNM("ViewQuest M318B")}, 2137 {USB_DEVICE(0x0733, 0x0402), .driver_info = ViewQuestM318B},
2193 {USB_DEVICE(0x1776, 0x501c), DVNM("Arowana 300K CMOS Camera")}, 2138 {USB_DEVICE(0x1776, 0x501c), .driver_info = Arowana300KCMOSCamera},
2194 {USB_DEVICE(0x0000, 0x0000), DVNM("MystFromOri Unknow Camera")}, 2139 {USB_DEVICE(0x0000, 0x0000), .driver_info = MystFromOriUnknownCamera},
2195 {} 2140 {}
2196}; 2141};
2197MODULE_DEVICE_TABLE(usb, device_table); 2142MODULE_DEVICE_TABLE(usb, device_table);
@@ -2216,7 +2161,7 @@ static int __init sd_mod_init(void)
2216{ 2161{
2217 if (usb_register(&sd_driver) < 0) 2162 if (usb_register(&sd_driver) < 0)
2218 return -1; 2163 return -1;
2219 PDEBUG(D_PROBE, "v%s registered", version); 2164 PDEBUG(D_PROBE, "registered");
2220 return 0; 2165 return 0;
2221} 2166}
2222static void __exit sd_mod_exit(void) 2167static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index ddea6e140aa8..3c2be80cbd65 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -23,9 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 26MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver"); 27MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -34,10 +31,6 @@ MODULE_LICENSE("GPL");
34struct sd { 31struct sd {
35 struct gspca_dev gspca_dev; /* !! must be the first item */ 32 struct gspca_dev gspca_dev; /* !! must be the first item */
36 33
37 int buflen;
38 unsigned char tmpbuf[640 * 480 * 3 / 2]; /* YYUV per line */
39 unsigned char tmpbuf2[640 * 480 * 2]; /* YUYV */
40
41 unsigned char brightness; 34 unsigned char brightness;
42 35
43 char subtype; 36 char subtype;
@@ -67,29 +60,29 @@ static struct ctrl sd_ctrls[] = {
67}; 60};
68 61
69static struct v4l2_pix_format vga_mode[] = { 62static struct v4l2_pix_format vga_mode[] = {
70 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 63 {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
71 .bytesperline = 160 * 2, 64 .bytesperline = 160 * 3,
72 .sizeimage = 160 * 120 * 2, 65 .sizeimage = 160 * 120 * 3 / 2,
73 .colorspace = V4L2_COLORSPACE_SRGB, 66 .colorspace = V4L2_COLORSPACE_SRGB,
74 .priv = 5}, 67 .priv = 5},
75 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 68 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
76 .bytesperline = 176 * 2, 69 .bytesperline = 176 * 3,
77 .sizeimage = 176 * 144 * 2, 70 .sizeimage = 176 * 144 * 3 / 2,
78 .colorspace = V4L2_COLORSPACE_SRGB, 71 .colorspace = V4L2_COLORSPACE_SRGB,
79 .priv = 4}, 72 .priv = 4},
80 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 73 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
81 .bytesperline = 320 * 2, 74 .bytesperline = 320 * 3,
82 .sizeimage = 320 * 240 * 2, 75 .sizeimage = 320 * 240 * 3 / 2,
83 .colorspace = V4L2_COLORSPACE_SRGB, 76 .colorspace = V4L2_COLORSPACE_SRGB,
84 .priv = 2}, 77 .priv = 2},
85 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 78 {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
86 .bytesperline = 352 * 2, 79 .bytesperline = 352 * 3,
87 .sizeimage = 352 * 288 * 2, 80 .sizeimage = 352 * 288 * 3 / 2,
88 .colorspace = V4L2_COLORSPACE_SRGB, 81 .colorspace = V4L2_COLORSPACE_SRGB,
89 .priv = 1}, 82 .priv = 1},
90 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 83 {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
91 .bytesperline = 640 * 2, 84 .bytesperline = 640 * 3,
92 .sizeimage = 640 * 480 * 2, 85 .sizeimage = 640 * 480 * 3 / 2,
93 .colorspace = V4L2_COLORSPACE_SRGB, 86 .colorspace = V4L2_COLORSPACE_SRGB,
94 .priv = 0}, 87 .priv = 0},
95}; 88};
@@ -641,33 +634,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
641{ 634{
642 struct sd *sd = (struct sd *) gspca_dev; 635 struct sd *sd = (struct sd *) gspca_dev;
643 struct cam *cam; 636 struct cam *cam;
644 __u16 vendor;
645 __u16 product;
646
647 vendor = id->idVendor;
648 product = id->idProduct;
649 switch (vendor) {
650 case 0x041e: /* Creative cameras */
651/* switch (product) { */
652/* case 0x401d: * here505b */
653 sd->subtype = Nxultra;
654/* break; */
655/* } */
656 break;
657 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
658/* switch (product) { */
659/* case 0x0430: */
660/* fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */
661 sd->subtype = IntelPCCameraPro;
662/* break; */
663/* } */
664 break;
665 }
666 637
667 cam = &gspca_dev->cam; 638 cam = &gspca_dev->cam;
668 cam->dev_name = (char *) id->driver_info;
669 cam->epaddr = 0x01; 639 cam->epaddr = 0x01;
670 cam->cam_mode = vga_mode; 640 cam->cam_mode = vga_mode;
641 sd->subtype = id->driver_info;
671 if (sd->subtype != IntelPCCameraPro) 642 if (sd->subtype != IntelPCCameraPro)
672 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 643 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
673 else /* no 640x480 for IntelPCCameraPro */ 644 else /* no 640x480 for IntelPCCameraPro */
@@ -785,77 +756,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
785 reg_write(gspca_dev->dev, 0x05, 0x11, 0xf); 756 reg_write(gspca_dev->dev, 0x05, 0x11, 0xf);
786} 757}
787 758
788/* convert YYUV per line to YUYV (YUV 4:2:2) */
789static void yyuv_decode(unsigned char *out,
790 unsigned char *in,
791 int width,
792 int height)
793{
794 unsigned char *Ui, *Vi, *yi, *yi1;
795 unsigned char *out1;
796 int i, j;
797
798 yi = in;
799 for (i = height / 2; --i >= 0; ) {
800 out1 = out + width * 2; /* next line */
801 yi1 = yi + width;
802 Ui = yi1 + width;
803 Vi = Ui + width / 2;
804 for (j = width / 2; --j >= 0; ) {
805 *out++ = 128 + *yi++;
806 *out++ = 128 + *Ui;
807 *out++ = 128 + *yi++;
808 *out++ = 128 + *Vi;
809
810 *out1++ = 128 + *yi1++;
811 *out1++ = 128 + *Ui++;
812 *out1++ = 128 + *yi1++;
813 *out1++ = 128 + *Vi++;
814 }
815 yi += width * 2;
816 out = out1;
817 }
818}
819
820static void sd_pkt_scan(struct gspca_dev *gspca_dev, 759static void sd_pkt_scan(struct gspca_dev *gspca_dev,
821 struct gspca_frame *frame, /* target */ 760 struct gspca_frame *frame, /* target */
822 __u8 *data, /* isoc packet */ 761 __u8 *data, /* isoc packet */
823 int len) /* iso packet length */ 762 int len) /* iso packet length */
824{ 763{
825 struct sd *sd = (struct sd *) gspca_dev;
826
827 switch (data[0]) { 764 switch (data[0]) {
828 case 0: /* start of frame */ 765 case 0: /* start of frame */
829 if (gspca_dev->last_packet_type == FIRST_PACKET) { 766 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
830 yyuv_decode(sd->tmpbuf2, sd->tmpbuf, 767 data, 0);
831 gspca_dev->width,
832 gspca_dev->height);
833 frame = gspca_frame_add(gspca_dev,
834 LAST_PACKET,
835 frame,
836 sd->tmpbuf2,
837 gspca_dev->width
838 * gspca_dev->height
839 * 2);
840 }
841 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
842 data, 0);
843 data += SPCA50X_OFFSET_DATA; 768 data += SPCA50X_OFFSET_DATA;
844 len -= SPCA50X_OFFSET_DATA; 769 len -= SPCA50X_OFFSET_DATA;
845 if (len > 0) 770 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
846 memcpy(sd->tmpbuf, data, len); 771 data, len);
847 else 772 break;
848 len = 0;
849 sd->buflen = len;
850 return;
851 case 0xff: /* drop */ 773 case 0xff: /* drop */
852/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 774/* gspca_dev->last_packet_type = DISCARD_PACKET; */
853 return; 775 break;
776 default:
777 data += 1;
778 len -= 1;
779 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
780 data, len);
781 break;
854 } 782 }
855 data += 1;
856 len -= 1;
857 memcpy(&sd->tmpbuf[sd->buflen], data, len);
858 sd->buflen += len;
859} 783}
860 784
861static void setbrightness(struct gspca_dev *gspca_dev) 785static void setbrightness(struct gspca_dev *gspca_dev)
@@ -910,10 +834,10 @@ static const struct sd_desc sd_desc = {
910}; 834};
911 835
912/* -- module initialisation -- */ 836/* -- module initialisation -- */
913#define DVNM(name) .driver_info = (kernel_ulong_t) name
914static const __devinitdata struct usb_device_id device_table[] = { 837static const __devinitdata struct usb_device_id device_table[] = {
915 {USB_DEVICE(0x041e, 0x401d), DVNM("Creative Webcam NX ULTRA")}, 838 {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra},
916 {USB_DEVICE(0x0733, 0x0430), DVNM("Intel PC Camera Pro")}, 839 {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro},
840/*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */
917 {} 841 {}
918}; 842};
919MODULE_DEVICE_TABLE(usb, device_table); 843MODULE_DEVICE_TABLE(usb, device_table);
@@ -938,7 +862,7 @@ static int __init sd_mod_init(void)
938{ 862{
939 if (usb_register(&sd_driver) < 0) 863 if (usb_register(&sd_driver) < 0)
940 return -1; 864 return -1;
941 PDEBUG(D_PROBE, "v%s registered", version); 865 PDEBUG(D_PROBE, "registered");
942 return 0; 866 return 0;
943} 867}
944static void __exit sd_mod_exit(void) 868static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index 143203c1fd9f..6fe715c80ad2 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -25,9 +25,6 @@
25 25
26#include "gspca.h" 26#include "gspca.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
29static const char version[] = "2.1.7";
30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver");
33MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -36,10 +33,6 @@ MODULE_LICENSE("GPL");
36struct sd { 33struct sd {
37 struct gspca_dev gspca_dev; /* !! must be the first item */ 34 struct gspca_dev gspca_dev; /* !! must be the first item */
38 35
39 int buflen;
40 __u8 tmpbuf[640 * 480 * 3]; /* YYUV per line */
41 __u8 tmpbuf2[640 * 480 * 2]; /* YUYV */
42
43 unsigned char brightness; 36 unsigned char brightness;
44 unsigned char contrast; 37 unsigned char contrast;
45 unsigned char colors; 38 unsigned char colors;
@@ -118,29 +111,29 @@ static struct ctrl sd_ctrls[] = {
118}; 111};
119 112
120static struct v4l2_pix_format vga_mode[] = { 113static struct v4l2_pix_format vga_mode[] = {
121 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 114 {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
122 .bytesperline = 160 * 2, 115 .bytesperline = 160 * 3,
123 .sizeimage = 160 * 120 * 2, 116 .sizeimage = 160 * 120 * 3 / 2,
124 .colorspace = V4L2_COLORSPACE_SRGB, 117 .colorspace = V4L2_COLORSPACE_SRGB,
125 .priv = 5}, 118 .priv = 5},
126 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 119 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
127 .bytesperline = 176 * 2, 120 .bytesperline = 176 * 3,
128 .sizeimage = 176 * 144 * 2, 121 .sizeimage = 176 * 144 * 3 / 2,
129 .colorspace = V4L2_COLORSPACE_SRGB, 122 .colorspace = V4L2_COLORSPACE_SRGB,
130 .priv = 4}, 123 .priv = 4},
131 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 124 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
132 .bytesperline = 320 * 2, 125 .bytesperline = 320 * 3,
133 .sizeimage = 320 * 240 * 2, 126 .sizeimage = 320 * 240 * 3 / 2,
134 .colorspace = V4L2_COLORSPACE_SRGB, 127 .colorspace = V4L2_COLORSPACE_SRGB,
135 .priv = 2}, 128 .priv = 2},
136 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 129 {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
137 .bytesperline = 352 * 2, 130 .bytesperline = 352 * 3,
138 .sizeimage = 352 * 288 * 2, 131 .sizeimage = 352 * 288 * 3 / 2,
139 .colorspace = V4L2_COLORSPACE_SRGB, 132 .colorspace = V4L2_COLORSPACE_SRGB,
140 .priv = 1}, 133 .priv = 1},
141 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 134 {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
142 .bytesperline = 640 * 2, 135 .bytesperline = 640 * 3,
143 .sizeimage = 640 * 480 * 2, 136 .sizeimage = 640 * 480 * 3 / 2,
144 .colorspace = V4L2_COLORSPACE_SRGB, 137 .colorspace = V4L2_COLORSPACE_SRGB,
145 .priv = 0}, 138 .priv = 0},
146}; 139};
@@ -310,7 +303,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
310 struct cam *cam; 303 struct cam *cam;
311 304
312 cam = &gspca_dev->cam; 305 cam = &gspca_dev->cam;
313 cam->dev_name = (char *) id->driver_info;
314 cam->epaddr = 0x01; 306 cam->epaddr = 0x01;
315 cam->cam_mode = vga_mode; 307 cam->cam_mode = vga_mode;
316 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 308 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
@@ -576,77 +568,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
576{ 568{
577} 569}
578 570
579/* convert YYUV per line to YUYV (YUV 4:2:2) */
580static void yyuv_decode(unsigned char *out,
581 unsigned char *in,
582 int width,
583 int height)
584{
585 unsigned char *Ui, *Vi, *yi, *yi1;
586 unsigned char *out1;
587 int i, j;
588
589 yi = in;
590 for (i = height / 2; --i >= 0; ) {
591 out1 = out + width * 2; /* next line */
592 yi1 = yi + width;
593 Ui = yi1 + width;
594 Vi = Ui + width / 2;
595 for (j = width / 2; --j >= 0; ) {
596 *out++ = 128 + *yi++;
597 *out++ = 128 + *Ui;
598 *out++ = 128 + *yi++;
599 *out++ = 128 + *Vi;
600
601 *out1++ = 128 + *yi1++;
602 *out1++ = 128 + *Ui++;
603 *out1++ = 128 + *yi1++;
604 *out1++ = 128 + *Vi++;
605 }
606 yi += width * 2;
607 out = out1;
608 }
609}
610
611static void sd_pkt_scan(struct gspca_dev *gspca_dev, 571static void sd_pkt_scan(struct gspca_dev *gspca_dev,
612 struct gspca_frame *frame, /* target */ 572 struct gspca_frame *frame, /* target */
613 __u8 *data, /* isoc packet */ 573 __u8 *data, /* isoc packet */
614 int len) /* iso packet length */ 574 int len) /* iso packet length */
615{ 575{
616 struct sd *sd = (struct sd *) gspca_dev;
617
618 switch (data[0]) { 576 switch (data[0]) {
619 case 0: /* start of frame */ 577 case 0: /* start of frame */
620 if (gspca_dev->last_packet_type == FIRST_PACKET) { 578 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
621 yyuv_decode(sd->tmpbuf2, sd->tmpbuf, 579 data, 0);
622 gspca_dev->width,
623 gspca_dev->height);
624 frame = gspca_frame_add(gspca_dev,
625 LAST_PACKET,
626 frame,
627 sd->tmpbuf2,
628 gspca_dev->width
629 * gspca_dev->height
630 * 2);
631 }
632 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
633 data, 0);
634 data += SPCA50X_OFFSET_DATA; 580 data += SPCA50X_OFFSET_DATA;
635 len -= SPCA50X_OFFSET_DATA; 581 len -= SPCA50X_OFFSET_DATA;
636 if (len > 0) 582 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
637 memcpy(sd->tmpbuf, data, len); 583 data, len);
638 else 584 break;
639 len = 0;
640 sd->buflen = len;
641 return;
642 case 0xff: /* drop */ 585 case 0xff: /* drop */
643/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 586/* gspca_dev->last_packet_type = DISCARD_PACKET; */
644 return; 587 break;
588 default:
589 data += 1;
590 len -= 1;
591 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
592 data, len);
593 break;
645 } 594 }
646 data += 1;
647 len -= 1;
648 memcpy(&sd->tmpbuf[sd->buflen], data, len);
649 sd->buflen += len;
650} 595}
651 596
652static void setbrightness(struct gspca_dev *gspca_dev) 597static void setbrightness(struct gspca_dev *gspca_dev)
@@ -804,12 +749,12 @@ static struct sd_desc sd_desc = {
804}; 749};
805 750
806/* -- module initialisation -- */ 751/* -- module initialisation -- */
807#define DVNM(name) .driver_info = (kernel_ulong_t) name
808static __devinitdata struct usb_device_id device_table[] = { 752static __devinitdata struct usb_device_id device_table[] = {
809 {USB_DEVICE(0x06e1, 0xa190), DVNM("ADS Instant VCD")}, 753 {USB_DEVICE(0x06e1, 0xa190)},
810/* {USB_DEVICE(0x0733, 0x0430), DVNM("UsbGrabber PV321c")}, */ 754/*fixme: may be IntelPCCameraPro BRIDGE_SPCA505
811 {USB_DEVICE(0x0734, 0x043b), DVNM("3DeMon USB Capture aka")}, 755 {USB_DEVICE(0x0733, 0x0430)}, */
812 {USB_DEVICE(0x99fa, 0x8988), DVNM("Grandtec V.cap")}, 756 {USB_DEVICE(0x0734, 0x043b)},
757 {USB_DEVICE(0x99fa, 0x8988)},
813 {} 758 {}
814}; 759};
815MODULE_DEVICE_TABLE(usb, device_table); 760MODULE_DEVICE_TABLE(usb, device_table);
@@ -834,7 +779,7 @@ static int __init sd_mod_init(void)
834{ 779{
835 if (usb_register(&sd_driver) < 0) 780 if (usb_register(&sd_driver) < 0)
836 return -1; 781 return -1;
837 PDEBUG(D_PROBE, "v%s registered", version); 782 PDEBUG(D_PROBE, "registered");
838 return 0; 783 return 0;
839} 784}
840static void __exit sd_mod_exit(void) 785static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index d8cd93866a4a..b608a27ad115 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver"); 26MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -33,10 +30,6 @@ MODULE_LICENSE("GPL");
33struct sd { 30struct sd {
34 struct gspca_dev gspca_dev; /* !! must be the first item */ 31 struct gspca_dev gspca_dev; /* !! must be the first item */
35 32
36 int buflen;
37 unsigned char tmpbuf[352 * 288 * 3 / 2]; /* YUVY per line */
38 unsigned char tmpbuf2[352 * 288 * 2]; /* YUYV */
39
40 unsigned char brightness; 33 unsigned char brightness;
41 34
42 char subtype; 35 char subtype;
@@ -71,23 +64,23 @@ static struct ctrl sd_ctrls[] = {
71 64
72static struct v4l2_pix_format sif_mode[] = { 65static struct v4l2_pix_format sif_mode[] = {
73 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 66 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
74 .bytesperline = 160 * 2, 67 .bytesperline = 160 * 3,
75 .sizeimage = 160 * 120 * 2, 68 .sizeimage = 160 * 120 * 3 / 2,
76 .colorspace = V4L2_COLORSPACE_SRGB, 69 .colorspace = V4L2_COLORSPACE_SRGB,
77 .priv = 3}, 70 .priv = 3},
78 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 71 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
79 .bytesperline = 176 * 2, 72 .bytesperline = 176 * 3,
80 .sizeimage = 176 * 144 * 2, 73 .sizeimage = 176 * 144 * 3 / 2,
81 .colorspace = V4L2_COLORSPACE_SRGB, 74 .colorspace = V4L2_COLORSPACE_SRGB,
82 .priv = 2}, 75 .priv = 2},
83 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 76 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
84 .bytesperline = 320 * 2, 77 .bytesperline = 320 * 3,
85 .sizeimage = 320 * 240 * 2, 78 .sizeimage = 320 * 240 * 3 / 2,
86 .colorspace = V4L2_COLORSPACE_SRGB, 79 .colorspace = V4L2_COLORSPACE_SRGB,
87 .priv = 1}, 80 .priv = 1},
88 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 81 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
89 .bytesperline = 352 * 2, 82 .bytesperline = 352 * 3,
90 .sizeimage = 352 * 288 * 2, 83 .sizeimage = 352 * 288 * 3 / 2,
91 .colorspace = V4L2_COLORSPACE_SRGB, 84 .colorspace = V4L2_COLORSPACE_SRGB,
92 .priv = 0}, 85 .priv = 0},
93}; 86};
@@ -1476,58 +1469,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1476{ 1469{
1477 struct sd *sd = (struct sd *) gspca_dev; 1470 struct sd *sd = (struct sd *) gspca_dev;
1478 struct cam *cam; 1471 struct cam *cam;
1479 __u16 product;
1480 int data1, data2; 1472 int data1, data2;
1481 1473
1482 product = id->idProduct;
1483 switch (id->idVendor) {
1484 case 0x0130: /* Clone webcam */
1485/* switch (product) { */
1486/* case 0x0130: */
1487 sd->subtype = HamaUSBSightcam; /* same as Hama 0010 */
1488/* break; */
1489/* } */
1490 break;
1491 case 0x041e: /* Creative cameras */
1492/* switch (product) { */
1493/* case 0x4018: */
1494 sd->subtype = CreativeVista;
1495/* break; */
1496/* } */
1497 break;
1498 case 0x0461: /* MicroInnovation */
1499/* switch (product) { */
1500/* case 0x0815: */
1501 sd->subtype = MicroInnovationIC200;
1502/* break; */
1503/* } */
1504 break;
1505 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
1506/* switch (product) { */
1507/* case 0x110: */
1508 sd->subtype = ViewQuestVQ110;
1509/* break; */
1510/* } */
1511 break;
1512 case 0x0af9: /* Hama cameras */
1513 switch (product) {
1514 case 0x0010:
1515 sd->subtype = HamaUSBSightcam;
1516 break;
1517 case 0x0011:
1518 sd->subtype = HamaUSBSightcam2;
1519 break;
1520 }
1521 break;
1522 case 0x8086: /* Intel */
1523/* switch (product) { */
1524/* case 0x0110: */
1525 sd->subtype = IntelEasyPCCamera;
1526/* break; */
1527/* } */
1528 break;
1529 }
1530
1531 /* Read from global register the USB product and vendor IDs, just to 1474 /* Read from global register the USB product and vendor IDs, just to
1532 * prove that we can communicate with the device. This works, which 1475 * prove that we can communicate with the device. This works, which
1533 * confirms at we are communicating properly and that the device 1476 * confirms at we are communicating properly and that the device
@@ -1544,10 +1487,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
1544 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); 1487 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1);
1545 1488
1546 cam = &gspca_dev->cam; 1489 cam = &gspca_dev->cam;
1547 cam->dev_name = (char *) id->driver_info;
1548 cam->epaddr = 0x01; 1490 cam->epaddr = 0x01;
1549 cam->cam_mode = sif_mode; 1491 cam->cam_mode = sif_mode;
1550 cam->nmodes = ARRAY_SIZE(sif_mode); 1492 cam->nmodes = ARRAY_SIZE(sif_mode);
1493
1494 sd->subtype = id->driver_info;
1551 sd->brightness = BRIGHTNESS_DEF; 1495 sd->brightness = BRIGHTNESS_DEF;
1552 1496
1553 switch (sd->subtype) { 1497 switch (sd->subtype) {
@@ -1619,77 +1563,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
1619{ 1563{
1620} 1564}
1621 1565
1622/* convert YUVY per line to YUYV (YUV 4:2:2) */
1623static void yuvy_decode(unsigned char *out,
1624 unsigned char *in,
1625 int width,
1626 int height)
1627{
1628 unsigned char *Ui, *Vi, *yi, *yi1;
1629 unsigned char *out1;
1630 int i, j;
1631
1632 yi = in;
1633 for (i = height / 2; --i >= 0; ) {
1634 out1 = out + width * 2; /* next line */
1635 Ui = yi + width;
1636 Vi = Ui + width / 2;
1637 yi1 = Vi + width / 2;
1638 for (j = width / 2; --j >= 0; ) {
1639 *out++ = 128 + *yi++;
1640 *out++ = 128 + *Ui;
1641 *out++ = 128 + *yi++;
1642 *out++ = 128 + *Vi;
1643
1644 *out1++ = 128 + *yi1++;
1645 *out1++ = 128 + *Ui++;
1646 *out1++ = 128 + *yi1++;
1647 *out1++ = 128 + *Vi++;
1648 }
1649 yi += width * 2;
1650 out = out1;
1651 }
1652}
1653
1654static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1566static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1655 struct gspca_frame *frame, /* target */ 1567 struct gspca_frame *frame, /* target */
1656 __u8 *data, /* isoc packet */ 1568 __u8 *data, /* isoc packet */
1657 int len) /* iso packet length */ 1569 int len) /* iso packet length */
1658{ 1570{
1659 struct sd *sd = (struct sd *) gspca_dev;
1660
1661 switch (data[0]) { 1571 switch (data[0]) {
1662 case 0: /* start of frame */ 1572 case 0: /* start of frame */
1663 if (gspca_dev->last_packet_type == FIRST_PACKET) { 1573 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
1664 yuvy_decode(sd->tmpbuf2, sd->tmpbuf, 1574 data, 0);
1665 gspca_dev->width,
1666 gspca_dev->height);
1667 frame = gspca_frame_add(gspca_dev,
1668 LAST_PACKET,
1669 frame,
1670 sd->tmpbuf2,
1671 gspca_dev->width
1672 * gspca_dev->height
1673 * 2);
1674 }
1675 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1676 data, 0);
1677 data += SPCA508_OFFSET_DATA; 1575 data += SPCA508_OFFSET_DATA;
1678 len -= SPCA508_OFFSET_DATA; 1576 len -= SPCA508_OFFSET_DATA;
1679 if (len > 0) 1577 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1680 memcpy(sd->tmpbuf, data, len); 1578 data, len);
1681 else 1579 break;
1682 len = 0;
1683 sd->buflen = len;
1684 return;
1685 case 0xff: /* drop */ 1580 case 0xff: /* drop */
1686/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 1581/* gspca_dev->last_packet_type = DISCARD_PACKET; */
1687 return; 1582 break;
1583 default:
1584 data += 1;
1585 len -= 1;
1586 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1587 data, len);
1588 break;
1688 } 1589 }
1689 data += 1;
1690 len -= 1;
1691 memcpy(&sd->tmpbuf[sd->buflen], data, len);
1692 sd->buflen += len;
1693} 1590}
1694 1591
1695static void setbrightness(struct gspca_dev *gspca_dev) 1592static void setbrightness(struct gspca_dev *gspca_dev)
@@ -1745,15 +1642,14 @@ static const struct sd_desc sd_desc = {
1745}; 1642};
1746 1643
1747/* -- module initialisation -- */ 1644/* -- module initialisation -- */
1748#define DVNM(name) .driver_info = (kernel_ulong_t) name
1749static const __devinitdata struct usb_device_id device_table[] = { 1645static const __devinitdata struct usb_device_id device_table[] = {
1750 {USB_DEVICE(0x0130, 0x0130), DVNM("Clone Digital Webcam 11043")}, 1646 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam},
1751 {USB_DEVICE(0x041e, 0x4018), DVNM("Creative Webcam Vista (PD1100)")}, 1647 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista},
1752 {USB_DEVICE(0x0461, 0x0815), DVNM("Micro Innovation IC200")}, 1648 {USB_DEVICE(0x0461, 0x0815), .driver_info = MicroInnovationIC200},
1753 {USB_DEVICE(0x0733, 0x0110), DVNM("ViewQuest VQ110")}, 1649 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
1754 {USB_DEVICE(0x0af9, 0x0010), DVNM("Hama USB Sightcam 100")}, 1650 {USB_DEVICE(0x0af9, 0x0010), .driver_info = HamaUSBSightcam},
1755 {USB_DEVICE(0x0af9, 0x0011), DVNM("Hama USB Sightcam 100")}, 1651 {USB_DEVICE(0x0af9, 0x0011), .driver_info = HamaUSBSightcam2},
1756 {USB_DEVICE(0x8086, 0x0110), DVNM("Intel Easy PC Camera")}, 1652 {USB_DEVICE(0x8086, 0x0110), .driver_info = IntelEasyPCCamera},
1757 {} 1653 {}
1758}; 1654};
1759MODULE_DEVICE_TABLE(usb, device_table); 1655MODULE_DEVICE_TABLE(usb, device_table);
@@ -1778,7 +1674,7 @@ static int __init sd_mod_init(void)
1778{ 1674{
1779 if (usb_register(&sd_driver) < 0) 1675 if (usb_register(&sd_driver) < 0)
1780 return -1; 1676 return -1;
1781 PDEBUG(D_PROBE, "v%s registered", version); 1677 PDEBUG(D_PROBE, "registered");
1782 return 0; 1678 return 0;
1783} 1679}
1784static void __exit sd_mod_exit(void) 1680static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index b659bd0f788d..a26174508cb9 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -582,35 +579,15 @@ static int sd_config(struct gspca_dev *gspca_dev,
582 PDEBUG(D_PROBE, "Bad vendor / product from device"); 579 PDEBUG(D_PROBE, "Bad vendor / product from device");
583 return -EINVAL; 580 return -EINVAL;
584 } 581 }
585 switch (product) { 582
586 case 0x0928:
587 case 0x0929:
588 case 0x092a:
589 case 0x092b:
590 case 0x092c:
591 case 0x092d:
592 case 0x092e:
593 case 0x092f:
594 case 0x403b:
595 sd->chip_revision = Rev012A;
596 break;
597 default:
598/* case 0x0561:
599 case 0x0815: * ?? in spca508.c
600 case 0x401a:
601 case 0x7004:
602 case 0x7e50:
603 case 0xa001:
604 case 0xcdee: */
605 sd->chip_revision = Rev072A;
606 break;
607 }
608 cam = &gspca_dev->cam; 583 cam = &gspca_dev->cam;
609 cam->dev_name = (char *) id->driver_info; 584 cam->dev_name = (char *) id->driver_info;
610 cam->epaddr = 0x01; 585 cam->epaddr = 0x01;
611 gspca_dev->nbalt = 7 + 1; /* choose alternate 7 first */ 586 gspca_dev->nbalt = 7 + 1; /* choose alternate 7 first */
612 cam->cam_mode = sif_mode; 587 cam->cam_mode = sif_mode;
613 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 588 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
589
590 sd->chip_revision = id->driver_info;
614 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 591 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
615 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 592 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
616 sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value; 593 sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value;
@@ -997,23 +974,22 @@ static const struct sd_desc sd_desc = {
997}; 974};
998 975
999/* -- module initialisation -- */ 976/* -- module initialisation -- */
1000#define DVNM(name) .driver_info = (kernel_ulong_t) name
1001static const __devinitdata struct usb_device_id device_table[] = { 977static const __devinitdata struct usb_device_id device_table[] = {
1002 {USB_DEVICE(0x041e, 0x401a), DVNM("Creative Webcam Vista (PD1100)")}, 978 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A},
1003 {USB_DEVICE(0x041e, 0x403b), DVNM("Creative Webcam Vista (VF0010)")}, 979 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A},
1004 {USB_DEVICE(0x0458, 0x7004), DVNM("Genius VideoCAM Express V2")}, 980 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A},
1005 {USB_DEVICE(0x046d, 0x0928), DVNM("Logitech QC Express Etch2")}, 981 {USB_DEVICE(0x046d, 0x0928), .driver_info = Rev012A},
1006 {USB_DEVICE(0x046d, 0x0929), DVNM("Labtec Webcam Elch2")}, 982 {USB_DEVICE(0x046d, 0x0929), .driver_info = Rev012A},
1007 {USB_DEVICE(0x046d, 0x092a), DVNM("Logitech QC for Notebook")}, 983 {USB_DEVICE(0x046d, 0x092a), .driver_info = Rev012A},
1008 {USB_DEVICE(0x046d, 0x092b), DVNM("Labtec Webcam Plus")}, 984 {USB_DEVICE(0x046d, 0x092b), .driver_info = Rev012A},
1009 {USB_DEVICE(0x046d, 0x092c), DVNM("Logitech QC chat Elch2")}, 985 {USB_DEVICE(0x046d, 0x092c), .driver_info = Rev012A},
1010 {USB_DEVICE(0x046d, 0x092d), DVNM("Logitech QC Elch2")}, 986 {USB_DEVICE(0x046d, 0x092d), .driver_info = Rev012A},
1011 {USB_DEVICE(0x046d, 0x092e), DVNM("Logitech QC Elch2")}, 987 {USB_DEVICE(0x046d, 0x092e), .driver_info = Rev012A},
1012 {USB_DEVICE(0x046d, 0x092f), DVNM("Logitech QC Elch2")}, 988 {USB_DEVICE(0x046d, 0x092f), .driver_info = Rev012A},
1013 {USB_DEVICE(0x04fc, 0x0561), DVNM("Flexcam 100")}, 989 {USB_DEVICE(0x04fc, 0x0561), .driver_info = Rev072A},
1014 {USB_DEVICE(0x060b, 0xa001), DVNM("Maxell Compact Pc PM3")}, 990 {USB_DEVICE(0x060b, 0xa001), .driver_info = Rev072A},
1015 {USB_DEVICE(0x10fd, 0x7e50), DVNM("FlyCam Usb 100")}, 991 {USB_DEVICE(0x10fd, 0x7e50), .driver_info = Rev072A},
1016 {USB_DEVICE(0xabcd, 0xcdee), DVNM("Petcam")}, 992 {USB_DEVICE(0xabcd, 0xcdee), .driver_info = Rev072A},
1017 {} 993 {}
1018}; 994};
1019 995
@@ -1039,7 +1015,7 @@ static int __init sd_mod_init(void)
1039{ 1015{
1040 if (usb_register(&sd_driver) < 0) 1016 if (usb_register(&sd_driver) < 0)
1041 return -1; 1017 return -1;
1042 PDEBUG(D_PROBE, "v%s registered", version); 1018 PDEBUG(D_PROBE, "registered");
1043 return 0; 1019 return 0;
1044} 1020}
1045static void __exit sd_mod_exit(void) 1021static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index c78ee0d3e59b..16219cf6a6d5 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -23,9 +23,6 @@
23#include "gspca.h" 23#include "gspca.h"
24#include "jpeg.h" 24#include "jpeg.h"
25 25
26#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
27static const char version[] = "2.1.7";
28
29MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 26MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
30MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); 27MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver");
31MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -299,7 +296,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
299 struct sd *sd = (struct sd *) gspca_dev; 296 struct sd *sd = (struct sd *) gspca_dev;
300 struct cam *cam = &gspca_dev->cam; 297 struct cam *cam = &gspca_dev->cam;
301 298
302 cam->dev_name = (char *) id->driver_info;
303 cam->epaddr = 0x02; 299 cam->epaddr = 0x02;
304 gspca_dev->cam.cam_mode = vga_mode; 300 gspca_dev->cam.cam_mode = vga_mode;
305 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); 301 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode);
@@ -549,9 +545,8 @@ static const struct sd_desc sd_desc = {
549}; 545};
550 546
551/* -- module initialisation -- */ 547/* -- module initialisation -- */
552#define DVNM(name) .driver_info = (kernel_ulong_t) name
553static const __devinitdata struct usb_device_id device_table[] = { 548static const __devinitdata struct usb_device_id device_table[] = {
554 {USB_DEVICE(0x05e1, 0x0893), DVNM("Syntek DV4000")}, 549 {USB_DEVICE(0x05e1, 0x0893)},
555 {} 550 {}
556}; 551};
557MODULE_DEVICE_TABLE(usb, device_table); 552MODULE_DEVICE_TABLE(usb, device_table);
@@ -576,7 +571,7 @@ static int __init sd_mod_init(void)
576{ 571{
577 if (usb_register(&sd_driver) < 0) 572 if (usb_register(&sd_driver) < 0)
578 return -1; 573 return -1;
579 info("v%s registered", version); 574 info("registered");
580 return 0; 575 return 0;
581} 576}
582static void __exit sd_mod_exit(void) 577static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index abd7bef9b3d1..54efa48bee01 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -24,9 +24,6 @@
24#include "gspca.h" 24#include "gspca.h"
25#include "jpeg.h" 25#include "jpeg.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 8)
28static const char version[] = "2.1.8";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -804,229 +801,29 @@ static int sd_config(struct gspca_dev *gspca_dev,
804 struct sd *sd = (struct sd *) gspca_dev; 801 struct sd *sd = (struct sd *) gspca_dev;
805 struct usb_device *dev = gspca_dev->dev; 802 struct usb_device *dev = gspca_dev->dev;
806 struct cam *cam; 803 struct cam *cam;
807 __u16 vendor; 804
808 __u16 product; 805 cam = &gspca_dev->cam;
809 __u8 fw; 806 cam->epaddr = 0x01;
810 807
811 vendor = id->idVendor; 808 sd->bridge = id->driver_info >> 8;
812 product = id->idProduct; 809 sd->subtype = id->driver_info;
813 switch (vendor) { 810
814 case 0x041e: /* Creative cameras */ 811 if (sd->subtype == AiptekMiniPenCam13) {
815/* switch (product) { */
816/* case 0x400b: */
817/* case 0x4012: */
818/* case 0x4013: */
819/* sd->bridge = BRIDGE_SPCA504C; */
820/* break; */
821/* } */
822 break;
823 case 0x0458: /* Genius KYE cameras */
824/* switch (product) { */
825/* case 0x7006: */
826 sd->bridge = BRIDGE_SPCA504B;
827/* break; */
828/* } */
829 break;
830 case 0x0461: /* MicroInnovation */
831/* switch (product) { */
832/* case 0x0821: */
833 sd->bridge = BRIDGE_SPCA533;
834/* break; */
835/* } */
836 break;
837 case 0x046d: /* Logitech Labtec */
838 switch (product) {
839 case 0x0905:
840 sd->subtype = LogitechClickSmart820;
841 sd->bridge = BRIDGE_SPCA533;
842 break;
843 case 0x0960:
844 sd->subtype = LogitechClickSmart420;
845 sd->bridge = BRIDGE_SPCA504C;
846 break;
847 }
848 break;
849 case 0x0471: /* Philips */
850/* switch (product) { */
851/* case 0x0322: */
852 sd->bridge = BRIDGE_SPCA504B;
853/* break; */
854/* } */
855 break;
856 case 0x04a5: /* Benq */
857 switch (product) {
858 case 0x3003:
859 sd->bridge = BRIDGE_SPCA504B;
860 break;
861 case 0x3008:
862 case 0x300a:
863 sd->bridge = BRIDGE_SPCA533;
864 break;
865 }
866 break;
867 case 0x04f1: /* JVC */
868/* switch (product) { */
869/* case 0x1001: */
870 sd->bridge = BRIDGE_SPCA504B;
871/* break; */
872/* } */
873 break;
874 case 0x04fc: /* SunPlus */
875 switch (product) {
876 case 0x500c:
877 sd->bridge = BRIDGE_SPCA504B;
878 break;
879 case 0x504a:
880/* try to get the firmware as some cam answer 2.0.1.2.2 812/* try to get the firmware as some cam answer 2.0.1.2.2
881 * and should be a spca504b then overwrite that setting */ 813 * and should be a spca504b then overwrite that setting */
882 reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1); 814 reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1);
883 fw = gspca_dev->usb_buf[0]; 815 switch (gspca_dev->usb_buf[0]) {
884 if (fw == 1) { 816 case 1:
885 sd->subtype = AiptekMiniPenCam13; 817 break; /* (right bridge/subtype) */
886 sd->bridge = BRIDGE_SPCA504; 818 case 2:
887 } else if (fw == 2) {
888 sd->bridge = BRIDGE_SPCA504B;
889 } else
890 return -ENODEV;
891 break;
892 case 0x504b:
893 sd->bridge = BRIDGE_SPCA504B;
894 break;
895 case 0x5330:
896 sd->bridge = BRIDGE_SPCA533;
897 break;
898 case 0x5360:
899 sd->bridge = BRIDGE_SPCA536;
900 break;
901 case 0xffff:
902 sd->bridge = BRIDGE_SPCA504B;
903 break;
904 }
905 break;
906 case 0x052b: /* ?? Megapix */
907/* switch (product) { */
908/* case 0x1513: */
909 sd->subtype = MegapixV4;
910 sd->bridge = BRIDGE_SPCA533;
911/* break; */
912/* } */
913 break;
914 case 0x0546: /* Polaroid */
915 switch (product) {
916 case 0x3155:
917 sd->bridge = BRIDGE_SPCA533;
918 break;
919 case 0x3191:
920 case 0x3273:
921 sd->bridge = BRIDGE_SPCA504B;
922 break;
923 }
924 break;
925 case 0x055f: /* Mustek cameras */
926 switch (product) {
927 case 0xc211:
928 sd->bridge = BRIDGE_SPCA536;
929 break;
930 case 0xc230:
931 case 0xc232:
932 sd->bridge = BRIDGE_SPCA533;
933 break;
934 case 0xc360:
935 sd->bridge = BRIDGE_SPCA536;
936 break;
937 case 0xc420:
938 sd->bridge = BRIDGE_SPCA504;
939 break;
940 case 0xc430:
941 case 0xc440:
942 sd->bridge = BRIDGE_SPCA533;
943 break;
944 case 0xc520:
945 sd->bridge = BRIDGE_SPCA504;
946 break;
947 case 0xc530:
948 case 0xc540:
949 case 0xc630:
950 case 0xc650:
951 sd->bridge = BRIDGE_SPCA533;
952 break;
953 }
954 break;
955 case 0x05da: /* Digital Dream cameras */
956/* switch (product) { */
957/* case 0x1018: */
958 sd->bridge = BRIDGE_SPCA504B; 819 sd->bridge = BRIDGE_SPCA504B;
959/* break; */ 820 sd->subtype = 0;
960/* } */
961 break;
962 case 0x06d6: /* Trust */
963/* switch (product) { */
964/* case 0x0031: */
965 sd->bridge = BRIDGE_SPCA533; /* SPCA533A */
966/* break; */
967/* } */
968 break;
969 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
970 switch (product) {
971 case 0x1311:
972 case 0x1314:
973 case 0x2211:
974 case 0x2221:
975 sd->bridge = BRIDGE_SPCA533;
976 break;
977 case 0x3261:
978 case 0x3281:
979 sd->bridge = BRIDGE_SPCA536;
980 break;
981 }
982 break;
983 case 0x08ca: /* Aiptek */
984 switch (product) {
985 case 0x0104:
986 case 0x0106:
987 sd->bridge = BRIDGE_SPCA533;
988 break;
989 case 0x2008:
990 sd->bridge = BRIDGE_SPCA504B;
991 break;
992 case 0x2010:
993 sd->bridge = BRIDGE_SPCA533;
994 break;
995 case 0x2016:
996 case 0x2018:
997 sd->bridge = BRIDGE_SPCA504B;
998 break;
999 case 0x2020:
1000 case 0x2022:
1001 sd->bridge = BRIDGE_SPCA533;
1002 break;
1003 case 0x2024:
1004 sd->bridge = BRIDGE_SPCA536;
1005 break;
1006 case 0x2028:
1007 sd->bridge = BRIDGE_SPCA533;
1008 break;
1009 case 0x2040:
1010 case 0x2042:
1011 case 0x2050:
1012 case 0x2060:
1013 sd->bridge = BRIDGE_SPCA536;
1014 break; 821 break;
822 default:
823 return -ENODEV;
1015 } 824 }
1016 break;
1017 case 0x0d64: /* SunPlus */
1018/* switch (product) { */
1019/* case 0x0303: */
1020 sd->bridge = BRIDGE_SPCA536;
1021/* break; */
1022/* } */
1023 break;
1024 } 825 }
1025 826
1026 cam = &gspca_dev->cam;
1027 cam->dev_name = (char *) id->driver_info;
1028 cam->epaddr = 0x01;
1029
1030 switch (sd->bridge) { 827 switch (sd->bridge) {
1031 default: 828 default:
1032/* case BRIDGE_SPCA504B: */ 829/* case BRIDGE_SPCA504B: */
@@ -1581,65 +1378,67 @@ static const struct sd_desc sd_desc = {
1581}; 1378};
1582 1379
1583/* -- module initialisation -- */ 1380/* -- module initialisation -- */
1584#define DVNM(name) .driver_info = (kernel_ulong_t) name 1381#define BS(bridge, subtype) \
1382 .driver_info = (BRIDGE_ ## bridge << 8) \
1383 | (subtype)
1585static const __devinitdata struct usb_device_id device_table[] = { 1384static const __devinitdata struct usb_device_id device_table[] = {
1586 {USB_DEVICE(0x041e, 0x400b), DVNM("Creative PC-CAM 600")}, 1385 {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
1587 {USB_DEVICE(0x041e, 0x4012), DVNM("PC-Cam350")}, 1386 {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
1588 {USB_DEVICE(0x041e, 0x4013), DVNM("Creative Pccam750")}, 1387 {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
1589 {USB_DEVICE(0x0458, 0x7006), DVNM("Genius Dsc 1.3 Smart")}, 1388 {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)},
1590 {USB_DEVICE(0x0461, 0x0821), DVNM("Fujifilm MV-1")}, 1389 {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)},
1591 {USB_DEVICE(0x046d, 0x0905), DVNM("Logitech ClickSmart 820")}, 1390 {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)},
1592 {USB_DEVICE(0x046d, 0x0960), DVNM("Logitech ClickSmart 420")}, 1391 {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)},
1593 {USB_DEVICE(0x0471, 0x0322), DVNM("Philips DMVC1300K")}, 1392 {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)},
1594 {USB_DEVICE(0x04a5, 0x3003), DVNM("Benq DC 1300")}, 1393 {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)},
1595 {USB_DEVICE(0x04a5, 0x3008), DVNM("Benq DC 1500")}, 1394 {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)},
1596 {USB_DEVICE(0x04a5, 0x300a), DVNM("Benq DC3410")}, 1395 {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)},
1597 {USB_DEVICE(0x04f1, 0x1001), DVNM("JVC GC A50")}, 1396 {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)},
1598 {USB_DEVICE(0x04fc, 0x500c), DVNM("Sunplus CA500C")}, 1397 {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)},
1599 {USB_DEVICE(0x04fc, 0x504a), DVNM("Aiptek Mini PenCam 1.3")}, 1398 {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)},
1600 {USB_DEVICE(0x04fc, 0x504b), DVNM("Maxell MaxPocket LE 1.3")}, 1399 {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)},
1601 {USB_DEVICE(0x04fc, 0x5330), DVNM("Digitrex 2110")}, 1400 {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)},
1602 {USB_DEVICE(0x04fc, 0x5360), DVNM("Sunplus Generic")}, 1401 {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
1603 {USB_DEVICE(0x04fc, 0xffff), DVNM("Pure DigitalDakota")}, 1402 {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
1604 {USB_DEVICE(0x052b, 0x1513), DVNM("Megapix V4")}, 1403 {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
1605 {USB_DEVICE(0x0546, 0x3155), DVNM("Polaroid PDC3070")}, 1404 {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
1606 {USB_DEVICE(0x0546, 0x3191), DVNM("Polaroid Ion 80")}, 1405 {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
1607 {USB_DEVICE(0x0546, 0x3273), DVNM("Polaroid PDC2030")}, 1406 {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
1608 {USB_DEVICE(0x055f, 0xc211), DVNM("Kowa Bs888e Microcamera")}, 1407 {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)},
1609 {USB_DEVICE(0x055f, 0xc230), DVNM("Mustek Digicam 330K")}, 1408 {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)},
1610 {USB_DEVICE(0x055f, 0xc232), DVNM("Mustek MDC3500")}, 1409 {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)},
1611 {USB_DEVICE(0x055f, 0xc360), DVNM("Mustek DV4000 Mpeg4 ")}, 1410 {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)},
1612 {USB_DEVICE(0x055f, 0xc420), DVNM("Mustek gSmart Mini 2")}, 1411 {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)},
1613 {USB_DEVICE(0x055f, 0xc430), DVNM("Mustek Gsmart LCD 2")}, 1412 {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)},
1614 {USB_DEVICE(0x055f, 0xc440), DVNM("Mustek DV 3000")}, 1413 {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)},
1615 {USB_DEVICE(0x055f, 0xc520), DVNM("Mustek gSmart Mini 3")}, 1414 {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)},
1616 {USB_DEVICE(0x055f, 0xc530), DVNM("Mustek Gsmart LCD 3")}, 1415 {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)},
1617 {USB_DEVICE(0x055f, 0xc540), DVNM("Gsmart D30")}, 1416 {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)},
1618 {USB_DEVICE(0x055f, 0xc630), DVNM("Mustek MDC4000")}, 1417 {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)},
1619 {USB_DEVICE(0x055f, 0xc650), DVNM("Mustek MDC5500Z")}, 1418 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
1620 {USB_DEVICE(0x05da, 0x1018), DVNM("Digital Dream Enigma 1.3")}, 1419 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
1621 {USB_DEVICE(0x06d6, 0x0031), DVNM("Trust 610 LCD PowerC@m Zoom")}, 1420 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
1622 {USB_DEVICE(0x0733, 0x1311), DVNM("Digital Dream Epsilon 1.3")}, 1421 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
1623 {USB_DEVICE(0x0733, 0x1314), DVNM("Mercury 2.1MEG Deluxe Classic Cam")}, 1422 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
1624 {USB_DEVICE(0x0733, 0x2211), DVNM("Jenoptik jdc 21 LCD")}, 1423 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
1625 {USB_DEVICE(0x0733, 0x2221), DVNM("Mercury Digital Pro 3.1p")}, 1424 {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)},
1626 {USB_DEVICE(0x0733, 0x3261), DVNM("Concord 3045 spca536a")}, 1425 {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)},
1627 {USB_DEVICE(0x0733, 0x3281), DVNM("Cyberpix S550V")}, 1426 {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)},
1628 {USB_DEVICE(0x08ca, 0x0104), DVNM("Aiptek PocketDVII 1.3")}, 1427 {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)},
1629 {USB_DEVICE(0x08ca, 0x0106), DVNM("Aiptek Pocket DV3100+")}, 1428 {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)},
1630 {USB_DEVICE(0x08ca, 0x2008), DVNM("Aiptek Mini PenCam 2 M")}, 1429 {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)},
1631 {USB_DEVICE(0x08ca, 0x2010), DVNM("Aiptek PocketCam 3M")}, 1430 {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)},
1632 {USB_DEVICE(0x08ca, 0x2016), DVNM("Aiptek PocketCam 2 Mega")}, 1431 {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)},
1633 {USB_DEVICE(0x08ca, 0x2018), DVNM("Aiptek Pencam SD 2M")}, 1432 {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)},
1634 {USB_DEVICE(0x08ca, 0x2020), DVNM("Aiptek Slim 3000F")}, 1433 {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)},
1635 {USB_DEVICE(0x08ca, 0x2022), DVNM("Aiptek Slim 3200")}, 1434 {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)},
1636 {USB_DEVICE(0x08ca, 0x2024), DVNM("Aiptek DV3500 Mpeg4 ")}, 1435 {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)},
1637 {USB_DEVICE(0x08ca, 0x2028), DVNM("Aiptek PocketCam4M")}, 1436 {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)},
1638 {USB_DEVICE(0x08ca, 0x2040), DVNM("Aiptek PocketDV4100M")}, 1437 {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)},
1639 {USB_DEVICE(0x08ca, 0x2042), DVNM("Aiptek PocketDV5100")}, 1438 {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)},
1640 {USB_DEVICE(0x08ca, 0x2050), DVNM("Medion MD 41437")}, 1439 {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)},
1641 {USB_DEVICE(0x08ca, 0x2060), DVNM("Aiptek PocketDV5300")}, 1440 {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)},
1642 {USB_DEVICE(0x0d64, 0x0303), DVNM("Sunplus FashionCam DXG")}, 1441 {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)},
1643 {} 1442 {}
1644}; 1443};
1645MODULE_DEVICE_TABLE(usb, device_table); 1444MODULE_DEVICE_TABLE(usb, device_table);
@@ -1664,7 +1463,7 @@ static int __init sd_mod_init(void)
1664{ 1463{
1665 if (usb_register(&sd_driver) < 0) 1464 if (usb_register(&sd_driver) < 0)
1666 return -1; 1465 return -1;
1667 PDEBUG(D_PROBE, "v%s registered", version); 1466 PDEBUG(D_PROBE, "registered");
1668 return 0; 1467 return 0;
1669} 1468}
1670static void __exit sd_mod_exit(void) 1469static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 00f47e463a05..91b555c34c68 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -1,12 +1,4 @@
1/* 1/*
2 *Notes: * t613 + tas5130A
3 * * Focus to light do not balance well as in win.
4 * Quality in win is not good, but its kinda better.
5 * * Fix some "extraneous bytes", most of apps will show the image anyway
6 * * Gamma table, is there, but its really doing something?
7 * * 7~8 Fps, its ok, max on win its 10.
8 * Costantino Leandro
9 *
10 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> 2 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
11 * 3 *
12 * 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
@@ -22,16 +14,22 @@
22 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 *Notes: * t613 + tas5130A
19 * * Focus to light do not balance well as in win.
20 * Quality in win is not good, but its kinda better.
21 * * Fix some "extraneous bytes", most of apps will show the image anyway
22 * * Gamma table, is there, but its really doing something?
23 * * 7~8 Fps, its ok, max on win its 10.
24 * Costantino Leandro
25 */ 25 */
26 26
27#define MODULE_NAME "t613" 27#define MODULE_NAME "t613"
28
28#include "gspca.h" 29#include "gspca.h"
29#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
30static const char version[] = "2.1.7";
31 30
32#define MAX_GAMMA 0x10 /* 0 to 15 */ 31#define MAX_GAMMA 0x10 /* 0 to 15 */
33 32
34/* From LUVCVIEW */
35#define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3) 33#define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3)
36 34
37MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); 35MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>");
@@ -424,7 +422,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
424 struct cam *cam; 422 struct cam *cam;
425 423
426 cam = &gspca_dev->cam; 424 cam = &gspca_dev->cam;
427 cam->dev_name = (char *) id->driver_info;
428 cam->epaddr = 0x01; 425 cam->epaddr = 0x01;
429 426
430 cam->cam_mode = vga_mode_t16; 427 cam->cam_mode = vga_mode_t16;
@@ -998,9 +995,8 @@ static const struct sd_desc sd_desc = {
998}; 995};
999 996
1000/* -- module initialisation -- */ 997/* -- module initialisation -- */
1001#define DVNM(name) .driver_info = (kernel_ulong_t) name
1002static const __devinitdata struct usb_device_id device_table[] = { 998static const __devinitdata struct usb_device_id device_table[] = {
1003 {USB_DEVICE(0x17a1, 0x0128), DVNM("XPX Webcam")}, 999 {USB_DEVICE(0x17a1, 0x0128)},
1004 {} 1000 {}
1005}; 1001};
1006MODULE_DEVICE_TABLE(usb, device_table); 1002MODULE_DEVICE_TABLE(usb, device_table);
@@ -1025,7 +1021,7 @@ static int __init sd_mod_init(void)
1025{ 1021{
1026 if (usb_register(&sd_driver) < 0) 1022 if (usb_register(&sd_driver) < 0)
1027 return -1; 1023 return -1;
1028 PDEBUG(D_PROBE, "v%s registered", version); 1024 PDEBUG(D_PROBE, "registered");
1029 return 0; 1025 return 0;
1030} 1026}
1031static void __exit sd_mod_exit(void) 1027static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index 0b793899095f..1ff8ba2f7fe5 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("TV8532 USB Camera Driver"); 26MODULE_DESCRIPTION("TV8532 USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -249,7 +246,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
249 tv_8532WriteEEprom(gspca_dev); 246 tv_8532WriteEEprom(gspca_dev);
250 247
251 cam = &gspca_dev->cam; 248 cam = &gspca_dev->cam;
252 cam->dev_name = (char *) id->driver_info;
253 cam->epaddr = 1; 249 cam->epaddr = 1;
254 cam->cam_mode = sif_mode; 250 cam->cam_mode = sif_mode;
255 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 251 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
@@ -624,13 +620,12 @@ static const struct sd_desc sd_desc = {
624}; 620};
625 621
626/* -- module initialisation -- */ 622/* -- module initialisation -- */
627#define DVNM(name) .driver_info = (kernel_ulong_t) name
628static const __devinitdata struct usb_device_id device_table[] = { 623static const __devinitdata struct usb_device_id device_table[] = {
629 {USB_DEVICE(0x046d, 0x0920), DVNM("QC Express")}, 624 {USB_DEVICE(0x046d, 0x0920)},
630 {USB_DEVICE(0x046d, 0x0921), DVNM("Labtec Webcam")}, 625 {USB_DEVICE(0x046d, 0x0921)},
631 {USB_DEVICE(0x0545, 0x808b), DVNM("Veo Stingray")}, 626 {USB_DEVICE(0x0545, 0x808b)},
632 {USB_DEVICE(0x0545, 0x8333), DVNM("Veo Stingray")}, 627 {USB_DEVICE(0x0545, 0x8333)},
633 {USB_DEVICE(0x0923, 0x010f), DVNM("ICM532 cams")}, 628 {USB_DEVICE(0x0923, 0x010f)},
634 {} 629 {}
635}; 630};
636 631
@@ -656,7 +651,7 @@ static int __init sd_mod_init(void)
656{ 651{
657 if (usb_register(&sd_driver) < 0) 652 if (usb_register(&sd_driver) < 0)
658 return -1; 653 return -1;
659 PDEBUG(D_PROBE, "v%s registered", version); 654 PDEBUG(D_PROBE, "registered");
660 return 0; 655 return 0;
661} 656}
662 657
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index fcf2c9e32573..a4221753e1bf 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/VC032X USB Camera Driver"); 28MODULE_DESCRIPTION("GSPCA/VC032X USB Camera Driver");
32MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
@@ -1419,30 +1416,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
1419 struct usb_device *dev = gspca_dev->dev; 1416 struct usb_device *dev = gspca_dev->dev;
1420 struct cam *cam; 1417 struct cam *cam;
1421 int sensor; 1418 int sensor;
1422 __u16 product;
1423
1424 product = id->idProduct;
1425 sd->bridge = BRIDGE_VC0321;
1426 switch (id->idVendor) {
1427 case 0x0ac8: /* Vimicro z-star */
1428 switch (product) {
1429 case 0x0323:
1430 sd->bridge = BRIDGE_VC0323;
1431 break;
1432 }
1433 break;
1434 case 0x17ef: /* Lenovo */
1435/* switch (product) { */
1436/* case 0x4802: * Lenovo MI1310_SOC */
1437 sd->bridge = BRIDGE_VC0323;
1438/* break; */
1439/* } */
1440 break;
1441 }
1442 1419
1443 cam = &gspca_dev->cam; 1420 cam = &gspca_dev->cam;
1444 cam->dev_name = (char *) id->driver_info;
1445 cam->epaddr = 0x02; 1421 cam->epaddr = 0x02;
1422 sd->bridge = id->driver_info;
1446 if (sd->bridge == BRIDGE_VC0321) { 1423 if (sd->bridge == BRIDGE_VC0321) {
1447 cam->cam_mode = vc0321_mode; 1424 cam->cam_mode = vc0321_mode;
1448 cam->nmodes = ARRAY_SIZE(vc0321_mode); 1425 cam->nmodes = ARRAY_SIZE(vc0321_mode);
@@ -1771,16 +1748,15 @@ static const struct sd_desc sd_desc = {
1771}; 1748};
1772 1749
1773/* -- module initialisation -- */ 1750/* -- module initialisation -- */
1774#define DVNM(name) .driver_info = (kernel_ulong_t) name
1775static const __devinitdata struct usb_device_id device_table[] = { 1751static const __devinitdata struct usb_device_id device_table[] = {
1776 {USB_DEVICE(0x046d, 0x0892), DVNM("Logitech Orbicam")}, 1752 {USB_DEVICE(0x046d, 0x0892), .driver_info = BRIDGE_VC0321},
1777 {USB_DEVICE(0x046d, 0x0896), DVNM("Logitech Orbicam")}, 1753 {USB_DEVICE(0x046d, 0x0896), .driver_info = BRIDGE_VC0321},
1778 {USB_DEVICE(0x0ac8, 0x0321), DVNM("Vimicro generic vc0321")}, 1754 {USB_DEVICE(0x0ac8, 0x0321), .driver_info = BRIDGE_VC0321},
1779 {USB_DEVICE(0x0ac8, 0x0323), DVNM("Vimicro Vc0323")}, 1755 {USB_DEVICE(0x0ac8, 0x0323), .driver_info = BRIDGE_VC0323},
1780 {USB_DEVICE(0x0ac8, 0x0328), DVNM("A4Tech PK-130MG")}, 1756 {USB_DEVICE(0x0ac8, 0x0328), .driver_info = BRIDGE_VC0321},
1781 {USB_DEVICE(0x0ac8, 0xc001), DVNM("Sony embedded vimicro")}, 1757 {USB_DEVICE(0x0ac8, 0xc001), .driver_info = BRIDGE_VC0321},
1782 {USB_DEVICE(0x0ac8, 0xc002), DVNM("Sony embedded vimicro")}, 1758 {USB_DEVICE(0x0ac8, 0xc002), .driver_info = BRIDGE_VC0321},
1783 {USB_DEVICE(0x17ef, 0x4802), DVNM("Lenovo Vc0323+MI1310_SOC")}, 1759 {USB_DEVICE(0x17ef, 0x4802), .driver_info = BRIDGE_VC0323},
1784 {} 1760 {}
1785}; 1761};
1786MODULE_DEVICE_TABLE(usb, device_table); 1762MODULE_DEVICE_TABLE(usb, device_table);
@@ -1805,7 +1781,7 @@ static int __init sd_mod_init(void)
1805{ 1781{
1806 if (usb_register(&sd_driver) < 0) 1782 if (usb_register(&sd_driver) < 0)
1807 return -1; 1783 return -1;
1808 PDEBUG(D_PROBE, "v%s registered", version); 1784 PDEBUG(D_PROBE, "registered");
1809 return 0; 1785 return 0;
1810} 1786}
1811static void __exit sd_mod_exit(void) 1787static void __exit sd_mod_exit(void)
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index b761b11c5c6a..22a994ccb1d5 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -24,9 +24,6 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.7";
29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, " 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, "
31 "Serge A. Suchkov <Serge.A.S@tochka.ru>"); 28 "Serge A. Suchkov <Serge.A.S@tochka.ru>");
32MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA ZC03xx/VC3xx USB Camera Driver");
@@ -49,7 +46,7 @@ struct sd {
49 __u8 sharpness; 46 __u8 sharpness;
50 47
51 char qindex; 48 char qindex;
52 char sensor; /* Type of image sensor chip */ 49 signed char sensor; /* Type of image sensor chip */
53/* !! values used in different tables */ 50/* !! values used in different tables */
54#define SENSOR_CS2102 0 51#define SENSOR_CS2102 0
55#define SENSOR_CS2102K 1 52#define SENSOR_CS2102K 1
@@ -2205,10 +2202,10 @@ static const struct usb_action hdcs2020xb_InitialScale[] = {
2205}; 2202};
2206static const struct usb_action hdcs2020b_50HZ[] = { 2203static const struct usb_action hdcs2020b_50HZ[] = {
2207 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2204 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2208 {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */ 2205 {0xaa, 0x13, 0x0018}, /* 00,13,18,aa */
2209 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2206 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2210 {0xaa, 0x0e, 0x0005}, /* 00,0e,05,aa */ 2207 {0xaa, 0x0e, 0x0005}, /* 00,0e,05,aa */
2211 {0xaa, 0x19, 0x001f}, /* 00,19,1f,aa */ 2208 {0xaa, 0x19, 0x001f}, /* 00,19,1f,aa */
2212 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2209 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2213 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2210 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2214 {0xa0, 0x76, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,76,cc */ 2211 {0xa0, 0x76, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,76,cc */
@@ -2226,10 +2223,10 @@ static const struct usb_action hdcs2020b_50HZ[] = {
2226}; 2223};
2227static const struct usb_action hdcs2020b_60HZ[] = { 2224static const struct usb_action hdcs2020b_60HZ[] = {
2228 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2225 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2229 {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */ 2226 {0xaa, 0x13, 0x0031}, /* 00,13,31,aa */
2230 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2227 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2231 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */ 2228 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */
2232 {0xaa, 0x19, 0x00cd}, /* 00,19,cd,aa */ 2229 {0xaa, 0x19, 0x00cd}, /* 00,19,cd,aa */
2233 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2230 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2234 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2231 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2235 {0xa0, 0x62, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,62,cc */ 2232 {0xa0, 0x62, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,62,cc */
@@ -2247,10 +2244,10 @@ static const struct usb_action hdcs2020b_60HZ[] = {
2247}; 2244};
2248static const struct usb_action hdcs2020b_NoFliker[] = { 2245static const struct usb_action hdcs2020b_NoFliker[] = {
2249 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */ 2246 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* 00,19,00,cc */
2250 {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */ 2247 {0xaa, 0x13, 0x0010}, /* 00,13,10,aa */
2251 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */ 2248 {0xaa, 0x14, 0x0001}, /* 00,14,01,aa */
2252 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */ 2249 {0xaa, 0x0e, 0x0004}, /* 00,0e,04,aa */
2253 {0xaa, 0x19, 0x0000}, /* 00,19,00,aa */ 2250 {0xaa, 0x19, 0x0000}, /* 00,19,00,aa */
2254 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */ 2251 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* 01,90,00,cc */
2255 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */ 2252 {0xa0, 0x02, ZC3XX_R191_EXPOSURELIMITMID}, /* 01,91,02,cc */
2256 {0xa0, 0x70, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,70,cc */ 2253 {0xa0, 0x70, ZC3XX_R192_EXPOSURELIMITLOW}, /* 01,92,70,cc */
@@ -4102,27 +4099,27 @@ static const struct usb_action pas106b_Initial_com[] = {
4102 4099
4103static const struct usb_action pas106b_Initial[] = { /* 176x144 */ 4100static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4104/* JPEG control */ 4101/* JPEG control */
4105 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4102 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4106/* Sream and Sensor specific */ 4103/* Sream and Sensor specific */
4107 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT}, /* CMOSSensorSelect */ 4104 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT},
4108/* Picture size */ 4105/* Picture size */
4109 {0xa0, 0x00, ZC3XX_R003_FRAMEWIDTHHIGH}, /* FrameWidthHigh 00 */ 4106 {0xa0, 0x00, ZC3XX_R003_FRAMEWIDTHHIGH},
4110 {0xa0, 0xb0, ZC3XX_R004_FRAMEWIDTHLOW}, /* FrameWidthLow B0 */ 4107 {0xa0, 0xb0, ZC3XX_R004_FRAMEWIDTHLOW},
4111 {0xa0, 0x00, ZC3XX_R005_FRAMEHEIGHTHIGH}, /* FrameHeightHigh 00 */ 4108 {0xa0, 0x00, ZC3XX_R005_FRAMEHEIGHTHIGH},
4112 {0xa0, 0x90, ZC3XX_R006_FRAMEHEIGHTLOW}, /* FrameHightLow 90 */ 4109 {0xa0, 0x90, ZC3XX_R006_FRAMEHEIGHTLOW},
4113/* System */ 4110/* System */
4114 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING}, /* SystemOperating */ 4111 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
4115/* Sream and Sensor specific */ 4112/* Sream and Sensor specific */
4116 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4113 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC},
4117 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4114 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
4118/* Sensor Interface */ 4115/* Sensor Interface */
4119 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE}, /* Compatibily Mode */ 4116 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE},
4120/* Window inside sensor array */ 4117/* Window inside sensor array */
4121 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW}, /* WinXStartLow */ 4118 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW},
4122 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW}, /* FirstYLow */ 4119 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW},
4123 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW}, /* FirstxLow */ 4120 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW},
4124 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW}, /* WinHeightLow */ 4121 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW},
4125 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW}, /* WinWidthLow */ 4122 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW},
4126/* Init the sensor */ 4123/* Init the sensor */
4127 {0xaa, 0x02, 0x0004}, 4124 {0xaa, 0x02, 0x0004},
4128 {0xaa, 0x08, 0x0000}, 4125 {0xaa, 0x08, 0x0000},
@@ -4135,40 +4132,40 @@ static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4135 {0xaa, 0x14, 0x0081}, 4132 {0xaa, 0x14, 0x0081},
4136 4133
4137/* Other registors */ 4134/* Other registors */
4138 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, /* SensorCorrection */ 4135 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
4139/* Frame retreiving */ 4136/* Frame retreiving */
4140 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* AutoAdjustFPS */ 4137 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
4141/* Gains */ 4138/* Gains */
4142 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, /* DigitalGain */ 4139 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN},
4143/* Unknown */ 4140/* Unknown */
4144 {0xa0, 0x00, 0x01ad}, 4141 {0xa0, 0x00, 0x01ad},
4145/* Sharpness */ 4142/* Sharpness */
4146 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE}, /* SharpnessMode */ 4143 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
4147 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05}, /* Sharpness05 */ 4144 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
4148/* Other registors */ 4145/* Other registors */
4149 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4146 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4150/* Auto exposure and white balance */ 4147/* Auto exposure and white balance */
4151 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4148 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4152/*Dead pixels */ 4149/*Dead pixels */
4153 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4150 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4154/* EEPROM */ 4151/* EEPROM */
4155 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4152 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4156/* JPEG control */ 4153/* JPEG control */
4157 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4154 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4158 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4155 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4159 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4156 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4160/* Other registers */ 4157/* Other registers */
4161 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4158 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4162/* Auto exposure and white balance */ 4159/* Auto exposure and white balance */
4163 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4160 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4164/*Dead pixels */ 4161/*Dead pixels */
4165 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4162 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4166/* EEPROM */ 4163/* EEPROM */
4167 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4164 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4168/* JPEG control */ 4165/* JPEG control */
4169 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4166 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4170 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4167 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4171 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4168 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4172 4169
4173 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */ 4170 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */
4174 {0xa0, 0xf4, ZC3XX_R10B_RGB01}, 4171 {0xa0, 0xf4, ZC3XX_R10B_RGB01},
@@ -4180,67 +4177,67 @@ static const struct usb_action pas106b_Initial[] = { /* 176x144 */
4180 {0xa0, 0xf4, ZC3XX_R111_RGB21}, 4177 {0xa0, 0xf4, ZC3XX_R111_RGB21},
4181 {0xa0, 0x58, ZC3XX_R112_RGB22}, 4178 {0xa0, 0x58, ZC3XX_R112_RGB22},
4182/* Auto correction */ 4179/* Auto correction */
4183 {0xa0, 0x03, ZC3XX_R181_WINXSTART}, /* WinXstart */ 4180 {0xa0, 0x03, ZC3XX_R181_WINXSTART},
4184 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH}, /* WinXWidth */ 4181 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH},
4185 {0xa0, 0x16, ZC3XX_R183_WINXCENTER}, /* WinXCenter */ 4182 {0xa0, 0x16, ZC3XX_R183_WINXCENTER},
4186 {0xa0, 0x03, ZC3XX_R184_WINYSTART}, /* WinYStart */ 4183 {0xa0, 0x03, ZC3XX_R184_WINYSTART},
4187 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, /* WinYWidth */ 4184 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH},
4188 {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, /* WinYCenter */ 4185 {0xa0, 0x14, ZC3XX_R186_WINYCENTER},
4189 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4186 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE},
4190 4187
4191/* Auto exposure and white balance */ 4188/* Auto exposure and white balance */
4192 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* ExposureLimitHigh */ 4189 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},
4193 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, /* ExposureLimitMid */ 4190 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID},
4194 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW}, /* ExposureLimitLow */ 4191 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW},
4195 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* AntiFlickerHigh */ 4192 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},
4196 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* AntiFlickerLow */ 4193 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},
4197 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW}, /* AntiFlickerLow */ 4194 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW},
4198 {0xa0, 0x0c, ZC3XX_R18C_AEFREEZE}, /* AEBFreeze */ 4195 {0xa0, 0x0c, ZC3XX_R18C_AEFREEZE},
4199 {0xa0, 0x18, ZC3XX_R18F_AEUNFREEZE}, /* AEBUnfreeze */ 4196 {0xa0, 0x18, ZC3XX_R18F_AEUNFREEZE},
4200/* sensor on */ 4197/* sensor on */
4201 {0xaa, 0x07, 0x00b1}, 4198 {0xaa, 0x07, 0x00b1},
4202 {0xaa, 0x05, 0x0003}, 4199 {0xaa, 0x05, 0x0003},
4203 {0xaa, 0x04, 0x0001}, 4200 {0xaa, 0x04, 0x0001},
4204 {0xaa, 0x03, 0x003b}, 4201 {0xaa, 0x03, 0x003b},
4205/* Gains */ 4202/* Gains */
4206 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF}, /* DigitalLimitDiff */ 4203 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF},
4207 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP}, /* DigitalGainStep */ 4204 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP},
4208 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4205 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN},
4209 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4206 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN},
4210/* Auto correction */ 4207/* Auto correction */
4211 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4208 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE},
4212 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */ 4209 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */
4213 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4210 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE},
4214/* Gains */ 4211/* Gains */
4215 {0xa0, 0x40, ZC3XX_R116_RGAIN}, /* RGain */ 4212 {0xa0, 0x40, ZC3XX_R116_RGAIN},
4216 {0xa0, 0x40, ZC3XX_R117_GGAIN}, /* GGain */ 4213 {0xa0, 0x40, ZC3XX_R117_GGAIN},
4217 {0xa0, 0x40, ZC3XX_R118_BGAIN}, /* BGain */ 4214 {0xa0, 0x40, ZC3XX_R118_BGAIN},
4218 {} 4215 {}
4219}; 4216};
4220 4217
4221static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */ 4218static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4222/* JPEG control */ 4219/* JPEG control */
4223 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4220 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4224/* Sream and Sensor specific */ 4221/* Sream and Sensor specific */
4225 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT}, /* CMOSSensorSelect */ 4222 {0xa0, 0x0f, ZC3XX_R010_CMOSSENSORSELECT},
4226/* Picture size */ 4223/* Picture size */
4227 {0xa0, 0x01, ZC3XX_R003_FRAMEWIDTHHIGH}, /* FrameWidthHigh */ 4224 {0xa0, 0x01, ZC3XX_R003_FRAMEWIDTHHIGH},
4228 {0xa0, 0x60, ZC3XX_R004_FRAMEWIDTHLOW}, /* FrameWidthLow */ 4225 {0xa0, 0x60, ZC3XX_R004_FRAMEWIDTHLOW},
4229 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, /* FrameHeightHigh */ 4226 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},
4230 {0xa0, 0x20, ZC3XX_R006_FRAMEHEIGHTLOW}, /* FrameHightLow */ 4227 {0xa0, 0x20, ZC3XX_R006_FRAMEHEIGHTLOW},
4231/* System */ 4228/* System */
4232 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING}, /* SystemOperating */ 4229 {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
4233/* Sream and Sensor specific */ 4230/* Sream and Sensor specific */
4234 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4231 {0xa0, 0x03, ZC3XX_R012_VIDEOCONTROLFUNC},
4235 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC}, /* VideoControlFunction */ 4232 {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
4236/* Sensor Interface */ 4233/* Sensor Interface */
4237 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE}, /* Compatibily Mode */ 4234 {0xa0, 0x08, ZC3XX_R08D_COMPABILITYMODE},
4238/* Window inside sensor array */ 4235/* Window inside sensor array */
4239 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW}, /* WinXStartLow */ 4236 {0xa0, 0x03, ZC3XX_R09A_WINXSTARTLOW},
4240 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW}, /* FirstYLow */ 4237 {0xa0, 0x00, ZC3XX_R11A_FIRSTYLOW},
4241 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW}, /* FirstxLow */ 4238 {0xa0, 0x03, ZC3XX_R11C_FIRSTXLOW},
4242 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW}, /* WinHeightLow */ 4239 {0xa0, 0x28, ZC3XX_R09C_WINHEIGHTLOW},
4243 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW}, /* WinWidthLow */ 4240 {0xa0, 0x68, ZC3XX_R09E_WINWIDTHLOW},
4244/* Init the sensor */ 4241/* Init the sensor */
4245 {0xaa, 0x02, 0x0004}, 4242 {0xaa, 0x02, 0x0004},
4246 {0xaa, 0x08, 0x0000}, 4243 {0xaa, 0x08, 0x0000},
@@ -4253,41 +4250,41 @@ static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4253 {0xaa, 0x14, 0x0081}, 4250 {0xaa, 0x14, 0x0081},
4254 4251
4255/* Other registors */ 4252/* Other registors */
4256 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION}, /* SensorCorrection */ 4253 {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
4257/* Frame retreiving */ 4254/* Frame retreiving */
4258 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS}, /* AutoAdjustFPS */ 4255 {0xa0, 0x00, ZC3XX_R019_AUTOADJUSTFPS},
4259/* Gains */ 4256/* Gains */
4260 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN}, /* DigitalGain */ 4257 {0xa0, 0xa0, ZC3XX_R1A8_DIGITALGAIN},
4261/* Unknown */ 4258/* Unknown */
4262 {0xa0, 0x00, 0x01ad}, 4259 {0xa0, 0x00, 0x01ad},
4263/* Sharpness */ 4260/* Sharpness */
4264 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE}, /* SharpnessMode */ 4261 {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
4265 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05}, /* Sharpness05 */ 4262 {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
4266/* Other registors */ 4263/* Other registors */
4267 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4264 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4268/* Auto exposure and white balance */ 4265/* Auto exposure and white balance */
4269 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4266 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4270 {0xa0, 0x80, ZC3XX_R18D_YTARGET}, /* ????????? */ 4267 {0xa0, 0x80, ZC3XX_R18D_YTARGET},
4271/*Dead pixels */ 4268/*Dead pixels */
4272 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4269 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4273/* EEPROM */ 4270/* EEPROM */
4274 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4271 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4275/* JPEG control */ 4272/* JPEG control */
4276 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4273 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4277 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4274 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4278 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4275 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4279/* Other registers */ 4276/* Other registers */
4280 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE}, /* OperationMode */ 4277 {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
4281/* Auto exposure and white balance */ 4278/* Auto exposure and white balance */
4282 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS}, /* AWBStatus */ 4279 {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
4283/*Dead pixels */ 4280/*Dead pixels */
4284 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE}, /* DeadPixelsMode */ 4281 {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
4285/* EEPROM */ 4282/* EEPROM */
4286 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS}, /* EEPROMAccess */ 4283 {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
4287/* JPEG control */ 4284/* JPEG control */
4288 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* ClockSetting */ 4285 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4289 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4286 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4290 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05}, /* sharpness- */ 4287 {0xa0, 0x0f, ZC3XX_R1CB_SHARPNESS05},
4291 4288
4292 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */ 4289 {0xa0, 0x58, ZC3XX_R10A_RGB00}, /* matrix */
4293 {0xa0, 0xf4, ZC3XX_R10B_RGB01}, 4290 {0xa0, 0xf4, ZC3XX_R10B_RGB01},
@@ -4299,43 +4296,43 @@ static const struct usb_action pas106b_InitialScale[] = { /* 352x288 */
4299 {0xa0, 0xf4, ZC3XX_R111_RGB21}, 4296 {0xa0, 0xf4, ZC3XX_R111_RGB21},
4300 {0xa0, 0x58, ZC3XX_R112_RGB22}, 4297 {0xa0, 0x58, ZC3XX_R112_RGB22},
4301/* Auto correction */ 4298/* Auto correction */
4302 {0xa0, 0x03, ZC3XX_R181_WINXSTART}, /* WinXstart */ 4299 {0xa0, 0x03, ZC3XX_R181_WINXSTART},
4303 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH}, /* WinXWidth */ 4300 {0xa0, 0x08, ZC3XX_R182_WINXWIDTH},
4304 {0xa0, 0x16, ZC3XX_R183_WINXCENTER}, /* WinXCenter */ 4301 {0xa0, 0x16, ZC3XX_R183_WINXCENTER},
4305 {0xa0, 0x03, ZC3XX_R184_WINYSTART}, /* WinYStart */ 4302 {0xa0, 0x03, ZC3XX_R184_WINYSTART},
4306 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH}, /* WinYWidth */ 4303 {0xa0, 0x05, ZC3XX_R185_WINYWIDTH},
4307 {0xa0, 0x14, ZC3XX_R186_WINYCENTER}, /* WinYCenter */ 4304 {0xa0, 0x14, ZC3XX_R186_WINYCENTER},
4308 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4305 {0xa0, 0x00, ZC3XX_R180_AUTOCORRECTENABLE},
4309 4306
4310/* Auto exposure and white balance */ 4307/* Auto exposure and white balance */
4311 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH}, /* ExposureLimitHigh 0 */ 4308 {0xa0, 0x00, ZC3XX_R190_EXPOSURELIMITHIGH},
4312 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID}, /* ExposureLimitMid */ 4309 {0xa0, 0x03, ZC3XX_R191_EXPOSURELIMITMID},
4313 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW}, /* ExposureLimitLow 0xb1 */ 4310 {0xa0, 0xb1, ZC3XX_R192_EXPOSURELIMITLOW},
4314 4311
4315 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH}, /* AntiFlickerHigh 0x00 */ 4312 {0xa0, 0x00, ZC3XX_R195_ANTIFLICKERHIGH},
4316 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID}, /* AntiFlickerLow 0x00 */ 4313 {0xa0, 0x00, ZC3XX_R196_ANTIFLICKERMID},
4317 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW}, /* AntiFlickerLow 0x87 */ 4314 {0xa0, 0x87, ZC3XX_R197_ANTIFLICKERLOW},
4318 4315
4319 {0xa0, 0x10, ZC3XX_R18C_AEFREEZE}, /* AEBFreeze 0x10 0x0c */ 4316 {0xa0, 0x10, ZC3XX_R18C_AEFREEZE},
4320 {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE}, /* AEBUnfreeze 0x30 0x18 */ 4317 {0xa0, 0x20, ZC3XX_R18F_AEUNFREEZE},
4321/* sensor on */ 4318/* sensor on */
4322 {0xaa, 0x07, 0x00b1}, 4319 {0xaa, 0x07, 0x00b1},
4323 {0xaa, 0x05, 0x0003}, 4320 {0xaa, 0x05, 0x0003},
4324 {0xaa, 0x04, 0x0001}, 4321 {0xaa, 0x04, 0x0001},
4325 {0xaa, 0x03, 0x003b}, 4322 {0xaa, 0x03, 0x003b},
4326/* Gains */ 4323/* Gains */
4327 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF}, /* DigitalLimitDiff */ 4324 {0xa0, 0x20, ZC3XX_R1A9_DIGITALLIMITDIFF},
4328 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP}, /* DigitalGainStep */ 4325 {0xa0, 0x26, ZC3XX_R1AA_DIGITALGAINSTEP},
4329 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4326 {0xa0, 0xa0, ZC3XX_R11D_GLOBALGAIN},
4330 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN}, /* GlobalGain */ 4327 {0xa0, 0x60, ZC3XX_R11D_GLOBALGAIN},
4331/* Auto correction */ 4328/* Auto correction */
4332 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4329 {0xa0, 0x40, ZC3XX_R180_AUTOCORRECTENABLE},
4333 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */ 4330 {0xa1, 0x01, 0x0180}, /* AutoCorrectEnable */
4334 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE}, /* AutoCorrectEnable */ 4331 {0xa0, 0x42, ZC3XX_R180_AUTOCORRECTENABLE},
4335/* Gains */ 4332/* Gains */
4336 {0xa0, 0x40, ZC3XX_R116_RGAIN}, /* RGain */ 4333 {0xa0, 0x40, ZC3XX_R116_RGAIN},
4337 {0xa0, 0x40, ZC3XX_R117_GGAIN}, /* GGain */ 4334 {0xa0, 0x40, ZC3XX_R117_GGAIN},
4338 {0xa0, 0x40, ZC3XX_R118_BGAIN}, /* BGain */ 4335 {0xa0, 0x40, ZC3XX_R118_BGAIN},
4339 4336
4340 {0xa0, 0x00, 0x0007}, /* AutoCorrectEnable */ 4337 {0xa0, 0x00, 0x0007}, /* AutoCorrectEnable */
4341 {0xa0, 0xff, ZC3XX_R018_FRAMELOST}, /* Frame adjust */ 4338 {0xa0, 0xff, ZC3XX_R018_FRAMELOST}, /* Frame adjust */
@@ -4459,8 +4456,8 @@ static const struct usb_action pb03303x_Initial[] = {
4459 {0xa0, 0x50, ZC3XX_R112_RGB22}, 4456 {0xa0, 0x50, ZC3XX_R112_RGB22},
4460 4457
4461 {0xa1, 0x01, 0x0008}, 4458 {0xa1, 0x01, 0x0008},
4462 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, /* clock ? */ 4459 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4463 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00}, /* sharpness+ */ 4460 {0xa0, 0x08, ZC3XX_R1C6_SHARPNESS00},
4464 {0xa1, 0x01, 0x01c8}, 4461 {0xa1, 0x01, 0x01c8},
4465 {0xa1, 0x01, 0x01c9}, 4462 {0xa1, 0x01, 0x01c9},
4466 {0xa1, 0x01, 0x01ca}, 4463 {0xa1, 0x01, 0x01ca},
@@ -5984,7 +5981,7 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
5984 {0xaa, 0x1b, 0x0000}, /* 00,1b,00,aa, */ 5981 {0xaa, 0x1b, 0x0000}, /* 00,1b,00,aa, */
5985 {0xaa, 0x13, 0x0002}, /* 00,13,02,aa, */ 5982 {0xaa, 0x13, 0x0002}, /* 00,13,02,aa, */
5986 {0xaa, 0x15, 0x0004}, /* 00,15,04,aa */ 5983 {0xaa, 0x15, 0x0004}, /* 00,15,04,aa */
5987 {0xaa, 0x01, 0x0000}, 5984/*?? {0xaa, 0x01, 0x0000}, */
5988 {0xaa, 0x01, 0x0000}, 5985 {0xaa, 0x01, 0x0000},
5989 {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa, */ 5986 {0xaa, 0x1a, 0x0000}, /* 00,1a,00,aa, */
5990 {0xaa, 0x1c, 0x0017}, /* 00,1c,17,aa, */ 5987 {0xaa, 0x1c, 0x0017}, /* 00,1c,17,aa, */
@@ -6000,8 +5997,8 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
6000 {0xaa, 0x0f, 0x00a0}, /* 00,0f,a0,aa, */ 5997 {0xaa, 0x0f, 0x00a0}, /* 00,0f,a0,aa, */
6001 {0xaa, 0x10, 0x0000}, /* 00,10,00,aa, */ 5998 {0xaa, 0x10, 0x0000}, /* 00,10,00,aa, */
6002 {0xaa, 0x11, 0x00a0}, /* 00,11,a0,aa, */ 5999 {0xaa, 0x11, 0x00a0}, /* 00,11,a0,aa, */
6003 {0xa0, 0x00, 0x0039}, 6000/*?? {0xa0, 0x00, 0x0039},
6004 {0xa1, 0x01, 0x0037}, 6001 {0xa1, 0x01, 0x0037}, */
6005 {0xaa, 0x16, 0x0001}, /* 00,16,01,aa, */ 6002 {0xaa, 0x16, 0x0001}, /* 00,16,01,aa, */
6006 {0xaa, 0x17, 0x00e8}, /* 00,17,e6,aa, (e6 -> e8) */ 6003 {0xaa, 0x17, 0x00e8}, /* 00,17,e6,aa, (e6 -> e8) */
6007 {0xaa, 0x18, 0x0002}, /* 00,18,02,aa, */ 6004 {0xaa, 0x18, 0x0002}, /* 00,18,02,aa, */
@@ -6272,7 +6269,7 @@ static void reg_w(struct usb_device *dev,
6272 __u8 value, 6269 __u8 value,
6273 __u16 index) 6270 __u16 index)
6274{ 6271{
6275 PDEBUG(D_USBO, "reg w %02x -> [%04x]", value, index); 6272 PDEBUG(D_USBO, "reg w [%04x] = %02x", index, value);
6276 reg_w_i(dev, value, index); 6273 reg_w_i(dev, value, index);
6277} 6274}
6278 6275
@@ -6280,17 +6277,17 @@ static __u16 i2c_read(struct gspca_dev *gspca_dev,
6280 __u8 reg) 6277 __u8 reg)
6281{ 6278{
6282 __u8 retbyte; 6279 __u8 retbyte;
6283 __u8 retval[2]; 6280 __u16 retval;
6284 6281
6285 reg_w_i(gspca_dev->dev, reg, 0x92); 6282 reg_w_i(gspca_dev->dev, reg, 0x92);
6286 reg_w_i(gspca_dev->dev, 0x02, 0x90); /* <- read command */ 6283 reg_w_i(gspca_dev->dev, 0x02, 0x90); /* <- read command */
6287 msleep(25); 6284 msleep(25);
6288 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 6285 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
6289 retval[0] = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */ 6286 retval = reg_r_i(gspca_dev, 0x0095); /* read Lowbyte */
6290 retval[1] = reg_r_i(gspca_dev, 0x0096); /* read Hightbyte */ 6287 retval |= reg_r_i(gspca_dev, 0x0096) << 8; /* read Hightbyte */
6291 PDEBUG(D_USBO, "i2c r [%02x] -> (%02x) %02x%02x", 6288 PDEBUG(D_USBO, "i2c r [%02x] -> %04x (%02x)",
6292 reg, retbyte, retval[1], retval[0]); 6289 reg, retval, retbyte);
6293 return (retval[1] << 8) | retval[0]; 6290 return retval;
6294} 6291}
6295 6292
6296static __u8 i2c_write(struct gspca_dev *gspca_dev, 6293static __u8 i2c_write(struct gspca_dev *gspca_dev,
@@ -6306,7 +6303,7 @@ static __u8 i2c_write(struct gspca_dev *gspca_dev,
6306 reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */ 6303 reg_w_i(gspca_dev->dev, 0x01, 0x90); /* <- write command */
6307 msleep(5); 6304 msleep(5);
6308 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */ 6305 retbyte = reg_r_i(gspca_dev, 0x0091); /* read status */
6309 PDEBUG(D_USBO, "i2c w [%02x] %02x%02x (%02x)", 6306 PDEBUG(D_USBO, "i2c w [%02x] = %02x%02x (%02x)",
6310 reg, valH, valL, retbyte); 6307 reg, valH, valL, retbyte);
6311 return retbyte; 6308 return retbyte;
6312} 6309}
@@ -6349,6 +6346,8 @@ static void setmatrix(struct gspca_dev *gspca_dev)
6349 {0x58, 0xf4, 0xf4, 0xf4, 0x58, 0xf4, 0xf4, 0xf4, 0x58}; 6346 {0x58, 0xf4, 0xf4, 0xf4, 0x58, 0xf4, 0xf4, 0xf4, 0x58};
6350 static const __u8 po2030_matrix[9] = 6347 static const __u8 po2030_matrix[9] =
6351 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60}; 6348 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60};
6349 static const __u8 vf0250_matrix[9] =
6350 {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b};
6352 6351
6353 switch (sd->sensor) { 6352 switch (sd->sensor) {
6354 case SENSOR_GC0305: 6353 case SENSOR_GC0305:
@@ -6363,8 +6362,9 @@ static void setmatrix(struct gspca_dev *gspca_dev)
6363 case SENSOR_PO2030: 6362 case SENSOR_PO2030:
6364 matrix = po2030_matrix; 6363 matrix = po2030_matrix;
6365 break; 6364 break;
6366 case SENSOR_TAS5130C_VF0250: /* no matrix? */ 6365 case SENSOR_TAS5130C_VF0250:
6367 return; 6366 matrix = vf0250_matrix;
6367 break;
6368 default: /* matrix already loaded */ 6368 default: /* matrix already loaded */
6369 return; 6369 return;
6370 } 6370 }
@@ -6744,7 +6744,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6744 return 0x04; /* CS2102 */ 6744 return 0x04; /* CS2102 */
6745 6745
6746 start_2wr_probe(dev, 0x06); /* OmniVision */ 6746 start_2wr_probe(dev, 0x06); /* OmniVision */
6747 reg_w(dev, 0x08, 0x8d); 6747 reg_w(dev, 0x08, 0x008d);
6748 i2c_write(gspca_dev, 0x11, 0xaa, 0x00); 6748 i2c_write(gspca_dev, 0x11, 0xaa, 0x00);
6749 retbyte = i2c_read(gspca_dev, 0x11); 6749 retbyte = i2c_read(gspca_dev, 0x11);
6750 if (retbyte != 0) { 6750 if (retbyte != 0) {
@@ -6778,7 +6778,7 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
6778 return 0x0c; /* ICM105A */ 6778 return 0x0c; /* ICM105A */
6779 6779
6780 start_2wr_probe(dev, 0x0e); /* PAS202BCB */ 6780 start_2wr_probe(dev, 0x0e); /* PAS202BCB */
6781 reg_w(dev, 0x08, 0x8d); 6781 reg_w(dev, 0x08, 0x008d);
6782 i2c_write(gspca_dev, 0x03, 0xaa, 0x00); 6782 i2c_write(gspca_dev, 0x03, 0xaa, 0x00);
6783 msleep(500); 6783 msleep(500);
6784 retbyte = i2c_read(gspca_dev, 0x03); 6784 retbyte = i2c_read(gspca_dev, 0x03);
@@ -6830,7 +6830,6 @@ static const struct sensor_by_chipset_revision chipset_revision_sensor[] = {
6830 {0x8001, 0x13}, 6830 {0x8001, 0x13},
6831 {0x8000, 0x14}, /* CS2102K */ 6831 {0x8000, 0x14}, /* CS2102K */
6832 {0x8400, 0x15}, /* TAS5130K */ 6832 {0x8400, 0x15}, /* TAS5130K */
6833 {0, 0}
6834}; 6833};
6835 6834
6836static int vga_3wr_probe(struct gspca_dev *gspca_dev) 6835static int vga_3wr_probe(struct gspca_dev *gspca_dev)
@@ -6843,7 +6842,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6843 6842
6844/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/ 6843/*fixme: lack of 8b=b3 (11,12)-> 10, 8b=e0 (14,15,16)-> 12 found in gspcav1*/
6845 reg_w(dev, 0x02, 0x0010); 6844 reg_w(dev, 0x02, 0x0010);
6846 reg_r(gspca_dev, 0x10); 6845 reg_r(gspca_dev, 0x0010);
6847 reg_w(dev, 0x01, 0x0000); 6846 reg_w(dev, 0x01, 0x0000);
6848 reg_w(dev, 0x00, 0x0010); 6847 reg_w(dev, 0x00, 0x0010);
6849 reg_w(dev, 0x01, 0x0001); 6848 reg_w(dev, 0x01, 0x0001);
@@ -6869,17 +6868,15 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6869 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword); 6868 PDEBUG(D_PROBE, "probe 3wr vga 1 0x%04x", checkword);
6870 reg_r(gspca_dev, 0x0010); 6869 reg_r(gspca_dev, 0x0010);
6871 /* this is tested only once anyway */ 6870 /* this is tested only once anyway */
6872 i = 0; 6871 for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
6873 while (chipset_revision_sensor[i].revision) {
6874 if (chipset_revision_sensor[i].revision == checkword) { 6872 if (chipset_revision_sensor[i].revision == checkword) {
6875 sd->chip_revision = checkword; 6873 sd->chip_revision = checkword;
6876 send_unknown(dev, SENSOR_PB0330); 6874 send_unknown(dev, SENSOR_PB0330);
6877 return chipset_revision_sensor[i].internal_sensor_id; 6875 return chipset_revision_sensor[i].internal_sensor_id;
6878 } 6876 }
6879 i++;
6880 } 6877 }
6881 6878
6882 reg_w(dev, 0x01, 0x0000); 6879 reg_w(dev, 0x01, 0x0000); /* check ?? */
6883 reg_w(dev, 0x01, 0x0001); 6880 reg_w(dev, 0x01, 0x0001);
6884 reg_w(dev, 0xdd, 0x008b); 6881 reg_w(dev, 0xdd, 0x008b);
6885 reg_w(dev, 0x0a, 0x0010); 6882 reg_w(dev, 0x0a, 0x0010);
@@ -6901,8 +6898,11 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6901 retbyte = i2c_read(gspca_dev, 0x00); 6898 retbyte = i2c_read(gspca_dev, 0x00);
6902 if (retbyte != 0) { 6899 if (retbyte != 0) {
6903 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte); 6900 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retbyte);
6904 send_unknown(dev, SENSOR_GC0305); 6901 if (retbyte == 0x11) /* VF0250 */
6905 return retbyte; /* 0x29 = gc0305 - should continue? */ 6902 return 0x0250;
6903 if (retbyte == 0x29) /* gc0305 */
6904 send_unknown(dev, SENSOR_GC0305);
6905 return retbyte;
6906 } 6906 }
6907 6907
6908 reg_w(dev, 0x01, 0x0000); /* check OmniVision */ 6908 reg_w(dev, 0x01, 0x0000); /* check OmniVision */
@@ -6918,18 +6918,18 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6918 return 0x06; /* OmniVision confirm ? */ 6918 return 0x06; /* OmniVision confirm ? */
6919 } 6919 }
6920 6920
6921 reg_w(dev, 0x01, 0x00); 6921 reg_w(dev, 0x01, 0x0000);
6922 reg_w(dev, 0x00, 0x02); 6922 reg_w(dev, 0x00, 0x0002);
6923 reg_w(dev, 0x01, 0x10); 6923 reg_w(dev, 0x01, 0x0010);
6924 reg_w(dev, 0x01, 0x01); 6924 reg_w(dev, 0x01, 0x0001);
6925 reg_w(dev, 0xee, 0x8b); 6925 reg_w(dev, 0xee, 0x008b);
6926 reg_w(dev, 0x03, 0x12); 6926 reg_w(dev, 0x03, 0x0012);
6927/* msleep(150); */ 6927/* msleep(150); */
6928 reg_w(dev, 0x01, 0x12); 6928 reg_w(dev, 0x01, 0x0012);
6929 reg_w(dev, 0x05, 0x12); 6929 reg_w(dev, 0x05, 0x0012);
6930 retbyte = i2c_read(gspca_dev, 0x00); /* ID 0 */ 6930 retbyte = i2c_read(gspca_dev, 0x0000); /* ID 0 */
6931 checkword = retbyte << 8; 6931 checkword = retbyte << 8;
6932 retbyte = i2c_read(gspca_dev, 0x01); /* ID 1 */ 6932 retbyte = i2c_read(gspca_dev, 0x0001); /* ID 1 */
6933 checkword |= retbyte; 6933 checkword |= retbyte;
6934 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword); 6934 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", checkword);
6935 if (checkword == 0x2030) { 6935 if (checkword == 0x2030) {
@@ -6939,14 +6939,14 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6939 return checkword; 6939 return checkword;
6940 } 6940 }
6941 6941
6942 reg_w(dev, 0x01, 0x00); 6942 reg_w(dev, 0x01, 0x0000);
6943 reg_w(dev, 0x0a, 0x10); 6943 reg_w(dev, 0x0a, 0x0010);
6944 reg_w(dev, 0xd3, 0x8b); 6944 reg_w(dev, 0xd3, 0x008b);
6945 reg_w(dev, 0x01, 0x01); 6945 reg_w(dev, 0x01, 0x0001);
6946 reg_w(dev, 0x03, 0x12); 6946 reg_w(dev, 0x03, 0x0012);
6947 reg_w(dev, 0x01, 0x12); 6947 reg_w(dev, 0x01, 0x0012);
6948 reg_w(dev, 0x05, 0x01); 6948 reg_w(dev, 0x05, 0x0001);
6949 reg_w(dev, 0xd3, 0x8b); 6949 reg_w(dev, 0xd3, 0x008b);
6950 retbyte = i2c_read(gspca_dev, 0x01); 6950 retbyte = i2c_read(gspca_dev, 0x01);
6951 if (retbyte != 0) { 6951 if (retbyte != 0) {
6952 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?"); 6952 PDEBUG(D_PROBE, "probe 3wr vga type 0a ?");
@@ -6962,7 +6962,9 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev)
6962 6962
6963 switch (sd->sensor) { 6963 switch (sd->sensor) {
6964 case SENSOR_MC501CB: 6964 case SENSOR_MC501CB:
6965 return -1; /* don't probe */
6965 case SENSOR_TAS5130C_VF0250: 6966 case SENSOR_TAS5130C_VF0250:
6967 /* may probe but with write in reg 0x0010 */
6966 return -1; /* don't probe */ 6968 return -1; /* don't probe */
6967 } 6969 }
6968 sensor = vga_2wr_probe(gspca_dev); 6970 sensor = vga_2wr_probe(gspca_dev);
@@ -7010,30 +7012,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
7010 7012
7011 /* define some sensors from the vendor/product */ 7013 /* define some sensors from the vendor/product */
7012 sd->sharpness = 2; 7014 sd->sharpness = 2;
7013 switch (id->idVendor) { 7015 sd->sensor = id->driver_info;
7014 case 0x041e: /* Creative */
7015 switch (id->idProduct) {
7016 case 0x4051: /* zc301 chips */
7017 case 0x4053:
7018 sd->sensor = SENSOR_TAS5130C_VF0250;
7019 break;
7020 }
7021 break;
7022 case 0x046d: /* Logitech Labtec */
7023 switch (id->idProduct) {
7024 case 0x08dd:
7025 sd->sensor = SENSOR_MC501CB;
7026 break;
7027 }
7028 break;
7029 case 0x0ac8: /* Vimicro z-star */
7030 switch (id->idProduct) {
7031 case 0x305b:
7032 sd->sensor = SENSOR_TAS5130C_VF0250;
7033 break;
7034 }
7035 break;
7036 }
7037 sensor = zcxx_probeSensor(gspca_dev); 7016 sensor = zcxx_probeSensor(gspca_dev);
7038 if (sensor >= 0) 7017 if (sensor >= 0)
7039 PDEBUG(D_PROBE, "probe sensor -> %02x", sensor); 7018 PDEBUG(D_PROBE, "probe sensor -> %02x", sensor);
@@ -7119,6 +7098,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
7119 PDEBUG(D_PROBE, "Find Sensor GC0305"); 7098 PDEBUG(D_PROBE, "Find Sensor GC0305");
7120 sd->sensor = SENSOR_GC0305; 7099 sd->sensor = SENSOR_GC0305;
7121 break; 7100 break;
7101 case 0x0250:
7102 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)");
7103 sd->sensor = SENSOR_TAS5130C_VF0250;
7104 break;
7122 case 0x2030: 7105 case 0x2030:
7123 PDEBUG(D_PROBE, "Find Sensor PO2030"); 7106 PDEBUG(D_PROBE, "Find Sensor PO2030");
7124 sd->sensor = SENSOR_PO2030; 7107 sd->sensor = SENSOR_PO2030;
@@ -7146,7 +7129,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
7146 } 7129 }
7147 7130
7148 cam = &gspca_dev->cam; 7131 cam = &gspca_dev->cam;
7149 cam->dev_name = (char *) id->driver_info;
7150 cam->epaddr = 0x01; 7132 cam->epaddr = 0x01;
7151/*fixme:test*/ 7133/*fixme:test*/
7152 gspca_dev->nbalt--; 7134 gspca_dev->nbalt--;
@@ -7235,6 +7217,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
7235 case SENSOR_GC0305: 7217 case SENSOR_GC0305:
7236 case SENSOR_OV7620: 7218 case SENSOR_OV7620:
7237 case SENSOR_PO2030: 7219 case SENSOR_PO2030:
7220 case SENSOR_TAS5130C_VF0250:
7238 msleep(100); /* ?? */ 7221 msleep(100); /* ?? */
7239 reg_r(gspca_dev, 0x0002); /* --> 0x40 */ 7222 reg_r(gspca_dev, 0x0002); /* --> 0x40 */
7240 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */ 7223 reg_w(dev, 0x09, 0x01ad); /* (from win traces) */
@@ -7515,70 +7498,69 @@ static const struct sd_desc sd_desc = {
7515 .querymenu = sd_querymenu, 7498 .querymenu = sd_querymenu,
7516}; 7499};
7517 7500
7518#define DVNM(name) .driver_info = (kernel_ulong_t) name
7519static const __devinitdata struct usb_device_id device_table[] = { 7501static const __devinitdata struct usb_device_id device_table[] = {
7520 {USB_DEVICE(0x041e, 0x041e), DVNM("Creative WebCam Live!")}, 7502 {USB_DEVICE(0x041e, 0x041e)},
7521#ifndef CONFIG_USB_ZC0301 7503#ifndef CONFIG_USB_ZC0301
7522 {USB_DEVICE(0x041e, 0x4017), DVNM("Creative Webcam Mobile PD1090")}, 7504 {USB_DEVICE(0x041e, 0x4017)},
7523 {USB_DEVICE(0x041e, 0x401c), DVNM("Creative NX")}, 7505 {USB_DEVICE(0x041e, 0x401c)},
7524 {USB_DEVICE(0x041e, 0x401e), DVNM("Creative Nx Pro")}, 7506 {USB_DEVICE(0x041e, 0x401e)},
7525 {USB_DEVICE(0x041e, 0x401f), DVNM("Creative Webcam Notebook PD1171")}, 7507 {USB_DEVICE(0x041e, 0x401f)},
7526#endif 7508#endif
7527 {USB_DEVICE(0x041e, 0x4029), DVNM("Creative WebCam Vista Pro")}, 7509 {USB_DEVICE(0x041e, 0x4029)},
7528#ifndef CONFIG_USB_ZC0301 7510#ifndef CONFIG_USB_ZC0301
7529 {USB_DEVICE(0x041e, 0x4034), DVNM("Creative Instant P0620")}, 7511 {USB_DEVICE(0x041e, 0x4034)},
7530 {USB_DEVICE(0x041e, 0x4035), DVNM("Creative Instant P0620D")}, 7512 {USB_DEVICE(0x041e, 0x4035)},
7531 {USB_DEVICE(0x041e, 0x4036), DVNM("Creative Live !")}, 7513 {USB_DEVICE(0x041e, 0x4036)},
7532 {USB_DEVICE(0x041e, 0x403a), DVNM("Creative Nx Pro 2")}, 7514 {USB_DEVICE(0x041e, 0x403a)},
7533#endif 7515#endif
7534 {USB_DEVICE(0x041e, 0x4051), DVNM("Creative Notebook Pro (VF0250)")}, 7516 {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_TAS5130C_VF0250},
7535 {USB_DEVICE(0x041e, 0x4053), DVNM("Creative Live!Cam Video IM")}, 7517 {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_TAS5130C_VF0250},
7536#ifndef CONFIG_USB_ZC0301 7518#ifndef CONFIG_USB_ZC0301
7537 {USB_DEVICE(0x0458, 0x7007), DVNM("Genius VideoCam V2")}, 7519 {USB_DEVICE(0x0458, 0x7007)},
7538 {USB_DEVICE(0x0458, 0x700c), DVNM("Genius VideoCam V3")}, 7520 {USB_DEVICE(0x0458, 0x700c)},
7539 {USB_DEVICE(0x0458, 0x700f), DVNM("Genius VideoCam Web V2")}, 7521 {USB_DEVICE(0x0458, 0x700f)},
7540#endif 7522#endif
7541 {USB_DEVICE(0x0461, 0x0a00), DVNM("MicroInnovation WebCam320")}, 7523 {USB_DEVICE(0x0461, 0x0a00)},
7542 {USB_DEVICE(0x046d, 0x08a0), DVNM("Logitech QC IM")}, 7524 {USB_DEVICE(0x046d, 0x08a0)},
7543 {USB_DEVICE(0x046d, 0x08a1), DVNM("Logitech QC IM 0x08A1 +sound")}, 7525 {USB_DEVICE(0x046d, 0x08a1)},
7544 {USB_DEVICE(0x046d, 0x08a2), DVNM("Labtec Webcam Pro")}, 7526 {USB_DEVICE(0x046d, 0x08a2)},
7545 {USB_DEVICE(0x046d, 0x08a3), DVNM("Logitech QC Chat")}, 7527 {USB_DEVICE(0x046d, 0x08a3)},
7546 {USB_DEVICE(0x046d, 0x08a6), DVNM("Logitech QCim")}, 7528 {USB_DEVICE(0x046d, 0x08a6)},
7547 {USB_DEVICE(0x046d, 0x08a7), DVNM("Logitech QuickCam Image")}, 7529 {USB_DEVICE(0x046d, 0x08a7)},
7548 {USB_DEVICE(0x046d, 0x08a9), DVNM("Logitech Notebook Deluxe")}, 7530 {USB_DEVICE(0x046d, 0x08a9)},
7549 {USB_DEVICE(0x046d, 0x08aa), DVNM("Labtec Webcam Notebook")}, 7531 {USB_DEVICE(0x046d, 0x08aa)},
7550 {USB_DEVICE(0x046d, 0x08ac), DVNM("Logitech QuickCam Cool")}, 7532 {USB_DEVICE(0x046d, 0x08ac)},
7551 {USB_DEVICE(0x046d, 0x08ad), DVNM("Logitech QCCommunicate STX")}, 7533 {USB_DEVICE(0x046d, 0x08ad)},
7552#ifndef CONFIG_USB_ZC0301 7534#ifndef CONFIG_USB_ZC0301
7553 {USB_DEVICE(0x046d, 0x08ae), DVNM("Logitech QuickCam for Notebooks")}, 7535 {USB_DEVICE(0x046d, 0x08ae)},
7554#endif 7536#endif
7555 {USB_DEVICE(0x046d, 0x08af), DVNM("Logitech QuickCam Cool")}, 7537 {USB_DEVICE(0x046d, 0x08af)},
7556 {USB_DEVICE(0x046d, 0x08b9), DVNM("Logitech QC IM ???")}, 7538 {USB_DEVICE(0x046d, 0x08b9)},
7557 {USB_DEVICE(0x046d, 0x08d7), DVNM("Logitech QCam STX")}, 7539 {USB_DEVICE(0x046d, 0x08d7)},
7558 {USB_DEVICE(0x046d, 0x08d9), DVNM("Logitech QuickCam IM/Connect")}, 7540 {USB_DEVICE(0x046d, 0x08d9)},
7559 {USB_DEVICE(0x046d, 0x08d8), DVNM("Logitech Notebook Deluxe")}, 7541 {USB_DEVICE(0x046d, 0x08d8)},
7560 {USB_DEVICE(0x046d, 0x08da), DVNM("Logitech QuickCam Messenger")}, 7542 {USB_DEVICE(0x046d, 0x08da)},
7561 {USB_DEVICE(0x046d, 0x08dd), DVNM("Logitech QuickCam for Notebooks")}, 7543 {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB},
7562 {USB_DEVICE(0x0471, 0x0325), DVNM("Philips SPC 200 NC")}, 7544 {USB_DEVICE(0x0471, 0x0325)},
7563 {USB_DEVICE(0x0471, 0x0326), DVNM("Philips SPC 300 NC")}, 7545 {USB_DEVICE(0x0471, 0x0326)},
7564 {USB_DEVICE(0x0471, 0x032d), DVNM("Philips spc210nc")}, 7546 {USB_DEVICE(0x0471, 0x032d)},
7565 {USB_DEVICE(0x0471, 0x032e), DVNM("Philips spc315nc")}, 7547 {USB_DEVICE(0x0471, 0x032e)},
7566 {USB_DEVICE(0x055f, 0xc005), DVNM("Mustek Wcam300A")}, 7548 {USB_DEVICE(0x055f, 0xc005)},
7567#ifndef CONFIG_USB_ZC0301 7549#ifndef CONFIG_USB_ZC0301
7568 {USB_DEVICE(0x055f, 0xd003), DVNM("Mustek WCam300A")}, 7550 {USB_DEVICE(0x055f, 0xd003)},
7569 {USB_DEVICE(0x055f, 0xd004), DVNM("Mustek WCam300 AN")}, 7551 {USB_DEVICE(0x055f, 0xd004)},
7570#endif 7552#endif
7571 {USB_DEVICE(0x0698, 0x2003), DVNM("CTX M730V built in")}, 7553 {USB_DEVICE(0x0698, 0x2003)},
7572 {USB_DEVICE(0x0ac8, 0x0302), DVNM("Z-star Vimicro zc0302")}, 7554 {USB_DEVICE(0x0ac8, 0x0302)},
7573#ifndef CONFIG_USB_ZC0301 7555#ifndef CONFIG_USB_ZC0301
7574 {USB_DEVICE(0x0ac8, 0x301b), DVNM("Z-Star zc301b")}, 7556 {USB_DEVICE(0x0ac8, 0x301b)},
7575 {USB_DEVICE(0x0ac8, 0x303b), DVNM("Vimicro 0x303b")}, 7557 {USB_DEVICE(0x0ac8, 0x303b)},
7576#endif 7558#endif
7577 {USB_DEVICE(0x0ac8, 0x305b), DVNM("Z-star Vimicro zc0305b")}, 7559 {USB_DEVICE(0x0ac8, 0x305b), .driver_info = SENSOR_TAS5130C_VF0250},
7578#ifndef CONFIG_USB_ZC0301 7560#ifndef CONFIG_USB_ZC0301
7579 {USB_DEVICE(0x0ac8, 0x307b), DVNM("Z-Star 307b")}, 7561 {USB_DEVICE(0x0ac8, 0x307b)},
7580 {USB_DEVICE(0x10fd, 0x0128), DVNM("Typhoon Webshot II 300k 0x0128")}, 7562 {USB_DEVICE(0x10fd, 0x0128)},
7581 {USB_DEVICE(0x10fd, 0x8050), DVNM("Typhoon Webshot II USB 300k")}, 7563 {USB_DEVICE(0x10fd, 0x8050)},
7582#endif 7564#endif
7583 {} /* end of entry */ 7565 {} /* end of entry */
7584}; 7566};
@@ -7605,7 +7587,7 @@ static int __init sd_mod_init(void)
7605{ 7587{
7606 if (usb_register(&sd_driver) < 0) 7588 if (usb_register(&sd_driver) < 0)
7607 return -1; 7589 return -1;
7608 PDEBUG(D_PROBE, "v%s registered", version); 7590 PDEBUG(D_PROBE, "registered");
7609 return 0; 7591 return 0;
7610} 7592}
7611 7593
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index 5d7ee8fcdd50..0069898bddab 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -2,9 +2,7 @@ config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR 4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
6 select I2C_ALGOBIT 5 select I2C_ALGOBIT
7 select FW_LOADER
8 select VIDEO_IR 6 select VIDEO_IR
9 select VIDEO_TUNER 7 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 41fd79279bb5..aea1664948ce 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -465,9 +465,8 @@ static void ivtv_process_eeprom(struct ivtv *itv)
465 if (itv->options.radio == -1) 465 if (itv->options.radio == -1)
466 itv->options.radio = (tv.has_radio != 0); 466 itv->options.radio = (tv.has_radio != 0);
467 /* only enable newi2c if an IR blaster is present */ 467 /* only enable newi2c if an IR blaster is present */
468 /* FIXME: for 2.6.20 the test against 2 should be removed */ 468 if (itv->options.newi2c == -1 && tv.has_ir) {
469 if (itv->options.newi2c == -1 && tv.has_ir != -1 && tv.has_ir != 2) { 469 itv->options.newi2c = (tv.has_ir & 4) ? 1 : 0;
470 itv->options.newi2c = (tv.has_ir & 2) ? 1 : 0;
471 if (itv->options.newi2c) { 470 if (itv->options.newi2c) {
472 IVTV_INFO("Reopen i2c bus for IR-blaster support\n"); 471 IVTV_INFO("Reopen i2c bus for IR-blaster support\n");
473 exit_ivtv_i2c(itv); 472 exit_ivtv_i2c(itv);
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index a08bb3331cfb..ab287b48fc2b 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -60,6 +60,7 @@
60#include <linux/dvb/video.h> 60#include <linux/dvb/video.h>
61#include <linux/dvb/audio.h> 61#include <linux/dvb/audio.h>
62#include <media/v4l2-common.h> 62#include <media/v4l2-common.h>
63#include <media/v4l2-ioctl.h>
63#include <media/tuner.h> 64#include <media/tuner.h>
64#include <media/cx2341x.h> 65#include <media/cx2341x.h>
65 66
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 52e00a7f3110..61030309d0ad 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1842,69 +1842,73 @@ int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1842 return res; 1842 return res;
1843} 1843}
1844 1844
1845void ivtv_set_funcs(struct video_device *vdev) 1845static const struct v4l2_ioctl_ops ivtv_ioctl_ops = {
1846{ 1846 .vidioc_querycap = ivtv_querycap,
1847 vdev->vidioc_querycap = ivtv_querycap; 1847 .vidioc_g_priority = ivtv_g_priority,
1848 vdev->vidioc_g_priority = ivtv_g_priority; 1848 .vidioc_s_priority = ivtv_s_priority,
1849 vdev->vidioc_s_priority = ivtv_s_priority; 1849 .vidioc_s_audio = ivtv_s_audio,
1850 vdev->vidioc_s_audio = ivtv_s_audio; 1850 .vidioc_g_audio = ivtv_g_audio,
1851 vdev->vidioc_g_audio = ivtv_g_audio; 1851 .vidioc_enumaudio = ivtv_enumaudio,
1852 vdev->vidioc_enumaudio = ivtv_enumaudio; 1852 .vidioc_s_audout = ivtv_s_audout,
1853 vdev->vidioc_s_audout = ivtv_s_audout; 1853 .vidioc_g_audout = ivtv_g_audout,
1854 vdev->vidioc_g_audout = ivtv_g_audout; 1854 .vidioc_enum_input = ivtv_enum_input,
1855 vdev->vidioc_enum_input = ivtv_enum_input; 1855 .vidioc_enum_output = ivtv_enum_output,
1856 vdev->vidioc_enum_output = ivtv_enum_output; 1856 .vidioc_enumaudout = ivtv_enumaudout,
1857 vdev->vidioc_enumaudout = ivtv_enumaudout; 1857 .vidioc_cropcap = ivtv_cropcap,
1858 vdev->vidioc_cropcap = ivtv_cropcap; 1858 .vidioc_s_crop = ivtv_s_crop,
1859 vdev->vidioc_s_crop = ivtv_s_crop; 1859 .vidioc_g_crop = ivtv_g_crop,
1860 vdev->vidioc_g_crop = ivtv_g_crop; 1860 .vidioc_g_input = ivtv_g_input,
1861 vdev->vidioc_g_input = ivtv_g_input; 1861 .vidioc_s_input = ivtv_s_input,
1862 vdev->vidioc_s_input = ivtv_s_input; 1862 .vidioc_g_output = ivtv_g_output,
1863 vdev->vidioc_g_output = ivtv_g_output; 1863 .vidioc_s_output = ivtv_s_output,
1864 vdev->vidioc_s_output = ivtv_s_output; 1864 .vidioc_g_frequency = ivtv_g_frequency,
1865 vdev->vidioc_g_frequency = ivtv_g_frequency; 1865 .vidioc_s_frequency = ivtv_s_frequency,
1866 vdev->vidioc_s_frequency = ivtv_s_frequency; 1866 .vidioc_s_tuner = ivtv_s_tuner,
1867 vdev->vidioc_s_tuner = ivtv_s_tuner; 1867 .vidioc_g_tuner = ivtv_g_tuner,
1868 vdev->vidioc_g_tuner = ivtv_g_tuner; 1868 .vidioc_g_enc_index = ivtv_g_enc_index,
1869 vdev->vidioc_g_enc_index = ivtv_g_enc_index; 1869 .vidioc_g_fbuf = ivtv_g_fbuf,
1870 vdev->vidioc_g_fbuf = ivtv_g_fbuf; 1870 .vidioc_s_fbuf = ivtv_s_fbuf,
1871 vdev->vidioc_s_fbuf = ivtv_s_fbuf; 1871 .vidioc_g_std = ivtv_g_std,
1872 vdev->vidioc_g_std = ivtv_g_std; 1872 .vidioc_s_std = ivtv_s_std,
1873 vdev->vidioc_s_std = ivtv_s_std; 1873 .vidioc_overlay = ivtv_overlay,
1874 vdev->vidioc_overlay = ivtv_overlay; 1874 .vidioc_log_status = ivtv_log_status,
1875 vdev->vidioc_log_status = ivtv_log_status; 1875 .vidioc_enum_fmt_vid_cap = ivtv_enum_fmt_vid_cap,
1876 vdev->vidioc_enum_fmt_vid_cap = ivtv_enum_fmt_vid_cap; 1876 .vidioc_encoder_cmd = ivtv_encoder_cmd,
1877 vdev->vidioc_encoder_cmd = ivtv_encoder_cmd; 1877 .vidioc_try_encoder_cmd = ivtv_try_encoder_cmd,
1878 vdev->vidioc_try_encoder_cmd = ivtv_try_encoder_cmd; 1878 .vidioc_enum_fmt_vid_out = ivtv_enum_fmt_vid_out,
1879 vdev->vidioc_enum_fmt_vid_out = ivtv_enum_fmt_vid_out; 1879 .vidioc_g_fmt_vid_cap = ivtv_g_fmt_vid_cap,
1880 vdev->vidioc_g_fmt_vid_cap = ivtv_g_fmt_vid_cap; 1880 .vidioc_g_fmt_vbi_cap = ivtv_g_fmt_vbi_cap,
1881 vdev->vidioc_g_fmt_vbi_cap = ivtv_g_fmt_vbi_cap; 1881 .vidioc_g_fmt_sliced_vbi_cap = ivtv_g_fmt_sliced_vbi_cap,
1882 vdev->vidioc_g_fmt_sliced_vbi_cap = ivtv_g_fmt_sliced_vbi_cap; 1882 .vidioc_g_fmt_vid_out = ivtv_g_fmt_vid_out,
1883 vdev->vidioc_g_fmt_vid_out = ivtv_g_fmt_vid_out; 1883 .vidioc_g_fmt_vid_out_overlay = ivtv_g_fmt_vid_out_overlay,
1884 vdev->vidioc_g_fmt_vid_out_overlay = ivtv_g_fmt_vid_out_overlay; 1884 .vidioc_g_fmt_sliced_vbi_out = ivtv_g_fmt_sliced_vbi_out,
1885 vdev->vidioc_g_fmt_sliced_vbi_out = ivtv_g_fmt_sliced_vbi_out; 1885 .vidioc_s_fmt_vid_cap = ivtv_s_fmt_vid_cap,
1886 vdev->vidioc_s_fmt_vid_cap = ivtv_s_fmt_vid_cap; 1886 .vidioc_s_fmt_vbi_cap = ivtv_s_fmt_vbi_cap,
1887 vdev->vidioc_s_fmt_vbi_cap = ivtv_s_fmt_vbi_cap; 1887 .vidioc_s_fmt_sliced_vbi_cap = ivtv_s_fmt_sliced_vbi_cap,
1888 vdev->vidioc_s_fmt_sliced_vbi_cap = ivtv_s_fmt_sliced_vbi_cap; 1888 .vidioc_s_fmt_vid_out = ivtv_s_fmt_vid_out,
1889 vdev->vidioc_s_fmt_vid_out = ivtv_s_fmt_vid_out; 1889 .vidioc_s_fmt_vid_out_overlay = ivtv_s_fmt_vid_out_overlay,
1890 vdev->vidioc_s_fmt_vid_out_overlay = ivtv_s_fmt_vid_out_overlay; 1890 .vidioc_s_fmt_sliced_vbi_out = ivtv_s_fmt_sliced_vbi_out,
1891 vdev->vidioc_s_fmt_sliced_vbi_out = ivtv_s_fmt_sliced_vbi_out; 1891 .vidioc_try_fmt_vid_cap = ivtv_try_fmt_vid_cap,
1892 vdev->vidioc_try_fmt_vid_cap = ivtv_try_fmt_vid_cap; 1892 .vidioc_try_fmt_vbi_cap = ivtv_try_fmt_vbi_cap,
1893 vdev->vidioc_try_fmt_vbi_cap = ivtv_try_fmt_vbi_cap; 1893 .vidioc_try_fmt_sliced_vbi_cap = ivtv_try_fmt_sliced_vbi_cap,
1894 vdev->vidioc_try_fmt_sliced_vbi_cap = ivtv_try_fmt_sliced_vbi_cap; 1894 .vidioc_try_fmt_vid_out = ivtv_try_fmt_vid_out,
1895 vdev->vidioc_try_fmt_vid_out = ivtv_try_fmt_vid_out; 1895 .vidioc_try_fmt_vid_out_overlay = ivtv_try_fmt_vid_out_overlay,
1896 vdev->vidioc_try_fmt_vid_out_overlay = ivtv_try_fmt_vid_out_overlay; 1896 .vidioc_try_fmt_sliced_vbi_out = ivtv_try_fmt_sliced_vbi_out,
1897 vdev->vidioc_try_fmt_sliced_vbi_out = ivtv_try_fmt_sliced_vbi_out; 1897 .vidioc_g_sliced_vbi_cap = ivtv_g_sliced_vbi_cap,
1898 vdev->vidioc_g_sliced_vbi_cap = ivtv_g_sliced_vbi_cap; 1898 .vidioc_g_chip_ident = ivtv_g_chip_ident,
1899 vdev->vidioc_g_chip_ident = ivtv_g_chip_ident;
1900#ifdef CONFIG_VIDEO_ADV_DEBUG 1899#ifdef CONFIG_VIDEO_ADV_DEBUG
1901 vdev->vidioc_g_register = ivtv_g_register; 1900 .vidioc_g_register = ivtv_g_register,
1902 vdev->vidioc_s_register = ivtv_s_register; 1901 .vidioc_s_register = ivtv_s_register,
1903#endif 1902#endif
1904 vdev->vidioc_default = ivtv_default; 1903 .vidioc_default = ivtv_default,
1905 vdev->vidioc_queryctrl = ivtv_queryctrl; 1904 .vidioc_queryctrl = ivtv_queryctrl,
1906 vdev->vidioc_querymenu = ivtv_querymenu; 1905 .vidioc_querymenu = ivtv_querymenu,
1907 vdev->vidioc_g_ext_ctrls = ivtv_g_ext_ctrls; 1906 .vidioc_g_ext_ctrls = ivtv_g_ext_ctrls,
1908 vdev->vidioc_s_ext_ctrls = ivtv_s_ext_ctrls; 1907 .vidioc_s_ext_ctrls = ivtv_s_ext_ctrls,
1909 vdev->vidioc_try_ext_ctrls = ivtv_try_ext_ctrls; 1908 .vidioc_try_ext_ctrls = ivtv_try_ext_ctrls,
1909};
1910
1911void ivtv_set_funcs(struct video_device *vdev)
1912{
1913 vdev->ioctl_ops = &ivtv_ioctl_ops;
1910} 1914}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index f8883b487f4a..54d2023b26c4 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -208,16 +208,11 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
208 return -ENOMEM; 208 return -ENOMEM;
209 } 209 }
210 210
211 s->v4l2dev->type = VID_TYPE_CAPTURE | VID_TYPE_TUNER | VID_TYPE_TELETEXT |
212 VID_TYPE_CLIPPING | VID_TYPE_SCALES | VID_TYPE_MPEG_ENCODER;
213 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
214 s->v4l2dev->type |= VID_TYPE_MPEG_DECODER;
215 }
216 snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d %s", 211 snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d %s",
217 itv->num, s->name); 212 itv->num, s->name);
218 213
219 s->v4l2dev->minor = minor; 214 s->v4l2dev->minor = minor;
220 s->v4l2dev->dev = &itv->dev->dev; 215 s->v4l2dev->parent = &itv->dev->dev;
221 s->v4l2dev->fops = ivtv_stream_info[type].fops; 216 s->v4l2dev->fops = ivtv_stream_info[type].fops;
222 s->v4l2dev->release = video_device_release; 217 s->v4l2dev->release = video_device_release;
223 s->v4l2dev->tvnorms = V4L2_STD_ALL; 218 s->v4l2dev->tvnorms = V4L2_STD_ALL;
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index 39bf6b114d50..89a781c6929d 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -26,7 +26,7 @@
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c-id.h> 28#include <linux/i2c-id.h>
29#include <linux/videodev.h> 29#include <linux/videodev2.h>
30#include <media/m52790.h> 30#include <media/m52790.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32#include <media/v4l2-chip-ident.h> 32#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 2fb5854cf6f0..7c8ef6ac6c39 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -31,6 +31,7 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/videodev.h> 32#include <linux/videodev.h>
33#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
34#include <media/v4l2-ioctl.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/io.h> 36#include <asm/io.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
@@ -1697,13 +1698,7 @@ static const struct file_operations meye_fops = {
1697 .llseek = no_llseek, 1698 .llseek = no_llseek,
1698}; 1699};
1699 1700
1700static struct video_device meye_template = { 1701static const struct v4l2_ioctl_ops meye_ioctl_ops = {
1701 .owner = THIS_MODULE,
1702 .name = "meye",
1703 .type = VID_TYPE_CAPTURE,
1704 .fops = &meye_fops,
1705 .release = video_device_release,
1706 .minor = -1,
1707 .vidioc_querycap = vidioc_querycap, 1702 .vidioc_querycap = vidioc_querycap,
1708 .vidioc_enum_input = vidioc_enum_input, 1703 .vidioc_enum_input = vidioc_enum_input,
1709 .vidioc_g_input = vidioc_g_input, 1704 .vidioc_g_input = vidioc_g_input,
@@ -1724,6 +1719,14 @@ static struct video_device meye_template = {
1724 .vidioc_default = vidioc_default, 1719 .vidioc_default = vidioc_default,
1725}; 1720};
1726 1721
1722static struct video_device meye_template = {
1723 .name = "meye",
1724 .fops = &meye_fops,
1725 .ioctl_ops = &meye_ioctl_ops,
1726 .release = video_device_release,
1727 .minor = -1,
1728};
1729
1727#ifdef CONFIG_PM 1730#ifdef CONFIG_PM
1728static int meye_suspend(struct pci_dev *pdev, pm_message_t state) 1731static int meye_suspend(struct pci_dev *pdev, pm_message_t state)
1729{ 1732{
@@ -1801,7 +1804,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1801 } 1804 }
1802 1805
1803 memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); 1806 memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
1804 meye.video_dev->dev = &meye.mchip_dev->dev; 1807 meye.video_dev->parent = &meye.mchip_dev->dev;
1805 1808
1806 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { 1809 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
1807 printk(KERN_ERR "meye: unable to power on the camera\n"); 1810 printk(KERN_ERR "meye: unable to power on the camera\n");
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 5691e019d195..3da74dcee902 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -51,9 +51,9 @@
51#include <linux/module.h> 51#include <linux/module.h>
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/i2c.h> 53#include <linux/i2c.h>
54#include <linux/videodev.h>
55#include <linux/videodev2.h> 54#include <linux/videodev2.h>
56#include <media/v4l2-common.h> 55#include <media/v4l2-common.h>
56#include <media/v4l2-ioctl.h>
57#include <media/v4l2-i2c-drv-legacy.h> 57#include <media/v4l2-i2c-drv-legacy.h>
58#include <media/tvaudio.h> 58#include <media/tvaudio.h>
59#include <media/msp3400.h> 59#include <media/msp3400.h>
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 1622f70e4dd0..846a14a61fd1 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -25,7 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/freezer.h> 27#include <linux/freezer.h>
28#include <linux/videodev.h>
29#include <linux/videodev2.h> 28#include <linux/videodev2.h>
30#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
31#include <media/msp3400.h> 30#include <media/msp3400.h>
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index ee43499544c1..554d2295484e 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -120,7 +120,7 @@ static int mt9m001_init(struct soc_camera_device *icd)
120 int ret; 120 int ret;
121 121
122 /* Disable chip, synchronous option update */ 122 /* Disable chip, synchronous option update */
123 dev_dbg(icd->vdev->dev, "%s\n", __func__); 123 dev_dbg(icd->vdev->parent, "%s\n", __func__);
124 124
125 ret = reg_write(icd, MT9M001_RESET, 1); 125 ret = reg_write(icd, MT9M001_RESET, 1);
126 if (ret >= 0) 126 if (ret >= 0)
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index eafb0c7736e6..9edaca4371d7 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -4666,9 +4666,7 @@ static const struct file_operations ov511_fops = {
4666}; 4666};
4667 4667
4668static struct video_device vdev_template = { 4668static struct video_device vdev_template = {
4669 .owner = THIS_MODULE,
4670 .name = "OV511 USB Camera", 4669 .name = "OV511 USB Camera",
4671 .type = VID_TYPE_CAPTURE,
4672 .fops = &ov511_fops, 4670 .fops = &ov511_fops,
4673 .release = video_device_release, 4671 .release = video_device_release,
4674 .minor = -1, 4672 .minor = -1,
@@ -5661,43 +5659,43 @@ static int ov_create_sysfs(struct video_device *vdev)
5661{ 5659{
5662 int rc; 5660 int rc;
5663 5661
5664 rc = video_device_create_file(vdev, &dev_attr_custom_id); 5662 rc = device_create_file(&vdev->dev, &dev_attr_custom_id);
5665 if (rc) goto err; 5663 if (rc) goto err;
5666 rc = video_device_create_file(vdev, &dev_attr_model); 5664 rc = device_create_file(&vdev->dev, &dev_attr_model);
5667 if (rc) goto err_id; 5665 if (rc) goto err_id;
5668 rc = video_device_create_file(vdev, &dev_attr_bridge); 5666 rc = device_create_file(&vdev->dev, &dev_attr_bridge);
5669 if (rc) goto err_model; 5667 if (rc) goto err_model;
5670 rc = video_device_create_file(vdev, &dev_attr_sensor); 5668 rc = device_create_file(&vdev->dev, &dev_attr_sensor);
5671 if (rc) goto err_bridge; 5669 if (rc) goto err_bridge;
5672 rc = video_device_create_file(vdev, &dev_attr_brightness); 5670 rc = device_create_file(&vdev->dev, &dev_attr_brightness);
5673 if (rc) goto err_sensor; 5671 if (rc) goto err_sensor;
5674 rc = video_device_create_file(vdev, &dev_attr_saturation); 5672 rc = device_create_file(&vdev->dev, &dev_attr_saturation);
5675 if (rc) goto err_bright; 5673 if (rc) goto err_bright;
5676 rc = video_device_create_file(vdev, &dev_attr_contrast); 5674 rc = device_create_file(&vdev->dev, &dev_attr_contrast);
5677 if (rc) goto err_sat; 5675 if (rc) goto err_sat;
5678 rc = video_device_create_file(vdev, &dev_attr_hue); 5676 rc = device_create_file(&vdev->dev, &dev_attr_hue);
5679 if (rc) goto err_contrast; 5677 if (rc) goto err_contrast;
5680 rc = video_device_create_file(vdev, &dev_attr_exposure); 5678 rc = device_create_file(&vdev->dev, &dev_attr_exposure);
5681 if (rc) goto err_hue; 5679 if (rc) goto err_hue;
5682 5680
5683 return 0; 5681 return 0;
5684 5682
5685err_hue: 5683err_hue:
5686 video_device_remove_file(vdev, &dev_attr_hue); 5684 device_remove_file(&vdev->dev, &dev_attr_hue);
5687err_contrast: 5685err_contrast:
5688 video_device_remove_file(vdev, &dev_attr_contrast); 5686 device_remove_file(&vdev->dev, &dev_attr_contrast);
5689err_sat: 5687err_sat:
5690 video_device_remove_file(vdev, &dev_attr_saturation); 5688 device_remove_file(&vdev->dev, &dev_attr_saturation);
5691err_bright: 5689err_bright:
5692 video_device_remove_file(vdev, &dev_attr_brightness); 5690 device_remove_file(&vdev->dev, &dev_attr_brightness);
5693err_sensor: 5691err_sensor:
5694 video_device_remove_file(vdev, &dev_attr_sensor); 5692 device_remove_file(&vdev->dev, &dev_attr_sensor);
5695err_bridge: 5693err_bridge:
5696 video_device_remove_file(vdev, &dev_attr_bridge); 5694 device_remove_file(&vdev->dev, &dev_attr_bridge);
5697err_model: 5695err_model:
5698 video_device_remove_file(vdev, &dev_attr_model); 5696 device_remove_file(&vdev->dev, &dev_attr_model);
5699err_id: 5697err_id:
5700 video_device_remove_file(vdev, &dev_attr_custom_id); 5698 device_remove_file(&vdev->dev, &dev_attr_custom_id);
5701err: 5699err:
5702 return rc; 5700 return rc;
5703} 5701}
@@ -5833,7 +5831,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5833 goto error; 5831 goto error;
5834 5832
5835 memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev)); 5833 memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev));
5836 ov->vdev->dev = &intf->dev; 5834 ov->vdev->parent = &intf->dev;
5837 video_set_drvdata(ov->vdev, ov); 5835 video_set_drvdata(ov->vdev, ov);
5838 5836
5839 for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) { 5837 for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) {
diff --git a/drivers/media/video/ov511.h b/drivers/media/video/ov511.h
index 1010e51189b7..baded1262ca9 100644
--- a/drivers/media/video/ov511.h
+++ b/drivers/media/video/ov511.h
@@ -4,6 +4,7 @@
4#include <asm/uaccess.h> 4#include <asm/uaccess.h>
5#include <linux/videodev.h> 5#include <linux/videodev.h>
6#include <media/v4l2-common.h> 6#include <media/v4l2-common.h>
7#include <media/v4l2-ioctl.h>
7#include <linux/usb.h> 8#include <linux/usb.h>
8#include <linux/mutex.h> 9#include <linux/mutex.h>
9 10
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 36047d4e70f6..e69de29bb2d1 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -1,2309 +0,0 @@
1/*
2 planb - PlanB frame grabber driver
3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
5 Computers as video input DMA controller.
6
7 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
8
9 Based largely on the bttv driver by Ralph Metzler (rjkm@thp.uni-koeln.de)
10
11 Additional debugging and coding by Takashi Oe (toe@unlserve.unl.edu)
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26*/
27
28/* $Id: planb.c,v 1.18 1999/05/02 17:36:34 mlan Exp $ */
29
30#include <linux/init.h>
31#include <linux/errno.h>
32#include <linux/module.h>
33#include <linux/kernel.h>
34#include <linux/major.h>
35#include <linux/slab.h>
36#include <linux/types.h>
37#include <linux/pci.h>
38#include <linux/delay.h>
39#include <linux/vmalloc.h>
40#include <linux/mm.h>
41#include <linux/sched.h>
42#include <linux/videodev.h>
43#include <media/v4l2-common.h>
44#include <linux/wait.h>
45#include <asm/uaccess.h>
46#include <asm/io.h>
47#include <asm/prom.h>
48#include <asm/dbdma.h>
49#include <asm/pgtable.h>
50#include <asm/page.h>
51#include <asm/irq.h>
52#include <linux/mutex.h>
53
54#include "planb.h"
55#include "saa7196.h"
56
57/* Would you mind for some ugly debugging? */
58#if 0
59#define DEBUG(x...) printk(KERN_DEBUG ## x) /* Debug driver */
60#else
61#define DEBUG(x...) /* Don't debug driver */
62#endif
63
64#if 0
65#define IDEBUG(x...) printk(KERN_DEBUG ## x) /* Debug interrupt part */
66#else
67#define IDEBUG(x...) /* Don't debug interrupt part */
68#endif
69
70/* Ever seen a Mac with more than 1 of these? */
71#define PLANB_MAX 1
72
73static int planb_num;
74static struct planb planbs[PLANB_MAX];
75static volatile struct planb_registers *planb_regs;
76
77static int def_norm = PLANB_DEF_NORM; /* default norm */
78static int video_nr = -1;
79
80module_param(def_norm, int, 0);
81MODULE_PARM_DESC(def_norm, "Default startup norm (0=PAL, 1=NTSC, 2=SECAM)");
82module_param(video_nr, int, 0);
83MODULE_LICENSE("GPL");
84
85
86/* ------------------ PlanB Exported Functions ------------------ */
87static long planb_write(struct video_device *, const char *, unsigned long, int);
88static long planb_read(struct video_device *, char *, unsigned long, int);
89static int planb_open(struct video_device *, int);
90static void planb_close(struct video_device *);
91static int planb_ioctl(struct video_device *, unsigned int, void *);
92static int planb_init_done(struct video_device *);
93static int planb_mmap(struct video_device *, const char *, unsigned long);
94static void release_planb(void);
95int init_planbs(struct video_init *);
96
97/* ------------------ PlanB Internal Functions ------------------ */
98static int planb_prepare_open(struct planb *);
99static void planb_prepare_close(struct planb *);
100static void saa_write_reg(unsigned char, unsigned char);
101static unsigned char saa_status(int, struct planb *);
102static void saa_set(unsigned char, unsigned char, struct planb *);
103static void saa_init_regs(struct planb *);
104static int grabbuf_alloc(struct planb *);
105static int vgrab(struct planb *, struct video_mmap *);
106static void add_clip(struct planb *, struct video_clip *);
107static void fill_cmd_buff(struct planb *);
108static void cmd_buff(struct planb *);
109static volatile struct dbdma_cmd *setup_grab_cmd(int, struct planb *);
110static void overlay_start(struct planb *);
111static void overlay_stop(struct planb *);
112static inline void tab_cmd_dbdma(volatile struct dbdma_cmd *, unsigned short,
113 unsigned int);
114static inline void tab_cmd_store(volatile struct dbdma_cmd *, unsigned int,
115 unsigned int);
116static inline void tab_cmd_gen(volatile struct dbdma_cmd *, unsigned short,
117 unsigned short, unsigned int, unsigned int);
118static int init_planb(struct planb *);
119static int find_planb(void);
120static void planb_pre_capture(int, int, struct planb *);
121static volatile struct dbdma_cmd *cmd_geo_setup(volatile struct dbdma_cmd *,
122 int, int, int, int, int, struct planb *);
123static inline void planb_dbdma_stop(volatile struct dbdma_regs *);
124static unsigned int saa_geo_setup(int, int, int, int, struct planb *);
125static inline int overlay_is_active(struct planb *);
126
127/*******************************/
128/* Memory management functions */
129/*******************************/
130
131static int grabbuf_alloc(struct planb *pb)
132{
133 int i, npage;
134
135 npage = MAX_GBUFFERS * ((PLANB_MAX_FBUF / PAGE_SIZE + 1)
136#ifndef PLANB_GSCANLINE
137 + MAX_LNUM
138#endif /* PLANB_GSCANLINE */
139 );
140 if ((pb->rawbuf = kmalloc(npage
141 * sizeof(unsigned long), GFP_KERNEL)) == 0)
142 return -ENOMEM;
143 for (i = 0; i < npage; i++) {
144 pb->rawbuf[i] = (unsigned char *)__get_free_pages(GFP_KERNEL
145 |GFP_DMA, 0);
146 if (!pb->rawbuf[i])
147 break;
148 SetPageReserved(virt_to_page(pb->rawbuf[i]));
149 }
150 if (i-- < npage) {
151 printk(KERN_DEBUG "PlanB: init_grab: grab buffer not allocated\n");
152 for (; i > 0; i--) {
153 ClearPageReserved(virt_to_page(pb->rawbuf[i]));
154 free_pages((unsigned long)pb->rawbuf[i], 0);
155 }
156 kfree(pb->rawbuf);
157 return -ENOBUFS;
158 }
159 pb->rawbuf_size = npage;
160 return 0;
161}
162
163/*****************************/
164/* Hardware access functions */
165/*****************************/
166
167static void saa_write_reg(unsigned char addr, unsigned char val)
168{
169 planb_regs->saa_addr = addr; eieio();
170 planb_regs->saa_regval = val; eieio();
171 return;
172}
173
174/* return status byte 0 or 1: */
175static unsigned char saa_status(int byte, struct planb *pb)
176{
177 saa_regs[pb->win.norm][SAA7196_STDC] =
178 (saa_regs[pb->win.norm][SAA7196_STDC] & ~2) | ((byte & 1) << 1);
179 saa_write_reg (SAA7196_STDC, saa_regs[pb->win.norm][SAA7196_STDC]);
180
181 /* Let's wait 30msec for this one */
182 msleep_interruptible(30);
183
184 return (unsigned char)in_8 (&planb_regs->saa_status);
185}
186
187static void saa_set(unsigned char addr, unsigned char val, struct planb *pb)
188{
189 if(saa_regs[pb->win.norm][addr] != val) {
190 saa_regs[pb->win.norm][addr] = val;
191 saa_write_reg (addr, val);
192 }
193 return;
194}
195
196static void saa_init_regs(struct planb *pb)
197{
198 int i;
199
200 for (i = 0; i < SAA7196_NUMREGS; i++)
201 saa_write_reg (i, saa_regs[pb->win.norm][i]);
202}
203
204static unsigned int saa_geo_setup(int width, int height, int interlace, int bpp,
205 struct planb *pb)
206{
207 int ht, norm = pb->win.norm;
208
209 switch(bpp) {
210 case 2:
211 /* RGB555+a 1x16-bit + 16-bit transparent */
212 saa_regs[norm][SAA7196_FMTS] &= ~0x3;
213 break;
214 case 1:
215 case 4:
216 /* RGB888 1x24-bit + 8-bit transparent */
217 saa_regs[norm][SAA7196_FMTS] &= ~0x1;
218 saa_regs[norm][SAA7196_FMTS] |= 0x2;
219 break;
220 default:
221 return -EINVAL;
222 }
223 ht = (interlace ? height / 2 : height);
224 saa_regs[norm][SAA7196_OUTPIX] = (unsigned char) (width & 0x00ff);
225 saa_regs[norm][SAA7196_HFILT] = (saa_regs[norm][SAA7196_HFILT] & ~0x3)
226 | (width >> 8 & 0x3);
227 saa_regs[norm][SAA7196_OUTLINE] = (unsigned char) (ht & 0xff);
228 saa_regs[norm][SAA7196_VYP] = (saa_regs[norm][SAA7196_VYP] & ~0x3)
229 | (ht >> 8 & 0x3);
230 /* feed both fields if interlaced, or else feed only even fields */
231 saa_regs[norm][SAA7196_FMTS] = (interlace) ?
232 (saa_regs[norm][SAA7196_FMTS] & ~0x60)
233 : (saa_regs[norm][SAA7196_FMTS] | 0x60);
234 /* transparent mode; extended format enabled */
235 saa_regs[norm][SAA7196_DPATH] |= 0x3;
236
237 return 0;
238}
239
240/***************************/
241/* DBDMA support functions */
242/***************************/
243
244static inline void planb_dbdma_restart(volatile struct dbdma_regs *ch)
245{
246 out_le32(&ch->control, PLANB_CLR(RUN));
247 out_le32(&ch->control, PLANB_SET(RUN|WAKE) | PLANB_CLR(PAUSE));
248}
249
250static inline void planb_dbdma_stop(volatile struct dbdma_regs *ch)
251{
252 int i = 0;
253
254 out_le32(&ch->control, PLANB_CLR(RUN) | PLANB_SET(FLUSH));
255 while((in_le32(&ch->status) == (ACTIVE | FLUSH)) && (i < 999)) {
256 IDEBUG("PlanB: waiting for DMA to stop\n");
257 i++;
258 }
259}
260
261static inline void tab_cmd_dbdma(volatile struct dbdma_cmd *ch,
262 unsigned short command, unsigned int cmd_dep)
263{
264 st_le16(&ch->command, command);
265 st_le32(&ch->cmd_dep, cmd_dep);
266}
267
268static inline void tab_cmd_store(volatile struct dbdma_cmd *ch,
269 unsigned int phy_addr, unsigned int cmd_dep)
270{
271 st_le16(&ch->command, STORE_WORD | KEY_SYSTEM);
272 st_le16(&ch->req_count, 4);
273 st_le32(&ch->phy_addr, phy_addr);
274 st_le32(&ch->cmd_dep, cmd_dep);
275}
276
277static inline void tab_cmd_gen(volatile struct dbdma_cmd *ch,
278 unsigned short command, unsigned short req_count,
279 unsigned int phy_addr, unsigned int cmd_dep)
280{
281 st_le16(&ch->command, command);
282 st_le16(&ch->req_count, req_count);
283 st_le32(&ch->phy_addr, phy_addr);
284 st_le32(&ch->cmd_dep, cmd_dep);
285}
286
287static volatile struct dbdma_cmd *cmd_geo_setup(
288 volatile struct dbdma_cmd *c1, int width, int height, int interlace,
289 int bpp, int clip, struct planb *pb)
290{
291 int norm = pb->win.norm;
292
293 if((saa_geo_setup(width, height, interlace, bpp, pb)) != 0)
294 return (volatile struct dbdma_cmd *)NULL;
295 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
296 SAA7196_FMTS);
297 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
298 saa_regs[norm][SAA7196_FMTS]);
299 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
300 SAA7196_DPATH);
301 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
302 saa_regs[norm][SAA7196_DPATH]);
303 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->even),
304 bpp | ((clip)? PLANB_CLIPMASK: 0));
305 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->odd),
306 bpp | ((clip)? PLANB_CLIPMASK: 0));
307 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
308 SAA7196_OUTPIX);
309 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
310 saa_regs[norm][SAA7196_OUTPIX]);
311 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
312 SAA7196_HFILT);
313 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
314 saa_regs[norm][SAA7196_HFILT]);
315 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
316 SAA7196_OUTLINE);
317 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
318 saa_regs[norm][SAA7196_OUTLINE]);
319 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_addr),
320 SAA7196_VYP);
321 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->saa_regval),
322 saa_regs[norm][SAA7196_VYP]);
323 return c1;
324}
325
326/******************************/
327/* misc. supporting functions */
328/******************************/
329
330static inline void planb_lock(struct planb *pb)
331{
332 mutex_lock(&pb->lock);
333}
334
335static inline void planb_unlock(struct planb *pb)
336{
337 mutex_unlock(&pb->lock);
338}
339
340/***************/
341/* Driver Core */
342/***************/
343
344static int planb_prepare_open(struct planb *pb)
345{
346 int i, size;
347
348 /* allocate memory for two plus alpha command buffers (size: max lines,
349 plus 40 commands handling, plus 1 alignment), plus dummy command buf,
350 plus clipmask buffer, plus frame grabbing status */
351 size = (pb->tab_size*(2+MAX_GBUFFERS*TAB_FACTOR)+1+MAX_GBUFFERS
352 * PLANB_DUMMY)*sizeof(struct dbdma_cmd)
353 +(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8
354 +MAX_GBUFFERS*sizeof(unsigned int);
355 if ((pb->priv_space = kzalloc (size, GFP_KERNEL)) == 0)
356 return -ENOMEM;
357 pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *)
358 DBDMA_ALIGN (pb->priv_space);
359 pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size;
360 pb->ch1_cmd_phys = virt_to_bus(pb->ch1_cmd);
361 pb->cap_cmd[0] = pb->ch2_cmd + pb->tab_size;
362 pb->pre_cmd[0] = pb->cap_cmd[0] + pb->tab_size * TAB_FACTOR;
363 for (i = 1; i < MAX_GBUFFERS; i++) {
364 pb->cap_cmd[i] = pb->pre_cmd[i-1] + PLANB_DUMMY;
365 pb->pre_cmd[i] = pb->cap_cmd[i] + pb->tab_size * TAB_FACTOR;
366 }
367 pb->frame_stat=(volatile unsigned int *)(pb->pre_cmd[MAX_GBUFFERS-1]
368 + PLANB_DUMMY);
369 pb->mask = (unsigned char *)(pb->frame_stat+MAX_GBUFFERS);
370
371 pb->rawbuf = NULL;
372 pb->rawbuf_size = 0;
373 pb->grabbing = 0;
374 for (i = 0; i < MAX_GBUFFERS; i++) {
375 pb->frame_stat[i] = GBUFFER_UNUSED;
376 pb->gwidth[i] = 0;
377 pb->gheight[i] = 0;
378 pb->gfmt[i] = 0;
379 pb->gnorm_switch[i] = 0;
380#ifndef PLANB_GSCANLINE
381 pb->lsize[i] = 0;
382 pb->lnum[i] = 0;
383#endif /* PLANB_GSCANLINE */
384 }
385 pb->gcount = 0;
386 pb->suspend = 0;
387 pb->last_fr = -999;
388 pb->prev_last_fr = -999;
389
390 /* Reset DMA controllers */
391 planb_dbdma_stop(&pb->planb_base->ch2);
392 planb_dbdma_stop(&pb->planb_base->ch1);
393
394 return 0;
395}
396
397static void planb_prepare_close(struct planb *pb)
398{
399 int i;
400
401 /* make sure the dma's are idle */
402 planb_dbdma_stop(&pb->planb_base->ch2);
403 planb_dbdma_stop(&pb->planb_base->ch1);
404 /* free kernel memory of command buffers */
405 if(pb->priv_space != 0) {
406 kfree (pb->priv_space);
407 pb->priv_space = 0;
408 pb->cmd_buff_inited = 0;
409 }
410 if(pb->rawbuf) {
411 for (i = 0; i < pb->rawbuf_size; i++) {
412 ClearPageReserved(virt_to_page(pb->rawbuf[i]));
413 free_pages((unsigned long)pb->rawbuf[i], 0);
414 }
415 kfree(pb->rawbuf);
416 }
417 pb->rawbuf = NULL;
418}
419
420/*****************************/
421/* overlay support functions */
422/*****************************/
423
424static inline int overlay_is_active(struct planb *pb)
425{
426 unsigned int size = pb->tab_size * sizeof(struct dbdma_cmd);
427 unsigned int caddr = (unsigned)in_le32(&pb->planb_base->ch1.cmdptr);
428
429 return (in_le32(&pb->overlay_last1->cmd_dep) == pb->ch1_cmd_phys)
430 && (caddr < (pb->ch1_cmd_phys + size))
431 && (caddr >= (unsigned)pb->ch1_cmd_phys);
432}
433
434static void overlay_start(struct planb *pb)
435{
436
437 DEBUG("PlanB: overlay_start()\n");
438
439 if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) {
440
441 DEBUG("PlanB: presumably, grabbing is in progress...\n");
442
443 planb_dbdma_stop(&pb->planb_base->ch2);
444 out_le32 (&pb->planb_base->ch2.cmdptr,
445 virt_to_bus(pb->ch2_cmd));
446 planb_dbdma_restart(&pb->planb_base->ch2);
447 st_le16 (&pb->ch1_cmd->command, DBDMA_NOP);
448 tab_cmd_dbdma(pb->last_cmd[pb->last_fr],
449 DBDMA_NOP | BR_ALWAYS,
450 virt_to_bus(pb->ch1_cmd));
451 eieio();
452 pb->prev_last_fr = pb->last_fr;
453 pb->last_fr = -2;
454 if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) {
455 IDEBUG("PlanB: became inactive "
456 "in the mean time... reactivating\n");
457 planb_dbdma_stop(&pb->planb_base->ch1);
458 out_le32 (&pb->planb_base->ch1.cmdptr,
459 virt_to_bus(pb->ch1_cmd));
460 planb_dbdma_restart(&pb->planb_base->ch1);
461 }
462 } else {
463
464 DEBUG("PlanB: currently idle, so can do whatever\n");
465
466 planb_dbdma_stop(&pb->planb_base->ch2);
467 planb_dbdma_stop(&pb->planb_base->ch1);
468 st_le32 (&pb->planb_base->ch2.cmdptr,
469 virt_to_bus(pb->ch2_cmd));
470 st_le32 (&pb->planb_base->ch1.cmdptr,
471 virt_to_bus(pb->ch1_cmd));
472 out_le16 (&pb->ch1_cmd->command, DBDMA_NOP);
473 planb_dbdma_restart(&pb->planb_base->ch2);
474 planb_dbdma_restart(&pb->planb_base->ch1);
475 pb->last_fr = -1;
476 }
477 return;
478}
479
480static void overlay_stop(struct planb *pb)
481{
482 DEBUG("PlanB: overlay_stop()\n");
483
484 if(pb->last_fr == -1) {
485
486 DEBUG("PlanB: no grabbing, it seems...\n");
487
488 planb_dbdma_stop(&pb->planb_base->ch2);
489 planb_dbdma_stop(&pb->planb_base->ch1);
490 pb->last_fr = -999;
491 } else if(pb->last_fr == -2) {
492 unsigned int cmd_dep;
493 tab_cmd_dbdma(pb->cap_cmd[pb->prev_last_fr], DBDMA_STOP, 0);
494 eieio();
495 cmd_dep = (unsigned int)in_le32(&pb->overlay_last1->cmd_dep);
496 if(overlay_is_active(pb)) {
497
498 DEBUG("PlanB: overlay is currently active\n");
499
500 planb_dbdma_stop(&pb->planb_base->ch2);
501 planb_dbdma_stop(&pb->planb_base->ch1);
502 if(cmd_dep != pb->ch1_cmd_phys) {
503 out_le32(&pb->planb_base->ch1.cmdptr,
504 virt_to_bus(pb->overlay_last1));
505 planb_dbdma_restart(&pb->planb_base->ch1);
506 }
507 }
508 pb->last_fr = pb->prev_last_fr;
509 pb->prev_last_fr = -999;
510 }
511 return;
512}
513
514static void suspend_overlay(struct planb *pb)
515{
516 int fr = -1;
517 struct dbdma_cmd last;
518
519 DEBUG("PlanB: suspend_overlay: %d\n", pb->suspend);
520
521 if(pb->suspend++)
522 return;
523 if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) {
524 if(pb->last_fr == -2) {
525 fr = pb->prev_last_fr;
526 memcpy(&last, (void*)pb->last_cmd[fr], sizeof(last));
527 tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0);
528 }
529 if(overlay_is_active(pb)) {
530 planb_dbdma_stop(&pb->planb_base->ch2);
531 planb_dbdma_stop(&pb->planb_base->ch1);
532 pb->suspended.overlay = 1;
533 pb->suspended.frame = fr;
534 memcpy(&pb->suspended.cmd, &last, sizeof(last));
535 return;
536 }
537 }
538 pb->suspended.overlay = 0;
539 pb->suspended.frame = fr;
540 memcpy(&pb->suspended.cmd, &last, sizeof(last));
541 return;
542}
543
544static void resume_overlay(struct planb *pb)
545{
546
547 DEBUG("PlanB: resume_overlay: %d\n", pb->suspend);
548
549 if(pb->suspend > 1)
550 return;
551 if(pb->suspended.frame != -1) {
552 memcpy((void*)pb->last_cmd[pb->suspended.frame],
553 &pb->suspended.cmd, sizeof(pb->suspended.cmd));
554 }
555 if(ACTIVE & in_le32(&pb->planb_base->ch1.status)) {
556 goto finish;
557 }
558 if(pb->suspended.overlay) {
559
560 DEBUG("PlanB: overlay being resumed\n");
561
562 st_le16 (&pb->ch1_cmd->command, DBDMA_NOP);
563 st_le16 (&pb->ch2_cmd->command, DBDMA_NOP);
564 /* Set command buffer addresses */
565 st_le32(&pb->planb_base->ch1.cmdptr,
566 virt_to_bus(pb->overlay_last1));
567 out_le32(&pb->planb_base->ch2.cmdptr,
568 virt_to_bus(pb->overlay_last2));
569 /* Start the DMA controller */
570 out_le32 (&pb->planb_base->ch2.control,
571 PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE));
572 out_le32 (&pb->planb_base->ch1.control,
573 PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE));
574 } else if(pb->suspended.frame != -1) {
575 out_le32(&pb->planb_base->ch1.cmdptr,
576 virt_to_bus(pb->last_cmd[pb->suspended.frame]));
577 out_le32 (&pb->planb_base->ch1.control,
578 PLANB_CLR(PAUSE) | PLANB_SET(RUN|WAKE));
579 }
580
581finish:
582 pb->suspend--;
583 wake_up_interruptible(&pb->suspendq);
584}
585
586static void add_clip(struct planb *pb, struct video_clip *clip)
587{
588 volatile unsigned char *base;
589 int xc = clip->x, yc = clip->y;
590 int wc = clip->width, hc = clip->height;
591 int ww = pb->win.width, hw = pb->win.height;
592 int x, y, xtmp1, xtmp2;
593
594 DEBUG("PlanB: clip %dx%d+%d+%d\n", wc, hc, xc, yc);
595
596 if(xc < 0) {
597 wc += xc;
598 xc = 0;
599 }
600 if(yc < 0) {
601 hc += yc;
602 yc = 0;
603 }
604 if(xc + wc > ww)
605 wc = ww - xc;
606 if(wc <= 0) /* Nothing to do */
607 return;
608 if(yc + hc > hw)
609 hc = hw - yc;
610
611 for (y = yc; y < yc+hc; y++) {
612 xtmp1=xc>>3;
613 xtmp2=(xc+wc)>>3;
614 base = pb->mask + y*96;
615 if(xc != 0 || wc >= 8)
616 *(base + xtmp1) &= (unsigned char)(0x00ff &
617 (0xff00 >> (xc&7)));
618 for (x = xtmp1 + 1; x < xtmp2; x++) {
619 *(base + x) = 0;
620 }
621 if(xc < (ww & ~0x7))
622 *(base + xtmp2) &= (unsigned char)(0x00ff >>
623 ((xc+wc) & 7));
624 }
625
626 return;
627}
628
629static void fill_cmd_buff(struct planb *pb)
630{
631 int restore = 0;
632 volatile struct dbdma_cmd last;
633
634 DEBUG("PlanB: fill_cmd_buff()\n");
635
636 if(pb->overlay_last1 != pb->ch1_cmd) {
637 restore = 1;
638 last = *(pb->overlay_last1);
639 }
640 memset ((void *) pb->ch1_cmd, 0, 2 * pb->tab_size
641 * sizeof(struct dbdma_cmd));
642 cmd_buff (pb);
643 if(restore)
644 *(pb->overlay_last1) = last;
645 if(pb->suspended.overlay) {
646 unsigned long jump_addr = in_le32(&pb->overlay_last1->cmd_dep);
647 if(jump_addr != pb->ch1_cmd_phys) {
648 int i;
649
650 DEBUG("PlanB: adjusting ch1's jump address\n");
651
652 for(i = 0; i < MAX_GBUFFERS; i++) {
653 if(pb->need_pre_capture[i]) {
654 if(jump_addr == virt_to_bus(pb->pre_cmd[i]))
655 goto found;
656 } else {
657 if(jump_addr == virt_to_bus(pb->cap_cmd[i]))
658 goto found;
659 }
660 }
661
662 DEBUG("PlanB: not found...\n");
663
664 goto out;
665found:
666 if(pb->need_pre_capture[i])
667 out_le32(&pb->pre_cmd[i]->phy_addr,
668 virt_to_bus(pb->overlay_last1));
669 else
670 out_le32(&pb->cap_cmd[i]->phy_addr,
671 virt_to_bus(pb->overlay_last1));
672 }
673 }
674out:
675 pb->cmd_buff_inited = 1;
676
677 return;
678}
679
680static void cmd_buff(struct planb *pb)
681{
682 int i, bpp, count, nlines, stepsize, interlace;
683 unsigned long base, jump, addr_com, addr_dep;
684 volatile struct dbdma_cmd *c1 = pb->ch1_cmd;
685 volatile struct dbdma_cmd *c2 = pb->ch2_cmd;
686
687 interlace = pb->win.interlace;
688 bpp = pb->win.bpp;
689 count = (bpp * ((pb->win.x + pb->win.width > pb->win.swidth) ?
690 (pb->win.swidth - pb->win.x) : pb->win.width));
691 nlines = ((pb->win.y + pb->win.height > pb->win.sheight) ?
692 (pb->win.sheight - pb->win.y) : pb->win.height);
693
694 /* Do video in: */
695
696 /* Preamble commands: */
697 addr_com = virt_to_bus(c1);
698 addr_dep = virt_to_bus(&c1->cmd_dep);
699 tab_cmd_dbdma(c1++, DBDMA_NOP, 0);
700 jump = virt_to_bus(c1+16); /* 14 by cmd_geo_setup() and 2 for padding */
701 if((c1 = cmd_geo_setup(c1, pb->win.width, pb->win.height, interlace,
702 bpp, 1, pb)) == NULL) {
703 printk(KERN_WARNING "PlanB: encountered serious problems\n");
704 tab_cmd_dbdma(pb->ch1_cmd + 1, DBDMA_STOP, 0);
705 tab_cmd_dbdma(pb->ch2_cmd + 1, DBDMA_STOP, 0);
706 return;
707 }
708 tab_cmd_store(c1++, addr_com, (unsigned)(DBDMA_NOP | BR_ALWAYS) << 16);
709 tab_cmd_store(c1++, addr_dep, jump);
710 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel),
711 PLANB_SET(FIELD_SYNC));
712 /* (1) wait for field sync to be set */
713 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
714 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
715 PLANB_SET(ODD_FIELD));
716 /* wait for field sync to be cleared */
717 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
718 /* if not odd field, wait until field sync is set again */
719 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++;
720 /* assert ch_sync to ch2 */
721 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch2.control),
722 PLANB_SET(CH_SYNC));
723 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
724 PLANB_SET(DMA_ABORT));
725
726 base = (pb->frame_buffer_phys + pb->offset + pb->win.y * (pb->win.bpl
727 + pb->win.pad) + pb->win.x * bpp);
728
729 if (interlace) {
730 stepsize = 2;
731 jump = virt_to_bus(c1 + (nlines + 1) / 2);
732 } else {
733 stepsize = 1;
734 jump = virt_to_bus(c1 + nlines);
735 }
736
737 /* even field data: */
738 for (i=0; i < nlines; i += stepsize, c1++)
739 tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET,
740 count, base + i * (pb->win.bpl + pb->win.pad), jump);
741
742 /* For non-interlaced, we use even fields only */
743 if (!interlace)
744 goto cmd_tab_data_end;
745
746 /* Resync to odd field */
747 /* (2) wait for field sync to be set */
748 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
749 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
750 PLANB_SET(ODD_FIELD));
751 /* wait for field sync to be cleared */
752 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
753 /* if not odd field, wait until field sync is set again */
754 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
755 /* assert ch_sync to ch2 */
756 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch2.control),
757 PLANB_SET(CH_SYNC));
758 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
759 PLANB_SET(DMA_ABORT));
760
761 /* odd field data: */
762 jump = virt_to_bus(c1 + nlines / 2);
763 for (i=1; i < nlines; i += stepsize, c1++)
764 tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count,
765 base + i * (pb->win.bpl + pb->win.pad), jump);
766
767 /* And jump back to the start */
768cmd_tab_data_end:
769 pb->overlay_last1 = c1; /* keep a pointer to the last command */
770 tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->ch1_cmd));
771
772 /* Clipmask command buffer */
773
774 /* Preamble commands: */
775 tab_cmd_dbdma(c2++, DBDMA_NOP, 0);
776 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.wait_sel),
777 PLANB_SET(CH_SYNC));
778 /* wait until ch1 asserts ch_sync */
779 tab_cmd_dbdma(c2++, DBDMA_NOP | WAIT_IFCLR, 0);
780 /* clear ch_sync asserted by ch1 */
781 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.control),
782 PLANB_CLR(CH_SYNC));
783 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.wait_sel),
784 PLANB_SET(FIELD_SYNC));
785 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel),
786 PLANB_SET(ODD_FIELD));
787
788 /* jump to end of even field if appropriate */
789 /* this points to (interlace)? pos. C: pos. B */
790 jump = (interlace) ? virt_to_bus(c2 + (nlines + 1) / 2 + 2):
791 virt_to_bus(c2 + nlines + 2);
792 /* if odd field, skip over to odd field clipmasking */
793 tab_cmd_dbdma(c2++, DBDMA_NOP | BR_IFSET, jump);
794
795 /* even field mask: */
796 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel),
797 PLANB_SET(DMA_ABORT));
798 /* this points to pos. B */
799 jump = (interlace) ? virt_to_bus(c2 + nlines + 1):
800 virt_to_bus(c2 + nlines);
801 base = virt_to_bus(pb->mask);
802 for (i=0; i < nlines; i += stepsize, c2++)
803 tab_cmd_gen(c2, OUTPUT_MORE | KEY_STREAM0 | BR_IFSET, 96,
804 base + i * 96, jump);
805
806 /* For non-interlaced, we use only even fields */
807 if(!interlace)
808 goto cmd_tab_mask_end;
809
810 /* odd field mask: */
811/* C */ tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch2.br_sel),
812 PLANB_SET(DMA_ABORT));
813 /* this points to pos. B */
814 jump = virt_to_bus(c2 + nlines / 2);
815 base = virt_to_bus(pb->mask);
816 for (i=1; i < nlines; i += 2, c2++) /* abort if set */
817 tab_cmd_gen(c2, OUTPUT_MORE | KEY_STREAM0 | BR_IFSET, 96,
818 base + i * 96, jump);
819
820 /* Inform channel 1 and jump back to start */
821cmd_tab_mask_end:
822 /* ok, I just realized this is kind of flawed. */
823 /* this part is reached only after odd field clipmasking. */
824 /* wanna clean up? */
825 /* wait for field sync to be set */
826 /* corresponds to fsync (1) of ch1 */
827/* B */ tab_cmd_dbdma(c2++, DBDMA_NOP | WAIT_IFCLR, 0);
828 /* restart ch1, meant to clear any dead bit or something */
829 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch1.control),
830 PLANB_CLR(RUN));
831 tab_cmd_store(c2++, (unsigned)(&pb->planb_base_phys->ch1.control),
832 PLANB_SET(RUN));
833 pb->overlay_last2 = c2; /* keep a pointer to the last command */
834 /* start over even field clipmasking */
835 tab_cmd_dbdma(c2, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->ch2_cmd));
836
837 eieio();
838 return;
839}
840
841/*********************************/
842/* grabdisplay support functions */
843/*********************************/
844
845static int palette2fmt[] = {
846 0,
847 PLANB_GRAY,
848 0,
849 0,
850 0,
851 PLANB_COLOUR32,
852 PLANB_COLOUR15,
853 0,
854 0,
855 0,
856 0,
857 0,
858 0,
859 0,
860 0,
861};
862
863#define PLANB_PALETTE_MAX 15
864
865static int vgrab(struct planb *pb, struct video_mmap *mp)
866{
867 unsigned int fr = mp->frame;
868 unsigned int format;
869
870 if(pb->rawbuf==NULL) {
871 int err;
872 if((err=grabbuf_alloc(pb)))
873 return err;
874 }
875
876 IDEBUG("PlanB: grab %d: %dx%d(%u)\n", pb->grabbing,
877 mp->width, mp->height, fr);
878
879 if(pb->grabbing >= MAX_GBUFFERS)
880 return -ENOBUFS;
881 if(fr > (MAX_GBUFFERS - 1) || fr < 0)
882 return -EINVAL;
883 if(mp->height <= 0 || mp->width <= 0)
884 return -EINVAL;
885 if(mp->format < 0 || mp->format >= PLANB_PALETTE_MAX)
886 return -EINVAL;
887 if((format = palette2fmt[mp->format]) == 0)
888 return -EINVAL;
889 if (mp->height * mp->width * format > PLANB_MAX_FBUF) /* format = bpp */
890 return -EINVAL;
891
892 planb_lock(pb);
893 if(mp->width != pb->gwidth[fr] || mp->height != pb->gheight[fr] ||
894 format != pb->gfmt[fr] || (pb->gnorm_switch[fr])) {
895 int i;
896#ifndef PLANB_GSCANLINE
897 unsigned int osize = pb->gwidth[fr] * pb->gheight[fr]
898 * pb->gfmt[fr];
899 unsigned int nsize = mp->width * mp->height * format;
900#endif
901
902 IDEBUG("PlanB: gwidth = %d, gheight = %d, mp->format = %u\n",
903 mp->width, mp->height, mp->format);
904
905#ifndef PLANB_GSCANLINE
906 if(pb->gnorm_switch[fr])
907 nsize = 0;
908 if (nsize < osize) {
909 for(i = pb->gbuf_idx[fr]; osize > 0; i++) {
910 memset((void *)pb->rawbuf[i], 0, PAGE_SIZE);
911 osize -= PAGE_SIZE;
912 }
913 }
914 for(i = pb->l_fr_addr_idx[fr]; i < pb->l_fr_addr_idx[fr]
915 + pb->lnum[fr]; i++)
916 memset((void *)pb->rawbuf[i], 0, PAGE_SIZE);
917#else
918/* XXX TODO */
919/*
920 if(pb->gnorm_switch[fr])
921 memset((void *)pb->gbuffer[fr], 0,
922 pb->gbytes_per_line * pb->gheight[fr]);
923 else {
924 if(mp->
925 for(i = 0; i < pb->gheight[fr]; i++) {
926 memset((void *)(pb->gbuffer[fr]
927 + pb->gbytes_per_line * i
928 }
929 }
930*/
931#endif
932 pb->gwidth[fr] = mp->width;
933 pb->gheight[fr] = mp->height;
934 pb->gfmt[fr] = format;
935 pb->last_cmd[fr] = setup_grab_cmd(fr, pb);
936 planb_pre_capture(fr, pb->gfmt[fr], pb); /* gfmt = bpp */
937 pb->need_pre_capture[fr] = 1;
938 pb->gnorm_switch[fr] = 0;
939 } else
940 pb->need_pre_capture[fr] = 0;
941 pb->frame_stat[fr] = GBUFFER_GRABBING;
942 if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) {
943
944 IDEBUG("PlanB: ch1 inactive, initiating grabbing\n");
945
946 planb_dbdma_stop(&pb->planb_base->ch1);
947 if(pb->need_pre_capture[fr]) {
948
949 IDEBUG("PlanB: padding pre-capture sequence\n");
950
951 out_le32 (&pb->planb_base->ch1.cmdptr,
952 virt_to_bus(pb->pre_cmd[fr]));
953 } else {
954 tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0);
955 tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0);
956 /* let's be on the safe side. here is not timing critical. */
957 tab_cmd_dbdma((pb->cap_cmd[fr] + 1), DBDMA_NOP, 0);
958 out_le32 (&pb->planb_base->ch1.cmdptr,
959 virt_to_bus(pb->cap_cmd[fr]));
960 }
961 planb_dbdma_restart(&pb->planb_base->ch1);
962 pb->last_fr = fr;
963 } else {
964 int i;
965
966 IDEBUG("PlanB: ch1 active, grabbing being queued\n");
967
968 if((pb->last_fr == -1) || ((pb->last_fr == -2) &&
969 overlay_is_active(pb))) {
970
971 IDEBUG("PlanB: overlay is active, grabbing defered\n");
972
973 tab_cmd_dbdma(pb->last_cmd[fr],
974 DBDMA_NOP | BR_ALWAYS,
975 virt_to_bus(pb->ch1_cmd));
976 if(pb->need_pre_capture[fr]) {
977
978 IDEBUG("PlanB: padding pre-capture sequence\n");
979
980 tab_cmd_store(pb->pre_cmd[fr],
981 virt_to_bus(&pb->overlay_last1->cmd_dep),
982 virt_to_bus(pb->ch1_cmd));
983 eieio();
984 out_le32 (&pb->overlay_last1->cmd_dep,
985 virt_to_bus(pb->pre_cmd[fr]));
986 } else {
987 tab_cmd_store(pb->cap_cmd[fr],
988 virt_to_bus(&pb->overlay_last1->cmd_dep),
989 virt_to_bus(pb->ch1_cmd));
990 tab_cmd_dbdma((pb->cap_cmd[fr] + 1),
991 DBDMA_NOP, 0);
992 eieio();
993 out_le32 (&pb->overlay_last1->cmd_dep,
994 virt_to_bus(pb->cap_cmd[fr]));
995 }
996 for(i = 0; overlay_is_active(pb) && i < 999; i++)
997 IDEBUG("PlanB: waiting for overlay done\n");
998 tab_cmd_dbdma(pb->ch1_cmd, DBDMA_NOP, 0);
999 pb->prev_last_fr = fr;
1000 pb->last_fr = -2;
1001 } else if(pb->last_fr == -2) {
1002
1003 IDEBUG("PlanB: mixed mode detected, grabbing"
1004 " will be done before activating overlay\n");
1005
1006 tab_cmd_dbdma(pb->ch1_cmd, DBDMA_NOP, 0);
1007 if(pb->need_pre_capture[fr]) {
1008
1009 IDEBUG("PlanB: padding pre-capture sequence\n");
1010
1011 tab_cmd_dbdma(pb->last_cmd[pb->prev_last_fr],
1012 DBDMA_NOP | BR_ALWAYS,
1013 virt_to_bus(pb->pre_cmd[fr]));
1014 eieio();
1015 } else {
1016 tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0);
1017 if(pb->gwidth[pb->prev_last_fr] !=
1018 pb->gwidth[fr]
1019 || pb->gheight[pb->prev_last_fr] !=
1020 pb->gheight[fr]
1021 || pb->gfmt[pb->prev_last_fr] !=
1022 pb->gfmt[fr])
1023 tab_cmd_dbdma((pb->cap_cmd[fr] + 1),
1024 DBDMA_NOP, 0);
1025 else
1026 tab_cmd_dbdma((pb->cap_cmd[fr] + 1),
1027 DBDMA_NOP | BR_ALWAYS,
1028 virt_to_bus(pb->cap_cmd[fr] + 16));
1029 tab_cmd_dbdma(pb->last_cmd[pb->prev_last_fr],
1030 DBDMA_NOP | BR_ALWAYS,
1031 virt_to_bus(pb->cap_cmd[fr]));
1032 eieio();
1033 }
1034 tab_cmd_dbdma(pb->last_cmd[fr],
1035 DBDMA_NOP | BR_ALWAYS,
1036 virt_to_bus(pb->ch1_cmd));
1037 eieio();
1038 pb->prev_last_fr = fr;
1039 pb->last_fr = -2;
1040 } else {
1041
1042 IDEBUG("PlanB: active grabbing session detected\n");
1043
1044 if(pb->need_pre_capture[fr]) {
1045
1046 IDEBUG("PlanB: padding pre-capture sequence\n");
1047
1048 tab_cmd_dbdma(pb->last_cmd[pb->last_fr],
1049 DBDMA_NOP | BR_ALWAYS,
1050 virt_to_bus(pb->pre_cmd[fr]));
1051 eieio();
1052 } else {
1053 tab_cmd_dbdma(pb->last_cmd[fr], DBDMA_STOP, 0);
1054 tab_cmd_dbdma(pb->cap_cmd[fr], DBDMA_NOP, 0);
1055 if(pb->gwidth[pb->last_fr] != pb->gwidth[fr]
1056 || pb->gheight[pb->last_fr] !=
1057 pb->gheight[fr]
1058 || pb->gfmt[pb->last_fr] !=
1059 pb->gfmt[fr])
1060 tab_cmd_dbdma((pb->cap_cmd[fr] + 1),
1061 DBDMA_NOP, 0);
1062 else
1063 tab_cmd_dbdma((pb->cap_cmd[fr] + 1),
1064 DBDMA_NOP | BR_ALWAYS,
1065 virt_to_bus(pb->cap_cmd[fr] + 16));
1066 tab_cmd_dbdma(pb->last_cmd[pb->last_fr],
1067 DBDMA_NOP | BR_ALWAYS,
1068 virt_to_bus(pb->cap_cmd[fr]));
1069 eieio();
1070 }
1071 pb->last_fr = fr;
1072 }
1073 if(!(ACTIVE & in_le32(&pb->planb_base->ch1.status))) {
1074
1075 IDEBUG("PlanB: became inactive in the mean time..."
1076 "reactivating\n");
1077
1078 planb_dbdma_stop(&pb->planb_base->ch1);
1079 out_le32 (&pb->planb_base->ch1.cmdptr,
1080 virt_to_bus(pb->cap_cmd[fr]));
1081 planb_dbdma_restart(&pb->planb_base->ch1);
1082 }
1083 }
1084 pb->grabbing++;
1085 planb_unlock(pb);
1086
1087 return 0;
1088}
1089
1090static void planb_pre_capture(int fr, int bpp, struct planb *pb)
1091{
1092 volatile struct dbdma_cmd *c1 = pb->pre_cmd[fr];
1093 int interlace = (pb->gheight[fr] > pb->maxlines/2)? 1: 0;
1094
1095 tab_cmd_dbdma(c1++, DBDMA_NOP, 0);
1096 if((c1 = cmd_geo_setup(c1, pb->gwidth[fr], pb->gheight[fr], interlace,
1097 bpp, 0, pb)) == NULL) {
1098 printk(KERN_WARNING "PlanB: encountered some problems\n");
1099 tab_cmd_dbdma(pb->pre_cmd[fr] + 1, DBDMA_STOP, 0);
1100 return;
1101 }
1102 /* Sync to even field */
1103 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel),
1104 PLANB_SET(FIELD_SYNC));
1105 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
1106 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1107 PLANB_SET(ODD_FIELD));
1108 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
1109 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++;
1110 tab_cmd_dbdma(c1++, DBDMA_NOP | INTR_ALWAYS, 0);
1111 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1112 PLANB_SET(DMA_ABORT));
1113 /* For non-interlaced, we use even fields only */
1114 if (pb->gheight[fr] <= pb->maxlines/2)
1115 goto cmd_tab_data_end;
1116 /* Sync to odd field */
1117 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
1118 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1119 PLANB_SET(ODD_FIELD));
1120 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
1121 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
1122 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1123 PLANB_SET(DMA_ABORT));
1124cmd_tab_data_end:
1125 tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(pb->cap_cmd[fr]));
1126
1127 eieio();
1128}
1129
1130static volatile struct dbdma_cmd *setup_grab_cmd(int fr, struct planb *pb)
1131{
1132 int i, bpp, count, nlines, stepsize, interlace;
1133#ifdef PLANB_GSCANLINE
1134 int scanline;
1135#else
1136 int nlpp, leftover1;
1137 unsigned long base;
1138#endif
1139 unsigned long jump;
1140 int pagei;
1141 volatile struct dbdma_cmd *c1;
1142 volatile struct dbdma_cmd *jump_addr;
1143
1144 c1 = pb->cap_cmd[fr];
1145 interlace = (pb->gheight[fr] > pb->maxlines/2)? 1: 0;
1146 bpp = pb->gfmt[fr]; /* gfmt = bpp */
1147 count = bpp * pb->gwidth[fr];
1148 nlines = pb->gheight[fr];
1149#ifdef PLANB_GSCANLINE
1150 scanline = pb->gbytes_per_line;
1151#else
1152 pb->lsize[fr] = count;
1153 pb->lnum[fr] = 0;
1154#endif
1155
1156 /* Do video in: */
1157
1158 /* Preamble commands: */
1159 tab_cmd_dbdma(c1++, DBDMA_NOP, 0);
1160 tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, virt_to_bus(c1 + 16)); c1++;
1161 if((c1 = cmd_geo_setup(c1, pb->gwidth[fr], pb->gheight[fr], interlace,
1162 bpp, 0, pb)) == NULL) {
1163 printk(KERN_WARNING "PlanB: encountered serious problems\n");
1164 tab_cmd_dbdma(pb->cap_cmd[fr] + 1, DBDMA_STOP, 0);
1165 return (pb->cap_cmd[fr] + 2);
1166 }
1167 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.wait_sel),
1168 PLANB_SET(FIELD_SYNC));
1169 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
1170 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1171 PLANB_SET(ODD_FIELD));
1172 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
1173 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFSET, virt_to_bus(c1-3)); c1++;
1174 tab_cmd_dbdma(c1++, DBDMA_NOP | INTR_ALWAYS, 0);
1175 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1176 PLANB_SET(DMA_ABORT));
1177
1178 if (interlace) {
1179 stepsize = 2;
1180 jump_addr = c1 + TAB_FACTOR * (nlines + 1) / 2;
1181 } else {
1182 stepsize = 1;
1183 jump_addr = c1 + TAB_FACTOR * nlines;
1184 }
1185 jump = virt_to_bus(jump_addr);
1186
1187 /* even field data: */
1188
1189 pagei = pb->gbuf_idx[fr];
1190#ifdef PLANB_GSCANLINE
1191 for (i = 0; i < nlines; i += stepsize) {
1192 tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count,
1193 virt_to_bus(pb->rawbuf[pagei
1194 + i * scanline / PAGE_SIZE]), jump);
1195 }
1196#else
1197 i = 0;
1198 leftover1 = 0;
1199 do {
1200 int j;
1201
1202 base = virt_to_bus(pb->rawbuf[pagei]);
1203 nlpp = (PAGE_SIZE - leftover1) / count / stepsize;
1204 for(j = 0; j < nlpp && i < nlines; j++, i += stepsize, c1++)
1205 tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET,
1206 count, base + count * j * stepsize + leftover1, jump);
1207 if(i < nlines) {
1208 int lov0 = PAGE_SIZE - count * nlpp * stepsize - leftover1;
1209
1210 if(lov0 == 0)
1211 leftover1 = 0;
1212 else {
1213 if(lov0 >= count) {
1214 tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count, base
1215 + count * nlpp * stepsize + leftover1, jump);
1216 } else {
1217 pb->l_to_addr[fr][pb->lnum[fr]] = pb->rawbuf[pagei]
1218 + count * nlpp * stepsize + leftover1;
1219 pb->l_to_next_idx[fr][pb->lnum[fr]] = pagei + 1;
1220 pb->l_to_next_size[fr][pb->lnum[fr]] = count - lov0;
1221 tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count,
1222 virt_to_bus(pb->rawbuf[pb->l_fr_addr_idx[fr]
1223 + pb->lnum[fr]]), jump);
1224 if(++pb->lnum[fr] > MAX_LNUM)
1225 pb->lnum[fr]--;
1226 }
1227 leftover1 = count * stepsize - lov0;
1228 i += stepsize;
1229 }
1230 }
1231 pagei++;
1232 } while(i < nlines);
1233 tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, jump);
1234 c1 = jump_addr;
1235#endif /* PLANB_GSCANLINE */
1236
1237 /* For non-interlaced, we use even fields only */
1238 if (!interlace)
1239 goto cmd_tab_data_end;
1240
1241 /* Sync to odd field */
1242 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFCLR, 0);
1243 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1244 PLANB_SET(ODD_FIELD));
1245 tab_cmd_dbdma(c1++, DBDMA_NOP | WAIT_IFSET, 0);
1246 tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
1247 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
1248 PLANB_SET(DMA_ABORT));
1249
1250 /* odd field data: */
1251 jump_addr = c1 + TAB_FACTOR * nlines / 2;
1252 jump = virt_to_bus(jump_addr);
1253#ifdef PLANB_GSCANLINE
1254 for (i = 1; i < nlines; i += stepsize) {
1255 tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count,
1256 virt_to_bus(pb->rawbuf[pagei
1257 + i * scanline / PAGE_SIZE]), jump);
1258 }
1259#else
1260 i = 1;
1261 leftover1 = 0;
1262 pagei = pb->gbuf_idx[fr];
1263 if(nlines <= 1)
1264 goto skip;
1265 do {
1266 int j;
1267
1268 base = virt_to_bus(pb->rawbuf[pagei]);
1269 nlpp = (PAGE_SIZE - leftover1) / count / stepsize;
1270 if(leftover1 >= count) {
1271 tab_cmd_gen(c1++, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count,
1272 base + leftover1 - count, jump);
1273 i += stepsize;
1274 }
1275 for(j = 0; j < nlpp && i < nlines; j++, i += stepsize, c1++)
1276 tab_cmd_gen(c1, INPUT_MORE | KEY_STREAM0 | BR_IFSET, count,
1277 base + count * (j * stepsize + 1) + leftover1, jump);
1278 if(i < nlines) {
1279 int lov0 = PAGE_SIZE - count * nlpp * stepsize - leftover1;
1280
1281 if(lov0 == 0)
1282 leftover1 = 0;
1283 else {
1284 if(lov0 > count) {
1285 pb->l_to_addr[fr][pb->lnum[fr]] = pb->rawbuf[pagei]
1286 + count * (nlpp * stepsize + 1) + leftover1;
1287 pb->l_to_next_idx[fr][pb->lnum[fr]] = pagei + 1;
1288 pb->l_to_next_size[fr][pb->lnum[fr]] = count * stepsize
1289 - lov0;
1290 tab_cmd_gen(c1++, INPUT_MORE | BR_IFSET, count,
1291 virt_to_bus(pb->rawbuf[pb->l_fr_addr_idx[fr]
1292 + pb->lnum[fr]]), jump);
1293 if(++pb->lnum[fr] > MAX_LNUM)
1294 pb->lnum[fr]--;
1295 i += stepsize;
1296 }
1297 leftover1 = count * stepsize - lov0;
1298 }
1299 }
1300 pagei++;
1301 } while(i < nlines);
1302skip:
1303 tab_cmd_dbdma(c1, DBDMA_NOP | BR_ALWAYS, jump);
1304 c1 = jump_addr;
1305#endif /* PLANB_GSCANLINE */
1306
1307cmd_tab_data_end:
1308 tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->intr_stat),
1309 (fr << 9) | PLANB_FRM_IRQ | PLANB_GEN_IRQ);
1310 /* stop it */
1311 tab_cmd_dbdma(c1, DBDMA_STOP, 0);
1312
1313 eieio();
1314 return c1;
1315}
1316
1317static irqreturn_t planb_irq(int irq, void *dev_id)
1318{
1319 unsigned int stat, astat;
1320 struct planb *pb = (struct planb *)dev_id;
1321
1322 IDEBUG("PlanB: planb_irq()\n");
1323
1324 /* get/clear interrupt status bits */
1325 eieio();
1326 stat = in_le32(&pb->planb_base->intr_stat);
1327 astat = stat & pb->intr_mask;
1328 out_le32(&pb->planb_base->intr_stat, PLANB_FRM_IRQ
1329 & ~astat & stat & ~PLANB_GEN_IRQ);
1330 IDEBUG("PlanB: stat = %X, astat = %X\n", stat, astat);
1331
1332 if(astat & PLANB_FRM_IRQ) {
1333 unsigned int fr = stat >> 9;
1334#ifndef PLANB_GSCANLINE
1335 int i;
1336#endif
1337 IDEBUG("PlanB: PLANB_FRM_IRQ\n");
1338
1339 pb->gcount++;
1340
1341 IDEBUG("PlanB: grab %d: fr = %d, gcount = %d\n",
1342 pb->grabbing, fr, pb->gcount);
1343#ifndef PLANB_GSCANLINE
1344 IDEBUG("PlanB: %d * %d bytes are being copied over\n",
1345 pb->lnum[fr], pb->lsize[fr]);
1346 for(i = 0; i < pb->lnum[fr]; i++) {
1347 int first = pb->lsize[fr] - pb->l_to_next_size[fr][i];
1348
1349 memcpy(pb->l_to_addr[fr][i],
1350 pb->rawbuf[pb->l_fr_addr_idx[fr] + i],
1351 first);
1352 memcpy(pb->rawbuf[pb->l_to_next_idx[fr][i]],
1353 pb->rawbuf[pb->l_fr_addr_idx[fr] + i] + first,
1354 pb->l_to_next_size[fr][i]);
1355 }
1356#endif
1357 pb->frame_stat[fr] = GBUFFER_DONE;
1358 pb->grabbing--;
1359 wake_up_interruptible(&pb->capq);
1360 return IRQ_HANDLED;
1361 }
1362 /* incorrect interrupts? */
1363 pb->intr_mask = PLANB_CLR_IRQ;
1364 out_le32(&pb->planb_base->intr_stat, PLANB_CLR_IRQ);
1365 printk(KERN_ERR "PlanB: IRQ lockup, cleared intrrupts"
1366 " unconditionally\n");
1367 return IRQ_HANDLED;
1368}
1369
1370/*******************************
1371 * Device Operations functions *
1372 *******************************/
1373
1374static int planb_open(struct video_device *dev, int mode)
1375{
1376 struct planb *pb = (struct planb *)dev;
1377
1378 if (pb->user == 0) {
1379 int err;
1380 if((err = planb_prepare_open(pb)) != 0)
1381 return err;
1382 }
1383 pb->user++;
1384
1385 DEBUG("PlanB: device opened\n");
1386 return 0;
1387}
1388
1389static void planb_close(struct video_device *dev)
1390{
1391 struct planb *pb = (struct planb *)dev;
1392
1393 if(pb->user < 1) /* ??? */
1394 return;
1395 planb_lock(pb);
1396 if (pb->user == 1) {
1397 if (pb->overlay) {
1398 planb_dbdma_stop(&pb->planb_base->ch2);
1399 planb_dbdma_stop(&pb->planb_base->ch1);
1400 pb->overlay = 0;
1401 }
1402 planb_prepare_close(pb);
1403 }
1404 pb->user--;
1405 planb_unlock(pb);
1406
1407 DEBUG("PlanB: device closed\n");
1408}
1409
1410static long planb_read(struct video_device *v, char *buf, unsigned long count,
1411 int nonblock)
1412{
1413 DEBUG("planb: read request\n");
1414 return -EINVAL;
1415}
1416
1417static long planb_write(struct video_device *v, const char *buf,
1418 unsigned long count, int nonblock)
1419{
1420 DEBUG("planb: write request\n");
1421 return -EINVAL;
1422}
1423
1424static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
1425{
1426 struct planb *pb=(struct planb *)dev;
1427
1428 switch (cmd)
1429 {
1430 case VIDIOCGCAP:
1431 {
1432 struct video_capability b;
1433
1434 DEBUG("PlanB: IOCTL VIDIOCGCAP\n");
1435
1436 strcpy (b.name, pb->video_dev.name);
1437 b.type = VID_TYPE_OVERLAY | VID_TYPE_CLIPPING |
1438 VID_TYPE_FRAMERAM | VID_TYPE_SCALES |
1439 VID_TYPE_CAPTURE;
1440 b.channels = 2; /* composite & svhs */
1441 b.audios = 0;
1442 b.maxwidth = PLANB_MAXPIXELS;
1443 b.maxheight = PLANB_MAXLINES;
1444 b.minwidth = 32; /* wild guess */
1445 b.minheight = 32;
1446 if (copy_to_user(arg,&b,sizeof(b)))
1447 return -EFAULT;
1448 return 0;
1449 }
1450 case VIDIOCSFBUF:
1451 {
1452 struct video_buffer v;
1453 unsigned short bpp;
1454 unsigned int fmt;
1455
1456 DEBUG("PlanB: IOCTL VIDIOCSFBUF\n");
1457
1458 if (!capable(CAP_SYS_ADMIN)
1459 || !capable(CAP_SYS_RAWIO))
1460 return -EPERM;
1461 if (copy_from_user(&v, arg,sizeof(v)))
1462 return -EFAULT;
1463 planb_lock(pb);
1464 switch(v.depth) {
1465 case 8:
1466 bpp = 1;
1467 fmt = PLANB_GRAY;
1468 break;
1469 case 15:
1470 case 16:
1471 bpp = 2;
1472 fmt = PLANB_COLOUR15;
1473 break;
1474 case 24:
1475 case 32:
1476 bpp = 4;
1477 fmt = PLANB_COLOUR32;
1478 break;
1479 default:
1480 planb_unlock(pb);
1481 return -EINVAL;
1482 }
1483 if (bpp * v.width > v.bytesperline) {
1484 planb_unlock(pb);
1485 return -EINVAL;
1486 }
1487 pb->win.bpp = bpp;
1488 pb->win.color_fmt = fmt;
1489 pb->frame_buffer_phys = (unsigned long) v.base;
1490 pb->win.sheight = v.height;
1491 pb->win.swidth = v.width;
1492 pb->picture.depth = pb->win.depth = v.depth;
1493 pb->win.bpl = pb->win.bpp * pb->win.swidth;
1494 pb->win.pad = v.bytesperline - pb->win.bpl;
1495
1496 DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d,"
1497 " bpl %d (+ %d)\n", v.base, v.width,v.height,
1498 pb->win.bpp, pb->win.bpl, pb->win.pad);
1499
1500 pb->cmd_buff_inited = 0;
1501 if(pb->overlay) {
1502 suspend_overlay(pb);
1503 fill_cmd_buff(pb);
1504 resume_overlay(pb);
1505 }
1506 planb_unlock(pb);
1507 return 0;
1508 }
1509 case VIDIOCGFBUF:
1510 {
1511 struct video_buffer v;
1512
1513 DEBUG("PlanB: IOCTL VIDIOCGFBUF\n");
1514
1515 v.base = (void *)pb->frame_buffer_phys;
1516 v.height = pb->win.sheight;
1517 v.width = pb->win.swidth;
1518 v.depth = pb->win.depth;
1519 v.bytesperline = pb->win.bpl + pb->win.pad;
1520 if (copy_to_user(arg, &v, sizeof(v)))
1521 return -EFAULT;
1522 return 0;
1523 }
1524 case VIDIOCCAPTURE:
1525 {
1526 int i;
1527
1528 if(copy_from_user(&i, arg, sizeof(i)))
1529 return -EFAULT;
1530 if(i==0) {
1531 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n");
1532
1533 if (!(pb->overlay))
1534 return 0;
1535 planb_lock(pb);
1536 pb->overlay = 0;
1537 overlay_stop(pb);
1538 planb_unlock(pb);
1539 } else {
1540 DEBUG("PlanB: IOCTL VIDIOCCAPTURE Start\n");
1541
1542 if (pb->frame_buffer_phys == 0 ||
1543 pb->win.width == 0 ||
1544 pb->win.height == 0)
1545 return -EINVAL;
1546 if (pb->overlay)
1547 return 0;
1548 planb_lock(pb);
1549 pb->overlay = 1;
1550 if(!(pb->cmd_buff_inited))
1551 fill_cmd_buff(pb);
1552 overlay_start(pb);
1553 planb_unlock(pb);
1554 }
1555 return 0;
1556 }
1557 case VIDIOCGCHAN:
1558 {
1559 struct video_channel v;
1560
1561 DEBUG("PlanB: IOCTL VIDIOCGCHAN\n");
1562
1563 if(copy_from_user(&v, arg,sizeof(v)))
1564 return -EFAULT;
1565 v.flags = 0;
1566 v.tuners = 0;
1567 v.type = VIDEO_TYPE_CAMERA;
1568 v.norm = pb->win.norm;
1569 switch(v.channel)
1570 {
1571 case 0:
1572 strcpy(v.name,"Composite");
1573 break;
1574 case 1:
1575 strcpy(v.name,"SVHS");
1576 break;
1577 default:
1578 return -EINVAL;
1579 break;
1580 }
1581 if(copy_to_user(arg,&v,sizeof(v)))
1582 return -EFAULT;
1583
1584 return 0;
1585 }
1586 case VIDIOCSCHAN:
1587 {
1588 struct video_channel v;
1589
1590 DEBUG("PlanB: IOCTL VIDIOCSCHAN\n");
1591
1592 if(copy_from_user(&v, arg, sizeof(v)))
1593 return -EFAULT;
1594
1595 if (v.norm != pb->win.norm) {
1596 int i, maxlines;
1597
1598 switch (v.norm)
1599 {
1600 case VIDEO_MODE_PAL:
1601 case VIDEO_MODE_SECAM:
1602 maxlines = PLANB_MAXLINES;
1603 break;
1604 case VIDEO_MODE_NTSC:
1605 maxlines = PLANB_NTSC_MAXLINES;
1606 break;
1607 default:
1608 return -EINVAL;
1609 break;
1610 }
1611 planb_lock(pb);
1612 /* empty the grabbing queue */
1613 wait_event(pb->capq, !pb->grabbing);
1614 pb->maxlines = maxlines;
1615 pb->win.norm = v.norm;
1616 /* Stop overlay if running */
1617 suspend_overlay(pb);
1618 for(i = 0; i < MAX_GBUFFERS; i++)
1619 pb->gnorm_switch[i] = 1;
1620 /* I know it's an overkill, but.... */
1621 fill_cmd_buff(pb);
1622 /* ok, now init it accordingly */
1623 saa_init_regs (pb);
1624 /* restart overlay if it was running */
1625 resume_overlay(pb);
1626 planb_unlock(pb);
1627 }
1628
1629 switch(v.channel)
1630 {
1631 case 0: /* Composite */
1632 saa_set (SAA7196_IOCC,
1633 ((saa_regs[pb->win.norm][SAA7196_IOCC] &
1634 ~7) | 3), pb);
1635 break;
1636 case 1: /* SVHS */
1637 saa_set (SAA7196_IOCC,
1638 ((saa_regs[pb->win.norm][SAA7196_IOCC] &
1639 ~7) | 4), pb);
1640 break;
1641 default:
1642 return -EINVAL;
1643 break;
1644 }
1645
1646 return 0;
1647 }
1648 case VIDIOCGPICT:
1649 {
1650 struct video_picture vp = pb->picture;
1651
1652 DEBUG("PlanB: IOCTL VIDIOCGPICT\n");
1653
1654 switch(pb->win.color_fmt) {
1655 case PLANB_GRAY:
1656 vp.palette = VIDEO_PALETTE_GREY;
1657 case PLANB_COLOUR15:
1658 vp.palette = VIDEO_PALETTE_RGB555;
1659 break;
1660 case PLANB_COLOUR32:
1661 vp.palette = VIDEO_PALETTE_RGB32;
1662 break;
1663 default:
1664 vp.palette = 0;
1665 break;
1666 }
1667
1668 if(copy_to_user(arg,&vp,sizeof(vp)))
1669 return -EFAULT;
1670 return 0;
1671 }
1672 case VIDIOCSPICT:
1673 {
1674 struct video_picture vp;
1675
1676 DEBUG("PlanB: IOCTL VIDIOCSPICT\n");
1677
1678 if(copy_from_user(&vp,arg,sizeof(vp)))
1679 return -EFAULT;
1680 pb->picture = vp;
1681 /* Should we do sanity checks here? */
1682 saa_set (SAA7196_BRIG, (unsigned char)
1683 ((pb->picture.brightness) >> 8), pb);
1684 saa_set (SAA7196_HUEC, (unsigned char)
1685 ((pb->picture.hue) >> 8) ^ 0x80, pb);
1686 saa_set (SAA7196_CSAT, (unsigned char)
1687 ((pb->picture.colour) >> 9), pb);
1688 saa_set (SAA7196_CONT, (unsigned char)
1689 ((pb->picture.contrast) >> 9), pb);
1690
1691 return 0;
1692 }
1693 case VIDIOCSWIN:
1694 {
1695 struct video_window vw;
1696 struct video_clip clip;
1697 int i;
1698
1699 DEBUG("PlanB: IOCTL VIDIOCSWIN\n");
1700
1701 if(copy_from_user(&vw,arg,sizeof(vw)))
1702 return -EFAULT;
1703
1704 planb_lock(pb);
1705 /* Stop overlay if running */
1706 suspend_overlay(pb);
1707 pb->win.interlace = (vw.height > pb->maxlines/2)? 1: 0;
1708 if (pb->win.x != vw.x ||
1709 pb->win.y != vw.y ||
1710 pb->win.width != vw.width ||
1711 pb->win.height != vw.height ||
1712 !pb->cmd_buff_inited) {
1713 pb->win.x = vw.x;
1714 pb->win.y = vw.y;
1715 pb->win.width = vw.width;
1716 pb->win.height = vw.height;
1717 fill_cmd_buff(pb);
1718 }
1719 /* Reset clip mask */
1720 memset ((void *) pb->mask, 0xff, (pb->maxlines
1721 * ((PLANB_MAXPIXELS + 7) & ~7)) / 8);
1722 /* Add any clip rects */
1723 for (i = 0; i < vw.clipcount; i++) {
1724 if (copy_from_user(&clip, vw.clips + i,
1725 sizeof(struct video_clip)))
1726 return -EFAULT;
1727 add_clip(pb, &clip);
1728 }
1729 /* restart overlay if it was running */
1730 resume_overlay(pb);
1731 planb_unlock(pb);
1732 return 0;
1733 }
1734 case VIDIOCGWIN:
1735 {
1736 struct video_window vw;
1737
1738 DEBUG("PlanB: IOCTL VIDIOCGWIN\n");
1739
1740 vw.x=pb->win.x;
1741 vw.y=pb->win.y;
1742 vw.width=pb->win.width;
1743 vw.height=pb->win.height;
1744 vw.chromakey=0;
1745 vw.flags=0;
1746 if(pb->win.interlace)
1747 vw.flags|=VIDEO_WINDOW_INTERLACE;
1748 if(copy_to_user(arg,&vw,sizeof(vw)))
1749 return -EFAULT;
1750 return 0;
1751 }
1752 case VIDIOCSYNC: {
1753 int i;
1754
1755 IDEBUG("PlanB: IOCTL VIDIOCSYNC\n");
1756
1757 if(copy_from_user((void *)&i,arg,sizeof(int)))
1758 return -EFAULT;
1759
1760 IDEBUG("PlanB: sync to frame %d\n", i);
1761
1762 if(i > (MAX_GBUFFERS - 1) || i < 0)
1763 return -EINVAL;
1764chk_grab:
1765 switch (pb->frame_stat[i]) {
1766 case GBUFFER_UNUSED:
1767 return -EINVAL;
1768 case GBUFFER_GRABBING:
1769 IDEBUG("PlanB: waiting for grab"
1770 " done (%d)\n", i);
1771 interruptible_sleep_on(&pb->capq);
1772 if(signal_pending(current))
1773 return -EINTR;
1774 goto chk_grab;
1775 case GBUFFER_DONE:
1776 pb->frame_stat[i] = GBUFFER_UNUSED;
1777 break;
1778 }
1779 return 0;
1780 }
1781
1782 case VIDIOCMCAPTURE:
1783 {
1784 struct video_mmap vm;
1785 volatile unsigned int status;
1786
1787 IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n");
1788
1789 if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm)))
1790 return -EFAULT;
1791 status = pb->frame_stat[vm.frame];
1792 if (status != GBUFFER_UNUSED)
1793 return -EBUSY;
1794
1795 return vgrab(pb, &vm);
1796 }
1797
1798 case VIDIOCGMBUF:
1799 {
1800 int i;
1801 struct video_mbuf vm;
1802
1803 DEBUG("PlanB: IOCTL VIDIOCGMBUF\n");
1804
1805 memset(&vm, 0 , sizeof(vm));
1806 vm.size = PLANB_MAX_FBUF * MAX_GBUFFERS;
1807 vm.frames = MAX_GBUFFERS;
1808 for(i = 0; i<MAX_GBUFFERS; i++)
1809 vm.offsets[i] = PLANB_MAX_FBUF * i;
1810 if(copy_to_user((void *)arg, (void *)&vm, sizeof(vm)))
1811 return -EFAULT;
1812 return 0;
1813 }
1814
1815 case PLANBIOCGSAAREGS:
1816 {
1817 struct planb_saa_regs preg;
1818
1819 DEBUG("PlanB: IOCTL PLANBIOCGSAAREGS\n");
1820
1821 if(copy_from_user(&preg, arg, sizeof(preg)))
1822 return -EFAULT;
1823 if(preg.addr >= SAA7196_NUMREGS)
1824 return -EINVAL;
1825 preg.val = saa_regs[pb->win.norm][preg.addr];
1826 if(copy_to_user((void *)arg, (void *)&preg,
1827 sizeof(preg)))
1828 return -EFAULT;
1829 return 0;
1830 }
1831
1832 case PLANBIOCSSAAREGS:
1833 {
1834 struct planb_saa_regs preg;
1835
1836 DEBUG("PlanB: IOCTL PLANBIOCSSAAREGS\n");
1837
1838 if(copy_from_user(&preg, arg, sizeof(preg)))
1839 return -EFAULT;
1840 if(preg.addr >= SAA7196_NUMREGS)
1841 return -EINVAL;
1842 saa_set (preg.addr, preg.val, pb);
1843 return 0;
1844 }
1845
1846 case PLANBIOCGSTAT:
1847 {
1848 struct planb_stat_regs pstat;
1849
1850 DEBUG("PlanB: IOCTL PLANBIOCGSTAT\n");
1851
1852 pstat.ch1_stat = in_le32(&pb->planb_base->ch1.status);
1853 pstat.ch2_stat = in_le32(&pb->planb_base->ch2.status);
1854 pstat.saa_stat0 = saa_status(0, pb);
1855 pstat.saa_stat1 = saa_status(1, pb);
1856
1857 if(copy_to_user((void *)arg, (void *)&pstat,
1858 sizeof(pstat)))
1859 return -EFAULT;
1860 return 0;
1861 }
1862
1863 case PLANBIOCSMODE: {
1864 int v;
1865
1866 DEBUG("PlanB: IOCTL PLANBIOCSMODE\n");
1867
1868 if(copy_from_user(&v, arg, sizeof(v)))
1869 return -EFAULT;
1870
1871 switch(v)
1872 {
1873 case PLANB_TV_MODE:
1874 saa_set (SAA7196_STDC,
1875 (saa_regs[pb->win.norm][SAA7196_STDC] &
1876 0x7f), pb);
1877 break;
1878 case PLANB_VTR_MODE:
1879 saa_set (SAA7196_STDC,
1880 (saa_regs[pb->win.norm][SAA7196_STDC] |
1881 0x80), pb);
1882 break;
1883 default:
1884 return -EINVAL;
1885 break;
1886 }
1887 pb->win.mode = v;
1888 return 0;
1889 }
1890 case PLANBIOCGMODE: {
1891 int v=pb->win.mode;
1892
1893 DEBUG("PlanB: IOCTL PLANBIOCGMODE\n");
1894
1895 if(copy_to_user(arg,&v,sizeof(v)))
1896 return -EFAULT;
1897 return 0;
1898 }
1899#ifdef PLANB_GSCANLINE
1900 case PLANBG_GRAB_BPL: {
1901 int v=pb->gbytes_per_line;
1902
1903 DEBUG("PlanB: IOCTL PLANBG_GRAB_BPL\n");
1904
1905 if(copy_to_user(arg,&v,sizeof(v)))
1906 return -EFAULT;
1907 return 0;
1908 }
1909#endif /* PLANB_GSCANLINE */
1910 case PLANB_INTR_DEBUG: {
1911 int i;
1912
1913 DEBUG("PlanB: IOCTL PLANB_INTR_DEBUG\n");
1914
1915 if(copy_from_user(&i, arg, sizeof(i)))
1916 return -EFAULT;
1917
1918 /* avoid hang ups all together */
1919 for (i = 0; i < MAX_GBUFFERS; i++) {
1920 if(pb->frame_stat[i] == GBUFFER_GRABBING) {
1921 pb->frame_stat[i] = GBUFFER_DONE;
1922 }
1923 }
1924 if(pb->grabbing)
1925 pb->grabbing--;
1926 wake_up_interruptible(&pb->capq);
1927 return 0;
1928 }
1929 case PLANB_INV_REGS: {
1930 int i;
1931 struct planb_any_regs any;
1932
1933 DEBUG("PlanB: IOCTL PLANB_INV_REGS\n");
1934
1935 if(copy_from_user(&any, arg, sizeof(any)))
1936 return -EFAULT;
1937 if(any.offset < 0 || any.offset + any.bytes > 0x400)
1938 return -EINVAL;
1939 if(any.bytes > 128)
1940 return -EINVAL;
1941 for (i = 0; i < any.bytes; i++) {
1942 any.data[i] =
1943 in_8((unsigned char *)pb->planb_base
1944 + any.offset + i);
1945 }
1946 if(copy_to_user(arg,&any,sizeof(any)))
1947 return -EFAULT;
1948 return 0;
1949 }
1950 default:
1951 {
1952 DEBUG("PlanB: Unimplemented IOCTL\n");
1953 return -ENOIOCTLCMD;
1954 }
1955 /* Some IOCTLs are currently unsupported on PlanB */
1956 case VIDIOCGTUNER: {
1957 DEBUG("PlanB: IOCTL VIDIOCGTUNER\n");
1958 goto unimplemented; }
1959 case VIDIOCSTUNER: {
1960 DEBUG("PlanB: IOCTL VIDIOCSTUNER\n");
1961 goto unimplemented; }
1962 case VIDIOCSFREQ: {
1963 DEBUG("PlanB: IOCTL VIDIOCSFREQ\n");
1964 goto unimplemented; }
1965 case VIDIOCGFREQ: {
1966 DEBUG("PlanB: IOCTL VIDIOCGFREQ\n");
1967 goto unimplemented; }
1968 case VIDIOCKEY: {
1969 DEBUG("PlanB: IOCTL VIDIOCKEY\n");
1970 goto unimplemented; }
1971 case VIDIOCSAUDIO: {
1972 DEBUG("PlanB: IOCTL VIDIOCSAUDIO\n");
1973 goto unimplemented; }
1974 case VIDIOCGAUDIO: {
1975 DEBUG("PlanB: IOCTL VIDIOCGAUDIO\n");
1976 goto unimplemented; }
1977unimplemented:
1978 DEBUG(" Unimplemented\n");
1979 return -ENOIOCTLCMD;
1980 }
1981 return 0;
1982}
1983
1984static int planb_mmap(struct vm_area_struct *vma, struct video_device *dev, const char *adr, unsigned long size)
1985{
1986 int i;
1987 struct planb *pb = (struct planb *)dev;
1988 unsigned long start = (unsigned long)adr;
1989
1990 if (size > MAX_GBUFFERS * PLANB_MAX_FBUF)
1991 return -EINVAL;
1992 if (!pb->rawbuf) {
1993 int err;
1994 if((err=grabbuf_alloc(pb)))
1995 return err;
1996 }
1997 for (i = 0; i < pb->rawbuf_size; i++) {
1998 unsigned long pfn;
1999
2000 pfn = virt_to_phys((void *)pb->rawbuf[i]) >> PAGE_SHIFT;
2001 if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED))
2002 return -EAGAIN;
2003 start += PAGE_SIZE;
2004 if (size <= PAGE_SIZE)
2005 break;
2006 size -= PAGE_SIZE;
2007 }
2008 return 0;
2009}
2010
2011static struct video_device planb_template=
2012{
2013 .owner = THIS_MODULE,
2014 .name = PLANB_DEVICE_NAME,
2015 .type = VID_TYPE_OVERLAY,
2016 .open = planb_open,
2017 .close = planb_close,
2018 .read = planb_read,
2019 .write = planb_write,
2020 .ioctl = planb_ioctl,
2021 .mmap = planb_mmap, /* mmap? */
2022};
2023
2024static int init_planb(struct planb *pb)
2025{
2026 unsigned char saa_rev;
2027 int i, result;
2028
2029 memset ((void *) &pb->win, 0, sizeof (struct planb_window));
2030 /* Simple sanity check */
2031 if(def_norm >= NUM_SUPPORTED_NORM || def_norm < 0) {
2032 printk(KERN_ERR "PlanB: Option(s) invalid\n");
2033 return -2;
2034 }
2035 pb->win.norm = def_norm;
2036 pb->win.mode = PLANB_TV_MODE; /* TV mode */
2037 pb->win.interlace=1;
2038 pb->win.x=0;
2039 pb->win.y=0;
2040 pb->win.width=768; /* 640 */
2041 pb->win.height=576; /* 480 */
2042 pb->maxlines=576;
2043#if 0
2044 btv->win.cropwidth=768; /* 640 */
2045 btv->win.cropheight=576; /* 480 */
2046 btv->win.cropx=0;
2047 btv->win.cropy=0;
2048#endif
2049 pb->win.pad=0;
2050 pb->win.bpp=4;
2051 pb->win.depth=32;
2052 pb->win.color_fmt=PLANB_COLOUR32;
2053 pb->win.bpl=1024*pb->win.bpp;
2054 pb->win.swidth=1024;
2055 pb->win.sheight=768;
2056#ifdef PLANB_GSCANLINE
2057 if((pb->gbytes_per_line = PLANB_MAXPIXELS * 4) > PAGE_SIZE
2058 || (pb->gbytes_per_line <= 0))
2059 return -3;
2060 else {
2061 /* page align pb->gbytes_per_line for DMA purpose */
2062 for(i = PAGE_SIZE; pb->gbytes_per_line < (i>>1);)
2063 i>>=1;
2064 pb->gbytes_per_line = i;
2065 }
2066#endif
2067 pb->tab_size = PLANB_MAXLINES + 40;
2068 pb->suspend = 0;
2069 mutex_init(&pb->lock);
2070 pb->ch1_cmd = 0;
2071 pb->ch2_cmd = 0;
2072 pb->mask = 0;
2073 pb->priv_space = 0;
2074 pb->offset = 0;
2075 pb->user = 0;
2076 pb->overlay = 0;
2077 init_waitqueue_head(&pb->suspendq);
2078 pb->cmd_buff_inited = 0;
2079 pb->frame_buffer_phys = 0;
2080
2081 /* Reset DMA controllers */
2082 planb_dbdma_stop(&pb->planb_base->ch2);
2083 planb_dbdma_stop(&pb->planb_base->ch1);
2084
2085 saa_rev = (saa_status(0, pb) & 0xf0) >> 4;
2086 printk(KERN_INFO "PlanB: SAA7196 video processor rev. %d\n", saa_rev);
2087 /* Initialize the SAA registers in memory and on chip */
2088 saa_init_regs (pb);
2089
2090 /* clear interrupt mask */
2091 pb->intr_mask = PLANB_CLR_IRQ;
2092
2093 result = request_irq(pb->irq, planb_irq, 0, "PlanB", pb);
2094 if (result < 0) {
2095 if (result==-EINVAL)
2096 printk(KERN_ERR "PlanB: Bad irq number (%d) "
2097 "or handler\n", (int)pb->irq);
2098 else if (result==-EBUSY)
2099 printk(KERN_ERR "PlanB: I don't know why, "
2100 "but IRQ %d is busy\n", (int)pb->irq);
2101 return result;
2102 }
2103 disable_irq(pb->irq);
2104
2105 /* Now add the template and register the device unit. */
2106 memcpy(&pb->video_dev,&planb_template,sizeof(planb_template));
2107
2108 pb->picture.brightness=0x90<<8;
2109 pb->picture.contrast = 0x70 << 8;
2110 pb->picture.colour = 0x70<<8;
2111 pb->picture.hue = 0x8000;
2112 pb->picture.whiteness = 0;
2113 pb->picture.depth = pb->win.depth;
2114
2115 pb->frame_stat=NULL;
2116 init_waitqueue_head(&pb->capq);
2117 for(i=0; i<MAX_GBUFFERS; i++) {
2118 pb->gbuf_idx[i] = PLANB_MAX_FBUF * i / PAGE_SIZE;
2119 pb->gwidth[i]=0;
2120 pb->gheight[i]=0;
2121 pb->gfmt[i]=0;
2122 pb->cap_cmd[i]=NULL;
2123#ifndef PLANB_GSCANLINE
2124 pb->l_fr_addr_idx[i] = MAX_GBUFFERS * (PLANB_MAX_FBUF
2125 / PAGE_SIZE + 1) + MAX_LNUM * i;
2126 pb->lsize[i] = 0;
2127 pb->lnum[i] = 0;
2128#endif
2129 }
2130 pb->rawbuf=NULL;
2131 pb->grabbing=0;
2132
2133 /* enable interrupts */
2134 out_le32(&pb->planb_base->intr_stat, PLANB_CLR_IRQ);
2135 pb->intr_mask = PLANB_FRM_IRQ;
2136 enable_irq(pb->irq);
2137
2138 if(video_register_device(&pb->video_dev, VFL_TYPE_GRABBER, video_nr)<0)
2139 return -1;
2140
2141 return 0;
2142}
2143
2144/*
2145 * Scan for a PlanB controller, request the irq and map the io memory
2146 */
2147
2148static int find_planb(void)
2149{
2150 struct planb *pb;
2151 struct device_node *planb_devices;
2152 unsigned char dev_fn, confreg, bus;
2153 unsigned int old_base, new_base;
2154 unsigned int irq;
2155 struct pci_dev *pdev;
2156 int rc;
2157
2158 if (!machine_is(powermac))
2159 return 0;
2160
2161 planb_devices = of_find_node_by_name(NULL, "planb");
2162 if (planb_devices == 0) {
2163 planb_num=0;
2164 printk(KERN_WARNING "PlanB: no device found!\n");
2165 return planb_num;
2166 }
2167
2168 if (planb_devices->next != NULL)
2169 printk(KERN_ERR "Warning: only using first PlanB device!\n");
2170 pb = &planbs[0];
2171 planb_num = 1;
2172
2173 if (planb_devices->n_addrs != 1) {
2174 printk (KERN_WARNING "PlanB: expecting 1 address for planb "
2175 "(got %d)", planb_devices->n_addrs);
2176 of_node_put(planb_devices);
2177 return 0;
2178 }
2179
2180 if (planb_devices->n_intrs == 0) {
2181 printk(KERN_WARNING "PlanB: no intrs for device %s\n",
2182 planb_devices->full_name);
2183 of_node_put(planb_devices);
2184 return 0;
2185 } else {
2186 irq = planb_devices->intrs[0].line;
2187 }
2188
2189 /* Initialize PlanB's PCI registers */
2190
2191 /* There is a bug with the way OF assigns addresses
2192 to the devices behind the chaos bridge.
2193 control needs only 0x1000 of space, but decodes only
2194 the upper 16 bits. It therefore occupies a full 64K.
2195 OF assigns the planb controller memory within this space;
2196 so we need to change that here in order to access planb. */
2197
2198 /* We remap to 0xf1000000 in hope that nobody uses it ! */
2199
2200 bus = (planb_devices->addrs[0].space >> 16) & 0xff;
2201 dev_fn = (planb_devices->addrs[0].space >> 8) & 0xff;
2202 confreg = planb_devices->addrs[0].space & 0xff;
2203 old_base = planb_devices->addrs[0].address;
2204 new_base = 0xf1000000;
2205 of_node_put(planb_devices);
2206
2207 DEBUG("PlanB: Found on bus %d, dev %d, func %d, "
2208 "membase 0x%x (base reg. 0x%x)\n",
2209 bus, PCI_SLOT(dev_fn), PCI_FUNC(dev_fn), old_base, confreg);
2210
2211 pdev = pci_get_bus_and_slot(bus, dev_fn);
2212 if (!pdev) {
2213 printk(KERN_ERR "planb: cannot find slot\n");
2214 goto err_out;
2215 }
2216
2217 /* Enable response in memory space, bus mastering,
2218 use memory write and invalidate */
2219 rc = pci_enable_device(pdev);
2220 if (rc) {
2221 printk(KERN_ERR "planb: cannot enable PCI device %s\n",
2222 pci_name(pdev));
2223 goto err_out;
2224 }
2225 rc = pci_set_mwi(pdev);
2226 if (rc) {
2227 printk(KERN_ERR "planb: cannot enable MWI on PCI device %s\n",
2228 pci_name(pdev));
2229 goto err_out_disable;
2230 }
2231 pci_set_master(pdev);
2232
2233 /* Set the new base address */
2234 pci_write_config_dword (pdev, confreg, new_base);
2235
2236 planb_regs = (volatile struct planb_registers *)
2237 ioremap (new_base, 0x400);
2238 pb->planb_base = planb_regs;
2239 pb->planb_base_phys = (struct planb_registers *)new_base;
2240 pb->irq = irq;
2241 pb->dev = pdev;
2242
2243 return planb_num;
2244
2245err_out_disable:
2246 pci_disable_device(pdev);
2247err_out:
2248 /* FIXME handle error */ /* comment moved from pci_find_slot, above */
2249 pci_dev_put(pdev);
2250 return 0;
2251}
2252
2253static void release_planb(void)
2254{
2255 int i;
2256 struct planb *pb;
2257
2258 for (i=0;i<planb_num; i++)
2259 {
2260 pb=&planbs[i];
2261
2262 /* stop and flash DMAs unconditionally */
2263 planb_dbdma_stop(&pb->planb_base->ch2);
2264 planb_dbdma_stop(&pb->planb_base->ch1);
2265
2266 /* clear and free interrupts */
2267 pb->intr_mask = PLANB_CLR_IRQ;
2268 out_le32 (&pb->planb_base->intr_stat, PLANB_CLR_IRQ);
2269 free_irq(pb->irq, pb);
2270
2271 /* make sure all allocated memory are freed */
2272 planb_prepare_close(pb);
2273
2274 printk(KERN_INFO "PlanB: unregistering with v4l\n");
2275 video_unregister_device(&pb->video_dev);
2276
2277 pci_dev_put(pb->dev);
2278
2279 /* note that iounmap() does nothing on the PPC right now */
2280 iounmap ((void *)pb->planb_base);
2281 }
2282}
2283
2284static int __init init_planbs(void)
2285{
2286 int i;
2287
2288 if (find_planb()<=0)
2289 return -EIO;
2290
2291 for (i=0; i<planb_num; i++) {
2292 if (init_planb(&planbs[i])<0) {
2293 printk(KERN_ERR "PlanB: error registering device %d"
2294 " with v4l\n", i);
2295 release_planb();
2296 return -EIO;
2297 }
2298 printk(KERN_INFO "PlanB: registered device %d with v4l\n", i);
2299 }
2300 return 0;
2301}
2302
2303static void __exit exit_planbs(void)
2304{
2305 release_planb();
2306}
2307
2308module_init(init_planbs);
2309module_exit(exit_planbs);
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
index e21b5735c103..e69de29bb2d1 100644
--- a/drivers/media/video/planb.h
+++ b/drivers/media/video/planb.h
@@ -1,232 +0,0 @@
1/*
2 planb - PlanB frame grabber driver
3
4 PlanB is used in the 7x00/8x00 series of PowerMacintosh
5 Computers as video input DMA controller.
6
7 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
8
9 Based largely on the bttv driver by Ralph Metzler (rjkm@thp.uni-koeln.de)
10
11 Additional debugging and coding by Takashi Oe (toe@unlserve.unl.edu)
12
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27*/
28
29/* $Id: planb.h,v 1.13 1999/05/03 19:28:56 mlan Exp $ */
30
31#ifndef _PLANB_H_
32#define _PLANB_H_
33
34#ifdef __KERNEL__
35#include <asm/dbdma.h>
36#include "saa7196.h"
37#endif /* __KERNEL__ */
38
39#define PLANB_DEVICE_NAME "Apple PlanB Video-In"
40#define PLANB_REV "1.0"
41
42#ifdef __KERNEL__
43//#define PLANB_GSCANLINE /* use this if apps have the notion of */
44 /* grab buffer scanline */
45/* This should be safe for both PAL and NTSC */
46#define PLANB_MAXPIXELS 768
47#define PLANB_MAXLINES 576
48#define PLANB_NTSC_MAXLINES 480
49
50/* Uncomment your preferred norm ;-) */
51#define PLANB_DEF_NORM VIDEO_MODE_PAL
52//#define PLANB_DEF_NORM VIDEO_MODE_NTSC
53//#define PLANB_DEF_NORM VIDEO_MODE_SECAM
54
55/* fields settings */
56#define PLANB_GRAY 0x1 /* 8-bit mono? */
57#define PLANB_COLOUR15 0x2 /* 16-bit mode */
58#define PLANB_COLOUR32 0x4 /* 32-bit mode */
59#define PLANB_CLIPMASK 0x8 /* hardware clipmasking */
60
61/* misc. flags for PlanB DMA operation */
62#define CH_SYNC 0x1 /* synchronize channels (set by ch1;
63 cleared by ch2) */
64#define FIELD_SYNC 0x2 /* used for the start of each field
65 (0 -> 1 -> 0 for ch1; 0 -> 1 for ch2) */
66#define EVEN_FIELD 0x0 /* even field is detected if unset */
67#define DMA_ABORT 0x2 /* error or just out of sync if set */
68#define ODD_FIELD 0x4 /* odd field is detected if set */
69
70/* for capture operations */
71#define MAX_GBUFFERS 2
72/* note PLANB_MAX_FBUF must be divisible by PAGE_SIZE */
73#ifdef PLANB_GSCANLINE
74#define PLANB_MAX_FBUF 0x240000 /* 576 * 1024 * 4 */
75#define TAB_FACTOR (1)
76#else
77#define PLANB_MAX_FBUF 0x1b0000 /* 576 * 768 * 4 */
78#define TAB_FACTOR (2)
79#endif
80#endif /* __KERNEL__ */
81
82struct planb_saa_regs {
83 unsigned char addr;
84 unsigned char val;
85};
86
87struct planb_stat_regs {
88 unsigned int ch1_stat;
89 unsigned int ch2_stat;
90 unsigned char saa_stat0;
91 unsigned char saa_stat1;
92};
93
94struct planb_any_regs {
95 unsigned int offset;
96 unsigned int bytes;
97 unsigned char data[128];
98};
99
100/* planb private ioctls */
101#define PLANBIOCGSAAREGS _IOWR('v', BASE_VIDIOCPRIVATE, struct planb_saa_regs) /* Read a saa7196 reg value */
102#define PLANBIOCSSAAREGS _IOW('v', BASE_VIDIOCPRIVATE + 1, struct planb_saa_regs) /* Set a saa7196 reg value */
103#define PLANBIOCGSTAT _IOR('v', BASE_VIDIOCPRIVATE + 2, struct planb_stat_regs) /* Read planb status */
104#define PLANB_TV_MODE 1
105#define PLANB_VTR_MODE 2
106#define PLANBIOCGMODE _IOR('v', BASE_VIDIOCPRIVATE + 3, int) /* Get TV/VTR mode */
107#define PLANBIOCSMODE _IOW('v', BASE_VIDIOCPRIVATE + 4, int) /* Set TV/VTR mode */
108
109#ifdef PLANB_GSCANLINE
110#define PLANBG_GRAB_BPL _IOR('v', BASE_VIDIOCPRIVATE + 5, int) /* # of bytes per scanline in grab buffer */
111#endif
112
113/* call wake_up_interruptible() with appropriate actions */
114#define PLANB_INTR_DEBUG _IOW('v', BASE_VIDIOCPRIVATE + 20, int)
115/* investigate which reg does what */
116#define PLANB_INV_REGS _IOWR('v', BASE_VIDIOCPRIVATE + 21, struct planb_any_regs)
117
118#ifdef __KERNEL__
119
120/* Potentially useful macros */
121#define PLANB_SET(x) ((x) << 16 | (x))
122#define PLANB_CLR(x) ((x) << 16)
123
124/* This represents the physical register layout */
125struct planb_registers {
126 volatile struct dbdma_regs ch1; /* 0x00: video in */
127 volatile unsigned int even; /* 0x40: even field setting */
128 volatile unsigned int odd; /* 0x44; odd field setting */
129 unsigned int pad1[14]; /* empty? */
130 volatile struct dbdma_regs ch2; /* 0x80: clipmask out */
131 unsigned int pad2[16]; /* 0xc0: empty? */
132 volatile unsigned int reg3; /* 0x100: ???? */
133 volatile unsigned int intr_stat; /* 0x104: irq status */
134#define PLANB_CLR_IRQ 0x00 /* clear Plan B interrupt */
135#define PLANB_GEN_IRQ 0x01 /* assert Plan B interrupt */
136#define PLANB_FRM_IRQ 0x0100 /* end of frame */
137 unsigned int pad3[1]; /* empty? */
138 volatile unsigned int reg5; /* 0x10c: ??? */
139 unsigned int pad4[60]; /* empty? */
140 volatile unsigned char saa_addr; /* 0x200: SAA subadr */
141 char pad5[3];
142 volatile unsigned char saa_regval; /* SAA7196 write reg. val */
143 char pad6[3];
144 volatile unsigned char saa_status; /* SAA7196 status byte */
145 /* There is more unused stuff here */
146};
147
148struct planb_window {
149 int x, y;
150 ushort width, height;
151 ushort bpp, bpl, depth, pad;
152 ushort swidth, sheight;
153 int norm;
154 int interlace;
155 u32 color_fmt;
156 int chromakey;
157 int mode; /* used to switch between TV/VTR modes */
158};
159
160struct planb_suspend {
161 int overlay;
162 int frame;
163 struct dbdma_cmd cmd;
164};
165
166struct planb {
167 struct video_device video_dev;
168 struct video_picture picture; /* Current picture params */
169 struct video_audio audio_dev; /* Current audio params */
170
171 volatile struct planb_registers *planb_base; /* virt base of planb */
172 struct planb_registers *planb_base_phys; /* phys base of planb */
173 void *priv_space; /* Org. alloc. mem for kfree */
174 int user;
175 unsigned int tab_size;
176 int maxlines;
177 struct mutex lock;
178 unsigned int irq; /* interrupt number */
179 volatile unsigned int intr_mask;
180 struct pci_dev *dev; /* Our PCI device */
181
182 int overlay; /* overlay running? */
183 struct planb_window win;
184 unsigned long frame_buffer_phys; /* We need phys for DMA */
185 int offset; /* offset of pixel 1 */
186 volatile struct dbdma_cmd *ch1_cmd; /* Video In DMA cmd buffer */
187 volatile struct dbdma_cmd *ch2_cmd; /* Clip Out DMA cmd buffer */
188 volatile struct dbdma_cmd *overlay_last1;
189 volatile struct dbdma_cmd *overlay_last2;
190 unsigned long ch1_cmd_phys;
191 volatile unsigned char *mask; /* Clipmask buffer */
192 int suspend;
193 wait_queue_head_t suspendq;
194 struct planb_suspend suspended;
195 int cmd_buff_inited; /* cmd buffer inited? */
196
197 int grabbing;
198 unsigned int gcount;
199 wait_queue_head_t capq;
200 int last_fr;
201 int prev_last_fr;
202 unsigned char **rawbuf;
203 int rawbuf_size;
204 int gbuf_idx[MAX_GBUFFERS];
205 volatile struct dbdma_cmd *cap_cmd[MAX_GBUFFERS];
206 volatile struct dbdma_cmd *last_cmd[MAX_GBUFFERS];
207 volatile struct dbdma_cmd *pre_cmd[MAX_GBUFFERS];
208 int need_pre_capture[MAX_GBUFFERS];
209#define PLANB_DUMMY 40 /* # of command buf's allocated for pre-capture seq. */
210 int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
211 unsigned int gfmt[MAX_GBUFFERS];
212 int gnorm_switch[MAX_GBUFFERS];
213 volatile unsigned int *frame_stat;
214#define GBUFFER_UNUSED 0x00U
215#define GBUFFER_GRABBING 0x01U
216#define GBUFFER_DONE 0x02U
217#ifdef PLANB_GSCANLINE
218 int gbytes_per_line;
219#else
220#define MAX_LNUM 431 /* change this if PLANB_MAXLINES or */
221 /* PLANB_MAXPIXELS changes */
222 int l_fr_addr_idx[MAX_GBUFFERS];
223 unsigned char *l_to_addr[MAX_GBUFFERS][MAX_LNUM];
224 int l_to_next_idx[MAX_GBUFFERS][MAX_LNUM];
225 int l_to_next_size[MAX_GBUFFERS][MAX_LNUM];
226 int lsize[MAX_GBUFFERS], lnum[MAX_GBUFFERS];
227#endif
228};
229
230#endif /* __KERNEL__ */
231
232#endif /* _PLANB_H_ */
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 51b1461d8fb6..00425d743656 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -30,6 +30,7 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <linux/videodev.h> 31#include <linux/videodev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33#include <linux/mutex.h> 34#include <linux/mutex.h>
34 35
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
@@ -894,9 +895,7 @@ static const struct file_operations pms_fops = {
894 895
895static struct video_device pms_template= 896static struct video_device pms_template=
896{ 897{
897 .owner = THIS_MODULE,
898 .name = "Mediavision PMS", 898 .name = "Mediavision PMS",
899 .type = VID_TYPE_CAPTURE,
900 .fops = &pms_fops, 899 .fops = &pms_fops,
901}; 900};
902 901
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 4482b2c72ced..19eb274c9cd0 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -2,8 +2,6 @@ config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && I2C 3 depends on VIDEO_V4L2 && I2C
4 depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M 4 depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M
5 depends on HOTPLUG # due to FW_LOADER
6 select FW_LOADER
7 select VIDEO_TUNER 5 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 7 select VIDEO_CX2341X
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.h b/drivers/media/video/pvrusb2/pvrusb2-context.h
index 61801291c2af..d657e53bbfa3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.h
@@ -16,8 +16,8 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * 17 *
18 */ 18 */
19#ifndef __PVRUSB2_BASE_H 19#ifndef __PVRUSB2_CONTEXT_H
20#define __PVRUSB2_BASE_H 20#define __PVRUSB2_CONTEXT_H
21 21
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/usb.h> 23#include <linux/usb.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
index 5d036e7e3f07..88e175168438 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
@@ -97,13 +97,13 @@ static const struct pvr2_device_desc pvr2_device_24xxx = {
97 .flag_has_cx25840 = !0, 97 .flag_has_cx25840 = !0,
98 .flag_has_wm8775 = !0, 98 .flag_has_wm8775 = !0,
99 .flag_has_hauppauge_rom = !0, 99 .flag_has_hauppauge_rom = !0,
100 .flag_has_hauppauge_custom_ir = !0,
101 .flag_has_analogtuner = !0, 100 .flag_has_analogtuner = !0,
102 .flag_has_fmradio = !0, 101 .flag_has_fmradio = !0,
103 .flag_has_composite = !0, 102 .flag_has_composite = !0,
104 .flag_has_svideo = !0, 103 .flag_has_svideo = !0,
105 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, 104 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
106 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, 105 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
106 .ir_scheme = PVR2_IR_SCHEME_24XXX,
107}; 107};
108 108
109 109
@@ -330,7 +330,7 @@ static const char *pvr2_fw1_names_73xxx[] = {
330}; 330};
331 331
332static const struct pvr2_device_desc pvr2_device_73xxx = { 332static const struct pvr2_device_desc pvr2_device_73xxx = {
333 .description = "WinTV PVR USB2 Model Category 73xxx", 333 .description = "WinTV HVR-1900 Model Category 73xxx",
334 .shortname = "73xxx", 334 .shortname = "73xxx",
335 .client_modules.lst = pvr2_client_73xxx, 335 .client_modules.lst = pvr2_client_73xxx,
336 .client_modules.cnt = ARRAY_SIZE(pvr2_client_73xxx), 336 .client_modules.cnt = ARRAY_SIZE(pvr2_client_73xxx),
@@ -344,6 +344,7 @@ static const struct pvr2_device_desc pvr2_device_73xxx = {
344 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, 344 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
345 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, 345 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
346 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, 346 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
347 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
347#ifdef CONFIG_VIDEO_PVRUSB2_DVB 348#ifdef CONFIG_VIDEO_PVRUSB2_DVB
348 .dvb_props = &pvr2_73xxx_dvb_props, 349 .dvb_props = &pvr2_73xxx_dvb_props,
349#endif 350#endif
@@ -438,7 +439,7 @@ static const char *pvr2_fw1_names_75xxx[] = {
438}; 439};
439 440
440static const struct pvr2_device_desc pvr2_device_750xx = { 441static const struct pvr2_device_desc pvr2_device_750xx = {
441 .description = "WinTV PVR USB2 Model Category 750xx", 442 .description = "WinTV HVR-1950 Model Category 750xx",
442 .shortname = "750xx", 443 .shortname = "750xx",
443 .client_modules.lst = pvr2_client_75xxx, 444 .client_modules.lst = pvr2_client_75xxx,
444 .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx), 445 .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx),
@@ -453,13 +454,14 @@ static const struct pvr2_device_desc pvr2_device_750xx = {
453 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, 454 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
454 .default_std_mask = V4L2_STD_NTSC_M, 455 .default_std_mask = V4L2_STD_NTSC_M,
455 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, 456 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
457 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
456#ifdef CONFIG_VIDEO_PVRUSB2_DVB 458#ifdef CONFIG_VIDEO_PVRUSB2_DVB
457 .dvb_props = &pvr2_750xx_dvb_props, 459 .dvb_props = &pvr2_750xx_dvb_props,
458#endif 460#endif
459}; 461};
460 462
461static const struct pvr2_device_desc pvr2_device_751xx = { 463static const struct pvr2_device_desc pvr2_device_751xx = {
462 .description = "WinTV PVR USB2 Model Category 751xx", 464 .description = "WinTV HVR-1950 Model Category 751xx",
463 .shortname = "751xx", 465 .shortname = "751xx",
464 .client_modules.lst = pvr2_client_75xxx, 466 .client_modules.lst = pvr2_client_75xxx,
465 .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx), 467 .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx),
@@ -474,6 +476,7 @@ static const struct pvr2_device_desc pvr2_device_751xx = {
474 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, 476 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
475 .default_std_mask = V4L2_STD_NTSC_M, 477 .default_std_mask = V4L2_STD_NTSC_M,
476 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, 478 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
479 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
477#ifdef CONFIG_VIDEO_PVRUSB2_DVB 480#ifdef CONFIG_VIDEO_PVRUSB2_DVB
478 .dvb_props = &pvr2_751xx_dvb_props, 481 .dvb_props = &pvr2_751xx_dvb_props,
479#endif 482#endif
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.h b/drivers/media/video/pvrusb2/pvrusb2-devattr.h
index e23ce1d2edd7..cb3a33eb0276 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.h
@@ -48,6 +48,10 @@ struct pvr2_string_table {
48#define PVR2_LED_SCHEME_NONE 0 48#define PVR2_LED_SCHEME_NONE 0
49#define PVR2_LED_SCHEME_HAUPPAUGE 1 49#define PVR2_LED_SCHEME_HAUPPAUGE 1
50 50
51#define PVR2_IR_SCHEME_NONE 0
52#define PVR2_IR_SCHEME_24XXX 1
53#define PVR2_IR_SCHEME_ZILOG 2
54
51/* This describes a particular hardware type (except for the USB device ID 55/* This describes a particular hardware type (except for the USB device ID
52 which must live in a separate structure due to environmental 56 which must live in a separate structure due to environmental
53 constraints). See the top of pvrusb2-hdw.c for where this is 57 constraints). See the top of pvrusb2-hdw.c for where this is
@@ -126,15 +130,19 @@ struct pvr2_device_desc {
126 ensure that it is found. */ 130 ensure that it is found. */
127 unsigned int flag_has_wm8775:1; 131 unsigned int flag_has_wm8775:1;
128 132
129 /* Device has IR hardware that can be faked into looking like a 133 /* Indicate any specialized IR scheme that might need to be
130 normal Hauppauge i2c IR receiver. This is currently very 134 supported by this driver. If not set, then it is assumed that
131 specific to the 24xxx device, where Hauppauge had replaced their 135 IR can work without help from the driver (which is frequently
132 'standard' I2C IR receiver with a bunch of FPGA logic controlled 136 the case). This is otherwise set to one of
133 directly via the FX2. Turning this on tells the pvrusb2 driver 137 PVR2_IR_SCHEME_xxxx. For "xxxx", the value "24XXX" indicates a
134 to virtualize the presence of the non-existant IR receiver chip and 138 Hauppauge 24xxx class device which has an FPGA-hosted IR
135 implement the virtual receiver in terms of appropriate FX2 139 receiver that can only be reached via FX2 command codes. In
136 commands. */ 140 that case the pvrusb2 driver will emulate the behavior of the
137 unsigned int flag_has_hauppauge_custom_ir:1; 141 older 29xxx device's IR receiver (a "virtual" I2C chip) in terms
142 of those command codes. For the value "ZILOG", we're dealing
143 with an IR chip that must be taken out of reset via another FX2
144 command code (which is the case for HVR-1950 devices). */
145 unsigned int ir_scheme:2;
138 146
139 /* These bits define which kinds of sources the device can handle. 147 /* These bits define which kinds of sources the device can handle.
140 Note: Digital tuner presence is inferred by the 148 Note: Digital tuner presence is inferred by the
diff --git a/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
index b58369e7f30b..614755ea2ea3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h
@@ -24,6 +24,8 @@
24#define FX2CMD_MEM_WRITE_DWORD 0x01u 24#define FX2CMD_MEM_WRITE_DWORD 0x01u
25#define FX2CMD_MEM_READ_DWORD 0x02u 25#define FX2CMD_MEM_READ_DWORD 0x02u
26 26
27#define FX2CMD_HCW_ZILOG_RESET 0x10u /* 1=reset 0=release */
28
27#define FX2CMD_MEM_READ_64BYTES 0x28u 29#define FX2CMD_MEM_READ_64BYTES 0x28u
28 30
29#define FX2CMD_REG_WRITE 0x04u 31#define FX2CMD_REG_WRITE 0x04u
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index a5217a2cf4c0..f051c6aa7f1f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -250,6 +250,7 @@ struct pvr2_fx2cmd_descdef {
250static const struct pvr2_fx2cmd_descdef pvr2_fx2cmd_desc[] = { 250static const struct pvr2_fx2cmd_descdef pvr2_fx2cmd_desc[] = {
251 {FX2CMD_MEM_WRITE_DWORD, "write encoder dword"}, 251 {FX2CMD_MEM_WRITE_DWORD, "write encoder dword"},
252 {FX2CMD_MEM_READ_DWORD, "read encoder dword"}, 252 {FX2CMD_MEM_READ_DWORD, "read encoder dword"},
253 {FX2CMD_HCW_ZILOG_RESET, "zilog IR reset control"},
253 {FX2CMD_MEM_READ_64BYTES, "read encoder 64bytes"}, 254 {FX2CMD_MEM_READ_64BYTES, "read encoder 64bytes"},
254 {FX2CMD_REG_WRITE, "write encoder register"}, 255 {FX2CMD_REG_WRITE, "write encoder register"},
255 {FX2CMD_REG_READ, "read encoder register"}, 256 {FX2CMD_REG_READ, "read encoder register"},
@@ -1711,6 +1712,14 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
1711 if (!pvr2_hdw_dev_ok(hdw)) return; 1712 if (!pvr2_hdw_dev_ok(hdw)) return;
1712 } 1713 }
1713 1714
1715 /* Take the IR chip out of reset, if appropriate */
1716 if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_ZILOG) {
1717 pvr2_issue_simple_cmd(hdw,
1718 FX2CMD_HCW_ZILOG_RESET |
1719 (1 << 8) |
1720 ((0) << 16));
1721 }
1722
1714 // This step MUST happen after the earlier powerup step. 1723 // This step MUST happen after the earlier powerup step.
1715 pvr2_i2c_core_init(hdw); 1724 pvr2_i2c_core_init(hdw);
1716 if (!pvr2_hdw_dev_ok(hdw)) return; 1725 if (!pvr2_hdw_dev_ok(hdw)) return;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 9d3c18b24744..e600576a6c4b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -979,7 +979,9 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
979 printk(KERN_INFO "%s: IR disabled\n",hdw->name); 979 printk(KERN_INFO "%s: IR disabled\n",hdw->name);
980 hdw->i2c_func[0x18] = i2c_black_hole; 980 hdw->i2c_func[0x18] = i2c_black_hole;
981 } else if (ir_mode[hdw->unit_number] == 1) { 981 } else if (ir_mode[hdw->unit_number] == 1) {
982 if (hdw->hdw_desc->flag_has_hauppauge_custom_ir) { 982 if (hdw->hdw_desc->ir_scheme == PVR2_IR_SCHEME_24XXX) {
983 /* This comment is present PURELY to get
984 checkpatch.pl to STFU. Lovely, eh? */
983 hdw->i2c_func[0x18] = i2c_24xxx_ir; 985 hdw->i2c_func[0x18] = i2c_24xxx_ir;
984 } 986 }
985 } 987 }
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 0d72dc470fef..00306faeac01 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -30,6 +30,7 @@
30#include <linux/videodev2.h> 30#include <linux/videodev2.h>
31#include <media/v4l2-dev.h> 31#include <media/v4l2-dev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33 34
34struct pvr2_v4l2_dev; 35struct pvr2_v4l2_dev;
35struct pvr2_v4l2_fh; 36struct pvr2_v4l2_fh;
@@ -1160,11 +1161,6 @@ static const struct file_operations vdev_fops = {
1160 1161
1161 1162
1162static struct video_device vdev_template = { 1163static struct video_device vdev_template = {
1163 .owner = THIS_MODULE,
1164 .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER,
1165 .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE
1166 | V4L2_CAP_TUNER | V4L2_CAP_AUDIO
1167 | V4L2_CAP_READWRITE),
1168 .fops = &vdev_fops, 1164 .fops = &vdev_fops,
1169}; 1165};
1170 1166
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 423fa7c2d0c9..9aee7cb6f79a 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -165,9 +165,7 @@ static const struct file_operations pwc_fops = {
165 .llseek = no_llseek, 165 .llseek = no_llseek,
166}; 166};
167static struct video_device pwc_template = { 167static struct video_device pwc_template = {
168 .owner = THIS_MODULE,
169 .name = "Philips Webcam", /* Filled in later */ 168 .name = "Philips Webcam", /* Filled in later */
170 .type = VID_TYPE_CAPTURE,
171 .release = video_device_release, 169 .release = video_device_release,
172 .fops = &pwc_fops, 170 .fops = &pwc_fops,
173 .minor = -1, 171 .minor = -1,
@@ -1048,19 +1046,20 @@ static int pwc_create_sysfs_files(struct video_device *vdev)
1048 struct pwc_device *pdev = video_get_drvdata(vdev); 1046 struct pwc_device *pdev = video_get_drvdata(vdev);
1049 int rc; 1047 int rc;
1050 1048
1051 rc = video_device_create_file(vdev, &dev_attr_button); 1049 rc = device_create_file(&vdev->dev, &dev_attr_button);
1052 if (rc) 1050 if (rc)
1053 goto err; 1051 goto err;
1054 if (pdev->features & FEATURE_MOTOR_PANTILT) { 1052 if (pdev->features & FEATURE_MOTOR_PANTILT) {
1055 rc = video_device_create_file(vdev, &dev_attr_pan_tilt); 1053 rc = device_create_file(&vdev->dev, &dev_attr_pan_tilt);
1056 if (rc) goto err_button; 1054 if (rc) goto err_button;
1057 } 1055 }
1058 1056
1059 return 0; 1057 return 0;
1060 1058
1061err_button: 1059err_button:
1062 video_device_remove_file(vdev, &dev_attr_button); 1060 device_remove_file(&vdev->dev, &dev_attr_button);
1063err: 1061err:
1062 PWC_ERROR("Could not create sysfs files.\n");
1064 return rc; 1063 return rc;
1065} 1064}
1066 1065
@@ -1068,8 +1067,8 @@ static void pwc_remove_sysfs_files(struct video_device *vdev)
1068{ 1067{
1069 struct pwc_device *pdev = video_get_drvdata(vdev); 1068 struct pwc_device *pdev = video_get_drvdata(vdev);
1070 if (pdev->features & FEATURE_MOTOR_PANTILT) 1069 if (pdev->features & FEATURE_MOTOR_PANTILT)
1071 video_device_remove_file(vdev, &dev_attr_pan_tilt); 1070 device_remove_file(&vdev->dev, &dev_attr_pan_tilt);
1072 video_device_remove_file(vdev, &dev_attr_button); 1071 device_remove_file(&vdev->dev, &dev_attr_button);
1073} 1072}
1074 1073
1075#ifdef CONFIG_USB_PWC_DEBUG 1074#ifdef CONFIG_USB_PWC_DEBUG
@@ -1767,9 +1766,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1767 return -ENOMEM; 1766 return -ENOMEM;
1768 } 1767 }
1769 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); 1768 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template));
1770 pdev->vdev->dev = &(udev->dev); 1769 pdev->vdev->parent = &(udev->dev);
1771 strcpy(pdev->vdev->name, name); 1770 strcpy(pdev->vdev->name, name);
1772 pdev->vdev->owner = THIS_MODULE;
1773 video_set_drvdata(pdev->vdev, pdev); 1771 video_set_drvdata(pdev->vdev, pdev);
1774 1772
1775 pdev->release = le16_to_cpu(udev->descriptor.bcdDevice); 1773 pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 8e8e5b27e77e..74178754b39b 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -32,9 +32,11 @@
32#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
33#include <linux/version.h> 33#include <linux/version.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/mm.h>
35#include <asm/errno.h> 36#include <asm/errno.h>
36#include <linux/videodev.h> 37#include <linux/videodev.h>
37#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
39#include <media/v4l2-ioctl.h>
38 40
39#include "pwc-uncompress.h" 41#include "pwc-uncompress.h"
40#include <media/pwc-ioctl.h> 42#include <media/pwc-ioctl.h>
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 04eb2c3fabd8..b1d09d8e2b85 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -47,8 +47,10 @@
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/videodev2.h> 48#include <linux/videodev2.h>
49#include <linux/version.h> 49#include <linux/version.h>
50#include <linux/mm.h>
50#include <media/videobuf-vmalloc.h> 51#include <media/videobuf-vmalloc.h>
51#include <media/v4l2-common.h> 52#include <media/v4l2-common.h>
53#include <media/v4l2-ioctl.h>
52#include <linux/vmalloc.h> 54#include <linux/vmalloc.h>
53#include <linux/usb.h> 55#include <linux/usb.h>
54 56
@@ -184,6 +186,7 @@ struct s2255_dmaqueue {
184#define S2255_FW_LOADED_DSPWAIT 1 186#define S2255_FW_LOADED_DSPWAIT 1
185#define S2255_FW_SUCCESS 2 187#define S2255_FW_SUCCESS 2
186#define S2255_FW_FAILED 3 188#define S2255_FW_FAILED 3
189#define S2255_FW_DISCONNECTING 4
187 190
188struct s2255_fw { 191struct s2255_fw {
189 int fw_loaded; 192 int fw_loaded;
@@ -263,7 +266,6 @@ struct s2255_buffer {
263 266
264struct s2255_fh { 267struct s2255_fh {
265 struct s2255_dev *dev; 268 struct s2255_dev *dev;
266 unsigned int resources;
267 const struct s2255_fmt *fmt; 269 const struct s2255_fmt *fmt;
268 unsigned int width; 270 unsigned int width;
269 unsigned int height; 271 unsigned int height;
@@ -273,14 +275,9 @@ struct s2255_fh {
273 /* mode below is the desired mode. 275 /* mode below is the desired mode.
274 mode in s2255_dev is the current mode that was last set */ 276 mode in s2255_dev is the current mode that was last set */
275 struct s2255_mode mode; 277 struct s2255_mode mode;
278 int resources[MAX_CHANNELS];
276}; 279};
277 280
278/*
279 * TODO: fixme S2255_MAX_USERS. Do not limit open driver handles.
280 * Limit V4L to one stream at a time.
281 */
282#define S2255_MAX_USERS 1
283
284#define CUR_USB_FWVER 774 /* current cypress EEPROM firmware version */ 281#define CUR_USB_FWVER 774 /* current cypress EEPROM firmware version */
285#define S2255_MAJOR_VERSION 1 282#define S2255_MAJOR_VERSION 1
286#define S2255_MINOR_VERSION 13 283#define S2255_MINOR_VERSION 13
@@ -476,10 +473,9 @@ static void s2255_timer(unsigned long user_data)
476 dprintk(100, "s2255 timer\n"); 473 dprintk(100, "s2255 timer\n");
477 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) { 474 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) {
478 printk(KERN_ERR "s2255: can't submit urb\n"); 475 printk(KERN_ERR "s2255: can't submit urb\n");
479 if (data->fw) { 476 atomic_set(&data->fw_state, S2255_FW_FAILED);
480 release_firmware(data->fw); 477 /* wake up anything waiting for the firmware */
481 data->fw = NULL; 478 wake_up(&data->wait_fw);
482 }
483 return; 479 return;
484 } 480 }
485} 481}
@@ -509,13 +505,18 @@ static void s2255_fwchunk_complete(struct urb *urb)
509 struct usb_device *udev = urb->dev; 505 struct usb_device *udev = urb->dev;
510 int len; 506 int len;
511 dprintk(100, "udev %p urb %p", udev, urb); 507 dprintk(100, "udev %p urb %p", udev, urb);
512 /* TODO: fixme. reflect change in status */
513 if (urb->status) { 508 if (urb->status) {
514 dev_err(&udev->dev, "URB failed with status %d", urb->status); 509 dev_err(&udev->dev, "URB failed with status %d", urb->status);
510 atomic_set(&data->fw_state, S2255_FW_FAILED);
511 /* wake up anything waiting for the firmware */
512 wake_up(&data->wait_fw);
515 return; 513 return;
516 } 514 }
517 if (data->fw_urb == NULL) { 515 if (data->fw_urb == NULL) {
518 dev_err(&udev->dev, "early disconncect\n"); 516 dev_err(&udev->dev, "s2255 disconnected\n");
517 atomic_set(&data->fw_state, S2255_FW_FAILED);
518 /* wake up anything waiting for the firmware */
519 wake_up(&data->wait_fw);
519 return; 520 return;
520 } 521 }
521#define CHUNK_SIZE 512 522#define CHUNK_SIZE 512
@@ -789,7 +790,8 @@ static int res_get(struct s2255_dev *dev, struct s2255_fh *fh)
789 } 790 }
790 /* it's free, grab it */ 791 /* it's free, grab it */
791 dev->resources[fh->channel] = 1; 792 dev->resources[fh->channel] = 1;
792 dprintk(1, "res: get\n"); 793 fh->resources[fh->channel] = 1;
794 dprintk(1, "s2255: res: get\n");
793 mutex_unlock(&dev->lock); 795 mutex_unlock(&dev->lock);
794 return 1; 796 return 1;
795} 797}
@@ -799,9 +801,18 @@ static int res_locked(struct s2255_dev *dev, struct s2255_fh *fh)
799 return dev->resources[fh->channel]; 801 return dev->resources[fh->channel];
800} 802}
801 803
804static int res_check(struct s2255_fh *fh)
805{
806 return fh->resources[fh->channel];
807}
808
809
802static void res_free(struct s2255_dev *dev, struct s2255_fh *fh) 810static void res_free(struct s2255_dev *dev, struct s2255_fh *fh)
803{ 811{
812 mutex_lock(&dev->lock);
804 dev->resources[fh->channel] = 0; 813 dev->resources[fh->channel] = 0;
814 fh->resources[fh->channel] = 0;
815 mutex_unlock(&dev->lock);
805 dprintk(1, "res: put\n"); 816 dprintk(1, "res: put\n");
806} 817}
807 818
@@ -1232,7 +1243,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1232 } 1243 }
1233 1244
1234 if (!res_get(dev, fh)) { 1245 if (!res_get(dev, fh)) {
1235 dev_err(&dev->udev->dev, "res get busy\n"); 1246 dev_err(&dev->udev->dev, "s2255: stream busy\n");
1236 return -EBUSY; 1247 return -EBUSY;
1237 } 1248 }
1238 1249
@@ -1288,8 +1299,10 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1288 } 1299 }
1289 s2255_stop_acquire(dev, fh->channel); 1300 s2255_stop_acquire(dev, fh->channel);
1290 res = videobuf_streamoff(&fh->vb_vidq); 1301 res = videobuf_streamoff(&fh->vb_vidq);
1302 if (res < 0)
1303 return res;
1291 res_free(dev, fh); 1304 res_free(dev, fh);
1292 return res; 1305 return 0;
1293} 1306}
1294 1307
1295static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i) 1308static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i)
@@ -1462,12 +1475,7 @@ static int s2255_open(struct inode *inode, struct file *file)
1462 mutex_lock(&dev->open_lock); 1475 mutex_lock(&dev->open_lock);
1463 1476
1464 dev->users[cur_channel]++; 1477 dev->users[cur_channel]++;
1465 if (dev->users[cur_channel] > S2255_MAX_USERS) { 1478 dprintk(4, "s2255: open_handles %d\n", dev->users[cur_channel]);
1466 dev->users[cur_channel]--;
1467 mutex_unlock(&dev->open_lock);
1468 printk(KERN_INFO "s2255drv: too many open handles!\n");
1469 return -EBUSY;
1470 }
1471 1479
1472 if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_FAILED) { 1480 if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_FAILED) {
1473 err("2255 firmware load failed. retrying.\n"); 1481 err("2255 firmware load failed. retrying.\n");
@@ -1478,7 +1486,8 @@ static int s2255_open(struct inode *inode, struct file *file)
1478 msecs_to_jiffies(S2255_LOAD_TIMEOUT)); 1486 msecs_to_jiffies(S2255_LOAD_TIMEOUT));
1479 if (atomic_read(&dev->fw_data->fw_state) 1487 if (atomic_read(&dev->fw_data->fw_state)
1480 != S2255_FW_SUCCESS) { 1488 != S2255_FW_SUCCESS) {
1481 printk(KERN_INFO "2255 FW load failed after 2 tries\n"); 1489 printk(KERN_INFO "2255 FW load failed.\n");
1490 dev->users[cur_channel]--;
1482 mutex_unlock(&dev->open_lock); 1491 mutex_unlock(&dev->open_lock);
1483 return -EFAULT; 1492 return -EFAULT;
1484 } 1493 }
@@ -1494,6 +1503,7 @@ static int s2255_open(struct inode *inode, struct file *file)
1494 != S2255_FW_SUCCESS) { 1503 != S2255_FW_SUCCESS) {
1495 printk(KERN_INFO "2255 firmware not loaded" 1504 printk(KERN_INFO "2255 firmware not loaded"
1496 "try again\n"); 1505 "try again\n");
1506 dev->users[cur_channel]--;
1497 mutex_unlock(&dev->open_lock); 1507 mutex_unlock(&dev->open_lock);
1498 return -EBUSY; 1508 return -EBUSY;
1499 } 1509 }
@@ -1502,6 +1512,7 @@ static int s2255_open(struct inode *inode, struct file *file)
1502 /* allocate + initialize per filehandle data */ 1512 /* allocate + initialize per filehandle data */
1503 fh = kzalloc(sizeof(*fh), GFP_KERNEL); 1513 fh = kzalloc(sizeof(*fh), GFP_KERNEL);
1504 if (NULL == fh) { 1514 if (NULL == fh) {
1515 dev->users[cur_channel]--;
1505 mutex_unlock(&dev->open_lock); 1516 mutex_unlock(&dev->open_lock);
1506 return -ENOMEM; 1517 return -ENOMEM;
1507 } 1518 }
@@ -1561,44 +1572,48 @@ static void s2255_destroy(struct kref *kref)
1561 printk(KERN_ERR "s2255drv: kref problem\n"); 1572 printk(KERN_ERR "s2255drv: kref problem\n");
1562 return; 1573 return;
1563 } 1574 }
1575
1576 /*
1577 * Wake up any firmware load waiting (only done in .open,
1578 * which holds the open_lock mutex)
1579 */
1580 atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING);
1581 wake_up(&dev->fw_data->wait_fw);
1582
1564 /* prevent s2255_disconnect from racing s2255_open */ 1583 /* prevent s2255_disconnect from racing s2255_open */
1565 mutex_lock(&dev->open_lock); 1584 mutex_lock(&dev->open_lock);
1566 s2255_exit_v4l(dev); 1585 s2255_exit_v4l(dev);
1567 /* device unregistered so no longer possible to open. open_mutex 1586 /*
1568 can be unlocked */ 1587 * device unregistered so no longer possible to open. open_mutex
1588 * can be unlocked and timers deleted afterwards.
1589 */
1569 mutex_unlock(&dev->open_lock); 1590 mutex_unlock(&dev->open_lock);
1570 1591
1571 /* board shutdown stops the read pipe if it is running */ 1592 /* board shutdown stops the read pipe if it is running */
1572 s2255_board_shutdown(dev); 1593 s2255_board_shutdown(dev);
1573 1594
1574 /* make sure firmware still not trying to load */ 1595 /* make sure firmware still not trying to load */
1596 del_timer(&dev->timer); /* only started in .probe and .open */
1597
1575 if (dev->fw_data->fw_urb) { 1598 if (dev->fw_data->fw_urb) {
1576 dprintk(2, "kill fw_urb\n"); 1599 dprintk(2, "kill fw_urb\n");
1577 usb_kill_urb(dev->fw_data->fw_urb); 1600 usb_kill_urb(dev->fw_data->fw_urb);
1578 usb_free_urb(dev->fw_data->fw_urb); 1601 usb_free_urb(dev->fw_data->fw_urb);
1579 dev->fw_data->fw_urb = NULL; 1602 dev->fw_data->fw_urb = NULL;
1580 } 1603 }
1604
1581 /* 1605 /*
1582 * TODO: fixme(above, below): potentially leaving timers alive. 1606 * delete the dsp_wait timer, which sets the firmware
1583 * do not ignore timeout below if 1607 * state on completion. This is done before fw_data
1584 * it occurs. 1608 * is freed below.
1585 */ 1609 */
1586 1610
1587 /* make sure we aren't waiting for the DSP */ 1611 del_timer(&dev->fw_data->dsp_wait); /* only started in .open */
1588 if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_LOADED_DSPWAIT) {
1589 /* if we are, wait for the wakeup for fw_success or timeout */
1590 wait_event_timeout(dev->fw_data->wait_fw,
1591 (atomic_read(&dev->fw_data->fw_state)
1592 == S2255_FW_SUCCESS),
1593 msecs_to_jiffies(S2255_LOAD_TIMEOUT));
1594 }
1595 1612
1596 if (dev->fw_data) { 1613 if (dev->fw_data->fw)
1597 if (dev->fw_data->fw) 1614 release_firmware(dev->fw_data->fw);
1598 release_firmware(dev->fw_data->fw); 1615 kfree(dev->fw_data->pfw_data);
1599 kfree(dev->fw_data->pfw_data); 1616 kfree(dev->fw_data);
1600 kfree(dev->fw_data);
1601 }
1602 1617
1603 usb_put_dev(dev->udev); 1618 usb_put_dev(dev->udev);
1604 dprintk(1, "%s", __func__); 1619 dprintk(1, "%s", __func__);
@@ -1615,17 +1630,23 @@ static int s2255_close(struct inode *inode, struct file *file)
1615 1630
1616 mutex_lock(&dev->open_lock); 1631 mutex_lock(&dev->open_lock);
1617 1632
1618 if (dev->b_acquire[fh->channel]) 1633 /* turn off stream */
1619 s2255_stop_acquire(dev, fh->channel); 1634 if (res_check(fh)) {
1620 res_free(dev, fh); 1635 if (dev->b_acquire[fh->channel])
1636 s2255_stop_acquire(dev, fh->channel);
1637 videobuf_streamoff(&fh->vb_vidq);
1638 res_free(dev, fh);
1639 }
1640
1621 videobuf_mmap_free(&fh->vb_vidq); 1641 videobuf_mmap_free(&fh->vb_vidq);
1622 kfree(fh);
1623 dev->users[fh->channel]--; 1642 dev->users[fh->channel]--;
1643
1624 mutex_unlock(&dev->open_lock); 1644 mutex_unlock(&dev->open_lock);
1625 1645
1626 kref_put(&dev->kref, s2255_destroy); 1646 kref_put(&dev->kref, s2255_destroy);
1627 dprintk(1, "s2255: close called (minor=%d, users=%d)\n", 1647 dprintk(1, "s2255: close called (minor=%d, users=%d)\n",
1628 minor, dev->users[fh->channel]); 1648 minor, dev->users[fh->channel]);
1649 kfree(fh);
1629 return 0; 1650 return 0;
1630} 1651}
1631 1652
@@ -1658,12 +1679,7 @@ static const struct file_operations s2255_fops_v4l = {
1658 .llseek = no_llseek, 1679 .llseek = no_llseek,
1659}; 1680};
1660 1681
1661static struct video_device template = { 1682static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1662 .name = "s2255v",
1663 .type = VID_TYPE_CAPTURE,
1664 .fops = &s2255_fops_v4l,
1665 .minor = -1,
1666 .release = video_device_release,
1667 .vidioc_querycap = vidioc_querycap, 1683 .vidioc_querycap = vidioc_querycap,
1668 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1684 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1669 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1685 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1685,6 +1701,14 @@ static struct video_device template = {
1685#ifdef CONFIG_VIDEO_V4L1_COMPAT 1701#ifdef CONFIG_VIDEO_V4L1_COMPAT
1686 .vidiocgmbuf = vidioc_cgmbuf, 1702 .vidiocgmbuf = vidioc_cgmbuf,
1687#endif 1703#endif
1704};
1705
1706static struct video_device template = {
1707 .name = "s2255v",
1708 .fops = &s2255_fops_v4l,
1709 .ioctl_ops = &s2255_ioctl_ops,
1710 .minor = -1,
1711 .release = video_device_release,
1688 .tvnorms = S2255_NORMS, 1712 .tvnorms = S2255_NORMS,
1689 .current_norm = V4L2_STD_NTSC_M, 1713 .current_norm = V4L2_STD_NTSC_M,
1690}; 1714};
@@ -1706,7 +1730,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1706 /* register 4 video devices */ 1730 /* register 4 video devices */
1707 dev->vdev[i] = video_device_alloc(); 1731 dev->vdev[i] = video_device_alloc();
1708 memcpy(dev->vdev[i], &template, sizeof(struct video_device)); 1732 memcpy(dev->vdev[i], &template, sizeof(struct video_device));
1709 dev->vdev[i]->dev = &dev->interface->dev; 1733 dev->vdev[i]->parent = &dev->interface->dev;
1710 if (video_nr == -1) 1734 if (video_nr == -1)
1711 ret = video_register_device(dev->vdev[i], 1735 ret = video_register_device(dev->vdev[i],
1712 VFL_TYPE_GRABBER, 1736 VFL_TYPE_GRABBER,
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 03e772130b55..6ee63e69b36c 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -46,6 +46,7 @@
46#include <linux/videotext.h> 46#include <linux/videotext.h>
47#include <linux/videodev.h> 47#include <linux/videodev.h>
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <media/v4l2-ioctl.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50 51
51#include "saa5246a.h" 52#include "saa5246a.h"
@@ -829,9 +830,7 @@ static const struct file_operations saa_fops = {
829 830
830static struct video_device saa_template = 831static struct video_device saa_template =
831{ 832{
832 .owner = THIS_MODULE,
833 .name = IF_NAME, 833 .name = IF_NAME,
834 .type = VID_TYPE_TELETEXT,
835 .fops = &saa_fops, 834 .fops = &saa_fops,
836 .release = video_device_release, 835 .release = video_device_release,
837 .minor = -1, 836 .minor = -1,
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index fde99d9ee71f..0d639738d4e6 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -57,6 +57,7 @@
57#include <linux/videotext.h> 57#include <linux/videotext.h>
58#include <linux/videodev.h> 58#include <linux/videodev.h>
59#include <media/v4l2-common.h> 59#include <media/v4l2-common.h>
60#include <media/v4l2-ioctl.h>
60#include <linux/mutex.h> 61#include <linux/mutex.h>
61 62
62 63
@@ -710,9 +711,7 @@ static const struct file_operations saa_fops = {
710 711
711static struct video_device saa_template = 712static struct video_device saa_template =
712{ 713{
713 .owner = THIS_MODULE,
714 .name = IF_NAME, 714 .name = IF_NAME,
715 .type = VID_TYPE_TELETEXT, /*| VID_TYPE_TUNER ?? */
716 .fops = &saa_fops, 715 .fops = &saa_fops,
717}; 716};
718 717
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 83f076abce35..7021bbf5897b 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -27,9 +27,7 @@ config VIDEO_SAA7134_ALSA
27config VIDEO_SAA7134_DVB 27config VIDEO_SAA7134_DVB
28 tristate "DVB/ATSC Support for saa7134 based TV cards" 28 tristate "DVB/ATSC Support for saa7134 based TV cards"
29 depends on VIDEO_SAA7134 && DVB_CORE 29 depends on VIDEO_SAA7134 && DVB_CORE
30 depends on HOTPLUG # due to FW_LOADER
31 select VIDEOBUF_DVB 30 select VIDEOBUF_DVB
32 select FW_LOADER
33 select DVB_PLL if !DVB_FE_CUSTOMISE 31 select DVB_PLL if !DVB_FE_CUSTOMISE
34 select DVB_MT352 if !DVB_FE_CUSTOMISE 32 select DVB_MT352 if !DVB_FE_CUSTOMISE
35 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 33 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 6893f998d292..98364d171def 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -5853,9 +5853,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
5853 unsigned char buf; 5853 unsigned char buf;
5854 int board; 5854 int board;
5855 5855
5856 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
5857 dev->tuner_addr = saa7134_boards[dev->board].tuner_addr;
5858
5859 switch (dev->board) { 5856 switch (dev->board) {
5860 case SAA7134_BOARD_BMK_MPEX_NOTUNER: 5857 case SAA7134_BOARD_BMK_MPEX_NOTUNER:
5861 case SAA7134_BOARD_BMK_MPEX_TUNER: 5858 case SAA7134_BOARD_BMK_MPEX_TUNER:
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index cfee84ee7a88..75d618415f4f 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -798,7 +798,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
798 return NULL; 798 return NULL;
799 *vfd = *template; 799 *vfd = *template;
800 vfd->minor = -1; 800 vfd->minor = -1;
801 vfd->dev = &dev->pci->dev; 801 vfd->parent = &dev->pci->dev;
802 vfd->release = video_device_release; 802 vfd->release = video_device_release;
803 vfd->debug = video_debug; 803 vfd->debug = video_debug;
804 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 804 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
@@ -945,11 +945,12 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
945 dev->board = SAA7134_BOARD_UNKNOWN; 945 dev->board = SAA7134_BOARD_UNKNOWN;
946 } 946 }
947 dev->autodetected = card[dev->nr] != dev->board; 947 dev->autodetected = card[dev->nr] != dev->board;
948 dev->tuner_type = saa7134_boards[dev->board].tuner_type; 948 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
949 dev->tuner_addr = saa7134_boards[dev->board].tuner_addr;
949 dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf; 950 dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf;
950 if (UNSET != tuner[dev->nr]) 951 if (UNSET != tuner[dev->nr])
951 dev->tuner_type = tuner[dev->nr]; 952 dev->tuner_type = tuner[dev->nr];
952 printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", 953 printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
953 dev->name,pci_dev->subsystem_vendor, 954 dev->name,pci_dev->subsystem_vendor,
954 pci_dev->subsystem_device,saa7134_boards[dev->board].name, 955 pci_dev->subsystem_device,saa7134_boards[dev->board].name,
955 dev->board, dev->autodetected ? 956 dev->board, dev->autodetected ?
@@ -1007,11 +1008,9 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1007 v4l2_prio_init(&dev->prio); 1008 v4l2_prio_init(&dev->prio);
1008 1009
1009 /* register v4l devices */ 1010 /* register v4l devices */
1010 if (saa7134_no_overlay <= 0) { 1011 if (saa7134_no_overlay > 0)
1011 saa7134_video_template.type |= VID_TYPE_OVERLAY; 1012 printk(KERN_INFO "%s: Overlay support disabled.\n", dev->name);
1012 } else { 1013
1013 printk("%s: Overlay support disabled.\n",dev->name);
1014 }
1015 dev->video_dev = vdev_init(dev,&saa7134_video_template,"video"); 1014 dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
1016 err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, 1015 err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
1017 video_nr[dev->nr]); 1016 video_nr[dev->nr]);
@@ -1024,7 +1023,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1024 dev->name,dev->video_dev->minor & 0x1f); 1023 dev->name,dev->video_dev->minor & 0x1f);
1025 1024
1026 dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi"); 1025 dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi");
1027 dev->vbi_dev->type = VID_TYPE_TUNER | VID_TYPE_TELETEXT;
1028 1026
1029 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, 1027 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
1030 vbi_nr[dev->nr]); 1028 vbi_nr[dev->nr]);
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 2a5ab957542d..c0c5d7509c25 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -89,14 +89,14 @@ static int ts_open(struct inode *inode, struct file *file)
89 err = -EBUSY; 89 err = -EBUSY;
90 if (!mutex_trylock(&dev->empress_tsq.vb_lock)) 90 if (!mutex_trylock(&dev->empress_tsq.vb_lock))
91 goto done; 91 goto done;
92 if (dev->empress_users) 92 if (atomic_read(&dev->empress_users))
93 goto done_up; 93 goto done_up;
94 94
95 /* Unmute audio */ 95 /* Unmute audio */
96 saa_writeb(SAA7134_AUDIO_MUTE_CTRL, 96 saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
97 saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6)); 97 saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6));
98 98
99 dev->empress_users++; 99 atomic_inc(&dev->empress_users);
100 file->private_data = dev; 100 file->private_data = dev;
101 err = 0; 101 err = 0;
102 102
@@ -110,8 +110,6 @@ static int ts_release(struct inode *inode, struct file *file)
110{ 110{
111 struct saa7134_dev *dev = file->private_data; 111 struct saa7134_dev *dev = file->private_data;
112 112
113 mutex_lock(&dev->empress_tsq.vb_lock);
114
115 videobuf_stop(&dev->empress_tsq); 113 videobuf_stop(&dev->empress_tsq);
116 videobuf_mmap_free(&dev->empress_tsq); 114 videobuf_mmap_free(&dev->empress_tsq);
117 115
@@ -122,9 +120,7 @@ static int ts_release(struct inode *inode, struct file *file)
122 saa_writeb(SAA7134_AUDIO_MUTE_CTRL, 120 saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
123 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); 121 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
124 122
125 dev->empress_users--; 123 atomic_dec(&dev->empress_users);
126
127 mutex_unlock(&dev->empress_tsq.vb_lock);
128 124
129 return 0; 125 return 0;
130} 126}
@@ -333,6 +329,22 @@ static int empress_g_ext_ctrls(struct file *file, void *priv,
333 return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls); 329 return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls);
334} 330}
335 331
332static int empress_g_ctrl(struct file *file, void *priv,
333 struct v4l2_control *c)
334{
335 struct saa7134_dev *dev = file->private_data;
336
337 return saa7134_g_ctrl_internal(dev, NULL, c);
338}
339
340static int empress_s_ctrl(struct file *file, void *priv,
341 struct v4l2_control *c)
342{
343 struct saa7134_dev *dev = file->private_data;
344
345 return saa7134_s_ctrl_internal(dev, NULL, c);
346}
347
336static int empress_queryctrl(struct file *file, void *priv, 348static int empress_queryctrl(struct file *file, void *priv,
337 struct v4l2_queryctrl *c) 349 struct v4l2_queryctrl *c)
338{ 350{
@@ -400,16 +412,7 @@ static const struct file_operations ts_fops =
400 .llseek = no_llseek, 412 .llseek = no_llseek,
401}; 413};
402 414
403/* ----------------------------------------------------------- */ 415static const struct v4l2_ioctl_ops ts_ioctl_ops = {
404
405static struct video_device saa7134_empress_template =
406{
407 .name = "saa7134-empress",
408 .type = 0 /* FIXME */,
409 .type2 = 0 /* FIXME */,
410 .fops = &ts_fops,
411 .minor = -1,
412
413 .vidioc_querycap = empress_querycap, 416 .vidioc_querycap = empress_querycap,
414 .vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap, 417 .vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap,
415 .vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap, 418 .vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap,
@@ -428,8 +431,17 @@ static struct video_device saa7134_empress_template =
428 431
429 .vidioc_queryctrl = empress_queryctrl, 432 .vidioc_queryctrl = empress_queryctrl,
430 .vidioc_querymenu = empress_querymenu, 433 .vidioc_querymenu = empress_querymenu,
431 .vidioc_g_ctrl = saa7134_g_ctrl, 434 .vidioc_g_ctrl = empress_g_ctrl,
432 .vidioc_s_ctrl = saa7134_s_ctrl, 435 .vidioc_s_ctrl = empress_s_ctrl,
436};
437
438/* ----------------------------------------------------------- */
439
440static struct video_device saa7134_empress_template = {
441 .name = "saa7134-empress",
442 .fops = &ts_fops,
443 .minor = -1,
444 .ioctl_ops = &ts_ioctl_ops,
433 445
434 .tvnorms = SAA7134_NORMS, 446 .tvnorms = SAA7134_NORMS,
435 .current_norm = V4L2_STD_PAL, 447 .current_norm = V4L2_STD_PAL,
@@ -445,7 +457,7 @@ static void empress_signal_update(struct work_struct *work)
445 ts_reset_encoder(dev); 457 ts_reset_encoder(dev);
446 } else { 458 } else {
447 dprintk("video signal acquired\n"); 459 dprintk("video signal acquired\n");
448 if (dev->empress_users) 460 if (atomic_read(&dev->empress_users))
449 ts_init_encoder(dev); 461 ts_init_encoder(dev);
450 } 462 }
451} 463}
@@ -465,7 +477,7 @@ static int empress_init(struct saa7134_dev *dev)
465 if (NULL == dev->empress_dev) 477 if (NULL == dev->empress_dev)
466 return -ENOMEM; 478 return -ENOMEM;
467 *(dev->empress_dev) = saa7134_empress_template; 479 *(dev->empress_dev) = saa7134_empress_template;
468 dev->empress_dev->dev = &dev->pci->dev; 480 dev->empress_dev->parent = &dev->pci->dev;
469 dev->empress_dev->release = video_device_release; 481 dev->empress_dev->release = video_device_release;
470 snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), 482 snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
471 "%s empress (%s)", dev->name, 483 "%s empress (%s)", dev->name,
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 1a5137550e7a..68c268981861 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1112,10 +1112,8 @@ static struct videobuf_queue_ops video_qops = {
1112 1112
1113/* ------------------------------------------------------------------ */ 1113/* ------------------------------------------------------------------ */
1114 1114
1115int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c) 1115int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c)
1116{ 1116{
1117 struct saa7134_fh *fh = priv;
1118 struct saa7134_dev *dev = fh->dev;
1119 const struct v4l2_queryctrl* ctrl; 1117 const struct v4l2_queryctrl* ctrl;
1120 1118
1121 ctrl = ctrl_by_id(c->id); 1119 ctrl = ctrl_by_id(c->id);
@@ -1160,20 +1158,31 @@ int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
1160 } 1158 }
1161 return 0; 1159 return 0;
1162} 1160}
1163EXPORT_SYMBOL_GPL(saa7134_g_ctrl); 1161EXPORT_SYMBOL_GPL(saa7134_g_ctrl_internal);
1162
1163static int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c)
1164{
1165 struct saa7134_fh *fh = priv;
1166
1167 return saa7134_g_ctrl_internal(fh->dev, fh, c);
1168}
1164 1169
1165int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c) 1170int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c)
1166{ 1171{
1167 const struct v4l2_queryctrl* ctrl; 1172 const struct v4l2_queryctrl* ctrl;
1168 struct saa7134_fh *fh = f;
1169 struct saa7134_dev *dev = fh->dev;
1170 unsigned long flags; 1173 unsigned long flags;
1171 int restart_overlay = 0; 1174 int restart_overlay = 0;
1172 int err = -EINVAL; 1175 int err;
1173 1176
1174 err = v4l2_prio_check(&dev->prio, &fh->prio); 1177 /* When called from the empress code fh == NULL.
1175 if (0 != err) 1178 That needs to be fixed somehow, but for now this is
1176 return err; 1179 good enough. */
1180 if (fh) {
1181 err = v4l2_prio_check(&dev->prio, &fh->prio);
1182 if (0 != err)
1183 return err;
1184 }
1185 err = -EINVAL;
1177 1186
1178 mutex_lock(&dev->lock); 1187 mutex_lock(&dev->lock);
1179 1188
@@ -1274,7 +1283,14 @@ error:
1274 mutex_unlock(&dev->lock); 1283 mutex_unlock(&dev->lock);
1275 return err; 1284 return err;
1276} 1285}
1277EXPORT_SYMBOL_GPL(saa7134_s_ctrl); 1286EXPORT_SYMBOL_GPL(saa7134_s_ctrl_internal);
1287
1288static int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
1289{
1290 struct saa7134_fh *fh = f;
1291
1292 return saa7134_s_ctrl_internal(fh->dev, fh, c);
1293}
1278 1294
1279/* ------------------------------------------------------------------ */ 1295/* ------------------------------------------------------------------ */
1280 1296
@@ -2353,26 +2369,7 @@ static const struct file_operations video_fops =
2353 .llseek = no_llseek, 2369 .llseek = no_llseek,
2354}; 2370};
2355 2371
2356static const struct file_operations radio_fops = 2372static const struct v4l2_ioctl_ops video_ioctl_ops = {
2357{
2358 .owner = THIS_MODULE,
2359 .open = video_open,
2360 .release = video_release,
2361 .ioctl = video_ioctl2,
2362 .compat_ioctl = v4l_compat_ioctl32,
2363 .llseek = no_llseek,
2364};
2365
2366/* ----------------------------------------------------------- */
2367/* exported stuff */
2368
2369struct video_device saa7134_video_template =
2370{
2371 .name = "saa7134-video",
2372 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER |
2373 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
2374 .fops = &video_fops,
2375 .minor = -1,
2376 .vidioc_querycap = saa7134_querycap, 2373 .vidioc_querycap = saa7134_querycap,
2377 .vidioc_enum_fmt_vid_cap = saa7134_enum_fmt_vid_cap, 2374 .vidioc_enum_fmt_vid_cap = saa7134_enum_fmt_vid_cap,
2378 .vidioc_g_fmt_vid_cap = saa7134_g_fmt_vid_cap, 2375 .vidioc_g_fmt_vid_cap = saa7134_g_fmt_vid_cap,
@@ -2421,16 +2418,18 @@ struct video_device saa7134_video_template =
2421 .vidioc_g_register = vidioc_g_register, 2418 .vidioc_g_register = vidioc_g_register,
2422 .vidioc_s_register = vidioc_s_register, 2419 .vidioc_s_register = vidioc_s_register,
2423#endif 2420#endif
2424 .tvnorms = SAA7134_NORMS,
2425 .current_norm = V4L2_STD_PAL,
2426}; 2421};
2427 2422
2428struct video_device saa7134_radio_template = 2423static const struct file_operations radio_fops = {
2429{ 2424 .owner = THIS_MODULE,
2430 .name = "saa7134-radio", 2425 .open = video_open,
2431 .type = VID_TYPE_TUNER, 2426 .release = video_release,
2432 .fops = &radio_fops, 2427 .ioctl = video_ioctl2,
2433 .minor = -1, 2428 .compat_ioctl = v4l_compat_ioctl32,
2429 .llseek = no_llseek,
2430};
2431
2432static const struct v4l2_ioctl_ops radio_ioctl_ops = {
2434 .vidioc_querycap = radio_querycap, 2433 .vidioc_querycap = radio_querycap,
2435 .vidioc_g_tuner = radio_g_tuner, 2434 .vidioc_g_tuner = radio_g_tuner,
2436 .vidioc_enum_input = radio_enum_input, 2435 .vidioc_enum_input = radio_enum_input,
@@ -2447,6 +2446,25 @@ struct video_device saa7134_radio_template =
2447 .vidioc_s_frequency = saa7134_s_frequency, 2446 .vidioc_s_frequency = saa7134_s_frequency,
2448}; 2447};
2449 2448
2449/* ----------------------------------------------------------- */
2450/* exported stuff */
2451
2452struct video_device saa7134_video_template = {
2453 .name = "saa7134-video",
2454 .fops = &video_fops,
2455 .ioctl_ops = &video_ioctl_ops,
2456 .minor = -1,
2457 .tvnorms = SAA7134_NORMS,
2458 .current_norm = V4L2_STD_PAL,
2459};
2460
2461struct video_device saa7134_radio_template = {
2462 .name = "saa7134-radio",
2463 .fops = &radio_fops,
2464 .ioctl_ops = &radio_ioctl_ops,
2465 .minor = -1,
2466};
2467
2450int saa7134_video_init1(struct saa7134_dev *dev) 2468int saa7134_video_init1(struct saa7134_dev *dev)
2451{ 2469{
2452 /* sanitycheck insmod options */ 2470 /* sanitycheck insmod options */
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 6927cbea8624..a0884f639f65 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -34,6 +34,7 @@
34#include <asm/io.h> 34#include <asm/io.h>
35 35
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
37#include <media/tuner.h> 38#include <media/tuner.h>
38#include <media/ir-common.h> 39#include <media/ir-common.h>
39#include <media/ir-kbd-i2c.h> 40#include <media/ir-kbd-i2c.h>
@@ -560,7 +561,7 @@ struct saa7134_dev {
560 /* SAA7134_MPEG_EMPRESS only */ 561 /* SAA7134_MPEG_EMPRESS only */
561 struct video_device *empress_dev; 562 struct video_device *empress_dev;
562 struct videobuf_queue empress_tsq; 563 struct videobuf_queue empress_tsq;
563 unsigned int empress_users; 564 atomic_t empress_users;
564 struct work_struct empress_workqueue; 565 struct work_struct empress_workqueue;
565 int empress_started; 566 int empress_started;
566 567
@@ -662,8 +663,8 @@ extern unsigned int video_debug;
662extern struct video_device saa7134_video_template; 663extern struct video_device saa7134_video_template;
663extern struct video_device saa7134_radio_template; 664extern struct video_device saa7134_radio_template;
664 665
665int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c); 666int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c);
666int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c); 667int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c);
667int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c); 668int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c);
668 669
669int saa7134_videoport_init(struct saa7134_dev *dev); 670int saa7134_videoport_init(struct saa7134_dev *dev);
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 2220f9569941..af60ede5310d 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -35,7 +35,6 @@
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/sched.h> 36#include <linux/sched.h>
37 37
38#include <linux/videodev.h>
39#include <linux/videodev2.h> 38#include <linux/videodev2.h>
40#include <linux/i2c.h> 39#include <linux/i2c.h>
41#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
diff --git a/drivers/media/video/saa7196.h b/drivers/media/video/saa7196.h
index cd4b6354a7b3..e69de29bb2d1 100644
--- a/drivers/media/video/saa7196.h
+++ b/drivers/media/video/saa7196.h
@@ -1,117 +0,0 @@
1/*
2 Definitions for the Philips SAA7196 digital video decoder,
3 scaler, and clock generator circuit (DESCpro), as used in
4 the PlanB video input of the Powermac 7x00/8x00 series.
5
6 Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
7
8 The register defines are shamelessly copied from the meteor
9 driver out of NetBSD (with permission),
10 and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe
11 (Thanks !)
12
13 Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu)
14
15 The default values used for PlanB are my mistakes.
16*/
17
18/* $Id: saa7196.h,v 1.5 1999/03/26 23:28:47 mlan Exp $ */
19
20#ifndef _SAA7196_H_
21#define _SAA7196_H_
22
23#define SAA7196_NUMREGS 0x31 /* Number of registers (used)*/
24#define NUM_SUPPORTED_NORM 3 /* Number of supported norms by PlanB */
25
26/* Decoder part: */
27#define SAA7196_IDEL 0x00 /* Increment delay */
28#define SAA7196_HSB5 0x01 /* H-sync begin; 50 hz */
29#define SAA7196_HSS5 0x02 /* H-sync stop; 50 hz */
30#define SAA7196_HCB5 0x03 /* H-clamp begin; 50 hz */
31#define SAA7196_HCS5 0x04 /* H-clamp stop; 50 hz */
32#define SAA7196_HSP5 0x05 /* H-sync after PHI1; 50 hz */
33#define SAA7196_LUMC 0x06 /* Luminance control */
34#define SAA7196_HUEC 0x07 /* Hue control */
35#define SAA7196_CKTQ 0x08 /* Colour Killer Threshold QAM (PAL, NTSC) */
36#define SAA7196_CKTS 0x09 /* Colour Killer Threshold SECAM */
37#define SAA7196_PALS 0x0a /* PAL switch sensitivity */
38#define SAA7196_SECAMS 0x0b /* SECAM switch sensitivity */
39#define SAA7196_CGAINC 0x0c /* Chroma gain control */
40#define SAA7196_STDC 0x0d /* Standard/Mode control */
41#define SAA7196_IOCC 0x0e /* I/O and Clock Control */
42#define SAA7196_CTRL1 0x0f /* Control #1 */
43#define SAA7196_CTRL2 0x10 /* Control #2 */
44#define SAA7196_CGAINR 0x11 /* Chroma Gain Reference */
45#define SAA7196_CSAT 0x12 /* Chroma Saturation */
46#define SAA7196_CONT 0x13 /* Luminance Contrast */
47#define SAA7196_HSB6 0x14 /* H-sync begin; 60 hz */
48#define SAA7196_HSS6 0x15 /* H-sync stop; 60 hz */
49#define SAA7196_HCB6 0x16 /* H-clamp begin; 60 hz */
50#define SAA7196_HCS6 0x17 /* H-clamp stop; 60 hz */
51#define SAA7196_HSP6 0x18 /* H-sync after PHI1; 60 hz */
52#define SAA7196_BRIG 0x19 /* Luminance Brightness */
53
54/* Scaler part: */
55#define SAA7196_FMTS 0x20 /* Formats and sequence */
56#define SAA7196_OUTPIX 0x21 /* Output data pixel/line */
57#define SAA7196_INPIX 0x22 /* Input data pixel/line */
58#define SAA7196_HWS 0x23 /* Horiz. window start */
59#define SAA7196_HFILT 0x24 /* Horiz. filter */
60#define SAA7196_OUTLINE 0x25 /* Output data lines/field */
61#define SAA7196_INLINE 0x26 /* Input data lines/field */
62#define SAA7196_VWS 0x27 /* Vertical window start */
63#define SAA7196_VYP 0x28 /* AFS/vertical Y processing */
64#define SAA7196_VBS 0x29 /* Vertical Bypass start */
65#define SAA7196_VBCNT 0x2a /* Vertical Bypass count */
66#define SAA7196_VBP 0x2b /* veritcal Bypass Polarity */
67#define SAA7196_VLOW 0x2c /* Colour-keying lower V limit */
68#define SAA7196_VHIGH 0x2d /* Colour-keying upper V limit */
69#define SAA7196_ULOW 0x2e /* Colour-keying lower U limit */
70#define SAA7196_UHIGH 0x2f /* Colour-keying upper U limit */
71#define SAA7196_DPATH 0x30 /* Data path setting */
72
73/* Initialization default values: */
74
75unsigned char saa_regs[NUM_SUPPORTED_NORM][SAA7196_NUMREGS] = {
76
77/* PAL, 768x576 (no scaling), composite video-in */
78/* Decoder: */
79 { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x63, 0xff,
80 0xfe, 0xf0, 0xfe, 0xe0, 0x20, 0x06, 0x3b, 0x98,
81 0x00, 0x59, 0x41, 0x45, 0x34, 0x0a, 0xf4, 0xd2,
82 0xe9, 0xa2,
83/* Padding */
84 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
85/* Scaler: */
86 0x72, 0x80, 0x00, 0x03, 0x8d, 0x20, 0x20, 0x12,
87 0xa5, 0x12, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
88 0x87 },
89
90/* NTSC, 640x480? (no scaling), composite video-in */
91/* Decoder: */
92 { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x50, 0x00,
93 0xf8, 0xf0, 0xfe, 0xe0, 0x00, 0x06, 0x3b, 0x98,
94 0x00, 0x2c, 0x3d, 0x40, 0x34, 0x0a, 0xf4, 0xd2,
95 0xe9, 0x98,
96/* Padding */
97 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
98/* Scaler: */
99 0x72, 0x80, 0x80, 0x03, 0x89, 0xf0, 0xf0, 0x0d,
100 0xa0, 0x0d, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
101 0x87 },
102
103/* SECAM, 768x576 (no scaling), composite video-in */
104/* Decoder: */
105 { 0x50, 0x30, 0x00, 0xe8, 0xb6, 0xe5, 0x63, 0xff,
106 0xfe, 0xf0, 0xfe, 0xe0, 0x20, 0x07, 0x3b, 0x98,
107 0x00, 0x59, 0x41, 0x45, 0x34, 0x0a, 0xf4, 0xd2,
108 0xe9, 0xa2,
109/* Padding */
110 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
111/* Scaler: */
112 0x72, 0x80, 0x00, 0x03, 0x8d, 0x20, 0x20, 0x12,
113 0xa5, 0x12, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
114 0x87 }
115 };
116
117#endif /* _SAA7196_H_ */
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index 1cd629380f71..f481277892da 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -1230,9 +1230,7 @@ static const struct file_operations se401_fops = {
1230 .llseek = no_llseek, 1230 .llseek = no_llseek,
1231}; 1231};
1232static struct video_device se401_template = { 1232static struct video_device se401_template = {
1233 .owner = THIS_MODULE,
1234 .name = "se401 USB camera", 1233 .name = "se401 USB camera",
1235 .type = VID_TYPE_CAPTURE,
1236 .fops = &se401_fops, 1234 .fops = &se401_fops,
1237}; 1235};
1238 1236
diff --git a/drivers/media/video/se401.h b/drivers/media/video/se401.h
index 835ef872e803..2ce685db5d8b 100644
--- a/drivers/media/video/se401.h
+++ b/drivers/media/video/se401.h
@@ -5,6 +5,7 @@
5#include <asm/uaccess.h> 5#include <asm/uaccess.h>
6#include <linux/videodev.h> 6#include <linux/videodev.h>
7#include <media/v4l2-common.h> 7#include <media/v4l2-common.h>
8#include <media/v4l2-ioctl.h>
8#include <linux/mutex.h> 9#include <linux/mutex.h>
9 10
10#define se401_DEBUG /* Turn on debug messages */ 11#define se401_DEBUG /* Turn on debug messages */
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 012005e1a77b..f7ca3cb9340a 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -91,6 +91,7 @@ struct sh_mobile_ceu_dev {
91 void __iomem *base; 91 void __iomem *base;
92 unsigned long video_limit; 92 unsigned long video_limit;
93 93
94 /* lock used to protect videobuf */
94 spinlock_t lock; 95 spinlock_t lock;
95 struct list_head capture; 96 struct list_head capture;
96 struct videobuf_buffer *active; 97 struct videobuf_buffer *active;
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 0c8d87d8d18d..cbfc44433b99 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -25,6 +25,7 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/list.h> 30#include <linux/list.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 7f9c7bcf3c85..23408764d0ef 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1038,8 +1038,7 @@ static ssize_t sn9c102_show_reg(struct device* cd,
1038 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1038 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1039 return -ERESTARTSYS; 1039 return -ERESTARTSYS;
1040 1040
1041 cam = video_get_drvdata(container_of(cd, struct video_device, 1041 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1042 class_dev));
1043 if (!cam) { 1042 if (!cam) {
1044 mutex_unlock(&sn9c102_sysfs_lock); 1043 mutex_unlock(&sn9c102_sysfs_lock);
1045 return -ENODEV; 1044 return -ENODEV;
@@ -1064,8 +1063,7 @@ sn9c102_store_reg(struct device* cd, struct device_attribute *attr,
1064 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1063 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1065 return -ERESTARTSYS; 1064 return -ERESTARTSYS;
1066 1065
1067 cam = video_get_drvdata(container_of(cd, struct video_device, 1066 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1068 class_dev));
1069 if (!cam) { 1067 if (!cam) {
1070 mutex_unlock(&sn9c102_sysfs_lock); 1068 mutex_unlock(&sn9c102_sysfs_lock);
1071 return -ENODEV; 1069 return -ENODEV;
@@ -1098,8 +1096,7 @@ static ssize_t sn9c102_show_val(struct device* cd,
1098 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1096 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1099 return -ERESTARTSYS; 1097 return -ERESTARTSYS;
1100 1098
1101 cam = video_get_drvdata(container_of(cd, struct video_device, 1099 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1102 class_dev));
1103 if (!cam) { 1100 if (!cam) {
1104 mutex_unlock(&sn9c102_sysfs_lock); 1101 mutex_unlock(&sn9c102_sysfs_lock);
1105 return -ENODEV; 1102 return -ENODEV;
@@ -1132,8 +1129,7 @@ sn9c102_store_val(struct device* cd, struct device_attribute *attr,
1132 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1129 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1133 return -ERESTARTSYS; 1130 return -ERESTARTSYS;
1134 1131
1135 cam = video_get_drvdata(container_of(cd, struct video_device, 1132 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1136 class_dev));
1137 if (!cam) { 1133 if (!cam) {
1138 mutex_unlock(&sn9c102_sysfs_lock); 1134 mutex_unlock(&sn9c102_sysfs_lock);
1139 return -ENODEV; 1135 return -ENODEV;
@@ -1170,8 +1166,7 @@ static ssize_t sn9c102_show_i2c_reg(struct device* cd,
1170 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1166 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1171 return -ERESTARTSYS; 1167 return -ERESTARTSYS;
1172 1168
1173 cam = video_get_drvdata(container_of(cd, struct video_device, 1169 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1174 class_dev));
1175 if (!cam) { 1170 if (!cam) {
1176 mutex_unlock(&sn9c102_sysfs_lock); 1171 mutex_unlock(&sn9c102_sysfs_lock);
1177 return -ENODEV; 1172 return -ENODEV;
@@ -1198,8 +1193,7 @@ sn9c102_store_i2c_reg(struct device* cd, struct device_attribute *attr,
1198 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1193 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1199 return -ERESTARTSYS; 1194 return -ERESTARTSYS;
1200 1195
1201 cam = video_get_drvdata(container_of(cd, struct video_device, 1196 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1202 class_dev));
1203 if (!cam) { 1197 if (!cam) {
1204 mutex_unlock(&sn9c102_sysfs_lock); 1198 mutex_unlock(&sn9c102_sysfs_lock);
1205 return -ENODEV; 1199 return -ENODEV;
@@ -1232,8 +1226,7 @@ static ssize_t sn9c102_show_i2c_val(struct device* cd,
1232 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1226 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1233 return -ERESTARTSYS; 1227 return -ERESTARTSYS;
1234 1228
1235 cam = video_get_drvdata(container_of(cd, struct video_device, 1229 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1236 class_dev));
1237 if (!cam) { 1230 if (!cam) {
1238 mutex_unlock(&sn9c102_sysfs_lock); 1231 mutex_unlock(&sn9c102_sysfs_lock);
1239 return -ENODEV; 1232 return -ENODEV;
@@ -1271,8 +1264,7 @@ sn9c102_store_i2c_val(struct device* cd, struct device_attribute *attr,
1271 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1264 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1272 return -ERESTARTSYS; 1265 return -ERESTARTSYS;
1273 1266
1274 cam = video_get_drvdata(container_of(cd, struct video_device, 1267 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1275 class_dev));
1276 if (!cam) { 1268 if (!cam) {
1277 mutex_unlock(&sn9c102_sysfs_lock); 1269 mutex_unlock(&sn9c102_sysfs_lock);
1278 return -ENODEV; 1270 return -ENODEV;
@@ -1318,8 +1310,7 @@ sn9c102_store_green(struct device* cd, struct device_attribute *attr,
1318 if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) 1310 if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
1319 return -ERESTARTSYS; 1311 return -ERESTARTSYS;
1320 1312
1321 cam = video_get_drvdata(container_of(cd, struct video_device, 1313 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1322 class_dev));
1323 if (!cam) { 1314 if (!cam) {
1324 mutex_unlock(&sn9c102_sysfs_lock); 1315 mutex_unlock(&sn9c102_sysfs_lock);
1325 return -ENODEV; 1316 return -ENODEV;
@@ -1400,8 +1391,7 @@ static ssize_t sn9c102_show_frame_header(struct device* cd,
1400 struct sn9c102_device* cam; 1391 struct sn9c102_device* cam;
1401 ssize_t count; 1392 ssize_t count;
1402 1393
1403 cam = video_get_drvdata(container_of(cd, struct video_device, 1394 cam = video_get_drvdata(container_of(cd, struct video_device, dev));
1404 class_dev));
1405 if (!cam) 1395 if (!cam)
1406 return -ENODEV; 1396 return -ENODEV;
1407 1397
@@ -1428,49 +1418,49 @@ static DEVICE_ATTR(frame_header, S_IRUGO, sn9c102_show_frame_header, NULL);
1428 1418
1429static int sn9c102_create_sysfs(struct sn9c102_device* cam) 1419static int sn9c102_create_sysfs(struct sn9c102_device* cam)
1430{ 1420{
1431 struct device *classdev = &(cam->v4ldev->class_dev); 1421 struct device *dev = &(cam->v4ldev->dev);
1432 int err = 0; 1422 int err = 0;
1433 1423
1434 if ((err = device_create_file(classdev, &dev_attr_reg))) 1424 if ((err = device_create_file(dev, &dev_attr_reg)))
1435 goto err_out; 1425 goto err_out;
1436 if ((err = device_create_file(classdev, &dev_attr_val))) 1426 if ((err = device_create_file(dev, &dev_attr_val)))
1437 goto err_reg; 1427 goto err_reg;
1438 if ((err = device_create_file(classdev, &dev_attr_frame_header))) 1428 if ((err = device_create_file(dev, &dev_attr_frame_header)))
1439 goto err_val; 1429 goto err_val;
1440 1430
1441 if (cam->sensor.sysfs_ops) { 1431 if (cam->sensor.sysfs_ops) {
1442 if ((err = device_create_file(classdev, &dev_attr_i2c_reg))) 1432 if ((err = device_create_file(dev, &dev_attr_i2c_reg)))
1443 goto err_frame_header; 1433 goto err_frame_header;
1444 if ((err = device_create_file(classdev, &dev_attr_i2c_val))) 1434 if ((err = device_create_file(dev, &dev_attr_i2c_val)))
1445 goto err_i2c_reg; 1435 goto err_i2c_reg;
1446 } 1436 }
1447 1437
1448 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) { 1438 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
1449 if ((err = device_create_file(classdev, &dev_attr_green))) 1439 if ((err = device_create_file(dev, &dev_attr_green)))
1450 goto err_i2c_val; 1440 goto err_i2c_val;
1451 } else { 1441 } else {
1452 if ((err = device_create_file(classdev, &dev_attr_blue))) 1442 if ((err = device_create_file(dev, &dev_attr_blue)))
1453 goto err_i2c_val; 1443 goto err_i2c_val;
1454 if ((err = device_create_file(classdev, &dev_attr_red))) 1444 if ((err = device_create_file(dev, &dev_attr_red)))
1455 goto err_blue; 1445 goto err_blue;
1456 } 1446 }
1457 1447
1458 return 0; 1448 return 0;
1459 1449
1460err_blue: 1450err_blue:
1461 device_remove_file(classdev, &dev_attr_blue); 1451 device_remove_file(dev, &dev_attr_blue);
1462err_i2c_val: 1452err_i2c_val:
1463 if (cam->sensor.sysfs_ops) 1453 if (cam->sensor.sysfs_ops)
1464 device_remove_file(classdev, &dev_attr_i2c_val); 1454 device_remove_file(dev, &dev_attr_i2c_val);
1465err_i2c_reg: 1455err_i2c_reg:
1466 if (cam->sensor.sysfs_ops) 1456 if (cam->sensor.sysfs_ops)
1467 device_remove_file(classdev, &dev_attr_i2c_reg); 1457 device_remove_file(dev, &dev_attr_i2c_reg);
1468err_frame_header: 1458err_frame_header:
1469 device_remove_file(classdev, &dev_attr_frame_header); 1459 device_remove_file(dev, &dev_attr_frame_header);
1470err_val: 1460err_val:
1471 device_remove_file(classdev, &dev_attr_val); 1461 device_remove_file(dev, &dev_attr_val);
1472err_reg: 1462err_reg:
1473 device_remove_file(classdev, &dev_attr_reg); 1463 device_remove_file(dev, &dev_attr_reg);
1474err_out: 1464err_out:
1475 return err; 1465 return err;
1476} 1466}
@@ -3319,8 +3309,6 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3319 } 3309 }
3320 3310
3321 strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); 3311 strcpy(cam->v4ldev->name, "SN9C1xx PC Camera");
3322 cam->v4ldev->owner = THIS_MODULE;
3323 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
3324 cam->v4ldev->fops = &sn9c102_fops; 3312 cam->v4ldev->fops = &sn9c102_fops;
3325 cam->v4ldev->minor = video_nr[dev_nr]; 3313 cam->v4ldev->minor = video_nr[dev_nr];
3326 cam->v4ldev->release = video_device_release; 3314 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index e39b98f1eca4..b6be5ee678b6 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -25,6 +25,7 @@
25#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
26 26
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <media/v4l2-dev.h> 29#include <media/v4l2-dev.h>
29#include <media/videobuf-core.h> 30#include <media/videobuf-core.h>
30#include <media/soc_camera.h> 31#include <media/soc_camera.h>
@@ -193,7 +194,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
193 mutex_lock(&video_lock); 194 mutex_lock(&video_lock);
194 195
195 vdev = video_devdata(file); 196 vdev = video_devdata(file);
196 icd = container_of(vdev->dev, struct soc_camera_device, dev); 197 icd = container_of(vdev->parent, struct soc_camera_device, dev);
197 ici = to_soc_camera_host(icd->dev.parent); 198 ici = to_soc_camera_host(icd->dev.parent);
198 199
199 if (!try_module_get(icd->ops->owner)) { 200 if (!try_module_get(icd->ops->owner)) {
@@ -258,7 +259,7 @@ static int soc_camera_close(struct inode *inode, struct file *file)
258 259
259 vfree(icf); 260 vfree(icf);
260 261
261 dev_dbg(vdev->dev, "camera device close\n"); 262 dev_dbg(vdev->parent, "camera device close\n");
262 263
263 return 0; 264 return 0;
264} 265}
@@ -271,7 +272,7 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf,
271 struct video_device *vdev = icd->vdev; 272 struct video_device *vdev = icd->vdev;
272 int err = -EINVAL; 273 int err = -EINVAL;
273 274
274 dev_err(vdev->dev, "camera device read not implemented\n"); 275 dev_err(vdev->parent, "camera device read not implemented\n");
275 276
276 return err; 277 return err;
277} 278}
@@ -861,6 +862,35 @@ void soc_camera_device_unregister(struct soc_camera_device *icd)
861} 862}
862EXPORT_SYMBOL(soc_camera_device_unregister); 863EXPORT_SYMBOL(soc_camera_device_unregister);
863 864
865static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = {
866 .vidioc_querycap = soc_camera_querycap,
867 .vidioc_g_fmt_vid_cap = soc_camera_g_fmt_vid_cap,
868 .vidioc_enum_fmt_vid_cap = soc_camera_enum_fmt_vid_cap,
869 .vidioc_s_fmt_vid_cap = soc_camera_s_fmt_vid_cap,
870 .vidioc_enum_input = soc_camera_enum_input,
871 .vidioc_g_input = soc_camera_g_input,
872 .vidioc_s_input = soc_camera_s_input,
873 .vidioc_s_std = soc_camera_s_std,
874 .vidioc_reqbufs = soc_camera_reqbufs,
875 .vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap,
876 .vidioc_querybuf = soc_camera_querybuf,
877 .vidioc_qbuf = soc_camera_qbuf,
878 .vidioc_dqbuf = soc_camera_dqbuf,
879 .vidioc_streamon = soc_camera_streamon,
880 .vidioc_streamoff = soc_camera_streamoff,
881 .vidioc_queryctrl = soc_camera_queryctrl,
882 .vidioc_g_ctrl = soc_camera_g_ctrl,
883 .vidioc_s_ctrl = soc_camera_s_ctrl,
884 .vidioc_cropcap = soc_camera_cropcap,
885 .vidioc_g_crop = soc_camera_g_crop,
886 .vidioc_s_crop = soc_camera_s_crop,
887 .vidioc_g_chip_ident = soc_camera_g_chip_ident,
888#ifdef CONFIG_VIDEO_ADV_DEBUG
889 .vidioc_g_register = soc_camera_g_register,
890 .vidioc_s_register = soc_camera_s_register,
891#endif
892};
893
864int soc_camera_video_start(struct soc_camera_device *icd) 894int soc_camera_video_start(struct soc_camera_device *icd)
865{ 895{
866 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 896 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
@@ -877,45 +907,19 @@ int soc_camera_video_start(struct soc_camera_device *icd)
877 907
878 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); 908 strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
879 /* Maybe better &ici->dev */ 909 /* Maybe better &ici->dev */
880 vdev->dev = &icd->dev; 910 vdev->parent = &icd->dev;
881 vdev->type = VID_TYPE_CAPTURE;
882 vdev->current_norm = V4L2_STD_UNKNOWN; 911 vdev->current_norm = V4L2_STD_UNKNOWN;
883 vdev->fops = &soc_camera_fops; 912 vdev->fops = &soc_camera_fops;
913 vdev->ioctl_ops = &soc_camera_ioctl_ops;
884 vdev->release = video_device_release; 914 vdev->release = video_device_release;
885 vdev->minor = -1; 915 vdev->minor = -1;
886 vdev->tvnorms = V4L2_STD_UNKNOWN, 916 vdev->tvnorms = V4L2_STD_UNKNOWN,
887 vdev->vidioc_querycap = soc_camera_querycap;
888 vdev->vidioc_g_fmt_vid_cap = soc_camera_g_fmt_vid_cap;
889 vdev->vidioc_enum_fmt_vid_cap = soc_camera_enum_fmt_vid_cap;
890 vdev->vidioc_s_fmt_vid_cap = soc_camera_s_fmt_vid_cap;
891 vdev->vidioc_enum_input = soc_camera_enum_input;
892 vdev->vidioc_g_input = soc_camera_g_input;
893 vdev->vidioc_s_input = soc_camera_s_input;
894 vdev->vidioc_s_std = soc_camera_s_std;
895 vdev->vidioc_reqbufs = soc_camera_reqbufs;
896 vdev->vidioc_try_fmt_vid_cap = soc_camera_try_fmt_vid_cap;
897 vdev->vidioc_querybuf = soc_camera_querybuf;
898 vdev->vidioc_qbuf = soc_camera_qbuf;
899 vdev->vidioc_dqbuf = soc_camera_dqbuf;
900 vdev->vidioc_streamon = soc_camera_streamon;
901 vdev->vidioc_streamoff = soc_camera_streamoff;
902 vdev->vidioc_queryctrl = soc_camera_queryctrl;
903 vdev->vidioc_g_ctrl = soc_camera_g_ctrl;
904 vdev->vidioc_s_ctrl = soc_camera_s_ctrl;
905 vdev->vidioc_cropcap = soc_camera_cropcap;
906 vdev->vidioc_g_crop = soc_camera_g_crop;
907 vdev->vidioc_s_crop = soc_camera_s_crop;
908 vdev->vidioc_g_chip_ident = soc_camera_g_chip_ident;
909#ifdef CONFIG_VIDEO_ADV_DEBUG
910 vdev->vidioc_g_register = soc_camera_g_register;
911 vdev->vidioc_s_register = soc_camera_s_register;
912#endif
913 917
914 icd->current_fmt = &icd->formats[0]; 918 icd->current_fmt = &icd->formats[0];
915 919
916 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor); 920 err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
917 if (err < 0) { 921 if (err < 0) {
918 dev_err(vdev->dev, "video_register_device failed\n"); 922 dev_err(vdev->parent, "video_register_device failed\n");
919 goto evidregd; 923 goto evidregd;
920 } 924 }
921 icd->vdev = vdev; 925 icd->vdev = vdev;
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index f308c38d744f..ad36af30e099 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -34,6 +34,7 @@
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/videodev2.h> 35#include <linux/videodev2.h>
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
37 38
38#include "stk-webcam.h" 39#include "stk-webcam.h"
39 40
@@ -340,17 +341,19 @@ static int stk_create_sysfs_files(struct video_device *vdev)
340{ 341{
341 int ret; 342 int ret;
342 343
343 ret = video_device_create_file(vdev, &dev_attr_brightness); 344 ret = device_create_file(&vdev->dev, &dev_attr_brightness);
344 ret += video_device_create_file(vdev, &dev_attr_hflip); 345 ret += device_create_file(&vdev->dev, &dev_attr_hflip);
345 ret += video_device_create_file(vdev, &dev_attr_vflip); 346 ret += device_create_file(&vdev->dev, &dev_attr_vflip);
347 if (ret)
348 STK_WARNING("Could not create sysfs files\n");
346 return ret; 349 return ret;
347} 350}
348 351
349static void stk_remove_sysfs_files(struct video_device *vdev) 352static void stk_remove_sysfs_files(struct video_device *vdev)
350{ 353{
351 video_device_remove_file(vdev, &dev_attr_brightness); 354 device_remove_file(&vdev->dev, &dev_attr_brightness);
352 video_device_remove_file(vdev, &dev_attr_hflip); 355 device_remove_file(&vdev->dev, &dev_attr_hflip);
353 video_device_remove_file(vdev, &dev_attr_vflip); 356 device_remove_file(&vdev->dev, &dev_attr_vflip);
354} 357}
355 358
356#else 359#else
@@ -442,18 +445,19 @@ static void stk_isoc_handler(struct urb *urb)
442 fb->v4lbuf.bytesused = 0; 445 fb->v4lbuf.bytesused = 0;
443 fill = fb->buffer; 446 fill = fb->buffer;
444 } else if (fb->v4lbuf.bytesused == dev->frame_size) { 447 } else if (fb->v4lbuf.bytesused == dev->frame_size) {
445 list_move_tail(dev->sio_avail.next, 448 if (list_is_singular(&dev->sio_avail)) {
446 &dev->sio_full); 449 /* Always reuse the last buffer */
447 wake_up(&dev->wait_frame); 450 fb->v4lbuf.bytesused = 0;
448 if (list_empty(&dev->sio_avail)) { 451 fill = fb->buffer;
449 (void) (printk_ratelimit() && 452 } else {
450 STK_ERROR("No buffer available\n")); 453 list_move_tail(dev->sio_avail.next,
451 goto resubmit; 454 &dev->sio_full);
455 wake_up(&dev->wait_frame);
456 fb = list_first_entry(&dev->sio_avail,
457 struct stk_sio_buffer, list);
458 fb->v4lbuf.bytesused = 0;
459 fill = fb->buffer;
452 } 460 }
453 fb = list_first_entry(&dev->sio_avail,
454 struct stk_sio_buffer, list);
455 fb->v4lbuf.bytesused = 0;
456 fill = fb->buffer;
457 } 461 }
458 } else { 462 } else {
459 framelen -= 4; 463 framelen -= 4;
@@ -1327,20 +1331,7 @@ static struct file_operations v4l_stk_fops = {
1327 .llseek = no_llseek 1331 .llseek = no_llseek
1328}; 1332};
1329 1333
1330static void stk_v4l_dev_release(struct video_device *vd) 1334static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
1331{
1332}
1333
1334static struct video_device stk_v4l_data = {
1335 .name = "stkwebcam",
1336 .type = VFL_TYPE_GRABBER,
1337 .type2 = VID_TYPE_CAPTURE,
1338 .minor = -1,
1339 .tvnorms = V4L2_STD_UNKNOWN,
1340 .current_norm = V4L2_STD_UNKNOWN,
1341 .fops = &v4l_stk_fops,
1342 .release = stk_v4l_dev_release,
1343
1344 .vidioc_querycap = stk_vidioc_querycap, 1335 .vidioc_querycap = stk_vidioc_querycap,
1345 .vidioc_enum_fmt_vid_cap = stk_vidioc_enum_fmt_vid_cap, 1336 .vidioc_enum_fmt_vid_cap = stk_vidioc_enum_fmt_vid_cap,
1346 .vidioc_try_fmt_vid_cap = stk_vidioc_try_fmt_vid_cap, 1337 .vidioc_try_fmt_vid_cap = stk_vidioc_try_fmt_vid_cap,
@@ -1362,6 +1353,20 @@ static struct video_device stk_v4l_data = {
1362 .vidioc_g_parm = stk_vidioc_g_parm, 1353 .vidioc_g_parm = stk_vidioc_g_parm,
1363}; 1354};
1364 1355
1356static void stk_v4l_dev_release(struct video_device *vd)
1357{
1358}
1359
1360static struct video_device stk_v4l_data = {
1361 .name = "stkwebcam",
1362 .minor = -1,
1363 .tvnorms = V4L2_STD_UNKNOWN,
1364 .current_norm = V4L2_STD_UNKNOWN,
1365 .fops = &v4l_stk_fops,
1366 .ioctl_ops = &v4l_stk_ioctl_ops,
1367 .release = stk_v4l_dev_release,
1368};
1369
1365 1370
1366static int stk_register_video_device(struct stk_camera *dev) 1371static int stk_register_video_device(struct stk_camera *dev)
1367{ 1372{
@@ -1369,7 +1374,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1369 1374
1370 dev->vdev = stk_v4l_data; 1375 dev->vdev = stk_v4l_data;
1371 dev->vdev.debug = debug; 1376 dev->vdev.debug = debug;
1372 dev->vdev.dev = &dev->interface->dev; 1377 dev->vdev.parent = &dev->interface->dev;
1373 dev->vdev.priv = dev; 1378 dev->vdev.priv = dev;
1374 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); 1379 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
1375 if (err) 1380 if (err)
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index c109511f21ea..276bded06ab3 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -43,6 +43,7 @@
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/videodev.h> 44#include <linux/videodev.h>
45#include <media/v4l2-common.h> 45#include <media/v4l2-common.h>
46#include <media/v4l2-ioctl.h>
46 47
47#include "saa7146.h" 48#include "saa7146.h"
48#include "saa7146reg.h" 49#include "saa7146reg.h"
@@ -1918,7 +1919,6 @@ static const struct file_operations saa_fops = {
1918/* template for video_device-structure */ 1919/* template for video_device-structure */
1919static struct video_device saa_template = { 1920static struct video_device saa_template = {
1920 .name = "SAA7146A", 1921 .name = "SAA7146A",
1921 .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY,
1922 .fops = &saa_fops, 1922 .fops = &saa_fops,
1923 .minor = -1, 1923 .minor = -1,
1924}; 1924};
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index d7f130bedb5f..56dc3d6b5b29 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -66,6 +66,7 @@
66#include <linux/errno.h> 66#include <linux/errno.h>
67#include <linux/videodev.h> 67#include <linux/videodev.h>
68#include <media/v4l2-common.h> 68#include <media/v4l2-common.h>
69#include <media/v4l2-ioctl.h>
69#include <linux/usb.h> 70#include <linux/usb.h>
70#include <linux/mutex.h> 71#include <linux/mutex.h>
71 72
@@ -524,53 +525,54 @@ static int stv680_create_sysfs_files(struct video_device *vdev)
524{ 525{
525 int rc; 526 int rc;
526 527
527 rc = video_device_create_file(vdev, &dev_attr_model); 528 rc = device_create_file(&vdev->dev, &dev_attr_model);
528 if (rc) goto err; 529 if (rc) goto err;
529 rc = video_device_create_file(vdev, &dev_attr_in_use); 530 rc = device_create_file(&vdev->dev, &dev_attr_in_use);
530 if (rc) goto err_model; 531 if (rc) goto err_model;
531 rc = video_device_create_file(vdev, &dev_attr_streaming); 532 rc = device_create_file(&vdev->dev, &dev_attr_streaming);
532 if (rc) goto err_inuse; 533 if (rc) goto err_inuse;
533 rc = video_device_create_file(vdev, &dev_attr_palette); 534 rc = device_create_file(&vdev->dev, &dev_attr_palette);
534 if (rc) goto err_stream; 535 if (rc) goto err_stream;
535 rc = video_device_create_file(vdev, &dev_attr_frames_total); 536 rc = device_create_file(&vdev->dev, &dev_attr_frames_total);
536 if (rc) goto err_pal; 537 if (rc) goto err_pal;
537 rc = video_device_create_file(vdev, &dev_attr_frames_read); 538 rc = device_create_file(&vdev->dev, &dev_attr_frames_read);
538 if (rc) goto err_framtot; 539 if (rc) goto err_framtot;
539 rc = video_device_create_file(vdev, &dev_attr_packets_dropped); 540 rc = device_create_file(&vdev->dev, &dev_attr_packets_dropped);
540 if (rc) goto err_framread; 541 if (rc) goto err_framread;
541 rc = video_device_create_file(vdev, &dev_attr_decoding_errors); 542 rc = device_create_file(&vdev->dev, &dev_attr_decoding_errors);
542 if (rc) goto err_dropped; 543 if (rc) goto err_dropped;
543 544
544 return 0; 545 return 0;
545 546
546err_dropped: 547err_dropped:
547 video_device_remove_file(vdev, &dev_attr_packets_dropped); 548 device_remove_file(&vdev->dev, &dev_attr_packets_dropped);
548err_framread: 549err_framread:
549 video_device_remove_file(vdev, &dev_attr_frames_read); 550 device_remove_file(&vdev->dev, &dev_attr_frames_read);
550err_framtot: 551err_framtot:
551 video_device_remove_file(vdev, &dev_attr_frames_total); 552 device_remove_file(&vdev->dev, &dev_attr_frames_total);
552err_pal: 553err_pal:
553 video_device_remove_file(vdev, &dev_attr_palette); 554 device_remove_file(&vdev->dev, &dev_attr_palette);
554err_stream: 555err_stream:
555 video_device_remove_file(vdev, &dev_attr_streaming); 556 device_remove_file(&vdev->dev, &dev_attr_streaming);
556err_inuse: 557err_inuse:
557 video_device_remove_file(vdev, &dev_attr_in_use); 558 device_remove_file(&vdev->dev, &dev_attr_in_use);
558err_model: 559err_model:
559 video_device_remove_file(vdev, &dev_attr_model); 560 device_remove_file(&vdev->dev, &dev_attr_model);
560err: 561err:
562 PDEBUG(0, "STV(e): Could not create sysfs files");
561 return rc; 563 return rc;
562} 564}
563 565
564static void stv680_remove_sysfs_files(struct video_device *vdev) 566static void stv680_remove_sysfs_files(struct video_device *vdev)
565{ 567{
566 video_device_remove_file(vdev, &dev_attr_model); 568 device_remove_file(&vdev->dev, &dev_attr_model);
567 video_device_remove_file(vdev, &dev_attr_in_use); 569 device_remove_file(&vdev->dev, &dev_attr_in_use);
568 video_device_remove_file(vdev, &dev_attr_streaming); 570 device_remove_file(&vdev->dev, &dev_attr_streaming);
569 video_device_remove_file(vdev, &dev_attr_palette); 571 device_remove_file(&vdev->dev, &dev_attr_palette);
570 video_device_remove_file(vdev, &dev_attr_frames_total); 572 device_remove_file(&vdev->dev, &dev_attr_frames_total);
571 video_device_remove_file(vdev, &dev_attr_frames_read); 573 device_remove_file(&vdev->dev, &dev_attr_frames_read);
572 video_device_remove_file(vdev, &dev_attr_packets_dropped); 574 device_remove_file(&vdev->dev, &dev_attr_packets_dropped);
573 video_device_remove_file(vdev, &dev_attr_decoding_errors); 575 device_remove_file(&vdev->dev, &dev_attr_decoding_errors);
574} 576}
575 577
576/******************************************************************** 578/********************************************************************
@@ -1400,9 +1402,7 @@ static const struct file_operations stv680_fops = {
1400 .llseek = no_llseek, 1402 .llseek = no_llseek,
1401}; 1403};
1402static struct video_device stv680_template = { 1404static struct video_device stv680_template = {
1403 .owner = THIS_MODULE,
1404 .name = "STV0680 USB camera", 1405 .name = "STV0680 USB camera",
1405 .type = VID_TYPE_CAPTURE,
1406 .fops = &stv680_fops, 1406 .fops = &stv680_fops,
1407 .release = video_device_release, 1407 .release = video_device_release,
1408 .minor = -1, 1408 .minor = -1,
@@ -1454,7 +1454,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1454 goto error; 1454 goto error;
1455 } 1455 }
1456 memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template)); 1456 memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template));
1457 stv680->vdev->dev = &intf->dev; 1457 stv680->vdev->parent = &intf->dev;
1458 video_set_drvdata(stv680->vdev, stv680); 1458 video_set_drvdata(stv680->vdev, stv680);
1459 1459
1460 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name)); 1460 memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name));
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index ae75c187da79..4963d4264880 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -44,10 +44,11 @@
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/errno.h> 45#include <linux/errno.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/videodev.h> 47#include <linux/videodev2.h>
48#include <linux/i2c.h> 48#include <linux/i2c.h>
49 49
50#include <media/v4l2-common.h> 50#include <media/v4l2-common.h>
51#include <media/v4l2-ioctl.h>
51#include <media/i2c-addr.h> 52#include <media/i2c-addr.h>
52 53
53#ifndef VIDEO_AUDIO_BALANCE 54#ifndef VIDEO_AUDIO_BALANCE
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 7a8ce8fb46dc..792f0b079909 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -25,7 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/videodev.h> 28#include <linux/videodev2.h>
29#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/init.h> 31#include <linux/init.h>
diff --git a/drivers/media/video/tlv320aic23b.c b/drivers/media/video/tlv320aic23b.c
index 9220378a5637..281065b9dd2d 100644
--- a/drivers/media/video/tlv320aic23b.c
+++ b/drivers/media/video/tlv320aic23b.c
@@ -29,7 +29,7 @@
29#include <asm/uaccess.h> 29#include <asm/uaccess.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/i2c-id.h> 31#include <linux/i2c-id.h>
32#include <linux/videodev.h> 32#include <linux/videodev2.h>
33#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
34#include <media/v4l2-i2c-drv-legacy.h> 34#include <media/v4l2-i2c-drv-legacy.h>
35 35
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 93d879dc510f..d806a3556eed 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -19,6 +19,7 @@
19#include <media/tuner.h> 19#include <media/tuner.h>
20#include <media/tuner-types.h> 20#include <media/tuner-types.h>
21#include <media/v4l2-common.h> 21#include <media/v4l2-common.h>
22#include <media/v4l2-ioctl.h>
22#include <media/v4l2-i2c-drv-legacy.h> 23#include <media/v4l2-i2c-drv-legacy.h>
23#include "mt20xx.h" 24#include "mt20xx.h"
24#include "tda8290.h" 25#include "tda8290.h"
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 9da0e1807ffb..bcc32fa92a81 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -34,13 +34,13 @@
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/videodev.h> 37#include <linux/videodev2.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39 39
40#include <media/tuner.h> 40#include <media/tuner.h>
41#include <media/tveeprom.h> 41#include <media/tveeprom.h>
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <media/audiochip.h> 43#include <media/v4l2-chip-ident.h>
44 44
45MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver"); 45MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver");
46MODULE_AUTHOR("John Klar"); 46MODULE_AUTHOR("John Klar");
@@ -261,70 +261,72 @@ hauppauge_tuner[] =
261 { TUNER_ABSENT, "MaxLinear MXL5005_v2"}, 261 { TUNER_ABSENT, "MaxLinear MXL5005_v2"},
262 { TUNER_PHILIPS_TDA8290, "Philips 18271_8295"}, 262 { TUNER_PHILIPS_TDA8290, "Philips 18271_8295"},
263 /* 150-159 */ 263 /* 150-159 */
264 { TUNER_ABSENT, "Xceive XC5000"}, 264 { TUNER_ABSENT, "Xceive XC5000"},
265}; 265};
266 266
267/* Use V4L2_IDENT_AMBIGUOUS for those audio 'chips' that are
268 * internal to a video chip, i.e. not a separate audio chip. */
267static struct HAUPPAUGE_AUDIOIC 269static struct HAUPPAUGE_AUDIOIC
268{ 270{
269 enum audiochip id; 271 u32 id;
270 char *name; 272 char *name;
271} 273}
272audioIC[] = 274audioIC[] =
273{ 275{
274 /* 0-4 */ 276 /* 0-4 */
275 {AUDIO_CHIP_NONE, "None"}, 277 { V4L2_IDENT_NONE, "None" },
276 {AUDIO_CHIP_TEA6300, "TEA6300"}, 278 { V4L2_IDENT_UNKNOWN, "TEA6300" },
277 {AUDIO_CHIP_TEA6300, "TEA6320"}, 279 { V4L2_IDENT_UNKNOWN, "TEA6320" },
278 {AUDIO_CHIP_TDA985X, "TDA9850"}, 280 { V4L2_IDENT_UNKNOWN, "TDA9850" },
279 {AUDIO_CHIP_MSP34XX, "MSP3400C"}, 281 { V4L2_IDENT_MSPX4XX, "MSP3400C" },
280 /* 5-9 */ 282 /* 5-9 */
281 {AUDIO_CHIP_MSP34XX, "MSP3410D"}, 283 { V4L2_IDENT_MSPX4XX, "MSP3410D" },
282 {AUDIO_CHIP_MSP34XX, "MSP3415"}, 284 { V4L2_IDENT_MSPX4XX, "MSP3415" },
283 {AUDIO_CHIP_MSP34XX, "MSP3430"}, 285 { V4L2_IDENT_MSPX4XX, "MSP3430" },
284 {AUDIO_CHIP_MSP34XX, "MSP3438"}, 286 { V4L2_IDENT_MSPX4XX, "MSP3438" },
285 {AUDIO_CHIP_UNKNOWN, "CS5331"}, 287 { V4L2_IDENT_UNKNOWN, "CS5331" },
286 /* 10-14 */ 288 /* 10-14 */
287 {AUDIO_CHIP_MSP34XX, "MSP3435"}, 289 { V4L2_IDENT_MSPX4XX, "MSP3435" },
288 {AUDIO_CHIP_MSP34XX, "MSP3440"}, 290 { V4L2_IDENT_MSPX4XX, "MSP3440" },
289 {AUDIO_CHIP_MSP34XX, "MSP3445"}, 291 { V4L2_IDENT_MSPX4XX, "MSP3445" },
290 {AUDIO_CHIP_MSP34XX, "MSP3411"}, 292 { V4L2_IDENT_MSPX4XX, "MSP3411" },
291 {AUDIO_CHIP_MSP34XX, "MSP3416"}, 293 { V4L2_IDENT_MSPX4XX, "MSP3416" },
292 /* 15-19 */ 294 /* 15-19 */
293 {AUDIO_CHIP_MSP34XX, "MSP3425"}, 295 { V4L2_IDENT_MSPX4XX, "MSP3425" },
294 {AUDIO_CHIP_MSP34XX, "MSP3451"}, 296 { V4L2_IDENT_MSPX4XX, "MSP3451" },
295 {AUDIO_CHIP_MSP34XX, "MSP3418"}, 297 { V4L2_IDENT_MSPX4XX, "MSP3418" },
296 {AUDIO_CHIP_UNKNOWN, "Type 0x12"}, 298 { V4L2_IDENT_UNKNOWN, "Type 0x12" },
297 {AUDIO_CHIP_UNKNOWN, "OKI7716"}, 299 { V4L2_IDENT_UNKNOWN, "OKI7716" },
298 /* 20-24 */ 300 /* 20-24 */
299 {AUDIO_CHIP_MSP34XX, "MSP4410"}, 301 { V4L2_IDENT_MSPX4XX, "MSP4410" },
300 {AUDIO_CHIP_MSP34XX, "MSP4420"}, 302 { V4L2_IDENT_MSPX4XX, "MSP4420" },
301 {AUDIO_CHIP_MSP34XX, "MSP4440"}, 303 { V4L2_IDENT_MSPX4XX, "MSP4440" },
302 {AUDIO_CHIP_MSP34XX, "MSP4450"}, 304 { V4L2_IDENT_MSPX4XX, "MSP4450" },
303 {AUDIO_CHIP_MSP34XX, "MSP4408"}, 305 { V4L2_IDENT_MSPX4XX, "MSP4408" },
304 /* 25-29 */ 306 /* 25-29 */
305 {AUDIO_CHIP_MSP34XX, "MSP4418"}, 307 { V4L2_IDENT_MSPX4XX, "MSP4418" },
306 {AUDIO_CHIP_MSP34XX, "MSP4428"}, 308 { V4L2_IDENT_MSPX4XX, "MSP4428" },
307 {AUDIO_CHIP_MSP34XX, "MSP4448"}, 309 { V4L2_IDENT_MSPX4XX, "MSP4448" },
308 {AUDIO_CHIP_MSP34XX, "MSP4458"}, 310 { V4L2_IDENT_MSPX4XX, "MSP4458" },
309 {AUDIO_CHIP_MSP34XX, "Type 0x1d"}, 311 { V4L2_IDENT_MSPX4XX, "Type 0x1d" },
310 /* 30-34 */ 312 /* 30-34 */
311 {AUDIO_CHIP_INTERNAL, "CX880"}, 313 { V4L2_IDENT_AMBIGUOUS, "CX880" },
312 {AUDIO_CHIP_INTERNAL, "CX881"}, 314 { V4L2_IDENT_AMBIGUOUS, "CX881" },
313 {AUDIO_CHIP_INTERNAL, "CX883"}, 315 { V4L2_IDENT_AMBIGUOUS, "CX883" },
314 {AUDIO_CHIP_INTERNAL, "CX882"}, 316 { V4L2_IDENT_AMBIGUOUS, "CX882" },
315 {AUDIO_CHIP_INTERNAL, "CX25840"}, 317 { V4L2_IDENT_AMBIGUOUS, "CX25840" },
316 /* 35-39 */ 318 /* 35-39 */
317 {AUDIO_CHIP_INTERNAL, "CX25841"}, 319 { V4L2_IDENT_AMBIGUOUS, "CX25841" },
318 {AUDIO_CHIP_INTERNAL, "CX25842"}, 320 { V4L2_IDENT_AMBIGUOUS, "CX25842" },
319 {AUDIO_CHIP_INTERNAL, "CX25843"}, 321 { V4L2_IDENT_AMBIGUOUS, "CX25843" },
320 {AUDIO_CHIP_INTERNAL, "CX23418"}, 322 { V4L2_IDENT_AMBIGUOUS, "CX23418" },
321 {AUDIO_CHIP_INTERNAL, "CX23885"}, 323 { V4L2_IDENT_AMBIGUOUS, "CX23885" },
322 /* 40-44 */ 324 /* 40-44 */
323 {AUDIO_CHIP_INTERNAL, "CX23888"}, 325 { V4L2_IDENT_AMBIGUOUS, "CX23888" },
324 {AUDIO_CHIP_INTERNAL, "SAA7131"}, 326 { V4L2_IDENT_AMBIGUOUS, "SAA7131" },
325 {AUDIO_CHIP_INTERNAL, "CX23887"}, 327 { V4L2_IDENT_AMBIGUOUS, "CX23887" },
326 {AUDIO_CHIP_INTERNAL, "SAA7164"}, 328 { V4L2_IDENT_AMBIGUOUS, "SAA7164" },
327 {AUDIO_CHIP_INTERNAL, "AU8522"}, 329 { V4L2_IDENT_AMBIGUOUS, "AU8522" },
328}; 330};
329 331
330/* This list is supplied by Hauppauge. Thanks! */ 332/* This list is supplied by Hauppauge. Thanks! */
@@ -483,7 +485,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
483 tvee->has_radio = eeprom_data[i+len-1]; 485 tvee->has_radio = eeprom_data[i+len-1];
484 /* old style tag, don't know how to detect 486 /* old style tag, don't know how to detect
485 IR presence, mark as unknown. */ 487 IR presence, mark as unknown. */
486 tvee->has_ir = -1; 488 tvee->has_ir = 0;
487 tvee->model = 489 tvee->model =
488 eeprom_data[i+8] + 490 eeprom_data[i+8] +
489 (eeprom_data[i+9] << 8); 491 (eeprom_data[i+9] << 8);
@@ -509,7 +511,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
509 if (audioic < ARRAY_SIZE(audioIC)) 511 if (audioic < ARRAY_SIZE(audioIC))
510 tvee->audio_processor = audioIC[audioic].id; 512 tvee->audio_processor = audioIC[audioic].id;
511 else 513 else
512 tvee->audio_processor = AUDIO_CHIP_UNKNOWN; 514 tvee->audio_processor = V4L2_IDENT_UNKNOWN;
513 break; 515 break;
514 516
515 /* case 0x03: tag 'EEInfo' */ 517 /* case 0x03: tag 'EEInfo' */
@@ -542,7 +544,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
542 if (audioic < ARRAY_SIZE(audioIC)) 544 if (audioic < ARRAY_SIZE(audioIC))
543 tvee->audio_processor = audioIC[audioic].id; 545 tvee->audio_processor = audioIC[audioic].id;
544 else 546 else
545 tvee->audio_processor = AUDIO_CHIP_UNKNOWN; 547 tvee->audio_processor = V4L2_IDENT_UNKNOWN;
546 548
547 break; 549 break;
548 550
@@ -603,7 +605,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
603 605
604 case 0x0f: 606 case 0x0f:
605 /* tag 'IRInfo' */ 607 /* tag 'IRInfo' */
606 tvee->has_ir = eeprom_data[i+1]; 608 tvee->has_ir = 1 | (eeprom_data[i+1] << 1);
607 break; 609 break;
608 610
609 /* case 0x10: tag 'VBIInfo' */ 611 /* case 0x10: tag 'VBIInfo' */
@@ -690,7 +692,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
690 t_fmt_name2[6], t_fmt_name2[7], t_format2); 692 t_fmt_name2[6], t_fmt_name2[7], t_format2);
691 if (audioic < 0) { 693 if (audioic < 0) {
692 tveeprom_info("audio processor is unknown (no idx)\n"); 694 tveeprom_info("audio processor is unknown (no idx)\n");
693 tvee->audio_processor = AUDIO_CHIP_UNKNOWN; 695 tvee->audio_processor = V4L2_IDENT_UNKNOWN;
694 } else { 696 } else {
695 if (audioic < ARRAY_SIZE(audioIC)) 697 if (audioic < ARRAY_SIZE(audioIC))
696 tveeprom_info("audio processor is %s (idx %d)\n", 698 tveeprom_info("audio processor is %s (idx %d)\n",
@@ -703,14 +705,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
703 tveeprom_info("decoder processor is %s (idx %d)\n", 705 tveeprom_info("decoder processor is %s (idx %d)\n",
704 STRM(decoderIC, tvee->decoder_processor), 706 STRM(decoderIC, tvee->decoder_processor),
705 tvee->decoder_processor); 707 tvee->decoder_processor);
706 if (tvee->has_ir == -1) 708 if (tvee->has_ir)
707 tveeprom_info("has %sradio\n",
708 tvee->has_radio ? "" : "no ");
709 else
710 tveeprom_info("has %sradio, has %sIR receiver, has %sIR transmitter\n", 709 tveeprom_info("has %sradio, has %sIR receiver, has %sIR transmitter\n",
711 tvee->has_radio ? "" : "no ", 710 tvee->has_radio ? "" : "no ",
712 (tvee->has_ir & 1) ? "" : "no ", 711 (tvee->has_ir & 2) ? "" : "no ",
713 (tvee->has_ir & 2) ? "" : "no "); 712 (tvee->has_ir & 4) ? "" : "no ");
713 else
714 tveeprom_info("has %sradio\n",
715 tvee->has_radio ? "" : "no ");
714} 716}
715EXPORT_SYMBOL(tveeprom_hauppauge_analog); 717EXPORT_SYMBOL(tveeprom_hauppauge_analog);
716 718
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 6a3af1005f03..28af5ce5560d 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include <linux/i2c.h> 8#include <linux/i2c.h>
9#include <linux/videodev.h> 9#include <linux/videodev2.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/video_decoder.h> 11#include <linux/video_decoder.h>
12#include <media/v4l2-common.h> 12#include <media/v4l2-common.h>
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 4128ee20b64e..bf1bc2f69b02 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -952,8 +952,6 @@ static const struct file_operations usbvideo_fops = {
952 .llseek = no_llseek, 952 .llseek = no_llseek,
953}; 953};
954static const struct video_device usbvideo_template = { 954static const struct video_device usbvideo_template = {
955 .owner = THIS_MODULE,
956 .type = VID_TYPE_CAPTURE,
957 .fops = &usbvideo_fops, 955 .fops = &usbvideo_fops,
958}; 956};
959 957
@@ -1040,7 +1038,7 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
1040 err("%s: uvd->dev == NULL", __func__); 1038 err("%s: uvd->dev == NULL", __func__);
1041 return -EINVAL; 1039 return -EINVAL;
1042 } 1040 }
1043 uvd->vdev.dev = &uvd->dev->dev; 1041 uvd->vdev.parent = &uvd->dev->dev;
1044 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 1042 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
1045 err("%s: video_register_device failed", __func__); 1043 err("%s: video_register_device failed", __func__);
1046 return -EPIPE; 1044 return -EPIPE;
diff --git a/drivers/media/video/usbvideo/usbvideo.h b/drivers/media/video/usbvideo/usbvideo.h
index 051775d4c726..c66985beb8c9 100644
--- a/drivers/media/video/usbvideo/usbvideo.h
+++ b/drivers/media/video/usbvideo/usbvideo.h
@@ -18,6 +18,7 @@
18 18
19#include <linux/videodev.h> 19#include <linux/videodev.h>
20#include <media/v4l2-common.h> 20#include <media/v4l2-common.h>
21#include <media/v4l2-ioctl.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23 24
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 40d053e0d5bf..b7792451a299 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -41,6 +41,7 @@
41#include <linux/videodev.h> 41#include <linux/videodev.h>
42#include <linux/usb.h> 42#include <linux/usb.h>
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/mm.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
45#include <linux/mutex.h> 46#include <linux/mutex.h>
46#include <linux/firmware.h> 47#include <linux/firmware.h>
@@ -791,9 +792,7 @@ static const struct file_operations vicam_fops = {
791}; 792};
792 793
793static struct video_device vicam_template = { 794static struct video_device vicam_template = {
794 .owner = THIS_MODULE,
795 .name = "ViCam-based USB Camera", 795 .name = "ViCam-based USB Camera",
796 .type = VID_TYPE_CAPTURE,
797 .fops = &vicam_fops, 796 .fops = &vicam_fops,
798 .minor = -1, 797 .minor = -1,
799}; 798};
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index abf685464b7c..c317ed7a8482 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -30,7 +30,6 @@
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/utsname.h> 31#include <linux/utsname.h>
32#include <linux/highmem.h> 32#include <linux/highmem.h>
33#include <linux/videodev.h>
34#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
35#include <linux/module.h> 34#include <linux/module.h>
36#include <linux/init.h> 35#include <linux/init.h>
@@ -43,7 +42,6 @@
43#include <media/saa7115.h> 42#include <media/saa7115.h>
44#include <media/v4l2-common.h> 43#include <media/v4l2-common.h>
45#include <media/tuner.h> 44#include <media/tuner.h>
46#include <media/audiochip.h>
47 45
48#include <linux/workqueue.h> 46#include <linux/workqueue.h>
49 47
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index cd6c41d67899..b977116a0dd9 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -53,7 +53,6 @@
53#include <linux/mm.h> 53#include <linux/mm.h>
54#include <linux/utsname.h> 54#include <linux/utsname.h>
55#include <linux/highmem.h> 55#include <linux/highmem.h>
56#include <linux/videodev.h>
57#include <linux/vmalloc.h> 56#include <linux/vmalloc.h>
58#include <linux/module.h> 57#include <linux/module.h>
59#include <linux/init.h> 58#include <linux/init.h>
@@ -65,8 +64,8 @@
65 64
66#include <media/saa7115.h> 65#include <media/saa7115.h>
67#include <media/v4l2-common.h> 66#include <media/v4l2-common.h>
67#include <media/v4l2-ioctl.h>
68#include <media/tuner.h> 68#include <media/tuner.h>
69#include <media/audiochip.h>
70 69
71#include <linux/workqueue.h> 70#include <linux/workqueue.h>
72 71
@@ -184,7 +183,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
184static inline struct usb_usbvision *cd_to_usbvision(struct device *cd) 183static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
185{ 184{
186 struct video_device *vdev = 185 struct video_device *vdev =
187 container_of(cd, struct video_device, class_dev); 186 container_of(cd, struct video_device, dev);
188 return video_get_drvdata(vdev); 187 return video_get_drvdata(vdev);
189} 188}
190 189
@@ -199,7 +198,7 @@ static ssize_t show_model(struct device *cd,
199 struct device_attribute *attr, char *buf) 198 struct device_attribute *attr, char *buf)
200{ 199{
201 struct video_device *vdev = 200 struct video_device *vdev =
202 container_of(cd, struct video_device, class_dev); 201 container_of(cd, struct video_device, dev);
203 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 202 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
204 return sprintf(buf, "%s\n", 203 return sprintf(buf, "%s\n",
205 usbvision_device_data[usbvision->DevModel].ModelString); 204 usbvision_device_data[usbvision->DevModel].ModelString);
@@ -210,7 +209,7 @@ static ssize_t show_hue(struct device *cd,
210 struct device_attribute *attr, char *buf) 209 struct device_attribute *attr, char *buf)
211{ 210{
212 struct video_device *vdev = 211 struct video_device *vdev =
213 container_of(cd, struct video_device, class_dev); 212 container_of(cd, struct video_device, dev);
214 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 213 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
215 struct v4l2_control ctrl; 214 struct v4l2_control ctrl;
216 ctrl.id = V4L2_CID_HUE; 215 ctrl.id = V4L2_CID_HUE;
@@ -225,7 +224,7 @@ static ssize_t show_contrast(struct device *cd,
225 struct device_attribute *attr, char *buf) 224 struct device_attribute *attr, char *buf)
226{ 225{
227 struct video_device *vdev = 226 struct video_device *vdev =
228 container_of(cd, struct video_device, class_dev); 227 container_of(cd, struct video_device, dev);
229 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 228 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
230 struct v4l2_control ctrl; 229 struct v4l2_control ctrl;
231 ctrl.id = V4L2_CID_CONTRAST; 230 ctrl.id = V4L2_CID_CONTRAST;
@@ -240,7 +239,7 @@ static ssize_t show_brightness(struct device *cd,
240 struct device_attribute *attr, char *buf) 239 struct device_attribute *attr, char *buf)
241{ 240{
242 struct video_device *vdev = 241 struct video_device *vdev =
243 container_of(cd, struct video_device, class_dev); 242 container_of(cd, struct video_device, dev);
244 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 243 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
245 struct v4l2_control ctrl; 244 struct v4l2_control ctrl;
246 ctrl.id = V4L2_CID_BRIGHTNESS; 245 ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -255,7 +254,7 @@ static ssize_t show_saturation(struct device *cd,
255 struct device_attribute *attr, char *buf) 254 struct device_attribute *attr, char *buf)
256{ 255{
257 struct video_device *vdev = 256 struct video_device *vdev =
258 container_of(cd, struct video_device, class_dev); 257 container_of(cd, struct video_device, dev);
259 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 258 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
260 struct v4l2_control ctrl; 259 struct v4l2_control ctrl;
261 ctrl.id = V4L2_CID_SATURATION; 260 ctrl.id = V4L2_CID_SATURATION;
@@ -270,7 +269,7 @@ static ssize_t show_streaming(struct device *cd,
270 struct device_attribute *attr, char *buf) 269 struct device_attribute *attr, char *buf)
271{ 270{
272 struct video_device *vdev = 271 struct video_device *vdev =
273 container_of(cd, struct video_device, class_dev); 272 container_of(cd, struct video_device, dev);
274 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 273 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
275 return sprintf(buf, "%s\n", 274 return sprintf(buf, "%s\n",
276 YES_NO(usbvision->streaming==Stream_On?1:0)); 275 YES_NO(usbvision->streaming==Stream_On?1:0));
@@ -281,7 +280,7 @@ static ssize_t show_compression(struct device *cd,
281 struct device_attribute *attr, char *buf) 280 struct device_attribute *attr, char *buf)
282{ 281{
283 struct video_device *vdev = 282 struct video_device *vdev =
284 container_of(cd, struct video_device, class_dev); 283 container_of(cd, struct video_device, dev);
285 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 284 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
286 return sprintf(buf, "%s\n", 285 return sprintf(buf, "%s\n",
287 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); 286 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
@@ -292,7 +291,7 @@ static ssize_t show_device_bridge(struct device *cd,
292 struct device_attribute *attr, char *buf) 291 struct device_attribute *attr, char *buf)
293{ 292{
294 struct video_device *vdev = 293 struct video_device *vdev =
295 container_of(cd, struct video_device, class_dev); 294 container_of(cd, struct video_device, dev);
296 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 295 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
297 return sprintf(buf, "%d\n", usbvision->bridgeType); 296 return sprintf(buf, "%d\n", usbvision->bridgeType);
298} 297}
@@ -304,40 +303,31 @@ static void usbvision_create_sysfs(struct video_device *vdev)
304 if (!vdev) 303 if (!vdev)
305 return; 304 return;
306 do { 305 do {
307 res = device_create_file(&vdev->class_dev, 306 res = device_create_file(&vdev->dev, &dev_attr_version);
308 &dev_attr_version);
309 if (res<0) 307 if (res<0)
310 break; 308 break;
311 res = device_create_file(&vdev->class_dev, 309 res = device_create_file(&vdev->dev, &dev_attr_model);
312 &dev_attr_model);
313 if (res<0) 310 if (res<0)
314 break; 311 break;
315 res = device_create_file(&vdev->class_dev, 312 res = device_create_file(&vdev->dev, &dev_attr_hue);
316 &dev_attr_hue);
317 if (res<0) 313 if (res<0)
318 break; 314 break;
319 res = device_create_file(&vdev->class_dev, 315 res = device_create_file(&vdev->dev, &dev_attr_contrast);
320 &dev_attr_contrast);
321 if (res<0) 316 if (res<0)
322 break; 317 break;
323 res = device_create_file(&vdev->class_dev, 318 res = device_create_file(&vdev->dev, &dev_attr_brightness);
324 &dev_attr_brightness);
325 if (res<0) 319 if (res<0)
326 break; 320 break;
327 res = device_create_file(&vdev->class_dev, 321 res = device_create_file(&vdev->dev, &dev_attr_saturation);
328 &dev_attr_saturation);
329 if (res<0) 322 if (res<0)
330 break; 323 break;
331 res = device_create_file(&vdev->class_dev, 324 res = device_create_file(&vdev->dev, &dev_attr_streaming);
332 &dev_attr_streaming);
333 if (res<0) 325 if (res<0)
334 break; 326 break;
335 res = device_create_file(&vdev->class_dev, 327 res = device_create_file(&vdev->dev, &dev_attr_compression);
336 &dev_attr_compression);
337 if (res<0) 328 if (res<0)
338 break; 329 break;
339 res = device_create_file(&vdev->class_dev, 330 res = device_create_file(&vdev->dev, &dev_attr_bridge);
340 &dev_attr_bridge);
341 if (res>=0) 331 if (res>=0)
342 return; 332 return;
343 } while (0); 333 } while (0);
@@ -348,24 +338,15 @@ static void usbvision_create_sysfs(struct video_device *vdev)
348static void usbvision_remove_sysfs(struct video_device *vdev) 338static void usbvision_remove_sysfs(struct video_device *vdev)
349{ 339{
350 if (vdev) { 340 if (vdev) {
351 device_remove_file(&vdev->class_dev, 341 device_remove_file(&vdev->dev, &dev_attr_version);
352 &dev_attr_version); 342 device_remove_file(&vdev->dev, &dev_attr_model);
353 device_remove_file(&vdev->class_dev, 343 device_remove_file(&vdev->dev, &dev_attr_hue);
354 &dev_attr_model); 344 device_remove_file(&vdev->dev, &dev_attr_contrast);
355 device_remove_file(&vdev->class_dev, 345 device_remove_file(&vdev->dev, &dev_attr_brightness);
356 &dev_attr_hue); 346 device_remove_file(&vdev->dev, &dev_attr_saturation);
357 device_remove_file(&vdev->class_dev, 347 device_remove_file(&vdev->dev, &dev_attr_streaming);
358 &dev_attr_contrast); 348 device_remove_file(&vdev->dev, &dev_attr_compression);
359 device_remove_file(&vdev->class_dev, 349 device_remove_file(&vdev->dev, &dev_attr_bridge);
360 &dev_attr_brightness);
361 device_remove_file(&vdev->class_dev,
362 &dev_attr_saturation);
363 device_remove_file(&vdev->class_dev,
364 &dev_attr_streaming);
365 device_remove_file(&vdev->class_dev,
366 &dev_attr_compression);
367 device_remove_file(&vdev->class_dev,
368 &dev_attr_bridge);
369 } 350 }
370} 351}
371 352
@@ -1388,13 +1369,8 @@ static const struct file_operations usbvision_fops = {
1388/* .poll = video_poll, */ 1369/* .poll = video_poll, */
1389 .compat_ioctl = v4l_compat_ioctl32, 1370 .compat_ioctl = v4l_compat_ioctl32,
1390}; 1371};
1391static struct video_device usbvision_video_template = { 1372
1392 .owner = THIS_MODULE, 1373static const struct v4l2_ioctl_ops usbvision_ioctl_ops = {
1393 .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE,
1394 .fops = &usbvision_fops,
1395 .name = "usbvision-video",
1396 .release = video_device_release,
1397 .minor = -1,
1398 .vidioc_querycap = vidioc_querycap, 1374 .vidioc_querycap = vidioc_querycap,
1399 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1375 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1400 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1376 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1426,6 +1402,14 @@ static struct video_device usbvision_video_template = {
1426 .vidioc_g_register = vidioc_g_register, 1402 .vidioc_g_register = vidioc_g_register,
1427 .vidioc_s_register = vidioc_s_register, 1403 .vidioc_s_register = vidioc_s_register,
1428#endif 1404#endif
1405};
1406
1407static struct video_device usbvision_video_template = {
1408 .fops = &usbvision_fops,
1409 .ioctl_ops = &usbvision_ioctl_ops,
1410 .name = "usbvision-video",
1411 .release = video_device_release,
1412 .minor = -1,
1429 .tvnorms = USBVISION_NORMS, 1413 .tvnorms = USBVISION_NORMS,
1430 .current_norm = V4L2_STD_PAL 1414 .current_norm = V4L2_STD_PAL
1431}; 1415};
@@ -1441,14 +1425,7 @@ static const struct file_operations usbvision_radio_fops = {
1441 .compat_ioctl = v4l_compat_ioctl32, 1425 .compat_ioctl = v4l_compat_ioctl32,
1442}; 1426};
1443 1427
1444static struct video_device usbvision_radio_template= 1428static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = {
1445{
1446 .owner = THIS_MODULE,
1447 .type = VID_TYPE_TUNER,
1448 .fops = &usbvision_radio_fops,
1449 .name = "usbvision-radio",
1450 .release = video_device_release,
1451 .minor = -1,
1452 .vidioc_querycap = vidioc_querycap, 1429 .vidioc_querycap = vidioc_querycap,
1453 .vidioc_enum_input = vidioc_enum_input, 1430 .vidioc_enum_input = vidioc_enum_input,
1454 .vidioc_g_input = vidioc_g_input, 1431 .vidioc_g_input = vidioc_g_input,
@@ -1462,6 +1439,14 @@ static struct video_device usbvision_radio_template=
1462 .vidioc_s_tuner = vidioc_s_tuner, 1439 .vidioc_s_tuner = vidioc_s_tuner,
1463 .vidioc_g_frequency = vidioc_g_frequency, 1440 .vidioc_g_frequency = vidioc_g_frequency,
1464 .vidioc_s_frequency = vidioc_s_frequency, 1441 .vidioc_s_frequency = vidioc_s_frequency,
1442};
1443
1444static struct video_device usbvision_radio_template = {
1445 .fops = &usbvision_radio_fops,
1446 .name = "usbvision-radio",
1447 .release = video_device_release,
1448 .minor = -1,
1449 .ioctl_ops = &usbvision_radio_ioctl_ops,
1465 1450
1466 .tvnorms = USBVISION_NORMS, 1451 .tvnorms = USBVISION_NORMS,
1467 .current_norm = V4L2_STD_PAL 1452 .current_norm = V4L2_STD_PAL
@@ -1479,8 +1464,6 @@ static const struct file_operations usbvision_vbi_fops = {
1479 1464
1480static struct video_device usbvision_vbi_template= 1465static struct video_device usbvision_vbi_template=
1481{ 1466{
1482 .owner = THIS_MODULE,
1483 .type = VID_TYPE_TUNER,
1484 .fops = &usbvision_vbi_fops, 1467 .fops = &usbvision_vbi_fops,
1485 .release = video_device_release, 1468 .release = video_device_release,
1486 .name = "usbvision-vbi", 1469 .name = "usbvision-vbi",
@@ -1506,7 +1489,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1506 } 1489 }
1507 *vdev = *vdev_template; 1490 *vdev = *vdev_template;
1508// vdev->minor = -1; 1491// vdev->minor = -1;
1509 vdev->dev = &usb_dev->dev; 1492 vdev->parent = &usb_dev->dev;
1510 snprintf(vdev->name, sizeof(vdev->name), "%s", name); 1493 snprintf(vdev->name, sizeof(vdev->name), "%s", name);
1511 video_set_drvdata(vdev, usbvision); 1494 video_set_drvdata(vdev, usbvision);
1512 return vdev; 1495 return vdev;
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 3ae95512666f..626f4ad7e876 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -195,8 +195,8 @@ static struct uvc_menu_info power_line_frequency_controls[] = {
195}; 195};
196 196
197static struct uvc_menu_info exposure_auto_controls[] = { 197static struct uvc_menu_info exposure_auto_controls[] = {
198 { 1, "Manual Mode" },
199 { 2, "Auto Mode" }, 198 { 2, "Auto Mode" },
199 { 1, "Manual Mode" },
200 { 4, "Shutter Priority Mode" }, 200 { 4, "Shutter Priority Mode" },
201 { 8, "Aperture Priority Mode" }, 201 { 8, "Aperture Priority Mode" },
202}; 202};
@@ -592,6 +592,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
592 if (ctrl == NULL) 592 if (ctrl == NULL)
593 return -EINVAL; 593 return -EINVAL;
594 594
595 memset(v4l2_ctrl, 0, sizeof *v4l2_ctrl);
595 v4l2_ctrl->id = mapping->id; 596 v4l2_ctrl->id = mapping->id;
596 v4l2_ctrl->type = mapping->v4l2_type; 597 v4l2_ctrl->type = mapping->v4l2_type;
597 strncpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name); 598 strncpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name);
@@ -608,7 +609,8 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
608 v4l2_ctrl->default_value = uvc_get_le_value(data, mapping); 609 v4l2_ctrl->default_value = uvc_get_le_value(data, mapping);
609 } 610 }
610 611
611 if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { 612 switch (mapping->v4l2_type) {
613 case V4L2_CTRL_TYPE_MENU:
612 v4l2_ctrl->minimum = 0; 614 v4l2_ctrl->minimum = 0;
613 v4l2_ctrl->maximum = mapping->menu_count - 1; 615 v4l2_ctrl->maximum = mapping->menu_count - 1;
614 v4l2_ctrl->step = 1; 616 v4l2_ctrl->step = 1;
@@ -622,6 +624,15 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
622 } 624 }
623 625
624 return 0; 626 return 0;
627
628 case V4L2_CTRL_TYPE_BOOLEAN:
629 v4l2_ctrl->minimum = 0;
630 v4l2_ctrl->maximum = 1;
631 v4l2_ctrl->step = 1;
632 return 0;
633
634 default:
635 break;
625 } 636 }
626 637
627 if (ctrl->info->flags & UVC_CONTROL_GET_MIN) { 638 if (ctrl->info->flags & UVC_CONTROL_GET_MIN) {
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index f2b2983fe062..b3c4d75e8490 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1458,9 +1458,7 @@ static int uvc_register_video(struct uvc_device *dev)
1458 * unregistered before the reference is released, so we don't need to 1458 * unregistered before the reference is released, so we don't need to
1459 * get another one. 1459 * get another one.
1460 */ 1460 */
1461 vdev->dev = &dev->intf->dev; 1461 vdev->parent = &dev->intf->dev;
1462 vdev->type = 0;
1463 vdev->type2 = 0;
1464 vdev->minor = -1; 1462 vdev->minor = -1;
1465 vdev->fops = &uvc_fops; 1463 vdev->fops = &uvc_fops;
1466 vdev->release = video_device_release; 1464 vdev->release = video_device_release;
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index b5a11eb8f9fa..d7bd71be40a9 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -23,6 +23,7 @@
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24 24
25#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
26 27
27#include "uvcvideo.h" 28#include "uvcvideo.h"
28 29
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index a0f6c60279ec..79937d1031fc 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -30,6 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/videodev.h> 31#include <linux/videodev.h>
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
33 34
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/system.h> 36#include <asm/system.h>
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index e9dd996fd5df..88ca13104417 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -64,7 +64,7 @@
64#include <linux/kmod.h> 64#include <linux/kmod.h>
65#endif 65#endif
66 66
67#include <linux/videodev.h> 67#include <linux/videodev2.h>
68 68
69MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr"); 69MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
70MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers"); 70MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers");
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
new file mode 100644
index 000000000000..556615fe93de
--- /dev/null
+++ b/drivers/media/video/v4l2-dev.c
@@ -0,0 +1,422 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic video device interface for the LINUX operating system
5 * using a set of device structures/vectors for low level operations.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * Authors: Alan Cox, <alan@redhat.com> (version 1)
13 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
14 *
15 * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
16 * - Added procfs support
17 */
18
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/kernel.h>
22#include <linux/mm.h>
23#include <linux/string.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/kmod.h>
27#include <linux/slab.h>
28#include <linux/smp_lock.h>
29#include <asm/uaccess.h>
30#include <asm/system.h>
31
32#include <media/v4l2-common.h>
33
34#define VIDEO_NUM_DEVICES 256
35#define VIDEO_NAME "video4linux"
36
37/*
38 * sysfs stuff
39 */
40
41static ssize_t show_index(struct device *cd,
42 struct device_attribute *attr, char *buf)
43{
44 struct video_device *vfd = container_of(cd, struct video_device, dev);
45 return sprintf(buf, "%i\n", vfd->index);
46}
47
48static ssize_t show_name(struct device *cd,
49 struct device_attribute *attr, char *buf)
50{
51 struct video_device *vfd = container_of(cd, struct video_device, dev);
52 return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
53}
54
55static struct device_attribute video_device_attrs[] = {
56 __ATTR(name, S_IRUGO, show_name, NULL),
57 __ATTR(index, S_IRUGO, show_index, NULL),
58 __ATTR_NULL
59};
60
61struct video_device *video_device_alloc(void)
62{
63 struct video_device *vfd;
64
65 vfd = kzalloc(sizeof(*vfd), GFP_KERNEL);
66 return vfd;
67}
68EXPORT_SYMBOL(video_device_alloc);
69
70void video_device_release(struct video_device *vfd)
71{
72 kfree(vfd);
73}
74EXPORT_SYMBOL(video_device_release);
75
76static void video_release(struct device *cd)
77{
78 struct video_device *vfd = container_of(cd, struct video_device, dev);
79
80#if 1
81 /* needed until all drivers are fixed */
82 if (!vfd->release)
83 return;
84#endif
85 vfd->release(vfd);
86}
87
88static struct class video_class = {
89 .name = VIDEO_NAME,
90 .dev_attrs = video_device_attrs,
91 .dev_release = video_release,
92};
93
94/*
95 * Active devices
96 */
97
98static struct video_device *video_device[VIDEO_NUM_DEVICES];
99static DEFINE_MUTEX(videodev_lock);
100
101struct video_device *video_devdata(struct file *file)
102{
103 return video_device[iminor(file->f_path.dentry->d_inode)];
104}
105EXPORT_SYMBOL(video_devdata);
106
107/*
108 * Open a video device - FIXME: Obsoleted
109 */
110static int video_open(struct inode *inode, struct file *file)
111{
112 unsigned int minor = iminor(inode);
113 int err = 0;
114 struct video_device *vfl;
115 const struct file_operations *old_fops;
116
117 if (minor >= VIDEO_NUM_DEVICES)
118 return -ENODEV;
119 lock_kernel();
120 mutex_lock(&videodev_lock);
121 vfl = video_device[minor];
122 if (vfl == NULL) {
123 mutex_unlock(&videodev_lock);
124 request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
125 mutex_lock(&videodev_lock);
126 vfl = video_device[minor];
127 if (vfl == NULL) {
128 mutex_unlock(&videodev_lock);
129 unlock_kernel();
130 return -ENODEV;
131 }
132 }
133 old_fops = file->f_op;
134 file->f_op = fops_get(vfl->fops);
135 if (file->f_op->open)
136 err = file->f_op->open(inode, file);
137 if (err) {
138 fops_put(file->f_op);
139 file->f_op = fops_get(old_fops);
140 }
141 fops_put(old_fops);
142 mutex_unlock(&videodev_lock);
143 unlock_kernel();
144 return err;
145}
146
147/*
148 * open/release helper functions -- handle exclusive opens
149 * Should be removed soon
150 */
151int video_exclusive_open(struct inode *inode, struct file *file)
152{
153 struct video_device *vfl = video_devdata(file);
154 int retval = 0;
155
156 mutex_lock(&vfl->lock);
157 if (vfl->users)
158 retval = -EBUSY;
159 else
160 vfl->users++;
161 mutex_unlock(&vfl->lock);
162 return retval;
163}
164EXPORT_SYMBOL(video_exclusive_open);
165
166int video_exclusive_release(struct inode *inode, struct file *file)
167{
168 struct video_device *vfl = video_devdata(file);
169
170 vfl->users--;
171 return 0;
172}
173EXPORT_SYMBOL(video_exclusive_release);
174
175/**
176 * get_index - assign stream number based on parent device
177 * @vdev: video_device to assign index number to, vdev->dev should be assigned
178 * @num: -1 if auto assign, requested number otherwise
179 *
180 *
181 * returns -ENFILE if num is already in use, a free index number if
182 * successful.
183 */
184static int get_index(struct video_device *vdev, int num)
185{
186 u32 used = 0;
187 const int max_index = sizeof(used) * 8 - 1;
188 int i;
189
190 /* Currently a single v4l driver instance cannot create more than
191 32 devices.
192 Increase to u64 or an array of u32 if more are needed. */
193 if (num > max_index) {
194 printk(KERN_ERR "videodev: %s num is too large\n", __func__);
195 return -EINVAL;
196 }
197
198 for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
199 if (video_device[i] != NULL &&
200 video_device[i] != vdev &&
201 video_device[i]->parent == vdev->parent) {
202 used |= 1 << video_device[i]->index;
203 }
204 }
205
206 if (num >= 0) {
207 if (used & (1 << num))
208 return -ENFILE;
209 return num;
210 }
211
212 i = ffz(used);
213 return i > max_index ? -ENFILE : i;
214}
215
216static const struct file_operations video_fops;
217
218int video_register_device(struct video_device *vfd, int type, int nr)
219{
220 return video_register_device_index(vfd, type, nr, -1);
221}
222EXPORT_SYMBOL(video_register_device);
223
224/**
225 * video_register_device - register video4linux devices
226 * @vfd: video device structure we want to register
227 * @type: type of device to register
228 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
229 * -1 == first free)
230 *
231 * The registration code assigns minor numbers based on the type
232 * requested. -ENFILE is returned in all the device slots for this
233 * category are full. If not then the minor field is set and the
234 * driver initialize function is called (if non %NULL).
235 *
236 * Zero is returned on success.
237 *
238 * Valid types are
239 *
240 * %VFL_TYPE_GRABBER - A frame grabber
241 *
242 * %VFL_TYPE_VTX - A teletext device
243 *
244 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
245 *
246 * %VFL_TYPE_RADIO - A radio card
247 */
248
249int video_register_device_index(struct video_device *vfd, int type, int nr,
250 int index)
251{
252 int i = 0;
253 int base;
254 int end;
255 int ret;
256 char *name_base;
257
258 switch (type) {
259 case VFL_TYPE_GRABBER:
260 base = MINOR_VFL_TYPE_GRABBER_MIN;
261 end = MINOR_VFL_TYPE_GRABBER_MAX+1;
262 name_base = "video";
263 break;
264 case VFL_TYPE_VTX:
265 base = MINOR_VFL_TYPE_VTX_MIN;
266 end = MINOR_VFL_TYPE_VTX_MAX+1;
267 name_base = "vtx";
268 break;
269 case VFL_TYPE_VBI:
270 base = MINOR_VFL_TYPE_VBI_MIN;
271 end = MINOR_VFL_TYPE_VBI_MAX+1;
272 name_base = "vbi";
273 break;
274 case VFL_TYPE_RADIO:
275 base = MINOR_VFL_TYPE_RADIO_MIN;
276 end = MINOR_VFL_TYPE_RADIO_MAX+1;
277 name_base = "radio";
278 break;
279 default:
280 printk(KERN_ERR "%s called with unknown type: %d\n",
281 __func__, type);
282 return -1;
283 }
284
285 /* pick a minor number */
286 mutex_lock(&videodev_lock);
287 if (nr >= 0 && nr < end-base) {
288 /* use the one the driver asked for */
289 i = base + nr;
290 if (NULL != video_device[i]) {
291 mutex_unlock(&videodev_lock);
292 return -ENFILE;
293 }
294 } else {
295 /* use first free */
296 for (i = base; i < end; i++)
297 if (NULL == video_device[i])
298 break;
299 if (i == end) {
300 mutex_unlock(&videodev_lock);
301 return -ENFILE;
302 }
303 }
304 video_device[i] = vfd;
305 vfd->vfl_type = type;
306 vfd->minor = i;
307
308 ret = get_index(vfd, index);
309 vfd->index = ret;
310
311 mutex_unlock(&videodev_lock);
312
313 if (ret < 0) {
314 printk(KERN_ERR "%s: get_index failed\n", __func__);
315 goto fail_minor;
316 }
317
318 mutex_init(&vfd->lock);
319
320 /* sysfs class */
321 memset(&vfd->dev, 0x00, sizeof(vfd->dev));
322 vfd->dev.class = &video_class;
323 vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
324 if (vfd->parent)
325 vfd->dev.parent = vfd->parent;
326 sprintf(vfd->dev.bus_id, "%s%d", name_base, i - base);
327 ret = device_register(&vfd->dev);
328 if (ret < 0) {
329 printk(KERN_ERR "%s: device_register failed\n", __func__);
330 goto fail_minor;
331 }
332
333#if 1
334 /* needed until all drivers are fixed */
335 if (!vfd->release)
336 printk(KERN_WARNING "videodev: \"%s\" has no release callback. "
337 "Please fix your driver for proper sysfs support, see "
338 "http://lwn.net/Articles/36850/\n", vfd->name);
339#endif
340 return 0;
341
342fail_minor:
343 mutex_lock(&videodev_lock);
344 video_device[vfd->minor] = NULL;
345 vfd->minor = -1;
346 mutex_unlock(&videodev_lock);
347 return ret;
348}
349EXPORT_SYMBOL(video_register_device_index);
350
351/**
352 * video_unregister_device - unregister a video4linux device
353 * @vfd: the device to unregister
354 *
355 * This unregisters the passed device and deassigns the minor
356 * number. Future open calls will be met with errors.
357 */
358
359void video_unregister_device(struct video_device *vfd)
360{
361 mutex_lock(&videodev_lock);
362 if (video_device[vfd->minor] != vfd)
363 panic("videodev: bad unregister");
364
365 video_device[vfd->minor] = NULL;
366 device_unregister(&vfd->dev);
367 mutex_unlock(&videodev_lock);
368}
369EXPORT_SYMBOL(video_unregister_device);
370
371/*
372 * Video fs operations
373 */
374static const struct file_operations video_fops = {
375 .owner = THIS_MODULE,
376 .llseek = no_llseek,
377 .open = video_open,
378};
379
380/*
381 * Initialise video for linux
382 */
383
384static int __init videodev_init(void)
385{
386 int ret;
387
388 printk(KERN_INFO "Linux video capture interface: v2.00\n");
389 if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) {
390 printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR);
391 return -EIO;
392 }
393
394 ret = class_register(&video_class);
395 if (ret < 0) {
396 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
397 printk(KERN_WARNING "video_dev: class_register failed\n");
398 return -EIO;
399 }
400
401 return 0;
402}
403
404static void __exit videodev_exit(void)
405{
406 class_unregister(&video_class);
407 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
408}
409
410module_init(videodev_init)
411module_exit(videodev_exit)
412
413MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
414MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
415MODULE_LICENSE("GPL");
416
417
418/*
419 * Local variables:
420 * c-basic-offset: 8
421 * End:
422 */
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
new file mode 100644
index 000000000000..fdfe7739c96e
--- /dev/null
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -0,0 +1,1875 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic framework to process V4L2 ioctl commands.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Authors: Alan Cox, <alan@redhat.com> (version 1)
12 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
13 */
14
15#include <linux/module.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18
19#define __OLD_VIDIOC_ /* To allow fixing old calls */
20#include <linux/videodev2.h>
21
22#ifdef CONFIG_VIDEO_V4L1
23#include <linux/videodev.h>
24#endif
25#include <media/v4l2-common.h>
26#include <media/v4l2-ioctl.h>
27#include <linux/video_decoder.h>
28
29#define dbgarg(cmd, fmt, arg...) \
30 do { \
31 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
32 printk(KERN_DEBUG "%s: ", vfd->name); \
33 v4l_printk_ioctl(cmd); \
34 printk(" " fmt, ## arg); \
35 } \
36 } while (0)
37
38#define dbgarg2(fmt, arg...) \
39 do { \
40 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
41 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
42 } while (0)
43
44struct std_descr {
45 v4l2_std_id std;
46 const char *descr;
47};
48
49static const struct std_descr standards[] = {
50 { V4L2_STD_NTSC, "NTSC" },
51 { V4L2_STD_NTSC_M, "NTSC-M" },
52 { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" },
53 { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" },
54 { V4L2_STD_NTSC_443, "NTSC-443" },
55 { V4L2_STD_PAL, "PAL" },
56 { V4L2_STD_PAL_BG, "PAL-BG" },
57 { V4L2_STD_PAL_B, "PAL-B" },
58 { V4L2_STD_PAL_B1, "PAL-B1" },
59 { V4L2_STD_PAL_G, "PAL-G" },
60 { V4L2_STD_PAL_H, "PAL-H" },
61 { V4L2_STD_PAL_I, "PAL-I" },
62 { V4L2_STD_PAL_DK, "PAL-DK" },
63 { V4L2_STD_PAL_D, "PAL-D" },
64 { V4L2_STD_PAL_D1, "PAL-D1" },
65 { V4L2_STD_PAL_K, "PAL-K" },
66 { V4L2_STD_PAL_M, "PAL-M" },
67 { V4L2_STD_PAL_N, "PAL-N" },
68 { V4L2_STD_PAL_Nc, "PAL-Nc" },
69 { V4L2_STD_PAL_60, "PAL-60" },
70 { V4L2_STD_SECAM, "SECAM" },
71 { V4L2_STD_SECAM_B, "SECAM-B" },
72 { V4L2_STD_SECAM_G, "SECAM-G" },
73 { V4L2_STD_SECAM_H, "SECAM-H" },
74 { V4L2_STD_SECAM_DK, "SECAM-DK" },
75 { V4L2_STD_SECAM_D, "SECAM-D" },
76 { V4L2_STD_SECAM_K, "SECAM-K" },
77 { V4L2_STD_SECAM_K1, "SECAM-K1" },
78 { V4L2_STD_SECAM_L, "SECAM-L" },
79 { V4L2_STD_SECAM_LC, "SECAM-Lc" },
80 { 0, "Unknown" }
81};
82
83/* video4linux standard ID conversion to standard name
84 */
85const char *v4l2_norm_to_name(v4l2_std_id id)
86{
87 u32 myid = id;
88 int i;
89
90 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
91 64 bit comparations. So, on that architecture, with some gcc
92 variants, compilation fails. Currently, the max value is 30bit wide.
93 */
94 BUG_ON(myid != id);
95
96 for (i = 0; standards[i].std; i++)
97 if (myid == standards[i].std)
98 break;
99 return standards[i].descr;
100}
101EXPORT_SYMBOL(v4l2_norm_to_name);
102
103/* Fill in the fields of a v4l2_standard structure according to the
104 'id' and 'transmission' parameters. Returns negative on error. */
105int v4l2_video_std_construct(struct v4l2_standard *vs,
106 int id, const char *name)
107{
108 u32 index = vs->index;
109
110 memset(vs, 0, sizeof(struct v4l2_standard));
111 vs->index = index;
112 vs->id = id;
113 if (id & V4L2_STD_525_60) {
114 vs->frameperiod.numerator = 1001;
115 vs->frameperiod.denominator = 30000;
116 vs->framelines = 525;
117 } else {
118 vs->frameperiod.numerator = 1;
119 vs->frameperiod.denominator = 25;
120 vs->framelines = 625;
121 }
122 strlcpy(vs->name, name, sizeof(vs->name));
123 return 0;
124}
125EXPORT_SYMBOL(v4l2_video_std_construct);
126
127/* ----------------------------------------------------------------- */
128/* some arrays for pretty-printing debug messages of enum types */
129
130const char *v4l2_field_names[] = {
131 [V4L2_FIELD_ANY] = "any",
132 [V4L2_FIELD_NONE] = "none",
133 [V4L2_FIELD_TOP] = "top",
134 [V4L2_FIELD_BOTTOM] = "bottom",
135 [V4L2_FIELD_INTERLACED] = "interlaced",
136 [V4L2_FIELD_SEQ_TB] = "seq-tb",
137 [V4L2_FIELD_SEQ_BT] = "seq-bt",
138 [V4L2_FIELD_ALTERNATE] = "alternate",
139 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
140 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
141};
142EXPORT_SYMBOL(v4l2_field_names);
143
144const char *v4l2_type_names[] = {
145 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "vid-cap",
146 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "vid-overlay",
147 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "vid-out",
148 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
149 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
150 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
151 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
152 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
153};
154EXPORT_SYMBOL(v4l2_type_names);
155
156static const char *v4l2_memory_names[] = {
157 [V4L2_MEMORY_MMAP] = "mmap",
158 [V4L2_MEMORY_USERPTR] = "userptr",
159 [V4L2_MEMORY_OVERLAY] = "overlay",
160};
161
162#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
163 arr[a] : "unknown")
164
165/* ------------------------------------------------------------------ */
166/* debug help functions */
167
168#ifdef CONFIG_VIDEO_V4L1_COMPAT
169static const char *v4l1_ioctls[] = {
170 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
171 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
172 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
173 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
174 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
175 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
176 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
177 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
178 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
179 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
180 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
181 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
182 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
183 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
184 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
185 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
186 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
187 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
188 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
189 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
190 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
191 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
192 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
193 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
194 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
195 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
196 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
197 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
198 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
199};
200#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
201#endif
202
203static const char *v4l2_ioctls[] = {
204 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
205 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
206 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
207 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
208 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
209 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
210 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
211 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
212 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
213 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
214 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
215 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
216 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
217 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
218 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
219 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
220 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
221 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
222 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
223 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
224 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
225 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
226 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
227 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
228 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
229 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
230 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
231 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
232 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
233 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
234 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
235 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
236 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
237 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
238 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
239 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
240 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
241 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
242 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
243 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
244 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
245 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
246 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
247 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
248 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
249 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
250 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
251 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
252 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
253 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
254 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
255 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
256 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
257 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
258 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
259#if 1
260 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
261 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
262 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
263 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
264 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
265
266 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
267 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
268
269 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
270 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
271#endif
272};
273#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
274
275static const char *v4l2_int_ioctls[] = {
276#ifdef CONFIG_VIDEO_V4L1_COMPAT
277 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
278 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
279 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
280 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
281 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
282 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
283 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
284 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
285 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
286 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
287 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
288#endif
289 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
290
291 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
292 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
293 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
294
295 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
296 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
297 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
298 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
299 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
300 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
301 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
302 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
303 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
304 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
305 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
306 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
307 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
308 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
309 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
310 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
311};
312#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
313
314/* Common ioctl debug function. This function can be used by
315 external ioctl messages as well as internal V4L ioctl */
316void v4l_printk_ioctl(unsigned int cmd)
317{
318 char *dir, *type;
319
320 switch (_IOC_TYPE(cmd)) {
321 case 'd':
322 if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) {
323 type = "v4l2_int";
324 break;
325 }
326 printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]);
327 return;
328#ifdef CONFIG_VIDEO_V4L1_COMPAT
329 case 'v':
330 if (_IOC_NR(cmd) >= V4L1_IOCTLS) {
331 type = "v4l1";
332 break;
333 }
334 printk("%s", v4l1_ioctls[_IOC_NR(cmd)]);
335 return;
336#endif
337 case 'V':
338 if (_IOC_NR(cmd) >= V4L2_IOCTLS) {
339 type = "v4l2";
340 break;
341 }
342 printk("%s", v4l2_ioctls[_IOC_NR(cmd)]);
343 return;
344 default:
345 type = "unknown";
346 }
347
348 switch (_IOC_DIR(cmd)) {
349 case _IOC_NONE: dir = "--"; break;
350 case _IOC_READ: dir = "r-"; break;
351 case _IOC_WRITE: dir = "-w"; break;
352 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
353 default: dir = "*ERR*"; break;
354 }
355 printk("%s ioctl '%c', dir=%s, #%d (0x%08x)",
356 type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
357}
358EXPORT_SYMBOL(v4l_printk_ioctl);
359
360/*
361 * helper function -- handles userspace copying for ioctl arguments
362 */
363
364#ifdef __OLD_VIDIOC_
365static unsigned int
366video_fix_command(unsigned int cmd)
367{
368 switch (cmd) {
369 case VIDIOC_OVERLAY_OLD:
370 cmd = VIDIOC_OVERLAY;
371 break;
372 case VIDIOC_S_PARM_OLD:
373 cmd = VIDIOC_S_PARM;
374 break;
375 case VIDIOC_S_CTRL_OLD:
376 cmd = VIDIOC_S_CTRL;
377 break;
378 case VIDIOC_G_AUDIO_OLD:
379 cmd = VIDIOC_G_AUDIO;
380 break;
381 case VIDIOC_G_AUDOUT_OLD:
382 cmd = VIDIOC_G_AUDOUT;
383 break;
384 case VIDIOC_CROPCAP_OLD:
385 cmd = VIDIOC_CROPCAP;
386 break;
387 }
388 return cmd;
389}
390#endif
391
392/*
393 * Obsolete usercopy function - Should be removed soon
394 */
395int
396video_usercopy(struct inode *inode, struct file *file,
397 unsigned int cmd, unsigned long arg,
398 int (*func)(struct inode *inode, struct file *file,
399 unsigned int cmd, void *arg))
400{
401 char sbuf[128];
402 void *mbuf = NULL;
403 void *parg = NULL;
404 int err = -EINVAL;
405 int is_ext_ctrl;
406 size_t ctrls_size = 0;
407 void __user *user_ptr = NULL;
408
409#ifdef __OLD_VIDIOC_
410 cmd = video_fix_command(cmd);
411#endif
412 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
413 cmd == VIDIOC_TRY_EXT_CTRLS);
414
415 /* Copy arguments into temp kernel buffer */
416 switch (_IOC_DIR(cmd)) {
417 case _IOC_NONE:
418 parg = NULL;
419 break;
420 case _IOC_READ:
421 case _IOC_WRITE:
422 case (_IOC_WRITE | _IOC_READ):
423 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
424 parg = sbuf;
425 } else {
426 /* too big to allocate from stack */
427 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
428 if (NULL == mbuf)
429 return -ENOMEM;
430 parg = mbuf;
431 }
432
433 err = -EFAULT;
434 if (_IOC_DIR(cmd) & _IOC_WRITE)
435 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
436 goto out;
437 break;
438 }
439 if (is_ext_ctrl) {
440 struct v4l2_ext_controls *p = parg;
441
442 /* In case of an error, tell the caller that it wasn't
443 a specific control that caused it. */
444 p->error_idx = p->count;
445 user_ptr = (void __user *)p->controls;
446 if (p->count) {
447 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
448 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
449 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
450 err = -ENOMEM;
451 if (NULL == mbuf)
452 goto out_ext_ctrl;
453 err = -EFAULT;
454 if (copy_from_user(mbuf, user_ptr, ctrls_size))
455 goto out_ext_ctrl;
456 p->controls = mbuf;
457 }
458 }
459
460 /* call driver */
461 err = func(inode, file, cmd, parg);
462 if (err == -ENOIOCTLCMD)
463 err = -EINVAL;
464 if (is_ext_ctrl) {
465 struct v4l2_ext_controls *p = parg;
466
467 p->controls = (void *)user_ptr;
468 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
469 err = -EFAULT;
470 goto out_ext_ctrl;
471 }
472 if (err < 0)
473 goto out;
474
475out_ext_ctrl:
476 /* Copy results into user buffer */
477 switch (_IOC_DIR(cmd)) {
478 case _IOC_READ:
479 case (_IOC_WRITE | _IOC_READ):
480 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
481 err = -EFAULT;
482 break;
483 }
484
485out:
486 kfree(mbuf);
487 return err;
488}
489EXPORT_SYMBOL(video_usercopy);
490
491static void dbgbuf(unsigned int cmd, struct video_device *vfd,
492 struct v4l2_buffer *p)
493{
494 struct v4l2_timecode *tc = &p->timecode;
495
496 dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
497 "bytesused=%d, flags=0x%08d, "
498 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n",
499 p->timestamp.tv_sec / 3600,
500 (int)(p->timestamp.tv_sec / 60) % 60,
501 (int)(p->timestamp.tv_sec % 60),
502 p->timestamp.tv_usec,
503 p->index,
504 prt_names(p->type, v4l2_type_names),
505 p->bytesused, p->flags,
506 p->field, p->sequence,
507 prt_names(p->memory, v4l2_memory_names),
508 p->m.userptr, p->length);
509 dbgarg2("timecode=%02d:%02d:%02d type=%d, "
510 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
511 tc->hours, tc->minutes, tc->seconds,
512 tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits);
513}
514
515static inline void dbgrect(struct video_device *vfd, char *s,
516 struct v4l2_rect *r)
517{
518 dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top,
519 r->width, r->height);
520};
521
522static inline void v4l_print_pix_fmt(struct video_device *vfd,
523 struct v4l2_pix_format *fmt)
524{
525 dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, "
526 "bytesperline=%d sizeimage=%d, colorspace=%d\n",
527 fmt->width, fmt->height,
528 (fmt->pixelformat & 0xff),
529 (fmt->pixelformat >> 8) & 0xff,
530 (fmt->pixelformat >> 16) & 0xff,
531 (fmt->pixelformat >> 24) & 0xff,
532 prt_names(fmt->field, v4l2_field_names),
533 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
534};
535
536static inline void v4l_print_ext_ctrls(unsigned int cmd,
537 struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals)
538{
539 __u32 i;
540
541 if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG))
542 return;
543 dbgarg(cmd, "");
544 printk(KERN_CONT "class=0x%x", c->ctrl_class);
545 for (i = 0; i < c->count; i++) {
546 if (show_vals)
547 printk(KERN_CONT " id/val=0x%x/0x%x",
548 c->controls[i].id, c->controls[i].value);
549 else
550 printk(KERN_CONT " id=0x%x", c->controls[i].id);
551 }
552 printk(KERN_CONT "\n");
553};
554
555static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
556{
557 __u32 i;
558
559 /* zero the reserved fields */
560 c->reserved[0] = c->reserved[1] = 0;
561 for (i = 0; i < c->count; i++) {
562 c->controls[i].reserved2[0] = 0;
563 c->controls[i].reserved2[1] = 0;
564 }
565 /* V4L2_CID_PRIVATE_BASE cannot be used as control class
566 when using extended controls.
567 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
568 is it allowed for backwards compatibility.
569 */
570 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)
571 return 0;
572 /* Check that all controls are from the same control class. */
573 for (i = 0; i < c->count; i++) {
574 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) {
575 c->error_idx = i;
576 return 0;
577 }
578 }
579 return 1;
580}
581
582static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type)
583{
584 if (ops == NULL)
585 return -EINVAL;
586
587 switch (type) {
588 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
589 if (ops->vidioc_try_fmt_vid_cap)
590 return 0;
591 break;
592 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
593 if (ops->vidioc_try_fmt_vid_overlay)
594 return 0;
595 break;
596 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
597 if (ops->vidioc_try_fmt_vid_out)
598 return 0;
599 break;
600 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
601 if (ops->vidioc_try_fmt_vid_out_overlay)
602 return 0;
603 break;
604 case V4L2_BUF_TYPE_VBI_CAPTURE:
605 if (ops->vidioc_try_fmt_vbi_cap)
606 return 0;
607 break;
608 case V4L2_BUF_TYPE_VBI_OUTPUT:
609 if (ops->vidioc_try_fmt_vbi_out)
610 return 0;
611 break;
612 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
613 if (ops->vidioc_try_fmt_sliced_vbi_cap)
614 return 0;
615 break;
616 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
617 if (ops->vidioc_try_fmt_sliced_vbi_out)
618 return 0;
619 break;
620 case V4L2_BUF_TYPE_PRIVATE:
621 if (ops->vidioc_try_fmt_type_private)
622 return 0;
623 break;
624 }
625 return -EINVAL;
626}
627
628static int __video_do_ioctl(struct inode *inode, struct file *file,
629 unsigned int cmd, void *arg)
630{
631 struct video_device *vfd = video_devdata(file);
632 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
633 void *fh = file->private_data;
634 int ret = -EINVAL;
635
636 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
637 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
638 v4l_print_ioctl(vfd->name, cmd);
639 printk(KERN_CONT "\n");
640 }
641
642 if (ops == NULL) {
643 printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n",
644 vfd->name);
645 return -EINVAL;
646 }
647
648#ifdef CONFIG_VIDEO_V4L1_COMPAT
649 /***********************************************************
650 Handles calls to the obsoleted V4L1 API
651 Due to the nature of VIDIOCGMBUF, each driver that supports
652 V4L1 should implement its own handler for this ioctl.
653 ***********************************************************/
654
655 /* --- streaming capture ------------------------------------- */
656 if (cmd == VIDIOCGMBUF) {
657 struct video_mbuf *p = arg;
658
659 memset(p, 0, sizeof(*p));
660
661 if (!ops->vidiocgmbuf)
662 return ret;
663 ret = ops->vidiocgmbuf(file, fh, p);
664 if (!ret)
665 dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
666 p->size, p->frames,
667 (unsigned long)p->offsets);
668 return ret;
669 }
670
671 /********************************************************
672 All other V4L1 calls are handled by v4l1_compat module.
673 Those calls will be translated into V4L2 calls, and
674 __video_do_ioctl will be called again, with one or more
675 V4L2 ioctls.
676 ********************************************************/
677 if (_IOC_TYPE(cmd) == 'v')
678 return v4l_compat_translate_ioctl(inode, file, cmd, arg,
679 __video_do_ioctl);
680#endif
681
682 switch (cmd) {
683 /* --- capabilities ------------------------------------------ */
684 case VIDIOC_QUERYCAP:
685 {
686 struct v4l2_capability *cap = (struct v4l2_capability *)arg;
687 memset(cap, 0, sizeof(*cap));
688
689 if (!ops->vidioc_querycap)
690 break;
691
692 ret = ops->vidioc_querycap(file, fh, cap);
693 if (!ret)
694 dbgarg(cmd, "driver=%s, card=%s, bus=%s, "
695 "version=0x%08x, "
696 "capabilities=0x%08x\n",
697 cap->driver, cap->card, cap->bus_info,
698 cap->version,
699 cap->capabilities);
700 break;
701 }
702
703 /* --- priority ------------------------------------------ */
704 case VIDIOC_G_PRIORITY:
705 {
706 enum v4l2_priority *p = arg;
707
708 if (!ops->vidioc_g_priority)
709 break;
710 ret = ops->vidioc_g_priority(file, fh, p);
711 if (!ret)
712 dbgarg(cmd, "priority is %d\n", *p);
713 break;
714 }
715 case VIDIOC_S_PRIORITY:
716 {
717 enum v4l2_priority *p = arg;
718
719 if (!ops->vidioc_s_priority)
720 break;
721 dbgarg(cmd, "setting priority to %d\n", *p);
722 ret = ops->vidioc_s_priority(file, fh, *p);
723 break;
724 }
725
726 /* --- capture ioctls ---------------------------------------- */
727 case VIDIOC_ENUM_FMT:
728 {
729 struct v4l2_fmtdesc *f = arg;
730 enum v4l2_buf_type type;
731 unsigned int index;
732
733 index = f->index;
734 type = f->type;
735 memset(f, 0, sizeof(*f));
736 f->index = index;
737 f->type = type;
738
739 switch (type) {
740 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
741 if (ops->vidioc_enum_fmt_vid_cap)
742 ret = ops->vidioc_enum_fmt_vid_cap(file, fh, f);
743 break;
744 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
745 if (ops->vidioc_enum_fmt_vid_overlay)
746 ret = ops->vidioc_enum_fmt_vid_overlay(file,
747 fh, f);
748 break;
749#if 1
750 /* V4L2_BUF_TYPE_VBI_CAPTURE should not support VIDIOC_ENUM_FMT
751 * according to the spec. The bttv and saa7134 drivers support
752 * it though, so just warn that this is deprecated and will be
753 * removed in the near future. */
754 case V4L2_BUF_TYPE_VBI_CAPTURE:
755 if (ops->vidioc_enum_fmt_vbi_cap) {
756 printk(KERN_WARNING "vidioc_enum_fmt_vbi_cap will be removed in 2.6.28!\n");
757 ret = ops->vidioc_enum_fmt_vbi_cap(file, fh, f);
758 }
759 break;
760#endif
761 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
762 if (ops->vidioc_enum_fmt_vid_out)
763 ret = ops->vidioc_enum_fmt_vid_out(file, fh, f);
764 break;
765 case V4L2_BUF_TYPE_PRIVATE:
766 if (ops->vidioc_enum_fmt_type_private)
767 ret = ops->vidioc_enum_fmt_type_private(file,
768 fh, f);
769 break;
770 default:
771 break;
772 }
773 if (!ret)
774 dbgarg(cmd, "index=%d, type=%d, flags=%d, "
775 "pixelformat=%c%c%c%c, description='%s'\n",
776 f->index, f->type, f->flags,
777 (f->pixelformat & 0xff),
778 (f->pixelformat >> 8) & 0xff,
779 (f->pixelformat >> 16) & 0xff,
780 (f->pixelformat >> 24) & 0xff,
781 f->description);
782 break;
783 }
784 case VIDIOC_G_FMT:
785 {
786 struct v4l2_format *f = (struct v4l2_format *)arg;
787
788 memset(f->fmt.raw_data, 0, sizeof(f->fmt.raw_data));
789
790 /* FIXME: Should be one dump per type */
791 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
792
793 switch (f->type) {
794 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
795 if (ops->vidioc_g_fmt_vid_cap)
796 ret = ops->vidioc_g_fmt_vid_cap(file, fh, f);
797 if (!ret)
798 v4l_print_pix_fmt(vfd, &f->fmt.pix);
799 break;
800 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
801 if (ops->vidioc_g_fmt_vid_overlay)
802 ret = ops->vidioc_g_fmt_vid_overlay(file,
803 fh, f);
804 break;
805 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
806 if (ops->vidioc_g_fmt_vid_out)
807 ret = ops->vidioc_g_fmt_vid_out(file, fh, f);
808 if (!ret)
809 v4l_print_pix_fmt(vfd, &f->fmt.pix);
810 break;
811 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
812 if (ops->vidioc_g_fmt_vid_out_overlay)
813 ret = ops->vidioc_g_fmt_vid_out_overlay(file,
814 fh, f);
815 break;
816 case V4L2_BUF_TYPE_VBI_CAPTURE:
817 if (ops->vidioc_g_fmt_vbi_cap)
818 ret = ops->vidioc_g_fmt_vbi_cap(file, fh, f);
819 break;
820 case V4L2_BUF_TYPE_VBI_OUTPUT:
821 if (ops->vidioc_g_fmt_vbi_out)
822 ret = ops->vidioc_g_fmt_vbi_out(file, fh, f);
823 break;
824 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
825 if (ops->vidioc_g_fmt_sliced_vbi_cap)
826 ret = ops->vidioc_g_fmt_sliced_vbi_cap(file,
827 fh, f);
828 break;
829 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
830 if (ops->vidioc_g_fmt_sliced_vbi_out)
831 ret = ops->vidioc_g_fmt_sliced_vbi_out(file,
832 fh, f);
833 break;
834 case V4L2_BUF_TYPE_PRIVATE:
835 if (ops->vidioc_g_fmt_type_private)
836 ret = ops->vidioc_g_fmt_type_private(file,
837 fh, f);
838 break;
839 }
840
841 break;
842 }
843 case VIDIOC_S_FMT:
844 {
845 struct v4l2_format *f = (struct v4l2_format *)arg;
846
847 /* FIXME: Should be one dump per type */
848 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
849
850 switch (f->type) {
851 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
852 v4l_print_pix_fmt(vfd, &f->fmt.pix);
853 if (ops->vidioc_s_fmt_vid_cap)
854 ret = ops->vidioc_s_fmt_vid_cap(file, fh, f);
855 break;
856 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
857 if (ops->vidioc_s_fmt_vid_overlay)
858 ret = ops->vidioc_s_fmt_vid_overlay(file,
859 fh, f);
860 break;
861 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
862 v4l_print_pix_fmt(vfd, &f->fmt.pix);
863 if (ops->vidioc_s_fmt_vid_out)
864 ret = ops->vidioc_s_fmt_vid_out(file, fh, f);
865 break;
866 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
867 if (ops->vidioc_s_fmt_vid_out_overlay)
868 ret = ops->vidioc_s_fmt_vid_out_overlay(file,
869 fh, f);
870 break;
871 case V4L2_BUF_TYPE_VBI_CAPTURE:
872 if (ops->vidioc_s_fmt_vbi_cap)
873 ret = ops->vidioc_s_fmt_vbi_cap(file, fh, f);
874 break;
875 case V4L2_BUF_TYPE_VBI_OUTPUT:
876 if (ops->vidioc_s_fmt_vbi_out)
877 ret = ops->vidioc_s_fmt_vbi_out(file, fh, f);
878 break;
879 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
880 if (ops->vidioc_s_fmt_sliced_vbi_cap)
881 ret = ops->vidioc_s_fmt_sliced_vbi_cap(file,
882 fh, f);
883 break;
884 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
885 if (ops->vidioc_s_fmt_sliced_vbi_out)
886 ret = ops->vidioc_s_fmt_sliced_vbi_out(file,
887 fh, f);
888 break;
889 case V4L2_BUF_TYPE_PRIVATE:
890 if (ops->vidioc_s_fmt_type_private)
891 ret = ops->vidioc_s_fmt_type_private(file,
892 fh, f);
893 break;
894 }
895 break;
896 }
897 case VIDIOC_TRY_FMT:
898 {
899 struct v4l2_format *f = (struct v4l2_format *)arg;
900
901 /* FIXME: Should be one dump per type */
902 dbgarg(cmd, "type=%s\n", prt_names(f->type,
903 v4l2_type_names));
904 switch (f->type) {
905 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
906 if (ops->vidioc_try_fmt_vid_cap)
907 ret = ops->vidioc_try_fmt_vid_cap(file, fh, f);
908 if (!ret)
909 v4l_print_pix_fmt(vfd, &f->fmt.pix);
910 break;
911 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
912 if (ops->vidioc_try_fmt_vid_overlay)
913 ret = ops->vidioc_try_fmt_vid_overlay(file,
914 fh, f);
915 break;
916 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
917 if (ops->vidioc_try_fmt_vid_out)
918 ret = ops->vidioc_try_fmt_vid_out(file, fh, f);
919 if (!ret)
920 v4l_print_pix_fmt(vfd, &f->fmt.pix);
921 break;
922 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
923 if (ops->vidioc_try_fmt_vid_out_overlay)
924 ret = ops->vidioc_try_fmt_vid_out_overlay(file,
925 fh, f);
926 break;
927 case V4L2_BUF_TYPE_VBI_CAPTURE:
928 if (ops->vidioc_try_fmt_vbi_cap)
929 ret = ops->vidioc_try_fmt_vbi_cap(file, fh, f);
930 break;
931 case V4L2_BUF_TYPE_VBI_OUTPUT:
932 if (ops->vidioc_try_fmt_vbi_out)
933 ret = ops->vidioc_try_fmt_vbi_out(file, fh, f);
934 break;
935 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
936 if (ops->vidioc_try_fmt_sliced_vbi_cap)
937 ret = ops->vidioc_try_fmt_sliced_vbi_cap(file,
938 fh, f);
939 break;
940 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
941 if (ops->vidioc_try_fmt_sliced_vbi_out)
942 ret = ops->vidioc_try_fmt_sliced_vbi_out(file,
943 fh, f);
944 break;
945 case V4L2_BUF_TYPE_PRIVATE:
946 if (ops->vidioc_try_fmt_type_private)
947 ret = ops->vidioc_try_fmt_type_private(file,
948 fh, f);
949 break;
950 }
951
952 break;
953 }
954 /* FIXME: Those buf reqs could be handled here,
955 with some changes on videobuf to allow its header to be included at
956 videodev2.h or being merged at videodev2.
957 */
958 case VIDIOC_REQBUFS:
959 {
960 struct v4l2_requestbuffers *p = arg;
961
962 if (!ops->vidioc_reqbufs)
963 break;
964 ret = check_fmt(ops, p->type);
965 if (ret)
966 break;
967
968 ret = ops->vidioc_reqbufs(file, fh, p);
969 dbgarg(cmd, "count=%d, type=%s, memory=%s\n",
970 p->count,
971 prt_names(p->type, v4l2_type_names),
972 prt_names(p->memory, v4l2_memory_names));
973 break;
974 }
975 case VIDIOC_QUERYBUF:
976 {
977 struct v4l2_buffer *p = arg;
978
979 if (!ops->vidioc_querybuf)
980 break;
981 ret = check_fmt(ops, p->type);
982 if (ret)
983 break;
984
985 ret = ops->vidioc_querybuf(file, fh, p);
986 if (!ret)
987 dbgbuf(cmd, vfd, p);
988 break;
989 }
990 case VIDIOC_QBUF:
991 {
992 struct v4l2_buffer *p = arg;
993
994 if (!ops->vidioc_qbuf)
995 break;
996 ret = check_fmt(ops, p->type);
997 if (ret)
998 break;
999
1000 ret = ops->vidioc_qbuf(file, fh, p);
1001 if (!ret)
1002 dbgbuf(cmd, vfd, p);
1003 break;
1004 }
1005 case VIDIOC_DQBUF:
1006 {
1007 struct v4l2_buffer *p = arg;
1008
1009 if (!ops->vidioc_dqbuf)
1010 break;
1011 ret = check_fmt(ops, p->type);
1012 if (ret)
1013 break;
1014
1015 ret = ops->vidioc_dqbuf(file, fh, p);
1016 if (!ret)
1017 dbgbuf(cmd, vfd, p);
1018 break;
1019 }
1020 case VIDIOC_OVERLAY:
1021 {
1022 int *i = arg;
1023
1024 if (!ops->vidioc_overlay)
1025 break;
1026 dbgarg(cmd, "value=%d\n", *i);
1027 ret = ops->vidioc_overlay(file, fh, *i);
1028 break;
1029 }
1030 case VIDIOC_G_FBUF:
1031 {
1032 struct v4l2_framebuffer *p = arg;
1033
1034 if (!ops->vidioc_g_fbuf)
1035 break;
1036 ret = ops->vidioc_g_fbuf(file, fh, arg);
1037 if (!ret) {
1038 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1039 p->capability, p->flags,
1040 (unsigned long)p->base);
1041 v4l_print_pix_fmt(vfd, &p->fmt);
1042 }
1043 break;
1044 }
1045 case VIDIOC_S_FBUF:
1046 {
1047 struct v4l2_framebuffer *p = arg;
1048
1049 if (!ops->vidioc_s_fbuf)
1050 break;
1051 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1052 p->capability, p->flags, (unsigned long)p->base);
1053 v4l_print_pix_fmt(vfd, &p->fmt);
1054 ret = ops->vidioc_s_fbuf(file, fh, arg);
1055 break;
1056 }
1057 case VIDIOC_STREAMON:
1058 {
1059 enum v4l2_buf_type i = *(int *)arg;
1060
1061 if (!ops->vidioc_streamon)
1062 break;
1063 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1064 ret = ops->vidioc_streamon(file, fh, i);
1065 break;
1066 }
1067 case VIDIOC_STREAMOFF:
1068 {
1069 enum v4l2_buf_type i = *(int *)arg;
1070
1071 if (!ops->vidioc_streamoff)
1072 break;
1073 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1074 ret = ops->vidioc_streamoff(file, fh, i);
1075 break;
1076 }
1077 /* ---------- tv norms ---------- */
1078 case VIDIOC_ENUMSTD:
1079 {
1080 struct v4l2_standard *p = arg;
1081 v4l2_std_id id = vfd->tvnorms, curr_id = 0;
1082 unsigned int index = p->index, i, j = 0;
1083 const char *descr = "";
1084
1085 /* Return norm array in a canonical way */
1086 for (i = 0; i <= index && id; i++) {
1087 /* last std value in the standards array is 0, so this
1088 while always ends there since (id & 0) == 0. */
1089 while ((id & standards[j].std) != standards[j].std)
1090 j++;
1091 curr_id = standards[j].std;
1092 descr = standards[j].descr;
1093 j++;
1094 if (curr_id == 0)
1095 break;
1096 if (curr_id != V4L2_STD_PAL &&
1097 curr_id != V4L2_STD_SECAM &&
1098 curr_id != V4L2_STD_NTSC)
1099 id &= ~curr_id;
1100 }
1101 if (i <= index)
1102 return -EINVAL;
1103
1104 v4l2_video_std_construct(p, curr_id, descr);
1105 p->index = index;
1106
1107 dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, "
1108 "framelines=%d\n", p->index,
1109 (unsigned long long)p->id, p->name,
1110 p->frameperiod.numerator,
1111 p->frameperiod.denominator,
1112 p->framelines);
1113
1114 ret = 0;
1115 break;
1116 }
1117 case VIDIOC_G_STD:
1118 {
1119 v4l2_std_id *id = arg;
1120
1121 ret = 0;
1122 /* Calls the specific handler */
1123 if (ops->vidioc_g_std)
1124 ret = ops->vidioc_g_std(file, fh, id);
1125 else
1126 *id = vfd->current_norm;
1127
1128 if (!ret)
1129 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
1130 break;
1131 }
1132 case VIDIOC_S_STD:
1133 {
1134 v4l2_std_id *id = arg, norm;
1135
1136 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1137
1138 norm = (*id) & vfd->tvnorms;
1139 if (vfd->tvnorms && !norm) /* Check if std is supported */
1140 break;
1141
1142 /* Calls the specific handler */
1143 if (ops->vidioc_s_std)
1144 ret = ops->vidioc_s_std(file, fh, &norm);
1145 else
1146 ret = -EINVAL;
1147
1148 /* Updates standard information */
1149 if (ret >= 0)
1150 vfd->current_norm = norm;
1151 break;
1152 }
1153 case VIDIOC_QUERYSTD:
1154 {
1155 v4l2_std_id *p = arg;
1156
1157 if (!ops->vidioc_querystd)
1158 break;
1159 ret = ops->vidioc_querystd(file, fh, arg);
1160 if (!ret)
1161 dbgarg(cmd, "detected std=%08Lx\n",
1162 (unsigned long long)*p);
1163 break;
1164 }
1165 /* ------ input switching ---------- */
1166 /* FIXME: Inputs can be handled inside videodev2 */
1167 case VIDIOC_ENUMINPUT:
1168 {
1169 struct v4l2_input *p = arg;
1170 int i = p->index;
1171
1172 if (!ops->vidioc_enum_input)
1173 break;
1174 memset(p, 0, sizeof(*p));
1175 p->index = i;
1176
1177 ret = ops->vidioc_enum_input(file, fh, p);
1178 if (!ret)
1179 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1180 "audioset=%d, "
1181 "tuner=%d, std=%08Lx, status=%d\n",
1182 p->index, p->name, p->type, p->audioset,
1183 p->tuner,
1184 (unsigned long long)p->std,
1185 p->status);
1186 break;
1187 }
1188 case VIDIOC_G_INPUT:
1189 {
1190 unsigned int *i = arg;
1191
1192 if (!ops->vidioc_g_input)
1193 break;
1194 ret = ops->vidioc_g_input(file, fh, i);
1195 if (!ret)
1196 dbgarg(cmd, "value=%d\n", *i);
1197 break;
1198 }
1199 case VIDIOC_S_INPUT:
1200 {
1201 unsigned int *i = arg;
1202
1203 if (!ops->vidioc_s_input)
1204 break;
1205 dbgarg(cmd, "value=%d\n", *i);
1206 ret = ops->vidioc_s_input(file, fh, *i);
1207 break;
1208 }
1209
1210 /* ------ output switching ---------- */
1211 case VIDIOC_ENUMOUTPUT:
1212 {
1213 struct v4l2_output *p = arg;
1214 int i = p->index;
1215
1216 if (!ops->vidioc_enum_output)
1217 break;
1218 memset(p, 0, sizeof(*p));
1219 p->index = i;
1220
1221 ret = ops->vidioc_enum_output(file, fh, p);
1222 if (!ret)
1223 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1224 "audioset=0x%x, "
1225 "modulator=%d, std=0x%08Lx\n",
1226 p->index, p->name, p->type, p->audioset,
1227 p->modulator, (unsigned long long)p->std);
1228 break;
1229 }
1230 case VIDIOC_G_OUTPUT:
1231 {
1232 unsigned int *i = arg;
1233
1234 if (!ops->vidioc_g_output)
1235 break;
1236 ret = ops->vidioc_g_output(file, fh, i);
1237 if (!ret)
1238 dbgarg(cmd, "value=%d\n", *i);
1239 break;
1240 }
1241 case VIDIOC_S_OUTPUT:
1242 {
1243 unsigned int *i = arg;
1244
1245 if (!ops->vidioc_s_output)
1246 break;
1247 dbgarg(cmd, "value=%d\n", *i);
1248 ret = ops->vidioc_s_output(file, fh, *i);
1249 break;
1250 }
1251
1252 /* --- controls ---------------------------------------------- */
1253 case VIDIOC_QUERYCTRL:
1254 {
1255 struct v4l2_queryctrl *p = arg;
1256
1257 if (!ops->vidioc_queryctrl)
1258 break;
1259 ret = ops->vidioc_queryctrl(file, fh, p);
1260 if (!ret)
1261 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
1262 "step=%d, default=%d, flags=0x%08x\n",
1263 p->id, p->type, p->name,
1264 p->minimum, p->maximum,
1265 p->step, p->default_value, p->flags);
1266 else
1267 dbgarg(cmd, "id=0x%x\n", p->id);
1268 break;
1269 }
1270 case VIDIOC_G_CTRL:
1271 {
1272 struct v4l2_control *p = arg;
1273
1274 if (ops->vidioc_g_ctrl)
1275 ret = ops->vidioc_g_ctrl(file, fh, p);
1276 else if (ops->vidioc_g_ext_ctrls) {
1277 struct v4l2_ext_controls ctrls;
1278 struct v4l2_ext_control ctrl;
1279
1280 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1281 ctrls.count = 1;
1282 ctrls.controls = &ctrl;
1283 ctrl.id = p->id;
1284 ctrl.value = p->value;
1285 if (check_ext_ctrls(&ctrls, 1)) {
1286 ret = ops->vidioc_g_ext_ctrls(file, fh, &ctrls);
1287 if (ret == 0)
1288 p->value = ctrl.value;
1289 }
1290 } else
1291 break;
1292 if (!ret)
1293 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1294 else
1295 dbgarg(cmd, "id=0x%x\n", p->id);
1296 break;
1297 }
1298 case VIDIOC_S_CTRL:
1299 {
1300 struct v4l2_control *p = arg;
1301 struct v4l2_ext_controls ctrls;
1302 struct v4l2_ext_control ctrl;
1303
1304 if (!ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
1305 break;
1306
1307 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1308
1309 if (ops->vidioc_s_ctrl) {
1310 ret = ops->vidioc_s_ctrl(file, fh, p);
1311 break;
1312 }
1313 if (!ops->vidioc_s_ext_ctrls)
1314 break;
1315
1316 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1317 ctrls.count = 1;
1318 ctrls.controls = &ctrl;
1319 ctrl.id = p->id;
1320 ctrl.value = p->value;
1321 if (check_ext_ctrls(&ctrls, 1))
1322 ret = ops->vidioc_s_ext_ctrls(file, fh, &ctrls);
1323 break;
1324 }
1325 case VIDIOC_G_EXT_CTRLS:
1326 {
1327 struct v4l2_ext_controls *p = arg;
1328
1329 p->error_idx = p->count;
1330 if (!ops->vidioc_g_ext_ctrls)
1331 break;
1332 if (check_ext_ctrls(p, 0))
1333 ret = ops->vidioc_g_ext_ctrls(file, fh, p);
1334 v4l_print_ext_ctrls(cmd, vfd, p, !ret);
1335 break;
1336 }
1337 case VIDIOC_S_EXT_CTRLS:
1338 {
1339 struct v4l2_ext_controls *p = arg;
1340
1341 p->error_idx = p->count;
1342 if (!ops->vidioc_s_ext_ctrls)
1343 break;
1344 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1345 if (check_ext_ctrls(p, 0))
1346 ret = ops->vidioc_s_ext_ctrls(file, fh, p);
1347 break;
1348 }
1349 case VIDIOC_TRY_EXT_CTRLS:
1350 {
1351 struct v4l2_ext_controls *p = arg;
1352
1353 p->error_idx = p->count;
1354 if (!ops->vidioc_try_ext_ctrls)
1355 break;
1356 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1357 if (check_ext_ctrls(p, 0))
1358 ret = ops->vidioc_try_ext_ctrls(file, fh, p);
1359 break;
1360 }
1361 case VIDIOC_QUERYMENU:
1362 {
1363 struct v4l2_querymenu *p = arg;
1364
1365 if (!ops->vidioc_querymenu)
1366 break;
1367 ret = ops->vidioc_querymenu(file, fh, p);
1368 if (!ret)
1369 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n",
1370 p->id, p->index, p->name);
1371 else
1372 dbgarg(cmd, "id=0x%x, index=%d\n",
1373 p->id, p->index);
1374 break;
1375 }
1376 /* --- audio ---------------------------------------------- */
1377 case VIDIOC_ENUMAUDIO:
1378 {
1379 struct v4l2_audio *p = arg;
1380
1381 if (!ops->vidioc_enumaudio)
1382 break;
1383 ret = ops->vidioc_enumaudio(file, fh, p);
1384 if (!ret)
1385 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1386 "mode=0x%x\n", p->index, p->name,
1387 p->capability, p->mode);
1388 else
1389 dbgarg(cmd, "index=%d\n", p->index);
1390 break;
1391 }
1392 case VIDIOC_G_AUDIO:
1393 {
1394 struct v4l2_audio *p = arg;
1395 __u32 index = p->index;
1396
1397 if (!ops->vidioc_g_audio)
1398 break;
1399
1400 memset(p, 0, sizeof(*p));
1401 p->index = index;
1402 ret = ops->vidioc_g_audio(file, fh, p);
1403 if (!ret)
1404 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1405 "mode=0x%x\n", p->index,
1406 p->name, p->capability, p->mode);
1407 else
1408 dbgarg(cmd, "index=%d\n", p->index);
1409 break;
1410 }
1411 case VIDIOC_S_AUDIO:
1412 {
1413 struct v4l2_audio *p = arg;
1414
1415 if (!ops->vidioc_s_audio)
1416 break;
1417 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1418 "mode=0x%x\n", p->index, p->name,
1419 p->capability, p->mode);
1420 ret = ops->vidioc_s_audio(file, fh, p);
1421 break;
1422 }
1423 case VIDIOC_ENUMAUDOUT:
1424 {
1425 struct v4l2_audioout *p = arg;
1426
1427 if (!ops->vidioc_enumaudout)
1428 break;
1429 dbgarg(cmd, "Enum for index=%d\n", p->index);
1430 ret = ops->vidioc_enumaudout(file, fh, p);
1431 if (!ret)
1432 dbgarg2("index=%d, name=%s, capability=%d, "
1433 "mode=%d\n", p->index, p->name,
1434 p->capability, p->mode);
1435 break;
1436 }
1437 case VIDIOC_G_AUDOUT:
1438 {
1439 struct v4l2_audioout *p = arg;
1440
1441 if (!ops->vidioc_g_audout)
1442 break;
1443 dbgarg(cmd, "Enum for index=%d\n", p->index);
1444 ret = ops->vidioc_g_audout(file, fh, p);
1445 if (!ret)
1446 dbgarg2("index=%d, name=%s, capability=%d, "
1447 "mode=%d\n", p->index, p->name,
1448 p->capability, p->mode);
1449 break;
1450 }
1451 case VIDIOC_S_AUDOUT:
1452 {
1453 struct v4l2_audioout *p = arg;
1454
1455 if (!ops->vidioc_s_audout)
1456 break;
1457 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1458 "mode=%d\n", p->index, p->name,
1459 p->capability, p->mode);
1460
1461 ret = ops->vidioc_s_audout(file, fh, p);
1462 break;
1463 }
1464 case VIDIOC_G_MODULATOR:
1465 {
1466 struct v4l2_modulator *p = arg;
1467
1468 if (!ops->vidioc_g_modulator)
1469 break;
1470 ret = ops->vidioc_g_modulator(file, fh, p);
1471 if (!ret)
1472 dbgarg(cmd, "index=%d, name=%s, "
1473 "capability=%d, rangelow=%d,"
1474 " rangehigh=%d, txsubchans=%d\n",
1475 p->index, p->name, p->capability,
1476 p->rangelow, p->rangehigh,
1477 p->txsubchans);
1478 break;
1479 }
1480 case VIDIOC_S_MODULATOR:
1481 {
1482 struct v4l2_modulator *p = arg;
1483
1484 if (!ops->vidioc_s_modulator)
1485 break;
1486 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1487 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1488 p->index, p->name, p->capability, p->rangelow,
1489 p->rangehigh, p->txsubchans);
1490 ret = ops->vidioc_s_modulator(file, fh, p);
1491 break;
1492 }
1493 case VIDIOC_G_CROP:
1494 {
1495 struct v4l2_crop *p = arg;
1496
1497 if (!ops->vidioc_g_crop)
1498 break;
1499 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1500 ret = ops->vidioc_g_crop(file, fh, p);
1501 if (!ret)
1502 dbgrect(vfd, "", &p->c);
1503 break;
1504 }
1505 case VIDIOC_S_CROP:
1506 {
1507 struct v4l2_crop *p = arg;
1508
1509 if (!ops->vidioc_s_crop)
1510 break;
1511 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1512 dbgrect(vfd, "", &p->c);
1513 ret = ops->vidioc_s_crop(file, fh, p);
1514 break;
1515 }
1516 case VIDIOC_CROPCAP:
1517 {
1518 struct v4l2_cropcap *p = arg;
1519
1520 /*FIXME: Should also show v4l2_fract pixelaspect */
1521 if (!ops->vidioc_cropcap)
1522 break;
1523 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1524 ret = ops->vidioc_cropcap(file, fh, p);
1525 if (!ret) {
1526 dbgrect(vfd, "bounds ", &p->bounds);
1527 dbgrect(vfd, "defrect ", &p->defrect);
1528 }
1529 break;
1530 }
1531 case VIDIOC_G_JPEGCOMP:
1532 {
1533 struct v4l2_jpegcompression *p = arg;
1534
1535 if (!ops->vidioc_g_jpegcomp)
1536 break;
1537 ret = ops->vidioc_g_jpegcomp(file, fh, p);
1538 if (!ret)
1539 dbgarg(cmd, "quality=%d, APPn=%d, "
1540 "APP_len=%d, COM_len=%d, "
1541 "jpeg_markers=%d\n",
1542 p->quality, p->APPn, p->APP_len,
1543 p->COM_len, p->jpeg_markers);
1544 break;
1545 }
1546 case VIDIOC_S_JPEGCOMP:
1547 {
1548 struct v4l2_jpegcompression *p = arg;
1549
1550 if (!ops->vidioc_g_jpegcomp)
1551 break;
1552 dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, "
1553 "COM_len=%d, jpeg_markers=%d\n",
1554 p->quality, p->APPn, p->APP_len,
1555 p->COM_len, p->jpeg_markers);
1556 ret = ops->vidioc_s_jpegcomp(file, fh, p);
1557 break;
1558 }
1559 case VIDIOC_G_ENC_INDEX:
1560 {
1561 struct v4l2_enc_idx *p = arg;
1562
1563 if (!ops->vidioc_g_enc_index)
1564 break;
1565 ret = ops->vidioc_g_enc_index(file, fh, p);
1566 if (!ret)
1567 dbgarg(cmd, "entries=%d, entries_cap=%d\n",
1568 p->entries, p->entries_cap);
1569 break;
1570 }
1571 case VIDIOC_ENCODER_CMD:
1572 {
1573 struct v4l2_encoder_cmd *p = arg;
1574
1575 if (!ops->vidioc_encoder_cmd)
1576 break;
1577 memset(&p->raw, 0, sizeof(p->raw));
1578 ret = ops->vidioc_encoder_cmd(file, fh, p);
1579 if (!ret)
1580 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1581 break;
1582 }
1583 case VIDIOC_TRY_ENCODER_CMD:
1584 {
1585 struct v4l2_encoder_cmd *p = arg;
1586
1587 if (!ops->vidioc_try_encoder_cmd)
1588 break;
1589 memset(&p->raw, 0, sizeof(p->raw));
1590 ret = ops->vidioc_try_encoder_cmd(file, fh, p);
1591 if (!ret)
1592 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1593 break;
1594 }
1595 case VIDIOC_G_PARM:
1596 {
1597 struct v4l2_streamparm *p = arg;
1598 __u32 type = p->type;
1599
1600 memset(p, 0, sizeof(*p));
1601 p->type = type;
1602
1603 if (ops->vidioc_g_parm) {
1604 ret = ops->vidioc_g_parm(file, fh, p);
1605 } else {
1606 struct v4l2_standard s;
1607
1608 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1609 return -EINVAL;
1610
1611 v4l2_video_std_construct(&s, vfd->current_norm,
1612 v4l2_norm_to_name(vfd->current_norm));
1613
1614 p->parm.capture.timeperframe = s.frameperiod;
1615 ret = 0;
1616 }
1617
1618 dbgarg(cmd, "type=%d\n", p->type);
1619 break;
1620 }
1621 case VIDIOC_S_PARM:
1622 {
1623 struct v4l2_streamparm *p = arg;
1624
1625 if (!ops->vidioc_s_parm)
1626 break;
1627 dbgarg(cmd, "type=%d\n", p->type);
1628 ret = ops->vidioc_s_parm(file, fh, p);
1629 break;
1630 }
1631 case VIDIOC_G_TUNER:
1632 {
1633 struct v4l2_tuner *p = arg;
1634 __u32 index = p->index;
1635
1636 if (!ops->vidioc_g_tuner)
1637 break;
1638
1639 memset(p, 0, sizeof(*p));
1640 p->index = index;
1641
1642 ret = ops->vidioc_g_tuner(file, fh, p);
1643 if (!ret)
1644 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1645 "capability=0x%x, rangelow=%d, "
1646 "rangehigh=%d, signal=%d, afc=%d, "
1647 "rxsubchans=0x%x, audmode=%d\n",
1648 p->index, p->name, p->type,
1649 p->capability, p->rangelow,
1650 p->rangehigh, p->signal, p->afc,
1651 p->rxsubchans, p->audmode);
1652 break;
1653 }
1654 case VIDIOC_S_TUNER:
1655 {
1656 struct v4l2_tuner *p = arg;
1657
1658 if (!ops->vidioc_s_tuner)
1659 break;
1660 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1661 "capability=0x%x, rangelow=%d, "
1662 "rangehigh=%d, signal=%d, afc=%d, "
1663 "rxsubchans=0x%x, audmode=%d\n",
1664 p->index, p->name, p->type,
1665 p->capability, p->rangelow,
1666 p->rangehigh, p->signal, p->afc,
1667 p->rxsubchans, p->audmode);
1668 ret = ops->vidioc_s_tuner(file, fh, p);
1669 break;
1670 }
1671 case VIDIOC_G_FREQUENCY:
1672 {
1673 struct v4l2_frequency *p = arg;
1674
1675 if (!ops->vidioc_g_frequency)
1676 break;
1677
1678 memset(p->reserved, 0, sizeof(p->reserved));
1679
1680 ret = ops->vidioc_g_frequency(file, fh, p);
1681 if (!ret)
1682 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1683 p->tuner, p->type, p->frequency);
1684 break;
1685 }
1686 case VIDIOC_S_FREQUENCY:
1687 {
1688 struct v4l2_frequency *p = arg;
1689
1690 if (!ops->vidioc_s_frequency)
1691 break;
1692 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1693 p->tuner, p->type, p->frequency);
1694 ret = ops->vidioc_s_frequency(file, fh, p);
1695 break;
1696 }
1697 case VIDIOC_G_SLICED_VBI_CAP:
1698 {
1699 struct v4l2_sliced_vbi_cap *p = arg;
1700 __u32 type = p->type;
1701
1702 if (!ops->vidioc_g_sliced_vbi_cap)
1703 break;
1704 memset(p, 0, sizeof(*p));
1705 p->type = type;
1706 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1707 ret = ops->vidioc_g_sliced_vbi_cap(file, fh, p);
1708 if (!ret)
1709 dbgarg2("service_set=%d\n", p->service_set);
1710 break;
1711 }
1712 case VIDIOC_LOG_STATUS:
1713 {
1714 if (!ops->vidioc_log_status)
1715 break;
1716 ret = ops->vidioc_log_status(file, fh);
1717 break;
1718 }
1719#ifdef CONFIG_VIDEO_ADV_DEBUG
1720 case VIDIOC_DBG_G_REGISTER:
1721 {
1722 struct v4l2_register *p = arg;
1723
1724 if (!capable(CAP_SYS_ADMIN))
1725 ret = -EPERM;
1726 else if (ops->vidioc_g_register)
1727 ret = ops->vidioc_g_register(file, fh, p);
1728 break;
1729 }
1730 case VIDIOC_DBG_S_REGISTER:
1731 {
1732 struct v4l2_register *p = arg;
1733
1734 if (!capable(CAP_SYS_ADMIN))
1735 ret = -EPERM;
1736 else if (ops->vidioc_s_register)
1737 ret = ops->vidioc_s_register(file, fh, p);
1738 break;
1739 }
1740#endif
1741 case VIDIOC_G_CHIP_IDENT:
1742 {
1743 struct v4l2_chip_ident *p = arg;
1744
1745 if (!ops->vidioc_g_chip_ident)
1746 break;
1747 ret = ops->vidioc_g_chip_ident(file, fh, p);
1748 if (!ret)
1749 dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1750 break;
1751 }
1752 case VIDIOC_S_HW_FREQ_SEEK:
1753 {
1754 struct v4l2_hw_freq_seek *p = arg;
1755
1756 if (!ops->vidioc_s_hw_freq_seek)
1757 break;
1758 dbgarg(cmd,
1759 "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n",
1760 p->tuner, p->type, p->seek_upward, p->wrap_around);
1761 ret = ops->vidioc_s_hw_freq_seek(file, fh, p);
1762 break;
1763 }
1764 default:
1765 {
1766 if (!ops->vidioc_default)
1767 break;
1768 ret = ops->vidioc_default(file, fh, cmd, arg);
1769 break;
1770 }
1771 } /* switch */
1772
1773 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
1774 if (ret < 0) {
1775 v4l_print_ioctl(vfd->name, cmd);
1776 printk(KERN_CONT " error %d\n", ret);
1777 }
1778 }
1779
1780 return ret;
1781}
1782
1783int video_ioctl2(struct inode *inode, struct file *file,
1784 unsigned int cmd, unsigned long arg)
1785{
1786 char sbuf[128];
1787 void *mbuf = NULL;
1788 void *parg = NULL;
1789 int err = -EINVAL;
1790 int is_ext_ctrl;
1791 size_t ctrls_size = 0;
1792 void __user *user_ptr = NULL;
1793
1794#ifdef __OLD_VIDIOC_
1795 cmd = video_fix_command(cmd);
1796#endif
1797 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
1798 cmd == VIDIOC_TRY_EXT_CTRLS);
1799
1800 /* Copy arguments into temp kernel buffer */
1801 switch (_IOC_DIR(cmd)) {
1802 case _IOC_NONE:
1803 parg = NULL;
1804 break;
1805 case _IOC_READ:
1806 case _IOC_WRITE:
1807 case (_IOC_WRITE | _IOC_READ):
1808 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
1809 parg = sbuf;
1810 } else {
1811 /* too big to allocate from stack */
1812 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
1813 if (NULL == mbuf)
1814 return -ENOMEM;
1815 parg = mbuf;
1816 }
1817
1818 err = -EFAULT;
1819 if (_IOC_DIR(cmd) & _IOC_WRITE)
1820 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
1821 goto out;
1822 break;
1823 }
1824
1825 if (is_ext_ctrl) {
1826 struct v4l2_ext_controls *p = parg;
1827
1828 /* In case of an error, tell the caller that it wasn't
1829 a specific control that caused it. */
1830 p->error_idx = p->count;
1831 user_ptr = (void __user *)p->controls;
1832 if (p->count) {
1833 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
1834 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
1835 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
1836 err = -ENOMEM;
1837 if (NULL == mbuf)
1838 goto out_ext_ctrl;
1839 err = -EFAULT;
1840 if (copy_from_user(mbuf, user_ptr, ctrls_size))
1841 goto out_ext_ctrl;
1842 p->controls = mbuf;
1843 }
1844 }
1845
1846 /* Handles IOCTL */
1847 err = __video_do_ioctl(inode, file, cmd, parg);
1848 if (err == -ENOIOCTLCMD)
1849 err = -EINVAL;
1850 if (is_ext_ctrl) {
1851 struct v4l2_ext_controls *p = parg;
1852
1853 p->controls = (void *)user_ptr;
1854 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
1855 err = -EFAULT;
1856 goto out_ext_ctrl;
1857 }
1858 if (err < 0)
1859 goto out;
1860
1861out_ext_ctrl:
1862 /* Copy results into user buffer */
1863 switch (_IOC_DIR(cmd)) {
1864 case _IOC_READ:
1865 case (_IOC_WRITE | _IOC_READ):
1866 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
1867 err = -EFAULT;
1868 break;
1869 }
1870
1871out:
1872 kfree(mbuf);
1873 return err;
1874}
1875EXPORT_SYMBOL(video_ioctl2);
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 03f20acb668c..31944b11e6ea 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -28,10 +28,10 @@ struct videobuf_dma_contig_memory {
28}; 28};
29 29
30#define MAGIC_DC_MEM 0x0733ac61 30#define MAGIC_DC_MEM 0x0733ac61
31#define MAGIC_CHECK(is, should) \ 31#define MAGIC_CHECK(is, should) \
32 if (unlikely((is) != (should))) { \ 32 if (unlikely((is) != (should))) { \
33 pr_err("magic mismatch: %x expected %x\n", is, should); \ 33 pr_err("magic mismatch: %x expected %x\n", (is), (should)); \
34 BUG(); \ 34 BUG(); \
35 } 35 }
36 36
37static void 37static void
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c
index a868b7ed75ff..be65a2fb3976 100644
--- a/drivers/media/video/videobuf-vmalloc.c
+++ b/drivers/media/video/videobuf-vmalloc.c
@@ -203,7 +203,7 @@ static int __videobuf_iolock (struct videobuf_queue* q,
203 return 0; 203 return 0;
204 204
205 /* FIXME: to properly support USERPTR, remap should occur. 205 /* FIXME: to properly support USERPTR, remap should occur.
206 The code bellow won't work, since mem->vma = NULL 206 The code below won't work, since mem->vma = NULL
207 */ 207 */
208 /* Try to remap memory */ 208 /* Try to remap memory */
209 rc = remap_vmalloc_range(mem->vma, (void *)vb->baddr, 0); 209 rc = remap_vmalloc_range(mem->vma, (void *)vb->baddr, 0);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 6616e6570557..e69de29bb2d1 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -1,2262 +0,0 @@
1/*
2 * Video capture interface for Linux version 2
3 *
4 * A generic video device interface for the LINUX operating system
5 * using a set of device structures/vectors for low level operations.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * Authors: Alan Cox, <alan@redhat.com> (version 1)
13 * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
14 *
15 * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
16 * - Added procfs support
17 */
18
19#define dbgarg(cmd, fmt, arg...) \
20 do { \
21 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
22 printk(KERN_DEBUG "%s: ", vfd->name); \
23 v4l_printk_ioctl(cmd); \
24 printk(" " fmt, ## arg); \
25 } \
26 } while (0)
27
28#define dbgarg2(fmt, arg...) \
29 do { \
30 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
31 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
32 } while (0)
33
34#include <linux/module.h>
35#include <linux/types.h>
36#include <linux/kernel.h>
37#include <linux/mm.h>
38#include <linux/string.h>
39#include <linux/errno.h>
40#include <linux/init.h>
41#include <linux/kmod.h>
42#include <linux/slab.h>
43#include <linux/smp_lock.h>
44#include <asm/uaccess.h>
45#include <asm/system.h>
46
47#define __OLD_VIDIOC_ /* To allow fixing old calls*/
48#include <linux/videodev2.h>
49
50#ifdef CONFIG_VIDEO_V4L1
51#include <linux/videodev.h>
52#endif
53#include <media/v4l2-common.h>
54#include <linux/video_decoder.h>
55
56#define VIDEO_NUM_DEVICES 256
57#define VIDEO_NAME "video4linux"
58
59struct std_descr {
60 v4l2_std_id std;
61 const char *descr;
62};
63
64static const struct std_descr standards[] = {
65 { V4L2_STD_NTSC, "NTSC" },
66 { V4L2_STD_NTSC_M, "NTSC-M" },
67 { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" },
68 { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" },
69 { V4L2_STD_NTSC_443, "NTSC-443" },
70 { V4L2_STD_PAL, "PAL" },
71 { V4L2_STD_PAL_BG, "PAL-BG" },
72 { V4L2_STD_PAL_B, "PAL-B" },
73 { V4L2_STD_PAL_B1, "PAL-B1" },
74 { V4L2_STD_PAL_G, "PAL-G" },
75 { V4L2_STD_PAL_H, "PAL-H" },
76 { V4L2_STD_PAL_I, "PAL-I" },
77 { V4L2_STD_PAL_DK, "PAL-DK" },
78 { V4L2_STD_PAL_D, "PAL-D" },
79 { V4L2_STD_PAL_D1, "PAL-D1" },
80 { V4L2_STD_PAL_K, "PAL-K" },
81 { V4L2_STD_PAL_M, "PAL-M" },
82 { V4L2_STD_PAL_N, "PAL-N" },
83 { V4L2_STD_PAL_Nc, "PAL-Nc" },
84 { V4L2_STD_PAL_60, "PAL-60" },
85 { V4L2_STD_SECAM, "SECAM" },
86 { V4L2_STD_SECAM_B, "SECAM-B" },
87 { V4L2_STD_SECAM_G, "SECAM-G" },
88 { V4L2_STD_SECAM_H, "SECAM-H" },
89 { V4L2_STD_SECAM_DK, "SECAM-DK" },
90 { V4L2_STD_SECAM_D, "SECAM-D" },
91 { V4L2_STD_SECAM_K, "SECAM-K" },
92 { V4L2_STD_SECAM_K1, "SECAM-K1" },
93 { V4L2_STD_SECAM_L, "SECAM-L" },
94 { V4L2_STD_SECAM_LC, "SECAM-Lc" },
95 { 0, "Unknown" }
96};
97
98/* video4linux standard ID conversion to standard name
99 */
100const char *v4l2_norm_to_name(v4l2_std_id id)
101{
102 u32 myid = id;
103 int i;
104
105 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
106 64 bit comparations. So, on that architecture, with some gcc
107 variants, compilation fails. Currently, the max value is 30bit wide.
108 */
109 BUG_ON(myid != id);
110
111 for (i = 0; standards[i].std; i++)
112 if (myid == standards[i].std)
113 break;
114 return standards[i].descr;
115}
116EXPORT_SYMBOL(v4l2_norm_to_name);
117
118/* Fill in the fields of a v4l2_standard structure according to the
119 'id' and 'transmission' parameters. Returns negative on error. */
120int v4l2_video_std_construct(struct v4l2_standard *vs,
121 int id, const char *name)
122{
123 u32 index = vs->index;
124
125 memset(vs, 0, sizeof(struct v4l2_standard));
126 vs->index = index;
127 vs->id = id;
128 if (id & V4L2_STD_525_60) {
129 vs->frameperiod.numerator = 1001;
130 vs->frameperiod.denominator = 30000;
131 vs->framelines = 525;
132 } else {
133 vs->frameperiod.numerator = 1;
134 vs->frameperiod.denominator = 25;
135 vs->framelines = 625;
136 }
137 strlcpy(vs->name, name, sizeof(vs->name));
138 return 0;
139}
140EXPORT_SYMBOL(v4l2_video_std_construct);
141
142/* ----------------------------------------------------------------- */
143/* some arrays for pretty-printing debug messages of enum types */
144
145const char *v4l2_field_names[] = {
146 [V4L2_FIELD_ANY] = "any",
147 [V4L2_FIELD_NONE] = "none",
148 [V4L2_FIELD_TOP] = "top",
149 [V4L2_FIELD_BOTTOM] = "bottom",
150 [V4L2_FIELD_INTERLACED] = "interlaced",
151 [V4L2_FIELD_SEQ_TB] = "seq-tb",
152 [V4L2_FIELD_SEQ_BT] = "seq-bt",
153 [V4L2_FIELD_ALTERNATE] = "alternate",
154 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
155 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
156};
157EXPORT_SYMBOL(v4l2_field_names);
158
159const char *v4l2_type_names[] = {
160 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "vid-cap",
161 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "vid-overlay",
162 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "vid-out",
163 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
164 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
165 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
166 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
167 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
168};
169EXPORT_SYMBOL(v4l2_type_names);
170
171static const char *v4l2_memory_names[] = {
172 [V4L2_MEMORY_MMAP] = "mmap",
173 [V4L2_MEMORY_USERPTR] = "userptr",
174 [V4L2_MEMORY_OVERLAY] = "overlay",
175};
176
177#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
178 arr[a] : "unknown")
179
180/* ------------------------------------------------------------------ */
181/* debug help functions */
182
183#ifdef CONFIG_VIDEO_V4L1_COMPAT
184static const char *v4l1_ioctls[] = {
185 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
186 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
187 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
188 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
189 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
190 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
191 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
192 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
193 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
194 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
195 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
196 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
197 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
198 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
199 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
200 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
201 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
202 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
203 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
204 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
205 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
206 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
207 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
208 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
209 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
210 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
211 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
212 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
213 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
214};
215#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
216#endif
217
218static const char *v4l2_ioctls[] = {
219 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
220 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
221 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
222 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
223 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
224 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
225 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
226 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
227 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
228 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
229 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
230 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
231 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
232 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
233 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
234 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
235 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
236 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
237 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
238 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
239 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
240 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
241 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
242 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
243 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
244 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
245 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
246 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
247 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
248 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
249 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
250 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
251 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
252 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
253 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
254 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
255 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
256 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
257 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
258 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
259 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
260 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
261 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
262 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
263 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
264 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
265 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
266 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
267 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
268 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
269 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
270 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
271 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
272 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
273 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
274#if 1
275 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
276 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
277 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
278 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
279 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
280
281 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
282 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
283
284 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
285 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
286#endif
287};
288#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
289
290static const char *v4l2_int_ioctls[] = {
291#ifdef CONFIG_VIDEO_V4L1_COMPAT
292 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
293 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
294 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
295 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
296 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
297 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
298 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
299 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
300 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
301 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
302 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
303#endif
304 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
305
306 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
307 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
308 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
309
310 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
311 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
312 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
313 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
314 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
315 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
316 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
317 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
318 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
319 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
320 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
321 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
322 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
323 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
324 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
325 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
326};
327#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
328
329/* Common ioctl debug function. This function can be used by
330 external ioctl messages as well as internal V4L ioctl */
331void v4l_printk_ioctl(unsigned int cmd)
332{
333 char *dir, *type;
334
335 switch (_IOC_TYPE(cmd)) {
336 case 'd':
337 if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) {
338 type = "v4l2_int";
339 break;
340 }
341 printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]);
342 return;
343#ifdef CONFIG_VIDEO_V4L1_COMPAT
344 case 'v':
345 if (_IOC_NR(cmd) >= V4L1_IOCTLS) {
346 type = "v4l1";
347 break;
348 }
349 printk("%s", v4l1_ioctls[_IOC_NR(cmd)]);
350 return;
351#endif
352 case 'V':
353 if (_IOC_NR(cmd) >= V4L2_IOCTLS) {
354 type = "v4l2";
355 break;
356 }
357 printk("%s", v4l2_ioctls[_IOC_NR(cmd)]);
358 return;
359 default:
360 type = "unknown";
361 }
362
363 switch (_IOC_DIR(cmd)) {
364 case _IOC_NONE: dir = "--"; break;
365 case _IOC_READ: dir = "r-"; break;
366 case _IOC_WRITE: dir = "-w"; break;
367 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
368 default: dir = "*ERR*"; break;
369 }
370 printk("%s ioctl '%c', dir=%s, #%d (0x%08x)",
371 type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
372}
373EXPORT_SYMBOL(v4l_printk_ioctl);
374
375/*
376 * sysfs stuff
377 */
378
379static ssize_t show_index(struct device *cd,
380 struct device_attribute *attr, char *buf)
381{
382 struct video_device *vfd = container_of(cd, struct video_device,
383 class_dev);
384 return sprintf(buf, "%i\n", vfd->index);
385}
386
387static ssize_t show_name(struct device *cd,
388 struct device_attribute *attr, char *buf)
389{
390 struct video_device *vfd = container_of(cd, struct video_device,
391 class_dev);
392 return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
393}
394
395static struct device_attribute video_device_attrs[] = {
396 __ATTR(name, S_IRUGO, show_name, NULL),
397 __ATTR(index, S_IRUGO, show_index, NULL),
398 __ATTR_NULL
399};
400
401struct video_device *video_device_alloc(void)
402{
403 struct video_device *vfd;
404
405 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
406 return vfd;
407}
408EXPORT_SYMBOL(video_device_alloc);
409
410void video_device_release(struct video_device *vfd)
411{
412 kfree(vfd);
413}
414EXPORT_SYMBOL(video_device_release);
415
416static void video_release(struct device *cd)
417{
418 struct video_device *vfd = container_of(cd, struct video_device,
419 class_dev);
420
421#if 1
422 /* needed until all drivers are fixed */
423 if (!vfd->release)
424 return;
425#endif
426 vfd->release(vfd);
427}
428
429static struct class video_class = {
430 .name = VIDEO_NAME,
431 .dev_attrs = video_device_attrs,
432 .dev_release = video_release,
433};
434
435/*
436 * Active devices
437 */
438
439static struct video_device *video_device[VIDEO_NUM_DEVICES];
440static DEFINE_MUTEX(videodev_lock);
441
442struct video_device* video_devdata(struct file *file)
443{
444 return video_device[iminor(file->f_path.dentry->d_inode)];
445}
446EXPORT_SYMBOL(video_devdata);
447
448/*
449 * Open a video device - FIXME: Obsoleted
450 */
451static int video_open(struct inode *inode, struct file *file)
452{
453 unsigned int minor = iminor(inode);
454 int err = 0;
455 struct video_device *vfl;
456 const struct file_operations *old_fops;
457
458 if(minor>=VIDEO_NUM_DEVICES)
459 return -ENODEV;
460 lock_kernel();
461 mutex_lock(&videodev_lock);
462 vfl=video_device[minor];
463 if(vfl==NULL) {
464 mutex_unlock(&videodev_lock);
465 request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
466 mutex_lock(&videodev_lock);
467 vfl=video_device[minor];
468 if (vfl==NULL) {
469 mutex_unlock(&videodev_lock);
470 unlock_kernel();
471 return -ENODEV;
472 }
473 }
474 old_fops = file->f_op;
475 file->f_op = fops_get(vfl->fops);
476 if(file->f_op->open)
477 err = file->f_op->open(inode,file);
478 if (err) {
479 fops_put(file->f_op);
480 file->f_op = fops_get(old_fops);
481 }
482 fops_put(old_fops);
483 mutex_unlock(&videodev_lock);
484 unlock_kernel();
485 return err;
486}
487
488/*
489 * helper function -- handles userspace copying for ioctl arguments
490 */
491
492#ifdef __OLD_VIDIOC_
493static unsigned int
494video_fix_command(unsigned int cmd)
495{
496 switch (cmd) {
497 case VIDIOC_OVERLAY_OLD:
498 cmd = VIDIOC_OVERLAY;
499 break;
500 case VIDIOC_S_PARM_OLD:
501 cmd = VIDIOC_S_PARM;
502 break;
503 case VIDIOC_S_CTRL_OLD:
504 cmd = VIDIOC_S_CTRL;
505 break;
506 case VIDIOC_G_AUDIO_OLD:
507 cmd = VIDIOC_G_AUDIO;
508 break;
509 case VIDIOC_G_AUDOUT_OLD:
510 cmd = VIDIOC_G_AUDOUT;
511 break;
512 case VIDIOC_CROPCAP_OLD:
513 cmd = VIDIOC_CROPCAP;
514 break;
515 }
516 return cmd;
517}
518#endif
519
520/*
521 * Obsolete usercopy function - Should be removed soon
522 */
523int
524video_usercopy(struct inode *inode, struct file *file,
525 unsigned int cmd, unsigned long arg,
526 int (*func)(struct inode *inode, struct file *file,
527 unsigned int cmd, void *arg))
528{
529 char sbuf[128];
530 void *mbuf = NULL;
531 void *parg = NULL;
532 int err = -EINVAL;
533 int is_ext_ctrl;
534 size_t ctrls_size = 0;
535 void __user *user_ptr = NULL;
536
537#ifdef __OLD_VIDIOC_
538 cmd = video_fix_command(cmd);
539#endif
540 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
541 cmd == VIDIOC_TRY_EXT_CTRLS);
542
543 /* Copy arguments into temp kernel buffer */
544 switch (_IOC_DIR(cmd)) {
545 case _IOC_NONE:
546 parg = NULL;
547 break;
548 case _IOC_READ:
549 case _IOC_WRITE:
550 case (_IOC_WRITE | _IOC_READ):
551 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
552 parg = sbuf;
553 } else {
554 /* too big to allocate from stack */
555 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
556 if (NULL == mbuf)
557 return -ENOMEM;
558 parg = mbuf;
559 }
560
561 err = -EFAULT;
562 if (_IOC_DIR(cmd) & _IOC_WRITE)
563 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
564 goto out;
565 break;
566 }
567 if (is_ext_ctrl) {
568 struct v4l2_ext_controls *p = parg;
569
570 /* In case of an error, tell the caller that it wasn't
571 a specific control that caused it. */
572 p->error_idx = p->count;
573 user_ptr = (void __user *)p->controls;
574 if (p->count) {
575 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
576 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
577 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
578 err = -ENOMEM;
579 if (NULL == mbuf)
580 goto out_ext_ctrl;
581 err = -EFAULT;
582 if (copy_from_user(mbuf, user_ptr, ctrls_size))
583 goto out_ext_ctrl;
584 p->controls = mbuf;
585 }
586 }
587
588 /* call driver */
589 err = func(inode, file, cmd, parg);
590 if (err == -ENOIOCTLCMD)
591 err = -EINVAL;
592 if (is_ext_ctrl) {
593 struct v4l2_ext_controls *p = parg;
594
595 p->controls = (void *)user_ptr;
596 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
597 err = -EFAULT;
598 goto out_ext_ctrl;
599 }
600 if (err < 0)
601 goto out;
602
603out_ext_ctrl:
604 /* Copy results into user buffer */
605 switch (_IOC_DIR(cmd))
606 {
607 case _IOC_READ:
608 case (_IOC_WRITE | _IOC_READ):
609 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
610 err = -EFAULT;
611 break;
612 }
613
614out:
615 kfree(mbuf);
616 return err;
617}
618EXPORT_SYMBOL(video_usercopy);
619
620/*
621 * open/release helper functions -- handle exclusive opens
622 * Should be removed soon
623 */
624int video_exclusive_open(struct inode *inode, struct file *file)
625{
626 struct video_device *vfl = video_devdata(file);
627 int retval = 0;
628
629 mutex_lock(&vfl->lock);
630 if (vfl->users) {
631 retval = -EBUSY;
632 } else {
633 vfl->users++;
634 }
635 mutex_unlock(&vfl->lock);
636 return retval;
637}
638EXPORT_SYMBOL(video_exclusive_open);
639
640int video_exclusive_release(struct inode *inode, struct file *file)
641{
642 struct video_device *vfl = video_devdata(file);
643
644 vfl->users--;
645 return 0;
646}
647EXPORT_SYMBOL(video_exclusive_release);
648
649static void dbgbuf(unsigned int cmd, struct video_device *vfd,
650 struct v4l2_buffer *p)
651{
652 struct v4l2_timecode *tc=&p->timecode;
653
654 dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
655 "bytesused=%d, flags=0x%08d, "
656 "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n",
657 (p->timestamp.tv_sec/3600),
658 (int)(p->timestamp.tv_sec/60)%60,
659 (int)(p->timestamp.tv_sec%60),
660 p->timestamp.tv_usec,
661 p->index,
662 prt_names(p->type, v4l2_type_names),
663 p->bytesused, p->flags,
664 p->field, p->sequence,
665 prt_names(p->memory, v4l2_memory_names),
666 p->m.userptr, p->length);
667 dbgarg2("timecode=%02d:%02d:%02d type=%d, "
668 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
669 tc->hours,tc->minutes,tc->seconds,
670 tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits);
671}
672
673static inline void dbgrect(struct video_device *vfd, char *s,
674 struct v4l2_rect *r)
675{
676 dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top,
677 r->width, r->height);
678};
679
680static inline void v4l_print_pix_fmt (struct video_device *vfd,
681 struct v4l2_pix_format *fmt)
682{
683 dbgarg2 ("width=%d, height=%d, format=%c%c%c%c, field=%s, "
684 "bytesperline=%d sizeimage=%d, colorspace=%d\n",
685 fmt->width,fmt->height,
686 (fmt->pixelformat & 0xff),
687 (fmt->pixelformat >> 8) & 0xff,
688 (fmt->pixelformat >> 16) & 0xff,
689 (fmt->pixelformat >> 24) & 0xff,
690 prt_names(fmt->field, v4l2_field_names),
691 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
692};
693
694static inline void v4l_print_ext_ctrls(unsigned int cmd,
695 struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals)
696{
697 __u32 i;
698
699 if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG))
700 return;
701 dbgarg(cmd, "");
702 printk(KERN_CONT "class=0x%x", c->ctrl_class);
703 for (i = 0; i < c->count; i++) {
704 if (show_vals)
705 printk(KERN_CONT " id/val=0x%x/0x%x",
706 c->controls[i].id, c->controls[i].value);
707 else
708 printk(KERN_CONT " id=0x%x", c->controls[i].id);
709 }
710 printk(KERN_CONT "\n");
711};
712
713static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
714{
715 __u32 i;
716
717 /* zero the reserved fields */
718 c->reserved[0] = c->reserved[1] = 0;
719 for (i = 0; i < c->count; i++) {
720 c->controls[i].reserved2[0] = 0;
721 c->controls[i].reserved2[1] = 0;
722 }
723 /* V4L2_CID_PRIVATE_BASE cannot be used as control class
724 when using extended controls.
725 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
726 is it allowed for backwards compatibility.
727 */
728 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)
729 return 0;
730 /* Check that all controls are from the same control class. */
731 for (i = 0; i < c->count; i++) {
732 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) {
733 c->error_idx = i;
734 return 0;
735 }
736 }
737 return 1;
738}
739
740static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type)
741{
742 switch (type) {
743 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
744 if (vfd->vidioc_try_fmt_vid_cap)
745 return (0);
746 break;
747 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
748 if (vfd->vidioc_try_fmt_vid_overlay)
749 return (0);
750 break;
751 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
752 if (vfd->vidioc_try_fmt_vid_out)
753 return (0);
754 break;
755 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
756 if (vfd->vidioc_try_fmt_vid_out_overlay)
757 return (0);
758 break;
759 case V4L2_BUF_TYPE_VBI_CAPTURE:
760 if (vfd->vidioc_try_fmt_vbi_cap)
761 return (0);
762 break;
763 case V4L2_BUF_TYPE_VBI_OUTPUT:
764 if (vfd->vidioc_try_fmt_vbi_out)
765 return (0);
766 break;
767 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
768 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
769 return (0);
770 break;
771 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
772 if (vfd->vidioc_try_fmt_sliced_vbi_out)
773 return (0);
774 break;
775 case V4L2_BUF_TYPE_PRIVATE:
776 if (vfd->vidioc_try_fmt_type_private)
777 return (0);
778 break;
779 }
780 return (-EINVAL);
781}
782
783static int __video_do_ioctl(struct inode *inode, struct file *file,
784 unsigned int cmd, void *arg)
785{
786 struct video_device *vfd = video_devdata(file);
787 void *fh = file->private_data;
788 int ret = -EINVAL;
789
790 if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
791 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
792 v4l_print_ioctl(vfd->name, cmd);
793 printk("\n");
794 }
795
796#ifdef CONFIG_VIDEO_V4L1_COMPAT
797 /***********************************************************
798 Handles calls to the obsoleted V4L1 API
799 Due to the nature of VIDIOCGMBUF, each driver that supports
800 V4L1 should implement its own handler for this ioctl.
801 ***********************************************************/
802
803 /* --- streaming capture ------------------------------------- */
804 if (cmd == VIDIOCGMBUF) {
805 struct video_mbuf *p=arg;
806
807 memset(p, 0, sizeof(*p));
808
809 if (!vfd->vidiocgmbuf)
810 return ret;
811 ret=vfd->vidiocgmbuf(file, fh, p);
812 if (!ret)
813 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
814 p->size, p->frames,
815 (unsigned long)p->offsets);
816 return ret;
817 }
818
819 /********************************************************
820 All other V4L1 calls are handled by v4l1_compat module.
821 Those calls will be translated into V4L2 calls, and
822 __video_do_ioctl will be called again, with one or more
823 V4L2 ioctls.
824 ********************************************************/
825 if (_IOC_TYPE(cmd)=='v')
826 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
827 __video_do_ioctl);
828#endif
829
830 switch(cmd) {
831 /* --- capabilities ------------------------------------------ */
832 case VIDIOC_QUERYCAP:
833 {
834 struct v4l2_capability *cap = (struct v4l2_capability*)arg;
835 memset(cap, 0, sizeof(*cap));
836
837 if (!vfd->vidioc_querycap)
838 break;
839
840 ret=vfd->vidioc_querycap(file, fh, cap);
841 if (!ret)
842 dbgarg (cmd, "driver=%s, card=%s, bus=%s, "
843 "version=0x%08x, "
844 "capabilities=0x%08x\n",
845 cap->driver,cap->card,cap->bus_info,
846 cap->version,
847 cap->capabilities);
848 break;
849 }
850
851 /* --- priority ------------------------------------------ */
852 case VIDIOC_G_PRIORITY:
853 {
854 enum v4l2_priority *p=arg;
855
856 if (!vfd->vidioc_g_priority)
857 break;
858 ret=vfd->vidioc_g_priority(file, fh, p);
859 if (!ret)
860 dbgarg(cmd, "priority is %d\n", *p);
861 break;
862 }
863 case VIDIOC_S_PRIORITY:
864 {
865 enum v4l2_priority *p=arg;
866
867 if (!vfd->vidioc_s_priority)
868 break;
869 dbgarg(cmd, "setting priority to %d\n", *p);
870 ret=vfd->vidioc_s_priority(file, fh, *p);
871 break;
872 }
873
874 /* --- capture ioctls ---------------------------------------- */
875 case VIDIOC_ENUM_FMT:
876 {
877 struct v4l2_fmtdesc *f = arg;
878 enum v4l2_buf_type type;
879 unsigned int index;
880
881 index = f->index;
882 type = f->type;
883 memset(f,0,sizeof(*f));
884 f->index = index;
885 f->type = type;
886
887 switch (type) {
888 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
889 if (vfd->vidioc_enum_fmt_vid_cap)
890 ret = vfd->vidioc_enum_fmt_vid_cap(file, fh, f);
891 break;
892 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
893 if (vfd->vidioc_enum_fmt_vid_overlay)
894 ret = vfd->vidioc_enum_fmt_vid_overlay(file,
895 fh, f);
896 break;
897#if 1
898 /* V4L2_BUF_TYPE_VBI_CAPTURE should not support VIDIOC_ENUM_FMT
899 * according to the spec. The bttv and saa7134 drivers support
900 * it though, so just warn that this is deprecated and will be
901 * removed in the near future. */
902 case V4L2_BUF_TYPE_VBI_CAPTURE:
903 if (vfd->vidioc_enum_fmt_vbi_cap) {
904 printk(KERN_WARNING "vidioc_enum_fmt_vbi_cap will be removed in 2.6.28!\n");
905 ret = vfd->vidioc_enum_fmt_vbi_cap(file, fh, f);
906 }
907 break;
908#endif
909 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
910 if (vfd->vidioc_enum_fmt_vid_out)
911 ret = vfd->vidioc_enum_fmt_vid_out(file, fh, f);
912 break;
913 case V4L2_BUF_TYPE_PRIVATE:
914 if (vfd->vidioc_enum_fmt_type_private)
915 ret = vfd->vidioc_enum_fmt_type_private(file,
916 fh, f);
917 break;
918 default:
919 break;
920 }
921 if (!ret)
922 dbgarg (cmd, "index=%d, type=%d, flags=%d, "
923 "pixelformat=%c%c%c%c, description='%s'\n",
924 f->index, f->type, f->flags,
925 (f->pixelformat & 0xff),
926 (f->pixelformat >> 8) & 0xff,
927 (f->pixelformat >> 16) & 0xff,
928 (f->pixelformat >> 24) & 0xff,
929 f->description);
930 break;
931 }
932 case VIDIOC_G_FMT:
933 {
934 struct v4l2_format *f = (struct v4l2_format *)arg;
935
936 memset(f->fmt.raw_data, 0, sizeof(f->fmt.raw_data));
937
938 /* FIXME: Should be one dump per type */
939 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
940
941 switch (f->type) {
942 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
943 if (vfd->vidioc_g_fmt_vid_cap)
944 ret = vfd->vidioc_g_fmt_vid_cap(file, fh, f);
945 if (!ret)
946 v4l_print_pix_fmt(vfd, &f->fmt.pix);
947 break;
948 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
949 if (vfd->vidioc_g_fmt_vid_overlay)
950 ret = vfd->vidioc_g_fmt_vid_overlay(file,
951 fh, f);
952 break;
953 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
954 if (vfd->vidioc_g_fmt_vid_out)
955 ret = vfd->vidioc_g_fmt_vid_out(file, fh, f);
956 if (!ret)
957 v4l_print_pix_fmt(vfd, &f->fmt.pix);
958 break;
959 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
960 if (vfd->vidioc_g_fmt_vid_out_overlay)
961 ret = vfd->vidioc_g_fmt_vid_out_overlay(file,
962 fh, f);
963 break;
964 case V4L2_BUF_TYPE_VBI_CAPTURE:
965 if (vfd->vidioc_g_fmt_vbi_cap)
966 ret = vfd->vidioc_g_fmt_vbi_cap(file, fh, f);
967 break;
968 case V4L2_BUF_TYPE_VBI_OUTPUT:
969 if (vfd->vidioc_g_fmt_vbi_out)
970 ret = vfd->vidioc_g_fmt_vbi_out(file, fh, f);
971 break;
972 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
973 if (vfd->vidioc_g_fmt_sliced_vbi_cap)
974 ret = vfd->vidioc_g_fmt_sliced_vbi_cap(file,
975 fh, f);
976 break;
977 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
978 if (vfd->vidioc_g_fmt_sliced_vbi_out)
979 ret = vfd->vidioc_g_fmt_sliced_vbi_out(file,
980 fh, f);
981 break;
982 case V4L2_BUF_TYPE_PRIVATE:
983 if (vfd->vidioc_g_fmt_type_private)
984 ret = vfd->vidioc_g_fmt_type_private(file,
985 fh, f);
986 break;
987 }
988
989 break;
990 }
991 case VIDIOC_S_FMT:
992 {
993 struct v4l2_format *f = (struct v4l2_format *)arg;
994
995 /* FIXME: Should be one dump per type */
996 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
997
998 switch (f->type) {
999 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1000 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1001 if (vfd->vidioc_s_fmt_vid_cap)
1002 ret = vfd->vidioc_s_fmt_vid_cap(file, fh, f);
1003 break;
1004 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
1005 if (vfd->vidioc_s_fmt_vid_overlay)
1006 ret = vfd->vidioc_s_fmt_vid_overlay(file,
1007 fh, f);
1008 break;
1009 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1010 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1011 if (vfd->vidioc_s_fmt_vid_out)
1012 ret = vfd->vidioc_s_fmt_vid_out(file, fh, f);
1013 break;
1014 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
1015 if (vfd->vidioc_s_fmt_vid_out_overlay)
1016 ret = vfd->vidioc_s_fmt_vid_out_overlay(file,
1017 fh, f);
1018 break;
1019 case V4L2_BUF_TYPE_VBI_CAPTURE:
1020 if (vfd->vidioc_s_fmt_vbi_cap)
1021 ret = vfd->vidioc_s_fmt_vbi_cap(file, fh, f);
1022 break;
1023 case V4L2_BUF_TYPE_VBI_OUTPUT:
1024 if (vfd->vidioc_s_fmt_vbi_out)
1025 ret = vfd->vidioc_s_fmt_vbi_out(file, fh, f);
1026 break;
1027 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
1028 if (vfd->vidioc_s_fmt_sliced_vbi_cap)
1029 ret = vfd->vidioc_s_fmt_sliced_vbi_cap(file,
1030 fh, f);
1031 break;
1032 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
1033 if (vfd->vidioc_s_fmt_sliced_vbi_out)
1034 ret = vfd->vidioc_s_fmt_sliced_vbi_out(file,
1035 fh, f);
1036 break;
1037 case V4L2_BUF_TYPE_PRIVATE:
1038 if (vfd->vidioc_s_fmt_type_private)
1039 ret = vfd->vidioc_s_fmt_type_private(file,
1040 fh, f);
1041 break;
1042 }
1043 break;
1044 }
1045 case VIDIOC_TRY_FMT:
1046 {
1047 struct v4l2_format *f = (struct v4l2_format *)arg;
1048
1049 /* FIXME: Should be one dump per type */
1050 dbgarg (cmd, "type=%s\n", prt_names(f->type,
1051 v4l2_type_names));
1052 switch (f->type) {
1053 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1054 if (vfd->vidioc_try_fmt_vid_cap)
1055 ret = vfd->vidioc_try_fmt_vid_cap(file, fh, f);
1056 if (!ret)
1057 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1058 break;
1059 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
1060 if (vfd->vidioc_try_fmt_vid_overlay)
1061 ret = vfd->vidioc_try_fmt_vid_overlay(file,
1062 fh, f);
1063 break;
1064 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1065 if (vfd->vidioc_try_fmt_vid_out)
1066 ret = vfd->vidioc_try_fmt_vid_out(file, fh, f);
1067 if (!ret)
1068 v4l_print_pix_fmt(vfd, &f->fmt.pix);
1069 break;
1070 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
1071 if (vfd->vidioc_try_fmt_vid_out_overlay)
1072 ret = vfd->vidioc_try_fmt_vid_out_overlay(file,
1073 fh, f);
1074 break;
1075 case V4L2_BUF_TYPE_VBI_CAPTURE:
1076 if (vfd->vidioc_try_fmt_vbi_cap)
1077 ret = vfd->vidioc_try_fmt_vbi_cap(file, fh, f);
1078 break;
1079 case V4L2_BUF_TYPE_VBI_OUTPUT:
1080 if (vfd->vidioc_try_fmt_vbi_out)
1081 ret = vfd->vidioc_try_fmt_vbi_out(file, fh, f);
1082 break;
1083 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
1084 if (vfd->vidioc_try_fmt_sliced_vbi_cap)
1085 ret = vfd->vidioc_try_fmt_sliced_vbi_cap(file,
1086 fh, f);
1087 break;
1088 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
1089 if (vfd->vidioc_try_fmt_sliced_vbi_out)
1090 ret = vfd->vidioc_try_fmt_sliced_vbi_out(file,
1091 fh, f);
1092 break;
1093 case V4L2_BUF_TYPE_PRIVATE:
1094 if (vfd->vidioc_try_fmt_type_private)
1095 ret = vfd->vidioc_try_fmt_type_private(file,
1096 fh, f);
1097 break;
1098 }
1099
1100 break;
1101 }
1102 /* FIXME: Those buf reqs could be handled here,
1103 with some changes on videobuf to allow its header to be included at
1104 videodev2.h or being merged at videodev2.
1105 */
1106 case VIDIOC_REQBUFS:
1107 {
1108 struct v4l2_requestbuffers *p=arg;
1109
1110 if (!vfd->vidioc_reqbufs)
1111 break;
1112 ret = check_fmt (vfd, p->type);
1113 if (ret)
1114 break;
1115
1116 ret=vfd->vidioc_reqbufs(file, fh, p);
1117 dbgarg (cmd, "count=%d, type=%s, memory=%s\n",
1118 p->count,
1119 prt_names(p->type, v4l2_type_names),
1120 prt_names(p->memory, v4l2_memory_names));
1121 break;
1122 }
1123 case VIDIOC_QUERYBUF:
1124 {
1125 struct v4l2_buffer *p=arg;
1126
1127 if (!vfd->vidioc_querybuf)
1128 break;
1129 ret = check_fmt (vfd, p->type);
1130 if (ret)
1131 break;
1132
1133 ret=vfd->vidioc_querybuf(file, fh, p);
1134 if (!ret)
1135 dbgbuf(cmd,vfd,p);
1136 break;
1137 }
1138 case VIDIOC_QBUF:
1139 {
1140 struct v4l2_buffer *p=arg;
1141
1142 if (!vfd->vidioc_qbuf)
1143 break;
1144 ret = check_fmt (vfd, p->type);
1145 if (ret)
1146 break;
1147
1148 ret=vfd->vidioc_qbuf(file, fh, p);
1149 if (!ret)
1150 dbgbuf(cmd,vfd,p);
1151 break;
1152 }
1153 case VIDIOC_DQBUF:
1154 {
1155 struct v4l2_buffer *p=arg;
1156 if (!vfd->vidioc_dqbuf)
1157 break;
1158 ret = check_fmt (vfd, p->type);
1159 if (ret)
1160 break;
1161
1162 ret=vfd->vidioc_dqbuf(file, fh, p);
1163 if (!ret)
1164 dbgbuf(cmd,vfd,p);
1165 break;
1166 }
1167 case VIDIOC_OVERLAY:
1168 {
1169 int *i = arg;
1170
1171 if (!vfd->vidioc_overlay)
1172 break;
1173 dbgarg (cmd, "value=%d\n",*i);
1174 ret=vfd->vidioc_overlay(file, fh, *i);
1175 break;
1176 }
1177 case VIDIOC_G_FBUF:
1178 {
1179 struct v4l2_framebuffer *p = arg;
1180
1181 if (!vfd->vidioc_g_fbuf)
1182 break;
1183 ret = vfd->vidioc_g_fbuf(file, fh, arg);
1184 if (!ret) {
1185 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1186 p->capability, p->flags,
1187 (unsigned long)p->base);
1188 v4l_print_pix_fmt(vfd, &p->fmt);
1189 }
1190 break;
1191 }
1192 case VIDIOC_S_FBUF:
1193 {
1194 struct v4l2_framebuffer *p = arg;
1195
1196 if (!vfd->vidioc_s_fbuf)
1197 break;
1198 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
1199 p->capability, p->flags, (unsigned long)p->base);
1200 v4l_print_pix_fmt(vfd, &p->fmt);
1201 ret = vfd->vidioc_s_fbuf(file, fh, arg);
1202 break;
1203 }
1204 case VIDIOC_STREAMON:
1205 {
1206 enum v4l2_buf_type i = *(int *)arg;
1207 if (!vfd->vidioc_streamon)
1208 break;
1209 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1210 ret=vfd->vidioc_streamon(file, fh,i);
1211 break;
1212 }
1213 case VIDIOC_STREAMOFF:
1214 {
1215 enum v4l2_buf_type i = *(int *)arg;
1216
1217 if (!vfd->vidioc_streamoff)
1218 break;
1219 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1220 ret=vfd->vidioc_streamoff(file, fh, i);
1221 break;
1222 }
1223 /* ---------- tv norms ---------- */
1224 case VIDIOC_ENUMSTD:
1225 {
1226 struct v4l2_standard *p = arg;
1227 v4l2_std_id id = vfd->tvnorms, curr_id = 0;
1228 unsigned int index = p->index, i, j = 0;
1229 const char *descr = "";
1230
1231 /* Return norm array in a canonical way */
1232 for (i = 0; i <= index && id; i++) {
1233 /* last std value in the standards array is 0, so this
1234 while always ends there since (id & 0) == 0. */
1235 while ((id & standards[j].std) != standards[j].std)
1236 j++;
1237 curr_id = standards[j].std;
1238 descr = standards[j].descr;
1239 j++;
1240 if (curr_id == 0)
1241 break;
1242 if (curr_id != V4L2_STD_PAL &&
1243 curr_id != V4L2_STD_SECAM &&
1244 curr_id != V4L2_STD_NTSC)
1245 id &= ~curr_id;
1246 }
1247 if (i <= index)
1248 return -EINVAL;
1249
1250 v4l2_video_std_construct(p, curr_id, descr);
1251 p->index = index;
1252
1253 dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, "
1254 "framelines=%d\n", p->index,
1255 (unsigned long long)p->id, p->name,
1256 p->frameperiod.numerator,
1257 p->frameperiod.denominator,
1258 p->framelines);
1259
1260 ret = 0;
1261 break;
1262 }
1263 case VIDIOC_G_STD:
1264 {
1265 v4l2_std_id *id = arg;
1266
1267 ret = 0;
1268 /* Calls the specific handler */
1269 if (vfd->vidioc_g_std)
1270 ret = vfd->vidioc_g_std(file, fh, id);
1271 else
1272 *id = vfd->current_norm;
1273
1274 if (!ret)
1275 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
1276 break;
1277 }
1278 case VIDIOC_S_STD:
1279 {
1280 v4l2_std_id *id = arg,norm;
1281
1282 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1283
1284 norm = (*id) & vfd->tvnorms;
1285 if ( vfd->tvnorms && !norm) /* Check if std is supported */
1286 break;
1287
1288 /* Calls the specific handler */
1289 if (vfd->vidioc_s_std)
1290 ret=vfd->vidioc_s_std(file, fh, &norm);
1291 else
1292 ret=-EINVAL;
1293
1294 /* Updates standard information */
1295 if (ret>=0)
1296 vfd->current_norm=norm;
1297
1298 break;
1299 }
1300 case VIDIOC_QUERYSTD:
1301 {
1302 v4l2_std_id *p=arg;
1303
1304 if (!vfd->vidioc_querystd)
1305 break;
1306 ret=vfd->vidioc_querystd(file, fh, arg);
1307 if (!ret)
1308 dbgarg (cmd, "detected std=%08Lx\n",
1309 (unsigned long long)*p);
1310 break;
1311 }
1312 /* ------ input switching ---------- */
1313 /* FIXME: Inputs can be handled inside videodev2 */
1314 case VIDIOC_ENUMINPUT:
1315 {
1316 struct v4l2_input *p=arg;
1317 int i=p->index;
1318
1319 if (!vfd->vidioc_enum_input)
1320 break;
1321 memset(p, 0, sizeof(*p));
1322 p->index=i;
1323
1324 ret=vfd->vidioc_enum_input(file, fh, p);
1325 if (!ret)
1326 dbgarg (cmd, "index=%d, name=%s, type=%d, "
1327 "audioset=%d, "
1328 "tuner=%d, std=%08Lx, status=%d\n",
1329 p->index,p->name,p->type,p->audioset,
1330 p->tuner,
1331 (unsigned long long)p->std,
1332 p->status);
1333 break;
1334 }
1335 case VIDIOC_G_INPUT:
1336 {
1337 unsigned int *i = arg;
1338
1339 if (!vfd->vidioc_g_input)
1340 break;
1341 ret=vfd->vidioc_g_input(file, fh, i);
1342 if (!ret)
1343 dbgarg (cmd, "value=%d\n",*i);
1344 break;
1345 }
1346 case VIDIOC_S_INPUT:
1347 {
1348 unsigned int *i = arg;
1349
1350 if (!vfd->vidioc_s_input)
1351 break;
1352 dbgarg (cmd, "value=%d\n",*i);
1353 ret=vfd->vidioc_s_input(file, fh, *i);
1354 break;
1355 }
1356
1357 /* ------ output switching ---------- */
1358 case VIDIOC_ENUMOUTPUT:
1359 {
1360 struct v4l2_output *p = arg;
1361 int i = p->index;
1362
1363 if (!vfd->vidioc_enum_output)
1364 break;
1365 memset(p, 0, sizeof(*p));
1366 p->index = i;
1367
1368 ret = vfd->vidioc_enum_output(file, fh, p);
1369 if (!ret)
1370 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1371 "audioset=0x%x, "
1372 "modulator=%d, std=0x%08Lx\n",
1373 p->index, p->name, p->type, p->audioset,
1374 p->modulator, (unsigned long long)p->std);
1375 break;
1376 }
1377 case VIDIOC_G_OUTPUT:
1378 {
1379 unsigned int *i = arg;
1380
1381 if (!vfd->vidioc_g_output)
1382 break;
1383 ret=vfd->vidioc_g_output(file, fh, i);
1384 if (!ret)
1385 dbgarg (cmd, "value=%d\n",*i);
1386 break;
1387 }
1388 case VIDIOC_S_OUTPUT:
1389 {
1390 unsigned int *i = arg;
1391
1392 if (!vfd->vidioc_s_output)
1393 break;
1394 dbgarg (cmd, "value=%d\n",*i);
1395 ret=vfd->vidioc_s_output(file, fh, *i);
1396 break;
1397 }
1398
1399 /* --- controls ---------------------------------------------- */
1400 case VIDIOC_QUERYCTRL:
1401 {
1402 struct v4l2_queryctrl *p = arg;
1403
1404 if (!vfd->vidioc_queryctrl)
1405 break;
1406 ret = vfd->vidioc_queryctrl(file, fh, p);
1407 if (!ret)
1408 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
1409 "step=%d, default=%d, flags=0x%08x\n",
1410 p->id, p->type, p->name,
1411 p->minimum, p->maximum,
1412 p->step, p->default_value, p->flags);
1413 else
1414 dbgarg(cmd, "id=0x%x\n", p->id);
1415 break;
1416 }
1417 case VIDIOC_G_CTRL:
1418 {
1419 struct v4l2_control *p = arg;
1420
1421 if (vfd->vidioc_g_ctrl)
1422 ret = vfd->vidioc_g_ctrl(file, fh, p);
1423 else if (vfd->vidioc_g_ext_ctrls) {
1424 struct v4l2_ext_controls ctrls;
1425 struct v4l2_ext_control ctrl;
1426
1427 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1428 ctrls.count = 1;
1429 ctrls.controls = &ctrl;
1430 ctrl.id = p->id;
1431 ctrl.value = p->value;
1432 if (check_ext_ctrls(&ctrls, 1)) {
1433 ret = vfd->vidioc_g_ext_ctrls(file, fh, &ctrls);
1434 if (ret == 0)
1435 p->value = ctrl.value;
1436 }
1437 } else
1438 break;
1439 if (!ret)
1440 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1441 else
1442 dbgarg(cmd, "id=0x%x\n", p->id);
1443 break;
1444 }
1445 case VIDIOC_S_CTRL:
1446 {
1447 struct v4l2_control *p = arg;
1448 struct v4l2_ext_controls ctrls;
1449 struct v4l2_ext_control ctrl;
1450
1451 if (!vfd->vidioc_s_ctrl && !vfd->vidioc_s_ext_ctrls)
1452 break;
1453
1454 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1455
1456 if (vfd->vidioc_s_ctrl) {
1457 ret = vfd->vidioc_s_ctrl(file, fh, p);
1458 break;
1459 }
1460 if (!vfd->vidioc_s_ext_ctrls)
1461 break;
1462
1463 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1464 ctrls.count = 1;
1465 ctrls.controls = &ctrl;
1466 ctrl.id = p->id;
1467 ctrl.value = p->value;
1468 if (check_ext_ctrls(&ctrls, 1))
1469 ret = vfd->vidioc_s_ext_ctrls(file, fh, &ctrls);
1470 break;
1471 }
1472 case VIDIOC_G_EXT_CTRLS:
1473 {
1474 struct v4l2_ext_controls *p = arg;
1475
1476 p->error_idx = p->count;
1477 if (!vfd->vidioc_g_ext_ctrls)
1478 break;
1479 if (check_ext_ctrls(p, 0))
1480 ret = vfd->vidioc_g_ext_ctrls(file, fh, p);
1481 v4l_print_ext_ctrls(cmd, vfd, p, !ret);
1482 break;
1483 }
1484 case VIDIOC_S_EXT_CTRLS:
1485 {
1486 struct v4l2_ext_controls *p = arg;
1487
1488 p->error_idx = p->count;
1489 if (!vfd->vidioc_s_ext_ctrls)
1490 break;
1491 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1492 if (check_ext_ctrls(p, 0))
1493 ret = vfd->vidioc_s_ext_ctrls(file, fh, p);
1494 break;
1495 }
1496 case VIDIOC_TRY_EXT_CTRLS:
1497 {
1498 struct v4l2_ext_controls *p = arg;
1499
1500 p->error_idx = p->count;
1501 if (!vfd->vidioc_try_ext_ctrls)
1502 break;
1503 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1504 if (check_ext_ctrls(p, 0))
1505 ret = vfd->vidioc_try_ext_ctrls(file, fh, p);
1506 break;
1507 }
1508 case VIDIOC_QUERYMENU:
1509 {
1510 struct v4l2_querymenu *p = arg;
1511
1512 if (!vfd->vidioc_querymenu)
1513 break;
1514 ret = vfd->vidioc_querymenu(file, fh, p);
1515 if (!ret)
1516 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n",
1517 p->id, p->index, p->name);
1518 else
1519 dbgarg(cmd, "id=0x%x, index=%d\n",
1520 p->id, p->index);
1521 break;
1522 }
1523 /* --- audio ---------------------------------------------- */
1524 case VIDIOC_ENUMAUDIO:
1525 {
1526 struct v4l2_audio *p = arg;
1527
1528 if (!vfd->vidioc_enumaudio)
1529 break;
1530 ret = vfd->vidioc_enumaudio(file, fh, p);
1531 if (!ret)
1532 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1533 "mode=0x%x\n", p->index, p->name,
1534 p->capability, p->mode);
1535 else
1536 dbgarg(cmd, "index=%d\n", p->index);
1537 break;
1538 }
1539 case VIDIOC_G_AUDIO:
1540 {
1541 struct v4l2_audio *p = arg;
1542 __u32 index = p->index;
1543
1544 if (!vfd->vidioc_g_audio)
1545 break;
1546
1547 memset(p, 0, sizeof(*p));
1548 p->index = index;
1549 ret = vfd->vidioc_g_audio(file, fh, p);
1550 if (!ret)
1551 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1552 "mode=0x%x\n", p->index,
1553 p->name, p->capability, p->mode);
1554 else
1555 dbgarg(cmd, "index=%d\n", p->index);
1556 break;
1557 }
1558 case VIDIOC_S_AUDIO:
1559 {
1560 struct v4l2_audio *p = arg;
1561
1562 if (!vfd->vidioc_s_audio)
1563 break;
1564 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1565 "mode=0x%x\n", p->index, p->name,
1566 p->capability, p->mode);
1567 ret = vfd->vidioc_s_audio(file, fh, p);
1568 break;
1569 }
1570 case VIDIOC_ENUMAUDOUT:
1571 {
1572 struct v4l2_audioout *p=arg;
1573
1574 if (!vfd->vidioc_enumaudout)
1575 break;
1576 dbgarg(cmd, "Enum for index=%d\n", p->index);
1577 ret=vfd->vidioc_enumaudout(file, fh, p);
1578 if (!ret)
1579 dbgarg2("index=%d, name=%s, capability=%d, "
1580 "mode=%d\n", p->index, p->name,
1581 p->capability,p->mode);
1582 break;
1583 }
1584 case VIDIOC_G_AUDOUT:
1585 {
1586 struct v4l2_audioout *p=arg;
1587
1588 if (!vfd->vidioc_g_audout)
1589 break;
1590 dbgarg(cmd, "Enum for index=%d\n", p->index);
1591 ret=vfd->vidioc_g_audout(file, fh, p);
1592 if (!ret)
1593 dbgarg2("index=%d, name=%s, capability=%d, "
1594 "mode=%d\n", p->index, p->name,
1595 p->capability,p->mode);
1596 break;
1597 }
1598 case VIDIOC_S_AUDOUT:
1599 {
1600 struct v4l2_audioout *p=arg;
1601
1602 if (!vfd->vidioc_s_audout)
1603 break;
1604 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1605 "mode=%d\n", p->index, p->name,
1606 p->capability,p->mode);
1607
1608 ret=vfd->vidioc_s_audout(file, fh, p);
1609 break;
1610 }
1611 case VIDIOC_G_MODULATOR:
1612 {
1613 struct v4l2_modulator *p=arg;
1614 if (!vfd->vidioc_g_modulator)
1615 break;
1616 ret=vfd->vidioc_g_modulator(file, fh, p);
1617 if (!ret)
1618 dbgarg(cmd, "index=%d, name=%s, "
1619 "capability=%d, rangelow=%d,"
1620 " rangehigh=%d, txsubchans=%d\n",
1621 p->index, p->name,p->capability,
1622 p->rangelow, p->rangehigh,
1623 p->txsubchans);
1624 break;
1625 }
1626 case VIDIOC_S_MODULATOR:
1627 {
1628 struct v4l2_modulator *p=arg;
1629 if (!vfd->vidioc_s_modulator)
1630 break;
1631 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1632 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1633 p->index, p->name,p->capability,p->rangelow,
1634 p->rangehigh,p->txsubchans);
1635 ret=vfd->vidioc_s_modulator(file, fh, p);
1636 break;
1637 }
1638 case VIDIOC_G_CROP:
1639 {
1640 struct v4l2_crop *p=arg;
1641 if (!vfd->vidioc_g_crop)
1642 break;
1643 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1644 ret=vfd->vidioc_g_crop(file, fh, p);
1645 if (!ret) {
1646 dbgrect(vfd, "", &p->c);
1647 }
1648 break;
1649 }
1650 case VIDIOC_S_CROP:
1651 {
1652 struct v4l2_crop *p=arg;
1653 if (!vfd->vidioc_s_crop)
1654 break;
1655 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1656 dbgrect(vfd, "", &p->c);
1657 ret=vfd->vidioc_s_crop(file, fh, p);
1658 break;
1659 }
1660 case VIDIOC_CROPCAP:
1661 {
1662 struct v4l2_cropcap *p = arg;
1663
1664 /*FIXME: Should also show v4l2_fract pixelaspect */
1665 if (!vfd->vidioc_cropcap)
1666 break;
1667 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1668 ret = vfd->vidioc_cropcap(file, fh, p);
1669 if (!ret) {
1670 dbgrect(vfd, "bounds ", &p->bounds);
1671 dbgrect(vfd, "defrect ", &p->defrect);
1672 }
1673 break;
1674 }
1675 case VIDIOC_G_JPEGCOMP:
1676 {
1677 struct v4l2_jpegcompression *p=arg;
1678 if (!vfd->vidioc_g_jpegcomp)
1679 break;
1680 ret=vfd->vidioc_g_jpegcomp(file, fh, p);
1681 if (!ret)
1682 dbgarg (cmd, "quality=%d, APPn=%d, "
1683 "APP_len=%d, COM_len=%d, "
1684 "jpeg_markers=%d\n",
1685 p->quality,p->APPn,p->APP_len,
1686 p->COM_len,p->jpeg_markers);
1687 break;
1688 }
1689 case VIDIOC_S_JPEGCOMP:
1690 {
1691 struct v4l2_jpegcompression *p=arg;
1692 if (!vfd->vidioc_g_jpegcomp)
1693 break;
1694 dbgarg (cmd, "quality=%d, APPn=%d, APP_len=%d, "
1695 "COM_len=%d, jpeg_markers=%d\n",
1696 p->quality,p->APPn,p->APP_len,
1697 p->COM_len,p->jpeg_markers);
1698 ret=vfd->vidioc_s_jpegcomp(file, fh, p);
1699 break;
1700 }
1701 case VIDIOC_G_ENC_INDEX:
1702 {
1703 struct v4l2_enc_idx *p=arg;
1704
1705 if (!vfd->vidioc_g_enc_index)
1706 break;
1707 ret=vfd->vidioc_g_enc_index(file, fh, p);
1708 if (!ret)
1709 dbgarg (cmd, "entries=%d, entries_cap=%d\n",
1710 p->entries,p->entries_cap);
1711 break;
1712 }
1713 case VIDIOC_ENCODER_CMD:
1714 {
1715 struct v4l2_encoder_cmd *p = arg;
1716
1717 if (!vfd->vidioc_encoder_cmd)
1718 break;
1719 memset(&p->raw, 0, sizeof(p->raw));
1720 ret = vfd->vidioc_encoder_cmd(file, fh, p);
1721 if (!ret)
1722 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1723 break;
1724 }
1725 case VIDIOC_TRY_ENCODER_CMD:
1726 {
1727 struct v4l2_encoder_cmd *p = arg;
1728
1729 if (!vfd->vidioc_try_encoder_cmd)
1730 break;
1731 memset(&p->raw, 0, sizeof(p->raw));
1732 ret = vfd->vidioc_try_encoder_cmd(file, fh, p);
1733 if (!ret)
1734 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
1735 break;
1736 }
1737 case VIDIOC_G_PARM:
1738 {
1739 struct v4l2_streamparm *p=arg;
1740 __u32 type=p->type;
1741
1742 memset(p,0,sizeof(*p));
1743 p->type=type;
1744
1745 if (vfd->vidioc_g_parm) {
1746 ret=vfd->vidioc_g_parm(file, fh, p);
1747 } else {
1748 struct v4l2_standard s;
1749
1750 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1751 return -EINVAL;
1752
1753 v4l2_video_std_construct(&s, vfd->current_norm,
1754 v4l2_norm_to_name(vfd->current_norm));
1755
1756 p->parm.capture.timeperframe = s.frameperiod;
1757 ret=0;
1758 }
1759
1760 dbgarg (cmd, "type=%d\n", p->type);
1761 break;
1762 }
1763 case VIDIOC_S_PARM:
1764 {
1765 struct v4l2_streamparm *p=arg;
1766 if (!vfd->vidioc_s_parm)
1767 break;
1768 dbgarg (cmd, "type=%d\n", p->type);
1769 ret=vfd->vidioc_s_parm(file, fh, p);
1770 break;
1771 }
1772 case VIDIOC_G_TUNER:
1773 {
1774 struct v4l2_tuner *p = arg;
1775 __u32 index = p->index;
1776
1777 if (!vfd->vidioc_g_tuner)
1778 break;
1779
1780 memset(p, 0, sizeof(*p));
1781 p->index = index;
1782
1783 ret = vfd->vidioc_g_tuner(file, fh, p);
1784 if (!ret)
1785 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1786 "capability=0x%x, rangelow=%d, "
1787 "rangehigh=%d, signal=%d, afc=%d, "
1788 "rxsubchans=0x%x, audmode=%d\n",
1789 p->index, p->name, p->type,
1790 p->capability, p->rangelow,
1791 p->rangehigh, p->signal, p->afc,
1792 p->rxsubchans, p->audmode);
1793 break;
1794 }
1795 case VIDIOC_S_TUNER:
1796 {
1797 struct v4l2_tuner *p = arg;
1798
1799 if (!vfd->vidioc_s_tuner)
1800 break;
1801 dbgarg(cmd, "index=%d, name=%s, type=%d, "
1802 "capability=0x%x, rangelow=%d, "
1803 "rangehigh=%d, signal=%d, afc=%d, "
1804 "rxsubchans=0x%x, audmode=%d\n",
1805 p->index, p->name, p->type,
1806 p->capability, p->rangelow,
1807 p->rangehigh, p->signal, p->afc,
1808 p->rxsubchans, p->audmode);
1809 ret = vfd->vidioc_s_tuner(file, fh, p);
1810 break;
1811 }
1812 case VIDIOC_G_FREQUENCY:
1813 {
1814 struct v4l2_frequency *p = arg;
1815
1816 if (!vfd->vidioc_g_frequency)
1817 break;
1818
1819 memset(p->reserved, 0, sizeof(p->reserved));
1820
1821 ret = vfd->vidioc_g_frequency(file, fh, p);
1822 if (!ret)
1823 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
1824 p->tuner, p->type, p->frequency);
1825 break;
1826 }
1827 case VIDIOC_S_FREQUENCY:
1828 {
1829 struct v4l2_frequency *p=arg;
1830 if (!vfd->vidioc_s_frequency)
1831 break;
1832 dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n",
1833 p->tuner,p->type,p->frequency);
1834 ret=vfd->vidioc_s_frequency(file, fh, p);
1835 break;
1836 }
1837 case VIDIOC_G_SLICED_VBI_CAP:
1838 {
1839 struct v4l2_sliced_vbi_cap *p = arg;
1840 __u32 type = p->type;
1841
1842 if (!vfd->vidioc_g_sliced_vbi_cap)
1843 break;
1844 memset(p, 0, sizeof(*p));
1845 p->type = type;
1846 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1847 ret = vfd->vidioc_g_sliced_vbi_cap(file, fh, p);
1848 if (!ret)
1849 dbgarg2("service_set=%d\n", p->service_set);
1850 break;
1851 }
1852 case VIDIOC_LOG_STATUS:
1853 {
1854 if (!vfd->vidioc_log_status)
1855 break;
1856 ret=vfd->vidioc_log_status(file, fh);
1857 break;
1858 }
1859#ifdef CONFIG_VIDEO_ADV_DEBUG
1860 case VIDIOC_DBG_G_REGISTER:
1861 {
1862 struct v4l2_register *p=arg;
1863 if (!capable(CAP_SYS_ADMIN))
1864 ret=-EPERM;
1865 else if (vfd->vidioc_g_register)
1866 ret=vfd->vidioc_g_register(file, fh, p);
1867 break;
1868 }
1869 case VIDIOC_DBG_S_REGISTER:
1870 {
1871 struct v4l2_register *p=arg;
1872 if (!capable(CAP_SYS_ADMIN))
1873 ret=-EPERM;
1874 else if (vfd->vidioc_s_register)
1875 ret=vfd->vidioc_s_register(file, fh, p);
1876 break;
1877 }
1878#endif
1879 case VIDIOC_G_CHIP_IDENT:
1880 {
1881 struct v4l2_chip_ident *p=arg;
1882 if (!vfd->vidioc_g_chip_ident)
1883 break;
1884 ret=vfd->vidioc_g_chip_ident(file, fh, p);
1885 if (!ret)
1886 dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1887 break;
1888 }
1889 default:
1890 {
1891 if (!vfd->vidioc_default)
1892 break;
1893 ret = vfd->vidioc_default(file, fh, cmd, arg);
1894 break;
1895 }
1896 case VIDIOC_S_HW_FREQ_SEEK:
1897 {
1898 struct v4l2_hw_freq_seek *p = arg;
1899 if (!vfd->vidioc_s_hw_freq_seek)
1900 break;
1901 dbgarg(cmd,
1902 "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n",
1903 p->tuner, p->type, p->seek_upward, p->wrap_around);
1904 ret = vfd->vidioc_s_hw_freq_seek(file, fh, p);
1905 break;
1906 }
1907 } /* switch */
1908
1909 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
1910 if (ret < 0) {
1911 v4l_print_ioctl(vfd->name, cmd);
1912 printk(KERN_CONT " error %d\n", ret);
1913 }
1914 }
1915
1916 return ret;
1917}
1918
1919int video_ioctl2 (struct inode *inode, struct file *file,
1920 unsigned int cmd, unsigned long arg)
1921{
1922 char sbuf[128];
1923 void *mbuf = NULL;
1924 void *parg = NULL;
1925 int err = -EINVAL;
1926 int is_ext_ctrl;
1927 size_t ctrls_size = 0;
1928 void __user *user_ptr = NULL;
1929
1930#ifdef __OLD_VIDIOC_
1931 cmd = video_fix_command(cmd);
1932#endif
1933 is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
1934 cmd == VIDIOC_TRY_EXT_CTRLS);
1935
1936 /* Copy arguments into temp kernel buffer */
1937 switch (_IOC_DIR(cmd)) {
1938 case _IOC_NONE:
1939 parg = NULL;
1940 break;
1941 case _IOC_READ:
1942 case _IOC_WRITE:
1943 case (_IOC_WRITE | _IOC_READ):
1944 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
1945 parg = sbuf;
1946 } else {
1947 /* too big to allocate from stack */
1948 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
1949 if (NULL == mbuf)
1950 return -ENOMEM;
1951 parg = mbuf;
1952 }
1953
1954 err = -EFAULT;
1955 if (_IOC_DIR(cmd) & _IOC_WRITE)
1956 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
1957 goto out;
1958 break;
1959 }
1960
1961 if (is_ext_ctrl) {
1962 struct v4l2_ext_controls *p = parg;
1963
1964 /* In case of an error, tell the caller that it wasn't
1965 a specific control that caused it. */
1966 p->error_idx = p->count;
1967 user_ptr = (void __user *)p->controls;
1968 if (p->count) {
1969 ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
1970 /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
1971 mbuf = kmalloc(ctrls_size, GFP_KERNEL);
1972 err = -ENOMEM;
1973 if (NULL == mbuf)
1974 goto out_ext_ctrl;
1975 err = -EFAULT;
1976 if (copy_from_user(mbuf, user_ptr, ctrls_size))
1977 goto out_ext_ctrl;
1978 p->controls = mbuf;
1979 }
1980 }
1981
1982 /* Handles IOCTL */
1983 err = __video_do_ioctl(inode, file, cmd, parg);
1984 if (err == -ENOIOCTLCMD)
1985 err = -EINVAL;
1986 if (is_ext_ctrl) {
1987 struct v4l2_ext_controls *p = parg;
1988
1989 p->controls = (void *)user_ptr;
1990 if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
1991 err = -EFAULT;
1992 goto out_ext_ctrl;
1993 }
1994 if (err < 0)
1995 goto out;
1996
1997out_ext_ctrl:
1998 /* Copy results into user buffer */
1999 switch (_IOC_DIR(cmd))
2000 {
2001 case _IOC_READ:
2002 case (_IOC_WRITE | _IOC_READ):
2003 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
2004 err = -EFAULT;
2005 break;
2006 }
2007
2008out:
2009 kfree(mbuf);
2010 return err;
2011}
2012EXPORT_SYMBOL(video_ioctl2);
2013
2014/**
2015 * get_index - assign stream number based on parent device
2016 * @vdev: video_device to assign index number to, vdev->dev should be assigned
2017 * @num: -1 if auto assign, requested number otherwise
2018 *
2019 *
2020 * returns -ENFILE if num is already in use, a free index number if
2021 * successful.
2022 */
2023static int get_index(struct video_device *vdev, int num)
2024{
2025 u32 used = 0;
2026 const int max_index = sizeof(used) * 8 - 1;
2027 int i;
2028
2029 /* Currently a single v4l driver instance cannot create more than
2030 32 devices.
2031 Increase to u64 or an array of u32 if more are needed. */
2032 if (num > max_index) {
2033 printk(KERN_ERR "videodev: %s num is too large\n", __func__);
2034 return -EINVAL;
2035 }
2036
2037 for (i = 0; i < VIDEO_NUM_DEVICES; i++) {
2038 if (video_device[i] != NULL &&
2039 video_device[i] != vdev &&
2040 video_device[i]->dev == vdev->dev) {
2041 used |= 1 << video_device[i]->index;
2042 }
2043 }
2044
2045 if (num >= 0) {
2046 if (used & (1 << num))
2047 return -ENFILE;
2048 return num;
2049 }
2050
2051 i = ffz(used);
2052 return i > max_index ? -ENFILE : i;
2053}
2054
2055static const struct file_operations video_fops;
2056
2057int video_register_device(struct video_device *vfd, int type, int nr)
2058{
2059 return video_register_device_index(vfd, type, nr, -1);
2060}
2061EXPORT_SYMBOL(video_register_device);
2062
2063/**
2064 * video_register_device - register video4linux devices
2065 * @vfd: video device structure we want to register
2066 * @type: type of device to register
2067 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
2068 * -1 == first free)
2069 *
2070 * The registration code assigns minor numbers based on the type
2071 * requested. -ENFILE is returned in all the device slots for this
2072 * category are full. If not then the minor field is set and the
2073 * driver initialize function is called (if non %NULL).
2074 *
2075 * Zero is returned on success.
2076 *
2077 * Valid types are
2078 *
2079 * %VFL_TYPE_GRABBER - A frame grabber
2080 *
2081 * %VFL_TYPE_VTX - A teletext device
2082 *
2083 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
2084 *
2085 * %VFL_TYPE_RADIO - A radio card
2086 */
2087
2088int video_register_device_index(struct video_device *vfd, int type, int nr,
2089 int index)
2090{
2091 int i=0;
2092 int base;
2093 int end;
2094 int ret;
2095 char *name_base;
2096
2097 switch(type)
2098 {
2099 case VFL_TYPE_GRABBER:
2100 base=MINOR_VFL_TYPE_GRABBER_MIN;
2101 end=MINOR_VFL_TYPE_GRABBER_MAX+1;
2102 name_base = "video";
2103 break;
2104 case VFL_TYPE_VTX:
2105 base=MINOR_VFL_TYPE_VTX_MIN;
2106 end=MINOR_VFL_TYPE_VTX_MAX+1;
2107 name_base = "vtx";
2108 break;
2109 case VFL_TYPE_VBI:
2110 base=MINOR_VFL_TYPE_VBI_MIN;
2111 end=MINOR_VFL_TYPE_VBI_MAX+1;
2112 name_base = "vbi";
2113 break;
2114 case VFL_TYPE_RADIO:
2115 base=MINOR_VFL_TYPE_RADIO_MIN;
2116 end=MINOR_VFL_TYPE_RADIO_MAX+1;
2117 name_base = "radio";
2118 break;
2119 default:
2120 printk(KERN_ERR "%s called with unknown type: %d\n",
2121 __func__, type);
2122 return -1;
2123 }
2124
2125 /* pick a minor number */
2126 mutex_lock(&videodev_lock);
2127 if (nr >= 0 && nr < end-base) {
2128 /* use the one the driver asked for */
2129 i = base+nr;
2130 if (NULL != video_device[i]) {
2131 mutex_unlock(&videodev_lock);
2132 return -ENFILE;
2133 }
2134 } else {
2135 /* use first free */
2136 for(i=base;i<end;i++)
2137 if (NULL == video_device[i])
2138 break;
2139 if (i == end) {
2140 mutex_unlock(&videodev_lock);
2141 return -ENFILE;
2142 }
2143 }
2144 video_device[i]=vfd;
2145 vfd->minor=i;
2146
2147 ret = get_index(vfd, index);
2148 vfd->index = ret;
2149
2150 mutex_unlock(&videodev_lock);
2151
2152 if (ret < 0) {
2153 printk(KERN_ERR "%s: get_index failed\n", __func__);
2154 goto fail_minor;
2155 }
2156
2157 mutex_init(&vfd->lock);
2158
2159 /* sysfs class */
2160 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
2161 vfd->class_dev.class = &video_class;
2162 vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
2163 if (vfd->dev)
2164 vfd->class_dev.parent = vfd->dev;
2165 sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
2166 ret = device_register(&vfd->class_dev);
2167 if (ret < 0) {
2168 printk(KERN_ERR "%s: device_register failed\n", __func__);
2169 goto fail_minor;
2170 }
2171
2172#if 1
2173 /* needed until all drivers are fixed */
2174 if (!vfd->release)
2175 printk(KERN_WARNING "videodev: \"%s\" has no release callback. "
2176 "Please fix your driver for proper sysfs support, see "
2177 "http://lwn.net/Articles/36850/\n", vfd->name);
2178#endif
2179 return 0;
2180
2181fail_minor:
2182 mutex_lock(&videodev_lock);
2183 video_device[vfd->minor] = NULL;
2184 vfd->minor = -1;
2185 mutex_unlock(&videodev_lock);
2186 return ret;
2187}
2188EXPORT_SYMBOL(video_register_device_index);
2189
2190/**
2191 * video_unregister_device - unregister a video4linux device
2192 * @vfd: the device to unregister
2193 *
2194 * This unregisters the passed device and deassigns the minor
2195 * number. Future open calls will be met with errors.
2196 */
2197
2198void video_unregister_device(struct video_device *vfd)
2199{
2200 mutex_lock(&videodev_lock);
2201 if(video_device[vfd->minor]!=vfd)
2202 panic("videodev: bad unregister");
2203
2204 video_device[vfd->minor]=NULL;
2205 device_unregister(&vfd->class_dev);
2206 mutex_unlock(&videodev_lock);
2207}
2208EXPORT_SYMBOL(video_unregister_device);
2209
2210/*
2211 * Video fs operations
2212 */
2213static const struct file_operations video_fops=
2214{
2215 .owner = THIS_MODULE,
2216 .llseek = no_llseek,
2217 .open = video_open,
2218};
2219
2220/*
2221 * Initialise video for linux
2222 */
2223
2224static int __init videodev_init(void)
2225{
2226 int ret;
2227
2228 printk(KERN_INFO "Linux video capture interface: v2.00\n");
2229 if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) {
2230 printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR);
2231 return -EIO;
2232 }
2233
2234 ret = class_register(&video_class);
2235 if (ret < 0) {
2236 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
2237 printk(KERN_WARNING "video_dev: class_register failed\n");
2238 return -EIO;
2239 }
2240
2241 return 0;
2242}
2243
2244static void __exit videodev_exit(void)
2245{
2246 class_unregister(&video_class);
2247 unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
2248}
2249
2250module_init(videodev_init)
2251module_exit(videodev_exit)
2252
2253MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
2254MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
2255MODULE_LICENSE("GPL");
2256
2257
2258/*
2259 * Local variables:
2260 * c-basic-offset: 8
2261 * End:
2262 */
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 01ea99c9bc1a..3989b0eded28 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -38,7 +38,7 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-algo-sgi.h> 39#include <linux/i2c-algo-sgi.h>
40 40
41#include <linux/videodev.h> 41#include <linux/videodev2.h>
42#include <media/v4l2-common.h> 42#include <media/v4l2-common.h>
43#include <linux/video_decoder.h> 43#include <linux/video_decoder.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
@@ -4385,8 +4385,6 @@ static const struct file_operations vino_fops = {
4385 4385
4386static struct video_device v4l_device_template = { 4386static struct video_device v4l_device_template = {
4387 .name = "NOT SET", 4387 .name = "NOT SET",
4388 /*.type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE | */
4389 /* VID_TYPE_CLIPPING | VID_TYPE_SCALES, VID_TYPE_OVERLAY */
4390 .fops = &vino_fops, 4388 .fops = &vino_fops,
4391 .minor = -1, 4389 .minor = -1,
4392}; 4390};
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 059b01c11dc1..3518af071a2e 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <media/videobuf-vmalloc.h> 36#include <media/videobuf-vmalloc.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38#include <linux/kthread.h> 39#include <linux/kthread.h>
39#include <linux/highmem.h> 40#include <linux/highmem.h>
40#include <linux/freezer.h> 41#include <linux/freezer.h>
@@ -1065,13 +1066,7 @@ static const struct file_operations vivi_fops = {
1065 .llseek = no_llseek, 1066 .llseek = no_llseek,
1066}; 1067};
1067 1068
1068static struct video_device vivi_template = { 1069static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
1069 .name = "vivi",
1070 .type = VID_TYPE_CAPTURE,
1071 .fops = &vivi_fops,
1072 .minor = -1,
1073 .release = video_device_release,
1074
1075 .vidioc_querycap = vidioc_querycap, 1070 .vidioc_querycap = vidioc_querycap,
1076 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1071 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1077 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1072 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1093,6 +1088,15 @@ static struct video_device vivi_template = {
1093#ifdef CONFIG_VIDEO_V4L1_COMPAT 1088#ifdef CONFIG_VIDEO_V4L1_COMPAT
1094 .vidiocgmbuf = vidiocgmbuf, 1089 .vidiocgmbuf = vidiocgmbuf,
1095#endif 1090#endif
1091};
1092
1093static struct video_device vivi_template = {
1094 .name = "vivi",
1095 .fops = &vivi_fops,
1096 .ioctl_ops = &vivi_ioctl_ops,
1097 .minor = -1,
1098 .release = video_device_release,
1099
1096 .tvnorms = V4L2_STD_525_60, 1100 .tvnorms = V4L2_STD_525_60,
1097 .current_norm = V4L2_STD_NTSC_M, 1101 .current_norm = V4L2_STD_NTSC_M,
1098}; 1102};
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c
index cbecb3cbbbaa..577956c5410b 100644
--- a/drivers/media/video/vp27smpx.c
+++ b/drivers/media/video/vp27smpx.c
@@ -27,7 +27,7 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-id.h> 29#include <linux/i2c-id.h>
30#include <linux/videodev.h> 30#include <linux/videodev2.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32#include <media/v4l2-chip-ident.h> 32#include <media/v4l2-chip-ident.h>
33#include <media/v4l2-i2c-drv.h> 33#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 33f702698a56..9402f40095b4 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -57,8 +57,9 @@
57#include <linux/module.h> 57#include <linux/module.h>
58#include <linux/init.h> 58#include <linux/init.h>
59#include <linux/delay.h> 59#include <linux/delay.h>
60#include <linux/videodev.h> 60#include <linux/videodev2.h>
61#include <media/v4l2-common.h> 61#include <media/v4l2-common.h>
62#include <media/v4l2-ioctl.h>
62#include <linux/parport.h> 63#include <linux/parport.h>
63 64
64/*#define DEBUG*/ /* Undef me for production */ 65/*#define DEBUG*/ /* Undef me for production */
@@ -195,9 +196,7 @@ static const struct file_operations w9966_fops = {
195 .llseek = no_llseek, 196 .llseek = no_llseek,
196}; 197};
197static struct video_device w9966_template = { 198static struct video_device w9966_template = {
198 .owner = THIS_MODULE,
199 .name = W9966_DRIVERNAME, 199 .name = W9966_DRIVERNAME,
200 .type = VID_TYPE_CAPTURE | VID_TYPE_SCALES,
201 .fops = &w9966_fops, 200 .fops = &w9966_fops,
202}; 201};
203 202
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 840522442d07..168baabe4659 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -42,6 +42,7 @@
42#include <asm/page.h> 42#include <asm/page.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <linux/page-flags.h> 44#include <linux/page-flags.h>
45#include <media/v4l2-ioctl.h>
45 46
46#include "w9968cf.h" 47#include "w9968cf.h"
47#include "w9968cf_decoder.h" 48#include "w9968cf_decoder.h"
@@ -3549,13 +3550,11 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3549 } 3550 }
3550 3551
3551 strcpy(cam->v4ldev->name, symbolic(camlist, mod_id)); 3552 strcpy(cam->v4ldev->name, symbolic(camlist, mod_id));
3552 cam->v4ldev->owner = THIS_MODULE;
3553 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
3554 cam->v4ldev->fops = &w9968cf_fops; 3553 cam->v4ldev->fops = &w9968cf_fops;
3555 cam->v4ldev->minor = video_nr[dev_nr]; 3554 cam->v4ldev->minor = video_nr[dev_nr];
3556 cam->v4ldev->release = video_device_release; 3555 cam->v4ldev->release = video_device_release;
3557 video_set_drvdata(cam->v4ldev, cam); 3556 video_set_drvdata(cam->v4ldev, cam);
3558 cam->v4ldev->dev = &cam->dev; 3557 cam->v4ldev->parent = &cam->dev;
3559 3558
3560 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 3559 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
3561 video_nr[dev_nr]); 3560 video_nr[dev_nr]);
diff --git a/drivers/media/video/w9968cf.h b/drivers/media/video/w9968cf.h
index 3c95316bc030..30032e15e23c 100644
--- a/drivers/media/video/w9968cf.h
+++ b/drivers/media/video/w9968cf.h
@@ -21,7 +21,7 @@
21#ifndef _W9968CF_H_ 21#ifndef _W9968CF_H_
22#define _W9968CF_H_ 22#define _W9968CF_H_
23 23
24#include <linux/videodev.h> 24#include <linux/videodev2.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/device.h> 27#include <linux/device.h>
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 7be47a255853..95c79ad80487 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -27,7 +27,7 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-id.h> 29#include <linux/i2c-id.h>
30#include <linux/videodev.h> 30#include <linux/videodev2.h>
31#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
32#include <media/v4l2-chip-ident.h> 32#include <media/v4l2-chip-ident.h>
33#include <media/v4l2-i2c-drv.h> 33#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index c2ab70a04a74..48df661d4fc3 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -31,7 +31,7 @@
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-id.h> 33#include <linux/i2c-id.h>
34#include <linux/videodev.h> 34#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-chip-ident.h> 36#include <media/v4l2-chip-ident.h>
37#include <media/v4l2-i2c-drv-legacy.h> 37#include <media/v4l2-i2c-drv-legacy.h>
diff --git a/drivers/media/video/zc0301/zc0301.h b/drivers/media/video/zc0301/zc0301.h
index 7bbab541a309..b1b5cceb4baa 100644
--- a/drivers/media/video/zc0301/zc0301.h
+++ b/drivers/media/video/zc0301/zc0301.h
@@ -25,6 +25,7 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/list.h> 30#include <linux/list.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index e5c4e9f5193f..550ce7bd5c87 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -1985,8 +1985,6 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
1985 } 1985 }
1986 1986
1987 strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera"); 1987 strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera");
1988 cam->v4ldev->owner = THIS_MODULE;
1989 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
1990 cam->v4ldev->fops = &zc0301_fops; 1988 cam->v4ldev->fops = &zc0301_fops;
1991 cam->v4ldev->minor = video_nr[dev_nr]; 1989 cam->v4ldev->minor = video_nr[dev_nr];
1992 cam->v4ldev->release = video_device_release; 1990 cam->v4ldev->release = video_device_release;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 0929edb2d4f1..d842a7cb99d2 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -161,7 +161,7 @@ static struct pci_device_id zr36067_pci_tbl[] = {
161MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 161MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
162 162
163int zoran_num; /* number of Buzs in use */ 163int zoran_num; /* number of Buzs in use */
164struct zoran zoran[BUZ_MAX]; 164struct zoran *zoran[BUZ_MAX];
165 165
166/* videocodec bus functions ZR36060 */ 166/* videocodec bus functions ZR36060 */
167static u32 167static u32
@@ -355,9 +355,15 @@ i2cid_to_modulename (u16 i2c_id)
355 case I2C_DRIVERID_BT856: 355 case I2C_DRIVERID_BT856:
356 name = "bt856"; 356 name = "bt856";
357 break; 357 break;
358 case I2C_DRIVERID_BT866:
359 name = "bt866";
360 break;
358 case I2C_DRIVERID_VPX3220: 361 case I2C_DRIVERID_VPX3220:
359 name = "vpx3220"; 362 name = "vpx3220";
360 break; 363 break;
364 case I2C_DRIVERID_KS0127:
365 name = "ks0127";
366 break;
361 } 367 }
362 368
363 return name; 369 return name;
@@ -1164,7 +1170,7 @@ static void
1164zoran_release (struct zoran *zr) 1170zoran_release (struct zoran *zr)
1165{ 1171{
1166 if (!zr->initialized) 1172 if (!zr->initialized)
1167 return; 1173 goto exit_free;
1168 /* unregister videocodec bus */ 1174 /* unregister videocodec bus */
1169 if (zr->codec) { 1175 if (zr->codec) {
1170 struct videocodec_master *master = zr->codec->master_data; 1176 struct videocodec_master *master = zr->codec->master_data;
@@ -1192,6 +1198,8 @@ zoran_release (struct zoran *zr)
1192 iounmap(zr->zr36057_mem); 1198 iounmap(zr->zr36057_mem);
1193 pci_disable_device(zr->pci_dev); 1199 pci_disable_device(zr->pci_dev);
1194 video_unregister_device(zr->video_dev); 1200 video_unregister_device(zr->video_dev);
1201exit_free:
1202 kfree(zr);
1195} 1203}
1196 1204
1197void 1205void
@@ -1269,8 +1277,14 @@ find_zr36057 (void)
1269 while (zoran_num < BUZ_MAX && 1277 while (zoran_num < BUZ_MAX &&
1270 (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { 1278 (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) {
1271 card_num = card[zoran_num]; 1279 card_num = card[zoran_num];
1272 zr = &zoran[zoran_num]; 1280 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
1273 memset(zr, 0, sizeof(struct zoran)); // Just in case if previous cycle failed 1281 if (!zr) {
1282 dprintk(1,
1283 KERN_ERR
1284 "%s: find_zr36057() - kzalloc failed\n",
1285 ZORAN_NAME);
1286 continue;
1287 }
1274 zr->pci_dev = dev; 1288 zr->pci_dev = dev;
1275 //zr->zr36057_mem = NULL; 1289 //zr->zr36057_mem = NULL;
1276 zr->id = zoran_num; 1290 zr->id = zoran_num;
@@ -1278,7 +1292,7 @@ find_zr36057 (void)
1278 spin_lock_init(&zr->spinlock); 1292 spin_lock_init(&zr->spinlock);
1279 mutex_init(&zr->resource_lock); 1293 mutex_init(&zr->resource_lock);
1280 if (pci_enable_device(dev)) 1294 if (pci_enable_device(dev))
1281 continue; 1295 goto zr_free_mem;
1282 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); 1296 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
1283 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, 1297 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION,
1284 &zr->revision); 1298 &zr->revision);
@@ -1294,7 +1308,7 @@ find_zr36057 (void)
1294 KERN_ERR 1308 KERN_ERR
1295 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n", 1309 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n",
1296 ZR_DEVNAME(zr)); 1310 ZR_DEVNAME(zr));
1297 continue; 1311 goto zr_free_mem;
1298 } 1312 }
1299 } else { 1313 } else {
1300 int i; 1314 int i;
@@ -1333,7 +1347,7 @@ find_zr36057 (void)
1333 KERN_ERR 1347 KERN_ERR
1334 "%s: find_zr36057() - unknown card\n", 1348 "%s: find_zr36057() - unknown card\n",
1335 ZR_DEVNAME(zr)); 1349 ZR_DEVNAME(zr));
1336 continue; 1350 goto zr_free_mem;
1337 } 1351 }
1338 } 1352 }
1339 } 1353 }
@@ -1343,7 +1357,7 @@ find_zr36057 (void)
1343 KERN_ERR 1357 KERN_ERR
1344 "%s: find_zr36057() - invalid cardnum %d\n", 1358 "%s: find_zr36057() - invalid cardnum %d\n",
1345 ZR_DEVNAME(zr), card_num); 1359 ZR_DEVNAME(zr), card_num);
1346 continue; 1360 goto zr_free_mem;
1347 } 1361 }
1348 1362
1349 /* even though we make this a non pointer and thus 1363 /* even though we make this a non pointer and thus
@@ -1361,7 +1375,7 @@ find_zr36057 (void)
1361 KERN_ERR 1375 KERN_ERR
1362 "%s: find_zr36057() - ioremap failed\n", 1376 "%s: find_zr36057() - ioremap failed\n",
1363 ZR_DEVNAME(zr)); 1377 ZR_DEVNAME(zr));
1364 continue; 1378 goto zr_free_mem;
1365 } 1379 }
1366 1380
1367 result = request_irq(zr->pci_dev->irq, 1381 result = request_irq(zr->pci_dev->irq,
@@ -1530,7 +1544,7 @@ find_zr36057 (void)
1530 } 1544 }
1531 /* Success so keep the pci_dev referenced */ 1545 /* Success so keep the pci_dev referenced */
1532 pci_dev_get(zr->pci_dev); 1546 pci_dev_get(zr->pci_dev);
1533 zoran_num++; 1547 zoran[zoran_num++] = zr;
1534 continue; 1548 continue;
1535 1549
1536 // Init errors 1550 // Init errors
@@ -1549,6 +1563,8 @@ find_zr36057 (void)
1549 free_irq(zr->pci_dev->irq, zr); 1563 free_irq(zr->pci_dev->irq, zr);
1550 zr_unmap: 1564 zr_unmap:
1551 iounmap(zr->zr36057_mem); 1565 iounmap(zr->zr36057_mem);
1566 zr_free_mem:
1567 kfree(zr);
1552 continue; 1568 continue;
1553 } 1569 }
1554 if (dev) /* Clean up ref count on early exit */ 1570 if (dev) /* Clean up ref count on early exit */
@@ -1620,7 +1636,7 @@ init_dc10_cards (void)
1620 1636
1621 /* take care of Natoma chipset and a revision 1 zr36057 */ 1637 /* take care of Natoma chipset and a revision 1 zr36057 */
1622 for (i = 0; i < zoran_num; i++) { 1638 for (i = 0; i < zoran_num; i++) {
1623 struct zoran *zr = &zoran[i]; 1639 struct zoran *zr = zoran[i];
1624 1640
1625 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { 1641 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
1626 zr->jpg_buffers.need_contiguous = 1; 1642 zr->jpg_buffers.need_contiguous = 1;
@@ -1632,7 +1648,7 @@ init_dc10_cards (void)
1632 1648
1633 if (zr36057_init(zr) < 0) { 1649 if (zr36057_init(zr) < 0) {
1634 for (i = 0; i < zoran_num; i++) 1650 for (i = 0; i < zoran_num; i++)
1635 zoran_release(&zoran[i]); 1651 zoran_release(zoran[i]);
1636 return -EIO; 1652 return -EIO;
1637 } 1653 }
1638 zoran_proc_init(zr); 1654 zoran_proc_init(zr);
@@ -1647,7 +1663,7 @@ unload_dc10_cards (void)
1647 int i; 1663 int i;
1648 1664
1649 for (i = 0; i < zoran_num; i++) 1665 for (i = 0; i < zoran_num; i++)
1650 zoran_release(&zoran[i]); 1666 zoran_release(zoran[i]);
1651} 1667}
1652 1668
1653module_init(init_dc10_cards); 1669module_init(init_dc10_cards);
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
index 1b5c4171cf9c..e4dc9d29b404 100644
--- a/drivers/media/video/zoran_card.h
+++ b/drivers/media/video/zoran_card.h
@@ -41,7 +41,7 @@ extern int zr36067_debug;
41/* Anybody who uses more than four? */ 41/* Anybody who uses more than four? */
42#define BUZ_MAX 4 42#define BUZ_MAX 4
43extern int zoran_num; 43extern int zoran_num;
44extern struct zoran zoran[BUZ_MAX]; 44extern struct zoran *zoran[BUZ_MAX];
45 45
46extern struct video_device zoran_template; 46extern struct video_device zoran_template;
47 47
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index c0675921fe20..ec6f59674b10 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -71,6 +71,7 @@
71 71
72#include <linux/videodev.h> 72#include <linux/videodev.h>
73#include <media/v4l2-common.h> 73#include <media/v4l2-common.h>
74#include <media/v4l2-ioctl.h>
74#include "videocodec.h" 75#include "videocodec.h"
75 76
76#include <asm/byteorder.h> 77#include <asm/byteorder.h>
@@ -1212,8 +1213,8 @@ zoran_open (struct inode *inode,
1212 1213
1213 /* find the device */ 1214 /* find the device */
1214 for (i = 0; i < zoran_num; i++) { 1215 for (i = 0; i < zoran_num; i++) {
1215 if (zoran[i].video_dev->minor == minor) { 1216 if (zoran[i]->video_dev->minor == minor) {
1216 zr = &zoran[i]; 1217 zr = zoran[i];
1217 break; 1218 break;
1218 } 1219 }
1219 } 1220 }
@@ -4643,8 +4644,6 @@ static const struct file_operations zoran_fops = {
4643 4644
4644struct video_device zoran_template __devinitdata = { 4645struct video_device zoran_template __devinitdata = {
4645 .name = ZORAN_NAME, 4646 .name = ZORAN_NAME,
4646 .type = ZORAN_VID_TYPE,
4647 .type2 = ZORAN_V4L2_VID_FLAGS,
4648 .fops = &zoran_fops, 4647 .fops = &zoran_fops,
4649 .release = &zoran_vdev_release, 4648 .release = &zoran_vdev_release,
4650 .minor = -1 4649 .minor = -1
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 485df2e36132..18d1c4ba79fb 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -35,6 +35,7 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h>
38 39
39 40
40/* Version Information */ 41/* Version Information */
@@ -761,14 +762,7 @@ static const struct file_operations zr364xx_fops = {
761 .llseek = no_llseek, 762 .llseek = no_llseek,
762}; 763};
763 764
764static struct video_device zr364xx_template = { 765static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
765 .owner = THIS_MODULE,
766 .name = DRIVER_DESC,
767 .type = VID_TYPE_CAPTURE,
768 .fops = &zr364xx_fops,
769 .release = video_device_release,
770 .minor = -1,
771
772 .vidioc_querycap = zr364xx_vidioc_querycap, 766 .vidioc_querycap = zr364xx_vidioc_querycap,
773 .vidioc_enum_fmt_vid_cap = zr364xx_vidioc_enum_fmt_vid_cap, 767 .vidioc_enum_fmt_vid_cap = zr364xx_vidioc_enum_fmt_vid_cap,
774 .vidioc_try_fmt_vid_cap = zr364xx_vidioc_try_fmt_vid_cap, 768 .vidioc_try_fmt_vid_cap = zr364xx_vidioc_try_fmt_vid_cap,
@@ -784,6 +778,14 @@ static struct video_device zr364xx_template = {
784 .vidioc_s_ctrl = zr364xx_vidioc_s_ctrl, 778 .vidioc_s_ctrl = zr364xx_vidioc_s_ctrl,
785}; 779};
786 780
781static struct video_device zr364xx_template = {
782 .name = DRIVER_DESC,
783 .fops = &zr364xx_fops,
784 .ioctl_ops = &zr364xx_ioctl_ops,
785 .release = video_device_release,
786 .minor = -1,
787};
788
787 789
788 790
789/*******************/ 791/*******************/
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index 61b98c333cb0..a38005008a20 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -249,8 +249,11 @@ EXPORT_SYMBOL(memstick_next_req);
249 */ 249 */
250void memstick_new_req(struct memstick_host *host) 250void memstick_new_req(struct memstick_host *host)
251{ 251{
252 host->retries = cmd_retries; 252 if (host->card) {
253 host->request(host); 253 host->retries = cmd_retries;
254 INIT_COMPLETION(host->card->mrq_complete);
255 host->request(host);
256 }
254} 257}
255EXPORT_SYMBOL(memstick_new_req); 258EXPORT_SYMBOL(memstick_new_req);
256 259
@@ -415,10 +418,14 @@ err_out:
415 return NULL; 418 return NULL;
416} 419}
417 420
418static void memstick_power_on(struct memstick_host *host) 421static int memstick_power_on(struct memstick_host *host)
419{ 422{
420 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 423 int rc = host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON);
421 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); 424
425 if (!rc)
426 rc = host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
427
428 return rc;
422} 429}
423 430
424static void memstick_check(struct work_struct *work) 431static void memstick_check(struct work_struct *work)
@@ -429,8 +436,11 @@ static void memstick_check(struct work_struct *work)
429 436
430 dev_dbg(&host->dev, "memstick_check started\n"); 437 dev_dbg(&host->dev, "memstick_check started\n");
431 mutex_lock(&host->lock); 438 mutex_lock(&host->lock);
432 if (!host->card) 439 if (!host->card) {
433 memstick_power_on(host); 440 if (memstick_power_on(host))
441 goto out_power_off;
442 } else
443 host->card->stop(host->card);
434 444
435 card = memstick_alloc_card(host); 445 card = memstick_alloc_card(host);
436 446
@@ -448,7 +458,8 @@ static void memstick_check(struct work_struct *work)
448 || !(host->card->check(host->card))) { 458 || !(host->card->check(host->card))) {
449 device_unregister(&host->card->dev); 459 device_unregister(&host->card->dev);
450 host->card = NULL; 460 host->card = NULL;
451 } 461 } else
462 host->card->start(host->card);
452 } 463 }
453 464
454 if (!host->card) { 465 if (!host->card) {
@@ -461,6 +472,7 @@ static void memstick_check(struct work_struct *work)
461 kfree(card); 472 kfree(card);
462 } 473 }
463 474
475out_power_off:
464 if (!host->card) 476 if (!host->card)
465 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); 477 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
466 478
@@ -573,11 +585,15 @@ EXPORT_SYMBOL(memstick_suspend_host);
573 */ 585 */
574void memstick_resume_host(struct memstick_host *host) 586void memstick_resume_host(struct memstick_host *host)
575{ 587{
588 int rc = 0;
589
576 mutex_lock(&host->lock); 590 mutex_lock(&host->lock);
577 if (host->card) 591 if (host->card)
578 memstick_power_on(host); 592 rc = memstick_power_on(host);
579 mutex_unlock(&host->lock); 593 mutex_unlock(&host->lock);
580 memstick_detect_change(host); 594
595 if (!rc)
596 memstick_detect_change(host);
581} 597}
582EXPORT_SYMBOL(memstick_resume_host); 598EXPORT_SYMBOL(memstick_resume_host);
583 599
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 477d0fb6e588..44b1817f2f2f 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -136,9 +136,8 @@ struct mspro_block_data {
136 unsigned int caps; 136 unsigned int caps;
137 struct gendisk *disk; 137 struct gendisk *disk;
138 struct request_queue *queue; 138 struct request_queue *queue;
139 struct request *block_req;
139 spinlock_t q_lock; 140 spinlock_t q_lock;
140 wait_queue_head_t q_wait;
141 struct task_struct *q_thread;
142 141
143 unsigned short page_size; 142 unsigned short page_size;
144 unsigned short cylinders; 143 unsigned short cylinders;
@@ -147,9 +146,10 @@ struct mspro_block_data {
147 146
148 unsigned char system; 147 unsigned char system;
149 unsigned char read_only:1, 148 unsigned char read_only:1,
150 active:1, 149 eject:1,
151 has_request:1, 150 has_request:1,
152 data_dir:1; 151 data_dir:1,
152 active:1;
153 unsigned char transfer_cmd; 153 unsigned char transfer_cmd;
154 154
155 int (*mrq_handler)(struct memstick_dev *card, 155 int (*mrq_handler)(struct memstick_dev *card,
@@ -160,12 +160,14 @@ struct mspro_block_data {
160 struct scatterlist req_sg[MSPRO_BLOCK_MAX_SEGS]; 160 struct scatterlist req_sg[MSPRO_BLOCK_MAX_SEGS];
161 unsigned int seg_count; 161 unsigned int seg_count;
162 unsigned int current_seg; 162 unsigned int current_seg;
163 unsigned short current_page; 163 unsigned int current_page;
164}; 164};
165 165
166static DEFINE_IDR(mspro_block_disk_idr); 166static DEFINE_IDR(mspro_block_disk_idr);
167static DEFINE_MUTEX(mspro_block_disk_lock); 167static DEFINE_MUTEX(mspro_block_disk_lock);
168 168
169static int mspro_block_complete_req(struct memstick_dev *card, int error);
170
169/*** Block device ***/ 171/*** Block device ***/
170 172
171static int mspro_block_bd_open(struct inode *inode, struct file *filp) 173static int mspro_block_bd_open(struct inode *inode, struct file *filp)
@@ -197,8 +199,10 @@ static int mspro_block_disk_release(struct gendisk *disk)
197 199
198 mutex_lock(&mspro_block_disk_lock); 200 mutex_lock(&mspro_block_disk_lock);
199 201
200 if (msb->usage_count) { 202 if (msb) {
201 msb->usage_count--; 203 if (msb->usage_count)
204 msb->usage_count--;
205
202 if (!msb->usage_count) { 206 if (!msb->usage_count) {
203 kfree(msb); 207 kfree(msb);
204 disk->private_data = NULL; 208 disk->private_data = NULL;
@@ -523,11 +527,13 @@ static int h_mspro_block_req_init(struct memstick_dev *card,
523static int h_mspro_block_default(struct memstick_dev *card, 527static int h_mspro_block_default(struct memstick_dev *card,
524 struct memstick_request **mrq) 528 struct memstick_request **mrq)
525{ 529{
526 complete(&card->mrq_complete); 530 return mspro_block_complete_req(card, (*mrq)->error);
527 if (!(*mrq)->error) 531}
528 return -EAGAIN; 532
529 else 533static int h_mspro_block_default_bad(struct memstick_dev *card,
530 return (*mrq)->error; 534 struct memstick_request **mrq)
535{
536 return -ENXIO;
531} 537}
532 538
533static int h_mspro_block_get_ro(struct memstick_dev *card, 539static int h_mspro_block_get_ro(struct memstick_dev *card,
@@ -535,44 +541,30 @@ static int h_mspro_block_get_ro(struct memstick_dev *card,
535{ 541{
536 struct mspro_block_data *msb = memstick_get_drvdata(card); 542 struct mspro_block_data *msb = memstick_get_drvdata(card);
537 543
538 if ((*mrq)->error) { 544 if (!(*mrq)->error) {
539 complete(&card->mrq_complete); 545 if ((*mrq)->data[offsetof(struct ms_status_register, status0)]
540 return (*mrq)->error; 546 & MEMSTICK_STATUS0_WP)
547 msb->read_only = 1;
548 else
549 msb->read_only = 0;
541 } 550 }
542 551
543 if ((*mrq)->data[offsetof(struct ms_status_register, status0)] 552 return mspro_block_complete_req(card, (*mrq)->error);
544 & MEMSTICK_STATUS0_WP)
545 msb->read_only = 1;
546 else
547 msb->read_only = 0;
548
549 complete(&card->mrq_complete);
550 return -EAGAIN;
551} 553}
552 554
553static int h_mspro_block_wait_for_ced(struct memstick_dev *card, 555static int h_mspro_block_wait_for_ced(struct memstick_dev *card,
554 struct memstick_request **mrq) 556 struct memstick_request **mrq)
555{ 557{
556 if ((*mrq)->error) {
557 complete(&card->mrq_complete);
558 return (*mrq)->error;
559 }
560
561 dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]); 558 dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]);
562 559
563 if ((*mrq)->data[0] & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR)) { 560 if (!(*mrq)->error) {
564 card->current_mrq.error = -EFAULT; 561 if ((*mrq)->data[0] & (MEMSTICK_INT_CMDNAK | MEMSTICK_INT_ERR))
565 complete(&card->mrq_complete); 562 (*mrq)->error = -EFAULT;
566 return card->current_mrq.error; 563 else if (!((*mrq)->data[0] & MEMSTICK_INT_CED))
564 return 0;
567 } 565 }
568 566
569 if (!((*mrq)->data[0] & MEMSTICK_INT_CED)) 567 return mspro_block_complete_req(card, (*mrq)->error);
570 return 0;
571 else {
572 card->current_mrq.error = 0;
573 complete(&card->mrq_complete);
574 return -EAGAIN;
575 }
576} 568}
577 569
578static int h_mspro_block_transfer_data(struct memstick_dev *card, 570static int h_mspro_block_transfer_data(struct memstick_dev *card,
@@ -583,10 +575,8 @@ static int h_mspro_block_transfer_data(struct memstick_dev *card,
583 struct scatterlist t_sg = { 0 }; 575 struct scatterlist t_sg = { 0 };
584 size_t t_offset; 576 size_t t_offset;
585 577
586 if ((*mrq)->error) { 578 if ((*mrq)->error)
587 complete(&card->mrq_complete); 579 return mspro_block_complete_req(card, (*mrq)->error);
588 return (*mrq)->error;
589 }
590 580
591 switch ((*mrq)->tpc) { 581 switch ((*mrq)->tpc) {
592 case MS_TPC_WRITE_REG: 582 case MS_TPC_WRITE_REG:
@@ -617,8 +607,8 @@ has_int_reg:
617 607
618 if (msb->current_seg == msb->seg_count) { 608 if (msb->current_seg == msb->seg_count) {
619 if (t_val & MEMSTICK_INT_CED) { 609 if (t_val & MEMSTICK_INT_CED) {
620 complete(&card->mrq_complete); 610 return mspro_block_complete_req(card,
621 return -EAGAIN; 611 0);
622 } else { 612 } else {
623 card->next_request 613 card->next_request
624 = h_mspro_block_wait_for_ced; 614 = h_mspro_block_wait_for_ced;
@@ -666,140 +656,184 @@ has_int_reg:
666 656
667/*** Data transfer ***/ 657/*** Data transfer ***/
668 658
669static void mspro_block_process_request(struct memstick_dev *card, 659static int mspro_block_issue_req(struct memstick_dev *card, int chunk)
670 struct request *req)
671{ 660{
672 struct mspro_block_data *msb = memstick_get_drvdata(card); 661 struct mspro_block_data *msb = memstick_get_drvdata(card);
673 struct mspro_param_register param;
674 int rc, chunk, cnt;
675 unsigned short page_count;
676 sector_t t_sec; 662 sector_t t_sec;
677 unsigned long flags; 663 unsigned int count;
664 struct mspro_param_register param;
678 665
679 do { 666try_again:
680 page_count = 0; 667 while (chunk) {
668 msb->current_page = 0;
681 msb->current_seg = 0; 669 msb->current_seg = 0;
682 msb->seg_count = blk_rq_map_sg(req->q, req, msb->req_sg); 670 msb->seg_count = blk_rq_map_sg(msb->block_req->q,
671 msb->block_req,
672 msb->req_sg);
683 673
684 if (msb->seg_count) { 674 if (!msb->seg_count) {
685 msb->current_page = 0; 675 chunk = __blk_end_request(msb->block_req, -ENOMEM,
686 for (rc = 0; rc < msb->seg_count; rc++) 676 blk_rq_cur_bytes(msb->block_req));
687 page_count += msb->req_sg[rc].length 677 continue;
688 / msb->page_size; 678 }
689
690 t_sec = req->sector;
691 sector_div(t_sec, msb->page_size >> 9);
692 param.system = msb->system;
693 param.data_count = cpu_to_be16(page_count);
694 param.data_address = cpu_to_be32((uint32_t)t_sec);
695 param.tpc_param = 0;
696
697 msb->data_dir = rq_data_dir(req);
698 msb->transfer_cmd = msb->data_dir == READ
699 ? MSPRO_CMD_READ_DATA
700 : MSPRO_CMD_WRITE_DATA;
701
702 dev_dbg(&card->dev, "data transfer: cmd %x, "
703 "lba %x, count %x\n", msb->transfer_cmd,
704 be32_to_cpu(param.data_address),
705 page_count);
706
707 card->next_request = h_mspro_block_req_init;
708 msb->mrq_handler = h_mspro_block_transfer_data;
709 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG,
710 &param, sizeof(param));
711 memstick_new_req(card->host);
712 wait_for_completion(&card->mrq_complete);
713 rc = card->current_mrq.error;
714 679
715 if (rc || (card->current_mrq.tpc == MSPRO_CMD_STOP)) { 680 t_sec = msb->block_req->sector << 9;
716 for (cnt = 0; cnt < msb->current_seg; cnt++) 681 sector_div(t_sec, msb->page_size);
717 page_count += msb->req_sg[cnt].length
718 / msb->page_size;
719
720 if (msb->current_page)
721 page_count += msb->current_page - 1;
722
723 if (page_count && (msb->data_dir == READ))
724 rc = msb->page_size * page_count;
725 else
726 rc = -EIO;
727 } else
728 rc = msb->page_size * page_count;
729 } else
730 rc = -EFAULT;
731 682
732 spin_lock_irqsave(&msb->q_lock, flags); 683 count = msb->block_req->nr_sectors << 9;
733 if (rc >= 0) 684 count /= msb->page_size;
734 chunk = __blk_end_request(req, 0, rc);
735 else
736 chunk = __blk_end_request(req, rc, 0);
737 685
738 dev_dbg(&card->dev, "end chunk %d, %d\n", rc, chunk); 686 param.system = msb->system;
739 spin_unlock_irqrestore(&msb->q_lock, flags); 687 param.data_count = cpu_to_be16(count);
740 } while (chunk); 688 param.data_address = cpu_to_be32((uint32_t)t_sec);
689 param.tpc_param = 0;
690
691 msb->data_dir = rq_data_dir(msb->block_req);
692 msb->transfer_cmd = msb->data_dir == READ
693 ? MSPRO_CMD_READ_DATA
694 : MSPRO_CMD_WRITE_DATA;
695
696 dev_dbg(&card->dev, "data transfer: cmd %x, "
697 "lba %x, count %x\n", msb->transfer_cmd,
698 be32_to_cpu(param.data_address), count);
699
700 card->next_request = h_mspro_block_req_init;
701 msb->mrq_handler = h_mspro_block_transfer_data;
702 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG,
703 &param, sizeof(param));
704 memstick_new_req(card->host);
705 return 0;
706 }
707
708 dev_dbg(&card->dev, "elv_next\n");
709 msb->block_req = elv_next_request(msb->queue);
710 if (!msb->block_req) {
711 dev_dbg(&card->dev, "issue end\n");
712 return -EAGAIN;
713 }
714
715 dev_dbg(&card->dev, "trying again\n");
716 chunk = 1;
717 goto try_again;
741} 718}
742 719
743static int mspro_block_has_request(struct mspro_block_data *msb) 720static int mspro_block_complete_req(struct memstick_dev *card, int error)
744{ 721{
745 int rc = 0; 722 struct mspro_block_data *msb = memstick_get_drvdata(card);
723 int chunk, cnt;
724 unsigned int t_len = 0;
746 unsigned long flags; 725 unsigned long flags;
747 726
748 spin_lock_irqsave(&msb->q_lock, flags); 727 spin_lock_irqsave(&msb->q_lock, flags);
749 if (kthread_should_stop() || msb->has_request) 728 dev_dbg(&card->dev, "complete %d, %d\n", msb->has_request ? 1 : 0,
750 rc = 1; 729 error);
730
731 if (msb->has_request) {
732 /* Nothing to do - not really an error */
733 if (error == -EAGAIN)
734 error = 0;
735
736 if (error || (card->current_mrq.tpc == MSPRO_CMD_STOP)) {
737 if (msb->data_dir == READ) {
738 for (cnt = 0; cnt < msb->current_seg; cnt++)
739 t_len += msb->req_sg[cnt].length
740 / msb->page_size;
741
742 if (msb->current_page)
743 t_len += msb->current_page - 1;
744
745 t_len *= msb->page_size;
746 }
747 } else
748 t_len = msb->block_req->nr_sectors << 9;
749
750 dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error);
751
752 if (error && !t_len)
753 t_len = blk_rq_cur_bytes(msb->block_req);
754
755 chunk = __blk_end_request(msb->block_req, error, t_len);
756
757 error = mspro_block_issue_req(card, chunk);
758
759 if (!error)
760 goto out;
761 else
762 msb->has_request = 0;
763 } else {
764 if (!error)
765 error = -EAGAIN;
766 }
767
768 card->next_request = h_mspro_block_default_bad;
769 complete_all(&card->mrq_complete);
770out:
751 spin_unlock_irqrestore(&msb->q_lock, flags); 771 spin_unlock_irqrestore(&msb->q_lock, flags);
752 return rc; 772 return error;
753} 773}
754 774
755static int mspro_block_queue_thread(void *data) 775static void mspro_block_stop(struct memstick_dev *card)
756{ 776{
757 struct memstick_dev *card = data;
758 struct memstick_host *host = card->host;
759 struct mspro_block_data *msb = memstick_get_drvdata(card); 777 struct mspro_block_data *msb = memstick_get_drvdata(card);
760 struct request *req; 778 int rc = 0;
761 unsigned long flags; 779 unsigned long flags;
762 780
763 while (1) { 781 while (1) {
764 wait_event(msb->q_wait, mspro_block_has_request(msb));
765 dev_dbg(&card->dev, "thread iter\n");
766
767 spin_lock_irqsave(&msb->q_lock, flags); 782 spin_lock_irqsave(&msb->q_lock, flags);
768 req = elv_next_request(msb->queue); 783 if (!msb->has_request) {
769 dev_dbg(&card->dev, "next req %p\n", req); 784 blk_stop_queue(msb->queue);
770 if (!req) { 785 rc = 1;
771 msb->has_request = 0; 786 }
772 if (kthread_should_stop()) {
773 spin_unlock_irqrestore(&msb->q_lock, flags);
774 break;
775 }
776 } else
777 msb->has_request = 1;
778 spin_unlock_irqrestore(&msb->q_lock, flags); 787 spin_unlock_irqrestore(&msb->q_lock, flags);
779 788
780 if (req) { 789 if (rc)
781 mutex_lock(&host->lock); 790 break;
782 mspro_block_process_request(card, req); 791
783 mutex_unlock(&host->lock); 792 wait_for_completion(&card->mrq_complete);
784 }
785 } 793 }
786 dev_dbg(&card->dev, "thread finished\n");
787 return 0;
788} 794}
789 795
790static void mspro_block_request(struct request_queue *q) 796static void mspro_block_start(struct memstick_dev *card)
797{
798 struct mspro_block_data *msb = memstick_get_drvdata(card);
799 unsigned long flags;
800
801 spin_lock_irqsave(&msb->q_lock, flags);
802 blk_start_queue(msb->queue);
803 spin_unlock_irqrestore(&msb->q_lock, flags);
804}
805
806static int mspro_block_prepare_req(struct request_queue *q, struct request *req)
807{
808 if (!blk_fs_request(req) && !blk_pc_request(req)) {
809 blk_dump_rq_flags(req, "MSPro unsupported request");
810 return BLKPREP_KILL;
811 }
812
813 req->cmd_flags |= REQ_DONTPREP;
814
815 return BLKPREP_OK;
816}
817
818static void mspro_block_submit_req(struct request_queue *q)
791{ 819{
792 struct memstick_dev *card = q->queuedata; 820 struct memstick_dev *card = q->queuedata;
793 struct mspro_block_data *msb = memstick_get_drvdata(card); 821 struct mspro_block_data *msb = memstick_get_drvdata(card);
794 struct request *req = NULL; 822 struct request *req = NULL;
795 823
796 if (msb->q_thread) { 824 if (msb->has_request)
797 msb->has_request = 1; 825 return;
798 wake_up_all(&msb->q_wait); 826
799 } else { 827 if (msb->eject) {
800 while ((req = elv_next_request(q)) != NULL) 828 while ((req = elv_next_request(q)) != NULL)
801 end_queued_request(req, -ENODEV); 829 end_queued_request(req, -ENODEV);
830
831 return;
802 } 832 }
833
834 msb->has_request = 1;
835 if (mspro_block_issue_req(card, 0))
836 msb->has_request = 0;
803} 837}
804 838
805/*** Initialization ***/ 839/*** Initialization ***/
@@ -1169,16 +1203,14 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1169 goto out_release_id; 1203 goto out_release_id;
1170 } 1204 }
1171 1205
1172 spin_lock_init(&msb->q_lock); 1206 msb->queue = blk_init_queue(mspro_block_submit_req, &msb->q_lock);
1173 init_waitqueue_head(&msb->q_wait);
1174
1175 msb->queue = blk_init_queue(mspro_block_request, &msb->q_lock);
1176 if (!msb->queue) { 1207 if (!msb->queue) {
1177 rc = -ENOMEM; 1208 rc = -ENOMEM;
1178 goto out_put_disk; 1209 goto out_put_disk;
1179 } 1210 }
1180 1211
1181 msb->queue->queuedata = card; 1212 msb->queue->queuedata = card;
1213 blk_queue_prep_rq(msb->queue, mspro_block_prepare_req);
1182 1214
1183 blk_queue_bounce_limit(msb->queue, limit); 1215 blk_queue_bounce_limit(msb->queue, limit);
1184 blk_queue_max_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES); 1216 blk_queue_max_sectors(msb->queue, MSPRO_BLOCK_MAX_PAGES);
@@ -1204,14 +1236,8 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1204 capacity *= msb->page_size >> 9; 1236 capacity *= msb->page_size >> 9;
1205 set_capacity(msb->disk, capacity); 1237 set_capacity(msb->disk, capacity);
1206 dev_dbg(&card->dev, "capacity set %ld\n", capacity); 1238 dev_dbg(&card->dev, "capacity set %ld\n", capacity);
1207 msb->q_thread = kthread_run(mspro_block_queue_thread, card,
1208 DRIVER_NAME"d");
1209 if (IS_ERR(msb->q_thread))
1210 goto out_put_disk;
1211 1239
1212 mutex_unlock(&host->lock);
1213 add_disk(msb->disk); 1240 add_disk(msb->disk);
1214 mutex_lock(&host->lock);
1215 msb->active = 1; 1241 msb->active = 1;
1216 return 0; 1242 return 0;
1217 1243
@@ -1259,6 +1285,7 @@ static int mspro_block_probe(struct memstick_dev *card)
1259 return -ENOMEM; 1285 return -ENOMEM;
1260 memstick_set_drvdata(card, msb); 1286 memstick_set_drvdata(card, msb);
1261 msb->card = card; 1287 msb->card = card;
1288 spin_lock_init(&msb->q_lock);
1262 1289
1263 rc = mspro_block_init_card(card); 1290 rc = mspro_block_init_card(card);
1264 1291
@@ -1272,6 +1299,8 @@ static int mspro_block_probe(struct memstick_dev *card)
1272 rc = mspro_block_init_disk(card); 1299 rc = mspro_block_init_disk(card);
1273 if (!rc) { 1300 if (!rc) {
1274 card->check = mspro_block_check_card; 1301 card->check = mspro_block_check_card;
1302 card->stop = mspro_block_stop;
1303 card->start = mspro_block_start;
1275 return 0; 1304 return 0;
1276 } 1305 }
1277 1306
@@ -1286,26 +1315,17 @@ out_free:
1286static void mspro_block_remove(struct memstick_dev *card) 1315static void mspro_block_remove(struct memstick_dev *card)
1287{ 1316{
1288 struct mspro_block_data *msb = memstick_get_drvdata(card); 1317 struct mspro_block_data *msb = memstick_get_drvdata(card);
1289 struct task_struct *q_thread = NULL;
1290 unsigned long flags; 1318 unsigned long flags;
1291 1319
1292 del_gendisk(msb->disk); 1320 del_gendisk(msb->disk);
1293 dev_dbg(&card->dev, "mspro block remove\n"); 1321 dev_dbg(&card->dev, "mspro block remove\n");
1294 spin_lock_irqsave(&msb->q_lock, flags); 1322 spin_lock_irqsave(&msb->q_lock, flags);
1295 q_thread = msb->q_thread; 1323 msb->eject = 1;
1296 msb->q_thread = NULL; 1324 blk_start_queue(msb->queue);
1297 msb->active = 0;
1298 spin_unlock_irqrestore(&msb->q_lock, flags); 1325 spin_unlock_irqrestore(&msb->q_lock, flags);
1299 1326
1300 if (q_thread) {
1301 mutex_unlock(&card->host->lock);
1302 kthread_stop(q_thread);
1303 mutex_lock(&card->host->lock);
1304 }
1305
1306 dev_dbg(&card->dev, "queue thread stopped\n");
1307
1308 blk_cleanup_queue(msb->queue); 1327 blk_cleanup_queue(msb->queue);
1328 msb->queue = NULL;
1309 1329
1310 sysfs_remove_group(&card->dev.kobj, &msb->attr_group); 1330 sysfs_remove_group(&card->dev.kobj, &msb->attr_group);
1311 1331
@@ -1322,19 +1342,13 @@ static void mspro_block_remove(struct memstick_dev *card)
1322static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state) 1342static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state)
1323{ 1343{
1324 struct mspro_block_data *msb = memstick_get_drvdata(card); 1344 struct mspro_block_data *msb = memstick_get_drvdata(card);
1325 struct task_struct *q_thread = NULL;
1326 unsigned long flags; 1345 unsigned long flags;
1327 1346
1328 spin_lock_irqsave(&msb->q_lock, flags); 1347 spin_lock_irqsave(&msb->q_lock, flags);
1329 q_thread = msb->q_thread;
1330 msb->q_thread = NULL;
1331 msb->active = 0;
1332 blk_stop_queue(msb->queue); 1348 blk_stop_queue(msb->queue);
1349 msb->active = 0;
1333 spin_unlock_irqrestore(&msb->q_lock, flags); 1350 spin_unlock_irqrestore(&msb->q_lock, flags);
1334 1351
1335 if (q_thread)
1336 kthread_stop(q_thread);
1337
1338 return 0; 1352 return 0;
1339} 1353}
1340 1354
@@ -1373,14 +1387,7 @@ static int mspro_block_resume(struct memstick_dev *card)
1373 if (memcmp(s_attr->data, r_attr->data, s_attr->size)) 1387 if (memcmp(s_attr->data, r_attr->data, s_attr->size))
1374 break; 1388 break;
1375 1389
1376 memstick_set_drvdata(card, msb); 1390 msb->active = 1;
1377 msb->q_thread = kthread_run(mspro_block_queue_thread,
1378 card, DRIVER_NAME"d");
1379 if (IS_ERR(msb->q_thread))
1380 msb->q_thread = NULL;
1381 else
1382 msb->active = 1;
1383
1384 break; 1391 break;
1385 } 1392 }
1386 } 1393 }
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index 4e3bfbcdf155..3485c63d20b0 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -50,6 +50,7 @@ struct jmb38x_ms_host {
50 struct jmb38x_ms *chip; 50 struct jmb38x_ms *chip;
51 void __iomem *addr; 51 void __iomem *addr;
52 spinlock_t lock; 52 spinlock_t lock;
53 struct tasklet_struct notify;
53 int id; 54 int id;
54 char host_id[32]; 55 char host_id[32];
55 int irq; 56 int irq;
@@ -590,55 +591,97 @@ static void jmb38x_ms_abort(unsigned long data)
590 spin_unlock_irqrestore(&host->lock, flags); 591 spin_unlock_irqrestore(&host->lock, flags);
591} 592}
592 593
593static void jmb38x_ms_request(struct memstick_host *msh) 594static void jmb38x_ms_req_tasklet(unsigned long data)
594{ 595{
596 struct memstick_host *msh = (struct memstick_host *)data;
595 struct jmb38x_ms_host *host = memstick_priv(msh); 597 struct jmb38x_ms_host *host = memstick_priv(msh);
596 unsigned long flags; 598 unsigned long flags;
597 int rc; 599 int rc;
598 600
599 spin_lock_irqsave(&host->lock, flags); 601 spin_lock_irqsave(&host->lock, flags);
600 if (host->req) { 602 if (!host->req) {
601 spin_unlock_irqrestore(&host->lock, flags); 603 do {
602 BUG(); 604 rc = memstick_next_req(msh, &host->req);
603 return; 605 dev_dbg(&host->chip->pdev->dev, "tasklet req %d\n", rc);
606 } while (!rc && jmb38x_ms_issue_cmd(msh));
604 } 607 }
605
606 do {
607 rc = memstick_next_req(msh, &host->req);
608 } while (!rc && jmb38x_ms_issue_cmd(msh));
609 spin_unlock_irqrestore(&host->lock, flags); 608 spin_unlock_irqrestore(&host->lock, flags);
610} 609}
611 610
612static void jmb38x_ms_reset(struct jmb38x_ms_host *host) 611static void jmb38x_ms_dummy_submit(struct memstick_host *msh)
613{ 612{
614 unsigned int host_ctl = readl(host->addr + HOST_CONTROL); 613 return;
614}
615
616static void jmb38x_ms_submit_req(struct memstick_host *msh)
617{
618 struct jmb38x_ms_host *host = memstick_priv(msh);
619
620 tasklet_schedule(&host->notify);
621}
622
623static int jmb38x_ms_reset(struct jmb38x_ms_host *host)
624{
625 int cnt;
626
627 writel(HOST_CONTROL_RESET_REQ | HOST_CONTROL_CLOCK_EN
628 | readl(host->addr + HOST_CONTROL),
629 host->addr + HOST_CONTROL);
630 mmiowb();
631
632 for (cnt = 0; cnt < 20; ++cnt) {
633 if (!(HOST_CONTROL_RESET_REQ
634 & readl(host->addr + HOST_CONTROL)))
635 goto reset_next;
615 636
616 writel(HOST_CONTROL_RESET_REQ, host->addr + HOST_CONTROL); 637 ndelay(20);
638 }
639 dev_dbg(&host->chip->pdev->dev, "reset_req timeout\n");
640 return -EIO;
641
642reset_next:
643 writel(HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN
644 | readl(host->addr + HOST_CONTROL),
645 host->addr + HOST_CONTROL);
646 mmiowb();
647
648 for (cnt = 0; cnt < 20; ++cnt) {
649 if (!(HOST_CONTROL_RESET
650 & readl(host->addr + HOST_CONTROL)))
651 goto reset_ok;
617 652
618 while (HOST_CONTROL_RESET_REQ
619 & (host_ctl = readl(host->addr + HOST_CONTROL))) {
620 ndelay(20); 653 ndelay(20);
621 dev_dbg(&host->chip->pdev->dev, "reset %08x\n", host_ctl);
622 } 654 }
655 dev_dbg(&host->chip->pdev->dev, "reset timeout\n");
656 return -EIO;
623 657
624 writel(HOST_CONTROL_RESET, host->addr + HOST_CONTROL); 658reset_ok:
625 mmiowb(); 659 mmiowb();
626 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE); 660 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE);
627 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE); 661 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE);
662 return 0;
628} 663}
629 664
630static void jmb38x_ms_set_param(struct memstick_host *msh, 665static int jmb38x_ms_set_param(struct memstick_host *msh,
631 enum memstick_param param, 666 enum memstick_param param,
632 int value) 667 int value)
633{ 668{
634 struct jmb38x_ms_host *host = memstick_priv(msh); 669 struct jmb38x_ms_host *host = memstick_priv(msh);
635 unsigned int host_ctl = readl(host->addr + HOST_CONTROL); 670 unsigned int host_ctl = readl(host->addr + HOST_CONTROL);
636 unsigned int clock_ctl = CLOCK_CONTROL_40MHZ, clock_delay = 0; 671 unsigned int clock_ctl = CLOCK_CONTROL_40MHZ, clock_delay = 0;
672 int rc = 0;
637 673
638 switch (param) { 674 switch (param) {
639 case MEMSTICK_POWER: 675 case MEMSTICK_POWER:
640 if (value == MEMSTICK_POWER_ON) { 676 if (value == MEMSTICK_POWER_ON) {
641 jmb38x_ms_reset(host); 677 rc = jmb38x_ms_reset(host);
678 if (rc)
679 return rc;
680
681 host_ctl = 7;
682 host_ctl |= HOST_CONTROL_POWER_EN
683 | HOST_CONTROL_CLOCK_EN;
684 writel(host_ctl, host->addr + HOST_CONTROL);
642 685
643 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 686 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1
644 : PAD_PU_PD_ON_MS_SOCK0, 687 : PAD_PU_PD_ON_MS_SOCK0,
@@ -647,11 +690,7 @@ static void jmb38x_ms_set_param(struct memstick_host *msh,
647 writel(PAD_OUTPUT_ENABLE_MS, 690 writel(PAD_OUTPUT_ENABLE_MS,
648 host->addr + PAD_OUTPUT_ENABLE); 691 host->addr + PAD_OUTPUT_ENABLE);
649 692
650 host_ctl = 7; 693 msleep(10);
651 host_ctl |= HOST_CONTROL_POWER_EN
652 | HOST_CONTROL_CLOCK_EN;
653 writel(host_ctl, host->addr + HOST_CONTROL);
654
655 dev_dbg(&host->chip->pdev->dev, "power on\n"); 694 dev_dbg(&host->chip->pdev->dev, "power on\n");
656 } else if (value == MEMSTICK_POWER_OFF) { 695 } else if (value == MEMSTICK_POWER_OFF) {
657 host_ctl &= ~(HOST_CONTROL_POWER_EN 696 host_ctl &= ~(HOST_CONTROL_POWER_EN
@@ -660,7 +699,8 @@ static void jmb38x_ms_set_param(struct memstick_host *msh,
660 writel(0, host->addr + PAD_OUTPUT_ENABLE); 699 writel(0, host->addr + PAD_OUTPUT_ENABLE);
661 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD); 700 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD);
662 dev_dbg(&host->chip->pdev->dev, "power off\n"); 701 dev_dbg(&host->chip->pdev->dev, "power off\n");
663 } 702 } else
703 return -EINVAL;
664 break; 704 break;
665 case MEMSTICK_INTERFACE: 705 case MEMSTICK_INTERFACE:
666 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT); 706 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT);
@@ -686,12 +726,14 @@ static void jmb38x_ms_set_param(struct memstick_host *msh,
686 host_ctl &= ~HOST_CONTROL_REI; 726 host_ctl &= ~HOST_CONTROL_REI;
687 clock_ctl = CLOCK_CONTROL_60MHZ; 727 clock_ctl = CLOCK_CONTROL_60MHZ;
688 clock_delay = 0; 728 clock_delay = 0;
689 } 729 } else
730 return -EINVAL;
690 writel(host_ctl, host->addr + HOST_CONTROL); 731 writel(host_ctl, host->addr + HOST_CONTROL);
691 writel(clock_ctl, host->addr + CLOCK_CONTROL); 732 writel(clock_ctl, host->addr + CLOCK_CONTROL);
692 writel(clock_delay, host->addr + CLOCK_DELAY); 733 writel(clock_delay, host->addr + CLOCK_DELAY);
693 break; 734 break;
694 }; 735 };
736 return 0;
695} 737}
696 738
697#ifdef CONFIG_PM 739#ifdef CONFIG_PM
@@ -785,7 +827,9 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
785 host->id); 827 host->id);
786 host->irq = jm->pdev->irq; 828 host->irq = jm->pdev->irq;
787 host->timeout_jiffies = msecs_to_jiffies(1000); 829 host->timeout_jiffies = msecs_to_jiffies(1000);
788 msh->request = jmb38x_ms_request; 830
831 tasklet_init(&host->notify, jmb38x_ms_req_tasklet, (unsigned long)msh);
832 msh->request = jmb38x_ms_submit_req;
789 msh->set_param = jmb38x_ms_set_param; 833 msh->set_param = jmb38x_ms_set_param;
790 834
791 msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8; 835 msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8;
@@ -897,6 +941,8 @@ static void jmb38x_ms_remove(struct pci_dev *dev)
897 941
898 host = memstick_priv(jm->hosts[cnt]); 942 host = memstick_priv(jm->hosts[cnt]);
899 943
944 jm->hosts[cnt]->request = jmb38x_ms_dummy_submit;
945 tasklet_kill(&host->notify);
900 writel(0, host->addr + INT_SIGNAL_ENABLE); 946 writel(0, host->addr + INT_SIGNAL_ENABLE);
901 writel(0, host->addr + INT_STATUS_ENABLE); 947 writel(0, host->addr + INT_STATUS_ENABLE);
902 mmiowb(); 948 mmiowb();
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index 8577de4ebb0e..d32d6ad8f3fc 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -71,6 +71,7 @@ struct tifm_ms {
71 struct tifm_dev *dev; 71 struct tifm_dev *dev;
72 struct timer_list timer; 72 struct timer_list timer;
73 struct memstick_request *req; 73 struct memstick_request *req;
74 struct tasklet_struct notify;
74 unsigned int mode_mask; 75 unsigned int mode_mask;
75 unsigned int block_pos; 76 unsigned int block_pos;
76 unsigned long timeout_jiffies; 77 unsigned long timeout_jiffies;
@@ -455,49 +456,51 @@ static void tifm_ms_card_event(struct tifm_dev *sock)
455 return; 456 return;
456} 457}
457 458
458static void tifm_ms_request(struct memstick_host *msh) 459static void tifm_ms_req_tasklet(unsigned long data)
459{ 460{
461 struct memstick_host *msh = (struct memstick_host *)data;
460 struct tifm_ms *host = memstick_priv(msh); 462 struct tifm_ms *host = memstick_priv(msh);
461 struct tifm_dev *sock = host->dev; 463 struct tifm_dev *sock = host->dev;
462 unsigned long flags; 464 unsigned long flags;
463 int rc; 465 int rc;
464 466
465 spin_lock_irqsave(&sock->lock, flags); 467 spin_lock_irqsave(&sock->lock, flags);
466 if (host->req) { 468 if (!host->req) {
467 printk(KERN_ERR "%s : unfinished request detected\n", 469 if (host->eject) {
468 sock->dev.bus_id); 470 do {
469 spin_unlock_irqrestore(&sock->lock, flags); 471 rc = memstick_next_req(msh, &host->req);
470 tifm_eject(host->dev); 472 if (!rc)
471 return; 473 host->req->error = -ETIME;
472 } 474 } while (!rc);
475 spin_unlock_irqrestore(&sock->lock, flags);
476 return;
477 }
473 478
474 if (host->eject) {
475 do { 479 do {
476 rc = memstick_next_req(msh, &host->req); 480 rc = memstick_next_req(msh, &host->req);
477 if (!rc) 481 } while (!rc && tifm_ms_issue_cmd(host));
478 host->req->error = -ETIME;
479 } while (!rc);
480 spin_unlock_irqrestore(&sock->lock, flags);
481 return;
482 } 482 }
483
484 do {
485 rc = memstick_next_req(msh, &host->req);
486 } while (!rc && tifm_ms_issue_cmd(host));
487
488 spin_unlock_irqrestore(&sock->lock, flags); 483 spin_unlock_irqrestore(&sock->lock, flags);
484}
485
486static void tifm_ms_dummy_submit(struct memstick_host *msh)
487{
489 return; 488 return;
490} 489}
491 490
492static void tifm_ms_set_param(struct memstick_host *msh, 491static void tifm_ms_submit_req(struct memstick_host *msh)
493 enum memstick_param param,
494 int value)
495{ 492{
496 struct tifm_ms *host = memstick_priv(msh); 493 struct tifm_ms *host = memstick_priv(msh);
497 struct tifm_dev *sock = host->dev;
498 unsigned long flags;
499 494
500 spin_lock_irqsave(&sock->lock, flags); 495 tasklet_schedule(&host->notify);
496}
497
498static int tifm_ms_set_param(struct memstick_host *msh,
499 enum memstick_param param,
500 int value)
501{
502 struct tifm_ms *host = memstick_priv(msh);
503 struct tifm_dev *sock = host->dev;
501 504
502 switch (param) { 505 switch (param) {
503 case MEMSTICK_POWER: 506 case MEMSTICK_POWER:
@@ -512,7 +515,8 @@ static void tifm_ms_set_param(struct memstick_host *msh,
512 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR, 515 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
513 sock->addr + SOCK_MS_SYSTEM); 516 sock->addr + SOCK_MS_SYSTEM);
514 writel(0xffffffff, sock->addr + SOCK_MS_STATUS); 517 writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
515 } 518 } else
519 return -EINVAL;
516 break; 520 break;
517 case MEMSTICK_INTERFACE: 521 case MEMSTICK_INTERFACE:
518 if (value == MEMSTICK_SERIAL) { 522 if (value == MEMSTICK_SERIAL) {
@@ -525,11 +529,12 @@ static void tifm_ms_set_param(struct memstick_host *msh,
525 writel(TIFM_CTRL_FAST_CLK 529 writel(TIFM_CTRL_FAST_CLK
526 | readl(sock->addr + SOCK_CONTROL), 530 | readl(sock->addr + SOCK_CONTROL),
527 sock->addr + SOCK_CONTROL); 531 sock->addr + SOCK_CONTROL);
528 } 532 } else
533 return -EINVAL;
529 break; 534 break;
530 }; 535 };
531 536
532 spin_unlock_irqrestore(&sock->lock, flags); 537 return 0;
533} 538}
534 539
535static void tifm_ms_abort(unsigned long data) 540static void tifm_ms_abort(unsigned long data)
@@ -570,8 +575,9 @@ static int tifm_ms_probe(struct tifm_dev *sock)
570 host->timeout_jiffies = msecs_to_jiffies(1000); 575 host->timeout_jiffies = msecs_to_jiffies(1000);
571 576
572 setup_timer(&host->timer, tifm_ms_abort, (unsigned long)host); 577 setup_timer(&host->timer, tifm_ms_abort, (unsigned long)host);
578 tasklet_init(&host->notify, tifm_ms_req_tasklet, (unsigned long)msh);
573 579
574 msh->request = tifm_ms_request; 580 msh->request = tifm_ms_submit_req;
575 msh->set_param = tifm_ms_set_param; 581 msh->set_param = tifm_ms_set_param;
576 sock->card_event = tifm_ms_card_event; 582 sock->card_event = tifm_ms_card_event;
577 sock->data_event = tifm_ms_data_event; 583 sock->data_event = tifm_ms_data_event;
@@ -593,6 +599,8 @@ static void tifm_ms_remove(struct tifm_dev *sock)
593 int rc = 0; 599 int rc = 0;
594 unsigned long flags; 600 unsigned long flags;
595 601
602 msh->request = tifm_ms_dummy_submit;
603 tasklet_kill(&host->notify);
596 spin_lock_irqsave(&sock->lock, flags); 604 spin_lock_irqsave(&sock->lock, flags);
597 host->eject = 1; 605 host->eject = 1;
598 if (host->req) { 606 if (host->req) {
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 241592ab13ad..3f15fcfe4a2e 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -127,7 +127,7 @@ mpi_ioc.h
127 * 08-08-01 01.02.01 Original release for v1.2 work. 127 * 08-08-01 01.02.01 Original release for v1.2 work.
128 * New format for FWVersion and ProductId in 128 * New format for FWVersion and ProductId in
129 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER. 129 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
130 * 08-31-01 01.02.02 Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and 130 * 08-31-01 01.02.02 Added event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
131 * related structure and defines. 131 * related structure and defines.
132 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED. 132 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
133 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE. 133 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
@@ -187,7 +187,7 @@ mpi_ioc.h
187 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED. 187 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
188 * Added MaxInitiators field to PortFacts reply. 188 * Added MaxInitiators field to PortFacts reply.
189 * Added SAS Device Status Change ReasonCode for 189 * Added SAS Device Status Change ReasonCode for
190 * asynchronous notificaiton. 190 * asynchronous notification.
191 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event 191 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
192 * data structure. 192 * data structure.
193 * Added new ImageType values for FWDownload and FWUpload 193 * Added new ImageType values for FWDownload and FWUpload
@@ -213,7 +213,7 @@ mpi_cnfg.h
213 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1 213 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1
214 * page and updated the page version. 214 * page and updated the page version.
215 * Added Information field and _INFO_PARAMS_NEGOTIATED 215 * Added Information field and _INFO_PARAMS_NEGOTIATED
216 * definitionto SCSI_DEVICE_0 page. 216 * definition to SCSI_DEVICE_0 page.
217 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the 217 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the
218 * page version. 218 * page version.
219 * Added BucketsRemaining to LAN_1 page, redefined the 219 * Added BucketsRemaining to LAN_1 page, redefined the
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 34402c47027e..d6a0074b9dc3 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -273,12 +273,12 @@ mpt_fault_reset_work(struct work_struct *work)
273 ioc_raw_state = mpt_GetIocState(ioc, 0); 273 ioc_raw_state = mpt_GetIocState(ioc, 0);
274 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) { 274 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) {
275 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state (%04xh)!!!\n", 275 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state (%04xh)!!!\n",
276 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK); 276 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK);
277 printk(MYIOC_s_WARN_FMT "Issuing HardReset from %s!!\n", 277 printk(MYIOC_s_WARN_FMT "Issuing HardReset from %s!!\n",
278 ioc->name, __FUNCTION__); 278 ioc->name, __func__);
279 rc = mpt_HardResetHandler(ioc, CAN_SLEEP); 279 rc = mpt_HardResetHandler(ioc, CAN_SLEEP);
280 printk(MYIOC_s_WARN_FMT "%s: HardReset: %s\n", ioc->name, 280 printk(MYIOC_s_WARN_FMT "%s: HardReset: %s\n", ioc->name,
281 __FUNCTION__, (rc == 0) ? "success" : "failed"); 281 __func__, (rc == 0) ? "success" : "failed");
282 ioc_raw_state = mpt_GetIocState(ioc, 0); 282 ioc_raw_state = mpt_GetIocState(ioc, 0);
283 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) 283 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT)
284 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state after " 284 printk(MYIOC_s_WARN_FMT "IOC is in FAULT state after "
@@ -356,7 +356,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
356 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 356 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
357 MptCallbacks[cb_idx] == NULL) { 357 MptCallbacks[cb_idx] == NULL) {
358 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 358 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
359 __FUNCTION__, ioc->name, cb_idx); 359 __func__, ioc->name, cb_idx);
360 goto out; 360 goto out;
361 } 361 }
362 362
@@ -420,7 +420,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
420 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 420 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
421 MptCallbacks[cb_idx] == NULL) { 421 MptCallbacks[cb_idx] == NULL) {
422 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 422 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
423 __FUNCTION__, ioc->name, cb_idx); 423 __func__, ioc->name, cb_idx);
424 freeme = 0; 424 freeme = 0;
425 goto out; 425 goto out;
426 } 426 }
@@ -2434,7 +2434,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2434 2434
2435 if (ioc->cached_fw != NULL) { 2435 if (ioc->cached_fw != NULL) {
2436 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: Pushing FW onto " 2436 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: Pushing FW onto "
2437 "adapter\n", __FUNCTION__, ioc->name)); 2437 "adapter\n", __func__, ioc->name));
2438 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *) 2438 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)
2439 ioc->cached_fw, CAN_SLEEP)) < 0) { 2439 ioc->cached_fw, CAN_SLEEP)) < 0) {
2440 printk(MYIOC_s_WARN_FMT 2440 printk(MYIOC_s_WARN_FMT
@@ -3693,7 +3693,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3693 3693
3694 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { 3694 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
3695 drsprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset " 3695 drsprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset "
3696 "address=%p\n", ioc->name, __FUNCTION__, 3696 "address=%p\n", ioc->name, __func__,
3697 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); 3697 &ioc->chip->Doorbell, &ioc->chip->Reset_1078));
3698 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); 3698 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07);
3699 if (sleepFlag == CAN_SLEEP) 3699 if (sleepFlag == CAN_SLEEP)
@@ -4742,12 +4742,12 @@ mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode)
4742 break; 4742 break;
4743 } 4743 }
4744 4744
4745 printk("%s: persist_opcode=%x\n",__FUNCTION__, persist_opcode); 4745 printk("%s: persist_opcode=%x\n",__func__, persist_opcode);
4746 4746
4747 /* Get a MF for this command. 4747 /* Get a MF for this command.
4748 */ 4748 */
4749 if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { 4749 if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
4750 printk("%s: no msg frames!\n",__FUNCTION__); 4750 printk("%s: no msg frames!\n",__func__);
4751 return -1; 4751 return -1;
4752 } 4752 }
4753 4753
@@ -4771,13 +4771,13 @@ mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode)
4771 (SasIoUnitControlReply_t *)ioc->persist_reply_frame; 4771 (SasIoUnitControlReply_t *)ioc->persist_reply_frame;
4772 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) { 4772 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) {
4773 printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", 4773 printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
4774 __FUNCTION__, 4774 __func__,
4775 sasIoUnitCntrReply->IOCStatus, 4775 sasIoUnitCntrReply->IOCStatus,
4776 sasIoUnitCntrReply->IOCLogInfo); 4776 sasIoUnitCntrReply->IOCLogInfo);
4777 return -1; 4777 return -1;
4778 } 4778 }
4779 4779
4780 printk("%s: success\n",__FUNCTION__); 4780 printk("%s: success\n",__func__);
4781 return 0; 4781 return 0;
4782} 4782}
4783 4783
@@ -5784,7 +5784,7 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5784 5784
5785 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { 5785 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
5786 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n", 5786 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
5787 ioc->name,__FUNCTION__)); 5787 ioc->name,__func__));
5788 return -1; 5788 return -1;
5789 } 5789 }
5790 5790
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index a5920423e2b2..f5233f3d9eff 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -505,7 +505,7 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
505 event = le32_to_cpu(pEvReply->Event) & 0xFF; 505 event = le32_to_cpu(pEvReply->Event) & 0xFF;
506 506
507 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s() called\n", 507 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s() called\n",
508 ioc->name, __FUNCTION__)); 508 ioc->name, __func__));
509 if(async_queue == NULL) 509 if(async_queue == NULL)
510 return 1; 510 return 1;
511 511
@@ -2482,7 +2482,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2482 */ 2482 */
2483 if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { 2483 if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
2484 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n", 2484 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
2485 ioc->name,__FUNCTION__)); 2485 ioc->name,__func__));
2486 goto out; 2486 goto out;
2487 } 2487 }
2488 2488
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index b36cae9ec6db..c3c24fdf9fb6 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -231,28 +231,28 @@ static int
231mptfc_abort(struct scsi_cmnd *SCpnt) 231mptfc_abort(struct scsi_cmnd *SCpnt)
232{ 232{
233 return 233 return
234 mptfc_block_error_handler(SCpnt, mptscsih_abort, __FUNCTION__); 234 mptfc_block_error_handler(SCpnt, mptscsih_abort, __func__);
235} 235}
236 236
237static int 237static int
238mptfc_dev_reset(struct scsi_cmnd *SCpnt) 238mptfc_dev_reset(struct scsi_cmnd *SCpnt)
239{ 239{
240 return 240 return
241 mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __FUNCTION__); 241 mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __func__);
242} 242}
243 243
244static int 244static int
245mptfc_bus_reset(struct scsi_cmnd *SCpnt) 245mptfc_bus_reset(struct scsi_cmnd *SCpnt)
246{ 246{
247 return 247 return
248 mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __FUNCTION__); 248 mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __func__);
249} 249}
250 250
251static int 251static int
252mptfc_host_reset(struct scsi_cmnd *SCpnt) 252mptfc_host_reset(struct scsi_cmnd *SCpnt)
253{ 253{
254 return 254 return
255 mptfc_block_error_handler(SCpnt, mptscsih_host_reset, __FUNCTION__); 255 mptfc_block_error_handler(SCpnt, mptscsih_host_reset, __func__);
256} 256}
257 257
258static void 258static void
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index d709d92b7b30..a1abf95cf751 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -610,7 +610,7 @@ mpt_lan_send_turbo(struct net_device *dev, u32 tmsg)
610 610
611 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n", 611 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
612 IOC_AND_NETDEV_NAMES_s_s(dev), 612 IOC_AND_NETDEV_NAMES_s_s(dev),
613 __FUNCTION__, sent)); 613 __func__, sent));
614 614
615 priv->SendCtl[ctx].skb = NULL; 615 priv->SendCtl[ctx].skb = NULL;
616 pci_unmap_single(mpt_dev->pcidev, priv->SendCtl[ctx].dma, 616 pci_unmap_single(mpt_dev->pcidev, priv->SendCtl[ctx].dma,
@@ -676,7 +676,7 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
676 676
677 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n", 677 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
678 IOC_AND_NETDEV_NAMES_s_s(dev), 678 IOC_AND_NETDEV_NAMES_s_s(dev),
679 __FUNCTION__, sent)); 679 __func__, sent));
680 680
681 priv->SendCtl[ctx].skb = NULL; 681 priv->SendCtl[ctx].skb = NULL;
682 pci_unmap_single(mpt_dev->pcidev, priv->SendCtl[ctx].dma, 682 pci_unmap_single(mpt_dev->pcidev, priv->SendCtl[ctx].dma,
@@ -715,7 +715,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
715 u16 cur_naa = 0x1000; 715 u16 cur_naa = 0x1000;
716 716
717 dioprintk((KERN_INFO MYNAM ": %s called, skb_addr = %p\n", 717 dioprintk((KERN_INFO MYNAM ": %s called, skb_addr = %p\n",
718 __FUNCTION__, skb)); 718 __func__, skb));
719 719
720 spin_lock_irqsave(&priv->txfidx_lock, flags); 720 spin_lock_irqsave(&priv->txfidx_lock, flags);
721 if (priv->mpt_txfidx_tail < 0) { 721 if (priv->mpt_txfidx_tail < 0) {
@@ -723,7 +723,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
723 spin_unlock_irqrestore(&priv->txfidx_lock, flags); 723 spin_unlock_irqrestore(&priv->txfidx_lock, flags);
724 724
725 printk (KERN_ERR "%s: no tx context available: %u\n", 725 printk (KERN_ERR "%s: no tx context available: %u\n",
726 __FUNCTION__, priv->mpt_txfidx_tail); 726 __func__, priv->mpt_txfidx_tail);
727 return 1; 727 return 1;
728 } 728 }
729 729
@@ -733,7 +733,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
733 spin_unlock_irqrestore(&priv->txfidx_lock, flags); 733 spin_unlock_irqrestore(&priv->txfidx_lock, flags);
734 734
735 printk (KERN_ERR "%s: Unable to alloc request frame\n", 735 printk (KERN_ERR "%s: Unable to alloc request frame\n",
736 __FUNCTION__); 736 __func__);
737 return 1; 737 return 1;
738 } 738 }
739 739
@@ -1208,7 +1208,7 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1208 1208
1209 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, Start_buckets = %u, buckets_out = %u\n", 1209 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, Start_buckets = %u, buckets_out = %u\n",
1210 IOC_AND_NETDEV_NAMES_s_s(dev), 1210 IOC_AND_NETDEV_NAMES_s_s(dev),
1211 __FUNCTION__, buckets, curr)); 1211 __func__, buckets, curr));
1212 1212
1213 max = (mpt_dev->req_sz - MPT_LAN_RECEIVE_POST_REQUEST_SIZE) / 1213 max = (mpt_dev->req_sz - MPT_LAN_RECEIVE_POST_REQUEST_SIZE) /
1214 (MPT_LAN_TRANSACTION32_SIZE + sizeof(SGESimple64_t)); 1214 (MPT_LAN_TRANSACTION32_SIZE + sizeof(SGESimple64_t));
@@ -1217,9 +1217,9 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1217 mf = mpt_get_msg_frame(LanCtx, mpt_dev); 1217 mf = mpt_get_msg_frame(LanCtx, mpt_dev);
1218 if (mf == NULL) { 1218 if (mf == NULL) {
1219 printk (KERN_ERR "%s: Unable to alloc request frame\n", 1219 printk (KERN_ERR "%s: Unable to alloc request frame\n",
1220 __FUNCTION__); 1220 __func__);
1221 dioprintk((KERN_ERR "%s: %u buckets remaining\n", 1221 dioprintk((KERN_ERR "%s: %u buckets remaining\n",
1222 __FUNCTION__, buckets)); 1222 __func__, buckets));
1223 goto out; 1223 goto out;
1224 } 1224 }
1225 pRecvReq = (LANReceivePostRequest_t *) mf; 1225 pRecvReq = (LANReceivePostRequest_t *) mf;
@@ -1244,7 +1244,7 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1244 spin_lock_irqsave(&priv->rxfidx_lock, flags); 1244 spin_lock_irqsave(&priv->rxfidx_lock, flags);
1245 if (priv->mpt_rxfidx_tail < 0) { 1245 if (priv->mpt_rxfidx_tail < 0) {
1246 printk (KERN_ERR "%s: Can't alloc context\n", 1246 printk (KERN_ERR "%s: Can't alloc context\n",
1247 __FUNCTION__); 1247 __func__);
1248 spin_unlock_irqrestore(&priv->rxfidx_lock, 1248 spin_unlock_irqrestore(&priv->rxfidx_lock,
1249 flags); 1249 flags);
1250 break; 1250 break;
@@ -1267,7 +1267,7 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1267 if (skb == NULL) { 1267 if (skb == NULL) {
1268 printk (KERN_WARNING 1268 printk (KERN_WARNING
1269 MYNAM "/%s: Can't alloc skb\n", 1269 MYNAM "/%s: Can't alloc skb\n",
1270 __FUNCTION__); 1270 __func__);
1271 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx; 1271 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = ctx;
1272 spin_unlock_irqrestore(&priv->rxfidx_lock, flags); 1272 spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
1273 break; 1273 break;
@@ -1305,7 +1305,7 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1305 1305
1306 if (pSimple == NULL) { 1306 if (pSimple == NULL) {
1307/**/ printk (KERN_WARNING MYNAM "/%s: No buckets posted\n", 1307/**/ printk (KERN_WARNING MYNAM "/%s: No buckets posted\n",
1308/**/ __FUNCTION__); 1308/**/ __func__);
1309 mpt_free_msg_frame(mpt_dev, mf); 1309 mpt_free_msg_frame(mpt_dev, mf);
1310 goto out; 1310 goto out;
1311 } 1311 }
@@ -1329,9 +1329,9 @@ mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1329 1329
1330out: 1330out:
1331 dioprintk((KERN_INFO MYNAM "/%s: End_buckets = %u, priv->buckets_out = %u\n", 1331 dioprintk((KERN_INFO MYNAM "/%s: End_buckets = %u, priv->buckets_out = %u\n",
1332 __FUNCTION__, buckets, atomic_read(&priv->buckets_out))); 1332 __func__, buckets, atomic_read(&priv->buckets_out)));
1333 dioprintk((KERN_INFO MYNAM "/%s: Posted %u buckets and received %u back\n", 1333 dioprintk((KERN_INFO MYNAM "/%s: Posted %u buckets and received %u back\n",
1334 __FUNCTION__, priv->total_posted, priv->total_received)); 1334 __func__, priv->total_posted, priv->total_received));
1335 1335
1336 clear_bit(0, &priv->post_buckets_active); 1336 clear_bit(0, &priv->post_buckets_active);
1337} 1337}
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index b1147aa7afde..12b732512e57 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -300,7 +300,7 @@ mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_detai
300 phy_info = port_info->phy_info; 300 phy_info = port_info->phy_info;
301 301
302 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d " 302 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d "
303 "bitmask=0x%016llX\n", ioc->name, __FUNCTION__, port_details, 303 "bitmask=0x%016llX\n", ioc->name, __func__, port_details,
304 port_details->num_phys, (unsigned long long) 304 port_details->num_phys, (unsigned long long)
305 port_details->phy_bitmask)); 305 port_details->phy_bitmask));
306 306
@@ -411,7 +411,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
411 */ 411 */
412 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT 412 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
413 "%s: [%p]: deleting phy = %d\n", 413 "%s: [%p]: deleting phy = %d\n",
414 ioc->name, __FUNCTION__, port_details, i)); 414 ioc->name, __func__, port_details, i));
415 port_details->num_phys--; 415 port_details->num_phys--;
416 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); 416 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id);
417 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); 417 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo));
@@ -497,7 +497,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
497 continue; 497 continue;
498 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT 498 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
499 "%s: [%p]: phy_id=%02d num_phys=%02d " 499 "%s: [%p]: phy_id=%02d num_phys=%02d "
500 "bitmask=0x%016llX\n", ioc->name, __FUNCTION__, 500 "bitmask=0x%016llX\n", ioc->name, __func__,
501 port_details, i, port_details->num_phys, 501 port_details, i, port_details->num_phys,
502 (unsigned long long)port_details->phy_bitmask)); 502 (unsigned long long)port_details->phy_bitmask));
503 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n", 503 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n",
@@ -553,7 +553,7 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
553 553
554 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) { 554 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
555 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames @%d!!\n", 555 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames @%d!!\n",
556 ioc->name,__FUNCTION__, __LINE__)); 556 ioc->name,__func__, __LINE__));
557 return 0; 557 return 0;
558 } 558 }
559 559
@@ -606,7 +606,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,
606 GFP_ATOMIC); 606 GFP_ATOMIC);
607 if (!target_reset_list) { 607 if (!target_reset_list) {
608 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", 608 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n",
609 ioc->name,__FUNCTION__, __LINE__)); 609 ioc->name,__func__, __LINE__));
610 return; 610 return;
611 } 611 }
612 612
@@ -673,7 +673,7 @@ mptsas_dev_reset_complete(MPT_ADAPTER *ioc)
673 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 673 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
674 if (!ev) { 674 if (!ev) {
675 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", 675 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n",
676 ioc->name,__FUNCTION__, __LINE__)); 676 ioc->name,__func__, __LINE__));
677 return; 677 return;
678 } 678 }
679 679
@@ -1183,7 +1183,7 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
1183 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply; 1183 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply;
1184 if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) { 1184 if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) {
1185 printk(MYIOC_s_INFO_FMT "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n", 1185 printk(MYIOC_s_INFO_FMT "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
1186 ioc->name, __FUNCTION__, reply->IOCStatus, reply->IOCLogInfo); 1186 ioc->name, __func__, reply->IOCStatus, reply->IOCLogInfo);
1187 error = -ENXIO; 1187 error = -ENXIO;
1188 goto out_unlock; 1188 goto out_unlock;
1189 } 1189 }
@@ -1270,14 +1270,14 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1270 1270
1271 if (!rsp) { 1271 if (!rsp) {
1272 printk(MYIOC_s_ERR_FMT "%s: the smp response space is missing\n", 1272 printk(MYIOC_s_ERR_FMT "%s: the smp response space is missing\n",
1273 ioc->name, __FUNCTION__); 1273 ioc->name, __func__);
1274 return -EINVAL; 1274 return -EINVAL;
1275 } 1275 }
1276 1276
1277 /* do we need to support multiple segments? */ 1277 /* do we need to support multiple segments? */
1278 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { 1278 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
1279 printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n", 1279 printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n",
1280 ioc->name, __FUNCTION__, req->bio->bi_vcnt, req->data_len, 1280 ioc->name, __func__, req->bio->bi_vcnt, req->data_len,
1281 rsp->bio->bi_vcnt, rsp->data_len); 1281 rsp->bio->bi_vcnt, rsp->data_len);
1282 return -EINVAL; 1282 return -EINVAL;
1283 } 1283 }
@@ -1343,7 +1343,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1343 1343
1344 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); 1344 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
1345 if (!timeleft) { 1345 if (!timeleft) {
1346 printk(MYIOC_s_ERR_FMT "%s: smp timeout!\n", ioc->name, __FUNCTION__); 1346 printk(MYIOC_s_ERR_FMT "%s: smp timeout!\n", ioc->name, __func__);
1347 /* On timeout reset the board */ 1347 /* On timeout reset the board */
1348 mpt_HardResetHandler(ioc, CAN_SLEEP); 1348 mpt_HardResetHandler(ioc, CAN_SLEEP);
1349 ret = -ETIMEDOUT; 1349 ret = -ETIMEDOUT;
@@ -1361,7 +1361,7 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1361 rsp->data_len -= smprep->ResponseDataLength; 1361 rsp->data_len -= smprep->ResponseDataLength;
1362 } else { 1362 } else {
1363 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n", 1363 printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n",
1364 ioc->name, __FUNCTION__); 1364 ioc->name, __func__);
1365 ret = -ENXIO; 1365 ret = -ENXIO;
1366 } 1366 }
1367unmap: 1367unmap:
@@ -2006,7 +2006,7 @@ static int mptsas_probe_one_phy(struct device *dev,
2006 if (error) { 2006 if (error) {
2007 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2007 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2008 "%s: exit at line=%d\n", ioc->name, 2008 "%s: exit at line=%d\n", ioc->name,
2009 __FUNCTION__, __LINE__)); 2009 __func__, __LINE__));
2010 goto out; 2010 goto out;
2011 } 2011 }
2012 mptsas_set_port(ioc, phy_info, port); 2012 mptsas_set_port(ioc, phy_info, port);
@@ -2076,7 +2076,7 @@ static int mptsas_probe_one_phy(struct device *dev,
2076 if (!rphy) { 2076 if (!rphy) {
2077 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2077 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2078 "%s: exit at line=%d\n", ioc->name, 2078 "%s: exit at line=%d\n", ioc->name,
2079 __FUNCTION__, __LINE__)); 2079 __func__, __LINE__));
2080 goto out; 2080 goto out;
2081 } 2081 }
2082 2082
@@ -2085,7 +2085,7 @@ static int mptsas_probe_one_phy(struct device *dev,
2085 if (error) { 2085 if (error) {
2086 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2086 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2087 "%s: exit at line=%d\n", ioc->name, 2087 "%s: exit at line=%d\n", ioc->name,
2088 __FUNCTION__, __LINE__)); 2088 __func__, __LINE__));
2089 sas_rphy_free(rphy); 2089 sas_rphy_free(rphy);
2090 goto out; 2090 goto out;
2091 } 2091 }
@@ -2613,7 +2613,7 @@ mptsas_hotplug_work(struct work_struct *work)
2613 (ev->channel << 8) + ev->id)) { 2613 (ev->channel << 8) + ev->id)) {
2614 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2614 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2615 "%s: exit at line=%d\n", ioc->name, 2615 "%s: exit at line=%d\n", ioc->name,
2616 __FUNCTION__, __LINE__)); 2616 __func__, __LINE__));
2617 break; 2617 break;
2618 } 2618 }
2619 phy_info = mptsas_find_phyinfo_by_sas_address( 2619 phy_info = mptsas_find_phyinfo_by_sas_address(
@@ -2633,20 +2633,20 @@ mptsas_hotplug_work(struct work_struct *work)
2633 if (!phy_info){ 2633 if (!phy_info){
2634 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2634 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2635 "%s: exit at line=%d\n", ioc->name, 2635 "%s: exit at line=%d\n", ioc->name,
2636 __FUNCTION__, __LINE__)); 2636 __func__, __LINE__));
2637 break; 2637 break;
2638 } 2638 }
2639 if (!phy_info->port_details) { 2639 if (!phy_info->port_details) {
2640 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2640 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2641 "%s: exit at line=%d\n", ioc->name, 2641 "%s: exit at line=%d\n", ioc->name,
2642 __FUNCTION__, __LINE__)); 2642 __func__, __LINE__));
2643 break; 2643 break;
2644 } 2644 }
2645 rphy = mptsas_get_rphy(phy_info); 2645 rphy = mptsas_get_rphy(phy_info);
2646 if (!rphy) { 2646 if (!rphy) {
2647 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2647 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2648 "%s: exit at line=%d\n", ioc->name, 2648 "%s: exit at line=%d\n", ioc->name,
2649 __FUNCTION__, __LINE__)); 2649 __func__, __LINE__));
2650 break; 2650 break;
2651 } 2651 }
2652 2652
@@ -2654,7 +2654,7 @@ mptsas_hotplug_work(struct work_struct *work)
2654 if (!port) { 2654 if (!port) {
2655 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2655 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2656 "%s: exit at line=%d\n", ioc->name, 2656 "%s: exit at line=%d\n", ioc->name,
2657 __FUNCTION__, __LINE__)); 2657 __func__, __LINE__));
2658 break; 2658 break;
2659 } 2659 }
2660 2660
@@ -2665,7 +2665,7 @@ mptsas_hotplug_work(struct work_struct *work)
2665 if (!vtarget) { 2665 if (!vtarget) {
2666 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2666 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2667 "%s: exit at line=%d\n", ioc->name, 2667 "%s: exit at line=%d\n", ioc->name,
2668 __FUNCTION__, __LINE__)); 2668 __func__, __LINE__));
2669 break; 2669 break;
2670 } 2670 }
2671 2671
@@ -2720,7 +2720,7 @@ mptsas_hotplug_work(struct work_struct *work)
2720 (ev->channel << 8) + ev->id)) { 2720 (ev->channel << 8) + ev->id)) {
2721 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2721 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2722 "%s: exit at line=%d\n", ioc->name, 2722 "%s: exit at line=%d\n", ioc->name,
2723 __FUNCTION__, __LINE__)); 2723 __func__, __LINE__));
2724 break; 2724 break;
2725 } 2725 }
2726 2726
@@ -2732,7 +2732,7 @@ mptsas_hotplug_work(struct work_struct *work)
2732 if (!phy_info || !phy_info->port_details) { 2732 if (!phy_info || !phy_info->port_details) {
2733 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2733 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2734 "%s: exit at line=%d\n", ioc->name, 2734 "%s: exit at line=%d\n", ioc->name,
2735 __FUNCTION__, __LINE__)); 2735 __func__, __LINE__));
2736 break; 2736 break;
2737 } 2737 }
2738 2738
@@ -2744,7 +2744,7 @@ mptsas_hotplug_work(struct work_struct *work)
2744 if (!vtarget) { 2744 if (!vtarget) {
2745 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2745 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2746 "%s: exit at line=%d\n", ioc->name, 2746 "%s: exit at line=%d\n", ioc->name,
2747 __FUNCTION__, __LINE__)); 2747 __func__, __LINE__));
2748 break; 2748 break;
2749 } 2749 }
2750 /* 2750 /*
@@ -2767,7 +2767,7 @@ mptsas_hotplug_work(struct work_struct *work)
2767 if (mptsas_get_rphy(phy_info)) { 2767 if (mptsas_get_rphy(phy_info)) {
2768 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2768 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2769 "%s: exit at line=%d\n", ioc->name, 2769 "%s: exit at line=%d\n", ioc->name,
2770 __FUNCTION__, __LINE__)); 2770 __func__, __LINE__));
2771 if (ev->channel) printk("%d\n", __LINE__); 2771 if (ev->channel) printk("%d\n", __LINE__);
2772 break; 2772 break;
2773 } 2773 }
@@ -2776,7 +2776,7 @@ mptsas_hotplug_work(struct work_struct *work)
2776 if (!port) { 2776 if (!port) {
2777 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2777 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2778 "%s: exit at line=%d\n", ioc->name, 2778 "%s: exit at line=%d\n", ioc->name,
2779 __FUNCTION__, __LINE__)); 2779 __func__, __LINE__));
2780 break; 2780 break;
2781 } 2781 }
2782 memcpy(&phy_info->attached, &sas_device, 2782 memcpy(&phy_info->attached, &sas_device,
@@ -2801,7 +2801,7 @@ mptsas_hotplug_work(struct work_struct *work)
2801 if (!rphy) { 2801 if (!rphy) {
2802 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2802 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2803 "%s: exit at line=%d\n", ioc->name, 2803 "%s: exit at line=%d\n", ioc->name,
2804 __FUNCTION__, __LINE__)); 2804 __func__, __LINE__));
2805 break; /* non-fatal: an rphy can be added later */ 2805 break; /* non-fatal: an rphy can be added later */
2806 } 2806 }
2807 2807
@@ -2809,7 +2809,7 @@ mptsas_hotplug_work(struct work_struct *work)
2809 if (sas_rphy_add(rphy)) { 2809 if (sas_rphy_add(rphy)) {
2810 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT 2810 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2811 "%s: exit at line=%d\n", ioc->name, 2811 "%s: exit at line=%d\n", ioc->name,
2812 __FUNCTION__, __LINE__)); 2812 __func__, __LINE__));
2813 sas_rphy_free(rphy); 2813 sas_rphy_free(rphy);
2814 break; 2814 break;
2815 } 2815 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index d142b6b4b976..9f9354fd3516 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -461,7 +461,7 @@ mptscsih_issue_sep_command(MPT_ADAPTER *ioc, VirtTarget *vtarget,
461 461
462 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) { 462 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
463 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: no msg frames!!\n", 463 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: no msg frames!!\n",
464 ioc->name,__FUNCTION__)); 464 ioc->name,__func__));
465 return; 465 return;
466 } 466 }
467 467
@@ -2187,7 +2187,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2187 (ioc->debug_level & MPT_DEBUG_TM )) 2187 (ioc->debug_level & MPT_DEBUG_TM ))
2188 printk("%s: ha=%d [%d:%d:0] task_type=0x%02X " 2188 printk("%s: ha=%d [%d:%d:0] task_type=0x%02X "
2189 "iocstatus=0x%04X\n\tloginfo=0x%08X response_code=0x%02X " 2189 "iocstatus=0x%04X\n\tloginfo=0x%08X response_code=0x%02X "
2190 "term_cmnds=%d\n", __FUNCTION__, ioc->id, pScsiTmReply->Bus, 2190 "term_cmnds=%d\n", __func__, ioc->id, pScsiTmReply->Bus,
2191 pScsiTmReply->TargetID, pScsiTmReq->TaskType, 2191 pScsiTmReply->TargetID, pScsiTmReq->TaskType,
2192 le16_to_cpu(pScsiTmReply->IOCStatus), 2192 le16_to_cpu(pScsiTmReply->IOCStatus),
2193 le32_to_cpu(pScsiTmReply->IOCLogInfo),pScsiTmReply->ResponseCode, 2193 le32_to_cpu(pScsiTmReply->IOCLogInfo),pScsiTmReply->ResponseCode,
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 3b870e7fb3e1..c6408a62d95e 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -256,28 +256,28 @@ static int asic3_gpio_irq_type(unsigned int irq, unsigned int type)
256 bank + ASIC3_GPIO_TRIGGER_TYPE); 256 bank + ASIC3_GPIO_TRIGGER_TYPE);
257 asic->irq_bothedge[(irq - asic->irq_base) >> 4] &= ~bit; 257 asic->irq_bothedge[(irq - asic->irq_base) >> 4] &= ~bit;
258 258
259 if (type == IRQT_RISING) { 259 if (type == IRQ_TYPE_EDGE_RISING) {
260 trigger |= bit; 260 trigger |= bit;
261 edge |= bit; 261 edge |= bit;
262 } else if (type == IRQT_FALLING) { 262 } else if (type == IRQ_TYPE_EDGE_FALLING) {
263 trigger |= bit; 263 trigger |= bit;
264 edge &= ~bit; 264 edge &= ~bit;
265 } else if (type == IRQT_BOTHEDGE) { 265 } else if (type == IRQ_TYPE_EDGE_BOTH) {
266 trigger |= bit; 266 trigger |= bit;
267 if (asic3_gpio_get(&asic->gpio, irq - asic->irq_base)) 267 if (asic3_gpio_get(&asic->gpio, irq - asic->irq_base))
268 edge &= ~bit; 268 edge &= ~bit;
269 else 269 else
270 edge |= bit; 270 edge |= bit;
271 asic->irq_bothedge[(irq - asic->irq_base) >> 4] |= bit; 271 asic->irq_bothedge[(irq - asic->irq_base) >> 4] |= bit;
272 } else if (type == IRQT_LOW) { 272 } else if (type == IRQ_TYPE_LEVEL_LOW) {
273 trigger &= ~bit; 273 trigger &= ~bit;
274 level &= ~bit; 274 level &= ~bit;
275 } else if (type == IRQT_HIGH) { 275 } else if (type == IRQ_TYPE_LEVEL_HIGH) {
276 trigger &= ~bit; 276 trigger &= ~bit;
277 level |= bit; 277 level |= bit;
278 } else { 278 } else {
279 /* 279 /*
280 * if type == IRQT_NOEDGE, we should mask interrupts, but 280 * if type == IRQ_TYPE_NONE, we should mask interrupts, but
281 * be careful to not unmask them if mask was also called. 281 * be careful to not unmask them if mask was also called.
282 * Probably need internal state for mask. 282 * Probably need internal state for mask.
283 */ 283 */
@@ -314,10 +314,12 @@ static int __init asic3_irq_probe(struct platform_device *pdev)
314 unsigned long clksel = 0; 314 unsigned long clksel = 0;
315 unsigned int irq, irq_base; 315 unsigned int irq, irq_base;
316 int map_size; 316 int map_size;
317 int ret;
317 318
318 asic->irq_nr = platform_get_irq(pdev, 0); 319 ret = platform_get_irq(pdev, 0);
319 if (asic->irq_nr < 0) 320 if (ret < 0)
320 return asic->irq_nr; 321 return ret;
322 asic->irq_nr = ret;
321 323
322 /* turn on clock to IRQ controller */ 324 /* turn on clock to IRQ controller */
323 clksel |= CLOCK_SEL_CX; 325 clksel |= CLOCK_SEL_CX;
@@ -341,7 +343,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev)
341 ASIC3_INTMASK_GINTMASK); 343 ASIC3_INTMASK_GINTMASK);
342 344
343 set_irq_chained_handler(asic->irq_nr, asic3_irq_demux); 345 set_irq_chained_handler(asic->irq_nr, asic3_irq_demux);
344 set_irq_type(asic->irq_nr, IRQT_RISING); 346 set_irq_type(asic->irq_nr, IRQ_TYPE_EDGE_RISING);
345 set_irq_data(asic->irq_nr, asic); 347 set_irq_data(asic->irq_nr, asic);
346 348
347 return 0; 349 return 0;
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 0454be4266c1..9c9c126ed334 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -15,24 +15,24 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/mfd/core.h> 16#include <linux/mfd/core.h>
17 17
18static int mfd_add_device(struct platform_device *parent, 18static int mfd_add_device(struct device *parent, int id,
19 const struct mfd_cell *cell, 19 const struct mfd_cell *cell,
20 struct resource *mem_base, 20 struct resource *mem_base,
21 int irq_base) 21 int irq_base)
22{ 22{
23 struct resource res[cell->num_resources]; 23 struct resource res[cell->num_resources];
24 struct platform_device *pdev; 24 struct platform_device *pdev;
25 int ret = -ENOMEM; 25 int ret = -ENOMEM;
26 int r; 26 int r;
27 27
28 pdev = platform_device_alloc(cell->name, parent->id); 28 pdev = platform_device_alloc(cell->name, id);
29 if (!pdev) 29 if (!pdev)
30 goto fail_alloc; 30 goto fail_alloc;
31 31
32 pdev->dev.parent = &parent->dev; 32 pdev->dev.parent = parent;
33 33
34 ret = platform_device_add_data(pdev, 34 ret = platform_device_add_data(pdev,
35 cell, sizeof(struct mfd_cell)); 35 cell->platform_data, cell->data_size);
36 if (ret) 36 if (ret)
37 goto fail_device; 37 goto fail_device;
38 38
@@ -75,17 +75,16 @@ fail_alloc:
75 return ret; 75 return ret;
76} 76}
77 77
78int mfd_add_devices( 78int mfd_add_devices(struct device *parent, int id,
79 struct platform_device *parent, 79 const struct mfd_cell *cells, int n_devs,
80 const struct mfd_cell *cells, int n_devs, 80 struct resource *mem_base,
81 struct resource *mem_base, 81 int irq_base)
82 int irq_base)
83{ 82{
84 int i; 83 int i;
85 int ret = 0; 84 int ret = 0;
86 85
87 for (i = 0; i < n_devs; i++) { 86 for (i = 0; i < n_devs; i++) {
88 ret = mfd_add_device(parent, cells + i, mem_base, irq_base); 87 ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base);
89 if (ret) 88 if (ret)
90 break; 89 break;
91 } 90 }
@@ -99,14 +98,13 @@ EXPORT_SYMBOL(mfd_add_devices);
99 98
100static int mfd_remove_devices_fn(struct device *dev, void *unused) 99static int mfd_remove_devices_fn(struct device *dev, void *unused)
101{ 100{
102 platform_device_unregister( 101 platform_device_unregister(to_platform_device(dev));
103 container_of(dev, struct platform_device, dev));
104 return 0; 102 return 0;
105} 103}
106 104
107void mfd_remove_devices(struct platform_device *parent) 105void mfd_remove_devices(struct device *parent)
108{ 106{
109 device_for_each_child(&parent->dev, NULL, mfd_remove_devices_fn); 107 device_for_each_child(parent, NULL, mfd_remove_devices_fn);
110} 108}
111EXPORT_SYMBOL(mfd_remove_devices); 109EXPORT_SYMBOL(mfd_remove_devices);
112 110
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index 2d87501b6fd4..f4fd797c1590 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -324,7 +324,7 @@ static void tc6393xb_attach_irq(struct platform_device *dev)
324 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 324 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
325 } 325 }
326 326
327 set_irq_type(tc6393xb->irq, IRQT_FALLING); 327 set_irq_type(tc6393xb->irq, IRQ_TYPE_EDGE_FALLING);
328 set_irq_data(tc6393xb->irq, tc6393xb); 328 set_irq_data(tc6393xb->irq, tc6393xb);
329 set_irq_chained_handler(tc6393xb->irq, tc6393xb_irq); 329 set_irq_chained_handler(tc6393xb->irq, tc6393xb_irq);
330} 330}
@@ -466,8 +466,12 @@ static int __devinit tc6393xb_probe(struct platform_device *dev)
466 tc6393xb_attach_irq(dev); 466 tc6393xb_attach_irq(dev);
467 467
468 tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; 468 tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data;
469 tc6393xb_cells[TC6393XB_CELL_NAND].platform_data =
470 &tc6393xb_cells[TC6393XB_CELL_NAND];
471 tc6393xb_cells[TC6393XB_CELL_NAND].data_size =
472 sizeof(tc6393xb_cells[TC6393XB_CELL_NAND]);
469 473
470 retval = mfd_add_devices(dev, 474 retval = mfd_add_devices(&dev->dev, dev->id,
471 tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), 475 tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
472 iomem, tcpd->irq_base); 476 iomem, tcpd->irq_base);
473 477
@@ -501,7 +505,7 @@ static int __devexit tc6393xb_remove(struct platform_device *dev)
501 struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 505 struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
502 int ret; 506 int ret;
503 507
504 mfd_remove_devices(dev); 508 mfd_remove_devices(&dev->dev);
505 509
506 if (tc6393xb->irq) 510 if (tc6393xb->irq)
507 tc6393xb_detach_irq(dev); 511 tc6393xb_detach_irq(dev);
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 321eb9134635..f5ade1904aad 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -360,7 +360,7 @@ config THINKPAD_ACPI_VIDEO
360 If you are not sure, say Y here. 360 If you are not sure, say Y here.
361 361
362config THINKPAD_ACPI_HOTKEY_POLL 362config THINKPAD_ACPI_HOTKEY_POLL
363 bool "Suport NVRAM polling for hot keys" 363 bool "Support NVRAM polling for hot keys"
364 depends on THINKPAD_ACPI 364 depends on THINKPAD_ACPI
365 default y 365 default y
366 ---help--- 366 ---help---
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index e171650766ce..bf5e4d065436 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -13,7 +13,6 @@
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/list.h>
17#include <linux/spinlock.h> 16#include <linux/spinlock.h>
18#include <linux/atmel-ssc.h> 17#include <linux/atmel-ssc.h>
19 18
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 579b01ff82d4..c3b4227f48a5 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -229,11 +229,10 @@ xpc_hb_checker(void *ignore)
229 int last_IRQ_count = 0; 229 int last_IRQ_count = 0;
230 int new_IRQ_count; 230 int new_IRQ_count;
231 int force_IRQ = 0; 231 int force_IRQ = 0;
232 cpumask_of_cpu_ptr(cpumask, XPC_HB_CHECK_CPU);
233 232
234 /* this thread was marked active by xpc_hb_init() */ 233 /* this thread was marked active by xpc_hb_init() */
235 234
236 set_cpus_allowed_ptr(current, cpumask); 235 set_cpus_allowed_ptr(current, &cpumask_of_cpu(XPC_HB_CHECK_CPU));
237 236
238 /* set our heartbeating to other partitions into motion */ 237 /* set our heartbeating to other partitions into motion */
239 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ); 238 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index 19a1a254a0c5..889e5f898f6f 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -12,3 +12,4 @@ mmc_core-y := core.o bus.o host.o \
12 sdio.o sdio_ops.o sdio_bus.o \ 12 sdio.o sdio_ops.o sdio_bus.o \
13 sdio_cis.o sdio_io.o sdio_irq.o 13 sdio_cis.o sdio_io.o sdio_irq.o
14 14
15mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index fd95b18e988b..0d9b2d6f9ebf 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -252,6 +252,10 @@ int mmc_add_card(struct mmc_card *card)
252 if (ret) 252 if (ret)
253 return ret; 253 return ret;
254 254
255#ifdef CONFIG_DEBUG_FS
256 mmc_add_card_debugfs(card);
257#endif
258
255 mmc_card_set_present(card); 259 mmc_card_set_present(card);
256 260
257 return 0; 261 return 0;
@@ -263,6 +267,10 @@ int mmc_add_card(struct mmc_card *card)
263 */ 267 */
264void mmc_remove_card(struct mmc_card *card) 268void mmc_remove_card(struct mmc_card *card)
265{ 269{
270#ifdef CONFIG_DEBUG_FS
271 mmc_remove_card_debugfs(card);
272#endif
273
266 if (mmc_card_present(card)) { 274 if (mmc_card_present(card)) {
267 if (mmc_host_is_spi(card->host)) { 275 if (mmc_host_is_spi(card->host)) {
268 printk(KERN_INFO "%s: SPI card removed\n", 276 printk(KERN_INFO "%s: SPI card removed\n",
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index cdb332b7dedc..c819effa1032 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -52,5 +52,12 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
52 52
53extern int use_spi_crc; 53extern int use_spi_crc;
54 54
55/* Debugfs information for hosts and cards */
56void mmc_add_host_debugfs(struct mmc_host *host);
57void mmc_remove_host_debugfs(struct mmc_host *host);
58
59void mmc_add_card_debugfs(struct mmc_card *card);
60void mmc_remove_card_debugfs(struct mmc_card *card);
61
55#endif 62#endif
56 63
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
new file mode 100644
index 000000000000..1237bb4c722b
--- /dev/null
+++ b/drivers/mmc/core/debugfs.c
@@ -0,0 +1,225 @@
1/*
2 * Debugfs support for hosts and cards
3 *
4 * Copyright (C) 2008 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/debugfs.h>
11#include <linux/fs.h>
12#include <linux/seq_file.h>
13#include <linux/stat.h>
14
15#include <linux/mmc/card.h>
16#include <linux/mmc/host.h>
17
18#include "core.h"
19#include "mmc_ops.h"
20
21/* The debugfs functions are optimized away when CONFIG_DEBUG_FS isn't set. */
22static int mmc_ios_show(struct seq_file *s, void *data)
23{
24 static const char *vdd_str[] = {
25 [8] = "2.0",
26 [9] = "2.1",
27 [10] = "2.2",
28 [11] = "2.3",
29 [12] = "2.4",
30 [13] = "2.5",
31 [14] = "2.6",
32 [15] = "2.7",
33 [16] = "2.8",
34 [17] = "2.9",
35 [18] = "3.0",
36 [19] = "3.1",
37 [20] = "3.2",
38 [21] = "3.3",
39 [22] = "3.4",
40 [23] = "3.5",
41 [24] = "3.6",
42 };
43 struct mmc_host *host = s->private;
44 struct mmc_ios *ios = &host->ios;
45 const char *str;
46
47 seq_printf(s, "clock:\t\t%u Hz\n", ios->clock);
48 seq_printf(s, "vdd:\t\t%u ", ios->vdd);
49 if ((1 << ios->vdd) & MMC_VDD_165_195)
50 seq_printf(s, "(1.65 - 1.95 V)\n");
51 else if (ios->vdd < (ARRAY_SIZE(vdd_str) - 1)
52 && vdd_str[ios->vdd] && vdd_str[ios->vdd + 1])
53 seq_printf(s, "(%s ~ %s V)\n", vdd_str[ios->vdd],
54 vdd_str[ios->vdd + 1]);
55 else
56 seq_printf(s, "(invalid)\n");
57
58 switch (ios->bus_mode) {
59 case MMC_BUSMODE_OPENDRAIN:
60 str = "open drain";
61 break;
62 case MMC_BUSMODE_PUSHPULL:
63 str = "push-pull";
64 break;
65 default:
66 str = "invalid";
67 break;
68 }
69 seq_printf(s, "bus mode:\t%u (%s)\n", ios->bus_mode, str);
70
71 switch (ios->chip_select) {
72 case MMC_CS_DONTCARE:
73 str = "don't care";
74 break;
75 case MMC_CS_HIGH:
76 str = "active high";
77 break;
78 case MMC_CS_LOW:
79 str = "active low";
80 break;
81 default:
82 str = "invalid";
83 break;
84 }
85 seq_printf(s, "chip select:\t%u (%s)\n", ios->chip_select, str);
86
87 switch (ios->power_mode) {
88 case MMC_POWER_OFF:
89 str = "off";
90 break;
91 case MMC_POWER_UP:
92 str = "up";
93 break;
94 case MMC_POWER_ON:
95 str = "on";
96 break;
97 default:
98 str = "invalid";
99 break;
100 }
101 seq_printf(s, "power mode:\t%u (%s)\n", ios->power_mode, str);
102 seq_printf(s, "bus width:\t%u (%u bits)\n",
103 ios->bus_width, 1 << ios->bus_width);
104
105 switch (ios->timing) {
106 case MMC_TIMING_LEGACY:
107 str = "legacy";
108 break;
109 case MMC_TIMING_MMC_HS:
110 str = "mmc high-speed";
111 break;
112 case MMC_TIMING_SD_HS:
113 str = "sd high-speed";
114 break;
115 default:
116 str = "invalid";
117 break;
118 }
119 seq_printf(s, "timing spec:\t%u (%s)\n", ios->timing, str);
120
121 return 0;
122}
123
124static int mmc_ios_open(struct inode *inode, struct file *file)
125{
126 return single_open(file, mmc_ios_show, inode->i_private);
127}
128
129static const struct file_operations mmc_ios_fops = {
130 .open = mmc_ios_open,
131 .read = seq_read,
132 .llseek = seq_lseek,
133 .release = single_release,
134};
135
136void mmc_add_host_debugfs(struct mmc_host *host)
137{
138 struct dentry *root;
139
140 root = debugfs_create_dir(mmc_hostname(host), NULL);
141 if (IS_ERR(root))
142 /* Don't complain -- debugfs just isn't enabled */
143 return;
144 if (!root)
145 /* Complain -- debugfs is enabled, but it failed to
146 * create the directory. */
147 goto err_root;
148
149 host->debugfs_root = root;
150
151 if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops))
152 goto err_ios;
153
154 return;
155
156err_ios:
157 debugfs_remove_recursive(root);
158 host->debugfs_root = NULL;
159err_root:
160 dev_err(&host->class_dev, "failed to initialize debugfs\n");
161}
162
163void mmc_remove_host_debugfs(struct mmc_host *host)
164{
165 debugfs_remove_recursive(host->debugfs_root);
166}
167
168static int mmc_dbg_card_status_get(void *data, u64 *val)
169{
170 struct mmc_card *card = data;
171 u32 status;
172 int ret;
173
174 mmc_claim_host(card->host);
175
176 ret = mmc_send_status(data, &status);
177 if (!ret)
178 *val = status;
179
180 mmc_release_host(card->host);
181
182 return ret;
183}
184DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
185 NULL, "%08llx\n");
186
187void mmc_add_card_debugfs(struct mmc_card *card)
188{
189 struct mmc_host *host = card->host;
190 struct dentry *root;
191
192 if (!host->debugfs_root)
193 return;
194
195 root = debugfs_create_dir(mmc_card_id(card), host->debugfs_root);
196 if (IS_ERR(root))
197 /* Don't complain -- debugfs just isn't enabled */
198 return;
199 if (!root)
200 /* Complain -- debugfs is enabled, but it failed to
201 * create the directory. */
202 goto err;
203
204 card->debugfs_root = root;
205
206 if (!debugfs_create_x32("state", S_IRUSR, root, &card->state))
207 goto err;
208
209 if (mmc_card_mmc(card) || mmc_card_sd(card))
210 if (!debugfs_create_file("status", S_IRUSR, root, card,
211 &mmc_dbg_card_status_fops))
212 goto err;
213
214 return;
215
216err:
217 debugfs_remove_recursive(root);
218 card->debugfs_root = NULL;
219 dev_err(&card->dev, "failed to initialize debugfs\n");
220}
221
222void mmc_remove_card_debugfs(struct mmc_card *card)
223{
224 debugfs_remove_recursive(card->debugfs_root);
225}
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 1d795c5379b5..6da80fd4d974 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -127,6 +127,10 @@ int mmc_add_host(struct mmc_host *host)
127 if (err) 127 if (err)
128 return err; 128 return err;
129 129
130#ifdef CONFIG_DEBUG_FS
131 mmc_add_host_debugfs(host);
132#endif
133
130 mmc_start_host(host); 134 mmc_start_host(host);
131 135
132 return 0; 136 return 0;
@@ -146,6 +150,10 @@ void mmc_remove_host(struct mmc_host *host)
146{ 150{
147 mmc_stop_host(host); 151 mmc_stop_host(host);
148 152
153#ifdef CONFIG_DEBUG_FS
154 mmc_remove_host_debugfs(host);
155#endif
156
149 device_del(&host->class_dev); 157 device_del(&host->class_dev);
150 158
151 led_trigger_unregister_simple(host->led); 159 led_trigger_unregister_simple(host->led);
diff --git a/drivers/mmc/host/atmel-mci-regs.h b/drivers/mmc/host/atmel-mci-regs.h
index a9a5657706c6..26bd80e65031 100644
--- a/drivers/mmc/host/atmel-mci-regs.h
+++ b/drivers/mmc/host/atmel-mci-regs.h
@@ -82,6 +82,8 @@
82# define MCI_OVRE ( 1 << 30) /* RX Overrun Error */ 82# define MCI_OVRE ( 1 << 30) /* RX Overrun Error */
83# define MCI_UNRE ( 1 << 31) /* TX Underrun Error */ 83# define MCI_UNRE ( 1 << 31) /* TX Underrun Error */
84 84
85#define MCI_REGS_SIZE 0x100
86
85/* Register access macros */ 87/* Register access macros */
86#define mci_readl(port,reg) \ 88#define mci_readl(port,reg) \
87 __raw_readl((port)->regs + MCI_##reg) 89 __raw_readl((port)->regs + MCI_##reg)
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index cce873c5a149..992b4beb757c 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -9,13 +9,18 @@
9 */ 9 */
10#include <linux/blkdev.h> 10#include <linux/blkdev.h>
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/debugfs.h>
12#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/err.h>
15#include <linux/gpio.h>
13#include <linux/init.h> 16#include <linux/init.h>
14#include <linux/interrupt.h> 17#include <linux/interrupt.h>
15#include <linux/ioport.h> 18#include <linux/ioport.h>
16#include <linux/module.h> 19#include <linux/module.h>
17#include <linux/platform_device.h> 20#include <linux/platform_device.h>
18#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
22#include <linux/seq_file.h>
23#include <linux/stat.h>
19 24
20#include <linux/mmc/host.h> 25#include <linux/mmc/host.h>
21 26
@@ -24,7 +29,6 @@
24#include <asm/unaligned.h> 29#include <asm/unaligned.h>
25 30
26#include <asm/arch/board.h> 31#include <asm/arch/board.h>
27#include <asm/arch/gpio.h>
28 32
29#include "atmel-mci-regs.h" 33#include "atmel-mci-regs.h"
30 34
@@ -88,6 +92,188 @@ struct atmel_mci {
88#define atmci_clear_pending(host, event) \ 92#define atmci_clear_pending(host, event) \
89 clear_bit(event, &host->pending_events) 93 clear_bit(event, &host->pending_events)
90 94
95/*
96 * The debugfs stuff below is mostly optimized away when
97 * CONFIG_DEBUG_FS is not set.
98 */
99static int atmci_req_show(struct seq_file *s, void *v)
100{
101 struct atmel_mci *host = s->private;
102 struct mmc_request *mrq = host->mrq;
103 struct mmc_command *cmd;
104 struct mmc_command *stop;
105 struct mmc_data *data;
106
107 /* Make sure we get a consistent snapshot */
108 spin_lock_irq(&host->mmc->lock);
109
110 if (mrq) {
111 cmd = mrq->cmd;
112 data = mrq->data;
113 stop = mrq->stop;
114
115 if (cmd)
116 seq_printf(s,
117 "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n",
118 cmd->opcode, cmd->arg, cmd->flags,
119 cmd->resp[0], cmd->resp[1], cmd->resp[2],
120 cmd->resp[2], cmd->error);
121 if (data)
122 seq_printf(s, "DATA %u / %u * %u flg %x err %d\n",
123 data->bytes_xfered, data->blocks,
124 data->blksz, data->flags, data->error);
125 if (stop)
126 seq_printf(s,
127 "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n",
128 stop->opcode, stop->arg, stop->flags,
129 stop->resp[0], stop->resp[1], stop->resp[2],
130 stop->resp[2], stop->error);
131 }
132
133 spin_unlock_irq(&host->mmc->lock);
134
135 return 0;
136}
137
138static int atmci_req_open(struct inode *inode, struct file *file)
139{
140 return single_open(file, atmci_req_show, inode->i_private);
141}
142
143static const struct file_operations atmci_req_fops = {
144 .owner = THIS_MODULE,
145 .open = atmci_req_open,
146 .read = seq_read,
147 .llseek = seq_lseek,
148 .release = single_release,
149};
150
151static void atmci_show_status_reg(struct seq_file *s,
152 const char *regname, u32 value)
153{
154 static const char *sr_bit[] = {
155 [0] = "CMDRDY",
156 [1] = "RXRDY",
157 [2] = "TXRDY",
158 [3] = "BLKE",
159 [4] = "DTIP",
160 [5] = "NOTBUSY",
161 [8] = "SDIOIRQA",
162 [9] = "SDIOIRQB",
163 [16] = "RINDE",
164 [17] = "RDIRE",
165 [18] = "RCRCE",
166 [19] = "RENDE",
167 [20] = "RTOE",
168 [21] = "DCRCE",
169 [22] = "DTOE",
170 [30] = "OVRE",
171 [31] = "UNRE",
172 };
173 unsigned int i;
174
175 seq_printf(s, "%s:\t0x%08x", regname, value);
176 for (i = 0; i < ARRAY_SIZE(sr_bit); i++) {
177 if (value & (1 << i)) {
178 if (sr_bit[i])
179 seq_printf(s, " %s", sr_bit[i]);
180 else
181 seq_puts(s, " UNKNOWN");
182 }
183 }
184 seq_putc(s, '\n');
185}
186
187static int atmci_regs_show(struct seq_file *s, void *v)
188{
189 struct atmel_mci *host = s->private;
190 u32 *buf;
191
192 buf = kmalloc(MCI_REGS_SIZE, GFP_KERNEL);
193 if (!buf)
194 return -ENOMEM;
195
196 /* Grab a more or less consistent snapshot */
197 spin_lock_irq(&host->mmc->lock);
198 memcpy_fromio(buf, host->regs, MCI_REGS_SIZE);
199 spin_unlock_irq(&host->mmc->lock);
200
201 seq_printf(s, "MR:\t0x%08x%s%s CLKDIV=%u\n",
202 buf[MCI_MR / 4],
203 buf[MCI_MR / 4] & MCI_MR_RDPROOF ? " RDPROOF" : "",
204 buf[MCI_MR / 4] & MCI_MR_WRPROOF ? " WRPROOF" : "",
205 buf[MCI_MR / 4] & 0xff);
206 seq_printf(s, "DTOR:\t0x%08x\n", buf[MCI_DTOR / 4]);
207 seq_printf(s, "SDCR:\t0x%08x\n", buf[MCI_SDCR / 4]);
208 seq_printf(s, "ARGR:\t0x%08x\n", buf[MCI_ARGR / 4]);
209 seq_printf(s, "BLKR:\t0x%08x BCNT=%u BLKLEN=%u\n",
210 buf[MCI_BLKR / 4],
211 buf[MCI_BLKR / 4] & 0xffff,
212 (buf[MCI_BLKR / 4] >> 16) & 0xffff);
213
214 /* Don't read RSPR and RDR; it will consume the data there */
215
216 atmci_show_status_reg(s, "SR", buf[MCI_SR / 4]);
217 atmci_show_status_reg(s, "IMR", buf[MCI_IMR / 4]);
218
219 return 0;
220}
221
222static int atmci_regs_open(struct inode *inode, struct file *file)
223{
224 return single_open(file, atmci_regs_show, inode->i_private);
225}
226
227static const struct file_operations atmci_regs_fops = {
228 .owner = THIS_MODULE,
229 .open = atmci_regs_open,
230 .read = seq_read,
231 .llseek = seq_lseek,
232 .release = single_release,
233};
234
235static void atmci_init_debugfs(struct atmel_mci *host)
236{
237 struct mmc_host *mmc;
238 struct dentry *root;
239 struct dentry *node;
240 struct resource *res;
241
242 mmc = host->mmc;
243 root = mmc->debugfs_root;
244 if (!root)
245 return;
246
247 node = debugfs_create_file("regs", S_IRUSR, root, host,
248 &atmci_regs_fops);
249 if (IS_ERR(node))
250 return;
251 if (!node)
252 goto err;
253
254 res = platform_get_resource(host->pdev, IORESOURCE_MEM, 0);
255 node->d_inode->i_size = res->end - res->start + 1;
256
257 node = debugfs_create_file("req", S_IRUSR, root, host, &atmci_req_fops);
258 if (!node)
259 goto err;
260
261 node = debugfs_create_x32("pending_events", S_IRUSR, root,
262 (u32 *)&host->pending_events);
263 if (!node)
264 goto err;
265
266 node = debugfs_create_x32("completed_events", S_IRUSR, root,
267 (u32 *)&host->completed_events);
268 if (!node)
269 goto err;
270
271 return;
272
273err:
274 dev_err(&host->pdev->dev,
275 "failed to initialize debugfs for controller\n");
276}
91 277
92static void atmci_enable(struct atmel_mci *host) 278static void atmci_enable(struct atmel_mci *host)
93{ 279{
@@ -388,7 +574,7 @@ static int atmci_get_ro(struct mmc_host *mmc)
388 int read_only = 0; 574 int read_only = 0;
389 struct atmel_mci *host = mmc_priv(mmc); 575 struct atmel_mci *host = mmc_priv(mmc);
390 576
391 if (host->wp_pin >= 0) { 577 if (gpio_is_valid(host->wp_pin)) {
392 read_only = gpio_get_value(host->wp_pin); 578 read_only = gpio_get_value(host->wp_pin);
393 dev_dbg(&mmc->class_dev, "card is %s\n", 579 dev_dbg(&mmc->class_dev, "card is %s\n",
394 read_only ? "read-only" : "read-write"); 580 read_only ? "read-only" : "read-write");
@@ -450,7 +636,7 @@ static void atmci_detect_change(unsigned long data)
450 * been freed. 636 * been freed.
451 */ 637 */
452 smp_rmb(); 638 smp_rmb();
453 if (host->detect_pin < 0) 639 if (!gpio_is_valid(host->detect_pin))
454 return; 640 return;
455 641
456 enable_irq(gpio_to_irq(host->detect_pin)); 642 enable_irq(gpio_to_irq(host->detect_pin));
@@ -865,7 +1051,7 @@ static int __init atmci_probe(struct platform_device *pdev)
865 1051
866 /* Assume card is present if we don't have a detect pin */ 1052 /* Assume card is present if we don't have a detect pin */
867 host->present = 1; 1053 host->present = 1;
868 if (host->detect_pin >= 0) { 1054 if (gpio_is_valid(host->detect_pin)) {
869 if (gpio_request(host->detect_pin, "mmc_detect")) { 1055 if (gpio_request(host->detect_pin, "mmc_detect")) {
870 dev_dbg(&mmc->class_dev, "no detect pin available\n"); 1056 dev_dbg(&mmc->class_dev, "no detect pin available\n");
871 host->detect_pin = -1; 1057 host->detect_pin = -1;
@@ -873,7 +1059,7 @@ static int __init atmci_probe(struct platform_device *pdev)
873 host->present = !gpio_get_value(host->detect_pin); 1059 host->present = !gpio_get_value(host->detect_pin);
874 } 1060 }
875 } 1061 }
876 if (host->wp_pin >= 0) { 1062 if (gpio_is_valid(host->wp_pin)) {
877 if (gpio_request(host->wp_pin, "mmc_wp")) { 1063 if (gpio_request(host->wp_pin, "mmc_wp")) {
878 dev_dbg(&mmc->class_dev, "no WP pin available\n"); 1064 dev_dbg(&mmc->class_dev, "no WP pin available\n");
879 host->wp_pin = -1; 1065 host->wp_pin = -1;
@@ -884,7 +1070,7 @@ static int __init atmci_probe(struct platform_device *pdev)
884 1070
885 mmc_add_host(mmc); 1071 mmc_add_host(mmc);
886 1072
887 if (host->detect_pin >= 0) { 1073 if (gpio_is_valid(host->detect_pin)) {
888 setup_timer(&host->detect_timer, atmci_detect_change, 1074 setup_timer(&host->detect_timer, atmci_detect_change,
889 (unsigned long)host); 1075 (unsigned long)host);
890 1076
@@ -905,6 +1091,8 @@ static int __init atmci_probe(struct platform_device *pdev)
905 "Atmel MCI controller at 0x%08lx irq %d\n", 1091 "Atmel MCI controller at 0x%08lx irq %d\n",
906 host->mapbase, irq); 1092 host->mapbase, irq);
907 1093
1094 atmci_init_debugfs(host);
1095
908 return 0; 1096 return 0;
909 1097
910err_request_irq: 1098err_request_irq:
@@ -923,7 +1111,9 @@ static int __exit atmci_remove(struct platform_device *pdev)
923 platform_set_drvdata(pdev, NULL); 1111 platform_set_drvdata(pdev, NULL);
924 1112
925 if (host) { 1113 if (host) {
926 if (host->detect_pin >= 0) { 1114 /* Debugfs stuff is cleaned up by mmc core */
1115
1116 if (gpio_is_valid(host->detect_pin)) {
927 int pin = host->detect_pin; 1117 int pin = host->detect_pin;
928 1118
929 /* Make sure the timer doesn't enable the interrupt */ 1119 /* Make sure the timer doesn't enable the interrupt */
@@ -943,7 +1133,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
943 mci_readl(host, SR); 1133 mci_readl(host, SR);
944 clk_disable(host->mck); 1134 clk_disable(host->mck);
945 1135
946 if (host->wp_pin >= 0) 1136 if (gpio_is_valid(host->wp_pin))
947 gpio_free(host->wp_pin); 1137 gpio_free(host->wp_pin);
948 1138
949 free_irq(platform_get_irq(pdev, 0), host->mmc); 1139 free_irq(platform_get_irq(pdev, 0), host->mmc);
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 5e880c0f1349..f61406da65d2 100644
--- a/drivers/mmc/host/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -26,12 +26,6 @@
26 * 26 *
27 */ 27 */
28 28
29#ifdef CONFIG_MMC_DEBUG
30#define DEBUG
31#else
32#undef DEBUG
33#endif
34
35#include <linux/module.h> 29#include <linux/module.h>
36#include <linux/init.h> 30#include <linux/init.h>
37#include <linux/ioport.h> 31#include <linux/ioport.h>
@@ -907,31 +901,12 @@ static const struct mmc_host_ops imxmci_ops = {
907 .get_ro = imxmci_get_ro, 901 .get_ro = imxmci_get_ro,
908}; 902};
909 903
910static struct resource *platform_device_resource(struct platform_device *dev, unsigned int mask, int nr)
911{
912 int i;
913
914 for (i = 0; i < dev->num_resources; i++)
915 if (dev->resource[i].flags == mask && nr-- == 0)
916 return &dev->resource[i];
917 return NULL;
918}
919
920static int platform_device_irq(struct platform_device *dev, int nr)
921{
922 int i;
923
924 for (i = 0; i < dev->num_resources; i++)
925 if (dev->resource[i].flags == IORESOURCE_IRQ && nr-- == 0)
926 return dev->resource[i].start;
927 return NO_IRQ;
928}
929
930static void imxmci_check_status(unsigned long data) 904static void imxmci_check_status(unsigned long data)
931{ 905{
932 struct imxmci_host *host = (struct imxmci_host *)data; 906 struct imxmci_host *host = (struct imxmci_host *)data;
933 907
934 if( host->pdata->card_present(mmc_dev(host->mmc)) != host->present ) { 908 if (host->pdata && host->pdata->card_present &&
909 host->pdata->card_present(mmc_dev(host->mmc)) != host->present) {
935 host->present ^= 1; 910 host->present ^= 1;
936 dev_info(mmc_dev(host->mmc), "card %s\n", 911 dev_info(mmc_dev(host->mmc), "card %s\n",
937 host->present ? "inserted" : "removed"); 912 host->present ? "inserted" : "removed");
@@ -962,13 +937,12 @@ static int imxmci_probe(struct platform_device *pdev)
962 937
963 printk(KERN_INFO "i.MX mmc driver\n"); 938 printk(KERN_INFO "i.MX mmc driver\n");
964 939
965 r = platform_device_resource(pdev, IORESOURCE_MEM, 0); 940 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
966 irq = platform_device_irq(pdev, 0); 941 irq = platform_get_irq(pdev, 0);
967 if (!r || irq == NO_IRQ) 942 if (!r || irq < 0)
968 return -ENXIO; 943 return -ENXIO;
969 944
970 r = request_mem_region(r->start, 0x100, "IMXMCI"); 945 if (!request_mem_region(r->start, 0x100, pdev->name))
971 if (!r)
972 return -EBUSY; 946 return -EBUSY;
973 947
974 mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev); 948 mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev);
@@ -995,6 +969,8 @@ static int imxmci_probe(struct platform_device *pdev)
995 host->mmc = mmc; 969 host->mmc = mmc;
996 host->dma_allocated = 0; 970 host->dma_allocated = 0;
997 host->pdata = pdev->dev.platform_data; 971 host->pdata = pdev->dev.platform_data;
972 if (!host->pdata)
973 dev_warn(&pdev->dev, "No platform data provided!\n");
998 974
999 spin_lock_init(&host->lock); 975 spin_lock_init(&host->lock);
1000 host->res = r; 976 host->res = r;
@@ -1047,7 +1023,11 @@ static int imxmci_probe(struct platform_device *pdev)
1047 if (ret) 1023 if (ret)
1048 goto out; 1024 goto out;
1049 1025
1050 host->present = host->pdata->card_present(mmc_dev(mmc)); 1026 if (host->pdata && host->pdata->card_present)
1027 host->present = host->pdata->card_present(mmc_dev(mmc));
1028 else /* if there is no way to detect assume that card is present */
1029 host->present = 1;
1030
1051 init_timer(&host->timer); 1031 init_timer(&host->timer);
1052 host->timer.data = (unsigned long)host; 1032 host->timer.data = (unsigned long)host;
1053 host->timer.function = imxmci_check_status; 1033 host->timer.function = imxmci_check_status;
@@ -1073,7 +1053,7 @@ out:
1073 } 1053 }
1074 if (mmc) 1054 if (mmc)
1075 mmc_free_host(mmc); 1055 mmc_free_host(mmc);
1076 release_resource(r); 1056 release_mem_region(r->start, 0x100);
1077 return ret; 1057 return ret;
1078} 1058}
1079 1059
@@ -1102,7 +1082,7 @@ static int imxmci_remove(struct platform_device *pdev)
1102 clk_disable(host->clk); 1082 clk_disable(host->clk);
1103 clk_put(host->clk); 1083 clk_put(host->clk);
1104 1084
1105 release_resource(host->res); 1085 release_mem_region(host->res->start, 0x100);
1106 1086
1107 mmc_free_host(mmc); 1087 mmc_free_host(mmc);
1108 } 1088 }
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 41cc63360e43..7503b81374e0 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1076,6 +1076,7 @@ static void mmc_spi_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1076 */ 1076 */
1077 if (canpower && ios->power_mode == MMC_POWER_OFF) { 1077 if (canpower && ios->power_mode == MMC_POWER_OFF) {
1078 int mres; 1078 int mres;
1079 u8 nullbyte = 0;
1079 1080
1080 host->spi->mode &= ~(SPI_CPOL|SPI_CPHA); 1081 host->spi->mode &= ~(SPI_CPOL|SPI_CPHA);
1081 mres = spi_setup(host->spi); 1082 mres = spi_setup(host->spi);
@@ -1083,7 +1084,7 @@ static void mmc_spi_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1083 dev_dbg(&host->spi->dev, 1084 dev_dbg(&host->spi->dev,
1084 "switch to SPI mode 0 failed\n"); 1085 "switch to SPI mode 0 failed\n");
1085 1086
1086 if (spi_w8r8(host->spi, 0x00) < 0) 1087 if (spi_write(host->spi, &nullbyte, 1) < 0)
1087 dev_dbg(&host->spi->dev, 1088 dev_dbg(&host->spi->dev,
1088 "put spi signals to low failed\n"); 1089 "put spi signals to low failed\n");
1089 1090
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c3a5db72ddd7..5f95e10229b5 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -337,7 +337,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
337 337
338 host->align_addr = dma_map_single(mmc_dev(host->mmc), 338 host->align_addr = dma_map_single(mmc_dev(host->mmc),
339 host->align_buffer, 128 * 4, direction); 339 host->align_buffer, 128 * 4, direction);
340 if (dma_mapping_error(host->align_addr)) 340 if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr))
341 goto fail; 341 goto fail;
342 BUG_ON(host->align_addr & 0x3); 342 BUG_ON(host->align_addr & 0x3);
343 343
@@ -439,7 +439,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
439 439
440 host->adma_addr = dma_map_single(mmc_dev(host->mmc), 440 host->adma_addr = dma_map_single(mmc_dev(host->mmc),
441 host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE); 441 host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE);
442 if (dma_mapping_error(host->align_addr)) 442 if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr))
443 goto unmap_entries; 443 goto unmap_entries;
444 BUG_ON(host->adma_addr & 0x3); 444 BUG_ON(host->adma_addr & 0x3);
445 445
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index a06bf8b89343..e354faee5df0 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -9,6 +9,8 @@
9 * your option) any later version. 9 * your option) any later version.
10 */ 10 */
11 11
12#include <linux/scatterlist.h>
13
12/* 14/*
13 * Controller registers 15 * Controller registers
14 */ 16 */
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index eed06d068fd1..14f11f8b9e5f 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,5 +1,3 @@
1# $Id: Kconfig,v 1.11 2005/11/07 11:14:19 gleixner Exp $
2
3menuconfig MTD 1menuconfig MTD
4 tristate "Memory Technology Device (MTD) support" 2 tristate "Memory Technology Device (MTD) support"
5 depends on HAS_IOMEM 3 depends on HAS_IOMEM
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c
index 52d51eb91c16..d072ca5be689 100644
--- a/drivers/mtd/afs.c
+++ b/drivers/mtd/afs.c
@@ -21,8 +21,6 @@
21 This is access code for flashes using ARM's flash partitioning 21 This is access code for flashes using ARM's flash partitioning
22 standards. 22 standards.
23 23
24 $Id: afs.c,v 1.15 2005/11/07 11:14:19 gleixner Exp $
25
26======================================================================*/ 24======================================================================*/
27 25
28#include <linux/module.h> 26#include <linux/module.h>
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index fcd1aeccdf93..5f1b472137a0 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,8 +4,6 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.186 2005/11/23 22:07:52 nico Exp $
8 *
9 * 7 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 8 * 10/10/2000 Nicolas Pitre <nico@cam.org>
11 * - completely revamped method functions so they are aware and 9 * - completely revamped method functions so they are aware and
@@ -50,6 +48,8 @@
50#define I82802AC 0x00ac 48#define I82802AC 0x00ac
51#define MANUFACTURER_ST 0x0020 49#define MANUFACTURER_ST 0x0020
52#define M50LPW080 0x002F 50#define M50LPW080 0x002F
51#define M50FLW080A 0x0080
52#define M50FLW080B 0x0081
53#define AT49BV640D 0x02de 53#define AT49BV640D 0x02de
54 54
55static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 55static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
@@ -204,7 +204,7 @@ static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
204{ 204{
205 struct map_info *map = mtd->priv; 205 struct map_info *map = mtd->priv;
206 struct cfi_private *cfi = map->fldrv_priv; 206 struct cfi_private *cfi = map->fldrv_priv;
207 struct cfi_pri_amdstd *extp = cfi->cmdset_priv; 207 struct cfi_pri_intelext *extp = cfi->cmdset_priv;
208 208
209 printk(KERN_WARNING "cfi_cmdset_0001: Suspend " 209 printk(KERN_WARNING "cfi_cmdset_0001: Suspend "
210 "erase on write disabled.\n"); 210 "erase on write disabled.\n");
@@ -301,6 +301,8 @@ static struct cfi_fixup jedec_fixup_table[] = {
301 { MANUFACTURER_INTEL, I82802AB, fixup_use_fwh_lock, NULL, }, 301 { MANUFACTURER_INTEL, I82802AB, fixup_use_fwh_lock, NULL, },
302 { MANUFACTURER_INTEL, I82802AC, fixup_use_fwh_lock, NULL, }, 302 { MANUFACTURER_INTEL, I82802AC, fixup_use_fwh_lock, NULL, },
303 { MANUFACTURER_ST, M50LPW080, fixup_use_fwh_lock, NULL, }, 303 { MANUFACTURER_ST, M50LPW080, fixup_use_fwh_lock, NULL, },
304 { MANUFACTURER_ST, M50FLW080A, fixup_use_fwh_lock, NULL, },
305 { MANUFACTURER_ST, M50FLW080B, fixup_use_fwh_lock, NULL, },
304 { 0, 0, NULL, NULL } 306 { 0, 0, NULL, NULL }
305}; 307};
306static struct cfi_fixup fixup_table[] = { 308static struct cfi_fixup fixup_table[] = {
@@ -1147,7 +1149,7 @@ static int inval_cache_and_wait_for_operation(
1147 struct cfi_private *cfi = map->fldrv_priv; 1149 struct cfi_private *cfi = map->fldrv_priv;
1148 map_word status, status_OK = CMD(0x80); 1150 map_word status, status_OK = CMD(0x80);
1149 int chip_state = chip->state; 1151 int chip_state = chip->state;
1150 unsigned int timeo, sleep_time; 1152 unsigned int timeo, sleep_time, reset_timeo;
1151 1153
1152 spin_unlock(chip->mutex); 1154 spin_unlock(chip->mutex);
1153 if (inval_len) 1155 if (inval_len)
@@ -1158,6 +1160,7 @@ static int inval_cache_and_wait_for_operation(
1158 timeo = chip_op_time * 8; 1160 timeo = chip_op_time * 8;
1159 if (!timeo) 1161 if (!timeo)
1160 timeo = 500000; 1162 timeo = 500000;
1163 reset_timeo = timeo;
1161 sleep_time = chip_op_time / 2; 1164 sleep_time = chip_op_time / 2;
1162 1165
1163 for (;;) { 1166 for (;;) {
@@ -1199,6 +1202,12 @@ static int inval_cache_and_wait_for_operation(
1199 remove_wait_queue(&chip->wq, &wait); 1202 remove_wait_queue(&chip->wq, &wait);
1200 spin_lock(chip->mutex); 1203 spin_lock(chip->mutex);
1201 } 1204 }
1205 if (chip->erase_suspended || chip->write_suspended) {
1206 /* Suspend has occured while sleep: reset timeout */
1207 timeo = reset_timeo;
1208 chip->erase_suspended = 0;
1209 chip->write_suspended = 0;
1210 }
1202 } 1211 }
1203 1212
1204 /* Done and happy. */ 1213 /* Done and happy. */
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index f7fcc6389533..a972cc6be436 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -16,9 +16,6 @@
16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com 16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
17 * 17 *
18 * This code is GPL 18 * This code is GPL
19 *
20 * $Id: cfi_cmdset_0002.c,v 1.122 2005/11/07 11:14:22 gleixner Exp $
21 *
22 */ 19 */
23 20
24#include <linux/module.h> 21#include <linux/module.h>
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 1b720cc571f3..d4714dd9f7ab 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -4,8 +4,6 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0020.c,v 1.22 2005/11/07 11:14:22 gleixner Exp $
8 *
9 * 10/10/2000 Nicolas Pitre <nico@cam.org> 7 * 10/10/2000 Nicolas Pitre <nico@cam.org>
10 * - completely revamped method functions so they are aware and 8 * - completely revamped method functions so they are aware and
11 * independent of the flash geometry (buswidth, interleave, etc.) 9 * independent of the flash geometry (buswidth, interleave, etc.)
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index a4463a91ce31..c418e92e1d92 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -1,7 +1,6 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: cfi_probe.c,v 1.86 2005/11/29 14:48:31 gleixner Exp $
5*/ 4*/
6 5
7#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
index 72e0022a47bf..0ee457018016 100644
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -6,9 +6,6 @@
6 * Copyright (C) 2003 STMicroelectronics Limited 6 * Copyright (C) 2003 STMicroelectronics Limited
7 * 7 *
8 * This code is covered by the GPL. 8 * This code is covered by the GPL.
9 *
10 * $Id: cfi_util.c,v 1.10 2005/11/07 11:14:23 gleixner Exp $
11 *
12 */ 9 */
13 10
14#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c
index 2174c97549f0..c85760968227 100644
--- a/drivers/mtd/chips/chipreg.c
+++ b/drivers/mtd/chips/chipreg.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: chipreg.c,v 1.17 2004/11/16 18:29:00 dwmw2 Exp $
3 *
4 * Registration for chip drivers 2 * Registration for chip drivers
5 * 3 *
6 */ 4 */
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c
index d338b8c92780..f061885b2812 100644
--- a/drivers/mtd/chips/gen_probe.c
+++ b/drivers/mtd/chips/gen_probe.c
@@ -2,7 +2,6 @@
2 * Routines common to all CFI-type probes. 2 * Routines common to all CFI-type probes.
3 * (C) 2001-2003 Red Hat, Inc. 3 * (C) 2001-2003 Red Hat, Inc.
4 * GPL'd 4 * GPL'd
5 * $Id: gen_probe.c,v 1.24 2005/11/07 11:14:23 gleixner Exp $
6 */ 5 */
7 6
8#include <linux/kernel.h> 7#include <linux/kernel.h>
@@ -71,8 +70,8 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
71 interleave and device type, etc. */ 70 interleave and device type, etc. */
72 if (!genprobe_new_chip(map, cp, &cfi)) { 71 if (!genprobe_new_chip(map, cp, &cfi)) {
73 /* The probe didn't like it */ 72 /* The probe didn't like it */
74 printk(KERN_DEBUG "%s: Found no %s device at location zero\n", 73 pr_debug("%s: Found no %s device at location zero\n",
75 cp->name, map->name); 74 cp->name, map->name);
76 return NULL; 75 return NULL;
77 } 76 }
78 77
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index aa07575eb288..dbba5abf0db8 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_probe.c
@@ -1,7 +1,6 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: jedec_probe.c,v 1.66 2005/11/07 11:14:23 gleixner Exp $
5 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5) 4 See JEDEC (http://www.jedec.org/) standard JESD21C (section 3.5)
6 for the standard this probe goes back to. 5 for the standard this probe goes back to.
7 6
@@ -26,6 +25,7 @@
26/* Manufacturers */ 25/* Manufacturers */
27#define MANUFACTURER_AMD 0x0001 26#define MANUFACTURER_AMD 0x0001
28#define MANUFACTURER_ATMEL 0x001f 27#define MANUFACTURER_ATMEL 0x001f
28#define MANUFACTURER_EON 0x001c
29#define MANUFACTURER_FUJITSU 0x0004 29#define MANUFACTURER_FUJITSU 0x0004
30#define MANUFACTURER_HYUNDAI 0x00AD 30#define MANUFACTURER_HYUNDAI 0x00AD
31#define MANUFACTURER_INTEL 0x0089 31#define MANUFACTURER_INTEL 0x0089
@@ -37,6 +37,7 @@
37#define MANUFACTURER_ST 0x0020 37#define MANUFACTURER_ST 0x0020
38#define MANUFACTURER_TOSHIBA 0x0098 38#define MANUFACTURER_TOSHIBA 0x0098
39#define MANUFACTURER_WINBOND 0x00da 39#define MANUFACTURER_WINBOND 0x00da
40#define CONTINUATION_CODE 0x007f
40 41
41 42
42/* AMD */ 43/* AMD */
@@ -58,6 +59,8 @@
58#define AM29LV040B 0x004F 59#define AM29LV040B 0x004F
59#define AM29F032B 0x0041 60#define AM29F032B 0x0041
60#define AM29F002T 0x00B0 61#define AM29F002T 0x00B0
62#define AM29SL800DB 0x226B
63#define AM29SL800DT 0x22EA
61 64
62/* Atmel */ 65/* Atmel */
63#define AT49BV512 0x0003 66#define AT49BV512 0x0003
@@ -67,6 +70,10 @@
67#define AT49BV32X 0x00C8 70#define AT49BV32X 0x00C8
68#define AT49BV32XT 0x00C9 71#define AT49BV32XT 0x00C9
69 72
73/* Eon */
74#define EN29SL800BB 0x226B
75#define EN29SL800BT 0x22EA
76
70/* Fujitsu */ 77/* Fujitsu */
71#define MBM29F040C 0x00A4 78#define MBM29F040C 0x00A4
72#define MBM29F800BA 0x2258 79#define MBM29F800BA 0x2258
@@ -141,6 +148,8 @@
141#define M50FW080 0x002D 148#define M50FW080 0x002D
142#define M50FW016 0x002E 149#define M50FW016 0x002E
143#define M50LPW080 0x002F 150#define M50LPW080 0x002F
151#define M50FLW080A 0x0080
152#define M50FLW080B 0x0081
144 153
145/* SST */ 154/* SST */
146#define SST29EE020 0x0010 155#define SST29EE020 0x0010
@@ -191,6 +200,7 @@ enum uaddr {
191 MTD_UADDR_0x0555_0x0AAA, 200 MTD_UADDR_0x0555_0x0AAA,
192 MTD_UADDR_0x5555_0x2AAA, 201 MTD_UADDR_0x5555_0x2AAA,
193 MTD_UADDR_0x0AAA_0x0555, 202 MTD_UADDR_0x0AAA_0x0555,
203 MTD_UADDR_0xAAAA_0x5555,
194 MTD_UADDR_DONT_CARE, /* Requires an arbitrary address */ 204 MTD_UADDR_DONT_CARE, /* Requires an arbitrary address */
195 MTD_UADDR_UNNECESSARY, /* Does not require any address */ 205 MTD_UADDR_UNNECESSARY, /* Does not require any address */
196}; 206};
@@ -238,6 +248,11 @@ static const struct unlock_addr unlock_addrs[] = {
238 .addr2 = 0x0555 248 .addr2 = 0x0555
239 }, 249 },
240 250
251 [MTD_UADDR_0xAAAA_0x5555] = {
252 .addr1 = 0xaaaa,
253 .addr2 = 0x5555
254 },
255
241 [MTD_UADDR_DONT_CARE] = { 256 [MTD_UADDR_DONT_CARE] = {
242 .addr1 = 0x0000, /* Doesn't matter which address */ 257 .addr1 = 0x0000, /* Doesn't matter which address */
243 .addr2 = 0x0000 /* is used - must be last entry */ 258 .addr2 = 0x0000 /* is used - must be last entry */
@@ -522,6 +537,36 @@ static const struct amd_flash_info jedec_table[] = {
522 ERASEINFO(0x04000,1), 537 ERASEINFO(0x04000,1),
523 } 538 }
524 }, { 539 }, {
540 .mfr_id = MANUFACTURER_AMD,
541 .dev_id = AM29SL800DT,
542 .name = "AMD AM29SL800DT",
543 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
544 .uaddr = MTD_UADDR_0x0AAA_0x0555,
545 .dev_size = SIZE_1MiB,
546 .cmd_set = P_ID_AMD_STD,
547 .nr_regions = 4,
548 .regions = {
549 ERASEINFO(0x10000,15),
550 ERASEINFO(0x08000,1),
551 ERASEINFO(0x02000,2),
552 ERASEINFO(0x04000,1),
553 }
554 }, {
555 .mfr_id = MANUFACTURER_AMD,
556 .dev_id = AM29SL800DB,
557 .name = "AMD AM29SL800DB",
558 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
559 .uaddr = MTD_UADDR_0x0AAA_0x0555,
560 .dev_size = SIZE_1MiB,
561 .cmd_set = P_ID_AMD_STD,
562 .nr_regions = 4,
563 .regions = {
564 ERASEINFO(0x04000,1),
565 ERASEINFO(0x02000,2),
566 ERASEINFO(0x08000,1),
567 ERASEINFO(0x10000,15),
568 }
569 }, {
525 .mfr_id = MANUFACTURER_ATMEL, 570 .mfr_id = MANUFACTURER_ATMEL,
526 .dev_id = AT49BV512, 571 .dev_id = AT49BV512,
527 .name = "Atmel AT49BV512", 572 .name = "Atmel AT49BV512",
@@ -599,6 +644,36 @@ static const struct amd_flash_info jedec_table[] = {
599 ERASEINFO(0x02000,8) 644 ERASEINFO(0x02000,8)
600 } 645 }
601 }, { 646 }, {
647 .mfr_id = MANUFACTURER_EON,
648 .dev_id = EN29SL800BT,
649 .name = "Eon EN29SL800BT",
650 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
651 .uaddr = MTD_UADDR_0x0AAA_0x0555,
652 .dev_size = SIZE_1MiB,
653 .cmd_set = P_ID_AMD_STD,
654 .nr_regions = 4,
655 .regions = {
656 ERASEINFO(0x10000,15),
657 ERASEINFO(0x08000,1),
658 ERASEINFO(0x02000,2),
659 ERASEINFO(0x04000,1),
660 }
661 }, {
662 .mfr_id = MANUFACTURER_EON,
663 .dev_id = EN29SL800BB,
664 .name = "Eon EN29SL800BB",
665 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
666 .uaddr = MTD_UADDR_0x0AAA_0x0555,
667 .dev_size = SIZE_1MiB,
668 .cmd_set = P_ID_AMD_STD,
669 .nr_regions = 4,
670 .regions = {
671 ERASEINFO(0x04000,1),
672 ERASEINFO(0x02000,2),
673 ERASEINFO(0x08000,1),
674 ERASEINFO(0x10000,15),
675 }
676 }, {
602 .mfr_id = MANUFACTURER_FUJITSU, 677 .mfr_id = MANUFACTURER_FUJITSU,
603 .dev_id = MBM29F040C, 678 .dev_id = MBM29F040C,
604 .name = "Fujitsu MBM29F040C", 679 .name = "Fujitsu MBM29F040C",
@@ -1392,8 +1467,8 @@ static const struct amd_flash_info jedec_table[] = {
1392 .mfr_id = MANUFACTURER_SST, /* should be CFI */ 1467 .mfr_id = MANUFACTURER_SST, /* should be CFI */
1393 .dev_id = SST39LF160, 1468 .dev_id = SST39LF160,
1394 .name = "SST 39LF160", 1469 .name = "SST 39LF160",
1395 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8, 1470 .devtypes = CFI_DEVICETYPE_X16,
1396 .uaddr = MTD_UADDR_0x5555_0x2AAA, /* ???? */ 1471 .uaddr = MTD_UADDR_0xAAAA_0x5555,
1397 .dev_size = SIZE_2MiB, 1472 .dev_size = SIZE_2MiB,
1398 .cmd_set = P_ID_AMD_STD, 1473 .cmd_set = P_ID_AMD_STD,
1399 .nr_regions = 2, 1474 .nr_regions = 2,
@@ -1405,8 +1480,8 @@ static const struct amd_flash_info jedec_table[] = {
1405 .mfr_id = MANUFACTURER_SST, /* should be CFI */ 1480 .mfr_id = MANUFACTURER_SST, /* should be CFI */
1406 .dev_id = SST39VF1601, 1481 .dev_id = SST39VF1601,
1407 .name = "SST 39VF1601", 1482 .name = "SST 39VF1601",
1408 .devtypes = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8, 1483 .devtypes = CFI_DEVICETYPE_X16,
1409 .uaddr = MTD_UADDR_0x5555_0x2AAA, /* ???? */ 1484 .uaddr = MTD_UADDR_0xAAAA_0x5555,
1410 .dev_size = SIZE_2MiB, 1485 .dev_size = SIZE_2MiB,
1411 .cmd_set = P_ID_AMD_STD, 1486 .cmd_set = P_ID_AMD_STD,
1412 .nr_regions = 2, 1487 .nr_regions = 2,
@@ -1590,6 +1665,36 @@ static const struct amd_flash_info jedec_table[] = {
1590 .nr_regions = 1, 1665 .nr_regions = 1,
1591 .regions = { 1666 .regions = {
1592 ERASEINFO(0x10000,16), 1667 ERASEINFO(0x10000,16),
1668 },
1669 }, {
1670 .mfr_id = MANUFACTURER_ST,
1671 .dev_id = M50FLW080A,
1672 .name = "ST M50FLW080A",
1673 .devtypes = CFI_DEVICETYPE_X8,
1674 .uaddr = MTD_UADDR_UNNECESSARY,
1675 .dev_size = SIZE_1MiB,
1676 .cmd_set = P_ID_INTEL_EXT,
1677 .nr_regions = 4,
1678 .regions = {
1679 ERASEINFO(0x1000,16),
1680 ERASEINFO(0x10000,13),
1681 ERASEINFO(0x1000,16),
1682 ERASEINFO(0x1000,16),
1683 }
1684 }, {
1685 .mfr_id = MANUFACTURER_ST,
1686 .dev_id = M50FLW080B,
1687 .name = "ST M50FLW080B",
1688 .devtypes = CFI_DEVICETYPE_X8,
1689 .uaddr = MTD_UADDR_UNNECESSARY,
1690 .dev_size = SIZE_1MiB,
1691 .cmd_set = P_ID_INTEL_EXT,
1692 .nr_regions = 4,
1693 .regions = {
1694 ERASEINFO(0x1000,16),
1695 ERASEINFO(0x1000,16),
1696 ERASEINFO(0x10000,13),
1697 ERASEINFO(0x1000,16),
1593 } 1698 }
1594 }, { 1699 }, {
1595 .mfr_id = MANUFACTURER_TOSHIBA, 1700 .mfr_id = MANUFACTURER_TOSHIBA,
@@ -1696,9 +1801,21 @@ static inline u32 jedec_read_mfr(struct map_info *map, uint32_t base,
1696{ 1801{
1697 map_word result; 1802 map_word result;
1698 unsigned long mask; 1803 unsigned long mask;
1699 u32 ofs = cfi_build_cmd_addr(0, cfi_interleave(cfi), cfi->device_type); 1804 int bank = 0;
1700 mask = (1 << (cfi->device_type * 8)) -1; 1805
1701 result = map_read(map, base + ofs); 1806 /* According to JEDEC "Standard Manufacturer's Identification Code"
1807 * (http://www.jedec.org/download/search/jep106W.pdf)
1808 * several first banks can contain 0x7f instead of actual ID
1809 */
1810 do {
1811 uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8),
1812 cfi_interleave(cfi),
1813 cfi->device_type);
1814 mask = (1 << (cfi->device_type * 8)) - 1;
1815 result = map_read(map, base + ofs);
1816 bank++;
1817 } while ((result.x[0] & mask) == CONTINUATION_CODE);
1818
1702 return result.x[0] & mask; 1819 return result.x[0] & mask;
1703} 1820}
1704 1821
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
index fc478c0f93f5..494d30d0631a 100644
--- a/drivers/mtd/chips/map_absent.c
+++ b/drivers/mtd/chips/map_absent.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Common code to handle absent "placeholder" devices 2 * Common code to handle absent "placeholder" devices
3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com> 3 * Copyright 2001 Resilience Corporation <ebrower@resilience.com>
4 * $Id: map_absent.c,v 1.6 2005/11/07 11:14:23 gleixner Exp $
5 * 4 *
6 * This map driver is used to allocate "placeholder" MTD 5 * This map driver is used to allocate "placeholder" MTD
7 * devices on systems that have socketed/removable media. 6 * devices on systems that have socketed/removable media.
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c
index 5cb6d5263661..072dd8abf33a 100644
--- a/drivers/mtd/chips/map_ram.c
+++ b/drivers/mtd/chips/map_ram.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Common code to handle map devices which are simple RAM 2 * Common code to handle map devices which are simple RAM
3 * (C) 2000 Red Hat. GPL'd. 3 * (C) 2000 Red Hat. GPL'd.
4 * $Id: map_ram.c,v 1.22 2005/01/05 18:05:12 dwmw2 Exp $
5 */ 4 */
6 5
7#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
index cb27f855074c..821d0ed6bae3 100644
--- a/drivers/mtd/chips/map_rom.c
+++ b/drivers/mtd/chips/map_rom.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Common code to handle map devices which are simple ROM 2 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd. 3 * (C) 2000 Red Hat. GPL'd.
4 * $Id: map_rom.c,v 1.23 2005/01/05 18:05:12 dwmw2 Exp $
5 */ 4 */
6 5
7#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index e472a0e9de9d..71bc07f149b7 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: cmdlinepart.c,v 1.19 2005/11/07 11:14:19 gleixner Exp $
3 *
4 * Read flash partition table from command line 2 * Read flash partition table from command line
5 * 3 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 4 * Copyright 2002 SYSGO Real-Time Solutions GmbH
@@ -308,7 +306,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
308 unsigned long offset; 306 unsigned long offset;
309 int i; 307 int i;
310 struct cmdline_mtd_partition *part; 308 struct cmdline_mtd_partition *part;
311 char *mtd_id = master->name; 309 const char *mtd_id = master->name;
312 310
313 /* parse command line */ 311 /* parse command line */
314 if (!cmdline_parsed) 312 if (!cmdline_parsed)
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 35ed1103dbb2..9c613f06623c 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -1,5 +1,4 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.18 2005/11/07 11:14:24 gleixner Exp $
3 2
4menu "Self-contained MTD device drivers" 3menu "Self-contained MTD device drivers"
5 depends on MTD!=n 4 depends on MTD!=n
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 0f788d5c4bf8..0993d5cf3923 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -1,7 +1,6 @@
1# 1#
2# linux/drivers/devices/Makefile 2# linux/drivers/devices/Makefile
3# 3#
4# $Id: Makefile.common,v 1.7 2004/12/22 17:51:15 joern Exp $
5 4
6obj-$(CONFIG_MTD_DOC2000) += doc2000.o 5obj-$(CONFIG_MTD_DOC2000) += doc2000.o
7obj-$(CONFIG_MTD_DOC2001) += doc2001.o 6obj-$(CONFIG_MTD_DOC2001) += doc2001.o
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 7b72a1b36115..91fbba767635 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: block2mtd.c,v 1.30 2005/11/29 14:48:32 gleixner Exp $
3 *
4 * block2mtd.c - create an mtd from a block device 2 * block2mtd.c - create an mtd from a block device
5 * 3 *
6 * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk> 4 * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk>
@@ -20,9 +18,6 @@
20#include <linux/mutex.h> 18#include <linux/mutex.h>
21#include <linux/mount.h> 19#include <linux/mount.h>
22 20
23#define VERSION "$Revision: 1.30 $"
24
25
26#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 21#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
27#define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args) 22#define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)
28 23
@@ -453,7 +448,6 @@ MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
453static int __init block2mtd_init(void) 448static int __init block2mtd_init(void)
454{ 449{
455 int ret = 0; 450 int ret = 0;
456 INFO("version " VERSION);
457 451
458#ifndef MODULE 452#ifndef MODULE
459 if (strlen(block2mtd_paramline)) 453 if (strlen(block2mtd_paramline))
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index 846989f292e3..50de839c77a9 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -3,8 +3,6 @@
3 * Linux driver for Disk-On-Chip 2000 and Millennium 3 * Linux driver for Disk-On-Chip 2000 and Millennium
4 * (c) 1999 Machine Vision Holdings, Inc. 4 * (c) 1999 Machine Vision Holdings, Inc.
5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
6 *
7 * $Id: doc2000.c,v 1.67 2005/11/07 11:14:24 gleixner Exp $
8 */ 6 */
9 7
10#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 6413efc045e0..e32c568c1145 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -3,8 +3,6 @@
3 * Linux driver for Disk-On-Chip Millennium 3 * Linux driver for Disk-On-Chip Millennium
4 * (c) 1999 Machine Vision Holdings, Inc. 4 * (c) 1999 Machine Vision Holdings, Inc.
5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 5 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
6 *
7 * $Id: doc2001.c,v 1.49 2005/11/07 11:14:24 gleixner Exp $
8 */ 6 */
9 7
10#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index 83be3461658f..d853f891b586 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -6,8 +6,6 @@
6 * (c) 1999 Machine Vision Holdings, Inc. 6 * (c) 1999 Machine Vision Holdings, Inc.
7 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> 7 * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
8 * 8 *
9 * $Id: doc2001plus.c,v 1.14 2005/11/07 11:14:24 gleixner Exp $
10 *
11 * Released under GPL 9 * Released under GPL
12 */ 10 */
13 11
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c
index fd8a8daba3a8..874e51b110a2 100644
--- a/drivers/mtd/devices/docecc.c
+++ b/drivers/mtd/devices/docecc.c
@@ -7,8 +7,6 @@
7 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 7 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
8 * Copyright (C) 2000 Netgem S.A. 8 * Copyright (C) 2000 Netgem S.A.
9 * 9 *
10 * $Id: docecc.c,v 1.7 2005/11/07 11:14:25 gleixner Exp $
11 *
12 * This program is free software; you can redistribute it and/or modify 10 * 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 11 * 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 12 * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c
index d8cc94ec4e50..6e62922942b1 100644
--- a/drivers/mtd/devices/docprobe.c
+++ b/drivers/mtd/devices/docprobe.c
@@ -4,9 +4,6 @@
4/* (C) 1999 Machine Vision Holdings, Inc. */ 4/* (C) 1999 Machine Vision Holdings, Inc. */
5/* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> */ 5/* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> */
6 6
7/* $Id: docprobe.c,v 1.46 2005/11/07 11:14:25 gleixner Exp $ */
8
9
10 7
11/* DOC_PASSIVE_PROBE: 8/* DOC_PASSIVE_PROBE:
12 In order to ensure that the BIOS checksum is correct at boot time, and 9 In order to ensure that the BIOS checksum is correct at boot time, and
@@ -79,8 +76,6 @@ static unsigned long __initdata doc_locations[] = {
79 0xe0000, 0xe2000, 0xe4000, 0xe6000, 76 0xe0000, 0xe2000, 0xe4000, 0xe6000,
80 0xe8000, 0xea000, 0xec000, 0xee000, 77 0xe8000, 0xea000, 0xec000, 0xee000,
81#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 78#endif /* CONFIG_MTD_DOCPROBE_HIGH */
82#elif defined(__PPC__)
83 0xe4000000,
84#else 79#else
85#warning Unknown architecture for DiskOnChip. No default probe locations defined 80#warning Unknown architecture for DiskOnChip. No default probe locations defined
86#endif 81#endif
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index 1d324e5c412d..f4bda4cee495 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -2,8 +2,6 @@
2/* 2/*
3 * MTD driver for the 28F160F3 Flash Memory (non-CFI) on LART. 3 * MTD driver for the 28F160F3 Flash Memory (non-CFI) on LART.
4 * 4 *
5 * $Id: lart.c,v 1.9 2005/11/07 11:14:25 gleixner Exp $
6 *
7 * Author: Abraham vd Merwe <abraham@2d3d.co.za> 5 * Author: Abraham vd Merwe <abraham@2d3d.co.za>
8 * 6 *
9 * Copyright (c) 2001, 2d3D, Inc. 7 * Copyright (c) 2001, 2d3D, Inc.
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index b402269301f6..b35c3333e210 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -33,6 +33,7 @@
33/* Flash opcodes. */ 33/* Flash opcodes. */
34#define OPCODE_WREN 0x06 /* Write enable */ 34#define OPCODE_WREN 0x06 /* Write enable */
35#define OPCODE_RDSR 0x05 /* Read status register */ 35#define OPCODE_RDSR 0x05 /* Read status register */
36#define OPCODE_WRSR 0x01 /* Write status register 1 byte */
36#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */ 37#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */
37#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */ 38#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
38#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */ 39#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
@@ -112,6 +113,17 @@ static int read_sr(struct m25p *flash)
112 return val; 113 return val;
113} 114}
114 115
116/*
117 * Write status register 1 byte
118 * Returns negative if error occurred.
119 */
120static int write_sr(struct m25p *flash, u8 val)
121{
122 flash->command[0] = OPCODE_WRSR;
123 flash->command[1] = val;
124
125 return spi_write(flash->spi, flash->command, 2);
126}
115 127
116/* 128/*
117 * Set write enable latch with Write Enable command. 129 * Set write enable latch with Write Enable command.
@@ -589,6 +601,16 @@ static int __devinit m25p_probe(struct spi_device *spi)
589 mutex_init(&flash->lock); 601 mutex_init(&flash->lock);
590 dev_set_drvdata(&spi->dev, flash); 602 dev_set_drvdata(&spi->dev, flash);
591 603
604 /*
605 * Atmel serial flash tend to power up
606 * with the software protection bits set
607 */
608
609 if (info->jedec_id >> 16 == 0x1f) {
610 write_enable(flash);
611 write_sr(flash, 0);
612 }
613
592 if (data && data->name) 614 if (data && data->name)
593 flash->mtd.name = data->name; 615 flash->mtd.name = data->name;
594 else 616 else
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index 9cff119a2024..6a9a24a80a6d 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -5,8 +5,6 @@
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 *
9 * $Id: ms02-nv.c,v 1.11 2005/11/14 13:41:47 macro Exp $
10 */ 8 */
11 9
12#include <linux/init.h> 10#include <linux/init.h>
diff --git a/drivers/mtd/devices/ms02-nv.h b/drivers/mtd/devices/ms02-nv.h
index 8a6eef7cfee3..04deafd3a771 100644
--- a/drivers/mtd/devices/ms02-nv.h
+++ b/drivers/mtd/devices/ms02-nv.h
@@ -9,8 +9,6 @@
9 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version. 11 * 2 of the License, or (at your option) any later version.
12 *
13 * $Id: ms02-nv.h,v 1.3 2003/08/19 09:25:36 dwmw2 Exp $
14 */ 12 */
15 13
16#include <linux/ioport.h> 14#include <linux/ioport.h>
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index b35e4813a3a5..54e36bfc2c3b 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -82,7 +82,7 @@
82 82
83 83
84struct dataflash { 84struct dataflash {
85 u8 command[4]; 85 uint8_t command[4];
86 char name[24]; 86 char name[24];
87 87
88 unsigned partitioned:1; 88 unsigned partitioned:1;
@@ -150,7 +150,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
150 struct spi_transfer x = { .tx_dma = 0, }; 150 struct spi_transfer x = { .tx_dma = 0, };
151 struct spi_message msg; 151 struct spi_message msg;
152 unsigned blocksize = priv->page_size << 3; 152 unsigned blocksize = priv->page_size << 3;
153 u8 *command; 153 uint8_t *command;
154 154
155 DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%x len 0x%x\n", 155 DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%x len 0x%x\n",
156 spi->dev.bus_id, 156 spi->dev.bus_id,
@@ -182,8 +182,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
182 pageaddr = pageaddr << priv->page_offset; 182 pageaddr = pageaddr << priv->page_offset;
183 183
184 command[0] = do_block ? OP_ERASE_BLOCK : OP_ERASE_PAGE; 184 command[0] = do_block ? OP_ERASE_BLOCK : OP_ERASE_PAGE;
185 command[1] = (u8)(pageaddr >> 16); 185 command[1] = (uint8_t)(pageaddr >> 16);
186 command[2] = (u8)(pageaddr >> 8); 186 command[2] = (uint8_t)(pageaddr >> 8);
187 command[3] = 0; 187 command[3] = 0;
188 188
189 DEBUG(MTD_DEBUG_LEVEL3, "ERASE %s: (%x) %x %x %x [%i]\n", 189 DEBUG(MTD_DEBUG_LEVEL3, "ERASE %s: (%x) %x %x %x [%i]\n",
@@ -234,7 +234,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
234 struct spi_transfer x[2] = { { .tx_dma = 0, }, }; 234 struct spi_transfer x[2] = { { .tx_dma = 0, }, };
235 struct spi_message msg; 235 struct spi_message msg;
236 unsigned int addr; 236 unsigned int addr;
237 u8 *command; 237 uint8_t *command;
238 int status; 238 int status;
239 239
240 DEBUG(MTD_DEBUG_LEVEL2, "%s: read 0x%x..0x%x\n", 240 DEBUG(MTD_DEBUG_LEVEL2, "%s: read 0x%x..0x%x\n",
@@ -274,9 +274,9 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
274 * fewer "don't care" bytes. Both buffers stay unchanged. 274 * fewer "don't care" bytes. Both buffers stay unchanged.
275 */ 275 */
276 command[0] = OP_READ_CONTINUOUS; 276 command[0] = OP_READ_CONTINUOUS;
277 command[1] = (u8)(addr >> 16); 277 command[1] = (uint8_t)(addr >> 16);
278 command[2] = (u8)(addr >> 8); 278 command[2] = (uint8_t)(addr >> 8);
279 command[3] = (u8)(addr >> 0); 279 command[3] = (uint8_t)(addr >> 0);
280 /* plus 4 "don't care" bytes */ 280 /* plus 4 "don't care" bytes */
281 281
282 status = spi_sync(priv->spi, &msg); 282 status = spi_sync(priv->spi, &msg);
@@ -311,7 +311,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
311 size_t remaining = len; 311 size_t remaining = len;
312 u_char *writebuf = (u_char *) buf; 312 u_char *writebuf = (u_char *) buf;
313 int status = -EINVAL; 313 int status = -EINVAL;
314 u8 *command; 314 uint8_t *command;
315 315
316 DEBUG(MTD_DEBUG_LEVEL2, "%s: write 0x%x..0x%x\n", 316 DEBUG(MTD_DEBUG_LEVEL2, "%s: write 0x%x..0x%x\n",
317 spi->dev.bus_id, (unsigned)to, (unsigned)(to + len)); 317 spi->dev.bus_id, (unsigned)to, (unsigned)(to + len));
@@ -487,7 +487,9 @@ add_dataflash(struct spi_device *spi, char *name,
487 device->write = dataflash_write; 487 device->write = dataflash_write;
488 device->priv = priv; 488 device->priv = priv;
489 489
490 dev_info(&spi->dev, "%s (%d KBytes)\n", name, device->size/1024); 490 dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes, "
491 "erasesize %d bytes\n", name, device->size/1024,
492 pagesize, pagesize * 8); /* 8 pages = 1 block */
491 dev_set_drvdata(&spi->dev, priv); 493 dev_set_drvdata(&spi->dev, priv);
492 494
493 if (mtd_has_partitions()) { 495 if (mtd_has_partitions()) {
@@ -521,7 +523,7 @@ add_dataflash(struct spi_device *spi, char *name,
521 * 523 *
522 * Device Density ID code #Pages PageSize Offset 524 * Device Density ID code #Pages PageSize Offset
523 * AT45DB011B 1Mbit (128K) xx0011xx (0x0c) 512 264 9 525 * AT45DB011B 1Mbit (128K) xx0011xx (0x0c) 512 264 9
524 * AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1025 264 9 526 * AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1024 264 9
525 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9 527 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9
526 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9 528 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9
527 * AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10 529 * AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10
@@ -529,9 +531,114 @@ add_dataflash(struct spi_device *spi, char *name,
529 * AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11 531 * AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11
530 * AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11 532 * AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11
531 */ 533 */
534
535struct flash_info {
536 char *name;
537
538 /* JEDEC id zero means "no ID" (most older chips); otherwise it has
539 * a high byte of zero plus three data bytes: the manufacturer id,
540 * then a two byte device id.
541 */
542 uint32_t jedec_id;
543
544 /* The size listed here is what works with OPCODE_SE, which isn't
545 * necessarily called a "sector" by the vendor.
546 */
547 unsigned nr_pages;
548 uint16_t pagesize;
549 uint16_t pageoffset;
550
551 uint16_t flags;
552#define SUP_POW2PS 0x02
553#define IS_POW2PS 0x01
554};
555
556static struct flash_info __devinitdata dataflash_data [] = {
557
558 { "at45db011d", 0x1f2200, 512, 264, 9, SUP_POW2PS},
559 { "at45db011d", 0x1f2200, 512, 256, 8, SUP_POW2PS | IS_POW2PS},
560
561 { "at45db021d", 0x1f2300, 1024, 264, 9, SUP_POW2PS},
562 { "at45db021d", 0x1f2300, 1024, 256, 8, SUP_POW2PS | IS_POW2PS},
563
564 { "at45db041d", 0x1f2400, 2048, 264, 9, SUP_POW2PS},
565 { "at45db041d", 0x1f2400, 2048, 256, 8, SUP_POW2PS | IS_POW2PS},
566
567 { "at45db081d", 0x1f2500, 4096, 264, 9, SUP_POW2PS},
568 { "at45db081d", 0x1f2500, 4096, 256, 8, SUP_POW2PS | IS_POW2PS},
569
570 { "at45db161d", 0x1f2600, 4096, 528, 10, SUP_POW2PS},
571 { "at45db161d", 0x1f2600, 4096, 512, 9, SUP_POW2PS | IS_POW2PS},
572
573 { "at45db321c", 0x1f2700, 8192, 528, 10, },
574
575 { "at45db321d", 0x1f2701, 8192, 528, 10, SUP_POW2PS},
576 { "at45db321d", 0x1f2701, 8192, 512, 9, SUP_POW2PS | IS_POW2PS},
577
578 { "at45db641d", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
579 { "at45db641d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
580};
581
582static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
583{
584 int tmp;
585 uint8_t code = OP_READ_ID;
586 uint8_t id[3];
587 uint32_t jedec;
588 struct flash_info *info;
589 int status;
590
591
592 /* JEDEC also defines an optional "extended device information"
593 * string for after vendor-specific data, after the three bytes
594 * we use here. Supporting some chips might require using it.
595 */
596 tmp = spi_write_then_read(spi, &code, 1, id, 3);
597 if (tmp < 0) {
598 DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n",
599 spi->dev.bus_id, tmp);
600 return NULL;
601 }
602 jedec = id[0];
603 jedec = jedec << 8;
604 jedec |= id[1];
605 jedec = jedec << 8;
606 jedec |= id[2];
607
608 for (tmp = 0, info = dataflash_data;
609 tmp < ARRAY_SIZE(dataflash_data);
610 tmp++, info++) {
611 if (info->jedec_id == jedec) {
612 if (info->flags & SUP_POW2PS) {
613 status = dataflash_status(spi);
614 if (status & 0x1)
615 /* return power of 2 pagesize */
616 return ++info;
617 else
618 return info;
619 }
620 }
621 }
622 return NULL;
623}
624
532static int __devinit dataflash_probe(struct spi_device *spi) 625static int __devinit dataflash_probe(struct spi_device *spi)
533{ 626{
534 int status; 627 int status;
628 struct flash_info *info;
629
630 /*
631 * Try to detect dataflash by JEDEC ID.
632 * If it succeeds we know we have either a C or D part.
633 * D will support power of 2 pagesize option.
634 */
635
636 info = jedec_probe(spi);
637
638 if (info != NULL)
639 return add_dataflash(spi, info->name, info->nr_pages,
640 info->pagesize, info->pageoffset);
641
535 642
536 status = dataflash_status(spi); 643 status = dataflash_status(spi);
537 if (status <= 0 || status == 0xff) { 644 if (status <= 0 || status == 0xff) {
@@ -551,16 +658,16 @@ static int __devinit dataflash_probe(struct spi_device *spi)
551 status = add_dataflash(spi, "AT45DB011B", 512, 264, 9); 658 status = add_dataflash(spi, "AT45DB011B", 512, 264, 9);
552 break; 659 break;
553 case 0x14: /* 0 1 0 1 x x */ 660 case 0x14: /* 0 1 0 1 x x */
554 status = add_dataflash(spi, "AT45DB021B", 1025, 264, 9); 661 status = add_dataflash(spi, "AT45DB021B", 1024, 264, 9);
555 break; 662 break;
556 case 0x1c: /* 0 1 1 1 x x */ 663 case 0x1c: /* 0 1 1 1 x x */
557 status = add_dataflash(spi, "AT45DB041x", 2048, 264, 9); 664 status = add_dataflash(spi, "AT45DB041B", 2048, 264, 9);
558 break; 665 break;
559 case 0x24: /* 1 0 0 1 x x */ 666 case 0x24: /* 1 0 0 1 x x */
560 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9); 667 status = add_dataflash(spi, "AT45DB081B", 4096, 264, 9);
561 break; 668 break;
562 case 0x2c: /* 1 0 1 1 x x */ 669 case 0x2c: /* 1 0 1 1 x x */
563 status = add_dataflash(spi, "AT45DB161x", 4096, 528, 10); 670 status = add_dataflash(spi, "AT45DB161B", 4096, 528, 10);
564 break; 671 break;
565 case 0x34: /* 1 1 0 1 x x */ 672 case 0x34: /* 1 1 0 1 x x */
566 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10); 673 status = add_dataflash(spi, "AT45DB321x", 8192, 528, 10);
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
index 0399be178620..3aaca88847d3 100644
--- a/drivers/mtd/devices/mtdram.c
+++ b/drivers/mtd/devices/mtdram.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * mtdram - a test mtd device 2 * mtdram - a test mtd device
3 * $Id: mtdram.c,v 1.37 2005/04/21 03:42:11 joern Exp $
4 * Author: Alexander Larsson <alex@cendio.se> 3 * Author: Alexander Larsson <alex@cendio.se>
5 * 4 *
6 * Copyright (c) 1999 Alexander Larsson <alex@cendio.se> 5 * Copyright (c) 1999 Alexander Larsson <alex@cendio.se>
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index c7987b1c5e01..088fbb7595b5 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -1,6 +1,4 @@
1/** 1/**
2 * $Id: phram.c,v 1.16 2005/11/07 11:14:25 gleixner Exp $
3 *
4 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> 2 * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de>
5 * Copyright (c) 2003-2004 Joern Engel <joern@wh.fh-wedel.de> 3 * Copyright (c) 2003-2004 Joern Engel <joern@wh.fh-wedel.de>
6 * 4 *
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index bc9981749064..d38bca64bb15 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: pmc551.c,v 1.32 2005/11/07 11:14:25 gleixner Exp $
3 *
4 * PMC551 PCI Mezzanine Ram Device 2 * PMC551 PCI Mezzanine Ram Device
5 * 3 *
6 * Author: 4 * Author:
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index cb86db746f28..a425d09f35a0 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -1,7 +1,5 @@
1/*====================================================================== 1/*======================================================================
2 2
3 $Id: slram.c,v 1.36 2005/11/07 11:14:25 gleixner Exp $
4
5 This driver provides a method to access memory not used by the kernel 3 This driver provides a method to access memory not used by the kernel
6 itself (i.e. if the kernel commandline mem=xxx is used). To actually 4 itself (i.e. if the kernel commandline mem=xxx is used). To actually
7 use slram at least mtdblock or mtdchar is required (for block or 5 use slram at least mtdblock or mtdchar is required (for block or
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 5c29872184e6..f34f20c78911 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1,5 +1,4 @@
1/* This version ported to the Linux-MTD system by dwmw2@infradead.org 1/* This version ported to the Linux-MTD system by dwmw2@infradead.org
2 * $Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $
3 * 2 *
4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br> 3 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups 4 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -1078,8 +1077,6 @@ static struct mtd_blktrans_ops ftl_tr = {
1078 1077
1079static int init_ftl(void) 1078static int init_ftl(void)
1080{ 1079{
1081 DEBUG(0, "$Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $\n");
1082
1083 return register_mtd_blktrans(&ftl_tr); 1080 return register_mtd_blktrans(&ftl_tr);
1084} 1081}
1085 1082
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index b0e396504e67..c4f9d3378b24 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -7,8 +7,6 @@
7 * (c) 1999 Machine Vision Holdings, Inc. 7 * (c) 1999 Machine Vision Holdings, Inc.
8 * Author: David Woodhouse <dwmw2@infradead.org> 8 * Author: David Woodhouse <dwmw2@infradead.org>
9 * 9 *
10 * $Id: inftlcore.c,v 1.19 2005/11/07 11:14:20 gleixner Exp $
11 *
12 * This program is free software; you can redistribute it and/or modify 10 * 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 11 * 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 12 * the Free Software Foundation; either version 2 of the License, or
@@ -953,9 +951,6 @@ static struct mtd_blktrans_ops inftl_tr = {
953 951
954static int __init init_inftl(void) 952static int __init init_inftl(void)
955{ 953{
956 printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, "
957 "inftlmount.c %s\n", inftlmountrev);
958
959 return register_mtd_blktrans(&inftl_tr); 954 return register_mtd_blktrans(&inftl_tr);
960} 955}
961 956
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index c551d2f0779c..9113628ed1ef 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -8,8 +8,6 @@
8 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 8 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
9 * Copyright (C) 2000 Netgem S.A. 9 * Copyright (C) 2000 Netgem S.A.
10 * 10 *
11 * $Id: inftlmount.c,v 1.18 2005/11/07 11:14:20 gleixner Exp $
12 *
13 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
@@ -39,8 +37,6 @@
39#include <linux/mtd/inftl.h> 37#include <linux/mtd/inftl.h>
40#include <linux/mtd/compatmac.h> 38#include <linux/mtd/compatmac.h>
41 39
42char inftlmountrev[]="$Revision: 1.18 $";
43
44/* 40/*
45 * find_boot_record: Find the INFTL Media Header and its Spare copy which 41 * find_boot_record: Find the INFTL Media Header and its Spare copy which
46 * contains the various device information of the INFTL partition and 42 * contains the various device information of the INFTL partition and
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index d2fbc2964523..df8e00bba07b 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -1,5 +1,4 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.61 2005/11/07 11:14:26 gleixner Exp $
3 2
4menu "Mapping drivers for chip access" 3menu "Mapping drivers for chip access"
5 depends on MTD!=n 4 depends on MTD!=n
@@ -510,6 +509,17 @@ config MTD_PCMCIA_ANONYMOUS
510 509
511 If unsure, say N. 510 If unsure, say N.
512 511
512config MTD_BFIN_ASYNC
513 tristate "Blackfin BF533-STAMP Flash Chip Support"
514 depends on BFIN533_STAMP && MTD_CFI
515 select MTD_PARTITIONS
516 default y
517 help
518 Map driver which allows for simultaneous utilization of
519 ethernet and CFI parallel flash.
520
521 If compiled as a module, it will be called bfin-async-flash.
522
513config MTD_UCLINUX 523config MTD_UCLINUX
514 tristate "Generic uClinux RAM/ROM filesystem support" 524 tristate "Generic uClinux RAM/ROM filesystem support"
515 depends on MTD_PARTITIONS && !MMU 525 depends on MTD_PARTITIONS && !MMU
@@ -539,24 +549,6 @@ config MTD_DMV182
539 help 549 help
540 Map driver for Dy-4 SVME/DMV-182 board. 550 Map driver for Dy-4 SVME/DMV-182 board.
541 551
542config MTD_BAST
543 tristate "Map driver for Simtec BAST (EB2410ITX) or Thorcom VR1000"
544 depends on ARCH_BAST || MACH_VR1000
545 select MTD_PARTITIONS
546 select MTD_MAP_BANK_WIDTH_16
547 select MTD_JEDECPROBE
548 help
549 Map driver for NOR flash on the Simtec BAST (EB2410ITX), or the
550 Thorcom VR1000
551
552 Note, this driver *cannot* over-ride the WP link on the
553 board, or currently detect the state of the link.
554
555config MTD_BAST_MAXSIZE
556 int "Maximum size for BAST flash area (MiB)"
557 depends on MTD_BAST
558 default "4"
559
560config MTD_SHARP_SL 552config MTD_SHARP_SL
561 tristate "ROM mapped on Sharp SL Series" 553 tristate "ROM mapped on Sharp SL Series"
562 depends on ARCH_PXA 554 depends on ARCH_PXA
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index c6ce8673dab2..6cda6df973e5 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -1,7 +1,6 @@
1# 1#
2# linux/drivers/maps/Makefile 2# linux/drivers/maps/Makefile
3# 3#
4# $Id: Makefile.common,v 1.34 2005/11/07 11:14:26 gleixner Exp $
5 4
6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) 5ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y)
7obj-$(CONFIG_MTD) += map_funcs.o 6obj-$(CONFIG_MTD) += map_funcs.o
@@ -10,7 +9,6 @@ endif
10# Chip mappings 9# Chip mappings
11obj-$(CONFIG_MTD_CDB89712) += cdb89712.o 10obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
12obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o 11obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
13obj-$(CONFIG_MTD_BAST) += bast-flash.o
14obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o 12obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
15obj-$(CONFIG_MTD_DC21285) += dc21285.o 13obj-$(CONFIG_MTD_DC21285) += dc21285.o
16obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o 14obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o
@@ -66,3 +64,4 @@ obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
66obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 64obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
67obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 65obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
68obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o 66obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
67obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index 728aed6ad722..948b86f35ef4 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -2,7 +2,6 @@
2 * amd76xrom.c 2 * amd76xrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: amd76xrom.c,v 1.21 2005/11/07 11:14:26 gleixner Exp $
6 */ 5 */
7 6
8#include <linux/module.h> 7#include <linux/module.h>
diff --git a/drivers/mtd/maps/autcpu12-nvram.c b/drivers/mtd/maps/autcpu12-nvram.c
index 7ed3424dd959..cf32267263df 100644
--- a/drivers/mtd/maps/autcpu12-nvram.c
+++ b/drivers/mtd/maps/autcpu12-nvram.c
@@ -2,8 +2,6 @@
2 * NV-RAM memory access on autcpu12 2 * NV-RAM memory access on autcpu12
3 * (C) 2002 Thomas Gleixner (gleixner@autronix.de) 3 * (C) 2002 Thomas Gleixner (gleixner@autronix.de)
4 * 4 *
5 * $Id: autcpu12-nvram.c,v 1.9 2005/11/07 11:14:26 gleixner Exp $
6 *
7 * This program is free software; you can redistribute it and/or modify 5 * 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 6 * 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 7 * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
deleted file mode 100644
index 1f492062f8ca..000000000000
--- a/drivers/mtd/maps/bast-flash.c
+++ /dev/null
@@ -1,226 +0,0 @@
1/* linux/drivers/mtd/maps/bast-flash.c
2 *
3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * Simtec Bast (EB2410ITX) NOR MTD Mapping driver
7 *
8 * Changelog:
9 * 20-Sep-2004 BJD Initial version
10 * 17-Jan-2005 BJD Add whole device if no partitions found
11 *
12 * $Id: bast-flash.c,v 1.5 2005/11/07 11:14:26 gleixner Exp $
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27*/
28
29#include <linux/module.h>
30#include <linux/types.h>
31#include <linux/init.h>
32#include <linux/kernel.h>
33#include <linux/string.h>
34#include <linux/ioport.h>
35#include <linux/device.h>
36#include <linux/slab.h>
37#include <linux/platform_device.h>
38#include <linux/mtd/mtd.h>
39#include <linux/mtd/map.h>
40#include <linux/mtd/partitions.h>
41
42#include <asm/io.h>
43#include <asm/mach/flash.h>
44
45#include <asm/arch/map.h>
46#include <asm/arch/bast-map.h>
47#include <asm/arch/bast-cpld.h>
48
49#ifdef CONFIG_MTD_BAST_MAXSIZE
50#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * SZ_1M)
51#else
52#define AREA_MAXSIZE (32 * SZ_1M)
53#endif
54
55#define PFX "bast-flash: "
56
57struct bast_flash_info {
58 struct mtd_info *mtd;
59 struct map_info map;
60 struct mtd_partition *partitions;
61 struct resource *area;
62};
63
64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
65
66static void bast_flash_setrw(int to)
67{
68 unsigned int val;
69 unsigned long flags;
70
71 local_irq_save(flags);
72 val = __raw_readb(BAST_VA_CTRL3);
73
74 if (to)
75 val |= BAST_CPLD_CTRL3_ROMWEN;
76 else
77 val &= ~BAST_CPLD_CTRL3_ROMWEN;
78
79 pr_debug("new cpld ctrl3=%02x\n", val);
80
81 __raw_writeb(val, BAST_VA_CTRL3);
82 local_irq_restore(flags);
83}
84
85static int bast_flash_remove(struct platform_device *pdev)
86{
87 struct bast_flash_info *info = platform_get_drvdata(pdev);
88
89 platform_set_drvdata(pdev, NULL);
90
91 if (info == NULL)
92 return 0;
93
94 if (info->map.virt != NULL)
95 iounmap(info->map.virt);
96
97 if (info->mtd) {
98 del_mtd_partitions(info->mtd);
99 map_destroy(info->mtd);
100 }
101
102 kfree(info->partitions);
103
104 if (info->area) {
105 release_resource(info->area);
106 kfree(info->area);
107 }
108
109 kfree(info);
110
111 return 0;
112}
113
114static int bast_flash_probe(struct platform_device *pdev)
115{
116 struct bast_flash_info *info;
117 struct resource *res;
118 int err = 0;
119
120 info = kmalloc(sizeof(*info), GFP_KERNEL);
121 if (info == NULL) {
122 printk(KERN_ERR PFX "no memory for flash info\n");
123 err = -ENOMEM;
124 goto exit_error;
125 }
126
127 memzero(info, sizeof(*info));
128 platform_set_drvdata(pdev, info);
129
130 res = pdev->resource; /* assume that the flash has one resource */
131
132 info->map.phys = res->start;
133 info->map.size = res->end - res->start + 1;
134 info->map.name = pdev->dev.bus_id;
135 info->map.bankwidth = 2;
136
137 if (info->map.size > AREA_MAXSIZE)
138 info->map.size = AREA_MAXSIZE;
139
140 pr_debug("%s: area %08lx, size %ld\n", __func__,
141 info->map.phys, info->map.size);
142
143 info->area = request_mem_region(res->start, info->map.size,
144 pdev->name);
145 if (info->area == NULL) {
146 printk(KERN_ERR PFX "cannot reserve flash memory region\n");
147 err = -ENOENT;
148 goto exit_error;
149 }
150
151 info->map.virt = ioremap(res->start, info->map.size);
152 pr_debug("%s: virt at %08x\n", __func__, (int)info->map.virt);
153
154 if (info->map.virt == 0) {
155 printk(KERN_ERR PFX "failed to ioremap() region\n");
156 err = -EIO;
157 goto exit_error;
158 }
159
160 simple_map_init(&info->map);
161
162 /* enable the write to the flash area */
163
164 bast_flash_setrw(1);
165
166 /* probe for the device(s) */
167
168 info->mtd = do_map_probe("jedec_probe", &info->map);
169 if (info->mtd == NULL)
170 info->mtd = do_map_probe("cfi_probe", &info->map);
171
172 if (info->mtd == NULL) {
173 printk(KERN_ERR PFX "map_probe() failed\n");
174 err = -ENXIO;
175 goto exit_error;
176 }
177
178 /* mark ourselves as the owner */
179 info->mtd->owner = THIS_MODULE;
180
181 err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
182 if (err > 0) {
183 err = add_mtd_partitions(info->mtd, info->partitions, err);
184 if (err)
185 printk(KERN_ERR PFX "cannot add/parse partitions\n");
186 } else {
187 err = add_mtd_device(info->mtd);
188 }
189
190 if (err == 0)
191 return 0;
192
193 /* fall through to exit error */
194
195 exit_error:
196 bast_flash_remove(pdev);
197 return err;
198}
199
200static struct platform_driver bast_flash_driver = {
201 .probe = bast_flash_probe,
202 .remove = bast_flash_remove,
203 .driver = {
204 .name = "bast-nor",
205 .owner = THIS_MODULE,
206 },
207};
208
209static int __init bast_flash_init(void)
210{
211 printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n");
212 return platform_driver_register(&bast_flash_driver);
213}
214
215static void __exit bast_flash_exit(void)
216{
217 platform_driver_unregister(&bast_flash_driver);
218}
219
220module_init(bast_flash_init);
221module_exit(bast_flash_exit);
222
223MODULE_LICENSE("GPL");
224MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
225MODULE_DESCRIPTION("BAST MTD Map driver");
226MODULE_ALIAS("platform:bast-nor");
diff --git a/drivers/mtd/maps/bfin-async-flash.c b/drivers/mtd/maps/bfin-async-flash.c
new file mode 100644
index 000000000000..6fec86aaed7e
--- /dev/null
+++ b/drivers/mtd/maps/bfin-async-flash.c
@@ -0,0 +1,219 @@
1/*
2 * drivers/mtd/maps/bfin-async-flash.c
3 *
4 * Handle the case where flash memory and ethernet mac/phy are
5 * mapped onto the same async bank. The BF533-STAMP does this
6 * for example. All board-specific configuration goes in your
7 * board resources file.
8 *
9 * Copyright 2000 Nicolas Pitre <nico@cam.org>
10 * Copyright 2005-2008 Analog Devices Inc.
11 *
12 * Enter bugs at http://blackfin.uclinux.org/
13 *
14 * Licensed under the GPL-2 or later.
15 */
16
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/map.h>
22#include <linux/mtd/partitions.h>
23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h>
25#include <linux/types.h>
26
27#include <asm/blackfin.h>
28#include <linux/gpio.h>
29#include <linux/io.h>
30#include <asm/unaligned.h>
31
32#define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); })
33
34#define DRIVER_NAME "bfin-async-flash"
35
36struct async_state {
37 struct mtd_info *mtd;
38 struct map_info map;
39 int enet_flash_pin;
40 uint32_t flash_ambctl0, flash_ambctl1;
41 uint32_t save_ambctl0, save_ambctl1;
42 unsigned long irq_flags;
43};
44
45static void switch_to_flash(struct async_state *state)
46{
47 local_irq_save(state->irq_flags);
48
49 gpio_set_value(state->enet_flash_pin, 0);
50
51 state->save_ambctl0 = bfin_read_EBIU_AMBCTL0();
52 state->save_ambctl1 = bfin_read_EBIU_AMBCTL1();
53 bfin_write_EBIU_AMBCTL0(state->flash_ambctl0);
54 bfin_write_EBIU_AMBCTL1(state->flash_ambctl1);
55 SSYNC();
56}
57
58static void switch_back(struct async_state *state)
59{
60 bfin_write_EBIU_AMBCTL0(state->save_ambctl0);
61 bfin_write_EBIU_AMBCTL1(state->save_ambctl1);
62 SSYNC();
63
64 gpio_set_value(state->enet_flash_pin, 1);
65
66 local_irq_restore(state->irq_flags);
67}
68
69static map_word bfin_read(struct map_info *map, unsigned long ofs)
70{
71 struct async_state *state = (struct async_state *)map->map_priv_1;
72 uint16_t word;
73 map_word test;
74
75 switch_to_flash(state);
76
77 word = readw(map->virt + ofs);
78
79 switch_back(state);
80
81 test.x[0] = word;
82 return test;
83}
84
85static void bfin_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
86{
87 struct async_state *state = (struct async_state *)map->map_priv_1;
88
89 switch_to_flash(state);
90
91 memcpy(to, map->virt + from, len);
92
93 switch_back(state);
94}
95
96static void bfin_write(struct map_info *map, map_word d1, unsigned long ofs)
97{
98 struct async_state *state = (struct async_state *)map->map_priv_1;
99 uint16_t d;
100
101 d = d1.x[0];
102
103 switch_to_flash(state);
104
105 writew(d, map->virt + ofs);
106 SSYNC();
107
108 switch_back(state);
109}
110
111static void bfin_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
112{
113 struct async_state *state = (struct async_state *)map->map_priv_1;
114
115 switch_to_flash(state);
116
117 memcpy(map->virt + to, from, len);
118 SSYNC();
119
120 switch_back(state);
121}
122
123#ifdef CONFIG_MTD_PARTITIONS
124static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
125#endif
126
127static int __devinit bfin_flash_probe(struct platform_device *pdev)
128{
129 int ret;
130 struct physmap_flash_data *pdata = pdev->dev.platform_data;
131 struct resource *memory = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132 struct resource *flash_ambctl = platform_get_resource(pdev, IORESOURCE_MEM, 1);
133 struct async_state *state;
134
135 state = kzalloc(sizeof(*state), GFP_KERNEL);
136 if (!state)
137 return -ENOMEM;
138
139 state->map.name = DRIVER_NAME;
140 state->map.read = bfin_read;
141 state->map.copy_from = bfin_copy_from;
142 state->map.write = bfin_write;
143 state->map.copy_to = bfin_copy_to;
144 state->map.bankwidth = pdata->width;
145 state->map.size = memory->end - memory->start + 1;
146 state->map.virt = (void __iomem *)memory->start;
147 state->map.phys = memory->start;
148 state->map.map_priv_1 = (unsigned long)state;
149 state->enet_flash_pin = platform_get_irq(pdev, 0);
150 state->flash_ambctl0 = flash_ambctl->start;
151 state->flash_ambctl1 = flash_ambctl->end;
152
153 if (gpio_request(state->enet_flash_pin, DRIVER_NAME)) {
154 pr_devinit(KERN_ERR DRIVER_NAME ": Failed to request gpio %d\n", state->enet_flash_pin);
155 return -EBUSY;
156 }
157 gpio_direction_output(state->enet_flash_pin, 1);
158
159 pr_devinit(KERN_NOTICE DRIVER_NAME ": probing %d-bit flash bus\n", state->map.bankwidth * 8);
160 state->mtd = do_map_probe(memory->name, &state->map);
161 if (!state->mtd)
162 return -ENXIO;
163
164#ifdef CONFIG_MTD_PARTITIONS
165 ret = parse_mtd_partitions(state->mtd, part_probe_types, &pdata->parts, 0);
166 if (ret > 0) {
167 pr_devinit(KERN_NOTICE DRIVER_NAME ": Using commandline partition definition\n");
168 add_mtd_partitions(state->mtd, pdata->parts, ret);
169
170 } else if (pdata->nr_parts) {
171 pr_devinit(KERN_NOTICE DRIVER_NAME ": Using board partition definition\n");
172 add_mtd_partitions(state->mtd, pdata->parts, pdata->nr_parts);
173
174 } else
175#endif
176 {
177 pr_devinit(KERN_NOTICE DRIVER_NAME ": no partition info available, registering whole flash at once\n");
178 add_mtd_device(state->mtd);
179 }
180
181 platform_set_drvdata(pdev, state);
182
183 return 0;
184}
185
186static int __devexit bfin_flash_remove(struct platform_device *pdev)
187{
188 struct async_state *state = platform_get_drvdata(pdev);
189 gpio_free(state->enet_flash_pin);
190#ifdef CONFIG_MTD_PARTITIONS
191 del_mtd_partitions(state->mtd);
192#endif
193 map_destroy(state->mtd);
194 kfree(state);
195 return 0;
196}
197
198static struct platform_driver bfin_flash_driver = {
199 .probe = bfin_flash_probe,
200 .remove = __devexit_p(bfin_flash_remove),
201 .driver = {
202 .name = DRIVER_NAME,
203 },
204};
205
206static int __init bfin_flash_init(void)
207{
208 return platform_driver_register(&bfin_flash_driver);
209}
210module_init(bfin_flash_init);
211
212static void __exit bfin_flash_exit(void)
213{
214 platform_driver_unregister(&bfin_flash_driver);
215}
216module_exit(bfin_flash_exit);
217
218MODULE_LICENSE("GPL");
219MODULE_DESCRIPTION("MTD map driver for Blackfins with flash/ethernet on same async bank");
diff --git a/drivers/mtd/maps/cdb89712.c b/drivers/mtd/maps/cdb89712.c
index 9f17bb6c5a9d..cb507da0a87d 100644
--- a/drivers/mtd/maps/cdb89712.c
+++ b/drivers/mtd/maps/cdb89712.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Flash on Cirrus CDB89712 2 * Flash on Cirrus CDB89712
3 * 3 *
4 * $Id: cdb89712.c,v 1.11 2005/11/07 11:14:26 gleixner Exp $
5 */ 4 */
6 5
7#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
index 629e6e2641a8..6464d487eb1a 100644
--- a/drivers/mtd/maps/ceiva.c
+++ b/drivers/mtd/maps/ceiva.c
@@ -11,7 +11,6 @@
11 * 11 *
12 * (C) 2000 Nicolas Pitre <nico@cam.org> 12 * (C) 2000 Nicolas Pitre <nico@cam.org>
13 * 13 *
14 * $Id: ceiva.c,v 1.11 2004/09/16 23:27:12 gleixner Exp $
15 */ 14 */
16 15
17#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
index 65e5ee552010..0ecc3f6d735b 100644
--- a/drivers/mtd/maps/cfi_flagadm.c
+++ b/drivers/mtd/maps/cfi_flagadm.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is> 2 * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is>
3 * 3 *
4 * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $
5 *
6 * This program is free software; you can redistribute it and/or modify it 4 * 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 5 * 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 6 * Free Software Foundation; either version 2 of the License, or (at your
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c
index 92a9c7fac993..e115667bf1d0 100644
--- a/drivers/mtd/maps/dbox2-flash.c
+++ b/drivers/mtd/maps/dbox2-flash.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: dbox2-flash.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
3 *
4 * D-Box 2 flash driver 2 * D-Box 2 flash driver
5 */ 3 */
6 4
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index b32bb9347d71..3aa018c092f8 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -4,8 +4,6 @@
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 *
8 * $Id: dc21285.c,v 1.24 2005/11/07 11:14:26 gleixner Exp $
9 */ 7 */
10#include <linux/module.h> 8#include <linux/module.h>
11#include <linux/types.h> 9#include <linux/types.h>
diff --git a/drivers/mtd/maps/dilnetpc.c b/drivers/mtd/maps/dilnetpc.c
index 1c3b34ad7325..0713e3a5a22c 100644
--- a/drivers/mtd/maps/dilnetpc.c
+++ b/drivers/mtd/maps/dilnetpc.c
@@ -14,8 +14,6 @@
14 * along with this program; if not, write to the Free Software 14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
16 * 16 *
17 * $Id: dilnetpc.c,v 1.20 2005/11/07 11:14:26 gleixner Exp $
18 *
19 * The DIL/Net PC is a tiny embedded PC board made by SSV Embedded Systems 17 * The DIL/Net PC is a tiny embedded PC board made by SSV Embedded Systems
20 * featuring the AMD Elan SC410 processor. There are two variants of this 18 * featuring the AMD Elan SC410 processor. There are two variants of this
21 * board: DNP/1486 and ADNP/1486. The DNP version has 2 megs of flash 19 * board: DNP/1486 and ADNP/1486. The DNP version has 2 megs of flash
diff --git a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c
index e0558b0b2fe6..d171674eb2ed 100644
--- a/drivers/mtd/maps/dmv182.c
+++ b/drivers/mtd/maps/dmv182.c
@@ -4,8 +4,6 @@
4 * 4 *
5 * Flash map driver for the Dy4 SVME182 board 5 * Flash map driver for the Dy4 SVME182 board
6 * 6 *
7 * $Id: dmv182.c,v 1.6 2005/11/07 11:14:26 gleixner Exp $
8 *
9 * Copyright 2003-2004, TimeSys Corporation 7 * Copyright 2003-2004, TimeSys Corporation
10 * 8 *
11 * Based on the SVME181 flash map, by Tom Nelson, Dot4, Inc. for TimeSys Corp. 9 * Based on the SVME181 flash map, by Tom Nelson, Dot4, Inc. for TimeSys Corp.
diff --git a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c
index 1488bb92f26f..d92b7c70d3ed 100644
--- a/drivers/mtd/maps/ebony.c
+++ b/drivers/mtd/maps/ebony.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ebony.c,v 1.16 2005/11/07 11:14:26 gleixner Exp $
3 *
4 * Mapping for Ebony user flash 2 * Mapping for Ebony user flash
5 * 3 *
6 * Matt Porter <mporter@kernel.crashing.org> 4 * Matt Porter <mporter@kernel.crashing.org>
diff --git a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c
index 1c5b97c89685..9433738c1664 100644
--- a/drivers/mtd/maps/edb7312.c
+++ b/drivers/mtd/maps/edb7312.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: edb7312.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards 2 * Handle mapping of the NOR flash on Cogent EDB7312 boards
5 * 3 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 4 * Copyright 2002 SYSGO Real-Time Solutions GmbH
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c
index 7c50c271651c..a8e3fde4cbd5 100644
--- a/drivers/mtd/maps/fortunet.c
+++ b/drivers/mtd/maps/fortunet.c
@@ -1,6 +1,5 @@
1/* fortunet.c memory map 1/* fortunet.c memory map
2 * 2 *
3 * $Id: fortunet.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $
4 */ 3 */
5 4
6#include <linux/module.h> 5#include <linux/module.h>
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
index 6dde3182d64a..ef8915474462 100644
--- a/drivers/mtd/maps/h720x-flash.c
+++ b/drivers/mtd/maps/h720x-flash.c
@@ -2,8 +2,6 @@
2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based 2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based
3 * evaluation boards 3 * evaluation boards
4 * 4 *
5 * $Id: h720x-flash.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $
6 *
7 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com> 5 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
8 * 2003 Thomas Gleixner <tglx@linutronix.de> 6 * 2003 Thomas Gleixner <tglx@linutronix.de>
9 */ 7 */
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index 2c884c49e84a..aeb6c916e23f 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -2,7 +2,6 @@
2 * ichxrom.c 2 * ichxrom.c
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * $Id: ichxrom.c,v 1.19 2005/11/07 11:14:27 gleixner Exp $
6 */ 5 */
7 6
8#include <linux/module.h> 7#include <linux/module.h>
diff --git a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c
index a0b4dc7155dc..2682ab51a367 100644
--- a/drivers/mtd/maps/impa7.c
+++ b/drivers/mtd/maps/impa7.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: impa7.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Handle mapping of the NOR flash on implementa A7 boards 2 * Handle mapping of the NOR flash on implementa A7 boards
5 * 3 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH 4 * Copyright 2002 SYSGO Real-Time Solutions GmbH
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index 325c8880c437..ee361aaadb1e 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -22,8 +22,6 @@
22 This is access code for flashes using ARM's flash partitioning 22 This is access code for flashes using ARM's flash partitioning
23 standards. 23 standards.
24 24
25 $Id: integrator-flash.c,v 1.20 2005/11/07 11:14:27 gleixner Exp $
26
27======================================================================*/ 25======================================================================*/
28 26
29#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index f27c132794c3..a806119797e0 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -4,8 +4,6 @@
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com> 5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com>
6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes 6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes
7 *
8 * $Id: ipaq-flash.c,v 1.5 2005/11/07 11:14:27 gleixner Exp $
9 */ 7 */
10 8
11#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index c8396b8574c4..c2264792a20b 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ixp2000.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * drivers/mtd/maps/ixp2000.c 2 * drivers/mtd/maps/ixp2000.c
5 * 3 *
6 * Mapping for the Intel XScale IXP2000 based systems 4 * Mapping for the Intel XScale IXP2000 based systems
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 01f19a4714b5..9c7a5fbd4e51 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ixp4xx.c,v 1.13 2005/11/16 16:23:21 dvrabel Exp $
3 *
4 * drivers/mtd/maps/ixp4xx.c 2 * drivers/mtd/maps/ixp4xx.c
5 * 3 *
6 * MTD Map file for IXP4XX based systems. Please do not make per-board 4 * MTD Map file for IXP4XX based systems. Please do not make per-board
diff --git a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c
index 67620adf4811..9e054503c4cf 100644
--- a/drivers/mtd/maps/l440gx.c
+++ b/drivers/mtd/maps/l440gx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: l440gx.c,v 1.18 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * BIOS Flash chip on Intel 440GX board. 2 * BIOS Flash chip on Intel 440GX board.
5 * 3 *
6 * Bugs this currently does not work under linuxBIOS. 4 * Bugs this currently does not work under linuxBIOS.
diff --git a/drivers/mtd/maps/map_funcs.c b/drivers/mtd/maps/map_funcs.c
index 9105e6ca0aa6..3f268370eeca 100644
--- a/drivers/mtd/maps/map_funcs.c
+++ b/drivers/mtd/maps/map_funcs.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: map_funcs.c,v 1.10 2005/06/06 23:04:36 tpoynor Exp $
3 *
4 * Out-of-line map I/O functions for simple maps when CONFIG_COMPLEX_MAPPINGS 2 * Out-of-line map I/O functions for simple maps when CONFIG_COMPLEX_MAPPINGS
5 * is enabled. 3 * is enabled.
6 */ 4 */
diff --git a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c
index 06b118727846..706f67394b07 100644
--- a/drivers/mtd/maps/mbx860.c
+++ b/drivers/mtd/maps/mbx860.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mbx860.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Handle mapping of the flash on MBX860 boards 2 * Handle mapping of the flash on MBX860 boards
5 * 3 *
6 * Author: Anton Todorov 4 * Author: Anton Todorov
diff --git a/drivers/mtd/maps/netsc520.c b/drivers/mtd/maps/netsc520.c
index 95dcab2146ad..c0cb319b2b70 100644
--- a/drivers/mtd/maps/netsc520.c
+++ b/drivers/mtd/maps/netsc520.c
@@ -3,8 +3,6 @@
3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com) 3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH 4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
5 * 5 *
6 * $Id: netsc520.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * 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 7 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index 0c9b305a72e0..965e6c6d6ab0 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -5,8 +5,6 @@
5 * 5 *
6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com) 7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com)
8 *
9 * $Id: nettel.c,v 1.12 2005/11/29 14:30:00 gleixner Exp $
10 */ 8 */
11 9
12/****************************************************************************/ 10/****************************************************************************/
diff --git a/drivers/mtd/maps/octagon-5066.c b/drivers/mtd/maps/octagon-5066.c
index a6642db3d325..43e04c1d22a9 100644
--- a/drivers/mtd/maps/octagon-5066.c
+++ b/drivers/mtd/maps/octagon-5066.c
@@ -1,4 +1,3 @@
1// $Id: octagon-5066.c,v 1.28 2005/11/07 11:14:27 gleixner Exp $
2/* ###################################################################### 1/* ######################################################################
3 2
4 Octagon 5066 MTD Driver. 3 Octagon 5066 MTD Driver.
diff --git a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c
index e6e391efbeb6..0a60ebbc2175 100644
--- a/drivers/mtd/maps/omap-toto-flash.c
+++ b/drivers/mtd/maps/omap-toto-flash.c
@@ -4,8 +4,6 @@
4 * jzhang@ti.com (C) 2003 Texas Instruments. 4 * jzhang@ti.com (C) 2003 Texas Instruments.
5 * 5 *
6 * (C) 2002 MontVista Software, Inc. 6 * (C) 2002 MontVista Software, Inc.
7 *
8 * $Id: omap-toto-flash.c,v 1.5 2005/11/07 11:14:27 gleixner Exp $
9 */ 7 */
10 8
11#include <linux/module.h> 9#include <linux/module.h>
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index d2ab1bae9c34..5c6a25c90380 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,8 +7,6 @@
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 * $Id: pci.c,v 1.14 2005/11/17 08:20:27 dwmw2 Exp $
11 *
12 * Generic PCI memory map driver. We support the following boards: 10 * Generic PCI memory map driver. We support the following boards:
13 * - Intel IQ80310 ATU. 11 * - Intel IQ80310 ATU.
14 * - Intel EBSA285 (blank rom programming mode). Tested working 27/09/2001 12 * - Intel EBSA285 (blank rom programming mode). Tested working 27/09/2001
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 0cc31675aeb9..90924fb00481 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: pcmciamtd.c,v 1.55 2005/11/07 11:14:28 gleixner Exp $
3 *
4 * pcmciamtd.c - MTD driver for PCMCIA flash memory cards 2 * pcmciamtd.c - MTD driver for PCMCIA flash memory cards
5 * 3 *
6 * Author: Simon Evans <spse@secret.org.uk> 4 * Author: Simon Evans <spse@secret.org.uk>
@@ -48,7 +46,6 @@ static const int debug = 0;
48 46
49 47
50#define DRIVER_DESC "PCMCIA Flash memory card driver" 48#define DRIVER_DESC "PCMCIA Flash memory card driver"
51#define DRIVER_VERSION "$Revision: 1.55 $"
52 49
53/* Size of the PCMCIA address space: 26 bits = 64 MB */ 50/* Size of the PCMCIA address space: 26 bits = 64 MB */
54#define MAX_PCMCIA_ADDR 0x4000000 51#define MAX_PCMCIA_ADDR 0x4000000
@@ -785,7 +782,7 @@ static struct pcmcia_driver pcmciamtd_driver = {
785 782
786static int __init init_pcmciamtd(void) 783static int __init init_pcmciamtd(void)
787{ 784{
788 info(DRIVER_DESC " " DRIVER_VERSION); 785 info(DRIVER_DESC);
789 786
790 if(bankwidth && bankwidth != 1 && bankwidth != 2) { 787 if(bankwidth && bankwidth != 1 && bankwidth != 2) {
791 info("bad bankwidth (%d), using default", bankwidth); 788 info("bad bankwidth (%d), using default", bankwidth);
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 183255fcfdcb..42d844f8f6bf 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: physmap.c,v 1.39 2005/11/29 14:49:36 gleixner Exp $
3 *
4 * Normal mappings of chips in physical memory 2 * Normal mappings of chips in physical memory
5 * 3 *
6 * Copyright (C) 2003 MontaVista Software Inc. 4 * Copyright (C) 2003 MontaVista Software Inc.
@@ -203,7 +201,19 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
203 int i; 201 int i;
204 202
205 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++) 203 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
206 ret |= info->mtd[i]->suspend(info->mtd[i]); 204 if (info->mtd[i]->suspend) {
205 ret = info->mtd[i]->suspend(info->mtd[i]);
206 if (ret)
207 goto fail;
208 }
209
210 return 0;
211fail:
212 for (--i; i >= 0; --i)
213 if (info->mtd[i]->suspend) {
214 BUG_ON(!info->mtd[i]->resume);
215 info->mtd[i]->resume(info->mtd[i]);
216 }
207 217
208 return ret; 218 return ret;
209} 219}
@@ -214,7 +224,8 @@ static int physmap_flash_resume(struct platform_device *dev)
214 int i; 224 int i;
215 225
216 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++) 226 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
217 info->mtd[i]->resume(info->mtd[i]); 227 if (info->mtd[i]->resume)
228 info->mtd[i]->resume(info->mtd[i]);
218 229
219 return 0; 230 return 0;
220} 231}
@@ -225,8 +236,9 @@ static void physmap_flash_shutdown(struct platform_device *dev)
225 int i; 236 int i;
226 237
227 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++) 238 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
228 if (info->mtd[i]->suspend(info->mtd[i]) == 0) 239 if (info->mtd[i]->suspend && info->mtd[i]->resume)
229 info->mtd[i]->resume(info->mtd[i]); 240 if (info->mtd[i]->suspend(info->mtd[i]) == 0)
241 info->mtd[i]->resume(info->mtd[i]);
230} 242}
231#else 243#else
232#define physmap_flash_suspend NULL 244#define physmap_flash_suspend NULL
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 3eb2643b2328..e7dd9c8a965e 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -6,8 +6,6 @@
6 * 6 *
7 * Generic platfrom device based RAM map 7 * Generic platfrom device based RAM map
8 * 8 *
9 * $Id: plat-ram.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $
10 *
11 * 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
12 * 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
13 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c
index 4d858b3d5f82..de002eb1a7fe 100644
--- a/drivers/mtd/maps/redwood.c
+++ b/drivers/mtd/maps/redwood.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: redwood.c,v 1.11 2005/11/07 11:14:28 gleixner Exp $
3 *
4 * drivers/mtd/maps/redwood.c 2 * drivers/mtd/maps/redwood.c
5 * 3 *
6 * FLASH map for the IBM Redwood 4/5/6 boards. 4 * FLASH map for the IBM Redwood 4/5/6 boards.
diff --git a/drivers/mtd/maps/rpxlite.c b/drivers/mtd/maps/rpxlite.c
index 809a0c8e7aaf..14d90edb4430 100644
--- a/drivers/mtd/maps/rpxlite.c
+++ b/drivers/mtd/maps/rpxlite.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: rpxlite.c,v 1.22 2004/11/04 13:24:15 gleixner Exp $
3 *
4 * Handle mapping of the flash on the RPX Lite and CLLF boards 2 * Handle mapping of the flash on the RPX Lite and CLLF boards
5 */ 3 */
6 4
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index c7d5a52a2d55..e177a43dfff0 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -2,8 +2,6 @@
2 * Flash memory access on SA11x0 based devices 2 * Flash memory access on SA11x0 based devices
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 *
6 * $Id: sa1100-flash.c,v 1.51 2005/11/07 11:14:28 gleixner Exp $
7 */ 5 */
8#include <linux/module.h> 6#include <linux/module.h>
9#include <linux/types.h> 7#include <linux/types.h>
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c
index b8c1331b7a04..6e1e99cd2b59 100644
--- a/drivers/mtd/maps/sbc8240.c
+++ b/drivers/mtd/maps/sbc8240.c
@@ -4,9 +4,6 @@
4 * Carolyn Smith, Tektronix, Inc. 4 * Carolyn Smith, Tektronix, Inc.
5 * 5 *
6 * This code is GPLed 6 * This code is GPLed
7 *
8 * $Id: sbc8240.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
9 *
10 */ 7 */
11 8
12/* 9/*
diff --git a/drivers/mtd/maps/sbc_gxx.c b/drivers/mtd/maps/sbc_gxx.c
index 7cc4041d096d..1b1c0b7e11ef 100644
--- a/drivers/mtd/maps/sbc_gxx.c
+++ b/drivers/mtd/maps/sbc_gxx.c
@@ -17,8 +17,6 @@
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 19
20 $Id: sbc_gxx.c,v 1.35 2005/11/07 11:14:28 gleixner Exp $
21
22The SBC-MediaGX / SBC-GXx has up to 16 MiB of 20The SBC-MediaGX / SBC-GXx has up to 16 MiB of
23Intel StrataFlash (28F320/28F640) in x8 mode. 21Intel StrataFlash (28F320/28F640) in x8 mode.
24 22
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index 4045e372b90d..85c1e56309ec 100644
--- a/drivers/mtd/maps/sc520cdp.c
+++ b/drivers/mtd/maps/sc520cdp.c
@@ -16,8 +16,6 @@
16 * along with this program; if not, write to the Free Software 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 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 * 18 *
19 * $Id: sc520cdp.c,v 1.23 2005/11/17 08:20:27 dwmw2 Exp $
20 *
21 * 19 *
22 * The SC520CDP is an evaluation board for the Elan SC520 processor available 20 * The SC520CDP is an evaluation board for the Elan SC520 processor available
23 * from AMD. It has two banks of 32-bit Flash ROM, each 8 Megabytes in size, 21 * from AMD. It has two banks of 32-bit Flash ROM, each 8 Megabytes in size,
diff --git a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c
index 0fc5584324e3..21169e6d646c 100644
--- a/drivers/mtd/maps/scb2_flash.c
+++ b/drivers/mtd/maps/scb2_flash.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * MTD map driver for BIOS Flash on Intel SCB2 boards 2 * MTD map driver for BIOS Flash on Intel SCB2 boards
3 * $Id: scb2_flash.c,v 1.12 2005/03/18 14:04:35 gleixner Exp $
4 * Copyright (C) 2002 Sun Microsystems, Inc. 3 * Copyright (C) 2002 Sun Microsystems, Inc.
5 * Tim Hockin <thockin@sun.com> 4 * Tim Hockin <thockin@sun.com>
6 * 5 *
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c
index 5e2bce22f37c..b5391ebb736e 100644
--- a/drivers/mtd/maps/scx200_docflash.c
+++ b/drivers/mtd/maps/scx200_docflash.c
@@ -2,8 +2,6 @@
2 2
3 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> 3 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
4 4
5 $Id: scx200_docflash.c,v 1.12 2005/11/07 11:14:28 gleixner Exp $
6
7 National Semiconductor SCx200 flash mapped with DOCCS 5 National Semiconductor SCx200 flash mapped with DOCCS
8*/ 6*/
9 7
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c
index 917dc778f24e..026eab028189 100644
--- a/drivers/mtd/maps/sharpsl-flash.c
+++ b/drivers/mtd/maps/sharpsl-flash.c
@@ -4,8 +4,6 @@
4 * Copyright (C) 2001 Lineo Japan, Inc. 4 * Copyright (C) 2001 Lineo Japan, Inc.
5 * Copyright (C) 2002 SHARP 5 * Copyright (C) 2002 SHARP
6 * 6 *
7 * $Id: sharpsl-flash.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $
8 *
9 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp 7 * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp
10 * Handle mapping of the flash on the RPX Lite and CLLF boards 8 * Handle mapping of the flash on the RPX Lite and CLLF boards
11 * 9 *
diff --git a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c
index d76ceef453ce..0eb41d9c6786 100644
--- a/drivers/mtd/maps/solutionengine.c
+++ b/drivers/mtd/maps/solutionengine.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: solutionengine.c,v 1.15 2005/11/07 11:14:28 gleixner Exp $
3 *
4 * Flash and EPROM on Hitachi Solution Engine and similar boards. 2 * Flash and EPROM on Hitachi Solution Engine and similar boards.
5 * 3 *
6 * (C) 2001 Red Hat, Inc. 4 * (C) 2001 Red Hat, Inc.
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
index 001af7f7ddda..0d7c88396c88 100644
--- a/drivers/mtd/maps/sun_uflash.c
+++ b/drivers/mtd/maps/sun_uflash.c
@@ -1,4 +1,4 @@
1/* $Id: sun_uflash.c,v 1.13 2005/11/07 11:14:28 gleixner Exp $ 1/*
2 * 2 *
3 * sun_uflash - Driver implementation for user-programmable flash 3 * sun_uflash - Driver implementation for user-programmable flash
4 * present on many Sun Microsystems SME boardsets. 4 * present on many Sun Microsystems SME boardsets.
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c
index 521734057314..a5d3d8531faa 100644
--- a/drivers/mtd/maps/tqm8xxl.c
+++ b/drivers/mtd/maps/tqm8xxl.c
@@ -2,8 +2,6 @@
2 * Handle mapping of the flash memory access routines 2 * Handle mapping of the flash memory access routines
3 * on TQM8xxL based devices. 3 * on TQM8xxL based devices.
4 * 4 *
5 * $Id: tqm8xxl.c,v 1.15 2005/11/07 11:14:28 gleixner Exp $
6 *
7 * based on rpxlite.c 5 * based on rpxlite.c
8 * 6 *
9 * Copyright(C) 2001 Kirk Lee <kirk@hpc.ee.ntu.edu.tw> 7 * Copyright(C) 2001 Kirk Lee <kirk@hpc.ee.ntu.edu.tw>
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c
index b47270e850bc..e2147bf11c88 100644
--- a/drivers/mtd/maps/ts5500_flash.c
+++ b/drivers/mtd/maps/ts5500_flash.c
@@ -22,8 +22,6 @@
22 * - Drive A and B use the resident flash disk (RFD) flash translation layer. 22 * - Drive A and B use the resident flash disk (RFD) flash translation layer.
23 * - If you have created your own jffs file system and the bios overwrites 23 * - If you have created your own jffs file system and the bios overwrites
24 * it during boot, try disabling Drive A: and B: in the boot order. 24 * it during boot, try disabling Drive A: and B: in the boot order.
25 *
26 * $Id: ts5500_flash.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
27 */ 25 */
28 26
29#include <linux/init.h> 27#include <linux/init.h>
diff --git a/drivers/mtd/maps/tsunami_flash.c b/drivers/mtd/maps/tsunami_flash.c
index 0f915ac3102e..77a8bfc02577 100644
--- a/drivers/mtd/maps/tsunami_flash.c
+++ b/drivers/mtd/maps/tsunami_flash.c
@@ -2,7 +2,6 @@
2 * tsunami_flash.c 2 * tsunami_flash.c
3 * 3 *
4 * flash chip on alpha ds10... 4 * flash chip on alpha ds10...
5 * $Id: tsunami_flash.c,v 1.10 2005/11/07 11:14:29 gleixner Exp $
6 */ 5 */
7#include <asm/io.h> 6#include <asm/io.h>
8#include <asm/core_tsunami.h> 7#include <asm/core_tsunami.h>
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c
index 3fcf92130aa4..0dc645f8152f 100644
--- a/drivers/mtd/maps/uclinux.c
+++ b/drivers/mtd/maps/uclinux.c
@@ -4,8 +4,6 @@
4 * uclinux.c -- generic memory mapped MTD driver for uclinux 4 * uclinux.c -- generic memory mapped MTD driver for uclinux
5 * 5 *
6 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
7 *
8 * $Id: uclinux.c,v 1.12 2005/11/07 11:14:29 gleixner Exp $
9 */ 7 */
10 8
11/****************************************************************************/ 9/****************************************************************************/
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c
index b3e487395435..5a0c9a353b0f 100644
--- a/drivers/mtd/maps/vmax301.c
+++ b/drivers/mtd/maps/vmax301.c
@@ -1,4 +1,3 @@
1// $Id: vmax301.c,v 1.32 2005/11/07 11:14:29 gleixner Exp $
2/* ###################################################################### 1/* ######################################################################
3 2
4 Tempustech VMAX SBC301 MTD Driver. 3 Tempustech VMAX SBC301 MTD Driver.
diff --git a/drivers/mtd/maps/walnut.c b/drivers/mtd/maps/walnut.c
index ca932122fb64..e243476c8171 100644
--- a/drivers/mtd/maps/walnut.c
+++ b/drivers/mtd/maps/walnut.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: walnut.c,v 1.3 2005/11/07 11:14:29 gleixner Exp $
3 *
4 * Mapping for Walnut flash 2 * Mapping for Walnut flash
5 * (used ebony.c as a "framework") 3 * (used ebony.c as a "framework")
6 * 4 *
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c
index ac5b8105b6ef..413b0cf9bbd2 100644
--- a/drivers/mtd/maps/wr_sbc82xx_flash.c
+++ b/drivers/mtd/maps/wr_sbc82xx_flash.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: wr_sbc82xx_flash.c,v 1.8 2005/11/07 11:14:29 gleixner Exp $
3 *
4 * Map for flash chips on Wind River PowerQUICC II SBC82xx board. 2 * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
5 * 3 *
6 * Copyright (C) 2004 Red Hat, Inc. 4 * Copyright (C) 2004 Red Hat, Inc.
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 839eed8430a2..9ff007c4962c 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd_blkdevs.c,v 1.27 2005/11/07 11:14:20 gleixner Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 3 *
6 * Interface to Linux 2.5 block layer for MTD 'translation layers'. 4 * Interface to Linux 2.5 block layer for MTD 'translation layers'.
@@ -212,7 +210,7 @@ static struct block_device_operations mtd_blktrans_ops = {
212int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) 210int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
213{ 211{
214 struct mtd_blktrans_ops *tr = new->tr; 212 struct mtd_blktrans_ops *tr = new->tr;
215 struct list_head *this; 213 struct mtd_blktrans_dev *d;
216 int last_devnum = -1; 214 int last_devnum = -1;
217 struct gendisk *gd; 215 struct gendisk *gd;
218 216
@@ -221,8 +219,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
221 BUG(); 219 BUG();
222 } 220 }
223 221
224 list_for_each(this, &tr->devs) { 222 list_for_each_entry(d, &tr->devs, list) {
225 struct mtd_blktrans_dev *d = list_entry(this, struct mtd_blktrans_dev, list);
226 if (new->devnum == -1) { 223 if (new->devnum == -1) {
227 /* Use first free number */ 224 /* Use first free number */
228 if (d->devnum != last_devnum+1) { 225 if (d->devnum != last_devnum+1) {
@@ -309,33 +306,24 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
309 306
310static void blktrans_notify_remove(struct mtd_info *mtd) 307static void blktrans_notify_remove(struct mtd_info *mtd)
311{ 308{
312 struct list_head *this, *this2, *next; 309 struct mtd_blktrans_ops *tr;
313 310 struct mtd_blktrans_dev *dev, *next;
314 list_for_each(this, &blktrans_majors) {
315 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
316
317 list_for_each_safe(this2, next, &tr->devs) {
318 struct mtd_blktrans_dev *dev = list_entry(this2, struct mtd_blktrans_dev, list);
319 311
312 list_for_each_entry(tr, &blktrans_majors, list)
313 list_for_each_entry_safe(dev, next, &tr->devs, list)
320 if (dev->mtd == mtd) 314 if (dev->mtd == mtd)
321 tr->remove_dev(dev); 315 tr->remove_dev(dev);
322 }
323 }
324} 316}
325 317
326static void blktrans_notify_add(struct mtd_info *mtd) 318static void blktrans_notify_add(struct mtd_info *mtd)
327{ 319{
328 struct list_head *this; 320 struct mtd_blktrans_ops *tr;
329 321
330 if (mtd->type == MTD_ABSENT) 322 if (mtd->type == MTD_ABSENT)
331 return; 323 return;
332 324
333 list_for_each(this, &blktrans_majors) { 325 list_for_each_entry(tr, &blktrans_majors, list)
334 struct mtd_blktrans_ops *tr = list_entry(this, struct mtd_blktrans_ops, list);
335
336 tr->add_mtd(tr, mtd); 326 tr->add_mtd(tr, mtd);
337 }
338
339} 327}
340 328
341static struct mtd_notifier blktrans_notifier = { 329static struct mtd_notifier blktrans_notifier = {
@@ -406,7 +394,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
406 394
407int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr) 395int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
408{ 396{
409 struct list_head *this, *next; 397 struct mtd_blktrans_dev *dev, *next;
410 398
411 mutex_lock(&mtd_table_mutex); 399 mutex_lock(&mtd_table_mutex);
412 400
@@ -416,10 +404,8 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
416 /* Remove it from the list of active majors */ 404 /* Remove it from the list of active majors */
417 list_del(&tr->list); 405 list_del(&tr->list);
418 406
419 list_for_each_safe(this, next, &tr->devs) { 407 list_for_each_entry_safe(dev, next, &tr->devs, list)
420 struct mtd_blktrans_dev *dev = list_entry(this, struct mtd_blktrans_dev, list);
421 tr->remove_dev(dev); 408 tr->remove_dev(dev);
422 }
423 409
424 blk_cleanup_queue(tr->blkcore_priv->rq); 410 blk_cleanup_queue(tr->blkcore_priv->rq);
425 unregister_blkdev(tr->major, tr->name); 411 unregister_blkdev(tr->major, tr->name);
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 952da30b1745..208c6faa0358 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Direct MTD block device access 2 * Direct MTD block device access
3 * 3 *
4 * $Id: mtdblock.c,v 1.68 2005/11/07 11:14:20 gleixner Exp $
5 *
6 * (C) 2000-2003 Nicolas Pitre <nico@cam.org> 4 * (C) 2000-2003 Nicolas Pitre <nico@cam.org>
7 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> 5 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
8 */ 6 */
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
index f79dbb49b1a2..852165f8b1c3 100644
--- a/drivers/mtd/mtdblock_ro.c
+++ b/drivers/mtd/mtdblock_ro.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtdblock_ro.c,v 1.19 2004/11/16 18:28:59 dwmw2 Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 3 *
6 * Simple read-only (writable only for RAM) mtdblock driver 4 * Simple read-only (writable only for RAM) mtdblock driver
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index aef9f4b687c9..d2f331876e4c 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtdchar.c,v 1.76 2005/11/07 11:14:20 gleixner Exp $
3 *
4 * Character-device access to raw MTD devices. 2 * Character-device access to raw MTD devices.
5 * 3 *
6 */ 4 */
@@ -494,6 +492,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
494 { 492 {
495 struct mtd_oob_buf buf; 493 struct mtd_oob_buf buf;
496 struct mtd_oob_ops ops; 494 struct mtd_oob_ops ops;
495 struct mtd_oob_buf __user *user_buf = argp;
497 uint32_t retlen; 496 uint32_t retlen;
498 497
499 if(!(file->f_mode & 2)) 498 if(!(file->f_mode & 2))
@@ -537,8 +536,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
537 if (ops.oobretlen > 0xFFFFFFFFU) 536 if (ops.oobretlen > 0xFFFFFFFFU)
538 ret = -EOVERFLOW; 537 ret = -EOVERFLOW;
539 retlen = ops.oobretlen; 538 retlen = ops.oobretlen;
540 if (copy_to_user(&((struct mtd_oob_buf *)argp)->length, 539 if (copy_to_user(&user_buf->length, &retlen, sizeof(buf.length)))
541 &retlen, sizeof(buf.length)))
542 ret = -EFAULT; 540 ret = -EFAULT;
543 541
544 kfree(ops.oobbuf); 542 kfree(ops.oobbuf);
@@ -592,29 +590,29 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
592 590
593 case MEMLOCK: 591 case MEMLOCK:
594 { 592 {
595 struct erase_info_user info; 593 struct erase_info_user einfo;
596 594
597 if (copy_from_user(&info, argp, sizeof(info))) 595 if (copy_from_user(&einfo, argp, sizeof(einfo)))
598 return -EFAULT; 596 return -EFAULT;
599 597
600 if (!mtd->lock) 598 if (!mtd->lock)
601 ret = -EOPNOTSUPP; 599 ret = -EOPNOTSUPP;
602 else 600 else
603 ret = mtd->lock(mtd, info.start, info.length); 601 ret = mtd->lock(mtd, einfo.start, einfo.length);
604 break; 602 break;
605 } 603 }
606 604
607 case MEMUNLOCK: 605 case MEMUNLOCK:
608 { 606 {
609 struct erase_info_user info; 607 struct erase_info_user einfo;
610 608
611 if (copy_from_user(&info, argp, sizeof(info))) 609 if (copy_from_user(&einfo, argp, sizeof(einfo)))
612 return -EFAULT; 610 return -EFAULT;
613 611
614 if (!mtd->unlock) 612 if (!mtd->unlock)
615 ret = -EOPNOTSUPP; 613 ret = -EOPNOTSUPP;
616 else 614 else
617 ret = mtd->unlock(mtd, info.start, info.length); 615 ret = mtd->unlock(mtd, einfo.start, einfo.length);
618 break; 616 break;
619 } 617 }
620 618
@@ -714,15 +712,15 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
714 712
715 case OTPLOCK: 713 case OTPLOCK:
716 { 714 {
717 struct otp_info info; 715 struct otp_info oinfo;
718 716
719 if (mfi->mode != MTD_MODE_OTP_USER) 717 if (mfi->mode != MTD_MODE_OTP_USER)
720 return -EINVAL; 718 return -EINVAL;
721 if (copy_from_user(&info, argp, sizeof(info))) 719 if (copy_from_user(&oinfo, argp, sizeof(oinfo)))
722 return -EFAULT; 720 return -EFAULT;
723 if (!mtd->lock_user_prot_reg) 721 if (!mtd->lock_user_prot_reg)
724 return -EOPNOTSUPP; 722 return -EOPNOTSUPP;
725 ret = mtd->lock_user_prot_reg(mtd, info.start, info.length); 723 ret = mtd->lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
726 break; 724 break;
727 } 725 }
728#endif 726#endif
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index d563dcd4b264..2972a5edb73d 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -6,8 +6,6 @@
6 * NAND support by Christian Gan <cgan@iders.ca> 6 * NAND support by Christian Gan <cgan@iders.ca>
7 * 7 *
8 * This code is GPL 8 * This code is GPL
9 *
10 * $Id: mtdconcat.c,v 1.11 2005/11/07 11:14:20 gleixner Exp $
11 */ 9 */
12 10
13#include <linux/kernel.h> 11#include <linux/kernel.h>
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index f7e7890e5bc6..a9d246949820 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $
3 *
4 * Core registration and callback routines for MTD 2 * Core registration and callback routines for MTD
5 * drivers and users. 3 * drivers and users.
6 * 4 *
@@ -53,7 +51,7 @@ int add_mtd_device(struct mtd_info *mtd)
53 51
54 for (i=0; i < MAX_MTD_DEVICES; i++) 52 for (i=0; i < MAX_MTD_DEVICES; i++)
55 if (!mtd_table[i]) { 53 if (!mtd_table[i]) {
56 struct list_head *this; 54 struct mtd_notifier *not;
57 55
58 mtd_table[i] = mtd; 56 mtd_table[i] = mtd;
59 mtd->index = i; 57 mtd->index = i;
@@ -72,10 +70,8 @@ int add_mtd_device(struct mtd_info *mtd)
72 DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name); 70 DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
73 /* No need to get a refcount on the module containing 71 /* No need to get a refcount on the module containing
74 the notifier, since we hold the mtd_table_mutex */ 72 the notifier, since we hold the mtd_table_mutex */
75 list_for_each(this, &mtd_notifiers) { 73 list_for_each_entry(not, &mtd_notifiers, list)
76 struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
77 not->add(mtd); 74 not->add(mtd);
78 }
79 75
80 mutex_unlock(&mtd_table_mutex); 76 mutex_unlock(&mtd_table_mutex);
81 /* We _know_ we aren't being removed, because 77 /* We _know_ we aren't being removed, because
@@ -113,14 +109,12 @@ int del_mtd_device (struct mtd_info *mtd)
113 mtd->index, mtd->name, mtd->usecount); 109 mtd->index, mtd->name, mtd->usecount);
114 ret = -EBUSY; 110 ret = -EBUSY;
115 } else { 111 } else {
116 struct list_head *this; 112 struct mtd_notifier *not;
117 113
118 /* No need to get a refcount on the module containing 114 /* No need to get a refcount on the module containing
119 the notifier, since we hold the mtd_table_mutex */ 115 the notifier, since we hold the mtd_table_mutex */
120 list_for_each(this, &mtd_notifiers) { 116 list_for_each_entry(not, &mtd_notifiers, list)
121 struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
122 not->remove(mtd); 117 not->remove(mtd);
123 }
124 118
125 mtd_table[mtd->index] = NULL; 119 mtd_table[mtd->index] = NULL;
126 120
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 07c701169344..edb90b58a9b1 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -5,8 +5,6 @@
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
8 * $Id: mtdpart.c,v 1.55 2005/11/07 11:14:20 gleixner Exp $
9 *
10 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de> 8 * 02-21-2002 Thomas Gleixner <gleixner@autronix.de>
11 * added support for read_oob, write_oob 9 * added support for read_oob, write_oob
12 */ 10 */
@@ -46,8 +44,8 @@ struct mtd_part {
46 * to the _real_ device. 44 * to the _real_ device.
47 */ 45 */
48 46
49static int part_read (struct mtd_info *mtd, loff_t from, size_t len, 47static int part_read(struct mtd_info *mtd, loff_t from, size_t len,
50 size_t *retlen, u_char *buf) 48 size_t *retlen, u_char *buf)
51{ 49{
52 struct mtd_part *part = PART(mtd); 50 struct mtd_part *part = PART(mtd);
53 int res; 51 int res;
@@ -56,7 +54,7 @@ static int part_read (struct mtd_info *mtd, loff_t from, size_t len,
56 len = 0; 54 len = 0;
57 else if (from + len > mtd->size) 55 else if (from + len > mtd->size)
58 len = mtd->size - from; 56 len = mtd->size - from;
59 res = part->master->read (part->master, from + part->offset, 57 res = part->master->read(part->master, from + part->offset,
60 len, retlen, buf); 58 len, retlen, buf);
61 if (unlikely(res)) { 59 if (unlikely(res)) {
62 if (res == -EUCLEAN) 60 if (res == -EUCLEAN)
@@ -67,8 +65,8 @@ static int part_read (struct mtd_info *mtd, loff_t from, size_t len,
67 return res; 65 return res;
68} 66}
69 67
70static int part_point (struct mtd_info *mtd, loff_t from, size_t len, 68static int part_point(struct mtd_info *mtd, loff_t from, size_t len,
71 size_t *retlen, void **virt, resource_size_t *phys) 69 size_t *retlen, void **virt, resource_size_t *phys)
72{ 70{
73 struct mtd_part *part = PART(mtd); 71 struct mtd_part *part = PART(mtd);
74 if (from >= mtd->size) 72 if (from >= mtd->size)
@@ -87,7 +85,7 @@ static void part_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
87} 85}
88 86
89static int part_read_oob(struct mtd_info *mtd, loff_t from, 87static int part_read_oob(struct mtd_info *mtd, loff_t from,
90 struct mtd_oob_ops *ops) 88 struct mtd_oob_ops *ops)
91{ 89{
92 struct mtd_part *part = PART(mtd); 90 struct mtd_part *part = PART(mtd);
93 int res; 91 int res;
@@ -107,38 +105,38 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
107 return res; 105 return res;
108} 106}
109 107
110static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 108static int part_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
111 size_t *retlen, u_char *buf) 109 size_t len, size_t *retlen, u_char *buf)
112{ 110{
113 struct mtd_part *part = PART(mtd); 111 struct mtd_part *part = PART(mtd);
114 return part->master->read_user_prot_reg (part->master, from, 112 return part->master->read_user_prot_reg(part->master, from,
115 len, retlen, buf); 113 len, retlen, buf);
116} 114}
117 115
118static int part_get_user_prot_info (struct mtd_info *mtd, 116static int part_get_user_prot_info(struct mtd_info *mtd,
119 struct otp_info *buf, size_t len) 117 struct otp_info *buf, size_t len)
120{ 118{
121 struct mtd_part *part = PART(mtd); 119 struct mtd_part *part = PART(mtd);
122 return part->master->get_user_prot_info (part->master, buf, len); 120 return part->master->get_user_prot_info(part->master, buf, len);
123} 121}
124 122
125static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 123static int part_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
126 size_t *retlen, u_char *buf) 124 size_t len, size_t *retlen, u_char *buf)
127{ 125{
128 struct mtd_part *part = PART(mtd); 126 struct mtd_part *part = PART(mtd);
129 return part->master->read_fact_prot_reg (part->master, from, 127 return part->master->read_fact_prot_reg(part->master, from,
130 len, retlen, buf); 128 len, retlen, buf);
131} 129}
132 130
133static int part_get_fact_prot_info (struct mtd_info *mtd, 131static int part_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
134 struct otp_info *buf, size_t len) 132 size_t len)
135{ 133{
136 struct mtd_part *part = PART(mtd); 134 struct mtd_part *part = PART(mtd);
137 return part->master->get_fact_prot_info (part->master, buf, len); 135 return part->master->get_fact_prot_info(part->master, buf, len);
138} 136}
139 137
140static int part_write (struct mtd_info *mtd, loff_t to, size_t len, 138static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
141 size_t *retlen, const u_char *buf) 139 size_t *retlen, const u_char *buf)
142{ 140{
143 struct mtd_part *part = PART(mtd); 141 struct mtd_part *part = PART(mtd);
144 if (!(mtd->flags & MTD_WRITEABLE)) 142 if (!(mtd->flags & MTD_WRITEABLE))
@@ -147,12 +145,12 @@ static int part_write (struct mtd_info *mtd, loff_t to, size_t len,
147 len = 0; 145 len = 0;
148 else if (to + len > mtd->size) 146 else if (to + len > mtd->size)
149 len = mtd->size - to; 147 len = mtd->size - to;
150 return part->master->write (part->master, to + part->offset, 148 return part->master->write(part->master, to + part->offset,
151 len, retlen, buf); 149 len, retlen, buf);
152} 150}
153 151
154static int part_panic_write (struct mtd_info *mtd, loff_t to, size_t len, 152static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
155 size_t *retlen, const u_char *buf) 153 size_t *retlen, const u_char *buf)
156{ 154{
157 struct mtd_part *part = PART(mtd); 155 struct mtd_part *part = PART(mtd);
158 if (!(mtd->flags & MTD_WRITEABLE)) 156 if (!(mtd->flags & MTD_WRITEABLE))
@@ -161,12 +159,12 @@ static int part_panic_write (struct mtd_info *mtd, loff_t to, size_t len,
161 len = 0; 159 len = 0;
162 else if (to + len > mtd->size) 160 else if (to + len > mtd->size)
163 len = mtd->size - to; 161 len = mtd->size - to;
164 return part->master->panic_write (part->master, to + part->offset, 162 return part->master->panic_write(part->master, to + part->offset,
165 len, retlen, buf); 163 len, retlen, buf);
166} 164}
167 165
168static int part_write_oob(struct mtd_info *mtd, loff_t to, 166static int part_write_oob(struct mtd_info *mtd, loff_t to,
169 struct mtd_oob_ops *ops) 167 struct mtd_oob_ops *ops)
170{ 168{
171 struct mtd_part *part = PART(mtd); 169 struct mtd_part *part = PART(mtd);
172 170
@@ -180,31 +178,32 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to,
180 return part->master->write_oob(part->master, to + part->offset, ops); 178 return part->master->write_oob(part->master, to + part->offset, ops);
181} 179}
182 180
183static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len, 181static int part_write_user_prot_reg(struct mtd_info *mtd, loff_t from,
184 size_t *retlen, u_char *buf) 182 size_t len, size_t *retlen, u_char *buf)
185{ 183{
186 struct mtd_part *part = PART(mtd); 184 struct mtd_part *part = PART(mtd);
187 return part->master->write_user_prot_reg (part->master, from, 185 return part->master->write_user_prot_reg(part->master, from,
188 len, retlen, buf); 186 len, retlen, buf);
189} 187}
190 188
191static int part_lock_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len) 189static int part_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
190 size_t len)
192{ 191{
193 struct mtd_part *part = PART(mtd); 192 struct mtd_part *part = PART(mtd);
194 return part->master->lock_user_prot_reg (part->master, from, len); 193 return part->master->lock_user_prot_reg(part->master, from, len);
195} 194}
196 195
197static int part_writev (struct mtd_info *mtd, const struct kvec *vecs, 196static int part_writev(struct mtd_info *mtd, const struct kvec *vecs,
198 unsigned long count, loff_t to, size_t *retlen) 197 unsigned long count, loff_t to, size_t *retlen)
199{ 198{
200 struct mtd_part *part = PART(mtd); 199 struct mtd_part *part = PART(mtd);
201 if (!(mtd->flags & MTD_WRITEABLE)) 200 if (!(mtd->flags & MTD_WRITEABLE))
202 return -EROFS; 201 return -EROFS;
203 return part->master->writev (part->master, vecs, count, 202 return part->master->writev(part->master, vecs, count,
204 to + part->offset, retlen); 203 to + part->offset, retlen);
205} 204}
206 205
207static int part_erase (struct mtd_info *mtd, struct erase_info *instr) 206static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
208{ 207{
209 struct mtd_part *part = PART(mtd); 208 struct mtd_part *part = PART(mtd);
210 int ret; 209 int ret;
@@ -236,7 +235,7 @@ void mtd_erase_callback(struct erase_info *instr)
236} 235}
237EXPORT_SYMBOL_GPL(mtd_erase_callback); 236EXPORT_SYMBOL_GPL(mtd_erase_callback);
238 237
239static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len) 238static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
240{ 239{
241 struct mtd_part *part = PART(mtd); 240 struct mtd_part *part = PART(mtd);
242 if ((len + ofs) > mtd->size) 241 if ((len + ofs) > mtd->size)
@@ -244,7 +243,7 @@ static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len)
244 return part->master->lock(part->master, ofs + part->offset, len); 243 return part->master->lock(part->master, ofs + part->offset, len);
245} 244}
246 245
247static int part_unlock (struct mtd_info *mtd, loff_t ofs, size_t len) 246static int part_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
248{ 247{
249 struct mtd_part *part = PART(mtd); 248 struct mtd_part *part = PART(mtd);
250 if ((len + ofs) > mtd->size) 249 if ((len + ofs) > mtd->size)
@@ -270,7 +269,7 @@ static void part_resume(struct mtd_info *mtd)
270 part->master->resume(part->master); 269 part->master->resume(part->master);
271} 270}
272 271
273static int part_block_isbad (struct mtd_info *mtd, loff_t ofs) 272static int part_block_isbad(struct mtd_info *mtd, loff_t ofs)
274{ 273{
275 struct mtd_part *part = PART(mtd); 274 struct mtd_part *part = PART(mtd);
276 if (ofs >= mtd->size) 275 if (ofs >= mtd->size)
@@ -279,7 +278,7 @@ static int part_block_isbad (struct mtd_info *mtd, loff_t ofs)
279 return part->master->block_isbad(part->master, ofs); 278 return part->master->block_isbad(part->master, ofs);
280} 279}
281 280
282static int part_block_markbad (struct mtd_info *mtd, loff_t ofs) 281static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
283{ 282{
284 struct mtd_part *part = PART(mtd); 283 struct mtd_part *part = PART(mtd);
285 int res; 284 int res;
@@ -302,229 +301,237 @@ static int part_block_markbad (struct mtd_info *mtd, loff_t ofs)
302 301
303int del_mtd_partitions(struct mtd_info *master) 302int del_mtd_partitions(struct mtd_info *master)
304{ 303{
305 struct list_head *node; 304 struct mtd_part *slave, *next;
306 struct mtd_part *slave;
307 305
308 for (node = mtd_partitions.next; 306 list_for_each_entry_safe(slave, next, &mtd_partitions, list)
309 node != &mtd_partitions;
310 node = node->next) {
311 slave = list_entry(node, struct mtd_part, list);
312 if (slave->master == master) { 307 if (slave->master == master) {
313 struct list_head *prev = node->prev; 308 list_del(&slave->list);
314 __list_del(prev, node->next); 309 if (slave->registered)
315 if(slave->registered)
316 del_mtd_device(&slave->mtd); 310 del_mtd_device(&slave->mtd);
317 kfree(slave); 311 kfree(slave);
318 node = prev;
319 } 312 }
320 }
321 313
322 return 0; 314 return 0;
323} 315}
316EXPORT_SYMBOL(del_mtd_partitions);
324 317
325/* 318static struct mtd_part *add_one_partition(struct mtd_info *master,
326 * This function, given a master MTD object and a partition table, creates 319 const struct mtd_partition *part, int partno,
327 * and registers slave MTD objects which are bound to the master according to 320 u_int32_t cur_offset)
328 * the partition definitions.
329 * (Q: should we register the master MTD object as well?)
330 */
331
332int add_mtd_partitions(struct mtd_info *master,
333 const struct mtd_partition *parts,
334 int nbparts)
335{ 321{
336 struct mtd_part *slave; 322 struct mtd_part *slave;
337 u_int32_t cur_offset = 0;
338 int i;
339
340 printk (KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
341
342 for (i = 0; i < nbparts; i++) {
343 323
344 /* allocate the partition structure */ 324 /* allocate the partition structure */
345 slave = kzalloc (sizeof(*slave), GFP_KERNEL); 325 slave = kzalloc(sizeof(*slave), GFP_KERNEL);
346 if (!slave) { 326 if (!slave) {
347 printk ("memory allocation error while creating partitions for \"%s\"\n", 327 printk(KERN_ERR"memory allocation error while creating partitions for \"%s\"\n",
348 master->name); 328 master->name);
349 del_mtd_partitions(master); 329 del_mtd_partitions(master);
350 return -ENOMEM; 330 return NULL;
351 } 331 }
352 list_add(&slave->list, &mtd_partitions); 332 list_add(&slave->list, &mtd_partitions);
353 333
354 /* set up the MTD object for this partition */ 334 /* set up the MTD object for this partition */
355 slave->mtd.type = master->type; 335 slave->mtd.type = master->type;
356 slave->mtd.flags = master->flags & ~parts[i].mask_flags; 336 slave->mtd.flags = master->flags & ~part->mask_flags;
357 slave->mtd.size = parts[i].size; 337 slave->mtd.size = part->size;
358 slave->mtd.writesize = master->writesize; 338 slave->mtd.writesize = master->writesize;
359 slave->mtd.oobsize = master->oobsize; 339 slave->mtd.oobsize = master->oobsize;
360 slave->mtd.oobavail = master->oobavail; 340 slave->mtd.oobavail = master->oobavail;
361 slave->mtd.subpage_sft = master->subpage_sft; 341 slave->mtd.subpage_sft = master->subpage_sft;
362 342
363 slave->mtd.name = parts[i].name; 343 slave->mtd.name = part->name;
364 slave->mtd.owner = master->owner; 344 slave->mtd.owner = master->owner;
365 345
366 slave->mtd.read = part_read; 346 slave->mtd.read = part_read;
367 slave->mtd.write = part_write; 347 slave->mtd.write = part_write;
368 348
369 if (master->panic_write) 349 if (master->panic_write)
370 slave->mtd.panic_write = part_panic_write; 350 slave->mtd.panic_write = part_panic_write;
371 351
372 if(master->point && master->unpoint){ 352 if (master->point && master->unpoint) {
373 slave->mtd.point = part_point; 353 slave->mtd.point = part_point;
374 slave->mtd.unpoint = part_unpoint; 354 slave->mtd.unpoint = part_unpoint;
375 } 355 }
376 356
377 if (master->read_oob) 357 if (master->read_oob)
378 slave->mtd.read_oob = part_read_oob; 358 slave->mtd.read_oob = part_read_oob;
379 if (master->write_oob) 359 if (master->write_oob)
380 slave->mtd.write_oob = part_write_oob; 360 slave->mtd.write_oob = part_write_oob;
381 if(master->read_user_prot_reg) 361 if (master->read_user_prot_reg)
382 slave->mtd.read_user_prot_reg = part_read_user_prot_reg; 362 slave->mtd.read_user_prot_reg = part_read_user_prot_reg;
383 if(master->read_fact_prot_reg) 363 if (master->read_fact_prot_reg)
384 slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg; 364 slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg;
385 if(master->write_user_prot_reg) 365 if (master->write_user_prot_reg)
386 slave->mtd.write_user_prot_reg = part_write_user_prot_reg; 366 slave->mtd.write_user_prot_reg = part_write_user_prot_reg;
387 if(master->lock_user_prot_reg) 367 if (master->lock_user_prot_reg)
388 slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg; 368 slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg;
389 if(master->get_user_prot_info) 369 if (master->get_user_prot_info)
390 slave->mtd.get_user_prot_info = part_get_user_prot_info; 370 slave->mtd.get_user_prot_info = part_get_user_prot_info;
391 if(master->get_fact_prot_info) 371 if (master->get_fact_prot_info)
392 slave->mtd.get_fact_prot_info = part_get_fact_prot_info; 372 slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
393 if (master->sync) 373 if (master->sync)
394 slave->mtd.sync = part_sync; 374 slave->mtd.sync = part_sync;
395 if (!i && master->suspend && master->resume) { 375 if (!partno && master->suspend && master->resume) {
396 slave->mtd.suspend = part_suspend; 376 slave->mtd.suspend = part_suspend;
397 slave->mtd.resume = part_resume; 377 slave->mtd.resume = part_resume;
378 }
379 if (master->writev)
380 slave->mtd.writev = part_writev;
381 if (master->lock)
382 slave->mtd.lock = part_lock;
383 if (master->unlock)
384 slave->mtd.unlock = part_unlock;
385 if (master->block_isbad)
386 slave->mtd.block_isbad = part_block_isbad;
387 if (master->block_markbad)
388 slave->mtd.block_markbad = part_block_markbad;
389 slave->mtd.erase = part_erase;
390 slave->master = master;
391 slave->offset = part->offset;
392 slave->index = partno;
393
394 if (slave->offset == MTDPART_OFS_APPEND)
395 slave->offset = cur_offset;
396 if (slave->offset == MTDPART_OFS_NXTBLK) {
397 slave->offset = cur_offset;
398 if ((cur_offset % master->erasesize) != 0) {
399 /* Round up to next erasesize */
400 slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize;
401 printk(KERN_NOTICE "Moving partition %d: "
402 "0x%08x -> 0x%08x\n", partno,
403 cur_offset, slave->offset);
398 } 404 }
399 if (master->writev) 405 }
400 slave->mtd.writev = part_writev; 406 if (slave->mtd.size == MTDPART_SIZ_FULL)
401 if (master->lock) 407 slave->mtd.size = master->size - slave->offset;
402 slave->mtd.lock = part_lock; 408
403 if (master->unlock) 409 printk(KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset,
404 slave->mtd.unlock = part_unlock; 410 slave->offset + slave->mtd.size, slave->mtd.name);
405 if (master->block_isbad) 411
406 slave->mtd.block_isbad = part_block_isbad; 412 /* let's do some sanity checks */
407 if (master->block_markbad) 413 if (slave->offset >= master->size) {
408 slave->mtd.block_markbad = part_block_markbad; 414 /* let's register it anyway to preserve ordering */
409 slave->mtd.erase = part_erase; 415 slave->offset = 0;
410 slave->master = master; 416 slave->mtd.size = 0;
411 slave->offset = parts[i].offset; 417 printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
412 slave->index = i; 418 part->name);
413 419 goto out_register;
414 if (slave->offset == MTDPART_OFS_APPEND) 420 }
415 slave->offset = cur_offset; 421 if (slave->offset + slave->mtd.size > master->size) {
416 if (slave->offset == MTDPART_OFS_NXTBLK) { 422 slave->mtd.size = master->size - slave->offset;
417 slave->offset = cur_offset; 423 printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n",
418 if ((cur_offset % master->erasesize) != 0) { 424 part->name, master->name, slave->mtd.size);
419 /* Round up to next erasesize */ 425 }
420 slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize; 426 if (master->numeraseregions > 1) {
421 printk(KERN_NOTICE "Moving partition %d: " 427 /* Deal with variable erase size stuff */
422 "0x%08x -> 0x%08x\n", i, 428 int i, max = master->numeraseregions;
423 cur_offset, slave->offset); 429 u32 end = slave->offset + slave->mtd.size;
430 struct mtd_erase_region_info *regions = master->eraseregions;
431
432 /* Find the first erase regions which is part of this
433 * partition. */
434 for (i = 0; i < max && regions[i].offset <= slave->offset; i++)
435 ;
436 /* The loop searched for the region _behind_ the first one */
437 i--;
438
439 /* Pick biggest erasesize */
440 for (; i < max && regions[i].offset < end; i++) {
441 if (slave->mtd.erasesize < regions[i].erasesize) {
442 slave->mtd.erasesize = regions[i].erasesize;
424 } 443 }
425 } 444 }
426 if (slave->mtd.size == MTDPART_SIZ_FULL) 445 BUG_ON(slave->mtd.erasesize == 0);
427 slave->mtd.size = master->size - slave->offset; 446 } else {
428 cur_offset = slave->offset + slave->mtd.size; 447 /* Single erase size */
448 slave->mtd.erasesize = master->erasesize;
449 }
429 450
430 printk (KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset, 451 if ((slave->mtd.flags & MTD_WRITEABLE) &&
431 slave->offset + slave->mtd.size, slave->mtd.name); 452 (slave->offset % slave->mtd.erasesize)) {
453 /* Doesn't start on a boundary of major erase size */
454 /* FIXME: Let it be writable if it is on a boundary of
455 * _minor_ erase size though */
456 slave->mtd.flags &= ~MTD_WRITEABLE;
457 printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
458 part->name);
459 }
460 if ((slave->mtd.flags & MTD_WRITEABLE) &&
461 (slave->mtd.size % slave->mtd.erasesize)) {
462 slave->mtd.flags &= ~MTD_WRITEABLE;
463 printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
464 part->name);
465 }
432 466
433 /* let's do some sanity checks */ 467 slave->mtd.ecclayout = master->ecclayout;
434 if (slave->offset >= master->size) { 468 if (master->block_isbad) {
435 /* let's register it anyway to preserve ordering */ 469 uint32_t offs = 0;
436 slave->offset = 0;
437 slave->mtd.size = 0;
438 printk ("mtd: partition \"%s\" is out of reach -- disabled\n",
439 parts[i].name);
440 }
441 if (slave->offset + slave->mtd.size > master->size) {
442 slave->mtd.size = master->size - slave->offset;
443 printk ("mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n",
444 parts[i].name, master->name, slave->mtd.size);
445 }
446 if (master->numeraseregions>1) {
447 /* Deal with variable erase size stuff */
448 int i;
449 struct mtd_erase_region_info *regions = master->eraseregions;
450
451 /* Find the first erase regions which is part of this partition. */
452 for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++)
453 ;
454
455 for (i--; i < master->numeraseregions && slave->offset + slave->mtd.size > regions[i].offset; i++) {
456 if (slave->mtd.erasesize < regions[i].erasesize) {
457 slave->mtd.erasesize = regions[i].erasesize;
458 }
459 }
460 } else {
461 /* Single erase size */
462 slave->mtd.erasesize = master->erasesize;
463 }
464 470
465 if ((slave->mtd.flags & MTD_WRITEABLE) && 471 while (offs < slave->mtd.size) {
466 (slave->offset % slave->mtd.erasesize)) { 472 if (master->block_isbad(master,
467 /* Doesn't start on a boundary of major erase size */ 473 offs + slave->offset))
468 /* FIXME: Let it be writable if it is on a boundary of _minor_ erase size though */ 474 slave->mtd.ecc_stats.badblocks++;
469 slave->mtd.flags &= ~MTD_WRITEABLE; 475 offs += slave->mtd.erasesize;
470 printk ("mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
471 parts[i].name);
472 }
473 if ((slave->mtd.flags & MTD_WRITEABLE) &&
474 (slave->mtd.size % slave->mtd.erasesize)) {
475 slave->mtd.flags &= ~MTD_WRITEABLE;
476 printk ("mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
477 parts[i].name);
478 } 476 }
477 }
479 478
480 slave->mtd.ecclayout = master->ecclayout; 479out_register:
481 if (master->block_isbad) { 480 if (part->mtdp) {
482 uint32_t offs = 0; 481 /* store the object pointer (caller may or may not register it*/
482 *part->mtdp = &slave->mtd;
483 slave->registered = 0;
484 } else {
485 /* register our partition */
486 add_mtd_device(&slave->mtd);
487 slave->registered = 1;
488 }
489 return slave;
490}
483 491
484 while(offs < slave->mtd.size) { 492/*
485 if (master->block_isbad(master, 493 * This function, given a master MTD object and a partition table, creates
486 offs + slave->offset)) 494 * and registers slave MTD objects which are bound to the master according to
487 slave->mtd.ecc_stats.badblocks++; 495 * the partition definitions.
488 offs += slave->mtd.erasesize; 496 * (Q: should we register the master MTD object as well?)
489 } 497 */
490 }
491 498
492 if(parts[i].mtdp) 499int add_mtd_partitions(struct mtd_info *master,
493 { /* store the object pointer (caller may or may not register it */ 500 const struct mtd_partition *parts,
494 *parts[i].mtdp = &slave->mtd; 501 int nbparts)
495 slave->registered = 0; 502{
496 } 503 struct mtd_part *slave;
497 else 504 u_int32_t cur_offset = 0;
498 { 505 int i;
499 /* register our partition */ 506
500 add_mtd_device(&slave->mtd); 507 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
501 slave->registered = 1; 508
502 } 509 for (i = 0; i < nbparts; i++) {
510 slave = add_one_partition(master, parts + i, i, cur_offset);
511 if (!slave)
512 return -ENOMEM;
513 cur_offset = slave->offset + slave->mtd.size;
503 } 514 }
504 515
505 return 0; 516 return 0;
506} 517}
507
508EXPORT_SYMBOL(add_mtd_partitions); 518EXPORT_SYMBOL(add_mtd_partitions);
509EXPORT_SYMBOL(del_mtd_partitions);
510 519
511static DEFINE_SPINLOCK(part_parser_lock); 520static DEFINE_SPINLOCK(part_parser_lock);
512static LIST_HEAD(part_parsers); 521static LIST_HEAD(part_parsers);
513 522
514static struct mtd_part_parser *get_partition_parser(const char *name) 523static struct mtd_part_parser *get_partition_parser(const char *name)
515{ 524{
516 struct list_head *this; 525 struct mtd_part_parser *p, *ret = NULL;
517 void *ret = NULL;
518 spin_lock(&part_parser_lock);
519 526
520 list_for_each(this, &part_parsers) { 527 spin_lock(&part_parser_lock);
521 struct mtd_part_parser *p = list_entry(this, struct mtd_part_parser, list);
522 528
529 list_for_each_entry(p, &part_parsers, list)
523 if (!strcmp(p->name, name) && try_module_get(p->owner)) { 530 if (!strcmp(p->name, name) && try_module_get(p->owner)) {
524 ret = p; 531 ret = p;
525 break; 532 break;
526 } 533 }
527 } 534
528 spin_unlock(&part_parser_lock); 535 spin_unlock(&part_parser_lock);
529 536
530 return ret; 537 return ret;
@@ -538,6 +545,7 @@ int register_mtd_parser(struct mtd_part_parser *p)
538 545
539 return 0; 546 return 0;
540} 547}
548EXPORT_SYMBOL_GPL(register_mtd_parser);
541 549
542int deregister_mtd_parser(struct mtd_part_parser *p) 550int deregister_mtd_parser(struct mtd_part_parser *p)
543{ 551{
@@ -546,6 +554,7 @@ int deregister_mtd_parser(struct mtd_part_parser *p)
546 spin_unlock(&part_parser_lock); 554 spin_unlock(&part_parser_lock);
547 return 0; 555 return 0;
548} 556}
557EXPORT_SYMBOL_GPL(deregister_mtd_parser);
549 558
550int parse_mtd_partitions(struct mtd_info *master, const char **types, 559int parse_mtd_partitions(struct mtd_info *master, const char **types,
551 struct mtd_partition **pparts, unsigned long origin) 560 struct mtd_partition **pparts, unsigned long origin)
@@ -573,7 +582,4 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
573 } 582 }
574 return ret; 583 return ret;
575} 584}
576
577EXPORT_SYMBOL_GPL(parse_mtd_partitions); 585EXPORT_SYMBOL_GPL(parse_mtd_partitions);
578EXPORT_SYMBOL_GPL(register_mtd_parser);
579EXPORT_SYMBOL_GPL(deregister_mtd_parser);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 5076faf9ca66..71406e517857 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1,5 +1,4 @@
1# drivers/mtd/nand/Kconfig 1# drivers/mtd/nand/Kconfig
2# $Id: Kconfig,v 1.35 2005/11/07 11:14:30 gleixner Exp $
3 2
4menuconfig MTD_NAND 3menuconfig MTD_NAND
5 tristate "NAND Device Support" 4 tristate "NAND Device Support"
@@ -272,22 +271,23 @@ config MTD_NAND_CS553X
272 271
273 If you say "m", the module will be called "cs553x_nand.ko". 272 If you say "m", the module will be called "cs553x_nand.ko".
274 273
275config MTD_NAND_AT91 274config MTD_NAND_ATMEL
276 bool "Support for NAND Flash / SmartMedia on AT91" 275 tristate "Support for NAND Flash / SmartMedia on AT91 and AVR32"
277 depends on ARCH_AT91 276 depends on ARCH_AT91 || AVR32
278 help 277 help
279 Enables support for NAND Flash / Smart Media Card interface 278 Enables support for NAND Flash / Smart Media Card interface
280 on Atmel AT91 processors. 279 on Atmel AT91 and AVR32 processors.
281choice 280choice
282 prompt "ECC management for NAND Flash / SmartMedia on AT91" 281 prompt "ECC management for NAND Flash / SmartMedia on AT91 / AVR32"
283 depends on MTD_NAND_AT91 282 depends on MTD_NAND_ATMEL
284 283
285config MTD_NAND_AT91_ECC_HW 284config MTD_NAND_ATMEL_ECC_HW
286 bool "Hardware ECC" 285 bool "Hardware ECC"
287 depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9260 286 depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9260 || AVR32
288 help 287 help
289 Uses hardware ECC provided by the at91sam9260/at91sam9263 chip 288 Use hardware ECC instead of software ECC when the chip
290 instead of software ECC. 289 supports it.
290
291 The hardware ECC controller is capable of single bit error 291 The hardware ECC controller is capable of single bit error
292 correction and 2-bit random detection per page. 292 correction and 2-bit random detection per page.
293 293
@@ -297,16 +297,16 @@ config MTD_NAND_AT91_ECC_HW
297 297
298 If unsure, say Y 298 If unsure, say Y
299 299
300config MTD_NAND_AT91_ECC_SOFT 300config MTD_NAND_ATMEL_ECC_SOFT
301 bool "Software ECC" 301 bool "Software ECC"
302 help 302 help
303 Uses software ECC. 303 Use software ECC.
304 304
305 NB : hardware and software ECC schemes are incompatible. 305 NB : hardware and software ECC schemes are incompatible.
306 If you switch from one to another, you'll have to erase your 306 If you switch from one to another, you'll have to erase your
307 mtd partition. 307 mtd partition.
308 308
309config MTD_NAND_AT91_ECC_NONE 309config MTD_NAND_ATMEL_ECC_NONE
310 bool "No ECC (testing only, DANGEROUS)" 310 bool "No ECC (testing only, DANGEROUS)"
311 depends on DEBUG_KERNEL 311 depends on DEBUG_KERNEL
312 help 312 help
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index a6e74a46992a..d772581de573 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -1,7 +1,6 @@
1# 1#
2# linux/drivers/nand/Makefile 2# linux/drivers/nand/Makefile
3# 3#
4# $Id: Makefile.common,v 1.15 2004/11/26 12:28:22 dedekind Exp $
5 4
6obj-$(CONFIG_MTD_NAND) += nand.o nand_ecc.o 5obj-$(CONFIG_MTD_NAND) += nand.o nand_ecc.o
7obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o 6obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o
@@ -24,7 +23,7 @@ obj-$(CONFIG_MTD_NAND_TS7250) += ts7250.o
24obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o 23obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o
25obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o 24obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o
26obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o 25obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
27obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o 26obj-$(CONFIG_MTD_NAND_ATMEL) += atmel_nand.o
28obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o 27obj-$(CONFIG_MTD_NAND_CM_X270) += cmx270_nand.o
29obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o 28obj-$(CONFIG_MTD_NAND_BASLER_EXCITE) += excite_nandflash.o
30obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o 29obj-$(CONFIG_MTD_NAND_PXA3xx) += pxa3xx_nand.o
diff --git a/drivers/mtd/nand/at91_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0adb287027a2..99aec46e2145 100644
--- a/drivers/mtd/nand/at91_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/mtd/nand/at91_nand.c
3 *
4 * Copyright (C) 2003 Rick Bronson 2 * Copyright (C) 2003 Rick Bronson
5 * 3 *
6 * Derived from drivers/mtd/nand/autcpu12.c 4 * Derived from drivers/mtd/nand/autcpu12.c
@@ -31,20 +29,19 @@
31#include <linux/mtd/nand.h> 29#include <linux/mtd/nand.h>
32#include <linux/mtd/partitions.h> 30#include <linux/mtd/partitions.h>
33 31
34#include <asm/io.h> 32#include <linux/gpio.h>
35#include <asm/sizes.h> 33#include <linux/io.h>
36 34
37#include <asm/hardware.h>
38#include <asm/arch/board.h> 35#include <asm/arch/board.h>
39#include <asm/arch/gpio.h> 36#include <asm/arch/cpu.h>
40 37
41#ifdef CONFIG_MTD_NAND_AT91_ECC_HW 38#ifdef CONFIG_MTD_NAND_ATMEL_ECC_HW
42#define hard_ecc 1 39#define hard_ecc 1
43#else 40#else
44#define hard_ecc 0 41#define hard_ecc 0
45#endif 42#endif
46 43
47#ifdef CONFIG_MTD_NAND_AT91_ECC_NONE 44#ifdef CONFIG_MTD_NAND_ATMEL_ECC_NONE
48#define no_ecc 1 45#define no_ecc 1
49#else 46#else
50#define no_ecc 0 47#define no_ecc 0
@@ -52,18 +49,18 @@
52 49
53/* Register access macros */ 50/* Register access macros */
54#define ecc_readl(add, reg) \ 51#define ecc_readl(add, reg) \
55 __raw_readl(add + AT91_ECC_##reg) 52 __raw_readl(add + ATMEL_ECC_##reg)
56#define ecc_writel(add, reg, value) \ 53#define ecc_writel(add, reg, value) \
57 __raw_writel((value), add + AT91_ECC_##reg) 54 __raw_writel((value), add + ATMEL_ECC_##reg)
58 55
59#include <asm/arch/at91_ecc.h> /* AT91SAM9260/3 ECC registers */ 56#include "atmel_nand_ecc.h" /* Hardware ECC registers */
60 57
61/* oob layout for large page size 58/* oob layout for large page size
62 * bad block info is on bytes 0 and 1 59 * bad block info is on bytes 0 and 1
63 * the bytes have to be consecutives to avoid 60 * the bytes have to be consecutives to avoid
64 * several NAND_CMD_RNDOUT during read 61 * several NAND_CMD_RNDOUT during read
65 */ 62 */
66static struct nand_ecclayout at91_oobinfo_large = { 63static struct nand_ecclayout atmel_oobinfo_large = {
67 .eccbytes = 4, 64 .eccbytes = 4,
68 .eccpos = {60, 61, 62, 63}, 65 .eccpos = {60, 61, 62, 63},
69 .oobfree = { 66 .oobfree = {
@@ -76,7 +73,7 @@ static struct nand_ecclayout at91_oobinfo_large = {
76 * the bytes have to be consecutives to avoid 73 * the bytes have to be consecutives to avoid
77 * several NAND_CMD_RNDOUT during read 74 * several NAND_CMD_RNDOUT during read
78 */ 75 */
79static struct nand_ecclayout at91_oobinfo_small = { 76static struct nand_ecclayout atmel_oobinfo_small = {
80 .eccbytes = 4, 77 .eccbytes = 4,
81 .eccpos = {0, 1, 2, 3}, 78 .eccpos = {0, 1, 2, 3},
82 .oobfree = { 79 .oobfree = {
@@ -84,11 +81,11 @@ static struct nand_ecclayout at91_oobinfo_small = {
84 }, 81 },
85}; 82};
86 83
87struct at91_nand_host { 84struct atmel_nand_host {
88 struct nand_chip nand_chip; 85 struct nand_chip nand_chip;
89 struct mtd_info mtd; 86 struct mtd_info mtd;
90 void __iomem *io_base; 87 void __iomem *io_base;
91 struct at91_nand_data *board; 88 struct atmel_nand_data *board;
92 struct device *dev; 89 struct device *dev;
93 void __iomem *ecc; 90 void __iomem *ecc;
94}; 91};
@@ -96,34 +93,34 @@ struct at91_nand_host {
96/* 93/*
97 * Enable NAND. 94 * Enable NAND.
98 */ 95 */
99static void at91_nand_enable(struct at91_nand_host *host) 96static void atmel_nand_enable(struct atmel_nand_host *host)
100{ 97{
101 if (host->board->enable_pin) 98 if (host->board->enable_pin)
102 at91_set_gpio_value(host->board->enable_pin, 0); 99 gpio_set_value(host->board->enable_pin, 0);
103} 100}
104 101
105/* 102/*
106 * Disable NAND. 103 * Disable NAND.
107 */ 104 */
108static void at91_nand_disable(struct at91_nand_host *host) 105static void atmel_nand_disable(struct atmel_nand_host *host)
109{ 106{
110 if (host->board->enable_pin) 107 if (host->board->enable_pin)
111 at91_set_gpio_value(host->board->enable_pin, 1); 108 gpio_set_value(host->board->enable_pin, 1);
112} 109}
113 110
114/* 111/*
115 * Hardware specific access to control-lines 112 * Hardware specific access to control-lines
116 */ 113 */
117static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 114static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
118{ 115{
119 struct nand_chip *nand_chip = mtd->priv; 116 struct nand_chip *nand_chip = mtd->priv;
120 struct at91_nand_host *host = nand_chip->priv; 117 struct atmel_nand_host *host = nand_chip->priv;
121 118
122 if (ctrl & NAND_CTRL_CHANGE) { 119 if (ctrl & NAND_CTRL_CHANGE) {
123 if (ctrl & NAND_NCE) 120 if (ctrl & NAND_NCE)
124 at91_nand_enable(host); 121 atmel_nand_enable(host);
125 else 122 else
126 at91_nand_disable(host); 123 atmel_nand_disable(host);
127 } 124 }
128 if (cmd == NAND_CMD_NONE) 125 if (cmd == NAND_CMD_NONE)
129 return; 126 return;
@@ -137,18 +134,49 @@ static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
137/* 134/*
138 * Read the Device Ready pin. 135 * Read the Device Ready pin.
139 */ 136 */
140static int at91_nand_device_ready(struct mtd_info *mtd) 137static int atmel_nand_device_ready(struct mtd_info *mtd)
141{ 138{
142 struct nand_chip *nand_chip = mtd->priv; 139 struct nand_chip *nand_chip = mtd->priv;
143 struct at91_nand_host *host = nand_chip->priv; 140 struct atmel_nand_host *host = nand_chip->priv;
144 141
145 return at91_get_gpio_value(host->board->rdy_pin); 142 return gpio_get_value(host->board->rdy_pin);
143}
144
145/*
146 * Minimal-overhead PIO for data access.
147 */
148static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
149{
150 struct nand_chip *nand_chip = mtd->priv;
151
152 __raw_readsb(nand_chip->IO_ADDR_R, buf, len);
153}
154
155static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
156{
157 struct nand_chip *nand_chip = mtd->priv;
158
159 __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2);
160}
161
162static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
163{
164 struct nand_chip *nand_chip = mtd->priv;
165
166 __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
167}
168
169static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
170{
171 struct nand_chip *nand_chip = mtd->priv;
172
173 __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
146} 174}
147 175
148/* 176/*
149 * write oob for small pages 177 * write oob for small pages
150 */ 178 */
151static int at91_nand_write_oob_512(struct mtd_info *mtd, 179static int atmel_nand_write_oob_512(struct mtd_info *mtd,
152 struct nand_chip *chip, int page) 180 struct nand_chip *chip, int page)
153{ 181{
154 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; 182 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
@@ -176,7 +204,7 @@ static int at91_nand_write_oob_512(struct mtd_info *mtd,
176/* 204/*
177 * read oob for small pages 205 * read oob for small pages
178 */ 206 */
179static int at91_nand_read_oob_512(struct mtd_info *mtd, 207static int atmel_nand_read_oob_512(struct mtd_info *mtd,
180 struct nand_chip *chip, int page, int sndcmd) 208 struct nand_chip *chip, int page, int sndcmd)
181{ 209{
182 if (sndcmd) { 210 if (sndcmd) {
@@ -196,11 +224,11 @@ static int at91_nand_read_oob_512(struct mtd_info *mtd,
196 * dat: raw data (unused) 224 * dat: raw data (unused)
197 * ecc_code: buffer for ECC 225 * ecc_code: buffer for ECC
198 */ 226 */
199static int at91_nand_calculate(struct mtd_info *mtd, 227static int atmel_nand_calculate(struct mtd_info *mtd,
200 const u_char *dat, unsigned char *ecc_code) 228 const u_char *dat, unsigned char *ecc_code)
201{ 229{
202 struct nand_chip *nand_chip = mtd->priv; 230 struct nand_chip *nand_chip = mtd->priv;
203 struct at91_nand_host *host = nand_chip->priv; 231 struct atmel_nand_host *host = nand_chip->priv;
204 uint32_t *eccpos = nand_chip->ecc.layout->eccpos; 232 uint32_t *eccpos = nand_chip->ecc.layout->eccpos;
205 unsigned int ecc_value; 233 unsigned int ecc_value;
206 234
@@ -211,7 +239,7 @@ static int at91_nand_calculate(struct mtd_info *mtd,
211 ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF; 239 ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF;
212 240
213 /* get the last 2 ECC bytes */ 241 /* get the last 2 ECC bytes */
214 ecc_value = ecc_readl(host->ecc, NPR) & AT91_ECC_NPARITY; 242 ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY;
215 243
216 ecc_code[eccpos[2]] = ecc_value & 0xFF; 244 ecc_code[eccpos[2]] = ecc_value & 0xFF;
217 ecc_code[eccpos[3]] = (ecc_value >> 8) & 0xFF; 245 ecc_code[eccpos[3]] = (ecc_value >> 8) & 0xFF;
@@ -226,7 +254,7 @@ static int at91_nand_calculate(struct mtd_info *mtd,
226 * chip: nand chip info structure 254 * chip: nand chip info structure
227 * buf: buffer to store read data 255 * buf: buffer to store read data
228 */ 256 */
229static int at91_nand_read_page(struct mtd_info *mtd, 257static int atmel_nand_read_page(struct mtd_info *mtd,
230 struct nand_chip *chip, uint8_t *buf) 258 struct nand_chip *chip, uint8_t *buf)
231{ 259{
232 int eccsize = chip->ecc.size; 260 int eccsize = chip->ecc.size;
@@ -237,6 +265,19 @@ static int at91_nand_read_page(struct mtd_info *mtd,
237 uint8_t *ecc_pos; 265 uint8_t *ecc_pos;
238 int stat; 266 int stat;
239 267
268 /*
269 * Errata: ALE is incorrectly wired up to the ECC controller
270 * on the AP7000, so it will include the address cycles in the
271 * ECC calculation.
272 *
273 * Workaround: Reset the parity registers before reading the
274 * actual data.
275 */
276 if (cpu_is_at32ap7000()) {
277 struct atmel_nand_host *host = chip->priv;
278 ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
279 }
280
240 /* read the page */ 281 /* read the page */
241 chip->read_buf(mtd, p, eccsize); 282 chip->read_buf(mtd, p, eccsize);
242 283
@@ -285,11 +326,11 @@ static int at91_nand_read_page(struct mtd_info *mtd,
285 * 326 *
286 * Detect and correct a 1 bit error for a page 327 * Detect and correct a 1 bit error for a page
287 */ 328 */
288static int at91_nand_correct(struct mtd_info *mtd, u_char *dat, 329static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
289 u_char *read_ecc, u_char *isnull) 330 u_char *read_ecc, u_char *isnull)
290{ 331{
291 struct nand_chip *nand_chip = mtd->priv; 332 struct nand_chip *nand_chip = mtd->priv;
292 struct at91_nand_host *host = nand_chip->priv; 333 struct atmel_nand_host *host = nand_chip->priv;
293 unsigned int ecc_status; 334 unsigned int ecc_status;
294 unsigned int ecc_word, ecc_bit; 335 unsigned int ecc_word, ecc_bit;
295 336
@@ -297,43 +338,43 @@ static int at91_nand_correct(struct mtd_info *mtd, u_char *dat,
297 ecc_status = ecc_readl(host->ecc, SR); 338 ecc_status = ecc_readl(host->ecc, SR);
298 339
299 /* if there's no error */ 340 /* if there's no error */
300 if (likely(!(ecc_status & AT91_ECC_RECERR))) 341 if (likely(!(ecc_status & ATMEL_ECC_RECERR)))
301 return 0; 342 return 0;
302 343
303 /* get error bit offset (4 bits) */ 344 /* get error bit offset (4 bits) */
304 ecc_bit = ecc_readl(host->ecc, PR) & AT91_ECC_BITADDR; 345 ecc_bit = ecc_readl(host->ecc, PR) & ATMEL_ECC_BITADDR;
305 /* get word address (12 bits) */ 346 /* get word address (12 bits) */
306 ecc_word = ecc_readl(host->ecc, PR) & AT91_ECC_WORDADDR; 347 ecc_word = ecc_readl(host->ecc, PR) & ATMEL_ECC_WORDADDR;
307 ecc_word >>= 4; 348 ecc_word >>= 4;
308 349
309 /* if there are multiple errors */ 350 /* if there are multiple errors */
310 if (ecc_status & AT91_ECC_MULERR) { 351 if (ecc_status & ATMEL_ECC_MULERR) {
311 /* check if it is a freshly erased block 352 /* check if it is a freshly erased block
312 * (filled with 0xff) */ 353 * (filled with 0xff) */
313 if ((ecc_bit == AT91_ECC_BITADDR) 354 if ((ecc_bit == ATMEL_ECC_BITADDR)
314 && (ecc_word == (AT91_ECC_WORDADDR >> 4))) { 355 && (ecc_word == (ATMEL_ECC_WORDADDR >> 4))) {
315 /* the block has just been erased, return OK */ 356 /* the block has just been erased, return OK */
316 return 0; 357 return 0;
317 } 358 }
318 /* it doesn't seems to be a freshly 359 /* it doesn't seems to be a freshly
319 * erased block. 360 * erased block.
320 * We can't correct so many errors */ 361 * We can't correct so many errors */
321 dev_dbg(host->dev, "at91_nand : multiple errors detected." 362 dev_dbg(host->dev, "atmel_nand : multiple errors detected."
322 " Unable to correct.\n"); 363 " Unable to correct.\n");
323 return -EIO; 364 return -EIO;
324 } 365 }
325 366
326 /* if there's a single bit error : we can correct it */ 367 /* if there's a single bit error : we can correct it */
327 if (ecc_status & AT91_ECC_ECCERR) { 368 if (ecc_status & ATMEL_ECC_ECCERR) {
328 /* there's nothing much to do here. 369 /* there's nothing much to do here.
329 * the bit error is on the ECC itself. 370 * the bit error is on the ECC itself.
330 */ 371 */
331 dev_dbg(host->dev, "at91_nand : one bit error on ECC code." 372 dev_dbg(host->dev, "atmel_nand : one bit error on ECC code."
332 " Nothing to correct\n"); 373 " Nothing to correct\n");
333 return 0; 374 return 0;
334 } 375 }
335 376
336 dev_dbg(host->dev, "at91_nand : one bit error on data." 377 dev_dbg(host->dev, "atmel_nand : one bit error on data."
337 " (word offset in the page :" 378 " (word offset in the page :"
338 " 0x%x bit offset : 0x%x)\n", 379 " 0x%x bit offset : 0x%x)\n",
339 ecc_word, ecc_bit); 380 ecc_word, ecc_bit);
@@ -345,14 +386,21 @@ static int at91_nand_correct(struct mtd_info *mtd, u_char *dat,
345 /* 8 bits words */ 386 /* 8 bits words */
346 dat[ecc_word] ^= (1 << ecc_bit); 387 dat[ecc_word] ^= (1 << ecc_bit);
347 } 388 }
348 dev_dbg(host->dev, "at91_nand : error corrected\n"); 389 dev_dbg(host->dev, "atmel_nand : error corrected\n");
349 return 1; 390 return 1;
350} 391}
351 392
352/* 393/*
353 * Enable HW ECC : unsused 394 * Enable HW ECC : unused on most chips
354 */ 395 */
355static void at91_nand_hwctl(struct mtd_info *mtd, int mode) { ; } 396static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
397{
398 if (cpu_is_at32ap7000()) {
399 struct nand_chip *nand_chip = mtd->priv;
400 struct atmel_nand_host *host = nand_chip->priv;
401 ecc_writel(host->ecc, CR, ATMEL_ECC_RST);
402 }
403}
356 404
357#ifdef CONFIG_MTD_PARTITIONS 405#ifdef CONFIG_MTD_PARTITIONS
358static const char *part_probes[] = { "cmdlinepart", NULL }; 406static const char *part_probes[] = { "cmdlinepart", NULL };
@@ -361,9 +409,9 @@ static const char *part_probes[] = { "cmdlinepart", NULL };
361/* 409/*
362 * Probe for the NAND device. 410 * Probe for the NAND device.
363 */ 411 */
364static int __init at91_nand_probe(struct platform_device *pdev) 412static int __init atmel_nand_probe(struct platform_device *pdev)
365{ 413{
366 struct at91_nand_host *host; 414 struct atmel_nand_host *host;
367 struct mtd_info *mtd; 415 struct mtd_info *mtd;
368 struct nand_chip *nand_chip; 416 struct nand_chip *nand_chip;
369 struct resource *regs; 417 struct resource *regs;
@@ -375,24 +423,24 @@ static int __init at91_nand_probe(struct platform_device *pdev)
375 int num_partitions = 0; 423 int num_partitions = 0;
376#endif 424#endif
377 425
378 /* Allocate memory for the device structure (and zero it) */
379 host = kzalloc(sizeof(struct at91_nand_host), GFP_KERNEL);
380 if (!host) {
381 printk(KERN_ERR "at91_nand: failed to allocate device structure.\n");
382 return -ENOMEM;
383 }
384
385 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 426 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
386 if (!mem) { 427 if (!mem) {
387 printk(KERN_ERR "at91_nand: can't get I/O resource mem\n"); 428 printk(KERN_ERR "atmel_nand: can't get I/O resource mem\n");
388 return -ENXIO; 429 return -ENXIO;
389 } 430 }
390 431
432 /* Allocate memory for the device structure (and zero it) */
433 host = kzalloc(sizeof(struct atmel_nand_host), GFP_KERNEL);
434 if (!host) {
435 printk(KERN_ERR "atmel_nand: failed to allocate device structure.\n");
436 return -ENOMEM;
437 }
438
391 host->io_base = ioremap(mem->start, mem->end - mem->start + 1); 439 host->io_base = ioremap(mem->start, mem->end - mem->start + 1);
392 if (host->io_base == NULL) { 440 if (host->io_base == NULL) {
393 printk(KERN_ERR "at91_nand: ioremap failed\n"); 441 printk(KERN_ERR "atmel_nand: ioremap failed\n");
394 kfree(host); 442 res = -EIO;
395 return -EIO; 443 goto err_nand_ioremap;
396 } 444 }
397 445
398 mtd = &host->mtd; 446 mtd = &host->mtd;
@@ -407,14 +455,14 @@ static int __init at91_nand_probe(struct platform_device *pdev)
407 /* Set address of NAND IO lines */ 455 /* Set address of NAND IO lines */
408 nand_chip->IO_ADDR_R = host->io_base; 456 nand_chip->IO_ADDR_R = host->io_base;
409 nand_chip->IO_ADDR_W = host->io_base; 457 nand_chip->IO_ADDR_W = host->io_base;
410 nand_chip->cmd_ctrl = at91_nand_cmd_ctrl; 458 nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;
411 459
412 if (host->board->rdy_pin) 460 if (host->board->rdy_pin)
413 nand_chip->dev_ready = at91_nand_device_ready; 461 nand_chip->dev_ready = atmel_nand_device_ready;
414 462
415 regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); 463 regs = platform_get_resource(pdev, IORESOURCE_MEM, 1);
416 if (!regs && hard_ecc) { 464 if (!regs && hard_ecc) {
417 printk(KERN_ERR "at91_nand: can't get I/O resource " 465 printk(KERN_ERR "atmel_nand: can't get I/O resource "
418 "regs\nFalling back on software ECC\n"); 466 "regs\nFalling back on software ECC\n");
419 } 467 }
420 468
@@ -424,15 +472,15 @@ static int __init at91_nand_probe(struct platform_device *pdev)
424 if (hard_ecc && regs) { 472 if (hard_ecc && regs) {
425 host->ecc = ioremap(regs->start, regs->end - regs->start + 1); 473 host->ecc = ioremap(regs->start, regs->end - regs->start + 1);
426 if (host->ecc == NULL) { 474 if (host->ecc == NULL) {
427 printk(KERN_ERR "at91_nand: ioremap failed\n"); 475 printk(KERN_ERR "atmel_nand: ioremap failed\n");
428 res = -EIO; 476 res = -EIO;
429 goto err_ecc_ioremap; 477 goto err_ecc_ioremap;
430 } 478 }
431 nand_chip->ecc.mode = NAND_ECC_HW_SYNDROME; 479 nand_chip->ecc.mode = NAND_ECC_HW_SYNDROME;
432 nand_chip->ecc.calculate = at91_nand_calculate; 480 nand_chip->ecc.calculate = atmel_nand_calculate;
433 nand_chip->ecc.correct = at91_nand_correct; 481 nand_chip->ecc.correct = atmel_nand_correct;
434 nand_chip->ecc.hwctl = at91_nand_hwctl; 482 nand_chip->ecc.hwctl = atmel_nand_hwctl;
435 nand_chip->ecc.read_page = at91_nand_read_page; 483 nand_chip->ecc.read_page = atmel_nand_read_page;
436 nand_chip->ecc.bytes = 4; 484 nand_chip->ecc.bytes = 4;
437 nand_chip->ecc.prepad = 0; 485 nand_chip->ecc.prepad = 0;
438 nand_chip->ecc.postpad = 0; 486 nand_chip->ecc.postpad = 0;
@@ -440,24 +488,30 @@ static int __init at91_nand_probe(struct platform_device *pdev)
440 488
441 nand_chip->chip_delay = 20; /* 20us command delay time */ 489 nand_chip->chip_delay = 20; /* 20us command delay time */
442 490
443 if (host->board->bus_width_16) /* 16-bit bus width */ 491 if (host->board->bus_width_16) { /* 16-bit bus width */
444 nand_chip->options |= NAND_BUSWIDTH_16; 492 nand_chip->options |= NAND_BUSWIDTH_16;
493 nand_chip->read_buf = atmel_read_buf16;
494 nand_chip->write_buf = atmel_write_buf16;
495 } else {
496 nand_chip->read_buf = atmel_read_buf;
497 nand_chip->write_buf = atmel_write_buf;
498 }
445 499
446 platform_set_drvdata(pdev, host); 500 platform_set_drvdata(pdev, host);
447 at91_nand_enable(host); 501 atmel_nand_enable(host);
448 502
449 if (host->board->det_pin) { 503 if (host->board->det_pin) {
450 if (at91_get_gpio_value(host->board->det_pin)) { 504 if (gpio_get_value(host->board->det_pin)) {
451 printk ("No SmartMedia card inserted.\n"); 505 printk("No SmartMedia card inserted.\n");
452 res = ENXIO; 506 res = ENXIO;
453 goto out; 507 goto err_no_card;
454 } 508 }
455 } 509 }
456 510
457 /* first scan to find the device and get the page size */ 511 /* first scan to find the device and get the page size */
458 if (nand_scan_ident(mtd, 1)) { 512 if (nand_scan_ident(mtd, 1)) {
459 res = -ENXIO; 513 res = -ENXIO;
460 goto out; 514 goto err_scan_ident;
461 } 515 }
462 516
463 if (nand_chip->ecc.mode == NAND_ECC_HW_SYNDROME) { 517 if (nand_chip->ecc.mode == NAND_ECC_HW_SYNDROME) {
@@ -467,22 +521,22 @@ static int __init at91_nand_probe(struct platform_device *pdev)
467 /* set ECC page size and oob layout */ 521 /* set ECC page size and oob layout */
468 switch (mtd->writesize) { 522 switch (mtd->writesize) {
469 case 512: 523 case 512:
470 nand_chip->ecc.layout = &at91_oobinfo_small; 524 nand_chip->ecc.layout = &atmel_oobinfo_small;
471 nand_chip->ecc.read_oob = at91_nand_read_oob_512; 525 nand_chip->ecc.read_oob = atmel_nand_read_oob_512;
472 nand_chip->ecc.write_oob = at91_nand_write_oob_512; 526 nand_chip->ecc.write_oob = atmel_nand_write_oob_512;
473 ecc_writel(host->ecc, MR, AT91_ECC_PAGESIZE_528); 527 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_528);
474 break; 528 break;
475 case 1024: 529 case 1024:
476 nand_chip->ecc.layout = &at91_oobinfo_large; 530 nand_chip->ecc.layout = &atmel_oobinfo_large;
477 ecc_writel(host->ecc, MR, AT91_ECC_PAGESIZE_1056); 531 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_1056);
478 break; 532 break;
479 case 2048: 533 case 2048:
480 nand_chip->ecc.layout = &at91_oobinfo_large; 534 nand_chip->ecc.layout = &atmel_oobinfo_large;
481 ecc_writel(host->ecc, MR, AT91_ECC_PAGESIZE_2112); 535 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_2112);
482 break; 536 break;
483 case 4096: 537 case 4096:
484 nand_chip->ecc.layout = &at91_oobinfo_large; 538 nand_chip->ecc.layout = &atmel_oobinfo_large;
485 ecc_writel(host->ecc, MR, AT91_ECC_PAGESIZE_4224); 539 ecc_writel(host->ecc, MR, ATMEL_ECC_PAGESIZE_4224);
486 break; 540 break;
487 default: 541 default:
488 /* page size not handled by HW ECC */ 542 /* page size not handled by HW ECC */
@@ -502,12 +556,12 @@ static int __init at91_nand_probe(struct platform_device *pdev)
502 /* second phase scan */ 556 /* second phase scan */
503 if (nand_scan_tail(mtd)) { 557 if (nand_scan_tail(mtd)) {
504 res = -ENXIO; 558 res = -ENXIO;
505 goto out; 559 goto err_scan_tail;
506 } 560 }
507 561
508#ifdef CONFIG_MTD_PARTITIONS 562#ifdef CONFIG_MTD_PARTITIONS
509#ifdef CONFIG_MTD_CMDLINE_PARTS 563#ifdef CONFIG_MTD_CMDLINE_PARTS
510 mtd->name = "at91_nand"; 564 mtd->name = "atmel_nand";
511 num_partitions = parse_mtd_partitions(mtd, part_probes, 565 num_partitions = parse_mtd_partitions(mtd, part_probes,
512 &partitions, 0); 566 &partitions, 0);
513#endif 567#endif
@@ -516,9 +570,9 @@ static int __init at91_nand_probe(struct platform_device *pdev)
516 &num_partitions); 570 &num_partitions);
517 571
518 if ((!partitions) || (num_partitions == 0)) { 572 if ((!partitions) || (num_partitions == 0)) {
519 printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n"); 573 printk(KERN_ERR "atmel_nand: No parititions defined, or unsupported device.\n");
520 res = ENXIO; 574 res = ENXIO;
521 goto release; 575 goto err_no_partitions;
522 } 576 }
523 577
524 res = add_mtd_partitions(mtd, partitions, num_partitions); 578 res = add_mtd_partitions(mtd, partitions, num_partitions);
@@ -530,17 +584,19 @@ static int __init at91_nand_probe(struct platform_device *pdev)
530 return res; 584 return res;
531 585
532#ifdef CONFIG_MTD_PARTITIONS 586#ifdef CONFIG_MTD_PARTITIONS
533release: 587err_no_partitions:
534#endif 588#endif
535 nand_release(mtd); 589 nand_release(mtd);
536 590err_scan_tail:
537out: 591err_scan_ident:
538 iounmap(host->ecc); 592err_no_card:
539 593 atmel_nand_disable(host);
540err_ecc_ioremap:
541 at91_nand_disable(host);
542 platform_set_drvdata(pdev, NULL); 594 platform_set_drvdata(pdev, NULL);
595 if (host->ecc)
596 iounmap(host->ecc);
597err_ecc_ioremap:
543 iounmap(host->io_base); 598 iounmap(host->io_base);
599err_nand_ioremap:
544 kfree(host); 600 kfree(host);
545 return res; 601 return res;
546} 602}
@@ -548,47 +604,47 @@ err_ecc_ioremap:
548/* 604/*
549 * Remove a NAND device. 605 * Remove a NAND device.
550 */ 606 */
551static int __devexit at91_nand_remove(struct platform_device *pdev) 607static int __exit atmel_nand_remove(struct platform_device *pdev)
552{ 608{
553 struct at91_nand_host *host = platform_get_drvdata(pdev); 609 struct atmel_nand_host *host = platform_get_drvdata(pdev);
554 struct mtd_info *mtd = &host->mtd; 610 struct mtd_info *mtd = &host->mtd;
555 611
556 nand_release(mtd); 612 nand_release(mtd);
557 613
558 at91_nand_disable(host); 614 atmel_nand_disable(host);
559 615
616 if (host->ecc)
617 iounmap(host->ecc);
560 iounmap(host->io_base); 618 iounmap(host->io_base);
561 iounmap(host->ecc);
562 kfree(host); 619 kfree(host);
563 620
564 return 0; 621 return 0;
565} 622}
566 623
567static struct platform_driver at91_nand_driver = { 624static struct platform_driver atmel_nand_driver = {
568 .probe = at91_nand_probe, 625 .remove = __exit_p(atmel_nand_remove),
569 .remove = at91_nand_remove,
570 .driver = { 626 .driver = {
571 .name = "at91_nand", 627 .name = "atmel_nand",
572 .owner = THIS_MODULE, 628 .owner = THIS_MODULE,
573 }, 629 },
574}; 630};
575 631
576static int __init at91_nand_init(void) 632static int __init atmel_nand_init(void)
577{ 633{
578 return platform_driver_register(&at91_nand_driver); 634 return platform_driver_probe(&atmel_nand_driver, atmel_nand_probe);
579} 635}
580 636
581 637
582static void __exit at91_nand_exit(void) 638static void __exit atmel_nand_exit(void)
583{ 639{
584 platform_driver_unregister(&at91_nand_driver); 640 platform_driver_unregister(&atmel_nand_driver);
585} 641}
586 642
587 643
588module_init(at91_nand_init); 644module_init(atmel_nand_init);
589module_exit(at91_nand_exit); 645module_exit(atmel_nand_exit);
590 646
591MODULE_LICENSE("GPL"); 647MODULE_LICENSE("GPL");
592MODULE_AUTHOR("Rick Bronson"); 648MODULE_AUTHOR("Rick Bronson");
593MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91RM9200 / AT91SAM9"); 649MODULE_DESCRIPTION("NAND/SmartMedia driver for AT91 / AVR32");
594MODULE_ALIAS("platform:at91_nand"); 650MODULE_ALIAS("platform:atmel_nand");
diff --git a/drivers/mtd/nand/atmel_nand_ecc.h b/drivers/mtd/nand/atmel_nand_ecc.h
new file mode 100644
index 000000000000..1ee7f993db1c
--- /dev/null
+++ b/drivers/mtd/nand/atmel_nand_ecc.h
@@ -0,0 +1,36 @@
1/*
2 * Error Corrected Code Controller (ECC) - System peripherals regsters.
3 * Based on AT91SAM9260 datasheet revision B.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#ifndef ATMEL_NAND_ECC_H
12#define ATMEL_NAND_ECC_H
13
14#define ATMEL_ECC_CR 0x00 /* Control register */
15#define ATMEL_ECC_RST (1 << 0) /* Reset parity */
16
17#define ATMEL_ECC_MR 0x04 /* Mode register */
18#define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
19#define ATMEL_ECC_PAGESIZE_528 (0)
20#define ATMEL_ECC_PAGESIZE_1056 (1)
21#define ATMEL_ECC_PAGESIZE_2112 (2)
22#define ATMEL_ECC_PAGESIZE_4224 (3)
23
24#define ATMEL_ECC_SR 0x08 /* Status register */
25#define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
26#define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
27#define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
28
29#define ATMEL_ECC_PR 0x0c /* Parity register */
30#define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
31#define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
32
33#define ATMEL_ECC_NPR 0x10 /* NParity register */
34#define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
35
36#endif
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 09e421a96893..761946ea45b1 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2004 Embedded Edge, LLC 4 * Copyright (C) 2004 Embedded Edge, LLC
5 * 5 *
6 * $Id: au1550nd.c,v 1.13 2005/11/07 11:14:30 gleixner Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
@@ -604,8 +602,6 @@ module_init(au1xxx_nand_init);
604 */ 602 */
605static void __exit au1550_cleanup(void) 603static void __exit au1550_cleanup(void)
606{ 604{
607 struct nand_chip *this = (struct nand_chip *)&au1550_mtd[1];
608
609 /* Release resources, unregister device */ 605 /* Release resources, unregister device */
610 nand_release(au1550_mtd); 606 nand_release(au1550_mtd);
611 607
diff --git a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
index dd38011ee0b7..553dd7e9b41c 100644
--- a/drivers/mtd/nand/autcpu12.c
+++ b/drivers/mtd/nand/autcpu12.c
@@ -6,8 +6,6 @@
6 * Derived from drivers/mtd/spia.c 6 * Derived from drivers/mtd/spia.c
7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
8 * 8 *
9 * $Id: autcpu12.c,v 1.23 2005/11/07 11:14:30 gleixner Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index da6ceaa80ba1..95345d051579 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -626,10 +626,12 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
626{ 626{
627 struct mtd_info *mtd; 627 struct mtd_info *mtd;
628 struct cafe_priv *cafe; 628 struct cafe_priv *cafe;
629 struct mtd_partition *parts;
630 uint32_t ctrl; 629 uint32_t ctrl;
631 int nr_parts;
632 int err = 0; 630 int err = 0;
631#ifdef CONFIG_MTD_PARTITIONS
632 struct mtd_partition *parts;
633 int nr_parts;
634#endif
633 635
634 /* Very old versions shared the same PCI ident for all three 636 /* Very old versions shared the same PCI ident for all three
635 functions on the chip. Verify the class too... */ 637 functions on the chip. Verify the class too... */
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 0e72153b3297..765d4f0f7c86 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -15,8 +15,6 @@
15 * converted to the generic Reed-Solomon library by Thomas Gleixner <tglx@linutronix.de> 15 * converted to the generic Reed-Solomon library by Thomas Gleixner <tglx@linutronix.de>
16 * 16 *
17 * Interface to generic NAND code for M-Systems DiskOnChip devices 17 * Interface to generic NAND code for M-Systems DiskOnChip devices
18 *
19 * $Id: diskonchip.c,v 1.55 2005/11/07 11:14:30 gleixner Exp $
20 */ 18 */
21 19
22#include <linux/kernel.h> 20#include <linux/kernel.h>
@@ -54,8 +52,6 @@ static unsigned long __initdata doc_locations[] = {
54 0xe0000, 0xe2000, 0xe4000, 0xe6000, 52 0xe0000, 0xe2000, 0xe4000, 0xe6000,
55 0xe8000, 0xea000, 0xec000, 0xee000, 53 0xe8000, 0xea000, 0xec000, 0xee000,
56#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 54#endif /* CONFIG_MTD_DOCPROBE_HIGH */
57#elif defined(__PPC__)
58 0xe4000000,
59#else 55#else
60#warning Unknown architecture for DiskOnChip. No default probe locations defined 56#warning Unknown architecture for DiskOnChip. No default probe locations defined
61#endif 57#endif
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
index ba67bbec20d3..387e4352903e 100644
--- a/drivers/mtd/nand/edb7312.c
+++ b/drivers/mtd/nand/edb7312.c
@@ -6,8 +6,6 @@
6 * Derived from drivers/mtd/nand/autcpu12.c 6 * Derived from drivers/mtd/nand/autcpu12.c
7 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 7 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
8 * 8 *
9 * $Id: edb7312.c,v 1.12 2005/11/07 11:14:30 gleixner Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/excite_nandflash.c b/drivers/mtd/nand/excite_nandflash.c
index bed87290decc..ced14b5294d5 100644
--- a/drivers/mtd/nand/excite_nandflash.c
+++ b/drivers/mtd/nand/excite_nandflash.c
@@ -209,7 +209,7 @@ static int __init excite_nand_probe(struct device *dev)
209 if (likely(!scan_res)) { 209 if (likely(!scan_res)) {
210 DEBUG(MTD_DEBUG_LEVEL2, "%s: register partitions\n", module_id); 210 DEBUG(MTD_DEBUG_LEVEL2, "%s: register partitions\n", module_id);
211 add_mtd_partitions(&drvdata->board_mtd, partition_info, 211 add_mtd_partitions(&drvdata->board_mtd, partition_info,
212 sizeof partition_info / sizeof partition_info[0]); 212 ARRAY_SIZE(partition_info));
213 } else { 213 } else {
214 iounmap(drvdata->regs); 214 iounmap(drvdata->regs);
215 kfree(drvdata); 215 kfree(drvdata);
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 4b69aacdf5ca..9dff51351f4f 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -89,7 +89,6 @@ static struct nand_ecclayout fsl_elbc_oob_sp_eccm0 = {
89 .eccbytes = 3, 89 .eccbytes = 3,
90 .eccpos = {6, 7, 8}, 90 .eccpos = {6, 7, 8},
91 .oobfree = { {0, 5}, {9, 7} }, 91 .oobfree = { {0, 5}, {9, 7} },
92 .oobavail = 12,
93}; 92};
94 93
95/* Small Page FLASH with FMR[ECCM] = 1 */ 94/* Small Page FLASH with FMR[ECCM] = 1 */
@@ -97,7 +96,6 @@ static struct nand_ecclayout fsl_elbc_oob_sp_eccm1 = {
97 .eccbytes = 3, 96 .eccbytes = 3,
98 .eccpos = {8, 9, 10}, 97 .eccpos = {8, 9, 10},
99 .oobfree = { {0, 5}, {6, 2}, {11, 5} }, 98 .oobfree = { {0, 5}, {6, 2}, {11, 5} },
100 .oobavail = 12,
101}; 99};
102 100
103/* Large Page FLASH with FMR[ECCM] = 0 */ 101/* Large Page FLASH with FMR[ECCM] = 0 */
@@ -105,7 +103,6 @@ static struct nand_ecclayout fsl_elbc_oob_lp_eccm0 = {
105 .eccbytes = 12, 103 .eccbytes = 12,
106 .eccpos = {6, 7, 8, 22, 23, 24, 38, 39, 40, 54, 55, 56}, 104 .eccpos = {6, 7, 8, 22, 23, 24, 38, 39, 40, 54, 55, 56},
107 .oobfree = { {1, 5}, {9, 13}, {25, 13}, {41, 13}, {57, 7} }, 105 .oobfree = { {1, 5}, {9, 13}, {25, 13}, {41, 13}, {57, 7} },
108 .oobavail = 48,
109}; 106};
110 107
111/* Large Page FLASH with FMR[ECCM] = 1 */ 108/* Large Page FLASH with FMR[ECCM] = 1 */
@@ -113,7 +110,48 @@ static struct nand_ecclayout fsl_elbc_oob_lp_eccm1 = {
113 .eccbytes = 12, 110 .eccbytes = 12,
114 .eccpos = {8, 9, 10, 24, 25, 26, 40, 41, 42, 56, 57, 58}, 111 .eccpos = {8, 9, 10, 24, 25, 26, 40, 41, 42, 56, 57, 58},
115 .oobfree = { {1, 7}, {11, 13}, {27, 13}, {43, 13}, {59, 5} }, 112 .oobfree = { {1, 7}, {11, 13}, {27, 13}, {43, 13}, {59, 5} },
116 .oobavail = 48, 113};
114
115/*
116 * fsl_elbc_oob_lp_eccm* specify that LP NAND's OOB free area starts at offset
117 * 1, so we have to adjust bad block pattern. This pattern should be used for
118 * x8 chips only. So far hardware does not support x16 chips anyway.
119 */
120static u8 scan_ff_pattern[] = { 0xff, };
121
122static struct nand_bbt_descr largepage_memorybased = {
123 .options = 0,
124 .offs = 0,
125 .len = 1,
126 .pattern = scan_ff_pattern,
127};
128
129/*
130 * ELBC may use HW ECC, so that OOB offsets, that NAND core uses for bbt,
131 * interfere with ECC positions, that's why we implement our own descriptors.
132 * OOB {11, 5}, works for both SP and LP chips, with ECCM = 1 and ECCM = 0.
133 */
134static u8 bbt_pattern[] = {'B', 'b', 't', '0' };
135static u8 mirror_pattern[] = {'1', 't', 'b', 'B' };
136
137static struct nand_bbt_descr bbt_main_descr = {
138 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
139 NAND_BBT_2BIT | NAND_BBT_VERSION,
140 .offs = 11,
141 .len = 4,
142 .veroffs = 15,
143 .maxblocks = 4,
144 .pattern = bbt_pattern,
145};
146
147static struct nand_bbt_descr bbt_mirror_descr = {
148 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
149 NAND_BBT_2BIT | NAND_BBT_VERSION,
150 .offs = 11,
151 .len = 4,
152 .veroffs = 15,
153 .maxblocks = 4,
154 .pattern = mirror_pattern,
117}; 155};
118 156
119/*=================================*/ 157/*=================================*/
@@ -687,8 +725,7 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
687 chip->ecc.layout = (priv->fmr & FMR_ECCM) ? 725 chip->ecc.layout = (priv->fmr & FMR_ECCM) ?
688 &fsl_elbc_oob_lp_eccm1 : 726 &fsl_elbc_oob_lp_eccm1 :
689 &fsl_elbc_oob_lp_eccm0; 727 &fsl_elbc_oob_lp_eccm0;
690 mtd->ecclayout = chip->ecc.layout; 728 chip->badblock_pattern = &largepage_memorybased;
691 mtd->oobavail = chip->ecc.layout->oobavail;
692 } 729 }
693 } else { 730 } else {
694 dev_err(ctrl->dev, 731 dev_err(ctrl->dev,
@@ -752,8 +789,12 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
752 chip->cmdfunc = fsl_elbc_cmdfunc; 789 chip->cmdfunc = fsl_elbc_cmdfunc;
753 chip->waitfunc = fsl_elbc_wait; 790 chip->waitfunc = fsl_elbc_wait;
754 791
792 chip->bbt_td = &bbt_main_descr;
793 chip->bbt_md = &bbt_mirror_descr;
794
755 /* set up nand options */ 795 /* set up nand options */
756 chip->options = NAND_NO_READRDY | NAND_NO_AUTOINCR; 796 chip->options = NAND_NO_READRDY | NAND_NO_AUTOINCR |
797 NAND_USE_FLASH_BBT;
757 798
758 chip->controller = &ctrl->controller; 799 chip->controller = &ctrl->controller;
759 chip->priv = priv; 800 chip->priv = priv;
@@ -795,8 +836,8 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
795 return 0; 836 return 0;
796} 837}
797 838
798static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl, 839static int __devinit fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
799 struct device_node *node) 840 struct device_node *node)
800{ 841{
801 struct fsl_lbc_regs __iomem *lbc = ctrl->regs; 842 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
802 struct fsl_elbc_mtd *priv; 843 struct fsl_elbc_mtd *priv;
@@ -917,7 +958,7 @@ static int __devinit fsl_elbc_ctrl_init(struct fsl_elbc_ctrl *ctrl)
917 return 0; 958 return 0;
918} 959}
919 960
920static int __devexit fsl_elbc_ctrl_remove(struct of_device *ofdev) 961static int fsl_elbc_ctrl_remove(struct of_device *ofdev)
921{ 962{
922 struct fsl_elbc_ctrl *ctrl = dev_get_drvdata(&ofdev->dev); 963 struct fsl_elbc_ctrl *ctrl = dev_get_drvdata(&ofdev->dev);
923 int i; 964 int i;
@@ -1041,7 +1082,7 @@ static struct of_platform_driver fsl_elbc_ctrl_driver = {
1041 }, 1082 },
1042 .match_table = fsl_elbc_match, 1083 .match_table = fsl_elbc_match,
1043 .probe = fsl_elbc_ctrl_probe, 1084 .probe = fsl_elbc_ctrl_probe,
1044 .remove = __devexit_p(fsl_elbc_ctrl_remove), 1085 .remove = fsl_elbc_ctrl_remove,
1045}; 1086};
1046 1087
1047static int __init fsl_elbc_init(void) 1088static int __init fsl_elbc_init(void)
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index 2d585d2d090c..9e59de501c2e 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -7,8 +7,6 @@
7 * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) 7 * Copyright (C) 2002 Marius Gröger (mag@sysgo.de)
8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
9 * 9 *
10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $
11 *
12 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ba1bdf787323..d1129bae6c27 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -798,6 +798,87 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
798} 798}
799 799
800/** 800/**
801 * nand_read_subpage - [REPLACABLE] software ecc based sub-page read function
802 * @mtd: mtd info structure
803 * @chip: nand chip info structure
804 * @dataofs offset of requested data within the page
805 * @readlen data length
806 * @buf: buffer to store read data
807 */
808static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint32_t data_offs, uint32_t readlen, uint8_t *bufpoi)
809{
810 int start_step, end_step, num_steps;
811 uint32_t *eccpos = chip->ecc.layout->eccpos;
812 uint8_t *p;
813 int data_col_addr, i, gaps = 0;
814 int datafrag_len, eccfrag_len, aligned_len, aligned_pos;
815 int busw = (chip->options & NAND_BUSWIDTH_16) ? 2 : 1;
816
817 /* Column address wihin the page aligned to ECC size (256bytes). */
818 start_step = data_offs / chip->ecc.size;
819 end_step = (data_offs + readlen - 1) / chip->ecc.size;
820 num_steps = end_step - start_step + 1;
821
822 /* Data size aligned to ECC ecc.size*/
823 datafrag_len = num_steps * chip->ecc.size;
824 eccfrag_len = num_steps * chip->ecc.bytes;
825
826 data_col_addr = start_step * chip->ecc.size;
827 /* If we read not a page aligned data */
828 if (data_col_addr != 0)
829 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
830
831 p = bufpoi + data_col_addr;
832 chip->read_buf(mtd, p, datafrag_len);
833
834 /* Calculate ECC */
835 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size)
836 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]);
837
838 /* The performance is faster if to position offsets
839 according to ecc.pos. Let make sure here that
840 there are no gaps in ecc positions */
841 for (i = 0; i < eccfrag_len - 1; i++) {
842 if (eccpos[i + start_step * chip->ecc.bytes] + 1 !=
843 eccpos[i + start_step * chip->ecc.bytes + 1]) {
844 gaps = 1;
845 break;
846 }
847 }
848 if (gaps) {
849 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
850 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
851 } else {
852 /* send the command to read the particular ecc bytes */
853 /* take care about buswidth alignment in read_buf */
854 aligned_pos = eccpos[start_step * chip->ecc.bytes] & ~(busw - 1);
855 aligned_len = eccfrag_len;
856 if (eccpos[start_step * chip->ecc.bytes] & (busw - 1))
857 aligned_len++;
858 if (eccpos[(start_step + num_steps) * chip->ecc.bytes] & (busw - 1))
859 aligned_len++;
860
861 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize + aligned_pos, -1);
862 chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len);
863 }
864
865 for (i = 0; i < eccfrag_len; i++)
866 chip->buffers->ecccode[i] = chip->oob_poi[eccpos[i + start_step * chip->ecc.bytes]];
867
868 p = bufpoi + data_col_addr;
869 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) {
870 int stat;
871
872 stat = chip->ecc.correct(mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]);
873 if (stat == -1)
874 mtd->ecc_stats.failed++;
875 else
876 mtd->ecc_stats.corrected += stat;
877 }
878 return 0;
879}
880
881/**
801 * nand_read_page_hwecc - [REPLACABLE] hardware ecc based page read function 882 * nand_read_page_hwecc - [REPLACABLE] hardware ecc based page read function
802 * @mtd: mtd info structure 883 * @mtd: mtd info structure
803 * @chip: nand chip info structure 884 * @chip: nand chip info structure
@@ -994,6 +1075,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
994 /* Now read the page into the buffer */ 1075 /* Now read the page into the buffer */
995 if (unlikely(ops->mode == MTD_OOB_RAW)) 1076 if (unlikely(ops->mode == MTD_OOB_RAW))
996 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi); 1077 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi);
1078 else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
1079 ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi);
997 else 1080 else
998 ret = chip->ecc.read_page(mtd, chip, bufpoi); 1081 ret = chip->ecc.read_page(mtd, chip, bufpoi);
999 if (ret < 0) 1082 if (ret < 0)
@@ -1001,7 +1084,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
1001 1084
1002 /* Transfer not aligned data */ 1085 /* Transfer not aligned data */
1003 if (!aligned) { 1086 if (!aligned) {
1004 chip->pagebuf = realpage; 1087 if (!NAND_SUBPAGE_READ(chip) && !oob)
1088 chip->pagebuf = realpage;
1005 memcpy(buf, chip->buffers->databuf + col, bytes); 1089 memcpy(buf, chip->buffers->databuf + col, bytes);
1006 } 1090 }
1007 1091
@@ -2521,6 +2605,7 @@ int nand_scan_tail(struct mtd_info *mtd)
2521 chip->ecc.calculate = nand_calculate_ecc; 2605 chip->ecc.calculate = nand_calculate_ecc;
2522 chip->ecc.correct = nand_correct_data; 2606 chip->ecc.correct = nand_correct_data;
2523 chip->ecc.read_page = nand_read_page_swecc; 2607 chip->ecc.read_page = nand_read_page_swecc;
2608 chip->ecc.read_subpage = nand_read_subpage;
2524 chip->ecc.write_page = nand_write_page_swecc; 2609 chip->ecc.write_page = nand_write_page_swecc;
2525 chip->ecc.read_oob = nand_read_oob_std; 2610 chip->ecc.read_oob = nand_read_oob_std;
2526 chip->ecc.write_oob = nand_write_oob_std; 2611 chip->ecc.write_oob = nand_write_oob_std;
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 5e121ceaa598..0b1c48595f12 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -6,8 +6,6 @@
6 * 6 *
7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) 7 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
8 * 8 *
9 * $Id: nand_bbt.c,v 1.36 2005/11/07 11:14:30 gleixner Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index 9003a135e050..918a806a8471 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -9,8 +9,6 @@
9 * 9 *
10 * Copyright (C) 2006 Thomas Gleixner <tglx@linutronix.de> 10 * Copyright (C) 2006 Thomas Gleixner <tglx@linutronix.de>
11 * 11 *
12 * $Id: nand_ecc.c,v 1.15 2005/11/07 11:14:30 gleixner Exp $
13 *
14 * This file is free software; you can redistribute it and/or modify it 12 * This file is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 or (at your option) any 14 * Free Software Foundation; either version 2 or (at your option) any
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c
index a3e3ab0185d5..69ee2c90eb0b 100644
--- a/drivers/mtd/nand/nand_ids.c
+++ b/drivers/mtd/nand/nand_ids.c
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de) 4 * Copyright (C) 2002 Thomas Gleixner (tglx@linutronix.de)
5 * 5 *
6 * $Id: nand_ids.c,v 1.16 2005/11/07 11:14:31 gleixner Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index bb885d1fcab5..ecd70e2504f6 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -21,8 +21,6 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
24 *
25 * $Id: nandsim.c,v 1.8 2005/03/19 15:33:56 dedekind Exp $
26 */ 24 */
27 25
28#include <linux/init.h> 26#include <linux/init.h>
@@ -39,6 +37,7 @@
39#include <linux/delay.h> 37#include <linux/delay.h>
40#include <linux/list.h> 38#include <linux/list.h>
41#include <linux/random.h> 39#include <linux/random.h>
40#include <asm/div64.h>
42 41
43/* Default simulator parameters values */ 42/* Default simulator parameters values */
44#if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \ 43#if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \
@@ -298,11 +297,11 @@ struct nandsim {
298 297
299 /* NAND flash "geometry" */ 298 /* NAND flash "geometry" */
300 struct nandsin_geometry { 299 struct nandsin_geometry {
301 uint32_t totsz; /* total flash size, bytes */ 300 uint64_t totsz; /* total flash size, bytes */
302 uint32_t secsz; /* flash sector (erase block) size, bytes */ 301 uint32_t secsz; /* flash sector (erase block) size, bytes */
303 uint pgsz; /* NAND flash page size, bytes */ 302 uint pgsz; /* NAND flash page size, bytes */
304 uint oobsz; /* page OOB area size, bytes */ 303 uint oobsz; /* page OOB area size, bytes */
305 uint32_t totszoob; /* total flash size including OOB, bytes */ 304 uint64_t totszoob; /* total flash size including OOB, bytes */
306 uint pgszoob; /* page size including OOB , bytes*/ 305 uint pgszoob; /* page size including OOB , bytes*/
307 uint secszoob; /* sector size including OOB, bytes */ 306 uint secszoob; /* sector size including OOB, bytes */
308 uint pgnum; /* total number of pages */ 307 uint pgnum; /* total number of pages */
@@ -459,6 +458,12 @@ static char *get_partition_name(int i)
459 return kstrdup(buf, GFP_KERNEL); 458 return kstrdup(buf, GFP_KERNEL);
460} 459}
461 460
461static u_int64_t divide(u_int64_t n, u_int32_t d)
462{
463 do_div(n, d);
464 return n;
465}
466
462/* 467/*
463 * Initialize the nandsim structure. 468 * Initialize the nandsim structure.
464 * 469 *
@@ -469,8 +474,8 @@ static int init_nandsim(struct mtd_info *mtd)
469 struct nand_chip *chip = (struct nand_chip *)mtd->priv; 474 struct nand_chip *chip = (struct nand_chip *)mtd->priv;
470 struct nandsim *ns = (struct nandsim *)(chip->priv); 475 struct nandsim *ns = (struct nandsim *)(chip->priv);
471 int i, ret = 0; 476 int i, ret = 0;
472 u_int32_t remains; 477 u_int64_t remains;
473 u_int32_t next_offset; 478 u_int64_t next_offset;
474 479
475 if (NS_IS_INITIALIZED(ns)) { 480 if (NS_IS_INITIALIZED(ns)) {
476 NS_ERR("init_nandsim: nandsim is already initialized\n"); 481 NS_ERR("init_nandsim: nandsim is already initialized\n");
@@ -487,8 +492,8 @@ static int init_nandsim(struct mtd_info *mtd)
487 ns->geom.oobsz = mtd->oobsize; 492 ns->geom.oobsz = mtd->oobsize;
488 ns->geom.secsz = mtd->erasesize; 493 ns->geom.secsz = mtd->erasesize;
489 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; 494 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
490 ns->geom.pgnum = ns->geom.totsz / ns->geom.pgsz; 495 ns->geom.pgnum = divide(ns->geom.totsz, ns->geom.pgsz);
491 ns->geom.totszoob = ns->geom.totsz + ns->geom.pgnum * ns->geom.oobsz; 496 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz;
492 ns->geom.secshift = ffs(ns->geom.secsz) - 1; 497 ns->geom.secshift = ffs(ns->geom.secsz) - 1;
493 ns->geom.pgshift = chip->page_shift; 498 ns->geom.pgshift = chip->page_shift;
494 ns->geom.oobshift = ffs(ns->geom.oobsz) - 1; 499 ns->geom.oobshift = ffs(ns->geom.oobsz) - 1;
@@ -511,7 +516,7 @@ static int init_nandsim(struct mtd_info *mtd)
511 } 516 }
512 517
513 if (ns->options & OPT_SMALLPAGE) { 518 if (ns->options & OPT_SMALLPAGE) {
514 if (ns->geom.totsz < (32 << 20)) { 519 if (ns->geom.totsz <= (32 << 20)) {
515 ns->geom.pgaddrbytes = 3; 520 ns->geom.pgaddrbytes = 3;
516 ns->geom.secaddrbytes = 2; 521 ns->geom.secaddrbytes = 2;
517 } else { 522 } else {
@@ -537,15 +542,16 @@ static int init_nandsim(struct mtd_info *mtd)
537 remains = ns->geom.totsz; 542 remains = ns->geom.totsz;
538 next_offset = 0; 543 next_offset = 0;
539 for (i = 0; i < parts_num; ++i) { 544 for (i = 0; i < parts_num; ++i) {
540 unsigned long part = parts[i]; 545 u_int64_t part_sz = (u_int64_t)parts[i] * ns->geom.secsz;
541 if (!part || part > remains / ns->geom.secsz) { 546
547 if (!part_sz || part_sz > remains) {
542 NS_ERR("bad partition size.\n"); 548 NS_ERR("bad partition size.\n");
543 ret = -EINVAL; 549 ret = -EINVAL;
544 goto error; 550 goto error;
545 } 551 }
546 ns->partitions[i].name = get_partition_name(i); 552 ns->partitions[i].name = get_partition_name(i);
547 ns->partitions[i].offset = next_offset; 553 ns->partitions[i].offset = next_offset;
548 ns->partitions[i].size = part * ns->geom.secsz; 554 ns->partitions[i].size = part_sz;
549 next_offset += ns->partitions[i].size; 555 next_offset += ns->partitions[i].size;
550 remains -= ns->partitions[i].size; 556 remains -= ns->partitions[i].size;
551 } 557 }
@@ -573,7 +579,7 @@ static int init_nandsim(struct mtd_info *mtd)
573 if (ns->busw == 16) 579 if (ns->busw == 16)
574 NS_WARN("16-bit flashes support wasn't tested\n"); 580 NS_WARN("16-bit flashes support wasn't tested\n");
575 581
576 printk("flash size: %u MiB\n", ns->geom.totsz >> 20); 582 printk("flash size: %llu MiB\n", ns->geom.totsz >> 20);
577 printk("page size: %u bytes\n", ns->geom.pgsz); 583 printk("page size: %u bytes\n", ns->geom.pgsz);
578 printk("OOB area size: %u bytes\n", ns->geom.oobsz); 584 printk("OOB area size: %u bytes\n", ns->geom.oobsz);
579 printk("sector size: %u KiB\n", ns->geom.secsz >> 10); 585 printk("sector size: %u KiB\n", ns->geom.secsz >> 10);
@@ -583,7 +589,7 @@ static int init_nandsim(struct mtd_info *mtd)
583 printk("bits in sector size: %u\n", ns->geom.secshift); 589 printk("bits in sector size: %u\n", ns->geom.secshift);
584 printk("bits in page size: %u\n", ns->geom.pgshift); 590 printk("bits in page size: %u\n", ns->geom.pgshift);
585 printk("bits in OOB size: %u\n", ns->geom.oobshift); 591 printk("bits in OOB size: %u\n", ns->geom.oobshift);
586 printk("flash size with OOB: %u KiB\n", ns->geom.totszoob >> 10); 592 printk("flash size with OOB: %llu KiB\n", ns->geom.totszoob >> 10);
587 printk("page address bytes: %u\n", ns->geom.pgaddrbytes); 593 printk("page address bytes: %u\n", ns->geom.pgaddrbytes);
588 printk("sector address bytes: %u\n", ns->geom.secaddrbytes); 594 printk("sector address bytes: %u\n", ns->geom.secaddrbytes);
589 printk("options: %#x\n", ns->options); 595 printk("options: %#x\n", ns->options);
@@ -825,7 +831,7 @@ static int setup_wear_reporting(struct mtd_info *mtd)
825 831
826 if (!rptwear) 832 if (!rptwear)
827 return 0; 833 return 0;
828 wear_eb_count = mtd->size / mtd->erasesize; 834 wear_eb_count = divide(mtd->size, mtd->erasesize);
829 mem = wear_eb_count * sizeof(unsigned long); 835 mem = wear_eb_count * sizeof(unsigned long);
830 if (mem / sizeof(unsigned long) != wear_eb_count) { 836 if (mem / sizeof(unsigned long) != wear_eb_count) {
831 NS_ERR("Too many erase blocks for wear reporting\n"); 837 NS_ERR("Too many erase blocks for wear reporting\n");
@@ -2013,7 +2019,7 @@ static int __init ns_init_module(void)
2013 } 2019 }
2014 2020
2015 if (overridesize) { 2021 if (overridesize) {
2016 u_int32_t new_size = nsmtd->erasesize << overridesize; 2022 u_int64_t new_size = (u_int64_t)nsmtd->erasesize << overridesize;
2017 if (new_size >> overridesize != nsmtd->erasesize) { 2023 if (new_size >> overridesize != nsmtd->erasesize) {
2018 NS_ERR("overridesize is too big\n"); 2024 NS_ERR("overridesize is too big\n");
2019 goto err_exit; 2025 goto err_exit;
@@ -2021,7 +2027,8 @@ static int __init ns_init_module(void)
2021 /* N.B. This relies on nand_scan not doing anything with the size before we change it */ 2027 /* N.B. This relies on nand_scan not doing anything with the size before we change it */
2022 nsmtd->size = new_size; 2028 nsmtd->size = new_size;
2023 chip->chipsize = new_size; 2029 chip->chipsize = new_size;
2024 chip->chip_shift = ffs(new_size) - 1; 2030 chip->chip_shift = ffs(nsmtd->erasesize) + overridesize - 1;
2031 chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
2025 } 2032 }
2026 2033
2027 if ((retval = setup_wear_reporting(nsmtd)) != 0) 2034 if ((retval = setup_wear_reporting(nsmtd)) != 0)
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c
index 082073acf20f..cc8658431851 100644
--- a/drivers/mtd/nand/ppchameleonevb.c
+++ b/drivers/mtd/nand/ppchameleonevb.c
@@ -6,8 +6,6 @@
6 * Derived from drivers/mtd/nand/edb7312.c 6 * Derived from drivers/mtd/nand/edb7312.c
7 * 7 *
8 * 8 *
9 * $Id: ppchameleonevb.c,v 1.7 2005/11/07 11:14:31 gleixner Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 26f88215bc47..a033c4cd8e16 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -6,8 +6,6 @@
6 * Derived from drivers/mtd/nand/spia.c 6 * Derived from drivers/mtd/nand/spia.c
7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 7 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
8 * 8 *
9 * $Id: rtc_from4.c,v 1.10 2005/11/07 11:14:31 gleixner Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index b34a460ab679..556139ed1fdf 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -1,26 +1,10 @@
1/* linux/drivers/mtd/nand/s3c2410.c 1/* linux/drivers/mtd/nand/s3c2410.c
2 * 2 *
3 * Copyright (c) 2004,2005 Simtec Electronics 3 * Copyright © 2004-2008 Simtec Electronics
4 * http://www.simtec.co.uk/products/SWLINUX/ 4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk> 5 * Ben Dooks <ben@simtec.co.uk>
6 * 6 *
7 * Samsung S3C2410/S3C240 NAND driver 7 * Samsung S3C2410/S3C2440/S3C2412 NAND driver
8 *
9 * Changelog:
10 * 21-Sep-2004 BJD Initial version
11 * 23-Sep-2004 BJD Multiple device support
12 * 28-Sep-2004 BJD Fixed ECC placement for Hardware mode
13 * 12-Oct-2004 BJD Fixed errors in use of platform data
14 * 18-Feb-2005 BJD Fix sparse errors
15 * 14-Mar-2005 BJD Applied tglx's code reduction patch
16 * 02-May-2005 BJD Fixed s3c2440 support
17 * 02-May-2005 BJD Reduced hwcontrol decode
18 * 20-Jun-2005 BJD Updated s3c2440 support, fixed timing bug
19 * 08-Jul-2005 BJD Fix OOPS when no platform data supplied
20 * 20-Oct-2005 BJD Fix timing calculation bug
21 * 14-Jan-2006 BJD Allow clock to be stopped when idle
22 *
23 * $Id: s3c2410.c,v 1.23 2006/04/01 18:06:29 bjd Exp $
24 * 8 *
25 * 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
26 * 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
@@ -52,6 +36,7 @@
52#include <linux/err.h> 36#include <linux/err.h>
53#include <linux/slab.h> 37#include <linux/slab.h>
54#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/cpufreq.h>
55 40
56#include <linux/mtd/mtd.h> 41#include <linux/mtd/mtd.h>
57#include <linux/mtd/nand.h> 42#include <linux/mtd/nand.h>
@@ -120,8 +105,13 @@ struct s3c2410_nand_info {
120 int sel_bit; 105 int sel_bit;
121 int mtd_count; 106 int mtd_count;
122 unsigned long save_sel; 107 unsigned long save_sel;
108 unsigned long clk_rate;
123 109
124 enum s3c_cpu_type cpu_type; 110 enum s3c_cpu_type cpu_type;
111
112#ifdef CONFIG_CPU_FREQ
113 struct notifier_block freq_transition;
114#endif
125}; 115};
126 116
127/* conversion functions */ 117/* conversion functions */
@@ -179,17 +169,18 @@ static int s3c_nand_calc_rate(int wanted, unsigned long clk, int max)
179 169
180/* controller setup */ 170/* controller setup */
181 171
182static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 172static int s3c2410_nand_setrate(struct s3c2410_nand_info *info)
183 struct platform_device *pdev)
184{ 173{
185 struct s3c2410_platform_nand *plat = to_nand_plat(pdev); 174 struct s3c2410_platform_nand *plat = info->platform;
186 unsigned long clkrate = clk_get_rate(info->clk);
187 int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4; 175 int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4;
188 int tacls, twrph0, twrph1; 176 int tacls, twrph0, twrph1;
189 unsigned long cfg = 0; 177 unsigned long clkrate = clk_get_rate(info->clk);
178 unsigned long set, cfg, mask;
179 unsigned long flags;
190 180
191 /* calculate the timing information for the controller */ 181 /* calculate the timing information for the controller */
192 182
183 info->clk_rate = clkrate;
193 clkrate /= 1000; /* turn clock into kHz for ease of use */ 184 clkrate /= 1000; /* turn clock into kHz for ease of use */
194 185
195 if (plat != NULL) { 186 if (plat != NULL) {
@@ -211,28 +202,69 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
211 dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", 202 dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
212 tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate)); 203 tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
213 204
205 switch (info->cpu_type) {
206 case TYPE_S3C2410:
207 mask = (S3C2410_NFCONF_TACLS(3) |
208 S3C2410_NFCONF_TWRPH0(7) |
209 S3C2410_NFCONF_TWRPH1(7));
210 set = S3C2410_NFCONF_EN;
211 set |= S3C2410_NFCONF_TACLS(tacls - 1);
212 set |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
213 set |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
214 break;
215
216 case TYPE_S3C2440:
217 case TYPE_S3C2412:
218 mask = (S3C2410_NFCONF_TACLS(tacls_max - 1) |
219 S3C2410_NFCONF_TWRPH0(7) |
220 S3C2410_NFCONF_TWRPH1(7));
221
222 set = S3C2440_NFCONF_TACLS(tacls - 1);
223 set |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
224 set |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
225 break;
226
227 default:
228 /* keep compiler happy */
229 mask = 0;
230 set = 0;
231 BUG();
232 }
233
234 dev_dbg(info->device, "NF_CONF is 0x%lx\n", cfg);
235
236 local_irq_save(flags);
237
238 cfg = readl(info->regs + S3C2410_NFCONF);
239 cfg &= ~mask;
240 cfg |= set;
241 writel(cfg, info->regs + S3C2410_NFCONF);
242
243 local_irq_restore(flags);
244
245 return 0;
246}
247
248static int s3c2410_nand_inithw(struct s3c2410_nand_info *info)
249{
250 int ret;
251
252 ret = s3c2410_nand_setrate(info);
253 if (ret < 0)
254 return ret;
255
214 switch (info->cpu_type) { 256 switch (info->cpu_type) {
215 case TYPE_S3C2410: 257 case TYPE_S3C2410:
216 cfg = S3C2410_NFCONF_EN; 258 default:
217 cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
218 cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
219 cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
220 break; 259 break;
221 260
222 case TYPE_S3C2440: 261 case TYPE_S3C2440:
223 case TYPE_S3C2412: 262 case TYPE_S3C2412:
224 cfg = S3C2440_NFCONF_TACLS(tacls - 1);
225 cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
226 cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
227
228 /* enable the controller and de-assert nFCE */ 263 /* enable the controller and de-assert nFCE */
229 264
230 writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT); 265 writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT);
231 } 266 }
232 267
233 dev_dbg(info->device, "NF_CONF is 0x%lx\n", cfg);
234
235 writel(cfg, info->regs + S3C2410_NFCONF);
236 return 0; 268 return 0;
237} 269}
238 270
@@ -513,6 +545,52 @@ static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int
513 writesl(info->regs + S3C2440_NFDATA, buf, len / 4); 545 writesl(info->regs + S3C2440_NFDATA, buf, len / 4);
514} 546}
515 547
548/* cpufreq driver support */
549
550#ifdef CONFIG_CPU_FREQ
551
552static int s3c2410_nand_cpufreq_transition(struct notifier_block *nb,
553 unsigned long val, void *data)
554{
555 struct s3c2410_nand_info *info;
556 unsigned long newclk;
557
558 info = container_of(nb, struct s3c2410_nand_info, freq_transition);
559 newclk = clk_get_rate(info->clk);
560
561 if ((val == CPUFREQ_POSTCHANGE && newclk < info->clk_rate) ||
562 (val == CPUFREQ_PRECHANGE && newclk > info->clk_rate)) {
563 s3c2410_nand_setrate(info);
564 }
565
566 return 0;
567}
568
569static inline int s3c2410_nand_cpufreq_register(struct s3c2410_nand_info *info)
570{
571 info->freq_transition.notifier_call = s3c2410_nand_cpufreq_transition;
572
573 return cpufreq_register_notifier(&info->freq_transition,
574 CPUFREQ_TRANSITION_NOTIFIER);
575}
576
577static inline void s3c2410_nand_cpufreq_deregister(struct s3c2410_nand_info *info)
578{
579 cpufreq_unregister_notifier(&info->freq_transition,
580 CPUFREQ_TRANSITION_NOTIFIER);
581}
582
583#else
584static inline int s3c2410_nand_cpufreq_register(struct s3c2410_nand_info *info)
585{
586 return 0;
587}
588
589static inline void s3c2410_nand_cpufreq_deregister(struct s3c2410_nand_info *info)
590{
591}
592#endif
593
516/* device management functions */ 594/* device management functions */
517 595
518static int s3c2410_nand_remove(struct platform_device *pdev) 596static int s3c2410_nand_remove(struct platform_device *pdev)
@@ -524,9 +602,10 @@ static int s3c2410_nand_remove(struct platform_device *pdev)
524 if (info == NULL) 602 if (info == NULL)
525 return 0; 603 return 0;
526 604
527 /* first thing we need to do is release all our mtds 605 s3c2410_nand_cpufreq_deregister(info);
528 * and their partitions, then go through freeing the 606
529 * resources used 607 /* Release all our mtds and their partitions, then go through
608 * freeing the resources used
530 */ 609 */
531 610
532 if (info->mtds != NULL) { 611 if (info->mtds != NULL) {
@@ -691,7 +770,8 @@ static void s3c2410_nand_update_chip(struct s3c2410_nand_info *info,
691{ 770{
692 struct nand_chip *chip = &nmtd->chip; 771 struct nand_chip *chip = &nmtd->chip;
693 772
694 printk("%s: chip %p: %d\n", __func__, chip, chip->page_shift); 773 dev_dbg(info->device, "chip %p => page shift %d\n",
774 chip, chip->page_shift);
695 775
696 if (hardware_ecc) { 776 if (hardware_ecc) {
697 /* change the behaviour depending on wether we are using 777 /* change the behaviour depending on wether we are using
@@ -784,7 +864,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
784 864
785 /* initialise the hardware */ 865 /* initialise the hardware */
786 866
787 err = s3c2410_nand_inithw(info, pdev); 867 err = s3c2410_nand_inithw(info);
788 if (err != 0) 868 if (err != 0)
789 goto exit_error; 869 goto exit_error;
790 870
@@ -827,6 +907,12 @@ static int s3c24xx_nand_probe(struct platform_device *pdev,
827 sets++; 907 sets++;
828 } 908 }
829 909
910 err = s3c2410_nand_cpufreq_register(info);
911 if (err < 0) {
912 dev_err(&pdev->dev, "failed to init cpufreq support\n");
913 goto exit_error;
914 }
915
830 if (allow_clk_stop(info)) { 916 if (allow_clk_stop(info)) {
831 dev_info(&pdev->dev, "clock idle support enabled\n"); 917 dev_info(&pdev->dev, "clock idle support enabled\n");
832 clk_disable(info->clk); 918 clk_disable(info->clk);
@@ -874,7 +960,7 @@ static int s3c24xx_nand_resume(struct platform_device *dev)
874 960
875 if (info) { 961 if (info) {
876 clk_enable(info->clk); 962 clk_enable(info->clk);
877 s3c2410_nand_inithw(info, dev); 963 s3c2410_nand_inithw(info);
878 964
879 /* Restore the state of the nFCE line. */ 965 /* Restore the state of the nFCE line. */
880 966
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 033f8800b1e6..6dba2fb66ae5 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2004 Richard Purdie 4 * Copyright (C) 2004 Richard Purdie
5 * 5 *
6 * $Id: sharpsl.c,v 1.7 2005/11/07 11:14:31 gleixner Exp $
7 *
8 * Based on Sharp's NAND driver sharp_sl.c 6 * Based on Sharp's NAND driver sharp_sl.c
9 * 7 *
10 * 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
diff --git a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c
index 1f6d429b1583..0cc6d0acb8fe 100644
--- a/drivers/mtd/nand/spia.c
+++ b/drivers/mtd/nand/spia.c
@@ -8,8 +8,6 @@
8 * to controllines (due to change in nand.c) 8 * to controllines (due to change in nand.c)
9 * page_cache added 9 * page_cache added
10 * 10 *
11 * $Id: spia.c,v 1.25 2005/11/07 11:14:31 gleixner Exp $
12 *
13 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c
index f9e2d4a0ab8c..bbf492e6830d 100644
--- a/drivers/mtd/nand/toto.c
+++ b/drivers/mtd/nand/toto.c
@@ -14,8 +14,6 @@
14 * Overview: 14 * Overview:
15 * This is a device driver for the NAND flash device found on the 15 * This is a device driver for the NAND flash device found on the
16 * TI fido board. It supports 32MiB and 64MiB cards 16 * TI fido board. It supports 32MiB and 64MiB cards
17 *
18 * $Id: toto.c,v 1.5 2005/11/07 11:14:31 gleixner Exp $
19 */ 17 */
20 18
21#include <linux/slab.h> 19#include <linux/slab.h>
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c
index f40081069ab2..807a72752eeb 100644
--- a/drivers/mtd/nand/ts7250.c
+++ b/drivers/mtd/nand/ts7250.c
@@ -9,8 +9,6 @@
9 * Derived from drivers/mtd/nand/autcpu12.c 9 * Derived from drivers/mtd/nand/autcpu12.c
10 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 10 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
11 * 11 *
12 * $Id: ts7250.c,v 1.4 2004/12/30 22:02:07 joff Exp $
13 *
14 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index 0c9ce19ea27a..320b929abe79 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -1,7 +1,6 @@
1/* Linux driver for NAND Flash Translation Layer */ 1/* Linux driver for NAND Flash Translation Layer */
2/* (c) 1999 Machine Vision Holdings, Inc. */ 2/* (c) 1999 Machine Vision Holdings, Inc. */
3/* Author: David Woodhouse <dwmw2@infradead.org> */ 3/* Author: David Woodhouse <dwmw2@infradead.org> */
4/* $Id: nftlcore.c,v 1.98 2005/11/07 11:14:21 gleixner Exp $ */
5 4
6/* 5/*
7 The contents of this file are distributed under the GNU General 6 The contents of this file are distributed under the GNU General
@@ -803,12 +802,8 @@ static struct mtd_blktrans_ops nftl_tr = {
803 .owner = THIS_MODULE, 802 .owner = THIS_MODULE,
804}; 803};
805 804
806extern char nftlmountrev[];
807
808static int __init init_nftl(void) 805static int __init init_nftl(void)
809{ 806{
810 printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.98 $, nftlmount.c %s\n", nftlmountrev);
811
812 return register_mtd_blktrans(&nftl_tr); 807 return register_mtd_blktrans(&nftl_tr);
813} 808}
814 809
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 345e6eff89ce..ccc4f209fbb5 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -4,8 +4,6 @@
4 * Author: Fabrice Bellard (fabrice.bellard@netgem.com) 4 * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
5 * Copyright (C) 2000 Netgem S.A. 5 * Copyright (C) 2000 Netgem S.A.
6 * 6 *
7 * $Id: nftlmount.c,v 1.41 2005/11/07 11:14:21 gleixner Exp $
8 *
9 * 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
10 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
@@ -31,8 +29,6 @@
31 29
32#define SECTORSIZE 512 30#define SECTORSIZE 512
33 31
34char nftlmountrev[]="$Revision: 1.41 $";
35
36/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the 32/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
37 * various device information of the NFTL partition and Bad Unit Table. Update 33 * various device information of the NFTL partition and Bad Unit Table. Update
38 * the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[] 34 * the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[]
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 5d7965f7e9ce..926cf3a4135d 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -325,28 +325,11 @@ static int onenand_wait(struct mtd_info *mtd, int state)
325 325
326 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS); 326 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
327 327
328 if (ctrl & ONENAND_CTRL_ERROR) { 328 /*
329 printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n", ctrl); 329 * In the Spec. it checks the controller status first
330 if (ctrl & ONENAND_CTRL_LOCK) 330 * However if you get the correct information in case of
331 printk(KERN_ERR "onenand_wait: it's locked error.\n"); 331 * power off recovery (POR) test, it should read ECC status first
332 if (state == FL_READING) { 332 */
333 /*
334 * A power loss while writing can result in a page
335 * becoming unreadable. When the device is mounted
336 * again, reading that page gives controller errors.
337 * Upper level software like JFFS2 treat -EIO as fatal,
338 * refusing to mount at all. That means it is necessary
339 * to treat the error as an ECC error to allow recovery.
340 * Note that typically in this case, the eraseblock can
341 * still be erased and rewritten i.e. it has not become
342 * a bad block.
343 */
344 mtd->ecc_stats.failed++;
345 return -EBADMSG;
346 }
347 return -EIO;
348 }
349
350 if (interrupt & ONENAND_INT_READ) { 333 if (interrupt & ONENAND_INT_READ) {
351 int ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS); 334 int ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
352 if (ecc) { 335 if (ecc) {
@@ -364,6 +347,15 @@ static int onenand_wait(struct mtd_info *mtd, int state)
364 return -EIO; 347 return -EIO;
365 } 348 }
366 349
350 /* If there's controller error, it's a real error */
351 if (ctrl & ONENAND_CTRL_ERROR) {
352 printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n",
353 ctrl);
354 if (ctrl & ONENAND_CTRL_LOCK)
355 printk(KERN_ERR "onenand_wait: it's locked error.\n");
356 return -EIO;
357 }
358
367 return 0; 359 return 0;
368} 360}
369 361
@@ -1135,22 +1127,26 @@ static int onenand_bbt_wait(struct mtd_info *mtd, int state)
1135 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT); 1127 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1136 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS); 1128 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
1137 1129
1138 /* Initial bad block case: 0x2400 or 0x0400 */
1139 if (ctrl & ONENAND_CTRL_ERROR) {
1140 printk(KERN_DEBUG "onenand_bbt_wait: controller error = 0x%04x\n", ctrl);
1141 return ONENAND_BBT_READ_ERROR;
1142 }
1143
1144 if (interrupt & ONENAND_INT_READ) { 1130 if (interrupt & ONENAND_INT_READ) {
1145 int ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS); 1131 int ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS);
1146 if (ecc & ONENAND_ECC_2BIT_ALL) 1132 if (ecc & ONENAND_ECC_2BIT_ALL) {
1133 printk(KERN_INFO "onenand_bbt_wait: ecc error = 0x%04x"
1134 ", controller error 0x%04x\n", ecc, ctrl);
1147 return ONENAND_BBT_READ_ERROR; 1135 return ONENAND_BBT_READ_ERROR;
1136 }
1148 } else { 1137 } else {
1149 printk(KERN_ERR "onenand_bbt_wait: read timeout!" 1138 printk(KERN_ERR "onenand_bbt_wait: read timeout!"
1150 "ctrl=0x%04x intr=0x%04x\n", ctrl, interrupt); 1139 "ctrl=0x%04x intr=0x%04x\n", ctrl, interrupt);
1151 return ONENAND_BBT_READ_FATAL_ERROR; 1140 return ONENAND_BBT_READ_FATAL_ERROR;
1152 } 1141 }
1153 1142
1143 /* Initial bad block case: 0x2400 or 0x0400 */
1144 if (ctrl & ONENAND_CTRL_ERROR) {
1145 printk(KERN_DEBUG "onenand_bbt_wait: "
1146 "controller error = 0x%04x\n", ctrl);
1147 return ONENAND_BBT_READ_ERROR;
1148 }
1149
1154 return 0; 1150 return 0;
1155} 1151}
1156 1152
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index c5030f94f04e..2d600a1bf2aa 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: redboot.c,v 1.21 2006/03/30 18:34:37 bjd Exp $
3 *
4 * Parse RedBoot-style Flash Image System (FIS) tables and 2 * Parse RedBoot-style Flash Image System (FIS) tables and
5 * produce a Linux partition array to match. 3 * produce a Linux partition array to match.
6 */ 4 */
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index c84e45465499..e538c0a72abb 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2005 Sean Young <sean@mess.org> 4 * Copyright (C) 2005 Sean Young <sean@mess.org>
5 * 5 *
6 * $Id: rfd_ftl.c,v 1.8 2006/01/15 12:51:44 sean Exp $
7 *
8 * This type of flash translation layer (FTL) is used by the Embedded BIOS 6 * This type of flash translation layer (FTL) is used by the Embedded BIOS
9 * by General Software. It is known as the Resident Flash Disk (RFD), see: 7 * by General Software. It is known as the Resident Flash Disk (RFD), see:
10 * 8 *
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 7a14980f3472..18d3eeb7eab2 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -482,7 +482,7 @@ static int ep93xx_alloc_buffers(struct ep93xx_priv *ep)
482 goto err; 482 goto err;
483 483
484 d = dma_map_single(NULL, page, PAGE_SIZE, DMA_FROM_DEVICE); 484 d = dma_map_single(NULL, page, PAGE_SIZE, DMA_FROM_DEVICE);
485 if (dma_mapping_error(d)) { 485 if (dma_mapping_error(NULL, d)) {
486 free_page((unsigned long)page); 486 free_page((unsigned long)page);
487 goto err; 487 goto err;
488 } 488 }
@@ -505,7 +505,7 @@ static int ep93xx_alloc_buffers(struct ep93xx_priv *ep)
505 goto err; 505 goto err;
506 506
507 d = dma_map_single(NULL, page, PAGE_SIZE, DMA_TO_DEVICE); 507 d = dma_map_single(NULL, page, PAGE_SIZE, DMA_TO_DEVICE);
508 if (dma_mapping_error(d)) { 508 if (dma_mapping_error(NULL, d)) {
509 free_page((unsigned long)page); 509 free_page((unsigned long)page);
510 goto err; 510 goto err;
511 } 511 }
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 0263bef9cc6d..af251a5df844 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -814,7 +814,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fastpath *fp,
814 } 814 }
815 815
816 /* release skb */ 816 /* release skb */
817 BUG_TRAP(skb); 817 WARN_ON(!skb);
818 dev_kfree_skb(skb); 818 dev_kfree_skb(skb);
819 tx_buf->first_bd = 0; 819 tx_buf->first_bd = 0;
820 tx_buf->skb = NULL; 820 tx_buf->skb = NULL;
@@ -837,9 +837,9 @@ static inline u16 bnx2x_tx_avail(struct bnx2x_fastpath *fp)
837 used = SUB_S16(prod, cons) + (s16)NUM_TX_RINGS; 837 used = SUB_S16(prod, cons) + (s16)NUM_TX_RINGS;
838 838
839#ifdef BNX2X_STOP_ON_ERROR 839#ifdef BNX2X_STOP_ON_ERROR
840 BUG_TRAP(used >= 0); 840 WARN_ON(used < 0);
841 BUG_TRAP(used <= fp->bp->tx_ring_size); 841 WARN_ON(used > fp->bp->tx_ring_size);
842 BUG_TRAP((fp->bp->tx_ring_size - used) <= MAX_TX_AVAIL); 842 WARN_ON((fp->bp->tx_ring_size - used) > MAX_TX_AVAIL);
843#endif 843#endif
844 844
845 return (s16)(fp->bp->tx_ring_size) - used; 845 return (s16)(fp->bp->tx_ring_size) - used;
@@ -1020,7 +1020,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
1020 1020
1021 mapping = pci_map_page(bp->pdev, page, 0, BCM_PAGE_SIZE*PAGES_PER_SGE, 1021 mapping = pci_map_page(bp->pdev, page, 0, BCM_PAGE_SIZE*PAGES_PER_SGE,
1022 PCI_DMA_FROMDEVICE); 1022 PCI_DMA_FROMDEVICE);
1023 if (unlikely(dma_mapping_error(mapping))) { 1023 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
1024 __free_pages(page, PAGES_PER_SGE_SHIFT); 1024 __free_pages(page, PAGES_PER_SGE_SHIFT);
1025 return -ENOMEM; 1025 return -ENOMEM;
1026 } 1026 }
@@ -1048,7 +1048,7 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp,
1048 1048
1049 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, 1049 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
1050 PCI_DMA_FROMDEVICE); 1050 PCI_DMA_FROMDEVICE);
1051 if (unlikely(dma_mapping_error(mapping))) { 1051 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
1052 dev_kfree_skb(skb); 1052 dev_kfree_skb(skb);
1053 return -ENOMEM; 1053 return -ENOMEM;
1054 } 1054 }
@@ -4374,7 +4374,7 @@ static void bnx2x_init_rx_rings(struct bnx2x *bp)
4374 } 4374 }
4375 ring_prod = NEXT_RX_IDX(ring_prod); 4375 ring_prod = NEXT_RX_IDX(ring_prod);
4376 cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod); 4376 cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod);
4377 BUG_TRAP(ring_prod > i); 4377 WARN_ON(ring_prod <= i);
4378 } 4378 }
4379 4379
4380 fp->rx_bd_prod = ring_prod; 4380 fp->rx_bd_prod = ring_prod;
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 83768df27806..f1936d51b458 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -576,6 +576,18 @@ static void cas_spare_recover(struct cas *cp, const gfp_t flags)
576 list_for_each_safe(elem, tmp, &list) { 576 list_for_each_safe(elem, tmp, &list) {
577 cas_page_t *page = list_entry(elem, cas_page_t, list); 577 cas_page_t *page = list_entry(elem, cas_page_t, list);
578 578
579 /*
580 * With the lockless pagecache, cassini buffering scheme gets
581 * slightly less accurate: we might find that a page has an
582 * elevated reference count here, due to a speculative ref,
583 * and skip it as in-use. Ideally we would be able to reclaim
584 * it. However this would be such a rare case, it doesn't
585 * matter too much as we should pick it up the next time round.
586 *
587 * Importantly, if we find that the page has a refcount of 1
588 * here (our refcount), then we know it is definitely not inuse
589 * so we can reuse it.
590 */
579 if (page_count(page->buffer) > 1) 591 if (page_count(page->buffer) > 1)
580 continue; 592 continue;
581 593
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index a96331c875e6..1b0861d73ab7 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -386,7 +386,7 @@ static inline int add_one_rx_buf(void *va, unsigned int len,
386 dma_addr_t mapping; 386 dma_addr_t mapping;
387 387
388 mapping = pci_map_single(pdev, va, len, PCI_DMA_FROMDEVICE); 388 mapping = pci_map_single(pdev, va, len, PCI_DMA_FROMDEVICE);
389 if (unlikely(pci_dma_mapping_error(mapping))) 389 if (unlikely(pci_dma_mapping_error(pdev, mapping)))
390 return -ENOMEM; 390 return -ENOMEM;
391 391
392 pci_unmap_addr_set(sd, dma_addr, mapping); 392 pci_unmap_addr_set(sd, dma_addr, mapping);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 1037b1332312..19d32a227be1 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1790,7 +1790,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1790 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data, 1790 rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
1791 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1791 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1792 1792
1793 if (pci_dma_mapping_error(rx->dma_addr)) { 1793 if (pci_dma_mapping_error(nic->pdev, rx->dma_addr)) {
1794 dev_kfree_skb_any(rx->skb); 1794 dev_kfree_skb_any(rx->skb);
1795 rx->skb = NULL; 1795 rx->skb = NULL;
1796 rx->dma_addr = 0; 1796 rx->dma_addr = 0;
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index a14561f40db0..9350564065e7 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1090,7 +1090,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1090 tx_ring->buffer_info[i].dma = 1090 tx_ring->buffer_info[i].dma =
1091 pci_map_single(pdev, skb->data, skb->len, 1091 pci_map_single(pdev, skb->data, skb->len,
1092 PCI_DMA_TODEVICE); 1092 PCI_DMA_TODEVICE);
1093 if (pci_dma_mapping_error(tx_ring->buffer_info[i].dma)) { 1093 if (pci_dma_mapping_error(pdev, tx_ring->buffer_info[i].dma)) {
1094 ret_val = 4; 1094 ret_val = 4;
1095 goto err_nomem; 1095 goto err_nomem;
1096 } 1096 }
@@ -1153,7 +1153,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1153 rx_ring->buffer_info[i].dma = 1153 rx_ring->buffer_info[i].dma =
1154 pci_map_single(pdev, skb->data, 2048, 1154 pci_map_single(pdev, skb->data, 2048,
1155 PCI_DMA_FROMDEVICE); 1155 PCI_DMA_FROMDEVICE);
1156 if (pci_dma_mapping_error(rx_ring->buffer_info[i].dma)) { 1156 if (pci_dma_mapping_error(pdev, rx_ring->buffer_info[i].dma)) {
1157 ret_val = 8; 1157 ret_val = 8;
1158 goto err_nomem; 1158 goto err_nomem;
1159 } 1159 }
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 9c0f56b3c518..d13677899767 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -195,7 +195,7 @@ map_skb:
195 buffer_info->dma = pci_map_single(pdev, skb->data, 195 buffer_info->dma = pci_map_single(pdev, skb->data,
196 adapter->rx_buffer_len, 196 adapter->rx_buffer_len,
197 PCI_DMA_FROMDEVICE); 197 PCI_DMA_FROMDEVICE);
198 if (pci_dma_mapping_error(buffer_info->dma)) { 198 if (pci_dma_mapping_error(pdev, buffer_info->dma)) {
199 dev_err(&pdev->dev, "RX DMA map failed\n"); 199 dev_err(&pdev->dev, "RX DMA map failed\n");
200 adapter->rx_dma_failed++; 200 adapter->rx_dma_failed++;
201 break; 201 break;
@@ -265,7 +265,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
265 ps_page->page, 265 ps_page->page,
266 0, PAGE_SIZE, 266 0, PAGE_SIZE,
267 PCI_DMA_FROMDEVICE); 267 PCI_DMA_FROMDEVICE);
268 if (pci_dma_mapping_error(ps_page->dma)) { 268 if (pci_dma_mapping_error(pdev, ps_page->dma)) {
269 dev_err(&adapter->pdev->dev, 269 dev_err(&adapter->pdev->dev,
270 "RX DMA page map failed\n"); 270 "RX DMA page map failed\n");
271 adapter->rx_dma_failed++; 271 adapter->rx_dma_failed++;
@@ -300,7 +300,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
300 buffer_info->dma = pci_map_single(pdev, skb->data, 300 buffer_info->dma = pci_map_single(pdev, skb->data,
301 adapter->rx_ps_bsize0, 301 adapter->rx_ps_bsize0,
302 PCI_DMA_FROMDEVICE); 302 PCI_DMA_FROMDEVICE);
303 if (pci_dma_mapping_error(buffer_info->dma)) { 303 if (pci_dma_mapping_error(pdev, buffer_info->dma)) {
304 dev_err(&pdev->dev, "RX DMA map failed\n"); 304 dev_err(&pdev->dev, "RX DMA map failed\n");
305 adapter->rx_dma_failed++; 305 adapter->rx_dma_failed++;
306 /* cleanup skb */ 306 /* cleanup skb */
@@ -3344,7 +3344,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
3344 skb->data + offset, 3344 skb->data + offset,
3345 size, 3345 size,
3346 PCI_DMA_TODEVICE); 3346 PCI_DMA_TODEVICE);
3347 if (pci_dma_mapping_error(buffer_info->dma)) { 3347 if (pci_dma_mapping_error(adapter->pdev, buffer_info->dma)) {
3348 dev_err(&adapter->pdev->dev, "TX DMA map failed\n"); 3348 dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
3349 adapter->tx_dma_failed++; 3349 adapter->tx_dma_failed++;
3350 return -1; 3350 return -1;
@@ -3382,7 +3382,8 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
3382 offset, 3382 offset,
3383 size, 3383 size,
3384 PCI_DMA_TODEVICE); 3384 PCI_DMA_TODEVICE);
3385 if (pci_dma_mapping_error(buffer_info->dma)) { 3385 if (pci_dma_mapping_error(adapter->pdev,
3386 buffer_info->dma)) {
3386 dev_err(&adapter->pdev->dev, 3387 dev_err(&adapter->pdev->dev,
3387 "TX DMA page map failed\n"); 3388 "TX DMA page map failed\n");
3388 adapter->tx_dma_failed++; 3389 adapter->tx_dma_failed++;
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index e5a6e2e84540..a03fe1fb61ca 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -260,7 +260,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
260 dma_addr = dma_map_single(&adapter->vdev->dev, skb->data, 260 dma_addr = dma_map_single(&adapter->vdev->dev, skb->data,
261 pool->buff_size, DMA_FROM_DEVICE); 261 pool->buff_size, DMA_FROM_DEVICE);
262 262
263 if (dma_mapping_error(dma_addr)) 263 if (dma_mapping_error(&adapter->vdev->dev, dma_addr))
264 goto failure; 264 goto failure;
265 265
266 pool->free_map[free_index] = IBM_VETH_INVALID_MAP; 266 pool->free_map[free_index] = IBM_VETH_INVALID_MAP;
@@ -294,7 +294,7 @@ failure:
294 pool->consumer_index = pool->size - 1; 294 pool->consumer_index = pool->size - 1;
295 else 295 else
296 pool->consumer_index--; 296 pool->consumer_index--;
297 if (!dma_mapping_error(dma_addr)) 297 if (!dma_mapping_error(&adapter->vdev->dev, dma_addr))
298 dma_unmap_single(&adapter->vdev->dev, 298 dma_unmap_single(&adapter->vdev->dev,
299 pool->dma_addr[index], pool->buff_size, 299 pool->dma_addr[index], pool->buff_size,
300 DMA_FROM_DEVICE); 300 DMA_FROM_DEVICE);
@@ -448,11 +448,11 @@ static void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter)
448static void ibmveth_cleanup(struct ibmveth_adapter *adapter) 448static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
449{ 449{
450 int i; 450 int i;
451 struct device *dev = &adapter->vdev->dev;
451 452
452 if(adapter->buffer_list_addr != NULL) { 453 if(adapter->buffer_list_addr != NULL) {
453 if(!dma_mapping_error(adapter->buffer_list_dma)) { 454 if (!dma_mapping_error(dev, adapter->buffer_list_dma)) {
454 dma_unmap_single(&adapter->vdev->dev, 455 dma_unmap_single(dev, adapter->buffer_list_dma, 4096,
455 adapter->buffer_list_dma, 4096,
456 DMA_BIDIRECTIONAL); 456 DMA_BIDIRECTIONAL);
457 adapter->buffer_list_dma = DMA_ERROR_CODE; 457 adapter->buffer_list_dma = DMA_ERROR_CODE;
458 } 458 }
@@ -461,9 +461,8 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
461 } 461 }
462 462
463 if(adapter->filter_list_addr != NULL) { 463 if(adapter->filter_list_addr != NULL) {
464 if(!dma_mapping_error(adapter->filter_list_dma)) { 464 if (!dma_mapping_error(dev, adapter->filter_list_dma)) {
465 dma_unmap_single(&adapter->vdev->dev, 465 dma_unmap_single(dev, adapter->filter_list_dma, 4096,
466 adapter->filter_list_dma, 4096,
467 DMA_BIDIRECTIONAL); 466 DMA_BIDIRECTIONAL);
468 adapter->filter_list_dma = DMA_ERROR_CODE; 467 adapter->filter_list_dma = DMA_ERROR_CODE;
469 } 468 }
@@ -472,8 +471,8 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
472 } 471 }
473 472
474 if(adapter->rx_queue.queue_addr != NULL) { 473 if(adapter->rx_queue.queue_addr != NULL) {
475 if(!dma_mapping_error(adapter->rx_queue.queue_dma)) { 474 if (!dma_mapping_error(dev, adapter->rx_queue.queue_dma)) {
476 dma_unmap_single(&adapter->vdev->dev, 475 dma_unmap_single(dev,
477 adapter->rx_queue.queue_dma, 476 adapter->rx_queue.queue_dma,
478 adapter->rx_queue.queue_len, 477 adapter->rx_queue.queue_len,
479 DMA_BIDIRECTIONAL); 478 DMA_BIDIRECTIONAL);
@@ -489,7 +488,7 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
489 &adapter->rx_buff_pool[i]); 488 &adapter->rx_buff_pool[i]);
490 489
491 if (adapter->bounce_buffer != NULL) { 490 if (adapter->bounce_buffer != NULL) {
492 if (!dma_mapping_error(adapter->bounce_buffer_dma)) { 491 if (!dma_mapping_error(dev, adapter->bounce_buffer_dma)) {
493 dma_unmap_single(&adapter->vdev->dev, 492 dma_unmap_single(&adapter->vdev->dev,
494 adapter->bounce_buffer_dma, 493 adapter->bounce_buffer_dma,
495 adapter->netdev->mtu + IBMVETH_BUFF_OH, 494 adapter->netdev->mtu + IBMVETH_BUFF_OH,
@@ -535,6 +534,7 @@ static int ibmveth_open(struct net_device *netdev)
535 int rc; 534 int rc;
536 union ibmveth_buf_desc rxq_desc; 535 union ibmveth_buf_desc rxq_desc;
537 int i; 536 int i;
537 struct device *dev;
538 538
539 ibmveth_debug_printk("open starting\n"); 539 ibmveth_debug_printk("open starting\n");
540 540
@@ -563,17 +563,19 @@ static int ibmveth_open(struct net_device *netdev)
563 return -ENOMEM; 563 return -ENOMEM;
564 } 564 }
565 565
566 adapter->buffer_list_dma = dma_map_single(&adapter->vdev->dev, 566 dev = &adapter->vdev->dev;
567
568 adapter->buffer_list_dma = dma_map_single(dev,
567 adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL); 569 adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL);
568 adapter->filter_list_dma = dma_map_single(&adapter->vdev->dev, 570 adapter->filter_list_dma = dma_map_single(dev,
569 adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL); 571 adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL);
570 adapter->rx_queue.queue_dma = dma_map_single(&adapter->vdev->dev, 572 adapter->rx_queue.queue_dma = dma_map_single(dev,
571 adapter->rx_queue.queue_addr, 573 adapter->rx_queue.queue_addr,
572 adapter->rx_queue.queue_len, DMA_BIDIRECTIONAL); 574 adapter->rx_queue.queue_len, DMA_BIDIRECTIONAL);
573 575
574 if((dma_mapping_error(adapter->buffer_list_dma) ) || 576 if ((dma_mapping_error(dev, adapter->buffer_list_dma)) ||
575 (dma_mapping_error(adapter->filter_list_dma)) || 577 (dma_mapping_error(dev, adapter->filter_list_dma)) ||
576 (dma_mapping_error(adapter->rx_queue.queue_dma))) { 578 (dma_mapping_error(dev, adapter->rx_queue.queue_dma))) {
577 ibmveth_error_printk("unable to map filter or buffer list pages\n"); 579 ibmveth_error_printk("unable to map filter or buffer list pages\n");
578 ibmveth_cleanup(adapter); 580 ibmveth_cleanup(adapter);
579 napi_disable(&adapter->napi); 581 napi_disable(&adapter->napi);
@@ -645,7 +647,7 @@ static int ibmveth_open(struct net_device *netdev)
645 adapter->bounce_buffer_dma = 647 adapter->bounce_buffer_dma =
646 dma_map_single(&adapter->vdev->dev, adapter->bounce_buffer, 648 dma_map_single(&adapter->vdev->dev, adapter->bounce_buffer,
647 netdev->mtu + IBMVETH_BUFF_OH, DMA_BIDIRECTIONAL); 649 netdev->mtu + IBMVETH_BUFF_OH, DMA_BIDIRECTIONAL);
648 if (dma_mapping_error(adapter->bounce_buffer_dma)) { 650 if (dma_mapping_error(dev, adapter->bounce_buffer_dma)) {
649 ibmveth_error_printk("unable to map bounce buffer\n"); 651 ibmveth_error_printk("unable to map bounce buffer\n");
650 ibmveth_cleanup(adapter); 652 ibmveth_cleanup(adapter);
651 napi_disable(&adapter->napi); 653 napi_disable(&adapter->napi);
@@ -922,7 +924,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
922 buf[1] = 0; 924 buf[1] = 0;
923 } 925 }
924 926
925 if (dma_mapping_error(data_dma_addr)) { 927 if (dma_mapping_error(&adapter->vdev->dev, data_dma_addr)) {
926 if (!firmware_has_feature(FW_FEATURE_CMO)) 928 if (!firmware_has_feature(FW_FEATURE_CMO))
927 ibmveth_error_printk("tx: unable to map xmit buffer\n"); 929 ibmveth_error_printk("tx: unable to map xmit buffer\n");
928 skb_copy_from_linear_data(skb, adapter->bounce_buffer, 930 skb_copy_from_linear_data(skb, adapter->bounce_buffer,
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index b8d0639c1cdf..c46864d626b2 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -1128,7 +1128,7 @@ static int veth_transmit_to_one(struct sk_buff *skb, HvLpIndex rlp,
1128 msg->data.addr[0] = dma_map_single(port->dev, skb->data, 1128 msg->data.addr[0] = dma_map_single(port->dev, skb->data,
1129 skb->len, DMA_TO_DEVICE); 1129 skb->len, DMA_TO_DEVICE);
1130 1130
1131 if (dma_mapping_error(msg->data.addr[0])) 1131 if (dma_mapping_error(port->dev, msg->data.addr[0]))
1132 goto recycle_and_drop; 1132 goto recycle_and_drop;
1133 1133
1134 msg->dev = port->dev; 1134 msg->dev = port->dev;
@@ -1226,7 +1226,7 @@ static void veth_recycle_msg(struct veth_lpar_connection *cnx,
1226 dma_address = msg->data.addr[0]; 1226 dma_address = msg->data.addr[0];
1227 dma_length = msg->data.len[0]; 1227 dma_length = msg->data.len[0];
1228 1228
1229 if (!dma_mapping_error(dma_address)) 1229 if (!dma_mapping_error(msg->dev, dma_address))
1230 dma_unmap_single(msg->dev, dma_address, dma_length, 1230 dma_unmap_single(msg->dev, dma_address, dma_length,
1231 DMA_TO_DEVICE); 1231 DMA_TO_DEVICE);
1232 1232
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c
index f9d6b4dca180..096bca54bcf7 100644
--- a/drivers/net/mlx4/alloc.c
+++ b/drivers/net/mlx4/alloc.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/mlx4/catas.c b/drivers/net/mlx4/catas.c
index aa9528779044..f094ee00c416 100644
--- a/drivers/net/mlx4/catas.c
+++ b/drivers/net/mlx4/catas.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/mlx4/cmd.c b/drivers/net/mlx4/cmd.c
index 04d5bc69a6f8..2845a0560b84 100644
--- a/drivers/net/mlx4/cmd.c
+++ b/drivers/net/mlx4/cmd.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/cq.c b/drivers/net/mlx4/cq.c
index 95e87a2f8896..9bb50e3f8974 100644
--- a/drivers/net/mlx4/cq.c
+++ b/drivers/net/mlx4/cq.c
@@ -2,7 +2,7 @@
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 5 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
7 * 7 *
8 * This software is available to you under a choice of one of two 8 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c
index ea3a09aaa844..8a8b56135a58 100644
--- a/drivers/net/mlx4/eq.c
+++ b/drivers/net/mlx4/eq.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
@@ -526,7 +526,7 @@ int mlx4_map_eq_icm(struct mlx4_dev *dev, u64 icm_virt)
526 return -ENOMEM; 526 return -ENOMEM;
527 priv->eq_table.icm_dma = pci_map_page(dev->pdev, priv->eq_table.icm_page, 0, 527 priv->eq_table.icm_dma = pci_map_page(dev->pdev, priv->eq_table.icm_page, 0,
528 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); 528 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
529 if (pci_dma_mapping_error(priv->eq_table.icm_dma)) { 529 if (pci_dma_mapping_error(dev->pdev, priv->eq_table.icm_dma)) {
530 __free_page(priv->eq_table.icm_page); 530 __free_page(priv->eq_table.icm_page);
531 return -ENOMEM; 531 return -ENOMEM;
532 } 532 }
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index 57278224ba1e..7e32955da982 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/fw.h b/drivers/net/mlx4/fw.h
index fbf0e22be122..decbb5c2ad41 100644
--- a/drivers/net/mlx4/fw.h
+++ b/drivers/net/mlx4/fw.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved. 4 * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c
index 2a5bef6388fe..baf4bf66062c 100644
--- a/drivers/net/mlx4/icm.c
+++ b/drivers/net/mlx4/icm.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/icm.h b/drivers/net/mlx4/icm.h
index 6c44edf35847..ab56a2f89b65 100644
--- a/drivers/net/mlx4/icm.h
+++ b/drivers/net/mlx4/icm.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 2 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/intf.c b/drivers/net/mlx4/intf.c
index 4a6c4d526f1b..0e7eb1038f9f 100644
--- a/drivers/net/mlx4/intf.c
+++ b/drivers/net/mlx4/intf.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 8e1d24cda1b0..1252a919de2e 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 5 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
6 * 6 *
7 * This software is available to you under a choice of one of two 7 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/mcg.c b/drivers/net/mlx4/mcg.c
index b4b57870ddfd..c83f88ce0736 100644
--- a/drivers/net/mlx4/mcg.c
+++ b/drivers/net/mlx4/mcg.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
index 78038499cff5..5337e3ac3e78 100644
--- a/drivers/net/mlx4/mlx4.h
+++ b/drivers/net/mlx4/mlx4.h
@@ -2,7 +2,7 @@
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 3 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
4 * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
5 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 5 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 6 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
7 * 7 *
8 * This software is available to you under a choice of one of two 8 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index a3c04c5f12c2..62071d9c4a55 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 4 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
5 * 5 *
6 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index ee5484c44a18..c49a86044bf7 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2004 Voltaire, Inc. All rights reserved. 5 * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
6 * 6 *
7 * This software is available to you under a choice of one of two 7 * This software is available to you under a choice of one of two
diff --git a/drivers/net/mlx4/reset.c b/drivers/net/mlx4/reset.c
index e199715fabd0..3951b884c0fb 100644
--- a/drivers/net/mlx4/reset.c
+++ b/drivers/net/mlx4/reset.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/mlx4/srq.c b/drivers/net/mlx4/srq.c
index d23f46d692ef..533eb6db24b3 100644
--- a/drivers/net/mlx4/srq.c
+++ b/drivers/net/mlx4/srq.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. 2 * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
3 * 4 *
4 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 6 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 993d87c9296f..edc0fd588985 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -650,7 +650,7 @@ static void pasemi_mac_replenish_rx_ring(const struct net_device *dev,
650 mac->bufsz - LOCAL_SKB_ALIGN, 650 mac->bufsz - LOCAL_SKB_ALIGN,
651 PCI_DMA_FROMDEVICE); 651 PCI_DMA_FROMDEVICE);
652 652
653 if (unlikely(dma_mapping_error(dma))) { 653 if (unlikely(pci_dma_mapping_error(mac->dma_pdev, dma))) {
654 dev_kfree_skb_irq(info->skb); 654 dev_kfree_skb_irq(info->skb);
655 break; 655 break;
656 } 656 }
@@ -1519,7 +1519,7 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1519 map[0] = pci_map_single(mac->dma_pdev, skb->data, skb_headlen(skb), 1519 map[0] = pci_map_single(mac->dma_pdev, skb->data, skb_headlen(skb),
1520 PCI_DMA_TODEVICE); 1520 PCI_DMA_TODEVICE);
1521 map_size[0] = skb_headlen(skb); 1521 map_size[0] = skb_headlen(skb);
1522 if (dma_mapping_error(map[0])) 1522 if (pci_dma_mapping_error(mac->dma_pdev, map[0]))
1523 goto out_err_nolock; 1523 goto out_err_nolock;
1524 1524
1525 for (i = 0; i < nfrags; i++) { 1525 for (i = 0; i < nfrags; i++) {
@@ -1529,7 +1529,7 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1529 frag->page_offset, frag->size, 1529 frag->page_offset, frag->size,
1530 PCI_DMA_TODEVICE); 1530 PCI_DMA_TODEVICE);
1531 map_size[i+1] = frag->size; 1531 map_size[i+1] = frag->size;
1532 if (dma_mapping_error(map[i+1])) { 1532 if (pci_dma_mapping_error(mac->dma_pdev, map[i+1])) {
1533 nfrags = i; 1533 nfrags = i;
1534 goto out_err_nolock; 1534 goto out_err_nolock;
1535 } 1535 }
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 739b3ab7bccc..ddccc074a76a 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -581,12 +581,12 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
581 if (file == ppp->owner) 581 if (file == ppp->owner)
582 ppp_shutdown_interface(ppp); 582 ppp_shutdown_interface(ppp);
583 } 583 }
584 if (atomic_read(&file->f_count) <= 2) { 584 if (atomic_long_read(&file->f_count) <= 2) {
585 ppp_release(NULL, file); 585 ppp_release(NULL, file);
586 err = 0; 586 err = 0;
587 } else 587 } else
588 printk(KERN_DEBUG "PPPIOCDETACH file->f_count=%d\n", 588 printk(KERN_DEBUG "PPPIOCDETACH file->f_count=%ld\n",
589 atomic_read(&file->f_count)); 589 atomic_long_read(&file->f_count));
590 unlock_kernel(); 590 unlock_kernel();
591 return err; 591 return err;
592 } 592 }
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index e7d48a352beb..e82b37bbd6c3 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -328,7 +328,7 @@ static void ql_release_to_lrg_buf_free_list(struct ql3_adapter *qdev,
328 qdev->lrg_buffer_len - 328 qdev->lrg_buffer_len -
329 QL_HEADER_SPACE, 329 QL_HEADER_SPACE,
330 PCI_DMA_FROMDEVICE); 330 PCI_DMA_FROMDEVICE);
331 err = pci_dma_mapping_error(map); 331 err = pci_dma_mapping_error(qdev->pdev, map);
332 if(err) { 332 if(err) {
333 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 333 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n",
334 qdev->ndev->name, err); 334 qdev->ndev->name, err);
@@ -1919,7 +1919,7 @@ static int ql_populate_free_queue(struct ql3_adapter *qdev)
1919 QL_HEADER_SPACE, 1919 QL_HEADER_SPACE,
1920 PCI_DMA_FROMDEVICE); 1920 PCI_DMA_FROMDEVICE);
1921 1921
1922 err = pci_dma_mapping_error(map); 1922 err = pci_dma_mapping_error(qdev->pdev, map);
1923 if(err) { 1923 if(err) {
1924 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 1924 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n",
1925 qdev->ndev->name, err); 1925 qdev->ndev->name, err);
@@ -2454,7 +2454,7 @@ static int ql_send_map(struct ql3_adapter *qdev,
2454 */ 2454 */
2455 map = pci_map_single(qdev->pdev, skb->data, len, PCI_DMA_TODEVICE); 2455 map = pci_map_single(qdev->pdev, skb->data, len, PCI_DMA_TODEVICE);
2456 2456
2457 err = pci_dma_mapping_error(map); 2457 err = pci_dma_mapping_error(qdev->pdev, map);
2458 if(err) { 2458 if(err) {
2459 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 2459 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n",
2460 qdev->ndev->name, err); 2460 qdev->ndev->name, err);
@@ -2487,7 +2487,7 @@ static int ql_send_map(struct ql3_adapter *qdev,
2487 sizeof(struct oal), 2487 sizeof(struct oal),
2488 PCI_DMA_TODEVICE); 2488 PCI_DMA_TODEVICE);
2489 2489
2490 err = pci_dma_mapping_error(map); 2490 err = pci_dma_mapping_error(qdev->pdev, map);
2491 if(err) { 2491 if(err) {
2492 2492
2493 printk(KERN_ERR "%s: PCI mapping outbound address list with error: %d\n", 2493 printk(KERN_ERR "%s: PCI mapping outbound address list with error: %d\n",
@@ -2514,7 +2514,7 @@ static int ql_send_map(struct ql3_adapter *qdev,
2514 frag->page_offset, frag->size, 2514 frag->page_offset, frag->size,
2515 PCI_DMA_TODEVICE); 2515 PCI_DMA_TODEVICE);
2516 2516
2517 err = pci_dma_mapping_error(map); 2517 err = pci_dma_mapping_error(qdev->pdev, map);
2518 if(err) { 2518 if(err) {
2519 printk(KERN_ERR "%s: PCI mapping frags failed with error: %d\n", 2519 printk(KERN_ERR "%s: PCI mapping frags failed with error: %d\n",
2520 qdev->ndev->name, err); 2520 qdev->ndev->name, err);
@@ -2916,7 +2916,7 @@ static int ql_alloc_large_buffers(struct ql3_adapter *qdev)
2916 QL_HEADER_SPACE, 2916 QL_HEADER_SPACE,
2917 PCI_DMA_FROMDEVICE); 2917 PCI_DMA_FROMDEVICE);
2918 2918
2919 err = pci_dma_mapping_error(map); 2919 err = pci_dma_mapping_error(qdev->pdev, map);
2920 if(err) { 2920 if(err) {
2921 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n", 2921 printk(KERN_ERR "%s: PCI mapping failed with error: %d\n",
2922 qdev->ndev->name, err); 2922 qdev->ndev->name, err);
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 9dae40ccf048..86d77d05190a 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2512,8 +2512,8 @@ static void stop_nic(struct s2io_nic *nic)
2512 * Return Value: 2512 * Return Value:
2513 * SUCCESS on success or an appropriate -ve value on failure. 2513 * SUCCESS on success or an appropriate -ve value on failure.
2514 */ 2514 */
2515 2515static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring,
2516static int fill_rx_buffers(struct ring_info *ring, int from_card_up) 2516 int from_card_up)
2517{ 2517{
2518 struct sk_buff *skb; 2518 struct sk_buff *skb;
2519 struct RxD_t *rxdp; 2519 struct RxD_t *rxdp;
@@ -2602,7 +2602,8 @@ static int fill_rx_buffers(struct ring_info *ring, int from_card_up)
2602 rxdp1->Buffer0_ptr = pci_map_single 2602 rxdp1->Buffer0_ptr = pci_map_single
2603 (ring->pdev, skb->data, size - NET_IP_ALIGN, 2603 (ring->pdev, skb->data, size - NET_IP_ALIGN,
2604 PCI_DMA_FROMDEVICE); 2604 PCI_DMA_FROMDEVICE);
2605 if(pci_dma_mapping_error(rxdp1->Buffer0_ptr)) 2605 if (pci_dma_mapping_error(nic->pdev,
2606 rxdp1->Buffer0_ptr))
2606 goto pci_map_failed; 2607 goto pci_map_failed;
2607 2608
2608 rxdp->Control_2 = 2609 rxdp->Control_2 =
@@ -2636,7 +2637,8 @@ static int fill_rx_buffers(struct ring_info *ring, int from_card_up)
2636 rxdp3->Buffer0_ptr = 2637 rxdp3->Buffer0_ptr =
2637 pci_map_single(ring->pdev, ba->ba_0, 2638 pci_map_single(ring->pdev, ba->ba_0,
2638 BUF0_LEN, PCI_DMA_FROMDEVICE); 2639 BUF0_LEN, PCI_DMA_FROMDEVICE);
2639 if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) 2640 if (pci_dma_mapping_error(nic->pdev,
2641 rxdp3->Buffer0_ptr))
2640 goto pci_map_failed; 2642 goto pci_map_failed;
2641 } else 2643 } else
2642 pci_dma_sync_single_for_device(ring->pdev, 2644 pci_dma_sync_single_for_device(ring->pdev,
@@ -2655,7 +2657,8 @@ static int fill_rx_buffers(struct ring_info *ring, int from_card_up)
2655 (ring->pdev, skb->data, ring->mtu + 4, 2657 (ring->pdev, skb->data, ring->mtu + 4,
2656 PCI_DMA_FROMDEVICE); 2658 PCI_DMA_FROMDEVICE);
2657 2659
2658 if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) 2660 if (pci_dma_mapping_error(nic->pdev,
2661 rxdp3->Buffer2_ptr))
2659 goto pci_map_failed; 2662 goto pci_map_failed;
2660 2663
2661 if (from_card_up) { 2664 if (from_card_up) {
@@ -2664,8 +2667,8 @@ static int fill_rx_buffers(struct ring_info *ring, int from_card_up)
2664 ba->ba_1, BUF1_LEN, 2667 ba->ba_1, BUF1_LEN,
2665 PCI_DMA_FROMDEVICE); 2668 PCI_DMA_FROMDEVICE);
2666 2669
2667 if (pci_dma_mapping_error 2670 if (pci_dma_mapping_error(nic->pdev,
2668 (rxdp3->Buffer1_ptr)) { 2671 rxdp3->Buffer1_ptr)) {
2669 pci_unmap_single 2672 pci_unmap_single
2670 (ring->pdev, 2673 (ring->pdev,
2671 (dma_addr_t)(unsigned long) 2674 (dma_addr_t)(unsigned long)
@@ -2806,9 +2809,9 @@ static void free_rx_buffers(struct s2io_nic *sp)
2806 } 2809 }
2807} 2810}
2808 2811
2809static int s2io_chk_rx_buffers(struct ring_info *ring) 2812static int s2io_chk_rx_buffers(struct s2io_nic *nic, struct ring_info *ring)
2810{ 2813{
2811 if (fill_rx_buffers(ring, 0) == -ENOMEM) { 2814 if (fill_rx_buffers(nic, ring, 0) == -ENOMEM) {
2812 DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name); 2815 DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name);
2813 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n"); 2816 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
2814 } 2817 }
@@ -2848,7 +2851,7 @@ static int s2io_poll_msix(struct napi_struct *napi, int budget)
2848 return 0; 2851 return 0;
2849 2852
2850 pkts_processed = rx_intr_handler(ring, budget); 2853 pkts_processed = rx_intr_handler(ring, budget);
2851 s2io_chk_rx_buffers(ring); 2854 s2io_chk_rx_buffers(nic, ring);
2852 2855
2853 if (pkts_processed < budget_org) { 2856 if (pkts_processed < budget_org) {
2854 netif_rx_complete(dev, napi); 2857 netif_rx_complete(dev, napi);
@@ -2882,7 +2885,7 @@ static int s2io_poll_inta(struct napi_struct *napi, int budget)
2882 for (i = 0; i < config->rx_ring_num; i++) { 2885 for (i = 0; i < config->rx_ring_num; i++) {
2883 ring = &mac_control->rings[i]; 2886 ring = &mac_control->rings[i];
2884 ring_pkts_processed = rx_intr_handler(ring, budget); 2887 ring_pkts_processed = rx_intr_handler(ring, budget);
2885 s2io_chk_rx_buffers(ring); 2888 s2io_chk_rx_buffers(nic, ring);
2886 pkts_processed += ring_pkts_processed; 2889 pkts_processed += ring_pkts_processed;
2887 budget -= ring_pkts_processed; 2890 budget -= ring_pkts_processed;
2888 if (budget <= 0) 2891 if (budget <= 0)
@@ -2939,7 +2942,8 @@ static void s2io_netpoll(struct net_device *dev)
2939 rx_intr_handler(&mac_control->rings[i], 0); 2942 rx_intr_handler(&mac_control->rings[i], 0);
2940 2943
2941 for (i = 0; i < config->rx_ring_num; i++) { 2944 for (i = 0; i < config->rx_ring_num; i++) {
2942 if (fill_rx_buffers(&mac_control->rings[i], 0) == -ENOMEM) { 2945 if (fill_rx_buffers(nic, &mac_control->rings[i], 0) ==
2946 -ENOMEM) {
2943 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2947 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name);
2944 DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n"); 2948 DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n");
2945 break; 2949 break;
@@ -4235,14 +4239,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4235 txdp->Buffer_Pointer = pci_map_single(sp->pdev, 4239 txdp->Buffer_Pointer = pci_map_single(sp->pdev,
4236 fifo->ufo_in_band_v, 4240 fifo->ufo_in_band_v,
4237 sizeof(u64), PCI_DMA_TODEVICE); 4241 sizeof(u64), PCI_DMA_TODEVICE);
4238 if (pci_dma_mapping_error(txdp->Buffer_Pointer)) 4242 if (pci_dma_mapping_error(sp->pdev, txdp->Buffer_Pointer))
4239 goto pci_map_failed; 4243 goto pci_map_failed;
4240 txdp++; 4244 txdp++;
4241 } 4245 }
4242 4246
4243 txdp->Buffer_Pointer = pci_map_single 4247 txdp->Buffer_Pointer = pci_map_single
4244 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); 4248 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
4245 if (pci_dma_mapping_error(txdp->Buffer_Pointer)) 4249 if (pci_dma_mapping_error(sp->pdev, txdp->Buffer_Pointer))
4246 goto pci_map_failed; 4250 goto pci_map_failed;
4247 4251
4248 txdp->Host_Control = (unsigned long) skb; 4252 txdp->Host_Control = (unsigned long) skb;
@@ -4345,7 +4349,7 @@ static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id)
4345 netif_rx_schedule(dev, &ring->napi); 4349 netif_rx_schedule(dev, &ring->napi);
4346 } else { 4350 } else {
4347 rx_intr_handler(ring, 0); 4351 rx_intr_handler(ring, 0);
4348 s2io_chk_rx_buffers(ring); 4352 s2io_chk_rx_buffers(sp, ring);
4349 } 4353 }
4350 4354
4351 return IRQ_HANDLED; 4355 return IRQ_HANDLED;
@@ -4826,7 +4830,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id)
4826 */ 4830 */
4827 if (!config->napi) { 4831 if (!config->napi) {
4828 for (i = 0; i < config->rx_ring_num; i++) 4832 for (i = 0; i < config->rx_ring_num; i++)
4829 s2io_chk_rx_buffers(&mac_control->rings[i]); 4833 s2io_chk_rx_buffers(sp, &mac_control->rings[i]);
4830 } 4834 }
4831 writeq(sp->general_int_mask, &bar0->general_int_mask); 4835 writeq(sp->general_int_mask, &bar0->general_int_mask);
4832 readl(&bar0->general_int_status); 4836 readl(&bar0->general_int_status);
@@ -6859,7 +6863,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6859 pci_map_single( sp->pdev, (*skb)->data, 6863 pci_map_single( sp->pdev, (*skb)->data,
6860 size - NET_IP_ALIGN, 6864 size - NET_IP_ALIGN,
6861 PCI_DMA_FROMDEVICE); 6865 PCI_DMA_FROMDEVICE);
6862 if (pci_dma_mapping_error(rxdp1->Buffer0_ptr)) 6866 if (pci_dma_mapping_error(sp->pdev, rxdp1->Buffer0_ptr))
6863 goto memalloc_failed; 6867 goto memalloc_failed;
6864 rxdp->Host_Control = (unsigned long) (*skb); 6868 rxdp->Host_Control = (unsigned long) (*skb);
6865 } 6869 }
@@ -6886,12 +6890,13 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6886 pci_map_single(sp->pdev, (*skb)->data, 6890 pci_map_single(sp->pdev, (*skb)->data,
6887 dev->mtu + 4, 6891 dev->mtu + 4,
6888 PCI_DMA_FROMDEVICE); 6892 PCI_DMA_FROMDEVICE);
6889 if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) 6893 if (pci_dma_mapping_error(sp->pdev, rxdp3->Buffer2_ptr))
6890 goto memalloc_failed; 6894 goto memalloc_failed;
6891 rxdp3->Buffer0_ptr = *temp0 = 6895 rxdp3->Buffer0_ptr = *temp0 =
6892 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN, 6896 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN,
6893 PCI_DMA_FROMDEVICE); 6897 PCI_DMA_FROMDEVICE);
6894 if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) { 6898 if (pci_dma_mapping_error(sp->pdev,
6899 rxdp3->Buffer0_ptr)) {
6895 pci_unmap_single (sp->pdev, 6900 pci_unmap_single (sp->pdev,
6896 (dma_addr_t)rxdp3->Buffer2_ptr, 6901 (dma_addr_t)rxdp3->Buffer2_ptr,
6897 dev->mtu + 4, PCI_DMA_FROMDEVICE); 6902 dev->mtu + 4, PCI_DMA_FROMDEVICE);
@@ -6903,7 +6908,8 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6903 rxdp3->Buffer1_ptr = *temp1 = 6908 rxdp3->Buffer1_ptr = *temp1 =
6904 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, 6909 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN,
6905 PCI_DMA_FROMDEVICE); 6910 PCI_DMA_FROMDEVICE);
6906 if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) { 6911 if (pci_dma_mapping_error(sp->pdev,
6912 rxdp3->Buffer1_ptr)) {
6907 pci_unmap_single (sp->pdev, 6913 pci_unmap_single (sp->pdev,
6908 (dma_addr_t)rxdp3->Buffer0_ptr, 6914 (dma_addr_t)rxdp3->Buffer0_ptr,
6909 BUF0_LEN, PCI_DMA_FROMDEVICE); 6915 BUF0_LEN, PCI_DMA_FROMDEVICE);
@@ -7187,7 +7193,7 @@ static int s2io_card_up(struct s2io_nic * sp)
7187 7193
7188 for (i = 0; i < config->rx_ring_num; i++) { 7194 for (i = 0; i < config->rx_ring_num; i++) {
7189 mac_control->rings[i].mtu = dev->mtu; 7195 mac_control->rings[i].mtu = dev->mtu;
7190 ret = fill_rx_buffers(&mac_control->rings[i], 1); 7196 ret = fill_rx_buffers(sp, &mac_control->rings[i], 1);
7191 if (ret) { 7197 if (ret) {
7192 DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n", 7198 DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n",
7193 dev->name); 7199 dev->name);
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 601b001437c0..0d27dd39bc09 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -233,7 +233,7 @@ static inline int efx_init_rx_buffer_skb(struct efx_rx_queue *rx_queue,
233 rx_buf->data, rx_buf->len, 233 rx_buf->data, rx_buf->len,
234 PCI_DMA_FROMDEVICE); 234 PCI_DMA_FROMDEVICE);
235 235
236 if (unlikely(pci_dma_mapping_error(rx_buf->dma_addr))) { 236 if (unlikely(pci_dma_mapping_error(efx->pci_dev, rx_buf->dma_addr))) {
237 dev_kfree_skb_any(rx_buf->skb); 237 dev_kfree_skb_any(rx_buf->skb);
238 rx_buf->skb = NULL; 238 rx_buf->skb = NULL;
239 return -EIO; 239 return -EIO;
@@ -275,7 +275,7 @@ static inline int efx_init_rx_buffer_page(struct efx_rx_queue *rx_queue,
275 0, efx_rx_buf_size(efx), 275 0, efx_rx_buf_size(efx),
276 PCI_DMA_FROMDEVICE); 276 PCI_DMA_FROMDEVICE);
277 277
278 if (unlikely(pci_dma_mapping_error(dma_addr))) { 278 if (unlikely(pci_dma_mapping_error(efx->pci_dev, dma_addr))) {
279 __free_pages(rx_buf->page, efx->rx_buffer_order); 279 __free_pages(rx_buf->page, efx->rx_buffer_order);
280 rx_buf->page = NULL; 280 rx_buf->page = NULL;
281 return -EIO; 281 return -EIO;
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index 5cdd082ab8f6..5e8374ab28ee 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -172,7 +172,7 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
172 172
173 /* Process all fragments */ 173 /* Process all fragments */
174 while (1) { 174 while (1) {
175 if (unlikely(pci_dma_mapping_error(dma_addr))) 175 if (unlikely(pci_dma_mapping_error(pci_dev, dma_addr)))
176 goto pci_err; 176 goto pci_err;
177 177
178 /* Store fields for marking in the per-fragment final 178 /* Store fields for marking in the per-fragment final
@@ -661,7 +661,8 @@ efx_tsoh_heap_alloc(struct efx_tx_queue *tx_queue, size_t header_len)
661 tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev, 661 tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev,
662 TSOH_BUFFER(tsoh), header_len, 662 TSOH_BUFFER(tsoh), header_len,
663 PCI_DMA_TODEVICE); 663 PCI_DMA_TODEVICE);
664 if (unlikely(pci_dma_mapping_error(tsoh->dma_addr))) { 664 if (unlikely(pci_dma_mapping_error(tx_queue->efx->pci_dev,
665 tsoh->dma_addr))) {
665 kfree(tsoh); 666 kfree(tsoh);
666 return NULL; 667 return NULL;
667 } 668 }
@@ -863,7 +864,7 @@ static inline int tso_get_fragment(struct tso_state *st, struct efx_nic *efx,
863 864
864 st->ifc.unmap_addr = pci_map_page(efx->pci_dev, page, page_off, 865 st->ifc.unmap_addr = pci_map_page(efx->pci_dev, page, page_off,
865 len, PCI_DMA_TODEVICE); 866 len, PCI_DMA_TODEVICE);
866 if (likely(!pci_dma_mapping_error(st->ifc.unmap_addr))) { 867 if (likely(!pci_dma_mapping_error(efx->pci_dev, st->ifc.unmap_addr))) {
867 st->ifc.unmap_len = len; 868 st->ifc.unmap_len = len;
868 st->ifc.len = len; 869 st->ifc.len = len;
869 st->ifc.dma_addr = st->ifc.unmap_addr; 870 st->ifc.dma_addr = st->ifc.unmap_addr;
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 00aa0b108cb9..b6435d0d71f9 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -452,7 +452,7 @@ spider_net_prepare_rx_descr(struct spider_net_card *card,
452 /* iommu-map the skb */ 452 /* iommu-map the skb */
453 buf = pci_map_single(card->pdev, descr->skb->data, 453 buf = pci_map_single(card->pdev, descr->skb->data,
454 SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); 454 SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
455 if (pci_dma_mapping_error(buf)) { 455 if (pci_dma_mapping_error(card->pdev, buf)) {
456 dev_kfree_skb_any(descr->skb); 456 dev_kfree_skb_any(descr->skb);
457 descr->skb = NULL; 457 descr->skb = NULL;
458 if (netif_msg_rx_err(card) && net_ratelimit()) 458 if (netif_msg_rx_err(card) && net_ratelimit())
@@ -691,7 +691,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
691 unsigned long flags; 691 unsigned long flags;
692 692
693 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); 693 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
694 if (pci_dma_mapping_error(buf)) { 694 if (pci_dma_mapping_error(card->pdev, buf)) {
695 if (netif_msg_tx_err(card) && net_ratelimit()) 695 if (netif_msg_tx_err(card) && net_ratelimit())
696 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " 696 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). "
697 "Dropping packet\n", skb->data, skb->len); 697 "Dropping packet\n", skb->data, skb->len);
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index a645e5028c14..8487ace9d2e3 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -506,7 +506,7 @@ static void *alloc_rxbuf_page(struct pci_dev *hwdev, dma_addr_t *dma_handle)
506 return NULL; 506 return NULL;
507 *dma_handle = pci_map_single(hwdev, buf, PAGE_SIZE, 507 *dma_handle = pci_map_single(hwdev, buf, PAGE_SIZE,
508 PCI_DMA_FROMDEVICE); 508 PCI_DMA_FROMDEVICE);
509 if (pci_dma_mapping_error(*dma_handle)) { 509 if (pci_dma_mapping_error(hwdev, *dma_handle)) {
510 free_page((unsigned long)buf); 510 free_page((unsigned long)buf);
511 return NULL; 511 return NULL;
512 } 512 }
@@ -536,7 +536,7 @@ static struct sk_buff *alloc_rxbuf_skb(struct net_device *dev,
536 return NULL; 536 return NULL;
537 *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE, 537 *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE,
538 PCI_DMA_FROMDEVICE); 538 PCI_DMA_FROMDEVICE);
539 if (pci_dma_mapping_error(*dma_handle)) { 539 if (pci_dma_mapping_error(hwdev, *dma_handle)) {
540 dev_kfree_skb_any(skb); 540 dev_kfree_skb_any(skb);
541 return NULL; 541 return NULL;
542 } 542 }
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 217d506527a9..d9769c527346 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -1166,7 +1166,7 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1166 bf->skb = skb; 1166 bf->skb = skb;
1167 bf->skbaddr = pci_map_single(sc->pdev, 1167 bf->skbaddr = pci_map_single(sc->pdev,
1168 skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE); 1168 skb->data, sc->rxbufsize, PCI_DMA_FROMDEVICE);
1169 if (unlikely(pci_dma_mapping_error(bf->skbaddr))) { 1169 if (unlikely(pci_dma_mapping_error(sc->pdev, bf->skbaddr))) {
1170 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__); 1170 ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__);
1171 dev_kfree_skb(skb); 1171 dev_kfree_skb(skb);
1172 bf->skb = NULL; 1172 bf->skb = NULL;
@@ -1918,7 +1918,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1918 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] " 1918 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] "
1919 "skbaddr %llx\n", skb, skb->data, skb->len, 1919 "skbaddr %llx\n", skb, skb->data, skb->len,
1920 (unsigned long long)bf->skbaddr); 1920 (unsigned long long)bf->skbaddr);
1921 if (pci_dma_mapping_error(bf->skbaddr)) { 1921 if (pci_dma_mapping_error(sc->pdev, bf->skbaddr)) {
1922 ATH5K_ERR(sc, "beacon DMA mapping failed\n"); 1922 ATH5K_ERR(sc, "beacon DMA mapping failed\n");
1923 return -EIO; 1923 return -EIO;
1924 } 1924 }
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 1d7ec3129349..f821dbc952a4 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -13,3 +13,9 @@ config OF_I2C
13 depends on PPC_OF && I2C 13 depends on PPC_OF && I2C
14 help 14 help
15 OpenFirmware I2C accessors 15 OpenFirmware I2C accessors
16
17config OF_SPI
18 def_tristate SPI
19 depends on OF && PPC_OF && SPI
20 help
21 OpenFirmware SPI accessors
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 548772e871fd..4c3c6f8e36f5 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -2,3 +2,4 @@ obj-y = base.o
2obj-$(CONFIG_OF_DEVICE) += device.o platform.o 2obj-$(CONFIG_OF_DEVICE) += device.o platform.o
3obj-$(CONFIG_OF_GPIO) += gpio.o 3obj-$(CONFIG_OF_GPIO) += gpio.o
4obj-$(CONFIG_OF_I2C) += of_i2c.o 4obj-$(CONFIG_OF_I2C) += of_i2c.o
5obj-$(CONFIG_OF_SPI) += of_spi.o
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 23ffb7c0caf2..ad8ac1a8af28 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -385,3 +385,91 @@ struct device_node *of_find_matching_node(struct device_node *from,
385 return np; 385 return np;
386} 386}
387EXPORT_SYMBOL(of_find_matching_node); 387EXPORT_SYMBOL(of_find_matching_node);
388
389/**
390 * of_modalias_table: Table of explicit compatible ==> modalias mappings
391 *
392 * This table allows particulare compatible property values to be mapped
393 * to modalias strings. This is useful for busses which do not directly
394 * understand the OF device tree but are populated based on data contained
395 * within the device tree. SPI and I2C are the two current users of this
396 * table.
397 *
398 * In most cases, devices do not need to be listed in this table because
399 * the modalias value can be derived directly from the compatible table.
400 * However, if for any reason a value cannot be derived, then this table
401 * provides a method to override the implicit derivation.
402 *
403 * At the moment, a single table is used for all bus types because it is
404 * assumed that the data size is small and that the compatible values
405 * should already be distinct enough to differentiate between SPI, I2C
406 * and other devices.
407 */
408struct of_modalias_table {
409 char *of_device;
410 char *modalias;
411};
412static struct of_modalias_table of_modalias_table[] = {
413 /* Empty for now; add entries as needed */
414};
415
416/**
417 * of_modalias_node - Lookup appropriate modalias for a device node
418 * @node: pointer to a device tree node
419 * @modalias: Pointer to buffer that modalias value will be copied into
420 * @len: Length of modalias value
421 *
422 * Based on the value of the compatible property, this routine will determine
423 * an appropriate modalias value for a particular device tree node. Three
424 * separate methods are used to derive a modalias value.
425 *
426 * First method is to lookup the compatible value in of_modalias_table.
427 * Second is to look for a "linux,<modalias>" entry in the compatible list
428 * and used that for modalias. Third is to strip off the manufacturer
429 * prefix from the first compatible entry and use the remainder as modalias
430 *
431 * This routine returns 0 on success
432 */
433int of_modalias_node(struct device_node *node, char *modalias, int len)
434{
435 int i, cplen;
436 const char *compatible;
437 const char *p;
438
439 /* 1. search for exception list entry */
440 for (i = 0; i < ARRAY_SIZE(of_modalias_table); i++) {
441 compatible = of_modalias_table[i].of_device;
442 if (!of_device_is_compatible(node, compatible))
443 continue;
444 strlcpy(modalias, of_modalias_table[i].modalias, len);
445 return 0;
446 }
447
448 compatible = of_get_property(node, "compatible", &cplen);
449 if (!compatible)
450 return -ENODEV;
451
452 /* 2. search for linux,<modalias> entry */
453 p = compatible;
454 while (cplen > 0) {
455 if (!strncmp(p, "linux,", 6)) {
456 p += 6;
457 strlcpy(modalias, p, len);
458 return 0;
459 }
460
461 i = strlen(p) + 1;
462 p += i;
463 cplen -= i;
464 }
465
466 /* 3. take first compatible entry and strip manufacturer */
467 p = strchr(compatible, ',');
468 if (!p)
469 return -ENODEV;
470 p++;
471 strlcpy(modalias, p, len);
472 return 0;
473}
474EXPORT_SYMBOL_GPL(of_modalias_node);
475
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index 344e1b03dd8b..6a98dc8aa30b 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -16,62 +16,6 @@
16#include <linux/of_i2c.h> 16#include <linux/of_i2c.h>
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19struct i2c_driver_device {
20 char *of_device;
21 char *i2c_type;
22};
23
24static struct i2c_driver_device i2c_devices[] = {
25};
26
27static int of_find_i2c_driver(struct device_node *node,
28 struct i2c_board_info *info)
29{
30 int i, cplen;
31 const char *compatible;
32 const char *p;
33
34 /* 1. search for exception list entry */
35 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
36 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
37 continue;
38 if (strlcpy(info->type, i2c_devices[i].i2c_type,
39 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
40 return -ENOMEM;
41
42 return 0;
43 }
44
45 compatible = of_get_property(node, "compatible", &cplen);
46 if (!compatible)
47 return -ENODEV;
48
49 /* 2. search for linux,<i2c-type> entry */
50 p = compatible;
51 while (cplen > 0) {
52 if (!strncmp(p, "linux,", 6)) {
53 p += 6;
54 if (strlcpy(info->type, p,
55 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
56 return -ENOMEM;
57 return 0;
58 }
59
60 i = strlen(p) + 1;
61 p += i;
62 cplen -= i;
63 }
64
65 /* 3. take fist compatible entry and strip manufacturer */
66 p = strchr(compatible, ',');
67 if (!p)
68 return -ENODEV;
69 p++;
70 if (strlcpy(info->type, p, I2C_NAME_SIZE) >= I2C_NAME_SIZE)
71 return -ENOMEM;
72 return 0;
73}
74
75void of_register_i2c_devices(struct i2c_adapter *adap, 19void of_register_i2c_devices(struct i2c_adapter *adap,
76 struct device_node *adap_node) 20 struct device_node *adap_node)
77{ 21{
@@ -83,6 +27,9 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
83 const u32 *addr; 27 const u32 *addr;
84 int len; 28 int len;
85 29
30 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0)
31 continue;
32
86 addr = of_get_property(node, "reg", &len); 33 addr = of_get_property(node, "reg", &len);
87 if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { 34 if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
88 printk(KERN_ERR 35 printk(KERN_ERR
@@ -92,11 +39,6 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
92 39
93 info.irq = irq_of_parse_and_map(node, 0); 40 info.irq = irq_of_parse_and_map(node, 0);
94 41
95 if (of_find_i2c_driver(node, &info) < 0) {
96 irq_dispose_mapping(info.irq);
97 continue;
98 }
99
100 info.addr = *addr; 42 info.addr = *addr;
101 43
102 request_module(info.type); 44 request_module(info.type);
diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c
new file mode 100644
index 000000000000..b01eec026f68
--- /dev/null
+++ b/drivers/of/of_spi.c
@@ -0,0 +1,93 @@
1/*
2 * SPI OF support routines
3 * Copyright (C) 2008 Secret Lab Technologies Ltd.
4 *
5 * Support routines for deriving SPI device attachments from the device
6 * tree.
7 */
8
9#include <linux/of.h>
10#include <linux/device.h>
11#include <linux/spi/spi.h>
12#include <linux/of_spi.h>
13
14/**
15 * of_register_spi_devices - Register child devices onto the SPI bus
16 * @master: Pointer to spi_master device
17 * @np: parent node of SPI device nodes
18 *
19 * Registers an spi_device for each child node of 'np' which has a 'reg'
20 * property.
21 */
22void of_register_spi_devices(struct spi_master *master, struct device_node *np)
23{
24 struct spi_device *spi;
25 struct device_node *nc;
26 const u32 *prop;
27 int rc;
28 int len;
29
30 for_each_child_of_node(np, nc) {
31 /* Alloc an spi_device */
32 spi = spi_alloc_device(master);
33 if (!spi) {
34 dev_err(&master->dev, "spi_device alloc error for %s\n",
35 nc->full_name);
36 spi_dev_put(spi);
37 continue;
38 }
39
40 /* Select device driver */
41 if (of_modalias_node(nc, spi->modalias,
42 sizeof(spi->modalias)) < 0) {
43 dev_err(&master->dev, "cannot find modalias for %s\n",
44 nc->full_name);
45 spi_dev_put(spi);
46 continue;
47 }
48
49 /* Device address */
50 prop = of_get_property(nc, "reg", &len);
51 if (!prop || len < sizeof(*prop)) {
52 dev_err(&master->dev, "%s has no 'reg' property\n",
53 nc->full_name);
54 spi_dev_put(spi);
55 continue;
56 }
57 spi->chip_select = *prop;
58
59 /* Mode (clock phase/polarity/etc.) */
60 if (of_find_property(nc, "spi-cpha", NULL))
61 spi->mode |= SPI_CPHA;
62 if (of_find_property(nc, "spi-cpol", NULL))
63 spi->mode |= SPI_CPOL;
64
65 /* Device speed */
66 prop = of_get_property(nc, "spi-max-frequency", &len);
67 if (!prop || len < sizeof(*prop)) {
68 dev_err(&master->dev, "%s has no 'spi-max-frequency' property\n",
69 nc->full_name);
70 spi_dev_put(spi);
71 continue;
72 }
73 spi->max_speed_hz = *prop;
74
75 /* IRQ */
76 spi->irq = irq_of_parse_and_map(nc, 0);
77
78 /* Store a pointer to the node in the device structure */
79 of_node_get(nc);
80 spi->dev.archdata.of_node = nc;
81
82 /* Register the new device */
83 request_module(spi->modalias);
84 rc = spi_add_device(spi);
85 if (rc) {
86 dev_err(&master->dev, "spi_device register error %s\n",
87 nc->full_name);
88 spi_dev_put(spi);
89 }
90
91 }
92}
93EXPORT_SYMBOL(of_register_spi_devices);
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 0338b0912674..e97059415ab4 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -199,8 +199,6 @@ int parport_wait_peripheral(struct parport *port,
199 /* 40ms of slow polling. */ 199 /* 40ms of slow polling. */
200 deadline = jiffies + msecs_to_jiffies(40); 200 deadline = jiffies + msecs_to_jiffies(40);
201 while (time_before (jiffies, deadline)) { 201 while (time_before (jiffies, deadline)) {
202 int ret;
203
204 if (signal_pending (current)) 202 if (signal_pending (current))
205 return -EINTR; 203 return -EINTR;
206 204
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 802a81d47367..00e1d9620f7c 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -235,7 +235,7 @@ failed:
235 235
236======================================================================*/ 236======================================================================*/
237 237
238void parport_cs_release(struct pcmcia_device *link) 238static void parport_cs_release(struct pcmcia_device *link)
239{ 239{
240 parport_info_t *info = link->priv; 240 parport_info_t *info = link->priv;
241 241
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index e0c2a4584ec6..8a846adf1dcf 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -2867,7 +2867,7 @@ static struct parport_pc_pci {
2867 * and 840 locks up if you write 1 to bit 2! */ 2867 * and 840 locks up if you write 1 to bit 2! */
2868 /* oxsemi_952 */ { 1, { { 0, 1 }, } }, 2868 /* oxsemi_952 */ { 1, { { 0, 1 }, } },
2869 /* oxsemi_954 */ { 1, { { 0, -1 }, } }, 2869 /* oxsemi_954 */ { 1, { { 0, -1 }, } },
2870 /* oxsemi_840 */ { 1, { { 0, -1 }, } }, 2870 /* oxsemi_840 */ { 1, { { 0, 1 }, } },
2871 /* aks_0100 */ { 1, { { 0, -1 }, } }, 2871 /* aks_0100 */ { 1, { { 0, -1 }, } },
2872 /* mobility_pp */ { 1, { { 0, 1 }, } }, 2872 /* mobility_pp */ { 1, { { 0, 1 }, } },
2873 /* netmos_9705 */ { 1, { { 0, -1 }, } }, /* untested */ 2873 /* netmos_9705 */ { 1, { { 0, -1 }, } }, /* untested */
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index d950fc34320a..554e11f9e1ce 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -429,9 +429,6 @@ struct parport_default_sysctl_table
429 ctl_table dev_dir[2]; 429 ctl_table dev_dir[2];
430}; 430};
431 431
432extern unsigned long parport_default_timeslice;
433extern int parport_default_spintime;
434
435static struct parport_default_sysctl_table 432static struct parport_default_sysctl_table
436parport_default_sysctl_table = { 433parport_default_sysctl_table = {
437 .sysctl_header = NULL, 434 .sysctl_header = NULL,
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 1323a43285d7..ad27e9e225a6 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1103,7 +1103,7 @@ static inline void dbg_ctrl(struct controller *ctrl)
1103 dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); 1103 dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no");
1104 dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); 1104 dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no");
1105 dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); 1105 dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no");
1106 dbg(" Comamnd Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); 1106 dbg(" Command Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes");
1107 pciehp_readw(ctrl, SLOTSTATUS, &reg16); 1107 pciehp_readw(ctrl, SLOTSTATUS, &reg16);
1108 dbg("Slot Status : 0x%04x\n", reg16); 1108 dbg("Slot Status : 0x%04x\n", reg16);
1109 pciehp_readw(ctrl, SLOTCTRL, &reg16); 1109 pciehp_readw(ctrl, SLOTCTRL, &reg16);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 15af618d36e2..18354817173c 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -126,7 +126,16 @@ static void msix_flush_writes(unsigned int irq)
126 } 126 }
127} 127}
128 128
129static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) 129/*
130 * PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to
131 * mask all MSI interrupts by clearing the MSI enable bit does not work
132 * reliably as devices without an INTx disable bit will then generate a
133 * level IRQ which will never be cleared.
134 *
135 * Returns 1 if it succeeded in masking the interrupt and 0 if the device
136 * doesn't support MSI masking.
137 */
138static int msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag)
130{ 139{
131 struct msi_desc *entry; 140 struct msi_desc *entry;
132 141
@@ -144,8 +153,7 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag)
144 mask_bits |= flag & mask; 153 mask_bits |= flag & mask;
145 pci_write_config_dword(entry->dev, pos, mask_bits); 154 pci_write_config_dword(entry->dev, pos, mask_bits);
146 } else { 155 } else {
147 __msi_set_enable(entry->dev, entry->msi_attrib.pos, 156 return 0;
148 !flag);
149 } 157 }
150 break; 158 break;
151 case PCI_CAP_ID_MSIX: 159 case PCI_CAP_ID_MSIX:
@@ -161,6 +169,7 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag)
161 break; 169 break;
162 } 170 }
163 entry->msi_attrib.masked = !!flag; 171 entry->msi_attrib.masked = !!flag;
172 return 1;
164} 173}
165 174
166void read_msi_msg(unsigned int irq, struct msi_msg *msg) 175void read_msi_msg(unsigned int irq, struct msi_msg *msg)
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 7764768b6a0e..89a2f0fa10f9 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pci-aspm.h>
14#include <acpi/acpi.h> 15#include <acpi/acpi.h>
15#include <acpi/acnamesp.h> 16#include <acpi/acnamesp.h>
16#include <acpi/acresrc.h> 17#include <acpi/acresrc.h>
@@ -372,6 +373,12 @@ static int __init acpi_pci_init(void)
372 printk(KERN_INFO"ACPI FADT declares the system doesn't support MSI, so disable it\n"); 373 printk(KERN_INFO"ACPI FADT declares the system doesn't support MSI, so disable it\n");
373 pci_no_msi(); 374 pci_no_msi();
374 } 375 }
376
377 if (acpi_gbl_FADT.boot_flags & BAF_PCIE_ASPM_CONTROL) {
378 printk(KERN_INFO"ACPI FADT declares the system doesn't support PCIe ASPM, so disable it\n");
379 pcie_no_aspm();
380 }
381
375 ret = register_acpi_bus_type(&acpi_pci_bus); 382 ret = register_acpi_bus_type(&acpi_pci_bus);
376 if (ret) 383 if (ret)
377 return 0; 384 return 0;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e9c356236d27..0a3d856833fc 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -572,6 +572,10 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
572 if (!ret) 572 if (!ret)
573 pci_update_current_state(dev); 573 pci_update_current_state(dev);
574 } 574 }
575 /* This device is quirked not to be put into D3, so
576 don't put it in D3 */
577 if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3))
578 return 0;
575 579
576 error = pci_raw_set_power_state(dev, state); 580 error = pci_raw_set_power_state(dev, state);
577 581
@@ -1123,6 +1127,12 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
1123} 1127}
1124 1128
1125/** 1129/**
1130 * pci_target_state - find an appropriate low power state for a given PCI dev
1131 * @dev: PCI device
1132 *
1133 * Use underlying platform code to find a supported low power state for @dev.
1134 * If the platform can't manage @dev, return the deepest state from which it
1135 * can generate wake events, based on any available PME info.
1126 */ 1136 */
1127pci_power_t pci_target_state(struct pci_dev *dev) 1137pci_power_t pci_target_state(struct pci_dev *dev)
1128{ 1138{
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index f82495583e63..9a7c9e1408a4 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -55,7 +55,7 @@ struct pcie_link_state {
55 struct endpoint_state endpoints[8]; 55 struct endpoint_state endpoints[8];
56}; 56};
57 57
58static int aspm_disabled; 58static int aspm_disabled, aspm_force;
59static DEFINE_MUTEX(aspm_lock); 59static DEFINE_MUTEX(aspm_lock);
60static LIST_HEAD(link_list); 60static LIST_HEAD(link_list);
61 61
@@ -510,6 +510,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
510{ 510{
511 struct pci_dev *child_dev; 511 struct pci_dev *child_dev;
512 int child_pos; 512 int child_pos;
513 u32 reg32;
513 514
514 /* 515 /*
515 * Some functions in a slot might not all be PCIE functions, very 516 * Some functions in a slot might not all be PCIE functions, very
@@ -519,6 +520,19 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
519 child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP); 520 child_pos = pci_find_capability(child_dev, PCI_CAP_ID_EXP);
520 if (!child_pos) 521 if (!child_pos)
521 return -EINVAL; 522 return -EINVAL;
523
524 /*
525 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use
526 * RBER bit to determine if a function is 1.1 version device
527 */
528 pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP,
529 &reg32);
530 if (!(reg32 & PCI_EXP_DEVCAP_RBER && !aspm_force)) {
531 printk("Pre-1.1 PCIe device detected, "
532 "disable ASPM for %s. It can be enabled forcedly"
533 " with 'pcie_aspm=force'\n", pci_name(pdev));
534 return -EINVAL;
535 }
522 } 536 }
523 return 0; 537 return 0;
524} 538}
@@ -802,11 +816,23 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
802 816
803static int __init pcie_aspm_disable(char *str) 817static int __init pcie_aspm_disable(char *str)
804{ 818{
805 aspm_disabled = 1; 819 if (!strcmp(str, "off")) {
820 aspm_disabled = 1;
821 printk(KERN_INFO "PCIe ASPM is disabled\n");
822 } else if (!strcmp(str, "force")) {
823 aspm_force = 1;
824 printk(KERN_INFO "PCIe ASPM is forcedly enabled\n");
825 }
806 return 1; 826 return 1;
807} 827}
808 828
809__setup("pcie_noaspm", pcie_aspm_disable); 829__setup("pcie_aspm=", pcie_aspm_disable);
830
831void pcie_no_aspm(void)
832{
833 if (!aspm_force)
834 aspm_disabled = 1;
835}
810 836
811#ifdef CONFIG_ACPI 837#ifdef CONFIG_ACPI
812#include <acpi/acpi_bus.h> 838#include <acpi/acpi_bus.h>
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b1724cf31b66..7098dfb07449 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -163,12 +163,9 @@ static inline unsigned int pci_calc_resource_flags(unsigned int flags)
163 return IORESOURCE_MEM; 163 return IORESOURCE_MEM;
164} 164}
165 165
166/* 166static u64 pci_size(u64 base, u64 maxbase, u64 mask)
167 * Find the extent of a PCI decode..
168 */
169static u32 pci_size(u32 base, u32 maxbase, u32 mask)
170{ 167{
171 u32 size = mask & maxbase; /* Find the significant bits */ 168 u64 size = mask & maxbase; /* Find the significant bits */
172 if (!size) 169 if (!size)
173 return 0; 170 return 0;
174 171
@@ -184,135 +181,142 @@ static u32 pci_size(u32 base, u32 maxbase, u32 mask)
184 return size; 181 return size;
185} 182}
186 183
187static u64 pci_size64(u64 base, u64 maxbase, u64 mask) 184enum pci_bar_type {
188{ 185 pci_bar_unknown, /* Standard PCI BAR probe */
189 u64 size = mask & maxbase; /* Find the significant bits */ 186 pci_bar_io, /* An io port BAR */
190 if (!size) 187 pci_bar_mem32, /* A 32-bit memory BAR */
191 return 0; 188 pci_bar_mem64, /* A 64-bit memory BAR */
189};
192 190
193 /* Get the lowest of them to find the decode size, and 191static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar)
194 from that the extent. */ 192{
195 size = (size & ~(size-1)) - 1; 193 if ((bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
194 res->flags = bar & ~PCI_BASE_ADDRESS_IO_MASK;
195 return pci_bar_io;
196 }
196 197
197 /* base == maxbase can be valid only if the BAR has 198 res->flags = bar & ~PCI_BASE_ADDRESS_MEM_MASK;
198 already been programmed with all 1s. */
199 if (base == maxbase && ((base | size) & mask) != mask)
200 return 0;
201 199
202 return size; 200 if (res->flags == PCI_BASE_ADDRESS_MEM_TYPE_64)
201 return pci_bar_mem64;
202 return pci_bar_mem32;
203} 203}
204 204
205static inline int is_64bit_memory(u32 mask) 205/*
206 * If the type is not unknown, we assume that the lowest bit is 'enable'.
207 * Returns 1 if the BAR was 64-bit and 0 if it was 32-bit.
208 */
209static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
210 struct resource *res, unsigned int pos)
206{ 211{
207 if ((mask & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == 212 u32 l, sz, mask;
208 (PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64))
209 return 1;
210 return 0;
211}
212 213
213static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) 214 mask = type ? ~PCI_ROM_ADDRESS_ENABLE : ~0;
214{
215 unsigned int pos, reg, next;
216 u32 l, sz;
217 struct resource *res;
218 215
219 for(pos=0; pos<howmany; pos = next) { 216 res->name = pci_name(dev);
220 u64 l64;
221 u64 sz64;
222 u32 raw_sz;
223 217
224 next = pos+1; 218 pci_read_config_dword(dev, pos, &l);
225 res = &dev->resource[pos]; 219 pci_write_config_dword(dev, pos, mask);
226 res->name = pci_name(dev); 220 pci_read_config_dword(dev, pos, &sz);
227 reg = PCI_BASE_ADDRESS_0 + (pos << 2); 221 pci_write_config_dword(dev, pos, l);
228 pci_read_config_dword(dev, reg, &l); 222
229 pci_write_config_dword(dev, reg, ~0); 223 /*
230 pci_read_config_dword(dev, reg, &sz); 224 * All bits set in sz means the device isn't working properly.
231 pci_write_config_dword(dev, reg, l); 225 * If the BAR isn't implemented, all bits must be 0. If it's a
232 if (!sz || sz == 0xffffffff) 226 * memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit
233 continue; 227 * 1 must be clear.
234 if (l == 0xffffffff) 228 */
235 l = 0; 229 if (!sz || sz == 0xffffffff)
236 raw_sz = sz; 230 goto fail;
237 if ((l & PCI_BASE_ADDRESS_SPACE) == 231
238 PCI_BASE_ADDRESS_SPACE_MEMORY) { 232 /*
239 sz = pci_size(l, sz, (u32)PCI_BASE_ADDRESS_MEM_MASK); 233 * I don't know how l can have all bits set. Copied from old code.
240 /* 234 * Maybe it fixes a bug on some ancient platform.
241 * For 64bit prefetchable memory sz could be 0, if the 235 */
242 * real size is bigger than 4G, so we need to check 236 if (l == 0xffffffff)
243 * szhi for that. 237 l = 0;
244 */ 238
245 if (!is_64bit_memory(l) && !sz) 239 if (type == pci_bar_unknown) {
246 continue; 240 type = decode_bar(res, l);
247 res->start = l & PCI_BASE_ADDRESS_MEM_MASK; 241 res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN;
248 res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK; 242 if (type == pci_bar_io) {
243 l &= PCI_BASE_ADDRESS_IO_MASK;
244 mask = PCI_BASE_ADDRESS_IO_MASK & 0xffff;
249 } else { 245 } else {
250 sz = pci_size(l, sz, PCI_BASE_ADDRESS_IO_MASK & 0xffff); 246 l &= PCI_BASE_ADDRESS_MEM_MASK;
251 if (!sz) 247 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
252 continue;
253 res->start = l & PCI_BASE_ADDRESS_IO_MASK;
254 res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK;
255 } 248 }
256 res->end = res->start + (unsigned long) sz; 249 } else {
257 res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; 250 res->flags |= (l & IORESOURCE_ROM_ENABLE);
258 if (is_64bit_memory(l)) { 251 l &= PCI_ROM_ADDRESS_MASK;
259 u32 szhi, lhi; 252 mask = (u32)PCI_ROM_ADDRESS_MASK;
260 253 }
261 pci_read_config_dword(dev, reg+4, &lhi); 254
262 pci_write_config_dword(dev, reg+4, ~0); 255 if (type == pci_bar_mem64) {
263 pci_read_config_dword(dev, reg+4, &szhi); 256 u64 l64 = l;
264 pci_write_config_dword(dev, reg+4, lhi); 257 u64 sz64 = sz;
265 sz64 = ((u64)szhi << 32) | raw_sz; 258 u64 mask64 = mask | (u64)~0 << 32;
266 l64 = ((u64)lhi << 32) | l; 259
267 sz64 = pci_size64(l64, sz64, PCI_BASE_ADDRESS_MEM_MASK); 260 pci_read_config_dword(dev, pos + 4, &l);
268 next++; 261 pci_write_config_dword(dev, pos + 4, ~0);
269#if BITS_PER_LONG == 64 262 pci_read_config_dword(dev, pos + 4, &sz);
270 if (!sz64) { 263 pci_write_config_dword(dev, pos + 4, l);
271 res->start = 0; 264
272 res->end = 0; 265 l64 |= ((u64)l << 32);
273 res->flags = 0; 266 sz64 |= ((u64)sz << 32);
274 continue; 267
275 } 268 sz64 = pci_size(l64, sz64, mask64);
276 res->start = l64 & PCI_BASE_ADDRESS_MEM_MASK; 269
277 res->end = res->start + sz64; 270 if (!sz64)
278#else 271 goto fail;
279 if (sz64 > 0x100000000ULL) { 272
280 dev_err(&dev->dev, "BAR %d: can't handle 64-bit" 273 if ((sizeof(resource_size_t) < 8) && (sz64 > 0x100000000ULL)) {
281 " BAR\n", pos); 274 dev_err(&dev->dev, "can't handle 64-bit BAR\n");
282 res->start = 0; 275 goto fail;
283 res->flags = 0; 276 } else if ((sizeof(resource_size_t) < 8) && l) {
284 } else if (lhi) { 277 /* Address above 32-bit boundary; disable the BAR */
285 /* 64-bit wide address, treat as disabled */ 278 pci_write_config_dword(dev, pos, 0);
286 pci_write_config_dword(dev, reg, 279 pci_write_config_dword(dev, pos + 4, 0);
287 l & ~(u32)PCI_BASE_ADDRESS_MEM_MASK); 280 res->start = 0;
288 pci_write_config_dword(dev, reg+4, 0); 281 res->end = sz64;
289 res->start = 0; 282 } else {
290 res->end = sz; 283 res->start = l64;
291 } 284 res->end = l64 + sz64;
292#endif
293 } 285 }
286 } else {
287 sz = pci_size(l, sz, mask);
288
289 if (!sz)
290 goto fail;
291
292 res->start = l;
293 res->end = l + sz;
294 } 294 }
295
296 out:
297 return (type == pci_bar_mem64) ? 1 : 0;
298 fail:
299 res->flags = 0;
300 goto out;
301}
302
303static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
304{
305 unsigned int pos, reg;
306
307 for (pos = 0; pos < howmany; pos++) {
308 struct resource *res = &dev->resource[pos];
309 reg = PCI_BASE_ADDRESS_0 + (pos << 2);
310 pos += __pci_read_base(dev, pci_bar_unknown, res, reg);
311 }
312
295 if (rom) { 313 if (rom) {
314 struct resource *res = &dev->resource[PCI_ROM_RESOURCE];
296 dev->rom_base_reg = rom; 315 dev->rom_base_reg = rom;
297 res = &dev->resource[PCI_ROM_RESOURCE]; 316 res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH |
298 res->name = pci_name(dev); 317 IORESOURCE_READONLY | IORESOURCE_CACHEABLE |
299 pci_read_config_dword(dev, rom, &l); 318 IORESOURCE_SIZEALIGN;
300 pci_write_config_dword(dev, rom, ~PCI_ROM_ADDRESS_ENABLE); 319 __pci_read_base(dev, pci_bar_mem32, res, rom);
301 pci_read_config_dword(dev, rom, &sz);
302 pci_write_config_dword(dev, rom, l);
303 if (l == 0xffffffff)
304 l = 0;
305 if (sz && sz != 0xffffffff) {
306 sz = pci_size(l, sz, (u32)PCI_ROM_ADDRESS_MASK);
307 if (sz) {
308 res->flags = (l & IORESOURCE_ROM_ENABLE) |
309 IORESOURCE_MEM | IORESOURCE_PREFETCH |
310 IORESOURCE_READONLY | IORESOURCE_CACHEABLE |
311 IORESOURCE_SIZEALIGN;
312 res->start = l & PCI_ROM_ADDRESS_MASK;
313 res->end = res->start + (unsigned long) sz;
314 }
315 }
316 } 320 }
317} 321}
318 322
@@ -1053,7 +1057,8 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
1053 } 1057 }
1054 } 1058 }
1055 1059
1056 if (bus->self) 1060 /* only one slot has pcie device */
1061 if (bus->self && nr)
1057 pcie_aspm_init_link_state(bus->self); 1062 pcie_aspm_init_link_state(bus->self);
1058 1063
1059 return nr; 1064 return nr;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 12d489395fad..0fb365074288 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -923,6 +923,19 @@ static void __init quirk_ide_samemode(struct pci_dev *pdev)
923} 923}
924DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); 924DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode);
925 925
926/*
927 * Some ATA devices break if put into D3
928 */
929
930static void __devinit quirk_no_ata_d3(struct pci_dev *pdev)
931{
932 /* Quirk the legacy ATA devices only. The AHCI ones are ok */
933 if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE)
934 pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
935}
936DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, quirk_no_ata_d3);
937DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, quirk_no_ata_d3);
938
926/* This was originally an Alpha specific thing, but it really fits here. 939/* This was originally an Alpha specific thing, but it really fits here.
927 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 940 * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
928 */ 941 */
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 420a77540f41..8c21446996f2 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -149,10 +149,10 @@ soc_common_pcmcia_config_skt(struct soc_pcmcia_socket *skt, socket_state_t *stat
149 */ 149 */
150 if (skt->irq_state != 1 && state->io_irq) { 150 if (skt->irq_state != 1 && state->io_irq) {
151 skt->irq_state = 1; 151 skt->irq_state = 1;
152 set_irq_type(skt->irq, IRQT_FALLING); 152 set_irq_type(skt->irq, IRQ_TYPE_EDGE_FALLING);
153 } else if (skt->irq_state == 1 && state->io_irq == 0) { 153 } else if (skt->irq_state == 1 && state->io_irq == 0) {
154 skt->irq_state = 0; 154 skt->irq_state = 0;
155 set_irq_type(skt->irq, IRQT_NOEDGE); 155 set_irq_type(skt->irq, IRQ_TYPE_NONE);
156 } 156 }
157 157
158 skt->cs_state = *state; 158 skt->cs_state = *state;
@@ -527,7 +527,7 @@ int soc_pcmcia_request_irqs(struct soc_pcmcia_socket *skt,
527 IRQF_DISABLED, irqs[i].str, skt); 527 IRQF_DISABLED, irqs[i].str, skt);
528 if (res) 528 if (res)
529 break; 529 break;
530 set_irq_type(irqs[i].irq, IRQT_NOEDGE); 530 set_irq_type(irqs[i].irq, IRQ_TYPE_NONE);
531 } 531 }
532 532
533 if (res) { 533 if (res) {
@@ -560,7 +560,7 @@ void soc_pcmcia_disable_irqs(struct soc_pcmcia_socket *skt,
560 560
561 for (i = 0; i < nr; i++) 561 for (i = 0; i < nr; i++)
562 if (irqs[i].sock == skt->nr) 562 if (irqs[i].sock == skt->nr)
563 set_irq_type(irqs[i].irq, IRQT_NOEDGE); 563 set_irq_type(irqs[i].irq, IRQ_TYPE_NONE);
564} 564}
565EXPORT_SYMBOL(soc_pcmcia_disable_irqs); 565EXPORT_SYMBOL(soc_pcmcia_disable_irqs);
566 566
@@ -571,8 +571,8 @@ void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt,
571 571
572 for (i = 0; i < nr; i++) 572 for (i = 0; i < nr; i++)
573 if (irqs[i].sock == skt->nr) { 573 if (irqs[i].sock == skt->nr) {
574 set_irq_type(irqs[i].irq, IRQT_RISING); 574 set_irq_type(irqs[i].irq, IRQ_TYPE_EDGE_RISING);
575 set_irq_type(irqs[i].irq, IRQT_BOTHEDGE); 575 set_irq_type(irqs[i].irq, IRQ_TYPE_EDGE_BOTH);
576 } 576 }
577} 577}
578EXPORT_SYMBOL(soc_pcmcia_enable_irqs); 578EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index e3fa9a2d9a3d..9fd7bb9b7dce 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -19,7 +19,6 @@ struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
19int pnp_interface_attach_device(struct pnp_dev *dev); 19int pnp_interface_attach_device(struct pnp_dev *dev);
20 20
21int pnp_add_card(struct pnp_card *card); 21int pnp_add_card(struct pnp_card *card);
22struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
23void pnp_remove_card(struct pnp_card *card); 22void pnp_remove_card(struct pnp_card *card);
24int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); 23int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
25void pnp_remove_card_device(struct pnp_dev *dev); 24void pnp_remove_card_device(struct pnp_dev *dev);
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index a762a4176736..e75b060daa95 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -8,6 +8,7 @@
8#include <linux/ctype.h> 8#include <linux/ctype.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/pnp.h> 10#include <linux/pnp.h>
11#include <linux/dma-mapping.h>
11#include "base.h" 12#include "base.h"
12 13
13LIST_HEAD(pnp_cards); 14LIST_HEAD(pnp_cards);
@@ -101,7 +102,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
101 * @id: pointer to a pnp_id structure 102 * @id: pointer to a pnp_id structure
102 * @card: pointer to the desired card 103 * @card: pointer to the desired card
103 */ 104 */
104struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id) 105static struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
105{ 106{
106 struct pnp_id *dev_id, *ptr; 107 struct pnp_id *dev_id, *ptr;
107 108
@@ -167,6 +168,9 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnp
167 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, 168 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
168 card->number); 169 card->number);
169 170
171 card->dev.coherent_dma_mask = DMA_24BIT_MASK;
172 card->dev.dma_mask = &card->dev.coherent_dma_mask;
173
170 dev_id = pnp_add_card_id(card, pnpid); 174 dev_id = pnp_add_card_id(card, pnpid);
171 if (!dev_id) { 175 if (!dev_id) {
172 kfree(card); 176 kfree(card);
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index 55f55ed72dc7..0bdf9b8a5e58 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -245,15 +245,17 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
245 */ 245 */
246 for_each_pci_dev(pdev) { 246 for_each_pci_dev(pdev) {
247 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 247 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
248 if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM) || 248 unsigned int type;
249 pci_resource_len(pdev, i) == 0) 249
250 type = pci_resource_flags(pdev, i) &
251 (IORESOURCE_IO | IORESOURCE_MEM);
252 if (!type || pci_resource_len(pdev, i) == 0)
250 continue; 253 continue;
251 254
252 pci_start = pci_resource_start(pdev, i); 255 pci_start = pci_resource_start(pdev, i);
253 pci_end = pci_resource_end(pdev, i); 256 pci_end = pci_resource_end(pdev, i);
254 for (j = 0; 257 for (j = 0;
255 (res = pnp_get_resource(dev, IORESOURCE_MEM, j)); 258 (res = pnp_get_resource(dev, type, j)); j++) {
256 j++) {
257 if (res->start == 0 && res->end == 0) 259 if (res->start == 0 && res->end == 0)
258 continue; 260 continue;
259 261
@@ -283,9 +285,10 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
283 * the PCI region, and that might prevent a PCI 285 * the PCI region, and that might prevent a PCI
284 * driver from requesting its resources. 286 * driver from requesting its resources.
285 */ 287 */
286 dev_warn(&dev->dev, "mem resource " 288 dev_warn(&dev->dev, "%s resource "
287 "(0x%llx-0x%llx) overlaps %s BAR %d " 289 "(0x%llx-0x%llx) overlaps %s BAR %d "
288 "(0x%llx-0x%llx), disabling\n", 290 "(0x%llx-0x%llx), disabling\n",
291 pnp_resource_type_name(res),
289 (unsigned long long) pnp_start, 292 (unsigned long long) pnp_start,
290 (unsigned long long) pnp_end, 293 (unsigned long long) pnp_end,
291 pci_name(pdev), i, 294 pci_name(pdev), i,
diff --git a/drivers/s390/kvm/Makefile b/drivers/s390/kvm/Makefile
index 4a5ec39f9ca6..0815690ac1e0 100644
--- a/drivers/s390/kvm/Makefile
+++ b/drivers/s390/kvm/Makefile
@@ -6,4 +6,4 @@
6# it under the terms of the GNU General Public License (version 2 only) 6# it under the terms of the GNU General Public License (version 2 only)
7# as published by the Free Software Foundation. 7# as published by the Free Software Foundation.
8 8
9obj-$(CONFIG_VIRTIO) += kvm_virtio.o 9obj-$(CONFIG_S390_GUEST) += kvm_virtio.o
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index c3ad89e302bd..cebb25e36e82 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -3321,7 +3321,7 @@ int qeth_change_mtu(struct net_device *dev, int new_mtu)
3321 struct qeth_card *card; 3321 struct qeth_card *card;
3322 char dbf_text[15]; 3322 char dbf_text[15];
3323 3323
3324 card = netdev_priv(dev); 3324 card = dev->ml_priv;
3325 3325
3326 QETH_DBF_TEXT(TRACE, 4, "chgmtu"); 3326 QETH_DBF_TEXT(TRACE, 4, "chgmtu");
3327 sprintf(dbf_text, "%8x", new_mtu); 3327 sprintf(dbf_text, "%8x", new_mtu);
@@ -3343,7 +3343,7 @@ struct net_device_stats *qeth_get_stats(struct net_device *dev)
3343{ 3343{
3344 struct qeth_card *card; 3344 struct qeth_card *card;
3345 3345
3346 card = netdev_priv(dev); 3346 card = dev->ml_priv;
3347 3347
3348 QETH_DBF_TEXT(TRACE, 5, "getstat"); 3348 QETH_DBF_TEXT(TRACE, 5, "getstat");
3349 3349
@@ -3395,7 +3395,7 @@ void qeth_tx_timeout(struct net_device *dev)
3395{ 3395{
3396 struct qeth_card *card; 3396 struct qeth_card *card;
3397 3397
3398 card = netdev_priv(dev); 3398 card = dev->ml_priv;
3399 card->stats.tx_errors++; 3399 card->stats.tx_errors++;
3400 qeth_schedule_recovery(card); 3400 qeth_schedule_recovery(card);
3401} 3401}
@@ -3403,7 +3403,7 @@ EXPORT_SYMBOL_GPL(qeth_tx_timeout);
3403 3403
3404int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum) 3404int qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
3405{ 3405{
3406 struct qeth_card *card = netdev_priv(dev); 3406 struct qeth_card *card = dev->ml_priv;
3407 int rc = 0; 3407 int rc = 0;
3408 3408
3409 switch (regnum) { 3409 switch (regnum) {
@@ -4253,7 +4253,7 @@ EXPORT_SYMBOL_GPL(qeth_core_get_stats_count);
4253void qeth_core_get_ethtool_stats(struct net_device *dev, 4253void qeth_core_get_ethtool_stats(struct net_device *dev,
4254 struct ethtool_stats *stats, u64 *data) 4254 struct ethtool_stats *stats, u64 *data)
4255{ 4255{
4256 struct qeth_card *card = netdev_priv(dev); 4256 struct qeth_card *card = dev->ml_priv;
4257 data[0] = card->stats.rx_packets - 4257 data[0] = card->stats.rx_packets -
4258 card->perf_stats.initial_rx_packets; 4258 card->perf_stats.initial_rx_packets;
4259 data[1] = card->perf_stats.bufs_rec; 4259 data[1] = card->perf_stats.bufs_rec;
@@ -4313,7 +4313,7 @@ EXPORT_SYMBOL_GPL(qeth_core_get_strings);
4313void qeth_core_get_drvinfo(struct net_device *dev, 4313void qeth_core_get_drvinfo(struct net_device *dev,
4314 struct ethtool_drvinfo *info) 4314 struct ethtool_drvinfo *info)
4315{ 4315{
4316 struct qeth_card *card = netdev_priv(dev); 4316 struct qeth_card *card = dev->ml_priv;
4317 if (card->options.layer2) 4317 if (card->options.layer2)
4318 strcpy(info->driver, "qeth_l2"); 4318 strcpy(info->driver, "qeth_l2");
4319 else 4319 else
@@ -4331,7 +4331,7 @@ EXPORT_SYMBOL_GPL(qeth_core_get_drvinfo);
4331int qeth_core_ethtool_get_settings(struct net_device *netdev, 4331int qeth_core_ethtool_get_settings(struct net_device *netdev,
4332 struct ethtool_cmd *ecmd) 4332 struct ethtool_cmd *ecmd)
4333{ 4333{
4334 struct qeth_card *card = netdev_priv(netdev); 4334 struct qeth_card *card = netdev->ml_priv;
4335 enum qeth_link_types link_type; 4335 enum qeth_link_types link_type;
4336 4336
4337 if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan)) 4337 if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan))
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 3fbc3bdec0c5..a8b069cd9a4c 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -35,7 +35,7 @@ static int qeth_l2_recover(void *);
35 35
36static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 36static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
37{ 37{
38 struct qeth_card *card = netdev_priv(dev); 38 struct qeth_card *card = dev->ml_priv;
39 struct mii_ioctl_data *mii_data; 39 struct mii_ioctl_data *mii_data;
40 int rc = 0; 40 int rc = 0;
41 41
@@ -317,7 +317,7 @@ static void qeth_l2_process_vlans(struct qeth_card *card, int clear)
317 317
318static void qeth_l2_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) 318static void qeth_l2_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
319{ 319{
320 struct qeth_card *card = netdev_priv(dev); 320 struct qeth_card *card = dev->ml_priv;
321 struct qeth_vlan_vid *id; 321 struct qeth_vlan_vid *id;
322 322
323 QETH_DBF_TEXT_(TRACE, 4, "aid:%d", vid); 323 QETH_DBF_TEXT_(TRACE, 4, "aid:%d", vid);
@@ -334,7 +334,7 @@ static void qeth_l2_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
334static void qeth_l2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 334static void qeth_l2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
335{ 335{
336 struct qeth_vlan_vid *id, *tmpid = NULL; 336 struct qeth_vlan_vid *id, *tmpid = NULL;
337 struct qeth_card *card = netdev_priv(dev); 337 struct qeth_card *card = dev->ml_priv;
338 338
339 QETH_DBF_TEXT_(TRACE, 4, "kid:%d", vid); 339 QETH_DBF_TEXT_(TRACE, 4, "kid:%d", vid);
340 spin_lock_bh(&card->vlanlock); 340 spin_lock_bh(&card->vlanlock);
@@ -566,7 +566,7 @@ static int qeth_l2_request_initial_mac(struct qeth_card *card)
566static int qeth_l2_set_mac_address(struct net_device *dev, void *p) 566static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
567{ 567{
568 struct sockaddr *addr = p; 568 struct sockaddr *addr = p;
569 struct qeth_card *card = netdev_priv(dev); 569 struct qeth_card *card = dev->ml_priv;
570 int rc = 0; 570 int rc = 0;
571 571
572 QETH_DBF_TEXT(TRACE, 3, "setmac"); 572 QETH_DBF_TEXT(TRACE, 3, "setmac");
@@ -590,7 +590,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
590 590
591static void qeth_l2_set_multicast_list(struct net_device *dev) 591static void qeth_l2_set_multicast_list(struct net_device *dev)
592{ 592{
593 struct qeth_card *card = netdev_priv(dev); 593 struct qeth_card *card = dev->ml_priv;
594 struct dev_mc_list *dm; 594 struct dev_mc_list *dm;
595 595
596 if (card->info.type == QETH_CARD_TYPE_OSN) 596 if (card->info.type == QETH_CARD_TYPE_OSN)
@@ -612,7 +612,7 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
612 int rc; 612 int rc;
613 struct qeth_hdr *hdr = NULL; 613 struct qeth_hdr *hdr = NULL;
614 int elements = 0; 614 int elements = 0;
615 struct qeth_card *card = netdev_priv(dev); 615 struct qeth_card *card = dev->ml_priv;
616 struct sk_buff *new_skb = skb; 616 struct sk_buff *new_skb = skb;
617 int ipv = qeth_get_ip_version(skb); 617 int ipv = qeth_get_ip_version(skb);
618 int cast_type = qeth_get_cast_type(card, skb); 618 int cast_type = qeth_get_cast_type(card, skb);
@@ -767,7 +767,7 @@ static void qeth_l2_qdio_input_handler(struct ccw_device *ccwdev,
767 767
768static int qeth_l2_open(struct net_device *dev) 768static int qeth_l2_open(struct net_device *dev)
769{ 769{
770 struct qeth_card *card = netdev_priv(dev); 770 struct qeth_card *card = dev->ml_priv;
771 771
772 QETH_DBF_TEXT(TRACE, 4, "qethopen"); 772 QETH_DBF_TEXT(TRACE, 4, "qethopen");
773 if (card->state != CARD_STATE_SOFTSETUP) 773 if (card->state != CARD_STATE_SOFTSETUP)
@@ -791,7 +791,7 @@ static int qeth_l2_open(struct net_device *dev)
791 791
792static int qeth_l2_stop(struct net_device *dev) 792static int qeth_l2_stop(struct net_device *dev)
793{ 793{
794 struct qeth_card *card = netdev_priv(dev); 794 struct qeth_card *card = dev->ml_priv;
795 795
796 QETH_DBF_TEXT(TRACE, 4, "qethstop"); 796 QETH_DBF_TEXT(TRACE, 4, "qethstop");
797 netif_tx_disable(dev); 797 netif_tx_disable(dev);
@@ -838,7 +838,7 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
838 838
839static int qeth_l2_ethtool_set_tso(struct net_device *dev, u32 data) 839static int qeth_l2_ethtool_set_tso(struct net_device *dev, u32 data)
840{ 840{
841 struct qeth_card *card = netdev_priv(dev); 841 struct qeth_card *card = dev->ml_priv;
842 842
843 if (data) { 843 if (data) {
844 if (card->options.large_send == QETH_LARGE_SEND_NO) { 844 if (card->options.large_send == QETH_LARGE_SEND_NO) {
@@ -894,7 +894,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
894 if (!card->dev) 894 if (!card->dev)
895 return -ENODEV; 895 return -ENODEV;
896 896
897 card->dev->priv = card; 897 card->dev->ml_priv = card;
898 card->dev->tx_timeout = &qeth_tx_timeout; 898 card->dev->tx_timeout = &qeth_tx_timeout;
899 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 899 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
900 card->dev->open = qeth_l2_open; 900 card->dev->open = qeth_l2_open;
@@ -1178,7 +1178,7 @@ int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
1178 QETH_DBF_TEXT(TRACE, 2, "osnsdmc"); 1178 QETH_DBF_TEXT(TRACE, 2, "osnsdmc");
1179 if (!dev) 1179 if (!dev)
1180 return -ENODEV; 1180 return -ENODEV;
1181 card = netdev_priv(dev); 1181 card = dev->ml_priv;
1182 if (!card) 1182 if (!card)
1183 return -ENODEV; 1183 return -ENODEV;
1184 if ((card->state != CARD_STATE_UP) && 1184 if ((card->state != CARD_STATE_UP) &&
@@ -1201,7 +1201,7 @@ int qeth_osn_register(unsigned char *read_dev_no, struct net_device **dev,
1201 *dev = qeth_l2_netdev_by_devno(read_dev_no); 1201 *dev = qeth_l2_netdev_by_devno(read_dev_no);
1202 if (*dev == NULL) 1202 if (*dev == NULL)
1203 return -ENODEV; 1203 return -ENODEV;
1204 card = netdev_priv(*dev); 1204 card = (*dev)->ml_priv;
1205 if (!card) 1205 if (!card)
1206 return -ENODEV; 1206 return -ENODEV;
1207 if ((assist_cb == NULL) || (data_cb == NULL)) 1207 if ((assist_cb == NULL) || (data_cb == NULL))
@@ -1219,7 +1219,7 @@ void qeth_osn_deregister(struct net_device *dev)
1219 QETH_DBF_TEXT(TRACE, 2, "osndereg"); 1219 QETH_DBF_TEXT(TRACE, 2, "osndereg");
1220 if (!dev) 1220 if (!dev)
1221 return; 1221 return;
1222 card = netdev_priv(dev); 1222 card = dev->ml_priv;
1223 if (!card) 1223 if (!card)
1224 return; 1224 return;
1225 card->osn_info.assist_cb = NULL; 1225 card->osn_info.assist_cb = NULL;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 38de31b55708..3e1d13857350 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1813,7 +1813,7 @@ static void qeth_l3_free_vlan_addresses(struct qeth_card *card,
1813static void qeth_l3_vlan_rx_register(struct net_device *dev, 1813static void qeth_l3_vlan_rx_register(struct net_device *dev,
1814 struct vlan_group *grp) 1814 struct vlan_group *grp)
1815{ 1815{
1816 struct qeth_card *card = netdev_priv(dev); 1816 struct qeth_card *card = dev->ml_priv;
1817 unsigned long flags; 1817 unsigned long flags;
1818 1818
1819 QETH_DBF_TEXT(TRACE, 4, "vlanreg"); 1819 QETH_DBF_TEXT(TRACE, 4, "vlanreg");
@@ -1825,7 +1825,7 @@ static void qeth_l3_vlan_rx_register(struct net_device *dev,
1825static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) 1825static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1826{ 1826{
1827 struct net_device *vlandev; 1827 struct net_device *vlandev;
1828 struct qeth_card *card = (struct qeth_card *) dev->priv; 1828 struct qeth_card *card = dev->ml_priv;
1829 struct in_device *in_dev; 1829 struct in_device *in_dev;
1830 1830
1831 if (card->info.type == QETH_CARD_TYPE_IQD) 1831 if (card->info.type == QETH_CARD_TYPE_IQD)
@@ -1851,7 +1851,7 @@ static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1851 1851
1852static void qeth_l3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 1852static void qeth_l3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1853{ 1853{
1854 struct qeth_card *card = netdev_priv(dev); 1854 struct qeth_card *card = dev->ml_priv;
1855 unsigned long flags; 1855 unsigned long flags;
1856 1856
1857 QETH_DBF_TEXT_(TRACE, 4, "kid:%d", vid); 1857 QETH_DBF_TEXT_(TRACE, 4, "kid:%d", vid);
@@ -2013,7 +2013,7 @@ static int qeth_l3_verify_vlan_dev(struct net_device *dev,
2013 } 2013 }
2014 } 2014 }
2015 2015
2016 if (rc && !(netdev_priv(vlan_dev_real_dev(dev)) == (void *)card)) 2016 if (rc && !(vlan_dev_real_dev(dev)->ml_priv == (void *)card))
2017 return 0; 2017 return 0;
2018 2018
2019 return rc; 2019 return rc;
@@ -2047,9 +2047,9 @@ static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev)
2047 2047
2048 rc = qeth_l3_verify_dev(dev); 2048 rc = qeth_l3_verify_dev(dev);
2049 if (rc == QETH_REAL_CARD) 2049 if (rc == QETH_REAL_CARD)
2050 card = netdev_priv(dev); 2050 card = dev->ml_priv;
2051 else if (rc == QETH_VLAN_CARD) 2051 else if (rc == QETH_VLAN_CARD)
2052 card = netdev_priv(vlan_dev_real_dev(dev)); 2052 card = vlan_dev_real_dev(dev)->ml_priv;
2053 if (card && card->options.layer2) 2053 if (card && card->options.layer2)
2054 card = NULL; 2054 card = NULL;
2055 QETH_DBF_TEXT_(TRACE, 4, "%d", rc); 2055 QETH_DBF_TEXT_(TRACE, 4, "%d", rc);
@@ -2110,7 +2110,7 @@ static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
2110 2110
2111static void qeth_l3_set_multicast_list(struct net_device *dev) 2111static void qeth_l3_set_multicast_list(struct net_device *dev)
2112{ 2112{
2113 struct qeth_card *card = netdev_priv(dev); 2113 struct qeth_card *card = dev->ml_priv;
2114 2114
2115 QETH_DBF_TEXT(TRACE, 3, "setmulti"); 2115 QETH_DBF_TEXT(TRACE, 3, "setmulti");
2116 qeth_l3_delete_mc_addresses(card); 2116 qeth_l3_delete_mc_addresses(card);
@@ -2438,7 +2438,7 @@ static int qeth_l3_arp_flush_cache(struct qeth_card *card)
2438 2438
2439static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2439static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2440{ 2440{
2441 struct qeth_card *card = netdev_priv(dev); 2441 struct qeth_card *card = dev->ml_priv;
2442 struct qeth_arp_cache_entry arp_entry; 2442 struct qeth_arp_cache_entry arp_entry;
2443 struct mii_ioctl_data *mii_data; 2443 struct mii_ioctl_data *mii_data;
2444 int rc = 0; 2444 int rc = 0;
@@ -2595,7 +2595,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2595 u16 *tag; 2595 u16 *tag;
2596 struct qeth_hdr *hdr = NULL; 2596 struct qeth_hdr *hdr = NULL;
2597 int elements_needed = 0; 2597 int elements_needed = 0;
2598 struct qeth_card *card = netdev_priv(dev); 2598 struct qeth_card *card = dev->ml_priv;
2599 struct sk_buff *new_skb = NULL; 2599 struct sk_buff *new_skb = NULL;
2600 int ipv = qeth_get_ip_version(skb); 2600 int ipv = qeth_get_ip_version(skb);
2601 int cast_type = qeth_get_cast_type(card, skb); 2601 int cast_type = qeth_get_cast_type(card, skb);
@@ -2763,7 +2763,7 @@ tx_drop:
2763 2763
2764static int qeth_l3_open(struct net_device *dev) 2764static int qeth_l3_open(struct net_device *dev)
2765{ 2765{
2766 struct qeth_card *card = netdev_priv(dev); 2766 struct qeth_card *card = dev->ml_priv;
2767 2767
2768 QETH_DBF_TEXT(TRACE, 4, "qethopen"); 2768 QETH_DBF_TEXT(TRACE, 4, "qethopen");
2769 if (card->state != CARD_STATE_SOFTSETUP) 2769 if (card->state != CARD_STATE_SOFTSETUP)
@@ -2780,7 +2780,7 @@ static int qeth_l3_open(struct net_device *dev)
2780 2780
2781static int qeth_l3_stop(struct net_device *dev) 2781static int qeth_l3_stop(struct net_device *dev)
2782{ 2782{
2783 struct qeth_card *card = netdev_priv(dev); 2783 struct qeth_card *card = dev->ml_priv;
2784 2784
2785 QETH_DBF_TEXT(TRACE, 4, "qethstop"); 2785 QETH_DBF_TEXT(TRACE, 4, "qethstop");
2786 netif_tx_disable(dev); 2786 netif_tx_disable(dev);
@@ -2792,14 +2792,14 @@ static int qeth_l3_stop(struct net_device *dev)
2792 2792
2793static u32 qeth_l3_ethtool_get_rx_csum(struct net_device *dev) 2793static u32 qeth_l3_ethtool_get_rx_csum(struct net_device *dev)
2794{ 2794{
2795 struct qeth_card *card = netdev_priv(dev); 2795 struct qeth_card *card = dev->ml_priv;
2796 2796
2797 return (card->options.checksum_type == HW_CHECKSUMMING); 2797 return (card->options.checksum_type == HW_CHECKSUMMING);
2798} 2798}
2799 2799
2800static int qeth_l3_ethtool_set_rx_csum(struct net_device *dev, u32 data) 2800static int qeth_l3_ethtool_set_rx_csum(struct net_device *dev, u32 data)
2801{ 2801{
2802 struct qeth_card *card = netdev_priv(dev); 2802 struct qeth_card *card = dev->ml_priv;
2803 enum qeth_card_states old_state; 2803 enum qeth_card_states old_state;
2804 enum qeth_checksum_types csum_type; 2804 enum qeth_checksum_types csum_type;
2805 2805
@@ -2825,7 +2825,7 @@ static int qeth_l3_ethtool_set_rx_csum(struct net_device *dev, u32 data)
2825 2825
2826static int qeth_l3_ethtool_set_tso(struct net_device *dev, u32 data) 2826static int qeth_l3_ethtool_set_tso(struct net_device *dev, u32 data)
2827{ 2827{
2828 struct qeth_card *card = netdev_priv(dev); 2828 struct qeth_card *card = dev->ml_priv;
2829 2829
2830 if (data) { 2830 if (data) {
2831 if (card->options.large_send == QETH_LARGE_SEND_NO) { 2831 if (card->options.large_send == QETH_LARGE_SEND_NO) {
@@ -2915,7 +2915,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2915 return -ENODEV; 2915 return -ENODEV;
2916 2916
2917 card->dev->hard_start_xmit = qeth_l3_hard_start_xmit; 2917 card->dev->hard_start_xmit = qeth_l3_hard_start_xmit;
2918 card->dev->priv = card; 2918 card->dev->ml_priv = card;
2919 card->dev->tx_timeout = &qeth_tx_timeout; 2919 card->dev->tx_timeout = &qeth_tx_timeout;
2920 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 2920 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
2921 card->dev->open = qeth_l3_open; 2921 card->dev->open = qeth_l3_open;
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 7045511f9ad2..b92c19bb6876 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -4,7 +4,7 @@
4 Written By: Adam Radford <linuxraid@amcc.com> 4 Written By: Adam Radford <linuxraid@amcc.com>
5 Modifications By: Tom Couch <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com>
6 6
7 Copyright (C) 2004-2007 Applied Micro Circuits Corporation. 7 Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
8 8
9 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
10 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
@@ -71,6 +71,10 @@
71 Add support for 9650SE controllers. 71 Add support for 9650SE controllers.
72 2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails. 72 2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
73 2.26.02.010 - Add support for 9690SA controllers. 73 2.26.02.010 - Add support for 9690SA controllers.
74 2.26.02.011 - Increase max AENs drained to 256.
75 Add MSI support and "use_msi" module parameter.
76 Fix bug in twa_get_param() on 4GB+.
77 Use pci_resource_len() for ioremap().
74*/ 78*/
75 79
76#include <linux/module.h> 80#include <linux/module.h>
@@ -95,7 +99,7 @@
95#include "3w-9xxx.h" 99#include "3w-9xxx.h"
96 100
97/* Globals */ 101/* Globals */
98#define TW_DRIVER_VERSION "2.26.02.010" 102#define TW_DRIVER_VERSION "2.26.02.011"
99static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 103static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
100static unsigned int twa_device_extension_count; 104static unsigned int twa_device_extension_count;
101static int twa_major = -1; 105static int twa_major = -1;
@@ -107,6 +111,10 @@ MODULE_DESCRIPTION ("3ware 9000 Storage Controller Linux Driver");
107MODULE_LICENSE("GPL"); 111MODULE_LICENSE("GPL");
108MODULE_VERSION(TW_DRIVER_VERSION); 112MODULE_VERSION(TW_DRIVER_VERSION);
109 113
114static int use_msi = 0;
115module_param(use_msi, int, S_IRUGO);
116MODULE_PARM_DESC(use_msi, "Use Message Signaled Interrupts. Default: 0");
117
110/* Function prototypes */ 118/* Function prototypes */
111static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header); 119static void twa_aen_queue_event(TW_Device_Extension *tw_dev, TW_Command_Apache_Header *header);
112static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id); 120static int twa_aen_read_queue(TW_Device_Extension *tw_dev, int request_id);
@@ -1038,7 +1046,6 @@ static void *twa_get_param(TW_Device_Extension *tw_dev, int request_id, int tabl
1038 TW_Command_Full *full_command_packet; 1046 TW_Command_Full *full_command_packet;
1039 TW_Command *command_packet; 1047 TW_Command *command_packet;
1040 TW_Param_Apache *param; 1048 TW_Param_Apache *param;
1041 unsigned long param_value;
1042 void *retval = NULL; 1049 void *retval = NULL;
1043 1050
1044 /* Setup the command packet */ 1051 /* Setup the command packet */
@@ -1057,9 +1064,8 @@ static void *twa_get_param(TW_Device_Extension *tw_dev, int request_id, int tabl
1057 param->table_id = cpu_to_le16(table_id | 0x8000); 1064 param->table_id = cpu_to_le16(table_id | 0x8000);
1058 param->parameter_id = cpu_to_le16(parameter_id); 1065 param->parameter_id = cpu_to_le16(parameter_id);
1059 param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes); 1066 param->parameter_size_bytes = cpu_to_le16(parameter_size_bytes);
1060 param_value = tw_dev->generic_buffer_phys[request_id];
1061 1067
1062 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(param_value); 1068 command_packet->byte8_offset.param.sgl[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
1063 command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE); 1069 command_packet->byte8_offset.param.sgl[0].length = cpu_to_le32(TW_SECTOR_SIZE);
1064 1070
1065 /* Post the command packet to the board */ 1071 /* Post the command packet to the board */
@@ -2000,7 +2006,7 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2000{ 2006{
2001 struct Scsi_Host *host = NULL; 2007 struct Scsi_Host *host = NULL;
2002 TW_Device_Extension *tw_dev; 2008 TW_Device_Extension *tw_dev;
2003 u32 mem_addr; 2009 unsigned long mem_addr, mem_len;
2004 int retval = -ENODEV; 2010 int retval = -ENODEV;
2005 2011
2006 retval = pci_enable_device(pdev); 2012 retval = pci_enable_device(pdev);
@@ -2045,13 +2051,16 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2045 goto out_free_device_extension; 2051 goto out_free_device_extension;
2046 } 2052 }
2047 2053
2048 if (pdev->device == PCI_DEVICE_ID_3WARE_9000) 2054 if (pdev->device == PCI_DEVICE_ID_3WARE_9000) {
2049 mem_addr = pci_resource_start(pdev, 1); 2055 mem_addr = pci_resource_start(pdev, 1);
2050 else 2056 mem_len = pci_resource_len(pdev, 1);
2057 } else {
2051 mem_addr = pci_resource_start(pdev, 2); 2058 mem_addr = pci_resource_start(pdev, 2);
2059 mem_len = pci_resource_len(pdev, 2);
2060 }
2052 2061
2053 /* Save base address */ 2062 /* Save base address */
2054 tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE); 2063 tw_dev->base_addr = ioremap(mem_addr, mem_len);
2055 if (!tw_dev->base_addr) { 2064 if (!tw_dev->base_addr) {
2056 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap"); 2065 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
2057 goto out_release_mem_region; 2066 goto out_release_mem_region;
@@ -2086,7 +2095,7 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2086 2095
2087 pci_set_drvdata(pdev, host); 2096 pci_set_drvdata(pdev, host);
2088 2097
2089 printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%x, IRQ: %d.\n", 2098 printk(KERN_WARNING "3w-9xxx: scsi%d: Found a 3ware 9000 Storage Controller at 0x%lx, IRQ: %d.\n",
2090 host->host_no, mem_addr, pdev->irq); 2099 host->host_no, mem_addr, pdev->irq);
2091 printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n", 2100 printk(KERN_WARNING "3w-9xxx: scsi%d: Firmware %s, BIOS %s, Ports: %d.\n",
2092 host->host_no, 2101 host->host_no,
@@ -2097,6 +2106,11 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2097 le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE, 2106 le32_to_cpu(*(int *)twa_get_param(tw_dev, 2, TW_INFORMATION_TABLE,
2098 TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH))); 2107 TW_PARAM_PORTCOUNT, TW_PARAM_PORTCOUNT_LENGTH)));
2099 2108
2109 /* Try to enable MSI */
2110 if (use_msi && (pdev->device != PCI_DEVICE_ID_3WARE_9000) &&
2111 !pci_enable_msi(pdev))
2112 set_bit(TW_USING_MSI, &tw_dev->flags);
2113
2100 /* Now setup the interrupt handler */ 2114 /* Now setup the interrupt handler */
2101 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev); 2115 retval = request_irq(pdev->irq, twa_interrupt, IRQF_SHARED, "3w-9xxx", tw_dev);
2102 if (retval) { 2116 if (retval) {
@@ -2120,6 +2134,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2120 return 0; 2134 return 0;
2121 2135
2122out_remove_host: 2136out_remove_host:
2137 if (test_bit(TW_USING_MSI, &tw_dev->flags))
2138 pci_disable_msi(pdev);
2123 scsi_remove_host(host); 2139 scsi_remove_host(host);
2124out_iounmap: 2140out_iounmap:
2125 iounmap(tw_dev->base_addr); 2141 iounmap(tw_dev->base_addr);
@@ -2151,6 +2167,10 @@ static void twa_remove(struct pci_dev *pdev)
2151 /* Shutdown the card */ 2167 /* Shutdown the card */
2152 __twa_shutdown(tw_dev); 2168 __twa_shutdown(tw_dev);
2153 2169
2170 /* Disable MSI if enabled */
2171 if (test_bit(TW_USING_MSI, &tw_dev->flags))
2172 pci_disable_msi(pdev);
2173
2154 /* Free IO remapping */ 2174 /* Free IO remapping */
2155 iounmap(tw_dev->base_addr); 2175 iounmap(tw_dev->base_addr);
2156 2176
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index d14a9479e389..1729a8785fea 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -4,7 +4,7 @@
4 Written By: Adam Radford <linuxraid@amcc.com> 4 Written By: Adam Radford <linuxraid@amcc.com>
5 Modifications By: Tom Couch <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com>
6 6
7 Copyright (C) 2004-2007 Applied Micro Circuits Corporation. 7 Copyright (C) 2004-2008 Applied Micro Circuits Corporation.
8 8
9 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
10 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
@@ -319,8 +319,8 @@ static twa_message_type twa_error_table[] = {
319 319
320/* Compatibility defines */ 320/* Compatibility defines */
321#define TW_9000_ARCH_ID 0x5 321#define TW_9000_ARCH_ID 0x5
322#define TW_CURRENT_DRIVER_SRL 30 322#define TW_CURRENT_DRIVER_SRL 35
323#define TW_CURRENT_DRIVER_BUILD 80 323#define TW_CURRENT_DRIVER_BUILD 0
324#define TW_CURRENT_DRIVER_BRANCH 0 324#define TW_CURRENT_DRIVER_BRANCH 0
325 325
326/* Phase defines */ 326/* Phase defines */
@@ -352,8 +352,9 @@ static twa_message_type twa_error_table[] = {
352#define TW_MAX_RESET_TRIES 2 352#define TW_MAX_RESET_TRIES 2
353#define TW_MAX_CMDS_PER_LUN 254 353#define TW_MAX_CMDS_PER_LUN 254
354#define TW_MAX_RESPONSE_DRAIN 256 354#define TW_MAX_RESPONSE_DRAIN 256
355#define TW_MAX_AEN_DRAIN 40 355#define TW_MAX_AEN_DRAIN 255
356#define TW_IN_RESET 2 356#define TW_IN_RESET 2
357#define TW_USING_MSI 3
357#define TW_IN_ATTENTION_LOOP 4 358#define TW_IN_ATTENTION_LOOP 4
358#define TW_MAX_SECTORS 256 359#define TW_MAX_SECTORS 256
359#define TW_AEN_WAIT_TIME 1000 360#define TW_AEN_WAIT_TIME 1000
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 26be540d1dd3..c7f06298bd3c 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -63,6 +63,7 @@ comment "SCSI support type (disk, tape, CD-ROM)"
63config BLK_DEV_SD 63config BLK_DEV_SD
64 tristate "SCSI disk support" 64 tristate "SCSI disk support"
65 depends on SCSI 65 depends on SCSI
66 select CRC_T10DIF
66 ---help--- 67 ---help---
67 If you want to use SCSI hard disks, Fibre Channel disks, 68 If you want to use SCSI hard disks, Fibre Channel disks,
68 Serial ATA (SATA) or Parallel ATA (PATA) hard disks, 69 Serial ATA (SATA) or Parallel ATA (PATA) hard disks,
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index a8149677de23..72fd5043cfa1 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -151,6 +151,8 @@ scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
151scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o 151scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o
152 152
153sd_mod-objs := sd.o 153sd_mod-objs := sd.o
154sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
155
154sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o 156sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
155ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ 157ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
156 := -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \ 158 := -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 8591585e5cc5..218777bfc143 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2278,7 +2278,7 @@ do { \
2278#define ASC_DBG(lvl, format, arg...) { \ 2278#define ASC_DBG(lvl, format, arg...) { \
2279 if (asc_dbglvl >= (lvl)) \ 2279 if (asc_dbglvl >= (lvl)) \
2280 printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \ 2280 printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
2281 __FUNCTION__ , ## arg); \ 2281 __func__ , ## arg); \
2282} 2282}
2283 2283
2284#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \ 2284#define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 0899cb61e3dd..b5a868d85eb4 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -288,20 +288,20 @@ static LIST_HEAD(aha152x_host_list);
288#define DO_LOCK(flags) \ 288#define DO_LOCK(flags) \
289 do { \ 289 do { \
290 if(spin_is_locked(&QLOCK)) { \ 290 if(spin_is_locked(&QLOCK)) { \
291 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ 291 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
292 } \ 292 } \
293 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 293 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
294 spin_lock_irqsave(&QLOCK,flags); \ 294 spin_lock_irqsave(&QLOCK,flags); \
295 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 295 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
296 QLOCKER=__FUNCTION__; \ 296 QLOCKER=__func__; \
297 QLOCKERL=__LINE__; \ 297 QLOCKERL=__LINE__; \
298 } while(0) 298 } while(0)
299 299
300#define DO_UNLOCK(flags) \ 300#define DO_UNLOCK(flags) \
301 do { \ 301 do { \
302 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ 302 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
303 spin_unlock_irqrestore(&QLOCK,flags); \ 303 spin_unlock_irqrestore(&QLOCK,flags); \
304 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 304 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
305 QLOCKER="(not locked)"; \ 305 QLOCKER="(not locked)"; \
306 QLOCKERL=0; \ 306 QLOCKERL=0; \
307 } while(0) 307 } while(0)
diff --git a/drivers/scsi/aic94xx/aic94xx.h b/drivers/scsi/aic94xx/aic94xx.h
index 2ef459e9cda1..2863a9d22851 100644
--- a/drivers/scsi/aic94xx/aic94xx.h
+++ b/drivers/scsi/aic94xx/aic94xx.h
@@ -39,9 +39,9 @@
39 39
40#ifdef ASD_ENTER_EXIT 40#ifdef ASD_ENTER_EXIT
41#define ENTER printk(KERN_NOTICE "%s: ENTER %s\n", ASD_DRIVER_NAME, \ 41#define ENTER printk(KERN_NOTICE "%s: ENTER %s\n", ASD_DRIVER_NAME, \
42 __FUNCTION__) 42 __func__)
43#define EXIT printk(KERN_NOTICE "%s: --EXIT %s\n", ASD_DRIVER_NAME, \ 43#define EXIT printk(KERN_NOTICE "%s: --EXIT %s\n", ASD_DRIVER_NAME, \
44 __FUNCTION__) 44 __func__)
45#else 45#else
46#define ENTER 46#define ENTER
47#define EXIT 47#define EXIT
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index 83a78222896d..eb9dc3195fdf 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -1359,7 +1359,7 @@ int asd_enable_phys(struct asd_ha_struct *asd_ha, const u8 phy_mask)
1359 struct asd_ascb *ascb_list; 1359 struct asd_ascb *ascb_list;
1360 1360
1361 if (!phy_mask) { 1361 if (!phy_mask) {
1362 asd_printk("%s called with phy_mask of 0!?\n", __FUNCTION__); 1362 asd_printk("%s called with phy_mask of 0!?\n", __func__);
1363 return 0; 1363 return 0;
1364 } 1364 }
1365 1365
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index 46643319c520..ca55013b6ae5 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -211,7 +211,7 @@ static void asd_form_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy)
211 phy->asd_port = port; 211 phy->asd_port = port;
212 } 212 }
213 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n", 213 ASD_DPRINTK("%s: updating phy_mask 0x%x for phy%d\n",
214 __FUNCTION__, phy->asd_port->phy_mask, sas_phy->id); 214 __func__, phy->asd_port->phy_mask, sas_phy->id);
215 asd_update_port_links(asd_ha, phy); 215 asd_update_port_links(asd_ha, phy);
216 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); 216 spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags);
217} 217}
@@ -294,7 +294,7 @@ static void asd_link_reset_err_tasklet(struct asd_ascb *ascb,
294 struct asd_ascb *cp = asd_ascb_alloc_list(ascb->ha, &num, 294 struct asd_ascb *cp = asd_ascb_alloc_list(ascb->ha, &num,
295 GFP_ATOMIC); 295 GFP_ATOMIC);
296 if (!cp) { 296 if (!cp) {
297 asd_printk("%s: out of memory\n", __FUNCTION__); 297 asd_printk("%s: out of memory\n", __func__);
298 goto out; 298 goto out;
299 } 299 }
300 ASD_DPRINTK("phy%d: retries:0 performing link reset seq\n", 300 ASD_DPRINTK("phy%d: retries:0 performing link reset seq\n",
@@ -446,7 +446,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
446 struct domain_device *failed_dev = NULL; 446 struct domain_device *failed_dev = NULL;
447 447
448 ASD_DPRINTK("%s: REQ_TASK_ABORT, reason=0x%X\n", 448 ASD_DPRINTK("%s: REQ_TASK_ABORT, reason=0x%X\n",
449 __FUNCTION__, dl->status_block[3]); 449 __func__, dl->status_block[3]);
450 450
451 /* 451 /*
452 * Find the task that caused the abort and abort it first. 452 * Find the task that caused the abort and abort it first.
@@ -474,7 +474,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
474 474
475 if (!failed_dev) { 475 if (!failed_dev) {
476 ASD_DPRINTK("%s: Can't find task (tc=%d) to abort!\n", 476 ASD_DPRINTK("%s: Can't find task (tc=%d) to abort!\n",
477 __FUNCTION__, tc_abort); 477 __func__, tc_abort);
478 goto out; 478 goto out;
479 } 479 }
480 480
@@ -502,7 +502,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
502 conn_handle = *((u16*)(&dl->status_block[1])); 502 conn_handle = *((u16*)(&dl->status_block[1]));
503 conn_handle = le16_to_cpu(conn_handle); 503 conn_handle = le16_to_cpu(conn_handle);
504 504
505 ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __FUNCTION__, 505 ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __func__,
506 dl->status_block[3]); 506 dl->status_block[3]);
507 507
508 /* Find the last pending task for the device... */ 508 /* Find the last pending task for the device... */
@@ -522,7 +522,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
522 522
523 if (!last_dev_task) { 523 if (!last_dev_task) {
524 ASD_DPRINTK("%s: Device reset for idle device %d?\n", 524 ASD_DPRINTK("%s: Device reset for idle device %d?\n",
525 __FUNCTION__, conn_handle); 525 __func__, conn_handle);
526 goto out; 526 goto out;
527 } 527 }
528 528
@@ -549,10 +549,10 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
549 goto out; 549 goto out;
550 } 550 }
551 case SIGNAL_NCQ_ERROR: 551 case SIGNAL_NCQ_ERROR:
552 ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __FUNCTION__); 552 ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __func__);
553 goto out; 553 goto out;
554 case CLEAR_NCQ_ERROR: 554 case CLEAR_NCQ_ERROR:
555 ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __FUNCTION__); 555 ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __func__);
556 goto out; 556 goto out;
557 } 557 }
558 558
@@ -560,26 +560,26 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
560 560
561 switch (sb_opcode) { 561 switch (sb_opcode) {
562 case BYTES_DMAED: 562 case BYTES_DMAED:
563 ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __FUNCTION__, phy_id); 563 ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __func__, phy_id);
564 asd_bytes_dmaed_tasklet(ascb, dl, edb, phy_id); 564 asd_bytes_dmaed_tasklet(ascb, dl, edb, phy_id);
565 break; 565 break;
566 case PRIMITIVE_RECVD: 566 case PRIMITIVE_RECVD:
567 ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __FUNCTION__, 567 ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __func__,
568 phy_id); 568 phy_id);
569 asd_primitive_rcvd_tasklet(ascb, dl, phy_id); 569 asd_primitive_rcvd_tasklet(ascb, dl, phy_id);
570 break; 570 break;
571 case PHY_EVENT: 571 case PHY_EVENT:
572 ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __FUNCTION__, phy_id); 572 ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __func__, phy_id);
573 asd_phy_event_tasklet(ascb, dl); 573 asd_phy_event_tasklet(ascb, dl);
574 break; 574 break;
575 case LINK_RESET_ERROR: 575 case LINK_RESET_ERROR:
576 ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __FUNCTION__, 576 ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __func__,
577 phy_id); 577 phy_id);
578 asd_link_reset_err_tasklet(ascb, dl, phy_id); 578 asd_link_reset_err_tasklet(ascb, dl, phy_id);
579 break; 579 break;
580 case TIMER_EVENT: 580 case TIMER_EVENT:
581 ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n", 581 ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n",
582 __FUNCTION__, phy_id); 582 __func__, phy_id);
583 asd_turn_led(asd_ha, phy_id, 0); 583 asd_turn_led(asd_ha, phy_id, 0);
584 /* the device is gone */ 584 /* the device is gone */
585 sas_phy_disconnected(sas_phy); 585 sas_phy_disconnected(sas_phy);
@@ -587,7 +587,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
587 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 587 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
588 break; 588 break;
589 default: 589 default:
590 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__, 590 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __func__,
591 phy_id, sb_opcode); 591 phy_id, sb_opcode);
592 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n", 592 ASD_DPRINTK("edb is 0x%x! dl->opcode is 0x%x\n",
593 edb, dl->opcode); 593 edb, dl->opcode);
@@ -654,7 +654,7 @@ static void control_phy_tasklet_complete(struct asd_ascb *ascb,
654 654
655 if (status != 0) { 655 if (status != 0) {
656 ASD_DPRINTK("%s: phy%d status block opcode:0x%x\n", 656 ASD_DPRINTK("%s: phy%d status block opcode:0x%x\n",
657 __FUNCTION__, phy_id, status); 657 __func__, phy_id, status);
658 goto out; 658 goto out;
659 } 659 }
660 660
@@ -663,7 +663,7 @@ static void control_phy_tasklet_complete(struct asd_ascb *ascb,
663 asd_ha->hw_prof.enabled_phys &= ~(1 << phy_id); 663 asd_ha->hw_prof.enabled_phys &= ~(1 << phy_id);
664 asd_turn_led(asd_ha, phy_id, 0); 664 asd_turn_led(asd_ha, phy_id, 0);
665 asd_control_led(asd_ha, phy_id, 0); 665 asd_control_led(asd_ha, phy_id, 0);
666 ASD_DPRINTK("%s: disable phy%d\n", __FUNCTION__, phy_id); 666 ASD_DPRINTK("%s: disable phy%d\n", __func__, phy_id);
667 break; 667 break;
668 668
669 case ENABLE_PHY: 669 case ENABLE_PHY:
@@ -673,40 +673,40 @@ static void control_phy_tasklet_complete(struct asd_ascb *ascb,
673 get_lrate_mode(phy, oob_mode); 673 get_lrate_mode(phy, oob_mode);
674 asd_turn_led(asd_ha, phy_id, 1); 674 asd_turn_led(asd_ha, phy_id, 1);
675 ASD_DPRINTK("%s: phy%d, lrate:0x%x, proto:0x%x\n", 675 ASD_DPRINTK("%s: phy%d, lrate:0x%x, proto:0x%x\n",
676 __FUNCTION__, phy_id,phy->sas_phy.linkrate, 676 __func__, phy_id,phy->sas_phy.linkrate,
677 phy->sas_phy.iproto); 677 phy->sas_phy.iproto);
678 } else if (oob_status & CURRENT_SPINUP_HOLD) { 678 } else if (oob_status & CURRENT_SPINUP_HOLD) {
679 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); 679 asd_ha->hw_prof.enabled_phys |= (1 << phy_id);
680 asd_turn_led(asd_ha, phy_id, 1); 680 asd_turn_led(asd_ha, phy_id, 1);
681 ASD_DPRINTK("%s: phy%d, spinup hold\n", __FUNCTION__, 681 ASD_DPRINTK("%s: phy%d, spinup hold\n", __func__,
682 phy_id); 682 phy_id);
683 } else if (oob_status & CURRENT_ERR_MASK) { 683 } else if (oob_status & CURRENT_ERR_MASK) {
684 asd_turn_led(asd_ha, phy_id, 0); 684 asd_turn_led(asd_ha, phy_id, 0);
685 ASD_DPRINTK("%s: phy%d: error: oob status:0x%02x\n", 685 ASD_DPRINTK("%s: phy%d: error: oob status:0x%02x\n",
686 __FUNCTION__, phy_id, oob_status); 686 __func__, phy_id, oob_status);
687 } else if (oob_status & (CURRENT_HOT_PLUG_CNCT 687 } else if (oob_status & (CURRENT_HOT_PLUG_CNCT
688 | CURRENT_DEVICE_PRESENT)) { 688 | CURRENT_DEVICE_PRESENT)) {
689 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); 689 asd_ha->hw_prof.enabled_phys |= (1 << phy_id);
690 asd_turn_led(asd_ha, phy_id, 1); 690 asd_turn_led(asd_ha, phy_id, 1);
691 ASD_DPRINTK("%s: phy%d: hot plug or device present\n", 691 ASD_DPRINTK("%s: phy%d: hot plug or device present\n",
692 __FUNCTION__, phy_id); 692 __func__, phy_id);
693 } else { 693 } else {
694 asd_ha->hw_prof.enabled_phys |= (1 << phy_id); 694 asd_ha->hw_prof.enabled_phys |= (1 << phy_id);
695 asd_turn_led(asd_ha, phy_id, 0); 695 asd_turn_led(asd_ha, phy_id, 0);
696 ASD_DPRINTK("%s: phy%d: no device present: " 696 ASD_DPRINTK("%s: phy%d: no device present: "
697 "oob_status:0x%x\n", 697 "oob_status:0x%x\n",
698 __FUNCTION__, phy_id, oob_status); 698 __func__, phy_id, oob_status);
699 } 699 }
700 break; 700 break;
701 case RELEASE_SPINUP_HOLD: 701 case RELEASE_SPINUP_HOLD:
702 case PHY_NO_OP: 702 case PHY_NO_OP:
703 case EXECUTE_HARD_RESET: 703 case EXECUTE_HARD_RESET:
704 ASD_DPRINTK("%s: phy%d: sub_func:0x%x\n", __FUNCTION__, 704 ASD_DPRINTK("%s: phy%d: sub_func:0x%x\n", __func__,
705 phy_id, control_phy->sub_func); 705 phy_id, control_phy->sub_func);
706 /* XXX finish */ 706 /* XXX finish */
707 break; 707 break;
708 default: 708 default:
709 ASD_DPRINTK("%s: phy%d: sub_func:0x%x?\n", __FUNCTION__, 709 ASD_DPRINTK("%s: phy%d: sub_func:0x%x?\n", __func__,
710 phy_id, control_phy->sub_func); 710 phy_id, control_phy->sub_func);
711 break; 711 break;
712 } 712 }
diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 326765c9caf8..75d20f72501f 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -320,7 +320,7 @@ Again:
320 case TC_RESUME: 320 case TC_RESUME:
321 case TC_PARTIAL_SG_LIST: 321 case TC_PARTIAL_SG_LIST:
322 default: 322 default:
323 ASD_DPRINTK("%s: dl opcode: 0x%x?\n", __FUNCTION__, opcode); 323 ASD_DPRINTK("%s: dl opcode: 0x%x?\n", __func__, opcode);
324 break; 324 break;
325 } 325 }
326 326
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index 633ff40c736a..d4640ef6d44f 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -75,12 +75,12 @@ static void asd_clear_nexus_tasklet_complete(struct asd_ascb *ascb,
75 struct done_list_struct *dl) 75 struct done_list_struct *dl)
76{ 76{
77 struct tasklet_completion_status *tcs = ascb->uldd_task; 77 struct tasklet_completion_status *tcs = ascb->uldd_task;
78 ASD_DPRINTK("%s: here\n", __FUNCTION__); 78 ASD_DPRINTK("%s: here\n", __func__);
79 if (!del_timer(&ascb->timer)) { 79 if (!del_timer(&ascb->timer)) {
80 ASD_DPRINTK("%s: couldn't delete timer\n", __FUNCTION__); 80 ASD_DPRINTK("%s: couldn't delete timer\n", __func__);
81 return; 81 return;
82 } 82 }
83 ASD_DPRINTK("%s: opcode: 0x%x\n", __FUNCTION__, dl->opcode); 83 ASD_DPRINTK("%s: opcode: 0x%x\n", __func__, dl->opcode);
84 tcs->dl_opcode = dl->opcode; 84 tcs->dl_opcode = dl->opcode;
85 complete(ascb->completion); 85 complete(ascb->completion);
86 asd_ascb_free(ascb); 86 asd_ascb_free(ascb);
@@ -91,7 +91,7 @@ static void asd_clear_nexus_timedout(unsigned long data)
91 struct asd_ascb *ascb = (void *)data; 91 struct asd_ascb *ascb = (void *)data;
92 struct tasklet_completion_status *tcs = ascb->uldd_task; 92 struct tasklet_completion_status *tcs = ascb->uldd_task;
93 93
94 ASD_DPRINTK("%s: here\n", __FUNCTION__); 94 ASD_DPRINTK("%s: here\n", __func__);
95 tcs->dl_opcode = TMF_RESP_FUNC_FAILED; 95 tcs->dl_opcode = TMF_RESP_FUNC_FAILED;
96 complete(ascb->completion); 96 complete(ascb->completion);
97} 97}
@@ -103,7 +103,7 @@ static void asd_clear_nexus_timedout(unsigned long data)
103 DECLARE_COMPLETION_ONSTACK(completion); \ 103 DECLARE_COMPLETION_ONSTACK(completion); \
104 DECLARE_TCS(tcs); \ 104 DECLARE_TCS(tcs); \
105 \ 105 \
106 ASD_DPRINTK("%s: PRE\n", __FUNCTION__); \ 106 ASD_DPRINTK("%s: PRE\n", __func__); \
107 res = 1; \ 107 res = 1; \
108 ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL); \ 108 ascb = asd_ascb_alloc_list(asd_ha, &res, GFP_KERNEL); \
109 if (!ascb) \ 109 if (!ascb) \
@@ -115,12 +115,12 @@ static void asd_clear_nexus_timedout(unsigned long data)
115 scb->header.opcode = CLEAR_NEXUS 115 scb->header.opcode = CLEAR_NEXUS
116 116
117#define CLEAR_NEXUS_POST \ 117#define CLEAR_NEXUS_POST \
118 ASD_DPRINTK("%s: POST\n", __FUNCTION__); \ 118 ASD_DPRINTK("%s: POST\n", __func__); \
119 res = asd_enqueue_internal(ascb, asd_clear_nexus_tasklet_complete, \ 119 res = asd_enqueue_internal(ascb, asd_clear_nexus_tasklet_complete, \
120 asd_clear_nexus_timedout); \ 120 asd_clear_nexus_timedout); \
121 if (res) \ 121 if (res) \
122 goto out_err; \ 122 goto out_err; \
123 ASD_DPRINTK("%s: clear nexus posted, waiting...\n", __FUNCTION__); \ 123 ASD_DPRINTK("%s: clear nexus posted, waiting...\n", __func__); \
124 wait_for_completion(&completion); \ 124 wait_for_completion(&completion); \
125 res = tcs.dl_opcode; \ 125 res = tcs.dl_opcode; \
126 if (res == TC_NO_ERROR) \ 126 if (res == TC_NO_ERROR) \
@@ -417,7 +417,7 @@ int asd_abort_task(struct sas_task *task)
417 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 417 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
418 spin_unlock_irqrestore(&task->task_state_lock, flags); 418 spin_unlock_irqrestore(&task->task_state_lock, flags);
419 res = TMF_RESP_FUNC_COMPLETE; 419 res = TMF_RESP_FUNC_COMPLETE;
420 ASD_DPRINTK("%s: task 0x%p done\n", __FUNCTION__, task); 420 ASD_DPRINTK("%s: task 0x%p done\n", __func__, task);
421 goto out_done; 421 goto out_done;
422 } 422 }
423 spin_unlock_irqrestore(&task->task_state_lock, flags); 423 spin_unlock_irqrestore(&task->task_state_lock, flags);
@@ -481,7 +481,7 @@ int asd_abort_task(struct sas_task *task)
481 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 481 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
482 spin_unlock_irqrestore(&task->task_state_lock, flags); 482 spin_unlock_irqrestore(&task->task_state_lock, flags);
483 res = TMF_RESP_FUNC_COMPLETE; 483 res = TMF_RESP_FUNC_COMPLETE;
484 ASD_DPRINTK("%s: task 0x%p done\n", __FUNCTION__, task); 484 ASD_DPRINTK("%s: task 0x%p done\n", __func__, task);
485 goto out_done; 485 goto out_done;
486 } 486 }
487 spin_unlock_irqrestore(&task->task_state_lock, flags); 487 spin_unlock_irqrestore(&task->task_state_lock, flags);
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index a715632e19d4..477542602284 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -240,7 +240,7 @@ static void __fas216_checkmagic(FAS216_Info *info, const char *func)
240 panic("scsi memory space corrupted in %s", func); 240 panic("scsi memory space corrupted in %s", func);
241 } 241 }
242} 242}
243#define fas216_checkmagic(info) __fas216_checkmagic((info), __FUNCTION__) 243#define fas216_checkmagic(info) __fas216_checkmagic((info), __func__)
244#else 244#else
245#define fas216_checkmagic(info) 245#define fas216_checkmagic(info)
246#endif 246#endif
@@ -2658,7 +2658,7 @@ int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
2658 fas216_checkmagic(info); 2658 fas216_checkmagic(info);
2659 2659
2660 printk("scsi%d.%c: %s: resetting host\n", 2660 printk("scsi%d.%c: %s: resetting host\n",
2661 info->host->host_no, '0' + SCpnt->device->id, __FUNCTION__); 2661 info->host->host_no, '0' + SCpnt->device->id, __func__);
2662 2662
2663 /* 2663 /*
2664 * Reset the SCSI chip. 2664 * Reset the SCSI chip.
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index aa2011b64683..3c257fe0893e 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -930,6 +930,7 @@ static int ch_probe(struct device *dev)
930 if (init) 930 if (init)
931 ch_init_elem(ch); 931 ch_init_elem(ch);
932 932
933 dev_set_drvdata(dev, ch);
933 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name); 934 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
934 935
935 return 0; 936 return 0;
diff --git a/drivers/scsi/device_handler/Kconfig b/drivers/scsi/device_handler/Kconfig
index 2adc0f666b68..67070257919f 100644
--- a/drivers/scsi/device_handler/Kconfig
+++ b/drivers/scsi/device_handler/Kconfig
@@ -30,3 +30,11 @@ config SCSI_DH_EMC
30 depends on SCSI_DH 30 depends on SCSI_DH
31 help 31 help
32 If you have a EMC CLARiiON select y. Otherwise, say N. 32 If you have a EMC CLARiiON select y. Otherwise, say N.
33
34config SCSI_DH_ALUA
35 tristate "SPC-3 ALUA Device Handler (EXPERIMENTAL)"
36 depends on SCSI_DH && EXPERIMENTAL
37 help
38 SCSI Device handler for generic SPC-3 Asymmetric Logical Unit
39 Access (ALUA).
40
diff --git a/drivers/scsi/device_handler/Makefile b/drivers/scsi/device_handler/Makefile
index 35272e93b1c8..e1d2ea083e15 100644
--- a/drivers/scsi/device_handler/Makefile
+++ b/drivers/scsi/device_handler/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_SCSI_DH) += scsi_dh.o
5obj-$(CONFIG_SCSI_DH_RDAC) += scsi_dh_rdac.o 5obj-$(CONFIG_SCSI_DH_RDAC) += scsi_dh_rdac.o
6obj-$(CONFIG_SCSI_DH_HP_SW) += scsi_dh_hp_sw.o 6obj-$(CONFIG_SCSI_DH_HP_SW) += scsi_dh_hp_sw.o
7obj-$(CONFIG_SCSI_DH_EMC) += scsi_dh_emc.o 7obj-$(CONFIG_SCSI_DH_EMC) += scsi_dh_emc.o
8obj-$(CONFIG_SCSI_DH_ALUA) += scsi_dh_alua.o
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index ab6c21cd9689..a518f2eff19a 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -24,8 +24,16 @@
24#include <scsi/scsi_dh.h> 24#include <scsi/scsi_dh.h>
25#include "../scsi_priv.h" 25#include "../scsi_priv.h"
26 26
27struct scsi_dh_devinfo_list {
28 struct list_head node;
29 char vendor[9];
30 char model[17];
31 struct scsi_device_handler *handler;
32};
33
27static DEFINE_SPINLOCK(list_lock); 34static DEFINE_SPINLOCK(list_lock);
28static LIST_HEAD(scsi_dh_list); 35static LIST_HEAD(scsi_dh_list);
36static LIST_HEAD(scsi_dh_dev_list);
29 37
30static struct scsi_device_handler *get_device_handler(const char *name) 38static struct scsi_device_handler *get_device_handler(const char *name)
31{ 39{
@@ -33,7 +41,7 @@ static struct scsi_device_handler *get_device_handler(const char *name)
33 41
34 spin_lock(&list_lock); 42 spin_lock(&list_lock);
35 list_for_each_entry(tmp, &scsi_dh_list, list) { 43 list_for_each_entry(tmp, &scsi_dh_list, list) {
36 if (!strcmp(tmp->name, name)) { 44 if (!strncmp(tmp->name, name, strlen(tmp->name))) {
37 found = tmp; 45 found = tmp;
38 break; 46 break;
39 } 47 }
@@ -42,11 +50,307 @@ static struct scsi_device_handler *get_device_handler(const char *name)
42 return found; 50 return found;
43} 51}
44 52
53
54static struct scsi_device_handler *
55scsi_dh_cache_lookup(struct scsi_device *sdev)
56{
57 struct scsi_dh_devinfo_list *tmp;
58 struct scsi_device_handler *found_dh = NULL;
59
60 spin_lock(&list_lock);
61 list_for_each_entry(tmp, &scsi_dh_dev_list, node) {
62 if (!strncmp(sdev->vendor, tmp->vendor, strlen(tmp->vendor)) &&
63 !strncmp(sdev->model, tmp->model, strlen(tmp->model))) {
64 found_dh = tmp->handler;
65 break;
66 }
67 }
68 spin_unlock(&list_lock);
69
70 return found_dh;
71}
72
73static int scsi_dh_handler_lookup(struct scsi_device_handler *scsi_dh,
74 struct scsi_device *sdev)
75{
76 int i, found = 0;
77
78 for(i = 0; scsi_dh->devlist[i].vendor; i++) {
79 if (!strncmp(sdev->vendor, scsi_dh->devlist[i].vendor,
80 strlen(scsi_dh->devlist[i].vendor)) &&
81 !strncmp(sdev->model, scsi_dh->devlist[i].model,
82 strlen(scsi_dh->devlist[i].model))) {
83 found = 1;
84 break;
85 }
86 }
87 return found;
88}
89
90/*
91 * device_handler_match - Attach a device handler to a device
92 * @scsi_dh - The device handler to match against or NULL
93 * @sdev - SCSI device to be tested against @scsi_dh
94 *
95 * Tests @sdev against the device handler @scsi_dh or against
96 * all registered device_handler if @scsi_dh == NULL.
97 * Returns the found device handler or NULL if not found.
98 */
99static struct scsi_device_handler *
100device_handler_match(struct scsi_device_handler *scsi_dh,
101 struct scsi_device *sdev)
102{
103 struct scsi_device_handler *found_dh = NULL;
104 struct scsi_dh_devinfo_list *tmp;
105
106 found_dh = scsi_dh_cache_lookup(sdev);
107 if (found_dh)
108 return found_dh;
109
110 if (scsi_dh) {
111 if (scsi_dh_handler_lookup(scsi_dh, sdev))
112 found_dh = scsi_dh;
113 } else {
114 struct scsi_device_handler *tmp_dh;
115
116 spin_lock(&list_lock);
117 list_for_each_entry(tmp_dh, &scsi_dh_list, list) {
118 if (scsi_dh_handler_lookup(tmp_dh, sdev))
119 found_dh = tmp_dh;
120 }
121 spin_unlock(&list_lock);
122 }
123
124 if (found_dh) { /* If device is found, add it to the cache */
125 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
126 if (tmp) {
127 strncpy(tmp->vendor, sdev->vendor, 8);
128 strncpy(tmp->model, sdev->model, 16);
129 tmp->vendor[8] = '\0';
130 tmp->model[16] = '\0';
131 tmp->handler = found_dh;
132 spin_lock(&list_lock);
133 list_add(&tmp->node, &scsi_dh_dev_list);
134 spin_unlock(&list_lock);
135 } else {
136 found_dh = NULL;
137 }
138 }
139
140 return found_dh;
141}
142
143/*
144 * scsi_dh_handler_attach - Attach a device handler to a device
145 * @sdev - SCSI device the device handler should attach to
146 * @scsi_dh - The device handler to attach
147 */
148static int scsi_dh_handler_attach(struct scsi_device *sdev,
149 struct scsi_device_handler *scsi_dh)
150{
151 int err = 0;
152
153 if (sdev->scsi_dh_data) {
154 if (sdev->scsi_dh_data->scsi_dh != scsi_dh)
155 err = -EBUSY;
156 } else if (scsi_dh->attach)
157 err = scsi_dh->attach(sdev);
158
159 return err;
160}
161
162/*
163 * scsi_dh_handler_detach - Detach a device handler from a device
164 * @sdev - SCSI device the device handler should be detached from
165 * @scsi_dh - Device handler to be detached
166 *
167 * Detach from a device handler. If a device handler is specified,
168 * only detach if the currently attached handler matches @scsi_dh.
169 */
170static void scsi_dh_handler_detach(struct scsi_device *sdev,
171 struct scsi_device_handler *scsi_dh)
172{
173 if (!sdev->scsi_dh_data)
174 return;
175
176 if (scsi_dh && scsi_dh != sdev->scsi_dh_data->scsi_dh)
177 return;
178
179 if (!scsi_dh)
180 scsi_dh = sdev->scsi_dh_data->scsi_dh;
181
182 if (scsi_dh && scsi_dh->detach)
183 scsi_dh->detach(sdev);
184}
185
186/*
187 * Functions for sysfs attribute 'dh_state'
188 */
189static ssize_t
190store_dh_state(struct device *dev, struct device_attribute *attr,
191 const char *buf, size_t count)
192{
193 struct scsi_device *sdev = to_scsi_device(dev);
194 struct scsi_device_handler *scsi_dh;
195 int err = -EINVAL;
196
197 if (!sdev->scsi_dh_data) {
198 /*
199 * Attach to a device handler
200 */
201 if (!(scsi_dh = get_device_handler(buf)))
202 return err;
203 err = scsi_dh_handler_attach(sdev, scsi_dh);
204 } else {
205 scsi_dh = sdev->scsi_dh_data->scsi_dh;
206 if (!strncmp(buf, "detach", 6)) {
207 /*
208 * Detach from a device handler
209 */
210 scsi_dh_handler_detach(sdev, scsi_dh);
211 err = 0;
212 } else if (!strncmp(buf, "activate", 8)) {
213 /*
214 * Activate a device handler
215 */
216 if (scsi_dh->activate)
217 err = scsi_dh->activate(sdev);
218 else
219 err = 0;
220 }
221 }
222
223 return err<0?err:count;
224}
225
226static ssize_t
227show_dh_state(struct device *dev, struct device_attribute *attr, char *buf)
228{
229 struct scsi_device *sdev = to_scsi_device(dev);
230
231 if (!sdev->scsi_dh_data)
232 return snprintf(buf, 20, "detached\n");
233
234 return snprintf(buf, 20, "%s\n", sdev->scsi_dh_data->scsi_dh->name);
235}
236
237static struct device_attribute scsi_dh_state_attr =
238 __ATTR(dh_state, S_IRUGO | S_IWUSR, show_dh_state,
239 store_dh_state);
240
241/*
242 * scsi_dh_sysfs_attr_add - Callback for scsi_init_dh
243 */
244static int scsi_dh_sysfs_attr_add(struct device *dev, void *data)
245{
246 struct scsi_device *sdev;
247 int err;
248
249 if (!scsi_is_sdev_device(dev))
250 return 0;
251
252 sdev = to_scsi_device(dev);
253
254 err = device_create_file(&sdev->sdev_gendev,
255 &scsi_dh_state_attr);
256
257 return 0;
258}
259
260/*
261 * scsi_dh_sysfs_attr_remove - Callback for scsi_exit_dh
262 */
263static int scsi_dh_sysfs_attr_remove(struct device *dev, void *data)
264{
265 struct scsi_device *sdev;
266
267 if (!scsi_is_sdev_device(dev))
268 return 0;
269
270 sdev = to_scsi_device(dev);
271
272 device_remove_file(&sdev->sdev_gendev,
273 &scsi_dh_state_attr);
274
275 return 0;
276}
277
278/*
279 * scsi_dh_notifier - notifier chain callback
280 */
281static int scsi_dh_notifier(struct notifier_block *nb,
282 unsigned long action, void *data)
283{
284 struct device *dev = data;
285 struct scsi_device *sdev;
286 int err = 0;
287 struct scsi_device_handler *devinfo = NULL;
288
289 if (!scsi_is_sdev_device(dev))
290 return 0;
291
292 sdev = to_scsi_device(dev);
293
294 if (action == BUS_NOTIFY_ADD_DEVICE) {
295 devinfo = device_handler_match(NULL, sdev);
296 if (!devinfo)
297 goto out;
298
299 err = scsi_dh_handler_attach(sdev, devinfo);
300 if (!err)
301 err = device_create_file(dev, &scsi_dh_state_attr);
302 } else if (action == BUS_NOTIFY_DEL_DEVICE) {
303 device_remove_file(dev, &scsi_dh_state_attr);
304 scsi_dh_handler_detach(sdev, NULL);
305 }
306out:
307 return err;
308}
309
310/*
311 * scsi_dh_notifier_add - Callback for scsi_register_device_handler
312 */
45static int scsi_dh_notifier_add(struct device *dev, void *data) 313static int scsi_dh_notifier_add(struct device *dev, void *data)
46{ 314{
47 struct scsi_device_handler *scsi_dh = data; 315 struct scsi_device_handler *scsi_dh = data;
316 struct scsi_device *sdev;
317
318 if (!scsi_is_sdev_device(dev))
319 return 0;
320
321 if (!get_device(dev))
322 return 0;
323
324 sdev = to_scsi_device(dev);
325
326 if (device_handler_match(scsi_dh, sdev))
327 scsi_dh_handler_attach(sdev, scsi_dh);
328
329 put_device(dev);
330
331 return 0;
332}
333
334/*
335 * scsi_dh_notifier_remove - Callback for scsi_unregister_device_handler
336 */
337static int scsi_dh_notifier_remove(struct device *dev, void *data)
338{
339 struct scsi_device_handler *scsi_dh = data;
340 struct scsi_device *sdev;
341
342 if (!scsi_is_sdev_device(dev))
343 return 0;
344
345 if (!get_device(dev))
346 return 0;
347
348 sdev = to_scsi_device(dev);
349
350 scsi_dh_handler_detach(sdev, scsi_dh);
351
352 put_device(dev);
48 353
49 scsi_dh->nb.notifier_call(&scsi_dh->nb, BUS_NOTIFY_ADD_DEVICE, dev);
50 return 0; 354 return 0;
51} 355}
52 356
@@ -59,33 +363,19 @@ static int scsi_dh_notifier_add(struct device *dev, void *data)
59 */ 363 */
60int scsi_register_device_handler(struct scsi_device_handler *scsi_dh) 364int scsi_register_device_handler(struct scsi_device_handler *scsi_dh)
61{ 365{
62 int ret = -EBUSY; 366 if (get_device_handler(scsi_dh->name))
63 struct scsi_device_handler *tmp; 367 return -EBUSY;
64 368
65 tmp = get_device_handler(scsi_dh->name);
66 if (tmp)
67 goto done;
68
69 ret = bus_register_notifier(&scsi_bus_type, &scsi_dh->nb);
70
71 bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, scsi_dh_notifier_add);
72 spin_lock(&list_lock); 369 spin_lock(&list_lock);
73 list_add(&scsi_dh->list, &scsi_dh_list); 370 list_add(&scsi_dh->list, &scsi_dh_list);
74 spin_unlock(&list_lock); 371 spin_unlock(&list_lock);
372 bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, scsi_dh_notifier_add);
373 printk(KERN_INFO "%s: device handler registered\n", scsi_dh->name);
75 374
76done: 375 return SCSI_DH_OK;
77 return ret;
78} 376}
79EXPORT_SYMBOL_GPL(scsi_register_device_handler); 377EXPORT_SYMBOL_GPL(scsi_register_device_handler);
80 378
81static int scsi_dh_notifier_remove(struct device *dev, void *data)
82{
83 struct scsi_device_handler *scsi_dh = data;
84
85 scsi_dh->nb.notifier_call(&scsi_dh->nb, BUS_NOTIFY_DEL_DEVICE, dev);
86 return 0;
87}
88
89/* 379/*
90 * scsi_unregister_device_handler - register a device handler personality 380 * scsi_unregister_device_handler - register a device handler personality
91 * module. 381 * module.
@@ -95,23 +385,26 @@ static int scsi_dh_notifier_remove(struct device *dev, void *data)
95 */ 385 */
96int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) 386int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh)
97{ 387{
98 int ret = -ENODEV; 388 struct scsi_dh_devinfo_list *tmp, *pos;
99 struct scsi_device_handler *tmp;
100
101 tmp = get_device_handler(scsi_dh->name);
102 if (!tmp)
103 goto done;
104 389
105 ret = bus_unregister_notifier(&scsi_bus_type, &scsi_dh->nb); 390 if (!get_device_handler(scsi_dh->name))
391 return -ENODEV;
106 392
107 bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, 393 bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh,
108 scsi_dh_notifier_remove); 394 scsi_dh_notifier_remove);
395
109 spin_lock(&list_lock); 396 spin_lock(&list_lock);
110 list_del(&scsi_dh->list); 397 list_del(&scsi_dh->list);
398 list_for_each_entry_safe(pos, tmp, &scsi_dh_dev_list, node) {
399 if (pos->handler == scsi_dh) {
400 list_del(&pos->node);
401 kfree(pos);
402 }
403 }
111 spin_unlock(&list_lock); 404 spin_unlock(&list_lock);
405 printk(KERN_INFO "%s: device handler unregistered\n", scsi_dh->name);
112 406
113done: 407 return SCSI_DH_OK;
114 return ret;
115} 408}
116EXPORT_SYMBOL_GPL(scsi_unregister_device_handler); 409EXPORT_SYMBOL_GPL(scsi_unregister_device_handler);
117 410
@@ -157,6 +450,97 @@ int scsi_dh_handler_exist(const char *name)
157} 450}
158EXPORT_SYMBOL_GPL(scsi_dh_handler_exist); 451EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);
159 452
453/*
454 * scsi_dh_handler_attach - Attach device handler
455 * @sdev - sdev the handler should be attached to
456 * @name - name of the handler to attach
457 */
458int scsi_dh_attach(struct request_queue *q, const char *name)
459{
460 unsigned long flags;
461 struct scsi_device *sdev;
462 struct scsi_device_handler *scsi_dh;
463 int err = 0;
464
465 scsi_dh = get_device_handler(name);
466 if (!scsi_dh)
467 return -EINVAL;
468
469 spin_lock_irqsave(q->queue_lock, flags);
470 sdev = q->queuedata;
471 if (!sdev || !get_device(&sdev->sdev_gendev))
472 err = -ENODEV;
473 spin_unlock_irqrestore(q->queue_lock, flags);
474
475 if (!err) {
476 err = scsi_dh_handler_attach(sdev, scsi_dh);
477
478 put_device(&sdev->sdev_gendev);
479 }
480 return err;
481}
482EXPORT_SYMBOL_GPL(scsi_dh_attach);
483
484/*
485 * scsi_dh_handler_detach - Detach device handler
486 * @sdev - sdev the handler should be detached from
487 *
488 * This function will detach the device handler only
489 * if the sdev is not part of the internal list, ie
490 * if it has been attached manually.
491 */
492void scsi_dh_detach(struct request_queue *q)
493{
494 unsigned long flags;
495 struct scsi_device *sdev;
496 struct scsi_device_handler *scsi_dh = NULL;
497
498 spin_lock_irqsave(q->queue_lock, flags);
499 sdev = q->queuedata;
500 if (!sdev || !get_device(&sdev->sdev_gendev))
501 sdev = NULL;
502 spin_unlock_irqrestore(q->queue_lock, flags);
503
504 if (!sdev)
505 return;
506
507 if (sdev->scsi_dh_data) {
508 /* if sdev is not on internal list, detach */
509 scsi_dh = sdev->scsi_dh_data->scsi_dh;
510 if (!device_handler_match(scsi_dh, sdev))
511 scsi_dh_handler_detach(sdev, scsi_dh);
512 }
513 put_device(&sdev->sdev_gendev);
514}
515EXPORT_SYMBOL_GPL(scsi_dh_detach);
516
517static struct notifier_block scsi_dh_nb = {
518 .notifier_call = scsi_dh_notifier
519};
520
521static int __init scsi_dh_init(void)
522{
523 int r;
524
525 r = bus_register_notifier(&scsi_bus_type, &scsi_dh_nb);
526
527 if (!r)
528 bus_for_each_dev(&scsi_bus_type, NULL, NULL,
529 scsi_dh_sysfs_attr_add);
530
531 return r;
532}
533
534static void __exit scsi_dh_exit(void)
535{
536 bus_for_each_dev(&scsi_bus_type, NULL, NULL,
537 scsi_dh_sysfs_attr_remove);
538 bus_unregister_notifier(&scsi_bus_type, &scsi_dh_nb);
539}
540
541module_init(scsi_dh_init);
542module_exit(scsi_dh_exit);
543
160MODULE_DESCRIPTION("SCSI device handler"); 544MODULE_DESCRIPTION("SCSI device handler");
161MODULE_AUTHOR("Chandra Seetharaman <sekharan@us.ibm.com>"); 545MODULE_AUTHOR("Chandra Seetharaman <sekharan@us.ibm.com>");
162MODULE_LICENSE("GPL"); 546MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
new file mode 100644
index 000000000000..fcdd73f25625
--- /dev/null
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -0,0 +1,802 @@
1/*
2 * Generic SCSI-3 ALUA SCSI Device Handler
3 *
4 * Copyright (C) 2007, 2008 Hannes Reinecke, SUSE Linux Products GmbH.
5 * All rights reserved.
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
10 * (at your option) any later version.
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#include <scsi/scsi.h>
23#include <scsi/scsi_eh.h>
24#include <scsi/scsi_dh.h>
25
26#define ALUA_DH_NAME "alua"
27#define ALUA_DH_VER "1.2"
28
29#define TPGS_STATE_OPTIMIZED 0x0
30#define TPGS_STATE_NONOPTIMIZED 0x1
31#define TPGS_STATE_STANDBY 0x2
32#define TPGS_STATE_UNAVAILABLE 0x3
33#define TPGS_STATE_OFFLINE 0xe
34#define TPGS_STATE_TRANSITIONING 0xf
35
36#define TPGS_SUPPORT_NONE 0x00
37#define TPGS_SUPPORT_OPTIMIZED 0x01
38#define TPGS_SUPPORT_NONOPTIMIZED 0x02
39#define TPGS_SUPPORT_STANDBY 0x04
40#define TPGS_SUPPORT_UNAVAILABLE 0x08
41#define TPGS_SUPPORT_OFFLINE 0x40
42#define TPGS_SUPPORT_TRANSITION 0x80
43
44#define TPGS_MODE_UNINITIALIZED -1
45#define TPGS_MODE_NONE 0x0
46#define TPGS_MODE_IMPLICIT 0x1
47#define TPGS_MODE_EXPLICIT 0x2
48
49#define ALUA_INQUIRY_SIZE 36
50#define ALUA_FAILOVER_TIMEOUT (60 * HZ)
51#define ALUA_FAILOVER_RETRIES 5
52
53struct alua_dh_data {
54 int group_id;
55 int rel_port;
56 int tpgs;
57 int state;
58 unsigned char inq[ALUA_INQUIRY_SIZE];
59 unsigned char *buff;
60 int bufflen;
61 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
62 int senselen;
63};
64
65#define ALUA_POLICY_SWITCH_CURRENT 0
66#define ALUA_POLICY_SWITCH_ALL 1
67
68static inline struct alua_dh_data *get_alua_data(struct scsi_device *sdev)
69{
70 struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data;
71 BUG_ON(scsi_dh_data == NULL);
72 return ((struct alua_dh_data *) scsi_dh_data->buf);
73}
74
75static int realloc_buffer(struct alua_dh_data *h, unsigned len)
76{
77 if (h->buff && h->buff != h->inq)
78 kfree(h->buff);
79
80 h->buff = kmalloc(len, GFP_NOIO);
81 if (!h->buff) {
82 h->buff = h->inq;
83 h->bufflen = ALUA_INQUIRY_SIZE;
84 return 1;
85 }
86 h->bufflen = len;
87 return 0;
88}
89
90static struct request *get_alua_req(struct scsi_device *sdev,
91 void *buffer, unsigned buflen, int rw)
92{
93 struct request *rq;
94 struct request_queue *q = sdev->request_queue;
95
96 rq = blk_get_request(q, rw, GFP_NOIO);
97
98 if (!rq) {
99 sdev_printk(KERN_INFO, sdev,
100 "%s: blk_get_request failed\n", __func__);
101 return NULL;
102 }
103
104 if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_NOIO)) {
105 blk_put_request(rq);
106 sdev_printk(KERN_INFO, sdev,
107 "%s: blk_rq_map_kern failed\n", __func__);
108 return NULL;
109 }
110
111 rq->cmd_type = REQ_TYPE_BLOCK_PC;
112 rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE;
113 rq->retries = ALUA_FAILOVER_RETRIES;
114 rq->timeout = ALUA_FAILOVER_TIMEOUT;
115
116 return rq;
117}
118
119/*
120 * submit_std_inquiry - Issue a standard INQUIRY command
121 * @sdev: sdev the command should be send to
122 */
123static int submit_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
124{
125 struct request *rq;
126 int err = SCSI_DH_RES_TEMP_UNAVAIL;
127
128 rq = get_alua_req(sdev, h->inq, ALUA_INQUIRY_SIZE, READ);
129 if (!rq)
130 goto done;
131
132 /* Prepare the command. */
133 rq->cmd[0] = INQUIRY;
134 rq->cmd[1] = 0;
135 rq->cmd[2] = 0;
136 rq->cmd[4] = ALUA_INQUIRY_SIZE;
137 rq->cmd_len = COMMAND_SIZE(INQUIRY);
138
139 rq->sense = h->sense;
140 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
141 rq->sense_len = h->senselen = 0;
142
143 err = blk_execute_rq(rq->q, NULL, rq, 1);
144 if (err == -EIO) {
145 sdev_printk(KERN_INFO, sdev,
146 "%s: std inquiry failed with %x\n",
147 ALUA_DH_NAME, rq->errors);
148 h->senselen = rq->sense_len;
149 err = SCSI_DH_IO;
150 }
151 blk_put_request(rq);
152done:
153 return err;
154}
155
156/*
157 * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command
158 * @sdev: sdev the command should be sent to
159 */
160static int submit_vpd_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
161{
162 struct request *rq;
163 int err = SCSI_DH_RES_TEMP_UNAVAIL;
164
165 rq = get_alua_req(sdev, h->buff, h->bufflen, READ);
166 if (!rq)
167 goto done;
168
169 /* Prepare the command. */
170 rq->cmd[0] = INQUIRY;
171 rq->cmd[1] = 1;
172 rq->cmd[2] = 0x83;
173 rq->cmd[4] = h->bufflen;
174 rq->cmd_len = COMMAND_SIZE(INQUIRY);
175
176 rq->sense = h->sense;
177 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
178 rq->sense_len = h->senselen = 0;
179
180 err = blk_execute_rq(rq->q, NULL, rq, 1);
181 if (err == -EIO) {
182 sdev_printk(KERN_INFO, sdev,
183 "%s: evpd inquiry failed with %x\n",
184 ALUA_DH_NAME, rq->errors);
185 h->senselen = rq->sense_len;
186 err = SCSI_DH_IO;
187 }
188 blk_put_request(rq);
189done:
190 return err;
191}
192
193/*
194 * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
195 * @sdev: sdev the command should be sent to
196 */
197static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)
198{
199 struct request *rq;
200 int err = SCSI_DH_RES_TEMP_UNAVAIL;
201
202 rq = get_alua_req(sdev, h->buff, h->bufflen, READ);
203 if (!rq)
204 goto done;
205
206 /* Prepare the command. */
207 rq->cmd[0] = MAINTENANCE_IN;
208 rq->cmd[1] = MI_REPORT_TARGET_PGS;
209 rq->cmd[6] = (h->bufflen >> 24) & 0xff;
210 rq->cmd[7] = (h->bufflen >> 16) & 0xff;
211 rq->cmd[8] = (h->bufflen >> 8) & 0xff;
212 rq->cmd[9] = h->bufflen & 0xff;
213 rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN);
214
215 rq->sense = h->sense;
216 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
217 rq->sense_len = h->senselen = 0;
218
219 err = blk_execute_rq(rq->q, NULL, rq, 1);
220 if (err == -EIO) {
221 sdev_printk(KERN_INFO, sdev,
222 "%s: rtpg failed with %x\n",
223 ALUA_DH_NAME, rq->errors);
224 h->senselen = rq->sense_len;
225 err = SCSI_DH_IO;
226 }
227 blk_put_request(rq);
228done:
229 return err;
230}
231
232/*
233 * submit_stpg - Issue a SET TARGET GROUP STATES command
234 * @sdev: sdev the command should be sent to
235 *
236 * Currently we're only setting the current target port group state
237 * to 'active/optimized' and let the array firmware figure out
238 * the states of the remaining groups.
239 */
240static unsigned submit_stpg(struct scsi_device *sdev, struct alua_dh_data *h)
241{
242 struct request *rq;
243 int err = SCSI_DH_RES_TEMP_UNAVAIL;
244 int stpg_len = 8;
245
246 /* Prepare the data buffer */
247 memset(h->buff, 0, stpg_len);
248 h->buff[4] = TPGS_STATE_OPTIMIZED & 0x0f;
249 h->buff[6] = (h->group_id >> 8) & 0x0f;
250 h->buff[7] = h->group_id & 0x0f;
251
252 rq = get_alua_req(sdev, h->buff, stpg_len, WRITE);
253 if (!rq)
254 goto done;
255
256 /* Prepare the command. */
257 rq->cmd[0] = MAINTENANCE_OUT;
258 rq->cmd[1] = MO_SET_TARGET_PGS;
259 rq->cmd[6] = (stpg_len >> 24) & 0xff;
260 rq->cmd[7] = (stpg_len >> 16) & 0xff;
261 rq->cmd[8] = (stpg_len >> 8) & 0xff;
262 rq->cmd[9] = stpg_len & 0xff;
263 rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT);
264
265 rq->sense = h->sense;
266 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
267 rq->sense_len = h->senselen = 0;
268
269 err = blk_execute_rq(rq->q, NULL, rq, 1);
270 if (err == -EIO) {
271 sdev_printk(KERN_INFO, sdev,
272 "%s: stpg failed with %x\n",
273 ALUA_DH_NAME, rq->errors);
274 h->senselen = rq->sense_len;
275 err = SCSI_DH_IO;
276 }
277 blk_put_request(rq);
278done:
279 return err;
280}
281
282/*
283 * alua_std_inquiry - Evaluate standard INQUIRY command
284 * @sdev: device to be checked
285 *
286 * Just extract the TPGS setting to find out if ALUA
287 * is supported.
288 */
289static int alua_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
290{
291 int err;
292
293 err = submit_std_inquiry(sdev, h);
294
295 if (err != SCSI_DH_OK)
296 return err;
297
298 /* Check TPGS setting */
299 h->tpgs = (h->inq[5] >> 4) & 0x3;
300 switch (h->tpgs) {
301 case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT:
302 sdev_printk(KERN_INFO, sdev,
303 "%s: supports implicit and explicit TPGS\n",
304 ALUA_DH_NAME);
305 break;
306 case TPGS_MODE_EXPLICIT:
307 sdev_printk(KERN_INFO, sdev, "%s: supports explicit TPGS\n",
308 ALUA_DH_NAME);
309 break;
310 case TPGS_MODE_IMPLICIT:
311 sdev_printk(KERN_INFO, sdev, "%s: supports implicit TPGS\n",
312 ALUA_DH_NAME);
313 break;
314 default:
315 h->tpgs = TPGS_MODE_NONE;
316 sdev_printk(KERN_INFO, sdev, "%s: not supported\n",
317 ALUA_DH_NAME);
318 err = SCSI_DH_DEV_UNSUPP;
319 break;
320 }
321
322 return err;
323}
324
325/*
326 * alua_vpd_inquiry - Evaluate INQUIRY vpd page 0x83
327 * @sdev: device to be checked
328 *
329 * Extract the relative target port and the target port group
330 * descriptor from the list of identificators.
331 */
332static int alua_vpd_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
333{
334 int len;
335 unsigned err;
336 unsigned char *d;
337
338 retry:
339 err = submit_vpd_inquiry(sdev, h);
340
341 if (err != SCSI_DH_OK)
342 return err;
343
344 /* Check if vpd page exceeds initial buffer */
345 len = (h->buff[2] << 8) + h->buff[3] + 4;
346 if (len > h->bufflen) {
347 /* Resubmit with the correct length */
348 if (realloc_buffer(h, len)) {
349 sdev_printk(KERN_WARNING, sdev,
350 "%s: kmalloc buffer failed\n",
351 ALUA_DH_NAME);
352 /* Temporary failure, bypass */
353 return SCSI_DH_DEV_TEMP_BUSY;
354 }
355 goto retry;
356 }
357
358 /*
359 * Now look for the correct descriptor.
360 */
361 d = h->buff + 4;
362 while (d < h->buff + len) {
363 switch (d[1] & 0xf) {
364 case 0x4:
365 /* Relative target port */
366 h->rel_port = (d[6] << 8) + d[7];
367 break;
368 case 0x5:
369 /* Target port group */
370 h->group_id = (d[6] << 8) + d[7];
371 break;
372 default:
373 break;
374 }
375 d += d[3] + 4;
376 }
377
378 if (h->group_id == -1) {
379 /*
380 * Internal error; TPGS supported but required
381 * VPD identification descriptors not present.
382 * Disable ALUA support
383 */
384 sdev_printk(KERN_INFO, sdev,
385 "%s: No target port descriptors found\n",
386 ALUA_DH_NAME);
387 h->state = TPGS_STATE_OPTIMIZED;
388 h->tpgs = TPGS_MODE_NONE;
389 err = SCSI_DH_DEV_UNSUPP;
390 } else {
391 sdev_printk(KERN_INFO, sdev,
392 "%s: port group %02x rel port %02x\n",
393 ALUA_DH_NAME, h->group_id, h->rel_port);
394 }
395
396 return err;
397}
398
399static char print_alua_state(int state)
400{
401 switch (state) {
402 case TPGS_STATE_OPTIMIZED:
403 return 'A';
404 case TPGS_STATE_NONOPTIMIZED:
405 return 'N';
406 case TPGS_STATE_STANDBY:
407 return 'S';
408 case TPGS_STATE_UNAVAILABLE:
409 return 'U';
410 case TPGS_STATE_OFFLINE:
411 return 'O';
412 case TPGS_STATE_TRANSITIONING:
413 return 'T';
414 default:
415 return 'X';
416 }
417}
418
419static int alua_check_sense(struct scsi_device *sdev,
420 struct scsi_sense_hdr *sense_hdr)
421{
422 switch (sense_hdr->sense_key) {
423 case NOT_READY:
424 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a)
425 /*
426 * LUN Not Accessible - ALUA state transition
427 */
428 return NEEDS_RETRY;
429 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0b)
430 /*
431 * LUN Not Accessible -- Target port in standby state
432 */
433 return SUCCESS;
434 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0c)
435 /*
436 * LUN Not Accessible -- Target port in unavailable state
437 */
438 return SUCCESS;
439 if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x12)
440 /*
441 * LUN Not Ready -- Offline
442 */
443 return SUCCESS;
444 break;
445 case UNIT_ATTENTION:
446 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
447 /*
448 * Power On, Reset, or Bus Device Reset, just retry.
449 */
450 return NEEDS_RETRY;
451 if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x06) {
452 /*
453 * ALUA state changed
454 */
455 return NEEDS_RETRY;
456 }
457 if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x07) {
458 /*
459 * Implicit ALUA state transition failed
460 */
461 return NEEDS_RETRY;
462 }
463 break;
464 }
465
466 return SCSI_RETURN_NOT_HANDLED;
467}
468
469/*
470 * alua_stpg - Evaluate SET TARGET GROUP STATES
471 * @sdev: the device to be evaluated
472 * @state: the new target group state
473 *
474 * Send a SET TARGET GROUP STATES command to the device.
475 * We only have to test here if we should resubmit the command;
476 * any other error is assumed as a failure.
477 */
478static int alua_stpg(struct scsi_device *sdev, int state,
479 struct alua_dh_data *h)
480{
481 struct scsi_sense_hdr sense_hdr;
482 unsigned err;
483 int retry = ALUA_FAILOVER_RETRIES;
484
485 retry:
486 err = submit_stpg(sdev, h);
487 if (err == SCSI_DH_IO && h->senselen > 0) {
488 err = scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE,
489 &sense_hdr);
490 if (!err)
491 return SCSI_DH_IO;
492 err = alua_check_sense(sdev, &sense_hdr);
493 if (retry > 0 && err == NEEDS_RETRY) {
494 retry--;
495 goto retry;
496 }
497 sdev_printk(KERN_INFO, sdev,
498 "%s: stpg sense code: %02x/%02x/%02x\n",
499 ALUA_DH_NAME, sense_hdr.sense_key,
500 sense_hdr.asc, sense_hdr.ascq);
501 err = SCSI_DH_IO;
502 }
503 if (err == SCSI_DH_OK) {
504 h->state = state;
505 sdev_printk(KERN_INFO, sdev,
506 "%s: port group %02x switched to state %c\n",
507 ALUA_DH_NAME, h->group_id,
508 print_alua_state(h->state) );
509 }
510 return err;
511}
512
513/*
514 * alua_rtpg - Evaluate REPORT TARGET GROUP STATES
515 * @sdev: the device to be evaluated.
516 *
517 * Evaluate the Target Port Group State.
518 * Returns SCSI_DH_DEV_OFFLINED if the path is
519 * found to be unuseable.
520 */
521static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)
522{
523 struct scsi_sense_hdr sense_hdr;
524 int len, k, off, valid_states = 0;
525 char *ucp;
526 unsigned err;
527
528 retry:
529 err = submit_rtpg(sdev, h);
530
531 if (err == SCSI_DH_IO && h->senselen > 0) {
532 err = scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE,
533 &sense_hdr);
534 if (!err)
535 return SCSI_DH_IO;
536
537 err = alua_check_sense(sdev, &sense_hdr);
538 if (err == NEEDS_RETRY)
539 goto retry;
540 sdev_printk(KERN_INFO, sdev,
541 "%s: rtpg sense code %02x/%02x/%02x\n",
542 ALUA_DH_NAME, sense_hdr.sense_key,
543 sense_hdr.asc, sense_hdr.ascq);
544 err = SCSI_DH_IO;
545 }
546 if (err != SCSI_DH_OK)
547 return err;
548
549 len = (h->buff[0] << 24) + (h->buff[1] << 16) +
550 (h->buff[2] << 8) + h->buff[3] + 4;
551
552 if (len > h->bufflen) {
553 /* Resubmit with the correct length */
554 if (realloc_buffer(h, len)) {
555 sdev_printk(KERN_WARNING, sdev,
556 "%s: kmalloc buffer failed\n",__func__);
557 /* Temporary failure, bypass */
558 return SCSI_DH_DEV_TEMP_BUSY;
559 }
560 goto retry;
561 }
562
563 for (k = 4, ucp = h->buff + 4; k < len; k += off, ucp += off) {
564 if (h->group_id == (ucp[2] << 8) + ucp[3]) {
565 h->state = ucp[0] & 0x0f;
566 valid_states = ucp[1];
567 }
568 off = 8 + (ucp[7] * 4);
569 }
570
571 sdev_printk(KERN_INFO, sdev,
572 "%s: port group %02x state %c supports %c%c%c%c%c%c\n",
573 ALUA_DH_NAME, h->group_id, print_alua_state(h->state),
574 valid_states&TPGS_SUPPORT_TRANSITION?'T':'t',
575 valid_states&TPGS_SUPPORT_OFFLINE?'O':'o',
576 valid_states&TPGS_SUPPORT_UNAVAILABLE?'U':'u',
577 valid_states&TPGS_SUPPORT_STANDBY?'S':'s',
578 valid_states&TPGS_SUPPORT_NONOPTIMIZED?'N':'n',
579 valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a');
580
581 if (h->tpgs & TPGS_MODE_EXPLICIT) {
582 switch (h->state) {
583 case TPGS_STATE_TRANSITIONING:
584 /* State transition, retry */
585 goto retry;
586 break;
587 case TPGS_STATE_OFFLINE:
588 /* Path is offline, fail */
589 err = SCSI_DH_DEV_OFFLINED;
590 break;
591 default:
592 break;
593 }
594 } else {
595 /* Only Implicit ALUA support */
596 if (h->state == TPGS_STATE_OPTIMIZED ||
597 h->state == TPGS_STATE_NONOPTIMIZED ||
598 h->state == TPGS_STATE_STANDBY)
599 /* Useable path if active */
600 err = SCSI_DH_OK;
601 else
602 /* Path unuseable for unavailable/offline */
603 err = SCSI_DH_DEV_OFFLINED;
604 }
605 return err;
606}
607
608/*
609 * alua_initialize - Initialize ALUA state
610 * @sdev: the device to be initialized
611 *
612 * For the prep_fn to work correctly we have
613 * to initialize the ALUA state for the device.
614 */
615static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h)
616{
617 int err;
618
619 err = alua_std_inquiry(sdev, h);
620 if (err != SCSI_DH_OK)
621 goto out;
622
623 err = alua_vpd_inquiry(sdev, h);
624 if (err != SCSI_DH_OK)
625 goto out;
626
627 err = alua_rtpg(sdev, h);
628 if (err != SCSI_DH_OK)
629 goto out;
630
631out:
632 return err;
633}
634
635/*
636 * alua_activate - activate a path
637 * @sdev: device on the path to be activated
638 *
639 * We're currently switching the port group to be activated only and
640 * let the array figure out the rest.
641 * There may be other arrays which require us to switch all port groups
642 * based on a certain policy. But until we actually encounter them it
643 * should be okay.
644 */
645static int alua_activate(struct scsi_device *sdev)
646{
647 struct alua_dh_data *h = get_alua_data(sdev);
648 int err = SCSI_DH_OK;
649
650 if (h->group_id != -1) {
651 err = alua_rtpg(sdev, h);
652 if (err != SCSI_DH_OK)
653 goto out;
654 }
655
656 if (h->tpgs == TPGS_MODE_EXPLICIT && h->state != TPGS_STATE_OPTIMIZED)
657 err = alua_stpg(sdev, TPGS_STATE_OPTIMIZED, h);
658
659out:
660 return err;
661}
662
663/*
664 * alua_prep_fn - request callback
665 *
666 * Fail I/O to all paths not in state
667 * active/optimized or active/non-optimized.
668 */
669static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
670{
671 struct alua_dh_data *h = get_alua_data(sdev);
672 int ret = BLKPREP_OK;
673
674 if (h->state != TPGS_STATE_OPTIMIZED &&
675 h->state != TPGS_STATE_NONOPTIMIZED) {
676 ret = BLKPREP_KILL;
677 req->cmd_flags |= REQ_QUIET;
678 }
679 return ret;
680
681}
682
683const struct scsi_dh_devlist alua_dev_list[] = {
684 {"HP", "MSA VOLUME" },
685 {"HP", "HSV101" },
686 {"HP", "HSV111" },
687 {"HP", "HSV200" },
688 {"HP", "HSV210" },
689 {"HP", "HSV300" },
690 {"IBM", "2107900" },
691 {"IBM", "2145" },
692 {"Pillar", "Axiom" },
693 {NULL, NULL}
694};
695
696static int alua_bus_attach(struct scsi_device *sdev);
697static void alua_bus_detach(struct scsi_device *sdev);
698
699static struct scsi_device_handler alua_dh = {
700 .name = ALUA_DH_NAME,
701 .module = THIS_MODULE,
702 .devlist = alua_dev_list,
703 .attach = alua_bus_attach,
704 .detach = alua_bus_detach,
705 .prep_fn = alua_prep_fn,
706 .check_sense = alua_check_sense,
707 .activate = alua_activate,
708};
709
710/*
711 * alua_bus_attach - Attach device handler
712 * @sdev: device to be attached to
713 */
714static int alua_bus_attach(struct scsi_device *sdev)
715{
716 struct scsi_dh_data *scsi_dh_data;
717 struct alua_dh_data *h;
718 unsigned long flags;
719 int err = SCSI_DH_OK;
720
721 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
722 + sizeof(*h) , GFP_KERNEL);
723 if (!scsi_dh_data) {
724 sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
725 ALUA_DH_NAME);
726 return -ENOMEM;
727 }
728
729 scsi_dh_data->scsi_dh = &alua_dh;
730 h = (struct alua_dh_data *) scsi_dh_data->buf;
731 h->tpgs = TPGS_MODE_UNINITIALIZED;
732 h->state = TPGS_STATE_OPTIMIZED;
733 h->group_id = -1;
734 h->rel_port = -1;
735 h->buff = h->inq;
736 h->bufflen = ALUA_INQUIRY_SIZE;
737
738 err = alua_initialize(sdev, h);
739 if (err != SCSI_DH_OK)
740 goto failed;
741
742 if (!try_module_get(THIS_MODULE))
743 goto failed;
744
745 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
746 sdev->scsi_dh_data = scsi_dh_data;
747 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
748
749 return 0;
750
751failed:
752 kfree(scsi_dh_data);
753 sdev_printk(KERN_ERR, sdev, "%s: not attached\n", ALUA_DH_NAME);
754 return -EINVAL;
755}
756
757/*
758 * alua_bus_detach - Detach device handler
759 * @sdev: device to be detached from
760 */
761static void alua_bus_detach(struct scsi_device *sdev)
762{
763 struct scsi_dh_data *scsi_dh_data;
764 struct alua_dh_data *h;
765 unsigned long flags;
766
767 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
768 scsi_dh_data = sdev->scsi_dh_data;
769 sdev->scsi_dh_data = NULL;
770 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
771
772 h = (struct alua_dh_data *) scsi_dh_data->buf;
773 if (h->buff && h->inq != h->buff)
774 kfree(h->buff);
775 kfree(scsi_dh_data);
776 module_put(THIS_MODULE);
777 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", ALUA_DH_NAME);
778}
779
780static int __init alua_init(void)
781{
782 int r;
783
784 r = scsi_register_device_handler(&alua_dh);
785 if (r != 0)
786 printk(KERN_ERR "%s: Failed to register scsi device handler",
787 ALUA_DH_NAME);
788 return r;
789}
790
791static void __exit alua_exit(void)
792{
793 scsi_unregister_device_handler(&alua_dh);
794}
795
796module_init(alua_init);
797module_exit(alua_exit);
798
799MODULE_DESCRIPTION("DM Multipath ALUA support");
800MODULE_AUTHOR("Hannes Reinecke <hare@suse.de>");
801MODULE_LICENSE("GPL");
802MODULE_VERSION(ALUA_DH_VER);
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index f2467e936e55..aa46b131b20e 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -25,28 +25,31 @@
25#include <scsi/scsi_dh.h> 25#include <scsi/scsi_dh.h>
26#include <scsi/scsi_device.h> 26#include <scsi/scsi_device.h>
27 27
28#define CLARIION_NAME "emc_clariion" 28#define CLARIION_NAME "emc"
29 29
30#define CLARIION_TRESPASS_PAGE 0x22 30#define CLARIION_TRESPASS_PAGE 0x22
31#define CLARIION_BUFFER_SIZE 0x80 31#define CLARIION_BUFFER_SIZE 0xFC
32#define CLARIION_TIMEOUT (60 * HZ) 32#define CLARIION_TIMEOUT (60 * HZ)
33#define CLARIION_RETRIES 3 33#define CLARIION_RETRIES 3
34#define CLARIION_UNBOUND_LU -1 34#define CLARIION_UNBOUND_LU -1
35#define CLARIION_SP_A 0
36#define CLARIION_SP_B 1
35 37
36static unsigned char long_trespass[] = { 38/* Flags */
37 0, 0, 0, 0, 39#define CLARIION_SHORT_TRESPASS 1
38 CLARIION_TRESPASS_PAGE, /* Page code */ 40#define CLARIION_HONOR_RESERVATIONS 2
39 0x09, /* Page length - 2 */
40 0x81, /* Trespass code + Honor reservation bit */
41 0xff, 0xff, /* Trespass target */
42 0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */
43};
44 41
45static unsigned char long_trespass_hr[] = { 42/* LUN states */
46 0, 0, 0, 0, 43#define CLARIION_LUN_UNINITIALIZED -1
44#define CLARIION_LUN_UNBOUND 0
45#define CLARIION_LUN_BOUND 1
46#define CLARIION_LUN_OWNED 2
47
48static unsigned char long_trespass[] = {
49 0, 0, 0, 0, 0, 0, 0, 0,
47 CLARIION_TRESPASS_PAGE, /* Page code */ 50 CLARIION_TRESPASS_PAGE, /* Page code */
48 0x09, /* Page length - 2 */ 51 0x09, /* Page length - 2 */
49 0x01, /* Trespass code + Honor reservation bit */ 52 0x01, /* Trespass code */
50 0xff, 0xff, /* Trespass target */ 53 0xff, 0xff, /* Trespass target */
51 0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */ 54 0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */
52}; 55};
@@ -55,39 +58,56 @@ static unsigned char short_trespass[] = {
55 0, 0, 0, 0, 58 0, 0, 0, 0,
56 CLARIION_TRESPASS_PAGE, /* Page code */ 59 CLARIION_TRESPASS_PAGE, /* Page code */
57 0x02, /* Page length - 2 */ 60 0x02, /* Page length - 2 */
58 0x81, /* Trespass code + Honor reservation bit */ 61 0x01, /* Trespass code */
59 0xff, /* Trespass target */ 62 0xff, /* Trespass target */
60}; 63};
61 64
62static unsigned char short_trespass_hr[] = { 65static const char * lun_state[] =
63 0, 0, 0, 0, 66{
64 CLARIION_TRESPASS_PAGE, /* Page code */ 67 "not bound",
65 0x02, /* Page length - 2 */ 68 "bound",
66 0x01, /* Trespass code + Honor reservation bit */ 69 "owned",
67 0xff, /* Trespass target */
68}; 70};
69 71
70struct clariion_dh_data { 72struct clariion_dh_data {
71 /* 73 /*
74 * Flags:
75 * CLARIION_SHORT_TRESPASS
72 * Use short trespass command (FC-series) or the long version 76 * Use short trespass command (FC-series) or the long version
73 * (default for AX/CX CLARiiON arrays). 77 * (default for AX/CX CLARiiON arrays).
74 */ 78 *
75 unsigned short_trespass; 79 * CLARIION_HONOR_RESERVATIONS
76 /*
77 * Whether or not (default) to honor SCSI reservations when 80 * Whether or not (default) to honor SCSI reservations when
78 * initiating a switch-over. 81 * initiating a switch-over.
79 */ 82 */
80 unsigned hr; 83 unsigned flags;
81 /* I/O buffer for both MODE_SELECT and INQUIRY commands. */ 84 /*
85 * I/O buffer for both MODE_SELECT and INQUIRY commands.
86 */
82 char buffer[CLARIION_BUFFER_SIZE]; 87 char buffer[CLARIION_BUFFER_SIZE];
83 /* 88 /*
84 * SCSI sense buffer for commands -- assumes serial issuance 89 * SCSI sense buffer for commands -- assumes serial issuance
85 * and completion sequence of all commands for same multipath. 90 * and completion sequence of all commands for same multipath.
86 */ 91 */
87 unsigned char sense[SCSI_SENSE_BUFFERSIZE]; 92 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
88 /* which SP (A=0,B=1,UNBOUND=-1) is dflt SP for path's mapped dev */ 93 unsigned int senselen;
94 /*
95 * LUN state
96 */
97 int lun_state;
98 /*
99 * SP Port number
100 */
101 int port;
102 /*
103 * which SP (A=0,B=1,UNBOUND=-1) is the default SP for this
104 * path's mapped LUN
105 */
89 int default_sp; 106 int default_sp;
90 /* which SP (A=0,B=1,UNBOUND=-1) is active for path's mapped dev */ 107 /*
108 * which SP (A=0,B=1,UNBOUND=-1) is the active SP for this
109 * path's mapped LUN
110 */
91 int current_sp; 111 int current_sp;
92}; 112};
93 113
@@ -102,19 +122,16 @@ static inline struct clariion_dh_data
102/* 122/*
103 * Parse MODE_SELECT cmd reply. 123 * Parse MODE_SELECT cmd reply.
104 */ 124 */
105static int trespass_endio(struct scsi_device *sdev, int result) 125static int trespass_endio(struct scsi_device *sdev, char *sense)
106{ 126{
107 int err = SCSI_DH_OK; 127 int err = SCSI_DH_IO;
108 struct scsi_sense_hdr sshdr; 128 struct scsi_sense_hdr sshdr;
109 struct clariion_dh_data *csdev = get_clariion_data(sdev);
110 char *sense = csdev->sense;
111 129
112 if (status_byte(result) == CHECK_CONDITION && 130 if (!scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) {
113 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)) { 131 sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, "
114 sdev_printk(KERN_ERR, sdev, "Found valid sense data 0x%2x, "
115 "0x%2x, 0x%2x while sending CLARiiON trespass " 132 "0x%2x, 0x%2x while sending CLARiiON trespass "
116 "command.\n", sshdr.sense_key, sshdr.asc, 133 "command.\n", CLARIION_NAME, sshdr.sense_key,
117 sshdr.ascq); 134 sshdr.asc, sshdr.ascq);
118 135
119 if ((sshdr.sense_key == 0x05) && (sshdr.asc == 0x04) && 136 if ((sshdr.sense_key == 0x05) && (sshdr.asc == 0x04) &&
120 (sshdr.ascq == 0x00)) { 137 (sshdr.ascq == 0x00)) {
@@ -122,9 +139,9 @@ static int trespass_endio(struct scsi_device *sdev, int result)
122 * Array based copy in progress -- do not send 139 * Array based copy in progress -- do not send
123 * mode_select or copy will be aborted mid-stream. 140 * mode_select or copy will be aborted mid-stream.
124 */ 141 */
125 sdev_printk(KERN_INFO, sdev, "Array Based Copy in " 142 sdev_printk(KERN_INFO, sdev, "%s: Array Based Copy in "
126 "progress while sending CLARiiON trespass " 143 "progress while sending CLARiiON trespass "
127 "command.\n"); 144 "command.\n", CLARIION_NAME);
128 err = SCSI_DH_DEV_TEMP_BUSY; 145 err = SCSI_DH_DEV_TEMP_BUSY;
129 } else if ((sshdr.sense_key == 0x02) && (sshdr.asc == 0x04) && 146 } else if ((sshdr.sense_key == 0x02) && (sshdr.asc == 0x04) &&
130 (sshdr.ascq == 0x03)) { 147 (sshdr.ascq == 0x03)) {
@@ -132,160 +149,153 @@ static int trespass_endio(struct scsi_device *sdev, int result)
132 * LUN Not Ready - Manual Intervention Required 149 * LUN Not Ready - Manual Intervention Required
133 * indicates in-progress ucode upgrade (NDU). 150 * indicates in-progress ucode upgrade (NDU).
134 */ 151 */
135 sdev_printk(KERN_INFO, sdev, "Detected in-progress " 152 sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress "
136 "ucode upgrade NDU operation while sending " 153 "ucode upgrade NDU operation while sending "
137 "CLARiiON trespass command.\n"); 154 "CLARiiON trespass command.\n", CLARIION_NAME);
138 err = SCSI_DH_DEV_TEMP_BUSY; 155 err = SCSI_DH_DEV_TEMP_BUSY;
139 } else 156 } else
140 err = SCSI_DH_DEV_FAILED; 157 err = SCSI_DH_DEV_FAILED;
141 } else if (result) { 158 } else {
142 sdev_printk(KERN_ERR, sdev, "Error 0x%x while sending " 159 sdev_printk(KERN_INFO, sdev,
143 "CLARiiON trespass command.\n", result); 160 "%s: failed to send MODE SELECT, no sense available\n",
144 err = SCSI_DH_IO; 161 CLARIION_NAME);
145 } 162 }
146
147 return err; 163 return err;
148} 164}
149 165
150static int parse_sp_info_reply(struct scsi_device *sdev, int result, 166static int parse_sp_info_reply(struct scsi_device *sdev,
151 int *default_sp, int *current_sp, int *new_current_sp) 167 struct clariion_dh_data *csdev)
152{ 168{
153 int err = SCSI_DH_OK; 169 int err = SCSI_DH_OK;
154 struct clariion_dh_data *csdev = get_clariion_data(sdev);
155 170
156 if (result == 0) { 171 /* check for in-progress ucode upgrade (NDU) */
157 /* check for in-progress ucode upgrade (NDU) */ 172 if (csdev->buffer[48] != 0) {
158 if (csdev->buffer[48] != 0) { 173 sdev_printk(KERN_NOTICE, sdev, "%s: Detected in-progress "
159 sdev_printk(KERN_NOTICE, sdev, "Detected in-progress " 174 "ucode upgrade NDU operation while finding "
160 "ucode upgrade NDU operation while finding " 175 "current active SP.", CLARIION_NAME);
161 "current active SP."); 176 err = SCSI_DH_DEV_TEMP_BUSY;
162 err = SCSI_DH_DEV_TEMP_BUSY; 177 goto out;
163 } else { 178 }
164 *default_sp = csdev->buffer[5]; 179 if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
165 180 /* Invalid buffer format */
166 if (csdev->buffer[4] == 2) 181 sdev_printk(KERN_NOTICE, sdev,
167 /* SP for path is current */ 182 "%s: invalid VPD page 0xC0 format\n",
168 *current_sp = csdev->buffer[8]; 183 CLARIION_NAME);
169 else { 184 err = SCSI_DH_NOSYS;
170 if (csdev->buffer[4] == 1) 185 goto out;
171 /* SP for this path is NOT current */ 186 }
172 if (csdev->buffer[8] == 0) 187 switch (csdev->buffer[28] & 0x0f) {
173 *current_sp = 1; 188 case 6:
174 else 189 sdev_printk(KERN_NOTICE, sdev,
175 *current_sp = 0; 190 "%s: ALUA failover mode detected\n",
176 else 191 CLARIION_NAME);
177 /* unbound LU or LUNZ */ 192 break;
178 *current_sp = CLARIION_UNBOUND_LU; 193 case 4:
179 } 194 /* Linux failover */
180 *new_current_sp = csdev->buffer[8]; 195 break;
181 } 196 default:
182 } else { 197 sdev_printk(KERN_WARNING, sdev,
183 struct scsi_sense_hdr sshdr; 198 "%s: Invalid failover mode %d\n",
184 199 CLARIION_NAME, csdev->buffer[28] & 0x0f);
185 err = SCSI_DH_IO; 200 err = SCSI_DH_NOSYS;
186 201 goto out;
187 if (scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE,
188 &sshdr))
189 sdev_printk(KERN_ERR, sdev, "Found valid sense data "
190 "0x%2x, 0x%2x, 0x%2x while finding current "
191 "active SP.", sshdr.sense_key, sshdr.asc,
192 sshdr.ascq);
193 else
194 sdev_printk(KERN_ERR, sdev, "Error 0x%x finding "
195 "current active SP.", result);
196 } 202 }
197 203
204 csdev->default_sp = csdev->buffer[5];
205 csdev->lun_state = csdev->buffer[4];
206 csdev->current_sp = csdev->buffer[8];
207 csdev->port = csdev->buffer[7];
208
209out:
198 return err; 210 return err;
199} 211}
200 212
201static int sp_info_endio(struct scsi_device *sdev, int result, 213#define emc_default_str "FC (Legacy)"
202 int mode_select_sent, int *done) 214
215static char * parse_sp_model(struct scsi_device *sdev, unsigned char *buffer)
203{ 216{
204 struct clariion_dh_data *csdev = get_clariion_data(sdev); 217 unsigned char len = buffer[4] + 5;
205 int err_flags, default_sp, current_sp, new_current_sp; 218 char *sp_model = NULL;
219 unsigned char sp_len, serial_len;
220
221 if (len < 160) {
222 sdev_printk(KERN_WARNING, sdev,
223 "%s: Invalid information section length %d\n",
224 CLARIION_NAME, len);
225 /* Check for old FC arrays */
226 if (!strncmp(buffer + 8, "DGC", 3)) {
227 /* Old FC array, not supporting extended information */
228 sp_model = emc_default_str;
229 }
230 goto out;
231 }
206 232
207 err_flags = parse_sp_info_reply(sdev, result, &default_sp, 233 /*
208 &current_sp, &new_current_sp); 234 * Parse extended information for SP model number
235 */
236 serial_len = buffer[160];
237 if (serial_len == 0 || serial_len + 161 > len) {
238 sdev_printk(KERN_WARNING, sdev,
239 "%s: Invalid array serial number length %d\n",
240 CLARIION_NAME, serial_len);
241 goto out;
242 }
243 sp_len = buffer[99];
244 if (sp_len == 0 || serial_len + sp_len + 161 > len) {
245 sdev_printk(KERN_WARNING, sdev,
246 "%s: Invalid model number length %d\n",
247 CLARIION_NAME, sp_len);
248 goto out;
249 }
250 sp_model = &buffer[serial_len + 161];
251 /* Strip whitespace at the end */
252 while (sp_len > 1 && sp_model[sp_len - 1] == ' ')
253 sp_len--;
209 254
210 if (err_flags != SCSI_DH_OK) 255 sp_model[sp_len] = '\0';
211 goto done;
212 256
213 if (mode_select_sent) { 257out:
214 csdev->default_sp = default_sp; 258 return sp_model;
215 csdev->current_sp = current_sp;
216 } else {
217 /*
218 * Issue the actual module_selec request IFF either
219 * (1) we do not know the identity of the current SP OR
220 * (2) what we think we know is actually correct.
221 */
222 if ((current_sp != CLARIION_UNBOUND_LU) &&
223 (new_current_sp != current_sp)) {
224
225 csdev->default_sp = default_sp;
226 csdev->current_sp = current_sp;
227
228 sdev_printk(KERN_INFO, sdev, "Ignoring path group "
229 "switch-over command for CLARiiON SP%s since "
230 " mapped device is already initialized.",
231 current_sp ? "B" : "A");
232 if (done)
233 *done = 1; /* as good as doing it */
234 }
235 }
236done:
237 return err_flags;
238} 259}
239 260
240/* 261/*
241* Get block request for REQ_BLOCK_PC command issued to path. Currently 262 * Get block request for REQ_BLOCK_PC command issued to path. Currently
242* limited to MODE_SELECT (trespass) and INQUIRY (VPD page 0xC0) commands. 263 * limited to MODE_SELECT (trespass) and INQUIRY (VPD page 0xC0) commands.
243* 264 *
244* Uses data and sense buffers in hardware handler context structure and 265 * Uses data and sense buffers in hardware handler context structure and
245* assumes serial servicing of commands, both issuance and completion. 266 * assumes serial servicing of commands, both issuance and completion.
246*/ 267 */
247static struct request *get_req(struct scsi_device *sdev, int cmd) 268static struct request *get_req(struct scsi_device *sdev, int cmd,
269 unsigned char *buffer)
248{ 270{
249 struct clariion_dh_data *csdev = get_clariion_data(sdev);
250 struct request *rq; 271 struct request *rq;
251 unsigned char *page22;
252 int len = 0; 272 int len = 0;
253 273
254 rq = blk_get_request(sdev->request_queue, 274 rq = blk_get_request(sdev->request_queue,
255 (cmd == MODE_SELECT) ? WRITE : READ, GFP_ATOMIC); 275 (cmd == MODE_SELECT) ? WRITE : READ, GFP_NOIO);
256 if (!rq) { 276 if (!rq) {
257 sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed"); 277 sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed");
258 return NULL; 278 return NULL;
259 } 279 }
260 280
261 memset(&rq->cmd, 0, BLK_MAX_CDB); 281 memset(rq->cmd, 0, BLK_MAX_CDB);
282 rq->cmd_len = COMMAND_SIZE(cmd);
262 rq->cmd[0] = cmd; 283 rq->cmd[0] = cmd;
263 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
264 284
265 switch (cmd) { 285 switch (cmd) {
266 case MODE_SELECT: 286 case MODE_SELECT:
267 if (csdev->short_trespass) { 287 len = sizeof(short_trespass);
268 page22 = csdev->hr ? short_trespass_hr : short_trespass; 288 rq->cmd_flags |= REQ_RW;
269 len = sizeof(short_trespass); 289 rq->cmd[1] = 0x10;
270 } else { 290 break;
271 page22 = csdev->hr ? long_trespass_hr : long_trespass; 291 case MODE_SELECT_10:
272 len = sizeof(long_trespass); 292 len = sizeof(long_trespass);
273 }
274 /*
275 * Can't DMA from kernel BSS -- must copy selected trespass
276 * command mode page contents to context buffer which is
277 * allocated by kmalloc.
278 */
279 BUG_ON((len > CLARIION_BUFFER_SIZE));
280 memcpy(csdev->buffer, page22, len);
281 rq->cmd_flags |= REQ_RW; 293 rq->cmd_flags |= REQ_RW;
282 rq->cmd[1] = 0x10; 294 rq->cmd[1] = 0x10;
283 break; 295 break;
284 case INQUIRY: 296 case INQUIRY:
285 rq->cmd[1] = 0x1;
286 rq->cmd[2] = 0xC0;
287 len = CLARIION_BUFFER_SIZE; 297 len = CLARIION_BUFFER_SIZE;
288 memset(csdev->buffer, 0, CLARIION_BUFFER_SIZE); 298 memset(buffer, 0, len);
289 break; 299 break;
290 default: 300 default:
291 BUG_ON(1); 301 BUG_ON(1);
@@ -298,47 +308,94 @@ static struct request *get_req(struct scsi_device *sdev, int cmd)
298 rq->timeout = CLARIION_TIMEOUT; 308 rq->timeout = CLARIION_TIMEOUT;
299 rq->retries = CLARIION_RETRIES; 309 rq->retries = CLARIION_RETRIES;
300 310
301 rq->sense = csdev->sense; 311 if (blk_rq_map_kern(rq->q, rq, buffer, len, GFP_NOIO)) {
302 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); 312 blk_put_request(rq);
303 rq->sense_len = 0;
304
305 if (blk_rq_map_kern(sdev->request_queue, rq, csdev->buffer,
306 len, GFP_ATOMIC)) {
307 __blk_put_request(rq->q, rq);
308 return NULL; 313 return NULL;
309 } 314 }
310 315
311 return rq; 316 return rq;
312} 317}
313 318
314static int send_cmd(struct scsi_device *sdev, int cmd) 319static int send_inquiry_cmd(struct scsi_device *sdev, int page,
320 struct clariion_dh_data *csdev)
315{ 321{
316 struct request *rq = get_req(sdev, cmd); 322 struct request *rq = get_req(sdev, INQUIRY, csdev->buffer);
323 int err;
317 324
318 if (!rq) 325 if (!rq)
319 return SCSI_DH_RES_TEMP_UNAVAIL; 326 return SCSI_DH_RES_TEMP_UNAVAIL;
320 327
321 return blk_execute_rq(sdev->request_queue, NULL, rq, 1); 328 rq->sense = csdev->sense;
329 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
330 rq->sense_len = csdev->senselen = 0;
331
332 rq->cmd[0] = INQUIRY;
333 if (page != 0) {
334 rq->cmd[1] = 1;
335 rq->cmd[2] = page;
336 }
337 err = blk_execute_rq(sdev->request_queue, NULL, rq, 1);
338 if (err == -EIO) {
339 sdev_printk(KERN_INFO, sdev,
340 "%s: failed to send %s INQUIRY: %x\n",
341 CLARIION_NAME, page?"EVPD":"standard",
342 rq->errors);
343 csdev->senselen = rq->sense_len;
344 err = SCSI_DH_IO;
345 }
346
347 blk_put_request(rq);
348
349 return err;
322} 350}
323 351
324static int clariion_activate(struct scsi_device *sdev) 352static int send_trespass_cmd(struct scsi_device *sdev,
353 struct clariion_dh_data *csdev)
325{ 354{
326 int result, done = 0; 355 struct request *rq;
356 unsigned char *page22;
357 int err, len, cmd;
358
359 if (csdev->flags & CLARIION_SHORT_TRESPASS) {
360 page22 = short_trespass;
361 if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
362 /* Set Honor Reservations bit */
363 page22[6] |= 0x80;
364 len = sizeof(short_trespass);
365 cmd = MODE_SELECT;
366 } else {
367 page22 = long_trespass;
368 if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
369 /* Set Honor Reservations bit */
370 page22[10] |= 0x80;
371 len = sizeof(long_trespass);
372 cmd = MODE_SELECT_10;
373 }
374 BUG_ON((len > CLARIION_BUFFER_SIZE));
375 memcpy(csdev->buffer, page22, len);
327 376
328 result = send_cmd(sdev, INQUIRY); 377 rq = get_req(sdev, cmd, csdev->buffer);
329 result = sp_info_endio(sdev, result, 0, &done); 378 if (!rq)
330 if (result || done) 379 return SCSI_DH_RES_TEMP_UNAVAIL;
331 goto done;
332 380
333 result = send_cmd(sdev, MODE_SELECT); 381 rq->sense = csdev->sense;
334 result = trespass_endio(sdev, result); 382 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
335 if (result) 383 rq->sense_len = csdev->senselen = 0;
336 goto done;
337 384
338 result = send_cmd(sdev, INQUIRY); 385 err = blk_execute_rq(sdev->request_queue, NULL, rq, 1);
339 result = sp_info_endio(sdev, result, 1, NULL); 386 if (err == -EIO) {
340done: 387 if (rq->sense_len) {
341 return result; 388 err = trespass_endio(sdev, csdev->sense);
389 } else {
390 sdev_printk(KERN_INFO, sdev,
391 "%s: failed to send MODE SELECT: %x\n",
392 CLARIION_NAME, rq->errors);
393 }
394 }
395
396 blk_put_request(rq);
397
398 return err;
342} 399}
343 400
344static int clariion_check_sense(struct scsi_device *sdev, 401static int clariion_check_sense(struct scsi_device *sdev,
@@ -386,99 +443,215 @@ static int clariion_check_sense(struct scsi_device *sdev,
386 break; 443 break;
387 } 444 }
388 445
389 /* success just means we do not care what scsi-ml does */ 446 return SCSI_RETURN_NOT_HANDLED;
390 return SUCCESS; 447}
448
449static int clariion_prep_fn(struct scsi_device *sdev, struct request *req)
450{
451 struct clariion_dh_data *h = get_clariion_data(sdev);
452 int ret = BLKPREP_OK;
453
454 if (h->lun_state != CLARIION_LUN_OWNED) {
455 ret = BLKPREP_KILL;
456 req->cmd_flags |= REQ_QUIET;
457 }
458 return ret;
459
460}
461
462static int clariion_std_inquiry(struct scsi_device *sdev,
463 struct clariion_dh_data *csdev)
464{
465 int err;
466 char *sp_model;
467
468 err = send_inquiry_cmd(sdev, 0, csdev);
469 if (err != SCSI_DH_OK && csdev->senselen) {
470 struct scsi_sense_hdr sshdr;
471
472 if (scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE,
473 &sshdr)) {
474 sdev_printk(KERN_ERR, sdev, "%s: INQUIRY sense code "
475 "%02x/%02x/%02x\n", CLARIION_NAME,
476 sshdr.sense_key, sshdr.asc, sshdr.ascq);
477 }
478 err = SCSI_DH_IO;
479 goto out;
480 }
481
482 sp_model = parse_sp_model(sdev, csdev->buffer);
483 if (!sp_model) {
484 err = SCSI_DH_DEV_UNSUPP;
485 goto out;
486 }
487
488 /*
489 * FC Series arrays do not support long trespass
490 */
491 if (!strlen(sp_model) || !strncmp(sp_model, "FC",2))
492 csdev->flags |= CLARIION_SHORT_TRESPASS;
493
494 sdev_printk(KERN_INFO, sdev,
495 "%s: detected Clariion %s, flags %x\n",
496 CLARIION_NAME, sp_model, csdev->flags);
497out:
498 return err;
391} 499}
392 500
393static const struct { 501static int clariion_send_inquiry(struct scsi_device *sdev,
394 char *vendor; 502 struct clariion_dh_data *csdev)
395 char *model; 503{
396} clariion_dev_list[] = { 504 int err, retry = CLARIION_RETRIES;
505
506retry:
507 err = send_inquiry_cmd(sdev, 0xC0, csdev);
508 if (err != SCSI_DH_OK && csdev->senselen) {
509 struct scsi_sense_hdr sshdr;
510
511 err = scsi_normalize_sense(csdev->sense, SCSI_SENSE_BUFFERSIZE,
512 &sshdr);
513 if (!err)
514 return SCSI_DH_IO;
515
516 err = clariion_check_sense(sdev, &sshdr);
517 if (retry > 0 && err == NEEDS_RETRY) {
518 retry--;
519 goto retry;
520 }
521 sdev_printk(KERN_ERR, sdev, "%s: INQUIRY sense code "
522 "%02x/%02x/%02x\n", CLARIION_NAME,
523 sshdr.sense_key, sshdr.asc, sshdr.ascq);
524 err = SCSI_DH_IO;
525 } else {
526 err = parse_sp_info_reply(sdev, csdev);
527 }
528 return err;
529}
530
531static int clariion_activate(struct scsi_device *sdev)
532{
533 struct clariion_dh_data *csdev = get_clariion_data(sdev);
534 int result;
535
536 result = clariion_send_inquiry(sdev, csdev);
537 if (result != SCSI_DH_OK)
538 goto done;
539
540 if (csdev->lun_state == CLARIION_LUN_OWNED)
541 goto done;
542
543 result = send_trespass_cmd(sdev, csdev);
544 if (result != SCSI_DH_OK)
545 goto done;
546 sdev_printk(KERN_INFO, sdev,"%s: %s trespass command sent\n",
547 CLARIION_NAME,
548 csdev->flags&CLARIION_SHORT_TRESPASS?"short":"long" );
549
550 /* Update status */
551 result = clariion_send_inquiry(sdev, csdev);
552 if (result != SCSI_DH_OK)
553 goto done;
554
555done:
556 sdev_printk(KERN_INFO, sdev,
557 "%s: at SP %c Port %d (%s, default SP %c)\n",
558 CLARIION_NAME, csdev->current_sp + 'A',
559 csdev->port, lun_state[csdev->lun_state],
560 csdev->default_sp + 'A');
561
562 return result;
563}
564
565const struct scsi_dh_devlist clariion_dev_list[] = {
397 {"DGC", "RAID"}, 566 {"DGC", "RAID"},
398 {"DGC", "DISK"}, 567 {"DGC", "DISK"},
568 {"DGC", "VRAID"},
399 {NULL, NULL}, 569 {NULL, NULL},
400}; 570};
401 571
402static int clariion_bus_notify(struct notifier_block *, unsigned long, void *); 572static int clariion_bus_attach(struct scsi_device *sdev);
573static void clariion_bus_detach(struct scsi_device *sdev);
403 574
404static struct scsi_device_handler clariion_dh = { 575static struct scsi_device_handler clariion_dh = {
405 .name = CLARIION_NAME, 576 .name = CLARIION_NAME,
406 .module = THIS_MODULE, 577 .module = THIS_MODULE,
407 .nb.notifier_call = clariion_bus_notify, 578 .devlist = clariion_dev_list,
579 .attach = clariion_bus_attach,
580 .detach = clariion_bus_detach,
408 .check_sense = clariion_check_sense, 581 .check_sense = clariion_check_sense,
409 .activate = clariion_activate, 582 .activate = clariion_activate,
583 .prep_fn = clariion_prep_fn,
410}; 584};
411 585
412/* 586/*
413 * TODO: need some interface so we can set trespass values 587 * TODO: need some interface so we can set trespass values
414 */ 588 */
415static int clariion_bus_notify(struct notifier_block *nb, 589static int clariion_bus_attach(struct scsi_device *sdev)
416 unsigned long action, void *data)
417{ 590{
418 struct device *dev = data;
419 struct scsi_device *sdev;
420 struct scsi_dh_data *scsi_dh_data; 591 struct scsi_dh_data *scsi_dh_data;
421 struct clariion_dh_data *h; 592 struct clariion_dh_data *h;
422 int i, found = 0;
423 unsigned long flags; 593 unsigned long flags;
594 int err;
424 595
425 if (!scsi_is_sdev_device(dev)) 596 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
426 return 0; 597 + sizeof(*h) , GFP_KERNEL);
598 if (!scsi_dh_data) {
599 sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
600 CLARIION_NAME);
601 return -ENOMEM;
602 }
427 603
428 sdev = to_scsi_device(dev); 604 scsi_dh_data->scsi_dh = &clariion_dh;
605 h = (struct clariion_dh_data *) scsi_dh_data->buf;
606 h->lun_state = CLARIION_LUN_UNINITIALIZED;
607 h->default_sp = CLARIION_UNBOUND_LU;
608 h->current_sp = CLARIION_UNBOUND_LU;
429 609
430 if (action == BUS_NOTIFY_ADD_DEVICE) { 610 err = clariion_std_inquiry(sdev, h);
431 for (i = 0; clariion_dev_list[i].vendor; i++) { 611 if (err != SCSI_DH_OK)
432 if (!strncmp(sdev->vendor, clariion_dev_list[i].vendor, 612 goto failed;
433 strlen(clariion_dev_list[i].vendor)) &&
434 !strncmp(sdev->model, clariion_dev_list[i].model,
435 strlen(clariion_dev_list[i].model))) {
436 found = 1;
437 break;
438 }
439 }
440 if (!found)
441 goto out;
442
443 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
444 + sizeof(*h) , GFP_KERNEL);
445 if (!scsi_dh_data) {
446 sdev_printk(KERN_ERR, sdev, "Attach failed %s.\n",
447 CLARIION_NAME);
448 goto out;
449 }
450 613
451 scsi_dh_data->scsi_dh = &clariion_dh; 614 err = clariion_send_inquiry(sdev, h);
452 h = (struct clariion_dh_data *) scsi_dh_data->buf; 615 if (err != SCSI_DH_OK)
453 h->default_sp = CLARIION_UNBOUND_LU; 616 goto failed;
454 h->current_sp = CLARIION_UNBOUND_LU;
455 617
456 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 618 if (!try_module_get(THIS_MODULE))
457 sdev->scsi_dh_data = scsi_dh_data; 619 goto failed;
458 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
459 620
460 sdev_printk(KERN_NOTICE, sdev, "Attached %s.\n", CLARIION_NAME); 621 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
461 try_module_get(THIS_MODULE); 622 sdev->scsi_dh_data = scsi_dh_data;
623 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
462 624
463 } else if (action == BUS_NOTIFY_DEL_DEVICE) { 625 sdev_printk(KERN_INFO, sdev,
464 if (sdev->scsi_dh_data == NULL || 626 "%s: connected to SP %c Port %d (%s, default SP %c)\n",
465 sdev->scsi_dh_data->scsi_dh != &clariion_dh) 627 CLARIION_NAME, h->current_sp + 'A',
466 goto out; 628 h->port, lun_state[h->lun_state],
629 h->default_sp + 'A');
467 630
468 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 631 return 0;
469 scsi_dh_data = sdev->scsi_dh_data;
470 sdev->scsi_dh_data = NULL;
471 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
472 632
473 sdev_printk(KERN_NOTICE, sdev, "Dettached %s.\n", 633failed:
474 CLARIION_NAME); 634 kfree(scsi_dh_data);
635 sdev_printk(KERN_ERR, sdev, "%s: not attached\n",
636 CLARIION_NAME);
637 return -EINVAL;
638}
475 639
476 kfree(scsi_dh_data); 640static void clariion_bus_detach(struct scsi_device *sdev)
477 module_put(THIS_MODULE); 641{
478 } 642 struct scsi_dh_data *scsi_dh_data;
643 unsigned long flags;
479 644
480out: 645 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
481 return 0; 646 scsi_dh_data = sdev->scsi_dh_data;
647 sdev->scsi_dh_data = NULL;
648 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
649
650 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n",
651 CLARIION_NAME);
652
653 kfree(scsi_dh_data);
654 module_put(THIS_MODULE);
482} 655}
483 656
484static int __init clariion_init(void) 657static int __init clariion_init(void)
@@ -487,7 +660,8 @@ static int __init clariion_init(void)
487 660
488 r = scsi_register_device_handler(&clariion_dh); 661 r = scsi_register_device_handler(&clariion_dh);
489 if (r != 0) 662 if (r != 0)
490 printk(KERN_ERR "Failed to register scsi device handler."); 663 printk(KERN_ERR "%s: Failed to register scsi device handler.",
664 CLARIION_NAME);
491 return r; 665 return r;
492} 666}
493 667
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index ae6be87d6a83..9c7a1f8ebb72 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 5 * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
6 * Copyright (C) 2006 Mike Christie 6 * Copyright (C) 2006 Mike Christie
7 * Copyright (C) 2008 Hannes Reinecke <hare@suse.de>
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
@@ -25,13 +26,18 @@
25#include <scsi/scsi_eh.h> 26#include <scsi/scsi_eh.h>
26#include <scsi/scsi_dh.h> 27#include <scsi/scsi_dh.h>
27 28
28#define HP_SW_NAME "hp_sw" 29#define HP_SW_NAME "hp_sw"
29 30
30#define HP_SW_TIMEOUT (60 * HZ) 31#define HP_SW_TIMEOUT (60 * HZ)
31#define HP_SW_RETRIES 3 32#define HP_SW_RETRIES 3
33
34#define HP_SW_PATH_UNINITIALIZED -1
35#define HP_SW_PATH_ACTIVE 0
36#define HP_SW_PATH_PASSIVE 1
32 37
33struct hp_sw_dh_data { 38struct hp_sw_dh_data {
34 unsigned char sense[SCSI_SENSE_BUFFERSIZE]; 39 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
40 int path_state;
35 int retries; 41 int retries;
36}; 42};
37 43
@@ -42,51 +48,161 @@ static inline struct hp_sw_dh_data *get_hp_sw_data(struct scsi_device *sdev)
42 return ((struct hp_sw_dh_data *) scsi_dh_data->buf); 48 return ((struct hp_sw_dh_data *) scsi_dh_data->buf);
43} 49}
44 50
45static int hp_sw_done(struct scsi_device *sdev) 51/*
52 * tur_done - Handle TEST UNIT READY return status
53 * @sdev: sdev the command has been sent to
54 * @errors: blk error code
55 *
56 * Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path
57 */
58static int tur_done(struct scsi_device *sdev, unsigned char *sense)
46{ 59{
47 struct hp_sw_dh_data *h = get_hp_sw_data(sdev);
48 struct scsi_sense_hdr sshdr; 60 struct scsi_sense_hdr sshdr;
49 int rc; 61 int ret;
50
51 sdev_printk(KERN_INFO, sdev, "hp_sw_done\n");
52 62
53 rc = scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE, &sshdr); 63 ret = scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr);
54 if (!rc) 64 if (!ret) {
65 sdev_printk(KERN_WARNING, sdev,
66 "%s: sending tur failed, no sense available\n",
67 HP_SW_NAME);
68 ret = SCSI_DH_IO;
55 goto done; 69 goto done;
70 }
56 switch (sshdr.sense_key) { 71 switch (sshdr.sense_key) {
72 case UNIT_ATTENTION:
73 ret = SCSI_DH_IMM_RETRY;
74 break;
57 case NOT_READY: 75 case NOT_READY:
58 if ((sshdr.asc == 0x04) && (sshdr.ascq == 3)) { 76 if ((sshdr.asc == 0x04) && (sshdr.ascq == 2)) {
59 rc = SCSI_DH_RETRY; 77 /*
60 h->retries++; 78 * LUN not ready - Initialization command required
79 *
80 * This is the passive path
81 */
82 ret = SCSI_DH_DEV_OFFLINED;
61 break; 83 break;
62 } 84 }
63 /* fall through */ 85 /* Fallthrough */
64 default: 86 default:
65 h->retries++; 87 sdev_printk(KERN_WARNING, sdev,
66 rc = SCSI_DH_IMM_RETRY; 88 "%s: sending tur failed, sense %x/%x/%x\n",
89 HP_SW_NAME, sshdr.sense_key, sshdr.asc,
90 sshdr.ascq);
91 break;
67 } 92 }
68 93
69done: 94done:
70 if (rc == SCSI_DH_OK || rc == SCSI_DH_IO) 95 return ret;
71 h->retries = 0; 96}
72 else if (h->retries > HP_SW_RETRIES) { 97
73 h->retries = 0; 98/*
99 * hp_sw_tur - Send TEST UNIT READY
100 * @sdev: sdev command should be sent to
101 *
102 * Use the TEST UNIT READY command to determine
103 * the path state.
104 */
105static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
106{
107 struct request *req;
108 int ret;
109
110 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
111 if (!req)
112 return SCSI_DH_RES_TEMP_UNAVAIL;
113
114 req->cmd_type = REQ_TYPE_BLOCK_PC;
115 req->cmd_flags |= REQ_FAILFAST;
116 req->cmd_len = COMMAND_SIZE(TEST_UNIT_READY);
117 memset(req->cmd, 0, MAX_COMMAND_SIZE);
118 req->cmd[0] = TEST_UNIT_READY;
119 req->timeout = HP_SW_TIMEOUT;
120 req->sense = h->sense;
121 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
122 req->sense_len = 0;
123
124retry:
125 ret = blk_execute_rq(req->q, NULL, req, 1);
126 if (ret == -EIO) {
127 if (req->sense_len > 0) {
128 ret = tur_done(sdev, h->sense);
129 } else {
130 sdev_printk(KERN_WARNING, sdev,
131 "%s: sending tur failed with %x\n",
132 HP_SW_NAME, req->errors);
133 ret = SCSI_DH_IO;
134 }
135 } else {
136 h->path_state = HP_SW_PATH_ACTIVE;
137 ret = SCSI_DH_OK;
138 }
139 if (ret == SCSI_DH_IMM_RETRY)
140 goto retry;
141 if (ret == SCSI_DH_DEV_OFFLINED) {
142 h->path_state = HP_SW_PATH_PASSIVE;
143 ret = SCSI_DH_OK;
144 }
145
146 blk_put_request(req);
147
148 return ret;
149}
150
151/*
152 * start_done - Handle START STOP UNIT return status
153 * @sdev: sdev the command has been sent to
154 * @errors: blk error code
155 */
156static int start_done(struct scsi_device *sdev, unsigned char *sense)
157{
158 struct scsi_sense_hdr sshdr;
159 int rc;
160
161 rc = scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr);
162 if (!rc) {
163 sdev_printk(KERN_WARNING, sdev,
164 "%s: sending start_stop_unit failed, "
165 "no sense available\n",
166 HP_SW_NAME);
167 return SCSI_DH_IO;
168 }
169 switch (sshdr.sense_key) {
170 case NOT_READY:
171 if ((sshdr.asc == 0x04) && (sshdr.ascq == 3)) {
172 /*
173 * LUN not ready - manual intervention required
174 *
175 * Switch-over in progress, retry.
176 */
177 rc = SCSI_DH_RETRY;
178 break;
179 }
180 /* fall through */
181 default:
182 sdev_printk(KERN_WARNING, sdev,
183 "%s: sending start_stop_unit failed, sense %x/%x/%x\n",
184 HP_SW_NAME, sshdr.sense_key, sshdr.asc,
185 sshdr.ascq);
74 rc = SCSI_DH_IO; 186 rc = SCSI_DH_IO;
75 } 187 }
188
76 return rc; 189 return rc;
77} 190}
78 191
79static int hp_sw_activate(struct scsi_device *sdev) 192/*
193 * hp_sw_start_stop - Send START STOP UNIT command
194 * @sdev: sdev command should be sent to
195 *
196 * Sending START STOP UNIT activates the SP.
197 */
198static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
80{ 199{
81 struct hp_sw_dh_data *h = get_hp_sw_data(sdev);
82 struct request *req; 200 struct request *req;
83 int ret = SCSI_DH_RES_TEMP_UNAVAIL; 201 int ret, retry;
84 202
85 req = blk_get_request(sdev->request_queue, WRITE, GFP_ATOMIC); 203 req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
86 if (!req) 204 if (!req)
87 goto done; 205 return SCSI_DH_RES_TEMP_UNAVAIL;
88
89 sdev_printk(KERN_INFO, sdev, "sending START_STOP.");
90 206
91 req->cmd_type = REQ_TYPE_BLOCK_PC; 207 req->cmd_type = REQ_TYPE_BLOCK_PC;
92 req->cmd_flags |= REQ_FAILFAST; 208 req->cmd_flags |= REQ_FAILFAST;
@@ -98,95 +214,153 @@ static int hp_sw_activate(struct scsi_device *sdev)
98 req->sense = h->sense; 214 req->sense = h->sense;
99 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); 215 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
100 req->sense_len = 0; 216 req->sense_len = 0;
217 retry = h->retries;
101 218
219retry:
102 ret = blk_execute_rq(req->q, NULL, req, 1); 220 ret = blk_execute_rq(req->q, NULL, req, 1);
103 if (!ret) /* SUCCESS */ 221 if (ret == -EIO) {
104 ret = hp_sw_done(sdev); 222 if (req->sense_len > 0) {
105 else 223 ret = start_done(sdev, h->sense);
224 } else {
225 sdev_printk(KERN_WARNING, sdev,
226 "%s: sending start_stop_unit failed with %x\n",
227 HP_SW_NAME, req->errors);
228 ret = SCSI_DH_IO;
229 }
230 } else
231 ret = SCSI_DH_OK;
232
233 if (ret == SCSI_DH_RETRY) {
234 if (--retry)
235 goto retry;
106 ret = SCSI_DH_IO; 236 ret = SCSI_DH_IO;
107done: 237 }
238
239 blk_put_request(req);
240
241 return ret;
242}
243
244static int hp_sw_prep_fn(struct scsi_device *sdev, struct request *req)
245{
246 struct hp_sw_dh_data *h = get_hp_sw_data(sdev);
247 int ret = BLKPREP_OK;
248
249 if (h->path_state != HP_SW_PATH_ACTIVE) {
250 ret = BLKPREP_KILL;
251 req->cmd_flags |= REQ_QUIET;
252 }
253 return ret;
254
255}
256
257/*
258 * hp_sw_activate - Activate a path
259 * @sdev: sdev on the path to be activated
260 *
261 * The HP Active/Passive firmware is pretty simple;
262 * the passive path reports NOT READY with sense codes
263 * 0x04/0x02; a START STOP UNIT command will then
264 * activate the passive path (and deactivate the
265 * previously active one).
266 */
267static int hp_sw_activate(struct scsi_device *sdev)
268{
269 int ret = SCSI_DH_OK;
270 struct hp_sw_dh_data *h = get_hp_sw_data(sdev);
271
272 ret = hp_sw_tur(sdev, h);
273
274 if (ret == SCSI_DH_OK && h->path_state == HP_SW_PATH_PASSIVE) {
275 ret = hp_sw_start_stop(sdev, h);
276 if (ret == SCSI_DH_OK)
277 sdev_printk(KERN_INFO, sdev,
278 "%s: activated path\n",
279 HP_SW_NAME);
280 }
281
108 return ret; 282 return ret;
109} 283}
110 284
111static const struct { 285const struct scsi_dh_devlist hp_sw_dh_data_list[] = {
112 char *vendor; 286 {"COMPAQ", "MSA1000 VOLUME"},
113 char *model; 287 {"COMPAQ", "HSV110"},
114} hp_sw_dh_data_list[] = { 288 {"HP", "HSV100"},
115 {"COMPAQ", "MSA"},
116 {"HP", "HSV"},
117 {"DEC", "HSG80"}, 289 {"DEC", "HSG80"},
118 {NULL, NULL}, 290 {NULL, NULL},
119}; 291};
120 292
121static int hp_sw_bus_notify(struct notifier_block *, unsigned long, void *); 293static int hp_sw_bus_attach(struct scsi_device *sdev);
294static void hp_sw_bus_detach(struct scsi_device *sdev);
122 295
123static struct scsi_device_handler hp_sw_dh = { 296static struct scsi_device_handler hp_sw_dh = {
124 .name = HP_SW_NAME, 297 .name = HP_SW_NAME,
125 .module = THIS_MODULE, 298 .module = THIS_MODULE,
126 .nb.notifier_call = hp_sw_bus_notify, 299 .devlist = hp_sw_dh_data_list,
300 .attach = hp_sw_bus_attach,
301 .detach = hp_sw_bus_detach,
127 .activate = hp_sw_activate, 302 .activate = hp_sw_activate,
303 .prep_fn = hp_sw_prep_fn,
128}; 304};
129 305
130static int hp_sw_bus_notify(struct notifier_block *nb, 306static int hp_sw_bus_attach(struct scsi_device *sdev)
131 unsigned long action, void *data)
132{ 307{
133 struct device *dev = data;
134 struct scsi_device *sdev;
135 struct scsi_dh_data *scsi_dh_data; 308 struct scsi_dh_data *scsi_dh_data;
136 int i, found = 0; 309 struct hp_sw_dh_data *h;
137 unsigned long flags; 310 unsigned long flags;
311 int ret;
138 312
139 if (!scsi_is_sdev_device(dev)) 313 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
314 + sizeof(struct hp_sw_dh_data) , GFP_KERNEL);
315 if (!scsi_dh_data) {
316 sdev_printk(KERN_ERR, sdev, "%s: Attach Failed\n",
317 HP_SW_NAME);
140 return 0; 318 return 0;
319 }
141 320
142 sdev = to_scsi_device(dev); 321 scsi_dh_data->scsi_dh = &hp_sw_dh;
143 322 h = (struct hp_sw_dh_data *) scsi_dh_data->buf;
144 if (action == BUS_NOTIFY_ADD_DEVICE) { 323 h->path_state = HP_SW_PATH_UNINITIALIZED;
145 for (i = 0; hp_sw_dh_data_list[i].vendor; i++) { 324 h->retries = HP_SW_RETRIES;
146 if (!strncmp(sdev->vendor, hp_sw_dh_data_list[i].vendor,
147 strlen(hp_sw_dh_data_list[i].vendor)) &&
148 !strncmp(sdev->model, hp_sw_dh_data_list[i].model,
149 strlen(hp_sw_dh_data_list[i].model))) {
150 found = 1;
151 break;
152 }
153 }
154 if (!found)
155 goto out;
156 325
157 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *) 326 ret = hp_sw_tur(sdev, h);
158 + sizeof(struct hp_sw_dh_data) , GFP_KERNEL); 327 if (ret != SCSI_DH_OK || h->path_state == HP_SW_PATH_UNINITIALIZED)
159 if (!scsi_dh_data) { 328 goto failed;
160 sdev_printk(KERN_ERR, sdev, "Attach Failed %s.\n",
161 HP_SW_NAME);
162 goto out;
163 }
164 329
165 scsi_dh_data->scsi_dh = &hp_sw_dh; 330 if (!try_module_get(THIS_MODULE))
166 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 331 goto failed;
167 sdev->scsi_dh_data = scsi_dh_data;
168 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
169 try_module_get(THIS_MODULE);
170 332
171 sdev_printk(KERN_NOTICE, sdev, "Attached %s.\n", HP_SW_NAME); 333 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
172 } else if (action == BUS_NOTIFY_DEL_DEVICE) { 334 sdev->scsi_dh_data = scsi_dh_data;
173 if (sdev->scsi_dh_data == NULL || 335 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
174 sdev->scsi_dh_data->scsi_dh != &hp_sw_dh)
175 goto out;
176 336
177 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 337 sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n",
178 scsi_dh_data = sdev->scsi_dh_data; 338 HP_SW_NAME, h->path_state == HP_SW_PATH_ACTIVE?
179 sdev->scsi_dh_data = NULL; 339 "active":"passive");
180 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
181 module_put(THIS_MODULE);
182 340
183 sdev_printk(KERN_NOTICE, sdev, "Dettached %s.\n", HP_SW_NAME); 341 return 0;
184 342
185 kfree(scsi_dh_data); 343failed:
186 } 344 kfree(scsi_dh_data);
345 sdev_printk(KERN_ERR, sdev, "%s: not attached\n",
346 HP_SW_NAME);
347 return -EINVAL;
348}
187 349
188out: 350static void hp_sw_bus_detach( struct scsi_device *sdev )
189 return 0; 351{
352 struct scsi_dh_data *scsi_dh_data;
353 unsigned long flags;
354
355 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
356 scsi_dh_data = sdev->scsi_dh_data;
357 sdev->scsi_dh_data = NULL;
358 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
359 module_put(THIS_MODULE);
360
361 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", HP_SW_NAME);
362
363 kfree(scsi_dh_data);
190} 364}
191 365
192static int __init hp_sw_init(void) 366static int __init hp_sw_init(void)
@@ -202,6 +376,6 @@ static void __exit hp_sw_exit(void)
202module_init(hp_sw_init); 376module_init(hp_sw_init);
203module_exit(hp_sw_exit); 377module_exit(hp_sw_exit);
204 378
205MODULE_DESCRIPTION("HP MSA 1000"); 379MODULE_DESCRIPTION("HP Active/Passive driver");
206MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu"); 380MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu");
207MODULE_LICENSE("GPL"); 381MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index fdf34b0ec6e1..b093a501f8ae 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -173,6 +173,11 @@ struct rdac_dh_data {
173#define RDAC_STATE_ACTIVE 0 173#define RDAC_STATE_ACTIVE 0
174#define RDAC_STATE_PASSIVE 1 174#define RDAC_STATE_PASSIVE 1
175 unsigned char state; 175 unsigned char state;
176
177#define RDAC_LUN_UNOWNED 0
178#define RDAC_LUN_OWNED 1
179#define RDAC_LUN_AVT 2
180 char lun_state;
176 unsigned char sense[SCSI_SENSE_BUFFERSIZE]; 181 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
177 union { 182 union {
178 struct c2_inquiry c2; 183 struct c2_inquiry c2;
@@ -182,6 +187,13 @@ struct rdac_dh_data {
182 } inq; 187 } inq;
183}; 188};
184 189
190static const char *lun_state[] =
191{
192 "unowned",
193 "owned",
194 "owned (AVT mode)",
195};
196
185static LIST_HEAD(ctlr_list); 197static LIST_HEAD(ctlr_list);
186static DEFINE_SPINLOCK(list_lock); 198static DEFINE_SPINLOCK(list_lock);
187 199
@@ -197,9 +209,8 @@ static struct request *get_rdac_req(struct scsi_device *sdev,
197{ 209{
198 struct request *rq; 210 struct request *rq;
199 struct request_queue *q = sdev->request_queue; 211 struct request_queue *q = sdev->request_queue;
200 struct rdac_dh_data *h = get_rdac_data(sdev);
201 212
202 rq = blk_get_request(q, rw, GFP_KERNEL); 213 rq = blk_get_request(q, rw, GFP_NOIO);
203 214
204 if (!rq) { 215 if (!rq) {
205 sdev_printk(KERN_INFO, sdev, 216 sdev_printk(KERN_INFO, sdev,
@@ -207,17 +218,14 @@ static struct request *get_rdac_req(struct scsi_device *sdev,
207 return NULL; 218 return NULL;
208 } 219 }
209 220
210 if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_KERNEL)) { 221 if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_NOIO)) {
211 blk_put_request(rq); 222 blk_put_request(rq);
212 sdev_printk(KERN_INFO, sdev, 223 sdev_printk(KERN_INFO, sdev,
213 "get_rdac_req: blk_rq_map_kern failed.\n"); 224 "get_rdac_req: blk_rq_map_kern failed.\n");
214 return NULL; 225 return NULL;
215 } 226 }
216 227
217 memset(&rq->cmd, 0, BLK_MAX_CDB); 228 memset(rq->cmd, 0, BLK_MAX_CDB);
218 rq->sense = h->sense;
219 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
220 rq->sense_len = 0;
221 229
222 rq->cmd_type = REQ_TYPE_BLOCK_PC; 230 rq->cmd_type = REQ_TYPE_BLOCK_PC;
223 rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE; 231 rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE;
@@ -227,12 +235,12 @@ static struct request *get_rdac_req(struct scsi_device *sdev,
227 return rq; 235 return rq;
228} 236}
229 237
230static struct request *rdac_failover_get(struct scsi_device *sdev) 238static struct request *rdac_failover_get(struct scsi_device *sdev,
239 struct rdac_dh_data *h)
231{ 240{
232 struct request *rq; 241 struct request *rq;
233 struct rdac_mode_common *common; 242 struct rdac_mode_common *common;
234 unsigned data_size; 243 unsigned data_size;
235 struct rdac_dh_data *h = get_rdac_data(sdev);
236 244
237 if (h->ctlr->use_ms10) { 245 if (h->ctlr->use_ms10) {
238 struct rdac_pg_expanded *rdac_pg; 246 struct rdac_pg_expanded *rdac_pg;
@@ -277,6 +285,10 @@ static struct request *rdac_failover_get(struct scsi_device *sdev)
277 } 285 }
278 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]); 286 rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
279 287
288 rq->sense = h->sense;
289 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
290 rq->sense_len = 0;
291
280 return rq; 292 return rq;
281} 293}
282 294
@@ -321,11 +333,10 @@ done:
321} 333}
322 334
323static int submit_inquiry(struct scsi_device *sdev, int page_code, 335static int submit_inquiry(struct scsi_device *sdev, int page_code,
324 unsigned int len) 336 unsigned int len, struct rdac_dh_data *h)
325{ 337{
326 struct request *rq; 338 struct request *rq;
327 struct request_queue *q = sdev->request_queue; 339 struct request_queue *q = sdev->request_queue;
328 struct rdac_dh_data *h = get_rdac_data(sdev);
329 int err = SCSI_DH_RES_TEMP_UNAVAIL; 340 int err = SCSI_DH_RES_TEMP_UNAVAIL;
330 341
331 rq = get_rdac_req(sdev, &h->inq, len, READ); 342 rq = get_rdac_req(sdev, &h->inq, len, READ);
@@ -338,59 +349,68 @@ static int submit_inquiry(struct scsi_device *sdev, int page_code,
338 rq->cmd[2] = page_code; 349 rq->cmd[2] = page_code;
339 rq->cmd[4] = len; 350 rq->cmd[4] = len;
340 rq->cmd_len = COMMAND_SIZE(INQUIRY); 351 rq->cmd_len = COMMAND_SIZE(INQUIRY);
352
353 rq->sense = h->sense;
354 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
355 rq->sense_len = 0;
356
341 err = blk_execute_rq(q, NULL, rq, 1); 357 err = blk_execute_rq(q, NULL, rq, 1);
342 if (err == -EIO) 358 if (err == -EIO)
343 err = SCSI_DH_IO; 359 err = SCSI_DH_IO;
360
361 blk_put_request(rq);
344done: 362done:
345 return err; 363 return err;
346} 364}
347 365
348static int get_lun(struct scsi_device *sdev) 366static int get_lun(struct scsi_device *sdev, struct rdac_dh_data *h)
349{ 367{
350 int err; 368 int err;
351 struct c8_inquiry *inqp; 369 struct c8_inquiry *inqp;
352 struct rdac_dh_data *h = get_rdac_data(sdev);
353 370
354 err = submit_inquiry(sdev, 0xC8, sizeof(struct c8_inquiry)); 371 err = submit_inquiry(sdev, 0xC8, sizeof(struct c8_inquiry), h);
355 if (err == SCSI_DH_OK) { 372 if (err == SCSI_DH_OK) {
356 inqp = &h->inq.c8; 373 inqp = &h->inq.c8;
357 h->lun = inqp->lun[7]; /* currently it uses only one byte */ 374 if (inqp->page_code != 0xc8)
375 return SCSI_DH_NOSYS;
376 if (inqp->page_id[0] != 'e' || inqp->page_id[1] != 'd' ||
377 inqp->page_id[2] != 'i' || inqp->page_id[3] != 'd')
378 return SCSI_DH_NOSYS;
379 h->lun = scsilun_to_int((struct scsi_lun *)inqp->lun);
358 } 380 }
359 return err; 381 return err;
360} 382}
361 383
362#define RDAC_OWNED 0 384static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)
363#define RDAC_UNOWNED 1
364#define RDAC_FAILED 2
365static int check_ownership(struct scsi_device *sdev)
366{ 385{
367 int err; 386 int err;
368 struct c9_inquiry *inqp; 387 struct c9_inquiry *inqp;
369 struct rdac_dh_data *h = get_rdac_data(sdev);
370 388
371 err = submit_inquiry(sdev, 0xC9, sizeof(struct c9_inquiry)); 389 err = submit_inquiry(sdev, 0xC9, sizeof(struct c9_inquiry), h);
372 if (err == SCSI_DH_OK) { 390 if (err == SCSI_DH_OK) {
373 err = RDAC_UNOWNED;
374 inqp = &h->inq.c9; 391 inqp = &h->inq.c9;
375 /* 392 if ((inqp->avte_cvp >> 7) == 0x1) {
376 * If in AVT mode or if the path already owns the LUN, 393 /* LUN in AVT mode */
377 * return RDAC_OWNED; 394 sdev_printk(KERN_NOTICE, sdev,
378 */ 395 "%s: AVT mode detected\n",
379 if (((inqp->avte_cvp >> 7) == 0x1) || 396 RDAC_NAME);
380 ((inqp->avte_cvp & 0x1) != 0)) 397 h->lun_state = RDAC_LUN_AVT;
381 err = RDAC_OWNED; 398 } else if ((inqp->avte_cvp & 0x1) != 0) {
382 } else 399 /* LUN was owned by the controller */
383 err = RDAC_FAILED; 400 h->lun_state = RDAC_LUN_OWNED;
401 }
402 }
403
384 return err; 404 return err;
385} 405}
386 406
387static int initialize_controller(struct scsi_device *sdev) 407static int initialize_controller(struct scsi_device *sdev,
408 struct rdac_dh_data *h)
388{ 409{
389 int err; 410 int err;
390 struct c4_inquiry *inqp; 411 struct c4_inquiry *inqp;
391 struct rdac_dh_data *h = get_rdac_data(sdev);
392 412
393 err = submit_inquiry(sdev, 0xC4, sizeof(struct c4_inquiry)); 413 err = submit_inquiry(sdev, 0xC4, sizeof(struct c4_inquiry), h);
394 if (err == SCSI_DH_OK) { 414 if (err == SCSI_DH_OK) {
395 inqp = &h->inq.c4; 415 inqp = &h->inq.c4;
396 h->ctlr = get_controller(inqp->subsys_id, inqp->slot_id); 416 h->ctlr = get_controller(inqp->subsys_id, inqp->slot_id);
@@ -400,13 +420,12 @@ static int initialize_controller(struct scsi_device *sdev)
400 return err; 420 return err;
401} 421}
402 422
403static int set_mode_select(struct scsi_device *sdev) 423static int set_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h)
404{ 424{
405 int err; 425 int err;
406 struct c2_inquiry *inqp; 426 struct c2_inquiry *inqp;
407 struct rdac_dh_data *h = get_rdac_data(sdev);
408 427
409 err = submit_inquiry(sdev, 0xC2, sizeof(struct c2_inquiry)); 428 err = submit_inquiry(sdev, 0xC2, sizeof(struct c2_inquiry), h);
410 if (err == SCSI_DH_OK) { 429 if (err == SCSI_DH_OK) {
411 inqp = &h->inq.c2; 430 inqp = &h->inq.c2;
412 /* 431 /*
@@ -421,13 +440,13 @@ static int set_mode_select(struct scsi_device *sdev)
421 return err; 440 return err;
422} 441}
423 442
424static int mode_select_handle_sense(struct scsi_device *sdev) 443static int mode_select_handle_sense(struct scsi_device *sdev,
444 unsigned char *sensebuf)
425{ 445{
426 struct scsi_sense_hdr sense_hdr; 446 struct scsi_sense_hdr sense_hdr;
427 struct rdac_dh_data *h = get_rdac_data(sdev);
428 int sense, err = SCSI_DH_IO, ret; 447 int sense, err = SCSI_DH_IO, ret;
429 448
430 ret = scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE, &sense_hdr); 449 ret = scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE, &sense_hdr);
431 if (!ret) 450 if (!ret)
432 goto done; 451 goto done;
433 452
@@ -451,14 +470,13 @@ done:
451 return err; 470 return err;
452} 471}
453 472
454static int send_mode_select(struct scsi_device *sdev) 473static int send_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h)
455{ 474{
456 struct request *rq; 475 struct request *rq;
457 struct request_queue *q = sdev->request_queue; 476 struct request_queue *q = sdev->request_queue;
458 struct rdac_dh_data *h = get_rdac_data(sdev);
459 int err = SCSI_DH_RES_TEMP_UNAVAIL; 477 int err = SCSI_DH_RES_TEMP_UNAVAIL;
460 478
461 rq = rdac_failover_get(sdev); 479 rq = rdac_failover_get(sdev, h);
462 if (!rq) 480 if (!rq)
463 goto done; 481 goto done;
464 482
@@ -466,9 +484,11 @@ static int send_mode_select(struct scsi_device *sdev)
466 484
467 err = blk_execute_rq(q, NULL, rq, 1); 485 err = blk_execute_rq(q, NULL, rq, 1);
468 if (err != SCSI_DH_OK) 486 if (err != SCSI_DH_OK)
469 err = mode_select_handle_sense(sdev); 487 err = mode_select_handle_sense(sdev, h->sense);
470 if (err == SCSI_DH_OK) 488 if (err == SCSI_DH_OK)
471 h->state = RDAC_STATE_ACTIVE; 489 h->state = RDAC_STATE_ACTIVE;
490
491 blk_put_request(rq);
472done: 492done:
473 return err; 493 return err;
474} 494}
@@ -478,38 +498,23 @@ static int rdac_activate(struct scsi_device *sdev)
478 struct rdac_dh_data *h = get_rdac_data(sdev); 498 struct rdac_dh_data *h = get_rdac_data(sdev);
479 int err = SCSI_DH_OK; 499 int err = SCSI_DH_OK;
480 500
481 if (h->lun == UNINITIALIZED_LUN) { 501 err = check_ownership(sdev, h);
482 err = get_lun(sdev); 502 if (err != SCSI_DH_OK)
483 if (err != SCSI_DH_OK)
484 goto done;
485 }
486
487 err = check_ownership(sdev);
488 switch (err) {
489 case RDAC_UNOWNED:
490 break;
491 case RDAC_OWNED:
492 err = SCSI_DH_OK;
493 goto done;
494 case RDAC_FAILED:
495 default:
496 err = SCSI_DH_IO;
497 goto done; 503 goto done;
498 }
499 504
500 if (!h->ctlr) { 505 if (!h->ctlr) {
501 err = initialize_controller(sdev); 506 err = initialize_controller(sdev, h);
502 if (err != SCSI_DH_OK) 507 if (err != SCSI_DH_OK)
503 goto done; 508 goto done;
504 } 509 }
505 510
506 if (h->ctlr->use_ms10 == -1) { 511 if (h->ctlr->use_ms10 == -1) {
507 err = set_mode_select(sdev); 512 err = set_mode_select(sdev, h);
508 if (err != SCSI_DH_OK) 513 if (err != SCSI_DH_OK)
509 goto done; 514 goto done;
510 } 515 }
511 516 if (h->lun_state == RDAC_LUN_UNOWNED)
512 err = send_mode_select(sdev); 517 err = send_mode_select(sdev, h);
513done: 518done:
514 return err; 519 return err;
515} 520}
@@ -569,10 +574,7 @@ static int rdac_check_sense(struct scsi_device *sdev,
569 return SCSI_RETURN_NOT_HANDLED; 574 return SCSI_RETURN_NOT_HANDLED;
570} 575}
571 576
572static const struct { 577const struct scsi_dh_devlist rdac_dev_list[] = {
573 char *vendor;
574 char *model;
575} rdac_dev_list[] = {
576 {"IBM", "1722"}, 578 {"IBM", "1722"},
577 {"IBM", "1724"}, 579 {"IBM", "1724"},
578 {"IBM", "1726"}, 580 {"IBM", "1726"},
@@ -590,89 +592,89 @@ static const struct {
590 {NULL, NULL}, 592 {NULL, NULL},
591}; 593};
592 594
593static int rdac_bus_notify(struct notifier_block *, unsigned long, void *); 595static int rdac_bus_attach(struct scsi_device *sdev);
596static void rdac_bus_detach(struct scsi_device *sdev);
594 597
595static struct scsi_device_handler rdac_dh = { 598static struct scsi_device_handler rdac_dh = {
596 .name = RDAC_NAME, 599 .name = RDAC_NAME,
597 .module = THIS_MODULE, 600 .module = THIS_MODULE,
598 .nb.notifier_call = rdac_bus_notify, 601 .devlist = rdac_dev_list,
599 .prep_fn = rdac_prep_fn, 602 .prep_fn = rdac_prep_fn,
600 .check_sense = rdac_check_sense, 603 .check_sense = rdac_check_sense,
604 .attach = rdac_bus_attach,
605 .detach = rdac_bus_detach,
601 .activate = rdac_activate, 606 .activate = rdac_activate,
602}; 607};
603 608
604/* 609static int rdac_bus_attach(struct scsi_device *sdev)
605 * TODO: need some interface so we can set trespass values
606 */
607static int rdac_bus_notify(struct notifier_block *nb,
608 unsigned long action, void *data)
609{ 610{
610 struct device *dev = data;
611 struct scsi_device *sdev;
612 struct scsi_dh_data *scsi_dh_data; 611 struct scsi_dh_data *scsi_dh_data;
613 struct rdac_dh_data *h; 612 struct rdac_dh_data *h;
614 int i, found = 0;
615 unsigned long flags; 613 unsigned long flags;
614 int err;
616 615
617 if (!scsi_is_sdev_device(dev)) 616 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
617 + sizeof(*h) , GFP_KERNEL);
618 if (!scsi_dh_data) {
619 sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
620 RDAC_NAME);
618 return 0; 621 return 0;
622 }
619 623
620 sdev = to_scsi_device(dev); 624 scsi_dh_data->scsi_dh = &rdac_dh;
621 625 h = (struct rdac_dh_data *) scsi_dh_data->buf;
622 if (action == BUS_NOTIFY_ADD_DEVICE) { 626 h->lun = UNINITIALIZED_LUN;
623 for (i = 0; rdac_dev_list[i].vendor; i++) { 627 h->state = RDAC_STATE_ACTIVE;
624 if (!strncmp(sdev->vendor, rdac_dev_list[i].vendor,
625 strlen(rdac_dev_list[i].vendor)) &&
626 !strncmp(sdev->model, rdac_dev_list[i].model,
627 strlen(rdac_dev_list[i].model))) {
628 found = 1;
629 break;
630 }
631 }
632 if (!found)
633 goto out;
634 628
635 scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *) 629 err = get_lun(sdev, h);
636 + sizeof(*h) , GFP_KERNEL); 630 if (err != SCSI_DH_OK)
637 if (!scsi_dh_data) { 631 goto failed;
638 sdev_printk(KERN_ERR, sdev, "Attach failed %s.\n",
639 RDAC_NAME);
640 goto out;
641 }
642 632
643 scsi_dh_data->scsi_dh = &rdac_dh; 633 err = check_ownership(sdev, h);
644 h = (struct rdac_dh_data *) scsi_dh_data->buf; 634 if (err != SCSI_DH_OK)
645 h->lun = UNINITIALIZED_LUN; 635 goto failed;
646 h->state = RDAC_STATE_ACTIVE; 636
647 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 637 if (!try_module_get(THIS_MODULE))
648 sdev->scsi_dh_data = scsi_dh_data; 638 goto failed;
649 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags); 639
650 try_module_get(THIS_MODULE); 640 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
651 641 sdev->scsi_dh_data = scsi_dh_data;
652 sdev_printk(KERN_NOTICE, sdev, "Attached %s.\n", RDAC_NAME); 642 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
653 643
654 } else if (action == BUS_NOTIFY_DEL_DEVICE) { 644 sdev_printk(KERN_NOTICE, sdev,
655 if (sdev->scsi_dh_data == NULL || 645 "%s: LUN %d (%s)\n",
656 sdev->scsi_dh_data->scsi_dh != &rdac_dh) 646 RDAC_NAME, h->lun, lun_state[(int)h->lun_state]);
657 goto out;
658
659 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
660 scsi_dh_data = sdev->scsi_dh_data;
661 sdev->scsi_dh_data = NULL;
662 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
663
664 h = (struct rdac_dh_data *) scsi_dh_data->buf;
665 if (h->ctlr)
666 kref_put(&h->ctlr->kref, release_controller);
667 kfree(scsi_dh_data);
668 module_put(THIS_MODULE);
669 sdev_printk(KERN_NOTICE, sdev, "Dettached %s.\n", RDAC_NAME);
670 }
671 647
672out:
673 return 0; 648 return 0;
649
650failed:
651 kfree(scsi_dh_data);
652 sdev_printk(KERN_ERR, sdev, "%s: not attached\n",
653 RDAC_NAME);
654 return -EINVAL;
655}
656
657static void rdac_bus_detach( struct scsi_device *sdev )
658{
659 struct scsi_dh_data *scsi_dh_data;
660 struct rdac_dh_data *h;
661 unsigned long flags;
662
663 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
664 scsi_dh_data = sdev->scsi_dh_data;
665 sdev->scsi_dh_data = NULL;
666 spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
667
668 h = (struct rdac_dh_data *) scsi_dh_data->buf;
669 if (h->ctlr)
670 kref_put(&h->ctlr->kref, release_controller);
671 kfree(scsi_dh_data);
672 module_put(THIS_MODULE);
673 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME);
674} 674}
675 675
676
677
676static int __init rdac_init(void) 678static int __init rdac_init(void)
677{ 679{
678 int r; 680 int r;
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index c4a7c06793c5..ae560bc04f9d 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -521,9 +521,10 @@ static void ibmvfc_set_host_action(struct ibmvfc_host *vhost,
521static void ibmvfc_reinit_host(struct ibmvfc_host *vhost) 521static void ibmvfc_reinit_host(struct ibmvfc_host *vhost)
522{ 522{
523 if (vhost->action == IBMVFC_HOST_ACTION_NONE) { 523 if (vhost->action == IBMVFC_HOST_ACTION_NONE) {
524 scsi_block_requests(vhost->host); 524 if (!ibmvfc_set_host_state(vhost, IBMVFC_INITIALIZING)) {
525 ibmvfc_set_host_state(vhost, IBMVFC_INITIALIZING); 525 scsi_block_requests(vhost->host);
526 ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY); 526 ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY);
527 }
527 } else 528 } else
528 vhost->reinit = 1; 529 vhost->reinit = 1;
529 530
@@ -854,39 +855,41 @@ static void ibmvfc_retry_host_init(struct ibmvfc_host *vhost)
854} 855}
855 856
856/** 857/**
857 * __ibmvfc_find_target - Find the specified scsi_target (no locking) 858 * __ibmvfc_get_target - Find the specified scsi_target (no locking)
858 * @starget: scsi target struct 859 * @starget: scsi target struct
859 * 860 *
860 * Return value: 861 * Return value:
861 * ibmvfc_target struct / NULL if not found 862 * ibmvfc_target struct / NULL if not found
862 **/ 863 **/
863static struct ibmvfc_target *__ibmvfc_find_target(struct scsi_target *starget) 864static struct ibmvfc_target *__ibmvfc_get_target(struct scsi_target *starget)
864{ 865{
865 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 866 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
866 struct ibmvfc_host *vhost = shost_priv(shost); 867 struct ibmvfc_host *vhost = shost_priv(shost);
867 struct ibmvfc_target *tgt; 868 struct ibmvfc_target *tgt;
868 869
869 list_for_each_entry(tgt, &vhost->targets, queue) 870 list_for_each_entry(tgt, &vhost->targets, queue)
870 if (tgt->target_id == starget->id) 871 if (tgt->target_id == starget->id) {
872 kref_get(&tgt->kref);
871 return tgt; 873 return tgt;
874 }
872 return NULL; 875 return NULL;
873} 876}
874 877
875/** 878/**
876 * ibmvfc_find_target - Find the specified scsi_target 879 * ibmvfc_get_target - Find the specified scsi_target
877 * @starget: scsi target struct 880 * @starget: scsi target struct
878 * 881 *
879 * Return value: 882 * Return value:
880 * ibmvfc_target struct / NULL if not found 883 * ibmvfc_target struct / NULL if not found
881 **/ 884 **/
882static struct ibmvfc_target *ibmvfc_find_target(struct scsi_target *starget) 885static struct ibmvfc_target *ibmvfc_get_target(struct scsi_target *starget)
883{ 886{
884 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 887 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
885 struct ibmvfc_target *tgt; 888 struct ibmvfc_target *tgt;
886 unsigned long flags; 889 unsigned long flags;
887 890
888 spin_lock_irqsave(shost->host_lock, flags); 891 spin_lock_irqsave(shost->host_lock, flags);
889 tgt = __ibmvfc_find_target(starget); 892 tgt = __ibmvfc_get_target(starget);
890 spin_unlock_irqrestore(shost->host_lock, flags); 893 spin_unlock_irqrestore(shost->host_lock, flags);
891 return tgt; 894 return tgt;
892} 895}
@@ -963,6 +966,9 @@ static void ibmvfc_get_host_port_state(struct Scsi_Host *shost)
963 case IBMVFC_HALTED: 966 case IBMVFC_HALTED:
964 fc_host_port_state(shost) = FC_PORTSTATE_BLOCKED; 967 fc_host_port_state(shost) = FC_PORTSTATE_BLOCKED;
965 break; 968 break;
969 case IBMVFC_NO_CRQ:
970 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
971 break;
966 default: 972 default:
967 ibmvfc_log(vhost, 3, "Unknown port state: %d\n", vhost->state); 973 ibmvfc_log(vhost, 3, "Unknown port state: %d\n", vhost->state);
968 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; 974 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
@@ -988,6 +994,17 @@ static void ibmvfc_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
988} 994}
989 995
990/** 996/**
997 * ibmvfc_release_tgt - Free memory allocated for a target
998 * @kref: kref struct
999 *
1000 **/
1001static void ibmvfc_release_tgt(struct kref *kref)
1002{
1003 struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref);
1004 kfree(tgt);
1005}
1006
1007/**
991 * ibmvfc_get_starget_node_name - Get SCSI target's node name 1008 * ibmvfc_get_starget_node_name - Get SCSI target's node name
992 * @starget: scsi target struct 1009 * @starget: scsi target struct
993 * 1010 *
@@ -996,8 +1013,10 @@ static void ibmvfc_set_rport_dev_loss_tmo(struct fc_rport *rport, u32 timeout)
996 **/ 1013 **/
997static void ibmvfc_get_starget_node_name(struct scsi_target *starget) 1014static void ibmvfc_get_starget_node_name(struct scsi_target *starget)
998{ 1015{
999 struct ibmvfc_target *tgt = ibmvfc_find_target(starget); 1016 struct ibmvfc_target *tgt = ibmvfc_get_target(starget);
1000 fc_starget_port_name(starget) = tgt ? tgt->ids.node_name : 0; 1017 fc_starget_port_name(starget) = tgt ? tgt->ids.node_name : 0;
1018 if (tgt)
1019 kref_put(&tgt->kref, ibmvfc_release_tgt);
1001} 1020}
1002 1021
1003/** 1022/**
@@ -1009,8 +1028,10 @@ static void ibmvfc_get_starget_node_name(struct scsi_target *starget)
1009 **/ 1028 **/
1010static void ibmvfc_get_starget_port_name(struct scsi_target *starget) 1029static void ibmvfc_get_starget_port_name(struct scsi_target *starget)
1011{ 1030{
1012 struct ibmvfc_target *tgt = ibmvfc_find_target(starget); 1031 struct ibmvfc_target *tgt = ibmvfc_get_target(starget);
1013 fc_starget_port_name(starget) = tgt ? tgt->ids.port_name : 0; 1032 fc_starget_port_name(starget) = tgt ? tgt->ids.port_name : 0;
1033 if (tgt)
1034 kref_put(&tgt->kref, ibmvfc_release_tgt);
1014} 1035}
1015 1036
1016/** 1037/**
@@ -1022,8 +1043,10 @@ static void ibmvfc_get_starget_port_name(struct scsi_target *starget)
1022 **/ 1043 **/
1023static void ibmvfc_get_starget_port_id(struct scsi_target *starget) 1044static void ibmvfc_get_starget_port_id(struct scsi_target *starget)
1024{ 1045{
1025 struct ibmvfc_target *tgt = ibmvfc_find_target(starget); 1046 struct ibmvfc_target *tgt = ibmvfc_get_target(starget);
1026 fc_starget_port_id(starget) = tgt ? tgt->scsi_id : -1; 1047 fc_starget_port_id(starget) = tgt ? tgt->scsi_id : -1;
1048 if (tgt)
1049 kref_put(&tgt->kref, ibmvfc_release_tgt);
1027} 1050}
1028 1051
1029/** 1052/**
@@ -1113,7 +1136,7 @@ static void ibmvfc_set_login_info(struct ibmvfc_host *vhost)
1113 login_info->max_cmds = max_requests + IBMVFC_NUM_INTERNAL_REQ; 1136 login_info->max_cmds = max_requests + IBMVFC_NUM_INTERNAL_REQ;
1114 login_info->capabilities = IBMVFC_CAN_MIGRATE; 1137 login_info->capabilities = IBMVFC_CAN_MIGRATE;
1115 login_info->async.va = vhost->async_crq.msg_token; 1138 login_info->async.va = vhost->async_crq.msg_token;
1116 login_info->async.len = vhost->async_crq.size; 1139 login_info->async.len = vhost->async_crq.size * sizeof(*vhost->async_crq.msgs);
1117 strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME); 1140 strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME);
1118 strncpy(login_info->device_name, 1141 strncpy(login_info->device_name,
1119 vhost->host->shost_gendev.bus_id, IBMVFC_MAX_NAME); 1142 vhost->host->shost_gendev.bus_id, IBMVFC_MAX_NAME);
@@ -1404,7 +1427,7 @@ static void ibmvfc_log_error(struct ibmvfc_event *evt)
1404 err = cmd_status[index].name; 1427 err = cmd_status[index].name;
1405 } 1428 }
1406 1429
1407 if (!logerr && (vhost->log_level <= IBMVFC_DEFAULT_LOG_LEVEL)) 1430 if (!logerr && (vhost->log_level <= (IBMVFC_DEFAULT_LOG_LEVEL + 1)))
1408 return; 1431 return;
1409 1432
1410 if (rsp->flags & FCP_RSP_LEN_VALID) 1433 if (rsp->flags & FCP_RSP_LEN_VALID)
@@ -2054,7 +2077,7 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
2054{ 2077{
2055 const char *desc = ibmvfc_get_ae_desc(crq->event); 2078 const char *desc = ibmvfc_get_ae_desc(crq->event);
2056 2079
2057 ibmvfc_log(vhost, 2, "%s event received\n", desc); 2080 ibmvfc_log(vhost, 3, "%s event received\n", desc);
2058 2081
2059 switch (crq->event) { 2082 switch (crq->event) {
2060 case IBMVFC_AE_LINK_UP: 2083 case IBMVFC_AE_LINK_UP:
@@ -2648,17 +2671,6 @@ static void ibmvfc_retry_tgt_init(struct ibmvfc_target *tgt,
2648} 2671}
2649 2672
2650/** 2673/**
2651 * ibmvfc_release_tgt - Free memory allocated for a target
2652 * @kref: kref struct
2653 *
2654 **/
2655static void ibmvfc_release_tgt(struct kref *kref)
2656{
2657 struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref);
2658 kfree(tgt);
2659}
2660
2661/**
2662 * ibmvfc_tgt_prli_done - Completion handler for Process Login 2674 * ibmvfc_tgt_prli_done - Completion handler for Process Login
2663 * @evt: ibmvfc event struct 2675 * @evt: ibmvfc event struct
2664 * 2676 *
@@ -2902,6 +2914,139 @@ static void ibmvfc_tgt_implicit_logout(struct ibmvfc_target *tgt)
2902} 2914}
2903 2915
2904/** 2916/**
2917 * ibmvfc_adisc_needs_plogi - Does device need PLOGI?
2918 * @mad: ibmvfc passthru mad struct
2919 * @tgt: ibmvfc target struct
2920 *
2921 * Returns:
2922 * 1 if PLOGI needed / 0 if PLOGI not needed
2923 **/
2924static int ibmvfc_adisc_needs_plogi(struct ibmvfc_passthru_mad *mad,
2925 struct ibmvfc_target *tgt)
2926{
2927 if (memcmp(&mad->fc_iu.response[2], &tgt->ids.port_name,
2928 sizeof(tgt->ids.port_name)))
2929 return 1;
2930 if (memcmp(&mad->fc_iu.response[4], &tgt->ids.node_name,
2931 sizeof(tgt->ids.node_name)))
2932 return 1;
2933 if (mad->fc_iu.response[6] != tgt->scsi_id)
2934 return 1;
2935 return 0;
2936}
2937
2938/**
2939 * ibmvfc_tgt_adisc_done - Completion handler for ADISC
2940 * @evt: ibmvfc event struct
2941 *
2942 **/
2943static void ibmvfc_tgt_adisc_done(struct ibmvfc_event *evt)
2944{
2945 struct ibmvfc_target *tgt = evt->tgt;
2946 struct ibmvfc_host *vhost = evt->vhost;
2947 struct ibmvfc_passthru_mad *mad = &evt->xfer_iu->passthru;
2948 u32 status = mad->common.status;
2949 u8 fc_reason, fc_explain;
2950
2951 vhost->discovery_threads--;
2952 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE);
2953
2954 switch (status) {
2955 case IBMVFC_MAD_SUCCESS:
2956 tgt_dbg(tgt, "ADISC succeeded\n");
2957 if (ibmvfc_adisc_needs_plogi(mad, tgt))
2958 tgt->need_login = 1;
2959 break;
2960 case IBMVFC_MAD_DRIVER_FAILED:
2961 break;
2962 case IBMVFC_MAD_FAILED:
2963 default:
2964 tgt->need_login = 1;
2965 fc_reason = (mad->fc_iu.response[1] & 0x00ff0000) >> 16;
2966 fc_explain = (mad->fc_iu.response[1] & 0x0000ff00) >> 8;
2967 tgt_info(tgt, "ADISC failed: %s (%x:%x) %s (%x) %s (%x) rc=0x%02X\n",
2968 ibmvfc_get_cmd_error(mad->iu.status, mad->iu.error),
2969 mad->iu.status, mad->iu.error,
2970 ibmvfc_get_fc_type(fc_reason), fc_reason,
2971 ibmvfc_get_ls_explain(fc_explain), fc_explain, status);
2972 break;
2973 };
2974
2975 kref_put(&tgt->kref, ibmvfc_release_tgt);
2976 ibmvfc_free_event(evt);
2977 wake_up(&vhost->work_wait_q);
2978}
2979
2980/**
2981 * ibmvfc_init_passthru - Initialize an event struct for FC passthru
2982 * @evt: ibmvfc event struct
2983 *
2984 **/
2985static void ibmvfc_init_passthru(struct ibmvfc_event *evt)
2986{
2987 struct ibmvfc_passthru_mad *mad = &evt->iu.passthru;
2988
2989 memset(mad, 0, sizeof(*mad));
2990 mad->common.version = 1;
2991 mad->common.opcode = IBMVFC_PASSTHRU;
2992 mad->common.length = sizeof(*mad) - sizeof(mad->fc_iu) - sizeof(mad->iu);
2993 mad->cmd_ioba.va = (u64)evt->crq.ioba +
2994 offsetof(struct ibmvfc_passthru_mad, iu);
2995 mad->cmd_ioba.len = sizeof(mad->iu);
2996 mad->iu.cmd_len = sizeof(mad->fc_iu.payload);
2997 mad->iu.rsp_len = sizeof(mad->fc_iu.response);
2998 mad->iu.cmd.va = (u64)evt->crq.ioba +
2999 offsetof(struct ibmvfc_passthru_mad, fc_iu) +
3000 offsetof(struct ibmvfc_passthru_fc_iu, payload);
3001 mad->iu.cmd.len = sizeof(mad->fc_iu.payload);
3002 mad->iu.rsp.va = (u64)evt->crq.ioba +
3003 offsetof(struct ibmvfc_passthru_mad, fc_iu) +
3004 offsetof(struct ibmvfc_passthru_fc_iu, response);
3005 mad->iu.rsp.len = sizeof(mad->fc_iu.response);
3006}
3007
3008/**
3009 * ibmvfc_tgt_adisc - Initiate an ADISC for specified target
3010 * @tgt: ibmvfc target struct
3011 *
3012 **/
3013static void ibmvfc_tgt_adisc(struct ibmvfc_target *tgt)
3014{
3015 struct ibmvfc_passthru_mad *mad;
3016 struct ibmvfc_host *vhost = tgt->vhost;
3017 struct ibmvfc_event *evt;
3018
3019 if (vhost->discovery_threads >= disc_threads)
3020 return;
3021
3022 kref_get(&tgt->kref);
3023 evt = ibmvfc_get_event(vhost);
3024 vhost->discovery_threads++;
3025 ibmvfc_init_event(evt, ibmvfc_tgt_adisc_done, IBMVFC_MAD_FORMAT);
3026 evt->tgt = tgt;
3027
3028 ibmvfc_init_passthru(evt);
3029 mad = &evt->iu.passthru;
3030 mad->iu.flags = IBMVFC_FC_ELS;
3031 mad->iu.scsi_id = tgt->scsi_id;
3032
3033 mad->fc_iu.payload[0] = IBMVFC_ADISC;
3034 memcpy(&mad->fc_iu.payload[2], &vhost->login_buf->resp.port_name,
3035 sizeof(vhost->login_buf->resp.port_name));
3036 memcpy(&mad->fc_iu.payload[4], &vhost->login_buf->resp.node_name,
3037 sizeof(vhost->login_buf->resp.node_name));
3038 mad->fc_iu.payload[6] = vhost->login_buf->resp.scsi_id & 0x00ffffff;
3039
3040 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT);
3041 if (ibmvfc_send_event(evt, vhost, default_timeout)) {
3042 vhost->discovery_threads--;
3043 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE);
3044 kref_put(&tgt->kref, ibmvfc_release_tgt);
3045 } else
3046 tgt_dbg(tgt, "Sent ADISC\n");
3047}
3048
3049/**
2905 * ibmvfc_tgt_query_target_done - Completion handler for Query Target MAD 3050 * ibmvfc_tgt_query_target_done - Completion handler for Query Target MAD
2906 * @evt: ibmvfc event struct 3051 * @evt: ibmvfc event struct
2907 * 3052 *
@@ -2921,6 +3066,8 @@ static void ibmvfc_tgt_query_target_done(struct ibmvfc_event *evt)
2921 tgt->new_scsi_id = rsp->scsi_id; 3066 tgt->new_scsi_id = rsp->scsi_id;
2922 if (rsp->scsi_id != tgt->scsi_id) 3067 if (rsp->scsi_id != tgt->scsi_id)
2923 ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); 3068 ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout);
3069 else
3070 ibmvfc_init_tgt(tgt, ibmvfc_tgt_adisc);
2924 break; 3071 break;
2925 case IBMVFC_MAD_DRIVER_FAILED: 3072 case IBMVFC_MAD_DRIVER_FAILED:
2926 break; 3073 break;
@@ -3336,6 +3483,7 @@ static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
3336 tgt_dbg(tgt, "rport add succeeded\n"); 3483 tgt_dbg(tgt, "rport add succeeded\n");
3337 rport->maxframe_size = tgt->service_parms.common.bb_rcv_sz & 0x0fff; 3484 rport->maxframe_size = tgt->service_parms.common.bb_rcv_sz & 0x0fff;
3338 rport->supported_classes = 0; 3485 rport->supported_classes = 0;
3486 tgt->target_id = rport->scsi_target_id;
3339 if (tgt->service_parms.class1_parms[0] & 0x80000000) 3487 if (tgt->service_parms.class1_parms[0] & 0x80000000)
3340 rport->supported_classes |= FC_COS_CLASS1; 3488 rport->supported_classes |= FC_COS_CLASS1;
3341 if (tgt->service_parms.class2_parms[0] & 0x80000000) 3489 if (tgt->service_parms.class2_parms[0] & 0x80000000)
@@ -3525,7 +3673,7 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost)
3525 crq->msg_token = dma_map_single(dev, crq->msgs, 3673 crq->msg_token = dma_map_single(dev, crq->msgs,
3526 PAGE_SIZE, DMA_BIDIRECTIONAL); 3674 PAGE_SIZE, DMA_BIDIRECTIONAL);
3527 3675
3528 if (dma_mapping_error(crq->msg_token)) 3676 if (dma_mapping_error(dev, crq->msg_token))
3529 goto map_failed; 3677 goto map_failed;
3530 3678
3531 retrc = rc = plpar_hcall_norets(H_REG_CRQ, vdev->unit_address, 3679 retrc = rc = plpar_hcall_norets(H_REG_CRQ, vdev->unit_address,
@@ -3618,7 +3766,7 @@ static int ibmvfc_alloc_mem(struct ibmvfc_host *vhost)
3618 async_q->size * sizeof(*async_q->msgs), 3766 async_q->size * sizeof(*async_q->msgs),
3619 DMA_BIDIRECTIONAL); 3767 DMA_BIDIRECTIONAL);
3620 3768
3621 if (dma_mapping_error(async_q->msg_token)) { 3769 if (dma_mapping_error(dev, async_q->msg_token)) {
3622 dev_err(dev, "Failed to map async queue\n"); 3770 dev_err(dev, "Failed to map async queue\n");
3623 goto free_async_crq; 3771 goto free_async_crq;
3624 } 3772 }
@@ -3800,10 +3948,12 @@ static int ibmvfc_remove(struct vio_dev *vdev)
3800 3948
3801 ENTER; 3949 ENTER;
3802 ibmvfc_remove_trace_file(&vhost->host->shost_dev.kobj, &ibmvfc_trace_attr); 3950 ibmvfc_remove_trace_file(&vhost->host->shost_dev.kobj, &ibmvfc_trace_attr);
3951 ibmvfc_link_down(vhost, IBMVFC_HOST_OFFLINE);
3952 ibmvfc_wait_while_resetting(vhost);
3953 ibmvfc_release_crq_queue(vhost);
3803 kthread_stop(vhost->work_thread); 3954 kthread_stop(vhost->work_thread);
3804 fc_remove_host(vhost->host); 3955 fc_remove_host(vhost->host);
3805 scsi_remove_host(vhost->host); 3956 scsi_remove_host(vhost->host);
3806 ibmvfc_release_crq_queue(vhost);
3807 3957
3808 spin_lock_irqsave(vhost->host->host_lock, flags); 3958 spin_lock_irqsave(vhost->host->host_lock, flags);
3809 ibmvfc_purge_requests(vhost, DID_ERROR); 3959 ibmvfc_purge_requests(vhost, DID_ERROR);
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
index 057f3c01ed61..4bf6e374f076 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.h
+++ b/drivers/scsi/ibmvscsi/ibmvfc.h
@@ -29,8 +29,8 @@
29#include "viosrp.h" 29#include "viosrp.h"
30 30
31#define IBMVFC_NAME "ibmvfc" 31#define IBMVFC_NAME "ibmvfc"
32#define IBMVFC_DRIVER_VERSION "1.0.0" 32#define IBMVFC_DRIVER_VERSION "1.0.1"
33#define IBMVFC_DRIVER_DATE "(July 1, 2008)" 33#define IBMVFC_DRIVER_DATE "(July 11, 2008)"
34 34
35#define IBMVFC_DEFAULT_TIMEOUT 15 35#define IBMVFC_DEFAULT_TIMEOUT 15
36#define IBMVFC_INIT_TIMEOUT 30 36#define IBMVFC_INIT_TIMEOUT 30
@@ -119,6 +119,7 @@ enum ibmvfc_mad_types {
119 IBMVFC_PROCESS_LOGIN = 0x0008, 119 IBMVFC_PROCESS_LOGIN = 0x0008,
120 IBMVFC_QUERY_TARGET = 0x0010, 120 IBMVFC_QUERY_TARGET = 0x0010,
121 IBMVFC_IMPLICIT_LOGOUT = 0x0040, 121 IBMVFC_IMPLICIT_LOGOUT = 0x0040,
122 IBMVFC_PASSTHRU = 0x0200,
122 IBMVFC_TMF_MAD = 0x0100, 123 IBMVFC_TMF_MAD = 0x0100,
123}; 124};
124 125
@@ -439,6 +440,37 @@ struct ibmvfc_cmd {
439 struct ibmvfc_fcp_rsp rsp; 440 struct ibmvfc_fcp_rsp rsp;
440}__attribute__((packed, aligned (8))); 441}__attribute__((packed, aligned (8)));
441 442
443struct ibmvfc_passthru_fc_iu {
444 u32 payload[7];
445#define IBMVFC_ADISC 0x52000000
446 u32 response[7];
447};
448
449struct ibmvfc_passthru_iu {
450 u64 task_tag;
451 u32 cmd_len;
452 u32 rsp_len;
453 u16 status;
454 u16 error;
455 u32 flags;
456#define IBMVFC_FC_ELS 0x01
457 u32 cancel_key;
458 u32 reserved;
459 struct srp_direct_buf cmd;
460 struct srp_direct_buf rsp;
461 u64 correlation;
462 u64 scsi_id;
463 u64 tag;
464 u64 reserved2[2];
465}__attribute__((packed, aligned (8)));
466
467struct ibmvfc_passthru_mad {
468 struct ibmvfc_mad_common common;
469 struct srp_direct_buf cmd_ioba;
470 struct ibmvfc_passthru_iu iu;
471 struct ibmvfc_passthru_fc_iu fc_iu;
472}__attribute__((packed, aligned (8)));
473
442struct ibmvfc_trace_start_entry { 474struct ibmvfc_trace_start_entry {
443 u32 xfer_len; 475 u32 xfer_len;
444}__attribute__((packed)); 476}__attribute__((packed));
@@ -531,6 +563,7 @@ union ibmvfc_iu {
531 struct ibmvfc_implicit_logout implicit_logout; 563 struct ibmvfc_implicit_logout implicit_logout;
532 struct ibmvfc_tmf tmf; 564 struct ibmvfc_tmf tmf;
533 struct ibmvfc_cmd cmd; 565 struct ibmvfc_cmd cmd;
566 struct ibmvfc_passthru_mad passthru;
534}__attribute__((packed, aligned (8))); 567}__attribute__((packed, aligned (8)));
535 568
536enum ibmvfc_target_action { 569enum ibmvfc_target_action {
@@ -656,6 +689,9 @@ struct ibmvfc_host {
656#define tgt_dbg(t, fmt, ...) \ 689#define tgt_dbg(t, fmt, ...) \
657 DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)) 690 DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
658 691
692#define tgt_info(t, fmt, ...) \
693 dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
694
659#define tgt_err(t, fmt, ...) \ 695#define tgt_err(t, fmt, ...) \
660 dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 696 dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
661 697
@@ -668,8 +704,8 @@ struct ibmvfc_host {
668 dev_err((vhost)->dev, ##__VA_ARGS__); \ 704 dev_err((vhost)->dev, ##__VA_ARGS__); \
669 } while (0) 705 } while (0)
670 706
671#define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __FUNCTION__)) 707#define ENTER DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Entering %s\n", __func__))
672#define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __FUNCTION__)) 708#define LEAVE DBG_CMD(printk(KERN_INFO IBMVFC_NAME": Leaving %s\n", __func__))
673 709
674#ifdef CONFIG_SCSI_IBMVFC_TRACE 710#ifdef CONFIG_SCSI_IBMVFC_TRACE
675#define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr) 711#define ibmvfc_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 20000ec79b04..6b24b9cdb04c 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -859,7 +859,7 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata)
859 sizeof(hostdata->madapter_info), 859 sizeof(hostdata->madapter_info),
860 DMA_BIDIRECTIONAL); 860 DMA_BIDIRECTIONAL);
861 861
862 if (dma_mapping_error(req->buffer)) { 862 if (dma_mapping_error(hostdata->dev, req->buffer)) {
863 if (!firmware_has_feature(FW_FEATURE_CMO)) 863 if (!firmware_has_feature(FW_FEATURE_CMO))
864 dev_err(hostdata->dev, 864 dev_err(hostdata->dev,
865 "Unable to map request_buffer for " 865 "Unable to map request_buffer for "
@@ -1407,7 +1407,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata,
1407 length, 1407 length,
1408 DMA_BIDIRECTIONAL); 1408 DMA_BIDIRECTIONAL);
1409 1409
1410 if (dma_mapping_error(host_config->buffer)) { 1410 if (dma_mapping_error(hostdata->dev, host_config->buffer)) {
1411 if (!firmware_has_feature(FW_FEATURE_CMO)) 1411 if (!firmware_has_feature(FW_FEATURE_CMO))
1412 dev_err(hostdata->dev, 1412 dev_err(hostdata->dev,
1413 "dma_mapping error getting host config\n"); 1413 "dma_mapping error getting host config\n");
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 3b9514c8f1f1..2a5b29d12172 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -55,7 +55,7 @@
55/* tmp - will replace with SCSI logging stuff */ 55/* tmp - will replace with SCSI logging stuff */
56#define eprintk(fmt, args...) \ 56#define eprintk(fmt, args...) \
57do { \ 57do { \
58 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 58 printk("%s(%d) " fmt, __func__, __LINE__, ##args); \
59} while (0) 59} while (0)
60/* #define dprintk eprintk */ 60/* #define dprintk eprintk */
61#define dprintk(fmt, args...) 61#define dprintk(fmt, args...)
@@ -564,7 +564,7 @@ static int crq_queue_create(struct crq_queue *queue, struct srp_target *target)
564 queue->size * sizeof(*queue->msgs), 564 queue->size * sizeof(*queue->msgs),
565 DMA_BIDIRECTIONAL); 565 DMA_BIDIRECTIONAL);
566 566
567 if (dma_mapping_error(queue->msg_token)) 567 if (dma_mapping_error(target->dev, queue->msg_token))
568 goto map_failed; 568 goto map_failed;
569 569
570 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token, 570 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token,
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 182146100dc1..462a8574dad9 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -253,7 +253,7 @@ static int rpavscsi_init_crq_queue(struct crq_queue *queue,
253 queue->size * sizeof(*queue->msgs), 253 queue->size * sizeof(*queue->msgs),
254 DMA_BIDIRECTIONAL); 254 DMA_BIDIRECTIONAL);
255 255
256 if (dma_mapping_error(queue->msg_token)) 256 if (dma_mapping_error(hostdata->dev, queue->msg_token))
257 goto map_failed; 257 goto map_failed;
258 258
259 gather_partition_info(); 259 gather_partition_info();
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index f97d172844be..c2a9a13d788f 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -163,7 +163,7 @@ static int imm_proc_info(struct Scsi_Host *host, char *buffer, char **start,
163 163
164#if IMM_DEBUG > 0 164#if IMM_DEBUG > 0
165#define imm_fail(x,y) printk("imm: imm_fail(%i) from %s at line %d\n",\ 165#define imm_fail(x,y) printk("imm: imm_fail(%i) from %s at line %d\n",\
166 y, __FUNCTION__, __LINE__); imm_fail_func(x,y); 166 y, __func__, __LINE__); imm_fail_func(x,y);
167static inline void 167static inline void
168imm_fail_func(imm_struct *dev, int error_code) 168imm_fail_func(imm_struct *dev, int error_code)
169#else 169#else
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index d93156671e93..4871dd1f2582 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -1403,10 +1403,10 @@ struct ipr_ucode_image_header {
1403} 1403}
1404 1404
1405#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ 1405#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
1406 __FILE__, __FUNCTION__, __LINE__) 1406 __FILE__, __func__, __LINE__)
1407 1407
1408#define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__)) 1408#define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __func__))
1409#define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__)) 1409#define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __func__))
1410 1410
1411#define ipr_err_separator \ 1411#define ipr_err_separator \
1412ipr_err("----------------------------------------------------------\n") 1412ipr_err("----------------------------------------------------------\n")
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 744f06d04a36..48ee8c7f5bdd 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -74,7 +74,7 @@ static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)
74 case SAS_OPEN_TO: 74 case SAS_OPEN_TO:
75 case SAS_OPEN_REJECT: 75 case SAS_OPEN_REJECT:
76 SAS_DPRINTK("%s: Saw error %d. What to do?\n", 76 SAS_DPRINTK("%s: Saw error %d. What to do?\n",
77 __FUNCTION__, ts->stat); 77 __func__, ts->stat);
78 return AC_ERR_OTHER; 78 return AC_ERR_OTHER;
79 79
80 case SAS_ABORTED_TASK: 80 case SAS_ABORTED_TASK:
@@ -115,7 +115,7 @@ static void sas_ata_task_done(struct sas_task *task)
115 } else if (stat->stat != SAM_STAT_GOOD) { 115 } else if (stat->stat != SAM_STAT_GOOD) {
116 ac = sas_to_ata_err(stat); 116 ac = sas_to_ata_err(stat);
117 if (ac) { 117 if (ac) {
118 SAS_DPRINTK("%s: SAS error %x\n", __FUNCTION__, 118 SAS_DPRINTK("%s: SAS error %x\n", __func__,
119 stat->stat); 119 stat->stat);
120 /* We saw a SAS error. Send a vague error. */ 120 /* We saw a SAS error. Send a vague error. */
121 qc->err_mask = ac; 121 qc->err_mask = ac;
@@ -244,20 +244,20 @@ static void sas_ata_phy_reset(struct ata_port *ap)
244 res = i->dft->lldd_I_T_nexus_reset(dev); 244 res = i->dft->lldd_I_T_nexus_reset(dev);
245 245
246 if (res != TMF_RESP_FUNC_COMPLETE) 246 if (res != TMF_RESP_FUNC_COMPLETE)
247 SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __FUNCTION__); 247 SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __func__);
248 248
249 switch (dev->sata_dev.command_set) { 249 switch (dev->sata_dev.command_set) {
250 case ATA_COMMAND_SET: 250 case ATA_COMMAND_SET:
251 SAS_DPRINTK("%s: Found ATA device.\n", __FUNCTION__); 251 SAS_DPRINTK("%s: Found ATA device.\n", __func__);
252 ap->link.device[0].class = ATA_DEV_ATA; 252 ap->link.device[0].class = ATA_DEV_ATA;
253 break; 253 break;
254 case ATAPI_COMMAND_SET: 254 case ATAPI_COMMAND_SET:
255 SAS_DPRINTK("%s: Found ATAPI device.\n", __FUNCTION__); 255 SAS_DPRINTK("%s: Found ATAPI device.\n", __func__);
256 ap->link.device[0].class = ATA_DEV_ATAPI; 256 ap->link.device[0].class = ATA_DEV_ATAPI;
257 break; 257 break;
258 default: 258 default:
259 SAS_DPRINTK("%s: Unknown SATA command set: %d.\n", 259 SAS_DPRINTK("%s: Unknown SATA command set: %d.\n",
260 __FUNCTION__, 260 __func__,
261 dev->sata_dev.command_set); 261 dev->sata_dev.command_set);
262 ap->link.device[0].class = ATA_DEV_UNKNOWN; 262 ap->link.device[0].class = ATA_DEV_UNKNOWN;
263 break; 263 break;
@@ -299,7 +299,7 @@ static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
299{ 299{
300 struct domain_device *dev = ap->private_data; 300 struct domain_device *dev = ap->private_data;
301 301
302 SAS_DPRINTK("STUB %s\n", __FUNCTION__); 302 SAS_DPRINTK("STUB %s\n", __func__);
303 switch (sc_reg_in) { 303 switch (sc_reg_in) {
304 case SCR_STATUS: 304 case SCR_STATUS:
305 dev->sata_dev.sstatus = val; 305 dev->sata_dev.sstatus = val;
@@ -324,7 +324,7 @@ static int sas_ata_scr_read(struct ata_port *ap, unsigned int sc_reg_in,
324{ 324{
325 struct domain_device *dev = ap->private_data; 325 struct domain_device *dev = ap->private_data;
326 326
327 SAS_DPRINTK("STUB %s\n", __FUNCTION__); 327 SAS_DPRINTK("STUB %s\n", __func__);
328 switch (sc_reg_in) { 328 switch (sc_reg_in) {
329 case SCR_STATUS: 329 case SCR_STATUS:
330 *val = dev->sata_dev.sstatus; 330 *val = dev->sata_dev.sstatus;
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index aefd865a5788..3da02e436788 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -121,7 +121,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
121 break; 121 break;
122 } else { 122 } else {
123 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x " 123 SAS_DPRINTK("%s: task to dev %016llx response: 0x%x "
124 "status 0x%x\n", __FUNCTION__, 124 "status 0x%x\n", __func__,
125 SAS_ADDR(dev->sas_addr), 125 SAS_ADDR(dev->sas_addr),
126 task->task_status.resp, 126 task->task_status.resp,
127 task->task_status.stat); 127 task->task_status.stat);
@@ -1279,7 +1279,7 @@ static int sas_configure_present(struct domain_device *dev, int phy_id,
1279 goto out; 1279 goto out;
1280 } else if (res != SMP_RESP_FUNC_ACC) { 1280 } else if (res != SMP_RESP_FUNC_ACC) {
1281 SAS_DPRINTK("%s: dev %016llx phy 0x%x index 0x%x " 1281 SAS_DPRINTK("%s: dev %016llx phy 0x%x index 0x%x "
1282 "result 0x%x\n", __FUNCTION__, 1282 "result 0x%x\n", __func__,
1283 SAS_ADDR(dev->sas_addr), phy_id, i, res); 1283 SAS_ADDR(dev->sas_addr), phy_id, i, res);
1284 goto out; 1284 goto out;
1285 } 1285 }
@@ -1901,7 +1901,7 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1901 1901
1902 if (!rsp) { 1902 if (!rsp) {
1903 printk("%s: space for a smp response is missing\n", 1903 printk("%s: space for a smp response is missing\n",
1904 __FUNCTION__); 1904 __func__);
1905 return -EINVAL; 1905 return -EINVAL;
1906 } 1906 }
1907 1907
@@ -1914,20 +1914,20 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1914 if (type != SAS_EDGE_EXPANDER_DEVICE && 1914 if (type != SAS_EDGE_EXPANDER_DEVICE &&
1915 type != SAS_FANOUT_EXPANDER_DEVICE) { 1915 type != SAS_FANOUT_EXPANDER_DEVICE) {
1916 printk("%s: can we send a smp request to a device?\n", 1916 printk("%s: can we send a smp request to a device?\n",
1917 __FUNCTION__); 1917 __func__);
1918 return -EINVAL; 1918 return -EINVAL;
1919 } 1919 }
1920 1920
1921 dev = sas_find_dev_by_rphy(rphy); 1921 dev = sas_find_dev_by_rphy(rphy);
1922 if (!dev) { 1922 if (!dev) {
1923 printk("%s: fail to find a domain_device?\n", __FUNCTION__); 1923 printk("%s: fail to find a domain_device?\n", __func__);
1924 return -EINVAL; 1924 return -EINVAL;
1925 } 1925 }
1926 1926
1927 /* do we need to support multiple segments? */ 1927 /* do we need to support multiple segments? */
1928 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { 1928 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
1929 printk("%s: multiple segments req %u %u, rsp %u %u\n", 1929 printk("%s: multiple segments req %u %u, rsp %u %u\n",
1930 __FUNCTION__, req->bio->bi_vcnt, req->data_len, 1930 __func__, req->bio->bi_vcnt, req->data_len,
1931 rsp->bio->bi_vcnt, rsp->data_len); 1931 rsp->bio->bi_vcnt, rsp->data_len);
1932 return -EINVAL; 1932 return -EINVAL;
1933 } 1933 }
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 39ae68a3b0ef..139935a121b4 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -50,7 +50,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
50 sas_deform_port(phy); 50 sas_deform_port(phy);
51 else { 51 else {
52 SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n", 52 SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n",
53 __FUNCTION__, phy->id, phy->port->id, 53 __func__, phy->id, phy->port->id,
54 phy->port->num_phys); 54 phy->port->num_phys);
55 return; 55 return;
56 } 56 }
@@ -78,7 +78,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
78 78
79 if (i >= sas_ha->num_phys) { 79 if (i >= sas_ha->num_phys) {
80 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n", 80 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n",
81 __FUNCTION__); 81 __func__);
82 spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); 82 spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);
83 return; 83 return;
84 } 84 }
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 601ec5b6a7f6..a8e3ef309070 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -343,7 +343,7 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)
343 flags); 343 flags);
344 SAS_DPRINTK("%s: task 0x%p aborted from " 344 SAS_DPRINTK("%s: task 0x%p aborted from "
345 "task_queue\n", 345 "task_queue\n",
346 __FUNCTION__, task); 346 __func__, task);
347 return TASK_IS_ABORTED; 347 return TASK_IS_ABORTED;
348 } 348 }
349 } 349 }
@@ -351,13 +351,13 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)
351 } 351 }
352 352
353 for (i = 0; i < 5; i++) { 353 for (i = 0; i < 5; i++) {
354 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task); 354 SAS_DPRINTK("%s: aborting task 0x%p\n", __func__, task);
355 res = si->dft->lldd_abort_task(task); 355 res = si->dft->lldd_abort_task(task);
356 356
357 spin_lock_irqsave(&task->task_state_lock, flags); 357 spin_lock_irqsave(&task->task_state_lock, flags);
358 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 358 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
359 spin_unlock_irqrestore(&task->task_state_lock, flags); 359 spin_unlock_irqrestore(&task->task_state_lock, flags);
360 SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__, 360 SAS_DPRINTK("%s: task 0x%p is done\n", __func__,
361 task); 361 task);
362 return TASK_IS_DONE; 362 return TASK_IS_DONE;
363 } 363 }
@@ -365,24 +365,24 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)
365 365
366 if (res == TMF_RESP_FUNC_COMPLETE) { 366 if (res == TMF_RESP_FUNC_COMPLETE) {
367 SAS_DPRINTK("%s: task 0x%p is aborted\n", 367 SAS_DPRINTK("%s: task 0x%p is aborted\n",
368 __FUNCTION__, task); 368 __func__, task);
369 return TASK_IS_ABORTED; 369 return TASK_IS_ABORTED;
370 } else if (si->dft->lldd_query_task) { 370 } else if (si->dft->lldd_query_task) {
371 SAS_DPRINTK("%s: querying task 0x%p\n", 371 SAS_DPRINTK("%s: querying task 0x%p\n",
372 __FUNCTION__, task); 372 __func__, task);
373 res = si->dft->lldd_query_task(task); 373 res = si->dft->lldd_query_task(task);
374 switch (res) { 374 switch (res) {
375 case TMF_RESP_FUNC_SUCC: 375 case TMF_RESP_FUNC_SUCC:
376 SAS_DPRINTK("%s: task 0x%p at LU\n", 376 SAS_DPRINTK("%s: task 0x%p at LU\n",
377 __FUNCTION__, task); 377 __func__, task);
378 return TASK_IS_AT_LU; 378 return TASK_IS_AT_LU;
379 case TMF_RESP_FUNC_COMPLETE: 379 case TMF_RESP_FUNC_COMPLETE:
380 SAS_DPRINTK("%s: task 0x%p not at LU\n", 380 SAS_DPRINTK("%s: task 0x%p not at LU\n",
381 __FUNCTION__, task); 381 __func__, task);
382 return TASK_IS_NOT_AT_LU; 382 return TASK_IS_NOT_AT_LU;
383 case TMF_RESP_FUNC_FAILED: 383 case TMF_RESP_FUNC_FAILED:
384 SAS_DPRINTK("%s: task 0x%p failed to abort\n", 384 SAS_DPRINTK("%s: task 0x%p failed to abort\n",
385 __FUNCTION__, task); 385 __func__, task);
386 return TASK_ABORT_FAILED; 386 return TASK_ABORT_FAILED;
387 } 387 }
388 388
@@ -545,7 +545,7 @@ Again:
545 545
546 if (need_reset) { 546 if (need_reset) {
547 SAS_DPRINTK("%s: task 0x%p requests reset\n", 547 SAS_DPRINTK("%s: task 0x%p requests reset\n",
548 __FUNCTION__, task); 548 __func__, task);
549 goto reset; 549 goto reset;
550 } 550 }
551 551
@@ -556,13 +556,13 @@ Again:
556 556
557 switch (res) { 557 switch (res) {
558 case TASK_IS_DONE: 558 case TASK_IS_DONE:
559 SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__, 559 SAS_DPRINTK("%s: task 0x%p is done\n", __func__,
560 task); 560 task);
561 sas_eh_finish_cmd(cmd); 561 sas_eh_finish_cmd(cmd);
562 continue; 562 continue;
563 case TASK_IS_ABORTED: 563 case TASK_IS_ABORTED:
564 SAS_DPRINTK("%s: task 0x%p is aborted\n", 564 SAS_DPRINTK("%s: task 0x%p is aborted\n",
565 __FUNCTION__, task); 565 __func__, task);
566 sas_eh_finish_cmd(cmd); 566 sas_eh_finish_cmd(cmd);
567 continue; 567 continue;
568 case TASK_IS_AT_LU: 568 case TASK_IS_AT_LU:
@@ -633,7 +633,7 @@ Again:
633 } 633 }
634 return list_empty(work_q); 634 return list_empty(work_q);
635clear_q: 635clear_q:
636 SAS_DPRINTK("--- Exit %s -- clear_q\n", __FUNCTION__); 636 SAS_DPRINTK("--- Exit %s -- clear_q\n", __func__);
637 list_for_each_entry_safe(cmd, n, work_q, eh_entry) 637 list_for_each_entry_safe(cmd, n, work_q, eh_entry)
638 sas_eh_finish_cmd(cmd); 638 sas_eh_finish_cmd(cmd);
639 639
@@ -650,7 +650,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
650 list_splice_init(&shost->eh_cmd_q, &eh_work_q); 650 list_splice_init(&shost->eh_cmd_q, &eh_work_q);
651 spin_unlock_irqrestore(shost->host_lock, flags); 651 spin_unlock_irqrestore(shost->host_lock, flags);
652 652
653 SAS_DPRINTK("Enter %s\n", __FUNCTION__); 653 SAS_DPRINTK("Enter %s\n", __func__);
654 /* 654 /*
655 * Deal with commands that still have SAS tasks (i.e. they didn't 655 * Deal with commands that still have SAS tasks (i.e. they didn't
656 * complete via the normal sas_task completion mechanism) 656 * complete via the normal sas_task completion mechanism)
@@ -669,7 +669,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
669 669
670out: 670out:
671 scsi_eh_flush_done_q(&ha->eh_done_q); 671 scsi_eh_flush_done_q(&ha->eh_done_q);
672 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__); 672 SAS_DPRINTK("--- Exit %s\n", __func__);
673 return; 673 return;
674} 674}
675 675
@@ -990,7 +990,7 @@ int __sas_task_abort(struct sas_task *task)
990 if (task->task_state_flags & SAS_TASK_STATE_ABORTED || 990 if (task->task_state_flags & SAS_TASK_STATE_ABORTED ||
991 task->task_state_flags & SAS_TASK_STATE_DONE) { 991 task->task_state_flags & SAS_TASK_STATE_DONE) {
992 spin_unlock_irqrestore(&task->task_state_lock, flags); 992 spin_unlock_irqrestore(&task->task_state_lock, flags);
993 SAS_DPRINTK("%s: Task %p already finished.\n", __FUNCTION__, 993 SAS_DPRINTK("%s: Task %p already finished.\n", __func__,
994 task); 994 task);
995 return 0; 995 return 0;
996 } 996 }
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 6d6a76e65a6c..15e2d132e8b9 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -39,7 +39,7 @@ enum srp_task_attributes {
39/* tmp - will replace with SCSI logging stuff */ 39/* tmp - will replace with SCSI logging stuff */
40#define eprintk(fmt, args...) \ 40#define eprintk(fmt, args...) \
41do { \ 41do { \
42 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 42 printk("%s(%d) " fmt, __func__, __LINE__, ##args); \
43} while (0) 43} while (0)
44/* #define dprintk eprintk */ 44/* #define dprintk eprintk */
45#define dprintk(fmt, args...) 45#define dprintk(fmt, args...)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 5b6e5395c8eb..d51a2a4b43eb 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -2083,7 +2083,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
2083 if (iocbq_entry == NULL) { 2083 if (iocbq_entry == NULL) {
2084 printk(KERN_ERR "%s: only allocated %d iocbs of " 2084 printk(KERN_ERR "%s: only allocated %d iocbs of "
2085 "expected %d count. Unloading driver.\n", 2085 "expected %d count. Unloading driver.\n",
2086 __FUNCTION__, i, LPFC_IOCB_LIST_CNT); 2086 __func__, i, LPFC_IOCB_LIST_CNT);
2087 error = -ENOMEM; 2087 error = -ENOMEM;
2088 goto out_free_iocbq; 2088 goto out_free_iocbq;
2089 } 2089 }
@@ -2093,7 +2093,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
2093 kfree (iocbq_entry); 2093 kfree (iocbq_entry);
2094 printk(KERN_ERR "%s: failed to allocate IOTAG. " 2094 printk(KERN_ERR "%s: failed to allocate IOTAG. "
2095 "Unloading driver.\n", 2095 "Unloading driver.\n",
2096 __FUNCTION__); 2096 __func__);
2097 error = -ENOMEM; 2097 error = -ENOMEM;
2098 goto out_free_iocbq; 2098 goto out_free_iocbq;
2099 } 2099 }
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c94da4f2b8a6..1bcebbd3dfac 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -341,7 +341,7 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
341 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 341 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
342 printk(KERN_ERR "%s: Too many sg segments from " 342 printk(KERN_ERR "%s: Too many sg segments from "
343 "dma_map_sg. Config %d, seg_cnt %d", 343 "dma_map_sg. Config %d, seg_cnt %d",
344 __FUNCTION__, phba->cfg_sg_seg_cnt, 344 __func__, phba->cfg_sg_seg_cnt,
345 lpfc_cmd->seg_cnt); 345 lpfc_cmd->seg_cnt);
346 scsi_dma_unmap(scsi_cmnd); 346 scsi_dma_unmap(scsi_cmnd);
347 return 1; 347 return 1;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index f40aa7b905f7..50fe07646738 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -219,7 +219,7 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
219 case CMD_IOCB_LOGENTRY_CN: 219 case CMD_IOCB_LOGENTRY_CN:
220 case CMD_IOCB_LOGENTRY_ASYNC_CN: 220 case CMD_IOCB_LOGENTRY_ASYNC_CN:
221 printk("%s - Unhandled SLI-3 Command x%x\n", 221 printk("%s - Unhandled SLI-3 Command x%x\n",
222 __FUNCTION__, iocb_cmnd); 222 __func__, iocb_cmnd);
223 type = LPFC_UNKNOWN_IOCB; 223 type = LPFC_UNKNOWN_IOCB;
224 break; 224 break;
225 default: 225 default:
@@ -1715,7 +1715,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
1715 rspiocbp = __lpfc_sli_get_iocbq(phba); 1715 rspiocbp = __lpfc_sli_get_iocbq(phba);
1716 if (rspiocbp == NULL) { 1716 if (rspiocbp == NULL) {
1717 printk(KERN_ERR "%s: out of buffers! Failing " 1717 printk(KERN_ERR "%s: out of buffers! Failing "
1718 "completion.\n", __FUNCTION__); 1718 "completion.\n", __func__);
1719 break; 1719 break;
1720 } 1720 }
1721 1721
@@ -3793,7 +3793,7 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport,
3793 break; 3793 break;
3794 default: 3794 default:
3795 printk(KERN_ERR "%s: Unknown context cmd type, value %d\n", 3795 printk(KERN_ERR "%s: Unknown context cmd type, value %d\n",
3796 __FUNCTION__, ctx_cmd); 3796 __func__, ctx_cmd);
3797 break; 3797 break;
3798 } 3798 }
3799 3799
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index f62ed468ada0..5ead1283a844 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -265,7 +265,7 @@ typedef struct {
265#define ASSERT(expression) \ 265#define ASSERT(expression) \
266 if (!(expression)) { \ 266 if (!(expression)) { \
267 ASSERT_ACTION("assertion failed:(%s), file: %s, line: %d:%s\n", \ 267 ASSERT_ACTION("assertion failed:(%s), file: %s, line: %d:%s\n", \
268 #expression, __FILE__, __LINE__, __FUNCTION__); \ 268 #expression, __FILE__, __LINE__, __func__); \
269 } 269 }
270#else 270#else
271#define ASSERT(expression) 271#define ASSERT(expression)
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 70a0f11f48b2..805bb61dde18 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -458,7 +458,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
458 458
459 if (adapter == NULL) { 459 if (adapter == NULL) {
460 con_log(CL_ANN, (KERN_WARNING 460 con_log(CL_ANN, (KERN_WARNING
461 "megaraid: out of memory, %s %d.\n", __FUNCTION__, __LINE__)); 461 "megaraid: out of memory, %s %d.\n", __func__, __LINE__));
462 462
463 goto out_probe_one; 463 goto out_probe_one;
464 } 464 }
@@ -1002,7 +1002,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1002 1002
1003 if (!raid_dev->una_mbox64) { 1003 if (!raid_dev->una_mbox64) {
1004 con_log(CL_ANN, (KERN_WARNING 1004 con_log(CL_ANN, (KERN_WARNING
1005 "megaraid: out of memory, %s %d\n", __FUNCTION__, 1005 "megaraid: out of memory, %s %d\n", __func__,
1006 __LINE__)); 1006 __LINE__));
1007 return -1; 1007 return -1;
1008 } 1008 }
@@ -1030,7 +1030,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1030 if (!adapter->ibuf) { 1030 if (!adapter->ibuf) {
1031 1031
1032 con_log(CL_ANN, (KERN_WARNING 1032 con_log(CL_ANN, (KERN_WARNING
1033 "megaraid: out of memory, %s %d\n", __FUNCTION__, 1033 "megaraid: out of memory, %s %d\n", __func__,
1034 __LINE__)); 1034 __LINE__));
1035 1035
1036 goto out_free_common_mbox; 1036 goto out_free_common_mbox;
@@ -1052,7 +1052,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1052 1052
1053 if (adapter->kscb_list == NULL) { 1053 if (adapter->kscb_list == NULL) {
1054 con_log(CL_ANN, (KERN_WARNING 1054 con_log(CL_ANN, (KERN_WARNING
1055 "megaraid: out of memory, %s %d\n", __FUNCTION__, 1055 "megaraid: out of memory, %s %d\n", __func__,
1056 __LINE__)); 1056 __LINE__));
1057 goto out_free_ibuf; 1057 goto out_free_ibuf;
1058 } 1058 }
@@ -1060,7 +1060,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
1060 // memory allocation for our command packets 1060 // memory allocation for our command packets
1061 if (megaraid_mbox_setup_dma_pools(adapter) != 0) { 1061 if (megaraid_mbox_setup_dma_pools(adapter) != 0) {
1062 con_log(CL_ANN, (KERN_WARNING 1062 con_log(CL_ANN, (KERN_WARNING
1063 "megaraid: out of memory, %s %d\n", __FUNCTION__, 1063 "megaraid: out of memory, %s %d\n", __func__,
1064 __LINE__)); 1064 __LINE__));
1065 goto out_free_scb_list; 1065 goto out_free_scb_list;
1066 } 1066 }
@@ -2981,7 +2981,7 @@ megaraid_mbox_product_info(adapter_t *adapter)
2981 2981
2982 if (pinfo == NULL) { 2982 if (pinfo == NULL) {
2983 con_log(CL_ANN, (KERN_WARNING 2983 con_log(CL_ANN, (KERN_WARNING
2984 "megaraid: out of memory, %s %d\n", __FUNCTION__, 2984 "megaraid: out of memory, %s %d\n", __func__,
2985 __LINE__)); 2985 __LINE__));
2986 2986
2987 return -1; 2987 return -1;
@@ -3508,7 +3508,7 @@ megaraid_cmm_register(adapter_t *adapter)
3508 3508
3509 if (adapter->uscb_list == NULL) { 3509 if (adapter->uscb_list == NULL) {
3510 con_log(CL_ANN, (KERN_WARNING 3510 con_log(CL_ANN, (KERN_WARNING
3511 "megaraid: out of memory, %s %d\n", __FUNCTION__, 3511 "megaraid: out of memory, %s %d\n", __func__,
3512 __LINE__)); 3512 __LINE__));
3513 return -1; 3513 return -1;
3514 } 3514 }
@@ -3879,7 +3879,7 @@ megaraid_sysfs_alloc_resources(adapter_t *adapter)
3879 !raid_dev->sysfs_buffer) { 3879 !raid_dev->sysfs_buffer) {
3880 3880
3881 con_log(CL_ANN, (KERN_WARNING 3881 con_log(CL_ANN, (KERN_WARNING
3882 "megaraid: out of memory, %s %d\n", __FUNCTION__, 3882 "megaraid: out of memory, %s %d\n", __func__,
3883 __LINE__)); 3883 __LINE__));
3884 3884
3885 rval = -ENOMEM; 3885 rval = -ENOMEM;
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index ac3b280c2a72..f680561d2c6f 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -929,7 +929,7 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
929 !adapter->pthru_dma_pool) { 929 !adapter->pthru_dma_pool) {
930 930
931 con_log(CL_ANN, (KERN_WARNING 931 con_log(CL_ANN, (KERN_WARNING
932 "megaraid cmm: out of memory, %s %d\n", __FUNCTION__, 932 "megaraid cmm: out of memory, %s %d\n", __func__,
933 __LINE__)); 933 __LINE__));
934 934
935 rval = (-ENOMEM); 935 rval = (-ENOMEM);
@@ -957,7 +957,7 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
957 957
958 con_log(CL_ANN, (KERN_WARNING 958 con_log(CL_ANN, (KERN_WARNING
959 "megaraid cmm: out of memory, %s %d\n", 959 "megaraid cmm: out of memory, %s %d\n",
960 __FUNCTION__, __LINE__)); 960 __func__, __LINE__));
961 961
962 rval = (-ENOMEM); 962 rval = (-ENOMEM);
963 963
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 7fed35372150..edf9fdb3cb3c 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -299,9 +299,9 @@ static struct scsi_host_template nsp32_template = {
299#else 299#else
300# define NSP32_DEBUG_MASK 0xffffff 300# define NSP32_DEBUG_MASK 0xffffff
301# define nsp32_msg(type, args...) \ 301# define nsp32_msg(type, args...) \
302 nsp32_message (__FUNCTION__, __LINE__, (type), args) 302 nsp32_message (__func__, __LINE__, (type), args)
303# define nsp32_dbg(mask, args...) \ 303# define nsp32_dbg(mask, args...) \
304 nsp32_dmessage(__FUNCTION__, __LINE__, (mask), args) 304 nsp32_dmessage(__func__, __LINE__, (mask), args)
305#endif 305#endif
306 306
307#define NSP32_DEBUG_QUEUECOMMAND BIT(0) 307#define NSP32_DEBUG_QUEUECOMMAND BIT(0)
diff --git a/drivers/scsi/nsp32_debug.c b/drivers/scsi/nsp32_debug.c
index ef3c59cbcff6..2fb3fb58858d 100644
--- a/drivers/scsi/nsp32_debug.c
+++ b/drivers/scsi/nsp32_debug.c
@@ -88,7 +88,7 @@ static void print_commandk (unsigned char *command)
88 int i,s; 88 int i,s;
89// printk(KERN_DEBUG); 89// printk(KERN_DEBUG);
90 print_opcodek(command[0]); 90 print_opcodek(command[0]);
91 /*printk(KERN_DEBUG "%s ", __FUNCTION__);*/ 91 /*printk(KERN_DEBUG "%s ", __func__);*/
92 if ((command[0] >> 5) == 6 || 92 if ((command[0] >> 5) == 6 ||
93 (command[0] >> 5) == 7 ) { 93 (command[0] >> 5) == 7 ) {
94 s = 12; /* vender specific */ 94 s = 12; /* vender specific */
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 5082ca3c6876..a221b6ef9fa9 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -107,9 +107,9 @@ static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
107#else 107#else
108# define NSP_DEBUG_MASK 0xffffff 108# define NSP_DEBUG_MASK 0xffffff
109# define nsp_msg(type, args...) \ 109# define nsp_msg(type, args...) \
110 nsp_cs_message (__FUNCTION__, __LINE__, (type), args) 110 nsp_cs_message (__func__, __LINE__, (type), args)
111# define nsp_dbg(mask, args...) \ 111# define nsp_dbg(mask, args...) \
112 nsp_cs_dmessage(__FUNCTION__, __LINE__, (mask), args) 112 nsp_cs_dmessage(__func__, __LINE__, (mask), args)
113#endif 113#endif
114 114
115#define NSP_DEBUG_QUEUECOMMAND BIT(0) 115#define NSP_DEBUG_QUEUECOMMAND BIT(0)
diff --git a/drivers/scsi/pcmcia/nsp_debug.c b/drivers/scsi/pcmcia/nsp_debug.c
index 2f75fe6e35a7..3c6ef64fcbff 100644
--- a/drivers/scsi/pcmcia/nsp_debug.c
+++ b/drivers/scsi/pcmcia/nsp_debug.c
@@ -90,7 +90,7 @@ static void print_commandk (unsigned char *command)
90 int i, s; 90 int i, s;
91 printk(KERN_DEBUG); 91 printk(KERN_DEBUG);
92 print_opcodek(command[0]); 92 print_opcodek(command[0]);
93 /*printk(KERN_DEBUG "%s ", __FUNCTION__);*/ 93 /*printk(KERN_DEBUG "%s ", __func__);*/
94 if ((command[0] >> 5) == 6 || 94 if ((command[0] >> 5) == 6 ||
95 (command[0] >> 5) == 7 ) { 95 (command[0] >> 5) == 7 ) {
96 s = 12; /* vender specific */ 96 s = 12; /* vender specific */
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index f655ae320b48..8aa0bd987e29 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -171,7 +171,7 @@ static int device_check(ppa_struct *dev);
171 171
172#if PPA_DEBUG > 0 172#if PPA_DEBUG > 0
173#define ppa_fail(x,y) printk("ppa: ppa_fail(%i) from %s at line %d\n",\ 173#define ppa_fail(x,y) printk("ppa: ppa_fail(%i) from %s at line %d\n",\
174 y, __FUNCTION__, __LINE__); ppa_fail_func(x,y); 174 y, __func__, __LINE__); ppa_fail_func(x,y);
175static inline void ppa_fail_func(ppa_struct *dev, int error_code) 175static inline void ppa_fail_func(ppa_struct *dev, int error_code)
176#else 176#else
177static inline void ppa_fail(ppa_struct *dev, int error_code) 177static inline void ppa_fail(ppa_struct *dev, int error_code)
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 3754ab87f89a..37f9ba0cd798 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -1695,7 +1695,7 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1695 risc_code_size = *ql1280_board_tbl[ha->devnum].fwlen; 1695 risc_code_size = *ql1280_board_tbl[ha->devnum].fwlen;
1696 1696
1697 dprintk(1, "%s: DMA RISC code (%i) words\n", 1697 dprintk(1, "%s: DMA RISC code (%i) words\n",
1698 __FUNCTION__, risc_code_size); 1698 __func__, risc_code_size);
1699 1699
1700 num = 0; 1700 num = 0;
1701 while (risc_code_size > 0) { 1701 while (risc_code_size > 0) {
@@ -1721,7 +1721,7 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1721 mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff; 1721 mb[7] = pci_dma_hi32(ha->request_dma) & 0xffff;
1722 mb[6] = pci_dma_hi32(ha->request_dma) >> 16; 1722 mb[6] = pci_dma_hi32(ha->request_dma) >> 16;
1723 dprintk(2, "%s: op=%d 0x%p = 0x%4x,0x%4x,0x%4x,0x%4x\n", 1723 dprintk(2, "%s: op=%d 0x%p = 0x%4x,0x%4x,0x%4x,0x%4x\n",
1724 __FUNCTION__, mb[0], 1724 __func__, mb[0],
1725 (void *)(long)ha->request_dma, 1725 (void *)(long)ha->request_dma,
1726 mb[6], mb[7], mb[2], mb[3]); 1726 mb[6], mb[7], mb[2], mb[3]);
1727 err = qla1280_mailbox_command(ha, BIT_4 | BIT_3 | BIT_2 | 1727 err = qla1280_mailbox_command(ha, BIT_4 | BIT_3 | BIT_2 |
@@ -1753,10 +1753,10 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1753 if (tbuf[i] != sp[i] && warn++ < 10) { 1753 if (tbuf[i] != sp[i] && warn++ < 10) {
1754 printk(KERN_ERR "%s: FW compare error @ " 1754 printk(KERN_ERR "%s: FW compare error @ "
1755 "byte(0x%x) loop#=%x\n", 1755 "byte(0x%x) loop#=%x\n",
1756 __FUNCTION__, i, num); 1756 __func__, i, num);
1757 printk(KERN_ERR "%s: FWbyte=%x " 1757 printk(KERN_ERR "%s: FWbyte=%x "
1758 "FWfromChip=%x\n", 1758 "FWfromChip=%x\n",
1759 __FUNCTION__, sp[i], tbuf[i]); 1759 __func__, sp[i], tbuf[i]);
1760 /*break; */ 1760 /*break; */
1761 } 1761 }
1762 } 1762 }
@@ -1781,7 +1781,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha)
1781 int err; 1781 int err;
1782 1782
1783 dprintk(1, "%s: Verifying checksum of loaded RISC code.\n", 1783 dprintk(1, "%s: Verifying checksum of loaded RISC code.\n",
1784 __FUNCTION__); 1784 __func__);
1785 1785
1786 /* Verify checksum of loaded RISC code. */ 1786 /* Verify checksum of loaded RISC code. */
1787 mb[0] = MBC_VERIFY_CHECKSUM; 1787 mb[0] = MBC_VERIFY_CHECKSUM;
@@ -1794,7 +1794,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha)
1794 } 1794 }
1795 1795
1796 /* Start firmware execution. */ 1796 /* Start firmware execution. */
1797 dprintk(1, "%s: start firmware running.\n", __FUNCTION__); 1797 dprintk(1, "%s: start firmware running.\n", __func__);
1798 mb[0] = MBC_EXECUTE_FIRMWARE; 1798 mb[0] = MBC_EXECUTE_FIRMWARE;
1799 mb[1] = *ql1280_board_tbl[ha->devnum].fwstart; 1799 mb[1] = *ql1280_board_tbl[ha->devnum].fwstart;
1800 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]); 1800 err = qla1280_mailbox_command(ha, BIT_1 | BIT_0, &mb[0]);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 8dd88fc1244a..a319a20ed440 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/kthread.h> 9#include <linux/kthread.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/delay.h>
11 12
12static int qla24xx_vport_disable(struct fc_vport *, bool); 13static int qla24xx_vport_disable(struct fc_vport *, bool);
13 14
@@ -20,18 +21,12 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
20{ 21{
21 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 22 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
22 struct device, kobj))); 23 struct device, kobj)));
23 char *rbuf = (char *)ha->fw_dump;
24 24
25 if (ha->fw_dump_reading == 0) 25 if (ha->fw_dump_reading == 0)
26 return 0; 26 return 0;
27 if (off > ha->fw_dump_len)
28 return 0;
29 if (off + count > ha->fw_dump_len)
30 count = ha->fw_dump_len - off;
31 27
32 memcpy(buf, &rbuf[off], count); 28 return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
33 29 ha->fw_dump_len);
34 return (count);
35} 30}
36 31
37static ssize_t 32static ssize_t
@@ -94,20 +89,13 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
94{ 89{
95 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 90 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
96 struct device, kobj))); 91 struct device, kobj)));
97 int size = ha->nvram_size;
98 char *nvram_cache = ha->nvram;
99 92
100 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 93 if (!capable(CAP_SYS_ADMIN))
101 return 0; 94 return 0;
102 if (off + count > size) {
103 size -= off;
104 count = size;
105 }
106 95
107 /* Read NVRAM data from cache. */ 96 /* Read NVRAM data from cache. */
108 memcpy(buf, &nvram_cache[off], count); 97 return memory_read_from_buffer(buf, count, &off, ha->nvram,
109 98 ha->nvram_size);
110 return count;
111} 99}
112 100
113static ssize_t 101static ssize_t
@@ -175,14 +163,9 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj,
175 163
176 if (ha->optrom_state != QLA_SREADING) 164 if (ha->optrom_state != QLA_SREADING)
177 return 0; 165 return 0;
178 if (off > ha->optrom_region_size)
179 return 0;
180 if (off + count > ha->optrom_region_size)
181 count = ha->optrom_region_size - off;
182
183 memcpy(buf, &ha->optrom_buffer[off], count);
184 166
185 return count; 167 return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
168 ha->optrom_region_size);
186} 169}
187 170
188static ssize_t 171static ssize_t
@@ -374,20 +357,12 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
374{ 357{
375 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 358 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
376 struct device, kobj))); 359 struct device, kobj)));
377 int size = ha->vpd_size;
378 char *vpd_cache = ha->vpd;
379 360
380 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 361 if (!capable(CAP_SYS_ADMIN))
381 return 0; 362 return 0;
382 if (off + count > size) {
383 size -= off;
384 count = size;
385 }
386 363
387 /* Read NVRAM data from cache. */ 364 /* Read NVRAM data from cache. */
388 memcpy(buf, &vpd_cache[off], count); 365 return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
389
390 return count;
391} 366}
392 367
393static ssize_t 368static ssize_t
@@ -557,8 +532,10 @@ qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
557 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev)); 532 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
558 uint32_t sn; 533 uint32_t sn;
559 534
560 if (IS_FWI2_CAPABLE(ha)) 535 if (IS_FWI2_CAPABLE(ha)) {
561 return snprintf(buf, PAGE_SIZE, "\n"); 536 qla2xxx_get_vpd_field(ha, "SN", buf, PAGE_SIZE);
537 return snprintf(buf, PAGE_SIZE, "%s\n", buf);
538 }
562 539
563 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; 540 sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
564 return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000, 541 return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
@@ -809,6 +786,16 @@ qla2x00_optrom_fw_version_show(struct device *dev,
809 ha->fw_revision[3]); 786 ha->fw_revision[3]);
810} 787}
811 788
789static ssize_t
790qla2x00_total_isp_aborts_show(struct device *dev,
791 struct device_attribute *attr, char *buf)
792{
793 scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
794
795 return snprintf(buf, PAGE_SIZE, "%d\n",
796 ha->qla_stats.total_isp_aborts);
797}
798
812static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); 799static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
813static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 800static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
814static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 801static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
@@ -831,6 +818,8 @@ static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
831 qla2x00_optrom_fcode_version_show, NULL); 818 qla2x00_optrom_fcode_version_show, NULL);
832static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show, 819static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
833 NULL); 820 NULL);
821static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
822 NULL);
834 823
835struct device_attribute *qla2x00_host_attrs[] = { 824struct device_attribute *qla2x00_host_attrs[] = {
836 &dev_attr_driver_version, 825 &dev_attr_driver_version,
@@ -849,6 +838,7 @@ struct device_attribute *qla2x00_host_attrs[] = {
849 &dev_attr_optrom_efi_version, 838 &dev_attr_optrom_efi_version,
850 &dev_attr_optrom_fcode_version, 839 &dev_attr_optrom_fcode_version,
851 &dev_attr_optrom_fw_version, 840 &dev_attr_optrom_fw_version,
841 &dev_attr_total_isp_aborts,
852 NULL, 842 NULL,
853}; 843};
854 844
@@ -972,26 +962,39 @@ qla2x00_get_starget_port_id(struct scsi_target *starget)
972} 962}
973 963
974static void 964static void
975qla2x00_get_rport_loss_tmo(struct fc_rport *rport) 965qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
976{ 966{
977 struct Scsi_Host *host = rport_to_shost(rport); 967 if (timeout)
978 scsi_qla_host_t *ha = shost_priv(host); 968 rport->dev_loss_tmo = timeout;
979 969 else
980 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 970 rport->dev_loss_tmo = 1;
981} 971}
982 972
983static void 973static void
984qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 974qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
985{ 975{
986 struct Scsi_Host *host = rport_to_shost(rport); 976 struct Scsi_Host *host = rport_to_shost(rport);
987 scsi_qla_host_t *ha = shost_priv(host); 977 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
978
979 qla2x00_abort_fcport_cmds(fcport);
980
981 /*
982 * Transport has effectively 'deleted' the rport, clear
983 * all local references.
984 */
985 spin_lock_irq(host->host_lock);
986 fcport->rport = NULL;
987 *((fc_port_t **)rport->dd_data) = NULL;
988 spin_unlock_irq(host->host_lock);
989}
988 990
989 if (timeout) 991static void
990 ha->port_down_retry_count = timeout; 992qla2x00_terminate_rport_io(struct fc_rport *rport)
991 else 993{
992 ha->port_down_retry_count = 1; 994 fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
993 995
994 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 996 qla2x00_abort_fcport_cmds(fcport);
997 scsi_target_unblock(&rport->dev);
995} 998}
996 999
997static int 1000static int
@@ -1045,6 +1048,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
1045 pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt; 1048 pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
1046 pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt; 1049 pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
1047 if (IS_FWI2_CAPABLE(ha)) { 1050 if (IS_FWI2_CAPABLE(ha)) {
1051 pfc_host_stat->lip_count = stats->lip_cnt;
1048 pfc_host_stat->tx_frames = stats->tx_frames; 1052 pfc_host_stat->tx_frames = stats->tx_frames;
1049 pfc_host_stat->rx_frames = stats->rx_frames; 1053 pfc_host_stat->rx_frames = stats->rx_frames;
1050 pfc_host_stat->dumped_frames = stats->dumped_frames; 1054 pfc_host_stat->dumped_frames = stats->dumped_frames;
@@ -1173,17 +1177,16 @@ vport_create_failed_2:
1173static int 1177static int
1174qla24xx_vport_delete(struct fc_vport *fc_vport) 1178qla24xx_vport_delete(struct fc_vport *fc_vport)
1175{ 1179{
1176 scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
1177 scsi_qla_host_t *vha = fc_vport->dd_data; 1180 scsi_qla_host_t *vha = fc_vport->dd_data;
1181 scsi_qla_host_t *pha = to_qla_parent(vha);
1182
1183 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
1184 test_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags))
1185 msleep(1000);
1178 1186
1179 qla24xx_disable_vp(vha); 1187 qla24xx_disable_vp(vha);
1180 qla24xx_deallocate_vp_id(vha); 1188 qla24xx_deallocate_vp_id(vha);
1181 1189
1182 mutex_lock(&ha->vport_lock);
1183 ha->cur_vport_count--;
1184 clear_bit(vha->vp_idx, ha->vp_idx_map);
1185 mutex_unlock(&ha->vport_lock);
1186
1187 kfree(vha->node_name); 1190 kfree(vha->node_name);
1188 kfree(vha->port_name); 1191 kfree(vha->port_name);
1189 1192
@@ -1248,11 +1251,12 @@ struct fc_function_template qla2xxx_transport_functions = {
1248 .get_starget_port_id = qla2x00_get_starget_port_id, 1251 .get_starget_port_id = qla2x00_get_starget_port_id,
1249 .show_starget_port_id = 1, 1252 .show_starget_port_id = 1,
1250 1253
1251 .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
1252 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, 1254 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
1253 .show_rport_dev_loss_tmo = 1, 1255 .show_rport_dev_loss_tmo = 1,
1254 1256
1255 .issue_fc_host_lip = qla2x00_issue_lip, 1257 .issue_fc_host_lip = qla2x00_issue_lip,
1258 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
1259 .terminate_rport_io = qla2x00_terminate_rport_io,
1256 .get_fc_host_stats = qla2x00_get_fc_host_stats, 1260 .get_fc_host_stats = qla2x00_get_fc_host_stats,
1257 1261
1258 .vport_create = qla24xx_vport_create, 1262 .vport_create = qla24xx_vport_create,
@@ -1291,11 +1295,12 @@ struct fc_function_template qla2xxx_transport_vport_functions = {
1291 .get_starget_port_id = qla2x00_get_starget_port_id, 1295 .get_starget_port_id = qla2x00_get_starget_port_id,
1292 .show_starget_port_id = 1, 1296 .show_starget_port_id = 1,
1293 1297
1294 .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
1295 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo, 1298 .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
1296 .show_rport_dev_loss_tmo = 1, 1299 .show_rport_dev_loss_tmo = 1,
1297 1300
1298 .issue_fc_host_lip = qla2x00_issue_lip, 1301 .issue_fc_host_lip = qla2x00_issue_lip,
1302 .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
1303 .terminate_rport_io = qla2x00_terminate_rport_io,
1299 .get_fc_host_stats = qla2x00_get_fc_host_stats, 1304 .get_fc_host_stats = qla2x00_get_fc_host_stats,
1300}; 1305};
1301 1306
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index cbef785765cf..510ba64bc286 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -216,7 +216,7 @@ qla24xx_soft_reset(scsi_qla_host_t *ha)
216 216
217static int 217static int
218qla2xxx_dump_ram(scsi_qla_host_t *ha, uint32_t addr, uint16_t *ram, 218qla2xxx_dump_ram(scsi_qla_host_t *ha, uint32_t addr, uint16_t *ram,
219 uint16_t ram_words, void **nxt) 219 uint32_t ram_words, void **nxt)
220{ 220{
221 int rval; 221 int rval;
222 uint32_t cnt, stat, timer, words, idx; 222 uint32_t cnt, stat, timer, words, idx;
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 8dd600013bd1..6da31ba94404 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -864,7 +864,8 @@ struct link_statistics {
864 uint32_t prim_seq_err_cnt; 864 uint32_t prim_seq_err_cnt;
865 uint32_t inval_xmit_word_cnt; 865 uint32_t inval_xmit_word_cnt;
866 uint32_t inval_crc_cnt; 866 uint32_t inval_crc_cnt;
867 uint32_t unused1[0x1b]; 867 uint32_t lip_cnt;
868 uint32_t unused1[0x1a];
868 uint32_t tx_frames; 869 uint32_t tx_frames;
869 uint32_t rx_frames; 870 uint32_t rx_frames;
870 uint32_t dumped_frames; 871 uint32_t dumped_frames;
@@ -1544,7 +1545,6 @@ typedef struct fc_port {
1544 int login_retry; 1545 int login_retry;
1545 atomic_t port_down_timer; 1546 atomic_t port_down_timer;
1546 1547
1547 spinlock_t rport_lock;
1548 struct fc_rport *rport, *drport; 1548 struct fc_rport *rport, *drport;
1549 u32 supported_classes; 1549 u32 supported_classes;
1550 1550
@@ -2155,6 +2155,10 @@ struct qla_chip_state_84xx {
2155 uint32_t gold_fw_version; 2155 uint32_t gold_fw_version;
2156}; 2156};
2157 2157
2158struct qla_statistics {
2159 uint32_t total_isp_aborts;
2160};
2161
2158/* 2162/*
2159 * Linux Host Adapter structure 2163 * Linux Host Adapter structure
2160 */ 2164 */
@@ -2166,7 +2170,6 @@ typedef struct scsi_qla_host {
2166 struct pci_dev *pdev; 2170 struct pci_dev *pdev;
2167 2171
2168 unsigned long host_no; 2172 unsigned long host_no;
2169 unsigned long instance;
2170 2173
2171 volatile struct { 2174 volatile struct {
2172 uint32_t init_done :1; 2175 uint32_t init_done :1;
@@ -2515,7 +2518,7 @@ typedef struct scsi_qla_host {
2515 2518
2516 uint8_t model_number[16+1]; 2519 uint8_t model_number[16+1];
2517#define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 2520#define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
2518 char *model_desc; 2521 char model_desc[80];
2519 uint8_t adapter_id[16+1]; 2522 uint8_t adapter_id[16+1];
2520 2523
2521 uint8_t *node_name; 2524 uint8_t *node_name;
@@ -2596,6 +2599,7 @@ typedef struct scsi_qla_host {
2596 int cur_vport_count; 2599 int cur_vport_count;
2597 2600
2598 struct qla_chip_state_84xx *cs84xx; 2601 struct qla_chip_state_84xx *cs84xx;
2602 struct qla_statistics qla_stats;
2599} scsi_qla_host_t; 2603} scsi_qla_host_t;
2600 2604
2601 2605
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 9b4bebee6879..0b156735e9a6 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -62,7 +62,7 @@ extern int ql2xfdmienable;
62extern int ql2xallocfwdump; 62extern int ql2xallocfwdump;
63extern int ql2xextended_error_logging; 63extern int ql2xextended_error_logging;
64extern int ql2xqfullrampup; 64extern int ql2xqfullrampup;
65extern int num_hosts; 65extern int ql2xiidmaenable;
66 66
67extern int qla2x00_loop_reset(scsi_qla_host_t *); 67extern int qla2x00_loop_reset(scsi_qla_host_t *);
68extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int); 68extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
@@ -71,6 +71,8 @@ extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum
71extern int qla2x00_post_hwe_work(struct scsi_qla_host *, uint16_t , uint16_t, 71extern int qla2x00_post_hwe_work(struct scsi_qla_host *, uint16_t , uint16_t,
72 uint16_t, uint16_t); 72 uint16_t, uint16_t);
73 73
74extern void qla2x00_abort_fcport_cmds(fc_port_t *);
75
74/* 76/*
75 * Global Functions in qla_mid.c source file. 77 * Global Functions in qla_mid.c source file.
76 */ 78 */
@@ -312,6 +314,7 @@ extern int qla2xxx_hw_event_log(scsi_qla_host_t *, uint16_t , uint16_t,
312 uint16_t, uint16_t); 314 uint16_t, uint16_t);
313 315
314extern void qla2xxx_get_flash_info(scsi_qla_host_t *); 316extern void qla2xxx_get_flash_info(scsi_qla_host_t *);
317extern int qla2xxx_get_vpd_field(scsi_qla_host_t *, char *, char *, size_t);
315 318
316/* 319/*
317 * Global Function Prototypes in qla_dbg.c source file. 320 * Global Function Prototypes in qla_dbg.c source file.
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 4cb80b476c85..c2a4bfbcb05b 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1661,6 +1661,12 @@ qla2x00_fdmi_register(scsi_qla_host_t *ha)
1661{ 1661{
1662 int rval; 1662 int rval;
1663 1663
1664 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
1665 DEBUG2(printk("scsi(%ld): FDMI unsupported on "
1666 "ISP2100/ISP2200.\n", ha->host_no));
1667 return QLA_SUCCESS;
1668 }
1669
1664 rval = qla2x00_mgmt_svr_login(ha); 1670 rval = qla2x00_mgmt_svr_login(ha);
1665 if (rval) 1671 if (rval)
1666 return rval; 1672 return rval;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index bbbc5a632a1d..601a6b29750c 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -334,6 +334,8 @@ static int
334qla2x00_isp_firmware(scsi_qla_host_t *ha) 334qla2x00_isp_firmware(scsi_qla_host_t *ha)
335{ 335{
336 int rval; 336 int rval;
337 uint16_t loop_id, topo, sw_cap;
338 uint8_t domain, area, al_pa;
337 339
338 /* Assume loading risc code */ 340 /* Assume loading risc code */
339 rval = QLA_FUNCTION_FAILED; 341 rval = QLA_FUNCTION_FAILED;
@@ -345,6 +347,11 @@ qla2x00_isp_firmware(scsi_qla_host_t *ha)
345 347
346 /* Verify checksum of loaded RISC code. */ 348 /* Verify checksum of loaded RISC code. */
347 rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address); 349 rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address);
350 if (rval == QLA_SUCCESS) {
351 /* And, verify we are not in ROM code. */
352 rval = qla2x00_get_adapter_id(ha, &loop_id, &al_pa,
353 &area, &domain, &topo, &sw_cap);
354 }
348 } 355 }
349 356
350 if (rval) { 357 if (rval) {
@@ -722,7 +729,7 @@ qla24xx_chip_diag(scsi_qla_host_t *ha)
722 /* Perform RISC reset. */ 729 /* Perform RISC reset. */
723 qla24xx_reset_risc(ha); 730 qla24xx_reset_risc(ha);
724 731
725 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; 732 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * ha->request_q_length;
726 733
727 rval = qla2x00_mbx_reg_test(ha); 734 rval = qla2x00_mbx_reg_test(ha);
728 if (rval) { 735 if (rval) {
@@ -768,42 +775,16 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
768 mem_size = (ha->fw_memory_size - 0x100000 + 1) * 775 mem_size = (ha->fw_memory_size - 0x100000 + 1) *
769 sizeof(uint32_t); 776 sizeof(uint32_t);
770 777
771 /* Allocate memory for Extended Trace Buffer. */
772 tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
773 GFP_KERNEL);
774 if (!tc) {
775 qla_printk(KERN_WARNING, ha, "Unable to allocate "
776 "(%d KB) for EFT.\n", EFT_SIZE / 1024);
777 goto cont_alloc;
778 }
779
780 memset(tc, 0, EFT_SIZE);
781 rval = qla2x00_enable_eft_trace(ha, tc_dma, EFT_NUM_BUFFERS);
782 if (rval) {
783 qla_printk(KERN_WARNING, ha, "Unable to initialize "
784 "EFT (%d).\n", rval);
785 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
786 tc_dma);
787 goto cont_alloc;
788 }
789
790 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n",
791 EFT_SIZE / 1024);
792
793 eft_size = EFT_SIZE;
794 ha->eft_dma = tc_dma;
795 ha->eft = tc;
796
797 /* Allocate memory for Fibre Channel Event Buffer. */ 778 /* Allocate memory for Fibre Channel Event Buffer. */
798 if (!IS_QLA25XX(ha)) 779 if (!IS_QLA25XX(ha))
799 goto cont_alloc; 780 goto try_eft;
800 781
801 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, 782 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma,
802 GFP_KERNEL); 783 GFP_KERNEL);
803 if (!tc) { 784 if (!tc) {
804 qla_printk(KERN_WARNING, ha, "Unable to allocate " 785 qla_printk(KERN_WARNING, ha, "Unable to allocate "
805 "(%d KB) for FCE.\n", FCE_SIZE / 1024); 786 "(%d KB) for FCE.\n", FCE_SIZE / 1024);
806 goto cont_alloc; 787 goto try_eft;
807 } 788 }
808 789
809 memset(tc, 0, FCE_SIZE); 790 memset(tc, 0, FCE_SIZE);
@@ -815,7 +796,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
815 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, 796 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc,
816 tc_dma); 797 tc_dma);
817 ha->flags.fce_enabled = 0; 798 ha->flags.fce_enabled = 0;
818 goto cont_alloc; 799 goto try_eft;
819 } 800 }
820 801
821 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n", 802 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n",
@@ -825,6 +806,32 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
825 ha->flags.fce_enabled = 1; 806 ha->flags.fce_enabled = 1;
826 ha->fce_dma = tc_dma; 807 ha->fce_dma = tc_dma;
827 ha->fce = tc; 808 ha->fce = tc;
809try_eft:
810 /* Allocate memory for Extended Trace Buffer. */
811 tc = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &tc_dma,
812 GFP_KERNEL);
813 if (!tc) {
814 qla_printk(KERN_WARNING, ha, "Unable to allocate "
815 "(%d KB) for EFT.\n", EFT_SIZE / 1024);
816 goto cont_alloc;
817 }
818
819 memset(tc, 0, EFT_SIZE);
820 rval = qla2x00_enable_eft_trace(ha, tc_dma, EFT_NUM_BUFFERS);
821 if (rval) {
822 qla_printk(KERN_WARNING, ha, "Unable to initialize "
823 "EFT (%d).\n", rval);
824 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc,
825 tc_dma);
826 goto cont_alloc;
827 }
828
829 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n",
830 EFT_SIZE / 1024);
831
832 eft_size = EFT_SIZE;
833 ha->eft_dma = tc_dma;
834 ha->eft = tc;
828 } 835 }
829cont_alloc: 836cont_alloc:
830 req_q_size = ha->request_q_length * sizeof(request_t); 837 req_q_size = ha->request_q_length * sizeof(request_t);
@@ -1501,18 +1508,25 @@ qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *de
1501 index = (ha->pdev->subsystem_device & 0xff); 1508 index = (ha->pdev->subsystem_device & 0xff);
1502 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && 1509 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
1503 index < QLA_MODEL_NAMES) 1510 index < QLA_MODEL_NAMES)
1504 ha->model_desc = qla2x00_model_name[index * 2 + 1]; 1511 strncpy(ha->model_desc,
1512 qla2x00_model_name[index * 2 + 1],
1513 sizeof(ha->model_desc) - 1);
1505 } else { 1514 } else {
1506 index = (ha->pdev->subsystem_device & 0xff); 1515 index = (ha->pdev->subsystem_device & 0xff);
1507 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && 1516 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
1508 index < QLA_MODEL_NAMES) { 1517 index < QLA_MODEL_NAMES) {
1509 strcpy(ha->model_number, 1518 strcpy(ha->model_number,
1510 qla2x00_model_name[index * 2]); 1519 qla2x00_model_name[index * 2]);
1511 ha->model_desc = qla2x00_model_name[index * 2 + 1]; 1520 strncpy(ha->model_desc,
1521 qla2x00_model_name[index * 2 + 1],
1522 sizeof(ha->model_desc) - 1);
1512 } else { 1523 } else {
1513 strcpy(ha->model_number, def); 1524 strcpy(ha->model_number, def);
1514 } 1525 }
1515 } 1526 }
1527 if (IS_FWI2_CAPABLE(ha))
1528 qla2xxx_get_vpd_field(ha, "\x82", ha->model_desc,
1529 sizeof(ha->model_desc));
1516} 1530}
1517 1531
1518/* On sparc systems, obtain port and node WWN from firmware 1532/* On sparc systems, obtain port and node WWN from firmware
@@ -1864,12 +1878,11 @@ qla2x00_rport_del(void *data)
1864{ 1878{
1865 fc_port_t *fcport = data; 1879 fc_port_t *fcport = data;
1866 struct fc_rport *rport; 1880 struct fc_rport *rport;
1867 unsigned long flags;
1868 1881
1869 spin_lock_irqsave(&fcport->rport_lock, flags); 1882 spin_lock_irq(fcport->ha->host->host_lock);
1870 rport = fcport->drport; 1883 rport = fcport->drport;
1871 fcport->drport = NULL; 1884 fcport->drport = NULL;
1872 spin_unlock_irqrestore(&fcport->rport_lock, flags); 1885 spin_unlock_irq(fcport->ha->host->host_lock);
1873 if (rport) 1886 if (rport)
1874 fc_remote_port_delete(rport); 1887 fc_remote_port_delete(rport);
1875} 1888}
@@ -1898,7 +1911,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
1898 atomic_set(&fcport->state, FCS_UNCONFIGURED); 1911 atomic_set(&fcport->state, FCS_UNCONFIGURED);
1899 fcport->flags = FCF_RLC_SUPPORT; 1912 fcport->flags = FCF_RLC_SUPPORT;
1900 fcport->supported_classes = FC_COS_UNSPECIFIED; 1913 fcport->supported_classes = FC_COS_UNSPECIFIED;
1901 spin_lock_init(&fcport->rport_lock);
1902 1914
1903 return fcport; 1915 return fcport;
1904} 1916}
@@ -2007,8 +2019,10 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
2007 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { 2019 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
2008 if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) 2020 if (test_bit(LOCAL_LOOP_UPDATE, &save_flags))
2009 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); 2021 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
2010 if (test_bit(RSCN_UPDATE, &save_flags)) 2022 if (test_bit(RSCN_UPDATE, &save_flags)) {
2023 ha->flags.rscn_queue_overflow = 1;
2011 set_bit(RSCN_UPDATE, &ha->dpc_flags); 2024 set_bit(RSCN_UPDATE, &ha->dpc_flags);
2025 }
2012 } 2026 }
2013 2027
2014 return (rval); 2028 return (rval);
@@ -2243,28 +2257,24 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
2243{ 2257{
2244 struct fc_rport_identifiers rport_ids; 2258 struct fc_rport_identifiers rport_ids;
2245 struct fc_rport *rport; 2259 struct fc_rport *rport;
2246 unsigned long flags;
2247 2260
2248 if (fcport->drport) 2261 if (fcport->drport)
2249 qla2x00_rport_del(fcport); 2262 qla2x00_rport_del(fcport);
2250 if (fcport->rport)
2251 return;
2252 2263
2253 rport_ids.node_name = wwn_to_u64(fcport->node_name); 2264 rport_ids.node_name = wwn_to_u64(fcport->node_name);
2254 rport_ids.port_name = wwn_to_u64(fcport->port_name); 2265 rport_ids.port_name = wwn_to_u64(fcport->port_name);
2255 rport_ids.port_id = fcport->d_id.b.domain << 16 | 2266 rport_ids.port_id = fcport->d_id.b.domain << 16 |
2256 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; 2267 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
2257 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 2268 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
2258 rport = fc_remote_port_add(ha->host, 0, &rport_ids); 2269 fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
2259 if (!rport) { 2270 if (!rport) {
2260 qla_printk(KERN_WARNING, ha, 2271 qla_printk(KERN_WARNING, ha,
2261 "Unable to allocate fc remote port!\n"); 2272 "Unable to allocate fc remote port!\n");
2262 return; 2273 return;
2263 } 2274 }
2264 spin_lock_irqsave(&fcport->rport_lock, flags); 2275 spin_lock_irq(fcport->ha->host->host_lock);
2265 fcport->rport = rport;
2266 *((fc_port_t **)rport->dd_data) = fcport; 2276 *((fc_port_t **)rport->dd_data) = fcport;
2267 spin_unlock_irqrestore(&fcport->rport_lock, flags); 2277 spin_unlock_irq(fcport->ha->host->host_lock);
2268 2278
2269 rport->supported_classes = fcport->supported_classes; 2279 rport->supported_classes = fcport->supported_classes;
2270 2280
@@ -2565,7 +2575,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2565 } else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) { 2575 } else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) {
2566 kfree(swl); 2576 kfree(swl);
2567 swl = NULL; 2577 swl = NULL;
2568 } else if (qla2x00_gfpn_id(ha, swl) == QLA_SUCCESS) { 2578 } else if (ql2xiidmaenable &&
2579 qla2x00_gfpn_id(ha, swl) == QLA_SUCCESS) {
2569 qla2x00_gpsc(ha, swl); 2580 qla2x00_gpsc(ha, swl);
2570 } 2581 }
2571 } 2582 }
@@ -3220,7 +3231,8 @@ qla2x00_update_fcports(scsi_qla_host_t *ha)
3220 3231
3221 /* Go with deferred removal of rport references. */ 3232 /* Go with deferred removal of rport references. */
3222 list_for_each_entry(fcport, &ha->fcports, list) 3233 list_for_each_entry(fcport, &ha->fcports, list)
3223 if (fcport->drport) 3234 if (fcport->drport &&
3235 atomic_read(&fcport->state) != FCS_UNCONFIGURED)
3224 qla2x00_rport_del(fcport); 3236 qla2x00_rport_del(fcport);
3225} 3237}
3226 3238
@@ -3243,6 +3255,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3243 if (ha->flags.online) { 3255 if (ha->flags.online) {
3244 ha->flags.online = 0; 3256 ha->flags.online = 0;
3245 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 3257 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
3258 ha->qla_stats.total_isp_aborts++;
3246 3259
3247 qla_printk(KERN_INFO, ha, 3260 qla_printk(KERN_INFO, ha,
3248 "Performing ISP error recovery - ha= %p.\n", ha); 3261 "Performing ISP error recovery - ha= %p.\n", ha);
@@ -3283,17 +3296,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3283 ha->isp_abort_cnt = 0; 3296 ha->isp_abort_cnt = 0;
3284 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); 3297 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
3285 3298
3286 if (ha->eft) {
3287 memset(ha->eft, 0, EFT_SIZE);
3288 rval = qla2x00_enable_eft_trace(ha,
3289 ha->eft_dma, EFT_NUM_BUFFERS);
3290 if (rval) {
3291 qla_printk(KERN_WARNING, ha,
3292 "Unable to reinitialize EFT "
3293 "(%d).\n", rval);
3294 }
3295 }
3296
3297 if (ha->fce) { 3299 if (ha->fce) {
3298 ha->flags.fce_enabled = 1; 3300 ha->flags.fce_enabled = 1;
3299 memset(ha->fce, 0, 3301 memset(ha->fce, 0,
@@ -3308,6 +3310,17 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3308 ha->flags.fce_enabled = 0; 3310 ha->flags.fce_enabled = 0;
3309 } 3311 }
3310 } 3312 }
3313
3314 if (ha->eft) {
3315 memset(ha->eft, 0, EFT_SIZE);
3316 rval = qla2x00_enable_eft_trace(ha,
3317 ha->eft_dma, EFT_NUM_BUFFERS);
3318 if (rval) {
3319 qla_printk(KERN_WARNING, ha,
3320 "Unable to reinitialize EFT "
3321 "(%d).\n", rval);
3322 }
3323 }
3311 } else { /* failed the ISP abort */ 3324 } else { /* failed the ISP abort */
3312 ha->flags.online = 1; 3325 ha->flags.online = 1;
3313 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) { 3326 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) {
@@ -4026,8 +4039,8 @@ qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
4026 ret = qla2x00_stop_firmware(ha); 4039 ret = qla2x00_stop_firmware(ha);
4027 for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT && 4040 for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT &&
4028 retries ; retries--) { 4041 retries ; retries--) {
4029 qla2x00_reset_chip(ha); 4042 ha->isp_ops->reset_chip(ha);
4030 if (qla2x00_chip_diag(ha) != QLA_SUCCESS) 4043 if (ha->isp_ops->chip_diag(ha) != QLA_SUCCESS)
4031 continue; 4044 continue;
4032 if (qla2x00_setup_chip(ha) != QLA_SUCCESS) 4045 if (qla2x00_setup_chip(ha) != QLA_SUCCESS)
4033 continue; 4046 continue;
@@ -4049,7 +4062,7 @@ qla24xx_configure_vhba(scsi_qla_host_t *ha)
4049 rval = qla2x00_fw_ready(ha->parent); 4062 rval = qla2x00_fw_ready(ha->parent);
4050 if (rval == QLA_SUCCESS) { 4063 if (rval == QLA_SUCCESS) {
4051 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 4064 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
4052 qla2x00_marker(ha->parent, 0, 0, MK_SYNC_ALL); 4065 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
4053 } 4066 }
4054 4067
4055 ha->flags.management_server_logged_in = 0; 4068 ha->flags.management_server_logged_in = 0;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 5489d5024673..d57669aa4615 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -454,10 +454,11 @@ qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
454{ 454{
455 int ret; 455 int ret;
456 unsigned long flags = 0; 456 unsigned long flags = 0;
457 scsi_qla_host_t *pha = to_qla_parent(ha);
457 458
458 spin_lock_irqsave(&ha->hardware_lock, flags); 459 spin_lock_irqsave(&pha->hardware_lock, flags);
459 ret = __qla2x00_marker(ha, loop_id, lun, type); 460 ret = __qla2x00_marker(ha, loop_id, lun, type);
460 spin_unlock_irqrestore(&ha->hardware_lock, flags); 461 spin_unlock_irqrestore(&pha->hardware_lock, flags);
461 462
462 return (ret); 463 return (ret);
463} 464}
@@ -672,7 +673,7 @@ qla24xx_start_scsi(srb_t *sp)
672{ 673{
673 int ret, nseg; 674 int ret, nseg;
674 unsigned long flags; 675 unsigned long flags;
675 scsi_qla_host_t *ha; 676 scsi_qla_host_t *ha, *pha;
676 struct scsi_cmnd *cmd; 677 struct scsi_cmnd *cmd;
677 uint32_t *clr_ptr; 678 uint32_t *clr_ptr;
678 uint32_t index; 679 uint32_t index;
@@ -686,6 +687,7 @@ qla24xx_start_scsi(srb_t *sp)
686 /* Setup device pointers. */ 687 /* Setup device pointers. */
687 ret = 0; 688 ret = 0;
688 ha = sp->ha; 689 ha = sp->ha;
690 pha = to_qla_parent(ha);
689 reg = &ha->iobase->isp24; 691 reg = &ha->iobase->isp24;
690 cmd = sp->cmd; 692 cmd = sp->cmd;
691 /* So we know we haven't pci_map'ed anything yet */ 693 /* So we know we haven't pci_map'ed anything yet */
@@ -700,7 +702,7 @@ qla24xx_start_scsi(srb_t *sp)
700 } 702 }
701 703
702 /* Acquire ring specific lock */ 704 /* Acquire ring specific lock */
703 spin_lock_irqsave(&ha->hardware_lock, flags); 705 spin_lock_irqsave(&pha->hardware_lock, flags);
704 706
705 /* Check for room in outstanding command list. */ 707 /* Check for room in outstanding command list. */
706 handle = ha->current_outstanding_cmd; 708 handle = ha->current_outstanding_cmd;
@@ -795,14 +797,14 @@ qla24xx_start_scsi(srb_t *sp)
795 ha->response_ring_ptr->signature != RESPONSE_PROCESSED) 797 ha->response_ring_ptr->signature != RESPONSE_PROCESSED)
796 qla24xx_process_response_queue(ha); 798 qla24xx_process_response_queue(ha);
797 799
798 spin_unlock_irqrestore(&ha->hardware_lock, flags); 800 spin_unlock_irqrestore(&pha->hardware_lock, flags);
799 return QLA_SUCCESS; 801 return QLA_SUCCESS;
800 802
801queuing_error: 803queuing_error:
802 if (tot_dsds) 804 if (tot_dsds)
803 scsi_dma_unmap(cmd); 805 scsi_dma_unmap(cmd);
804 806
805 spin_unlock_irqrestore(&ha->hardware_lock, flags); 807 spin_unlock_irqrestore(&pha->hardware_lock, flags);
806 808
807 return QLA_FUNCTION_FAILED; 809 return QLA_FUNCTION_FAILED;
808} 810}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index ec63b79f900a..874d802edb7d 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -542,10 +542,6 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
542 break; 542 break;
543 543
544 case MBA_PORT_UPDATE: /* Port database update */ 544 case MBA_PORT_UPDATE: /* Port database update */
545 /* Only handle SCNs for our Vport index. */
546 if (ha->parent && ha->vp_idx != (mb[3] & 0xff))
547 break;
548
549 /* 545 /*
550 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET 546 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
551 * event etc. earlier indicating loop is down) then process 547 * event etc. earlier indicating loop is down) then process
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 250d2f604397..bc90d6b8d0a0 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -918,6 +918,8 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
918 rval = qla2x00_mailbox_command(ha, mcp); 918 rval = qla2x00_mailbox_command(ha, mcp);
919 if (mcp->mb[0] == MBS_COMMAND_ERROR) 919 if (mcp->mb[0] == MBS_COMMAND_ERROR)
920 rval = QLA_COMMAND_ERROR; 920 rval = QLA_COMMAND_ERROR;
921 else if (mcp->mb[0] == MBS_INVALID_COMMAND)
922 rval = QLA_INVALID_COMMAND;
921 923
922 /* Return data. */ 924 /* Return data. */
923 *id = mcp->mb[1]; 925 *id = mcp->mb[1];
@@ -2161,17 +2163,18 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2161 struct abort_entry_24xx *abt; 2163 struct abort_entry_24xx *abt;
2162 dma_addr_t abt_dma; 2164 dma_addr_t abt_dma;
2163 uint32_t handle; 2165 uint32_t handle;
2166 scsi_qla_host_t *pha = to_qla_parent(ha);
2164 2167
2165 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2168 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
2166 2169
2167 fcport = sp->fcport; 2170 fcport = sp->fcport;
2168 2171
2169 spin_lock_irqsave(&ha->hardware_lock, flags); 2172 spin_lock_irqsave(&pha->hardware_lock, flags);
2170 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2173 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
2171 if (ha->outstanding_cmds[handle] == sp) 2174 if (pha->outstanding_cmds[handle] == sp)
2172 break; 2175 break;
2173 } 2176 }
2174 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2177 spin_unlock_irqrestore(&pha->hardware_lock, flags);
2175 if (handle == MAX_OUTSTANDING_COMMANDS) { 2178 if (handle == MAX_OUTSTANDING_COMMANDS) {
2176 /* Command not found. */ 2179 /* Command not found. */
2177 return QLA_FUNCTION_FAILED; 2180 return QLA_FUNCTION_FAILED;
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 62a3ad6e8ecb..50baf6a1d67c 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -43,6 +43,7 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
43 43
44 set_bit(vp_id, ha->vp_idx_map); 44 set_bit(vp_id, ha->vp_idx_map);
45 ha->num_vhosts++; 45 ha->num_vhosts++;
46 ha->cur_vport_count++;
46 vha->vp_idx = vp_id; 47 vha->vp_idx = vp_id;
47 list_add_tail(&vha->vp_list, &ha->vp_list); 48 list_add_tail(&vha->vp_list, &ha->vp_list);
48 mutex_unlock(&ha->vport_lock); 49 mutex_unlock(&ha->vport_lock);
@@ -58,6 +59,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
58 mutex_lock(&ha->vport_lock); 59 mutex_lock(&ha->vport_lock);
59 vp_id = vha->vp_idx; 60 vp_id = vha->vp_idx;
60 ha->num_vhosts--; 61 ha->num_vhosts--;
62 ha->cur_vport_count--;
61 clear_bit(vp_id, ha->vp_idx_map); 63 clear_bit(vp_id, ha->vp_idx_map);
62 list_del(&vha->vp_list); 64 list_del(&vha->vp_list);
63 mutex_unlock(&ha->vport_lock); 65 mutex_unlock(&ha->vport_lock);
@@ -103,8 +105,8 @@ qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
103 "loop_id=0x%04x :%x\n", 105 "loop_id=0x%04x :%x\n",
104 vha->host_no, fcport->loop_id, fcport->vp_idx)); 106 vha->host_no, fcport->loop_id, fcport->vp_idx));
105 107
106 atomic_set(&fcport->state, FCS_DEVICE_DEAD);
107 qla2x00_mark_device_lost(vha, fcport, 0, 0); 108 qla2x00_mark_device_lost(vha, fcport, 0, 0);
109 atomic_set(&fcport->state, FCS_UNCONFIGURED);
108 } 110 }
109} 111}
110 112
@@ -276,7 +278,8 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha)
276 clear_bit(RESET_ACTIVE, &vha->dpc_flags); 278 clear_bit(RESET_ACTIVE, &vha->dpc_flags);
277 } 279 }
278 280
279 if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { 281 if (atomic_read(&vha->vp_state) == VP_ACTIVE &&
282 test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) {
280 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) { 283 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) {
281 qla2x00_loop_resync(vha); 284 qla2x00_loop_resync(vha);
282 clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags); 285 clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags);
@@ -390,7 +393,6 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
390 vha->parent = ha; 393 vha->parent = ha;
391 vha->fc_vport = fc_vport; 394 vha->fc_vport = fc_vport;
392 vha->device_flags = 0; 395 vha->device_flags = 0;
393 vha->instance = num_hosts;
394 vha->vp_idx = qla24xx_allocate_vp_id(vha); 396 vha->vp_idx = qla24xx_allocate_vp_id(vha);
395 if (vha->vp_idx > ha->max_npiv_vports) { 397 if (vha->vp_idx > ha->max_npiv_vports) {
396 DEBUG15(printk("scsi(%ld): Couldn't allocate vp_id.\n", 398 DEBUG15(printk("scsi(%ld): Couldn't allocate vp_id.\n",
@@ -428,7 +430,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
428 host->max_cmd_len = MAX_CMDSZ; 430 host->max_cmd_len = MAX_CMDSZ;
429 host->max_channel = MAX_BUSES - 1; 431 host->max_channel = MAX_BUSES - 1;
430 host->max_lun = MAX_LUNS; 432 host->max_lun = MAX_LUNS;
431 host->unique_id = vha->instance; 433 host->unique_id = host->host_no;
432 host->max_id = MAX_TARGETS_2200; 434 host->max_id = MAX_TARGETS_2200;
433 host->transportt = qla2xxx_transport_vport_template; 435 host->transportt = qla2xxx_transport_vport_template;
434 436
@@ -436,12 +438,6 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
436 vha->host_no, vha)); 438 vha->host_no, vha));
437 439
438 vha->flags.init_done = 1; 440 vha->flags.init_done = 1;
439 num_hosts++;
440
441 mutex_lock(&ha->vport_lock);
442 set_bit(vha->vp_idx, ha->vp_idx_map);
443 ha->cur_vport_count++;
444 mutex_unlock(&ha->vport_lock);
445 441
446 return vha; 442 return vha;
447 443
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 48eaa3bb5433..7c8af7ed2a5d 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -27,7 +27,6 @@ char qla2x00_version_str[40];
27 */ 27 */
28static struct kmem_cache *srb_cachep; 28static struct kmem_cache *srb_cachep;
29 29
30int num_hosts;
31int ql2xlogintimeout = 20; 30int ql2xlogintimeout = 20;
32module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR); 31module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
33MODULE_PARM_DESC(ql2xlogintimeout, 32MODULE_PARM_DESC(ql2xlogintimeout,
@@ -87,6 +86,13 @@ MODULE_PARM_DESC(ql2xqfullrampup,
87 "depth for a device after a queue-full condition has been " 86 "depth for a device after a queue-full condition has been "
88 "detected. Default is 120 seconds."); 87 "detected. Default is 120 seconds.");
89 88
89int ql2xiidmaenable=1;
90module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
91MODULE_PARM_DESC(ql2xiidmaenable,
92 "Enables iIDMA settings "
93 "Default is 1 - perform iIDMA. 0 - no iIDMA.");
94
95
90/* 96/*
91 * SCSI host template entry points 97 * SCSI host template entry points
92 */ 98 */
@@ -388,7 +394,7 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
388 } 394 }
389 395
390 /* Close window on fcport/rport state-transitioning. */ 396 /* Close window on fcport/rport state-transitioning. */
391 if (!*(fc_port_t **)rport->dd_data) { 397 if (fcport->drport) {
392 cmd->result = DID_IMM_RETRY << 16; 398 cmd->result = DID_IMM_RETRY << 16;
393 goto qc_fail_command; 399 goto qc_fail_command;
394 } 400 }
@@ -443,7 +449,7 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
443 int rval; 449 int rval;
444 scsi_qla_host_t *pha = to_qla_parent(ha); 450 scsi_qla_host_t *pha = to_qla_parent(ha);
445 451
446 if (unlikely(pci_channel_offline(ha->pdev))) { 452 if (unlikely(pci_channel_offline(pha->pdev))) {
447 cmd->result = DID_REQUEUE << 16; 453 cmd->result = DID_REQUEUE << 16;
448 goto qc24_fail_command; 454 goto qc24_fail_command;
449 } 455 }
@@ -455,7 +461,7 @@ qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
455 } 461 }
456 462
457 /* Close window on fcport/rport state-transitioning. */ 463 /* Close window on fcport/rport state-transitioning. */
458 if (!*(fc_port_t **)rport->dd_data) { 464 if (fcport->drport) {
459 cmd->result = DID_IMM_RETRY << 16; 465 cmd->result = DID_IMM_RETRY << 16;
460 goto qc24_fail_command; 466 goto qc24_fail_command;
461 } 467 }
@@ -617,6 +623,40 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
617 return (return_status); 623 return (return_status);
618} 624}
619 625
626void
627qla2x00_abort_fcport_cmds(fc_port_t *fcport)
628{
629 int cnt;
630 unsigned long flags;
631 srb_t *sp;
632 scsi_qla_host_t *ha = fcport->ha;
633 scsi_qla_host_t *pha = to_qla_parent(ha);
634
635 spin_lock_irqsave(&pha->hardware_lock, flags);
636 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
637 sp = pha->outstanding_cmds[cnt];
638 if (!sp)
639 continue;
640 if (sp->fcport != fcport)
641 continue;
642
643 spin_unlock_irqrestore(&pha->hardware_lock, flags);
644 if (ha->isp_ops->abort_command(ha, sp)) {
645 DEBUG2(qla_printk(KERN_WARNING, ha,
646 "Abort failed -- %lx\n", sp->cmd->serial_number));
647 } else {
648 if (qla2x00_eh_wait_on_command(ha, sp->cmd) !=
649 QLA_SUCCESS)
650 DEBUG2(qla_printk(KERN_WARNING, ha,
651 "Abort failed while waiting -- %lx\n",
652 sp->cmd->serial_number));
653
654 }
655 spin_lock_irqsave(&pha->hardware_lock, flags);
656 }
657 spin_unlock_irqrestore(&pha->hardware_lock, flags);
658}
659
620static void 660static void
621qla2x00_block_error_handler(struct scsi_cmnd *cmnd) 661qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
622{ 662{
@@ -1073,7 +1113,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1073 else 1113 else
1074 scsi_deactivate_tcq(sdev, ha->max_q_depth); 1114 scsi_deactivate_tcq(sdev, ha->max_q_depth);
1075 1115
1076 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 1116 rport->dev_loss_tmo = ha->port_down_retry_count;
1077 1117
1078 return 0; 1118 return 0;
1079} 1119}
@@ -1629,9 +1669,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1629 } 1669 }
1630 host->can_queue = ha->request_q_length + 128; 1670 host->can_queue = ha->request_q_length + 128;
1631 1671
1632 /* load the F/W, read paramaters, and init the H/W */
1633 ha->instance = num_hosts;
1634
1635 mutex_init(&ha->vport_lock); 1672 mutex_init(&ha->vport_lock);
1636 init_completion(&ha->mbx_cmd_comp); 1673 init_completion(&ha->mbx_cmd_comp);
1637 complete(&ha->mbx_cmd_comp); 1674 complete(&ha->mbx_cmd_comp);
@@ -1679,7 +1716,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1679 1716
1680 host->this_id = 255; 1717 host->this_id = 255;
1681 host->cmd_per_lun = 3; 1718 host->cmd_per_lun = 3;
1682 host->unique_id = ha->instance; 1719 host->unique_id = host->host_no;
1683 host->max_cmd_len = MAX_CMDSZ; 1720 host->max_cmd_len = MAX_CMDSZ;
1684 host->max_channel = MAX_BUSES - 1; 1721 host->max_channel = MAX_BUSES - 1;
1685 host->max_lun = MAX_LUNS; 1722 host->max_lun = MAX_LUNS;
@@ -1700,8 +1737,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1700 ha->flags.init_done = 1; 1737 ha->flags.init_done = 1;
1701 ha->flags.online = 1; 1738 ha->flags.online = 1;
1702 1739
1703 num_hosts++;
1704
1705 ret = scsi_add_host(host, &pdev->dev); 1740 ret = scsi_add_host(host, &pdev->dev);
1706 if (ret) 1741 if (ret)
1707 goto probe_failed; 1742 goto probe_failed;
@@ -1813,27 +1848,21 @@ static inline void
1813qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport, 1848qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport,
1814 int defer) 1849 int defer)
1815{ 1850{
1816 unsigned long flags;
1817 struct fc_rport *rport; 1851 struct fc_rport *rport;
1852 scsi_qla_host_t *pha = to_qla_parent(ha);
1818 1853
1819 if (!fcport->rport) 1854 if (!fcport->rport)
1820 return; 1855 return;
1821 1856
1822 rport = fcport->rport; 1857 rport = fcport->rport;
1823 if (defer) { 1858 if (defer) {
1824 spin_lock_irqsave(&fcport->rport_lock, flags); 1859 spin_lock_irq(ha->host->host_lock);
1825 fcport->drport = rport; 1860 fcport->drport = rport;
1826 fcport->rport = NULL; 1861 spin_unlock_irq(ha->host->host_lock);
1827 *(fc_port_t **)rport->dd_data = NULL; 1862 set_bit(FCPORT_UPDATE_NEEDED, &pha->dpc_flags);
1828 spin_unlock_irqrestore(&fcport->rport_lock, flags); 1863 qla2xxx_wake_dpc(pha);
1829 set_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags); 1864 } else
1830 } else {
1831 spin_lock_irqsave(&fcport->rport_lock, flags);
1832 fcport->rport = NULL;
1833 *(fc_port_t **)rport->dd_data = NULL;
1834 spin_unlock_irqrestore(&fcport->rport_lock, flags);
1835 fc_remote_port_delete(rport); 1865 fc_remote_port_delete(rport);
1836 }
1837} 1866}
1838 1867
1839/* 1868/*
@@ -1903,7 +1932,7 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
1903 scsi_qla_host_t *pha = to_qla_parent(ha); 1932 scsi_qla_host_t *pha = to_qla_parent(ha);
1904 1933
1905 list_for_each_entry(fcport, &pha->fcports, list) { 1934 list_for_each_entry(fcport, &pha->fcports, list) {
1906 if (ha->vp_idx != 0 && ha->vp_idx != fcport->vp_idx) 1935 if (ha->vp_idx != fcport->vp_idx)
1907 continue; 1936 continue;
1908 /* 1937 /*
1909 * No point in marking the device as lost, if the device is 1938 * No point in marking the device as lost, if the device is
@@ -1911,17 +1940,10 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
1911 */ 1940 */
1912 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) 1941 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
1913 continue; 1942 continue;
1914 if (atomic_read(&fcport->state) == FCS_ONLINE) { 1943 if (atomic_read(&fcport->state) == FCS_ONLINE)
1915 if (defer) 1944 qla2x00_schedule_rport_del(ha, fcport, defer);
1916 qla2x00_schedule_rport_del(ha, fcport, defer);
1917 else if (ha->vp_idx == fcport->vp_idx)
1918 qla2x00_schedule_rport_del(ha, fcport, defer);
1919 }
1920 atomic_set(&fcport->state, FCS_DEVICE_LOST); 1945 atomic_set(&fcport->state, FCS_DEVICE_LOST);
1921 } 1946 }
1922
1923 if (defer)
1924 qla2xxx_wake_dpc(ha);
1925} 1947}
1926 1948
1927/* 1949/*
@@ -2156,7 +2178,7 @@ qla2x00_alloc_work(struct scsi_qla_host *ha, enum qla_work_type type,
2156static int 2178static int
2157qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked) 2179qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked)
2158{ 2180{
2159 unsigned long flags; 2181 unsigned long uninitialized_var(flags);
2160 scsi_qla_host_t *pha = to_qla_parent(ha); 2182 scsi_qla_host_t *pha = to_qla_parent(ha);
2161 2183
2162 if (!locked) 2184 if (!locked)
@@ -2313,8 +2335,10 @@ qla2x00_do_dpc(void *data)
2313 ha->host_no)); 2335 ha->host_no));
2314 } 2336 }
2315 2337
2316 if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) 2338 if (test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags)) {
2317 qla2x00_update_fcports(ha); 2339 qla2x00_update_fcports(ha);
2340 clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags);
2341 }
2318 2342
2319 if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) && 2343 if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) &&
2320 (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) { 2344 (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 1728ab3ccb20..1bca74474935 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -869,11 +869,9 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
869 uint32_t i; 869 uint32_t i;
870 uint32_t *dwptr; 870 uint32_t *dwptr;
871 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 871 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
872 unsigned long flags;
873 872
874 ret = QLA_SUCCESS; 873 ret = QLA_SUCCESS;
875 874
876 spin_lock_irqsave(&ha->hardware_lock, flags);
877 /* Enable flash write. */ 875 /* Enable flash write. */
878 WRT_REG_DWORD(&reg->ctrl_status, 876 WRT_REG_DWORD(&reg->ctrl_status,
879 RD_REG_DWORD(&reg->ctrl_status) | CSRX_FLASH_ENABLE); 877 RD_REG_DWORD(&reg->ctrl_status) | CSRX_FLASH_ENABLE);
@@ -907,7 +905,6 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
907 WRT_REG_DWORD(&reg->ctrl_status, 905 WRT_REG_DWORD(&reg->ctrl_status,
908 RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE); 906 RD_REG_DWORD(&reg->ctrl_status) & ~CSRX_FLASH_ENABLE);
909 RD_REG_DWORD(&reg->ctrl_status); /* PCI Posting. */ 907 RD_REG_DWORD(&reg->ctrl_status); /* PCI Posting. */
910 spin_unlock_irqrestore(&ha->hardware_lock, flags);
911 908
912 return ret; 909 return ret;
913} 910}
@@ -2306,6 +2303,51 @@ qla24xx_get_flash_version(scsi_qla_host_t *ha, void *mbuf)
2306} 2303}
2307 2304
2308static int 2305static int
2306qla2xxx_is_vpd_valid(uint8_t *pos, uint8_t *end)
2307{
2308 if (pos >= end || *pos != 0x82)
2309 return 0;
2310
2311 pos += 3 + pos[1];
2312 if (pos >= end || *pos != 0x90)
2313 return 0;
2314
2315 pos += 3 + pos[1];
2316 if (pos >= end || *pos != 0x78)
2317 return 0;
2318
2319 return 1;
2320}
2321
2322int
2323qla2xxx_get_vpd_field(scsi_qla_host_t *ha, char *key, char *str, size_t size)
2324{
2325 uint8_t *pos = ha->vpd;
2326 uint8_t *end = pos + ha->vpd_size;
2327 int len = 0;
2328
2329 if (!IS_FWI2_CAPABLE(ha) || !qla2xxx_is_vpd_valid(pos, end))
2330 return 0;
2331
2332 while (pos < end && *pos != 0x78) {
2333 len = (*pos == 0x82) ? pos[1] : pos[2];
2334
2335 if (!strncmp(pos, key, strlen(key)))
2336 break;
2337
2338 if (*pos != 0x90 && *pos != 0x91)
2339 pos += len;
2340
2341 pos += 3;
2342 }
2343
2344 if (pos < end - len && *pos != 0x78)
2345 return snprintf(str, size, "%.*s", len, pos + 3);
2346
2347 return 0;
2348}
2349
2350static int
2309qla2xxx_hw_event_store(scsi_qla_host_t *ha, uint32_t *fdata) 2351qla2xxx_hw_event_store(scsi_qla_host_t *ha, uint32_t *fdata)
2310{ 2352{
2311 uint32_t d[2], faddr; 2353 uint32_t d[2], faddr;
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index d058c8862b35..676c390db354 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.02.01-k4" 10#define QLA2XXX_VERSION "8.02.01-k6"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 2 13#define QLA_DRIVER_MINOR_VER 2
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 5822dd595826..88bebb13bc52 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -46,6 +46,8 @@ MODULE_PARM_DESC(ql4xextended_error_logging,
46 46
47int ql4_mod_unload = 0; 47int ql4_mod_unload = 0;
48 48
49#define QL4_DEF_QDEPTH 32
50
49/* 51/*
50 * SCSI host template entry points 52 * SCSI host template entry points
51 */ 53 */
@@ -1387,7 +1389,7 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev)
1387 1389
1388 sdev->hostdata = ddb; 1390 sdev->hostdata = ddb;
1389 sdev->tagged_supported = 1; 1391 sdev->tagged_supported = 1;
1390 scsi_activate_tcq(sdev, sdev->host->can_queue); 1392 scsi_activate_tcq(sdev, QL4_DEF_QDEPTH);
1391 return 0; 1393 return 0;
1392} 1394}
1393 1395
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 36c92f961e15..ee6be596503d 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -197,11 +197,43 @@ static void
197scsi_pool_free_command(struct scsi_host_cmd_pool *pool, 197scsi_pool_free_command(struct scsi_host_cmd_pool *pool,
198 struct scsi_cmnd *cmd) 198 struct scsi_cmnd *cmd)
199{ 199{
200 if (cmd->prot_sdb)
201 kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb);
202
200 kmem_cache_free(pool->sense_slab, cmd->sense_buffer); 203 kmem_cache_free(pool->sense_slab, cmd->sense_buffer);
201 kmem_cache_free(pool->cmd_slab, cmd); 204 kmem_cache_free(pool->cmd_slab, cmd);
202} 205}
203 206
204/** 207/**
208 * scsi_host_alloc_command - internal function to allocate command
209 * @shost: SCSI host whose pool to allocate from
210 * @gfp_mask: mask for the allocation
211 *
212 * Returns a fully allocated command with sense buffer and protection
213 * data buffer (where applicable) or NULL on failure
214 */
215static struct scsi_cmnd *
216scsi_host_alloc_command(struct Scsi_Host *shost, gfp_t gfp_mask)
217{
218 struct scsi_cmnd *cmd;
219
220 cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask);
221 if (!cmd)
222 return NULL;
223
224 if (scsi_host_get_prot(shost) >= SHOST_DIX_TYPE0_PROTECTION) {
225 cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp_mask);
226
227 if (!cmd->prot_sdb) {
228 scsi_pool_free_command(shost->cmd_pool, cmd);
229 return NULL;
230 }
231 }
232
233 return cmd;
234}
235
236/**
205 * __scsi_get_command - Allocate a struct scsi_cmnd 237 * __scsi_get_command - Allocate a struct scsi_cmnd
206 * @shost: host to transmit command 238 * @shost: host to transmit command
207 * @gfp_mask: allocation mask 239 * @gfp_mask: allocation mask
@@ -214,7 +246,7 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
214 struct scsi_cmnd *cmd; 246 struct scsi_cmnd *cmd;
215 unsigned char *buf; 247 unsigned char *buf;
216 248
217 cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask); 249 cmd = scsi_host_alloc_command(shost, gfp_mask);
218 250
219 if (unlikely(!cmd)) { 251 if (unlikely(!cmd)) {
220 unsigned long flags; 252 unsigned long flags;
@@ -457,7 +489,7 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost)
457 /* 489 /*
458 * Get one backup command for this host. 490 * Get one backup command for this host.
459 */ 491 */
460 cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask); 492 cmd = scsi_host_alloc_command(shost, gfp_mask);
461 if (!cmd) { 493 if (!cmd) {
462 scsi_put_host_cmd_pool(gfp_mask); 494 scsi_put_host_cmd_pool(gfp_mask);
463 shost->cmd_pool = NULL; 495 shost->cmd_pool = NULL;
@@ -902,11 +934,20 @@ void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags)
902 934
903 spin_lock_irqsave(sdev->request_queue->queue_lock, flags); 935 spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
904 936
905 /* Check to see if the queue is managed by the block layer. 937 /*
906 * If it is, and we fail to adjust the depth, exit. */ 938 * Check to see if the queue is managed by the block layer.
907 if (blk_queue_tagged(sdev->request_queue) && 939 * If it is, and we fail to adjust the depth, exit.
908 blk_queue_resize_tags(sdev->request_queue, tags) != 0) 940 *
909 goto out; 941 * Do not resize the tag map if it is a host wide share bqt,
942 * because the size should be the hosts's can_queue. If there
943 * is more IO than the LLD's can_queue (so there are not enuogh
944 * tags) request_fn's host queue ready check will handle it.
945 */
946 if (!sdev->host->bqt) {
947 if (blk_queue_tagged(sdev->request_queue) &&
948 blk_queue_resize_tags(sdev->request_queue, tags) != 0)
949 goto out;
950 }
910 951
911 sdev->queue_depth = tags; 952 sdev->queue_depth = tags;
912 switch (tagged) { 953 switch (tagged) {
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 01d11a01ffbf..27c633f55794 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1753,7 +1753,7 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev)
1753 open_devip = sdebug_device_create(sdbg_host, GFP_ATOMIC); 1753 open_devip = sdebug_device_create(sdbg_host, GFP_ATOMIC);
1754 if (!open_devip) { 1754 if (!open_devip) {
1755 printk(KERN_ERR "%s: out of memory at line %d\n", 1755 printk(KERN_ERR "%s: out of memory at line %d\n",
1756 __FUNCTION__, __LINE__); 1756 __func__, __LINE__);
1757 return NULL; 1757 return NULL;
1758 } 1758 }
1759 } 1759 }
@@ -2656,7 +2656,7 @@ static int sdebug_add_adapter(void)
2656 sdbg_host = kzalloc(sizeof(*sdbg_host),GFP_KERNEL); 2656 sdbg_host = kzalloc(sizeof(*sdbg_host),GFP_KERNEL);
2657 if (NULL == sdbg_host) { 2657 if (NULL == sdbg_host) {
2658 printk(KERN_ERR "%s: out of memory at line %d\n", 2658 printk(KERN_ERR "%s: out of memory at line %d\n",
2659 __FUNCTION__, __LINE__); 2659 __func__, __LINE__);
2660 return -ENOMEM; 2660 return -ENOMEM;
2661 } 2661 }
2662 2662
@@ -2667,7 +2667,7 @@ static int sdebug_add_adapter(void)
2667 sdbg_devinfo = sdebug_device_create(sdbg_host, GFP_KERNEL); 2667 sdbg_devinfo = sdebug_device_create(sdbg_host, GFP_KERNEL);
2668 if (!sdbg_devinfo) { 2668 if (!sdbg_devinfo) {
2669 printk(KERN_ERR "%s: out of memory at line %d\n", 2669 printk(KERN_ERR "%s: out of memory at line %d\n",
2670 __FUNCTION__, __LINE__); 2670 __func__, __LINE__);
2671 error = -ENOMEM; 2671 error = -ENOMEM;
2672 goto clean; 2672 goto clean;
2673 } 2673 }
@@ -2987,7 +2987,7 @@ static int sdebug_driver_probe(struct device * dev)
2987 2987
2988 hpnt = scsi_host_alloc(&sdebug_driver_template, sizeof(sdbg_host)); 2988 hpnt = scsi_host_alloc(&sdebug_driver_template, sizeof(sdbg_host));
2989 if (NULL == hpnt) { 2989 if (NULL == hpnt) {
2990 printk(KERN_ERR "%s: scsi_register failed\n", __FUNCTION__); 2990 printk(KERN_ERR "%s: scsi_register failed\n", __func__);
2991 error = -ENODEV; 2991 error = -ENODEV;
2992 return error; 2992 return error;
2993 } 2993 }
@@ -3002,7 +3002,7 @@ static int sdebug_driver_probe(struct device * dev)
3002 3002
3003 error = scsi_add_host(hpnt, &sdbg_host->dev); 3003 error = scsi_add_host(hpnt, &sdbg_host->dev);
3004 if (error) { 3004 if (error) {
3005 printk(KERN_ERR "%s: scsi_add_host failed\n", __FUNCTION__); 3005 printk(KERN_ERR "%s: scsi_add_host failed\n", __func__);
3006 error = -ENODEV; 3006 error = -ENODEV;
3007 scsi_host_put(hpnt); 3007 scsi_host_put(hpnt);
3008 } else 3008 } else
@@ -3021,7 +3021,7 @@ static int sdebug_driver_remove(struct device * dev)
3021 3021
3022 if (!sdbg_host) { 3022 if (!sdbg_host) {
3023 printk(KERN_ERR "%s: Unable to locate host info\n", 3023 printk(KERN_ERR "%s: Unable to locate host info\n",
3024 __FUNCTION__); 3024 __func__);
3025 return -ENODEV; 3025 return -ENODEV;
3026 } 3026 }
3027 3027
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index a235802f2981..4969e4ec75ea 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -272,7 +272,7 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
272 } 272 }
273 if (from_length > to_length) 273 if (from_length > to_length)
274 printk(KERN_WARNING "%s: %s string '%s' is too long\n", 274 printk(KERN_WARNING "%s: %s string '%s' is too long\n",
275 __FUNCTION__, name, from); 275 __func__, name, from);
276} 276}
277 277
278/** 278/**
@@ -298,7 +298,7 @@ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
298 298
299 devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL); 299 devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL);
300 if (!devinfo) { 300 if (!devinfo) {
301 printk(KERN_ERR "%s: no memory\n", __FUNCTION__); 301 printk(KERN_ERR "%s: no memory\n", __func__);
302 return -ENOMEM; 302 return -ENOMEM;
303 } 303 }
304 304
@@ -363,7 +363,7 @@ static int scsi_dev_info_list_add_str(char *dev_list)
363 strflags = strsep(&next, next_check); 363 strflags = strsep(&next, next_check);
364 if (!model || !strflags) { 364 if (!model || !strflags) {
365 printk(KERN_ERR "%s: bad dev info string '%s' '%s'" 365 printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
366 " '%s'\n", __FUNCTION__, vendor, model, 366 " '%s'\n", __func__, vendor, model,
367 strflags); 367 strflags);
368 res = -EINVAL; 368 res = -EINVAL;
369 } else 369 } else
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 006a95916f72..880051c89bde 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -139,7 +139,7 @@ void scsi_add_timer(struct scsi_cmnd *scmd, int timeout,
139 scmd->eh_timeout.function = (void (*)(unsigned long)) complete; 139 scmd->eh_timeout.function = (void (*)(unsigned long)) complete;
140 140
141 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p, time:" 141 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p, time:"
142 " %d, (%p)\n", __FUNCTION__, 142 " %d, (%p)\n", __func__,
143 scmd, timeout, complete)); 143 scmd, timeout, complete));
144 144
145 add_timer(&scmd->eh_timeout); 145 add_timer(&scmd->eh_timeout);
@@ -163,7 +163,7 @@ int scsi_delete_timer(struct scsi_cmnd *scmd)
163 rtn = del_timer(&scmd->eh_timeout); 163 rtn = del_timer(&scmd->eh_timeout);
164 164
165 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p," 165 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p,"
166 " rtn: %d\n", __FUNCTION__, 166 " rtn: %d\n", __func__,
167 scmd, rtn)); 167 scmd, rtn));
168 168
169 scmd->eh_timeout.data = (unsigned long)NULL; 169 scmd->eh_timeout.data = (unsigned long)NULL;
@@ -233,7 +233,7 @@ int scsi_block_when_processing_errors(struct scsi_device *sdev)
233 233
234 online = scsi_device_online(sdev); 234 online = scsi_device_online(sdev);
235 235
236 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: rtn: %d\n", __FUNCTION__, 236 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: rtn: %d\n", __func__,
237 online)); 237 online));
238 238
239 return online; 239 return online;
@@ -271,7 +271,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
271 SCSI_LOG_ERROR_RECOVERY(3, 271 SCSI_LOG_ERROR_RECOVERY(3,
272 sdev_printk(KERN_INFO, sdev, 272 sdev_printk(KERN_INFO, sdev,
273 "%s: cmds failed: %d, cancel: %d\n", 273 "%s: cmds failed: %d, cancel: %d\n",
274 __FUNCTION__, cmd_failed, 274 __func__, cmd_failed,
275 cmd_cancel)); 275 cmd_cancel));
276 cmd_cancel = 0; 276 cmd_cancel = 0;
277 cmd_failed = 0; 277 cmd_failed = 0;
@@ -344,6 +344,9 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
344 return /* soft_error */ SUCCESS; 344 return /* soft_error */ SUCCESS;
345 345
346 case ABORTED_COMMAND: 346 case ABORTED_COMMAND:
347 if (sshdr.asc == 0x10) /* DIF */
348 return SUCCESS;
349
347 return NEEDS_RETRY; 350 return NEEDS_RETRY;
348 case NOT_READY: 351 case NOT_READY:
349 case UNIT_ATTENTION: 352 case UNIT_ATTENTION:
@@ -470,7 +473,7 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
470 473
471 SCSI_LOG_ERROR_RECOVERY(3, 474 SCSI_LOG_ERROR_RECOVERY(3,
472 printk("%s scmd: %p result: %x\n", 475 printk("%s scmd: %p result: %x\n",
473 __FUNCTION__, scmd, scmd->result)); 476 __func__, scmd, scmd->result));
474 477
475 eh_action = scmd->device->host->eh_action; 478 eh_action = scmd->device->host->eh_action;
476 if (eh_action) 479 if (eh_action)
@@ -487,7 +490,7 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
487 int rtn; 490 int rtn;
488 491
489 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", 492 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n",
490 __FUNCTION__)); 493 __func__));
491 494
492 if (!scmd->device->host->hostt->eh_host_reset_handler) 495 if (!scmd->device->host->hostt->eh_host_reset_handler)
493 return FAILED; 496 return FAILED;
@@ -516,7 +519,7 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
516 int rtn; 519 int rtn;
517 520
518 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n", 521 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n",
519 __FUNCTION__)); 522 __func__));
520 523
521 if (!scmd->device->host->hostt->eh_bus_reset_handler) 524 if (!scmd->device->host->hostt->eh_bus_reset_handler)
522 return FAILED; 525 return FAILED;
@@ -664,7 +667,10 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
664 ses->sdb = scmd->sdb; 667 ses->sdb = scmd->sdb;
665 ses->next_rq = scmd->request->next_rq; 668 ses->next_rq = scmd->request->next_rq;
666 ses->result = scmd->result; 669 ses->result = scmd->result;
670 ses->underflow = scmd->underflow;
671 ses->prot_op = scmd->prot_op;
667 672
673 scmd->prot_op = SCSI_PROT_NORMAL;
668 scmd->cmnd = ses->eh_cmnd; 674 scmd->cmnd = ses->eh_cmnd;
669 memset(scmd->cmnd, 0, BLK_MAX_CDB); 675 memset(scmd->cmnd, 0, BLK_MAX_CDB);
670 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 676 memset(&scmd->sdb, 0, sizeof(scmd->sdb));
@@ -722,6 +728,8 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
722 scmd->sdb = ses->sdb; 728 scmd->sdb = ses->sdb;
723 scmd->request->next_rq = ses->next_rq; 729 scmd->request->next_rq = ses->next_rq;
724 scmd->result = ses->result; 730 scmd->result = ses->result;
731 scmd->underflow = ses->underflow;
732 scmd->prot_op = ses->prot_op;
725} 733}
726EXPORT_SYMBOL(scsi_eh_restore_cmnd); 734EXPORT_SYMBOL(scsi_eh_restore_cmnd);
727 735
@@ -766,7 +774,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
766 774
767 SCSI_LOG_ERROR_RECOVERY(3, 775 SCSI_LOG_ERROR_RECOVERY(3,
768 printk("%s: scmd: %p, timeleft: %ld\n", 776 printk("%s: scmd: %p, timeleft: %ld\n",
769 __FUNCTION__, scmd, timeleft)); 777 __func__, scmd, timeleft));
770 778
771 /* 779 /*
772 * If there is time left scsi_eh_done got called, and we will 780 * If there is time left scsi_eh_done got called, and we will
@@ -778,7 +786,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
778 rtn = scsi_eh_completed_normally(scmd); 786 rtn = scsi_eh_completed_normally(scmd);
779 SCSI_LOG_ERROR_RECOVERY(3, 787 SCSI_LOG_ERROR_RECOVERY(3,
780 printk("%s: scsi_eh_completed_normally %x\n", 788 printk("%s: scsi_eh_completed_normally %x\n",
781 __FUNCTION__, rtn)); 789 __func__, rtn));
782 790
783 switch (rtn) { 791 switch (rtn) {
784 case SUCCESS: 792 case SUCCESS:
@@ -913,7 +921,7 @@ retry_tur:
913 rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0); 921 rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0);
914 922
915 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n", 923 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
916 __FUNCTION__, scmd, rtn)); 924 __func__, scmd, rtn));
917 925
918 switch (rtn) { 926 switch (rtn) {
919 case NEEDS_RETRY: 927 case NEEDS_RETRY:
@@ -1296,7 +1304,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1296 if (!scsi_device_online(scmd->device)) { 1304 if (!scsi_device_online(scmd->device)) {
1297 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report" 1305 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report"
1298 " as SUCCESS\n", 1306 " as SUCCESS\n",
1299 __FUNCTION__)); 1307 __func__));
1300 return SUCCESS; 1308 return SUCCESS;
1301 } 1309 }
1302 1310
@@ -1511,7 +1519,7 @@ static void scsi_restart_operations(struct Scsi_Host *shost)
1511 * ioctls to queued block devices. 1519 * ioctls to queued block devices.
1512 */ 1520 */
1513 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n", 1521 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n",
1514 __FUNCTION__)); 1522 __func__));
1515 1523
1516 spin_lock_irqsave(shost->host_lock, flags); 1524 spin_lock_irqsave(shost->host_lock, flags);
1517 if (scsi_host_set_state(shost, SHOST_RUNNING)) 1525 if (scsi_host_set_state(shost, SHOST_RUNNING))
@@ -1835,7 +1843,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
1835 */ 1843 */
1836 SCSI_LOG_ERROR_RECOVERY(3, 1844 SCSI_LOG_ERROR_RECOVERY(3,
1837 printk("%s: waking up host to restart after TMF\n", 1845 printk("%s: waking up host to restart after TMF\n",
1838 __FUNCTION__)); 1846 __func__));
1839 1847
1840 wake_up(&shost->host_wait); 1848 wake_up(&shost->host_wait);
1841 1849
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 88d1b5f44e59..ff5d56b3ee4d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -65,7 +65,7 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = {
65}; 65};
66#undef SP 66#undef SP
67 67
68static struct kmem_cache *scsi_sdb_cache; 68struct kmem_cache *scsi_sdb_cache;
69 69
70static void scsi_run_queue(struct request_queue *q); 70static void scsi_run_queue(struct request_queue *q);
71 71
@@ -787,6 +787,9 @@ void scsi_release_buffers(struct scsi_cmnd *cmd)
787 kmem_cache_free(scsi_sdb_cache, bidi_sdb); 787 kmem_cache_free(scsi_sdb_cache, bidi_sdb);
788 cmd->request->next_rq->special = NULL; 788 cmd->request->next_rq->special = NULL;
789 } 789 }
790
791 if (scsi_prot_sg_count(cmd))
792 scsi_free_sgtable(cmd->prot_sdb);
790} 793}
791EXPORT_SYMBOL(scsi_release_buffers); 794EXPORT_SYMBOL(scsi_release_buffers);
792 795
@@ -947,9 +950,14 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
947 * 6-byte command. 950 * 6-byte command.
948 */ 951 */
949 scsi_requeue_command(q, cmd); 952 scsi_requeue_command(q, cmd);
950 return; 953 } else if (sshdr.asc == 0x10) /* DIX */
951 } else { 954 scsi_end_request(cmd, -EIO, this_count, 0);
955 else
952 scsi_end_request(cmd, -EIO, this_count, 1); 956 scsi_end_request(cmd, -EIO, this_count, 1);
957 return;
958 case ABORTED_COMMAND:
959 if (sshdr.asc == 0x10) { /* DIF */
960 scsi_end_request(cmd, -EIO, this_count, 0);
953 return; 961 return;
954 } 962 }
955 break; 963 break;
@@ -1072,6 +1080,26 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
1072 goto err_exit; 1080 goto err_exit;
1073 } 1081 }
1074 1082
1083 if (blk_integrity_rq(cmd->request)) {
1084 struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
1085 int ivecs, count;
1086
1087 BUG_ON(prot_sdb == NULL);
1088 ivecs = blk_rq_count_integrity_sg(cmd->request);
1089
1090 if (scsi_alloc_sgtable(prot_sdb, ivecs, gfp_mask)) {
1091 error = BLKPREP_DEFER;
1092 goto err_exit;
1093 }
1094
1095 count = blk_rq_map_integrity_sg(cmd->request,
1096 prot_sdb->table.sgl);
1097 BUG_ON(unlikely(count > ivecs));
1098
1099 cmd->prot_sdb = prot_sdb;
1100 cmd->prot_sdb->table.nents = count;
1101 }
1102
1075 return BLKPREP_OK ; 1103 return BLKPREP_OK ;
1076 1104
1077err_exit: 1105err_exit:
@@ -1367,7 +1395,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
1367 1395
1368 if (unlikely(cmd == NULL)) { 1396 if (unlikely(cmd == NULL)) {
1369 printk(KERN_CRIT "impossible request in %s.\n", 1397 printk(KERN_CRIT "impossible request in %s.\n",
1370 __FUNCTION__); 1398 __func__);
1371 BUG(); 1399 BUG();
1372 } 1400 }
1373 1401
@@ -1491,12 +1519,27 @@ static void scsi_request_fn(struct request_queue *q)
1491 printk(KERN_CRIT "impossible request in %s.\n" 1519 printk(KERN_CRIT "impossible request in %s.\n"
1492 "please mail a stack trace to " 1520 "please mail a stack trace to "
1493 "linux-scsi@vger.kernel.org\n", 1521 "linux-scsi@vger.kernel.org\n",
1494 __FUNCTION__); 1522 __func__);
1495 blk_dump_rq_flags(req, "foo"); 1523 blk_dump_rq_flags(req, "foo");
1496 BUG(); 1524 BUG();
1497 } 1525 }
1498 spin_lock(shost->host_lock); 1526 spin_lock(shost->host_lock);
1499 1527
1528 /*
1529 * We hit this when the driver is using a host wide
1530 * tag map. For device level tag maps the queue_depth check
1531 * in the device ready fn would prevent us from trying
1532 * to allocate a tag. Since the map is a shared host resource
1533 * we add the dev to the starved list so it eventually gets
1534 * a run when a tag is freed.
1535 */
1536 if (blk_queue_tagged(q) && !blk_rq_tagged(req)) {
1537 if (list_empty(&sdev->starved_entry))
1538 list_add_tail(&sdev->starved_entry,
1539 &shost->starved_list);
1540 goto not_ready;
1541 }
1542
1500 if (!scsi_host_queue_ready(q, shost, sdev)) 1543 if (!scsi_host_queue_ready(q, shost, sdev))
1501 goto not_ready; 1544 goto not_ready;
1502 if (scsi_target(sdev)->single_lun) { 1545 if (scsi_target(sdev)->single_lun) {
@@ -2486,7 +2529,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
2486 if (unlikely(i == sg_count)) { 2529 if (unlikely(i == sg_count)) {
2487 printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, " 2530 printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
2488 "elements %d\n", 2531 "elements %d\n",
2489 __FUNCTION__, sg_len, *offset, sg_count); 2532 __func__, sg_len, *offset, sg_count);
2490 WARN_ON(1); 2533 WARN_ON(1);
2491 return NULL; 2534 return NULL;
2492 } 2535 }
diff --git a/drivers/scsi/scsi_netlink.c b/drivers/scsi/scsi_netlink.c
index 370c78cc1cb5..ae7ed9a22662 100644
--- a/drivers/scsi/scsi_netlink.c
+++ b/drivers/scsi/scsi_netlink.c
@@ -55,7 +55,7 @@ scsi_nl_rcv_msg(struct sk_buff *skb)
55 if ((nlh->nlmsg_len < (sizeof(*nlh) + sizeof(*hdr))) || 55 if ((nlh->nlmsg_len < (sizeof(*nlh) + sizeof(*hdr))) ||
56 (skb->len < nlh->nlmsg_len)) { 56 (skb->len < nlh->nlmsg_len)) {
57 printk(KERN_WARNING "%s: discarding partial skb\n", 57 printk(KERN_WARNING "%s: discarding partial skb\n",
58 __FUNCTION__); 58 __func__);
59 return; 59 return;
60 } 60 }
61 61
@@ -82,7 +82,7 @@ scsi_nl_rcv_msg(struct sk_buff *skb)
82 82
83 if (nlh->nlmsg_len < (sizeof(*nlh) + hdr->msglen)) { 83 if (nlh->nlmsg_len < (sizeof(*nlh) + hdr->msglen)) {
84 printk(KERN_WARNING "%s: discarding partial message\n", 84 printk(KERN_WARNING "%s: discarding partial message\n",
85 __FUNCTION__); 85 __func__);
86 return; 86 return;
87 } 87 }
88 88
@@ -139,7 +139,7 @@ scsi_netlink_init(void)
139 error = netlink_register_notifier(&scsi_netlink_notifier); 139 error = netlink_register_notifier(&scsi_netlink_notifier);
140 if (error) { 140 if (error) {
141 printk(KERN_ERR "%s: register of event handler failed - %d\n", 141 printk(KERN_ERR "%s: register of event handler failed - %d\n",
142 __FUNCTION__, error); 142 __func__, error);
143 return; 143 return;
144 } 144 }
145 145
@@ -148,7 +148,7 @@ scsi_netlink_init(void)
148 THIS_MODULE); 148 THIS_MODULE);
149 if (!scsi_nl_sock) { 149 if (!scsi_nl_sock) {
150 printk(KERN_ERR "%s: register of recieve handler failed\n", 150 printk(KERN_ERR "%s: register of recieve handler failed\n",
151 __FUNCTION__); 151 __func__);
152 netlink_unregister_notifier(&scsi_netlink_notifier); 152 netlink_unregister_notifier(&scsi_netlink_notifier);
153 } 153 }
154 154
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index b33e72516ef8..79f0f7511204 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -77,6 +77,7 @@ extern void scsi_exit_queue(void);
77struct request_queue; 77struct request_queue;
78struct request; 78struct request;
79extern int scsi_prep_fn(struct request_queue *, struct request *); 79extern int scsi_prep_fn(struct request_queue *, struct request *);
80extern struct kmem_cache *scsi_sdb_cache;
80 81
81/* scsi_proc.c */ 82/* scsi_proc.c */
82#ifdef CONFIG_SCSI_PROC_FS 83#ifdef CONFIG_SCSI_PROC_FS
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index e4a0d2f9b357..c6a904a45bf9 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -114,7 +114,7 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
114 sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi); 114 sht->proc_dir = proc_mkdir(sht->proc_name, proc_scsi);
115 if (!sht->proc_dir) 115 if (!sht->proc_dir)
116 printk(KERN_ERR "%s: proc_mkdir failed for %s\n", 116 printk(KERN_ERR "%s: proc_mkdir failed for %s\n",
117 __FUNCTION__, sht->proc_name); 117 __func__, sht->proc_name);
118 else 118 else
119 sht->proc_dir->owner = sht->module; 119 sht->proc_dir->owner = sht->module;
120 } 120 }
@@ -157,7 +157,7 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
157 sht->proc_dir, proc_scsi_read, shost); 157 sht->proc_dir, proc_scsi_read, shost);
158 if (!p) { 158 if (!p) {
159 printk(KERN_ERR "%s: Failed to register host %d in" 159 printk(KERN_ERR "%s: Failed to register host %d in"
160 "%s\n", __FUNCTION__, shost->host_no, 160 "%s\n", __func__, shost->host_no,
161 sht->proc_name); 161 sht->proc_name);
162 return; 162 return;
163 } 163 }
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 196fe3af0d5e..84b4879cff11 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -318,7 +318,7 @@ out_device_destroy:
318 put_device(&sdev->sdev_gendev); 318 put_device(&sdev->sdev_gendev);
319out: 319out:
320 if (display_failure_msg) 320 if (display_failure_msg)
321 printk(ALLOC_FAILURE_MSG, __FUNCTION__); 321 printk(ALLOC_FAILURE_MSG, __func__);
322 return NULL; 322 return NULL;
323} 323}
324 324
@@ -404,7 +404,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
404 404
405 starget = kzalloc(size, GFP_KERNEL); 405 starget = kzalloc(size, GFP_KERNEL);
406 if (!starget) { 406 if (!starget) {
407 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 407 printk(KERN_ERR "%s: allocation failure\n", __func__);
408 return NULL; 408 return NULL;
409 } 409 }
410 dev = &starget->dev; 410 dev = &starget->dev;
@@ -1337,7 +1337,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1337 lun_data = kmalloc(length, GFP_ATOMIC | 1337 lun_data = kmalloc(length, GFP_ATOMIC |
1338 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0)); 1338 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
1339 if (!lun_data) { 1339 if (!lun_data) {
1340 printk(ALLOC_FAILURE_MSG, __FUNCTION__); 1340 printk(ALLOC_FAILURE_MSG, __func__);
1341 goto out; 1341 goto out;
1342 } 1342 }
1343 1343
@@ -1649,7 +1649,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1649{ 1649{
1650 SCSI_LOG_SCAN_BUS(3, shost_printk (KERN_INFO, shost, 1650 SCSI_LOG_SCAN_BUS(3, shost_printk (KERN_INFO, shost,
1651 "%s: <%u:%u:%u>\n", 1651 "%s: <%u:%u:%u>\n",
1652 __FUNCTION__, channel, id, lun)); 1652 __func__, channel, id, lun));
1653 1653
1654 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) || 1654 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
1655 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) || 1655 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
@@ -1703,7 +1703,7 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
1703 return NULL; 1703 return NULL;
1704 1704
1705 if (shost->async_scan) { 1705 if (shost->async_scan) {
1706 printk("%s called twice for host %d", __FUNCTION__, 1706 printk("%s called twice for host %d", __func__,
1707 shost->host_no); 1707 shost->host_no);
1708 dump_stack(); 1708 dump_stack();
1709 return NULL; 1709 return NULL;
@@ -1757,9 +1757,10 @@ static void scsi_finish_async_scan(struct async_scan_data *data)
1757 mutex_lock(&shost->scan_mutex); 1757 mutex_lock(&shost->scan_mutex);
1758 1758
1759 if (!shost->async_scan) { 1759 if (!shost->async_scan) {
1760 printk("%s called twice for host %d", __FUNCTION__, 1760 printk("%s called twice for host %d", __func__,
1761 shost->host_no); 1761 shost->host_no);
1762 dump_stack(); 1762 dump_stack();
1763 mutex_unlock(&shost->scan_mutex);
1763 return; 1764 return;
1764 } 1765 }
1765 1766
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b6e561059779..ab3c71869be5 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -249,6 +249,8 @@ shost_rd_attr(cmd_per_lun, "%hd\n");
249shost_rd_attr(can_queue, "%hd\n"); 249shost_rd_attr(can_queue, "%hd\n");
250shost_rd_attr(sg_tablesize, "%hu\n"); 250shost_rd_attr(sg_tablesize, "%hu\n");
251shost_rd_attr(unchecked_isa_dma, "%d\n"); 251shost_rd_attr(unchecked_isa_dma, "%d\n");
252shost_rd_attr(prot_capabilities, "%u\n");
253shost_rd_attr(prot_guard_type, "%hd\n");
252shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 254shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
253 255
254static struct attribute *scsi_sysfs_shost_attrs[] = { 256static struct attribute *scsi_sysfs_shost_attrs[] = {
@@ -263,6 +265,8 @@ static struct attribute *scsi_sysfs_shost_attrs[] = {
263 &dev_attr_hstate.attr, 265 &dev_attr_hstate.attr,
264 &dev_attr_supported_mode.attr, 266 &dev_attr_supported_mode.attr,
265 &dev_attr_active_mode.attr, 267 &dev_attr_active_mode.attr,
268 &dev_attr_prot_capabilities.attr,
269 &dev_attr_prot_guard_type.attr,
266 NULL 270 NULL
267}; 271};
268 272
diff --git a/drivers/scsi/scsi_tgt_priv.h b/drivers/scsi/scsi_tgt_priv.h
index cb92888948f9..fe4c62177f78 100644
--- a/drivers/scsi/scsi_tgt_priv.h
+++ b/drivers/scsi/scsi_tgt_priv.h
@@ -6,7 +6,7 @@ struct task_struct;
6/* tmp - will replace with SCSI logging stuff */ 6/* tmp - will replace with SCSI logging stuff */
7#define eprintk(fmt, args...) \ 7#define eprintk(fmt, args...) \
8do { \ 8do { \
9 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \ 9 printk("%s(%d) " fmt, __func__, __LINE__, ##args); \
10} while (0) 10} while (0)
11 11
12#define dprintk(fmt, args...) 12#define dprintk(fmt, args...)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index a272b9a2c869..56823fd1fb84 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -571,7 +571,7 @@ send_fail:
571 name = get_fc_host_event_code_name(event_code); 571 name = get_fc_host_event_code_name(event_code);
572 printk(KERN_WARNING 572 printk(KERN_WARNING
573 "%s: Dropped Event : host %d %s data 0x%08x - err %d\n", 573 "%s: Dropped Event : host %d %s data 0x%08x - err %d\n",
574 __FUNCTION__, shost->host_no, 574 __func__, shost->host_no,
575 (name) ? name : "<unknown>", event_data, err); 575 (name) ? name : "<unknown>", event_data, err);
576 return; 576 return;
577} 577}
@@ -644,7 +644,7 @@ send_vendor_fail_skb:
644send_vendor_fail: 644send_vendor_fail:
645 printk(KERN_WARNING 645 printk(KERN_WARNING
646 "%s: Dropped Event : host %d vendor_unique - err %d\n", 646 "%s: Dropped Event : host %d vendor_unique - err %d\n",
647 __FUNCTION__, shost->host_no, err); 647 __func__, shost->host_no, err);
648 return; 648 return;
649} 649}
650EXPORT_SYMBOL(fc_host_post_vendor_event); 650EXPORT_SYMBOL(fc_host_post_vendor_event);
@@ -2464,7 +2464,7 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
2464 size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size); 2464 size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
2465 rport = kzalloc(size, GFP_KERNEL); 2465 rport = kzalloc(size, GFP_KERNEL);
2466 if (unlikely(!rport)) { 2466 if (unlikely(!rport)) {
2467 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 2467 printk(KERN_ERR "%s: allocation failure\n", __func__);
2468 return NULL; 2468 return NULL;
2469 } 2469 }
2470 2470
@@ -3137,7 +3137,7 @@ fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
3137 size = (sizeof(struct fc_vport) + fci->f->dd_fcvport_size); 3137 size = (sizeof(struct fc_vport) + fci->f->dd_fcvport_size);
3138 vport = kzalloc(size, GFP_KERNEL); 3138 vport = kzalloc(size, GFP_KERNEL);
3139 if (unlikely(!vport)) { 3139 if (unlikely(!vport)) {
3140 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 3140 printk(KERN_ERR "%s: allocation failure\n", __func__);
3141 return -ENOMEM; 3141 return -ENOMEM;
3142 } 3142 }
3143 3143
@@ -3201,7 +3201,7 @@ fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
3201 printk(KERN_ERR 3201 printk(KERN_ERR
3202 "%s: Cannot create vport symlinks for " 3202 "%s: Cannot create vport symlinks for "
3203 "%s, err=%d\n", 3203 "%s, err=%d\n",
3204 __FUNCTION__, dev->bus_id, error); 3204 __func__, dev->bus_id, error);
3205 } 3205 }
3206 spin_lock_irqsave(shost->host_lock, flags); 3206 spin_lock_irqsave(shost->host_lock, flags);
3207 vport->flags &= ~FC_VPORT_CREATING; 3207 vport->flags &= ~FC_VPORT_CREATING;
@@ -3314,7 +3314,7 @@ fc_vport_sched_delete(struct work_struct *work)
3314 if (stat) 3314 if (stat)
3315 dev_printk(KERN_ERR, vport->dev.parent, 3315 dev_printk(KERN_ERR, vport->dev.parent,
3316 "%s: %s could not be deleted created via " 3316 "%s: %s could not be deleted created via "
3317 "shost%d channel %d - error %d\n", __FUNCTION__, 3317 "shost%d channel %d - error %d\n", __func__,
3318 vport->dev.bus_id, vport->shost->host_no, 3318 vport->dev.bus_id, vport->shost->host_no,
3319 vport->channel, stat); 3319 vport->channel, stat);
3320} 3320}
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index f4461d35ffb9..366609386be1 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -779,7 +779,7 @@ static void sas_port_create_link(struct sas_port *port,
779 return; 779 return;
780err: 780err:
781 printk(KERN_ERR "%s: Cannot create port links, err=%d\n", 781 printk(KERN_ERR "%s: Cannot create port links, err=%d\n",
782 __FUNCTION__, res); 782 __func__, res);
783} 783}
784 784
785static void sas_port_delete_link(struct sas_port *port, 785static void sas_port_delete_link(struct sas_port *port,
@@ -1029,7 +1029,7 @@ void sas_port_mark_backlink(struct sas_port *port)
1029 return; 1029 return;
1030err: 1030err:
1031 printk(KERN_ERR "%s: Cannot create port backlink, err=%d\n", 1031 printk(KERN_ERR "%s: Cannot create port backlink, err=%d\n",
1032 __FUNCTION__, res); 1032 __func__, res);
1033 1033
1034} 1034}
1035EXPORT_SYMBOL(sas_port_mark_backlink); 1035EXPORT_SYMBOL(sas_port_mark_backlink);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 0c63947d8a9d..e5e7d7856454 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -99,8 +99,7 @@ static void scsi_disk_release(struct device *cdev);
99static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 99static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
100static void sd_print_result(struct scsi_disk *, int); 100static void sd_print_result(struct scsi_disk *, int);
101 101
102static DEFINE_IDR(sd_index_idr); 102static DEFINE_IDA(sd_index_ida);
103static DEFINE_SPINLOCK(sd_index_lock);
104 103
105/* This semaphore is used to mediate the 0->1 reference get in the 104/* This semaphore is used to mediate the 0->1 reference get in the
106 * face of object destruction (i.e. we can't allow a get on an 105 * face of object destruction (i.e. we can't allow a get on an
@@ -234,6 +233,24 @@ sd_show_allow_restart(struct device *dev, struct device_attribute *attr,
234 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); 233 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart);
235} 234}
236 235
236static ssize_t
237sd_show_protection_type(struct device *dev, struct device_attribute *attr,
238 char *buf)
239{
240 struct scsi_disk *sdkp = to_scsi_disk(dev);
241
242 return snprintf(buf, 20, "%u\n", sdkp->protection_type);
243}
244
245static ssize_t
246sd_show_app_tag_own(struct device *dev, struct device_attribute *attr,
247 char *buf)
248{
249 struct scsi_disk *sdkp = to_scsi_disk(dev);
250
251 return snprintf(buf, 20, "%u\n", sdkp->ATO);
252}
253
237static struct device_attribute sd_disk_attrs[] = { 254static struct device_attribute sd_disk_attrs[] = {
238 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 255 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,
239 sd_store_cache_type), 256 sd_store_cache_type),
@@ -242,6 +259,8 @@ static struct device_attribute sd_disk_attrs[] = {
242 sd_store_allow_restart), 259 sd_store_allow_restart),
243 __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop, 260 __ATTR(manage_start_stop, S_IRUGO|S_IWUSR, sd_show_manage_start_stop,
244 sd_store_manage_start_stop), 261 sd_store_manage_start_stop),
262 __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL),
263 __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL),
245 __ATTR_NULL, 264 __ATTR_NULL,
246}; 265};
247 266
@@ -354,7 +373,9 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
354 struct scsi_cmnd *SCpnt; 373 struct scsi_cmnd *SCpnt;
355 struct scsi_device *sdp = q->queuedata; 374 struct scsi_device *sdp = q->queuedata;
356 struct gendisk *disk = rq->rq_disk; 375 struct gendisk *disk = rq->rq_disk;
376 struct scsi_disk *sdkp;
357 sector_t block = rq->sector; 377 sector_t block = rq->sector;
378 sector_t threshold;
358 unsigned int this_count = rq->nr_sectors; 379 unsigned int this_count = rq->nr_sectors;
359 unsigned int timeout = sdp->timeout; 380 unsigned int timeout = sdp->timeout;
360 int ret; 381 int ret;
@@ -370,6 +391,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
370 if (ret != BLKPREP_OK) 391 if (ret != BLKPREP_OK)
371 goto out; 392 goto out;
372 SCpnt = rq->special; 393 SCpnt = rq->special;
394 sdkp = scsi_disk(disk);
373 395
374 /* from here on until we're complete, any goto out 396 /* from here on until we're complete, any goto out
375 * is used for a killable error condition */ 397 * is used for a killable error condition */
@@ -401,13 +423,21 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
401 } 423 }
402 424
403 /* 425 /*
404 * Some devices (some sdcards for one) don't like it if the 426 * Some SD card readers can't handle multi-sector accesses which touch
405 * last sector gets read in a larger then 1 sector read. 427 * the last one or two hardware sectors. Split accesses as needed.
406 */ 428 */
407 if (unlikely(sdp->last_sector_bug && 429 threshold = get_capacity(disk) - SD_LAST_BUGGY_SECTORS *
408 rq->nr_sectors > sdp->sector_size / 512 && 430 (sdp->sector_size / 512);
409 block + this_count == get_capacity(disk))) 431
410 this_count -= sdp->sector_size / 512; 432 if (unlikely(sdp->last_sector_bug && block + this_count > threshold)) {
433 if (block < threshold) {
434 /* Access up to the threshold but not beyond */
435 this_count = threshold - block;
436 } else {
437 /* Access only a single hardware sector */
438 this_count = sdp->sector_size / 512;
439 }
440 }
411 441
412 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n", 442 SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n",
413 (unsigned long long)block)); 443 (unsigned long long)block));
@@ -459,6 +489,11 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
459 } 489 }
460 SCpnt->cmnd[0] = WRITE_6; 490 SCpnt->cmnd[0] = WRITE_6;
461 SCpnt->sc_data_direction = DMA_TO_DEVICE; 491 SCpnt->sc_data_direction = DMA_TO_DEVICE;
492
493 if (blk_integrity_rq(rq) &&
494 sd_dif_prepare(rq, block, sdp->sector_size) == -EIO)
495 goto out;
496
462 } else if (rq_data_dir(rq) == READ) { 497 } else if (rq_data_dir(rq) == READ) {
463 SCpnt->cmnd[0] = READ_6; 498 SCpnt->cmnd[0] = READ_6;
464 SCpnt->sc_data_direction = DMA_FROM_DEVICE; 499 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
@@ -473,8 +508,12 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
473 "writing" : "reading", this_count, 508 "writing" : "reading", this_count,
474 rq->nr_sectors)); 509 rq->nr_sectors));
475 510
476 SCpnt->cmnd[1] = 0; 511 /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */
477 512 if (scsi_host_dif_capable(sdp->host, sdkp->protection_type))
513 SCpnt->cmnd[1] = 1 << 5;
514 else
515 SCpnt->cmnd[1] = 0;
516
478 if (block > 0xffffffff) { 517 if (block > 0xffffffff) {
479 SCpnt->cmnd[0] += READ_16 - READ_6; 518 SCpnt->cmnd[0] += READ_16 - READ_6;
480 SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; 519 SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0;
@@ -492,6 +531,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
492 SCpnt->cmnd[13] = (unsigned char) this_count & 0xff; 531 SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
493 SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0; 532 SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
494 } else if ((this_count > 0xff) || (block > 0x1fffff) || 533 } else if ((this_count > 0xff) || (block > 0x1fffff) ||
534 scsi_device_protection(SCpnt->device) ||
495 SCpnt->device->use_10_for_rw) { 535 SCpnt->device->use_10_for_rw) {
496 if (this_count > 0xffff) 536 if (this_count > 0xffff)
497 this_count = 0xffff; 537 this_count = 0xffff;
@@ -526,6 +566,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
526 } 566 }
527 SCpnt->sdb.length = this_count * sdp->sector_size; 567 SCpnt->sdb.length = this_count * sdp->sector_size;
528 568
569 /* If DIF or DIX is enabled, tell HBA how to handle request */
570 if (sdkp->protection_type || scsi_prot_sg_count(SCpnt))
571 sd_dif_op(SCpnt, sdkp->protection_type, scsi_prot_sg_count(SCpnt));
572
529 /* 573 /*
530 * We shouldn't disconnect in the middle of a sector, so with a dumb 574 * We shouldn't disconnect in the middle of a sector, so with a dumb
531 * host adapter, it's safe to assume that we can at least transfer 575 * host adapter, it's safe to assume that we can at least transfer
@@ -920,6 +964,48 @@ static struct block_device_operations sd_fops = {
920 .revalidate_disk = sd_revalidate_disk, 964 .revalidate_disk = sd_revalidate_disk,
921}; 965};
922 966
967static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
968{
969 u64 start_lba = scmd->request->sector;
970 u64 end_lba = scmd->request->sector + (scsi_bufflen(scmd) / 512);
971 u64 bad_lba;
972 int info_valid;
973
974 if (!blk_fs_request(scmd->request))
975 return 0;
976
977 info_valid = scsi_get_sense_info_fld(scmd->sense_buffer,
978 SCSI_SENSE_BUFFERSIZE,
979 &bad_lba);
980 if (!info_valid)
981 return 0;
982
983 if (scsi_bufflen(scmd) <= scmd->device->sector_size)
984 return 0;
985
986 if (scmd->device->sector_size < 512) {
987 /* only legitimate sector_size here is 256 */
988 start_lba <<= 1;
989 end_lba <<= 1;
990 } else {
991 /* be careful ... don't want any overflows */
992 u64 factor = scmd->device->sector_size / 512;
993 do_div(start_lba, factor);
994 do_div(end_lba, factor);
995 }
996
997 /* The bad lba was reported incorrectly, we have no idea where
998 * the error is.
999 */
1000 if (bad_lba < start_lba || bad_lba >= end_lba)
1001 return 0;
1002
1003 /* This computation should always be done in terms of
1004 * the resolution of the device's medium.
1005 */
1006 return (bad_lba - start_lba) * scmd->device->sector_size;
1007}
1008
923/** 1009/**
924 * sd_done - bottom half handler: called when the lower level 1010 * sd_done - bottom half handler: called when the lower level
925 * driver has completed (successfully or otherwise) a scsi command. 1011 * driver has completed (successfully or otherwise) a scsi command.
@@ -930,15 +1016,10 @@ static struct block_device_operations sd_fops = {
930static int sd_done(struct scsi_cmnd *SCpnt) 1016static int sd_done(struct scsi_cmnd *SCpnt)
931{ 1017{
932 int result = SCpnt->result; 1018 int result = SCpnt->result;
933 unsigned int xfer_size = scsi_bufflen(SCpnt); 1019 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
934 unsigned int good_bytes = result ? 0 : xfer_size;
935 u64 start_lba = SCpnt->request->sector;
936 u64 end_lba = SCpnt->request->sector + (xfer_size / 512);
937 u64 bad_lba;
938 struct scsi_sense_hdr sshdr; 1020 struct scsi_sense_hdr sshdr;
939 int sense_valid = 0; 1021 int sense_valid = 0;
940 int sense_deferred = 0; 1022 int sense_deferred = 0;
941 int info_valid;
942 1023
943 if (result) { 1024 if (result) {
944 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); 1025 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr);
@@ -963,36 +1044,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
963 switch (sshdr.sense_key) { 1044 switch (sshdr.sense_key) {
964 case HARDWARE_ERROR: 1045 case HARDWARE_ERROR:
965 case MEDIUM_ERROR: 1046 case MEDIUM_ERROR:
966 if (!blk_fs_request(SCpnt->request)) 1047 good_bytes = sd_completed_bytes(SCpnt);
967 goto out;
968 info_valid = scsi_get_sense_info_fld(SCpnt->sense_buffer,
969 SCSI_SENSE_BUFFERSIZE,
970 &bad_lba);
971 if (!info_valid)
972 goto out;
973 if (xfer_size <= SCpnt->device->sector_size)
974 goto out;
975 if (SCpnt->device->sector_size < 512) {
976 /* only legitimate sector_size here is 256 */
977 start_lba <<= 1;
978 end_lba <<= 1;
979 } else {
980 /* be careful ... don't want any overflows */
981 u64 factor = SCpnt->device->sector_size / 512;
982 do_div(start_lba, factor);
983 do_div(end_lba, factor);
984 }
985
986 if (bad_lba < start_lba || bad_lba >= end_lba)
987 /* the bad lba was reported incorrectly, we have
988 * no idea where the error is
989 */
990 goto out;
991
992 /* This computation should always be done in terms of
993 * the resolution of the device's medium.
994 */
995 good_bytes = (bad_lba - start_lba)*SCpnt->device->sector_size;
996 break; 1048 break;
997 case RECOVERED_ERROR: 1049 case RECOVERED_ERROR:
998 case NO_SENSE: 1050 case NO_SENSE:
@@ -1002,10 +1054,23 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1002 scsi_print_sense("sd", SCpnt); 1054 scsi_print_sense("sd", SCpnt);
1003 SCpnt->result = 0; 1055 SCpnt->result = 0;
1004 memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 1056 memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
1005 good_bytes = xfer_size; 1057 good_bytes = scsi_bufflen(SCpnt);
1058 break;
1059 case ABORTED_COMMAND:
1060 if (sshdr.asc == 0x10) { /* DIF: Disk detected corruption */
1061 scsi_print_result(SCpnt);
1062 scsi_print_sense("sd", SCpnt);
1063 good_bytes = sd_completed_bytes(SCpnt);
1064 }
1006 break; 1065 break;
1007 case ILLEGAL_REQUEST: 1066 case ILLEGAL_REQUEST:
1008 if (SCpnt->device->use_10_for_rw && 1067 if (sshdr.asc == 0x10) { /* DIX: HBA detected corruption */
1068 scsi_print_result(SCpnt);
1069 scsi_print_sense("sd", SCpnt);
1070 good_bytes = sd_completed_bytes(SCpnt);
1071 }
1072 if (!scsi_device_protection(SCpnt->device) &&
1073 SCpnt->device->use_10_for_rw &&
1009 (SCpnt->cmnd[0] == READ_10 || 1074 (SCpnt->cmnd[0] == READ_10 ||
1010 SCpnt->cmnd[0] == WRITE_10)) 1075 SCpnt->cmnd[0] == WRITE_10))
1011 SCpnt->device->use_10_for_rw = 0; 1076 SCpnt->device->use_10_for_rw = 0;
@@ -1018,6 +1083,9 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1018 break; 1083 break;
1019 } 1084 }
1020 out: 1085 out:
1086 if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt))
1087 sd_dif_complete(SCpnt, good_bytes);
1088
1021 return good_bytes; 1089 return good_bytes;
1022} 1090}
1023 1091
@@ -1165,6 +1233,49 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1165 } 1233 }
1166} 1234}
1167 1235
1236
1237/*
1238 * Determine whether disk supports Data Integrity Field.
1239 */
1240void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer)
1241{
1242 struct scsi_device *sdp = sdkp->device;
1243 u8 type;
1244
1245 if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0)
1246 type = 0;
1247 else
1248 type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
1249
1250 switch (type) {
1251 case SD_DIF_TYPE0_PROTECTION:
1252 sdkp->protection_type = 0;
1253 break;
1254
1255 case SD_DIF_TYPE1_PROTECTION:
1256 case SD_DIF_TYPE3_PROTECTION:
1257 sdkp->protection_type = type;
1258 break;
1259
1260 case SD_DIF_TYPE2_PROTECTION:
1261 sd_printk(KERN_ERR, sdkp, "formatted with DIF Type 2 " \
1262 "protection which is currently unsupported. " \
1263 "Disabling disk!\n");
1264 goto disable;
1265
1266 default:
1267 sd_printk(KERN_ERR, sdkp, "formatted with unknown " \
1268 "protection type %d. Disabling disk!\n", type);
1269 goto disable;
1270 }
1271
1272 return;
1273
1274disable:
1275 sdkp->protection_type = 0;
1276 sdkp->capacity = 0;
1277}
1278
1168/* 1279/*
1169 * read disk capacity 1280 * read disk capacity
1170 */ 1281 */
@@ -1174,7 +1285,8 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
1174 unsigned char cmd[16]; 1285 unsigned char cmd[16];
1175 int the_result, retries; 1286 int the_result, retries;
1176 int sector_size = 0; 1287 int sector_size = 0;
1177 int longrc = 0; 1288 /* Force READ CAPACITY(16) when PROTECT=1 */
1289 int longrc = scsi_device_protection(sdkp->device) ? 1 : 0;
1178 struct scsi_sense_hdr sshdr; 1290 struct scsi_sense_hdr sshdr;
1179 int sense_valid = 0; 1291 int sense_valid = 0;
1180 struct scsi_device *sdp = sdkp->device; 1292 struct scsi_device *sdp = sdkp->device;
@@ -1186,8 +1298,8 @@ repeat:
1186 memset((void *) cmd, 0, 16); 1298 memset((void *) cmd, 0, 16);
1187 cmd[0] = SERVICE_ACTION_IN; 1299 cmd[0] = SERVICE_ACTION_IN;
1188 cmd[1] = SAI_READ_CAPACITY_16; 1300 cmd[1] = SAI_READ_CAPACITY_16;
1189 cmd[13] = 12; 1301 cmd[13] = 13;
1190 memset((void *) buffer, 0, 12); 1302 memset((void *) buffer, 0, 13);
1191 } else { 1303 } else {
1192 cmd[0] = READ_CAPACITY; 1304 cmd[0] = READ_CAPACITY;
1193 memset((void *) &cmd[1], 0, 9); 1305 memset((void *) &cmd[1], 0, 9);
@@ -1195,7 +1307,7 @@ repeat:
1195 } 1307 }
1196 1308
1197 the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE, 1309 the_result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
1198 buffer, longrc ? 12 : 8, &sshdr, 1310 buffer, longrc ? 13 : 8, &sshdr,
1199 SD_TIMEOUT, SD_MAX_RETRIES); 1311 SD_TIMEOUT, SD_MAX_RETRIES);
1200 1312
1201 if (media_not_present(sdkp, &sshdr)) 1313 if (media_not_present(sdkp, &sshdr))
@@ -1270,6 +1382,8 @@ repeat:
1270 1382
1271 sector_size = (buffer[8] << 24) | 1383 sector_size = (buffer[8] << 24) |
1272 (buffer[9] << 16) | (buffer[10] << 8) | buffer[11]; 1384 (buffer[9] << 16) | (buffer[10] << 8) | buffer[11];
1385
1386 sd_read_protection_type(sdkp, buffer);
1273 } 1387 }
1274 1388
1275 /* Some devices return the total number of sectors, not the 1389 /* Some devices return the total number of sectors, not the
@@ -1531,6 +1645,52 @@ defaults:
1531 sdkp->DPOFUA = 0; 1645 sdkp->DPOFUA = 0;
1532} 1646}
1533 1647
1648/*
1649 * The ATO bit indicates whether the DIF application tag is available
1650 * for use by the operating system.
1651 */
1652void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
1653{
1654 int res, offset;
1655 struct scsi_device *sdp = sdkp->device;
1656 struct scsi_mode_data data;
1657 struct scsi_sense_hdr sshdr;
1658
1659 if (sdp->type != TYPE_DISK)
1660 return;
1661
1662 if (sdkp->protection_type == 0)
1663 return;
1664
1665 res = scsi_mode_sense(sdp, 1, 0x0a, buffer, 36, SD_TIMEOUT,
1666 SD_MAX_RETRIES, &data, &sshdr);
1667
1668 if (!scsi_status_is_good(res) || !data.header_length ||
1669 data.length < 6) {
1670 sd_printk(KERN_WARNING, sdkp,
1671 "getting Control mode page failed, assume no ATO\n");
1672
1673 if (scsi_sense_valid(&sshdr))
1674 sd_print_sense_hdr(sdkp, &sshdr);
1675
1676 return;
1677 }
1678
1679 offset = data.header_length + data.block_descriptor_length;
1680
1681 if ((buffer[offset] & 0x3f) != 0x0a) {
1682 sd_printk(KERN_ERR, sdkp, "ATO Got wrong page\n");
1683 return;
1684 }
1685
1686 if ((buffer[offset + 5] & 0x80) == 0)
1687 return;
1688
1689 sdkp->ATO = 1;
1690
1691 return;
1692}
1693
1534/** 1694/**
1535 * sd_revalidate_disk - called the first time a new disk is seen, 1695 * sd_revalidate_disk - called the first time a new disk is seen,
1536 * performs disk spin up, read_capacity, etc. 1696 * performs disk spin up, read_capacity, etc.
@@ -1567,6 +1727,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
1567 sdkp->write_prot = 0; 1727 sdkp->write_prot = 0;
1568 sdkp->WCE = 0; 1728 sdkp->WCE = 0;
1569 sdkp->RCD = 0; 1729 sdkp->RCD = 0;
1730 sdkp->ATO = 0;
1570 1731
1571 sd_spinup_disk(sdkp); 1732 sd_spinup_disk(sdkp);
1572 1733
@@ -1578,6 +1739,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
1578 sd_read_capacity(sdkp, buffer); 1739 sd_read_capacity(sdkp, buffer);
1579 sd_read_write_protect_flag(sdkp, buffer); 1740 sd_read_write_protect_flag(sdkp, buffer);
1580 sd_read_cache_type(sdkp, buffer); 1741 sd_read_cache_type(sdkp, buffer);
1742 sd_read_app_tag_own(sdkp, buffer);
1581 } 1743 }
1582 1744
1583 /* 1745 /*
@@ -1643,18 +1805,20 @@ static int sd_probe(struct device *dev)
1643 if (!gd) 1805 if (!gd)
1644 goto out_free; 1806 goto out_free;
1645 1807
1646 if (!idr_pre_get(&sd_index_idr, GFP_KERNEL)) 1808 do {
1647 goto out_put; 1809 if (!ida_pre_get(&sd_index_ida, GFP_KERNEL))
1810 goto out_put;
1648 1811
1649 spin_lock(&sd_index_lock); 1812 error = ida_get_new(&sd_index_ida, &index);
1650 error = idr_get_new(&sd_index_idr, NULL, &index); 1813 } while (error == -EAGAIN);
1651 spin_unlock(&sd_index_lock);
1652 1814
1653 if (index >= SD_MAX_DISKS)
1654 error = -EBUSY;
1655 if (error) 1815 if (error)
1656 goto out_put; 1816 goto out_put;
1657 1817
1818 error = -EBUSY;
1819 if (index >= SD_MAX_DISKS)
1820 goto out_free_index;
1821
1658 sdkp->device = sdp; 1822 sdkp->device = sdp;
1659 sdkp->driver = &sd_template; 1823 sdkp->driver = &sd_template;
1660 sdkp->disk = gd; 1824 sdkp->disk = gd;
@@ -1675,7 +1839,7 @@ static int sd_probe(struct device *dev)
1675 strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE); 1839 strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE);
1676 1840
1677 if (device_add(&sdkp->dev)) 1841 if (device_add(&sdkp->dev))
1678 goto out_put; 1842 goto out_free_index;
1679 1843
1680 get_device(&sdp->sdev_gendev); 1844 get_device(&sdp->sdev_gendev);
1681 1845
@@ -1711,12 +1875,15 @@ static int sd_probe(struct device *dev)
1711 1875
1712 dev_set_drvdata(dev, sdkp); 1876 dev_set_drvdata(dev, sdkp);
1713 add_disk(gd); 1877 add_disk(gd);
1878 sd_dif_config_host(sdkp);
1714 1879
1715 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", 1880 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
1716 sdp->removable ? "removable " : ""); 1881 sdp->removable ? "removable " : "");
1717 1882
1718 return 0; 1883 return 0;
1719 1884
1885 out_free_index:
1886 ida_remove(&sd_index_ida, index);
1720 out_put: 1887 out_put:
1721 put_disk(gd); 1888 put_disk(gd);
1722 out_free: 1889 out_free:
@@ -1766,9 +1933,7 @@ static void scsi_disk_release(struct device *dev)
1766 struct scsi_disk *sdkp = to_scsi_disk(dev); 1933 struct scsi_disk *sdkp = to_scsi_disk(dev);
1767 struct gendisk *disk = sdkp->disk; 1934 struct gendisk *disk = sdkp->disk;
1768 1935
1769 spin_lock(&sd_index_lock); 1936 ida_remove(&sd_index_ida, sdkp->index);
1770 idr_remove(&sd_index_idr, sdkp->index);
1771 spin_unlock(&sd_index_lock);
1772 1937
1773 disk->private_data = NULL; 1938 disk->private_data = NULL;
1774 put_disk(disk); 1939 put_disk(disk);
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 03a3d45cfa42..95b9f06534d5 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -31,6 +31,12 @@
31 */ 31 */
32#define SD_BUF_SIZE 512 32#define SD_BUF_SIZE 512
33 33
34/*
35 * Number of sectors at the end of the device to avoid multi-sector
36 * accesses to in the case of last_sector_bug
37 */
38#define SD_LAST_BUGGY_SECTORS 8
39
34struct scsi_disk { 40struct scsi_disk {
35 struct scsi_driver *driver; /* always &sd_template */ 41 struct scsi_driver *driver; /* always &sd_template */
36 struct scsi_device *device; 42 struct scsi_device *device;
@@ -41,7 +47,9 @@ struct scsi_disk {
41 u32 index; 47 u32 index;
42 u8 media_present; 48 u8 media_present;
43 u8 write_prot; 49 u8 write_prot;
50 u8 protection_type;/* Data Integrity Field */
44 unsigned previous_state : 1; 51 unsigned previous_state : 1;
52 unsigned ATO : 1; /* state of disk ATO bit */
45 unsigned WCE : 1; /* state of disk WCE bit */ 53 unsigned WCE : 1; /* state of disk WCE bit */
46 unsigned RCD : 1; /* state of disk RCD bit, unused */ 54 unsigned RCD : 1; /* state of disk RCD bit, unused */
47 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 55 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
@@ -59,4 +67,50 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
59 (sdsk)->disk->disk_name, ##a) : \ 67 (sdsk)->disk->disk_name, ##a) : \
60 sdev_printk(prefix, (sdsk)->device, fmt, ##a) 68 sdev_printk(prefix, (sdsk)->device, fmt, ##a)
61 69
70/*
71 * A DIF-capable target device can be formatted with different
72 * protection schemes. Currently 0 through 3 are defined:
73 *
74 * Type 0 is regular (unprotected) I/O
75 *
76 * Type 1 defines the contents of the guard and reference tags
77 *
78 * Type 2 defines the contents of the guard and reference tags and
79 * uses 32-byte commands to seed the latter
80 *
81 * Type 3 defines the contents of the guard tag only
82 */
83
84enum sd_dif_target_protection_types {
85 SD_DIF_TYPE0_PROTECTION = 0x0,
86 SD_DIF_TYPE1_PROTECTION = 0x1,
87 SD_DIF_TYPE2_PROTECTION = 0x2,
88 SD_DIF_TYPE3_PROTECTION = 0x3,
89};
90
91/*
92 * Data Integrity Field tuple.
93 */
94struct sd_dif_tuple {
95 __be16 guard_tag; /* Checksum */
96 __be16 app_tag; /* Opaque storage */
97 __be32 ref_tag; /* Target LBA or indirect LBA */
98};
99
100#if defined(CONFIG_BLK_DEV_INTEGRITY)
101
102extern void sd_dif_op(struct scsi_cmnd *, unsigned int, unsigned int);
103extern void sd_dif_config_host(struct scsi_disk *);
104extern int sd_dif_prepare(struct request *rq, sector_t, unsigned int);
105extern void sd_dif_complete(struct scsi_cmnd *, unsigned int);
106
107#else /* CONFIG_BLK_DEV_INTEGRITY */
108
109#define sd_dif_op(a, b, c) do { } while (0)
110#define sd_dif_config_host(a) do { } while (0)
111#define sd_dif_prepare(a, b, c) (0)
112#define sd_dif_complete(a, b) (0)
113
114#endif /* CONFIG_BLK_DEV_INTEGRITY */
115
62#endif /* _SCSI_DISK_H */ 116#endif /* _SCSI_DISK_H */
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
new file mode 100644
index 000000000000..4d17f3d35aac
--- /dev/null
+++ b/drivers/scsi/sd_dif.c
@@ -0,0 +1,538 @@
1/*
2 * sd_dif.c - SCSI Data Integrity Field
3 *
4 * Copyright (C) 2007, 2008 Oracle Corporation
5 * Written by: Martin K. Petersen <martin.petersen@oracle.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
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. See the GNU
14 * 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; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA.
20 *
21 */
22
23#include <linux/blkdev.h>
24#include <linux/crc-t10dif.h>
25
26#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_dbg.h>
29#include <scsi/scsi_device.h>
30#include <scsi/scsi_driver.h>
31#include <scsi/scsi_eh.h>
32#include <scsi/scsi_host.h>
33#include <scsi/scsi_ioctl.h>
34#include <scsi/scsicam.h>
35
36#include <net/checksum.h>
37
38#include "sd.h"
39
40typedef __u16 (csum_fn) (void *, unsigned int);
41
42static __u16 sd_dif_crc_fn(void *data, unsigned int len)
43{
44 return cpu_to_be16(crc_t10dif(data, len));
45}
46
47static __u16 sd_dif_ip_fn(void *data, unsigned int len)
48{
49 return ip_compute_csum(data, len);
50}
51
52/*
53 * Type 1 and Type 2 protection use the same format: 16 bit guard tag,
54 * 16 bit app tag, 32 bit reference tag.
55 */
56static void sd_dif_type1_generate(struct blk_integrity_exchg *bix, csum_fn *fn)
57{
58 void *buf = bix->data_buf;
59 struct sd_dif_tuple *sdt = bix->prot_buf;
60 sector_t sector = bix->sector;
61 unsigned int i;
62
63 for (i = 0 ; i < bix->data_size ; i += bix->sector_size, sdt++) {
64 sdt->guard_tag = fn(buf, bix->sector_size);
65 sdt->ref_tag = cpu_to_be32(sector & 0xffffffff);
66 sdt->app_tag = 0;
67
68 buf += bix->sector_size;
69 sector++;
70 }
71}
72
73static void sd_dif_type1_generate_crc(struct blk_integrity_exchg *bix)
74{
75 sd_dif_type1_generate(bix, sd_dif_crc_fn);
76}
77
78static void sd_dif_type1_generate_ip(struct blk_integrity_exchg *bix)
79{
80 sd_dif_type1_generate(bix, sd_dif_ip_fn);
81}
82
83static int sd_dif_type1_verify(struct blk_integrity_exchg *bix, csum_fn *fn)
84{
85 void *buf = bix->data_buf;
86 struct sd_dif_tuple *sdt = bix->prot_buf;
87 sector_t sector = bix->sector;
88 unsigned int i;
89 __u16 csum;
90
91 for (i = 0 ; i < bix->data_size ; i += bix->sector_size, sdt++) {
92 /* Unwritten sectors */
93 if (sdt->app_tag == 0xffff)
94 return 0;
95
96 /* Bad ref tag received from disk */
97 if (sdt->ref_tag == 0xffffffff) {
98 printk(KERN_ERR
99 "%s: bad phys ref tag on sector %lu\n",
100 bix->disk_name, (unsigned long)sector);
101 return -EIO;
102 }
103
104 if (be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) {
105 printk(KERN_ERR
106 "%s: ref tag error on sector %lu (rcvd %u)\n",
107 bix->disk_name, (unsigned long)sector,
108 be32_to_cpu(sdt->ref_tag));
109 return -EIO;
110 }
111
112 csum = fn(buf, bix->sector_size);
113
114 if (sdt->guard_tag != csum) {
115 printk(KERN_ERR "%s: guard tag error on sector %lu " \
116 "(rcvd %04x, data %04x)\n", bix->disk_name,
117 (unsigned long)sector,
118 be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum));
119 return -EIO;
120 }
121
122 buf += bix->sector_size;
123 sector++;
124 }
125
126 return 0;
127}
128
129static int sd_dif_type1_verify_crc(struct blk_integrity_exchg *bix)
130{
131 return sd_dif_type1_verify(bix, sd_dif_crc_fn);
132}
133
134static int sd_dif_type1_verify_ip(struct blk_integrity_exchg *bix)
135{
136 return sd_dif_type1_verify(bix, sd_dif_ip_fn);
137}
138
139/*
140 * Functions for interleaving and deinterleaving application tags
141 */
142static void sd_dif_type1_set_tag(void *prot, void *tag_buf, unsigned int sectors)
143{
144 struct sd_dif_tuple *sdt = prot;
145 char *tag = tag_buf;
146 unsigned int i, j;
147
148 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
149 sdt->app_tag = tag[j] << 8 | tag[j+1];
150 BUG_ON(sdt->app_tag == 0xffff);
151 }
152}
153
154static void sd_dif_type1_get_tag(void *prot, void *tag_buf, unsigned int sectors)
155{
156 struct sd_dif_tuple *sdt = prot;
157 char *tag = tag_buf;
158 unsigned int i, j;
159
160 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
161 tag[j] = (sdt->app_tag & 0xff00) >> 8;
162 tag[j+1] = sdt->app_tag & 0xff;
163 }
164}
165
166static struct blk_integrity dif_type1_integrity_crc = {
167 .name = "T10-DIF-TYPE1-CRC",
168 .generate_fn = sd_dif_type1_generate_crc,
169 .verify_fn = sd_dif_type1_verify_crc,
170 .get_tag_fn = sd_dif_type1_get_tag,
171 .set_tag_fn = sd_dif_type1_set_tag,
172 .tuple_size = sizeof(struct sd_dif_tuple),
173 .tag_size = 0,
174};
175
176static struct blk_integrity dif_type1_integrity_ip = {
177 .name = "T10-DIF-TYPE1-IP",
178 .generate_fn = sd_dif_type1_generate_ip,
179 .verify_fn = sd_dif_type1_verify_ip,
180 .get_tag_fn = sd_dif_type1_get_tag,
181 .set_tag_fn = sd_dif_type1_set_tag,
182 .tuple_size = sizeof(struct sd_dif_tuple),
183 .tag_size = 0,
184};
185
186
187/*
188 * Type 3 protection has a 16-bit guard tag and 16 + 32 bits of opaque
189 * tag space.
190 */
191static void sd_dif_type3_generate(struct blk_integrity_exchg *bix, csum_fn *fn)
192{
193 void *buf = bix->data_buf;
194 struct sd_dif_tuple *sdt = bix->prot_buf;
195 unsigned int i;
196
197 for (i = 0 ; i < bix->data_size ; i += bix->sector_size, sdt++) {
198 sdt->guard_tag = fn(buf, bix->sector_size);
199 sdt->ref_tag = 0;
200 sdt->app_tag = 0;
201
202 buf += bix->sector_size;
203 }
204}
205
206static void sd_dif_type3_generate_crc(struct blk_integrity_exchg *bix)
207{
208 sd_dif_type3_generate(bix, sd_dif_crc_fn);
209}
210
211static void sd_dif_type3_generate_ip(struct blk_integrity_exchg *bix)
212{
213 sd_dif_type3_generate(bix, sd_dif_ip_fn);
214}
215
216static int sd_dif_type3_verify(struct blk_integrity_exchg *bix, csum_fn *fn)
217{
218 void *buf = bix->data_buf;
219 struct sd_dif_tuple *sdt = bix->prot_buf;
220 sector_t sector = bix->sector;
221 unsigned int i;
222 __u16 csum;
223
224 for (i = 0 ; i < bix->data_size ; i += bix->sector_size, sdt++) {
225 /* Unwritten sectors */
226 if (sdt->app_tag == 0xffff && sdt->ref_tag == 0xffffffff)
227 return 0;
228
229 csum = fn(buf, bix->sector_size);
230
231 if (sdt->guard_tag != csum) {
232 printk(KERN_ERR "%s: guard tag error on sector %lu " \
233 "(rcvd %04x, data %04x)\n", bix->disk_name,
234 (unsigned long)sector,
235 be16_to_cpu(sdt->guard_tag), be16_to_cpu(csum));
236 return -EIO;
237 }
238
239 buf += bix->sector_size;
240 sector++;
241 }
242
243 return 0;
244}
245
246static int sd_dif_type3_verify_crc(struct blk_integrity_exchg *bix)
247{
248 return sd_dif_type3_verify(bix, sd_dif_crc_fn);
249}
250
251static int sd_dif_type3_verify_ip(struct blk_integrity_exchg *bix)
252{
253 return sd_dif_type3_verify(bix, sd_dif_ip_fn);
254}
255
256static void sd_dif_type3_set_tag(void *prot, void *tag_buf, unsigned int sectors)
257{
258 struct sd_dif_tuple *sdt = prot;
259 char *tag = tag_buf;
260 unsigned int i, j;
261
262 for (i = 0, j = 0 ; i < sectors ; i++, j += 6, sdt++) {
263 sdt->app_tag = tag[j] << 8 | tag[j+1];
264 sdt->ref_tag = tag[j+2] << 24 | tag[j+3] << 16 |
265 tag[j+4] << 8 | tag[j+5];
266 }
267}
268
269static void sd_dif_type3_get_tag(void *prot, void *tag_buf, unsigned int sectors)
270{
271 struct sd_dif_tuple *sdt = prot;
272 char *tag = tag_buf;
273 unsigned int i, j;
274
275 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
276 tag[j] = (sdt->app_tag & 0xff00) >> 8;
277 tag[j+1] = sdt->app_tag & 0xff;
278 tag[j+2] = (sdt->ref_tag & 0xff000000) >> 24;
279 tag[j+3] = (sdt->ref_tag & 0xff0000) >> 16;
280 tag[j+4] = (sdt->ref_tag & 0xff00) >> 8;
281 tag[j+5] = sdt->ref_tag & 0xff;
282 BUG_ON(sdt->app_tag == 0xffff || sdt->ref_tag == 0xffffffff);
283 }
284}
285
286static struct blk_integrity dif_type3_integrity_crc = {
287 .name = "T10-DIF-TYPE3-CRC",
288 .generate_fn = sd_dif_type3_generate_crc,
289 .verify_fn = sd_dif_type3_verify_crc,
290 .get_tag_fn = sd_dif_type3_get_tag,
291 .set_tag_fn = sd_dif_type3_set_tag,
292 .tuple_size = sizeof(struct sd_dif_tuple),
293 .tag_size = 0,
294};
295
296static struct blk_integrity dif_type3_integrity_ip = {
297 .name = "T10-DIF-TYPE3-IP",
298 .generate_fn = sd_dif_type3_generate_ip,
299 .verify_fn = sd_dif_type3_verify_ip,
300 .get_tag_fn = sd_dif_type3_get_tag,
301 .set_tag_fn = sd_dif_type3_set_tag,
302 .tuple_size = sizeof(struct sd_dif_tuple),
303 .tag_size = 0,
304};
305
306/*
307 * Configure exchange of protection information between OS and HBA.
308 */
309void sd_dif_config_host(struct scsi_disk *sdkp)
310{
311 struct scsi_device *sdp = sdkp->device;
312 struct gendisk *disk = sdkp->disk;
313 u8 type = sdkp->protection_type;
314
315 /* If this HBA doesn't support DIX, resort to normal I/O or DIF */
316 if (scsi_host_dix_capable(sdp->host, type) == 0) {
317
318 if (type == SD_DIF_TYPE0_PROTECTION)
319 return;
320
321 if (scsi_host_dif_capable(sdp->host, type) == 0) {
322 sd_printk(KERN_INFO, sdkp, "Type %d protection " \
323 "unsupported by HBA. Disabling DIF.\n", type);
324 sdkp->protection_type = 0;
325 return;
326 }
327
328 sd_printk(KERN_INFO, sdkp, "Enabling DIF Type %d protection\n",
329 type);
330
331 return;
332 }
333
334 /* Enable DMA of protection information */
335 if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP)
336 if (type == SD_DIF_TYPE3_PROTECTION)
337 blk_integrity_register(disk, &dif_type3_integrity_ip);
338 else
339 blk_integrity_register(disk, &dif_type1_integrity_ip);
340 else
341 if (type == SD_DIF_TYPE3_PROTECTION)
342 blk_integrity_register(disk, &dif_type3_integrity_crc);
343 else
344 blk_integrity_register(disk, &dif_type1_integrity_crc);
345
346 sd_printk(KERN_INFO, sdkp,
347 "Enabling %s integrity protection\n", disk->integrity->name);
348
349 /* Signal to block layer that we support sector tagging */
350 if (type && sdkp->ATO) {
351 if (type == SD_DIF_TYPE3_PROTECTION)
352 disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
353 else
354 disk->integrity->tag_size = sizeof(u16);
355
356 sd_printk(KERN_INFO, sdkp, "DIF application tag size %u\n",
357 disk->integrity->tag_size);
358 }
359}
360
361/*
362 * DIF DMA operation magic decoder ring.
363 */
364void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix)
365{
366 int csum_convert, prot_op;
367
368 prot_op = 0;
369
370 /* Convert checksum? */
371 if (scsi_host_get_guard(scmd->device->host) != SHOST_DIX_GUARD_CRC)
372 csum_convert = 1;
373 else
374 csum_convert = 0;
375
376 switch (scmd->cmnd[0]) {
377 case READ_10:
378 case READ_12:
379 case READ_16:
380 if (dif && dix)
381 if (csum_convert)
382 prot_op = SCSI_PROT_READ_CONVERT;
383 else
384 prot_op = SCSI_PROT_READ_PASS;
385 else if (dif && !dix)
386 prot_op = SCSI_PROT_READ_STRIP;
387 else if (!dif && dix)
388 prot_op = SCSI_PROT_READ_INSERT;
389
390 break;
391
392 case WRITE_10:
393 case WRITE_12:
394 case WRITE_16:
395 if (dif && dix)
396 if (csum_convert)
397 prot_op = SCSI_PROT_WRITE_CONVERT;
398 else
399 prot_op = SCSI_PROT_WRITE_PASS;
400 else if (dif && !dix)
401 prot_op = SCSI_PROT_WRITE_INSERT;
402 else if (!dif && dix)
403 prot_op = SCSI_PROT_WRITE_STRIP;
404
405 break;
406 }
407
408 scsi_set_prot_op(scmd, prot_op);
409 scsi_set_prot_type(scmd, dif);
410}
411
412/*
413 * The virtual start sector is the one that was originally submitted
414 * by the block layer. Due to partitioning, MD/DM cloning, etc. the
415 * actual physical start sector is likely to be different. Remap
416 * protection information to match the physical LBA.
417 *
418 * From a protocol perspective there's a slight difference between
419 * Type 1 and 2. The latter uses 32-byte CDBs exclusively, and the
420 * reference tag is seeded in the CDB. This gives us the potential to
421 * avoid virt->phys remapping during write. However, at read time we
422 * don't know whether the virt sector is the same as when we wrote it
423 * (we could be reading from real disk as opposed to MD/DM device. So
424 * we always remap Type 2 making it identical to Type 1.
425 *
426 * Type 3 does not have a reference tag so no remapping is required.
427 */
428int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_sz)
429{
430 const int tuple_sz = sizeof(struct sd_dif_tuple);
431 struct bio *bio;
432 struct scsi_disk *sdkp;
433 struct sd_dif_tuple *sdt;
434 unsigned int i, j;
435 u32 phys, virt;
436
437 /* Already remapped? */
438 if (rq->cmd_flags & REQ_INTEGRITY)
439 return 0;
440
441 sdkp = rq->bio->bi_bdev->bd_disk->private_data;
442
443 if (sdkp->protection_type == SD_DIF_TYPE3_PROTECTION)
444 return 0;
445
446 rq->cmd_flags |= REQ_INTEGRITY;
447 phys = hw_sector & 0xffffffff;
448
449 __rq_for_each_bio(bio, rq) {
450 struct bio_vec *iv;
451
452 virt = bio->bi_integrity->bip_sector & 0xffffffff;
453
454 bip_for_each_vec(iv, bio->bi_integrity, i) {
455 sdt = kmap_atomic(iv->bv_page, KM_USER0)
456 + iv->bv_offset;
457
458 for (j = 0 ; j < iv->bv_len ; j += tuple_sz, sdt++) {
459
460 if (be32_to_cpu(sdt->ref_tag) != virt)
461 goto error;
462
463 sdt->ref_tag = cpu_to_be32(phys);
464 virt++;
465 phys++;
466 }
467
468 kunmap_atomic(sdt, KM_USER0);
469 }
470 }
471
472 return 0;
473
474error:
475 kunmap_atomic(sdt, KM_USER0);
476 sd_printk(KERN_ERR, sdkp, "%s: virt %u, phys %u, ref %u\n",
477 __func__, virt, phys, be32_to_cpu(sdt->ref_tag));
478
479 return -EIO;
480}
481
482/*
483 * Remap physical sector values in the reference tag to the virtual
484 * values expected by the block layer.
485 */
486void sd_dif_complete(struct scsi_cmnd *scmd, unsigned int good_bytes)
487{
488 const int tuple_sz = sizeof(struct sd_dif_tuple);
489 struct scsi_disk *sdkp;
490 struct bio *bio;
491 struct sd_dif_tuple *sdt;
492 unsigned int i, j, sectors, sector_sz;
493 u32 phys, virt;
494
495 sdkp = scsi_disk(scmd->request->rq_disk);
496
497 if (sdkp->protection_type == SD_DIF_TYPE3_PROTECTION || good_bytes == 0)
498 return;
499
500 sector_sz = scmd->device->sector_size;
501 sectors = good_bytes / sector_sz;
502
503 phys = scmd->request->sector & 0xffffffff;
504 if (sector_sz == 4096)
505 phys >>= 3;
506
507 __rq_for_each_bio(bio, scmd->request) {
508 struct bio_vec *iv;
509
510 virt = bio->bi_integrity->bip_sector & 0xffffffff;
511
512 bip_for_each_vec(iv, bio->bi_integrity, i) {
513 sdt = kmap_atomic(iv->bv_page, KM_USER0)
514 + iv->bv_offset;
515
516 for (j = 0 ; j < iv->bv_len ; j += tuple_sz, sdt++) {
517
518 if (sectors == 0) {
519 kunmap_atomic(sdt, KM_USER0);
520 return;
521 }
522
523 if (be32_to_cpu(sdt->ref_tag) != phys &&
524 sdt->app_tag != 0xffff)
525 sdt->ref_tag = 0xffffffff; /* Bad ref */
526 else
527 sdt->ref_tag = cpu_to_be32(virt);
528
529 virt++;
530 phys++;
531 sectors--;
532 }
533
534 kunmap_atomic(sdt, KM_USER0);
535 }
536 }
537}
538
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 4684cc716aa4..c2bb53e3d941 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -17,7 +17,7 @@
17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 */ 18 */
19 19
20static const char *verstr = "20080224"; 20static const char *verstr = "20080504";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23 23
@@ -631,7 +631,7 @@ static int cross_eof(struct scsi_tape * STp, int forward)
631/* Flush the write buffer (never need to write if variable blocksize). */ 631/* Flush the write buffer (never need to write if variable blocksize). */
632static int st_flush_write_buffer(struct scsi_tape * STp) 632static int st_flush_write_buffer(struct scsi_tape * STp)
633{ 633{
634 int offset, transfer, blks; 634 int transfer, blks;
635 int result; 635 int result;
636 unsigned char cmd[MAX_COMMAND_SIZE]; 636 unsigned char cmd[MAX_COMMAND_SIZE];
637 struct st_request *SRpnt; 637 struct st_request *SRpnt;
@@ -644,14 +644,10 @@ static int st_flush_write_buffer(struct scsi_tape * STp)
644 result = 0; 644 result = 0;
645 if (STp->dirty == 1) { 645 if (STp->dirty == 1) {
646 646
647 offset = (STp->buffer)->buffer_bytes; 647 transfer = STp->buffer->buffer_bytes;
648 transfer = ((offset + STp->block_size - 1) /
649 STp->block_size) * STp->block_size;
650 DEBC(printk(ST_DEB_MSG "%s: Flushing %d bytes.\n", 648 DEBC(printk(ST_DEB_MSG "%s: Flushing %d bytes.\n",
651 tape_name(STp), transfer)); 649 tape_name(STp), transfer));
652 650
653 memset((STp->buffer)->b_data + offset, 0, transfer - offset);
654
655 memset(cmd, 0, MAX_COMMAND_SIZE); 651 memset(cmd, 0, MAX_COMMAND_SIZE);
656 cmd[0] = WRITE_6; 652 cmd[0] = WRITE_6;
657 cmd[1] = 1; 653 cmd[1] = 1;
@@ -1670,6 +1666,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1670 if (undone <= do_count) { 1666 if (undone <= do_count) {
1671 /* Only data from this write is not written */ 1667 /* Only data from this write is not written */
1672 count += undone; 1668 count += undone;
1669 b_point -= undone;
1673 do_count -= undone; 1670 do_count -= undone;
1674 if (STp->block_size) 1671 if (STp->block_size)
1675 blks = (transfer - undone) / STp->block_size; 1672 blks = (transfer - undone) / STp->block_size;
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index f308a0308829..3790906a77d1 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -467,7 +467,7 @@ stex_slave_alloc(struct scsi_device *sdev)
467 /* Cheat: usually extracted from Inquiry data */ 467 /* Cheat: usually extracted from Inquiry data */
468 sdev->tagged_supported = 1; 468 sdev->tagged_supported = 1;
469 469
470 scsi_activate_tcq(sdev, sdev->host->can_queue); 470 scsi_activate_tcq(sdev, ST_CMD_PER_LUN);
471 471
472 return 0; 472 return 0;
473} 473}
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 22a6aae78699..98df1651404f 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -5741,6 +5741,8 @@ void sym_hcb_free(struct sym_hcb *np)
5741 5741
5742 for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { 5742 for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) {
5743 tp = &np->target[target]; 5743 tp = &np->target[target];
5744 if (tp->luntbl)
5745 sym_mfree_dma(tp->luntbl, 256, "LUNTBL");
5744#if SYM_CONF_MAX_LUN > 1 5746#if SYM_CONF_MAX_LUN > 1
5745 kfree(tp->lunmp); 5747 kfree(tp->lunmp);
5746#endif 5748#endif
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 5b04ddfed26c..1723d71cbf3f 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -452,7 +452,7 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
452 /* TODO: error handling */ 452 /* TODO: error handling */
453 if (pSRB->SGcount != 1) 453 if (pSRB->SGcount != 1)
454 error = 1; 454 error = 1;
455 DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle)); 455 DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __func__, pcmd->sense_buffer, cmdp->saved_dma_handle));
456 /* Map SG list */ 456 /* Map SG list */
457 } else if (scsi_sg_count(pcmd)) { 457 } else if (scsi_sg_count(pcmd)) {
458 int nseg; 458 int nseg;
@@ -466,7 +466,7 @@ static int dc390_pci_map (struct dc390_srb* pSRB)
466 if (nseg < 0) 466 if (nseg < 0)
467 error = 1; 467 error = 1;
468 DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\ 468 DEBUG1(printk("%s(): Mapped SG %p with %d (%d) elements\n",\
469 __FUNCTION__, scsi_sglist(pcmd), nseg, scsi_sg_count(pcmd))); 469 __func__, scsi_sglist(pcmd), nseg, scsi_sg_count(pcmd)));
470 /* Map single segment */ 470 /* Map single segment */
471 } else 471 } else
472 pSRB->SGcount = 0; 472 pSRB->SGcount = 0;
@@ -483,11 +483,11 @@ static void dc390_pci_unmap (struct dc390_srb* pSRB)
483 483
484 if (pSRB->SRBFlag) { 484 if (pSRB->SRBFlag) {
485 pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE); 485 pci_unmap_sg(pdev, &pSRB->Segmentx, 1, DMA_FROM_DEVICE);
486 DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __FUNCTION__, cmdp->saved_dma_handle)); 486 DEBUG1(printk("%s(): Unmapped sense buffer at %x\n", __func__, cmdp->saved_dma_handle));
487 } else { 487 } else {
488 scsi_dma_unmap(pcmd); 488 scsi_dma_unmap(pcmd);
489 DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n", 489 DEBUG1(printk("%s(): Unmapped SG at %p with %d elements\n",
490 __FUNCTION__, scsi_sglist(pcmd), scsi_sg_count(pcmd))); 490 __func__, scsi_sglist(pcmd), scsi_sg_count(pcmd)));
491 } 491 }
492} 492}
493 493
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index c975c01b3a02..d4c13561f4a6 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -148,7 +148,7 @@
148 * 148 *
149 * 2002/10/04 - Alan Cox <alan@redhat.com> 149 * 2002/10/04 - Alan Cox <alan@redhat.com>
150 * 150 *
151 * Use dev_id for interrupts, kill __FUNCTION__ pasting 151 * Use dev_id for interrupts, kill __func__ pasting
152 * Add a lock for the scb pool, clean up all other cli/sti usage stuff 152 * Add a lock for the scb pool, clean up all other cli/sti usage stuff
153 * Use the adapter lock for the other places we had the cli's 153 * Use the adapter lock for the other places we had the cli's
154 * 154 *
@@ -640,12 +640,12 @@ static int __init wd7000_setup(char *str)
640 (void) get_options(str, ARRAY_SIZE(ints), ints); 640 (void) get_options(str, ARRAY_SIZE(ints), ints);
641 641
642 if (wd7000_card_num >= NUM_CONFIGS) { 642 if (wd7000_card_num >= NUM_CONFIGS) {
643 printk(KERN_ERR "%s: Too many \"wd7000=\" configurations in " "command line!\n", __FUNCTION__); 643 printk(KERN_ERR "%s: Too many \"wd7000=\" configurations in " "command line!\n", __func__);
644 return 0; 644 return 0;
645 } 645 }
646 646
647 if ((ints[0] < 3) || (ints[0] > 5)) { 647 if ((ints[0] < 3) || (ints[0] > 5)) {
648 printk(KERN_ERR "%s: Error in command line! " "Usage: wd7000=<IRQ>,<DMA>,IO>[,<BUS_ON>" "[,<BUS_OFF>]]\n", __FUNCTION__); 648 printk(KERN_ERR "%s: Error in command line! " "Usage: wd7000=<IRQ>,<DMA>,IO>[,<BUS_ON>" "[,<BUS_OFF>]]\n", __func__);
649 } else { 649 } else {
650 for (i = 0; i < NUM_IRQS; i++) 650 for (i = 0; i < NUM_IRQS; i++)
651 if (ints[1] == wd7000_irq[i]) 651 if (ints[1] == wd7000_irq[i])
@@ -1642,7 +1642,7 @@ static int wd7000_biosparam(struct scsi_device *sdev,
1642 ip[2] = info[2]; 1642 ip[2] = info[2];
1643 1643
1644 if (info[0] == 255) 1644 if (info[0] == 255)
1645 printk(KERN_INFO "%s: current partition table is " "using extended translation.\n", __FUNCTION__); 1645 printk(KERN_INFO "%s: current partition table is " "using extended translation.\n", __func__);
1646 } 1646 }
1647 } 1647 }
1648 1648
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
index 4b5f908d35c3..3c4a300494a4 100644
--- a/drivers/scsi/zalon.c
+++ b/drivers/scsi/zalon.c
@@ -68,11 +68,11 @@ lasi_scsi_clock(void * hpa, int defaultclock)
68 if (status == PDC_RET_OK) { 68 if (status == PDC_RET_OK) {
69 clock = (int) pdc_result[16]; 69 clock = (int) pdc_result[16];
70 } else { 70 } else {
71 printk(KERN_WARNING "%s: pdc_iodc_read returned %d\n", __FUNCTION__, status); 71 printk(KERN_WARNING "%s: pdc_iodc_read returned %d\n", __func__, status);
72 clock = defaultclock; 72 clock = defaultclock;
73 } 73 }
74 74
75 printk(KERN_DEBUG "%s: SCSI clock %d\n", __FUNCTION__, clock); 75 printk(KERN_DEBUG "%s: SCSI clock %d\n", __func__, clock);
76 return clock; 76 return clock;
77} 77}
78#endif 78#endif
@@ -108,13 +108,13 @@ zalon_probe(struct parisc_device *dev)
108 */ 108 */
109 dev->irq = gsc_alloc_irq(&gsc_irq); 109 dev->irq = gsc_alloc_irq(&gsc_irq);
110 110
111 printk(KERN_INFO "%s: Zalon version %d, IRQ %d\n", __FUNCTION__, 111 printk(KERN_INFO "%s: Zalon version %d, IRQ %d\n", __func__,
112 zalon_vers, dev->irq); 112 zalon_vers, dev->irq);
113 113
114 __raw_writel(gsc_irq.txn_addr | gsc_irq.txn_data, zalon + IO_MODULE_EIM); 114 __raw_writel(gsc_irq.txn_addr | gsc_irq.txn_data, zalon + IO_MODULE_EIM);
115 115
116 if (zalon_vers == 0) 116 if (zalon_vers == 0)
117 printk(KERN_WARNING "%s: Zalon 1.1 or earlier\n", __FUNCTION__); 117 printk(KERN_WARNING "%s: Zalon 1.1 or earlier\n", __func__);
118 118
119 memset(&device, 0, sizeof(struct ncr_device)); 119 memset(&device, 0, sizeof(struct ncr_device));
120 120
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 208e42ba9455..3df2aaec829f 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -410,7 +410,6 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
410#endif 410#endif
411 411
412#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ 412#if defined(CONFIG_CPU_SUBTYPE_SH7760) || \
413 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
414 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 413 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
415 defined(CONFIG_CPU_SUBTYPE_SH7785) 414 defined(CONFIG_CPU_SUBTYPE_SH7785)
416static inline int scif_txroom(struct uart_port *port) 415static inline int scif_txroom(struct uart_port *port)
@@ -422,6 +421,22 @@ static inline int scif_rxroom(struct uart_port *port)
422{ 421{
423 return sci_in(port, SCRFDR) & 0xff; 422 return sci_in(port, SCRFDR) & 0xff;
424} 423}
424#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
425static inline int scif_txroom(struct uart_port *port)
426{
427 if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
428 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
429 else /* SCIF2 */
430 return SCIF2_TXROOM_MAX - (sci_in(port, SCFDR) >> 8);
431}
432
433static inline int scif_rxroom(struct uart_port *port)
434{
435 if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
436 return sci_in(port, SCRFDR) & 0xff;
437 else /* SCIF2 */
438 return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
439}
425#else 440#else
426static inline int scif_txroom(struct uart_port *port) 441static inline int scif_txroom(struct uart_port *port)
427{ 442{
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index eb84833233fd..cd728df6a01a 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -123,8 +123,9 @@
123#elif defined(CONFIG_CPU_SUBTYPE_SH7763) 123#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
124# define SCSPTR0 0xffe00024 /* 16 bit SCIF */ 124# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
125# define SCSPTR1 0xffe08024 /* 16 bit SCIF */ 125# define SCSPTR1 0xffe08024 /* 16 bit SCIF */
126# define SCSPTR2 0xffe10020 /* 16 bit SCIF/IRDA */
126# define SCIF_ORER 0x0001 /* overrun error bit */ 127# define SCIF_ORER 0x0001 /* overrun error bit */
127# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 128# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
128# define SCIF_ONLY 129# define SCIF_ONLY
129#elif defined(CONFIG_CPU_SUBTYPE_SH7770) 130#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
130# define SCSPTR0 0xff923020 /* 16 bit SCIF */ 131# define SCSPTR0 0xff923020 /* 16 bit SCIF */
@@ -188,6 +189,7 @@
188 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \ 189 defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
189 defined(CONFIG_CPU_SUBTYPE_SH7751) || \ 190 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
190 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \ 191 defined(CONFIG_CPU_SUBTYPE_SH7751R) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
191 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 193 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7785) || \ 194 defined(CONFIG_CPU_SUBTYPE_SH7785) || \
193 defined(CONFIG_CPU_SUBTYPE_SHX3) 195 defined(CONFIG_CPU_SUBTYPE_SHX3)
@@ -225,14 +227,21 @@
225#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 227#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
226 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 228 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
227 defined(CONFIG_CPU_SUBTYPE_SH7721) 229 defined(CONFIG_CPU_SUBTYPE_SH7721)
228#define SCIF_ORER 0x0200 230# define SCIF_ORER 0x0200
229#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) 231# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
230#define SCIF_RFDC_MASK 0x007f 232# define SCIF_RFDC_MASK 0x007f
231#define SCIF_TXROOM_MAX 64 233# define SCIF_TXROOM_MAX 64
234#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
235# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK )
236# define SCIF_RFDC_MASK 0x007f
237# define SCIF_TXROOM_MAX 64
238/* SH7763 SCIF2 support */
239# define SCIF2_RFDC_MASK 0x001f
240# define SCIF2_TXROOM_MAX 16
232#else 241#else
233#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK) 242# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
234#define SCIF_RFDC_MASK 0x001f 243# define SCIF_RFDC_MASK 0x001f
235#define SCIF_TXROOM_MAX 16 244# define SCIF_TXROOM_MAX 16
236#endif 245#endif
237 246
238#if defined(SCI_ONLY) 247#if defined(SCI_ONLY)
@@ -445,11 +454,16 @@ SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
445 defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 454 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
446 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 455 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
447 defined(CONFIG_CPU_SUBTYPE_SH7785) 456 defined(CONFIG_CPU_SUBTYPE_SH7785)
448SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
449SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 457SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
450SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 458SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
451SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 459SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
452SCIF_FNS(SCLSR, 0, 0, 0x28, 16) 460SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
461#if defined(CONFIG_CPU_SUBTYPE_SH7763)
462/* SH7763 SCIF2 */
463SCIF_FNS(SCFDR, 0, 0, 0x1C, 16)
464SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16)
465SCIF_FNS(SCLSR2, 0, 0, 0x24, 16)
466#endif /* CONFIG_CPU_SUBTYPE_SH7763 */
453#else 467#else
454SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 468SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
455#if defined(CONFIG_CPU_SUBTYPE_SH7722) 469#if defined(CONFIG_CPU_SUBTYPE_SH7722)
@@ -652,6 +666,9 @@ static inline int sci_rxd_in(struct uart_port *port)
652 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ 666 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
653 if (port->mapbase == 0xffe08000) 667 if (port->mapbase == 0xffe08000)
654 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 668 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
669 if (port->mapbase == 0xffe10000)
670 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */
671
655 return 1; 672 return 1;
656} 673}
657#elif defined(CONFIG_CPU_SUBTYPE_SH7770) 674#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
@@ -764,8 +781,7 @@ static inline int sci_rxd_in(struct uart_port *port)
764 * -- Mitch Davis - 15 Jul 2000 781 * -- Mitch Davis - 15 Jul 2000
765 */ 782 */
766 783
767#if defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 784#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
768 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
769 defined(CONFIG_CPU_SUBTYPE_SH7785) 785 defined(CONFIG_CPU_SUBTYPE_SH7785)
770#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) 786#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
771#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 787#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index e81d59d78910..0c7165660853 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -313,14 +313,14 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer)
313 xfer->tx_dma = dma_map_single(dev, 313 xfer->tx_dma = dma_map_single(dev,
314 (void *) xfer->tx_buf, xfer->len, 314 (void *) xfer->tx_buf, xfer->len,
315 DMA_TO_DEVICE); 315 DMA_TO_DEVICE);
316 if (dma_mapping_error(xfer->tx_dma)) 316 if (dma_mapping_error(dev, xfer->tx_dma))
317 return -ENOMEM; 317 return -ENOMEM;
318 } 318 }
319 if (xfer->rx_buf) { 319 if (xfer->rx_buf) {
320 xfer->rx_dma = dma_map_single(dev, 320 xfer->rx_dma = dma_map_single(dev,
321 xfer->rx_buf, xfer->len, 321 xfer->rx_buf, xfer->len,
322 DMA_FROM_DEVICE); 322 DMA_FROM_DEVICE);
323 if (dma_mapping_error(xfer->rx_dma)) { 323 if (dma_mapping_error(dev, xfer->rx_dma)) {
324 if (xfer->tx_buf) 324 if (xfer->tx_buf)
325 dma_unmap_single(dev, 325 dma_unmap_single(dev,
326 xfer->tx_dma, xfer->len, 326 xfer->tx_dma, xfer->len,
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 9149689c79d9..87b73e0169c5 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -334,7 +334,7 @@ static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size)
334 hw->dma_rx_tmpbuf_size = size; 334 hw->dma_rx_tmpbuf_size = size;
335 hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf, 335 hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf,
336 size, DMA_FROM_DEVICE); 336 size, DMA_FROM_DEVICE);
337 if (dma_mapping_error(hw->dma_rx_tmpbuf_addr)) { 337 if (dma_mapping_error(hw->dev, hw->dma_rx_tmpbuf_addr)) {
338 kfree(hw->dma_rx_tmpbuf); 338 kfree(hw->dma_rx_tmpbuf);
339 hw->dma_rx_tmpbuf = 0; 339 hw->dma_rx_tmpbuf = 0;
340 hw->dma_rx_tmpbuf_size = 0; 340 hw->dma_rx_tmpbuf_size = 0;
@@ -378,7 +378,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
378 dma_rx_addr = dma_map_single(hw->dev, 378 dma_rx_addr = dma_map_single(hw->dev,
379 (void *)t->rx_buf, 379 (void *)t->rx_buf,
380 t->len, DMA_FROM_DEVICE); 380 t->len, DMA_FROM_DEVICE);
381 if (dma_mapping_error(dma_rx_addr)) 381 if (dma_mapping_error(hw->dev, dma_rx_addr))
382 dev_err(hw->dev, "rx dma map error\n"); 382 dev_err(hw->dev, "rx dma map error\n");
383 } 383 }
384 } else { 384 } else {
@@ -401,7 +401,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
401 dma_tx_addr = dma_map_single(hw->dev, 401 dma_tx_addr = dma_map_single(hw->dev,
402 (void *)t->tx_buf, 402 (void *)t->tx_buf,
403 t->len, DMA_TO_DEVICE); 403 t->len, DMA_TO_DEVICE);
404 if (dma_mapping_error(dma_tx_addr)) 404 if (dma_mapping_error(hw->dev, dma_tx_addr))
405 dev_err(hw->dev, "tx dma map error\n"); 405 dev_err(hw->dev, "tx dma map error\n");
406 } 406 }
407 } else { 407 } else {
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 604e5f0a2d95..25eda71f4bf4 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -148,7 +148,6 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
148 unsigned rfalarm; 148 unsigned rfalarm;
149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
150 unsigned recv_at_once; 150 unsigned recv_at_once;
151 unsigned bpw = mps->bits_per_word / 8;
152 151
153 if (!t->tx_buf && !t->rx_buf && t->len) 152 if (!t->tx_buf && !t->rx_buf && t->len)
154 return -EINVAL; 153 return -EINVAL;
@@ -164,22 +163,15 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
164 } 163 }
165 164
166 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 165 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
167 if (tx_buf) { 166 for (; send_at_once; sb++, send_at_once--) {
168 for (; send_at_once; sb++, send_at_once--) { 167 /* set EOF flag before the last word is sent */
169 /* set EOF flag */ 168 if (send_at_once == 1)
170 if (mps->bits_per_word 169 out_8(&psc->ircr2, 0x01);
171 && (sb + 1) % bpw == 0) 170
172 out_8(&psc->ircr2, 0x01); 171 if (tx_buf)
173 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); 172 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]);
174 } 173 else
175 } else {
176 for (; send_at_once; sb++, send_at_once--) {
177 /* set EOF flag */
178 if (mps->bits_per_word
179 && ((sb + 1) % bpw) == 0)
180 out_8(&psc->ircr2, 0x01);
181 out_8(&psc->mpc52xx_psc_buffer_8, 0); 174 out_8(&psc->mpc52xx_psc_buffer_8, 0);
182 }
183 } 175 }
184 176
185 177
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index b1cc148036c1..f6f987bb71ca 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -836,7 +836,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m)
836 if (tx_buf != NULL) { 836 if (tx_buf != NULL) {
837 t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf, 837 t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf,
838 len, DMA_TO_DEVICE); 838 len, DMA_TO_DEVICE);
839 if (dma_mapping_error(t->tx_dma)) { 839 if (dma_mapping_error(&spi->dev, t->tx_dma)) {
840 dev_dbg(&spi->dev, "dma %cX %d bytes error\n", 840 dev_dbg(&spi->dev, "dma %cX %d bytes error\n",
841 'T', len); 841 'T', len);
842 return -EINVAL; 842 return -EINVAL;
@@ -845,7 +845,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m)
845 if (rx_buf != NULL) { 845 if (rx_buf != NULL) {
846 t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len, 846 t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len,
847 DMA_FROM_DEVICE); 847 DMA_FROM_DEVICE);
848 if (dma_mapping_error(t->rx_dma)) { 848 if (dma_mapping_error(&spi->dev, t->rx_dma)) {
849 dev_dbg(&spi->dev, "dma %cX %d bytes error\n", 849 dev_dbg(&spi->dev, "dma %cX %d bytes error\n",
850 'R', len); 850 'R', len);
851 if (tx_buf != NULL) 851 if (tx_buf != NULL)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 0c452c46ab07..067299d6d192 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -353,7 +353,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
353 drv_data->rx_dma = dma_map_single(dev, drv_data->rx, 353 drv_data->rx_dma = dma_map_single(dev, drv_data->rx,
354 drv_data->rx_map_len, 354 drv_data->rx_map_len,
355 DMA_FROM_DEVICE); 355 DMA_FROM_DEVICE);
356 if (dma_mapping_error(drv_data->rx_dma)) 356 if (dma_mapping_error(dev, drv_data->rx_dma))
357 return 0; 357 return 0;
358 358
359 /* Stream map the tx buffer */ 359 /* Stream map the tx buffer */
@@ -361,7 +361,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
361 drv_data->tx_map_len, 361 drv_data->tx_map_len,
362 DMA_TO_DEVICE); 362 DMA_TO_DEVICE);
363 363
364 if (dma_mapping_error(drv_data->tx_dma)) { 364 if (dma_mapping_error(dev, drv_data->tx_dma)) {
365 dma_unmap_single(dev, drv_data->rx_dma, 365 dma_unmap_single(dev, drv_data->rx_dma,
366 drv_data->rx_map_len, DMA_FROM_DEVICE); 366 drv_data->rx_map_len, DMA_FROM_DEVICE);
367 return 0; 367 return 0;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ecca4a6a6f94..964124b60db2 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -178,6 +178,96 @@ struct boardinfo {
178static LIST_HEAD(board_list); 178static LIST_HEAD(board_list);
179static DEFINE_MUTEX(board_lock); 179static DEFINE_MUTEX(board_lock);
180 180
181/**
182 * spi_alloc_device - Allocate a new SPI device
183 * @master: Controller to which device is connected
184 * Context: can sleep
185 *
186 * Allows a driver to allocate and initialize a spi_device without
187 * registering it immediately. This allows a driver to directly
188 * fill the spi_device with device parameters before calling
189 * spi_add_device() on it.
190 *
191 * Caller is responsible to call spi_add_device() on the returned
192 * spi_device structure to add it to the SPI master. If the caller
193 * needs to discard the spi_device without adding it, then it should
194 * call spi_dev_put() on it.
195 *
196 * Returns a pointer to the new device, or NULL.
197 */
198struct spi_device *spi_alloc_device(struct spi_master *master)
199{
200 struct spi_device *spi;
201 struct device *dev = master->dev.parent;
202
203 if (!spi_master_get(master))
204 return NULL;
205
206 spi = kzalloc(sizeof *spi, GFP_KERNEL);
207 if (!spi) {
208 dev_err(dev, "cannot alloc spi_device\n");
209 spi_master_put(master);
210 return NULL;
211 }
212
213 spi->master = master;
214 spi->dev.parent = dev;
215 spi->dev.bus = &spi_bus_type;
216 spi->dev.release = spidev_release;
217 device_initialize(&spi->dev);
218 return spi;
219}
220EXPORT_SYMBOL_GPL(spi_alloc_device);
221
222/**
223 * spi_add_device - Add spi_device allocated with spi_alloc_device
224 * @spi: spi_device to register
225 *
226 * Companion function to spi_alloc_device. Devices allocated with
227 * spi_alloc_device can be added onto the spi bus with this function.
228 *
229 * Returns 0 on success; non-zero on failure
230 */
231int spi_add_device(struct spi_device *spi)
232{
233 struct device *dev = spi->master->dev.parent;
234 int status;
235
236 /* Chipselects are numbered 0..max; validate. */
237 if (spi->chip_select >= spi->master->num_chipselect) {
238 dev_err(dev, "cs%d >= max %d\n",
239 spi->chip_select,
240 spi->master->num_chipselect);
241 return -EINVAL;
242 }
243
244 /* Set the bus ID string */
245 snprintf(spi->dev.bus_id, sizeof spi->dev.bus_id,
246 "%s.%u", spi->master->dev.bus_id,
247 spi->chip_select);
248
249 /* drivers may modify this initial i/o setup */
250 status = spi->master->setup(spi);
251 if (status < 0) {
252 dev_err(dev, "can't %s %s, status %d\n",
253 "setup", spi->dev.bus_id, status);
254 return status;
255 }
256
257 /* driver core catches callers that misbehave by defining
258 * devices that already exist.
259 */
260 status = device_add(&spi->dev);
261 if (status < 0) {
262 dev_err(dev, "can't %s %s, status %d\n",
263 "add", spi->dev.bus_id, status);
264 return status;
265 }
266
267 dev_dbg(dev, "registered child %s\n", spi->dev.bus_id);
268 return 0;
269}
270EXPORT_SYMBOL_GPL(spi_add_device);
181 271
182/** 272/**
183 * spi_new_device - instantiate one new SPI device 273 * spi_new_device - instantiate one new SPI device
@@ -197,7 +287,6 @@ struct spi_device *spi_new_device(struct spi_master *master,
197 struct spi_board_info *chip) 287 struct spi_board_info *chip)
198{ 288{
199 struct spi_device *proxy; 289 struct spi_device *proxy;
200 struct device *dev = master->dev.parent;
201 int status; 290 int status;
202 291
203 /* NOTE: caller did any chip->bus_num checks necessary. 292 /* NOTE: caller did any chip->bus_num checks necessary.
@@ -207,66 +296,28 @@ struct spi_device *spi_new_device(struct spi_master *master,
207 * suggests syslogged diagnostics are best here (ugh). 296 * suggests syslogged diagnostics are best here (ugh).
208 */ 297 */
209 298
210 /* Chipselects are numbered 0..max; validate. */ 299 proxy = spi_alloc_device(master);
211 if (chip->chip_select >= master->num_chipselect) { 300 if (!proxy)
212 dev_err(dev, "cs%d > max %d\n",
213 chip->chip_select,
214 master->num_chipselect);
215 return NULL;
216 }
217
218 if (!spi_master_get(master))
219 return NULL; 301 return NULL;
220 302
221 WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias)); 303 WARN_ON(strlen(chip->modalias) >= sizeof(proxy->modalias));
222 304
223 proxy = kzalloc(sizeof *proxy, GFP_KERNEL);
224 if (!proxy) {
225 dev_err(dev, "can't alloc dev for cs%d\n",
226 chip->chip_select);
227 goto fail;
228 }
229 proxy->master = master;
230 proxy->chip_select = chip->chip_select; 305 proxy->chip_select = chip->chip_select;
231 proxy->max_speed_hz = chip->max_speed_hz; 306 proxy->max_speed_hz = chip->max_speed_hz;
232 proxy->mode = chip->mode; 307 proxy->mode = chip->mode;
233 proxy->irq = chip->irq; 308 proxy->irq = chip->irq;
234 strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias)); 309 strlcpy(proxy->modalias, chip->modalias, sizeof(proxy->modalias));
235
236 snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
237 "%s.%u", master->dev.bus_id,
238 chip->chip_select);
239 proxy->dev.parent = dev;
240 proxy->dev.bus = &spi_bus_type;
241 proxy->dev.platform_data = (void *) chip->platform_data; 310 proxy->dev.platform_data = (void *) chip->platform_data;
242 proxy->controller_data = chip->controller_data; 311 proxy->controller_data = chip->controller_data;
243 proxy->controller_state = NULL; 312 proxy->controller_state = NULL;
244 proxy->dev.release = spidev_release;
245 313
246 /* drivers may modify this initial i/o setup */ 314 status = spi_add_device(proxy);
247 status = master->setup(proxy);
248 if (status < 0) { 315 if (status < 0) {
249 dev_err(dev, "can't %s %s, status %d\n", 316 spi_dev_put(proxy);
250 "setup", proxy->dev.bus_id, status); 317 return NULL;
251 goto fail;
252 } 318 }
253 319
254 /* driver core catches callers that misbehave by defining
255 * devices that already exist.
256 */
257 status = device_register(&proxy->dev);
258 if (status < 0) {
259 dev_err(dev, "can't %s %s, status %d\n",
260 "add", proxy->dev.bus_id, status);
261 goto fail;
262 }
263 dev_dbg(dev, "registered child %s\n", proxy->dev.bus_id);
264 return proxy; 320 return proxy;
265
266fail:
267 spi_master_put(master);
268 kfree(proxy);
269 return NULL;
270} 321}
271EXPORT_SYMBOL_GPL(spi_new_device); 322EXPORT_SYMBOL_GPL(spi_new_device);
272 323
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 54ac7bea5f8c..6fb77fcc4971 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -491,7 +491,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
491 buf, 491 buf,
492 drv_data->tx_map_len, 492 drv_data->tx_map_len,
493 DMA_TO_DEVICE); 493 DMA_TO_DEVICE);
494 if (dma_mapping_error(drv_data->tx_dma)) 494 if (dma_mapping_error(dev, drv_data->tx_dma))
495 return -1; 495 return -1;
496 496
497 drv_data->tx_dma_needs_unmap = 1; 497 drv_data->tx_dma_needs_unmap = 1;
@@ -516,7 +516,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
516 buf, 516 buf,
517 drv_data->len, 517 drv_data->len,
518 DMA_FROM_DEVICE); 518 DMA_FROM_DEVICE);
519 if (dma_mapping_error(drv_data->rx_dma)) 519 if (dma_mapping_error(dev, drv_data->rx_dma))
520 return -1; 520 return -1;
521 drv_data->rx_dma_needs_unmap = 1; 521 drv_data->rx_dma_needs_unmap = 1;
522 } 522 }
@@ -534,7 +534,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
534 buf, 534 buf,
535 drv_data->tx_map_len, 535 drv_data->tx_map_len,
536 DMA_TO_DEVICE); 536 DMA_TO_DEVICE);
537 if (dma_mapping_error(drv_data->tx_dma)) { 537 if (dma_mapping_error(dev, drv_data->tx_dma)) {
538 if (drv_data->rx_dma) { 538 if (drv_data->rx_dma) {
539 dma_unmap_single(dev, 539 dma_unmap_single(dev,
540 drv_data->rx_dma, 540 drv_data->rx_dma,
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 0885cc357a37..1c643c9e1f15 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -270,6 +270,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
270 /* setup the master state. */ 270 /* setup the master state. */
271 271
272 master->num_chipselect = hw->pdata->num_cs; 272 master->num_chipselect = hw->pdata->num_cs;
273 master->bus_num = pdata->bus_num;
273 274
274 /* setup the state for the bitbang driver */ 275 /* setup the state for the bitbang driver */
275 276
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 5e3e4e9b6c77..1f715436d6d3 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -87,7 +87,7 @@ struct mon_reader_text {
87 87
88static struct dentry *mon_dir; /* Usually /sys/kernel/debug/usbmon */ 88static struct dentry *mon_dir; /* Usually /sys/kernel/debug/usbmon */
89 89
90static void mon_text_ctor(struct kmem_cache *, void *); 90static void mon_text_ctor(void *);
91 91
92struct mon_text_ptr { 92struct mon_text_ptr {
93 int cnt, limit; 93 int cnt, limit;
@@ -720,7 +720,7 @@ void mon_text_del(struct mon_bus *mbus)
720/* 720/*
721 * Slab interface: constructor. 721 * Slab interface: constructor.
722 */ 722 */
723static void mon_text_ctor(struct kmem_cache *slab, void *mem) 723static void mon_text_ctor(void *mem)
724{ 724{
725 /* 725 /*
726 * Nothing to initialize. No, really! 726 * Nothing to initialize. No, really!
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 832a5a4f3cb3..cd9a2e138c8b 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -651,15 +651,17 @@ static int ipaq_open(struct tty_struct *tty,
651 */ 651 */
652 652
653 kfree(port->bulk_in_buffer); 653 kfree(port->bulk_in_buffer);
654 kfree(port->bulk_out_buffer);
655 /* make sure the generic serial code knows */
656 port->bulk_out_buffer = NULL;
657
654 port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); 658 port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);
655 if (port->bulk_in_buffer == NULL) { 659 if (port->bulk_in_buffer == NULL)
656 port->bulk_out_buffer = NULL; /* prevent double free */
657 goto enomem; 660 goto enomem;
658 }
659 661
660 kfree(port->bulk_out_buffer);
661 port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); 662 port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);
662 if (port->bulk_out_buffer == NULL) { 663 if (port->bulk_out_buffer == NULL) {
664 /* the buffer is useless, free it */
663 kfree(port->bulk_in_buffer); 665 kfree(port->bulk_in_buffer);
664 port->bulk_in_buffer = NULL; 666 port->bulk_in_buffer = NULL;
665 goto enomem; 667 goto enomem;
diff --git a/drivers/video/am200epd.c b/drivers/video/am200epd.c
index 51e26c1f5e8b..32dd85126931 100644
--- a/drivers/video/am200epd.c
+++ b/drivers/video/am200epd.c
@@ -221,7 +221,7 @@ static int am200_setup_irq(struct fb_info *info)
221 return retval; 221 return retval;
222 } 222 }
223 223
224 return set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQT_FALLING); 224 return set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQ_TYPE_EDGE_FALLING);
225} 225}
226 226
227static void am200_set_rst(struct metronomefb_par *par, int state) 227static void am200_set_rst(struct metronomefb_par *par, int state)
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index a11cc2fdd4cd..4055dbdd1b42 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -370,7 +370,7 @@ static const struct consw sti_con = {
370 370
371 371
372 372
373int __init sticonsole_init(void) 373static int __init sticonsole_init(void)
374{ 374{
375 /* already initialized ? */ 375 /* already initialized ? */
376 if (sticon_sti) 376 if (sticon_sti)
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index e9ab657f0bb7..d7822af0e00a 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -29,7 +29,7 @@
29 29
30#define STI_DRIVERVERSION "Version 0.9a" 30#define STI_DRIVERVERSION "Version 0.9a"
31 31
32struct sti_struct *default_sti __read_mostly; 32static struct sti_struct *default_sti __read_mostly;
33 33
34/* number of STI ROMS found and their ptrs to each struct */ 34/* number of STI ROMS found and their ptrs to each struct */
35static int num_sti_roms __read_mostly; 35static int num_sti_roms __read_mostly;
@@ -68,8 +68,7 @@ static const struct sti_init_flags default_init_flags = {
68 .init_cmap_tx = 1, 68 .init_cmap_tx = 1,
69}; 69};
70 70
71int 71static int sti_init_graph(struct sti_struct *sti)
72sti_init_graph(struct sti_struct *sti)
73{ 72{
74 struct sti_init_inptr_ext inptr_ext = { 0, }; 73 struct sti_init_inptr_ext inptr_ext = { 0, };
75 struct sti_init_inptr inptr = { 74 struct sti_init_inptr inptr = {
@@ -100,8 +99,7 @@ static const struct sti_conf_flags default_conf_flags = {
100 .wait = STI_WAIT, 99 .wait = STI_WAIT,
101}; 100};
102 101
103void 102static void sti_inq_conf(struct sti_struct *sti)
104sti_inq_conf(struct sti_struct *sti)
105{ 103{
106 struct sti_conf_inptr inptr = { 0, }; 104 struct sti_conf_inptr inptr = { 0, };
107 unsigned long flags; 105 unsigned long flags;
@@ -237,8 +235,8 @@ static void sti_flush(unsigned long start, unsigned long end)
237 flush_icache_range(start, end); 235 flush_icache_range(start, end);
238} 236}
239 237
240void __devinit 238static void __devinit sti_rom_copy(unsigned long base, unsigned long count,
241sti_rom_copy(unsigned long base, unsigned long count, void *dest) 239 void *dest)
242{ 240{
243 unsigned long dest_start = (unsigned long) dest; 241 unsigned long dest_start = (unsigned long) dest;
244 242
@@ -478,8 +476,8 @@ sti_init_glob_cfg(struct sti_struct *sti,
478} 476}
479 477
480#ifdef CONFIG_FB 478#ifdef CONFIG_FB
481struct sti_cooked_font * __devinit 479static struct sti_cooked_font __devinit
482sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name) 480*sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
483{ 481{
484 const struct font_desc *fbfont; 482 const struct font_desc *fbfont;
485 unsigned int size, bpc; 483 unsigned int size, bpc;
@@ -534,16 +532,16 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
534 return cooked_font; 532 return cooked_font;
535} 533}
536#else 534#else
537struct sti_cooked_font * __devinit 535static struct sti_cooked_font __devinit
538sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name) 536*sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
539{ 537{
540 return NULL; 538 return NULL;
541} 539}
542#endif 540#endif
543 541
544struct sti_cooked_font * __devinit 542static struct sti_cooked_font __devinit
545sti_select_font(struct sti_cooked_rom *rom, 543*sti_select_font(struct sti_cooked_rom *rom,
546 int (*search_font_fnc) (struct sti_cooked_rom *,int,int) ) 544 int (*search_font_fnc)(struct sti_cooked_rom *, int, int))
547{ 545{
548 struct sti_cooked_font *font; 546 struct sti_cooked_font *font;
549 int i; 547 int i;
@@ -707,8 +705,7 @@ sti_get_bmode_rom (unsigned long address)
707 return raw; 705 return raw;
708} 706}
709 707
710struct sti_rom * __devinit 708static struct sti_rom __devinit *sti_get_wmode_rom(unsigned long address)
711sti_get_wmode_rom (unsigned long address)
712{ 709{
713 struct sti_rom *raw; 710 struct sti_rom *raw;
714 unsigned long size; 711 unsigned long size;
@@ -723,8 +720,8 @@ sti_get_wmode_rom (unsigned long address)
723 return raw; 720 return raw;
724} 721}
725 722
726int __devinit 723static int __devinit sti_read_rom(int wordmode, struct sti_struct *sti,
727sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address) 724 unsigned long address)
728{ 725{
729 struct sti_cooked_rom *cooked; 726 struct sti_cooked_rom *cooked;
730 struct sti_rom *raw = NULL; 727 struct sti_rom *raw = NULL;
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 5d84b3431098..6b487801eeae 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -35,7 +35,6 @@
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/efi.h> 36#include <linux/efi.h>
37#include <linux/fb.h> 37#include <linux/fb.h>
38#include <linux/major.h>
39 38
40#include <asm/fb.h> 39#include <asm/fb.h>
41 40
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index aa8c714d6245..b790ddff76f9 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -596,7 +596,7 @@ static struct fb_ops macfb_ops = {
596 .fb_imageblit = cfb_imageblit, 596 .fb_imageblit = cfb_imageblit,
597}; 597};
598 598
599void __init macfb_setup(char *options) 599static void __init macfb_setup(char *options)
600{ 600{
601 char *this_opt; 601 char *this_opt;
602 602
diff --git a/drivers/video/omap/sossi.c b/drivers/video/omap/sossi.c
index 81dbcf53cf0e..fafd0f26b90f 100644
--- a/drivers/video/omap/sossi.c
+++ b/drivers/video/omap/sossi.c
@@ -646,7 +646,7 @@ static int sossi_init(struct omapfb_device *fbdev)
646 sossi_write_reg(SOSSI_INIT1_REG, l); 646 sossi_write_reg(SOSSI_INIT1_REG, l);
647 647
648 if ((r = request_irq(INT_1610_SoSSI_MATCH, sossi_match_irq, 648 if ((r = request_irq(INT_1610_SoSSI_MATCH, sossi_match_irq,
649 IRQT_FALLING, 649 IRQ_TYPE_EDGE_FALLING,
650 "sossi_match", sossi.fbdev->dev)) < 0) { 650 "sossi_match", sossi.fbdev->dev)) < 0) {
651 dev_err(sossi.fbdev->dev, "can't get SoSSI match IRQ\n"); 651 dev_err(sossi.fbdev->dev, "can't get SoSSI match IRQ\n");
652 goto err; 652 goto err;
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 2b707a8ce5de..69de2fed6c58 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -1336,7 +1336,7 @@ static int __devinit pxafb_map_video_memory(struct pxafb_info *fbi)
1336 fbi->dma_buff_phys = fbi->map_dma; 1336 fbi->dma_buff_phys = fbi->map_dma;
1337 fbi->palette_cpu = (u16 *) fbi->dma_buff->palette; 1337 fbi->palette_cpu = (u16 *) fbi->dma_buff->palette;
1338 1338
1339 pr_debug("pxafb: palette_mem_size = 0x%08lx\n", fbi->palette_size*sizeof(u16)); 1339 pr_debug("pxafb: palette_mem_size = 0x%08x\n", fbi->palette_size*sizeof(u16));
1340 1340
1341#ifdef CONFIG_FB_PXA_SMARTPANEL 1341#ifdef CONFIG_FB_PXA_SMARTPANEL
1342 fbi->smart_cmds = (uint16_t *) fbi->dma_buff->cmd_buff; 1342 fbi->smart_cmds = (uint16_t *) fbi->dma_buff->cmd_buff;
diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index 4d0e28c5790b..8d0212da4514 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -152,6 +152,7 @@ static int sh7760fb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
152 col |= ((*g) & 0xff) << 8; 152 col |= ((*g) & 0xff) << 8;
153 col |= ((*b) & 0xff); 153 col |= ((*b) & 0xff);
154 col &= SH7760FB_PALETTE_MASK; 154 col &= SH7760FB_PALETTE_MASK;
155 iowrite32(col, par->base + LDPR(s));
155 156
156 if (s < 16) 157 if (s < 16)
157 ((u32 *) (info->pseudo_palette))[s] = s; 158 ((u32 *) (info->pseudo_palette))[s] = s;
diff --git a/drivers/video/sticore.h b/drivers/video/sticore.h
index 1a9a60c74be3..7fe5be4bc70e 100644
--- a/drivers/video/sticore.h
+++ b/drivers/video/sticore.h
@@ -352,8 +352,6 @@ struct sti_struct *sti_get_rom(unsigned int index); /* 0: default sti */
352 352
353/* functions to call the STI ROM directly */ 353/* functions to call the STI ROM directly */
354 354
355int sti_init_graph(struct sti_struct *sti);
356void sti_inq_conf(struct sti_struct *sti);
357void sti_putc(struct sti_struct *sti, int c, int y, int x); 355void sti_putc(struct sti_struct *sti, int c, int y, int x);
358void sti_set(struct sti_struct *sti, int src_y, int src_x, 356void sti_set(struct sti_struct *sti, int src_y, int src_x,
359 int height, int width, u8 color); 357 int height, int width, u8 color);
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index 598d35eff935..166481402412 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -1078,8 +1078,7 @@ static struct fb_ops stifb_ops = {
1078 * Initialization 1078 * Initialization
1079 */ 1079 */
1080 1080
1081int __init 1081static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
1082stifb_init_fb(struct sti_struct *sti, int bpp_pref)
1083{ 1082{
1084 struct fb_fix_screeninfo *fix; 1083 struct fb_fix_screeninfo *fix;
1085 struct fb_var_screeninfo *var; 1084 struct fb_var_screeninfo *var;
@@ -1315,8 +1314,7 @@ static int stifb_disabled __initdata;
1315int __init 1314int __init
1316stifb_setup(char *options); 1315stifb_setup(char *options);
1317 1316
1318int __init 1317static int __init stifb_init(void)
1319stifb_init(void)
1320{ 1318{
1321 struct sti_struct *sti; 1319 struct sti_struct *sti;
1322 struct sti_struct *def_sti; 1320 struct sti_struct *def_sti;
diff --git a/fs/Kconfig b/fs/Kconfig
index 97e3bdedb1e6..d3873583360b 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1383,6 +1383,19 @@ config MINIX_FS
1383 partition (the one containing the directory /) cannot be compiled as 1383 partition (the one containing the directory /) cannot be compiled as
1384 a module. 1384 a module.
1385 1385
1386config OMFS_FS
1387 tristate "SonicBlue Optimized MPEG File System support"
1388 depends on BLOCK
1389 select CRC_ITU_T
1390 help
1391 This is the proprietary file system used by the Rio Karma music
1392 player and ReplayTV DVR. Despite the name, this filesystem is not
1393 more efficient than a standard FS for MPEG files, in fact likely
1394 the opposite is true. Say Y if you have either of these devices
1395 and wish to mount its disk.
1396
1397 To compile this file system support as a module, choose M here: the
1398 module will be called omfs. If unsure, say N.
1386 1399
1387config HPFS_FS 1400config HPFS_FS
1388 tristate "OS/2 HPFS file system support" 1401 tristate "OS/2 HPFS file system support"
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 3263084eef9e..4a551af6f3fc 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -30,7 +30,7 @@ config COMPAT_BINFMT_ELF
30config BINFMT_ELF_FDPIC 30config BINFMT_ELF_FDPIC
31 bool "Kernel support for FDPIC ELF binaries" 31 bool "Kernel support for FDPIC ELF binaries"
32 default y 32 default y
33 depends on (FRV || BLACKFIN) 33 depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
34 help 34 help
35 ELF FDPIC binaries are based on ELF, but allow the individual load 35 ELF FDPIC binaries are based on ELF, but allow the individual load
36 segments of a binary to be located in memory independently of each 36 segments of a binary to be located in memory independently of each
diff --git a/fs/Makefile b/fs/Makefile
index 3b2178b4bb66..a1482a5eff15 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -111,6 +111,7 @@ obj-$(CONFIG_ADFS_FS) += adfs/
111obj-$(CONFIG_FUSE_FS) += fuse/ 111obj-$(CONFIG_FUSE_FS) += fuse/
112obj-$(CONFIG_UDF_FS) += udf/ 112obj-$(CONFIG_UDF_FS) += udf/
113obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ 113obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
114obj-$(CONFIG_OMFS_FS) += omfs/
114obj-$(CONFIG_JFS_FS) += jfs/ 115obj-$(CONFIG_JFS_FS) += jfs/
115obj-$(CONFIG_XFS_FS) += xfs/ 116obj-$(CONFIG_XFS_FS) += xfs/
116obj-$(CONFIG_9P_FS) += 9p/ 117obj-$(CONFIG_9P_FS) += 9p/
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 9e421eeb672b..26f3b43726bb 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -249,7 +249,7 @@ static void adfs_destroy_inode(struct inode *inode)
249 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 249 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
250} 250}
251 251
252static void init_once(struct kmem_cache *cachep, void *foo) 252static void init_once(void *foo)
253{ 253{
254 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; 254 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
255 255
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 223b1917093e..e9ec915f7553 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -2,6 +2,7 @@
2#include <linux/fs.h> 2#include <linux/fs.h>
3#include <linux/buffer_head.h> 3#include <linux/buffer_head.h>
4#include <linux/amigaffs.h> 4#include <linux/amigaffs.h>
5#include <linux/mutex.h>
5 6
6/* AmigaOS allows file names with up to 30 characters length. 7/* AmigaOS allows file names with up to 30 characters length.
7 * Names longer than that will be silently truncated. If you 8 * Names longer than that will be silently truncated. If you
@@ -98,7 +99,7 @@ struct affs_sb_info {
98 gid_t s_gid; /* gid to override */ 99 gid_t s_gid; /* gid to override */
99 umode_t s_mode; /* mode to override */ 100 umode_t s_mode; /* mode to override */
100 struct buffer_head *s_root_bh; /* Cached root block. */ 101 struct buffer_head *s_root_bh; /* Cached root block. */
101 struct semaphore s_bmlock; /* Protects bitmap access. */ 102 struct mutex s_bmlock; /* Protects bitmap access. */
102 struct affs_bm_info *s_bitmap; /* Bitmap infos. */ 103 struct affs_bm_info *s_bitmap; /* Bitmap infos. */
103 u32 s_bmap_count; /* # of bitmap blocks. */ 104 u32 s_bmap_count; /* # of bitmap blocks. */
104 u32 s_bmap_bits; /* # of bits in one bitmap blocks */ 105 u32 s_bmap_bits; /* # of bits in one bitmap blocks */
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index c4a5ad09ddf2..dc5ef14bdc1c 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb)
45 if (sb->s_flags & MS_RDONLY) 45 if (sb->s_flags & MS_RDONLY)
46 return 0; 46 return 0;
47 47
48 down(&AFFS_SB(sb)->s_bmlock); 48 mutex_lock(&AFFS_SB(sb)->s_bmlock);
49 49
50 bm = AFFS_SB(sb)->s_bitmap; 50 bm = AFFS_SB(sb)->s_bitmap;
51 free = 0; 51 free = 0;
52 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) 52 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
53 free += bm->bm_free; 53 free += bm->bm_free;
54 54
55 up(&AFFS_SB(sb)->s_bmlock); 55 mutex_unlock(&AFFS_SB(sb)->s_bmlock);
56 56
57 return free; 57 return free;
58} 58}
@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block)
76 bit = blk % sbi->s_bmap_bits; 76 bit = blk % sbi->s_bmap_bits;
77 bm = &sbi->s_bitmap[bmap]; 77 bm = &sbi->s_bitmap[bmap];
78 78
79 down(&sbi->s_bmlock); 79 mutex_lock(&sbi->s_bmlock);
80 80
81 bh = sbi->s_bmap_bh; 81 bh = sbi->s_bmap_bh;
82 if (sbi->s_last_bmap != bmap) { 82 if (sbi->s_last_bmap != bmap) {
@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block)
105 sb->s_dirt = 1; 105 sb->s_dirt = 1;
106 bm->bm_free++; 106 bm->bm_free++;
107 107
108 up(&sbi->s_bmlock); 108 mutex_unlock(&sbi->s_bmlock);
109 return; 109 return;
110 110
111err_free: 111err_free:
112 affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); 112 affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block);
113 up(&sbi->s_bmlock); 113 mutex_unlock(&sbi->s_bmlock);
114 return; 114 return;
115 115
116err_bh_read: 116err_bh_read:
117 affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); 117 affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key);
118 sbi->s_bmap_bh = NULL; 118 sbi->s_bmap_bh = NULL;
119 sbi->s_last_bmap = ~0; 119 sbi->s_last_bmap = ~0;
120 up(&sbi->s_bmlock); 120 mutex_unlock(&sbi->s_bmlock);
121 return; 121 return;
122 122
123err_range: 123err_range:
@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
168 bmap = blk / sbi->s_bmap_bits; 168 bmap = blk / sbi->s_bmap_bits;
169 bm = &sbi->s_bitmap[bmap]; 169 bm = &sbi->s_bitmap[bmap];
170 170
171 down(&sbi->s_bmlock); 171 mutex_lock(&sbi->s_bmlock);
172 172
173 if (bm->bm_free) 173 if (bm->bm_free)
174 goto find_bmap_bit; 174 goto find_bmap_bit;
@@ -249,7 +249,7 @@ find_bit:
249 mark_buffer_dirty(bh); 249 mark_buffer_dirty(bh);
250 sb->s_dirt = 1; 250 sb->s_dirt = 1;
251 251
252 up(&sbi->s_bmlock); 252 mutex_unlock(&sbi->s_bmlock);
253 253
254 pr_debug("%d\n", blk); 254 pr_debug("%d\n", blk);
255 return blk; 255 return blk;
@@ -259,7 +259,7 @@ err_bh_read:
259 sbi->s_bmap_bh = NULL; 259 sbi->s_bmap_bh = NULL;
260 sbi->s_last_bmap = ~0; 260 sbi->s_last_bmap = ~0;
261err_full: 261err_full:
262 up(&sbi->s_bmlock); 262 mutex_unlock(&sbi->s_bmlock);
263 pr_debug("failed\n"); 263 pr_debug("failed\n");
264 return 0; 264 return 0;
265} 265}
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 6eac7bdeec94..1377b1240b6e 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -46,8 +46,6 @@ const struct inode_operations affs_file_inode_operations = {
46static int 46static int
47affs_file_open(struct inode *inode, struct file *filp) 47affs_file_open(struct inode *inode, struct file *filp)
48{ 48{
49 if (atomic_read(&filp->f_count) != 1)
50 return 0;
51 pr_debug("AFFS: open(%lu,%d)\n", 49 pr_debug("AFFS: open(%lu,%d)\n",
52 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); 50 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt));
53 atomic_inc(&AFFS_I(inode)->i_opencnt); 51 atomic_inc(&AFFS_I(inode)->i_opencnt);
@@ -57,8 +55,6 @@ affs_file_open(struct inode *inode, struct file *filp)
57static int 55static int
58affs_file_release(struct inode *inode, struct file *filp) 56affs_file_release(struct inode *inode, struct file *filp)
59{ 57{
60 if (atomic_read(&filp->f_count) != 0)
61 return 0;
62 pr_debug("AFFS: release(%lu, %d)\n", 58 pr_debug("AFFS: release(%lu, %d)\n",
63 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); 59 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt));
64 60
diff --git a/fs/affs/super.c b/fs/affs/super.c
index d214837d5e42..3a89094f93d0 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -90,7 +90,7 @@ static void affs_destroy_inode(struct inode *inode)
90 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 90 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
91} 91}
92 92
93static void init_once(struct kmem_cache *cachep, void *foo) 93static void init_once(void *foo)
94{ 94{
95 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 95 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
96 96
@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
290 if (!sbi) 290 if (!sbi)
291 return -ENOMEM; 291 return -ENOMEM;
292 sb->s_fs_info = sbi; 292 sb->s_fs_info = sbi;
293 init_MUTEX(&sbi->s_bmlock); 293 mutex_init(&sbi->s_bmlock);
294 294
295 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, 295 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
296 &blocksize,&sbi->s_prefix, 296 &blocksize,&sbi->s_prefix,
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 7102824ba847..3cb6920ff30b 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -469,8 +469,6 @@ extern bool afs_cm_incoming_call(struct afs_call *);
469extern const struct inode_operations afs_dir_inode_operations; 469extern const struct inode_operations afs_dir_inode_operations;
470extern const struct file_operations afs_dir_file_operations; 470extern const struct file_operations afs_dir_file_operations;
471 471
472extern int afs_permission(struct inode *, int, struct nameidata *);
473
474/* 472/*
475 * file.c 473 * file.c
476 */ 474 */
@@ -605,7 +603,7 @@ extern void afs_clear_permits(struct afs_vnode *);
605extern void afs_cache_permit(struct afs_vnode *, struct key *, long); 603extern void afs_cache_permit(struct afs_vnode *, struct key *, long);
606extern void afs_zap_permits(struct rcu_head *); 604extern void afs_zap_permits(struct rcu_head *);
607extern struct key *afs_request_key(struct afs_cell *); 605extern struct key *afs_request_key(struct afs_cell *);
608extern int afs_permission(struct inode *, int, struct nameidata *); 606extern int afs_permission(struct inode *, int);
609 607
610/* 608/*
611 * server.c 609 * server.c
diff --git a/fs/afs/security.c b/fs/afs/security.c
index 3bcbeceba1bb..3ef504370034 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -284,7 +284,7 @@ static int afs_check_permit(struct afs_vnode *vnode, struct key *key,
284 * - AFS ACLs are attached to directories only, and a file is controlled by its 284 * - AFS ACLs are attached to directories only, and a file is controlled by its
285 * parent directory's ACL 285 * parent directory's ACL
286 */ 286 */
287int afs_permission(struct inode *inode, int mask, struct nameidata *nd) 287int afs_permission(struct inode *inode, int mask)
288{ 288{
289 struct afs_vnode *vnode = AFS_FS_I(inode); 289 struct afs_vnode *vnode = AFS_FS_I(inode);
290 afs_access_t uninitialized_var(access); 290 afs_access_t uninitialized_var(access);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 7e3faeef6818..250d8c4d66e4 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -27,7 +27,7 @@
27 27
28#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 28#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
29 29
30static void afs_i_init_once(struct kmem_cache *cachep, void *foo); 30static void afs_i_init_once(void *foo);
31static int afs_get_sb(struct file_system_type *fs_type, 31static int afs_get_sb(struct file_system_type *fs_type,
32 int flags, const char *dev_name, 32 int flags, const char *dev_name,
33 void *data, struct vfsmount *mnt); 33 void *data, struct vfsmount *mnt);
@@ -449,7 +449,7 @@ static void afs_put_super(struct super_block *sb)
449/* 449/*
450 * initialise an inode cache slab element prior to any use 450 * initialise an inode cache slab element prior to any use
451 */ 451 */
452static void afs_i_init_once(struct kmem_cache *cachep, void *_vnode) 452static void afs_i_init_once(void *_vnode)
453{ 453{
454 struct afs_vnode *vnode = _vnode; 454 struct afs_vnode *vnode = _vnode;
455 455
diff --git a/fs/aio.c b/fs/aio.c
index 0051fd94b44e..f658441d5666 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -512,8 +512,8 @@ static void aio_fput_routine(struct work_struct *data)
512 */ 512 */
513static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) 513static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
514{ 514{
515 dprintk(KERN_DEBUG "aio_put(%p): f_count=%d\n", 515 dprintk(KERN_DEBUG "aio_put(%p): f_count=%ld\n",
516 req, atomic_read(&req->ki_filp->f_count)); 516 req, atomic_long_read(&req->ki_filp->f_count));
517 517
518 assert_spin_locked(&ctx->ctx_lock); 518 assert_spin_locked(&ctx->ctx_lock);
519 519
@@ -528,7 +528,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
528 /* Must be done under the lock to serialise against cancellation. 528 /* Must be done under the lock to serialise against cancellation.
529 * Call this aio_fput as it duplicates fput via the fput_work. 529 * Call this aio_fput as it duplicates fput via the fput_work.
530 */ 530 */
531 if (unlikely(atomic_dec_and_test(&req->ki_filp->f_count))) { 531 if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) {
532 get_ioctx(ctx); 532 get_ioctx(ctx);
533 spin_lock(&fput_lock); 533 spin_lock(&fput_lock);
534 list_add(&req->ki_list, &fput_head); 534 list_add(&req->ki_list, &fput_head);
diff --git a/fs/attr.c b/fs/attr.c
index 966b73e25f82..26c71ba1eed4 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -51,7 +51,7 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
51 } 51 }
52 52
53 /* Check for setting the inode time. */ 53 /* Check for setting the inode time. */
54 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) { 54 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) {
55 if (!is_owner_or_cap(inode)) 55 if (!is_owner_or_cap(inode))
56 goto error; 56 goto error;
57 } 57 }
@@ -108,6 +108,11 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
108 struct timespec now; 108 struct timespec now;
109 unsigned int ia_valid = attr->ia_valid; 109 unsigned int ia_valid = attr->ia_valid;
110 110
111 if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
112 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
113 return -EPERM;
114 }
115
111 now = current_fs_time(inode->i_sb); 116 now = current_fs_time(inode->i_sb);
112 117
113 attr->ia_ctime = now; 118 attr->ia_ctime = now;
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index f1c2ea8342f5..5f1538c03b1b 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -243,8 +243,7 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
243 return -EIO; 243 return -EIO;
244} 244}
245 245
246static int bad_inode_permission(struct inode *inode, int mask, 246static int bad_inode_permission(struct inode *inode, int mask)
247 struct nameidata *nd)
248{ 247{
249 return -EIO; 248 return -EIO;
250} 249}
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index e8717de3bab3..02c6e62b72f8 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode)
289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
290} 290}
291 291
292static void init_once(struct kmem_cache *cachep, void *foo) 292static void init_once(void *foo)
293{ 293{
294 struct befs_inode_info *bi = (struct befs_inode_info *) foo; 294 struct befs_inode_info *bi = (struct befs_inode_info *) foo;
295 295
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 70f5d3a8eede..7109e451abf7 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -16,8 +16,9 @@ struct bfs_sb_info {
16 unsigned long si_freei; 16 unsigned long si_freei;
17 unsigned long si_lf_eblk; 17 unsigned long si_lf_eblk;
18 unsigned long si_lasti; 18 unsigned long si_lasti;
19 unsigned long * si_imap; 19 unsigned long *si_imap;
20 struct buffer_head * si_sbh; /* buffer header w/superblock */ 20 struct buffer_head *si_sbh; /* buffer header w/superblock */
21 struct mutex bfs_lock;
21}; 22};
22 23
23/* 24/*
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 034950cb3cbe..87ee5ccee348 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -32,16 +32,17 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
32 struct inode *dir = f->f_path.dentry->d_inode; 32 struct inode *dir = f->f_path.dentry->d_inode;
33 struct buffer_head *bh; 33 struct buffer_head *bh;
34 struct bfs_dirent *de; 34 struct bfs_dirent *de;
35 struct bfs_sb_info *info = BFS_SB(dir->i_sb);
35 unsigned int offset; 36 unsigned int offset;
36 int block; 37 int block;
37 38
38 lock_kernel(); 39 mutex_lock(&info->bfs_lock);
39 40
40 if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { 41 if (f->f_pos & (BFS_DIRENT_SIZE - 1)) {
41 printf("Bad f_pos=%08lx for %s:%08lx\n", 42 printf("Bad f_pos=%08lx for %s:%08lx\n",
42 (unsigned long)f->f_pos, 43 (unsigned long)f->f_pos,
43 dir->i_sb->s_id, dir->i_ino); 44 dir->i_sb->s_id, dir->i_ino);
44 unlock_kernel(); 45 mutex_unlock(&info->bfs_lock);
45 return -EBADF; 46 return -EBADF;
46 } 47 }
47 48
@@ -61,7 +62,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
61 le16_to_cpu(de->ino), 62 le16_to_cpu(de->ino),
62 DT_UNKNOWN) < 0) { 63 DT_UNKNOWN) < 0) {
63 brelse(bh); 64 brelse(bh);
64 unlock_kernel(); 65 mutex_unlock(&info->bfs_lock);
65 return 0; 66 return 0;
66 } 67 }
67 } 68 }
@@ -71,7 +72,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
71 brelse(bh); 72 brelse(bh);
72 } 73 }
73 74
74 unlock_kernel(); 75 mutex_unlock(&info->bfs_lock);
75 return 0; 76 return 0;
76} 77}
77 78
@@ -95,10 +96,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode,
95 inode = new_inode(s); 96 inode = new_inode(s);
96 if (!inode) 97 if (!inode)
97 return -ENOSPC; 98 return -ENOSPC;
98 lock_kernel(); 99 mutex_lock(&info->bfs_lock);
99 ino = find_first_zero_bit(info->si_imap, info->si_lasti); 100 ino = find_first_zero_bit(info->si_imap, info->si_lasti);
100 if (ino > info->si_lasti) { 101 if (ino > info->si_lasti) {
101 unlock_kernel(); 102 mutex_unlock(&info->bfs_lock);
102 iput(inode); 103 iput(inode);
103 return -ENOSPC; 104 return -ENOSPC;
104 } 105 }
@@ -125,10 +126,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode,
125 if (err) { 126 if (err) {
126 inode_dec_link_count(inode); 127 inode_dec_link_count(inode);
127 iput(inode); 128 iput(inode);
128 unlock_kernel(); 129 mutex_unlock(&info->bfs_lock);
129 return err; 130 return err;
130 } 131 }
131 unlock_kernel(); 132 mutex_unlock(&info->bfs_lock);
132 d_instantiate(dentry, inode); 133 d_instantiate(dentry, inode);
133 return 0; 134 return 0;
134} 135}
@@ -139,22 +140,23 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry,
139 struct inode *inode = NULL; 140 struct inode *inode = NULL;
140 struct buffer_head *bh; 141 struct buffer_head *bh;
141 struct bfs_dirent *de; 142 struct bfs_dirent *de;
143 struct bfs_sb_info *info = BFS_SB(dir->i_sb);
142 144
143 if (dentry->d_name.len > BFS_NAMELEN) 145 if (dentry->d_name.len > BFS_NAMELEN)
144 return ERR_PTR(-ENAMETOOLONG); 146 return ERR_PTR(-ENAMETOOLONG);
145 147
146 lock_kernel(); 148 mutex_lock(&info->bfs_lock);
147 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); 149 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de);
148 if (bh) { 150 if (bh) {
149 unsigned long ino = (unsigned long)le16_to_cpu(de->ino); 151 unsigned long ino = (unsigned long)le16_to_cpu(de->ino);
150 brelse(bh); 152 brelse(bh);
151 inode = bfs_iget(dir->i_sb, ino); 153 inode = bfs_iget(dir->i_sb, ino);
152 if (IS_ERR(inode)) { 154 if (IS_ERR(inode)) {
153 unlock_kernel(); 155 mutex_unlock(&info->bfs_lock);
154 return ERR_CAST(inode); 156 return ERR_CAST(inode);
155 } 157 }
156 } 158 }
157 unlock_kernel(); 159 mutex_unlock(&info->bfs_lock);
158 d_add(dentry, inode); 160 d_add(dentry, inode);
159 return NULL; 161 return NULL;
160} 162}
@@ -163,13 +165,14 @@ static int bfs_link(struct dentry *old, struct inode *dir,
163 struct dentry *new) 165 struct dentry *new)
164{ 166{
165 struct inode *inode = old->d_inode; 167 struct inode *inode = old->d_inode;
168 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
166 int err; 169 int err;
167 170
168 lock_kernel(); 171 mutex_lock(&info->bfs_lock);
169 err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, 172 err = bfs_add_entry(dir, new->d_name.name, new->d_name.len,
170 inode->i_ino); 173 inode->i_ino);
171 if (err) { 174 if (err) {
172 unlock_kernel(); 175 mutex_unlock(&info->bfs_lock);
173 return err; 176 return err;
174 } 177 }
175 inc_nlink(inode); 178 inc_nlink(inode);
@@ -177,19 +180,19 @@ static int bfs_link(struct dentry *old, struct inode *dir,
177 mark_inode_dirty(inode); 180 mark_inode_dirty(inode);
178 atomic_inc(&inode->i_count); 181 atomic_inc(&inode->i_count);
179 d_instantiate(new, inode); 182 d_instantiate(new, inode);
180 unlock_kernel(); 183 mutex_unlock(&info->bfs_lock);
181 return 0; 184 return 0;
182} 185}
183 186
184static int bfs_unlink(struct inode *dir, struct dentry *dentry) 187static int bfs_unlink(struct inode *dir, struct dentry *dentry)
185{ 188{
186 int error = -ENOENT; 189 int error = -ENOENT;
187 struct inode *inode; 190 struct inode *inode = dentry->d_inode;
188 struct buffer_head *bh; 191 struct buffer_head *bh;
189 struct bfs_dirent *de; 192 struct bfs_dirent *de;
193 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
190 194
191 inode = dentry->d_inode; 195 mutex_lock(&info->bfs_lock);
192 lock_kernel();
193 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); 196 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de);
194 if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) 197 if (!bh || (le16_to_cpu(de->ino) != inode->i_ino))
195 goto out_brelse; 198 goto out_brelse;
@@ -210,7 +213,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
210 213
211out_brelse: 214out_brelse:
212 brelse(bh); 215 brelse(bh);
213 unlock_kernel(); 216 mutex_unlock(&info->bfs_lock);
214 return error; 217 return error;
215} 218}
216 219
@@ -220,6 +223,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
220 struct inode *old_inode, *new_inode; 223 struct inode *old_inode, *new_inode;
221 struct buffer_head *old_bh, *new_bh; 224 struct buffer_head *old_bh, *new_bh;
222 struct bfs_dirent *old_de, *new_de; 225 struct bfs_dirent *old_de, *new_de;
226 struct bfs_sb_info *info;
223 int error = -ENOENT; 227 int error = -ENOENT;
224 228
225 old_bh = new_bh = NULL; 229 old_bh = new_bh = NULL;
@@ -227,7 +231,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
227 if (S_ISDIR(old_inode->i_mode)) 231 if (S_ISDIR(old_inode->i_mode))
228 return -EINVAL; 232 return -EINVAL;
229 233
230 lock_kernel(); 234 info = BFS_SB(old_inode->i_sb);
235
236 mutex_lock(&info->bfs_lock);
231 old_bh = bfs_find_entry(old_dir, 237 old_bh = bfs_find_entry(old_dir,
232 old_dentry->d_name.name, 238 old_dentry->d_name.name,
233 old_dentry->d_name.len, &old_de); 239 old_dentry->d_name.len, &old_de);
@@ -264,7 +270,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
264 error = 0; 270 error = 0;
265 271
266end_rename: 272end_rename:
267 unlock_kernel(); 273 mutex_unlock(&info->bfs_lock);
268 brelse(old_bh); 274 brelse(old_bh);
269 brelse(new_bh); 275 brelse(new_bh);
270 return error; 276 return error;
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index b11e63e8fbcd..6a021265f018 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -99,7 +99,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
99 return -ENOSPC; 99 return -ENOSPC;
100 100
101 /* The rest has to be protected against itself. */ 101 /* The rest has to be protected against itself. */
102 lock_kernel(); 102 mutex_lock(&info->bfs_lock);
103 103
104 /* 104 /*
105 * If the last data block for this file is the last allocated 105 * If the last data block for this file is the last allocated
@@ -151,7 +151,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
151 mark_buffer_dirty(sbh); 151 mark_buffer_dirty(sbh);
152 map_bh(bh_result, sb, phys); 152 map_bh(bh_result, sb, phys);
153out: 153out:
154 unlock_kernel(); 154 mutex_unlock(&info->bfs_lock);
155 return err; 155 return err;
156} 156}
157 157
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 8db623838b50..0ed57b5ee012 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -104,6 +104,7 @@ static int bfs_write_inode(struct inode *inode, int unused)
104 struct bfs_inode *di; 104 struct bfs_inode *di;
105 struct buffer_head *bh; 105 struct buffer_head *bh;
106 int block, off; 106 int block, off;
107 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
107 108
108 dprintf("ino=%08x\n", ino); 109 dprintf("ino=%08x\n", ino);
109 110
@@ -112,13 +113,13 @@ static int bfs_write_inode(struct inode *inode, int unused)
112 return -EIO; 113 return -EIO;
113 } 114 }
114 115
115 lock_kernel(); 116 mutex_lock(&info->bfs_lock);
116 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 117 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
117 bh = sb_bread(inode->i_sb, block); 118 bh = sb_bread(inode->i_sb, block);
118 if (!bh) { 119 if (!bh) {
119 printf("Unable to read inode %s:%08x\n", 120 printf("Unable to read inode %s:%08x\n",
120 inode->i_sb->s_id, ino); 121 inode->i_sb->s_id, ino);
121 unlock_kernel(); 122 mutex_unlock(&info->bfs_lock);
122 return -EIO; 123 return -EIO;
123 } 124 }
124 125
@@ -145,7 +146,7 @@ static int bfs_write_inode(struct inode *inode, int unused)
145 146
146 mark_buffer_dirty(bh); 147 mark_buffer_dirty(bh);
147 brelse(bh); 148 brelse(bh);
148 unlock_kernel(); 149 mutex_unlock(&info->bfs_lock);
149 return 0; 150 return 0;
150} 151}
151 152
@@ -170,7 +171,7 @@ static void bfs_delete_inode(struct inode *inode)
170 171
171 inode->i_size = 0; 172 inode->i_size = 0;
172 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 173 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
173 lock_kernel(); 174 mutex_lock(&info->bfs_lock);
174 mark_inode_dirty(inode); 175 mark_inode_dirty(inode);
175 176
176 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 177 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
@@ -178,7 +179,7 @@ static void bfs_delete_inode(struct inode *inode)
178 if (!bh) { 179 if (!bh) {
179 printf("Unable to read inode %s:%08lx\n", 180 printf("Unable to read inode %s:%08lx\n",
180 inode->i_sb->s_id, ino); 181 inode->i_sb->s_id, ino);
181 unlock_kernel(); 182 mutex_unlock(&info->bfs_lock);
182 return; 183 return;
183 } 184 }
184 off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; 185 off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
@@ -204,14 +205,16 @@ static void bfs_delete_inode(struct inode *inode)
204 info->si_lf_eblk = bi->i_sblock - 1; 205 info->si_lf_eblk = bi->i_sblock - 1;
205 mark_buffer_dirty(info->si_sbh); 206 mark_buffer_dirty(info->si_sbh);
206 } 207 }
207 unlock_kernel(); 208 mutex_unlock(&info->bfs_lock);
208 clear_inode(inode); 209 clear_inode(inode);
209} 210}
210 211
211static void bfs_put_super(struct super_block *s) 212static void bfs_put_super(struct super_block *s)
212{ 213{
213 struct bfs_sb_info *info = BFS_SB(s); 214 struct bfs_sb_info *info = BFS_SB(s);
215
214 brelse(info->si_sbh); 216 brelse(info->si_sbh);
217 mutex_destroy(&info->bfs_lock);
215 kfree(info->si_imap); 218 kfree(info->si_imap);
216 kfree(info); 219 kfree(info);
217 s->s_fs_info = NULL; 220 s->s_fs_info = NULL;
@@ -236,11 +239,13 @@ static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf)
236 239
237static void bfs_write_super(struct super_block *s) 240static void bfs_write_super(struct super_block *s)
238{ 241{
239 lock_kernel(); 242 struct bfs_sb_info *info = BFS_SB(s);
243
244 mutex_lock(&info->bfs_lock);
240 if (!(s->s_flags & MS_RDONLY)) 245 if (!(s->s_flags & MS_RDONLY))
241 mark_buffer_dirty(BFS_SB(s)->si_sbh); 246 mark_buffer_dirty(info->si_sbh);
242 s->s_dirt = 0; 247 s->s_dirt = 0;
243 unlock_kernel(); 248 mutex_unlock(&info->bfs_lock);
244} 249}
245 250
246static struct kmem_cache *bfs_inode_cachep; 251static struct kmem_cache *bfs_inode_cachep;
@@ -259,7 +264,7 @@ static void bfs_destroy_inode(struct inode *inode)
259 kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 264 kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
260} 265}
261 266
262static void init_once(struct kmem_cache *cachep, void *foo) 267static void init_once(void *foo)
263{ 268{
264 struct bfs_inode_info *bi = foo; 269 struct bfs_inode_info *bi = foo;
265 270
@@ -380,7 +385,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
380 struct bfs_inode *di; 385 struct bfs_inode *di;
381 int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 386 int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
382 int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; 387 int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
383 unsigned long sblock, eblock; 388 unsigned long eblock;
384 389
385 if (!off) { 390 if (!off) {
386 brelse(bh); 391 brelse(bh);
@@ -399,7 +404,6 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
399 set_bit(i, info->si_imap); 404 set_bit(i, info->si_imap);
400 info->si_freeb -= BFS_FILEBLOCKS(di); 405 info->si_freeb -= BFS_FILEBLOCKS(di);
401 406
402 sblock = le32_to_cpu(di->i_sblock);
403 eblock = le32_to_cpu(di->i_eblock); 407 eblock = le32_to_cpu(di->i_eblock);
404 if (eblock > info->si_lf_eblk) 408 if (eblock > info->si_lf_eblk)
405 info->si_lf_eblk = eblock; 409 info->si_lf_eblk = eblock;
@@ -410,6 +414,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
410 s->s_dirt = 1; 414 s->s_dirt = 1;
411 } 415 }
412 dump_imap("read_super", s); 416 dump_imap("read_super", s);
417 mutex_init(&info->bfs_lock);
413 return 0; 418 return 0;
414 419
415out: 420out:
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index ba4cddb92f1d..204cfd1d7676 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -444,12 +444,6 @@ beyond_if:
444 regs->gp = ex.a_gpvalue; 444 regs->gp = ex.a_gpvalue;
445#endif 445#endif
446 start_thread(regs, ex.a_entry, current->mm->start_stack); 446 start_thread(regs, ex.a_entry, current->mm->start_stack);
447 if (unlikely(current->ptrace & PT_PTRACED)) {
448 if (current->ptrace & PT_TRACE_EXEC)
449 ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
450 else
451 send_sig(SIGTRAP, current, 0);
452 }
453 return 0; 447 return 0;
454} 448}
455 449
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 3b6ff854d983..655ed8d30a86 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1003,12 +1003,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
1003#endif 1003#endif
1004 1004
1005 start_thread(regs, elf_entry, bprm->p); 1005 start_thread(regs, elf_entry, bprm->p);
1006 if (unlikely(current->ptrace & PT_PTRACED)) {
1007 if (current->ptrace & PT_TRACE_EXEC)
1008 ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
1009 else
1010 send_sig(SIGTRAP, current, 0);
1011 }
1012 retval = 0; 1006 retval = 0;
1013out: 1007out:
1014 kfree(loc); 1008 kfree(loc);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 1b59b1edf26d..80c1f952ef78 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -433,13 +433,6 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
433 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; 433 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr;
434 start_thread(regs, entryaddr, current->mm->start_stack); 434 start_thread(regs, entryaddr, current->mm->start_stack);
435 435
436 if (unlikely(current->ptrace & PT_PTRACED)) {
437 if (current->ptrace & PT_TRACE_EXEC)
438 ptrace_notify((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
439 else
440 send_sig(SIGTRAP, current, 0);
441 }
442
443 retval = 0; 436 retval = 0;
444 437
445error: 438error:
@@ -477,6 +470,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
477 char __user *u_platform, *p; 470 char __user *u_platform, *p;
478 long hwcap; 471 long hwcap;
479 int loop; 472 int loop;
473 int nr; /* reset for each csp adjustment */
480 474
481 /* we're going to shovel a whole load of stuff onto the stack */ 475 /* we're going to shovel a whole load of stuff onto the stack */
482#ifdef CONFIG_MMU 476#ifdef CONFIG_MMU
@@ -549,10 +543,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
549 /* force 16 byte _final_ alignment here for generality */ 543 /* force 16 byte _final_ alignment here for generality */
550#define DLINFO_ITEMS 13 544#define DLINFO_ITEMS 13
551 545
552 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0); 546 nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
553#ifdef DLINFO_ARCH_ITEMS
554 nitems += DLINFO_ARCH_ITEMS;
555#endif
556 547
557 csp = sp; 548 csp = sp;
558 sp -= nitems * 2 * sizeof(unsigned long); 549 sp -= nitems * 2 * sizeof(unsigned long);
@@ -564,39 +555,46 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
564 sp -= sp & 15UL; 555 sp -= sp & 15UL;
565 556
566 /* put the ELF interpreter info on the stack */ 557 /* put the ELF interpreter info on the stack */
567#define NEW_AUX_ENT(nr, id, val) \ 558#define NEW_AUX_ENT(id, val) \
568 do { \ 559 do { \
569 struct { unsigned long _id, _val; } __user *ent; \ 560 struct { unsigned long _id, _val; } __user *ent; \
570 \ 561 \
571 ent = (void __user *) csp; \ 562 ent = (void __user *) csp; \
572 __put_user((id), &ent[nr]._id); \ 563 __put_user((id), &ent[nr]._id); \
573 __put_user((val), &ent[nr]._val); \ 564 __put_user((val), &ent[nr]._val); \
565 nr++; \
574 } while (0) 566 } while (0)
575 567
568 nr = 0;
576 csp -= 2 * sizeof(unsigned long); 569 csp -= 2 * sizeof(unsigned long);
577 NEW_AUX_ENT(0, AT_NULL, 0); 570 NEW_AUX_ENT(AT_NULL, 0);
578 if (k_platform) { 571 if (k_platform) {
572 nr = 0;
579 csp -= 2 * sizeof(unsigned long); 573 csp -= 2 * sizeof(unsigned long);
580 NEW_AUX_ENT(0, AT_PLATFORM, 574 NEW_AUX_ENT(AT_PLATFORM,
581 (elf_addr_t) (unsigned long) u_platform); 575 (elf_addr_t) (unsigned long) u_platform);
582 } 576 }
583 577
578 nr = 0;
584 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long); 579 csp -= DLINFO_ITEMS * 2 * sizeof(unsigned long);
585 NEW_AUX_ENT( 0, AT_HWCAP, hwcap); 580 NEW_AUX_ENT(AT_HWCAP, hwcap);
586 NEW_AUX_ENT( 1, AT_PAGESZ, PAGE_SIZE); 581 NEW_AUX_ENT(AT_PAGESZ, PAGE_SIZE);
587 NEW_AUX_ENT( 2, AT_CLKTCK, CLOCKS_PER_SEC); 582 NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC);
588 NEW_AUX_ENT( 3, AT_PHDR, exec_params->ph_addr); 583 NEW_AUX_ENT(AT_PHDR, exec_params->ph_addr);
589 NEW_AUX_ENT( 4, AT_PHENT, sizeof(struct elf_phdr)); 584 NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr));
590 NEW_AUX_ENT( 5, AT_PHNUM, exec_params->hdr.e_phnum); 585 NEW_AUX_ENT(AT_PHNUM, exec_params->hdr.e_phnum);
591 NEW_AUX_ENT( 6, AT_BASE, interp_params->elfhdr_addr); 586 NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr);
592 NEW_AUX_ENT( 7, AT_FLAGS, 0); 587 NEW_AUX_ENT(AT_FLAGS, 0);
593 NEW_AUX_ENT( 8, AT_ENTRY, exec_params->entry_addr); 588 NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr);
594 NEW_AUX_ENT( 9, AT_UID, (elf_addr_t) current->uid); 589 NEW_AUX_ENT(AT_UID, (elf_addr_t) current->uid);
595 NEW_AUX_ENT(10, AT_EUID, (elf_addr_t) current->euid); 590 NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid);
596 NEW_AUX_ENT(11, AT_GID, (elf_addr_t) current->gid); 591 NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid);
597 NEW_AUX_ENT(12, AT_EGID, (elf_addr_t) current->egid); 592 NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid);
598 593
599#ifdef ARCH_DLINFO 594#ifdef ARCH_DLINFO
595 nr = 0;
596 csp -= AT_VECTOR_SIZE_ARCH * 2 * sizeof(unsigned long);
597
600 /* ARCH_DLINFO must come last so platform specific code can enforce 598 /* ARCH_DLINFO must come last so platform specific code can enforce
601 * special alignment requirements on the AUXV if necessary (eg. PPC). 599 * special alignment requirements on the AUXV if necessary (eg. PPC).
602 */ 600 */
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 2cb1acda3a82..56372ecf1690 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -920,9 +920,6 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)
920 920
921 start_thread(regs, start_addr, current->mm->start_stack); 921 start_thread(regs, start_addr, current->mm->start_stack);
922 922
923 if (current->ptrace & PT_PTRACED)
924 send_sig(SIGTRAP, current, 0);
925
926 return 0; 923 return 0;
927} 924}
928 925
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
index fdc36bfd6a7b..68be580ba289 100644
--- a/fs/binfmt_som.c
+++ b/fs/binfmt_som.c
@@ -274,8 +274,6 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
274 map_hpux_gateway_page(current,current->mm); 274 map_hpux_gateway_page(current,current->mm);
275 275
276 start_thread_som(regs, som_entry, bprm->p); 276 start_thread_som(regs, som_entry, bprm->p);
277 if (current->ptrace & PT_PTRACED)
278 send_sig(SIGTRAP, current, 0);
279 return 0; 277 return 0;
280 278
281 /* error cleanup */ 279 /* error cleanup */
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 63e2ee63058d..c3e174b35fe6 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -705,7 +705,6 @@ void __init bio_integrity_init_slab(void)
705 bio_integrity_slab = KMEM_CACHE(bio_integrity_payload, 705 bio_integrity_slab = KMEM_CACHE(bio_integrity_payload,
706 SLAB_HWCACHE_ALIGN|SLAB_PANIC); 706 SLAB_HWCACHE_ALIGN|SLAB_PANIC);
707} 707}
708EXPORT_SYMBOL(bio_integrity_init_slab);
709 708
710static int __init integrity_init(void) 709static int __init integrity_init(void)
711{ 710{
diff --git a/fs/bio.c b/fs/bio.c
index 88322b066acb..25f1af0d81e5 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -721,12 +721,8 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
721 const int local_nr_pages = end - start; 721 const int local_nr_pages = end - start;
722 const int page_limit = cur_page + local_nr_pages; 722 const int page_limit = cur_page + local_nr_pages;
723 723
724 down_read(&current->mm->mmap_sem); 724 ret = get_user_pages_fast(uaddr, local_nr_pages,
725 ret = get_user_pages(current, current->mm, uaddr, 725 write_to_vm, &pages[cur_page]);
726 local_nr_pages,
727 write_to_vm, 0, &pages[cur_page], NULL);
728 up_read(&current->mm->mmap_sem);
729
730 if (ret < local_nr_pages) { 726 if (ret < local_nr_pages) {
731 ret = -EFAULT; 727 ret = -EFAULT;
732 goto out_unmap; 728 goto out_unmap;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 10d8a0aa871a..dcf37cada369 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -271,7 +271,7 @@ static void bdev_destroy_inode(struct inode *inode)
271 kmem_cache_free(bdev_cachep, bdi); 271 kmem_cache_free(bdev_cachep, bdi);
272} 272}
273 273
274static void init_once(struct kmem_cache * cachep, void *foo) 274static void init_once(void *foo)
275{ 275{
276 struct bdev_inode *ei = (struct bdev_inode *) foo; 276 struct bdev_inode *ei = (struct bdev_inode *) foo;
277 struct block_device *bdev = &ei->bdev; 277 struct block_device *bdev = &ei->bdev;
diff --git a/fs/buffer.c b/fs/buffer.c
index d48caee12e2a..ca12a6bb82b1 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -706,7 +706,7 @@ static int __set_page_dirty(struct page *page,
706 if (TestSetPageDirty(page)) 706 if (TestSetPageDirty(page))
707 return 0; 707 return 0;
708 708
709 write_lock_irq(&mapping->tree_lock); 709 spin_lock_irq(&mapping->tree_lock);
710 if (page->mapping) { /* Race with truncate? */ 710 if (page->mapping) { /* Race with truncate? */
711 WARN_ON_ONCE(warn && !PageUptodate(page)); 711 WARN_ON_ONCE(warn && !PageUptodate(page));
712 712
@@ -719,7 +719,7 @@ static int __set_page_dirty(struct page *page,
719 radix_tree_tag_set(&mapping->page_tree, 719 radix_tree_tag_set(&mapping->page_tree,
720 page_index(page), PAGECACHE_TAG_DIRTY); 720 page_index(page), PAGECACHE_TAG_DIRTY);
721 } 721 }
722 write_unlock_irq(&mapping->tree_lock); 722 spin_unlock_irq(&mapping->tree_lock);
723 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 723 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
724 724
725 return 1; 725 return 1;
@@ -1214,8 +1214,7 @@ void __brelse(struct buffer_head * buf)
1214 put_bh(buf); 1214 put_bh(buf);
1215 return; 1215 return;
1216 } 1216 }
1217 printk(KERN_ERR "VFS: brelse: Trying to free free buffer\n"); 1217 WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n");
1218 WARN_ON(1);
1219} 1218}
1220 1219
1221/* 1220/*
@@ -2097,6 +2096,52 @@ int generic_write_end(struct file *file, struct address_space *mapping,
2097EXPORT_SYMBOL(generic_write_end); 2096EXPORT_SYMBOL(generic_write_end);
2098 2097
2099/* 2098/*
2099 * block_is_partially_uptodate checks whether buffers within a page are
2100 * uptodate or not.
2101 *
2102 * Returns true if all buffers which correspond to a file portion
2103 * we want to read are uptodate.
2104 */
2105int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
2106 unsigned long from)
2107{
2108 struct inode *inode = page->mapping->host;
2109 unsigned block_start, block_end, blocksize;
2110 unsigned to;
2111 struct buffer_head *bh, *head;
2112 int ret = 1;
2113
2114 if (!page_has_buffers(page))
2115 return 0;
2116
2117 blocksize = 1 << inode->i_blkbits;
2118 to = min_t(unsigned, PAGE_CACHE_SIZE - from, desc->count);
2119 to = from + to;
2120 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize)
2121 return 0;
2122
2123 head = page_buffers(page);
2124 bh = head;
2125 block_start = 0;
2126 do {
2127 block_end = block_start + blocksize;
2128 if (block_end > from && block_start < to) {
2129 if (!buffer_uptodate(bh)) {
2130 ret = 0;
2131 break;
2132 }
2133 if (block_end >= to)
2134 break;
2135 }
2136 block_start = block_end;
2137 bh = bh->b_this_page;
2138 } while (bh != head);
2139
2140 return ret;
2141}
2142EXPORT_SYMBOL(block_is_partially_uptodate);
2143
2144/*
2100 * Generic "read page" function for block devices that have the normal 2145 * Generic "read page" function for block devices that have the normal
2101 * get_block functionality. This is most of the block device filesystems. 2146 * get_block functionality. This is most of the block device filesystems.
2102 * Reads the page asynchronously --- the unlock_buffer() and 2147 * Reads the page asynchronously --- the unlock_buffer() and
@@ -3272,7 +3317,7 @@ int bh_submit_read(struct buffer_head *bh)
3272EXPORT_SYMBOL(bh_submit_read); 3317EXPORT_SYMBOL(bh_submit_read);
3273 3318
3274static void 3319static void
3275init_buffer_head(struct kmem_cache *cachep, void *data) 3320init_buffer_head(void *data)
3276{ 3321{
3277 struct buffer_head *bh = data; 3322 struct buffer_head *bh = data;
3278 3323
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index f58e41d3ba48..6bb440b257b0 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
400 size = eoc - ctx->pointer + 1; 400 size = eoc - ctx->pointer + 1;
401 401
402 /* first subid actually encodes first two subids */ 402 /* first subid actually encodes first two subids */
403 if (size < 2 || size > ULONG_MAX/sizeof(unsigned long)) 403 if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
404 return 0; 404 return 0;
405 405
406 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); 406 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
@@ -494,7 +494,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
494 /* remember to free obj->oid */ 494 /* remember to free obj->oid */
495 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); 495 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
496 if (rc) { 496 if (rc) {
497 if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { 497 if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
498 rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); 498 rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
499 if (rc) { 499 if (rc) {
500 rc = compare_oid(oid, oidlen, 500 rc = compare_oid(oid, oidlen,
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index cc950f69e51e..688a2d42153f 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -107,9 +107,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
107#endif /* CONFIG_CIFS_DEBUG2 */ 107#endif /* CONFIG_CIFS_DEBUG2 */
108 108
109#ifdef CONFIG_PROC_FS 109#ifdef CONFIG_PROC_FS
110static int 110static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
111cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
112 int count, int *eof, void *data)
113{ 111{
114 struct list_head *tmp; 112 struct list_head *tmp;
115 struct list_head *tmp1; 113 struct list_head *tmp1;
@@ -117,23 +115,13 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
117 struct cifsSesInfo *ses; 115 struct cifsSesInfo *ses;
118 struct cifsTconInfo *tcon; 116 struct cifsTconInfo *tcon;
119 int i; 117 int i;
120 int length = 0;
121 char *original_buf = buf;
122 118
123 *beginBuffer = buf + offset; 119 seq_puts(m,
124
125 length =
126 sprintf(buf,
127 "Display Internal CIFS Data Structures for Debugging\n" 120 "Display Internal CIFS Data Structures for Debugging\n"
128 "---------------------------------------------------\n"); 121 "---------------------------------------------------\n");
129 buf += length; 122 seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
130 length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); 123 seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
131 buf += length; 124 seq_printf(m, "Servers:");
132 length = sprintf(buf,
133 "Active VFS Requests: %d\n", GlobalTotalActiveXid);
134 buf += length;
135 length = sprintf(buf, "Servers:");
136 buf += length;
137 125
138 i = 0; 126 i = 0;
139 read_lock(&GlobalSMBSeslock); 127 read_lock(&GlobalSMBSeslock);
@@ -142,11 +130,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
142 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 130 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
143 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || 131 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
144 (ses->serverNOS == NULL)) { 132 (ses->serverNOS == NULL)) {
145 buf += sprintf(buf, "\nentry for %s not fully " 133 seq_printf(m, "\nentry for %s not fully "
146 "displayed\n\t", ses->serverName); 134 "displayed\n\t", ses->serverName);
147 } else { 135 } else {
148 length = 136 seq_printf(m,
149 sprintf(buf,
150 "\n%d) Name: %s Domain: %s Mounts: %d OS:" 137 "\n%d) Name: %s Domain: %s Mounts: %d OS:"
151 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" 138 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
152 " session status: %d\t", 139 " session status: %d\t",
@@ -154,10 +141,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
154 atomic_read(&ses->inUse), 141 atomic_read(&ses->inUse),
155 ses->serverOS, ses->serverNOS, 142 ses->serverOS, ses->serverNOS,
156 ses->capabilities, ses->status); 143 ses->capabilities, ses->status);
157 buf += length;
158 } 144 }
159 if (ses->server) { 145 if (ses->server) {
160 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " 146 seq_printf(m, "TCP status: %d\n\tLocal Users To "
161 "Server: %d SecMode: 0x%x Req On Wire: %d", 147 "Server: %d SecMode: 0x%x Req On Wire: %d",
162 ses->server->tcpStatus, 148 ses->server->tcpStatus,
163 atomic_read(&ses->server->socketUseCount), 149 atomic_read(&ses->server->socketUseCount),
@@ -165,13 +151,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
165 atomic_read(&ses->server->inFlight)); 151 atomic_read(&ses->server->inFlight));
166 152
167#ifdef CONFIG_CIFS_STATS2 153#ifdef CONFIG_CIFS_STATS2
168 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", 154 seq_printf(m, " In Send: %d In MaxReq Wait: %d",
169 atomic_read(&ses->server->inSend), 155 atomic_read(&ses->server->inSend),
170 atomic_read(&ses->server->num_waiters)); 156 atomic_read(&ses->server->num_waiters));
171#endif 157#endif
172 158
173 length = sprintf(buf, "\nMIDs:\n"); 159 seq_puts(m, "\nMIDs:\n");
174 buf += length;
175 160
176 spin_lock(&GlobalMid_Lock); 161 spin_lock(&GlobalMid_Lock);
177 list_for_each(tmp1, &ses->server->pending_mid_q) { 162 list_for_each(tmp1, &ses->server->pending_mid_q) {
@@ -179,7 +164,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
179 mid_q_entry, 164 mid_q_entry,
180 qhead); 165 qhead);
181 if (mid_entry) { 166 if (mid_entry) {
182 length = sprintf(buf, 167 seq_printf(m,
183 "State: %d com: %d pid:" 168 "State: %d com: %d pid:"
184 " %d tsk: %p mid %d\n", 169 " %d tsk: %p mid %d\n",
185 mid_entry->midState, 170 mid_entry->midState,
@@ -187,7 +172,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
187 mid_entry->pid, 172 mid_entry->pid,
188 mid_entry->tsk, 173 mid_entry->tsk,
189 mid_entry->mid); 174 mid_entry->mid);
190 buf += length;
191 } 175 }
192 } 176 }
193 spin_unlock(&GlobalMid_Lock); 177 spin_unlock(&GlobalMid_Lock);
@@ -195,11 +179,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
195 179
196 } 180 }
197 read_unlock(&GlobalSMBSeslock); 181 read_unlock(&GlobalSMBSeslock);
198 sprintf(buf, "\n"); 182 seq_putc(m, '\n');
199 buf++;
200 183
201 length = sprintf(buf, "Shares:"); 184 seq_puts(m, "Shares:");
202 buf += length;
203 185
204 i = 0; 186 i = 0;
205 read_lock(&GlobalSMBSeslock); 187 read_lock(&GlobalSMBSeslock);
@@ -208,62 +190,52 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
208 i++; 190 i++;
209 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 191 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
210 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 192 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
211 length = sprintf(buf, "\n%d) %s Uses: %d ", i, 193 seq_printf(m, "\n%d) %s Uses: %d ", i,
212 tcon->treeName, atomic_read(&tcon->useCount)); 194 tcon->treeName, atomic_read(&tcon->useCount));
213 buf += length;
214 if (tcon->nativeFileSystem) { 195 if (tcon->nativeFileSystem) {
215 length = sprintf(buf, "Type: %s ", 196 seq_printf(m, "Type: %s ",
216 tcon->nativeFileSystem); 197 tcon->nativeFileSystem);
217 buf += length;
218 } 198 }
219 length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" 199 seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
220 "\nPathComponentMax: %d Status: %d", 200 "\nPathComponentMax: %d Status: %d",
221 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), 201 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
222 le32_to_cpu(tcon->fsAttrInfo.Attributes), 202 le32_to_cpu(tcon->fsAttrInfo.Attributes),
223 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), 203 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
224 tcon->tidStatus); 204 tcon->tidStatus);
225 buf += length;
226 if (dev_type == FILE_DEVICE_DISK) 205 if (dev_type == FILE_DEVICE_DISK)
227 length = sprintf(buf, " type: DISK "); 206 seq_puts(m, " type: DISK ");
228 else if (dev_type == FILE_DEVICE_CD_ROM) 207 else if (dev_type == FILE_DEVICE_CD_ROM)
229 length = sprintf(buf, " type: CDROM "); 208 seq_puts(m, " type: CDROM ");
230 else 209 else
231 length = 210 seq_printf(m, " type: %d ", dev_type);
232 sprintf(buf, " type: %d ", dev_type); 211
233 buf += length; 212 if (tcon->tidStatus == CifsNeedReconnect)
234 if (tcon->tidStatus == CifsNeedReconnect) { 213 seq_puts(m, "\tDISCONNECTED ");
235 buf += sprintf(buf, "\tDISCONNECTED ");
236 length += 14;
237 }
238 } 214 }
239 read_unlock(&GlobalSMBSeslock); 215 read_unlock(&GlobalSMBSeslock);
240 216
241 length = sprintf(buf, "\n"); 217 seq_putc(m, '\n');
242 buf += length;
243 218
244 /* BB add code to dump additional info such as TCP session info now */ 219 /* BB add code to dump additional info such as TCP session info now */
245 /* Now calculate total size of returned data */ 220 return 0;
246 length = buf - original_buf; 221}
247
248 if (offset + count >= length)
249 *eof = 1;
250 if (length < offset) {
251 *eof = 1;
252 return 0;
253 } else {
254 length = length - offset;
255 }
256 if (length > count)
257 length = count;
258 222
259 return length; 223static int cifs_debug_data_proc_open(struct inode *inode, struct file *file)
224{
225 return single_open(file, cifs_debug_data_proc_show, NULL);
260} 226}
261 227
262#ifdef CONFIG_CIFS_STATS 228static const struct file_operations cifs_debug_data_proc_fops = {
229 .owner = THIS_MODULE,
230 .open = cifs_debug_data_proc_open,
231 .read = seq_read,
232 .llseek = seq_lseek,
233 .release = single_release,
234};
263 235
264static int 236#ifdef CONFIG_CIFS_STATS
265cifs_stats_write(struct file *file, const char __user *buffer, 237static ssize_t cifs_stats_proc_write(struct file *file,
266 unsigned long count, void *data) 238 const char __user *buffer, size_t count, loff_t *ppos)
267{ 239{
268 char c; 240 char c;
269 int rc; 241 int rc;
@@ -307,236 +279,132 @@ cifs_stats_write(struct file *file, const char __user *buffer,
307 return count; 279 return count;
308} 280}
309 281
310static int 282static int cifs_stats_proc_show(struct seq_file *m, void *v)
311cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
312 int count, int *eof, void *data)
313{ 283{
314 int item_length, i, length; 284 int i;
315 struct list_head *tmp; 285 struct list_head *tmp;
316 struct cifsTconInfo *tcon; 286 struct cifsTconInfo *tcon;
317 287
318 *beginBuffer = buf + offset; 288 seq_printf(m,
319
320 length = sprintf(buf,
321 "Resources in use\nCIFS Session: %d\n", 289 "Resources in use\nCIFS Session: %d\n",
322 sesInfoAllocCount.counter); 290 sesInfoAllocCount.counter);
323 buf += length; 291 seq_printf(m, "Share (unique mount targets): %d\n",
324 item_length =
325 sprintf(buf, "Share (unique mount targets): %d\n",
326 tconInfoAllocCount.counter); 292 tconInfoAllocCount.counter);
327 length += item_length; 293 seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
328 buf += item_length;
329 item_length =
330 sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
331 bufAllocCount.counter, 294 bufAllocCount.counter,
332 cifs_min_rcv + tcpSesAllocCount.counter); 295 cifs_min_rcv + tcpSesAllocCount.counter);
333 length += item_length; 296 seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
334 buf += item_length;
335 item_length =
336 sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
337 smBufAllocCount.counter, cifs_min_small); 297 smBufAllocCount.counter, cifs_min_small);
338 length += item_length;
339 buf += item_length;
340#ifdef CONFIG_CIFS_STATS2 298#ifdef CONFIG_CIFS_STATS2
341 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", 299 seq_printf(m, "Total Large %d Small %d Allocations\n",
342 atomic_read(&totBufAllocCount), 300 atomic_read(&totBufAllocCount),
343 atomic_read(&totSmBufAllocCount)); 301 atomic_read(&totSmBufAllocCount));
344 length += item_length;
345 buf += item_length;
346#endif /* CONFIG_CIFS_STATS2 */ 302#endif /* CONFIG_CIFS_STATS2 */
347 303
348 item_length = 304 seq_printf(m, "Operations (MIDs): %d\n", midCount.counter);
349 sprintf(buf, "Operations (MIDs): %d\n", 305 seq_printf(m,
350 midCount.counter);
351 length += item_length;
352 buf += item_length;
353 item_length = sprintf(buf,
354 "\n%d session %d share reconnects\n", 306 "\n%d session %d share reconnects\n",
355 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); 307 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
356 length += item_length;
357 buf += item_length;
358 308
359 item_length = sprintf(buf, 309 seq_printf(m,
360 "Total vfs operations: %d maximum at one time: %d\n", 310 "Total vfs operations: %d maximum at one time: %d\n",
361 GlobalCurrentXid, GlobalMaxActiveXid); 311 GlobalCurrentXid, GlobalMaxActiveXid);
362 length += item_length;
363 buf += item_length;
364 312
365 i = 0; 313 i = 0;
366 read_lock(&GlobalSMBSeslock); 314 read_lock(&GlobalSMBSeslock);
367 list_for_each(tmp, &GlobalTreeConnectionList) { 315 list_for_each(tmp, &GlobalTreeConnectionList) {
368 i++; 316 i++;
369 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 317 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
370 item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); 318 seq_printf(m, "\n%d) %s", i, tcon->treeName);
371 buf += item_length; 319 if (tcon->tidStatus == CifsNeedReconnect)
372 length += item_length; 320 seq_puts(m, "\tDISCONNECTED ");
373 if (tcon->tidStatus == CifsNeedReconnect) { 321 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
374 buf += sprintf(buf, "\tDISCONNECTED ");
375 length += 14;
376 }
377 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
378 atomic_read(&tcon->num_smbs_sent), 322 atomic_read(&tcon->num_smbs_sent),
379 atomic_read(&tcon->num_oplock_brks)); 323 atomic_read(&tcon->num_oplock_brks));
380 buf += item_length; 324 seq_printf(m, "\nReads: %d Bytes: %lld",
381 length += item_length;
382 item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
383 atomic_read(&tcon->num_reads), 325 atomic_read(&tcon->num_reads),
384 (long long)(tcon->bytes_read)); 326 (long long)(tcon->bytes_read));
385 buf += item_length; 327 seq_printf(m, "\nWrites: %d Bytes: %lld",
386 length += item_length;
387 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
388 atomic_read(&tcon->num_writes), 328 atomic_read(&tcon->num_writes),
389 (long long)(tcon->bytes_written)); 329 (long long)(tcon->bytes_written));
390 buf += item_length; 330 seq_printf(m,
391 length += item_length;
392 item_length = sprintf(buf,
393 "\nLocks: %d HardLinks: %d Symlinks: %d", 331 "\nLocks: %d HardLinks: %d Symlinks: %d",
394 atomic_read(&tcon->num_locks), 332 atomic_read(&tcon->num_locks),
395 atomic_read(&tcon->num_hardlinks), 333 atomic_read(&tcon->num_hardlinks),
396 atomic_read(&tcon->num_symlinks)); 334 atomic_read(&tcon->num_symlinks));
397 buf += item_length;
398 length += item_length;
399 335
400 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", 336 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
401 atomic_read(&tcon->num_opens), 337 atomic_read(&tcon->num_opens),
402 atomic_read(&tcon->num_closes), 338 atomic_read(&tcon->num_closes),
403 atomic_read(&tcon->num_deletes)); 339 atomic_read(&tcon->num_deletes));
404 buf += item_length; 340 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
405 length += item_length;
406 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
407 atomic_read(&tcon->num_mkdirs), 341 atomic_read(&tcon->num_mkdirs),
408 atomic_read(&tcon->num_rmdirs)); 342 atomic_read(&tcon->num_rmdirs));
409 buf += item_length; 343 seq_printf(m, "\nRenames: %d T2 Renames %d",
410 length += item_length;
411 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
412 atomic_read(&tcon->num_renames), 344 atomic_read(&tcon->num_renames),
413 atomic_read(&tcon->num_t2renames)); 345 atomic_read(&tcon->num_t2renames));
414 buf += item_length; 346 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
415 length += item_length;
416 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
417 atomic_read(&tcon->num_ffirst), 347 atomic_read(&tcon->num_ffirst),
418 atomic_read(&tcon->num_fnext), 348 atomic_read(&tcon->num_fnext),
419 atomic_read(&tcon->num_fclose)); 349 atomic_read(&tcon->num_fclose));
420 buf += item_length;
421 length += item_length;
422 } 350 }
423 read_unlock(&GlobalSMBSeslock); 351 read_unlock(&GlobalSMBSeslock);
424 352
425 buf += sprintf(buf, "\n"); 353 seq_putc(m, '\n');
426 length++; 354 return 0;
427 355}
428 if (offset + count >= length)
429 *eof = 1;
430 if (length < offset) {
431 *eof = 1;
432 return 0;
433 } else {
434 length = length - offset;
435 }
436 if (length > count)
437 length = count;
438 356
439 return length; 357static int cifs_stats_proc_open(struct inode *inode, struct file *file)
358{
359 return single_open(file, cifs_stats_proc_show, NULL);
440} 360}
361
362static const struct file_operations cifs_stats_proc_fops = {
363 .owner = THIS_MODULE,
364 .open = cifs_stats_proc_open,
365 .read = seq_read,
366 .llseek = seq_lseek,
367 .release = single_release,
368 .write = cifs_stats_proc_write,
369};
441#endif /* STATS */ 370#endif /* STATS */
442 371
443static struct proc_dir_entry *proc_fs_cifs; 372static struct proc_dir_entry *proc_fs_cifs;
444read_proc_t cifs_txanchor_read; 373static const struct file_operations cifsFYI_proc_fops;
445static read_proc_t cifsFYI_read; 374static const struct file_operations cifs_oplock_proc_fops;
446static write_proc_t cifsFYI_write; 375static const struct file_operations cifs_lookup_cache_proc_fops;
447static read_proc_t oplockEnabled_read; 376static const struct file_operations traceSMB_proc_fops;
448static write_proc_t oplockEnabled_write; 377static const struct file_operations cifs_multiuser_mount_proc_fops;
449static read_proc_t lookupFlag_read; 378static const struct file_operations cifs_security_flags_proc_fops;
450static write_proc_t lookupFlag_write; 379static const struct file_operations cifs_experimental_proc_fops;
451static read_proc_t traceSMB_read; 380static const struct file_operations cifs_linux_ext_proc_fops;
452static write_proc_t traceSMB_write;
453static read_proc_t multiuser_mount_read;
454static write_proc_t multiuser_mount_write;
455static read_proc_t security_flags_read;
456static write_proc_t security_flags_write;
457/* static read_proc_t ntlmv2_enabled_read;
458static write_proc_t ntlmv2_enabled_write;
459static read_proc_t packet_signing_enabled_read;
460static write_proc_t packet_signing_enabled_write;*/
461static read_proc_t experimEnabled_read;
462static write_proc_t experimEnabled_write;
463static read_proc_t linuxExtensionsEnabled_read;
464static write_proc_t linuxExtensionsEnabled_write;
465 381
466void 382void
467cifs_proc_init(void) 383cifs_proc_init(void)
468{ 384{
469 struct proc_dir_entry *pde;
470
471 proc_fs_cifs = proc_mkdir("fs/cifs", NULL); 385 proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
472 if (proc_fs_cifs == NULL) 386 if (proc_fs_cifs == NULL)
473 return; 387 return;
474 388
475 proc_fs_cifs->owner = THIS_MODULE; 389 proc_fs_cifs->owner = THIS_MODULE;
476 create_proc_read_entry("DebugData", 0, proc_fs_cifs, 390 proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
477 cifs_debug_data_read, NULL);
478 391
479#ifdef CONFIG_CIFS_STATS 392#ifdef CONFIG_CIFS_STATS
480 pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, 393 proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops);
481 cifs_stats_read, NULL);
482 if (pde)
483 pde->write_proc = cifs_stats_write;
484#endif /* STATS */ 394#endif /* STATS */
485 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, 395 proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops);
486 cifsFYI_read, NULL); 396 proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
487 if (pde) 397 proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops);
488 pde->write_proc = cifsFYI_write; 398 proc_create("Experimental", 0, proc_fs_cifs,
489 399 &cifs_experimental_proc_fops);
490 pde = 400 proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
491 create_proc_read_entry("traceSMB", 0, proc_fs_cifs, 401 &cifs_linux_ext_proc_fops);
492 traceSMB_read, NULL); 402 proc_create("MultiuserMount", 0, proc_fs_cifs,
493 if (pde) 403 &cifs_multiuser_mount_proc_fops);
494 pde->write_proc = traceSMB_write; 404 proc_create("SecurityFlags", 0, proc_fs_cifs,
495 405 &cifs_security_flags_proc_fops);
496 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, 406 proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
497 oplockEnabled_read, NULL); 407 &cifs_lookup_cache_proc_fops);
498 if (pde)
499 pde->write_proc = oplockEnabled_write;
500
501 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
502 experimEnabled_read, NULL);
503 if (pde)
504 pde->write_proc = experimEnabled_write;
505
506 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
507 linuxExtensionsEnabled_read, NULL);
508 if (pde)
509 pde->write_proc = linuxExtensionsEnabled_write;
510
511 pde =
512 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
513 multiuser_mount_read, NULL);
514 if (pde)
515 pde->write_proc = multiuser_mount_write;
516
517 pde =
518 create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
519 security_flags_read, NULL);
520 if (pde)
521 pde->write_proc = security_flags_write;
522
523 pde =
524 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
525 lookupFlag_read, NULL);
526 if (pde)
527 pde->write_proc = lookupFlag_write;
528
529/* pde =
530 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
531 ntlmv2_enabled_read, NULL);
532 if (pde)
533 pde->write_proc = ntlmv2_enabled_write;
534
535 pde =
536 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
537 packet_signing_enabled_read, NULL);
538 if (pde)
539 pde->write_proc = packet_signing_enabled_write;*/
540} 408}
541 409
542void 410void
@@ -553,39 +421,26 @@ cifs_proc_clean(void)
553#endif 421#endif
554 remove_proc_entry("MultiuserMount", proc_fs_cifs); 422 remove_proc_entry("MultiuserMount", proc_fs_cifs);
555 remove_proc_entry("OplockEnabled", proc_fs_cifs); 423 remove_proc_entry("OplockEnabled", proc_fs_cifs);
556/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
557 remove_proc_entry("SecurityFlags", proc_fs_cifs); 424 remove_proc_entry("SecurityFlags", proc_fs_cifs);
558/* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
559 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); 425 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
560 remove_proc_entry("Experimental", proc_fs_cifs); 426 remove_proc_entry("Experimental", proc_fs_cifs);
561 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); 427 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
562 remove_proc_entry("fs/cifs", NULL); 428 remove_proc_entry("fs/cifs", NULL);
563} 429}
564 430
565static int 431static int cifsFYI_proc_show(struct seq_file *m, void *v)
566cifsFYI_read(char *page, char **start, off_t off, int count,
567 int *eof, void *data)
568{ 432{
569 int len; 433 seq_printf(m, "%d\n", cifsFYI);
570 434 return 0;
571 len = sprintf(page, "%d\n", cifsFYI); 435}
572
573 len -= off;
574 *start = page + off;
575
576 if (len > count)
577 len = count;
578 else
579 *eof = 1;
580
581 if (len < 0)
582 len = 0;
583 436
584 return len; 437static int cifsFYI_proc_open(struct inode *inode, struct file *file)
438{
439 return single_open(file, cifsFYI_proc_show, NULL);
585} 440}
586static int 441
587cifsFYI_write(struct file *file, const char __user *buffer, 442static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
588 unsigned long count, void *data) 443 size_t count, loff_t *ppos)
589{ 444{
590 char c; 445 char c;
591 int rc; 446 int rc;
@@ -603,30 +458,28 @@ cifsFYI_write(struct file *file, const char __user *buffer,
603 return count; 458 return count;
604} 459}
605 460
606static int 461static const struct file_operations cifsFYI_proc_fops = {
607oplockEnabled_read(char *page, char **start, off_t off, 462 .owner = THIS_MODULE,
608 int count, int *eof, void *data) 463 .open = cifsFYI_proc_open,
609{ 464 .read = seq_read,
610 int len; 465 .llseek = seq_lseek,
611 466 .release = single_release,
612 len = sprintf(page, "%d\n", oplockEnabled); 467 .write = cifsFYI_proc_write,
613 468};
614 len -= off;
615 *start = page + off;
616
617 if (len > count)
618 len = count;
619 else
620 *eof = 1;
621 469
622 if (len < 0) 470static int cifs_oplock_proc_show(struct seq_file *m, void *v)
623 len = 0; 471{
472 seq_printf(m, "%d\n", oplockEnabled);
473 return 0;
474}
624 475
625 return len; 476static int cifs_oplock_proc_open(struct inode *inode, struct file *file)
477{
478 return single_open(file, cifs_oplock_proc_show, NULL);
626} 479}
627static int 480
628oplockEnabled_write(struct file *file, const char __user *buffer, 481static ssize_t cifs_oplock_proc_write(struct file *file,
629 unsigned long count, void *data) 482 const char __user *buffer, size_t count, loff_t *ppos)
630{ 483{
631 char c; 484 char c;
632 int rc; 485 int rc;
@@ -642,30 +495,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
642 return count; 495 return count;
643} 496}
644 497
645static int 498static const struct file_operations cifs_oplock_proc_fops = {
646experimEnabled_read(char *page, char **start, off_t off, 499 .owner = THIS_MODULE,
647 int count, int *eof, void *data) 500 .open = cifs_oplock_proc_open,
648{ 501 .read = seq_read,
649 int len; 502 .llseek = seq_lseek,
650 503 .release = single_release,
651 len = sprintf(page, "%d\n", experimEnabled); 504 .write = cifs_oplock_proc_write,
652 505};
653 len -= off;
654 *start = page + off;
655 506
656 if (len > count) 507static int cifs_experimental_proc_show(struct seq_file *m, void *v)
657 len = count; 508{
658 else 509 seq_printf(m, "%d\n", experimEnabled);
659 *eof = 1; 510 return 0;
660 511}
661 if (len < 0)
662 len = 0;
663 512
664 return len; 513static int cifs_experimental_proc_open(struct inode *inode, struct file *file)
514{
515 return single_open(file, cifs_experimental_proc_show, NULL);
665} 516}
666static int 517
667experimEnabled_write(struct file *file, const char __user *buffer, 518static ssize_t cifs_experimental_proc_write(struct file *file,
668 unsigned long count, void *data) 519 const char __user *buffer, size_t count, loff_t *ppos)
669{ 520{
670 char c; 521 char c;
671 int rc; 522 int rc;
@@ -683,29 +534,28 @@ experimEnabled_write(struct file *file, const char __user *buffer,
683 return count; 534 return count;
684} 535}
685 536
686static int 537static const struct file_operations cifs_experimental_proc_fops = {
687linuxExtensionsEnabled_read(char *page, char **start, off_t off, 538 .owner = THIS_MODULE,
688 int count, int *eof, void *data) 539 .open = cifs_experimental_proc_open,
689{ 540 .read = seq_read,
690 int len; 541 .llseek = seq_lseek,
691 542 .release = single_release,
692 len = sprintf(page, "%d\n", linuxExtEnabled); 543 .write = cifs_experimental_proc_write,
693 len -= off; 544};
694 *start = page + off;
695 545
696 if (len > count) 546static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
697 len = count; 547{
698 else 548 seq_printf(m, "%d\n", linuxExtEnabled);
699 *eof = 1; 549 return 0;
700 550}
701 if (len < 0)
702 len = 0;
703 551
704 return len; 552static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
553{
554 return single_open(file, cifs_linux_ext_proc_show, NULL);
705} 555}
706static int 556
707linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, 557static ssize_t cifs_linux_ext_proc_write(struct file *file,
708 unsigned long count, void *data) 558 const char __user *buffer, size_t count, loff_t *ppos)
709{ 559{
710 char c; 560 char c;
711 int rc; 561 int rc;
@@ -721,31 +571,28 @@ linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
721 return count; 571 return count;
722} 572}
723 573
574static const struct file_operations cifs_linux_ext_proc_fops = {
575 .owner = THIS_MODULE,
576 .open = cifs_linux_ext_proc_open,
577 .read = seq_read,
578 .llseek = seq_lseek,
579 .release = single_release,
580 .write = cifs_linux_ext_proc_write,
581};
724 582
725static int 583static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
726lookupFlag_read(char *page, char **start, off_t off,
727 int count, int *eof, void *data)
728{ 584{
729 int len; 585 seq_printf(m, "%d\n", lookupCacheEnabled);
730 586 return 0;
731 len = sprintf(page, "%d\n", lookupCacheEnabled); 587}
732
733 len -= off;
734 *start = page + off;
735
736 if (len > count)
737 len = count;
738 else
739 *eof = 1;
740
741 if (len < 0)
742 len = 0;
743 588
744 return len; 589static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
590{
591 return single_open(file, cifs_lookup_cache_proc_show, NULL);
745} 592}
746static int 593
747lookupFlag_write(struct file *file, const char __user *buffer, 594static ssize_t cifs_lookup_cache_proc_write(struct file *file,
748 unsigned long count, void *data) 595 const char __user *buffer, size_t count, loff_t *ppos)
749{ 596{
750 char c; 597 char c;
751 int rc; 598 int rc;
@@ -760,30 +607,29 @@ lookupFlag_write(struct file *file, const char __user *buffer,
760 607
761 return count; 608 return count;
762} 609}
763static int
764traceSMB_read(char *page, char **start, off_t off, int count,
765 int *eof, void *data)
766{
767 int len;
768
769 len = sprintf(page, "%d\n", traceSMB);
770
771 len -= off;
772 *start = page + off;
773 610
774 if (len > count) 611static const struct file_operations cifs_lookup_cache_proc_fops = {
775 len = count; 612 .owner = THIS_MODULE,
776 else 613 .open = cifs_lookup_cache_proc_open,
777 *eof = 1; 614 .read = seq_read,
615 .llseek = seq_lseek,
616 .release = single_release,
617 .write = cifs_lookup_cache_proc_write,
618};
778 619
779 if (len < 0) 620static int traceSMB_proc_show(struct seq_file *m, void *v)
780 len = 0; 621{
622 seq_printf(m, "%d\n", traceSMB);
623 return 0;
624}
781 625
782 return len; 626static int traceSMB_proc_open(struct inode *inode, struct file *file)
627{
628 return single_open(file, traceSMB_proc_show, NULL);
783} 629}
784static int 630
785traceSMB_write(struct file *file, const char __user *buffer, 631static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
786 unsigned long count, void *data) 632 size_t count, loff_t *ppos)
787{ 633{
788 char c; 634 char c;
789 int rc; 635 int rc;
@@ -799,30 +645,28 @@ traceSMB_write(struct file *file, const char __user *buffer,
799 return count; 645 return count;
800} 646}
801 647
802static int 648static const struct file_operations traceSMB_proc_fops = {
803multiuser_mount_read(char *page, char **start, off_t off, 649 .owner = THIS_MODULE,
804 int count, int *eof, void *data) 650 .open = traceSMB_proc_open,
805{ 651 .read = seq_read,
806 int len; 652 .llseek = seq_lseek,
807 653 .release = single_release,
808 len = sprintf(page, "%d\n", multiuser_mount); 654 .write = traceSMB_proc_write,
809 655};
810 len -= off;
811 *start = page + off;
812 656
813 if (len > count) 657static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
814 len = count; 658{
815 else 659 seq_printf(m, "%d\n", multiuser_mount);
816 *eof = 1; 660 return 0;
817 661}
818 if (len < 0)
819 len = 0;
820 662
821 return len; 663static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
664{
665 return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
822} 666}
823static int 667
824multiuser_mount_write(struct file *file, const char __user *buffer, 668static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
825 unsigned long count, void *data) 669 const char __user *buffer, size_t count, loff_t *ppos)
826{ 670{
827 char c; 671 char c;
828 int rc; 672 int rc;
@@ -838,30 +682,28 @@ multiuser_mount_write(struct file *file, const char __user *buffer,
838 return count; 682 return count;
839} 683}
840 684
841static int 685static const struct file_operations cifs_multiuser_mount_proc_fops = {
842security_flags_read(char *page, char **start, off_t off, 686 .owner = THIS_MODULE,
843 int count, int *eof, void *data) 687 .open = cifs_multiuser_mount_proc_open,
844{ 688 .read = seq_read,
845 int len; 689 .llseek = seq_lseek,
846 690 .release = single_release,
847 len = sprintf(page, "0x%x\n", extended_security); 691 .write = cifs_multiuser_mount_proc_write,
848 692};
849 len -= off;
850 *start = page + off;
851 693
852 if (len > count) 694static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
853 len = count; 695{
854 else 696 seq_printf(m, "0x%x\n", extended_security);
855 *eof = 1; 697 return 0;
856 698}
857 if (len < 0)
858 len = 0;
859 699
860 return len; 700static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
701{
702 return single_open(file, cifs_security_flags_proc_show, NULL);
861} 703}
862static int 704
863security_flags_write(struct file *file, const char __user *buffer, 705static ssize_t cifs_security_flags_proc_write(struct file *file,
864 unsigned long count, void *data) 706 const char __user *buffer, size_t count, loff_t *ppos)
865{ 707{
866 unsigned int flags; 708 unsigned int flags;
867 char flags_string[12]; 709 char flags_string[12];
@@ -917,6 +759,15 @@ security_flags_write(struct file *file, const char __user *buffer,
917 /* BB should we turn on MAY flags for other MUST options? */ 759 /* BB should we turn on MAY flags for other MUST options? */
918 return count; 760 return count;
919} 761}
762
763static const struct file_operations cifs_security_flags_proc_fops = {
764 .owner = THIS_MODULE,
765 .open = cifs_security_flags_proc_open,
766 .read = seq_read,
767 .llseek = seq_lseek,
768 .release = single_release,
769 .write = cifs_security_flags_proc_write,
770};
920#else 771#else
921inline void cifs_proc_init(void) 772inline void cifs_proc_init(void)
922{ 773{
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 0e9fc2ba90ee..57ecdc83c26f 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -56,7 +56,7 @@ int match_sid(struct cifs_sid *ctsid)
56 struct cifs_sid *cwsid; 56 struct cifs_sid *cwsid;
57 57
58 if (!ctsid) 58 if (!ctsid)
59 return (-1); 59 return -1;
60 60
61 for (i = 0; i < NUM_WK_SIDS; ++i) { 61 for (i = 0; i < NUM_WK_SIDS; ++i) {
62 cwsid = &(wksidarr[i].cifssid); 62 cwsid = &(wksidarr[i].cifssid);
@@ -87,11 +87,11 @@ int match_sid(struct cifs_sid *ctsid)
87 } 87 }
88 88
89 cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); 89 cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname));
90 return (0); /* sids compare/match */ 90 return 0; /* sids compare/match */
91 } 91 }
92 92
93 cFYI(1, ("No matching sid")); 93 cFYI(1, ("No matching sid"));
94 return (-1); 94 return -1;
95} 95}
96 96
97/* if the two SIDs (roughly equivalent to a UUID for a user or group) are 97/* if the two SIDs (roughly equivalent to a UUID for a user or group) are
@@ -102,16 +102,16 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
102 int num_subauth, num_sat, num_saw; 102 int num_subauth, num_sat, num_saw;
103 103
104 if ((!ctsid) || (!cwsid)) 104 if ((!ctsid) || (!cwsid))
105 return (0); 105 return 0;
106 106
107 /* compare the revision */ 107 /* compare the revision */
108 if (ctsid->revision != cwsid->revision) 108 if (ctsid->revision != cwsid->revision)
109 return (0); 109 return 0;
110 110
111 /* compare all of the six auth values */ 111 /* compare all of the six auth values */
112 for (i = 0; i < 6; ++i) { 112 for (i = 0; i < 6; ++i) {
113 if (ctsid->authority[i] != cwsid->authority[i]) 113 if (ctsid->authority[i] != cwsid->authority[i])
114 return (0); 114 return 0;
115 } 115 }
116 116
117 /* compare all of the subauth values if any */ 117 /* compare all of the subauth values if any */
@@ -121,11 +121,11 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
121 if (num_subauth) { 121 if (num_subauth) {
122 for (i = 0; i < num_subauth; ++i) { 122 for (i = 0; i < num_subauth; ++i) {
123 if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) 123 if (ctsid->sub_auth[i] != cwsid->sub_auth[i])
124 return (0); 124 return 0;
125 } 125 }
126 } 126 }
127 127
128 return (1); /* sids compare/match */ 128 return 1; /* sids compare/match */
129} 129}
130 130
131 131
@@ -169,8 +169,7 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd,
169 for (i = 0; i < 6; i++) 169 for (i = 0; i < 6; i++)
170 ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; 170 ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i];
171 for (i = 0; i < 5; i++) 171 for (i = 0; i < 5; i++)
172 ngroup_sid_ptr->sub_auth[i] = 172 ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i];
173 cpu_to_le32(group_sid_ptr->sub_auth[i]);
174 173
175 return; 174 return;
176} 175}
@@ -285,7 +284,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace,
285 size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); 284 size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4);
286 pntace->size = cpu_to_le16(size); 285 pntace->size = cpu_to_le16(size);
287 286
288 return (size); 287 return size;
289} 288}
290 289
291 290
@@ -426,7 +425,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
426 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); 425 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
427 pndacl->num_aces = cpu_to_le32(3); 426 pndacl->num_aces = cpu_to_le32(3);
428 427
429 return (0); 428 return 0;
430} 429}
431 430
432 431
@@ -510,7 +509,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
510 sizeof(struct cifs_sid)); */ 509 sizeof(struct cifs_sid)); */
511 510
512 511
513 return (0); 512 return 0;
514} 513}
515 514
516 515
@@ -527,7 +526,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
527 struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ 526 struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */
528 527
529 if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) 528 if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL))
530 return (-EIO); 529 return -EIO;
531 530
532 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + 531 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
533 le32_to_cpu(pntsd->osidoffset)); 532 le32_to_cpu(pntsd->osidoffset));
@@ -550,7 +549,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
550 /* copy security descriptor control portion and owner and group sid */ 549 /* copy security descriptor control portion and owner and group sid */
551 copy_sec_desc(pntsd, pnntsd, sidsoffset); 550 copy_sec_desc(pntsd, pnntsd, sidsoffset);
552 551
553 return (rc); 552 return rc;
554} 553}
555 554
556 555
@@ -629,11 +628,11 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
629 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); 628 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
630 629
631 if (!inode) 630 if (!inode)
632 return (rc); 631 return rc;
633 632
634 sb = inode->i_sb; 633 sb = inode->i_sb;
635 if (sb == NULL) 634 if (sb == NULL)
636 return (rc); 635 return rc;
637 636
638 cifs_sb = CIFS_SB(sb); 637 cifs_sb = CIFS_SB(sb);
639 xid = GetXid(); 638 xid = GetXid();
@@ -652,7 +651,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
652 if (rc != 0) { 651 if (rc != 0) {
653 cERROR(1, ("Unable to open file to set ACL")); 652 cERROR(1, ("Unable to open file to set ACL"));
654 FreeXid(xid); 653 FreeXid(xid);
655 return (rc); 654 return rc;
656 } 655 }
657 } 656 }
658 657
@@ -665,7 +664,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
665 664
666 FreeXid(xid); 665 FreeXid(xid);
667 666
668 return (rc); 667 return rc;
669} 668}
670 669
671/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 670/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
@@ -715,7 +714,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
715 if (!pnntsd) { 714 if (!pnntsd) {
716 cERROR(1, ("Unable to allocate security descriptor")); 715 cERROR(1, ("Unable to allocate security descriptor"));
717 kfree(pntsd); 716 kfree(pntsd);
718 return (-ENOMEM); 717 return -ENOMEM;
719 } 718 }
720 719
721 rc = build_sec_desc(pntsd, pnntsd, inode, nmode); 720 rc = build_sec_desc(pntsd, pnntsd, inode, nmode);
@@ -732,6 +731,6 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
732 kfree(pntsd); 731 kfree(pntsd);
733 } 732 }
734 733
735 return (rc); 734 return rc;
736} 735}
737#endif /* CONFIG_CIFS_EXPERIMENTAL */ 736#endif /* CONFIG_CIFS_EXPERIMENTAL */
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 4ff8939c6cc7..83fd40dc1ef0 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -310,9 +310,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key)
310 utf8 and other multibyte codepages each need their own strupper 310 utf8 and other multibyte codepages each need their own strupper
311 function since a byte at a time will ont work. */ 311 function since a byte at a time will ont work. */
312 312
313 for (i = 0; i < CIFS_ENCPWD_SIZE; i++) { 313 for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
314 password_with_pad[i] = toupper(password_with_pad[i]); 314 password_with_pad[i] = toupper(password_with_pad[i]);
315 }
316 315
317 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); 316 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key);
318 /* clear password before we return/free memory */ 317 /* clear password before we return/free memory */
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 22857c639df5..1ec7076f7b24 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -267,7 +267,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
267 return 0; 267 return 0;
268} 268}
269 269
270static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) 270static int cifs_permission(struct inode *inode, int mask)
271{ 271{
272 struct cifs_sb_info *cifs_sb; 272 struct cifs_sb_info *cifs_sb;
273 273
@@ -766,7 +766,7 @@ const struct file_operations cifs_dir_ops = {
766}; 766};
767 767
768static void 768static void
769cifs_init_once(struct kmem_cache *cachep, void *inode) 769cifs_init_once(void *inode)
770{ 770{
771 struct cifsInodeInfo *cifsi = inode; 771 struct cifsInodeInfo *cifsi = inode;
772 772
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 9cfcf326ead3..7e1cf262effe 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -27,7 +27,7 @@
27#define MAX_SES_INFO 2 27#define MAX_SES_INFO 2
28#define MAX_TCON_INFO 4 28#define MAX_TCON_INFO 4
29 29
30#define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 30#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
31#define MAX_SERVER_SIZE 15 31#define MAX_SERVER_SIZE 15
32#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ 32#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
33#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null 33#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null
@@ -537,8 +537,8 @@ require use of the stronger protocol */
537#endif /* WEAK_PW_HASH */ 537#endif /* WEAK_PW_HASH */
538#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ 538#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
539 539
540#define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 540#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
541#define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2 541#define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
542#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) 542#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5)
543/* 543/*
544 ***************************************************************** 544 *****************************************************************
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 0f327c224da3..409abce12732 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -31,7 +31,7 @@
31#else 31#else
32#define CIFS_PROT 0 32#define CIFS_PROT 0
33#endif 33#endif
34#define POSIX_PROT CIFS_PROT+1 34#define POSIX_PROT (CIFS_PROT+1)
35#define BAD_PROT 0xFFFF 35#define BAD_PROT 0xFFFF
36 36
37/* SMB command codes */ 37/* SMB command codes */
@@ -341,7 +341,7 @@
341#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ 341#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
342#define CREATE_NO_EA_KNOWLEDGE 0x00000200 342#define CREATE_NO_EA_KNOWLEDGE 0x00000200
343#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete 343#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
344 "open for recovery" flag - should 344 "open for recovery" flag should
345 be zero in any case */ 345 be zero in any case */
346#define CREATE_OPEN_FOR_RECOVERY 0x00000400 346#define CREATE_OPEN_FOR_RECOVERY 0x00000400
347#define CREATE_RANDOM_ACCESS 0x00000800 347#define CREATE_RANDOM_ACCESS 0x00000800
@@ -414,8 +414,8 @@ struct smb_hdr {
414 __u8 WordCount; 414 __u8 WordCount;
415} __attribute__((packed)); 415} __attribute__((packed));
416/* given a pointer to an smb_hdr retrieve the value of byte count */ 416/* given a pointer to an smb_hdr retrieve the value of byte count */
417#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) 417#define BCC(smb_var) (*(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
418#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) 418#define BCC_LE(smb_var) (*(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
419/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ 419/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
420#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) 420#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
421 421
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 4511b708f0f3..c621ffa2ca90 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -686,11 +686,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
686 SecurityBlob, 686 SecurityBlob,
687 count - 16, 687 count - 16,
688 &server->secType); 688 &server->secType);
689 if (rc == 1) { 689 if (rc == 1)
690 rc = 0; 690 rc = 0;
691 } else { 691 else
692 rc = -EINVAL; 692 rc = -EINVAL;
693 }
694 } 693 }
695 } else 694 } else
696 server->capabilities &= ~CAP_EXTENDED_SECURITY; 695 server->capabilities &= ~CAP_EXTENDED_SECURITY;
@@ -3914,7 +3913,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3914 bool is_unicode; 3913 bool is_unicode;
3915 struct dfs_referral_level_3 *ref; 3914 struct dfs_referral_level_3 *ref;
3916 3915
3917 is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE; 3916 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3917 is_unicode = true;
3918 else
3919 is_unicode = false;
3918 *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); 3920 *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals);
3919 3921
3920 if (*num_of_nodes < 1) { 3922 if (*num_of_nodes < 1) {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e8fa46c7cff2..b51d5777cde6 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -455,7 +455,7 @@ incomplete_rcv:
455 /* Note that FC 1001 length is big endian on the wire, 455 /* Note that FC 1001 length is big endian on the wire,
456 but we convert it here so it is always manipulated 456 but we convert it here so it is always manipulated
457 as host byte order */ 457 as host byte order */
458 pdu_length = ntohl(smb_buffer->smb_buf_length); 458 pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length);
459 smb_buffer->smb_buf_length = pdu_length; 459 smb_buffer->smb_buf_length = pdu_length;
460 460
461 cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); 461 cFYI(1, ("rfc1002 length 0x%x", pdu_length+4));
@@ -1461,6 +1461,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
1461 return rc; 1461 return rc;
1462} 1462}
1463 1463
1464#ifdef CONFIG_DEBUG_LOCK_ALLOC
1465static struct lock_class_key cifs_key[2];
1466static struct lock_class_key cifs_slock_key[2];
1467
1468static inline void
1469cifs_reclassify_socket4(struct socket *sock)
1470{
1471 struct sock *sk = sock->sk;
1472 BUG_ON(sock_owned_by_user(sk));
1473 sock_lock_init_class_and_name(sk, "slock-AF_INET-CIFS",
1474 &cifs_slock_key[0], "sk_lock-AF_INET-CIFS", &cifs_key[0]);
1475}
1476
1477static inline void
1478cifs_reclassify_socket6(struct socket *sock)
1479{
1480 struct sock *sk = sock->sk;
1481 BUG_ON(sock_owned_by_user(sk));
1482 sock_lock_init_class_and_name(sk, "slock-AF_INET6-CIFS",
1483 &cifs_slock_key[1], "sk_lock-AF_INET6-CIFS", &cifs_key[1]);
1484}
1485#else
1486static inline void
1487cifs_reclassify_socket4(struct socket *sock)
1488{
1489}
1490
1491static inline void
1492cifs_reclassify_socket6(struct socket *sock)
1493{
1494}
1495#endif
1496
1464/* See RFC1001 section 14 on representation of Netbios names */ 1497/* See RFC1001 section 14 on representation of Netbios names */
1465static void rfc1002mangle(char *target, char *source, unsigned int length) 1498static void rfc1002mangle(char *target, char *source, unsigned int length)
1466{ 1499{
@@ -1495,6 +1528,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
1495 /* BB other socket options to set KEEPALIVE, NODELAY? */ 1528 /* BB other socket options to set KEEPALIVE, NODELAY? */
1496 cFYI(1, ("Socket created")); 1529 cFYI(1, ("Socket created"));
1497 (*csocket)->sk->sk_allocation = GFP_NOFS; 1530 (*csocket)->sk->sk_allocation = GFP_NOFS;
1531 cifs_reclassify_socket4(*csocket);
1498 } 1532 }
1499 } 1533 }
1500 1534
@@ -1627,6 +1661,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
1627 /* BB other socket options to set KEEPALIVE, NODELAY? */ 1661 /* BB other socket options to set KEEPALIVE, NODELAY? */
1628 cFYI(1, ("ipv6 Socket created")); 1662 cFYI(1, ("ipv6 Socket created"));
1629 (*csocket)->sk->sk_allocation = GFP_NOFS; 1663 (*csocket)->sk->sk_allocation = GFP_NOFS;
1664 cifs_reclassify_socket6(*csocket);
1630 } 1665 }
1631 } 1666 }
1632 1667
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2e904bd111c8..46e54d39461d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1413,6 +1413,82 @@ out_busy:
1413 return -ETXTBSY; 1413 return -ETXTBSY;
1414} 1414}
1415 1415
1416static int
1417cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1418 int xid, char *full_path)
1419{
1420 int rc;
1421 struct cifsFileInfo *open_file;
1422 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1423 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1424 struct cifsTconInfo *pTcon = cifs_sb->tcon;
1425
1426 /*
1427 * To avoid spurious oplock breaks from server, in the case of
1428 * inodes that we already have open, avoid doing path based
1429 * setting of file size if we can do it by handle.
1430 * This keeps our caching token (oplock) and avoids timeouts
1431 * when the local oplock break takes longer to flush
1432 * writebehind data than the SMB timeout for the SetPathInfo
1433 * request would allow
1434 */
1435 open_file = find_writable_file(cifsInode);
1436 if (open_file) {
1437 __u16 nfid = open_file->netfid;
1438 __u32 npid = open_file->pid;
1439 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
1440 npid, false);
1441 atomic_dec(&open_file->wrtPending);
1442 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1443 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1444 unsigned int bytes_written;
1445 rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size,
1446 &bytes_written, NULL, NULL, 1);
1447 cFYI(1, ("Wrt seteof rc %d", rc));
1448 }
1449 } else
1450 rc = -EINVAL;
1451
1452 if (rc != 0) {
1453 /* Set file size by pathname rather than by handle
1454 either because no valid, writeable file handle for
1455 it was found or because there was an error setting
1456 it by handle */
1457 rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size,
1458 false, cifs_sb->local_nls,
1459 cifs_sb->mnt_cifs_flags &
1460 CIFS_MOUNT_MAP_SPECIAL_CHR);
1461 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1462 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1463 __u16 netfid;
1464 int oplock = 0;
1465
1466 rc = SMBLegacyOpen(xid, pTcon, full_path,
1467 FILE_OPEN, GENERIC_WRITE,
1468 CREATE_NOT_DIR, &netfid, &oplock, NULL,
1469 cifs_sb->local_nls,
1470 cifs_sb->mnt_cifs_flags &
1471 CIFS_MOUNT_MAP_SPECIAL_CHR);
1472 if (rc == 0) {
1473 unsigned int bytes_written;
1474 rc = CIFSSMBWrite(xid, pTcon, netfid, 0,
1475 attrs->ia_size,
1476 &bytes_written, NULL,
1477 NULL, 1);
1478 cFYI(1, ("wrt seteof rc %d", rc));
1479 CIFSSMBClose(xid, pTcon, netfid);
1480 }
1481 }
1482 }
1483
1484 if (rc == 0) {
1485 rc = cifs_vmtruncate(inode, attrs->ia_size);
1486 cifs_truncate_page(inode->i_mapping, inode->i_size);
1487 }
1488
1489 return rc;
1490}
1491
1416int cifs_setattr(struct dentry *direntry, struct iattr *attrs) 1492int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1417{ 1493{
1418 int xid; 1494 int xid;
@@ -1420,7 +1496,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1420 struct cifsTconInfo *pTcon; 1496 struct cifsTconInfo *pTcon;
1421 char *full_path = NULL; 1497 char *full_path = NULL;
1422 int rc = -EACCES; 1498 int rc = -EACCES;
1423 struct cifsFileInfo *open_file = NULL;
1424 FILE_BASIC_INFO time_buf; 1499 FILE_BASIC_INFO time_buf;
1425 bool set_time = false; 1500 bool set_time = false;
1426 bool set_dosattr = false; 1501 bool set_dosattr = false;
@@ -1472,78 +1547,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1472 } 1547 }
1473 1548
1474 if (attrs->ia_valid & ATTR_SIZE) { 1549 if (attrs->ia_valid & ATTR_SIZE) {
1475 /* To avoid spurious oplock breaks from server, in the case of 1550 rc = cifs_set_file_size(inode, attrs, xid, full_path);
1476 inodes that we already have open, avoid doing path based 1551 if (rc != 0)
1477 setting of file size if we can do it by handle.
1478 This keeps our caching token (oplock) and avoids timeouts
1479 when the local oplock break takes longer to flush
1480 writebehind data than the SMB timeout for the SetPathInfo
1481 request would allow */
1482
1483 open_file = find_writable_file(cifsInode);
1484 if (open_file) {
1485 __u16 nfid = open_file->netfid;
1486 __u32 npid = open_file->pid;
1487 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
1488 nfid, npid, false);
1489 atomic_dec(&open_file->wrtPending);
1490 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1491 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1492 unsigned int bytes_written;
1493 rc = CIFSSMBWrite(xid, pTcon,
1494 nfid, 0, attrs->ia_size,
1495 &bytes_written, NULL, NULL,
1496 1 /* 45 seconds */);
1497 cFYI(1, ("Wrt seteof rc %d", rc));
1498 }
1499 } else
1500 rc = -EINVAL;
1501
1502 if (rc != 0) {
1503 /* Set file size by pathname rather than by handle
1504 either because no valid, writeable file handle for
1505 it was found or because there was an error setting
1506 it by handle */
1507 rc = CIFSSMBSetEOF(xid, pTcon, full_path,
1508 attrs->ia_size, false,
1509 cifs_sb->local_nls,
1510 cifs_sb->mnt_cifs_flags &
1511 CIFS_MOUNT_MAP_SPECIAL_CHR);
1512 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1513 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1514 __u16 netfid;
1515 int oplock = 0;
1516
1517 rc = SMBLegacyOpen(xid, pTcon, full_path,
1518 FILE_OPEN, GENERIC_WRITE,
1519 CREATE_NOT_DIR, &netfid, &oplock,
1520 NULL, cifs_sb->local_nls,
1521 cifs_sb->mnt_cifs_flags &
1522 CIFS_MOUNT_MAP_SPECIAL_CHR);
1523 if (rc == 0) {
1524 unsigned int bytes_written;
1525 rc = CIFSSMBWrite(xid, pTcon,
1526 netfid, 0,
1527 attrs->ia_size,
1528 &bytes_written, NULL,
1529 NULL, 1 /* 45 sec */);
1530 cFYI(1, ("wrt seteof rc %d", rc));
1531 CIFSSMBClose(xid, pTcon, netfid);
1532 }
1533
1534 }
1535 }
1536
1537 /* Server is ok setting allocation size implicitly - no need
1538 to call:
1539 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true,
1540 cifs_sb->local_nls);
1541 */
1542
1543 if (rc == 0) {
1544 rc = cifs_vmtruncate(inode, attrs->ia_size);
1545 cifs_truncate_page(inode->i_mapping, inode->i_size);
1546 } else
1547 goto cifs_setattr_exit; 1552 goto cifs_setattr_exit;
1548 } 1553 }
1549 1554
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 83f306954883..5f40ed3473f5 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -690,6 +690,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
690 else 690 else
691 cifs_buf_release(cifsFile->srch_inf. 691 cifs_buf_release(cifsFile->srch_inf.
692 ntwrk_buf_start); 692 ntwrk_buf_start);
693 cifsFile->srch_inf.ntwrk_buf_start = NULL;
693 } 694 }
694 rc = initiate_cifs_search(xid, file); 695 rc = initiate_cifs_search(xid, file);
695 if (rc) { 696 if (rc) {
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 3d2580e00a3e..c5916228243c 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -137,9 +137,11 @@ exit:
137} 137}
138 138
139 139
140int coda_permission(struct inode *inode, int mask, struct nameidata *nd) 140int coda_permission(struct inode *inode, int mask)
141{ 141{
142 int error = 0; 142 int error = 0;
143
144 mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
143 145
144 if (!mask) 146 if (!mask)
145 return 0; 147 return 0;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 2f58dfc70083..830f51abb971 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode)
58 kmem_cache_free(coda_inode_cachep, ITOC(inode)); 58 kmem_cache_free(coda_inode_cachep, ITOC(inode));
59} 59}
60 60
61static void init_once(struct kmem_cache * cachep, void *foo) 61static void init_once(void *foo)
62{ 62{
63 struct coda_inode_info *ei = (struct coda_inode_info *) foo; 63 struct coda_inode_info *ei = (struct coda_inode_info *) foo;
64 64
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index c21a1f552a63..c51365422aa8 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -24,8 +24,7 @@
24#include <linux/coda_psdev.h> 24#include <linux/coda_psdev.h>
25 25
26/* pioctl ops */ 26/* pioctl ops */
27static int coda_ioctl_permission(struct inode *inode, int mask, 27static int coda_ioctl_permission(struct inode *inode, int mask);
28 struct nameidata *nd);
29static int coda_pioctl(struct inode * inode, struct file * filp, 28static int coda_pioctl(struct inode * inode, struct file * filp,
30 unsigned int cmd, unsigned long user_data); 29 unsigned int cmd, unsigned long user_data);
31 30
@@ -42,8 +41,7 @@ const struct file_operations coda_ioctl_operations = {
42}; 41};
43 42
44/* the coda pioctl inode ops */ 43/* the coda pioctl inode ops */
45static int coda_ioctl_permission(struct inode *inode, int mask, 44static int coda_ioctl_permission(struct inode *inode, int mask)
46 struct nameidata *nd)
47{ 45{
48 return 0; 46 return 0;
49} 47}
@@ -51,7 +49,7 @@ static int coda_ioctl_permission(struct inode *inode, int mask,
51static int coda_pioctl(struct inode * inode, struct file * filp, 49static int coda_pioctl(struct inode * inode, struct file * filp,
52 unsigned int cmd, unsigned long user_data) 50 unsigned int cmd, unsigned long user_data)
53{ 51{
54 struct nameidata nd; 52 struct path path;
55 int error; 53 int error;
56 struct PioctlData data; 54 struct PioctlData data;
57 struct inode *target_inode = NULL; 55 struct inode *target_inode = NULL;
@@ -66,21 +64,21 @@ static int coda_pioctl(struct inode * inode, struct file * filp,
66 * Look up the pathname. Note that the pathname is in 64 * Look up the pathname. Note that the pathname is in
67 * user memory, and namei takes care of this 65 * user memory, and namei takes care of this
68 */ 66 */
69 if ( data.follow ) { 67 if (data.follow) {
70 error = user_path_walk(data.path, &nd); 68 error = user_path(data.path, &path);
71 } else { 69 } else {
72 error = user_path_walk_link(data.path, &nd); 70 error = user_lpath(data.path, &path);
73 } 71 }
74 72
75 if ( error ) { 73 if ( error ) {
76 return error; 74 return error;
77 } else { 75 } else {
78 target_inode = nd.path.dentry->d_inode; 76 target_inode = path.dentry->d_inode;
79 } 77 }
80 78
81 /* return if it is not a Coda inode */ 79 /* return if it is not a Coda inode */
82 if ( target_inode->i_sb != inode->i_sb ) { 80 if ( target_inode->i_sb != inode->i_sb ) {
83 path_put(&nd.path); 81 path_put(&path);
84 return -EINVAL; 82 return -EINVAL;
85 } 83 }
86 84
@@ -89,7 +87,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp,
89 87
90 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); 88 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
91 89
92 path_put(&nd.path); 90 path_put(&path);
93 return error; 91 return error;
94} 92}
95 93
diff --git a/fs/compat.c b/fs/compat.c
index 106eba28ec5a..c9d1472e65c5 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -234,18 +234,18 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *
234 * The following statfs calls are copies of code from fs/open.c and 234 * The following statfs calls are copies of code from fs/open.c and
235 * should be checked against those from time to time 235 * should be checked against those from time to time
236 */ 236 */
237asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs __user *buf) 237asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_statfs __user *buf)
238{ 238{
239 struct nameidata nd; 239 struct path path;
240 int error; 240 int error;
241 241
242 error = user_path_walk(path, &nd); 242 error = user_path(pathname, &path);
243 if (!error) { 243 if (!error) {
244 struct kstatfs tmp; 244 struct kstatfs tmp;
245 error = vfs_statfs(nd.path.dentry, &tmp); 245 error = vfs_statfs(path.dentry, &tmp);
246 if (!error) 246 if (!error)
247 error = put_compat_statfs(buf, &tmp); 247 error = put_compat_statfs(buf, &tmp);
248 path_put(&nd.path); 248 path_put(&path);
249 } 249 }
250 return error; 250 return error;
251} 251}
@@ -299,21 +299,21 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat
299 return 0; 299 return 0;
300} 300}
301 301
302asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, struct compat_statfs64 __user *buf) 302asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sz, struct compat_statfs64 __user *buf)
303{ 303{
304 struct nameidata nd; 304 struct path path;
305 int error; 305 int error;
306 306
307 if (sz != sizeof(*buf)) 307 if (sz != sizeof(*buf))
308 return -EINVAL; 308 return -EINVAL;
309 309
310 error = user_path_walk(path, &nd); 310 error = user_path(pathname, &path);
311 if (!error) { 311 if (!error) {
312 struct kstatfs tmp; 312 struct kstatfs tmp;
313 error = vfs_statfs(nd.path.dentry, &tmp); 313 error = vfs_statfs(path.dentry, &tmp);
314 if (!error) 314 if (!error)
315 error = put_compat_statfs64(buf, &tmp); 315 error = put_compat_statfs64(buf, &tmp);
316 path_put(&nd.path); 316 path_put(&path);
317 } 317 }
318 return error; 318 return error;
319} 319}
diff --git a/fs/dcache.c b/fs/dcache.c
index 3818d6ab76ca..f2584d22cb45 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -487,6 +487,7 @@ restart:
487 if (!cnt) 487 if (!cnt)
488 break; 488 break;
489 } 489 }
490 cond_resched_lock(&dcache_lock);
490 } 491 }
491 } 492 }
492 while (!list_empty(&tmp)) { 493 while (!list_empty(&tmp)) {
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 9e81addbd6ea..9606ee848fd8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -150,17 +150,11 @@ static int dio_refill_pages(struct dio *dio)
150 int nr_pages; 150 int nr_pages;
151 151
152 nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES); 152 nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES);
153 down_read(&current->mm->mmap_sem); 153 ret = get_user_pages_fast(
154 ret = get_user_pages(
155 current, /* Task for fault acounting */
156 current->mm, /* whose pages? */
157 dio->curr_user_address, /* Where from? */ 154 dio->curr_user_address, /* Where from? */
158 nr_pages, /* How many pages? */ 155 nr_pages, /* How many pages? */
159 dio->rw == READ, /* Write to memory? */ 156 dio->rw == READ, /* Write to memory? */
160 0, /* force (?) */ 157 &dio->pages[0]); /* Put results here */
161 &dio->pages[0],
162 NULL); /* vmas */
163 up_read(&current->mm->mmap_sem);
164 158
165 if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) { 159 if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) {
166 struct page *page = ZERO_PAGE(0); 160 struct page *page = ZERO_PAGE(0);
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 2d3d1027ce2b..724ddac91538 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -363,6 +363,7 @@ static int search_rsb_list(struct list_head *head, char *name, int len,
363 if (len == r->res_length && !memcmp(name, r->res_name, len)) 363 if (len == r->res_length && !memcmp(name, r->res_name, len))
364 goto found; 364 goto found;
365 } 365 }
366 *r_ret = NULL;
366 return -EBADR; 367 return -EBADR;
367 368
368 found: 369 found:
@@ -1782,7 +1783,8 @@ static void grant_pending_locks(struct dlm_rsb *r)
1782 1783
1783 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) { 1784 list_for_each_entry_safe(lkb, s, &r->res_grantqueue, lkb_statequeue) {
1784 if (lkb->lkb_bastfn && lock_requires_bast(lkb, high, cw)) { 1785 if (lkb->lkb_bastfn && lock_requires_bast(lkb, high, cw)) {
1785 if (cw && high == DLM_LOCK_PR) 1786 if (cw && high == DLM_LOCK_PR &&
1787 lkb->lkb_grmode == DLM_LOCK_PR)
1786 queue_bast(r, lkb, DLM_LOCK_CW); 1788 queue_bast(r, lkb, DLM_LOCK_CW);
1787 else 1789 else
1788 queue_bast(r, lkb, high); 1790 queue_bast(r, lkb, high);
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 637018c891ef..3962262f991a 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -891,8 +891,10 @@ static void tcp_connect_to_sock(struct connection *con)
891 goto out_err; 891 goto out_err;
892 892
893 memset(&saddr, 0, sizeof(saddr)); 893 memset(&saddr, 0, sizeof(saddr));
894 if (dlm_nodeid_to_addr(con->nodeid, &saddr)) 894 if (dlm_nodeid_to_addr(con->nodeid, &saddr)) {
895 sock_release(sock);
895 goto out_err; 896 goto out_err;
897 }
896 898
897 sock->sk->sk_user_data = con; 899 sock->sk->sk_user_data = con;
898 con->rx_action = receive_from_sock; 900 con->rx_action = receive_from_sock;
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index f976f303c196..929e48ae7591 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -539,7 +539,7 @@ static ssize_t device_write(struct file *file, const char __user *buf,
539 539
540 /* do we really need this? can a write happen after a close? */ 540 /* do we really need this? can a write happen after a close? */
541 if ((kbuf->cmd == DLM_USER_LOCK || kbuf->cmd == DLM_USER_UNLOCK) && 541 if ((kbuf->cmd == DLM_USER_LOCK || kbuf->cmd == DLM_USER_UNLOCK) &&
542 test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags)) 542 (proc && test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags)))
543 return -EINVAL; 543 return -EINVAL;
544 544
545 sigfillset(&allsigs); 545 sigfillset(&allsigs);
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 7b99917ffadc..06db79d05c12 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -475,8 +475,8 @@ int ecryptfs_encrypt_page(struct page *page)
475{ 475{
476 struct inode *ecryptfs_inode; 476 struct inode *ecryptfs_inode;
477 struct ecryptfs_crypt_stat *crypt_stat; 477 struct ecryptfs_crypt_stat *crypt_stat;
478 char *enc_extent_virt = NULL; 478 char *enc_extent_virt;
479 struct page *enc_extent_page; 479 struct page *enc_extent_page = NULL;
480 loff_t extent_offset; 480 loff_t extent_offset;
481 int rc = 0; 481 int rc = 0;
482 482
@@ -492,14 +492,14 @@ int ecryptfs_encrypt_page(struct page *page)
492 page->index); 492 page->index);
493 goto out; 493 goto out;
494 } 494 }
495 enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER); 495 enc_extent_page = alloc_page(GFP_USER);
496 if (!enc_extent_virt) { 496 if (!enc_extent_page) {
497 rc = -ENOMEM; 497 rc = -ENOMEM;
498 ecryptfs_printk(KERN_ERR, "Error allocating memory for " 498 ecryptfs_printk(KERN_ERR, "Error allocating memory for "
499 "encrypted extent\n"); 499 "encrypted extent\n");
500 goto out; 500 goto out;
501 } 501 }
502 enc_extent_page = virt_to_page(enc_extent_virt); 502 enc_extent_virt = kmap(enc_extent_page);
503 for (extent_offset = 0; 503 for (extent_offset = 0;
504 extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); 504 extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size);
505 extent_offset++) { 505 extent_offset++) {
@@ -527,7 +527,10 @@ int ecryptfs_encrypt_page(struct page *page)
527 } 527 }
528 } 528 }
529out: 529out:
530 kfree(enc_extent_virt); 530 if (enc_extent_page) {
531 kunmap(enc_extent_page);
532 __free_page(enc_extent_page);
533 }
531 return rc; 534 return rc;
532} 535}
533 536
@@ -609,8 +612,8 @@ int ecryptfs_decrypt_page(struct page *page)
609{ 612{
610 struct inode *ecryptfs_inode; 613 struct inode *ecryptfs_inode;
611 struct ecryptfs_crypt_stat *crypt_stat; 614 struct ecryptfs_crypt_stat *crypt_stat;
612 char *enc_extent_virt = NULL; 615 char *enc_extent_virt;
613 struct page *enc_extent_page; 616 struct page *enc_extent_page = NULL;
614 unsigned long extent_offset; 617 unsigned long extent_offset;
615 int rc = 0; 618 int rc = 0;
616 619
@@ -627,14 +630,14 @@ int ecryptfs_decrypt_page(struct page *page)
627 page->index); 630 page->index);
628 goto out; 631 goto out;
629 } 632 }
630 enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER); 633 enc_extent_page = alloc_page(GFP_USER);
631 if (!enc_extent_virt) { 634 if (!enc_extent_page) {
632 rc = -ENOMEM; 635 rc = -ENOMEM;
633 ecryptfs_printk(KERN_ERR, "Error allocating memory for " 636 ecryptfs_printk(KERN_ERR, "Error allocating memory for "
634 "encrypted extent\n"); 637 "encrypted extent\n");
635 goto out; 638 goto out;
636 } 639 }
637 enc_extent_page = virt_to_page(enc_extent_virt); 640 enc_extent_virt = kmap(enc_extent_page);
638 for (extent_offset = 0; 641 for (extent_offset = 0;
639 extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); 642 extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size);
640 extent_offset++) { 643 extent_offset++) {
@@ -662,7 +665,10 @@ int ecryptfs_decrypt_page(struct page *page)
662 } 665 }
663 } 666 }
664out: 667out:
665 kfree(enc_extent_virt); 668 if (enc_extent_page) {
669 kunmap(enc_extent_page);
670 __free_page(enc_extent_page);
671 }
666 return rc; 672 return rc;
667} 673}
668 674
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index d755455e3bff..89209f00f9c7 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -465,7 +465,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
465 int rc; 465 int rc;
466 struct dentry *lower_dentry; 466 struct dentry *lower_dentry;
467 struct dentry *lower_dir_dentry; 467 struct dentry *lower_dir_dentry;
468 umode_t mode;
469 char *encoded_symname; 468 char *encoded_symname;
470 int encoded_symlen; 469 int encoded_symlen;
471 struct ecryptfs_crypt_stat *crypt_stat = NULL; 470 struct ecryptfs_crypt_stat *crypt_stat = NULL;
@@ -473,7 +472,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
473 lower_dentry = ecryptfs_dentry_to_lower(dentry); 472 lower_dentry = ecryptfs_dentry_to_lower(dentry);
474 dget(lower_dentry); 473 dget(lower_dentry);
475 lower_dir_dentry = lock_parent(lower_dentry); 474 lower_dir_dentry = lock_parent(lower_dentry);
476 mode = S_IALLUGO;
477 encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname, 475 encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname,
478 strlen(symname), 476 strlen(symname),
479 &encoded_symname); 477 &encoded_symname);
@@ -482,7 +480,7 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
482 goto out_lock; 480 goto out_lock;
483 } 481 }
484 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, 482 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
485 encoded_symname, mode); 483 encoded_symname);
486 kfree(encoded_symname); 484 kfree(encoded_symname);
487 if (rc || !lower_dentry->d_inode) 485 if (rc || !lower_dentry->d_inode)
488 goto out_lock; 486 goto out_lock;
@@ -830,22 +828,9 @@ out:
830} 828}
831 829
832static int 830static int
833ecryptfs_permission(struct inode *inode, int mask, struct nameidata *nd) 831ecryptfs_permission(struct inode *inode, int mask)
834{ 832{
835 int rc; 833 return inode_permission(ecryptfs_inode_to_lower(inode), mask);
836
837 if (nd) {
838 struct vfsmount *vfsmnt_save = nd->path.mnt;
839 struct dentry *dentry_save = nd->path.dentry;
840
841 nd->path.mnt = ecryptfs_dentry_to_lower_mnt(nd->path.dentry);
842 nd->path.dentry = ecryptfs_dentry_to_lower(nd->path.dentry);
843 rc = permission(ecryptfs_inode_to_lower(inode), mask, nd);
844 nd->path.mnt = vfsmnt_save;
845 nd->path.dentry = dentry_save;
846 } else
847 rc = permission(ecryptfs_inode_to_lower(inode), mask, NULL);
848 return rc;
849} 834}
850 835
851/** 836/**
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 6f403cfba14f..448dfd597b5f 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -578,7 +578,7 @@ static struct file_system_type ecryptfs_fs_type = {
578 * Initializes the ecryptfs_inode_info_cache when it is created 578 * Initializes the ecryptfs_inode_info_cache when it is created
579 */ 579 */
580static void 580static void
581inode_info_init_once(struct kmem_cache *cachep, void *vptr) 581inode_info_init_once(void *vptr)
582{ 582{
583 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; 583 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr;
584 584
@@ -589,7 +589,7 @@ static struct ecryptfs_cache_info {
589 struct kmem_cache **cache; 589 struct kmem_cache **cache;
590 const char *name; 590 const char *name;
591 size_t size; 591 size_t size;
592 void (*ctor)(struct kmem_cache *cache, void *obj); 592 void (*ctor)(void *obj);
593} ecryptfs_cache_infos[] = { 593} ecryptfs_cache_infos[] = {
594 { 594 {
595 .cache = &ecryptfs_auth_tok_list_item_cache, 595 .cache = &ecryptfs_auth_tok_list_item_cache,
diff --git a/fs/efs/super.c b/fs/efs/super.c
index d733531b55e2..567b134fa1f1 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -70,7 +70,7 @@ static void efs_destroy_inode(struct inode *inode)
70 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 70 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
71} 71}
72 72
73static void init_once(struct kmem_cache *cachep, void *foo) 73static void init_once(void *foo)
74{ 74{
75 struct efs_inode_info *ei = (struct efs_inode_info *) foo; 75 struct efs_inode_info *ei = (struct efs_inode_info *) foo;
76 76
diff --git a/fs/exec.c b/fs/exec.c
index 5e559013e303..32993beecbe9 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -32,6 +32,7 @@
32#include <linux/swap.h> 32#include <linux/swap.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/pagemap.h>
35#include <linux/highmem.h> 36#include <linux/highmem.h>
36#include <linux/spinlock.h> 37#include <linux/spinlock.h>
37#include <linux/key.h> 38#include <linux/key.h>
@@ -42,13 +43,13 @@
42#include <linux/module.h> 43#include <linux/module.h>
43#include <linux/namei.h> 44#include <linux/namei.h>
44#include <linux/proc_fs.h> 45#include <linux/proc_fs.h>
45#include <linux/ptrace.h>
46#include <linux/mount.h> 46#include <linux/mount.h>
47#include <linux/security.h> 47#include <linux/security.h>
48#include <linux/syscalls.h> 48#include <linux/syscalls.h>
49#include <linux/tsacct_kern.h> 49#include <linux/tsacct_kern.h>
50#include <linux/cn_proc.h> 50#include <linux/cn_proc.h>
51#include <linux/audit.h> 51#include <linux/audit.h>
52#include <linux/tracehook.h>
52 53
53#include <asm/uaccess.h> 54#include <asm/uaccess.h>
54#include <asm/mmu_context.h> 55#include <asm/mmu_context.h>
@@ -106,11 +107,17 @@ static inline void put_binfmt(struct linux_binfmt * fmt)
106 */ 107 */
107asmlinkage long sys_uselib(const char __user * library) 108asmlinkage long sys_uselib(const char __user * library)
108{ 109{
109 struct file * file; 110 struct file *file;
110 struct nameidata nd; 111 struct nameidata nd;
111 int error; 112 char *tmp = getname(library);
112 113 int error = PTR_ERR(tmp);
113 error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC); 114
115 if (!IS_ERR(tmp)) {
116 error = path_lookup_open(AT_FDCWD, tmp,
117 LOOKUP_FOLLOW, &nd,
118 FMODE_READ|FMODE_EXEC);
119 putname(tmp);
120 }
114 if (error) 121 if (error)
115 goto out; 122 goto out;
116 123
@@ -118,7 +125,11 @@ asmlinkage long sys_uselib(const char __user * library)
118 if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) 125 if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
119 goto exit; 126 goto exit;
120 127
121 error = vfs_permission(&nd, MAY_READ | MAY_EXEC); 128 error = -EACCES;
129 if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
130 goto exit;
131
132 error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN);
122 if (error) 133 if (error)
123 goto exit; 134 goto exit;
124 135
@@ -656,38 +667,43 @@ EXPORT_SYMBOL(setup_arg_pages);
656struct file *open_exec(const char *name) 667struct file *open_exec(const char *name)
657{ 668{
658 struct nameidata nd; 669 struct nameidata nd;
659 int err;
660 struct file *file; 670 struct file *file;
671 int err;
661 672
662 err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC); 673 err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,
663 file = ERR_PTR(err); 674 FMODE_READ|FMODE_EXEC);
664 675 if (err)
665 if (!err) { 676 goto out;
666 struct inode *inode = nd.path.dentry->d_inode; 677
667 file = ERR_PTR(-EACCES); 678 err = -EACCES;
668 if (S_ISREG(inode->i_mode)) { 679 if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
669 int err = vfs_permission(&nd, MAY_EXEC); 680 goto out_path_put;
670 file = ERR_PTR(err); 681
671 if (!err) { 682 if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
672 file = nameidata_to_filp(&nd, 683 goto out_path_put;
673 O_RDONLY|O_LARGEFILE); 684
674 if (!IS_ERR(file)) { 685 err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN);
675 err = deny_write_access(file); 686 if (err)
676 if (err) { 687 goto out_path_put;
677 fput(file); 688
678 file = ERR_PTR(err); 689 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
679 } 690 if (IS_ERR(file))
680 } 691 return file;
681out: 692
682 return file; 693 err = deny_write_access(file);
683 } 694 if (err) {
684 } 695 fput(file);
685 release_open_intent(&nd); 696 goto out;
686 path_put(&nd.path);
687 } 697 }
688 goto out;
689}
690 698
699 return file;
700
701 out_path_put:
702 release_open_intent(&nd);
703 path_put(&nd.path);
704 out:
705 return ERR_PTR(err);
706}
691EXPORT_SYMBOL(open_exec); 707EXPORT_SYMBOL(open_exec);
692 708
693int kernel_read(struct file *file, unsigned long offset, 709int kernel_read(struct file *file, unsigned long offset,
@@ -1071,13 +1087,8 @@ EXPORT_SYMBOL(prepare_binprm);
1071 1087
1072static int unsafe_exec(struct task_struct *p) 1088static int unsafe_exec(struct task_struct *p)
1073{ 1089{
1074 int unsafe = 0; 1090 int unsafe = tracehook_unsafe_exec(p);
1075 if (p->ptrace & PT_PTRACED) { 1091
1076 if (p->ptrace & PT_PTRACE_CAP)
1077 unsafe |= LSM_UNSAFE_PTRACE_CAP;
1078 else
1079 unsafe |= LSM_UNSAFE_PTRACE;
1080 }
1081 if (atomic_read(&p->fs->count) > 1 || 1092 if (atomic_read(&p->fs->count) > 1 ||
1082 atomic_read(&p->files->count) > 1 || 1093 atomic_read(&p->files->count) > 1 ||
1083 atomic_read(&p->sighand->count) > 1) 1094 atomic_read(&p->sighand->count) > 1)
@@ -1214,6 +1225,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1214 read_unlock(&binfmt_lock); 1225 read_unlock(&binfmt_lock);
1215 retval = fn(bprm, regs); 1226 retval = fn(bprm, regs);
1216 if (retval >= 0) { 1227 if (retval >= 0) {
1228 tracehook_report_exec(fmt, bprm, regs);
1217 put_binfmt(fmt); 1229 put_binfmt(fmt);
1218 allow_write_access(bprm->file); 1230 allow_write_access(bprm->file);
1219 if (bprm->file) 1231 if (bprm->file)
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index e58669e1b87c..ae8c4f850b27 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -294,7 +294,7 @@ ext2_check_acl(struct inode *inode, int mask)
294} 294}
295 295
296int 296int
297ext2_permission(struct inode *inode, int mask, struct nameidata *nd) 297ext2_permission(struct inode *inode, int mask)
298{ 298{
299 return generic_permission(inode, mask, ext2_check_acl); 299 return generic_permission(inode, mask, ext2_check_acl);
300} 300}
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index 0bde85bafe38..b42cf578554b 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -58,7 +58,7 @@ static inline int ext2_acl_count(size_t size)
58#define EXT2_ACL_NOT_CACHED ((void *)-1) 58#define EXT2_ACL_NOT_CACHED ((void *)-1)
59 59
60/* acl.c */ 60/* acl.c */
61extern int ext2_permission (struct inode *, int, struct nameidata *); 61extern int ext2_permission (struct inode *, int);
62extern int ext2_acl_chmod (struct inode *); 62extern int ext2_acl_chmod (struct inode *);
63extern int ext2_init_acl (struct inode *, struct inode *); 63extern int ext2_init_acl (struct inode *, struct inode *);
64 64
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 384fc0d1dd74..991d6dfeb51f 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -791,6 +791,7 @@ const struct address_space_operations ext2_aops = {
791 .direct_IO = ext2_direct_IO, 791 .direct_IO = ext2_direct_IO,
792 .writepages = ext2_writepages, 792 .writepages = ext2_writepages,
793 .migratepage = buffer_migrate_page, 793 .migratepage = buffer_migrate_page,
794 .is_partially_uptodate = block_is_partially_uptodate,
794}; 795};
795 796
796const struct address_space_operations ext2_aops_xip = { 797const struct address_space_operations ext2_aops_xip = {
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 31308a3b0b8b..fd88c7b43e66 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -159,7 +159,7 @@ static void ext2_destroy_inode(struct inode *inode)
159 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 159 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
160} 160}
161 161
162static void init_once(struct kmem_cache * cachep, void *foo) 162static void init_once(void *foo)
163{ 163{
164 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; 164 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
165 165
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index a754d1848173..b60bb241880c 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -299,7 +299,7 @@ ext3_check_acl(struct inode *inode, int mask)
299} 299}
300 300
301int 301int
302ext3_permission(struct inode *inode, int mask, struct nameidata *nd) 302ext3_permission(struct inode *inode, int mask)
303{ 303{
304 return generic_permission(inode, mask, ext3_check_acl); 304 return generic_permission(inode, mask, ext3_check_acl);
305} 305}
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h
index 0d1e6279cbfd..42da16b8cac0 100644
--- a/fs/ext3/acl.h
+++ b/fs/ext3/acl.h
@@ -58,7 +58,7 @@ static inline int ext3_acl_count(size_t size)
58#define EXT3_ACL_NOT_CACHED ((void *)-1) 58#define EXT3_ACL_NOT_CACHED ((void *)-1)
59 59
60/* acl.c */ 60/* acl.c */
61extern int ext3_permission (struct inode *, int, struct nameidata *); 61extern int ext3_permission (struct inode *, int);
62extern int ext3_acl_chmod (struct inode *); 62extern int ext3_acl_chmod (struct inode *);
63extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); 63extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
64 64
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 3bf07d70b914..507d8689b111 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1767,44 +1767,47 @@ static int ext3_journalled_set_page_dirty(struct page *page)
1767} 1767}
1768 1768
1769static const struct address_space_operations ext3_ordered_aops = { 1769static const struct address_space_operations ext3_ordered_aops = {
1770 .readpage = ext3_readpage, 1770 .readpage = ext3_readpage,
1771 .readpages = ext3_readpages, 1771 .readpages = ext3_readpages,
1772 .writepage = ext3_ordered_writepage, 1772 .writepage = ext3_ordered_writepage,
1773 .sync_page = block_sync_page, 1773 .sync_page = block_sync_page,
1774 .write_begin = ext3_write_begin, 1774 .write_begin = ext3_write_begin,
1775 .write_end = ext3_ordered_write_end, 1775 .write_end = ext3_ordered_write_end,
1776 .bmap = ext3_bmap, 1776 .bmap = ext3_bmap,
1777 .invalidatepage = ext3_invalidatepage, 1777 .invalidatepage = ext3_invalidatepage,
1778 .releasepage = ext3_releasepage, 1778 .releasepage = ext3_releasepage,
1779 .direct_IO = ext3_direct_IO, 1779 .direct_IO = ext3_direct_IO,
1780 .migratepage = buffer_migrate_page, 1780 .migratepage = buffer_migrate_page,
1781 .is_partially_uptodate = block_is_partially_uptodate,
1781}; 1782};
1782 1783
1783static const struct address_space_operations ext3_writeback_aops = { 1784static const struct address_space_operations ext3_writeback_aops = {
1784 .readpage = ext3_readpage, 1785 .readpage = ext3_readpage,
1785 .readpages = ext3_readpages, 1786 .readpages = ext3_readpages,
1786 .writepage = ext3_writeback_writepage, 1787 .writepage = ext3_writeback_writepage,
1787 .sync_page = block_sync_page, 1788 .sync_page = block_sync_page,
1788 .write_begin = ext3_write_begin, 1789 .write_begin = ext3_write_begin,
1789 .write_end = ext3_writeback_write_end, 1790 .write_end = ext3_writeback_write_end,
1790 .bmap = ext3_bmap, 1791 .bmap = ext3_bmap,
1791 .invalidatepage = ext3_invalidatepage, 1792 .invalidatepage = ext3_invalidatepage,
1792 .releasepage = ext3_releasepage, 1793 .releasepage = ext3_releasepage,
1793 .direct_IO = ext3_direct_IO, 1794 .direct_IO = ext3_direct_IO,
1794 .migratepage = buffer_migrate_page, 1795 .migratepage = buffer_migrate_page,
1796 .is_partially_uptodate = block_is_partially_uptodate,
1795}; 1797};
1796 1798
1797static const struct address_space_operations ext3_journalled_aops = { 1799static const struct address_space_operations ext3_journalled_aops = {
1798 .readpage = ext3_readpage, 1800 .readpage = ext3_readpage,
1799 .readpages = ext3_readpages, 1801 .readpages = ext3_readpages,
1800 .writepage = ext3_journalled_writepage, 1802 .writepage = ext3_journalled_writepage,
1801 .sync_page = block_sync_page, 1803 .sync_page = block_sync_page,
1802 .write_begin = ext3_write_begin, 1804 .write_begin = ext3_write_begin,
1803 .write_end = ext3_journalled_write_end, 1805 .write_end = ext3_journalled_write_end,
1804 .set_page_dirty = ext3_journalled_set_page_dirty, 1806 .set_page_dirty = ext3_journalled_set_page_dirty,
1805 .bmap = ext3_bmap, 1807 .bmap = ext3_bmap,
1806 .invalidatepage = ext3_invalidatepage, 1808 .invalidatepage = ext3_invalidatepage,
1807 .releasepage = ext3_releasepage, 1809 .releasepage = ext3_releasepage,
1810 .is_partially_uptodate = block_is_partially_uptodate,
1808}; 1811};
1809 1812
1810void ext3_set_aops(struct inode *inode) 1813void ext3_set_aops(struct inode *inode)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 615788c6843a..8ddced384674 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -472,7 +472,7 @@ static void ext3_destroy_inode(struct inode *inode)
472 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 472 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
473} 473}
474 474
475static void init_once(struct kmem_cache * cachep, void *foo) 475static void init_once(void *foo)
476{ 476{
477 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 477 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
478 478
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 3c8dab880d91..c7d04e165446 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -299,7 +299,7 @@ ext4_check_acl(struct inode *inode, int mask)
299} 299}
300 300
301int 301int
302ext4_permission(struct inode *inode, int mask, struct nameidata *nd) 302ext4_permission(struct inode *inode, int mask)
303{ 303{
304 return generic_permission(inode, mask, ext4_check_acl); 304 return generic_permission(inode, mask, ext4_check_acl);
305} 305}
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index 26a5c1abf147..cd2b855a07d6 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -58,7 +58,7 @@ static inline int ext4_acl_count(size_t size)
58#define EXT4_ACL_NOT_CACHED ((void *)-1) 58#define EXT4_ACL_NOT_CACHED ((void *)-1)
59 59
60/* acl.c */ 60/* acl.c */
61extern int ext4_permission (struct inode *, int, struct nameidata *); 61extern int ext4_permission (struct inode *, int);
62extern int ext4_acl_chmod (struct inode *); 62extern int ext4_acl_chmod (struct inode *);
63extern int ext4_init_acl (handle_t *, struct inode *, struct inode *); 63extern int ext4_init_acl (handle_t *, struct inode *, struct inode *);
64 64
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8ca2763df091..9843b046c235 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2806,59 +2806,63 @@ static int ext4_journalled_set_page_dirty(struct page *page)
2806} 2806}
2807 2807
2808static const struct address_space_operations ext4_ordered_aops = { 2808static const struct address_space_operations ext4_ordered_aops = {
2809 .readpage = ext4_readpage, 2809 .readpage = ext4_readpage,
2810 .readpages = ext4_readpages, 2810 .readpages = ext4_readpages,
2811 .writepage = ext4_normal_writepage, 2811 .writepage = ext4_normal_writepage,
2812 .sync_page = block_sync_page, 2812 .sync_page = block_sync_page,
2813 .write_begin = ext4_write_begin, 2813 .write_begin = ext4_write_begin,
2814 .write_end = ext4_ordered_write_end, 2814 .write_end = ext4_ordered_write_end,
2815 .bmap = ext4_bmap, 2815 .bmap = ext4_bmap,
2816 .invalidatepage = ext4_invalidatepage, 2816 .invalidatepage = ext4_invalidatepage,
2817 .releasepage = ext4_releasepage, 2817 .releasepage = ext4_releasepage,
2818 .direct_IO = ext4_direct_IO, 2818 .direct_IO = ext4_direct_IO,
2819 .migratepage = buffer_migrate_page, 2819 .migratepage = buffer_migrate_page,
2820 .is_partially_uptodate = block_is_partially_uptodate,
2820}; 2821};
2821 2822
2822static const struct address_space_operations ext4_writeback_aops = { 2823static const struct address_space_operations ext4_writeback_aops = {
2823 .readpage = ext4_readpage, 2824 .readpage = ext4_readpage,
2824 .readpages = ext4_readpages, 2825 .readpages = ext4_readpages,
2825 .writepage = ext4_normal_writepage, 2826 .writepage = ext4_normal_writepage,
2826 .sync_page = block_sync_page, 2827 .sync_page = block_sync_page,
2827 .write_begin = ext4_write_begin, 2828 .write_begin = ext4_write_begin,
2828 .write_end = ext4_writeback_write_end, 2829 .write_end = ext4_writeback_write_end,
2829 .bmap = ext4_bmap, 2830 .bmap = ext4_bmap,
2830 .invalidatepage = ext4_invalidatepage, 2831 .invalidatepage = ext4_invalidatepage,
2831 .releasepage = ext4_releasepage, 2832 .releasepage = ext4_releasepage,
2832 .direct_IO = ext4_direct_IO, 2833 .direct_IO = ext4_direct_IO,
2833 .migratepage = buffer_migrate_page, 2834 .migratepage = buffer_migrate_page,
2835 .is_partially_uptodate = block_is_partially_uptodate,
2834}; 2836};
2835 2837
2836static const struct address_space_operations ext4_journalled_aops = { 2838static const struct address_space_operations ext4_journalled_aops = {
2837 .readpage = ext4_readpage, 2839 .readpage = ext4_readpage,
2838 .readpages = ext4_readpages, 2840 .readpages = ext4_readpages,
2839 .writepage = ext4_journalled_writepage, 2841 .writepage = ext4_journalled_writepage,
2840 .sync_page = block_sync_page, 2842 .sync_page = block_sync_page,
2841 .write_begin = ext4_write_begin, 2843 .write_begin = ext4_write_begin,
2842 .write_end = ext4_journalled_write_end, 2844 .write_end = ext4_journalled_write_end,
2843 .set_page_dirty = ext4_journalled_set_page_dirty, 2845 .set_page_dirty = ext4_journalled_set_page_dirty,
2844 .bmap = ext4_bmap, 2846 .bmap = ext4_bmap,
2845 .invalidatepage = ext4_invalidatepage, 2847 .invalidatepage = ext4_invalidatepage,
2846 .releasepage = ext4_releasepage, 2848 .releasepage = ext4_releasepage,
2849 .is_partially_uptodate = block_is_partially_uptodate,
2847}; 2850};
2848 2851
2849static const struct address_space_operations ext4_da_aops = { 2852static const struct address_space_operations ext4_da_aops = {
2850 .readpage = ext4_readpage, 2853 .readpage = ext4_readpage,
2851 .readpages = ext4_readpages, 2854 .readpages = ext4_readpages,
2852 .writepage = ext4_da_writepage, 2855 .writepage = ext4_da_writepage,
2853 .writepages = ext4_da_writepages, 2856 .writepages = ext4_da_writepages,
2854 .sync_page = block_sync_page, 2857 .sync_page = block_sync_page,
2855 .write_begin = ext4_da_write_begin, 2858 .write_begin = ext4_da_write_begin,
2856 .write_end = ext4_da_write_end, 2859 .write_end = ext4_da_write_end,
2857 .bmap = ext4_bmap, 2860 .bmap = ext4_bmap,
2858 .invalidatepage = ext4_da_invalidatepage, 2861 .invalidatepage = ext4_da_invalidatepage,
2859 .releasepage = ext4_releasepage, 2862 .releasepage = ext4_releasepage,
2860 .direct_IO = ext4_direct_IO, 2863 .direct_IO = ext4_direct_IO,
2861 .migratepage = buffer_migrate_page, 2864 .migratepage = buffer_migrate_page,
2865 .is_partially_uptodate = block_is_partially_uptodate,
2862}; 2866};
2863 2867
2864void ext4_set_aops(struct inode *inode) 2868void ext4_set_aops(struct inode *inode)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1cb371dcd609..b5479b1dff14 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -595,7 +595,7 @@ static void ext4_destroy_inode(struct inode *inode)
595 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 595 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
596} 596}
597 597
598static void init_once(struct kmem_cache *cachep, void *foo) 598static void init_once(void *foo)
599{ 599{
600 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 600 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
601 601
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 3a9ecac8d61f..3222f51c41cf 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -36,7 +36,7 @@ static inline int fat_max_cache(struct inode *inode)
36 36
37static struct kmem_cache *fat_cache_cachep; 37static struct kmem_cache *fat_cache_cachep;
38 38
39static void init_once(struct kmem_cache *cachep, void *foo) 39static void init_once(void *foo)
40{ 40{
41 struct fat_cache *cache = (struct fat_cache *)foo; 41 struct fat_cache *cache = (struct fat_cache *)foo;
42 42
diff --git a/fs/fat/file.c b/fs/fat/file.c
index c672df4036e9..8707a8cfa02c 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -15,6 +15,8 @@
15#include <linux/writeback.h> 15#include <linux/writeback.h>
16#include <linux/backing-dev.h> 16#include <linux/backing-dev.h>
17#include <linux/blkdev.h> 17#include <linux/blkdev.h>
18#include <linux/fsnotify.h>
19#include <linux/security.h>
18 20
19int fat_generic_ioctl(struct inode *inode, struct file *filp, 21int fat_generic_ioctl(struct inode *inode, struct file *filp,
20 unsigned int cmd, unsigned long arg) 22 unsigned int cmd, unsigned long arg)
@@ -64,6 +66,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
64 66
65 /* Equivalent to a chmod() */ 67 /* Equivalent to a chmod() */
66 ia.ia_valid = ATTR_MODE | ATTR_CTIME; 68 ia.ia_valid = ATTR_MODE | ATTR_CTIME;
69 ia.ia_ctime = current_fs_time(inode->i_sb);
67 if (is_dir) { 70 if (is_dir) {
68 ia.ia_mode = MSDOS_MKMODE(attr, 71 ia.ia_mode = MSDOS_MKMODE(attr,
69 S_IRWXUGO & ~sbi->options.fs_dmask) 72 S_IRWXUGO & ~sbi->options.fs_dmask)
@@ -90,11 +93,21 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
90 } 93 }
91 } 94 }
92 95
96 /*
97 * The security check is questionable... We single
98 * out the RO attribute for checking by the security
99 * module, just because it maps to a file mode.
100 */
101 err = security_inode_setattr(filp->f_path.dentry, &ia);
102 if (err)
103 goto up;
104
93 /* This MUST be done before doing anything irreversible... */ 105 /* This MUST be done before doing anything irreversible... */
94 err = notify_change(filp->f_path.dentry, &ia); 106 err = fat_setattr(filp->f_path.dentry, &ia);
95 if (err) 107 if (err)
96 goto up; 108 goto up;
97 109
110 fsnotify_change(filp->f_path.dentry, ia.ia_valid);
98 if (sbi->options.sys_immutable) { 111 if (sbi->options.sys_immutable) {
99 if (attr & ATTR_SYS) 112 if (attr & ATTR_SYS)
100 inode->i_flags |= S_IMMUTABLE; 113 inode->i_flags |= S_IMMUTABLE;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 23676f9d79ce..6d266d793e2c 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -498,7 +498,7 @@ static void fat_destroy_inode(struct inode *inode)
498 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 498 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
499} 499}
500 500
501static void init_once(struct kmem_cache *cachep, void *foo) 501static void init_once(void *foo)
502{ 502{
503 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; 503 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
504 504
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 9679fcbdeaa0..61d625136813 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -64,11 +64,6 @@ static int locate_fd(unsigned int orig_start, int cloexec)
64 struct fdtable *fdt; 64 struct fdtable *fdt;
65 65
66 spin_lock(&files->file_lock); 66 spin_lock(&files->file_lock);
67
68 error = -EINVAL;
69 if (orig_start >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
70 goto out;
71
72repeat: 67repeat:
73 fdt = files_fdtable(files); 68 fdt = files_fdtable(files);
74 /* 69 /*
@@ -83,10 +78,6 @@ repeat:
83 if (start < fdt->max_fds) 78 if (start < fdt->max_fds)
84 newfd = find_next_zero_bit(fdt->open_fds->fds_bits, 79 newfd = find_next_zero_bit(fdt->open_fds->fds_bits,
85 fdt->max_fds, start); 80 fdt->max_fds, start);
86
87 error = -EMFILE;
88 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
89 goto out;
90 81
91 error = expand_files(files, newfd); 82 error = expand_files(files, newfd);
92 if (error < 0) 83 if (error < 0)
@@ -135,20 +126,20 @@ asmlinkage long sys_dup3(unsigned int oldfd, unsigned int newfd, int flags)
135 if ((flags & ~O_CLOEXEC) != 0) 126 if ((flags & ~O_CLOEXEC) != 0)
136 return -EINVAL; 127 return -EINVAL;
137 128
129 if (unlikely(oldfd == newfd))
130 return -EINVAL;
131
138 spin_lock(&files->file_lock); 132 spin_lock(&files->file_lock);
139 if (!(file = fcheck(oldfd))) 133 if (!(file = fcheck(oldfd)))
140 goto out_unlock; 134 goto out_unlock;
141 err = newfd;
142 if (newfd == oldfd)
143 goto out_unlock;
144 err = -EBADF;
145 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
146 goto out_unlock;
147 get_file(file); /* We are now finished with oldfd */ 135 get_file(file); /* We are now finished with oldfd */
148 136
149 err = expand_files(files, newfd); 137 err = expand_files(files, newfd);
150 if (err < 0) 138 if (unlikely(err < 0)) {
139 if (err == -EMFILE)
140 err = -EBADF;
151 goto out_fput; 141 goto out_fput;
142 }
152 143
153 /* To avoid races with open() and dup(), we will mark the fd as 144 /* To avoid races with open() and dup(), we will mark the fd as
154 * in-use in the open-file bitmap throughout the entire dup2() 145 * in-use in the open-file bitmap throughout the entire dup2()
@@ -189,6 +180,14 @@ out_fput:
189 180
190asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) 181asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd)
191{ 182{
183 if (unlikely(newfd == oldfd)) { /* corner case */
184 struct files_struct *files = current->files;
185 rcu_read_lock();
186 if (!fcheck_files(files, oldfd))
187 oldfd = -EBADF;
188 rcu_read_unlock();
189 return oldfd;
190 }
192 return sys_dup3(oldfd, newfd, 0); 191 return sys_dup3(oldfd, newfd, 0);
193} 192}
194 193
@@ -321,6 +320,8 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
321 switch (cmd) { 320 switch (cmd) {
322 case F_DUPFD: 321 case F_DUPFD:
323 case F_DUPFD_CLOEXEC: 322 case F_DUPFD_CLOEXEC:
323 if (arg >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
324 break;
324 get_file(filp); 325 get_file(filp);
325 err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC); 326 err = dupfd(filp, arg, cmd == F_DUPFD_CLOEXEC);
326 break; 327 break;
diff --git a/fs/fifo.c b/fs/fifo.c
index 9785e36f81e7..987bf9411495 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -57,7 +57,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
57 * POSIX.1 says that O_NONBLOCK means return with the FIFO 57 * POSIX.1 says that O_NONBLOCK means return with the FIFO
58 * opened, even when there is no process writing the FIFO. 58 * opened, even when there is no process writing the FIFO.
59 */ 59 */
60 filp->f_op = &read_fifo_fops; 60 filp->f_op = &read_pipefifo_fops;
61 pipe->r_counter++; 61 pipe->r_counter++;
62 if (pipe->readers++ == 0) 62 if (pipe->readers++ == 0)
63 wake_up_partner(inode); 63 wake_up_partner(inode);
@@ -86,7 +86,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
86 if ((filp->f_flags & O_NONBLOCK) && !pipe->readers) 86 if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
87 goto err; 87 goto err;
88 88
89 filp->f_op = &write_fifo_fops; 89 filp->f_op = &write_pipefifo_fops;
90 pipe->w_counter++; 90 pipe->w_counter++;
91 if (!pipe->writers++) 91 if (!pipe->writers++)
92 wake_up_partner(inode); 92 wake_up_partner(inode);
@@ -105,7 +105,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
105 * This implementation will NEVER block on a O_RDWR open, since 105 * This implementation will NEVER block on a O_RDWR open, since
106 * the process can at least talk to itself. 106 * the process can at least talk to itself.
107 */ 107 */
108 filp->f_op = &rdwr_fifo_fops; 108 filp->f_op = &rdwr_pipefifo_fops;
109 109
110 pipe->readers++; 110 pipe->readers++;
111 pipe->writers++; 111 pipe->writers++;
@@ -151,5 +151,5 @@ err_nocleanup:
151 * depending on the access mode of the file... 151 * depending on the access mode of the file...
152 */ 152 */
153const struct file_operations def_fifo_fops = { 153const struct file_operations def_fifo_fops = {
154 .open = fifo_open, /* will set read or write pipe_fops */ 154 .open = fifo_open, /* will set read_ or write_pipefifo_fops */
155}; 155};
diff --git a/fs/file.c b/fs/file.c
index 7b3887e054d0..d8773b19fe47 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -250,9 +250,18 @@ int expand_files(struct files_struct *files, int nr)
250 struct fdtable *fdt; 250 struct fdtable *fdt;
251 251
252 fdt = files_fdtable(files); 252 fdt = files_fdtable(files);
253
254 /*
255 * N.B. For clone tasks sharing a files structure, this test
256 * will limit the total number of files that can be opened.
257 */
258 if (nr >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
259 return -EMFILE;
260
253 /* Do we need to expand? */ 261 /* Do we need to expand? */
254 if (nr < fdt->max_fds) 262 if (nr < fdt->max_fds)
255 return 0; 263 return 0;
264
256 /* Can we expand? */ 265 /* Can we expand? */
257 if (nr >= sysctl_nr_open) 266 if (nr >= sysctl_nr_open)
258 return -EMFILE; 267 return -EMFILE;
diff --git a/fs/file_table.c b/fs/file_table.c
index 83084225b4c3..f45a4493f9e7 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -120,7 +120,7 @@ struct file *get_empty_filp(void)
120 120
121 tsk = current; 121 tsk = current;
122 INIT_LIST_HEAD(&f->f_u.fu_list); 122 INIT_LIST_HEAD(&f->f_u.fu_list);
123 atomic_set(&f->f_count, 1); 123 atomic_long_set(&f->f_count, 1);
124 rwlock_init(&f->f_owner.lock); 124 rwlock_init(&f->f_owner.lock);
125 f->f_uid = tsk->fsuid; 125 f->f_uid = tsk->fsuid;
126 f->f_gid = tsk->fsgid; 126 f->f_gid = tsk->fsgid;
@@ -219,7 +219,7 @@ EXPORT_SYMBOL(init_file);
219 219
220void fput(struct file *file) 220void fput(struct file *file)
221{ 221{
222 if (atomic_dec_and_test(&file->f_count)) 222 if (atomic_long_dec_and_test(&file->f_count))
223 __fput(file); 223 __fput(file);
224} 224}
225 225
@@ -294,7 +294,7 @@ struct file *fget(unsigned int fd)
294 rcu_read_lock(); 294 rcu_read_lock();
295 file = fcheck_files(files, fd); 295 file = fcheck_files(files, fd);
296 if (file) { 296 if (file) {
297 if (!atomic_inc_not_zero(&file->f_count)) { 297 if (!atomic_long_inc_not_zero(&file->f_count)) {
298 /* File object ref couldn't be taken */ 298 /* File object ref couldn't be taken */
299 rcu_read_unlock(); 299 rcu_read_unlock();
300 return NULL; 300 return NULL;
@@ -326,7 +326,7 @@ struct file *fget_light(unsigned int fd, int *fput_needed)
326 rcu_read_lock(); 326 rcu_read_lock();
327 file = fcheck_files(files, fd); 327 file = fcheck_files(files, fd);
328 if (file) { 328 if (file) {
329 if (atomic_inc_not_zero(&file->f_count)) 329 if (atomic_long_inc_not_zero(&file->f_count))
330 *fput_needed = 1; 330 *fput_needed = 1;
331 else 331 else
332 /* Didn't get the reference, someone's freed */ 332 /* Didn't get the reference, someone's freed */
@@ -341,7 +341,7 @@ struct file *fget_light(unsigned int fd, int *fput_needed)
341 341
342void put_filp(struct file *file) 342void put_filp(struct file *file)
343{ 343{
344 if (atomic_dec_and_test(&file->f_count)) { 344 if (atomic_long_dec_and_test(&file->f_count)) {
345 security_file_free(file); 345 security_file_free(file);
346 file_kill(file); 346 file_kill(file);
347 file_free(file); 347 file_free(file);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 51d0035ff07e..fd03330cadeb 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -898,7 +898,7 @@ static int fuse_access(struct inode *inode, int mask)
898 return PTR_ERR(req); 898 return PTR_ERR(req);
899 899
900 memset(&inarg, 0, sizeof(inarg)); 900 memset(&inarg, 0, sizeof(inarg));
901 inarg.mask = mask; 901 inarg.mask = mask & (MAY_READ | MAY_WRITE | MAY_EXEC);
902 req->in.h.opcode = FUSE_ACCESS; 902 req->in.h.opcode = FUSE_ACCESS;
903 req->in.h.nodeid = get_node_id(inode); 903 req->in.h.nodeid = get_node_id(inode);
904 req->in.numargs = 1; 904 req->in.numargs = 1;
@@ -927,7 +927,7 @@ static int fuse_access(struct inode *inode, int mask)
927 * access request is sent. Execute permission is still checked 927 * access request is sent. Execute permission is still checked
928 * locally based on file mode. 928 * locally based on file mode.
929 */ 929 */
930static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) 930static int fuse_permission(struct inode *inode, int mask)
931{ 931{
932 struct fuse_conn *fc = get_fuse_conn(inode); 932 struct fuse_conn *fc = get_fuse_conn(inode);
933 bool refreshed = false; 933 bool refreshed = false;
@@ -962,7 +962,7 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
962 exist. So if permissions are revoked this won't be 962 exist. So if permissions are revoked this won't be
963 noticed immediately, only after the attribute 963 noticed immediately, only after the attribute
964 timeout has expired */ 964 timeout has expired */
965 } else if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR))) { 965 } else if (mask & MAY_ACCESS) {
966 err = fuse_access(inode, mask); 966 err = fuse_access(inode, mask);
967 } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) { 967 } else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) {
968 if (!(inode->i_mode & S_IXUGO)) { 968 if (!(inode->i_mode & S_IXUGO)) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 67ff2c6a8f63..2bada6bbc317 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
893 if (count == 0) 893 if (count == 0)
894 goto out; 894 goto out;
895 895
896 err = remove_suid(file->f_path.dentry); 896 err = file_remove_suid(file);
897 if (err) 897 if (err)
898 goto out; 898 goto out;
899 899
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 7d2f7d6e22e2..d2249f174e20 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -956,7 +956,7 @@ static inline void unregister_fuseblk(void)
956} 956}
957#endif 957#endif
958 958
959static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo) 959static void fuse_inode_init_once(void *foo)
960{ 960{
961 struct inode * inode = foo; 961 struct inode * inode = foo;
962 962
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 6da0ab355b8a..8b0806a32948 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -448,7 +448,7 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
448 struct qstr qstr; 448 struct qstr qstr;
449 struct inode *inode; 449 struct inode *inode;
450 gfs2_str2qstr(&qstr, name); 450 gfs2_str2qstr(&qstr, name);
451 inode = gfs2_lookupi(dip, &qstr, 1, NULL); 451 inode = gfs2_lookupi(dip, &qstr, 1);
452 /* gfs2_lookupi has inconsistent callers: vfs 452 /* gfs2_lookupi has inconsistent callers: vfs
453 * related routines expect NULL for no entry found, 453 * related routines expect NULL for no entry found,
454 * gfs2_lookup_simple callers expect ENOENT 454 * gfs2_lookup_simple callers expect ENOENT
@@ -477,7 +477,7 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
477 */ 477 */
478 478
479struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 479struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
480 int is_root, struct nameidata *nd) 480 int is_root)
481{ 481{
482 struct super_block *sb = dir->i_sb; 482 struct super_block *sb = dir->i_sb;
483 struct gfs2_inode *dip = GFS2_I(dir); 483 struct gfs2_inode *dip = GFS2_I(dir);
@@ -1173,7 +1173,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1173 break; 1173 break;
1174 } 1174 }
1175 1175
1176 tmp = gfs2_lookupi(dir, &dotdot, 1, NULL); 1176 tmp = gfs2_lookupi(dir, &dotdot, 1);
1177 if (IS_ERR(tmp)) { 1177 if (IS_ERR(tmp)) {
1178 error = PTR_ERR(tmp); 1178 error = PTR_ERR(tmp);
1179 break; 1179 break;
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 6074c2506f75..58f9607d6a86 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -83,7 +83,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip);
83int gfs2_dinode_dealloc(struct gfs2_inode *inode); 83int gfs2_dinode_dealloc(struct gfs2_inode *inode);
84int gfs2_change_nlink(struct gfs2_inode *ip, int diff); 84int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
85struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 85struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
86 int is_root, struct nameidata *nd); 86 int is_root);
87struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, 87struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
88 unsigned int mode, dev_t dev); 88 unsigned int mode, dev_t dev);
89int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, 89int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index bcc668d0fadd..bb2cc303ac29 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -24,7 +24,7 @@
24#include "util.h" 24#include "util.h"
25#include "glock.h" 25#include "glock.h"
26 26
27static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo) 27static void gfs2_init_inode_once(void *foo)
28{ 28{
29 struct gfs2_inode *ip = foo; 29 struct gfs2_inode *ip = foo;
30 30
@@ -33,7 +33,7 @@ static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo)
33 ip->i_alloc = NULL; 33 ip->i_alloc = NULL;
34} 34}
35 35
36static void gfs2_init_glock_once(struct kmem_cache *cachep, void *foo) 36static void gfs2_init_glock_once(void *foo)
37{ 37{
38 struct gfs2_glock *gl = foo; 38 struct gfs2_glock *gl = foo;
39 39
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index 990d9f4bc463..9cda8536530c 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -134,7 +134,7 @@ static struct dentry *gfs2_get_parent(struct dentry *child)
134 struct dentry *dentry; 134 struct dentry *dentry;
135 135
136 gfs2_str2qstr(&dotdot, ".."); 136 gfs2_str2qstr(&dotdot, "..");
137 inode = gfs2_lookupi(child->d_inode, &dotdot, 1, NULL); 137 inode = gfs2_lookupi(child->d_inode, &dotdot, 1);
138 138
139 if (!inode) 139 if (!inode)
140 return ERR_PTR(-ENOENT); 140 return ERR_PTR(-ENOENT);
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 1e252dfc5294..e2c62f73a778 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -74,7 +74,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
74 return PTR_ERR(inode); 74 return PTR_ERR(inode);
75 } 75 }
76 76
77 inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); 77 inode = gfs2_lookupi(dir, &dentry->d_name, 0);
78 if (inode) { 78 if (inode) {
79 if (!IS_ERR(inode)) { 79 if (!IS_ERR(inode)) {
80 gfs2_holder_uninit(ghs); 80 gfs2_holder_uninit(ghs);
@@ -109,7 +109,7 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
109 109
110 dentry->d_op = &gfs2_dops; 110 dentry->d_op = &gfs2_dops;
111 111
112 inode = gfs2_lookupi(dir, &dentry->d_name, 0, nd); 112 inode = gfs2_lookupi(dir, &dentry->d_name, 0);
113 if (inode && IS_ERR(inode)) 113 if (inode && IS_ERR(inode))
114 return ERR_CAST(inode); 114 return ERR_CAST(inode);
115 115
@@ -915,12 +915,6 @@ int gfs2_permission(struct inode *inode, int mask)
915 return error; 915 return error;
916} 916}
917 917
918static int gfs2_iop_permission(struct inode *inode, int mask,
919 struct nameidata *nd)
920{
921 return gfs2_permission(inode, mask);
922}
923
924static int setattr_size(struct inode *inode, struct iattr *attr) 918static int setattr_size(struct inode *inode, struct iattr *attr)
925{ 919{
926 struct gfs2_inode *ip = GFS2_I(inode); 920 struct gfs2_inode *ip = GFS2_I(inode);
@@ -1150,7 +1144,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
1150} 1144}
1151 1145
1152const struct inode_operations gfs2_file_iops = { 1146const struct inode_operations gfs2_file_iops = {
1153 .permission = gfs2_iop_permission, 1147 .permission = gfs2_permission,
1154 .setattr = gfs2_setattr, 1148 .setattr = gfs2_setattr,
1155 .getattr = gfs2_getattr, 1149 .getattr = gfs2_getattr,
1156 .setxattr = gfs2_setxattr, 1150 .setxattr = gfs2_setxattr,
@@ -1169,7 +1163,7 @@ const struct inode_operations gfs2_dir_iops = {
1169 .rmdir = gfs2_rmdir, 1163 .rmdir = gfs2_rmdir,
1170 .mknod = gfs2_mknod, 1164 .mknod = gfs2_mknod,
1171 .rename = gfs2_rename, 1165 .rename = gfs2_rename,
1172 .permission = gfs2_iop_permission, 1166 .permission = gfs2_permission,
1173 .setattr = gfs2_setattr, 1167 .setattr = gfs2_setattr,
1174 .getattr = gfs2_getattr, 1168 .getattr = gfs2_getattr,
1175 .setxattr = gfs2_setxattr, 1169 .setxattr = gfs2_setxattr,
@@ -1181,7 +1175,7 @@ const struct inode_operations gfs2_dir_iops = {
1181const struct inode_operations gfs2_symlink_iops = { 1175const struct inode_operations gfs2_symlink_iops = {
1182 .readlink = gfs2_readlink, 1176 .readlink = gfs2_readlink,
1183 .follow_link = gfs2_follow_link, 1177 .follow_link = gfs2_follow_link,
1184 .permission = gfs2_iop_permission, 1178 .permission = gfs2_permission,
1185 .setattr = gfs2_setattr, 1179 .setattr = gfs2_setattr,
1186 .getattr = gfs2_getattr, 1180 .getattr = gfs2_getattr,
1187 .setxattr = gfs2_setxattr, 1181 .setxattr = gfs2_setxattr,
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 63a8a902d9db..ca831991cbc2 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -389,7 +389,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
389 break; 389 break;
390 390
391 INIT_LIST_HEAD(&jd->extent_list); 391 INIT_LIST_HEAD(&jd->extent_list);
392 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1, NULL); 392 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1);
393 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { 393 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
394 if (!jd->jd_inode) 394 if (!jd->jd_inode)
395 error = -ENOENT; 395 error = -ENOENT;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index dc4ec640e875..7e19835efa2e 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -511,8 +511,7 @@ void hfs_clear_inode(struct inode *inode)
511 } 511 }
512} 512}
513 513
514static int hfs_permission(struct inode *inode, int mask, 514static int hfs_permission(struct inode *inode, int mask)
515 struct nameidata *nd)
516{ 515{
517 if (S_ISREG(inode->i_mode) && mask & MAY_EXEC) 516 if (S_ISREG(inode->i_mode) && mask & MAY_EXEC)
518 return 0; 517 return 0;
@@ -523,8 +522,6 @@ static int hfs_file_open(struct inode *inode, struct file *file)
523{ 522{
524 if (HFS_IS_RSRC(inode)) 523 if (HFS_IS_RSRC(inode))
525 inode = HFS_I(inode)->rsrc_inode; 524 inode = HFS_I(inode)->rsrc_inode;
526 if (atomic_read(&file->f_count) != 1)
527 return 0;
528 atomic_inc(&HFS_I(inode)->opencnt); 525 atomic_inc(&HFS_I(inode)->opencnt);
529 return 0; 526 return 0;
530} 527}
@@ -535,8 +532,6 @@ static int hfs_file_release(struct inode *inode, struct file *file)
535 532
536 if (HFS_IS_RSRC(inode)) 533 if (HFS_IS_RSRC(inode))
537 inode = HFS_I(inode)->rsrc_inode; 534 inode = HFS_I(inode)->rsrc_inode;
538 if (atomic_read(&file->f_count) != 0)
539 return 0;
540 if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) { 535 if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) {
541 mutex_lock(&inode->i_mutex); 536 mutex_lock(&inode->i_mutex);
542 hfs_file_truncate(inode); 537 hfs_file_truncate(inode);
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index ac2ec5ef66e4..4abb1047c689 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -432,7 +432,7 @@ static struct file_system_type hfs_fs_type = {
432 .fs_flags = FS_REQUIRES_DEV, 432 .fs_flags = FS_REQUIRES_DEV,
433}; 433};
434 434
435static void hfs_init_once(struct kmem_cache *cachep, void *p) 435static void hfs_init_once(void *p)
436{ 436{
437 struct hfs_inode_info *i = p; 437 struct hfs_inode_info *i = p;
438 438
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index cc3b5e24339b..b085d64a2b67 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -238,7 +238,7 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms)
238 perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); 238 perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev);
239} 239}
240 240
241static int hfsplus_permission(struct inode *inode, int mask, struct nameidata *nd) 241static int hfsplus_permission(struct inode *inode, int mask)
242{ 242{
243 /* MAY_EXEC is also used for lookup, if no x bit is set allow lookup, 243 /* MAY_EXEC is also used for lookup, if no x bit is set allow lookup,
244 * open_exec has the same test, so it's still not executable, if a x bit 244 * open_exec has the same test, so it's still not executable, if a x bit
@@ -254,8 +254,6 @@ static int hfsplus_file_open(struct inode *inode, struct file *file)
254{ 254{
255 if (HFSPLUS_IS_RSRC(inode)) 255 if (HFSPLUS_IS_RSRC(inode))
256 inode = HFSPLUS_I(inode).rsrc_inode; 256 inode = HFSPLUS_I(inode).rsrc_inode;
257 if (atomic_read(&file->f_count) != 1)
258 return 0;
259 atomic_inc(&HFSPLUS_I(inode).opencnt); 257 atomic_inc(&HFSPLUS_I(inode).opencnt);
260 return 0; 258 return 0;
261} 259}
@@ -266,8 +264,6 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
266 264
267 if (HFSPLUS_IS_RSRC(inode)) 265 if (HFSPLUS_IS_RSRC(inode))
268 inode = HFSPLUS_I(inode).rsrc_inode; 266 inode = HFSPLUS_I(inode).rsrc_inode;
269 if (atomic_read(&file->f_count) != 0)
270 return 0;
271 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { 267 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) {
272 mutex_lock(&inode->i_mutex); 268 mutex_lock(&inode->i_mutex);
273 hfsplus_file_truncate(inode); 269 hfsplus_file_truncate(inode);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 3859118531c7..e834e578c93f 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -485,7 +485,7 @@ static struct file_system_type hfsplus_fs_type = {
485 .fs_flags = FS_REQUIRES_DEV, 485 .fs_flags = FS_REQUIRES_DEV,
486}; 486};
487 487
488static void hfsplus_init_once(struct kmem_cache *cachep, void *p) 488static void hfsplus_init_once(void *p)
489{ 489{
490 struct hfsplus_inode_info *i = p; 490 struct hfsplus_inode_info *i = p;
491 491
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 5222345ddccf..d6ecabf4d231 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -822,7 +822,7 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
822 return err; 822 return err;
823} 823}
824 824
825int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) 825int hostfs_permission(struct inode *ino, int desired)
826{ 826{
827 char *name; 827 char *name;
828 int r = 0, w = 0, x = 0, err; 828 int r = 0, w = 0, x = 0, err;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index d256559b4104..d9c59a775449 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -415,7 +415,7 @@ again:
415 d_drop(dentry); 415 d_drop(dentry);
416 spin_lock(&dentry->d_lock); 416 spin_lock(&dentry->d_lock);
417 if (atomic_read(&dentry->d_count) > 1 || 417 if (atomic_read(&dentry->d_count) > 1 ||
418 permission(inode, MAY_WRITE, NULL) || 418 generic_permission(inode, MAY_WRITE, NULL) ||
419 !S_ISREG(inode->i_mode) || 419 !S_ISREG(inode->i_mode) ||
420 get_write_access(inode)) { 420 get_write_access(inode)) {
421 spin_unlock(&dentry->d_lock); 421 spin_unlock(&dentry->d_lock);
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index f63a699ec659..b8ae9c90ada0 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -173,7 +173,7 @@ static void hpfs_destroy_inode(struct inode *inode)
173 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 173 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
174} 174}
175 175
176static void init_once(struct kmem_cache *cachep, void *foo) 176static void init_once(void *foo)
177{ 177{
178 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 178 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
179 179
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 65077aa90f0a..2b3d1828db99 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -655,20 +655,13 @@ static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
655 return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd); 655 return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
656} 656}
657 657
658int hppfs_permission(struct inode *inode, int mask, struct nameidata *nd)
659{
660 return generic_permission(inode, mask, NULL);
661}
662
663static const struct inode_operations hppfs_dir_iops = { 658static const struct inode_operations hppfs_dir_iops = {
664 .lookup = hppfs_lookup, 659 .lookup = hppfs_lookup,
665 .permission = hppfs_permission,
666}; 660};
667 661
668static const struct inode_operations hppfs_link_iops = { 662static const struct inode_operations hppfs_link_iops = {
669 .readlink = hppfs_readlink, 663 .readlink = hppfs_readlink,
670 .follow_link = hppfs_follow_link, 664 .follow_link = hppfs_follow_link,
671 .permission = hppfs_permission,
672}; 665};
673 666
674static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) 667static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index dbd01d262ca4..3f58923fb39b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -705,7 +705,7 @@ static const struct address_space_operations hugetlbfs_aops = {
705}; 705};
706 706
707 707
708static void init_once(struct kmem_cache *cachep, void *foo) 708static void init_once(void *foo)
709{ 709{
710 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; 710 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
711 711
diff --git a/fs/inode.c b/fs/inode.c
index c36d9480335c..b6726f644530 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode)
209 INIT_LIST_HEAD(&inode->i_dentry); 209 INIT_LIST_HEAD(&inode->i_dentry);
210 INIT_LIST_HEAD(&inode->i_devices); 210 INIT_LIST_HEAD(&inode->i_devices);
211 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); 211 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
212 rwlock_init(&inode->i_data.tree_lock); 212 spin_lock_init(&inode->i_data.tree_lock);
213 spin_lock_init(&inode->i_data.i_mmap_lock); 213 spin_lock_init(&inode->i_data.i_mmap_lock);
214 INIT_LIST_HEAD(&inode->i_data.private_list); 214 INIT_LIST_HEAD(&inode->i_data.private_list);
215 spin_lock_init(&inode->i_data.private_lock); 215 spin_lock_init(&inode->i_data.private_lock);
@@ -224,7 +224,7 @@ void inode_init_once(struct inode *inode)
224 224
225EXPORT_SYMBOL(inode_init_once); 225EXPORT_SYMBOL(inode_init_once);
226 226
227static void init_once(struct kmem_cache * cachep, void *foo) 227static void init_once(void *foo)
228{ 228{
229 struct inode * inode = (struct inode *) foo; 229 struct inode * inode = (struct inode *) foo;
230 230
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index fe79c25d95dc..60249429a253 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -354,20 +354,20 @@ static void inotify_dev_event_dequeue(struct inotify_device *dev)
354} 354}
355 355
356/* 356/*
357 * find_inode - resolve a user-given path to a specific inode and return a nd 357 * find_inode - resolve a user-given path to a specific inode
358 */ 358 */
359static int find_inode(const char __user *dirname, struct nameidata *nd, 359static int find_inode(const char __user *dirname, struct path *path,
360 unsigned flags) 360 unsigned flags)
361{ 361{
362 int error; 362 int error;
363 363
364 error = __user_walk(dirname, flags, nd); 364 error = user_path_at(AT_FDCWD, dirname, flags, path);
365 if (error) 365 if (error)
366 return error; 366 return error;
367 /* you can only watch an inode if you have read permissions on it */ 367 /* you can only watch an inode if you have read permissions on it */
368 error = vfs_permission(nd, MAY_READ); 368 error = inode_permission(path->dentry->d_inode, MAY_READ);
369 if (error) 369 if (error)
370 path_put(&nd->path); 370 path_put(path);
371 return error; 371 return error;
372} 372}
373 373
@@ -650,11 +650,11 @@ asmlinkage long sys_inotify_init(void)
650 return sys_inotify_init1(0); 650 return sys_inotify_init1(0);
651} 651}
652 652
653asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask) 653asmlinkage long sys_inotify_add_watch(int fd, const char __user *pathname, u32 mask)
654{ 654{
655 struct inode *inode; 655 struct inode *inode;
656 struct inotify_device *dev; 656 struct inotify_device *dev;
657 struct nameidata nd; 657 struct path path;
658 struct file *filp; 658 struct file *filp;
659 int ret, fput_needed; 659 int ret, fput_needed;
660 unsigned flags = 0; 660 unsigned flags = 0;
@@ -674,12 +674,12 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
674 if (mask & IN_ONLYDIR) 674 if (mask & IN_ONLYDIR)
675 flags |= LOOKUP_DIRECTORY; 675 flags |= LOOKUP_DIRECTORY;
676 676
677 ret = find_inode(path, &nd, flags); 677 ret = find_inode(pathname, &path, flags);
678 if (unlikely(ret)) 678 if (unlikely(ret))
679 goto fput_and_out; 679 goto fput_and_out;
680 680
681 /* inode held in place by reference to nd; dev by fget on fd */ 681 /* inode held in place by reference to path; dev by fget on fd */
682 inode = nd.path.dentry->d_inode; 682 inode = path.dentry->d_inode;
683 dev = filp->private_data; 683 dev = filp->private_data;
684 684
685 mutex_lock(&dev->up_mutex); 685 mutex_lock(&dev->up_mutex);
@@ -688,7 +688,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
688 ret = create_watch(dev, inode, mask); 688 ret = create_watch(dev, inode, mask);
689 mutex_unlock(&dev->up_mutex); 689 mutex_unlock(&dev->up_mutex);
690 690
691 path_put(&nd.path); 691 path_put(&path);
692fput_and_out: 692fput_and_out:
693 fput_light(filp, fput_needed); 693 fput_light(filp, fput_needed);
694 return ret; 694 return ret;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 044a254d526b..26948a6033b6 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
74} 74}
75 75
76static void init_once(struct kmem_cache *cachep, void *foo) 76static void init_once(void *foo)
77{ 77{
78 struct iso_inode_info *ei = foo; 78 struct iso_inode_info *ei = foo;
79 79
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 4c80404a9aba..d98713777a1b 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -314,7 +314,7 @@ static int jffs2_check_acl(struct inode *inode, int mask)
314 return -EAGAIN; 314 return -EAGAIN;
315} 315}
316 316
317int jffs2_permission(struct inode *inode, int mask, struct nameidata *nd) 317int jffs2_permission(struct inode *inode, int mask)
318{ 318{
319 return generic_permission(inode, mask, jffs2_check_acl); 319 return generic_permission(inode, mask, jffs2_check_acl);
320} 320}
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
index 0bb7f003fd80..8ca058aed384 100644
--- a/fs/jffs2/acl.h
+++ b/fs/jffs2/acl.h
@@ -28,7 +28,7 @@ struct jffs2_acl_header {
28 28
29#define JFFS2_ACL_NOT_CACHED ((void *)-1) 29#define JFFS2_ACL_NOT_CACHED ((void *)-1)
30 30
31extern int jffs2_permission(struct inode *, int, struct nameidata *); 31extern int jffs2_permission(struct inode *, int);
32extern int jffs2_acl_chmod(struct inode *); 32extern int jffs2_acl_chmod(struct inode *);
33extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); 33extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *);
34extern int jffs2_init_acl_post(struct inode *); 34extern int jffs2_init_acl_post(struct inode *);
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index c0c141f6fde1..cd219ef55254 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -38,7 +38,7 @@ const struct file_operations jffs2_dir_operations =
38{ 38{
39 .read = generic_read_dir, 39 .read = generic_read_dir,
40 .readdir = jffs2_readdir, 40 .readdir = jffs2_readdir,
41 .ioctl = jffs2_ioctl, 41 .unlocked_ioctl=jffs2_ioctl,
42 .fsync = jffs2_fsync 42 .fsync = jffs2_fsync
43}; 43};
44 44
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 5e920343b2c5..5a98aa87c853 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -46,7 +46,7 @@ const struct file_operations jffs2_file_operations =
46 .aio_read = generic_file_aio_read, 46 .aio_read = generic_file_aio_read,
47 .write = do_sync_write, 47 .write = do_sync_write,
48 .aio_write = generic_file_aio_write, 48 .aio_write = generic_file_aio_write,
49 .ioctl = jffs2_ioctl, 49 .unlocked_ioctl=jffs2_ioctl,
50 .mmap = generic_file_readonly_mmap, 50 .mmap = generic_file_readonly_mmap,
51 .fsync = jffs2_fsync, 51 .fsync = jffs2_fsync,
52 .splice_read = generic_file_splice_read, 52 .splice_read = generic_file_splice_read,
diff --git a/fs/jffs2/ioctl.c b/fs/jffs2/ioctl.c
index e2177210f621..9d41f43e47bb 100644
--- a/fs/jffs2/ioctl.c
+++ b/fs/jffs2/ioctl.c
@@ -12,8 +12,7 @@
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include "nodelist.h" 13#include "nodelist.h"
14 14
15int jffs2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 15long jffs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
16 unsigned long arg)
17{ 16{
18 /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which 17 /* Later, this will provide for lsattr.jffs2 and chattr.jffs2, which
19 will include compression support etc. */ 18 will include compression support etc. */
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 2cc866cf134f..5e194a5c8e29 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -167,7 +167,7 @@ int jffs2_fsync(struct file *, struct dentry *, int);
167int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg); 167int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg);
168 168
169/* ioctl.c */ 169/* ioctl.c */
170int jffs2_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 170long jffs2_ioctl(struct file *, unsigned int, unsigned long);
171 171
172/* symlink.c */ 172/* symlink.c */
173extern const struct inode_operations jffs2_symlink_inode_operations; 173extern const struct inode_operations jffs2_symlink_inode_operations;
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 7da69eae49e4..efd401257ed9 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode)
44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
45} 45}
46 46
47static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) 47static void jffs2_i_init_once(void *foo)
48{ 48{
49 struct jffs2_inode_info *f = foo; 49 struct jffs2_inode_info *f = foo;
50 50
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 4d84bdc88299..d3e5c33665de 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -140,7 +140,7 @@ static int jfs_check_acl(struct inode *inode, int mask)
140 return -EAGAIN; 140 return -EAGAIN;
141} 141}
142 142
143int jfs_permission(struct inode *inode, int mask, struct nameidata *nd) 143int jfs_permission(struct inode *inode, int mask)
144{ 144{
145 return generic_permission(inode, mask, jfs_check_acl); 145 return generic_permission(inode, mask, jfs_check_acl);
146} 146}
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
index 455fa4292045..88475f10a389 100644
--- a/fs/jfs/jfs_acl.h
+++ b/fs/jfs/jfs_acl.h
@@ -20,7 +20,7 @@
20 20
21#ifdef CONFIG_JFS_POSIX_ACL 21#ifdef CONFIG_JFS_POSIX_ACL
22 22
23int jfs_permission(struct inode *, int, struct nameidata *); 23int jfs_permission(struct inode *, int);
24int jfs_init_acl(tid_t, struct inode *, struct inode *); 24int jfs_init_acl(tid_t, struct inode *, struct inode *);
25int jfs_setattr(struct dentry *, struct iattr *); 25int jfs_setattr(struct dentry *, struct iattr *);
26 26
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 854ff0ec574f..c350057087dd 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -182,7 +182,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
182 182
183#endif 183#endif
184 184
185static void init_once(struct kmem_cache *cachep, void *foo) 185static void init_once(void *foo)
186{ 186{
187 struct metapage *mp = (struct metapage *)foo; 187 struct metapage *mp = (struct metapage *)foo;
188 188
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 359c091d8965..3630718be395 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -760,7 +760,7 @@ static struct file_system_type jfs_fs_type = {
760 .fs_flags = FS_REQUIRES_DEV, 760 .fs_flags = FS_REQUIRES_DEV,
761}; 761};
762 762
763static void init_once(struct kmem_cache *cachep, void *foo) 763static void init_once(void *foo)
764{ 764{
765 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 765 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
766 766
diff --git a/fs/locks.c b/fs/locks.c
index 01490300f7cb..5eb259e3cd38 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -201,7 +201,7 @@ EXPORT_SYMBOL(locks_init_lock);
201 * Initialises the fields of the file lock which are invariant for 201 * Initialises the fields of the file lock which are invariant for
202 * free file_locks. 202 * free file_locks.
203 */ 203 */
204static void init_once(struct kmem_cache *cache, void *foo) 204static void init_once(void *foo)
205{ 205{
206 struct file_lock *lock = (struct file_lock *) foo; 206 struct file_lock *lock = (struct file_lock *) foo;
207 207
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 523d73713418..d1d1eb84679d 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -68,7 +68,7 @@ static void minix_destroy_inode(struct inode *inode)
68 kmem_cache_free(minix_inode_cachep, minix_i(inode)); 68 kmem_cache_free(minix_inode_cachep, minix_i(inode));
69} 69}
70 70
71static void init_once(struct kmem_cache * cachep, void *foo) 71static void init_once(void *foo)
72{ 72{
73 struct minix_inode_info *ei = (struct minix_inode_info *) foo; 73 struct minix_inode_info *ei = (struct minix_inode_info *) foo;
74 74
diff --git a/fs/namei.c b/fs/namei.c
index 01e67dddcc3d..a7b0a0b80128 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -31,7 +31,6 @@
31#include <linux/file.h> 31#include <linux/file.h>
32#include <linux/fcntl.h> 32#include <linux/fcntl.h>
33#include <linux/device_cgroup.h> 33#include <linux/device_cgroup.h>
34#include <asm/namei.h>
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36 35
37#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) 36#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
@@ -185,6 +184,8 @@ int generic_permission(struct inode *inode, int mask,
185{ 184{
186 umode_t mode = inode->i_mode; 185 umode_t mode = inode->i_mode;
187 186
187 mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
188
188 if (current->fsuid == inode->i_uid) 189 if (current->fsuid == inode->i_uid)
189 mode >>= 6; 190 mode >>= 6;
190 else { 191 else {
@@ -203,7 +204,7 @@ int generic_permission(struct inode *inode, int mask,
203 /* 204 /*
204 * If the DACs are ok we don't need any capability check. 205 * If the DACs are ok we don't need any capability check.
205 */ 206 */
206 if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)) 207 if ((mask & ~mode) == 0)
207 return 0; 208 return 0;
208 209
209 check_capabilities: 210 check_capabilities:
@@ -226,13 +227,9 @@ int generic_permission(struct inode *inode, int mask,
226 return -EACCES; 227 return -EACCES;
227} 228}
228 229
229int permission(struct inode *inode, int mask, struct nameidata *nd) 230int inode_permission(struct inode *inode, int mask)
230{ 231{
231 int retval, submask; 232 int retval;
232 struct vfsmount *mnt = NULL;
233
234 if (nd)
235 mnt = nd->path.mnt;
236 233
237 if (mask & MAY_WRITE) { 234 if (mask & MAY_WRITE) {
238 umode_t mode = inode->i_mode; 235 umode_t mode = inode->i_mode;
@@ -251,19 +248,9 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
251 return -EACCES; 248 return -EACCES;
252 } 249 }
253 250
254 if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) {
255 /*
256 * MAY_EXEC on regular files is denied if the fs is mounted
257 * with the "noexec" flag.
258 */
259 if (mnt && (mnt->mnt_flags & MNT_NOEXEC))
260 return -EACCES;
261 }
262
263 /* Ordinary permission routines do not understand MAY_APPEND. */ 251 /* Ordinary permission routines do not understand MAY_APPEND. */
264 submask = mask & ~MAY_APPEND;
265 if (inode->i_op && inode->i_op->permission) { 252 if (inode->i_op && inode->i_op->permission) {
266 retval = inode->i_op->permission(inode, submask, nd); 253 retval = inode->i_op->permission(inode, mask);
267 if (!retval) { 254 if (!retval) {
268 /* 255 /*
269 * Exec permission on a regular file is denied if none 256 * Exec permission on a regular file is denied if none
@@ -277,7 +264,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
277 return -EACCES; 264 return -EACCES;
278 } 265 }
279 } else { 266 } else {
280 retval = generic_permission(inode, submask, NULL); 267 retval = generic_permission(inode, mask, NULL);
281 } 268 }
282 if (retval) 269 if (retval)
283 return retval; 270 return retval;
@@ -286,7 +273,8 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
286 if (retval) 273 if (retval)
287 return retval; 274 return retval;
288 275
289 return security_inode_permission(inode, mask, nd); 276 return security_inode_permission(inode,
277 mask & (MAY_READ|MAY_WRITE|MAY_EXEC));
290} 278}
291 279
292/** 280/**
@@ -301,7 +289,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
301 */ 289 */
302int vfs_permission(struct nameidata *nd, int mask) 290int vfs_permission(struct nameidata *nd, int mask)
303{ 291{
304 return permission(nd->path.dentry->d_inode, mask, nd); 292 return inode_permission(nd->path.dentry->d_inode, mask);
305} 293}
306 294
307/** 295/**
@@ -318,7 +306,7 @@ int vfs_permission(struct nameidata *nd, int mask)
318 */ 306 */
319int file_permission(struct file *file, int mask) 307int file_permission(struct file *file, int mask)
320{ 308{
321 return permission(file->f_path.dentry->d_inode, mask, NULL); 309 return inode_permission(file->f_path.dentry->d_inode, mask);
322} 310}
323 311
324/* 312/*
@@ -459,8 +447,7 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name,
459 * short-cut DAC fails, then call permission() to do more 447 * short-cut DAC fails, then call permission() to do more
460 * complete permission check. 448 * complete permission check.
461 */ 449 */
462static int exec_permission_lite(struct inode *inode, 450static int exec_permission_lite(struct inode *inode)
463 struct nameidata *nd)
464{ 451{
465 umode_t mode = inode->i_mode; 452 umode_t mode = inode->i_mode;
466 453
@@ -486,7 +473,7 @@ static int exec_permission_lite(struct inode *inode,
486 473
487 return -EACCES; 474 return -EACCES;
488ok: 475ok:
489 return security_inode_permission(inode, MAY_EXEC, nd); 476 return security_inode_permission(inode, MAY_EXEC);
490} 477}
491 478
492/* 479/*
@@ -519,7 +506,14 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
519 */ 506 */
520 result = d_lookup(parent, name); 507 result = d_lookup(parent, name);
521 if (!result) { 508 if (!result) {
522 struct dentry * dentry = d_alloc(parent, name); 509 struct dentry *dentry;
510
511 /* Don't create child dentry for a dead directory. */
512 result = ERR_PTR(-ENOENT);
513 if (IS_DEADDIR(dir))
514 goto out_unlock;
515
516 dentry = d_alloc(parent, name);
523 result = ERR_PTR(-ENOMEM); 517 result = ERR_PTR(-ENOMEM);
524 if (dentry) { 518 if (dentry) {
525 result = dir->i_op->lookup(dir, dentry, nd); 519 result = dir->i_op->lookup(dir, dentry, nd);
@@ -528,6 +522,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
528 else 522 else
529 result = dentry; 523 result = dentry;
530 } 524 }
525out_unlock:
531 mutex_unlock(&dir->i_mutex); 526 mutex_unlock(&dir->i_mutex);
532 return result; 527 return result;
533 } 528 }
@@ -545,27 +540,16 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
545 return result; 540 return result;
546} 541}
547 542
548static int __emul_lookup_dentry(const char *, struct nameidata *);
549
550/* SMP-safe */ 543/* SMP-safe */
551static __always_inline int 544static __always_inline void
552walk_init_root(const char *name, struct nameidata *nd) 545walk_init_root(const char *name, struct nameidata *nd)
553{ 546{
554 struct fs_struct *fs = current->fs; 547 struct fs_struct *fs = current->fs;
555 548
556 read_lock(&fs->lock); 549 read_lock(&fs->lock);
557 if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
558 nd->path = fs->altroot;
559 path_get(&fs->altroot);
560 read_unlock(&fs->lock);
561 if (__emul_lookup_dentry(name,nd))
562 return 0;
563 read_lock(&fs->lock);
564 }
565 nd->path = fs->root; 550 nd->path = fs->root;
566 path_get(&fs->root); 551 path_get(&fs->root);
567 read_unlock(&fs->lock); 552 read_unlock(&fs->lock);
568 return 1;
569} 553}
570 554
571/* 555/*
@@ -606,12 +590,9 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *l
606 590
607 if (*link == '/') { 591 if (*link == '/') {
608 path_put(&nd->path); 592 path_put(&nd->path);
609 if (!walk_init_root(link, nd)) 593 walk_init_root(link, nd);
610 /* weird __emul_prefix() stuff did it */
611 goto out;
612 } 594 }
613 res = link_path_walk(link, nd); 595 res = link_path_walk(link, nd);
614out:
615 if (nd->depth || res || nd->last_type!=LAST_NORM) 596 if (nd->depth || res || nd->last_type!=LAST_NORM)
616 return res; 597 return res;
617 /* 598 /*
@@ -889,7 +870,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
889 unsigned int c; 870 unsigned int c;
890 871
891 nd->flags |= LOOKUP_CONTINUE; 872 nd->flags |= LOOKUP_CONTINUE;
892 err = exec_permission_lite(inode, nd); 873 err = exec_permission_lite(inode);
893 if (err == -EAGAIN) 874 if (err == -EAGAIN)
894 err = vfs_permission(nd, MAY_EXEC); 875 err = vfs_permission(nd, MAY_EXEC);
895 if (err) 876 if (err)
@@ -1060,67 +1041,6 @@ static int path_walk(const char *name, struct nameidata *nd)
1060 return link_path_walk(name, nd); 1041 return link_path_walk(name, nd);
1061} 1042}
1062 1043
1063/*
1064 * SMP-safe: Returns 1 and nd will have valid dentry and mnt, if
1065 * everything is done. Returns 0 and drops input nd, if lookup failed;
1066 */
1067static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
1068{
1069 if (path_walk(name, nd))
1070 return 0; /* something went wrong... */
1071
1072 if (!nd->path.dentry->d_inode ||
1073 S_ISDIR(nd->path.dentry->d_inode->i_mode)) {
1074 struct path old_path = nd->path;
1075 struct qstr last = nd->last;
1076 int last_type = nd->last_type;
1077 struct fs_struct *fs = current->fs;
1078
1079 /*
1080 * NAME was not found in alternate root or it's a directory.
1081 * Try to find it in the normal root:
1082 */
1083 nd->last_type = LAST_ROOT;
1084 read_lock(&fs->lock);
1085 nd->path = fs->root;
1086 path_get(&fs->root);
1087 read_unlock(&fs->lock);
1088 if (path_walk(name, nd) == 0) {
1089 if (nd->path.dentry->d_inode) {
1090 path_put(&old_path);
1091 return 1;
1092 }
1093 path_put(&nd->path);
1094 }
1095 nd->path = old_path;
1096 nd->last = last;
1097 nd->last_type = last_type;
1098 }
1099 return 1;
1100}
1101
1102void set_fs_altroot(void)
1103{
1104 char *emul = __emul_prefix();
1105 struct nameidata nd;
1106 struct path path = {}, old_path;
1107 int err;
1108 struct fs_struct *fs = current->fs;
1109
1110 if (!emul)
1111 goto set_it;
1112 err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd);
1113 if (!err)
1114 path = nd.path;
1115set_it:
1116 write_lock(&fs->lock);
1117 old_path = fs->altroot;
1118 fs->altroot = path;
1119 write_unlock(&fs->lock);
1120 if (old_path.dentry)
1121 path_put(&old_path);
1122}
1123
1124/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ 1044/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
1125static int do_path_lookup(int dfd, const char *name, 1045static int do_path_lookup(int dfd, const char *name,
1126 unsigned int flags, struct nameidata *nd) 1046 unsigned int flags, struct nameidata *nd)
@@ -1136,14 +1056,6 @@ static int do_path_lookup(int dfd, const char *name,
1136 1056
1137 if (*name=='/') { 1057 if (*name=='/') {
1138 read_lock(&fs->lock); 1058 read_lock(&fs->lock);
1139 if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
1140 nd->path = fs->altroot;
1141 path_get(&fs->altroot);
1142 read_unlock(&fs->lock);
1143 if (__emul_lookup_dentry(name,nd))
1144 goto out; /* found in altroot */
1145 read_lock(&fs->lock);
1146 }
1147 nd->path = fs->root; 1059 nd->path = fs->root;
1148 path_get(&fs->root); 1060 path_get(&fs->root);
1149 read_unlock(&fs->lock); 1061 read_unlock(&fs->lock);
@@ -1177,7 +1089,6 @@ static int do_path_lookup(int dfd, const char *name,
1177 } 1089 }
1178 1090
1179 retval = path_walk(name, nd); 1091 retval = path_walk(name, nd);
1180out:
1181 if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry && 1092 if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
1182 nd->path.dentry->d_inode)) 1093 nd->path.dentry->d_inode))
1183 audit_inode(name, nd->path.dentry); 1094 audit_inode(name, nd->path.dentry);
@@ -1282,19 +1193,6 @@ static int path_lookup_create(int dfd, const char *name,
1282 nd, open_flags, create_mode); 1193 nd, open_flags, create_mode);
1283} 1194}
1284 1195
1285int __user_path_lookup_open(const char __user *name, unsigned int lookup_flags,
1286 struct nameidata *nd, int open_flags)
1287{
1288 char *tmp = getname(name);
1289 int err = PTR_ERR(tmp);
1290
1291 if (!IS_ERR(tmp)) {
1292 err = __path_lookup_intent_open(AT_FDCWD, tmp, lookup_flags, nd, open_flags, 0);
1293 putname(tmp);
1294 }
1295 return err;
1296}
1297
1298static struct dentry *__lookup_hash(struct qstr *name, 1196static struct dentry *__lookup_hash(struct qstr *name,
1299 struct dentry *base, struct nameidata *nd) 1197 struct dentry *base, struct nameidata *nd)
1300{ 1198{
@@ -1317,7 +1215,14 @@ static struct dentry *__lookup_hash(struct qstr *name,
1317 1215
1318 dentry = cached_lookup(base, name, nd); 1216 dentry = cached_lookup(base, name, nd);
1319 if (!dentry) { 1217 if (!dentry) {
1320 struct dentry *new = d_alloc(base, name); 1218 struct dentry *new;
1219
1220 /* Don't create child dentry for a dead directory. */
1221 dentry = ERR_PTR(-ENOENT);
1222 if (IS_DEADDIR(inode))
1223 goto out;
1224
1225 new = d_alloc(base, name);
1321 dentry = ERR_PTR(-ENOMEM); 1226 dentry = ERR_PTR(-ENOMEM);
1322 if (!new) 1227 if (!new)
1323 goto out; 1228 goto out;
@@ -1340,7 +1245,7 @@ static struct dentry *lookup_hash(struct nameidata *nd)
1340{ 1245{
1341 int err; 1246 int err;
1342 1247
1343 err = permission(nd->path.dentry->d_inode, MAY_EXEC, nd); 1248 err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC);
1344 if (err) 1249 if (err)
1345 return ERR_PTR(err); 1250 return ERR_PTR(err);
1346 return __lookup_hash(&nd->last, nd->path.dentry, nd); 1251 return __lookup_hash(&nd->last, nd->path.dentry, nd);
@@ -1388,7 +1293,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
1388 if (err) 1293 if (err)
1389 return ERR_PTR(err); 1294 return ERR_PTR(err);
1390 1295
1391 err = permission(base->d_inode, MAY_EXEC, NULL); 1296 err = inode_permission(base->d_inode, MAY_EXEC);
1392 if (err) 1297 if (err)
1393 return ERR_PTR(err); 1298 return ERR_PTR(err);
1394 return __lookup_hash(&this, base, NULL); 1299 return __lookup_hash(&this, base, NULL);
@@ -1416,22 +1321,40 @@ struct dentry *lookup_one_noperm(const char *name, struct dentry *base)
1416 return __lookup_hash(&this, base, NULL); 1321 return __lookup_hash(&this, base, NULL);
1417} 1322}
1418 1323
1419int __user_walk_fd(int dfd, const char __user *name, unsigned flags, 1324int user_path_at(int dfd, const char __user *name, unsigned flags,
1420 struct nameidata *nd) 1325 struct path *path)
1421{ 1326{
1327 struct nameidata nd;
1422 char *tmp = getname(name); 1328 char *tmp = getname(name);
1423 int err = PTR_ERR(tmp); 1329 int err = PTR_ERR(tmp);
1424
1425 if (!IS_ERR(tmp)) { 1330 if (!IS_ERR(tmp)) {
1426 err = do_path_lookup(dfd, tmp, flags, nd); 1331
1332 BUG_ON(flags & LOOKUP_PARENT);
1333
1334 err = do_path_lookup(dfd, tmp, flags, &nd);
1427 putname(tmp); 1335 putname(tmp);
1336 if (!err)
1337 *path = nd.path;
1428 } 1338 }
1429 return err; 1339 return err;
1430} 1340}
1431 1341
1432int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) 1342static int user_path_parent(int dfd, const char __user *path,
1343 struct nameidata *nd, char **name)
1433{ 1344{
1434 return __user_walk_fd(AT_FDCWD, name, flags, nd); 1345 char *s = getname(path);
1346 int error;
1347
1348 if (IS_ERR(s))
1349 return PTR_ERR(s);
1350
1351 error = do_path_lookup(dfd, s, LOOKUP_PARENT, nd);
1352 if (error)
1353 putname(s);
1354 else
1355 *name = s;
1356
1357 return error;
1435} 1358}
1436 1359
1437/* 1360/*
@@ -1478,7 +1401,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
1478 BUG_ON(victim->d_parent->d_inode != dir); 1401 BUG_ON(victim->d_parent->d_inode != dir);
1479 audit_inode_child(victim->d_name.name, victim, dir); 1402 audit_inode_child(victim->d_name.name, victim, dir);
1480 1403
1481 error = permission(dir,MAY_WRITE | MAY_EXEC, NULL); 1404 error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
1482 if (error) 1405 if (error)
1483 return error; 1406 return error;
1484 if (IS_APPEND(dir)) 1407 if (IS_APPEND(dir))
@@ -1515,7 +1438,7 @@ static inline int may_create(struct inode *dir, struct dentry *child,
1515 return -EEXIST; 1438 return -EEXIST;
1516 if (IS_DEADDIR(dir)) 1439 if (IS_DEADDIR(dir))
1517 return -ENOENT; 1440 return -ENOENT;
1518 return permission(dir,MAY_WRITE | MAY_EXEC, nd); 1441 return inode_permission(dir, MAY_WRITE | MAY_EXEC);
1519} 1442}
1520 1443
1521/* 1444/*
@@ -1755,7 +1678,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
1755 int will_write; 1678 int will_write;
1756 int flag = open_to_namei_flags(open_flag); 1679 int flag = open_to_namei_flags(open_flag);
1757 1680
1758 acc_mode = ACC_MODE(flag); 1681 acc_mode = MAY_OPEN | ACC_MODE(flag);
1759 1682
1760 /* O_TRUNC implies we need access checks for write permissions */ 1683 /* O_TRUNC implies we need access checks for write permissions */
1761 if (flag & O_TRUNC) 1684 if (flag & O_TRUNC)
@@ -2071,20 +1994,18 @@ static int may_mknod(mode_t mode)
2071asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode, 1994asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode,
2072 unsigned dev) 1995 unsigned dev)
2073{ 1996{
2074 int error = 0; 1997 int error;
2075 char * tmp; 1998 char *tmp;
2076 struct dentry * dentry; 1999 struct dentry *dentry;
2077 struct nameidata nd; 2000 struct nameidata nd;
2078 2001
2079 if (S_ISDIR(mode)) 2002 if (S_ISDIR(mode))
2080 return -EPERM; 2003 return -EPERM;
2081 tmp = getname(filename);
2082 if (IS_ERR(tmp))
2083 return PTR_ERR(tmp);
2084 2004
2085 error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd); 2005 error = user_path_parent(dfd, filename, &nd, &tmp);
2086 if (error) 2006 if (error)
2087 goto out; 2007 return error;
2008
2088 dentry = lookup_create(&nd, 0); 2009 dentry = lookup_create(&nd, 0);
2089 if (IS_ERR(dentry)) { 2010 if (IS_ERR(dentry)) {
2090 error = PTR_ERR(dentry); 2011 error = PTR_ERR(dentry);
@@ -2116,7 +2037,6 @@ out_dput:
2116out_unlock: 2037out_unlock:
2117 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2038 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2118 path_put(&nd.path); 2039 path_put(&nd.path);
2119out:
2120 putname(tmp); 2040 putname(tmp);
2121 2041
2122 return error; 2042 return error;
@@ -2156,14 +2076,10 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode)
2156 struct dentry *dentry; 2076 struct dentry *dentry;
2157 struct nameidata nd; 2077 struct nameidata nd;
2158 2078
2159 tmp = getname(pathname); 2079 error = user_path_parent(dfd, pathname, &nd, &tmp);
2160 error = PTR_ERR(tmp); 2080 if (error)
2161 if (IS_ERR(tmp))
2162 goto out_err; 2081 goto out_err;
2163 2082
2164 error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
2165 if (error)
2166 goto out;
2167 dentry = lookup_create(&nd, 1); 2083 dentry = lookup_create(&nd, 1);
2168 error = PTR_ERR(dentry); 2084 error = PTR_ERR(dentry);
2169 if (IS_ERR(dentry)) 2085 if (IS_ERR(dentry))
@@ -2181,7 +2097,6 @@ out_dput:
2181out_unlock: 2097out_unlock:
2182 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2098 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2183 path_put(&nd.path); 2099 path_put(&nd.path);
2184out:
2185 putname(tmp); 2100 putname(tmp);
2186out_err: 2101out_err:
2187 return error; 2102 return error;
@@ -2259,13 +2174,9 @@ static long do_rmdir(int dfd, const char __user *pathname)
2259 struct dentry *dentry; 2174 struct dentry *dentry;
2260 struct nameidata nd; 2175 struct nameidata nd;
2261 2176
2262 name = getname(pathname); 2177 error = user_path_parent(dfd, pathname, &nd, &name);
2263 if(IS_ERR(name))
2264 return PTR_ERR(name);
2265
2266 error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);
2267 if (error) 2178 if (error)
2268 goto exit; 2179 return error;
2269 2180
2270 switch(nd.last_type) { 2181 switch(nd.last_type) {
2271 case LAST_DOTDOT: 2182 case LAST_DOTDOT:
@@ -2294,7 +2205,6 @@ exit2:
2294 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2205 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2295exit1: 2206exit1:
2296 path_put(&nd.path); 2207 path_put(&nd.path);
2297exit:
2298 putname(name); 2208 putname(name);
2299 return error; 2209 return error;
2300} 2210}
@@ -2343,19 +2253,16 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
2343 */ 2253 */
2344static long do_unlinkat(int dfd, const char __user *pathname) 2254static long do_unlinkat(int dfd, const char __user *pathname)
2345{ 2255{
2346 int error = 0; 2256 int error;
2347 char * name; 2257 char *name;
2348 struct dentry *dentry; 2258 struct dentry *dentry;
2349 struct nameidata nd; 2259 struct nameidata nd;
2350 struct inode *inode = NULL; 2260 struct inode *inode = NULL;
2351 2261
2352 name = getname(pathname); 2262 error = user_path_parent(dfd, pathname, &nd, &name);
2353 if(IS_ERR(name))
2354 return PTR_ERR(name);
2355
2356 error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);
2357 if (error) 2263 if (error)
2358 goto exit; 2264 return error;
2265
2359 error = -EISDIR; 2266 error = -EISDIR;
2360 if (nd.last_type != LAST_NORM) 2267 if (nd.last_type != LAST_NORM)
2361 goto exit1; 2268 goto exit1;
@@ -2382,7 +2289,6 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2382 iput(inode); /* truncate the inode here */ 2289 iput(inode); /* truncate the inode here */
2383exit1: 2290exit1:
2384 path_put(&nd.path); 2291 path_put(&nd.path);
2385exit:
2386 putname(name); 2292 putname(name);
2387 return error; 2293 return error;
2388 2294
@@ -2408,7 +2314,7 @@ asmlinkage long sys_unlink(const char __user *pathname)
2408 return do_unlinkat(AT_FDCWD, pathname); 2314 return do_unlinkat(AT_FDCWD, pathname);
2409} 2315}
2410 2316
2411int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode) 2317int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
2412{ 2318{
2413 int error = may_create(dir, dentry, NULL); 2319 int error = may_create(dir, dentry, NULL);
2414 2320
@@ -2432,23 +2338,20 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, i
2432asmlinkage long sys_symlinkat(const char __user *oldname, 2338asmlinkage long sys_symlinkat(const char __user *oldname,
2433 int newdfd, const char __user *newname) 2339 int newdfd, const char __user *newname)
2434{ 2340{
2435 int error = 0; 2341 int error;
2436 char * from; 2342 char *from;
2437 char * to; 2343 char *to;
2438 struct dentry *dentry; 2344 struct dentry *dentry;
2439 struct nameidata nd; 2345 struct nameidata nd;
2440 2346
2441 from = getname(oldname); 2347 from = getname(oldname);
2442 if(IS_ERR(from)) 2348 if (IS_ERR(from))
2443 return PTR_ERR(from); 2349 return PTR_ERR(from);
2444 to = getname(newname);
2445 error = PTR_ERR(to);
2446 if (IS_ERR(to))
2447 goto out_putname;
2448 2350
2449 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); 2351 error = user_path_parent(newdfd, newname, &nd, &to);
2450 if (error) 2352 if (error)
2451 goto out; 2353 goto out_putname;
2354
2452 dentry = lookup_create(&nd, 0); 2355 dentry = lookup_create(&nd, 0);
2453 error = PTR_ERR(dentry); 2356 error = PTR_ERR(dentry);
2454 if (IS_ERR(dentry)) 2357 if (IS_ERR(dentry))
@@ -2457,14 +2360,13 @@ asmlinkage long sys_symlinkat(const char __user *oldname,
2457 error = mnt_want_write(nd.path.mnt); 2360 error = mnt_want_write(nd.path.mnt);
2458 if (error) 2361 if (error)
2459 goto out_dput; 2362 goto out_dput;
2460 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from, S_IALLUGO); 2363 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from);
2461 mnt_drop_write(nd.path.mnt); 2364 mnt_drop_write(nd.path.mnt);
2462out_dput: 2365out_dput:
2463 dput(dentry); 2366 dput(dentry);
2464out_unlock: 2367out_unlock:
2465 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2368 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2466 path_put(&nd.path); 2369 path_put(&nd.path);
2467out:
2468 putname(to); 2370 putname(to);
2469out_putname: 2371out_putname:
2470 putname(from); 2372 putname(from);
@@ -2498,19 +2400,19 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
2498 return -EPERM; 2400 return -EPERM;
2499 if (!dir->i_op || !dir->i_op->link) 2401 if (!dir->i_op || !dir->i_op->link)
2500 return -EPERM; 2402 return -EPERM;
2501 if (S_ISDIR(old_dentry->d_inode->i_mode)) 2403 if (S_ISDIR(inode->i_mode))
2502 return -EPERM; 2404 return -EPERM;
2503 2405
2504 error = security_inode_link(old_dentry, dir, new_dentry); 2406 error = security_inode_link(old_dentry, dir, new_dentry);
2505 if (error) 2407 if (error)
2506 return error; 2408 return error;
2507 2409
2508 mutex_lock(&old_dentry->d_inode->i_mutex); 2410 mutex_lock(&inode->i_mutex);
2509 DQUOT_INIT(dir); 2411 DQUOT_INIT(dir);
2510 error = dir->i_op->link(old_dentry, dir, new_dentry); 2412 error = dir->i_op->link(old_dentry, dir, new_dentry);
2511 mutex_unlock(&old_dentry->d_inode->i_mutex); 2413 mutex_unlock(&inode->i_mutex);
2512 if (!error) 2414 if (!error)
2513 fsnotify_link(dir, old_dentry->d_inode, new_dentry); 2415 fsnotify_link(dir, inode, new_dentry);
2514 return error; 2416 return error;
2515} 2417}
2516 2418
@@ -2528,27 +2430,25 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
2528 int flags) 2430 int flags)
2529{ 2431{
2530 struct dentry *new_dentry; 2432 struct dentry *new_dentry;
2531 struct nameidata nd, old_nd; 2433 struct nameidata nd;
2434 struct path old_path;
2532 int error; 2435 int error;
2533 char * to; 2436 char *to;
2534 2437
2535 if ((flags & ~AT_SYMLINK_FOLLOW) != 0) 2438 if ((flags & ~AT_SYMLINK_FOLLOW) != 0)
2536 return -EINVAL; 2439 return -EINVAL;
2537 2440
2538 to = getname(newname); 2441 error = user_path_at(olddfd, oldname,
2539 if (IS_ERR(to)) 2442 flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0,
2540 return PTR_ERR(to); 2443 &old_path);
2541
2542 error = __user_walk_fd(olddfd, oldname,
2543 flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0,
2544 &old_nd);
2545 if (error) 2444 if (error)
2546 goto exit; 2445 return error;
2547 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); 2446
2447 error = user_path_parent(newdfd, newname, &nd, &to);
2548 if (error) 2448 if (error)
2549 goto out; 2449 goto out;
2550 error = -EXDEV; 2450 error = -EXDEV;
2551 if (old_nd.path.mnt != nd.path.mnt) 2451 if (old_path.mnt != nd.path.mnt)
2552 goto out_release; 2452 goto out_release;
2553 new_dentry = lookup_create(&nd, 0); 2453 new_dentry = lookup_create(&nd, 0);
2554 error = PTR_ERR(new_dentry); 2454 error = PTR_ERR(new_dentry);
@@ -2557,7 +2457,7 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
2557 error = mnt_want_write(nd.path.mnt); 2457 error = mnt_want_write(nd.path.mnt);
2558 if (error) 2458 if (error)
2559 goto out_dput; 2459 goto out_dput;
2560 error = vfs_link(old_nd.path.dentry, nd.path.dentry->d_inode, new_dentry); 2460 error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry);
2561 mnt_drop_write(nd.path.mnt); 2461 mnt_drop_write(nd.path.mnt);
2562out_dput: 2462out_dput:
2563 dput(new_dentry); 2463 dput(new_dentry);
@@ -2565,10 +2465,9 @@ out_unlock:
2565 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2465 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2566out_release: 2466out_release:
2567 path_put(&nd.path); 2467 path_put(&nd.path);
2568out:
2569 path_put(&old_nd.path);
2570exit:
2571 putname(to); 2468 putname(to);
2469out:
2470 path_put(&old_path);
2572 2471
2573 return error; 2472 return error;
2574} 2473}
@@ -2621,7 +2520,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
2621 * we'll need to flip '..'. 2520 * we'll need to flip '..'.
2622 */ 2521 */
2623 if (new_dir != old_dir) { 2522 if (new_dir != old_dir) {
2624 error = permission(old_dentry->d_inode, MAY_WRITE, NULL); 2523 error = inode_permission(old_dentry->d_inode, MAY_WRITE);
2625 if (error) 2524 if (error)
2626 return error; 2525 return error;
2627 } 2526 }
@@ -2724,20 +2623,22 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2724 return error; 2623 return error;
2725} 2624}
2726 2625
2727static int do_rename(int olddfd, const char *oldname, 2626asmlinkage long sys_renameat(int olddfd, const char __user *oldname,
2728 int newdfd, const char *newname) 2627 int newdfd, const char __user *newname)
2729{ 2628{
2730 int error = 0; 2629 struct dentry *old_dir, *new_dir;
2731 struct dentry * old_dir, * new_dir; 2630 struct dentry *old_dentry, *new_dentry;
2732 struct dentry * old_dentry, *new_dentry; 2631 struct dentry *trap;
2733 struct dentry * trap;
2734 struct nameidata oldnd, newnd; 2632 struct nameidata oldnd, newnd;
2633 char *from;
2634 char *to;
2635 int error;
2735 2636
2736 error = do_path_lookup(olddfd, oldname, LOOKUP_PARENT, &oldnd); 2637 error = user_path_parent(olddfd, oldname, &oldnd, &from);
2737 if (error) 2638 if (error)
2738 goto exit; 2639 goto exit;
2739 2640
2740 error = do_path_lookup(newdfd, newname, LOOKUP_PARENT, &newnd); 2641 error = user_path_parent(newdfd, newname, &newnd, &to);
2741 if (error) 2642 if (error)
2742 goto exit1; 2643 goto exit1;
2743 2644
@@ -2799,29 +2700,11 @@ exit3:
2799 unlock_rename(new_dir, old_dir); 2700 unlock_rename(new_dir, old_dir);
2800exit2: 2701exit2:
2801 path_put(&newnd.path); 2702 path_put(&newnd.path);
2703 putname(to);
2802exit1: 2704exit1:
2803 path_put(&oldnd.path); 2705 path_put(&oldnd.path);
2804exit:
2805 return error;
2806}
2807
2808asmlinkage long sys_renameat(int olddfd, const char __user *oldname,
2809 int newdfd, const char __user *newname)
2810{
2811 int error;
2812 char * from;
2813 char * to;
2814
2815 from = getname(oldname);
2816 if(IS_ERR(from))
2817 return PTR_ERR(from);
2818 to = getname(newname);
2819 error = PTR_ERR(to);
2820 if (!IS_ERR(to)) {
2821 error = do_rename(olddfd, from, newdfd, to);
2822 putname(to);
2823 }
2824 putname(from); 2706 putname(from);
2707exit:
2825 return error; 2708 return error;
2826} 2709}
2827 2710
@@ -2959,8 +2842,7 @@ const struct inode_operations page_symlink_inode_operations = {
2959 .put_link = page_put_link, 2842 .put_link = page_put_link,
2960}; 2843};
2961 2844
2962EXPORT_SYMBOL(__user_walk); 2845EXPORT_SYMBOL(user_path_at);
2963EXPORT_SYMBOL(__user_walk_fd);
2964EXPORT_SYMBOL(follow_down); 2846EXPORT_SYMBOL(follow_down);
2965EXPORT_SYMBOL(follow_up); 2847EXPORT_SYMBOL(follow_up);
2966EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ 2848EXPORT_SYMBOL(get_write_access); /* binfmt_aout */
@@ -2975,7 +2857,7 @@ EXPORT_SYMBOL(page_symlink);
2975EXPORT_SYMBOL(page_symlink_inode_operations); 2857EXPORT_SYMBOL(page_symlink_inode_operations);
2976EXPORT_SYMBOL(path_lookup); 2858EXPORT_SYMBOL(path_lookup);
2977EXPORT_SYMBOL(vfs_path_lookup); 2859EXPORT_SYMBOL(vfs_path_lookup);
2978EXPORT_SYMBOL(permission); 2860EXPORT_SYMBOL(inode_permission);
2979EXPORT_SYMBOL(vfs_permission); 2861EXPORT_SYMBOL(vfs_permission);
2980EXPORT_SYMBOL(file_permission); 2862EXPORT_SYMBOL(file_permission);
2981EXPORT_SYMBOL(unlock_rename); 2863EXPORT_SYMBOL(unlock_rename);
diff --git a/fs/namespace.c b/fs/namespace.c
index 4f6f7635b59c..411728c0c8bb 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -112,9 +112,13 @@ struct vfsmount *alloc_vfsmnt(const char *name)
112 int err; 112 int err;
113 113
114 err = mnt_alloc_id(mnt); 114 err = mnt_alloc_id(mnt);
115 if (err) { 115 if (err)
116 kmem_cache_free(mnt_cache, mnt); 116 goto out_free_cache;
117 return NULL; 117
118 if (name) {
119 mnt->mnt_devname = kstrdup(name, GFP_KERNEL);
120 if (!mnt->mnt_devname)
121 goto out_free_id;
118 } 122 }
119 123
120 atomic_set(&mnt->mnt_count, 1); 124 atomic_set(&mnt->mnt_count, 1);
@@ -127,16 +131,14 @@ struct vfsmount *alloc_vfsmnt(const char *name)
127 INIT_LIST_HEAD(&mnt->mnt_slave_list); 131 INIT_LIST_HEAD(&mnt->mnt_slave_list);
128 INIT_LIST_HEAD(&mnt->mnt_slave); 132 INIT_LIST_HEAD(&mnt->mnt_slave);
129 atomic_set(&mnt->__mnt_writers, 0); 133 atomic_set(&mnt->__mnt_writers, 0);
130 if (name) {
131 int size = strlen(name) + 1;
132 char *newname = kmalloc(size, GFP_KERNEL);
133 if (newname) {
134 memcpy(newname, name, size);
135 mnt->mnt_devname = newname;
136 }
137 }
138 } 134 }
139 return mnt; 135 return mnt;
136
137out_free_id:
138 mnt_free_id(mnt);
139out_free_cache:
140 kmem_cache_free(mnt_cache, mnt);
141 return NULL;
140} 142}
141 143
142/* 144/*
@@ -309,10 +311,9 @@ static void handle_write_count_underflow(struct vfsmount *mnt)
309 */ 311 */
310 if ((atomic_read(&mnt->__mnt_writers) < 0) && 312 if ((atomic_read(&mnt->__mnt_writers) < 0) &&
311 !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) { 313 !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) {
312 printk(KERN_DEBUG "leak detected on mount(%p) writers " 314 WARN(1, KERN_DEBUG "leak detected on mount(%p) writers "
313 "count: %d\n", 315 "count: %d\n",
314 mnt, atomic_read(&mnt->__mnt_writers)); 316 mnt, atomic_read(&mnt->__mnt_writers));
315 WARN_ON(1);
316 /* use the flag to keep the dmesg spam down */ 317 /* use the flag to keep the dmesg spam down */
317 mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT; 318 mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT;
318 } 319 }
@@ -1129,27 +1130,27 @@ static int do_umount(struct vfsmount *mnt, int flags)
1129 1130
1130asmlinkage long sys_umount(char __user * name, int flags) 1131asmlinkage long sys_umount(char __user * name, int flags)
1131{ 1132{
1132 struct nameidata nd; 1133 struct path path;
1133 int retval; 1134 int retval;
1134 1135
1135 retval = __user_walk(name, LOOKUP_FOLLOW, &nd); 1136 retval = user_path(name, &path);
1136 if (retval) 1137 if (retval)
1137 goto out; 1138 goto out;
1138 retval = -EINVAL; 1139 retval = -EINVAL;
1139 if (nd.path.dentry != nd.path.mnt->mnt_root) 1140 if (path.dentry != path.mnt->mnt_root)
1140 goto dput_and_out; 1141 goto dput_and_out;
1141 if (!check_mnt(nd.path.mnt)) 1142 if (!check_mnt(path.mnt))
1142 goto dput_and_out; 1143 goto dput_and_out;
1143 1144
1144 retval = -EPERM; 1145 retval = -EPERM;
1145 if (!capable(CAP_SYS_ADMIN)) 1146 if (!capable(CAP_SYS_ADMIN))
1146 goto dput_and_out; 1147 goto dput_and_out;
1147 1148
1148 retval = do_umount(nd.path.mnt, flags); 1149 retval = do_umount(path.mnt, flags);
1149dput_and_out: 1150dput_and_out:
1150 /* we mustn't call path_put() as that would clear mnt_expiry_mark */ 1151 /* we mustn't call path_put() as that would clear mnt_expiry_mark */
1151 dput(nd.path.dentry); 1152 dput(path.dentry);
1152 mntput_no_expire(nd.path.mnt); 1153 mntput_no_expire(path.mnt);
1153out: 1154out:
1154 return retval; 1155 return retval;
1155} 1156}
@@ -1973,7 +1974,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
1973 struct fs_struct *fs) 1974 struct fs_struct *fs)
1974{ 1975{
1975 struct mnt_namespace *new_ns; 1976 struct mnt_namespace *new_ns;
1976 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; 1977 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL;
1977 struct vfsmount *p, *q; 1978 struct vfsmount *p, *q;
1978 1979
1979 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); 1980 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
@@ -2016,10 +2017,6 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2016 pwdmnt = p; 2017 pwdmnt = p;
2017 fs->pwd.mnt = mntget(q); 2018 fs->pwd.mnt = mntget(q);
2018 } 2019 }
2019 if (p == fs->altroot.mnt) {
2020 altrootmnt = p;
2021 fs->altroot.mnt = mntget(q);
2022 }
2023 } 2020 }
2024 p = next_mnt(p, mnt_ns->root); 2021 p = next_mnt(p, mnt_ns->root);
2025 q = next_mnt(q, new_ns->root); 2022 q = next_mnt(q, new_ns->root);
@@ -2030,8 +2027,6 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2030 mntput(rootmnt); 2027 mntput(rootmnt);
2031 if (pwdmnt) 2028 if (pwdmnt)
2032 mntput(pwdmnt); 2029 mntput(pwdmnt);
2033 if (altrootmnt)
2034 mntput(altrootmnt);
2035 2030
2036 return new_ns; 2031 return new_ns;
2037} 2032}
@@ -2184,28 +2179,26 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
2184 const char __user * put_old) 2179 const char __user * put_old)
2185{ 2180{
2186 struct vfsmount *tmp; 2181 struct vfsmount *tmp;
2187 struct nameidata new_nd, old_nd; 2182 struct path new, old, parent_path, root_parent, root;
2188 struct path parent_path, root_parent, root;
2189 int error; 2183 int error;
2190 2184
2191 if (!capable(CAP_SYS_ADMIN)) 2185 if (!capable(CAP_SYS_ADMIN))
2192 return -EPERM; 2186 return -EPERM;
2193 2187
2194 error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, 2188 error = user_path_dir(new_root, &new);
2195 &new_nd);
2196 if (error) 2189 if (error)
2197 goto out0; 2190 goto out0;
2198 error = -EINVAL; 2191 error = -EINVAL;
2199 if (!check_mnt(new_nd.path.mnt)) 2192 if (!check_mnt(new.mnt))
2200 goto out1; 2193 goto out1;
2201 2194
2202 error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd); 2195 error = user_path_dir(put_old, &old);
2203 if (error) 2196 if (error)
2204 goto out1; 2197 goto out1;
2205 2198
2206 error = security_sb_pivotroot(&old_nd.path, &new_nd.path); 2199 error = security_sb_pivotroot(&old, &new);
2207 if (error) { 2200 if (error) {
2208 path_put(&old_nd.path); 2201 path_put(&old);
2209 goto out1; 2202 goto out1;
2210 } 2203 }
2211 2204
@@ -2214,69 +2207,69 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
2214 path_get(&current->fs->root); 2207 path_get(&current->fs->root);
2215 read_unlock(&current->fs->lock); 2208 read_unlock(&current->fs->lock);
2216 down_write(&namespace_sem); 2209 down_write(&namespace_sem);
2217 mutex_lock(&old_nd.path.dentry->d_inode->i_mutex); 2210 mutex_lock(&old.dentry->d_inode->i_mutex);
2218 error = -EINVAL; 2211 error = -EINVAL;
2219 if (IS_MNT_SHARED(old_nd.path.mnt) || 2212 if (IS_MNT_SHARED(old.mnt) ||
2220 IS_MNT_SHARED(new_nd.path.mnt->mnt_parent) || 2213 IS_MNT_SHARED(new.mnt->mnt_parent) ||
2221 IS_MNT_SHARED(root.mnt->mnt_parent)) 2214 IS_MNT_SHARED(root.mnt->mnt_parent))
2222 goto out2; 2215 goto out2;
2223 if (!check_mnt(root.mnt)) 2216 if (!check_mnt(root.mnt))
2224 goto out2; 2217 goto out2;
2225 error = -ENOENT; 2218 error = -ENOENT;
2226 if (IS_DEADDIR(new_nd.path.dentry->d_inode)) 2219 if (IS_DEADDIR(new.dentry->d_inode))
2227 goto out2; 2220 goto out2;
2228 if (d_unhashed(new_nd.path.dentry) && !IS_ROOT(new_nd.path.dentry)) 2221 if (d_unhashed(new.dentry) && !IS_ROOT(new.dentry))
2229 goto out2; 2222 goto out2;
2230 if (d_unhashed(old_nd.path.dentry) && !IS_ROOT(old_nd.path.dentry)) 2223 if (d_unhashed(old.dentry) && !IS_ROOT(old.dentry))
2231 goto out2; 2224 goto out2;
2232 error = -EBUSY; 2225 error = -EBUSY;
2233 if (new_nd.path.mnt == root.mnt || 2226 if (new.mnt == root.mnt ||
2234 old_nd.path.mnt == root.mnt) 2227 old.mnt == root.mnt)
2235 goto out2; /* loop, on the same file system */ 2228 goto out2; /* loop, on the same file system */
2236 error = -EINVAL; 2229 error = -EINVAL;
2237 if (root.mnt->mnt_root != root.dentry) 2230 if (root.mnt->mnt_root != root.dentry)
2238 goto out2; /* not a mountpoint */ 2231 goto out2; /* not a mountpoint */
2239 if (root.mnt->mnt_parent == root.mnt) 2232 if (root.mnt->mnt_parent == root.mnt)
2240 goto out2; /* not attached */ 2233 goto out2; /* not attached */
2241 if (new_nd.path.mnt->mnt_root != new_nd.path.dentry) 2234 if (new.mnt->mnt_root != new.dentry)
2242 goto out2; /* not a mountpoint */ 2235 goto out2; /* not a mountpoint */
2243 if (new_nd.path.mnt->mnt_parent == new_nd.path.mnt) 2236 if (new.mnt->mnt_parent == new.mnt)
2244 goto out2; /* not attached */ 2237 goto out2; /* not attached */
2245 /* make sure we can reach put_old from new_root */ 2238 /* make sure we can reach put_old from new_root */
2246 tmp = old_nd.path.mnt; 2239 tmp = old.mnt;
2247 spin_lock(&vfsmount_lock); 2240 spin_lock(&vfsmount_lock);
2248 if (tmp != new_nd.path.mnt) { 2241 if (tmp != new.mnt) {
2249 for (;;) { 2242 for (;;) {
2250 if (tmp->mnt_parent == tmp) 2243 if (tmp->mnt_parent == tmp)
2251 goto out3; /* already mounted on put_old */ 2244 goto out3; /* already mounted on put_old */
2252 if (tmp->mnt_parent == new_nd.path.mnt) 2245 if (tmp->mnt_parent == new.mnt)
2253 break; 2246 break;
2254 tmp = tmp->mnt_parent; 2247 tmp = tmp->mnt_parent;
2255 } 2248 }
2256 if (!is_subdir(tmp->mnt_mountpoint, new_nd.path.dentry)) 2249 if (!is_subdir(tmp->mnt_mountpoint, new.dentry))
2257 goto out3; 2250 goto out3;
2258 } else if (!is_subdir(old_nd.path.dentry, new_nd.path.dentry)) 2251 } else if (!is_subdir(old.dentry, new.dentry))
2259 goto out3; 2252 goto out3;
2260 detach_mnt(new_nd.path.mnt, &parent_path); 2253 detach_mnt(new.mnt, &parent_path);
2261 detach_mnt(root.mnt, &root_parent); 2254 detach_mnt(root.mnt, &root_parent);
2262 /* mount old root on put_old */ 2255 /* mount old root on put_old */
2263 attach_mnt(root.mnt, &old_nd.path); 2256 attach_mnt(root.mnt, &old);
2264 /* mount new_root on / */ 2257 /* mount new_root on / */
2265 attach_mnt(new_nd.path.mnt, &root_parent); 2258 attach_mnt(new.mnt, &root_parent);
2266 touch_mnt_namespace(current->nsproxy->mnt_ns); 2259 touch_mnt_namespace(current->nsproxy->mnt_ns);
2267 spin_unlock(&vfsmount_lock); 2260 spin_unlock(&vfsmount_lock);
2268 chroot_fs_refs(&root, &new_nd.path); 2261 chroot_fs_refs(&root, &new);
2269 security_sb_post_pivotroot(&root, &new_nd.path); 2262 security_sb_post_pivotroot(&root, &new);
2270 error = 0; 2263 error = 0;
2271 path_put(&root_parent); 2264 path_put(&root_parent);
2272 path_put(&parent_path); 2265 path_put(&parent_path);
2273out2: 2266out2:
2274 mutex_unlock(&old_nd.path.dentry->d_inode->i_mutex); 2267 mutex_unlock(&old.dentry->d_inode->i_mutex);
2275 up_write(&namespace_sem); 2268 up_write(&namespace_sem);
2276 path_put(&root); 2269 path_put(&root);
2277 path_put(&old_nd.path); 2270 path_put(&old);
2278out1: 2271out1:
2279 path_put(&new_nd.path); 2272 path_put(&new);
2280out0: 2273out0:
2281 return error; 2274 return error;
2282out3: 2275out3:
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 011ef0b6d2d4..07e9715b8658 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -266,7 +266,7 @@ leave_me:;
266 266
267 267
268static int 268static int
269__ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd) 269__ncp_lookup_validate(struct dentry *dentry)
270{ 270{
271 struct ncp_server *server; 271 struct ncp_server *server;
272 struct dentry *parent; 272 struct dentry *parent;
@@ -340,7 +340,7 @@ ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd)
340{ 340{
341 int res; 341 int res;
342 lock_kernel(); 342 lock_kernel();
343 res = __ncp_lookup_validate(dentry, nd); 343 res = __ncp_lookup_validate(dentry);
344 unlock_kernel(); 344 unlock_kernel();
345 return res; 345 return res;
346} 346}
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 2e5ab1204dec..d642f0e5b365 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -64,7 +64,7 @@ static void ncp_destroy_inode(struct inode *inode)
64 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 64 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
65} 65}
66 66
67static void init_once(struct kmem_cache *cachep, void *foo) 67static void init_once(void *foo)
68{ 68{
69 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; 69 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
70 70
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 28a238dab23a..74f92b717f78 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1884,7 +1884,7 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)
1884 return status; 1884 return status;
1885 nfs_access_add_cache(inode, &cache); 1885 nfs_access_add_cache(inode, &cache);
1886out: 1886out:
1887 if ((cache.mask & mask) == mask) 1887 if ((mask & ~cache.mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0)
1888 return 0; 1888 return 0;
1889 return -EACCES; 1889 return -EACCES;
1890} 1890}
@@ -1907,17 +1907,17 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
1907 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); 1907 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
1908} 1908}
1909 1909
1910int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) 1910int nfs_permission(struct inode *inode, int mask)
1911{ 1911{
1912 struct rpc_cred *cred; 1912 struct rpc_cred *cred;
1913 int res = 0; 1913 int res = 0;
1914 1914
1915 nfs_inc_stats(inode, NFSIOS_VFSACCESS); 1915 nfs_inc_stats(inode, NFSIOS_VFSACCESS);
1916 1916
1917 if (mask == 0) 1917 if ((mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0)
1918 goto out; 1918 goto out;
1919 /* Is this sys_access() ? */ 1919 /* Is this sys_access() ? */
1920 if (nd != NULL && (nd->flags & LOOKUP_ACCESS)) 1920 if (mask & MAY_ACCESS)
1921 goto force_lookup; 1921 goto force_lookup;
1922 1922
1923 switch (inode->i_mode & S_IFMT) { 1923 switch (inode->i_mode & S_IFMT) {
@@ -1926,8 +1926,7 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
1926 case S_IFREG: 1926 case S_IFREG:
1927 /* NFSv4 has atomic_open... */ 1927 /* NFSv4 has atomic_open... */
1928 if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN) 1928 if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN)
1929 && nd != NULL 1929 && (mask & MAY_OPEN))
1930 && (nd->flags & LOOKUP_OPEN))
1931 goto out; 1930 goto out;
1932 break; 1931 break;
1933 case S_IFDIR: 1932 case S_IFDIR:
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index df23f987da6b..52daefa2f521 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1242,7 +1242,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
1242#endif 1242#endif
1243} 1243}
1244 1244
1245static void init_once(struct kmem_cache * cachep, void *foo) 1245static void init_once(void *foo)
1246{ 1246{
1247 struct nfs_inode *nfsi = (struct nfs_inode *) foo; 1247 struct nfs_inode *nfsi = (struct nfs_inode *) foo;
1248 1248
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1b94e3650f5c..9abcd2b329f7 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1718,9 +1718,9 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1718 * ones were explicitly specified. Fall back to legacy behavior and 1718 * ones were explicitly specified. Fall back to legacy behavior and
1719 * just return success. 1719 * just return success.
1720 */ 1720 */
1721 if ((nfsvers == 4 && options4->version == 1) || 1721 if ((nfsvers == 4 && (!options4 || options4->version == 1)) ||
1722 (nfsvers <= 3 && options->version >= 1 && 1722 (nfsvers <= 3 && (!options || (options->version >= 1 &&
1723 options->version <= 6)) 1723 options->version <= 6))))
1724 return 0; 1724 return 0;
1725 1725
1726 data = kzalloc(sizeof(*data), GFP_KERNEL); 1726 data = kzalloc(sizeof(*data), GFP_KERNEL);
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 3adf8b266461..f089e5839d7d 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -95,10 +95,11 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata)
95static void nfs_async_unlink_release(void *calldata) 95static void nfs_async_unlink_release(void *calldata)
96{ 96{
97 struct nfs_unlinkdata *data = calldata; 97 struct nfs_unlinkdata *data = calldata;
98 struct super_block *sb = data->dir->i_sb;
98 99
99 nfs_dec_sillycount(data->dir); 100 nfs_dec_sillycount(data->dir);
100 nfs_sb_deactive(NFS_SERVER(data->dir));
101 nfs_free_unlinkdata(data); 101 nfs_free_unlinkdata(data);
102 nfs_sb_deactive(NFS_SB(sb));
102} 103}
103 104
104static const struct rpc_call_ops nfs_unlink_ops = { 105static const struct rpc_call_ops nfs_unlink_ops = {
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 1955a2702e60..c53e65f8f3a2 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -12,6 +12,7 @@
12#include <linux/time.h> 12#include <linux/time.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/namei.h>
15#include <linux/fcntl.h> 16#include <linux/fcntl.h>
16#include <linux/net.h> 17#include <linux/net.h>
17#include <linux/in.h> 18#include <linux/in.h>
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index f45451eb1e38..ea37c96f0445 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -51,7 +51,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
51 /* make sure parents give x permission to user */ 51 /* make sure parents give x permission to user */
52 int err; 52 int err;
53 parent = dget_parent(tdentry); 53 parent = dget_parent(tdentry);
54 err = permission(parent->d_inode, MAY_EXEC, NULL); 54 err = inode_permission(parent->d_inode, MAY_EXEC);
55 if (err < 0) { 55 if (err < 0) {
56 dput(parent); 56 dput(parent);
57 break; 57 break;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 0f4481e0502d..18060bed5267 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1516,7 +1516,6 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1516 struct dentry *dentry, *dnew; 1516 struct dentry *dentry, *dnew;
1517 __be32 err, cerr; 1517 __be32 err, cerr;
1518 int host_err; 1518 int host_err;
1519 umode_t mode;
1520 1519
1521 err = nfserr_noent; 1520 err = nfserr_noent;
1522 if (!flen || !plen) 1521 if (!flen || !plen)
@@ -1535,11 +1534,6 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1535 if (IS_ERR(dnew)) 1534 if (IS_ERR(dnew))
1536 goto out_nfserr; 1535 goto out_nfserr;
1537 1536
1538 mode = S_IALLUGO;
1539 /* Only the MODE ATTRibute is even vaguely meaningful */
1540 if (iap && (iap->ia_valid & ATTR_MODE))
1541 mode = iap->ia_mode & S_IALLUGO;
1542
1543 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); 1537 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt);
1544 if (host_err) 1538 if (host_err)
1545 goto out_nfserr; 1539 goto out_nfserr;
@@ -1551,11 +1545,11 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1551 else { 1545 else {
1552 strncpy(path_alloced, path, plen); 1546 strncpy(path_alloced, path, plen);
1553 path_alloced[plen] = 0; 1547 path_alloced[plen] = 0;
1554 host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode); 1548 host_err = vfs_symlink(dentry->d_inode, dnew, path_alloced);
1555 kfree(path_alloced); 1549 kfree(path_alloced);
1556 } 1550 }
1557 } else 1551 } else
1558 host_err = vfs_symlink(dentry->d_inode, dnew, path, mode); 1552 host_err = vfs_symlink(dentry->d_inode, dnew, path);
1559 1553
1560 if (!host_err) { 1554 if (!host_err) {
1561 if (EX_ISSYNC(fhp->fh_export)) 1555 if (EX_ISSYNC(fhp->fh_export))
@@ -1959,12 +1953,12 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp,
1959 return 0; 1953 return 0;
1960 1954
1961 /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ 1955 /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */
1962 err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL); 1956 err = inode_permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC));
1963 1957
1964 /* Allow read access to binaries even when mode 111 */ 1958 /* Allow read access to binaries even when mode 111 */
1965 if (err == -EACCES && S_ISREG(inode->i_mode) && 1959 if (err == -EACCES && S_ISREG(inode->i_mode) &&
1966 acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE)) 1960 acc == (NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE))
1967 err = permission(inode, MAY_EXEC, NULL); 1961 err = inode_permission(inode, MAY_EXEC);
1968 1962
1969 return err? nfserrno(err) : 0; 1963 return err? nfserrno(err) : 0;
1970} 1964}
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 3c5550cd11d6..d020866d4232 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
2118 goto out; 2118 goto out;
2119 if (!count) 2119 if (!count)
2120 goto out; 2120 goto out;
2121 err = remove_suid(file->f_path.dentry); 2121 err = file_remove_suid(file);
2122 if (err) 2122 if (err)
2123 goto out; 2123 goto out;
2124 file_update_time(file); 2124 file_update_time(file);
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 3e76f3b216bc..4a46743b5077 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3080,7 +3080,7 @@ struct kmem_cache *ntfs_inode_cache;
3080struct kmem_cache *ntfs_big_inode_cache; 3080struct kmem_cache *ntfs_big_inode_cache;
3081 3081
3082/* Init once constructor for the inode slab cache. */ 3082/* Init once constructor for the inode slab cache. */
3083static void ntfs_big_inode_init_once(struct kmem_cache *cachep, void *foo) 3083static void ntfs_big_inode_init_once(void *foo)
3084{ 3084{
3085 ntfs_inode *ni = (ntfs_inode *)foo; 3085 ntfs_inode *ni = (ntfs_inode *)foo;
3086 3086
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index e48aba698b77..533a789c3ef8 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -267,8 +267,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
267 return writelen; 267 return writelen;
268} 268}
269 269
270static void dlmfs_init_once(struct kmem_cache *cachep, 270static void dlmfs_init_once(void *foo)
271 void *foo)
272{ 271{
273 struct dlmfs_inode_private *ip = 272 struct dlmfs_inode_private *ip =
274 (struct dlmfs_inode_private *) foo; 273 (struct dlmfs_inode_private *) foo;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index e8514e8b6ce8..be2dd95d3a1d 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1176,7 +1176,7 @@ bail:
1176 return err; 1176 return err;
1177} 1177}
1178 1178
1179int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd) 1179int ocfs2_permission(struct inode *inode, int mask)
1180{ 1180{
1181 int ret; 1181 int ret;
1182 1182
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index 048ddcaf5c80..1e27b4d017ea 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -62,8 +62,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di,
62int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); 62int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
63int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, 63int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
64 struct kstat *stat); 64 struct kstat *stat);
65int ocfs2_permission(struct inode *inode, int mask, 65int ocfs2_permission(struct inode *inode, int mask);
66 struct nameidata *nd);
67 66
68int ocfs2_should_update_atime(struct inode *inode, 67int ocfs2_should_update_atime(struct inode *inode,
69 struct vfsmount *vfsmnt); 68 struct vfsmount *vfsmnt);
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index ccecfe5094fa..2560b33889aa 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1118,7 +1118,7 @@ bail:
1118 return status; 1118 return status;
1119} 1119}
1120 1120
1121static void ocfs2_inode_init_once(struct kmem_cache *cachep, void *data) 1121static void ocfs2_inode_init_once(void *data)
1122{ 1122{
1123 struct ocfs2_inode_info *oi = data; 1123 struct ocfs2_inode_info *oi = data;
1124 1124
diff --git a/fs/omfs/Makefile b/fs/omfs/Makefile
new file mode 100644
index 000000000000..8b82b63f1129
--- /dev/null
+++ b/fs/omfs/Makefile
@@ -0,0 +1,4 @@
1
2obj-$(CONFIG_OMFS_FS) += omfs.o
3
4omfs-y := bitmap.o dir.o file.o inode.o
diff --git a/fs/omfs/bitmap.c b/fs/omfs/bitmap.c
new file mode 100644
index 000000000000..dc75f22be3f2
--- /dev/null
+++ b/fs/omfs/bitmap.c
@@ -0,0 +1,192 @@
1#include <linux/kernel.h>
2#include <linux/fs.h>
3#include <linux/buffer_head.h>
4#include <asm/div64.h>
5#include "omfs.h"
6
7unsigned long omfs_count_free(struct super_block *sb)
8{
9 unsigned int i;
10 unsigned long sum = 0;
11 struct omfs_sb_info *sbi = OMFS_SB(sb);
12 int nbits = sb->s_blocksize * 8;
13
14 for (i = 0; i < sbi->s_imap_size; i++)
15 sum += nbits - bitmap_weight(sbi->s_imap[i], nbits);
16
17 return sum;
18}
19
20/*
21 * Counts the run of zero bits starting at bit up to max.
22 * It handles the case where a run might spill over a buffer.
23 * Called with bitmap lock.
24 */
25static int count_run(unsigned long **addr, int nbits,
26 int addrlen, int bit, int max)
27{
28 int count = 0;
29 int x;
30
31 for (; addrlen > 0; addrlen--, addr++) {
32 x = find_next_bit(*addr, nbits, bit);
33 count += x - bit;
34
35 if (x < nbits || count > max)
36 return min(count, max);
37
38 bit = 0;
39 }
40 return min(count, max);
41}
42
43/*
44 * Sets or clears the run of count bits starting with bit.
45 * Called with bitmap lock.
46 */
47static int set_run(struct super_block *sb, int map,
48 int nbits, int bit, int count, int set)
49{
50 int i;
51 int err;
52 struct buffer_head *bh;
53 struct omfs_sb_info *sbi = OMFS_SB(sb);
54
55 err = -ENOMEM;
56 bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
57 if (!bh)
58 goto out;
59
60 for (i = 0; i < count; i++, bit++) {
61 if (bit >= nbits) {
62 bit = 0;
63 map++;
64
65 mark_buffer_dirty(bh);
66 brelse(bh);
67 bh = sb_bread(sb,
68 clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
69 if (!bh)
70 goto out;
71 }
72 if (set) {
73 set_bit(bit, sbi->s_imap[map]);
74 set_bit(bit, (long *) bh->b_data);
75 } else {
76 clear_bit(bit, sbi->s_imap[map]);
77 clear_bit(bit, (long *) bh->b_data);
78 }
79 }
80 mark_buffer_dirty(bh);
81 brelse(bh);
82 err = 0;
83out:
84 return err;
85}
86
87/*
88 * Tries to allocate exactly one block. Returns true if sucessful.
89 */
90int omfs_allocate_block(struct super_block *sb, u64 block)
91{
92 struct buffer_head *bh;
93 struct omfs_sb_info *sbi = OMFS_SB(sb);
94 int bits_per_entry = 8 * sb->s_blocksize;
95 int map, bit;
96 int ret = 0;
97 u64 tmp;
98
99 tmp = block;
100 bit = do_div(tmp, bits_per_entry);
101 map = tmp;
102
103 mutex_lock(&sbi->s_bitmap_lock);
104 if (map >= sbi->s_imap_size || test_and_set_bit(bit, sbi->s_imap[map]))
105 goto out;
106
107 if (sbi->s_bitmap_ino > 0) {
108 bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
109 if (!bh)
110 goto out;
111
112 set_bit(bit, (long *) bh->b_data);
113 mark_buffer_dirty(bh);
114 brelse(bh);
115 }
116 ret = 1;
117out:
118 mutex_unlock(&sbi->s_bitmap_lock);
119 return ret;
120}
121
122
123/*
124 * Tries to allocate a set of blocks. The request size depends on the
125 * type: for inodes, we must allocate sbi->s_mirrors blocks, and for file
126 * blocks, we try to allocate sbi->s_clustersize, but can always get away
127 * with just one block.
128 */
129int omfs_allocate_range(struct super_block *sb,
130 int min_request,
131 int max_request,
132 u64 *return_block,
133 int *return_size)
134{
135 struct omfs_sb_info *sbi = OMFS_SB(sb);
136 int bits_per_entry = 8 * sb->s_blocksize;
137 int ret = 0;
138 int i, run, bit;
139
140 mutex_lock(&sbi->s_bitmap_lock);
141 for (i = 0; i < sbi->s_imap_size; i++) {
142 bit = 0;
143 while (bit < bits_per_entry) {
144 bit = find_next_zero_bit(sbi->s_imap[i], bits_per_entry,
145 bit);
146
147 if (bit == bits_per_entry)
148 break;
149
150 run = count_run(&sbi->s_imap[i], bits_per_entry,
151 sbi->s_imap_size-i, bit, max_request);
152
153 if (run >= min_request)
154 goto found;
155 bit += run;
156 }
157 }
158 ret = -ENOSPC;
159 goto out;
160
161found:
162 *return_block = i * bits_per_entry + bit;
163 *return_size = run;
164 ret = set_run(sb, i, bits_per_entry, bit, run, 1);
165
166out:
167 mutex_unlock(&sbi->s_bitmap_lock);
168 return ret;
169}
170
171/*
172 * Clears count bits starting at a given block.
173 */
174int omfs_clear_range(struct super_block *sb, u64 block, int count)
175{
176 struct omfs_sb_info *sbi = OMFS_SB(sb);
177 int bits_per_entry = 8 * sb->s_blocksize;
178 u64 tmp;
179 int map, bit, ret;
180
181 tmp = block;
182 bit = do_div(tmp, bits_per_entry);
183 map = tmp;
184
185 if (map >= sbi->s_imap_size)
186 return 0;
187
188 mutex_lock(&sbi->s_bitmap_lock);
189 ret = set_run(sb, map, bits_per_entry, bit, count, 0);
190 mutex_unlock(&sbi->s_bitmap_lock);
191 return ret;
192}
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
new file mode 100644
index 000000000000..05a5bc31e4bd
--- /dev/null
+++ b/fs/omfs/dir.c
@@ -0,0 +1,504 @@
1/*
2 * OMFS (as used by RIO Karma) directory operations.
3 * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6
7#include <linux/fs.h>
8#include <linux/ctype.h>
9#include <linux/buffer_head.h>
10#include "omfs.h"
11
12static int omfs_hash(const char *name, int namelen, int mod)
13{
14 int i, hash = 0;
15 for (i = 0; i < namelen; i++)
16 hash ^= tolower(name[i]) << (i % 24);
17 return hash % mod;
18}
19
20/*
21 * Finds the bucket for a given name and reads the containing block;
22 * *ofs is set to the offset of the first list entry.
23 */
24static struct buffer_head *omfs_get_bucket(struct inode *dir,
25 const char *name, int namelen, int *ofs)
26{
27 int nbuckets = (dir->i_size - OMFS_DIR_START)/8;
28 int block = clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino);
29 int bucket = omfs_hash(name, namelen, nbuckets);
30
31 *ofs = OMFS_DIR_START + bucket * 8;
32 return sb_bread(dir->i_sb, block);
33}
34
35static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block,
36 const char *name, int namelen,
37 u64 *prev_block)
38{
39 struct buffer_head *bh;
40 struct omfs_inode *oi;
41 int err = -ENOENT;
42 *prev_block = ~0;
43
44 while (block != ~0) {
45 bh = sb_bread(dir->i_sb,
46 clus_to_blk(OMFS_SB(dir->i_sb), block));
47 if (!bh) {
48 err = -EIO;
49 goto err;
50 }
51
52 oi = (struct omfs_inode *) bh->b_data;
53 if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, block)) {
54 brelse(bh);
55 goto err;
56 }
57
58 if (strncmp(oi->i_name, name, namelen) == 0)
59 return bh;
60
61 *prev_block = block;
62 block = be64_to_cpu(oi->i_sibling);
63 brelse(bh);
64 }
65err:
66 return ERR_PTR(err);
67}
68
69static struct buffer_head *omfs_find_entry(struct inode *dir,
70 const char *name, int namelen)
71{
72 struct buffer_head *bh;
73 int ofs;
74 u64 block, dummy;
75
76 bh = omfs_get_bucket(dir, name, namelen, &ofs);
77 if (!bh)
78 return ERR_PTR(-EIO);
79
80 block = be64_to_cpu(*((__be64 *) &bh->b_data[ofs]));
81 brelse(bh);
82
83 return omfs_scan_list(dir, block, name, namelen, &dummy);
84}
85
86int omfs_make_empty(struct inode *inode, struct super_block *sb)
87{
88 struct omfs_sb_info *sbi = OMFS_SB(sb);
89 int block = clus_to_blk(sbi, inode->i_ino);
90 struct buffer_head *bh;
91 struct omfs_inode *oi;
92
93 bh = sb_bread(sb, block);
94 if (!bh)
95 return -ENOMEM;
96
97 memset(bh->b_data, 0, sizeof(struct omfs_inode));
98
99 if (inode->i_mode & S_IFDIR) {
100 memset(&bh->b_data[OMFS_DIR_START], 0xff,
101 sbi->s_sys_blocksize - OMFS_DIR_START);
102 } else
103 omfs_make_empty_table(bh, OMFS_EXTENT_START);
104
105 oi = (struct omfs_inode *) bh->b_data;
106 oi->i_head.h_self = cpu_to_be64(inode->i_ino);
107 oi->i_sibling = ~0ULL;
108
109 mark_buffer_dirty(bh);
110 brelse(bh);
111 return 0;
112}
113
114static int omfs_add_link(struct dentry *dentry, struct inode *inode)
115{
116 struct inode *dir = dentry->d_parent->d_inode;
117 const char *name = dentry->d_name.name;
118 int namelen = dentry->d_name.len;
119 struct omfs_inode *oi;
120 struct buffer_head *bh;
121 u64 block;
122 __be64 *entry;
123 int ofs;
124
125 /* just prepend to head of queue in proper bucket */
126 bh = omfs_get_bucket(dir, name, namelen, &ofs);
127 if (!bh)
128 goto out;
129
130 entry = (__be64 *) &bh->b_data[ofs];
131 block = be64_to_cpu(*entry);
132 *entry = cpu_to_be64(inode->i_ino);
133 mark_buffer_dirty(bh);
134 brelse(bh);
135
136 /* now set the sibling and parent pointers on the new inode */
137 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), inode->i_ino));
138 if (!bh)
139 goto out;
140
141 oi = (struct omfs_inode *) bh->b_data;
142 memcpy(oi->i_name, name, namelen);
143 memset(oi->i_name + namelen, 0, OMFS_NAMELEN - namelen);
144 oi->i_sibling = cpu_to_be64(block);
145 oi->i_parent = cpu_to_be64(dir->i_ino);
146 mark_buffer_dirty(bh);
147 brelse(bh);
148
149 dir->i_ctime = CURRENT_TIME_SEC;
150
151 /* mark affected inodes dirty to rebuild checksums */
152 mark_inode_dirty(dir);
153 mark_inode_dirty(inode);
154 return 0;
155out:
156 return -ENOMEM;
157}
158
159static int omfs_delete_entry(struct dentry *dentry)
160{
161 struct inode *dir = dentry->d_parent->d_inode;
162 struct inode *dirty;
163 const char *name = dentry->d_name.name;
164 int namelen = dentry->d_name.len;
165 struct omfs_inode *oi;
166 struct buffer_head *bh, *bh2;
167 __be64 *entry, next;
168 u64 block, prev;
169 int ofs;
170 int err = -ENOMEM;
171
172 /* delete the proper node in the bucket's linked list */
173 bh = omfs_get_bucket(dir, name, namelen, &ofs);
174 if (!bh)
175 goto out;
176
177 entry = (__be64 *) &bh->b_data[ofs];
178 block = be64_to_cpu(*entry);
179
180 bh2 = omfs_scan_list(dir, block, name, namelen, &prev);
181 if (IS_ERR(bh2)) {
182 err = PTR_ERR(bh2);
183 goto out_free_bh;
184 }
185
186 oi = (struct omfs_inode *) bh2->b_data;
187 next = oi->i_sibling;
188 brelse(bh2);
189
190 if (prev != ~0) {
191 /* found in middle of list, get list ptr */
192 brelse(bh);
193 bh = sb_bread(dir->i_sb,
194 clus_to_blk(OMFS_SB(dir->i_sb), prev));
195 if (!bh)
196 goto out;
197
198 oi = (struct omfs_inode *) bh->b_data;
199 entry = &oi->i_sibling;
200 }
201
202 *entry = next;
203 mark_buffer_dirty(bh);
204
205 if (prev != ~0) {
206 dirty = omfs_iget(dir->i_sb, prev);
207 if (!IS_ERR(dirty)) {
208 mark_inode_dirty(dirty);
209 iput(dirty);
210 }
211 }
212
213 err = 0;
214out_free_bh:
215 brelse(bh);
216out:
217 return err;
218}
219
220static int omfs_dir_is_empty(struct inode *inode)
221{
222 int nbuckets = (inode->i_size - OMFS_DIR_START) / 8;
223 struct buffer_head *bh;
224 u64 *ptr;
225 int i;
226
227 bh = sb_bread(inode->i_sb, clus_to_blk(OMFS_SB(inode->i_sb),
228 inode->i_ino));
229
230 if (!bh)
231 return 0;
232
233 ptr = (u64 *) &bh->b_data[OMFS_DIR_START];
234
235 for (i = 0; i < nbuckets; i++, ptr++)
236 if (*ptr != ~0)
237 break;
238
239 brelse(bh);
240 return *ptr != ~0;
241}
242
243static int omfs_unlink(struct inode *dir, struct dentry *dentry)
244{
245 int ret;
246 struct inode *inode = dentry->d_inode;
247
248 ret = omfs_delete_entry(dentry);
249 if (ret)
250 goto end_unlink;
251
252 inode_dec_link_count(inode);
253 mark_inode_dirty(dir);
254
255end_unlink:
256 return ret;
257}
258
259static int omfs_rmdir(struct inode *dir, struct dentry *dentry)
260{
261 int err = -ENOTEMPTY;
262 struct inode *inode = dentry->d_inode;
263
264 if (omfs_dir_is_empty(inode)) {
265 err = omfs_unlink(dir, dentry);
266 if (!err)
267 inode_dec_link_count(inode);
268 }
269 return err;
270}
271
272static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode)
273{
274 int err;
275 struct inode *inode = omfs_new_inode(dir, mode);
276
277 if (IS_ERR(inode))
278 return PTR_ERR(inode);
279
280 err = omfs_make_empty(inode, dir->i_sb);
281 if (err)
282 goto out_free_inode;
283
284 err = omfs_add_link(dentry, inode);
285 if (err)
286 goto out_free_inode;
287
288 d_instantiate(dentry, inode);
289 return 0;
290
291out_free_inode:
292 iput(inode);
293 return err;
294}
295
296static int omfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
297{
298 return omfs_add_node(dir, dentry, mode | S_IFDIR);
299}
300
301static int omfs_create(struct inode *dir, struct dentry *dentry, int mode,
302 struct nameidata *nd)
303{
304 return omfs_add_node(dir, dentry, mode | S_IFREG);
305}
306
307static struct dentry *omfs_lookup(struct inode *dir, struct dentry *dentry,
308 struct nameidata *nd)
309{
310 struct buffer_head *bh;
311 struct inode *inode = NULL;
312
313 if (dentry->d_name.len > OMFS_NAMELEN)
314 return ERR_PTR(-ENAMETOOLONG);
315
316 bh = omfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
317 if (!IS_ERR(bh)) {
318 struct omfs_inode *oi = (struct omfs_inode *)bh->b_data;
319 ino_t ino = be64_to_cpu(oi->i_head.h_self);
320 brelse(bh);
321 inode = omfs_iget(dir->i_sb, ino);
322 if (IS_ERR(inode))
323 return ERR_CAST(inode);
324 }
325 d_add(dentry, inode);
326 return NULL;
327}
328
329/* sanity check block's self pointer */
330int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
331 u64 fsblock)
332{
333 int is_bad;
334 u64 ino = be64_to_cpu(header->h_self);
335 is_bad = ((ino != fsblock) || (ino < sbi->s_root_ino) ||
336 (ino > sbi->s_num_blocks));
337
338 if (is_bad)
339 printk(KERN_WARNING "omfs: bad hash chain detected\n");
340
341 return is_bad;
342}
343
344static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir,
345 u64 fsblock, int hindex)
346{
347 struct inode *dir = filp->f_dentry->d_inode;
348 struct buffer_head *bh;
349 struct omfs_inode *oi;
350 u64 self;
351 int res = 0;
352 unsigned char d_type;
353
354 /* follow chain in this bucket */
355 while (fsblock != ~0) {
356 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb),
357 fsblock));
358 if (!bh)
359 goto out;
360
361 oi = (struct omfs_inode *) bh->b_data;
362 if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, fsblock)) {
363 brelse(bh);
364 goto out;
365 }
366
367 self = fsblock;
368 fsblock = be64_to_cpu(oi->i_sibling);
369
370 /* skip visited nodes */
371 if (hindex) {
372 hindex--;
373 brelse(bh);
374 continue;
375 }
376
377 d_type = (oi->i_type == OMFS_DIR) ? DT_DIR : DT_REG;
378
379 res = filldir(dirent, oi->i_name, strnlen(oi->i_name,
380 OMFS_NAMELEN), filp->f_pos, self, d_type);
381 if (res == 0)
382 filp->f_pos++;
383 brelse(bh);
384 }
385out:
386 return res;
387}
388
389static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry,
390 struct inode *new_dir, struct dentry *new_dentry)
391{
392 struct inode *new_inode = new_dentry->d_inode;
393 struct inode *old_inode = old_dentry->d_inode;
394 struct buffer_head *bh;
395 int is_dir;
396 int err;
397
398 is_dir = S_ISDIR(old_inode->i_mode);
399
400 if (new_inode) {
401 /* overwriting existing file/dir */
402 err = -ENOTEMPTY;
403 if (is_dir && !omfs_dir_is_empty(new_inode))
404 goto out;
405
406 err = -ENOENT;
407 bh = omfs_find_entry(new_dir, new_dentry->d_name.name,
408 new_dentry->d_name.len);
409 if (IS_ERR(bh))
410 goto out;
411 brelse(bh);
412
413 err = omfs_unlink(new_dir, new_dentry);
414 if (err)
415 goto out;
416 }
417
418 /* since omfs locates files by name, we need to unlink _before_
419 * adding the new link or we won't find the old one */
420 inode_inc_link_count(old_inode);
421 err = omfs_unlink(old_dir, old_dentry);
422 if (err) {
423 inode_dec_link_count(old_inode);
424 goto out;
425 }
426
427 err = omfs_add_link(new_dentry, old_inode);
428 if (err)
429 goto out;
430
431 old_inode->i_ctime = CURRENT_TIME_SEC;
432out:
433 return err;
434}
435
436static int omfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
437{
438 struct inode *dir = filp->f_dentry->d_inode;
439 struct buffer_head *bh;
440 loff_t offset, res;
441 unsigned int hchain, hindex;
442 int nbuckets;
443 u64 fsblock;
444 int ret = -EINVAL;
445
446 if (filp->f_pos >> 32)
447 goto success;
448
449 switch ((unsigned long) filp->f_pos) {
450 case 0:
451 if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0)
452 goto success;
453 filp->f_pos++;
454 /* fall through */
455 case 1:
456 if (filldir(dirent, "..", 2, 1,
457 parent_ino(filp->f_dentry), DT_DIR) < 0)
458 goto success;
459 filp->f_pos = 1 << 20;
460 /* fall through */
461 }
462
463 nbuckets = (dir->i_size - OMFS_DIR_START) / 8;
464
465 /* high 12 bits store bucket + 1 and low 20 bits store hash index */
466 hchain = (filp->f_pos >> 20) - 1;
467 hindex = filp->f_pos & 0xfffff;
468
469 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino));
470 if (!bh)
471 goto out;
472
473 offset = OMFS_DIR_START + hchain * 8;
474
475 for (; hchain < nbuckets; hchain++, offset += 8) {
476 fsblock = be64_to_cpu(*((__be64 *) &bh->b_data[offset]));
477
478 res = omfs_fill_chain(filp, dirent, filldir, fsblock, hindex);
479 hindex = 0;
480 if (res < 0)
481 break;
482
483 filp->f_pos = (hchain+2) << 20;
484 }
485 brelse(bh);
486success:
487 ret = 0;
488out:
489 return ret;
490}
491
492struct inode_operations omfs_dir_inops = {
493 .lookup = omfs_lookup,
494 .mkdir = omfs_mkdir,
495 .rename = omfs_rename,
496 .create = omfs_create,
497 .unlink = omfs_unlink,
498 .rmdir = omfs_rmdir,
499};
500
501struct file_operations omfs_dir_operations = {
502 .read = generic_read_dir,
503 .readdir = omfs_readdir,
504};
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
new file mode 100644
index 000000000000..66e01fae4384
--- /dev/null
+++ b/fs/omfs/file.c
@@ -0,0 +1,346 @@
1/*
2 * OMFS (as used by RIO Karma) file operations.
3 * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6
7#include <linux/version.h>
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/buffer_head.h>
11#include <linux/mpage.h>
12#include "omfs.h"
13
14static int omfs_sync_file(struct file *file, struct dentry *dentry,
15 int datasync)
16{
17 struct inode *inode = dentry->d_inode;
18 int err;
19
20 err = sync_mapping_buffers(inode->i_mapping);
21 if (!(inode->i_state & I_DIRTY))
22 return err;
23 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
24 return err;
25 err |= omfs_sync_inode(inode);
26 return err ? -EIO : 0;
27}
28
29void omfs_make_empty_table(struct buffer_head *bh, int offset)
30{
31 struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset];
32
33 oe->e_next = ~0ULL;
34 oe->e_extent_count = cpu_to_be32(1),
35 oe->e_fill = cpu_to_be32(0x22),
36 oe->e_entry.e_cluster = ~0ULL;
37 oe->e_entry.e_blocks = ~0ULL;
38}
39
40int omfs_shrink_inode(struct inode *inode)
41{
42 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
43 struct omfs_extent *oe;
44 struct omfs_extent_entry *entry;
45 struct buffer_head *bh;
46 u64 next, last;
47 u32 extent_count;
48 int ret;
49
50 /* traverse extent table, freeing each entry that is greater
51 * than inode->i_size;
52 */
53 next = inode->i_ino;
54
55 /* only support truncate -> 0 for now */
56 ret = -EIO;
57 if (inode->i_size != 0)
58 goto out;
59
60 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
61 if (!bh)
62 goto out;
63
64 oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
65
66 for (;;) {
67
68 if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) {
69 brelse(bh);
70 goto out;
71 }
72
73 extent_count = be32_to_cpu(oe->e_extent_count);
74 last = next;
75 next = be64_to_cpu(oe->e_next);
76 entry = &oe->e_entry;
77
78 /* ignore last entry as it is the terminator */
79 for (; extent_count > 1; extent_count--) {
80 u64 start, count;
81 start = be64_to_cpu(entry->e_cluster);
82 count = be64_to_cpu(entry->e_blocks);
83
84 omfs_clear_range(inode->i_sb, start, (int) count);
85 entry++;
86 }
87 omfs_make_empty_table(bh, (char *) oe - bh->b_data);
88 mark_buffer_dirty(bh);
89 brelse(bh);
90
91 if (last != inode->i_ino)
92 omfs_clear_range(inode->i_sb, last, sbi->s_mirrors);
93
94 if (next == ~0)
95 break;
96
97 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
98 if (!bh)
99 goto out;
100 oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
101 }
102 ret = 0;
103out:
104 return ret;
105}
106
107static void omfs_truncate(struct inode *inode)
108{
109 omfs_shrink_inode(inode);
110 mark_inode_dirty(inode);
111}
112
113/*
114 * Add new blocks to the current extent, or create new entries/continuations
115 * as necessary.
116 */
117static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
118 u64 *ret_block)
119{
120 struct omfs_extent_entry *terminator;
121 struct omfs_extent_entry *entry = &oe->e_entry;
122 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
123 u32 extent_count = be32_to_cpu(oe->e_extent_count);
124 u64 new_block = 0;
125 u32 max_count;
126 int new_count;
127 int ret = 0;
128
129 /* reached the end of the extent table with no blocks mapped.
130 * there are three possibilities for adding: grow last extent,
131 * add a new extent to the current extent table, and add a
132 * continuation inode. in last two cases need an allocator for
133 * sbi->s_cluster_size
134 */
135
136 /* TODO: handle holes */
137
138 /* should always have a terminator */
139 if (extent_count < 1)
140 return -EIO;
141
142 /* trivially grow current extent, if next block is not taken */
143 terminator = entry + extent_count - 1;
144 if (extent_count > 1) {
145 entry = terminator-1;
146 new_block = be64_to_cpu(entry->e_cluster) +
147 be64_to_cpu(entry->e_blocks);
148
149 if (omfs_allocate_block(inode->i_sb, new_block)) {
150 entry->e_blocks =
151 cpu_to_be64(be64_to_cpu(entry->e_blocks) + 1);
152 terminator->e_blocks = ~(cpu_to_be64(
153 be64_to_cpu(~terminator->e_blocks) + 1));
154 goto out;
155 }
156 }
157 max_count = (sbi->s_sys_blocksize - OMFS_EXTENT_START -
158 sizeof(struct omfs_extent)) /
159 sizeof(struct omfs_extent_entry) + 1;
160
161 /* TODO: add a continuation block here */
162 if (be32_to_cpu(oe->e_extent_count) > max_count-1)
163 return -EIO;
164
165 /* try to allocate a new cluster */
166 ret = omfs_allocate_range(inode->i_sb, 1, sbi->s_clustersize,
167 &new_block, &new_count);
168 if (ret)
169 goto out_fail;
170
171 /* copy terminator down an entry */
172 entry = terminator;
173 terminator++;
174 memcpy(terminator, entry, sizeof(struct omfs_extent_entry));
175
176 entry->e_cluster = cpu_to_be64(new_block);
177 entry->e_blocks = cpu_to_be64((u64) new_count);
178
179 terminator->e_blocks = ~(cpu_to_be64(
180 be64_to_cpu(~terminator->e_blocks) + (u64) new_count));
181
182 /* write in new entry */
183 oe->e_extent_count = cpu_to_be32(1 + be32_to_cpu(oe->e_extent_count));
184
185out:
186 *ret_block = new_block;
187out_fail:
188 return ret;
189}
190
191/*
192 * Scans across the directory table for a given file block number.
193 * If block not found, return 0.
194 */
195static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent,
196 sector_t block, int count, int *left)
197{
198 /* count > 1 because of terminator */
199 sector_t searched = 0;
200 for (; count > 1; count--) {
201 int numblocks = clus_to_blk(OMFS_SB(inode->i_sb),
202 be64_to_cpu(ent->e_blocks));
203
204 if (block >= searched &&
205 block < searched + numblocks) {
206 /*
207 * found it at cluster + (block - searched)
208 * numblocks - (block - searched) is remainder
209 */
210 *left = numblocks - (block - searched);
211 return clus_to_blk(OMFS_SB(inode->i_sb),
212 be64_to_cpu(ent->e_cluster)) +
213 block - searched;
214 }
215 searched += numblocks;
216 ent++;
217 }
218 return 0;
219}
220
221static int omfs_get_block(struct inode *inode, sector_t block,
222 struct buffer_head *bh_result, int create)
223{
224 struct buffer_head *bh;
225 sector_t next, offset;
226 int ret;
227 u64 new_block;
228 int extent_count;
229 struct omfs_extent *oe;
230 struct omfs_extent_entry *entry;
231 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
232 int max_blocks = bh_result->b_size >> inode->i_blkbits;
233 int remain;
234
235 ret = -EIO;
236 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, inode->i_ino));
237 if (!bh)
238 goto out;
239
240 oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
241 next = inode->i_ino;
242
243 for (;;) {
244
245 if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next))
246 goto out_brelse;
247
248 extent_count = be32_to_cpu(oe->e_extent_count);
249 next = be64_to_cpu(oe->e_next);
250 entry = &oe->e_entry;
251
252 offset = find_block(inode, entry, block, extent_count, &remain);
253 if (offset > 0) {
254 ret = 0;
255 map_bh(bh_result, inode->i_sb, offset);
256 if (remain > max_blocks)
257 remain = max_blocks;
258 bh_result->b_size = (remain << inode->i_blkbits);
259 goto out_brelse;
260 }
261 if (next == ~0)
262 break;
263
264 brelse(bh);
265 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
266 if (!bh)
267 goto out;
268 oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
269 }
270 if (create) {
271 ret = omfs_grow_extent(inode, oe, &new_block);
272 if (ret == 0) {
273 mark_buffer_dirty(bh);
274 mark_inode_dirty(inode);
275 map_bh(bh_result, inode->i_sb,
276 clus_to_blk(sbi, new_block));
277 }
278 }
279out_brelse:
280 brelse(bh);
281out:
282 return ret;
283}
284
285static int omfs_readpage(struct file *file, struct page *page)
286{
287 return block_read_full_page(page, omfs_get_block);
288}
289
290static int omfs_readpages(struct file *file, struct address_space *mapping,
291 struct list_head *pages, unsigned nr_pages)
292{
293 return mpage_readpages(mapping, pages, nr_pages, omfs_get_block);
294}
295
296static int omfs_writepage(struct page *page, struct writeback_control *wbc)
297{
298 return block_write_full_page(page, omfs_get_block, wbc);
299}
300
301static int
302omfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
303{
304 return mpage_writepages(mapping, wbc, omfs_get_block);
305}
306
307static int omfs_write_begin(struct file *file, struct address_space *mapping,
308 loff_t pos, unsigned len, unsigned flags,
309 struct page **pagep, void **fsdata)
310{
311 *pagep = NULL;
312 return block_write_begin(file, mapping, pos, len, flags,
313 pagep, fsdata, omfs_get_block);
314}
315
316static sector_t omfs_bmap(struct address_space *mapping, sector_t block)
317{
318 return generic_block_bmap(mapping, block, omfs_get_block);
319}
320
321struct file_operations omfs_file_operations = {
322 .llseek = generic_file_llseek,
323 .read = do_sync_read,
324 .write = do_sync_write,
325 .aio_read = generic_file_aio_read,
326 .aio_write = generic_file_aio_write,
327 .mmap = generic_file_mmap,
328 .fsync = omfs_sync_file,
329 .splice_read = generic_file_splice_read,
330};
331
332struct inode_operations omfs_file_inops = {
333 .truncate = omfs_truncate
334};
335
336struct address_space_operations omfs_aops = {
337 .readpage = omfs_readpage,
338 .readpages = omfs_readpages,
339 .writepage = omfs_writepage,
340 .writepages = omfs_writepages,
341 .sync_page = block_sync_page,
342 .write_begin = omfs_write_begin,
343 .write_end = generic_write_end,
344 .bmap = omfs_bmap,
345};
346
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
new file mode 100644
index 000000000000..d865f5535436
--- /dev/null
+++ b/fs/omfs/inode.c
@@ -0,0 +1,553 @@
1/*
2 * Optimized MPEG FS - inode and super operations.
3 * Copyright (C) 2006 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6#include <linux/version.h>
7#include <linux/module.h>
8#include <linux/sched.h>
9#include <linux/fs.h>
10#include <linux/vfs.h>
11#include <linux/parser.h>
12#include <linux/buffer_head.h>
13#include <linux/vmalloc.h>
14#include <linux/crc-itu-t.h>
15#include "omfs.h"
16
17MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>");
18MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux");
19MODULE_LICENSE("GPL");
20
21struct inode *omfs_new_inode(struct inode *dir, int mode)
22{
23 struct inode *inode;
24 u64 new_block;
25 int err;
26 int len;
27 struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb);
28
29 inode = new_inode(dir->i_sb);
30 if (!inode)
31 return ERR_PTR(-ENOMEM);
32
33 err = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors,
34 &new_block, &len);
35 if (err)
36 goto fail;
37
38 inode->i_ino = new_block;
39 inode->i_mode = mode;
40 inode->i_uid = current->fsuid;
41 inode->i_gid = current->fsgid;
42 inode->i_blocks = 0;
43 inode->i_mapping->a_ops = &omfs_aops;
44
45 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
46 switch (mode & S_IFMT) {
47 case S_IFDIR:
48 inode->i_op = &omfs_dir_inops;
49 inode->i_fop = &omfs_dir_operations;
50 inode->i_size = sbi->s_sys_blocksize;
51 inc_nlink(inode);
52 break;
53 case S_IFREG:
54 inode->i_op = &omfs_file_inops;
55 inode->i_fop = &omfs_file_operations;
56 inode->i_size = 0;
57 break;
58 }
59
60 insert_inode_hash(inode);
61 mark_inode_dirty(inode);
62 return inode;
63fail:
64 make_bad_inode(inode);
65 iput(inode);
66 return ERR_PTR(err);
67}
68
69/*
70 * Update the header checksums for a dirty inode based on its contents.
71 * Caller is expected to hold the buffer head underlying oi and mark it
72 * dirty.
73 */
74static void omfs_update_checksums(struct omfs_inode *oi)
75{
76 int xor, i, ofs = 0, count;
77 u16 crc = 0;
78 unsigned char *ptr = (unsigned char *) oi;
79
80 count = be32_to_cpu(oi->i_head.h_body_size);
81 ofs = sizeof(struct omfs_header);
82
83 crc = crc_itu_t(crc, ptr + ofs, count);
84 oi->i_head.h_crc = cpu_to_be16(crc);
85
86 xor = ptr[0];
87 for (i = 1; i < OMFS_XOR_COUNT; i++)
88 xor ^= ptr[i];
89
90 oi->i_head.h_check_xor = xor;
91}
92
93static int omfs_write_inode(struct inode *inode, int wait)
94{
95 struct omfs_inode *oi;
96 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
97 struct buffer_head *bh, *bh2;
98 unsigned int block;
99 u64 ctime;
100 int i;
101 int ret = -EIO;
102 int sync_failed = 0;
103
104 /* get current inode since we may have written sibling ptrs etc. */
105 block = clus_to_blk(sbi, inode->i_ino);
106 bh = sb_bread(inode->i_sb, block);
107 if (!bh)
108 goto out;
109
110 oi = (struct omfs_inode *) bh->b_data;
111
112 oi->i_head.h_self = cpu_to_be64(inode->i_ino);
113 if (S_ISDIR(inode->i_mode))
114 oi->i_type = OMFS_DIR;
115 else if (S_ISREG(inode->i_mode))
116 oi->i_type = OMFS_FILE;
117 else {
118 printk(KERN_WARNING "omfs: unknown file type: %d\n",
119 inode->i_mode);
120 goto out_brelse;
121 }
122
123 oi->i_head.h_body_size = cpu_to_be32(sbi->s_sys_blocksize -
124 sizeof(struct omfs_header));
125 oi->i_head.h_version = 1;
126 oi->i_head.h_type = OMFS_INODE_NORMAL;
127 oi->i_head.h_magic = OMFS_IMAGIC;
128 oi->i_size = cpu_to_be64(inode->i_size);
129
130 ctime = inode->i_ctime.tv_sec * 1000LL +
131 ((inode->i_ctime.tv_nsec + 999)/1000);
132 oi->i_ctime = cpu_to_be64(ctime);
133
134 omfs_update_checksums(oi);
135
136 mark_buffer_dirty(bh);
137 if (wait) {
138 sync_dirty_buffer(bh);
139 if (buffer_req(bh) && !buffer_uptodate(bh))
140 sync_failed = 1;
141 }
142
143 /* if mirroring writes, copy to next fsblock */
144 for (i = 1; i < sbi->s_mirrors; i++) {
145 bh2 = sb_bread(inode->i_sb, block + i *
146 (sbi->s_blocksize / sbi->s_sys_blocksize));
147 if (!bh2)
148 goto out_brelse;
149
150 memcpy(bh2->b_data, bh->b_data, bh->b_size);
151 mark_buffer_dirty(bh2);
152 if (wait) {
153 sync_dirty_buffer(bh2);
154 if (buffer_req(bh2) && !buffer_uptodate(bh2))
155 sync_failed = 1;
156 }
157 brelse(bh2);
158 }
159 ret = (sync_failed) ? -EIO : 0;
160out_brelse:
161 brelse(bh);
162out:
163 return ret;
164}
165
166int omfs_sync_inode(struct inode *inode)
167{
168 return omfs_write_inode(inode, 1);
169}
170
171/*
172 * called when an entry is deleted, need to clear the bits in the
173 * bitmaps.
174 */
175static void omfs_delete_inode(struct inode *inode)
176{
177 truncate_inode_pages(&inode->i_data, 0);
178
179 if (S_ISREG(inode->i_mode)) {
180 inode->i_size = 0;
181 omfs_shrink_inode(inode);
182 }
183
184 omfs_clear_range(inode->i_sb, inode->i_ino, 2);
185 clear_inode(inode);
186}
187
188struct inode *omfs_iget(struct super_block *sb, ino_t ino)
189{
190 struct omfs_sb_info *sbi = OMFS_SB(sb);
191 struct omfs_inode *oi;
192 struct buffer_head *bh;
193 unsigned int block;
194 u64 ctime;
195 unsigned long nsecs;
196 struct inode *inode;
197
198 inode = iget_locked(sb, ino);
199 if (!inode)
200 return ERR_PTR(-ENOMEM);
201 if (!(inode->i_state & I_NEW))
202 return inode;
203
204 block = clus_to_blk(sbi, ino);
205 bh = sb_bread(inode->i_sb, block);
206 if (!bh)
207 goto iget_failed;
208
209 oi = (struct omfs_inode *)bh->b_data;
210
211 /* check self */
212 if (ino != be64_to_cpu(oi->i_head.h_self))
213 goto fail_bh;
214
215 inode->i_uid = sbi->s_uid;
216 inode->i_gid = sbi->s_gid;
217
218 ctime = be64_to_cpu(oi->i_ctime);
219 nsecs = do_div(ctime, 1000) * 1000L;
220
221 inode->i_atime.tv_sec = ctime;
222 inode->i_mtime.tv_sec = ctime;
223 inode->i_ctime.tv_sec = ctime;
224 inode->i_atime.tv_nsec = nsecs;
225 inode->i_mtime.tv_nsec = nsecs;
226 inode->i_ctime.tv_nsec = nsecs;
227
228 inode->i_mapping->a_ops = &omfs_aops;
229
230 switch (oi->i_type) {
231 case OMFS_DIR:
232 inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask);
233 inode->i_op = &omfs_dir_inops;
234 inode->i_fop = &omfs_dir_operations;
235 inode->i_size = be32_to_cpu(oi->i_head.h_body_size) +
236 sizeof(struct omfs_header);
237 inc_nlink(inode);
238 break;
239 case OMFS_FILE:
240 inode->i_mode = S_IFREG | (S_IRWXUGO & ~sbi->s_fmask);
241 inode->i_fop = &omfs_file_operations;
242 inode->i_size = be64_to_cpu(oi->i_size);
243 break;
244 }
245 brelse(bh);
246 unlock_new_inode(inode);
247 return inode;
248fail_bh:
249 brelse(bh);
250iget_failed:
251 iget_failed(inode);
252 return ERR_PTR(-EIO);
253}
254
255static void omfs_put_super(struct super_block *sb)
256{
257 struct omfs_sb_info *sbi = OMFS_SB(sb);
258 kfree(sbi->s_imap);
259 kfree(sbi);
260 sb->s_fs_info = NULL;
261}
262
263static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf)
264{
265 struct super_block *s = dentry->d_sb;
266 struct omfs_sb_info *sbi = OMFS_SB(s);
267 buf->f_type = OMFS_MAGIC;
268 buf->f_bsize = sbi->s_blocksize;
269 buf->f_blocks = sbi->s_num_blocks;
270 buf->f_files = sbi->s_num_blocks;
271 buf->f_namelen = OMFS_NAMELEN;
272
273 buf->f_bfree = buf->f_bavail = buf->f_ffree =
274 omfs_count_free(s);
275 return 0;
276}
277
278static struct super_operations omfs_sops = {
279 .write_inode = omfs_write_inode,
280 .delete_inode = omfs_delete_inode,
281 .put_super = omfs_put_super,
282 .statfs = omfs_statfs,
283 .show_options = generic_show_options,
284};
285
286/*
287 * For Rio Karma, there is an on-disk free bitmap whose location is
288 * stored in the root block. For ReplayTV, there is no such free bitmap
289 * so we have to walk the tree. Both inodes and file data are allocated
290 * from the same map. This array can be big (300k) so we allocate
291 * in units of the blocksize.
292 */
293static int omfs_get_imap(struct super_block *sb)
294{
295 int bitmap_size;
296 int array_size;
297 int count;
298 struct omfs_sb_info *sbi = OMFS_SB(sb);
299 struct buffer_head *bh;
300 unsigned long **ptr;
301 sector_t block;
302
303 bitmap_size = DIV_ROUND_UP(sbi->s_num_blocks, 8);
304 array_size = DIV_ROUND_UP(bitmap_size, sb->s_blocksize);
305
306 if (sbi->s_bitmap_ino == ~0ULL)
307 goto out;
308
309 sbi->s_imap_size = array_size;
310 sbi->s_imap = kzalloc(array_size * sizeof(unsigned long *), GFP_KERNEL);
311 if (!sbi->s_imap)
312 goto nomem;
313
314 block = clus_to_blk(sbi, sbi->s_bitmap_ino);
315 ptr = sbi->s_imap;
316 for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
317 bh = sb_bread(sb, block++);
318 if (!bh)
319 goto nomem_free;
320 *ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
321 if (!*ptr) {
322 brelse(bh);
323 goto nomem_free;
324 }
325 memcpy(*ptr, bh->b_data, sb->s_blocksize);
326 if (count < sb->s_blocksize)
327 memset((void *)*ptr + count, 0xff,
328 sb->s_blocksize - count);
329 brelse(bh);
330 ptr++;
331 }
332out:
333 return 0;
334
335nomem_free:
336 for (count = 0; count < array_size; count++)
337 kfree(sbi->s_imap[count]);
338
339 kfree(sbi->s_imap);
340nomem:
341 sbi->s_imap = NULL;
342 sbi->s_imap_size = 0;
343 return -ENOMEM;
344}
345
346enum {
347 Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask
348};
349
350static match_table_t tokens = {
351 {Opt_uid, "uid=%u"},
352 {Opt_gid, "gid=%u"},
353 {Opt_umask, "umask=%o"},
354 {Opt_dmask, "dmask=%o"},
355 {Opt_fmask, "fmask=%o"},
356};
357
358static int parse_options(char *options, struct omfs_sb_info *sbi)
359{
360 char *p;
361 substring_t args[MAX_OPT_ARGS];
362 int option;
363
364 if (!options)
365 return 1;
366
367 while ((p = strsep(&options, ",")) != NULL) {
368 int token;
369 if (!*p)
370 continue;
371
372 token = match_token(p, tokens, args);
373 switch (token) {
374 case Opt_uid:
375 if (match_int(&args[0], &option))
376 return 0;
377 sbi->s_uid = option;
378 break;
379 case Opt_gid:
380 if (match_int(&args[0], &option))
381 return 0;
382 sbi->s_gid = option;
383 break;
384 case Opt_umask:
385 if (match_octal(&args[0], &option))
386 return 0;
387 sbi->s_fmask = sbi->s_dmask = option;
388 break;
389 case Opt_dmask:
390 if (match_octal(&args[0], &option))
391 return 0;
392 sbi->s_dmask = option;
393 break;
394 case Opt_fmask:
395 if (match_octal(&args[0], &option))
396 return 0;
397 sbi->s_fmask = option;
398 break;
399 default:
400 return 0;
401 }
402 }
403 return 1;
404}
405
406static int omfs_fill_super(struct super_block *sb, void *data, int silent)
407{
408 struct buffer_head *bh, *bh2;
409 struct omfs_super_block *omfs_sb;
410 struct omfs_root_block *omfs_rb;
411 struct omfs_sb_info *sbi;
412 struct inode *root;
413 sector_t start;
414 int ret = -EINVAL;
415
416 save_mount_options(sb, (char *) data);
417
418 sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
419 if (!sbi)
420 return -ENOMEM;
421
422 sb->s_fs_info = sbi;
423
424 sbi->s_uid = current->uid;
425 sbi->s_gid = current->gid;
426 sbi->s_dmask = sbi->s_fmask = current->fs->umask;
427
428 if (!parse_options((char *) data, sbi))
429 goto end;
430
431 sb->s_maxbytes = 0xffffffff;
432
433 sb_set_blocksize(sb, 0x200);
434
435 bh = sb_bread(sb, 0);
436 if (!bh)
437 goto end;
438
439 omfs_sb = (struct omfs_super_block *)bh->b_data;
440
441 if (omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)) {
442 if (!silent)
443 printk(KERN_ERR "omfs: Invalid superblock (%x)\n",
444 omfs_sb->s_magic);
445 goto out_brelse_bh;
446 }
447 sb->s_magic = OMFS_MAGIC;
448
449 sbi->s_num_blocks = be64_to_cpu(omfs_sb->s_num_blocks);
450 sbi->s_blocksize = be32_to_cpu(omfs_sb->s_blocksize);
451 sbi->s_mirrors = be32_to_cpu(omfs_sb->s_mirrors);
452 sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block);
453 sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
454 mutex_init(&sbi->s_bitmap_lock);
455
456 if (sbi->s_sys_blocksize > PAGE_SIZE) {
457 printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
458 sbi->s_sys_blocksize);
459 goto out_brelse_bh;
460 }
461
462 if (sbi->s_blocksize < sbi->s_sys_blocksize ||
463 sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) {
464 printk(KERN_ERR "omfs: block size (%d) is out of range\n",
465 sbi->s_blocksize);
466 goto out_brelse_bh;
467 }
468
469 /*
470 * Use sys_blocksize as the fs block since it is smaller than a
471 * page while the fs blocksize can be larger.
472 */
473 sb_set_blocksize(sb, sbi->s_sys_blocksize);
474
475 /*
476 * ...and the difference goes into a shift. sys_blocksize is always
477 * a power of two factor of blocksize.
478 */
479 sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) -
480 get_bitmask_order(sbi->s_sys_blocksize);
481
482 start = clus_to_blk(sbi, be64_to_cpu(omfs_sb->s_root_block));
483 bh2 = sb_bread(sb, start);
484 if (!bh2)
485 goto out_brelse_bh;
486
487 omfs_rb = (struct omfs_root_block *)bh2->b_data;
488
489 sbi->s_bitmap_ino = be64_to_cpu(omfs_rb->r_bitmap);
490 sbi->s_clustersize = be32_to_cpu(omfs_rb->r_clustersize);
491
492 if (sbi->s_num_blocks != be64_to_cpu(omfs_rb->r_num_blocks)) {
493 printk(KERN_ERR "omfs: block count discrepancy between "
494 "super and root blocks (%llx, %llx)\n",
495 sbi->s_num_blocks, be64_to_cpu(omfs_rb->r_num_blocks));
496 goto out_brelse_bh2;
497 }
498
499 ret = omfs_get_imap(sb);
500 if (ret)
501 goto out_brelse_bh2;
502
503 sb->s_op = &omfs_sops;
504
505 root = omfs_iget(sb, be64_to_cpu(omfs_rb->r_root_dir));
506 if (IS_ERR(root)) {
507 ret = PTR_ERR(root);
508 goto out_brelse_bh2;
509 }
510
511 sb->s_root = d_alloc_root(root);
512 if (!sb->s_root) {
513 iput(root);
514 goto out_brelse_bh2;
515 }
516 printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name);
517
518 ret = 0;
519out_brelse_bh2:
520 brelse(bh2);
521out_brelse_bh:
522 brelse(bh);
523end:
524 return ret;
525}
526
527static int omfs_get_sb(struct file_system_type *fs_type,
528 int flags, const char *dev_name,
529 void *data, struct vfsmount *m)
530{
531 return get_sb_bdev(fs_type, flags, dev_name, data, omfs_fill_super, m);
532}
533
534static struct file_system_type omfs_fs_type = {
535 .owner = THIS_MODULE,
536 .name = "omfs",
537 .get_sb = omfs_get_sb,
538 .kill_sb = kill_block_super,
539 .fs_flags = FS_REQUIRES_DEV,
540};
541
542static int __init init_omfs_fs(void)
543{
544 return register_filesystem(&omfs_fs_type);
545}
546
547static void __exit exit_omfs_fs(void)
548{
549 unregister_filesystem(&omfs_fs_type);
550}
551
552module_init(init_omfs_fs);
553module_exit(exit_omfs_fs);
diff --git a/fs/omfs/omfs.h b/fs/omfs/omfs.h
new file mode 100644
index 000000000000..2bc0f0670406
--- /dev/null
+++ b/fs/omfs/omfs.h
@@ -0,0 +1,67 @@
1#ifndef _OMFS_H
2#define _OMFS_H
3
4#include <linux/module.h>
5#include <linux/fs.h>
6
7#include "omfs_fs.h"
8
9/* In-memory structures */
10struct omfs_sb_info {
11 u64 s_num_blocks;
12 u64 s_bitmap_ino;
13 u64 s_root_ino;
14 u32 s_blocksize;
15 u32 s_mirrors;
16 u32 s_sys_blocksize;
17 u32 s_clustersize;
18 int s_block_shift;
19 unsigned long **s_imap;
20 int s_imap_size;
21 struct mutex s_bitmap_lock;
22 int s_uid;
23 int s_gid;
24 int s_dmask;
25 int s_fmask;
26};
27
28/* convert a cluster number to a scaled block number */
29static inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block)
30{
31 return block << sbi->s_block_shift;
32}
33
34static inline struct omfs_sb_info *OMFS_SB(struct super_block *sb)
35{
36 return sb->s_fs_info;
37}
38
39/* bitmap.c */
40extern unsigned long omfs_count_free(struct super_block *sb);
41extern int omfs_allocate_block(struct super_block *sb, u64 block);
42extern int omfs_allocate_range(struct super_block *sb, int min_request,
43 int max_request, u64 *return_block, int *return_size);
44extern int omfs_clear_range(struct super_block *sb, u64 block, int count);
45
46/* dir.c */
47extern struct file_operations omfs_dir_operations;
48extern struct inode_operations omfs_dir_inops;
49extern int omfs_make_empty(struct inode *inode, struct super_block *sb);
50extern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
51 u64 fsblock);
52
53/* file.c */
54extern struct file_operations omfs_file_operations;
55extern struct inode_operations omfs_file_inops;
56extern struct address_space_operations omfs_aops;
57extern void omfs_make_empty_table(struct buffer_head *bh, int offset);
58extern int omfs_shrink_inode(struct inode *inode);
59
60/* inode.c */
61extern struct inode *omfs_iget(struct super_block *sb, ino_t inode);
62extern struct inode *omfs_new_inode(struct inode *dir, int mode);
63extern int omfs_reserve_block(struct super_block *sb, sector_t block);
64extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino);
65extern int omfs_sync_inode(struct inode *inode);
66
67#endif
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h
new file mode 100644
index 000000000000..12cca245d6e8
--- /dev/null
+++ b/fs/omfs/omfs_fs.h
@@ -0,0 +1,80 @@
1#ifndef _OMFS_FS_H
2#define _OMFS_FS_H
3
4/* OMFS On-disk structures */
5
6#define OMFS_MAGIC 0xC2993D87
7#define OMFS_IMAGIC 0xD2
8
9#define OMFS_DIR 'D'
10#define OMFS_FILE 'F'
11#define OMFS_INODE_NORMAL 'e'
12#define OMFS_INODE_CONTINUATION 'c'
13#define OMFS_INODE_SYSTEM 's'
14#define OMFS_NAMELEN 256
15#define OMFS_DIR_START 0x1b8
16#define OMFS_EXTENT_START 0x1d0
17#define OMFS_EXTENT_CONT 0x40
18#define OMFS_XOR_COUNT 19
19#define OMFS_MAX_BLOCK_SIZE 8192
20
21struct omfs_super_block {
22 char s_fill1[256];
23 __be64 s_root_block; /* block number of omfs_root_block */
24 __be64 s_num_blocks; /* total number of FS blocks */
25 __be32 s_magic; /* OMFS_MAGIC */
26 __be32 s_blocksize; /* size of a block */
27 __be32 s_mirrors; /* # of mirrors of system blocks */
28 __be32 s_sys_blocksize; /* size of non-data blocks */
29};
30
31struct omfs_header {
32 __be64 h_self; /* FS block where this is located */
33 __be32 h_body_size; /* size of useful data after header */
34 __be16 h_crc; /* crc-ccitt of body_size bytes */
35 char h_fill1[2];
36 u8 h_version; /* version, always 1 */
37 char h_type; /* OMFS_INODE_X */
38 u8 h_magic; /* OMFS_IMAGIC */
39 u8 h_check_xor; /* XOR of header bytes before this */
40 __be32 h_fill2;
41};
42
43struct omfs_root_block {
44 struct omfs_header r_head; /* header */
45 __be64 r_fill1;
46 __be64 r_num_blocks; /* total number of FS blocks */
47 __be64 r_root_dir; /* block # of root directory */
48 __be64 r_bitmap; /* block # of free space bitmap */
49 __be32 r_blocksize; /* size of a block */
50 __be32 r_clustersize; /* size allocated for data blocks */
51 __be64 r_mirrors; /* # of mirrors of system blocks */
52 char r_name[OMFS_NAMELEN]; /* partition label */
53};
54
55struct omfs_inode {
56 struct omfs_header i_head; /* header */
57 __be64 i_parent; /* parent containing this inode */
58 __be64 i_sibling; /* next inode in hash bucket */
59 __be64 i_ctime; /* ctime, in milliseconds */
60 char i_fill1[35];
61 char i_type; /* OMFS_[DIR,FILE] */
62 __be32 i_fill2;
63 char i_fill3[64];
64 char i_name[OMFS_NAMELEN]; /* filename */
65 __be64 i_size; /* size of file, in bytes */
66};
67
68struct omfs_extent_entry {
69 __be64 e_cluster; /* start location of a set of blocks */
70 __be64 e_blocks; /* number of blocks after e_cluster */
71};
72
73struct omfs_extent {
74 __be64 e_next; /* next extent table location */
75 __be32 e_extent_count; /* total # extents in this table */
76 __be32 e_fill;
77 struct omfs_extent_entry e_entry; /* start of extent entries */
78};
79
80#endif
diff --git a/fs/open.c b/fs/open.c
index bb98d2fe809f..52647be277a2 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -122,37 +122,37 @@ static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf)
122 return 0; 122 return 0;
123} 123}
124 124
125asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf) 125asmlinkage long sys_statfs(const char __user *pathname, struct statfs __user * buf)
126{ 126{
127 struct nameidata nd; 127 struct path path;
128 int error; 128 int error;
129 129
130 error = user_path_walk(path, &nd); 130 error = user_path(pathname, &path);
131 if (!error) { 131 if (!error) {
132 struct statfs tmp; 132 struct statfs tmp;
133 error = vfs_statfs_native(nd.path.dentry, &tmp); 133 error = vfs_statfs_native(path.dentry, &tmp);
134 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 134 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
135 error = -EFAULT; 135 error = -EFAULT;
136 path_put(&nd.path); 136 path_put(&path);
137 } 137 }
138 return error; 138 return error;
139} 139}
140 140
141 141
142asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64 __user *buf) 142asmlinkage long sys_statfs64(const char __user *pathname, size_t sz, struct statfs64 __user *buf)
143{ 143{
144 struct nameidata nd; 144 struct path path;
145 long error; 145 long error;
146 146
147 if (sz != sizeof(*buf)) 147 if (sz != sizeof(*buf))
148 return -EINVAL; 148 return -EINVAL;
149 error = user_path_walk(path, &nd); 149 error = user_path(pathname, &path);
150 if (!error) { 150 if (!error) {
151 struct statfs64 tmp; 151 struct statfs64 tmp;
152 error = vfs_statfs64(nd.path.dentry, &tmp); 152 error = vfs_statfs64(path.dentry, &tmp);
153 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 153 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
154 error = -EFAULT; 154 error = -EFAULT;
155 path_put(&nd.path); 155 path_put(&path);
156 } 156 }
157 return error; 157 return error;
158} 158}
@@ -223,20 +223,20 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
223 return err; 223 return err;
224} 224}
225 225
226static long do_sys_truncate(const char __user * path, loff_t length) 226static long do_sys_truncate(const char __user *pathname, loff_t length)
227{ 227{
228 struct nameidata nd; 228 struct path path;
229 struct inode * inode; 229 struct inode *inode;
230 int error; 230 int error;
231 231
232 error = -EINVAL; 232 error = -EINVAL;
233 if (length < 0) /* sorry, but loff_t says... */ 233 if (length < 0) /* sorry, but loff_t says... */
234 goto out; 234 goto out;
235 235
236 error = user_path_walk(path, &nd); 236 error = user_path(pathname, &path);
237 if (error) 237 if (error)
238 goto out; 238 goto out;
239 inode = nd.path.dentry->d_inode; 239 inode = path.dentry->d_inode;
240 240
241 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ 241 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
242 error = -EISDIR; 242 error = -EISDIR;
@@ -247,16 +247,16 @@ static long do_sys_truncate(const char __user * path, loff_t length)
247 if (!S_ISREG(inode->i_mode)) 247 if (!S_ISREG(inode->i_mode))
248 goto dput_and_out; 248 goto dput_and_out;
249 249
250 error = mnt_want_write(nd.path.mnt); 250 error = mnt_want_write(path.mnt);
251 if (error) 251 if (error)
252 goto dput_and_out; 252 goto dput_and_out;
253 253
254 error = vfs_permission(&nd, MAY_WRITE); 254 error = inode_permission(inode, MAY_WRITE);
255 if (error) 255 if (error)
256 goto mnt_drop_write_and_out; 256 goto mnt_drop_write_and_out;
257 257
258 error = -EPERM; 258 error = -EPERM;
259 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 259 if (IS_APPEND(inode))
260 goto mnt_drop_write_and_out; 260 goto mnt_drop_write_and_out;
261 261
262 error = get_write_access(inode); 262 error = get_write_access(inode);
@@ -274,15 +274,15 @@ static long do_sys_truncate(const char __user * path, loff_t length)
274 error = locks_verify_truncate(inode, NULL, length); 274 error = locks_verify_truncate(inode, NULL, length);
275 if (!error) { 275 if (!error) {
276 DQUOT_INIT(inode); 276 DQUOT_INIT(inode);
277 error = do_truncate(nd.path.dentry, length, 0, NULL); 277 error = do_truncate(path.dentry, length, 0, NULL);
278 } 278 }
279 279
280put_write_and_out: 280put_write_and_out:
281 put_write_access(inode); 281 put_write_access(inode);
282mnt_drop_write_and_out: 282mnt_drop_write_and_out:
283 mnt_drop_write(nd.path.mnt); 283 mnt_drop_write(path.mnt);
284dput_and_out: 284dput_and_out:
285 path_put(&nd.path); 285 path_put(&path);
286out: 286out:
287 return error; 287 return error;
288} 288}
@@ -425,7 +425,8 @@ out:
425 */ 425 */
426asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) 426asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
427{ 427{
428 struct nameidata nd; 428 struct path path;
429 struct inode *inode;
429 int old_fsuid, old_fsgid; 430 int old_fsuid, old_fsgid;
430 kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */ 431 kernel_cap_t uninitialized_var(old_cap); /* !SECURE_NO_SETUID_FIXUP */
431 int res; 432 int res;
@@ -448,7 +449,7 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
448 * FIXME: There is a race here against sys_capset. The 449 * FIXME: There is a race here against sys_capset. The
449 * capabilities can change yet we will restore the old 450 * capabilities can change yet we will restore the old
450 * value below. We should hold task_capabilities_lock, 451 * value below. We should hold task_capabilities_lock,
451 * but we cannot because user_path_walk can sleep. 452 * but we cannot because user_path_at can sleep.
452 */ 453 */
453#endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */ 454#endif /* ndef CONFIG_SECURITY_FILE_CAPABILITIES */
454 if (current->uid) 455 if (current->uid)
@@ -457,14 +458,25 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
457 old_cap = cap_set_effective(current->cap_permitted); 458 old_cap = cap_set_effective(current->cap_permitted);
458 } 459 }
459 460
460 res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); 461 res = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
461 if (res) 462 if (res)
462 goto out; 463 goto out;
463 464
464 res = vfs_permission(&nd, mode); 465 inode = path.dentry->d_inode;
466
467 if ((mode & MAY_EXEC) && S_ISREG(inode->i_mode)) {
468 /*
469 * MAY_EXEC on regular files is denied if the fs is mounted
470 * with the "noexec" flag.
471 */
472 res = -EACCES;
473 if (path.mnt->mnt_flags & MNT_NOEXEC)
474 goto out_path_release;
475 }
476
477 res = inode_permission(inode, mode | MAY_ACCESS);
465 /* SuS v2 requires we report a read only fs too */ 478 /* SuS v2 requires we report a read only fs too */
466 if(res || !(mode & S_IWOTH) || 479 if (res || !(mode & S_IWOTH) || special_file(inode->i_mode))
467 special_file(nd.path.dentry->d_inode->i_mode))
468 goto out_path_release; 480 goto out_path_release;
469 /* 481 /*
470 * This is a rare case where using __mnt_is_readonly() 482 * This is a rare case where using __mnt_is_readonly()
@@ -476,11 +488,11 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
476 * inherently racy and know that the fs may change 488 * inherently racy and know that the fs may change
477 * state before we even see this result. 489 * state before we even see this result.
478 */ 490 */
479 if (__mnt_is_readonly(nd.path.mnt)) 491 if (__mnt_is_readonly(path.mnt))
480 res = -EROFS; 492 res = -EROFS;
481 493
482out_path_release: 494out_path_release:
483 path_put(&nd.path); 495 path_put(&path);
484out: 496out:
485 current->fsuid = old_fsuid; 497 current->fsuid = old_fsuid;
486 current->fsgid = old_fsgid; 498 current->fsgid = old_fsgid;
@@ -498,22 +510,21 @@ asmlinkage long sys_access(const char __user *filename, int mode)
498 510
499asmlinkage long sys_chdir(const char __user * filename) 511asmlinkage long sys_chdir(const char __user * filename)
500{ 512{
501 struct nameidata nd; 513 struct path path;
502 int error; 514 int error;
503 515
504 error = __user_walk(filename, 516 error = user_path_dir(filename, &path);
505 LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
506 if (error) 517 if (error)
507 goto out; 518 goto out;
508 519
509 error = vfs_permission(&nd, MAY_EXEC); 520 error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
510 if (error) 521 if (error)
511 goto dput_and_out; 522 goto dput_and_out;
512 523
513 set_fs_pwd(current->fs, &nd.path); 524 set_fs_pwd(current->fs, &path);
514 525
515dput_and_out: 526dput_and_out:
516 path_put(&nd.path); 527 path_put(&path);
517out: 528out:
518 return error; 529 return error;
519} 530}
@@ -535,7 +546,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
535 if (!S_ISDIR(inode->i_mode)) 546 if (!S_ISDIR(inode->i_mode))
536 goto out_putf; 547 goto out_putf;
537 548
538 error = file_permission(file, MAY_EXEC); 549 error = inode_permission(inode, MAY_EXEC | MAY_ACCESS);
539 if (!error) 550 if (!error)
540 set_fs_pwd(current->fs, &file->f_path); 551 set_fs_pwd(current->fs, &file->f_path);
541out_putf: 552out_putf:
@@ -546,14 +557,14 @@ out:
546 557
547asmlinkage long sys_chroot(const char __user * filename) 558asmlinkage long sys_chroot(const char __user * filename)
548{ 559{
549 struct nameidata nd; 560 struct path path;
550 int error; 561 int error;
551 562
552 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd); 563 error = user_path_dir(filename, &path);
553 if (error) 564 if (error)
554 goto out; 565 goto out;
555 566
556 error = vfs_permission(&nd, MAY_EXEC); 567 error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
557 if (error) 568 if (error)
558 goto dput_and_out; 569 goto dput_and_out;
559 570
@@ -561,11 +572,10 @@ asmlinkage long sys_chroot(const char __user * filename)
561 if (!capable(CAP_SYS_CHROOT)) 572 if (!capable(CAP_SYS_CHROOT))
562 goto dput_and_out; 573 goto dput_and_out;
563 574
564 set_fs_root(current->fs, &nd.path); 575 set_fs_root(current->fs, &path);
565 set_fs_altroot();
566 error = 0; 576 error = 0;
567dput_and_out: 577dput_and_out:
568 path_put(&nd.path); 578 path_put(&path);
569out: 579out:
570 return error; 580 return error;
571} 581}
@@ -590,9 +600,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
590 err = mnt_want_write(file->f_path.mnt); 600 err = mnt_want_write(file->f_path.mnt);
591 if (err) 601 if (err)
592 goto out_putf; 602 goto out_putf;
593 err = -EPERM;
594 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
595 goto out_drop_write;
596 mutex_lock(&inode->i_mutex); 603 mutex_lock(&inode->i_mutex);
597 if (mode == (mode_t) -1) 604 if (mode == (mode_t) -1)
598 mode = inode->i_mode; 605 mode = inode->i_mode;
@@ -600,8 +607,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
600 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 607 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
601 err = notify_change(dentry, &newattrs); 608 err = notify_change(dentry, &newattrs);
602 mutex_unlock(&inode->i_mutex); 609 mutex_unlock(&inode->i_mutex);
603
604out_drop_write:
605 mnt_drop_write(file->f_path.mnt); 610 mnt_drop_write(file->f_path.mnt);
606out_putf: 611out_putf:
607 fput(file); 612 fput(file);
@@ -612,36 +617,29 @@ out:
612asmlinkage long sys_fchmodat(int dfd, const char __user *filename, 617asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
613 mode_t mode) 618 mode_t mode)
614{ 619{
615 struct nameidata nd; 620 struct path path;
616 struct inode * inode; 621 struct inode *inode;
617 int error; 622 int error;
618 struct iattr newattrs; 623 struct iattr newattrs;
619 624
620 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); 625 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
621 if (error) 626 if (error)
622 goto out; 627 goto out;
623 inode = nd.path.dentry->d_inode; 628 inode = path.dentry->d_inode;
624 629
625 error = mnt_want_write(nd.path.mnt); 630 error = mnt_want_write(path.mnt);
626 if (error) 631 if (error)
627 goto dput_and_out; 632 goto dput_and_out;
628
629 error = -EPERM;
630 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
631 goto out_drop_write;
632
633 mutex_lock(&inode->i_mutex); 633 mutex_lock(&inode->i_mutex);
634 if (mode == (mode_t) -1) 634 if (mode == (mode_t) -1)
635 mode = inode->i_mode; 635 mode = inode->i_mode;
636 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 636 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
637 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 637 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
638 error = notify_change(nd.path.dentry, &newattrs); 638 error = notify_change(path.dentry, &newattrs);
639 mutex_unlock(&inode->i_mutex); 639 mutex_unlock(&inode->i_mutex);
640 640 mnt_drop_write(path.mnt);
641out_drop_write:
642 mnt_drop_write(nd.path.mnt);
643dput_and_out: 641dput_and_out:
644 path_put(&nd.path); 642 path_put(&path);
645out: 643out:
646 return error; 644 return error;
647} 645}
@@ -653,18 +651,10 @@ asmlinkage long sys_chmod(const char __user *filename, mode_t mode)
653 651
654static int chown_common(struct dentry * dentry, uid_t user, gid_t group) 652static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
655{ 653{
656 struct inode * inode; 654 struct inode *inode = dentry->d_inode;
657 int error; 655 int error;
658 struct iattr newattrs; 656 struct iattr newattrs;
659 657
660 error = -ENOENT;
661 if (!(inode = dentry->d_inode)) {
662 printk(KERN_ERR "chown_common: NULL inode\n");
663 goto out;
664 }
665 error = -EPERM;
666 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
667 goto out;
668 newattrs.ia_valid = ATTR_CTIME; 658 newattrs.ia_valid = ATTR_CTIME;
669 if (user != (uid_t) -1) { 659 if (user != (uid_t) -1) {
670 newattrs.ia_valid |= ATTR_UID; 660 newattrs.ia_valid |= ATTR_UID;
@@ -680,25 +670,25 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
680 mutex_lock(&inode->i_mutex); 670 mutex_lock(&inode->i_mutex);
681 error = notify_change(dentry, &newattrs); 671 error = notify_change(dentry, &newattrs);
682 mutex_unlock(&inode->i_mutex); 672 mutex_unlock(&inode->i_mutex);
683out: 673
684 return error; 674 return error;
685} 675}
686 676
687asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) 677asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
688{ 678{
689 struct nameidata nd; 679 struct path path;
690 int error; 680 int error;
691 681
692 error = user_path_walk(filename, &nd); 682 error = user_path(filename, &path);
693 if (error) 683 if (error)
694 goto out; 684 goto out;
695 error = mnt_want_write(nd.path.mnt); 685 error = mnt_want_write(path.mnt);
696 if (error) 686 if (error)
697 goto out_release; 687 goto out_release;
698 error = chown_common(nd.path.dentry, user, group); 688 error = chown_common(path.dentry, user, group);
699 mnt_drop_write(nd.path.mnt); 689 mnt_drop_write(path.mnt);
700out_release: 690out_release:
701 path_put(&nd.path); 691 path_put(&path);
702out: 692out:
703 return error; 693 return error;
704} 694}
@@ -706,7 +696,7 @@ out:
706asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, 696asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
707 gid_t group, int flag) 697 gid_t group, int flag)
708{ 698{
709 struct nameidata nd; 699 struct path path;
710 int error = -EINVAL; 700 int error = -EINVAL;
711 int follow; 701 int follow;
712 702
@@ -714,35 +704,35 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
714 goto out; 704 goto out;
715 705
716 follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; 706 follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
717 error = __user_walk_fd(dfd, filename, follow, &nd); 707 error = user_path_at(dfd, filename, follow, &path);
718 if (error) 708 if (error)
719 goto out; 709 goto out;
720 error = mnt_want_write(nd.path.mnt); 710 error = mnt_want_write(path.mnt);
721 if (error) 711 if (error)
722 goto out_release; 712 goto out_release;
723 error = chown_common(nd.path.dentry, user, group); 713 error = chown_common(path.dentry, user, group);
724 mnt_drop_write(nd.path.mnt); 714 mnt_drop_write(path.mnt);
725out_release: 715out_release:
726 path_put(&nd.path); 716 path_put(&path);
727out: 717out:
728 return error; 718 return error;
729} 719}
730 720
731asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group) 721asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group)
732{ 722{
733 struct nameidata nd; 723 struct path path;
734 int error; 724 int error;
735 725
736 error = user_path_walk_link(filename, &nd); 726 error = user_lpath(filename, &path);
737 if (error) 727 if (error)
738 goto out; 728 goto out;
739 error = mnt_want_write(nd.path.mnt); 729 error = mnt_want_write(path.mnt);
740 if (error) 730 if (error)
741 goto out_release; 731 goto out_release;
742 error = chown_common(nd.path.dentry, user, group); 732 error = chown_common(path.dentry, user, group);
743 mnt_drop_write(nd.path.mnt); 733 mnt_drop_write(path.mnt);
744out_release: 734out_release:
745 path_put(&nd.path); 735 path_put(&path);
746out: 736out:
747 return error; 737 return error;
748} 738}
@@ -982,7 +972,6 @@ int get_unused_fd_flags(int flags)
982 int fd, error; 972 int fd, error;
983 struct fdtable *fdt; 973 struct fdtable *fdt;
984 974
985 error = -EMFILE;
986 spin_lock(&files->file_lock); 975 spin_lock(&files->file_lock);
987 976
988repeat: 977repeat:
@@ -990,13 +979,6 @@ repeat:
990 fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, 979 fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds,
991 files->next_fd); 980 files->next_fd);
992 981
993 /*
994 * N.B. For clone tasks sharing a files structure, this test
995 * will limit the total number of files that can be opened.
996 */
997 if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
998 goto out;
999
1000 /* Do we need to expand the fd array or fd set? */ 982 /* Do we need to expand the fd array or fd set? */
1001 error = expand_files(files, fd); 983 error = expand_files(files, fd);
1002 if (error < 0) 984 if (error < 0)
@@ -1007,7 +989,6 @@ repeat:
1007 * If we needed to expand the fs array we 989 * If we needed to expand the fs array we
1008 * might have blocked - try again. 990 * might have blocked - try again.
1009 */ 991 */
1010 error = -EMFILE;
1011 goto repeat; 992 goto repeat;
1012 } 993 }
1013 994
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index d17b4fd204e1..9f5b054f06b9 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -430,7 +430,7 @@ static struct file_system_type openprom_fs_type = {
430 .kill_sb = kill_anon_super, 430 .kill_sb = kill_anon_super,
431}; 431};
432 432
433static void op_inode_init_once(struct kmem_cache * cachep, void *data) 433static void op_inode_init_once(void *data)
434{ 434{
435 struct op_inode_info *oi = (struct op_inode_info *) data; 435 struct op_inode_info *oi = (struct op_inode_info *) data;
436 436
diff --git a/fs/pipe.c b/fs/pipe.c
index 10c4e9aa5c49..fcba6542b8d0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -777,45 +777,10 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
777/* 777/*
778 * The file_operations structs are not static because they 778 * The file_operations structs are not static because they
779 * are also used in linux/fs/fifo.c to do operations on FIFOs. 779 * are also used in linux/fs/fifo.c to do operations on FIFOs.
780 *
781 * Pipes reuse fifos' file_operations structs.
780 */ 782 */
781const struct file_operations read_fifo_fops = { 783const struct file_operations read_pipefifo_fops = {
782 .llseek = no_llseek,
783 .read = do_sync_read,
784 .aio_read = pipe_read,
785 .write = bad_pipe_w,
786 .poll = pipe_poll,
787 .unlocked_ioctl = pipe_ioctl,
788 .open = pipe_read_open,
789 .release = pipe_read_release,
790 .fasync = pipe_read_fasync,
791};
792
793const struct file_operations write_fifo_fops = {
794 .llseek = no_llseek,
795 .read = bad_pipe_r,
796 .write = do_sync_write,
797 .aio_write = pipe_write,
798 .poll = pipe_poll,
799 .unlocked_ioctl = pipe_ioctl,
800 .open = pipe_write_open,
801 .release = pipe_write_release,
802 .fasync = pipe_write_fasync,
803};
804
805const struct file_operations rdwr_fifo_fops = {
806 .llseek = no_llseek,
807 .read = do_sync_read,
808 .aio_read = pipe_read,
809 .write = do_sync_write,
810 .aio_write = pipe_write,
811 .poll = pipe_poll,
812 .unlocked_ioctl = pipe_ioctl,
813 .open = pipe_rdwr_open,
814 .release = pipe_rdwr_release,
815 .fasync = pipe_rdwr_fasync,
816};
817
818static const struct file_operations read_pipe_fops = {
819 .llseek = no_llseek, 784 .llseek = no_llseek,
820 .read = do_sync_read, 785 .read = do_sync_read,
821 .aio_read = pipe_read, 786 .aio_read = pipe_read,
@@ -827,7 +792,7 @@ static const struct file_operations read_pipe_fops = {
827 .fasync = pipe_read_fasync, 792 .fasync = pipe_read_fasync,
828}; 793};
829 794
830static const struct file_operations write_pipe_fops = { 795const struct file_operations write_pipefifo_fops = {
831 .llseek = no_llseek, 796 .llseek = no_llseek,
832 .read = bad_pipe_r, 797 .read = bad_pipe_r,
833 .write = do_sync_write, 798 .write = do_sync_write,
@@ -839,7 +804,7 @@ static const struct file_operations write_pipe_fops = {
839 .fasync = pipe_write_fasync, 804 .fasync = pipe_write_fasync,
840}; 805};
841 806
842static const struct file_operations rdwr_pipe_fops = { 807const struct file_operations rdwr_pipefifo_fops = {
843 .llseek = no_llseek, 808 .llseek = no_llseek,
844 .read = do_sync_read, 809 .read = do_sync_read,
845 .aio_read = pipe_read, 810 .aio_read = pipe_read,
@@ -927,7 +892,7 @@ static struct inode * get_pipe_inode(void)
927 inode->i_pipe = pipe; 892 inode->i_pipe = pipe;
928 893
929 pipe->readers = pipe->writers = 1; 894 pipe->readers = pipe->writers = 1;
930 inode->i_fop = &rdwr_pipe_fops; 895 inode->i_fop = &rdwr_pipefifo_fops;
931 896
932 /* 897 /*
933 * Mark the inode dirty from the very beginning, 898 * Mark the inode dirty from the very beginning,
@@ -978,7 +943,7 @@ struct file *create_write_pipe(int flags)
978 d_instantiate(dentry, inode); 943 d_instantiate(dentry, inode);
979 944
980 err = -ENFILE; 945 err = -ENFILE;
981 f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipe_fops); 946 f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops);
982 if (!f) 947 if (!f)
983 goto err_dentry; 948 goto err_dentry;
984 f->f_mapping = inode->i_mapping; 949 f->f_mapping = inode->i_mapping;
@@ -1020,7 +985,7 @@ struct file *create_read_pipe(struct file *wrf, int flags)
1020 985
1021 f->f_pos = 0; 986 f->f_pos = 0;
1022 f->f_flags = O_RDONLY | (flags & O_NONBLOCK); 987 f->f_flags = O_RDONLY | (flags & O_NONBLOCK);
1023 f->f_op = &read_pipe_fops; 988 f->f_op = &read_pipefifo_fops;
1024 f->f_mode = FMODE_READ; 989 f->f_mode = FMODE_READ;
1025 f->f_version = 0; 990 f->f_version = 0;
1026 991
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 797d775e0354..0d6eb33597c6 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -80,6 +80,7 @@
80#include <linux/delayacct.h> 80#include <linux/delayacct.h>
81#include <linux/seq_file.h> 81#include <linux/seq_file.h>
82#include <linux/pid_namespace.h> 82#include <linux/pid_namespace.h>
83#include <linux/tracehook.h>
83 84
84#include <asm/pgtable.h> 85#include <asm/pgtable.h>
85#include <asm/processor.h> 86#include <asm/processor.h>
@@ -168,8 +169,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
168 rcu_read_lock(); 169 rcu_read_lock();
169 ppid = pid_alive(p) ? 170 ppid = pid_alive(p) ?
170 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; 171 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
171 tpid = pid_alive(p) && p->ptrace ? 172 tpid = 0;
172 task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; 173 if (pid_alive(p)) {
174 struct task_struct *tracer = tracehook_tracer_task(p);
175 if (tracer)
176 tpid = task_pid_nr_ns(tracer, ns);
177 }
173 seq_printf(m, 178 seq_printf(m,
174 "State:\t%s\n" 179 "State:\t%s\n"
175 "Tgid:\t%d\n" 180 "Tgid:\t%d\n"
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a891fe4cb43b..01ed610f9b87 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -53,6 +53,7 @@
53#include <linux/time.h> 53#include <linux/time.h>
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/stat.h> 55#include <linux/stat.h>
56#include <linux/task_io_accounting_ops.h>
56#include <linux/init.h> 57#include <linux/init.h>
57#include <linux/capability.h> 58#include <linux/capability.h>
58#include <linux/file.h> 59#include <linux/file.h>
@@ -69,6 +70,7 @@
69#include <linux/mount.h> 70#include <linux/mount.h>
70#include <linux/security.h> 71#include <linux/security.h>
71#include <linux/ptrace.h> 72#include <linux/ptrace.h>
73#include <linux/tracehook.h>
72#include <linux/cgroup.h> 74#include <linux/cgroup.h>
73#include <linux/cpuset.h> 75#include <linux/cpuset.h>
74#include <linux/audit.h> 76#include <linux/audit.h>
@@ -231,10 +233,14 @@ static int check_mem_permission(struct task_struct *task)
231 * If current is actively ptrace'ing, and would also be 233 * If current is actively ptrace'ing, and would also be
232 * permitted to freshly attach with ptrace now, permit it. 234 * permitted to freshly attach with ptrace now, permit it.
233 */ 235 */
234 if (task->parent == current && (task->ptrace & PT_PTRACED) && 236 if (task_is_stopped_or_traced(task)) {
235 task_is_stopped_or_traced(task) && 237 int match;
236 ptrace_may_access(task, PTRACE_MODE_ATTACH)) 238 rcu_read_lock();
237 return 0; 239 match = (tracehook_tracer_task(task) == current);
240 rcu_read_unlock();
241 if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))
242 return 0;
243 }
238 244
239 /* 245 /*
240 * Noone else is allowed. 246 * Noone else is allowed.
@@ -504,6 +510,26 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
504 return count; 510 return count;
505} 511}
506 512
513#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
514static int proc_pid_syscall(struct task_struct *task, char *buffer)
515{
516 long nr;
517 unsigned long args[6], sp, pc;
518
519 if (task_current_syscall(task, &nr, args, 6, &sp, &pc))
520 return sprintf(buffer, "running\n");
521
522 if (nr < 0)
523 return sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc);
524
525 return sprintf(buffer,
526 "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
527 nr,
528 args[0], args[1], args[2], args[3], args[4], args[5],
529 sp, pc);
530}
531#endif /* CONFIG_HAVE_ARCH_TRACEHOOK */
532
507/************************************************************************/ 533/************************************************************************/
508/* Here the fs part begins */ 534/* Here the fs part begins */
509/************************************************************************/ 535/************************************************************************/
@@ -1834,8 +1860,7 @@ static const struct file_operations proc_fd_operations = {
1834 * /proc/pid/fd needs a special permission handler so that a process can still 1860 * /proc/pid/fd needs a special permission handler so that a process can still
1835 * access /proc/self/fd after it has executed a setuid(). 1861 * access /proc/self/fd after it has executed a setuid().
1836 */ 1862 */
1837static int proc_fd_permission(struct inode *inode, int mask, 1863static int proc_fd_permission(struct inode *inode, int mask)
1838 struct nameidata *nd)
1839{ 1864{
1840 int rv; 1865 int rv;
1841 1866
@@ -2378,53 +2403,18 @@ static int proc_base_fill_cache(struct file *filp, void *dirent,
2378#ifdef CONFIG_TASK_IO_ACCOUNTING 2403#ifdef CONFIG_TASK_IO_ACCOUNTING
2379static int do_io_accounting(struct task_struct *task, char *buffer, int whole) 2404static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2380{ 2405{
2381 u64 rchar, wchar, syscr, syscw; 2406 struct task_io_accounting acct = task->ioac;
2382 struct task_io_accounting ioac; 2407 unsigned long flags;
2383
2384 if (!whole) {
2385 rchar = task->rchar;
2386 wchar = task->wchar;
2387 syscr = task->syscr;
2388 syscw = task->syscw;
2389 memcpy(&ioac, &task->ioac, sizeof(ioac));
2390 } else {
2391 unsigned long flags;
2392 struct task_struct *t = task;
2393 rchar = wchar = syscr = syscw = 0;
2394 memset(&ioac, 0, sizeof(ioac));
2395
2396 rcu_read_lock();
2397 do {
2398 rchar += t->rchar;
2399 wchar += t->wchar;
2400 syscr += t->syscr;
2401 syscw += t->syscw;
2402
2403 ioac.read_bytes += t->ioac.read_bytes;
2404 ioac.write_bytes += t->ioac.write_bytes;
2405 ioac.cancelled_write_bytes +=
2406 t->ioac.cancelled_write_bytes;
2407 t = next_thread(t);
2408 } while (t != task);
2409 rcu_read_unlock();
2410
2411 if (lock_task_sighand(task, &flags)) {
2412 struct signal_struct *sig = task->signal;
2413 2408
2414 rchar += sig->rchar; 2409 if (whole && lock_task_sighand(task, &flags)) {
2415 wchar += sig->wchar; 2410 struct task_struct *t = task;
2416 syscr += sig->syscr;
2417 syscw += sig->syscw;
2418 2411
2419 ioac.read_bytes += sig->ioac.read_bytes; 2412 task_io_accounting_add(&acct, &task->signal->ioac);
2420 ioac.write_bytes += sig->ioac.write_bytes; 2413 while_each_thread(task, t)
2421 ioac.cancelled_write_bytes += 2414 task_io_accounting_add(&acct, &t->ioac);
2422 sig->ioac.cancelled_write_bytes;
2423 2415
2424 unlock_task_sighand(task, &flags); 2416 unlock_task_sighand(task, &flags);
2425 }
2426 } 2417 }
2427
2428 return sprintf(buffer, 2418 return sprintf(buffer,
2429 "rchar: %llu\n" 2419 "rchar: %llu\n"
2430 "wchar: %llu\n" 2420 "wchar: %llu\n"
@@ -2433,13 +2423,10 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2433 "read_bytes: %llu\n" 2423 "read_bytes: %llu\n"
2434 "write_bytes: %llu\n" 2424 "write_bytes: %llu\n"
2435 "cancelled_write_bytes: %llu\n", 2425 "cancelled_write_bytes: %llu\n",
2436 (unsigned long long)rchar, 2426 acct.rchar, acct.wchar,
2437 (unsigned long long)wchar, 2427 acct.syscr, acct.syscw,
2438 (unsigned long long)syscr, 2428 acct.read_bytes, acct.write_bytes,
2439 (unsigned long long)syscw, 2429 acct.cancelled_write_bytes);
2440 (unsigned long long)ioac.read_bytes,
2441 (unsigned long long)ioac.write_bytes,
2442 (unsigned long long)ioac.cancelled_write_bytes);
2443} 2430}
2444 2431
2445static int proc_tid_io_accounting(struct task_struct *task, char *buffer) 2432static int proc_tid_io_accounting(struct task_struct *task, char *buffer)
@@ -2473,6 +2460,9 @@ static const struct pid_entry tgid_base_stuff[] = {
2473#ifdef CONFIG_SCHED_DEBUG 2460#ifdef CONFIG_SCHED_DEBUG
2474 REG("sched", S_IRUGO|S_IWUSR, pid_sched), 2461 REG("sched", S_IRUGO|S_IWUSR, pid_sched),
2475#endif 2462#endif
2463#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
2464 INF("syscall", S_IRUSR, pid_syscall),
2465#endif
2476 INF("cmdline", S_IRUGO, pid_cmdline), 2466 INF("cmdline", S_IRUGO, pid_cmdline),
2477 ONE("stat", S_IRUGO, tgid_stat), 2467 ONE("stat", S_IRUGO, tgid_stat),
2478 ONE("statm", S_IRUGO, pid_statm), 2468 ONE("statm", S_IRUGO, pid_statm),
@@ -2805,6 +2795,9 @@ static const struct pid_entry tid_base_stuff[] = {
2805#ifdef CONFIG_SCHED_DEBUG 2795#ifdef CONFIG_SCHED_DEBUG
2806 REG("sched", S_IRUGO|S_IWUSR, pid_sched), 2796 REG("sched", S_IRUGO|S_IWUSR, pid_sched),
2807#endif 2797#endif
2798#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
2799 INF("syscall", S_IRUSR, pid_syscall),
2800#endif
2808 INF("cmdline", S_IRUGO, pid_cmdline), 2801 INF("cmdline", S_IRUGO, pid_cmdline),
2809 ONE("stat", S_IRUGO, tid_stat), 2802 ONE("stat", S_IRUGO, tid_stat),
2810 ONE("statm", S_IRUGO, pid_statm), 2803 ONE("statm", S_IRUGO, pid_statm),
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bc0a0dd2d844..cb4096cc3fb7 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -806,12 +806,9 @@ continue_removing:
806 if (S_ISDIR(de->mode)) 806 if (S_ISDIR(de->mode))
807 parent->nlink--; 807 parent->nlink--;
808 de->nlink = 0; 808 de->nlink = 0;
809 if (de->subdir) { 809 WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory "
810 printk(KERN_WARNING "%s: removing non-empty directory "
811 "'%s/%s', leaking at least '%s'\n", __func__, 810 "'%s/%s', leaking at least '%s'\n", __func__,
812 de->parent->name, de->name, de->subdir->name); 811 de->parent->name, de->name, de->subdir->name);
813 WARN_ON(1);
814 }
815 if (atomic_dec_and_test(&de->count)) 812 if (atomic_dec_and_test(&de->count))
816 free_proc_entry(de); 813 free_proc_entry(de);
817} 814}
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 02eca2ed9dd7..8bb03f056c28 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <linux/sysctl.h>
20 21
21#include <asm/system.h> 22#include <asm/system.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
@@ -65,6 +66,8 @@ static void proc_delete_inode(struct inode *inode)
65 module_put(de->owner); 66 module_put(de->owner);
66 de_put(de); 67 de_put(de);
67 } 68 }
69 if (PROC_I(inode)->sysctl)
70 sysctl_head_put(PROC_I(inode)->sysctl);
68 clear_inode(inode); 71 clear_inode(inode);
69} 72}
70 73
@@ -84,6 +87,8 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
84 ei->fd = 0; 87 ei->fd = 0;
85 ei->op.proc_get_link = NULL; 88 ei->op.proc_get_link = NULL;
86 ei->pde = NULL; 89 ei->pde = NULL;
90 ei->sysctl = NULL;
91 ei->sysctl_entry = NULL;
87 inode = &ei->vfs_inode; 92 inode = &ei->vfs_inode;
88 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 93 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
89 return inode; 94 return inode;
@@ -94,7 +99,7 @@ static void proc_destroy_inode(struct inode *inode)
94 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 99 kmem_cache_free(proc_inode_cachep, PROC_I(inode));
95} 100}
96 101
97static void init_once(struct kmem_cache * cachep, void *foo) 102static void init_once(void *foo)
98{ 103{
99 struct proc_inode *ei = (struct proc_inode *) foo; 104 struct proc_inode *ei = (struct proc_inode *) foo;
100 105
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 5acc001d49f6..f9a8b892718f 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -10,149 +10,110 @@
10static struct dentry_operations proc_sys_dentry_operations; 10static struct dentry_operations proc_sys_dentry_operations;
11static const struct file_operations proc_sys_file_operations; 11static const struct file_operations proc_sys_file_operations;
12static const struct inode_operations proc_sys_inode_operations; 12static const struct inode_operations proc_sys_inode_operations;
13static const struct file_operations proc_sys_dir_file_operations;
14static const struct inode_operations proc_sys_dir_operations;
13 15
14static void proc_sys_refresh_inode(struct inode *inode, struct ctl_table *table) 16static struct inode *proc_sys_make_inode(struct super_block *sb,
15{ 17 struct ctl_table_header *head, struct ctl_table *table)
16 /* Refresh the cached information bits in the inode */
17 if (table) {
18 inode->i_uid = 0;
19 inode->i_gid = 0;
20 inode->i_mode = table->mode;
21 if (table->proc_handler) {
22 inode->i_mode |= S_IFREG;
23 inode->i_nlink = 1;
24 } else {
25 inode->i_mode |= S_IFDIR;
26 inode->i_nlink = 0; /* It is too hard to figure out */
27 }
28 }
29}
30
31static struct inode *proc_sys_make_inode(struct inode *dir, struct ctl_table *table)
32{ 18{
33 struct inode *inode; 19 struct inode *inode;
34 struct proc_inode *dir_ei, *ei; 20 struct proc_inode *ei;
35 int depth;
36 21
37 inode = new_inode(dir->i_sb); 22 inode = new_inode(sb);
38 if (!inode) 23 if (!inode)
39 goto out; 24 goto out;
40 25
41 /* A directory is always one deeper than it's parent */ 26 sysctl_head_get(head);
42 dir_ei = PROC_I(dir);
43 depth = dir_ei->fd + 1;
44
45 ei = PROC_I(inode); 27 ei = PROC_I(inode);
46 ei->fd = depth; 28 ei->sysctl = head;
29 ei->sysctl_entry = table;
30
47 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 31 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
48 inode->i_op = &proc_sys_inode_operations;
49 inode->i_fop = &proc_sys_file_operations;
50 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ 32 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */
51 proc_sys_refresh_inode(inode, table); 33 inode->i_mode = table->mode;
34 if (!table->child) {
35 inode->i_mode |= S_IFREG;
36 inode->i_op = &proc_sys_inode_operations;
37 inode->i_fop = &proc_sys_file_operations;
38 } else {
39 inode->i_mode |= S_IFDIR;
40 inode->i_nlink = 0;
41 inode->i_op = &proc_sys_dir_operations;
42 inode->i_fop = &proc_sys_dir_file_operations;
43 }
52out: 44out:
53 return inode; 45 return inode;
54} 46}
55 47
56static struct dentry *proc_sys_ancestor(struct dentry *dentry, int depth) 48static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
57{
58 for (;;) {
59 struct proc_inode *ei;
60
61 ei = PROC_I(dentry->d_inode);
62 if (ei->fd == depth)
63 break; /* found */
64
65 dentry = dentry->d_parent;
66 }
67 return dentry;
68}
69
70static struct ctl_table *proc_sys_lookup_table_one(struct ctl_table *table,
71 struct qstr *name)
72{ 49{
73 int len; 50 int len;
74 for ( ; table->ctl_name || table->procname; table++) { 51 for ( ; p->ctl_name || p->procname; p++) {
75 52
76 if (!table->procname) 53 if (!p->procname)
77 continue; 54 continue;
78 55
79 len = strlen(table->procname); 56 len = strlen(p->procname);
80 if (len != name->len) 57 if (len != name->len)
81 continue; 58 continue;
82 59
83 if (memcmp(table->procname, name->name, len) != 0) 60 if (memcmp(p->procname, name->name, len) != 0)
84 continue; 61 continue;
85 62
86 /* I have a match */ 63 /* I have a match */
87 return table; 64 return p;
88 } 65 }
89 return NULL; 66 return NULL;
90} 67}
91 68
92static struct ctl_table *proc_sys_lookup_table(struct dentry *dentry, 69struct ctl_table_header *grab_header(struct inode *inode)
93 struct ctl_table *table)
94{ 70{
95 struct dentry *ancestor; 71 if (PROC_I(inode)->sysctl)
96 struct proc_inode *ei; 72 return sysctl_head_grab(PROC_I(inode)->sysctl);
97 int depth, i; 73 else
74 return sysctl_head_next(NULL);
75}
98 76
99 ei = PROC_I(dentry->d_inode); 77static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
100 depth = ei->fd; 78 struct nameidata *nd)
79{
80 struct ctl_table_header *head = grab_header(dir);
81 struct ctl_table *table = PROC_I(dir)->sysctl_entry;
82 struct ctl_table_header *h = NULL;
83 struct qstr *name = &dentry->d_name;
84 struct ctl_table *p;
85 struct inode *inode;
86 struct dentry *err = ERR_PTR(-ENOENT);
101 87
102 if (depth == 0) 88 if (IS_ERR(head))
103 return table; 89 return ERR_CAST(head);
104 90
105 for (i = 1; table && (i <= depth); i++) { 91 if (table && !table->child) {
106 ancestor = proc_sys_ancestor(dentry, i); 92 WARN_ON(1);
107 table = proc_sys_lookup_table_one(table, &ancestor->d_name); 93 goto out;
108 if (table)
109 table = table->child;
110 } 94 }
111 return table;
112
113}
114static struct ctl_table *proc_sys_lookup_entry(struct dentry *dparent,
115 struct qstr *name,
116 struct ctl_table *table)
117{
118 table = proc_sys_lookup_table(dparent, table);
119 if (table)
120 table = proc_sys_lookup_table_one(table, name);
121 return table;
122}
123 95
124static struct ctl_table *do_proc_sys_lookup(struct dentry *parent, 96 table = table ? table->child : head->ctl_table;
125 struct qstr *name,
126 struct ctl_table_header **ptr)
127{
128 struct ctl_table_header *head;
129 struct ctl_table *table = NULL;
130 97
131 for (head = sysctl_head_next(NULL); head; 98 p = find_in_table(table, name);
132 head = sysctl_head_next(head)) { 99 if (!p) {
133 table = proc_sys_lookup_entry(parent, name, head->ctl_table); 100 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
134 if (table) 101 if (h->attached_to != table)
135 break; 102 continue;
103 p = find_in_table(h->attached_by, name);
104 if (p)
105 break;
106 }
136 } 107 }
137 *ptr = head;
138 return table;
139}
140
141static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
142 struct nameidata *nd)
143{
144 struct ctl_table_header *head;
145 struct inode *inode;
146 struct dentry *err;
147 struct ctl_table *table;
148 108
149 err = ERR_PTR(-ENOENT); 109 if (!p)
150 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head);
151 if (!table)
152 goto out; 110 goto out;
153 111
154 err = ERR_PTR(-ENOMEM); 112 err = ERR_PTR(-ENOMEM);
155 inode = proc_sys_make_inode(dir, table); 113 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
114 if (h)
115 sysctl_head_finish(h);
116
156 if (!inode) 117 if (!inode)
157 goto out; 118 goto out;
158 119
@@ -168,22 +129,14 @@ out:
168static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, 129static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
169 size_t count, loff_t *ppos, int write) 130 size_t count, loff_t *ppos, int write)
170{ 131{
171 struct dentry *dentry = filp->f_dentry; 132 struct inode *inode = filp->f_path.dentry->d_inode;
172 struct ctl_table_header *head; 133 struct ctl_table_header *head = grab_header(inode);
173 struct ctl_table *table; 134 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
174 ssize_t error; 135 ssize_t error;
175 size_t res; 136 size_t res;
176 137
177 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); 138 if (IS_ERR(head))
178 /* Has the sysctl entry disappeared on us? */ 139 return PTR_ERR(head);
179 error = -ENOENT;
180 if (!table)
181 goto out;
182
183 /* Has the sysctl entry been replaced by a directory? */
184 error = -EISDIR;
185 if (!table->proc_handler)
186 goto out;
187 140
188 /* 141 /*
189 * At this point we know that the sysctl was not unregistered 142 * At this point we know that the sysctl was not unregistered
@@ -193,6 +146,11 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
193 if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ)) 146 if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ))
194 goto out; 147 goto out;
195 148
149 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
150 error = -EINVAL;
151 if (!table->proc_handler)
152 goto out;
153
196 /* careful: calling conventions are nasty here */ 154 /* careful: calling conventions are nasty here */
197 res = count; 155 res = count;
198 error = table->proc_handler(table, write, filp, buf, &res, ppos); 156 error = table->proc_handler(table, write, filp, buf, &res, ppos);
@@ -218,82 +176,86 @@ static ssize_t proc_sys_write(struct file *filp, const char __user *buf,
218 176
219 177
220static int proc_sys_fill_cache(struct file *filp, void *dirent, 178static int proc_sys_fill_cache(struct file *filp, void *dirent,
221 filldir_t filldir, struct ctl_table *table) 179 filldir_t filldir,
180 struct ctl_table_header *head,
181 struct ctl_table *table)
222{ 182{
223 struct ctl_table_header *head;
224 struct ctl_table *child_table = NULL;
225 struct dentry *child, *dir = filp->f_path.dentry; 183 struct dentry *child, *dir = filp->f_path.dentry;
226 struct inode *inode; 184 struct inode *inode;
227 struct qstr qname; 185 struct qstr qname;
228 ino_t ino = 0; 186 ino_t ino = 0;
229 unsigned type = DT_UNKNOWN; 187 unsigned type = DT_UNKNOWN;
230 int ret;
231 188
232 qname.name = table->procname; 189 qname.name = table->procname;
233 qname.len = strlen(table->procname); 190 qname.len = strlen(table->procname);
234 qname.hash = full_name_hash(qname.name, qname.len); 191 qname.hash = full_name_hash(qname.name, qname.len);
235 192
236 /* Suppress duplicates.
237 * Only fill a directory entry if it is the value that
238 * an ordinary lookup of that name returns. Hide all
239 * others.
240 *
241 * If we ever cache this translation in the dcache
242 * I should do a dcache lookup first. But for now
243 * it is just simpler not to.
244 */
245 ret = 0;
246 child_table = do_proc_sys_lookup(dir, &qname, &head);
247 sysctl_head_finish(head);
248 if (child_table != table)
249 return 0;
250
251 child = d_lookup(dir, &qname); 193 child = d_lookup(dir, &qname);
252 if (!child) { 194 if (!child) {
253 struct dentry *new; 195 child = d_alloc(dir, &qname);
254 new = d_alloc(dir, &qname); 196 if (child) {
255 if (new) { 197 inode = proc_sys_make_inode(dir->d_sb, head, table);
256 inode = proc_sys_make_inode(dir->d_inode, table); 198 if (!inode) {
257 if (!inode) 199 dput(child);
258 child = ERR_PTR(-ENOMEM); 200 return -ENOMEM;
259 else { 201 } else {
260 new->d_op = &proc_sys_dentry_operations; 202 child->d_op = &proc_sys_dentry_operations;
261 d_add(new, inode); 203 d_add(child, inode);
262 } 204 }
263 if (child) 205 } else {
264 dput(new); 206 return -ENOMEM;
265 else
266 child = new;
267 } 207 }
268 } 208 }
269 if (!child || IS_ERR(child) || !child->d_inode)
270 goto end_instantiate;
271 inode = child->d_inode; 209 inode = child->d_inode;
272 if (inode) { 210 ino = inode->i_ino;
273 ino = inode->i_ino; 211 type = inode->i_mode >> 12;
274 type = inode->i_mode >> 12;
275 }
276 dput(child); 212 dput(child);
277end_instantiate: 213 return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type);
278 if (!ino) 214}
279 ino= find_inode_number(dir, &qname); 215
280 if (!ino) 216static int scan(struct ctl_table_header *head, ctl_table *table,
281 ino = 1; 217 unsigned long *pos, struct file *file,
282 return filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type); 218 void *dirent, filldir_t filldir)
219{
220
221 for (; table->ctl_name || table->procname; table++, (*pos)++) {
222 int res;
223
224 /* Can't do anything without a proc name */
225 if (!table->procname)
226 continue;
227
228 if (*pos < file->f_pos)
229 continue;
230
231 res = proc_sys_fill_cache(file, dirent, filldir, head, table);
232 if (res)
233 return res;
234
235 file->f_pos = *pos + 1;
236 }
237 return 0;
283} 238}
284 239
285static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir) 240static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)
286{ 241{
287 struct dentry *dentry = filp->f_dentry; 242 struct dentry *dentry = filp->f_path.dentry;
288 struct inode *inode = dentry->d_inode; 243 struct inode *inode = dentry->d_inode;
289 struct ctl_table_header *head = NULL; 244 struct ctl_table_header *head = grab_header(inode);
290 struct ctl_table *table; 245 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
246 struct ctl_table_header *h = NULL;
291 unsigned long pos; 247 unsigned long pos;
292 int ret; 248 int ret = -EINVAL;
249
250 if (IS_ERR(head))
251 return PTR_ERR(head);
293 252
294 ret = -ENOTDIR; 253 if (table && !table->child) {
295 if (!S_ISDIR(inode->i_mode)) 254 WARN_ON(1);
296 goto out; 255 goto out;
256 }
257
258 table = table ? table->child : head->ctl_table;
297 259
298 ret = 0; 260 ret = 0;
299 /* Avoid a switch here: arm builds fail with missing __cmpdi2 */ 261 /* Avoid a switch here: arm builds fail with missing __cmpdi2 */
@@ -311,30 +273,17 @@ static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)
311 } 273 }
312 pos = 2; 274 pos = 2;
313 275
314 /* - Find each instance of the directory 276 ret = scan(head, table, &pos, filp, dirent, filldir);
315 * - Read all entries in each instance 277 if (ret)
316 * - Before returning an entry to user space lookup the entry 278 goto out;
317 * by name and if I find a different entry don't return
318 * this one because it means it is a buried dup.
319 * For sysctl this should only happen for directory entries.
320 */
321 for (head = sysctl_head_next(NULL); head; head = sysctl_head_next(head)) {
322 table = proc_sys_lookup_table(dentry, head->ctl_table);
323 279
324 if (!table) 280 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
281 if (h->attached_to != table)
325 continue; 282 continue;
326 283 ret = scan(h, h->attached_by, &pos, filp, dirent, filldir);
327 for (; table->ctl_name || table->procname; table++, pos++) { 284 if (ret) {
328 /* Can't do anything without a proc name */ 285 sysctl_head_finish(h);
329 if (!table->procname) 286 break;
330 continue;
331
332 if (pos < filp->f_pos)
333 continue;
334
335 if (proc_sys_fill_cache(filp, dirent, filldir, table) < 0)
336 goto out;
337 filp->f_pos = pos + 1;
338 } 287 }
339 } 288 }
340 ret = 1; 289 ret = 1;
@@ -343,53 +292,24 @@ out:
343 return ret; 292 return ret;
344} 293}
345 294
346static int proc_sys_permission(struct inode *inode, int mask, struct nameidata *nd) 295static int proc_sys_permission(struct inode *inode, int mask)
347{ 296{
348 /* 297 /*
349 * sysctl entries that are not writeable, 298 * sysctl entries that are not writeable,
350 * are _NOT_ writeable, capabilities or not. 299 * are _NOT_ writeable, capabilities or not.
351 */ 300 */
352 struct ctl_table_header *head; 301 struct ctl_table_header *head = grab_header(inode);
353 struct ctl_table *table; 302 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
354 struct dentry *dentry;
355 int mode;
356 int depth;
357 int error; 303 int error;
358 304
359 head = NULL; 305 if (IS_ERR(head))
360 depth = PROC_I(inode)->fd; 306 return PTR_ERR(head);
361
362 /* First check the cached permissions, in case we don't have
363 * enough information to lookup the sysctl table entry.
364 */
365 error = -EACCES;
366 mode = inode->i_mode;
367
368 if (current->euid == 0)
369 mode >>= 6;
370 else if (in_group_p(0))
371 mode >>= 3;
372
373 if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)
374 error = 0;
375
376 /* If we can't get a sysctl table entry the permission
377 * checks on the cached mode will have to be enough.
378 */
379 if (!nd || !depth)
380 goto out;
381 307
382 dentry = nd->path.dentry; 308 if (!table) /* global root - r-xr-xr-x */
383 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); 309 error = mask & MAY_WRITE ? -EACCES : 0;
310 else /* Use the permissions on the sysctl table entry */
311 error = sysctl_perm(head->root, table, mask);
384 312
385 /* If the entry does not exist deny permission */
386 error = -EACCES;
387 if (!table)
388 goto out;
389
390 /* Use the permissions on the sysctl table entry */
391 error = sysctl_perm(head->root, table, mask);
392out:
393 sysctl_head_finish(head); 313 sysctl_head_finish(head);
394 return error; 314 return error;
395} 315}
@@ -409,33 +329,70 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
409 return error; 329 return error;
410} 330}
411 331
412/* I'm lazy and don't distinguish between files and directories, 332static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
413 * until access time. 333{
414 */ 334 struct inode *inode = dentry->d_inode;
335 struct ctl_table_header *head = grab_header(inode);
336 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
337
338 if (IS_ERR(head))
339 return PTR_ERR(head);
340
341 generic_fillattr(inode, stat);
342 if (table)
343 stat->mode = (stat->mode & S_IFMT) | table->mode;
344
345 sysctl_head_finish(head);
346 return 0;
347}
348
415static const struct file_operations proc_sys_file_operations = { 349static const struct file_operations proc_sys_file_operations = {
416 .read = proc_sys_read, 350 .read = proc_sys_read,
417 .write = proc_sys_write, 351 .write = proc_sys_write,
352};
353
354static const struct file_operations proc_sys_dir_file_operations = {
418 .readdir = proc_sys_readdir, 355 .readdir = proc_sys_readdir,
419}; 356};
420 357
421static const struct inode_operations proc_sys_inode_operations = { 358static const struct inode_operations proc_sys_inode_operations = {
359 .permission = proc_sys_permission,
360 .setattr = proc_sys_setattr,
361 .getattr = proc_sys_getattr,
362};
363
364static const struct inode_operations proc_sys_dir_operations = {
422 .lookup = proc_sys_lookup, 365 .lookup = proc_sys_lookup,
423 .permission = proc_sys_permission, 366 .permission = proc_sys_permission,
424 .setattr = proc_sys_setattr, 367 .setattr = proc_sys_setattr,
368 .getattr = proc_sys_getattr,
425}; 369};
426 370
427static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd) 371static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd)
428{ 372{
429 struct ctl_table_header *head; 373 return !PROC_I(dentry->d_inode)->sysctl->unregistering;
430 struct ctl_table *table; 374}
431 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); 375
432 proc_sys_refresh_inode(dentry->d_inode, table); 376static int proc_sys_delete(struct dentry *dentry)
433 sysctl_head_finish(head); 377{
434 return !!table; 378 return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
379}
380
381static int proc_sys_compare(struct dentry *dir, struct qstr *qstr,
382 struct qstr *name)
383{
384 struct dentry *dentry = container_of(qstr, struct dentry, d_name);
385 if (qstr->len != name->len)
386 return 1;
387 if (memcmp(qstr->name, name->name, name->len))
388 return 1;
389 return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl);
435} 390}
436 391
437static struct dentry_operations proc_sys_dentry_operations = { 392static struct dentry_operations proc_sys_dentry_operations = {
438 .d_revalidate = proc_sys_revalidate, 393 .d_revalidate = proc_sys_revalidate,
394 .d_delete = proc_sys_delete,
395 .d_compare = proc_sys_compare,
439}; 396};
440 397
441static struct proc_dir_entry *proc_sys_root; 398static struct proc_dir_entry *proc_sys_root;
@@ -443,8 +400,8 @@ static struct proc_dir_entry *proc_sys_root;
443int proc_sys_init(void) 400int proc_sys_init(void)
444{ 401{
445 proc_sys_root = proc_mkdir("sys", NULL); 402 proc_sys_root = proc_mkdir("sys", NULL);
446 proc_sys_root->proc_iops = &proc_sys_inode_operations; 403 proc_sys_root->proc_iops = &proc_sys_dir_operations;
447 proc_sys_root->proc_fops = &proc_sys_file_operations; 404 proc_sys_root->proc_fops = &proc_sys_dir_file_operations;
448 proc_sys_root->nlink = 0; 405 proc_sys_root->nlink = 0;
449 return 0; 406 return 0;
450} 407}
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index b31ab78052b3..2aad1044b84c 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -553,7 +553,7 @@ static void qnx4_destroy_inode(struct inode *inode)
553 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 553 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
554} 554}
555 555
556static void init_once(struct kmem_cache *cachep, void *foo) 556static void init_once(void *foo)
557{ 557{
558 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; 558 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
559 559
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 2ec748ba0bd3..879e54d35c2d 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -521,7 +521,7 @@ static void reiserfs_destroy_inode(struct inode *inode)
521 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 521 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
522} 522}
523 523
524static void init_once(struct kmem_cache * cachep, void *foo) 524static void init_once(void *foo)
525{ 525{
526 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 526 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
527 527
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index d7c4935c1034..bb3cb5b7cdb2 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -1250,7 +1250,7 @@ static int reiserfs_check_acl(struct inode *inode, int mask)
1250 return error; 1250 return error;
1251} 1251}
1252 1252
1253int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd) 1253int reiserfs_permission(struct inode *inode, int mask)
1254{ 1254{
1255 /* 1255 /*
1256 * We don't do permission checks on the internal objects. 1256 * We don't do permission checks on the internal objects.
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 3f13d491c7c7..8e51a2aaa977 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -577,7 +577,7 @@ static void romfs_destroy_inode(struct inode *inode)
577 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 577 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
578} 578}
579 579
580static void init_once(struct kmem_cache *cachep, void *foo) 580static void init_once(void *foo)
581{ 581{
582 struct romfs_inode_info *ei = foo; 582 struct romfs_inode_info *ei = foo;
583 583
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index 2294783320cb..e4f8d51a5553 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -408,7 +408,7 @@ smb_file_release(struct inode *inode, struct file * file)
408 * privileges, so we need our own check for this. 408 * privileges, so we need our own check for this.
409 */ 409 */
410static int 410static int
411smb_file_permission(struct inode *inode, int mask, struct nameidata *nd) 411smb_file_permission(struct inode *inode, int mask)
412{ 412{
413 int mode = inode->i_mode; 413 int mode = inode->i_mode;
414 int error = 0; 414 int error = 0;
@@ -417,7 +417,7 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
417 417
418 /* Look at user permissions */ 418 /* Look at user permissions */
419 mode >>= 6; 419 mode >>= 6;
420 if ((mode & 7 & mask) != mask) 420 if (mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC))
421 error = -EACCES; 421 error = -EACCES;
422 return error; 422 return error;
423} 423}
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 376ef3ee6ed7..3528f40ffb0f 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -67,7 +67,7 @@ static void smb_destroy_inode(struct inode *inode)
67 kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 67 kmem_cache_free(smb_inode_cachep, SMB_I(inode));
68} 68}
69 69
70static void init_once(struct kmem_cache *cachep, void *foo) 70static void init_once(void *foo)
71{ 71{
72 struct smb_inode_info *ei = (struct smb_inode_info *) foo; 72 struct smb_inode_info *ei = (struct smb_inode_info *) foo;
73 73
diff --git a/fs/splice.c b/fs/splice.c
index 399442179d89..b30311ba8af6 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -772,7 +772,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
772 ssize_t ret; 772 ssize_t ret;
773 int err; 773 int err;
774 774
775 err = remove_suid(out->f_path.dentry); 775 err = file_remove_suid(out);
776 if (unlikely(err)) 776 if (unlikely(err))
777 return err; 777 return err;
778 778
@@ -830,7 +830,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
830 ssize_t ret; 830 ssize_t ret;
831 831
832 inode_double_lock(inode, pipe->inode); 832 inode_double_lock(inode, pipe->inode);
833 ret = remove_suid(out->f_path.dentry); 833 ret = file_remove_suid(out);
834 if (likely(!ret)) 834 if (likely(!ret))
835 ret = __splice_from_pipe(pipe, &sd, pipe_to_file); 835 ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
836 inode_double_unlock(inode, pipe->inode); 836 inode_double_unlock(inode, pipe->inode);
@@ -1161,36 +1161,6 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1161} 1161}
1162 1162
1163/* 1163/*
1164 * Do a copy-from-user while holding the mmap_semaphore for reading, in a
1165 * manner safe from deadlocking with simultaneous mmap() (grabbing mmap_sem
1166 * for writing) and page faulting on the user memory pointed to by src.
1167 * This assumes that we will very rarely hit the partial != 0 path, or this
1168 * will not be a win.
1169 */
1170static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n)
1171{
1172 int partial;
1173
1174 if (!access_ok(VERIFY_READ, src, n))
1175 return -EFAULT;
1176
1177 pagefault_disable();
1178 partial = __copy_from_user_inatomic(dst, src, n);
1179 pagefault_enable();
1180
1181 /*
1182 * Didn't copy everything, drop the mmap_sem and do a faulting copy
1183 */
1184 if (unlikely(partial)) {
1185 up_read(&current->mm->mmap_sem);
1186 partial = copy_from_user(dst, src, n);
1187 down_read(&current->mm->mmap_sem);
1188 }
1189
1190 return partial;
1191}
1192
1193/*
1194 * Map an iov into an array of pages and offset/length tupples. With the 1164 * Map an iov into an array of pages and offset/length tupples. With the
1195 * partial_page structure, we can map several non-contiguous ranges into 1165 * partial_page structure, we can map several non-contiguous ranges into
1196 * our ones pages[] map instead of splitting that operation into pieces. 1166 * our ones pages[] map instead of splitting that operation into pieces.
@@ -1203,8 +1173,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1203{ 1173{
1204 int buffers = 0, error = 0; 1174 int buffers = 0, error = 0;
1205 1175
1206 down_read(&current->mm->mmap_sem);
1207
1208 while (nr_vecs) { 1176 while (nr_vecs) {
1209 unsigned long off, npages; 1177 unsigned long off, npages;
1210 struct iovec entry; 1178 struct iovec entry;
@@ -1213,7 +1181,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1213 int i; 1181 int i;
1214 1182
1215 error = -EFAULT; 1183 error = -EFAULT;
1216 if (copy_from_user_mmap_sem(&entry, iov, sizeof(entry))) 1184 if (copy_from_user(&entry, iov, sizeof(entry)))
1217 break; 1185 break;
1218 1186
1219 base = entry.iov_base; 1187 base = entry.iov_base;
@@ -1247,9 +1215,8 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1247 if (npages > PIPE_BUFFERS - buffers) 1215 if (npages > PIPE_BUFFERS - buffers)
1248 npages = PIPE_BUFFERS - buffers; 1216 npages = PIPE_BUFFERS - buffers;
1249 1217
1250 error = get_user_pages(current, current->mm, 1218 error = get_user_pages_fast((unsigned long)base, npages,
1251 (unsigned long) base, npages, 0, 0, 1219 0, &pages[buffers]);
1252 &pages[buffers], NULL);
1253 1220
1254 if (unlikely(error <= 0)) 1221 if (unlikely(error <= 0))
1255 break; 1222 break;
@@ -1288,8 +1255,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1288 iov++; 1255 iov++;
1289 } 1256 }
1290 1257
1291 up_read(&current->mm->mmap_sem);
1292
1293 if (buffers) 1258 if (buffers)
1294 return buffers; 1259 return buffers;
1295 1260
diff --git a/fs/stat.c b/fs/stat.c
index 9cf41f719d50..7c46fbeb8b76 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -57,13 +57,13 @@ EXPORT_SYMBOL(vfs_getattr);
57 57
58int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat) 58int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)
59{ 59{
60 struct nameidata nd; 60 struct path path;
61 int error; 61 int error;
62 62
63 error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd); 63 error = user_path_at(dfd, name, LOOKUP_FOLLOW, &path);
64 if (!error) { 64 if (!error) {
65 error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat); 65 error = vfs_getattr(path.mnt, path.dentry, stat);
66 path_put(&nd.path); 66 path_put(&path);
67 } 67 }
68 return error; 68 return error;
69} 69}
@@ -77,13 +77,13 @@ EXPORT_SYMBOL(vfs_stat);
77 77
78int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat) 78int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat)
79{ 79{
80 struct nameidata nd; 80 struct path path;
81 int error; 81 int error;
82 82
83 error = __user_walk_fd(dfd, name, 0, &nd); 83 error = user_path_at(dfd, name, 0, &path);
84 if (!error) { 84 if (!error) {
85 error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat); 85 error = vfs_getattr(path.mnt, path.dentry, stat);
86 path_put(&nd.path); 86 path_put(&path);
87 } 87 }
88 return error; 88 return error;
89} 89}
@@ -291,29 +291,29 @@ asmlinkage long sys_newfstat(unsigned int fd, struct stat __user *statbuf)
291 return error; 291 return error;
292} 292}
293 293
294asmlinkage long sys_readlinkat(int dfd, const char __user *path, 294asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
295 char __user *buf, int bufsiz) 295 char __user *buf, int bufsiz)
296{ 296{
297 struct nameidata nd; 297 struct path path;
298 int error; 298 int error;
299 299
300 if (bufsiz <= 0) 300 if (bufsiz <= 0)
301 return -EINVAL; 301 return -EINVAL;
302 302
303 error = __user_walk_fd(dfd, path, 0, &nd); 303 error = user_path_at(dfd, pathname, 0, &path);
304 if (!error) { 304 if (!error) {
305 struct inode *inode = nd.path.dentry->d_inode; 305 struct inode *inode = path.dentry->d_inode;
306 306
307 error = -EINVAL; 307 error = -EINVAL;
308 if (inode->i_op && inode->i_op->readlink) { 308 if (inode->i_op && inode->i_op->readlink) {
309 error = security_inode_readlink(nd.path.dentry); 309 error = security_inode_readlink(path.dentry);
310 if (!error) { 310 if (!error) {
311 touch_atime(nd.path.mnt, nd.path.dentry); 311 touch_atime(path.mnt, path.dentry);
312 error = inode->i_op->readlink(nd.path.dentry, 312 error = inode->i_op->readlink(path.dentry,
313 buf, bufsiz); 313 buf, bufsiz);
314 } 314 }
315 } 315 }
316 path_put(&nd.path); 316 path_put(&path);
317 } 317 }
318 return error; 318 return error;
319} 319}
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index c1a7efb310bf..aedaeba82ae5 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -459,11 +459,8 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
459 int ret; 459 int ret;
460 460
461 ret = __sysfs_add_one(acxt, sd); 461 ret = __sysfs_add_one(acxt, sd);
462 if (ret == -EEXIST) { 462 WARN(ret == -EEXIST, KERN_WARNING "sysfs: duplicate filename '%s' "
463 printk(KERN_WARNING "sysfs: duplicate filename '%s' "
464 "can not be created\n", sd->s_name); 463 "can not be created\n", sd->s_name);
465 WARN_ON(1);
466 }
467 return ret; 464 return ret;
468} 465}
469 466
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 3f07893ff896..c9e4e5091da1 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -337,9 +337,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
337 if (kobj->ktype && kobj->ktype->sysfs_ops) 337 if (kobj->ktype && kobj->ktype->sysfs_ops)
338 ops = kobj->ktype->sysfs_ops; 338 ops = kobj->ktype->sysfs_ops;
339 else { 339 else {
340 printk(KERN_ERR "missing sysfs attribute operations for " 340 WARN(1, KERN_ERR "missing sysfs attribute operations for "
341 "kobject: %s\n", kobject_name(kobj)); 341 "kobject: %s\n", kobject_name(kobj));
342 WARN_ON(1);
343 goto err_out; 342 goto err_out;
344 } 343 }
345 344
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index eeba38417b1d..fe611949a7f7 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -134,9 +134,8 @@ void sysfs_remove_group(struct kobject * kobj,
134 if (grp->name) { 134 if (grp->name) {
135 sd = sysfs_get_dirent(dir_sd, grp->name); 135 sd = sysfs_get_dirent(dir_sd, grp->name);
136 if (!sd) { 136 if (!sd) {
137 printk(KERN_WARNING "sysfs group %p not found for " 137 WARN(!sd, KERN_WARNING "sysfs group %p not found for "
138 "kobject '%s'\n", grp, kobject_name(kobj)); 138 "kobject '%s'\n", grp, kobject_name(kobj));
139 WARN_ON(!sd);
140 return; 139 return;
141 } 140 }
142 } else 141 } else
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index c5d60de0658f..df0d435baa48 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -326,7 +326,7 @@ static void sysv_destroy_inode(struct inode *inode)
326 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 326 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
327} 327}
328 328
329static void init_once(struct kmem_cache *cachep, void *p) 329static void init_once(void *p)
330{ 330{
331 struct sysv_inode_info *si = (struct sysv_inode_info *)p; 331 struct sysv_inode_info *si = (struct sysv_inode_info *)p;
332 332
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 005a3b854d96..8565e586e533 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -53,6 +53,7 @@
53 53
54#include "ubifs.h" 54#include "ubifs.h"
55#include <linux/mount.h> 55#include <linux/mount.h>
56#include <linux/namei.h>
56 57
57static int read_block(struct inode *inode, void *addr, unsigned int block, 58static int read_block(struct inode *inode, void *addr, unsigned int block,
58 struct ubifs_data_node *dn) 59 struct ubifs_data_node *dn)
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 00eb9c68ad03..ca1e2d4e03cc 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1841,7 +1841,7 @@ static struct file_system_type ubifs_fs_type = {
1841/* 1841/*
1842 * Inode slab cache constructor. 1842 * Inode slab cache constructor.
1843 */ 1843 */
1844static void inode_slab_ctor(struct kmem_cache *cachep, void *obj) 1844static void inode_slab_ctor(void *obj)
1845{ 1845{
1846 struct ubifs_inode *ui = obj; 1846 struct ubifs_inode *ui = obj;
1847 inode_init_once(&ui->vfs_inode); 1847 inode_init_once(&ui->vfs_inode);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 44cc702f96cc..5698bbf83bbf 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -148,7 +148,7 @@ static void udf_destroy_inode(struct inode *inode)
148 kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 148 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
149} 149}
150 150
151static void init_once(struct kmem_cache *cachep, void *foo) 151static void init_once(void *foo)
152{ 152{
153 struct udf_inode_info *ei = (struct udf_inode_info *)foo; 153 struct udf_inode_info *ei = (struct udf_inode_info *)foo;
154 154
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 227c9d700040..3e30e40aa24d 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1302,7 +1302,7 @@ static void ufs_destroy_inode(struct inode *inode)
1302 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1302 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1303} 1303}
1304 1304
1305static void init_once(struct kmem_cache * cachep, void *foo) 1305static void init_once(void *foo)
1306{ 1306{
1307 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1307 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1308 1308
diff --git a/fs/utimes.c b/fs/utimes.c
index b6b664e7145e..6929e3e91d05 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -48,66 +48,22 @@ static bool nsec_valid(long nsec)
48 return nsec >= 0 && nsec <= 999999999; 48 return nsec >= 0 && nsec <= 999999999;
49} 49}
50 50
51/* If times==NULL, set access and modification to current time, 51static int utimes_common(struct path *path, struct timespec *times)
52 * must be owner or have write permission.
53 * Else, update from *times, must be owner or super user.
54 */
55long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags)
56{ 52{
57 int error; 53 int error;
58 struct nameidata nd;
59 struct dentry *dentry;
60 struct inode *inode;
61 struct iattr newattrs; 54 struct iattr newattrs;
62 struct file *f = NULL; 55 struct inode *inode = path->dentry->d_inode;
63 struct vfsmount *mnt;
64
65 error = -EINVAL;
66 if (times && (!nsec_valid(times[0].tv_nsec) ||
67 !nsec_valid(times[1].tv_nsec))) {
68 goto out;
69 }
70
71 if (flags & ~AT_SYMLINK_NOFOLLOW)
72 goto out;
73
74 if (filename == NULL && dfd != AT_FDCWD) {
75 error = -EINVAL;
76 if (flags & AT_SYMLINK_NOFOLLOW)
77 goto out;
78 56
79 error = -EBADF; 57 error = mnt_want_write(path->mnt);
80 f = fget(dfd);
81 if (!f)
82 goto out;
83 dentry = f->f_path.dentry;
84 mnt = f->f_path.mnt;
85 } else {
86 error = __user_walk_fd(dfd, filename, (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW, &nd);
87 if (error)
88 goto out;
89
90 dentry = nd.path.dentry;
91 mnt = nd.path.mnt;
92 }
93
94 inode = dentry->d_inode;
95
96 error = mnt_want_write(mnt);
97 if (error) 58 if (error)
98 goto dput_and_out; 59 goto out;
99 60
100 if (times && times[0].tv_nsec == UTIME_NOW && 61 if (times && times[0].tv_nsec == UTIME_NOW &&
101 times[1].tv_nsec == UTIME_NOW) 62 times[1].tv_nsec == UTIME_NOW)
102 times = NULL; 63 times = NULL;
103 64
104 /* In most cases, the checks are done in inode_change_ok() */
105 newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; 65 newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
106 if (times) { 66 if (times) {
107 error = -EPERM;
108 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
109 goto mnt_drop_write_and_out;
110
111 if (times[0].tv_nsec == UTIME_OMIT) 67 if (times[0].tv_nsec == UTIME_OMIT)
112 newattrs.ia_valid &= ~ATTR_ATIME; 68 newattrs.ia_valid &= ~ATTR_ATIME;
113 else if (times[0].tv_nsec != UTIME_NOW) { 69 else if (times[0].tv_nsec != UTIME_NOW) {
@@ -123,21 +79,13 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
123 newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; 79 newattrs.ia_mtime.tv_nsec = times[1].tv_nsec;
124 newattrs.ia_valid |= ATTR_MTIME_SET; 80 newattrs.ia_valid |= ATTR_MTIME_SET;
125 } 81 }
126
127 /* 82 /*
128 * For the UTIME_OMIT/UTIME_NOW and UTIME_NOW/UTIME_OMIT 83 * Tell inode_change_ok(), that this is an explicit time
129 * cases, we need to make an extra check that is not done by 84 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
130 * inode_change_ok(). 85 * were used.
131 */ 86 */
132 if (((times[0].tv_nsec == UTIME_NOW && 87 newattrs.ia_valid |= ATTR_TIMES_SET;
133 times[1].tv_nsec == UTIME_OMIT)
134 ||
135 (times[0].tv_nsec == UTIME_OMIT &&
136 times[1].tv_nsec == UTIME_NOW))
137 && !is_owner_or_cap(inode))
138 goto mnt_drop_write_and_out;
139 } else { 88 } else {
140
141 /* 89 /*
142 * If times is NULL (or both times are UTIME_NOW), 90 * If times is NULL (or both times are UTIME_NOW),
143 * then we need to check permissions, because 91 * then we need to check permissions, because
@@ -148,21 +96,76 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
148 goto mnt_drop_write_and_out; 96 goto mnt_drop_write_and_out;
149 97
150 if (!is_owner_or_cap(inode)) { 98 if (!is_owner_or_cap(inode)) {
151 error = permission(inode, MAY_WRITE, NULL); 99 error = inode_permission(inode, MAY_WRITE);
152 if (error) 100 if (error)
153 goto mnt_drop_write_and_out; 101 goto mnt_drop_write_and_out;
154 } 102 }
155 } 103 }
156 mutex_lock(&inode->i_mutex); 104 mutex_lock(&inode->i_mutex);
157 error = notify_change(dentry, &newattrs); 105 error = notify_change(path->dentry, &newattrs);
158 mutex_unlock(&inode->i_mutex); 106 mutex_unlock(&inode->i_mutex);
107
159mnt_drop_write_and_out: 108mnt_drop_write_and_out:
160 mnt_drop_write(mnt); 109 mnt_drop_write(path->mnt);
161dput_and_out: 110out:
162 if (f) 111 return error;
163 fput(f); 112}
164 else 113
165 path_put(&nd.path); 114/*
115 * do_utimes - change times on filename or file descriptor
116 * @dfd: open file descriptor, -1 or AT_FDCWD
117 * @filename: path name or NULL
118 * @times: new times or NULL
119 * @flags: zero or more flags (only AT_SYMLINK_NOFOLLOW for the moment)
120 *
121 * If filename is NULL and dfd refers to an open file, then operate on
122 * the file. Otherwise look up filename, possibly using dfd as a
123 * starting point.
124 *
125 * If times==NULL, set access and modification to current time,
126 * must be owner or have write permission.
127 * Else, update from *times, must be owner or super user.
128 */
129long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags)
130{
131 int error = -EINVAL;
132
133 if (times && (!nsec_valid(times[0].tv_nsec) ||
134 !nsec_valid(times[1].tv_nsec))) {
135 goto out;
136 }
137
138 if (flags & ~AT_SYMLINK_NOFOLLOW)
139 goto out;
140
141 if (filename == NULL && dfd != AT_FDCWD) {
142 struct file *file;
143
144 if (flags & AT_SYMLINK_NOFOLLOW)
145 goto out;
146
147 file = fget(dfd);
148 error = -EBADF;
149 if (!file)
150 goto out;
151
152 error = utimes_common(&file->f_path, times);
153 fput(file);
154 } else {
155 struct path path;
156 int lookup_flags = 0;
157
158 if (!(flags & AT_SYMLINK_NOFOLLOW))
159 lookup_flags |= LOOKUP_FOLLOW;
160
161 error = user_path_at(dfd, filename, lookup_flags, &path);
162 if (error)
163 goto out;
164
165 error = utimes_common(&path, times);
166 path_put(&path);
167 }
168
166out: 169out:
167 return error; 170 return error;
168} 171}
diff --git a/fs/xattr.c b/fs/xattr.c
index 4706a8b1f495..468377e66531 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -63,7 +63,7 @@ xattr_permission(struct inode *inode, const char *name, int mask)
63 return -EPERM; 63 return -EPERM;
64 } 64 }
65 65
66 return permission(inode, mask, NULL); 66 return inode_permission(inode, mask);
67} 67}
68 68
69int 69int
@@ -252,40 +252,40 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
252} 252}
253 253
254asmlinkage long 254asmlinkage long
255sys_setxattr(const char __user *path, const char __user *name, 255sys_setxattr(const char __user *pathname, const char __user *name,
256 const void __user *value, size_t size, int flags) 256 const void __user *value, size_t size, int flags)
257{ 257{
258 struct nameidata nd; 258 struct path path;
259 int error; 259 int error;
260 260
261 error = user_path_walk(path, &nd); 261 error = user_path(pathname, &path);
262 if (error) 262 if (error)
263 return error; 263 return error;
264 error = mnt_want_write(nd.path.mnt); 264 error = mnt_want_write(path.mnt);
265 if (!error) { 265 if (!error) {
266 error = setxattr(nd.path.dentry, name, value, size, flags); 266 error = setxattr(path.dentry, name, value, size, flags);
267 mnt_drop_write(nd.path.mnt); 267 mnt_drop_write(path.mnt);
268 } 268 }
269 path_put(&nd.path); 269 path_put(&path);
270 return error; 270 return error;
271} 271}
272 272
273asmlinkage long 273asmlinkage long
274sys_lsetxattr(const char __user *path, const char __user *name, 274sys_lsetxattr(const char __user *pathname, const char __user *name,
275 const void __user *value, size_t size, int flags) 275 const void __user *value, size_t size, int flags)
276{ 276{
277 struct nameidata nd; 277 struct path path;
278 int error; 278 int error;
279 279
280 error = user_path_walk_link(path, &nd); 280 error = user_lpath(pathname, &path);
281 if (error) 281 if (error)
282 return error; 282 return error;
283 error = mnt_want_write(nd.path.mnt); 283 error = mnt_want_write(path.mnt);
284 if (!error) { 284 if (!error) {
285 error = setxattr(nd.path.dentry, name, value, size, flags); 285 error = setxattr(path.dentry, name, value, size, flags);
286 mnt_drop_write(nd.path.mnt); 286 mnt_drop_write(path.mnt);
287 } 287 }
288 path_put(&nd.path); 288 path_put(&path);
289 return error; 289 return error;
290} 290}
291 291
@@ -350,32 +350,32 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
350} 350}
351 351
352asmlinkage ssize_t 352asmlinkage ssize_t
353sys_getxattr(const char __user *path, const char __user *name, 353sys_getxattr(const char __user *pathname, const char __user *name,
354 void __user *value, size_t size) 354 void __user *value, size_t size)
355{ 355{
356 struct nameidata nd; 356 struct path path;
357 ssize_t error; 357 ssize_t error;
358 358
359 error = user_path_walk(path, &nd); 359 error = user_path(pathname, &path);
360 if (error) 360 if (error)
361 return error; 361 return error;
362 error = getxattr(nd.path.dentry, name, value, size); 362 error = getxattr(path.dentry, name, value, size);
363 path_put(&nd.path); 363 path_put(&path);
364 return error; 364 return error;
365} 365}
366 366
367asmlinkage ssize_t 367asmlinkage ssize_t
368sys_lgetxattr(const char __user *path, const char __user *name, void __user *value, 368sys_lgetxattr(const char __user *pathname, const char __user *name, void __user *value,
369 size_t size) 369 size_t size)
370{ 370{
371 struct nameidata nd; 371 struct path path;
372 ssize_t error; 372 ssize_t error;
373 373
374 error = user_path_walk_link(path, &nd); 374 error = user_lpath(pathname, &path);
375 if (error) 375 if (error)
376 return error; 376 return error;
377 error = getxattr(nd.path.dentry, name, value, size); 377 error = getxattr(path.dentry, name, value, size);
378 path_put(&nd.path); 378 path_put(&path);
379 return error; 379 return error;
380} 380}
381 381
@@ -425,30 +425,30 @@ listxattr(struct dentry *d, char __user *list, size_t size)
425} 425}
426 426
427asmlinkage ssize_t 427asmlinkage ssize_t
428sys_listxattr(const char __user *path, char __user *list, size_t size) 428sys_listxattr(const char __user *pathname, char __user *list, size_t size)
429{ 429{
430 struct nameidata nd; 430 struct path path;
431 ssize_t error; 431 ssize_t error;
432 432
433 error = user_path_walk(path, &nd); 433 error = user_path(pathname, &path);
434 if (error) 434 if (error)
435 return error; 435 return error;
436 error = listxattr(nd.path.dentry, list, size); 436 error = listxattr(path.dentry, list, size);
437 path_put(&nd.path); 437 path_put(&path);
438 return error; 438 return error;
439} 439}
440 440
441asmlinkage ssize_t 441asmlinkage ssize_t
442sys_llistxattr(const char __user *path, char __user *list, size_t size) 442sys_llistxattr(const char __user *pathname, char __user *list, size_t size)
443{ 443{
444 struct nameidata nd; 444 struct path path;
445 ssize_t error; 445 ssize_t error;
446 446
447 error = user_path_walk_link(path, &nd); 447 error = user_lpath(pathname, &path);
448 if (error) 448 if (error)
449 return error; 449 return error;
450 error = listxattr(nd.path.dentry, list, size); 450 error = listxattr(path.dentry, list, size);
451 path_put(&nd.path); 451 path_put(&path);
452 return error; 452 return error;
453} 453}
454 454
@@ -486,38 +486,38 @@ removexattr(struct dentry *d, const char __user *name)
486} 486}
487 487
488asmlinkage long 488asmlinkage long
489sys_removexattr(const char __user *path, const char __user *name) 489sys_removexattr(const char __user *pathname, const char __user *name)
490{ 490{
491 struct nameidata nd; 491 struct path path;
492 int error; 492 int error;
493 493
494 error = user_path_walk(path, &nd); 494 error = user_path(pathname, &path);
495 if (error) 495 if (error)
496 return error; 496 return error;
497 error = mnt_want_write(nd.path.mnt); 497 error = mnt_want_write(path.mnt);
498 if (!error) { 498 if (!error) {
499 error = removexattr(nd.path.dentry, name); 499 error = removexattr(path.dentry, name);
500 mnt_drop_write(nd.path.mnt); 500 mnt_drop_write(path.mnt);
501 } 501 }
502 path_put(&nd.path); 502 path_put(&path);
503 return error; 503 return error;
504} 504}
505 505
506asmlinkage long 506asmlinkage long
507sys_lremovexattr(const char __user *path, const char __user *name) 507sys_lremovexattr(const char __user *pathname, const char __user *name)
508{ 508{
509 struct nameidata nd; 509 struct path path;
510 int error; 510 int error;
511 511
512 error = user_path_walk_link(path, &nd); 512 error = user_lpath(pathname, &path);
513 if (error) 513 if (error)
514 return error; 514 return error;
515 error = mnt_want_write(nd.path.mnt); 515 error = mnt_want_write(path.mnt);
516 if (!error) { 516 if (!error) {
517 error = removexattr(nd.path.dentry, name); 517 error = removexattr(path.dentry, name);
518 mnt_drop_write(nd.path.mnt); 518 mnt_drop_write(path.mnt);
519 } 519 }
520 path_put(&nd.path); 520 path_put(&path);
521 return error; 521 return error;
522} 522}
523 523
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 5e9564902976..a20683cf74dd 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -79,7 +79,7 @@ kmem_zone_init(int size, char *zone_name)
79 79
80static inline kmem_zone_t * 80static inline kmem_zone_t *
81kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, 81kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
82 void (*construct)(kmem_zone_t *, void *)) 82 void (*construct)(void *))
83{ 83{
84 return kmem_cache_create(zone_name, size, 0, flags, construct); 84 return kmem_cache_create(zone_name, size, 0, flags, construct);
85} 85}
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index a42ba9d71156..01939ba2d8de 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -84,17 +84,15 @@ xfs_find_handle(
84 switch (cmd) { 84 switch (cmd) {
85 case XFS_IOC_PATH_TO_FSHANDLE: 85 case XFS_IOC_PATH_TO_FSHANDLE:
86 case XFS_IOC_PATH_TO_HANDLE: { 86 case XFS_IOC_PATH_TO_HANDLE: {
87 struct nameidata nd; 87 struct path path;
88 int error; 88 int error = user_lpath((const char __user *)hreq.path, &path);
89
90 error = user_path_walk_link((const char __user *)hreq.path, &nd);
91 if (error) 89 if (error)
92 return error; 90 return error;
93 91
94 ASSERT(nd.path.dentry); 92 ASSERT(path.dentry);
95 ASSERT(nd.path.dentry->d_inode); 93 ASSERT(path.dentry->d_inode);
96 inode = igrab(nd.path.dentry->d_inode); 94 inode = igrab(path.dentry->d_inode);
97 path_put(&nd.path); 95 path_put(&path);
98 break; 96 break;
99 } 97 }
100 98
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 2bf287ef5489..5fc61c824bb9 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -589,8 +589,7 @@ xfs_check_acl(
589STATIC int 589STATIC int
590xfs_vn_permission( 590xfs_vn_permission(
591 struct inode *inode, 591 struct inode *inode,
592 int mask, 592 int mask)
593 struct nameidata *nd)
594{ 593{
595 return generic_permission(inode, mask, xfs_check_acl); 594 return generic_permission(inode, mask, xfs_check_acl);
596} 595}
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 5e3b57516ec7..82333b3e118e 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -711,7 +711,7 @@ start:
711 !capable(CAP_FSETID)) { 711 !capable(CAP_FSETID)) {
712 error = xfs_write_clear_setuid(xip); 712 error = xfs_write_clear_setuid(xip);
713 if (likely(!error)) 713 if (likely(!error))
714 error = -remove_suid(file->f_path.dentry); 714 error = -file_remove_suid(file);
715 if (unlikely(error)) { 715 if (unlikely(error)) {
716 goto out_unlock_internal; 716 goto out_unlock_internal;
717 } 717 }
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 742b2c7852c1..943381284e2e 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -843,7 +843,6 @@ xfs_fs_destroy_inode(
843 843
844STATIC void 844STATIC void
845xfs_fs_inode_init_once( 845xfs_fs_inode_init_once(
846 kmem_zone_t *zonep,
847 void *vnode) 846 void *vnode)
848{ 847{
849 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); 848 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
diff --git a/include/Kbuild b/include/Kbuild
index bdca155028ec..d8c3e3cbf416 100644
--- a/include/Kbuild
+++ b/include/Kbuild
@@ -1,3 +1,6 @@
1# Top-level Makefile calls into asm-$(ARCH)
2# List only non-arch directories below
3
1header-y += asm-generic/ 4header-y += asm-generic/
2header-y += linux/ 5header-y += linux/
3header-y += sound/ 6header-y += sound/
@@ -5,5 +8,3 @@ header-y += mtd/
5header-y += rdma/ 8header-y += rdma/
6header-y += video/ 9header-y += video/
7header-y += drm/ 10header-y += drm/
8
9header-y += asm-$(ARCH)/
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 1ebbe883f786..13a3d9ad92db 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -277,6 +277,7 @@ enum acpi_prefered_pm_profiles {
277#define BAF_LEGACY_DEVICES 0x0001 277#define BAF_LEGACY_DEVICES 0x0001
278#define BAF_8042_KEYBOARD_CONTROLLER 0x0002 278#define BAF_8042_KEYBOARD_CONTROLLER 0x0002
279#define BAF_MSI_NOT_SUPPORTED 0x0008 279#define BAF_MSI_NOT_SUPPORTED 0x0008
280#define BAF_PCIE_ASPM_CONTROL 0x0010
280 281
281#define FADT2_REVISION_ID 3 282#define FADT2_REVISION_ID 3
282#define FADT2_MINUS_REVISION_ID 2 283#define FADT2_MINUS_REVISION_ID 2
diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h
index db351d1296f4..a5801ae02e4b 100644
--- a/include/asm-alpha/dma-mapping.h
+++ b/include/asm-alpha/dma-mapping.h
@@ -24,8 +24,8 @@
24 pci_unmap_sg(alpha_gendev_to_pci(dev), sg, nents, dir) 24 pci_unmap_sg(alpha_gendev_to_pci(dev), sg, nents, dir)
25#define dma_supported(dev, mask) \ 25#define dma_supported(dev, mask) \
26 pci_dma_supported(alpha_gendev_to_pci(dev), mask) 26 pci_dma_supported(alpha_gendev_to_pci(dev), mask)
27#define dma_mapping_error(addr) \ 27#define dma_mapping_error(dev, addr) \
28 pci_dma_mapping_error(addr) 28 pci_dma_mapping_error(alpha_gendev_to_pci(dev), addr)
29 29
30#else /* no PCI - no IOMMU. */ 30#else /* no PCI - no IOMMU. */
31 31
@@ -45,7 +45,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
45#define dma_unmap_page(dev, addr, size, dir) ((void)0) 45#define dma_unmap_page(dev, addr, size, dir) ((void)0)
46#define dma_unmap_sg(dev, sg, nents, dir) ((void)0) 46#define dma_unmap_sg(dev, sg, nents, dir) ((void)0)
47 47
48#define dma_mapping_error(addr) (0) 48#define dma_mapping_error(dev, addr) (0)
49 49
50#endif /* !CONFIG_PCI */ 50#endif /* !CONFIG_PCI */
51 51
diff --git a/include/asm-alpha/namei.h b/include/asm-alpha/namei.h
deleted file mode 100644
index 5cc9bb39499d..000000000000
--- a/include/asm-alpha/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* $Id: namei.h,v 1.1 1996/12/13 14:48:21 jj Exp $
2 * linux/include/asm-alpha/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __ALPHA_NAMEI_H
8#define __ALPHA_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* __ALPHA_NAMEI_H */
diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h
index d31fd49ff79a..2a14302c17a3 100644
--- a/include/asm-alpha/pci.h
+++ b/include/asm-alpha/pci.h
@@ -106,7 +106,7 @@ extern dma_addr_t pci_map_page(struct pci_dev *, struct page *,
106/* Test for pci_map_single or pci_map_page having generated an error. */ 106/* Test for pci_map_single or pci_map_page having generated an error. */
107 107
108static inline int 108static inline int
109pci_dma_mapping_error(dma_addr_t dma_addr) 109pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
110{ 110{
111 return dma_addr == 0; 111 return dma_addr == 0;
112} 112}
diff --git a/include/asm-arm/arch-at91/at91_ecc.h b/include/asm-arm/arch-at91/at91_ecc.h
deleted file mode 100644
index 1e5a8caca2d1..000000000000
--- a/include/asm-arm/arch-at91/at91_ecc.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * include/asm-arm/arch-at91/at91_ecc.h
3 *
4 * Error Corrected Code Controller (ECC) - System peripherals regsters.
5 * Based on AT91SAM9260 datasheet revision B.
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
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef AT91_ECC_H
14#define AT91_ECC_H
15
16#define AT91_ECC_CR 0x00 /* Control register */
17#define AT91_ECC_RST (1 << 0) /* Reset parity */
18
19#define AT91_ECC_MR 0x04 /* Mode register */
20#define AT91_ECC_PAGESIZE (3 << 0) /* Page Size */
21#define AT91_ECC_PAGESIZE_528 (0)
22#define AT91_ECC_PAGESIZE_1056 (1)
23#define AT91_ECC_PAGESIZE_2112 (2)
24#define AT91_ECC_PAGESIZE_4224 (3)
25
26#define AT91_ECC_SR 0x08 /* Status register */
27#define AT91_ECC_RECERR (1 << 0) /* Recoverable Error */
28#define AT91_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
29#define AT91_ECC_MULERR (1 << 2) /* Multiple Errors */
30
31#define AT91_ECC_PR 0x0c /* Parity register */
32#define AT91_ECC_BITADDR (0xf << 0) /* Bit Error Address */
33#define AT91_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
34
35#define AT91_ECC_NPR 0x10 /* NParity register */
36#define AT91_ECC_NPARITY (0xffff << 0) /* NParity */
37
38#endif
diff --git a/include/asm-arm/arch-at91/board.h b/include/asm-arm/arch-at91/board.h
index 94de788da76e..48bbd854f57d 100644
--- a/include/asm-arm/arch-at91/board.h
+++ b/include/asm-arm/arch-at91/board.h
@@ -89,7 +89,7 @@ struct at91_usbh_data {
89extern void __init at91_add_device_usbh(struct at91_usbh_data *data); 89extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
90 90
91 /* NAND / SmartMedia */ 91 /* NAND / SmartMedia */
92struct at91_nand_data { 92struct atmel_nand_data {
93 u8 enable_pin; /* chip enable */ 93 u8 enable_pin; /* chip enable */
94 u8 det_pin; /* card detect */ 94 u8 det_pin; /* card detect */
95 u8 rdy_pin; /* ready/busy */ 95 u8 rdy_pin; /* ready/busy */
@@ -98,7 +98,7 @@ struct at91_nand_data {
98 u8 bus_width_16; /* buswidth is 16 bit */ 98 u8 bus_width_16; /* buswidth is 16 bit */
99 struct mtd_partition* (*partition_info)(int, int*); 99 struct mtd_partition* (*partition_info)(int, int*);
100}; 100};
101extern void __init at91_add_device_nand(struct at91_nand_data *data); 101extern void __init at91_add_device_nand(struct atmel_nand_data *data);
102 102
103 /* I2C*/ 103 /* I2C*/
104extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices); 104extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices);
diff --git a/include/asm-arm/arch-pnx4008/irqs.h b/include/asm-arm/arch-pnx4008/irqs.h
index 13ec7ed0f501..a25d18f2d87a 100644
--- a/include/asm-arm/arch-pnx4008/irqs.h
+++ b/include/asm-arm/arch-pnx4008/irqs.h
@@ -135,30 +135,30 @@
135 135
136#define PNX4008_IRQ_TYPES \ 136#define PNX4008_IRQ_TYPES \
137{ /*IRQ #'s: */ \ 137{ /*IRQ #'s: */ \
138IRQT_LOW, IRQT_LOW, IRQT_LOW, IRQT_HIGH, /* 0, 1, 2, 3 */ \ 138IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, /* 0, 1, 2, 3 */ \
139IRQT_LOW, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 4, 5, 6, 7 */ \ 139IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 4, 5, 6, 7 */ \
140IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 8, 9,10,11 */ \ 140IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 8, 9,10,11 */ \
141IRQT_LOW, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 12,13,14,15 */ \ 141IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 12,13,14,15 */ \
142IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 16,17,18,19 */ \ 142IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 16,17,18,19 */ \
143IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 20,21,22,23 */ \ 143IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 20,21,22,23 */ \
144IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 24,25,26,27 */ \ 144IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 24,25,26,27 */ \
145IRQT_HIGH, IRQT_HIGH, IRQT_LOW, IRQT_LOW, /* 28,29,30,31 */ \ 145IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_LOW, /* 28,29,30,31 */ \
146IRQT_HIGH, IRQT_LOW, IRQT_HIGH, IRQT_HIGH, /* 32,33,34,35 */ \ 146IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 32,33,34,35 */ \
147IRQT_HIGH, IRQT_HIGH, IRQT_FALLING, IRQT_HIGH, /* 36,37,38,39 */ \ 147IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_HIGH, /* 36,37,38,39 */ \
148IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 40,41,42,43 */ \ 148IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 40,41,42,43 */ \
149IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 44,45,46,47 */ \ 149IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 44,45,46,47 */ \
150IRQT_HIGH, IRQT_HIGH, IRQT_LOW, IRQT_LOW, /* 48,49,50,51 */ \ 150IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_LOW, /* 48,49,50,51 */ \
151IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 52,53,54,55 */ \ 151IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 52,53,54,55 */ \
152IRQT_HIGH, IRQT_HIGH, IRQT_LOW, IRQT_HIGH, /* 56,57,58,59 */ \ 152IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH, /* 56,57,58,59 */ \
153IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 60,61,62,63 */ \ 153IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 60,61,62,63 */ \
154IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 64,65,66,67 */ \ 154IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 64,65,66,67 */ \
155IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 68,69,70,71 */ \ 155IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 68,69,70,71 */ \
156IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 72,73,74,75 */ \ 156IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 72,73,74,75 */ \
157IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 76,77,78,79 */ \ 157IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 76,77,78,79 */ \
158IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 80,81,82,83 */ \ 158IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 80,81,82,83 */ \
159IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 84,85,86,87 */ \ 159IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 84,85,86,87 */ \
160IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 88,89,90,91 */ \ 160IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 88,89,90,91 */ \
161IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, IRQT_HIGH, /* 92,93,94,95 */ \ 161IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_LEVEL_HIGH, /* 92,93,94,95 */ \
162} 162}
163 163
164/* Start Enable Pin Interrupts - table 58 page 66 */ 164/* Start Enable Pin Interrupts - table 58 page 66 */
diff --git a/include/asm-arm/arch-pxa/idp.h b/include/asm-arm/arch-pxa/idp.h
index b6952534a4e1..21aa8ac35c1c 100644
--- a/include/asm-arm/arch-pxa/idp.h
+++ b/include/asm-arm/arch-pxa/idp.h
@@ -138,18 +138,18 @@
138#define TOUCH_PANEL_IRQ IRQ_GPIO(5) 138#define TOUCH_PANEL_IRQ IRQ_GPIO(5)
139#define IDE_IRQ IRQ_GPIO(21) 139#define IDE_IRQ IRQ_GPIO(21)
140 140
141#define TOUCH_PANEL_IRQ_EDGE IRQT_FALLING 141#define TOUCH_PANEL_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
142 142
143#define ETHERNET_IRQ IRQ_GPIO(4) 143#define ETHERNET_IRQ IRQ_GPIO(4)
144#define ETHERNET_IRQ_EDGE IRQT_RISING 144#define ETHERNET_IRQ_EDGE IRQ_TYPE_EDGE_RISING
145 145
146#define IDE_IRQ_EDGE IRQT_RISING 146#define IDE_IRQ_EDGE IRQ_TYPE_EDGE_RISING
147 147
148#define PCMCIA_S0_CD_VALID IRQ_GPIO(7) 148#define PCMCIA_S0_CD_VALID IRQ_GPIO(7)
149#define PCMCIA_S0_CD_VALID_EDGE IRQT_BOTHEDGE 149#define PCMCIA_S0_CD_VALID_EDGE IRQ_TYPE_EDGE_BOTH
150 150
151#define PCMCIA_S1_CD_VALID IRQ_GPIO(8) 151#define PCMCIA_S1_CD_VALID IRQ_GPIO(8)
152#define PCMCIA_S1_CD_VALID_EDGE IRQT_BOTHEDGE 152#define PCMCIA_S1_CD_VALID_EDGE IRQ_TYPE_EDGE_BOTH
153 153
154#define PCMCIA_S0_RDYINT IRQ_GPIO(19) 154#define PCMCIA_S0_RDYINT IRQ_GPIO(19)
155#define PCMCIA_S1_RDYINT IRQ_GPIO(22) 155#define PCMCIA_S1_RDYINT IRQ_GPIO(22)
diff --git a/include/asm-arm/arch-pxa/pcm990_baseboard.h b/include/asm-arm/arch-pxa/pcm990_baseboard.h
index b699d0d7bdb2..2e2013179063 100644
--- a/include/asm-arm/arch-pxa/pcm990_baseboard.h
+++ b/include/asm-arm/arch-pxa/pcm990_baseboard.h
@@ -29,14 +29,14 @@
29/* CPLD's interrupt controller is connected to PCM-027 GPIO 9 */ 29/* CPLD's interrupt controller is connected to PCM-027 GPIO 9 */
30#define PCM990_CTRL_INT_IRQ_GPIO 9 30#define PCM990_CTRL_INT_IRQ_GPIO 9
31#define PCM990_CTRL_INT_IRQ IRQ_GPIO(PCM990_CTRL_INT_IRQ_GPIO) 31#define PCM990_CTRL_INT_IRQ IRQ_GPIO(PCM990_CTRL_INT_IRQ_GPIO)
32#define PCM990_CTRL_INT_IRQ_EDGE IRQT_RISING 32#define PCM990_CTRL_INT_IRQ_EDGE IRQ_TYPE_EDGE_RISING
33#define PCM990_CTRL_PHYS PXA_CS1_PHYS /* 16-Bit */ 33#define PCM990_CTRL_PHYS PXA_CS1_PHYS /* 16-Bit */
34#define PCM990_CTRL_BASE 0xea000000 34#define PCM990_CTRL_BASE 0xea000000
35#define PCM990_CTRL_SIZE (1*1024*1024) 35#define PCM990_CTRL_SIZE (1*1024*1024)
36 36
37#define PCM990_CTRL_PWR_IRQ_GPIO 14 37#define PCM990_CTRL_PWR_IRQ_GPIO 14
38#define PCM990_CTRL_PWR_IRQ IRQ_GPIO(PCM990_CTRL_PWR_IRQ_GPIO) 38#define PCM990_CTRL_PWR_IRQ IRQ_GPIO(PCM990_CTRL_PWR_IRQ_GPIO)
39#define PCM990_CTRL_PWR_IRQ_EDGE IRQT_RISING 39#define PCM990_CTRL_PWR_IRQ_EDGE IRQ_TYPE_EDGE_RISING
40 40
41/* visible CPLD (U7) registers */ 41/* visible CPLD (U7) registers */
42#define PCM990_CTRL_REG0 0x0000 /* RESET REGISTER */ 42#define PCM990_CTRL_REG0 0x0000 /* RESET REGISTER */
@@ -133,7 +133,7 @@
133 */ 133 */
134#define PCM990_IDE_IRQ_GPIO 13 134#define PCM990_IDE_IRQ_GPIO 13
135#define PCM990_IDE_IRQ IRQ_GPIO(PCM990_IDE_IRQ_GPIO) 135#define PCM990_IDE_IRQ IRQ_GPIO(PCM990_IDE_IRQ_GPIO)
136#define PCM990_IDE_IRQ_EDGE IRQT_RISING 136#define PCM990_IDE_IRQ_EDGE IRQ_TYPE_EDGE_RISING
137#define PCM990_IDE_PLD_PHYS 0x20000000 /* 16 bit wide */ 137#define PCM990_IDE_PLD_PHYS 0x20000000 /* 16 bit wide */
138#define PCM990_IDE_PLD_BASE 0xee000000 138#define PCM990_IDE_PLD_BASE 0xee000000
139#define PCM990_IDE_PLD_SIZE (1*1024*1024) 139#define PCM990_IDE_PLD_SIZE (1*1024*1024)
@@ -189,11 +189,11 @@
189 */ 189 */
190#define PCM990_CF_IRQ_GPIO 11 190#define PCM990_CF_IRQ_GPIO 11
191#define PCM990_CF_IRQ IRQ_GPIO(PCM990_CF_IRQ_GPIO) 191#define PCM990_CF_IRQ IRQ_GPIO(PCM990_CF_IRQ_GPIO)
192#define PCM990_CF_IRQ_EDGE IRQT_RISING 192#define PCM990_CF_IRQ_EDGE IRQ_TYPE_EDGE_RISING
193 193
194#define PCM990_CF_CD_GPIO 12 194#define PCM990_CF_CD_GPIO 12
195#define PCM990_CF_CD IRQ_GPIO(PCM990_CF_CD_GPIO) 195#define PCM990_CF_CD IRQ_GPIO(PCM990_CF_CD_GPIO)
196#define PCM990_CF_CD_EDGE IRQT_RISING 196#define PCM990_CF_CD_EDGE IRQ_TYPE_EDGE_RISING
197 197
198#define PCM990_CF_PLD_PHYS 0x30000000 /* 16 bit wide */ 198#define PCM990_CF_PLD_PHYS 0x30000000 /* 16 bit wide */
199#define PCM990_CF_PLD_BASE 0xef000000 199#define PCM990_CF_PLD_BASE 0xef000000
@@ -259,14 +259,14 @@
259 */ 259 */
260#define PCM990_AC97_IRQ_GPIO 10 260#define PCM990_AC97_IRQ_GPIO 10
261#define PCM990_AC97_IRQ IRQ_GPIO(PCM990_AC97_IRQ_GPIO) 261#define PCM990_AC97_IRQ IRQ_GPIO(PCM990_AC97_IRQ_GPIO)
262#define PCM990_AC97_IRQ_EDGE IRQT_RISING 262#define PCM990_AC97_IRQ_EDGE IRQ_TYPE_EDGE_RISING
263 263
264/* 264/*
265 * MMC phyCORE 265 * MMC phyCORE
266 */ 266 */
267#define PCM990_MMC0_IRQ_GPIO 9 267#define PCM990_MMC0_IRQ_GPIO 9
268#define PCM990_MMC0_IRQ IRQ_GPIO(PCM990_MMC0_IRQ_GPIO) 268#define PCM990_MMC0_IRQ IRQ_GPIO(PCM990_MMC0_IRQ_GPIO)
269#define PCM990_MMC0_IRQ_EDGE IRQT_FALLING 269#define PCM990_MMC0_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
270 270
271/* 271/*
272 * USB phyCore 272 * USB phyCore
diff --git a/include/asm-arm/arch-pxa/pxa25x-udc.h b/include/asm-arm/arch-pxa/pxa25x-udc.h
index 840305916b6d..1b80a4805a60 100644
--- a/include/asm-arm/arch-pxa/pxa25x-udc.h
+++ b/include/asm-arm/arch-pxa/pxa25x-udc.h
@@ -2,7 +2,7 @@
2#define _ASM_ARCH_PXA25X_UDC_H 2#define _ASM_ARCH_PXA25X_UDC_H
3 3
4#ifdef _ASM_ARCH_PXA27X_UDC_H 4#ifdef _ASM_ARCH_PXA27X_UDC_H
5#error You can't include both PXA25x and PXA27x UDC support 5#error "You can't include both PXA25x and PXA27x UDC support"
6#endif 6#endif
7 7
8#define UDC_RES1 __REG(0x40600004) /* UDC Undocumented - Reserved1 */ 8#define UDC_RES1 __REG(0x40600004) /* UDC Undocumented - Reserved1 */
diff --git a/include/asm-arm/arch-s3c2410/spi.h b/include/asm-arm/arch-s3c2410/spi.h
index 352d33860b63..442169887d3b 100644
--- a/include/asm-arm/arch-s3c2410/spi.h
+++ b/include/asm-arm/arch-s3c2410/spi.h
@@ -16,6 +16,7 @@
16struct s3c2410_spi_info { 16struct s3c2410_spi_info {
17 unsigned long pin_cs; /* simple gpio cs */ 17 unsigned long pin_cs; /* simple gpio cs */
18 unsigned int num_cs; /* total chipselects */ 18 unsigned int num_cs; /* total chipselects */
19 int bus_num; /* bus number to use. */
19 20
20 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); 21 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
21}; 22};
diff --git a/include/asm-arm/arch-sa1100/ide.h b/include/asm-arm/arch-sa1100/ide.h
index b14cbda01dc3..193f6c15f4dd 100644
--- a/include/asm-arm/arch-sa1100/ide.h
+++ b/include/asm-arm/arch-sa1100/ide.h
@@ -61,7 +61,7 @@ ide_init_default_hwifs(void)
61 61
62 /* Enable GPIO as interrupt line */ 62 /* Enable GPIO as interrupt line */
63 GPDR &= ~LART_GPIO_IDE; 63 GPDR &= ~LART_GPIO_IDE;
64 set_irq_type(LART_IRQ_IDE, IRQT_RISING); 64 set_irq_type(LART_IRQ_IDE, IRQ_TYPE_EDGE_RISING);
65 65
66 /* set PCMCIA interface timing */ 66 /* set PCMCIA interface timing */
67 MECR = 0x00060006; 67 MECR = 0x00060006;
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 5c60bfc1a84d..9a1db20e032a 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -277,9 +277,16 @@ static inline int constant_fls(int x)
277 * the clz instruction for much better code efficiency. 277 * the clz instruction for much better code efficiency.
278 */ 278 */
279 279
280#define fls(x) \ 280#define __fls(x) \
281 ( __builtin_constant_p(x) ? constant_fls(x) : \ 281 ( __builtin_constant_p(x) ? constant_fls(x) : \
282 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) 282 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
283
284/* Implement fls() in C so that 64-bit args are suitably truncated */
285static inline int fls(int x)
286{
287 return __fls(x);
288}
289
283#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) 290#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
284#define __ffs(x) (ffs(x) - 1) 291#define __ffs(x) (ffs(x) - 1)
285#define ffz(x) __ffs( ~(x) ) 292#define ffz(x) __ffs( ~(x) )
diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
index 70b0fe724b62..e68a1cbcc852 100644
--- a/include/asm-arm/cacheflush.h
+++ b/include/asm-arm/cacheflush.h
@@ -424,9 +424,9 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
424} 424}
425 425
426#define flush_dcache_mmap_lock(mapping) \ 426#define flush_dcache_mmap_lock(mapping) \
427 write_lock_irq(&(mapping)->tree_lock) 427 spin_lock_irq(&(mapping)->tree_lock)
428#define flush_dcache_mmap_unlock(mapping) \ 428#define flush_dcache_mmap_unlock(mapping) \
429 write_unlock_irq(&(mapping)->tree_lock) 429 spin_unlock_irq(&(mapping)->tree_lock)
430 430
431#define flush_icache_user_range(vma,page,addr,len) \ 431#define flush_icache_user_range(vma,page,addr,len) \
432 flush_dcache_page(page) 432 flush_dcache_page(page)
@@ -459,15 +459,19 @@ static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt,
459#define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0) 459#define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0)
460 460
461#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT) 461#if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT)
462 462/*
463 * VIVT caches only
464 */
463#define cache_is_vivt() 1 465#define cache_is_vivt() 1
464#define cache_is_vipt() 0 466#define cache_is_vipt() 0
465#define cache_is_vipt_nonaliasing() 0 467#define cache_is_vipt_nonaliasing() 0
466#define cache_is_vipt_aliasing() 0 468#define cache_is_vipt_aliasing() 0
467#define icache_is_vivt_asid_tagged() 0 469#define icache_is_vivt_asid_tagged() 0
468 470
469#elif defined(CONFIG_CPU_CACHE_VIPT) 471#elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT)
470 472/*
473 * VIPT caches only
474 */
471#define cache_is_vivt() 0 475#define cache_is_vivt() 0
472#define cache_is_vipt() 1 476#define cache_is_vipt() 1
473#define cache_is_vipt_nonaliasing() \ 477#define cache_is_vipt_nonaliasing() \
@@ -489,7 +493,12 @@ static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt,
489 }) 493 })
490 494
491#else 495#else
492 496/*
497 * VIVT or VIPT caches. Note that this is unreliable since ARM926
498 * and V6 CPUs satisfy the "(val & (15 << 25)) == (14 << 25)" test.
499 * There's no way to tell from the CacheType register what type (!)
500 * the cache is.
501 */
493#define cache_is_vivt() \ 502#define cache_is_vivt() \
494 ({ \ 503 ({ \
495 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \ 504 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index e99406a7bece..45329fca1b64 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -7,6 +7,8 @@
7 7
8#include <linux/scatterlist.h> 8#include <linux/scatterlist.h>
9 9
10#include <asm-generic/dma-coherent.h>
11
10/* 12/*
11 * DMA-consistent mapping functions. These allocate/free a region of 13 * DMA-consistent mapping functions. These allocate/free a region of
12 * uncached, unwrite-buffered mapped memory space for use with DMA 14 * uncached, unwrite-buffered mapped memory space for use with DMA
@@ -56,7 +58,7 @@ static inline int dma_is_consistent(struct device *dev, dma_addr_t handle)
56/* 58/*
57 * DMA errors are defined by all-bits-set in the DMA address. 59 * DMA errors are defined by all-bits-set in the DMA address.
58 */ 60 */
59static inline int dma_mapping_error(dma_addr_t dma_addr) 61static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
60{ 62{
61 return dma_addr == ~0; 63 return dma_addr == ~0;
62} 64}
diff --git a/include/asm-arm/irq.h b/include/asm-arm/irq.h
index 1b882a255e35..9cb01907e43b 100644
--- a/include/asm-arm/irq.h
+++ b/include/asm-arm/irq.h
@@ -19,23 +19,6 @@
19#define NO_IRQ ((unsigned int)(-1)) 19#define NO_IRQ ((unsigned int)(-1))
20#endif 20#endif
21 21
22
23/*
24 * Migration helpers
25 */
26#define __IRQT_FALEDGE IRQ_TYPE_EDGE_FALLING
27#define __IRQT_RISEDGE IRQ_TYPE_EDGE_RISING
28#define __IRQT_LOWLVL IRQ_TYPE_LEVEL_LOW
29#define __IRQT_HIGHLVL IRQ_TYPE_LEVEL_HIGH
30
31#define IRQT_NOEDGE (0)
32#define IRQT_RISING (__IRQT_RISEDGE)
33#define IRQT_FALLING (__IRQT_FALEDGE)
34#define IRQT_BOTHEDGE (__IRQT_RISEDGE|__IRQT_FALEDGE)
35#define IRQT_LOW (__IRQT_LOWLVL)
36#define IRQT_HIGH (__IRQT_HIGHLVL)
37#define IRQT_PROBE IRQ_TYPE_PROBE
38
39#ifndef __ASSEMBLY__ 22#ifndef __ASSEMBLY__
40struct irqaction; 23struct irqaction;
41extern void migrate_irqs(void); 24extern void migrate_irqs(void);
diff --git a/include/asm-arm/namei.h b/include/asm-arm/namei.h
deleted file mode 100644
index a402d3b9d0f7..000000000000
--- a/include/asm-arm/namei.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * linux/include/asm-arm/namei.h
3 *
4 * Routines to handle famous /usr/gnemul
5 * Derived from the Sparc version of this file
6 *
7 * Included from linux/fs/namei.c
8 */
9
10#ifndef __ASMARM_NAMEI_H
11#define __ASMARM_NAMEI_H
12
13#define ARM_BSD_EMUL "usr/gnemul/bsd/"
14
15static inline char *__emul_prefix(void)
16{
17 switch (current->personality) {
18 case PER_BSD:
19 return ARM_BSD_EMUL;
20 default:
21 return NULL;
22 }
23}
24
25#endif /* __ASMARM_NAMEI_H */
diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h
index 75feb1574a69..2d84792f2e12 100644
--- a/include/asm-arm/pci.h
+++ b/include/asm-arm/pci.h
@@ -78,6 +78,14 @@ pcibios_select_root(struct pci_dev *pdev, struct resource *res)
78 return root; 78 return root;
79} 79}
80 80
81/*
82 * Dummy implementation; always return 0.
83 */
84static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
85{
86 return 0;
87}
88
81#endif /* __KERNEL__ */ 89#endif /* __KERNEL__ */
82 90
83#endif 91#endif
diff --git a/include/asm-arm/plat-s3c/iic.h b/include/asm-arm/plat-s3c/iic.h
index 71211c8b5384..d08a1f2863e4 100644
--- a/include/asm-arm/plat-s3c/iic.h
+++ b/include/asm-arm/plat-s3c/iic.h
@@ -21,6 +21,7 @@
21*/ 21*/
22 22
23struct s3c2410_platform_i2c { 23struct s3c2410_platform_i2c {
24 int bus_num; /* bus number to use */
24 unsigned int flags; 25 unsigned int flags;
25 unsigned int slave_addr; /* slave address for controller */ 26 unsigned int slave_addr; /* slave address for controller */
26 unsigned long bus_freq; /* standard bus frequency */ 27 unsigned long bus_freq; /* standard bus frequency */
diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h
index a3783861cdd2..e60e9076544d 100644
--- a/include/asm-avr32/arch-at32ap/board.h
+++ b/include/asm-avr32/arch-at32ap/board.h
@@ -82,7 +82,15 @@ struct mci_platform_data;
82struct platform_device * 82struct platform_device *
83at32_add_device_mci(unsigned int id, struct mci_platform_data *data); 83at32_add_device_mci(unsigned int id, struct mci_platform_data *data);
84 84
85struct platform_device *at32_add_device_ac97c(unsigned int id); 85struct ac97c_platform_data {
86 unsigned short dma_rx_periph_id;
87 unsigned short dma_tx_periph_id;
88 unsigned short dma_controller_id;
89 int reset_pin;
90};
91struct platform_device *
92at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data);
93
86struct platform_device *at32_add_device_abdac(unsigned int id); 94struct platform_device *at32_add_device_abdac(unsigned int id);
87struct platform_device *at32_add_device_psif(unsigned int id); 95struct platform_device *at32_add_device_psif(unsigned int id);
88 96
@@ -97,4 +105,17 @@ struct platform_device *
97at32_add_device_cf(unsigned int id, unsigned int extint, 105at32_add_device_cf(unsigned int id, unsigned int extint,
98 struct cf_platform_data *data); 106 struct cf_platform_data *data);
99 107
108/* NAND / SmartMedia */
109struct atmel_nand_data {
110 int enable_pin; /* chip enable */
111 int det_pin; /* card detect */
112 int rdy_pin; /* ready/busy */
113 u8 ale; /* address line number connected to ALE */
114 u8 cle; /* address line number connected to CLE */
115 u8 bus_width_16; /* buswidth is 16 bit */
116 struct mtd_partition *(*partition_info)(int size, int *num_partitions);
117};
118struct platform_device *
119at32_add_device_nand(unsigned int id, struct atmel_nand_data *data);
120
100#endif /* __ASM_ARCH_BOARD_H */ 121#endif /* __ASM_ARCH_BOARD_H */
diff --git a/include/asm-avr32/dma-mapping.h b/include/asm-avr32/dma-mapping.h
index 57dc672bab8e..0399359ab5d8 100644
--- a/include/asm-avr32/dma-mapping.h
+++ b/include/asm-avr32/dma-mapping.h
@@ -35,7 +35,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
35/* 35/*
36 * dma_map_single can't fail as it is implemented now. 36 * dma_map_single can't fail as it is implemented now.
37 */ 37 */
38static inline int dma_mapping_error(dma_addr_t addr) 38static inline int dma_mapping_error(struct device *dev, dma_addr_t addr)
39{ 39{
40 return 0; 40 return 0;
41} 41}
diff --git a/include/asm-avr32/namei.h b/include/asm-avr32/namei.h
deleted file mode 100644
index f0a26de06cab..000000000000
--- a/include/asm-avr32/namei.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_AVR32_NAMEI_H
2#define __ASM_AVR32_NAMEI_H
3
4/* This dummy routine may be changed to something useful */
5#define __emul_prefix() NULL
6
7#endif /* __ASM_AVR32_NAMEI_H */
diff --git a/include/asm-blackfin/bfin-global.h b/include/asm-blackfin/bfin-global.h
index 76033831eb35..320aa5e167e9 100644
--- a/include/asm-blackfin/bfin-global.h
+++ b/include/asm-blackfin/bfin-global.h
@@ -92,16 +92,20 @@ extern void *l1_data_B_sram_alloc(size_t);
92extern void *l1_inst_sram_alloc(size_t); 92extern void *l1_inst_sram_alloc(size_t);
93extern void *l1_data_sram_alloc(size_t); 93extern void *l1_data_sram_alloc(size_t);
94extern void *l1_data_sram_zalloc(size_t); 94extern void *l1_data_sram_zalloc(size_t);
95extern void *l2_sram_alloc(size_t);
96extern void *l2_sram_zalloc(size_t);
95extern int l1_data_A_sram_free(const void*); 97extern int l1_data_A_sram_free(const void*);
96extern int l1_data_B_sram_free(const void*); 98extern int l1_data_B_sram_free(const void*);
97extern int l1_inst_sram_free(const void*); 99extern int l1_inst_sram_free(const void*);
98extern int l1_data_sram_free(const void*); 100extern int l1_data_sram_free(const void*);
101extern int l2_sram_free(const void *);
99extern int sram_free(const void*); 102extern int sram_free(const void*);
100 103
101#define L1_INST_SRAM 0x00000001 104#define L1_INST_SRAM 0x00000001
102#define L1_DATA_A_SRAM 0x00000002 105#define L1_DATA_A_SRAM 0x00000002
103#define L1_DATA_B_SRAM 0x00000004 106#define L1_DATA_B_SRAM 0x00000004
104#define L1_DATA_SRAM 0x00000006 107#define L1_DATA_SRAM 0x00000006
108#define L2_SRAM 0x00000008
105extern void *sram_alloc_with_lsl(size_t, unsigned long); 109extern void *sram_alloc_with_lsl(size_t, unsigned long);
106extern int sram_free_with_lsl(const void*); 110extern int sram_free_with_lsl(const void*);
107 111
@@ -114,7 +118,9 @@ extern struct file_operations dpmc_fops;
114extern unsigned long _ramstart, _ramend, _rambase; 118extern unsigned long _ramstart, _ramend, _rambase;
115extern unsigned long memory_start, memory_end, physical_mem_end; 119extern unsigned long memory_start, memory_end, physical_mem_end;
116extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[], 120extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
117 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _ebss_b_l1[]; 121 _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _ebss_b_l1[],
122 _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
123 _ebss_l2[], _l2_lma_start[];
118 124
119#ifdef CONFIG_MTD_UCLINUX 125#ifdef CONFIG_MTD_UCLINUX
120extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size; 126extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
diff --git a/include/asm-blackfin/dma.h b/include/asm-blackfin/dma.h
index c0d5259e315b..3cd4b522aa3f 100644
--- a/include/asm-blackfin/dma.h
+++ b/include/asm-blackfin/dma.h
@@ -144,8 +144,16 @@ struct dma_channel {
144 void *data; 144 void *data;
145 unsigned int dma_enable_flag; 145 unsigned int dma_enable_flag;
146 unsigned int loopback_flag; 146 unsigned int loopback_flag;
147#ifdef CONFIG_PM
148 unsigned short saved_peripheral_map;
149#endif
147}; 150};
148 151
152#ifdef CONFIG_PM
153int blackfin_dma_suspend(void);
154void blackfin_dma_resume(void);
155#endif
156
149/******************************************************************************* 157/*******************************************************************************
150* DMA API's 158* DMA API's
151*******************************************************************************/ 159*******************************************************************************/
diff --git a/include/asm-blackfin/dpmc.h b/include/asm-blackfin/dpmc.h
index 7f34cd384f12..de28e6e018b3 100644
--- a/include/asm-blackfin/dpmc.h
+++ b/include/asm-blackfin/dpmc.h
@@ -7,63 +7,18 @@
7#ifndef _BLACKFIN_DPMC_H_ 7#ifndef _BLACKFIN_DPMC_H_
8#define _BLACKFIN_DPMC_H_ 8#define _BLACKFIN_DPMC_H_
9 9
10#define SLEEP_MODE 1
11#define DEEP_SLEEP_MODE 2
12#define ACTIVE_PLL_DISABLED 3
13#define FULLON_MODE 4
14#define ACTIVE_PLL_ENABLED 5
15#define HIBERNATE_MODE 6
16
17#define IOCTL_FULL_ON_MODE _IO('s', 0xA0)
18#define IOCTL_ACTIVE_MODE _IO('s', 0xA1)
19#define IOCTL_SLEEP_MODE _IO('s', 0xA2)
20#define IOCTL_DEEP_SLEEP_MODE _IO('s', 0xA3)
21#define IOCTL_HIBERNATE_MODE _IO('s', 0xA4)
22#define IOCTL_CHANGE_FREQUENCY _IOW('s', 0xA5, unsigned long)
23#define IOCTL_CHANGE_VOLTAGE _IOW('s', 0xA6, unsigned long)
24#define IOCTL_SET_CCLK _IOW('s', 0xA7, unsigned long)
25#define IOCTL_SET_SCLK _IOW('s', 0xA8, unsigned long)
26#define IOCTL_GET_PLLSTATUS _IOW('s', 0xA9, unsigned long)
27#define IOCTL_GET_CORECLOCK _IOW('s', 0xAA, unsigned long)
28#define IOCTL_GET_SYSTEMCLOCK _IOW('s', 0xAB, unsigned long)
29#define IOCTL_GET_VCO _IOW('s', 0xAC, unsigned long)
30#define IOCTL_DISABLE_WDOG_TIMER _IO('s', 0xAD)
31#define IOCTL_UNMASK_WDOG_WAKEUP_EVENT _IO('s',0xAE)
32#define IOCTL_PROGRAM_WDOG_TIMER _IOW('s',0xAF,unsigned long)
33#define IOCTL_CLEAR_WDOG_WAKEUP_EVENT _IO('s',0xB0)
34#define IOCTL_SLEEP_DEEPER_MODE _IO('s',0xB1)
35
36#define DPMC_MINOR 254
37
38#define ON 0
39#define OFF 1
40
41#ifdef __KERNEL__ 10#ifdef __KERNEL__
11#ifndef __ASSEMBLY__
42 12
43unsigned long calc_volt(void);
44int calc_vlev(int vlt);
45unsigned long change_voltage(unsigned long volt);
46int calc_msel(int vco_hz);
47unsigned long change_frequency(unsigned long vco_mhz);
48int set_pll_div(unsigned short sel, unsigned char flag);
49int get_vco(void);
50unsigned long change_system_clock(unsigned long clock);
51unsigned long change_core_clock(unsigned long clock);
52unsigned long get_pll_status(void);
53void change_baud(int baud);
54void fullon_mode(void);
55void active_mode(void);
56void sleep_mode(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2); 13void sleep_mode(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2);
57void deep_sleep(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2); 14void deep_sleep(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2);
58void hibernate_mode(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2); 15void hibernate_mode(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2);
59void sleep_deeper(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2); 16void sleep_deeper(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2);
60void program_wdog_timer(unsigned long); 17void do_hibernate(int wakeup);
61void unmask_wdog_wakeup_evt(void); 18void set_dram_srfs(void);
62void clear_wdog_wakeup_evt(void); 19void unset_dram_srfs(void);
63void disable_wdog_timer(void);
64 20
65extern unsigned long get_cclk(void); 21#define VRPAIR(vlev, freq) (((vlev) << 16) | ((freq) >> 16))
66extern unsigned long get_sclk(void);
67 22
68struct bfin_dpmc_platform_data { 23struct bfin_dpmc_platform_data {
69 const unsigned int *tuple_tab; 24 const unsigned int *tuple_tab;
@@ -71,8 +26,33 @@ struct bfin_dpmc_platform_data {
71 unsigned short vr_settling_time; /* in us */ 26 unsigned short vr_settling_time; /* in us */
72}; 27};
73 28
74#define VRPAIR(vlev, freq) (((vlev) << 16) | ((freq) >> 16)) 29#else
30
31#define PM_PUSH(x) \
32 R0 = [P0 + (x - SRAM_BASE_ADDRESS)];\
33 [--SP] = R0;\
34
35#define PM_POP(x) \
36 R0 = [SP++];\
37 [P0 + (x - SRAM_BASE_ADDRESS)] = R0;\
38
39#define PM_SYS_PUSH(x) \
40 R0 = [P0 + (x - PLL_CTL)];\
41 [--SP] = R0;\
42
43#define PM_SYS_POP(x) \
44 R0 = [SP++];\
45 [P0 + (x - PLL_CTL)] = R0;\
46
47#define PM_SYS_PUSH16(x) \
48 R0 = w[P0 + (x - PLL_CTL)];\
49 [--SP] = R0;\
50
51#define PM_SYS_POP16(x) \
52 R0 = [SP++];\
53 w[P0 + (x - PLL_CTL)] = R0;\
75 54
55#endif
76#endif /* __KERNEL__ */ 56#endif /* __KERNEL__ */
77 57
78#endif /*_BLACKFIN_DPMC_H_*/ 58#endif /*_BLACKFIN_DPMC_H_*/
diff --git a/include/asm-blackfin/elf.h b/include/asm-blackfin/elf.h
index 30303fc8292c..67a03a8a353e 100644
--- a/include/asm-blackfin/elf.h
+++ b/include/asm-blackfin/elf.h
@@ -15,6 +15,8 @@
15#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */ 15#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */
16#define EF_BFIN_CODE_IN_L1 0x00000010 /* --code-in-l1 */ 16#define EF_BFIN_CODE_IN_L1 0x00000010 /* --code-in-l1 */
17#define EF_BFIN_DATA_IN_L1 0x00000020 /* --data-in-l1 */ 17#define EF_BFIN_DATA_IN_L1 0x00000020 /* --data-in-l1 */
18#define EF_BFIN_CODE_IN_L2 0x00000040 /* --code-in-l2 */
19#define EF_BFIN_DATA_IN_L2 0x00000080 /* --data-in-l2 */
18 20
19typedef unsigned long elf_greg_t; 21typedef unsigned long elf_greg_t;
20 22
diff --git a/include/asm-blackfin/gpio.h b/include/asm-blackfin/gpio.h
index ff95e9d88342..168f1251eb4d 100644
--- a/include/asm-blackfin/gpio.h
+++ b/include/asm-blackfin/gpio.h
@@ -376,8 +376,12 @@ struct gpio_port_t {
376#endif 376#endif
377 377
378#ifdef CONFIG_PM 378#ifdef CONFIG_PM
379unsigned int bfin_pm_setup(void); 379
380void bfin_pm_restore(void); 380unsigned int bfin_pm_standby_setup(void);
381void bfin_pm_standby_restore(void);
382
383void bfin_gpio_pm_hibernate_restore(void);
384void bfin_gpio_pm_hibernate_suspend(void);
381 385
382#ifndef CONFIG_BF54x 386#ifndef CONFIG_BF54x
383#define PM_WAKE_RISING 0x1 387#define PM_WAKE_RISING 0x1
@@ -392,17 +396,8 @@ void gpio_pm_wakeup_free(unsigned gpio);
392 396
393struct gpio_port_s { 397struct gpio_port_s {
394 unsigned short data; 398 unsigned short data;
395 unsigned short data_clear;
396 unsigned short data_set;
397 unsigned short toggle;
398 unsigned short maska; 399 unsigned short maska;
399 unsigned short maska_clear;
400 unsigned short maska_set;
401 unsigned short maska_toggle;
402 unsigned short maskb; 400 unsigned short maskb;
403 unsigned short maskb_clear;
404 unsigned short maskb_set;
405 unsigned short maskb_toggle;
406 unsigned short dir; 401 unsigned short dir;
407 unsigned short polar; 402 unsigned short polar;
408 unsigned short edge; 403 unsigned short edge;
@@ -411,10 +406,10 @@ struct gpio_port_s {
411 406
412 unsigned short fer; 407 unsigned short fer;
413 unsigned short reserved; 408 unsigned short reserved;
409 unsigned short mux;
414}; 410};
415#endif /*CONFIG_BF54x*/ 411#endif /*CONFIG_BF54x*/
416#endif /*CONFIG_PM*/ 412#endif /*CONFIG_PM*/
417
418/*********************************************************** 413/***********************************************************
419* 414*
420* FUNCTIONS: Blackfin GPIO Driver 415* FUNCTIONS: Blackfin GPIO Driver
diff --git a/include/asm-blackfin/mach-bf527/anomaly.h b/include/asm-blackfin/mach-bf527/anomaly.h
index 4725268a5ada..b7b166f4f064 100644
--- a/include/asm-blackfin/mach-bf527/anomaly.h
+++ b/include/asm-blackfin/mach-bf527/anomaly.h
@@ -23,6 +23,8 @@
23#define ANOMALY_05000245 (1) 23#define ANOMALY_05000245 (1)
24/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ 24/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */
25#define ANOMALY_05000265 (1) 25#define ANOMALY_05000265 (1)
26/* New Feature: EMAC TX DMA Word Alignment */
27#define ANOMALY_05000285 (1)
26/* Errors when SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */ 28/* Errors when SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */
27#define ANOMALY_05000312 (1) 29#define ANOMALY_05000312 (1)
28/* Incorrect Access of OTP_STATUS During otp_write() Function */ 30/* Incorrect Access of OTP_STATUS During otp_write() Function */
diff --git a/include/asm-blackfin/mach-bf527/bfin_sir.h b/include/asm-blackfin/mach-bf527/bfin_sir.h
index 0612d0c9501c..cfd8ad4f1f2c 100644
--- a/include/asm-blackfin/mach-bf527/bfin_sir.h
+++ b/include/asm-blackfin/mach-bf527/bfin_sir.h
@@ -118,16 +118,25 @@ static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
118 118
119#define DRIVER_NAME "bfin_sir" 119#define DRIVER_NAME "bfin_sir"
120 120
121static void bfin_sir_hw_init(void) 121static int bfin_sir_hw_init(void)
122{ 122{
123 int ret = -ENODEV;
123#ifdef CONFIG_BFIN_SIR0 124#ifdef CONFIG_BFIN_SIR0
124 peripheral_request(P_UART0_TX, DRIVER_NAME); 125 ret = peripheral_request(P_UART0_TX, DRIVER_NAME);
125 peripheral_request(P_UART0_RX, DRIVER_NAME); 126 if (ret)
127 return ret;
128 ret = peripheral_request(P_UART0_RX, DRIVER_NAME);
129 if (ret)
130 return ret;
126#endif 131#endif
127 132
128#ifdef CONFIG_BFIN_SIR1 133#ifdef CONFIG_BFIN_SIR1
129 peripheral_request(P_UART1_TX, DRIVER_NAME); 134 ret = peripheral_request(P_UART1_TX, DRIVER_NAME);
130 peripheral_request(P_UART1_RX, DRIVER_NAME); 135 if (ret)
136 return ret;
137 ret = peripheral_request(P_UART1_RX, DRIVER_NAME);
138 if (ret)
139 return ret;
131#endif 140#endif
132 SSYNC(); 141 return ret;
133} 142}
diff --git a/include/asm-blackfin/mach-bf527/defBF527.h b/include/asm-blackfin/mach-bf527/defBF527.h
index 82134f578f32..f1a70db70cb8 100644
--- a/include/asm-blackfin/mach-bf527/defBF527.h
+++ b/include/asm-blackfin/mach-bf527/defBF527.h
@@ -302,6 +302,7 @@
302#define PHYIE 0x00000001 /* PHY_INT Interrupt Enable */ 302#define PHYIE 0x00000001 /* PHY_INT Interrupt Enable */
303#define RXDWA 0x00000002 /* Receive Frame DMA Word Alignment (Odd/Even*) */ 303#define RXDWA 0x00000002 /* Receive Frame DMA Word Alignment (Odd/Even*) */
304#define RXCKS 0x00000004 /* Enable RX Frame TCP/UDP Checksum Computation */ 304#define RXCKS 0x00000004 /* Enable RX Frame TCP/UDP Checksum Computation */
305#define TXDWA 0x00000010 /* Transmit Frame DMA Word Alignment (Odd/Even*) */
305#define MDCDIV 0x00003F00 /* SCLK:MDC Clock Divisor [MDC=SCLK/(2*(N+1))] */ 306#define MDCDIV 0x00003F00 /* SCLK:MDC Clock Divisor [MDC=SCLK/(2*(N+1))] */
306 307
307#define SET_MDCDIV(x) (((x)&0x3F)<< 8) /* Set MDC Clock Divisor */ 308#define SET_MDCDIV(x) (((x)&0x3F)<< 8) /* Set MDC Clock Divisor */
diff --git a/include/asm-blackfin/mach-bf527/mem_init.h b/include/asm-blackfin/mach-bf527/mem_init.h
index 008ca66719e2..cbe03f4a5698 100644
--- a/include/asm-blackfin/mach-bf527/mem_init.h
+++ b/include/asm-blackfin/mach-bf527/mem_init.h
@@ -146,33 +146,6 @@
146#define SDRAM_CL CL_3 146#define SDRAM_CL CL_3
147#endif 147#endif
148 148
149#if (CONFIG_MEM_SIZE == 128)
150#define SDRAM_SIZE EBSZ_128
151#endif
152#if (CONFIG_MEM_SIZE == 64)
153#define SDRAM_SIZE EBSZ_64
154#endif
155#if (CONFIG_MEM_SIZE == 32)
156#define SDRAM_SIZE EBSZ_32
157#endif
158#if (CONFIG_MEM_SIZE == 16)
159#define SDRAM_SIZE EBSZ_16
160#endif
161#if (CONFIG_MEM_ADD_WIDTH == 11)
162#define SDRAM_WIDTH EBCAW_11
163#endif
164#if (CONFIG_MEM_ADD_WIDTH == 10)
165#define SDRAM_WIDTH EBCAW_10
166#endif
167#if (CONFIG_MEM_ADD_WIDTH == 9)
168#define SDRAM_WIDTH EBCAW_9
169#endif
170#if (CONFIG_MEM_ADD_WIDTH == 8)
171#define SDRAM_WIDTH EBCAW_8
172#endif
173
174#define mem_SDBCTL (SDRAM_WIDTH | SDRAM_SIZE | EBE)
175
176/* Equation from section 17 (p17-46) of BF533 HRM */ 149/* Equation from section 17 (p17-46) of BF533 HRM */
177#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num) 150#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
178 151
diff --git a/include/asm-blackfin/mach-bf533/bfin_sir.h b/include/asm-blackfin/mach-bf533/bfin_sir.h
index cefcf8bb505b..9bb87e9e2e9b 100644
--- a/include/asm-blackfin/mach-bf533/bfin_sir.h
+++ b/include/asm-blackfin/mach-bf533/bfin_sir.h
@@ -110,11 +110,16 @@ static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
110 110
111#define DRIVER_NAME "bfin_sir" 111#define DRIVER_NAME "bfin_sir"
112 112
113static void bfin_sir_hw_init(void) 113static int bfin_sir_hw_init(void)
114{ 114{
115 int ret = -ENODEV;
115#ifdef CONFIG_BFIN_SIR0 116#ifdef CONFIG_BFIN_SIR0
116 peripheral_request(P_UART0_TX, DRIVER_NAME); 117 ret = peripheral_request(P_UART0_TX, DRIVER_NAME);
117 peripheral_request(P_UART0_RX, DRIVER_NAME); 118 if (ret)
119 return ret;
120 ret = peripheral_request(P_UART0_RX, DRIVER_NAME);
121 if (ret)
122 return ret;
118#endif 123#endif
119 SSYNC(); 124 return ret;
120} 125}
diff --git a/include/asm-blackfin/mach-bf533/mem_init.h b/include/asm-blackfin/mach-bf533/mem_init.h
index f8f31901fca9..995c06b2b1ef 100644
--- a/include/asm-blackfin/mach-bf533/mem_init.h
+++ b/include/asm-blackfin/mach-bf533/mem_init.h
@@ -133,33 +133,6 @@
133#define SDRAM_CL CL_3 133#define SDRAM_CL CL_3
134#endif 134#endif
135 135
136#if (CONFIG_MEM_SIZE == 128)
137#define SDRAM_SIZE EBSZ_128
138#endif
139#if (CONFIG_MEM_SIZE == 64)
140#define SDRAM_SIZE EBSZ_64
141#endif
142#if (CONFIG_MEM_SIZE == 32)
143#define SDRAM_SIZE EBSZ_32
144#endif
145#if (CONFIG_MEM_SIZE == 16)
146#define SDRAM_SIZE EBSZ_16
147#endif
148#if (CONFIG_MEM_ADD_WIDTH == 11)
149#define SDRAM_WIDTH EBCAW_11
150#endif
151#if (CONFIG_MEM_ADD_WIDTH == 10)
152#define SDRAM_WIDTH EBCAW_10
153#endif
154#if (CONFIG_MEM_ADD_WIDTH == 9)
155#define SDRAM_WIDTH EBCAW_9
156#endif
157#if (CONFIG_MEM_ADD_WIDTH == 8)
158#define SDRAM_WIDTH EBCAW_8
159#endif
160
161#define mem_SDBCTL (SDRAM_WIDTH | SDRAM_SIZE | EBE)
162
163/* Equation from section 17 (p17-46) of BF533 HRM */ 136/* Equation from section 17 (p17-46) of BF533 HRM */
164#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num) 137#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
165 138
diff --git a/include/asm-blackfin/mach-bf537/bfin_sir.h b/include/asm-blackfin/mach-bf537/bfin_sir.h
index 0612d0c9501c..cfd8ad4f1f2c 100644
--- a/include/asm-blackfin/mach-bf537/bfin_sir.h
+++ b/include/asm-blackfin/mach-bf537/bfin_sir.h
@@ -118,16 +118,25 @@ static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
118 118
119#define DRIVER_NAME "bfin_sir" 119#define DRIVER_NAME "bfin_sir"
120 120
121static void bfin_sir_hw_init(void) 121static int bfin_sir_hw_init(void)
122{ 122{
123 int ret = -ENODEV;
123#ifdef CONFIG_BFIN_SIR0 124#ifdef CONFIG_BFIN_SIR0
124 peripheral_request(P_UART0_TX, DRIVER_NAME); 125 ret = peripheral_request(P_UART0_TX, DRIVER_NAME);
125 peripheral_request(P_UART0_RX, DRIVER_NAME); 126 if (ret)
127 return ret;
128 ret = peripheral_request(P_UART0_RX, DRIVER_NAME);
129 if (ret)
130 return ret;
126#endif 131#endif
127 132
128#ifdef CONFIG_BFIN_SIR1 133#ifdef CONFIG_BFIN_SIR1
129 peripheral_request(P_UART1_TX, DRIVER_NAME); 134 ret = peripheral_request(P_UART1_TX, DRIVER_NAME);
130 peripheral_request(P_UART1_RX, DRIVER_NAME); 135 if (ret)
136 return ret;
137 ret = peripheral_request(P_UART1_RX, DRIVER_NAME);
138 if (ret)
139 return ret;
131#endif 140#endif
132 SSYNC(); 141 return ret;
133} 142}
diff --git a/include/asm-blackfin/mach-bf537/defBF537.h b/include/asm-blackfin/mach-bf537/defBF537.h
index 3f455909c418..abde24c6d3b1 100644
--- a/include/asm-blackfin/mach-bf537/defBF537.h
+++ b/include/asm-blackfin/mach-bf537/defBF537.h
@@ -290,6 +290,7 @@
290#define PHYIE 0x00000001 /* PHY_INT Interrupt Enable */ 290#define PHYIE 0x00000001 /* PHY_INT Interrupt Enable */
291#define RXDWA 0x00000002 /* Receive Frame DMA Word Alignment (Odd/Even*) */ 291#define RXDWA 0x00000002 /* Receive Frame DMA Word Alignment (Odd/Even*) */
292#define RXCKS 0x00000004 /* Enable RX Frame TCP/UDP Checksum Computation */ 292#define RXCKS 0x00000004 /* Enable RX Frame TCP/UDP Checksum Computation */
293#define TXDWA 0x00000010 /* Transmit Frame DMA Word Alignment (Odd/Even*) */
293#define MDCDIV 0x00003F00 /* SCLK:MDC Clock Divisor [MDC=SCLK/(2*(N+1))] */ 294#define MDCDIV 0x00003F00 /* SCLK:MDC Clock Divisor [MDC=SCLK/(2*(N+1))] */
294 295
295#define SET_MDCDIV(x) (((x)&0x3F)<< 8) /* Set MDC Clock Divisor */ 296#define SET_MDCDIV(x) (((x)&0x3F)<< 8) /* Set MDC Clock Divisor */
diff --git a/include/asm-blackfin/mach-bf537/mem_init.h b/include/asm-blackfin/mach-bf537/mem_init.h
index 9ad979d416c6..f67698f670ca 100644
--- a/include/asm-blackfin/mach-bf537/mem_init.h
+++ b/include/asm-blackfin/mach-bf537/mem_init.h
@@ -139,33 +139,6 @@
139#define SDRAM_CL CL_3 139#define SDRAM_CL CL_3
140#endif 140#endif
141 141
142#if (CONFIG_MEM_SIZE == 128)
143#define SDRAM_SIZE EBSZ_128
144#endif
145#if (CONFIG_MEM_SIZE == 64)
146#define SDRAM_SIZE EBSZ_64
147#endif
148#if (CONFIG_MEM_SIZE == 32)
149#define SDRAM_SIZE EBSZ_32
150#endif
151#if (CONFIG_MEM_SIZE == 16)
152#define SDRAM_SIZE EBSZ_16
153#endif
154#if (CONFIG_MEM_ADD_WIDTH == 11)
155#define SDRAM_WIDTH EBCAW_11
156#endif
157#if (CONFIG_MEM_ADD_WIDTH == 10)
158#define SDRAM_WIDTH EBCAW_10
159#endif
160#if (CONFIG_MEM_ADD_WIDTH == 9)
161#define SDRAM_WIDTH EBCAW_9
162#endif
163#if (CONFIG_MEM_ADD_WIDTH == 8)
164#define SDRAM_WIDTH EBCAW_8
165#endif
166
167#define mem_SDBCTL (SDRAM_WIDTH | SDRAM_SIZE | EBE)
168
169/* Equation from section 17 (p17-46) of BF533 HRM */ 142/* Equation from section 17 (p17-46) of BF533 HRM */
170#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num) 143#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
171 144
diff --git a/include/asm-blackfin/mach-bf548/bfin_sir.h b/include/asm-blackfin/mach-bf548/bfin_sir.h
index 5e94271c7e3b..c41f9cf00268 100644
--- a/include/asm-blackfin/mach-bf548/bfin_sir.h
+++ b/include/asm-blackfin/mach-bf548/bfin_sir.h
@@ -124,26 +124,43 @@ struct bfin_sir_self {
124 124
125#define DRIVER_NAME "bfin_sir" 125#define DRIVER_NAME "bfin_sir"
126 126
127static void bfin_sir_hw_init(void) 127static int bfin_sir_hw_init(void)
128{ 128{
129 int ret = -ENODEV;
129#ifdef CONFIG_BFIN_SIR0 130#ifdef CONFIG_BFIN_SIR0
130 peripheral_request(P_UART0_TX, DRIVER_NAME); 131 ret = peripheral_request(P_UART0_TX, DRIVER_NAME);
131 peripheral_request(P_UART0_RX, DRIVER_NAME); 132 if (ret)
133 return ret;
134 ret = peripheral_request(P_UART0_RX, DRIVER_NAME);
135 if (ret)
136 return ret;
132#endif 137#endif
133 138
134#ifdef CONFIG_BFIN_SIR1 139#ifdef CONFIG_BFIN_SIR1
135 peripheral_request(P_UART1_TX, DRIVER_NAME); 140 ret = peripheral_request(P_UART1_TX, DRIVER_NAME);
136 peripheral_request(P_UART1_RX, DRIVER_NAME); 141 if (ret)
142 return ret;
143 ret = peripheral_request(P_UART1_RX, DRIVER_NAME);
144 if (ret)
145 return ret;
137#endif 146#endif
138 147
139#ifdef CONFIG_BFIN_SIR2 148#ifdef CONFIG_BFIN_SIR2
140 peripheral_request(P_UART2_TX, DRIVER_NAME); 149 ret = peripheral_request(P_UART2_TX, DRIVER_NAME);
141 peripheral_request(P_UART2_RX, DRIVER_NAME); 150 if (ret)
151 return ret;
152 ret = peripheral_request(P_UART2_RX, DRIVER_NAME);
153 if (ret)
154 return ret;
142#endif 155#endif
143 156
144#ifdef CONFIG_BFIN_SIR3 157#ifdef CONFIG_BFIN_SIR3
145 peripheral_request(P_UART3_TX, DRIVER_NAME); 158 ret = peripheral_request(P_UART3_TX, DRIVER_NAME);
146 peripheral_request(P_UART3_RX, DRIVER_NAME); 159 if (ret)
160 return ret;
161 ret = peripheral_request(P_UART3_RX, DRIVER_NAME);
162 if (ret)
163 return ret;
147#endif 164#endif
148 SSYNC(); 165 return ret;
149} 166}
diff --git a/include/asm-blackfin/mach-bf548/gpio.h b/include/asm-blackfin/mach-bf548/gpio.h
index cb8b0f15c9a6..bba82dc75f16 100644
--- a/include/asm-blackfin/mach-bf548/gpio.h
+++ b/include/asm-blackfin/mach-bf548/gpio.h
@@ -209,3 +209,11 @@ struct gpio_port_t {
209 unsigned short dummy7; 209 unsigned short dummy7;
210 unsigned int port_mux; 210 unsigned int port_mux;
211}; 211};
212
213struct gpio_port_s {
214 unsigned short fer;
215 unsigned short data;
216 unsigned short dir;
217 unsigned short inen;
218 unsigned int mux;
219};
diff --git a/include/asm-blackfin/mach-bf561/bfin_sir.h b/include/asm-blackfin/mach-bf561/bfin_sir.h
index cefcf8bb505b..9bb87e9e2e9b 100644
--- a/include/asm-blackfin/mach-bf561/bfin_sir.h
+++ b/include/asm-blackfin/mach-bf561/bfin_sir.h
@@ -110,11 +110,16 @@ static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
110 110
111#define DRIVER_NAME "bfin_sir" 111#define DRIVER_NAME "bfin_sir"
112 112
113static void bfin_sir_hw_init(void) 113static int bfin_sir_hw_init(void)
114{ 114{
115 int ret = -ENODEV;
115#ifdef CONFIG_BFIN_SIR0 116#ifdef CONFIG_BFIN_SIR0
116 peripheral_request(P_UART0_TX, DRIVER_NAME); 117 ret = peripheral_request(P_UART0_TX, DRIVER_NAME);
117 peripheral_request(P_UART0_RX, DRIVER_NAME); 118 if (ret)
119 return ret;
120 ret = peripheral_request(P_UART0_RX, DRIVER_NAME);
121 if (ret)
122 return ret;
118#endif 123#endif
119 SSYNC(); 124 return ret;
120} 125}
diff --git a/include/asm-blackfin/mach-bf561/mem_init.h b/include/asm-blackfin/mach-bf561/mem_init.h
index 439a5895b346..e163260bca18 100644
--- a/include/asm-blackfin/mach-bf561/mem_init.h
+++ b/include/asm-blackfin/mach-bf561/mem_init.h
@@ -131,33 +131,6 @@
131#define SDRAM_CL CL_3 131#define SDRAM_CL CL_3
132#endif 132#endif
133 133
134#if (CONFIG_MEM_SIZE == 128)
135#define SDRAM_SIZE EB0_SZ_128
136#endif
137#if (CONFIG_MEM_SIZE == 64)
138#define SDRAM_SIZE EB0_SZ_64
139#endif
140#if ( CONFIG_MEM_SIZE == 32)
141#define SDRAM_SIZE EB0_SZ_32
142#endif
143#if (CONFIG_MEM_SIZE == 16)
144#define SDRAM_SIZE EB0_SZ_16
145#endif
146#if (CONFIG_MEM_ADD_WIDTH == 11)
147#define SDRAM_WIDTH EB0_CAW_11
148#endif
149#if (CONFIG_MEM_ADD_WIDTH == 10)
150#define SDRAM_WIDTH EB0_CAW_10
151#endif
152#if (CONFIG_MEM_ADD_WIDTH == 9)
153#define SDRAM_WIDTH EB0_CAW_9
154#endif
155#if (CONFIG_MEM_ADD_WIDTH == 8)
156#define SDRAM_WIDTH EB0_CAW_8
157#endif
158
159#define mem_SDBCTL (SDRAM_WIDTH | SDRAM_SIZE | EB0_E)
160
161/* Equation from section 17 (p17-46) of BF533 HRM */ 134/* Equation from section 17 (p17-46) of BF533 HRM */
162#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num) 135#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
163 136
diff --git a/include/asm-blackfin/module.h b/include/asm-blackfin/module.h
index 3c7ce1644280..e3128df139d6 100644
--- a/include/asm-blackfin/module.h
+++ b/include/asm-blackfin/module.h
@@ -6,8 +6,6 @@
6#define Elf_Shdr Elf32_Shdr 6#define Elf_Shdr Elf32_Shdr
7#define Elf_Sym Elf32_Sym 7#define Elf_Sym Elf32_Sym
8#define Elf_Ehdr Elf32_Ehdr 8#define Elf_Ehdr Elf32_Ehdr
9#define FLG_CODE_IN_L1 0x10
10#define FLG_DATA_IN_L1 0x20
11 9
12struct mod_arch_specific { 10struct mod_arch_specific {
13 Elf_Shdr *text_l1; 11 Elf_Shdr *text_l1;
@@ -15,5 +13,8 @@ struct mod_arch_specific {
15 Elf_Shdr *bss_a_l1; 13 Elf_Shdr *bss_a_l1;
16 Elf_Shdr *data_b_l1; 14 Elf_Shdr *data_b_l1;
17 Elf_Shdr *bss_b_l1; 15 Elf_Shdr *bss_b_l1;
16 Elf_Shdr *text_l2;
17 Elf_Shdr *data_l2;
18 Elf_Shdr *bss_l2;
18}; 19};
19#endif /* _ASM_BFIN_MODULE_H */ 20#endif /* _ASM_BFIN_MODULE_H */
diff --git a/include/asm-blackfin/namei.h b/include/asm-blackfin/namei.h
deleted file mode 100644
index 8b89a2d65cb4..000000000000
--- a/include/asm-blackfin/namei.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * linux/include/asm/namei.h
3 *
4 * Included from linux/fs/namei.c
5 *
6 * Changes made by Lineo Inc. May 2001
7 */
8
9#ifndef __BFIN_NAMEI_H
10#define __BFIN_NAMEI_H
11
12/* This dummy routine maybe changed to something useful
13 * for /usr/gnemul/ emulation stuff.
14 * Look at asm-sparc/namei.h for details.
15 */
16
17#define __emul_prefix() NULL
18
19#endif
diff --git a/include/asm-blackfin/processor.h b/include/asm-blackfin/processor.h
index 1c0040724612..6f3995b119d8 100644
--- a/include/asm-blackfin/processor.h
+++ b/include/asm-blackfin/processor.h
@@ -112,7 +112,26 @@ unsigned long get_wchan(struct task_struct *p);
112static inline uint32_t __pure bfin_revid(void) 112static inline uint32_t __pure bfin_revid(void)
113{ 113{
114 /* stored in the upper 4 bits */ 114 /* stored in the upper 4 bits */
115 return bfin_read_CHIPID() >> 28; 115 uint32_t revid = bfin_read_CHIPID() >> 28;
116
117#ifdef CONFIG_BF52x
118 /* ANOMALY_05000357
119 * Incorrect Revision Number in DSPID Register
120 */
121 if (revid == 0)
122 switch (bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI)) {
123 case 0x0010:
124 revid = 0;
125 break;
126 case 0x2796:
127 revid = 1;
128 break;
129 default:
130 revid = 0xFFFF;
131 break;
132 }
133#endif
134 return revid;
116} 135}
117 136
118static inline uint32_t __pure bfin_compiled_revid(void) 137static inline uint32_t __pure bfin_compiled_revid(void)
diff --git a/include/asm-cris/dma-mapping.h b/include/asm-cris/dma-mapping.h
index edc8d1bfaae2..da8ef8e8f842 100644
--- a/include/asm-cris/dma-mapping.h
+++ b/include/asm-cris/dma-mapping.h
@@ -14,6 +14,8 @@
14#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 14#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
15 15
16#ifdef CONFIG_PCI 16#ifdef CONFIG_PCI
17#include <asm-generic/dma-coherent.h>
18
17void *dma_alloc_coherent(struct device *dev, size_t size, 19void *dma_alloc_coherent(struct device *dev, size_t size,
18 dma_addr_t *dma_handle, gfp_t flag); 20 dma_addr_t *dma_handle, gfp_t flag);
19 21
@@ -120,7 +122,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
120} 122}
121 123
122static inline int 124static inline int
123dma_mapping_error(dma_addr_t dma_addr) 125dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
124{ 126{
125 return 0; 127 return 0;
126} 128}
diff --git a/include/asm-cris/namei.h b/include/asm-cris/namei.h
deleted file mode 100644
index 8a3be7a6d9f6..000000000000
--- a/include/asm-cris/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* $Id: namei.h,v 1.1 2000/07/10 16:32:31 bjornw Exp $
2 * linux/include/asm-cris/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __CRIS_NAMEI_H
8#define __CRIS_NAMEI_H
9
10/* used to find file-system prefixes for doing emulations
11 * see for example asm-sparc/namei.h
12 * we don't use it...
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* __CRIS_NAMEI_H */
diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h
index 2e8966ca030d..b2898877c07b 100644
--- a/include/asm-frv/dma-mapping.h
+++ b/include/asm-frv/dma-mapping.h
@@ -126,7 +126,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
126} 126}
127 127
128static inline 128static inline
129int dma_mapping_error(dma_addr_t dma_addr) 129int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
130{ 130{
131 return 0; 131 return 0;
132} 132}
diff --git a/include/asm-frv/namei.h b/include/asm-frv/namei.h
deleted file mode 100644
index 4ea57171d951..000000000000
--- a/include/asm-frv/namei.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * include/asm-frv/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __ASM_NAMEI_H
8#define __ASM_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif
18
diff --git a/include/asm-generic/dma-coherent.h b/include/asm-generic/dma-coherent.h
new file mode 100644
index 000000000000..85a3ffaa0242
--- /dev/null
+++ b/include/asm-generic/dma-coherent.h
@@ -0,0 +1,32 @@
1#ifndef DMA_COHERENT_H
2#define DMA_COHERENT_H
3
4#ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
5/*
6 * These two functions are only for dma allocator.
7 * Don't use them in device drivers.
8 */
9int dma_alloc_from_coherent(struct device *dev, ssize_t size,
10 dma_addr_t *dma_handle, void **ret);
11int dma_release_from_coherent(struct device *dev, int order, void *vaddr);
12
13/*
14 * Standard interface
15 */
16#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
17extern int
18dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
19 dma_addr_t device_addr, size_t size, int flags);
20
21extern void
22dma_release_declared_memory(struct device *dev);
23
24extern void *
25dma_mark_declared_memory_occupied(struct device *dev,
26 dma_addr_t device_addr, size_t size);
27#else
28#define dma_alloc_from_coherent(dev, size, handle, ret) (0)
29#define dma_release_from_coherent(dev, order, vaddr) (0)
30#endif
31
32#endif
diff --git a/include/asm-generic/dma-mapping-broken.h b/include/asm-generic/dma-mapping-broken.h
index e2468f894d2a..82cd0cb1c3fe 100644
--- a/include/asm-generic/dma-mapping-broken.h
+++ b/include/asm-generic/dma-mapping-broken.h
@@ -61,7 +61,7 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
61#define dma_sync_sg_for_device dma_sync_sg_for_cpu 61#define dma_sync_sg_for_device dma_sync_sg_for_cpu
62 62
63extern int 63extern int
64dma_mapping_error(dma_addr_t dma_addr); 64dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
65 65
66extern int 66extern int
67dma_supported(struct device *dev, u64 mask); 67dma_supported(struct device *dev, u64 mask);
diff --git a/include/asm-generic/dma-mapping.h b/include/asm-generic/dma-mapping.h
index 783ab9944d70..189486c3f92e 100644
--- a/include/asm-generic/dma-mapping.h
+++ b/include/asm-generic/dma-mapping.h
@@ -144,9 +144,9 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
144} 144}
145 145
146static inline int 146static inline int
147dma_mapping_error(dma_addr_t dma_addr) 147dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
148{ 148{
149 return pci_dma_mapping_error(dma_addr); 149 return pci_dma_mapping_error(to_pci_dev(dev), dma_addr);
150} 150}
151 151
152 152
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index a3034d20ebd5..0f99ad38b012 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -2,6 +2,7 @@
2#define _ASM_GENERIC_GPIO_H 2#define _ASM_GENERIC_GPIO_H
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/errno.h>
5 6
6#ifdef CONFIG_GPIOLIB 7#ifdef CONFIG_GPIOLIB
7 8
@@ -13,7 +14,7 @@
13 * 14 *
14 * While the GPIO programming interface defines valid GPIO numbers 15 * While the GPIO programming interface defines valid GPIO numbers
15 * to be in the range 0..MAX_INT, this library restricts them to the 16 * to be in the range 0..MAX_INT, this library restricts them to the
16 * smaller range 0..ARCH_NR_GPIOS. 17 * smaller range 0..ARCH_NR_GPIOS-1.
17 */ 18 */
18 19
19#ifndef ARCH_NR_GPIOS 20#ifndef ARCH_NR_GPIOS
diff --git a/include/asm-generic/pci-dma-compat.h b/include/asm-generic/pci-dma-compat.h
index 25c10e96b2b7..37b3706226e7 100644
--- a/include/asm-generic/pci-dma-compat.h
+++ b/include/asm-generic/pci-dma-compat.h
@@ -99,9 +99,9 @@ pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
99} 99}
100 100
101static inline int 101static inline int
102pci_dma_mapping_error(dma_addr_t dma_addr) 102pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
103{ 103{
104 return dma_mapping_error(dma_addr); 104 return dma_mapping_error(&pdev->dev, dma_addr);
105} 105}
106 106
107#endif 107#endif
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 087325ede76c..a7cdc48e8b78 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -5,6 +5,8 @@
5 5
6#include <asm-generic/pgtable-nopud.h> 6#include <asm-generic/pgtable-nopud.h>
7 7
8struct mm_struct;
9
8#define __PAGETABLE_PMD_FOLDED 10#define __PAGETABLE_PMD_FOLDED
9 11
10/* 12/*
@@ -54,7 +56,9 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
54 * inside the pud, so has no extra memory associated with it. 56 * inside the pud, so has no extra memory associated with it.
55 */ 57 */
56#define pmd_alloc_one(mm, address) NULL 58#define pmd_alloc_one(mm, address) NULL
57#define pmd_free(mm, x) do { } while (0) 59static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
60{
61}
58#define __pmd_free_tlb(tlb, x) do { } while (0) 62#define __pmd_free_tlb(tlb, x) do { } while (0)
59 63
60#undef pmd_addr_end 64#undef pmd_addr_end
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
new file mode 100644
index 000000000000..abcf34c2fdc7
--- /dev/null
+++ b/include/asm-generic/syscall.h
@@ -0,0 +1,141 @@
1/*
2 * Access to user system call parameters and results
3 *
4 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
9 *
10 * This file is a stub providing documentation for what functions
11 * asm-ARCH/syscall.h files need to define. Most arch definitions
12 * will be simple inlines.
13 *
14 * All of these functions expect to be called with no locks,
15 * and only when the caller is sure that the task of interest
16 * cannot return to user mode while we are looking at it.
17 */
18
19#ifndef _ASM_SYSCALL_H
20#define _ASM_SYSCALL_H 1
21
22struct task_struct;
23struct pt_regs;
24
25/**
26 * syscall_get_nr - find what system call a task is executing
27 * @task: task of interest, must be blocked
28 * @regs: task_pt_regs() of @task
29 *
30 * If @task is executing a system call or is at system call
31 * tracing about to attempt one, returns the system call number.
32 * If @task is not executing a system call, i.e. it's blocked
33 * inside the kernel for a fault or signal, returns -1.
34 *
35 * It's only valid to call this when @task is known to be blocked.
36 */
37long syscall_get_nr(struct task_struct *task, struct pt_regs *regs);
38
39/**
40 * syscall_rollback - roll back registers after an aborted system call
41 * @task: task of interest, must be in system call exit tracing
42 * @regs: task_pt_regs() of @task
43 *
44 * It's only valid to call this when @task is stopped for system
45 * call exit tracing (due to TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT),
46 * after tracehook_report_syscall_entry() returned nonzero to prevent
47 * the system call from taking place.
48 *
49 * This rolls back the register state in @regs so it's as if the
50 * system call instruction was a no-op. The registers containing
51 * the system call number and arguments are as they were before the
52 * system call instruction. This may not be the same as what the
53 * register state looked like at system call entry tracing.
54 */
55void syscall_rollback(struct task_struct *task, struct pt_regs *regs);
56
57/**
58 * syscall_get_error - check result of traced system call
59 * @task: task of interest, must be blocked
60 * @regs: task_pt_regs() of @task
61 *
62 * Returns 0 if the system call succeeded, or -ERRORCODE if it failed.
63 *
64 * It's only valid to call this when @task is stopped for tracing on exit
65 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
66 */
67long syscall_get_error(struct task_struct *task, struct pt_regs *regs);
68
69/**
70 * syscall_get_return_value - get the return value of a traced system call
71 * @task: task of interest, must be blocked
72 * @regs: task_pt_regs() of @task
73 *
74 * Returns the return value of the successful system call.
75 * This value is meaningless if syscall_get_error() returned nonzero.
76 *
77 * It's only valid to call this when @task is stopped for tracing on exit
78 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
79 */
80long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs);
81
82/**
83 * syscall_set_return_value - change the return value of a traced system call
84 * @task: task of interest, must be blocked
85 * @regs: task_pt_regs() of @task
86 * @error: negative error code, or zero to indicate success
87 * @val: user return value if @error is zero
88 *
89 * This changes the results of the system call that user mode will see.
90 * If @error is zero, the user sees a successful system call with a
91 * return value of @val. If @error is nonzero, it's a negated errno
92 * code; the user sees a failed system call with this errno code.
93 *
94 * It's only valid to call this when @task is stopped for tracing on exit
95 * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
96 */
97void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
98 int error, long val);
99
100/**
101 * syscall_get_arguments - extract system call parameter values
102 * @task: task of interest, must be blocked
103 * @regs: task_pt_regs() of @task
104 * @i: argument index [0,5]
105 * @n: number of arguments; n+i must be [1,6].
106 * @args: array filled with argument values
107 *
108 * Fetches @n arguments to the system call starting with the @i'th argument
109 * (from 0 through 5). Argument @i is stored in @args[0], and so on.
110 * An arch inline version is probably optimal when @i and @n are constants.
111 *
112 * It's only valid to call this when @task is stopped for tracing on
113 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
114 * It's invalid to call this with @i + @n > 6; we only support system calls
115 * taking up to 6 arguments.
116 */
117void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
118 unsigned int i, unsigned int n, unsigned long *args);
119
120/**
121 * syscall_set_arguments - change system call parameter value
122 * @task: task of interest, must be in system call entry tracing
123 * @regs: task_pt_regs() of @task
124 * @i: argument index [0,5]
125 * @n: number of arguments; n+i must be [1,6].
126 * @args: array of argument values to store
127 *
128 * Changes @n arguments to the system call starting with the @i'th argument.
129 * @n'th argument to @val. Argument @i gets value @args[0], and so on.
130 * An arch inline version is probably optimal when @i and @n are constants.
131 *
132 * It's only valid to call this when @task is stopped for tracing on
133 * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
134 * It's invalid to call this with @i + @n > 6; we only support system calls
135 * taking up to 6 arguments.
136 */
137void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
138 unsigned int i, unsigned int n,
139 const unsigned long *args);
140
141#endif /* _ASM_SYSCALL_H */
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 729f6b0a60e9..6d88a923c945 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -221,6 +221,7 @@
221 * during second ld run in second ld pass when generating System.map */ 221 * during second ld run in second ld pass when generating System.map */
222#define TEXT_TEXT \ 222#define TEXT_TEXT \
223 ALIGN_FUNCTION(); \ 223 ALIGN_FUNCTION(); \
224 *(.text.hot) \
224 *(.text) \ 225 *(.text) \
225 *(.ref.text) \ 226 *(.ref.text) \
226 *(.text.init.refok) \ 227 *(.text.init.refok) \
@@ -230,7 +231,8 @@
230 CPU_KEEP(init.text) \ 231 CPU_KEEP(init.text) \
231 CPU_KEEP(exit.text) \ 232 CPU_KEEP(exit.text) \
232 MEM_KEEP(init.text) \ 233 MEM_KEEP(init.text) \
233 MEM_KEEP(exit.text) 234 MEM_KEEP(exit.text) \
235 *(.text.unlikely)
234 236
235 237
236/* sched.text is aling to function alignment to secure we have same 238/* sched.text is aling to function alignment to secure we have same
@@ -359,6 +361,8 @@
359 } 361 }
360 362
361#define INITCALLS \ 363#define INITCALLS \
364 *(.initcallearly.init) \
365 __early_initcall_end = .; \
362 *(.initcall0.init) \ 366 *(.initcall0.init) \
363 *(.initcall0s.init) \ 367 *(.initcall0s.init) \
364 *(.initcall1.init) \ 368 *(.initcall1.init) \
diff --git a/include/asm-h8300/namei.h b/include/asm-h8300/namei.h
deleted file mode 100644
index ab6f196db6e0..000000000000
--- a/include/asm-h8300/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * linux/include/asm-h8300/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __H8300_NAMEI_H
8#define __H8300_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif
diff --git a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
index 0721a5e8271e..a6d50c77b6bf 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
@@ -54,7 +54,7 @@ typedef void ia64_mv_dma_sync_single_for_cpu (struct device *, dma_addr_t, size_
54typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, int); 54typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, int);
55typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, int); 55typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, int);
56typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, int); 56typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, int);
57typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr); 57typedef int ia64_mv_dma_mapping_error(struct device *, dma_addr_t dma_addr);
58typedef int ia64_mv_dma_supported (struct device *, u64); 58typedef int ia64_mv_dma_supported (struct device *, u64);
59 59
60typedef dma_addr_t ia64_mv_dma_map_single_attrs (struct device *, void *, size_t, int, struct dma_attrs *); 60typedef dma_addr_t ia64_mv_dma_map_single_attrs (struct device *, void *, size_t, int, struct dma_attrs *);
diff --git a/include/asm-ia64/namei.h b/include/asm-ia64/namei.h
deleted file mode 100644
index 78e768079083..000000000000
--- a/include/asm-ia64/namei.h
+++ /dev/null
@@ -1,25 +0,0 @@
1#ifndef _ASM_IA64_NAMEI_H
2#define _ASM_IA64_NAMEI_H
3
4/*
5 * Modified 1998, 1999, 2001
6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7 */
8
9#include <asm/ptrace.h>
10#include <asm/system.h>
11
12#define EMUL_PREFIX_LINUX_IA32 "/emul/ia32-linux/"
13
14static inline char *
15__emul_prefix (void)
16{
17 switch (current->personality) {
18 case PER_LINUX32:
19 return EMUL_PREFIX_LINUX_IA32;
20 default:
21 return NULL;
22 }
23}
24
25#endif /* _ASM_IA64_NAMEI_H */
diff --git a/include/asm-m32r/namei.h b/include/asm-m32r/namei.h
deleted file mode 100644
index 210f8056b805..000000000000
--- a/include/asm-m32r/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _ASM_M32R_NAMEI_H
2#define _ASM_M32R_NAMEI_H
3
4/*
5 * linux/include/asm-m32r/namei.h
6 *
7 * Included from linux/fs/namei.c
8 */
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* _ASM_M32R_NAMEI_H */
diff --git a/include/asm-m68k/dma-mapping.h b/include/asm-m68k/dma-mapping.h
index a26cdeb46a57..91f7944333d4 100644
--- a/include/asm-m68k/dma-mapping.h
+++ b/include/asm-m68k/dma-mapping.h
@@ -84,7 +84,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *s
84{ 84{
85} 85}
86 86
87static inline int dma_mapping_error(dma_addr_t handle) 87static inline int dma_mapping_error(struct device *dev, dma_addr_t handle)
88{ 88{
89 return 0; 89 return 0;
90} 90}
diff --git a/include/asm-m68k/namei.h b/include/asm-m68k/namei.h
deleted file mode 100644
index f33f243b644a..000000000000
--- a/include/asm-m68k/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * linux/include/asm-m68k/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __M68K_NAMEI_H
8#define __M68K_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif
diff --git a/include/asm-m68knommu/namei.h b/include/asm-m68knommu/namei.h
deleted file mode 100644
index 31a85d27b931..000000000000
--- a/include/asm-m68knommu/namei.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-m68k/namei.h>
diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index 230b3f1b69b1..c64afb40cd06 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -42,7 +42,7 @@ extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
42 int nelems, enum dma_data_direction direction); 42 int nelems, enum dma_data_direction direction);
43extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, 43extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
44 int nelems, enum dma_data_direction direction); 44 int nelems, enum dma_data_direction direction);
45extern int dma_mapping_error(dma_addr_t dma_addr); 45extern int dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
46extern int dma_supported(struct device *dev, u64 mask); 46extern int dma_supported(struct device *dev, u64 mask);
47 47
48static inline int 48static inline int
diff --git a/include/asm-mips/namei.h b/include/asm-mips/namei.h
deleted file mode 100644
index a6605a752469..000000000000
--- a/include/asm-mips/namei.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef _ASM_NAMEI_H
2#define _ASM_NAMEI_H
3
4/*
5 * This dummy routine maybe changed to something useful
6 * for /usr/gnemul/ emulation stuff.
7 */
8
9#define __emul_prefix() NULL
10
11#endif /* _ASM_NAMEI_H */
diff --git a/include/asm-mn10300/dma-mapping.h b/include/asm-mn10300/dma-mapping.h
index 7c882fca9ec8..ccae8f6c6326 100644
--- a/include/asm-mn10300/dma-mapping.h
+++ b/include/asm-mn10300/dma-mapping.h
@@ -182,7 +182,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
182} 182}
183 183
184static inline 184static inline
185int dma_mapping_error(dma_addr_t dma_addr) 185int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
186{ 186{
187 return 0; 187 return 0;
188} 188}
diff --git a/include/asm-mn10300/namei.h b/include/asm-mn10300/namei.h
deleted file mode 100644
index bd9ce94aeb65..000000000000
--- a/include/asm-mn10300/namei.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* Emulation stuff
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_NAMEI_H
13#define _ASM_NAMEI_H
14
15/* This dummy routine maybe changed to something useful
16 * for /usr/gnemul/ emulation stuff.
17 * Look at asm-sparc/namei.h for details.
18 */
19
20#define __emul_prefix() NULL
21
22#endif /* _ASM_NAMEI_H */
diff --git a/include/asm-parisc/cacheflush.h b/include/asm-parisc/cacheflush.h
index 2f1e1b05440a..b7ca6dc7fddc 100644
--- a/include/asm-parisc/cacheflush.h
+++ b/include/asm-parisc/cacheflush.h
@@ -45,9 +45,9 @@ void flush_cache_mm(struct mm_struct *mm);
45extern void flush_dcache_page(struct page *page); 45extern void flush_dcache_page(struct page *page);
46 46
47#define flush_dcache_mmap_lock(mapping) \ 47#define flush_dcache_mmap_lock(mapping) \
48 write_lock_irq(&(mapping)->tree_lock) 48 spin_lock_irq(&(mapping)->tree_lock)
49#define flush_dcache_mmap_unlock(mapping) \ 49#define flush_dcache_mmap_unlock(mapping) \
50 write_unlock_irq(&(mapping)->tree_lock) 50 spin_unlock_irq(&(mapping)->tree_lock)
51 51
52#define flush_icache_page(vma,page) do { \ 52#define flush_icache_page(vma,page) do { \
53 flush_kernel_dcache_page(page); \ 53 flush_kernel_dcache_page(page); \
diff --git a/include/asm-parisc/dma-mapping.h b/include/asm-parisc/dma-mapping.h
index c6c0e9ff6bde..53af696f23d2 100644
--- a/include/asm-parisc/dma-mapping.h
+++ b/include/asm-parisc/dma-mapping.h
@@ -248,6 +248,6 @@ void * sba_get_iommu(struct parisc_device *dev);
248#endif 248#endif
249 249
250/* At the moment, we panic on error for IOMMU resource exaustion */ 250/* At the moment, we panic on error for IOMMU resource exaustion */
251#define dma_mapping_error(x) 0 251#define dma_mapping_error(dev, x) 0
252 252
253#endif 253#endif
diff --git a/include/asm-parisc/namei.h b/include/asm-parisc/namei.h
deleted file mode 100644
index 8d29b3d9fb33..000000000000
--- a/include/asm-parisc/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* $Id: namei.h,v 1.1 1996/12/13 14:48:21 jj Exp $
2 * linux/include/asm-parisc/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __PARISC_NAMEI_H
8#define __PARISC_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* __PARISC_NAMEI_H */
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index 74c549780987..c7ca45f97dd2 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -415,7 +415,7 @@ static inline void dma_sync_sg_for_device(struct device *dev,
415 __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction); 415 __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
416} 416}
417 417
418static inline int dma_mapping_error(dma_addr_t dma_addr) 418static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
419{ 419{
420#ifdef CONFIG_PPC64 420#ifdef CONFIG_PPC64
421 return (dma_addr == DMA_ERROR_CODE); 421 return (dma_addr == DMA_ERROR_CODE);
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h
index 5a21115228af..a8b068792260 100644
--- a/include/asm-powerpc/kvm_ppc.h
+++ b/include/asm-powerpc/kvm_ppc.h
@@ -61,7 +61,8 @@ extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
61 61
62extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, 62extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn,
63 u64 asid, u32 flags); 63 u64 asid, u32 flags);
64extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, u64 eaddr, u64 asid); 64extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
65 gva_t eend, u32 asid);
65extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); 66extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode);
66 67
67extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu); 68extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu);
diff --git a/include/asm-powerpc/namei.h b/include/asm-powerpc/namei.h
deleted file mode 100644
index 657443474a6a..000000000000
--- a/include/asm-powerpc/namei.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef _ASM_POWERPC_NAMEI_H
2#define _ASM_POWERPC_NAMEI_H
3
4#ifdef __KERNEL__
5
6/*
7 * Adapted from include/asm-alpha/namei.h
8 *
9 * Included from fs/namei.c
10 */
11
12/* This dummy routine maybe changed to something useful
13 * for /usr/gnemul/ emulation stuff.
14 * Look at asm-sparc/namei.h for details.
15 */
16
17#define __emul_prefix() NULL
18
19#endif /* __KERNEL__ */
20#endif /* _ASM_POWERPC_NAMEI_H */
diff --git a/include/asm-powerpc/pgtable-4k.h b/include/asm-powerpc/pgtable-4k.h
index c9601dfb4a1e..6b18ba9d2d85 100644
--- a/include/asm-powerpc/pgtable-4k.h
+++ b/include/asm-powerpc/pgtable-4k.h
@@ -46,6 +46,8 @@
46#define _PAGE_GROUP_IX 0x7000 /* software: HPTE index within group */ 46#define _PAGE_GROUP_IX 0x7000 /* software: HPTE index within group */
47#define _PAGE_F_SECOND _PAGE_SECONDARY 47#define _PAGE_F_SECOND _PAGE_SECONDARY
48#define _PAGE_F_GIX _PAGE_GROUP_IX 48#define _PAGE_F_GIX _PAGE_GROUP_IX
49#define _PAGE_SPECIAL 0x10000 /* software: special page */
50#define __HAVE_ARCH_PTE_SPECIAL
49 51
50/* PTE flags to conserve for HPTE identification */ 52/* PTE flags to conserve for HPTE identification */
51#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \ 53#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \
diff --git a/include/asm-powerpc/pgtable-64k.h b/include/asm-powerpc/pgtable-64k.h
index 7e54adb35596..07b0d8f09cb6 100644
--- a/include/asm-powerpc/pgtable-64k.h
+++ b/include/asm-powerpc/pgtable-64k.h
@@ -70,6 +70,8 @@ static inline struct subpage_prot_table *pgd_subpage_prot(pgd_t *pgd)
70#define PGDIR_MASK (~(PGDIR_SIZE-1)) 70#define PGDIR_MASK (~(PGDIR_SIZE-1))
71 71
72/* Additional PTE bits (don't change without checking asm in hash_low.S) */ 72/* Additional PTE bits (don't change without checking asm in hash_low.S) */
73#define __HAVE_ARCH_PTE_SPECIAL
74#define _PAGE_SPECIAL 0x00000400 /* software: special page */
73#define _PAGE_HPTE_SUB 0x0ffff000 /* combo only: sub pages HPTE bits */ 75#define _PAGE_HPTE_SUB 0x0ffff000 /* combo only: sub pages HPTE bits */
74#define _PAGE_HPTE_SUB0 0x08000000 /* combo only: first sub page */ 76#define _PAGE_HPTE_SUB0 0x08000000 /* combo only: first sub page */
75#define _PAGE_COMBO 0x10000000 /* this is a combo 4k page */ 77#define _PAGE_COMBO 0x10000000 /* this is a combo 4k page */
diff --git a/include/asm-powerpc/pgtable-ppc32.h b/include/asm-powerpc/pgtable-ppc32.h
index bdbab72f3ebc..6fe39e327047 100644
--- a/include/asm-powerpc/pgtable-ppc32.h
+++ b/include/asm-powerpc/pgtable-ppc32.h
@@ -401,6 +401,9 @@ extern int icache_44x_need_flush;
401#ifndef _PAGE_COHERENT 401#ifndef _PAGE_COHERENT
402#define _PAGE_COHERENT 0 402#define _PAGE_COHERENT 0
403#endif 403#endif
404#ifndef _PAGE_WRITETHRU
405#define _PAGE_WRITETHRU 0
406#endif
404#ifndef _PMD_PRESENT_MASK 407#ifndef _PMD_PRESENT_MASK
405#define _PMD_PRESENT_MASK _PMD_PRESENT 408#define _PMD_PRESENT_MASK _PMD_PRESENT
406#endif 409#endif
diff --git a/include/asm-powerpc/pgtable-ppc64.h b/include/asm-powerpc/pgtable-ppc64.h
index ba8000352b9a..5fc78c0be302 100644
--- a/include/asm-powerpc/pgtable-ppc64.h
+++ b/include/asm-powerpc/pgtable-ppc64.h
@@ -245,7 +245,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
245static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;} 245static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
246static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;} 246static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
247static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;} 247static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
248static inline int pte_special(pte_t pte) { return 0; } 248static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPECIAL; }
249 249
250static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; } 250static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
251static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; } 251static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; }
@@ -265,7 +265,7 @@ static inline pte_t pte_mkyoung(pte_t pte) {
265static inline pte_t pte_mkhuge(pte_t pte) { 265static inline pte_t pte_mkhuge(pte_t pte) {
266 return pte; } 266 return pte; }
267static inline pte_t pte_mkspecial(pte_t pte) { 267static inline pte_t pte_mkspecial(pte_t pte) {
268 return pte; } 268 pte_val(pte) |= _PAGE_SPECIAL; return pte; }
269static inline unsigned long pte_pgprot(pte_t pte) 269static inline unsigned long pte_pgprot(pte_t pte)
270{ 270{
271 return __pgprot(pte_val(pte)) & PAGE_PROT_BITS; 271 return __pgprot(pte_val(pte)) & PAGE_PROT_BITS;
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h
index 3d6e31024e56..734e0754fb9b 100644
--- a/include/asm-powerpc/ptrace.h
+++ b/include/asm-powerpc/ptrace.h
@@ -84,6 +84,7 @@ struct pt_regs {
84#ifndef __ASSEMBLY__ 84#ifndef __ASSEMBLY__
85 85
86#define instruction_pointer(regs) ((regs)->nip) 86#define instruction_pointer(regs) ((regs)->nip)
87#define user_stack_pointer(regs) ((regs)->gpr[1])
87#define regs_return_value(regs) ((regs)->gpr[3]) 88#define regs_return_value(regs) ((regs)->gpr[3])
88 89
89#ifdef CONFIG_SMP 90#ifdef CONFIG_SMP
diff --git a/include/asm-powerpc/signal.h b/include/asm-powerpc/signal.h
index a8c7babf4950..a7360cdd99eb 100644
--- a/include/asm-powerpc/signal.h
+++ b/include/asm-powerpc/signal.h
@@ -122,8 +122,7 @@ typedef struct sigaltstack {
122 122
123#ifdef __KERNEL__ 123#ifdef __KERNEL__
124struct pt_regs; 124struct pt_regs;
125extern int do_signal(sigset_t *oldset, struct pt_regs *regs); 125extern void do_signal(struct pt_regs *regs, unsigned long thread_info_flags);
126extern int do_signal32(sigset_t *oldset, struct pt_regs *regs);
127#define ptrace_signal_deliver(regs, cookie) do { } while (0) 126#define ptrace_signal_deliver(regs, cookie) do { } while (0)
128#endif /* __KERNEL__ */ 127#endif /* __KERNEL__ */
129 128
diff --git a/include/asm-powerpc/smp.h b/include/asm-powerpc/smp.h
index 416d4c288cea..4d28e1e4521b 100644
--- a/include/asm-powerpc/smp.h
+++ b/include/asm-powerpc/smp.h
@@ -62,6 +62,8 @@ extern int smp_hw_index[];
62#endif 62#endif
63 63
64DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 64DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
65DECLARE_PER_CPU(cpumask_t, cpu_core_map);
66extern int cpu_to_core_id(int cpu);
65 67
66/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. 68/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
67 * 69 *
diff --git a/include/asm-powerpc/syscall.h b/include/asm-powerpc/syscall.h
new file mode 100644
index 000000000000..efa7f0b879f3
--- /dev/null
+++ b/include/asm-powerpc/syscall.h
@@ -0,0 +1,84 @@
1/*
2 * Access to user system call parameters and results
3 *
4 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
9 *
10 * See asm-generic/syscall.h for descriptions of what we must do here.
11 */
12
13#ifndef _ASM_SYSCALL_H
14#define _ASM_SYSCALL_H 1
15
16#include <linux/sched.h>
17
18static inline long syscall_get_nr(struct task_struct *task,
19 struct pt_regs *regs)
20{
21 return TRAP(regs) == 0xc00 ? regs->gpr[0] : -1L;
22}
23
24static inline void syscall_rollback(struct task_struct *task,
25 struct pt_regs *regs)
26{
27 regs->gpr[3] = regs->orig_gpr3;
28}
29
30static inline long syscall_get_error(struct task_struct *task,
31 struct pt_regs *regs)
32{
33 return (regs->ccr & 0x1000) ? -regs->gpr[3] : 0;
34}
35
36static inline long syscall_get_return_value(struct task_struct *task,
37 struct pt_regs *regs)
38{
39 return regs->gpr[3];
40}
41
42static inline void syscall_set_return_value(struct task_struct *task,
43 struct pt_regs *regs,
44 int error, long val)
45{
46 if (error) {
47 regs->ccr |= 0x1000L;
48 regs->gpr[3] = -error;
49 } else {
50 regs->ccr &= ~0x1000L;
51 regs->gpr[3] = val;
52 }
53}
54
55static inline void syscall_get_arguments(struct task_struct *task,
56 struct pt_regs *regs,
57 unsigned int i, unsigned int n,
58 unsigned long *args)
59{
60 BUG_ON(i + n > 6);
61#ifdef CONFIG_PPC64
62 if (test_tsk_thread_flag(task, TIF_32BIT)) {
63 /*
64 * Zero-extend 32-bit argument values. The high bits are
65 * garbage ignored by the actual syscall dispatch.
66 */
67 while (n-- > 0)
68 args[n] = (u32) regs->gpr[3 + i + n];
69 return;
70 }
71#endif
72 memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0]));
73}
74
75static inline void syscall_set_arguments(struct task_struct *task,
76 struct pt_regs *regs,
77 unsigned int i, unsigned int n,
78 const unsigned long *args)
79{
80 BUG_ON(i + n > 6);
81 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
82}
83
84#endif /* _ASM_SYSCALL_H */
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index a9db562df69a..9665a26a253a 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -108,6 +108,7 @@ static inline struct thread_info *current_thread_info(void)
108#define TIF_SECCOMP 10 /* secure computing */ 108#define TIF_SECCOMP 10 /* secure computing */
109#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ 109#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
110#define TIF_NOERROR 12 /* Force successful syscall return */ 110#define TIF_NOERROR 12 /* Force successful syscall return */
111#define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
111#define TIF_FREEZE 14 /* Freezing for suspend */ 112#define TIF_FREEZE 14 /* Freezing for suspend */
112#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */ 113#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
113#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */ 114#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
@@ -125,12 +126,14 @@ static inline struct thread_info *current_thread_info(void)
125#define _TIF_SECCOMP (1<<TIF_SECCOMP) 126#define _TIF_SECCOMP (1<<TIF_SECCOMP)
126#define _TIF_RESTOREALL (1<<TIF_RESTOREALL) 127#define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
127#define _TIF_NOERROR (1<<TIF_NOERROR) 128#define _TIF_NOERROR (1<<TIF_NOERROR)
129#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
128#define _TIF_FREEZE (1<<TIF_FREEZE) 130#define _TIF_FREEZE (1<<TIF_FREEZE)
129#define _TIF_RUNLATCH (1<<TIF_RUNLATCH) 131#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
130#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 132#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
131#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 133#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
132 134
133#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED) 135#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
136 _TIF_NOTIFY_RESUME)
134#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) 137#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
135 138
136/* Bits in local_flags */ 139/* Bits in local_flags */
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index 100c6fbfc587..c32da6f97999 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -108,6 +108,8 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
108#include <asm/smp.h> 108#include <asm/smp.h>
109 109
110#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 110#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
111#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
112#define topology_core_id(cpu) (cpu_to_core_id(cpu))
111#endif 113#endif
112#endif 114#endif
113 115
diff --git a/include/asm-s390/kvm_host.h b/include/asm-s390/kvm_host.h
index 3234dd5b3511..3c55e4107dcc 100644
--- a/include/asm-s390/kvm_host.h
+++ b/include/asm-s390/kvm_host.h
@@ -111,7 +111,7 @@ struct kvm_vcpu_stat {
111 u32 exit_validity; 111 u32 exit_validity;
112 u32 exit_instruction; 112 u32 exit_instruction;
113 u32 instruction_lctl; 113 u32 instruction_lctl;
114 u32 instruction_lctg; 114 u32 instruction_lctlg;
115 u32 exit_program_interruption; 115 u32 exit_program_interruption;
116 u32 exit_instr_and_program; 116 u32 exit_instr_and_program;
117 u32 deliver_emergency_signal; 117 u32 deliver_emergency_signal;
@@ -231,5 +231,5 @@ struct kvm_arch{
231 struct kvm_s390_float_interrupt float_int; 231 struct kvm_s390_float_interrupt float_int;
232}; 232};
233 233
234extern int sie64a(struct kvm_s390_sie_block *, __u64 *); 234extern int sie64a(struct kvm_s390_sie_block *, unsigned long *);
235#endif 235#endif
diff --git a/include/asm-s390/namei.h b/include/asm-s390/namei.h
deleted file mode 100644
index 3e286bdde4b0..000000000000
--- a/include/asm-s390/namei.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * include/asm-s390/namei.h
3 *
4 * S390 version
5 *
6 * Derived from "include/asm-i386/namei.h"
7 *
8 * Included from linux/fs/namei.c
9 */
10
11#ifndef __S390_NAMEI_H
12#define __S390_NAMEI_H
13
14/* This dummy routine maybe changed to something useful
15 * for /usr/gnemul/ emulation stuff.
16 * Look at asm-sparc/namei.h for details.
17 */
18
19#define __emul_prefix() NULL
20
21#endif /* __S390_NAMEI_H */
diff --git a/include/asm-sh/clock.h b/include/asm-sh/clock.h
index b550a27a7042..720dfab7b15e 100644
--- a/include/asm-sh/clock.h
+++ b/include/asm-sh/clock.h
@@ -5,6 +5,7 @@
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/seq_file.h> 6#include <linux/seq_file.h>
7#include <linux/clk.h> 7#include <linux/clk.h>
8#include <linux/err.h>
8 9
9struct clk; 10struct clk;
10 11
@@ -30,6 +31,7 @@ struct clk {
30 31
31 unsigned long rate; 32 unsigned long rate;
32 unsigned long flags; 33 unsigned long flags;
34 unsigned long arch_flags;
33}; 35};
34 36
35#define CLK_ALWAYS_ENABLED (1 << 0) 37#define CLK_ALWAYS_ENABLED (1 << 0)
@@ -41,14 +43,27 @@ void arch_init_clk_ops(struct clk_ops **, int type);
41/* arch/sh/kernel/cpu/clock.c */ 43/* arch/sh/kernel/cpu/clock.c */
42int clk_init(void); 44int clk_init(void);
43 45
44int __clk_enable(struct clk *);
45void __clk_disable(struct clk *);
46
47void clk_recalc_rate(struct clk *); 46void clk_recalc_rate(struct clk *);
48 47
49int clk_register(struct clk *); 48int clk_register(struct clk *);
50void clk_unregister(struct clk *); 49void clk_unregister(struct clk *);
51 50
51static inline int clk_always_enable(const char *id)
52{
53 struct clk *clk;
54 int ret;
55
56 clk = clk_get(NULL, id);
57 if (IS_ERR(clk))
58 return PTR_ERR(clk);
59
60 ret = clk_enable(clk);
61 if (ret)
62 clk_put(clk);
63
64 return ret;
65}
66
52/* the exported API, in addition to clk_set_rate */ 67/* the exported API, in addition to clk_set_rate */
53/** 68/**
54 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter 69 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
diff --git a/include/asm-sh/cpu-sh4/cacheflush.h b/include/asm-sh/cpu-sh4/cacheflush.h
index 5fd5c89ef86a..065306d376eb 100644
--- a/include/asm-sh/cpu-sh4/cacheflush.h
+++ b/include/asm-sh/cpu-sh4/cacheflush.h
@@ -30,7 +30,6 @@ void flush_dcache_page(struct page *pg);
30#define flush_dcache_mmap_unlock(mapping) do { } while (0) 30#define flush_dcache_mmap_unlock(mapping) do { } while (0)
31 31
32void flush_icache_range(unsigned long start, unsigned long end); 32void flush_icache_range(unsigned long start, unsigned long end);
33void flush_cache_sigtramp(unsigned long addr);
34void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, 33void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
35 unsigned long addr, int len); 34 unsigned long addr, int len);
36 35
diff --git a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
index da46e67ae26d..c23af81c2e70 100644
--- a/include/asm-sh/cpu-sh4/freq.h
+++ b/include/asm-sh/cpu-sh4/freq.h
@@ -12,12 +12,16 @@
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH7722) || \ 13#if defined(CONFIG_CPU_SUBTYPE_SH7722) || \
14 defined(CONFIG_CPU_SUBTYPE_SH7723) || \ 14 defined(CONFIG_CPU_SUBTYPE_SH7723) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7343) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7366) 16 defined(CONFIG_CPU_SUBTYPE_SH7366)
16#define FRQCR 0xa4150000 17#define FRQCR 0xa4150000
17#define VCLKCR 0xa4150004 18#define VCLKCR 0xa4150004
18#define SCLKACR 0xa4150008 19#define SCLKACR 0xa4150008
19#define SCLKBCR 0xa415000c 20#define SCLKBCR 0xa415000c
20#define IrDACLKCR 0xa4150010 21#define IrDACLKCR 0xa4150010
22#define MSTPCR0 0xa4150030
23#define MSTPCR1 0xa4150034
24#define MSTPCR2 0xa4150038
21#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 25#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
22 defined(CONFIG_CPU_SUBTYPE_SH7780) 26 defined(CONFIG_CPU_SUBTYPE_SH7780)
23#define FRQCR 0xffc80000 27#define FRQCR 0xffc80000
diff --git a/include/asm-sh/device.h b/include/asm-sh/device.h
index d8f9872b0e2d..efd511d0803a 100644
--- a/include/asm-sh/device.h
+++ b/include/asm-sh/device.h
@@ -5,3 +5,8 @@
5 */ 5 */
6#include <asm-generic/device.h> 6#include <asm-generic/device.h>
7 7
8struct platform_device;
9/* allocate contiguous memory chunk and fill in struct resource */
10int platform_resource_setup_memory(struct platform_device *pdev,
11 char *name, unsigned long memsize);
12
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index 22cc419389fe..627315ecdb52 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -5,6 +5,7 @@
5#include <linux/scatterlist.h> 5#include <linux/scatterlist.h>
6#include <asm/cacheflush.h> 6#include <asm/cacheflush.h>
7#include <asm/io.h> 7#include <asm/io.h>
8#include <asm-generic/dma-coherent.h>
8 9
9extern struct bus_type pci_bus_type; 10extern struct bus_type pci_bus_type;
10 11
@@ -171,7 +172,7 @@ static inline int dma_get_cache_alignment(void)
171 return L1_CACHE_BYTES; 172 return L1_CACHE_BYTES;
172} 173}
173 174
174static inline int dma_mapping_error(dma_addr_t dma_addr) 175static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
175{ 176{
176 return dma_addr == 0; 177 return dma_addr == 0;
177} 178}
diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h
index 05092da1aa59..f01449a8d378 100644
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -1,10 +1,15 @@
1#ifndef __ASM_SH_ELF_H 1#ifndef __ASM_SH_ELF_H
2#define __ASM_SH_ELF_H 2#define __ASM_SH_ELF_H
3 3
4#include <linux/utsname.h>
4#include <asm/auxvec.h> 5#include <asm/auxvec.h>
5#include <asm/ptrace.h> 6#include <asm/ptrace.h>
6#include <asm/user.h> 7#include <asm/user.h>
7 8
9/* ELF header e_flags defines */
10#define EF_SH_PIC 0x100 /* -fpic */
11#define EF_SH_FDPIC 0x8000 /* -mfdpic */
12
8/* SH (particularly SHcompact) relocation types */ 13/* SH (particularly SHcompact) relocation types */
9#define R_SH_NONE 0 14#define R_SH_NONE 0
10#define R_SH_DIR32 1 15#define R_SH_DIR32 1
@@ -43,6 +48,28 @@
43#define R_SH_RELATIVE 165 48#define R_SH_RELATIVE 165
44#define R_SH_GOTOFF 166 49#define R_SH_GOTOFF 166
45#define R_SH_GOTPC 167 50#define R_SH_GOTPC 167
51
52/* FDPIC relocs */
53#define R_SH_GOT20 70
54#define R_SH_GOTOFF20 71
55#define R_SH_GOTFUNCDESC 72
56#define R_SH_GOTFUNCDESC20 73
57#define R_SH_GOTOFFFUNCDESC 74
58#define R_SH_GOTOFFFUNCDESC20 75
59#define R_SH_FUNCDESC 76
60#define R_SH_FUNCDESC_VALUE 77
61
62#if 0 /* XXX - later .. */
63#define R_SH_GOT20 198
64#define R_SH_GOTOFF20 199
65#define R_SH_GOTFUNCDESC 200
66#define R_SH_GOTFUNCDESC20 201
67#define R_SH_GOTOFFFUNCDESC 202
68#define R_SH_GOTOFFFUNCDESC20 203
69#define R_SH_FUNCDESC 204
70#define R_SH_FUNCDESC_VALUE 205
71#endif
72
46/* SHmedia relocs */ 73/* SHmedia relocs */
47#define R_SH_IMM_LOW16 246 74#define R_SH_IMM_LOW16 246
48#define R_SH_IMM_LOW16_PCREL 247 75#define R_SH_IMM_LOW16_PCREL 247
@@ -77,9 +104,12 @@ typedef struct user_fpu_struct elf_fpregset_t;
77/* 104/*
78 * This is used to ensure we don't load something for the wrong architecture. 105 * This is used to ensure we don't load something for the wrong architecture.
79 */ 106 */
80#define elf_check_arch(x) ( (x)->e_machine == EM_SH ) 107#define elf_check_arch(x) ((x)->e_machine == EM_SH)
108#define elf_check_fdpic(x) ((x)->e_flags & EF_SH_FDPIC)
109#define elf_check_const_displacement(x) ((x)->e_flags & EF_SH_PIC)
81 110
82#define USE_ELF_CORE_DUMP 111#define USE_ELF_CORE_DUMP
112#define ELF_FDPIC_CORE_EFLAGS EF_SH_FDPIC
83#define ELF_EXEC_PAGESIZE PAGE_SIZE 113#define ELF_EXEC_PAGESIZE PAGE_SIZE
84 114
85/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 115/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
@@ -136,6 +166,27 @@ typedef struct user_fpu_struct elf_fpregset_t;
136 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \ 166 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \
137 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; \ 167 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; \
138 _r->sr = SR_FD; } while (0) 168 _r->sr = SR_FD; } while (0)
169
170#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, \
171 _dynamic_addr) \
172do { \
173 _r->regs[0] = 0; \
174 _r->regs[1] = 0; \
175 _r->regs[2] = 0; \
176 _r->regs[3] = 0; \
177 _r->regs[4] = 0; \
178 _r->regs[5] = 0; \
179 _r->regs[6] = 0; \
180 _r->regs[7] = 0; \
181 _r->regs[8] = _exec_map_addr; \
182 _r->regs[9] = _interp_map_addr; \
183 _r->regs[10] = _dynamic_addr; \
184 _r->regs[11] = 0; \
185 _r->regs[12] = 0; \
186 _r->regs[13] = 0; \
187 _r->regs[14] = 0; \
188 _r->sr = SR_FD; \
189} while (0)
139#endif 190#endif
140 191
141#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) 192#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT)
diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h
index 7438d1e21bc9..d557b00111bf 100644
--- a/include/asm-sh/hw_irq.h
+++ b/include/asm-sh/hw_irq.h
@@ -79,7 +79,7 @@ struct intc_desc {
79 struct intc_sense_reg *sense_regs; 79 struct intc_sense_reg *sense_regs;
80 unsigned int nr_sense_regs; 80 unsigned int nr_sense_regs;
81 char *name; 81 char *name;
82#ifdef CONFIG_CPU_SH3 82#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
83 struct intc_mask_reg *ack_regs; 83 struct intc_mask_reg *ack_regs;
84 unsigned int nr_ack_regs; 84 unsigned int nr_ack_regs;
85#endif 85#endif
@@ -95,7 +95,7 @@ struct intc_desc symbol __initdata = { \
95 chipname, \ 95 chipname, \
96} 96}
97 97
98#ifdef CONFIG_CPU_SH3 98#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
99#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \ 99#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
100 mask_regs, prio_regs, sense_regs, ack_regs) \ 100 mask_regs, prio_regs, sense_regs, ack_regs) \
101struct intc_desc symbol __initdata = { \ 101struct intc_desc symbol __initdata = { \
diff --git a/include/asm-sh/migor.h b/include/asm-sh/migor.h
index 2329363afdc3..10016e0f4a4e 100644
--- a/include/asm-sh/migor.h
+++ b/include/asm-sh/migor.h
@@ -16,10 +16,6 @@
16#include <asm/addrspace.h> 16#include <asm/addrspace.h>
17 17
18/* GPIO */ 18/* GPIO */
19#define MSTPCR0 0xa4150030
20#define MSTPCR1 0xa4150034
21#define MSTPCR2 0xa4150038
22
23#define PORT_PACR 0xa4050100 19#define PORT_PACR 0xa4050100
24#define PORT_PDCR 0xa4050106 20#define PORT_PDCR 0xa4050106
25#define PORT_PECR 0xa4050108 21#define PORT_PECR 0xa4050108
@@ -29,11 +25,16 @@
29#define PORT_PLCR 0xa4050114 25#define PORT_PLCR 0xa4050114
30#define PORT_PMCR 0xa4050116 26#define PORT_PMCR 0xa4050116
31#define PORT_PRCR 0xa405011c 27#define PORT_PRCR 0xa405011c
28#define PORT_PTCR 0xa4050140
29#define PORT_PUCR 0xa4050142
30#define PORT_PVCR 0xa4050144
32#define PORT_PWCR 0xa4050146 31#define PORT_PWCR 0xa4050146
33#define PORT_PXCR 0xa4050148 32#define PORT_PXCR 0xa4050148
34#define PORT_PYCR 0xa405014a 33#define PORT_PYCR 0xa405014a
35#define PORT_PZCR 0xa405014c 34#define PORT_PZCR 0xa405014c
36#define PORT_PADR 0xa4050120 35#define PORT_PADR 0xa4050120
36#define PORT_PHDR 0xa405012e
37#define PORT_PTDR 0xa4050160
37#define PORT_PWDR 0xa4050166 38#define PORT_PWDR 0xa4050166
38 39
39#define PORT_HIZCRA 0xa4050158 40#define PORT_HIZCRA 0xa4050158
@@ -48,6 +49,7 @@
48#define PORT_PSELB 0xa4050150 49#define PORT_PSELB 0xa4050150
49#define PORT_PSELC 0xa4050152 50#define PORT_PSELC 0xa4050152
50#define PORT_PSELD 0xa4050154 51#define PORT_PSELD 0xa4050154
52#define PORT_PSELE 0xa4050156
51 53
52#define PORT_HIZCRA 0xa4050158 54#define PORT_HIZCRA 0xa4050158
53#define PORT_HIZCRB 0xa405015a 55#define PORT_HIZCRB 0xa405015a
@@ -55,4 +57,9 @@
55 57
56#define BSC_CS6ABCR 0xfec1001c 58#define BSC_CS6ABCR 0xfec1001c
57 59
60#include <asm/sh_mobile_lcdc.h>
61
62int migor_lcd_qvga_setup(void *board_data, void *sys_ops_handle,
63 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
64
58#endif /* __ASM_SH_MIGOR_H */ 65#endif /* __ASM_SH_MIGOR_H */
diff --git a/include/asm-sh/mmu.h b/include/asm-sh/mmu.h
index eb0358c097d0..fdcb93bc6d11 100644
--- a/include/asm-sh/mmu.h
+++ b/include/asm-sh/mmu.h
@@ -12,6 +12,10 @@ typedef struct {
12 struct vm_list_struct *vmlist; 12 struct vm_list_struct *vmlist;
13 unsigned long end_brk; 13 unsigned long end_brk;
14#endif 14#endif
15#ifdef CONFIG_BINFMT_ELF_FDPIC
16 unsigned long exec_fdpic_loadmap;
17 unsigned long interp_fdpic_loadmap;
18#endif
15} mm_context_t; 19} mm_context_t;
16 20
17/* 21/*
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index 87e812f68bb0..8589a50febd0 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -27,8 +27,9 @@
27/* ASID is 8-bit value, so it can't be 0x100 */ 27/* ASID is 8-bit value, so it can't be 0x100 */
28#define MMU_NO_ASID 0x100 28#define MMU_NO_ASID 0x100
29 29
30#ifdef CONFIG_MMU
31#define asid_cache(cpu) (cpu_data[cpu].asid_cache) 30#define asid_cache(cpu) (cpu_data[cpu].asid_cache)
31
32#ifdef CONFIG_MMU
32#define cpu_context(cpu, mm) ((mm)->context.id[cpu]) 33#define cpu_context(cpu, mm) ((mm)->context.id[cpu])
33 34
34#define cpu_asid(cpu, mm) \ 35#define cpu_asid(cpu, mm) \
diff --git a/include/asm-sh/namei.h b/include/asm-sh/namei.h
deleted file mode 100644
index 338a5d947143..000000000000
--- a/include/asm-sh/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* $Id: namei.h,v 1.3 2000/07/04 06:24:49 gniibe Exp $
2 * linux/include/asm-sh/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __ASM_SH_NAMEI_H
8#define __ASM_SH_NAMEI_H
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* __ASM_SH_NAMEI_H */
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index 5dc01d2fcc4c..77fb8bf02e4e 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -12,6 +12,8 @@
12# define PAGE_SHIFT 12 12# define PAGE_SHIFT 12
13#elif defined(CONFIG_PAGE_SIZE_8KB) 13#elif defined(CONFIG_PAGE_SIZE_8KB)
14# define PAGE_SHIFT 13 14# define PAGE_SHIFT 13
15#elif defined(CONFIG_PAGE_SIZE_16KB)
16# define PAGE_SHIFT 14
15#elif defined(CONFIG_PAGE_SIZE_64KB) 17#elif defined(CONFIG_PAGE_SIZE_64KB)
16# define PAGE_SHIFT 16 18# define PAGE_SHIFT 16
17#else 19#else
diff --git a/include/asm-sh/pgtable_32.h b/include/asm-sh/pgtable_32.h
index cbc731d35c25..72ea209195bd 100644
--- a/include/asm-sh/pgtable_32.h
+++ b/include/asm-sh/pgtable_32.h
@@ -102,7 +102,9 @@
102#define _PAGE_FLAGS_HARDWARE_MASK (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS)) 102#define _PAGE_FLAGS_HARDWARE_MASK (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS))
103 103
104/* Hardware flags, page size encoding */ 104/* Hardware flags, page size encoding */
105#if defined(CONFIG_X2TLB) 105#if !defined(CONFIG_MMU)
106# define _PAGE_FLAGS_HARD 0ULL
107#elif defined(CONFIG_X2TLB)
106# if defined(CONFIG_PAGE_SIZE_4KB) 108# if defined(CONFIG_PAGE_SIZE_4KB)
107# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0) 109# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0)
108# elif defined(CONFIG_PAGE_SIZE_8KB) 110# elif defined(CONFIG_PAGE_SIZE_8KB)
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index b7c7ce80f03e..15d9f92ca383 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -2,6 +2,7 @@
2#define __ASM_SH_PROCESSOR_H 2#define __ASM_SH_PROCESSOR_H
3 3
4#include <asm/cpu-features.h> 4#include <asm/cpu-features.h>
5#include <asm/segment.h>
5 6
6#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
7/* 8/*
diff --git a/include/asm-sh/processor_32.h b/include/asm-sh/processor_32.h
index c09305d6a9d9..c6583f267071 100644
--- a/include/asm-sh/processor_32.h
+++ b/include/asm-sh/processor_32.h
@@ -28,6 +28,7 @@
28 28
29struct sh_cpuinfo { 29struct sh_cpuinfo {
30 unsigned int type; 30 unsigned int type;
31 int cut_major, cut_minor;
31 unsigned long loops_per_jiffy; 32 unsigned long loops_per_jiffy;
32 unsigned long asid_cache; 33 unsigned long asid_cache;
33 34
@@ -113,10 +114,6 @@ struct thread_struct {
113 union sh_fpu_union fpu; 114 union sh_fpu_union fpu;
114}; 115};
115 116
116typedef struct {
117 unsigned long seg;
118} mm_segment_t;
119
120/* Count of active tasks with UBC settings */ 117/* Count of active tasks with UBC settings */
121extern int ubc_usercnt; 118extern int ubc_usercnt;
122 119
diff --git a/include/asm-sh/processor_64.h b/include/asm-sh/processor_64.h
index 88a2edf8fa5d..fc7fc685ba27 100644
--- a/include/asm-sh/processor_64.h
+++ b/include/asm-sh/processor_64.h
@@ -166,10 +166,6 @@ struct thread_struct {
166 union sh_fpu_union fpu; 166 union sh_fpu_union fpu;
167}; 167};
168 168
169typedef struct {
170 unsigned long seg;
171} mm_segment_t;
172
173#define INIT_MMAP \ 169#define INIT_MMAP \
174{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL } 170{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
175 171
diff --git a/include/asm-sh/ptrace.h b/include/asm-sh/ptrace.h
index 7d36dc3bee69..643ab5a7cf3b 100644
--- a/include/asm-sh/ptrace.h
+++ b/include/asm-sh/ptrace.h
@@ -87,6 +87,11 @@ struct pt_dspregs {
87 unsigned long mod; 87 unsigned long mod;
88}; 88};
89 89
90#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
91
92#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
93#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
94
90#define PTRACE_GETDSPREGS 55 95#define PTRACE_GETDSPREGS 55
91#define PTRACE_SETDSPREGS 56 96#define PTRACE_SETDSPREGS 56
92#endif 97#endif
diff --git a/include/asm-sh/se.h b/include/asm-sh/se.h
index bd2596c014a9..eb23000e1bbe 100644
--- a/include/asm-sh/se.h
+++ b/include/asm-sh/se.h
@@ -76,6 +76,23 @@
76#define IRQ_CFCARD 7 76#define IRQ_CFCARD 7
77#endif 77#endif
78 78
79/* SH Ether support (SH7710/SH7712) */
80/* Base address */
81#define SH_ETH0_BASE 0xA7000000
82#define SH_ETH1_BASE 0xA7000400
83/* PHY ID */
84#if defined(CONFIG_CPU_SUBTYPE_SH7710)
85# define PHY_ID 0x00
86#elif defined(CONFIG_CPU_SUBTYPE_SH7712)
87# define PHY_ID 0x01
88#endif
89/* Ether IRQ */
90#define SH_ETH0_IRQ 80
91#define SH_ETH1_IRQ 81
92#define SH_TSU_IRQ 82
93
94void init_se_IRQ(void);
95
79#define __IO_PREFIX se 96#define __IO_PREFIX se
80#include <asm/io_generic.h> 97#include <asm/io_generic.h>
81 98
diff --git a/include/asm-sh/se7343.h b/include/asm-sh/se7343.h
index e7914a54aa96..98458460e632 100644
--- a/include/asm-sh/se7343.h
+++ b/include/asm-sh/se7343.h
@@ -59,24 +59,91 @@
59#define PA_LCD1 0xb8000000 59#define PA_LCD1 0xb8000000
60#define PA_LCD2 0xb8800000 60#define PA_LCD2 0xb8800000
61 61
62#define PORT_PACR 0xA4050100
63#define PORT_PBCR 0xA4050102
64#define PORT_PCCR 0xA4050104
65#define PORT_PDCR 0xA4050106
66#define PORT_PECR 0xA4050108
67#define PORT_PFCR 0xA405010A
68#define PORT_PGCR 0xA405010C
69#define PORT_PHCR 0xA405010E
70#define PORT_PJCR 0xA4050110
71#define PORT_PKCR 0xA4050112
72#define PORT_PLCR 0xA4050114
73#define PORT_PMCR 0xA4050116
74#define PORT_PNCR 0xA4050118
75#define PORT_PQCR 0xA405011A
76#define PORT_PRCR 0xA405011C
77#define PORT_PSCR 0xA405011E
78#define PORT_PTCR 0xA4050140
79#define PORT_PUCR 0xA4050142
80#define PORT_PVCR 0xA4050144
81#define PORT_PWCR 0xA4050146
82#define PORT_PYCR 0xA4050148
83#define PORT_PZCR 0xA405014A
84
85#define PORT_PSELA 0xA405014C
86#define PORT_PSELB 0xA405014E
87#define PORT_PSELC 0xA4050150
88#define PORT_PSELD 0xA4050152
89#define PORT_PSELE 0xA4050154
90
91#define PORT_HIZCRA 0xA4050156
92#define PORT_HIZCRB 0xA4050158
93#define PORT_HIZCRC 0xA405015C
94
95#define PORT_DRVCR 0xA4050180
96
97#define PORT_PADR 0xA4050120
98#define PORT_PBDR 0xA4050122
99#define PORT_PCDR 0xA4050124
100#define PORT_PDDR 0xA4050126
101#define PORT_PEDR 0xA4050128
102#define PORT_PFDR 0xA405012A
103#define PORT_PGDR 0xA405012C
104#define PORT_PHDR 0xA405012E
105#define PORT_PJDR 0xA4050130
106#define PORT_PKDR 0xA4050132
107#define PORT_PLDR 0xA4050134
108#define PORT_PMDR 0xA4050136
109#define PORT_PNDR 0xA4050138
110#define PORT_PQDR 0xA405013A
111#define PORT_PRDR 0xA405013C
112#define PORT_PTDR 0xA4050160
113#define PORT_PUDR 0xA4050162
114#define PORT_PVDR 0xA4050164
115#define PORT_PWDR 0xA4050166
116#define PORT_PYDR 0xA4050168
117
118#define FPGA_IN 0xb1400000
119#define FPGA_OUT 0xb1400002
120
62#define __IO_PREFIX sh7343se 121#define __IO_PREFIX sh7343se
63#include <asm/io_generic.h> 122#include <asm/io_generic.h>
64 123
65/* External Multiplexed interrupts */ 124#define IRQ0_IRQ 32
66#define PC_IRQ0 OFFCHIP_IRQ_BASE 125#define IRQ1_IRQ 33
67#define PC_IRQ1 (PC_IRQ0 + 1) 126#define IRQ4_IRQ 36
68#define PC_IRQ2 (PC_IRQ1 + 1) 127#define IRQ5_IRQ 37
69#define PC_IRQ3 (PC_IRQ2 + 1) 128
129#define SE7343_FPGA_IRQ_MRSHPC0 0
130#define SE7343_FPGA_IRQ_MRSHPC1 1
131#define SE7343_FPGA_IRQ_MRSHPC2 2
132#define SE7343_FPGA_IRQ_MRSHPC3 3
133#define SE7343_FPGA_IRQ_SMC 6 /* EXT_IRQ2 */
134#define SE7343_FPGA_IRQ_USB 8
70 135
71#define EXT_IRQ0 (PC_IRQ3 + 1) 136#define SE7343_FPGA_IRQ_NR 11
72#define EXT_IRQ1 (EXT_IRQ0 + 1) 137#define SE7343_FPGA_IRQ_BASE 120
73#define EXT_IRQ2 (EXT_IRQ1 + 1)
74#define EXT_IRQ3 (EXT_IRQ2 + 1)
75 138
76#define USB_IRQ0 (EXT_IRQ3 + 1) 139#define MRSHPC_IRQ3 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC3)
77#define USB_IRQ1 (USB_IRQ0 + 1) 140#define MRSHPC_IRQ2 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC2)
141#define MRSHPC_IRQ1 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC1)
142#define MRSHPC_IRQ0 (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_MRSHPC0)
143#define SMC_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_SMC)
144#define USB_IRQ (SE7343_FPGA_IRQ_BASE + SE7343_FPGA_IRQ_USB)
78 145
79#define UART_IRQ0 (USB_IRQ1 + 1) 146/* arch/sh/boards/se/7343/irq.c */
80#define UART_IRQ1 (UART_IRQ0 + 1) 147void init_7343se_IRQ(void);
81 148
82#endif /* __ASM_SH_HITACHI_SE7343_H */ 149#endif /* __ASM_SH_HITACHI_SE7343_H */
diff --git a/include/asm-sh/se7722.h b/include/asm-sh/se7722.h
index 3690fe5857a4..e971d9a82f4a 100644
--- a/include/asm-sh/se7722.h
+++ b/include/asm-sh/se7722.h
@@ -55,10 +55,6 @@
55 55
56#define PA_LAN (PA_AREA6_IO + 0) /* SMC LAN91C111 */ 56#define PA_LAN (PA_AREA6_IO + 0) /* SMC LAN91C111 */
57/* GPIO */ 57/* GPIO */
58#define MSTPCR0 0xA4150030UL
59#define MSTPCR1 0xA4150034UL
60#define MSTPCR2 0xA4150038UL
61
62#define FPGA_IN 0xb1840000UL 58#define FPGA_IN 0xb1840000UL
63#define FPGA_OUT 0xb1840004UL 59#define FPGA_OUT 0xb1840004UL
64 60
diff --git a/include/asm-sh/segment.h b/include/asm-sh/segment.h
index e417eab4c7d7..5e2725f4ac49 100644
--- a/include/asm-sh/segment.h
+++ b/include/asm-sh/segment.h
@@ -1,6 +1,34 @@
1#ifndef __ASM_SH_SEGMENT_H 1#ifndef __ASM_SH_SEGMENT_H
2#define __ASM_SH_SEGMENT_H 2#define __ASM_SH_SEGMENT_H
3 3
4/* Only here because we have some old header files that expect it.. */ 4#ifndef __ASSEMBLY__
5 5
6typedef struct {
7 unsigned long seg;
8} mm_segment_t;
9
10#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
11
12/*
13 * The fs value determines whether argument validity checking should be
14 * performed or not. If get_fs() == USER_DS, checking is performed, with
15 * get_fs() == KERNEL_DS, checking is bypassed.
16 *
17 * For historical reasons, these macros are grossly misnamed.
18 */
19#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
20#ifdef CONFIG_MMU
21#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
22#else
23#define USER_DS KERNEL_DS
24#endif
25
26#define segment_eq(a,b) ((a).seg == (b).seg)
27
28#define get_ds() (KERNEL_DS)
29
30#define get_fs() (current_thread_info()->addr_limit)
31#define set_fs(x) (current_thread_info()->addr_limit = (x))
32
33#endif /* __ASSEMBLY__ */
6#endif /* __ASM_SH_SEGMENT_H */ 34#endif /* __ASM_SH_SEGMENT_H */
diff --git a/include/asm-sh/sh7763rdp.h b/include/asm-sh/sh7763rdp.h
new file mode 100644
index 000000000000..8750cc852977
--- /dev/null
+++ b/include/asm-sh/sh7763rdp.h
@@ -0,0 +1,54 @@
1#ifndef __ASM_SH_SH7763RDP_H
2#define __ASM_SH_SH7763RDP_H
3
4/*
5 * linux/include/asm-sh/sh7763drp.h
6 *
7 * Copyright (C) 2008 Renesas Solutions
8 * Copyright (C) 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 *
14 */
15#include <asm/addrspace.h>
16
17/* clock control */
18#define MSTPCR1 0xFFC80038
19
20/* PORT */
21#define PORT_PSEL0 0xFFEF0070
22#define PORT_PSEL1 0xFFEF0072
23#define PORT_PSEL2 0xFFEF0074
24#define PORT_PSEL3 0xFFEF0076
25#define PORT_PSEL4 0xFFEF0078
26
27#define PORT_PACR 0xFFEF0000
28#define PORT_PCCR 0xFFEF0004
29#define PORT_PFCR 0xFFEF000A
30#define PORT_PGCR 0xFFEF000C
31#define PORT_PHCR 0xFFEF000E
32#define PORT_PICR 0xFFEF0010
33#define PORT_PJCR 0xFFEF0012
34#define PORT_PKCR 0xFFEF0014
35#define PORT_PLCR 0xFFEF0016
36#define PORT_PMCR 0xFFEF0018
37#define PORT_PNCR 0xFFEF001A
38
39/* FPGA */
40#define CPLD_BOARD_ID_ERV_REG 0xB1000000
41#define CPLD_CPLD_CMD_REG 0xB1000006
42
43/*
44 * USB SH7763RDP board can use Host only.
45 */
46#define USB_USBHSC 0xFFEC80f0
47
48/* arch/sh/boards/renesas/sh7763rdp/irq.c */
49void init_sh7763rdp_IRQ(void);
50int sh7763rdp_irq_demux(int irq);
51#define __IO_PREFIX sh7763rdp
52#include <asm/io_generic.h>
53
54#endif /* __ASM_SH_SH7763RDP_H */
diff --git a/include/asm-sh/sh7785lcr.h b/include/asm-sh/sh7785lcr.h
new file mode 100644
index 000000000000..1ce27d5c7491
--- /dev/null
+++ b/include/asm-sh/sh7785lcr.h
@@ -0,0 +1,55 @@
1#ifndef __ASM_SH_RENESAS_SH7785LCR_H
2#define __ASM_SH_RENESAS_SH7785LCR_H
3
4/*
5 * This board has 2 physical memory maps.
6 * It can be changed with DIP switch(S2-5).
7 *
8 * phys address | S2-5 = OFF | S2-5 = ON
9 * -----------------------------+---------------+---------------
10 * 0x00000000 - 0x03ffffff(CS0) | NOR Flash | NOR Flash
11 * 0x04000000 - 0x05ffffff(CS1) | PLD | PLD
12 * 0x06000000 - 0x07ffffff(CS1) | reserved | I2C
13 * 0x08000000 - 0x0bffffff(CS2) | USB | DDR SDRAM
14 * 0x0c000000 - 0x0fffffff(CS3) | SD | DDR SDRAM
15 * 0x10000000 - 0x13ffffff(CS4) | SM107 | SM107
16 * 0x14000000 - 0x17ffffff(CS5) | I2C | USB
17 * 0x18000000 - 0x1bffffff(CS6) | reserved | SD
18 * 0x40000000 - 0x5fffffff | DDR SDRAM | (cannot use)
19 *
20 */
21
22#define NOR_FLASH_ADDR 0x00000000
23#define NOR_FLASH_SIZE 0x04000000
24
25#define PLD_BASE_ADDR 0x04000000
26#define PLD_PCICR (PLD_BASE_ADDR + 0x00)
27#define PLD_LCD_BK_CONTR (PLD_BASE_ADDR + 0x02)
28#define PLD_LOCALCR (PLD_BASE_ADDR + 0x04)
29#define PLD_POFCR (PLD_BASE_ADDR + 0x06)
30#define PLD_LEDCR (PLD_BASE_ADDR + 0x08)
31#define PLD_SWSR (PLD_BASE_ADDR + 0x0a)
32#define PLD_VERSR (PLD_BASE_ADDR + 0x0c)
33#define PLD_MMSR (PLD_BASE_ADDR + 0x0e)
34
35#define SM107_MEM_ADDR 0x10000000
36#define SM107_MEM_SIZE 0x00e00000
37#define SM107_REG_ADDR 0x13e00000
38#define SM107_REG_SIZE 0x00200000
39
40#if defined(CONFIG_SH_SH7785LCR_29BIT_PHYSMAPS)
41#define R8A66597_ADDR 0x14000000 /* USB */
42#define CG200_ADDR 0x18000000 /* SD */
43#define PCA9564_ADDR 0x06000000 /* I2C */
44#else
45#define R8A66597_ADDR 0x08000000
46#define CG200_ADDR 0x0c000000
47#define PCA9564_ADDR 0x14000000
48#endif
49
50#define R8A66597_SIZE 0x00000100
51#define CG200_SIZE 0x00010000
52#define PCA9564_SIZE 0x00000100
53
54#endif /* __ASM_SH_RENESAS_SH7785LCR_H */
55
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index e65b6b822cb3..056d68cd2108 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -148,14 +148,6 @@ extern unsigned long cached_to_uncached;
148 148
149extern struct dentry *sh_debugfs_root; 149extern struct dentry *sh_debugfs_root;
150 150
151/* XXX
152 * disable hlt during certain critical i/o operations
153 */
154#define HAVE_DISABLE_HLT
155void disable_hlt(void);
156void enable_hlt(void);
157
158void default_idle(void);
159void per_cpu_trap_init(void); 151void per_cpu_trap_init(void);
160 152
161asmlinkage void break_point_trap(void); 153asmlinkage void break_point_trap(void);
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 5131e3907525..eeb4c747119e 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -38,6 +38,8 @@ struct thread_info {
38#define THREAD_SIZE_ORDER (1) 38#define THREAD_SIZE_ORDER (1)
39#elif defined(CONFIG_PAGE_SIZE_8KB) 39#elif defined(CONFIG_PAGE_SIZE_8KB)
40#define THREAD_SIZE_ORDER (1) 40#define THREAD_SIZE_ORDER (1)
41#elif defined(CONFIG_PAGE_SIZE_16KB)
42#define THREAD_SIZE_ORDER (0)
41#elif defined(CONFIG_PAGE_SIZE_64KB) 43#elif defined(CONFIG_PAGE_SIZE_64KB)
42#define THREAD_SIZE_ORDER (0) 44#define THREAD_SIZE_ORDER (0)
43#else 45#else
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h
index 701ba84c7049..327f7eb8976a 100644
--- a/include/asm-sh/timer.h
+++ b/include/asm-sh/timer.h
@@ -40,6 +40,5 @@ struct sys_timer *get_sys_timer(void);
40/* arch/sh/kernel/time.c */ 40/* arch/sh/kernel/time.c */
41void handle_timer_tick(void); 41void handle_timer_tick(void);
42extern unsigned long sh_hpt_frequency; 42extern unsigned long sh_hpt_frequency;
43extern struct clocksource clocksource_sh;
44 43
45#endif /* __ASM_SH_TIMER_H */ 44#endif /* __ASM_SH_TIMER_H */
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h
index b3440c305b5d..45c2c9b2993d 100644
--- a/include/asm-sh/uaccess.h
+++ b/include/asm-sh/uaccess.h
@@ -1,12 +1,171 @@
1#ifndef __ASM_SH_UACCESS_H 1#ifndef __ASM_SH_UACCESS_H
2#define __ASM_SH_UACCESS_H 2#define __ASM_SH_UACCESS_H
3 3
4#include <linux/errno.h>
5#include <linux/sched.h>
6#include <asm/segment.h>
7
8#define VERIFY_READ 0
9#define VERIFY_WRITE 1
10
11#define __addr_ok(addr) \
12 ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg)
13
14/*
15 * __access_ok: Check if address with size is OK or not.
16 *
17 * Uhhuh, this needs 33-bit arithmetic. We have a carry..
18 *
19 * sum := addr + size; carry? --> flag = true;
20 * if (sum >= addr_limit) flag = true;
21 */
22#define __access_ok(addr, size) \
23 (__addr_ok((addr) + (size)))
24#define access_ok(type, addr, size) \
25 (__chk_user_ptr(addr), \
26 __access_ok((unsigned long __force)(addr), (size)))
27
28/*
29 * Uh, these should become the main single-value transfer routines ...
30 * They automatically use the right size if we just have the right
31 * pointer type ...
32 *
33 * As SuperH uses the same address space for kernel and user data, we
34 * can just do these as direct assignments.
35 *
36 * Careful to not
37 * (a) re-use the arguments for side effects (sizeof is ok)
38 * (b) require any knowledge of processes at this stage
39 */
40#define put_user(x,ptr) __put_user_check((x), (ptr), sizeof(*(ptr)))
41#define get_user(x,ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))
42
43/*
44 * The "__xxx" versions do not do address space checking, useful when
45 * doing multiple accesses to the same area (the user has to do the
46 * checks by hand with "access_ok()")
47 */
48#define __put_user(x,ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
49#define __get_user(x,ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
50
51struct __large_struct { unsigned long buf[100]; };
52#define __m(x) (*(struct __large_struct __user *)(x))
53
54#define __get_user_nocheck(x,ptr,size) \
55({ \
56 long __gu_err; \
57 unsigned long __gu_val; \
58 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
59 __chk_user_ptr(ptr); \
60 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
61 (x) = (__typeof__(*(ptr)))__gu_val; \
62 __gu_err; \
63})
64
65#define __get_user_check(x,ptr,size) \
66({ \
67 long __gu_err = -EFAULT; \
68 unsigned long __gu_val = 0; \
69 const __typeof__(*(ptr)) *__gu_addr = (ptr); \
70 if (likely(access_ok(VERIFY_READ, __gu_addr, (size)))) \
71 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
72 (x) = (__typeof__(*(ptr)))__gu_val; \
73 __gu_err; \
74})
75
76#define __put_user_nocheck(x,ptr,size) \
77({ \
78 long __pu_err; \
79 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
80 __chk_user_ptr(ptr); \
81 __put_user_size((x), __pu_addr, (size), __pu_err); \
82 __pu_err; \
83})
84
85#define __put_user_check(x,ptr,size) \
86({ \
87 long __pu_err = -EFAULT; \
88 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
89 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \
90 __put_user_size((x), __pu_addr, (size), \
91 __pu_err); \
92 __pu_err; \
93})
94
4#ifdef CONFIG_SUPERH32 95#ifdef CONFIG_SUPERH32
5# include "uaccess_32.h" 96# include "uaccess_32.h"
6#else 97#else
7# include "uaccess_64.h" 98# include "uaccess_64.h"
8#endif 99#endif
9 100
101/* Generic arbitrary sized copy. */
102/* Return the number of bytes NOT copied */
103__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
104
105static __always_inline unsigned long
106__copy_from_user(void *to, const void __user *from, unsigned long n)
107{
108 return __copy_user(to, (__force void *)from, n);
109}
110
111static __always_inline unsigned long __must_check
112__copy_to_user(void __user *to, const void *from, unsigned long n)
113{
114 return __copy_user((__force void *)to, from, n);
115}
116
117#define __copy_to_user_inatomic __copy_to_user
118#define __copy_from_user_inatomic __copy_from_user
119
120/*
121 * Clear the area and return remaining number of bytes
122 * (on failure. Usually it's 0.)
123 */
124__kernel_size_t __clear_user(void *addr, __kernel_size_t size);
125
126#define clear_user(addr,n) \
127({ \
128 void __user * __cl_addr = (addr); \
129 unsigned long __cl_size = (n); \
130 \
131 if (__cl_size && access_ok(VERIFY_WRITE, \
132 ((unsigned long)(__cl_addr)), __cl_size)) \
133 __cl_size = __clear_user(__cl_addr, __cl_size); \
134 \
135 __cl_size; \
136})
137
138/**
139 * strncpy_from_user: - Copy a NUL terminated string from userspace.
140 * @dst: Destination address, in kernel space. This buffer must be at
141 * least @count bytes long.
142 * @src: Source address, in user space.
143 * @count: Maximum number of bytes to copy, including the trailing NUL.
144 *
145 * Copies a NUL-terminated string from userspace to kernel space.
146 *
147 * On success, returns the length of the string (not including the trailing
148 * NUL).
149 *
150 * If access to userspace fails, returns -EFAULT (some data may have been
151 * copied).
152 *
153 * If @count is smaller than the length of the string, copies @count bytes
154 * and returns @count.
155 */
156#define strncpy_from_user(dest,src,count) \
157({ \
158 unsigned long __sfu_src = (unsigned long)(src); \
159 int __sfu_count = (int)(count); \
160 long __sfu_res = -EFAULT; \
161 \
162 if (__access_ok(__sfu_src, __sfu_count)) \
163 __sfu_res = __strncpy_from_user((unsigned long)(dest), \
164 __sfu_src, __sfu_count); \
165 \
166 __sfu_res; \
167})
168
10static inline unsigned long 169static inline unsigned long
11copy_from_user(void *to, const void __user *from, unsigned long n) 170copy_from_user(void *to, const void __user *from, unsigned long n)
12{ 171{
@@ -31,4 +190,67 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
31 return __copy_size; 190 return __copy_size;
32} 191}
33 192
193/**
194 * strnlen_user: - Get the size of a string in user space.
195 * @s: The string to measure.
196 * @n: The maximum valid length
197 *
198 * Context: User context only. This function may sleep.
199 *
200 * Get the size of a NUL-terminated string in user space.
201 *
202 * Returns the size of the string INCLUDING the terminating NUL.
203 * On exception, returns 0.
204 * If the string is too long, returns a value greater than @n.
205 */
206static inline long strnlen_user(const char __user *s, long n)
207{
208 if (!__addr_ok(s))
209 return 0;
210 else
211 return __strnlen_user(s, n);
212}
213
214/**
215 * strlen_user: - Get the size of a string in user space.
216 * @str: The string to measure.
217 *
218 * Context: User context only. This function may sleep.
219 *
220 * Get the size of a NUL-terminated string in user space.
221 *
222 * Returns the size of the string INCLUDING the terminating NUL.
223 * On exception, returns 0.
224 *
225 * If there is a limit on the length of a valid string, you may wish to
226 * consider using strnlen_user() instead.
227 */
228#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
229
230/*
231 * The exception table consists of pairs of addresses: the first is the
232 * address of an instruction that is allowed to fault, and the second is
233 * the address at which the program should continue. No registers are
234 * modified, so it is entirely up to the continuation code to figure out
235 * what to do.
236 *
237 * All the routines below use bits of fixup code that are out of line
238 * with the main instruction path. This means when everything is well,
239 * we don't even have to jump over them. Further, they do not intrude
240 * on our cache or tlb entries.
241 */
242struct exception_table_entry {
243 unsigned long insn, fixup;
244};
245
246#if defined(CONFIG_SUPERH64) && defined(CONFIG_MMU)
247#define ARCH_HAS_SEARCH_EXTABLE
248#endif
249
250int fixup_exception(struct pt_regs *regs);
251/* Returns 0 if exception not found and fixup.unit otherwise. */
252unsigned long search_exception_table(unsigned long addr);
253const struct exception_table_entry *search_exception_tables(unsigned long addr);
254
255
34#endif /* __ASM_SH_UACCESS_H */ 256#endif /* __ASM_SH_UACCESS_H */
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h
index 1e41fda74bd3..892fd6dea9db 100644
--- a/include/asm-sh/uaccess_32.h
+++ b/include/asm-sh/uaccess_32.h
@@ -1,9 +1,8 @@
1/* $Id: uaccess.h,v 1.11 2003/10/13 07:21:20 lethal Exp $ 1/*
2 *
3 * User space memory access functions 2 * User space memory access functions
4 * 3 *
5 * Copyright (C) 1999, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt 5 * Copyright (C) 2003 - 2008 Paul Mundt
7 * 6 *
8 * Based on: 7 * Based on:
9 * MIPS implementation version 1.15 by 8 * MIPS implementation version 1.15 by
@@ -13,115 +12,6 @@
13#ifndef __ASM_SH_UACCESS_32_H 12#ifndef __ASM_SH_UACCESS_32_H
14#define __ASM_SH_UACCESS_32_H 13#define __ASM_SH_UACCESS_32_H
15 14
16#include <linux/errno.h>
17#include <linux/sched.h>
18
19#define VERIFY_READ 0
20#define VERIFY_WRITE 1
21
22/*
23 * The fs value determines whether argument validity checking should be
24 * performed or not. If get_fs() == USER_DS, checking is performed, with
25 * get_fs() == KERNEL_DS, checking is bypassed.
26 *
27 * For historical reasons (Data Segment Register?), these macros are misnamed.
28 */
29
30#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
31
32#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
33#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
34
35#define segment_eq(a,b) ((a).seg == (b).seg)
36
37#define get_ds() (KERNEL_DS)
38
39#if !defined(CONFIG_MMU)
40/* NOMMU is always true */
41#define __addr_ok(addr) (1)
42
43static inline mm_segment_t get_fs(void)
44{
45 return USER_DS;
46}
47
48static inline void set_fs(mm_segment_t s)
49{
50}
51
52/*
53 * __access_ok: Check if address with size is OK or not.
54 *
55 * If we don't have an MMU (or if its disabled) the only thing we really have
56 * to look out for is if the address resides somewhere outside of what
57 * available RAM we have.
58 */
59static inline int __access_ok(unsigned long addr, unsigned long size)
60{
61 return 1;
62}
63#else /* CONFIG_MMU */
64#define __addr_ok(addr) \
65 ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
66
67#define get_fs() (current_thread_info()->addr_limit)
68#define set_fs(x) (current_thread_info()->addr_limit = (x))
69
70/*
71 * __access_ok: Check if address with size is OK or not.
72 *
73 * Uhhuh, this needs 33-bit arithmetic. We have a carry..
74 *
75 * sum := addr + size; carry? --> flag = true;
76 * if (sum >= addr_limit) flag = true;
77 */
78static inline int __access_ok(unsigned long addr, unsigned long size)
79{
80 unsigned long flag, sum;
81
82 __asm__("clrt\n\t"
83 "addc %3, %1\n\t"
84 "movt %0\n\t"
85 "cmp/hi %4, %1\n\t"
86 "rotcl %0"
87 :"=&r" (flag), "=r" (sum)
88 :"1" (addr), "r" (size),
89 "r" (current_thread_info()->addr_limit.seg)
90 :"t");
91 return flag == 0;
92}
93#endif /* CONFIG_MMU */
94
95#define access_ok(type, addr, size) \
96 (__chk_user_ptr(addr), \
97 __access_ok((unsigned long __force)(addr), (size)))
98
99/*
100 * Uh, these should become the main single-value transfer routines ...
101 * They automatically use the right size if we just have the right
102 * pointer type ...
103 *
104 * As SuperH uses the same address space for kernel and user data, we
105 * can just do these as direct assignments.
106 *
107 * Careful to not
108 * (a) re-use the arguments for side effects (sizeof is ok)
109 * (b) require any knowledge of processes at this stage
110 */
111#define put_user(x,ptr) __put_user_check((x), (ptr), sizeof(*(ptr)))
112#define get_user(x,ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))
113
114/*
115 * The "__xxx" versions do not do address space checking, useful when
116 * doing multiple accesses to the same area (the user has to do the
117 * checks by hand with "access_ok()")
118 */
119#define __put_user(x,ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
120#define __get_user(x,ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
121
122struct __large_struct { unsigned long buf[100]; };
123#define __m(x) (*(struct __large_struct __user *)(x))
124
125#define __get_user_size(x,ptr,size,retval) \ 15#define __get_user_size(x,ptr,size,retval) \
126do { \ 16do { \
127 retval = 0; \ 17 retval = 0; \
@@ -141,28 +31,7 @@ do { \
141 } \ 31 } \
142} while (0) 32} while (0)
143 33
144#define __get_user_nocheck(x,ptr,size) \ 34#ifdef CONFIG_MMU
145({ \
146 long __gu_err; \
147 unsigned long __gu_val; \
148 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
149 __chk_user_ptr(ptr); \
150 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
151 (x) = (__typeof__(*(ptr)))__gu_val; \
152 __gu_err; \
153})
154
155#define __get_user_check(x,ptr,size) \
156({ \
157 long __gu_err = -EFAULT; \
158 unsigned long __gu_val = 0; \
159 const __typeof__(*(ptr)) *__gu_addr = (ptr); \
160 if (likely(access_ok(VERIFY_READ, __gu_addr, (size)))) \
161 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
162 (x) = (__typeof__(*(ptr)))__gu_val; \
163 __gu_err; \
164})
165
166#define __get_user_asm(x, addr, err, insn) \ 35#define __get_user_asm(x, addr, err, insn) \
167({ \ 36({ \
168__asm__ __volatile__( \ 37__asm__ __volatile__( \
@@ -183,6 +52,16 @@ __asm__ __volatile__( \
183 ".previous" \ 52 ".previous" \
184 :"=&r" (err), "=&r" (x) \ 53 :"=&r" (err), "=&r" (x) \
185 :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) 54 :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
55#else
56#define __get_user_asm(x, addr, err, insn) \
57do { \
58 __asm__ __volatile__ ( \
59 "mov." insn " %1, %0\n\t" \
60 : "=&r" (x) \
61 : "m" (__m(addr)) \
62 ); \
63} while (0)
64#endif /* CONFIG_MMU */
186 65
187extern void __get_user_unknown(void); 66extern void __get_user_unknown(void);
188 67
@@ -197,7 +76,8 @@ do { \
197 __put_user_asm(x, ptr, retval, "w"); \ 76 __put_user_asm(x, ptr, retval, "w"); \
198 break; \ 77 break; \
199 case 4: \ 78 case 4: \
200 __put_user_asm(x, ptr, retval, "l"); \ 79 __put_user_asm((u32)x, ptr, \
80 retval, "l"); \
201 break; \ 81 break; \
202 case 8: \ 82 case 8: \
203 __put_user_u64(x, ptr, retval); \ 83 __put_user_u64(x, ptr, retval); \
@@ -207,45 +87,41 @@ do { \
207 } \ 87 } \
208} while (0) 88} while (0)
209 89
210#define __put_user_nocheck(x,ptr,size) \ 90#ifdef CONFIG_MMU
211({ \ 91#define __put_user_asm(x, addr, err, insn) \
212 long __pu_err; \ 92do { \
213 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 93 __asm__ __volatile__ ( \
214 __chk_user_ptr(ptr); \ 94 "1:\n\t" \
215 __put_user_size((x), __pu_addr, (size), __pu_err); \ 95 "mov." insn " %1, %2\n\t" \
216 __pu_err; \ 96 "2:\n" \
217}) 97 ".section .fixup,\"ax\"\n" \
218 98 "3:\n\t" \
219#define __put_user_check(x,ptr,size) \ 99 "mov.l 4f, %0\n\t" \
220({ \ 100 "jmp @%0\n\t" \
221 long __pu_err = -EFAULT; \ 101 " mov %3, %0\n\t" \
222 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 102 ".balign 4\n" \
223 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \ 103 "4: .long 2b\n\t" \
224 __put_user_size((x), __pu_addr, (size), \ 104 ".previous\n" \
225 __pu_err); \ 105 ".section __ex_table,\"a\"\n\t" \
226 __pu_err; \ 106 ".long 1b, 3b\n\t" \
227}) 107 ".previous" \
228 108 : "=&r" (err) \
229#define __put_user_asm(x, addr, err, insn) \ 109 : "r" (x), "m" (__m(addr)), "i" (-EFAULT), \
230({ \ 110 "0" (err) \
231__asm__ __volatile__( \ 111 : "memory" \
232 "1:\n\t" \ 112 ); \
233 "mov." insn " %1, %2\n\t" \ 113} while (0)
234 "2:\n" \ 114#else
235 ".section .fixup,\"ax\"\n" \ 115#define __put_user_asm(x, addr, err, insn) \
236 "3:\n\t" \ 116do { \
237 "mov.l 4f, %0\n\t" \ 117 __asm__ __volatile__ ( \
238 "jmp @%0\n\t" \ 118 "mov." insn " %0, %1\n\t" \
239 " mov %3, %0\n\t" \ 119 : /* no outputs */ \
240 ".balign 4\n" \ 120 : "r" (x), "m" (__m(addr)) \
241 "4: .long 2b\n\t" \ 121 : "memory" \
242 ".previous\n" \ 122 ); \
243 ".section __ex_table,\"a\"\n\t" \ 123} while (0)
244 ".long 1b, 3b\n\t" \ 124#endif /* CONFIG_MMU */
245 ".previous" \
246 :"=&r" (err) \
247 :"r" (x), "m" (__m(addr)), "i" (-EFAULT), "0" (err) \
248 :"memory"); })
249 125
250#if defined(CONFIG_CPU_LITTLE_ENDIAN) 126#if defined(CONFIG_CPU_LITTLE_ENDIAN)
251#define __put_user_u64(val,addr,retval) \ 127#define __put_user_u64(val,addr,retval) \
@@ -295,40 +171,7 @@ __asm__ __volatile__( \
295 171
296extern void __put_user_unknown(void); 172extern void __put_user_unknown(void);
297 173
298/* Generic arbitrary sized copy. */ 174static inline int
299/* Return the number of bytes NOT copied */
300__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
301
302
303static __always_inline unsigned long
304__copy_from_user(void *to, const void __user *from, unsigned long n)
305{
306 return __copy_user(to, (__force void *)from, n);
307}
308
309static __always_inline unsigned long __must_check
310__copy_to_user(void __user *to, const void *from, unsigned long n)
311{
312 return __copy_user((__force void *)to, from, n);
313}
314
315#define __copy_to_user_inatomic __copy_to_user
316#define __copy_from_user_inatomic __copy_from_user
317
318/*
319 * Clear the area and return remaining number of bytes
320 * (on failure. Usually it's 0.)
321 */
322extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
323
324#define clear_user(addr,n) ({ \
325void * __cl_addr = (addr); \
326unsigned long __cl_size = (n); \
327if (__cl_size && __access_ok(((unsigned long)(__cl_addr)), __cl_size)) \
328__cl_size = __clear_user(__cl_addr, __cl_size); \
329__cl_size; })
330
331static __inline__ int
332__strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __count) 175__strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __count)
333{ 176{
334 __kernel_size_t res; 177 __kernel_size_t res;
@@ -367,37 +210,11 @@ __strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __coun
367 return res; 210 return res;
368} 211}
369 212
370/**
371 * strncpy_from_user: - Copy a NUL terminated string from userspace.
372 * @dst: Destination address, in kernel space. This buffer must be at
373 * least @count bytes long.
374 * @src: Source address, in user space.
375 * @count: Maximum number of bytes to copy, including the trailing NUL.
376 *
377 * Copies a NUL-terminated string from userspace to kernel space.
378 *
379 * On success, returns the length of the string (not including the trailing
380 * NUL).
381 *
382 * If access to userspace fails, returns -EFAULT (some data may have been
383 * copied).
384 *
385 * If @count is smaller than the length of the string, copies @count bytes
386 * and returns @count.
387 */
388#define strncpy_from_user(dest,src,count) ({ \
389unsigned long __sfu_src = (unsigned long) (src); \
390int __sfu_count = (int) (count); \
391long __sfu_res = -EFAULT; \
392if(__access_ok(__sfu_src, __sfu_count)) { \
393__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
394} __sfu_res; })
395
396/* 213/*
397 * Return the size of a string (including the ending 0 even when we have 214 * Return the size of a string (including the ending 0 even when we have
398 * exceeded the maximum string length). 215 * exceeded the maximum string length).
399 */ 216 */
400static __inline__ long __strnlen_user(const char __user *__s, long __n) 217static inline long __strnlen_user(const char __user *__s, long __n)
401{ 218{
402 unsigned long res; 219 unsigned long res;
403 unsigned long __dummy; 220 unsigned long __dummy;
@@ -429,61 +246,4 @@ static __inline__ long __strnlen_user(const char __user *__s, long __n)
429 return res; 246 return res;
430} 247}
431 248
432/**
433 * strnlen_user: - Get the size of a string in user space.
434 * @s: The string to measure.
435 * @n: The maximum valid length
436 *
437 * Context: User context only. This function may sleep.
438 *
439 * Get the size of a NUL-terminated string in user space.
440 *
441 * Returns the size of the string INCLUDING the terminating NUL.
442 * On exception, returns 0.
443 * If the string is too long, returns a value greater than @n.
444 */
445static __inline__ long strnlen_user(const char __user *s, long n)
446{
447 if (!__addr_ok(s))
448 return 0;
449 else
450 return __strnlen_user(s, n);
451}
452
453/**
454 * strlen_user: - Get the size of a string in user space.
455 * @str: The string to measure.
456 *
457 * Context: User context only. This function may sleep.
458 *
459 * Get the size of a NUL-terminated string in user space.
460 *
461 * Returns the size of the string INCLUDING the terminating NUL.
462 * On exception, returns 0.
463 *
464 * If there is a limit on the length of a valid string, you may wish to
465 * consider using strnlen_user() instead.
466 */
467#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
468
469/*
470 * The exception table consists of pairs of addresses: the first is the
471 * address of an instruction that is allowed to fault, and the second is
472 * the address at which the program should continue. No registers are
473 * modified, so it is entirely up to the continuation code to figure out
474 * what to do.
475 *
476 * All the routines below use bits of fixup code that are out of line
477 * with the main instruction path. This means when everything is well,
478 * we don't even have to jump over them. Further, they do not intrude
479 * on our cache or tlb entries.
480 */
481
482struct exception_table_entry
483{
484 unsigned long insn, fixup;
485};
486
487extern int fixup_exception(struct pt_regs *regs);
488
489#endif /* __ASM_SH_UACCESS_32_H */ 249#endif /* __ASM_SH_UACCESS_32_H */
diff --git a/include/asm-sh/uaccess_64.h b/include/asm-sh/uaccess_64.h
index a9b68d094844..81b3d515fcb3 100644
--- a/include/asm-sh/uaccess_64.h
+++ b/include/asm-sh/uaccess_64.h
@@ -20,87 +20,6 @@
20 * License. See the file "COPYING" in the main directory of this archive 20 * License. See the file "COPYING" in the main directory of this archive
21 * for more details. 21 * for more details.
22 */ 22 */
23#include <linux/errno.h>
24#include <linux/sched.h>
25
26#define VERIFY_READ 0
27#define VERIFY_WRITE 1
28
29/*
30 * The fs value determines whether argument validity checking should be
31 * performed or not. If get_fs() == USER_DS, checking is performed, with
32 * get_fs() == KERNEL_DS, checking is bypassed.
33 *
34 * For historical reasons (Data Segment Register?), these macros are misnamed.
35 */
36
37#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
38
39#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
40#define USER_DS MAKE_MM_SEG(0x80000000)
41
42#define get_ds() (KERNEL_DS)
43#define get_fs() (current_thread_info()->addr_limit)
44#define set_fs(x) (current_thread_info()->addr_limit=(x))
45
46#define segment_eq(a,b) ((a).seg == (b).seg)
47
48#define __addr_ok(addr) ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
49
50/*
51 * Uhhuh, this needs 33-bit arithmetic. We have a carry..
52 *
53 * sum := addr + size; carry? --> flag = true;
54 * if (sum >= addr_limit) flag = true;
55 */
56#define __range_ok(addr,size) (((unsigned long) (addr) + (size) < (current_thread_info()->addr_limit.seg)) ? 0 : 1)
57
58#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
59#define __access_ok(addr,size) (__range_ok(addr,size) == 0)
60
61/*
62 * Uh, these should become the main single-value transfer routines ...
63 * They automatically use the right size if we just have the right
64 * pointer type ...
65 *
66 * As MIPS uses the same address space for kernel and user data, we
67 * can just do these as direct assignments.
68 *
69 * Careful to not
70 * (a) re-use the arguments for side effects (sizeof is ok)
71 * (b) require any knowledge of processes at this stage
72 */
73#define put_user(x,ptr) __put_user_check((x),(ptr),sizeof(*(ptr)))
74#define get_user(x,ptr) __get_user_check((x),(ptr),sizeof(*(ptr)))
75
76/*
77 * The "__xxx" versions do not do address space checking, useful when
78 * doing multiple accesses to the same area (the user has to do the
79 * checks by hand with "access_ok()")
80 */
81#define __put_user(x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
82#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
83
84/*
85 * The "xxx_ret" versions return constant specified in third argument, if
86 * something bad happens. These macros can be optimized for the
87 * case of just returning from the function xxx_ret is used.
88 */
89
90#define put_user_ret(x,ptr,ret) ({ \
91if (put_user(x,ptr)) return ret; })
92
93#define get_user_ret(x,ptr,ret) ({ \
94if (get_user(x,ptr)) return ret; })
95
96#define __put_user_ret(x,ptr,ret) ({ \
97if (__put_user(x,ptr)) return ret; })
98
99#define __get_user_ret(x,ptr,ret) ({ \
100if (__get_user(x,ptr)) return ret; })
101
102struct __large_struct { unsigned long buf[100]; };
103#define __m(x) (*(struct __large_struct *)(x))
104 23
105#define __get_user_size(x,ptr,size,retval) \ 24#define __get_user_size(x,ptr,size,retval) \
106do { \ 25do { \
@@ -124,26 +43,6 @@ do { \
124 } \ 43 } \
125} while (0) 44} while (0)
126 45
127#define __get_user_nocheck(x,ptr,size) \
128({ \
129 long __gu_err, __gu_val; \
130 __get_user_size((void *)&__gu_val, (long)(ptr), \
131 (size), __gu_err); \
132 (x) = (__typeof__(*(ptr)))__gu_val; \
133 __gu_err; \
134})
135
136#define __get_user_check(x,ptr,size) \
137({ \
138 long __gu_addr = (long)(ptr); \
139 long __gu_err = -EFAULT, __gu_val; \
140 if (__access_ok(__gu_addr, (size))) \
141 __get_user_size((void *)&__gu_val, __gu_addr, \
142 (size), __gu_err); \
143 (x) = (__typeof__(*(ptr))) __gu_val; \
144 __gu_err; \
145})
146
147extern long __get_user_asm_b(void *, long); 46extern long __get_user_asm_b(void *, long);
148extern long __get_user_asm_w(void *, long); 47extern long __get_user_asm_w(void *, long);
149extern long __get_user_asm_l(void *, long); 48extern long __get_user_asm_l(void *, long);
@@ -171,115 +70,10 @@ do { \
171 } \ 70 } \
172} while (0) 71} while (0)
173 72
174#define __put_user_nocheck(x,ptr,size) \
175({ \
176 long __pu_err; \
177 __typeof__(*(ptr)) __pu_val = (x); \
178 __put_user_size((void *)&__pu_val, (long)(ptr), (size), __pu_err); \
179 __pu_err; \
180})
181
182#define __put_user_check(x,ptr,size) \
183({ \
184 long __pu_err = -EFAULT; \
185 long __pu_addr = (long)(ptr); \
186 __typeof__(*(ptr)) __pu_val = (x); \
187 \
188 if (__access_ok(__pu_addr, (size))) \
189 __put_user_size((void *)&__pu_val, __pu_addr, (size), __pu_err);\
190 __pu_err; \
191})
192
193extern long __put_user_asm_b(void *, long); 73extern long __put_user_asm_b(void *, long);
194extern long __put_user_asm_w(void *, long); 74extern long __put_user_asm_w(void *, long);
195extern long __put_user_asm_l(void *, long); 75extern long __put_user_asm_l(void *, long);
196extern long __put_user_asm_q(void *, long); 76extern long __put_user_asm_q(void *, long);
197extern void __put_user_unknown(void); 77extern void __put_user_unknown(void);
198 78
199
200/* Generic arbitrary sized copy. */
201/* Return the number of bytes NOT copied */
202/* XXX: should be such that: 4byte and the rest. */
203extern __kernel_size_t __copy_user(void *__to, const void *__from, __kernel_size_t __n);
204
205#define copy_to_user_ret(to,from,n,retval) ({ \
206if (copy_to_user(to,from,n)) \
207 return retval; \
208})
209
210#define __copy_to_user(to,from,n) \
211 __copy_user((void *)(to), \
212 (void *)(from), n)
213
214#define __copy_to_user_ret(to,from,n,retval) ({ \
215if (__copy_to_user(to,from,n)) \
216 return retval; \
217})
218
219#define copy_from_user_ret(to,from,n,retval) ({ \
220if (copy_from_user(to,from,n)) \
221 return retval; \
222})
223
224#define __copy_from_user(to,from,n) \
225 __copy_user((void *)(to), \
226 (void *)(from), n)
227
228#define __copy_from_user_ret(to,from,n,retval) ({ \
229if (__copy_from_user(to,from,n)) \
230 return retval; \
231})
232
233#define __copy_to_user_inatomic __copy_to_user
234#define __copy_from_user_inatomic __copy_from_user
235
236/* XXX: Not sure it works well..
237 should be such that: 4byte clear and the rest. */
238extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
239
240#define clear_user(addr,n) ({ \
241void * __cl_addr = (addr); \
242unsigned long __cl_size = (n); \
243if (__cl_size && __access_ok(((unsigned long)(__cl_addr)), __cl_size)) \
244__cl_size = __clear_user(__cl_addr, __cl_size); \
245__cl_size; })
246
247extern int __strncpy_from_user(unsigned long __dest, unsigned long __src, int __count);
248
249#define strncpy_from_user(dest,src,count) ({ \
250unsigned long __sfu_src = (unsigned long) (src); \
251int __sfu_count = (int) (count); \
252long __sfu_res = -EFAULT; \
253if(__access_ok(__sfu_src, __sfu_count)) { \
254__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
255} __sfu_res; })
256
257#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
258
259/*
260 * Return the size of a string (including the ending 0!)
261 */
262extern long __strnlen_user(const char *__s, long __n);
263
264static inline long strnlen_user(const char *s, long n)
265{
266 if (!__addr_ok(s))
267 return 0;
268 else
269 return __strnlen_user(s, n);
270}
271
272struct exception_table_entry
273{
274 unsigned long insn, fixup;
275};
276
277#ifdef CONFIG_MMU
278#define ARCH_HAS_SEARCH_EXTABLE
279#endif
280
281/* Returns 0 if exception not found and fixup.unit otherwise. */
282extern unsigned long search_exception_table(unsigned long addr);
283extern const struct exception_table_entry *search_exception_tables (unsigned long addr);
284
285#endif /* __ASM_SH_UACCESS_64_H */ 79#endif /* __ASM_SH_UACCESS_64_H */
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 4b21f369c28c..65be656ead7d 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -1,5 +1,13 @@
1#ifdef CONFIG_SUPERH32 1#ifdef __KERNEL__
2# include "unistd_32.h" 2# ifdef CONFIG_SUPERH32
3# include "unistd_32.h"
4# else
5# include "unistd_64.h"
6# endif
3#else 7#else
4# include "unistd_64.h" 8# ifdef __SH5__
9# include "unistd_64.h"
10# else
11# include "unistd_32.h"
12# endif
5#endif 13#endif
diff --git a/include/asm-sh/unistd_32.h b/include/asm-sh/unistd_32.h
index 0b07212ec659..d52c000cf924 100644
--- a/include/asm-sh/unistd_32.h
+++ b/include/asm-sh/unistd_32.h
@@ -335,8 +335,14 @@
335#define __NR_fallocate 324 335#define __NR_fallocate 324
336#define __NR_timerfd_settime 325 336#define __NR_timerfd_settime 325
337#define __NR_timerfd_gettime 326 337#define __NR_timerfd_gettime 326
338#define __NR_signalfd4 327
339#define __NR_eventfd2 328
340#define __NR_epoll_create1 329
341#define __NR_dup3 330
342#define __NR_pipe2 331
343#define __NR_inotify_init1 332
338 344
339#define NR_syscalls 327 345#define NR_syscalls 333
340 346
341#ifdef __KERNEL__ 347#ifdef __KERNEL__
342 348
diff --git a/include/asm-sh/unistd_64.h b/include/asm-sh/unistd_64.h
index 9d21eab52427..7c54e91753c1 100644
--- a/include/asm-sh/unistd_64.h
+++ b/include/asm-sh/unistd_64.h
@@ -375,10 +375,16 @@
375#define __NR_fallocate 352 375#define __NR_fallocate 352
376#define __NR_timerfd_settime 353 376#define __NR_timerfd_settime 353
377#define __NR_timerfd_gettime 354 377#define __NR_timerfd_gettime 354
378#define __NR_signalfd4 355
379#define __NR_eventfd2 356
380#define __NR_epoll_create1 357
381#define __NR_dup3 358
382#define __NR_pipe2 359
383#define __NR_inotify_init1 360
378 384
379#ifdef __KERNEL__ 385#ifdef __KERNEL__
380 386
381#define NR_syscalls 353 387#define NR_syscalls 361
382 388
383#define __ARCH_WANT_IPC_PARSE_VERSION 389#define __ARCH_WANT_IPC_PARSE_VERSION
384#define __ARCH_WANT_OLD_READDIR 390#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-sparc/Kbuild b/include/asm-sparc/Kbuild
deleted file mode 100644
index 6cdaf9d33b38..000000000000
--- a/include/asm-sparc/Kbuild
+++ /dev/null
@@ -1 +0,0 @@
1# dummy file to avoid breaking make headers_install
diff --git a/include/asm-sparc/namei.h b/include/asm-sparc/namei.h
deleted file mode 100644
index eff944b8e321..000000000000
--- a/include/asm-sparc/namei.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_NAMEI_H
2#define ___ASM_SPARC_NAMEI_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm-sparc/namei_64.h>
5#else
6#include <asm-sparc/namei_32.h>
7#endif
8#endif
diff --git a/include/asm-sparc/namei_32.h b/include/asm-sparc/namei_32.h
deleted file mode 100644
index 0646102fb020..000000000000
--- a/include/asm-sparc/namei_32.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * linux/include/asm-sparc/namei.h
3 *
4 * Routines to handle famous /usr/gnemul/s*.
5 * Included from linux/fs/namei.c
6 */
7
8#ifndef __SPARC_NAMEI_H
9#define __SPARC_NAMEI_H
10
11#define __emul_prefix() NULL
12
13#endif /* __SPARC_NAMEI_H */
diff --git a/include/asm-sparc/namei_64.h b/include/asm-sparc/namei_64.h
deleted file mode 100644
index cbc1b4c06891..000000000000
--- a/include/asm-sparc/namei_64.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * linux/include/asm-sparc64/namei.h
3 *
4 * Routines to handle famous /usr/gnemul/s*.
5 * Included from linux/fs/namei.c
6 */
7
8#ifndef __SPARC64_NAMEI_H
9#define __SPARC64_NAMEI_H
10
11#define __emul_prefix() NULL
12
13#endif /* __SPARC64_NAMEI_H */
diff --git a/include/asm-sparc64/Kbuild b/include/asm-sparc64/Kbuild
deleted file mode 100644
index 6cdaf9d33b38..000000000000
--- a/include/asm-sparc64/Kbuild
+++ /dev/null
@@ -1 +0,0 @@
1# dummy file to avoid breaking make headers_install
diff --git a/include/asm-sparc64/agp.h b/include/asm-sparc64/agp.h
deleted file mode 100644
index eb8d4b3f5163..000000000000
--- a/include/asm-sparc64/agp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/agp.h>
diff --git a/include/asm-sparc64/apb.h b/include/asm-sparc64/apb.h
deleted file mode 100644
index 5e236ca6e492..000000000000
--- a/include/asm-sparc64/apb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/apb.h>
diff --git a/include/asm-sparc64/asi.h b/include/asm-sparc64/asi.h
deleted file mode 100644
index 9b7110c516e8..000000000000
--- a/include/asm-sparc64/asi.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/asi.h>
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
deleted file mode 100644
index f5126826ba34..000000000000
--- a/include/asm-sparc64/atomic.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/atomic.h>
diff --git a/include/asm-sparc64/auxio.h b/include/asm-sparc64/auxio.h
deleted file mode 100644
index 46c9042f30b4..000000000000
--- a/include/asm-sparc64/auxio.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/auxio.h>
diff --git a/include/asm-sparc64/auxvec.h b/include/asm-sparc64/auxvec.h
deleted file mode 100644
index 1f45c67d7316..000000000000
--- a/include/asm-sparc64/auxvec.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/auxvec.h>
diff --git a/include/asm-sparc64/backoff.h b/include/asm-sparc64/backoff.h
deleted file mode 100644
index 8ee26d947e0e..000000000000
--- a/include/asm-sparc64/backoff.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/backoff.h>
diff --git a/include/asm-sparc64/bbc.h b/include/asm-sparc64/bbc.h
deleted file mode 100644
index 06e8b6306514..000000000000
--- a/include/asm-sparc64/bbc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/bbc.h>
diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h
deleted file mode 100644
index 204404355bdd..000000000000
--- a/include/asm-sparc64/bitops.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/bitops.h>
diff --git a/include/asm-sparc64/bpp.h b/include/asm-sparc64/bpp.h
deleted file mode 100644
index 514eee20272e..000000000000
--- a/include/asm-sparc64/bpp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/bpp.h>
diff --git a/include/asm-sparc64/bug.h b/include/asm-sparc64/bug.h
deleted file mode 100644
index 3433737c7a67..000000000000
--- a/include/asm-sparc64/bug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/bug.h>
diff --git a/include/asm-sparc64/bugs.h b/include/asm-sparc64/bugs.h
deleted file mode 100644
index 04ae9e2818cf..000000000000
--- a/include/asm-sparc64/bugs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/bugs.h>
diff --git a/include/asm-sparc64/byteorder.h b/include/asm-sparc64/byteorder.h
deleted file mode 100644
index f672855bee17..000000000000
--- a/include/asm-sparc64/byteorder.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/byteorder.h>
diff --git a/include/asm-sparc64/cache.h b/include/asm-sparc64/cache.h
deleted file mode 100644
index fa9de5cadbf1..000000000000
--- a/include/asm-sparc64/cache.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/cache.h>
diff --git a/include/asm-sparc64/cacheflush.h b/include/asm-sparc64/cacheflush.h
deleted file mode 100644
index cf5b6b3e8a55..000000000000
--- a/include/asm-sparc64/cacheflush.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/cacheflush.h>
diff --git a/include/asm-sparc64/chafsr.h b/include/asm-sparc64/chafsr.h
deleted file mode 100644
index aaab97562a39..000000000000
--- a/include/asm-sparc64/chafsr.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/chafsr.h>
diff --git a/include/asm-sparc64/checksum.h b/include/asm-sparc64/checksum.h
deleted file mode 100644
index c3966c5e29d8..000000000000
--- a/include/asm-sparc64/checksum.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/checksum.h>
diff --git a/include/asm-sparc64/chmctrl.h b/include/asm-sparc64/chmctrl.h
deleted file mode 100644
index eb757b483b30..000000000000
--- a/include/asm-sparc64/chmctrl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/chmctrl.h>
diff --git a/include/asm-sparc64/cmt.h b/include/asm-sparc64/cmt.h
deleted file mode 100644
index b19b445cb810..000000000000
--- a/include/asm-sparc64/cmt.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/cmt.h>
diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
deleted file mode 100644
index 8c155d221952..000000000000
--- a/include/asm-sparc64/compat.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/compat.h>
diff --git a/include/asm-sparc64/compat_signal.h b/include/asm-sparc64/compat_signal.h
deleted file mode 100644
index 7187dcc8cac7..000000000000
--- a/include/asm-sparc64/compat_signal.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/compat_signal.h>
diff --git a/include/asm-sparc64/cpudata.h b/include/asm-sparc64/cpudata.h
deleted file mode 100644
index 3220e134a579..000000000000
--- a/include/asm-sparc64/cpudata.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/cpudata.h>
diff --git a/include/asm-sparc64/cputime.h b/include/asm-sparc64/cputime.h
deleted file mode 100644
index 435f37a92f7c..000000000000
--- a/include/asm-sparc64/cputime.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/cputime.h>
diff --git a/include/asm-sparc64/current.h b/include/asm-sparc64/current.h
deleted file mode 100644
index a7904a7f53a8..000000000000
--- a/include/asm-sparc64/current.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/current.h>
diff --git a/include/asm-sparc64/dcr.h b/include/asm-sparc64/dcr.h
deleted file mode 100644
index d67613b1f5fe..000000000000
--- a/include/asm-sparc64/dcr.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/dcr.h>
diff --git a/include/asm-sparc64/dcu.h b/include/asm-sparc64/dcu.h
deleted file mode 100644
index 28853f4968d1..000000000000
--- a/include/asm-sparc64/dcu.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/dcu.h>
diff --git a/include/asm-sparc64/delay.h b/include/asm-sparc64/delay.h
deleted file mode 100644
index 33dc5589d841..000000000000
--- a/include/asm-sparc64/delay.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/delay.h>
diff --git a/include/asm-sparc64/device.h b/include/asm-sparc64/device.h
deleted file mode 100644
index 4145c47097e2..000000000000
--- a/include/asm-sparc64/device.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/device.h>
diff --git a/include/asm-sparc64/display7seg.h b/include/asm-sparc64/display7seg.h
deleted file mode 100644
index e74f046b41de..000000000000
--- a/include/asm-sparc64/display7seg.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/display7seg.h>
diff --git a/include/asm-sparc64/div64.h b/include/asm-sparc64/div64.h
deleted file mode 100644
index 928c94f99ecf..000000000000
--- a/include/asm-sparc64/div64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/div64.h>
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
deleted file mode 100644
index 380b7b63147f..000000000000
--- a/include/asm-sparc64/dma-mapping.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/dma-mapping.h>
diff --git a/include/asm-sparc64/dma.h b/include/asm-sparc64/dma.h
deleted file mode 100644
index 2e36248e6b59..000000000000
--- a/include/asm-sparc64/dma.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/dma.h>
diff --git a/include/asm-sparc64/ebus.h b/include/asm-sparc64/ebus.h
deleted file mode 100644
index d7d476158bd5..000000000000
--- a/include/asm-sparc64/ebus.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ebus.h>
diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h
deleted file mode 100644
index f256d9472c82..000000000000
--- a/include/asm-sparc64/elf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/elf.h>
diff --git a/include/asm-sparc64/emergency-restart.h b/include/asm-sparc64/emergency-restart.h
deleted file mode 100644
index 2cac7b644da8..000000000000
--- a/include/asm-sparc64/emergency-restart.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/emergency-restart.h>
diff --git a/include/asm-sparc64/envctrl.h b/include/asm-sparc64/envctrl.h
deleted file mode 100644
index a2cc0ca334ba..000000000000
--- a/include/asm-sparc64/envctrl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/envctrl.h>
diff --git a/include/asm-sparc64/errno.h b/include/asm-sparc64/errno.h
deleted file mode 100644
index 9701fe01cc53..000000000000
--- a/include/asm-sparc64/errno.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/errno.h>
diff --git a/include/asm-sparc64/estate.h b/include/asm-sparc64/estate.h
deleted file mode 100644
index bedd0ef5f19c..000000000000
--- a/include/asm-sparc64/estate.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/estate.h>
diff --git a/include/asm-sparc64/fb.h b/include/asm-sparc64/fb.h
deleted file mode 100644
index 1c2ac5832f39..000000000000
--- a/include/asm-sparc64/fb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/fb.h>
diff --git a/include/asm-sparc64/fbio.h b/include/asm-sparc64/fbio.h
deleted file mode 100644
index c17edf8c7bc4..000000000000
--- a/include/asm-sparc64/fbio.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/fbio.h>
diff --git a/include/asm-sparc64/fcntl.h b/include/asm-sparc64/fcntl.h
deleted file mode 100644
index 8b1beae48cd1..000000000000
--- a/include/asm-sparc64/fcntl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/fcntl.h>
diff --git a/include/asm-sparc64/fhc.h b/include/asm-sparc64/fhc.h
deleted file mode 100644
index 73eb04c19c47..000000000000
--- a/include/asm-sparc64/fhc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/fhc.h>
diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h
deleted file mode 100644
index 214878114436..000000000000
--- a/include/asm-sparc64/floppy.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/floppy.h>
diff --git a/include/asm-sparc64/fpumacro.h b/include/asm-sparc64/fpumacro.h
deleted file mode 100644
index 30d6d0f68bc3..000000000000
--- a/include/asm-sparc64/fpumacro.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/fpumacro.h>
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
deleted file mode 100644
index 1ceb0bb2fe53..000000000000
--- a/include/asm-sparc64/futex.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/futex.h>
diff --git a/include/asm-sparc64/hardirq.h b/include/asm-sparc64/hardirq.h
deleted file mode 100644
index 63dca3db11f3..000000000000
--- a/include/asm-sparc64/hardirq.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/hardirq.h>
diff --git a/include/asm-sparc64/head.h b/include/asm-sparc64/head.h
deleted file mode 100644
index 2254c09e53f9..000000000000
--- a/include/asm-sparc64/head.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/head.h>
diff --git a/include/asm-sparc64/hugetlb.h b/include/asm-sparc64/hugetlb.h
deleted file mode 100644
index 21d8f0a9c243..000000000000
--- a/include/asm-sparc64/hugetlb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/hugetlb.h>
diff --git a/include/asm-sparc64/hvtramp.h b/include/asm-sparc64/hvtramp.h
deleted file mode 100644
index fb46bfe934a7..000000000000
--- a/include/asm-sparc64/hvtramp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/hvtramp.h>
diff --git a/include/asm-sparc64/hw_irq.h b/include/asm-sparc64/hw_irq.h
deleted file mode 100644
index 16920a291f51..000000000000
--- a/include/asm-sparc64/hw_irq.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/hw_irq.h>
diff --git a/include/asm-sparc64/hypervisor.h b/include/asm-sparc64/hypervisor.h
deleted file mode 100644
index fe7e51a9e429..000000000000
--- a/include/asm-sparc64/hypervisor.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/hypervisor.h>
diff --git a/include/asm-sparc64/ide.h b/include/asm-sparc64/ide.h
deleted file mode 100644
index 7125317a428d..000000000000
--- a/include/asm-sparc64/ide.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ide.h>
diff --git a/include/asm-sparc64/idprom.h b/include/asm-sparc64/idprom.h
deleted file mode 100644
index c22f9c30bc78..000000000000
--- a/include/asm-sparc64/idprom.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/idprom.h>
diff --git a/include/asm-sparc64/intr_queue.h b/include/asm-sparc64/intr_queue.h
deleted file mode 100644
index f7225015b3db..000000000000
--- a/include/asm-sparc64/intr_queue.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/intr_queue.h>
diff --git a/include/asm-sparc64/io.h b/include/asm-sparc64/io.h
deleted file mode 100644
index 25ff258dfd33..000000000000
--- a/include/asm-sparc64/io.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/io.h>
diff --git a/include/asm-sparc64/ioctl.h b/include/asm-sparc64/ioctl.h
deleted file mode 100644
index 18fc5623ff51..000000000000
--- a/include/asm-sparc64/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ioctl.h>
diff --git a/include/asm-sparc64/ioctls.h b/include/asm-sparc64/ioctls.h
deleted file mode 100644
index dcd5540ec103..000000000000
--- a/include/asm-sparc64/ioctls.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ioctls.h>
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
deleted file mode 100644
index 76252bb85e97..000000000000
--- a/include/asm-sparc64/iommu.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/iommu.h>
diff --git a/include/asm-sparc64/ipcbuf.h b/include/asm-sparc64/ipcbuf.h
deleted file mode 100644
index 41dfaf1149b5..000000000000
--- a/include/asm-sparc64/ipcbuf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ipcbuf.h>
diff --git a/include/asm-sparc64/irq.h b/include/asm-sparc64/irq.h
deleted file mode 100644
index b2102e65947c..000000000000
--- a/include/asm-sparc64/irq.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/irq.h>
diff --git a/include/asm-sparc64/irq_regs.h b/include/asm-sparc64/irq_regs.h
deleted file mode 100644
index 1e2b8a1e745a..000000000000
--- a/include/asm-sparc64/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/irq_regs.h>
diff --git a/include/asm-sparc64/irqflags.h b/include/asm-sparc64/irqflags.h
deleted file mode 100644
index 27b091fc3fa0..000000000000
--- a/include/asm-sparc64/irqflags.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/irqflags.h>
diff --git a/include/asm-sparc64/kdebug.h b/include/asm-sparc64/kdebug.h
deleted file mode 100644
index 78cfd5d2749b..000000000000
--- a/include/asm-sparc64/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/kdebug.h>
diff --git a/include/asm-sparc64/kgdb.h b/include/asm-sparc64/kgdb.h
deleted file mode 100644
index aa6532fd3a13..000000000000
--- a/include/asm-sparc64/kgdb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/kgdb.h>
diff --git a/include/asm-sparc64/kmap_types.h b/include/asm-sparc64/kmap_types.h
deleted file mode 100644
index 276530cf5395..000000000000
--- a/include/asm-sparc64/kmap_types.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/kmap_types.h>
diff --git a/include/asm-sparc64/kprobes.h b/include/asm-sparc64/kprobes.h
deleted file mode 100644
index c55e43e4d2a4..000000000000
--- a/include/asm-sparc64/kprobes.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/kprobes.h>
diff --git a/include/asm-sparc64/ldc.h b/include/asm-sparc64/ldc.h
deleted file mode 100644
index 40f3f231c457..000000000000
--- a/include/asm-sparc64/ldc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ldc.h>
diff --git a/include/asm-sparc64/linkage.h b/include/asm-sparc64/linkage.h
deleted file mode 100644
index 3ea4fd13f193..000000000000
--- a/include/asm-sparc64/linkage.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/linkage.h>
diff --git a/include/asm-sparc64/lmb.h b/include/asm-sparc64/lmb.h
deleted file mode 100644
index 3d04981701e2..000000000000
--- a/include/asm-sparc64/lmb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/lmb.h>
diff --git a/include/asm-sparc64/local.h b/include/asm-sparc64/local.h
deleted file mode 100644
index c11c530f74d0..000000000000
--- a/include/asm-sparc64/local.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/local.h>
diff --git a/include/asm-sparc64/lsu.h b/include/asm-sparc64/lsu.h
deleted file mode 100644
index 4e3d8b128a58..000000000000
--- a/include/asm-sparc64/lsu.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/lsu.h>
diff --git a/include/asm-sparc64/mc146818rtc.h b/include/asm-sparc64/mc146818rtc.h
deleted file mode 100644
index 97842e6ed1c2..000000000000
--- a/include/asm-sparc64/mc146818rtc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mc146818rtc.h>
diff --git a/include/asm-sparc64/mdesc.h b/include/asm-sparc64/mdesc.h
deleted file mode 100644
index 165a19347286..000000000000
--- a/include/asm-sparc64/mdesc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mdesc.h>
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
deleted file mode 100644
index 17ddb1724f51..000000000000
--- a/include/asm-sparc64/mman.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mman.h>
diff --git a/include/asm-sparc64/mmu.h b/include/asm-sparc64/mmu.h
deleted file mode 100644
index e677a64d8db1..000000000000
--- a/include/asm-sparc64/mmu.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mmu.h>
diff --git a/include/asm-sparc64/mmu_context.h b/include/asm-sparc64/mmu_context.h
deleted file mode 100644
index 877fee94bd4e..000000000000
--- a/include/asm-sparc64/mmu_context.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mmu_context.h>
diff --git a/include/asm-sparc64/mmzone.h b/include/asm-sparc64/mmzone.h
deleted file mode 100644
index 43a710f7892a..000000000000
--- a/include/asm-sparc64/mmzone.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mmzone.h>
diff --git a/include/asm-sparc64/module.h b/include/asm-sparc64/module.h
deleted file mode 100644
index a9606db55e4a..000000000000
--- a/include/asm-sparc64/module.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/module.h>
diff --git a/include/asm-sparc64/mostek.h b/include/asm-sparc64/mostek.h
deleted file mode 100644
index 95a752f7e875..000000000000
--- a/include/asm-sparc64/mostek.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mostek.h>
diff --git a/include/asm-sparc64/msgbuf.h b/include/asm-sparc64/msgbuf.h
deleted file mode 100644
index 5b33cc9d9bfb..000000000000
--- a/include/asm-sparc64/msgbuf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/msgbuf.h>
diff --git a/include/asm-sparc64/mutex.h b/include/asm-sparc64/mutex.h
deleted file mode 100644
index c0c0f8f260d6..000000000000
--- a/include/asm-sparc64/mutex.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/mutex.h>
diff --git a/include/asm-sparc64/namei.h b/include/asm-sparc64/namei.h
deleted file mode 100644
index 1344a910ba2f..000000000000
--- a/include/asm-sparc64/namei.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/namei.h>
diff --git a/include/asm-sparc64/ns87303.h b/include/asm-sparc64/ns87303.h
deleted file mode 100644
index 5f369d4df3db..000000000000
--- a/include/asm-sparc64/ns87303.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ns87303.h>
diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h
deleted file mode 100644
index a769fdbe164a..000000000000
--- a/include/asm-sparc64/of_device.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/of_device.h>
diff --git a/include/asm-sparc64/of_platform.h b/include/asm-sparc64/of_platform.h
deleted file mode 100644
index f7c427b8bc61..000000000000
--- a/include/asm-sparc64/of_platform.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/of_platform.h>
diff --git a/include/asm-sparc64/openprom.h b/include/asm-sparc64/openprom.h
deleted file mode 100644
index acf4b234fae3..000000000000
--- a/include/asm-sparc64/openprom.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/openprom.h>
diff --git a/include/asm-sparc64/openpromio.h b/include/asm-sparc64/openpromio.h
deleted file mode 100644
index 122fabda21f1..000000000000
--- a/include/asm-sparc64/openpromio.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/openpromio.h>
diff --git a/include/asm-sparc64/oplib.h b/include/asm-sparc64/oplib.h
deleted file mode 100644
index d93e44e63510..000000000000
--- a/include/asm-sparc64/oplib.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/oplib.h>
diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
deleted file mode 100644
index f46c1fb53028..000000000000
--- a/include/asm-sparc64/page.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/page.h>
diff --git a/include/asm-sparc64/param.h b/include/asm-sparc64/param.h
deleted file mode 100644
index 40c6dc110822..000000000000
--- a/include/asm-sparc64/param.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/param.h>
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
deleted file mode 100644
index b4e4ca812eb6..000000000000
--- a/include/asm-sparc64/parport.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/parport.h>
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
deleted file mode 100644
index da54c4d1f39c..000000000000
--- a/include/asm-sparc64/pci.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/pci.h>
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
deleted file mode 100644
index 292729bb350f..000000000000
--- a/include/asm-sparc64/percpu.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/percpu.h>
diff --git a/include/asm-sparc64/perfctr.h b/include/asm-sparc64/perfctr.h
deleted file mode 100644
index 52073a9f8e30..000000000000
--- a/include/asm-sparc64/perfctr.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/perfctr.h>
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
deleted file mode 100644
index bec31641011c..000000000000
--- a/include/asm-sparc64/pgalloc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/pgalloc.h>
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
deleted file mode 100644
index 9decbd99aeff..000000000000
--- a/include/asm-sparc64/pgtable.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/pgtable.h>
diff --git a/include/asm-sparc64/pil.h b/include/asm-sparc64/pil.h
deleted file mode 100644
index d805f33f1e0f..000000000000
--- a/include/asm-sparc64/pil.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/pil.h>
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h
deleted file mode 100644
index 8e2f31b4641a..000000000000
--- a/include/asm-sparc64/poll.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/poll.h>
diff --git a/include/asm-sparc64/posix_types.h b/include/asm-sparc64/posix_types.h
deleted file mode 100644
index 8cee99200232..000000000000
--- a/include/asm-sparc64/posix_types.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/posix_types.h>
diff --git a/include/asm-sparc64/processor.h b/include/asm-sparc64/processor.h
deleted file mode 100644
index 21de6cc182eb..000000000000
--- a/include/asm-sparc64/processor.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/processor.h>
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h
deleted file mode 100644
index 5fa166ee3ffa..000000000000
--- a/include/asm-sparc64/prom.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/prom.h>
diff --git a/include/asm-sparc64/psrcompat.h b/include/asm-sparc64/psrcompat.h
deleted file mode 100644
index 587846f48358..000000000000
--- a/include/asm-sparc64/psrcompat.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/psrcompat.h>
diff --git a/include/asm-sparc64/pstate.h b/include/asm-sparc64/pstate.h
deleted file mode 100644
index 3ccf0be25360..000000000000
--- a/include/asm-sparc64/pstate.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/pstate.h>
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
deleted file mode 100644
index 1a55b9fb3b0c..000000000000
--- a/include/asm-sparc64/ptrace.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ptrace.h>
diff --git a/include/asm-sparc64/reboot.h b/include/asm-sparc64/reboot.h
deleted file mode 100644
index 0d72eb811cc8..000000000000
--- a/include/asm-sparc64/reboot.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/reboot.h>
diff --git a/include/asm-sparc64/reg.h b/include/asm-sparc64/reg.h
deleted file mode 100644
index 495bab27da07..000000000000
--- a/include/asm-sparc64/reg.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/reg.h>
diff --git a/include/asm-sparc64/resource.h b/include/asm-sparc64/resource.h
deleted file mode 100644
index 46e3bc0de476..000000000000
--- a/include/asm-sparc64/resource.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/resource.h>
diff --git a/include/asm-sparc64/rtc.h b/include/asm-sparc64/rtc.h
deleted file mode 100644
index e49a9685aead..000000000000
--- a/include/asm-sparc64/rtc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/rtc.h>
diff --git a/include/asm-sparc64/rwsem-const.h b/include/asm-sparc64/rwsem-const.h
deleted file mode 100644
index 2a1de315c86a..000000000000
--- a/include/asm-sparc64/rwsem-const.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/rwsem-const.h>
diff --git a/include/asm-sparc64/rwsem.h b/include/asm-sparc64/rwsem.h
deleted file mode 100644
index 6943c56ed087..000000000000
--- a/include/asm-sparc64/rwsem.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/rwsem.h>
diff --git a/include/asm-sparc64/sbus.h b/include/asm-sparc64/sbus.h
deleted file mode 100644
index 0cab0e89b874..000000000000
--- a/include/asm-sparc64/sbus.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sbus.h>
diff --git a/include/asm-sparc64/scatterlist.h b/include/asm-sparc64/scatterlist.h
deleted file mode 100644
index b7fef95953ca..000000000000
--- a/include/asm-sparc64/scatterlist.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/scatterlist.h>
diff --git a/include/asm-sparc64/scratchpad.h b/include/asm-sparc64/scratchpad.h
deleted file mode 100644
index 23675f6a915a..000000000000
--- a/include/asm-sparc64/scratchpad.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/scratchpad.h>
diff --git a/include/asm-sparc64/seccomp.h b/include/asm-sparc64/seccomp.h
deleted file mode 100644
index f22f02a08a61..000000000000
--- a/include/asm-sparc64/seccomp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/seccomp.h>
diff --git a/include/asm-sparc64/sections.h b/include/asm-sparc64/sections.h
deleted file mode 100644
index 721496f8b2be..000000000000
--- a/include/asm-sparc64/sections.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sections.h>
diff --git a/include/asm-sparc64/sembuf.h b/include/asm-sparc64/sembuf.h
deleted file mode 100644
index c55b95214136..000000000000
--- a/include/asm-sparc64/sembuf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sembuf.h>
diff --git a/include/asm-sparc64/setup.h b/include/asm-sparc64/setup.h
deleted file mode 100644
index 7143d06b2c55..000000000000
--- a/include/asm-sparc64/setup.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/setup.h>
diff --git a/include/asm-sparc64/sfafsr.h b/include/asm-sparc64/sfafsr.h
deleted file mode 100644
index 8036fc377a4d..000000000000
--- a/include/asm-sparc64/sfafsr.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sfafsr.h>
diff --git a/include/asm-sparc64/sfp-machine.h b/include/asm-sparc64/sfp-machine.h
deleted file mode 100644
index 7bbc4fecdc7d..000000000000
--- a/include/asm-sparc64/sfp-machine.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sfp-machine.h>
diff --git a/include/asm-sparc64/shmbuf.h b/include/asm-sparc64/shmbuf.h
deleted file mode 100644
index 0c54a2d68681..000000000000
--- a/include/asm-sparc64/shmbuf.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/shmbuf.h>
diff --git a/include/asm-sparc64/shmparam.h b/include/asm-sparc64/shmparam.h
deleted file mode 100644
index 5fa3a9b05e7f..000000000000
--- a/include/asm-sparc64/shmparam.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/shmparam.h>
diff --git a/include/asm-sparc64/sigcontext.h b/include/asm-sparc64/sigcontext.h
deleted file mode 100644
index 5b16dcce44f2..000000000000
--- a/include/asm-sparc64/sigcontext.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sigcontext.h>
diff --git a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
deleted file mode 100644
index 8ffd6ebabc7a..000000000000
--- a/include/asm-sparc64/siginfo.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/siginfo.h>
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
deleted file mode 100644
index 79705e5d49c3..000000000000
--- a/include/asm-sparc64/signal.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/signal.h>
diff --git a/include/asm-sparc64/smp.h b/include/asm-sparc64/smp.h
deleted file mode 100644
index 5095a2cbea52..000000000000
--- a/include/asm-sparc64/smp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/smp.h>
diff --git a/include/asm-sparc64/socket.h b/include/asm-sparc64/socket.h
deleted file mode 100644
index 13e0d5d94bb3..000000000000
--- a/include/asm-sparc64/socket.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/socket.h>
diff --git a/include/asm-sparc64/sockios.h b/include/asm-sparc64/sockios.h
deleted file mode 100644
index 2cb4b641482c..000000000000
--- a/include/asm-sparc64/sockios.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sockios.h>
diff --git a/include/asm-sparc64/sparsemem.h b/include/asm-sparc64/sparsemem.h
deleted file mode 100644
index e681f22a97ae..000000000000
--- a/include/asm-sparc64/sparsemem.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sparsemem.h>
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h
deleted file mode 100644
index 0115b8156eb8..000000000000
--- a/include/asm-sparc64/spinlock.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/spinlock.h>
diff --git a/include/asm-sparc64/spinlock_types.h b/include/asm-sparc64/spinlock_types.h
deleted file mode 100644
index 48d81c8734b5..000000000000
--- a/include/asm-sparc64/spinlock_types.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/spinlock_types.h>
diff --git a/include/asm-sparc64/spitfire.h b/include/asm-sparc64/spitfire.h
deleted file mode 100644
index 4430d2fbb0dc..000000000000
--- a/include/asm-sparc64/spitfire.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/spitfire.h>
diff --git a/include/asm-sparc64/sstate.h b/include/asm-sparc64/sstate.h
deleted file mode 100644
index 97720ce2fd43..000000000000
--- a/include/asm-sparc64/sstate.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sstate.h>
diff --git a/include/asm-sparc64/stacktrace.h b/include/asm-sparc64/stacktrace.h
deleted file mode 100644
index adc9b92c0ef1..000000000000
--- a/include/asm-sparc64/stacktrace.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/stacktrace.h>
diff --git a/include/asm-sparc64/starfire.h b/include/asm-sparc64/starfire.h
deleted file mode 100644
index db97daa3bed4..000000000000
--- a/include/asm-sparc64/starfire.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/starfire.h>
diff --git a/include/asm-sparc64/stat.h b/include/asm-sparc64/stat.h
deleted file mode 100644
index b108a866256b..000000000000
--- a/include/asm-sparc64/stat.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/stat.h>
diff --git a/include/asm-sparc64/statfs.h b/include/asm-sparc64/statfs.h
deleted file mode 100644
index 5503d6a4c67e..000000000000
--- a/include/asm-sparc64/statfs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/statfs.h>
diff --git a/include/asm-sparc64/string.h b/include/asm-sparc64/string.h
deleted file mode 100644
index 5018cd8b6ad0..000000000000
--- a/include/asm-sparc64/string.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/string.h>
diff --git a/include/asm-sparc64/sunbpp.h b/include/asm-sparc64/sunbpp.h
deleted file mode 100644
index 9632be290eb5..000000000000
--- a/include/asm-sparc64/sunbpp.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/sunbpp.h>
diff --git a/include/asm-sparc64/syscalls.h b/include/asm-sparc64/syscalls.h
deleted file mode 100644
index 3477b16e30ca..000000000000
--- a/include/asm-sparc64/syscalls.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/syscalls.h>
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
deleted file mode 100644
index be2603c2e527..000000000000
--- a/include/asm-sparc64/system.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/system.h>
diff --git a/include/asm-sparc64/termbits.h b/include/asm-sparc64/termbits.h
deleted file mode 100644
index e03f97592c70..000000000000
--- a/include/asm-sparc64/termbits.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/termbits.h>
diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h
deleted file mode 100644
index 940495eb05cc..000000000000
--- a/include/asm-sparc64/termios.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/termios.h>
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
deleted file mode 100644
index 92bed7913395..000000000000
--- a/include/asm-sparc64/thread_info.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/thread_info.h>
diff --git a/include/asm-sparc64/timer.h b/include/asm-sparc64/timer.h
deleted file mode 100644
index 88026d83cc93..000000000000
--- a/include/asm-sparc64/timer.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/timer.h>
diff --git a/include/asm-sparc64/timex.h b/include/asm-sparc64/timex.h
deleted file mode 100644
index 8dd59ee24b48..000000000000
--- a/include/asm-sparc64/timex.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/timex.h>
diff --git a/include/asm-sparc64/tlb.h b/include/asm-sparc64/tlb.h
deleted file mode 100644
index ae92fce10936..000000000000
--- a/include/asm-sparc64/tlb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/tlb.h>
diff --git a/include/asm-sparc64/tlbflush.h b/include/asm-sparc64/tlbflush.h
deleted file mode 100644
index a43979a06cd9..000000000000
--- a/include/asm-sparc64/tlbflush.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/tlbflush.h>
diff --git a/include/asm-sparc64/topology.h b/include/asm-sparc64/topology.h
deleted file mode 100644
index 46999b60fbba..000000000000
--- a/include/asm-sparc64/topology.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/topology.h>
diff --git a/include/asm-sparc64/tsb.h b/include/asm-sparc64/tsb.h
deleted file mode 100644
index 3677a302ea3e..000000000000
--- a/include/asm-sparc64/tsb.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/tsb.h>
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
deleted file mode 100644
index a550f1bf6f9b..000000000000
--- a/include/asm-sparc64/ttable.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/ttable.h>
diff --git a/include/asm-sparc64/types.h b/include/asm-sparc64/types.h
deleted file mode 100644
index cfbfad5043eb..000000000000
--- a/include/asm-sparc64/types.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/types.h>
diff --git a/include/asm-sparc64/uaccess.h b/include/asm-sparc64/uaccess.h
deleted file mode 100644
index 2872d22844f3..000000000000
--- a/include/asm-sparc64/uaccess.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/uaccess.h>
diff --git a/include/asm-sparc64/uctx.h b/include/asm-sparc64/uctx.h
deleted file mode 100644
index 9e1b5794b07f..000000000000
--- a/include/asm-sparc64/uctx.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/uctx.h>
diff --git a/include/asm-sparc64/unaligned.h b/include/asm-sparc64/unaligned.h
deleted file mode 100644
index 19fbf9508acf..000000000000
--- a/include/asm-sparc64/unaligned.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/unaligned.h>
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
deleted file mode 100644
index ad86e0b7a455..000000000000
--- a/include/asm-sparc64/unistd.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/unistd.h>
diff --git a/include/asm-sparc64/upa.h b/include/asm-sparc64/upa.h
deleted file mode 100644
index aab72930815a..000000000000
--- a/include/asm-sparc64/upa.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/upa.h>
diff --git a/include/asm-sparc64/user.h b/include/asm-sparc64/user.h
deleted file mode 100644
index 29fc6e906c29..000000000000
--- a/include/asm-sparc64/user.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/user.h>
diff --git a/include/asm-sparc64/utrap.h b/include/asm-sparc64/utrap.h
deleted file mode 100644
index b030a41f1895..000000000000
--- a/include/asm-sparc64/utrap.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/utrap.h>
diff --git a/include/asm-sparc64/vga.h b/include/asm-sparc64/vga.h
deleted file mode 100644
index fbf4d58a56f0..000000000000
--- a/include/asm-sparc64/vga.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/vga.h>
diff --git a/include/asm-sparc64/vio.h b/include/asm-sparc64/vio.h
deleted file mode 100644
index 299b26ab81a7..000000000000
--- a/include/asm-sparc64/vio.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/vio.h>
diff --git a/include/asm-sparc64/visasm.h b/include/asm-sparc64/visasm.h
deleted file mode 100644
index 837a12278f4a..000000000000
--- a/include/asm-sparc64/visasm.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/visasm.h>
diff --git a/include/asm-sparc64/watchdog.h b/include/asm-sparc64/watchdog.h
deleted file mode 100644
index b0f2857145f7..000000000000
--- a/include/asm-sparc64/watchdog.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/watchdog.h>
diff --git a/include/asm-sparc64/xor.h b/include/asm-sparc64/xor.h
deleted file mode 100644
index ef187cc07ed5..000000000000
--- a/include/asm-sparc64/xor.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/xor.h>
diff --git a/include/asm-um/namei.h b/include/asm-um/namei.h
deleted file mode 100644
index 002984d5bc85..000000000000
--- a/include/asm-um/namei.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __UM_NAMEI_H
2#define __UM_NAMEI_H
3
4#include "asm/arch/namei.h"
5
6#endif
diff --git a/include/asm-v850/namei.h b/include/asm-v850/namei.h
deleted file mode 100644
index ee8339b23843..000000000000
--- a/include/asm-v850/namei.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * linux/include/asm-v850/namei.h
3 *
4 * Included from linux/fs/namei.c
5 */
6
7#ifndef __V850_NAMEI_H__
8#define __V850_NAMEI_H__
9
10/* This dummy routine maybe changed to something useful
11 * for /usr/gnemul/ emulation stuff.
12 * Look at asm-sparc/namei.h for details.
13 */
14
15#define __emul_prefix() NULL
16
17#endif /* __V850_NAMEI_H__ */
diff --git a/include/asm-x86/device.h b/include/asm-x86/device.h
index dbe885543895..1bece04c7d9d 100644
--- a/include/asm-x86/device.h
+++ b/include/asm-x86/device.h
@@ -5,6 +5,9 @@ struct dev_archdata {
5#ifdef CONFIG_ACPI 5#ifdef CONFIG_ACPI
6 void *acpi_handle; 6 void *acpi_handle;
7#endif 7#endif
8#ifdef CONFIG_X86_64
9struct dma_mapping_ops *dma_ops;
10#endif
8#ifdef CONFIG_DMAR 11#ifdef CONFIG_DMAR
9 void *iommu; /* hook for IOMMU specific extension */ 12 void *iommu; /* hook for IOMMU specific extension */
10#endif 13#endif
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 71b6f7d22e9a..5d200e78bd81 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -17,7 +17,8 @@ extern int panic_on_overflow;
17extern int force_iommu; 17extern int force_iommu;
18 18
19struct dma_mapping_ops { 19struct dma_mapping_ops {
20 int (*mapping_error)(dma_addr_t dma_addr); 20 int (*mapping_error)(struct device *dev,
21 dma_addr_t dma_addr);
21 void* (*alloc_coherent)(struct device *dev, size_t size, 22 void* (*alloc_coherent)(struct device *dev, size_t size,
22 dma_addr_t *dma_handle, gfp_t gfp); 23 dma_addr_t *dma_handle, gfp_t gfp);
23 void (*free_coherent)(struct device *dev, size_t size, 24 void (*free_coherent)(struct device *dev, size_t size,
@@ -56,14 +57,32 @@ struct dma_mapping_ops {
56 int is_phys; 57 int is_phys;
57}; 58};
58 59
59extern const struct dma_mapping_ops *dma_ops; 60extern struct dma_mapping_ops *dma_ops;
60 61
61static inline int dma_mapping_error(dma_addr_t dma_addr) 62static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
62{ 63{
63 if (dma_ops->mapping_error) 64#ifdef CONFIG_X86_32
64 return dma_ops->mapping_error(dma_addr); 65 return dma_ops;
66#else
67 if (unlikely(!dev) || !dev->archdata.dma_ops)
68 return dma_ops;
69 else
70 return dev->archdata.dma_ops;
71#endif
72}
73
74/* Make sure we keep the same behaviour */
75static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
76{
77#ifdef CONFIG_X86_32
78 return 0;
79#else
80 struct dma_mapping_ops *ops = get_dma_ops(dev);
81 if (ops->mapping_error)
82 return ops->mapping_error(dev, dma_addr);
65 83
66 return (dma_addr == bad_dma_address); 84 return (dma_addr == bad_dma_address);
85#endif
67} 86}
68 87
69#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 88#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
@@ -83,44 +102,53 @@ static inline dma_addr_t
83dma_map_single(struct device *hwdev, void *ptr, size_t size, 102dma_map_single(struct device *hwdev, void *ptr, size_t size,
84 int direction) 103 int direction)
85{ 104{
105 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
106
86 BUG_ON(!valid_dma_direction(direction)); 107 BUG_ON(!valid_dma_direction(direction));
87 return dma_ops->map_single(hwdev, virt_to_phys(ptr), size, direction); 108 return ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
88} 109}
89 110
90static inline void 111static inline void
91dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size, 112dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size,
92 int direction) 113 int direction)
93{ 114{
115 struct dma_mapping_ops *ops = get_dma_ops(dev);
116
94 BUG_ON(!valid_dma_direction(direction)); 117 BUG_ON(!valid_dma_direction(direction));
95 if (dma_ops->unmap_single) 118 if (ops->unmap_single)
96 dma_ops->unmap_single(dev, addr, size, direction); 119 ops->unmap_single(dev, addr, size, direction);
97} 120}
98 121
99static inline int 122static inline int
100dma_map_sg(struct device *hwdev, struct scatterlist *sg, 123dma_map_sg(struct device *hwdev, struct scatterlist *sg,
101 int nents, int direction) 124 int nents, int direction)
102{ 125{
126 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
127
103 BUG_ON(!valid_dma_direction(direction)); 128 BUG_ON(!valid_dma_direction(direction));
104 return dma_ops->map_sg(hwdev, sg, nents, direction); 129 return ops->map_sg(hwdev, sg, nents, direction);
105} 130}
106 131
107static inline void 132static inline void
108dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, 133dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
109 int direction) 134 int direction)
110{ 135{
136 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
137
111 BUG_ON(!valid_dma_direction(direction)); 138 BUG_ON(!valid_dma_direction(direction));
112 if (dma_ops->unmap_sg) 139 if (ops->unmap_sg)
113 dma_ops->unmap_sg(hwdev, sg, nents, direction); 140 ops->unmap_sg(hwdev, sg, nents, direction);
114} 141}
115 142
116static inline void 143static inline void
117dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle, 144dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
118 size_t size, int direction) 145 size_t size, int direction)
119{ 146{
147 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
148
120 BUG_ON(!valid_dma_direction(direction)); 149 BUG_ON(!valid_dma_direction(direction));
121 if (dma_ops->sync_single_for_cpu) 150 if (ops->sync_single_for_cpu)
122 dma_ops->sync_single_for_cpu(hwdev, dma_handle, size, 151 ops->sync_single_for_cpu(hwdev, dma_handle, size, direction);
123 direction);
124 flush_write_buffers(); 152 flush_write_buffers();
125} 153}
126 154
@@ -128,10 +156,11 @@ static inline void
128dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle, 156dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
129 size_t size, int direction) 157 size_t size, int direction)
130{ 158{
159 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
160
131 BUG_ON(!valid_dma_direction(direction)); 161 BUG_ON(!valid_dma_direction(direction));
132 if (dma_ops->sync_single_for_device) 162 if (ops->sync_single_for_device)
133 dma_ops->sync_single_for_device(hwdev, dma_handle, size, 163 ops->sync_single_for_device(hwdev, dma_handle, size, direction);
134 direction);
135 flush_write_buffers(); 164 flush_write_buffers();
136} 165}
137 166
@@ -139,11 +168,12 @@ static inline void
139dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle, 168dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
140 unsigned long offset, size_t size, int direction) 169 unsigned long offset, size_t size, int direction)
141{ 170{
142 BUG_ON(!valid_dma_direction(direction)); 171 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
143 if (dma_ops->sync_single_range_for_cpu)
144 dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
145 size, direction);
146 172
173 BUG_ON(!valid_dma_direction(direction));
174 if (ops->sync_single_range_for_cpu)
175 ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
176 size, direction);
147 flush_write_buffers(); 177 flush_write_buffers();
148} 178}
149 179
@@ -152,11 +182,12 @@ dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
152 unsigned long offset, size_t size, 182 unsigned long offset, size_t size,
153 int direction) 183 int direction)
154{ 184{
155 BUG_ON(!valid_dma_direction(direction)); 185 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
156 if (dma_ops->sync_single_range_for_device)
157 dma_ops->sync_single_range_for_device(hwdev, dma_handle,
158 offset, size, direction);
159 186
187 BUG_ON(!valid_dma_direction(direction));
188 if (ops->sync_single_range_for_device)
189 ops->sync_single_range_for_device(hwdev, dma_handle,
190 offset, size, direction);
160 flush_write_buffers(); 191 flush_write_buffers();
161} 192}
162 193
@@ -164,9 +195,11 @@ static inline void
164dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, 195dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
165 int nelems, int direction) 196 int nelems, int direction)
166{ 197{
198 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
199
167 BUG_ON(!valid_dma_direction(direction)); 200 BUG_ON(!valid_dma_direction(direction));
168 if (dma_ops->sync_sg_for_cpu) 201 if (ops->sync_sg_for_cpu)
169 dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction); 202 ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
170 flush_write_buffers(); 203 flush_write_buffers();
171} 204}
172 205
@@ -174,9 +207,11 @@ static inline void
174dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, 207dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
175 int nelems, int direction) 208 int nelems, int direction)
176{ 209{
210 struct dma_mapping_ops *ops = get_dma_ops(hwdev);
211
177 BUG_ON(!valid_dma_direction(direction)); 212 BUG_ON(!valid_dma_direction(direction));
178 if (dma_ops->sync_sg_for_device) 213 if (ops->sync_sg_for_device)
179 dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction); 214 ops->sync_sg_for_device(hwdev, sg, nelems, direction);
180 215
181 flush_write_buffers(); 216 flush_write_buffers();
182} 217}
@@ -185,9 +220,11 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
185 size_t offset, size_t size, 220 size_t offset, size_t size,
186 int direction) 221 int direction)
187{ 222{
223 struct dma_mapping_ops *ops = get_dma_ops(dev);
224
188 BUG_ON(!valid_dma_direction(direction)); 225 BUG_ON(!valid_dma_direction(direction));
189 return dma_ops->map_single(dev, page_to_phys(page)+offset, 226 return ops->map_single(dev, page_to_phys(page) + offset,
190 size, direction); 227 size, direction);
191} 228}
192 229
193static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, 230static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
@@ -212,25 +249,5 @@ static inline int dma_get_cache_alignment(void)
212 249
213#define dma_is_consistent(d, h) (1) 250#define dma_is_consistent(d, h) (1)
214 251
215#ifdef CONFIG_X86_32 252#include <asm-generic/dma-coherent.h>
216# define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
217struct dma_coherent_mem {
218 void *virt_base;
219 u32 device_base;
220 int size;
221 int flags;
222 unsigned long *bitmap;
223};
224
225extern int
226dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
227 dma_addr_t device_addr, size_t size, int flags);
228
229extern void
230dma_release_declared_memory(struct device *dev);
231
232extern void *
233dma_mark_declared_memory_occupied(struct device *dev,
234 dma_addr_t device_addr, size_t size);
235#endif /* CONFIG_X86_32 */
236#endif /* ASM_X86__DMA_MAPPING_H */ 253#endif /* ASM_X86__DMA_MAPPING_H */
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index 4f3d212d8270..bdb823e6edb4 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -3,6 +3,7 @@
3 3
4extern void pci_iommu_shutdown(void); 4extern void pci_iommu_shutdown(void);
5extern void no_iommu_init(void); 5extern void no_iommu_init(void);
6extern struct dma_mapping_ops nommu_dma_ops;
6extern int force_iommu, no_iommu; 7extern int force_iommu, no_iommu;
7extern int iommu_detected; 8extern int iommu_detected;
8 9
diff --git a/include/asm-x86/kexec.h b/include/asm-x86/kexec.h
index 262b63ec9112..17bde9552a88 100644
--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -10,14 +10,15 @@
10# define VA_PTE_0 5 10# define VA_PTE_0 5
11# define PA_PTE_1 6 11# define PA_PTE_1 6
12# define VA_PTE_1 7 12# define VA_PTE_1 7
13# define PA_SWAP_PAGE 8
13# ifdef CONFIG_X86_PAE 14# ifdef CONFIG_X86_PAE
14# define PA_PMD_0 8 15# define PA_PMD_0 9
15# define VA_PMD_0 9 16# define VA_PMD_0 10
16# define PA_PMD_1 10 17# define PA_PMD_1 11
17# define VA_PMD_1 11 18# define VA_PMD_1 12
18# define PAGES_NR 12 19# define PAGES_NR 13
19# else 20# else
20# define PAGES_NR 8 21# define PAGES_NR 9
21# endif 22# endif
22#else 23#else
23# define PA_CONTROL_PAGE 0 24# define PA_CONTROL_PAGE 0
@@ -152,11 +153,12 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
152} 153}
153 154
154#ifdef CONFIG_X86_32 155#ifdef CONFIG_X86_32
155asmlinkage NORET_TYPE void 156asmlinkage unsigned long
156relocate_kernel(unsigned long indirection_page, 157relocate_kernel(unsigned long indirection_page,
157 unsigned long control_page, 158 unsigned long control_page,
158 unsigned long start_address, 159 unsigned long start_address,
159 unsigned int has_pae) ATTRIB_NORET; 160 unsigned int has_pae,
161 unsigned int preserve_context);
160#else 162#else
161NORET_TYPE void 163NORET_TYPE void
162relocate_kernel(unsigned long indirection_page, 164relocate_kernel(unsigned long indirection_page,
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 920823d53d6e..95eb742765b3 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -556,6 +556,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
556int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); 556int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
557 557
558void kvm_enable_tdp(void); 558void kvm_enable_tdp(void);
559void kvm_disable_tdp(void);
559 560
560int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 561int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
561int complete_pio(struct kvm_vcpu *vcpu); 562int complete_pio(struct kvm_vcpu *vcpu);
diff --git a/include/asm-x86/namei.h b/include/asm-x86/namei.h
deleted file mode 100644
index 6e5de58c10cc..000000000000
--- a/include/asm-x86/namei.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef ASM_X86__NAMEI_H
2#define ASM_X86__NAMEI_H
3
4/* This dummy routine maybe changed to something useful
5 * for /usr/gnemul/ emulation stuff.
6 * Look at asm-sparc/namei.h for details.
7 */
8
9#define __emul_prefix() NULL
10
11#endif /* ASM_X86__NAMEI_H */
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 3ca03f902e05..70fcb2adbb71 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -18,6 +18,7 @@
18#define _PAGE_BIT_UNUSED2 10 18#define _PAGE_BIT_UNUSED2 10
19#define _PAGE_BIT_UNUSED3 11 19#define _PAGE_BIT_UNUSED3 11
20#define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ 20#define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
21#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
21#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ 22#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
22 23
23#define _PAGE_PRESENT (_AT(pteval_t, 1) << _PAGE_BIT_PRESENT) 24#define _PAGE_PRESENT (_AT(pteval_t, 1) << _PAGE_BIT_PRESENT)
@@ -34,6 +35,8 @@
34#define _PAGE_UNUSED3 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED3) 35#define _PAGE_UNUSED3 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED3)
35#define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT) 36#define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
36#define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE) 37#define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
38#define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL)
39#define __HAVE_ARCH_PTE_SPECIAL
37 40
38#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 41#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
39#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) 42#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
@@ -54,7 +57,7 @@
54 57
55/* Set of bits not changed in pte_modify */ 58/* Set of bits not changed in pte_modify */
56#define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \ 59#define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \
57 _PAGE_ACCESSED | _PAGE_DIRTY) 60 _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY)
58 61
59#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT) 62#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)
60#define _PAGE_CACHE_WB (0) 63#define _PAGE_CACHE_WB (0)
@@ -180,7 +183,7 @@ static inline int pte_exec(pte_t pte)
180 183
181static inline int pte_special(pte_t pte) 184static inline int pte_special(pte_t pte)
182{ 185{
183 return 0; 186 return pte_val(pte) & _PAGE_SPECIAL;
184} 187}
185 188
186static inline int pmd_large(pmd_t pte) 189static inline int pmd_large(pmd_t pte)
@@ -246,7 +249,7 @@ static inline pte_t pte_clrglobal(pte_t pte)
246 249
247static inline pte_t pte_mkspecial(pte_t pte) 250static inline pte_t pte_mkspecial(pte_t pte)
248{ 251{
249 return pte; 252 return __pte(pte_val(pte) | _PAGE_SPECIAL);
250} 253}
251 254
252extern pteval_t __supported_pte_mask; 255extern pteval_t __supported_pte_mask;
diff --git a/include/asm-x86/swiotlb.h b/include/asm-x86/swiotlb.h
index 9486c400a71d..1e20adbcad4b 100644
--- a/include/asm-x86/swiotlb.h
+++ b/include/asm-x86/swiotlb.h
@@ -35,7 +35,7 @@ extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
35 int nents, int direction); 35 int nents, int direction);
36extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, 36extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
37 int nents, int direction); 37 int nents, int direction);
38extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr); 38extern int swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
39extern void swiotlb_free_coherent(struct device *hwdev, size_t size, 39extern void swiotlb_free_coherent(struct device *hwdev, size_t size,
40 void *vaddr, dma_addr_t dma_handle); 40 void *vaddr, dma_addr_t dma_handle);
41extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); 41extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h
index 1838f3959a5e..48ebc0ad40ec 100644
--- a/include/asm-x86/uaccess.h
+++ b/include/asm-x86/uaccess.h
@@ -451,3 +451,4 @@ extern struct movsl_mask {
451#endif 451#endif
452 452
453#endif /* ASM_X86__UACCESS_H */ 453#endif /* ASM_X86__UACCESS_H */
454
diff --git a/include/asm-xtensa/dma-mapping.h b/include/asm-xtensa/dma-mapping.h
index 3c7d537dd15d..51882ae3db4d 100644
--- a/include/asm-xtensa/dma-mapping.h
+++ b/include/asm-xtensa/dma-mapping.h
@@ -139,7 +139,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
139 consistent_sync(sg_virt(sg), sg->length, dir); 139 consistent_sync(sg_virt(sg), sg->length, dir);
140} 140}
141static inline int 141static inline int
142dma_mapping_error(dma_addr_t dma_addr) 142dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
143{ 143{
144 return 0; 144 return 0;
145} 145}
diff --git a/include/asm-xtensa/namei.h b/include/asm-xtensa/namei.h
deleted file mode 100644
index 3fdff039d27d..000000000000
--- a/include/asm-xtensa/namei.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * include/asm-xtensa/namei.h
3 *
4 * Included from linux/fs/namei.c
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */
12
13#ifndef _XTENSA_NAMEI_H
14#define _XTENSA_NAMEI_H
15
16#ifdef __KERNEL__
17
18/* This dummy routine maybe changed to something useful
19 * for /usr/gnemul/ emulation stuff.
20 * Look at asm-sparc/namei.h for details.
21 */
22
23#define __emul_prefix() NULL
24
25#endif /* __KERNEL__ */
26#endif /* _XTENSA_NAMEI_H */
diff --git a/include/linux/aio.h b/include/linux/aio.h
index b51ddd28444e..09b276c35227 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -7,7 +7,6 @@
7#include <linux/uio.h> 7#include <linux/uio.h>
8 8
9#include <asm/atomic.h> 9#include <asm/atomic.h>
10#include <linux/uio.h>
11 10
12#define AIO_MAXSEGS 4 11#define AIO_MAXSEGS 4
13#define AIO_KIOGRP_NR_ATOMIC 8 12#define AIO_KIOGRP_NR_ATOMIC 8
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 82aa36c53ea7..50cfe8ceb478 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -205,6 +205,8 @@ void block_invalidatepage(struct page *page, unsigned long offset);
205int block_write_full_page(struct page *page, get_block_t *get_block, 205int block_write_full_page(struct page *page, get_block_t *get_block,
206 struct writeback_control *wbc); 206 struct writeback_control *wbc);
207int block_read_full_page(struct page*, get_block_t*); 207int block_read_full_page(struct page*, get_block_t*);
208int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
209 unsigned long from);
208int block_write_begin(struct file *, struct address_space *, 210int block_write_begin(struct file *, struct address_space *,
209 loff_t, unsigned, unsigned, 211 loff_t, unsigned, unsigned,
210 struct page **, void **, get_block_t*); 212 struct page **, void **, get_block_t*);
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index 31b75311e2ca..dcc228aa335a 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -37,7 +37,7 @@ extern const struct file_operations coda_ioctl_operations;
37/* operations shared over more than one file */ 37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f); 38int coda_open(struct inode *i, struct file *f);
39int coda_release(struct inode *i, struct file *f); 39int coda_release(struct inode *i, struct file *f);
40int coda_permission(struct inode *inode, int mask, struct nameidata *nd); 40int coda_permission(struct inode *inode, int mask);
41int coda_revalidate_inode(struct dentry *); 41int coda_revalidate_inode(struct dentry *);
42int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *); 42int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
43int coda_setattr(struct dentry *, struct iattr *); 43int coda_setattr(struct dentry *, struct iattr *);
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 1b5c98e7fef7..96d0509fb8d8 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -62,15 +62,7 @@
62 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids 62 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
63 * 63 *
64 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set 64 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
65 *ifdef CONFIG_HAS_CPUMASK_OF_CPU 65 * (can be used as an lvalue)
66 * cpumask_of_cpu_ptr_declare(v) Declares cpumask_t *v
67 * cpumask_of_cpu_ptr_next(v, cpu) Sets v = &cpumask_of_cpu_map[cpu]
68 * cpumask_of_cpu_ptr(v, cpu) Combines above two operations
69 *else
70 * cpumask_of_cpu_ptr_declare(v) Declares cpumask_t _v and *v = &_v
71 * cpumask_of_cpu_ptr_next(v, cpu) Sets _v = cpumask_of_cpu(cpu)
72 * cpumask_of_cpu_ptr(v, cpu) Combines above two operations
73 *endif
74 * CPU_MASK_ALL Initializer - all bits set 66 * CPU_MASK_ALL Initializer - all bits set
75 * CPU_MASK_NONE Initializer - no bits set 67 * CPU_MASK_NONE Initializer - no bits set
76 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask 68 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
@@ -273,37 +265,30 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
273 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 265 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
274} 266}
275 267
268/*
269 * Special-case data structure for "single bit set only" constant CPU masks.
270 *
271 * We pre-generate all the 64 (or 32) possible bit positions, with enough
272 * padding to the left and the right, and return the constant pointer
273 * appropriately offset.
274 */
275extern const unsigned long
276 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
277
278static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
279{
280 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
281 p -= cpu / BITS_PER_LONG;
282 return (const cpumask_t *)p;
283}
284
285/*
286 * In cases where we take the address of the cpumask immediately,
287 * gcc optimizes it out (it's a constant) and there's no huge stack
288 * variable created:
289 */
290#define cpumask_of_cpu(cpu) ({ *get_cpu_mask(cpu); })
276 291
277#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
278extern cpumask_t *cpumask_of_cpu_map;
279#define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu])
280#define cpumask_of_cpu_ptr(v, cpu) \
281 const cpumask_t *v = &cpumask_of_cpu(cpu)
282#define cpumask_of_cpu_ptr_declare(v) \
283 const cpumask_t *v
284#define cpumask_of_cpu_ptr_next(v, cpu) \
285 v = &cpumask_of_cpu(cpu)
286#else
287#define cpumask_of_cpu(cpu) \
288({ \
289 typeof(_unused_cpumask_arg_) m; \
290 if (sizeof(m) == sizeof(unsigned long)) { \
291 m.bits[0] = 1UL<<(cpu); \
292 } else { \
293 cpus_clear(m); \
294 cpu_set((cpu), m); \
295 } \
296 m; \
297})
298#define cpumask_of_cpu_ptr(v, cpu) \
299 cpumask_t _##v = cpumask_of_cpu(cpu); \
300 const cpumask_t *v = &_##v
301#define cpumask_of_cpu_ptr_declare(v) \
302 cpumask_t _##v; \
303 const cpumask_t *v = &_##v
304#define cpumask_of_cpu_ptr_next(v, cpu) \
305 _##v = cpumask_of_cpu(cpu)
306#endif
307 292
308#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 293#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
309 294
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 49d8eb7a71be..580b513668fe 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -60,6 +60,8 @@ extern int dir_notify_enable;
60#define MAY_WRITE 2 60#define MAY_WRITE 2
61#define MAY_READ 4 61#define MAY_READ 4
62#define MAY_APPEND 8 62#define MAY_APPEND 8
63#define MAY_ACCESS 16
64#define MAY_OPEN 32
63 65
64#define FMODE_READ 1 66#define FMODE_READ 1
65#define FMODE_WRITE 2 67#define FMODE_WRITE 2
@@ -277,7 +279,7 @@ extern int dir_notify_enable;
277#include <linux/types.h> 279#include <linux/types.h>
278#include <linux/kdev_t.h> 280#include <linux/kdev_t.h>
279#include <linux/dcache.h> 281#include <linux/dcache.h>
280#include <linux/namei.h> 282#include <linux/path.h>
281#include <linux/stat.h> 283#include <linux/stat.h>
282#include <linux/cache.h> 284#include <linux/cache.h>
283#include <linux/kobject.h> 285#include <linux/kobject.h>
@@ -318,22 +320,23 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
318 * Attribute flags. These should be or-ed together to figure out what 320 * Attribute flags. These should be or-ed together to figure out what
319 * has been changed! 321 * has been changed!
320 */ 322 */
321#define ATTR_MODE 1 323#define ATTR_MODE (1 << 0)
322#define ATTR_UID 2 324#define ATTR_UID (1 << 1)
323#define ATTR_GID 4 325#define ATTR_GID (1 << 2)
324#define ATTR_SIZE 8 326#define ATTR_SIZE (1 << 3)
325#define ATTR_ATIME 16 327#define ATTR_ATIME (1 << 4)
326#define ATTR_MTIME 32 328#define ATTR_MTIME (1 << 5)
327#define ATTR_CTIME 64 329#define ATTR_CTIME (1 << 6)
328#define ATTR_ATIME_SET 128 330#define ATTR_ATIME_SET (1 << 7)
329#define ATTR_MTIME_SET 256 331#define ATTR_MTIME_SET (1 << 8)
330#define ATTR_FORCE 512 /* Not a change, but a change it */ 332#define ATTR_FORCE (1 << 9) /* Not a change, but a change it */
331#define ATTR_ATTR_FLAG 1024 333#define ATTR_ATTR_FLAG (1 << 10)
332#define ATTR_KILL_SUID 2048 334#define ATTR_KILL_SUID (1 << 11)
333#define ATTR_KILL_SGID 4096 335#define ATTR_KILL_SGID (1 << 12)
334#define ATTR_FILE 8192 336#define ATTR_FILE (1 << 13)
335#define ATTR_KILL_PRIV 16384 337#define ATTR_KILL_PRIV (1 << 14)
336#define ATTR_OPEN 32768 /* Truncating from open(O_TRUNC) */ 338#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
339#define ATTR_TIMES_SET (1 << 16)
337 340
338/* 341/*
339 * This is the Inode Attributes structure, used for notify_change(). It 342 * This is the Inode Attributes structure, used for notify_change(). It
@@ -440,6 +443,27 @@ static inline size_t iov_iter_count(struct iov_iter *i)
440 return i->count; 443 return i->count;
441} 444}
442 445
446/*
447 * "descriptor" for what we're up to with a read.
448 * This allows us to use the same read code yet
449 * have multiple different users of the data that
450 * we read from a file.
451 *
452 * The simplest case just copies the data to user
453 * mode.
454 */
455typedef struct {
456 size_t written;
457 size_t count;
458 union {
459 char __user *buf;
460 void *data;
461 } arg;
462 int error;
463} read_descriptor_t;
464
465typedef int (*read_actor_t)(read_descriptor_t *, struct page *,
466 unsigned long, unsigned long);
443 467
444struct address_space_operations { 468struct address_space_operations {
445 int (*writepage)(struct page *page, struct writeback_control *wbc); 469 int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -481,6 +505,8 @@ struct address_space_operations {
481 int (*migratepage) (struct address_space *, 505 int (*migratepage) (struct address_space *,
482 struct page *, struct page *); 506 struct page *, struct page *);
483 int (*launder_page) (struct page *); 507 int (*launder_page) (struct page *);
508 int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
509 unsigned long);
484}; 510};
485 511
486/* 512/*
@@ -499,7 +525,7 @@ struct backing_dev_info;
499struct address_space { 525struct address_space {
500 struct inode *host; /* owner: inode, block_device */ 526 struct inode *host; /* owner: inode, block_device */
501 struct radix_tree_root page_tree; /* radix tree of all pages */ 527 struct radix_tree_root page_tree; /* radix tree of all pages */
502 rwlock_t tree_lock; /* and rwlock protecting it */ 528 spinlock_t tree_lock; /* and lock protecting it */
503 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 529 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
504 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 530 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
505 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 531 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
@@ -792,7 +818,7 @@ struct file {
792#define f_dentry f_path.dentry 818#define f_dentry f_path.dentry
793#define f_vfsmnt f_path.mnt 819#define f_vfsmnt f_path.mnt
794 const struct file_operations *f_op; 820 const struct file_operations *f_op;
795 atomic_t f_count; 821 atomic_long_t f_count;
796 unsigned int f_flags; 822 unsigned int f_flags;
797 mode_t f_mode; 823 mode_t f_mode;
798 loff_t f_pos; 824 loff_t f_pos;
@@ -821,8 +847,8 @@ extern spinlock_t files_lock;
821#define file_list_lock() spin_lock(&files_lock); 847#define file_list_lock() spin_lock(&files_lock);
822#define file_list_unlock() spin_unlock(&files_lock); 848#define file_list_unlock() spin_unlock(&files_lock);
823 849
824#define get_file(x) atomic_inc(&(x)->f_count) 850#define get_file(x) atomic_long_inc(&(x)->f_count)
825#define file_count(x) atomic_read(&(x)->f_count) 851#define file_count(x) atomic_long_read(&(x)->f_count)
826 852
827#ifdef CONFIG_DEBUG_WRITECOUNT 853#ifdef CONFIG_DEBUG_WRITECOUNT
828static inline void file_take_write(struct file *f) 854static inline void file_take_write(struct file *f)
@@ -1136,7 +1162,7 @@ extern int vfs_permission(struct nameidata *, int);
1136extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); 1162extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
1137extern int vfs_mkdir(struct inode *, struct dentry *, int); 1163extern int vfs_mkdir(struct inode *, struct dentry *, int);
1138extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); 1164extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
1139extern int vfs_symlink(struct inode *, struct dentry *, const char *, int); 1165extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1140extern int vfs_link(struct dentry *, struct inode *, struct dentry *); 1166extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1141extern int vfs_rmdir(struct inode *, struct dentry *); 1167extern int vfs_rmdir(struct inode *, struct dentry *);
1142extern int vfs_unlink(struct inode *, struct dentry *); 1168extern int vfs_unlink(struct inode *, struct dentry *);
@@ -1195,27 +1221,6 @@ struct block_device_operations {
1195 struct module *owner; 1221 struct module *owner;
1196}; 1222};
1197 1223
1198/*
1199 * "descriptor" for what we're up to with a read.
1200 * This allows us to use the same read code yet
1201 * have multiple different users of the data that
1202 * we read from a file.
1203 *
1204 * The simplest case just copies the data to user
1205 * mode.
1206 */
1207typedef struct {
1208 size_t written;
1209 size_t count;
1210 union {
1211 char __user * buf;
1212 void *data;
1213 } arg;
1214 int error;
1215} read_descriptor_t;
1216
1217typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1218
1219/* These macros are for out of kernel modules to test that 1224/* These macros are for out of kernel modules to test that
1220 * the kernel supports the unlocked_ioctl and compat_ioctl 1225 * the kernel supports the unlocked_ioctl and compat_ioctl
1221 * fields in struct file_operations. */ 1226 * fields in struct file_operations. */
@@ -1272,7 +1277,7 @@ struct inode_operations {
1272 void * (*follow_link) (struct dentry *, struct nameidata *); 1277 void * (*follow_link) (struct dentry *, struct nameidata *);
1273 void (*put_link) (struct dentry *, struct nameidata *, void *); 1278 void (*put_link) (struct dentry *, struct nameidata *, void *);
1274 void (*truncate) (struct inode *); 1279 void (*truncate) (struct inode *);
1275 int (*permission) (struct inode *, int, struct nameidata *); 1280 int (*permission) (struct inode *, int);
1276 int (*setattr) (struct dentry *, struct iattr *); 1281 int (*setattr) (struct dentry *, struct iattr *);
1277 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1282 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1278 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1283 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1696,9 +1701,9 @@ extern void init_special_inode(struct inode *, umode_t, dev_t);
1696extern void make_bad_inode(struct inode *); 1701extern void make_bad_inode(struct inode *);
1697extern int is_bad_inode(struct inode *); 1702extern int is_bad_inode(struct inode *);
1698 1703
1699extern const struct file_operations read_fifo_fops; 1704extern const struct file_operations read_pipefifo_fops;
1700extern const struct file_operations write_fifo_fops; 1705extern const struct file_operations write_pipefifo_fops;
1701extern const struct file_operations rdwr_fifo_fops; 1706extern const struct file_operations rdwr_pipefifo_fops;
1702 1707
1703extern int fs_may_remount_ro(struct super_block *); 1708extern int fs_may_remount_ro(struct super_block *);
1704 1709
@@ -1767,7 +1772,7 @@ extern int do_remount_sb(struct super_block *sb, int flags,
1767extern sector_t bmap(struct inode *, sector_t); 1772extern sector_t bmap(struct inode *, sector_t);
1768#endif 1773#endif
1769extern int notify_change(struct dentry *, struct iattr *); 1774extern int notify_change(struct dentry *, struct iattr *);
1770extern int permission(struct inode *, int, struct nameidata *); 1775extern int inode_permission(struct inode *, int);
1771extern int generic_permission(struct inode *, int, 1776extern int generic_permission(struct inode *, int,
1772 int (*check_acl)(struct inode *, int)); 1777 int (*check_acl)(struct inode *, int));
1773 1778
@@ -1831,7 +1836,7 @@ extern void clear_inode(struct inode *);
1831extern void destroy_inode(struct inode *); 1836extern void destroy_inode(struct inode *);
1832extern struct inode *new_inode(struct super_block *); 1837extern struct inode *new_inode(struct super_block *);
1833extern int should_remove_suid(struct dentry *); 1838extern int should_remove_suid(struct dentry *);
1834extern int remove_suid(struct dentry *); 1839extern int file_remove_suid(struct file *);
1835 1840
1836extern void __insert_inode_hash(struct inode *, unsigned long hashval); 1841extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1837extern void remove_inode_hash(struct inode *); 1842extern void remove_inode_hash(struct inode *);
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index 282f54219129..9e5a06e78d02 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -7,7 +7,7 @@ struct fs_struct {
7 atomic_t count; 7 atomic_t count;
8 rwlock_t lock; 8 rwlock_t lock;
9 int umask; 9 int umask;
10 struct path root, pwd, altroot; 10 struct path root, pwd;
11}; 11};
12 12
13#define INIT_FS { \ 13#define INIT_FS { \
@@ -19,7 +19,6 @@ struct fs_struct {
19extern struct kmem_cache *fs_cachep; 19extern struct kmem_cache *fs_cachep;
20 20
21extern void exit_fs(struct task_struct *); 21extern void exit_fs(struct task_struct *);
22extern void set_fs_altroot(void);
23extern void set_fs_root(struct fs_struct *, struct path *); 22extern void set_fs_root(struct fs_struct *, struct path *);
24extern void set_fs_pwd(struct fs_struct *, struct path *); 23extern void set_fs_pwd(struct fs_struct *, struct path *);
25extern struct fs_struct *copy_fs_struct(struct fs_struct *); 24extern struct fs_struct *copy_fs_struct(struct fs_struct *);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 9a71d4cc88c8..32e0ef0f6e1f 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -273,7 +273,10 @@ struct hstate {};
273#define huge_page_mask(h) PAGE_MASK 273#define huge_page_mask(h) PAGE_MASK
274#define huge_page_order(h) 0 274#define huge_page_order(h) 0
275#define huge_page_shift(h) PAGE_SHIFT 275#define huge_page_shift(h) PAGE_SHIFT
276#define pages_per_huge_page(h) 1 276static inline unsigned int pages_per_huge_page(struct hstate *h)
277{
278 return 1;
279}
277#endif 280#endif
278 281
279#endif /* _LINUX_HUGETLB_H */ 282#endif /* _LINUX_HUGETLB_H */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 7d51cbca49ab..75ae6d8aba4f 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -758,7 +758,7 @@ static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
758 } 758 }
759 759
760 dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction); 760 dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
761 if (!dma_mapping_error(dma_addr)) { 761 if (!dma_mapping_error(&c->pdev->dev, dma_addr)) {
762#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 762#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
763 if ((sizeof(dma_addr_t) > 4) && c->pae_support) { 763 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
764 *mptr++ = cpu_to_le32(0x7C020002); 764 *mptr++ = cpu_to_le32(0x7C020002);
diff --git a/include/linux/init.h b/include/linux/init.h
index 42ae95411a93..11b84e106053 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -170,6 +170,13 @@ extern void (*late_time_init)(void);
170 __attribute__((__section__(".initcall" level ".init"))) = fn 170 __attribute__((__section__(".initcall" level ".init"))) = fn
171 171
172/* 172/*
173 * Early initcalls run before initializing SMP.
174 *
175 * Only for built-in code, not modules.
176 */
177#define early_initcall(fn) __define_initcall("early",fn,early)
178
179/*
173 * A "pure" initcall has no dependencies on anything else, and purely 180 * A "pure" initcall has no dependencies on anything else, and purely
174 * initializes variables that couldn't be statically initialized. 181 * initializes variables that couldn't be statically initialized.
175 * 182 *
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
index c975caf75385..f8598f583944 100644
--- a/include/linux/iommu-helper.h
+++ b/include/linux/iommu-helper.h
@@ -8,3 +8,4 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
8 unsigned long align_mask); 8 unsigned long align_mask);
9extern void iommu_area_free(unsigned long *map, unsigned long start, 9extern void iommu_area_free(unsigned long *map, unsigned long start,
10 unsigned int nr); 10 unsigned int nr);
11extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len);
diff --git a/include/linux/jffs2.h b/include/linux/jffs2.h
index 6b563cae23df..da720bc3eb15 100644
--- a/include/linux/jffs2.h
+++ b/include/linux/jffs2.h
@@ -7,9 +7,6 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in the 8 * For licensing information, see the file 'LICENCE' in the
9 * jffs2 directory. 9 * jffs2 directory.
10 *
11 * $Id: jffs2.h,v 1.38 2005/09/26 11:37:23 havasi Exp $
12 *
13 */ 10 */
14 11
15#ifndef __LINUX_JFFS2_H__ 12#ifndef __LINUX_JFFS2_H__
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 3265968cd2cd..82f88a8a827b 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -83,6 +83,7 @@ struct kimage {
83 83
84 unsigned long start; 84 unsigned long start;
85 struct page *control_code_page; 85 struct page *control_code_page;
86 struct page *swap_page;
86 87
87 unsigned long nr_segments; 88 unsigned long nr_segments;
88 struct kexec_segment segment[KEXEC_SEGMENT_MAX]; 89 struct kexec_segment segment[KEXEC_SEGMENT_MAX];
@@ -98,18 +99,20 @@ struct kimage {
98 unsigned int type : 1; 99 unsigned int type : 1;
99#define KEXEC_TYPE_DEFAULT 0 100#define KEXEC_TYPE_DEFAULT 0
100#define KEXEC_TYPE_CRASH 1 101#define KEXEC_TYPE_CRASH 1
102 unsigned int preserve_context : 1;
101}; 103};
102 104
103 105
104 106
105/* kexec interface functions */ 107/* kexec interface functions */
106extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET; 108extern void machine_kexec(struct kimage *image);
107extern int machine_kexec_prepare(struct kimage *image); 109extern int machine_kexec_prepare(struct kimage *image);
108extern void machine_kexec_cleanup(struct kimage *image); 110extern void machine_kexec_cleanup(struct kimage *image);
109extern asmlinkage long sys_kexec_load(unsigned long entry, 111extern asmlinkage long sys_kexec_load(unsigned long entry,
110 unsigned long nr_segments, 112 unsigned long nr_segments,
111 struct kexec_segment __user *segments, 113 struct kexec_segment __user *segments,
112 unsigned long flags); 114 unsigned long flags);
115extern int kernel_kexec(void);
113#ifdef CONFIG_COMPAT 116#ifdef CONFIG_COMPAT
114extern asmlinkage long compat_sys_kexec_load(unsigned long entry, 117extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
115 unsigned long nr_segments, 118 unsigned long nr_segments,
@@ -156,8 +159,9 @@ extern struct kimage *kexec_crash_image;
156#define kexec_flush_icache_page(page) 159#define kexec_flush_icache_page(page)
157#endif 160#endif
158 161
159#define KEXEC_ON_CRASH 0x00000001 162#define KEXEC_ON_CRASH 0x00000001
160#define KEXEC_ARCH_MASK 0xffff0000 163#define KEXEC_PRESERVE_CONTEXT 0x00000002
164#define KEXEC_ARCH_MASK 0xffff0000
161 165
162/* These values match the ELF architecture values. 166/* These values match the ELF architecture values.
163 * Unless there is a good reason that should continue to be the case. 167 * Unless there is a good reason that should continue to be the case.
@@ -174,7 +178,12 @@ extern struct kimage *kexec_crash_image;
174#define KEXEC_ARCH_MIPS_LE (10 << 16) 178#define KEXEC_ARCH_MIPS_LE (10 << 16)
175#define KEXEC_ARCH_MIPS ( 8 << 16) 179#define KEXEC_ARCH_MIPS ( 8 << 16)
176 180
177#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */ 181/* List of defined/legal kexec flags */
182#ifndef CONFIG_KEXEC_JUMP
183#define KEXEC_FLAGS KEXEC_ON_CRASH
184#else
185#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT)
186#endif
178 187
179#define VMCOREINFO_BYTES (4096) 188#define VMCOREINFO_BYTES (4096)
180#define VMCOREINFO_NOTE_NAME "VMCOREINFO" 189#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
diff --git a/include/linux/mISDNdsp.h b/include/linux/mISDNdsp.h
new file mode 100644
index 000000000000..6b71d2dce508
--- /dev/null
+++ b/include/linux/mISDNdsp.h
@@ -0,0 +1,37 @@
1#ifndef __mISDNdsp_H__
2#define __mISDNdsp_H__
3
4struct mISDN_dsp_element_arg {
5 char *name;
6 char *def;
7 char *desc;
8};
9
10struct mISDN_dsp_element {
11 char *name;
12 void *(*new)(const char *arg);
13 void (*free)(void *p);
14 void (*process_tx)(void *p, unsigned char *data, int len);
15 void (*process_rx)(void *p, unsigned char *data, int len);
16 int num_args;
17 struct mISDN_dsp_element_arg
18 *args;
19};
20
21extern int mISDN_dsp_element_register(struct mISDN_dsp_element *elem);
22extern void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem);
23
24struct dsp_features {
25 int hfc_id; /* unique id to identify the chip (or -1) */
26 int hfc_dtmf; /* set if HFCmulti card supports dtmf */
27 int hfc_loops; /* set if card supports tone loops */
28 int hfc_echocanhw; /* set if card supports echocancelation*/
29 int pcm_id; /* unique id to identify the pcm bus (or -1) */
30 int pcm_slots; /* number of slots on the pcm bus */
31 int pcm_banks; /* number of IO banks of pcm bus */
32 int unclocked; /* data is not clocked (has jitter/loss) */
33 int unordered; /* data is unordered (packets have index) */
34};
35
36#endif
37
diff --git a/include/linux/mISDNhw.h b/include/linux/mISDNhw.h
new file mode 100644
index 000000000000..e794dfb87504
--- /dev/null
+++ b/include/linux/mISDNhw.h
@@ -0,0 +1,193 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Basic declarations for the mISDN HW channels
6 *
7 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * 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 */
19
20#ifndef MISDNHW_H
21#define MISDNHW_H
22#include <linux/mISDNif.h>
23#include <linux/timer.h>
24
25/*
26 * HW DEBUG 0xHHHHGGGG
27 * H - hardware driver specific bits
28 * G - for all drivers
29 */
30
31#define DEBUG_HW 0x00000001
32#define DEBUG_HW_OPEN 0x00000002
33#define DEBUG_HW_DCHANNEL 0x00000100
34#define DEBUG_HW_DFIFO 0x00000200
35#define DEBUG_HW_BCHANNEL 0x00001000
36#define DEBUG_HW_BFIFO 0x00002000
37
38#define MAX_DFRAME_LEN_L1 300
39#define MAX_MON_FRAME 32
40#define MAX_LOG_SPACE 2048
41#define MISDN_COPY_SIZE 32
42
43/* channel->Flags bit field */
44#define FLG_TX_BUSY 0 /* tx_buf in use */
45#define FLG_TX_NEXT 1 /* next_skb in use */
46#define FLG_L1_BUSY 2 /* L1 is permanent busy */
47#define FLG_L2_ACTIVATED 3 /* activated from L2 */
48#define FLG_OPEN 5 /* channel is in use */
49#define FLG_ACTIVE 6 /* channel is activated */
50#define FLG_BUSY_TIMER 7
51/* channel type */
52#define FLG_DCHANNEL 8 /* channel is D-channel */
53#define FLG_BCHANNEL 9 /* channel is B-channel */
54#define FLG_ECHANNEL 10 /* channel is E-channel */
55#define FLG_TRANSPARENT 12 /* channel use transparent data */
56#define FLG_HDLC 13 /* channel use hdlc data */
57#define FLG_L2DATA 14 /* channel use L2 DATA primitivs */
58#define FLG_ORIGIN 15 /* channel is on origin site */
59/* channel specific stuff */
60/* arcofi specific */
61#define FLG_ARCOFI_TIMER 16
62#define FLG_ARCOFI_ERROR 17
63/* isar specific */
64#define FLG_INITIALIZED 16
65#define FLG_DLEETX 17
66#define FLG_LASTDLE 18
67#define FLG_FIRST 19
68#define FLG_LASTDATA 20
69#define FLG_NMD_DATA 21
70#define FLG_FTI_RUN 22
71#define FLG_LL_OK 23
72#define FLG_LL_CONN 24
73#define FLG_DTMFSEND 25
74
75/* workq events */
76#define FLG_RECVQUEUE 30
77#define FLG_PHCHANGE 31
78
79#define schedule_event(s, ev) do { \
80 test_and_set_bit(ev, &((s)->Flags)); \
81 schedule_work(&((s)->workq)); \
82 } while (0)
83
84struct dchannel {
85 struct mISDNdevice dev;
86 u_long Flags;
87 struct work_struct workq;
88 void (*phfunc) (struct dchannel *);
89 u_int state;
90 void *l1;
91 /* HW access */
92 u_char (*read_reg) (void *, u_char);
93 void (*write_reg) (void *, u_char, u_char);
94 void (*read_fifo) (void *, u_char *, int);
95 void (*write_fifo) (void *, u_char *, int);
96 void *hw;
97 int slot; /* multiport card channel slot */
98 struct timer_list timer;
99 /* receive data */
100 struct sk_buff *rx_skb;
101 int maxlen;
102 /* send data */
103 struct sk_buff_head squeue;
104 struct sk_buff_head rqueue;
105 struct sk_buff *tx_skb;
106 int tx_idx;
107 int debug;
108 /* statistics */
109 int err_crc;
110 int err_tx;
111 int err_rx;
112};
113
114typedef int (dchannel_l1callback)(struct dchannel *, u_int);
115extern int create_l1(struct dchannel *, dchannel_l1callback *);
116
117/* private L1 commands */
118#define INFO0 0x8002
119#define INFO1 0x8102
120#define INFO2 0x8202
121#define INFO3_P8 0x8302
122#define INFO3_P10 0x8402
123#define INFO4_P8 0x8502
124#define INFO4_P10 0x8602
125#define LOSTFRAMING 0x8702
126#define ANYSIGNAL 0x8802
127#define HW_POWERDOWN 0x8902
128#define HW_RESET_REQ 0x8a02
129#define HW_POWERUP_REQ 0x8b02
130#define HW_DEACT_REQ 0x8c02
131#define HW_ACTIVATE_REQ 0x8e02
132#define HW_D_NOBLOCKED 0x8f02
133#define HW_RESET_IND 0x9002
134#define HW_POWERUP_IND 0x9102
135#define HW_DEACT_IND 0x9202
136#define HW_ACTIVATE_IND 0x9302
137#define HW_DEACT_CNF 0x9402
138#define HW_TESTLOOP 0x9502
139#define HW_TESTRX_RAW 0x9602
140#define HW_TESTRX_HDLC 0x9702
141#define HW_TESTRX_OFF 0x9802
142
143struct layer1;
144extern int l1_event(struct layer1 *, u_int);
145
146
147struct bchannel {
148 struct mISDNchannel ch;
149 int nr;
150 u_long Flags;
151 struct work_struct workq;
152 u_int state;
153 /* HW access */
154 u_char (*read_reg) (void *, u_char);
155 void (*write_reg) (void *, u_char, u_char);
156 void (*read_fifo) (void *, u_char *, int);
157 void (*write_fifo) (void *, u_char *, int);
158 void *hw;
159 int slot; /* multiport card channel slot */
160 struct timer_list timer;
161 /* receive data */
162 struct sk_buff *rx_skb;
163 int maxlen;
164 /* send data */
165 struct sk_buff *next_skb;
166 struct sk_buff *tx_skb;
167 struct sk_buff_head rqueue;
168 int rcount;
169 int tx_idx;
170 int debug;
171 /* statistics */
172 int err_crc;
173 int err_tx;
174 int err_rx;
175};
176
177extern int mISDN_initdchannel(struct dchannel *, int, void *);
178extern int mISDN_initbchannel(struct bchannel *, int);
179extern int mISDN_freedchannel(struct dchannel *);
180extern int mISDN_freebchannel(struct bchannel *);
181extern void queue_ch_frame(struct mISDNchannel *, u_int,
182 int, struct sk_buff *);
183extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
184extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
185extern void recv_Dchannel(struct dchannel *);
186extern void recv_Bchannel(struct bchannel *);
187extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
188extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
189extern void confirm_Bsend(struct bchannel *bch);
190extern int get_next_bframe(struct bchannel *);
191extern int get_next_dframe(struct dchannel *);
192
193#endif
diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
new file mode 100644
index 000000000000..5c948f337817
--- /dev/null
+++ b/include/linux/mISDNif.h
@@ -0,0 +1,487 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This code 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 LESSER GENERAL PUBLIC LICENSE for more details.
15 *
16 */
17
18#ifndef mISDNIF_H
19#define mISDNIF_H
20
21#include <stdarg.h>
22#include <linux/types.h>
23#include <linux/errno.h>
24#include <linux/socket.h>
25
26/*
27 * ABI Version 32 bit
28 *
29 * <8 bit> Major version
30 * - changed if any interface become backwards incompatible
31 *
32 * <8 bit> Minor version
33 * - changed if any interface is extended but backwards compatible
34 *
35 * <16 bit> Release number
36 * - should be incremented on every checkin
37 */
38#define MISDN_MAJOR_VERSION 1
39#define MISDN_MINOR_VERSION 0
40#define MISDN_RELEASE 18
41
42/* primitives for information exchange
43 * generell format
44 * <16 bit 0 >
45 * <8 bit command>
46 * BIT 8 = 1 LAYER private
47 * BIT 7 = 1 answer
48 * BIT 6 = 1 DATA
49 * <8 bit target layer mask>
50 *
51 * Layer = 00 is reserved for general commands
52 Layer = 01 L2 -> HW
53 Layer = 02 HW -> L2
54 Layer = 04 L3 -> L2
55 Layer = 08 L2 -> L3
56 * Layer = FF is reserved for broadcast commands
57 */
58
59#define MISDN_CMDMASK 0xff00
60#define MISDN_LAYERMASK 0x00ff
61
62/* generell commands */
63#define OPEN_CHANNEL 0x0100
64#define CLOSE_CHANNEL 0x0200
65#define CONTROL_CHANNEL 0x0300
66#define CHECK_DATA 0x0400
67
68/* layer 2 -> layer 1 */
69#define PH_ACTIVATE_REQ 0x0101
70#define PH_DEACTIVATE_REQ 0x0201
71#define PH_DATA_REQ 0x2001
72#define MPH_ACTIVATE_REQ 0x0501
73#define MPH_DEACTIVATE_REQ 0x0601
74#define MPH_INFORMATION_REQ 0x0701
75#define PH_CONTROL_REQ 0x0801
76
77/* layer 1 -> layer 2 */
78#define PH_ACTIVATE_IND 0x0102
79#define PH_ACTIVATE_CNF 0x4102
80#define PH_DEACTIVATE_IND 0x0202
81#define PH_DEACTIVATE_CNF 0x4202
82#define PH_DATA_IND 0x2002
83#define MPH_ACTIVATE_IND 0x0502
84#define MPH_DEACTIVATE_IND 0x0602
85#define MPH_INFORMATION_IND 0x0702
86#define PH_DATA_CNF 0x6002
87#define PH_CONTROL_IND 0x0802
88#define PH_CONTROL_CNF 0x4802
89
90/* layer 3 -> layer 2 */
91#define DL_ESTABLISH_REQ 0x1004
92#define DL_RELEASE_REQ 0x1104
93#define DL_DATA_REQ 0x3004
94#define DL_UNITDATA_REQ 0x3104
95#define DL_INFORMATION_REQ 0x0004
96
97/* layer 2 -> layer 3 */
98#define DL_ESTABLISH_IND 0x1008
99#define DL_ESTABLISH_CNF 0x5008
100#define DL_RELEASE_IND 0x1108
101#define DL_RELEASE_CNF 0x5108
102#define DL_DATA_IND 0x3008
103#define DL_UNITDATA_IND 0x3108
104#define DL_INFORMATION_IND 0x0008
105
106/* intern layer 2 managment */
107#define MDL_ASSIGN_REQ 0x1804
108#define MDL_ASSIGN_IND 0x1904
109#define MDL_REMOVE_REQ 0x1A04
110#define MDL_REMOVE_IND 0x1B04
111#define MDL_STATUS_UP_IND 0x1C04
112#define MDL_STATUS_DOWN_IND 0x1D04
113#define MDL_STATUS_UI_IND 0x1E04
114#define MDL_ERROR_IND 0x1F04
115#define MDL_ERROR_RSP 0x5F04
116
117/* DL_INFORMATION_IND types */
118#define DL_INFO_L2_CONNECT 0x0001
119#define DL_INFO_L2_REMOVED 0x0002
120
121/* PH_CONTROL types */
122/* TOUCH TONE IS 0x20XX XX "0"..."9", "A","B","C","D","*","#" */
123#define DTMF_TONE_VAL 0x2000
124#define DTMF_TONE_MASK 0x007F
125#define DTMF_TONE_START 0x2100
126#define DTMF_TONE_STOP 0x2200
127#define DTMF_HFC_COEF 0x4000
128#define DSP_CONF_JOIN 0x2403
129#define DSP_CONF_SPLIT 0x2404
130#define DSP_RECEIVE_OFF 0x2405
131#define DSP_RECEIVE_ON 0x2406
132#define DSP_ECHO_ON 0x2407
133#define DSP_ECHO_OFF 0x2408
134#define DSP_MIX_ON 0x2409
135#define DSP_MIX_OFF 0x240a
136#define DSP_DELAY 0x240b
137#define DSP_JITTER 0x240c
138#define DSP_TXDATA_ON 0x240d
139#define DSP_TXDATA_OFF 0x240e
140#define DSP_TX_DEJITTER 0x240f
141#define DSP_TX_DEJ_OFF 0x2410
142#define DSP_TONE_PATT_ON 0x2411
143#define DSP_TONE_PATT_OFF 0x2412
144#define DSP_VOL_CHANGE_TX 0x2413
145#define DSP_VOL_CHANGE_RX 0x2414
146#define DSP_BF_ENABLE_KEY 0x2415
147#define DSP_BF_DISABLE 0x2416
148#define DSP_BF_ACCEPT 0x2416
149#define DSP_BF_REJECT 0x2417
150#define DSP_PIPELINE_CFG 0x2418
151#define HFC_VOL_CHANGE_TX 0x2601
152#define HFC_VOL_CHANGE_RX 0x2602
153#define HFC_SPL_LOOP_ON 0x2603
154#define HFC_SPL_LOOP_OFF 0x2604
155
156/* DSP_TONE_PATT_ON parameter */
157#define TONE_OFF 0x0000
158#define TONE_GERMAN_DIALTONE 0x0001
159#define TONE_GERMAN_OLDDIALTONE 0x0002
160#define TONE_AMERICAN_DIALTONE 0x0003
161#define TONE_GERMAN_DIALPBX 0x0004
162#define TONE_GERMAN_OLDDIALPBX 0x0005
163#define TONE_AMERICAN_DIALPBX 0x0006
164#define TONE_GERMAN_RINGING 0x0007
165#define TONE_GERMAN_OLDRINGING 0x0008
166#define TONE_AMERICAN_RINGPBX 0x000b
167#define TONE_GERMAN_RINGPBX 0x000c
168#define TONE_GERMAN_OLDRINGPBX 0x000d
169#define TONE_AMERICAN_RINGING 0x000e
170#define TONE_GERMAN_BUSY 0x000f
171#define TONE_GERMAN_OLDBUSY 0x0010
172#define TONE_AMERICAN_BUSY 0x0011
173#define TONE_GERMAN_HANGUP 0x0012
174#define TONE_GERMAN_OLDHANGUP 0x0013
175#define TONE_AMERICAN_HANGUP 0x0014
176#define TONE_SPECIAL_INFO 0x0015
177#define TONE_GERMAN_GASSENBESETZT 0x0016
178#define TONE_GERMAN_AUFSCHALTTON 0x0016
179
180/* MPH_INFORMATION_IND */
181#define L1_SIGNAL_LOS_OFF 0x0010
182#define L1_SIGNAL_LOS_ON 0x0011
183#define L1_SIGNAL_AIS_OFF 0x0012
184#define L1_SIGNAL_AIS_ON 0x0013
185#define L1_SIGNAL_RDI_OFF 0x0014
186#define L1_SIGNAL_RDI_ON 0x0015
187#define L1_SIGNAL_SLIP_RX 0x0020
188#define L1_SIGNAL_SLIP_TX 0x0021
189
190/*
191 * protocol ids
192 * D channel 1-31
193 * B channel 33 - 63
194 */
195
196#define ISDN_P_NONE 0
197#define ISDN_P_BASE 0
198#define ISDN_P_TE_S0 0x01
199#define ISDN_P_NT_S0 0x02
200#define ISDN_P_TE_E1 0x03
201#define ISDN_P_NT_E1 0x04
202#define ISDN_P_LAPD_TE 0x10
203#define ISDN_P_LAPD_NT 0x11
204
205#define ISDN_P_B_MASK 0x1f
206#define ISDN_P_B_START 0x20
207
208#define ISDN_P_B_RAW 0x21
209#define ISDN_P_B_HDLC 0x22
210#define ISDN_P_B_X75SLP 0x23
211#define ISDN_P_B_L2DTMF 0x24
212#define ISDN_P_B_L2DSP 0x25
213#define ISDN_P_B_L2DSPHDLC 0x26
214
215#define OPTION_L2_PMX 1
216#define OPTION_L2_PTP 2
217#define OPTION_L2_FIXEDTEI 3
218#define OPTION_L2_CLEANUP 4
219
220/* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
221#define MISDN_MAX_IDLEN 20
222
223struct mISDNhead {
224 unsigned int prim;
225 unsigned int id;
226} __attribute__((packed));
227
228#define MISDN_HEADER_LEN sizeof(struct mISDNhead)
229#define MAX_DATA_SIZE 2048
230#define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN)
231#define MAX_DFRAME_LEN 260
232
233#define MISDN_ID_ADDR_MASK 0xFFFF
234#define MISDN_ID_TEI_MASK 0xFF00
235#define MISDN_ID_SAPI_MASK 0x00FF
236#define MISDN_ID_TEI_ANY 0x7F00
237
238#define MISDN_ID_ANY 0xFFFF
239#define MISDN_ID_NONE 0xFFFE
240
241#define GROUP_TEI 127
242#define TEI_SAPI 63
243#define CTRL_SAPI 0
244
245#define MISDN_CHMAP_SIZE 4
246
247#define SOL_MISDN 0
248
249struct sockaddr_mISDN {
250 sa_family_t family;
251 unsigned char dev;
252 unsigned char channel;
253 unsigned char sapi;
254 unsigned char tei;
255};
256
257/* timer device ioctl */
258#define IMADDTIMER _IOR('I', 64, int)
259#define IMDELTIMER _IOR('I', 65, int)
260/* socket ioctls */
261#define IMGETVERSION _IOR('I', 66, int)
262#define IMGETCOUNT _IOR('I', 67, int)
263#define IMGETDEVINFO _IOR('I', 68, int)
264#define IMCTRLREQ _IOR('I', 69, int)
265#define IMCLEAR_L2 _IOR('I', 70, int)
266
267struct mISDNversion {
268 unsigned char major;
269 unsigned char minor;
270 unsigned short release;
271};
272
273struct mISDN_devinfo {
274 u_int id;
275 u_int Dprotocols;
276 u_int Bprotocols;
277 u_int protocol;
278 u_long channelmap[MISDN_CHMAP_SIZE];
279 u_int nrbchan;
280 char name[MISDN_MAX_IDLEN];
281};
282
283/* CONTROL_CHANNEL parameters */
284#define MISDN_CTRL_GETOP 0x0000
285#define MISDN_CTRL_LOOP 0x0001
286#define MISDN_CTRL_CONNECT 0x0002
287#define MISDN_CTRL_DISCONNECT 0x0004
288#define MISDN_CTRL_PCMCONNECT 0x0010
289#define MISDN_CTRL_PCMDISCONNECT 0x0020
290#define MISDN_CTRL_SETPEER 0x0040
291#define MISDN_CTRL_UNSETPEER 0x0080
292#define MISDN_CTRL_RX_OFF 0x0100
293#define MISDN_CTRL_HW_FEATURES_OP 0x2000
294#define MISDN_CTRL_HW_FEATURES 0x2001
295#define MISDN_CTRL_HFC_OP 0x4000
296#define MISDN_CTRL_HFC_PCM_CONN 0x4001
297#define MISDN_CTRL_HFC_PCM_DISC 0x4002
298#define MISDN_CTRL_HFC_CONF_JOIN 0x4003
299#define MISDN_CTRL_HFC_CONF_SPLIT 0x4004
300#define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005
301#define MISDN_CTRL_HFC_RECEIVE_ON 0x4006
302#define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007
303#define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008
304
305
306/* socket options */
307#define MISDN_TIME_STAMP 0x0001
308
309struct mISDN_ctrl_req {
310 int op;
311 int channel;
312 int p1;
313 int p2;
314};
315
316/* muxer options */
317#define MISDN_OPT_ALL 1
318#define MISDN_OPT_TEIMGR 2
319
320#ifdef __KERNEL__
321#include <linux/list.h>
322#include <linux/skbuff.h>
323#include <linux/net.h>
324#include <net/sock.h>
325#include <linux/completion.h>
326
327#define DEBUG_CORE 0x000000ff
328#define DEBUG_CORE_FUNC 0x00000002
329#define DEBUG_SOCKET 0x00000004
330#define DEBUG_MANAGER 0x00000008
331#define DEBUG_SEND_ERR 0x00000010
332#define DEBUG_MSG_THREAD 0x00000020
333#define DEBUG_QUEUE_FUNC 0x00000040
334#define DEBUG_L1 0x0000ff00
335#define DEBUG_L1_FSM 0x00000200
336#define DEBUG_L2 0x00ff0000
337#define DEBUG_L2_FSM 0x00020000
338#define DEBUG_L2_CTRL 0x00040000
339#define DEBUG_L2_RECV 0x00080000
340#define DEBUG_L2_TEI 0x00100000
341#define DEBUG_L2_TEIFSM 0x00200000
342#define DEBUG_TIMER 0x01000000
343
344#define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0])
345#define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim)
346#define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id)
347
348/* socket states */
349#define MISDN_OPEN 1
350#define MISDN_BOUND 2
351#define MISDN_CLOSED 3
352
353struct mISDNchannel;
354struct mISDNdevice;
355struct mISDNstack;
356
357struct channel_req {
358 u_int protocol;
359 struct sockaddr_mISDN adr;
360 struct mISDNchannel *ch;
361};
362
363typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *);
364typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *);
365typedef int (create_func_t)(struct channel_req *);
366
367struct Bprotocol {
368 struct list_head list;
369 char *name;
370 u_int Bprotocols;
371 create_func_t *create;
372};
373
374struct mISDNchannel {
375 struct list_head list;
376 u_int protocol;
377 u_int nr;
378 u_long opt;
379 u_int addr;
380 struct mISDNstack *st;
381 struct mISDNchannel *peer;
382 send_func_t *send;
383 send_func_t *recv;
384 ctrl_func_t *ctrl;
385};
386
387struct mISDN_sock_list {
388 struct hlist_head head;
389 rwlock_t lock;
390};
391
392struct mISDN_sock {
393 struct sock sk;
394 struct mISDNchannel ch;
395 u_int cmask;
396 struct mISDNdevice *dev;
397};
398
399
400
401struct mISDNdevice {
402 struct mISDNchannel D;
403 u_int id;
404 char name[MISDN_MAX_IDLEN];
405 u_int Dprotocols;
406 u_int Bprotocols;
407 u_int nrbchan;
408 u_long channelmap[MISDN_CHMAP_SIZE];
409 struct list_head bchannels;
410 struct mISDNchannel *teimgr;
411 struct device dev;
412};
413
414struct mISDNstack {
415 u_long status;
416 struct mISDNdevice *dev;
417 struct task_struct *thread;
418 struct completion *notify;
419 wait_queue_head_t workq;
420 struct sk_buff_head msgq;
421 struct list_head layer2;
422 struct mISDNchannel *layer1;
423 struct mISDNchannel own;
424 struct mutex lmutex; /* protect lists */
425 struct mISDN_sock_list l1sock;
426#ifdef MISDN_MSG_STATS
427 u_int msg_cnt;
428 u_int sleep_cnt;
429 u_int stopped_cnt;
430#endif
431};
432
433/* global alloc/queue dunctions */
434
435static inline struct sk_buff *
436mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
437{
438 struct sk_buff *skb;
439
440 skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
441 if (likely(skb))
442 skb_reserve(skb, MISDN_HEADER_LEN);
443 return skb;
444}
445
446static inline struct sk_buff *
447_alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
448{
449 struct sk_buff *skb = mI_alloc_skb(len, gfp_mask);
450 struct mISDNhead *hh;
451
452 if (!skb)
453 return NULL;
454 if (len)
455 memcpy(skb_put(skb, len), dp, len);
456 hh = mISDN_HEAD_P(skb);
457 hh->prim = prim;
458 hh->id = id;
459 return skb;
460}
461
462static inline void
463_queue_data(struct mISDNchannel *ch, u_int prim,
464 u_int id, u_int len, void *dp, gfp_t gfp_mask)
465{
466 struct sk_buff *skb;
467
468 if (!ch->peer)
469 return;
470 skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
471 if (!skb)
472 return;
473 if (ch->recv(ch->peer, skb))
474 dev_kfree_skb(skb);
475}
476
477/* global register/unregister functions */
478
479extern int mISDN_register_device(struct mISDNdevice *, char *name);
480extern void mISDN_unregister_device(struct mISDNdevice *);
481extern int mISDN_register_Bprotocol(struct Bprotocol *);
482extern void mISDN_unregister_Bprotocol(struct Bprotocol *);
483
484extern void set_channel_address(struct mISDNchannel *, u_int, u_int);
485
486#endif /* __KERNEL__ */
487#endif /* mISDNIF_H */
diff --git a/include/linux/maple.h b/include/linux/maple.h
index d31e36ebb436..523a286bb477 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -61,8 +61,6 @@ struct maple_device {
61 61
62struct maple_driver { 62struct maple_driver {
63 unsigned long function; 63 unsigned long function;
64 int (*connect) (struct maple_device * dev);
65 void (*disconnect) (struct maple_device * dev);
66 struct device_driver drv; 64 struct device_driver drv;
67}; 65};
68 66
diff --git a/include/linux/memstick.h b/include/linux/memstick.h
index 37a5cdb03918..a9f998a3f48b 100644
--- a/include/linux/memstick.h
+++ b/include/linux/memstick.h
@@ -263,6 +263,10 @@ struct memstick_dev {
263 /* Get next request from the media driver. */ 263 /* Get next request from the media driver. */
264 int (*next_request)(struct memstick_dev *card, 264 int (*next_request)(struct memstick_dev *card,
265 struct memstick_request **mrq); 265 struct memstick_request **mrq);
266 /* Tell the media driver to stop doing things */
267 void (*stop)(struct memstick_dev *card);
268 /* Allow the media driver to continue */
269 void (*start)(struct memstick_dev *card);
266 270
267 struct device dev; 271 struct device dev;
268}; 272};
@@ -284,7 +288,7 @@ struct memstick_host {
284 /* Notify the host that some requests are pending. */ 288 /* Notify the host that some requests are pending. */
285 void (*request)(struct memstick_host *host); 289 void (*request)(struct memstick_host *host);
286 /* Set host IO parameters (power, clock, etc). */ 290 /* Set host IO parameters (power, clock, etc). */
287 void (*set_param)(struct memstick_host *host, 291 int (*set_param)(struct memstick_host *host,
288 enum memstick_param param, 292 enum memstick_param param,
289 int value); 293 int value);
290 unsigned long private[0] ____cacheline_aligned; 294 unsigned long private[0] ____cacheline_aligned;
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index bb3dd0545928..49ef857cdb2d 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -1,5 +1,3 @@
1#ifndef MFD_CORE_H
2#define MFD_CORE_H
3/* 1/*
4 * drivers/mfd/mfd-core.h 2 * drivers/mfd/mfd-core.h
5 * 3 *
@@ -13,6 +11,9 @@
13 * 11 *
14 */ 12 */
15 13
14#ifndef MFD_CORE_H
15#define MFD_CORE_H
16
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17 18
18/* 19/*
@@ -28,7 +29,13 @@ struct mfd_cell {
28 int (*suspend)(struct platform_device *dev); 29 int (*suspend)(struct platform_device *dev);
29 int (*resume)(struct platform_device *dev); 30 int (*resume)(struct platform_device *dev);
30 31
31 void *driver_data; /* driver-specific data */ 32 /* driver-specific data for MFD-aware "cell" drivers */
33 void *driver_data;
34
35 /* platform_data can be used to either pass data to "generic"
36 driver or as a hook to mfd_cell for the "cell" drivers */
37 void *platform_data;
38 size_t data_size;
32 39
33 /* 40 /*
34 * This resources can be specified relatievly to the parent device. 41 * This resources can be specified relatievly to the parent device.
@@ -38,18 +45,11 @@ struct mfd_cell {
38 const struct resource *resources; 45 const struct resource *resources;
39}; 46};
40 47
41static inline struct mfd_cell * 48extern int mfd_add_devices(struct device *parent, int id,
42mfd_get_cell(struct platform_device *pdev) 49 const struct mfd_cell *cells, int n_devs,
43{ 50 struct resource *mem_base,
44 return (struct mfd_cell *)pdev->dev.platform_data; 51 int irq_base);
45}
46
47extern int mfd_add_devices(
48 struct platform_device *parent,
49 const struct mfd_cell *cells, int n_devs,
50 struct resource *mem_base,
51 int irq_base);
52 52
53extern void mfd_remove_devices(struct platform_device *parent); 53extern void mfd_remove_devices(struct device *parent);
54 54
55#endif 55#endif
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index e27082cd650e..bf8f11982dae 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -164,11 +164,13 @@ enum {
164 MLX4_WQE_CTRL_SOLICITED = 1 << 1, 164 MLX4_WQE_CTRL_SOLICITED = 1 << 1,
165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4, 165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4,
166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5, 166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
167 MLX4_WQE_CTRL_INS_VLAN = 1 << 6,
167}; 168};
168 169
169struct mlx4_wqe_ctrl_seg { 170struct mlx4_wqe_ctrl_seg {
170 __be32 owner_opcode; 171 __be32 owner_opcode;
171 u8 reserved2[3]; 172 __be16 vlan_tag;
173 u8 ins_vlan;
172 u8 fence_size; 174 u8 fence_size;
173 /* 175 /*
174 * High 24 bits are SRC remote buffer; low 8 bits are flags: 176 * High 24 bits are SRC remote buffer; low 8 bits are flags:
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d87a5a5fe87d..866a3dbe5c75 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -810,7 +810,6 @@ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *
810 810
811int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, 811int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
812 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas); 812 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
813void print_bad_pte(struct vm_area_struct *, pte_t, unsigned long);
814 813
815extern int try_to_release_page(struct page * page, gfp_t gfp_mask); 814extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
816extern void do_invalidatepage(struct page *page, unsigned long offset); 815extern void do_invalidatepage(struct page *page, unsigned long offset);
@@ -833,6 +832,39 @@ extern int mprotect_fixup(struct vm_area_struct *vma,
833 struct vm_area_struct **pprev, unsigned long start, 832 struct vm_area_struct **pprev, unsigned long start,
834 unsigned long end, unsigned long newflags); 833 unsigned long end, unsigned long newflags);
835 834
835#ifdef CONFIG_HAVE_GET_USER_PAGES_FAST
836/*
837 * get_user_pages_fast provides equivalent functionality to get_user_pages,
838 * operating on current and current->mm (force=0 and doesn't return any vmas).
839 *
840 * get_user_pages_fast may take mmap_sem and page tables, so no assumptions
841 * can be made about locking. get_user_pages_fast is to be implemented in a
842 * way that is advantageous (vs get_user_pages()) when the user memory area is
843 * already faulted in and present in ptes. However if the pages have to be
844 * faulted in, it may turn out to be slightly slower).
845 */
846int get_user_pages_fast(unsigned long start, int nr_pages, int write,
847 struct page **pages);
848
849#else
850/*
851 * Should probably be moved to asm-generic, and architectures can include it if
852 * they don't implement their own get_user_pages_fast.
853 */
854#define get_user_pages_fast(start, nr_pages, write, pages) \
855({ \
856 struct mm_struct *mm = current->mm; \
857 int ret; \
858 \
859 down_read(&mm->mmap_sem); \
860 ret = get_user_pages(current, mm, start, nr_pages, \
861 write, 0, pages, NULL); \
862 up_read(&mm->mmap_sem); \
863 \
864 ret; \
865})
866#endif
867
836/* 868/*
837 * A callback you can register to apply pressure to ageable caches. 869 * A callback you can register to apply pressure to ageable caches.
838 * 870 *
@@ -1072,6 +1104,9 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
1072 unsigned long addr, unsigned long len, pgoff_t pgoff); 1104 unsigned long addr, unsigned long len, pgoff_t pgoff);
1073extern void exit_mmap(struct mm_struct *); 1105extern void exit_mmap(struct mm_struct *);
1074 1106
1107extern int mm_take_all_locks(struct mm_struct *mm);
1108extern void mm_drop_all_locks(struct mm_struct *mm);
1109
1075#ifdef CONFIG_PROC_FS 1110#ifdef CONFIG_PROC_FS
1076/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */ 1111/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */
1077extern void added_exe_file_vma(struct mm_struct *mm); 1112extern void added_exe_file_vma(struct mm_struct *mm);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 746f975b58ef..386edbe2cb4e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -10,6 +10,7 @@
10#include <linux/rbtree.h> 10#include <linux/rbtree.h>
11#include <linux/rwsem.h> 11#include <linux/rwsem.h>
12#include <linux/completion.h> 12#include <linux/completion.h>
13#include <linux/cpumask.h>
13#include <asm/page.h> 14#include <asm/page.h>
14#include <asm/mmu.h> 15#include <asm/mmu.h>
15 16
@@ -253,6 +254,9 @@ struct mm_struct {
253 struct file *exe_file; 254 struct file *exe_file;
254 unsigned long num_exe_file_vmas; 255 unsigned long num_exe_file_vmas;
255#endif 256#endif
257#ifdef CONFIG_MMU_NOTIFIER
258 struct mmu_notifier_mm *mmu_notifier_mm;
259#endif
256}; 260};
257 261
258#endif /* _LINUX_MM_TYPES_H */ 262#endif /* _LINUX_MM_TYPES_H */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 0d508ac17d64..ee6e822d5994 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -111,6 +111,8 @@ struct mmc_card {
111 unsigned num_info; /* number of info strings */ 111 unsigned num_info; /* number of info strings */
112 const char **info; /* info strings */ 112 const char **info; /* info strings */
113 struct sdio_func_tuple *tuples; /* unknown common tuples */ 113 struct sdio_func_tuple *tuples; /* unknown common tuples */
114
115 struct dentry *debugfs_root;
114}; 116};
115 117
116#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC) 118#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 10a2080086ca..9c288c909878 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -157,6 +157,8 @@ struct mmc_host {
157 struct led_trigger *led; /* activity led */ 157 struct led_trigger *led; /* activity led */
158#endif 158#endif
159 159
160 struct dentry *debugfs_root;
161
160 unsigned long private[0] ____cacheline_aligned; 162 unsigned long private[0] ____cacheline_aligned;
161}; 163};
162 164
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
new file mode 100644
index 000000000000..b77486d152cd
--- /dev/null
+++ b/include/linux/mmu_notifier.h
@@ -0,0 +1,279 @@
1#ifndef _LINUX_MMU_NOTIFIER_H
2#define _LINUX_MMU_NOTIFIER_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6#include <linux/mm_types.h>
7
8struct mmu_notifier;
9struct mmu_notifier_ops;
10
11#ifdef CONFIG_MMU_NOTIFIER
12
13/*
14 * The mmu notifier_mm structure is allocated and installed in
15 * mm->mmu_notifier_mm inside the mm_take_all_locks() protected
16 * critical section and it's released only when mm_count reaches zero
17 * in mmdrop().
18 */
19struct mmu_notifier_mm {
20 /* all mmu notifiers registerd in this mm are queued in this list */
21 struct hlist_head list;
22 /* to serialize the list modifications and hlist_unhashed */
23 spinlock_t lock;
24};
25
26struct mmu_notifier_ops {
27 /*
28 * Called either by mmu_notifier_unregister or when the mm is
29 * being destroyed by exit_mmap, always before all pages are
30 * freed. This can run concurrently with other mmu notifier
31 * methods (the ones invoked outside the mm context) and it
32 * should tear down all secondary mmu mappings and freeze the
33 * secondary mmu. If this method isn't implemented you've to
34 * be sure that nothing could possibly write to the pages
35 * through the secondary mmu by the time the last thread with
36 * tsk->mm == mm exits.
37 *
38 * As side note: the pages freed after ->release returns could
39 * be immediately reallocated by the gart at an alias physical
40 * address with a different cache model, so if ->release isn't
41 * implemented because all _software_ driven memory accesses
42 * through the secondary mmu are terminated by the time the
43 * last thread of this mm quits, you've also to be sure that
44 * speculative _hardware_ operations can't allocate dirty
45 * cachelines in the cpu that could not be snooped and made
46 * coherent with the other read and write operations happening
47 * through the gart alias address, so leading to memory
48 * corruption.
49 */
50 void (*release)(struct mmu_notifier *mn,
51 struct mm_struct *mm);
52
53 /*
54 * clear_flush_young is called after the VM is
55 * test-and-clearing the young/accessed bitflag in the
56 * pte. This way the VM will provide proper aging to the
57 * accesses to the page through the secondary MMUs and not
58 * only to the ones through the Linux pte.
59 */
60 int (*clear_flush_young)(struct mmu_notifier *mn,
61 struct mm_struct *mm,
62 unsigned long address);
63
64 /*
65 * Before this is invoked any secondary MMU is still ok to
66 * read/write to the page previously pointed to by the Linux
67 * pte because the page hasn't been freed yet and it won't be
68 * freed until this returns. If required set_page_dirty has to
69 * be called internally to this method.
70 */
71 void (*invalidate_page)(struct mmu_notifier *mn,
72 struct mm_struct *mm,
73 unsigned long address);
74
75 /*
76 * invalidate_range_start() and invalidate_range_end() must be
77 * paired and are called only when the mmap_sem and/or the
78 * locks protecting the reverse maps are held. The subsystem
79 * must guarantee that no additional references are taken to
80 * the pages in the range established between the call to
81 * invalidate_range_start() and the matching call to
82 * invalidate_range_end().
83 *
84 * Invalidation of multiple concurrent ranges may be
85 * optionally permitted by the driver. Either way the
86 * establishment of sptes is forbidden in the range passed to
87 * invalidate_range_begin/end for the whole duration of the
88 * invalidate_range_begin/end critical section.
89 *
90 * invalidate_range_start() is called when all pages in the
91 * range are still mapped and have at least a refcount of one.
92 *
93 * invalidate_range_end() is called when all pages in the
94 * range have been unmapped and the pages have been freed by
95 * the VM.
96 *
97 * The VM will remove the page table entries and potentially
98 * the page between invalidate_range_start() and
99 * invalidate_range_end(). If the page must not be freed
100 * because of pending I/O or other circumstances then the
101 * invalidate_range_start() callback (or the initial mapping
102 * by the driver) must make sure that the refcount is kept
103 * elevated.
104 *
105 * If the driver increases the refcount when the pages are
106 * initially mapped into an address space then either
107 * invalidate_range_start() or invalidate_range_end() may
108 * decrease the refcount. If the refcount is decreased on
109 * invalidate_range_start() then the VM can free pages as page
110 * table entries are removed. If the refcount is only
111 * droppped on invalidate_range_end() then the driver itself
112 * will drop the last refcount but it must take care to flush
113 * any secondary tlb before doing the final free on the
114 * page. Pages will no longer be referenced by the linux
115 * address space but may still be referenced by sptes until
116 * the last refcount is dropped.
117 */
118 void (*invalidate_range_start)(struct mmu_notifier *mn,
119 struct mm_struct *mm,
120 unsigned long start, unsigned long end);
121 void (*invalidate_range_end)(struct mmu_notifier *mn,
122 struct mm_struct *mm,
123 unsigned long start, unsigned long end);
124};
125
126/*
127 * The notifier chains are protected by mmap_sem and/or the reverse map
128 * semaphores. Notifier chains are only changed when all reverse maps and
129 * the mmap_sem locks are taken.
130 *
131 * Therefore notifier chains can only be traversed when either
132 *
133 * 1. mmap_sem is held.
134 * 2. One of the reverse map locks is held (i_mmap_lock or anon_vma->lock).
135 * 3. No other concurrent thread can access the list (release)
136 */
137struct mmu_notifier {
138 struct hlist_node hlist;
139 const struct mmu_notifier_ops *ops;
140};
141
142static inline int mm_has_notifiers(struct mm_struct *mm)
143{
144 return unlikely(mm->mmu_notifier_mm);
145}
146
147extern int mmu_notifier_register(struct mmu_notifier *mn,
148 struct mm_struct *mm);
149extern int __mmu_notifier_register(struct mmu_notifier *mn,
150 struct mm_struct *mm);
151extern void mmu_notifier_unregister(struct mmu_notifier *mn,
152 struct mm_struct *mm);
153extern void __mmu_notifier_mm_destroy(struct mm_struct *mm);
154extern void __mmu_notifier_release(struct mm_struct *mm);
155extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
156 unsigned long address);
157extern void __mmu_notifier_invalidate_page(struct mm_struct *mm,
158 unsigned long address);
159extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
160 unsigned long start, unsigned long end);
161extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm,
162 unsigned long start, unsigned long end);
163
164static inline void mmu_notifier_release(struct mm_struct *mm)
165{
166 if (mm_has_notifiers(mm))
167 __mmu_notifier_release(mm);
168}
169
170static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
171 unsigned long address)
172{
173 if (mm_has_notifiers(mm))
174 return __mmu_notifier_clear_flush_young(mm, address);
175 return 0;
176}
177
178static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
179 unsigned long address)
180{
181 if (mm_has_notifiers(mm))
182 __mmu_notifier_invalidate_page(mm, address);
183}
184
185static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
186 unsigned long start, unsigned long end)
187{
188 if (mm_has_notifiers(mm))
189 __mmu_notifier_invalidate_range_start(mm, start, end);
190}
191
192static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
193 unsigned long start, unsigned long end)
194{
195 if (mm_has_notifiers(mm))
196 __mmu_notifier_invalidate_range_end(mm, start, end);
197}
198
199static inline void mmu_notifier_mm_init(struct mm_struct *mm)
200{
201 mm->mmu_notifier_mm = NULL;
202}
203
204static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
205{
206 if (mm_has_notifiers(mm))
207 __mmu_notifier_mm_destroy(mm);
208}
209
210/*
211 * These two macros will sometime replace ptep_clear_flush.
212 * ptep_clear_flush is impleemnted as macro itself, so this also is
213 * implemented as a macro until ptep_clear_flush will converted to an
214 * inline function, to diminish the risk of compilation failure. The
215 * invalidate_page method over time can be moved outside the PT lock
216 * and these two macros can be later removed.
217 */
218#define ptep_clear_flush_notify(__vma, __address, __ptep) \
219({ \
220 pte_t __pte; \
221 struct vm_area_struct *___vma = __vma; \
222 unsigned long ___address = __address; \
223 __pte = ptep_clear_flush(___vma, ___address, __ptep); \
224 mmu_notifier_invalidate_page(___vma->vm_mm, ___address); \
225 __pte; \
226})
227
228#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
229({ \
230 int __young; \
231 struct vm_area_struct *___vma = __vma; \
232 unsigned long ___address = __address; \
233 __young = ptep_clear_flush_young(___vma, ___address, __ptep); \
234 __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \
235 ___address); \
236 __young; \
237})
238
239#else /* CONFIG_MMU_NOTIFIER */
240
241static inline void mmu_notifier_release(struct mm_struct *mm)
242{
243}
244
245static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
246 unsigned long address)
247{
248 return 0;
249}
250
251static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
252 unsigned long address)
253{
254}
255
256static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
257 unsigned long start, unsigned long end)
258{
259}
260
261static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
262 unsigned long start, unsigned long end)
263{
264}
265
266static inline void mmu_notifier_mm_init(struct mm_struct *mm)
267{
268}
269
270static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
271{
272}
273
274#define ptep_clear_flush_young_notify ptep_clear_flush_young
275#define ptep_clear_flush_notify ptep_clear_flush
276
277#endif /* CONFIG_MMU_NOTIFIER */
278
279#endif /* _LINUX_MMU_NOTIFIER_H */
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 4374d1adeb4b..b5efaa2132ab 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -47,7 +47,7 @@ struct vfsmount {
47 struct list_head mnt_child; /* and going through their mnt_child */ 47 struct list_head mnt_child; /* and going through their mnt_child */
48 int mnt_flags; 48 int mnt_flags;
49 /* 4 bytes hole on 64bits arches */ 49 /* 4 bytes hole on 64bits arches */
50 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ 50 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
51 struct list_head mnt_list; 51 struct list_head mnt_list;
52 struct list_head mnt_expire; /* link in fs-specific expiry list */ 52 struct list_head mnt_expire; /* link in fs-specific expiry list */
53 struct list_head mnt_share; /* circular list of shared mounts */ 53 struct list_head mnt_share; /* circular list of shared mounts */
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 9a6e2f953cba..310e61606415 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: blktrans.h,v 1.6 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 3 *
6 * Interface to Linux block layer for MTD 'translation layers'. 4 * Interface to Linux block layer for MTD 'translation layers'.
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
index b0ddf4b25862..d6fb115f5a07 100644
--- a/include/linux/mtd/cfi.h
+++ b/include/linux/mtd/cfi.h
@@ -1,7 +1,6 @@
1 1
2/* Common Flash Interface structures 2/* Common Flash Interface structures
3 * See http://support.intel.com/design/flash/technote/index.htm 3 * See http://support.intel.com/design/flash/technote/index.htm
4 * $Id: cfi.h,v 1.57 2005/11/15 23:28:17 tpoynor Exp $
5 */ 4 */
6 5
7#ifndef __MTD_CFI_H__ 6#ifndef __MTD_CFI_H__
diff --git a/include/linux/mtd/cfi_endian.h b/include/linux/mtd/cfi_endian.h
index 25724f7d3867..d802f7736be3 100644
--- a/include/linux/mtd/cfi_endian.h
+++ b/include/linux/mtd/cfi_endian.h
@@ -1,8 +1,3 @@
1/*
2 * $Id: cfi_endian.h,v 1.11 2002/01/30 23:20:48 awozniak Exp $
3 *
4 */
5
6#include <asm/byteorder.h> 1#include <asm/byteorder.h>
7 2
8#ifndef CONFIG_MTD_CFI_ADV_OPTIONS 3#ifndef CONFIG_MTD_CFI_ADV_OPTIONS
diff --git a/include/linux/mtd/concat.h b/include/linux/mtd/concat.h
index ed8dc6755219..c02f3d264ecf 100644
--- a/include/linux/mtd/concat.h
+++ b/include/linux/mtd/concat.h
@@ -4,8 +4,6 @@
4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de> 4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 *
8 * $Id: concat.h,v 1.1 2002/03/08 16:34:36 rkaiser Exp $
9 */ 7 */
10 8
11#ifndef MTD_CONCAT_H 9#ifndef MTD_CONCAT_H
diff --git a/include/linux/mtd/doc2000.h b/include/linux/mtd/doc2000.h
index 9addd073bf15..0a6d516ab71d 100644
--- a/include/linux/mtd/doc2000.h
+++ b/include/linux/mtd/doc2000.h
@@ -6,8 +6,6 @@
6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com> 6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com>
7 * Copyright (C) 2002-2003 SnapGear Inc 7 * Copyright (C) 2002-2003 SnapGear Inc
8 * 8 *
9 * $Id: doc2000.h,v 1.25 2005/11/07 11:14:54 gleixner Exp $
10 *
11 * Released under GPL 9 * Released under GPL
12 */ 10 */
13 11
diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h
index 39e7d2a1be9a..08dd131301c1 100644
--- a/include/linux/mtd/flashchip.h
+++ b/include/linux/mtd/flashchip.h
@@ -5,9 +5,6 @@
5 * Contains information about the location and state of a given flash device 5 * Contains information about the location and state of a given flash device
6 * 6 *
7 * (C) 2000 Red Hat. GPLd. 7 * (C) 2000 Red Hat. GPLd.
8 *
9 * $Id: flashchip.h,v 1.18 2005/11/07 11:14:54 gleixner Exp $
10 *
11 */ 8 */
12 9
13#ifndef __MTD_FLASHCHIP_H__ 10#ifndef __MTD_FLASHCHIP_H__
diff --git a/include/linux/mtd/ftl.h b/include/linux/mtd/ftl.h
index d99609113307..0be442f881dd 100644
--- a/include/linux/mtd/ftl.h
+++ b/include/linux/mtd/ftl.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ftl.h,v 1.7 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * Derived from (and probably identical to): 2 * Derived from (and probably identical to):
5 * ftl.h 1.7 1999/10/25 20:23:17 3 * ftl.h 1.7 1999/10/25 20:23:17
6 * 4 *
diff --git a/include/linux/mtd/gen_probe.h b/include/linux/mtd/gen_probe.h
index 256e7342ed1e..df362ddf2949 100644
--- a/include/linux/mtd/gen_probe.h
+++ b/include/linux/mtd/gen_probe.h
@@ -1,7 +1,6 @@
1/* 1/*
2 * (C) 2001, 2001 Red Hat, Inc. 2 * (C) 2001, 2001 Red Hat, Inc.
3 * GPL'd 3 * GPL'd
4 * $Id: gen_probe.h,v 1.4 2005/11/07 11:14:54 gleixner Exp $
5 */ 4 */
6 5
7#ifndef __LINUX_MTD_GEN_PROBE_H__ 6#ifndef __LINUX_MTD_GEN_PROBE_H__
diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h
index 85fd041d44ad..64ee53ce95a9 100644
--- a/include/linux/mtd/inftl.h
+++ b/include/linux/mtd/inftl.h
@@ -2,8 +2,6 @@
2 * inftl.h -- defines to support the Inverse NAND Flash Translation Layer 2 * inftl.h -- defines to support the Inverse NAND Flash Translation Layer
3 * 3 *
4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
5 *
6 * $Id: inftl.h,v 1.7 2005/06/13 13:08:45 sean Exp $
7 */ 5 */
8 6
9#ifndef __MTD_INFTL_H__ 7#ifndef __MTD_INFTL_H__
@@ -52,8 +50,6 @@ struct INFTLrecord {
52int INFTL_mount(struct INFTLrecord *s); 50int INFTL_mount(struct INFTLrecord *s);
53int INFTL_formatblock(struct INFTLrecord *s, int block); 51int INFTL_formatblock(struct INFTLrecord *s, int block);
54 52
55extern char inftlmountrev[];
56
57void INFTL_dumptables(struct INFTLrecord *s); 53void INFTL_dumptables(struct INFTLrecord *s);
58void INFTL_dumpVUchains(struct INFTLrecord *s); 54void INFTL_dumpVUchains(struct INFTLrecord *s);
59 55
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index 9c1d95491f8b..aa30244492c6 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -1,6 +1,5 @@
1 1
2/* Overhauled routines for dealing with different mmap regions of flash */ 2/* Overhauled routines for dealing with different mmap regions of flash */
3/* $Id: map.h,v 1.54 2005/11/07 11:14:54 gleixner Exp $ */
4 3
5#ifndef __LINUX_MTD_MAP_H__ 4#ifndef __LINUX_MTD_MAP_H__
6#define __LINUX_MTD_MAP_H__ 5#define __LINUX_MTD_MAP_H__
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8b5d49133ec6..4ed40caff4e5 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd.h,v 1.61 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al. 2 * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al.
5 * 3 *
6 * Released under GPL 4 * Released under GPL
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 53ea3dc8b0e8..83f678702dff 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -5,8 +5,6 @@
5 * Steven J. Hill <sjhill@realitydiluted.com> 5 * Steven J. Hill <sjhill@realitydiluted.com>
6 * Thomas Gleixner <tglx@linutronix.de> 6 * Thomas Gleixner <tglx@linutronix.de>
7 * 7 *
8 * $Id: nand.h,v 1.74 2005/09/15 13:58:50 vwool Exp $
9 *
10 * 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
11 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
@@ -179,6 +177,7 @@ typedef enum {
179#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING)) 177#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
180#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) 178#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
181#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK)) 179#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
180#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT))
182 181
183/* Mask to zero out the chip options, which come from the id table */ 182/* Mask to zero out the chip options, which come from the id table */
184#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) 183#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
@@ -276,6 +275,10 @@ struct nand_ecc_ctrl {
276 int (*read_page)(struct mtd_info *mtd, 275 int (*read_page)(struct mtd_info *mtd,
277 struct nand_chip *chip, 276 struct nand_chip *chip,
278 uint8_t *buf); 277 uint8_t *buf);
278 int (*read_subpage)(struct mtd_info *mtd,
279 struct nand_chip *chip,
280 uint32_t offs, uint32_t len,
281 uint8_t *buf);
279 void (*write_page)(struct mtd_info *mtd, 282 void (*write_page)(struct mtd_info *mtd,
280 struct nand_chip *chip, 283 struct nand_chip *chip,
281 const uint8_t *buf); 284 const uint8_t *buf);
diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h
index 12c5bc342ead..090da505425d 100644
--- a/include/linux/mtd/nand_ecc.h
+++ b/include/linux/mtd/nand_ecc.h
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 4 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
5 * 5 *
6 * $Id: nand_ecc.h,v 1.4 2004/06/17 02:35:02 dbrown Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
diff --git a/include/linux/mtd/nftl.h b/include/linux/mtd/nftl.h
index 001eec50cac6..dcaf611ed748 100644
--- a/include/linux/mtd/nftl.h
+++ b/include/linux/mtd/nftl.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: nftl.h,v 1.16 2004/06/30 14:49:00 dbrown Exp $
3 *
4 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
5 */ 3 */
6 4
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 7c37d7e55abc..5014f7a9f5df 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -4,8 +4,6 @@
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 *
8 * $Id: partitions.h,v 1.17 2005/11/07 11:14:55 gleixner Exp $
9 */ 7 */
10 8
11#ifndef MTD_PARTITIONS_H 9#ifndef MTD_PARTITIONS_H
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
index 0dc07d5f3354..c8e63a5ee72e 100644
--- a/include/linux/mtd/physmap.h
+++ b/include/linux/mtd/physmap.h
@@ -2,8 +2,6 @@
2 * For boards with physically mapped flash and using 2 * For boards with physically mapped flash and using
3 * drivers/mtd/maps/physmap.c mapping driver. 3 * drivers/mtd/maps/physmap.c mapping driver.
4 * 4 *
5 * $Id: physmap.h,v 1.4 2005/11/07 11:14:55 gleixner Exp $
6 *
7 * Copyright (C) 2003 MontaVista Software Inc. 5 * Copyright (C) 2003 MontaVista Software Inc.
8 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net 6 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
9 * 7 *
diff --git a/include/linux/mtd/plat-ram.h b/include/linux/mtd/plat-ram.h
index 0e37ad07bce2..e07890aff1cf 100644
--- a/include/linux/mtd/plat-ram.h
+++ b/include/linux/mtd/plat-ram.h
@@ -6,8 +6,6 @@
6 * 6 *
7 * Generic platform device based RAM map 7 * Generic platform device based RAM map
8 * 8 *
9 * $Id: plat-ram.h,v 1.2 2005/01/24 00:37:40 bjd Exp $
10 *
11 * 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
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
index 5cc070c24d88..27ad40aed19f 100644
--- a/include/linux/mtd/pmc551.h
+++ b/include/linux/mtd/pmc551.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: pmc551.h,v 1.6 2005/11/07 11:14:55 gleixner Exp $
3 *
4 * PMC551 PCI Mezzanine Ram Device 2 * PMC551 PCI Mezzanine Ram Device
5 * 3 *
6 * Author: 4 * Author:
@@ -17,7 +15,7 @@
17 15
18#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
19 17
20#define PMC551_VERSION "$Id: pmc551.h,v 1.6 2005/11/07 11:14:55 gleixner Exp $\n"\ 18#define PMC551_VERSION \
21 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n" 19 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n"
22 20
23/* 21/*
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h
index e9d40bdde48c..36efcba15ecd 100644
--- a/include/linux/mtd/xip.h
+++ b/include/linux/mtd/xip.h
@@ -11,8 +11,6 @@
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
14 *
15 * $Id: xip.h,v 1.5 2005/11/07 11:14:55 gleixner Exp $
16 */ 14 */
17 15
18#ifndef __LINUX_MTD_XIP_H__ 16#ifndef __LINUX_MTD_XIP_H__
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 24d88e98a626..68f8c3203c89 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -47,27 +47,24 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
47#define LOOKUP_DIRECTORY 2 47#define LOOKUP_DIRECTORY 2
48#define LOOKUP_CONTINUE 4 48#define LOOKUP_CONTINUE 4
49#define LOOKUP_PARENT 16 49#define LOOKUP_PARENT 16
50#define LOOKUP_NOALT 32
51#define LOOKUP_REVAL 64 50#define LOOKUP_REVAL 64
52/* 51/*
53 * Intent data 52 * Intent data
54 */ 53 */
55#define LOOKUP_OPEN (0x0100) 54#define LOOKUP_OPEN (0x0100)
56#define LOOKUP_CREATE (0x0200) 55#define LOOKUP_CREATE (0x0200)
57#define LOOKUP_ACCESS (0x0400) 56
58#define LOOKUP_CHDIR (0x0800) 57extern int user_path_at(int, const char __user *, unsigned, struct path *);
59 58
60extern int __user_walk(const char __user *, unsigned, struct nameidata *); 59#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
61extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *); 60#define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
62#define user_path_walk(name,nd) \ 61#define user_path_dir(name, path) \
63 __user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd) 62 user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
64#define user_path_walk_link(name,nd) \ 63
65 __user_walk_fd(AT_FDCWD, name, 0, nd)
66extern int path_lookup(const char *, unsigned, struct nameidata *); 64extern int path_lookup(const char *, unsigned, struct nameidata *);
67extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 65extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
68 const char *, unsigned int, struct nameidata *); 66 const char *, unsigned int, struct nameidata *);
69 67
70extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
71extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags); 68extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
72extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, 69extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
73 int (*open)(struct inode *, struct file *)); 70 int (*open)(struct inode *, struct file *));
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 29d261918734..78a5922a2f11 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -42,7 +42,6 @@
42#include <linux/in.h> 42#include <linux/in.h>
43#include <linux/kref.h> 43#include <linux/kref.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/namei.h>
46#include <linux/pagemap.h> 45#include <linux/pagemap.h>
47#include <linux/rbtree.h> 46#include <linux/rbtree.h>
48#include <linux/rwsem.h> 47#include <linux/rwsem.h>
@@ -332,7 +331,7 @@ extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
332extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr); 331extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
333extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr); 332extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
334extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 333extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
335extern int nfs_permission(struct inode *, int, struct nameidata *); 334extern int nfs_permission(struct inode *, int);
336extern int nfs_open(struct inode *, struct file *); 335extern int nfs_open(struct inode *, struct file *);
337extern int nfs_release(struct inode *, struct file *); 336extern int nfs_release(struct inode *, struct file *);
338extern int nfs_attribute_timeout(struct inode *inode); 337extern int nfs_attribute_timeout(struct inode *inode);
diff --git a/include/linux/of.h b/include/linux/of.h
index 59a61bdc98b6..79886ade070f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -70,5 +70,6 @@ extern int of_n_addr_cells(struct device_node *np);
70extern int of_n_size_cells(struct device_node *np); 70extern int of_n_size_cells(struct device_node *np);
71extern const struct of_device_id *of_match_node( 71extern const struct of_device_id *of_match_node(
72 const struct of_device_id *matches, const struct device_node *node); 72 const struct of_device_id *matches, const struct device_node *node);
73extern int of_modalias_node(struct device_node *node, char *modalias, int len);
73 74
74#endif /* _LINUX_OF_H */ 75#endif /* _LINUX_OF_H */
diff --git a/include/linux/of_spi.h b/include/linux/of_spi.h
new file mode 100644
index 000000000000..5f71ee8c0868
--- /dev/null
+++ b/include/linux/of_spi.h
@@ -0,0 +1,18 @@
1/*
2 * OpenFirmware SPI support routines
3 * Copyright (C) 2008 Secret Lab Technologies Ltd.
4 *
5 * Support routines for deriving SPI device attachments from the device
6 * tree.
7 */
8
9#ifndef __LINUX_OF_SPI_H
10#define __LINUX_OF_SPI_H
11
12#include <linux/of.h>
13#include <linux/spi/spi.h>
14
15extern void of_register_spi_devices(struct spi_master *master,
16 struct device_node *np);
17
18#endif /* __LINUX_OF_SPI */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ee1ec2c7723c..a39b38ccdc97 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -12,6 +12,7 @@
12#include <asm/uaccess.h> 12#include <asm/uaccess.h>
13#include <linux/gfp.h> 13#include <linux/gfp.h>
14#include <linux/bitops.h> 14#include <linux/bitops.h>
15#include <linux/hardirq.h> /* for in_interrupt() */
15 16
16/* 17/*
17 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page 18 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page
@@ -19,6 +20,7 @@
19 */ 20 */
20#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */ 21#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */
21#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */ 22#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */
23#define AS_MM_ALL_LOCKS (__GFP_BITS_SHIFT + 2) /* under mm_take_all_locks() */
22 24
23static inline void mapping_set_error(struct address_space *mapping, int error) 25static inline void mapping_set_error(struct address_space *mapping, int error)
24{ 26{
@@ -62,6 +64,98 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
62#define page_cache_release(page) put_page(page) 64#define page_cache_release(page) put_page(page)
63void release_pages(struct page **pages, int nr, int cold); 65void release_pages(struct page **pages, int nr, int cold);
64 66
67/*
68 * speculatively take a reference to a page.
69 * If the page is free (_count == 0), then _count is untouched, and 0
70 * is returned. Otherwise, _count is incremented by 1 and 1 is returned.
71 *
72 * This function must be called inside the same rcu_read_lock() section as has
73 * been used to lookup the page in the pagecache radix-tree (or page table):
74 * this allows allocators to use a synchronize_rcu() to stabilize _count.
75 *
76 * Unless an RCU grace period has passed, the count of all pages coming out
77 * of the allocator must be considered unstable. page_count may return higher
78 * than expected, and put_page must be able to do the right thing when the
79 * page has been finished with, no matter what it is subsequently allocated
80 * for (because put_page is what is used here to drop an invalid speculative
81 * reference).
82 *
83 * This is the interesting part of the lockless pagecache (and lockless
84 * get_user_pages) locking protocol, where the lookup-side (eg. find_get_page)
85 * has the following pattern:
86 * 1. find page in radix tree
87 * 2. conditionally increment refcount
88 * 3. check the page is still in pagecache (if no, goto 1)
89 *
90 * Remove-side that cares about stability of _count (eg. reclaim) has the
91 * following (with tree_lock held for write):
92 * A. atomically check refcount is correct and set it to 0 (atomic_cmpxchg)
93 * B. remove page from pagecache
94 * C. free the page
95 *
96 * There are 2 critical interleavings that matter:
97 * - 2 runs before A: in this case, A sees elevated refcount and bails out
98 * - A runs before 2: in this case, 2 sees zero refcount and retries;
99 * subsequently, B will complete and 1 will find no page, causing the
100 * lookup to return NULL.
101 *
102 * It is possible that between 1 and 2, the page is removed then the exact same
103 * page is inserted into the same position in pagecache. That's OK: the
104 * old find_get_page using tree_lock could equally have run before or after
105 * such a re-insertion, depending on order that locks are granted.
106 *
107 * Lookups racing against pagecache insertion isn't a big problem: either 1
108 * will find the page or it will not. Likewise, the old find_get_page could run
109 * either before the insertion or afterwards, depending on timing.
110 */
111static inline int page_cache_get_speculative(struct page *page)
112{
113 VM_BUG_ON(in_interrupt());
114
115#if !defined(CONFIG_SMP) && defined(CONFIG_CLASSIC_RCU)
116# ifdef CONFIG_PREEMPT
117 VM_BUG_ON(!in_atomic());
118# endif
119 /*
120 * Preempt must be disabled here - we rely on rcu_read_lock doing
121 * this for us.
122 *
123 * Pagecache won't be truncated from interrupt context, so if we have
124 * found a page in the radix tree here, we have pinned its refcount by
125 * disabling preempt, and hence no need for the "speculative get" that
126 * SMP requires.
127 */
128 VM_BUG_ON(page_count(page) == 0);
129 atomic_inc(&page->_count);
130
131#else
132 if (unlikely(!get_page_unless_zero(page))) {
133 /*
134 * Either the page has been freed, or will be freed.
135 * In either case, retry here and the caller should
136 * do the right thing (see comments above).
137 */
138 return 0;
139 }
140#endif
141 VM_BUG_ON(PageTail(page));
142
143 return 1;
144}
145
146static inline int page_freeze_refs(struct page *page, int count)
147{
148 return likely(atomic_cmpxchg(&page->_count, count, 0) == count);
149}
150
151static inline void page_unfreeze_refs(struct page *page, int count)
152{
153 VM_BUG_ON(page_count(page) != 0);
154 VM_BUG_ON(count == 0);
155
156 atomic_set(&page->_count, count);
157}
158
65#ifdef CONFIG_NUMA 159#ifdef CONFIG_NUMA
66extern struct page *__page_cache_alloc(gfp_t gfp); 160extern struct page *__page_cache_alloc(gfp_t gfp);
67#else 161#else
@@ -133,7 +227,7 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
133 return read_cache_page(mapping, index, filler, data); 227 return read_cache_page(mapping, index, filler, data);
134} 228}
135 229
136int add_to_page_cache(struct page *page, struct address_space *mapping, 230int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
137 pgoff_t index, gfp_t gfp_mask); 231 pgoff_t index, gfp_t gfp_mask);
138int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 232int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
139 pgoff_t index, gfp_t gfp_mask); 233 pgoff_t index, gfp_t gfp_mask);
@@ -141,6 +235,22 @@ extern void remove_from_page_cache(struct page *page);
141extern void __remove_from_page_cache(struct page *page); 235extern void __remove_from_page_cache(struct page *page);
142 236
143/* 237/*
238 * Like add_to_page_cache_locked, but used to add newly allocated pages:
239 * the page is new, so we can just run SetPageLocked() against it.
240 */
241static inline int add_to_page_cache(struct page *page,
242 struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask)
243{
244 int error;
245
246 SetPageLocked(page);
247 error = add_to_page_cache_locked(page, mapping, offset, gfp_mask);
248 if (unlikely(error))
249 ClearPageLocked(page);
250 return error;
251}
252
253/*
144 * Return byte-offset into filesystem object for page. 254 * Return byte-offset into filesystem object for page.
145 */ 255 */
146static inline loff_t page_offset(struct page *page) 256static inline loff_t page_offset(struct page *page)
diff --git a/include/linux/parport.h b/include/linux/parport.h
index dcb9e01a69ca..6a0d7cdb5774 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -560,5 +560,8 @@ extern int parport_device_proc_unregister(struct pardevice *device);
560 560
561#endif /* !CONFIG_PARPORT_NOT_PC */ 561#endif /* !CONFIG_PARPORT_NOT_PC */
562 562
563extern unsigned long parport_default_timeslice;
564extern int parport_default_spintime;
565
563#endif /* __KERNEL__ */ 566#endif /* __KERNEL__ */
564#endif /* _PARPORT_H_ */ 567#endif /* _PARPORT_H_ */
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index a1a1e618e996..91ba0b338b47 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -27,6 +27,7 @@ extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev); 27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev); 28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state); 29extern void pci_disable_link_state(struct pci_dev *pdev, int state);
30extern void pcie_no_aspm(void);
30#else 31#else
31static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) 32static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
32{ 33{
@@ -40,6 +41,10 @@ static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
40static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 41static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
41{ 42{
42} 43}
44
45static inline void pcie_no_aspm(void)
46{
47}
43#endif 48#endif
44 49
45#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */ 50#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 1d296d31abe0..825be3878f68 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -124,6 +124,8 @@ enum pci_dev_flags {
124 * generation too. 124 * generation too.
125 */ 125 */
126 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1, 126 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
127 /* Device configuration is irrevocably lost if disabled into D3 */
128 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
127}; 129};
128 130
129typedef unsigned short __bitwise pci_bus_flags_t; 131typedef unsigned short __bitwise pci_bus_flags_t;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c3b1761aba26..35a78415accc 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -748,6 +748,7 @@
748#define PCI_VENDOR_ID_TI 0x104c 748#define PCI_VENDOR_ID_TI 0x104c
749#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 749#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
750#define PCI_DEVICE_ID_TI_4450 0x8011 750#define PCI_DEVICE_ID_TI_4450 0x8011
751#define PCI_DEVICE_ID_TI_TSB43AB22 0x8023
751#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 752#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031
752#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033 753#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033
753#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034 754#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034
@@ -1832,7 +1833,13 @@
1832#define PCI_DEVICE_ID_MOXA_C320 0x3200 1833#define PCI_DEVICE_ID_MOXA_C320 0x3200
1833 1834
1834#define PCI_VENDOR_ID_CCD 0x1397 1835#define PCI_VENDOR_ID_CCD 0x1397
1836#define PCI_DEVICE_ID_CCD_HFC4S 0x08B4
1837#define PCI_SUBDEVICE_ID_CCD_PMX2S 0x1234
1838#define PCI_DEVICE_ID_CCD_HFC8S 0x16B8
1835#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 1839#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
1840#define PCI_DEVICE_ID_CCD_HFCE1 0x30B1
1841#define PCI_SUBDEVICE_ID_CCD_SPD4S 0x3136
1842#define PCI_SUBDEVICE_ID_CCD_SPDE1 0x3137
1836#define PCI_DEVICE_ID_CCD_B000 0xb000 1843#define PCI_DEVICE_ID_CCD_B000 0xb000
1837#define PCI_DEVICE_ID_CCD_B006 0xb006 1844#define PCI_DEVICE_ID_CCD_B006 0xb006
1838#define PCI_DEVICE_ID_CCD_B007 0xb007 1845#define PCI_DEVICE_ID_CCD_B007 0xb007
@@ -1842,8 +1849,32 @@
1842#define PCI_DEVICE_ID_CCD_B00B 0xb00b 1849#define PCI_DEVICE_ID_CCD_B00B 0xb00b
1843#define PCI_DEVICE_ID_CCD_B00C 0xb00c 1850#define PCI_DEVICE_ID_CCD_B00C 0xb00c
1844#define PCI_DEVICE_ID_CCD_B100 0xb100 1851#define PCI_DEVICE_ID_CCD_B100 0xb100
1852#define PCI_SUBDEVICE_ID_CCD_IOB4ST 0xB520
1853#define PCI_SUBDEVICE_ID_CCD_IOB8STR 0xB521
1854#define PCI_SUBDEVICE_ID_CCD_IOB8ST 0xB522
1855#define PCI_SUBDEVICE_ID_CCD_IOB1E1 0xB523
1856#define PCI_SUBDEVICE_ID_CCD_SWYX4S 0xB540
1857#define PCI_SUBDEVICE_ID_CCD_JH4S20 0xB550
1858#define PCI_SUBDEVICE_ID_CCD_IOB8ST_1 0xB552
1859#define PCI_SUBDEVICE_ID_CCD_BN4S 0xB560
1860#define PCI_SUBDEVICE_ID_CCD_BN8S 0xB562
1861#define PCI_SUBDEVICE_ID_CCD_BNE1 0xB563
1862#define PCI_SUBDEVICE_ID_CCD_BNE1D 0xB564
1863#define PCI_SUBDEVICE_ID_CCD_BNE1DP 0xB565
1864#define PCI_SUBDEVICE_ID_CCD_BN2S 0xB566
1865#define PCI_SUBDEVICE_ID_CCD_BN1SM 0xB567
1866#define PCI_SUBDEVICE_ID_CCD_BN4SM 0xB568
1867#define PCI_SUBDEVICE_ID_CCD_BN2SM 0xB569
1868#define PCI_SUBDEVICE_ID_CCD_BNE1M 0xB56A
1869#define PCI_SUBDEVICE_ID_CCD_BN8SP 0xB56B
1870#define PCI_SUBDEVICE_ID_CCD_HFC4S 0xB620
1871#define PCI_SUBDEVICE_ID_CCD_HFC8S 0xB622
1845#define PCI_DEVICE_ID_CCD_B700 0xb700 1872#define PCI_DEVICE_ID_CCD_B700 0xb700
1846#define PCI_DEVICE_ID_CCD_B701 0xb701 1873#define PCI_DEVICE_ID_CCD_B701 0xb701
1874#define PCI_SUBDEVICE_ID_CCD_HFCE1 0xC523
1875#define PCI_SUBDEVICE_ID_CCD_OV2S 0xE884
1876#define PCI_SUBDEVICE_ID_CCD_OV4S 0xE888
1877#define PCI_SUBDEVICE_ID_CCD_OV8S 0xE998
1847 1878
1848#define PCI_VENDOR_ID_EXAR 0x13a8 1879#define PCI_VENDOR_ID_EXAR 0x13a8
1849#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 1880#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152
@@ -2523,6 +2554,9 @@
2523 2554
2524#define PCI_VENDOR_ID_3COM_2 0xa727 2555#define PCI_VENDOR_ID_3COM_2 0xa727
2525 2556
2557#define PCI_VENDOR_ID_DIGIUM 0xd161
2558#define PCI_DEVICE_ID_DIGIUM_HFC4S 0xb410
2559
2526#define PCI_SUBVENDOR_ID_EXSYS 0xd84d 2560#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
2527#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 2561#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
2528#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 2562#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 19958b929905..450684f7eaac 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -374,6 +374,7 @@
374#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ 374#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
375#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ 375#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
376#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ 376#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
377#define PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
377#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ 378#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
378#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ 379#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
379#define PCI_EXP_DEVCTL 8 /* Device Control */ 380#define PCI_EXP_DEVCTL 8 /* Device Control */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 4cdd393e71e1..fac3337547eb 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -74,11 +74,6 @@ struct percpu_data {
74 (__typeof__(ptr))__p->ptrs[(cpu)]; \ 74 (__typeof__(ptr))__p->ptrs[(cpu)]; \
75}) 75})
76 76
77extern void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu);
78extern void percpu_depopulate(void *__pdata, int cpu);
79extern int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
80 cpumask_t *mask);
81extern void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask);
82extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask); 77extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask);
83extern void percpu_free(void *__pdata); 78extern void percpu_free(void *__pdata);
84 79
@@ -86,26 +81,6 @@ extern void percpu_free(void *__pdata);
86 81
87#define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) 82#define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
88 83
89static inline void percpu_depopulate(void *__pdata, int cpu)
90{
91}
92
93static inline void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask)
94{
95}
96
97static inline void *percpu_populate(void *__pdata, size_t size, gfp_t gfp,
98 int cpu)
99{
100 return percpu_ptr(__pdata, cpu);
101}
102
103static inline int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
104 cpumask_t *mask)
105{
106 return 0;
107}
108
109static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) 84static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask)
110{ 85{
111 return kzalloc(size, gfp); 86 return kzalloc(size, gfp);
@@ -118,10 +93,6 @@ static inline void percpu_free(void *__pdata)
118 93
119#endif /* CONFIG_SMP */ 94#endif /* CONFIG_SMP */
120 95
121#define percpu_populate_mask(__pdata, size, gfp, mask) \
122 __percpu_populate_mask((__pdata), (size), (gfp), &(mask))
123#define percpu_depopulate_mask(__pdata, mask) \
124 __percpu_depopulate_mask((__pdata), &(mask))
125#define percpu_alloc_mask(size, gfp, mask) \ 96#define percpu_alloc_mask(size, gfp, mask) \
126 __percpu_alloc_mask((size), (gfp), &(mask)) 97 __percpu_alloc_mask((size), (gfp), &(mask))
127 98
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index f560d1705afe..fb61850d1cfc 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -282,11 +282,16 @@ union proc_op {
282 struct task_struct *task); 282 struct task_struct *task);
283}; 283};
284 284
285struct ctl_table_header;
286struct ctl_table;
287
285struct proc_inode { 288struct proc_inode {
286 struct pid *pid; 289 struct pid *pid;
287 int fd; 290 int fd;
288 union proc_op op; 291 union proc_op op;
289 struct proc_dir_entry *pde; 292 struct proc_dir_entry *pde;
293 struct ctl_table_header *sysctl;
294 struct ctl_table *sysctl_entry;
290 struct inode vfs_inode; 295 struct inode vfs_inode;
291}; 296};
292 297
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index c6f5f9dd0cee..fd31756e1a00 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -121,6 +121,74 @@ static inline void ptrace_unlink(struct task_struct *child)
121int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data); 121int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data);
122int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data); 122int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data);
123 123
124/**
125 * task_ptrace - return %PT_* flags that apply to a task
126 * @task: pointer to &task_struct in question
127 *
128 * Returns the %PT_* flags that apply to @task.
129 */
130static inline int task_ptrace(struct task_struct *task)
131{
132 return task->ptrace;
133}
134
135/**
136 * ptrace_event - possibly stop for a ptrace event notification
137 * @mask: %PT_* bit to check in @current->ptrace
138 * @event: %PTRACE_EVENT_* value to report if @mask is set
139 * @message: value for %PTRACE_GETEVENTMSG to return
140 *
141 * This checks the @mask bit to see if ptrace wants stops for this event.
142 * If so we stop, reporting @event and @message to the ptrace parent.
143 *
144 * Returns nonzero if we did a ptrace notification, zero if not.
145 *
146 * Called without locks.
147 */
148static inline int ptrace_event(int mask, int event, unsigned long message)
149{
150 if (mask && likely(!(current->ptrace & mask)))
151 return 0;
152 current->ptrace_message = message;
153 ptrace_notify((event << 8) | SIGTRAP);
154 return 1;
155}
156
157/**
158 * ptrace_init_task - initialize ptrace state for a new child
159 * @child: new child task
160 * @ptrace: true if child should be ptrace'd by parent's tracer
161 *
162 * This is called immediately after adding @child to its parent's children
163 * list. @ptrace is false in the normal case, and true to ptrace @child.
164 *
165 * Called with current's siglock and write_lock_irq(&tasklist_lock) held.
166 */
167static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
168{
169 INIT_LIST_HEAD(&child->ptrace_entry);
170 INIT_LIST_HEAD(&child->ptraced);
171 child->parent = child->real_parent;
172 child->ptrace = 0;
173 if (unlikely(ptrace)) {
174 child->ptrace = current->ptrace;
175 __ptrace_link(child, current->parent);
176 }
177}
178
179/**
180 * ptrace_release_task - final ptrace-related cleanup of a zombie being reaped
181 * @task: task in %EXIT_DEAD state
182 *
183 * Called with write_lock(&tasklist_lock) held.
184 */
185static inline void ptrace_release_task(struct task_struct *task)
186{
187 BUG_ON(!list_empty(&task->ptraced));
188 ptrace_unlink(task);
189 BUG_ON(!list_empty(&task->ptrace_entry));
190}
191
124#ifndef force_successful_syscall_return 192#ifndef force_successful_syscall_return
125/* 193/*
126 * System call handlers that, upon successful completion, need to return a 194 * System call handlers that, upon successful completion, need to return a
@@ -246,6 +314,10 @@ static inline void user_enable_block_step(struct task_struct *task)
246#define arch_ptrace_stop(code, info) do { } while (0) 314#define arch_ptrace_stop(code, info) do { } while (0)
247#endif 315#endif
248 316
317extern int task_current_syscall(struct task_struct *target, long *callno,
318 unsigned long args[6], unsigned int maxargs,
319 unsigned long *sp, unsigned long *pc);
320
249#endif 321#endif
250 322
251#endif 323#endif
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index b8ce2b444bb5..a916c6660dfa 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -99,12 +99,15 @@ do { \
99 * 99 *
100 * The notable exceptions to this rule are the following functions: 100 * The notable exceptions to this rule are the following functions:
101 * radix_tree_lookup 101 * radix_tree_lookup
102 * radix_tree_lookup_slot
102 * radix_tree_tag_get 103 * radix_tree_tag_get
103 * radix_tree_gang_lookup 104 * radix_tree_gang_lookup
105 * radix_tree_gang_lookup_slot
104 * radix_tree_gang_lookup_tag 106 * radix_tree_gang_lookup_tag
107 * radix_tree_gang_lookup_tag_slot
105 * radix_tree_tagged 108 * radix_tree_tagged
106 * 109 *
107 * The first 4 functions are able to be called locklessly, using RCU. The 110 * The first 7 functions are able to be called locklessly, using RCU. The
108 * caller must ensure calls to these functions are made within rcu_read_lock() 111 * caller must ensure calls to these functions are made within rcu_read_lock()
109 * regions. Other readers (lock-free or otherwise) and modifications may be 112 * regions. Other readers (lock-free or otherwise) and modifications may be
110 * running concurrently. 113 * running concurrently.
@@ -159,6 +162,9 @@ void *radix_tree_delete(struct radix_tree_root *, unsigned long);
159unsigned int 162unsigned int
160radix_tree_gang_lookup(struct radix_tree_root *root, void **results, 163radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
161 unsigned long first_index, unsigned int max_items); 164 unsigned long first_index, unsigned int max_items);
165unsigned int
166radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results,
167 unsigned long first_index, unsigned int max_items);
162unsigned long radix_tree_next_hole(struct radix_tree_root *root, 168unsigned long radix_tree_next_hole(struct radix_tree_root *root,
163 unsigned long index, unsigned long max_scan); 169 unsigned long index, unsigned long max_scan);
164int radix_tree_preload(gfp_t gfp_mask); 170int radix_tree_preload(gfp_t gfp_mask);
@@ -173,6 +179,10 @@ unsigned int
173radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, 179radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
174 unsigned long first_index, unsigned int max_items, 180 unsigned long first_index, unsigned int max_items,
175 unsigned int tag); 181 unsigned int tag);
182unsigned int
183radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results,
184 unsigned long first_index, unsigned int max_items,
185 unsigned int tag);
176int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag); 186int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
177 187
178static inline void radix_tree_preload_end(void) 188static inline void radix_tree_preload_end(void)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index b0f39be08b6c..eb4443c7e05b 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -98,6 +98,34 @@ static inline void list_del_rcu(struct list_head *entry)
98} 98}
99 99
100/** 100/**
101 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
102 * @n: the element to delete from the hash list.
103 *
104 * Note: list_unhashed() on the node return true after this. It is
105 * useful for RCU based read lockfree traversal if the writer side
106 * must know if the list entry is still hashed or already unhashed.
107 *
108 * In particular, it means that we can not poison the forward pointers
109 * that may still be used for walking the hash list and we can only
110 * zero the pprev pointer so list_unhashed() will return true after
111 * this.
112 *
113 * The caller must take whatever precautions are necessary (such as
114 * holding appropriate locks) to avoid racing with another
115 * list-mutation primitive, such as hlist_add_head_rcu() or
116 * hlist_del_rcu(), running on this same list. However, it is
117 * perfectly legal to run concurrently with the _rcu list-traversal
118 * primitives, such as hlist_for_each_entry_rcu().
119 */
120static inline void hlist_del_init_rcu(struct hlist_node *n)
121{
122 if (!hlist_unhashed(n)) {
123 __hlist_del(n);
124 n->pprev = NULL;
125 }
126}
127
128/**
101 * list_replace_rcu - replace old entry by new one 129 * list_replace_rcu - replace old entry by new one
102 * @old : the element to be replaced 130 * @old : the element to be replaced
103 * @new : the new element to insert 131 * @new : the new element to insert
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 66a96814d614..af135ae895db 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -55,7 +55,7 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name);
55int reiserfs_delete_xattrs(struct inode *inode); 55int reiserfs_delete_xattrs(struct inode *inode);
56int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); 56int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
57int reiserfs_xattr_init(struct super_block *sb, int mount_flags); 57int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
58int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd); 58int reiserfs_permission(struct inode *inode, int mask);
59 59
60int reiserfs_xattr_del(struct inode *, const char *); 60int reiserfs_xattr_del(struct inode *, const char *);
61int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t); 61int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 6cd8c4425fc7..953fc055e875 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -48,6 +48,7 @@ struct rchan_buf
48 size_t *padding; /* padding counts per sub-buffer */ 48 size_t *padding; /* padding counts per sub-buffer */
49 size_t prev_padding; /* temporary variable */ 49 size_t prev_padding; /* temporary variable */
50 size_t bytes_consumed; /* bytes consumed in cur read subbuf */ 50 size_t bytes_consumed; /* bytes consumed in cur read subbuf */
51 size_t early_bytes; /* bytes consumed before VFS inited */
51 unsigned int cpu; /* this buf's cpu */ 52 unsigned int cpu; /* this buf's cpu */
52} ____cacheline_aligned; 53} ____cacheline_aligned;
53 54
@@ -68,6 +69,7 @@ struct rchan
68 int is_global; /* One global buffer ? */ 69 int is_global; /* One global buffer ? */
69 struct list_head list; /* for channel list */ 70 struct list_head list; /* for channel list */
70 struct dentry *parent; /* parent dentry passed to open */ 71 struct dentry *parent; /* parent dentry passed to open */
72 int has_base_filename; /* has a filename associated? */
71 char base_filename[NAME_MAX]; /* saved base filename */ 73 char base_filename[NAME_MAX]; /* saved base filename */
72}; 74};
73 75
@@ -169,6 +171,9 @@ struct rchan *relay_open(const char *base_filename,
169 size_t n_subbufs, 171 size_t n_subbufs,
170 struct rchan_callbacks *cb, 172 struct rchan_callbacks *cb,
171 void *private_data); 173 void *private_data);
174extern int relay_late_setup_files(struct rchan *chan,
175 const char *base_filename,
176 struct dentry *parent);
172extern void relay_close(struct rchan *chan); 177extern void relay_close(struct rchan *chan);
173extern void relay_flush(struct rchan *chan); 178extern void relay_flush(struct rchan *chan);
174extern void relay_subbufs_consumed(struct rchan *chan, 179extern void relay_subbufs_consumed(struct rchan *chan,
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 1383692ac5bd..69407f85e10b 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -26,6 +26,14 @@
26 */ 26 */
27struct anon_vma { 27struct anon_vma {
28 spinlock_t lock; /* Serialize access to vma list */ 28 spinlock_t lock; /* Serialize access to vma list */
29 /*
30 * NOTE: the LSB of the head.next is set by
31 * mm_take_all_locks() _after_ taking the above lock. So the
32 * head must only be read/written after taking the above lock
33 * to be sure to see a valid next pointer. The LSB bit itself
34 * is serialized by a system wide lock only visible to
35 * mm_take_all_locks() (mm_all_locks_mutex).
36 */
29 struct list_head head; /* List of private "related" vmas */ 37 struct list_head head; /* List of private "related" vmas */
30}; 38};
31 39
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index b01fe004cb5e..91f597ad6acc 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -225,8 +225,6 @@ typedef struct rtc_task {
225int rtc_register(rtc_task_t *task); 225int rtc_register(rtc_task_t *task);
226int rtc_unregister(rtc_task_t *task); 226int rtc_unregister(rtc_task_t *task);
227int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); 227int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
228void rtc_get_rtc_time(struct rtc_time *rtc_tm);
229irqreturn_t rtc_interrupt(int irq, void *dev_id);
230 228
231#endif /* __KERNEL__ */ 229#endif /* __KERNEL__ */
232 230
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index f4d386c191f5..ca643b13b026 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -755,13 +755,6 @@ extern void __rtnl_unlock(void);
755 } \ 755 } \
756} while(0) 756} while(0)
757 757
758#define BUG_TRAP(x) do { \
759 if (unlikely(!(x))) { \
760 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
761 #x, __FILE__ , __LINE__); \
762 } \
763} while(0)
764
765static inline u32 rtm_get_table(struct rtattr **rta, u8 table) 758static inline u32 rtm_get_table(struct rtattr **rta, u8 table)
766{ 759{
767 return RTA_GET_U32(rta[RTA_TABLE-1]); 760 return RTA_GET_U32(rta[RTA_TABLE-1]);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 42036ffe6b00..5270d449ff9d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -292,7 +292,6 @@ extern void sched_show_task(struct task_struct *p);
292 292
293#ifdef CONFIG_DETECT_SOFTLOCKUP 293#ifdef CONFIG_DETECT_SOFTLOCKUP
294extern void softlockup_tick(void); 294extern void softlockup_tick(void);
295extern void spawn_softlockup_task(void);
296extern void touch_softlockup_watchdog(void); 295extern void touch_softlockup_watchdog(void);
297extern void touch_all_softlockup_watchdogs(void); 296extern void touch_all_softlockup_watchdogs(void);
298extern unsigned int softlockup_panic; 297extern unsigned int softlockup_panic;
@@ -506,9 +505,6 @@ struct signal_struct {
506 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 505 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
507 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 506 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
508 unsigned long inblock, oublock, cinblock, coublock; 507 unsigned long inblock, oublock, cinblock, coublock;
509#ifdef CONFIG_TASK_XACCT
510 u64 rchar, wchar, syscr, syscw;
511#endif
512 struct task_io_accounting ioac; 508 struct task_io_accounting ioac;
513 509
514 /* 510 /*
@@ -1257,10 +1253,6 @@ struct task_struct {
1257 1253
1258 unsigned long ptrace_message; 1254 unsigned long ptrace_message;
1259 siginfo_t *last_siginfo; /* For ptrace use. */ 1255 siginfo_t *last_siginfo; /* For ptrace use. */
1260#ifdef CONFIG_TASK_XACCT
1261/* i/o counters(bytes read/written, #syscalls */
1262 u64 rchar, wchar, syscr, syscw;
1263#endif
1264 struct task_io_accounting ioac; 1256 struct task_io_accounting ioac;
1265#if defined(CONFIG_TASK_XACCT) 1257#if defined(CONFIG_TASK_XACCT)
1266 u64 acct_rss_mem1; /* accumulated rss usage */ 1258 u64 acct_rss_mem1; /* accumulated rss usage */
@@ -1797,7 +1789,7 @@ extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_
1797extern int kill_pgrp(struct pid *pid, int sig, int priv); 1789extern int kill_pgrp(struct pid *pid, int sig, int priv);
1798extern int kill_pid(struct pid *pid, int sig, int priv); 1790extern int kill_pid(struct pid *pid, int sig, int priv);
1799extern int kill_proc_info(int, struct siginfo *, pid_t); 1791extern int kill_proc_info(int, struct siginfo *, pid_t);
1800extern void do_notify_parent(struct task_struct *, int); 1792extern int do_notify_parent(struct task_struct *, int);
1801extern void force_sig(int, struct task_struct *); 1793extern void force_sig(int, struct task_struct *);
1802extern void force_sig_specific(int, struct task_struct *); 1794extern void force_sig_specific(int, struct task_struct *);
1803extern int send_sig(int, struct task_struct *, int); 1795extern int send_sig(int, struct task_struct *, int);
@@ -1883,9 +1875,13 @@ extern void set_task_comm(struct task_struct *tsk, char *from);
1883extern char *get_task_comm(char *to, struct task_struct *tsk); 1875extern char *get_task_comm(char *to, struct task_struct *tsk);
1884 1876
1885#ifdef CONFIG_SMP 1877#ifdef CONFIG_SMP
1886extern void wait_task_inactive(struct task_struct * p); 1878extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
1887#else 1879#else
1888#define wait_task_inactive(p) do { } while (0) 1880static inline unsigned long wait_task_inactive(struct task_struct *p,
1881 long match_state)
1882{
1883 return 1;
1884}
1889#endif 1885#endif
1890 1886
1891#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 1887#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks)
@@ -2139,16 +2135,7 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
2139 2135
2140#endif /* CONFIG_SMP */ 2136#endif /* CONFIG_SMP */
2141 2137
2142#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2143extern void arch_pick_mmap_layout(struct mm_struct *mm); 2138extern void arch_pick_mmap_layout(struct mm_struct *mm);
2144#else
2145static inline void arch_pick_mmap_layout(struct mm_struct *mm)
2146{
2147 mm->mmap_base = TASK_UNMAPPED_BASE;
2148 mm->get_unmapped_area = arch_get_unmapped_area;
2149 mm->unmap_area = arch_unmap_area;
2150}
2151#endif
2152 2139
2153#ifdef CONFIG_TRACING 2140#ifdef CONFIG_TRACING
2154extern void 2141extern void
@@ -2196,22 +2183,22 @@ extern long sched_group_rt_period(struct task_group *tg);
2196#ifdef CONFIG_TASK_XACCT 2183#ifdef CONFIG_TASK_XACCT
2197static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 2184static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
2198{ 2185{
2199 tsk->rchar += amt; 2186 tsk->ioac.rchar += amt;
2200} 2187}
2201 2188
2202static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 2189static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
2203{ 2190{
2204 tsk->wchar += amt; 2191 tsk->ioac.wchar += amt;
2205} 2192}
2206 2193
2207static inline void inc_syscr(struct task_struct *tsk) 2194static inline void inc_syscr(struct task_struct *tsk)
2208{ 2195{
2209 tsk->syscr++; 2196 tsk->ioac.syscr++;
2210} 2197}
2211 2198
2212static inline void inc_syscw(struct task_struct *tsk) 2199static inline void inc_syscw(struct task_struct *tsk)
2213{ 2200{
2214 tsk->syscw++; 2201 tsk->ioac.syscw++;
2215} 2202}
2216#else 2203#else
2217static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 2204static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
@@ -2231,14 +2218,6 @@ static inline void inc_syscw(struct task_struct *tsk)
2231} 2218}
2232#endif 2219#endif
2233 2220
2234#ifdef CONFIG_SMP
2235void migration_init(void);
2236#else
2237static inline void migration_init(void)
2238{
2239}
2240#endif
2241
2242#ifndef TASK_SIZE_OF 2221#ifndef TASK_SIZE_OF
2243#define TASK_SIZE_OF(tsk) TASK_SIZE 2222#define TASK_SIZE_OF(tsk) TASK_SIZE
2244#endif 2223#endif
diff --git a/include/linux/security.h b/include/linux/security.h
index f0e9adb22ac2..fd96e7f8a6f9 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1362,7 +1362,7 @@ struct security_operations {
1362 struct inode *new_dir, struct dentry *new_dentry); 1362 struct inode *new_dir, struct dentry *new_dentry);
1363 int (*inode_readlink) (struct dentry *dentry); 1363 int (*inode_readlink) (struct dentry *dentry);
1364 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); 1364 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1365 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); 1365 int (*inode_permission) (struct inode *inode, int mask);
1366 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); 1366 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1367 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); 1367 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1368 void (*inode_delete) (struct inode *inode); 1368 void (*inode_delete) (struct inode *inode);
@@ -1628,7 +1628,7 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1628 struct inode *new_dir, struct dentry *new_dentry); 1628 struct inode *new_dir, struct dentry *new_dentry);
1629int security_inode_readlink(struct dentry *dentry); 1629int security_inode_readlink(struct dentry *dentry);
1630int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); 1630int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1631int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd); 1631int security_inode_permission(struct inode *inode, int mask);
1632int security_inode_setattr(struct dentry *dentry, struct iattr *attr); 1632int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1633int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); 1633int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1634void security_inode_delete(struct inode *inode); 1634void security_inode_delete(struct inode *inode);
@@ -2021,8 +2021,7 @@ static inline int security_inode_follow_link(struct dentry *dentry,
2021 return 0; 2021 return 0;
2022} 2022}
2023 2023
2024static inline int security_inode_permission(struct inode *inode, int mask, 2024static inline int security_inode_permission(struct inode *inode, int mask)
2025 struct nameidata *nd)
2026{ 2025{
2027 return 0; 2026 return 0;
2028} 2027}
diff --git a/include/linux/serio.h b/include/linux/serio.h
index e72716cca577..25641d9e0ea8 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -87,11 +87,10 @@ void serio_unregister_port(struct serio *serio);
87void serio_unregister_child_port(struct serio *serio); 87void serio_unregister_child_port(struct serio *serio);
88 88
89int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name); 89int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name);
90static inline int serio_register_driver(struct serio_driver *drv) 90static inline int __must_check serio_register_driver(struct serio_driver *drv)
91{ 91{
92 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME); 92 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
93} 93}
94int serio_register_driver(struct serio_driver *drv);
95void serio_unregister_driver(struct serio_driver *drv); 94void serio_unregister_driver(struct serio_driver *drv);
96 95
97static inline int serio_write(struct serio *serio, unsigned char data) 96static inline int serio_write(struct serio *serio, unsigned char data)
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index f2d12d5a21b8..fd83f2584b15 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -43,7 +43,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
43} 43}
44 44
45#ifdef CONFIG_TMPFS_POSIX_ACL 45#ifdef CONFIG_TMPFS_POSIX_ACL
46int shmem_permission(struct inode *, int, struct nameidata *); 46int shmem_permission(struct inode *, int);
47int shmem_acl_init(struct inode *, struct inode *); 47int shmem_acl_init(struct inode *, struct inode *);
48void shmem_acl_destroy_inode(struct inode *); 48void shmem_acl_destroy_inode(struct inode *);
49 49
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 41103910f8a2..5ff9676c1e2c 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -58,7 +58,7 @@ int slab_is_available(void);
58 58
59struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 59struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
60 unsigned long, 60 unsigned long,
61 void (*)(struct kmem_cache *, void *)); 61 void (*)(void *));
62void kmem_cache_destroy(struct kmem_cache *); 62void kmem_cache_destroy(struct kmem_cache *);
63int kmem_cache_shrink(struct kmem_cache *); 63int kmem_cache_shrink(struct kmem_cache *);
64void kmem_cache_free(struct kmem_cache *, void *); 64void kmem_cache_free(struct kmem_cache *, void *);
@@ -96,6 +96,7 @@ int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
96/* 96/*
97 * Common kmalloc functions provided by all allocators 97 * Common kmalloc functions provided by all allocators
98 */ 98 */
99void * __must_check __krealloc(const void *, size_t, gfp_t);
99void * __must_check krealloc(const void *, size_t, gfp_t); 100void * __must_check krealloc(const void *, size_t, gfp_t);
100void kfree(const void *); 101void kfree(const void *);
101size_t ksize(const void *); 102size_t ksize(const void *);
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index d117ea2825a9..5bad61a93f65 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -85,7 +85,7 @@ struct kmem_cache {
85 struct kmem_cache_order_objects min; 85 struct kmem_cache_order_objects min;
86 gfp_t allocflags; /* gfp flags to use on each alloc */ 86 gfp_t allocflags; /* gfp flags to use on each alloc */
87 int refcount; /* Refcount for slab cache destroy */ 87 int refcount; /* Refcount for slab cache destroy */
88 void (*ctor)(struct kmem_cache *, void *); 88 void (*ctor)(void *);
89 int inuse; /* Offset to metadata */ 89 int inuse; /* Offset to metadata */
90 int align; /* Alignment */ 90 int align; /* Alignment */
91 const char *name; /* Name (only for display!) */ 91 const char *name; /* Name (only for display!) */
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 48262f86c969..66484d4a8459 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -74,15 +74,10 @@ void __smp_call_function_single(int cpuid, struct call_single_data *data);
74#ifdef CONFIG_USE_GENERIC_SMP_HELPERS 74#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
75void generic_smp_call_function_single_interrupt(void); 75void generic_smp_call_function_single_interrupt(void);
76void generic_smp_call_function_interrupt(void); 76void generic_smp_call_function_interrupt(void);
77void init_call_single_data(void);
78void ipi_call_lock(void); 77void ipi_call_lock(void);
79void ipi_call_unlock(void); 78void ipi_call_unlock(void);
80void ipi_call_lock_irq(void); 79void ipi_call_lock_irq(void);
81void ipi_call_unlock_irq(void); 80void ipi_call_unlock_irq(void);
82#else
83static inline void init_call_single_data(void)
84{
85}
86#endif 81#endif
87 82
88/* 83/*
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 950af631e7fb..dc5086fe7736 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -189,7 +189,8 @@ struct ucred {
189#define AF_BLUETOOTH 31 /* Bluetooth sockets */ 189#define AF_BLUETOOTH 31 /* Bluetooth sockets */
190#define AF_IUCV 32 /* IUCV sockets */ 190#define AF_IUCV 32 /* IUCV sockets */
191#define AF_RXRPC 33 /* RxRPC sockets */ 191#define AF_RXRPC 33 /* RxRPC sockets */
192#define AF_MAX 34 /* For now.. */ 192#define AF_ISDN 34 /* mISDN sockets */
193#define AF_MAX 35 /* For now.. */
193 194
194/* Protocol families, same as address families. */ 195/* Protocol families, same as address families. */
195#define PF_UNSPEC AF_UNSPEC 196#define PF_UNSPEC AF_UNSPEC
@@ -225,6 +226,7 @@ struct ucred {
225#define PF_BLUETOOTH AF_BLUETOOTH 226#define PF_BLUETOOTH AF_BLUETOOTH
226#define PF_IUCV AF_IUCV 227#define PF_IUCV AF_IUCV
227#define PF_RXRPC AF_RXRPC 228#define PF_RXRPC AF_RXRPC
229#define PF_ISDN AF_ISDN
228#define PF_MAX AF_MAX 230#define PF_MAX AF_MAX
229 231
230/* Maximum queue length specifiable by listen. */ 232/* Maximum queue length specifiable by listen. */
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index a9cc29d46653..4be01bb44377 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -778,8 +778,20 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
778 * use spi_new_device() to describe each device. You can also call 778 * use spi_new_device() to describe each device. You can also call
779 * spi_unregister_device() to start making that device vanish, but 779 * spi_unregister_device() to start making that device vanish, but
780 * normally that would be handled by spi_unregister_master(). 780 * normally that would be handled by spi_unregister_master().
781 *
782 * You can also use spi_alloc_device() and spi_add_device() to use a two
783 * stage registration sequence for each spi_device. This gives the caller
784 * some more control over the spi_device structure before it is registered,
785 * but requires that caller to initialize fields that would otherwise
786 * be defined using the board info.
781 */ 787 */
782extern struct spi_device * 788extern struct spi_device *
789spi_alloc_device(struct spi_master *master);
790
791extern int
792spi_add_device(struct spi_device *spi);
793
794extern struct spi_device *
783spi_new_device(struct spi_master *, struct spi_board_info *); 795spi_new_device(struct spi_master *, struct spi_board_info *);
784 796
785static inline void 797static inline void
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 4bf8cade9dbc..e530026eedf7 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -427,9 +427,9 @@ static inline int ssb_dma_mapping_error(struct ssb_device *dev, dma_addr_t addr)
427{ 427{
428 switch (dev->bus->bustype) { 428 switch (dev->bus->bustype) {
429 case SSB_BUSTYPE_PCI: 429 case SSB_BUSTYPE_PCI:
430 return pci_dma_mapping_error(addr); 430 return pci_dma_mapping_error(dev->bus->host_pci, addr);
431 case SSB_BUSTYPE_SSB: 431 case SSB_BUSTYPE_SSB:
432 return dma_mapping_error(addr); 432 return dma_mapping_error(dev->dev, addr);
433 default: 433 default:
434 __ssb_dma_not_implemented(dev); 434 __ssb_dma_not_implemented(dev);
435 } 435 }
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 5bfc553bdb21..f1cb0ba6d715 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -5,41 +5,43 @@
5 (and more). So the "read" side to such a lock is anything which 5 (and more). So the "read" side to such a lock is anything which
6 diables preeempt. */ 6 diables preeempt. */
7#include <linux/cpu.h> 7#include <linux/cpu.h>
8#include <linux/cpumask.h>
8#include <asm/system.h> 9#include <asm/system.h>
9 10
10#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP) 11#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
12
13/* Deprecated, but useful for transition. */
14#define ALL_CPUS ~0U
15
11/** 16/**
12 * stop_machine_run: freeze the machine on all CPUs and run this function 17 * stop_machine: freeze the machine on all CPUs and run this function
13 * @fn: the function to run 18 * @fn: the function to run
14 * @data: the data ptr for the @fn() 19 * @data: the data ptr for the @fn()
15 * @cpu: the cpu to run @fn() on (or any, if @cpu == NR_CPUS. 20 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
16 * 21 *
17 * Description: This causes a thread to be scheduled on every other cpu, 22 * Description: This causes a thread to be scheduled on every cpu,
18 * each of which disables interrupts, and finally interrupts are disabled 23 * each of which disables interrupts. The result is that noone is
19 * on the current CPU. The result is that noone is holding a spinlock 24 * holding a spinlock or inside any other preempt-disabled region when
20 * or inside any other preempt-disabled region when @fn() runs. 25 * @fn() runs.
21 * 26 *
22 * This can be thought of as a very heavy write lock, equivalent to 27 * This can be thought of as a very heavy write lock, equivalent to
23 * grabbing every spinlock in the kernel. */ 28 * grabbing every spinlock in the kernel. */
24int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu); 29int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
25 30
26/** 31/**
27 * __stop_machine_run: freeze the machine on all CPUs and run this function 32 * __stop_machine: freeze the machine on all CPUs and run this function
28 * @fn: the function to run 33 * @fn: the function to run
29 * @data: the data ptr for the @fn 34 * @data: the data ptr for the @fn
30 * @cpu: the cpu to run @fn on (or any, if @cpu == NR_CPUS. 35 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
31 * 36 *
32 * Description: This is a special version of the above, which returns the 37 * Description: This is a special version of the above, which assumes cpus
33 * thread which has run @fn(): kthread_stop will return the return value 38 * won't come or go while it's being called. Used by hotplug cpu.
34 * of @fn(). Used by hotplug cpu.
35 */ 39 */
36struct task_struct *__stop_machine_run(int (*fn)(void *), void *data, 40int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
37 unsigned int cpu);
38
39#else 41#else
40 42
41static inline int stop_machine_run(int (*fn)(void *), void *data, 43static inline int stop_machine(int (*fn)(void *), void *data,
42 unsigned int cpu) 44 const cpumask_t *cpus)
43{ 45{
44 int ret; 46 int ret;
45 local_irq_disable(); 47 local_irq_disable();
@@ -48,4 +50,18 @@ static inline int stop_machine_run(int (*fn)(void *), void *data,
48 return ret; 50 return ret;
49} 51}
50#endif /* CONFIG_SMP */ 52#endif /* CONFIG_SMP */
53
54static inline int __deprecated stop_machine_run(int (*fn)(void *), void *data,
55 unsigned int cpu)
56{
57 /* If they don't care which cpu fn runs on, just pick one. */
58 if (cpu == NR_CPUS)
59 return stop_machine(fn, data, NULL);
60 else if (cpu == ~0U)
61 return stop_machine(fn, data, &cpu_possible_map);
62 else {
63 cpumask_t cpus = cpumask_of_cpu(cpu);
64 return stop_machine(fn, data, &cpus);
65 }
66}
51#endif /* _LINUX_STOP_MACHINE */ 67#endif /* _LINUX_STOP_MACHINE */
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index e8e69159af71..c63435095970 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -278,4 +278,6 @@ static inline void register_nosave_region_late(unsigned long b, unsigned long e)
278} 278}
279#endif 279#endif
280 280
281extern struct mutex pm_mutex;
282
281#endif /* _LINUX_SUSPEND_H */ 283#endif /* _LINUX_SUSPEND_H */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 0b3377650c85..de40f169a4e4 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -237,7 +237,6 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
237 237
238/* linux/mm/swapfile.c */ 238/* linux/mm/swapfile.c */
239extern long total_swap_pages; 239extern long total_swap_pages;
240extern unsigned int nr_swapfiles;
241extern void si_swapinfo(struct sysinfo *); 240extern void si_swapinfo(struct sysinfo *);
242extern swp_entry_t get_swap_page(void); 241extern swp_entry_t get_swap_page(void);
243extern swp_entry_t get_swap_page_of_type(int); 242extern swp_entry_t get_swap_page_of_type(int);
@@ -254,8 +253,6 @@ extern int can_share_swap_page(struct page *);
254extern int remove_exclusive_swap_page(struct page *); 253extern int remove_exclusive_swap_page(struct page *);
255struct backing_dev_info; 254struct backing_dev_info;
256 255
257extern spinlock_t swap_lock;
258
259/* linux/mm/thrash.c */ 256/* linux/mm/thrash.c */
260extern struct mm_struct * swap_token_mm; 257extern struct mm_struct * swap_token_mm;
261extern void grab_swap_token(void); 258extern void grab_swap_token(void);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 24141b4d1a11..d0437f36921f 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -947,6 +947,22 @@ struct ctl_table;
947struct nsproxy; 947struct nsproxy;
948struct ctl_table_root; 948struct ctl_table_root;
949 949
950struct ctl_table_set {
951 struct list_head list;
952 struct ctl_table_set *parent;
953 int (*is_seen)(struct ctl_table_set *);
954};
955
956extern void setup_sysctl_set(struct ctl_table_set *p,
957 struct ctl_table_set *parent,
958 int (*is_seen)(struct ctl_table_set *));
959
960struct ctl_table_header;
961
962extern void sysctl_head_get(struct ctl_table_header *);
963extern void sysctl_head_put(struct ctl_table_header *);
964extern int sysctl_is_seen(struct ctl_table_header *);
965extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);
950extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); 966extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
951extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 967extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
952 struct ctl_table_header *prev); 968 struct ctl_table_header *prev);
@@ -1049,8 +1065,8 @@ struct ctl_table
1049 1065
1050struct ctl_table_root { 1066struct ctl_table_root {
1051 struct list_head root_list; 1067 struct list_head root_list;
1052 struct list_head header_list; 1068 struct ctl_table_set default_set;
1053 struct list_head *(*lookup)(struct ctl_table_root *root, 1069 struct ctl_table_set *(*lookup)(struct ctl_table_root *root,
1054 struct nsproxy *namespaces); 1070 struct nsproxy *namespaces);
1055 int (*permissions)(struct ctl_table_root *root, 1071 int (*permissions)(struct ctl_table_root *root,
1056 struct nsproxy *namespaces, struct ctl_table *table); 1072 struct nsproxy *namespaces, struct ctl_table *table);
@@ -1063,9 +1079,14 @@ struct ctl_table_header
1063 struct ctl_table *ctl_table; 1079 struct ctl_table *ctl_table;
1064 struct list_head ctl_entry; 1080 struct list_head ctl_entry;
1065 int used; 1081 int used;
1082 int count;
1066 struct completion *unregistering; 1083 struct completion *unregistering;
1067 struct ctl_table *ctl_table_arg; 1084 struct ctl_table *ctl_table_arg;
1068 struct ctl_table_root *root; 1085 struct ctl_table_root *root;
1086 struct ctl_table_set *set;
1087 struct ctl_table *attached_by;
1088 struct ctl_table *attached_to;
1089 struct ctl_table_header *parent;
1069}; 1090};
1070 1091
1071/* struct ctl_path describes where in the hierarchy a table is added */ 1092/* struct ctl_path describes where in the hierarchy a table is added */
diff --git a/include/linux/task_io_accounting.h b/include/linux/task_io_accounting.h
index 44d00e9cceea..5e88afc9a2fb 100644
--- a/include/linux/task_io_accounting.h
+++ b/include/linux/task_io_accounting.h
@@ -8,8 +8,19 @@
8 * Blame akpm@osdl.org for all this. 8 * Blame akpm@osdl.org for all this.
9 */ 9 */
10 10
11#ifdef CONFIG_TASK_IO_ACCOUNTING
12struct task_io_accounting { 11struct task_io_accounting {
12#ifdef CONFIG_TASK_XACCT
13 /* bytes read */
14 u64 rchar;
15 /* bytes written */
16 u64 wchar;
17 /* # of read syscalls */
18 u64 syscr;
19 /* # of write syscalls */
20 u64 syscw;
21#endif /* CONFIG_TASK_XACCT */
22
23#ifdef CONFIG_TASK_IO_ACCOUNTING
13 /* 24 /*
14 * The number of bytes which this task has caused to be read from 25 * The number of bytes which this task has caused to be read from
15 * storage. 26 * storage.
@@ -30,8 +41,5 @@ struct task_io_accounting {
30 * information loss in doing that. 41 * information loss in doing that.
31 */ 42 */
32 u64 cancelled_write_bytes; 43 u64 cancelled_write_bytes;
44#endif /* CONFIG_TASK_IO_ACCOUNTING */
33}; 45};
34#else
35struct task_io_accounting {
36};
37#endif
diff --git a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
index ff46c6fad79d..4d090f9ee608 100644
--- a/include/linux/task_io_accounting_ops.h
+++ b/include/linux/task_io_accounting_ops.h
@@ -40,9 +40,17 @@ static inline void task_io_account_cancelled_write(size_t bytes)
40 current->ioac.cancelled_write_bytes += bytes; 40 current->ioac.cancelled_write_bytes += bytes;
41} 41}
42 42
43static inline void task_io_accounting_init(struct task_struct *tsk) 43static inline void task_io_accounting_init(struct task_io_accounting *ioac)
44{ 44{
45 memset(&tsk->ioac, 0, sizeof(tsk->ioac)); 45 memset(ioac, 0, sizeof(*ioac));
46}
47
48static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
49 struct task_io_accounting *src)
50{
51 dst->read_bytes += src->read_bytes;
52 dst->write_bytes += src->write_bytes;
53 dst->cancelled_write_bytes += src->cancelled_write_bytes;
46} 54}
47 55
48#else 56#else
@@ -69,9 +77,37 @@ static inline void task_io_account_cancelled_write(size_t bytes)
69{ 77{
70} 78}
71 79
72static inline void task_io_accounting_init(struct task_struct *tsk) 80static inline void task_io_accounting_init(struct task_io_accounting *ioac)
81{
82}
83
84static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
85 struct task_io_accounting *src)
73{ 86{
74} 87}
75 88
76#endif /* CONFIG_TASK_IO_ACCOUNTING */ 89#endif /* CONFIG_TASK_IO_ACCOUNTING */
77#endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */ 90
91#ifdef CONFIG_TASK_XACCT
92static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
93 struct task_io_accounting *src)
94{
95 dst->rchar += src->rchar;
96 dst->wchar += src->wchar;
97 dst->syscr += src->syscr;
98 dst->syscw += src->syscw;
99}
100#else
101static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
102 struct task_io_accounting *src)
103{
104}
105#endif /* CONFIG_TASK_XACCT */
106
107static inline void task_io_accounting_add(struct task_io_accounting *dst,
108 struct task_io_accounting *src)
109{
110 task_chr_io_accounting_add(dst, src);
111 task_blk_io_accounting_add(dst, src);
112}
113#endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
new file mode 100644
index 000000000000..b1875582c1a1
--- /dev/null
+++ b/include/linux/tracehook.h
@@ -0,0 +1,576 @@
1/*
2 * Tracing hooks
3 *
4 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
9 *
10 * This file defines hook entry points called by core code where
11 * user tracing/debugging support might need to do something. These
12 * entry points are called tracehook_*(). Each hook declared below
13 * has a detailed kerneldoc comment giving the context (locking et
14 * al) from which it is called, and the meaning of its return value.
15 *
16 * Each function here typically has only one call site, so it is ok
17 * to have some nontrivial tracehook_*() inlines. In all cases, the
18 * fast path when no tracing is enabled should be very short.
19 *
20 * The purpose of this file and the tracehook_* layer is to consolidate
21 * the interface that the kernel core and arch code uses to enable any
22 * user debugging or tracing facility (such as ptrace). The interfaces
23 * here are carefully documented so that maintainers of core and arch
24 * code do not need to think about the implementation details of the
25 * tracing facilities. Likewise, maintainers of the tracing code do not
26 * need to understand all the calling core or arch code in detail, just
27 * documented circumstances of each call, such as locking conditions.
28 *
29 * If the calling core code changes so that locking is different, then
30 * it is ok to change the interface documented here. The maintainer of
31 * core code changing should notify the maintainers of the tracing code
32 * that they need to work out the change.
33 *
34 * Some tracehook_*() inlines take arguments that the current tracing
35 * implementations might not necessarily use. These function signatures
36 * are chosen to pass in all the information that is on hand in the
37 * caller and might conceivably be relevant to a tracer, so that the
38 * core code won't have to be updated when tracing adds more features.
39 * If a call site changes so that some of those parameters are no longer
40 * already on hand without extra work, then the tracehook_* interface
41 * can change so there is no make-work burden on the core code. The
42 * maintainer of core code changing should notify the maintainers of the
43 * tracing code that they need to work out the change.
44 */
45
46#ifndef _LINUX_TRACEHOOK_H
47#define _LINUX_TRACEHOOK_H 1
48
49#include <linux/sched.h>
50#include <linux/ptrace.h>
51#include <linux/security.h>
52struct linux_binprm;
53
54/**
55 * tracehook_expect_breakpoints - guess if task memory might be touched
56 * @task: current task, making a new mapping
57 *
58 * Return nonzero if @task is expected to want breakpoint insertion in
59 * its memory at some point. A zero return is no guarantee it won't
60 * be done, but this is a hint that it's known to be likely.
61 *
62 * May be called with @task->mm->mmap_sem held for writing.
63 */
64static inline int tracehook_expect_breakpoints(struct task_struct *task)
65{
66 return (task_ptrace(task) & PT_PTRACED) != 0;
67}
68
69/*
70 * ptrace report for syscall entry and exit looks identical.
71 */
72static inline void ptrace_report_syscall(struct pt_regs *regs)
73{
74 int ptrace = task_ptrace(current);
75
76 if (!(ptrace & PT_PTRACED))
77 return;
78
79 ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
80
81 /*
82 * this isn't the same as continuing with a signal, but it will do
83 * for normal use. strace only continues with a signal if the
84 * stopping signal is not SIGTRAP. -brl
85 */
86 if (current->exit_code) {
87 send_sig(current->exit_code, current, 1);
88 current->exit_code = 0;
89 }
90}
91
92/**
93 * tracehook_report_syscall_entry - task is about to attempt a system call
94 * @regs: user register state of current task
95 *
96 * This will be called if %TIF_SYSCALL_TRACE has been set, when the
97 * current task has just entered the kernel for a system call.
98 * Full user register state is available here. Changing the values
99 * in @regs can affect the system call number and arguments to be tried.
100 * It is safe to block here, preventing the system call from beginning.
101 *
102 * Returns zero normally, or nonzero if the calling arch code should abort
103 * the system call. That must prevent normal entry so no system call is
104 * made. If @task ever returns to user mode after this, its register state
105 * is unspecified, but should be something harmless like an %ENOSYS error
106 * return. It should preserve enough information so that syscall_rollback()
107 * can work (see asm-generic/syscall.h).
108 *
109 * Called without locks, just after entering kernel mode.
110 */
111static inline __must_check int tracehook_report_syscall_entry(
112 struct pt_regs *regs)
113{
114 ptrace_report_syscall(regs);
115 return 0;
116}
117
118/**
119 * tracehook_report_syscall_exit - task has just finished a system call
120 * @regs: user register state of current task
121 * @step: nonzero if simulating single-step or block-step
122 *
123 * This will be called if %TIF_SYSCALL_TRACE has been set, when the
124 * current task has just finished an attempted system call. Full
125 * user register state is available here. It is safe to block here,
126 * preventing signals from being processed.
127 *
128 * If @step is nonzero, this report is also in lieu of the normal
129 * trap that would follow the system call instruction because
130 * user_enable_block_step() or user_enable_single_step() was used.
131 * In this case, %TIF_SYSCALL_TRACE might not be set.
132 *
133 * Called without locks, just before checking for pending signals.
134 */
135static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
136{
137 ptrace_report_syscall(regs);
138}
139
140/**
141 * tracehook_unsafe_exec - check for exec declared unsafe due to tracing
142 * @task: current task doing exec
143 *
144 * Return %LSM_UNSAFE_* bits applied to an exec because of tracing.
145 *
146 * Called with task_lock() held on @task.
147 */
148static inline int tracehook_unsafe_exec(struct task_struct *task)
149{
150 int unsafe = 0;
151 int ptrace = task_ptrace(task);
152 if (ptrace & PT_PTRACED) {
153 if (ptrace & PT_PTRACE_CAP)
154 unsafe |= LSM_UNSAFE_PTRACE_CAP;
155 else
156 unsafe |= LSM_UNSAFE_PTRACE;
157 }
158 return unsafe;
159}
160
161/**
162 * tracehook_tracer_task - return the task that is tracing the given task
163 * @tsk: task to consider
164 *
165 * Returns NULL if noone is tracing @task, or the &struct task_struct
166 * pointer to its tracer.
167 *
168 * Must called under rcu_read_lock(). The pointer returned might be kept
169 * live only by RCU. During exec, this may be called with task_lock()
170 * held on @task, still held from when tracehook_unsafe_exec() was called.
171 */
172static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk)
173{
174 if (task_ptrace(tsk) & PT_PTRACED)
175 return rcu_dereference(tsk->parent);
176 return NULL;
177}
178
179/**
180 * tracehook_report_exec - a successful exec was completed
181 * @fmt: &struct linux_binfmt that performed the exec
182 * @bprm: &struct linux_binprm containing exec details
183 * @regs: user-mode register state
184 *
185 * An exec just completed, we are shortly going to return to user mode.
186 * The freshly initialized register state can be seen and changed in @regs.
187 * The name, file and other pointers in @bprm are still on hand to be
188 * inspected, but will be freed as soon as this returns.
189 *
190 * Called with no locks, but with some kernel resources held live
191 * and a reference on @fmt->module.
192 */
193static inline void tracehook_report_exec(struct linux_binfmt *fmt,
194 struct linux_binprm *bprm,
195 struct pt_regs *regs)
196{
197 if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) &&
198 unlikely(task_ptrace(current) & PT_PTRACED))
199 send_sig(SIGTRAP, current, 0);
200}
201
202/**
203 * tracehook_report_exit - task has begun to exit
204 * @exit_code: pointer to value destined for @current->exit_code
205 *
206 * @exit_code points to the value passed to do_exit(), which tracing
207 * might change here. This is almost the first thing in do_exit(),
208 * before freeing any resources or setting the %PF_EXITING flag.
209 *
210 * Called with no locks held.
211 */
212static inline void tracehook_report_exit(long *exit_code)
213{
214 ptrace_event(PT_TRACE_EXIT, PTRACE_EVENT_EXIT, *exit_code);
215}
216
217/**
218 * tracehook_prepare_clone - prepare for new child to be cloned
219 * @clone_flags: %CLONE_* flags from clone/fork/vfork system call
220 *
221 * This is called before a new user task is to be cloned.
222 * Its return value will be passed to tracehook_finish_clone().
223 *
224 * Called with no locks held.
225 */
226static inline int tracehook_prepare_clone(unsigned clone_flags)
227{
228 if (clone_flags & CLONE_UNTRACED)
229 return 0;
230
231 if (clone_flags & CLONE_VFORK) {
232 if (current->ptrace & PT_TRACE_VFORK)
233 return PTRACE_EVENT_VFORK;
234 } else if ((clone_flags & CSIGNAL) != SIGCHLD) {
235 if (current->ptrace & PT_TRACE_CLONE)
236 return PTRACE_EVENT_CLONE;
237 } else if (current->ptrace & PT_TRACE_FORK)
238 return PTRACE_EVENT_FORK;
239
240 return 0;
241}
242
243/**
244 * tracehook_finish_clone - new child created and being attached
245 * @child: new child task
246 * @clone_flags: %CLONE_* flags from clone/fork/vfork system call
247 * @trace: return value from tracehook_prepare_clone()
248 *
249 * This is called immediately after adding @child to its parent's children list.
250 * The @trace value is that returned by tracehook_prepare_clone().
251 *
252 * Called with current's siglock and write_lock_irq(&tasklist_lock) held.
253 */
254static inline void tracehook_finish_clone(struct task_struct *child,
255 unsigned long clone_flags, int trace)
256{
257 ptrace_init_task(child, (clone_flags & CLONE_PTRACE) || trace);
258}
259
260/**
261 * tracehook_report_clone - in parent, new child is about to start running
262 * @trace: return value from tracehook_prepare_clone()
263 * @regs: parent's user register state
264 * @clone_flags: flags from parent's system call
265 * @pid: new child's PID in the parent's namespace
266 * @child: new child task
267 *
268 * Called after a child is set up, but before it has been started
269 * running. @trace is the value returned by tracehook_prepare_clone().
270 * This is not a good place to block, because the child has not started
271 * yet. Suspend the child here if desired, and then block in
272 * tracehook_report_clone_complete(). This must prevent the child from
273 * self-reaping if tracehook_report_clone_complete() uses the @child
274 * pointer; otherwise it might have died and been released by the time
275 * tracehook_report_report_clone_complete() is called.
276 *
277 * Called with no locks held, but the child cannot run until this returns.
278 */
279static inline void tracehook_report_clone(int trace, struct pt_regs *regs,
280 unsigned long clone_flags,
281 pid_t pid, struct task_struct *child)
282{
283 if (unlikely(trace)) {
284 /*
285 * The child starts up with an immediate SIGSTOP.
286 */
287 sigaddset(&child->pending.signal, SIGSTOP);
288 set_tsk_thread_flag(child, TIF_SIGPENDING);
289 }
290}
291
292/**
293 * tracehook_report_clone_complete - new child is running
294 * @trace: return value from tracehook_prepare_clone()
295 * @regs: parent's user register state
296 * @clone_flags: flags from parent's system call
297 * @pid: new child's PID in the parent's namespace
298 * @child: child task, already running
299 *
300 * This is called just after the child has started running. This is
301 * just before the clone/fork syscall returns, or blocks for vfork
302 * child completion if @clone_flags has the %CLONE_VFORK bit set.
303 * The @child pointer may be invalid if a self-reaping child died and
304 * tracehook_report_clone() took no action to prevent it from self-reaping.
305 *
306 * Called with no locks held.
307 */
308static inline void tracehook_report_clone_complete(int trace,
309 struct pt_regs *regs,
310 unsigned long clone_flags,
311 pid_t pid,
312 struct task_struct *child)
313{
314 if (unlikely(trace))
315 ptrace_event(0, trace, pid);
316}
317
318/**
319 * tracehook_report_vfork_done - vfork parent's child has exited or exec'd
320 * @child: child task, already running
321 * @pid: new child's PID in the parent's namespace
322 *
323 * Called after a %CLONE_VFORK parent has waited for the child to complete.
324 * The clone/vfork system call will return immediately after this.
325 * The @child pointer may be invalid if a self-reaping child died and
326 * tracehook_report_clone() took no action to prevent it from self-reaping.
327 *
328 * Called with no locks held.
329 */
330static inline void tracehook_report_vfork_done(struct task_struct *child,
331 pid_t pid)
332{
333 ptrace_event(PT_TRACE_VFORK_DONE, PTRACE_EVENT_VFORK_DONE, pid);
334}
335
336/**
337 * tracehook_prepare_release_task - task is being reaped, clean up tracing
338 * @task: task in %EXIT_DEAD state
339 *
340 * This is called in release_task() just before @task gets finally reaped
341 * and freed. This would be the ideal place to remove and clean up any
342 * tracing-related state for @task.
343 *
344 * Called with no locks held.
345 */
346static inline void tracehook_prepare_release_task(struct task_struct *task)
347{
348}
349
350/**
351 * tracehook_finish_release_task - final tracing clean-up
352 * @task: task in %EXIT_DEAD state
353 *
354 * This is called in release_task() when @task is being in the middle of
355 * being reaped. After this, there must be no tracing entanglements.
356 *
357 * Called with write_lock_irq(&tasklist_lock) held.
358 */
359static inline void tracehook_finish_release_task(struct task_struct *task)
360{
361 ptrace_release_task(task);
362}
363
364/**
365 * tracehook_signal_handler - signal handler setup is complete
366 * @sig: number of signal being delivered
367 * @info: siginfo_t of signal being delivered
368 * @ka: sigaction setting that chose the handler
369 * @regs: user register state
370 * @stepping: nonzero if debugger single-step or block-step in use
371 *
372 * Called by the arch code after a signal handler has been set up.
373 * Register and stack state reflects the user handler about to run.
374 * Signal mask changes have already been made.
375 *
376 * Called without locks, shortly before returning to user mode
377 * (or handling more signals).
378 */
379static inline void tracehook_signal_handler(int sig, siginfo_t *info,
380 const struct k_sigaction *ka,
381 struct pt_regs *regs, int stepping)
382{
383 if (stepping)
384 ptrace_notify(SIGTRAP);
385}
386
387/**
388 * tracehook_consider_ignored_signal - suppress short-circuit of ignored signal
389 * @task: task receiving the signal
390 * @sig: signal number being sent
391 * @handler: %SIG_IGN or %SIG_DFL
392 *
393 * Return zero iff tracing doesn't care to examine this ignored signal,
394 * so it can short-circuit normal delivery and never even get queued.
395 * Either @handler is %SIG_DFL and @sig's default is ignore, or it's %SIG_IGN.
396 *
397 * Called with @task->sighand->siglock held.
398 */
399static inline int tracehook_consider_ignored_signal(struct task_struct *task,
400 int sig,
401 void __user *handler)
402{
403 return (task_ptrace(task) & PT_PTRACED) != 0;
404}
405
406/**
407 * tracehook_consider_fatal_signal - suppress special handling of fatal signal
408 * @task: task receiving the signal
409 * @sig: signal number being sent
410 * @handler: %SIG_DFL or %SIG_IGN
411 *
412 * Return nonzero to prevent special handling of this termination signal.
413 * Normally @handler is %SIG_DFL. It can be %SIG_IGN if @sig is ignored,
414 * in which case force_sig() is about to reset it to %SIG_DFL.
415 * When this returns zero, this signal might cause a quick termination
416 * that does not give the debugger a chance to intercept the signal.
417 *
418 * Called with or without @task->sighand->siglock held.
419 */
420static inline int tracehook_consider_fatal_signal(struct task_struct *task,
421 int sig,
422 void __user *handler)
423{
424 return (task_ptrace(task) & PT_PTRACED) != 0;
425}
426
427/**
428 * tracehook_force_sigpending - let tracing force signal_pending(current) on
429 *
430 * Called when recomputing our signal_pending() flag. Return nonzero
431 * to force the signal_pending() flag on, so that tracehook_get_signal()
432 * will be called before the next return to user mode.
433 *
434 * Called with @current->sighand->siglock held.
435 */
436static inline int tracehook_force_sigpending(void)
437{
438 return 0;
439}
440
441/**
442 * tracehook_get_signal - deliver synthetic signal to traced task
443 * @task: @current
444 * @regs: task_pt_regs(@current)
445 * @info: details of synthetic signal
446 * @return_ka: sigaction for synthetic signal
447 *
448 * Return zero to check for a real pending signal normally.
449 * Return -1 after releasing the siglock to repeat the check.
450 * Return a signal number to induce an artifical signal delivery,
451 * setting *@info and *@return_ka to specify its details and behavior.
452 *
453 * The @return_ka->sa_handler value controls the disposition of the
454 * signal, no matter the signal number. For %SIG_DFL, the return value
455 * is a representative signal to indicate the behavior (e.g. %SIGTERM
456 * for death, %SIGQUIT for core dump, %SIGSTOP for job control stop,
457 * %SIGTSTP for stop unless in an orphaned pgrp), but the signal number
458 * reported will be @info->si_signo instead.
459 *
460 * Called with @task->sighand->siglock held, before dequeuing pending signals.
461 */
462static inline int tracehook_get_signal(struct task_struct *task,
463 struct pt_regs *regs,
464 siginfo_t *info,
465 struct k_sigaction *return_ka)
466{
467 return 0;
468}
469
470/**
471 * tracehook_notify_jctl - report about job control stop/continue
472 * @notify: nonzero if this is the last thread in the group to stop
473 * @why: %CLD_STOPPED or %CLD_CONTINUED
474 *
475 * This is called when we might call do_notify_parent_cldstop().
476 * It's called when about to stop for job control; we are already in
477 * %TASK_STOPPED state, about to call schedule(). It's also called when
478 * a delayed %CLD_STOPPED or %CLD_CONTINUED report is ready to be made.
479 *
480 * Return nonzero to generate a %SIGCHLD with @why, which is
481 * normal if @notify is nonzero.
482 *
483 * Called with no locks held.
484 */
485static inline int tracehook_notify_jctl(int notify, int why)
486{
487 return notify || (current->ptrace & PT_PTRACED);
488}
489
490/**
491 * tracehook_notify_death - task is dead, ready to notify parent
492 * @task: @current task now exiting
493 * @death_cookie: value to pass to tracehook_report_death()
494 * @group_dead: nonzero if this was the last thread in the group to die
495 *
496 * Return the signal number to send our parent with do_notify_parent(), or
497 * zero to send no signal and leave a zombie, or -1 to self-reap right now.
498 *
499 * Called with write_lock_irq(&tasklist_lock) held.
500 */
501static inline int tracehook_notify_death(struct task_struct *task,
502 void **death_cookie, int group_dead)
503{
504 if (task->exit_signal == -1)
505 return task->ptrace ? SIGCHLD : -1;
506
507 /*
508 * If something other than our normal parent is ptracing us, then
509 * send it a SIGCHLD instead of honoring exit_signal. exit_signal
510 * only has special meaning to our real parent.
511 */
512 if (thread_group_empty(task) && !ptrace_reparented(task))
513 return task->exit_signal;
514
515 return task->ptrace ? SIGCHLD : 0;
516}
517
518/**
519 * tracehook_report_death - task is dead and ready to be reaped
520 * @task: @current task now exiting
521 * @signal: signal number sent to parent, or 0 or -1
522 * @death_cookie: value passed back from tracehook_notify_death()
523 * @group_dead: nonzero if this was the last thread in the group to die
524 *
525 * Thread has just become a zombie or is about to self-reap. If positive,
526 * @signal is the signal number just sent to the parent (usually %SIGCHLD).
527 * If @signal is -1, this thread will self-reap. If @signal is 0, this is
528 * a delayed_group_leader() zombie. The @death_cookie was passed back by
529 * tracehook_notify_death().
530 *
531 * If normal reaping is not inhibited, @task->exit_state might be changing
532 * in parallel.
533 *
534 * Called without locks.
535 */
536static inline void tracehook_report_death(struct task_struct *task,
537 int signal, void *death_cookie,
538 int group_dead)
539{
540}
541
542#ifdef TIF_NOTIFY_RESUME
543/**
544 * set_notify_resume - cause tracehook_notify_resume() to be called
545 * @task: task that will call tracehook_notify_resume()
546 *
547 * Calling this arranges that @task will call tracehook_notify_resume()
548 * before returning to user mode. If it's already running in user mode,
549 * it will enter the kernel and call tracehook_notify_resume() soon.
550 * If it's blocked, it will not be woken.
551 */
552static inline void set_notify_resume(struct task_struct *task)
553{
554 if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
555 kick_process(task);
556}
557
558/**
559 * tracehook_notify_resume - report when about to return to user mode
560 * @regs: user-mode registers of @current task
561 *
562 * This is called when %TIF_NOTIFY_RESUME has been set. Now we are
563 * about to return to user mode, and the user state in @regs can be
564 * inspected or adjusted. The caller in arch code has cleared
565 * %TIF_NOTIFY_RESUME before the call. If the flag gets set again
566 * asynchronously, this will be called again before we return to
567 * user mode.
568 *
569 * Called without locks.
570 */
571static inline void tracehook_notify_resume(struct pt_regs *regs)
572{
573}
574#endif /* TIF_NOTIFY_RESUME */
575
576#endif /* <linux/tracehook.h> */
diff --git a/include/linux/videodev.h b/include/linux/videodev.h
index 9385a566aed8..15a653d41132 100644
--- a/include/linux/videodev.h
+++ b/include/linux/videodev.h
@@ -17,6 +17,21 @@
17 17
18#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__) 18#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__)
19 19
20#define VID_TYPE_CAPTURE 1 /* Can capture */
21#define VID_TYPE_TUNER 2 /* Can tune */
22#define VID_TYPE_TELETEXT 4 /* Does teletext */
23#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
24#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
25#define VID_TYPE_CLIPPING 32 /* Can clip */
26#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
27#define VID_TYPE_SCALES 128 /* Scalable */
28#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
29#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
30#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
31#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
32#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
33#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
34
20struct video_capability 35struct video_capability
21{ 36{
22 char name[32]; 37 char name[32];
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 2e66a95e8d32..e466bd54a50e 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -71,6 +71,11 @@
71 */ 71 */
72#define VIDEO_MAX_FRAME 32 72#define VIDEO_MAX_FRAME 32
73 73
74#ifndef __KERNEL__
75
76/* These defines are V4L1 specific and should not be used with the V4L2 API!
77 They will be removed from this header in the future. */
78
74#define VID_TYPE_CAPTURE 1 /* Can capture */ 79#define VID_TYPE_CAPTURE 1 /* Can capture */
75#define VID_TYPE_TUNER 2 /* Can tune */ 80#define VID_TYPE_TUNER 2 /* Can tune */
76#define VID_TYPE_TELETEXT 4 /* Does teletext */ 81#define VID_TYPE_TELETEXT 4 /* Does teletext */
@@ -85,14 +90,15 @@
85#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ 90#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
86#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ 91#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
87#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ 92#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
93#endif
88 94
89/* 95/*
90 * M I S C E L L A N E O U S 96 * M I S C E L L A N E O U S
91 */ 97 */
92 98
93/* Four-character-code (FOURCC) */ 99/* Four-character-code (FOURCC) */
94#define v4l2_fourcc(a,b,c,d)\ 100#define v4l2_fourcc(a, b, c, d)\
95 (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) 101 ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
96 102
97/* 103/*
98 * E N U M S 104 * E N U M S
@@ -226,8 +232,7 @@ struct v4l2_fract {
226/* 232/*
227 * D R I V E R C A P A B I L I T I E S 233 * D R I V E R C A P A B I L I T I E S
228 */ 234 */
229struct v4l2_capability 235struct v4l2_capability {
230{
231 __u8 driver[16]; /* i.e. "bttv" */ 236 __u8 driver[16]; /* i.e. "bttv" */
232 __u8 card[32]; /* i.e. "Hauppauge WinTV" */ 237 __u8 card[32]; /* i.e. "Hauppauge WinTV" */
233 __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ 238 __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
@@ -259,8 +264,7 @@ struct v4l2_capability
259/* 264/*
260 * V I D E O I M A G E F O R M A T 265 * V I D E O I M A G E F O R M A T
261 */ 266 */
262struct v4l2_pix_format 267struct v4l2_pix_format {
263{
264 __u32 width; 268 __u32 width;
265 __u32 height; 269 __u32 height;
266 __u32 pixelformat; 270 __u32 pixelformat;
@@ -272,68 +276,69 @@ struct v4l2_pix_format
272}; 276};
273 277
274/* Pixel format FOURCC depth Description */ 278/* Pixel format FOURCC depth Description */
275#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ 279#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
276#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R','4','4','4') /* 16 xxxxrrrr ggggbbbb */ 280#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
277#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ 281#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
278#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ 282#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */
279#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ 283#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
280#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ 284#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
281#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ 285#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
282#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ 286#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
283#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ 287#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
284#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ 288#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
285#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ 289#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
286#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y','1','6',' ') /* 16 Greyscale */ 290#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
287#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */ 291#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
288#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ 292#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
289#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ 293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
290#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ 294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
291#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ 295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
292#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ 296#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
293#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ 297#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
294#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ 298#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
295#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y','4','4','4') /* 16 xxxxyyyy uuuuvvvv */ 299#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
296#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y','U','V','O') /* 16 YUV-5-5-5 */ 300#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
297#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y','U','V','P') /* 16 YUV-5-6-5 */ 301#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
298#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y','U','V','4') /* 32 YUV-8-8-8-8 */ 302#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
299 303
300/* two planes -- one Y, one Cr + Cb interleaved */ 304/* two planes -- one Y, one Cr + Cb interleaved */
301#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ 305#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
302#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ 306#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
303 307
304/* The following formats are not defined in the V4L2 specification */ 308/* The following formats are not defined in the V4L2 specification */
305#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ 309#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
306#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ 310#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
307#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ 311#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
308#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ 312#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
309#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ 313#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
310 314
311/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 315/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
312#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ 316#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
313#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G','B','R','G') /* 8 GBGB.. RGRG.. */ 317#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
314#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B','Y','R','2') /* 16 BGBG.. GRGR.. */ 318#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
315 319
316/* compressed formats */ 320/* compressed formats */
317#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ 321#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
318#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ 322#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */
319#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ 323#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */
320#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ 324#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */
321 325
322/* Vendor-specific formats */ 326/* Vendor-specific formats */
323#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ 327#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
324#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ 328#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
325#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ 329#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */
326#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ 330#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */
327#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ 331#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */
328#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S','5','0','1') /* YUYV per line */ 332#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */
329#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S','5','6','1') /* compressed GBRG bayer */ 333#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */
330#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P','2','0','7') /* compressed BGGR bayer */ 334#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */
335#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */
336#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */
331 337
332/* 338/*
333 * F O R M A T E N U M E R A T I O N 339 * F O R M A T E N U M E R A T I O N
334 */ 340 */
335struct v4l2_fmtdesc 341struct v4l2_fmtdesc {
336{
337 __u32 index; /* Format number */ 342 __u32 index; /* Format number */
338 enum v4l2_buf_type type; /* buffer type */ 343 enum v4l2_buf_type type; /* buffer type */
339 __u32 flags; 344 __u32 flags;
@@ -349,21 +354,18 @@ struct v4l2_fmtdesc
349/* 354/*
350 * F R A M E S I Z E E N U M E R A T I O N 355 * F R A M E S I Z E E N U M E R A T I O N
351 */ 356 */
352enum v4l2_frmsizetypes 357enum v4l2_frmsizetypes {
353{
354 V4L2_FRMSIZE_TYPE_DISCRETE = 1, 358 V4L2_FRMSIZE_TYPE_DISCRETE = 1,
355 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, 359 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
356 V4L2_FRMSIZE_TYPE_STEPWISE = 3, 360 V4L2_FRMSIZE_TYPE_STEPWISE = 3,
357}; 361};
358 362
359struct v4l2_frmsize_discrete 363struct v4l2_frmsize_discrete {
360{
361 __u32 width; /* Frame width [pixel] */ 364 __u32 width; /* Frame width [pixel] */
362 __u32 height; /* Frame height [pixel] */ 365 __u32 height; /* Frame height [pixel] */
363}; 366};
364 367
365struct v4l2_frmsize_stepwise 368struct v4l2_frmsize_stepwise {
366{
367 __u32 min_width; /* Minimum frame width [pixel] */ 369 __u32 min_width; /* Minimum frame width [pixel] */
368 __u32 max_width; /* Maximum frame width [pixel] */ 370 __u32 max_width; /* Maximum frame width [pixel] */
369 __u32 step_width; /* Frame width step size [pixel] */ 371 __u32 step_width; /* Frame width step size [pixel] */
@@ -372,8 +374,7 @@ struct v4l2_frmsize_stepwise
372 __u32 step_height; /* Frame height step size [pixel] */ 374 __u32 step_height; /* Frame height step size [pixel] */
373}; 375};
374 376
375struct v4l2_frmsizeenum 377struct v4l2_frmsizeenum {
376{
377 __u32 index; /* Frame size number */ 378 __u32 index; /* Frame size number */
378 __u32 pixel_format; /* Pixel format */ 379 __u32 pixel_format; /* Pixel format */
379 __u32 type; /* Frame size type the device supports. */ 380 __u32 type; /* Frame size type the device supports. */
@@ -389,22 +390,19 @@ struct v4l2_frmsizeenum
389/* 390/*
390 * F R A M E R A T E E N U M E R A T I O N 391 * F R A M E R A T E E N U M E R A T I O N
391 */ 392 */
392enum v4l2_frmivaltypes 393enum v4l2_frmivaltypes {
393{
394 V4L2_FRMIVAL_TYPE_DISCRETE = 1, 394 V4L2_FRMIVAL_TYPE_DISCRETE = 1,
395 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, 395 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
396 V4L2_FRMIVAL_TYPE_STEPWISE = 3, 396 V4L2_FRMIVAL_TYPE_STEPWISE = 3,
397}; 397};
398 398
399struct v4l2_frmival_stepwise 399struct v4l2_frmival_stepwise {
400{
401 struct v4l2_fract min; /* Minimum frame interval [s] */ 400 struct v4l2_fract min; /* Minimum frame interval [s] */
402 struct v4l2_fract max; /* Maximum frame interval [s] */ 401 struct v4l2_fract max; /* Maximum frame interval [s] */
403 struct v4l2_fract step; /* Frame interval step size [s] */ 402 struct v4l2_fract step; /* Frame interval step size [s] */
404}; 403};
405 404
406struct v4l2_frmivalenum 405struct v4l2_frmivalenum {
407{
408 __u32 index; /* Frame format index */ 406 __u32 index; /* Frame format index */
409 __u32 pixel_format; /* Pixel format */ 407 __u32 pixel_format; /* Pixel format */
410 __u32 width; /* Frame width */ 408 __u32 width; /* Frame width */
@@ -423,8 +421,7 @@ struct v4l2_frmivalenum
423/* 421/*
424 * T I M E C O D E 422 * T I M E C O D E
425 */ 423 */
426struct v4l2_timecode 424struct v4l2_timecode {
427{
428 __u32 type; 425 __u32 type;
429 __u32 flags; 426 __u32 flags;
430 __u8 frames; 427 __u8 frames;
@@ -449,8 +446,7 @@ struct v4l2_timecode
449#define V4L2_TC_USERBITS_8BITCHARS 0x0008 446#define V4L2_TC_USERBITS_8BITCHARS 0x0008
450/* The above is based on SMPTE timecodes */ 447/* The above is based on SMPTE timecodes */
451 448
452struct v4l2_jpegcompression 449struct v4l2_jpegcompression {
453{
454 int quality; 450 int quality;
455 451
456 int APPn; /* Number of APP segment to be written, 452 int APPn; /* Number of APP segment to be written,
@@ -482,16 +478,14 @@ struct v4l2_jpegcompression
482/* 478/*
483 * M E M O R Y - M A P P I N G B U F F E R S 479 * M E M O R Y - M A P P I N G B U F F E R S
484 */ 480 */
485struct v4l2_requestbuffers 481struct v4l2_requestbuffers {
486{
487 __u32 count; 482 __u32 count;
488 enum v4l2_buf_type type; 483 enum v4l2_buf_type type;
489 enum v4l2_memory memory; 484 enum v4l2_memory memory;
490 __u32 reserved[2]; 485 __u32 reserved[2];
491}; 486};
492 487
493struct v4l2_buffer 488struct v4l2_buffer {
494{
495 __u32 index; 489 __u32 index;
496 enum v4l2_buf_type type; 490 enum v4l2_buf_type type;
497 __u32 bytesused; 491 __u32 bytesused;
@@ -525,13 +519,12 @@ struct v4l2_buffer
525/* 519/*
526 * O V E R L A Y P R E V I E W 520 * O V E R L A Y P R E V I E W
527 */ 521 */
528struct v4l2_framebuffer 522struct v4l2_framebuffer {
529{
530 __u32 capability; 523 __u32 capability;
531 __u32 flags; 524 __u32 flags;
532/* FIXME: in theory we should pass something like PCI device + memory 525/* FIXME: in theory we should pass something like PCI device + memory
533 * region + offset instead of some physical address */ 526 * region + offset instead of some physical address */
534 void* base; 527 void *base;
535 struct v4l2_pix_format fmt; 528 struct v4l2_pix_format fmt;
536}; 529};
537/* Flags for the 'capability' field. Read only */ 530/* Flags for the 'capability' field. Read only */
@@ -550,14 +543,12 @@ struct v4l2_framebuffer
550#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 543#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
551#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 544#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
552 545
553struct v4l2_clip 546struct v4l2_clip {
554{
555 struct v4l2_rect c; 547 struct v4l2_rect c;
556 struct v4l2_clip __user *next; 548 struct v4l2_clip __user *next;
557}; 549};
558 550
559struct v4l2_window 551struct v4l2_window {
560{
561 struct v4l2_rect w; 552 struct v4l2_rect w;
562 enum v4l2_field field; 553 enum v4l2_field field;
563 __u32 chromakey; 554 __u32 chromakey;
@@ -570,8 +561,7 @@ struct v4l2_window
570/* 561/*
571 * C A P T U R E P A R A M E T E R S 562 * C A P T U R E P A R A M E T E R S
572 */ 563 */
573struct v4l2_captureparm 564struct v4l2_captureparm {
574{
575 __u32 capability; /* Supported modes */ 565 __u32 capability; /* Supported modes */
576 __u32 capturemode; /* Current mode */ 566 __u32 capturemode; /* Current mode */
577 struct v4l2_fract timeperframe; /* Time per frame in .1us units */ 567 struct v4l2_fract timeperframe; /* Time per frame in .1us units */
@@ -584,8 +574,7 @@ struct v4l2_captureparm
584#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ 574#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
585#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ 575#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
586 576
587struct v4l2_outputparm 577struct v4l2_outputparm {
588{
589 __u32 capability; /* Supported modes */ 578 __u32 capability; /* Supported modes */
590 __u32 outputmode; /* Current mode */ 579 __u32 outputmode; /* Current mode */
591 struct v4l2_fract timeperframe; /* Time per frame in seconds */ 580 struct v4l2_fract timeperframe; /* Time per frame in seconds */
@@ -702,8 +691,7 @@ typedef __u64 v4l2_std_id;
702#define V4L2_STD_ALL (V4L2_STD_525_60 |\ 691#define V4L2_STD_ALL (V4L2_STD_525_60 |\
703 V4L2_STD_625_50) 692 V4L2_STD_625_50)
704 693
705struct v4l2_standard 694struct v4l2_standard {
706{
707 __u32 index; 695 __u32 index;
708 v4l2_std_id id; 696 v4l2_std_id id;
709 __u8 name[24]; 697 __u8 name[24];
@@ -715,8 +703,7 @@ struct v4l2_standard
715/* 703/*
716 * V I D E O I N P U T S 704 * V I D E O I N P U T S
717 */ 705 */
718struct v4l2_input 706struct v4l2_input {
719{
720 __u32 index; /* Which input */ 707 __u32 index; /* Which input */
721 __u8 name[32]; /* Label */ 708 __u8 name[32]; /* Label */
722 __u32 type; /* Type of input */ 709 __u32 type; /* Type of input */
@@ -753,8 +740,7 @@ struct v4l2_input
753/* 740/*
754 * V I D E O O U T P U T S 741 * V I D E O O U T P U T S
755 */ 742 */
756struct v4l2_output 743struct v4l2_output {
757{
758 __u32 index; /* Which output */ 744 __u32 index; /* Which output */
759 __u8 name[32]; /* Label */ 745 __u8 name[32]; /* Label */
760 __u32 type; /* Type of output */ 746 __u32 type; /* Type of output */
@@ -771,14 +757,12 @@ struct v4l2_output
771/* 757/*
772 * C O N T R O L S 758 * C O N T R O L S
773 */ 759 */
774struct v4l2_control 760struct v4l2_control {
775{
776 __u32 id; 761 __u32 id;
777 __s32 value; 762 __s32 value;
778}; 763};
779 764
780struct v4l2_ext_control 765struct v4l2_ext_control {
781{
782 __u32 id; 766 __u32 id;
783 __u32 reserved2[2]; 767 __u32 reserved2[2];
784 union { 768 union {
@@ -788,8 +772,7 @@ struct v4l2_ext_control
788 }; 772 };
789} __attribute__ ((packed)); 773} __attribute__ ((packed));
790 774
791struct v4l2_ext_controls 775struct v4l2_ext_controls {
792{
793 __u32 ctrl_class; 776 __u32 ctrl_class;
794 __u32 count; 777 __u32 count;
795 __u32 error_idx; 778 __u32 error_idx;
@@ -807,8 +790,7 @@ struct v4l2_ext_controls
807#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) 790#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
808 791
809/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ 792/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
810struct v4l2_queryctrl 793struct v4l2_queryctrl {
811{
812 __u32 id; 794 __u32 id;
813 enum v4l2_ctrl_type type; 795 enum v4l2_ctrl_type type;
814 __u8 name[32]; /* Whatever */ 796 __u8 name[32]; /* Whatever */
@@ -821,8 +803,7 @@ struct v4l2_queryctrl
821}; 803};
822 804
823/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ 805/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
824struct v4l2_querymenu 806struct v4l2_querymenu {
825{
826 __u32 id; 807 __u32 id;
827 __u32 index; 808 __u32 index;
828 __u8 name[32]; /* Whatever */ 809 __u8 name[32]; /* Whatever */
@@ -1104,8 +1085,7 @@ enum v4l2_exposure_auto_type {
1104/* 1085/*
1105 * T U N I N G 1086 * T U N I N G
1106 */ 1087 */
1107struct v4l2_tuner 1088struct v4l2_tuner {
1108{
1109 __u32 index; 1089 __u32 index;
1110 __u8 name[32]; 1090 __u8 name[32];
1111 enum v4l2_tuner_type type; 1091 enum v4l2_tuner_type type;
@@ -1119,8 +1099,7 @@ struct v4l2_tuner
1119 __u32 reserved[4]; 1099 __u32 reserved[4];
1120}; 1100};
1121 1101
1122struct v4l2_modulator 1102struct v4l2_modulator {
1123{
1124 __u32 index; 1103 __u32 index;
1125 __u8 name[32]; 1104 __u8 name[32];
1126 __u32 capability; 1105 __u32 capability;
@@ -1153,8 +1132,7 @@ struct v4l2_modulator
1153#define V4L2_TUNER_MODE_LANG1 0x0003 1132#define V4L2_TUNER_MODE_LANG1 0x0003
1154#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 1133#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
1155 1134
1156struct v4l2_frequency 1135struct v4l2_frequency {
1157{
1158 __u32 tuner; 1136 __u32 tuner;
1159 enum v4l2_tuner_type type; 1137 enum v4l2_tuner_type type;
1160 __u32 frequency; 1138 __u32 frequency;
@@ -1172,8 +1150,7 @@ struct v4l2_hw_freq_seek {
1172/* 1150/*
1173 * A U D I O 1151 * A U D I O
1174 */ 1152 */
1175struct v4l2_audio 1153struct v4l2_audio {
1176{
1177 __u32 index; 1154 __u32 index;
1178 __u8 name[32]; 1155 __u8 name[32];
1179 __u32 capability; 1156 __u32 capability;
@@ -1188,8 +1165,7 @@ struct v4l2_audio
1188/* Flags for the 'mode' field */ 1165/* Flags for the 'mode' field */
1189#define V4L2_AUDMODE_AVL 0x00001 1166#define V4L2_AUDMODE_AVL 0x00001
1190 1167
1191struct v4l2_audioout 1168struct v4l2_audioout {
1192{
1193 __u32 index; 1169 __u32 index;
1194 __u8 name[32]; 1170 __u8 name[32];
1195 __u32 capability; 1171 __u32 capability;
@@ -1253,8 +1229,7 @@ struct v4l2_encoder_cmd {
1253 */ 1229 */
1254 1230
1255/* Raw VBI */ 1231/* Raw VBI */
1256struct v4l2_vbi_format 1232struct v4l2_vbi_format {
1257{
1258 __u32 sampling_rate; /* in 1 Hz */ 1233 __u32 sampling_rate; /* in 1 Hz */
1259 __u32 offset; 1234 __u32 offset;
1260 __u32 samples_per_line; 1235 __u32 samples_per_line;
@@ -1266,8 +1241,8 @@ struct v4l2_vbi_format
1266}; 1241};
1267 1242
1268/* VBI flags */ 1243/* VBI flags */
1269#define V4L2_VBI_UNSYNC (1<< 0) 1244#define V4L2_VBI_UNSYNC (1 << 0)
1270#define V4L2_VBI_INTERLACED (1<< 1) 1245#define V4L2_VBI_INTERLACED (1 << 1)
1271 1246
1272/* Sliced VBI 1247/* Sliced VBI
1273 * 1248 *
@@ -1276,8 +1251,7 @@ struct v4l2_vbi_format
1276 * notice in the definitive implementation. 1251 * notice in the definitive implementation.
1277 */ 1252 */
1278 1253
1279struct v4l2_sliced_vbi_format 1254struct v4l2_sliced_vbi_format {
1280{
1281 __u16 service_set; 1255 __u16 service_set;
1282 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field 1256 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
1283 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field 1257 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
@@ -1301,8 +1275,7 @@ struct v4l2_sliced_vbi_format
1301#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) 1275#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
1302#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) 1276#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
1303 1277
1304struct v4l2_sliced_vbi_cap 1278struct v4l2_sliced_vbi_cap {
1305{
1306 __u16 service_set; 1279 __u16 service_set;
1307 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field 1280 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
1308 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field 1281 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
@@ -1313,8 +1286,7 @@ struct v4l2_sliced_vbi_cap
1313 __u32 reserved[3]; /* must be 0 */ 1286 __u32 reserved[3]; /* must be 0 */
1314}; 1287};
1315 1288
1316struct v4l2_sliced_vbi_data 1289struct v4l2_sliced_vbi_data {
1317{
1318 __u32 id; 1290 __u32 id;
1319 __u32 field; /* 0: first field, 1: second field */ 1291 __u32 field; /* 0: first field, 1: second field */
1320 __u32 line; /* 1-23 */ 1292 __u32 line; /* 1-23 */
@@ -1328,27 +1300,23 @@ struct v4l2_sliced_vbi_data
1328 1300
1329/* Stream data format 1301/* Stream data format
1330 */ 1302 */
1331struct v4l2_format 1303struct v4l2_format {
1332{
1333 enum v4l2_buf_type type; 1304 enum v4l2_buf_type type;
1334 union 1305 union {
1335 { 1306 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
1336 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE 1307 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
1337 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY 1308 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
1338 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE 1309 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
1339 struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 1310 __u8 raw_data[200]; /* user-defined */
1340 __u8 raw_data[200]; // user-defined
1341 } fmt; 1311 } fmt;
1342}; 1312};
1343 1313
1344 1314
1345/* Stream type-dependent parameters 1315/* Stream type-dependent parameters
1346 */ 1316 */
1347struct v4l2_streamparm 1317struct v4l2_streamparm {
1348{
1349 enum v4l2_buf_type type; 1318 enum v4l2_buf_type type;
1350 union 1319 union {
1351 {
1352 struct v4l2_captureparm capture; 1320 struct v4l2_captureparm capture;
1353 struct v4l2_outputparm output; 1321 struct v4l2_outputparm output;
1354 __u8 raw_data[200]; /* user-defined */ 1322 __u8 raw_data[200]; /* user-defined */
@@ -1386,92 +1354,86 @@ struct v4l2_chip_ident {
1386 * I O C T L C O D E S F O R V I D E O D E V I C E S 1354 * I O C T L C O D E S F O R V I D E O D E V I C E S
1387 * 1355 *
1388 */ 1356 */
1389#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) 1357#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
1390#define VIDIOC_RESERVED _IO ('V', 1) 1358#define VIDIOC_RESERVED _IO('V', 1)
1391#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) 1359#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
1392#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) 1360#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
1393#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) 1361#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
1394#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) 1362#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
1395#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) 1363#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
1396#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) 1364#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
1397#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) 1365#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
1398#define VIDIOC_OVERLAY _IOW ('V', 14, int) 1366#define VIDIOC_OVERLAY _IOW('V', 14, int)
1399#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) 1367#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
1400#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) 1368#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
1401#define VIDIOC_STREAMON _IOW ('V', 18, int) 1369#define VIDIOC_STREAMON _IOW('V', 18, int)
1402#define VIDIOC_STREAMOFF _IOW ('V', 19, int) 1370#define VIDIOC_STREAMOFF _IOW('V', 19, int)
1403#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) 1371#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
1404#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) 1372#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
1405#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) 1373#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
1406#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) 1374#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
1407#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) 1375#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
1408#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) 1376#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
1409#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) 1377#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
1410#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) 1378#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
1411#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) 1379#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
1412#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) 1380#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
1413#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) 1381#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
1414#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) 1382#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
1415#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) 1383#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
1416#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) 1384#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
1417#define VIDIOC_G_INPUT _IOR ('V', 38, int) 1385#define VIDIOC_G_INPUT _IOR('V', 38, int)
1418#define VIDIOC_S_INPUT _IOWR ('V', 39, int) 1386#define VIDIOC_S_INPUT _IOWR('V', 39, int)
1419#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) 1387#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
1420#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) 1388#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
1421#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) 1389#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
1422#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) 1390#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
1423#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) 1391#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
1424#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) 1392#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
1425#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) 1393#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
1426#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) 1394#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
1427#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) 1395#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
1428#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) 1396#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
1429#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) 1397#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
1430#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) 1398#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
1431#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) 1399#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
1432#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) 1400#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
1433#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) 1401#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
1434#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) 1402#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
1435#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) 1403#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
1436#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) 1404#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
1437#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) 1405#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
1438#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) 1406#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
1439#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) 1407#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
1440#define VIDIOC_LOG_STATUS _IO ('V', 70) 1408#define VIDIOC_LOG_STATUS _IO('V', 70)
1441#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) 1409#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
1442#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) 1410#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
1443#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) 1411#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
1444#if 1 1412#if 1
1445#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) 1413#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
1446#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) 1414#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
1447#define VIDIOC_G_ENC_INDEX _IOR ('V', 76, struct v4l2_enc_idx) 1415#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
1448#define VIDIOC_ENCODER_CMD _IOWR ('V', 77, struct v4l2_encoder_cmd) 1416#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
1449#define VIDIOC_TRY_ENCODER_CMD _IOWR ('V', 78, struct v4l2_encoder_cmd) 1417#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
1450 1418
1451/* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1419/* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */
1452#define VIDIOC_DBG_S_REGISTER _IOW ('V', 79, struct v4l2_register) 1420#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_register)
1453#define VIDIOC_DBG_G_REGISTER _IOWR ('V', 80, struct v4l2_register) 1421#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_register)
1454 1422
1455#define VIDIOC_G_CHIP_IDENT _IOWR ('V', 81, struct v4l2_chip_ident) 1423#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident)
1456#endif 1424#endif
1457#define VIDIOC_S_HW_FREQ_SEEK _IOW ('V', 82, struct v4l2_hw_freq_seek) 1425#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1458 1426
1459#ifdef __OLD_VIDIOC_ 1427#ifdef __OLD_VIDIOC_
1460/* for compatibility, will go away some day */ 1428/* for compatibility, will go away some day */
1461#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) 1429#define VIDIOC_OVERLAY_OLD _IOWR('V', 14, int)
1462#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) 1430#define VIDIOC_S_PARM_OLD _IOW('V', 22, struct v4l2_streamparm)
1463#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) 1431#define VIDIOC_S_CTRL_OLD _IOW('V', 28, struct v4l2_control)
1464#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) 1432#define VIDIOC_G_AUDIO_OLD _IOWR('V', 33, struct v4l2_audio)
1465#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) 1433#define VIDIOC_G_AUDOUT_OLD _IOWR('V', 49, struct v4l2_audioout)
1466#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) 1434#define VIDIOC_CROPCAP_OLD _IOR('V', 58, struct v4l2_cropcap)
1467#endif 1435#endif
1468 1436
1469#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ 1437#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
1470 1438
1471#endif /* __LINUX_VIDEODEV2_H */ 1439#endif /* __LINUX_VIDEODEV2_H */
1472
1473/*
1474 * Local variables:
1475 * c-basic-offset: 8
1476 * End:
1477 */
diff --git a/include/linux/videotext.h b/include/linux/videotext.h
index 018f92047ff8..3e68c8d1c7f7 100644
--- a/include/linux/videotext.h
+++ b/include/linux/videotext.h
@@ -45,10 +45,10 @@
45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */ 45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */
46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */ 46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */
47 47
48/* 48/*
49 * Definitions for VTXIOCGETINFO 49 * Definitions for VTXIOCGETINFO
50 */ 50 */
51 51
52#define SAA5243 0 52#define SAA5243 0
53#define SAA5246 1 53#define SAA5246 1
54#define SAA5249 2 54#define SAA5249 2
@@ -57,10 +57,10 @@
57 57
58typedef struct { 58typedef struct {
59 int version_major, version_minor; /* version of driver; if version_major changes, driver */ 59 int version_major, version_minor; /* version of driver; if version_major changes, driver */
60 /* is not backward compatible!!! CHECK THIS!!! */ 60 /* is not backward compatible!!! CHECK THIS!!! */
61 int numpages; /* number of page-buffers of vtx-chipset */ 61 int numpages; /* number of page-buffers of vtx-chipset */
62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or 62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or
63 * SAA5249) */ 63 * SAA5249) */
64} 64}
65vtx_info_t; 65vtx_info_t;
66 66
@@ -81,7 +81,7 @@ vtx_info_t;
81#define PGMASK_HOUR (HR_TEN | HR_UNIT) 81#define PGMASK_HOUR (HR_TEN | HR_UNIT)
82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT) 82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT)
83 83
84typedef struct 84typedef struct
85{ 85{
86 int page; /* number of requested page (hexadecimal) */ 86 int page; /* number of requested page (hexadecimal) */
87 int hour; /* requested hour (hexadecimal) */ 87 int hour; /* requested hour (hexadecimal) */
@@ -98,11 +98,11 @@ vtx_pagereq_t;
98/* 98/*
99 * Definitions for VTXIOC{GETSTAT,PUTSTAT} 99 * Definitions for VTXIOC{GETSTAT,PUTSTAT}
100 */ 100 */
101 101
102#define VTX_PAGESIZE (40 * 24) 102#define VTX_PAGESIZE (40 * 24)
103#define VTX_VIRTUALSIZE (40 * 49) 103#define VTX_VIRTUALSIZE (40 * 49)
104 104
105typedef struct 105typedef struct
106{ 106{
107 int pagenum; /* number of page (hexadecimal) */ 107 int pagenum; /* number of page (hexadecimal) */
108 int hour; /* hour (hexadecimal) */ 108 int hour; /* hour (hexadecimal) */
@@ -121,5 +121,5 @@ typedef struct
121 unsigned hamming : 1; /* hamming-error occurred */ 121 unsigned hamming : 1; /* hamming-error occurred */
122} 122}
123vtx_pageinfo_t; 123vtx_pageinfo_t;
124 124
125#endif /* _VTX_H */ 125#endif /* _VTX_H */
diff --git a/include/media/audiochip.h b/include/media/audiochip.h
index db8823d45a7d..e69de29bb2d1 100644
--- a/include/media/audiochip.h
+++ b/include/media/audiochip.h
@@ -1,26 +0,0 @@
1/*
2 */
3
4#ifndef AUDIOCHIP_H
5#define AUDIOCHIP_H
6
7enum audiochip {
8 AUDIO_CHIP_NONE,
9 AUDIO_CHIP_UNKNOWN,
10 /* Provided by video chip */
11 AUDIO_CHIP_INTERNAL,
12 /* Provided by tvaudio.c */
13 AUDIO_CHIP_TDA8425,
14 AUDIO_CHIP_TEA6300,
15 AUDIO_CHIP_TEA6420,
16 AUDIO_CHIP_TDA9840,
17 AUDIO_CHIP_TDA985X,
18 AUDIO_CHIP_TDA9874,
19 AUDIO_CHIP_PIC16C54,
20 /* Provided by msp3400.c */
21 AUDIO_CHIP_MSP34XX,
22 /* Provided by wm8775.c */
23 AUDIO_CHIP_WM8775
24};
25
26#endif /* AUDIOCHIP_H */
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 89c442eb8849..1d104096619c 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -2,6 +2,7 @@
2#define __SAA7146_VV__ 2#define __SAA7146_VV__
3 3
4#include <media/v4l2-common.h> 4#include <media/v4l2-common.h>
5#include <media/v4l2-ioctl.h>
5#include <media/saa7146.h> 6#include <media/saa7146.h>
6#include <media/videobuf-dma-sg.h> 7#include <media/videobuf-dma-sg.h>
7 8
diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h
index 5660ea24996b..a8ad75a9152a 100644
--- a/include/media/tveeprom.h
+++ b/include/media/tveeprom.h
@@ -3,7 +3,12 @@
3 3
4struct tveeprom { 4struct tveeprom {
5 u32 has_radio; 5 u32 has_radio;
6 u32 has_ir; /* bit 0: IR receiver present, bit 1: IR transmitter (blaster) present. -1 == unknown */ 6 /* If has_ir == 0, then it is unknown what the IR capabilities are,
7 otherwise:
8 bit 0: 1 (= IR capabilities are known)
9 bit 1: IR receiver present
10 bit 2: IR transmitter (blaster) present */
11 u32 has_ir;
7 u32 has_MAC_address; /* 0: no MAC, 1: MAC present, 2: unknown */ 12 u32 has_MAC_address; /* 0: no MAC, 1: MAC present, 2: unknown */
8 13
9 u32 tuner_type; 14 u32 tuner_type;
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 2a527742701a..41b509babf3f 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -90,7 +90,10 @@ enum {
90 /* module m52790: just ident 52790 */ 90 /* module m52790: just ident 52790 */
91 V4L2_IDENT_M52790 = 52790, 91 V4L2_IDENT_M52790 = 52790,
92 92
93 /* module msp34xx: reserved range 34000-34999 */ 93 /* module msp3400: reserved range 34000-34999 and 44000-44999 */
94 V4L2_IDENT_MSPX4XX = 34000, /* generic MSPX4XX identifier, only
95 use internally (tveeprom.c). */
96
94 V4L2_IDENT_MSP3400B = 34002, 97 V4L2_IDENT_MSP3400B = 34002,
95 V4L2_IDENT_MSP3410B = 34102, 98 V4L2_IDENT_MSP3410B = 34102,
96 99
@@ -142,7 +145,7 @@ enum {
142 V4L2_IDENT_MSP3457G = 34577, 145 V4L2_IDENT_MSP3457G = 34577,
143 V4L2_IDENT_MSP3467G = 34677, 146 V4L2_IDENT_MSP3467G = 34677,
144 147
145 /* module msp44xx: reserved range 44000-44999 */ 148 /* module msp3400: reserved range 34000-34999 and 44000-44999 */
146 V4L2_IDENT_MSP4400G = 44007, 149 V4L2_IDENT_MSP4400G = 44007,
147 V4L2_IDENT_MSP4410G = 44107, 150 V4L2_IDENT_MSP4410G = 44107,
148 V4L2_IDENT_MSP4420G = 44207, 151 V4L2_IDENT_MSP4420G = 44207,
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 020d05758bd8..07d3a9a575d1 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -28,12 +28,6 @@
28 28
29#include <media/v4l2-dev.h> 29#include <media/v4l2-dev.h>
30 30
31/* v4l debugging and diagnostics */
32
33/* Debug bitmask flags to be used on V4L2 */
34#define V4L2_DEBUG_IOCTL 0x01
35#define V4L2_DEBUG_IOCTL_ARG 0x02
36
37/* Common printk constucts for v4l-i2c drivers. These macros create a unique 31/* Common printk constucts for v4l-i2c drivers. These macros create a unique
38 prefix consisting of the driver name, the adapter number and the i2c 32 prefix consisting of the driver name, the adapter number and the i2c
39 address. */ 33 address. */
@@ -61,21 +55,20 @@
61 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ 55 v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \
62 } while (0) 56 } while (0)
63 57
58/* ------------------------------------------------------------------------- */
64 59
65/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ 60/* Priority helper functions */
66#define v4l_print_ioctl(name, cmd) \
67 do { \
68 printk(KERN_DEBUG "%s: ", name); \
69 v4l_printk_ioctl(cmd); \
70 } while (0)
71 61
72/* Use this macro in I2C drivers where 'client' is the struct i2c_client 62struct v4l2_prio_state {
73 pointer */ 63 atomic_t prios[4];
74#define v4l_i2c_print_ioctl(client, cmd) \ 64};
75 do { \ 65int v4l2_prio_init(struct v4l2_prio_state *global);
76 v4l_client_printk(KERN_DEBUG, client, ""); \ 66int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
77 v4l_printk_ioctl(cmd); \ 67 enum v4l2_priority new);
78 } while (0) 68int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
69int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
70enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
71int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
79 72
80/* ------------------------------------------------------------------------- */ 73/* ------------------------------------------------------------------------- */
81 74
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 33f379b1ecfe..2745e1afc722 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -9,7 +9,6 @@
9#ifndef _V4L2_DEV_H 9#ifndef _V4L2_DEV_H
10#define _V4L2_DEV_H 10#define _V4L2_DEV_H
11 11
12#define OBSOLETE_OWNER 1 /* to be removed soon */
13#define OBSOLETE_DEVDATA 1 /* to be removed soon */ 12#define OBSOLETE_DEVDATA 1 /* to be removed soon */
14 13
15#include <linux/poll.h> 14#include <linux/poll.h>
@@ -17,11 +16,7 @@
17#include <linux/device.h> 16#include <linux/device.h>
18#include <linux/mutex.h> 17#include <linux/mutex.h>
19#include <linux/compiler.h> /* need __user */ 18#include <linux/compiler.h> /* need __user */
20#ifdef CONFIG_VIDEO_V4L1_COMPAT
21#include <linux/videodev.h>
22#else
23#include <linux/videodev2.h> 19#include <linux/videodev2.h>
24#endif
25 20
26#define VIDEO_MAJOR 81 21#define VIDEO_MAJOR 81
27/* Minor device allocation */ 22/* Minor device allocation */
@@ -39,42 +34,7 @@
39#define VFL_TYPE_RADIO 2 34#define VFL_TYPE_RADIO 2
40#define VFL_TYPE_VTX 3 35#define VFL_TYPE_VTX 3
41 36
42/* Video standard functions */ 37struct v4l2_ioctl_callbacks;
43extern const char *v4l2_norm_to_name(v4l2_std_id id);
44extern int v4l2_video_std_construct(struct v4l2_standard *vs,
45 int id, const char *name);
46/* Prints the ioctl in a human-readable format */
47extern void v4l_printk_ioctl(unsigned int cmd);
48
49/* prority handling */
50struct v4l2_prio_state {
51 atomic_t prios[4];
52};
53int v4l2_prio_init(struct v4l2_prio_state *global);
54int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
55 enum v4l2_priority new);
56int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
57int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
58enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
59int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
60
61/* names for fancy debug output */
62extern const char *v4l2_field_names[];
63extern const char *v4l2_type_names[];
64
65/* Compatibility layer interface -- v4l1-compat module */
66typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
67 unsigned int cmd, void *arg);
68#ifdef CONFIG_VIDEO_V4L1_COMPAT
69int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
70 int cmd, void *arg, v4l2_kioctl driver_ioctl);
71#else
72#define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL
73#endif
74
75/* 32 Bits compatibility layer for 64 bits processors */
76extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
77 unsigned long arg);
78 38
79/* 39/*
80 * Newer version of video_device, handled by videodev2.c 40 * Newer version of video_device, handled by videodev2.c
@@ -88,18 +48,17 @@ struct video_device
88 const struct file_operations *fops; 48 const struct file_operations *fops;
89 49
90 /* sysfs */ 50 /* sysfs */
91 struct device class_dev; /* v4l device */ 51 struct device dev; /* v4l device */
92 struct device *dev; /* device parent */ 52 struct device *parent; /* device parent */
93 53
94 /* device info */ 54 /* device info */
95 char name[32]; 55 char name[32];
96 int type; /* v4l1 */ 56 int vfl_type;
97 int type2; /* v4l2 */
98 int minor; 57 int minor;
99 /* attribute to diferentiate multiple indexs on one physical device */ 58 /* attribute to differentiate multiple indices on one physical device */
100 int index; 59 int index;
101 60
102 int debug; /* Activates debug level*/ 61 int debug; /* Activates debug level*/
103 62
104 /* Video standard vars */ 63 /* Video standard vars */
105 v4l2_std_id tvnorms; /* Supported tv norms */ 64 v4l2_std_id tvnorms; /* Supported tv norms */
@@ -109,285 +68,36 @@ struct video_device
109 void (*release)(struct video_device *vfd); 68 void (*release)(struct video_device *vfd);
110 69
111 /* ioctl callbacks */ 70 /* ioctl callbacks */
71 const struct v4l2_ioctl_ops *ioctl_ops;
112 72
113 /* VIDIOC_QUERYCAP handler */ 73#ifdef OBSOLETE_DEVDATA /* to be removed soon */
114 int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); 74 /* dev->driver_data will be used instead some day.
115 75 * Use the video_{get|set}_drvdata() helper functions,
116 /* Priority handling */ 76 * so the switch over will be transparent for you.
117 int (*vidioc_g_priority) (struct file *file, void *fh, 77 * Or use {pci|usb}_{get|set}_drvdata() directly. */
118 enum v4l2_priority *p); 78 void *priv;
119 int (*vidioc_s_priority) (struct file *file, void *fh,
120 enum v4l2_priority p);
121
122 /* VIDIOC_ENUM_FMT handlers */
123 int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
124 struct v4l2_fmtdesc *f);
125 int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
126 struct v4l2_fmtdesc *f);
127 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
128 struct v4l2_fmtdesc *f);
129#if 1
130 /* deprecated, will be removed in 2.6.28 */
131 int (*vidioc_enum_fmt_vbi_cap) (struct file *file, void *fh,
132 struct v4l2_fmtdesc *f);
133#endif
134 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
135 struct v4l2_fmtdesc *f);
136
137 /* VIDIOC_G_FMT handlers */
138 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
139 struct v4l2_format *f);
140 int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
141 struct v4l2_format *f);
142 int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
143 struct v4l2_format *f);
144 int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
145 struct v4l2_format *f);
146 int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
147 struct v4l2_format *f);
148 int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
149 struct v4l2_format *f);
150 int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
151 struct v4l2_format *f);
152 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
153 struct v4l2_format *f);
154 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
155 struct v4l2_format *f);
156
157 /* VIDIOC_S_FMT handlers */
158 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
159 struct v4l2_format *f);
160 int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
161 struct v4l2_format *f);
162 int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
163 struct v4l2_format *f);
164 int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
165 struct v4l2_format *f);
166 int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
167 struct v4l2_format *f);
168 int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
169 struct v4l2_format *f);
170 int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
171 struct v4l2_format *f);
172 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
173 struct v4l2_format *f);
174 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
175 struct v4l2_format *f);
176
177 /* VIDIOC_TRY_FMT handlers */
178 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
179 struct v4l2_format *f);
180 int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
181 struct v4l2_format *f);
182 int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
183 struct v4l2_format *f);
184 int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
185 struct v4l2_format *f);
186 int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
187 struct v4l2_format *f);
188 int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
189 struct v4l2_format *f);
190 int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
191 struct v4l2_format *f);
192 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
193 struct v4l2_format *f);
194 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
195 struct v4l2_format *f);
196
197 /* Buffer handlers */
198 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
199 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
200 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
201 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
202
203
204 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
205#ifdef CONFIG_VIDEO_V4L1_COMPAT
206 /* buffer type is struct vidio_mbuf * */
207 int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
208#endif
209 int (*vidioc_g_fbuf) (struct file *file, void *fh,
210 struct v4l2_framebuffer *a);
211 int (*vidioc_s_fbuf) (struct file *file, void *fh,
212 struct v4l2_framebuffer *a);
213
214 /* Stream on/off */
215 int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
216 int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
217
218 /* Standard handling
219 ENUMSTD is handled by videodev.c
220 */
221 int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
222 int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
223 int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
224
225 /* Input handling */
226 int (*vidioc_enum_input)(struct file *file, void *fh,
227 struct v4l2_input *inp);
228 int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
229 int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
230
231 /* Output handling */
232 int (*vidioc_enum_output) (struct file *file, void *fh,
233 struct v4l2_output *a);
234 int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
235 int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
236
237 /* Control handling */
238 int (*vidioc_queryctrl) (struct file *file, void *fh,
239 struct v4l2_queryctrl *a);
240 int (*vidioc_g_ctrl) (struct file *file, void *fh,
241 struct v4l2_control *a);
242 int (*vidioc_s_ctrl) (struct file *file, void *fh,
243 struct v4l2_control *a);
244 int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
245 struct v4l2_ext_controls *a);
246 int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
247 struct v4l2_ext_controls *a);
248 int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
249 struct v4l2_ext_controls *a);
250 int (*vidioc_querymenu) (struct file *file, void *fh,
251 struct v4l2_querymenu *a);
252
253 /* Audio ioctls */
254 int (*vidioc_enumaudio) (struct file *file, void *fh,
255 struct v4l2_audio *a);
256 int (*vidioc_g_audio) (struct file *file, void *fh,
257 struct v4l2_audio *a);
258 int (*vidioc_s_audio) (struct file *file, void *fh,
259 struct v4l2_audio *a);
260
261 /* Audio out ioctls */
262 int (*vidioc_enumaudout) (struct file *file, void *fh,
263 struct v4l2_audioout *a);
264 int (*vidioc_g_audout) (struct file *file, void *fh,
265 struct v4l2_audioout *a);
266 int (*vidioc_s_audout) (struct file *file, void *fh,
267 struct v4l2_audioout *a);
268 int (*vidioc_g_modulator) (struct file *file, void *fh,
269 struct v4l2_modulator *a);
270 int (*vidioc_s_modulator) (struct file *file, void *fh,
271 struct v4l2_modulator *a);
272 /* Crop ioctls */
273 int (*vidioc_cropcap) (struct file *file, void *fh,
274 struct v4l2_cropcap *a);
275 int (*vidioc_g_crop) (struct file *file, void *fh,
276 struct v4l2_crop *a);
277 int (*vidioc_s_crop) (struct file *file, void *fh,
278 struct v4l2_crop *a);
279 /* Compression ioctls */
280 int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
281 struct v4l2_jpegcompression *a);
282 int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
283 struct v4l2_jpegcompression *a);
284 int (*vidioc_g_enc_index) (struct file *file, void *fh,
285 struct v4l2_enc_idx *a);
286 int (*vidioc_encoder_cmd) (struct file *file, void *fh,
287 struct v4l2_encoder_cmd *a);
288 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
289 struct v4l2_encoder_cmd *a);
290
291 /* Stream type-dependent parameter ioctls */
292 int (*vidioc_g_parm) (struct file *file, void *fh,
293 struct v4l2_streamparm *a);
294 int (*vidioc_s_parm) (struct file *file, void *fh,
295 struct v4l2_streamparm *a);
296
297 /* Tuner ioctls */
298 int (*vidioc_g_tuner) (struct file *file, void *fh,
299 struct v4l2_tuner *a);
300 int (*vidioc_s_tuner) (struct file *file, void *fh,
301 struct v4l2_tuner *a);
302 int (*vidioc_g_frequency) (struct file *file, void *fh,
303 struct v4l2_frequency *a);
304 int (*vidioc_s_frequency) (struct file *file, void *fh,
305 struct v4l2_frequency *a);
306
307 /* Sliced VBI cap */
308 int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
309 struct v4l2_sliced_vbi_cap *a);
310
311 /* Log status ioctl */
312 int (*vidioc_log_status) (struct file *file, void *fh);
313
314 int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
315 struct v4l2_hw_freq_seek *a);
316
317 /* Debugging ioctls */
318#ifdef CONFIG_VIDEO_ADV_DEBUG
319 int (*vidioc_g_register) (struct file *file, void *fh,
320 struct v4l2_register *reg);
321 int (*vidioc_s_register) (struct file *file, void *fh,
322 struct v4l2_register *reg);
323#endif
324 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
325 struct v4l2_chip_ident *chip);
326
327 /* For other private ioctls */
328 int (*vidioc_default) (struct file *file, void *fh,
329 int cmd, void *arg);
330
331
332#ifdef OBSOLETE_OWNER /* to be removed soon */
333/* obsolete -- fops->owner is used instead */
334struct module *owner;
335/* dev->driver_data will be used instead some day.
336 * Use the video_{get|set}_drvdata() helper functions,
337 * so the switch over will be transparent for you.
338 * Or use {pci|usb}_{get|set}_drvdata() directly. */
339void *priv;
340#endif 79#endif
341 80
342 /* for videodev.c intenal usage -- please don't touch */ 81 /* for videodev.c internal usage -- please don't touch */
343 int users; /* video_exclusive_{open|close} ... */ 82 int users; /* video_exclusive_{open|close} ... */
344 struct mutex lock; /* ... helper function uses these */ 83 struct mutex lock; /* ... helper function uses these */
345}; 84};
346 85
347/* Class-dev to video-device */ 86/* Class-dev to video-device */
348#define to_video_device(cd) container_of(cd, struct video_device, class_dev) 87#define to_video_device(cd) container_of(cd, struct video_device, dev)
349 88
350/* Version 2 functions */ 89/* Version 2 functions */
351extern int video_register_device(struct video_device *vfd, int type, int nr); 90extern int video_register_device(struct video_device *vfd, int type, int nr);
352int video_register_device_index(struct video_device *vfd, int type, int nr, 91int video_register_device_index(struct video_device *vfd, int type, int nr,
353 int index); 92 int index);
354void video_unregister_device(struct video_device *); 93void video_unregister_device(struct video_device *);
355extern int video_ioctl2(struct inode *inode, struct file *file,
356 unsigned int cmd, unsigned long arg);
357 94
358/* helper functions to alloc / release struct video_device, the 95/* helper functions to alloc / release struct video_device, the
359 later can be used for video_device->release() */ 96 later can be used for video_device->release() */
360struct video_device *video_device_alloc(void); 97struct video_device *video_device_alloc(void);
361void video_device_release(struct video_device *vfd); 98void video_device_release(struct video_device *vfd);
362 99
363/* Include support for obsoleted stuff */ 100#ifdef OBSOLETE_DEVDATA /* to be removed soon */
364extern int video_usercopy(struct inode *inode, struct file *file,
365 unsigned int cmd, unsigned long arg,
366 int (*func)(struct inode *inode, struct file *file,
367 unsigned int cmd, void *arg));
368
369#ifdef CONFIG_VIDEO_V4L1_COMPAT
370#include <linux/mm.h>
371
372static inline int __must_check
373video_device_create_file(struct video_device *vfd,
374 struct device_attribute *attr)
375{
376 int ret = device_create_file(&vfd->class_dev, attr);
377 if (ret < 0)
378 printk(KERN_WARNING "%s error: %d\n", __func__, ret);
379 return ret;
380}
381static inline void
382video_device_remove_file(struct video_device *vfd,
383 struct device_attribute *attr)
384{
385 device_remove_file(&vfd->class_dev, attr);
386}
387
388#endif /* CONFIG_VIDEO_V4L1_COMPAT */
389
390#ifdef OBSOLETE_OWNER /* to be removed soon */
391/* helper functions to access driver private data. */ 101/* helper functions to access driver private data. */
392static inline void *video_get_drvdata(struct video_device *dev) 102static inline void *video_get_drvdata(struct video_device *dev)
393{ 103{
@@ -399,9 +109,6 @@ static inline void video_set_drvdata(struct video_device *dev, void *data)
399 dev->priv = data; 109 dev->priv = data;
400} 110}
401 111
402#endif
403
404#ifdef OBSOLETE_DEVDATA /* to be removed soon */
405/* Obsolete stuff - Still needed for radio devices and obsolete drivers */ 112/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
406extern struct video_device* video_devdata(struct file*); 113extern struct video_device* video_devdata(struct file*);
407extern int video_exclusive_open(struct inode *inode, struct file *file); 114extern int video_exclusive_open(struct inode *inode, struct file *file);
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
new file mode 100644
index 000000000000..dc6404618555
--- /dev/null
+++ b/include/media/v4l2-ioctl.h
@@ -0,0 +1,301 @@
1/*
2 *
3 * V 4 L 2 D R I V E R H E L P E R A P I
4 *
5 * Moved from videodev2.h
6 *
7 * Some commonly needed functions for drivers (v4l2-common.o module)
8 */
9#ifndef _V4L2_IOCTL_H
10#define _V4L2_IOCTL_H
11
12#include <linux/poll.h>
13#include <linux/fs.h>
14#include <linux/device.h>
15#include <linux/mutex.h>
16#include <linux/compiler.h> /* need __user */
17#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#include <linux/videodev.h>
19#else
20#include <linux/videodev2.h>
21#endif
22
23struct v4l2_ioctl_ops {
24 /* ioctl callbacks */
25
26 /* VIDIOC_QUERYCAP handler */
27 int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
28
29 /* Priority handling */
30 int (*vidioc_g_priority) (struct file *file, void *fh,
31 enum v4l2_priority *p);
32 int (*vidioc_s_priority) (struct file *file, void *fh,
33 enum v4l2_priority p);
34
35 /* VIDIOC_ENUM_FMT handlers */
36 int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
37 struct v4l2_fmtdesc *f);
38 int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
39 struct v4l2_fmtdesc *f);
40 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
41 struct v4l2_fmtdesc *f);
42#if 1
43 /* deprecated, will be removed in 2.6.28 */
44 int (*vidioc_enum_fmt_vbi_cap) (struct file *file, void *fh,
45 struct v4l2_fmtdesc *f);
46#endif
47 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
48 struct v4l2_fmtdesc *f);
49
50 /* VIDIOC_G_FMT handlers */
51 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
52 struct v4l2_format *f);
53 int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
54 struct v4l2_format *f);
55 int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
56 struct v4l2_format *f);
57 int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
58 struct v4l2_format *f);
59 int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
60 struct v4l2_format *f);
61 int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
62 struct v4l2_format *f);
63 int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
64 struct v4l2_format *f);
65 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
66 struct v4l2_format *f);
67 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
68 struct v4l2_format *f);
69
70 /* VIDIOC_S_FMT handlers */
71 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
72 struct v4l2_format *f);
73 int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
74 struct v4l2_format *f);
75 int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
76 struct v4l2_format *f);
77 int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
78 struct v4l2_format *f);
79 int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
80 struct v4l2_format *f);
81 int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
82 struct v4l2_format *f);
83 int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
84 struct v4l2_format *f);
85 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
86 struct v4l2_format *f);
87 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
88 struct v4l2_format *f);
89
90 /* VIDIOC_TRY_FMT handlers */
91 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
92 struct v4l2_format *f);
93 int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
94 struct v4l2_format *f);
95 int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
96 struct v4l2_format *f);
97 int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
98 struct v4l2_format *f);
99 int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
100 struct v4l2_format *f);
101 int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
102 struct v4l2_format *f);
103 int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
104 struct v4l2_format *f);
105 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
106 struct v4l2_format *f);
107 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
108 struct v4l2_format *f);
109
110 /* Buffer handlers */
111 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
112 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
113 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
114 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
115
116
117 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
118#ifdef CONFIG_VIDEO_V4L1_COMPAT
119 /* buffer type is struct vidio_mbuf * */
120 int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
121#endif
122 int (*vidioc_g_fbuf) (struct file *file, void *fh,
123 struct v4l2_framebuffer *a);
124 int (*vidioc_s_fbuf) (struct file *file, void *fh,
125 struct v4l2_framebuffer *a);
126
127 /* Stream on/off */
128 int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
129 int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
130
131 /* Standard handling
132 ENUMSTD is handled by videodev.c
133 */
134 int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
135 int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
136 int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
137
138 /* Input handling */
139 int (*vidioc_enum_input)(struct file *file, void *fh,
140 struct v4l2_input *inp);
141 int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
142 int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
143
144 /* Output handling */
145 int (*vidioc_enum_output) (struct file *file, void *fh,
146 struct v4l2_output *a);
147 int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
148 int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
149
150 /* Control handling */
151 int (*vidioc_queryctrl) (struct file *file, void *fh,
152 struct v4l2_queryctrl *a);
153 int (*vidioc_g_ctrl) (struct file *file, void *fh,
154 struct v4l2_control *a);
155 int (*vidioc_s_ctrl) (struct file *file, void *fh,
156 struct v4l2_control *a);
157 int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
158 struct v4l2_ext_controls *a);
159 int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
160 struct v4l2_ext_controls *a);
161 int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
162 struct v4l2_ext_controls *a);
163 int (*vidioc_querymenu) (struct file *file, void *fh,
164 struct v4l2_querymenu *a);
165
166 /* Audio ioctls */
167 int (*vidioc_enumaudio) (struct file *file, void *fh,
168 struct v4l2_audio *a);
169 int (*vidioc_g_audio) (struct file *file, void *fh,
170 struct v4l2_audio *a);
171 int (*vidioc_s_audio) (struct file *file, void *fh,
172 struct v4l2_audio *a);
173
174 /* Audio out ioctls */
175 int (*vidioc_enumaudout) (struct file *file, void *fh,
176 struct v4l2_audioout *a);
177 int (*vidioc_g_audout) (struct file *file, void *fh,
178 struct v4l2_audioout *a);
179 int (*vidioc_s_audout) (struct file *file, void *fh,
180 struct v4l2_audioout *a);
181 int (*vidioc_g_modulator) (struct file *file, void *fh,
182 struct v4l2_modulator *a);
183 int (*vidioc_s_modulator) (struct file *file, void *fh,
184 struct v4l2_modulator *a);
185 /* Crop ioctls */
186 int (*vidioc_cropcap) (struct file *file, void *fh,
187 struct v4l2_cropcap *a);
188 int (*vidioc_g_crop) (struct file *file, void *fh,
189 struct v4l2_crop *a);
190 int (*vidioc_s_crop) (struct file *file, void *fh,
191 struct v4l2_crop *a);
192 /* Compression ioctls */
193 int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
194 struct v4l2_jpegcompression *a);
195 int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
196 struct v4l2_jpegcompression *a);
197 int (*vidioc_g_enc_index) (struct file *file, void *fh,
198 struct v4l2_enc_idx *a);
199 int (*vidioc_encoder_cmd) (struct file *file, void *fh,
200 struct v4l2_encoder_cmd *a);
201 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
202 struct v4l2_encoder_cmd *a);
203
204 /* Stream type-dependent parameter ioctls */
205 int (*vidioc_g_parm) (struct file *file, void *fh,
206 struct v4l2_streamparm *a);
207 int (*vidioc_s_parm) (struct file *file, void *fh,
208 struct v4l2_streamparm *a);
209
210 /* Tuner ioctls */
211 int (*vidioc_g_tuner) (struct file *file, void *fh,
212 struct v4l2_tuner *a);
213 int (*vidioc_s_tuner) (struct file *file, void *fh,
214 struct v4l2_tuner *a);
215 int (*vidioc_g_frequency) (struct file *file, void *fh,
216 struct v4l2_frequency *a);
217 int (*vidioc_s_frequency) (struct file *file, void *fh,
218 struct v4l2_frequency *a);
219
220 /* Sliced VBI cap */
221 int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
222 struct v4l2_sliced_vbi_cap *a);
223
224 /* Log status ioctl */
225 int (*vidioc_log_status) (struct file *file, void *fh);
226
227 int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
228 struct v4l2_hw_freq_seek *a);
229
230 /* Debugging ioctls */
231#ifdef CONFIG_VIDEO_ADV_DEBUG
232 int (*vidioc_g_register) (struct file *file, void *fh,
233 struct v4l2_register *reg);
234 int (*vidioc_s_register) (struct file *file, void *fh,
235 struct v4l2_register *reg);
236#endif
237 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
238 struct v4l2_chip_ident *chip);
239
240 /* For other private ioctls */
241 int (*vidioc_default) (struct file *file, void *fh,
242 int cmd, void *arg);
243};
244
245
246/* v4l debugging and diagnostics */
247
248/* Debug bitmask flags to be used on V4L2 */
249#define V4L2_DEBUG_IOCTL 0x01
250#define V4L2_DEBUG_IOCTL_ARG 0x02
251
252/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
253#define v4l_print_ioctl(name, cmd) \
254 do { \
255 printk(KERN_DEBUG "%s: ", name); \
256 v4l_printk_ioctl(cmd); \
257 } while (0)
258
259/* Use this macro in I2C drivers where 'client' is the struct i2c_client
260 pointer */
261#define v4l_i2c_print_ioctl(client, cmd) \
262 do { \
263 v4l_client_printk(KERN_DEBUG, client, ""); \
264 v4l_printk_ioctl(cmd); \
265 } while (0)
266
267/* Video standard functions */
268extern const char *v4l2_norm_to_name(v4l2_std_id id);
269extern int v4l2_video_std_construct(struct v4l2_standard *vs,
270 int id, const char *name);
271/* Prints the ioctl in a human-readable format */
272extern void v4l_printk_ioctl(unsigned int cmd);
273
274/* names for fancy debug output */
275extern const char *v4l2_field_names[];
276extern const char *v4l2_type_names[];
277
278/* Compatibility layer interface -- v4l1-compat module */
279typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
280 unsigned int cmd, void *arg);
281#ifdef CONFIG_VIDEO_V4L1_COMPAT
282int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
283 int cmd, void *arg, v4l2_kioctl driver_ioctl);
284#else
285#define v4l_compat_translate_ioctl(inode, file, cmd, arg, ioctl) (-EINVAL)
286#endif
287
288/* 32 Bits compatibility layer for 64 bits processors */
289extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
290 unsigned long arg);
291
292extern int video_ioctl2(struct inode *inode, struct file *file,
293 unsigned int cmd, unsigned long arg);
294
295/* Include support for obsoleted stuff */
296extern int video_usercopy(struct inode *inode, struct file *file,
297 unsigned int cmd, unsigned long arg,
298 int (*func)(struct inode *inode, struct file *file,
299 unsigned int cmd, void *arg));
300
301#endif /* _V4L2_IOCTL_H */
diff --git a/include/mtd/inftl-user.h b/include/mtd/inftl-user.h
index 9b1e2526b45e..e17eda302b2d 100644
--- a/include/mtd/inftl-user.h
+++ b/include/mtd/inftl-user.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: inftl-user.h,v 1.2 2005/11/07 11:14:56 gleixner Exp $
3 *
4 * Parts of INFTL headers shared with userspace 2 * Parts of INFTL headers shared with userspace
5 * 3 *
6 */ 4 */
diff --git a/include/mtd/jffs2-user.h b/include/mtd/jffs2-user.h
index d508ef0ae091..001685d7fa88 100644
--- a/include/mtd/jffs2-user.h
+++ b/include/mtd/jffs2-user.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: jffs2-user.h,v 1.1 2004/05/05 11:57:54 dwmw2 Exp $
3 *
4 * JFFS2 definitions for use in user space only 2 * JFFS2 definitions for use in user space only
5 */ 3 */
6 4
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 615072c4da04..c6c61cd5a254 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd-abi.h,v 1.13 2005/11/07 11:14:56 gleixner Exp $
3 *
4 * Portions of MTD ABI definition which are shared by kernel and user space 2 * Portions of MTD ABI definition which are shared by kernel and user space
5 */ 3 */
6 4
diff --git a/include/mtd/mtd-user.h b/include/mtd/mtd-user.h
index 713f34d3e62e..170ceca3b2d0 100644
--- a/include/mtd/mtd-user.h
+++ b/include/mtd/mtd-user.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd-user.h,v 1.2 2004/05/05 14:44:57 dwmw2 Exp $
3 *
4 * MTD ABI header for use by user space only. 2 * MTD ABI header for use by user space only.
5 */ 3 */
6 4
diff --git a/include/mtd/nftl-user.h b/include/mtd/nftl-user.h
index b2bca18e7311..390d21c080aa 100644
--- a/include/mtd/nftl-user.h
+++ b/include/mtd/nftl-user.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: nftl-user.h,v 1.2 2005/11/07 11:14:56 gleixner Exp $
3 *
4 * Parts of NFTL headers shared with userspace 2 * Parts of NFTL headers shared with userspace
5 * 3 *
6 */ 4 */
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 2dfa96b0575e..7dd29b7e461d 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -51,7 +51,7 @@ struct unix_sock {
51 struct sock *peer; 51 struct sock *peer;
52 struct sock *other; 52 struct sock *other;
53 struct list_head link; 53 struct list_head link;
54 atomic_t inflight; 54 atomic_long_t inflight;
55 spinlock_t lock; 55 spinlock_t lock;
56 unsigned int gc_candidate : 1; 56 unsigned int gc_candidate : 1;
57 wait_queue_head_t peer_wait; 57 wait_queue_head_t peer_wait;
diff --git a/include/net/ip.h b/include/net/ip.h
index b5862b975207..250e6ef025a4 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -188,6 +188,8 @@ extern int sysctl_ip_dynaddr;
188 188
189extern void ipfrag_init(void); 189extern void ipfrag_init(void);
190 190
191extern void ip_static_sysctl_init(void);
192
191#ifdef CONFIG_INET 193#ifdef CONFIG_INET
192#include <net/dst.h> 194#include <net/dst.h>
193 195
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 2d5c18514a2d..113028fb8f66 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -608,6 +608,8 @@ extern struct ctl_table *ipv6_icmp_sysctl_init(struct net *net);
608extern struct ctl_table *ipv6_route_sysctl_init(struct net *net); 608extern struct ctl_table *ipv6_route_sysctl_init(struct net *net);
609extern int ipv6_sysctl_register(void); 609extern int ipv6_sysctl_register(void);
610extern void ipv6_sysctl_unregister(void); 610extern void ipv6_sysctl_unregister(void);
611extern int ipv6_static_sysctl_register(void);
612extern void ipv6_static_sysctl_unregister(void);
611#endif 613#endif
612 614
613#endif /* __KERNEL__ */ 615#endif /* __KERNEL__ */
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 3855620b78a9..a8eb43cf0c7e 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -38,7 +38,9 @@ struct net {
38 struct proc_dir_entry *proc_net; 38 struct proc_dir_entry *proc_net;
39 struct proc_dir_entry *proc_net_stat; 39 struct proc_dir_entry *proc_net_stat;
40 40
41 struct list_head sysctl_table_headers; 41#ifdef CONFIG_SYSCTL
42 struct ctl_table_set sysctls;
43#endif
42 44
43 struct net_device *loopback_dev; /* The loopback */ 45 struct net_device *loopback_dev; /* The loopback */
44 46
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 0c96e7bed5db..8d6e991ef4df 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -18,6 +18,7 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/bug.h>
21 22
22#include <net/sock.h> 23#include <net/sock.h>
23 24
@@ -170,7 +171,7 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
170{ 171{
171 struct request_sock *req = queue->rskq_accept_head; 172 struct request_sock *req = queue->rskq_accept_head;
172 173
173 BUG_TRAP(req != NULL); 174 WARN_ON(req == NULL);
174 175
175 queue->rskq_accept_head = req->dl_next; 176 queue->rskq_accept_head = req->dl_next;
176 if (queue->rskq_accept_head == NULL) 177 if (queue->rskq_accept_head == NULL)
@@ -185,7 +186,7 @@ static inline struct sock *reqsk_queue_get_child(struct request_sock_queue *queu
185 struct request_sock *req = reqsk_queue_remove(queue); 186 struct request_sock *req = reqsk_queue_remove(queue);
186 struct sock *child = req->sk; 187 struct sock *child = req->sk;
187 188
188 BUG_TRAP(child != NULL); 189 WARN_ON(child == NULL);
189 190
190 sk_acceptq_removed(parent); 191 sk_acceptq_removed(parent);
191 __reqsk_free(req); 192 __reqsk_free(req);
diff --git a/include/net/route.h b/include/net/route.h
index 3140cc500854..4f0d8c14736c 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -204,6 +204,4 @@ static inline struct inet_peer *rt_get_peer(struct rtable *rt)
204 return rt->peer; 204 return rt->peer;
205} 205}
206 206
207extern ctl_table ipv4_route_table[];
208
209#endif /* _ROUTE_H */ 207#endif /* _ROUTE_H */
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 90b529f7a154..936e333e7ce5 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1590,7 +1590,7 @@ static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
1590{ 1590{
1591 if (dev->dma_ops) 1591 if (dev->dma_ops)
1592 return dev->dma_ops->mapping_error(dev, dma_addr); 1592 return dev->dma_ops->mapping_error(dev, dma_addr);
1593 return dma_mapping_error(dma_addr); 1593 return dma_mapping_error(dev->dma_device, dma_addr);
1594} 1594}
1595 1595
1596/** 1596/**
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 00137a7769ee..5c40cc537d4c 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -106,6 +106,7 @@
106#define VARIABLE_LENGTH_CMD 0x7f 106#define VARIABLE_LENGTH_CMD 0x7f
107#define REPORT_LUNS 0xa0 107#define REPORT_LUNS 0xa0
108#define MAINTENANCE_IN 0xa3 108#define MAINTENANCE_IN 0xa3
109#define MAINTENANCE_OUT 0xa4
109#define MOVE_MEDIUM 0xa5 110#define MOVE_MEDIUM 0xa5
110#define EXCHANGE_MEDIUM 0xa6 111#define EXCHANGE_MEDIUM 0xa6
111#define READ_12 0xa8 112#define READ_12 0xa8
@@ -125,6 +126,8 @@
125#define SAI_READ_CAPACITY_16 0x10 126#define SAI_READ_CAPACITY_16 0x10
126/* values for maintenance in */ 127/* values for maintenance in */
127#define MI_REPORT_TARGET_PGS 0x0a 128#define MI_REPORT_TARGET_PGS 0x0a
129/* values for maintenance out */
130#define MO_SET_TARGET_PGS 0x0a
128 131
129/* Values for T10/04-262r7 */ 132/* Values for T10/04-262r7 */
130#define ATA_16 0x85 /* 16-byte pass-thru */ 133#define ATA_16 0x85 /* 16-byte pass-thru */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 66c944849d6b..f9f6e793575c 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -77,6 +77,9 @@ struct scsi_cmnd {
77 int allowed; 77 int allowed;
78 int timeout_per_command; 78 int timeout_per_command;
79 79
80 unsigned char prot_op;
81 unsigned char prot_type;
82
80 unsigned short cmd_len; 83 unsigned short cmd_len;
81 enum dma_data_direction sc_data_direction; 84 enum dma_data_direction sc_data_direction;
82 85
@@ -87,6 +90,8 @@ struct scsi_cmnd {
87 90
88 /* These elements define the operation we ultimately want to perform */ 91 /* These elements define the operation we ultimately want to perform */
89 struct scsi_data_buffer sdb; 92 struct scsi_data_buffer sdb;
93 struct scsi_data_buffer *prot_sdb;
94
90 unsigned underflow; /* Return error if less than 95 unsigned underflow; /* Return error if less than
91 this amount is transferred */ 96 this amount is transferred */
92 97
@@ -208,4 +213,85 @@ static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd,
208 buf, buflen); 213 buf, buflen);
209} 214}
210 215
216/*
217 * The operations below are hints that tell the controller driver how
218 * to handle I/Os with DIF or similar types of protection information.
219 */
220enum scsi_prot_operations {
221 /* Normal I/O */
222 SCSI_PROT_NORMAL = 0,
223
224 /* OS-HBA: Protected, HBA-Target: Unprotected */
225 SCSI_PROT_READ_INSERT,
226 SCSI_PROT_WRITE_STRIP,
227
228 /* OS-HBA: Unprotected, HBA-Target: Protected */
229 SCSI_PROT_READ_STRIP,
230 SCSI_PROT_WRITE_INSERT,
231
232 /* OS-HBA: Protected, HBA-Target: Protected */
233 SCSI_PROT_READ_PASS,
234 SCSI_PROT_WRITE_PASS,
235
236 /* OS-HBA: Protected, HBA-Target: Protected, checksum conversion */
237 SCSI_PROT_READ_CONVERT,
238 SCSI_PROT_WRITE_CONVERT,
239};
240
241static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op)
242{
243 scmd->prot_op = op;
244}
245
246static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
247{
248 return scmd->prot_op;
249}
250
251/*
252 * The controller usually does not know anything about the target it
253 * is communicating with. However, when DIX is enabled the controller
254 * must be know target type so it can verify the protection
255 * information passed along with the I/O.
256 */
257enum scsi_prot_target_type {
258 SCSI_PROT_DIF_TYPE0 = 0,
259 SCSI_PROT_DIF_TYPE1,
260 SCSI_PROT_DIF_TYPE2,
261 SCSI_PROT_DIF_TYPE3,
262};
263
264static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type)
265{
266 scmd->prot_type = type;
267}
268
269static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd)
270{
271 return scmd->prot_type;
272}
273
274static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd)
275{
276 return scmd->request->sector;
277}
278
279static inline unsigned scsi_prot_sg_count(struct scsi_cmnd *cmd)
280{
281 return cmd->prot_sdb ? cmd->prot_sdb->table.nents : 0;
282}
283
284static inline struct scatterlist *scsi_prot_sglist(struct scsi_cmnd *cmd)
285{
286 return cmd->prot_sdb ? cmd->prot_sdb->table.sgl : NULL;
287}
288
289static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
290{
291 return cmd->prot_sdb;
292}
293
294#define scsi_for_each_prot_sg(cmd, sg, nseg, __i) \
295 for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i)
296
211#endif /* _SCSI_SCSI_CMND_H */ 297#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 6467f78b191f..291d56a19167 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -140,7 +140,8 @@ struct scsi_device {
140 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 140 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
141 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ 141 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */
142 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 142 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
143 unsigned last_sector_bug:1; /* Always read last sector in a 1 sector read */ 143 unsigned last_sector_bug:1; /* do not use multisector accesses on
144 SD_LAST_BUGGY_SECTORS */
144 145
145 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ 146 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
146 struct list_head event_list; /* asserted events */ 147 struct list_head event_list; /* asserted events */
@@ -167,15 +168,22 @@ struct scsi_device {
167 unsigned long sdev_data[0]; 168 unsigned long sdev_data[0];
168} __attribute__((aligned(sizeof(unsigned long)))); 169} __attribute__((aligned(sizeof(unsigned long))));
169 170
171struct scsi_dh_devlist {
172 char *vendor;
173 char *model;
174};
175
170struct scsi_device_handler { 176struct scsi_device_handler {
171 /* Used by the infrastructure */ 177 /* Used by the infrastructure */
172 struct list_head list; /* list of scsi_device_handlers */ 178 struct list_head list; /* list of scsi_device_handlers */
173 struct notifier_block nb;
174 179
175 /* Filled by the hardware handler */ 180 /* Filled by the hardware handler */
176 struct module *module; 181 struct module *module;
177 const char *name; 182 const char *name;
183 const struct scsi_dh_devlist *devlist;
178 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); 184 int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
185 int (*attach)(struct scsi_device *);
186 void (*detach)(struct scsi_device *);
179 int (*activate)(struct scsi_device *); 187 int (*activate)(struct scsi_device *);
180 int (*prep_fn)(struct scsi_device *, struct request *); 188 int (*prep_fn)(struct scsi_device *, struct request *);
181}; 189};
@@ -416,6 +424,11 @@ static inline int scsi_device_enclosure(struct scsi_device *sdev)
416 return sdev->inquiry[6] & (1<<6); 424 return sdev->inquiry[6] & (1<<6);
417} 425}
418 426
427static inline int scsi_device_protection(struct scsi_device *sdev)
428{
429 return sdev->inquiry[5] & (1<<0);
430}
431
419#define MODULE_ALIAS_SCSI_DEVICE(type) \ 432#define MODULE_ALIAS_SCSI_DEVICE(type) \
420 MODULE_ALIAS("scsi:t-" __stringify(type) "*") 433 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
421#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" 434#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h
index 3ad2303d1a16..33efce20c26c 100644
--- a/include/scsi/scsi_dh.h
+++ b/include/scsi/scsi_dh.h
@@ -32,6 +32,7 @@ enum {
32 */ 32 */
33 SCSI_DH_DEV_FAILED, /* generic device error */ 33 SCSI_DH_DEV_FAILED, /* generic device error */
34 SCSI_DH_DEV_TEMP_BUSY, 34 SCSI_DH_DEV_TEMP_BUSY,
35 SCSI_DH_DEV_UNSUPP, /* device handler not supported */
35 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */ 36 SCSI_DH_DEVICE_MAX, /* max device blkerr definition */
36 37
37 /* 38 /*
@@ -57,6 +58,8 @@ enum {
57#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE) 58#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE)
58extern int scsi_dh_activate(struct request_queue *); 59extern int scsi_dh_activate(struct request_queue *);
59extern int scsi_dh_handler_exist(const char *); 60extern int scsi_dh_handler_exist(const char *);
61extern int scsi_dh_attach(struct request_queue *, const char *);
62extern void scsi_dh_detach(struct request_queue *);
60#else 63#else
61static inline int scsi_dh_activate(struct request_queue *req) 64static inline int scsi_dh_activate(struct request_queue *req)
62{ 65{
@@ -66,4 +69,12 @@ static inline int scsi_dh_handler_exist(const char *name)
66{ 69{
67 return 0; 70 return 0;
68} 71}
72static inline int scsi_dh_attach(struct request_queue *req, const char *name)
73{
74 return SCSI_DH_NOSYS;
75}
76static inline void scsi_dh_detach(struct request_queue *q)
77{
78 return;
79}
69#endif 80#endif
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 2a9add21267d..06a8790893ef 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -74,7 +74,9 @@ struct scsi_eh_save {
74 /* saved state */ 74 /* saved state */
75 int result; 75 int result;
76 enum dma_data_direction data_direction; 76 enum dma_data_direction data_direction;
77 unsigned underflow;
77 unsigned char cmd_len; 78 unsigned char cmd_len;
79 unsigned char prot_op;
78 unsigned char *cmnd; 80 unsigned char *cmnd;
79 struct scsi_data_buffer sdb; 81 struct scsi_data_buffer sdb;
80 struct request *next_rq; 82 struct request *next_rq;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index a594bac4a77d..44a55d1bf530 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -547,7 +547,7 @@ struct Scsi_Host {
547 unsigned int host_failed; /* commands that failed. */ 547 unsigned int host_failed; /* commands that failed. */
548 unsigned int host_eh_scheduled; /* EH scheduled without command */ 548 unsigned int host_eh_scheduled; /* EH scheduled without command */
549 549
550 unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ 550 unsigned int host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
551 int resetting; /* if set, it means that last_reset is a valid value */ 551 int resetting; /* if set, it means that last_reset is a valid value */
552 unsigned long last_reset; 552 unsigned long last_reset;
553 553
@@ -636,6 +636,10 @@ struct Scsi_Host {
636 */ 636 */
637 unsigned int max_host_blocked; 637 unsigned int max_host_blocked;
638 638
639 /* Protection Information */
640 unsigned int prot_capabilities;
641 unsigned char prot_guard_type;
642
639 /* 643 /*
640 * q used for scsi_tgt msgs, async events or any other requests that 644 * q used for scsi_tgt msgs, async events or any other requests that
641 * need to be processed in userspace 645 * need to be processed in userspace
@@ -756,6 +760,86 @@ extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
756extern void scsi_free_host_dev(struct scsi_device *); 760extern void scsi_free_host_dev(struct scsi_device *);
757extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *); 761extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *);
758 762
763/*
764 * DIF defines the exchange of protection information between
765 * initiator and SBC block device.
766 *
767 * DIX defines the exchange of protection information between OS and
768 * initiator.
769 */
770enum scsi_host_prot_capabilities {
771 SHOST_DIF_TYPE1_PROTECTION = 1 << 0, /* T10 DIF Type 1 */
772 SHOST_DIF_TYPE2_PROTECTION = 1 << 1, /* T10 DIF Type 2 */
773 SHOST_DIF_TYPE3_PROTECTION = 1 << 2, /* T10 DIF Type 3 */
774
775 SHOST_DIX_TYPE0_PROTECTION = 1 << 3, /* DIX between OS and HBA only */
776 SHOST_DIX_TYPE1_PROTECTION = 1 << 4, /* DIX with DIF Type 1 */
777 SHOST_DIX_TYPE2_PROTECTION = 1 << 5, /* DIX with DIF Type 2 */
778 SHOST_DIX_TYPE3_PROTECTION = 1 << 6, /* DIX with DIF Type 3 */
779};
780
781/*
782 * SCSI hosts which support the Data Integrity Extensions must
783 * indicate their capabilities by setting the prot_capabilities using
784 * this call.
785 */
786static inline void scsi_host_set_prot(struct Scsi_Host *shost, unsigned int mask)
787{
788 shost->prot_capabilities = mask;
789}
790
791static inline unsigned int scsi_host_get_prot(struct Scsi_Host *shost)
792{
793 return shost->prot_capabilities;
794}
795
796static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type)
797{
798 switch (target_type) {
799 case 1: return shost->prot_capabilities & SHOST_DIF_TYPE1_PROTECTION;
800 case 2: return shost->prot_capabilities & SHOST_DIF_TYPE2_PROTECTION;
801 case 3: return shost->prot_capabilities & SHOST_DIF_TYPE3_PROTECTION;
802 }
803
804 return 0;
805}
806
807static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsigned int target_type)
808{
809 switch (target_type) {
810 case 0: return shost->prot_capabilities & SHOST_DIX_TYPE0_PROTECTION;
811 case 1: return shost->prot_capabilities & SHOST_DIX_TYPE1_PROTECTION;
812 case 2: return shost->prot_capabilities & SHOST_DIX_TYPE2_PROTECTION;
813 case 3: return shost->prot_capabilities & SHOST_DIX_TYPE3_PROTECTION;
814 }
815
816 return 0;
817}
818
819/*
820 * All DIX-capable initiators must support the T10-mandated CRC
821 * checksum. Controllers can optionally implement the IP checksum
822 * scheme which has much lower impact on system performance. Note
823 * that the main rationale for the checksum is to match integrity
824 * metadata with data. Detecting bit errors are a job for ECC memory
825 * and buses.
826 */
827
828enum scsi_host_guard_type {
829 SHOST_DIX_GUARD_CRC = 1 << 0,
830 SHOST_DIX_GUARD_IP = 1 << 1,
831};
832
833static inline void scsi_host_set_guard(struct Scsi_Host *shost, unsigned char type)
834{
835 shost->prot_guard_type = type;
836}
837
838static inline unsigned char scsi_host_get_guard(struct Scsi_Host *shost)
839{
840 return shost->prot_guard_type;
841}
842
759/* legacy interfaces */ 843/* legacy interfaces */
760extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int); 844extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int);
761extern void scsi_unregister(struct Scsi_Host *); 845extern void scsi_unregister(struct Scsi_Host *);
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 1ccf462b433a..613173b5db69 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -22,6 +22,7 @@
22#ifndef __ATMEL_LCDC_H__ 22#ifndef __ATMEL_LCDC_H__
23#define __ATMEL_LCDC_H__ 23#define __ATMEL_LCDC_H__
24 24
25#include <linux/workqueue.h>
25 26
26/* Way LCD wires are connected to the chip: 27/* Way LCD wires are connected to the chip:
27 * Some Atmel chips use BGR color mode (instead of standard RGB) 28 * Some Atmel chips use BGR color mode (instead of standard RGB)
diff --git a/init/Kconfig b/init/Kconfig
index a50bdfed2df7..250e02c8f8f9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -171,7 +171,7 @@ config BSD_PROCESS_ACCT_V3
171 process and it's parent. Note that this file format is incompatible 171 process and it's parent. Note that this file format is incompatible
172 with previous v0/v1/v2 file formats, so you will need updated tools 172 with previous v0/v1/v2 file formats, so you will need updated tools
173 for processing it. A preliminary version of these tools is available 173 for processing it. A preliminary version of these tools is available
174 at <http://www.physik3.uni-rostock.de/tim/kernel/utils/acct/>. 174 at <http://www.gnu.org/software/acct/>.
175 175
176config TASKSTATS 176config TASKSTATS
177 bool "Export task/process statistics through netlink (EXPERIMENTAL)" 177 bool "Export task/process statistics through netlink (EXPERIMENTAL)"
@@ -486,7 +486,7 @@ config PID_NS
486 default n 486 default n
487 depends on NAMESPACES && EXPERIMENTAL 487 depends on NAMESPACES && EXPERIMENTAL
488 help 488 help
489 Suport process id namespaces. This allows having multiple 489 Support process id namespaces. This allows having multiple
490 process with the same pid as long as they are in different 490 process with the same pid as long as they are in different
491 pid namespaces. This is a building block of containers. 491 pid namespaces. This is a building block of containers.
492 492
@@ -802,6 +802,10 @@ config PROC_PAGE_MONITOR
802 802
803endmenu # General setup 803endmenu # General setup
804 804
805config HAVE_GENERIC_DMA_COHERENT
806 bool
807 default n
808
805config SLABINFO 809config SLABINFO
806 bool 810 bool
807 depends on PROC_FS 811 depends on PROC_FS
diff --git a/init/do_mounts.c b/init/do_mounts.c
index f769fac4f4c0..3715feb8446d 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -23,7 +23,7 @@
23int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */ 23int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */
24 24
25int root_mountflags = MS_RDONLY | MS_SILENT; 25int root_mountflags = MS_RDONLY | MS_SILENT;
26char * __initdata root_device_name; 26static char * __initdata root_device_name;
27static char __initdata saved_root_name[64]; 27static char __initdata saved_root_name[64];
28static int __initdata root_wait; 28static int __initdata root_wait;
29 29
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 735705d137ff..9aa968d54329 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -11,7 +11,6 @@ void change_floppy(char *fmt, ...);
11void mount_block_root(char *name, int flags); 11void mount_block_root(char *name, int flags);
12void mount_root(void); 12void mount_root(void);
13extern int root_mountflags; 13extern int root_mountflags;
14extern char *root_device_name;
15 14
16static inline int create_dev(char *name, dev_t dev) 15static inline int create_dev(char *name, dev_t dev)
17{ 16{
diff --git a/init/main.c b/init/main.c
index 0604cbcaf1e4..20fdc9884b77 100644
--- a/init/main.c
+++ b/init/main.c
@@ -743,13 +743,13 @@ static void __init do_one_initcall(initcall_t fn)
743} 743}
744 744
745 745
746extern initcall_t __initcall_start[], __initcall_end[]; 746extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
747 747
748static void __init do_initcalls(void) 748static void __init do_initcalls(void)
749{ 749{
750 initcall_t *call; 750 initcall_t *call;
751 751
752 for (call = __initcall_start; call < __initcall_end; call++) 752 for (call = __early_initcall_end; call < __initcall_end; call++)
753 do_one_initcall(*call); 753 do_one_initcall(*call);
754 754
755 /* Make sure there is no pending stuff from the initcall sequence */ 755 /* Make sure there is no pending stuff from the initcall sequence */
@@ -774,24 +774,12 @@ static void __init do_basic_setup(void)
774 do_initcalls(); 774 do_initcalls();
775} 775}
776 776
777static int __initdata nosoftlockup;
778
779static int __init nosoftlockup_setup(char *str)
780{
781 nosoftlockup = 1;
782 return 1;
783}
784__setup("nosoftlockup", nosoftlockup_setup);
785
786static void __init do_pre_smp_initcalls(void) 777static void __init do_pre_smp_initcalls(void)
787{ 778{
788 extern int spawn_ksoftirqd(void); 779 initcall_t *call;
789 780
790 init_call_single_data(); 781 for (call = __initcall_start; call < __early_initcall_end; call++)
791 migration_init(); 782 do_one_initcall(*call);
792 spawn_ksoftirqd();
793 if (!nosoftlockup)
794 spawn_softlockup_task();
795} 783}
796 784
797static void run_init_process(char *init_filename) 785static void run_init_process(char *init_filename)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 1fdc2eb2f6d8..96fb36cd9874 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -207,7 +207,7 @@ static int mqueue_get_sb(struct file_system_type *fs_type,
207 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt); 207 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt);
208} 208}
209 209
210static void init_once(struct kmem_cache *cachep, void *foo) 210static void init_once(void *foo)
211{ 211{
212 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo; 212 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo;
213 213
@@ -638,7 +638,7 @@ static int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
638 return ERR_PTR(-EINVAL); 638 return ERR_PTR(-EINVAL);
639 } 639 }
640 640
641 if (permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE], NULL)) { 641 if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) {
642 dput(dentry); 642 dput(dentry);
643 mntput(mqueue_mnt); 643 mntput(mqueue_mnt);
644 return ERR_PTR(-EACCES); 644 return ERR_PTR(-EACCES);
diff --git a/kernel/Makefile b/kernel/Makefile
index 54f69837d35a..4e1d7df7c3e2 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -84,6 +84,7 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
84obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o 84obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
85obj-$(CONFIG_MARKERS) += marker.o 85obj-$(CONFIG_MARKERS) += marker.o
86obj-$(CONFIG_LATENCYTOP) += latencytop.o 86obj-$(CONFIG_LATENCYTOP) += latencytop.o
87obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
87obj-$(CONFIG_FTRACE) += trace/ 88obj-$(CONFIG_FTRACE) += trace/
88obj-$(CONFIG_TRACING) += trace/ 89obj-$(CONFIG_TRACING) += trace/
89obj-$(CONFIG_SMP) += sched_cpupri.o 90obj-$(CONFIG_SMP) += sched_cpupri.o
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 66ec9fd21e0c..657f8f8d93a5 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -45,6 +45,7 @@
45#include <linux/delayacct.h> 45#include <linux/delayacct.h>
46#include <linux/cgroupstats.h> 46#include <linux/cgroupstats.h>
47#include <linux/hash.h> 47#include <linux/hash.h>
48#include <linux/namei.h>
48 49
49#include <asm/atomic.h> 50#include <asm/atomic.h>
50 51
@@ -1529,7 +1530,7 @@ static int cgroup_seqfile_show(struct seq_file *m, void *arg)
1529 return cft->read_seq_string(state->cgroup, cft, m); 1530 return cft->read_seq_string(state->cgroup, cft, m);
1530} 1531}
1531 1532
1532int cgroup_seqfile_release(struct inode *inode, struct file *file) 1533static int cgroup_seqfile_release(struct inode *inode, struct file *file)
1533{ 1534{
1534 struct seq_file *seq = file->private_data; 1535 struct seq_file *seq = file->private_data;
1535 kfree(seq->private); 1536 kfree(seq->private);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 10ba5f1004a5..e202a68d1cc1 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -216,7 +216,6 @@ static int __ref take_cpu_down(void *_param)
216static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) 216static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
217{ 217{
218 int err, nr_calls = 0; 218 int err, nr_calls = 0;
219 struct task_struct *p;
220 cpumask_t old_allowed, tmp; 219 cpumask_t old_allowed, tmp;
221 void *hcpu = (void *)(long)cpu; 220 void *hcpu = (void *)(long)cpu;
222 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 221 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0;
@@ -249,21 +248,18 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
249 cpus_setall(tmp); 248 cpus_setall(tmp);
250 cpu_clear(cpu, tmp); 249 cpu_clear(cpu, tmp);
251 set_cpus_allowed_ptr(current, &tmp); 250 set_cpus_allowed_ptr(current, &tmp);
251 tmp = cpumask_of_cpu(cpu);
252 252
253 p = __stop_machine_run(take_cpu_down, &tcd_param, cpu); 253 err = __stop_machine(take_cpu_down, &tcd_param, &tmp);
254 254 if (err) {
255 if (IS_ERR(p) || cpu_online(cpu)) {
256 /* CPU didn't die: tell everyone. Can't complain. */ 255 /* CPU didn't die: tell everyone. Can't complain. */
257 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, 256 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
258 hcpu) == NOTIFY_BAD) 257 hcpu) == NOTIFY_BAD)
259 BUG(); 258 BUG();
260 259
261 if (IS_ERR(p)) { 260 goto out_allowed;
262 err = PTR_ERR(p);
263 goto out_allowed;
264 }
265 goto out_thread;
266 } 261 }
262 BUG_ON(cpu_online(cpu));
267 263
268 /* Wait for it to sleep (leaving idle task). */ 264 /* Wait for it to sleep (leaving idle task). */
269 while (!idle_cpu(cpu)) 265 while (!idle_cpu(cpu))
@@ -279,8 +275,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
279 275
280 check_for_tasks(cpu); 276 check_for_tasks(cpu);
281 277
282out_thread:
283 err = kthread_stop(p);
284out_allowed: 278out_allowed:
285 set_cpus_allowed_ptr(current, &old_allowed); 279 set_cpus_allowed_ptr(current, &old_allowed);
286out_release: 280out_release:
@@ -461,3 +455,28 @@ out:
461#endif /* CONFIG_PM_SLEEP_SMP */ 455#endif /* CONFIG_PM_SLEEP_SMP */
462 456
463#endif /* CONFIG_SMP */ 457#endif /* CONFIG_SMP */
458
459/*
460 * cpu_bit_bitmap[] is a special, "compressed" data structure that
461 * represents all NR_CPUS bits binary values of 1<<nr.
462 *
463 * It is used by cpumask_of_cpu() to get a constant address to a CPU
464 * mask value that has a single bit set only.
465 */
466
467/* cpu_bit_bitmap[0] is empty - so we can back into it */
468#define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x)
469#define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1)
470#define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2)
471#define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
472
473const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
474
475 MASK_DECLARE_8(0), MASK_DECLARE_8(8),
476 MASK_DECLARE_8(16), MASK_DECLARE_8(24),
477#if BITS_PER_LONG > 32
478 MASK_DECLARE_8(32), MASK_DECLARE_8(40),
479 MASK_DECLARE_8(48), MASK_DECLARE_8(56),
480#endif
481};
482EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
diff --git a/kernel/dma-coherent.c b/kernel/dma-coherent.c
new file mode 100644
index 000000000000..7517115a8cce
--- /dev/null
+++ b/kernel/dma-coherent.c
@@ -0,0 +1,154 @@
1/*
2 * Coherent per-device memory handling.
3 * Borrowed from i386
4 */
5#include <linux/kernel.h>
6#include <linux/dma-mapping.h>
7
8struct dma_coherent_mem {
9 void *virt_base;
10 u32 device_base;
11 int size;
12 int flags;
13 unsigned long *bitmap;
14};
15
16int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
17 dma_addr_t device_addr, size_t size, int flags)
18{
19 void __iomem *mem_base = NULL;
20 int pages = size >> PAGE_SHIFT;
21 int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
22
23 if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
24 goto out;
25 if (!size)
26 goto out;
27 if (dev->dma_mem)
28 goto out;
29
30 /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
31
32 mem_base = ioremap(bus_addr, size);
33 if (!mem_base)
34 goto out;
35
36 dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
37 if (!dev->dma_mem)
38 goto out;
39 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
40 if (!dev->dma_mem->bitmap)
41 goto free1_out;
42
43 dev->dma_mem->virt_base = mem_base;
44 dev->dma_mem->device_base = device_addr;
45 dev->dma_mem->size = pages;
46 dev->dma_mem->flags = flags;
47
48 if (flags & DMA_MEMORY_MAP)
49 return DMA_MEMORY_MAP;
50
51 return DMA_MEMORY_IO;
52
53 free1_out:
54 kfree(dev->dma_mem);
55 out:
56 if (mem_base)
57 iounmap(mem_base);
58 return 0;
59}
60EXPORT_SYMBOL(dma_declare_coherent_memory);
61
62void dma_release_declared_memory(struct device *dev)
63{
64 struct dma_coherent_mem *mem = dev->dma_mem;
65
66 if (!mem)
67 return;
68 dev->dma_mem = NULL;
69 iounmap(mem->virt_base);
70 kfree(mem->bitmap);
71 kfree(mem);
72}
73EXPORT_SYMBOL(dma_release_declared_memory);
74
75void *dma_mark_declared_memory_occupied(struct device *dev,
76 dma_addr_t device_addr, size_t size)
77{
78 struct dma_coherent_mem *mem = dev->dma_mem;
79 int pos, err;
80 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1);
81
82 pages >>= PAGE_SHIFT;
83
84 if (!mem)
85 return ERR_PTR(-EINVAL);
86
87 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
88 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages));
89 if (err != 0)
90 return ERR_PTR(err);
91 return mem->virt_base + (pos << PAGE_SHIFT);
92}
93EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
94
95/**
96 * Try to allocate memory from the per-device coherent area.
97 *
98 * @dev: device from which we allocate memory
99 * @size: size of requested memory area
100 * @dma_handle: This will be filled with the correct dma handle
101 * @ret: This pointer will be filled with the virtual address
102 * to allocated area.
103 *
104 * This function should be only called from per-arch %dma_alloc_coherent()
105 * to support allocation from per-device coherent memory pools.
106 *
107 * Returns 0 if dma_alloc_coherent should continue with allocating from
108 * generic memory areas, or !0 if dma_alloc_coherent should return %ret.
109 */
110int dma_alloc_from_coherent(struct device *dev, ssize_t size,
111 dma_addr_t *dma_handle, void **ret)
112{
113 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
114 int order = get_order(size);
115
116 if (mem) {
117 int page = bitmap_find_free_region(mem->bitmap, mem->size,
118 order);
119 if (page >= 0) {
120 *dma_handle = mem->device_base + (page << PAGE_SHIFT);
121 *ret = mem->virt_base + (page << PAGE_SHIFT);
122 memset(*ret, 0, size);
123 } else if (mem->flags & DMA_MEMORY_EXCLUSIVE)
124 *ret = NULL;
125 }
126 return (mem != NULL);
127}
128
129/**
130 * Try to free the memory allocated from per-device coherent memory pool.
131 * @dev: device from which the memory was allocated
132 * @order: the order of pages allocated
133 * @vaddr: virtual address of allocated pages
134 *
135 * This checks whether the memory was allocated from the per-device
136 * coherent memory pool and if so, releases that memory.
137 *
138 * Returns 1 if we correctly released the memory, or 0 if
139 * %dma_release_coherent() should proceed with releasing memory from
140 * generic pools.
141 */
142int dma_release_from_coherent(struct device *dev, int order, void *vaddr)
143{
144 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
145
146 if (mem && vaddr >= mem->virt_base && vaddr <
147 (mem->virt_base + (mem->size << PAGE_SHIFT))) {
148 int page = (vaddr - mem->virt_base) >> PAGE_SHIFT;
149
150 bitmap_release_region(mem->bitmap, page, order);
151 return 1;
152 }
153 return 0;
154}
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index c1ef192aa655..0d407e886735 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -168,7 +168,6 @@ __set_personality(u_long personality)
168 current->personality = personality; 168 current->personality = personality;
169 oep = current_thread_info()->exec_domain; 169 oep = current_thread_info()->exec_domain;
170 current_thread_info()->exec_domain = ep; 170 current_thread_info()->exec_domain = ep;
171 set_fs_altroot();
172 171
173 module_put(oep->module); 172 module_put(oep->module);
174 return 0; 173 return 0;
diff --git a/kernel/exit.c b/kernel/exit.c
index ad933bb29ec7..eb4d6470d1d0 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -46,6 +46,7 @@
46#include <linux/resource.h> 46#include <linux/resource.h>
47#include <linux/blkdev.h> 47#include <linux/blkdev.h>
48#include <linux/task_io_accounting_ops.h> 48#include <linux/task_io_accounting_ops.h>
49#include <linux/tracehook.h>
49 50
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include <asm/unistd.h> 52#include <asm/unistd.h>
@@ -120,18 +121,7 @@ static void __exit_signal(struct task_struct *tsk)
120 sig->nivcsw += tsk->nivcsw; 121 sig->nivcsw += tsk->nivcsw;
121 sig->inblock += task_io_get_inblock(tsk); 122 sig->inblock += task_io_get_inblock(tsk);
122 sig->oublock += task_io_get_oublock(tsk); 123 sig->oublock += task_io_get_oublock(tsk);
123#ifdef CONFIG_TASK_XACCT 124 task_io_accounting_add(&sig->ioac, &tsk->ioac);
124 sig->rchar += tsk->rchar;
125 sig->wchar += tsk->wchar;
126 sig->syscr += tsk->syscr;
127 sig->syscw += tsk->syscw;
128#endif /* CONFIG_TASK_XACCT */
129#ifdef CONFIG_TASK_IO_ACCOUNTING
130 sig->ioac.read_bytes += tsk->ioac.read_bytes;
131 sig->ioac.write_bytes += tsk->ioac.write_bytes;
132 sig->ioac.cancelled_write_bytes +=
133 tsk->ioac.cancelled_write_bytes;
134#endif /* CONFIG_TASK_IO_ACCOUNTING */
135 sig->sum_sched_runtime += tsk->se.sum_exec_runtime; 125 sig->sum_sched_runtime += tsk->se.sum_exec_runtime;
136 sig = NULL; /* Marker for below. */ 126 sig = NULL; /* Marker for below. */
137 } 127 }
@@ -162,27 +152,17 @@ static void delayed_put_task_struct(struct rcu_head *rhp)
162 put_task_struct(container_of(rhp, struct task_struct, rcu)); 152 put_task_struct(container_of(rhp, struct task_struct, rcu));
163} 153}
164 154
165/*
166 * Do final ptrace-related cleanup of a zombie being reaped.
167 *
168 * Called with write_lock(&tasklist_lock) held.
169 */
170static void ptrace_release_task(struct task_struct *p)
171{
172 BUG_ON(!list_empty(&p->ptraced));
173 ptrace_unlink(p);
174 BUG_ON(!list_empty(&p->ptrace_entry));
175}
176 155
177void release_task(struct task_struct * p) 156void release_task(struct task_struct * p)
178{ 157{
179 struct task_struct *leader; 158 struct task_struct *leader;
180 int zap_leader; 159 int zap_leader;
181repeat: 160repeat:
161 tracehook_prepare_release_task(p);
182 atomic_dec(&p->user->processes); 162 atomic_dec(&p->user->processes);
183 proc_flush_task(p); 163 proc_flush_task(p);
184 write_lock_irq(&tasklist_lock); 164 write_lock_irq(&tasklist_lock);
185 ptrace_release_task(p); 165 tracehook_finish_release_task(p);
186 __exit_signal(p); 166 __exit_signal(p);
187 167
188 /* 168 /*
@@ -204,6 +184,13 @@ repeat:
204 * that case. 184 * that case.
205 */ 185 */
206 zap_leader = task_detached(leader); 186 zap_leader = task_detached(leader);
187
188 /*
189 * This maintains the invariant that release_task()
190 * only runs on a task in EXIT_DEAD, just for sanity.
191 */
192 if (zap_leader)
193 leader->exit_state = EXIT_DEAD;
207 } 194 }
208 195
209 write_unlock_irq(&tasklist_lock); 196 write_unlock_irq(&tasklist_lock);
@@ -567,8 +554,6 @@ void put_fs_struct(struct fs_struct *fs)
567 if (atomic_dec_and_test(&fs->count)) { 554 if (atomic_dec_and_test(&fs->count)) {
568 path_put(&fs->root); 555 path_put(&fs->root);
569 path_put(&fs->pwd); 556 path_put(&fs->pwd);
570 if (fs->altroot.dentry)
571 path_put(&fs->altroot);
572 kmem_cache_free(fs_cachep, fs); 557 kmem_cache_free(fs_cachep, fs);
573 } 558 }
574} 559}
@@ -887,7 +872,8 @@ static void forget_original_parent(struct task_struct *father)
887 */ 872 */
888static void exit_notify(struct task_struct *tsk, int group_dead) 873static void exit_notify(struct task_struct *tsk, int group_dead)
889{ 874{
890 int state; 875 int signal;
876 void *cookie;
891 877
892 /* 878 /*
893 * This does two things: 879 * This does two things:
@@ -924,22 +910,11 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
924 !capable(CAP_KILL)) 910 !capable(CAP_KILL))
925 tsk->exit_signal = SIGCHLD; 911 tsk->exit_signal = SIGCHLD;
926 912
927 /* If something other than our normal parent is ptracing us, then 913 signal = tracehook_notify_death(tsk, &cookie, group_dead);
928 * send it a SIGCHLD instead of honoring exit_signal. exit_signal 914 if (signal > 0)
929 * only has special meaning to our real parent. 915 signal = do_notify_parent(tsk, signal);
930 */
931 if (!task_detached(tsk) && thread_group_empty(tsk)) {
932 int signal = ptrace_reparented(tsk) ?
933 SIGCHLD : tsk->exit_signal;
934 do_notify_parent(tsk, signal);
935 } else if (tsk->ptrace) {
936 do_notify_parent(tsk, SIGCHLD);
937 }
938 916
939 state = EXIT_ZOMBIE; 917 tsk->exit_state = signal < 0 ? EXIT_DEAD : EXIT_ZOMBIE;
940 if (task_detached(tsk) && likely(!tsk->ptrace))
941 state = EXIT_DEAD;
942 tsk->exit_state = state;
943 918
944 /* mt-exec, de_thread() is waiting for us */ 919 /* mt-exec, de_thread() is waiting for us */
945 if (thread_group_leader(tsk) && 920 if (thread_group_leader(tsk) &&
@@ -949,8 +924,10 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
949 924
950 write_unlock_irq(&tasklist_lock); 925 write_unlock_irq(&tasklist_lock);
951 926
927 tracehook_report_death(tsk, signal, cookie, group_dead);
928
952 /* If the process is dead, release it - nobody will wait for it */ 929 /* If the process is dead, release it - nobody will wait for it */
953 if (state == EXIT_DEAD) 930 if (signal < 0)
954 release_task(tsk); 931 release_task(tsk);
955} 932}
956 933
@@ -1029,10 +1006,7 @@ NORET_TYPE void do_exit(long code)
1029 if (unlikely(!tsk->pid)) 1006 if (unlikely(!tsk->pid))
1030 panic("Attempted to kill the idle task!"); 1007 panic("Attempted to kill the idle task!");
1031 1008
1032 if (unlikely(current->ptrace & PT_TRACE_EXIT)) { 1009 tracehook_report_exit(&code);
1033 current->ptrace_message = code;
1034 ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
1035 }
1036 1010
1037 /* 1011 /*
1038 * We're taking recursive faults here in do_exit. Safest is to just 1012 * We're taking recursive faults here in do_exit. Safest is to just
@@ -1378,21 +1352,8 @@ static int wait_task_zombie(struct task_struct *p, int options,
1378 psig->coublock += 1352 psig->coublock +=
1379 task_io_get_oublock(p) + 1353 task_io_get_oublock(p) +
1380 sig->oublock + sig->coublock; 1354 sig->oublock + sig->coublock;
1381#ifdef CONFIG_TASK_XACCT 1355 task_io_accounting_add(&psig->ioac, &p->ioac);
1382 psig->rchar += p->rchar + sig->rchar; 1356 task_io_accounting_add(&psig->ioac, &sig->ioac);
1383 psig->wchar += p->wchar + sig->wchar;
1384 psig->syscr += p->syscr + sig->syscr;
1385 psig->syscw += p->syscw + sig->syscw;
1386#endif /* CONFIG_TASK_XACCT */
1387#ifdef CONFIG_TASK_IO_ACCOUNTING
1388 psig->ioac.read_bytes +=
1389 p->ioac.read_bytes + sig->ioac.read_bytes;
1390 psig->ioac.write_bytes +=
1391 p->ioac.write_bytes + sig->ioac.write_bytes;
1392 psig->ioac.cancelled_write_bytes +=
1393 p->ioac.cancelled_write_bytes +
1394 sig->ioac.cancelled_write_bytes;
1395#endif /* CONFIG_TASK_IO_ACCOUNTING */
1396 spin_unlock_irq(&p->parent->sighand->siglock); 1357 spin_unlock_irq(&p->parent->sighand->siglock);
1397 } 1358 }
1398 1359
diff --git a/kernel/fork.c b/kernel/fork.c
index b99d73e971a4..7ce2ebe84796 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -27,6 +27,7 @@
27#include <linux/key.h> 27#include <linux/key.h>
28#include <linux/binfmts.h> 28#include <linux/binfmts.h>
29#include <linux/mman.h> 29#include <linux/mman.h>
30#include <linux/mmu_notifier.h>
30#include <linux/fs.h> 31#include <linux/fs.h>
31#include <linux/nsproxy.h> 32#include <linux/nsproxy.h>
32#include <linux/capability.h> 33#include <linux/capability.h>
@@ -37,6 +38,7 @@
37#include <linux/swap.h> 38#include <linux/swap.h>
38#include <linux/syscalls.h> 39#include <linux/syscalls.h>
39#include <linux/jiffies.h> 40#include <linux/jiffies.h>
41#include <linux/tracehook.h>
40#include <linux/futex.h> 42#include <linux/futex.h>
41#include <linux/task_io_accounting_ops.h> 43#include <linux/task_io_accounting_ops.h>
42#include <linux/rcupdate.h> 44#include <linux/rcupdate.h>
@@ -413,6 +415,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
413 415
414 if (likely(!mm_alloc_pgd(mm))) { 416 if (likely(!mm_alloc_pgd(mm))) {
415 mm->def_flags = 0; 417 mm->def_flags = 0;
418 mmu_notifier_mm_init(mm);
416 return mm; 419 return mm;
417 } 420 }
418 421
@@ -445,6 +448,7 @@ void __mmdrop(struct mm_struct *mm)
445 BUG_ON(mm == &init_mm); 448 BUG_ON(mm == &init_mm);
446 mm_free_pgd(mm); 449 mm_free_pgd(mm);
447 destroy_context(mm); 450 destroy_context(mm);
451 mmu_notifier_mm_destroy(mm);
448 free_mm(mm); 452 free_mm(mm);
449} 453}
450EXPORT_SYMBOL_GPL(__mmdrop); 454EXPORT_SYMBOL_GPL(__mmdrop);
@@ -656,13 +660,6 @@ static struct fs_struct *__copy_fs_struct(struct fs_struct *old)
656 path_get(&old->root); 660 path_get(&old->root);
657 fs->pwd = old->pwd; 661 fs->pwd = old->pwd;
658 path_get(&old->pwd); 662 path_get(&old->pwd);
659 if (old->altroot.dentry) {
660 fs->altroot = old->altroot;
661 path_get(&old->altroot);
662 } else {
663 fs->altroot.mnt = NULL;
664 fs->altroot.dentry = NULL;
665 }
666 read_unlock(&old->lock); 663 read_unlock(&old->lock);
667 } 664 }
668 return fs; 665 return fs;
@@ -812,12 +809,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
812 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; 809 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
813 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; 810 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
814 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; 811 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0;
815#ifdef CONFIG_TASK_XACCT 812 task_io_accounting_init(&sig->ioac);
816 sig->rchar = sig->wchar = sig->syscr = sig->syscw = 0;
817#endif
818#ifdef CONFIG_TASK_IO_ACCOUNTING
819 memset(&sig->ioac, 0, sizeof(sig->ioac));
820#endif
821 sig->sum_sched_runtime = 0; 813 sig->sum_sched_runtime = 0;
822 INIT_LIST_HEAD(&sig->cpu_timers[0]); 814 INIT_LIST_HEAD(&sig->cpu_timers[0]);
823 INIT_LIST_HEAD(&sig->cpu_timers[1]); 815 INIT_LIST_HEAD(&sig->cpu_timers[1]);
@@ -865,8 +857,7 @@ static void copy_flags(unsigned long clone_flags, struct task_struct *p)
865 857
866 new_flags &= ~PF_SUPERPRIV; 858 new_flags &= ~PF_SUPERPRIV;
867 new_flags |= PF_FORKNOEXEC; 859 new_flags |= PF_FORKNOEXEC;
868 if (!(clone_flags & CLONE_PTRACE)) 860 new_flags |= PF_STARTING;
869 p->ptrace = 0;
870 p->flags = new_flags; 861 p->flags = new_flags;
871 clear_freeze_flag(p); 862 clear_freeze_flag(p);
872} 863}
@@ -907,7 +898,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
907 struct pt_regs *regs, 898 struct pt_regs *regs,
908 unsigned long stack_size, 899 unsigned long stack_size,
909 int __user *child_tidptr, 900 int __user *child_tidptr,
910 struct pid *pid) 901 struct pid *pid,
902 int trace)
911{ 903{
912 int retval; 904 int retval;
913 struct task_struct *p; 905 struct task_struct *p;
@@ -1000,13 +992,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1000 p->last_switch_timestamp = 0; 992 p->last_switch_timestamp = 0;
1001#endif 993#endif
1002 994
1003#ifdef CONFIG_TASK_XACCT 995 task_io_accounting_init(&p->ioac);
1004 p->rchar = 0; /* I/O counter: bytes read */
1005 p->wchar = 0; /* I/O counter: bytes written */
1006 p->syscr = 0; /* I/O counter: read syscalls */
1007 p->syscw = 0; /* I/O counter: write syscalls */
1008#endif
1009 task_io_accounting_init(p);
1010 acct_clear_integrals(p); 996 acct_clear_integrals(p);
1011 997
1012 p->it_virt_expires = cputime_zero; 998 p->it_virt_expires = cputime_zero;
@@ -1163,8 +1149,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1163 */ 1149 */
1164 p->group_leader = p; 1150 p->group_leader = p;
1165 INIT_LIST_HEAD(&p->thread_group); 1151 INIT_LIST_HEAD(&p->thread_group);
1166 INIT_LIST_HEAD(&p->ptrace_entry);
1167 INIT_LIST_HEAD(&p->ptraced);
1168 1152
1169 /* Now that the task is set up, run cgroup callbacks if 1153 /* Now that the task is set up, run cgroup callbacks if
1170 * necessary. We need to run them before the task is visible 1154 * necessary. We need to run them before the task is visible
@@ -1195,7 +1179,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1195 p->real_parent = current->real_parent; 1179 p->real_parent = current->real_parent;
1196 else 1180 else
1197 p->real_parent = current; 1181 p->real_parent = current;
1198 p->parent = p->real_parent;
1199 1182
1200 spin_lock(&current->sighand->siglock); 1183 spin_lock(&current->sighand->siglock);
1201 1184
@@ -1237,8 +1220,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1237 1220
1238 if (likely(p->pid)) { 1221 if (likely(p->pid)) {
1239 list_add_tail(&p->sibling, &p->real_parent->children); 1222 list_add_tail(&p->sibling, &p->real_parent->children);
1240 if (unlikely(p->ptrace & PT_PTRACED)) 1223 tracehook_finish_clone(p, clone_flags, trace);
1241 __ptrace_link(p, current->parent);
1242 1224
1243 if (thread_group_leader(p)) { 1225 if (thread_group_leader(p)) {
1244 if (clone_flags & CLONE_NEWPID) 1226 if (clone_flags & CLONE_NEWPID)
@@ -1323,29 +1305,13 @@ struct task_struct * __cpuinit fork_idle(int cpu)
1323 struct pt_regs regs; 1305 struct pt_regs regs;
1324 1306
1325 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, 1307 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL,
1326 &init_struct_pid); 1308 &init_struct_pid, 0);
1327 if (!IS_ERR(task)) 1309 if (!IS_ERR(task))
1328 init_idle(task, cpu); 1310 init_idle(task, cpu);
1329 1311
1330 return task; 1312 return task;
1331} 1313}
1332 1314
1333static int fork_traceflag(unsigned clone_flags)
1334{
1335 if (clone_flags & CLONE_UNTRACED)
1336 return 0;
1337 else if (clone_flags & CLONE_VFORK) {
1338 if (current->ptrace & PT_TRACE_VFORK)
1339 return PTRACE_EVENT_VFORK;
1340 } else if ((clone_flags & CSIGNAL) != SIGCHLD) {
1341 if (current->ptrace & PT_TRACE_CLONE)
1342 return PTRACE_EVENT_CLONE;
1343 } else if (current->ptrace & PT_TRACE_FORK)
1344 return PTRACE_EVENT_FORK;
1345
1346 return 0;
1347}
1348
1349/* 1315/*
1350 * Ok, this is the main fork-routine. 1316 * Ok, this is the main fork-routine.
1351 * 1317 *
@@ -1380,14 +1346,14 @@ long do_fork(unsigned long clone_flags,
1380 } 1346 }
1381 } 1347 }
1382 1348
1383 if (unlikely(current->ptrace)) { 1349 /*
1384 trace = fork_traceflag (clone_flags); 1350 * When called from kernel_thread, don't do user tracing stuff.
1385 if (trace) 1351 */
1386 clone_flags |= CLONE_PTRACE; 1352 if (likely(user_mode(regs)))
1387 } 1353 trace = tracehook_prepare_clone(clone_flags);
1388 1354
1389 p = copy_process(clone_flags, stack_start, regs, stack_size, 1355 p = copy_process(clone_flags, stack_start, regs, stack_size,
1390 child_tidptr, NULL); 1356 child_tidptr, NULL, trace);
1391 /* 1357 /*
1392 * Do this prior waking up the new thread - the thread pointer 1358 * Do this prior waking up the new thread - the thread pointer
1393 * might get invalid after that point, if the thread exits quickly. 1359 * might get invalid after that point, if the thread exits quickly.
@@ -1405,32 +1371,35 @@ long do_fork(unsigned long clone_flags,
1405 init_completion(&vfork); 1371 init_completion(&vfork);
1406 } 1372 }
1407 1373
1408 if ((p->ptrace & PT_PTRACED) || (clone_flags & CLONE_STOPPED)) { 1374 tracehook_report_clone(trace, regs, clone_flags, nr, p);
1375
1376 /*
1377 * We set PF_STARTING at creation in case tracing wants to
1378 * use this to distinguish a fully live task from one that
1379 * hasn't gotten to tracehook_report_clone() yet. Now we
1380 * clear it and set the child going.
1381 */
1382 p->flags &= ~PF_STARTING;
1383
1384 if (unlikely(clone_flags & CLONE_STOPPED)) {
1409 /* 1385 /*
1410 * We'll start up with an immediate SIGSTOP. 1386 * We'll start up with an immediate SIGSTOP.
1411 */ 1387 */
1412 sigaddset(&p->pending.signal, SIGSTOP); 1388 sigaddset(&p->pending.signal, SIGSTOP);
1413 set_tsk_thread_flag(p, TIF_SIGPENDING); 1389 set_tsk_thread_flag(p, TIF_SIGPENDING);
1414 }
1415
1416 if (!(clone_flags & CLONE_STOPPED))
1417 wake_up_new_task(p, clone_flags);
1418 else
1419 __set_task_state(p, TASK_STOPPED); 1390 __set_task_state(p, TASK_STOPPED);
1420 1391 } else {
1421 if (unlikely (trace)) { 1392 wake_up_new_task(p, clone_flags);
1422 current->ptrace_message = nr;
1423 ptrace_notify ((trace << 8) | SIGTRAP);
1424 } 1393 }
1425 1394
1395 tracehook_report_clone_complete(trace, regs,
1396 clone_flags, nr, p);
1397
1426 if (clone_flags & CLONE_VFORK) { 1398 if (clone_flags & CLONE_VFORK) {
1427 freezer_do_not_count(); 1399 freezer_do_not_count();
1428 wait_for_completion(&vfork); 1400 wait_for_completion(&vfork);
1429 freezer_count(); 1401 freezer_count();
1430 if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) { 1402 tracehook_report_vfork_done(p, nr);
1431 current->ptrace_message = nr;
1432 ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
1433 }
1434 } 1403 }
1435 } else { 1404 } else {
1436 nr = PTR_ERR(p); 1405 nr = PTR_ERR(p);
@@ -1442,7 +1411,7 @@ long do_fork(unsigned long clone_flags,
1442#define ARCH_MIN_MMSTRUCT_ALIGN 0 1411#define ARCH_MIN_MMSTRUCT_ALIGN 0
1443#endif 1412#endif
1444 1413
1445static void sighand_ctor(struct kmem_cache *cachep, void *data) 1414static void sighand_ctor(void *data)
1446{ 1415{
1447 struct sighand_struct *sighand = data; 1416 struct sighand_struct *sighand = data;
1448 1417
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 964964baefa2..3cd441ebf5d2 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -28,8 +28,7 @@ void dynamic_irq_init(unsigned int irq)
28 unsigned long flags; 28 unsigned long flags;
29 29
30 if (irq >= NR_IRQS) { 30 if (irq >= NR_IRQS) {
31 printk(KERN_ERR "Trying to initialize invalid IRQ%d\n", irq); 31 WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
32 WARN_ON(1);
33 return; 32 return;
34 } 33 }
35 34
@@ -62,8 +61,7 @@ void dynamic_irq_cleanup(unsigned int irq)
62 unsigned long flags; 61 unsigned long flags;
63 62
64 if (irq >= NR_IRQS) { 63 if (irq >= NR_IRQS) {
65 printk(KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq); 64 WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
66 WARN_ON(1);
67 return; 65 return;
68 } 66 }
69 67
@@ -71,9 +69,8 @@ void dynamic_irq_cleanup(unsigned int irq)
71 spin_lock_irqsave(&desc->lock, flags); 69 spin_lock_irqsave(&desc->lock, flags);
72 if (desc->action) { 70 if (desc->action) {
73 spin_unlock_irqrestore(&desc->lock, flags); 71 spin_unlock_irqrestore(&desc->lock, flags);
74 printk(KERN_ERR "Destroying IRQ%d without calling free_irq\n", 72 WARN(1, KERN_ERR "Destroying IRQ%d without calling free_irq\n",
75 irq); 73 irq);
76 WARN_ON(1);
77 return; 74 return;
78 } 75 }
79 desc->msi_desc = NULL; 76 desc->msi_desc = NULL;
@@ -96,8 +93,7 @@ int set_irq_chip(unsigned int irq, struct irq_chip *chip)
96 unsigned long flags; 93 unsigned long flags;
97 94
98 if (irq >= NR_IRQS) { 95 if (irq >= NR_IRQS) {
99 printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq); 96 WARN(1, KERN_ERR "Trying to install chip for IRQ%d\n", irq);
100 WARN_ON(1);
101 return -EINVAL; 97 return -EINVAL;
102 } 98 }
103 99
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 7d73e008fc3b..22d10d3189f8 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -184,8 +184,7 @@ static void __enable_irq(struct irq_desc *desc, unsigned int irq)
184{ 184{
185 switch (desc->depth) { 185 switch (desc->depth) {
186 case 0: 186 case 0:
187 printk(KERN_WARNING "Unbalanced enable for IRQ %d\n", irq); 187 WARN(1, KERN_WARNING "Unbalanced enable for IRQ %d\n", irq);
188 WARN_ON(1);
189 break; 188 break;
190 case 1: { 189 case 1: {
191 unsigned int status = desc->status & ~IRQ_DISABLED; 190 unsigned int status = desc->status & ~IRQ_DISABLED;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 1c5fcacbcf33..c8a4370e2a34 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -24,6 +24,12 @@
24#include <linux/utsrelease.h> 24#include <linux/utsrelease.h>
25#include <linux/utsname.h> 25#include <linux/utsname.h>
26#include <linux/numa.h> 26#include <linux/numa.h>
27#include <linux/suspend.h>
28#include <linux/device.h>
29#include <linux/freezer.h>
30#include <linux/pm.h>
31#include <linux/cpu.h>
32#include <linux/console.h>
27 33
28#include <asm/page.h> 34#include <asm/page.h>
29#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -242,6 +248,12 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
242 goto out; 248 goto out;
243 } 249 }
244 250
251 image->swap_page = kimage_alloc_control_pages(image, 0);
252 if (!image->swap_page) {
253 printk(KERN_ERR "Could not allocate swap buffer\n");
254 goto out;
255 }
256
245 result = 0; 257 result = 0;
246 out: 258 out:
247 if (result == 0) 259 if (result == 0)
@@ -589,14 +601,12 @@ static void kimage_free_extra_pages(struct kimage *image)
589 kimage_free_page_list(&image->unuseable_pages); 601 kimage_free_page_list(&image->unuseable_pages);
590 602
591} 603}
592static int kimage_terminate(struct kimage *image) 604static void kimage_terminate(struct kimage *image)
593{ 605{
594 if (*image->entry != 0) 606 if (*image->entry != 0)
595 image->entry++; 607 image->entry++;
596 608
597 *image->entry = IND_DONE; 609 *image->entry = IND_DONE;
598
599 return 0;
600} 610}
601 611
602#define for_each_kimage_entry(image, ptr, entry) \ 612#define for_each_kimage_entry(image, ptr, entry) \
@@ -988,6 +998,8 @@ asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
988 if (result) 998 if (result)
989 goto out; 999 goto out;
990 1000
1001 if (flags & KEXEC_PRESERVE_CONTEXT)
1002 image->preserve_context = 1;
991 result = machine_kexec_prepare(image); 1003 result = machine_kexec_prepare(image);
992 if (result) 1004 if (result)
993 goto out; 1005 goto out;
@@ -997,9 +1009,7 @@ asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
997 if (result) 1009 if (result)
998 goto out; 1010 goto out;
999 } 1011 }
1000 result = kimage_terminate(image); 1012 kimage_terminate(image);
1001 if (result)
1002 goto out;
1003 } 1013 }
1004 /* Install the new kernel, and Uninstall the old */ 1014 /* Install the new kernel, and Uninstall the old */
1005 image = xchg(dest_image, image); 1015 image = xchg(dest_image, image);
@@ -1415,3 +1425,85 @@ static int __init crash_save_vmcoreinfo_init(void)
1415} 1425}
1416 1426
1417module_init(crash_save_vmcoreinfo_init) 1427module_init(crash_save_vmcoreinfo_init)
1428
1429/**
1430 * kernel_kexec - reboot the system
1431 *
1432 * Move into place and start executing a preloaded standalone
1433 * executable. If nothing was preloaded return an error.
1434 */
1435int kernel_kexec(void)
1436{
1437 int error = 0;
1438
1439 if (xchg(&kexec_lock, 1))
1440 return -EBUSY;
1441 if (!kexec_image) {
1442 error = -EINVAL;
1443 goto Unlock;
1444 }
1445
1446 if (kexec_image->preserve_context) {
1447#ifdef CONFIG_KEXEC_JUMP
1448 mutex_lock(&pm_mutex);
1449 pm_prepare_console();
1450 error = freeze_processes();
1451 if (error) {
1452 error = -EBUSY;
1453 goto Restore_console;
1454 }
1455 suspend_console();
1456 error = device_suspend(PMSG_FREEZE);
1457 if (error)
1458 goto Resume_console;
1459 error = disable_nonboot_cpus();
1460 if (error)
1461 goto Resume_devices;
1462 local_irq_disable();
1463 /* At this point, device_suspend() has been called,
1464 * but *not* device_power_down(). We *must*
1465 * device_power_down() now. Otherwise, drivers for
1466 * some devices (e.g. interrupt controllers) become
1467 * desynchronized with the actual state of the
1468 * hardware at resume time, and evil weirdness ensues.
1469 */
1470 error = device_power_down(PMSG_FREEZE);
1471 if (error)
1472 goto Enable_irqs;
1473 save_processor_state();
1474#endif
1475 } else {
1476 blocking_notifier_call_chain(&reboot_notifier_list,
1477 SYS_RESTART, NULL);
1478 system_state = SYSTEM_RESTART;
1479 device_shutdown();
1480 sysdev_shutdown();
1481 printk(KERN_EMERG "Starting new kernel\n");
1482 machine_shutdown();
1483 }
1484
1485 machine_kexec(kexec_image);
1486
1487 if (kexec_image->preserve_context) {
1488#ifdef CONFIG_KEXEC_JUMP
1489 restore_processor_state();
1490 device_power_up(PMSG_RESTORE);
1491 Enable_irqs:
1492 local_irq_enable();
1493 enable_nonboot_cpus();
1494 Resume_devices:
1495 device_resume(PMSG_RESTORE);
1496 Resume_console:
1497 resume_console();
1498 thaw_processes();
1499 Restore_console:
1500 pm_restore_console();
1501 mutex_unlock(&pm_mutex);
1502#endif
1503 }
1504
1505 Unlock:
1506 xchg(&kexec_lock, 0);
1507
1508 return error;
1509}
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 6111c27491b1..96cff2f8710b 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -176,7 +176,7 @@ void kthread_bind(struct task_struct *k, unsigned int cpu)
176 return; 176 return;
177 } 177 }
178 /* Must have done schedule() in kthread() before we set_task_cpu */ 178 /* Must have done schedule() in kthread() before we set_task_cpu */
179 wait_task_inactive(k); 179 wait_task_inactive(k, 0);
180 set_task_cpu(k, cpu); 180 set_task_cpu(k, cpu);
181 k->cpus_allowed = cpumask_of_cpu(cpu); 181 k->cpus_allowed = cpumask_of_cpu(cpu);
182 k->rt.nr_cpus_allowed = 1; 182 k->rt.nr_cpus_allowed = 1;
diff --git a/kernel/module.c b/kernel/module.c
index d8b5605132a0..61d212120df4 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -325,18 +325,6 @@ static unsigned long find_symbol(const char *name,
325 return -ENOENT; 325 return -ENOENT;
326} 326}
327 327
328/* lookup symbol in given range of kernel_symbols */
329static const struct kernel_symbol *lookup_symbol(const char *name,
330 const struct kernel_symbol *start,
331 const struct kernel_symbol *stop)
332{
333 const struct kernel_symbol *ks = start;
334 for (; ks < stop; ks++)
335 if (strcmp(ks->name, name) == 0)
336 return ks;
337 return NULL;
338}
339
340/* Search for module by name: must hold module_mutex. */ 328/* Search for module by name: must hold module_mutex. */
341static struct module *find_module(const char *name) 329static struct module *find_module(const char *name)
342{ 330{
@@ -690,7 +678,7 @@ static int try_stop_module(struct module *mod, int flags, int *forced)
690 if (flags & O_NONBLOCK) { 678 if (flags & O_NONBLOCK) {
691 struct stopref sref = { mod, flags, forced }; 679 struct stopref sref = { mod, flags, forced };
692 680
693 return stop_machine_run(__try_stop_module, &sref, NR_CPUS); 681 return stop_machine(__try_stop_module, &sref, NULL);
694 } else { 682 } else {
695 /* We don't need to stop the machine for this. */ 683 /* We don't need to stop the machine for this. */
696 mod->state = MODULE_STATE_GOING; 684 mod->state = MODULE_STATE_GOING;
@@ -1428,7 +1416,7 @@ static int __unlink_module(void *_mod)
1428static void free_module(struct module *mod) 1416static void free_module(struct module *mod)
1429{ 1417{
1430 /* Delete from various lists */ 1418 /* Delete from various lists */
1431 stop_machine_run(__unlink_module, mod, NR_CPUS); 1419 stop_machine(__unlink_module, mod, NULL);
1432 remove_notes_attrs(mod); 1420 remove_notes_attrs(mod);
1433 remove_sect_attrs(mod); 1421 remove_sect_attrs(mod);
1434 mod_kobject_remove(mod); 1422 mod_kobject_remove(mod);
@@ -1703,6 +1691,19 @@ static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs,
1703} 1691}
1704 1692
1705#ifdef CONFIG_KALLSYMS 1693#ifdef CONFIG_KALLSYMS
1694
1695/* lookup symbol in given range of kernel_symbols */
1696static const struct kernel_symbol *lookup_symbol(const char *name,
1697 const struct kernel_symbol *start,
1698 const struct kernel_symbol *stop)
1699{
1700 const struct kernel_symbol *ks = start;
1701 for (; ks < stop; ks++)
1702 if (strcmp(ks->name, name) == 0)
1703 return ks;
1704 return NULL;
1705}
1706
1706static int is_exported(const char *name, const struct module *mod) 1707static int is_exported(const char *name, const struct module *mod)
1707{ 1708{
1708 if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab)) 1709 if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab))
@@ -2196,7 +2197,7 @@ static struct module *load_module(void __user *umod,
2196 /* Now sew it into the lists so we can get lockdep and oops 2197 /* Now sew it into the lists so we can get lockdep and oops
2197 * info during argument parsing. Noone should access us, since 2198 * info during argument parsing. Noone should access us, since
2198 * strong_try_module_get() will fail. */ 2199 * strong_try_module_get() will fail. */
2199 stop_machine_run(__link_module, mod, NR_CPUS); 2200 stop_machine(__link_module, mod, NULL);
2200 2201
2201 /* Size of section 0 is 0, so this works well if no params */ 2202 /* Size of section 0 is 0, so this works well if no params */
2202 err = parse_args(mod->name, mod->args, 2203 err = parse_args(mod->name, mod->args,
@@ -2230,7 +2231,7 @@ static struct module *load_module(void __user *umod,
2230 return mod; 2231 return mod;
2231 2232
2232 unlink: 2233 unlink:
2233 stop_machine_run(__unlink_module, mod, NR_CPUS); 2234 stop_machine(__unlink_module, mod, NULL);
2234 module_arch_cleanup(mod); 2235 module_arch_cleanup(mod);
2235 cleanup: 2236 cleanup:
2236 kobject_del(&mod->mkobj.kobj); 2237 kobject_del(&mod->mkobj.kobj);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 95bff23ecdaa..0b7476f5d2a6 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -635,6 +635,13 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
635 } 635 }
636 if (status < 0) 636 if (status < 0)
637 printk(err_suspend, status); 637 printk(err_suspend, status);
638
639 /* Some platforms can't detect that the alarm triggered the
640 * wakeup, or (accordingly) disable it after it afterwards.
641 * It's supposed to give oneshot behavior; cope.
642 */
643 alm.enabled = false;
644 rtc_set_alarm(rtc, &alm);
638} 645}
639 646
640static int __init has_wakealarm(struct device *dev, void *name_ptr) 647static int __init has_wakealarm(struct device *dev, void *name_ptr)
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 700f44ec8406..acc0c101dbd5 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -53,8 +53,6 @@ extern int hibernation_platform_enter(void);
53 53
54extern int pfn_is_nosave(unsigned long); 54extern int pfn_is_nosave(unsigned long);
55 55
56extern struct mutex pm_mutex;
57
58#define power_attr(_name) \ 56#define power_attr(_name) \
59static struct kobj_attribute _name##_attr = { \ 57static struct kobj_attribute _name##_attr = { \
60 .attr = { \ 58 .attr = { \
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 8392a9da6450..082b3fcb32a0 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -107,7 +107,7 @@ int ptrace_check_attach(struct task_struct *child, int kill)
107 read_unlock(&tasklist_lock); 107 read_unlock(&tasklist_lock);
108 108
109 if (!ret && !kill) 109 if (!ret && !kill)
110 wait_task_inactive(child); 110 ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;
111 111
112 /* All systems go.. */ 112 /* All systems go.. */
113 return ret; 113 return ret;
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
index 6f8696c502f4..aad93cdc9f68 100644
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@ -91,8 +91,8 @@ static void force_quiescent_state(struct rcu_data *rdp,
91 * rdp->cpu is the current cpu. 91 * rdp->cpu is the current cpu.
92 * 92 *
93 * cpu_online_map is updated by the _cpu_down() 93 * cpu_online_map is updated by the _cpu_down()
94 * using stop_machine_run(). Since we're in irqs disabled 94 * using __stop_machine(). Since we're in irqs disabled
95 * section, stop_machine_run() is not exectuting, hence 95 * section, __stop_machine() is not exectuting, hence
96 * the cpu_online_map is stable. 96 * the cpu_online_map is stable.
97 * 97 *
98 * However, a cpu might have been offlined _just_ before 98 * However, a cpu might have been offlined _just_ before
diff --git a/kernel/relay.c b/kernel/relay.c
index 7de644cdec43..04006ef970b8 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -407,6 +407,35 @@ void relay_reset(struct rchan *chan)
407} 407}
408EXPORT_SYMBOL_GPL(relay_reset); 408EXPORT_SYMBOL_GPL(relay_reset);
409 409
410static inline void relay_set_buf_dentry(struct rchan_buf *buf,
411 struct dentry *dentry)
412{
413 buf->dentry = dentry;
414 buf->dentry->d_inode->i_size = buf->early_bytes;
415}
416
417static struct dentry *relay_create_buf_file(struct rchan *chan,
418 struct rchan_buf *buf,
419 unsigned int cpu)
420{
421 struct dentry *dentry;
422 char *tmpname;
423
424 tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
425 if (!tmpname)
426 return NULL;
427 snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
428
429 /* Create file in fs */
430 dentry = chan->cb->create_buf_file(tmpname, chan->parent,
431 S_IRUSR, buf,
432 &chan->is_global);
433
434 kfree(tmpname);
435
436 return dentry;
437}
438
410/* 439/*
411 * relay_open_buf - create a new relay channel buffer 440 * relay_open_buf - create a new relay channel buffer
412 * 441 *
@@ -416,45 +445,34 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
416{ 445{
417 struct rchan_buf *buf = NULL; 446 struct rchan_buf *buf = NULL;
418 struct dentry *dentry; 447 struct dentry *dentry;
419 char *tmpname;
420 448
421 if (chan->is_global) 449 if (chan->is_global)
422 return chan->buf[0]; 450 return chan->buf[0];
423 451
424 tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
425 if (!tmpname)
426 goto end;
427 snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
428
429 buf = relay_create_buf(chan); 452 buf = relay_create_buf(chan);
430 if (!buf) 453 if (!buf)
431 goto free_name; 454 return NULL;
455
456 if (chan->has_base_filename) {
457 dentry = relay_create_buf_file(chan, buf, cpu);
458 if (!dentry)
459 goto free_buf;
460 relay_set_buf_dentry(buf, dentry);
461 }
432 462
433 buf->cpu = cpu; 463 buf->cpu = cpu;
434 __relay_reset(buf, 1); 464 __relay_reset(buf, 1);
435 465
436 /* Create file in fs */
437 dentry = chan->cb->create_buf_file(tmpname, chan->parent, S_IRUSR,
438 buf, &chan->is_global);
439 if (!dentry)
440 goto free_buf;
441
442 buf->dentry = dentry;
443
444 if(chan->is_global) { 466 if(chan->is_global) {
445 chan->buf[0] = buf; 467 chan->buf[0] = buf;
446 buf->cpu = 0; 468 buf->cpu = 0;
447 } 469 }
448 470
449 goto free_name; 471 return buf;
450 472
451free_buf: 473free_buf:
452 relay_destroy_buf(buf); 474 relay_destroy_buf(buf);
453 buf = NULL; 475 return NULL;
454free_name:
455 kfree(tmpname);
456end:
457 return buf;
458} 476}
459 477
460/** 478/**
@@ -537,8 +555,8 @@ static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
537 555
538/** 556/**
539 * relay_open - create a new relay channel 557 * relay_open - create a new relay channel
540 * @base_filename: base name of files to create 558 * @base_filename: base name of files to create, %NULL for buffering only
541 * @parent: dentry of parent directory, %NULL for root directory 559 * @parent: dentry of parent directory, %NULL for root directory or buffer
542 * @subbuf_size: size of sub-buffers 560 * @subbuf_size: size of sub-buffers
543 * @n_subbufs: number of sub-buffers 561 * @n_subbufs: number of sub-buffers
544 * @cb: client callback functions 562 * @cb: client callback functions
@@ -560,8 +578,6 @@ struct rchan *relay_open(const char *base_filename,
560{ 578{
561 unsigned int i; 579 unsigned int i;
562 struct rchan *chan; 580 struct rchan *chan;
563 if (!base_filename)
564 return NULL;
565 581
566 if (!(subbuf_size && n_subbufs)) 582 if (!(subbuf_size && n_subbufs))
567 return NULL; 583 return NULL;
@@ -576,7 +592,10 @@ struct rchan *relay_open(const char *base_filename,
576 chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs); 592 chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
577 chan->parent = parent; 593 chan->parent = parent;
578 chan->private_data = private_data; 594 chan->private_data = private_data;
579 strlcpy(chan->base_filename, base_filename, NAME_MAX); 595 if (base_filename) {
596 chan->has_base_filename = 1;
597 strlcpy(chan->base_filename, base_filename, NAME_MAX);
598 }
580 setup_callbacks(chan, cb); 599 setup_callbacks(chan, cb);
581 kref_init(&chan->kref); 600 kref_init(&chan->kref);
582 601
@@ -604,6 +623,94 @@ free_bufs:
604} 623}
605EXPORT_SYMBOL_GPL(relay_open); 624EXPORT_SYMBOL_GPL(relay_open);
606 625
626struct rchan_percpu_buf_dispatcher {
627 struct rchan_buf *buf;
628 struct dentry *dentry;
629};
630
631/* Called in atomic context. */
632static void __relay_set_buf_dentry(void *info)
633{
634 struct rchan_percpu_buf_dispatcher *p = info;
635
636 relay_set_buf_dentry(p->buf, p->dentry);
637}
638
639/**
640 * relay_late_setup_files - triggers file creation
641 * @chan: channel to operate on
642 * @base_filename: base name of files to create
643 * @parent: dentry of parent directory, %NULL for root directory
644 *
645 * Returns 0 if successful, non-zero otherwise.
646 *
647 * Use to setup files for a previously buffer-only channel.
648 * Useful to do early tracing in kernel, before VFS is up, for example.
649 */
650int relay_late_setup_files(struct rchan *chan,
651 const char *base_filename,
652 struct dentry *parent)
653{
654 int err = 0;
655 unsigned int i, curr_cpu;
656 unsigned long flags;
657 struct dentry *dentry;
658 struct rchan_percpu_buf_dispatcher disp;
659
660 if (!chan || !base_filename)
661 return -EINVAL;
662
663 strlcpy(chan->base_filename, base_filename, NAME_MAX);
664
665 mutex_lock(&relay_channels_mutex);
666 /* Is chan already set up? */
667 if (unlikely(chan->has_base_filename))
668 return -EEXIST;
669 chan->has_base_filename = 1;
670 chan->parent = parent;
671 curr_cpu = get_cpu();
672 /*
673 * The CPU hotplug notifier ran before us and created buffers with
674 * no files associated. So it's safe to call relay_setup_buf_file()
675 * on all currently online CPUs.
676 */
677 for_each_online_cpu(i) {
678 if (unlikely(!chan->buf[i])) {
679 printk(KERN_ERR "relay_late_setup_files: CPU %u "
680 "has no buffer, it must have!\n", i);
681 BUG();
682 err = -EINVAL;
683 break;
684 }
685
686 dentry = relay_create_buf_file(chan, chan->buf[i], i);
687 if (unlikely(!dentry)) {
688 err = -EINVAL;
689 break;
690 }
691
692 if (curr_cpu == i) {
693 local_irq_save(flags);
694 relay_set_buf_dentry(chan->buf[i], dentry);
695 local_irq_restore(flags);
696 } else {
697 disp.buf = chan->buf[i];
698 disp.dentry = dentry;
699 smp_mb();
700 /* relay_channels_mutex must be held, so wait. */
701 err = smp_call_function_single(i,
702 __relay_set_buf_dentry,
703 &disp, 1);
704 }
705 if (unlikely(err))
706 break;
707 }
708 put_cpu();
709 mutex_unlock(&relay_channels_mutex);
710
711 return err;
712}
713
607/** 714/**
608 * relay_switch_subbuf - switch to a new sub-buffer 715 * relay_switch_subbuf - switch to a new sub-buffer
609 * @buf: channel buffer 716 * @buf: channel buffer
@@ -627,8 +734,13 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
627 old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs; 734 old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
628 buf->padding[old_subbuf] = buf->prev_padding; 735 buf->padding[old_subbuf] = buf->prev_padding;
629 buf->subbufs_produced++; 736 buf->subbufs_produced++;
630 buf->dentry->d_inode->i_size += buf->chan->subbuf_size - 737 if (buf->dentry)
631 buf->padding[old_subbuf]; 738 buf->dentry->d_inode->i_size +=
739 buf->chan->subbuf_size -
740 buf->padding[old_subbuf];
741 else
742 buf->early_bytes += buf->chan->subbuf_size -
743 buf->padding[old_subbuf];
632 smp_mb(); 744 smp_mb();
633 if (waitqueue_active(&buf->read_wait)) 745 if (waitqueue_active(&buf->read_wait))
634 /* 746 /*
@@ -1237,4 +1349,4 @@ static __init int relay_init(void)
1237 return 0; 1349 return 0;
1238} 1350}
1239 1351
1240module_init(relay_init); 1352early_initcall(relay_init);
diff --git a/kernel/sched.c b/kernel/sched.c
index 0047bd9b96aa..0236958addcb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1867,16 +1867,24 @@ migrate_task(struct task_struct *p, int dest_cpu, struct migration_req *req)
1867/* 1867/*
1868 * wait_task_inactive - wait for a thread to unschedule. 1868 * wait_task_inactive - wait for a thread to unschedule.
1869 * 1869 *
1870 * If @match_state is nonzero, it's the @p->state value just checked and
1871 * not expected to change. If it changes, i.e. @p might have woken up,
1872 * then return zero. When we succeed in waiting for @p to be off its CPU,
1873 * we return a positive number (its total switch count). If a second call
1874 * a short while later returns the same number, the caller can be sure that
1875 * @p has remained unscheduled the whole time.
1876 *
1870 * The caller must ensure that the task *will* unschedule sometime soon, 1877 * The caller must ensure that the task *will* unschedule sometime soon,
1871 * else this function might spin for a *long* time. This function can't 1878 * else this function might spin for a *long* time. This function can't
1872 * be called with interrupts off, or it may introduce deadlock with 1879 * be called with interrupts off, or it may introduce deadlock with
1873 * smp_call_function() if an IPI is sent by the same process we are 1880 * smp_call_function() if an IPI is sent by the same process we are
1874 * waiting to become inactive. 1881 * waiting to become inactive.
1875 */ 1882 */
1876void wait_task_inactive(struct task_struct *p) 1883unsigned long wait_task_inactive(struct task_struct *p, long match_state)
1877{ 1884{
1878 unsigned long flags; 1885 unsigned long flags;
1879 int running, on_rq; 1886 int running, on_rq;
1887 unsigned long ncsw;
1880 struct rq *rq; 1888 struct rq *rq;
1881 1889
1882 for (;;) { 1890 for (;;) {
@@ -1899,8 +1907,11 @@ void wait_task_inactive(struct task_struct *p)
1899 * return false if the runqueue has changed and p 1907 * return false if the runqueue has changed and p
1900 * is actually now running somewhere else! 1908 * is actually now running somewhere else!
1901 */ 1909 */
1902 while (task_running(rq, p)) 1910 while (task_running(rq, p)) {
1911 if (match_state && unlikely(p->state != match_state))
1912 return 0;
1903 cpu_relax(); 1913 cpu_relax();
1914 }
1904 1915
1905 /* 1916 /*
1906 * Ok, time to look more closely! We need the rq 1917 * Ok, time to look more closely! We need the rq
@@ -1910,9 +1921,21 @@ void wait_task_inactive(struct task_struct *p)
1910 rq = task_rq_lock(p, &flags); 1921 rq = task_rq_lock(p, &flags);
1911 running = task_running(rq, p); 1922 running = task_running(rq, p);
1912 on_rq = p->se.on_rq; 1923 on_rq = p->se.on_rq;
1924 ncsw = 0;
1925 if (!match_state || p->state == match_state) {
1926 ncsw = p->nivcsw + p->nvcsw;
1927 if (unlikely(!ncsw))
1928 ncsw = 1;
1929 }
1913 task_rq_unlock(rq, &flags); 1930 task_rq_unlock(rq, &flags);
1914 1931
1915 /* 1932 /*
1933 * If it changed from the expected state, bail out now.
1934 */
1935 if (unlikely(!ncsw))
1936 break;
1937
1938 /*
1916 * Was it really running after all now that we 1939 * Was it really running after all now that we
1917 * checked with the proper locks actually held? 1940 * checked with the proper locks actually held?
1918 * 1941 *
@@ -1944,6 +1967,8 @@ void wait_task_inactive(struct task_struct *p)
1944 */ 1967 */
1945 break; 1968 break;
1946 } 1969 }
1970
1971 return ncsw;
1947} 1972}
1948 1973
1949/*** 1974/***
@@ -6389,7 +6414,7 @@ static struct notifier_block __cpuinitdata migration_notifier = {
6389 .priority = 10 6414 .priority = 10
6390}; 6415};
6391 6416
6392void __init migration_init(void) 6417static int __init migration_init(void)
6393{ 6418{
6394 void *cpu = (void *)(long)smp_processor_id(); 6419 void *cpu = (void *)(long)smp_processor_id();
6395 int err; 6420 int err;
@@ -6399,7 +6424,10 @@ void __init migration_init(void)
6399 BUG_ON(err == NOTIFY_BAD); 6424 BUG_ON(err == NOTIFY_BAD);
6400 migration_call(&migration_notifier, CPU_ONLINE, cpu); 6425 migration_call(&migration_notifier, CPU_ONLINE, cpu);
6401 register_cpu_notifier(&migration_notifier); 6426 register_cpu_notifier(&migration_notifier);
6427
6428 return err;
6402} 6429}
6430early_initcall(migration_init);
6403#endif 6431#endif
6404 6432
6405#ifdef CONFIG_SMP 6433#ifdef CONFIG_SMP
diff --git a/kernel/signal.c b/kernel/signal.c
index 82c3545596c5..954f77d7e3bc 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -22,6 +22,7 @@
22#include <linux/ptrace.h> 22#include <linux/ptrace.h>
23#include <linux/signal.h> 23#include <linux/signal.h>
24#include <linux/signalfd.h> 24#include <linux/signalfd.h>
25#include <linux/tracehook.h>
25#include <linux/capability.h> 26#include <linux/capability.h>
26#include <linux/freezer.h> 27#include <linux/freezer.h>
27#include <linux/pid_namespace.h> 28#include <linux/pid_namespace.h>
@@ -39,24 +40,21 @@
39 40
40static struct kmem_cache *sigqueue_cachep; 41static struct kmem_cache *sigqueue_cachep;
41 42
42static int __sig_ignored(struct task_struct *t, int sig) 43static void __user *sig_handler(struct task_struct *t, int sig)
43{ 44{
44 void __user *handler; 45 return t->sighand->action[sig - 1].sa.sa_handler;
46}
45 47
48static int sig_handler_ignored(void __user *handler, int sig)
49{
46 /* Is it explicitly or implicitly ignored? */ 50 /* Is it explicitly or implicitly ignored? */
47
48 handler = t->sighand->action[sig - 1].sa.sa_handler;
49 return handler == SIG_IGN || 51 return handler == SIG_IGN ||
50 (handler == SIG_DFL && sig_kernel_ignore(sig)); 52 (handler == SIG_DFL && sig_kernel_ignore(sig));
51} 53}
52 54
53static int sig_ignored(struct task_struct *t, int sig) 55static int sig_ignored(struct task_struct *t, int sig)
54{ 56{
55 /* 57 void __user *handler;
56 * Tracers always want to know about signals..
57 */
58 if (t->ptrace & PT_PTRACED)
59 return 0;
60 58
61 /* 59 /*
62 * Blocked signals are never ignored, since the 60 * Blocked signals are never ignored, since the
@@ -66,7 +64,14 @@ static int sig_ignored(struct task_struct *t, int sig)
66 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) 64 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
67 return 0; 65 return 0;
68 66
69 return __sig_ignored(t, sig); 67 handler = sig_handler(t, sig);
68 if (!sig_handler_ignored(handler, sig))
69 return 0;
70
71 /*
72 * Tracers may want to know about even ignored signals.
73 */
74 return !tracehook_consider_ignored_signal(t, sig, handler);
70} 75}
71 76
72/* 77/*
@@ -129,7 +134,9 @@ void recalc_sigpending_and_wake(struct task_struct *t)
129 134
130void recalc_sigpending(void) 135void recalc_sigpending(void)
131{ 136{
132 if (!recalc_sigpending_tsk(current) && !freezing(current)) 137 if (unlikely(tracehook_force_sigpending()))
138 set_thread_flag(TIF_SIGPENDING);
139 else if (!recalc_sigpending_tsk(current) && !freezing(current))
133 clear_thread_flag(TIF_SIGPENDING); 140 clear_thread_flag(TIF_SIGPENDING);
134 141
135} 142}
@@ -295,12 +302,12 @@ flush_signal_handlers(struct task_struct *t, int force_default)
295 302
296int unhandled_signal(struct task_struct *tsk, int sig) 303int unhandled_signal(struct task_struct *tsk, int sig)
297{ 304{
305 void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
298 if (is_global_init(tsk)) 306 if (is_global_init(tsk))
299 return 1; 307 return 1;
300 if (tsk->ptrace & PT_PTRACED) 308 if (handler != SIG_IGN && handler != SIG_DFL)
301 return 0; 309 return 0;
302 return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) || 310 return !tracehook_consider_fatal_signal(tsk, sig, handler);
303 (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
304} 311}
305 312
306 313
@@ -591,9 +598,6 @@ static int check_kill_permission(int sig, struct siginfo *info,
591 return security_task_kill(t, info, sig, 0); 598 return security_task_kill(t, info, sig, 0);
592} 599}
593 600
594/* forward decl */
595static void do_notify_parent_cldstop(struct task_struct *tsk, int why);
596
597/* 601/*
598 * Handle magic process-wide effects of stop/continue signals. Unlike 602 * Handle magic process-wide effects of stop/continue signals. Unlike
599 * the signal actions, these happen immediately at signal-generation 603 * the signal actions, these happen immediately at signal-generation
@@ -756,7 +760,8 @@ static void complete_signal(int sig, struct task_struct *p, int group)
756 if (sig_fatal(p, sig) && 760 if (sig_fatal(p, sig) &&
757 !(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) && 761 !(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) &&
758 !sigismember(&t->real_blocked, sig) && 762 !sigismember(&t->real_blocked, sig) &&
759 (sig == SIGKILL || !(t->ptrace & PT_PTRACED))) { 763 (sig == SIGKILL ||
764 !tracehook_consider_fatal_signal(t, sig, SIG_DFL))) {
760 /* 765 /*
761 * This signal will be fatal to the whole group. 766 * This signal will be fatal to the whole group.
762 */ 767 */
@@ -1323,9 +1328,11 @@ static inline void __wake_up_parent(struct task_struct *p,
1323/* 1328/*
1324 * Let a parent know about the death of a child. 1329 * Let a parent know about the death of a child.
1325 * For a stopped/continued status change, use do_notify_parent_cldstop instead. 1330 * For a stopped/continued status change, use do_notify_parent_cldstop instead.
1331 *
1332 * Returns -1 if our parent ignored us and so we've switched to
1333 * self-reaping, or else @sig.
1326 */ 1334 */
1327 1335int do_notify_parent(struct task_struct *tsk, int sig)
1328void do_notify_parent(struct task_struct *tsk, int sig)
1329{ 1336{
1330 struct siginfo info; 1337 struct siginfo info;
1331 unsigned long flags; 1338 unsigned long flags;
@@ -1396,12 +1403,14 @@ void do_notify_parent(struct task_struct *tsk, int sig)
1396 */ 1403 */
1397 tsk->exit_signal = -1; 1404 tsk->exit_signal = -1;
1398 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) 1405 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
1399 sig = 0; 1406 sig = -1;
1400 } 1407 }
1401 if (valid_signal(sig) && sig > 0) 1408 if (valid_signal(sig) && sig > 0)
1402 __group_send_sig_info(sig, &info, tsk->parent); 1409 __group_send_sig_info(sig, &info, tsk->parent);
1403 __wake_up_parent(tsk, tsk->parent); 1410 __wake_up_parent(tsk, tsk->parent);
1404 spin_unlock_irqrestore(&psig->siglock, flags); 1411 spin_unlock_irqrestore(&psig->siglock, flags);
1412
1413 return sig;
1405} 1414}
1406 1415
1407static void do_notify_parent_cldstop(struct task_struct *tsk, int why) 1416static void do_notify_parent_cldstop(struct task_struct *tsk, int why)
@@ -1599,7 +1608,7 @@ finish_stop(int stop_count)
1599 * a group stop in progress and we are the last to stop, 1608 * a group stop in progress and we are the last to stop,
1600 * report to the parent. When ptraced, every thread reports itself. 1609 * report to the parent. When ptraced, every thread reports itself.
1601 */ 1610 */
1602 if (stop_count == 0 || (current->ptrace & PT_PTRACED)) { 1611 if (tracehook_notify_jctl(stop_count == 0, CLD_STOPPED)) {
1603 read_lock(&tasklist_lock); 1612 read_lock(&tasklist_lock);
1604 do_notify_parent_cldstop(current, CLD_STOPPED); 1613 do_notify_parent_cldstop(current, CLD_STOPPED);
1605 read_unlock(&tasklist_lock); 1614 read_unlock(&tasklist_lock);
@@ -1735,6 +1744,9 @@ relock:
1735 signal->flags &= ~SIGNAL_CLD_MASK; 1744 signal->flags &= ~SIGNAL_CLD_MASK;
1736 spin_unlock_irq(&sighand->siglock); 1745 spin_unlock_irq(&sighand->siglock);
1737 1746
1747 if (unlikely(!tracehook_notify_jctl(1, why)))
1748 goto relock;
1749
1738 read_lock(&tasklist_lock); 1750 read_lock(&tasklist_lock);
1739 do_notify_parent_cldstop(current->group_leader, why); 1751 do_notify_parent_cldstop(current->group_leader, why);
1740 read_unlock(&tasklist_lock); 1752 read_unlock(&tasklist_lock);
@@ -1748,17 +1760,33 @@ relock:
1748 do_signal_stop(0)) 1760 do_signal_stop(0))
1749 goto relock; 1761 goto relock;
1750 1762
1751 signr = dequeue_signal(current, &current->blocked, info); 1763 /*
1752 if (!signr) 1764 * Tracing can induce an artifical signal and choose sigaction.
1753 break; /* will return 0 */ 1765 * The return value in @signr determines the default action,
1766 * but @info->si_signo is the signal number we will report.
1767 */
1768 signr = tracehook_get_signal(current, regs, info, return_ka);
1769 if (unlikely(signr < 0))
1770 goto relock;
1771 if (unlikely(signr != 0))
1772 ka = return_ka;
1773 else {
1774 signr = dequeue_signal(current, &current->blocked,
1775 info);
1754 1776
1755 if (signr != SIGKILL) {
1756 signr = ptrace_signal(signr, info, regs, cookie);
1757 if (!signr) 1777 if (!signr)
1758 continue; 1778 break; /* will return 0 */
1779
1780 if (signr != SIGKILL) {
1781 signr = ptrace_signal(signr, info,
1782 regs, cookie);
1783 if (!signr)
1784 continue;
1785 }
1786
1787 ka = &sighand->action[signr-1];
1759 } 1788 }
1760 1789
1761 ka = &sighand->action[signr-1];
1762 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ 1790 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */
1763 continue; 1791 continue;
1764 if (ka->sa.sa_handler != SIG_DFL) { 1792 if (ka->sa.sa_handler != SIG_DFL) {
@@ -1806,7 +1834,7 @@ relock:
1806 spin_lock_irq(&sighand->siglock); 1834 spin_lock_irq(&sighand->siglock);
1807 } 1835 }
1808 1836
1809 if (likely(do_signal_stop(signr))) { 1837 if (likely(do_signal_stop(info->si_signo))) {
1810 /* It released the siglock. */ 1838 /* It released the siglock. */
1811 goto relock; 1839 goto relock;
1812 } 1840 }
@@ -1827,7 +1855,7 @@ relock:
1827 1855
1828 if (sig_kernel_coredump(signr)) { 1856 if (sig_kernel_coredump(signr)) {
1829 if (print_fatal_signals) 1857 if (print_fatal_signals)
1830 print_fatal_signal(regs, signr); 1858 print_fatal_signal(regs, info->si_signo);
1831 /* 1859 /*
1832 * If it was able to dump core, this kills all 1860 * If it was able to dump core, this kills all
1833 * other threads in the group and synchronizes with 1861 * other threads in the group and synchronizes with
@@ -1836,13 +1864,13 @@ relock:
1836 * first and our do_group_exit call below will use 1864 * first and our do_group_exit call below will use
1837 * that value and ignore the one we pass it. 1865 * that value and ignore the one we pass it.
1838 */ 1866 */
1839 do_coredump((long)signr, signr, regs); 1867 do_coredump(info->si_signo, info->si_signo, regs);
1840 } 1868 }
1841 1869
1842 /* 1870 /*
1843 * Death signals, no core dump. 1871 * Death signals, no core dump.
1844 */ 1872 */
1845 do_group_exit(signr); 1873 do_group_exit(info->si_signo);
1846 /* NOTREACHED */ 1874 /* NOTREACHED */
1847 } 1875 }
1848 spin_unlock_irq(&sighand->siglock); 1876 spin_unlock_irq(&sighand->siglock);
@@ -1884,7 +1912,7 @@ void exit_signals(struct task_struct *tsk)
1884out: 1912out:
1885 spin_unlock_irq(&tsk->sighand->siglock); 1913 spin_unlock_irq(&tsk->sighand->siglock);
1886 1914
1887 if (unlikely(group_stop)) { 1915 if (unlikely(group_stop) && tracehook_notify_jctl(1, CLD_STOPPED)) {
1888 read_lock(&tasklist_lock); 1916 read_lock(&tasklist_lock);
1889 do_notify_parent_cldstop(tsk, CLD_STOPPED); 1917 do_notify_parent_cldstop(tsk, CLD_STOPPED);
1890 read_unlock(&tasklist_lock); 1918 read_unlock(&tasklist_lock);
@@ -1895,7 +1923,6 @@ EXPORT_SYMBOL(recalc_sigpending);
1895EXPORT_SYMBOL_GPL(dequeue_signal); 1923EXPORT_SYMBOL_GPL(dequeue_signal);
1896EXPORT_SYMBOL(flush_signals); 1924EXPORT_SYMBOL(flush_signals);
1897EXPORT_SYMBOL(force_sig); 1925EXPORT_SYMBOL(force_sig);
1898EXPORT_SYMBOL(ptrace_notify);
1899EXPORT_SYMBOL(send_sig); 1926EXPORT_SYMBOL(send_sig);
1900EXPORT_SYMBOL(send_sig_info); 1927EXPORT_SYMBOL(send_sig_info);
1901EXPORT_SYMBOL(sigprocmask); 1928EXPORT_SYMBOL(sigprocmask);
@@ -2299,7 +2326,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
2299 * (for example, SIGCHLD), shall cause the pending signal to 2326 * (for example, SIGCHLD), shall cause the pending signal to
2300 * be discarded, whether or not it is blocked" 2327 * be discarded, whether or not it is blocked"
2301 */ 2328 */
2302 if (__sig_ignored(t, sig)) { 2329 if (sig_handler_ignored(sig_handler(t, sig), sig)) {
2303 sigemptyset(&mask); 2330 sigemptyset(&mask);
2304 sigaddset(&mask, sig); 2331 sigaddset(&mask, sig);
2305 rm_from_queue_full(&mask, &t->signal->shared_pending); 2332 rm_from_queue_full(&mask, &t->signal->shared_pending);
diff --git a/kernel/smp.c b/kernel/smp.c
index 462c785ca1ee..96fc7c0edc59 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -33,7 +33,7 @@ struct call_single_queue {
33 spinlock_t lock; 33 spinlock_t lock;
34}; 34};
35 35
36void __cpuinit init_call_single_data(void) 36static int __cpuinit init_call_single_data(void)
37{ 37{
38 int i; 38 int i;
39 39
@@ -43,7 +43,9 @@ void __cpuinit init_call_single_data(void)
43 spin_lock_init(&q->lock); 43 spin_lock_init(&q->lock);
44 INIT_LIST_HEAD(&q->list); 44 INIT_LIST_HEAD(&q->list);
45 } 45 }
46 return 0;
46} 47}
48early_initcall(init_call_single_data);
47 49
48static void csd_flag_wait(struct call_single_data *data) 50static void csd_flag_wait(struct call_single_data *data)
49{ 51{
diff --git a/kernel/softirq.c b/kernel/softirq.c
index f6b03d56c2bf..c506f266a6b9 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -630,7 +630,7 @@ static struct notifier_block __cpuinitdata cpu_nfb = {
630 .notifier_call = cpu_callback 630 .notifier_call = cpu_callback
631}; 631};
632 632
633__init int spawn_ksoftirqd(void) 633static __init int spawn_ksoftirqd(void)
634{ 634{
635 void *cpu = (void *)(long)smp_processor_id(); 635 void *cpu = (void *)(long)smp_processor_id();
636 int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); 636 int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
@@ -640,6 +640,7 @@ __init int spawn_ksoftirqd(void)
640 register_cpu_notifier(&cpu_nfb); 640 register_cpu_notifier(&cpu_nfb);
641 return 0; 641 return 0;
642} 642}
643early_initcall(spawn_ksoftirqd);
643 644
644#ifdef CONFIG_SMP 645#ifdef CONFIG_SMP
645/* 646/*
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 7bd8d1aadd5d..b75b492fbfcf 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -338,14 +338,33 @@ static struct notifier_block __cpuinitdata cpu_nfb = {
338 .notifier_call = cpu_callback 338 .notifier_call = cpu_callback
339}; 339};
340 340
341__init void spawn_softlockup_task(void) 341static int __initdata nosoftlockup;
342
343static int __init nosoftlockup_setup(char *str)
344{
345 nosoftlockup = 1;
346 return 1;
347}
348__setup("nosoftlockup", nosoftlockup_setup);
349
350static int __init spawn_softlockup_task(void)
342{ 351{
343 void *cpu = (void *)(long)smp_processor_id(); 352 void *cpu = (void *)(long)smp_processor_id();
344 int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); 353 int err;
345 354
346 BUG_ON(err == NOTIFY_BAD); 355 if (nosoftlockup)
356 return 0;
357
358 err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
359 if (err == NOTIFY_BAD) {
360 BUG();
361 return 1;
362 }
347 cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); 363 cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
348 register_cpu_notifier(&cpu_nfb); 364 register_cpu_notifier(&cpu_nfb);
349 365
350 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 366 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
367
368 return 0;
351} 369}
370early_initcall(spawn_softlockup_task);
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 738b411ff2d3..e446c7c7d6a9 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -1,4 +1,4 @@
1/* Copyright 2005 Rusty Russell rusty@rustcorp.com.au IBM Corporation. 1/* Copyright 2008, 2005 Rusty Russell rusty@rustcorp.com.au IBM Corporation.
2 * GPL v2 and any later version. 2 * GPL v2 and any later version.
3 */ 3 */
4#include <linux/cpu.h> 4#include <linux/cpu.h>
@@ -13,204 +13,178 @@
13#include <asm/atomic.h> 13#include <asm/atomic.h>
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15 15
16/* Since we effect priority and affinity (both of which are visible 16/* This controls the threads on each CPU. */
17 * to, and settable by outside processes) we do indirection via a
18 * kthread. */
19
20/* Thread to stop each CPU in user context. */
21enum stopmachine_state { 17enum stopmachine_state {
22 STOPMACHINE_WAIT, 18 /* Dummy starting state for thread. */
19 STOPMACHINE_NONE,
20 /* Awaiting everyone to be scheduled. */
23 STOPMACHINE_PREPARE, 21 STOPMACHINE_PREPARE,
22 /* Disable interrupts. */
24 STOPMACHINE_DISABLE_IRQ, 23 STOPMACHINE_DISABLE_IRQ,
24 /* Run the function */
25 STOPMACHINE_RUN,
26 /* Exit */
25 STOPMACHINE_EXIT, 27 STOPMACHINE_EXIT,
26}; 28};
29static enum stopmachine_state state;
27 30
28static enum stopmachine_state stopmachine_state; 31struct stop_machine_data {
29static unsigned int stopmachine_num_threads; 32 int (*fn)(void *);
30static atomic_t stopmachine_thread_ack; 33 void *data;
31 34 int fnret;
32static int stopmachine(void *cpu) 35};
33{
34 int irqs_disabled = 0;
35 int prepared = 0;
36 cpumask_of_cpu_ptr(cpumask, (int)(long)cpu);
37
38 set_cpus_allowed_ptr(current, cpumask);
39
40 /* Ack: we are alive */
41 smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */
42 atomic_inc(&stopmachine_thread_ack);
43
44 /* Simple state machine */
45 while (stopmachine_state != STOPMACHINE_EXIT) {
46 if (stopmachine_state == STOPMACHINE_DISABLE_IRQ
47 && !irqs_disabled) {
48 local_irq_disable();
49 hard_irq_disable();
50 irqs_disabled = 1;
51 /* Ack: irqs disabled. */
52 smp_mb(); /* Must read state first. */
53 atomic_inc(&stopmachine_thread_ack);
54 } else if (stopmachine_state == STOPMACHINE_PREPARE
55 && !prepared) {
56 /* Everyone is in place, hold CPU. */
57 preempt_disable();
58 prepared = 1;
59 smp_mb(); /* Must read state first. */
60 atomic_inc(&stopmachine_thread_ack);
61 }
62 /* Yield in first stage: migration threads need to
63 * help our sisters onto their CPUs. */
64 if (!prepared && !irqs_disabled)
65 yield();
66 cpu_relax();
67 }
68
69 /* Ack: we are exiting. */
70 smp_mb(); /* Must read state first. */
71 atomic_inc(&stopmachine_thread_ack);
72
73 if (irqs_disabled)
74 local_irq_enable();
75 if (prepared)
76 preempt_enable();
77 36
78 return 0; 37/* Like num_online_cpus(), but hotplug cpu uses us, so we need this. */
79} 38static unsigned int num_threads;
39static atomic_t thread_ack;
40static struct completion finished;
41static DEFINE_MUTEX(lock);
80 42
81/* Change the thread state */ 43static void set_state(enum stopmachine_state newstate)
82static void stopmachine_set_state(enum stopmachine_state state)
83{ 44{
84 atomic_set(&stopmachine_thread_ack, 0); 45 /* Reset ack counter. */
46 atomic_set(&thread_ack, num_threads);
85 smp_wmb(); 47 smp_wmb();
86 stopmachine_state = state; 48 state = newstate;
87 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads)
88 cpu_relax();
89} 49}
90 50
91static int stop_machine(void) 51/* Last one to ack a state moves to the next state. */
52static void ack_state(void)
92{ 53{
93 int i, ret = 0; 54 if (atomic_dec_and_test(&thread_ack)) {
94 55 /* If we're the last one to ack the EXIT, we're finished. */
95 atomic_set(&stopmachine_thread_ack, 0); 56 if (state == STOPMACHINE_EXIT)
96 stopmachine_num_threads = 0; 57 complete(&finished);
97 stopmachine_state = STOPMACHINE_WAIT; 58 else
98 59 set_state(state + 1);
99 for_each_online_cpu(i) {
100 if (i == raw_smp_processor_id())
101 continue;
102 ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL);
103 if (ret < 0)
104 break;
105 stopmachine_num_threads++;
106 }
107
108 /* Wait for them all to come to life. */
109 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) {
110 yield();
111 cpu_relax();
112 } 60 }
61}
113 62
114 /* If some failed, kill them all. */ 63/* This is the actual thread which stops the CPU. It exits by itself rather
115 if (ret < 0) { 64 * than waiting for kthread_stop(), because it's easier for hotplug CPU. */
116 stopmachine_set_state(STOPMACHINE_EXIT); 65static int stop_cpu(struct stop_machine_data *smdata)
117 return ret; 66{
118 } 67 enum stopmachine_state curstate = STOPMACHINE_NONE;
68 int uninitialized_var(ret);
119 69
120 /* Now they are all started, make them hold the CPUs, ready. */ 70 /* Simple state machine */
121 preempt_disable(); 71 do {
122 stopmachine_set_state(STOPMACHINE_PREPARE); 72 /* Chill out and ensure we re-read stopmachine_state. */
73 cpu_relax();
74 if (state != curstate) {
75 curstate = state;
76 switch (curstate) {
77 case STOPMACHINE_DISABLE_IRQ:
78 local_irq_disable();
79 hard_irq_disable();
80 break;
81 case STOPMACHINE_RUN:
82 /* |= allows error detection if functions on
83 * multiple CPUs. */
84 smdata->fnret |= smdata->fn(smdata->data);
85 break;
86 default:
87 break;
88 }
89 ack_state();
90 }
91 } while (curstate != STOPMACHINE_EXIT);
123 92
124 /* Make them disable irqs. */ 93 local_irq_enable();
125 local_irq_disable(); 94 do_exit(0);
126 hard_irq_disable(); 95}
127 stopmachine_set_state(STOPMACHINE_DISABLE_IRQ);
128 96
97/* Callback for CPUs which aren't supposed to do anything. */
98static int chill(void *unused)
99{
129 return 0; 100 return 0;
130} 101}
131 102
132static void restart_machine(void) 103int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
133{ 104{
134 stopmachine_set_state(STOPMACHINE_EXIT); 105 int i, err;
135 local_irq_enable(); 106 struct stop_machine_data active, idle;
136 preempt_enable_no_resched(); 107 struct task_struct **threads;
137} 108
109 active.fn = fn;
110 active.data = data;
111 active.fnret = 0;
112 idle.fn = chill;
113 idle.data = NULL;
114
115 /* This could be too big for stack on large machines. */
116 threads = kcalloc(NR_CPUS, sizeof(threads[0]), GFP_KERNEL);
117 if (!threads)
118 return -ENOMEM;
119
120 /* Set up initial state. */
121 mutex_lock(&lock);
122 init_completion(&finished);
123 num_threads = num_online_cpus();
124 set_state(STOPMACHINE_PREPARE);
138 125
139struct stop_machine_data { 126 for_each_online_cpu(i) {
140 int (*fn)(void *); 127 struct stop_machine_data *smdata = &idle;
141 void *data; 128 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
142 struct completion done;
143};
144 129
145static int do_stop(void *_smdata) 130 if (!cpus) {
146{ 131 if (i == first_cpu(cpu_online_map))
147 struct stop_machine_data *smdata = _smdata; 132 smdata = &active;
148 int ret; 133 } else {
134 if (cpu_isset(i, *cpus))
135 smdata = &active;
136 }
149 137
150 ret = stop_machine(); 138 threads[i] = kthread_create((void *)stop_cpu, smdata, "kstop%u",
151 if (ret == 0) { 139 i);
152 ret = smdata->fn(smdata->data); 140 if (IS_ERR(threads[i])) {
153 restart_machine(); 141 err = PTR_ERR(threads[i]);
154 } 142 threads[i] = NULL;
143 goto kill_threads;
144 }
155 145
156 /* We're done: you can kthread_stop us now */ 146 /* Place it onto correct cpu. */
157 complete(&smdata->done); 147 kthread_bind(threads[i], i);
158 148
159 /* Wait for kthread_stop */ 149 /* Make it highest prio. */
160 set_current_state(TASK_INTERRUPTIBLE); 150 if (sched_setscheduler_nocheck(threads[i], SCHED_FIFO, &param))
161 while (!kthread_should_stop()) { 151 BUG();
162 schedule();
163 set_current_state(TASK_INTERRUPTIBLE);
164 } 152 }
165 __set_current_state(TASK_RUNNING);
166 return ret;
167}
168 153
169struct task_struct *__stop_machine_run(int (*fn)(void *), void *data, 154 /* We've created all the threads. Wake them all: hold this CPU so one
170 unsigned int cpu) 155 * doesn't hit this CPU until we're ready. */
171{ 156 get_cpu();
172 static DEFINE_MUTEX(stopmachine_mutex); 157 for_each_online_cpu(i)
173 struct stop_machine_data smdata; 158 wake_up_process(threads[i]);
174 struct task_struct *p;
175 159
176 smdata.fn = fn; 160 /* This will release the thread on our CPU. */
177 smdata.data = data; 161 put_cpu();
178 init_completion(&smdata.done); 162 wait_for_completion(&finished);
163 mutex_unlock(&lock);
179 164
180 mutex_lock(&stopmachine_mutex); 165 kfree(threads);
181 166
182 /* If they don't care which CPU fn runs on, bind to any online one. */ 167 return active.fnret;
183 if (cpu == NR_CPUS)
184 cpu = raw_smp_processor_id();
185 168
186 p = kthread_create(do_stop, &smdata, "kstopmachine"); 169kill_threads:
187 if (!IS_ERR(p)) { 170 for_each_online_cpu(i)
188 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 171 if (threads[i])
172 kthread_stop(threads[i]);
173 mutex_unlock(&lock);
189 174
190 /* One high-prio thread per cpu. We'll do this one. */ 175 kfree(threads);
191 sched_setscheduler_nocheck(p, SCHED_FIFO, &param); 176 return err;
192 kthread_bind(p, cpu);
193 wake_up_process(p);
194 wait_for_completion(&smdata.done);
195 }
196 mutex_unlock(&stopmachine_mutex);
197 return p;
198} 177}
199 178
200int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu) 179int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
201{ 180{
202 struct task_struct *p;
203 int ret; 181 int ret;
204 182
205 /* No CPUs can come up or down during this. */ 183 /* No CPUs can come up or down during this. */
206 get_online_cpus(); 184 get_online_cpus();
207 p = __stop_machine_run(fn, data, cpu); 185 ret = __stop_machine(fn, data, cpus);
208 if (!IS_ERR(p))
209 ret = kthread_stop(p);
210 else
211 ret = PTR_ERR(p);
212 put_online_cpus(); 186 put_online_cpus();
213 187
214 return ret; 188 return ret;
215} 189}
216EXPORT_SYMBOL_GPL(stop_machine_run); 190EXPORT_SYMBOL_GPL(stop_machine);
diff --git a/kernel/sys.c b/kernel/sys.c
index 0c9d3fa1f5ff..c01858090a98 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -301,26 +301,6 @@ void kernel_restart(char *cmd)
301} 301}
302EXPORT_SYMBOL_GPL(kernel_restart); 302EXPORT_SYMBOL_GPL(kernel_restart);
303 303
304/**
305 * kernel_kexec - reboot the system
306 *
307 * Move into place and start executing a preloaded standalone
308 * executable. If nothing was preloaded return an error.
309 */
310static void kernel_kexec(void)
311{
312#ifdef CONFIG_KEXEC
313 struct kimage *image;
314 image = xchg(&kexec_image, NULL);
315 if (!image)
316 return;
317 kernel_restart_prepare(NULL);
318 printk(KERN_EMERG "Starting new kernel\n");
319 machine_shutdown();
320 machine_kexec(image);
321#endif
322}
323
324static void kernel_shutdown_prepare(enum system_states state) 304static void kernel_shutdown_prepare(enum system_states state)
325{ 305{
326 blocking_notifier_call_chain(&reboot_notifier_list, 306 blocking_notifier_call_chain(&reboot_notifier_list,
@@ -425,10 +405,15 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
425 kernel_restart(buffer); 405 kernel_restart(buffer);
426 break; 406 break;
427 407
408#ifdef CONFIG_KEXEC
428 case LINUX_REBOOT_CMD_KEXEC: 409 case LINUX_REBOOT_CMD_KEXEC:
429 kernel_kexec(); 410 {
430 unlock_kernel(); 411 int ret;
431 return -EINVAL; 412 ret = kernel_kexec();
413 unlock_kernel();
414 return ret;
415 }
416#endif
432 417
433#ifdef CONFIG_HIBERNATION 418#ifdef CONFIG_HIBERNATION
434 case LINUX_REBOOT_CMD_SW_SUSPEND: 419 case LINUX_REBOOT_CMD_SW_SUSPEND:
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 35a50db9b6ce..fe4713347275 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -160,12 +160,13 @@ static struct ctl_table root_table[];
160static struct ctl_table_root sysctl_table_root; 160static struct ctl_table_root sysctl_table_root;
161static struct ctl_table_header root_table_header = { 161static struct ctl_table_header root_table_header = {
162 .ctl_table = root_table, 162 .ctl_table = root_table,
163 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.header_list), 163 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
164 .root = &sysctl_table_root, 164 .root = &sysctl_table_root,
165 .set = &sysctl_table_root.default_set,
165}; 166};
166static struct ctl_table_root sysctl_table_root = { 167static struct ctl_table_root sysctl_table_root = {
167 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 168 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
168 .header_list = LIST_HEAD_INIT(root_table_header.ctl_entry), 169 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
169}; 170};
170 171
171static struct ctl_table kern_table[]; 172static struct ctl_table kern_table[];
@@ -1386,6 +1387,9 @@ static void start_unregistering(struct ctl_table_header *p)
1386 spin_unlock(&sysctl_lock); 1387 spin_unlock(&sysctl_lock);
1387 wait_for_completion(&wait); 1388 wait_for_completion(&wait);
1388 spin_lock(&sysctl_lock); 1389 spin_lock(&sysctl_lock);
1390 } else {
1391 /* anything non-NULL; we'll never dereference it */
1392 p->unregistering = ERR_PTR(-EINVAL);
1389 } 1393 }
1390 /* 1394 /*
1391 * do not remove from the list until nobody holds it; walking the 1395 * do not remove from the list until nobody holds it; walking the
@@ -1394,6 +1398,32 @@ static void start_unregistering(struct ctl_table_header *p)
1394 list_del_init(&p->ctl_entry); 1398 list_del_init(&p->ctl_entry);
1395} 1399}
1396 1400
1401void sysctl_head_get(struct ctl_table_header *head)
1402{
1403 spin_lock(&sysctl_lock);
1404 head->count++;
1405 spin_unlock(&sysctl_lock);
1406}
1407
1408void sysctl_head_put(struct ctl_table_header *head)
1409{
1410 spin_lock(&sysctl_lock);
1411 if (!--head->count)
1412 kfree(head);
1413 spin_unlock(&sysctl_lock);
1414}
1415
1416struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1417{
1418 if (!head)
1419 BUG();
1420 spin_lock(&sysctl_lock);
1421 if (!use_table(head))
1422 head = ERR_PTR(-ENOENT);
1423 spin_unlock(&sysctl_lock);
1424 return head;
1425}
1426
1397void sysctl_head_finish(struct ctl_table_header *head) 1427void sysctl_head_finish(struct ctl_table_header *head)
1398{ 1428{
1399 if (!head) 1429 if (!head)
@@ -1403,14 +1433,20 @@ void sysctl_head_finish(struct ctl_table_header *head)
1403 spin_unlock(&sysctl_lock); 1433 spin_unlock(&sysctl_lock);
1404} 1434}
1405 1435
1436static struct ctl_table_set *
1437lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1438{
1439 struct ctl_table_set *set = &root->default_set;
1440 if (root->lookup)
1441 set = root->lookup(root, namespaces);
1442 return set;
1443}
1444
1406static struct list_head * 1445static struct list_head *
1407lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1446lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1408{ 1447{
1409 struct list_head *header_list; 1448 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1410 header_list = &root->header_list; 1449 return &set->list;
1411 if (root->lookup)
1412 header_list = root->lookup(root, namespaces);
1413 return header_list;
1414} 1450}
1415 1451
1416struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1452struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
@@ -1480,9 +1516,9 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
1480 int op = 0, rc; 1516 int op = 0, rc;
1481 1517
1482 if (oldval) 1518 if (oldval)
1483 op |= 004; 1519 op |= MAY_READ;
1484 if (newval) 1520 if (newval)
1485 op |= 002; 1521 op |= MAY_WRITE;
1486 if (sysctl_perm(root, table, op)) 1522 if (sysctl_perm(root, table, op))
1487 return -EPERM; 1523 return -EPERM;
1488 1524
@@ -1524,7 +1560,7 @@ repeat:
1524 if (n == table->ctl_name) { 1560 if (n == table->ctl_name) {
1525 int error; 1561 int error;
1526 if (table->child) { 1562 if (table->child) {
1527 if (sysctl_perm(root, table, 001)) 1563 if (sysctl_perm(root, table, MAY_EXEC))
1528 return -EPERM; 1564 return -EPERM;
1529 name++; 1565 name++;
1530 nlen--; 1566 nlen--;
@@ -1599,7 +1635,7 @@ static int test_perm(int mode, int op)
1599 mode >>= 6; 1635 mode >>= 6;
1600 else if (in_egroup_p(0)) 1636 else if (in_egroup_p(0))
1601 mode >>= 3; 1637 mode >>= 3;
1602 if ((mode & op & 0007) == op) 1638 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
1603 return 0; 1639 return 0;
1604 return -EACCES; 1640 return -EACCES;
1605} 1641}
@@ -1609,7 +1645,7 @@ int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
1609 int error; 1645 int error;
1610 int mode; 1646 int mode;
1611 1647
1612 error = security_sysctl(table, op); 1648 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
1613 if (error) 1649 if (error)
1614 return error; 1650 return error;
1615 1651
@@ -1644,6 +1680,54 @@ static __init int sysctl_init(void)
1644 1680
1645core_initcall(sysctl_init); 1681core_initcall(sysctl_init);
1646 1682
1683static struct ctl_table *is_branch_in(struct ctl_table *branch,
1684 struct ctl_table *table)
1685{
1686 struct ctl_table *p;
1687 const char *s = branch->procname;
1688
1689 /* branch should have named subdirectory as its first element */
1690 if (!s || !branch->child)
1691 return NULL;
1692
1693 /* ... and nothing else */
1694 if (branch[1].procname || branch[1].ctl_name)
1695 return NULL;
1696
1697 /* table should contain subdirectory with the same name */
1698 for (p = table; p->procname || p->ctl_name; p++) {
1699 if (!p->child)
1700 continue;
1701 if (p->procname && strcmp(p->procname, s) == 0)
1702 return p;
1703 }
1704 return NULL;
1705}
1706
1707/* see if attaching q to p would be an improvement */
1708static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1709{
1710 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1711 struct ctl_table *next;
1712 int is_better = 0;
1713 int not_in_parent = !p->attached_by;
1714
1715 while ((next = is_branch_in(by, to)) != NULL) {
1716 if (by == q->attached_by)
1717 is_better = 1;
1718 if (to == p->attached_by)
1719 not_in_parent = 1;
1720 by = by->child;
1721 to = next->child;
1722 }
1723
1724 if (is_better && not_in_parent) {
1725 q->attached_by = by;
1726 q->attached_to = to;
1727 q->parent = p;
1728 }
1729}
1730
1647/** 1731/**
1648 * __register_sysctl_paths - register a sysctl hierarchy 1732 * __register_sysctl_paths - register a sysctl hierarchy
1649 * @root: List of sysctl headers to register on 1733 * @root: List of sysctl headers to register on
@@ -1720,10 +1804,10 @@ struct ctl_table_header *__register_sysctl_paths(
1720 struct nsproxy *namespaces, 1804 struct nsproxy *namespaces,
1721 const struct ctl_path *path, struct ctl_table *table) 1805 const struct ctl_path *path, struct ctl_table *table)
1722{ 1806{
1723 struct list_head *header_list;
1724 struct ctl_table_header *header; 1807 struct ctl_table_header *header;
1725 struct ctl_table *new, **prevp; 1808 struct ctl_table *new, **prevp;
1726 unsigned int n, npath; 1809 unsigned int n, npath;
1810 struct ctl_table_set *set;
1727 1811
1728 /* Count the path components */ 1812 /* Count the path components */
1729 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) 1813 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
@@ -1765,6 +1849,7 @@ struct ctl_table_header *__register_sysctl_paths(
1765 header->unregistering = NULL; 1849 header->unregistering = NULL;
1766 header->root = root; 1850 header->root = root;
1767 sysctl_set_parent(NULL, header->ctl_table); 1851 sysctl_set_parent(NULL, header->ctl_table);
1852 header->count = 1;
1768#ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1853#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1769 if (sysctl_check_table(namespaces, header->ctl_table)) { 1854 if (sysctl_check_table(namespaces, header->ctl_table)) {
1770 kfree(header); 1855 kfree(header);
@@ -1772,8 +1857,20 @@ struct ctl_table_header *__register_sysctl_paths(
1772 } 1857 }
1773#endif 1858#endif
1774 spin_lock(&sysctl_lock); 1859 spin_lock(&sysctl_lock);
1775 header_list = lookup_header_list(root, namespaces); 1860 header->set = lookup_header_set(root, namespaces);
1776 list_add_tail(&header->ctl_entry, header_list); 1861 header->attached_by = header->ctl_table;
1862 header->attached_to = root_table;
1863 header->parent = &root_table_header;
1864 for (set = header->set; set; set = set->parent) {
1865 struct ctl_table_header *p;
1866 list_for_each_entry(p, &set->list, ctl_entry) {
1867 if (p->unregistering)
1868 continue;
1869 try_attach(p, header);
1870 }
1871 }
1872 header->parent->count++;
1873 list_add_tail(&header->ctl_entry, &header->set->list);
1777 spin_unlock(&sysctl_lock); 1874 spin_unlock(&sysctl_lock);
1778 1875
1779 return header; 1876 return header;
@@ -1828,8 +1925,37 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1828 1925
1829 spin_lock(&sysctl_lock); 1926 spin_lock(&sysctl_lock);
1830 start_unregistering(header); 1927 start_unregistering(header);
1928 if (!--header->parent->count) {
1929 WARN_ON(1);
1930 kfree(header->parent);
1931 }
1932 if (!--header->count)
1933 kfree(header);
1831 spin_unlock(&sysctl_lock); 1934 spin_unlock(&sysctl_lock);
1832 kfree(header); 1935}
1936
1937int sysctl_is_seen(struct ctl_table_header *p)
1938{
1939 struct ctl_table_set *set = p->set;
1940 int res;
1941 spin_lock(&sysctl_lock);
1942 if (p->unregistering)
1943 res = 0;
1944 else if (!set->is_seen)
1945 res = 1;
1946 else
1947 res = set->is_seen(set);
1948 spin_unlock(&sysctl_lock);
1949 return res;
1950}
1951
1952void setup_sysctl_set(struct ctl_table_set *p,
1953 struct ctl_table_set *parent,
1954 int (*is_seen)(struct ctl_table_set *))
1955{
1956 INIT_LIST_HEAD(&p->list);
1957 p->parent = parent ? parent : &sysctl_table_root.default_set;
1958 p->is_seen = is_seen;
1833} 1959}
1834 1960
1835#else /* !CONFIG_SYSCTL */ 1961#else /* !CONFIG_SYSCTL */
@@ -1848,6 +1974,16 @@ void unregister_sysctl_table(struct ctl_table_header * table)
1848{ 1974{
1849} 1975}
1850 1976
1977void setup_sysctl_set(struct ctl_table_set *p,
1978 struct ctl_table_set *parent,
1979 int (*is_seen)(struct ctl_table_set *))
1980{
1981}
1982
1983void sysctl_head_put(struct ctl_table_header *head)
1984{
1985}
1986
1851#endif /* CONFIG_SYSCTL */ 1987#endif /* CONFIG_SYSCTL */
1852 1988
1853/* 1989/*
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index bf43284d6855..80c4336f4188 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -196,12 +196,10 @@ static int tick_check_new_device(struct clock_event_device *newdev)
196 struct tick_device *td; 196 struct tick_device *td;
197 int cpu, ret = NOTIFY_OK; 197 int cpu, ret = NOTIFY_OK;
198 unsigned long flags; 198 unsigned long flags;
199 cpumask_of_cpu_ptr_declare(cpumask);
200 199
201 spin_lock_irqsave(&tick_device_lock, flags); 200 spin_lock_irqsave(&tick_device_lock, flags);
202 201
203 cpu = smp_processor_id(); 202 cpu = smp_processor_id();
204 cpumask_of_cpu_ptr_next(cpumask, cpu);
205 if (!cpu_isset(cpu, newdev->cpumask)) 203 if (!cpu_isset(cpu, newdev->cpumask))
206 goto out_bc; 204 goto out_bc;
207 205
@@ -209,7 +207,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
209 curdev = td->evtdev; 207 curdev = td->evtdev;
210 208
211 /* cpu local device ? */ 209 /* cpu local device ? */
212 if (!cpus_equal(newdev->cpumask, *cpumask)) { 210 if (!cpus_equal(newdev->cpumask, cpumask_of_cpu(cpu))) {
213 211
214 /* 212 /*
215 * If the cpu affinity of the device interrupt can not 213 * If the cpu affinity of the device interrupt can not
@@ -222,7 +220,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
222 * If we have a cpu local device already, do not replace it 220 * If we have a cpu local device already, do not replace it
223 * by a non cpu local device 221 * by a non cpu local device
224 */ 222 */
225 if (curdev && cpus_equal(curdev->cpumask, *cpumask)) 223 if (curdev && cpus_equal(curdev->cpumask, cpumask_of_cpu(cpu)))
226 goto out_bc; 224 goto out_bc;
227 } 225 }
228 226
@@ -254,7 +252,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
254 curdev = NULL; 252 curdev = NULL;
255 } 253 }
256 clockevents_exchange_device(curdev, newdev); 254 clockevents_exchange_device(curdev, newdev);
257 tick_setup_device(td, newdev, cpu, cpumask); 255 tick_setup_device(td, newdev, cpu, &cpumask_of_cpu(cpu));
258 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 256 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT)
259 tick_oneshot_notify(); 257 tick_oneshot_notify();
260 258
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4231a3dc224a..f6e3af31b403 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -587,7 +587,7 @@ static int __ftrace_modify_code(void *data)
587 587
588static void ftrace_run_update_code(int command) 588static void ftrace_run_update_code(int command)
589{ 589{
590 stop_machine_run(__ftrace_modify_code, &command, NR_CPUS); 590 stop_machine(__ftrace_modify_code, &command, NULL);
591} 591}
592 592
593void ftrace_disable_daemon(void) 593void ftrace_disable_daemon(void)
@@ -787,7 +787,7 @@ static int ftrace_update_code(void)
787 !ftrace_enabled || !ftraced_trigger) 787 !ftrace_enabled || !ftraced_trigger)
788 return 0; 788 return 0;
789 789
790 stop_machine_run(__ftrace_update_code, NULL, NR_CPUS); 790 stop_machine(__ftrace_update_code, NULL, NULL);
791 791
792 return 1; 792 return 1;
793} 793}
@@ -1564,7 +1564,7 @@ static int __init ftrace_dynamic_init(void)
1564 1564
1565 addr = (unsigned long)ftrace_record_ip; 1565 addr = (unsigned long)ftrace_record_ip;
1566 1566
1567 stop_machine_run(ftrace_dyn_arch_init, &addr, NR_CPUS); 1567 stop_machine(ftrace_dyn_arch_init, &addr, NULL);
1568 1568
1569 /* ftrace_dyn_arch_init places the return code in addr */ 1569 /* ftrace_dyn_arch_init places the return code in addr */
1570 if (addr) { 1570 if (addr) {
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 868e121c8e38..8f3fb3db61c3 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1183,7 +1183,6 @@ static void *find_next_entry_inc(struct trace_iterator *iter)
1183static void *s_next(struct seq_file *m, void *v, loff_t *pos) 1183static void *s_next(struct seq_file *m, void *v, loff_t *pos)
1184{ 1184{
1185 struct trace_iterator *iter = m->private; 1185 struct trace_iterator *iter = m->private;
1186 void *last_ent = iter->ent;
1187 int i = (int)*pos; 1186 int i = (int)*pos;
1188 void *ent; 1187 void *ent;
1189 1188
@@ -1203,9 +1202,6 @@ static void *s_next(struct seq_file *m, void *v, loff_t *pos)
1203 1202
1204 iter->pos = *pos; 1203 iter->pos = *pos;
1205 1204
1206 if (last_ent && !ent)
1207 seq_puts(m, "\n\nvim:ft=help\n");
1208
1209 return ent; 1205 return ent;
1210} 1206}
1211 1207
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 421d6fe3650e..ece6cfb649fa 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -253,12 +253,14 @@ void start_critical_timings(void)
253 if (preempt_trace() || irq_trace()) 253 if (preempt_trace() || irq_trace())
254 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1); 254 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
255} 255}
256EXPORT_SYMBOL_GPL(start_critical_timings);
256 257
257void stop_critical_timings(void) 258void stop_critical_timings(void)
258{ 259{
259 if (preempt_trace() || irq_trace()) 260 if (preempt_trace() || irq_trace())
260 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1); 261 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
261} 262}
263EXPORT_SYMBOL_GPL(stop_critical_timings);
262 264
263#ifdef CONFIG_IRQSOFF_TRACER 265#ifdef CONFIG_IRQSOFF_TRACER
264#ifdef CONFIG_PROVE_LOCKING 266#ifdef CONFIG_PROVE_LOCKING
@@ -337,12 +339,14 @@ EXPORT_SYMBOL(trace_hardirqs_off_caller);
337#ifdef CONFIG_PREEMPT_TRACER 339#ifdef CONFIG_PREEMPT_TRACER
338void trace_preempt_on(unsigned long a0, unsigned long a1) 340void trace_preempt_on(unsigned long a0, unsigned long a1)
339{ 341{
340 stop_critical_timing(a0, a1); 342 if (preempt_trace())
343 stop_critical_timing(a0, a1);
341} 344}
342 345
343void trace_preempt_off(unsigned long a0, unsigned long a1) 346void trace_preempt_off(unsigned long a0, unsigned long a1)
344{ 347{
345 start_critical_timing(a0, a1); 348 if (preempt_trace())
349 start_critical_timing(a0, a1);
346} 350}
347#endif /* CONFIG_PREEMPT_TRACER */ 351#endif /* CONFIG_PREEMPT_TRACER */
348 352
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 3c8d61df4474..e303ccb62cdf 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -26,7 +26,8 @@ static struct task_struct *wakeup_task;
26static int wakeup_cpu; 26static int wakeup_cpu;
27static unsigned wakeup_prio = -1; 27static unsigned wakeup_prio = -1;
28 28
29static DEFINE_SPINLOCK(wakeup_lock); 29static raw_spinlock_t wakeup_lock =
30 (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
30 31
31static void __wakeup_reset(struct trace_array *tr); 32static void __wakeup_reset(struct trace_array *tr);
32 33
@@ -56,7 +57,8 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
56 if (unlikely(disabled != 1)) 57 if (unlikely(disabled != 1))
57 goto out; 58 goto out;
58 59
59 spin_lock_irqsave(&wakeup_lock, flags); 60 local_irq_save(flags);
61 __raw_spin_lock(&wakeup_lock);
60 62
61 if (unlikely(!wakeup_task)) 63 if (unlikely(!wakeup_task))
62 goto unlock; 64 goto unlock;
@@ -71,7 +73,8 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip)
71 trace_function(tr, data, ip, parent_ip, flags); 73 trace_function(tr, data, ip, parent_ip, flags);
72 74
73 unlock: 75 unlock:
74 spin_unlock_irqrestore(&wakeup_lock, flags); 76 __raw_spin_unlock(&wakeup_lock);
77 local_irq_restore(flags);
75 78
76 out: 79 out:
77 atomic_dec(&data->disabled); 80 atomic_dec(&data->disabled);
@@ -145,7 +148,8 @@ wakeup_sched_switch(void *private, void *rq, struct task_struct *prev,
145 if (likely(disabled != 1)) 148 if (likely(disabled != 1))
146 goto out; 149 goto out;
147 150
148 spin_lock_irqsave(&wakeup_lock, flags); 151 local_irq_save(flags);
152 __raw_spin_lock(&wakeup_lock);
149 153
150 /* We could race with grabbing wakeup_lock */ 154 /* We could race with grabbing wakeup_lock */
151 if (unlikely(!tracer_enabled || next != wakeup_task)) 155 if (unlikely(!tracer_enabled || next != wakeup_task))
@@ -174,7 +178,8 @@ wakeup_sched_switch(void *private, void *rq, struct task_struct *prev,
174 178
175out_unlock: 179out_unlock:
176 __wakeup_reset(tr); 180 __wakeup_reset(tr);
177 spin_unlock_irqrestore(&wakeup_lock, flags); 181 __raw_spin_unlock(&wakeup_lock);
182 local_irq_restore(flags);
178out: 183out:
179 atomic_dec(&tr->data[cpu]->disabled); 184 atomic_dec(&tr->data[cpu]->disabled);
180} 185}
@@ -209,8 +214,6 @@ static void __wakeup_reset(struct trace_array *tr)
209 struct trace_array_cpu *data; 214 struct trace_array_cpu *data;
210 int cpu; 215 int cpu;
211 216
212 assert_spin_locked(&wakeup_lock);
213
214 for_each_possible_cpu(cpu) { 217 for_each_possible_cpu(cpu) {
215 data = tr->data[cpu]; 218 data = tr->data[cpu];
216 tracing_reset(data); 219 tracing_reset(data);
@@ -229,9 +232,11 @@ static void wakeup_reset(struct trace_array *tr)
229{ 232{
230 unsigned long flags; 233 unsigned long flags;
231 234
232 spin_lock_irqsave(&wakeup_lock, flags); 235 local_irq_save(flags);
236 __raw_spin_lock(&wakeup_lock);
233 __wakeup_reset(tr); 237 __wakeup_reset(tr);
234 spin_unlock_irqrestore(&wakeup_lock, flags); 238 __raw_spin_unlock(&wakeup_lock);
239 local_irq_restore(flags);
235} 240}
236 241
237static void 242static void
@@ -252,7 +257,7 @@ wakeup_check_start(struct trace_array *tr, struct task_struct *p,
252 goto out; 257 goto out;
253 258
254 /* interrupts should be off from try_to_wake_up */ 259 /* interrupts should be off from try_to_wake_up */
255 spin_lock(&wakeup_lock); 260 __raw_spin_lock(&wakeup_lock);
256 261
257 /* check for races. */ 262 /* check for races. */
258 if (!tracer_enabled || p->prio >= wakeup_prio) 263 if (!tracer_enabled || p->prio >= wakeup_prio)
@@ -274,7 +279,7 @@ wakeup_check_start(struct trace_array *tr, struct task_struct *p,
274 CALLER_ADDR1, CALLER_ADDR2, flags); 279 CALLER_ADDR1, CALLER_ADDR2, flags);
275 280
276out_locked: 281out_locked:
277 spin_unlock(&wakeup_lock); 282 __raw_spin_unlock(&wakeup_lock);
278out: 283out:
279 atomic_dec(&tr->data[cpu]->disabled); 284 atomic_dec(&tr->data[cpu]->disabled);
280} 285}
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c
index ce2d723c10e1..bb948e52ce20 100644
--- a/kernel/trace/trace_sysprof.c
+++ b/kernel/trace/trace_sysprof.c
@@ -213,9 +213,7 @@ static void start_stack_timers(void)
213 int cpu; 213 int cpu;
214 214
215 for_each_online_cpu(cpu) { 215 for_each_online_cpu(cpu) {
216 cpumask_of_cpu_ptr(new_mask, cpu); 216 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
217
218 set_cpus_allowed_ptr(current, new_mask);
219 start_stack_timer(cpu); 217 start_stack_timer(cpu);
220 } 218 }
221 set_cpus_allowed_ptr(current, &saved_mask); 219 set_cpus_allowed_ptr(current, &saved_mask);
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 3da47ccdc5e5..8ebcd8532dfb 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -94,10 +94,10 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
94 stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB; 94 stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;
95 mmput(mm); 95 mmput(mm);
96 } 96 }
97 stats->read_char = p->rchar; 97 stats->read_char = p->ioac.rchar;
98 stats->write_char = p->wchar; 98 stats->write_char = p->ioac.wchar;
99 stats->read_syscalls = p->syscr; 99 stats->read_syscalls = p->ioac.syscr;
100 stats->write_syscalls = p->syscw; 100 stats->write_syscalls = p->ioac.syscw;
101#ifdef CONFIG_TASK_IO_ACCOUNTING 101#ifdef CONFIG_TASK_IO_ACCOUNTING
102 stats->read_bytes = p->ioac.read_bytes; 102 stats->read_bytes = p->ioac.read_bytes;
103 stats->write_bytes = p->ioac.write_bytes; 103 stats->write_bytes = p->ioac.write_bytes;
diff --git a/lib/Makefile b/lib/Makefile
index 9085ad6fa53d..3b1f94bbe9de 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,7 +11,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
11 rbtree.o radix-tree.o dump_stack.o \ 11 rbtree.o radix-tree.o dump_stack.o \
12 idr.o int_sqrt.o extable.o prio_tree.o \ 12 idr.o int_sqrt.o extable.o prio_tree.o \
13 sha1.o irq_regs.o reciprocal_div.o argv_split.o \ 13 sha1.o irq_regs.o reciprocal_div.o argv_split.o \
14 proportions.o prio_heap.o ratelimit.o 14 proportions.o prio_heap.o ratelimit.o show_mem.o
15 15
16lib-$(CONFIG_MMU) += ioremap.o 16lib-$(CONFIG_MMU) += ioremap.o
17lib-$(CONFIG_SMP) += cpumask.o 17lib-$(CONFIG_SMP) += cpumask.o
@@ -78,6 +78,8 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o
78 78
79obj-$(CONFIG_HAVE_LMB) += lmb.o 79obj-$(CONFIG_HAVE_LMB) += lmb.o
80 80
81obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
82
81hostprogs-y := gen_crc32table 83hostprogs-y := gen_crc32table
82clean-files := crc32table.h 84clean-files := crc32table.h
83 85
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index f86196390cfd..45a6bde762d1 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -205,9 +205,8 @@ static void debug_print_object(struct debug_obj *obj, char *msg)
205 205
206 if (limit < 5 && obj->descr != descr_test) { 206 if (limit < 5 && obj->descr != descr_test) {
207 limit++; 207 limit++;
208 printk(KERN_ERR "ODEBUG: %s %s object type: %s\n", msg, 208 WARN(1, KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
209 obj_states[obj->state], obj->descr->name); 209 obj_states[obj->state], obj->descr->name);
210 WARN_ON(1);
211 } 210 }
212 debug_objects_warnings++; 211 debug_objects_warnings++;
213} 212}
@@ -733,26 +732,22 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
733 732
734 obj = lookup_object(addr, db); 733 obj = lookup_object(addr, db);
735 if (!obj && state != ODEBUG_STATE_NONE) { 734 if (!obj && state != ODEBUG_STATE_NONE) {
736 printk(KERN_ERR "ODEBUG: selftest object not found\n"); 735 WARN(1, KERN_ERR "ODEBUG: selftest object not found\n");
737 WARN_ON(1);
738 goto out; 736 goto out;
739 } 737 }
740 if (obj && obj->state != state) { 738 if (obj && obj->state != state) {
741 printk(KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n", 739 WARN(1, KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
742 obj->state, state); 740 obj->state, state);
743 WARN_ON(1);
744 goto out; 741 goto out;
745 } 742 }
746 if (fixups != debug_objects_fixups) { 743 if (fixups != debug_objects_fixups) {
747 printk(KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n", 744 WARN(1, KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
748 fixups, debug_objects_fixups); 745 fixups, debug_objects_fixups);
749 WARN_ON(1);
750 goto out; 746 goto out;
751 } 747 }
752 if (warnings != debug_objects_warnings) { 748 if (warnings != debug_objects_warnings) {
753 printk(KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n", 749 WARN(1, KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
754 warnings, debug_objects_warnings); 750 warnings, debug_objects_warnings);
755 WARN_ON(1);
756 goto out; 751 goto out;
757 } 752 }
758 res = 0; 753 res = 0;
diff --git a/lib/idr.c b/lib/idr.c
index 3476f8203e97..e728c7fccc4d 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -607,7 +607,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
607} 607}
608EXPORT_SYMBOL(idr_replace); 608EXPORT_SYMBOL(idr_replace);
609 609
610static void idr_cache_ctor(struct kmem_cache *idr_layer_cache, void *idr_layer) 610static void idr_cache_ctor(void *idr_layer)
611{ 611{
612 memset(idr_layer, 0, sizeof(struct idr_layer)); 612 memset(idr_layer, 0, sizeof(struct idr_layer));
613} 613}
diff --git a/lib/iomap.c b/lib/iomap.c
index 37a3ea4cac9f..d32229385151 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -40,8 +40,7 @@ static void bad_io_access(unsigned long port, const char *access)
40 static int count = 10; 40 static int count = 10;
41 if (count) { 41 if (count) {
42 count--; 42 count--;
43 printk(KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access); 43 WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
44 WARN_ON(1);
45 } 44 }
46} 45}
47 46
diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c
index a3b8d4c3f77a..889ddce2021e 100644
--- a/lib/iommu-helper.c
+++ b/lib/iommu-helper.c
@@ -80,3 +80,11 @@ void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr)
80 } 80 }
81} 81}
82EXPORT_SYMBOL(iommu_area_free); 82EXPORT_SYMBOL(iommu_area_free);
83
84unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
85{
86 unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);
87
88 return size >> PAGE_SHIFT;
89}
90EXPORT_SYMBOL(iommu_num_pages);
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 9f8d599459d1..3f914725bda8 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -285,8 +285,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
285 int len; 285 int len;
286 286
287 if (env->envp_idx >= ARRAY_SIZE(env->envp)) { 287 if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
288 printk(KERN_ERR "add_uevent_var: too many keys\n"); 288 WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
289 WARN_ON(1);
290 return -ENOMEM; 289 return -ENOMEM;
291 } 290 }
292 291
@@ -297,8 +296,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
297 va_end(args); 296 va_end(args);
298 297
299 if (len >= (sizeof(env->buf) - env->buflen)) { 298 if (len >= (sizeof(env->buf) - env->buflen)) {
300 printk(KERN_ERR "add_uevent_var: buffer size too small\n"); 299 WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");
301 WARN_ON(1);
302 return -ENOMEM; 300 return -ENOMEM;
303 } 301 }
304 302
diff --git a/lib/plist.c b/lib/plist.c
index 3074a02272f3..d6c64a824e1d 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -31,12 +31,13 @@
31static void plist_check_prev_next(struct list_head *t, struct list_head *p, 31static void plist_check_prev_next(struct list_head *t, struct list_head *p,
32 struct list_head *n) 32 struct list_head *n)
33{ 33{
34 if (n->prev != p || p->next != n) { 34 WARN(n->prev != p || p->next != n,
35 printk("top: %p, n: %p, p: %p\n", t, t->next, t->prev); 35 "top: %p, n: %p, p: %p\n"
36 printk("prev: %p, n: %p, p: %p\n", p, p->next, p->prev); 36 "prev: %p, n: %p, p: %p\n"
37 printk("next: %p, n: %p, p: %p\n", n, n->next, n->prev); 37 "next: %p, n: %p, p: %p\n",
38 WARN_ON(1); 38 t, t->next, t->prev,
39 } 39 p, p->next, p->prev,
40 n, n->next, n->prev);
40} 41}
41 42
42static void plist_check_list(struct list_head *top) 43static void plist_check_list(struct list_head *top)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 56ec21a7f73d..be86b32bc874 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -359,18 +359,17 @@ EXPORT_SYMBOL(radix_tree_insert);
359 * Returns: the slot corresponding to the position @index in the 359 * Returns: the slot corresponding to the position @index in the
360 * radix tree @root. This is useful for update-if-exists operations. 360 * radix tree @root. This is useful for update-if-exists operations.
361 * 361 *
362 * This function cannot be called under rcu_read_lock, it must be 362 * This function can be called under rcu_read_lock iff the slot is not
363 * excluded from writers, as must the returned slot for subsequent 363 * modified by radix_tree_replace_slot, otherwise it must be called
364 * use by radix_tree_deref_slot() and radix_tree_replace slot. 364 * exclusive from other writers. Any dereference of the slot must be done
365 * Caller must hold tree write locked across slot lookup and 365 * using radix_tree_deref_slot.
366 * replace.
367 */ 366 */
368void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index) 367void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
369{ 368{
370 unsigned int height, shift; 369 unsigned int height, shift;
371 struct radix_tree_node *node, **slot; 370 struct radix_tree_node *node, **slot;
372 371
373 node = root->rnode; 372 node = rcu_dereference(root->rnode);
374 if (node == NULL) 373 if (node == NULL)
375 return NULL; 374 return NULL;
376 375
@@ -390,7 +389,7 @@ void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
390 do { 389 do {
391 slot = (struct radix_tree_node **) 390 slot = (struct radix_tree_node **)
392 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK)); 391 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
393 node = *slot; 392 node = rcu_dereference(*slot);
394 if (node == NULL) 393 if (node == NULL)
395 return NULL; 394 return NULL;
396 395
@@ -667,7 +666,7 @@ unsigned long radix_tree_next_hole(struct radix_tree_root *root,
667EXPORT_SYMBOL(radix_tree_next_hole); 666EXPORT_SYMBOL(radix_tree_next_hole);
668 667
669static unsigned int 668static unsigned int
670__lookup(struct radix_tree_node *slot, void **results, unsigned long index, 669__lookup(struct radix_tree_node *slot, void ***results, unsigned long index,
671 unsigned int max_items, unsigned long *next_index) 670 unsigned int max_items, unsigned long *next_index)
672{ 671{
673 unsigned int nr_found = 0; 672 unsigned int nr_found = 0;
@@ -701,11 +700,9 @@ __lookup(struct radix_tree_node *slot, void **results, unsigned long index,
701 700
702 /* Bottom level: grab some items */ 701 /* Bottom level: grab some items */
703 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { 702 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
704 struct radix_tree_node *node;
705 index++; 703 index++;
706 node = slot->slots[i]; 704 if (slot->slots[i]) {
707 if (node) { 705 results[nr_found++] = &(slot->slots[i]);
708 results[nr_found++] = rcu_dereference(node);
709 if (nr_found == max_items) 706 if (nr_found == max_items)
710 goto out; 707 goto out;
711 } 708 }
@@ -759,13 +756,22 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
759 756
760 ret = 0; 757 ret = 0;
761 while (ret < max_items) { 758 while (ret < max_items) {
762 unsigned int nr_found; 759 unsigned int nr_found, slots_found, i;
763 unsigned long next_index; /* Index of next search */ 760 unsigned long next_index; /* Index of next search */
764 761
765 if (cur_index > max_index) 762 if (cur_index > max_index)
766 break; 763 break;
767 nr_found = __lookup(node, results + ret, cur_index, 764 slots_found = __lookup(node, (void ***)results + ret, cur_index,
768 max_items - ret, &next_index); 765 max_items - ret, &next_index);
766 nr_found = 0;
767 for (i = 0; i < slots_found; i++) {
768 struct radix_tree_node *slot;
769 slot = *(((void ***)results)[ret + i]);
770 if (!slot)
771 continue;
772 results[ret + nr_found] = rcu_dereference(slot);
773 nr_found++;
774 }
769 ret += nr_found; 775 ret += nr_found;
770 if (next_index == 0) 776 if (next_index == 0)
771 break; 777 break;
@@ -776,12 +782,71 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
776} 782}
777EXPORT_SYMBOL(radix_tree_gang_lookup); 783EXPORT_SYMBOL(radix_tree_gang_lookup);
778 784
785/**
786 * radix_tree_gang_lookup_slot - perform multiple slot lookup on radix tree
787 * @root: radix tree root
788 * @results: where the results of the lookup are placed
789 * @first_index: start the lookup from this key
790 * @max_items: place up to this many items at *results
791 *
792 * Performs an index-ascending scan of the tree for present items. Places
793 * their slots at *@results and returns the number of items which were
794 * placed at *@results.
795 *
796 * The implementation is naive.
797 *
798 * Like radix_tree_gang_lookup as far as RCU and locking goes. Slots must
799 * be dereferenced with radix_tree_deref_slot, and if using only RCU
800 * protection, radix_tree_deref_slot may fail requiring a retry.
801 */
802unsigned int
803radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results,
804 unsigned long first_index, unsigned int max_items)
805{
806 unsigned long max_index;
807 struct radix_tree_node *node;
808 unsigned long cur_index = first_index;
809 unsigned int ret;
810
811 node = rcu_dereference(root->rnode);
812 if (!node)
813 return 0;
814
815 if (!radix_tree_is_indirect_ptr(node)) {
816 if (first_index > 0)
817 return 0;
818 results[0] = (void **)&root->rnode;
819 return 1;
820 }
821 node = radix_tree_indirect_to_ptr(node);
822
823 max_index = radix_tree_maxindex(node->height);
824
825 ret = 0;
826 while (ret < max_items) {
827 unsigned int slots_found;
828 unsigned long next_index; /* Index of next search */
829
830 if (cur_index > max_index)
831 break;
832 slots_found = __lookup(node, results + ret, cur_index,
833 max_items - ret, &next_index);
834 ret += slots_found;
835 if (next_index == 0)
836 break;
837 cur_index = next_index;
838 }
839
840 return ret;
841}
842EXPORT_SYMBOL(radix_tree_gang_lookup_slot);
843
779/* 844/*
780 * FIXME: the two tag_get()s here should use find_next_bit() instead of 845 * FIXME: the two tag_get()s here should use find_next_bit() instead of
781 * open-coding the search. 846 * open-coding the search.
782 */ 847 */
783static unsigned int 848static unsigned int
784__lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index, 849__lookup_tag(struct radix_tree_node *slot, void ***results, unsigned long index,
785 unsigned int max_items, unsigned long *next_index, unsigned int tag) 850 unsigned int max_items, unsigned long *next_index, unsigned int tag)
786{ 851{
787 unsigned int nr_found = 0; 852 unsigned int nr_found = 0;
@@ -811,11 +876,9 @@ __lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
811 unsigned long j = index & RADIX_TREE_MAP_MASK; 876 unsigned long j = index & RADIX_TREE_MAP_MASK;
812 877
813 for ( ; j < RADIX_TREE_MAP_SIZE; j++) { 878 for ( ; j < RADIX_TREE_MAP_SIZE; j++) {
814 struct radix_tree_node *node;
815 index++; 879 index++;
816 if (!tag_get(slot, tag, j)) 880 if (!tag_get(slot, tag, j))
817 continue; 881 continue;
818 node = slot->slots[j];
819 /* 882 /*
820 * Even though the tag was found set, we need to 883 * Even though the tag was found set, we need to
821 * recheck that we have a non-NULL node, because 884 * recheck that we have a non-NULL node, because
@@ -826,9 +889,8 @@ __lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
826 * lookup ->slots[x] without a lock (ie. can't 889 * lookup ->slots[x] without a lock (ie. can't
827 * rely on its value remaining the same). 890 * rely on its value remaining the same).
828 */ 891 */
829 if (node) { 892 if (slot->slots[j]) {
830 node = rcu_dereference(node); 893 results[nr_found++] = &(slot->slots[j]);
831 results[nr_found++] = node;
832 if (nr_found == max_items) 894 if (nr_found == max_items)
833 goto out; 895 goto out;
834 } 896 }
@@ -887,13 +949,22 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
887 949
888 ret = 0; 950 ret = 0;
889 while (ret < max_items) { 951 while (ret < max_items) {
890 unsigned int nr_found; 952 unsigned int nr_found, slots_found, i;
891 unsigned long next_index; /* Index of next search */ 953 unsigned long next_index; /* Index of next search */
892 954
893 if (cur_index > max_index) 955 if (cur_index > max_index)
894 break; 956 break;
895 nr_found = __lookup_tag(node, results + ret, cur_index, 957 slots_found = __lookup_tag(node, (void ***)results + ret,
896 max_items - ret, &next_index, tag); 958 cur_index, max_items - ret, &next_index, tag);
959 nr_found = 0;
960 for (i = 0; i < slots_found; i++) {
961 struct radix_tree_node *slot;
962 slot = *(((void ***)results)[ret + i]);
963 if (!slot)
964 continue;
965 results[ret + nr_found] = rcu_dereference(slot);
966 nr_found++;
967 }
897 ret += nr_found; 968 ret += nr_found;
898 if (next_index == 0) 969 if (next_index == 0)
899 break; 970 break;
@@ -905,6 +976,67 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
905EXPORT_SYMBOL(radix_tree_gang_lookup_tag); 976EXPORT_SYMBOL(radix_tree_gang_lookup_tag);
906 977
907/** 978/**
979 * radix_tree_gang_lookup_tag_slot - perform multiple slot lookup on a
980 * radix tree based on a tag
981 * @root: radix tree root
982 * @results: where the results of the lookup are placed
983 * @first_index: start the lookup from this key
984 * @max_items: place up to this many items at *results
985 * @tag: the tag index (< RADIX_TREE_MAX_TAGS)
986 *
987 * Performs an index-ascending scan of the tree for present items which
988 * have the tag indexed by @tag set. Places the slots at *@results and
989 * returns the number of slots which were placed at *@results.
990 */
991unsigned int
992radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results,
993 unsigned long first_index, unsigned int max_items,
994 unsigned int tag)
995{
996 struct radix_tree_node *node;
997 unsigned long max_index;
998 unsigned long cur_index = first_index;
999 unsigned int ret;
1000
1001 /* check the root's tag bit */
1002 if (!root_tag_get(root, tag))
1003 return 0;
1004
1005 node = rcu_dereference(root->rnode);
1006 if (!node)
1007 return 0;
1008
1009 if (!radix_tree_is_indirect_ptr(node)) {
1010 if (first_index > 0)
1011 return 0;
1012 results[0] = (void **)&root->rnode;
1013 return 1;
1014 }
1015 node = radix_tree_indirect_to_ptr(node);
1016
1017 max_index = radix_tree_maxindex(node->height);
1018
1019 ret = 0;
1020 while (ret < max_items) {
1021 unsigned int slots_found;
1022 unsigned long next_index; /* Index of next search */
1023
1024 if (cur_index > max_index)
1025 break;
1026 slots_found = __lookup_tag(node, results + ret,
1027 cur_index, max_items - ret, &next_index, tag);
1028 ret += slots_found;
1029 if (next_index == 0)
1030 break;
1031 cur_index = next_index;
1032 }
1033
1034 return ret;
1035}
1036EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot);
1037
1038
1039/**
908 * radix_tree_shrink - shrink height of a radix tree to minimal 1040 * radix_tree_shrink - shrink height of a radix tree to minimal
909 * @root radix tree root 1041 * @root radix tree root
910 */ 1042 */
@@ -1051,7 +1183,7 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
1051EXPORT_SYMBOL(radix_tree_tagged); 1183EXPORT_SYMBOL(radix_tree_tagged);
1052 1184
1053static void 1185static void
1054radix_tree_node_ctor(struct kmem_cache *cachep, void *node) 1186radix_tree_node_ctor(void *node)
1055{ 1187{
1056 memset(node, 0, sizeof(struct radix_tree_node)); 1188 memset(node, 0, sizeof(struct radix_tree_node));
1057} 1189}
diff --git a/lib/ratelimit.c b/lib/ratelimit.c
index 35136671b215..26187edcc7ea 100644
--- a/lib/ratelimit.c
+++ b/lib/ratelimit.c
@@ -15,7 +15,6 @@
15#include <linux/module.h> 15#include <linux/module.h>
16 16
17static DEFINE_SPINLOCK(ratelimit_lock); 17static DEFINE_SPINLOCK(ratelimit_lock);
18static unsigned long flags;
19 18
20/* 19/*
21 * __ratelimit - rate limiting 20 * __ratelimit - rate limiting
@@ -26,6 +25,8 @@ static unsigned long flags;
26 */ 25 */
27int __ratelimit(struct ratelimit_state *rs) 26int __ratelimit(struct ratelimit_state *rs)
28{ 27{
28 unsigned long flags;
29
29 if (!rs->interval) 30 if (!rs->interval)
30 return 1; 31 return 1;
31 32
diff --git a/lib/show_mem.c b/lib/show_mem.c
new file mode 100644
index 000000000000..238e72a18ce1
--- /dev/null
+++ b/lib/show_mem.c
@@ -0,0 +1,63 @@
1/*
2 * Generic show_mem() implementation
3 *
4 * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
5 * All code subject to the GPL version 2.
6 */
7
8#include <linux/mm.h>
9#include <linux/nmi.h>
10#include <linux/quicklist.h>
11
12void show_mem(void)
13{
14 pg_data_t *pgdat;
15 unsigned long total = 0, reserved = 0, shared = 0,
16 nonshared = 0, highmem = 0;
17
18 printk(KERN_INFO "Mem-Info:\n");
19 show_free_areas();
20
21 for_each_online_pgdat(pgdat) {
22 unsigned long i, flags;
23
24 pgdat_resize_lock(pgdat, &flags);
25 for (i = 0; i < pgdat->node_spanned_pages; i++) {
26 struct page *page;
27 unsigned long pfn = pgdat->node_start_pfn + i;
28
29 if (unlikely(!(i % MAX_ORDER_NR_PAGES)))
30 touch_nmi_watchdog();
31
32 if (!pfn_valid(pfn))
33 continue;
34
35 page = pfn_to_page(pfn);
36
37 if (PageHighMem(page))
38 highmem++;
39
40 if (PageReserved(page))
41 reserved++;
42 else if (page_count(page) == 1)
43 nonshared++;
44 else if (page_count(page) > 1)
45 shared += page_count(page) - 1;
46
47 total++;
48 }
49 pgdat_resize_unlock(pgdat, &flags);
50 }
51
52 printk(KERN_INFO "%lu pages RAM\n", total);
53#ifdef CONFIG_HIGHMEM
54 printk(KERN_INFO "%lu pages HighMem\n", highmem);
55#endif
56 printk(KERN_INFO "%lu pages reserved\n", reserved);
57 printk(KERN_INFO "%lu pages shared\n", shared);
58 printk(KERN_INFO "%lu pages non-shared\n", nonshared);
59#ifdef CONFIG_QUICKLIST
60 printk(KERN_INFO "%lu pages in pagetable cache\n",
61 quicklist_total_size());
62#endif
63}
diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
index c4381d9516f6..0f8fc22ed103 100644
--- a/lib/smp_processor_id.c
+++ b/lib/smp_processor_id.c
@@ -11,7 +11,6 @@ notrace unsigned int debug_smp_processor_id(void)
11{ 11{
12 unsigned long preempt_count = preempt_count(); 12 unsigned long preempt_count = preempt_count();
13 int this_cpu = raw_smp_processor_id(); 13 int this_cpu = raw_smp_processor_id();
14 cpumask_of_cpu_ptr_declare(this_mask);
15 14
16 if (likely(preempt_count)) 15 if (likely(preempt_count))
17 goto out; 16 goto out;
@@ -23,9 +22,7 @@ notrace unsigned int debug_smp_processor_id(void)
23 * Kernel threads bound to a single CPU can safely use 22 * Kernel threads bound to a single CPU can safely use
24 * smp_processor_id(): 23 * smp_processor_id():
25 */ 24 */
26 cpumask_of_cpu_ptr_next(this_mask, this_cpu); 25 if (cpus_equal(current->cpus_allowed, cpumask_of_cpu(this_cpu)))
27
28 if (cpus_equal(current->cpus_allowed, *this_mask))
29 goto out; 26 goto out;
30 27
31 /* 28 /*
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index d568894df8cc..977edbdbc1de 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -492,7 +492,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
492 */ 492 */
493 dma_addr_t handle; 493 dma_addr_t handle;
494 handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE); 494 handle = swiotlb_map_single(NULL, NULL, size, DMA_FROM_DEVICE);
495 if (swiotlb_dma_mapping_error(handle)) 495 if (swiotlb_dma_mapping_error(hwdev, handle))
496 return NULL; 496 return NULL;
497 497
498 ret = bus_to_virt(handle); 498 ret = bus_to_virt(handle);
@@ -824,7 +824,7 @@ swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
824} 824}
825 825
826int 826int
827swiotlb_dma_mapping_error(dma_addr_t dma_addr) 827swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
828{ 828{
829 return (dma_addr == virt_to_bus(io_tlb_overflow_buffer)); 829 return (dma_addr == virt_to_bus(io_tlb_overflow_buffer));
830} 830}
diff --git a/lib/syscall.c b/lib/syscall.c
new file mode 100644
index 000000000000..a4f7067f72fa
--- /dev/null
+++ b/lib/syscall.c
@@ -0,0 +1,75 @@
1#include <linux/ptrace.h>
2#include <linux/sched.h>
3#include <linux/module.h>
4#include <asm/syscall.h>
5
6static int collect_syscall(struct task_struct *target, long *callno,
7 unsigned long args[6], unsigned int maxargs,
8 unsigned long *sp, unsigned long *pc)
9{
10 struct pt_regs *regs = task_pt_regs(target);
11 if (unlikely(!regs))
12 return -EAGAIN;
13
14 *sp = user_stack_pointer(regs);
15 *pc = instruction_pointer(regs);
16
17 *callno = syscall_get_nr(target, regs);
18 if (*callno != -1L && maxargs > 0)
19 syscall_get_arguments(target, regs, 0, maxargs, args);
20
21 return 0;
22}
23
24/**
25 * task_current_syscall - Discover what a blocked task is doing.
26 * @target: thread to examine
27 * @callno: filled with system call number or -1
28 * @args: filled with @maxargs system call arguments
29 * @maxargs: number of elements in @args to fill
30 * @sp: filled with user stack pointer
31 * @pc: filled with user PC
32 *
33 * If @target is blocked in a system call, returns zero with *@callno
34 * set to the the call's number and @args filled in with its arguments.
35 * Registers not used for system call arguments may not be available and
36 * it is not kosher to use &struct user_regset calls while the system
37 * call is still in progress. Note we may get this result if @target
38 * has finished its system call but not yet returned to user mode, such
39 * as when it's stopped for signal handling or syscall exit tracing.
40 *
41 * If @target is blocked in the kernel during a fault or exception,
42 * returns zero with *@callno set to -1 and does not fill in @args.
43 * If so, it's now safe to examine @target using &struct user_regset
44 * get() calls as long as we're sure @target won't return to user mode.
45 *
46 * Returns -%EAGAIN if @target does not remain blocked.
47 *
48 * Returns -%EINVAL if @maxargs is too large (maximum is six).
49 */
50int task_current_syscall(struct task_struct *target, long *callno,
51 unsigned long args[6], unsigned int maxargs,
52 unsigned long *sp, unsigned long *pc)
53{
54 long state;
55 unsigned long ncsw;
56
57 if (unlikely(maxargs > 6))
58 return -EINVAL;
59
60 if (target == current)
61 return collect_syscall(target, callno, args, maxargs, sp, pc);
62
63 state = target->state;
64 if (unlikely(!state))
65 return -EAGAIN;
66
67 ncsw = wait_task_inactive(target, state);
68 if (unlikely(!ncsw) ||
69 unlikely(collect_syscall(target, callno, args, maxargs, sp, pc)) ||
70 unlikely(wait_task_inactive(target, state) != ncsw))
71 return -EAGAIN;
72
73 return 0;
74}
75EXPORT_SYMBOL_GPL(task_current_syscall);
diff --git a/mm/Kconfig b/mm/Kconfig
index aa799007a11b..446c6588c753 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -77,6 +77,9 @@ config FLAT_NODE_MEM_MAP
77 def_bool y 77 def_bool y
78 depends on !SPARSEMEM 78 depends on !SPARSEMEM
79 79
80config HAVE_GET_USER_PAGES_FAST
81 bool
82
80# 83#
81# Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's 84# Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's
82# to represent different areas of memory. This variable allows 85# to represent different areas of memory. This variable allows
@@ -205,3 +208,6 @@ config NR_QUICK
205config VIRT_TO_BUS 208config VIRT_TO_BUS
206 def_bool y 209 def_bool y
207 depends on !ARCH_NO_VIRT_TO_BUS 210 depends on !ARCH_NO_VIRT_TO_BUS
211
212config MMU_NOTIFIER
213 bool
diff --git a/mm/Makefile b/mm/Makefile
index 06ca2381fef1..da4ccf015aea 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_SHMEM) += shmem.o
25obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o 25obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o
26obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o 26obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o
27obj-$(CONFIG_SLOB) += slob.o 27obj-$(CONFIG_SLOB) += slob.o
28obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
28obj-$(CONFIG_SLAB) += slab.o 29obj-$(CONFIG_SLAB) += slab.o
29obj-$(CONFIG_SLUB) += slub.o 30obj-$(CONFIG_SLUB) += slub.o
30obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o 31obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
index 843364594e23..4297bc41bfd2 100644
--- a/mm/allocpercpu.c
+++ b/mm/allocpercpu.c
@@ -18,27 +18,28 @@
18 * Depopulating per-cpu data for a cpu going offline would be a typical 18 * Depopulating per-cpu data for a cpu going offline would be a typical
19 * use case. You need to register a cpu hotplug handler for that purpose. 19 * use case. You need to register a cpu hotplug handler for that purpose.
20 */ 20 */
21void percpu_depopulate(void *__pdata, int cpu) 21static void percpu_depopulate(void *__pdata, int cpu)
22{ 22{
23 struct percpu_data *pdata = __percpu_disguise(__pdata); 23 struct percpu_data *pdata = __percpu_disguise(__pdata);
24 24
25 kfree(pdata->ptrs[cpu]); 25 kfree(pdata->ptrs[cpu]);
26 pdata->ptrs[cpu] = NULL; 26 pdata->ptrs[cpu] = NULL;
27} 27}
28EXPORT_SYMBOL_GPL(percpu_depopulate);
29 28
30/** 29/**
31 * percpu_depopulate_mask - depopulate per-cpu data for some cpu's 30 * percpu_depopulate_mask - depopulate per-cpu data for some cpu's
32 * @__pdata: per-cpu data to depopulate 31 * @__pdata: per-cpu data to depopulate
33 * @mask: depopulate per-cpu data for cpu's selected through mask bits 32 * @mask: depopulate per-cpu data for cpu's selected through mask bits
34 */ 33 */
35void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask) 34static void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask)
36{ 35{
37 int cpu; 36 int cpu;
38 for_each_cpu_mask_nr(cpu, *mask) 37 for_each_cpu_mask_nr(cpu, *mask)
39 percpu_depopulate(__pdata, cpu); 38 percpu_depopulate(__pdata, cpu);
40} 39}
41EXPORT_SYMBOL_GPL(__percpu_depopulate_mask); 40
41#define percpu_depopulate_mask(__pdata, mask) \
42 __percpu_depopulate_mask((__pdata), &(mask))
42 43
43/** 44/**
44 * percpu_populate - populate per-cpu data for given cpu 45 * percpu_populate - populate per-cpu data for given cpu
@@ -51,7 +52,7 @@ EXPORT_SYMBOL_GPL(__percpu_depopulate_mask);
51 * use case. You need to register a cpu hotplug handler for that purpose. 52 * use case. You need to register a cpu hotplug handler for that purpose.
52 * Per-cpu object is populated with zeroed buffer. 53 * Per-cpu object is populated with zeroed buffer.
53 */ 54 */
54void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu) 55static void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu)
55{ 56{
56 struct percpu_data *pdata = __percpu_disguise(__pdata); 57 struct percpu_data *pdata = __percpu_disguise(__pdata);
57 int node = cpu_to_node(cpu); 58 int node = cpu_to_node(cpu);
@@ -68,7 +69,6 @@ void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu)
68 pdata->ptrs[cpu] = kzalloc(size, gfp); 69 pdata->ptrs[cpu] = kzalloc(size, gfp);
69 return pdata->ptrs[cpu]; 70 return pdata->ptrs[cpu];
70} 71}
71EXPORT_SYMBOL_GPL(percpu_populate);
72 72
73/** 73/**
74 * percpu_populate_mask - populate per-cpu data for more cpu's 74 * percpu_populate_mask - populate per-cpu data for more cpu's
@@ -79,8 +79,8 @@ EXPORT_SYMBOL_GPL(percpu_populate);
79 * 79 *
80 * Per-cpu objects are populated with zeroed buffers. 80 * Per-cpu objects are populated with zeroed buffers.
81 */ 81 */
82int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp, 82static int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
83 cpumask_t *mask) 83 cpumask_t *mask)
84{ 84{
85 cpumask_t populated; 85 cpumask_t populated;
86 int cpu; 86 int cpu;
@@ -94,7 +94,9 @@ int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
94 cpu_set(cpu, populated); 94 cpu_set(cpu, populated);
95 return 0; 95 return 0;
96} 96}
97EXPORT_SYMBOL_GPL(__percpu_populate_mask); 97
98#define percpu_populate_mask(__pdata, size, gfp, mask) \
99 __percpu_populate_mask((__pdata), (size), (gfp), &(mask))
98 100
99/** 101/**
100 * percpu_alloc_mask - initial setup of per-cpu data 102 * percpu_alloc_mask - initial setup of per-cpu data
diff --git a/mm/filemap.c b/mm/filemap.c
index 2d3ec1ffc66e..42bbc6909ba4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -109,7 +109,7 @@
109/* 109/*
110 * Remove a page from the page cache and free it. Caller has to make 110 * Remove a page from the page cache and free it. Caller has to make
111 * sure the page is locked and that nobody else uses it - or that usage 111 * sure the page is locked and that nobody else uses it - or that usage
112 * is safe. The caller must hold a write_lock on the mapping's tree_lock. 112 * is safe. The caller must hold the mapping's tree_lock.
113 */ 113 */
114void __remove_from_page_cache(struct page *page) 114void __remove_from_page_cache(struct page *page)
115{ 115{
@@ -141,9 +141,9 @@ void remove_from_page_cache(struct page *page)
141 141
142 BUG_ON(!PageLocked(page)); 142 BUG_ON(!PageLocked(page));
143 143
144 write_lock_irq(&mapping->tree_lock); 144 spin_lock_irq(&mapping->tree_lock);
145 __remove_from_page_cache(page); 145 __remove_from_page_cache(page);
146 write_unlock_irq(&mapping->tree_lock); 146 spin_unlock_irq(&mapping->tree_lock);
147} 147}
148 148
149static int sync_page(void *word) 149static int sync_page(void *word)
@@ -442,48 +442,52 @@ int filemap_write_and_wait_range(struct address_space *mapping,
442} 442}
443 443
444/** 444/**
445 * add_to_page_cache - add newly allocated pagecache pages 445 * add_to_page_cache_locked - add a locked page to the pagecache
446 * @page: page to add 446 * @page: page to add
447 * @mapping: the page's address_space 447 * @mapping: the page's address_space
448 * @offset: page index 448 * @offset: page index
449 * @gfp_mask: page allocation mode 449 * @gfp_mask: page allocation mode
450 * 450 *
451 * This function is used to add newly allocated pagecache pages; 451 * This function is used to add a page to the pagecache. It must be locked.
452 * the page is new, so we can just run SetPageLocked() against it.
453 * The other page state flags were set by rmqueue().
454 *
455 * This function does not add the page to the LRU. The caller must do that. 452 * This function does not add the page to the LRU. The caller must do that.
456 */ 453 */
457int add_to_page_cache(struct page *page, struct address_space *mapping, 454int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
458 pgoff_t offset, gfp_t gfp_mask) 455 pgoff_t offset, gfp_t gfp_mask)
459{ 456{
460 int error = mem_cgroup_cache_charge(page, current->mm, 457 int error;
458
459 VM_BUG_ON(!PageLocked(page));
460
461 error = mem_cgroup_cache_charge(page, current->mm,
461 gfp_mask & ~__GFP_HIGHMEM); 462 gfp_mask & ~__GFP_HIGHMEM);
462 if (error) 463 if (error)
463 goto out; 464 goto out;
464 465
465 error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); 466 error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
466 if (error == 0) { 467 if (error == 0) {
467 write_lock_irq(&mapping->tree_lock); 468 page_cache_get(page);
469 page->mapping = mapping;
470 page->index = offset;
471
472 spin_lock_irq(&mapping->tree_lock);
468 error = radix_tree_insert(&mapping->page_tree, offset, page); 473 error = radix_tree_insert(&mapping->page_tree, offset, page);
469 if (!error) { 474 if (likely(!error)) {
470 page_cache_get(page);
471 SetPageLocked(page);
472 page->mapping = mapping;
473 page->index = offset;
474 mapping->nrpages++; 475 mapping->nrpages++;
475 __inc_zone_page_state(page, NR_FILE_PAGES); 476 __inc_zone_page_state(page, NR_FILE_PAGES);
476 } else 477 } else {
478 page->mapping = NULL;
477 mem_cgroup_uncharge_cache_page(page); 479 mem_cgroup_uncharge_cache_page(page);
480 page_cache_release(page);
481 }
478 482
479 write_unlock_irq(&mapping->tree_lock); 483 spin_unlock_irq(&mapping->tree_lock);
480 radix_tree_preload_end(); 484 radix_tree_preload_end();
481 } else 485 } else
482 mem_cgroup_uncharge_cache_page(page); 486 mem_cgroup_uncharge_cache_page(page);
483out: 487out:
484 return error; 488 return error;
485} 489}
486EXPORT_SYMBOL(add_to_page_cache); 490EXPORT_SYMBOL(add_to_page_cache_locked);
487 491
488int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 492int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
489 pgoff_t offset, gfp_t gfp_mask) 493 pgoff_t offset, gfp_t gfp_mask)
@@ -633,15 +637,35 @@ void __lock_page_nosync(struct page *page)
633 * Is there a pagecache struct page at the given (mapping, offset) tuple? 637 * Is there a pagecache struct page at the given (mapping, offset) tuple?
634 * If yes, increment its refcount and return it; if no, return NULL. 638 * If yes, increment its refcount and return it; if no, return NULL.
635 */ 639 */
636struct page * find_get_page(struct address_space *mapping, pgoff_t offset) 640struct page *find_get_page(struct address_space *mapping, pgoff_t offset)
637{ 641{
642 void **pagep;
638 struct page *page; 643 struct page *page;
639 644
640 read_lock_irq(&mapping->tree_lock); 645 rcu_read_lock();
641 page = radix_tree_lookup(&mapping->page_tree, offset); 646repeat:
642 if (page) 647 page = NULL;
643 page_cache_get(page); 648 pagep = radix_tree_lookup_slot(&mapping->page_tree, offset);
644 read_unlock_irq(&mapping->tree_lock); 649 if (pagep) {
650 page = radix_tree_deref_slot(pagep);
651 if (unlikely(!page || page == RADIX_TREE_RETRY))
652 goto repeat;
653
654 if (!page_cache_get_speculative(page))
655 goto repeat;
656
657 /*
658 * Has the page moved?
659 * This is part of the lockless pagecache protocol. See
660 * include/linux/pagemap.h for details.
661 */
662 if (unlikely(page != *pagep)) {
663 page_cache_release(page);
664 goto repeat;
665 }
666 }
667 rcu_read_unlock();
668
645 return page; 669 return page;
646} 670}
647EXPORT_SYMBOL(find_get_page); 671EXPORT_SYMBOL(find_get_page);
@@ -656,32 +680,22 @@ EXPORT_SYMBOL(find_get_page);
656 * 680 *
657 * Returns zero if the page was not present. find_lock_page() may sleep. 681 * Returns zero if the page was not present. find_lock_page() may sleep.
658 */ 682 */
659struct page *find_lock_page(struct address_space *mapping, 683struct page *find_lock_page(struct address_space *mapping, pgoff_t offset)
660 pgoff_t offset)
661{ 684{
662 struct page *page; 685 struct page *page;
663 686
664repeat: 687repeat:
665 read_lock_irq(&mapping->tree_lock); 688 page = find_get_page(mapping, offset);
666 page = radix_tree_lookup(&mapping->page_tree, offset);
667 if (page) { 689 if (page) {
668 page_cache_get(page); 690 lock_page(page);
669 if (TestSetPageLocked(page)) { 691 /* Has the page been truncated? */
670 read_unlock_irq(&mapping->tree_lock); 692 if (unlikely(page->mapping != mapping)) {
671 __lock_page(page); 693 unlock_page(page);
672 694 page_cache_release(page);
673 /* Has the page been truncated while we slept? */ 695 goto repeat;
674 if (unlikely(page->mapping != mapping)) {
675 unlock_page(page);
676 page_cache_release(page);
677 goto repeat;
678 }
679 VM_BUG_ON(page->index != offset);
680 goto out;
681 } 696 }
697 VM_BUG_ON(page->index != offset);
682 } 698 }
683 read_unlock_irq(&mapping->tree_lock);
684out:
685 return page; 699 return page;
686} 700}
687EXPORT_SYMBOL(find_lock_page); 701EXPORT_SYMBOL(find_lock_page);
@@ -747,13 +761,39 @@ unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
747{ 761{
748 unsigned int i; 762 unsigned int i;
749 unsigned int ret; 763 unsigned int ret;
764 unsigned int nr_found;
765
766 rcu_read_lock();
767restart:
768 nr_found = radix_tree_gang_lookup_slot(&mapping->page_tree,
769 (void ***)pages, start, nr_pages);
770 ret = 0;
771 for (i = 0; i < nr_found; i++) {
772 struct page *page;
773repeat:
774 page = radix_tree_deref_slot((void **)pages[i]);
775 if (unlikely(!page))
776 continue;
777 /*
778 * this can only trigger if nr_found == 1, making livelock
779 * a non issue.
780 */
781 if (unlikely(page == RADIX_TREE_RETRY))
782 goto restart;
750 783
751 read_lock_irq(&mapping->tree_lock); 784 if (!page_cache_get_speculative(page))
752 ret = radix_tree_gang_lookup(&mapping->page_tree, 785 goto repeat;
753 (void **)pages, start, nr_pages); 786
754 for (i = 0; i < ret; i++) 787 /* Has the page moved? */
755 page_cache_get(pages[i]); 788 if (unlikely(page != *((void **)pages[i]))) {
756 read_unlock_irq(&mapping->tree_lock); 789 page_cache_release(page);
790 goto repeat;
791 }
792
793 pages[ret] = page;
794 ret++;
795 }
796 rcu_read_unlock();
757 return ret; 797 return ret;
758} 798}
759 799
@@ -774,19 +814,44 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index,
774{ 814{
775 unsigned int i; 815 unsigned int i;
776 unsigned int ret; 816 unsigned int ret;
817 unsigned int nr_found;
818
819 rcu_read_lock();
820restart:
821 nr_found = radix_tree_gang_lookup_slot(&mapping->page_tree,
822 (void ***)pages, index, nr_pages);
823 ret = 0;
824 for (i = 0; i < nr_found; i++) {
825 struct page *page;
826repeat:
827 page = radix_tree_deref_slot((void **)pages[i]);
828 if (unlikely(!page))
829 continue;
830 /*
831 * this can only trigger if nr_found == 1, making livelock
832 * a non issue.
833 */
834 if (unlikely(page == RADIX_TREE_RETRY))
835 goto restart;
777 836
778 read_lock_irq(&mapping->tree_lock); 837 if (page->mapping == NULL || page->index != index)
779 ret = radix_tree_gang_lookup(&mapping->page_tree,
780 (void **)pages, index, nr_pages);
781 for (i = 0; i < ret; i++) {
782 if (pages[i]->mapping == NULL || pages[i]->index != index)
783 break; 838 break;
784 839
785 page_cache_get(pages[i]); 840 if (!page_cache_get_speculative(page))
841 goto repeat;
842
843 /* Has the page moved? */
844 if (unlikely(page != *((void **)pages[i]))) {
845 page_cache_release(page);
846 goto repeat;
847 }
848
849 pages[ret] = page;
850 ret++;
786 index++; 851 index++;
787 } 852 }
788 read_unlock_irq(&mapping->tree_lock); 853 rcu_read_unlock();
789 return i; 854 return ret;
790} 855}
791EXPORT_SYMBOL(find_get_pages_contig); 856EXPORT_SYMBOL(find_get_pages_contig);
792 857
@@ -806,15 +871,43 @@ unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
806{ 871{
807 unsigned int i; 872 unsigned int i;
808 unsigned int ret; 873 unsigned int ret;
874 unsigned int nr_found;
875
876 rcu_read_lock();
877restart:
878 nr_found = radix_tree_gang_lookup_tag_slot(&mapping->page_tree,
879 (void ***)pages, *index, nr_pages, tag);
880 ret = 0;
881 for (i = 0; i < nr_found; i++) {
882 struct page *page;
883repeat:
884 page = radix_tree_deref_slot((void **)pages[i]);
885 if (unlikely(!page))
886 continue;
887 /*
888 * this can only trigger if nr_found == 1, making livelock
889 * a non issue.
890 */
891 if (unlikely(page == RADIX_TREE_RETRY))
892 goto restart;
893
894 if (!page_cache_get_speculative(page))
895 goto repeat;
896
897 /* Has the page moved? */
898 if (unlikely(page != *((void **)pages[i]))) {
899 page_cache_release(page);
900 goto repeat;
901 }
902
903 pages[ret] = page;
904 ret++;
905 }
906 rcu_read_unlock();
809 907
810 read_lock_irq(&mapping->tree_lock);
811 ret = radix_tree_gang_lookup_tag(&mapping->page_tree,
812 (void **)pages, *index, nr_pages, tag);
813 for (i = 0; i < ret; i++)
814 page_cache_get(pages[i]);
815 if (ret) 908 if (ret)
816 *index = pages[ret - 1]->index + 1; 909 *index = pages[ret - 1]->index + 1;
817 read_unlock_irq(&mapping->tree_lock); 910
818 return ret; 911 return ret;
819} 912}
820EXPORT_SYMBOL(find_get_pages_tag); 913EXPORT_SYMBOL(find_get_pages_tag);
@@ -930,8 +1023,17 @@ find_page:
930 ra, filp, page, 1023 ra, filp, page,
931 index, last_index - index); 1024 index, last_index - index);
932 } 1025 }
933 if (!PageUptodate(page)) 1026 if (!PageUptodate(page)) {
934 goto page_not_up_to_date; 1027 if (inode->i_blkbits == PAGE_CACHE_SHIFT ||
1028 !mapping->a_ops->is_partially_uptodate)
1029 goto page_not_up_to_date;
1030 if (TestSetPageLocked(page))
1031 goto page_not_up_to_date;
1032 if (!mapping->a_ops->is_partially_uptodate(page,
1033 desc, offset))
1034 goto page_not_up_to_date_locked;
1035 unlock_page(page);
1036 }
935page_ok: 1037page_ok:
936 /* 1038 /*
937 * i_size must be checked after we know the page is Uptodate. 1039 * i_size must be checked after we know the page is Uptodate.
@@ -1001,6 +1103,7 @@ page_not_up_to_date:
1001 if (lock_page_killable(page)) 1103 if (lock_page_killable(page))
1002 goto readpage_eio; 1104 goto readpage_eio;
1003 1105
1106page_not_up_to_date_locked:
1004 /* Did it get truncated before we got the lock? */ 1107 /* Did it get truncated before we got the lock? */
1005 if (!page->mapping) { 1108 if (!page->mapping) {
1006 unlock_page(page); 1109 unlock_page(page);
@@ -1665,8 +1768,9 @@ static int __remove_suid(struct dentry *dentry, int kill)
1665 return notify_change(dentry, &newattrs); 1768 return notify_change(dentry, &newattrs);
1666} 1769}
1667 1770
1668int remove_suid(struct dentry *dentry) 1771int file_remove_suid(struct file *file)
1669{ 1772{
1773 struct dentry *dentry = file->f_path.dentry;
1670 int killsuid = should_remove_suid(dentry); 1774 int killsuid = should_remove_suid(dentry);
1671 int killpriv = security_inode_need_killpriv(dentry); 1775 int killpriv = security_inode_need_killpriv(dentry);
1672 int error = 0; 1776 int error = 0;
@@ -1680,7 +1784,7 @@ int remove_suid(struct dentry *dentry)
1680 1784
1681 return error; 1785 return error;
1682} 1786}
1683EXPORT_SYMBOL(remove_suid); 1787EXPORT_SYMBOL(file_remove_suid);
1684 1788
1685static size_t __iovec_copy_from_user_inatomic(char *vaddr, 1789static size_t __iovec_copy_from_user_inatomic(char *vaddr,
1686 const struct iovec *iov, size_t base, size_t bytes) 1790 const struct iovec *iov, size_t base, size_t bytes)
@@ -2436,7 +2540,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
2436 if (count == 0) 2540 if (count == 0)
2437 goto out; 2541 goto out;
2438 2542
2439 err = remove_suid(file->f_path.dentry); 2543 err = file_remove_suid(file);
2440 if (err) 2544 if (err)
2441 goto out; 2545 goto out;
2442 2546
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 3e744abcce9d..380ab402d711 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/uio.h> 14#include <linux/uio.h>
15#include <linux/rmap.h> 15#include <linux/rmap.h>
16#include <linux/mmu_notifier.h>
16#include <linux/sched.h> 17#include <linux/sched.h>
17#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
18#include <asm/io.h> 19#include <asm/io.h>
@@ -188,7 +189,7 @@ __xip_unmap (struct address_space * mapping,
188 if (pte) { 189 if (pte) {
189 /* Nuke the page table entry. */ 190 /* Nuke the page table entry. */
190 flush_cache_page(vma, address, pte_pfn(*pte)); 191 flush_cache_page(vma, address, pte_pfn(*pte));
191 pteval = ptep_clear_flush(vma, address, pte); 192 pteval = ptep_clear_flush_notify(vma, address, pte);
192 page_remove_rmap(page, vma); 193 page_remove_rmap(page, vma);
193 dec_mm_counter(mm, file_rss); 194 dec_mm_counter(mm, file_rss);
194 BUG_ON(pte_dirty(pteval)); 195 BUG_ON(pte_dirty(pteval));
@@ -380,7 +381,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
380 if (count == 0) 381 if (count == 0)
381 goto out_backing; 382 goto out_backing;
382 383
383 ret = remove_suid(filp->f_path.dentry); 384 ret = file_remove_suid(filp);
384 if (ret) 385 if (ret)
385 goto out_backing; 386 goto out_backing;
386 387
diff --git a/mm/fremap.c b/mm/fremap.c
index 07a9c82ce1a3..7881638e4a12 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -15,6 +15,7 @@
15#include <linux/rmap.h> 15#include <linux/rmap.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/syscalls.h> 17#include <linux/syscalls.h>
18#include <linux/mmu_notifier.h>
18 19
19#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
20#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
@@ -214,7 +215,9 @@ asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
214 spin_unlock(&mapping->i_mmap_lock); 215 spin_unlock(&mapping->i_mmap_lock);
215 } 216 }
216 217
218 mmu_notifier_invalidate_range_start(mm, start, start + size);
217 err = populate_range(mm, vma, start, size, pgoff); 219 err = populate_range(mm, vma, start, size, pgoff);
220 mmu_notifier_invalidate_range_end(mm, start, start + size);
218 if (!err && !(flags & MAP_NONBLOCK)) { 221 if (!err && !(flags & MAP_NONBLOCK)) {
219 if (unlikely(has_write_lock)) { 222 if (unlikely(has_write_lock)) {
220 downgrade_write(&mm->mmap_sem); 223 downgrade_write(&mm->mmap_sem);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a8bf4ab01f86..254ce2b90158 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -9,6 +9,7 @@
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/sysctl.h> 10#include <linux/sysctl.h>
11#include <linux/highmem.h> 11#include <linux/highmem.h>
12#include <linux/mmu_notifier.h>
12#include <linux/nodemask.h> 13#include <linux/nodemask.h>
13#include <linux/pagemap.h> 14#include <linux/pagemap.h>
14#include <linux/mempolicy.h> 15#include <linux/mempolicy.h>
@@ -19,6 +20,7 @@
19 20
20#include <asm/page.h> 21#include <asm/page.h>
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
23#include <asm/io.h>
22 24
23#include <linux/hugetlb.h> 25#include <linux/hugetlb.h>
24#include "internal.h" 26#include "internal.h"
@@ -1026,18 +1028,6 @@ static void __init report_hugepages(void)
1026 } 1028 }
1027} 1029}
1028 1030
1029static unsigned int cpuset_mems_nr(unsigned int *array)
1030{
1031 int node;
1032 unsigned int nr = 0;
1033
1034 for_each_node_mask(node, cpuset_current_mems_allowed)
1035 nr += array[node];
1036
1037 return nr;
1038}
1039
1040#ifdef CONFIG_SYSCTL
1041#ifdef CONFIG_HIGHMEM 1031#ifdef CONFIG_HIGHMEM
1042static void try_to_free_low(struct hstate *h, unsigned long count) 1032static void try_to_free_low(struct hstate *h, unsigned long count)
1043{ 1033{
@@ -1386,6 +1376,18 @@ static int __init hugetlb_default_setup(char *s)
1386} 1376}
1387__setup("default_hugepagesz=", hugetlb_default_setup); 1377__setup("default_hugepagesz=", hugetlb_default_setup);
1388 1378
1379static unsigned int cpuset_mems_nr(unsigned int *array)
1380{
1381 int node;
1382 unsigned int nr = 0;
1383
1384 for_each_node_mask(node, cpuset_current_mems_allowed)
1385 nr += array[node];
1386
1387 return nr;
1388}
1389
1390#ifdef CONFIG_SYSCTL
1389int hugetlb_sysctl_handler(struct ctl_table *table, int write, 1391int hugetlb_sysctl_handler(struct ctl_table *table, int write,
1390 struct file *file, void __user *buffer, 1392 struct file *file, void __user *buffer,
1391 size_t *length, loff_t *ppos) 1393 size_t *length, loff_t *ppos)
@@ -1672,6 +1674,7 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
1672 BUG_ON(start & ~huge_page_mask(h)); 1674 BUG_ON(start & ~huge_page_mask(h));
1673 BUG_ON(end & ~huge_page_mask(h)); 1675 BUG_ON(end & ~huge_page_mask(h));
1674 1676
1677 mmu_notifier_invalidate_range_start(mm, start, end);
1675 spin_lock(&mm->page_table_lock); 1678 spin_lock(&mm->page_table_lock);
1676 for (address = start; address < end; address += sz) { 1679 for (address = start; address < end; address += sz) {
1677 ptep = huge_pte_offset(mm, address); 1680 ptep = huge_pte_offset(mm, address);
@@ -1713,6 +1716,7 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
1713 } 1716 }
1714 spin_unlock(&mm->page_table_lock); 1717 spin_unlock(&mm->page_table_lock);
1715 flush_tlb_range(vma, start, end); 1718 flush_tlb_range(vma, start, end);
1719 mmu_notifier_invalidate_range_end(mm, start, end);
1716 list_for_each_entry_safe(page, tmp, &page_list, lru) { 1720 list_for_each_entry_safe(page, tmp, &page_list, lru) {
1717 list_del(&page->lru); 1721 list_del(&page->lru);
1718 put_page(page); 1722 put_page(page);
diff --git a/mm/memory.c b/mm/memory.c
index 262e3eb6601a..67f0ab9077d9 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -51,6 +51,7 @@
51#include <linux/init.h> 51#include <linux/init.h>
52#include <linux/writeback.h> 52#include <linux/writeback.h>
53#include <linux/memcontrol.h> 53#include <linux/memcontrol.h>
54#include <linux/mmu_notifier.h>
54 55
55#include <asm/pgalloc.h> 56#include <asm/pgalloc.h>
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
@@ -374,7 +375,8 @@ static inline void add_mm_rss(struct mm_struct *mm, int file_rss, int anon_rss)
374 * 375 *
375 * The calling function must still handle the error. 376 * The calling function must still handle the error.
376 */ 377 */
377void print_bad_pte(struct vm_area_struct *vma, pte_t pte, unsigned long vaddr) 378static void print_bad_pte(struct vm_area_struct *vma, pte_t pte,
379 unsigned long vaddr)
378{ 380{
379 printk(KERN_ERR "Bad pte = %08llx, process = %s, " 381 printk(KERN_ERR "Bad pte = %08llx, process = %s, "
380 "vm_flags = %lx, vaddr = %lx\n", 382 "vm_flags = %lx, vaddr = %lx\n",
@@ -651,6 +653,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
651 unsigned long next; 653 unsigned long next;
652 unsigned long addr = vma->vm_start; 654 unsigned long addr = vma->vm_start;
653 unsigned long end = vma->vm_end; 655 unsigned long end = vma->vm_end;
656 int ret;
654 657
655 /* 658 /*
656 * Don't copy ptes where a page fault will fill them correctly. 659 * Don't copy ptes where a page fault will fill them correctly.
@@ -666,17 +669,33 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
666 if (is_vm_hugetlb_page(vma)) 669 if (is_vm_hugetlb_page(vma))
667 return copy_hugetlb_page_range(dst_mm, src_mm, vma); 670 return copy_hugetlb_page_range(dst_mm, src_mm, vma);
668 671
672 /*
673 * We need to invalidate the secondary MMU mappings only when
674 * there could be a permission downgrade on the ptes of the
675 * parent mm. And a permission downgrade will only happen if
676 * is_cow_mapping() returns true.
677 */
678 if (is_cow_mapping(vma->vm_flags))
679 mmu_notifier_invalidate_range_start(src_mm, addr, end);
680
681 ret = 0;
669 dst_pgd = pgd_offset(dst_mm, addr); 682 dst_pgd = pgd_offset(dst_mm, addr);
670 src_pgd = pgd_offset(src_mm, addr); 683 src_pgd = pgd_offset(src_mm, addr);
671 do { 684 do {
672 next = pgd_addr_end(addr, end); 685 next = pgd_addr_end(addr, end);
673 if (pgd_none_or_clear_bad(src_pgd)) 686 if (pgd_none_or_clear_bad(src_pgd))
674 continue; 687 continue;
675 if (copy_pud_range(dst_mm, src_mm, dst_pgd, src_pgd, 688 if (unlikely(copy_pud_range(dst_mm, src_mm, dst_pgd, src_pgd,
676 vma, addr, next)) 689 vma, addr, next))) {
677 return -ENOMEM; 690 ret = -ENOMEM;
691 break;
692 }
678 } while (dst_pgd++, src_pgd++, addr = next, addr != end); 693 } while (dst_pgd++, src_pgd++, addr = next, addr != end);
679 return 0; 694
695 if (is_cow_mapping(vma->vm_flags))
696 mmu_notifier_invalidate_range_end(src_mm,
697 vma->vm_start, end);
698 return ret;
680} 699}
681 700
682static unsigned long zap_pte_range(struct mmu_gather *tlb, 701static unsigned long zap_pte_range(struct mmu_gather *tlb,
@@ -880,7 +899,9 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
880 unsigned long start = start_addr; 899 unsigned long start = start_addr;
881 spinlock_t *i_mmap_lock = details? details->i_mmap_lock: NULL; 900 spinlock_t *i_mmap_lock = details? details->i_mmap_lock: NULL;
882 int fullmm = (*tlbp)->fullmm; 901 int fullmm = (*tlbp)->fullmm;
902 struct mm_struct *mm = vma->vm_mm;
883 903
904 mmu_notifier_invalidate_range_start(mm, start_addr, end_addr);
884 for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) { 905 for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
885 unsigned long end; 906 unsigned long end;
886 907
@@ -945,6 +966,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlbp,
945 } 966 }
946 } 967 }
947out: 968out:
969 mmu_notifier_invalidate_range_end(mm, start_addr, end_addr);
948 return start; /* which is now the end (or restart) address */ 970 return start; /* which is now the end (or restart) address */
949} 971}
950 972
@@ -1615,10 +1637,11 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
1615{ 1637{
1616 pgd_t *pgd; 1638 pgd_t *pgd;
1617 unsigned long next; 1639 unsigned long next;
1618 unsigned long end = addr + size; 1640 unsigned long start = addr, end = addr + size;
1619 int err; 1641 int err;
1620 1642
1621 BUG_ON(addr >= end); 1643 BUG_ON(addr >= end);
1644 mmu_notifier_invalidate_range_start(mm, start, end);
1622 pgd = pgd_offset(mm, addr); 1645 pgd = pgd_offset(mm, addr);
1623 do { 1646 do {
1624 next = pgd_addr_end(addr, end); 1647 next = pgd_addr_end(addr, end);
@@ -1626,6 +1649,7 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
1626 if (err) 1649 if (err)
1627 break; 1650 break;
1628 } while (pgd++, addr = next, addr != end); 1651 } while (pgd++, addr = next, addr != end);
1652 mmu_notifier_invalidate_range_end(mm, start, end);
1629 return err; 1653 return err;
1630} 1654}
1631EXPORT_SYMBOL_GPL(apply_to_page_range); 1655EXPORT_SYMBOL_GPL(apply_to_page_range);
@@ -1838,7 +1862,7 @@ gotten:
1838 * seen in the presence of one thread doing SMC and another 1862 * seen in the presence of one thread doing SMC and another
1839 * thread doing COW. 1863 * thread doing COW.
1840 */ 1864 */
1841 ptep_clear_flush(vma, address, page_table); 1865 ptep_clear_flush_notify(vma, address, page_table);
1842 set_pte_at(mm, address, page_table, entry); 1866 set_pte_at(mm, address, page_table, entry);
1843 update_mmu_cache(vma, address, entry); 1867 update_mmu_cache(vma, address, entry);
1844 lru_cache_add_active(new_page); 1868 lru_cache_add_active(new_page);
diff --git a/mm/migrate.c b/mm/migrate.c
index d8c65a65c61d..153572fb60b8 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -285,7 +285,15 @@ void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
285 285
286 page = migration_entry_to_page(entry); 286 page = migration_entry_to_page(entry);
287 287
288 get_page(page); 288 /*
289 * Once radix-tree replacement of page migration started, page_count
290 * *must* be zero. And, we don't want to call wait_on_page_locked()
291 * against a page without get_page().
292 * So, we use get_page_unless_zero(), here. Even failed, page fault
293 * will occur again.
294 */
295 if (!get_page_unless_zero(page))
296 goto out;
289 pte_unmap_unlock(ptep, ptl); 297 pte_unmap_unlock(ptep, ptl);
290 wait_on_page_locked(page); 298 wait_on_page_locked(page);
291 put_page(page); 299 put_page(page);
@@ -305,6 +313,7 @@ out:
305static int migrate_page_move_mapping(struct address_space *mapping, 313static int migrate_page_move_mapping(struct address_space *mapping,
306 struct page *newpage, struct page *page) 314 struct page *newpage, struct page *page)
307{ 315{
316 int expected_count;
308 void **pslot; 317 void **pslot;
309 318
310 if (!mapping) { 319 if (!mapping) {
@@ -314,14 +323,20 @@ static int migrate_page_move_mapping(struct address_space *mapping,
314 return 0; 323 return 0;
315 } 324 }
316 325
317 write_lock_irq(&mapping->tree_lock); 326 spin_lock_irq(&mapping->tree_lock);
318 327
319 pslot = radix_tree_lookup_slot(&mapping->page_tree, 328 pslot = radix_tree_lookup_slot(&mapping->page_tree,
320 page_index(page)); 329 page_index(page));
321 330
322 if (page_count(page) != 2 + !!PagePrivate(page) || 331 expected_count = 2 + !!PagePrivate(page);
332 if (page_count(page) != expected_count ||
323 (struct page *)radix_tree_deref_slot(pslot) != page) { 333 (struct page *)radix_tree_deref_slot(pslot) != page) {
324 write_unlock_irq(&mapping->tree_lock); 334 spin_unlock_irq(&mapping->tree_lock);
335 return -EAGAIN;
336 }
337
338 if (!page_freeze_refs(page, expected_count)) {
339 spin_unlock_irq(&mapping->tree_lock);
325 return -EAGAIN; 340 return -EAGAIN;
326 } 341 }
327 342
@@ -338,6 +353,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
338 353
339 radix_tree_replace_slot(pslot, newpage); 354 radix_tree_replace_slot(pslot, newpage);
340 355
356 page_unfreeze_refs(page, expected_count);
341 /* 357 /*
342 * Drop cache reference from old page. 358 * Drop cache reference from old page.
343 * We know this isn't the last reference. 359 * We know this isn't the last reference.
@@ -357,10 +373,9 @@ static int migrate_page_move_mapping(struct address_space *mapping,
357 __dec_zone_page_state(page, NR_FILE_PAGES); 373 __dec_zone_page_state(page, NR_FILE_PAGES);
358 __inc_zone_page_state(newpage, NR_FILE_PAGES); 374 __inc_zone_page_state(newpage, NR_FILE_PAGES);
359 375
360 write_unlock_irq(&mapping->tree_lock); 376 spin_unlock_irq(&mapping->tree_lock);
361 if (!PageSwapCache(newpage)) { 377 if (!PageSwapCache(newpage))
362 mem_cgroup_uncharge_cache_page(page); 378 mem_cgroup_uncharge_cache_page(page);
363 }
364 379
365 return 0; 380 return 0;
366} 381}
diff --git a/mm/mmap.c b/mm/mmap.c
index 5e0cc99e9cd5..245c3d69067b 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -26,6 +26,7 @@
26#include <linux/mount.h> 26#include <linux/mount.h>
27#include <linux/mempolicy.h> 27#include <linux/mempolicy.h>
28#include <linux/rmap.h> 28#include <linux/rmap.h>
29#include <linux/mmu_notifier.h>
29 30
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/cacheflush.h> 32#include <asm/cacheflush.h>
@@ -2061,6 +2062,7 @@ void exit_mmap(struct mm_struct *mm)
2061 2062
2062 /* mm's last user has gone, and its about to be pulled down */ 2063 /* mm's last user has gone, and its about to be pulled down */
2063 arch_exit_mmap(mm); 2064 arch_exit_mmap(mm);
2065 mmu_notifier_release(mm);
2064 2066
2065 lru_add_drain(); 2067 lru_add_drain();
2066 flush_cache_mm(mm); 2068 flush_cache_mm(mm);
@@ -2268,3 +2270,161 @@ int install_special_mapping(struct mm_struct *mm,
2268 2270
2269 return 0; 2271 return 0;
2270} 2272}
2273
2274static DEFINE_MUTEX(mm_all_locks_mutex);
2275
2276static void vm_lock_anon_vma(struct anon_vma *anon_vma)
2277{
2278 if (!test_bit(0, (unsigned long *) &anon_vma->head.next)) {
2279 /*
2280 * The LSB of head.next can't change from under us
2281 * because we hold the mm_all_locks_mutex.
2282 */
2283 spin_lock(&anon_vma->lock);
2284 /*
2285 * We can safely modify head.next after taking the
2286 * anon_vma->lock. If some other vma in this mm shares
2287 * the same anon_vma we won't take it again.
2288 *
2289 * No need of atomic instructions here, head.next
2290 * can't change from under us thanks to the
2291 * anon_vma->lock.
2292 */
2293 if (__test_and_set_bit(0, (unsigned long *)
2294 &anon_vma->head.next))
2295 BUG();
2296 }
2297}
2298
2299static void vm_lock_mapping(struct address_space *mapping)
2300{
2301 if (!test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) {
2302 /*
2303 * AS_MM_ALL_LOCKS can't change from under us because
2304 * we hold the mm_all_locks_mutex.
2305 *
2306 * Operations on ->flags have to be atomic because
2307 * even if AS_MM_ALL_LOCKS is stable thanks to the
2308 * mm_all_locks_mutex, there may be other cpus
2309 * changing other bitflags in parallel to us.
2310 */
2311 if (test_and_set_bit(AS_MM_ALL_LOCKS, &mapping->flags))
2312 BUG();
2313 spin_lock(&mapping->i_mmap_lock);
2314 }
2315}
2316
2317/*
2318 * This operation locks against the VM for all pte/vma/mm related
2319 * operations that could ever happen on a certain mm. This includes
2320 * vmtruncate, try_to_unmap, and all page faults.
2321 *
2322 * The caller must take the mmap_sem in write mode before calling
2323 * mm_take_all_locks(). The caller isn't allowed to release the
2324 * mmap_sem until mm_drop_all_locks() returns.
2325 *
2326 * mmap_sem in write mode is required in order to block all operations
2327 * that could modify pagetables and free pages without need of
2328 * altering the vma layout (for example populate_range() with
2329 * nonlinear vmas). It's also needed in write mode to avoid new
2330 * anon_vmas to be associated with existing vmas.
2331 *
2332 * A single task can't take more than one mm_take_all_locks() in a row
2333 * or it would deadlock.
2334 *
2335 * The LSB in anon_vma->head.next and the AS_MM_ALL_LOCKS bitflag in
2336 * mapping->flags avoid to take the same lock twice, if more than one
2337 * vma in this mm is backed by the same anon_vma or address_space.
2338 *
2339 * We can take all the locks in random order because the VM code
2340 * taking i_mmap_lock or anon_vma->lock outside the mmap_sem never
2341 * takes more than one of them in a row. Secondly we're protected
2342 * against a concurrent mm_take_all_locks() by the mm_all_locks_mutex.
2343 *
2344 * mm_take_all_locks() and mm_drop_all_locks are expensive operations
2345 * that may have to take thousand of locks.
2346 *
2347 * mm_take_all_locks() can fail if it's interrupted by signals.
2348 */
2349int mm_take_all_locks(struct mm_struct *mm)
2350{
2351 struct vm_area_struct *vma;
2352 int ret = -EINTR;
2353
2354 BUG_ON(down_read_trylock(&mm->mmap_sem));
2355
2356 mutex_lock(&mm_all_locks_mutex);
2357
2358 for (vma = mm->mmap; vma; vma = vma->vm_next) {
2359 if (signal_pending(current))
2360 goto out_unlock;
2361 if (vma->anon_vma)
2362 vm_lock_anon_vma(vma->anon_vma);
2363 if (vma->vm_file && vma->vm_file->f_mapping)
2364 vm_lock_mapping(vma->vm_file->f_mapping);
2365 }
2366 ret = 0;
2367
2368out_unlock:
2369 if (ret)
2370 mm_drop_all_locks(mm);
2371
2372 return ret;
2373}
2374
2375static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
2376{
2377 if (test_bit(0, (unsigned long *) &anon_vma->head.next)) {
2378 /*
2379 * The LSB of head.next can't change to 0 from under
2380 * us because we hold the mm_all_locks_mutex.
2381 *
2382 * We must however clear the bitflag before unlocking
2383 * the vma so the users using the anon_vma->head will
2384 * never see our bitflag.
2385 *
2386 * No need of atomic instructions here, head.next
2387 * can't change from under us until we release the
2388 * anon_vma->lock.
2389 */
2390 if (!__test_and_clear_bit(0, (unsigned long *)
2391 &anon_vma->head.next))
2392 BUG();
2393 spin_unlock(&anon_vma->lock);
2394 }
2395}
2396
2397static void vm_unlock_mapping(struct address_space *mapping)
2398{
2399 if (test_bit(AS_MM_ALL_LOCKS, &mapping->flags)) {
2400 /*
2401 * AS_MM_ALL_LOCKS can't change to 0 from under us
2402 * because we hold the mm_all_locks_mutex.
2403 */
2404 spin_unlock(&mapping->i_mmap_lock);
2405 if (!test_and_clear_bit(AS_MM_ALL_LOCKS,
2406 &mapping->flags))
2407 BUG();
2408 }
2409}
2410
2411/*
2412 * The mmap_sem cannot be released by the caller until
2413 * mm_drop_all_locks() returns.
2414 */
2415void mm_drop_all_locks(struct mm_struct *mm)
2416{
2417 struct vm_area_struct *vma;
2418
2419 BUG_ON(down_read_trylock(&mm->mmap_sem));
2420 BUG_ON(!mutex_is_locked(&mm_all_locks_mutex));
2421
2422 for (vma = mm->mmap; vma; vma = vma->vm_next) {
2423 if (vma->anon_vma)
2424 vm_unlock_anon_vma(vma->anon_vma);
2425 if (vma->vm_file && vma->vm_file->f_mapping)
2426 vm_unlock_mapping(vma->vm_file->f_mapping);
2427 }
2428
2429 mutex_unlock(&mm_all_locks_mutex);
2430}
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
new file mode 100644
index 000000000000..5f4ef0250bee
--- /dev/null
+++ b/mm/mmu_notifier.c
@@ -0,0 +1,277 @@
1/*
2 * linux/mm/mmu_notifier.c
3 *
4 * Copyright (C) 2008 Qumranet, Inc.
5 * Copyright (C) 2008 SGI
6 * Christoph Lameter <clameter@sgi.com>
7 *
8 * This work is licensed under the terms of the GNU GPL, version 2. See
9 * the COPYING file in the top-level directory.
10 */
11
12#include <linux/rculist.h>
13#include <linux/mmu_notifier.h>
14#include <linux/module.h>
15#include <linux/mm.h>
16#include <linux/err.h>
17#include <linux/rcupdate.h>
18#include <linux/sched.h>
19
20/*
21 * This function can't run concurrently against mmu_notifier_register
22 * because mm->mm_users > 0 during mmu_notifier_register and exit_mmap
23 * runs with mm_users == 0. Other tasks may still invoke mmu notifiers
24 * in parallel despite there being no task using this mm any more,
25 * through the vmas outside of the exit_mmap context, such as with
26 * vmtruncate. This serializes against mmu_notifier_unregister with
27 * the mmu_notifier_mm->lock in addition to RCU and it serializes
28 * against the other mmu notifiers with RCU. struct mmu_notifier_mm
29 * can't go away from under us as exit_mmap holds an mm_count pin
30 * itself.
31 */
32void __mmu_notifier_release(struct mm_struct *mm)
33{
34 struct mmu_notifier *mn;
35
36 spin_lock(&mm->mmu_notifier_mm->lock);
37 while (unlikely(!hlist_empty(&mm->mmu_notifier_mm->list))) {
38 mn = hlist_entry(mm->mmu_notifier_mm->list.first,
39 struct mmu_notifier,
40 hlist);
41 /*
42 * We arrived before mmu_notifier_unregister so
43 * mmu_notifier_unregister will do nothing other than
44 * to wait ->release to finish and
45 * mmu_notifier_unregister to return.
46 */
47 hlist_del_init_rcu(&mn->hlist);
48 /*
49 * RCU here will block mmu_notifier_unregister until
50 * ->release returns.
51 */
52 rcu_read_lock();
53 spin_unlock(&mm->mmu_notifier_mm->lock);
54 /*
55 * if ->release runs before mmu_notifier_unregister it
56 * must be handled as it's the only way for the driver
57 * to flush all existing sptes and stop the driver
58 * from establishing any more sptes before all the
59 * pages in the mm are freed.
60 */
61 if (mn->ops->release)
62 mn->ops->release(mn, mm);
63 rcu_read_unlock();
64 spin_lock(&mm->mmu_notifier_mm->lock);
65 }
66 spin_unlock(&mm->mmu_notifier_mm->lock);
67
68 /*
69 * synchronize_rcu here prevents mmu_notifier_release to
70 * return to exit_mmap (which would proceed freeing all pages
71 * in the mm) until the ->release method returns, if it was
72 * invoked by mmu_notifier_unregister.
73 *
74 * The mmu_notifier_mm can't go away from under us because one
75 * mm_count is hold by exit_mmap.
76 */
77 synchronize_rcu();
78}
79
80/*
81 * If no young bitflag is supported by the hardware, ->clear_flush_young can
82 * unmap the address and return 1 or 0 depending if the mapping previously
83 * existed or not.
84 */
85int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
86 unsigned long address)
87{
88 struct mmu_notifier *mn;
89 struct hlist_node *n;
90 int young = 0;
91
92 rcu_read_lock();
93 hlist_for_each_entry_rcu(mn, n, &mm->mmu_notifier_mm->list, hlist) {
94 if (mn->ops->clear_flush_young)
95 young |= mn->ops->clear_flush_young(mn, mm, address);
96 }
97 rcu_read_unlock();
98
99 return young;
100}
101
102void __mmu_notifier_invalidate_page(struct mm_struct *mm,
103 unsigned long address)
104{
105 struct mmu_notifier *mn;
106 struct hlist_node *n;
107
108 rcu_read_lock();
109 hlist_for_each_entry_rcu(mn, n, &mm->mmu_notifier_mm->list, hlist) {
110 if (mn->ops->invalidate_page)
111 mn->ops->invalidate_page(mn, mm, address);
112 }
113 rcu_read_unlock();
114}
115
116void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
117 unsigned long start, unsigned long end)
118{
119 struct mmu_notifier *mn;
120 struct hlist_node *n;
121
122 rcu_read_lock();
123 hlist_for_each_entry_rcu(mn, n, &mm->mmu_notifier_mm->list, hlist) {
124 if (mn->ops->invalidate_range_start)
125 mn->ops->invalidate_range_start(mn, mm, start, end);
126 }
127 rcu_read_unlock();
128}
129
130void __mmu_notifier_invalidate_range_end(struct mm_struct *mm,
131 unsigned long start, unsigned long end)
132{
133 struct mmu_notifier *mn;
134 struct hlist_node *n;
135
136 rcu_read_lock();
137 hlist_for_each_entry_rcu(mn, n, &mm->mmu_notifier_mm->list, hlist) {
138 if (mn->ops->invalidate_range_end)
139 mn->ops->invalidate_range_end(mn, mm, start, end);
140 }
141 rcu_read_unlock();
142}
143
144static int do_mmu_notifier_register(struct mmu_notifier *mn,
145 struct mm_struct *mm,
146 int take_mmap_sem)
147{
148 struct mmu_notifier_mm *mmu_notifier_mm;
149 int ret;
150
151 BUG_ON(atomic_read(&mm->mm_users) <= 0);
152
153 ret = -ENOMEM;
154 mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm), GFP_KERNEL);
155 if (unlikely(!mmu_notifier_mm))
156 goto out;
157
158 if (take_mmap_sem)
159 down_write(&mm->mmap_sem);
160 ret = mm_take_all_locks(mm);
161 if (unlikely(ret))
162 goto out_cleanup;
163
164 if (!mm_has_notifiers(mm)) {
165 INIT_HLIST_HEAD(&mmu_notifier_mm->list);
166 spin_lock_init(&mmu_notifier_mm->lock);
167 mm->mmu_notifier_mm = mmu_notifier_mm;
168 mmu_notifier_mm = NULL;
169 }
170 atomic_inc(&mm->mm_count);
171
172 /*
173 * Serialize the update against mmu_notifier_unregister. A
174 * side note: mmu_notifier_release can't run concurrently with
175 * us because we hold the mm_users pin (either implicitly as
176 * current->mm or explicitly with get_task_mm() or similar).
177 * We can't race against any other mmu notifier method either
178 * thanks to mm_take_all_locks().
179 */
180 spin_lock(&mm->mmu_notifier_mm->lock);
181 hlist_add_head(&mn->hlist, &mm->mmu_notifier_mm->list);
182 spin_unlock(&mm->mmu_notifier_mm->lock);
183
184 mm_drop_all_locks(mm);
185out_cleanup:
186 if (take_mmap_sem)
187 up_write(&mm->mmap_sem);
188 /* kfree() does nothing if mmu_notifier_mm is NULL */
189 kfree(mmu_notifier_mm);
190out:
191 BUG_ON(atomic_read(&mm->mm_users) <= 0);
192 return ret;
193}
194
195/*
196 * Must not hold mmap_sem nor any other VM related lock when calling
197 * this registration function. Must also ensure mm_users can't go down
198 * to zero while this runs to avoid races with mmu_notifier_release,
199 * so mm has to be current->mm or the mm should be pinned safely such
200 * as with get_task_mm(). If the mm is not current->mm, the mm_users
201 * pin should be released by calling mmput after mmu_notifier_register
202 * returns. mmu_notifier_unregister must be always called to
203 * unregister the notifier. mm_count is automatically pinned to allow
204 * mmu_notifier_unregister to safely run at any time later, before or
205 * after exit_mmap. ->release will always be called before exit_mmap
206 * frees the pages.
207 */
208int mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm)
209{
210 return do_mmu_notifier_register(mn, mm, 1);
211}
212EXPORT_SYMBOL_GPL(mmu_notifier_register);
213
214/*
215 * Same as mmu_notifier_register but here the caller must hold the
216 * mmap_sem in write mode.
217 */
218int __mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm)
219{
220 return do_mmu_notifier_register(mn, mm, 0);
221}
222EXPORT_SYMBOL_GPL(__mmu_notifier_register);
223
224/* this is called after the last mmu_notifier_unregister() returned */
225void __mmu_notifier_mm_destroy(struct mm_struct *mm)
226{
227 BUG_ON(!hlist_empty(&mm->mmu_notifier_mm->list));
228 kfree(mm->mmu_notifier_mm);
229 mm->mmu_notifier_mm = LIST_POISON1; /* debug */
230}
231
232/*
233 * This releases the mm_count pin automatically and frees the mm
234 * structure if it was the last user of it. It serializes against
235 * running mmu notifiers with RCU and against mmu_notifier_unregister
236 * with the unregister lock + RCU. All sptes must be dropped before
237 * calling mmu_notifier_unregister. ->release or any other notifier
238 * method may be invoked concurrently with mmu_notifier_unregister,
239 * and only after mmu_notifier_unregister returned we're guaranteed
240 * that ->release or any other method can't run anymore.
241 */
242void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
243{
244 BUG_ON(atomic_read(&mm->mm_count) <= 0);
245
246 spin_lock(&mm->mmu_notifier_mm->lock);
247 if (!hlist_unhashed(&mn->hlist)) {
248 hlist_del_rcu(&mn->hlist);
249
250 /*
251 * RCU here will force exit_mmap to wait ->release to finish
252 * before freeing the pages.
253 */
254 rcu_read_lock();
255 spin_unlock(&mm->mmu_notifier_mm->lock);
256 /*
257 * exit_mmap will block in mmu_notifier_release to
258 * guarantee ->release is called before freeing the
259 * pages.
260 */
261 if (mn->ops->release)
262 mn->ops->release(mn, mm);
263 rcu_read_unlock();
264 } else
265 spin_unlock(&mm->mmu_notifier_mm->lock);
266
267 /*
268 * Wait any running method to finish, of course including
269 * ->release if it was run by mmu_notifier_relase instead of us.
270 */
271 synchronize_rcu();
272
273 BUG_ON(atomic_read(&mm->mm_count) <= 0);
274
275 mmdrop(mm);
276}
277EXPORT_SYMBOL_GPL(mmu_notifier_unregister);
diff --git a/mm/mprotect.c b/mm/mprotect.c
index abd645a3b0a0..fded06f923f4 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -21,6 +21,7 @@
21#include <linux/syscalls.h> 21#include <linux/syscalls.h>
22#include <linux/swap.h> 22#include <linux/swap.h>
23#include <linux/swapops.h> 23#include <linux/swapops.h>
24#include <linux/mmu_notifier.h>
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25#include <asm/pgtable.h> 26#include <asm/pgtable.h>
26#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
@@ -203,10 +204,12 @@ success:
203 dirty_accountable = 1; 204 dirty_accountable = 1;
204 } 205 }
205 206
207 mmu_notifier_invalidate_range_start(mm, start, end);
206 if (is_vm_hugetlb_page(vma)) 208 if (is_vm_hugetlb_page(vma))
207 hugetlb_change_protection(vma, start, end, vma->vm_page_prot); 209 hugetlb_change_protection(vma, start, end, vma->vm_page_prot);
208 else 210 else
209 change_protection(vma, start, end, vma->vm_page_prot, dirty_accountable); 211 change_protection(vma, start, end, vma->vm_page_prot, dirty_accountable);
212 mmu_notifier_invalidate_range_end(mm, start, end);
210 vm_stat_account(mm, oldflags, vma->vm_file, -nrpages); 213 vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
211 vm_stat_account(mm, newflags, vma->vm_file, nrpages); 214 vm_stat_account(mm, newflags, vma->vm_file, nrpages);
212 return 0; 215 return 0;
diff --git a/mm/mremap.c b/mm/mremap.c
index 08e3c7f2bd15..1a7743923c8c 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/security.h> 19#include <linux/security.h>
20#include <linux/syscalls.h> 20#include <linux/syscalls.h>
21#include <linux/mmu_notifier.h>
21 22
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
@@ -74,7 +75,11 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
74 struct mm_struct *mm = vma->vm_mm; 75 struct mm_struct *mm = vma->vm_mm;
75 pte_t *old_pte, *new_pte, pte; 76 pte_t *old_pte, *new_pte, pte;
76 spinlock_t *old_ptl, *new_ptl; 77 spinlock_t *old_ptl, *new_ptl;
78 unsigned long old_start;
77 79
80 old_start = old_addr;
81 mmu_notifier_invalidate_range_start(vma->vm_mm,
82 old_start, old_end);
78 if (vma->vm_file) { 83 if (vma->vm_file) {
79 /* 84 /*
80 * Subtle point from Rajesh Venkatasubramanian: before 85 * Subtle point from Rajesh Venkatasubramanian: before
@@ -116,6 +121,7 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
116 pte_unmap_unlock(old_pte - 1, old_ptl); 121 pte_unmap_unlock(old_pte - 1, old_ptl);
117 if (mapping) 122 if (mapping)
118 spin_unlock(&mapping->i_mmap_lock); 123 spin_unlock(&mapping->i_mmap_lock);
124 mmu_notifier_invalidate_range_end(vma->vm_mm, old_start, old_end);
119} 125}
120 126
121#define LATENCY_LIMIT (64 * PAGE_SIZE) 127#define LATENCY_LIMIT (64 * PAGE_SIZE)
diff --git a/mm/nommu.c b/mm/nommu.c
index 4462b6a3fcb9..5edccd9c9218 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -22,7 +22,7 @@
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
25#include <linux/ptrace.h> 25#include <linux/tracehook.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/backing-dev.h> 27#include <linux/backing-dev.h>
28#include <linux/mount.h> 28#include <linux/mount.h>
@@ -745,7 +745,7 @@ static unsigned long determine_vm_flags(struct file *file,
745 * it's being traced - otherwise breakpoints set in it may interfere 745 * it's being traced - otherwise breakpoints set in it may interfere
746 * with another untraced process 746 * with another untraced process
747 */ 747 */
748 if ((flags & MAP_PRIVATE) && (current->ptrace & PT_PTRACED)) 748 if ((flags & MAP_PRIVATE) && tracehook_expect_breakpoints(current))
749 vm_flags &= ~VM_MAYSHARE; 749 vm_flags &= ~VM_MAYSHARE;
750 750
751 return vm_flags; 751 return vm_flags;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 94c6d8988ab3..24de8b65fdbd 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1088,7 +1088,7 @@ int __set_page_dirty_nobuffers(struct page *page)
1088 if (!mapping) 1088 if (!mapping)
1089 return 1; 1089 return 1;
1090 1090
1091 write_lock_irq(&mapping->tree_lock); 1091 spin_lock_irq(&mapping->tree_lock);
1092 mapping2 = page_mapping(page); 1092 mapping2 = page_mapping(page);
1093 if (mapping2) { /* Race with truncate? */ 1093 if (mapping2) { /* Race with truncate? */
1094 BUG_ON(mapping2 != mapping); 1094 BUG_ON(mapping2 != mapping);
@@ -1102,7 +1102,7 @@ int __set_page_dirty_nobuffers(struct page *page)
1102 radix_tree_tag_set(&mapping->page_tree, 1102 radix_tree_tag_set(&mapping->page_tree,
1103 page_index(page), PAGECACHE_TAG_DIRTY); 1103 page_index(page), PAGECACHE_TAG_DIRTY);
1104 } 1104 }
1105 write_unlock_irq(&mapping->tree_lock); 1105 spin_unlock_irq(&mapping->tree_lock);
1106 if (mapping->host) { 1106 if (mapping->host) {
1107 /* !PageAnon && !swapper_space */ 1107 /* !PageAnon && !swapper_space */
1108 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 1108 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
@@ -1258,7 +1258,7 @@ int test_clear_page_writeback(struct page *page)
1258 struct backing_dev_info *bdi = mapping->backing_dev_info; 1258 struct backing_dev_info *bdi = mapping->backing_dev_info;
1259 unsigned long flags; 1259 unsigned long flags;
1260 1260
1261 write_lock_irqsave(&mapping->tree_lock, flags); 1261 spin_lock_irqsave(&mapping->tree_lock, flags);
1262 ret = TestClearPageWriteback(page); 1262 ret = TestClearPageWriteback(page);
1263 if (ret) { 1263 if (ret) {
1264 radix_tree_tag_clear(&mapping->page_tree, 1264 radix_tree_tag_clear(&mapping->page_tree,
@@ -1269,7 +1269,7 @@ int test_clear_page_writeback(struct page *page)
1269 __bdi_writeout_inc(bdi); 1269 __bdi_writeout_inc(bdi);
1270 } 1270 }
1271 } 1271 }
1272 write_unlock_irqrestore(&mapping->tree_lock, flags); 1272 spin_unlock_irqrestore(&mapping->tree_lock, flags);
1273 } else { 1273 } else {
1274 ret = TestClearPageWriteback(page); 1274 ret = TestClearPageWriteback(page);
1275 } 1275 }
@@ -1287,7 +1287,7 @@ int test_set_page_writeback(struct page *page)
1287 struct backing_dev_info *bdi = mapping->backing_dev_info; 1287 struct backing_dev_info *bdi = mapping->backing_dev_info;
1288 unsigned long flags; 1288 unsigned long flags;
1289 1289
1290 write_lock_irqsave(&mapping->tree_lock, flags); 1290 spin_lock_irqsave(&mapping->tree_lock, flags);
1291 ret = TestSetPageWriteback(page); 1291 ret = TestSetPageWriteback(page);
1292 if (!ret) { 1292 if (!ret) {
1293 radix_tree_tag_set(&mapping->page_tree, 1293 radix_tree_tag_set(&mapping->page_tree,
@@ -1300,7 +1300,7 @@ int test_set_page_writeback(struct page *page)
1300 radix_tree_tag_clear(&mapping->page_tree, 1300 radix_tree_tag_clear(&mapping->page_tree,
1301 page_index(page), 1301 page_index(page),
1302 PAGECACHE_TAG_DIRTY); 1302 PAGECACHE_TAG_DIRTY);
1303 write_unlock_irqrestore(&mapping->tree_lock, flags); 1303 spin_unlock_irqrestore(&mapping->tree_lock, flags);
1304 } else { 1304 } else {
1305 ret = TestSetPageWriteback(page); 1305 ret = TestSetPageWriteback(page);
1306 } 1306 }
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6da667274df5..3cf3d05b6bd4 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2372,7 +2372,7 @@ static void build_zonelist_cache(pg_data_t *pgdat)
2372 2372
2373#endif /* CONFIG_NUMA */ 2373#endif /* CONFIG_NUMA */
2374 2374
2375/* return values int ....just for stop_machine_run() */ 2375/* return values int ....just for stop_machine() */
2376static int __build_all_zonelists(void *dummy) 2376static int __build_all_zonelists(void *dummy)
2377{ 2377{
2378 int nid; 2378 int nid;
@@ -2397,7 +2397,7 @@ void build_all_zonelists(void)
2397 } else { 2397 } else {
2398 /* we have to stop all cpus to guarantee there is no user 2398 /* we have to stop all cpus to guarantee there is no user
2399 of zonelist */ 2399 of zonelist */
2400 stop_machine_run(__build_all_zonelists, NULL, NR_CPUS); 2400 stop_machine(__build_all_zonelists, NULL, NULL);
2401 /* cpuset refresh routine should be here */ 2401 /* cpuset refresh routine should be here */
2402 } 2402 }
2403 vm_total_pages = nr_free_pagecache_pages(); 2403 vm_total_pages = nr_free_pagecache_pages();
diff --git a/mm/readahead.c b/mm/readahead.c
index d8723a5f6496..77e8ddf945e9 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -382,9 +382,9 @@ ondemand_readahead(struct address_space *mapping,
382 if (hit_readahead_marker) { 382 if (hit_readahead_marker) {
383 pgoff_t start; 383 pgoff_t start;
384 384
385 read_lock_irq(&mapping->tree_lock); 385 rcu_read_lock();
386 start = radix_tree_next_hole(&mapping->page_tree, offset, max+1); 386 start = radix_tree_next_hole(&mapping->page_tree, offset,max+1);
387 read_unlock_irq(&mapping->tree_lock); 387 rcu_read_unlock();
388 388
389 if (!start || start - offset > max) 389 if (!start || start - offset > max)
390 return 0; 390 return 0;
diff --git a/mm/rmap.c b/mm/rmap.c
index abbd29f7c43f..99bc3f9cd796 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -49,6 +49,7 @@
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/kallsyms.h> 50#include <linux/kallsyms.h>
51#include <linux/memcontrol.h> 51#include <linux/memcontrol.h>
52#include <linux/mmu_notifier.h>
52 53
53#include <asm/tlbflush.h> 54#include <asm/tlbflush.h>
54 55
@@ -138,7 +139,7 @@ void anon_vma_unlink(struct vm_area_struct *vma)
138 anon_vma_free(anon_vma); 139 anon_vma_free(anon_vma);
139} 140}
140 141
141static void anon_vma_ctor(struct kmem_cache *cachep, void *data) 142static void anon_vma_ctor(void *data)
142{ 143{
143 struct anon_vma *anon_vma = data; 144 struct anon_vma *anon_vma = data;
144 145
@@ -287,7 +288,7 @@ static int page_referenced_one(struct page *page,
287 if (vma->vm_flags & VM_LOCKED) { 288 if (vma->vm_flags & VM_LOCKED) {
288 referenced++; 289 referenced++;
289 *mapcount = 1; /* break early from loop */ 290 *mapcount = 1; /* break early from loop */
290 } else if (ptep_clear_flush_young(vma, address, pte)) 291 } else if (ptep_clear_flush_young_notify(vma, address, pte))
291 referenced++; 292 referenced++;
292 293
293 /* Pretend the page is referenced if the task has the 294 /* Pretend the page is referenced if the task has the
@@ -457,7 +458,7 @@ static int page_mkclean_one(struct page *page, struct vm_area_struct *vma)
457 pte_t entry; 458 pte_t entry;
458 459
459 flush_cache_page(vma, address, pte_pfn(*pte)); 460 flush_cache_page(vma, address, pte_pfn(*pte));
460 entry = ptep_clear_flush(vma, address, pte); 461 entry = ptep_clear_flush_notify(vma, address, pte);
461 entry = pte_wrprotect(entry); 462 entry = pte_wrprotect(entry);
462 entry = pte_mkclean(entry); 463 entry = pte_mkclean(entry);
463 set_pte_at(mm, address, pte, entry); 464 set_pte_at(mm, address, pte, entry);
@@ -705,14 +706,14 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
705 * skipped over this mm) then we should reactivate it. 706 * skipped over this mm) then we should reactivate it.
706 */ 707 */
707 if (!migration && ((vma->vm_flags & VM_LOCKED) || 708 if (!migration && ((vma->vm_flags & VM_LOCKED) ||
708 (ptep_clear_flush_young(vma, address, pte)))) { 709 (ptep_clear_flush_young_notify(vma, address, pte)))) {
709 ret = SWAP_FAIL; 710 ret = SWAP_FAIL;
710 goto out_unmap; 711 goto out_unmap;
711 } 712 }
712 713
713 /* Nuke the page table entry. */ 714 /* Nuke the page table entry. */
714 flush_cache_page(vma, address, page_to_pfn(page)); 715 flush_cache_page(vma, address, page_to_pfn(page));
715 pteval = ptep_clear_flush(vma, address, pte); 716 pteval = ptep_clear_flush_notify(vma, address, pte);
716 717
717 /* Move the dirty bit to the physical page now the pte is gone. */ 718 /* Move the dirty bit to the physical page now the pte is gone. */
718 if (pte_dirty(pteval)) 719 if (pte_dirty(pteval))
@@ -837,12 +838,12 @@ static void try_to_unmap_cluster(unsigned long cursor,
837 page = vm_normal_page(vma, address, *pte); 838 page = vm_normal_page(vma, address, *pte);
838 BUG_ON(!page || PageAnon(page)); 839 BUG_ON(!page || PageAnon(page));
839 840
840 if (ptep_clear_flush_young(vma, address, pte)) 841 if (ptep_clear_flush_young_notify(vma, address, pte))
841 continue; 842 continue;
842 843
843 /* Nuke the page table entry. */ 844 /* Nuke the page table entry. */
844 flush_cache_page(vma, address, pte_pfn(*pte)); 845 flush_cache_page(vma, address, pte_pfn(*pte));
845 pteval = ptep_clear_flush(vma, address, pte); 846 pteval = ptep_clear_flush_notify(vma, address, pte);
846 847
847 /* If nonlinear, store the file page offset in the pte. */ 848 /* If nonlinear, store the file page offset in the pte. */
848 if (page->index != linear_page_index(vma, address)) 849 if (page->index != linear_page_index(vma, address))
diff --git a/mm/shmem.c b/mm/shmem.c
index f92fea94d037..c1e5a3b4f758 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -936,7 +936,7 @@ found:
936 spin_lock(&info->lock); 936 spin_lock(&info->lock);
937 ptr = shmem_swp_entry(info, idx, NULL); 937 ptr = shmem_swp_entry(info, idx, NULL);
938 if (ptr && ptr->val == entry.val) { 938 if (ptr && ptr->val == entry.val) {
939 error = add_to_page_cache(page, inode->i_mapping, 939 error = add_to_page_cache_locked(page, inode->i_mapping,
940 idx, GFP_NOWAIT); 940 idx, GFP_NOWAIT);
941 /* does mem_cgroup_uncharge_cache_page on error */ 941 /* does mem_cgroup_uncharge_cache_page on error */
942 } else /* we must compensate for our precharge above */ 942 } else /* we must compensate for our precharge above */
@@ -1301,8 +1301,8 @@ repeat:
1301 SetPageUptodate(filepage); 1301 SetPageUptodate(filepage);
1302 set_page_dirty(filepage); 1302 set_page_dirty(filepage);
1303 swap_free(swap); 1303 swap_free(swap);
1304 } else if (!(error = add_to_page_cache( 1304 } else if (!(error = add_to_page_cache_locked(swappage, mapping,
1305 swappage, mapping, idx, GFP_NOWAIT))) { 1305 idx, GFP_NOWAIT))) {
1306 info->flags |= SHMEM_PAGEIN; 1306 info->flags |= SHMEM_PAGEIN;
1307 shmem_swp_set(info, entry, 0); 1307 shmem_swp_set(info, entry, 0);
1308 shmem_swp_unmap(entry); 1308 shmem_swp_unmap(entry);
@@ -1513,7 +1513,6 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1513 inode->i_uid = current->fsuid; 1513 inode->i_uid = current->fsuid;
1514 inode->i_gid = current->fsgid; 1514 inode->i_gid = current->fsgid;
1515 inode->i_blocks = 0; 1515 inode->i_blocks = 0;
1516 inode->i_mapping->a_ops = &shmem_aops;
1517 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1516 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
1518 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1517 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1519 inode->i_generation = get_seconds(); 1518 inode->i_generation = get_seconds();
@@ -1528,6 +1527,7 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1528 init_special_inode(inode, mode, dev); 1527 init_special_inode(inode, mode, dev);
1529 break; 1528 break;
1530 case S_IFREG: 1529 case S_IFREG:
1530 inode->i_mapping->a_ops = &shmem_aops;
1531 inode->i_op = &shmem_inode_operations; 1531 inode->i_op = &shmem_inode_operations;
1532 inode->i_fop = &shmem_file_operations; 1532 inode->i_fop = &shmem_file_operations;
1533 mpol_shared_policy_init(&info->policy, 1533 mpol_shared_policy_init(&info->policy,
@@ -1929,6 +1929,7 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
1929 return error; 1929 return error;
1930 } 1930 }
1931 unlock_page(page); 1931 unlock_page(page);
1932 inode->i_mapping->a_ops = &shmem_aops;
1932 inode->i_op = &shmem_symlink_inode_operations; 1933 inode->i_op = &shmem_symlink_inode_operations;
1933 kaddr = kmap_atomic(page, KM_USER0); 1934 kaddr = kmap_atomic(page, KM_USER0);
1934 memcpy(kaddr, symname, len); 1935 memcpy(kaddr, symname, len);
@@ -2352,7 +2353,7 @@ static void shmem_destroy_inode(struct inode *inode)
2352 kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); 2353 kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode));
2353} 2354}
2354 2355
2355static void init_once(struct kmem_cache *cachep, void *foo) 2356static void init_once(void *foo)
2356{ 2357{
2357 struct shmem_inode_info *p = (struct shmem_inode_info *) foo; 2358 struct shmem_inode_info *p = (struct shmem_inode_info *) foo;
2358 2359
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c
index f5664c5b9eb1..8e5aadd7dcd6 100644
--- a/mm/shmem_acl.c
+++ b/mm/shmem_acl.c
@@ -191,7 +191,7 @@ shmem_check_acl(struct inode *inode, int mask)
191 * shmem_permission - permission() inode operation 191 * shmem_permission - permission() inode operation
192 */ 192 */
193int 193int
194shmem_permission(struct inode *inode, int mask, struct nameidata *nd) 194shmem_permission(struct inode *inode, int mask)
195{ 195{
196 return generic_permission(inode, mask, shmem_check_acl); 196 return generic_permission(inode, mask, shmem_check_acl);
197} 197}
diff --git a/mm/slab.c b/mm/slab.c
index 052e7d64537e..918f04f7fef1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -406,7 +406,7 @@ struct kmem_cache {
406 unsigned int dflags; /* dynamic flags */ 406 unsigned int dflags; /* dynamic flags */
407 407
408 /* constructor func */ 408 /* constructor func */
409 void (*ctor)(struct kmem_cache *, void *); 409 void (*ctor)(void *obj);
410 410
411/* 5) cache creation/removal */ 411/* 5) cache creation/removal */
412 const char *name; 412 const char *name;
@@ -2137,8 +2137,7 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep)
2137 */ 2137 */
2138struct kmem_cache * 2138struct kmem_cache *
2139kmem_cache_create (const char *name, size_t size, size_t align, 2139kmem_cache_create (const char *name, size_t size, size_t align,
2140 unsigned long flags, 2140 unsigned long flags, void (*ctor)(void *))
2141 void (*ctor)(struct kmem_cache *, void *))
2142{ 2141{
2143 size_t left_over, slab_size, ralign; 2142 size_t left_over, slab_size, ralign;
2144 struct kmem_cache *cachep = NULL, *pc; 2143 struct kmem_cache *cachep = NULL, *pc;
@@ -2653,7 +2652,7 @@ static void cache_init_objs(struct kmem_cache *cachep,
2653 * They must also be threaded. 2652 * They must also be threaded.
2654 */ 2653 */
2655 if (cachep->ctor && !(cachep->flags & SLAB_POISON)) 2654 if (cachep->ctor && !(cachep->flags & SLAB_POISON))
2656 cachep->ctor(cachep, objp + obj_offset(cachep)); 2655 cachep->ctor(objp + obj_offset(cachep));
2657 2656
2658 if (cachep->flags & SLAB_RED_ZONE) { 2657 if (cachep->flags & SLAB_RED_ZONE) {
2659 if (*dbg_redzone2(cachep, objp) != RED_INACTIVE) 2658 if (*dbg_redzone2(cachep, objp) != RED_INACTIVE)
@@ -2669,7 +2668,7 @@ static void cache_init_objs(struct kmem_cache *cachep,
2669 cachep->buffer_size / PAGE_SIZE, 0); 2668 cachep->buffer_size / PAGE_SIZE, 0);
2670#else 2669#else
2671 if (cachep->ctor) 2670 if (cachep->ctor)
2672 cachep->ctor(cachep, objp); 2671 cachep->ctor(objp);
2673#endif 2672#endif
2674 slab_bufctl(slabp)[i] = i + 1; 2673 slab_bufctl(slabp)[i] = i + 1;
2675 } 2674 }
@@ -3093,7 +3092,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3093#endif 3092#endif
3094 objp += obj_offset(cachep); 3093 objp += obj_offset(cachep);
3095 if (cachep->ctor && cachep->flags & SLAB_POISON) 3094 if (cachep->ctor && cachep->flags & SLAB_POISON)
3096 cachep->ctor(cachep, objp); 3095 cachep->ctor(objp);
3097#if ARCH_SLAB_MINALIGN 3096#if ARCH_SLAB_MINALIGN
3098 if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) { 3097 if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
3099 printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n", 3098 printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
diff --git a/mm/slob.c b/mm/slob.c
index de268eb7ac70..d8fbd4d1bfa7 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -525,12 +525,11 @@ struct kmem_cache {
525 unsigned int size, align; 525 unsigned int size, align;
526 unsigned long flags; 526 unsigned long flags;
527 const char *name; 527 const char *name;
528 void (*ctor)(struct kmem_cache *, void *); 528 void (*ctor)(void *);
529}; 529};
530 530
531struct kmem_cache *kmem_cache_create(const char *name, size_t size, 531struct kmem_cache *kmem_cache_create(const char *name, size_t size,
532 size_t align, unsigned long flags, 532 size_t align, unsigned long flags, void (*ctor)(void *))
533 void (*ctor)(struct kmem_cache *, void *))
534{ 533{
535 struct kmem_cache *c; 534 struct kmem_cache *c;
536 535
@@ -575,7 +574,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
575 b = slob_new_page(flags, get_order(c->size), node); 574 b = slob_new_page(flags, get_order(c->size), node);
576 575
577 if (c->ctor) 576 if (c->ctor)
578 c->ctor(c, b); 577 c->ctor(b);
579 578
580 return b; 579 return b;
581} 580}
diff --git a/mm/slub.c b/mm/slub.c
index 77c21cf53ff9..b7e2cd5d82db 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1012,7 +1012,7 @@ __setup("slub_debug", setup_slub_debug);
1012 1012
1013static unsigned long kmem_cache_flags(unsigned long objsize, 1013static unsigned long kmem_cache_flags(unsigned long objsize,
1014 unsigned long flags, const char *name, 1014 unsigned long flags, const char *name,
1015 void (*ctor)(struct kmem_cache *, void *)) 1015 void (*ctor)(void *))
1016{ 1016{
1017 /* 1017 /*
1018 * Enable debugging if selected on the kernel commandline. 1018 * Enable debugging if selected on the kernel commandline.
@@ -1040,7 +1040,7 @@ static inline int check_object(struct kmem_cache *s, struct page *page,
1040static inline void add_full(struct kmem_cache_node *n, struct page *page) {} 1040static inline void add_full(struct kmem_cache_node *n, struct page *page) {}
1041static inline unsigned long kmem_cache_flags(unsigned long objsize, 1041static inline unsigned long kmem_cache_flags(unsigned long objsize,
1042 unsigned long flags, const char *name, 1042 unsigned long flags, const char *name,
1043 void (*ctor)(struct kmem_cache *, void *)) 1043 void (*ctor)(void *))
1044{ 1044{
1045 return flags; 1045 return flags;
1046} 1046}
@@ -1103,7 +1103,7 @@ static void setup_object(struct kmem_cache *s, struct page *page,
1103{ 1103{
1104 setup_object_debug(s, page, object); 1104 setup_object_debug(s, page, object);
1105 if (unlikely(s->ctor)) 1105 if (unlikely(s->ctor))
1106 s->ctor(s, object); 1106 s->ctor(object);
1107} 1107}
1108 1108
1109static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) 1109static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
@@ -2286,7 +2286,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
2286static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags, 2286static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
2287 const char *name, size_t size, 2287 const char *name, size_t size,
2288 size_t align, unsigned long flags, 2288 size_t align, unsigned long flags,
2289 void (*ctor)(struct kmem_cache *, void *)) 2289 void (*ctor)(void *))
2290{ 2290{
2291 memset(s, 0, kmem_size); 2291 memset(s, 0, kmem_size);
2292 s->name = name; 2292 s->name = name;
@@ -3042,7 +3042,7 @@ static int slab_unmergeable(struct kmem_cache *s)
3042 3042
3043static struct kmem_cache *find_mergeable(size_t size, 3043static struct kmem_cache *find_mergeable(size_t size,
3044 size_t align, unsigned long flags, const char *name, 3044 size_t align, unsigned long flags, const char *name,
3045 void (*ctor)(struct kmem_cache *, void *)) 3045 void (*ctor)(void *))
3046{ 3046{
3047 struct kmem_cache *s; 3047 struct kmem_cache *s;
3048 3048
@@ -3082,8 +3082,7 @@ static struct kmem_cache *find_mergeable(size_t size,
3082} 3082}
3083 3083
3084struct kmem_cache *kmem_cache_create(const char *name, size_t size, 3084struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3085 size_t align, unsigned long flags, 3085 size_t align, unsigned long flags, void (*ctor)(void *))
3086 void (*ctor)(struct kmem_cache *, void *))
3087{ 3086{
3088 struct kmem_cache *s; 3087 struct kmem_cache *s;
3089 3088
diff --git a/mm/sparse.c b/mm/sparse.c
index 8ffc08990008..5d9dbbb9d39e 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -377,7 +377,7 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid)
377} 377}
378#endif /* !CONFIG_SPARSEMEM_VMEMMAP */ 378#endif /* !CONFIG_SPARSEMEM_VMEMMAP */
379 379
380struct page __init *sparse_early_mem_map_alloc(unsigned long pnum) 380static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)
381{ 381{
382 struct page *map; 382 struct page *map;
383 struct mem_section *ms = __nr_to_section(pnum); 383 struct mem_section *ms = __nr_to_section(pnum);
diff --git a/mm/swap_state.c b/mm/swap_state.c
index d8aadaf2a0ba..b8035b055129 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -39,7 +39,7 @@ static struct backing_dev_info swap_backing_dev_info = {
39 39
40struct address_space swapper_space = { 40struct address_space swapper_space = {
41 .page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN), 41 .page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN),
42 .tree_lock = __RW_LOCK_UNLOCKED(swapper_space.tree_lock), 42 .tree_lock = __SPIN_LOCK_UNLOCKED(swapper_space.tree_lock),
43 .a_ops = &swap_aops, 43 .a_ops = &swap_aops,
44 .i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear), 44 .i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear),
45 .backing_dev_info = &swap_backing_dev_info, 45 .backing_dev_info = &swap_backing_dev_info,
@@ -56,7 +56,8 @@ static struct {
56 56
57void show_swap_cache_info(void) 57void show_swap_cache_info(void)
58{ 58{
59 printk("Swap cache: add %lu, delete %lu, find %lu/%lu\n", 59 printk("%lu pages in swap cache\n", total_swapcache_pages);
60 printk("Swap cache stats: add %lu, delete %lu, find %lu/%lu\n",
60 swap_cache_info.add_total, swap_cache_info.del_total, 61 swap_cache_info.add_total, swap_cache_info.del_total,
61 swap_cache_info.find_success, swap_cache_info.find_total); 62 swap_cache_info.find_success, swap_cache_info.find_total);
62 printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10)); 63 printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10));
@@ -64,7 +65,7 @@ void show_swap_cache_info(void)
64} 65}
65 66
66/* 67/*
67 * add_to_swap_cache resembles add_to_page_cache on swapper_space, 68 * add_to_swap_cache resembles add_to_page_cache_locked on swapper_space,
68 * but sets SwapCache flag and private instead of mapping and index. 69 * but sets SwapCache flag and private instead of mapping and index.
69 */ 70 */
70int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask) 71int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask)
@@ -76,19 +77,26 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask)
76 BUG_ON(PagePrivate(page)); 77 BUG_ON(PagePrivate(page));
77 error = radix_tree_preload(gfp_mask); 78 error = radix_tree_preload(gfp_mask);
78 if (!error) { 79 if (!error) {
79 write_lock_irq(&swapper_space.tree_lock); 80 page_cache_get(page);
81 SetPageSwapCache(page);
82 set_page_private(page, entry.val);
83
84 spin_lock_irq(&swapper_space.tree_lock);
80 error = radix_tree_insert(&swapper_space.page_tree, 85 error = radix_tree_insert(&swapper_space.page_tree,
81 entry.val, page); 86 entry.val, page);
82 if (!error) { 87 if (likely(!error)) {
83 page_cache_get(page);
84 SetPageSwapCache(page);
85 set_page_private(page, entry.val);
86 total_swapcache_pages++; 88 total_swapcache_pages++;
87 __inc_zone_page_state(page, NR_FILE_PAGES); 89 __inc_zone_page_state(page, NR_FILE_PAGES);
88 INC_CACHE_INFO(add_total); 90 INC_CACHE_INFO(add_total);
89 } 91 }
90 write_unlock_irq(&swapper_space.tree_lock); 92 spin_unlock_irq(&swapper_space.tree_lock);
91 radix_tree_preload_end(); 93 radix_tree_preload_end();
94
95 if (unlikely(error)) {
96 set_page_private(page, 0UL);
97 ClearPageSwapCache(page);
98 page_cache_release(page);
99 }
92 } 100 }
93 return error; 101 return error;
94} 102}
@@ -175,9 +183,9 @@ void delete_from_swap_cache(struct page *page)
175 183
176 entry.val = page_private(page); 184 entry.val = page_private(page);
177 185
178 write_lock_irq(&swapper_space.tree_lock); 186 spin_lock_irq(&swapper_space.tree_lock);
179 __delete_from_swap_cache(page); 187 __delete_from_swap_cache(page);
180 write_unlock_irq(&swapper_space.tree_lock); 188 spin_unlock_irq(&swapper_space.tree_lock);
181 189
182 swap_free(entry); 190 swap_free(entry);
183 page_cache_release(page); 191 page_cache_release(page);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 2f33edb8bee9..6beb6251e99d 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -33,8 +33,8 @@
33#include <asm/tlbflush.h> 33#include <asm/tlbflush.h>
34#include <linux/swapops.h> 34#include <linux/swapops.h>
35 35
36DEFINE_SPINLOCK(swap_lock); 36static DEFINE_SPINLOCK(swap_lock);
37unsigned int nr_swapfiles; 37static unsigned int nr_swapfiles;
38long total_swap_pages; 38long total_swap_pages;
39static int swap_overflow; 39static int swap_overflow;
40static int least_priority; 40static int least_priority;
@@ -44,7 +44,7 @@ static const char Unused_file[] = "Unused swap file entry ";
44static const char Bad_offset[] = "Bad swap offset entry "; 44static const char Bad_offset[] = "Bad swap offset entry ";
45static const char Unused_offset[] = "Unused swap offset entry "; 45static const char Unused_offset[] = "Unused swap offset entry ";
46 46
47struct swap_list_t swap_list = {-1, -1}; 47static struct swap_list_t swap_list = {-1, -1};
48 48
49static struct swap_info_struct swap_info[MAX_SWAPFILES]; 49static struct swap_info_struct swap_info[MAX_SWAPFILES];
50 50
@@ -369,13 +369,13 @@ int remove_exclusive_swap_page(struct page *page)
369 retval = 0; 369 retval = 0;
370 if (p->swap_map[swp_offset(entry)] == 1) { 370 if (p->swap_map[swp_offset(entry)] == 1) {
371 /* Recheck the page count with the swapcache lock held.. */ 371 /* Recheck the page count with the swapcache lock held.. */
372 write_lock_irq(&swapper_space.tree_lock); 372 spin_lock_irq(&swapper_space.tree_lock);
373 if ((page_count(page) == 2) && !PageWriteback(page)) { 373 if ((page_count(page) == 2) && !PageWriteback(page)) {
374 __delete_from_swap_cache(page); 374 __delete_from_swap_cache(page);
375 SetPageDirty(page); 375 SetPageDirty(page);
376 retval = 1; 376 retval = 1;
377 } 377 }
378 write_unlock_irq(&swapper_space.tree_lock); 378 spin_unlock_irq(&swapper_space.tree_lock);
379 } 379 }
380 spin_unlock(&swap_lock); 380 spin_unlock(&swap_lock);
381 381
diff --git a/mm/truncate.c b/mm/truncate.c
index b8961cb63414..e68443d74567 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -349,18 +349,18 @@ invalidate_complete_page2(struct address_space *mapping, struct page *page)
349 if (PagePrivate(page) && !try_to_release_page(page, GFP_KERNEL)) 349 if (PagePrivate(page) && !try_to_release_page(page, GFP_KERNEL))
350 return 0; 350 return 0;
351 351
352 write_lock_irq(&mapping->tree_lock); 352 spin_lock_irq(&mapping->tree_lock);
353 if (PageDirty(page)) 353 if (PageDirty(page))
354 goto failed; 354 goto failed;
355 355
356 BUG_ON(PagePrivate(page)); 356 BUG_ON(PagePrivate(page));
357 __remove_from_page_cache(page); 357 __remove_from_page_cache(page);
358 write_unlock_irq(&mapping->tree_lock); 358 spin_unlock_irq(&mapping->tree_lock);
359 ClearPageUptodate(page); 359 ClearPageUptodate(page);
360 page_cache_release(page); /* pagecache ref */ 360 page_cache_release(page); /* pagecache ref */
361 return 1; 361 return 1;
362failed: 362failed:
363 write_unlock_irq(&mapping->tree_lock); 363 spin_unlock_irq(&mapping->tree_lock);
364 return 0; 364 return 0;
365} 365}
366 366
diff --git a/mm/util.c b/mm/util.c
index 8f18683825bc..9341ca77bd88 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1,7 +1,9 @@
1#include <linux/mm.h>
1#include <linux/slab.h> 2#include <linux/slab.h>
2#include <linux/string.h> 3#include <linux/string.h>
3#include <linux/module.h> 4#include <linux/module.h>
4#include <linux/err.h> 5#include <linux/err.h>
6#include <linux/sched.h>
5#include <asm/uaccess.h> 7#include <asm/uaccess.h>
6 8
7/** 9/**
@@ -68,25 +70,22 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
68EXPORT_SYMBOL(kmemdup); 70EXPORT_SYMBOL(kmemdup);
69 71
70/** 72/**
71 * krealloc - reallocate memory. The contents will remain unchanged. 73 * __krealloc - like krealloc() but don't free @p.
72 * @p: object to reallocate memory for. 74 * @p: object to reallocate memory for.
73 * @new_size: how many bytes of memory are required. 75 * @new_size: how many bytes of memory are required.
74 * @flags: the type of memory to allocate. 76 * @flags: the type of memory to allocate.
75 * 77 *
76 * The contents of the object pointed to are preserved up to the 78 * This function is like krealloc() except it never frees the originally
77 * lesser of the new and old sizes. If @p is %NULL, krealloc() 79 * allocated buffer. Use this if you don't want to free the buffer immediately
78 * behaves exactly like kmalloc(). If @size is 0 and @p is not a 80 * like, for example, with RCU.
79 * %NULL pointer, the object pointed to is freed.
80 */ 81 */
81void *krealloc(const void *p, size_t new_size, gfp_t flags) 82void *__krealloc(const void *p, size_t new_size, gfp_t flags)
82{ 83{
83 void *ret; 84 void *ret;
84 size_t ks = 0; 85 size_t ks = 0;
85 86
86 if (unlikely(!new_size)) { 87 if (unlikely(!new_size))
87 kfree(p);
88 return ZERO_SIZE_PTR; 88 return ZERO_SIZE_PTR;
89 }
90 89
91 if (p) 90 if (p)
92 ks = ksize(p); 91 ks = ksize(p);
@@ -95,10 +94,37 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags)
95 return (void *)p; 94 return (void *)p;
96 95
97 ret = kmalloc_track_caller(new_size, flags); 96 ret = kmalloc_track_caller(new_size, flags);
98 if (ret && p) { 97 if (ret && p)
99 memcpy(ret, p, ks); 98 memcpy(ret, p, ks);
99
100 return ret;
101}
102EXPORT_SYMBOL(__krealloc);
103
104/**
105 * krealloc - reallocate memory. The contents will remain unchanged.
106 * @p: object to reallocate memory for.
107 * @new_size: how many bytes of memory are required.
108 * @flags: the type of memory to allocate.
109 *
110 * The contents of the object pointed to are preserved up to the
111 * lesser of the new and old sizes. If @p is %NULL, krealloc()
112 * behaves exactly like kmalloc(). If @size is 0 and @p is not a
113 * %NULL pointer, the object pointed to is freed.
114 */
115void *krealloc(const void *p, size_t new_size, gfp_t flags)
116{
117 void *ret;
118
119 if (unlikely(!new_size)) {
100 kfree(p); 120 kfree(p);
121 return ZERO_SIZE_PTR;
101 } 122 }
123
124 ret = __krealloc(p, new_size, flags);
125 if (ret && p != ret)
126 kfree(p);
127
102 return ret; 128 return ret;
103} 129}
104EXPORT_SYMBOL(krealloc); 130EXPORT_SYMBOL(krealloc);
@@ -136,3 +162,12 @@ char *strndup_user(const char __user *s, long n)
136 return p; 162 return p;
137} 163}
138EXPORT_SYMBOL(strndup_user); 164EXPORT_SYMBOL(strndup_user);
165
166#ifndef HAVE_ARCH_PICK_MMAP_LAYOUT
167void arch_pick_mmap_layout(struct mm_struct *mm)
168{
169 mm->mmap_base = TASK_UNMAPPED_BASE;
170 mm->get_unmapped_area = arch_get_unmapped_area;
171 mm->unmap_area = arch_unmap_area;
172}
173#endif
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 35f293816294..85b9a0d2c877 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -381,16 +381,14 @@ static void __vunmap(const void *addr, int deallocate_pages)
381 return; 381 return;
382 382
383 if ((PAGE_SIZE-1) & (unsigned long)addr) { 383 if ((PAGE_SIZE-1) & (unsigned long)addr) {
384 printk(KERN_ERR "Trying to vfree() bad address (%p)\n", addr); 384 WARN(1, KERN_ERR "Trying to vfree() bad address (%p)\n", addr);
385 WARN_ON(1);
386 return; 385 return;
387 } 386 }
388 387
389 area = remove_vm_area(addr); 388 area = remove_vm_area(addr);
390 if (unlikely(!area)) { 389 if (unlikely(!area)) {
391 printk(KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n", 390 WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
392 addr); 391 addr);
393 WARN_ON(1);
394 return; 392 return;
395 } 393 }
396 394
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 26672c6cd3ce..8f71761bc4b7 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -391,17 +391,15 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
391} 391}
392 392
393/* 393/*
394 * Attempt to detach a locked page from its ->mapping. If it is dirty or if 394 * Same as remove_mapping, but if the page is removed from the mapping, it
395 * someone else has a ref on the page, abort and return 0. If it was 395 * gets returned with a refcount of 0.
396 * successfully detached, return 1. Assumes the caller has a single ref on
397 * this page.
398 */ 396 */
399int remove_mapping(struct address_space *mapping, struct page *page) 397static int __remove_mapping(struct address_space *mapping, struct page *page)
400{ 398{
401 BUG_ON(!PageLocked(page)); 399 BUG_ON(!PageLocked(page));
402 BUG_ON(mapping != page_mapping(page)); 400 BUG_ON(mapping != page_mapping(page));
403 401
404 write_lock_irq(&mapping->tree_lock); 402 spin_lock_irq(&mapping->tree_lock);
405 /* 403 /*
406 * The non racy check for a busy page. 404 * The non racy check for a busy page.
407 * 405 *
@@ -427,28 +425,48 @@ int remove_mapping(struct address_space *mapping, struct page *page)
427 * Note that if SetPageDirty is always performed via set_page_dirty, 425 * Note that if SetPageDirty is always performed via set_page_dirty,
428 * and thus under tree_lock, then this ordering is not required. 426 * and thus under tree_lock, then this ordering is not required.
429 */ 427 */
430 if (unlikely(page_count(page) != 2)) 428 if (!page_freeze_refs(page, 2))
431 goto cannot_free; 429 goto cannot_free;
432 smp_rmb(); 430 /* note: atomic_cmpxchg in page_freeze_refs provides the smp_rmb */
433 if (unlikely(PageDirty(page))) 431 if (unlikely(PageDirty(page))) {
432 page_unfreeze_refs(page, 2);
434 goto cannot_free; 433 goto cannot_free;
434 }
435 435
436 if (PageSwapCache(page)) { 436 if (PageSwapCache(page)) {
437 swp_entry_t swap = { .val = page_private(page) }; 437 swp_entry_t swap = { .val = page_private(page) };
438 __delete_from_swap_cache(page); 438 __delete_from_swap_cache(page);
439 write_unlock_irq(&mapping->tree_lock); 439 spin_unlock_irq(&mapping->tree_lock);
440 swap_free(swap); 440 swap_free(swap);
441 __put_page(page); /* The pagecache ref */ 441 } else {
442 return 1; 442 __remove_from_page_cache(page);
443 spin_unlock_irq(&mapping->tree_lock);
443 } 444 }
444 445
445 __remove_from_page_cache(page);
446 write_unlock_irq(&mapping->tree_lock);
447 __put_page(page);
448 return 1; 446 return 1;
449 447
450cannot_free: 448cannot_free:
451 write_unlock_irq(&mapping->tree_lock); 449 spin_unlock_irq(&mapping->tree_lock);
450 return 0;
451}
452
453/*
454 * Attempt to detach a locked page from its ->mapping. If it is dirty or if
455 * someone else has a ref on the page, abort and return 0. If it was
456 * successfully detached, return 1. Assumes the caller has a single ref on
457 * this page.
458 */
459int remove_mapping(struct address_space *mapping, struct page *page)
460{
461 if (__remove_mapping(mapping, page)) {
462 /*
463 * Unfreezing the refcount with 1 rather than 2 effectively
464 * drops the pagecache ref for us without requiring another
465 * atomic operation.
466 */
467 page_unfreeze_refs(page, 1);
468 return 1;
469 }
452 return 0; 470 return 0;
453} 471}
454 472
@@ -598,18 +616,34 @@ static unsigned long shrink_page_list(struct list_head *page_list,
598 if (PagePrivate(page)) { 616 if (PagePrivate(page)) {
599 if (!try_to_release_page(page, sc->gfp_mask)) 617 if (!try_to_release_page(page, sc->gfp_mask))
600 goto activate_locked; 618 goto activate_locked;
601 if (!mapping && page_count(page) == 1) 619 if (!mapping && page_count(page) == 1) {
602 goto free_it; 620 unlock_page(page);
621 if (put_page_testzero(page))
622 goto free_it;
623 else {
624 /*
625 * rare race with speculative reference.
626 * the speculative reference will free
627 * this page shortly, so we may
628 * increment nr_reclaimed here (and
629 * leave it off the LRU).
630 */
631 nr_reclaimed++;
632 continue;
633 }
634 }
603 } 635 }
604 636
605 if (!mapping || !remove_mapping(mapping, page)) 637 if (!mapping || !__remove_mapping(mapping, page))
606 goto keep_locked; 638 goto keep_locked;
607 639
608free_it:
609 unlock_page(page); 640 unlock_page(page);
641free_it:
610 nr_reclaimed++; 642 nr_reclaimed++;
611 if (!pagevec_add(&freed_pvec, page)) 643 if (!pagevec_add(&freed_pvec, page)) {
612 __pagevec_release_nonlru(&freed_pvec); 644 __pagevec_free(&freed_pvec);
645 pagevec_reinit(&freed_pvec);
646 }
613 continue; 647 continue;
614 648
615activate_locked: 649activate_locked:
@@ -623,7 +657,7 @@ keep:
623 } 657 }
624 list_splice(&ret_pages, page_list); 658 list_splice(&ret_pages, page_list);
625 if (pagevec_count(&freed_pvec)) 659 if (pagevec_count(&freed_pvec))
626 __pagevec_release_nonlru(&freed_pvec); 660 __pagevec_free(&freed_pvec);
627 count_vm_events(PGACTIVATE, pgactivate); 661 count_vm_events(PGACTIVATE, pgactivate);
628 return nr_reclaimed; 662 return nr_reclaimed;
629} 663}
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 07b5b82c5eab..0c850427a85b 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -959,7 +959,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
959 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 959 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
960 int end; 960 int end;
961 961
962 BUG_TRAP(start <= offset + len); 962 WARN_ON(start > offset + len);
963 963
964 end = start + skb_shinfo(skb)->frags[i].size; 964 end = start + skb_shinfo(skb)->frags[i].size;
965 if ((copy = end - offset) > 0) { 965 if ((copy = end - offset) > 0) {
@@ -986,7 +986,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
986 for (; list; list = list->next) { 986 for (; list; list = list->next) {
987 int end; 987 int end;
988 988
989 BUG_TRAP(start <= offset + len); 989 WARN_ON(start > offset + len);
990 990
991 end = start + list->len; 991 end = start + list->len;
992 if ((copy = end - offset) > 0) { 992 if ((copy = end - offset) > 0) {
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 690bc3ab186c..1a58af51a2e2 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -93,28 +93,20 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
93 93
94static int __init ebtable_filter_init(void) 94static int __init ebtable_filter_init(void)
95{ 95{
96 int i, j, ret; 96 int ret;
97 97
98 ret = ebt_register_table(&frame_filter); 98 ret = ebt_register_table(&frame_filter);
99 if (ret < 0) 99 if (ret < 0)
100 return ret; 100 return ret;
101 for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++) 101 ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
102 if ((ret = nf_register_hook(&ebt_ops_filter[i])) < 0) 102 if (ret < 0)
103 goto cleanup; 103 ebt_unregister_table(&frame_filter);
104 return ret;
105cleanup:
106 for (j = 0; j < i; j++)
107 nf_unregister_hook(&ebt_ops_filter[j]);
108 ebt_unregister_table(&frame_filter);
109 return ret; 104 return ret;
110} 105}
111 106
112static void __exit ebtable_filter_fini(void) 107static void __exit ebtable_filter_fini(void)
113{ 108{
114 int i; 109 nf_unregister_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
115
116 for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++)
117 nf_unregister_hook(&ebt_ops_filter[i]);
118 ebt_unregister_table(&frame_filter); 110 ebt_unregister_table(&frame_filter);
119} 111}
120 112
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 5b495fe2d0b6..f60c1e78e575 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -100,28 +100,20 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
100 100
101static int __init ebtable_nat_init(void) 101static int __init ebtable_nat_init(void)
102{ 102{
103 int i, ret, j; 103 int ret;
104 104
105 ret = ebt_register_table(&frame_nat); 105 ret = ebt_register_table(&frame_nat);
106 if (ret < 0) 106 if (ret < 0)
107 return ret; 107 return ret;
108 for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++) 108 ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
109 if ((ret = nf_register_hook(&ebt_ops_nat[i])) < 0) 109 if (ret < 0)
110 goto cleanup; 110 ebt_unregister_table(&frame_nat);
111 return ret;
112cleanup:
113 for (j = 0; j < i; j++)
114 nf_unregister_hook(&ebt_ops_nat[j]);
115 ebt_unregister_table(&frame_nat);
116 return ret; 111 return ret;
117} 112}
118 113
119static void __exit ebtable_nat_fini(void) 114static void __exit ebtable_nat_fini(void)
120{ 115{
121 int i; 116 nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
122
123 for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++)
124 nf_unregister_hook(&ebt_ops_nat[i]);
125 ebt_unregister_table(&frame_nat); 117 ebt_unregister_table(&frame_nat);
126} 118}
127 119
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 8a28fc93b724..dd61dcad6019 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -285,7 +285,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
285 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 285 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
286 int end; 286 int end;
287 287
288 BUG_TRAP(start <= offset + len); 288 WARN_ON(start > offset + len);
289 289
290 end = start + skb_shinfo(skb)->frags[i].size; 290 end = start + skb_shinfo(skb)->frags[i].size;
291 if ((copy = end - offset) > 0) { 291 if ((copy = end - offset) > 0) {
@@ -315,7 +315,7 @@ int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
315 for (; list; list = list->next) { 315 for (; list; list = list->next) {
316 int end; 316 int end;
317 317
318 BUG_TRAP(start <= offset + len); 318 WARN_ON(start > offset + len);
319 319
320 end = start + list->len; 320 end = start + list->len;
321 if ((copy = end - offset) > 0) { 321 if ((copy = end - offset) > 0) {
@@ -366,7 +366,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
366 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 366 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
367 int end; 367 int end;
368 368
369 BUG_TRAP(start <= offset + len); 369 WARN_ON(start > offset + len);
370 370
371 end = start + skb_shinfo(skb)->frags[i].size; 371 end = start + skb_shinfo(skb)->frags[i].size;
372 if ((copy = end - offset) > 0) { 372 if ((copy = end - offset) > 0) {
@@ -402,7 +402,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
402 for (; list; list=list->next) { 402 for (; list; list=list->next) {
403 int end; 403 int end;
404 404
405 BUG_TRAP(start <= offset + len); 405 WARN_ON(start > offset + len);
406 406
407 end = start + list->len; 407 end = start + list->len;
408 if ((copy = end - offset) > 0) { 408 if ((copy = end - offset) > 0) {
diff --git a/net/core/dev.c b/net/core/dev.c
index 53af7841018a..8d13a9b9f1df 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1973,7 +1973,7 @@ static void net_tx_action(struct softirq_action *h)
1973 struct sk_buff *skb = clist; 1973 struct sk_buff *skb = clist;
1974 clist = clist->next; 1974 clist = clist->next;
1975 1975
1976 BUG_TRAP(!atomic_read(&skb->users)); 1976 WARN_ON(atomic_read(&skb->users));
1977 __kfree_skb(skb); 1977 __kfree_skb(skb);
1978 } 1978 }
1979 } 1979 }
@@ -3847,7 +3847,7 @@ static void rollback_registered(struct net_device *dev)
3847 dev->uninit(dev); 3847 dev->uninit(dev);
3848 3848
3849 /* Notifier chain MUST detach us from master device. */ 3849 /* Notifier chain MUST detach us from master device. */
3850 BUG_TRAP(!dev->master); 3850 WARN_ON(dev->master);
3851 3851
3852 /* Remove entries from kobject tree */ 3852 /* Remove entries from kobject tree */
3853 netdev_unregister_kobject(dev); 3853 netdev_unregister_kobject(dev);
@@ -4169,9 +4169,9 @@ void netdev_run_todo(void)
4169 4169
4170 /* paranoia */ 4170 /* paranoia */
4171 BUG_ON(atomic_read(&dev->refcnt)); 4171 BUG_ON(atomic_read(&dev->refcnt));
4172 BUG_TRAP(!dev->ip_ptr); 4172 WARN_ON(dev->ip_ptr);
4173 BUG_TRAP(!dev->ip6_ptr); 4173 WARN_ON(dev->ip6_ptr);
4174 BUG_TRAP(!dev->dn_ptr); 4174 WARN_ON(dev->dn_ptr);
4175 4175
4176 if (dev->destructor) 4176 if (dev->destructor)
4177 dev->destructor(dev); 4177 dev->destructor(dev);
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 2d3035d3abd7..7552495aff7a 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -123,7 +123,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
123 } 123 }
124 } 124 }
125 125
126 BUG_TRAP(lopt->qlen == 0); 126 WARN_ON(lopt->qlen != 0);
127 if (lopt_size > PAGE_SIZE) 127 if (lopt_size > PAGE_SIZE)
128 vfree(lopt); 128 vfree(lopt);
129 else 129 else
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e4115672b6cf..4e0c92274189 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1200,7 +1200,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
1200 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 1200 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1201 int end; 1201 int end;
1202 1202
1203 BUG_TRAP(start <= offset + len); 1203 WARN_ON(start > offset + len);
1204 1204
1205 end = start + skb_shinfo(skb)->frags[i].size; 1205 end = start + skb_shinfo(skb)->frags[i].size;
1206 if ((copy = end - offset) > 0) { 1206 if ((copy = end - offset) > 0) {
@@ -1229,7 +1229,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
1229 for (; list; list = list->next) { 1229 for (; list; list = list->next) {
1230 int end; 1230 int end;
1231 1231
1232 BUG_TRAP(start <= offset + len); 1232 WARN_ON(start > offset + len);
1233 1233
1234 end = start + list->len; 1234 end = start + list->len;
1235 if ((copy = end - offset) > 0) { 1235 if ((copy = end - offset) > 0) {
@@ -1475,7 +1475,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
1475 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1475 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1476 int end; 1476 int end;
1477 1477
1478 BUG_TRAP(start <= offset + len); 1478 WARN_ON(start > offset + len);
1479 1479
1480 end = start + frag->size; 1480 end = start + frag->size;
1481 if ((copy = end - offset) > 0) { 1481 if ((copy = end - offset) > 0) {
@@ -1503,7 +1503,7 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
1503 for (; list; list = list->next) { 1503 for (; list; list = list->next) {
1504 int end; 1504 int end;
1505 1505
1506 BUG_TRAP(start <= offset + len); 1506 WARN_ON(start > offset + len);
1507 1507
1508 end = start + list->len; 1508 end = start + list->len;
1509 if ((copy = end - offset) > 0) { 1509 if ((copy = end - offset) > 0) {
@@ -1552,7 +1552,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
1552 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 1552 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1553 int end; 1553 int end;
1554 1554
1555 BUG_TRAP(start <= offset + len); 1555 WARN_ON(start > offset + len);
1556 1556
1557 end = start + skb_shinfo(skb)->frags[i].size; 1557 end = start + skb_shinfo(skb)->frags[i].size;
1558 if ((copy = end - offset) > 0) { 1558 if ((copy = end - offset) > 0) {
@@ -1581,7 +1581,7 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
1581 for (; list; list = list->next) { 1581 for (; list; list = list->next) {
1582 int end; 1582 int end;
1583 1583
1584 BUG_TRAP(start <= offset + len); 1584 WARN_ON(start > offset + len);
1585 1585
1586 end = start + list->len; 1586 end = start + list->len;
1587 if ((copy = end - offset) > 0) { 1587 if ((copy = end - offset) > 0) {
@@ -1629,7 +1629,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1629 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 1629 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1630 int end; 1630 int end;
1631 1631
1632 BUG_TRAP(start <= offset + len); 1632 WARN_ON(start > offset + len);
1633 1633
1634 end = start + skb_shinfo(skb)->frags[i].size; 1634 end = start + skb_shinfo(skb)->frags[i].size;
1635 if ((copy = end - offset) > 0) { 1635 if ((copy = end - offset) > 0) {
@@ -1662,7 +1662,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1662 __wsum csum2; 1662 __wsum csum2;
1663 int end; 1663 int end;
1664 1664
1665 BUG_TRAP(start <= offset + len); 1665 WARN_ON(start > offset + len);
1666 1666
1667 end = start + list->len; 1667 end = start + list->len;
1668 if ((copy = end - offset) > 0) { 1668 if ((copy = end - offset) > 0) {
@@ -2373,7 +2373,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2373 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 2373 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2374 int end; 2374 int end;
2375 2375
2376 BUG_TRAP(start <= offset + len); 2376 WARN_ON(start > offset + len);
2377 2377
2378 end = start + skb_shinfo(skb)->frags[i].size; 2378 end = start + skb_shinfo(skb)->frags[i].size;
2379 if ((copy = end - offset) > 0) { 2379 if ((copy = end - offset) > 0) {
@@ -2397,7 +2397,7 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2397 for (; list; list = list->next) { 2397 for (; list; list = list->next) {
2398 int end; 2398 int end;
2399 2399
2400 BUG_TRAP(start <= offset + len); 2400 WARN_ON(start > offset + len);
2401 2401
2402 end = start + list->len; 2402 end = start + list->len;
2403 if ((copy = end - offset) > 0) { 2403 if ((copy = end - offset) > 0) {
diff --git a/net/core/stream.c b/net/core/stream.c
index 4a0ad152c9c4..a6b3437ff082 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -192,13 +192,13 @@ void sk_stream_kill_queues(struct sock *sk)
192 __skb_queue_purge(&sk->sk_error_queue); 192 __skb_queue_purge(&sk->sk_error_queue);
193 193
194 /* Next, the write queue. */ 194 /* Next, the write queue. */
195 BUG_TRAP(skb_queue_empty(&sk->sk_write_queue)); 195 WARN_ON(!skb_queue_empty(&sk->sk_write_queue));
196 196
197 /* Account for returned memory. */ 197 /* Account for returned memory. */
198 sk_mem_reclaim(sk); 198 sk_mem_reclaim(sk);
199 199
200 BUG_TRAP(!sk->sk_wmem_queued); 200 WARN_ON(sk->sk_wmem_queued);
201 BUG_TRAP(!sk->sk_forward_alloc); 201 WARN_ON(sk->sk_forward_alloc);
202 202
203 /* It is _impossible_ for the backlog to contain anything 203 /* It is _impossible_ for the backlog to contain anything
204 * when we get here. All user references to this socket 204 * when we get here. All user references to this socket
diff --git a/net/core/user_dma.c b/net/core/user_dma.c
index 8c6b706963ff..164b090d5ac3 100644
--- a/net/core/user_dma.c
+++ b/net/core/user_dma.c
@@ -27,7 +27,6 @@
27 27
28#include <linux/dmaengine.h> 28#include <linux/dmaengine.h>
29#include <linux/socket.h> 29#include <linux/socket.h>
30#include <linux/rtnetlink.h> /* for BUG_TRAP */
31#include <net/tcp.h> 30#include <net/tcp.h>
32#include <net/netdma.h> 31#include <net/netdma.h>
33 32
@@ -72,7 +71,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
72 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 71 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
73 int end; 72 int end;
74 73
75 BUG_TRAP(start <= offset + len); 74 WARN_ON(start > offset + len);
76 75
77 end = start + skb_shinfo(skb)->frags[i].size; 76 end = start + skb_shinfo(skb)->frags[i].size;
78 copy = end - offset; 77 copy = end - offset;
@@ -101,7 +100,7 @@ int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
101 for (; list; list = list->next) { 100 for (; list; list = list->next) {
102 int end; 101 int end;
103 102
104 BUG_TRAP(start <= offset + len); 103 WARN_ON(start > offset + len);
105 104
106 end = start + list->len; 105 end = start + list->len;
107 copy = end - offset; 106 copy = end - offset;
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 32617e0576cb..1c2e3ec2eb57 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -164,7 +164,7 @@ static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp)
164{ 164{
165 s64 delta = dccp_delta_seqno(s1, s2); 165 s64 delta = dccp_delta_seqno(s1, s2);
166 166
167 BUG_TRAP(delta >= 0); 167 WARN_ON(delta < 0);
168 return (u64)delta <= ndp + 1; 168 return (u64)delta <= ndp + 1;
169} 169}
170 170
@@ -226,7 +226,7 @@ static inline void dccp_csum_outgoing(struct sk_buff *skb)
226 226
227extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); 227extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb);
228 228
229extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); 229extern int dccp_retransmit_skb(struct sock *sk);
230 230
231extern void dccp_send_ack(struct sock *sk); 231extern void dccp_send_ack(struct sock *sk);
232extern void dccp_reqsk_send_ack(struct sk_buff *sk, struct request_sock *rsk); 232extern void dccp_reqsk_send_ack(struct sk_buff *sk, struct request_sock *rsk);
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 08392ed86c25..df2f110df94a 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -413,7 +413,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
413 413
414 /* Stop the REQUEST timer */ 414 /* Stop the REQUEST timer */
415 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); 415 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
416 BUG_TRAP(sk->sk_send_head != NULL); 416 WARN_ON(sk->sk_send_head == NULL);
417 __kfree_skb(sk->sk_send_head); 417 __kfree_skb(sk->sk_send_head);
418 sk->sk_send_head = NULL; 418 sk->sk_send_head = NULL;
419 419
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 2622ace17c46..882c5c4de69e 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -196,8 +196,8 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
196static void dccp_v4_err(struct sk_buff *skb, u32 info) 196static void dccp_v4_err(struct sk_buff *skb, u32 info)
197{ 197{
198 const struct iphdr *iph = (struct iphdr *)skb->data; 198 const struct iphdr *iph = (struct iphdr *)skb->data;
199 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + 199 const u8 offset = iph->ihl << 2;
200 (iph->ihl << 2)); 200 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
201 struct dccp_sock *dp; 201 struct dccp_sock *dp;
202 struct inet_sock *inet; 202 struct inet_sock *inet;
203 const int type = icmp_hdr(skb)->type; 203 const int type = icmp_hdr(skb)->type;
@@ -207,7 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
207 int err; 207 int err;
208 struct net *net = dev_net(skb->dev); 208 struct net *net = dev_net(skb->dev);
209 209
210 if (skb->len < (iph->ihl << 2) + 8) { 210 if (skb->len < offset + sizeof(*dh) ||
211 skb->len < offset + __dccp_basic_hdr_len(dh)) {
211 ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); 212 ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
212 return; 213 return;
213 } 214 }
@@ -238,7 +239,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
238 dp = dccp_sk(sk); 239 dp = dccp_sk(sk);
239 seq = dccp_hdr_seq(dh); 240 seq = dccp_hdr_seq(dh);
240 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) && 241 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&
241 !between48(seq, dp->dccps_swl, dp->dccps_swh)) { 242 !between48(seq, dp->dccps_awl, dp->dccps_awh)) {
242 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); 243 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
243 goto out; 244 goto out;
244 } 245 }
@@ -283,7 +284,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
283 * ICMPs are not backlogged, hence we cannot get an established 284 * ICMPs are not backlogged, hence we cannot get an established
284 * socket here. 285 * socket here.
285 */ 286 */
286 BUG_TRAP(!req->sk); 287 WARN_ON(req->sk);
287 288
288 if (seq != dccp_rsk(req)->dreq_iss) { 289 if (seq != dccp_rsk(req)->dreq_iss) {
289 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); 290 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index b74e8b2cbe55..5e1ee0da2c40 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -89,12 +89,19 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
89{ 89{
90 struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data; 90 struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data;
91 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset); 91 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
92 struct dccp_sock *dp;
92 struct ipv6_pinfo *np; 93 struct ipv6_pinfo *np;
93 struct sock *sk; 94 struct sock *sk;
94 int err; 95 int err;
95 __u64 seq; 96 __u64 seq;
96 struct net *net = dev_net(skb->dev); 97 struct net *net = dev_net(skb->dev);
97 98
99 if (skb->len < offset + sizeof(*dh) ||
100 skb->len < offset + __dccp_basic_hdr_len(dh)) {
101 ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
102 return;
103 }
104
98 sk = inet6_lookup(net, &dccp_hashinfo, 105 sk = inet6_lookup(net, &dccp_hashinfo,
99 &hdr->daddr, dh->dccph_dport, 106 &hdr->daddr, dh->dccph_dport,
100 &hdr->saddr, dh->dccph_sport, inet6_iif(skb)); 107 &hdr->saddr, dh->dccph_sport, inet6_iif(skb));
@@ -116,6 +123,14 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
116 if (sk->sk_state == DCCP_CLOSED) 123 if (sk->sk_state == DCCP_CLOSED)
117 goto out; 124 goto out;
118 125
126 dp = dccp_sk(sk);
127 seq = dccp_hdr_seq(dh);
128 if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&
129 !between48(seq, dp->dccps_awl, dp->dccps_awh)) {
130 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
131 goto out;
132 }
133
119 np = inet6_sk(sk); 134 np = inet6_sk(sk);
120 135
121 if (type == ICMPV6_PKT_TOOBIG) { 136 if (type == ICMPV6_PKT_TOOBIG) {
@@ -168,7 +183,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
168 183
169 icmpv6_err_convert(type, code, &err); 184 icmpv6_err_convert(type, code, &err);
170 185
171 seq = dccp_hdr_seq(dh);
172 /* Might be for an request_sock */ 186 /* Might be for an request_sock */
173 switch (sk->sk_state) { 187 switch (sk->sk_state) {
174 struct request_sock *req, **prev; 188 struct request_sock *req, **prev;
@@ -186,7 +200,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
186 * ICMPs are not backlogged, hence we cannot get an established 200 * ICMPs are not backlogged, hence we cannot get an established
187 * socket here. 201 * socket here.
188 */ 202 */
189 BUG_TRAP(req->sk == NULL); 203 WARN_ON(req->sk != NULL);
190 204
191 if (seq != dccp_rsk(req)->dreq_iss) { 205 if (seq != dccp_rsk(req)->dreq_iss) {
192 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); 206 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
diff --git a/net/dccp/output.c b/net/dccp/output.c
index fe20068c5d8e..d06945c7d3df 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -53,8 +53,11 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
53 dccp_packet_hdr_len(dcb->dccpd_type); 53 dccp_packet_hdr_len(dcb->dccpd_type);
54 int err, set_ack = 1; 54 int err, set_ack = 1;
55 u64 ackno = dp->dccps_gsr; 55 u64 ackno = dp->dccps_gsr;
56 56 /*
57 dccp_inc_seqno(&dp->dccps_gss); 57 * Increment GSS here already in case the option code needs it.
58 * Update GSS for real only if option processing below succeeds.
59 */
60 dcb->dccpd_seq = ADD48(dp->dccps_gss, 1);
58 61
59 switch (dcb->dccpd_type) { 62 switch (dcb->dccpd_type) {
60 case DCCP_PKT_DATA: 63 case DCCP_PKT_DATA:
@@ -66,6 +69,9 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
66 69
67 case DCCP_PKT_REQUEST: 70 case DCCP_PKT_REQUEST:
68 set_ack = 0; 71 set_ack = 0;
72 /* Use ISS on the first (non-retransmitted) Request. */
73 if (icsk->icsk_retransmits == 0)
74 dcb->dccpd_seq = dp->dccps_iss;
69 /* fall through */ 75 /* fall through */
70 76
71 case DCCP_PKT_SYNC: 77 case DCCP_PKT_SYNC:
@@ -84,8 +90,6 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
84 break; 90 break;
85 } 91 }
86 92
87 dcb->dccpd_seq = dp->dccps_gss;
88
89 if (dccp_insert_options(sk, skb)) { 93 if (dccp_insert_options(sk, skb)) {
90 kfree_skb(skb); 94 kfree_skb(skb);
91 return -EPROTO; 95 return -EPROTO;
@@ -103,7 +107,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
103 /* XXX For now we're using only 48 bits sequence numbers */ 107 /* XXX For now we're using only 48 bits sequence numbers */
104 dh->dccph_x = 1; 108 dh->dccph_x = 1;
105 109
106 dp->dccps_awh = dp->dccps_gss; 110 dccp_update_gss(sk, dcb->dccpd_seq);
107 dccp_hdr_set_seq(dh, dp->dccps_gss); 111 dccp_hdr_set_seq(dh, dp->dccps_gss);
108 if (set_ack) 112 if (set_ack)
109 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), ackno); 113 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), ackno);
@@ -112,6 +116,11 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
112 case DCCP_PKT_REQUEST: 116 case DCCP_PKT_REQUEST:
113 dccp_hdr_request(skb)->dccph_req_service = 117 dccp_hdr_request(skb)->dccph_req_service =
114 dp->dccps_service; 118 dp->dccps_service;
119 /*
120 * Limit Ack window to ISS <= P.ackno <= GSS, so that
121 * only Responses to Requests we sent are considered.
122 */
123 dp->dccps_awl = dp->dccps_iss;
115 break; 124 break;
116 case DCCP_PKT_RESET: 125 case DCCP_PKT_RESET:
117 dccp_hdr_reset(skb)->dccph_reset_code = 126 dccp_hdr_reset(skb)->dccph_reset_code =
@@ -284,14 +293,26 @@ void dccp_write_xmit(struct sock *sk, int block)
284 } 293 }
285} 294}
286 295
287int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb) 296/**
297 * dccp_retransmit_skb - Retransmit Request, Close, or CloseReq packets
298 * There are only four retransmittable packet types in DCCP:
299 * - Request in client-REQUEST state (sec. 8.1.1),
300 * - CloseReq in server-CLOSEREQ state (sec. 8.3),
301 * - Close in node-CLOSING state (sec. 8.3),
302 * - Acks in client-PARTOPEN state (sec. 8.1.5, handled by dccp_delack_timer()).
303 * This function expects sk->sk_send_head to contain the original skb.
304 */
305int dccp_retransmit_skb(struct sock *sk)
288{ 306{
307 WARN_ON(sk->sk_send_head == NULL);
308
289 if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0) 309 if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0)
290 return -EHOSTUNREACH; /* Routing failure or similar. */ 310 return -EHOSTUNREACH; /* Routing failure or similar. */
291 311
292 return dccp_transmit_skb(sk, (skb_cloned(skb) ? 312 /* this count is used to distinguish original and retransmitted skb */
293 pskb_copy(skb, GFP_ATOMIC): 313 inet_csk(sk)->icsk_retransmits++;
294 skb_clone(skb, GFP_ATOMIC))); 314
315 return dccp_transmit_skb(sk, skb_clone(sk->sk_send_head, GFP_ATOMIC));
295} 316}
296 317
297struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, 318struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
@@ -437,19 +458,7 @@ static inline void dccp_connect_init(struct sock *sk)
437 458
438 dccp_sync_mss(sk, dst_mtu(dst)); 459 dccp_sync_mss(sk, dst_mtu(dst));
439 460
440 /* 461 /* Initialise GAR as per 8.5; AWL/AWH are set in dccp_transmit_skb() */
441 * SWL and AWL are initially adjusted so that they are not less than
442 * the initial Sequence Numbers received and sent, respectively:
443 * SWL := max(GSR + 1 - floor(W/4), ISR),
444 * AWL := max(GSS - W' + 1, ISS).
445 * These adjustments MUST be applied only at the beginning of the
446 * connection.
447 */
448 dccp_update_gss(sk, dp->dccps_iss);
449 dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
450
451 /* S.GAR - greatest valid acknowledgement number received on a non-Sync;
452 * initialized to S.ISS (sec. 8.5) */
453 dp->dccps_gar = dp->dccps_iss; 462 dp->dccps_gar = dp->dccps_iss;
454 463
455 icsk->icsk_retransmits = 0; 464 icsk->icsk_retransmits = 0;
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index a0b56009611f..b622d9744856 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -327,7 +327,7 @@ int dccp_disconnect(struct sock *sk, int flags)
327 inet_csk_delack_init(sk); 327 inet_csk_delack_init(sk);
328 __sk_dst_reset(sk); 328 __sk_dst_reset(sk);
329 329
330 BUG_TRAP(!inet->num || icsk->icsk_bind_hash); 330 WARN_ON(inet->num && !icsk->icsk_bind_hash);
331 331
332 sk->sk_error_report(sk); 332 sk->sk_error_report(sk);
333 return err; 333 return err;
@@ -981,7 +981,7 @@ adjudge_to_death:
981 */ 981 */
982 local_bh_disable(); 982 local_bh_disable();
983 bh_lock_sock(sk); 983 bh_lock_sock(sk);
984 BUG_TRAP(!sock_owned_by_user(sk)); 984 WARN_ON(sock_owned_by_user(sk));
985 985
986 /* Have we already been destroyed by a softirq or backlog? */ 986 /* Have we already been destroyed by a softirq or backlog? */
987 if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED) 987 if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED)
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 3608d5342ca2..54b3c7e9e016 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -99,21 +99,11 @@ static void dccp_retransmit_timer(struct sock *sk)
99 } 99 }
100 100
101 /* 101 /*
102 * sk->sk_send_head has to have one skb with
103 * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP
104 * packet types. The only packets eligible for retransmission are:
105 * -- Requests in client-REQUEST state (sec. 8.1.1)
106 * -- Acks in client-PARTOPEN state (sec. 8.1.5)
107 * -- CloseReq in server-CLOSEREQ state (sec. 8.3)
108 * -- Close in node-CLOSING state (sec. 8.3) */
109 BUG_TRAP(sk->sk_send_head != NULL);
110
111 /*
112 * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was 102 * More than than 4MSL (8 minutes) has passed, a RESET(aborted) was
113 * sent, no need to retransmit, this sock is dead. 103 * sent, no need to retransmit, this sock is dead.
114 */ 104 */
115 if (dccp_write_timeout(sk)) 105 if (dccp_write_timeout(sk))
116 goto out; 106 return;
117 107
118 /* 108 /*
119 * We want to know the number of packets retransmitted, not the 109 * We want to know the number of packets retransmitted, not the
@@ -122,30 +112,28 @@ static void dccp_retransmit_timer(struct sock *sk)
122 if (icsk->icsk_retransmits == 0) 112 if (icsk->icsk_retransmits == 0)
123 DCCP_INC_STATS_BH(DCCP_MIB_TIMEOUTS); 113 DCCP_INC_STATS_BH(DCCP_MIB_TIMEOUTS);
124 114
125 if (dccp_retransmit_skb(sk, sk->sk_send_head) < 0) { 115 if (dccp_retransmit_skb(sk) != 0) {
126 /* 116 /*
127 * Retransmission failed because of local congestion, 117 * Retransmission failed because of local congestion,
128 * do not backoff. 118 * do not backoff.
129 */ 119 */
130 if (icsk->icsk_retransmits == 0) 120 if (--icsk->icsk_retransmits == 0)
131 icsk->icsk_retransmits = 1; 121 icsk->icsk_retransmits = 1;
132 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 122 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
133 min(icsk->icsk_rto, 123 min(icsk->icsk_rto,
134 TCP_RESOURCE_PROBE_INTERVAL), 124 TCP_RESOURCE_PROBE_INTERVAL),
135 DCCP_RTO_MAX); 125 DCCP_RTO_MAX);
136 goto out; 126 return;
137 } 127 }
138 128
139backoff: 129backoff:
140 icsk->icsk_backoff++; 130 icsk->icsk_backoff++;
141 icsk->icsk_retransmits++;
142 131
143 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX); 132 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX);
144 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, 133 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto,
145 DCCP_RTO_MAX); 134 DCCP_RTO_MAX);
146 if (icsk->icsk_retransmits > sysctl_dccp_retries1) 135 if (icsk->icsk_retransmits > sysctl_dccp_retries1)
147 __sk_dst_reset(sk); 136 __sk_dst_reset(sk);
148out:;
149} 137}
150 138
151static void dccp_write_timer(unsigned long data) 139static void dccp_write_timer(unsigned long data)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index f440a9f54924..8a3ac1fa71a9 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -148,10 +148,10 @@ void inet_sock_destruct(struct sock *sk)
148 return; 148 return;
149 } 149 }
150 150
151 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); 151 WARN_ON(atomic_read(&sk->sk_rmem_alloc));
152 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 152 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
153 BUG_TRAP(!sk->sk_wmem_queued); 153 WARN_ON(sk->sk_wmem_queued);
154 BUG_TRAP(!sk->sk_forward_alloc); 154 WARN_ON(sk->sk_forward_alloc);
155 155
156 kfree(inet->opt); 156 kfree(inet->opt);
157 dst_release(sk->sk_dst_cache); 157 dst_release(sk->sk_dst_cache);
@@ -338,7 +338,7 @@ lookup_protocol:
338 answer_flags = answer->flags; 338 answer_flags = answer->flags;
339 rcu_read_unlock(); 339 rcu_read_unlock();
340 340
341 BUG_TRAP(answer_prot->slab != NULL); 341 WARN_ON(answer_prot->slab == NULL);
342 342
343 err = -ENOBUFS; 343 err = -ENOBUFS;
344 sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot); 344 sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot);
@@ -658,8 +658,8 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags)
658 658
659 lock_sock(sk2); 659 lock_sock(sk2);
660 660
661 BUG_TRAP((1 << sk2->sk_state) & 661 WARN_ON(!((1 << sk2->sk_state) &
662 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE)); 662 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE)));
663 663
664 sock_graft(sk2, newsock); 664 sock_graft(sk2, newsock);
665 665
@@ -1439,6 +1439,10 @@ static int __init inet_init(void)
1439 1439
1440 (void)sock_register(&inet_family_ops); 1440 (void)sock_register(&inet_family_ops);
1441 1441
1442#ifdef CONFIG_SYSCTL
1443 ip_static_sysctl_init();
1444#endif
1445
1442 /* 1446 /*
1443 * Add all the base protocols. 1447 * Add all the base protocols.
1444 */ 1448 */
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 2e667e2f90df..91d3d96805d0 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -138,8 +138,8 @@ void in_dev_finish_destroy(struct in_device *idev)
138{ 138{
139 struct net_device *dev = idev->dev; 139 struct net_device *dev = idev->dev;
140 140
141 BUG_TRAP(!idev->ifa_list); 141 WARN_ON(idev->ifa_list);
142 BUG_TRAP(!idev->mc_list); 142 WARN_ON(idev->mc_list);
143#ifdef NET_REFCNT_DEBUG 143#ifdef NET_REFCNT_DEBUG
144 printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n", 144 printk(KERN_DEBUG "in_dev_finish_destroy: %p=%s\n",
145 idev, dev ? dev->name : "NIL"); 145 idev, dev ? dev->name : "NIL");
@@ -399,7 +399,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
399 } 399 }
400 ipv4_devconf_setall(in_dev); 400 ipv4_devconf_setall(in_dev);
401 if (ifa->ifa_dev != in_dev) { 401 if (ifa->ifa_dev != in_dev) {
402 BUG_TRAP(!ifa->ifa_dev); 402 WARN_ON(ifa->ifa_dev);
403 in_dev_hold(in_dev); 403 in_dev_hold(in_dev);
404 ifa->ifa_dev = in_dev; 404 ifa->ifa_dev = in_dev;
405 } 405 }
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index bb81c958b744..0c1ae68ee84b 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -167,7 +167,7 @@ tb_not_found:
167success: 167success:
168 if (!inet_csk(sk)->icsk_bind_hash) 168 if (!inet_csk(sk)->icsk_bind_hash)
169 inet_bind_hash(sk, tb, snum); 169 inet_bind_hash(sk, tb, snum);
170 BUG_TRAP(inet_csk(sk)->icsk_bind_hash == tb); 170 WARN_ON(inet_csk(sk)->icsk_bind_hash != tb);
171 ret = 0; 171 ret = 0;
172 172
173fail_unlock: 173fail_unlock:
@@ -260,7 +260,7 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err)
260 } 260 }
261 261
262 newsk = reqsk_queue_get_child(&icsk->icsk_accept_queue, sk); 262 newsk = reqsk_queue_get_child(&icsk->icsk_accept_queue, sk);
263 BUG_TRAP(newsk->sk_state != TCP_SYN_RECV); 263 WARN_ON(newsk->sk_state == TCP_SYN_RECV);
264out: 264out:
265 release_sock(sk); 265 release_sock(sk);
266 return newsk; 266 return newsk;
@@ -386,7 +386,7 @@ struct request_sock *inet_csk_search_req(const struct sock *sk,
386 ireq->rmt_addr == raddr && 386 ireq->rmt_addr == raddr &&
387 ireq->loc_addr == laddr && 387 ireq->loc_addr == laddr &&
388 AF_INET_FAMILY(req->rsk_ops->family)) { 388 AF_INET_FAMILY(req->rsk_ops->family)) {
389 BUG_TRAP(!req->sk); 389 WARN_ON(req->sk);
390 *prevp = prev; 390 *prevp = prev;
391 break; 391 break;
392 } 392 }
@@ -539,14 +539,14 @@ EXPORT_SYMBOL_GPL(inet_csk_clone);
539 */ 539 */
540void inet_csk_destroy_sock(struct sock *sk) 540void inet_csk_destroy_sock(struct sock *sk)
541{ 541{
542 BUG_TRAP(sk->sk_state == TCP_CLOSE); 542 WARN_ON(sk->sk_state != TCP_CLOSE);
543 BUG_TRAP(sock_flag(sk, SOCK_DEAD)); 543 WARN_ON(!sock_flag(sk, SOCK_DEAD));
544 544
545 /* It cannot be in hash table! */ 545 /* It cannot be in hash table! */
546 BUG_TRAP(sk_unhashed(sk)); 546 WARN_ON(!sk_unhashed(sk));
547 547
548 /* If it has not 0 inet_sk(sk)->num, it must be bound */ 548 /* If it has not 0 inet_sk(sk)->num, it must be bound */
549 BUG_TRAP(!inet_sk(sk)->num || inet_csk(sk)->icsk_bind_hash); 549 WARN_ON(inet_sk(sk)->num && !inet_csk(sk)->icsk_bind_hash);
550 550
551 sk->sk_prot->destroy(sk); 551 sk->sk_prot->destroy(sk);
552 552
@@ -629,7 +629,7 @@ void inet_csk_listen_stop(struct sock *sk)
629 629
630 local_bh_disable(); 630 local_bh_disable();
631 bh_lock_sock(child); 631 bh_lock_sock(child);
632 BUG_TRAP(!sock_owned_by_user(child)); 632 WARN_ON(sock_owned_by_user(child));
633 sock_hold(child); 633 sock_hold(child);
634 634
635 sk->sk_prot->disconnect(child, O_NONBLOCK); 635 sk->sk_prot->disconnect(child, O_NONBLOCK);
@@ -647,7 +647,7 @@ void inet_csk_listen_stop(struct sock *sk)
647 sk_acceptq_removed(sk); 647 sk_acceptq_removed(sk);
648 __reqsk_free(req); 648 __reqsk_free(req);
649 } 649 }
650 BUG_TRAP(!sk->sk_ack_backlog); 650 WARN_ON(sk->sk_ack_backlog);
651} 651}
652 652
653EXPORT_SYMBOL_GPL(inet_csk_listen_stop); 653EXPORT_SYMBOL_GPL(inet_csk_listen_stop);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 0546a0bc97ea..6c52e08f786e 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -134,8 +134,8 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f,
134 struct sk_buff *fp; 134 struct sk_buff *fp;
135 struct netns_frags *nf; 135 struct netns_frags *nf;
136 136
137 BUG_TRAP(q->last_in & INET_FRAG_COMPLETE); 137 WARN_ON(!(q->last_in & INET_FRAG_COMPLETE));
138 BUG_TRAP(del_timer(&q->timer) == 0); 138 WARN_ON(del_timer(&q->timer) != 0);
139 139
140 /* Release all fragment data. */ 140 /* Release all fragment data. */
141 fp = q->fragments; 141 fp = q->fragments;
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 115f53722d20..44981906fb91 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -305,7 +305,7 @@ unique:
305 inet->num = lport; 305 inet->num = lport;
306 inet->sport = htons(lport); 306 inet->sport = htons(lport);
307 sk->sk_hash = hash; 307 sk->sk_hash = hash;
308 BUG_TRAP(sk_unhashed(sk)); 308 WARN_ON(!sk_unhashed(sk));
309 __sk_add_node(sk, &head->chain); 309 __sk_add_node(sk, &head->chain);
310 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 310 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
311 write_unlock(lock); 311 write_unlock(lock);
@@ -342,7 +342,7 @@ void __inet_hash_nolisten(struct sock *sk)
342 rwlock_t *lock; 342 rwlock_t *lock;
343 struct inet_ehash_bucket *head; 343 struct inet_ehash_bucket *head;
344 344
345 BUG_TRAP(sk_unhashed(sk)); 345 WARN_ON(!sk_unhashed(sk));
346 346
347 sk->sk_hash = inet_sk_ehashfn(sk); 347 sk->sk_hash = inet_sk_ehashfn(sk);
348 head = inet_ehash_bucket(hashinfo, sk->sk_hash); 348 head = inet_ehash_bucket(hashinfo, sk->sk_hash);
@@ -367,7 +367,7 @@ static void __inet_hash(struct sock *sk)
367 return; 367 return;
368 } 368 }
369 369
370 BUG_TRAP(sk_unhashed(sk)); 370 WARN_ON(!sk_unhashed(sk));
371 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; 371 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
372 lock = &hashinfo->lhash_lock; 372 lock = &hashinfo->lhash_lock;
373 373
@@ -450,7 +450,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
450 */ 450 */
451 inet_bind_bucket_for_each(tb, node, &head->chain) { 451 inet_bind_bucket_for_each(tb, node, &head->chain) {
452 if (tb->ib_net == net && tb->port == port) { 452 if (tb->ib_net == net && tb->port == port) {
453 BUG_TRAP(!hlist_empty(&tb->owners)); 453 WARN_ON(hlist_empty(&tb->owners));
454 if (tb->fastreuse >= 0) 454 if (tb->fastreuse >= 0)
455 goto next_port; 455 goto next_port;
456 if (!check_established(death_row, sk, 456 if (!check_established(death_row, sk,
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 75c2def8f9a0..d985bd613d25 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -86,7 +86,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
86 hashinfo->bhash_size)]; 86 hashinfo->bhash_size)];
87 spin_lock(&bhead->lock); 87 spin_lock(&bhead->lock);
88 tw->tw_tb = icsk->icsk_bind_hash; 88 tw->tw_tb = icsk->icsk_bind_hash;
89 BUG_TRAP(icsk->icsk_bind_hash); 89 WARN_ON(!icsk->icsk_bind_hash);
90 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); 90 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners);
91 spin_unlock(&bhead->lock); 91 spin_unlock(&bhead->lock);
92 92
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 38d38f058018..2152d222b954 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -488,8 +488,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
488 qp->q.fragments = head; 488 qp->q.fragments = head;
489 } 489 }
490 490
491 BUG_TRAP(head != NULL); 491 WARN_ON(head == NULL);
492 BUG_TRAP(FRAG_CB(head)->offset == 0); 492 WARN_ON(FRAG_CB(head)->offset != 0);
493 493
494 /* Allocate a new buffer for the datagram. */ 494 /* Allocate a new buffer for the datagram. */
495 ihlen = ip_hdrlen(head); 495 ihlen = ip_hdrlen(head);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 465544f6281a..d533a89e08de 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -118,7 +118,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb)
118 __skb_pull(newskb, skb_network_offset(newskb)); 118 __skb_pull(newskb, skb_network_offset(newskb));
119 newskb->pkt_type = PACKET_LOOPBACK; 119 newskb->pkt_type = PACKET_LOOPBACK;
120 newskb->ip_summed = CHECKSUM_UNNECESSARY; 120 newskb->ip_summed = CHECKSUM_UNNECESSARY;
121 BUG_TRAP(newskb->dst); 121 WARN_ON(!newskb->dst);
122 netif_rx(newskb); 122 netif_rx(newskb);
123 return 0; 123 return 0;
124} 124}
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index a42b64d040c4..38ccb6dfb02e 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -104,9 +104,7 @@ out:
104 104
105static int ipcomp4_init_state(struct xfrm_state *x) 105static int ipcomp4_init_state(struct xfrm_state *x)
106{ 106{
107 int err; 107 int err = -EINVAL;
108 struct ipcomp_data *ipcd;
109 struct xfrm_algo_desc *calg_desc;
110 108
111 x->props.header_len = 0; 109 x->props.header_len = 0;
112 switch (x->props.mode) { 110 switch (x->props.mode) {
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index 3be4d07e7ed9..082f5dd3156c 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -55,32 +55,53 @@ static struct xt_table packet_filter = {
55}; 55};
56 56
57/* The work comes in here from netfilter.c */ 57/* The work comes in here from netfilter.c */
58static unsigned int arpt_hook(unsigned int hook, 58static unsigned int arpt_in_hook(unsigned int hook,
59 struct sk_buff *skb, 59 struct sk_buff *skb,
60 const struct net_device *in, 60 const struct net_device *in,
61 const struct net_device *out, 61 const struct net_device *out,
62 int (*okfn)(struct sk_buff *)) 62 int (*okfn)(struct sk_buff *))
63{ 63{
64 return arpt_do_table(skb, hook, in, out, init_net.ipv4.arptable_filter); 64 return arpt_do_table(skb, hook, in, out,
65 dev_net(in)->ipv4.arptable_filter);
66}
67
68static unsigned int arpt_out_hook(unsigned int hook,
69 struct sk_buff *skb,
70 const struct net_device *in,
71 const struct net_device *out,
72 int (*okfn)(struct sk_buff *))
73{
74 return arpt_do_table(skb, hook, in, out,
75 dev_net(out)->ipv4.arptable_filter);
76}
77
78static unsigned int arpt_forward_hook(unsigned int hook,
79 struct sk_buff *skb,
80 const struct net_device *in,
81 const struct net_device *out,
82 int (*okfn)(struct sk_buff *))
83{
84 return arpt_do_table(skb, hook, in, out,
85 dev_net(in)->ipv4.arptable_filter);
65} 86}
66 87
67static struct nf_hook_ops arpt_ops[] __read_mostly = { 88static struct nf_hook_ops arpt_ops[] __read_mostly = {
68 { 89 {
69 .hook = arpt_hook, 90 .hook = arpt_in_hook,
70 .owner = THIS_MODULE, 91 .owner = THIS_MODULE,
71 .pf = NF_ARP, 92 .pf = NF_ARP,
72 .hooknum = NF_ARP_IN, 93 .hooknum = NF_ARP_IN,
73 .priority = NF_IP_PRI_FILTER, 94 .priority = NF_IP_PRI_FILTER,
74 }, 95 },
75 { 96 {
76 .hook = arpt_hook, 97 .hook = arpt_out_hook,
77 .owner = THIS_MODULE, 98 .owner = THIS_MODULE,
78 .pf = NF_ARP, 99 .pf = NF_ARP,
79 .hooknum = NF_ARP_OUT, 100 .hooknum = NF_ARP_OUT,
80 .priority = NF_IP_PRI_FILTER, 101 .priority = NF_IP_PRI_FILTER,
81 }, 102 },
82 { 103 {
83 .hook = arpt_hook, 104 .hook = arpt_forward_hook,
84 .owner = THIS_MODULE, 105 .owner = THIS_MODULE,
85 .pf = NF_ARP, 106 .pf = NF_ARP,
86 .hooknum = NF_ARP_FORWARD, 107 .hooknum = NF_ARP_FORWARD,
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index 2b472ac2263a..db6d312128e1 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -32,7 +32,7 @@ static struct
32 struct ipt_replace repl; 32 struct ipt_replace repl;
33 struct ipt_standard entries[3]; 33 struct ipt_standard entries[3];
34 struct ipt_error term; 34 struct ipt_error term;
35} initial_table __initdata = { 35} initial_table __net_initdata = {
36 .repl = { 36 .repl = {
37 .name = "security", 37 .name = "security",
38 .valid_hooks = SECURITY_VALID_HOOKS, 38 .valid_hooks = SECURITY_VALID_HOOKS,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index e4ab0ac94f92..380d6474cf66 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1502,7 +1502,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1502 rth->fl.iif != 0 || 1502 rth->fl.iif != 0 ||
1503 dst_metric_locked(&rth->u.dst, RTAX_MTU) || 1503 dst_metric_locked(&rth->u.dst, RTAX_MTU) ||
1504 !net_eq(dev_net(rth->u.dst.dev), net) || 1504 !net_eq(dev_net(rth->u.dst.dev), net) ||
1505 !rt_is_expired(rth)) 1505 rt_is_expired(rth))
1506 continue; 1506 continue;
1507 1507
1508 if (new_mtu < 68 || new_mtu >= old_mtu) { 1508 if (new_mtu < 68 || new_mtu >= old_mtu) {
@@ -2914,7 +2914,7 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table,
2914 return 0; 2914 return 0;
2915} 2915}
2916 2916
2917ctl_table ipv4_route_table[] = { 2917static ctl_table ipv4_route_table[] = {
2918 { 2918 {
2919 .ctl_name = NET_IPV4_ROUTE_GC_THRESH, 2919 .ctl_name = NET_IPV4_ROUTE_GC_THRESH,
2920 .procname = "gc_thresh", 2920 .procname = "gc_thresh",
@@ -3216,6 +3216,15 @@ int __init ip_rt_init(void)
3216 return rc; 3216 return rc;
3217} 3217}
3218 3218
3219/*
3220 * We really need to sanitize the damn ipv4 init order, then all
3221 * this nonsense will go away.
3222 */
3223void __init ip_static_sysctl_init(void)
3224{
3225 register_sysctl_paths(ipv4_route_path, ipv4_route_table);
3226}
3227
3219EXPORT_SYMBOL(__ip_select_ident); 3228EXPORT_SYMBOL(__ip_select_ident);
3220EXPORT_SYMBOL(ip_route_input); 3229EXPORT_SYMBOL(ip_route_input);
3221EXPORT_SYMBOL(ip_route_output_key); 3230EXPORT_SYMBOL(ip_route_output_key);
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 51bc24d3b8a7..9d38005abbac 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -299,6 +299,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
299 ireq->rmt_port = th->source; 299 ireq->rmt_port = th->source;
300 ireq->loc_addr = ip_hdr(skb)->daddr; 300 ireq->loc_addr = ip_hdr(skb)->daddr;
301 ireq->rmt_addr = ip_hdr(skb)->saddr; 301 ireq->rmt_addr = ip_hdr(skb)->saddr;
302 ireq->ecn_ok = 0;
302 ireq->snd_wscale = tcp_opt.snd_wscale; 303 ireq->snd_wscale = tcp_opt.snd_wscale;
303 ireq->rcv_wscale = tcp_opt.rcv_wscale; 304 ireq->rcv_wscale = tcp_opt.rcv_wscale;
304 ireq->sack_ok = tcp_opt.sack_ok; 305 ireq->sack_ok = tcp_opt.sack_ok;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 14ef202a2254..770d827f5ab8 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -401,13 +401,6 @@ static struct ctl_table ipv4_table[] = {
401 .proc_handler = &ipv4_local_port_range, 401 .proc_handler = &ipv4_local_port_range,
402 .strategy = &ipv4_sysctl_local_port_range, 402 .strategy = &ipv4_sysctl_local_port_range,
403 }, 403 },
404 {
405 .ctl_name = NET_IPV4_ROUTE,
406 .procname = "route",
407 .maxlen = 0,
408 .mode = 0555,
409 .child = ipv4_route_table
410 },
411#ifdef CONFIG_IP_MULTICAST 404#ifdef CONFIG_IP_MULTICAST
412 { 405 {
413 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS, 406 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0b491bf03db4..1ab341e5d3e0 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1096,7 +1096,7 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied)
1096#if TCP_DEBUG 1096#if TCP_DEBUG
1097 struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); 1097 struct sk_buff *skb = skb_peek(&sk->sk_receive_queue);
1098 1098
1099 BUG_TRAP(!skb || before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)); 1099 WARN_ON(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq));
1100#endif 1100#endif
1101 1101
1102 if (inet_csk_ack_scheduled(sk)) { 1102 if (inet_csk_ack_scheduled(sk)) {
@@ -1358,7 +1358,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1358 goto found_ok_skb; 1358 goto found_ok_skb;
1359 if (tcp_hdr(skb)->fin) 1359 if (tcp_hdr(skb)->fin)
1360 goto found_fin_ok; 1360 goto found_fin_ok;
1361 BUG_TRAP(flags & MSG_PEEK); 1361 WARN_ON(!(flags & MSG_PEEK));
1362 skb = skb->next; 1362 skb = skb->next;
1363 } while (skb != (struct sk_buff *)&sk->sk_receive_queue); 1363 } while (skb != (struct sk_buff *)&sk->sk_receive_queue);
1364 1364
@@ -1421,8 +1421,8 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1421 1421
1422 tp->ucopy.len = len; 1422 tp->ucopy.len = len;
1423 1423
1424 BUG_TRAP(tp->copied_seq == tp->rcv_nxt || 1424 WARN_ON(tp->copied_seq != tp->rcv_nxt &&
1425 (flags & (MSG_PEEK | MSG_TRUNC))); 1425 !(flags & (MSG_PEEK | MSG_TRUNC)));
1426 1426
1427 /* Ugly... If prequeue is not empty, we have to 1427 /* Ugly... If prequeue is not empty, we have to
1428 * process it before releasing socket, otherwise 1428 * process it before releasing socket, otherwise
@@ -1844,7 +1844,7 @@ adjudge_to_death:
1844 */ 1844 */
1845 local_bh_disable(); 1845 local_bh_disable();
1846 bh_lock_sock(sk); 1846 bh_lock_sock(sk);
1847 BUG_TRAP(!sock_owned_by_user(sk)); 1847 WARN_ON(sock_owned_by_user(sk));
1848 1848
1849 /* Have we already been destroyed by a softirq or backlog? */ 1849 /* Have we already been destroyed by a softirq or backlog? */
1850 if (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE) 1850 if (state != TCP_CLOSE && sk->sk_state == TCP_CLOSE)
@@ -1973,7 +1973,7 @@ int tcp_disconnect(struct sock *sk, int flags)
1973 memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); 1973 memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
1974 __sk_dst_reset(sk); 1974 __sk_dst_reset(sk);
1975 1975
1976 BUG_TRAP(!inet->num || icsk->icsk_bind_hash); 1976 WARN_ON(inet->num && !icsk->icsk_bind_hash);
1977 1977
1978 sk->sk_error_report(sk); 1978 sk->sk_error_report(sk);
1979 return err; 1979 return err;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 75efd244f2af..67ccce2a96bd 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1629,10 +1629,10 @@ advance_sp:
1629out: 1629out:
1630 1630
1631#if FASTRETRANS_DEBUG > 0 1631#if FASTRETRANS_DEBUG > 0
1632 BUG_TRAP((int)tp->sacked_out >= 0); 1632 WARN_ON((int)tp->sacked_out < 0);
1633 BUG_TRAP((int)tp->lost_out >= 0); 1633 WARN_ON((int)tp->lost_out < 0);
1634 BUG_TRAP((int)tp->retrans_out >= 0); 1634 WARN_ON((int)tp->retrans_out < 0);
1635 BUG_TRAP((int)tcp_packets_in_flight(tp) >= 0); 1635 WARN_ON((int)tcp_packets_in_flight(tp) < 0);
1636#endif 1636#endif
1637 return flag; 1637 return flag;
1638} 1638}
@@ -2181,7 +2181,7 @@ static void tcp_mark_head_lost(struct sock *sk, int packets)
2181 int err; 2181 int err;
2182 unsigned int mss; 2182 unsigned int mss;
2183 2183
2184 BUG_TRAP(packets <= tp->packets_out); 2184 WARN_ON(packets > tp->packets_out);
2185 if (tp->lost_skb_hint) { 2185 if (tp->lost_skb_hint) {
2186 skb = tp->lost_skb_hint; 2186 skb = tp->lost_skb_hint;
2187 cnt = tp->lost_cnt_hint; 2187 cnt = tp->lost_cnt_hint;
@@ -2610,7 +2610,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag)
2610 /* E. Check state exit conditions. State can be terminated 2610 /* E. Check state exit conditions. State can be terminated
2611 * when high_seq is ACKed. */ 2611 * when high_seq is ACKed. */
2612 if (icsk->icsk_ca_state == TCP_CA_Open) { 2612 if (icsk->icsk_ca_state == TCP_CA_Open) {
2613 BUG_TRAP(tp->retrans_out == 0); 2613 WARN_ON(tp->retrans_out != 0);
2614 tp->retrans_stamp = 0; 2614 tp->retrans_stamp = 0;
2615 } else if (!before(tp->snd_una, tp->high_seq)) { 2615 } else if (!before(tp->snd_una, tp->high_seq)) {
2616 switch (icsk->icsk_ca_state) { 2616 switch (icsk->icsk_ca_state) {
@@ -2972,9 +2972,9 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets)
2972 } 2972 }
2973 2973
2974#if FASTRETRANS_DEBUG > 0 2974#if FASTRETRANS_DEBUG > 0
2975 BUG_TRAP((int)tp->sacked_out >= 0); 2975 WARN_ON((int)tp->sacked_out < 0);
2976 BUG_TRAP((int)tp->lost_out >= 0); 2976 WARN_ON((int)tp->lost_out < 0);
2977 BUG_TRAP((int)tp->retrans_out >= 0); 2977 WARN_ON((int)tp->retrans_out < 0);
2978 if (!tp->packets_out && tcp_is_sack(tp)) { 2978 if (!tp->packets_out && tcp_is_sack(tp)) {
2979 icsk = inet_csk(sk); 2979 icsk = inet_csk(sk);
2980 if (tp->lost_out) { 2980 if (tp->lost_out) {
@@ -3877,7 +3877,7 @@ static void tcp_sack_remove(struct tcp_sock *tp)
3877 int i; 3877 int i;
3878 3878
3879 /* RCV.NXT must cover all the block! */ 3879 /* RCV.NXT must cover all the block! */
3880 BUG_TRAP(!before(tp->rcv_nxt, sp->end_seq)); 3880 WARN_ON(before(tp->rcv_nxt, sp->end_seq));
3881 3881
3882 /* Zap this SACK, by moving forward any other SACKS. */ 3882 /* Zap this SACK, by moving forward any other SACKS. */
3883 for (i=this_sack+1; i < num_sacks; i++) 3883 for (i=this_sack+1; i < num_sacks; i++)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a82df6307567..a2b06d0cc26b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -418,7 +418,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
418 /* ICMPs are not backlogged, hence we cannot get 418 /* ICMPs are not backlogged, hence we cannot get
419 an established socket here. 419 an established socket here.
420 */ 420 */
421 BUG_TRAP(!req->sk); 421 WARN_ON(req->sk);
422 422
423 if (seq != tcp_rsk(req)->snt_isn) { 423 if (seq != tcp_rsk(req)->snt_isn) {
424 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); 424 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 328e0cf42b3c..5ab6ba19c3ce 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -287,7 +287,7 @@ static void tcp_retransmit_timer(struct sock *sk)
287 if (!tp->packets_out) 287 if (!tp->packets_out)
288 goto out; 288 goto out;
289 289
290 BUG_TRAP(!tcp_write_queue_empty(sk)); 290 WARN_ON(tcp_write_queue_empty(sk));
291 291
292 if (!tp->snd_wnd && !sock_flag(sk, SOCK_DEAD) && 292 if (!tp->snd_wnd && !sock_flag(sk, SOCK_DEAD) &&
293 !((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))) { 293 !((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))) {
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 74d543d504a1..a7842c54f58a 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -313,8 +313,10 @@ static void in6_dev_finish_destroy_rcu(struct rcu_head *head)
313void in6_dev_finish_destroy(struct inet6_dev *idev) 313void in6_dev_finish_destroy(struct inet6_dev *idev)
314{ 314{
315 struct net_device *dev = idev->dev; 315 struct net_device *dev = idev->dev;
316 BUG_TRAP(idev->addr_list==NULL); 316
317 BUG_TRAP(idev->mc_list==NULL); 317 WARN_ON(idev->addr_list != NULL);
318 WARN_ON(idev->mc_list != NULL);
319
318#ifdef NET_REFCNT_DEBUG 320#ifdef NET_REFCNT_DEBUG
319 printk(KERN_DEBUG "in6_dev_finish_destroy: %s\n", dev ? dev->name : "NIL"); 321 printk(KERN_DEBUG "in6_dev_finish_destroy: %s\n", dev ? dev->name : "NIL");
320#endif 322#endif
@@ -517,8 +519,9 @@ static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)
517 519
518void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp) 520void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
519{ 521{
520 BUG_TRAP(ifp->if_next==NULL); 522 WARN_ON(ifp->if_next != NULL);
521 BUG_TRAP(ifp->lst_next==NULL); 523 WARN_ON(ifp->lst_next != NULL);
524
522#ifdef NET_REFCNT_DEBUG 525#ifdef NET_REFCNT_DEBUG
523 printk(KERN_DEBUG "inet6_ifa_finish_destroy\n"); 526 printk(KERN_DEBUG "inet6_ifa_finish_destroy\n");
524#endif 527#endif
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 60461ad7fa6f..95055f8c3f35 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -150,7 +150,7 @@ lookup_protocol:
150 answer_flags = answer->flags; 150 answer_flags = answer->flags;
151 rcu_read_unlock(); 151 rcu_read_unlock();
152 152
153 BUG_TRAP(answer_prot->slab != NULL); 153 WARN_ON(answer_prot->slab == NULL);
154 154
155 err = -ENOBUFS; 155 err = -ENOBUFS;
156 sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot); 156 sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot);
@@ -934,6 +934,11 @@ static int __init inet6_init(void)
934 if (err) 934 if (err)
935 goto out_unregister_sock; 935 goto out_unregister_sock;
936 936
937#ifdef CONFIG_SYSCTL
938 err = ipv6_static_sysctl_register();
939 if (err)
940 goto static_sysctl_fail;
941#endif
937 /* 942 /*
938 * ipngwg API draft makes clear that the correct semantics 943 * ipngwg API draft makes clear that the correct semantics
939 * for TCP and UDP is to consider one TCP and UDP instance 944 * for TCP and UDP is to consider one TCP and UDP instance
@@ -1058,6 +1063,10 @@ ipmr_fail:
1058icmp_fail: 1063icmp_fail:
1059 unregister_pernet_subsys(&inet6_net_ops); 1064 unregister_pernet_subsys(&inet6_net_ops);
1060register_pernet_fail: 1065register_pernet_fail:
1066#ifdef CONFIG_SYSCTL
1067 ipv6_static_sysctl_unregister();
1068static_sysctl_fail:
1069#endif
1061 cleanup_ipv6_mibs(); 1070 cleanup_ipv6_mibs();
1062out_unregister_sock: 1071out_unregister_sock:
1063 sock_unregister(PF_INET6); 1072 sock_unregister(PF_INET6);
@@ -1113,6 +1122,9 @@ static void __exit inet6_exit(void)
1113 rawv6_exit(); 1122 rawv6_exit();
1114 1123
1115 unregister_pernet_subsys(&inet6_net_ops); 1124 unregister_pernet_subsys(&inet6_net_ops);
1125#ifdef CONFIG_SYSCTL
1126 ipv6_static_sysctl_unregister();
1127#endif
1116 cleanup_ipv6_mibs(); 1128 cleanup_ipv6_mibs();
1117 proto_unregister(&rawv6_prot); 1129 proto_unregister(&rawv6_prot);
1118 proto_unregister(&udplitev6_prot); 1130 proto_unregister(&udplitev6_prot);
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 87801cc1b2f8..16d43f20b32f 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -98,7 +98,7 @@ struct request_sock *inet6_csk_search_req(const struct sock *sk,
98 ipv6_addr_equal(&treq->rmt_addr, raddr) && 98 ipv6_addr_equal(&treq->rmt_addr, raddr) &&
99 ipv6_addr_equal(&treq->loc_addr, laddr) && 99 ipv6_addr_equal(&treq->loc_addr, laddr) &&
100 (!treq->iif || treq->iif == iif)) { 100 (!treq->iif || treq->iif == iif)) {
101 BUG_TRAP(req->sk == NULL); 101 WARN_ON(req->sk != NULL);
102 *prevp = prev; 102 *prevp = prev;
103 return req; 103 return req;
104 } 104 }
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 00a8a5f9380c..1646a5658255 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -28,7 +28,7 @@ void __inet6_hash(struct sock *sk)
28 struct hlist_head *list; 28 struct hlist_head *list;
29 rwlock_t *lock; 29 rwlock_t *lock;
30 30
31 BUG_TRAP(sk_unhashed(sk)); 31 WARN_ON(!sk_unhashed(sk));
32 32
33 if (sk->sk_state == TCP_LISTEN) { 33 if (sk->sk_state == TCP_LISTEN) {
34 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; 34 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
@@ -202,7 +202,7 @@ unique:
202 * in hash table socket with a funny identity. */ 202 * in hash table socket with a funny identity. */
203 inet->num = lport; 203 inet->num = lport;
204 inet->sport = htons(lport); 204 inet->sport = htons(lport);
205 BUG_TRAP(sk_unhashed(sk)); 205 WARN_ON(!sk_unhashed(sk));
206 __sk_add_node(sk, &head->chain); 206 __sk_add_node(sk, &head->chain);
207 sk->sk_hash = hash; 207 sk->sk_hash = hash;
208 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 208 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 08ea2de28d63..52dddc25d3e6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -287,7 +287,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
287 w->leaf = rt; 287 w->leaf = rt;
288 return 1; 288 return 1;
289 } 289 }
290 BUG_TRAP(res!=0); 290 WARN_ON(res == 0);
291 } 291 }
292 w->leaf = NULL; 292 w->leaf = NULL;
293 return 0; 293 return 0;
@@ -778,7 +778,7 @@ out:
778 pn->leaf = fib6_find_prefix(info->nl_net, pn); 778 pn->leaf = fib6_find_prefix(info->nl_net, pn);
779#if RT6_DEBUG >= 2 779#if RT6_DEBUG >= 2
780 if (!pn->leaf) { 780 if (!pn->leaf) {
781 BUG_TRAP(pn->leaf != NULL); 781 WARN_ON(pn->leaf == NULL);
782 pn->leaf = info->nl_net->ipv6.ip6_null_entry; 782 pn->leaf = info->nl_net->ipv6.ip6_null_entry;
783 } 783 }
784#endif 784#endif
@@ -942,7 +942,7 @@ struct fib6_node * fib6_locate(struct fib6_node *root,
942 942
943#ifdef CONFIG_IPV6_SUBTREES 943#ifdef CONFIG_IPV6_SUBTREES
944 if (src_len) { 944 if (src_len) {
945 BUG_TRAP(saddr!=NULL); 945 WARN_ON(saddr == NULL);
946 if (fn && fn->subtree) 946 if (fn && fn->subtree)
947 fn = fib6_locate_1(fn->subtree, saddr, src_len, 947 fn = fib6_locate_1(fn->subtree, saddr, src_len,
948 offsetof(struct rt6_info, rt6i_src)); 948 offsetof(struct rt6_info, rt6i_src));
@@ -996,9 +996,9 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
996 RT6_TRACE("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter); 996 RT6_TRACE("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter);
997 iter++; 997 iter++;
998 998
999 BUG_TRAP(!(fn->fn_flags&RTN_RTINFO)); 999 WARN_ON(fn->fn_flags & RTN_RTINFO);
1000 BUG_TRAP(!(fn->fn_flags&RTN_TL_ROOT)); 1000 WARN_ON(fn->fn_flags & RTN_TL_ROOT);
1001 BUG_TRAP(fn->leaf==NULL); 1001 WARN_ON(fn->leaf != NULL);
1002 1002
1003 children = 0; 1003 children = 0;
1004 child = NULL; 1004 child = NULL;
@@ -1014,7 +1014,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
1014 fn->leaf = fib6_find_prefix(net, fn); 1014 fn->leaf = fib6_find_prefix(net, fn);
1015#if RT6_DEBUG >= 2 1015#if RT6_DEBUG >= 2
1016 if (fn->leaf==NULL) { 1016 if (fn->leaf==NULL) {
1017 BUG_TRAP(fn->leaf); 1017 WARN_ON(!fn->leaf);
1018 fn->leaf = net->ipv6.ip6_null_entry; 1018 fn->leaf = net->ipv6.ip6_null_entry;
1019 } 1019 }
1020#endif 1020#endif
@@ -1025,16 +1025,17 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
1025 pn = fn->parent; 1025 pn = fn->parent;
1026#ifdef CONFIG_IPV6_SUBTREES 1026#ifdef CONFIG_IPV6_SUBTREES
1027 if (FIB6_SUBTREE(pn) == fn) { 1027 if (FIB6_SUBTREE(pn) == fn) {
1028 BUG_TRAP(fn->fn_flags&RTN_ROOT); 1028 WARN_ON(!(fn->fn_flags & RTN_ROOT));
1029 FIB6_SUBTREE(pn) = NULL; 1029 FIB6_SUBTREE(pn) = NULL;
1030 nstate = FWS_L; 1030 nstate = FWS_L;
1031 } else { 1031 } else {
1032 BUG_TRAP(!(fn->fn_flags&RTN_ROOT)); 1032 WARN_ON(fn->fn_flags & RTN_ROOT);
1033#endif 1033#endif
1034 if (pn->right == fn) pn->right = child; 1034 if (pn->right == fn) pn->right = child;
1035 else if (pn->left == fn) pn->left = child; 1035 else if (pn->left == fn) pn->left = child;
1036#if RT6_DEBUG >= 2 1036#if RT6_DEBUG >= 2
1037 else BUG_TRAP(0); 1037 else
1038 WARN_ON(1);
1038#endif 1039#endif
1039 if (child) 1040 if (child)
1040 child->parent = pn; 1041 child->parent = pn;
@@ -1154,14 +1155,14 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
1154 1155
1155#if RT6_DEBUG >= 2 1156#if RT6_DEBUG >= 2
1156 if (rt->u.dst.obsolete>0) { 1157 if (rt->u.dst.obsolete>0) {
1157 BUG_TRAP(fn==NULL); 1158 WARN_ON(fn != NULL);
1158 return -ENOENT; 1159 return -ENOENT;
1159 } 1160 }
1160#endif 1161#endif
1161 if (fn == NULL || rt == net->ipv6.ip6_null_entry) 1162 if (fn == NULL || rt == net->ipv6.ip6_null_entry)
1162 return -ENOENT; 1163 return -ENOENT;
1163 1164
1164 BUG_TRAP(fn->fn_flags&RTN_RTINFO); 1165 WARN_ON(!(fn->fn_flags & RTN_RTINFO));
1165 1166
1166 if (!(rt->rt6i_flags&RTF_CACHE)) { 1167 if (!(rt->rt6i_flags&RTF_CACHE)) {
1167 struct fib6_node *pn = fn; 1168 struct fib6_node *pn = fn;
@@ -1266,7 +1267,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
1266 w->node = pn; 1267 w->node = pn;
1267#ifdef CONFIG_IPV6_SUBTREES 1268#ifdef CONFIG_IPV6_SUBTREES
1268 if (FIB6_SUBTREE(pn) == fn) { 1269 if (FIB6_SUBTREE(pn) == fn) {
1269 BUG_TRAP(fn->fn_flags&RTN_ROOT); 1270 WARN_ON(!(fn->fn_flags & RTN_ROOT));
1270 w->state = FWS_L; 1271 w->state = FWS_L;
1271 continue; 1272 continue;
1272 } 1273 }
@@ -1281,7 +1282,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
1281 continue; 1282 continue;
1282 } 1283 }
1283#if RT6_DEBUG >= 2 1284#if RT6_DEBUG >= 2
1284 BUG_TRAP(0); 1285 WARN_ON(1);
1285#endif 1286#endif
1286 } 1287 }
1287 } 1288 }
@@ -1323,7 +1324,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
1323 } 1324 }
1324 return 0; 1325 return 0;
1325 } 1326 }
1326 BUG_TRAP(res==0); 1327 WARN_ON(res != 0);
1327 } 1328 }
1328 w->leaf = rt; 1329 w->leaf = rt;
1329 return 0; 1330 return 0;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 6407c64ea4a5..6811901e6b1e 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -116,7 +116,7 @@ static int ip6_dev_loopback_xmit(struct sk_buff *newskb)
116 __skb_pull(newskb, skb_network_offset(newskb)); 116 __skb_pull(newskb, skb_network_offset(newskb));
117 newskb->pkt_type = PACKET_LOOPBACK; 117 newskb->pkt_type = PACKET_LOOPBACK;
118 newskb->ip_summed = CHECKSUM_UNNECESSARY; 118 newskb->ip_summed = CHECKSUM_UNNECESSARY;
119 BUG_TRAP(newskb->dst); 119 WARN_ON(!newskb->dst);
120 120
121 netif_rx(newskb); 121 netif_rx(newskb);
122 return 0; 122 return 0;
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 0cfcea42153a..4545e4306862 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -134,9 +134,7 @@ out:
134 134
135static int ipcomp6_init_state(struct xfrm_state *x) 135static int ipcomp6_init_state(struct xfrm_state *x)
136{ 136{
137 int err; 137 int err = -EINVAL;
138 struct ipcomp_data *ipcd;
139 struct xfrm_algo_desc *calg_desc;
140 138
141 x->props.header_len = 0; 139 x->props.header_len = 0;
142 switch (x->props.mode) { 140 switch (x->props.mode) {
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index ad1cc5bbf977..31295c8f6196 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -164,8 +164,8 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb)
164 calc_padlen(sizeof(*dstopt), 6)); 164 calc_padlen(sizeof(*dstopt), 6));
165 165
166 hao->type = IPV6_TLV_HAO; 166 hao->type = IPV6_TLV_HAO;
167 BUILD_BUG_ON(sizeof(*hao) != 18);
167 hao->length = sizeof(*hao) - 2; 168 hao->length = sizeof(*hao) - 2;
168 BUG_TRAP(hao->length == 16);
169 169
170 len = ((char *)hao - (char *)dstopt) + sizeof(*hao); 170 len = ((char *)hao - (char *)dstopt) + sizeof(*hao);
171 171
@@ -174,7 +174,7 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb)
174 memcpy(&iph->saddr, x->coaddr, sizeof(iph->saddr)); 174 memcpy(&iph->saddr, x->coaddr, sizeof(iph->saddr));
175 spin_unlock_bh(&x->lock); 175 spin_unlock_bh(&x->lock);
176 176
177 BUG_TRAP(len == x->props.header_len); 177 WARN_ON(len != x->props.header_len);
178 dstopt->hdrlen = (x->props.header_len >> 3) - 1; 178 dstopt->hdrlen = (x->props.header_len >> 3) - 1;
179 179
180 return 0; 180 return 0;
@@ -317,7 +317,7 @@ static int mip6_destopt_init_state(struct xfrm_state *x)
317 x->props.header_len = sizeof(struct ipv6_destopt_hdr) + 317 x->props.header_len = sizeof(struct ipv6_destopt_hdr) +
318 calc_padlen(sizeof(struct ipv6_destopt_hdr), 6) + 318 calc_padlen(sizeof(struct ipv6_destopt_hdr), 6) +
319 sizeof(struct ipv6_destopt_hao); 319 sizeof(struct ipv6_destopt_hao);
320 BUG_TRAP(x->props.header_len == 24); 320 WARN_ON(x->props.header_len != 24);
321 321
322 return 0; 322 return 0;
323} 323}
@@ -380,7 +380,7 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb)
380 rt2->rt_hdr.segments_left = 1; 380 rt2->rt_hdr.segments_left = 1;
381 memset(&rt2->reserved, 0, sizeof(rt2->reserved)); 381 memset(&rt2->reserved, 0, sizeof(rt2->reserved));
382 382
383 BUG_TRAP(rt2->rt_hdr.hdrlen == 2); 383 WARN_ON(rt2->rt_hdr.hdrlen != 2);
384 384
385 memcpy(&rt2->addr, &iph->daddr, sizeof(rt2->addr)); 385 memcpy(&rt2->addr, &iph->daddr, sizeof(rt2->addr));
386 spin_lock_bh(&x->lock); 386 spin_lock_bh(&x->lock);
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index a07abee30497..6e7131036bc6 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -31,7 +31,7 @@ static struct
31 struct ip6t_replace repl; 31 struct ip6t_replace repl;
32 struct ip6t_standard entries[3]; 32 struct ip6t_standard entries[3];
33 struct ip6t_error term; 33 struct ip6t_error term;
34} initial_table __initdata = { 34} initial_table __net_initdata = {
35 .repl = { 35 .repl = {
36 .name = "security", 36 .name = "security",
37 .valid_hooks = SECURITY_VALID_HOOKS, 37 .valid_hooks = SECURITY_VALID_HOOKS,
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index cf20bc4fd60d..52d06dd4b817 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -416,8 +416,8 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
416 416
417 fq_kill(fq); 417 fq_kill(fq);
418 418
419 BUG_TRAP(head != NULL); 419 WARN_ON(head == NULL);
420 BUG_TRAP(NFCT_FRAG6_CB(head)->offset == 0); 420 WARN_ON(NFCT_FRAG6_CB(head)->offset != 0);
421 421
422 /* Unfragmented part is taken from the first segment. */ 422 /* Unfragmented part is taken from the first segment. */
423 payload_len = ((head->data - skb_network_header(head)) - 423 payload_len = ((head->data - skb_network_header(head)) -
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 6ab957ec2dd6..89184b576e23 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -473,8 +473,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
473 fq->q.fragments = head; 473 fq->q.fragments = head;
474 } 474 }
475 475
476 BUG_TRAP(head != NULL); 476 WARN_ON(head == NULL);
477 BUG_TRAP(FRAG6_CB(head)->offset == 0); 477 WARN_ON(FRAG6_CB(head)->offset != 0);
478 478
479 /* Unfragmented part is taken from the first segment. */ 479 /* Unfragmented part is taken from the first segment. */
480 payload_len = ((head->data - skb_network_header(head)) - 480 payload_len = ((head->data - skb_network_header(head)) -
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 6a68eeb7bbf8..a46badd1082d 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -223,6 +223,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
223 223
224 req->expires = 0UL; 224 req->expires = 0UL;
225 req->retrans = 0; 225 req->retrans = 0;
226 ireq->ecn_ok = 0;
226 ireq->snd_wscale = tcp_opt.snd_wscale; 227 ireq->snd_wscale = tcp_opt.snd_wscale;
227 ireq->rcv_wscale = tcp_opt.rcv_wscale; 228 ireq->rcv_wscale = tcp_opt.rcv_wscale;
228 ireq->sack_ok = tcp_opt.sack_ok; 229 ireq->sack_ok = tcp_opt.sack_ok;
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 5c99274558bf..e6dfaeac6be3 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -150,3 +150,19 @@ void ipv6_sysctl_unregister(void)
150 unregister_net_sysctl_table(ip6_header); 150 unregister_net_sysctl_table(ip6_header);
151 unregister_pernet_subsys(&ipv6_sysctl_net_ops); 151 unregister_pernet_subsys(&ipv6_sysctl_net_ops);
152} 152}
153
154static struct ctl_table_header *ip6_base;
155
156int ipv6_static_sysctl_register(void)
157{
158 static struct ctl_table empty[1];
159 ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty);
160 if (ip6_base == NULL)
161 return -ENOMEM;
162 return 0;
163}
164
165void ipv6_static_sysctl_unregister(void)
166{
167 unregister_net_sysctl_table(ip6_base);
168}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index ae45f9835014..cff778b23a7f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -421,7 +421,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
421 /* ICMPs are not backlogged, hence we cannot get 421 /* ICMPs are not backlogged, hence we cannot get
422 * an established socket here. 422 * an established socket here.
423 */ 423 */
424 BUG_TRAP(req->sk == NULL); 424 WARN_ON(req->sk != NULL);
425 425
426 if (seq != tcp_rsk(req)->snt_isn) { 426 if (seq != tcp_rsk(req)->snt_isn) {
427 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS); 427 NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index f0fc46c8038d..d628df97e02e 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -96,8 +96,8 @@ static void pfkey_sock_destruct(struct sock *sk)
96 return; 96 return;
97 } 97 }
98 98
99 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); 99 WARN_ON(atomic_read(&sk->sk_rmem_alloc));
100 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 100 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
101 101
102 atomic_dec(&pfkey_socks_nr); 102 atomic_dec(&pfkey_socks_nr);
103} 103}
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index 3469bc71a385..4b2c769d555f 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -95,7 +95,7 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
95 newlen = newoff + t->len; 95 newlen = newoff + t->len;
96 rcu_read_unlock(); 96 rcu_read_unlock();
97 97
98 new = krealloc(ct->ext, newlen, gfp); 98 new = __krealloc(ct->ext, newlen, gfp);
99 if (!new) 99 if (!new)
100 return NULL; 100 return NULL;
101 101
@@ -115,10 +115,10 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
115 ct->ext = new; 115 ct->ext = new;
116 } 116 }
117 117
118 ct->ext->offset[id] = newoff; 118 new->offset[id] = newoff;
119 ct->ext->len = newlen; 119 new->len = newlen;
120 memset((void *)ct->ext + newoff, 0, newlen - newoff); 120 memset((void *)new + newoff, 0, newlen - newoff);
121 return (void *)ct->ext + newoff; 121 return (void *)new + newoff;
122} 122}
123EXPORT_SYMBOL(__nf_ct_ext_add); 123EXPORT_SYMBOL(__nf_ct_ext_add);
124 124
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 98bfe277eab2..b0eacc0007cc 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -158,9 +158,10 @@ static void netlink_sock_destruct(struct sock *sk)
158 printk(KERN_ERR "Freeing alive netlink socket %p\n", sk); 158 printk(KERN_ERR "Freeing alive netlink socket %p\n", sk);
159 return; 159 return;
160 } 160 }
161 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); 161
162 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 162 WARN_ON(atomic_read(&sk->sk_rmem_alloc));
163 BUG_TRAP(!nlk_sk(sk)->groups); 163 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
164 WARN_ON(nlk_sk(sk)->groups);
164} 165}
165 166
166/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on 167/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d56cae112dc8..c718e7e3f7de 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -260,8 +260,8 @@ static inline struct packet_sock *pkt_sk(struct sock *sk)
260 260
261static void packet_sock_destruct(struct sock *sk) 261static void packet_sock_destruct(struct sock *sk)
262{ 262{
263 BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc)); 263 WARN_ON(atomic_read(&sk->sk_rmem_alloc));
264 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 264 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
265 265
266 if (!sock_flag(sk, SOCK_DEAD)) { 266 if (!sock_flag(sk, SOCK_DEAD)) {
267 printk("Attempt to release alive packet socket: %p\n", sk); 267 printk("Attempt to release alive packet socket: %p\n", sk);
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 4b2682feeedc..32e489118beb 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -660,9 +660,9 @@ static void rxrpc_sock_destructor(struct sock *sk)
660 660
661 rxrpc_purge_queue(&sk->sk_receive_queue); 661 rxrpc_purge_queue(&sk->sk_receive_queue);
662 662
663 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 663 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
664 BUG_TRAP(sk_unhashed(sk)); 664 WARN_ON(!sk_unhashed(sk));
665 BUG_TRAP(!sk->sk_socket); 665 WARN_ON(sk->sk_socket);
666 666
667 if (!sock_flag(sk, SOCK_DEAD)) { 667 if (!sock_flag(sk, SOCK_DEAD)) {
668 printk("Attempt to release alive rxrpc socket: %p\n", sk); 668 printk("Attempt to release alive rxrpc socket: %p\n", sk);
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 74e662cbb2c5..d308c19aa3f9 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -41,7 +41,7 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
41 return; 41 return;
42 } 42 }
43 } 43 }
44 BUG_TRAP(0); 44 WARN_ON(1);
45} 45}
46EXPORT_SYMBOL(tcf_hash_destroy); 46EXPORT_SYMBOL(tcf_hash_destroy);
47 47
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 32c3f9d9fb7a..38015b493947 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -116,7 +116,7 @@ static void tcf_police_destroy(struct tcf_police *p)
116 return; 116 return;
117 } 117 }
118 } 118 }
119 BUG_TRAP(0); 119 WARN_ON(1);
120} 120}
121 121
122static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { 122static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 527db2559dd2..246f9065ce34 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -345,7 +345,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode* key)
345 } 345 }
346 } 346 }
347 } 347 }
348 BUG_TRAP(0); 348 WARN_ON(1);
349 return 0; 349 return 0;
350} 350}
351 351
@@ -368,7 +368,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
368 struct tc_u_common *tp_c = tp->data; 368 struct tc_u_common *tp_c = tp->data;
369 struct tc_u_hnode **hn; 369 struct tc_u_hnode **hn;
370 370
371 BUG_TRAP(!ht->refcnt); 371 WARN_ON(ht->refcnt);
372 372
373 u32_clear_hnode(tp, ht); 373 u32_clear_hnode(tp, ht);
374 374
@@ -380,7 +380,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
380 } 380 }
381 } 381 }
382 382
383 BUG_TRAP(0); 383 WARN_ON(1);
384 return -ENOENT; 384 return -ENOENT;
385} 385}
386 386
@@ -389,7 +389,7 @@ static void u32_destroy(struct tcf_proto *tp)
389 struct tc_u_common *tp_c = tp->data; 389 struct tc_u_common *tp_c = tp->data;
390 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); 390 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL);
391 391
392 BUG_TRAP(root_ht != NULL); 392 WARN_ON(root_ht == NULL);
393 393
394 if (root_ht && --root_ht->refcnt == 0) 394 if (root_ht && --root_ht->refcnt == 0)
395 u32_destroy_hnode(tp, root_ht); 395 u32_destroy_hnode(tp, root_ht);
@@ -407,7 +407,7 @@ static void u32_destroy(struct tcf_proto *tp)
407 while ((ht = tp_c->hlist) != NULL) { 407 while ((ht = tp_c->hlist) != NULL) {
408 tp_c->hlist = ht->next; 408 tp_c->hlist = ht->next;
409 409
410 BUG_TRAP(ht->refcnt == 0); 410 WARN_ON(ht->refcnt != 0);
411 411
412 kfree(ht); 412 kfree(ht);
413 } 413 }
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 04faa835be17..6b517b9dac5b 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -162,7 +162,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
162 qdisc_destroy(flow->q); 162 qdisc_destroy(flow->q);
163 tcf_destroy_chain(&flow->filter_list); 163 tcf_destroy_chain(&flow->filter_list);
164 if (flow->sock) { 164 if (flow->sock) {
165 pr_debug("atm_tc_put: f_count %d\n", 165 pr_debug("atm_tc_put: f_count %ld\n",
166 file_count(flow->sock->file)); 166 file_count(flow->sock->file));
167 flow->vcc->pop = flow->old_pop; 167 flow->vcc->pop = flow->old_pop;
168 sockfd_put(flow->sock); 168 sockfd_put(flow->sock);
@@ -259,7 +259,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
259 sock = sockfd_lookup(fd, &error); 259 sock = sockfd_lookup(fd, &error);
260 if (!sock) 260 if (!sock)
261 return error; /* f_count++ */ 261 return error; /* f_count++ */
262 pr_debug("atm_tc_change: f_count %d\n", file_count(sock->file)); 262 pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file));
263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { 263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
264 error = -EPROTOTYPE; 264 error = -EPROTOTYPE;
265 goto err_out; 265 goto err_out;
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index f1d2f8ec8b4c..14954bf4a683 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1175,7 +1175,7 @@ static void cbq_unlink_class(struct cbq_class *this)
1175 this->tparent->children = NULL; 1175 this->tparent->children = NULL;
1176 } 1176 }
1177 } else { 1177 } else {
1178 BUG_TRAP(this->sibling == this); 1178 WARN_ON(this->sibling != this);
1179 } 1179 }
1180} 1180}
1181 1181
@@ -1699,7 +1699,7 @@ static void cbq_destroy_class(struct Qdisc *sch, struct cbq_class *cl)
1699{ 1699{
1700 struct cbq_sched_data *q = qdisc_priv(sch); 1700 struct cbq_sched_data *q = qdisc_priv(sch);
1701 1701
1702 BUG_TRAP(!cl->filters); 1702 WARN_ON(cl->filters);
1703 1703
1704 tcf_destroy_chain(&cl->filter_list); 1704 tcf_destroy_chain(&cl->filter_list);
1705 qdisc_destroy(cl->q); 1705 qdisc_destroy(cl->q);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 43abd4d27ea6..fd2a6cadb115 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -746,5 +746,5 @@ void dev_shutdown(struct net_device *dev)
746{ 746{
747 netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc); 747 netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc);
748 shutdown_scheduler_queue(dev, &dev->rx_queue, NULL); 748 shutdown_scheduler_queue(dev, &dev->rx_queue, NULL);
749 BUG_TRAP(!timer_pending(&dev->watchdog_timer)); 749 WARN_ON(timer_pending(&dev->watchdog_timer));
750} 750}
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 30c999c61b01..75a40951c4f2 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -524,7 +524,7 @@ htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, long *diff)
524 */ 524 */
525static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) 525static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
526{ 526{
527 BUG_TRAP(!cl->level && cl->un.leaf.q && cl->un.leaf.q->q.qlen); 527 WARN_ON(cl->level || !cl->un.leaf.q || !cl->un.leaf.q->q.qlen);
528 528
529 if (!cl->prio_activity) { 529 if (!cl->prio_activity) {
530 cl->prio_activity = 1 << (cl->un.leaf.aprio = cl->un.leaf.prio); 530 cl->prio_activity = 1 << (cl->un.leaf.aprio = cl->un.leaf.prio);
@@ -542,7 +542,7 @@ static inline void htb_activate(struct htb_sched *q, struct htb_class *cl)
542 */ 542 */
543static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl) 543static inline void htb_deactivate(struct htb_sched *q, struct htb_class *cl)
544{ 544{
545 BUG_TRAP(cl->prio_activity); 545 WARN_ON(!cl->prio_activity);
546 546
547 htb_deactivate_prios(q, cl); 547 htb_deactivate_prios(q, cl);
548 cl->prio_activity = 0; 548 cl->prio_activity = 0;
@@ -757,7 +757,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
757 u32 *pid; 757 u32 *pid;
758 } stk[TC_HTB_MAXDEPTH], *sp = stk; 758 } stk[TC_HTB_MAXDEPTH], *sp = stk;
759 759
760 BUG_TRAP(tree->rb_node); 760 WARN_ON(!tree->rb_node);
761 sp->root = tree->rb_node; 761 sp->root = tree->rb_node;
762 sp->pptr = pptr; 762 sp->pptr = pptr;
763 sp->pid = pid; 763 sp->pid = pid;
@@ -777,7 +777,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
777 *sp->pptr = (*sp->pptr)->rb_left; 777 *sp->pptr = (*sp->pptr)->rb_left;
778 if (sp > stk) { 778 if (sp > stk) {
779 sp--; 779 sp--;
780 BUG_TRAP(*sp->pptr); 780 WARN_ON(!*sp->pptr);
781 if (!*sp->pptr) 781 if (!*sp->pptr)
782 return NULL; 782 return NULL;
783 htb_next_rb_node(sp->pptr); 783 htb_next_rb_node(sp->pptr);
@@ -792,7 +792,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
792 sp->pid = cl->un.inner.last_ptr_id + prio; 792 sp->pid = cl->un.inner.last_ptr_id + prio;
793 } 793 }
794 } 794 }
795 BUG_TRAP(0); 795 WARN_ON(1);
796 return NULL; 796 return NULL;
797} 797}
798 798
@@ -810,7 +810,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio,
810 810
811 do { 811 do {
812next: 812next:
813 BUG_TRAP(cl); 813 WARN_ON(!cl);
814 if (!cl) 814 if (!cl)
815 return NULL; 815 return NULL;
816 816
@@ -1185,7 +1185,7 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
1185{ 1185{
1186 struct htb_class *parent = cl->parent; 1186 struct htb_class *parent = cl->parent;
1187 1187
1188 BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity); 1188 WARN_ON(cl->level || !cl->un.leaf.q || cl->prio_activity);
1189 1189
1190 if (parent->cmode != HTB_CAN_SEND) 1190 if (parent->cmode != HTB_CAN_SEND)
1191 htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level); 1191 htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level);
@@ -1205,7 +1205,7 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
1205static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) 1205static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
1206{ 1206{
1207 if (!cl->level) { 1207 if (!cl->level) {
1208 BUG_TRAP(cl->un.leaf.q); 1208 WARN_ON(!cl->un.leaf.q);
1209 qdisc_destroy(cl->un.leaf.q); 1209 qdisc_destroy(cl->un.leaf.q);
1210 } 1210 }
1211 gen_kill_estimator(&cl->bstats, &cl->rate_est); 1211 gen_kill_estimator(&cl->bstats, &cl->rate_est);
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 73f53844ce97..8589da666568 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -536,14 +536,7 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
536 536
537 opt.limit = q->limit; 537 opt.limit = q->limit;
538 opt.divisor = SFQ_HASH_DIVISOR; 538 opt.divisor = SFQ_HASH_DIVISOR;
539 opt.flows = 0; 539 opt.flows = q->limit;
540 if (q->tail != SFQ_DEPTH) {
541 unsigned int i;
542
543 for (i = 0; i < SFQ_HASH_DIVISOR; i++)
544 if (q->ht[i] != SFQ_DEPTH)
545 opt.flows++;
546 }
547 540
548 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); 541 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
549 542
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index ec2a0a33fd78..8472b8b349c4 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -464,7 +464,7 @@ static void sctp_association_destroy(struct sctp_association *asoc)
464 spin_unlock_bh(&sctp_assocs_id_lock); 464 spin_unlock_bh(&sctp_assocs_id_lock);
465 } 465 }
466 466
467 BUG_TRAP(!atomic_read(&asoc->rmem_alloc)); 467 WARN_ON(atomic_read(&asoc->rmem_alloc));
468 468
469 if (asoc->base.malloced) { 469 if (asoc->base.malloced) {
470 kfree(asoc); 470 kfree(asoc);
diff --git a/net/socket.c b/net/socket.c
index 1310a82cbba7..8ef8ba81b9e2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -265,7 +265,7 @@ static void sock_destroy_inode(struct inode *inode)
265 container_of(inode, struct socket_alloc, vfs_inode)); 265 container_of(inode, struct socket_alloc, vfs_inode));
266} 266}
267 267
268static void init_once(struct kmem_cache *cachep, void *foo) 268static void init_once(void *foo)
269{ 269{
270 struct socket_alloc *ei = (struct socket_alloc *)foo; 270 struct socket_alloc *ei = (struct socket_alloc *)foo;
271 271
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 5a9b0e7828cd..23a2b8f6dc49 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -897,7 +897,7 @@ static struct file_system_type rpc_pipe_fs_type = {
897}; 897};
898 898
899static void 899static void
900init_once(struct kmem_cache * cachep, void *foo) 900init_once(void *foo)
901{ 901{
902 struct rpc_inode *rpci = (struct rpc_inode *) foo; 902 struct rpc_inode *rpci = (struct rpc_inode *) foo;
903 903
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 835d27413083..5a32cb7c4bb4 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -310,8 +310,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)
310 switch (m->mode) { 310 switch (m->mode) {
311 case SVC_POOL_PERCPU: 311 case SVC_POOL_PERCPU:
312 { 312 {
313 cpumask_of_cpu_ptr(cpumask, node); 313 set_cpus_allowed_ptr(task, &cpumask_of_cpu(node));
314 set_cpus_allowed_ptr(task, cpumask);
315 break; 314 break;
316 } 315 }
317 case SVC_POOL_PERNODE: 316 case SVC_POOL_PERNODE:
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index a19b22b452a3..84d328329d98 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -169,7 +169,8 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
169 (void *) 169 (void *)
170 vec->sge[xdr_sge_no].iov_base + sge_off, 170 vec->sge[xdr_sge_no].iov_base + sge_off,
171 sge_bytes, DMA_TO_DEVICE); 171 sge_bytes, DMA_TO_DEVICE);
172 if (dma_mapping_error(sge[sge_no].addr)) 172 if (dma_mapping_error(xprt->sc_cm_id->device->dma_device,
173 sge[sge_no].addr))
173 goto err; 174 goto err;
174 sge_off = 0; 175 sge_off = 0;
175 sge_no++; 176 sge_no++;
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 63ada437fc2f..972201cd5fa7 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -29,10 +29,15 @@
29#include <linux/if_tr.h> 29#include <linux/if_tr.h>
30#endif 30#endif
31 31
32static struct list_head * 32static struct ctl_table_set *
33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) 33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces)
34{ 34{
35 return &namespaces->net_ns->sysctl_table_headers; 35 return &namespaces->net_ns->sysctls;
36}
37
38static int is_seen(struct ctl_table_set *set)
39{
40 return &current->nsproxy->net_ns->sysctls == set;
36} 41}
37 42
38/* Return standard mode bits for table entry. */ 43/* Return standard mode bits for table entry. */
@@ -53,13 +58,6 @@ static struct ctl_table_root net_sysctl_root = {
53 .permissions = net_ctl_permissions, 58 .permissions = net_ctl_permissions,
54}; 59};
55 60
56static LIST_HEAD(net_sysctl_ro_tables);
57static struct list_head *net_ctl_ro_header_lookup(struct ctl_table_root *root,
58 struct nsproxy *namespaces)
59{
60 return &net_sysctl_ro_tables;
61}
62
63static int net_ctl_ro_header_perms(struct ctl_table_root *root, 61static int net_ctl_ro_header_perms(struct ctl_table_root *root,
64 struct nsproxy *namespaces, struct ctl_table *table) 62 struct nsproxy *namespaces, struct ctl_table *table)
65{ 63{
@@ -70,19 +68,20 @@ static int net_ctl_ro_header_perms(struct ctl_table_root *root,
70} 68}
71 69
72static struct ctl_table_root net_sysctl_ro_root = { 70static struct ctl_table_root net_sysctl_ro_root = {
73 .lookup = net_ctl_ro_header_lookup,
74 .permissions = net_ctl_ro_header_perms, 71 .permissions = net_ctl_ro_header_perms,
75}; 72};
76 73
77static int sysctl_net_init(struct net *net) 74static int sysctl_net_init(struct net *net)
78{ 75{
79 INIT_LIST_HEAD(&net->sysctl_table_headers); 76 setup_sysctl_set(&net->sysctls,
77 &net_sysctl_ro_root.default_set,
78 is_seen);
80 return 0; 79 return 0;
81} 80}
82 81
83static void sysctl_net_exit(struct net *net) 82static void sysctl_net_exit(struct net *net)
84{ 83{
85 WARN_ON(!list_empty(&net->sysctl_table_headers)); 84 WARN_ON(!list_empty(&net->sysctls.list));
86 return; 85 return;
87} 86}
88 87
@@ -98,6 +97,7 @@ static __init int sysctl_init(void)
98 if (ret) 97 if (ret)
99 goto out; 98 goto out;
100 register_sysctl_root(&net_sysctl_root); 99 register_sysctl_root(&net_sysctl_root);
100 setup_sysctl_set(&net_sysctl_ro_root.default_set, NULL, NULL);
101 register_sysctl_root(&net_sysctl_ro_root); 101 register_sysctl_root(&net_sysctl_ro_root);
102out: 102out:
103 return ret; 103 return ret;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 70ceb1604ad8..015606b54d9b 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -227,7 +227,7 @@ static void __unix_remove_socket(struct sock *sk)
227 227
228static void __unix_insert_socket(struct hlist_head *list, struct sock *sk) 228static void __unix_insert_socket(struct hlist_head *list, struct sock *sk)
229{ 229{
230 BUG_TRAP(sk_unhashed(sk)); 230 WARN_ON(!sk_unhashed(sk));
231 sk_add_node(sk, list); 231 sk_add_node(sk, list);
232} 232}
233 233
@@ -350,9 +350,9 @@ static void unix_sock_destructor(struct sock *sk)
350 350
351 skb_queue_purge(&sk->sk_receive_queue); 351 skb_queue_purge(&sk->sk_receive_queue);
352 352
353 BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc)); 353 WARN_ON(atomic_read(&sk->sk_wmem_alloc));
354 BUG_TRAP(sk_unhashed(sk)); 354 WARN_ON(!sk_unhashed(sk));
355 BUG_TRAP(!sk->sk_socket); 355 WARN_ON(sk->sk_socket);
356 if (!sock_flag(sk, SOCK_DEAD)) { 356 if (!sock_flag(sk, SOCK_DEAD)) {
357 printk("Attempt to release alive unix socket: %p\n", sk); 357 printk("Attempt to release alive unix socket: %p\n", sk);
358 return; 358 return;
@@ -603,7 +603,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
603 u->dentry = NULL; 603 u->dentry = NULL;
604 u->mnt = NULL; 604 u->mnt = NULL;
605 spin_lock_init(&u->lock); 605 spin_lock_init(&u->lock);
606 atomic_set(&u->inflight, 0); 606 atomic_long_set(&u->inflight, 0);
607 INIT_LIST_HEAD(&u->link); 607 INIT_LIST_HEAD(&u->link);
608 mutex_init(&u->readlock); /* single task reading lock */ 608 mutex_init(&u->readlock); /* single task reading lock */
609 init_waitqueue_head(&u->peer_wait); 609 init_waitqueue_head(&u->peer_wait);
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index ebdff3d877a1..2a27b84f740b 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -127,7 +127,7 @@ void unix_inflight(struct file *fp)
127 if(s) { 127 if(s) {
128 struct unix_sock *u = unix_sk(s); 128 struct unix_sock *u = unix_sk(s);
129 spin_lock(&unix_gc_lock); 129 spin_lock(&unix_gc_lock);
130 if (atomic_inc_return(&u->inflight) == 1) { 130 if (atomic_long_inc_return(&u->inflight) == 1) {
131 BUG_ON(!list_empty(&u->link)); 131 BUG_ON(!list_empty(&u->link));
132 list_add_tail(&u->link, &gc_inflight_list); 132 list_add_tail(&u->link, &gc_inflight_list);
133 } else { 133 } else {
@@ -145,7 +145,7 @@ void unix_notinflight(struct file *fp)
145 struct unix_sock *u = unix_sk(s); 145 struct unix_sock *u = unix_sk(s);
146 spin_lock(&unix_gc_lock); 146 spin_lock(&unix_gc_lock);
147 BUG_ON(list_empty(&u->link)); 147 BUG_ON(list_empty(&u->link));
148 if (atomic_dec_and_test(&u->inflight)) 148 if (atomic_long_dec_and_test(&u->inflight))
149 list_del_init(&u->link); 149 list_del_init(&u->link);
150 unix_tot_inflight--; 150 unix_tot_inflight--;
151 spin_unlock(&unix_gc_lock); 151 spin_unlock(&unix_gc_lock);
@@ -237,17 +237,17 @@ static void scan_children(struct sock *x, void (*func)(struct unix_sock *),
237 237
238static void dec_inflight(struct unix_sock *usk) 238static void dec_inflight(struct unix_sock *usk)
239{ 239{
240 atomic_dec(&usk->inflight); 240 atomic_long_dec(&usk->inflight);
241} 241}
242 242
243static void inc_inflight(struct unix_sock *usk) 243static void inc_inflight(struct unix_sock *usk)
244{ 244{
245 atomic_inc(&usk->inflight); 245 atomic_long_inc(&usk->inflight);
246} 246}
247 247
248static void inc_inflight_move_tail(struct unix_sock *u) 248static void inc_inflight_move_tail(struct unix_sock *u)
249{ 249{
250 atomic_inc(&u->inflight); 250 atomic_long_inc(&u->inflight);
251 /* 251 /*
252 * If this is still a candidate, move it to the end of the 252 * If this is still a candidate, move it to the end of the
253 * list, so that it's checked even if it was already passed 253 * list, so that it's checked even if it was already passed
@@ -288,11 +288,11 @@ void unix_gc(void)
288 * before the detach without atomicity guarantees. 288 * before the detach without atomicity guarantees.
289 */ 289 */
290 list_for_each_entry_safe(u, next, &gc_inflight_list, link) { 290 list_for_each_entry_safe(u, next, &gc_inflight_list, link) {
291 int total_refs; 291 long total_refs;
292 int inflight_refs; 292 long inflight_refs;
293 293
294 total_refs = file_count(u->sk.sk_socket->file); 294 total_refs = file_count(u->sk.sk_socket->file);
295 inflight_refs = atomic_read(&u->inflight); 295 inflight_refs = atomic_long_read(&u->inflight);
296 296
297 BUG_ON(inflight_refs < 1); 297 BUG_ON(inflight_refs < 1);
298 BUG_ON(total_refs < inflight_refs); 298 BUG_ON(total_refs < inflight_refs);
@@ -324,7 +324,7 @@ void unix_gc(void)
324 /* Move cursor to after the current position. */ 324 /* Move cursor to after the current position. */
325 list_move(&cursor, &u->link); 325 list_move(&cursor, &u->link);
326 326
327 if (atomic_read(&u->inflight) > 0) { 327 if (atomic_long_read(&u->inflight) > 0) {
328 list_move_tail(&u->link, &gc_inflight_list); 328 list_move_tail(&u->link, &gc_inflight_list);
329 u->gc_candidate = 0; 329 u->gc_candidate = 0;
330 scan_children(&u->sk, inc_inflight_move_tail, NULL); 330 scan_children(&u->sk, inc_inflight_move_tail, NULL);
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 23a2cc04b8cd..96036cf2216d 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -718,7 +718,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
718 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 718 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
719 int end; 719 int end;
720 720
721 BUG_TRAP(start <= offset + len); 721 WARN_ON(start > offset + len);
722 722
723 end = start + skb_shinfo(skb)->frags[i].size; 723 end = start + skb_shinfo(skb)->frags[i].size;
724 if ((copy = end - offset) > 0) { 724 if ((copy = end - offset) > 0) {
@@ -748,7 +748,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
748 for (; list; list = list->next) { 748 for (; list; list = list->next) {
749 int end; 749 int end;
750 750
751 BUG_TRAP(start <= offset + len); 751 WARN_ON(start > offset + len);
752 752
753 end = start + list->len; 753 end = start + list->len;
754 if ((copy = end - offset) > 0) { 754 if ((copy = end - offset) > 0) {
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 800f669083fb..c609a4b98e15 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -22,7 +22,6 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/percpu.h> 24#include <linux/percpu.h>
25#include <linux/rtnetlink.h>
26#include <linux/smp.h> 25#include <linux/smp.h>
27#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
28#include <net/ip.h> 27#include <net/ip.h>
@@ -251,7 +250,7 @@ static void ipcomp_free_tfms(struct crypto_comp **tfms)
251 break; 250 break;
252 } 251 }
253 252
254 BUG_TRAP(pos); 253 WARN_ON(!pos);
255 254
256 if (--pos->users) 255 if (--pos->users)
257 return; 256 return;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 72fddafd891a..4c6914ef7d92 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -538,7 +538,7 @@ EXPORT_SYMBOL(xfrm_state_alloc);
538 538
539void __xfrm_state_destroy(struct xfrm_state *x) 539void __xfrm_state_destroy(struct xfrm_state *x)
540{ 540{
541 BUG_TRAP(x->km.state == XFRM_STATE_DEAD); 541 WARN_ON(x->km.state != XFRM_STATE_DEAD);
542 542
543 spin_lock_bh(&xfrm_state_lock); 543 spin_lock_bh(&xfrm_state_lock);
544 list_del(&x->all); 544 list_del(&x->all);
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 53dae3eb3d1f..612dc13ddd85 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -1,194 +1,98 @@
1# ========================================================================== 1# ==========================================================================
2# Installing headers 2# Installing headers
3# 3#
4# header-y files will be installed verbatim 4# header-y - list files to be installed. They are preprocessed
5# unifdef-y are the files where unifdef will be run before installing files 5# to remove __KERNEL__ section of the file
6# objhdr-y are generated files that will be installed verbatim 6# unifdef-y - Same as header-y. Obsolete
7# objhdr-y - Same as header-y but for generated files
7# 8#
8# ========================================================================== 9# ==========================================================================
9 10
10UNIFDEF := scripts/unifdef -U__KERNEL__ 11# called may set destination dir (when installing to asm/)
11
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
17 -e "s/(__force[[:space:]]\{1,\}/ (/g" \
18 -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
19 -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
20 -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \
21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj)) 12_dst := $(if $(dst),$(dst),$(obj))
25 13
26ifeq (,$(patsubst include/asm/%,,$(obj)/)) 14kbuild-file := $(srctree)/$(obj)/Kbuild
27# For producing the generated stuff in include/asm for biarch builds, include 15include $(kbuild-file)
28# both sets of Kbuild files; we'll generate anything which is mentioned in
29# _either_ arch, and recurse into subdirectories which are mentioned in either
30# arch. Since some directories may exist in one but not the other, we must
31# use $(wildcard...).
32GENASM := 1
33archasm := $(subst include/asm,asm-$(ARCH),$(obj))
34altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
35KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild)
36else
37KBUILDFILES := $(srctree)/$(obj)/Kbuild
38endif
39 16
40include $(KBUILDFILES) 17include scripts/Kbuild.include
41 18
42include scripts/Kbuild.include 19install := $(INSTALL_HDR_PATH)/$(_dst)
43 20
44# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then 21header-y := $(sort $(header-y) $(unifdef-y))
45# override $(_dst) so that we install to include/asm directly. 22subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
46# Unless $(BIASMDIR) is set, in which case we're probably doing 23header-y := $(filter-out %/, $(header-y))
47# a 'headers_install_all' build and we should keep the -$(ARCH)
48# in the directory name.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR))
50 _dst := include/asm
51endif
52 24
53header-y := $(sort $(header-y)) 25# files used to track state of install/check
54unifdef-y := $(sort $(unifdef-y)) 26install-file := $(install)/.install
55subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) 27check-file := $(install)/.check
56header-y := $(filter-out %/, $(header-y))
57header-y := $(filter-out $(unifdef-y),$(header-y))
58 28
59# stamp files for header checks 29# all headers files for this dir
60check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) 30all-files := $(header-y) $(objhdr-y)
31input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
32 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
33output-files := $(addprefix $(install)/, $(all-files))
61 34
62# Work out what needs to be removed 35# Work out what needs to be removed
63oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) 36oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
64unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) 37unwanted := $(filter-out $(all-files),$(oldheaders))
65 38
66oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) 39# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
67unwanted += $(filter-out $(check-y),$(oldcheckstamps)) 40unwanted-file := $(addprefix $(install)/, $(unwanted))
68 41
69# Prefix them all with full paths to $(INSTALL_HDR_PATH) 42printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
70header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
71unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y))
72objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
73check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
74 43
44quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
45 file$(if $(word 2, $(all-files)),s))
46 cmd_install = \
47 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
48 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
49 touch $@
75 50
76ifdef ALTARCH 51quiet_cmd_remove = REMOVE $(unwanted)
77ifeq ($(obj),include/asm-$(ARCH)) 52 cmd_remove = rm -f $(unwanted-file)
78altarch-y := altarch-dir
79endif
80endif
81 53
82# Make the definitions visible for recursive make invocations 54quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
83export ALTARCH 55 cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
84export ARCHDEF 56 $(addprefix $(install)/, $(all-files)); \
85export ALTARCHDEF 57 touch $@
86
87quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
88 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \
89 $(INSTALL_HDR_PATH)/$(_dst)
90
91quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
92 cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
93 > $@
94
95quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
96 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
97 | $(HDRSED) > $@ || :
98
99quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
100 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
101 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
102
103quiet_cmd_remove = REMOVE $(_dst)/$@
104 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
105
106quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
107 cmd_mkdir = mkdir -p $@
108
109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
110 cmd_gen = \
111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \
112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \
113(echo "/* File autogenerated by 'make headers_install' */" ; \
114echo "\#ifndef $$STUBDEF" ; \
115echo "\#define $$STUBDEF" ; \
116echo "\# if $(ARCHDEF)" ; \
117if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \
118 echo "\# include <$(archasm)/$$FNAME>" ; \
119else \
120 echo "\# error $(archasm)/$$FNAME does not exist in" \
121 "the $(ARCH) architecture" ; \
122fi ; \
123echo "\# elif $(ALTARCHDEF)" ; \
124if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \
125 echo "\# include <$(altarchasm)/$$FNAME>" ; \
126else \
127 echo "\# error $(altarchasm)/$$FNAME does not exist in" \
128 "the $(ALTARCH) architecture" ; \
129fi ; \
130echo "\# else" ; \
131echo "\# warning This machine appears to be" \
132 "neither $(ARCH) nor $(ALTARCH)." ; \
133echo "\# endif" ; \
134echo "\#endif /* $$STUBDEF */" ; \
135) > $@
136
137.PHONY: __headersinst __headerscheck
138
139ifdef HDRCHECK
140__headerscheck: $(subdir-y) $(check-y)
141 @true
142
143$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
144 $(call cmd,check)
145
146# Other dependencies for $(check-y)
147include /dev/null $(wildcard $(check-y))
148
149# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
150.PHONY: $(check-y)
151 58
152else 59PHONY += __headersinst __headerscheck
153# Rules for installing headers
154__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
155 @true
156 60
157$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) 61ifndef HDRCHECK
158 62# Rules for installing headers
159$(INSTALL_HDR_PATH)/$(_dst): 63__headersinst: $(subdirs) $(install-file)
160 $(call cmd,mkdir) 64 @:
161
162.PHONY: $(unwanted)
163$(unwanted):
164 $(call cmd,remove)
165 65
166ifdef GENASM 66targets += $(install-file)
167$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) 67$(install-file): scripts/headers_install.pl $(input-files) FORCE
168 $(call cmd,gen) 68 $(if $(unwanted),$(call cmd,remove),)
69 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
70 $(call if_changed,install)
169 71
170else 72else
171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES) 73__headerscheck: $(subdirs) $(check-file)
172 $(call cmd,o_hdr_install) 74 @:
173 75
174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) 76targets += $(check-file)
175 $(call cmd,headers_install) 77$(check-file): scripts/headers_check.pl $(output-files) FORCE
78 $(call if_changed,check)
176 79
177$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
178 $(call cmd,unifdef)
179endif
180endif 80endif
181 81
182hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 82# Recursion
83hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
84.PHONY: $(subdirs)
85$(subdirs):
86 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
183 87
184.PHONY: altarch-dir 88targets := $(wildcard $(sort $(targets)))
185# All the files in the normal arch dir must be created first, since we test 89cmd_files := $(wildcard \
186# for their existence. 90 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
187altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y)
188 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
189 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR)
190 91
191# Recursion 92ifneq ($(cmd_files),)
192.PHONY: $(subdir-y) 93 include $(cmd_files)
193$(subdir-y): 94endif
194 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) 95
96.PHONY: $(PHONY)
97PHONY += FORCE
98FORCE: ;
diff --git a/scripts/diffconfig b/scripts/diffconfig
new file mode 100755
index 000000000000..b91f3e34d44d
--- /dev/null
+++ b/scripts/diffconfig
@@ -0,0 +1,129 @@
1#!/usr/bin/python
2#
3# diffconfig - a tool to compare .config files.
4#
5# originally written in 2006 by Matt Mackall
6# (at least, this was in his bloatwatch source code)
7# last worked on 2008 by Tim Bird
8#
9
10import sys, os
11
12def usage():
13 print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
14
15Diffconfig is a simple utility for comparing two .config files.
16Using standard diff to compare .config files often includes extraneous and
17distracting information. This utility produces sorted output with only the
18changes in configuration values between the two files.
19
20Added and removed items are shown with a leading plus or minus, respectively.
21Changed items show the old and new values on a single line.
22
23If -m is specified, then output will be in "merge" style, which has the
24changed and new values in kernel config option format.
25
26If no config files are specified, .config and .config.old are used.
27
28Example usage:
29 $ diffconfig .config config-with-some-changes
30-EXT2_FS_XATTR n
31-EXT2_FS_XIP n
32 CRAMFS n -> y
33 EXT2_FS y -> n
34 LOG_BUF_SHIFT 14 -> 16
35 PRINTK_TIME n -> y
36"""
37 sys.exit(0)
38
39# returns a dictionary of name/value pairs for config items in the file
40def readconfig(config_file):
41 d = {}
42 for line in config_file:
43 line = line[:-1]
44 if line[:7] == "CONFIG_":
45 name, val = line[7:].split("=", 1)
46 d[name] = val
47 if line[-11:] == " is not set":
48 d[line[9:-11]] = "n"
49 return d
50
51def print_config(op, config, value, new_value):
52 global merge_style
53
54 if merge_style:
55 if new_value:
56 if new_value=="n":
57 print "# CONFIG_%s is not set" % config
58 else:
59 print "CONFIG_%s=%s" % (config, new_value)
60 else:
61 if op=="-":
62 print "-%s %s" % (config, value)
63 elif op=="+":
64 print "+%s %s" % (config, new_value)
65 else:
66 print " %s %s -> %s" % (config, value, new_value)
67
68def main():
69 global merge_style
70
71 # parse command line args
72 if ("-h" in sys.argv or "--help" in sys.argv):
73 usage()
74
75 merge_style = 0
76 if "-m" in sys.argv:
77 merge_style = 1
78 sys.argv.remove("-m")
79
80 argc = len(sys.argv)
81 if not (argc==1 or argc == 3):
82 print "Error: incorrect number of arguments or unrecognized option"
83 usage()
84
85 if argc == 1:
86 # if no filenames given, assume .config and .config.old
87 build_dir=""
88 if os.environ.has_key("KBUILD_OUTPUT"):
89 build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90
91 configa_filename = build_dir + ".config.old"
92 configb_filename = build_dir + ".config"
93 else:
94 configa_filename = sys.argv[1]
95 configb_filename = sys.argv[2]
96
97 a = readconfig(file(configa_filename))
98 b = readconfig(file(configb_filename))
99
100 # print items in a but not b (accumulate, sort and print)
101 old = []
102 for config in a:
103 if config not in b:
104 old.append(config)
105 old.sort()
106 for config in old:
107 print_config("-", config, a[config], None)
108 del a[config]
109
110 # print items that changed (accumulate, sort, and print)
111 changed = []
112 for config in a:
113 if a[config] != b[config]:
114 changed.append(config)
115 else:
116 del b[config]
117 changed.sort()
118 for config in changed:
119 print_config("->", config, a[config], b[config])
120 del b[config]
121
122 # now print items in b but not in a
123 # (items from b that were in a were removed above)
124 new = b.keys()
125 new.sort()
126 for config in new:
127 print_config("+", config, None, b[config])
128
129main()
diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh
deleted file mode 100755
index 31598584f871..000000000000
--- a/scripts/hdrcheck.sh
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/sh
2
3for FILE in `grep '^[ \t]*#[ \t]*include[ \t]*<' $2 | cut -f2 -d\< | cut -f1 -d\> | egrep ^linux\|^asm` ; do
4 if [ ! -r $1/$FILE ]; then
5 echo $2 requires $FILE, which does not exist in exported headers
6 exit 1
7 fi
8done
9# FIXME: List dependencies into $3
10touch $3
diff --git a/scripts/headers.sh b/scripts/headers.sh
new file mode 100755
index 000000000000..d33426f866db
--- /dev/null
+++ b/scripts/headers.sh
@@ -0,0 +1,41 @@
1#!/bin/sh
2# Run headers_$1 command for all suitable architectures
3
4# Stop on error
5set -e
6
7do_command()
8{
9 if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
10 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
11 elif [ -f ${srctree}/include/asm-$2/Kbuild ]; then
12 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
13 else
14 printf "Ignoring arch: %s\n" ${arch}
15 fi
16}
17
18# Do not try this architecture
19drop="generic um ppc sparc64 cris"
20
21archs=$(ls ${srctree}/arch)
22
23for arch in ${archs}; do
24 case ${arch} in
25 um) # no userspace export
26 ;;
27 ppc) # headers exported by powerpc
28 ;;
29 sparc64) # headers exported by sparc
30 ;;
31 cris) # headers export are known broken
32 ;;
33 *)
34 if [ -d ${srctree}/arch/${arch} ]; then
35 do_command $1 ${arch}
36 fi
37 ;;
38 esac
39done
40
41
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
new file mode 100644
index 000000000000..15d53a6b1a1f
--- /dev/null
+++ b/scripts/headers_check.pl
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2#
3# headers_check.pl execute a number of trivial consistency checks
4#
5# Usage: headers_check.pl dir [files...]
6# dir: dir to look for included files
7# arch: architecture
8# files: list of files to check
9#
10# The script reads the supplied files line by line and:
11#
12# 1) for each include statement it checks if the
13# included file actually exists.
14# Only include files located in asm* and linux* are checked.
15# The rest are assumed to be system include files.
16#
17# 2) TODO: check for leaked CONFIG_ symbols
18
19use strict;
20use warnings;
21
22my ($dir, $arch, @files) = @ARGV;
23
24my $ret = 0;
25my $line;
26my $lineno = 0;
27my $filename;
28
29foreach my $file (@files) {
30 $filename = $file;
31 open(my $fh, '<', "$filename") or die "$filename: $!\n";
32 $lineno = 0;
33 while ($line = <$fh>) {
34 $lineno++;
35 check_include();
36 }
37 close $fh;
38}
39exit $ret;
40
41sub check_include
42{
43 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
44 my $inc = $1;
45 my $found;
46 $found = stat($dir . "/" . $inc);
47 if (!$found) {
48 $inc =~ s#asm/#asm-$arch/#;
49 $found = stat($dir . "/" . $inc);
50 }
51 if (!$found) {
52 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
53 $ret = 1;
54 }
55 }
56}
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
new file mode 100644
index 000000000000..68591cd08731
--- /dev/null
+++ b/scripts/headers_install.pl
@@ -0,0 +1,45 @@
1#!/usr/bin/perl
2#
3# headers_install prepare the listed header files for use in
4# user space and copy the files to their destination.
5#
6# Usage: headers_install.pl readdir installdir arch [files...]
7# readdir: dir to open files
8# installdir: dir to install the files
9# arch: current architecture
10# arch is used to force a reinstallation when the arch
11# changes because kbuild then detect a command line change.
12# files: list of files to check
13#
14# Step in preparation for users space:
15# 1) Drop all use of compiler.h definitions
16# 2) Drop include of compiler.h
17# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
18
19use strict;
20use warnings;
21
22my ($readdir, $installdir, $arch, @files) = @ARGV;
23
24my $unifdef = "scripts/unifdef -U__KERNEL__";
25
26foreach my $file (@files) {
27 my $tmpfile = "$installdir/$file.tmp";
28 open(my $infile, '<', "$readdir/$file")
29 or die "$readdir/$file: $!\n";
30 open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n";
31 while (my $line = <$infile>) {
32 $line =~ s/([\s(])__user\s/$1/g;
33 $line =~ s/([\s(])__force\s/$1/g;
34 $line =~ s/([\s(])__iomem\s/$1/g;
35 $line =~ s/\s__attribute_const__\s/ /g;
36 $line =~ s/\s__attribute_const__$//g;
37 $line =~ s/^#include <linux\/compiler.h>//;
38 printf $outfile "%s", $line;
39 }
40 close $outfile;
41 close $infile;
42 system $unifdef . " $tmpfile > $installdir/$file";
43 unlink $tmpfile;
44}
45exit 0;
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda63136ae68..9fba838c7069 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -76,7 +76,6 @@ static void check_stdin(void)
76static int conf_askvalue(struct symbol *sym, const char *def) 76static int conf_askvalue(struct symbol *sym, const char *def)
77{ 77{
78 enum symbol_type type = sym_get_type(sym); 78 enum symbol_type type = sym_get_type(sym);
79 tristate val;
80 79
81 if (!sym_has_value(sym)) 80 if (!sym_has_value(sym))
82 printf(_("(NEW) ")); 81 printf(_("(NEW) "));
@@ -92,15 +91,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
92 } 91 }
93 92
94 switch (input_mode) { 93 switch (input_mode) {
95 case set_no:
96 case set_mod:
97 case set_yes:
98 case set_random:
99 if (sym_has_value(sym)) {
100 printf("%s\n", def);
101 return 0;
102 }
103 break;
104 case ask_new: 94 case ask_new:
105 case ask_silent: 95 case ask_silent:
106 if (sym_has_value(sym)) { 96 if (sym_has_value(sym)) {
@@ -112,9 +102,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
112 fflush(stdout); 102 fflush(stdout);
113 fgets(line, 128, stdin); 103 fgets(line, 128, stdin);
114 return 1; 104 return 1;
115 case set_default:
116 printf("%s\n", def);
117 return 1;
118 default: 105 default:
119 break; 106 break;
120 } 107 }
@@ -128,52 +115,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
128 default: 115 default:
129 ; 116 ;
130 } 117 }
131 switch (input_mode) {
132 case set_yes:
133 if (sym_tristate_within_range(sym, yes)) {
134 line[0] = 'y';
135 line[1] = '\n';
136 line[2] = 0;
137 break;
138 }
139 case set_mod:
140 if (type == S_TRISTATE) {
141 if (sym_tristate_within_range(sym, mod)) {
142 line[0] = 'm';
143 line[1] = '\n';
144 line[2] = 0;
145 break;
146 }
147 } else {
148 if (sym_tristate_within_range(sym, yes)) {
149 line[0] = 'y';
150 line[1] = '\n';
151 line[2] = 0;
152 break;
153 }
154 }
155 case set_no:
156 if (sym_tristate_within_range(sym, no)) {
157 line[0] = 'n';
158 line[1] = '\n';
159 line[2] = 0;
160 break;
161 }
162 case set_random:
163 do {
164 val = (tristate)(rand() % 3);
165 } while (!sym_tristate_within_range(sym, val));
166 switch (val) {
167 case no: line[0] = 'n'; break;
168 case mod: line[0] = 'm'; break;
169 case yes: line[0] = 'y'; break;
170 }
171 line[1] = '\n';
172 line[2] = 0;
173 break;
174 default:
175 break;
176 }
177 printf("%s", line); 118 printf("%s", line);
178 return 1; 119 return 1;
179} 120}
@@ -374,15 +315,7 @@ static int conf_choice(struct menu *menu)
374 else 315 else
375 continue; 316 continue;
376 break; 317 break;
377 case set_random: 318 default:
378 if (is_new)
379 def = (rand() % cnt) + 1;
380 case set_default:
381 case set_yes:
382 case set_mod:
383 case set_no:
384 cnt = def;
385 printf("%d\n", cnt);
386 break; 319 break;
387 } 320 }
388 321
@@ -494,6 +427,43 @@ static void check_conf(struct menu *menu)
494 check_conf(child); 427 check_conf(child);
495} 428}
496 429
430static void conf_do_update(void)
431{
432 /* Update until a loop caused no more changes */
433 do {
434 conf_cnt = 0;
435 check_conf(&rootmenu);
436 } while (conf_cnt);
437}
438
439static int conf_silent_update(void)
440{
441 const char *name;
442
443 if (conf_get_changed()) {
444 name = getenv("KCONFIG_NOSILENTUPDATE");
445 if (name && *name) {
446 fprintf(stderr,
447 _("\n*** Kernel configuration requires explicit update.\n\n"));
448 return 1;
449 }
450 conf_do_update();
451 }
452 return 0;
453}
454
455static int conf_update(void)
456{
457 rootEntry = &rootmenu;
458 conf(&rootmenu);
459 if (input_mode == ask_all) {
460 input_mode = ask_silent;
461 valid_stdin = 1;
462 }
463 conf_do_update();
464 return 0;
465}
466
497int main(int ac, char **av) 467int main(int ac, char **av)
498{ 468{
499 int opt; 469 int opt;
@@ -599,36 +569,43 @@ int main(int ac, char **av)
599 default: 569 default:
600 break; 570 break;
601 } 571 }
572 switch (input_mode) {
573 case set_no:
574 conf_set_all_new_symbols(def_no);
575 break;
576 case set_yes:
577 conf_set_all_new_symbols(def_yes);
578 break;
579 case set_mod:
580 conf_set_all_new_symbols(def_mod);
581 break;
582 case set_random:
583 conf_set_all_new_symbols(def_random);
584 break;
585 case set_default:
586 conf_set_all_new_symbols(def_default);
587 break;
588 case ask_silent:
589 case ask_new:
590 if (conf_silent_update())
591 exit(1);
592 break;
593 case ask_all:
594 if (conf_update())
595 exit(1);
596 break;
597 }
602 598
603 if (input_mode != ask_silent) { 599 if (conf_get_changed() && conf_write(NULL)) {
604 rootEntry = &rootmenu;
605 conf(&rootmenu);
606 if (input_mode == ask_all) {
607 input_mode = ask_silent;
608 valid_stdin = 1;
609 }
610 } else if (conf_get_changed()) {
611 name = getenv("KCONFIG_NOSILENTUPDATE");
612 if (name && *name) {
613 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
614 return 1;
615 }
616 } else
617 goto skip_check;
618
619 do {
620 conf_cnt = 0;
621 check_conf(&rootmenu);
622 } while (conf_cnt);
623 if (conf_write(NULL)) {
624 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 600 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
625 return 1; 601 exit(1);
626 } 602 }
627skip_check: 603 /* ask_silent is used during the build so we shall update autoconf.
604 * All other commands are only used to generate a config.
605 */
628 if (input_mode == ask_silent && conf_write_autoconf()) { 606 if (input_mode == ask_silent && conf_write_autoconf()) {
629 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 607 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
630 return 1; 608 return 1;
631 } 609 }
632
633 return 0; 610 return 0;
634} 611}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ee5fe943d58d..07597611cc50 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void))
812{ 812{
813 conf_changed_callback = fn; 813 conf_changed_callback = fn;
814} 814}
815
816
817void conf_set_all_new_symbols(enum conf_def_mode mode)
818{
819 struct symbol *sym, *csym;
820 struct property *prop;
821 struct expr *e;
822 int i, cnt, def;
823
824 for_all_symbols(i, sym) {
825 if (sym_has_value(sym))
826 continue;
827 switch (sym_get_type(sym)) {
828 case S_BOOLEAN:
829 case S_TRISTATE:
830 switch (mode) {
831 case def_yes:
832 sym->def[S_DEF_USER].tri = yes;
833 break;
834 case def_mod:
835 sym->def[S_DEF_USER].tri = mod;
836 break;
837 case def_no:
838 sym->def[S_DEF_USER].tri = no;
839 break;
840 case def_random:
841 sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
842 break;
843 default:
844 continue;
845 }
846 if (!sym_is_choice(sym) || mode != def_random)
847 sym->flags |= SYMBOL_DEF_USER;
848 break;
849 default:
850 break;
851 }
852
853 }
854
855 if (modules_sym)
856 sym_calc_value(modules_sym);
857
858 if (mode != def_random)
859 return;
860
861 for_all_symbols(i, csym) {
862 if (sym_has_value(csym) || !sym_is_choice(csym))
863 continue;
864
865 sym_calc_value(csym);
866 prop = sym_get_choice_prop(csym);
867 def = -1;
868 while (1) {
869 cnt = 0;
870 expr_list_for_each_sym(prop->expr, e, sym) {
871 if (sym->visible == no)
872 continue;
873 if (def == cnt++) {
874 csym->def[S_DEF_USER].val = sym;
875 break;
876 }
877 }
878 if (def >= 0 || cnt < 2)
879 break;
880 def = (rand() % cnt) + 1;
881 }
882 csym->flags |= SYMBOL_DEF_USER;
883 }
884}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 96521cb087ec..4a9af6f7886b 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -42,6 +42,14 @@ extern "C" {
42#define TF_PARAM 0x0002 42#define TF_PARAM 0x0002
43#define TF_OPTION 0x0004 43#define TF_OPTION 0x0004
44 44
45enum conf_def_mode {
46 def_default,
47 def_yes,
48 def_mod,
49 def_no,
50 def_random
51};
52
45#define T_OPT_MODULES 1 53#define T_OPT_MODULES 1
46#define T_OPT_DEFCONFIG_LIST 2 54#define T_OPT_DEFCONFIG_LIST 2
47#define T_OPT_ENV 3 55#define T_OPT_ENV 3
@@ -69,6 +77,7 @@ const char *conf_get_configname(void);
69char *conf_get_default_confname(void); 77char *conf_get_default_confname(void);
70void sym_set_change_count(int count); 78void sym_set_change_count(int count);
71void sym_add_change_count(int count); 79void sym_add_change_count(int count);
80void conf_set_all_new_symbols(enum conf_def_mode mode);
72 81
73/* kconfig_load.c */ 82/* kconfig_load.c */
74void kconfig_load(void); 83void kconfig_load(void);
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 88e3934a8b8c..d8f77e26081c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1643,6 +1643,7 @@ sub dump_function($$) {
1643 $prototype =~ s/^__always_inline +//; 1643 $prototype =~ s/^__always_inline +//;
1644 $prototype =~ s/^noinline +//; 1644 $prototype =~ s/^noinline +//;
1645 $prototype =~ s/__devinit +//; 1645 $prototype =~ s/__devinit +//;
1646 $prototype =~ s/__init +//;
1646 $prototype =~ s/^#define\s+//; #ak added 1647 $prototype =~ s/^#define\s+//; #ak added
1647 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; 1648 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
1648 1649
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 1c1bdaf7348a..83b75126c9f7 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -12,7 +12,9 @@ cd "${1:-.}" || usage
12if head=`git rev-parse --verify HEAD 2>/dev/null`; then 12if head=`git rev-parse --verify HEAD 2>/dev/null`; then
13 # Do we have an untagged version? 13 # Do we have an untagged version?
14 if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then 14 if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
15 git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' 15 if tag=`git describe 2>/dev/null`; then
16 echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
17 fi
16 fi 18 fi
17 19
18 # Are there uncommitted changes? 20 # Are there uncommitted changes?
diff --git a/security/capability.c b/security/capability.c
index 5b01c0b02422..63d10da515a5 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -211,8 +211,7 @@ static int cap_inode_follow_link(struct dentry *dentry,
211 return 0; 211 return 0;
212} 212}
213 213
214static int cap_inode_permission(struct inode *inode, int mask, 214static int cap_inode_permission(struct inode *inode, int mask)
215 struct nameidata *nd)
216{ 215{
217 return 0; 216 return 0;
218} 217}
diff --git a/security/security.c b/security/security.c
index 59f23b5918b3..ff7068727757 100644
--- a/security/security.c
+++ b/security/security.c
@@ -429,11 +429,11 @@ int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
429 return security_ops->inode_follow_link(dentry, nd); 429 return security_ops->inode_follow_link(dentry, nd);
430} 430}
431 431
432int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd) 432int security_inode_permission(struct inode *inode, int mask)
433{ 433{
434 if (unlikely(IS_PRIVATE(inode))) 434 if (unlikely(IS_PRIVATE(inode)))
435 return 0; 435 return 0;
436 return security_ops->inode_permission(inode, mask, nd); 436 return security_ops->inode_permission(inode, mask);
437} 437}
438 438
439int security_inode_setattr(struct dentry *dentry, struct iattr *attr) 439int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
@@ -442,6 +442,7 @@ int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
442 return 0; 442 return 0;
443 return security_ops->inode_setattr(dentry, attr); 443 return security_ops->inode_setattr(dentry, attr);
444} 444}
445EXPORT_SYMBOL_GPL(security_inode_setattr);
445 446
446int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) 447int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
447{ 448{
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 63f131fc42e4..40d06c533f89 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -25,7 +25,7 @@
25 25
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/ptrace.h> 28#include <linux/tracehook.h>
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/security.h> 31#include <linux/security.h>
@@ -1971,22 +1971,6 @@ static int selinux_vm_enough_memory(struct mm_struct *mm, long pages)
1971 return __vm_enough_memory(mm, pages, cap_sys_admin); 1971 return __vm_enough_memory(mm, pages, cap_sys_admin);
1972} 1972}
1973 1973
1974/**
1975 * task_tracer_task - return the task that is tracing the given task
1976 * @task: task to consider
1977 *
1978 * Returns NULL if noone is tracing @task, or the &struct task_struct
1979 * pointer to its tracer.
1980 *
1981 * Must be called under rcu_read_lock().
1982 */
1983static struct task_struct *task_tracer_task(struct task_struct *task)
1984{
1985 if (task->ptrace & PT_PTRACED)
1986 return rcu_dereference(task->parent);
1987 return NULL;
1988}
1989
1990/* binprm security operations */ 1974/* binprm security operations */
1991 1975
1992static int selinux_bprm_alloc_security(struct linux_binprm *bprm) 1976static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
@@ -2238,7 +2222,7 @@ static void selinux_bprm_apply_creds(struct linux_binprm *bprm, int unsafe)
2238 u32 ptsid = 0; 2222 u32 ptsid = 0;
2239 2223
2240 rcu_read_lock(); 2224 rcu_read_lock();
2241 tracer = task_tracer_task(current); 2225 tracer = tracehook_tracer_task(current);
2242 if (likely(tracer != NULL)) { 2226 if (likely(tracer != NULL)) {
2243 sec = tracer->security; 2227 sec = tracer->security;
2244 ptsid = sec->sid; 2228 ptsid = sec->sid;
@@ -2640,12 +2624,11 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na
2640 return dentry_has_perm(current, NULL, dentry, FILE__READ); 2624 return dentry_has_perm(current, NULL, dentry, FILE__READ);
2641} 2625}
2642 2626
2643static int selinux_inode_permission(struct inode *inode, int mask, 2627static int selinux_inode_permission(struct inode *inode, int mask)
2644 struct nameidata *nd)
2645{ 2628{
2646 int rc; 2629 int rc;
2647 2630
2648 rc = secondary_ops->inode_permission(inode, mask, nd); 2631 rc = secondary_ops->inode_permission(inode, mask);
2649 if (rc) 2632 if (rc)
2650 return rc; 2633 return rc;
2651 2634
@@ -5247,7 +5230,7 @@ static int selinux_setprocattr(struct task_struct *p,
5247 Otherwise, leave SID unchanged and fail. */ 5230 Otherwise, leave SID unchanged and fail. */
5248 task_lock(p); 5231 task_lock(p);
5249 rcu_read_lock(); 5232 rcu_read_lock();
5250 tracer = task_tracer_task(p); 5233 tracer = tracehook_tracer_task(p);
5251 if (tracer != NULL) { 5234 if (tracer != NULL) {
5252 struct task_security_struct *ptsec = tracer->security; 5235 struct task_security_struct *ptsec = tracer->security;
5253 u32 ptsid = ptsec->sid; 5236 u32 ptsid = ptsec->sid;
@@ -5670,27 +5653,20 @@ static struct nf_hook_ops selinux_ipv6_ops[] = {
5670static int __init selinux_nf_ip_init(void) 5653static int __init selinux_nf_ip_init(void)
5671{ 5654{
5672 int err = 0; 5655 int err = 0;
5673 u32 iter;
5674 5656
5675 if (!selinux_enabled) 5657 if (!selinux_enabled)
5676 goto out; 5658 goto out;
5677 5659
5678 printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n"); 5660 printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n");
5679 5661
5680 for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++) { 5662 err = nf_register_hooks(selinux_ipv4_ops, ARRAY_SIZE(selinux_ipv4_ops));
5681 err = nf_register_hook(&selinux_ipv4_ops[iter]); 5663 if (err)
5682 if (err) 5664 panic("SELinux: nf_register_hooks for IPv4: error %d\n", err);
5683 panic("SELinux: nf_register_hook for IPv4: error %d\n",
5684 err);
5685 }
5686 5665
5687#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 5666#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
5688 for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++) { 5667 err = nf_register_hooks(selinux_ipv6_ops, ARRAY_SIZE(selinux_ipv6_ops));
5689 err = nf_register_hook(&selinux_ipv6_ops[iter]); 5668 if (err)
5690 if (err) 5669 panic("SELinux: nf_register_hooks for IPv6: error %d\n", err);
5691 panic("SELinux: nf_register_hook for IPv6: error %d\n",
5692 err);
5693 }
5694#endif /* IPV6 */ 5670#endif /* IPV6 */
5695 5671
5696out: 5672out:
@@ -5702,15 +5678,11 @@ __initcall(selinux_nf_ip_init);
5702#ifdef CONFIG_SECURITY_SELINUX_DISABLE 5678#ifdef CONFIG_SECURITY_SELINUX_DISABLE
5703static void selinux_nf_ip_exit(void) 5679static void selinux_nf_ip_exit(void)
5704{ 5680{
5705 u32 iter;
5706
5707 printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n"); 5681 printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n");
5708 5682
5709 for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++) 5683 nf_unregister_hooks(selinux_ipv4_ops, ARRAY_SIZE(selinux_ipv4_ops));
5710 nf_unregister_hook(&selinux_ipv4_ops[iter]);
5711#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 5684#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
5712 for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++) 5685 nf_unregister_hooks(selinux_ipv6_ops, ARRAY_SIZE(selinux_ipv6_ops));
5713 nf_unregister_hook(&selinux_ipv6_ops[iter]);
5714#endif /* IPV6 */ 5686#endif /* IPV6 */
5715} 5687}
5716#endif 5688#endif
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index ee5a51cbc5eb..1b40e558f983 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -522,8 +522,7 @@ static int smack_inode_rename(struct inode *old_inode,
522 * 522 *
523 * Returns 0 if access is permitted, -EACCES otherwise 523 * Returns 0 if access is permitted, -EACCES otherwise
524 */ 524 */
525static int smack_inode_permission(struct inode *inode, int mask, 525static int smack_inode_permission(struct inode *inode, int mask)
526 struct nameidata *nd)
527{ 526{
528 /* 527 /*
529 * No permission to check. Existence test. Yup, it's there. 528 * No permission to check. Existence test. Yup, it's there.
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 87e3aefeddc3..83e90057270e 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -189,9 +189,7 @@ void snd_tea575x_init(struct snd_tea575x *tea)
189 } 189 }
190 190
191 memset(&tea->vd, 0, sizeof(tea->vd)); 191 memset(&tea->vd, 0, sizeof(tea->vd));
192 tea->vd.owner = tea->card->module;
193 strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio"); 192 strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio");
194 tea->vd.type = VID_TYPE_TUNER;
195 tea->vd.release = snd_tea575x_release; 193 tea->vd.release = snd_tea575x_release;
196 video_set_drvdata(&tea->vd, tea); 194 video_set_drvdata(&tea->vd, tea);
197 tea->vd.fops = &tea->fops; 195 tea->vd.fops = &tea->fops;
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index dbe63db4bfd6..4d4b8ddc26ba 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -325,6 +325,7 @@ static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
325static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard, 325static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard,
326 struct pnp_dev *pdev) 326 struct pnp_dev *pdev)
327{ 327{
328 acard->wss = pdev;
328 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0) 329 if (snd_cs423x_pnp_init_wss(dev, acard->wss) < 0)
329 return -EBUSY; 330 return -EBUSY;
330 cport[dev] = -1; 331 cport[dev] = -1;
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 41c047e665ec..0797ca441a37 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -68,7 +68,9 @@ MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)},"
68static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 68static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
69static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 69static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
70//static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ 70//static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
71#ifdef CONFIG_PNP
71static int isapnp = 1; /* Enable ISA PnP detection */ 72static int isapnp = 1; /* Enable ISA PnP detection */
73#endif
72static long port = SNDRV_DEFAULT_PORT1; /* 0x530,0xe80,0xf40,0x604 */ 74static long port = SNDRV_DEFAULT_PORT1; /* 0x530,0xe80,0xf40,0x604 */
73static long mpu_port = SNDRV_DEFAULT_PORT1; /* 0x300,0x310,0x320,0x330 */ 75static long mpu_port = SNDRV_DEFAULT_PORT1; /* 0x300,0x310,0x320,0x330 */
74static long fm_port = SNDRV_DEFAULT_PORT1; /* 0x388 */ 76static long fm_port = SNDRV_DEFAULT_PORT1; /* 0x388 */
@@ -85,8 +87,10 @@ module_param(id, charp, 0444);
85MODULE_PARM_DESC(id, "ID string for opti9xx based soundcard."); 87MODULE_PARM_DESC(id, "ID string for opti9xx based soundcard.");
86//module_param(enable, bool, 0444); 88//module_param(enable, bool, 0444);
87//MODULE_PARM_DESC(enable, "Enable opti9xx soundcard."); 89//MODULE_PARM_DESC(enable, "Enable opti9xx soundcard.");
90#ifdef CONFIG_PNP
88module_param(isapnp, bool, 0444); 91module_param(isapnp, bool, 0444);
89MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); 92MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard.");
93#endif
90module_param(port, long, 0444); 94module_param(port, long, 0444);
91MODULE_PARM_DESC(port, "WSS port # for opti9xx driver."); 95MODULE_PARM_DESC(port, "WSS port # for opti9xx driver.");
92module_param(mpu_port, long, 0444); 96module_param(mpu_port, long, 0444);
@@ -688,7 +692,7 @@ static void snd_card_opti9xx_free(struct snd_card *card)
688 if (chip) { 692 if (chip) {
689#ifdef OPTi93X 693#ifdef OPTi93X
690 struct snd_cs4231 *codec = chip->codec; 694 struct snd_cs4231 *codec = chip->codec;
691 if (codec->irq > 0) { 695 if (codec && codec->irq > 0) {
692 disable_irq(codec->irq); 696 disable_irq(codec->irq);
693 free_irq(codec->irq, codec); 697 free_irq(codec->irq, codec);
694 } 698 }
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 07364c00768a..8c49a00a5e39 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -161,6 +161,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
161{ 0x50534304, 0xffffffff, "UCB1400", patch_ucb1400, NULL }, 161{ 0x50534304, 0xffffffff, "UCB1400", patch_ucb1400, NULL },
162{ 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH }, 162{ 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH },
163{ 0x54524102, 0xffffffff, "TR28022", NULL, NULL }, 163{ 0x54524102, 0xffffffff, "TR28022", NULL, NULL },
164{ 0x54524103, 0xffffffff, "TR28023", NULL, NULL },
164{ 0x54524106, 0xffffffff, "TR28026", NULL, NULL }, 165{ 0x54524106, 0xffffffff, "TR28026", NULL, NULL },
165{ 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99] 166{ 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99]
166{ 0x54524123, 0xffffffff, "TR28602", NULL, NULL }, // only guess --jk [TR28023 = eMicro EM28023 (new CT1297)] 167{ 0x54524123, 0xffffffff, "TR28602", NULL, NULL }, // only guess --jk [TR28023 = eMicro EM28023 (new CT1297)]
@@ -169,7 +170,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
169{ 0x56494170, 0xffffffff, "VIA1617A", patch_vt1617a, NULL }, // modified VT1616 with S/PDIF 170{ 0x56494170, 0xffffffff, "VIA1617A", patch_vt1617a, NULL }, // modified VT1616 with S/PDIF
170{ 0x56494182, 0xffffffff, "VIA1618", NULL, NULL }, 171{ 0x56494182, 0xffffffff, "VIA1618", NULL, NULL },
171{ 0x57454301, 0xffffffff, "W83971D", NULL, NULL }, 172{ 0x57454301, 0xffffffff, "W83971D", NULL, NULL },
172{ 0x574d4c00, 0xffffffff, "WM9701A", NULL, NULL }, 173{ 0x574d4c00, 0xffffffff, "WM9701,WM9701A", NULL, NULL },
173{ 0x574d4C03, 0xffffffff, "WM9703,WM9707,WM9708,WM9717", patch_wolfson03, NULL}, 174{ 0x574d4C03, 0xffffffff, "WM9703,WM9707,WM9708,WM9717", patch_wolfson03, NULL},
174{ 0x574d4C04, 0xffffffff, "WM9704M,WM9704Q", patch_wolfson04, NULL}, 175{ 0x574d4C04, 0xffffffff, "WM9704M,WM9704Q", patch_wolfson04, NULL},
175{ 0x574d4C05, 0xffffffff, "WM9705,WM9710", patch_wolfson05, NULL}, 176{ 0x574d4C05, 0xffffffff, "WM9705,WM9710", patch_wolfson05, NULL},
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 0746e9ccc20b..f4fbc795ee81 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -3381,8 +3381,8 @@ static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3381} 3381}
3382 3382
3383/* create a virtual master control and add slaves */ 3383/* create a virtual master control and add slaves */
3384int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name, 3384static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3385 const unsigned int *tlv, const char **slaves) 3385 const unsigned int *tlv, const char **slaves)
3386{ 3386{
3387 struct snd_kcontrol *kctl; 3387 struct snd_kcontrol *kctl;
3388 const char **s; 3388 const char **s;
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h
index 7e3e8942d073..974e05122f00 100644
--- a/sound/pci/azt3328.h
+++ b/sound/pci/azt3328.h
@@ -94,7 +94,7 @@ enum azf_freq_t {
94 AZF_FREQ(48000), 94 AZF_FREQ(48000),
95 AZF_FREQ(66200), 95 AZF_FREQ(66200),
96#undef AZF_FREQ 96#undef AZF_FREQ
97} AZF_FREQUENCIES; 97};
98 98
99/** recording area (see also: playback bit flag definitions) **/ 99/** recording area (see also: playback bit flag definitions) **/
100#define IDX_IO_REC_FLAGS 0x20 /* ??, PU:0x0000 */ 100#define IDX_IO_REC_FLAGS 0x20 /* ??, PU:0x0000 */
@@ -210,7 +210,7 @@ enum azf_freq_t {
210 210
211enum { 211enum {
212 AZF_GAME_LEGACY_IO_PORT = 0x200 212 AZF_GAME_LEGACY_IO_PORT = 0x200
213} AZF_GAME_CONFIGS; 213};
214 214
215#define IDX_GAME_LEGACY_COMPATIBLE 0x00 215#define IDX_GAME_LEGACY_COMPATIBLE 0x00
216 /* in some operation mode, writing anything to this port 216 /* in some operation mode, writing anything to this port
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index fbf1124f7c79..9bf95367c882 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -522,7 +522,7 @@ static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq)
522 return r; 522 return r;
523 cond_resched(); 523 cond_resched();
524 } 524 }
525 snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n", 525 snd_printk(KERN_ERR "wait src ready timeout 0x%lx [0x%x]\n",
526 ES_REG(ensoniq, 1371_SMPRATE), r); 526 ES_REG(ensoniq, 1371_SMPRATE), r);
527 return 0; 527 return 0;
528} 528}
@@ -1629,6 +1629,7 @@ static int __devinit snd_ensoniq_1371_mixer(struct ensoniq *ensoniq,
1629 memset(&ac97, 0, sizeof(ac97)); 1629 memset(&ac97, 0, sizeof(ac97));
1630 ac97.private_data = ensoniq; 1630 ac97.private_data = ensoniq;
1631 ac97.private_free = snd_ensoniq_mixer_free_ac97; 1631 ac97.private_free = snd_ensoniq_mixer_free_ac97;
1632 ac97.pci = ensoniq->pci;
1632 ac97.scaps = AC97_SCAP_AUDIO; 1633 ac97.scaps = AC97_SCAP_AUDIO;
1633 if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0) 1634 if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0)
1634 return err; 1635 return err;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 16715a68ba5e..ef9f072b47fc 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1047,9 +1047,13 @@ static int azx_setup_periods(struct azx *chip,
1047 pos_adj = bdl_pos_adj[chip->dev_index]; 1047 pos_adj = bdl_pos_adj[chip->dev_index];
1048 if (pos_adj > 0) { 1048 if (pos_adj > 0) {
1049 struct snd_pcm_runtime *runtime = substream->runtime; 1049 struct snd_pcm_runtime *runtime = substream->runtime;
1050 int pos_align = pos_adj;
1050 pos_adj = (pos_adj * runtime->rate + 47999) / 48000; 1051 pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
1051 if (!pos_adj) 1052 if (!pos_adj)
1052 pos_adj = 1; 1053 pos_adj = pos_align;
1054 else
1055 pos_adj = ((pos_adj + pos_align - 1) / pos_align) *
1056 pos_align;
1053 pos_adj = frames_to_bytes(runtime, pos_adj); 1057 pos_adj = frames_to_bytes(runtime, pos_adj);
1054 if (pos_adj >= period_bytes) { 1058 if (pos_adj >= period_bytes) {
1055 snd_printk(KERN_WARNING "Too big adjustment %d\n", 1059 snd_printk(KERN_WARNING "Too big adjustment %d\n",
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 2807bc840d26..add4e87e0b20 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -122,6 +122,8 @@ enum {
122/* ALC269 models */ 122/* ALC269 models */
123enum { 123enum {
124 ALC269_BASIC, 124 ALC269_BASIC,
125 ALC269_ASUS_EEEPC_P703,
126 ALC269_ASUS_EEEPC_P901,
125 ALC269_AUTO, 127 ALC269_AUTO,
126 ALC269_MODEL_LAST /* last tag */ 128 ALC269_MODEL_LAST /* last tag */
127}; 129};
@@ -7905,6 +7907,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7905 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), 7907 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7906 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), 7908 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7907 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), 7909 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7910 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
7908 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 7911 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7909 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 7912 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7910 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 7913 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
@@ -10946,7 +10949,23 @@ static int patch_alc268(struct hda_codec *codec)
10946 10949
10947static hda_nid_t alc269_adc_nids[1] = { 10950static hda_nid_t alc269_adc_nids[1] = {
10948 /* ADC1 */ 10951 /* ADC1 */
10949 0x07, 10952 0x08,
10953};
10954
10955static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
10956 .num_items = 2,
10957 .items = {
10958 { "i-Mic", 0x5 },
10959 { "e-Mic", 0x0 },
10960 },
10961};
10962
10963static struct hda_input_mux alc269_eeepc_amic_capture_source = {
10964 .num_items = 2,
10965 .items = {
10966 { "i-Mic", 0x1 },
10967 { "e-Mic", 0x0 },
10968 },
10950}; 10969};
10951 10970
10952#define alc269_modes alc260_modes 10971#define alc269_modes alc260_modes
@@ -10968,10 +10987,27 @@ static struct snd_kcontrol_new alc269_base_mixer[] = {
10968 { } /* end */ 10987 { } /* end */
10969}; 10988};
10970 10989
10990/* bind volumes of both NID 0x0c and 0x0d */
10991static struct hda_bind_ctls alc269_epc_bind_vol = {
10992 .ops = &snd_hda_bind_vol,
10993 .values = {
10994 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10995 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10996 0
10997 },
10998};
10999
11000static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11001 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11002 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11003 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11004 { } /* end */
11005};
11006
10971/* capture mixer elements */ 11007/* capture mixer elements */
10972static struct snd_kcontrol_new alc269_capture_mixer[] = { 11008static struct snd_kcontrol_new alc269_capture_mixer[] = {
10973 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 11009 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10974 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 11010 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10975 { 11011 {
10976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10977 /* The multiple "Capture Source" controls confuse alsamixer 11013 /* The multiple "Capture Source" controls confuse alsamixer
@@ -10987,6 +11023,13 @@ static struct snd_kcontrol_new alc269_capture_mixer[] = {
10987 { } /* end */ 11023 { } /* end */
10988}; 11024};
10989 11025
11026/* capture mixer elements */
11027static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11030 { } /* end */
11031};
11032
10990/* 11033/*
10991 * generic initialization of ADC, input mixers and output mixers 11034 * generic initialization of ADC, input mixers and output mixers
10992 */ 11035 */
@@ -10994,7 +11037,7 @@ static struct hda_verb alc269_init_verbs[] = {
10994 /* 11037 /*
10995 * Unmute ADC0 and set the default input to mic-in 11038 * Unmute ADC0 and set the default input to mic-in
10996 */ 11039 */
10997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10998 11041
10999 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the 11042 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11000 * analog-loopback mixer widget 11043 * analog-loopback mixer widget
@@ -11057,6 +11100,98 @@ static struct hda_verb alc269_init_verbs[] = {
11057 { } 11100 { }
11058}; 11101};
11059 11102
11103static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11104 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11105 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11108 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11111 {}
11112};
11113
11114static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11116 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11117 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11119 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11120 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11121 {}
11122};
11123
11124/* toggle speaker-output according to the hp-jack state */
11125static void alc269_speaker_automute(struct hda_codec *codec)
11126{
11127 unsigned int present;
11128 unsigned int bits;
11129
11130 present = snd_hda_codec_read(codec, 0x15, 0,
11131 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11132 bits = present ? AMP_IN_MUTE(0) : 0;
11133 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11134 AMP_IN_MUTE(0), bits);
11135 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11136 AMP_IN_MUTE(0), bits);
11137}
11138
11139static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11140{
11141 unsigned int present;
11142
11143 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11144 & AC_PINSENSE_PRESENCE;
11145 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11146 present ? 0 : 5);
11147}
11148
11149static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11150{
11151 unsigned int present;
11152
11153 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11154 & AC_PINSENSE_PRESENCE;
11155 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11156 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11157 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11158 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11159}
11160
11161/* unsolicited event for HP jack sensing */
11162static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11163 unsigned int res)
11164{
11165 if ((res >> 26) == ALC880_HP_EVENT)
11166 alc269_speaker_automute(codec);
11167
11168 if ((res >> 26) == ALC880_MIC_EVENT)
11169 alc269_eeepc_dmic_automute(codec);
11170}
11171
11172static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11173{
11174 alc269_speaker_automute(codec);
11175 alc269_eeepc_dmic_automute(codec);
11176}
11177
11178/* unsolicited event for HP jack sensing */
11179static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11180 unsigned int res)
11181{
11182 if ((res >> 26) == ALC880_HP_EVENT)
11183 alc269_speaker_automute(codec);
11184
11185 if ((res >> 26) == ALC880_MIC_EVENT)
11186 alc269_eeepc_amic_automute(codec);
11187}
11188
11189static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11190{
11191 alc269_speaker_automute(codec);
11192 alc269_eeepc_amic_automute(codec);
11193}
11194
11060/* add playback controls from the parsed DAC table */ 11195/* add playback controls from the parsed DAC table */
11061static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, 11196static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11062 const struct auto_pin_cfg *cfg) 11197 const struct auto_pin_cfg *cfg)
@@ -11188,6 +11323,9 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
11188 if (err < 0) 11323 if (err < 0)
11189 return err; 11324 return err;
11190 11325
11326 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11327 spec->num_mixers++;
11328
11191 return 1; 11329 return 1;
11192} 11330}
11193 11331
@@ -11215,12 +11353,16 @@ static const char *alc269_models[ALC269_MODEL_LAST] = {
11215}; 11353};
11216 11354
11217static struct snd_pci_quirk alc269_cfg_tbl[] = { 11355static struct snd_pci_quirk alc269_cfg_tbl[] = {
11356 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11357 ALC269_ASUS_EEEPC_P703),
11358 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11359 ALC269_ASUS_EEEPC_P901),
11218 {} 11360 {}
11219}; 11361};
11220 11362
11221static struct alc_config_preset alc269_presets[] = { 11363static struct alc_config_preset alc269_presets[] = {
11222 [ALC269_BASIC] = { 11364 [ALC269_BASIC] = {
11223 .mixers = { alc269_base_mixer }, 11365 .mixers = { alc269_base_mixer, alc269_capture_mixer },
11224 .init_verbs = { alc269_init_verbs }, 11366 .init_verbs = { alc269_init_verbs },
11225 .num_dacs = ARRAY_SIZE(alc269_dac_nids), 11367 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11226 .dac_nids = alc269_dac_nids, 11368 .dac_nids = alc269_dac_nids,
@@ -11229,6 +11371,32 @@ static struct alc_config_preset alc269_presets[] = {
11229 .channel_mode = alc269_modes, 11371 .channel_mode = alc269_modes,
11230 .input_mux = &alc269_capture_source, 11372 .input_mux = &alc269_capture_source,
11231 }, 11373 },
11374 [ALC269_ASUS_EEEPC_P703] = {
11375 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11376 .init_verbs = { alc269_init_verbs,
11377 alc269_eeepc_amic_init_verbs },
11378 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11379 .dac_nids = alc269_dac_nids,
11380 .hp_nid = 0x03,
11381 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11382 .channel_mode = alc269_modes,
11383 .input_mux = &alc269_eeepc_amic_capture_source,
11384 .unsol_event = alc269_eeepc_amic_unsol_event,
11385 .init_hook = alc269_eeepc_amic_inithook,
11386 },
11387 [ALC269_ASUS_EEEPC_P901] = {
11388 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11389 .init_verbs = { alc269_init_verbs,
11390 alc269_eeepc_dmic_init_verbs },
11391 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11392 .dac_nids = alc269_dac_nids,
11393 .hp_nid = 0x03,
11394 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11395 .channel_mode = alc269_modes,
11396 .input_mux = &alc269_eeepc_dmic_capture_source,
11397 .unsol_event = alc269_eeepc_dmic_unsol_event,
11398 .init_hook = alc269_eeepc_dmic_inithook,
11399 },
11232}; 11400};
11233 11401
11234static int patch_alc269(struct hda_codec *codec) 11402static int patch_alc269(struct hda_codec *codec)
@@ -11282,8 +11450,6 @@ static int patch_alc269(struct hda_codec *codec)
11282 11450
11283 spec->adc_nids = alc269_adc_nids; 11451 spec->adc_nids = alc269_adc_nids;
11284 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 11452 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11285 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11286 spec->num_mixers++;
11287 11453
11288 codec->patch_ops = alc_patch_ops; 11454 codec->patch_ops = alc_patch_ops;
11289 if (board_config == ALC269_AUTO) 11455 if (board_config == ALC269_AUTO)
@@ -12994,6 +13160,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12994 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), 13160 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12995 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), 13161 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12996 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 13162 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
13163 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
12997 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), 13164 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12998 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 13165 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12999 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 13166 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 08cb77f51880..7fdafcb0015d 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -94,6 +94,9 @@ enum {
94 STAC_INTEL_MAC_V3, 94 STAC_INTEL_MAC_V3,
95 STAC_INTEL_MAC_V4, 95 STAC_INTEL_MAC_V4,
96 STAC_INTEL_MAC_V5, 96 STAC_INTEL_MAC_V5,
97 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
98 * is given, one of the above models will be
99 * chosen according to the subsystem id. */
97 /* for backward compatibility */ 100 /* for backward compatibility */
98 STAC_MACMINI, 101 STAC_MACMINI,
99 STAC_MACBOOK, 102 STAC_MACBOOK,
@@ -1483,6 +1486,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1483 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, 1486 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1484 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, 1487 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1485 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, 1488 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1489 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1486 /* for backward compatibility */ 1490 /* for backward compatibility */
1487 [STAC_MACMINI] = intel_mac_v3_pin_configs, 1491 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1488 [STAC_MACBOOK] = intel_mac_v5_pin_configs, 1492 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
@@ -1505,6 +1509,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
1505 [STAC_INTEL_MAC_V3] = "intel-mac-v3", 1509 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1506 [STAC_INTEL_MAC_V4] = "intel-mac-v4", 1510 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1507 [STAC_INTEL_MAC_V5] = "intel-mac-v5", 1511 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1512 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1508 /* for backward compatibility */ 1513 /* for backward compatibility */
1509 [STAC_MACMINI] = "macmini", 1514 [STAC_MACMINI] = "macmini",
1510 [STAC_MACBOOK] = "macbook", 1515 [STAC_MACBOOK] = "macbook",
@@ -1576,9 +1581,9 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, 1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1577 "Intel D945P", STAC_D945GTP5), 1582 "Intel D945P", STAC_D945GTP5),
1578 /* other systems */ 1583 /* other systems */
1579 /* Apple Mac Mini (early 2006) */ 1584 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1580 SND_PCI_QUIRK(0x8384, 0x7680, 1585 SND_PCI_QUIRK(0x8384, 0x7680,
1581 "Mac Mini", STAC_INTEL_MAC_V3), 1586 "Mac", STAC_INTEL_MAC_AUTO),
1582 /* Dell systems */ 1587 /* Dell systems */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, 1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1584 "unknown Dell", STAC_922X_DELL_D81), 1589 "unknown Dell", STAC_922X_DELL_D81),
@@ -3725,7 +3730,7 @@ static int patch_stac922x(struct hda_codec *codec)
3725 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, 3730 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3726 stac922x_models, 3731 stac922x_models,
3727 stac922x_cfg_tbl); 3732 stac922x_cfg_tbl);
3728 if (spec->board_config == STAC_INTEL_MAC_V3) { 3733 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
3729 spec->gpio_mask = spec->gpio_dir = 0x03; 3734 spec->gpio_mask = spec->gpio_dir = 0x03;
3730 spec->gpio_data = 0x03; 3735 spec->gpio_data = 0x03;
3731 /* Intel Macs have all same PCI SSID, so we need to check 3736 /* Intel Macs have all same PCI SSID, so we need to check
@@ -3757,6 +3762,9 @@ static int patch_stac922x(struct hda_codec *codec)
3757 case 0x106b2200: 3762 case 0x106b2200:
3758 spec->board_config = STAC_INTEL_MAC_V5; 3763 spec->board_config = STAC_INTEL_MAC_V5;
3759 break; 3764 break;
3765 default:
3766 spec->board_config = STAC_INTEL_MAC_V3;
3767 break;
3760 } 3768 }
3761 } 3769 }
3762 3770
diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c
index ba4b5c199f21..9384702c7ebd 100644
--- a/sound/soc/au1x/psc-i2s.c
+++ b/sound/soc/au1x/psc-i2s.c
@@ -231,7 +231,7 @@ static int au1xpsc_i2s_stop(struct au1xpsc_audio_data *pscdata, int stype)
231 231
232 /* if both TX and RX are idle, disable PSC */ 232 /* if both TX and RX are idle, disable PSC */
233 stat = au_readl(I2S_STAT(pscdata)); 233 stat = au_readl(I2S_STAT(pscdata));
234 if (!(stat & (PSC_I2SSTAT_RB | PSC_I2SSTAT_RB))) { 234 if (!(stat & (PSC_I2SSTAT_TB | PSC_I2SSTAT_RB))) {
235 au_writel(0, I2S_CFG(pscdata)); 235 au_writel(0, I2S_CFG(pscdata));
236 au_sync(); 236 au_sync();
237 au_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata)); 237 au_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata));
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 9fc8edd82225..1fb7f9a7aecd 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -427,20 +427,20 @@ static const struct snd_soc_dapm_route audio_map[] = {
427 {"HPOUTR", NULL, "Headphone PGA"}, 427 {"HPOUTR", NULL, "Headphone PGA"},
428 {"Headphone PGA", NULL, "Right HP Mixer"}, 428 {"Headphone PGA", NULL, "Right HP Mixer"},
429 429
430 /* mono hp mixer */ 430 /* mono mixer */
431 {"Mono HP Mixer", NULL, "Left HP Mixer"}, 431 {"Mono Mixer", NULL, "Left HP Mixer"},
432 {"Mono HP Mixer", NULL, "Right HP Mixer"}, 432 {"Mono Mixer", NULL, "Right HP Mixer"},
433 433
434 /* Out3 Mux */ 434 /* Out3 Mux */
435 {"Out3 Mux", "Left", "Left HP Mixer"}, 435 {"Out3 Mux", "Left", "Left HP Mixer"},
436 {"Out3 Mux", "Mono", "Phone Mixer"}, 436 {"Out3 Mux", "Mono", "Phone Mixer"},
437 {"Out3 Mux", "Left + Right", "Mono HP Mixer"}, 437 {"Out3 Mux", "Left + Right", "Mono Mixer"},
438 {"Out 3 PGA", NULL, "Out3 Mux"}, 438 {"Out 3 PGA", NULL, "Out3 Mux"},
439 {"OUT3", NULL, "Out 3 PGA"}, 439 {"OUT3", NULL, "Out 3 PGA"},
440 440
441 /* speaker Mux */ 441 /* speaker Mux */
442 {"Speaker Mux", "Speaker Mix", "Speaker Mixer"}, 442 {"Speaker Mux", "Speaker Mix", "Speaker Mixer"},
443 {"Speaker Mux", "Headphone Mix", "Mono HP Mixer"}, 443 {"Speaker Mux", "Headphone Mix", "Mono Mixer"},
444 {"Speaker PGA", NULL, "Speaker Mux"}, 444 {"Speaker PGA", NULL, "Speaker Mux"},
445 {"LOUT2", NULL, "Speaker PGA"}, 445 {"LOUT2", NULL, "Speaker PGA"},
446 {"ROUT2", NULL, "Speaker PGA"}, 446 {"ROUT2", NULL, "Speaker PGA"},
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2c87061c2a6b..820347c9ae4b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -523,24 +523,6 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
523 continue; 523 continue;
524 } 524 }
525 525
526 /* programmable gain/attenuation */
527 if (w->id == snd_soc_dapm_pga) {
528 int on;
529 in = is_connected_input_ep(w);
530 dapm_clear_walk(w->codec);
531 out = is_connected_output_ep(w);
532 dapm_clear_walk(w->codec);
533 w->power = on = (out != 0 && in != 0) ? 1 : 0;
534
535 if (!on)
536 dapm_set_pga(w, on); /* lower volume to reduce pops */
537 dapm_update_bits(w);
538 if (on)
539 dapm_set_pga(w, on); /* restore volume from zero */
540
541 continue;
542 }
543
544 /* pre and post event widgets */ 526 /* pre and post event widgets */
545 if (w->id == snd_soc_dapm_pre) { 527 if (w->id == snd_soc_dapm_pre) {
546 if (!w->event) 528 if (!w->event)
@@ -586,45 +568,56 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
586 power_change = (w->power == power) ? 0: 1; 568 power_change = (w->power == power) ? 0: 1;
587 w->power = power; 569 w->power = power;
588 570
571 if (!power_change)
572 continue;
573
589 /* call any power change event handlers */ 574 /* call any power change event handlers */
590 if (power_change) { 575 if (w->event)
591 if (w->event) { 576 pr_debug("power %s event for %s flags %x\n",
592 pr_debug("power %s event for %s flags %x\n", 577 w->power ? "on" : "off",
593 w->power ? "on" : "off", w->name, w->event_flags); 578 w->name, w->event_flags);
594 if (power) { 579
595 /* power up event */ 580 /* power up pre event */
596 if (w->event_flags & SND_SOC_DAPM_PRE_PMU) { 581 if (power && w->event &&
597 ret = w->event(w, 582 (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
598 NULL, SND_SOC_DAPM_PRE_PMU); 583 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
599 if (ret < 0) 584 if (ret < 0)
600 return ret; 585 return ret;
601 } 586 }
602 dapm_update_bits(w); 587
603 if (w->event_flags & SND_SOC_DAPM_POST_PMU){ 588 /* power down pre event */
604 ret = w->event(w, 589 if (!power && w->event &&
605 NULL, SND_SOC_DAPM_POST_PMU); 590 (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
606 if (ret < 0) 591 ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
607 return ret; 592 if (ret < 0)
608 } 593 return ret;
609 } else { 594 }
610 /* power down event */ 595
611 if (w->event_flags & SND_SOC_DAPM_PRE_PMD) { 596 /* Lower PGA volume to reduce pops */
612 ret = w->event(w, 597 if (w->id == snd_soc_dapm_pga && !power)
613 NULL, SND_SOC_DAPM_PRE_PMD); 598 dapm_set_pga(w, power);
614 if (ret < 0) 599
615 return ret; 600 dapm_update_bits(w);
616 } 601
617 dapm_update_bits(w); 602 /* Raise PGA volume to reduce pops */
618 if (w->event_flags & SND_SOC_DAPM_POST_PMD) { 603 if (w->id == snd_soc_dapm_pga && power)
619 ret = w->event(w, 604 dapm_set_pga(w, power);
620 NULL, SND_SOC_DAPM_POST_PMD); 605
621 if (ret < 0) 606 /* power up post event */
622 return ret; 607 if (power && w->event &&
623 } 608 (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
624 } 609 ret = w->event(w,
625 } else 610 NULL, SND_SOC_DAPM_POST_PMU);
626 /* no event handler */ 611 if (ret < 0)
627 dapm_update_bits(w); 612 return ret;
613 }
614
615 /* power down post event */
616 if (!power && w->event &&
617 (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
618 ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
619 if (ret < 0)
620 return ret;
628 } 621 }
629 } 622 }
630 } 623 }