aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power46
-rw-r--r--Documentation/devicetree/bindings/dma/fsl-edma.txt76
-rw-r--r--Documentation/devicetree/bindings/dma/qcom_bam_dma.txt41
-rw-r--r--Documentation/devicetree/bindings/dma/sirfsoc-dma.txt43
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-at91.txt2
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-cadence.txt24
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-designware.txt8
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-efm32.txt34
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt20
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-rcar.txt14
-rw-r--r--Documentation/devicetree/bindings/i2c/qcom,i2c-qup.txt40
-rw-r--r--Documentation/devicetree/bindings/leds/leds-gpio.txt12
-rw-r--r--Documentation/devicetree/bindings/mfd/mc13xxx.txt47
-rw-r--r--Documentation/devicetree/bindings/mmc/mmc.txt9
-rw-r--r--Documentation/devicetree/bindings/mmc/sdhci-msm.txt55
-rw-r--r--Documentation/devicetree/bindings/mmc/sdhci-pxa.txt17
-rw-r--r--Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt1
-rw-r--r--Documentation/devicetree/bindings/regulator/pbias-regulator.txt27
-rw-r--r--Documentation/devicetree/bindings/sound/fsl,ssi.txt21
-rw-r--r--Documentation/devicetree/bindings/spi/efm32-spi.txt8
-rw-r--r--Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt16
-rw-r--r--Documentation/dontdiff3
-rw-r--r--Documentation/filesystems/Locking2
-rw-r--r--Documentation/filesystems/vfs.txt2
-rw-r--r--Documentation/i2c/busses/i2c-i8011
-rw-r--r--Documentation/i2c/functionality2
-rw-r--r--Documentation/i2c/i2c-protocol35
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--MAINTAINERS7
-rw-r--r--Makefile37
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/boot/dts/atlas6.dtsi2
-rw-r--r--arch/arm/boot/dts/dra7.dtsi17
-rw-r--r--arch/arm/boot/dts/omap2430.dtsi17
-rw-r--r--arch/arm/boot/dts/omap3-ldp.dts23
-rw-r--r--arch/arm/boot/dts/omap3.dtsi17
-rw-r--r--arch/arm/boot/dts/omap4.dtsi17
-rw-r--r--arch/arm/boot/dts/omap5.dtsi17
-rw-r--r--arch/arm/boot/dts/prima2.dtsi2
-rw-r--r--arch/arm/configs/omap2plus_defconfig2
-rw-r--r--arch/arm/include/asm/assembler.h42
-rw-r--r--arch/arm/include/asm/cputype.h19
-rw-r--r--arch/arm/include/asm/syscall.h5
-rw-r--r--arch/arm/kernel/crash_dump.c2
-rw-r--r--arch/arm/kernel/entry-header.S11
-rw-r--r--arch/arm/kernel/kprobes-common.c4
-rw-r--r--arch/arm/kernel/kprobes-test-arm.c603
-rw-r--r--arch/arm/kernel/kprobes-test-thumb.c447
-rw-r--r--arch/arm/kernel/kprobes-test.c13
-rw-r--r--arch/arm/kernel/kprobes-test.h2
-rw-r--r--arch/arm/kernel/kprobes-thumb.c20
-rw-r--r--arch/arm/kernel/kprobes.c9
-rw-r--r--arch/arm/kernel/pj4-cp0.c4
-rw-r--r--arch/arm/kernel/probes.c15
-rw-r--r--arch/arm/kernel/process.c3
-rw-r--r--arch/arm/kernel/traps.c1
-rw-r--r--arch/arm/mach-vexpress/dcscb.c13
-rw-r--r--arch/arm/mm/dump.c47
-rw-r--r--arch/arm/vfp/entry.S25
-rw-r--r--arch/arm/vfp/vfphw.S19
-rw-r--r--arch/blackfin/Kconfig12
-rw-r--r--arch/blackfin/include/asm/bfin_crc.h125
-rw-r--r--arch/blackfin/include/asm/bfin_twi.h143
-rw-r--r--arch/blackfin/include/asm/dma.h2
-rw-r--r--arch/blackfin/include/asm/portmux.h10
-rw-r--r--arch/blackfin/kernel/debug-mmrs.c1
-rw-r--r--arch/blackfin/kernel/irqchip.c39
-rw-r--r--arch/blackfin/mach-bf518/boards/ezbrd.c87
-rw-r--r--arch/blackfin/mach-bf518/boards/tcm-bf518.c64
-rw-r--r--arch/blackfin/mach-bf527/boards/ad7160eval.c71
-rw-r--r--arch/blackfin/mach-bf527/boards/cm_bf527.c91
-rw-r--r--arch/blackfin/mach-bf527/boards/ezbrd.c76
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c139
-rw-r--r--arch/blackfin/mach-bf527/boards/tll6527m.c91
-rw-r--r--arch/blackfin/mach-bf533/boards/H8606.c46
-rw-r--r--arch/blackfin/mach-bf533/boards/blackstamp.c44
-rw-r--r--arch/blackfin/mach-bf533/boards/cm_bf533.c54
-rw-r--r--arch/blackfin/mach-bf533/boards/ezkit.c56
-rw-r--r--arch/blackfin/mach-bf533/boards/ip0x.c26
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c118
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537e.c82
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537u.c70
-rw-r--r--arch/blackfin/mach-bf537/boards/dnp5370.c32
-rw-r--r--arch/blackfin/mach-bf537/boards/minotaur.c50
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c55
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c425
-rw-r--r--arch/blackfin/mach-bf537/boards/tcm_bf537.c70
-rw-r--r--arch/blackfin/mach-bf538/boards/ezkit.c62
-rw-r--r--arch/blackfin/mach-bf548/boards/cm_bf548.c78
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c136
-rw-r--r--arch/blackfin/mach-bf548/include/mach/defBF544.h30
-rw-r--r--arch/blackfin/mach-bf548/include/mach/defBF547.h30
-rw-r--r--arch/blackfin/mach-bf561/boards/acvilon.c28
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c56
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c74
-rw-r--r--arch/blackfin/mach-bf561/boards/tepla.c8
-rw-r--r--arch/blackfin/mach-bf609/boards/ezkit.c131
-rw-r--r--arch/blackfin/mach-bf609/clock.c18
-rw-r--r--arch/blackfin/mach-bf609/pm.c2
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/microblaze/Kconfig54
-rw-r--r--arch/microblaze/Kconfig.platform (renamed from arch/microblaze/platform/Kconfig.platform)55
-rw-r--r--arch/microblaze/Makefile1
-rw-r--r--[l---------]arch/microblaze/boot/dts/system.dts367
-rw-r--r--arch/microblaze/include/asm/io.h302
-rw-r--r--arch/microblaze/include/asm/processor.h2
-rw-r--r--arch/microblaze/include/asm/setup.h6
-rw-r--r--arch/microblaze/include/uapi/asm/unistd.h6
-rw-r--r--arch/microblaze/kernel/Makefile2
-rw-r--r--arch/microblaze/kernel/heartbeat.c4
-rw-r--r--arch/microblaze/kernel/intc.c51
-rw-r--r--arch/microblaze/kernel/platform.c (renamed from arch/microblaze/platform/platform.c)0
-rw-r--r--arch/microblaze/kernel/process.c1
-rw-r--r--arch/microblaze/kernel/signal.c2
-rw-r--r--arch/microblaze/kernel/syscall_table.S8
-rw-r--r--arch/microblaze/kernel/timer.c66
-rw-r--r--arch/microblaze/mm/consistent.c2
-rw-r--r--arch/microblaze/mm/init.c2
-rw-r--r--arch/microblaze/mm/pgtable.c5
-rw-r--r--arch/microblaze/platform/Makefile6
-rw-r--r--arch/microblaze/platform/generic/Kconfig.auto61
-rw-r--r--arch/microblaze/platform/generic/Makefile3
-rw-r--r--arch/microblaze/platform/generic/system.dts366
-rw-r--r--arch/mips/include/asm/syscall.h7
-rw-r--r--arch/mips/kernel/ptrace.c2
-rw-r--r--arch/mips/loongson/lemote-2f/clock.c20
-rw-r--r--arch/mn10300/include/asm/highmem.h4
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/Makefile1
-rw-r--r--arch/powerpc/configs/ppc6xx_defconfig1
-rw-r--r--arch/powerpc/configs/ps3_defconfig1
-rw-r--r--arch/powerpc/configs/pseries_defconfig1
-rw-r--r--arch/powerpc/configs/pseries_le_defconfig1
-rw-r--r--arch/powerpc/include/asm/emulated_ops.h1
-rw-r--r--arch/powerpc/include/asm/opal.h19
-rw-r--r--arch/powerpc/include/asm/reg.h4
-rw-r--r--arch/powerpc/include/asm/rtas.h127
-rw-r--r--arch/powerpc/kernel/align.c52
-rw-r--r--arch/powerpc/kernel/cpu_setup_power.S2
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S8
-rw-r--r--arch/powerpc/kernel/paca.c3
-rw-r--r--arch/powerpc/kernel/process.c34
-rw-r--r--arch/powerpc/kernel/prom.c58
-rw-r--r--arch/powerpc/kernel/rtas.c15
-rw-r--r--arch/powerpc/kernel/rtasd.c24
-rw-r--r--arch/powerpc/kernel/setup-common.c3
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c29
-rw-r--r--arch/powerpc/kernel/signal_32.c2
-rw-r--r--arch/powerpc/kernel/signal_64.c2
-rw-r--r--arch/powerpc/kernel/tm.S2
-rw-r--r--arch/powerpc/kernel/traps.c1
-rw-r--r--arch/powerpc/math-emu/mtfsf.c58
-rw-r--r--arch/powerpc/mm/gup.c13
-rw-r--r--arch/powerpc/mm/numa.c15
-rw-r--r--arch/powerpc/platforms/cell/spu_syscalls.c2
-rw-r--r--arch/powerpc/platforms/powernv/Kconfig6
-rw-r--r--arch/powerpc/platforms/powernv/Makefile1
-rw-r--r--arch/powerpc/platforms/powernv/opal-async.c7
-rw-r--r--arch/powerpc/platforms/powernv/opal-dump.c9
-rw-r--r--arch/powerpc/platforms/powernv/opal-elog.c9
-rw-r--r--arch/powerpc/platforms/powernv/opal-msglog.c120
-rw-r--r--arch/powerpc/platforms/powernv/opal-sensor.c6
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c4
-rw-r--r--arch/powerpc/platforms/powernv/opal-wrappers.S1
-rw-r--r--arch/powerpc/platforms/powernv/opal.c59
-rw-r--r--arch/powerpc/platforms/pseries/io_event_irq.c6
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c11
-rw-r--r--arch/powerpc/platforms/pseries/ras.c17
-rw-r--r--arch/powerpc/sysdev/msi_bitmap.c2
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/configs/default_defconfig1
-rw-r--r--arch/s390/include/asm/syscall.h7
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/configs/rsk7203_defconfig1
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/um/Kconfig.common1
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/Makefile2
-rw-r--r--arch/x86/boot/compressed/eboot.c19
-rw-r--r--arch/x86/boot/compressed/head_32.S8
-rw-r--r--arch/x86/boot/compressed/head_64.S9
-rw-r--r--arch/x86/include/asm/syscall.h10
-rw-r--r--arch/x86/kernel/acpi/cstate.c4
-rw-r--r--arch/x86/kernel/apic/apic.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c18
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_intel.c19
-rw-r--r--arch/x86/kernel/early-quirks.c211
-rw-r--r--arch/x86/kernel/irq.c2
-rw-r--r--arch/x86/kernel/ldt.c11
-rw-r--r--arch/x86/kernel/pci-calgary_64.c31
-rw-r--r--arch/x86/mm/kmemcheck/kmemcheck.c8
-rw-r--r--arch/xtensa/configs/iss_defconfig1
-rw-r--r--arch/xtensa/configs/s6105_defconfig1
-rw-r--r--block/blk-core.c2
-rw-r--r--block/blk-map.c2
-rw-r--r--block/blk-mq.c8
-rw-r--r--block/blk-softirq.c17
-rw-r--r--block/blk.h2
-rw-r--r--block/elevator.c2
-rw-r--r--drivers/acpi/Kconfig8
-rw-r--r--drivers/acpi/dock.c6
-rw-r--r--drivers/acpi/osl.c3
-rw-r--r--drivers/acpi/thermal.c2
-rw-r--r--drivers/acpi/utils.c3
-rw-r--r--drivers/acpi/video.c8
-rw-r--r--drivers/base/power/domain.c13
-rw-r--r--drivers/base/regmap/regmap.c3
-rw-r--r--drivers/block/drbd/drbd_receiver.c12
-rw-r--r--drivers/block/loop.c8
-rw-r--r--drivers/block/nbd.c48
-rw-r--r--drivers/block/nvme-core.c684
-rw-r--r--drivers/block/nvme-scsi.c43
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/virtio_console.c4
-rw-r--r--drivers/cpufreq/Kconfig.arm6
-rw-r--r--drivers/cpufreq/Kconfig.powerpc8
-rw-r--r--drivers/cpufreq/Makefile1
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c2
-rw-r--r--drivers/cpufreq/at32ap-cpufreq.c2
-rw-r--r--drivers/cpufreq/cris-artpec3-cpufreq.c6
-rw-r--r--drivers/cpufreq/cris-etraxfs-cpufreq.c6
-rw-r--r--drivers/cpufreq/elanfreq.c18
-rw-r--r--drivers/cpufreq/exynos4210-cpufreq.c12
-rw-r--r--drivers/cpufreq/exynos4x12-cpufreq.c30
-rw-r--r--drivers/cpufreq/exynos5250-cpufreq.c34
-rw-r--r--drivers/cpufreq/freq_table.c11
-rw-r--r--drivers/cpufreq/ia64-acpi-cpufreq.c3
-rw-r--r--drivers/cpufreq/kirkwood-cpufreq.c6
-rw-r--r--drivers/cpufreq/longhaul.c2
-rw-r--r--drivers/cpufreq/loongson2_cpufreq.c2
-rw-r--r--drivers/cpufreq/maple-cpufreq.c6
-rw-r--r--drivers/cpufreq/p4-clockmod.c20
-rw-r--r--drivers/cpufreq/pasemi-cpufreq.c12
-rw-r--r--drivers/cpufreq/pmac32-cpufreq.c6
-rw-r--r--drivers/cpufreq/pmac64-cpufreq.c6
-rw-r--r--drivers/cpufreq/powernow-k6.c18
-rw-r--r--drivers/cpufreq/powernow-k8.c5
-rw-r--r--drivers/cpufreq/powernv-cpufreq.c341
-rw-r--r--drivers/cpufreq/ppc-corenet-cpufreq.c1
-rw-r--r--drivers/cpufreq/ppc_cbe_cpufreq.c18
-rw-r--r--drivers/cpufreq/s3c2416-cpufreq.c20
-rw-r--r--drivers/cpufreq/s3c24xx-cpufreq.c4
-rw-r--r--drivers/cpufreq/s3c64xx-cpufreq.c26
-rw-r--r--drivers/cpufreq/s5pv210-cpufreq.c12
-rw-r--r--drivers/cpufreq/sc520_freq.c6
-rw-r--r--drivers/cpufreq/spear-cpufreq.c7
-rw-r--r--drivers/cpufreq/speedstep-ich.c6
-rw-r--r--drivers/cpufreq/speedstep-smi.c6
-rw-r--r--drivers/cpufreq/unicore2-cpufreq.c2
-rw-r--r--drivers/cpuidle/sysfs.c3
-rw-r--r--drivers/dma/Kconfig21
-rw-r--r--drivers/dma/Makefile2
-rw-r--r--drivers/dma/acpi-dma.c17
-rw-r--r--drivers/dma/at_hdmac.c1
-rw-r--r--drivers/dma/cppi41.c7
-rw-r--r--drivers/dma/dmaengine.c9
-rw-r--r--drivers/dma/dmatest.c4
-rw-r--r--drivers/dma/dw/core.c21
-rw-r--r--drivers/dma/dw/pci.c36
-rw-r--r--drivers/dma/dw/regs.h4
-rw-r--r--drivers/dma/edma.c5
-rw-r--r--drivers/dma/fsl-edma.c975
-rw-r--r--drivers/dma/imx-dma.c13
-rw-r--r--drivers/dma/mmp_pdma.c8
-rw-r--r--drivers/dma/mmp_tdma.c50
-rw-r--r--drivers/dma/omap-dma.c18
-rw-r--r--drivers/dma/pch_dma.c4
-rw-r--r--drivers/dma/qcom_bam_dma.c1111
-rw-r--r--drivers/dma/s3c24xx-dma.c2
-rw-r--r--drivers/dma/sh/Kconfig6
-rw-r--r--drivers/dma/sh/Makefile1
-rw-r--r--drivers/dma/sh/rcar-audmapp.c320
-rw-r--r--drivers/dma/sh/shdma-base.c10
-rw-r--r--drivers/dma/sh/shdma-of.c3
-rw-r--r--drivers/dma/sh/shdmac.c13
-rw-r--r--drivers/dma/sh/sudmac.c4
-rw-r--r--drivers/dma/sirf-dma.c23
-rw-r--r--drivers/firmware/efi/efi-stub-helper.c6
-rw-r--r--drivers/hwmon/Kconfig8
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/ibmpowernv.c529
-rw-r--r--drivers/i2c/busses/Kconfig27
-rw-r--r--drivers/i2c/busses/Makefile3
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c2
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756.c2
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c2
-rw-r--r--drivers/i2c/busses/i2c-at91.c12
-rw-r--r--drivers/i2c/busses/i2c-bcm2835.c26
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c20
-rw-r--r--drivers/i2c/busses/i2c-cadence.c905
-rw-r--r--drivers/i2c/busses/i2c-davinci.c2
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c27
-rw-r--r--drivers/i2c/busses/i2c-designware-core.h2
-rw-r--r--drivers/i2c/busses/i2c-designware-pcidrv.c125
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c9
-rw-r--r--drivers/i2c/busses/i2c-efm32.c481
-rw-r--r--drivers/i2c/busses/i2c-eg20t.c2
-rw-r--r--drivers/i2c/busses/i2c-exynos5.c4
-rw-r--r--drivers/i2c/busses/i2c-gpio.c3
-rw-r--r--drivers/i2c/busses/i2c-hydra.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c5
-rw-r--r--drivers/i2c/busses/i2c-ismt.c2
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c83
-rw-r--r--drivers/i2c/busses/i2c-mxs.c18
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c2
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c253
-rw-r--r--drivers/i2c/busses/i2c-ocores.c2
-rw-r--r--drivers/i2c/busses/i2c-omap.c8
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c2
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-pxa-pci.c2
-rw-r--r--drivers/i2c/busses/i2c-qup.c768
-rw-r--r--drivers/i2c/busses/i2c-rcar.c3
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c39
-rw-r--r--drivers/i2c/busses/i2c-sirf.c2
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/busses/i2c-sis630.c2
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/i2c/busses/i2c-st.c2
-rw-r--r--drivers/i2c/busses/i2c-stu300.c2
-rw-r--r--drivers/i2c/busses/i2c-tegra.c2
-rw-r--r--drivers/i2c/busses/i2c-via.c2
-rw-r--r--drivers/i2c/busses/i2c-viapro.c2
-rw-r--r--drivers/i2c/busses/i2c-xiic.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c2
-rw-r--r--drivers/i2c/i2c-core.c67
-rw-r--r--drivers/idle/intel_idle.c204
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c828
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.h38
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c27
-rw-r--r--drivers/leds/Kconfig4
-rw-r--r--drivers/leds/led-core.c6
-rw-r--r--drivers/leds/led-triggers.c6
-rw-r--r--drivers/leds/leds-88pm860x.c1
-rw-r--r--drivers/leds/leds-adp5520.c1
-rw-r--r--drivers/leds/leds-asic3.c1
-rw-r--r--drivers/leds/leds-blinkm.c3
-rw-r--r--drivers/leds/leds-clevo-mail.c5
-rw-r--r--drivers/leds/leds-cobalt-qube.c1
-rw-r--r--drivers/leds/leds-da903x.c1
-rw-r--r--drivers/leds/leds-da9052.c1
-rw-r--r--drivers/leds/leds-fsg.c1
-rw-r--r--drivers/leds/leds-gpio.c6
-rw-r--r--drivers/leds/leds-hp6xx.c1
-rw-r--r--drivers/leds/leds-lm3533.c1
-rw-r--r--drivers/leds/leds-lp5521.c1
-rw-r--r--drivers/leds/leds-lp5523.c1
-rw-r--r--drivers/leds/leds-lp5562.c7
-rw-r--r--drivers/leds/leds-lt3593.c1
-rw-r--r--drivers/leds/leds-mc13783.c223
-rw-r--r--drivers/leds/leds-netxbig.c1
-rw-r--r--drivers/leds/leds-ns2.c1
-rw-r--r--drivers/leds/leds-ot200.c1
-rw-r--r--drivers/leds/leds-pwm.c24
-rw-r--r--drivers/leds/leds-s3c24xx.c1
-rw-r--r--drivers/leds/leds-ss4200.c4
-rw-r--r--drivers/leds/leds-wm831x-status.c1
-rw-r--r--drivers/leds/leds-wm8350.c1
-rw-r--r--drivers/leds/trigger/ledtrig-cpu.c24
-rw-r--r--drivers/md/bitmap.c1
-rw-r--r--drivers/md/md.c65
-rw-r--r--drivers/md/md.h1
-rw-r--r--drivers/md/raid1.c17
-rw-r--r--drivers/md/raid5.c28
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/Kconfig2
-rw-r--r--drivers/media/dvb-frontends/lgdt3305.c1
-rw-r--r--drivers/media/dvb-frontends/m88rs2000.c8
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c45
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.c15
-rw-r--r--drivers/media/rc/img-ir/img-ir-nec.c27
-rw-r--r--drivers/media/rc/ir-nec-decoder.c5
-rw-r--r--drivers/media/rc/keymaps/rc-tivo.c86
-rw-r--r--drivers/media/rc/rc-main.c98
-rw-r--r--drivers/media/tuners/r820t.c3
-rw-r--r--drivers/media/tuners/tuner-xc2028.c1
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c2
-rw-r--r--drivers/media/usb/gspca/jpeg.h4
-rw-r--r--drivers/media/usb/stk1160/stk1160-ac97.c2
-rw-r--r--drivers/mfd/rtsx_pcr.c132
-rw-r--r--drivers/mmc/card/block.c181
-rw-r--r--drivers/mmc/core/Kconfig15
-rw-r--r--drivers/mmc/core/bus.c12
-rw-r--r--drivers/mmc/core/core.c87
-rw-r--r--drivers/mmc/core/host.c18
-rw-r--r--drivers/mmc/core/mmc.c65
-rw-r--r--drivers/mmc/core/mmc_ops.c64
-rw-r--r--drivers/mmc/core/sd.c23
-rw-r--r--drivers/mmc/core/slot-gpio.c180
-rw-r--r--drivers/mmc/host/Kconfig23
-rw-r--r--drivers/mmc/host/Makefile2
-rw-r--r--drivers/mmc/host/davinci_mmc.c4
-rw-r--r--drivers/mmc/host/dw_mmc-k3.c2
-rw-r--r--drivers/mmc/host/dw_mmc-pltfm.c12
-rw-r--r--drivers/mmc/host/dw_mmc-socfpga.c138
-rw-r--r--drivers/mmc/host/dw_mmc.c2
-rw-r--r--drivers/mmc/host/dw_mmc.h3
-rw-r--r--drivers/mmc/host/mmci.c54
-rw-r--r--drivers/mmc/host/mmci.h2
-rw-r--r--drivers/mmc/host/omap.c93
-rw-r--r--drivers/mmc/host/omap_hsmmc.c242
-rw-r--r--drivers/mmc/host/rtsx_pci_sdmmc.c529
-rw-r--r--drivers/mmc/host/sdhci-acpi.c80
-rw-r--r--drivers/mmc/host/sdhci-bcm-kona.c39
-rw-r--r--drivers/mmc/host/sdhci-dove.c2
-rw-r--r--drivers/mmc/host/sdhci-msm.c618
-rw-r--r--drivers/mmc/host/sdhci-pci.c20
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c68
-rw-r--r--drivers/mmc/host/sdhci-s3c.c170
-rw-r--r--drivers/mmc/host/sdhci-spear.c199
-rw-r--r--drivers/mmc/host/sdhci.c24
-rw-r--r--drivers/mmc/host/sh_mobile_sdhi.c50
-rw-r--r--drivers/mmc/host/tmio_mmc.c30
-rw-r--r--drivers/mmc/host/tmio_mmc.h7
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c7
-rw-r--r--drivers/mmc/host/ushc.c2
-rw-r--r--drivers/mmc/host/wmt-sdmmc.c4
-rw-r--r--drivers/net/bonding/bond_main.c1
-rw-r--r--drivers/net/ethernet/8390/apne.c4
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c30
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_hw.c124
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c11
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c10
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.c10
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c20
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h16
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c13
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c14
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c16
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c10
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c28
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c20
-rw-r--r--drivers/net/ethernet/ti/cpsw.c17
-rw-r--r--drivers/net/hyperv/hyperv_net.h1
-rw-r--r--drivers/net/hyperv/netvsc.c2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c30
-rw-r--r--drivers/net/hyperv/rndis_filter.c12
-rw-r--r--drivers/net/ntb_netdev.c27
-rw-r--r--drivers/net/phy/phy.c6
-rw-r--r--drivers/net/usb/r8152.c48
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c2
-rw-r--r--drivers/net/wireless/b43/phy_n.c14
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_core.c6
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_debugfs.c35
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_mgmt.c8
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_sdio.c5
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_sdio_ops.c6
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_usb.c26
-rw-r--r--drivers/net/wireless/rtlwifi/btcoexist/halbtcoutsrc.c10
-rw-r--r--drivers/net/xen-netfront.c2
-rw-r--r--drivers/ntb/ntb_hw.c192
-rw-r--r--drivers/ntb/ntb_hw.h8
-rw-r--r--drivers/ntb/ntb_transport.c20
-rw-r--r--drivers/platform/x86/Kconfig22
-rw-r--r--drivers/platform/x86/Makefile2
-rw-r--r--drivers/platform/x86/alienware-wmi.c565
-rw-r--r--drivers/platform/x86/fujitsu-tablet.c65
-rw-r--r--drivers/platform/x86/intel_baytrail.c224
-rw-r--r--drivers/platform/x86/intel_baytrail.h90
-rw-r--r--drivers/platform/x86/panasonic-laptop.c11
-rw-r--r--drivers/platform/x86/sony-laptop.c539
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c227
-rw-r--r--drivers/platform/x86/toshiba_acpi.c635
-rw-r--r--drivers/regulator/Kconfig9
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/bcm590xx-regulator.c1
-rw-r--r--drivers/regulator/pbias-regulator.c255
-rw-r--r--drivers/regulator/s2mpa01.c12
-rw-r--r--drivers/regulator/s2mps11.c12
-rw-r--r--drivers/regulator/s5m8767.c1
-rw-r--r--drivers/remoteproc/da8xx_remoteproc.c16
-rw-r--r--drivers/remoteproc/ste_modem_rproc.c4
-rw-r--r--drivers/scsi/Kconfig3
-rw-r--r--drivers/scsi/iscsi_tcp.c2
-rw-r--r--drivers/scsi/iscsi_tcp.h2
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c18
-rw-r--r--drivers/scsi/scsi.c9
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/scsi_pm.c128
-rw-r--r--drivers/scsi/scsi_priv.h2
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/sd.c1
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c4
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/spi/spi-fsl-espi.c3
-rw-r--r--drivers/spi/spi-fsl-spi.c3
-rw-r--r--drivers/spi/spi-mpc512x-psc.c3
-rw-r--r--drivers/spi/spi-mpc52xx-psc.c3
-rw-r--r--drivers/spi/spi-mpc52xx.c6
-rw-r--r--drivers/spi/spi-omap2-mcspi.c26
-rw-r--r--drivers/spi/spi-sh.c6
-rw-r--r--drivers/spi/spi-txx9.c3
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c64
-rw-r--r--drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c24
-rw-r--r--drivers/staging/lustre/lustre/llite/symlink.c23
-rw-r--r--drivers/staging/media/msi3101/msi001.c2
-rw-r--r--drivers/staging/media/msi3101/sdr-msi3101.c15
-rw-r--r--drivers/staging/usbip/stub_dev.c8
-rw-r--r--drivers/staging/usbip/usbip_common.c25
-rw-r--r--drivers/staging/usbip/usbip_common.h1
-rw-r--r--drivers/staging/usbip/vhci_hcd.c4
-rw-r--r--drivers/staging/usbip/vhci_sysfs.c6
-rw-r--r--drivers/target/iscsi/iscsi_target.c33
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c14
-rw-r--r--drivers/target/iscsi/iscsi_target_core.h7
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_nego.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_tpg.c21
-rw-r--r--drivers/target/iscsi/iscsi_target_tpg.h1
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_util.h1
-rw-r--r--drivers/target/loopback/tcm_loop.c12
-rw-r--r--drivers/target/sbp/sbp_target.c8
-rw-r--r--drivers/target/target_core_alua.c95
-rw-r--r--drivers/target/target_core_configfs.c4
-rw-r--r--drivers/target/target_core_file.c40
-rw-r--r--drivers/target/target_core_iblock.c5
-rw-r--r--drivers/target/target_core_rd.c14
-rw-r--r--drivers/target/target_core_sbc.c178
-rw-r--r--drivers/target/target_core_spc.c49
-rw-r--r--drivers/target/target_core_tmr.c23
-rw-r--r--drivers/target/target_core_transport.c92
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h13
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c5
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c76
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c10
-rw-r--r--drivers/thermal/imx_thermal.c39
-rw-r--r--drivers/thermal/rcar_thermal.c9
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-bandgap.c6
-rw-r--r--drivers/tty/hvc/hvc_opal.c22
-rw-r--r--drivers/tty/tty_audit.c3
-rw-r--r--drivers/usb/gadget/tcm_usb_gadget.c8
-rw-r--r--drivers/vhost/net.c14
-rw-r--r--drivers/vhost/scsi.c9
-rw-r--r--drivers/video/backlight/backlight.c2
-rw-r--r--drivers/video/backlight/gpio_backlight.c58
-rw-r--r--drivers/video/backlight/lm3639_bl.c17
-rw-r--r--fs/aio.c120
-rw-r--r--fs/autofs4/dev-ioctl.c3
-rw-r--r--fs/bio-integrity.c22
-rw-r--r--fs/bio.c10
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/btrfs/async-thread.c2
-rw-r--r--fs/btrfs/backref.c33
-rw-r--r--fs/btrfs/ctree.c94
-rw-r--r--fs/btrfs/ctree.h13
-rw-r--r--fs/btrfs/disk-io.c23
-rw-r--r--fs/btrfs/extent-tree.c35
-rw-r--r--fs/btrfs/extent_io.c8
-rw-r--r--fs/btrfs/extent_io.h1
-rw-r--r--fs/btrfs/file.c21
-rw-r--r--fs/btrfs/inode-map.c14
-rw-r--r--fs/btrfs/inode.c36
-rw-r--r--fs/btrfs/ioctl.c35
-rw-r--r--fs/btrfs/relocation.c21
-rw-r--r--fs/btrfs/scrub.c108
-rw-r--r--fs/btrfs/send.c117
-rw-r--r--fs/btrfs/super.c22
-rw-r--r--fs/btrfs/transaction.c48
-rw-r--r--fs/btrfs/transaction.h3
-rw-r--r--fs/btrfs/volumes.c35
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cachefiles/bind.c1
-rw-r--r--fs/cachefiles/namei.c3
-rw-r--r--fs/ceph/file.c12
-rw-r--r--fs/ceph/ioctl.c3
-rw-r--r--fs/cifs/cifsfs.c1
-rw-r--r--fs/cifs/file.c128
-rw-r--r--fs/dlm/lowcomms.c2
-rw-r--r--fs/exec.c2
-rw-r--r--fs/exofs/ore_raid.c4
-rw-r--r--fs/exofs/super.c2
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/file.c11
-rw-r--r--fs/file_table.c43
-rw-r--r--fs/fuse/dev.c14
-rw-r--r--fs/fuse/file.c5
-rw-r--r--fs/lockd/svc.c1
-rw-r--r--fs/mount.h5
-rw-r--r--fs/namei.c67
-rw-r--r--fs/namespace.c56
-rw-r--r--fs/ncpfs/dir.c69
-rw-r--r--fs/ncpfs/file.c24
-rw-r--r--fs/ncpfs/getopt.c12
-rw-r--r--fs/ncpfs/inode.c82
-rw-r--r--fs/ncpfs/ioctl.c17
-rw-r--r--fs/ncpfs/mmap.c2
-rw-r--r--fs/ncpfs/ncp_fs.h30
-rw-r--r--fs/ncpfs/ncp_fs_sb.h6
-rw-r--r--fs/ncpfs/ncplib_kernel.c28
-rw-r--r--fs/ncpfs/sock.c53
-rw-r--r--fs/ncpfs/symlink.c2
-rw-r--r--fs/nfsd/acl.h10
-rw-r--r--fs/nfsd/nfs4acl.c13
-rw-r--r--fs/nfsd/nfs4callback.c19
-rw-r--r--fs/nfsd/nfs4proc.c39
-rw-r--r--fs/nfsd/nfs4state.c28
-rw-r--r--fs/nfsd/nfs4xdr.c30
-rw-r--r--fs/nfsd/nfsctl.c5
-rw-r--r--fs/nfsd/nfsd.h2
-rw-r--r--fs/nfsd/nfsfh.h14
-rw-r--r--fs/nfsd/nfsxdr.c2
-rw-r--r--fs/nfsd/vfs.c15
-rw-r--r--fs/nfsd/xdr4.h2
-rw-r--r--fs/ntfs/inode.c2
-rw-r--r--fs/ocfs2/cluster/tcp.c64
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h2
-rw-r--r--fs/ocfs2/file.c9
-rw-r--r--fs/open.c68
-rw-r--r--fs/pipe.c133
-rw-r--r--fs/pnode.c198
-rw-r--r--fs/pnode.h3
-rw-r--r--fs/proc/base.c36
-rw-r--r--fs/proc/namespaces.c14
-rw-r--r--fs/proc/self.c2
-rw-r--r--fs/proc_namespace.c1
-rw-r--r--fs/splice.c126
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/xfs/xfs_file.c13
-rw-r--r--fs/xfs/xfs_ioctl.c28
-rw-r--r--include/asm-generic/cmpxchg-local.h3
-rw-r--r--include/asm-generic/syscall.h4
-rw-r--r--include/drm/i915_drm.h20
-rw-r--r--include/linux/acpi_dma.h5
-rw-r--r--include/linux/audit.h14
-rw-r--r--include/linux/bio.h11
-rw-r--r--include/linux/blk_types.h2
-rw-r--r--include/linux/blkdev.h17
-rw-r--r--include/linux/buffer_head.h4
-rw-r--r--include/linux/compiler-clang.h12
-rw-r--r--include/linux/compiler.h7
-rw-r--r--include/linux/cpufreq.h9
-rw-r--r--include/linux/dmaengine.h14
-rw-r--r--include/linux/dw_dmac.h5
-rw-r--r--include/linux/fdtable.h2
-rw-r--r--include/linux/fs.h97
-rw-r--r--include/linux/ftrace_event.h22
-rw-r--r--include/linux/i2c.h1
-rw-r--r--include/linux/i2c/bfin_twi.h145
-rw-r--r--include/linux/mfd/mc13xxx.h6
-rw-r--r--include/linux/mfd/rtsx_common.h1
-rw-r--r--include/linux/mfd/rtsx_pci.h8
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/mmc/core.h4
-rw-r--r--include/linux/mmc/host.h13
-rw-r--r--include/linux/mmc/sdhci-spear.h8
-rw-r--r--include/linux/mmc/sdhci.h2
-rw-r--r--include/linux/mmc/slot-gpio.h6
-rw-r--r--include/linux/mod_devicetable.h5
-rw-r--r--include/linux/mount.h3
-rw-r--r--include/linux/nbd.h3
-rw-r--r--include/linux/ntb.h19
-rw-r--r--include/linux/nvme.h21
-rw-r--r--include/linux/pipe_fs_i.h19
-rw-r--r--include/linux/platform_data/dma-rcar-audmapp.h34
-rw-r--r--include/linux/platform_data/i2c-s3c2410.h9
-rw-r--r--include/linux/platform_data/leds-s3c24xx.h9
-rw-r--r--include/linux/platform_data/mmc-msm_sdcc.h7
-rw-r--r--include/linux/platform_data/mmc-mvsdio.h6
-rw-r--r--include/linux/sched.h20
-rw-r--r--include/linux/sunrpc/clnt.h2
-rw-r--r--include/linux/sunrpc/svcsock.h3
-rw-r--r--include/linux/sunrpc/xprt.h13
-rw-r--r--include/linux/syscalls.h8
-rw-r--r--include/linux/tracepoint.h49
-rw-r--r--include/linux/uio.h52
-rw-r--r--include/media/rc-core.h8
-rw-r--r--include/net/9p/client.h6
-rw-r--r--include/net/9p/transport.h3
-rw-r--r--include/net/sctp/sctp.h2
-rw-r--r--include/net/sock.h2
-rw-r--r--include/scsi/scsi_device.h4
-rw-r--r--include/sound/cs8427.h1
-rw-r--r--include/target/iscsi/iscsi_transport.h2
-rw-r--r--include/target/target_core_backend.h2
-rw-r--r--include/target/target_core_base.h33
-rw-r--r--include/target/target_core_fabric.h6
-rw-r--r--include/trace/events/i2c.h372
-rw-r--r--include/trace/events/syscalls.h3
-rw-r--r--include/trace/ftrace.h15
-rw-r--r--include/uapi/linux/audit.h3
-rw-r--r--include/uapi/linux/capability.h4
-rw-r--r--include/uapi/linux/nvme.h1
-rw-r--r--include/uapi/linux/v4l2-common.h2
-rw-r--r--init/Kconfig5
-rw-r--r--kernel/audit.c27
-rw-r--r--kernel/audit.h6
-rw-r--r--kernel/auditfilter.c33
-rw-r--r--kernel/auditsc.c133
-rw-r--r--kernel/futex.c37
-rw-r--r--kernel/relay.c4
-rw-r--r--kernel/seccomp.c4
-rw-r--r--kernel/trace/trace.c10
-rw-r--r--kernel/trace/trace_events.c55
-rw-r--r--kernel/trace/trace_events_trigger.c2
-rw-r--r--kernel/trace/trace_export.c6
-rw-r--r--kernel/trace/trace_kprobe.c21
-rw-r--r--kernel/trace/trace_output.c2
-rw-r--r--kernel/trace/trace_uprobe.c20
-rw-r--r--kernel/tracepoint.c516
-rw-r--r--lib/Kconfig9
-rw-r--r--lib/Kconfig.debug10
-rw-r--r--lib/Makefile1
-rw-r--r--lib/audit.c15
-rw-r--r--lib/compat_audit.c50
-rw-r--r--lib/percpu_counter.c2
-rw-r--r--mm/Makefile3
-rw-r--r--mm/filemap.c344
-rw-r--r--mm/iov_iter.c224
-rw-r--r--mm/process_vm_access.c250
-rw-r--r--mm/shmem.c79
-rw-r--r--mm/util.c48
-rw-r--r--mm/vmscan.c16
-rw-r--r--net/9p/client.c25
-rw-r--r--net/9p/trans_fd.c110
-rw-r--r--net/9p/trans_rdma.c26
-rw-r--r--net/9p/trans_virtio.c3
-rw-r--r--net/atm/clip.c2
-rw-r--r--net/atm/lec.c10
-rw-r--r--net/atm/mpc.c6
-rw-r--r--net/atm/raw.c2
-rw-r--r--net/atm/signaling.c2
-rw-r--r--net/ax25/ax25_in.c2
-rw-r--r--net/bluetooth/l2cap_sock.c6
-rw-r--r--net/bluetooth/rfcomm/core.c4
-rw-r--r--net/bluetooth/rfcomm/sock.c4
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bridge/br_input.c2
-rw-r--r--net/bridge/br_vlan.c7
-rw-r--r--net/caif/caif_socket.c4
-rw-r--r--net/ceph/messenger.c2
-rw-r--r--net/core/pktgen.c8
-rw-r--r--net/core/skbuff.c16
-rw-r--r--net/core/sock.c4
-rw-r--r--net/dccp/input.c2
-rw-r--r--net/dccp/minisocks.c2
-rw-r--r--net/decnet/dn_nsp_in.c4
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_vti.c2
-rw-r--r--net/ipv4/tcp_input.c10
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/iucv/af_iucv.c4
-rw-r--r--net/key/af_key.c2
-rw-r--r--net/l2tp/l2tp_ppp.c4
-rw-r--r--net/netlink/af_netlink.c4
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--net/nfc/llcp_core.c2
-rw-r--r--net/packet/af_packet.c6
-rw-r--r--net/phonet/pep-gprs.c4
-rw-r--r--net/phonet/pep.c8
-rw-r--r--net/rds/tcp.h4
-rw-r--r--net/rds/tcp_listen.c6
-rw-r--r--net/rds/tcp_recv.c8
-rw-r--r--net/rose/af_rose.c2
-rw-r--r--net/rxrpc/ar-input.c6
-rw-r--r--net/rxrpc/ar-internal.h2
-rw-r--r--net/sctp/socket.c8
-rw-r--r--net/sctp/ulpqueue.c4
-rw-r--r--net/sunrpc/Kconfig39
-rw-r--r--net/sunrpc/Makefile3
-rw-r--r--net/sunrpc/clnt.c58
-rw-r--r--net/sunrpc/svcsock.c28
-rw-r--r--net/sunrpc/xdr.c22
-rw-r--r--net/sunrpc/xprt.c12
-rw-r--r--net/sunrpc/xprtrdma/Makefile4
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_recvfrom.c12
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_sendto.c2
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_transport.c3
-rw-r--r--net/sunrpc/xprtsock.c42
-rw-r--r--net/tipc/server.c4
-rw-r--r--net/tipc/socket.c6
-rw-r--r--net/unix/af_unix.c6
-rw-r--r--net/vmw_vsock/vmci_transport_notify.c2
-rw-r--r--net/vmw_vsock/vmci_transport_notify_qstate.c4
-rw-r--r--net/x25/af_x25.c2
-rw-r--r--net/x25/x25_in.c2
-rw-r--r--scripts/Makefile.build12
-rw-r--r--scripts/bootgraph.pl42
-rw-r--r--scripts/coccinelle/api/ptr_ret.cocci14
-rw-r--r--scripts/coccinelle/misc/memcpy-assign.cocci103
-rwxr-xr-xscripts/mkcompile_h2
-rwxr-xr-xscripts/objdiff141
-rwxr-xr-xscripts/tags.sh9
-rw-r--r--security/integrity/evm/evm_crypto.c2
-rw-r--r--security/integrity/evm/evm_main.c2
-rw-r--r--security/integrity/integrity_audit.c2
-rw-r--r--security/lsm_audit.c11
-rw-r--r--security/tomoyo/realpath.c4
-rw-r--r--sound/i2c/cs8427.c57
-rw-r--r--sound/mips/au1x00.c13
-rw-r--r--sound/oss/ad1848.c4
-rw-r--r--sound/oss/dmasound/dmasound_paula.c14
-rw-r--r--sound/oss/opl3.c3
-rw-r--r--sound/oss/pas2_mixer.c9
-rw-r--r--sound/oss/pas2_pcm.c18
-rw-r--r--sound/oss/sb_common.c4
-rw-r--r--sound/oss/sb_ess.c4
-rw-r--r--sound/oss/sequencer.c6
-rw-r--r--sound/oss/sound_config.h4
-rw-r--r--sound/oss/soundcard.c6
-rw-r--r--sound/oss/uart401.c11
-rw-r--r--sound/pci/hda/hda_controller.c19
-rw-r--r--sound/pci/hda/hda_controller.h2
-rw-r--r--sound/pci/hda/hda_intel.c4
-rw-r--r--sound/pci/hda/patch_realtek.c23
-rw-r--r--sound/pci/ice1712/delta.c31
-rw-r--r--sound/pci/ice1712/ice1712.c47
-rw-r--r--sound/soc/codecs/alc5623.c3
-rw-r--r--sound/soc/codecs/alc5632.c10
-rw-r--r--sound/soc/codecs/cs42l52.c2
-rw-r--r--sound/soc/codecs/cs42l52.h2
-rw-r--r--sound/soc/codecs/cs42xx8.c11
-rw-r--r--sound/soc/codecs/da732x.c3
-rw-r--r--sound/soc/codecs/max98090.c7
-rw-r--r--sound/soc/codecs/rt5640.c9
-rw-r--r--sound/soc/codecs/tlv320aic23-i2c.c7
-rw-r--r--sound/soc/davinci/davinci-mcasp.c6
-rw-r--r--sound/soc/fsl/fsl_sai.c93
-rw-r--r--sound/soc/fsl/fsl_sai.h15
-rw-r--r--sound/soc/samsung/ac97.c6
-rw-r--r--sound/soc/samsung/dma.h6
-rw-r--r--sound/soc/samsung/i2s.c6
-rw-r--r--sound/soc/samsung/pcm.c5
-rw-r--r--sound/soc/samsung/s3c2412-i2s.c4
-rw-r--r--sound/soc/samsung/s3c24xx-i2s.c4
-rw-r--r--sound/soc/samsung/spdif.c3
-rw-r--r--sound/usb/pcm.c3
-rw-r--r--tools/power/x86/turbostat/turbostat.8127
-rw-r--r--tools/power/x86/turbostat/turbostat.c240
-rw-r--r--virt/kvm/arm/arch_timer.c2
-rw-r--r--virt/kvm/arm/vgic.c2
842 files changed, 21142 insertions, 11089 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-power b/Documentation/ABI/testing/sysfs-devices-power
index 7dbf96b724ed..676fdf5f2a99 100644
--- a/Documentation/ABI/testing/sysfs-devices-power
+++ b/Documentation/ABI/testing/sysfs-devices-power
@@ -83,8 +83,10 @@ Contact: Rafael J. Wysocki <rjw@rjwysocki.net>
83Description: 83Description:
84 The /sys/devices/.../wakeup_count attribute contains the number 84 The /sys/devices/.../wakeup_count attribute contains the number
85 of signaled wakeup events associated with the device. This 85 of signaled wakeup events associated with the device. This
86 attribute is read-only. If the device is not enabled to wake up 86 attribute is read-only. If the device is not capable to wake up
87 the system from sleep states, this attribute is not present. 87 the system from sleep states, this attribute is not present.
88 If the device is not enabled to wake up the system from sleep
89 states, this attribute is empty.
88 90
89What: /sys/devices/.../power/wakeup_active_count 91What: /sys/devices/.../power/wakeup_active_count
90Date: September 2010 92Date: September 2010
@@ -93,8 +95,10 @@ Description:
93 The /sys/devices/.../wakeup_active_count attribute contains the 95 The /sys/devices/.../wakeup_active_count attribute contains the
94 number of times the processing of wakeup events associated with 96 number of times the processing of wakeup events associated with
95 the device was completed (at the kernel level). This attribute 97 the device was completed (at the kernel level). This attribute
96 is read-only. If the device is not enabled to wake up the 98 is read-only. If the device is not capable to wake up the
97 system from sleep states, this attribute is not present. 99 system from sleep states, this attribute is not present. If
100 the device is not enabled to wake up the system from sleep
101 states, this attribute is empty.
98 102
99What: /sys/devices/.../power/wakeup_abort_count 103What: /sys/devices/.../power/wakeup_abort_count
100Date: February 2012 104Date: February 2012
@@ -104,8 +108,9 @@ Description:
104 number of times the processing of a wakeup event associated with 108 number of times the processing of a wakeup event associated with
105 the device might have aborted system transition into a sleep 109 the device might have aborted system transition into a sleep
106 state in progress. This attribute is read-only. If the device 110 state in progress. This attribute is read-only. If the device
107 is not enabled to wake up the system from sleep states, this 111 is not capable to wake up the system from sleep states, this
108 attribute is not present. 112 attribute is not present. If the device is not enabled to wake
113 up the system from sleep states, this attribute is empty.
109 114
110What: /sys/devices/.../power/wakeup_expire_count 115What: /sys/devices/.../power/wakeup_expire_count
111Date: February 2012 116Date: February 2012
@@ -114,8 +119,10 @@ Description:
114 The /sys/devices/.../wakeup_expire_count attribute contains the 119 The /sys/devices/.../wakeup_expire_count attribute contains the
115 number of times a wakeup event associated with the device has 120 number of times a wakeup event associated with the device has
116 been reported with a timeout that expired. This attribute is 121 been reported with a timeout that expired. This attribute is
117 read-only. If the device is not enabled to wake up the system 122 read-only. If the device is not capable to wake up the system
118 from sleep states, this attribute is not present. 123 from sleep states, this attribute is not present. If the
124 device is not enabled to wake up the system from sleep states,
125 this attribute is empty.
119 126
120What: /sys/devices/.../power/wakeup_active 127What: /sys/devices/.../power/wakeup_active
121Date: September 2010 128Date: September 2010
@@ -124,8 +131,10 @@ Description:
124 The /sys/devices/.../wakeup_active attribute contains either 1, 131 The /sys/devices/.../wakeup_active attribute contains either 1,
125 or 0, depending on whether or not a wakeup event associated with 132 or 0, depending on whether or not a wakeup event associated with
126 the device is being processed (1). This attribute is read-only. 133 the device is being processed (1). This attribute is read-only.
127 If the device is not enabled to wake up the system from sleep 134 If the device is not capable to wake up the system from sleep
128 states, this attribute is not present. 135 states, this attribute is not present. If the device is not
136 enabled to wake up the system from sleep states, this attribute
137 is empty.
129 138
130What: /sys/devices/.../power/wakeup_total_time_ms 139What: /sys/devices/.../power/wakeup_total_time_ms
131Date: September 2010 140Date: September 2010
@@ -134,8 +143,9 @@ Description:
134 The /sys/devices/.../wakeup_total_time_ms attribute contains 143 The /sys/devices/.../wakeup_total_time_ms attribute contains
135 the total time of processing wakeup events associated with the 144 the total time of processing wakeup events associated with the
136 device, in milliseconds. This attribute is read-only. If the 145 device, in milliseconds. This attribute is read-only. If the
137 device is not enabled to wake up the system from sleep states, 146 device is not capable to wake up the system from sleep states,
138 this attribute is not present. 147 this attribute is not present. If the device is not enabled to
148 wake up the system from sleep states, this attribute is empty.
139 149
140What: /sys/devices/.../power/wakeup_max_time_ms 150What: /sys/devices/.../power/wakeup_max_time_ms
141Date: September 2010 151Date: September 2010
@@ -144,8 +154,10 @@ Description:
144 The /sys/devices/.../wakeup_max_time_ms attribute contains 154 The /sys/devices/.../wakeup_max_time_ms attribute contains
145 the maximum time of processing a single wakeup event associated 155 the maximum time of processing a single wakeup event associated
146 with the device, in milliseconds. This attribute is read-only. 156 with the device, in milliseconds. This attribute is read-only.
147 If the device is not enabled to wake up the system from sleep 157 If the device is not capable to wake up the system from sleep
148 states, this attribute is not present. 158 states, this attribute is not present. If the device is not
159 enabled to wake up the system from sleep states, this attribute
160 is empty.
149 161
150What: /sys/devices/.../power/wakeup_last_time_ms 162What: /sys/devices/.../power/wakeup_last_time_ms
151Date: September 2010 163Date: September 2010
@@ -156,7 +168,8 @@ Description:
156 signaling the last wakeup event associated with the device, in 168 signaling the last wakeup event associated with the device, in
157 milliseconds. This attribute is read-only. If the device is 169 milliseconds. This attribute is read-only. If the device is
158 not enabled to wake up the system from sleep states, this 170 not enabled to wake up the system from sleep states, this
159 attribute is not present. 171 attribute is not present. If the device is not enabled to wake
172 up the system from sleep states, this attribute is empty.
160 173
161What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms 174What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms
162Date: February 2012 175Date: February 2012
@@ -165,9 +178,10 @@ Description:
165 The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute 178 The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute
166 contains the total time the device has been preventing 179 contains the total time the device has been preventing
167 opportunistic transitions to sleep states from occurring. 180 opportunistic transitions to sleep states from occurring.
168 This attribute is read-only. If the device is not enabled to 181 This attribute is read-only. If the device is not capable to
169 wake up the system from sleep states, this attribute is not 182 wake up the system from sleep states, this attribute is not
170 present. 183 present. If the device is not enabled to wake up the system
184 from sleep states, this attribute is empty.
171 185
172What: /sys/devices/.../power/autosuspend_delay_ms 186What: /sys/devices/.../power/autosuspend_delay_ms
173Date: September 2010 187Date: September 2010
diff --git a/Documentation/devicetree/bindings/dma/fsl-edma.txt b/Documentation/devicetree/bindings/dma/fsl-edma.txt
new file mode 100644
index 000000000000..191d7bd8a6fe
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/fsl-edma.txt
@@ -0,0 +1,76 @@
1* Freescale enhanced Direct Memory Access(eDMA) Controller
2
3 The eDMA channels have multiplex capability by programmble memory-mapped
4registers. channels are split into two groups, called DMAMUX0 and DMAMUX1,
5specific DMA request source can only be multiplexed by any channel of certain
6group, DMAMUX0 or DMAMUX1, but not both.
7
8* eDMA Controller
9Required properties:
10- compatible :
11 - "fsl,vf610-edma" for eDMA used similar to that on Vybrid vf610 SoC
12- reg : Specifies base physical address(s) and size of the eDMA registers.
13 The 1st region is eDMA control register's address and size.
14 The 2nd and the 3rd regions are programmable channel multiplexing
15 control register's address and size.
16- interrupts : A list of interrupt-specifiers, one for each entry in
17 interrupt-names.
18- interrupt-names : Should contain:
19 "edma-tx" - the transmission interrupt
20 "edma-err" - the error interrupt
21- #dma-cells : Must be <2>.
22 The 1st cell specifies the DMAMUX(0 for DMAMUX0 and 1 for DMAMUX1).
23 Specific request source can only be multiplexed by specific channels
24 group called DMAMUX.
25 The 2nd cell specifies the request source(slot) ID.
26 See the SoC's reference manual for all the supported request sources.
27- dma-channels : Number of channels supported by the controller
28- clock-names : A list of channel group clock names. Should contain:
29 "dmamux0" - clock name of mux0 group
30 "dmamux1" - clock name of mux1 group
31- clocks : A list of phandle and clock-specifier pairs, one for each entry in
32 clock-names.
33
34Optional properties:
35- big-endian: If present registers and hardware scatter/gather descriptors
36 of the eDMA are implemented in big endian mode, otherwise in little
37 mode.
38
39
40Examples:
41
42edma0: dma-controller@40018000 {
43 #dma-cells = <2>;
44 compatible = "fsl,vf610-edma";
45 reg = <0x40018000 0x2000>,
46 <0x40024000 0x1000>,
47 <0x40025000 0x1000>;
48 interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>,
49 <0 9 IRQ_TYPE_LEVEL_HIGH>;
50 interrupt-names = "edma-tx", "edma-err";
51 dma-channels = <32>;
52 clock-names = "dmamux0", "dmamux1";
53 clocks = <&clks VF610_CLK_DMAMUX0>,
54 <&clks VF610_CLK_DMAMUX1>;
55};
56
57
58* DMA clients
59DMA client drivers that uses the DMA function must use the format described
60in the dma.txt file, using a two-cell specifier for each channel: the 1st
61specifies the channel group(DMAMUX) in which this request can be multiplexed,
62and the 2nd specifies the request source.
63
64Examples:
65
66sai2: sai@40031000 {
67 compatible = "fsl,vf610-sai";
68 reg = <0x40031000 0x1000>;
69 interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>;
70 clock-names = "sai";
71 clocks = <&clks VF610_CLK_SAI2>;
72 dma-names = "tx", "rx";
73 dmas = <&edma0 0 21>,
74 <&edma0 0 20>;
75 status = "disabled";
76};
diff --git a/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
new file mode 100644
index 000000000000..d75a9d767022
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/qcom_bam_dma.txt
@@ -0,0 +1,41 @@
1QCOM BAM DMA controller
2
3Required properties:
4- compatible: must contain "qcom,bam-v1.4.0" for MSM8974
5- reg: Address range for DMA registers
6- interrupts: Should contain the one interrupt shared by all channels
7- #dma-cells: must be <1>, the cell in the dmas property of the client device
8 represents the channel number
9- clocks: required clock
10- clock-names: must contain "bam_clk" entry
11- qcom,ee : indicates the active Execution Environment identifier (0-7) used in
12 the secure world.
13
14Example:
15
16 uart-bam: dma@f9984000 = {
17 compatible = "qcom,bam-v1.4.0";
18 reg = <0xf9984000 0x15000>;
19 interrupts = <0 94 0>;
20 clocks = <&gcc GCC_BAM_DMA_AHB_CLK>;
21 clock-names = "bam_clk";
22 #dma-cells = <1>;
23 qcom,ee = <0>;
24 };
25
26DMA clients must use the format described in the dma.txt file, using a two cell
27specifier for each channel.
28
29Example:
30 serial@f991e000 {
31 compatible = "qcom,msm-uart";
32 reg = <0xf991e000 0x1000>
33 <0xf9944000 0x19000>;
34 interrupts = <0 108 0>;
35 clocks = <&gcc GCC_BLSP1_UART2_APPS_CLK>,
36 <&gcc GCC_BLSP1_AHB_CLK>;
37 clock-names = "core", "iface";
38
39 dmas = <&uart-bam 0>, <&uart-bam 1>;
40 dma-names = "rx", "tx";
41 };
diff --git a/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
new file mode 100644
index 000000000000..ecbc96ad36f8
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/sirfsoc-dma.txt
@@ -0,0 +1,43 @@
1* CSR SiRFSoC DMA controller
2
3See dma.txt first
4
5Required properties:
6- compatible: Should be "sirf,prima2-dmac" or "sirf,marco-dmac"
7- reg: Should contain DMA registers location and length.
8- interrupts: Should contain one interrupt shared by all channel
9- #dma-cells: must be <1>. used to represent the number of integer
10 cells in the dmas property of client device.
11- clocks: clock required
12
13Example:
14
15Controller:
16dmac0: dma-controller@b00b0000 {
17 compatible = "sirf,prima2-dmac";
18 reg = <0xb00b0000 0x10000>;
19 interrupts = <12>;
20 clocks = <&clks 24>;
21 #dma-cells = <1>;
22};
23
24
25Client:
26Fill the specific dma request line in dmas. In the below example, spi0 read
27channel request line is 9 of the 2nd dma controller, while write channel uses
284 of the 2nd dma controller; spi1 read channel request line is 12 of the 1st
29dma controller, while write channel uses 13 of the 1st dma controller:
30
31spi0: spi@b00d0000 {
32 compatible = "sirf,prima2-spi";
33 dmas = <&dmac1 9>,
34 <&dmac1 4>;
35 dma-names = "rx", "tx";
36};
37
38spi1: spi@b0170000 {
39 compatible = "sirf,prima2-spi";
40 dmas = <&dmac0 12>,
41 <&dmac0 13>;
42 dma-names = "rx", "tx";
43};
diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
index 4fade84bea16..388f0a275fba 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt
@@ -12,6 +12,7 @@ Required properties :
12- clocks: phandles to input clocks. 12- clocks: phandles to input clocks.
13 13
14Optional properties: 14Optional properties:
15- clock-frequency: Desired I2C bus frequency in Hz, otherwise defaults to 100000
15- Child nodes conforming to i2c bus binding 16- Child nodes conforming to i2c bus binding
16 17
17Examples : 18Examples :
@@ -23,6 +24,7 @@ i2c0: i2c@fff84000 {
23 #address-cells = <1>; 24 #address-cells = <1>;
24 #size-cells = <0>; 25 #size-cells = <0>;
25 clocks = <&twi0_clk>; 26 clocks = <&twi0_clk>;
27 clock-frequency = <400000>;
26 28
27 24c512@50 { 29 24c512@50 {
28 compatible = "24c512"; 30 compatible = "24c512";
diff --git a/Documentation/devicetree/bindings/i2c/i2c-cadence.txt b/Documentation/devicetree/bindings/i2c/i2c-cadence.txt
new file mode 100644
index 000000000000..7cb0b5608f49
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-cadence.txt
@@ -0,0 +1,24 @@
1Binding for the Cadence I2C controller
2
3Required properties:
4 - reg: Physical base address and size of the controller's register area.
5 - compatible: Compatibility string. Must be 'cdns,i2c-r1p10'.
6 - clocks: Input clock specifier. Refer to common clock bindings.
7 - interrupts: Interrupt specifier. Refer to interrupt bindings.
8 - #address-cells: Should be 1.
9 - #size-cells: Should be 0.
10
11Optional properties:
12 - clock-frequency: Desired operating frequency, in Hz, of the bus.
13 - clock-names: Input clock name, should be 'pclk'.
14
15Example:
16 i2c@e0004000 {
17 compatible = "cdns,i2c-r1p10";
18 clocks = <&clkc 38>;
19 interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
20 reg = <0xe0004000 0x1000>;
21 clock-frequency = <400000>;
22 #address-cells = <1>;
23 #size-cells = <0>;
24 };
diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt
index 7fd7fa25e9b0..5199b0c8cf7a 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-designware.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-designware.txt
@@ -14,6 +14,12 @@ Optional properties :
14 - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds. 14 - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
15 This option is only supported in hardware blocks version 1.11a or newer. 15 This option is only supported in hardware blocks version 1.11a or newer.
16 16
17 - i2c-scl-falling-time : should contain the SCL falling time in nanoseconds.
18 This value which is by default 300ns is used to compute the tLOW period.
19
20 - i2c-sda-falling-time : should contain the SDA falling time in nanoseconds.
21 This value which is by default 300ns is used to compute the tHIGH period.
22
17Example : 23Example :
18 24
19 i2c@f0000 { 25 i2c@f0000 {
@@ -34,4 +40,6 @@ Example :
34 interrupts = <12 1>; 40 interrupts = <12 1>;
35 clock-frequency = <400000>; 41 clock-frequency = <400000>;
36 i2c-sda-hold-time-ns = <300>; 42 i2c-sda-hold-time-ns = <300>;
43 i2c-sda-falling-time-ns = <300>;
44 i2c-scl-falling-time-ns = <300>;
37 }; 45 };
diff --git a/Documentation/devicetree/bindings/i2c/i2c-efm32.txt b/Documentation/devicetree/bindings/i2c/i2c-efm32.txt
new file mode 100644
index 000000000000..fc15ac519437
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-efm32.txt
@@ -0,0 +1,34 @@
1* Energymicro efm32 i2c controller
2
3Required properties :
4
5 - reg : Offset and length of the register set for the device
6 - compatible : should be "energymicro,efm32-i2c"
7 - interrupts : the interrupt number
8 - clocks : reference to the module clock
9
10Recommended properties :
11
12 - clock-frequency : maximal I2C bus clock frequency in Hz.
13 - efm32,location : Decides the location of the USART I/O pins.
14 Allowed range : [0 .. 6]
15
16Example:
17 i2c0: i2c@4000a000 {
18 #address-cells = <1>;
19 #size-cells = <0>;
20 compatible = "energymicro,efm32-i2c";
21 reg = <0x4000a000 0x400>;
22 interrupts = <9>;
23 clocks = <&cmu clk_HFPERCLKI2C0>;
24 clock-frequency = <100000>;
25 status = "ok";
26 efm32,location = <3>;
27
28 eeprom@50 {
29 compatible = "microchip,24c02";
30 reg = <0x50>;
31 pagesize = <16>;
32 };
33 };
34
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
index 582b4652a82a..befd4fb4764f 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
@@ -4,12 +4,16 @@
4Required properties : 4Required properties :
5 5
6 - reg : Offset and length of the register set for the device 6 - reg : Offset and length of the register set for the device
7 - compatible : Should be "marvell,mv64xxx-i2c" or "allwinner,sun4i-i2c" 7 - compatible : Should be either:
8 or "marvell,mv78230-i2c" or "marvell,mv78230-a0-i2c" 8 - "allwinner,sun4i-i2c"
9 Note: Only use "marvell,mv78230-a0-i2c" for a very rare, 9 - "allwinner,sun6i-a31-i2c"
10 initial version of the SoC which had broken offload 10 - "marvell,mv64xxx-i2c"
11 support. Linux auto-detects this and sets it 11 - "marvell,mv78230-i2c"
12 appropriately. 12 - "marvell,mv78230-a0-i2c"
13 * Note: Only use "marvell,mv78230-a0-i2c" for a
14 very rare, initial version of the SoC which
15 had broken offload support. Linux
16 auto-detects this and sets it appropriately.
13 - interrupts : The interrupt number 17 - interrupts : The interrupt number
14 18
15Optional properties : 19Optional properties :
@@ -17,6 +21,10 @@ Optional properties :
17 - clock-frequency : Desired I2C bus clock frequency in Hz. If not set the 21 - clock-frequency : Desired I2C bus clock frequency in Hz. If not set the
18default frequency is 100kHz 22default frequency is 100kHz
19 23
24 - resets : phandle to the parent reset controller. Mandatory
25 whenever you're using the "allwinner,sun6i-a31-i2c"
26 compatible.
27
20Examples: 28Examples:
21 29
22 i2c@11000 { 30 i2c@11000 {
diff --git a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
index 897cfcd5ce92..dd8b2dd1edeb 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
@@ -6,6 +6,7 @@ Required properties:
6 "renesas,i2c-r8a7778" 6 "renesas,i2c-r8a7778"
7 "renesas,i2c-r8a7779" 7 "renesas,i2c-r8a7779"
8 "renesas,i2c-r8a7790" 8 "renesas,i2c-r8a7790"
9 "renesas,i2c-r8a7791"
9- reg: physical base address of the controller and length of memory mapped 10- reg: physical base address of the controller and length of memory mapped
10 region. 11 region.
11- interrupts: interrupt specifier. 12- interrupts: interrupt specifier.
@@ -13,11 +14,16 @@ Required properties:
13Optional properties: 14Optional properties:
14- clock-frequency: desired I2C bus clock frequency in Hz. The absence of this 15- clock-frequency: desired I2C bus clock frequency in Hz. The absence of this
15 propoerty indicates the default frequency 100 kHz. 16 propoerty indicates the default frequency 100 kHz.
17- clocks: clock specifier.
16 18
17Examples : 19Examples :
18 20
19i2c0: i2c@e6500000 { 21i2c0: i2c@e6508000 {
20 compatible = "renesas,i2c-rcar-h2"; 22 #address-cells = <1>;
21 reg = <0 0xe6500000 0 0x428>; 23 #size-cells = <0>;
22 interrupts = <0 174 0x4>; 24 compatible = "renesas,i2c-r8a7791";
25 reg = <0 0xe6508000 0 0x40>;
26 interrupts = <0 287 IRQ_TYPE_LEVEL_HIGH>;
27 clocks = <&mstp9_clks R8A7791_CLK_I2C0>;
28 clock-frequency = <400000>;
23}; 29};
diff --git a/Documentation/devicetree/bindings/i2c/qcom,i2c-qup.txt b/Documentation/devicetree/bindings/i2c/qcom,i2c-qup.txt
new file mode 100644
index 000000000000..dc71754a56af
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/qcom,i2c-qup.txt
@@ -0,0 +1,40 @@
1Qualcomm Universal Peripheral (QUP) I2C controller
2
3Required properties:
4 - compatible: Should be:
5 * "qcom,i2c-qup-v1.1.1" for 8660, 8960 and 8064.
6 * "qcom,i2c-qup-v2.1.1" for 8974 v1.
7 * "qcom,i2c-qup-v2.2.1" for 8974 v2 and later.
8 - reg: Should contain QUP register address and length.
9 - interrupts: Should contain I2C interrupt.
10
11 - clocks: A list of phandles + clock-specifiers, one for each entry in
12 clock-names.
13 - clock-names: Should contain:
14 * "core" for the core clock
15 * "iface" for the AHB clock
16
17 - #address-cells: Should be <1> Address cells for i2c device address
18 - #size-cells: Should be <0> as i2c addresses have no size component
19
20Optional properties:
21 - clock-frequency: Should specify the desired i2c bus clock frequency in Hz,
22 defaults to 100kHz if omitted.
23
24Child nodes should conform to i2c bus binding.
25
26Example:
27
28 i2c@f9924000 {
29 compatible = "qcom,i2c-qup-v2.2.1";
30 reg = <0xf9924000 0x1000>;
31 interrupts = <0 96 0>;
32
33 clocks = <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>;
34 clock-names = "core", "iface";
35
36 clock-frequency = <355000>;
37
38 #address-cells = <1>;
39 #size-cells = <0>;
40 };
diff --git a/Documentation/devicetree/bindings/leds/leds-gpio.txt b/Documentation/devicetree/bindings/leds/leds-gpio.txt
index df1b3080f6b8..f77148f372ea 100644
--- a/Documentation/devicetree/bindings/leds/leds-gpio.txt
+++ b/Documentation/devicetree/bindings/leds/leds-gpio.txt
@@ -21,6 +21,8 @@ LED sub-node properties:
21 on). The "keep" setting will keep the LED at whatever its current 21 on). The "keep" setting will keep the LED at whatever its current
22 state is, without producing a glitch. The default is off if this 22 state is, without producing a glitch. The default is off if this
23 property is not present. 23 property is not present.
24- retain-state-suspended: (optional) The suspend state can be retained.Such
25 as charge-led gpio.
24 26
25Examples: 27Examples:
26 28
@@ -50,3 +52,13 @@ run-control {
50 default-state = "on"; 52 default-state = "on";
51 }; 53 };
52}; 54};
55
56leds {
57 compatible = "gpio-leds";
58
59 charger-led {
60 gpios = <&gpio1 2 0>;
61 linux,default-trigger = "max8903-charger-charging";
62 retain-state-suspended;
63 };
64};
diff --git a/Documentation/devicetree/bindings/mfd/mc13xxx.txt b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
index abd9e3cb2db7..1413f39912d3 100644
--- a/Documentation/devicetree/bindings/mfd/mc13xxx.txt
+++ b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
@@ -10,9 +10,44 @@ Optional properties:
10- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used 10- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used
11 11
12Sub-nodes: 12Sub-nodes:
13- leds : Contain the led nodes and initial register values in property
14 "led-control". Number of register depends of used IC, for MC13783 is 6,
15 for MC13892 is 4, for MC34708 is 1. See datasheet for bits definitions of
16 these registers.
17 - #address-cells: Must be 1.
18 - #size-cells: Must be 0.
19 Each led node should contain "reg", which used as LED ID (described below).
20 Optional properties "label" and "linux,default-trigger" is described in
21 Documentation/devicetree/bindings/leds/common.txt.
13- regulators : Contain the regulator nodes. The regulators are bound using 22- regulators : Contain the regulator nodes. The regulators are bound using
14 their names as listed below with their registers and bits for enabling. 23 their names as listed below with their registers and bits for enabling.
15 24
25MC13783 LED IDs:
26 0 : Main display
27 1 : AUX display
28 2 : Keypad
29 3 : Red 1
30 4 : Green 1
31 5 : Blue 1
32 6 : Red 2
33 7 : Green 2
34 8 : Blue 2
35 9 : Red 3
36 10 : Green 3
37 11 : Blue 3
38
39MC13892 LED IDs:
40 0 : Main display
41 1 : AUX display
42 2 : Keypad
43 3 : Red
44 4 : Green
45 5 : Blue
46
47MC34708 LED IDs:
48 0 : Charger Red
49 1 : Charger Green
50
16MC13783 regulators: 51MC13783 regulators:
17 sw1a : regulator SW1A (register 24, bit 0) 52 sw1a : regulator SW1A (register 24, bit 0)
18 sw1b : regulator SW1B (register 25, bit 0) 53 sw1b : regulator SW1B (register 25, bit 0)
@@ -89,6 +124,18 @@ ecspi@70010000 { /* ECSPI1 */
89 interrupt-parent = <&gpio0>; 124 interrupt-parent = <&gpio0>;
90 interrupts = <8>; 125 interrupts = <8>;
91 126
127 leds {
128 #address-cells = <1>;
129 #size-cells = <0>;
130 led-control = <0x000 0x000 0x0e0 0x000>;
131
132 sysled {
133 reg = <3>;
134 label = "system:red:live";
135 linux,default-trigger = "heartbeat";
136 };
137 };
138
92 regulators { 139 regulators {
93 sw1_reg: mc13892__sw1 { 140 sw1_reg: mc13892__sw1 {
94 regulator-min-microvolt = <600000>; 141 regulator-min-microvolt = <600000>;
diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt
index 458b57f199af..9dce540771fb 100644
--- a/Documentation/devicetree/bindings/mmc/mmc.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc.txt
@@ -26,9 +26,18 @@ Optional properties:
26 this system, even if the controller claims it is. 26 this system, even if the controller claims it is.
27- cap-sd-highspeed: SD high-speed timing is supported 27- cap-sd-highspeed: SD high-speed timing is supported
28- cap-mmc-highspeed: MMC high-speed timing is supported 28- cap-mmc-highspeed: MMC high-speed timing is supported
29- sd-uhs-sdr12: SD UHS SDR12 speed is supported
30- sd-uhs-sdr25: SD UHS SDR25 speed is supported
31- sd-uhs-sdr50: SD UHS SDR50 speed is supported
32- sd-uhs-sdr104: SD UHS SDR104 speed is supported
33- sd-uhs-ddr50: SD UHS DDR50 speed is supported
29- cap-power-off-card: powering off the card is safe 34- cap-power-off-card: powering off the card is safe
30- cap-sdio-irq: enable SDIO IRQ signalling on this interface 35- cap-sdio-irq: enable SDIO IRQ signalling on this interface
31- full-pwr-cycle: full power cycle of the card is supported 36- full-pwr-cycle: full power cycle of the card is supported
37- mmc-highspeed-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported
38- mmc-highspeed-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported
39- mmc-hs200-1_8v: eMMC HS200 mode(1.8V I/O) is supported
40- mmc-hs200-1_2v: eMMC HS200 mode(1.2V I/O) is supported
32 41
33*NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line 42*NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
34polarity properties, we have to fix the meaning of the "normal" and "inverted" 43polarity properties, we have to fix the meaning of the "normal" and "inverted"
diff --git a/Documentation/devicetree/bindings/mmc/sdhci-msm.txt b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
new file mode 100644
index 000000000000..81b33b5b20fc
--- /dev/null
+++ b/Documentation/devicetree/bindings/mmc/sdhci-msm.txt
@@ -0,0 +1,55 @@
1* Qualcomm SDHCI controller (sdhci-msm)
2
3This file documents differences between the core properties in mmc.txt
4and the properties used by the sdhci-msm driver.
5
6Required properties:
7- compatible: Should contain "qcom,sdhci-msm-v4".
8- reg: Base address and length of the register in the following order:
9 - Host controller register map (required)
10 - SD Core register map (required)
11- interrupts: Should contain an interrupt-specifiers for the interrupts:
12 - Host controller interrupt (required)
13- pinctrl-names: Should contain only one value - "default".
14- pinctrl-0: Should specify pin control groups used for this controller.
15- clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names.
16- clock-names: Should contain the following:
17 "iface" - Main peripheral bus clock (PCLK/HCLK - AHB Bus clock) (required)
18 "core" - SDC MMC clock (MCLK) (required)
19 "bus" - SDCC bus voter clock (optional)
20
21Example:
22
23 sdhc_1: sdhci@f9824900 {
24 compatible = "qcom,sdhci-msm-v4";
25 reg = <0xf9824900 0x11c>, <0xf9824000 0x800>;
26 interrupts = <0 123 0>;
27 bus-width = <8>;
28 non-removable;
29
30 vmmc = <&pm8941_l20>;
31 vqmmc = <&pm8941_s3>;
32
33 pinctrl-names = "default";
34 pinctrl-0 = <&sdc1_clk &sdc1_cmd &sdc1_data>;
35
36 clocks = <&gcc GCC_SDCC1_APPS_CLK>, <&gcc GCC_SDCC1_AHB_CLK>;
37 clock-names = "core", "iface";
38 };
39
40 sdhc_2: sdhci@f98a4900 {
41 compatible = "qcom,sdhci-msm-v4";
42 reg = <0xf98a4900 0x11c>, <0xf98a4000 0x800>;
43 interrupts = <0 125 0>;
44 bus-width = <4>;
45 cd-gpios = <&msmgpio 62 0x1>;
46
47 vmmc = <&pm8941_l21>;
48 vqmmc = <&pm8941_l13>;
49
50 pinctrl-names = "default";
51 pinctrl-0 = <&sdc2_clk &sdc2_cmd &sdc2_data>;
52
53 clocks = <&gcc GCC_SDCC2_APPS_CLK>, <&gcc GCC_SDCC2_AHB_CLK>;
54 clock-names = "core", "iface";
55 };
diff --git a/Documentation/devicetree/bindings/mmc/sdhci-pxa.txt b/Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
index dbe98a3c183a..86223c3eda90 100644
--- a/Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
+++ b/Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
@@ -4,7 +4,14 @@ This file documents differences between the core properties in mmc.txt
4and the properties used by the sdhci-pxav2 and sdhci-pxav3 drivers. 4and the properties used by the sdhci-pxav2 and sdhci-pxav3 drivers.
5 5
6Required properties: 6Required properties:
7- compatible: Should be "mrvl,pxav2-mmc" or "mrvl,pxav3-mmc". 7- compatible: Should be "mrvl,pxav2-mmc", "mrvl,pxav3-mmc" or
8 "marvell,armada-380-sdhci".
9- reg:
10 * for "mrvl,pxav2-mmc" and "mrvl,pxav3-mmc", one register area for
11 the SDHCI registers.
12 * for "marvell,armada-380-sdhci", two register areas. The first one
13 for the SDHCI registers themselves, and the second one for the
14 AXI/Mbus bridge registers of the SDHCI unit.
8 15
9Optional properties: 16Optional properties:
10- mrvl,clk-delay-cycles: Specify a number of cycles to delay for tuning. 17- mrvl,clk-delay-cycles: Specify a number of cycles to delay for tuning.
@@ -19,3 +26,11 @@ sdhci@d4280800 {
19 non-removable; 26 non-removable;
20 mrvl,clk-delay-cycles = <31>; 27 mrvl,clk-delay-cycles = <31>;
21}; 28};
29
30sdhci@d8000 {
31 compatible = "marvell,armada-380-sdhci";
32 reg = <0xd8000 0x1000>, <0xdc000 0x100>;
33 interrupts = <0 25 0x4>;
34 clocks = <&gateclk 17>;
35 mrvl,clk-delay-cycles = <0x1F>;
36};
diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
index 8c8908ab84ba..ce8056116fb0 100644
--- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
+++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
@@ -10,6 +10,7 @@ Required properties:
10- compatible: 10- compatible:
11 Should be "ti,omap2-hsmmc", for OMAP2 controllers 11 Should be "ti,omap2-hsmmc", for OMAP2 controllers
12 Should be "ti,omap3-hsmmc", for OMAP3 controllers 12 Should be "ti,omap3-hsmmc", for OMAP3 controllers
13 Should be "ti,omap3-pre-es3-hsmmc" for OMAP3 controllers pre ES3.0
13 Should be "ti,omap4-hsmmc", for OMAP4 controllers 14 Should be "ti,omap4-hsmmc", for OMAP4 controllers
14- ti,hwmods: Must be "mmc<n>", n is controller instance starting 1 15- ti,hwmods: Must be "mmc<n>", n is controller instance starting 1
15 16
diff --git a/Documentation/devicetree/bindings/regulator/pbias-regulator.txt b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
new file mode 100644
index 000000000000..32aa26f1e434
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/pbias-regulator.txt
@@ -0,0 +1,27 @@
1PBIAS internal regulator for SD card dual voltage i/o pads on OMAP SoCs.
2
3Required properties:
4- compatible:
5 - "ti,pbias-omap" for OMAP2, OMAP3, OMAP4, OMAP5, DRA7.
6- reg: pbias register offset from syscon base and size of pbias register.
7- syscon : phandle of the system control module
8- regulator-name : should be
9 pbias_mmc_omap2430 for OMAP2430, OMAP3 SoCs
10 pbias_sim_omap3 for OMAP3 SoCs
11 pbias_mmc_omap4 for OMAP4 SoCs
12 pbias_mmc_omap5 for OMAP5 and DRA7 SoC
13
14Optional properties:
15- Any optional property defined in bindings/regulator/regulator.txt
16
17Example:
18
19 pbias_regulator: pbias_regulator {
20 compatible = "ti,pbias-omap";
21 reg = <0 0x4>;
22 syscon = <&omap5_padconf_global>;
23 pbias_mmc_reg: pbias_mmc_omap5 {
24 regulator-name = "pbias_mmc_omap5";
25 regulator-min-microvolt = <1800000>;
26 regulator-max-microvolt = <3000000>;
27 };
diff --git a/Documentation/devicetree/bindings/sound/fsl,ssi.txt b/Documentation/devicetree/bindings/sound/fsl,ssi.txt
index b93e9a91e30e..3aa4a8f528f4 100644
--- a/Documentation/devicetree/bindings/sound/fsl,ssi.txt
+++ b/Documentation/devicetree/bindings/sound/fsl,ssi.txt
@@ -20,15 +20,6 @@ Required properties:
20 have. 20 have.
21- interrupt-parent: The phandle for the interrupt controller that 21- interrupt-parent: The phandle for the interrupt controller that
22 services interrupts for this device. 22 services interrupts for this device.
23- fsl,mode: The operating mode for the SSI interface.
24 "i2s-slave" - I2S mode, SSI is clock slave
25 "i2s-master" - I2S mode, SSI is clock master
26 "lj-slave" - left-justified mode, SSI is clock slave
27 "lj-master" - l.j. mode, SSI is clock master
28 "rj-slave" - right-justified mode, SSI is clock slave
29 "rj-master" - r.j., SSI is clock master
30 "ac97-slave" - AC97 mode, SSI is clock slave
31 "ac97-master" - AC97 mode, SSI is clock master
32- fsl,playback-dma: Phandle to a node for the DMA channel to use for 23- fsl,playback-dma: Phandle to a node for the DMA channel to use for
33 playback of audio. This is typically dictated by SOC 24 playback of audio. This is typically dictated by SOC
34 design. See the notes below. 25 design. See the notes below.
@@ -47,6 +38,9 @@ Required properties:
47 be connected together, and SRFS and STFS be connected 38 be connected together, and SRFS and STFS be connected
48 together. This would still allow different sample sizes, 39 together. This would still allow different sample sizes,
49 but not different sample rates. 40 but not different sample rates.
41 - clocks: "ipg" - Required clock for the SSI unit
42 "baud" - Required clock for SSI master mode. Otherwise this
43 clock is not used
50 44
51Required are also ac97 link bindings if ac97 is used. See 45Required are also ac97 link bindings if ac97 is used. See
52Documentation/devicetree/bindings/sound/soc-ac97link.txt for the necessary 46Documentation/devicetree/bindings/sound/soc-ac97link.txt for the necessary
@@ -64,6 +58,15 @@ Optional properties:
64 Documentation/devicetree/bindings/dma/dma.txt. 58 Documentation/devicetree/bindings/dma/dma.txt.
65- dma-names: Two dmas have to be defined, "tx" and "rx", if fsl,imx-fiq 59- dma-names: Two dmas have to be defined, "tx" and "rx", if fsl,imx-fiq
66 is not defined. 60 is not defined.
61- fsl,mode: The operating mode for the SSI interface.
62 "i2s-slave" - I2S mode, SSI is clock slave
63 "i2s-master" - I2S mode, SSI is clock master
64 "lj-slave" - left-justified mode, SSI is clock slave
65 "lj-master" - l.j. mode, SSI is clock master
66 "rj-slave" - right-justified mode, SSI is clock slave
67 "rj-master" - r.j., SSI is clock master
68 "ac97-slave" - AC97 mode, SSI is clock slave
69 "ac97-master" - AC97 mode, SSI is clock master
67 70
68Child 'codec' node required properties: 71Child 'codec' node required properties:
69- compatible: Compatible list, contains the name of the codec 72- compatible: Compatible list, contains the name of the codec
diff --git a/Documentation/devicetree/bindings/spi/efm32-spi.txt b/Documentation/devicetree/bindings/spi/efm32-spi.txt
index 8f081c96a4fa..130cd17e3680 100644
--- a/Documentation/devicetree/bindings/spi/efm32-spi.txt
+++ b/Documentation/devicetree/bindings/spi/efm32-spi.txt
@@ -8,7 +8,13 @@ Required properties:
8- interrupts: pair specifying rx and tx irq 8- interrupts: pair specifying rx and tx irq
9- clocks: phandle to the spi clock 9- clocks: phandle to the spi clock
10- cs-gpios: see spi-bus.txt 10- cs-gpios: see spi-bus.txt
11- efm32,location: Value to write to the ROUTE register's LOCATION bitfield to configure the pinmux for the device, see datasheet for values. 11
12Recommended properties :
13- efm32,location: Value to write to the ROUTE register's LOCATION bitfield to
14 configure the pinmux for the device, see datasheet for values.
15 If "efm32,location" property is not provided, keeping what is
16 already configured in the hardware, so its either the reset
17 default 0 or whatever the bootloader did.
12 18
13Example: 19Example:
14 20
diff --git a/Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt b/Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt
new file mode 100644
index 000000000000..321be6640533
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt
@@ -0,0 +1,16 @@
1gpio-backlight bindings
2
3Required properties:
4 - compatible: "gpio-backlight"
5 - gpios: describes the gpio that is used for enabling/disabling the backlight.
6 refer to bindings/gpio/gpio.txt for more details.
7
8Optional properties:
9 - default-on: enable the backlight at boot.
10
11Example:
12 backlight {
13 compatible = "gpio-backlight";
14 gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>;
15 default-on;
16 };
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index b89a739a3276..9de9813d0ec5 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -1,5 +1,6 @@
1*.a 1*.a
2*.aux 2*.aux
3*.bc
3*.bin 4*.bin
4*.bz2 5*.bz2
5*.cis 6*.cis
@@ -21,6 +22,7 @@
21*.i 22*.i
22*.jpeg 23*.jpeg
23*.ko 24*.ko
25*.ll
24*.log 26*.log
25*.lst 27*.lst
26*.lzma 28*.lzma
@@ -35,6 +37,7 @@
35*.out 37*.out
36*.patch 38*.patch
37*.pdf 39*.pdf
40*.plist
38*.png 41*.png
39*.pot 42*.pot
40*.ps 43*.ps
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index efca5c1bbb10..eba790134253 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -202,7 +202,7 @@ prototypes:
202 unsigned long *); 202 unsigned long *);
203 int (*migratepage)(struct address_space *, struct page *, struct page *); 203 int (*migratepage)(struct address_space *, struct page *, struct page *);
204 int (*launder_page)(struct page *); 204 int (*launder_page)(struct page *);
205 int (*is_partially_uptodate)(struct page *, read_descriptor_t *, unsigned long); 205 int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long);
206 int (*error_remove_page)(struct address_space *, struct page *); 206 int (*error_remove_page)(struct address_space *, struct page *);
207 int (*swap_activate)(struct file *); 207 int (*swap_activate)(struct file *);
208 int (*swap_deactivate)(struct file *); 208 int (*swap_deactivate)(struct file *);
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 94eb86287bcb..617f6d70c077 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -596,7 +596,7 @@ struct address_space_operations {
596 /* migrate the contents of a page to the specified target */ 596 /* migrate the contents of a page to the specified target */
597 int (*migratepage) (struct page *, struct page *); 597 int (*migratepage) (struct page *, struct page *);
598 int (*launder_page) (struct page *); 598 int (*launder_page) (struct page *);
599 int (*is_partially_uptodate) (struct page *, read_descriptor_t *, 599 int (*is_partially_uptodate) (struct page *, unsigned long,
600 unsigned long); 600 unsigned long);
601 void (*is_dirty_writeback) (struct page *, bool *, bool *); 601 void (*is_dirty_writeback) (struct page *, bool *, bool *);
602 int (*error_remove_page) (struct mapping *mapping, struct page *page); 602 int (*error_remove_page) (struct mapping *mapping, struct page *page);
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index aaaf069306a3..adf5e33e8312 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -26,6 +26,7 @@ Supported adapters:
26 * Intel Wellsburg (PCH) 26 * Intel Wellsburg (PCH)
27 * Intel Coleto Creek (PCH) 27 * Intel Coleto Creek (PCH)
28 * Intel Wildcat Point-LP (PCH) 28 * Intel Wildcat Point-LP (PCH)
29 * Intel BayTrail (SOC)
29 Datasheets: Publicly available at the Intel website 30 Datasheets: Publicly available at the Intel website
30 31
31On Intel Patsburg and later chipsets, both the normal host SMBus controller 32On Intel Patsburg and later chipsets, both the normal host SMBus controller
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index b0ff2ab596ce..4556a3eb87c4 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -46,7 +46,7 @@ A few combinations of the above flags are also defined for your convenience:
46 and write_block_data commands 46 and write_block_data commands
47 I2C_FUNC_SMBUS_I2C_BLOCK Handles the SMBus read_i2c_block_data 47 I2C_FUNC_SMBUS_I2C_BLOCK Handles the SMBus read_i2c_block_data
48 and write_i2c_block_data commands 48 and write_i2c_block_data commands
49 I2C_FUNC_SMBUS_EMUL Handles all SMBus commands than can be 49 I2C_FUNC_SMBUS_EMUL Handles all SMBus commands that can be
50 emulated by a real I2C adapter (using 50 emulated by a real I2C adapter (using
51 the transparent emulation layer) 51 the transparent emulation layer)
52 52
diff --git a/Documentation/i2c/i2c-protocol b/Documentation/i2c/i2c-protocol
index 0b3e62d1f77a..ff6d6cee6c7e 100644
--- a/Documentation/i2c/i2c-protocol
+++ b/Documentation/i2c/i2c-protocol
@@ -6,8 +6,8 @@ Key to symbols
6S (1 bit) : Start bit 6S (1 bit) : Start bit
7P (1 bit) : Stop bit 7P (1 bit) : Stop bit
8Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. 8Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
9A, NA (1 bit) : Accept and reverse accept bit. 9A, NA (1 bit) : Accept and reverse accept bit.
10Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to 10Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to
11 get a 10 bit I2C address. 11 get a 10 bit I2C address.
12Comm (8 bits): Command byte, a data byte which often selects a register on 12Comm (8 bits): Command byte, a data byte which often selects a register on
13 the device. 13 the device.
@@ -49,11 +49,20 @@ a byte read, followed by a byte write:
49Modified transactions 49Modified transactions
50===================== 50=====================
51 51
52The following modifications to the I2C protocol can also be generated, 52The following modifications to the I2C protocol can also be generated by
53with the exception of I2C_M_NOSTART these are usually only needed to 53setting these flags for i2c messages. With the exception of I2C_M_NOSTART, they
54work around device issues: 54are usually only needed to work around device issues:
55 55
56 Flag I2C_M_NOSTART: 56I2C_M_IGNORE_NAK:
57 Normally message is interrupted immediately if there is [NA] from the
58 client. Setting this flag treats any [NA] as [A], and all of
59 message is sent.
60 These messages may still fail to SCL lo->hi timeout.
61
62I2C_M_NO_RD_ACK:
63 In a read message, master A/NA bit is skipped.
64
65I2C_M_NOSTART:
57 In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some 66 In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some
58 point. For example, setting I2C_M_NOSTART on the second partial message 67 point. For example, setting I2C_M_NOSTART on the second partial message
59 generates something like: 68 generates something like:
@@ -67,17 +76,13 @@ work around device issues:
67 I2C device but may also be used between direction changes by some 76 I2C device but may also be used between direction changes by some
68 rare devices. 77 rare devices.
69 78
70 Flags I2C_M_REV_DIR_ADDR 79I2C_M_REV_DIR_ADDR:
71 This toggles the Rd/Wr flag. That is, if you want to do a write, but 80 This toggles the Rd/Wr flag. That is, if you want to do a write, but
72 need to emit an Rd instead of a Wr, or vice versa, you set this 81 need to emit an Rd instead of a Wr, or vice versa, you set this
73 flag. For example: 82 flag. For example:
74 S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P 83 S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P
75 84
76 Flags I2C_M_IGNORE_NAK 85I2C_M_STOP:
77 Normally message is interrupted immediately if there is [NA] from the 86 Force a stop condition (P) after the message. Some I2C related protocols
78 client. Setting this flag treats any [NA] as [A], and all of 87 like SCCB require that. Normally, you really don't want to get interrupted
79 message is sent. 88 between the messages of one transfer.
80 These messages may still fail to SCL lo->hi timeout.
81
82 Flags I2C_M_NO_RD_ACK
83 In a read message, master A/NA bit is skipped.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index b6c67d592be5..03e50b4883a8 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2563,6 +2563,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2563 2563
2564 pcmv= [HW,PCMCIA] BadgePAD 4 2564 pcmv= [HW,PCMCIA] BadgePAD 4
2565 2565
2566 pd_ignore_unused
2567 [PM]
2568 Keep all power-domains already enabled by bootloader on,
2569 even if no driver has claimed them. This is useful
2570 for debug and development, but should not be
2571 needed on a platform with proper driver support.
2572
2566 pd. [PARIDE] 2573 pd. [PARIDE]
2567 See Documentation/blockdev/paride.txt. 2574 See Documentation/blockdev/paride.txt.
2568 2575
diff --git a/MAINTAINERS b/MAINTAINERS
index 7faf31001437..6dc67b1fdb50 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1427,6 +1427,7 @@ F: drivers/cpuidle/cpuidle-zynq.c
1427N: zynq 1427N: zynq
1428N: xilinx 1428N: xilinx
1429F: drivers/clocksource/cadence_ttc_timer.c 1429F: drivers/clocksource/cadence_ttc_timer.c
1430F: drivers/i2c/busses/i2c-cadence.c
1430F: drivers/mmc/host/sdhci-of-arasan.c 1431F: drivers/mmc/host/sdhci-of-arasan.c
1431 1432
1432ARM SMMU DRIVER 1433ARM SMMU DRIVER
@@ -4308,7 +4309,8 @@ F: drivers/i2c/i2c-stub.c
4308I2C SUBSYSTEM 4309I2C SUBSYSTEM
4309M: Wolfram Sang <wsa@the-dreams.de> 4310M: Wolfram Sang <wsa@the-dreams.de>
4310L: linux-i2c@vger.kernel.org 4311L: linux-i2c@vger.kernel.org
4311W: http://i2c.wiki.kernel.org/ 4312W: https://i2c.wiki.kernel.org/
4313Q: https://patchwork.ozlabs.org/project/linux-i2c/list/
4312T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 4314T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git
4313S: Maintained 4315S: Maintained
4314F: Documentation/i2c/ 4316F: Documentation/i2c/
@@ -5930,6 +5932,7 @@ F: include/linux/mfd/
5930 5932
5931MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM 5933MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM
5932M: Chris Ball <chris@printf.net> 5934M: Chris Ball <chris@printf.net>
5935M: Ulf Hansson <ulf.hansson@linaro.org>
5933L: linux-mmc@vger.kernel.org 5936L: linux-mmc@vger.kernel.org
5934T: git git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git 5937T: git git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git
5935S: Maintained 5938S: Maintained
@@ -6540,7 +6543,7 @@ F: drivers/net/wireless/orinoco/
6540 6543
6541OSD LIBRARY and FILESYSTEM 6544OSD LIBRARY and FILESYSTEM
6542M: Boaz Harrosh <bharrosh@panasas.com> 6545M: Boaz Harrosh <bharrosh@panasas.com>
6543M: Benny Halevy <bhalevy@tonian.com> 6546M: Benny Halevy <bhalevy@primarydata.com>
6544L: osd-dev@open-osd.org 6547L: osd-dev@open-osd.org
6545W: http://open-osd.org 6548W: http://open-osd.org
6546T: git git://git.open-osd.org/open-osd.git 6549T: git git://git.open-osd.org/open-osd.git
diff --git a/Makefile b/Makefile
index cf3e07516a04..e709613d68e5 100644
--- a/Makefile
+++ b/Makefile
@@ -248,6 +248,11 @@ HOSTCXX = g++
248HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 248HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
249HOSTCXXFLAGS = -O2 249HOSTCXXFLAGS = -O2
250 250
251ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
252HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
253 -Wno-missing-field-initializers -fno-delete-null-pointer-checks
254endif
255
251# Decide whether to build built-in, modular, or both. 256# Decide whether to build built-in, modular, or both.
252# Normally, just do built-in. 257# Normally, just do built-in.
253 258
@@ -324,6 +329,14 @@ endif
324 329
325export quiet Q KBUILD_VERBOSE 330export quiet Q KBUILD_VERBOSE
326 331
332ifneq ($(CC),)
333ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
334COMPILER := clang
335else
336COMPILER := gcc
337endif
338export COMPILER
339endif
327 340
328# Look for make include files relative to root of kernel src 341# Look for make include files relative to root of kernel src
329MAKEFLAGS += --include-dir=$(srctree) 342MAKEFLAGS += --include-dir=$(srctree)
@@ -383,7 +396,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
383 -fno-strict-aliasing -fno-common \ 396 -fno-strict-aliasing -fno-common \
384 -Werror-implicit-function-declaration \ 397 -Werror-implicit-function-declaration \
385 -Wno-format-security \ 398 -Wno-format-security \
386 -fno-delete-null-pointer-checks 399 $(call cc-option,-fno-delete-null-pointer-checks,)
387KBUILD_AFLAGS_KERNEL := 400KBUILD_AFLAGS_KERNEL :=
388KBUILD_CFLAGS_KERNEL := 401KBUILD_CFLAGS_KERNEL :=
389KBUILD_AFLAGS := -D__ASSEMBLY__ 402KBUILD_AFLAGS := -D__ASSEMBLY__
@@ -415,8 +428,9 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
415 428
416# Files to ignore in find ... statements 429# Files to ignore in find ... statements
417 430
418RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ 431export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
419 -o -name .pc -o -name .hg -o -name .git \) -prune -o 432 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
433 -prune -o
420export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 434export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
421 --exclude CVS --exclude .pc --exclude .hg --exclude .git 435 --exclude CVS --exclude .pc --exclude .hg --exclude .git
422 436
@@ -623,9 +637,24 @@ endif
623endif 637endif
624KBUILD_CFLAGS += $(stackp-flag) 638KBUILD_CFLAGS += $(stackp-flag)
625 639
640ifeq ($(COMPILER),clang)
641KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
642KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
643KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
644KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
645KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
646# Quiet clang warning: comparison of unsigned expression < 0 is always false
647KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
648# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
649# source of a reference will be _MergedGlobals and not on of the whitelisted names.
650# See modpost pattern 2
651KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
652else
653
626# This warning generated too much noise in a regular build. 654# This warning generated too much noise in a regular build.
627# Use make W=1 to enable this warning (see scripts/Makefile.build) 655# Use make W=1 to enable this warning (see scripts/Makefile.build)
628KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 656KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
657endif
629 658
630ifdef CONFIG_FRAME_POINTER 659ifdef CONFIG_FRAME_POINTER
631KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 660KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
@@ -1075,7 +1104,7 @@ CLEAN_DIRS += $(MODVERDIR)
1075 1104
1076# Directories & files removed with 'make mrproper' 1105# Directories & files removed with 'make mrproper'
1077MRPROPER_DIRS += include/config usr/include include/generated \ 1106MRPROPER_DIRS += include/config usr/include include/generated \
1078 arch/*/include/generated 1107 arch/*/include/generated .tmp_objdiff
1079MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \ 1108MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
1080 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ 1109 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
1081 signing_key.priv signing_key.x509 x509.genkey \ 1110 signing_key.priv signing_key.x509 x509.genkey \
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index f6c6b345388c..b7ff9a318c31 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -22,6 +22,7 @@ config ALPHA
22 select GENERIC_SMP_IDLE_THREAD 22 select GENERIC_SMP_IDLE_THREAD
23 select GENERIC_STRNCPY_FROM_USER 23 select GENERIC_STRNCPY_FROM_USER
24 select GENERIC_STRNLEN_USER 24 select GENERIC_STRNLEN_USER
25 select HAVE_ARCH_AUDITSYSCALL
25 select HAVE_MOD_ARCH_SPECIFIC 26 select HAVE_MOD_ARCH_SPECIFIC
26 select MODULES_USE_ELF_RELA 27 select MODULES_USE_ELF_RELA
27 select ODD_RT_SIGACTION 28 select ODD_RT_SIGACTION
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5db05f6a0412..ab438cb5af55 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -24,6 +24,7 @@ config ARM
24 select GENERIC_STRNCPY_FROM_USER 24 select GENERIC_STRNCPY_FROM_USER
25 select GENERIC_STRNLEN_USER 25 select GENERIC_STRNLEN_USER
26 select HARDIRQS_SW_RESEND 26 select HARDIRQS_SW_RESEND
27 select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT)
27 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL 28 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
28 select HAVE_ARCH_KGDB 29 select HAVE_ARCH_KGDB
29 select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) 30 select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)
diff --git a/arch/arm/boot/dts/atlas6.dtsi b/arch/arm/boot/dts/atlas6.dtsi
index 55d3f79c2ef5..9d72674049d6 100644
--- a/arch/arm/boot/dts/atlas6.dtsi
+++ b/arch/arm/boot/dts/atlas6.dtsi
@@ -271,6 +271,7 @@
271 reg = <0xb00b0000 0x10000>; 271 reg = <0xb00b0000 0x10000>;
272 interrupts = <12>; 272 interrupts = <12>;
273 clocks = <&clks 24>; 273 clocks = <&clks 24>;
274 #dma-cells = <1>;
274 }; 275 };
275 276
276 dmac1: dma-controller@b0160000 { 277 dmac1: dma-controller@b0160000 {
@@ -279,6 +280,7 @@
279 reg = <0xb0160000 0x10000>; 280 reg = <0xb0160000 0x10000>;
280 interrupts = <13>; 281 interrupts = <13>;
281 clocks = <&clks 25>; 282 clocks = <&clks 25>;
283 #dma-cells = <1>;
282 }; 284 };
283 285
284 vip@b00C0000 { 286 vip@b00C0000 {
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 9e3caf3d19fb..1c0f8e1893ae 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -154,6 +154,22 @@
154 ti,hwmods = "counter_32k"; 154 ti,hwmods = "counter_32k";
155 }; 155 };
156 156
157 dra7_ctrl_general: tisyscon@4a002e00 {
158 compatible = "syscon";
159 reg = <0x4a002e00 0x7c>;
160 };
161
162 pbias_regulator: pbias_regulator {
163 compatible = "ti,pbias-omap";
164 reg = <0 0x4>;
165 syscon = <&dra7_ctrl_general>;
166 pbias_mmc_reg: pbias_mmc_omap5 {
167 regulator-name = "pbias_mmc_omap5";
168 regulator-min-microvolt = <1800000>;
169 regulator-max-microvolt = <3000000>;
170 };
171 };
172
157 dra7_pmx_core: pinmux@4a003400 { 173 dra7_pmx_core: pinmux@4a003400 {
158 compatible = "pinctrl-single"; 174 compatible = "pinctrl-single";
159 reg = <0x4a003400 0x0464>; 175 reg = <0x4a003400 0x0464>;
@@ -543,6 +559,7 @@
543 dmas = <&sdma 61>, <&sdma 62>; 559 dmas = <&sdma 61>, <&sdma 62>;
544 dma-names = "tx", "rx"; 560 dma-names = "tx", "rx";
545 status = "disabled"; 561 status = "disabled";
562 pbias-supply = <&pbias_mmc_reg>;
546 }; 563 };
547 564
548 mmc2: mmc@480b4000 { 565 mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap2430.dtsi b/arch/arm/boot/dts/omap2430.dtsi
index 9d2f028fd687..d09697dab55e 100644
--- a/arch/arm/boot/dts/omap2430.dtsi
+++ b/arch/arm/boot/dts/omap2430.dtsi
@@ -29,6 +29,22 @@
29 pinctrl-single,function-mask = <0x3f>; 29 pinctrl-single,function-mask = <0x3f>;
30 }; 30 };
31 31
32 omap2_scm_general: tisyscon@49002270 {
33 compatible = "syscon";
34 reg = <0x49002270 0x240>;
35 };
36
37 pbias_regulator: pbias_regulator {
38 compatible = "ti,pbias-omap";
39 reg = <0x230 0x4>;
40 syscon = <&omap2_scm_general>;
41 pbias_mmc_reg: pbias_mmc_omap2430 {
42 regulator-name = "pbias_mmc_omap2430";
43 regulator-min-microvolt = <1800000>;
44 regulator-max-microvolt = <3000000>;
45 };
46 };
47
32 gpio1: gpio@4900c000 { 48 gpio1: gpio@4900c000 {
33 compatible = "ti,omap2-gpio"; 49 compatible = "ti,omap2-gpio";
34 reg = <0x4900c000 0x200>; 50 reg = <0x4900c000 0x200>;
@@ -188,6 +204,7 @@
188 ti,dual-volt; 204 ti,dual-volt;
189 dmas = <&sdma 61>, <&sdma 62>; 205 dmas = <&sdma 61>, <&sdma 62>;
190 dma-names = "tx", "rx"; 206 dma-names = "tx", "rx";
207 pbias-supply = <&pbias_mmc_reg>;
191 }; 208 };
192 209
193 mmc2: mmc@480b4000 { 210 mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap3-ldp.dts b/arch/arm/boot/dts/omap3-ldp.dts
index ddce0d807f70..0abe986a4ecc 100644
--- a/arch/arm/boot/dts/omap3-ldp.dts
+++ b/arch/arm/boot/dts/omap3-ldp.dts
@@ -174,8 +174,20 @@
174}; 174};
175 175
176&mmc1 { 176&mmc1 {
177 /* See 35xx errata 2.1.1.128 in SPRZ278F */
178 compatible = "ti,omap3-pre-es3-hsmmc";
177 vmmc-supply = <&vmmc1>; 179 vmmc-supply = <&vmmc1>;
178 bus-width = <4>; 180 bus-width = <4>;
181 pinctrl-names = "default";
182 pinctrl-0 = <&mmc1_pins>;
183};
184
185&mmc2 {
186 status="disabled";
187};
188
189&mmc3 {
190 status="disabled";
179}; 191};
180 192
181&omap3_pmx_core { 193&omap3_pmx_core {
@@ -209,6 +221,17 @@
209 0x174 (PIN_OUTPUT | MUX_MODE0) /* hsusb0_stp.hsusb0_stp */ 221 0x174 (PIN_OUTPUT | MUX_MODE0) /* hsusb0_stp.hsusb0_stp */
210 >; 222 >;
211 }; 223 };
224
225 mmc1_pins: pinmux_mmc1_pins {
226 pinctrl-single,pins = <
227 OMAP3_CORE1_IOPAD(0x2144, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_clk.mmc1_clk */
228 OMAP3_CORE1_IOPAD(0x2146, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.mmc1_cmd */
229 OMAP3_CORE1_IOPAD(0x2148, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.mmc1_dat0 */
230 OMAP3_CORE1_IOPAD(0x214A, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.mmc1_dat1 */
231 OMAP3_CORE1_IOPAD(0x214C, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.mmc1_dat2 */
232 OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.mmc1_dat3 */
233 >;
234 };
212}; 235};
213 236
214&usb_otg_hs { 237&usb_otg_hs {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3d05eff67e25..5e5790f631eb 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -181,6 +181,22 @@
181 pinctrl-single,function-mask = <0xff1f>; 181 pinctrl-single,function-mask = <0xff1f>;
182 }; 182 };
183 183
184 omap3_scm_general: tisyscon@48002270 {
185 compatible = "syscon";
186 reg = <0x48002270 0x2f0>;
187 };
188
189 pbias_regulator: pbias_regulator {
190 compatible = "ti,pbias-omap";
191 reg = <0x2b0 0x4>;
192 syscon = <&omap3_scm_general>;
193 pbias_mmc_reg: pbias_mmc_omap2430 {
194 regulator-name = "pbias_mmc_omap2430";
195 regulator-min-microvolt = <1800000>;
196 regulator-max-microvolt = <3000000>;
197 };
198 };
199
184 gpio1: gpio@48310000 { 200 gpio1: gpio@48310000 {
185 compatible = "ti,omap3-gpio"; 201 compatible = "ti,omap3-gpio";
186 reg = <0x48310000 0x200>; 202 reg = <0x48310000 0x200>;
@@ -395,6 +411,7 @@
395 ti,dual-volt; 411 ti,dual-volt;
396 dmas = <&sdma 61>, <&sdma 62>; 412 dmas = <&sdma 61>, <&sdma 62>;
397 dma-names = "tx", "rx"; 413 dma-names = "tx", "rx";
414 pbias-supply = <&pbias_mmc_reg>;
398 }; 415 };
399 416
400 mmc2: mmc@480b4000 { 417 mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 2b4c1cbbce33..27fcac874742 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -191,6 +191,22 @@
191 pinctrl-single,function-mask = <0x7fff>; 191 pinctrl-single,function-mask = <0x7fff>;
192 }; 192 };
193 193
194 omap4_padconf_global: tisyscon@4a1005a0 {
195 compatible = "syscon";
196 reg = <0x4a1005a0 0x170>;
197 };
198
199 pbias_regulator: pbias_regulator {
200 compatible = "ti,pbias-omap";
201 reg = <0x60 0x4>;
202 syscon = <&omap4_padconf_global>;
203 pbias_mmc_reg: pbias_mmc_omap4 {
204 regulator-name = "pbias_mmc_omap4";
205 regulator-min-microvolt = <1800000>;
206 regulator-max-microvolt = <3000000>;
207 };
208 };
209
194 sdma: dma-controller@4a056000 { 210 sdma: dma-controller@4a056000 {
195 compatible = "ti,omap4430-sdma"; 211 compatible = "ti,omap4430-sdma";
196 reg = <0x4a056000 0x1000>; 212 reg = <0x4a056000 0x1000>;
@@ -427,6 +443,7 @@
427 ti,needs-special-reset; 443 ti,needs-special-reset;
428 dmas = <&sdma 61>, <&sdma 62>; 444 dmas = <&sdma 61>, <&sdma 62>;
429 dma-names = "tx", "rx"; 445 dma-names = "tx", "rx";
446 pbias-supply = <&pbias_mmc_reg>;
430 }; 447 };
431 448
432 mmc2: mmc@480b4000 { 449 mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 19155bb84835..6f3de22fb266 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -198,6 +198,22 @@
198 pinctrl-single,function-mask = <0x7fff>; 198 pinctrl-single,function-mask = <0x7fff>;
199 }; 199 };
200 200
201 omap5_padconf_global: tisyscon@4a002da0 {
202 compatible = "syscon";
203 reg = <0x4A002da0 0xec>;
204 };
205
206 pbias_regulator: pbias_regulator {
207 compatible = "ti,pbias-omap";
208 reg = <0x60 0x4>;
209 syscon = <&omap5_padconf_global>;
210 pbias_mmc_reg: pbias_mmc_omap5 {
211 regulator-name = "pbias_mmc_omap5";
212 regulator-min-microvolt = <1800000>;
213 regulator-max-microvolt = <3000000>;
214 };
215 };
216
201 sdma: dma-controller@4a056000 { 217 sdma: dma-controller@4a056000 {
202 compatible = "ti,omap4430-sdma"; 218 compatible = "ti,omap4430-sdma";
203 reg = <0x4a056000 0x1000>; 219 reg = <0x4a056000 0x1000>;
@@ -480,6 +496,7 @@
480 ti,needs-special-reset; 496 ti,needs-special-reset;
481 dmas = <&sdma 61>, <&sdma 62>; 497 dmas = <&sdma 61>, <&sdma 62>;
482 dma-names = "tx", "rx"; 498 dma-names = "tx", "rx";
499 pbias-supply = <&pbias_mmc_reg>;
483 }; 500 };
484 501
485 mmc2: mmc@480b4000 { 502 mmc2: mmc@480b4000 {
diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi
index 20145526cd7b..1e82571d6823 100644
--- a/arch/arm/boot/dts/prima2.dtsi
+++ b/arch/arm/boot/dts/prima2.dtsi
@@ -287,6 +287,7 @@
287 reg = <0xb00b0000 0x10000>; 287 reg = <0xb00b0000 0x10000>;
288 interrupts = <12>; 288 interrupts = <12>;
289 clocks = <&clks 24>; 289 clocks = <&clks 24>;
290 #dma-cells = <1>;
290 }; 291 };
291 292
292 dmac1: dma-controller@b0160000 { 293 dmac1: dma-controller@b0160000 {
@@ -295,6 +296,7 @@
295 reg = <0xb0160000 0x10000>; 296 reg = <0xb0160000 0x10000>;
296 interrupts = <13>; 297 interrupts = <13>;
297 clocks = <&clks 25>; 298 clocks = <&clks 25>;
299 #dma-cells = <1>;
298 }; 300 };
299 301
300 vip@b00C0000 { 302 vip@b00C0000 {
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 364ba38e40f3..a9667957b757 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -170,6 +170,7 @@ CONFIG_DRA752_THERMAL=y
170CONFIG_WATCHDOG=y 170CONFIG_WATCHDOG=y
171CONFIG_OMAP_WATCHDOG=y 171CONFIG_OMAP_WATCHDOG=y
172CONFIG_TWL4030_WATCHDOG=y 172CONFIG_TWL4030_WATCHDOG=y
173CONFIG_MFD_SYSCON=y
173CONFIG_MFD_PALMAS=y 174CONFIG_MFD_PALMAS=y
174CONFIG_MFD_TPS65217=y 175CONFIG_MFD_TPS65217=y
175CONFIG_MFD_TPS65910=y 176CONFIG_MFD_TPS65910=y
@@ -181,6 +182,7 @@ CONFIG_REGULATOR_TPS6507X=y
181CONFIG_REGULATOR_TPS65217=y 182CONFIG_REGULATOR_TPS65217=y
182CONFIG_REGULATOR_TPS65910=y 183CONFIG_REGULATOR_TPS65910=y
183CONFIG_REGULATOR_TWL4030=y 184CONFIG_REGULATOR_TWL4030=y
185CONFIG_REGULATOR_PBIAS=y
184CONFIG_FB=y 186CONFIG_FB=y
185CONFIG_FIRMWARE_EDID=y 187CONFIG_FIRMWARE_EDID=y
186CONFIG_FB_MODE_HELPERS=y 188CONFIG_FB_MODE_HELPERS=y
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 380ac4f20000..b974184f9941 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -23,6 +23,7 @@
23#include <asm/ptrace.h> 23#include <asm/ptrace.h>
24#include <asm/domain.h> 24#include <asm/domain.h>
25#include <asm/opcodes-virt.h> 25#include <asm/opcodes-virt.h>
26#include <asm/asm-offsets.h>
26 27
27#define IOMEM(x) (x) 28#define IOMEM(x) (x)
28 29
@@ -174,6 +175,47 @@
174 restore_irqs_notrace \oldcpsr 175 restore_irqs_notrace \oldcpsr
175 .endm 176 .endm
176 177
178/*
179 * Get current thread_info.
180 */
181 .macro get_thread_info, rd
182 ARM( mov \rd, sp, lsr #13 )
183 THUMB( mov \rd, sp )
184 THUMB( lsr \rd, \rd, #13 )
185 mov \rd, \rd, lsl #13
186 .endm
187
188/*
189 * Increment/decrement the preempt count.
190 */
191#ifdef CONFIG_PREEMPT_COUNT
192 .macro inc_preempt_count, ti, tmp
193 ldr \tmp, [\ti, #TI_PREEMPT] @ get preempt count
194 add \tmp, \tmp, #1 @ increment it
195 str \tmp, [\ti, #TI_PREEMPT]
196 .endm
197
198 .macro dec_preempt_count, ti, tmp
199 ldr \tmp, [\ti, #TI_PREEMPT] @ get preempt count
200 sub \tmp, \tmp, #1 @ decrement it
201 str \tmp, [\ti, #TI_PREEMPT]
202 .endm
203
204 .macro dec_preempt_count_ti, ti, tmp
205 get_thread_info \ti
206 dec_preempt_count \ti, \tmp
207 .endm
208#else
209 .macro inc_preempt_count, ti, tmp
210 .endm
211
212 .macro dec_preempt_count, ti, tmp
213 .endm
214
215 .macro dec_preempt_count_ti, ti, tmp
216 .endm
217#endif
218
177#define USER(x...) \ 219#define USER(x...) \
1789999: x; \ 2209999: x; \
179 .pushsection __ex_table,"a"; \ 221 .pushsection __ex_table,"a"; \
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index 42f0889f0584..c651e3b26ec7 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -221,4 +221,23 @@ static inline int cpu_is_xsc3(void)
221#define cpu_is_xscale() 1 221#define cpu_is_xscale() 1
222#endif 222#endif
223 223
224/*
225 * Marvell's PJ4 core is based on V7 version. It has some modification
226 * for coprocessor setting. For this reason, we need a way to distinguish
227 * it.
228 */
229#ifndef CONFIG_CPU_PJ4
230#define cpu_is_pj4() 0
231#else
232static inline int cpu_is_pj4(void)
233{
234 unsigned int id;
235
236 id = read_cpuid_id();
237 if ((id & 0xfffffff0) == 0x562f5840)
238 return 1;
239
240 return 0;
241}
242#endif
224#endif 243#endif
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index 73ddd7239b33..4651f6999b7d 100644
--- a/arch/arm/include/asm/syscall.h
+++ b/arch/arm/include/asm/syscall.h
@@ -7,7 +7,7 @@
7#ifndef _ASM_ARM_SYSCALL_H 7#ifndef _ASM_ARM_SYSCALL_H
8#define _ASM_ARM_SYSCALL_H 8#define _ASM_ARM_SYSCALL_H
9 9
10#include <linux/audit.h> /* for AUDIT_ARCH_* */ 10#include <uapi/linux/audit.h> /* for AUDIT_ARCH_* */
11#include <linux/elf.h> /* for ELF_EM */ 11#include <linux/elf.h> /* for ELF_EM */
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
@@ -103,8 +103,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
103 memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0])); 103 memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
104} 104}
105 105
106static inline int syscall_get_arch(struct task_struct *task, 106static inline int syscall_get_arch(void)
107 struct pt_regs *regs)
108{ 107{
109 /* ARM tasks don't change audit architectures on the fly. */ 108 /* ARM tasks don't change audit architectures on the fly. */
110 return AUDIT_ARCH_ARM; 109 return AUDIT_ARCH_ARM;
diff --git a/arch/arm/kernel/crash_dump.c b/arch/arm/kernel/crash_dump.c
index 90c50d4b43f7..5d1286d51154 100644
--- a/arch/arm/kernel/crash_dump.c
+++ b/arch/arm/kernel/crash_dump.c
@@ -39,7 +39,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
39 if (!csize) 39 if (!csize)
40 return 0; 40 return 0;
41 41
42 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); 42 vaddr = ioremap(__pfn_to_phys(pfn), PAGE_SIZE);
43 if (!vaddr) 43 if (!vaddr)
44 return -ENOMEM; 44 return -ENOMEM;
45 45
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 39f89fbd5111..1420725142ca 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -236,11 +236,6 @@
236 movs pc, lr @ return & move spsr_svc into cpsr 236 movs pc, lr @ return & move spsr_svc into cpsr
237 .endm 237 .endm
238 238
239 .macro get_thread_info, rd
240 mov \rd, sp, lsr #13
241 mov \rd, \rd, lsl #13
242 .endm
243
244 @ 239 @
245 @ 32-bit wide "mov pc, reg" 240 @ 32-bit wide "mov pc, reg"
246 @ 241 @
@@ -306,12 +301,6 @@
306 .endm 301 .endm
307#endif /* ifdef CONFIG_CPU_V7M / else */ 302#endif /* ifdef CONFIG_CPU_V7M / else */
308 303
309 .macro get_thread_info, rd
310 mov \rd, sp
311 lsr \rd, \rd, #13
312 mov \rd, \rd, lsl #13
313 .endm
314
315 @ 304 @
316 @ 32-bit wide "mov pc, reg" 305 @ 32-bit wide "mov pc, reg"
317 @ 306 @
diff --git a/arch/arm/kernel/kprobes-common.c b/arch/arm/kernel/kprobes-common.c
index c311ed94ff1c..0bf5d64eba1d 100644
--- a/arch/arm/kernel/kprobes-common.c
+++ b/arch/arm/kernel/kprobes-common.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/kprobes.h> 15#include <linux/kprobes.h>
16#include <asm/opcodes.h>
16 17
17#include "kprobes.h" 18#include "kprobes.h"
18 19
@@ -153,7 +154,8 @@ kprobe_decode_ldmstm(probes_opcode_t insn, struct arch_probes_insn *asi,
153 154
154 if (handler) { 155 if (handler) {
155 /* We can emulate the instruction in (possibly) modified form */ 156 /* We can emulate the instruction in (possibly) modified form */
156 asi->insn[0] = (insn & 0xfff00000) | (rn << 16) | reglist; 157 asi->insn[0] = __opcode_to_mem_arm((insn & 0xfff00000) |
158 (rn << 16) | reglist);
157 asi->insn_handler = handler; 159 asi->insn_handler = handler;
158 return INSN_GOOD; 160 return INSN_GOOD;
159 } 161 }
diff --git a/arch/arm/kernel/kprobes-test-arm.c b/arch/arm/kernel/kprobes-test-arm.c
index 87839de77e5f..9db4b659d03e 100644
--- a/arch/arm/kernel/kprobes-test-arm.c
+++ b/arch/arm/kernel/kprobes-test-arm.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <asm/system_info.h> 13#include <asm/system_info.h>
14#include <asm/opcodes.h>
14 15
15#include "kprobes-test.h" 16#include "kprobes-test.h"
16 17
@@ -159,9 +160,9 @@ void kprobe_arm_test_cases(void)
159 TEST_SUPPORTED("cmp sp, #0x1000"); 160 TEST_SUPPORTED("cmp sp, #0x1000");
160 161
161 /* Data-processing with PC as shift*/ 162 /* Data-processing with PC as shift*/
162 TEST_UNSUPPORTED(".word 0xe15c0f1e @ cmp r12, r14, asl pc") 163 TEST_UNSUPPORTED(__inst_arm(0xe15c0f1e) " @ cmp r12, r14, asl pc")
163 TEST_UNSUPPORTED(".word 0xe1a0cf1e @ mov r12, r14, asl pc") 164 TEST_UNSUPPORTED(__inst_arm(0xe1a0cf1e) " @ mov r12, r14, asl pc")
164 TEST_UNSUPPORTED(".word 0xe08caf1e @ add r10, r12, r14, asl pc") 165 TEST_UNSUPPORTED(__inst_arm(0xe08caf1e) " @ add r10, r12, r14, asl pc")
165 166
166 /* Data-processing with PC as shift*/ 167 /* Data-processing with PC as shift*/
167 TEST_UNSUPPORTED("movs pc, r1") 168 TEST_UNSUPPORTED("movs pc, r1")
@@ -203,7 +204,7 @@ void kprobe_arm_test_cases(void)
203 TEST("mrs r0, cpsr") 204 TEST("mrs r0, cpsr")
204 TEST("mrspl r7, cpsr") 205 TEST("mrspl r7, cpsr")
205 TEST("mrs r14, cpsr") 206 TEST("mrs r14, cpsr")
206 TEST_UNSUPPORTED(".word 0xe10ff000 @ mrs r15, cpsr") 207 TEST_UNSUPPORTED(__inst_arm(0xe10ff000) " @ mrs r15, cpsr")
207 TEST_UNSUPPORTED("mrs r0, spsr") 208 TEST_UNSUPPORTED("mrs r0, spsr")
208 TEST_UNSUPPORTED("mrs lr, spsr") 209 TEST_UNSUPPORTED("mrs lr, spsr")
209 210
@@ -219,8 +220,8 @@ void kprobe_arm_test_cases(void)
219 TEST_R("clzeq r7, r",14,0x1,"") 220 TEST_R("clzeq r7, r",14,0x1,"")
220 TEST_R("clz lr, r",7, 0xffffffff,"") 221 TEST_R("clz lr, r",7, 0xffffffff,"")
221 TEST( "clz r4, sp") 222 TEST( "clz r4, sp")
222 TEST_UNSUPPORTED(".word 0x016fff10 @ clz pc, r0") 223 TEST_UNSUPPORTED(__inst_arm(0x016fff10) " @ clz pc, r0")
223 TEST_UNSUPPORTED(".word 0x016f0f1f @ clz r0, pc") 224 TEST_UNSUPPORTED(__inst_arm(0x016f0f1f) " @ clz r0, pc")
224 225
225#if __LINUX_ARM_ARCH__ >= 6 226#if __LINUX_ARM_ARCH__ >= 6
226 TEST_UNSUPPORTED("bxj r0") 227 TEST_UNSUPPORTED("bxj r0")
@@ -229,7 +230,7 @@ void kprobe_arm_test_cases(void)
229 TEST_BF_R("blx r",0,2f,"") 230 TEST_BF_R("blx r",0,2f,"")
230 TEST_BB_R("blx r",7,2f,"") 231 TEST_BB_R("blx r",7,2f,"")
231 TEST_BF_R("blxeq r",14,2f,"") 232 TEST_BF_R("blxeq r",14,2f,"")
232 TEST_UNSUPPORTED(".word 0x0120003f @ blx pc") 233 TEST_UNSUPPORTED(__inst_arm(0x0120003f) " @ blx pc")
233 234
234 TEST_RR( "qadd r0, r",1, VAL1,", r",2, VAL2,"") 235 TEST_RR( "qadd r0, r",1, VAL1,", r",2, VAL2,"")
235 TEST_RR( "qaddvs lr, r",9, VAL2,", r",8, VAL1,"") 236 TEST_RR( "qaddvs lr, r",9, VAL2,", r",8, VAL1,"")
@@ -243,190 +244,190 @@ void kprobe_arm_test_cases(void)
243 TEST_RR( "qdsub r0, r",1, VAL1,", r",2, VAL2,"") 244 TEST_RR( "qdsub r0, r",1, VAL1,", r",2, VAL2,"")
244 TEST_RR( "qdsubvs lr, r",9, VAL2,", r",8, VAL1,"") 245 TEST_RR( "qdsubvs lr, r",9, VAL2,", r",8, VAL1,"")
245 TEST_R( "qdsub lr, r",9, VAL2,", r13") 246 TEST_R( "qdsub lr, r",9, VAL2,", r13")
246 TEST_UNSUPPORTED(".word 0xe101f050 @ qadd pc, r0, r1") 247 TEST_UNSUPPORTED(__inst_arm(0xe101f050) " @ qadd pc, r0, r1")
247 TEST_UNSUPPORTED(".word 0xe121f050 @ qsub pc, r0, r1") 248 TEST_UNSUPPORTED(__inst_arm(0xe121f050) " @ qsub pc, r0, r1")
248 TEST_UNSUPPORTED(".word 0xe141f050 @ qdadd pc, r0, r1") 249 TEST_UNSUPPORTED(__inst_arm(0xe141f050) " @ qdadd pc, r0, r1")
249 TEST_UNSUPPORTED(".word 0xe161f050 @ qdsub pc, r0, r1") 250 TEST_UNSUPPORTED(__inst_arm(0xe161f050) " @ qdsub pc, r0, r1")
250 TEST_UNSUPPORTED(".word 0xe16f2050 @ qdsub r2, r0, pc") 251 TEST_UNSUPPORTED(__inst_arm(0xe16f2050) " @ qdsub r2, r0, pc")
251 TEST_UNSUPPORTED(".word 0xe161205f @ qdsub r2, pc, r1") 252 TEST_UNSUPPORTED(__inst_arm(0xe161205f) " @ qdsub r2, pc, r1")
252 253
253 TEST_UNSUPPORTED("bkpt 0xffff") 254 TEST_UNSUPPORTED("bkpt 0xffff")
254 TEST_UNSUPPORTED("bkpt 0x0000") 255 TEST_UNSUPPORTED("bkpt 0x0000")
255 256
256 TEST_UNSUPPORTED(".word 0xe1600070 @ smc #0") 257 TEST_UNSUPPORTED(__inst_arm(0xe1600070) " @ smc #0")
257 258
258 TEST_GROUP("Halfword multiply and multiply-accumulate") 259 TEST_GROUP("Halfword multiply and multiply-accumulate")
259 260
260 TEST_RRR( "smlabb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 261 TEST_RRR( "smlabb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
261 TEST_RRR( "smlabbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 262 TEST_RRR( "smlabbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
262 TEST_RR( "smlabb lr, r",1, VAL2,", r",2, VAL3,", r13") 263 TEST_RR( "smlabb lr, r",1, VAL2,", r",2, VAL3,", r13")
263 TEST_UNSUPPORTED(".word 0xe10f3281 @ smlabb pc, r1, r2, r3") 264 TEST_UNSUPPORTED(__inst_arm(0xe10f3281) " @ smlabb pc, r1, r2, r3")
264 TEST_RRR( "smlatb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 265 TEST_RRR( "smlatb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
265 TEST_RRR( "smlatbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 266 TEST_RRR( "smlatbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
266 TEST_RR( "smlatb lr, r",1, VAL2,", r",2, VAL3,", r13") 267 TEST_RR( "smlatb lr, r",1, VAL2,", r",2, VAL3,", r13")
267 TEST_UNSUPPORTED(".word 0xe10f32a1 @ smlatb pc, r1, r2, r3") 268 TEST_UNSUPPORTED(__inst_arm(0xe10f32a1) " @ smlatb pc, r1, r2, r3")
268 TEST_RRR( "smlabt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 269 TEST_RRR( "smlabt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
269 TEST_RRR( "smlabtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 270 TEST_RRR( "smlabtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
270 TEST_RR( "smlabt lr, r",1, VAL2,", r",2, VAL3,", r13") 271 TEST_RR( "smlabt lr, r",1, VAL2,", r",2, VAL3,", r13")
271 TEST_UNSUPPORTED(".word 0xe10f32c1 @ smlabt pc, r1, r2, r3") 272 TEST_UNSUPPORTED(__inst_arm(0xe10f32c1) " @ smlabt pc, r1, r2, r3")
272 TEST_RRR( "smlatt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 273 TEST_RRR( "smlatt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
273 TEST_RRR( "smlattge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 274 TEST_RRR( "smlattge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
274 TEST_RR( "smlatt lr, r",1, VAL2,", r",2, VAL3,", r13") 275 TEST_RR( "smlatt lr, r",1, VAL2,", r",2, VAL3,", r13")
275 TEST_UNSUPPORTED(".word 0xe10f32e1 @ smlatt pc, r1, r2, r3") 276 TEST_UNSUPPORTED(__inst_arm(0xe10f32e1) " @ smlatt pc, r1, r2, r3")
276 277
277 TEST_RRR( "smlawb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 278 TEST_RRR( "smlawb r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
278 TEST_RRR( "smlawbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 279 TEST_RRR( "smlawbge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
279 TEST_RR( "smlawb lr, r",1, VAL2,", r",2, VAL3,", r13") 280 TEST_RR( "smlawb lr, r",1, VAL2,", r",2, VAL3,", r13")
280 TEST_UNSUPPORTED(".word 0xe12f3281 @ smlawb pc, r1, r2, r3") 281 TEST_UNSUPPORTED(__inst_arm(0xe12f3281) " @ smlawb pc, r1, r2, r3")
281 TEST_RRR( "smlawt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 282 TEST_RRR( "smlawt r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
282 TEST_RRR( "smlawtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 283 TEST_RRR( "smlawtge r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
283 TEST_RR( "smlawt lr, r",1, VAL2,", r",2, VAL3,", r13") 284 TEST_RR( "smlawt lr, r",1, VAL2,", r",2, VAL3,", r13")
284 TEST_UNSUPPORTED(".word 0xe12f32c1 @ smlawt pc, r1, r2, r3") 285 TEST_UNSUPPORTED(__inst_arm(0xe12f32c1) " @ smlawt pc, r1, r2, r3")
285 TEST_UNSUPPORTED(".word 0xe12032cf @ smlawt r0, pc, r2, r3") 286 TEST_UNSUPPORTED(__inst_arm(0xe12032cf) " @ smlawt r0, pc, r2, r3")
286 TEST_UNSUPPORTED(".word 0xe1203fc1 @ smlawt r0, r1, pc, r3") 287 TEST_UNSUPPORTED(__inst_arm(0xe1203fc1) " @ smlawt r0, r1, pc, r3")
287 TEST_UNSUPPORTED(".word 0xe120f2c1 @ smlawt r0, r1, r2, pc") 288 TEST_UNSUPPORTED(__inst_arm(0xe120f2c1) " @ smlawt r0, r1, r2, pc")
288 289
289 TEST_RR( "smulwb r0, r",1, VAL1,", r",2, VAL2,"") 290 TEST_RR( "smulwb r0, r",1, VAL1,", r",2, VAL2,"")
290 TEST_RR( "smulwbge r7, r",8, VAL3,", r",9, VAL1,"") 291 TEST_RR( "smulwbge r7, r",8, VAL3,", r",9, VAL1,"")
291 TEST_R( "smulwb lr, r",1, VAL2,", r13") 292 TEST_R( "smulwb lr, r",1, VAL2,", r13")
292 TEST_UNSUPPORTED(".word 0xe12f02a1 @ smulwb pc, r1, r2") 293 TEST_UNSUPPORTED(__inst_arm(0xe12f02a1) " @ smulwb pc, r1, r2")
293 TEST_RR( "smulwt r0, r",1, VAL1,", r",2, VAL2,"") 294 TEST_RR( "smulwt r0, r",1, VAL1,", r",2, VAL2,"")
294 TEST_RR( "smulwtge r7, r",8, VAL3,", r",9, VAL1,"") 295 TEST_RR( "smulwtge r7, r",8, VAL3,", r",9, VAL1,"")
295 TEST_R( "smulwt lr, r",1, VAL2,", r13") 296 TEST_R( "smulwt lr, r",1, VAL2,", r13")
296 TEST_UNSUPPORTED(".word 0xe12f02e1 @ smulwt pc, r1, r2") 297 TEST_UNSUPPORTED(__inst_arm(0xe12f02e1) " @ smulwt pc, r1, r2")
297 298
298 TEST_RRRR( "smlalbb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 299 TEST_RRRR( "smlalbb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
299 TEST_RRRR( "smlalbble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 300 TEST_RRRR( "smlalbble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
300 TEST_RRR( "smlalbb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 301 TEST_RRR( "smlalbb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
301 TEST_UNSUPPORTED(".word 0xe14f1382 @ smlalbb pc, r1, r2, r3") 302 TEST_UNSUPPORTED(__inst_arm(0xe14f1382) " @ smlalbb pc, r1, r2, r3")
302 TEST_UNSUPPORTED(".word 0xe141f382 @ smlalbb r1, pc, r2, r3") 303 TEST_UNSUPPORTED(__inst_arm(0xe141f382) " @ smlalbb r1, pc, r2, r3")
303 TEST_RRRR( "smlaltb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 304 TEST_RRRR( "smlaltb r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
304 TEST_RRRR( "smlaltble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 305 TEST_RRRR( "smlaltble r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
305 TEST_RRR( "smlaltb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 306 TEST_RRR( "smlaltb r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
306 TEST_UNSUPPORTED(".word 0xe14f13a2 @ smlaltb pc, r1, r2, r3") 307 TEST_UNSUPPORTED(__inst_arm(0xe14f13a2) " @ smlaltb pc, r1, r2, r3")
307 TEST_UNSUPPORTED(".word 0xe141f3a2 @ smlaltb r1, pc, r2, r3") 308 TEST_UNSUPPORTED(__inst_arm(0xe141f3a2) " @ smlaltb r1, pc, r2, r3")
308 TEST_RRRR( "smlalbt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 309 TEST_RRRR( "smlalbt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
309 TEST_RRRR( "smlalbtle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 310 TEST_RRRR( "smlalbtle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
310 TEST_RRR( "smlalbt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 311 TEST_RRR( "smlalbt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
311 TEST_UNSUPPORTED(".word 0xe14f13c2 @ smlalbt pc, r1, r2, r3") 312 TEST_UNSUPPORTED(__inst_arm(0xe14f13c2) " @ smlalbt pc, r1, r2, r3")
312 TEST_UNSUPPORTED(".word 0xe141f3c2 @ smlalbt r1, pc, r2, r3") 313 TEST_UNSUPPORTED(__inst_arm(0xe141f3c2) " @ smlalbt r1, pc, r2, r3")
313 TEST_RRRR( "smlaltt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 314 TEST_RRRR( "smlaltt r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
314 TEST_RRRR( "smlalttle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 315 TEST_RRRR( "smlalttle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
315 TEST_RRR( "smlaltt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 316 TEST_RRR( "smlaltt r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
316 TEST_UNSUPPORTED(".word 0xe14f13e2 @ smlalbb pc, r1, r2, r3") 317 TEST_UNSUPPORTED(__inst_arm(0xe14f13e2) " @ smlalbb pc, r1, r2, r3")
317 TEST_UNSUPPORTED(".word 0xe140f3e2 @ smlalbb r0, pc, r2, r3") 318 TEST_UNSUPPORTED(__inst_arm(0xe140f3e2) " @ smlalbb r0, pc, r2, r3")
318 TEST_UNSUPPORTED(".word 0xe14013ef @ smlalbb r0, r1, pc, r3") 319 TEST_UNSUPPORTED(__inst_arm(0xe14013ef) " @ smlalbb r0, r1, pc, r3")
319 TEST_UNSUPPORTED(".word 0xe1401fe2 @ smlalbb r0, r1, r2, pc") 320 TEST_UNSUPPORTED(__inst_arm(0xe1401fe2) " @ smlalbb r0, r1, r2, pc")
320 321
321 TEST_RR( "smulbb r0, r",1, VAL1,", r",2, VAL2,"") 322 TEST_RR( "smulbb r0, r",1, VAL1,", r",2, VAL2,"")
322 TEST_RR( "smulbbge r7, r",8, VAL3,", r",9, VAL1,"") 323 TEST_RR( "smulbbge r7, r",8, VAL3,", r",9, VAL1,"")
323 TEST_R( "smulbb lr, r",1, VAL2,", r13") 324 TEST_R( "smulbb lr, r",1, VAL2,", r13")
324 TEST_UNSUPPORTED(".word 0xe16f0281 @ smulbb pc, r1, r2") 325 TEST_UNSUPPORTED(__inst_arm(0xe16f0281) " @ smulbb pc, r1, r2")
325 TEST_RR( "smultb r0, r",1, VAL1,", r",2, VAL2,"") 326 TEST_RR( "smultb r0, r",1, VAL1,", r",2, VAL2,"")
326 TEST_RR( "smultbge r7, r",8, VAL3,", r",9, VAL1,"") 327 TEST_RR( "smultbge r7, r",8, VAL3,", r",9, VAL1,"")
327 TEST_R( "smultb lr, r",1, VAL2,", r13") 328 TEST_R( "smultb lr, r",1, VAL2,", r13")
328 TEST_UNSUPPORTED(".word 0xe16f02a1 @ smultb pc, r1, r2") 329 TEST_UNSUPPORTED(__inst_arm(0xe16f02a1) " @ smultb pc, r1, r2")
329 TEST_RR( "smulbt r0, r",1, VAL1,", r",2, VAL2,"") 330 TEST_RR( "smulbt r0, r",1, VAL1,", r",2, VAL2,"")
330 TEST_RR( "smulbtge r7, r",8, VAL3,", r",9, VAL1,"") 331 TEST_RR( "smulbtge r7, r",8, VAL3,", r",9, VAL1,"")
331 TEST_R( "smulbt lr, r",1, VAL2,", r13") 332 TEST_R( "smulbt lr, r",1, VAL2,", r13")
332 TEST_UNSUPPORTED(".word 0xe16f02c1 @ smultb pc, r1, r2") 333 TEST_UNSUPPORTED(__inst_arm(0xe16f02c1) " @ smultb pc, r1, r2")
333 TEST_RR( "smultt r0, r",1, VAL1,", r",2, VAL2,"") 334 TEST_RR( "smultt r0, r",1, VAL1,", r",2, VAL2,"")
334 TEST_RR( "smulttge r7, r",8, VAL3,", r",9, VAL1,"") 335 TEST_RR( "smulttge r7, r",8, VAL3,", r",9, VAL1,"")
335 TEST_R( "smultt lr, r",1, VAL2,", r13") 336 TEST_R( "smultt lr, r",1, VAL2,", r13")
336 TEST_UNSUPPORTED(".word 0xe16f02e1 @ smultt pc, r1, r2") 337 TEST_UNSUPPORTED(__inst_arm(0xe16f02e1) " @ smultt pc, r1, r2")
337 TEST_UNSUPPORTED(".word 0xe16002ef @ smultt r0, pc, r2") 338 TEST_UNSUPPORTED(__inst_arm(0xe16002ef) " @ smultt r0, pc, r2")
338 TEST_UNSUPPORTED(".word 0xe1600fe1 @ smultt r0, r1, pc") 339 TEST_UNSUPPORTED(__inst_arm(0xe1600fe1) " @ smultt r0, r1, pc")
339 340
340 TEST_GROUP("Multiply and multiply-accumulate") 341 TEST_GROUP("Multiply and multiply-accumulate")
341 342
342 TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"") 343 TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"")
343 TEST_RR( "mulls r7, r",8, VAL2,", r",9, VAL2,"") 344 TEST_RR( "mulls r7, r",8, VAL2,", r",9, VAL2,"")
344 TEST_R( "mul lr, r",4, VAL3,", r13") 345 TEST_R( "mul lr, r",4, VAL3,", r13")
345 TEST_UNSUPPORTED(".word 0xe00f0291 @ mul pc, r1, r2") 346 TEST_UNSUPPORTED(__inst_arm(0xe00f0291) " @ mul pc, r1, r2")
346 TEST_UNSUPPORTED(".word 0xe000029f @ mul r0, pc, r2") 347 TEST_UNSUPPORTED(__inst_arm(0xe000029f) " @ mul r0, pc, r2")
347 TEST_UNSUPPORTED(".word 0xe0000f91 @ mul r0, r1, pc") 348 TEST_UNSUPPORTED(__inst_arm(0xe0000f91) " @ mul r0, r1, pc")
348 TEST_RR( "muls r0, r",1, VAL1,", r",2, VAL2,"") 349 TEST_RR( "muls r0, r",1, VAL1,", r",2, VAL2,"")
349 TEST_RR( "mullss r7, r",8, VAL2,", r",9, VAL2,"") 350 TEST_RR( "mullss r7, r",8, VAL2,", r",9, VAL2,"")
350 TEST_R( "muls lr, r",4, VAL3,", r13") 351 TEST_R( "muls lr, r",4, VAL3,", r13")
351 TEST_UNSUPPORTED(".word 0xe01f0291 @ muls pc, r1, r2") 352 TEST_UNSUPPORTED(__inst_arm(0xe01f0291) " @ muls pc, r1, r2")
352 353
353 TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 354 TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
354 TEST_RRR( "mlahi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 355 TEST_RRR( "mlahi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
355 TEST_RR( "mla lr, r",1, VAL2,", r",2, VAL3,", r13") 356 TEST_RR( "mla lr, r",1, VAL2,", r",2, VAL3,", r13")
356 TEST_UNSUPPORTED(".word 0xe02f3291 @ mla pc, r1, r2, r3") 357 TEST_UNSUPPORTED(__inst_arm(0xe02f3291) " @ mla pc, r1, r2, r3")
357 TEST_RRR( "mlas r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 358 TEST_RRR( "mlas r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
358 TEST_RRR( "mlahis r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 359 TEST_RRR( "mlahis r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
359 TEST_RR( "mlas lr, r",1, VAL2,", r",2, VAL3,", r13") 360 TEST_RR( "mlas lr, r",1, VAL2,", r",2, VAL3,", r13")
360 TEST_UNSUPPORTED(".word 0xe03f3291 @ mlas pc, r1, r2, r3") 361 TEST_UNSUPPORTED(__inst_arm(0xe03f3291) " @ mlas pc, r1, r2, r3")
361 362
362#if __LINUX_ARM_ARCH__ >= 6 363#if __LINUX_ARM_ARCH__ >= 6
363 TEST_RR( "umaal r0, r1, r",2, VAL1,", r",3, VAL2,"") 364 TEST_RR( "umaal r0, r1, r",2, VAL1,", r",3, VAL2,"")
364 TEST_RR( "umaalls r7, r8, r",9, VAL2,", r",10, VAL1,"") 365 TEST_RR( "umaalls r7, r8, r",9, VAL2,", r",10, VAL1,"")
365 TEST_R( "umaal lr, r12, r",11,VAL3,", r13") 366 TEST_R( "umaal lr, r12, r",11,VAL3,", r13")
366 TEST_UNSUPPORTED(".word 0xe041f392 @ umaal pc, r1, r2, r3") 367 TEST_UNSUPPORTED(__inst_arm(0xe041f392) " @ umaal pc, r1, r2, r3")
367 TEST_UNSUPPORTED(".word 0xe04f0392 @ umaal r0, pc, r2, r3") 368 TEST_UNSUPPORTED(__inst_arm(0xe04f0392) " @ umaal r0, pc, r2, r3")
368 TEST_UNSUPPORTED(".word 0xe0500090 @ undef") 369 TEST_UNSUPPORTED(__inst_arm(0xe0500090) " @ undef")
369 TEST_UNSUPPORTED(".word 0xe05fff9f @ undef") 370 TEST_UNSUPPORTED(__inst_arm(0xe05fff9f) " @ undef")
370#endif 371#endif
371 372
372#if __LINUX_ARM_ARCH__ >= 7 373#if __LINUX_ARM_ARCH__ >= 7
373 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 374 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
374 TEST_RRR( "mlshi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 375 TEST_RRR( "mlshi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
375 TEST_RR( "mls lr, r",1, VAL2,", r",2, VAL3,", r13") 376 TEST_RR( "mls lr, r",1, VAL2,", r",2, VAL3,", r13")
376 TEST_UNSUPPORTED(".word 0xe06f3291 @ mls pc, r1, r2, r3") 377 TEST_UNSUPPORTED(__inst_arm(0xe06f3291) " @ mls pc, r1, r2, r3")
377 TEST_UNSUPPORTED(".word 0xe060329f @ mls r0, pc, r2, r3") 378 TEST_UNSUPPORTED(__inst_arm(0xe060329f) " @ mls r0, pc, r2, r3")
378 TEST_UNSUPPORTED(".word 0xe0603f91 @ mls r0, r1, pc, r3") 379 TEST_UNSUPPORTED(__inst_arm(0xe0603f91) " @ mls r0, r1, pc, r3")
379 TEST_UNSUPPORTED(".word 0xe060f291 @ mls r0, r1, r2, pc") 380 TEST_UNSUPPORTED(__inst_arm(0xe060f291) " @ mls r0, r1, r2, pc")
380#endif 381#endif
381 382
382 TEST_UNSUPPORTED(".word 0xe0700090 @ undef") 383 TEST_UNSUPPORTED(__inst_arm(0xe0700090) " @ undef")
383 TEST_UNSUPPORTED(".word 0xe07fff9f @ undef") 384 TEST_UNSUPPORTED(__inst_arm(0xe07fff9f) " @ undef")
384 385
385 TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"") 386 TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"")
386 TEST_RR( "umullls r7, r8, r",9, VAL2,", r",10, VAL1,"") 387 TEST_RR( "umullls r7, r8, r",9, VAL2,", r",10, VAL1,"")
387 TEST_R( "umull lr, r12, r",11,VAL3,", r13") 388 TEST_R( "umull lr, r12, r",11,VAL3,", r13")
388 TEST_UNSUPPORTED(".word 0xe081f392 @ umull pc, r1, r2, r3") 389 TEST_UNSUPPORTED(__inst_arm(0xe081f392) " @ umull pc, r1, r2, r3")
389 TEST_UNSUPPORTED(".word 0xe08f1392 @ umull r1, pc, r2, r3") 390 TEST_UNSUPPORTED(__inst_arm(0xe08f1392) " @ umull r1, pc, r2, r3")
390 TEST_RR( "umulls r0, r1, r",2, VAL1,", r",3, VAL2,"") 391 TEST_RR( "umulls r0, r1, r",2, VAL1,", r",3, VAL2,"")
391 TEST_RR( "umulllss r7, r8, r",9, VAL2,", r",10, VAL1,"") 392 TEST_RR( "umulllss r7, r8, r",9, VAL2,", r",10, VAL1,"")
392 TEST_R( "umulls lr, r12, r",11,VAL3,", r13") 393 TEST_R( "umulls lr, r12, r",11,VAL3,", r13")
393 TEST_UNSUPPORTED(".word 0xe091f392 @ umulls pc, r1, r2, r3") 394 TEST_UNSUPPORTED(__inst_arm(0xe091f392) " @ umulls pc, r1, r2, r3")
394 TEST_UNSUPPORTED(".word 0xe09f1392 @ umulls r1, pc, r2, r3") 395 TEST_UNSUPPORTED(__inst_arm(0xe09f1392) " @ umulls r1, pc, r2, r3")
395 396
396 TEST_RRRR( "umlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 397 TEST_RRRR( "umlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
397 TEST_RRRR( "umlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 398 TEST_RRRR( "umlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
398 TEST_RRR( "umlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 399 TEST_RRR( "umlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
399 TEST_UNSUPPORTED(".word 0xe0af1392 @ umlal pc, r1, r2, r3") 400 TEST_UNSUPPORTED(__inst_arm(0xe0af1392) " @ umlal pc, r1, r2, r3")
400 TEST_UNSUPPORTED(".word 0xe0a1f392 @ umlal r1, pc, r2, r3") 401 TEST_UNSUPPORTED(__inst_arm(0xe0a1f392) " @ umlal r1, pc, r2, r3")
401 TEST_RRRR( "umlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 402 TEST_RRRR( "umlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
402 TEST_RRRR( "umlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 403 TEST_RRRR( "umlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
403 TEST_RRR( "umlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 404 TEST_RRR( "umlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
404 TEST_UNSUPPORTED(".word 0xe0bf1392 @ umlals pc, r1, r2, r3") 405 TEST_UNSUPPORTED(__inst_arm(0xe0bf1392) " @ umlals pc, r1, r2, r3")
405 TEST_UNSUPPORTED(".word 0xe0b1f392 @ umlals r1, pc, r2, r3") 406 TEST_UNSUPPORTED(__inst_arm(0xe0b1f392) " @ umlals r1, pc, r2, r3")
406 407
407 TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"") 408 TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"")
408 TEST_RR( "smullls r7, r8, r",9, VAL2,", r",10, VAL1,"") 409 TEST_RR( "smullls r7, r8, r",9, VAL2,", r",10, VAL1,"")
409 TEST_R( "smull lr, r12, r",11,VAL3,", r13") 410 TEST_R( "smull lr, r12, r",11,VAL3,", r13")
410 TEST_UNSUPPORTED(".word 0xe0c1f392 @ smull pc, r1, r2, r3") 411 TEST_UNSUPPORTED(__inst_arm(0xe0c1f392) " @ smull pc, r1, r2, r3")
411 TEST_UNSUPPORTED(".word 0xe0cf1392 @ smull r1, pc, r2, r3") 412 TEST_UNSUPPORTED(__inst_arm(0xe0cf1392) " @ smull r1, pc, r2, r3")
412 TEST_RR( "smulls r0, r1, r",2, VAL1,", r",3, VAL2,"") 413 TEST_RR( "smulls r0, r1, r",2, VAL1,", r",3, VAL2,"")
413 TEST_RR( "smulllss r7, r8, r",9, VAL2,", r",10, VAL1,"") 414 TEST_RR( "smulllss r7, r8, r",9, VAL2,", r",10, VAL1,"")
414 TEST_R( "smulls lr, r12, r",11,VAL3,", r13") 415 TEST_R( "smulls lr, r12, r",11,VAL3,", r13")
415 TEST_UNSUPPORTED(".word 0xe0d1f392 @ smulls pc, r1, r2, r3") 416 TEST_UNSUPPORTED(__inst_arm(0xe0d1f392) " @ smulls pc, r1, r2, r3")
416 TEST_UNSUPPORTED(".word 0xe0df1392 @ smulls r1, pc, r2, r3") 417 TEST_UNSUPPORTED(__inst_arm(0xe0df1392) " @ smulls r1, pc, r2, r3")
417 418
418 TEST_RRRR( "smlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 419 TEST_RRRR( "smlal r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
419 TEST_RRRR( "smlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 420 TEST_RRRR( "smlalle r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
420 TEST_RRR( "smlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 421 TEST_RRR( "smlal r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
421 TEST_UNSUPPORTED(".word 0xe0ef1392 @ smlal pc, r1, r2, r3") 422 TEST_UNSUPPORTED(__inst_arm(0xe0ef1392) " @ smlal pc, r1, r2, r3")
422 TEST_UNSUPPORTED(".word 0xe0e1f392 @ smlal r1, pc, r2, r3") 423 TEST_UNSUPPORTED(__inst_arm(0xe0e1f392) " @ smlal r1, pc, r2, r3")
423 TEST_RRRR( "smlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4) 424 TEST_RRRR( "smlals r",0, VAL1,", r",1, VAL2,", r",2, VAL3,", r",3, VAL4)
424 TEST_RRRR( "smlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3) 425 TEST_RRRR( "smlalles r",8, VAL4,", r",9, VAL1,", r",10,VAL2,", r",11,VAL3)
425 TEST_RRR( "smlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13") 426 TEST_RRR( "smlals r",14,VAL3,", r",7, VAL4,", r",5, VAL1,", r13")
426 TEST_UNSUPPORTED(".word 0xe0ff1392 @ smlals pc, r1, r2, r3") 427 TEST_UNSUPPORTED(__inst_arm(0xe0ff1392) " @ smlals pc, r1, r2, r3")
427 TEST_UNSUPPORTED(".word 0xe0f0f392 @ smlals r0, pc, r2, r3") 428 TEST_UNSUPPORTED(__inst_arm(0xe0f0f392) " @ smlals r0, pc, r2, r3")
428 TEST_UNSUPPORTED(".word 0xe0f0139f @ smlals r0, r1, pc, r3") 429 TEST_UNSUPPORTED(__inst_arm(0xe0f0139f) " @ smlals r0, r1, pc, r3")
429 TEST_UNSUPPORTED(".word 0xe0f01f92 @ smlals r0, r1, r2, pc") 430 TEST_UNSUPPORTED(__inst_arm(0xe0f01f92) " @ smlals r0, r1, r2, pc")
430 431
431 TEST_GROUP("Synchronization primitives") 432 TEST_GROUP("Synchronization primitives")
432 433
@@ -435,28 +436,28 @@ void kprobe_arm_test_cases(void)
435 TEST_R( "swpvs r0, r",1,VAL1,", [sp]") 436 TEST_R( "swpvs r0, r",1,VAL1,", [sp]")
436 TEST_RP("swp sp, r",14,VAL2,", [r",12,13*4,"]") 437 TEST_RP("swp sp, r",14,VAL2,", [r",12,13*4,"]")
437#else 438#else
438 TEST_UNSUPPORTED(".word 0xe108e097 @ swp lr, r7, [r8]") 439 TEST_UNSUPPORTED(__inst_arm(0xe108e097) " @ swp lr, r7, [r8]")
439 TEST_UNSUPPORTED(".word 0x610d0091 @ swpvs r0, r1, [sp]") 440 TEST_UNSUPPORTED(__inst_arm(0x610d0091) " @ swpvs r0, r1, [sp]")
440 TEST_UNSUPPORTED(".word 0xe10cd09e @ swp sp, r14 [r12]") 441 TEST_UNSUPPORTED(__inst_arm(0xe10cd09e) " @ swp sp, r14 [r12]")
441#endif 442#endif
442 TEST_UNSUPPORTED(".word 0xe102f091 @ swp pc, r1, [r2]") 443 TEST_UNSUPPORTED(__inst_arm(0xe102f091) " @ swp pc, r1, [r2]")
443 TEST_UNSUPPORTED(".word 0xe102009f @ swp r0, pc, [r2]") 444 TEST_UNSUPPORTED(__inst_arm(0xe102009f) " @ swp r0, pc, [r2]")
444 TEST_UNSUPPORTED(".word 0xe10f0091 @ swp r0, r1, [pc]") 445 TEST_UNSUPPORTED(__inst_arm(0xe10f0091) " @ swp r0, r1, [pc]")
445#if __LINUX_ARM_ARCH__ < 6 446#if __LINUX_ARM_ARCH__ < 6
446 TEST_RP("swpb lr, r",7,VAL2,", [r",8,0,"]") 447 TEST_RP("swpb lr, r",7,VAL2,", [r",8,0,"]")
447 TEST_R( "swpvsb r0, r",1,VAL1,", [sp]") 448 TEST_R( "swpvsb r0, r",1,VAL1,", [sp]")
448#else 449#else
449 TEST_UNSUPPORTED(".word 0xe148e097 @ swpb lr, r7, [r8]") 450 TEST_UNSUPPORTED(__inst_arm(0xe148e097) " @ swpb lr, r7, [r8]")
450 TEST_UNSUPPORTED(".word 0x614d0091 @ swpvsb r0, r1, [sp]") 451 TEST_UNSUPPORTED(__inst_arm(0x614d0091) " @ swpvsb r0, r1, [sp]")
451#endif 452#endif
452 TEST_UNSUPPORTED(".word 0xe142f091 @ swpb pc, r1, [r2]") 453 TEST_UNSUPPORTED(__inst_arm(0xe142f091) " @ swpb pc, r1, [r2]")
453 454
454 TEST_UNSUPPORTED(".word 0xe1100090") /* Unallocated space */ 455 TEST_UNSUPPORTED(__inst_arm(0xe1100090)) /* Unallocated space */
455 TEST_UNSUPPORTED(".word 0xe1200090") /* Unallocated space */ 456 TEST_UNSUPPORTED(__inst_arm(0xe1200090)) /* Unallocated space */
456 TEST_UNSUPPORTED(".word 0xe1300090") /* Unallocated space */ 457 TEST_UNSUPPORTED(__inst_arm(0xe1300090)) /* Unallocated space */
457 TEST_UNSUPPORTED(".word 0xe1500090") /* Unallocated space */ 458 TEST_UNSUPPORTED(__inst_arm(0xe1500090)) /* Unallocated space */
458 TEST_UNSUPPORTED(".word 0xe1600090") /* Unallocated space */ 459 TEST_UNSUPPORTED(__inst_arm(0xe1600090)) /* Unallocated space */
459 TEST_UNSUPPORTED(".word 0xe1700090") /* Unallocated space */ 460 TEST_UNSUPPORTED(__inst_arm(0xe1700090)) /* Unallocated space */
460#if __LINUX_ARM_ARCH__ >= 6 461#if __LINUX_ARM_ARCH__ >= 6
461 TEST_UNSUPPORTED("ldrex r2, [sp]") 462 TEST_UNSUPPORTED("ldrex r2, [sp]")
462#endif 463#endif
@@ -476,9 +477,9 @@ void kprobe_arm_test_cases(void)
476 TEST_RPR( "strneh r",12,VAL2,", [r",11,48,", -r",10,24,"]!") 477 TEST_RPR( "strneh r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
477 TEST_RPR( "strh r",2, VAL1,", [r",3, 24,"], r",4, 48,"") 478 TEST_RPR( "strh r",2, VAL1,", [r",3, 24,"], r",4, 48,"")
478 TEST_RPR( "strh r",10,VAL2,", [r",9, 48,"], -r",11,24,"") 479 TEST_RPR( "strh r",10,VAL2,", [r",9, 48,"], -r",11,24,"")
479 TEST_UNSUPPORTED(".word 0xe1afc0ba @ strh r12, [pc, r10]!") 480 TEST_UNSUPPORTED(__inst_arm(0xe1afc0ba) " @ strh r12, [pc, r10]!")
480 TEST_UNSUPPORTED(".word 0xe089f0bb @ strh pc, [r9], r11") 481 TEST_UNSUPPORTED(__inst_arm(0xe089f0bb) " @ strh pc, [r9], r11")
481 TEST_UNSUPPORTED(".word 0xe089a0bf @ strh r10, [r9], pc") 482 TEST_UNSUPPORTED(__inst_arm(0xe089a0bf) " @ strh r10, [r9], pc")
482 483
483 TEST_PR( "ldrh r0, [r",0, 48,", -r",2, 24,"]") 484 TEST_PR( "ldrh r0, [r",0, 48,", -r",2, 24,"]")
484 TEST_PR( "ldrcsh r14, [r",13,0, ", r",12, 48,"]") 485 TEST_PR( "ldrcsh r14, [r",13,0, ", r",12, 48,"]")
@@ -486,9 +487,9 @@ void kprobe_arm_test_cases(void)
486 TEST_PR( "ldrcch r12, [r",11,48,", -r",10,24,"]!") 487 TEST_PR( "ldrcch r12, [r",11,48,", -r",10,24,"]!")
487 TEST_PR( "ldrh r2, [r",3, 24,"], r",4, 48,"") 488 TEST_PR( "ldrh r2, [r",3, 24,"], r",4, 48,"")
488 TEST_PR( "ldrh r10, [r",9, 48,"], -r",11,24,"") 489 TEST_PR( "ldrh r10, [r",9, 48,"], -r",11,24,"")
489 TEST_UNSUPPORTED(".word 0xe1bfc0ba @ ldrh r12, [pc, r10]!") 490 TEST_UNSUPPORTED(__inst_arm(0xe1bfc0ba) " @ ldrh r12, [pc, r10]!")
490 TEST_UNSUPPORTED(".word 0xe099f0bb @ ldrh pc, [r9], r11") 491 TEST_UNSUPPORTED(__inst_arm(0xe099f0bb) " @ ldrh pc, [r9], r11")
491 TEST_UNSUPPORTED(".word 0xe099a0bf @ ldrh r10, [r9], pc") 492 TEST_UNSUPPORTED(__inst_arm(0xe099a0bf) " @ ldrh r10, [r9], pc")
492 493
493 TEST_RP( "strh r",0, VAL1,", [r",1, 24,", #-2]") 494 TEST_RP( "strh r",0, VAL1,", [r",1, 24,", #-2]")
494 TEST_RP( "strmih r",14,VAL2,", [r",13,0, ", #2]") 495 TEST_RP( "strmih r",14,VAL2,", [r",13,0, ", #2]")
@@ -496,8 +497,8 @@ void kprobe_arm_test_cases(void)
496 TEST_RP( "strplh r",12,VAL2,", [r",11,24,", #-4]!") 497 TEST_RP( "strplh r",12,VAL2,", [r",11,24,", #-4]!")
497 TEST_RP( "strh r",2, VAL1,", [r",3, 24,"], #48") 498 TEST_RP( "strh r",2, VAL1,", [r",3, 24,"], #48")
498 TEST_RP( "strh r",10,VAL2,", [r",9, 64,"], #-48") 499 TEST_RP( "strh r",10,VAL2,", [r",9, 64,"], #-48")
499 TEST_UNSUPPORTED(".word 0xe1efc3b0 @ strh r12, [pc, #48]!") 500 TEST_UNSUPPORTED(__inst_arm(0xe1efc3b0) " @ strh r12, [pc, #48]!")
500 TEST_UNSUPPORTED(".word 0xe0c9f3b0 @ strh pc, [r9], #48") 501 TEST_UNSUPPORTED(__inst_arm(0xe0c9f3b0) " @ strh pc, [r9], #48")
501 502
502 TEST_P( "ldrh r0, [r",0, 24,", #-2]") 503 TEST_P( "ldrh r0, [r",0, 24,", #-2]")
503 TEST_P( "ldrvsh r14, [r",13,0, ", #2]") 504 TEST_P( "ldrvsh r14, [r",13,0, ", #2]")
@@ -506,8 +507,8 @@ void kprobe_arm_test_cases(void)
506 TEST_P( "ldrh r2, [r",3, 24,"], #48") 507 TEST_P( "ldrh r2, [r",3, 24,"], #48")
507 TEST_P( "ldrh r10, [r",9, 64,"], #-48") 508 TEST_P( "ldrh r10, [r",9, 64,"], #-48")
508 TEST( "ldrh r0, [pc, #0]") 509 TEST( "ldrh r0, [pc, #0]")
509 TEST_UNSUPPORTED(".word 0xe1ffc3b0 @ ldrh r12, [pc, #48]!") 510 TEST_UNSUPPORTED(__inst_arm(0xe1ffc3b0) " @ ldrh r12, [pc, #48]!")
510 TEST_UNSUPPORTED(".word 0xe0d9f3b0 @ ldrh pc, [r9], #48") 511 TEST_UNSUPPORTED(__inst_arm(0xe0d9f3b0) " @ ldrh pc, [r9], #48")
511 512
512 TEST_PR( "ldrsb r0, [r",0, 48,", -r",2, 24,"]") 513 TEST_PR( "ldrsb r0, [r",0, 48,", -r",2, 24,"]")
513 TEST_PR( "ldrhisb r14, [r",13,0,", r",12, 48,"]") 514 TEST_PR( "ldrhisb r14, [r",13,0,", r",12, 48,"]")
@@ -515,8 +516,8 @@ void kprobe_arm_test_cases(void)
515 TEST_PR( "ldrlssb r12, [r",11,48,", -r",10,24,"]!") 516 TEST_PR( "ldrlssb r12, [r",11,48,", -r",10,24,"]!")
516 TEST_PR( "ldrsb r2, [r",3, 24,"], r",4, 48,"") 517 TEST_PR( "ldrsb r2, [r",3, 24,"], r",4, 48,"")
517 TEST_PR( "ldrsb r10, [r",9, 48,"], -r",11,24,"") 518 TEST_PR( "ldrsb r10, [r",9, 48,"], -r",11,24,"")
518 TEST_UNSUPPORTED(".word 0xe1bfc0da @ ldrsb r12, [pc, r10]!") 519 TEST_UNSUPPORTED(__inst_arm(0xe1bfc0da) " @ ldrsb r12, [pc, r10]!")
519 TEST_UNSUPPORTED(".word 0xe099f0db @ ldrsb pc, [r9], r11") 520 TEST_UNSUPPORTED(__inst_arm(0xe099f0db) " @ ldrsb pc, [r9], r11")
520 521
521 TEST_P( "ldrsb r0, [r",0, 24,", #-1]") 522 TEST_P( "ldrsb r0, [r",0, 24,", #-1]")
522 TEST_P( "ldrgesb r14, [r",13,0, ", #1]") 523 TEST_P( "ldrgesb r14, [r",13,0, ", #1]")
@@ -525,8 +526,8 @@ void kprobe_arm_test_cases(void)
525 TEST_P( "ldrsb r2, [r",3, 24,"], #48") 526 TEST_P( "ldrsb r2, [r",3, 24,"], #48")
526 TEST_P( "ldrsb r10, [r",9, 64,"], #-48") 527 TEST_P( "ldrsb r10, [r",9, 64,"], #-48")
527 TEST( "ldrsb r0, [pc, #0]") 528 TEST( "ldrsb r0, [pc, #0]")
528 TEST_UNSUPPORTED(".word 0xe1ffc3d0 @ ldrsb r12, [pc, #48]!") 529 TEST_UNSUPPORTED(__inst_arm(0xe1ffc3d0) " @ ldrsb r12, [pc, #48]!")
529 TEST_UNSUPPORTED(".word 0xe0d9f3d0 @ ldrsb pc, [r9], #48") 530 TEST_UNSUPPORTED(__inst_arm(0xe0d9f3d0) " @ ldrsb pc, [r9], #48")
530 531
531 TEST_PR( "ldrsh r0, [r",0, 48,", -r",2, 24,"]") 532 TEST_PR( "ldrsh r0, [r",0, 48,", -r",2, 24,"]")
532 TEST_PR( "ldrgtsh r14, [r",13,0, ", r",12, 48,"]") 533 TEST_PR( "ldrgtsh r14, [r",13,0, ", r",12, 48,"]")
@@ -534,8 +535,8 @@ void kprobe_arm_test_cases(void)
534 TEST_PR( "ldrlesh r12, [r",11,48,", -r",10,24,"]!") 535 TEST_PR( "ldrlesh r12, [r",11,48,", -r",10,24,"]!")
535 TEST_PR( "ldrsh r2, [r",3, 24,"], r",4, 48,"") 536 TEST_PR( "ldrsh r2, [r",3, 24,"], r",4, 48,"")
536 TEST_PR( "ldrsh r10, [r",9, 48,"], -r",11,24,"") 537 TEST_PR( "ldrsh r10, [r",9, 48,"], -r",11,24,"")
537 TEST_UNSUPPORTED(".word 0xe1bfc0fa @ ldrsh r12, [pc, r10]!") 538 TEST_UNSUPPORTED(__inst_arm(0xe1bfc0fa) " @ ldrsh r12, [pc, r10]!")
538 TEST_UNSUPPORTED(".word 0xe099f0fb @ ldrsh pc, [r9], r11") 539 TEST_UNSUPPORTED(__inst_arm(0xe099f0fb) " @ ldrsh pc, [r9], r11")
539 540
540 TEST_P( "ldrsh r0, [r",0, 24,", #-1]") 541 TEST_P( "ldrsh r0, [r",0, 24,", #-1]")
541 TEST_P( "ldreqsh r14, [r",13,0 ,", #1]") 542 TEST_P( "ldreqsh r14, [r",13,0 ,", #1]")
@@ -544,8 +545,8 @@ void kprobe_arm_test_cases(void)
544 TEST_P( "ldrsh r2, [r",3, 24,"], #48") 545 TEST_P( "ldrsh r2, [r",3, 24,"], #48")
545 TEST_P( "ldrsh r10, [r",9, 64,"], #-48") 546 TEST_P( "ldrsh r10, [r",9, 64,"], #-48")
546 TEST( "ldrsh r0, [pc, #0]") 547 TEST( "ldrsh r0, [pc, #0]")
547 TEST_UNSUPPORTED(".word 0xe1ffc3f0 @ ldrsh r12, [pc, #48]!") 548 TEST_UNSUPPORTED(__inst_arm(0xe1ffc3f0) " @ ldrsh r12, [pc, #48]!")
548 TEST_UNSUPPORTED(".word 0xe0d9f3f0 @ ldrsh pc, [r9], #48") 549 TEST_UNSUPPORTED(__inst_arm(0xe0d9f3f0) " @ ldrsh pc, [r9], #48")
549 550
550#if __LINUX_ARM_ARCH__ >= 7 551#if __LINUX_ARM_ARCH__ >= 7
551 TEST_UNSUPPORTED("strht r1, [r2], r3") 552 TEST_UNSUPPORTED("strht r1, [r2], r3")
@@ -564,7 +565,7 @@ void kprobe_arm_test_cases(void)
564 TEST_RPR( "strcsd r",12,VAL2,", [r",11,48,", -r",10,24,"]!") 565 TEST_RPR( "strcsd r",12,VAL2,", [r",11,48,", -r",10,24,"]!")
565 TEST_RPR( "strd r",2, VAL1,", [r",5, 24,"], r",4,48,"") 566 TEST_RPR( "strd r",2, VAL1,", [r",5, 24,"], r",4,48,"")
566 TEST_RPR( "strd r",10,VAL2,", [r",9, 48,"], -r",7,24,"") 567 TEST_RPR( "strd r",10,VAL2,", [r",9, 48,"], -r",7,24,"")
567 TEST_UNSUPPORTED(".word 0xe1afc0fa @ strd r12, [pc, r10]!") 568 TEST_UNSUPPORTED(__inst_arm(0xe1afc0fa) " @ strd r12, [pc, r10]!")
568 569
569 TEST_PR( "ldrd r0, [r",0, 48,", -r",2,24,"]") 570 TEST_PR( "ldrd r0, [r",0, 48,", -r",2,24,"]")
570 TEST_PR( "ldrmid r8, [r",13,0, ", r",12,48,"]") 571 TEST_PR( "ldrmid r8, [r",13,0, ", r",12,48,"]")
@@ -572,10 +573,10 @@ void kprobe_arm_test_cases(void)
572 TEST_PR( "ldrpld r6, [r",11,48,", -r",10,24,"]!") 573 TEST_PR( "ldrpld r6, [r",11,48,", -r",10,24,"]!")
573 TEST_PR( "ldrd r2, [r",5, 24,"], r",4,48,"") 574 TEST_PR( "ldrd r2, [r",5, 24,"], r",4,48,"")
574 TEST_PR( "ldrd r10, [r",9,48,"], -r",7,24,"") 575 TEST_PR( "ldrd r10, [r",9,48,"], -r",7,24,"")
575 TEST_UNSUPPORTED(".word 0xe1afc0da @ ldrd r12, [pc, r10]!") 576 TEST_UNSUPPORTED(__inst_arm(0xe1afc0da) " @ ldrd r12, [pc, r10]!")
576 TEST_UNSUPPORTED(".word 0xe089f0db @ ldrd pc, [r9], r11") 577 TEST_UNSUPPORTED(__inst_arm(0xe089f0db) " @ ldrd pc, [r9], r11")
577 TEST_UNSUPPORTED(".word 0xe089e0db @ ldrd lr, [r9], r11") 578 TEST_UNSUPPORTED(__inst_arm(0xe089e0db) " @ ldrd lr, [r9], r11")
578 TEST_UNSUPPORTED(".word 0xe089c0df @ ldrd r12, [r9], pc") 579 TEST_UNSUPPORTED(__inst_arm(0xe089c0df) " @ ldrd r12, [r9], pc")
579 580
580 TEST_RP( "strd r",0, VAL1,", [r",1, 24,", #-8]") 581 TEST_RP( "strd r",0, VAL1,", [r",1, 24,", #-8]")
581 TEST_RP( "strvsd r",8, VAL2,", [r",13,0, ", #8]") 582 TEST_RP( "strvsd r",8, VAL2,", [r",13,0, ", #8]")
@@ -583,7 +584,7 @@ void kprobe_arm_test_cases(void)
583 TEST_RP( "strvcd r",12,VAL2,", [r",11,24,", #-16]!") 584 TEST_RP( "strvcd r",12,VAL2,", [r",11,24,", #-16]!")
584 TEST_RP( "strd r",2, VAL1,", [r",4, 24,"], #48") 585 TEST_RP( "strd r",2, VAL1,", [r",4, 24,"], #48")
585 TEST_RP( "strd r",10,VAL2,", [r",9, 64,"], #-48") 586 TEST_RP( "strd r",10,VAL2,", [r",9, 64,"], #-48")
586 TEST_UNSUPPORTED(".word 0xe1efc3f0 @ strd r12, [pc, #48]!") 587 TEST_UNSUPPORTED(__inst_arm(0xe1efc3f0) " @ strd r12, [pc, #48]!")
587 588
588 TEST_P( "ldrd r0, [r",0, 24,", #-8]") 589 TEST_P( "ldrd r0, [r",0, 24,", #-8]")
589 TEST_P( "ldrhid r8, [r",13,0, ", #8]") 590 TEST_P( "ldrhid r8, [r",13,0, ", #8]")
@@ -591,9 +592,9 @@ void kprobe_arm_test_cases(void)
591 TEST_P( "ldrlsd r6, [r",11,24,", #-16]!") 592 TEST_P( "ldrlsd r6, [r",11,24,", #-16]!")
592 TEST_P( "ldrd r2, [r",5, 24,"], #48") 593 TEST_P( "ldrd r2, [r",5, 24,"], #48")
593 TEST_P( "ldrd r10, [r",9,6,"], #-48") 594 TEST_P( "ldrd r10, [r",9,6,"], #-48")
594 TEST_UNSUPPORTED(".word 0xe1efc3d0 @ ldrd r12, [pc, #48]!") 595 TEST_UNSUPPORTED(__inst_arm(0xe1efc3d0) " @ ldrd r12, [pc, #48]!")
595 TEST_UNSUPPORTED(".word 0xe0c9f3d0 @ ldrd pc, [r9], #48") 596 TEST_UNSUPPORTED(__inst_arm(0xe0c9f3d0) " @ ldrd pc, [r9], #48")
596 TEST_UNSUPPORTED(".word 0xe0c9e3d0 @ ldrd lr, [r9], #48") 597 TEST_UNSUPPORTED(__inst_arm(0xe0c9e3d0) " @ ldrd lr, [r9], #48")
597 598
598 TEST_GROUP("Miscellaneous") 599 TEST_GROUP("Miscellaneous")
599 600
@@ -601,11 +602,11 @@ void kprobe_arm_test_cases(void)
601 TEST("movw r0, #0") 602 TEST("movw r0, #0")
602 TEST("movw r0, #0xffff") 603 TEST("movw r0, #0xffff")
603 TEST("movw lr, #0xffff") 604 TEST("movw lr, #0xffff")
604 TEST_UNSUPPORTED(".word 0xe300f000 @ movw pc, #0") 605 TEST_UNSUPPORTED(__inst_arm(0xe300f000) " @ movw pc, #0")
605 TEST_R("movt r",0, VAL1,", #0") 606 TEST_R("movt r",0, VAL1,", #0")
606 TEST_R("movt r",0, VAL2,", #0xffff") 607 TEST_R("movt r",0, VAL2,", #0xffff")
607 TEST_R("movt r",14,VAL1,", #0xffff") 608 TEST_R("movt r",14,VAL1,", #0xffff")
608 TEST_UNSUPPORTED(".word 0xe340f000 @ movt pc, #0") 609 TEST_UNSUPPORTED(__inst_arm(0xe340f000) " @ movt pc, #0")
609#endif 610#endif
610 611
611 TEST_UNSUPPORTED("msr cpsr, 0x13") 612 TEST_UNSUPPORTED("msr cpsr, 0x13")
@@ -673,20 +674,20 @@ void kprobe_arm_test_cases(void)
673#ifdef CONFIG_THUMB2_KERNEL 674#ifdef CONFIG_THUMB2_KERNEL
674 TEST_ARM_TO_THUMB_INTERWORK_P("ldr pc, [r",0,0,", #15*4]") 675 TEST_ARM_TO_THUMB_INTERWORK_P("ldr pc, [r",0,0,", #15*4]")
675#endif 676#endif
676 TEST_UNSUPPORTED(".word 0xe5af6008 @ str r6, [pc, #8]!") 677 TEST_UNSUPPORTED(__inst_arm(0xe5af6008) " @ str r6, [pc, #8]!")
677 TEST_UNSUPPORTED(".word 0xe7af6008 @ str r6, [pc, r8]!") 678 TEST_UNSUPPORTED(__inst_arm(0xe7af6008) " @ str r6, [pc, r8]!")
678 TEST_UNSUPPORTED(".word 0xe5bf6008 @ ldr r6, [pc, #8]!") 679 TEST_UNSUPPORTED(__inst_arm(0xe5bf6008) " @ ldr r6, [pc, #8]!")
679 TEST_UNSUPPORTED(".word 0xe7bf6008 @ ldr r6, [pc, r8]!") 680 TEST_UNSUPPORTED(__inst_arm(0xe7bf6008) " @ ldr r6, [pc, r8]!")
680 TEST_UNSUPPORTED(".word 0xe788600f @ str r6, [r8, pc]") 681 TEST_UNSUPPORTED(__inst_arm(0xe788600f) " @ str r6, [r8, pc]")
681 TEST_UNSUPPORTED(".word 0xe798600f @ ldr r6, [r8, pc]") 682 TEST_UNSUPPORTED(__inst_arm(0xe798600f) " @ ldr r6, [r8, pc]")
682 683
683 LOAD_STORE("b") 684 LOAD_STORE("b")
684 TEST_UNSUPPORTED(".word 0xe5f7f008 @ ldrb pc, [r7, #8]!") 685 TEST_UNSUPPORTED(__inst_arm(0xe5f7f008) " @ ldrb pc, [r7, #8]!")
685 TEST_UNSUPPORTED(".word 0xe7f7f008 @ ldrb pc, [r7, r8]!") 686 TEST_UNSUPPORTED(__inst_arm(0xe7f7f008) " @ ldrb pc, [r7, r8]!")
686 TEST_UNSUPPORTED(".word 0xe5ef6008 @ strb r6, [pc, #8]!") 687 TEST_UNSUPPORTED(__inst_arm(0xe5ef6008) " @ strb r6, [pc, #8]!")
687 TEST_UNSUPPORTED(".word 0xe7ef6008 @ strb r6, [pc, r3]!") 688 TEST_UNSUPPORTED(__inst_arm(0xe7ef6008) " @ strb r6, [pc, r3]!")
688 TEST_UNSUPPORTED(".word 0xe5ff6008 @ ldrb r6, [pc, #8]!") 689 TEST_UNSUPPORTED(__inst_arm(0xe5ff6008) " @ ldrb r6, [pc, #8]!")
689 TEST_UNSUPPORTED(".word 0xe7ff6008 @ ldrb r6, [pc, r3]!") 690 TEST_UNSUPPORTED(__inst_arm(0xe7ff6008) " @ ldrb r6, [pc, r3]!")
690 691
691 TEST_UNSUPPORTED("ldrt r0, [r1], #4") 692 TEST_UNSUPPORTED("ldrt r0, [r1], #4")
692 TEST_UNSUPPORTED("ldrt r1, [r2], r3") 693 TEST_UNSUPPORTED("ldrt r1, [r2], r3")
@@ -700,153 +701,153 @@ void kprobe_arm_test_cases(void)
700#if __LINUX_ARM_ARCH__ >= 7 701#if __LINUX_ARM_ARCH__ >= 7
701 TEST_GROUP("Parallel addition and subtraction, signed") 702 TEST_GROUP("Parallel addition and subtraction, signed")
702 703
703 TEST_UNSUPPORTED(".word 0xe6000010") /* Unallocated space */ 704 TEST_UNSUPPORTED(__inst_arm(0xe6000010) "") /* Unallocated space */
704 TEST_UNSUPPORTED(".word 0xe60fffff") /* Unallocated space */ 705 TEST_UNSUPPORTED(__inst_arm(0xe60fffff) "") /* Unallocated space */
705 706
706 TEST_RR( "sadd16 r0, r",0, HH1,", r",1, HH2,"") 707 TEST_RR( "sadd16 r0, r",0, HH1,", r",1, HH2,"")
707 TEST_RR( "sadd16 r14, r",12,HH2,", r",10,HH1,"") 708 TEST_RR( "sadd16 r14, r",12,HH2,", r",10,HH1,"")
708 TEST_UNSUPPORTED(".word 0xe61cff1a @ sadd16 pc, r12, r10") 709 TEST_UNSUPPORTED(__inst_arm(0xe61cff1a) " @ sadd16 pc, r12, r10")
709 TEST_RR( "sasx r0, r",0, HH1,", r",1, HH2,"") 710 TEST_RR( "sasx r0, r",0, HH1,", r",1, HH2,"")
710 TEST_RR( "sasx r14, r",12,HH2,", r",10,HH1,"") 711 TEST_RR( "sasx r14, r",12,HH2,", r",10,HH1,"")
711 TEST_UNSUPPORTED(".word 0xe61cff3a @ sasx pc, r12, r10") 712 TEST_UNSUPPORTED(__inst_arm(0xe61cff3a) " @ sasx pc, r12, r10")
712 TEST_RR( "ssax r0, r",0, HH1,", r",1, HH2,"") 713 TEST_RR( "ssax r0, r",0, HH1,", r",1, HH2,"")
713 TEST_RR( "ssax r14, r",12,HH2,", r",10,HH1,"") 714 TEST_RR( "ssax r14, r",12,HH2,", r",10,HH1,"")
714 TEST_UNSUPPORTED(".word 0xe61cff5a @ ssax pc, r12, r10") 715 TEST_UNSUPPORTED(__inst_arm(0xe61cff5a) " @ ssax pc, r12, r10")
715 TEST_RR( "ssub16 r0, r",0, HH1,", r",1, HH2,"") 716 TEST_RR( "ssub16 r0, r",0, HH1,", r",1, HH2,"")
716 TEST_RR( "ssub16 r14, r",12,HH2,", r",10,HH1,"") 717 TEST_RR( "ssub16 r14, r",12,HH2,", r",10,HH1,"")
717 TEST_UNSUPPORTED(".word 0xe61cff7a @ ssub16 pc, r12, r10") 718 TEST_UNSUPPORTED(__inst_arm(0xe61cff7a) " @ ssub16 pc, r12, r10")
718 TEST_RR( "sadd8 r0, r",0, HH1,", r",1, HH2,"") 719 TEST_RR( "sadd8 r0, r",0, HH1,", r",1, HH2,"")
719 TEST_RR( "sadd8 r14, r",12,HH2,", r",10,HH1,"") 720 TEST_RR( "sadd8 r14, r",12,HH2,", r",10,HH1,"")
720 TEST_UNSUPPORTED(".word 0xe61cff9a @ sadd8 pc, r12, r10") 721 TEST_UNSUPPORTED(__inst_arm(0xe61cff9a) " @ sadd8 pc, r12, r10")
721 TEST_UNSUPPORTED(".word 0xe61000b0") /* Unallocated space */ 722 TEST_UNSUPPORTED(__inst_arm(0xe61000b0) "") /* Unallocated space */
722 TEST_UNSUPPORTED(".word 0xe61fffbf") /* Unallocated space */ 723 TEST_UNSUPPORTED(__inst_arm(0xe61fffbf) "") /* Unallocated space */
723 TEST_UNSUPPORTED(".word 0xe61000d0") /* Unallocated space */ 724 TEST_UNSUPPORTED(__inst_arm(0xe61000d0) "") /* Unallocated space */
724 TEST_UNSUPPORTED(".word 0xe61fffdf") /* Unallocated space */ 725 TEST_UNSUPPORTED(__inst_arm(0xe61fffdf) "") /* Unallocated space */
725 TEST_RR( "ssub8 r0, r",0, HH1,", r",1, HH2,"") 726 TEST_RR( "ssub8 r0, r",0, HH1,", r",1, HH2,"")
726 TEST_RR( "ssub8 r14, r",12,HH2,", r",10,HH1,"") 727 TEST_RR( "ssub8 r14, r",12,HH2,", r",10,HH1,"")
727 TEST_UNSUPPORTED(".word 0xe61cfffa @ ssub8 pc, r12, r10") 728 TEST_UNSUPPORTED(__inst_arm(0xe61cfffa) " @ ssub8 pc, r12, r10")
728 729
729 TEST_RR( "qadd16 r0, r",0, HH1,", r",1, HH2,"") 730 TEST_RR( "qadd16 r0, r",0, HH1,", r",1, HH2,"")
730 TEST_RR( "qadd16 r14, r",12,HH2,", r",10,HH1,"") 731 TEST_RR( "qadd16 r14, r",12,HH2,", r",10,HH1,"")
731 TEST_UNSUPPORTED(".word 0xe62cff1a @ qadd16 pc, r12, r10") 732 TEST_UNSUPPORTED(__inst_arm(0xe62cff1a) " @ qadd16 pc, r12, r10")
732 TEST_RR( "qasx r0, r",0, HH1,", r",1, HH2,"") 733 TEST_RR( "qasx r0, r",0, HH1,", r",1, HH2,"")
733 TEST_RR( "qasx r14, r",12,HH2,", r",10,HH1,"") 734 TEST_RR( "qasx r14, r",12,HH2,", r",10,HH1,"")
734 TEST_UNSUPPORTED(".word 0xe62cff3a @ qasx pc, r12, r10") 735 TEST_UNSUPPORTED(__inst_arm(0xe62cff3a) " @ qasx pc, r12, r10")
735 TEST_RR( "qsax r0, r",0, HH1,", r",1, HH2,"") 736 TEST_RR( "qsax r0, r",0, HH1,", r",1, HH2,"")
736 TEST_RR( "qsax r14, r",12,HH2,", r",10,HH1,"") 737 TEST_RR( "qsax r14, r",12,HH2,", r",10,HH1,"")
737 TEST_UNSUPPORTED(".word 0xe62cff5a @ qsax pc, r12, r10") 738 TEST_UNSUPPORTED(__inst_arm(0xe62cff5a) " @ qsax pc, r12, r10")
738 TEST_RR( "qsub16 r0, r",0, HH1,", r",1, HH2,"") 739 TEST_RR( "qsub16 r0, r",0, HH1,", r",1, HH2,"")
739 TEST_RR( "qsub16 r14, r",12,HH2,", r",10,HH1,"") 740 TEST_RR( "qsub16 r14, r",12,HH2,", r",10,HH1,"")
740 TEST_UNSUPPORTED(".word 0xe62cff7a @ qsub16 pc, r12, r10") 741 TEST_UNSUPPORTED(__inst_arm(0xe62cff7a) " @ qsub16 pc, r12, r10")
741 TEST_RR( "qadd8 r0, r",0, HH1,", r",1, HH2,"") 742 TEST_RR( "qadd8 r0, r",0, HH1,", r",1, HH2,"")
742 TEST_RR( "qadd8 r14, r",12,HH2,", r",10,HH1,"") 743 TEST_RR( "qadd8 r14, r",12,HH2,", r",10,HH1,"")
743 TEST_UNSUPPORTED(".word 0xe62cff9a @ qadd8 pc, r12, r10") 744 TEST_UNSUPPORTED(__inst_arm(0xe62cff9a) " @ qadd8 pc, r12, r10")
744 TEST_UNSUPPORTED(".word 0xe62000b0") /* Unallocated space */ 745 TEST_UNSUPPORTED(__inst_arm(0xe62000b0) "") /* Unallocated space */
745 TEST_UNSUPPORTED(".word 0xe62fffbf") /* Unallocated space */ 746 TEST_UNSUPPORTED(__inst_arm(0xe62fffbf) "") /* Unallocated space */
746 TEST_UNSUPPORTED(".word 0xe62000d0") /* Unallocated space */ 747 TEST_UNSUPPORTED(__inst_arm(0xe62000d0) "") /* Unallocated space */
747 TEST_UNSUPPORTED(".word 0xe62fffdf") /* Unallocated space */ 748 TEST_UNSUPPORTED(__inst_arm(0xe62fffdf) "") /* Unallocated space */
748 TEST_RR( "qsub8 r0, r",0, HH1,", r",1, HH2,"") 749 TEST_RR( "qsub8 r0, r",0, HH1,", r",1, HH2,"")
749 TEST_RR( "qsub8 r14, r",12,HH2,", r",10,HH1,"") 750 TEST_RR( "qsub8 r14, r",12,HH2,", r",10,HH1,"")
750 TEST_UNSUPPORTED(".word 0xe62cfffa @ qsub8 pc, r12, r10") 751 TEST_UNSUPPORTED(__inst_arm(0xe62cfffa) " @ qsub8 pc, r12, r10")
751 752
752 TEST_RR( "shadd16 r0, r",0, HH1,", r",1, HH2,"") 753 TEST_RR( "shadd16 r0, r",0, HH1,", r",1, HH2,"")
753 TEST_RR( "shadd16 r14, r",12,HH2,", r",10,HH1,"") 754 TEST_RR( "shadd16 r14, r",12,HH2,", r",10,HH1,"")
754 TEST_UNSUPPORTED(".word 0xe63cff1a @ shadd16 pc, r12, r10") 755 TEST_UNSUPPORTED(__inst_arm(0xe63cff1a) " @ shadd16 pc, r12, r10")
755 TEST_RR( "shasx r0, r",0, HH1,", r",1, HH2,"") 756 TEST_RR( "shasx r0, r",0, HH1,", r",1, HH2,"")
756 TEST_RR( "shasx r14, r",12,HH2,", r",10,HH1,"") 757 TEST_RR( "shasx r14, r",12,HH2,", r",10,HH1,"")
757 TEST_UNSUPPORTED(".word 0xe63cff3a @ shasx pc, r12, r10") 758 TEST_UNSUPPORTED(__inst_arm(0xe63cff3a) " @ shasx pc, r12, r10")
758 TEST_RR( "shsax r0, r",0, HH1,", r",1, HH2,"") 759 TEST_RR( "shsax r0, r",0, HH1,", r",1, HH2,"")
759 TEST_RR( "shsax r14, r",12,HH2,", r",10,HH1,"") 760 TEST_RR( "shsax r14, r",12,HH2,", r",10,HH1,"")
760 TEST_UNSUPPORTED(".word 0xe63cff5a @ shsax pc, r12, r10") 761 TEST_UNSUPPORTED(__inst_arm(0xe63cff5a) " @ shsax pc, r12, r10")
761 TEST_RR( "shsub16 r0, r",0, HH1,", r",1, HH2,"") 762 TEST_RR( "shsub16 r0, r",0, HH1,", r",1, HH2,"")
762 TEST_RR( "shsub16 r14, r",12,HH2,", r",10,HH1,"") 763 TEST_RR( "shsub16 r14, r",12,HH2,", r",10,HH1,"")
763 TEST_UNSUPPORTED(".word 0xe63cff7a @ shsub16 pc, r12, r10") 764 TEST_UNSUPPORTED(__inst_arm(0xe63cff7a) " @ shsub16 pc, r12, r10")
764 TEST_RR( "shadd8 r0, r",0, HH1,", r",1, HH2,"") 765 TEST_RR( "shadd8 r0, r",0, HH1,", r",1, HH2,"")
765 TEST_RR( "shadd8 r14, r",12,HH2,", r",10,HH1,"") 766 TEST_RR( "shadd8 r14, r",12,HH2,", r",10,HH1,"")
766 TEST_UNSUPPORTED(".word 0xe63cff9a @ shadd8 pc, r12, r10") 767 TEST_UNSUPPORTED(__inst_arm(0xe63cff9a) " @ shadd8 pc, r12, r10")
767 TEST_UNSUPPORTED(".word 0xe63000b0") /* Unallocated space */ 768 TEST_UNSUPPORTED(__inst_arm(0xe63000b0) "") /* Unallocated space */
768 TEST_UNSUPPORTED(".word 0xe63fffbf") /* Unallocated space */ 769 TEST_UNSUPPORTED(__inst_arm(0xe63fffbf) "") /* Unallocated space */
769 TEST_UNSUPPORTED(".word 0xe63000d0") /* Unallocated space */ 770 TEST_UNSUPPORTED(__inst_arm(0xe63000d0) "") /* Unallocated space */
770 TEST_UNSUPPORTED(".word 0xe63fffdf") /* Unallocated space */ 771 TEST_UNSUPPORTED(__inst_arm(0xe63fffdf) "") /* Unallocated space */
771 TEST_RR( "shsub8 r0, r",0, HH1,", r",1, HH2,"") 772 TEST_RR( "shsub8 r0, r",0, HH1,", r",1, HH2,"")
772 TEST_RR( "shsub8 r14, r",12,HH2,", r",10,HH1,"") 773 TEST_RR( "shsub8 r14, r",12,HH2,", r",10,HH1,"")
773 TEST_UNSUPPORTED(".word 0xe63cfffa @ shsub8 pc, r12, r10") 774 TEST_UNSUPPORTED(__inst_arm(0xe63cfffa) " @ shsub8 pc, r12, r10")
774 775
775 TEST_GROUP("Parallel addition and subtraction, unsigned") 776 TEST_GROUP("Parallel addition and subtraction, unsigned")
776 777
777 TEST_UNSUPPORTED(".word 0xe6400010") /* Unallocated space */ 778 TEST_UNSUPPORTED(__inst_arm(0xe6400010) "") /* Unallocated space */
778 TEST_UNSUPPORTED(".word 0xe64fffff") /* Unallocated space */ 779 TEST_UNSUPPORTED(__inst_arm(0xe64fffff) "") /* Unallocated space */
779 780
780 TEST_RR( "uadd16 r0, r",0, HH1,", r",1, HH2,"") 781 TEST_RR( "uadd16 r0, r",0, HH1,", r",1, HH2,"")
781 TEST_RR( "uadd16 r14, r",12,HH2,", r",10,HH1,"") 782 TEST_RR( "uadd16 r14, r",12,HH2,", r",10,HH1,"")
782 TEST_UNSUPPORTED(".word 0xe65cff1a @ uadd16 pc, r12, r10") 783 TEST_UNSUPPORTED(__inst_arm(0xe65cff1a) " @ uadd16 pc, r12, r10")
783 TEST_RR( "uasx r0, r",0, HH1,", r",1, HH2,"") 784 TEST_RR( "uasx r0, r",0, HH1,", r",1, HH2,"")
784 TEST_RR( "uasx r14, r",12,HH2,", r",10,HH1,"") 785 TEST_RR( "uasx r14, r",12,HH2,", r",10,HH1,"")
785 TEST_UNSUPPORTED(".word 0xe65cff3a @ uasx pc, r12, r10") 786 TEST_UNSUPPORTED(__inst_arm(0xe65cff3a) " @ uasx pc, r12, r10")
786 TEST_RR( "usax r0, r",0, HH1,", r",1, HH2,"") 787 TEST_RR( "usax r0, r",0, HH1,", r",1, HH2,"")
787 TEST_RR( "usax r14, r",12,HH2,", r",10,HH1,"") 788 TEST_RR( "usax r14, r",12,HH2,", r",10,HH1,"")
788 TEST_UNSUPPORTED(".word 0xe65cff5a @ usax pc, r12, r10") 789 TEST_UNSUPPORTED(__inst_arm(0xe65cff5a) " @ usax pc, r12, r10")
789 TEST_RR( "usub16 r0, r",0, HH1,", r",1, HH2,"") 790 TEST_RR( "usub16 r0, r",0, HH1,", r",1, HH2,"")
790 TEST_RR( "usub16 r14, r",12,HH2,", r",10,HH1,"") 791 TEST_RR( "usub16 r14, r",12,HH2,", r",10,HH1,"")
791 TEST_UNSUPPORTED(".word 0xe65cff7a @ usub16 pc, r12, r10") 792 TEST_UNSUPPORTED(__inst_arm(0xe65cff7a) " @ usub16 pc, r12, r10")
792 TEST_RR( "uadd8 r0, r",0, HH1,", r",1, HH2,"") 793 TEST_RR( "uadd8 r0, r",0, HH1,", r",1, HH2,"")
793 TEST_RR( "uadd8 r14, r",12,HH2,", r",10,HH1,"") 794 TEST_RR( "uadd8 r14, r",12,HH2,", r",10,HH1,"")
794 TEST_UNSUPPORTED(".word 0xe65cff9a @ uadd8 pc, r12, r10") 795 TEST_UNSUPPORTED(__inst_arm(0xe65cff9a) " @ uadd8 pc, r12, r10")
795 TEST_UNSUPPORTED(".word 0xe65000b0") /* Unallocated space */ 796 TEST_UNSUPPORTED(__inst_arm(0xe65000b0) "") /* Unallocated space */
796 TEST_UNSUPPORTED(".word 0xe65fffbf") /* Unallocated space */ 797 TEST_UNSUPPORTED(__inst_arm(0xe65fffbf) "") /* Unallocated space */
797 TEST_UNSUPPORTED(".word 0xe65000d0") /* Unallocated space */ 798 TEST_UNSUPPORTED(__inst_arm(0xe65000d0) "") /* Unallocated space */
798 TEST_UNSUPPORTED(".word 0xe65fffdf") /* Unallocated space */ 799 TEST_UNSUPPORTED(__inst_arm(0xe65fffdf) "") /* Unallocated space */
799 TEST_RR( "usub8 r0, r",0, HH1,", r",1, HH2,"") 800 TEST_RR( "usub8 r0, r",0, HH1,", r",1, HH2,"")
800 TEST_RR( "usub8 r14, r",12,HH2,", r",10,HH1,"") 801 TEST_RR( "usub8 r14, r",12,HH2,", r",10,HH1,"")
801 TEST_UNSUPPORTED(".word 0xe65cfffa @ usub8 pc, r12, r10") 802 TEST_UNSUPPORTED(__inst_arm(0xe65cfffa) " @ usub8 pc, r12, r10")
802 803
803 TEST_RR( "uqadd16 r0, r",0, HH1,", r",1, HH2,"") 804 TEST_RR( "uqadd16 r0, r",0, HH1,", r",1, HH2,"")
804 TEST_RR( "uqadd16 r14, r",12,HH2,", r",10,HH1,"") 805 TEST_RR( "uqadd16 r14, r",12,HH2,", r",10,HH1,"")
805 TEST_UNSUPPORTED(".word 0xe66cff1a @ uqadd16 pc, r12, r10") 806 TEST_UNSUPPORTED(__inst_arm(0xe66cff1a) " @ uqadd16 pc, r12, r10")
806 TEST_RR( "uqasx r0, r",0, HH1,", r",1, HH2,"") 807 TEST_RR( "uqasx r0, r",0, HH1,", r",1, HH2,"")
807 TEST_RR( "uqasx r14, r",12,HH2,", r",10,HH1,"") 808 TEST_RR( "uqasx r14, r",12,HH2,", r",10,HH1,"")
808 TEST_UNSUPPORTED(".word 0xe66cff3a @ uqasx pc, r12, r10") 809 TEST_UNSUPPORTED(__inst_arm(0xe66cff3a) " @ uqasx pc, r12, r10")
809 TEST_RR( "uqsax r0, r",0, HH1,", r",1, HH2,"") 810 TEST_RR( "uqsax r0, r",0, HH1,", r",1, HH2,"")
810 TEST_RR( "uqsax r14, r",12,HH2,", r",10,HH1,"") 811 TEST_RR( "uqsax r14, r",12,HH2,", r",10,HH1,"")
811 TEST_UNSUPPORTED(".word 0xe66cff5a @ uqsax pc, r12, r10") 812 TEST_UNSUPPORTED(__inst_arm(0xe66cff5a) " @ uqsax pc, r12, r10")
812 TEST_RR( "uqsub16 r0, r",0, HH1,", r",1, HH2,"") 813 TEST_RR( "uqsub16 r0, r",0, HH1,", r",1, HH2,"")
813 TEST_RR( "uqsub16 r14, r",12,HH2,", r",10,HH1,"") 814 TEST_RR( "uqsub16 r14, r",12,HH2,", r",10,HH1,"")
814 TEST_UNSUPPORTED(".word 0xe66cff7a @ uqsub16 pc, r12, r10") 815 TEST_UNSUPPORTED(__inst_arm(0xe66cff7a) " @ uqsub16 pc, r12, r10")
815 TEST_RR( "uqadd8 r0, r",0, HH1,", r",1, HH2,"") 816 TEST_RR( "uqadd8 r0, r",0, HH1,", r",1, HH2,"")
816 TEST_RR( "uqadd8 r14, r",12,HH2,", r",10,HH1,"") 817 TEST_RR( "uqadd8 r14, r",12,HH2,", r",10,HH1,"")
817 TEST_UNSUPPORTED(".word 0xe66cff9a @ uqadd8 pc, r12, r10") 818 TEST_UNSUPPORTED(__inst_arm(0xe66cff9a) " @ uqadd8 pc, r12, r10")
818 TEST_UNSUPPORTED(".word 0xe66000b0") /* Unallocated space */ 819 TEST_UNSUPPORTED(__inst_arm(0xe66000b0) "") /* Unallocated space */
819 TEST_UNSUPPORTED(".word 0xe66fffbf") /* Unallocated space */ 820 TEST_UNSUPPORTED(__inst_arm(0xe66fffbf) "") /* Unallocated space */
820 TEST_UNSUPPORTED(".word 0xe66000d0") /* Unallocated space */ 821 TEST_UNSUPPORTED(__inst_arm(0xe66000d0) "") /* Unallocated space */
821 TEST_UNSUPPORTED(".word 0xe66fffdf") /* Unallocated space */ 822 TEST_UNSUPPORTED(__inst_arm(0xe66fffdf) "") /* Unallocated space */
822 TEST_RR( "uqsub8 r0, r",0, HH1,", r",1, HH2,"") 823 TEST_RR( "uqsub8 r0, r",0, HH1,", r",1, HH2,"")
823 TEST_RR( "uqsub8 r14, r",12,HH2,", r",10,HH1,"") 824 TEST_RR( "uqsub8 r14, r",12,HH2,", r",10,HH1,"")
824 TEST_UNSUPPORTED(".word 0xe66cfffa @ uqsub8 pc, r12, r10") 825 TEST_UNSUPPORTED(__inst_arm(0xe66cfffa) " @ uqsub8 pc, r12, r10")
825 826
826 TEST_RR( "uhadd16 r0, r",0, HH1,", r",1, HH2,"") 827 TEST_RR( "uhadd16 r0, r",0, HH1,", r",1, HH2,"")
827 TEST_RR( "uhadd16 r14, r",12,HH2,", r",10,HH1,"") 828 TEST_RR( "uhadd16 r14, r",12,HH2,", r",10,HH1,"")
828 TEST_UNSUPPORTED(".word 0xe67cff1a @ uhadd16 pc, r12, r10") 829 TEST_UNSUPPORTED(__inst_arm(0xe67cff1a) " @ uhadd16 pc, r12, r10")
829 TEST_RR( "uhasx r0, r",0, HH1,", r",1, HH2,"") 830 TEST_RR( "uhasx r0, r",0, HH1,", r",1, HH2,"")
830 TEST_RR( "uhasx r14, r",12,HH2,", r",10,HH1,"") 831 TEST_RR( "uhasx r14, r",12,HH2,", r",10,HH1,"")
831 TEST_UNSUPPORTED(".word 0xe67cff3a @ uhasx pc, r12, r10") 832 TEST_UNSUPPORTED(__inst_arm(0xe67cff3a) " @ uhasx pc, r12, r10")
832 TEST_RR( "uhsax r0, r",0, HH1,", r",1, HH2,"") 833 TEST_RR( "uhsax r0, r",0, HH1,", r",1, HH2,"")
833 TEST_RR( "uhsax r14, r",12,HH2,", r",10,HH1,"") 834 TEST_RR( "uhsax r14, r",12,HH2,", r",10,HH1,"")
834 TEST_UNSUPPORTED(".word 0xe67cff5a @ uhsax pc, r12, r10") 835 TEST_UNSUPPORTED(__inst_arm(0xe67cff5a) " @ uhsax pc, r12, r10")
835 TEST_RR( "uhsub16 r0, r",0, HH1,", r",1, HH2,"") 836 TEST_RR( "uhsub16 r0, r",0, HH1,", r",1, HH2,"")
836 TEST_RR( "uhsub16 r14, r",12,HH2,", r",10,HH1,"") 837 TEST_RR( "uhsub16 r14, r",12,HH2,", r",10,HH1,"")
837 TEST_UNSUPPORTED(".word 0xe67cff7a @ uhsub16 pc, r12, r10") 838 TEST_UNSUPPORTED(__inst_arm(0xe67cff7a) " @ uhsub16 pc, r12, r10")
838 TEST_RR( "uhadd8 r0, r",0, HH1,", r",1, HH2,"") 839 TEST_RR( "uhadd8 r0, r",0, HH1,", r",1, HH2,"")
839 TEST_RR( "uhadd8 r14, r",12,HH2,", r",10,HH1,"") 840 TEST_RR( "uhadd8 r14, r",12,HH2,", r",10,HH1,"")
840 TEST_UNSUPPORTED(".word 0xe67cff9a @ uhadd8 pc, r12, r10") 841 TEST_UNSUPPORTED(__inst_arm(0xe67cff9a) " @ uhadd8 pc, r12, r10")
841 TEST_UNSUPPORTED(".word 0xe67000b0") /* Unallocated space */ 842 TEST_UNSUPPORTED(__inst_arm(0xe67000b0) "") /* Unallocated space */
842 TEST_UNSUPPORTED(".word 0xe67fffbf") /* Unallocated space */ 843 TEST_UNSUPPORTED(__inst_arm(0xe67fffbf) "") /* Unallocated space */
843 TEST_UNSUPPORTED(".word 0xe67000d0") /* Unallocated space */ 844 TEST_UNSUPPORTED(__inst_arm(0xe67000d0) "") /* Unallocated space */
844 TEST_UNSUPPORTED(".word 0xe67fffdf") /* Unallocated space */ 845 TEST_UNSUPPORTED(__inst_arm(0xe67fffdf) "") /* Unallocated space */
845 TEST_RR( "uhsub8 r0, r",0, HH1,", r",1, HH2,"") 846 TEST_RR( "uhsub8 r0, r",0, HH1,", r",1, HH2,"")
846 TEST_RR( "uhsub8 r14, r",12,HH2,", r",10,HH1,"") 847 TEST_RR( "uhsub8 r14, r",12,HH2,", r",10,HH1,"")
847 TEST_UNSUPPORTED(".word 0xe67cfffa @ uhsub8 pc, r12, r10") 848 TEST_UNSUPPORTED(__inst_arm(0xe67cfffa) " @ uhsub8 pc, r12, r10")
848 TEST_UNSUPPORTED(".word 0xe67feffa @ uhsub8 r14, pc, r10") 849 TEST_UNSUPPORTED(__inst_arm(0xe67feffa) " @ uhsub8 r14, pc, r10")
849 TEST_UNSUPPORTED(".word 0xe67cefff @ uhsub8 r14, r12, pc") 850 TEST_UNSUPPORTED(__inst_arm(0xe67cefff) " @ uhsub8 r14, r12, pc")
850#endif /* __LINUX_ARM_ARCH__ >= 7 */ 851#endif /* __LINUX_ARM_ARCH__ >= 7 */
851 852
852#if __LINUX_ARM_ARCH__ >= 6 853#if __LINUX_ARM_ARCH__ >= 6
@@ -854,99 +855,99 @@ void kprobe_arm_test_cases(void)
854 855
855 TEST_RR( "pkhbt r0, r",0, HH1,", r",1, HH2,"") 856 TEST_RR( "pkhbt r0, r",0, HH1,", r",1, HH2,"")
856 TEST_RR( "pkhbt r14,r",12, HH1,", r",10,HH2,", lsl #2") 857 TEST_RR( "pkhbt r14,r",12, HH1,", r",10,HH2,", lsl #2")
857 TEST_UNSUPPORTED(".word 0xe68cf11a @ pkhbt pc, r12, r10, lsl #2") 858 TEST_UNSUPPORTED(__inst_arm(0xe68cf11a) " @ pkhbt pc, r12, r10, lsl #2")
858 TEST_RR( "pkhtb r0, r",0, HH1,", r",1, HH2,"") 859 TEST_RR( "pkhtb r0, r",0, HH1,", r",1, HH2,"")
859 TEST_RR( "pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2") 860 TEST_RR( "pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2")
860 TEST_UNSUPPORTED(".word 0xe68cf15a @ pkhtb pc, r12, r10, asr #2") 861 TEST_UNSUPPORTED(__inst_arm(0xe68cf15a) " @ pkhtb pc, r12, r10, asr #2")
861 TEST_UNSUPPORTED(".word 0xe68fe15a @ pkhtb r14, pc, r10, asr #2") 862 TEST_UNSUPPORTED(__inst_arm(0xe68fe15a) " @ pkhtb r14, pc, r10, asr #2")
862 TEST_UNSUPPORTED(".word 0xe68ce15f @ pkhtb r14, r12, pc, asr #2") 863 TEST_UNSUPPORTED(__inst_arm(0xe68ce15f) " @ pkhtb r14, r12, pc, asr #2")
863 TEST_UNSUPPORTED(".word 0xe6900010") /* Unallocated space */ 864 TEST_UNSUPPORTED(__inst_arm(0xe6900010) "") /* Unallocated space */
864 TEST_UNSUPPORTED(".word 0xe69fffdf") /* Unallocated space */ 865 TEST_UNSUPPORTED(__inst_arm(0xe69fffdf) "") /* Unallocated space */
865 866
866 TEST_R( "ssat r0, #24, r",0, VAL1,"") 867 TEST_R( "ssat r0, #24, r",0, VAL1,"")
867 TEST_R( "ssat r14, #24, r",12, VAL2,"") 868 TEST_R( "ssat r14, #24, r",12, VAL2,"")
868 TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8") 869 TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8")
869 TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8") 870 TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8")
870 TEST_UNSUPPORTED(".word 0xe6b7f01c @ ssat pc, #24, r12") 871 TEST_UNSUPPORTED(__inst_arm(0xe6b7f01c) " @ ssat pc, #24, r12")
871 872
872 TEST_R( "usat r0, #24, r",0, VAL1,"") 873 TEST_R( "usat r0, #24, r",0, VAL1,"")
873 TEST_R( "usat r14, #24, r",12, VAL2,"") 874 TEST_R( "usat r14, #24, r",12, VAL2,"")
874 TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8") 875 TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8")
875 TEST_R( "usat r14, #24, r",12, VAL2,", asr #8") 876 TEST_R( "usat r14, #24, r",12, VAL2,", asr #8")
876 TEST_UNSUPPORTED(".word 0xe6f7f01c @ usat pc, #24, r12") 877 TEST_UNSUPPORTED(__inst_arm(0xe6f7f01c) " @ usat pc, #24, r12")
877 878
878 TEST_RR( "sxtab16 r0, r",0, HH1,", r",1, HH2,"") 879 TEST_RR( "sxtab16 r0, r",0, HH1,", r",1, HH2,"")
879 TEST_RR( "sxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") 880 TEST_RR( "sxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8")
880 TEST_R( "sxtb16 r8, r",7, HH1,"") 881 TEST_R( "sxtb16 r8, r",7, HH1,"")
881 TEST_UNSUPPORTED(".word 0xe68cf47a @ sxtab16 pc,r12, r10, ror #8") 882 TEST_UNSUPPORTED(__inst_arm(0xe68cf47a) " @ sxtab16 pc,r12, r10, ror #8")
882 883
883 TEST_RR( "sel r0, r",0, VAL1,", r",1, VAL2,"") 884 TEST_RR( "sel r0, r",0, VAL1,", r",1, VAL2,"")
884 TEST_RR( "sel r14, r",12,VAL1,", r",10, VAL2,"") 885 TEST_RR( "sel r14, r",12,VAL1,", r",10, VAL2,"")
885 TEST_UNSUPPORTED(".word 0xe68cffba @ sel pc, r12, r10") 886 TEST_UNSUPPORTED(__inst_arm(0xe68cffba) " @ sel pc, r12, r10")
886 TEST_UNSUPPORTED(".word 0xe68fefba @ sel r14, pc, r10") 887 TEST_UNSUPPORTED(__inst_arm(0xe68fefba) " @ sel r14, pc, r10")
887 TEST_UNSUPPORTED(".word 0xe68cefbf @ sel r14, r12, pc") 888 TEST_UNSUPPORTED(__inst_arm(0xe68cefbf) " @ sel r14, r12, pc")
888 889
889 TEST_R( "ssat16 r0, #12, r",0, HH1,"") 890 TEST_R( "ssat16 r0, #12, r",0, HH1,"")
890 TEST_R( "ssat16 r14, #12, r",12, HH2,"") 891 TEST_R( "ssat16 r14, #12, r",12, HH2,"")
891 TEST_UNSUPPORTED(".word 0xe6abff3c @ ssat16 pc, #12, r12") 892 TEST_UNSUPPORTED(__inst_arm(0xe6abff3c) " @ ssat16 pc, #12, r12")
892 893
893 TEST_RR( "sxtab r0, r",0, HH1,", r",1, HH2,"") 894 TEST_RR( "sxtab r0, r",0, HH1,", r",1, HH2,"")
894 TEST_RR( "sxtab r14,r",12, HH2,", r",10,HH1,", ror #8") 895 TEST_RR( "sxtab r14,r",12, HH2,", r",10,HH1,", ror #8")
895 TEST_R( "sxtb r8, r",7, HH1,"") 896 TEST_R( "sxtb r8, r",7, HH1,"")
896 TEST_UNSUPPORTED(".word 0xe6acf47a @ sxtab pc,r12, r10, ror #8") 897 TEST_UNSUPPORTED(__inst_arm(0xe6acf47a) " @ sxtab pc,r12, r10, ror #8")
897 898
898 TEST_R( "rev r0, r",0, VAL1,"") 899 TEST_R( "rev r0, r",0, VAL1,"")
899 TEST_R( "rev r14, r",12, VAL2,"") 900 TEST_R( "rev r14, r",12, VAL2,"")
900 TEST_UNSUPPORTED(".word 0xe6bfff3c @ rev pc, r12") 901 TEST_UNSUPPORTED(__inst_arm(0xe6bfff3c) " @ rev pc, r12")
901 902
902 TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"") 903 TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"")
903 TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8") 904 TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8")
904 TEST_R( "sxth r8, r",7, HH1,"") 905 TEST_R( "sxth r8, r",7, HH1,"")
905 TEST_UNSUPPORTED(".word 0xe6bcf47a @ sxtah pc,r12, r10, ror #8") 906 TEST_UNSUPPORTED(__inst_arm(0xe6bcf47a) " @ sxtah pc,r12, r10, ror #8")
906 907
907 TEST_R( "rev16 r0, r",0, VAL1,"") 908 TEST_R( "rev16 r0, r",0, VAL1,"")
908 TEST_R( "rev16 r14, r",12, VAL2,"") 909 TEST_R( "rev16 r14, r",12, VAL2,"")
909 TEST_UNSUPPORTED(".word 0xe6bfffbc @ rev16 pc, r12") 910 TEST_UNSUPPORTED(__inst_arm(0xe6bfffbc) " @ rev16 pc, r12")
910 911
911 TEST_RR( "uxtab16 r0, r",0, HH1,", r",1, HH2,"") 912 TEST_RR( "uxtab16 r0, r",0, HH1,", r",1, HH2,"")
912 TEST_RR( "uxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8") 913 TEST_RR( "uxtab16 r14,r",12, HH2,", r",10,HH1,", ror #8")
913 TEST_R( "uxtb16 r8, r",7, HH1,"") 914 TEST_R( "uxtb16 r8, r",7, HH1,"")
914 TEST_UNSUPPORTED(".word 0xe6ccf47a @ uxtab16 pc,r12, r10, ror #8") 915 TEST_UNSUPPORTED(__inst_arm(0xe6ccf47a) " @ uxtab16 pc,r12, r10, ror #8")
915 916
916 TEST_R( "usat16 r0, #12, r",0, HH1,"") 917 TEST_R( "usat16 r0, #12, r",0, HH1,"")
917 TEST_R( "usat16 r14, #12, r",12, HH2,"") 918 TEST_R( "usat16 r14, #12, r",12, HH2,"")
918 TEST_UNSUPPORTED(".word 0xe6ecff3c @ usat16 pc, #12, r12") 919 TEST_UNSUPPORTED(__inst_arm(0xe6ecff3c) " @ usat16 pc, #12, r12")
919 TEST_UNSUPPORTED(".word 0xe6ecef3f @ usat16 r14, #12, pc") 920 TEST_UNSUPPORTED(__inst_arm(0xe6ecef3f) " @ usat16 r14, #12, pc")
920 921
921 TEST_RR( "uxtab r0, r",0, HH1,", r",1, HH2,"") 922 TEST_RR( "uxtab r0, r",0, HH1,", r",1, HH2,"")
922 TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8") 923 TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8")
923 TEST_R( "uxtb r8, r",7, HH1,"") 924 TEST_R( "uxtb r8, r",7, HH1,"")
924 TEST_UNSUPPORTED(".word 0xe6ecf47a @ uxtab pc,r12, r10, ror #8") 925 TEST_UNSUPPORTED(__inst_arm(0xe6ecf47a) " @ uxtab pc,r12, r10, ror #8")
925 926
926#if __LINUX_ARM_ARCH__ >= 7 927#if __LINUX_ARM_ARCH__ >= 7
927 TEST_R( "rbit r0, r",0, VAL1,"") 928 TEST_R( "rbit r0, r",0, VAL1,"")
928 TEST_R( "rbit r14, r",12, VAL2,"") 929 TEST_R( "rbit r14, r",12, VAL2,"")
929 TEST_UNSUPPORTED(".word 0xe6ffff3c @ rbit pc, r12") 930 TEST_UNSUPPORTED(__inst_arm(0xe6ffff3c) " @ rbit pc, r12")
930#endif 931#endif
931 932
932 TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"") 933 TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"")
933 TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8") 934 TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8")
934 TEST_R( "uxth r8, r",7, HH1,"") 935 TEST_R( "uxth r8, r",7, HH1,"")
935 TEST_UNSUPPORTED(".word 0xe6fff077 @ uxth pc, r7") 936 TEST_UNSUPPORTED(__inst_arm(0xe6fff077) " @ uxth pc, r7")
936 TEST_UNSUPPORTED(".word 0xe6ff807f @ uxth r8, pc") 937 TEST_UNSUPPORTED(__inst_arm(0xe6ff807f) " @ uxth r8, pc")
937 TEST_UNSUPPORTED(".word 0xe6fcf47a @ uxtah pc, r12, r10, ror #8") 938 TEST_UNSUPPORTED(__inst_arm(0xe6fcf47a) " @ uxtah pc, r12, r10, ror #8")
938 TEST_UNSUPPORTED(".word 0xe6fce47f @ uxtah r14, r12, pc, ror #8") 939 TEST_UNSUPPORTED(__inst_arm(0xe6fce47f) " @ uxtah r14, r12, pc, ror #8")
939 940
940 TEST_R( "revsh r0, r",0, VAL1,"") 941 TEST_R( "revsh r0, r",0, VAL1,"")
941 TEST_R( "revsh r14, r",12, VAL2,"") 942 TEST_R( "revsh r14, r",12, VAL2,"")
942 TEST_UNSUPPORTED(".word 0xe6ffff3c @ revsh pc, r12") 943 TEST_UNSUPPORTED(__inst_arm(0xe6ffff3c) " @ revsh pc, r12")
943 TEST_UNSUPPORTED(".word 0xe6ffef3f @ revsh r14, pc") 944 TEST_UNSUPPORTED(__inst_arm(0xe6ffef3f) " @ revsh r14, pc")
944 945
945 TEST_UNSUPPORTED(".word 0xe6900070") /* Unallocated space */ 946 TEST_UNSUPPORTED(__inst_arm(0xe6900070) "") /* Unallocated space */
946 TEST_UNSUPPORTED(".word 0xe69fff7f") /* Unallocated space */ 947 TEST_UNSUPPORTED(__inst_arm(0xe69fff7f) "") /* Unallocated space */
947 948
948 TEST_UNSUPPORTED(".word 0xe6d00070") /* Unallocated space */ 949 TEST_UNSUPPORTED(__inst_arm(0xe6d00070) "") /* Unallocated space */
949 TEST_UNSUPPORTED(".word 0xe6dfff7f") /* Unallocated space */ 950 TEST_UNSUPPORTED(__inst_arm(0xe6dfff7f) "") /* Unallocated space */
950#endif /* __LINUX_ARM_ARCH__ >= 6 */ 951#endif /* __LINUX_ARM_ARCH__ >= 6 */
951 952
952#if __LINUX_ARM_ARCH__ >= 6 953#if __LINUX_ARM_ARCH__ >= 6
@@ -954,79 +955,79 @@ void kprobe_arm_test_cases(void)
954 955
955 TEST_RRR( "smlad r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") 956 TEST_RRR( "smlad r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"")
956 TEST_RRR( "smlad r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") 957 TEST_RRR( "smlad r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"")
957 TEST_UNSUPPORTED(".word 0xe70f8a1c @ smlad pc, r12, r10, r8") 958 TEST_UNSUPPORTED(__inst_arm(0xe70f8a1c) " @ smlad pc, r12, r10, r8")
958 TEST_RRR( "smladx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") 959 TEST_RRR( "smladx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"")
959 TEST_RRR( "smladx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") 960 TEST_RRR( "smladx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"")
960 TEST_UNSUPPORTED(".word 0xe70f8a3c @ smladx pc, r12, r10, r8") 961 TEST_UNSUPPORTED(__inst_arm(0xe70f8a3c) " @ smladx pc, r12, r10, r8")
961 962
962 TEST_RR( "smuad r0, r",0, HH1,", r",1, HH2,"") 963 TEST_RR( "smuad r0, r",0, HH1,", r",1, HH2,"")
963 TEST_RR( "smuad r14, r",12,HH2,", r",10,HH1,"") 964 TEST_RR( "smuad r14, r",12,HH2,", r",10,HH1,"")
964 TEST_UNSUPPORTED(".word 0xe70ffa1c @ smuad pc, r12, r10") 965 TEST_UNSUPPORTED(__inst_arm(0xe70ffa1c) " @ smuad pc, r12, r10")
965 TEST_RR( "smuadx r0, r",0, HH1,", r",1, HH2,"") 966 TEST_RR( "smuadx r0, r",0, HH1,", r",1, HH2,"")
966 TEST_RR( "smuadx r14, r",12,HH2,", r",10,HH1,"") 967 TEST_RR( "smuadx r14, r",12,HH2,", r",10,HH1,"")
967 TEST_UNSUPPORTED(".word 0xe70ffa3c @ smuadx pc, r12, r10") 968 TEST_UNSUPPORTED(__inst_arm(0xe70ffa3c) " @ smuadx pc, r12, r10")
968 969
969 TEST_RRR( "smlsd r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") 970 TEST_RRR( "smlsd r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"")
970 TEST_RRR( "smlsd r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") 971 TEST_RRR( "smlsd r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"")
971 TEST_UNSUPPORTED(".word 0xe70f8a5c @ smlsd pc, r12, r10, r8") 972 TEST_UNSUPPORTED(__inst_arm(0xe70f8a5c) " @ smlsd pc, r12, r10, r8")
972 TEST_RRR( "smlsdx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"") 973 TEST_RRR( "smlsdx r0, r",0, HH1,", r",1, HH2,", r",2, VAL1,"")
973 TEST_RRR( "smlsdx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"") 974 TEST_RRR( "smlsdx r14, r",12,HH2,", r",10,HH1,", r",8, VAL2,"")
974 TEST_UNSUPPORTED(".word 0xe70f8a7c @ smlsdx pc, r12, r10, r8") 975 TEST_UNSUPPORTED(__inst_arm(0xe70f8a7c) " @ smlsdx pc, r12, r10, r8")
975 976
976 TEST_RR( "smusd r0, r",0, HH1,", r",1, HH2,"") 977 TEST_RR( "smusd r0, r",0, HH1,", r",1, HH2,"")
977 TEST_RR( "smusd r14, r",12,HH2,", r",10,HH1,"") 978 TEST_RR( "smusd r14, r",12,HH2,", r",10,HH1,"")
978 TEST_UNSUPPORTED(".word 0xe70ffa5c @ smusd pc, r12, r10") 979 TEST_UNSUPPORTED(__inst_arm(0xe70ffa5c) " @ smusd pc, r12, r10")
979 TEST_RR( "smusdx r0, r",0, HH1,", r",1, HH2,"") 980 TEST_RR( "smusdx r0, r",0, HH1,", r",1, HH2,"")
980 TEST_RR( "smusdx r14, r",12,HH2,", r",10,HH1,"") 981 TEST_RR( "smusdx r14, r",12,HH2,", r",10,HH1,"")
981 TEST_UNSUPPORTED(".word 0xe70ffa7c @ smusdx pc, r12, r10") 982 TEST_UNSUPPORTED(__inst_arm(0xe70ffa7c) " @ smusdx pc, r12, r10")
982 983
983 TEST_RRRR( "smlald r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) 984 TEST_RRRR( "smlald r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2)
984 TEST_RRRR( "smlald r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) 985 TEST_RRRR( "smlald r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1)
985 TEST_UNSUPPORTED(".word 0xe74af819 @ smlald pc, r10, r9, r8") 986 TEST_UNSUPPORTED(__inst_arm(0xe74af819) " @ smlald pc, r10, r9, r8")
986 TEST_UNSUPPORTED(".word 0xe74fb819 @ smlald r11, pc, r9, r8") 987 TEST_UNSUPPORTED(__inst_arm(0xe74fb819) " @ smlald r11, pc, r9, r8")
987 TEST_UNSUPPORTED(".word 0xe74ab81f @ smlald r11, r10, pc, r8") 988 TEST_UNSUPPORTED(__inst_arm(0xe74ab81f) " @ smlald r11, r10, pc, r8")
988 TEST_UNSUPPORTED(".word 0xe74abf19 @ smlald r11, r10, r9, pc") 989 TEST_UNSUPPORTED(__inst_arm(0xe74abf19) " @ smlald r11, r10, r9, pc")
989 990
990 TEST_RRRR( "smlaldx r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2) 991 TEST_RRRR( "smlaldx r",0, VAL1,", r",1, VAL2, ", r",0, HH1,", r",1, HH2)
991 TEST_RRRR( "smlaldx r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1) 992 TEST_RRRR( "smlaldx r",11,VAL2,", r",10,VAL1, ", r",9, HH2,", r",8, HH1)
992 TEST_UNSUPPORTED(".word 0xe74af839 @ smlaldx pc, r10, r9, r8") 993 TEST_UNSUPPORTED(__inst_arm(0xe74af839) " @ smlaldx pc, r10, r9, r8")
993 TEST_UNSUPPORTED(".word 0xe74fb839 @ smlaldx r11, pc, r9, r8") 994 TEST_UNSUPPORTED(__inst_arm(0xe74fb839) " @ smlaldx r11, pc, r9, r8")
994 995
995 TEST_RRR( "smmla r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") 996 TEST_RRR( "smmla r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"")
996 TEST_RRR( "smmla r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") 997 TEST_RRR( "smmla r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"")
997 TEST_UNSUPPORTED(".word 0xe75f8a1c @ smmla pc, r12, r10, r8") 998 TEST_UNSUPPORTED(__inst_arm(0xe75f8a1c) " @ smmla pc, r12, r10, r8")
998 TEST_RRR( "smmlar r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") 999 TEST_RRR( "smmlar r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"")
999 TEST_RRR( "smmlar r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") 1000 TEST_RRR( "smmlar r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"")
1000 TEST_UNSUPPORTED(".word 0xe75f8a3c @ smmlar pc, r12, r10, r8") 1001 TEST_UNSUPPORTED(__inst_arm(0xe75f8a3c) " @ smmlar pc, r12, r10, r8")
1001 1002
1002 TEST_RR( "smmul r0, r",0, VAL1,", r",1, VAL2,"") 1003 TEST_RR( "smmul r0, r",0, VAL1,", r",1, VAL2,"")
1003 TEST_RR( "smmul r14, r",12,VAL2,", r",10,VAL1,"") 1004 TEST_RR( "smmul r14, r",12,VAL2,", r",10,VAL1,"")
1004 TEST_UNSUPPORTED(".word 0xe75ffa1c @ smmul pc, r12, r10") 1005 TEST_UNSUPPORTED(__inst_arm(0xe75ffa1c) " @ smmul pc, r12, r10")
1005 TEST_RR( "smmulr r0, r",0, VAL1,", r",1, VAL2,"") 1006 TEST_RR( "smmulr r0, r",0, VAL1,", r",1, VAL2,"")
1006 TEST_RR( "smmulr r14, r",12,VAL2,", r",10,VAL1,"") 1007 TEST_RR( "smmulr r14, r",12,VAL2,", r",10,VAL1,"")
1007 TEST_UNSUPPORTED(".word 0xe75ffa3c @ smmulr pc, r12, r10") 1008 TEST_UNSUPPORTED(__inst_arm(0xe75ffa3c) " @ smmulr pc, r12, r10")
1008 1009
1009 TEST_RRR( "smmls r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") 1010 TEST_RRR( "smmls r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"")
1010 TEST_RRR( "smmls r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") 1011 TEST_RRR( "smmls r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"")
1011 TEST_UNSUPPORTED(".word 0xe75f8adc @ smmls pc, r12, r10, r8") 1012 TEST_UNSUPPORTED(__inst_arm(0xe75f8adc) " @ smmls pc, r12, r10, r8")
1012 TEST_RRR( "smmlsr r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"") 1013 TEST_RRR( "smmlsr r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL1,"")
1013 TEST_RRR( "smmlsr r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"") 1014 TEST_RRR( "smmlsr r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL2,"")
1014 TEST_UNSUPPORTED(".word 0xe75f8afc @ smmlsr pc, r12, r10, r8") 1015 TEST_UNSUPPORTED(__inst_arm(0xe75f8afc) " @ smmlsr pc, r12, r10, r8")
1015 TEST_UNSUPPORTED(".word 0xe75e8aff @ smmlsr r14, pc, r10, r8") 1016 TEST_UNSUPPORTED(__inst_arm(0xe75e8aff) " @ smmlsr r14, pc, r10, r8")
1016 TEST_UNSUPPORTED(".word 0xe75e8ffc @ smmlsr r14, r12, pc, r8") 1017 TEST_UNSUPPORTED(__inst_arm(0xe75e8ffc) " @ smmlsr r14, r12, pc, r8")
1017 TEST_UNSUPPORTED(".word 0xe75efafc @ smmlsr r14, r12, r10, pc") 1018 TEST_UNSUPPORTED(__inst_arm(0xe75efafc) " @ smmlsr r14, r12, r10, pc")
1018 1019
1019 TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"") 1020 TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"")
1020 TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"") 1021 TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"")
1021 TEST_UNSUPPORTED(".word 0xe75ffa1c @ usad8 pc, r12, r10") 1022 TEST_UNSUPPORTED(__inst_arm(0xe75ffa1c) " @ usad8 pc, r12, r10")
1022 TEST_UNSUPPORTED(".word 0xe75efa1f @ usad8 r14, pc, r10") 1023 TEST_UNSUPPORTED(__inst_arm(0xe75efa1f) " @ usad8 r14, pc, r10")
1023 TEST_UNSUPPORTED(".word 0xe75eff1c @ usad8 r14, r12, pc") 1024 TEST_UNSUPPORTED(__inst_arm(0xe75eff1c) " @ usad8 r14, r12, pc")
1024 1025
1025 TEST_RRR( "usada8 r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL3,"") 1026 TEST_RRR( "usada8 r0, r",0, VAL1,", r",1, VAL2,", r",2, VAL3,"")
1026 TEST_RRR( "usada8 r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL3,"") 1027 TEST_RRR( "usada8 r14, r",12,VAL2,", r",10,VAL1,", r",8, VAL3,"")
1027 TEST_UNSUPPORTED(".word 0xe78f8a1c @ usada8 pc, r12, r10, r8") 1028 TEST_UNSUPPORTED(__inst_arm(0xe78f8a1c) " @ usada8 pc, r12, r10, r8")
1028 TEST_UNSUPPORTED(".word 0xe78e8a1f @ usada8 r14, pc, r10, r8") 1029 TEST_UNSUPPORTED(__inst_arm(0xe78e8a1f) " @ usada8 r14, pc, r10, r8")
1029 TEST_UNSUPPORTED(".word 0xe78e8f1c @ usada8 r14, r12, pc, r8") 1030 TEST_UNSUPPORTED(__inst_arm(0xe78e8f1c) " @ usada8 r14, r12, pc, r8")
1030#endif /* __LINUX_ARM_ARCH__ >= 6 */ 1031#endif /* __LINUX_ARM_ARCH__ >= 6 */
1031 1032
1032#if __LINUX_ARM_ARCH__ >= 7 1033#if __LINUX_ARM_ARCH__ >= 7
@@ -1035,26 +1036,26 @@ void kprobe_arm_test_cases(void)
1035 TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31") 1036 TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31")
1036 TEST_R( "sbfxeq r14, r",12, VAL2,", #8, #16") 1037 TEST_R( "sbfxeq r14, r",12, VAL2,", #8, #16")
1037 TEST_R( "sbfx r4, r",10, VAL1,", #16, #15") 1038 TEST_R( "sbfx r4, r",10, VAL1,", #16, #15")
1038 TEST_UNSUPPORTED(".word 0xe7aff45c @ sbfx pc, r12, #8, #16") 1039 TEST_UNSUPPORTED(__inst_arm(0xe7aff45c) " @ sbfx pc, r12, #8, #16")
1039 1040
1040 TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31") 1041 TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31")
1041 TEST_R( "ubfxcs r14, r",12, VAL2,", #8, #16") 1042 TEST_R( "ubfxcs r14, r",12, VAL2,", #8, #16")
1042 TEST_R( "ubfx r4, r",10, VAL1,", #16, #15") 1043 TEST_R( "ubfx r4, r",10, VAL1,", #16, #15")
1043 TEST_UNSUPPORTED(".word 0xe7eff45c @ ubfx pc, r12, #8, #16") 1044 TEST_UNSUPPORTED(__inst_arm(0xe7eff45c) " @ ubfx pc, r12, #8, #16")
1044 TEST_UNSUPPORTED(".word 0xe7efc45f @ ubfx r12, pc, #8, #16") 1045 TEST_UNSUPPORTED(__inst_arm(0xe7efc45f) " @ ubfx r12, pc, #8, #16")
1045 1046
1046 TEST_R( "bfc r",0, VAL1,", #4, #20") 1047 TEST_R( "bfc r",0, VAL1,", #4, #20")
1047 TEST_R( "bfcvs r",14,VAL2,", #4, #20") 1048 TEST_R( "bfcvs r",14,VAL2,", #4, #20")
1048 TEST_R( "bfc r",7, VAL1,", #0, #31") 1049 TEST_R( "bfc r",7, VAL1,", #0, #31")
1049 TEST_R( "bfc r",8, VAL2,", #0, #31") 1050 TEST_R( "bfc r",8, VAL2,", #0, #31")
1050 TEST_UNSUPPORTED(".word 0xe7def01f @ bfc pc, #0, #31"); 1051 TEST_UNSUPPORTED(__inst_arm(0xe7def01f) " @ bfc pc, #0, #31");
1051 1052
1052 TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31") 1053 TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31")
1053 TEST_RR( "bfipl r",12,VAL1,", r",14 , VAL2,", #4, #20") 1054 TEST_RR( "bfipl r",12,VAL1,", r",14 , VAL2,", #4, #20")
1054 TEST_UNSUPPORTED(".word 0xe7d7f21e @ bfi pc, r14, #4, #20") 1055 TEST_UNSUPPORTED(__inst_arm(0xe7d7f21e) " @ bfi pc, r14, #4, #20")
1055 1056
1056 TEST_UNSUPPORTED(".word 0x07f000f0") /* Permanently UNDEFINED */ 1057 TEST_UNSUPPORTED(__inst_arm(0x07f000f0) "") /* Permanently UNDEFINED */
1057 TEST_UNSUPPORTED(".word 0x07ffffff") /* Permanently UNDEFINED */ 1058 TEST_UNSUPPORTED(__inst_arm(0x07ffffff) "") /* Permanently UNDEFINED */
1058#endif /* __LINUX_ARM_ARCH__ >= 6 */ 1059#endif /* __LINUX_ARM_ARCH__ >= 6 */
1059 1060
1060 TEST_GROUP("Branch, branch with link, and block data transfer") 1061 TEST_GROUP("Branch, branch with link, and block data transfer")
@@ -1181,43 +1182,43 @@ void kprobe_arm_test_cases(void)
1181 \ 1182 \
1182 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #4]") \ 1183 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #4]") \
1183 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #-4]") \ 1184 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15, #-4]") \
1184 TEST_UNSUPPORTED(".word 0x"cc"daf0001 @ stc"two" 0, cr0, [r15, #4]!") \ 1185 TEST_UNSUPPORTED(__inst_arm(0x##cc##daf0001) " @ stc"two" 0, cr0, [r15, #4]!") \
1185 TEST_UNSUPPORTED(".word 0x"cc"d2f0001 @ stc"two" 0, cr0, [r15, #-4]!") \ 1186 TEST_UNSUPPORTED(__inst_arm(0x##cc##d2f0001) " @ stc"two" 0, cr0, [r15, #-4]!") \
1186 TEST_UNSUPPORTED(".word 0x"cc"caf0001 @ stc"two" 0, cr0, [r15], #4") \ 1187 TEST_UNSUPPORTED(__inst_arm(0x##cc##caf0001) " @ stc"two" 0, cr0, [r15], #4") \
1187 TEST_UNSUPPORTED(".word 0x"cc"c2f0001 @ stc"two" 0, cr0, [r15], #-4") \ 1188 TEST_UNSUPPORTED(__inst_arm(0x##cc##c2f0001) " @ stc"two" 0, cr0, [r15], #-4") \
1188 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15], {1}") \ 1189 TEST_COPROCESSOR( "stc"two" 0, cr0, [r15], {1}") \
1189 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #4]") \ 1190 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #4]") \
1190 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #-4]") \ 1191 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15, #-4]") \
1191 TEST_UNSUPPORTED(".word 0x"cc"def0001 @ stc"two"l 0, cr0, [r15, #4]!") \ 1192 TEST_UNSUPPORTED(__inst_arm(0x##cc##def0001) " @ stc"two"l 0, cr0, [r15, #4]!") \
1192 TEST_UNSUPPORTED(".word 0x"cc"d6f0001 @ stc"two"l 0, cr0, [r15, #-4]!") \ 1193 TEST_UNSUPPORTED(__inst_arm(0x##cc##d6f0001) " @ stc"two"l 0, cr0, [r15, #-4]!") \
1193 TEST_UNSUPPORTED(".word 0x"cc"cef0001 @ stc"two"l 0, cr0, [r15], #4") \ 1194 TEST_UNSUPPORTED(__inst_arm(0x##cc##cef0001) " @ stc"two"l 0, cr0, [r15], #4") \
1194 TEST_UNSUPPORTED(".word 0x"cc"c6f0001 @ stc"two"l 0, cr0, [r15], #-4") \ 1195 TEST_UNSUPPORTED(__inst_arm(0x##cc##c6f0001) " @ stc"two"l 0, cr0, [r15], #-4") \
1195 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15], {1}") \ 1196 TEST_COPROCESSOR( "stc"two"l 0, cr0, [r15], {1}") \
1196 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #4]") \ 1197 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #4]") \
1197 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #-4]") \ 1198 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15, #-4]") \
1198 TEST_UNSUPPORTED(".word 0x"cc"dbf0001 @ ldc"two" 0, cr0, [r15, #4]!") \ 1199 TEST_UNSUPPORTED(__inst_arm(0x##cc##dbf0001) " @ ldc"two" 0, cr0, [r15, #4]!") \
1199 TEST_UNSUPPORTED(".word 0x"cc"d3f0001 @ ldc"two" 0, cr0, [r15, #-4]!") \ 1200 TEST_UNSUPPORTED(__inst_arm(0x##cc##d3f0001) " @ ldc"two" 0, cr0, [r15, #-4]!") \
1200 TEST_UNSUPPORTED(".word 0x"cc"cbf0001 @ ldc"two" 0, cr0, [r15], #4") \ 1201 TEST_UNSUPPORTED(__inst_arm(0x##cc##cbf0001) " @ ldc"two" 0, cr0, [r15], #4") \
1201 TEST_UNSUPPORTED(".word 0x"cc"c3f0001 @ ldc"two" 0, cr0, [r15], #-4") \ 1202 TEST_UNSUPPORTED(__inst_arm(0x##cc##c3f0001) " @ ldc"two" 0, cr0, [r15], #-4") \
1202 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15], {1}") \ 1203 TEST_COPROCESSOR( "ldc"two" 0, cr0, [r15], {1}") \
1203 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #4]") \ 1204 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #4]") \
1204 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #-4]") \ 1205 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15, #-4]") \
1205 TEST_UNSUPPORTED(".word 0x"cc"dff0001 @ ldc"two"l 0, cr0, [r15, #4]!") \ 1206 TEST_UNSUPPORTED(__inst_arm(0x##cc##dff0001) " @ ldc"two"l 0, cr0, [r15, #4]!") \
1206 TEST_UNSUPPORTED(".word 0x"cc"d7f0001 @ ldc"two"l 0, cr0, [r15, #-4]!") \ 1207 TEST_UNSUPPORTED(__inst_arm(0x##cc##d7f0001) " @ ldc"two"l 0, cr0, [r15, #-4]!") \
1207 TEST_UNSUPPORTED(".word 0x"cc"cff0001 @ ldc"two"l 0, cr0, [r15], #4") \ 1208 TEST_UNSUPPORTED(__inst_arm(0x##cc##cff0001) " @ ldc"two"l 0, cr0, [r15], #4") \
1208 TEST_UNSUPPORTED(".word 0x"cc"c7f0001 @ ldc"two"l 0, cr0, [r15], #-4") \ 1209 TEST_UNSUPPORTED(__inst_arm(0x##cc##c7f0001) " @ ldc"two"l 0, cr0, [r15], #-4") \
1209 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15], {1}") 1210 TEST_COPROCESSOR( "ldc"two"l 0, cr0, [r15], {1}")
1210 1211
1211#define COPROCESSOR_INSTRUCTIONS_MC_MR(two,cc) \ 1212#define COPROCESSOR_INSTRUCTIONS_MC_MR(two,cc) \
1212 \ 1213 \
1213 TEST_COPROCESSOR( "mcrr"two" 0, 15, r0, r14, cr0") \ 1214 TEST_COPROCESSOR( "mcrr"two" 0, 15, r0, r14, cr0") \
1214 TEST_COPROCESSOR( "mcrr"two" 15, 0, r14, r0, cr15") \ 1215 TEST_COPROCESSOR( "mcrr"two" 15, 0, r14, r0, cr15") \
1215 TEST_UNSUPPORTED(".word 0x"cc"c4f00f0 @ mcrr"two" 0, 15, r0, r15, cr0") \ 1216 TEST_UNSUPPORTED(__inst_arm(0x##cc##c4f00f0) " @ mcrr"two" 0, 15, r0, r15, cr0") \
1216 TEST_UNSUPPORTED(".word 0x"cc"c40ff0f @ mcrr"two" 15, 0, r15, r0, cr15") \ 1217 TEST_UNSUPPORTED(__inst_arm(0x##cc##c40ff0f) " @ mcrr"two" 15, 0, r15, r0, cr15") \
1217 TEST_COPROCESSOR( "mrrc"two" 0, 15, r0, r14, cr0") \ 1218 TEST_COPROCESSOR( "mrrc"two" 0, 15, r0, r14, cr0") \
1218 TEST_COPROCESSOR( "mrrc"two" 15, 0, r14, r0, cr15") \ 1219 TEST_COPROCESSOR( "mrrc"two" 15, 0, r14, r0, cr15") \
1219 TEST_UNSUPPORTED(".word 0x"cc"c5f00f0 @ mrrc"two" 0, 15, r0, r15, cr0") \ 1220 TEST_UNSUPPORTED(__inst_arm(0x##cc##c5f00f0) " @ mrrc"two" 0, 15, r0, r15, cr0") \
1220 TEST_UNSUPPORTED(".word 0x"cc"c50ff0f @ mrrc"two" 15, 0, r15, r0, cr15") \ 1221 TEST_UNSUPPORTED(__inst_arm(0x##cc##c50ff0f) " @ mrrc"two" 15, 0, r15, r0, cr15") \
1221 TEST_COPROCESSOR( "cdp"two" 15, 15, cr15, cr15, cr15, 7") \ 1222 TEST_COPROCESSOR( "cdp"two" 15, 15, cr15, cr15, cr15, 7") \
1222 TEST_COPROCESSOR( "cdp"two" 0, 0, cr0, cr0, cr0, 0") \ 1223 TEST_COPROCESSOR( "cdp"two" 0, 0, cr0, cr0, cr0, 0") \
1223 TEST_COPROCESSOR( "mcr"two" 15, 7, r15, cr15, cr15, 7") \ 1224 TEST_COPROCESSOR( "mcr"two" 15, 7, r15, cr15, cr15, 7") \
@@ -1225,8 +1226,8 @@ void kprobe_arm_test_cases(void)
1225 TEST_COPROCESSOR( "mrc"two" 15, 7, r15, cr15, cr15, 7") \ 1226 TEST_COPROCESSOR( "mrc"two" 15, 7, r15, cr15, cr15, 7") \
1226 TEST_COPROCESSOR( "mrc"two" 0, 0, r0, cr0, cr0, 0") 1227 TEST_COPROCESSOR( "mrc"two" 0, 0, r0, cr0, cr0, 0")
1227 1228
1228 COPROCESSOR_INSTRUCTIONS_ST_LD("","e") 1229 COPROCESSOR_INSTRUCTIONS_ST_LD("",e)
1229 COPROCESSOR_INSTRUCTIONS_MC_MR("","e") 1230 COPROCESSOR_INSTRUCTIONS_MC_MR("",e)
1230 TEST_UNSUPPORTED("svc 0") 1231 TEST_UNSUPPORTED("svc 0")
1231 TEST_UNSUPPORTED("svc 0xffffff") 1232 TEST_UNSUPPORTED("svc 0xffffff")
1232 1233
@@ -1252,14 +1253,14 @@ void kprobe_arm_test_cases(void)
1252 TEST_UNSUPPORTED("rfedb sp!") 1253 TEST_UNSUPPORTED("rfedb sp!")
1253 TEST_UNSUPPORTED("rfeia sp!") 1254 TEST_UNSUPPORTED("rfeia sp!")
1254 TEST_UNSUPPORTED("rfeib sp!") 1255 TEST_UNSUPPORTED("rfeib sp!")
1255 TEST_UNSUPPORTED(".word 0xf81d0a00 @ rfeda pc") 1256 TEST_UNSUPPORTED(__inst_arm(0xf81d0a00) " @ rfeda pc")
1256 TEST_UNSUPPORTED(".word 0xf91d0a00 @ rfedb pc") 1257 TEST_UNSUPPORTED(__inst_arm(0xf91d0a00) " @ rfedb pc")
1257 TEST_UNSUPPORTED(".word 0xf89d0a00 @ rfeia pc") 1258 TEST_UNSUPPORTED(__inst_arm(0xf89d0a00) " @ rfeia pc")
1258 TEST_UNSUPPORTED(".word 0xf99d0a00 @ rfeib pc") 1259 TEST_UNSUPPORTED(__inst_arm(0xf99d0a00) " @ rfeib pc")
1259 TEST_UNSUPPORTED(".word 0xf83d0a00 @ rfeda pc!") 1260 TEST_UNSUPPORTED(__inst_arm(0xf83d0a00) " @ rfeda pc!")
1260 TEST_UNSUPPORTED(".word 0xf93d0a00 @ rfedb pc!") 1261 TEST_UNSUPPORTED(__inst_arm(0xf93d0a00) " @ rfedb pc!")
1261 TEST_UNSUPPORTED(".word 0xf8bd0a00 @ rfeia pc!") 1262 TEST_UNSUPPORTED(__inst_arm(0xf8bd0a00) " @ rfeia pc!")
1262 TEST_UNSUPPORTED(".word 0xf9bd0a00 @ rfeib pc!") 1263 TEST_UNSUPPORTED(__inst_arm(0xf9bd0a00) " @ rfeib pc!")
1263#endif /* __LINUX_ARM_ARCH__ >= 6 */ 1264#endif /* __LINUX_ARM_ARCH__ >= 6 */
1264 1265
1265#if __LINUX_ARM_ARCH__ >= 6 1266#if __LINUX_ARM_ARCH__ >= 6
@@ -1286,9 +1287,9 @@ void kprobe_arm_test_cases(void)
1286 TEST( "blx __dummy_thumb_subroutine_odd") 1287 TEST( "blx __dummy_thumb_subroutine_odd")
1287#endif /* __LINUX_ARM_ARCH__ >= 6 */ 1288#endif /* __LINUX_ARM_ARCH__ >= 6 */
1288 1289
1289 COPROCESSOR_INSTRUCTIONS_ST_LD("2","f") 1290 COPROCESSOR_INSTRUCTIONS_ST_LD("2",f)
1290#if __LINUX_ARM_ARCH__ >= 6 1291#if __LINUX_ARM_ARCH__ >= 6
1291 COPROCESSOR_INSTRUCTIONS_MC_MR("2","f") 1292 COPROCESSOR_INSTRUCTIONS_MC_MR("2",f)
1292#endif 1293#endif
1293 1294
1294 TEST_GROUP("Miscellaneous instructions, memory hints, and Advanced SIMD instructions") 1295 TEST_GROUP("Miscellaneous instructions, memory hints, and Advanced SIMD instructions")
@@ -1318,9 +1319,9 @@ void kprobe_arm_test_cases(void)
1318#endif 1319#endif
1319 1320
1320#if __LINUX_ARM_ARCH__ >= 7 1321#if __LINUX_ARM_ARCH__ >= 7
1321 TEST_SUPPORTED( ".word 0xf590f000 @ pldw [r0, #0]") 1322 TEST_SUPPORTED( __inst_arm(0xf590f000) " @ pldw [r0, #0]")
1322 TEST_SUPPORTED( ".word 0xf797f000 @ pldw [r7, r0]") 1323 TEST_SUPPORTED( __inst_arm(0xf797f000) " @ pldw [r7, r0]")
1323 TEST_SUPPORTED( ".word 0xf798f18c @ pldw [r8, r12, lsl #3]"); 1324 TEST_SUPPORTED( __inst_arm(0xf798f18c) " @ pldw [r8, r12, lsl #3]");
1324#endif 1325#endif
1325 1326
1326#if __LINUX_ARM_ARCH__ >= 7 1327#if __LINUX_ARM_ARCH__ >= 7
diff --git a/arch/arm/kernel/kprobes-test-thumb.c b/arch/arm/kernel/kprobes-test-thumb.c
index 5d8b85792222..844dd10d8593 100644
--- a/arch/arm/kernel/kprobes-test-thumb.c
+++ b/arch/arm/kernel/kprobes-test-thumb.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <asm/opcodes.h>
13 14
14#include "kprobes-test.h" 15#include "kprobes-test.h"
15 16
@@ -119,7 +120,7 @@ void kprobe_thumb16_test_cases(void)
119 TEST_R( "add sp" ", r",8,-8, "") 120 TEST_R( "add sp" ", r",8,-8, "")
120 TEST_R( "add r",14,VAL1,", pc") 121 TEST_R( "add r",14,VAL1,", pc")
121 TEST_BF_R("add pc" ", r",0,2f-1f-8,"") 122 TEST_BF_R("add pc" ", r",0,2f-1f-8,"")
122 TEST_UNSUPPORTED(".short 0x44ff @ add pc, pc") 123 TEST_UNSUPPORTED(__inst_thumb16(0x44ff) " @ add pc, pc")
123 124
124 TEST_RR( "cmp r",3,VAL1,", r",8,VAL2,"") 125 TEST_RR( "cmp r",3,VAL1,", r",8,VAL2,"")
125 TEST_RR( "cmp r",8,VAL2,", r",0,VAL1,"") 126 TEST_RR( "cmp r",8,VAL2,", r",0,VAL1,"")
@@ -150,7 +151,7 @@ void kprobe_thumb16_test_cases(void)
150 151
151 TEST_BF_R("blx r",0, 2f+1,"") 152 TEST_BF_R("blx r",0, 2f+1,"")
152 TEST_BB_R("blx r",14,2f+1,"") 153 TEST_BB_R("blx r",14,2f+1,"")
153 TEST_UNSUPPORTED(".short 0x47f8 @ blx pc") 154 TEST_UNSUPPORTED(__inst_thumb16(0x47f8) " @ blx pc")
154 155
155 TEST_GROUP("Load from Literal Pool") 156 TEST_GROUP("Load from Literal Pool")
156 157
@@ -237,8 +238,8 @@ DONT_TEST_IN_ITBLOCK(
237 TEST_R("rev r7, r",0, VAL2,"") 238 TEST_R("rev r7, r",0, VAL2,"")
238 TEST_R("rev16 r0, r",7, VAL1,"") 239 TEST_R("rev16 r0, r",7, VAL1,"")
239 TEST_R("rev16 r7, r",0, VAL2,"") 240 TEST_R("rev16 r7, r",0, VAL2,"")
240 TEST_UNSUPPORTED(".short 0xba80") 241 TEST_UNSUPPORTED(__inst_thumb16(0xba80) "")
241 TEST_UNSUPPORTED(".short 0xbabf") 242 TEST_UNSUPPORTED(__inst_thumb16(0xbabf) "")
242 TEST_R("revsh r0, r",7, VAL1,"") 243 TEST_R("revsh r0, r",7, VAL1,"")
243 TEST_R("revsh r7, r",0, VAL2,"") 244 TEST_R("revsh r7, r",0, VAL2,"")
244 245
@@ -272,8 +273,8 @@ DONT_TEST_IN_ITBLOCK(
272 TEST("nop") 273 TEST("nop")
273 TEST("wfi") 274 TEST("wfi")
274 TEST_SUPPORTED("wfe") 275 TEST_SUPPORTED("wfe")
275 TEST_UNSUPPORTED(".short 0xbf50") /* Unassigned hints */ 276 TEST_UNSUPPORTED(__inst_thumb16(0xbf50) "") /* Unassigned hints */
276 TEST_UNSUPPORTED(".short 0xbff0") /* Unassigned hints */ 277 TEST_UNSUPPORTED(__inst_thumb16(0xbff0) "") /* Unassigned hints */
277 278
278#define TEST_IT(code, code2) \ 279#define TEST_IT(code, code2) \
279 TESTCASE_START(code) \ 280 TESTCASE_START(code) \
@@ -310,8 +311,8 @@ CONDITION_INSTRUCTIONS(8,
310 TEST_BF("bgt 2f") 311 TEST_BF("bgt 2f")
311 TEST_BB("blt 2b") 312 TEST_BB("blt 2b")
312) 313)
313 TEST_UNSUPPORTED(".short 0xde00") 314 TEST_UNSUPPORTED(__inst_thumb16(0xde00) "")
314 TEST_UNSUPPORTED(".short 0xdeff") 315 TEST_UNSUPPORTED(__inst_thumb16(0xdeff) "")
315 TEST_UNSUPPORTED("svc #0x00") 316 TEST_UNSUPPORTED("svc #0x00")
316 TEST_UNSUPPORTED("svc #0xff") 317 TEST_UNSUPPORTED("svc #0xff")
317 318
@@ -380,13 +381,13 @@ void kprobe_thumb32_test_cases(void)
380 TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",0,14*4,", {r12,pc}") 381 TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",0,14*4,", {r12,pc}")
381 TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",13,2*4,", {r0-r12,pc}") 382 TEST_THUMB_TO_ARM_INTERWORK_P("ldmia r",13,2*4,", {r0-r12,pc}")
382 383
383 TEST_UNSUPPORTED(".short 0xe88f,0x0101 @ stmia pc, {r0,r8}") 384 TEST_UNSUPPORTED(__inst_thumb32(0xe88f0101) " @ stmia pc, {r0,r8}")
384 TEST_UNSUPPORTED(".short 0xe92f,0x5f00 @ stmdb pc!, {r8-r12,r14}") 385 TEST_UNSUPPORTED(__inst_thumb32(0xe92f5f00) " @ stmdb pc!, {r8-r12,r14}")
385 TEST_UNSUPPORTED(".short 0xe8bd,0xc000 @ ldmia r13!, {r14,pc}") 386 TEST_UNSUPPORTED(__inst_thumb32(0xe8bdc000) " @ ldmia r13!, {r14,pc}")
386 TEST_UNSUPPORTED(".short 0xe93e,0xc000 @ ldmdb r14!, {r14,pc}") 387 TEST_UNSUPPORTED(__inst_thumb32(0xe93ec000) " @ ldmdb r14!, {r14,pc}")
387 TEST_UNSUPPORTED(".short 0xe8a7,0x3f00 @ stmia r7!, {r8-r12,sp}") 388 TEST_UNSUPPORTED(__inst_thumb32(0xe8a73f00) " @ stmia r7!, {r8-r12,sp}")
388 TEST_UNSUPPORTED(".short 0xe8a7,0x9f00 @ stmia r7!, {r8-r12,pc}") 389 TEST_UNSUPPORTED(__inst_thumb32(0xe8a79f00) " @ stmia r7!, {r8-r12,pc}")
389 TEST_UNSUPPORTED(".short 0xe93e,0x2010 @ ldmdb r14!, {r4,sp}") 390 TEST_UNSUPPORTED(__inst_thumb32(0xe93e2010) " @ ldmdb r14!, {r4,sp}")
390 391
391 TEST_GROUP("Load/store double or exclusive, table branch") 392 TEST_GROUP("Load/store double or exclusive, table branch")
392 393
@@ -402,12 +403,12 @@ void kprobe_thumb32_test_cases(void)
402 "3: .word "__stringify(VAL1)" \n\t" 403 "3: .word "__stringify(VAL1)" \n\t"
403 " .word "__stringify(VAL2)) 404 " .word "__stringify(VAL2))
404 405
405 TEST_UNSUPPORTED(".short 0xe9ff,0xec04 @ ldrd r14, r12, [pc, #16]!") 406 TEST_UNSUPPORTED(__inst_thumb32(0xe9ffec04) " @ ldrd r14, r12, [pc, #16]!")
406 TEST_UNSUPPORTED(".short 0xe8ff,0xec04 @ ldrd r14, r12, [pc], #16") 407 TEST_UNSUPPORTED(__inst_thumb32(0xe8ffec04) " @ ldrd r14, r12, [pc], #16")
407 TEST_UNSUPPORTED(".short 0xe9d4,0xd800 @ ldrd sp, r8, [r4]") 408 TEST_UNSUPPORTED(__inst_thumb32(0xe9d4d800) " @ ldrd sp, r8, [r4]")
408 TEST_UNSUPPORTED(".short 0xe9d4,0xf800 @ ldrd pc, r8, [r4]") 409 TEST_UNSUPPORTED(__inst_thumb32(0xe9d4f800) " @ ldrd pc, r8, [r4]")
409 TEST_UNSUPPORTED(".short 0xe9d4,0x7d00 @ ldrd r7, sp, [r4]") 410 TEST_UNSUPPORTED(__inst_thumb32(0xe9d47d00) " @ ldrd r7, sp, [r4]")
410 TEST_UNSUPPORTED(".short 0xe9d4,0x7f00 @ ldrd r7, pc, [r4]") 411 TEST_UNSUPPORTED(__inst_thumb32(0xe9d47f00) " @ ldrd r7, pc, [r4]")
411 412
412 TEST_RRP("strd r",0, VAL1,", r",1, VAL2,", [r",1, 24,", #-16]") 413 TEST_RRP("strd r",0, VAL1,", r",1, VAL2,", [r",1, 24,", #-16]")
413 TEST_RR( "strd r",12,VAL2,", r",14,VAL1,", [sp, #16]") 414 TEST_RR( "strd r",12,VAL2,", r",14,VAL1,", [sp, #16]")
@@ -415,8 +416,8 @@ void kprobe_thumb32_test_cases(void)
415 TEST_RR( "strd r",14,VAL2,", r",12,VAL1,", [sp, #16]!") 416 TEST_RR( "strd r",14,VAL2,", r",12,VAL1,", [sp, #16]!")
416 TEST_RRP("strd r",1, VAL1,", r",0, VAL2,", [r",7, 24,"], #16") 417 TEST_RRP("strd r",1, VAL1,", r",0, VAL2,", [r",7, 24,"], #16")
417 TEST_RR( "strd r",7, VAL2,", r",8, VAL1,", [sp], #-16") 418 TEST_RR( "strd r",7, VAL2,", r",8, VAL1,", [sp], #-16")
418 TEST_UNSUPPORTED(".short 0xe9ef,0xec04 @ strd r14, r12, [pc, #16]!") 419 TEST_UNSUPPORTED(__inst_thumb32(0xe9efec04) " @ strd r14, r12, [pc, #16]!")
419 TEST_UNSUPPORTED(".short 0xe8ef,0xec04 @ strd r14, r12, [pc], #16") 420 TEST_UNSUPPORTED(__inst_thumb32(0xe8efec04) " @ strd r14, r12, [pc], #16")
420 421
421 TEST_RX("tbb [pc, r",0, (9f-(1f+4)),"]", 422 TEST_RX("tbb [pc, r",0, (9f-(1f+4)),"]",
422 "9: \n\t" 423 "9: \n\t"
@@ -460,9 +461,9 @@ void kprobe_thumb32_test_cases(void)
460 "3: mvn r0, r0 \n\t" 461 "3: mvn r0, r0 \n\t"
461 "2: nop \n\t") 462 "2: nop \n\t")
462 463
463 TEST_UNSUPPORTED(".short 0xe8d1,0xf01f @ tbh [r1, pc]") 464 TEST_UNSUPPORTED(__inst_thumb32(0xe8d1f01f) " @ tbh [r1, pc]")
464 TEST_UNSUPPORTED(".short 0xe8d1,0xf01d @ tbh [r1, sp]") 465 TEST_UNSUPPORTED(__inst_thumb32(0xe8d1f01d) " @ tbh [r1, sp]")
465 TEST_UNSUPPORTED(".short 0xe8dd,0xf012 @ tbh [sp, r2]") 466 TEST_UNSUPPORTED(__inst_thumb32(0xe8ddf012) " @ tbh [sp, r2]")
466 467
467 TEST_UNSUPPORTED("strexb r0, r1, [r2]") 468 TEST_UNSUPPORTED("strexb r0, r1, [r2]")
468 TEST_UNSUPPORTED("strexh r0, r1, [r2]") 469 TEST_UNSUPPORTED("strexh r0, r1, [r2]")
@@ -540,40 +541,40 @@ void kprobe_thumb32_test_cases(void)
540 TEST_RR("pkhtb r0, r",0, HH1,", r",1, HH2,"") 541 TEST_RR("pkhtb r0, r",0, HH1,", r",1, HH2,"")
541 TEST_RR("pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2") 542 TEST_RR("pkhtb r14,r",12, HH1,", r",10,HH2,", asr #2")
542 543
543 TEST_UNSUPPORTED(".short 0xea17,0x0f0d @ tst.w r7, sp") 544 TEST_UNSUPPORTED(__inst_thumb32(0xea170f0d) " @ tst.w r7, sp")
544 TEST_UNSUPPORTED(".short 0xea17,0x0f0f @ tst.w r7, pc") 545 TEST_UNSUPPORTED(__inst_thumb32(0xea170f0f) " @ tst.w r7, pc")
545 TEST_UNSUPPORTED(".short 0xea1d,0x0f07 @ tst.w sp, r7") 546 TEST_UNSUPPORTED(__inst_thumb32(0xea1d0f07) " @ tst.w sp, r7")
546 TEST_UNSUPPORTED(".short 0xea1f,0x0f07 @ tst.w pc, r7") 547 TEST_UNSUPPORTED(__inst_thumb32(0xea1f0f07) " @ tst.w pc, r7")
547 TEST_UNSUPPORTED(".short 0xf01d,0x1f08 @ tst sp, #0x00080008") 548 TEST_UNSUPPORTED(__inst_thumb32(0xf01d1f08) " @ tst sp, #0x00080008")
548 TEST_UNSUPPORTED(".short 0xf01f,0x1f08 @ tst pc, #0x00080008") 549 TEST_UNSUPPORTED(__inst_thumb32(0xf01f1f08) " @ tst pc, #0x00080008")
549 550
550 TEST_UNSUPPORTED(".short 0xea97,0x0f0d @ teq.w r7, sp") 551 TEST_UNSUPPORTED(__inst_thumb32(0xea970f0d) " @ teq.w r7, sp")
551 TEST_UNSUPPORTED(".short 0xea97,0x0f0f @ teq.w r7, pc") 552 TEST_UNSUPPORTED(__inst_thumb32(0xea970f0f) " @ teq.w r7, pc")
552 TEST_UNSUPPORTED(".short 0xea9d,0x0f07 @ teq.w sp, r7") 553 TEST_UNSUPPORTED(__inst_thumb32(0xea9d0f07) " @ teq.w sp, r7")
553 TEST_UNSUPPORTED(".short 0xea9f,0x0f07 @ teq.w pc, r7") 554 TEST_UNSUPPORTED(__inst_thumb32(0xea9f0f07) " @ teq.w pc, r7")
554 TEST_UNSUPPORTED(".short 0xf09d,0x1f08 @ tst sp, #0x00080008") 555 TEST_UNSUPPORTED(__inst_thumb32(0xf09d1f08) " @ tst sp, #0x00080008")
555 TEST_UNSUPPORTED(".short 0xf09f,0x1f08 @ tst pc, #0x00080008") 556 TEST_UNSUPPORTED(__inst_thumb32(0xf09f1f08) " @ tst pc, #0x00080008")
556 557
557 TEST_UNSUPPORTED(".short 0xeb17,0x0f0d @ cmn.w r7, sp") 558 TEST_UNSUPPORTED(__inst_thumb32(0xeb170f0d) " @ cmn.w r7, sp")
558 TEST_UNSUPPORTED(".short 0xeb17,0x0f0f @ cmn.w r7, pc") 559 TEST_UNSUPPORTED(__inst_thumb32(0xeb170f0f) " @ cmn.w r7, pc")
559 TEST_P("cmn.w sp, r",7,0,"") 560 TEST_P("cmn.w sp, r",7,0,"")
560 TEST_UNSUPPORTED(".short 0xeb1f,0x0f07 @ cmn.w pc, r7") 561 TEST_UNSUPPORTED(__inst_thumb32(0xeb1f0f07) " @ cmn.w pc, r7")
561 TEST( "cmn sp, #0x00080008") 562 TEST( "cmn sp, #0x00080008")
562 TEST_UNSUPPORTED(".short 0xf11f,0x1f08 @ cmn pc, #0x00080008") 563 TEST_UNSUPPORTED(__inst_thumb32(0xf11f1f08) " @ cmn pc, #0x00080008")
563 564
564 TEST_UNSUPPORTED(".short 0xebb7,0x0f0d @ cmp.w r7, sp") 565 TEST_UNSUPPORTED(__inst_thumb32(0xebb70f0d) " @ cmp.w r7, sp")
565 TEST_UNSUPPORTED(".short 0xebb7,0x0f0f @ cmp.w r7, pc") 566 TEST_UNSUPPORTED(__inst_thumb32(0xebb70f0f) " @ cmp.w r7, pc")
566 TEST_P("cmp.w sp, r",7,0,"") 567 TEST_P("cmp.w sp, r",7,0,"")
567 TEST_UNSUPPORTED(".short 0xebbf,0x0f07 @ cmp.w pc, r7") 568 TEST_UNSUPPORTED(__inst_thumb32(0xebbf0f07) " @ cmp.w pc, r7")
568 TEST( "cmp sp, #0x00080008") 569 TEST( "cmp sp, #0x00080008")
569 TEST_UNSUPPORTED(".short 0xf1bf,0x1f08 @ cmp pc, #0x00080008") 570 TEST_UNSUPPORTED(__inst_thumb32(0xf1bf1f08) " @ cmp pc, #0x00080008")
570 571
571 TEST_UNSUPPORTED(".short 0xea5f,0x070d @ movs.w r7, sp") 572 TEST_UNSUPPORTED(__inst_thumb32(0xea5f070d) " @ movs.w r7, sp")
572 TEST_UNSUPPORTED(".short 0xea5f,0x070f @ movs.w r7, pc") 573 TEST_UNSUPPORTED(__inst_thumb32(0xea5f070f) " @ movs.w r7, pc")
573 TEST_UNSUPPORTED(".short 0xea5f,0x0d07 @ movs.w sp, r7") 574 TEST_UNSUPPORTED(__inst_thumb32(0xea5f0d07) " @ movs.w sp, r7")
574 TEST_UNSUPPORTED(".short 0xea4f,0x0f07 @ mov.w pc, r7") 575 TEST_UNSUPPORTED(__inst_thumb32(0xea4f0f07) " @ mov.w pc, r7")
575 TEST_UNSUPPORTED(".short 0xf04f,0x1d08 @ mov sp, #0x00080008") 576 TEST_UNSUPPORTED(__inst_thumb32(0xf04f1d08) " @ mov sp, #0x00080008")
576 TEST_UNSUPPORTED(".short 0xf04f,0x1f08 @ mov pc, #0x00080008") 577 TEST_UNSUPPORTED(__inst_thumb32(0xf04f1f08) " @ mov pc, #0x00080008")
577 578
578 TEST_R("add.w r0, sp, r",1, 4,"") 579 TEST_R("add.w r0, sp, r",1, 4,"")
579 TEST_R("adds r0, sp, r",1, 4,", asl #3") 580 TEST_R("adds r0, sp, r",1, 4,", asl #3")
@@ -581,15 +582,15 @@ void kprobe_thumb32_test_cases(void)
581 TEST_R("add r0, sp, r",1, 16,", ror #1") 582 TEST_R("add r0, sp, r",1, 16,", ror #1")
582 TEST_R("add.w sp, sp, r",1, 4,"") 583 TEST_R("add.w sp, sp, r",1, 4,"")
583 TEST_R("add sp, sp, r",1, 4,", asl #3") 584 TEST_R("add sp, sp, r",1, 4,", asl #3")
584 TEST_UNSUPPORTED(".short 0xeb0d,0x1d01 @ add sp, sp, r1, asl #4") 585 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d1d01) " @ add sp, sp, r1, asl #4")
585 TEST_UNSUPPORTED(".short 0xeb0d,0x0d71 @ add sp, sp, r1, ror #1") 586 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d0d71) " @ add sp, sp, r1, ror #1")
586 TEST( "add.w r0, sp, #24") 587 TEST( "add.w r0, sp, #24")
587 TEST( "add.w sp, sp, #24") 588 TEST( "add.w sp, sp, #24")
588 TEST_UNSUPPORTED(".short 0xeb0d,0x0f01 @ add pc, sp, r1") 589 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d0f01) " @ add pc, sp, r1")
589 TEST_UNSUPPORTED(".short 0xeb0d,0x000f @ add r0, sp, pc") 590 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d000f) " @ add r0, sp, pc")
590 TEST_UNSUPPORTED(".short 0xeb0d,0x000d @ add r0, sp, sp") 591 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d000d) " @ add r0, sp, sp")
591 TEST_UNSUPPORTED(".short 0xeb0d,0x0d0f @ add sp, sp, pc") 592 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d0d0f) " @ add sp, sp, pc")
592 TEST_UNSUPPORTED(".short 0xeb0d,0x0d0d @ add sp, sp, sp") 593 TEST_UNSUPPORTED(__inst_thumb32(0xeb0d0d0d) " @ add sp, sp, sp")
593 594
594 TEST_R("sub.w r0, sp, r",1, 4,"") 595 TEST_R("sub.w r0, sp, r",1, 4,"")
595 TEST_R("subs r0, sp, r",1, 4,", asl #3") 596 TEST_R("subs r0, sp, r",1, 4,", asl #3")
@@ -597,54 +598,54 @@ void kprobe_thumb32_test_cases(void)
597 TEST_R("sub r0, sp, r",1, 16,", ror #1") 598 TEST_R("sub r0, sp, r",1, 16,", ror #1")
598 TEST_R("sub.w sp, sp, r",1, 4,"") 599 TEST_R("sub.w sp, sp, r",1, 4,"")
599 TEST_R("sub sp, sp, r",1, 4,", asl #3") 600 TEST_R("sub sp, sp, r",1, 4,", asl #3")
600 TEST_UNSUPPORTED(".short 0xebad,0x1d01 @ sub sp, sp, r1, asl #4") 601 TEST_UNSUPPORTED(__inst_thumb32(0xebad1d01) " @ sub sp, sp, r1, asl #4")
601 TEST_UNSUPPORTED(".short 0xebad,0x0d71 @ sub sp, sp, r1, ror #1") 602 TEST_UNSUPPORTED(__inst_thumb32(0xebad0d71) " @ sub sp, sp, r1, ror #1")
602 TEST_UNSUPPORTED(".short 0xebad,0x0f01 @ sub pc, sp, r1") 603 TEST_UNSUPPORTED(__inst_thumb32(0xebad0f01) " @ sub pc, sp, r1")
603 TEST( "sub.w r0, sp, #24") 604 TEST( "sub.w r0, sp, #24")
604 TEST( "sub.w sp, sp, #24") 605 TEST( "sub.w sp, sp, #24")
605 606
606 TEST_UNSUPPORTED(".short 0xea02,0x010f @ and r1, r2, pc") 607 TEST_UNSUPPORTED(__inst_thumb32(0xea02010f) " @ and r1, r2, pc")
607 TEST_UNSUPPORTED(".short 0xea0f,0x0103 @ and r1, pc, r3") 608 TEST_UNSUPPORTED(__inst_thumb32(0xea0f0103) " @ and r1, pc, r3")
608 TEST_UNSUPPORTED(".short 0xea02,0x0f03 @ and pc, r2, r3") 609 TEST_UNSUPPORTED(__inst_thumb32(0xea020f03) " @ and pc, r2, r3")
609 TEST_UNSUPPORTED(".short 0xea02,0x010d @ and r1, r2, sp") 610 TEST_UNSUPPORTED(__inst_thumb32(0xea02010d) " @ and r1, r2, sp")
610 TEST_UNSUPPORTED(".short 0xea0d,0x0103 @ and r1, sp, r3") 611 TEST_UNSUPPORTED(__inst_thumb32(0xea0d0103) " @ and r1, sp, r3")
611 TEST_UNSUPPORTED(".short 0xea02,0x0d03 @ and sp, r2, r3") 612 TEST_UNSUPPORTED(__inst_thumb32(0xea020d03) " @ and sp, r2, r3")
612 TEST_UNSUPPORTED(".short 0xf00d,0x1108 @ and r1, sp, #0x00080008") 613 TEST_UNSUPPORTED(__inst_thumb32(0xf00d1108) " @ and r1, sp, #0x00080008")
613 TEST_UNSUPPORTED(".short 0xf00f,0x1108 @ and r1, pc, #0x00080008") 614 TEST_UNSUPPORTED(__inst_thumb32(0xf00f1108) " @ and r1, pc, #0x00080008")
614 TEST_UNSUPPORTED(".short 0xf002,0x1d08 @ and sp, r8, #0x00080008") 615 TEST_UNSUPPORTED(__inst_thumb32(0xf0021d08) " @ and sp, r8, #0x00080008")
615 TEST_UNSUPPORTED(".short 0xf002,0x1f08 @ and pc, r8, #0x00080008") 616 TEST_UNSUPPORTED(__inst_thumb32(0xf0021f08) " @ and pc, r8, #0x00080008")
616 617
617 TEST_UNSUPPORTED(".short 0xeb02,0x010f @ add r1, r2, pc") 618 TEST_UNSUPPORTED(__inst_thumb32(0xeb02010f) " @ add r1, r2, pc")
618 TEST_UNSUPPORTED(".short 0xeb0f,0x0103 @ add r1, pc, r3") 619 TEST_UNSUPPORTED(__inst_thumb32(0xeb0f0103) " @ add r1, pc, r3")
619 TEST_UNSUPPORTED(".short 0xeb02,0x0f03 @ add pc, r2, r3") 620 TEST_UNSUPPORTED(__inst_thumb32(0xeb020f03) " @ add pc, r2, r3")
620 TEST_UNSUPPORTED(".short 0xeb02,0x010d @ add r1, r2, sp") 621 TEST_UNSUPPORTED(__inst_thumb32(0xeb02010d) " @ add r1, r2, sp")
621 TEST_SUPPORTED( ".short 0xeb0d,0x0103 @ add r1, sp, r3") 622 TEST_SUPPORTED( __inst_thumb32(0xeb0d0103) " @ add r1, sp, r3")
622 TEST_UNSUPPORTED(".short 0xeb02,0x0d03 @ add sp, r2, r3") 623 TEST_UNSUPPORTED(__inst_thumb32(0xeb020d03) " @ add sp, r2, r3")
623 TEST_SUPPORTED( ".short 0xf10d,0x1108 @ add r1, sp, #0x00080008") 624 TEST_SUPPORTED( __inst_thumb32(0xf10d1108) " @ add r1, sp, #0x00080008")
624 TEST_UNSUPPORTED(".short 0xf10d,0x1f08 @ add pc, sp, #0x00080008") 625 TEST_UNSUPPORTED(__inst_thumb32(0xf10d1f08) " @ add pc, sp, #0x00080008")
625 TEST_UNSUPPORTED(".short 0xf10f,0x1108 @ add r1, pc, #0x00080008") 626 TEST_UNSUPPORTED(__inst_thumb32(0xf10f1108) " @ add r1, pc, #0x00080008")
626 TEST_UNSUPPORTED(".short 0xf102,0x1d08 @ add sp, r8, #0x00080008") 627 TEST_UNSUPPORTED(__inst_thumb32(0xf1021d08) " @ add sp, r8, #0x00080008")
627 TEST_UNSUPPORTED(".short 0xf102,0x1f08 @ add pc, r8, #0x00080008") 628 TEST_UNSUPPORTED(__inst_thumb32(0xf1021f08) " @ add pc, r8, #0x00080008")
628 629
629 TEST_UNSUPPORTED(".short 0xeaa0,0x0000") 630 TEST_UNSUPPORTED(__inst_thumb32(0xeaa00000) "")
630 TEST_UNSUPPORTED(".short 0xeaf0,0x0000") 631 TEST_UNSUPPORTED(__inst_thumb32(0xeaf00000) "")
631 TEST_UNSUPPORTED(".short 0xeb20,0x0000") 632 TEST_UNSUPPORTED(__inst_thumb32(0xeb200000) "")
632 TEST_UNSUPPORTED(".short 0xeb80,0x0000") 633 TEST_UNSUPPORTED(__inst_thumb32(0xeb800000) "")
633 TEST_UNSUPPORTED(".short 0xebe0,0x0000") 634 TEST_UNSUPPORTED(__inst_thumb32(0xebe00000) "")
634 635
635 TEST_UNSUPPORTED(".short 0xf0a0,0x0000") 636 TEST_UNSUPPORTED(__inst_thumb32(0xf0a00000) "")
636 TEST_UNSUPPORTED(".short 0xf0c0,0x0000") 637 TEST_UNSUPPORTED(__inst_thumb32(0xf0c00000) "")
637 TEST_UNSUPPORTED(".short 0xf0f0,0x0000") 638 TEST_UNSUPPORTED(__inst_thumb32(0xf0f00000) "")
638 TEST_UNSUPPORTED(".short 0xf120,0x0000") 639 TEST_UNSUPPORTED(__inst_thumb32(0xf1200000) "")
639 TEST_UNSUPPORTED(".short 0xf180,0x0000") 640 TEST_UNSUPPORTED(__inst_thumb32(0xf1800000) "")
640 TEST_UNSUPPORTED(".short 0xf1e0,0x0000") 641 TEST_UNSUPPORTED(__inst_thumb32(0xf1e00000) "")
641 642
642 TEST_GROUP("Coprocessor instructions") 643 TEST_GROUP("Coprocessor instructions")
643 644
644 TEST_UNSUPPORTED(".short 0xec00,0x0000") 645 TEST_UNSUPPORTED(__inst_thumb32(0xec000000) "")
645 TEST_UNSUPPORTED(".short 0xeff0,0x0000") 646 TEST_UNSUPPORTED(__inst_thumb32(0xeff00000) "")
646 TEST_UNSUPPORTED(".short 0xfc00,0x0000") 647 TEST_UNSUPPORTED(__inst_thumb32(0xfc000000) "")
647 TEST_UNSUPPORTED(".short 0xfff0,0x0000") 648 TEST_UNSUPPORTED(__inst_thumb32(0xfff00000) "")
648 649
649 TEST_GROUP("Data-processing (plain binary immediate)") 650 TEST_GROUP("Data-processing (plain binary immediate)")
650 651
@@ -652,92 +653,92 @@ void kprobe_thumb32_test_cases(void)
652 TEST( "addw r14, sp, #0xf5a") 653 TEST( "addw r14, sp, #0xf5a")
653 TEST( "addw sp, sp, #0x20") 654 TEST( "addw sp, sp, #0x20")
654 TEST( "addw r7, pc, #0x888") 655 TEST( "addw r7, pc, #0x888")
655 TEST_UNSUPPORTED(".short 0xf20f,0x1f20 @ addw pc, pc, #0x120") 656 TEST_UNSUPPORTED(__inst_thumb32(0xf20f1f20) " @ addw pc, pc, #0x120")
656 TEST_UNSUPPORTED(".short 0xf20d,0x1f20 @ addw pc, sp, #0x120") 657 TEST_UNSUPPORTED(__inst_thumb32(0xf20d1f20) " @ addw pc, sp, #0x120")
657 TEST_UNSUPPORTED(".short 0xf20f,0x1d20 @ addw sp, pc, #0x120") 658 TEST_UNSUPPORTED(__inst_thumb32(0xf20f1d20) " @ addw sp, pc, #0x120")
658 TEST_UNSUPPORTED(".short 0xf200,0x1d20 @ addw sp, r0, #0x120") 659 TEST_UNSUPPORTED(__inst_thumb32(0xf2001d20) " @ addw sp, r0, #0x120")
659 660
660 TEST_R("subw r0, r",1, VAL1,", #0x123") 661 TEST_R("subw r0, r",1, VAL1,", #0x123")
661 TEST( "subw r14, sp, #0xf5a") 662 TEST( "subw r14, sp, #0xf5a")
662 TEST( "subw sp, sp, #0x20") 663 TEST( "subw sp, sp, #0x20")
663 TEST( "subw r7, pc, #0x888") 664 TEST( "subw r7, pc, #0x888")
664 TEST_UNSUPPORTED(".short 0xf2af,0x1f20 @ subw pc, pc, #0x120") 665 TEST_UNSUPPORTED(__inst_thumb32(0xf2af1f20) " @ subw pc, pc, #0x120")
665 TEST_UNSUPPORTED(".short 0xf2ad,0x1f20 @ subw pc, sp, #0x120") 666 TEST_UNSUPPORTED(__inst_thumb32(0xf2ad1f20) " @ subw pc, sp, #0x120")
666 TEST_UNSUPPORTED(".short 0xf2af,0x1d20 @ subw sp, pc, #0x120") 667 TEST_UNSUPPORTED(__inst_thumb32(0xf2af1d20) " @ subw sp, pc, #0x120")
667 TEST_UNSUPPORTED(".short 0xf2a0,0x1d20 @ subw sp, r0, #0x120") 668 TEST_UNSUPPORTED(__inst_thumb32(0xf2a01d20) " @ subw sp, r0, #0x120")
668 669
669 TEST("movw r0, #0") 670 TEST("movw r0, #0")
670 TEST("movw r0, #0xffff") 671 TEST("movw r0, #0xffff")
671 TEST("movw lr, #0xffff") 672 TEST("movw lr, #0xffff")
672 TEST_UNSUPPORTED(".short 0xf240,0x0d00 @ movw sp, #0") 673 TEST_UNSUPPORTED(__inst_thumb32(0xf2400d00) " @ movw sp, #0")
673 TEST_UNSUPPORTED(".short 0xf240,0x0f00 @ movw pc, #0") 674 TEST_UNSUPPORTED(__inst_thumb32(0xf2400f00) " @ movw pc, #0")
674 675
675 TEST_R("movt r",0, VAL1,", #0") 676 TEST_R("movt r",0, VAL1,", #0")
676 TEST_R("movt r",0, VAL2,", #0xffff") 677 TEST_R("movt r",0, VAL2,", #0xffff")
677 TEST_R("movt r",14,VAL1,", #0xffff") 678 TEST_R("movt r",14,VAL1,", #0xffff")
678 TEST_UNSUPPORTED(".short 0xf2c0,0x0d00 @ movt sp, #0") 679 TEST_UNSUPPORTED(__inst_thumb32(0xf2c00d00) " @ movt sp, #0")
679 TEST_UNSUPPORTED(".short 0xf2c0,0x0f00 @ movt pc, #0") 680 TEST_UNSUPPORTED(__inst_thumb32(0xf2c00f00) " @ movt pc, #0")
680 681
681 TEST_R( "ssat r0, #24, r",0, VAL1,"") 682 TEST_R( "ssat r0, #24, r",0, VAL1,"")
682 TEST_R( "ssat r14, #24, r",12, VAL2,"") 683 TEST_R( "ssat r14, #24, r",12, VAL2,"")
683 TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8") 684 TEST_R( "ssat r0, #24, r",0, VAL1,", lsl #8")
684 TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8") 685 TEST_R( "ssat r14, #24, r",12, VAL2,", asr #8")
685 TEST_UNSUPPORTED(".short 0xf30c,0x0d17 @ ssat sp, #24, r12") 686 TEST_UNSUPPORTED(__inst_thumb32(0xf30c0d17) " @ ssat sp, #24, r12")
686 TEST_UNSUPPORTED(".short 0xf30c,0x0f17 @ ssat pc, #24, r12") 687 TEST_UNSUPPORTED(__inst_thumb32(0xf30c0f17) " @ ssat pc, #24, r12")
687 TEST_UNSUPPORTED(".short 0xf30d,0x0c17 @ ssat r12, #24, sp") 688 TEST_UNSUPPORTED(__inst_thumb32(0xf30d0c17) " @ ssat r12, #24, sp")
688 TEST_UNSUPPORTED(".short 0xf30f,0x0c17 @ ssat r12, #24, pc") 689 TEST_UNSUPPORTED(__inst_thumb32(0xf30f0c17) " @ ssat r12, #24, pc")
689 690
690 TEST_R( "usat r0, #24, r",0, VAL1,"") 691 TEST_R( "usat r0, #24, r",0, VAL1,"")
691 TEST_R( "usat r14, #24, r",12, VAL2,"") 692 TEST_R( "usat r14, #24, r",12, VAL2,"")
692 TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8") 693 TEST_R( "usat r0, #24, r",0, VAL1,", lsl #8")
693 TEST_R( "usat r14, #24, r",12, VAL2,", asr #8") 694 TEST_R( "usat r14, #24, r",12, VAL2,", asr #8")
694 TEST_UNSUPPORTED(".short 0xf38c,0x0d17 @ usat sp, #24, r12") 695 TEST_UNSUPPORTED(__inst_thumb32(0xf38c0d17) " @ usat sp, #24, r12")
695 TEST_UNSUPPORTED(".short 0xf38c,0x0f17 @ usat pc, #24, r12") 696 TEST_UNSUPPORTED(__inst_thumb32(0xf38c0f17) " @ usat pc, #24, r12")
696 TEST_UNSUPPORTED(".short 0xf38d,0x0c17 @ usat r12, #24, sp") 697 TEST_UNSUPPORTED(__inst_thumb32(0xf38d0c17) " @ usat r12, #24, sp")
697 TEST_UNSUPPORTED(".short 0xf38f,0x0c17 @ usat r12, #24, pc") 698 TEST_UNSUPPORTED(__inst_thumb32(0xf38f0c17) " @ usat r12, #24, pc")
698 699
699 TEST_R( "ssat16 r0, #12, r",0, HH1,"") 700 TEST_R( "ssat16 r0, #12, r",0, HH1,"")
700 TEST_R( "ssat16 r14, #12, r",12, HH2,"") 701 TEST_R( "ssat16 r14, #12, r",12, HH2,"")
701 TEST_UNSUPPORTED(".short 0xf32c,0x0d0b @ ssat16 sp, #12, r12") 702 TEST_UNSUPPORTED(__inst_thumb32(0xf32c0d0b) " @ ssat16 sp, #12, r12")
702 TEST_UNSUPPORTED(".short 0xf32c,0x0f0b @ ssat16 pc, #12, r12") 703 TEST_UNSUPPORTED(__inst_thumb32(0xf32c0f0b) " @ ssat16 pc, #12, r12")
703 TEST_UNSUPPORTED(".short 0xf32d,0x0c0b @ ssat16 r12, #12, sp") 704 TEST_UNSUPPORTED(__inst_thumb32(0xf32d0c0b) " @ ssat16 r12, #12, sp")
704 TEST_UNSUPPORTED(".short 0xf32f,0x0c0b @ ssat16 r12, #12, pc") 705 TEST_UNSUPPORTED(__inst_thumb32(0xf32f0c0b) " @ ssat16 r12, #12, pc")
705 706
706 TEST_R( "usat16 r0, #12, r",0, HH1,"") 707 TEST_R( "usat16 r0, #12, r",0, HH1,"")
707 TEST_R( "usat16 r14, #12, r",12, HH2,"") 708 TEST_R( "usat16 r14, #12, r",12, HH2,"")
708 TEST_UNSUPPORTED(".short 0xf3ac,0x0d0b @ usat16 sp, #12, r12") 709 TEST_UNSUPPORTED(__inst_thumb32(0xf3ac0d0b) " @ usat16 sp, #12, r12")
709 TEST_UNSUPPORTED(".short 0xf3ac,0x0f0b @ usat16 pc, #12, r12") 710 TEST_UNSUPPORTED(__inst_thumb32(0xf3ac0f0b) " @ usat16 pc, #12, r12")
710 TEST_UNSUPPORTED(".short 0xf3ad,0x0c0b @ usat16 r12, #12, sp") 711 TEST_UNSUPPORTED(__inst_thumb32(0xf3ad0c0b) " @ usat16 r12, #12, sp")
711 TEST_UNSUPPORTED(".short 0xf3af,0x0c0b @ usat16 r12, #12, pc") 712 TEST_UNSUPPORTED(__inst_thumb32(0xf3af0c0b) " @ usat16 r12, #12, pc")
712 713
713 TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31") 714 TEST_R( "sbfx r0, r",0 , VAL1,", #0, #31")
714 TEST_R( "sbfx r14, r",12, VAL2,", #8, #16") 715 TEST_R( "sbfx r14, r",12, VAL2,", #8, #16")
715 TEST_R( "sbfx r4, r",10, VAL1,", #16, #15") 716 TEST_R( "sbfx r4, r",10, VAL1,", #16, #15")
716 TEST_UNSUPPORTED(".short 0xf34c,0x2d0f @ sbfx sp, r12, #8, #16") 717 TEST_UNSUPPORTED(__inst_thumb32(0xf34c2d0f) " @ sbfx sp, r12, #8, #16")
717 TEST_UNSUPPORTED(".short 0xf34c,0x2f0f @ sbfx pc, r12, #8, #16") 718 TEST_UNSUPPORTED(__inst_thumb32(0xf34c2f0f) " @ sbfx pc, r12, #8, #16")
718 TEST_UNSUPPORTED(".short 0xf34d,0x2c0f @ sbfx r12, sp, #8, #16") 719 TEST_UNSUPPORTED(__inst_thumb32(0xf34d2c0f) " @ sbfx r12, sp, #8, #16")
719 TEST_UNSUPPORTED(".short 0xf34f,0x2c0f @ sbfx r12, pc, #8, #16") 720 TEST_UNSUPPORTED(__inst_thumb32(0xf34f2c0f) " @ sbfx r12, pc, #8, #16")
720 721
721 TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31") 722 TEST_R( "ubfx r0, r",0 , VAL1,", #0, #31")
722 TEST_R( "ubfx r14, r",12, VAL2,", #8, #16") 723 TEST_R( "ubfx r14, r",12, VAL2,", #8, #16")
723 TEST_R( "ubfx r4, r",10, VAL1,", #16, #15") 724 TEST_R( "ubfx r4, r",10, VAL1,", #16, #15")
724 TEST_UNSUPPORTED(".short 0xf3cc,0x2d0f @ ubfx sp, r12, #8, #16") 725 TEST_UNSUPPORTED(__inst_thumb32(0xf3cc2d0f) " @ ubfx sp, r12, #8, #16")
725 TEST_UNSUPPORTED(".short 0xf3cc,0x2f0f @ ubfx pc, r12, #8, #16") 726 TEST_UNSUPPORTED(__inst_thumb32(0xf3cc2f0f) " @ ubfx pc, r12, #8, #16")
726 TEST_UNSUPPORTED(".short 0xf3cd,0x2c0f @ ubfx r12, sp, #8, #16") 727 TEST_UNSUPPORTED(__inst_thumb32(0xf3cd2c0f) " @ ubfx r12, sp, #8, #16")
727 TEST_UNSUPPORTED(".short 0xf3cf,0x2c0f @ ubfx r12, pc, #8, #16") 728 TEST_UNSUPPORTED(__inst_thumb32(0xf3cf2c0f) " @ ubfx r12, pc, #8, #16")
728 729
729 TEST_R( "bfc r",0, VAL1,", #4, #20") 730 TEST_R( "bfc r",0, VAL1,", #4, #20")
730 TEST_R( "bfc r",14,VAL2,", #4, #20") 731 TEST_R( "bfc r",14,VAL2,", #4, #20")
731 TEST_R( "bfc r",7, VAL1,", #0, #31") 732 TEST_R( "bfc r",7, VAL1,", #0, #31")
732 TEST_R( "bfc r",8, VAL2,", #0, #31") 733 TEST_R( "bfc r",8, VAL2,", #0, #31")
733 TEST_UNSUPPORTED(".short 0xf36f,0x0d1e @ bfc sp, #0, #31") 734 TEST_UNSUPPORTED(__inst_thumb32(0xf36f0d1e) " @ bfc sp, #0, #31")
734 TEST_UNSUPPORTED(".short 0xf36f,0x0f1e @ bfc pc, #0, #31") 735 TEST_UNSUPPORTED(__inst_thumb32(0xf36f0f1e) " @ bfc pc, #0, #31")
735 736
736 TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31") 737 TEST_RR( "bfi r",0, VAL1,", r",0 , VAL2,", #0, #31")
737 TEST_RR( "bfi r",12,VAL1,", r",14 , VAL2,", #4, #20") 738 TEST_RR( "bfi r",12,VAL1,", r",14 , VAL2,", #4, #20")
738 TEST_UNSUPPORTED(".short 0xf36e,0x1d17 @ bfi sp, r14, #4, #20") 739 TEST_UNSUPPORTED(__inst_thumb32(0xf36e1d17) " @ bfi sp, r14, #4, #20")
739 TEST_UNSUPPORTED(".short 0xf36e,0x1f17 @ bfi pc, r14, #4, #20") 740 TEST_UNSUPPORTED(__inst_thumb32(0xf36e1f17) " @ bfi pc, r14, #4, #20")
740 TEST_UNSUPPORTED(".short 0xf36d,0x1e17 @ bfi r14, sp, #4, #20") 741 TEST_UNSUPPORTED(__inst_thumb32(0xf36d1e17) " @ bfi r14, sp, #4, #20")
741 742
742 TEST_GROUP("Branches and miscellaneous control") 743 TEST_GROUP("Branches and miscellaneous control")
743 744
@@ -775,14 +776,14 @@ CONDITION_INSTRUCTIONS(22,
775 776
776 TEST("mrs r0, cpsr") 777 TEST("mrs r0, cpsr")
777 TEST("mrs r14, cpsr") 778 TEST("mrs r14, cpsr")
778 TEST_UNSUPPORTED(".short 0xf3ef,0x8d00 @ mrs sp, spsr") 779 TEST_UNSUPPORTED(__inst_thumb32(0xf3ef8d00) " @ mrs sp, spsr")
779 TEST_UNSUPPORTED(".short 0xf3ef,0x8f00 @ mrs pc, spsr") 780 TEST_UNSUPPORTED(__inst_thumb32(0xf3ef8f00) " @ mrs pc, spsr")
780 TEST_UNSUPPORTED("mrs r0, spsr") 781 TEST_UNSUPPORTED("mrs r0, spsr")
781 TEST_UNSUPPORTED("mrs lr, spsr") 782 TEST_UNSUPPORTED("mrs lr, spsr")
782 783
783 TEST_UNSUPPORTED(".short 0xf7f0,0x8000 @ smc #0") 784 TEST_UNSUPPORTED(__inst_thumb32(0xf7f08000) " @ smc #0")
784 785
785 TEST_UNSUPPORTED(".short 0xf7f0,0xa000 @ undefeined") 786 TEST_UNSUPPORTED(__inst_thumb32(0xf7f0a000) " @ undefeined")
786 787
787 TEST_BF( "b.w 2f") 788 TEST_BF( "b.w 2f")
788 TEST_BB( "b.w 2b") 789 TEST_BB( "b.w 2b")
@@ -829,15 +830,15 @@ CONDITION_INSTRUCTIONS(22,
829 SINGLE_STORE("") 830 SINGLE_STORE("")
830 831
831 TEST("str sp, [sp]") 832 TEST("str sp, [sp]")
832 TEST_UNSUPPORTED(".short 0xf8cf,0xe000 @ str r14, [pc]") 833 TEST_UNSUPPORTED(__inst_thumb32(0xf8cfe000) " @ str r14, [pc]")
833 TEST_UNSUPPORTED(".short 0xf8ce,0xf000 @ str pc, [r14]") 834 TEST_UNSUPPORTED(__inst_thumb32(0xf8cef000) " @ str pc, [r14]")
834 835
835 TEST_GROUP("Advanced SIMD element or structure load/store instructions") 836 TEST_GROUP("Advanced SIMD element or structure load/store instructions")
836 837
837 TEST_UNSUPPORTED(".short 0xf900,0x0000") 838 TEST_UNSUPPORTED(__inst_thumb32(0xf9000000) "")
838 TEST_UNSUPPORTED(".short 0xf92f,0xffff") 839 TEST_UNSUPPORTED(__inst_thumb32(0xf92fffff) "")
839 TEST_UNSUPPORTED(".short 0xf980,0x0000") 840 TEST_UNSUPPORTED(__inst_thumb32(0xf9800000) "")
840 TEST_UNSUPPORTED(".short 0xf9ef,0xffff") 841 TEST_UNSUPPORTED(__inst_thumb32(0xf9efffff) "")
841 842
842 TEST_GROUP("Load single data item and memory hints") 843 TEST_GROUP("Load single data item and memory hints")
843 844
@@ -881,20 +882,20 @@ CONDITION_INSTRUCTIONS(22,
881 TEST_SUPPORTED("ldr sp, 99f") 882 TEST_SUPPORTED("ldr sp, 99f")
882 TEST_SUPPORTED("ldr pc, 99f") 883 TEST_SUPPORTED("ldr pc, 99f")
883 884
884 TEST_UNSUPPORTED(".short 0xf854,0x700d @ ldr r7, [r4, sp]") 885 TEST_UNSUPPORTED(__inst_thumb32(0xf854700d) " @ ldr r7, [r4, sp]")
885 TEST_UNSUPPORTED(".short 0xf854,0x700f @ ldr r7, [r4, pc]") 886 TEST_UNSUPPORTED(__inst_thumb32(0xf854700f) " @ ldr r7, [r4, pc]")
886 TEST_UNSUPPORTED(".short 0xf814,0x700d @ ldrb r7, [r4, sp]") 887 TEST_UNSUPPORTED(__inst_thumb32(0xf814700d) " @ ldrb r7, [r4, sp]")
887 TEST_UNSUPPORTED(".short 0xf814,0x700f @ ldrb r7, [r4, pc]") 888 TEST_UNSUPPORTED(__inst_thumb32(0xf814700f) " @ ldrb r7, [r4, pc]")
888 TEST_UNSUPPORTED(".short 0xf89f,0xd004 @ ldrb sp, 99f") 889 TEST_UNSUPPORTED(__inst_thumb32(0xf89fd004) " @ ldrb sp, 99f")
889 TEST_UNSUPPORTED(".short 0xf814,0xd008 @ ldrb sp, [r4, r8]") 890 TEST_UNSUPPORTED(__inst_thumb32(0xf814d008) " @ ldrb sp, [r4, r8]")
890 TEST_UNSUPPORTED(".short 0xf894,0xd000 @ ldrb sp, [r4]") 891 TEST_UNSUPPORTED(__inst_thumb32(0xf894d000) " @ ldrb sp, [r4]")
891 892
892 TEST_UNSUPPORTED(".short 0xf860,0x0000") /* Unallocated space */ 893 TEST_UNSUPPORTED(__inst_thumb32(0xf8600000) "") /* Unallocated space */
893 TEST_UNSUPPORTED(".short 0xf9ff,0xffff") /* Unallocated space */ 894 TEST_UNSUPPORTED(__inst_thumb32(0xf9ffffff) "") /* Unallocated space */
894 TEST_UNSUPPORTED(".short 0xf950,0x0000") /* Unallocated space */ 895 TEST_UNSUPPORTED(__inst_thumb32(0xf9500000) "") /* Unallocated space */
895 TEST_UNSUPPORTED(".short 0xf95f,0xffff") /* Unallocated space */ 896 TEST_UNSUPPORTED(__inst_thumb32(0xf95fffff) "") /* Unallocated space */
896 TEST_UNSUPPORTED(".short 0xf800,0x0800") /* Unallocated space */ 897 TEST_UNSUPPORTED(__inst_thumb32(0xf8000800) "") /* Unallocated space */
897 TEST_UNSUPPORTED(".short 0xf97f,0xfaff") /* Unallocated space */ 898 TEST_UNSUPPORTED(__inst_thumb32(0xf97ffaff) "") /* Unallocated space */
898 899
899 TEST( "pli [pc, #4]") 900 TEST( "pli [pc, #4]")
900 TEST( "pli [pc, #-4]") 901 TEST( "pli [pc, #-4]")
@@ -902,22 +903,22 @@ CONDITION_INSTRUCTIONS(22,
902 TEST( "pld [pc, #-4]") 903 TEST( "pld [pc, #-4]")
903 904
904 TEST_P( "pld [r",0,-1024,", #1024]") 905 TEST_P( "pld [r",0,-1024,", #1024]")
905 TEST( ".short 0xf8b0,0xf400 @ pldw [r0, #1024]") 906 TEST( __inst_thumb32(0xf8b0f400) " @ pldw [r0, #1024]")
906 TEST_P( "pli [r",4, 0b,", #1024]") 907 TEST_P( "pli [r",4, 0b,", #1024]")
907 TEST_P( "pld [r",7, 120,", #-120]") 908 TEST_P( "pld [r",7, 120,", #-120]")
908 TEST( ".short 0xf837,0xfc78 @ pldw [r7, #-120]") 909 TEST( __inst_thumb32(0xf837fc78) " @ pldw [r7, #-120]")
909 TEST_P( "pli [r",11,120,", #-120]") 910 TEST_P( "pli [r",11,120,", #-120]")
910 TEST( "pld [sp, #0]") 911 TEST( "pld [sp, #0]")
911 912
912 TEST_PR("pld [r",7, 24, ", r",0, 16,"]") 913 TEST_PR("pld [r",7, 24, ", r",0, 16,"]")
913 TEST_PR("pld [r",8, 24, ", r",12,16,", lsl #3]") 914 TEST_PR("pld [r",8, 24, ", r",12,16,", lsl #3]")
914 TEST_SUPPORTED(".short 0xf837,0xf000 @ pldw [r7, r0]") 915 TEST_SUPPORTED(__inst_thumb32(0xf837f000) " @ pldw [r7, r0]")
915 TEST_SUPPORTED(".short 0xf838,0xf03c @ pldw [r8, r12, lsl #3]"); 916 TEST_SUPPORTED(__inst_thumb32(0xf838f03c) " @ pldw [r8, r12, lsl #3]");
916 TEST_RR("pli [r",12,0b,", r",0, 16,"]") 917 TEST_RR("pli [r",12,0b,", r",0, 16,"]")
917 TEST_RR("pli [r",0, 0b,", r",12,16,", lsl #3]") 918 TEST_RR("pli [r",0, 0b,", r",12,16,", lsl #3]")
918 TEST_R( "pld [sp, r",1, 16,"]") 919 TEST_R( "pld [sp, r",1, 16,"]")
919 TEST_UNSUPPORTED(".short 0xf817,0xf00d @pld [r7, sp]") 920 TEST_UNSUPPORTED(__inst_thumb32(0xf817f00d) " @pld [r7, sp]")
920 TEST_UNSUPPORTED(".short 0xf817,0xf00f @pld [r7, pc]") 921 TEST_UNSUPPORTED(__inst_thumb32(0xf817f00f) " @pld [r7, pc]")
921 922
922 TEST_GROUP("Data-processing (register)") 923 TEST_GROUP("Data-processing (register)")
923 924
@@ -934,21 +935,21 @@ CONDITION_INSTRUCTIONS(22,
934 SHIFTS32("ror") 935 SHIFTS32("ror")
935 SHIFTS32("rors") 936 SHIFTS32("rors")
936 937
937 TEST_UNSUPPORTED(".short 0xfa01,0xff02 @ lsl pc, r1, r2") 938 TEST_UNSUPPORTED(__inst_thumb32(0xfa01ff02) " @ lsl pc, r1, r2")
938 TEST_UNSUPPORTED(".short 0xfa01,0xfd02 @ lsl sp, r1, r2") 939 TEST_UNSUPPORTED(__inst_thumb32(0xfa01fd02) " @ lsl sp, r1, r2")
939 TEST_UNSUPPORTED(".short 0xfa0f,0xf002 @ lsl r0, pc, r2") 940 TEST_UNSUPPORTED(__inst_thumb32(0xfa0ff002) " @ lsl r0, pc, r2")
940 TEST_UNSUPPORTED(".short 0xfa0d,0xf002 @ lsl r0, sp, r2") 941 TEST_UNSUPPORTED(__inst_thumb32(0xfa0df002) " @ lsl r0, sp, r2")
941 TEST_UNSUPPORTED(".short 0xfa01,0xf00f @ lsl r0, r1, pc") 942 TEST_UNSUPPORTED(__inst_thumb32(0xfa01f00f) " @ lsl r0, r1, pc")
942 TEST_UNSUPPORTED(".short 0xfa01,0xf00d @ lsl r0, r1, sp") 943 TEST_UNSUPPORTED(__inst_thumb32(0xfa01f00d) " @ lsl r0, r1, sp")
943 944
944 TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"") 945 TEST_RR( "sxtah r0, r",0, HH1,", r",1, HH2,"")
945 TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8") 946 TEST_RR( "sxtah r14,r",12, HH2,", r",10,HH1,", ror #8")
946 TEST_R( "sxth r8, r",7, HH1,"") 947 TEST_R( "sxth r8, r",7, HH1,"")
947 948
948 TEST_UNSUPPORTED(".short 0xfa0f,0xff87 @ sxth pc, r7"); 949 TEST_UNSUPPORTED(__inst_thumb32(0xfa0fff87) " @ sxth pc, r7");
949 TEST_UNSUPPORTED(".short 0xfa0f,0xfd87 @ sxth sp, r7"); 950 TEST_UNSUPPORTED(__inst_thumb32(0xfa0ffd87) " @ sxth sp, r7");
950 TEST_UNSUPPORTED(".short 0xfa0f,0xf88f @ sxth r8, pc"); 951 TEST_UNSUPPORTED(__inst_thumb32(0xfa0ff88f) " @ sxth r8, pc");
951 TEST_UNSUPPORTED(".short 0xfa0f,0xf88d @ sxth r8, sp"); 952 TEST_UNSUPPORTED(__inst_thumb32(0xfa0ff88d) " @ sxth r8, sp");
952 953
953 TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"") 954 TEST_RR( "uxtah r0, r",0, HH1,", r",1, HH2,"")
954 TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8") 955 TEST_RR( "uxtah r14,r",12, HH2,", r",10,HH1,", ror #8")
@@ -970,8 +971,8 @@ CONDITION_INSTRUCTIONS(22,
970 TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8") 971 TEST_RR( "uxtab r14,r",12, HH2,", r",10,HH1,", ror #8")
971 TEST_R( "uxtb r8, r",7, HH1,"") 972 TEST_R( "uxtb r8, r",7, HH1,"")
972 973
973 TEST_UNSUPPORTED(".short 0xfa60,0x00f0") 974 TEST_UNSUPPORTED(__inst_thumb32(0xfa6000f0) "")
974 TEST_UNSUPPORTED(".short 0xfa7f,0xffff") 975 TEST_UNSUPPORTED(__inst_thumb32(0xfa7fffff) "")
975 976
976#define PARALLEL_ADD_SUB(op) \ 977#define PARALLEL_ADD_SUB(op) \
977 TEST_RR( op"add16 r0, r",0, HH1,", r",1, HH2,"") \ 978 TEST_RR( op"add16 r0, r",0, HH1,", r",1, HH2,"") \
@@ -1019,10 +1020,10 @@ CONDITION_INSTRUCTIONS(22,
1019 TEST_R("revsh.w r0, r",0, VAL1,"") 1020 TEST_R("revsh.w r0, r",0, VAL1,"")
1020 TEST_R("revsh r14, r",12, VAL2,"") 1021 TEST_R("revsh r14, r",12, VAL2,"")
1021 1022
1022 TEST_UNSUPPORTED(".short 0xfa9c,0xff8c @ rev pc, r12"); 1023 TEST_UNSUPPORTED(__inst_thumb32(0xfa9cff8c) " @ rev pc, r12");
1023 TEST_UNSUPPORTED(".short 0xfa9c,0xfd8c @ rev sp, r12"); 1024 TEST_UNSUPPORTED(__inst_thumb32(0xfa9cfd8c) " @ rev sp, r12");
1024 TEST_UNSUPPORTED(".short 0xfa9f,0xfe8f @ rev r14, pc"); 1025 TEST_UNSUPPORTED(__inst_thumb32(0xfa9ffe8f) " @ rev r14, pc");
1025 TEST_UNSUPPORTED(".short 0xfa9d,0xfe8d @ rev r14, sp"); 1026 TEST_UNSUPPORTED(__inst_thumb32(0xfa9dfe8d) " @ rev r14, sp");
1026 1027
1027 TEST_RR("sel r0, r",0, VAL1,", r",1, VAL2,"") 1028 TEST_RR("sel r0, r",0, VAL1,", r",1, VAL2,"")
1028 TEST_RR("sel r14, r",12,VAL1,", r",10, VAL2,"") 1029 TEST_RR("sel r14, r",12,VAL1,", r",10, VAL2,"")
@@ -1031,31 +1032,31 @@ CONDITION_INSTRUCTIONS(22,
1031 TEST_R("clz r7, r",14,0x1,"") 1032 TEST_R("clz r7, r",14,0x1,"")
1032 TEST_R("clz lr, r",7, 0xffffffff,"") 1033 TEST_R("clz lr, r",7, 0xffffffff,"")
1033 1034
1034 TEST_UNSUPPORTED(".short 0xfa80,0xf030") /* Unallocated space */ 1035 TEST_UNSUPPORTED(__inst_thumb32(0xfa80f030) "") /* Unallocated space */
1035 TEST_UNSUPPORTED(".short 0xfaff,0xff7f") /* Unallocated space */ 1036 TEST_UNSUPPORTED(__inst_thumb32(0xfaffff7f) "") /* Unallocated space */
1036 TEST_UNSUPPORTED(".short 0xfab0,0xf000") /* Unallocated space */ 1037 TEST_UNSUPPORTED(__inst_thumb32(0xfab0f000) "") /* Unallocated space */
1037 TEST_UNSUPPORTED(".short 0xfaff,0xff7f") /* Unallocated space */ 1038 TEST_UNSUPPORTED(__inst_thumb32(0xfaffff7f) "") /* Unallocated space */
1038 1039
1039 TEST_GROUP("Multiply, multiply accumulate, and absolute difference operations") 1040 TEST_GROUP("Multiply, multiply accumulate, and absolute difference operations")
1040 1041
1041 TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"") 1042 TEST_RR( "mul r0, r",1, VAL1,", r",2, VAL2,"")
1042 TEST_RR( "mul r7, r",8, VAL2,", r",9, VAL2,"") 1043 TEST_RR( "mul r7, r",8, VAL2,", r",9, VAL2,"")
1043 TEST_UNSUPPORTED(".short 0xfb08,0xff09 @ mul pc, r8, r9") 1044 TEST_UNSUPPORTED(__inst_thumb32(0xfb08ff09) " @ mul pc, r8, r9")
1044 TEST_UNSUPPORTED(".short 0xfb08,0xfd09 @ mul sp, r8, r9") 1045 TEST_UNSUPPORTED(__inst_thumb32(0xfb08fd09) " @ mul sp, r8, r9")
1045 TEST_UNSUPPORTED(".short 0xfb0f,0xf709 @ mul r7, pc, r9") 1046 TEST_UNSUPPORTED(__inst_thumb32(0xfb0ff709) " @ mul r7, pc, r9")
1046 TEST_UNSUPPORTED(".short 0xfb0d,0xf709 @ mul r7, sp, r9") 1047 TEST_UNSUPPORTED(__inst_thumb32(0xfb0df709) " @ mul r7, sp, r9")
1047 TEST_UNSUPPORTED(".short 0xfb08,0xf70f @ mul r7, r8, pc") 1048 TEST_UNSUPPORTED(__inst_thumb32(0xfb08f70f) " @ mul r7, r8, pc")
1048 TEST_UNSUPPORTED(".short 0xfb08,0xf70d @ mul r7, r8, sp") 1049 TEST_UNSUPPORTED(__inst_thumb32(0xfb08f70d) " @ mul r7, r8, sp")
1049 1050
1050 TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 1051 TEST_RRR( "mla r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
1051 TEST_RRR( "mla r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 1052 TEST_RRR( "mla r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
1052 TEST_UNSUPPORTED(".short 0xfb08,0xaf09 @ mla pc, r8, r9, r10"); 1053 TEST_UNSUPPORTED(__inst_thumb32(0xfb08af09) " @ mla pc, r8, r9, r10");
1053 TEST_UNSUPPORTED(".short 0xfb08,0xad09 @ mla sp, r8, r9, r10"); 1054 TEST_UNSUPPORTED(__inst_thumb32(0xfb08ad09) " @ mla sp, r8, r9, r10");
1054 TEST_UNSUPPORTED(".short 0xfb0f,0xa709 @ mla r7, pc, r9, r10"); 1055 TEST_UNSUPPORTED(__inst_thumb32(0xfb0fa709) " @ mla r7, pc, r9, r10");
1055 TEST_UNSUPPORTED(".short 0xfb0d,0xa709 @ mla r7, sp, r9, r10"); 1056 TEST_UNSUPPORTED(__inst_thumb32(0xfb0da709) " @ mla r7, sp, r9, r10");
1056 TEST_UNSUPPORTED(".short 0xfb08,0xa70f @ mla r7, r8, pc, r10"); 1057 TEST_UNSUPPORTED(__inst_thumb32(0xfb08a70f) " @ mla r7, r8, pc, r10");
1057 TEST_UNSUPPORTED(".short 0xfb08,0xa70d @ mla r7, r8, sp, r10"); 1058 TEST_UNSUPPORTED(__inst_thumb32(0xfb08a70d) " @ mla r7, r8, sp, r10");
1058 TEST_UNSUPPORTED(".short 0xfb08,0xd709 @ mla r7, r8, r9, sp"); 1059 TEST_UNSUPPORTED(__inst_thumb32(0xfb08d709) " @ mla r7, r8, r9, sp");
1059 1060
1060 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 1061 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
1061 TEST_RRR( "mls r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 1062 TEST_RRR( "mls r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
@@ -1123,25 +1124,25 @@ CONDITION_INSTRUCTIONS(22,
1123 TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"") 1124 TEST_RR( "usad8 r0, r",0, VAL1,", r",1, VAL2,"")
1124 TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"") 1125 TEST_RR( "usad8 r14, r",12,VAL2,", r",10,VAL1,"")
1125 1126
1126 TEST_UNSUPPORTED(".short 0xfb00,0xf010") /* Unallocated space */ 1127 TEST_UNSUPPORTED(__inst_thumb32(0xfb00f010) "") /* Unallocated space */
1127 TEST_UNSUPPORTED(".short 0xfb0f,0xff1f") /* Unallocated space */ 1128 TEST_UNSUPPORTED(__inst_thumb32(0xfb0fff1f) "") /* Unallocated space */
1128 TEST_UNSUPPORTED(".short 0xfb70,0xf010") /* Unallocated space */ 1129 TEST_UNSUPPORTED(__inst_thumb32(0xfb70f010) "") /* Unallocated space */
1129 TEST_UNSUPPORTED(".short 0xfb7f,0xff1f") /* Unallocated space */ 1130 TEST_UNSUPPORTED(__inst_thumb32(0xfb7fff1f) "") /* Unallocated space */
1130 TEST_UNSUPPORTED(".short 0xfb70,0x0010") /* Unallocated space */ 1131 TEST_UNSUPPORTED(__inst_thumb32(0xfb700010) "") /* Unallocated space */
1131 TEST_UNSUPPORTED(".short 0xfb7f,0xff1f") /* Unallocated space */ 1132 TEST_UNSUPPORTED(__inst_thumb32(0xfb7fff1f) "") /* Unallocated space */
1132 1133
1133 TEST_GROUP("Long multiply, long multiply accumulate, and divide") 1134 TEST_GROUP("Long multiply, long multiply accumulate, and divide")
1134 1135
1135 TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"") 1136 TEST_RR( "smull r0, r1, r",2, VAL1,", r",3, VAL2,"")
1136 TEST_RR( "smull r7, r8, r",9, VAL2,", r",10, VAL1,"") 1137 TEST_RR( "smull r7, r8, r",9, VAL2,", r",10, VAL1,"")
1137 TEST_UNSUPPORTED(".short 0xfb89,0xf80a @ smull pc, r8, r9, r10"); 1138 TEST_UNSUPPORTED(__inst_thumb32(0xfb89f80a) " @ smull pc, r8, r9, r10");
1138 TEST_UNSUPPORTED(".short 0xfb89,0xd80a @ smull sp, r8, r9, r10"); 1139 TEST_UNSUPPORTED(__inst_thumb32(0xfb89d80a) " @ smull sp, r8, r9, r10");
1139 TEST_UNSUPPORTED(".short 0xfb89,0x7f0a @ smull r7, pc, r9, r10"); 1140 TEST_UNSUPPORTED(__inst_thumb32(0xfb897f0a) " @ smull r7, pc, r9, r10");
1140 TEST_UNSUPPORTED(".short 0xfb89,0x7d0a @ smull r7, sp, r9, r10"); 1141 TEST_UNSUPPORTED(__inst_thumb32(0xfb897d0a) " @ smull r7, sp, r9, r10");
1141 TEST_UNSUPPORTED(".short 0xfb8f,0x780a @ smull r7, r8, pc, r10"); 1142 TEST_UNSUPPORTED(__inst_thumb32(0xfb8f780a) " @ smull r7, r8, pc, r10");
1142 TEST_UNSUPPORTED(".short 0xfb8d,0x780a @ smull r7, r8, sp, r10"); 1143 TEST_UNSUPPORTED(__inst_thumb32(0xfb8d780a) " @ smull r7, r8, sp, r10");
1143 TEST_UNSUPPORTED(".short 0xfb89,0x780f @ smull r7, r8, r9, pc"); 1144 TEST_UNSUPPORTED(__inst_thumb32(0xfb89780f) " @ smull r7, r8, r9, pc");
1144 TEST_UNSUPPORTED(".short 0xfb89,0x780d @ smull r7, r8, r9, sp"); 1145 TEST_UNSUPPORTED(__inst_thumb32(0xfb89780d) " @ smull r7, r8, r9, sp");
1145 1146
1146 TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"") 1147 TEST_RR( "umull r0, r1, r",2, VAL1,", r",3, VAL2,"")
1147 TEST_RR( "umull r7, r8, r",9, VAL2,", r",10, VAL1,"") 1148 TEST_RR( "umull r7, r8, r",9, VAL2,", r",10, VAL1,"")
@@ -1175,8 +1176,8 @@ CONDITION_INSTRUCTIONS(22,
1175 1176
1176 TEST_GROUP("Coprocessor instructions") 1177 TEST_GROUP("Coprocessor instructions")
1177 1178
1178 TEST_UNSUPPORTED(".short 0xfc00,0x0000") 1179 TEST_UNSUPPORTED(__inst_thumb32(0xfc000000) "")
1179 TEST_UNSUPPORTED(".short 0xffff,0xffff") 1180 TEST_UNSUPPORTED(__inst_thumb32(0xffffffff) "")
1180 1181
1181 TEST_GROUP("Testing instructions in IT blocks") 1182 TEST_GROUP("Testing instructions in IT blocks")
1182 1183
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c
index c2fd06b4c389..379639998d5a 100644
--- a/arch/arm/kernel/kprobes-test.c
+++ b/arch/arm/kernel/kprobes-test.c
@@ -113,7 +113,7 @@
113 * @ start of inline data... 113 * @ start of inline data...
114 * .ascii "mov r0, r7" @ text title for test case 114 * .ascii "mov r0, r7" @ text title for test case
115 * .byte 0 115 * .byte 0
116 * .align 2 116 * .align 2, 0
117 * 117 *
118 * @ TEST_ARG_REG 118 * @ TEST_ARG_REG
119 * .byte ARG_TYPE_REG 119 * .byte ARG_TYPE_REG
@@ -1333,7 +1333,8 @@ static void test_case_failed(const char *message)
1333static unsigned long next_instruction(unsigned long pc) 1333static unsigned long next_instruction(unsigned long pc)
1334{ 1334{
1335#ifdef CONFIG_THUMB2_KERNEL 1335#ifdef CONFIG_THUMB2_KERNEL
1336 if ((pc & 1) && !is_wide_instruction(*(u16 *)(pc - 1))) 1336 if ((pc & 1) &&
1337 !is_wide_instruction(__mem_to_opcode_thumb16(*(u16 *)(pc - 1))))
1337 return pc + 2; 1338 return pc + 2;
1338 else 1339 else
1339#endif 1340#endif
@@ -1378,13 +1379,13 @@ static uintptr_t __used kprobes_test_case_start(const char *title, void *stack)
1378 1379
1379 if (test_case_is_thumb) { 1380 if (test_case_is_thumb) {
1380 u16 *p = (u16 *)(test_code & ~1); 1381 u16 *p = (u16 *)(test_code & ~1);
1381 current_instruction = p[0]; 1382 current_instruction = __mem_to_opcode_thumb16(p[0]);
1382 if (is_wide_instruction(current_instruction)) { 1383 if (is_wide_instruction(current_instruction)) {
1383 current_instruction <<= 16; 1384 u16 instr2 = __mem_to_opcode_thumb16(p[1]);
1384 current_instruction |= p[1]; 1385 current_instruction = __opcode_thumb32_compose(current_instruction, instr2);
1385 } 1386 }
1386 } else { 1387 } else {
1387 current_instruction = *(u32 *)test_code; 1388 current_instruction = __mem_to_opcode_arm(*(u32 *)test_code);
1388 } 1389 }
1389 1390
1390 if (current_title[0] == '.') 1391 if (current_title[0] == '.')
diff --git a/arch/arm/kernel/kprobes-test.h b/arch/arm/kernel/kprobes-test.h
index e28a869b1ae4..eecc90a0fd91 100644
--- a/arch/arm/kernel/kprobes-test.h
+++ b/arch/arm/kernel/kprobes-test.h
@@ -115,7 +115,7 @@ struct test_arg_end {
115 /* multiple strings to be concatenated. */ \ 115 /* multiple strings to be concatenated. */ \
116 ".ascii "#title" \n\t" \ 116 ".ascii "#title" \n\t" \
117 ".byte 0 \n\t" \ 117 ".byte 0 \n\t" \
118 ".align 2 \n\t" 118 ".align 2, 0 \n\t"
119 119
120#define TEST_ARG_REG(reg, val) \ 120#define TEST_ARG_REG(reg, val) \
121 ".byte "__stringify(ARG_TYPE_REG)" \n\t" \ 121 ".byte "__stringify(ARG_TYPE_REG)" \n\t" \
diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c
index 6619188619ae..9495d7f3516f 100644
--- a/arch/arm/kernel/kprobes-thumb.c
+++ b/arch/arm/kernel/kprobes-thumb.c
@@ -149,9 +149,9 @@ t32_decode_ldmstm(probes_opcode_t insn, struct arch_probes_insn *asi,
149 enum probes_insn ret = kprobe_decode_ldmstm(insn, asi, d); 149 enum probes_insn ret = kprobe_decode_ldmstm(insn, asi, d);
150 150
151 /* Fixup modified instruction to have halfwords in correct order...*/ 151 /* Fixup modified instruction to have halfwords in correct order...*/
152 insn = asi->insn[0]; 152 insn = __mem_to_opcode_arm(asi->insn[0]);
153 ((u16 *)asi->insn)[0] = insn >> 16; 153 ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(insn >> 16);
154 ((u16 *)asi->insn)[1] = insn & 0xffff; 154 ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0xffff);
155 155
156 return ret; 156 return ret;
157} 157}
@@ -516,7 +516,7 @@ t16_decode_hiregs(probes_opcode_t insn, struct arch_probes_insn *asi,
516{ 516{
517 insn &= ~0x00ff; 517 insn &= ~0x00ff;
518 insn |= 0x001; /* Set Rdn = R1 and Rm = R0 */ 518 insn |= 0x001; /* Set Rdn = R1 and Rm = R0 */
519 ((u16 *)asi->insn)[0] = insn; 519 ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(insn);
520 asi->insn_handler = t16_emulate_hiregs; 520 asi->insn_handler = t16_emulate_hiregs;
521 return INSN_GOOD; 521 return INSN_GOOD;
522} 522}
@@ -547,8 +547,10 @@ t16_decode_push(probes_opcode_t insn, struct arch_probes_insn *asi,
547 * and call it with R9=SP and LR in the register list represented 547 * and call it with R9=SP and LR in the register list represented
548 * by R8. 548 * by R8.
549 */ 549 */
550 ((u16 *)asi->insn)[0] = 0xe929; /* 1st half STMDB R9!,{} */ 550 /* 1st half STMDB R9!,{} */
551 ((u16 *)asi->insn)[1] = insn & 0x1ff; /* 2nd half (register list) */ 551 ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(0xe929);
552 /* 2nd half (register list) */
553 ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0x1ff);
552 asi->insn_handler = t16_emulate_push; 554 asi->insn_handler = t16_emulate_push;
553 return INSN_GOOD; 555 return INSN_GOOD;
554} 556}
@@ -600,8 +602,10 @@ t16_decode_pop(probes_opcode_t insn, struct arch_probes_insn *asi,
600 * and call it with R9=SP and PC in the register list represented 602 * and call it with R9=SP and PC in the register list represented
601 * by R8. 603 * by R8.
602 */ 604 */
603 ((u16 *)asi->insn)[0] = 0xe8b9; /* 1st half LDMIA R9!,{} */ 605 /* 1st half LDMIA R9!,{} */
604 ((u16 *)asi->insn)[1] = insn & 0x1ff; /* 2nd half (register list) */ 606 ((u16 *)asi->insn)[0] = __opcode_to_mem_thumb16(0xe8b9);
607 /* 2nd half (register list) */
608 ((u16 *)asi->insn)[1] = __opcode_to_mem_thumb16(insn & 0x1ff);
605 asi->insn_handler = insn & 0x100 ? t16_emulate_pop_pc 609 asi->insn_handler = insn & 0x100 ? t16_emulate_pop_pc
606 : t16_emulate_pop_nopc; 610 : t16_emulate_pop_nopc;
607 return INSN_GOOD; 611 return INSN_GOOD;
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c
index 8795f9f819d5..6d644202c8dc 100644
--- a/arch/arm/kernel/kprobes.c
+++ b/arch/arm/kernel/kprobes.c
@@ -26,6 +26,7 @@
26#include <linux/stop_machine.h> 26#include <linux/stop_machine.h>
27#include <linux/stringify.h> 27#include <linux/stringify.h>
28#include <asm/traps.h> 28#include <asm/traps.h>
29#include <asm/opcodes.h>
29#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
30#include <linux/percpu.h> 31#include <linux/percpu.h>
31#include <linux/bug.h> 32#include <linux/bug.h>
@@ -67,10 +68,10 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
67#ifdef CONFIG_THUMB2_KERNEL 68#ifdef CONFIG_THUMB2_KERNEL
68 thumb = true; 69 thumb = true;
69 addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */ 70 addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */
70 insn = ((u16 *)addr)[0]; 71 insn = __mem_to_opcode_thumb16(((u16 *)addr)[0]);
71 if (is_wide_instruction(insn)) { 72 if (is_wide_instruction(insn)) {
72 insn <<= 16; 73 u16 inst2 = __mem_to_opcode_thumb16(((u16 *)addr)[1]);
73 insn |= ((u16 *)addr)[1]; 74 insn = __opcode_thumb32_compose(insn, inst2);
74 decode_insn = thumb32_probes_decode_insn; 75 decode_insn = thumb32_probes_decode_insn;
75 actions = kprobes_t32_actions; 76 actions = kprobes_t32_actions;
76 } else { 77 } else {
@@ -81,7 +82,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
81 thumb = false; 82 thumb = false;
82 if (addr & 0x3) 83 if (addr & 0x3)
83 return -EINVAL; 84 return -EINVAL;
84 insn = *p->addr; 85 insn = __mem_to_opcode_arm(*p->addr);
85 decode_insn = arm_probes_decode_insn; 86 decode_insn = arm_probes_decode_insn;
86 actions = kprobes_arm_actions; 87 actions = kprobes_arm_actions;
87#endif 88#endif
diff --git a/arch/arm/kernel/pj4-cp0.c b/arch/arm/kernel/pj4-cp0.c
index 679cf4d18c08..fc7208636284 100644
--- a/arch/arm/kernel/pj4-cp0.c
+++ b/arch/arm/kernel/pj4-cp0.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <asm/thread_notify.h> 19#include <asm/thread_notify.h>
20#include <asm/cputype.h>
20 21
21static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t) 22static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t)
22{ 23{
@@ -80,6 +81,9 @@ static int __init pj4_cp0_init(void)
80{ 81{
81 u32 cp_access; 82 u32 cp_access;
82 83
84 if (!cpu_is_pj4())
85 return 0;
86
83 cp_access = pj4_cp_access_read() & ~0xf; 87 cp_access = pj4_cp_access_read() & ~0xf;
84 pj4_cp_access_write(cp_access); 88 pj4_cp_access_write(cp_access);
85 89
diff --git a/arch/arm/kernel/probes.c b/arch/arm/kernel/probes.c
index b41873f33e69..a8ab540d7e73 100644
--- a/arch/arm/kernel/probes.c
+++ b/arch/arm/kernel/probes.c
@@ -202,13 +202,14 @@ prepare_emulated_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
202#ifdef CONFIG_THUMB2_KERNEL 202#ifdef CONFIG_THUMB2_KERNEL
203 if (thumb) { 203 if (thumb) {
204 u16 *thumb_insn = (u16 *)asi->insn; 204 u16 *thumb_insn = (u16 *)asi->insn;
205 thumb_insn[1] = 0x4770; /* Thumb bx lr */ 205 /* Thumb bx lr */
206 thumb_insn[2] = 0x4770; /* Thumb bx lr */ 206 thumb_insn[1] = __opcode_to_mem_thumb16(0x4770);
207 thumb_insn[2] = __opcode_to_mem_thumb16(0x4770);
207 return insn; 208 return insn;
208 } 209 }
209 asi->insn[1] = 0xe12fff1e; /* ARM bx lr */ 210 asi->insn[1] = __opcode_to_mem_arm(0xe12fff1e); /* ARM bx lr */
210#else 211#else
211 asi->insn[1] = 0xe1a0f00e; /* mov pc, lr */ 212 asi->insn[1] = __opcode_to_mem_arm(0xe1a0f00e); /* mov pc, lr */
212#endif 213#endif
213 /* Make an ARM instruction unconditional */ 214 /* Make an ARM instruction unconditional */
214 if (insn < 0xe0000000) 215 if (insn < 0xe0000000)
@@ -228,12 +229,12 @@ set_emulated_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
228 if (thumb) { 229 if (thumb) {
229 u16 *ip = (u16 *)asi->insn; 230 u16 *ip = (u16 *)asi->insn;
230 if (is_wide_instruction(insn)) 231 if (is_wide_instruction(insn))
231 *ip++ = insn >> 16; 232 *ip++ = __opcode_to_mem_thumb16(insn >> 16);
232 *ip++ = insn; 233 *ip++ = __opcode_to_mem_thumb16(insn);
233 return; 234 return;
234 } 235 }
235#endif 236#endif
236 asi->insn[0] = insn; 237 asi->insn[0] = __opcode_to_mem_arm(insn);
237} 238}
238 239
239/* 240/*
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 806d287e3e53..81ef686a91ca 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -38,6 +38,7 @@
38#include <asm/processor.h> 38#include <asm/processor.h>
39#include <asm/thread_notify.h> 39#include <asm/thread_notify.h>
40#include <asm/stacktrace.h> 40#include <asm/stacktrace.h>
41#include <asm/system_misc.h>
41#include <asm/mach/time.h> 42#include <asm/mach/time.h>
42#include <asm/tls.h> 43#include <asm/tls.h>
43 44
@@ -99,7 +100,7 @@ void soft_restart(unsigned long addr)
99 u64 *stack = soft_restart_stack + ARRAY_SIZE(soft_restart_stack); 100 u64 *stack = soft_restart_stack + ARRAY_SIZE(soft_restart_stack);
100 101
101 /* Disable interrupts first */ 102 /* Disable interrupts first */
102 local_irq_disable(); 103 raw_local_irq_disable();
103 local_fiq_disable(); 104 local_fiq_disable();
104 105
105 /* Disable the L2 if we're the last man standing. */ 106 /* Disable the L2 if we're the last man standing. */
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 172ee18ff124..abd2fc067736 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -445,6 +445,7 @@ die_sig:
445 if (user_debug & UDBG_UNDEFINED) { 445 if (user_debug & UDBG_UNDEFINED) {
446 printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n", 446 printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",
447 current->comm, task_pid_nr(current), pc); 447 current->comm, task_pid_nr(current), pc);
448 __show_regs(regs);
448 dump_instr(KERN_INFO, regs); 449 dump_instr(KERN_INFO, regs);
449 } 450 }
450#endif 451#endif
diff --git a/arch/arm/mach-vexpress/dcscb.c b/arch/arm/mach-vexpress/dcscb.c
index 14d499688736..788495d35cf9 100644
--- a/arch/arm/mach-vexpress/dcscb.c
+++ b/arch/arm/mach-vexpress/dcscb.c
@@ -137,11 +137,16 @@ static void dcscb_power_down(void)
137 v7_exit_coherency_flush(all); 137 v7_exit_coherency_flush(all);
138 138
139 /* 139 /*
140 * This is a harmless no-op. On platforms with a real 140 * A full outer cache flush could be needed at this point
141 * outer cache this might either be needed or not, 141 * on platforms with such a cache, depending on where the
142 * depending on where the outer cache sits. 142 * outer cache sits. In some cases the notion of a "last
143 * cluster standing" would need to be implemented if the
144 * outer cache is shared across clusters. In any case, when
145 * the outer cache needs flushing, there is no concurrent
146 * access to the cache controller to worry about and no
147 * special locking besides what is already provided by the
148 * MCPM state machinery is needed.
143 */ 149 */
144 outer_flush_all();
145 150
146 /* 151 /*
147 * Disable cluster-level coherency by masking 152 * Disable cluster-level coherency by masking
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index ef69152f9b52..c508f41a43bc 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -120,34 +120,51 @@ static const struct prot_bits pte_bits[] = {
120}; 120};
121 121
122static const struct prot_bits section_bits[] = { 122static const struct prot_bits section_bits[] = {
123#ifndef CONFIG_ARM_LPAE 123#ifdef CONFIG_ARM_LPAE
124 /* These are approximate */ 124 {
125 .mask = PMD_SECT_USER,
126 .val = PMD_SECT_USER,
127 .set = "USR",
128 }, {
129 .mask = PMD_SECT_RDONLY,
130 .val = PMD_SECT_RDONLY,
131 .set = "ro",
132 .clear = "RW",
133#elif __LINUX_ARM_ARCH__ >= 6
125 { 134 {
126 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, 135 .mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
127 .val = 0, 136 .val = PMD_SECT_APX | PMD_SECT_AP_WRITE,
128 .set = " ro", 137 .set = " ro",
129 }, { 138 }, {
130 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, 139 .mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
131 .val = PMD_SECT_AP_WRITE, 140 .val = PMD_SECT_AP_WRITE,
132 .set = " RW", 141 .set = " RW",
133 }, { 142 }, {
134 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, 143 .mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
135 .val = PMD_SECT_AP_READ, 144 .val = PMD_SECT_AP_READ,
136 .set = "USR ro", 145 .set = "USR ro",
137 }, { 146 }, {
138 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, 147 .mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
139 .val = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, 148 .val = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
140 .set = "USR RW", 149 .set = "USR RW",
141#else 150#else /* ARMv4/ARMv5 */
151 /* These are approximate */
142 { 152 {
143 .mask = PMD_SECT_USER, 153 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
144 .val = PMD_SECT_USER, 154 .val = 0,
145 .set = "USR", 155 .set = " ro",
146 }, { 156 }, {
147 .mask = PMD_SECT_RDONLY, 157 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
148 .val = PMD_SECT_RDONLY, 158 .val = PMD_SECT_AP_WRITE,
149 .set = "ro", 159 .set = " RW",
150 .clear = "RW", 160 }, {
161 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
162 .val = PMD_SECT_AP_READ,
163 .set = "USR ro",
164 }, {
165 .mask = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
166 .val = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE,
167 .set = "USR RW",
151#endif 168#endif
152 }, { 169 }, {
153 .mask = PMD_SECT_XN, 170 .mask = PMD_SECT_XN,
diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
index 46e17492fd1f..f0759e70fb86 100644
--- a/arch/arm/vfp/entry.S
+++ b/arch/arm/vfp/entry.S
@@ -8,9 +8,12 @@
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11#include <linux/init.h>
12#include <linux/linkage.h>
11#include <asm/thread_info.h> 13#include <asm/thread_info.h>
12#include <asm/vfpmacros.h> 14#include <asm/vfpmacros.h>
13#include "../kernel/entry-header.S" 15#include <asm/assembler.h>
16#include <asm/asm-offsets.h>
14 17
15@ VFP entry point. 18@ VFP entry point.
16@ 19@
@@ -22,11 +25,7 @@
22@ IRQs disabled. 25@ IRQs disabled.
23@ 26@
24ENTRY(do_vfp) 27ENTRY(do_vfp)
25#ifdef CONFIG_PREEMPT_COUNT 28 inc_preempt_count r10, r4
26 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
27 add r11, r4, #1 @ increment it
28 str r11, [r10, #TI_PREEMPT]
29#endif
30 enable_irq 29 enable_irq
31 ldr r4, .LCvfp 30 ldr r4, .LCvfp
32 ldr r11, [r10, #TI_CPU] @ CPU number 31 ldr r11, [r10, #TI_CPU] @ CPU number
@@ -35,12 +34,7 @@ ENTRY(do_vfp)
35ENDPROC(do_vfp) 34ENDPROC(do_vfp)
36 35
37ENTRY(vfp_null_entry) 36ENTRY(vfp_null_entry)
38#ifdef CONFIG_PREEMPT_COUNT 37 dec_preempt_count_ti r10, r4
39 get_thread_info r10
40 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
41 sub r11, r4, #1 @ decrement it
42 str r11, [r10, #TI_PREEMPT]
43#endif
44 mov pc, lr 38 mov pc, lr
45ENDPROC(vfp_null_entry) 39ENDPROC(vfp_null_entry)
46 40
@@ -53,12 +47,7 @@ ENDPROC(vfp_null_entry)
53 47
54 __INIT 48 __INIT
55ENTRY(vfp_testing_entry) 49ENTRY(vfp_testing_entry)
56#ifdef CONFIG_PREEMPT_COUNT 50 dec_preempt_count_ti r10, r4
57 get_thread_info r10
58 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
59 sub r11, r4, #1 @ decrement it
60 str r11, [r10, #TI_PREEMPT]
61#endif
62 ldr r0, VFP_arch_address 51 ldr r0, VFP_arch_address
63 str r0, [r0] @ set to non-zero value 52 str r0, [r0] @ set to non-zero value
64 mov pc, r9 @ we have handled the fault 53 mov pc, r9 @ we have handled the fault
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index 3e5d3115a2a6..be807625ed8c 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -14,10 +14,13 @@
14 * r10 points at the start of the private FP workspace in the thread structure 14 * r10 points at the start of the private FP workspace in the thread structure
15 * sp points to a struct pt_regs (as defined in include/asm/proc/ptrace.h) 15 * sp points to a struct pt_regs (as defined in include/asm/proc/ptrace.h)
16 */ 16 */
17#include <linux/init.h>
18#include <linux/linkage.h>
17#include <asm/thread_info.h> 19#include <asm/thread_info.h>
18#include <asm/vfpmacros.h> 20#include <asm/vfpmacros.h>
19#include <linux/kern_levels.h> 21#include <linux/kern_levels.h>
20#include "../kernel/entry-header.S" 22#include <asm/assembler.h>
23#include <asm/asm-offsets.h>
21 24
22 .macro DBGSTR, str 25 .macro DBGSTR, str
23#ifdef DEBUG 26#ifdef DEBUG
@@ -179,12 +182,7 @@ vfp_hw_state_valid:
179 @ else it's one 32-bit instruction, so 182 @ else it's one 32-bit instruction, so
180 @ always subtract 4 from the following 183 @ always subtract 4 from the following
181 @ instruction address. 184 @ instruction address.
182#ifdef CONFIG_PREEMPT_COUNT 185 dec_preempt_count_ti r10, r4
183 get_thread_info r10
184 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
185 sub r11, r4, #1 @ decrement it
186 str r11, [r10, #TI_PREEMPT]
187#endif
188 mov pc, r9 @ we think we have handled things 186 mov pc, r9 @ we think we have handled things
189 187
190 188
@@ -203,12 +201,7 @@ look_for_VFP_exceptions:
203 @ not recognised by VFP 201 @ not recognised by VFP
204 202
205 DBGSTR "not VFP" 203 DBGSTR "not VFP"
206#ifdef CONFIG_PREEMPT_COUNT 204 dec_preempt_count_ti r10, r4
207 get_thread_info r10
208 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
209 sub r11, r4, #1 @ decrement it
210 str r11, [r10, #TI_PREEMPT]
211#endif
212 mov pc, lr 205 mov pc, lr
213 206
214process_exception: 207process_exception:
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 9ceccef9c649..f81e7b989fff 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -34,6 +34,7 @@ config BLACKFIN
34 select ARCH_WANT_IPC_PARSE_VERSION 34 select ARCH_WANT_IPC_PARSE_VERSION
35 select GENERIC_ATOMIC64 35 select GENERIC_ATOMIC64
36 select GENERIC_IRQ_PROBE 36 select GENERIC_IRQ_PROBE
37 select GENERIC_IRQ_SHOW
37 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG 38 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
38 select GENERIC_SMP_IDLE_THREAD 39 select GENERIC_SMP_IDLE_THREAD
39 select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS 40 select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS
@@ -51,9 +52,6 @@ config GENERIC_BUG
51config ZONE_DMA 52config ZONE_DMA
52 def_bool y 53 def_bool y
53 54
54config GENERIC_GPIO
55 def_bool y
56
57config FORCE_MAX_ZONEORDER 55config FORCE_MAX_ZONEORDER
58 int 56 int
59 default "14" 57 default "14"
@@ -870,14 +868,6 @@ config SYS_BFIN_SPINLOCK_L1
870 If enabled, sys_bfin_spinlock function is linked 868 If enabled, sys_bfin_spinlock function is linked
871 into L1 instruction memory. (less latency) 869 into L1 instruction memory. (less latency)
872 870
873config IP_CHECKSUM_L1
874 bool "Locate IP Checksum function in L1 Memory"
875 default n
876 depends on !SMP
877 help
878 If enabled, the IP Checksum function is linked
879 into L1 instruction memory. (less latency)
880
881config CACHELINE_ALIGNED_L1 871config CACHELINE_ALIGNED_L1
882 bool "Locate cacheline_aligned data to L1 Data Memory" 872 bool "Locate cacheline_aligned data to L1 Data Memory"
883 default y if !BF54x 873 default y if !BF54x
diff --git a/arch/blackfin/include/asm/bfin_crc.h b/arch/blackfin/include/asm/bfin_crc.h
deleted file mode 100644
index 75cef4dc85a1..000000000000
--- a/arch/blackfin/include/asm/bfin_crc.h
+++ /dev/null
@@ -1,125 +0,0 @@
1/*
2 * bfin_crc.h - interface to Blackfin CRC controllers
3 *
4 * Copyright 2012 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __BFIN_CRC_H__
10#define __BFIN_CRC_H__
11
12/* Function driver which use hardware crc must initialize the structure */
13struct crc_info {
14 /* Input data address */
15 unsigned char *in_addr;
16 /* Output data address */
17 unsigned char *out_addr;
18 /* Input or output bytes */
19 unsigned long datasize;
20 union {
21 /* CRC to compare with that of input buffer */
22 unsigned long crc_compare;
23 /* Value to compare with input data */
24 unsigned long val_verify;
25 /* Value to fill */
26 unsigned long val_fill;
27 };
28 /* Value to program the 32b CRC Polynomial */
29 unsigned long crc_poly;
30 union {
31 /* CRC calculated from the input data */
32 unsigned long crc_result;
33 /* First failed position to verify input data */
34 unsigned long pos_verify;
35 };
36 /* CRC mirror flags */
37 unsigned int bitmirr:1;
38 unsigned int bytmirr:1;
39 unsigned int w16swp:1;
40 unsigned int fdsel:1;
41 unsigned int rsltmirr:1;
42 unsigned int polymirr:1;
43 unsigned int cmpmirr:1;
44};
45
46/* Userspace interface */
47#define CRC_IOC_MAGIC 'C'
48#define CRC_IOC_CALC_CRC _IOWR('C', 0x01, unsigned int)
49#define CRC_IOC_MEMCPY_CRC _IOWR('C', 0x02, unsigned int)
50#define CRC_IOC_VERIFY_VAL _IOWR('C', 0x03, unsigned int)
51#define CRC_IOC_FILL_VAL _IOWR('C', 0x04, unsigned int)
52
53
54#ifdef __KERNEL__
55
56#include <linux/types.h>
57#include <linux/spinlock.h>
58#include <linux/miscdevice.h>
59
60struct crc_register {
61 u32 control;
62 u32 datacnt;
63 u32 datacntrld;
64 u32 __pad_1[2];
65 u32 compare;
66 u32 fillval;
67 u32 datafifo;
68 u32 intren;
69 u32 intrenset;
70 u32 intrenclr;
71 u32 poly;
72 u32 __pad_2[4];
73 u32 status;
74 u32 datacntcap;
75 u32 __pad_3;
76 u32 result;
77 u32 curresult;
78 u32 __pad_4[3];
79 u32 revid;
80};
81
82/* CRC_STATUS Masks */
83#define CMPERR 0x00000002 /* Compare error */
84#define DCNTEXP 0x00000010 /* datacnt register expired */
85#define IBR 0x00010000 /* Input buffer ready */
86#define OBR 0x00020000 /* Output buffer ready */
87#define IRR 0x00040000 /* Immediate result readt */
88#define LUTDONE 0x00080000 /* Look-up table generation done */
89#define FSTAT 0x00700000 /* FIFO status */
90#define MAX_FIFO 4 /* Max fifo size */
91
92/* CRC_CONTROL Masks */
93#define BLKEN 0x00000001 /* Block enable */
94#define OPMODE 0x000000F0 /* Operation mode */
95#define OPMODE_OFFSET 4 /* Operation mode mask offset*/
96#define MODE_DMACPY_CRC 1 /* MTM CRC compute and compare */
97#define MODE_DATA_FILL 2 /* MTM data fill */
98#define MODE_CALC_CRC 3 /* MSM CRC compute and compare */
99#define MODE_DATA_VERIFY 4 /* MSM data verify */
100#define AUTOCLRZ 0x00000100 /* Auto clear to zero */
101#define AUTOCLRF 0x00000200 /* Auto clear to one */
102#define OBRSTALL 0x00001000 /* Stall on output buffer ready */
103#define IRRSTALL 0x00002000 /* Stall on immediate result ready */
104#define BITMIRR 0x00010000 /* Mirror bits within each byte of 32-bit input data */
105#define BITMIRR_OFFSET 16 /* Mirror bits offset */
106#define BYTMIRR 0x00020000 /* Mirror bytes of 32-bit input data */
107#define BYTMIRR_OFFSET 17 /* Mirror bytes offset */
108#define W16SWP 0x00040000 /* Mirror uppper and lower 16-bit word of 32-bit input data */
109#define W16SWP_OFFSET 18 /* Mirror 16-bit word offset */
110#define FDSEL 0x00080000 /* FIFO is written after input data is mirrored */
111#define FDSEL_OFFSET 19 /* Mirror FIFO offset */
112#define RSLTMIRR 0x00100000 /* CRC result registers are mirrored. */
113#define RSLTMIRR_OFFSET 20 /* Mirror CRC result offset. */
114#define POLYMIRR 0x00200000 /* CRC poly register is mirrored. */
115#define POLYMIRR_OFFSET 21 /* Mirror CRC poly offset. */
116#define CMPMIRR 0x00400000 /* CRC compare register is mirrored. */
117#define CMPMIRR_OFFSET 22 /* Mirror CRC compare offset. */
118
119/* CRC_INTREN Masks */
120#define CMPERRI 0x02 /* CRC_ERROR_INTR */
121#define DCNTEXPI 0x10 /* CRC_STATUS_INTR */
122
123#endif
124
125#endif
diff --git a/arch/blackfin/include/asm/bfin_twi.h b/arch/blackfin/include/asm/bfin_twi.h
index 90c3c006557d..aaa0834d34aa 100644
--- a/arch/blackfin/include/asm/bfin_twi.h
+++ b/arch/blackfin/include/asm/bfin_twi.h
@@ -9,60 +9,7 @@
9#ifndef __ASM_BFIN_TWI_H__ 9#ifndef __ASM_BFIN_TWI_H__
10#define __ASM_BFIN_TWI_H__ 10#define __ASM_BFIN_TWI_H__
11 11
12#include <linux/types.h> 12#include <asm/blackfin.h>
13#include <linux/i2c.h>
14
15/*
16 * All Blackfin system MMRs are padded to 32bits even if the register
17 * itself is only 16bits. So use a helper macro to streamline this.
18 */
19#define __BFP(m) u16 m; u16 __pad_##m
20
21/*
22 * bfin twi registers layout
23 */
24struct bfin_twi_regs {
25 __BFP(clkdiv);
26 __BFP(control);
27 __BFP(slave_ctl);
28 __BFP(slave_stat);
29 __BFP(slave_addr);
30 __BFP(master_ctl);
31 __BFP(master_stat);
32 __BFP(master_addr);
33 __BFP(int_stat);
34 __BFP(int_mask);
35 __BFP(fifo_ctl);
36 __BFP(fifo_stat);
37 u32 __pad[20];
38 __BFP(xmt_data8);
39 __BFP(xmt_data16);
40 __BFP(rcv_data8);
41 __BFP(rcv_data16);
42};
43
44#undef __BFP
45
46struct bfin_twi_iface {
47 int irq;
48 spinlock_t lock;
49 char read_write;
50 u8 command;
51 u8 *transPtr;
52 int readNum;
53 int writeNum;
54 int cur_mode;
55 int manual_stop;
56 int result;
57 struct i2c_adapter adap;
58 struct completion complete;
59 struct i2c_msg *pmsg;
60 int msg_num;
61 int cur_msg;
62 u16 saved_clkdiv;
63 u16 saved_control;
64 struct bfin_twi_regs __iomem *regs_base;
65};
66 13
67#define DEFINE_TWI_REG(reg_name, reg) \ 14#define DEFINE_TWI_REG(reg_name, reg) \
68static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \ 15static inline u16 read_##reg_name(struct bfin_twi_iface *iface) \
@@ -71,7 +18,6 @@ static inline void write_##reg_name(struct bfin_twi_iface *iface, u16 v) \
71 { bfin_write16(&iface->regs_base->reg, v); } 18 { bfin_write16(&iface->regs_base->reg, v); }
72 19
73DEFINE_TWI_REG(CLKDIV, clkdiv) 20DEFINE_TWI_REG(CLKDIV, clkdiv)
74DEFINE_TWI_REG(CONTROL, control)
75DEFINE_TWI_REG(SLAVE_CTL, slave_ctl) 21DEFINE_TWI_REG(SLAVE_CTL, slave_ctl)
76DEFINE_TWI_REG(SLAVE_STAT, slave_stat) 22DEFINE_TWI_REG(SLAVE_STAT, slave_stat)
77DEFINE_TWI_REG(SLAVE_ADDR, slave_addr) 23DEFINE_TWI_REG(SLAVE_ADDR, slave_addr)
@@ -80,7 +26,6 @@ DEFINE_TWI_REG(MASTER_STAT, master_stat)
80DEFINE_TWI_REG(MASTER_ADDR, master_addr) 26DEFINE_TWI_REG(MASTER_ADDR, master_addr)
81DEFINE_TWI_REG(INT_STAT, int_stat) 27DEFINE_TWI_REG(INT_STAT, int_stat)
82DEFINE_TWI_REG(INT_MASK, int_mask) 28DEFINE_TWI_REG(INT_MASK, int_mask)
83DEFINE_TWI_REG(FIFO_CTL, fifo_ctl)
84DEFINE_TWI_REG(FIFO_STAT, fifo_stat) 29DEFINE_TWI_REG(FIFO_STAT, fifo_stat)
85DEFINE_TWI_REG(XMT_DATA8, xmt_data8) 30DEFINE_TWI_REG(XMT_DATA8, xmt_data8)
86DEFINE_TWI_REG(XMT_DATA16, xmt_data16) 31DEFINE_TWI_REG(XMT_DATA16, xmt_data16)
@@ -113,75 +58,25 @@ static inline u16 read_RCV_DATA16(struct bfin_twi_iface *iface)
113} 58}
114#endif 59#endif
115 60
61static inline u16 read_FIFO_CTL(struct bfin_twi_iface *iface)
62{
63 return bfin_read16(&iface->regs_base->fifo_ctl);
64}
116 65
117/* ******************** TWO-WIRE INTERFACE (TWI) MASKS ***********************/ 66static inline void write_FIFO_CTL(struct bfin_twi_iface *iface, u16 v)
118/* TWI_CLKDIV Macros (Use: *pTWI_CLKDIV = CLKLOW(x)|CLKHI(y); ) */ 67{
119#define CLKLOW(x) ((x) & 0xFF) /* Periods Clock Is Held Low */ 68 bfin_write16(&iface->regs_base->fifo_ctl, v);
120#define CLKHI(y) (((y)&0xFF)<<0x8) /* Periods Before New Clock Low */ 69 SSYNC();
121 70}
122/* TWI_PRESCALE Masks */
123#define PRESCALE 0x007F /* SCLKs Per Internal Time Reference (10MHz) */
124#define TWI_ENA 0x0080 /* TWI Enable */
125#define SCCB 0x0200 /* SCCB Compatibility Enable */
126
127/* TWI_SLAVE_CTL Masks */
128#define SEN 0x0001 /* Slave Enable */
129#define SADD_LEN 0x0002 /* Slave Address Length */
130#define STDVAL 0x0004 /* Slave Transmit Data Valid */
131#define NAK 0x0008 /* NAK/ACK* Generated At Conclusion Of Transfer */
132#define GEN 0x0010 /* General Call Address Matching Enabled */
133
134/* TWI_SLAVE_STAT Masks */
135#define SDIR 0x0001 /* Slave Transfer Direction (Transmit/Receive*) */
136#define GCALL 0x0002 /* General Call Indicator */
137
138/* TWI_MASTER_CTL Masks */
139#define MEN 0x0001 /* Master Mode Enable */
140#define MADD_LEN 0x0002 /* Master Address Length */
141#define MDIR 0x0004 /* Master Transmit Direction (RX/TX*) */
142#define FAST 0x0008 /* Use Fast Mode Timing Specs */
143#define STOP 0x0010 /* Issue Stop Condition */
144#define RSTART 0x0020 /* Repeat Start or Stop* At End Of Transfer */
145#define DCNT 0x3FC0 /* Data Bytes To Transfer */
146#define SDAOVR 0x4000 /* Serial Data Override */
147#define SCLOVR 0x8000 /* Serial Clock Override */
148
149/* TWI_MASTER_STAT Masks */
150#define MPROG 0x0001 /* Master Transfer In Progress */
151#define LOSTARB 0x0002 /* Lost Arbitration Indicator (Xfer Aborted) */
152#define ANAK 0x0004 /* Address Not Acknowledged */
153#define DNAK 0x0008 /* Data Not Acknowledged */
154#define BUFRDERR 0x0010 /* Buffer Read Error */
155#define BUFWRERR 0x0020 /* Buffer Write Error */
156#define SDASEN 0x0040 /* Serial Data Sense */
157#define SCLSEN 0x0080 /* Serial Clock Sense */
158#define BUSBUSY 0x0100 /* Bus Busy Indicator */
159
160/* TWI_INT_SRC and TWI_INT_ENABLE Masks */
161#define SINIT 0x0001 /* Slave Transfer Initiated */
162#define SCOMP 0x0002 /* Slave Transfer Complete */
163#define SERR 0x0004 /* Slave Transfer Error */
164#define SOVF 0x0008 /* Slave Overflow */
165#define MCOMP 0x0010 /* Master Transfer Complete */
166#define MERR 0x0020 /* Master Transfer Error */
167#define XMTSERV 0x0040 /* Transmit FIFO Service */
168#define RCVSERV 0x0080 /* Receive FIFO Service */
169
170/* TWI_FIFO_CTRL Masks */
171#define XMTFLUSH 0x0001 /* Transmit Buffer Flush */
172#define RCVFLUSH 0x0002 /* Receive Buffer Flush */
173#define XMTINTLEN 0x0004 /* Transmit Buffer Interrupt Length */
174#define RCVINTLEN 0x0008 /* Receive Buffer Interrupt Length */
175
176/* TWI_FIFO_STAT Masks */
177#define XMTSTAT 0x0003 /* Transmit FIFO Status */
178#define XMT_EMPTY 0x0000 /* Transmit FIFO Empty */
179#define XMT_HALF 0x0001 /* Transmit FIFO Has 1 Byte To Write */
180#define XMT_FULL 0x0003 /* Transmit FIFO Full (2 Bytes To Write) */
181 71
182#define RCVSTAT 0x000C /* Receive FIFO Status */ 72static inline u16 read_CONTROL(struct bfin_twi_iface *iface)
183#define RCV_EMPTY 0x0000 /* Receive FIFO Empty */ 73{
184#define RCV_HALF 0x0004 /* Receive FIFO Has 1 Byte To Read */ 74 return bfin_read16(&iface->regs_base->control);
185#define RCV_FULL 0x000C /* Receive FIFO Full (2 Bytes To Read) */ 75}
186 76
77static inline void write_CONTROL(struct bfin_twi_iface *iface, u16 v)
78{
79 SSYNC();
80 bfin_write16(&iface->regs_base->control, v);
81}
187#endif 82#endif
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h
index 40e9c2bbc6e3..8d1e4c2d2c36 100644
--- a/arch/blackfin/include/asm/dma.h
+++ b/arch/blackfin/include/asm/dma.h
@@ -316,8 +316,6 @@ static inline void disable_dma(unsigned int channel)
316} 316}
317static inline void enable_dma(unsigned int channel) 317static inline void enable_dma(unsigned int channel)
318{ 318{
319 dma_ch[channel].regs->curr_x_count = 0;
320 dma_ch[channel].regs->curr_y_count = 0;
321 dma_ch[channel].regs->cfg |= DMAEN; 319 dma_ch[channel].regs->cfg |= DMAEN;
322} 320}
323int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data); 321int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data);
diff --git a/arch/blackfin/include/asm/portmux.h b/arch/blackfin/include/asm/portmux.h
index 7aa20436e799..c8f0939419be 100644
--- a/arch/blackfin/include/asm/portmux.h
+++ b/arch/blackfin/include/asm/portmux.h
@@ -18,16 +18,14 @@
18#define P_DONTCARE 0x1000 18#define P_DONTCARE 0x1000
19 19
20#ifdef CONFIG_PINCTRL 20#ifdef CONFIG_PINCTRL
21#include <asm/irq_handler.h> 21int bfin_internal_set_wake(unsigned int irq, unsigned int state);
22 22
23#define gpio_pint_regs bfin_pint_regs 23#define gpio_pint_regs bfin_pint_regs
24#define adi_internal_set_wake bfin_internal_set_wake 24#define adi_internal_set_wake bfin_internal_set_wake
25 25
26#define peripheral_request(per, label) 0 26#define peripheral_request(per, label) (0)
27#define peripheral_free(per) 27#define peripheral_free(per)
28#define peripheral_request_list(per, label) \ 28#define peripheral_request_list(per, label) (0)
29 (pdev ? (IS_ERR(devm_pinctrl_get_select_default(&pdev->dev)) \
30 ? -EINVAL : 0) : 0)
31#define peripheral_free_list(per) 29#define peripheral_free_list(per)
32#else 30#else
33int peripheral_request(unsigned short per, const char *label); 31int peripheral_request(unsigned short per, const char *label);
@@ -39,7 +37,7 @@ void peripheral_free_list(const unsigned short per[]);
39#include <linux/err.h> 37#include <linux/err.h>
40#include <linux/pinctrl/pinctrl.h> 38#include <linux/pinctrl/pinctrl.h>
41#include <mach/portmux.h> 39#include <mach/portmux.h>
42#include <linux/gpio.h> 40#include <mach/gpio.h>
43 41
44#ifndef P_SPORT2_TFS 42#ifndef P_SPORT2_TFS
45#define P_SPORT2_TFS P_UNDEF 43#define P_SPORT2_TFS P_UNDEF
diff --git a/arch/blackfin/kernel/debug-mmrs.c b/arch/blackfin/kernel/debug-mmrs.c
index 01232a13470d..947ad0832338 100644
--- a/arch/blackfin/kernel/debug-mmrs.c
+++ b/arch/blackfin/kernel/debug-mmrs.c
@@ -10,6 +10,7 @@
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/i2c/bfin_twi.h>
13 14
14#include <asm/blackfin.h> 15#include <asm/blackfin.h>
15#include <asm/gpio.h> 16#include <asm/gpio.h>
diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c
index ff3d747154ac..0ba25764b8c0 100644
--- a/arch/blackfin/kernel/irqchip.c
+++ b/arch/blackfin/kernel/irqchip.c
@@ -11,6 +11,7 @@
11#include <linux/kallsyms.h> 11#include <linux/kallsyms.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/seq_file.h>
14#include <asm/irq_handler.h> 15#include <asm/irq_handler.h>
15#include <asm/trace.h> 16#include <asm/trace.h>
16#include <asm/pda.h> 17#include <asm/pda.h>
@@ -33,37 +34,15 @@ static struct irq_desc bad_irq_desc = {
33#endif 34#endif
34 35
35#ifdef CONFIG_PROC_FS 36#ifdef CONFIG_PROC_FS
36int show_interrupts(struct seq_file *p, void *v) 37int arch_show_interrupts(struct seq_file *p, int prec)
37{ 38{
38 int i = *(loff_t *) v, j; 39 int j;
39 struct irqaction *action; 40
40 unsigned long flags; 41 seq_printf(p, "%*s: ", prec, "NMI");
41 42 for_each_online_cpu(j)
42 if (i < NR_IRQS) { 43 seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
43 struct irq_desc *desc = irq_to_desc(i); 44 seq_printf(p, " CORE Non Maskable Interrupt\n");
44 45 seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
45 raw_spin_lock_irqsave(&desc->lock, flags);
46 action = desc->action;
47 if (!action)
48 goto skip;
49 seq_printf(p, "%3d: ", i);
50 for_each_online_cpu(j)
51 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
52 seq_printf(p, " %8s", irq_desc_get_chip(desc)->name);
53 seq_printf(p, " %s", action->name);
54 for (action = action->next; action; action = action->next)
55 seq_printf(p, " %s", action->name);
56
57 seq_putc(p, '\n');
58 skip:
59 raw_spin_unlock_irqrestore(&desc->lock, flags);
60 } else if (i == NR_IRQS) {
61 seq_printf(p, "NMI: ");
62 for_each_online_cpu(j)
63 seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
64 seq_printf(p, " CORE Non Maskable Interrupt\n");
65 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
66 }
67 return 0; 46 return 0;
68} 47}
69#endif 48#endif
diff --git a/arch/blackfin/mach-bf518/boards/ezbrd.c b/arch/blackfin/mach-bf518/boards/ezbrd.c
index f8047ca3b339..d022112927c2 100644
--- a/arch/blackfin/mach-bf518/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf518/boards/ezbrd.c
@@ -36,7 +36,7 @@ const char bfin_board_name[] = "ADI BF518F-EZBRD";
36 * Driver needs to know address, irq and flag pin. 36 * Driver needs to know address, irq and flag pin.
37 */ 37 */
38 38
39#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 39#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
40static struct mtd_partition ezbrd_partitions[] = { 40static struct mtd_partition ezbrd_partitions[] = {
41 { 41 {
42 .name = "bootloader(nor)", 42 .name = "bootloader(nor)",
@@ -61,7 +61,7 @@ static struct physmap_flash_data ezbrd_flash_data = {
61 61
62static struct resource ezbrd_flash_resource = { 62static struct resource ezbrd_flash_resource = {
63 .start = 0x20000000, 63 .start = 0x20000000,
64#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 64#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
65 .end = 0x202fffff, 65 .end = 0x202fffff,
66#else 66#else
67 .end = 0x203fffff, 67 .end = 0x203fffff,
@@ -80,14 +80,14 @@ static struct platform_device ezbrd_flash_device = {
80}; 80};
81#endif 81#endif
82 82
83#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 83#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
84static struct platform_device rtc_device = { 84static struct platform_device rtc_device = {
85 .name = "rtc-bfin", 85 .name = "rtc-bfin",
86 .id = -1, 86 .id = -1,
87}; 87};
88#endif 88#endif
89 89
90#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 90#if IS_ENABLED(CONFIG_BFIN_MAC)
91#include <linux/bfin_mac.h> 91#include <linux/bfin_mac.h>
92static const unsigned short bfin_mac_peripherals[] = { 92static const unsigned short bfin_mac_peripherals[] = {
93 P_MII0_ETxD0, 93 P_MII0_ETxD0,
@@ -105,7 +105,7 @@ static const unsigned short bfin_mac_peripherals[] = {
105 105
106static struct bfin_phydev_platform_data bfin_phydev_data[] = { 106static struct bfin_phydev_platform_data bfin_phydev_data[] = {
107 { 107 {
108#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE) 108#if IS_ENABLED(CONFIG_NET_DSA_KSZ8893M)
109 .addr = 3, 109 .addr = 3,
110#else 110#else
111 .addr = 1, 111 .addr = 1,
@@ -119,7 +119,7 @@ static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
119 .phydev_data = bfin_phydev_data, 119 .phydev_data = bfin_phydev_data,
120 .phy_mode = PHY_INTERFACE_MODE_MII, 120 .phy_mode = PHY_INTERFACE_MODE_MII,
121 .mac_peripherals = bfin_mac_peripherals, 121 .mac_peripherals = bfin_mac_peripherals,
122#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE) 122#if IS_ENABLED(CONFIG_NET_DSA_KSZ8893M)
123 .phy_mask = 0xfff7, /* Only probe the port phy connect to the on chip MAC */ 123 .phy_mask = 0xfff7, /* Only probe the port phy connect to the on chip MAC */
124#endif 124#endif
125 .vlan1_mask = 1, 125 .vlan1_mask = 1,
@@ -140,7 +140,7 @@ static struct platform_device bfin_mac_device = {
140 } 140 }
141}; 141};
142 142
143#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE) 143#if IS_ENABLED(CONFIG_NET_DSA_KSZ8893M)
144static struct dsa_chip_data ksz8893m_switch_chip_data = { 144static struct dsa_chip_data ksz8893m_switch_chip_data = {
145 .mii_bus = &bfin_mii_bus.dev, 145 .mii_bus = &bfin_mii_bus.dev,
146 .port_names = { 146 .port_names = {
@@ -165,8 +165,7 @@ static struct platform_device ksz8893m_switch_device = {
165#endif 165#endif
166#endif 166#endif
167 167
168#if defined(CONFIG_MTD_M25P80) \ 168#if IS_ENABLED(CONFIG_MTD_M25P80)
169 || defined(CONFIG_MTD_M25P80_MODULE)
170static struct mtd_partition bfin_spi_flash_partitions[] = { 169static struct mtd_partition bfin_spi_flash_partitions[] = {
171 { 170 {
172 .name = "bootloader(spi)", 171 .name = "bootloader(spi)",
@@ -193,13 +192,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
193}; 192};
194#endif 193#endif
195 194
196#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 195#if IS_ENABLED(CONFIG_MMC_SPI)
197static struct bfin5xx_spi_chip mmc_spi_chip_info = { 196static struct bfin5xx_spi_chip mmc_spi_chip_info = {
198 .enable_dma = 0, 197 .enable_dma = 0,
199}; 198};
200#endif 199#endif
201 200
202#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 201#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
203static const struct ad7877_platform_data bfin_ad7877_ts_info = { 202static const struct ad7877_platform_data bfin_ad7877_ts_info = {
204 .model = 7877, 203 .model = 7877,
205 .vref_delay_usecs = 50, /* internal, no capacitor */ 204 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -216,8 +215,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
216#endif 215#endif
217 216
218static struct spi_board_info bfin_spi_board_info[] __initdata = { 217static struct spi_board_info bfin_spi_board_info[] __initdata = {
219#if defined(CONFIG_MTD_M25P80) \ 218#if IS_ENABLED(CONFIG_MTD_M25P80)
220 || defined(CONFIG_MTD_M25P80_MODULE)
221 { 219 {
222 /* the modalias must be the same as spi device driver name */ 220 /* the modalias must be the same as spi device driver name */
223 .modalias = "m25p80", /* Name of spi_driver for this device */ 221 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -230,9 +228,8 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
230 }, 228 },
231#endif 229#endif
232 230
233#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 231#if IS_ENABLED(CONFIG_BFIN_MAC)
234#if defined(CONFIG_NET_DSA_KSZ8893M) \ 232#if IS_ENABLED(CONFIG_NET_DSA_KSZ8893M)
235 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
236 { 233 {
237 .modalias = "ksz8893m", 234 .modalias = "ksz8893m",
238 .max_speed_hz = 5000000, 235 .max_speed_hz = 5000000,
@@ -244,7 +241,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
244#endif 241#endif
245#endif 242#endif
246 243
247#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 244#if IS_ENABLED(CONFIG_MMC_SPI)
248 { 245 {
249 .modalias = "mmc_spi", 246 .modalias = "mmc_spi",
250 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ 247 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
@@ -254,7 +251,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
254 .mode = SPI_MODE_3, 251 .mode = SPI_MODE_3,
255 }, 252 },
256#endif 253#endif
257#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 254#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
258 { 255 {
259 .modalias = "ad7877", 256 .modalias = "ad7877",
260 .platform_data = &bfin_ad7877_ts_info, 257 .platform_data = &bfin_ad7877_ts_info,
@@ -264,7 +261,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
264 .chip_select = 2, 261 .chip_select = 2,
265 }, 262 },
266#endif 263#endif
267#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \ 264#if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
268 && defined(CONFIG_SND_SOC_WM8731_SPI) 265 && defined(CONFIG_SND_SOC_WM8731_SPI)
269 { 266 {
270 .modalias = "wm8731", 267 .modalias = "wm8731",
@@ -274,7 +271,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
274 .mode = SPI_MODE_0, 271 .mode = SPI_MODE_0,
275 }, 272 },
276#endif 273#endif
277#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 274#if IS_ENABLED(CONFIG_SPI_SPIDEV)
278 { 275 {
279 .modalias = "spidev", 276 .modalias = "spidev",
280 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 277 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -282,7 +279,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
282 .chip_select = 1, 279 .chip_select = 1,
283 }, 280 },
284#endif 281#endif
285#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 282#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
286 { 283 {
287 .modalias = "bfin-lq035q1-spi", 284 .modalias = "bfin-lq035q1-spi",
288 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 285 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -294,7 +291,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
294}; 291};
295 292
296/* SPI controller data */ 293/* SPI controller data */
297#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 294#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
298/* SPI (0) */ 295/* SPI (0) */
299static struct bfin5xx_spi_master bfin_spi0_info = { 296static struct bfin5xx_spi_master bfin_spi0_info = {
300 .num_chipselect = 6, 297 .num_chipselect = 6,
@@ -366,7 +363,7 @@ static struct platform_device bfin_spi1_device = {
366}; 363};
367#endif /* spi master and devices */ 364#endif /* spi master and devices */
368 365
369#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 366#if IS_ENABLED(CONFIG_SERIAL_BFIN)
370#ifdef CONFIG_SERIAL_BFIN_UART0 367#ifdef CONFIG_SERIAL_BFIN_UART0
371static struct resource bfin_uart0_resources[] = { 368static struct resource bfin_uart0_resources[] = {
372 { 369 {
@@ -465,7 +462,7 @@ static struct platform_device bfin_uart1_device = {
465#endif 462#endif
466#endif 463#endif
467 464
468#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 465#if IS_ENABLED(CONFIG_BFIN_SIR)
469#ifdef CONFIG_BFIN_SIR0 466#ifdef CONFIG_BFIN_SIR0
470static struct resource bfin_sir0_resources[] = { 467static struct resource bfin_sir0_resources[] = {
471 { 468 {
@@ -520,7 +517,7 @@ static struct platform_device bfin_sir1_device = {
520#endif 517#endif
521#endif 518#endif
522 519
523#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 520#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
524static struct platform_device bfin_i2s = { 521static struct platform_device bfin_i2s = {
525 .name = "bfin-i2s", 522 .name = "bfin-i2s",
526 .id = CONFIG_SND_BF5XX_SPORT_NUM, 523 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -528,7 +525,7 @@ static struct platform_device bfin_i2s = {
528}; 525};
529#endif 526#endif
530 527
531#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 528#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
532static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 529static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
533 530
534static struct resource bfin_twi0_resource[] = { 531static struct resource bfin_twi0_resource[] = {
@@ -556,25 +553,25 @@ static struct platform_device i2c_bfin_twi_device = {
556#endif 553#endif
557 554
558static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 555static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
559#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 556#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
560 { 557 {
561 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 558 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
562 }, 559 },
563#endif 560#endif
564#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 561#if IS_ENABLED(CONFIG_INPUT_PCF8574)
565 { 562 {
566 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 563 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
567 .irq = IRQ_PF8, 564 .irq = IRQ_PF8,
568 }, 565 },
569#endif 566#endif
570#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 567#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
571 { 568 {
572 I2C_BOARD_INFO("ssm2602", 0x1b), 569 I2C_BOARD_INFO("ssm2602", 0x1b),
573 }, 570 },
574#endif 571#endif
575}; 572};
576 573
577#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 574#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
578#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 575#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
579static struct resource bfin_sport0_uart_resources[] = { 576static struct resource bfin_sport0_uart_resources[] = {
580 { 577 {
@@ -645,7 +642,7 @@ static struct platform_device bfin_sport1_uart_device = {
645#endif 642#endif
646#endif 643#endif
647 644
648#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 645#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
649#include <linux/input.h> 646#include <linux/input.h>
650#include <linux/gpio_keys.h> 647#include <linux/gpio_keys.h>
651 648
@@ -667,7 +664,7 @@ static struct platform_device bfin_device_gpiokeys = {
667}; 664};
668#endif 665#endif
669 666
670#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 667#if IS_ENABLED(CONFIG_SDH_BFIN)
671 668
672static struct bfin_sd_host bfin_sdh_data = { 669static struct bfin_sd_host bfin_sdh_data = {
673 .dma_chan = CH_RSI, 670 .dma_chan = CH_RSI,
@@ -710,24 +707,24 @@ static struct platform_device *stamp_devices[] __initdata = {
710 707
711 &bfin_dpmc, 708 &bfin_dpmc,
712 709
713#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 710#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
714 &rtc_device, 711 &rtc_device,
715#endif 712#endif
716 713
717#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 714#if IS_ENABLED(CONFIG_BFIN_MAC)
718 &bfin_mii_bus, 715 &bfin_mii_bus,
719 &bfin_mac_device, 716 &bfin_mac_device,
720#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE) 717#if IS_ENABLED(CONFIG_NET_DSA_KSZ8893M)
721 &ksz8893m_switch_device, 718 &ksz8893m_switch_device,
722#endif 719#endif
723#endif 720#endif
724 721
725#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 722#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
726 &bfin_spi0_device, 723 &bfin_spi0_device,
727 &bfin_spi1_device, 724 &bfin_spi1_device,
728#endif 725#endif
729 726
730#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 727#if IS_ENABLED(CONFIG_SERIAL_BFIN)
731#ifdef CONFIG_SERIAL_BFIN_UART0 728#ifdef CONFIG_SERIAL_BFIN_UART0
732 &bfin_uart0_device, 729 &bfin_uart0_device,
733#endif 730#endif
@@ -736,7 +733,7 @@ static struct platform_device *stamp_devices[] __initdata = {
736#endif 733#endif
737#endif 734#endif
738 735
739#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 736#if IS_ENABLED(CONFIG_BFIN_SIR)
740#ifdef CONFIG_BFIN_SIR0 737#ifdef CONFIG_BFIN_SIR0
741 &bfin_sir0_device, 738 &bfin_sir0_device,
742#endif 739#endif
@@ -745,15 +742,15 @@ static struct platform_device *stamp_devices[] __initdata = {
745#endif 742#endif
746#endif 743#endif
747 744
748#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 745#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
749 &i2c_bfin_twi_device, 746 &i2c_bfin_twi_device,
750#endif 747#endif
751 748
752#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 749#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
753 &bfin_i2s, 750 &bfin_i2s,
754#endif 751#endif
755 752
756#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 753#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
757#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 754#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
758 &bfin_sport0_uart_device, 755 &bfin_sport0_uart_device,
759#endif 756#endif
@@ -762,15 +759,15 @@ static struct platform_device *stamp_devices[] __initdata = {
762#endif 759#endif
763#endif 760#endif
764 761
765#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 762#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
766 &bfin_device_gpiokeys, 763 &bfin_device_gpiokeys,
767#endif 764#endif
768 765
769#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 766#if IS_ENABLED(CONFIG_SDH_BFIN)
770 &bf51x_sdh_device, 767 &bf51x_sdh_device,
771#endif 768#endif
772 769
773#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 770#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
774 &ezbrd_flash_device, 771 &ezbrd_flash_device,
775#endif 772#endif
776}; 773};
@@ -784,7 +781,7 @@ static int __init ezbrd_init(void)
784 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 781 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
785 /* setup BF518-EZBRD GPIO pin PG11 to AMS2, PG15 to AMS3. */ 782 /* setup BF518-EZBRD GPIO pin PG11 to AMS2, PG15 to AMS3. */
786 peripheral_request(P_AMS2, "ParaFlash"); 783 peripheral_request(P_AMS2, "ParaFlash");
787#if !defined(CONFIG_SPI_BFIN5XX) && !defined(CONFIG_SPI_BFIN5XX_MODULE) 784#if !IS_ENABLED(CONFIG_SPI_BFIN5XX)
788 peripheral_request(P_AMS3, "ParaFlash"); 785 peripheral_request(P_AMS3, "ParaFlash");
789#endif 786#endif
790 return 0; 787 return 0;
diff --git a/arch/blackfin/mach-bf518/boards/tcm-bf518.c b/arch/blackfin/mach-bf518/boards/tcm-bf518.c
index 0bedc737566b..240d5cb1f02c 100644
--- a/arch/blackfin/mach-bf518/boards/tcm-bf518.c
+++ b/arch/blackfin/mach-bf518/boards/tcm-bf518.c
@@ -36,7 +36,7 @@ const char bfin_board_name[] = "Bluetechnix TCM-BF518";
36 * Driver needs to know address, irq and flag pin. 36 * Driver needs to know address, irq and flag pin.
37 */ 37 */
38 38
39#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 39#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
40static struct mtd_partition tcm_partitions[] = { 40static struct mtd_partition tcm_partitions[] = {
41 { 41 {
42 .name = "bootloader(nor)", 42 .name = "bootloader(nor)",
@@ -73,14 +73,14 @@ static struct platform_device tcm_flash_device = {
73}; 73};
74#endif 74#endif
75 75
76#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 76#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
77static struct platform_device rtc_device = { 77static struct platform_device rtc_device = {
78 .name = "rtc-bfin", 78 .name = "rtc-bfin",
79 .id = -1, 79 .id = -1,
80}; 80};
81#endif 81#endif
82 82
83#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 83#if IS_ENABLED(CONFIG_BFIN_MAC)
84#include <linux/bfin_mac.h> 84#include <linux/bfin_mac.h>
85static const unsigned short bfin_mac_peripherals[] = P_MII0; 85static const unsigned short bfin_mac_peripherals[] = P_MII0;
86 86
@@ -113,8 +113,7 @@ static struct platform_device bfin_mac_device = {
113}; 113};
114#endif 114#endif
115 115
116#if defined(CONFIG_MTD_M25P80) \ 116#if IS_ENABLED(CONFIG_MTD_M25P80)
117 || defined(CONFIG_MTD_M25P80_MODULE)
118static struct mtd_partition bfin_spi_flash_partitions[] = { 117static struct mtd_partition bfin_spi_flash_partitions[] = {
119 { 118 {
120 .name = "bootloader(spi)", 119 .name = "bootloader(spi)",
@@ -141,13 +140,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
141}; 140};
142#endif 141#endif
143 142
144#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 143#if IS_ENABLED(CONFIG_MMC_SPI)
145static struct bfin5xx_spi_chip mmc_spi_chip_info = { 144static struct bfin5xx_spi_chip mmc_spi_chip_info = {
146 .enable_dma = 0, 145 .enable_dma = 0,
147}; 146};
148#endif 147#endif
149 148
150#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 149#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
151static const struct ad7877_platform_data bfin_ad7877_ts_info = { 150static const struct ad7877_platform_data bfin_ad7877_ts_info = {
152 .model = 7877, 151 .model = 7877,
153 .vref_delay_usecs = 50, /* internal, no capacitor */ 152 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -164,8 +163,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
164#endif 163#endif
165 164
166static struct spi_board_info bfin_spi_board_info[] __initdata = { 165static struct spi_board_info bfin_spi_board_info[] __initdata = {
167#if defined(CONFIG_MTD_M25P80) \ 166#if IS_ENABLED(CONFIG_MTD_M25P80)
168 || defined(CONFIG_MTD_M25P80_MODULE)
169 { 167 {
170 /* the modalias must be the same as spi device driver name */ 168 /* the modalias must be the same as spi device driver name */
171 .modalias = "m25p80", /* Name of spi_driver for this device */ 169 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -178,7 +176,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
178 }, 176 },
179#endif 177#endif
180 178
181#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 179#if IS_ENABLED(CONFIG_MMC_SPI)
182 { 180 {
183 .modalias = "mmc_spi", 181 .modalias = "mmc_spi",
184 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 182 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -188,7 +186,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
188 .mode = SPI_MODE_3, 186 .mode = SPI_MODE_3,
189 }, 187 },
190#endif 188#endif
191#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 189#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
192 { 190 {
193 .modalias = "ad7877", 191 .modalias = "ad7877",
194 .platform_data = &bfin_ad7877_ts_info, 192 .platform_data = &bfin_ad7877_ts_info,
@@ -198,7 +196,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
198 .chip_select = 2, 196 .chip_select = 2,
199 }, 197 },
200#endif 198#endif
201#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \ 199#if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
202 && defined(CONFIG_SND_SOC_WM8731_SPI) 200 && defined(CONFIG_SND_SOC_WM8731_SPI)
203 { 201 {
204 .modalias = "wm8731", 202 .modalias = "wm8731",
@@ -208,7 +206,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
208 .mode = SPI_MODE_0, 206 .mode = SPI_MODE_0,
209 }, 207 },
210#endif 208#endif
211#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 209#if IS_ENABLED(CONFIG_SPI_SPIDEV)
212 { 210 {
213 .modalias = "spidev", 211 .modalias = "spidev",
214 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 212 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -216,7 +214,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
216 .chip_select = 1, 214 .chip_select = 1,
217 }, 215 },
218#endif 216#endif
219#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 217#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
220 { 218 {
221 .modalias = "bfin-lq035q1-spi", 219 .modalias = "bfin-lq035q1-spi",
222 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 220 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -228,7 +226,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
228}; 226};
229 227
230/* SPI controller data */ 228/* SPI controller data */
231#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 229#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
232/* SPI (0) */ 230/* SPI (0) */
233static struct bfin5xx_spi_master bfin_spi0_info = { 231static struct bfin5xx_spi_master bfin_spi0_info = {
234 .num_chipselect = 6, 232 .num_chipselect = 6,
@@ -300,7 +298,7 @@ static struct platform_device bfin_spi1_device = {
300}; 298};
301#endif /* spi master and devices */ 299#endif /* spi master and devices */
302 300
303#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 301#if IS_ENABLED(CONFIG_SERIAL_BFIN)
304#ifdef CONFIG_SERIAL_BFIN_UART0 302#ifdef CONFIG_SERIAL_BFIN_UART0
305static struct resource bfin_uart0_resources[] = { 303static struct resource bfin_uart0_resources[] = {
306 { 304 {
@@ -399,7 +397,7 @@ static struct platform_device bfin_uart1_device = {
399#endif 397#endif
400#endif 398#endif
401 399
402#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 400#if IS_ENABLED(CONFIG_BFIN_SIR)
403#ifdef CONFIG_BFIN_SIR0 401#ifdef CONFIG_BFIN_SIR0
404static struct resource bfin_sir0_resources[] = { 402static struct resource bfin_sir0_resources[] = {
405 { 403 {
@@ -454,7 +452,7 @@ static struct platform_device bfin_sir1_device = {
454#endif 452#endif
455#endif 453#endif
456 454
457#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 455#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
458static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 456static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
459 457
460static struct resource bfin_twi0_resource[] = { 458static struct resource bfin_twi0_resource[] = {
@@ -482,12 +480,12 @@ static struct platform_device i2c_bfin_twi_device = {
482#endif 480#endif
483 481
484static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 482static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
485#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 483#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
486 { 484 {
487 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 485 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
488 }, 486 },
489#endif 487#endif
490#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 488#if IS_ENABLED(CONFIG_INPUT_PCF8574)
491 { 489 {
492 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 490 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
493 .irq = IRQ_PF8, 491 .irq = IRQ_PF8,
@@ -495,7 +493,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
495#endif 493#endif
496}; 494};
497 495
498#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 496#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
499#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 497#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
500static struct resource bfin_sport0_uart_resources[] = { 498static struct resource bfin_sport0_uart_resources[] = {
501 { 499 {
@@ -566,7 +564,7 @@ static struct platform_device bfin_sport1_uart_device = {
566#endif 564#endif
567#endif 565#endif
568 566
569#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 567#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
570#include <linux/input.h> 568#include <linux/input.h>
571#include <linux/gpio_keys.h> 569#include <linux/gpio_keys.h>
572 570
@@ -588,7 +586,7 @@ static struct platform_device bfin_device_gpiokeys = {
588}; 586};
589#endif 587#endif
590 588
591#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 589#if IS_ENABLED(CONFIG_SDH_BFIN)
592 590
593static struct bfin_sd_host bfin_sdh_data = { 591static struct bfin_sd_host bfin_sdh_data = {
594 .dma_chan = CH_RSI, 592 .dma_chan = CH_RSI,
@@ -631,21 +629,21 @@ static struct platform_device *tcm_devices[] __initdata = {
631 629
632 &bfin_dpmc, 630 &bfin_dpmc,
633 631
634#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 632#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
635 &rtc_device, 633 &rtc_device,
636#endif 634#endif
637 635
638#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 636#if IS_ENABLED(CONFIG_BFIN_MAC)
639 &bfin_mii_bus, 637 &bfin_mii_bus,
640 &bfin_mac_device, 638 &bfin_mac_device,
641#endif 639#endif
642 640
643#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 641#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
644 &bfin_spi0_device, 642 &bfin_spi0_device,
645 &bfin_spi1_device, 643 &bfin_spi1_device,
646#endif 644#endif
647 645
648#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 646#if IS_ENABLED(CONFIG_SERIAL_BFIN)
649#ifdef CONFIG_SERIAL_BFIN_UART0 647#ifdef CONFIG_SERIAL_BFIN_UART0
650 &bfin_uart0_device, 648 &bfin_uart0_device,
651#endif 649#endif
@@ -654,7 +652,7 @@ static struct platform_device *tcm_devices[] __initdata = {
654#endif 652#endif
655#endif 653#endif
656 654
657#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 655#if IS_ENABLED(CONFIG_BFIN_SIR)
658#ifdef CONFIG_BFIN_SIR0 656#ifdef CONFIG_BFIN_SIR0
659 &bfin_sir0_device, 657 &bfin_sir0_device,
660#endif 658#endif
@@ -663,11 +661,11 @@ static struct platform_device *tcm_devices[] __initdata = {
663#endif 661#endif
664#endif 662#endif
665 663
666#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 664#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
667 &i2c_bfin_twi_device, 665 &i2c_bfin_twi_device,
668#endif 666#endif
669 667
670#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 668#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
671#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 669#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
672 &bfin_sport0_uart_device, 670 &bfin_sport0_uart_device,
673#endif 671#endif
@@ -676,15 +674,15 @@ static struct platform_device *tcm_devices[] __initdata = {
676#endif 674#endif
677#endif 675#endif
678 676
679#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 677#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
680 &bfin_device_gpiokeys, 678 &bfin_device_gpiokeys,
681#endif 679#endif
682 680
683#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 681#if IS_ENABLED(CONFIG_SDH_BFIN)
684 &bf51x_sdh_device, 682 &bf51x_sdh_device,
685#endif 683#endif
686 684
687#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 685#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
688 &tcm_flash_device, 686 &tcm_flash_device,
689#endif 687#endif
690}; 688};
diff --git a/arch/blackfin/mach-bf527/boards/ad7160eval.c b/arch/blackfin/mach-bf527/boards/ad7160eval.c
index 1e7be62fccb6..9501bd8d9cd1 100644
--- a/arch/blackfin/mach-bf527/boards/ad7160eval.c
+++ b/arch/blackfin/mach-bf527/boards/ad7160eval.c
@@ -37,7 +37,7 @@ const char bfin_board_name[] = "ADI BF527-AD7160EVAL";
37 * Driver needs to know address, irq and flag pin. 37 * Driver needs to know address, irq and flag pin.
38 */ 38 */
39 39
40#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 40#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
41static struct resource musb_resources[] = { 41static struct resource musb_resources[] = {
42 [0] = { 42 [0] = {
43 .start = 0xffc03800, 43 .start = 0xffc03800,
@@ -97,7 +97,7 @@ static struct platform_device musb_device = {
97}; 97};
98#endif 98#endif
99 99
100#if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE) 100#if IS_ENABLED(CONFIG_FB_BFIN_RA158Z)
101static struct resource bf52x_ra158z_resources[] = { 101static struct resource bf52x_ra158z_resources[] = {
102 { 102 {
103 .start = IRQ_PPI_ERROR, 103 .start = IRQ_PPI_ERROR,
@@ -114,7 +114,7 @@ static struct platform_device bf52x_ra158z_device = {
114}; 114};
115#endif 115#endif
116 116
117#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 117#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
118static struct mtd_partition ad7160eval_partitions[] = { 118static struct mtd_partition ad7160eval_partitions[] = {
119 { 119 {
120 .name = "bootloader(nor)", 120 .name = "bootloader(nor)",
@@ -154,7 +154,7 @@ static struct platform_device ad7160eval_flash_device = {
154}; 154};
155#endif 155#endif
156 156
157#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 157#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
158static struct mtd_partition partition_info[] = { 158static struct mtd_partition partition_info[] = {
159 { 159 {
160 .name = "linux kernel(nand)", 160 .name = "linux kernel(nand)",
@@ -200,14 +200,14 @@ static struct platform_device bf5xx_nand_device = {
200}; 200};
201#endif 201#endif
202 202
203#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 203#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
204static struct platform_device rtc_device = { 204static struct platform_device rtc_device = {
205 .name = "rtc-bfin", 205 .name = "rtc-bfin",
206 .id = -1, 206 .id = -1,
207}; 207};
208#endif 208#endif
209 209
210#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 210#if IS_ENABLED(CONFIG_BFIN_MAC)
211#include <linux/bfin_mac.h> 211#include <linux/bfin_mac.h>
212static const unsigned short bfin_mac_peripherals[] = P_RMII0; 212static const unsigned short bfin_mac_peripherals[] = P_RMII0;
213 213
@@ -241,8 +241,7 @@ static struct platform_device bfin_mac_device = {
241#endif 241#endif
242 242
243 243
244#if defined(CONFIG_MTD_M25P80) \ 244#if IS_ENABLED(CONFIG_MTD_M25P80)
245 || defined(CONFIG_MTD_M25P80_MODULE)
246static struct mtd_partition bfin_spi_flash_partitions[] = { 245static struct mtd_partition bfin_spi_flash_partitions[] = {
247 { 246 {
248 .name = "bootloader(spi)", 247 .name = "bootloader(spi)",
@@ -269,13 +268,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
269}; 268};
270#endif 269#endif
271 270
272#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 271#if IS_ENABLED(CONFIG_MMC_SPI)
273static struct bfin5xx_spi_chip mmc_spi_chip_info = { 272static struct bfin5xx_spi_chip mmc_spi_chip_info = {
274 .enable_dma = 0, 273 .enable_dma = 0,
275}; 274};
276#endif 275#endif
277 276
278#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 277#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
279static struct platform_device bfin_i2s = { 278static struct platform_device bfin_i2s = {
280 .name = "bfin-i2s", 279 .name = "bfin-i2s",
281 .id = CONFIG_SND_BF5XX_SPORT_NUM, 280 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -284,8 +283,7 @@ static struct platform_device bfin_i2s = {
284#endif 283#endif
285 284
286static struct spi_board_info bfin_spi_board_info[] __initdata = { 285static struct spi_board_info bfin_spi_board_info[] __initdata = {
287#if defined(CONFIG_MTD_M25P80) \ 286#if IS_ENABLED(CONFIG_MTD_M25P80)
288 || defined(CONFIG_MTD_M25P80_MODULE)
289 { 287 {
290 /* the modalias must be the same as spi device driver name */ 288 /* the modalias must be the same as spi device driver name */
291 .modalias = "m25p80", /* Name of spi_driver for this device */ 289 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -297,8 +295,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
297 .mode = SPI_MODE_3, 295 .mode = SPI_MODE_3,
298 }, 296 },
299#endif 297#endif
300#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 298#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
301 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
302 { 299 {
303 .modalias = "ad183x", 300 .modalias = "ad183x",
304 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 301 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -306,7 +303,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
306 .chip_select = 4, 303 .chip_select = 4,
307 }, 304 },
308#endif 305#endif
309#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 306#if IS_ENABLED(CONFIG_MMC_SPI)
310 { 307 {
311 .modalias = "mmc_spi", 308 .modalias = "mmc_spi",
312 .max_speed_hz = 30000000, /* max spi clock (SCK) speed in HZ */ 309 .max_speed_hz = 30000000, /* max spi clock (SCK) speed in HZ */
@@ -316,7 +313,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
316 .mode = SPI_MODE_3, 313 .mode = SPI_MODE_3,
317 }, 314 },
318#endif 315#endif
319#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 316#if IS_ENABLED(CONFIG_SPI_SPIDEV)
320 { 317 {
321 .modalias = "spidev", 318 .modalias = "spidev",
322 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 319 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -326,7 +323,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
326#endif 323#endif
327}; 324};
328 325
329#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 326#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
330/* SPI controller data */ 327/* SPI controller data */
331static struct bfin5xx_spi_master bfin_spi0_info = { 328static struct bfin5xx_spi_master bfin_spi0_info = {
332 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, 329 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
@@ -364,7 +361,7 @@ static struct platform_device bfin_spi0_device = {
364}; 361};
365#endif /* spi master and devices */ 362#endif /* spi master and devices */
366 363
367#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 364#if IS_ENABLED(CONFIG_SERIAL_BFIN)
368#ifdef CONFIG_SERIAL_BFIN_UART0 365#ifdef CONFIG_SERIAL_BFIN_UART0
369static struct resource bfin_uart0_resources[] = { 366static struct resource bfin_uart0_resources[] = {
370 { 367 {
@@ -475,7 +472,7 @@ static struct platform_device bfin_uart1_device = {
475#endif 472#endif
476#endif 473#endif
477 474
478#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 475#if IS_ENABLED(CONFIG_BFIN_SIR)
479#ifdef CONFIG_BFIN_SIR0 476#ifdef CONFIG_BFIN_SIR0
480static struct resource bfin_sir0_resources[] = { 477static struct resource bfin_sir0_resources[] = {
481 { 478 {
@@ -530,7 +527,7 @@ static struct platform_device bfin_sir1_device = {
530#endif 527#endif
531#endif 528#endif
532 529
533#if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE) 530#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7160)
534#include <linux/input/ad7160.h> 531#include <linux/input/ad7160.h>
535static const struct ad7160_platform_data bfin_ad7160_ts_info = { 532static const struct ad7160_platform_data bfin_ad7160_ts_info = {
536 .sensor_x_res = 854, 533 .sensor_x_res = 854,
@@ -560,7 +557,7 @@ static const struct ad7160_platform_data bfin_ad7160_ts_info = {
560}; 557};
561#endif 558#endif
562 559
563#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 560#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
564static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 561static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
565 562
566static struct resource bfin_twi0_resource[] = { 563static struct resource bfin_twi0_resource[] = {
@@ -588,7 +585,7 @@ static struct platform_device i2c_bfin_twi_device = {
588#endif 585#endif
589 586
590static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 587static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
591#if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE) 588#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7160)
592 { 589 {
593 I2C_BOARD_INFO("ad7160", 0x33), 590 I2C_BOARD_INFO("ad7160", 0x33),
594 .irq = IRQ_PH1, 591 .irq = IRQ_PH1,
@@ -597,7 +594,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
597#endif 594#endif
598}; 595};
599 596
600#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 597#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
601#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 598#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
602static struct resource bfin_sport0_uart_resources[] = { 599static struct resource bfin_sport0_uart_resources[] = {
603 { 600 {
@@ -668,7 +665,7 @@ static struct platform_device bfin_sport1_uart_device = {
668#endif 665#endif
669#endif 666#endif
670 667
671#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 668#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
672#include <asm/bfin_rotary.h> 669#include <asm/bfin_rotary.h>
673 670
674static struct bfin_rotary_platform_data bfin_rotary_data = { 671static struct bfin_rotary_platform_data bfin_rotary_data = {
@@ -725,28 +722,28 @@ static struct platform_device *stamp_devices[] __initdata = {
725 722
726 &bfin_dpmc, 723 &bfin_dpmc,
727 724
728#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 725#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
729 &bf5xx_nand_device, 726 &bf5xx_nand_device,
730#endif 727#endif
731 728
732#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 729#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
733 &rtc_device, 730 &rtc_device,
734#endif 731#endif
735 732
736#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 733#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
737 &musb_device, 734 &musb_device,
738#endif 735#endif
739 736
740#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 737#if IS_ENABLED(CONFIG_BFIN_MAC)
741 &bfin_mii_bus, 738 &bfin_mii_bus,
742 &bfin_mac_device, 739 &bfin_mac_device,
743#endif 740#endif
744 741
745#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 742#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
746 &bfin_spi0_device, 743 &bfin_spi0_device,
747#endif 744#endif
748 745
749#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 746#if IS_ENABLED(CONFIG_SERIAL_BFIN)
750#ifdef CONFIG_SERIAL_BFIN_UART0 747#ifdef CONFIG_SERIAL_BFIN_UART0
751 &bfin_uart0_device, 748 &bfin_uart0_device,
752#endif 749#endif
@@ -755,11 +752,11 @@ static struct platform_device *stamp_devices[] __initdata = {
755#endif 752#endif
756#endif 753#endif
757 754
758#if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE) 755#if IS_ENABLED(CONFIG_FB_BFIN_RA158Z)
759 &bf52x_ra158z_device, 756 &bf52x_ra158z_device,
760#endif 757#endif
761 758
762#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 759#if IS_ENABLED(CONFIG_BFIN_SIR)
763#ifdef CONFIG_BFIN_SIR0 760#ifdef CONFIG_BFIN_SIR0
764 &bfin_sir0_device, 761 &bfin_sir0_device,
765#endif 762#endif
@@ -768,11 +765,11 @@ static struct platform_device *stamp_devices[] __initdata = {
768#endif 765#endif
769#endif 766#endif
770 767
771#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 768#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
772 &i2c_bfin_twi_device, 769 &i2c_bfin_twi_device,
773#endif 770#endif
774 771
775#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 772#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
776#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 773#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
777 &bfin_sport0_uart_device, 774 &bfin_sport0_uart_device,
778#endif 775#endif
@@ -781,15 +778,15 @@ static struct platform_device *stamp_devices[] __initdata = {
781#endif 778#endif
782#endif 779#endif
783 780
784#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 781#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
785 &bfin_rotary_device, 782 &bfin_rotary_device,
786#endif 783#endif
787 784
788#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 785#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
789 &ad7160eval_flash_device, 786 &ad7160eval_flash_device,
790#endif 787#endif
791 788
792#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 789#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
793 &bfin_i2s, 790 &bfin_i2s,
794#endif 791#endif
795}; 792};
diff --git a/arch/blackfin/mach-bf527/boards/cm_bf527.c b/arch/blackfin/mach-bf527/boards/cm_bf527.c
index 413d0132b66f..b1004b35db36 100644
--- a/arch/blackfin/mach-bf527/boards/cm_bf527.c
+++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c
@@ -37,7 +37,7 @@ const char bfin_board_name[] = "Bluetechnix CM-BF527";
37 * Driver needs to know address, irq and flag pin. 37 * Driver needs to know address, irq and flag pin.
38 */ 38 */
39 39
40#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 40#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
41#include <linux/usb/isp1760.h> 41#include <linux/usb/isp1760.h>
42static struct resource bfin_isp1760_resources[] = { 42static struct resource bfin_isp1760_resources[] = {
43 [0] = { 43 [0] = {
@@ -72,7 +72,7 @@ static struct platform_device bfin_isp1760_device = {
72}; 72};
73#endif 73#endif
74 74
75#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 75#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
76static struct resource musb_resources[] = { 76static struct resource musb_resources[] = {
77 [0] = { 77 [0] = {
78 .start = 0xffc03800, 78 .start = 0xffc03800,
@@ -134,7 +134,7 @@ static struct platform_device musb_device = {
134}; 134};
135#endif 135#endif
136 136
137#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 137#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
138static struct mtd_partition partition_info[] = { 138static struct mtd_partition partition_info[] = {
139 { 139 {
140 .name = "linux kernel(nand)", 140 .name = "linux kernel(nand)",
@@ -180,7 +180,7 @@ static struct platform_device bf5xx_nand_device = {
180}; 180};
181#endif 181#endif
182 182
183#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 183#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
184static struct resource bfin_pcmcia_cf_resources[] = { 184static struct resource bfin_pcmcia_cf_resources[] = {
185 { 185 {
186 .start = 0x20310000, /* IO PORT */ 186 .start = 0x20310000, /* IO PORT */
@@ -209,14 +209,14 @@ static struct platform_device bfin_pcmcia_cf_device = {
209}; 209};
210#endif 210#endif
211 211
212#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 212#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
213static struct platform_device rtc_device = { 213static struct platform_device rtc_device = {
214 .name = "rtc-bfin", 214 .name = "rtc-bfin",
215 .id = -1, 215 .id = -1,
216}; 216};
217#endif 217#endif
218 218
219#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 219#if IS_ENABLED(CONFIG_SMC91X)
220#include <linux/smc91x.h> 220#include <linux/smc91x.h>
221 221
222static struct smc91x_platdata smc91x_info = { 222static struct smc91x_platdata smc91x_info = {
@@ -249,7 +249,7 @@ static struct platform_device smc91x_device = {
249}; 249};
250#endif 250#endif
251 251
252#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 252#if IS_ENABLED(CONFIG_DM9000)
253static struct resource dm9000_resources[] = { 253static struct resource dm9000_resources[] = {
254 [0] = { 254 [0] = {
255 .start = 0x203FB800, 255 .start = 0x203FB800,
@@ -276,7 +276,7 @@ static struct platform_device dm9000_device = {
276}; 276};
277#endif 277#endif
278 278
279#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 279#if IS_ENABLED(CONFIG_BFIN_MAC)
280#include <linux/bfin_mac.h> 280#include <linux/bfin_mac.h>
281static const unsigned short bfin_mac_peripherals[] = P_RMII0; 281static const unsigned short bfin_mac_peripherals[] = P_RMII0;
282 282
@@ -309,7 +309,7 @@ static struct platform_device bfin_mac_device = {
309}; 309};
310#endif 310#endif
311 311
312#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 312#if IS_ENABLED(CONFIG_USB_NET2272)
313static struct resource net2272_bfin_resources[] = { 313static struct resource net2272_bfin_resources[] = {
314 { 314 {
315 .start = 0x20300000, 315 .start = 0x20300000,
@@ -330,8 +330,7 @@ static struct platform_device net2272_bfin_device = {
330}; 330};
331#endif 331#endif
332 332
333#if defined(CONFIG_MTD_M25P80) \ 333#if IS_ENABLED(CONFIG_MTD_M25P80)
334 || defined(CONFIG_MTD_M25P80_MODULE)
335static struct mtd_partition bfin_spi_flash_partitions[] = { 334static struct mtd_partition bfin_spi_flash_partitions[] = {
336 { 335 {
337 .name = "bootloader(spi)", 336 .name = "bootloader(spi)",
@@ -358,13 +357,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
358}; 357};
359#endif 358#endif
360 359
361#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 360#if IS_ENABLED(CONFIG_MMC_SPI)
362static struct bfin5xx_spi_chip mmc_spi_chip_info = { 361static struct bfin5xx_spi_chip mmc_spi_chip_info = {
363 .enable_dma = 0, 362 .enable_dma = 0,
364}; 363};
365#endif 364#endif
366 365
367#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 366#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
368static const struct ad7877_platform_data bfin_ad7877_ts_info = { 367static const struct ad7877_platform_data bfin_ad7877_ts_info = {
369 .model = 7877, 368 .model = 7877,
370 .vref_delay_usecs = 50, /* internal, no capacitor */ 369 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -381,8 +380,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
381#endif 380#endif
382 381
383static struct spi_board_info bfin_spi_board_info[] __initdata = { 382static struct spi_board_info bfin_spi_board_info[] __initdata = {
384#if defined(CONFIG_MTD_M25P80) \ 383#if IS_ENABLED(CONFIG_MTD_M25P80)
385 || defined(CONFIG_MTD_M25P80_MODULE)
386 { 384 {
387 /* the modalias must be the same as spi device driver name */ 385 /* the modalias must be the same as spi device driver name */
388 .modalias = "m25p80", /* Name of spi_driver for this device */ 386 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -395,8 +393,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
395 }, 393 },
396#endif 394#endif
397 395
398#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 396#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
399 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
400 { 397 {
401 .modalias = "ad183x", 398 .modalias = "ad183x",
402 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 399 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -404,7 +401,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
404 .chip_select = 4, 401 .chip_select = 4,
405 }, 402 },
406#endif 403#endif
407#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 404#if IS_ENABLED(CONFIG_MMC_SPI)
408 { 405 {
409 .modalias = "mmc_spi", 406 .modalias = "mmc_spi",
410 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 407 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -414,7 +411,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
414 .mode = SPI_MODE_3, 411 .mode = SPI_MODE_3,
415 }, 412 },
416#endif 413#endif
417#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 414#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
418 { 415 {
419 .modalias = "ad7877", 416 .modalias = "ad7877",
420 .platform_data = &bfin_ad7877_ts_info, 417 .platform_data = &bfin_ad7877_ts_info,
@@ -424,7 +421,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
424 .chip_select = 2, 421 .chip_select = 2,
425 }, 422 },
426#endif 423#endif
427#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \ 424#if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
428 && defined(CONFIG_SND_SOC_WM8731_SPI) 425 && defined(CONFIG_SND_SOC_WM8731_SPI)
429 { 426 {
430 .modalias = "wm8731", 427 .modalias = "wm8731",
@@ -434,7 +431,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
434 .mode = SPI_MODE_0, 431 .mode = SPI_MODE_0,
435 }, 432 },
436#endif 433#endif
437#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 434#if IS_ENABLED(CONFIG_SPI_SPIDEV)
438 { 435 {
439 .modalias = "spidev", 436 .modalias = "spidev",
440 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 437 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -444,7 +441,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
444#endif 441#endif
445}; 442};
446 443
447#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 444#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
448/* SPI controller data */ 445/* SPI controller data */
449static struct bfin5xx_spi_master bfin_spi0_info = { 446static struct bfin5xx_spi_master bfin_spi0_info = {
450 .num_chipselect = 8, 447 .num_chipselect = 8,
@@ -482,7 +479,7 @@ static struct platform_device bfin_spi0_device = {
482}; 479};
483#endif /* spi master and devices */ 480#endif /* spi master and devices */
484 481
485#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 482#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
486static struct mtd_partition cm_partitions[] = { 483static struct mtd_partition cm_partitions[] = {
487 { 484 {
488 .name = "bootloader(nor)", 485 .name = "bootloader(nor)",
@@ -531,7 +528,7 @@ static struct platform_device cm_flash_device = {
531}; 528};
532#endif 529#endif
533 530
534#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 531#if IS_ENABLED(CONFIG_SERIAL_BFIN)
535#ifdef CONFIG_SERIAL_BFIN_UART0 532#ifdef CONFIG_SERIAL_BFIN_UART0
536static struct resource bfin_uart0_resources[] = { 533static struct resource bfin_uart0_resources[] = {
537 { 534 {
@@ -642,7 +639,7 @@ static struct platform_device bfin_uart1_device = {
642#endif 639#endif
643#endif 640#endif
644 641
645#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 642#if IS_ENABLED(CONFIG_BFIN_SIR)
646#ifdef CONFIG_BFIN_SIR0 643#ifdef CONFIG_BFIN_SIR0
647static struct resource bfin_sir0_resources[] = { 644static struct resource bfin_sir0_resources[] = {
648 { 645 {
@@ -697,7 +694,7 @@ static struct platform_device bfin_sir1_device = {
697#endif 694#endif
698#endif 695#endif
699 696
700#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 697#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
701static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 698static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
702 699
703static struct resource bfin_twi0_resource[] = { 700static struct resource bfin_twi0_resource[] = {
@@ -725,25 +722,25 @@ static struct platform_device i2c_bfin_twi_device = {
725#endif 722#endif
726 723
727static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 724static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
728#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 725#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
729 { 726 {
730 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 727 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
731 }, 728 },
732#endif 729#endif
733#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 730#if IS_ENABLED(CONFIG_INPUT_PCF8574)
734 { 731 {
735 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 732 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
736 .irq = IRQ_PF8, 733 .irq = IRQ_PF8,
737 }, 734 },
738#endif 735#endif
739#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 736#if IS_ENABLED(CONFIG_FB_BFIN_7393)
740 { 737 {
741 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 738 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
742 }, 739 },
743#endif 740#endif
744}; 741};
745 742
746#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 743#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
747#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 744#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
748static struct resource bfin_sport0_uart_resources[] = { 745static struct resource bfin_sport0_uart_resources[] = {
749 { 746 {
@@ -814,7 +811,7 @@ static struct platform_device bfin_sport1_uart_device = {
814#endif 811#endif
815#endif 812#endif
816 813
817#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 814#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
818#include <linux/input.h> 815#include <linux/input.h>
819#include <linux/gpio_keys.h> 816#include <linux/gpio_keys.h>
820 817
@@ -861,48 +858,48 @@ static struct platform_device *cmbf527_devices[] __initdata = {
861 858
862 &bfin_dpmc, 859 &bfin_dpmc,
863 860
864#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 861#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
865 &bf5xx_nand_device, 862 &bf5xx_nand_device,
866#endif 863#endif
867 864
868#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 865#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
869 &bfin_pcmcia_cf_device, 866 &bfin_pcmcia_cf_device,
870#endif 867#endif
871 868
872#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 869#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
873 &rtc_device, 870 &rtc_device,
874#endif 871#endif
875 872
876#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 873#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
877 &bfin_isp1760_device, 874 &bfin_isp1760_device,
878#endif 875#endif
879 876
880#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 877#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
881 &musb_device, 878 &musb_device,
882#endif 879#endif
883 880
884#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 881#if IS_ENABLED(CONFIG_SMC91X)
885 &smc91x_device, 882 &smc91x_device,
886#endif 883#endif
887 884
888#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 885#if IS_ENABLED(CONFIG_DM9000)
889 &dm9000_device, 886 &dm9000_device,
890#endif 887#endif
891 888
892#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 889#if IS_ENABLED(CONFIG_BFIN_MAC)
893 &bfin_mii_bus, 890 &bfin_mii_bus,
894 &bfin_mac_device, 891 &bfin_mac_device,
895#endif 892#endif
896 893
897#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 894#if IS_ENABLED(CONFIG_USB_NET2272)
898 &net2272_bfin_device, 895 &net2272_bfin_device,
899#endif 896#endif
900 897
901#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 898#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
902 &bfin_spi0_device, 899 &bfin_spi0_device,
903#endif 900#endif
904 901
905#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 902#if IS_ENABLED(CONFIG_SERIAL_BFIN)
906#ifdef CONFIG_SERIAL_BFIN_UART0 903#ifdef CONFIG_SERIAL_BFIN_UART0
907 &bfin_uart0_device, 904 &bfin_uart0_device,
908#endif 905#endif
@@ -911,7 +908,7 @@ static struct platform_device *cmbf527_devices[] __initdata = {
911#endif 908#endif
912#endif 909#endif
913 910
914#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 911#if IS_ENABLED(CONFIG_BFIN_SIR)
915#ifdef CONFIG_BFIN_SIR0 912#ifdef CONFIG_BFIN_SIR0
916 &bfin_sir0_device, 913 &bfin_sir0_device,
917#endif 914#endif
@@ -920,11 +917,11 @@ static struct platform_device *cmbf527_devices[] __initdata = {
920#endif 917#endif
921#endif 918#endif
922 919
923#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 920#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
924 &i2c_bfin_twi_device, 921 &i2c_bfin_twi_device,
925#endif 922#endif
926 923
927#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 924#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
928#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 925#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
929 &bfin_sport0_uart_device, 926 &bfin_sport0_uart_device,
930#endif 927#endif
@@ -933,11 +930,11 @@ static struct platform_device *cmbf527_devices[] __initdata = {
933#endif 930#endif
934#endif 931#endif
935 932
936#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 933#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
937 &bfin_device_gpiokeys, 934 &bfin_device_gpiokeys,
938#endif 935#endif
939 936
940#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 937#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
941 &cm_flash_device, 938 &cm_flash_device,
942#endif 939#endif
943}; 940};
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index 50bda79194e5..a3a572352769 100644
--- a/arch/blackfin/mach-bf527/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf527/boards/ezbrd.c
@@ -36,7 +36,7 @@ const char bfin_board_name[] = "ADI BF526-EZBRD";
36 * Driver needs to know address, irq and flag pin. 36 * Driver needs to know address, irq and flag pin.
37 */ 37 */
38 38
39#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 39#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
40static struct resource musb_resources[] = { 40static struct resource musb_resources[] = {
41 [0] = { 41 [0] = {
42 .start = 0xffc03800, 42 .start = 0xffc03800,
@@ -98,7 +98,7 @@ static struct platform_device musb_device = {
98}; 98};
99#endif 99#endif
100 100
101#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 101#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
102static struct mtd_partition ezbrd_partitions[] = { 102static struct mtd_partition ezbrd_partitions[] = {
103 { 103 {
104 .name = "bootloader(nor)", 104 .name = "bootloader(nor)",
@@ -138,7 +138,7 @@ static struct platform_device ezbrd_flash_device = {
138}; 138};
139#endif 139#endif
140 140
141#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 141#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
142static struct mtd_partition partition_info[] = { 142static struct mtd_partition partition_info[] = {
143 { 143 {
144 .name = "bootloader(nand)", 144 .name = "bootloader(nand)",
@@ -188,7 +188,7 @@ static struct platform_device bf5xx_nand_device = {
188}; 188};
189#endif 189#endif
190 190
191#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 191#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
192static struct platform_device rtc_device = { 192static struct platform_device rtc_device = {
193 .name = "rtc-bfin", 193 .name = "rtc-bfin",
194 .id = -1, 194 .id = -1,
@@ -196,7 +196,7 @@ static struct platform_device rtc_device = {
196#endif 196#endif
197 197
198 198
199#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 199#if IS_ENABLED(CONFIG_BFIN_MAC)
200#include <linux/bfin_mac.h> 200#include <linux/bfin_mac.h>
201static const unsigned short bfin_mac_peripherals[] = P_RMII0; 201static const unsigned short bfin_mac_peripherals[] = P_RMII0;
202 202
@@ -229,8 +229,7 @@ static struct platform_device bfin_mac_device = {
229}; 229};
230#endif 230#endif
231 231
232#if defined(CONFIG_MTD_M25P80) \ 232#if IS_ENABLED(CONFIG_MTD_M25P80)
233 || defined(CONFIG_MTD_M25P80_MODULE)
234static struct mtd_partition bfin_spi_flash_partitions[] = { 233static struct mtd_partition bfin_spi_flash_partitions[] = {
235 { 234 {
236 .name = "bootloader(spi)", 235 .name = "bootloader(spi)",
@@ -257,13 +256,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
257}; 256};
258#endif 257#endif
259 258
260#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 259#if IS_ENABLED(CONFIG_MMC_SPI)
261static struct bfin5xx_spi_chip mmc_spi_chip_info = { 260static struct bfin5xx_spi_chip mmc_spi_chip_info = {
262 .enable_dma = 0, 261 .enable_dma = 0,
263}; 262};
264#endif 263#endif
265 264
266#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 265#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
267static const struct ad7877_platform_data bfin_ad7877_ts_info = { 266static const struct ad7877_platform_data bfin_ad7877_ts_info = {
268 .model = 7877, 267 .model = 7877,
269 .vref_delay_usecs = 50, /* internal, no capacitor */ 268 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -279,7 +278,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
279}; 278};
280#endif 279#endif
281 280
282#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 281#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
283#include <linux/spi/ad7879.h> 282#include <linux/spi/ad7879.h>
284static const struct ad7879_platform_data bfin_ad7879_ts_info = { 283static const struct ad7879_platform_data bfin_ad7879_ts_info = {
285 .model = 7879, /* Model = AD7879 */ 284 .model = 7879, /* Model = AD7879 */
@@ -297,8 +296,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
297#endif 296#endif
298 297
299static struct spi_board_info bfin_spi_board_info[] __initdata = { 298static struct spi_board_info bfin_spi_board_info[] __initdata = {
300#if defined(CONFIG_MTD_M25P80) \ 299#if IS_ENABLED(CONFIG_MTD_M25P80)
301 || defined(CONFIG_MTD_M25P80_MODULE)
302 { 300 {
303 /* the modalias must be the same as spi device driver name */ 301 /* the modalias must be the same as spi device driver name */
304 .modalias = "m25p80", /* Name of spi_driver for this device */ 302 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -311,7 +309,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
311 }, 309 },
312#endif 310#endif
313 311
314#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 312#if IS_ENABLED(CONFIG_MMC_SPI)
315 { 313 {
316 .modalias = "mmc_spi", 314 .modalias = "mmc_spi",
317 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ 315 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
@@ -321,7 +319,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
321 .mode = SPI_MODE_3, 319 .mode = SPI_MODE_3,
322 }, 320 },
323#endif 321#endif
324#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 322#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
325 { 323 {
326 .modalias = "ad7877", 324 .modalias = "ad7877",
327 .platform_data = &bfin_ad7877_ts_info, 325 .platform_data = &bfin_ad7877_ts_info,
@@ -331,7 +329,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
331 .chip_select = 2, 329 .chip_select = 2,
332 }, 330 },
333#endif 331#endif
334#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 332#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
335 { 333 {
336 .modalias = "ad7879", 334 .modalias = "ad7879",
337 .platform_data = &bfin_ad7879_ts_info, 335 .platform_data = &bfin_ad7879_ts_info,
@@ -342,7 +340,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
342 .mode = SPI_CPHA | SPI_CPOL, 340 .mode = SPI_CPHA | SPI_CPOL,
343 }, 341 },
344#endif 342#endif
345#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \ 343#if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
346 && defined(CONFIG_SND_SOC_WM8731_SPI) 344 && defined(CONFIG_SND_SOC_WM8731_SPI)
347 { 345 {
348 .modalias = "wm8731", 346 .modalias = "wm8731",
@@ -352,7 +350,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
352 .mode = SPI_MODE_0, 350 .mode = SPI_MODE_0,
353 }, 351 },
354#endif 352#endif
355#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 353#if IS_ENABLED(CONFIG_SPI_SPIDEV)
356 { 354 {
357 .modalias = "spidev", 355 .modalias = "spidev",
358 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 356 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -360,7 +358,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
360 .chip_select = 1, 358 .chip_select = 1,
361 }, 359 },
362#endif 360#endif
363#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 361#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
364 { 362 {
365 .modalias = "bfin-lq035q1-spi", 363 .modalias = "bfin-lq035q1-spi",
366 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 364 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -371,7 +369,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
371#endif 369#endif
372}; 370};
373 371
374#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 372#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
375/* SPI controller data */ 373/* SPI controller data */
376static struct bfin5xx_spi_master bfin_spi0_info = { 374static struct bfin5xx_spi_master bfin_spi0_info = {
377 .num_chipselect = 8, 375 .num_chipselect = 8,
@@ -409,7 +407,7 @@ static struct platform_device bfin_spi0_device = {
409}; 407};
410#endif /* spi master and devices */ 408#endif /* spi master and devices */
411 409
412#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 410#if IS_ENABLED(CONFIG_SERIAL_BFIN)
413#ifdef CONFIG_SERIAL_BFIN_UART0 411#ifdef CONFIG_SERIAL_BFIN_UART0
414static struct resource bfin_uart0_resources[] = { 412static struct resource bfin_uart0_resources[] = {
415 { 413 {
@@ -520,7 +518,7 @@ static struct platform_device bfin_uart1_device = {
520#endif 518#endif
521#endif 519#endif
522 520
523#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 521#if IS_ENABLED(CONFIG_BFIN_SIR)
524#ifdef CONFIG_BFIN_SIR0 522#ifdef CONFIG_BFIN_SIR0
525static struct resource bfin_sir0_resources[] = { 523static struct resource bfin_sir0_resources[] = {
526 { 524 {
@@ -575,7 +573,7 @@ static struct platform_device bfin_sir1_device = {
575#endif 573#endif
576#endif 574#endif
577 575
578#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 576#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
579static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 577static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
580 578
581static struct resource bfin_twi0_resource[] = { 579static struct resource bfin_twi0_resource[] = {
@@ -603,12 +601,12 @@ static struct platform_device i2c_bfin_twi_device = {
603#endif 601#endif
604 602
605static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 603static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
606#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 604#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
607 { 605 {
608 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 606 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
609 }, 607 },
610#endif 608#endif
611#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 609#if IS_ENABLED(CONFIG_INPUT_PCF8574)
612 { 610 {
613 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 611 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
614 .irq = IRQ_PF8, 612 .irq = IRQ_PF8,
@@ -616,7 +614,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
616#endif 614#endif
617}; 615};
618 616
619#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 617#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
620#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 618#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
621static struct resource bfin_sport0_uart_resources[] = { 619static struct resource bfin_sport0_uart_resources[] = {
622 { 620 {
@@ -687,7 +685,7 @@ static struct platform_device bfin_sport1_uart_device = {
687#endif 685#endif
688#endif 686#endif
689 687
690#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 688#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
691#include <linux/input.h> 689#include <linux/input.h>
692#include <linux/gpio_keys.h> 690#include <linux/gpio_keys.h>
693 691
@@ -731,7 +729,7 @@ static struct platform_device bfin_dpmc = {
731 }, 729 },
732}; 730};
733 731
734#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 732#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
735#include <asm/bfin-lq035q1.h> 733#include <asm/bfin-lq035q1.h>
736 734
737static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = { 735static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
@@ -764,28 +762,28 @@ static struct platform_device *stamp_devices[] __initdata = {
764 762
765 &bfin_dpmc, 763 &bfin_dpmc,
766 764
767#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 765#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
768 &bf5xx_nand_device, 766 &bf5xx_nand_device,
769#endif 767#endif
770 768
771#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 769#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
772 &rtc_device, 770 &rtc_device,
773#endif 771#endif
774 772
775#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 773#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
776 &musb_device, 774 &musb_device,
777#endif 775#endif
778 776
779#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 777#if IS_ENABLED(CONFIG_BFIN_MAC)
780 &bfin_mii_bus, 778 &bfin_mii_bus,
781 &bfin_mac_device, 779 &bfin_mac_device,
782#endif 780#endif
783 781
784#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 782#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
785 &bfin_spi0_device, 783 &bfin_spi0_device,
786#endif 784#endif
787 785
788#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 786#if IS_ENABLED(CONFIG_SERIAL_BFIN)
789#ifdef CONFIG_SERIAL_BFIN_UART0 787#ifdef CONFIG_SERIAL_BFIN_UART0
790 &bfin_uart0_device, 788 &bfin_uart0_device,
791#endif 789#endif
@@ -794,11 +792,11 @@ static struct platform_device *stamp_devices[] __initdata = {
794#endif 792#endif
795#endif 793#endif
796 794
797#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 795#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
798 &bfin_lq035q1_device, 796 &bfin_lq035q1_device,
799#endif 797#endif
800 798
801#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 799#if IS_ENABLED(CONFIG_BFIN_SIR)
802#ifdef CONFIG_BFIN_SIR0 800#ifdef CONFIG_BFIN_SIR0
803 &bfin_sir0_device, 801 &bfin_sir0_device,
804#endif 802#endif
@@ -807,11 +805,11 @@ static struct platform_device *stamp_devices[] __initdata = {
807#endif 805#endif
808#endif 806#endif
809 807
810#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 808#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
811 &i2c_bfin_twi_device, 809 &i2c_bfin_twi_device,
812#endif 810#endif
813 811
814#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 812#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
815#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 813#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
816 &bfin_sport0_uart_device, 814 &bfin_sport0_uart_device,
817#endif 815#endif
@@ -820,11 +818,11 @@ static struct platform_device *stamp_devices[] __initdata = {
820#endif 818#endif
821#endif 819#endif
822 820
823#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 821#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
824 &bfin_device_gpiokeys, 822 &bfin_device_gpiokeys,
825#endif 823#endif
826 824
827#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 825#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
828 &ezbrd_flash_device, 826 &ezbrd_flash_device,
829#endif 827#endif
830}; 828};
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index d0a0c5e527cd..d64f565dc2a0 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -42,7 +42,7 @@ const char bfin_board_name[] = "ADI BF527-EZKIT";
42 * Driver needs to know address, irq and flag pin. 42 * Driver needs to know address, irq and flag pin.
43 */ 43 */
44 44
45#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 45#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
46#include <linux/usb/isp1760.h> 46#include <linux/usb/isp1760.h>
47static struct resource bfin_isp1760_resources[] = { 47static struct resource bfin_isp1760_resources[] = {
48 [0] = { 48 [0] = {
@@ -77,7 +77,7 @@ static struct platform_device bfin_isp1760_device = {
77}; 77};
78#endif 78#endif
79 79
80#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 80#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
81static struct resource musb_resources[] = { 81static struct resource musb_resources[] = {
82 [0] = { 82 [0] = {
83 .start = 0xffc03800, 83 .start = 0xffc03800,
@@ -139,7 +139,7 @@ static struct platform_device musb_device = {
139}; 139};
140#endif 140#endif
141 141
142#if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE) 142#if IS_ENABLED(CONFIG_FB_BFIN_T350MCQB)
143 143
144static struct resource bf52x_t350mcqb_resources[] = { 144static struct resource bf52x_t350mcqb_resources[] = {
145 { 145 {
@@ -157,7 +157,7 @@ static struct platform_device bf52x_t350mcqb_device = {
157}; 157};
158#endif 158#endif
159 159
160#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 160#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
161#include <asm/bfin-lq035q1.h> 161#include <asm/bfin-lq035q1.h>
162 162
163static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = { 163static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
@@ -184,7 +184,7 @@ static struct platform_device bfin_lq035q1_device = {
184}; 184};
185#endif 185#endif
186 186
187#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 187#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
188static struct mtd_partition ezkit_partitions[] = { 188static struct mtd_partition ezkit_partitions[] = {
189 { 189 {
190 .name = "bootloader(nor)", 190 .name = "bootloader(nor)",
@@ -224,7 +224,7 @@ static struct platform_device ezkit_flash_device = {
224}; 224};
225#endif 225#endif
226 226
227#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 227#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
228static struct mtd_partition partition_info[] = { 228static struct mtd_partition partition_info[] = {
229 { 229 {
230 .name = "bootloader(nand)", 230 .name = "bootloader(nand)",
@@ -274,7 +274,7 @@ static struct platform_device bf5xx_nand_device = {
274}; 274};
275#endif 275#endif
276 276
277#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 277#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
278static struct resource bfin_pcmcia_cf_resources[] = { 278static struct resource bfin_pcmcia_cf_resources[] = {
279 { 279 {
280 .start = 0x20310000, /* IO PORT */ 280 .start = 0x20310000, /* IO PORT */
@@ -303,14 +303,14 @@ static struct platform_device bfin_pcmcia_cf_device = {
303}; 303};
304#endif 304#endif
305 305
306#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 306#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
307static struct platform_device rtc_device = { 307static struct platform_device rtc_device = {
308 .name = "rtc-bfin", 308 .name = "rtc-bfin",
309 .id = -1, 309 .id = -1,
310}; 310};
311#endif 311#endif
312 312
313#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 313#if IS_ENABLED(CONFIG_SMC91X)
314#include <linux/smc91x.h> 314#include <linux/smc91x.h>
315 315
316static struct smc91x_platdata smc91x_info = { 316static struct smc91x_platdata smc91x_info = {
@@ -343,7 +343,7 @@ static struct platform_device smc91x_device = {
343}; 343};
344#endif 344#endif
345 345
346#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 346#if IS_ENABLED(CONFIG_DM9000)
347static struct resource dm9000_resources[] = { 347static struct resource dm9000_resources[] = {
348 [0] = { 348 [0] = {
349 .start = 0x203FB800, 349 .start = 0x203FB800,
@@ -370,7 +370,7 @@ static struct platform_device dm9000_device = {
370}; 370};
371#endif 371#endif
372 372
373#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 373#if IS_ENABLED(CONFIG_BFIN_MAC)
374#include <linux/bfin_mac.h> 374#include <linux/bfin_mac.h>
375static const unsigned short bfin_mac_peripherals[] = P_RMII0; 375static const unsigned short bfin_mac_peripherals[] = P_RMII0;
376 376
@@ -403,7 +403,7 @@ static struct platform_device bfin_mac_device = {
403}; 403};
404#endif 404#endif
405 405
406#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 406#if IS_ENABLED(CONFIG_USB_NET2272)
407static struct resource net2272_bfin_resources[] = { 407static struct resource net2272_bfin_resources[] = {
408 { 408 {
409 .start = 0x20300000, 409 .start = 0x20300000,
@@ -427,8 +427,7 @@ static struct platform_device net2272_bfin_device = {
427}; 427};
428#endif 428#endif
429 429
430#if defined(CONFIG_MTD_M25P80) \ 430#if IS_ENABLED(CONFIG_MTD_M25P80)
431 || defined(CONFIG_MTD_M25P80_MODULE)
432static struct mtd_partition bfin_spi_flash_partitions[] = { 431static struct mtd_partition bfin_spi_flash_partitions[] = {
433 { 432 {
434 .name = "bootloader(spi)", 433 .name = "bootloader(spi)",
@@ -455,13 +454,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
455}; 454};
456#endif 455#endif
457 456
458#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 457#if IS_ENABLED(CONFIG_MMC_SPI)
459static struct bfin5xx_spi_chip mmc_spi_chip_info = { 458static struct bfin5xx_spi_chip mmc_spi_chip_info = {
460 .enable_dma = 0, 459 .enable_dma = 0,
461}; 460};
462#endif 461#endif
463 462
464#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 463#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
465static const struct ad7877_platform_data bfin_ad7877_ts_info = { 464static const struct ad7877_platform_data bfin_ad7877_ts_info = {
466 .model = 7877, 465 .model = 7877,
467 .vref_delay_usecs = 50, /* internal, no capacitor */ 466 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -477,7 +476,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
477}; 476};
478#endif 477#endif
479 478
480#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 479#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
481#include <linux/spi/ad7879.h> 480#include <linux/spi/ad7879.h>
482static const struct ad7879_platform_data bfin_ad7879_ts_info = { 481static const struct ad7879_platform_data bfin_ad7879_ts_info = {
483 .model = 7879, /* Model = AD7879 */ 482 .model = 7879, /* Model = AD7879 */
@@ -493,7 +492,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
493}; 492};
494#endif 493#endif
495 494
496#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 495#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
497 496
498static const u16 bfin_snd_pin[][7] = { 497static const u16 bfin_snd_pin[][7] = {
499 {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, 498 {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
@@ -541,21 +540,21 @@ static struct resource bfin_snd_resources[][4] = {
541}; 540};
542#endif 541#endif
543 542
544#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 543#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
545static struct platform_device bfin_i2s_pcm = { 544static struct platform_device bfin_i2s_pcm = {
546 .name = "bfin-i2s-pcm-audio", 545 .name = "bfin-i2s-pcm-audio",
547 .id = -1, 546 .id = -1,
548}; 547};
549#endif 548#endif
550 549
551#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 550#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
552static struct platform_device bfin_ac97_pcm = { 551static struct platform_device bfin_ac97_pcm = {
553 .name = "bfin-ac97-pcm-audio", 552 .name = "bfin-ac97-pcm-audio",
554 .id = -1, 553 .id = -1,
555}; 554};
556#endif 555#endif
557 556
558#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 557#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
559static struct platform_device bfin_i2s = { 558static struct platform_device bfin_i2s = {
560 .name = "bfin-i2s", 559 .name = "bfin-i2s",
561 .id = CONFIG_SND_BF5XX_SPORT_NUM, 560 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -567,8 +566,7 @@ static struct platform_device bfin_i2s = {
567}; 566};
568#endif 567#endif
569 568
570#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 569#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
571 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
572static const char * const ad1836_link[] = { 570static const char * const ad1836_link[] = {
573 "bfin-i2s.0", 571 "bfin-i2s.0",
574 "spi0.4", 572 "spi0.4",
@@ -583,8 +581,7 @@ static struct platform_device bfin_ad1836_machine = {
583#endif 581#endif
584 582
585static struct spi_board_info bfin_spi_board_info[] __initdata = { 583static struct spi_board_info bfin_spi_board_info[] __initdata = {
586#if defined(CONFIG_MTD_M25P80) \ 584#if IS_ENABLED(CONFIG_MTD_M25P80)
587 || defined(CONFIG_MTD_M25P80_MODULE)
588 { 585 {
589 /* the modalias must be the same as spi device driver name */ 586 /* the modalias must be the same as spi device driver name */
590 .modalias = "m25p80", /* Name of spi_driver for this device */ 587 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -597,8 +594,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
597 }, 594 },
598#endif 595#endif
599 596
600#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 597#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
601 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
602 { 598 {
603 .modalias = "ad183x", 599 .modalias = "ad183x",
604 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 600 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -608,7 +604,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
608 .mode = SPI_MODE_3, 604 .mode = SPI_MODE_3,
609 }, 605 },
610#endif 606#endif
611#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 607#if IS_ENABLED(CONFIG_MMC_SPI)
612 { 608 {
613 .modalias = "mmc_spi", 609 .modalias = "mmc_spi",
614 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 610 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -619,7 +615,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
619 }, 615 },
620#endif 616#endif
621 617
622#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 618#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
623 { 619 {
624 .modalias = "ad7877", 620 .modalias = "ad7877",
625 .platform_data = &bfin_ad7877_ts_info, 621 .platform_data = &bfin_ad7877_ts_info,
@@ -629,7 +625,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
629 .chip_select = 2, 625 .chip_select = 2,
630 }, 626 },
631#endif 627#endif
632#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 628#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
633 { 629 {
634 .modalias = "ad7879", 630 .modalias = "ad7879",
635 .platform_data = &bfin_ad7879_ts_info, 631 .platform_data = &bfin_ad7879_ts_info,
@@ -640,7 +636,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
640 .mode = SPI_CPHA | SPI_CPOL, 636 .mode = SPI_CPHA | SPI_CPOL,
641 }, 637 },
642#endif 638#endif
643#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 639#if IS_ENABLED(CONFIG_SPI_SPIDEV)
644 { 640 {
645 .modalias = "spidev", 641 .modalias = "spidev",
646 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 642 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -648,7 +644,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
648 .chip_select = 1, 644 .chip_select = 1,
649 }, 645 },
650#endif 646#endif
651#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 647#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
652 { 648 {
653 .modalias = "bfin-lq035q1-spi", 649 .modalias = "bfin-lq035q1-spi",
654 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 650 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -659,7 +655,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
659#endif 655#endif
660}; 656};
661 657
662#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 658#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
663/* SPI controller data */ 659/* SPI controller data */
664static struct bfin5xx_spi_master bfin_spi0_info = { 660static struct bfin5xx_spi_master bfin_spi0_info = {
665 .num_chipselect = 8, 661 .num_chipselect = 8,
@@ -697,7 +693,7 @@ static struct platform_device bfin_spi0_device = {
697}; 693};
698#endif /* spi master and devices */ 694#endif /* spi master and devices */
699 695
700#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 696#if IS_ENABLED(CONFIG_SERIAL_BFIN)
701#ifdef CONFIG_SERIAL_BFIN_UART0 697#ifdef CONFIG_SERIAL_BFIN_UART0
702static struct resource bfin_uart0_resources[] = { 698static struct resource bfin_uart0_resources[] = {
703 { 699 {
@@ -808,7 +804,7 @@ static struct platform_device bfin_uart1_device = {
808#endif 804#endif
809#endif 805#endif
810 806
811#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 807#if IS_ENABLED(CONFIG_BFIN_SIR)
812#ifdef CONFIG_BFIN_SIR0 808#ifdef CONFIG_BFIN_SIR0
813static struct resource bfin_sir0_resources[] = { 809static struct resource bfin_sir0_resources[] = {
814 { 810 {
@@ -863,7 +859,7 @@ static struct platform_device bfin_sir1_device = {
863#endif 859#endif
864#endif 860#endif
865 861
866#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 862#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
867static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 863static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
868 864
869static struct resource bfin_twi0_resource[] = { 865static struct resource bfin_twi0_resource[] = {
@@ -890,7 +886,7 @@ static struct platform_device i2c_bfin_twi_device = {
890}; 886};
891#endif 887#endif
892 888
893#if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE) 889#if IS_ENABLED(CONFIG_PMIC_ADP5520)
894#include <linux/mfd/adp5520.h> 890#include <linux/mfd/adp5520.h>
895 891
896 /* 892 /*
@@ -956,54 +952,54 @@ static struct adp5520_platform_data adp5520_pdev_data = {
956#endif 952#endif
957 953
958static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 954static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
959#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 955#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
960 { 956 {
961 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 957 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
962 }, 958 },
963#endif 959#endif
964#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 960#if IS_ENABLED(CONFIG_INPUT_PCF8574)
965 { 961 {
966 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 962 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
967 .irq = IRQ_PF8, 963 .irq = IRQ_PF8,
968 }, 964 },
969#endif 965#endif
970#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 966#if IS_ENABLED(CONFIG_FB_BFIN_7393)
971 { 967 {
972 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 968 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
973 }, 969 },
974#endif 970#endif
975#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE) 971#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_I2C)
976 { 972 {
977 I2C_BOARD_INFO("ad7879", 0x2C), 973 I2C_BOARD_INFO("ad7879", 0x2C),
978 .irq = IRQ_PF8, 974 .irq = IRQ_PF8,
979 .platform_data = (void *)&bfin_ad7879_ts_info, 975 .platform_data = (void *)&bfin_ad7879_ts_info,
980 }, 976 },
981#endif 977#endif
982#if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE) 978#if IS_ENABLED(CONFIG_PMIC_ADP5520)
983 { 979 {
984 I2C_BOARD_INFO("pmic-adp5520", 0x32), 980 I2C_BOARD_INFO("pmic-adp5520", 0x32),
985 .irq = IRQ_PF9, 981 .irq = IRQ_PF9,
986 .platform_data = (void *)&adp5520_pdev_data, 982 .platform_data = (void *)&adp5520_pdev_data,
987 }, 983 },
988#endif 984#endif
989#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 985#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
990 { 986 {
991 I2C_BOARD_INFO("ssm2602", 0x1b), 987 I2C_BOARD_INFO("ssm2602", 0x1b),
992 }, 988 },
993#endif 989#endif
994#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 990#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
995 { 991 {
996 I2C_BOARD_INFO("ad5252", 0x2f), 992 I2C_BOARD_INFO("ad5252", 0x2f),
997 }, 993 },
998#endif 994#endif
999#if defined(CONFIG_SND_SOC_ADAU1373) || defined(CONFIG_SND_SOC_ADAU1373_MODULE) 995#if IS_ENABLED(CONFIG_SND_SOC_ADAU1373)
1000 { 996 {
1001 I2C_BOARD_INFO("adau1373", 0x1A), 997 I2C_BOARD_INFO("adau1373", 0x1A),
1002 }, 998 },
1003#endif 999#endif
1004}; 1000};
1005 1001
1006#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 1002#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
1007#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 1003#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1008static struct resource bfin_sport0_uart_resources[] = { 1004static struct resource bfin_sport0_uart_resources[] = {
1009 { 1005 {
@@ -1074,7 +1070,7 @@ static struct platform_device bfin_sport1_uart_device = {
1074#endif 1070#endif
1075#endif 1071#endif
1076 1072
1077#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1073#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1078#include <linux/gpio_keys.h> 1074#include <linux/gpio_keys.h>
1079 1075
1080static struct gpio_keys_button bfin_gpio_keys_table[] = { 1076static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -1095,7 +1091,7 @@ static struct platform_device bfin_device_gpiokeys = {
1095}; 1091};
1096#endif 1092#endif
1097 1093
1098#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 1094#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
1099#include <asm/bfin_rotary.h> 1095#include <asm/bfin_rotary.h>
1100 1096
1101static struct bfin_rotary_platform_data bfin_rotary_data = { 1097static struct bfin_rotary_platform_data bfin_rotary_data = {
@@ -1153,56 +1149,56 @@ static struct platform_device *stamp_devices[] __initdata = {
1153 1149
1154 &bfin_dpmc, 1150 &bfin_dpmc,
1155 1151
1156#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 1152#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
1157 &bf5xx_nand_device, 1153 &bf5xx_nand_device,
1158#endif 1154#endif
1159 1155
1160#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 1156#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
1161 &bfin_pcmcia_cf_device, 1157 &bfin_pcmcia_cf_device,
1162#endif 1158#endif
1163 1159
1164#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 1160#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
1165 &rtc_device, 1161 &rtc_device,
1166#endif 1162#endif
1167 1163
1168#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 1164#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
1169 &bfin_isp1760_device, 1165 &bfin_isp1760_device,
1170#endif 1166#endif
1171 1167
1172#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 1168#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
1173 &musb_device, 1169 &musb_device,
1174#endif 1170#endif
1175 1171
1176#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 1172#if IS_ENABLED(CONFIG_SMC91X)
1177 &smc91x_device, 1173 &smc91x_device,
1178#endif 1174#endif
1179 1175
1180#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 1176#if IS_ENABLED(CONFIG_DM9000)
1181 &dm9000_device, 1177 &dm9000_device,
1182#endif 1178#endif
1183 1179
1184#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 1180#if IS_ENABLED(CONFIG_BFIN_MAC)
1185 &bfin_mii_bus, 1181 &bfin_mii_bus,
1186 &bfin_mac_device, 1182 &bfin_mac_device,
1187#endif 1183#endif
1188 1184
1189#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 1185#if IS_ENABLED(CONFIG_USB_NET2272)
1190 &net2272_bfin_device, 1186 &net2272_bfin_device,
1191#endif 1187#endif
1192 1188
1193#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 1189#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1194 &bfin_spi0_device, 1190 &bfin_spi0_device,
1195#endif 1191#endif
1196 1192
1197#if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE) 1193#if IS_ENABLED(CONFIG_FB_BFIN_T350MCQB)
1198 &bf52x_t350mcqb_device, 1194 &bf52x_t350mcqb_device,
1199#endif 1195#endif
1200 1196
1201#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 1197#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
1202 &bfin_lq035q1_device, 1198 &bfin_lq035q1_device,
1203#endif 1199#endif
1204 1200
1205#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 1201#if IS_ENABLED(CONFIG_SERIAL_BFIN)
1206#ifdef CONFIG_SERIAL_BFIN_UART0 1202#ifdef CONFIG_SERIAL_BFIN_UART0
1207 &bfin_uart0_device, 1203 &bfin_uart0_device,
1208#endif 1204#endif
@@ -1211,7 +1207,7 @@ static struct platform_device *stamp_devices[] __initdata = {
1211#endif 1207#endif
1212#endif 1208#endif
1213 1209
1214#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 1210#if IS_ENABLED(CONFIG_BFIN_SIR)
1215#ifdef CONFIG_BFIN_SIR0 1211#ifdef CONFIG_BFIN_SIR0
1216 &bfin_sir0_device, 1212 &bfin_sir0_device,
1217#endif 1213#endif
@@ -1220,11 +1216,11 @@ static struct platform_device *stamp_devices[] __initdata = {
1220#endif 1216#endif
1221#endif 1217#endif
1222 1218
1223#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1219#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1224 &i2c_bfin_twi_device, 1220 &i2c_bfin_twi_device,
1225#endif 1221#endif
1226 1222
1227#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 1223#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
1228#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 1224#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1229 &bfin_sport0_uart_device, 1225 &bfin_sport0_uart_device,
1230#endif 1226#endif
@@ -1233,32 +1229,31 @@ static struct platform_device *stamp_devices[] __initdata = {
1233#endif 1229#endif
1234#endif 1230#endif
1235 1231
1236#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1232#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1237 &bfin_device_gpiokeys, 1233 &bfin_device_gpiokeys,
1238#endif 1234#endif
1239 1235
1240#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 1236#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
1241 &bfin_rotary_device, 1237 &bfin_rotary_device,
1242#endif 1238#endif
1243 1239
1244#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1240#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
1245 &ezkit_flash_device, 1241 &ezkit_flash_device,
1246#endif 1242#endif
1247 1243
1248#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 1244#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
1249 &bfin_i2s_pcm, 1245 &bfin_i2s_pcm,
1250#endif 1246#endif
1251 1247
1252#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 1248#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
1253 &bfin_ac97_pcm, 1249 &bfin_ac97_pcm,
1254#endif 1250#endif
1255 1251
1256#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 1252#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
1257 &bfin_i2s, 1253 &bfin_i2s,
1258#endif 1254#endif
1259 1255
1260#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 1256#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
1261 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
1262 &bfin_ad1836_machine, 1257 &bfin_ad1836_machine,
1263#endif 1258#endif
1264}; 1259};
diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c
index 1509c5a8a3ff..a0f5856a5ff8 100644
--- a/arch/blackfin/mach-bf527/boards/tll6527m.c
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -28,8 +28,7 @@
28#include <asm/portmux.h> 28#include <asm/portmux.h>
29#include <asm/dpmc.h> 29#include <asm/dpmc.h>
30 30
31#if defined(CONFIG_TOUCHSCREEN_AD7879) \ 31#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
32 || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
33#include <linux/spi/ad7879.h> 32#include <linux/spi/ad7879.h>
34#define LCD_BACKLIGHT_GPIO 0x40 33#define LCD_BACKLIGHT_GPIO 0x40
35/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for 34/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
@@ -45,7 +44,7 @@ const char bfin_board_name[] = "TLL6527M";
45 * Driver needs to know address, irq and flag pin. 44 * Driver needs to know address, irq and flag pin.
46 */ 45 */
47 46
48#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 47#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
49static struct resource musb_resources[] = { 48static struct resource musb_resources[] = {
50 [0] = { 49 [0] = {
51 .start = 0xffc03800, 50 .start = 0xffc03800,
@@ -104,7 +103,7 @@ static struct platform_device musb_device = {
104}; 103};
105#endif 104#endif
106 105
107#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 106#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
108#include <asm/bfin-lq035q1.h> 107#include <asm/bfin-lq035q1.h>
109 108
110static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = { 109static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
@@ -133,7 +132,7 @@ static struct platform_device bfin_lq035q1_device = {
133}; 132};
134#endif 133#endif
135 134
136#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 135#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
137static struct mtd_partition tll6527m_partitions[] = { 136static struct mtd_partition tll6527m_partitions[] = {
138 { 137 {
139 .name = "bootloader(nor)", 138 .name = "bootloader(nor)",
@@ -182,7 +181,7 @@ static struct platform_device tll6527m_flash_device = {
182}; 181};
183#endif 182#endif
184 183
185#if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE) 184#if IS_ENABLED(CONFIG_GPIO_DECODER)
186/* An SN74LVC138A 3:8 decoder chip has been used to generate 7 augmented 185/* An SN74LVC138A 3:8 decoder chip has been used to generate 7 augmented
187 * outputs used as SPI CS lines for all SPI SLAVE devices on TLL6527v1-0. 186 * outputs used as SPI CS lines for all SPI SLAVE devices on TLL6527v1-0.
188 * EXP_GPIO_SPISEL_BASE is the base number for the expanded outputs being 187 * EXP_GPIO_SPISEL_BASE is the base number for the expanded outputs being
@@ -215,7 +214,7 @@ static struct platform_device spi_decoded_gpio = {
215 214
216#endif 215#endif
217 216
218#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE) 217#if IS_ENABLED(CONFIG_INPUT_ADXL34X)
219#include <linux/input/adxl34x.h> 218#include <linux/input/adxl34x.h>
220static const struct adxl34x_platform_data adxl345_info = { 219static const struct adxl34x_platform_data adxl345_info = {
221 .x_axis_offset = 0, 220 .x_axis_offset = 0,
@@ -250,14 +249,14 @@ static const struct adxl34x_platform_data adxl345_info = {
250}; 249};
251#endif 250#endif
252 251
253#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 252#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
254static struct platform_device rtc_device = { 253static struct platform_device rtc_device = {
255 .name = "rtc-bfin", 254 .name = "rtc-bfin",
256 .id = -1, 255 .id = -1,
257}; 256};
258#endif 257#endif
259 258
260#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 259#if IS_ENABLED(CONFIG_BFIN_MAC)
261#include <linux/bfin_mac.h> 260#include <linux/bfin_mac.h>
262static const unsigned short bfin_mac_peripherals[] = P_RMII0; 261static const unsigned short bfin_mac_peripherals[] = P_RMII0;
263 262
@@ -290,8 +289,7 @@ static struct platform_device bfin_mac_device = {
290}; 289};
291#endif 290#endif
292 291
293#if defined(CONFIG_MTD_M25P80) \ 292#if IS_ENABLED(CONFIG_MTD_M25P80)
294 || defined(CONFIG_MTD_M25P80_MODULE)
295static struct mtd_partition bfin_spi_flash_partitions[] = { 293static struct mtd_partition bfin_spi_flash_partitions[] = {
296 { 294 {
297 .name = "bootloader(spi)", 295 .name = "bootloader(spi)",
@@ -318,14 +316,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
318}; 316};
319#endif 317#endif
320 318
321#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 319#if IS_ENABLED(CONFIG_MMC_SPI)
322static struct bfin5xx_spi_chip mmc_spi_chip_info = { 320static struct bfin5xx_spi_chip mmc_spi_chip_info = {
323 .enable_dma = 0, 321 .enable_dma = 0,
324}; 322};
325#endif 323#endif
326 324
327#if defined(CONFIG_TOUCHSCREEN_AD7879) \ 325#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
328 || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
329static const struct ad7879_platform_data bfin_ad7879_ts_info = { 326static const struct ad7879_platform_data bfin_ad7879_ts_info = {
330 .model = 7879, /* Model = AD7879 */ 327 .model = 7879, /* Model = AD7879 */
331 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */ 328 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
@@ -343,7 +340,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
343}; 340};
344#endif 341#endif
345 342
346#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 343#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
347static struct platform_device bfin_i2s = { 344static struct platform_device bfin_i2s = {
348 .name = "bfin-i2s", 345 .name = "bfin-i2s",
349 .id = CONFIG_SND_BF5XX_SPORT_NUM, 346 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -351,7 +348,7 @@ static struct platform_device bfin_i2s = {
351}; 348};
352#endif 349#endif
353 350
354#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE) 351#if IS_ENABLED(CONFIG_GPIO_MCP23S08)
355#include <linux/spi/mcp23s08.h> 352#include <linux/spi/mcp23s08.h>
356static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = { 353static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = {
357 .chip[0].is_present = true, 354 .chip[0].is_present = true,
@@ -364,8 +361,7 @@ static const struct mcp23s08_platform_data bfin_mcp23s08_usr_gpio_info = {
364#endif 361#endif
365 362
366static struct spi_board_info bfin_spi_board_info[] __initdata = { 363static struct spi_board_info bfin_spi_board_info[] __initdata = {
367#if defined(CONFIG_MTD_M25P80) \ 364#if IS_ENABLED(CONFIG_MTD_M25P80)
368 || defined(CONFIG_MTD_M25P80_MODULE)
369 { 365 {
370 /* the modalias must be the same as spi device driver name */ 366 /* the modalias must be the same as spi device driver name */
371 .modalias = "m25p80", /* Name of spi_driver for this device */ 367 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -381,7 +377,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
381 }, 377 },
382#endif 378#endif
383 379
384#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 380#if IS_ENABLED(CONFIG_MMC_SPI)
385 { 381 {
386 .modalias = "mmc_spi", 382 .modalias = "mmc_spi",
387/* 383/*
@@ -396,8 +392,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
396 .mode = SPI_MODE_0, 392 .mode = SPI_MODE_0,
397 }, 393 },
398#endif 394#endif
399#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \ 395#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
400 || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
401 { 396 {
402 .modalias = "ad7879", 397 .modalias = "ad7879",
403 .platform_data = &bfin_ad7879_ts_info, 398 .platform_data = &bfin_ad7879_ts_info,
@@ -409,7 +404,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
409 .mode = SPI_CPHA | SPI_CPOL, 404 .mode = SPI_CPHA | SPI_CPOL,
410 }, 405 },
411#endif 406#endif
412#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 407#if IS_ENABLED(CONFIG_SPI_SPIDEV)
413 { 408 {
414 .modalias = "spidev", 409 .modalias = "spidev",
415 .max_speed_hz = 10000000, 410 .max_speed_hz = 10000000,
@@ -419,7 +414,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
419 .mode = SPI_CPHA | SPI_CPOL, 414 .mode = SPI_CPHA | SPI_CPOL,
420 }, 415 },
421#endif 416#endif
422#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 417#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
423 { 418 {
424 .modalias = "bfin-lq035q1-spi", 419 .modalias = "bfin-lq035q1-spi",
425 .max_speed_hz = 20000000, 420 .max_speed_hz = 20000000,
@@ -428,7 +423,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
428 .mode = SPI_CPHA | SPI_CPOL, 423 .mode = SPI_CPHA | SPI_CPOL,
429 }, 424 },
430#endif 425#endif
431#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE) 426#if IS_ENABLED(CONFIG_GPIO_MCP23S08)
432 { 427 {
433 .modalias = "mcp23s08", 428 .modalias = "mcp23s08",
434 .platform_data = &bfin_mcp23s08_sys_gpio_info, 429 .platform_data = &bfin_mcp23s08_sys_gpio_info,
@@ -448,7 +443,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
448#endif 443#endif
449}; 444};
450 445
451#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 446#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
452/* SPI controller data */ 447/* SPI controller data */
453static struct bfin5xx_spi_master bfin_spi0_info = { 448static struct bfin5xx_spi_master bfin_spi0_info = {
454 .num_chipselect = EXP_GPIO_SPISEL_BASE + 8 + MAX_CTRL_CS, 449 .num_chipselect = EXP_GPIO_SPISEL_BASE + 8 + MAX_CTRL_CS,
@@ -487,7 +482,7 @@ static struct platform_device bfin_spi0_device = {
487}; 482};
488#endif /* spi master and devices */ 483#endif /* spi master and devices */
489 484
490#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 485#if IS_ENABLED(CONFIG_SERIAL_BFIN)
491#ifdef CONFIG_SERIAL_BFIN_UART0 486#ifdef CONFIG_SERIAL_BFIN_UART0
492static struct resource bfin_uart0_resources[] = { 487static struct resource bfin_uart0_resources[] = {
493 { 488 {
@@ -600,7 +595,7 @@ static struct platform_device bfin_uart1_device = {
600#endif 595#endif
601#endif 596#endif
602 597
603#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 598#if IS_ENABLED(CONFIG_BFIN_SIR)
604#ifdef CONFIG_BFIN_SIR0 599#ifdef CONFIG_BFIN_SIR0
605static struct resource bfin_sir0_resources[] = { 600static struct resource bfin_sir0_resources[] = {
606 { 601 {
@@ -655,7 +650,7 @@ static struct platform_device bfin_sir1_device = {
655#endif 650#endif
656#endif 651#endif
657 652
658#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 653#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
659static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 654static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
660 655
661static struct resource bfin_twi0_resource[] = { 656static struct resource bfin_twi0_resource[] = {
@@ -683,26 +678,25 @@ static struct platform_device i2c_bfin_twi_device = {
683#endif 678#endif
684 679
685static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 680static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
686#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 681#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
687 { 682 {
688 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 683 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
689 }, 684 },
690#endif 685#endif
691 686
692#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 687#if IS_ENABLED(CONFIG_FB_BFIN_7393)
693 { 688 {
694 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 689 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
695 }, 690 },
696#endif 691#endif
697#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) \ 692#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_I2C)
698 || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
699 { 693 {
700 I2C_BOARD_INFO("ad7879", 0x2C), 694 I2C_BOARD_INFO("ad7879", 0x2C),
701 .irq = IRQ_PH14, 695 .irq = IRQ_PH14,
702 .platform_data = (void *)&bfin_ad7879_ts_info, 696 .platform_data = (void *)&bfin_ad7879_ts_info,
703 }, 697 },
704#endif 698#endif
705#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 699#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
706 { 700 {
707 I2C_BOARD_INFO("ssm2602", 0x1b), 701 I2C_BOARD_INFO("ssm2602", 0x1b),
708 }, 702 },
@@ -714,8 +708,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
714 { 708 {
715 I2C_BOARD_INFO("ltc3576", 0x09), 709 I2C_BOARD_INFO("ltc3576", 0x09),
716 }, 710 },
717#if defined(CONFIG_INPUT_ADXL34X_I2C) \ 711#if IS_ENABLED(CONFIG_INPUT_ADXL34X_I2C)
718 || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE)
719 { 712 {
720 I2C_BOARD_INFO("adxl34x", 0x53), 713 I2C_BOARD_INFO("adxl34x", 0x53),
721 .irq = IRQ_PH13, 714 .irq = IRQ_PH13,
@@ -724,8 +717,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
724#endif 717#endif
725}; 718};
726 719
727#if defined(CONFIG_SERIAL_BFIN_SPORT) \ 720#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
728 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
729#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 721#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
730static struct resource bfin_sport0_uart_resources[] = { 722static struct resource bfin_sport0_uart_resources[] = {
731 { 723 {
@@ -823,28 +815,28 @@ static struct platform_device *tll6527m_devices[] __initdata = {
823 815
824 &bfin_dpmc, 816 &bfin_dpmc,
825 817
826#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 818#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
827 &rtc_device, 819 &rtc_device,
828#endif 820#endif
829 821
830#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 822#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
831 &musb_device, 823 &musb_device,
832#endif 824#endif
833 825
834#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 826#if IS_ENABLED(CONFIG_BFIN_MAC)
835 &bfin_mii_bus, 827 &bfin_mii_bus,
836 &bfin_mac_device, 828 &bfin_mac_device,
837#endif 829#endif
838 830
839#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 831#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
840 &bfin_spi0_device, 832 &bfin_spi0_device,
841#endif 833#endif
842 834
843#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 835#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
844 &bfin_lq035q1_device, 836 &bfin_lq035q1_device,
845#endif 837#endif
846 838
847#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 839#if IS_ENABLED(CONFIG_SERIAL_BFIN)
848#ifdef CONFIG_SERIAL_BFIN_UART0 840#ifdef CONFIG_SERIAL_BFIN_UART0
849 &bfin_uart0_device, 841 &bfin_uart0_device,
850#endif 842#endif
@@ -853,7 +845,7 @@ static struct platform_device *tll6527m_devices[] __initdata = {
853#endif 845#endif
854#endif 846#endif
855 847
856#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 848#if IS_ENABLED(CONFIG_BFIN_SIR)
857#ifdef CONFIG_BFIN_SIR0 849#ifdef CONFIG_BFIN_SIR0
858 &bfin_sir0_device, 850 &bfin_sir0_device,
859#endif 851#endif
@@ -862,12 +854,11 @@ static struct platform_device *tll6527m_devices[] __initdata = {
862#endif 854#endif
863#endif 855#endif
864 856
865#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 857#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
866 &i2c_bfin_twi_device, 858 &i2c_bfin_twi_device,
867#endif 859#endif
868 860
869#if defined(CONFIG_SERIAL_BFIN_SPORT) \ 861#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
870 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
871#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 862#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
872 &bfin_sport0_uart_device, 863 &bfin_sport0_uart_device,
873#endif 864#endif
@@ -876,15 +867,15 @@ static struct platform_device *tll6527m_devices[] __initdata = {
876#endif 867#endif
877#endif 868#endif
878 869
879#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 870#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
880 &tll6527m_flash_device, 871 &tll6527m_flash_device,
881#endif 872#endif
882 873
883#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 874#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
884 &bfin_i2s, 875 &bfin_i2s,
885#endif 876#endif
886 877
887#if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE) 878#if IS_ENABLED(CONFIG_GPIO_DECODER)
888 &spi_decoded_gpio, 879 &spi_decoded_gpio,
889#endif 880#endif
890}; 881};
diff --git a/arch/blackfin/mach-bf533/boards/H8606.c b/arch/blackfin/mach-bf533/boards/H8606.c
index 6cb7b3ed9b3d..01300f40db15 100644
--- a/arch/blackfin/mach-bf533/boards/H8606.c
+++ b/arch/blackfin/mach-bf533/boards/H8606.c
@@ -14,7 +14,7 @@
14#include <linux/mtd/partitions.h> 14#include <linux/mtd/partitions.h>
15#include <linux/spi/spi.h> 15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h> 16#include <linux/spi/flash.h>
17#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 17#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
18#include <linux/usb/isp1362.h> 18#include <linux/usb/isp1362.h>
19#endif 19#endif
20#include <linux/irq.h> 20#include <linux/irq.h>
@@ -29,7 +29,7 @@
29 */ 29 */
30const char bfin_board_name[] = "HV Sistemas H8606"; 30const char bfin_board_name[] = "HV Sistemas H8606";
31 31
32#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 32#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
33static struct platform_device rtc_device = { 33static struct platform_device rtc_device = {
34 .name = "rtc-bfin", 34 .name = "rtc-bfin",
35 .id = -1, 35 .id = -1,
@@ -39,7 +39,7 @@ static struct platform_device rtc_device = {
39/* 39/*
40* Driver needs to know address, irq and flag pin. 40* Driver needs to know address, irq and flag pin.
41 */ 41 */
42 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 42#if IS_ENABLED(CONFIG_DM9000)
43static struct resource dm9000_resources[] = { 43static struct resource dm9000_resources[] = {
44 [0] = { 44 [0] = {
45 .start = 0x20300000, 45 .start = 0x20300000,
@@ -67,7 +67,7 @@ static struct platform_device dm9000_device = {
67}; 67};
68#endif 68#endif
69 69
70#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 70#if IS_ENABLED(CONFIG_SMC91X)
71#include <linux/smc91x.h> 71#include <linux/smc91x.h>
72 72
73static struct smc91x_platdata smc91x_info = { 73static struct smc91x_platdata smc91x_info = {
@@ -104,7 +104,7 @@ static struct platform_device smc91x_device = {
104}; 104};
105#endif 105#endif
106 106
107#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 107#if IS_ENABLED(CONFIG_USB_NET2272)
108static struct resource net2272_bfin_resources[] = { 108static struct resource net2272_bfin_resources[] = {
109 { 109 {
110 .start = 0x20300000, 110 .start = 0x20300000,
@@ -125,10 +125,10 @@ static struct platform_device net2272_bfin_device = {
125}; 125};
126#endif 126#endif
127 127
128#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 128#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
129/* all SPI peripherals info goes here */ 129/* all SPI peripherals info goes here */
130 130
131#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 131#if IS_ENABLED(CONFIG_MTD_M25P80)
132static struct mtd_partition bfin_spi_flash_partitions[] = { 132static struct mtd_partition bfin_spi_flash_partitions[] = {
133 { 133 {
134 .name = "bootloader (spi)", 134 .name = "bootloader (spi)",
@@ -166,7 +166,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
166/* Notice: for blackfin, the speed_hz is the value of register 166/* Notice: for blackfin, the speed_hz is the value of register
167 * SPI_BAUD, not the real baudrate */ 167 * SPI_BAUD, not the real baudrate */
168static struct spi_board_info bfin_spi_board_info[] __initdata = { 168static struct spi_board_info bfin_spi_board_info[] __initdata = {
169#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 169#if IS_ENABLED(CONFIG_MTD_M25P80)
170 { 170 {
171 /* the modalias must be the same as spi device driver name */ 171 /* the modalias must be the same as spi device driver name */
172 .modalias = "m25p80", /* Name of spi_driver for this device */ 172 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -180,7 +180,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
180 }, 180 },
181#endif 181#endif
182 182
183#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 183#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
184 { 184 {
185 .modalias = "ad183x", 185 .modalias = "ad183x",
186 .max_speed_hz = 16, 186 .max_speed_hz = 16,
@@ -229,7 +229,7 @@ static struct platform_device bfin_spi0_device = {
229}; 229};
230#endif /* spi master and devices */ 230#endif /* spi master and devices */
231 231
232#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 232#if IS_ENABLED(CONFIG_SERIAL_BFIN)
233#ifdef CONFIG_SERIAL_BFIN_UART0 233#ifdef CONFIG_SERIAL_BFIN_UART0
234static struct resource bfin_uart0_resources[] = { 234static struct resource bfin_uart0_resources[] = {
235 { 235 {
@@ -280,7 +280,7 @@ static struct platform_device bfin_uart0_device = {
280#endif 280#endif
281#endif 281#endif
282 282
283#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 283#if IS_ENABLED(CONFIG_BFIN_SIR)
284#ifdef CONFIG_BFIN_SIR0 284#ifdef CONFIG_BFIN_SIR0
285static struct resource bfin_sir0_resources[] = { 285static struct resource bfin_sir0_resources[] = {
286 { 286 {
@@ -309,7 +309,7 @@ static struct platform_device bfin_sir0_device = {
309#endif 309#endif
310#endif 310#endif
311 311
312#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 312#if IS_ENABLED(CONFIG_SERIAL_8250)
313 313
314#include <linux/serial_8250.h> 314#include <linux/serial_8250.h>
315#include <linux/serial.h> 315#include <linux/serial.h>
@@ -353,7 +353,7 @@ static struct platform_device serial8250_device = {
353 353
354#endif 354#endif
355 355
356#if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE) 356#if IS_ENABLED(CONFIG_KEYBOARD_OPENCORES)
357 357
358/* 358/*
359 * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030, 359 * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030,
@@ -382,43 +382,43 @@ static struct platform_device opencores_kbd_device = {
382#endif 382#endif
383 383
384static struct platform_device *h8606_devices[] __initdata = { 384static struct platform_device *h8606_devices[] __initdata = {
385#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 385#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
386 &rtc_device, 386 &rtc_device,
387#endif 387#endif
388 388
389#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 389#if IS_ENABLED(CONFIG_DM9000)
390 &dm9000_device, 390 &dm9000_device,
391#endif 391#endif
392 392
393#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 393#if IS_ENABLED(CONFIG_SMC91X)
394 &smc91x_device, 394 &smc91x_device,
395#endif 395#endif
396 396
397#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 397#if IS_ENABLED(CONFIG_USB_NET2272)
398 &net2272_bfin_device, 398 &net2272_bfin_device,
399#endif 399#endif
400 400
401#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 401#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
402 &bfin_spi0_device, 402 &bfin_spi0_device,
403#endif 403#endif
404 404
405#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 405#if IS_ENABLED(CONFIG_SERIAL_BFIN)
406#ifdef CONFIG_SERIAL_BFIN_UART0 406#ifdef CONFIG_SERIAL_BFIN_UART0
407 &bfin_uart0_device, 407 &bfin_uart0_device,
408#endif 408#endif
409#endif 409#endif
410 410
411#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 411#if IS_ENABLED(CONFIG_SERIAL_8250)
412 &serial8250_device, 412 &serial8250_device,
413#endif 413#endif
414 414
415#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 415#if IS_ENABLED(CONFIG_BFIN_SIR)
416#ifdef CONFIG_BFIN_SIR0 416#ifdef CONFIG_BFIN_SIR0
417 &bfin_sir0_device, 417 &bfin_sir0_device,
418#endif 418#endif
419#endif 419#endif
420 420
421#if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE) 421#if IS_ENABLED(CONFIG_KEYBOARD_OPENCORES)
422 &opencores_kbd_device, 422 &opencores_kbd_device,
423#endif 423#endif
424}; 424};
@@ -428,7 +428,7 @@ static int __init H8606_init(void)
428 printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n"); 428 printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n");
429 printk(KERN_INFO "%s(): registering device resources\n", __func__); 429 printk(KERN_INFO "%s(): registering device resources\n", __func__);
430 platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices)); 430 platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices));
431#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 431#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
432 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 432 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
433#endif 433#endif
434 return 0; 434 return 0;
diff --git a/arch/blackfin/mach-bf533/boards/blackstamp.c b/arch/blackfin/mach-bf533/boards/blackstamp.c
index de44a3765e59..63b0e4fe760c 100644
--- a/arch/blackfin/mach-bf533/boards/blackstamp.c
+++ b/arch/blackfin/mach-bf533/boards/blackstamp.c
@@ -31,7 +31,7 @@
31 */ 31 */
32const char bfin_board_name[] = "BlackStamp"; 32const char bfin_board_name[] = "BlackStamp";
33 33
34#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 34#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
35static struct platform_device rtc_device = { 35static struct platform_device rtc_device = {
36 .name = "rtc-bfin", 36 .name = "rtc-bfin",
37 .id = -1, 37 .id = -1,
@@ -41,7 +41,7 @@ static struct platform_device rtc_device = {
41/* 41/*
42 * Driver needs to know address, irq and flag pin. 42 * Driver needs to know address, irq and flag pin.
43 */ 43 */
44#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 44#if IS_ENABLED(CONFIG_SMC91X)
45#include <linux/smc91x.h> 45#include <linux/smc91x.h>
46 46
47static struct smc91x_platdata smc91x_info = { 47static struct smc91x_platdata smc91x_info = {
@@ -74,7 +74,7 @@ static struct platform_device smc91x_device = {
74}; 74};
75#endif 75#endif
76 76
77#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 77#if IS_ENABLED(CONFIG_MTD_M25P80)
78static struct mtd_partition bfin_spi_flash_partitions[] = { 78static struct mtd_partition bfin_spi_flash_partitions[] = {
79 { 79 {
80 .name = "bootloader(spi)", 80 .name = "bootloader(spi)",
@@ -105,14 +105,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
105}; 105};
106#endif 106#endif
107 107
108#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 108#if IS_ENABLED(CONFIG_MMC_SPI)
109static struct bfin5xx_spi_chip mmc_spi_chip_info = { 109static struct bfin5xx_spi_chip mmc_spi_chip_info = {
110 .enable_dma = 0, 110 .enable_dma = 0,
111}; 111};
112#endif 112#endif
113 113
114static struct spi_board_info bfin_spi_board_info[] __initdata = { 114static struct spi_board_info bfin_spi_board_info[] __initdata = {
115#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 115#if IS_ENABLED(CONFIG_MTD_M25P80)
116 { 116 {
117 /* the modalias must be the same as spi device driver name */ 117 /* the modalias must be the same as spi device driver name */
118 .modalias = "m25p80", /* Name of spi_driver for this device */ 118 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -125,7 +125,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
125 }, 125 },
126#endif 126#endif
127 127
128#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 128#if IS_ENABLED(CONFIG_MMC_SPI)
129 { 129 {
130 .modalias = "mmc_spi", 130 .modalias = "mmc_spi",
131 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 131 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -136,7 +136,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
136 }, 136 },
137#endif 137#endif
138 138
139#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 139#if IS_ENABLED(CONFIG_SPI_SPIDEV)
140 { 140 {
141 .modalias = "spidev", 141 .modalias = "spidev",
142 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 142 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -146,7 +146,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
146#endif 146#endif
147}; 147};
148 148
149#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 149#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
150/* SPI (0) */ 150/* SPI (0) */
151static struct resource bfin_spi0_resource[] = { 151static struct resource bfin_spi0_resource[] = {
152 [0] = { 152 [0] = {
@@ -184,7 +184,7 @@ static struct platform_device bfin_spi0_device = {
184}; 184};
185#endif /* spi master and devices */ 185#endif /* spi master and devices */
186 186
187#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 187#if IS_ENABLED(CONFIG_SERIAL_BFIN)
188#ifdef CONFIG_SERIAL_BFIN_UART0 188#ifdef CONFIG_SERIAL_BFIN_UART0
189static struct resource bfin_uart0_resources[] = { 189static struct resource bfin_uart0_resources[] = {
190 { 190 {
@@ -235,7 +235,7 @@ static struct platform_device bfin_uart0_device = {
235#endif 235#endif
236#endif 236#endif
237 237
238#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 238#if IS_ENABLED(CONFIG_BFIN_SIR)
239#ifdef CONFIG_BFIN_SIR0 239#ifdef CONFIG_BFIN_SIR0
240static struct resource bfin_sir0_resources[] = { 240static struct resource bfin_sir0_resources[] = {
241 { 241 {
@@ -264,7 +264,7 @@ static struct platform_device bfin_sir0_device = {
264#endif 264#endif
265#endif 265#endif
266 266
267#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 267#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
268#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 268#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
269static struct resource bfin_sport0_uart_resources[] = { 269static struct resource bfin_sport0_uart_resources[] = {
270 { 270 {
@@ -335,7 +335,7 @@ static struct platform_device bfin_sport1_uart_device = {
335#endif 335#endif
336#endif 336#endif
337 337
338#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 338#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
339#include <linux/input.h> 339#include <linux/input.h>
340#include <linux/gpio_keys.h> 340#include <linux/gpio_keys.h>
341 341
@@ -358,7 +358,7 @@ static struct platform_device bfin_device_gpiokeys = {
358}; 358};
359#endif 359#endif
360 360
361#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 361#if IS_ENABLED(CONFIG_I2C_GPIO)
362#include <linux/i2c-gpio.h> 362#include <linux/i2c-gpio.h>
363 363
364static struct i2c_gpio_platform_data i2c_gpio_data = { 364static struct i2c_gpio_platform_data i2c_gpio_data = {
@@ -413,32 +413,32 @@ static struct platform_device *stamp_devices[] __initdata = {
413 413
414 &bfin_dpmc, 414 &bfin_dpmc,
415 415
416#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 416#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
417 &rtc_device, 417 &rtc_device,
418#endif 418#endif
419 419
420#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 420#if IS_ENABLED(CONFIG_SMC91X)
421 &smc91x_device, 421 &smc91x_device,
422#endif 422#endif
423 423
424 424
425#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 425#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
426 &bfin_spi0_device, 426 &bfin_spi0_device,
427#endif 427#endif
428 428
429#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 429#if IS_ENABLED(CONFIG_SERIAL_BFIN)
430#ifdef CONFIG_SERIAL_BFIN_UART0 430#ifdef CONFIG_SERIAL_BFIN_UART0
431 &bfin_uart0_device, 431 &bfin_uart0_device,
432#endif 432#endif
433#endif 433#endif
434 434
435#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 435#if IS_ENABLED(CONFIG_BFIN_SIR)
436#ifdef CONFIG_BFIN_SIR0 436#ifdef CONFIG_BFIN_SIR0
437 &bfin_sir0_device, 437 &bfin_sir0_device,
438#endif 438#endif
439#endif 439#endif
440 440
441#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 441#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
442#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 442#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
443 &bfin_sport0_uart_device, 443 &bfin_sport0_uart_device,
444#endif 444#endif
@@ -447,11 +447,11 @@ static struct platform_device *stamp_devices[] __initdata = {
447#endif 447#endif
448#endif 448#endif
449 449
450#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 450#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
451 &bfin_device_gpiokeys, 451 &bfin_device_gpiokeys,
452#endif 452#endif
453 453
454#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 454#if IS_ENABLED(CONFIG_I2C_GPIO)
455 &i2c_gpio_device, 455 &i2c_gpio_device,
456#endif 456#endif
457}; 457};
@@ -469,7 +469,7 @@ static int __init blackstamp_init(void)
469 if (ret < 0) 469 if (ret < 0)
470 return ret; 470 return ret;
471 471
472#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 472#if IS_ENABLED(CONFIG_SMC91X)
473 /* 473 /*
474 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC. 474 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
475 * the bfin-async-map driver takes care of flipping between 475 * the bfin-async-map driver takes care of flipping between
diff --git a/arch/blackfin/mach-bf533/boards/cm_bf533.c b/arch/blackfin/mach-bf533/boards/cm_bf533.c
index fe47e048c4e6..4ef2fb0e48d5 100644
--- a/arch/blackfin/mach-bf533/boards/cm_bf533.c
+++ b/arch/blackfin/mach-bf533/boards/cm_bf533.c
@@ -15,7 +15,7 @@
15#include <linux/spi/spi.h> 15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h> 16#include <linux/spi/flash.h>
17#include <linux/spi/mmc_spi.h> 17#include <linux/spi/mmc_spi.h>
18#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 18#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
19#include <linux/usb/isp1362.h> 19#include <linux/usb/isp1362.h>
20#endif 20#endif
21#include <linux/irq.h> 21#include <linux/irq.h>
@@ -29,9 +29,9 @@
29 */ 29 */
30const char bfin_board_name[] = "Bluetechnix CM BF533"; 30const char bfin_board_name[] = "Bluetechnix CM BF533";
31 31
32#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 32#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
33/* all SPI peripherals info goes here */ 33/* all SPI peripherals info goes here */
34#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 34#if IS_ENABLED(CONFIG_MTD_M25P80)
35static struct mtd_partition bfin_spi_flash_partitions[] = { 35static struct mtd_partition bfin_spi_flash_partitions[] = {
36 { 36 {
37 .name = "bootloader(spi)", 37 .name = "bootloader(spi)",
@@ -62,14 +62,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
62}; 62};
63#endif 63#endif
64 64
65#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 65#if IS_ENABLED(CONFIG_MMC_SPI)
66static struct bfin5xx_spi_chip mmc_spi_chip_info = { 66static struct bfin5xx_spi_chip mmc_spi_chip_info = {
67 .enable_dma = 0, 67 .enable_dma = 0,
68}; 68};
69#endif 69#endif
70 70
71static struct spi_board_info bfin_spi_board_info[] __initdata = { 71static struct spi_board_info bfin_spi_board_info[] __initdata = {
72#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 72#if IS_ENABLED(CONFIG_MTD_M25P80)
73 { 73 {
74 /* the modalias must be the same as spi device driver name */ 74 /* the modalias must be the same as spi device driver name */
75 .modalias = "m25p80", /* Name of spi_driver for this device */ 75 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -82,7 +82,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
82 }, 82 },
83#endif 83#endif
84 84
85#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 85#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
86 { 86 {
87 .modalias = "ad183x", 87 .modalias = "ad183x",
88 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 88 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -91,7 +91,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
91 }, 91 },
92#endif 92#endif
93 93
94#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 94#if IS_ENABLED(CONFIG_MMC_SPI)
95 { 95 {
96 .modalias = "mmc_spi", 96 .modalias = "mmc_spi",
97 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 97 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -140,14 +140,14 @@ static struct platform_device bfin_spi0_device = {
140}; 140};
141#endif /* spi master and devices */ 141#endif /* spi master and devices */
142 142
143#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 143#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
144static struct platform_device rtc_device = { 144static struct platform_device rtc_device = {
145 .name = "rtc-bfin", 145 .name = "rtc-bfin",
146 .id = -1, 146 .id = -1,
147}; 147};
148#endif 148#endif
149 149
150#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 150#if IS_ENABLED(CONFIG_SMC91X)
151#include <linux/smc91x.h> 151#include <linux/smc91x.h>
152 152
153static struct smc91x_platdata smc91x_info = { 153static struct smc91x_platdata smc91x_info = {
@@ -178,7 +178,7 @@ static struct platform_device smc91x_device = {
178}; 178};
179#endif 179#endif
180 180
181#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 181#if IS_ENABLED(CONFIG_SMSC911X)
182#include <linux/smsc911x.h> 182#include <linux/smsc911x.h>
183 183
184static struct resource smsc911x_resources[] = { 184static struct resource smsc911x_resources[] = {
@@ -212,7 +212,7 @@ static struct platform_device smsc911x_device = {
212}; 212};
213#endif 213#endif
214 214
215#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 215#if IS_ENABLED(CONFIG_SERIAL_BFIN)
216#ifdef CONFIG_SERIAL_BFIN_UART0 216#ifdef CONFIG_SERIAL_BFIN_UART0
217static struct resource bfin_uart0_resources[] = { 217static struct resource bfin_uart0_resources[] = {
218 { 218 {
@@ -263,7 +263,7 @@ static struct platform_device bfin_uart0_device = {
263#endif 263#endif
264#endif 264#endif
265 265
266#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 266#if IS_ENABLED(CONFIG_BFIN_SIR)
267#ifdef CONFIG_BFIN_SIR0 267#ifdef CONFIG_BFIN_SIR0
268static struct resource bfin_sir0_resources[] = { 268static struct resource bfin_sir0_resources[] = {
269 { 269 {
@@ -292,7 +292,7 @@ static struct platform_device bfin_sir0_device = {
292#endif 292#endif
293#endif 293#endif
294 294
295#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 295#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
296#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 296#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
297static struct resource bfin_sport0_uart_resources[] = { 297static struct resource bfin_sport0_uart_resources[] = {
298 { 298 {
@@ -363,7 +363,7 @@ static struct platform_device bfin_sport1_uart_device = {
363#endif 363#endif
364#endif 364#endif
365 365
366#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 366#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
367static struct resource isp1362_hcd_resources[] = { 367static struct resource isp1362_hcd_resources[] = {
368 { 368 {
369 .start = 0x20308000, 369 .start = 0x20308000,
@@ -403,7 +403,7 @@ static struct platform_device isp1362_hcd_device = {
403#endif 403#endif
404 404
405 405
406#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 406#if IS_ENABLED(CONFIG_USB_NET2272)
407static struct resource net2272_bfin_resources[] = { 407static struct resource net2272_bfin_resources[] = {
408 { 408 {
409 .start = 0x20300000, 409 .start = 0x20300000,
@@ -426,7 +426,7 @@ static struct platform_device net2272_bfin_device = {
426 426
427 427
428 428
429#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 429#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
430static struct mtd_partition para_partitions[] = { 430static struct mtd_partition para_partitions[] = {
431 { 431 {
432 .name = "bootloader(nor)", 432 .name = "bootloader(nor)",
@@ -495,19 +495,19 @@ static struct platform_device *cm_bf533_devices[] __initdata = {
495 495
496 &bfin_dpmc, 496 &bfin_dpmc,
497 497
498#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 498#if IS_ENABLED(CONFIG_SERIAL_BFIN)
499#ifdef CONFIG_SERIAL_BFIN_UART0 499#ifdef CONFIG_SERIAL_BFIN_UART0
500 &bfin_uart0_device, 500 &bfin_uart0_device,
501#endif 501#endif
502#endif 502#endif
503 503
504#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 504#if IS_ENABLED(CONFIG_BFIN_SIR)
505#ifdef CONFIG_BFIN_SIR0 505#ifdef CONFIG_BFIN_SIR0
506 &bfin_sir0_device, 506 &bfin_sir0_device,
507#endif 507#endif
508#endif 508#endif
509 509
510#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 510#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
511#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 511#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
512 &bfin_sport0_uart_device, 512 &bfin_sport0_uart_device,
513#endif 513#endif
@@ -516,31 +516,31 @@ static struct platform_device *cm_bf533_devices[] __initdata = {
516#endif 516#endif
517#endif 517#endif
518 518
519#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 519#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
520 &rtc_device, 520 &rtc_device,
521#endif 521#endif
522 522
523#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 523#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
524 &isp1362_hcd_device, 524 &isp1362_hcd_device,
525#endif 525#endif
526 526
527#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 527#if IS_ENABLED(CONFIG_SMC91X)
528 &smc91x_device, 528 &smc91x_device,
529#endif 529#endif
530 530
531#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 531#if IS_ENABLED(CONFIG_SMSC911X)
532 &smsc911x_device, 532 &smsc911x_device,
533#endif 533#endif
534 534
535#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 535#if IS_ENABLED(CONFIG_USB_NET2272)
536 &net2272_bfin_device, 536 &net2272_bfin_device,
537#endif 537#endif
538 538
539#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 539#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
540 &bfin_spi0_device, 540 &bfin_spi0_device,
541#endif 541#endif
542 542
543#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 543#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
544 &para_flash_device, 544 &para_flash_device,
545#endif 545#endif
546}; 546};
@@ -549,7 +549,7 @@ static int __init cm_bf533_init(void)
549{ 549{
550 printk(KERN_INFO "%s(): registering device resources\n", __func__); 550 printk(KERN_INFO "%s(): registering device resources\n", __func__);
551 platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices)); 551 platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
552#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 552#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
553 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 553 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
554#endif 554#endif
555 return 0; 555 return 0;
diff --git a/arch/blackfin/mach-bf533/boards/ezkit.c b/arch/blackfin/mach-bf533/boards/ezkit.c
index 90fb0d14b147..3625e9eaa8a8 100644
--- a/arch/blackfin/mach-bf533/boards/ezkit.c
+++ b/arch/blackfin/mach-bf533/boards/ezkit.c
@@ -14,7 +14,7 @@
14#include <linux/mtd/physmap.h> 14#include <linux/mtd/physmap.h>
15#include <linux/spi/spi.h> 15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h> 16#include <linux/spi/flash.h>
17#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 17#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
18#include <linux/usb/isp1362.h> 18#include <linux/usb/isp1362.h>
19#endif 19#endif
20#include <linux/irq.h> 20#include <linux/irq.h>
@@ -29,7 +29,7 @@
29 */ 29 */
30const char bfin_board_name[] = "ADI BF533-EZKIT"; 30const char bfin_board_name[] = "ADI BF533-EZKIT";
31 31
32#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 32#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
33static struct platform_device rtc_device = { 33static struct platform_device rtc_device = {
34 .name = "rtc-bfin", 34 .name = "rtc-bfin",
35 .id = -1, 35 .id = -1,
@@ -40,7 +40,7 @@ static struct platform_device rtc_device = {
40 * USB-LAN EzExtender board 40 * USB-LAN EzExtender board
41 * Driver needs to know address, irq and flag pin. 41 * Driver needs to know address, irq and flag pin.
42 */ 42 */
43#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 43#if IS_ENABLED(CONFIG_SMC91X)
44#include <linux/smc91x.h> 44#include <linux/smc91x.h>
45 45
46static struct smc91x_platdata smc91x_info = { 46static struct smc91x_platdata smc91x_info = {
@@ -72,7 +72,7 @@ static struct platform_device smc91x_device = {
72}; 72};
73#endif 73#endif
74 74
75#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 75#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
76static struct mtd_partition ezkit_partitions_a[] = { 76static struct mtd_partition ezkit_partitions_a[] = {
77 { 77 {
78 .name = "bootloader(nor a)", 78 .name = "bootloader(nor a)",
@@ -138,7 +138,7 @@ static struct platform_device ezkit_flash_device_b = {
138}; 138};
139#endif 139#endif
140 140
141#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE) 141#if IS_ENABLED(CONFIG_MTD_PLATRAM)
142static struct platdata_mtd_ram sram_data_a = { 142static struct platdata_mtd_ram sram_data_a = {
143 .mapname = "Flash A SRAM", 143 .mapname = "Flash A SRAM",
144 .bankwidth = 2, 144 .bankwidth = 2,
@@ -182,7 +182,7 @@ static struct platform_device sram_device_b = {
182}; 182};
183#endif 183#endif
184 184
185#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 185#if IS_ENABLED(CONFIG_MTD_M25P80)
186static struct mtd_partition bfin_spi_flash_partitions[] = { 186static struct mtd_partition bfin_spi_flash_partitions[] = {
187 { 187 {
188 .name = "bootloader(spi)", 188 .name = "bootloader(spi)",
@@ -214,7 +214,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
214#endif 214#endif
215 215
216static struct spi_board_info bfin_spi_board_info[] __initdata = { 216static struct spi_board_info bfin_spi_board_info[] __initdata = {
217#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 217#if IS_ENABLED(CONFIG_MTD_M25P80)
218 { 218 {
219 /* the modalias must be the same as spi device driver name */ 219 /* the modalias must be the same as spi device driver name */
220 .modalias = "m25p80", /* Name of spi_driver for this device */ 220 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -227,7 +227,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
227 }, 227 },
228#endif 228#endif
229 229
230#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 230#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
231 { 231 {
232 .modalias = "ad183x", 232 .modalias = "ad183x",
233 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 233 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -235,7 +235,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
235 .chip_select = 4, 235 .chip_select = 4,
236 }, 236 },
237#endif 237#endif
238#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 238#if IS_ENABLED(CONFIG_SPI_SPIDEV)
239 { 239 {
240 .modalias = "spidev", 240 .modalias = "spidev",
241 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 241 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -245,7 +245,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
245#endif 245#endif
246}; 246};
247 247
248#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 248#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
249/* SPI (0) */ 249/* SPI (0) */
250static struct resource bfin_spi0_resource[] = { 250static struct resource bfin_spi0_resource[] = {
251 [0] = { 251 [0] = {
@@ -283,7 +283,7 @@ static struct platform_device bfin_spi0_device = {
283}; 283};
284#endif /* spi master and devices */ 284#endif /* spi master and devices */
285 285
286#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 286#if IS_ENABLED(CONFIG_SERIAL_BFIN)
287#ifdef CONFIG_SERIAL_BFIN_UART0 287#ifdef CONFIG_SERIAL_BFIN_UART0
288static struct resource bfin_uart0_resources[] = { 288static struct resource bfin_uart0_resources[] = {
289 { 289 {
@@ -334,7 +334,7 @@ static struct platform_device bfin_uart0_device = {
334#endif 334#endif
335#endif 335#endif
336 336
337#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 337#if IS_ENABLED(CONFIG_BFIN_SIR)
338#ifdef CONFIG_BFIN_SIR0 338#ifdef CONFIG_BFIN_SIR0
339static struct resource bfin_sir0_resources[] = { 339static struct resource bfin_sir0_resources[] = {
340 { 340 {
@@ -363,7 +363,7 @@ static struct platform_device bfin_sir0_device = {
363#endif 363#endif
364#endif 364#endif
365 365
366#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 366#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
367#include <linux/input.h> 367#include <linux/input.h>
368#include <linux/gpio_keys.h> 368#include <linux/gpio_keys.h>
369 369
@@ -387,7 +387,7 @@ static struct platform_device bfin_device_gpiokeys = {
387}; 387};
388#endif 388#endif
389 389
390#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 390#if IS_ENABLED(CONFIG_I2C_GPIO)
391#include <linux/i2c-gpio.h> 391#include <linux/i2c-gpio.h>
392 392
393static struct i2c_gpio_platform_data i2c_gpio_data = { 393static struct i2c_gpio_platform_data i2c_gpio_data = {
@@ -435,14 +435,14 @@ static struct platform_device bfin_dpmc = {
435}; 435};
436 436
437static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 437static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
438#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 438#if IS_ENABLED(CONFIG_FB_BFIN_7393)
439 { 439 {
440 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 440 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
441 }, 441 },
442#endif 442#endif
443}; 443};
444 444
445#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 445#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
446static struct platform_device bfin_i2s = { 446static struct platform_device bfin_i2s = {
447 .name = "bfin-i2s", 447 .name = "bfin-i2s",
448 .id = CONFIG_SND_BF5XX_SPORT_NUM, 448 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -450,7 +450,7 @@ static struct platform_device bfin_i2s = {
450}; 450};
451#endif 451#endif
452 452
453#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 453#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
454static struct platform_device bfin_ac97 = { 454static struct platform_device bfin_ac97 = {
455 .name = "bfin-ac97", 455 .name = "bfin-ac97",
456 .id = CONFIG_SND_BF5XX_SPORT_NUM, 456 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -462,53 +462,53 @@ static struct platform_device *ezkit_devices[] __initdata = {
462 462
463 &bfin_dpmc, 463 &bfin_dpmc,
464 464
465#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 465#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
466 &ezkit_flash_device_a, 466 &ezkit_flash_device_a,
467 &ezkit_flash_device_b, 467 &ezkit_flash_device_b,
468#endif 468#endif
469 469
470#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE) 470#if IS_ENABLED(CONFIG_MTD_PLATRAM)
471 &sram_device_a, 471 &sram_device_a,
472 &sram_device_b, 472 &sram_device_b,
473#endif 473#endif
474 474
475#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 475#if IS_ENABLED(CONFIG_SMC91X)
476 &smc91x_device, 476 &smc91x_device,
477#endif 477#endif
478 478
479#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 479#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
480 &bfin_spi0_device, 480 &bfin_spi0_device,
481#endif 481#endif
482 482
483#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 483#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
484 &rtc_device, 484 &rtc_device,
485#endif 485#endif
486 486
487#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 487#if IS_ENABLED(CONFIG_SERIAL_BFIN)
488#ifdef CONFIG_SERIAL_BFIN_UART0 488#ifdef CONFIG_SERIAL_BFIN_UART0
489 &bfin_uart0_device, 489 &bfin_uart0_device,
490#endif 490#endif
491#endif 491#endif
492 492
493#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 493#if IS_ENABLED(CONFIG_BFIN_SIR)
494#ifdef CONFIG_BFIN_SIR0 494#ifdef CONFIG_BFIN_SIR0
495 &bfin_sir0_device, 495 &bfin_sir0_device,
496#endif 496#endif
497#endif 497#endif
498 498
499#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 499#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
500 &bfin_device_gpiokeys, 500 &bfin_device_gpiokeys,
501#endif 501#endif
502 502
503#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 503#if IS_ENABLED(CONFIG_I2C_GPIO)
504 &i2c_gpio_device, 504 &i2c_gpio_device,
505#endif 505#endif
506 506
507#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 507#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
508 &bfin_i2s, 508 &bfin_i2s,
509#endif 509#endif
510 510
511#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 511#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
512 &bfin_ac97, 512 &bfin_ac97,
513#endif 513#endif
514}; 514};
diff --git a/arch/blackfin/mach-bf533/boards/ip0x.c b/arch/blackfin/mach-bf533/boards/ip0x.c
index e303dae4e2d9..39c8e8547b82 100644
--- a/arch/blackfin/mach-bf533/boards/ip0x.c
+++ b/arch/blackfin/mach-bf533/boards/ip0x.c
@@ -15,7 +15,7 @@
15#include <linux/mtd/partitions.h> 15#include <linux/mtd/partitions.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/spi/flash.h> 17#include <linux/spi/flash.h>
18#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 18#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
19#include <linux/usb/isp1362.h> 19#include <linux/usb/isp1362.h>
20#endif 20#endif
21#include <asm/irq.h> 21#include <asm/irq.h>
@@ -32,7 +32,7 @@ const char bfin_board_name[] = "IP04/IP08";
32 * Driver needs to know address, irq and flag pin. 32 * Driver needs to know address, irq and flag pin.
33 */ 33 */
34#if defined(CONFIG_BFIN532_IP0X) 34#if defined(CONFIG_BFIN532_IP0X)
35#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 35#if IS_ENABLED(CONFIG_DM9000)
36 36
37#include <linux/dm9000.h> 37#include <linux/dm9000.h>
38 38
@@ -104,10 +104,10 @@ static struct platform_device dm9000_device2 = {
104#endif 104#endif
105 105
106 106
107#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 107#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
108/* all SPI peripherals info goes here */ 108/* all SPI peripherals info goes here */
109 109
110#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 110#if IS_ENABLED(CONFIG_MMC_SPI)
111static struct bfin5xx_spi_chip mmc_spi_chip_info = { 111static struct bfin5xx_spi_chip mmc_spi_chip_info = {
112 .enable_dma = 0, /* if 1 - block!!! */ 112 .enable_dma = 0, /* if 1 - block!!! */
113}; 113};
@@ -116,7 +116,7 @@ static struct bfin5xx_spi_chip mmc_spi_chip_info = {
116/* Notice: for blackfin, the speed_hz is the value of register 116/* Notice: for blackfin, the speed_hz is the value of register
117 * SPI_BAUD, not the real baudrate */ 117 * SPI_BAUD, not the real baudrate */
118static struct spi_board_info bfin_spi_board_info[] __initdata = { 118static struct spi_board_info bfin_spi_board_info[] __initdata = {
119#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 119#if IS_ENABLED(CONFIG_MMC_SPI)
120 { 120 {
121 .modalias = "mmc_spi", 121 .modalias = "mmc_spi",
122 .max_speed_hz = 2, 122 .max_speed_hz = 2,
@@ -142,7 +142,7 @@ static struct platform_device spi_bfin_master_device = {
142}; 142};
143#endif /* spi master and devices */ 143#endif /* spi master and devices */
144 144
145#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 145#if IS_ENABLED(CONFIG_SERIAL_BFIN)
146#ifdef CONFIG_SERIAL_BFIN_UART0 146#ifdef CONFIG_SERIAL_BFIN_UART0
147static struct resource bfin_uart0_resources[] = { 147static struct resource bfin_uart0_resources[] = {
148 { 148 {
@@ -193,7 +193,7 @@ static struct platform_device bfin_uart0_device = {
193#endif 193#endif
194#endif 194#endif
195 195
196#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 196#if IS_ENABLED(CONFIG_BFIN_SIR)
197#ifdef CONFIG_BFIN_SIR0 197#ifdef CONFIG_BFIN_SIR0
198static struct resource bfin_sir0_resources[] = { 198static struct resource bfin_sir0_resources[] = {
199 { 199 {
@@ -222,7 +222,7 @@ static struct platform_device bfin_sir0_device = {
222#endif 222#endif
223#endif 223#endif
224 224
225#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 225#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
226static struct resource isp1362_hcd_resources[] = { 226static struct resource isp1362_hcd_resources[] = {
227 { 227 {
228 .start = 0x20300000, 228 .start = 0x20300000,
@@ -264,29 +264,29 @@ static struct platform_device isp1362_hcd_device = {
264 264
265static struct platform_device *ip0x_devices[] __initdata = { 265static struct platform_device *ip0x_devices[] __initdata = {
266#if defined(CONFIG_BFIN532_IP0X) 266#if defined(CONFIG_BFIN532_IP0X)
267#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 267#if IS_ENABLED(CONFIG_DM9000)
268 &dm9000_device1, 268 &dm9000_device1,
269 &dm9000_device2, 269 &dm9000_device2,
270#endif 270#endif
271#endif 271#endif
272 272
273#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 273#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
274 &spi_bfin_master_device, 274 &spi_bfin_master_device,
275#endif 275#endif
276 276
277#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 277#if IS_ENABLED(CONFIG_SERIAL_BFIN)
278#ifdef CONFIG_SERIAL_BFIN_UART0 278#ifdef CONFIG_SERIAL_BFIN_UART0
279 &bfin_uart0_device, 279 &bfin_uart0_device,
280#endif 280#endif
281#endif 281#endif
282 282
283#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 283#if IS_ENABLED(CONFIG_BFIN_SIR)
284#ifdef CONFIG_BFIN_SIR0 284#ifdef CONFIG_BFIN_SIR0
285 &bfin_sir0_device, 285 &bfin_sir0_device,
286#endif 286#endif
287#endif 287#endif
288 288
289#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 289#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
290 &isp1362_hcd_device, 290 &isp1362_hcd_device,
291#endif 291#endif
292}; 292};
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index 4da70c47cc05..d0989290f54c 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -14,7 +14,7 @@
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/spi/flash.h> 15#include <linux/spi/flash.h>
16#include <linux/spi/mmc_spi.h> 16#include <linux/spi/mmc_spi.h>
17#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 17#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
18#include <linux/usb/isp1362.h> 18#include <linux/usb/isp1362.h>
19#endif 19#endif
20#include <linux/irq.h> 20#include <linux/irq.h>
@@ -30,7 +30,7 @@
30 */ 30 */
31const char bfin_board_name[] = "ADI BF533-STAMP"; 31const char bfin_board_name[] = "ADI BF533-STAMP";
32 32
33#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 33#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
34static struct platform_device rtc_device = { 34static struct platform_device rtc_device = {
35 .name = "rtc-bfin", 35 .name = "rtc-bfin",
36 .id = -1, 36 .id = -1,
@@ -40,7 +40,7 @@ static struct platform_device rtc_device = {
40/* 40/*
41 * Driver needs to know address, irq and flag pin. 41 * Driver needs to know address, irq and flag pin.
42 */ 42 */
43#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 43#if IS_ENABLED(CONFIG_SMC91X)
44#include <linux/smc91x.h> 44#include <linux/smc91x.h>
45 45
46static struct smc91x_platdata smc91x_info = { 46static struct smc91x_platdata smc91x_info = {
@@ -73,7 +73,7 @@ static struct platform_device smc91x_device = {
73}; 73};
74#endif 74#endif
75 75
76#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 76#if IS_ENABLED(CONFIG_USB_NET2272)
77static struct resource net2272_bfin_resources[] = { 77static struct resource net2272_bfin_resources[] = {
78 { 78 {
79 .start = 0x20300000, 79 .start = 0x20300000,
@@ -97,7 +97,7 @@ static struct platform_device net2272_bfin_device = {
97}; 97};
98#endif 98#endif
99 99
100#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE) 100#if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
101static struct mtd_partition stamp_partitions[] = { 101static struct mtd_partition stamp_partitions[] = {
102 { 102 {
103 .name = "bootloader(nor)", 103 .name = "bootloader(nor)",
@@ -147,7 +147,7 @@ static struct platform_device stamp_flash_device = {
147}; 147};
148#endif 148#endif
149 149
150#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 150#if IS_ENABLED(CONFIG_MTD_M25P80)
151static struct mtd_partition bfin_spi_flash_partitions[] = { 151static struct mtd_partition bfin_spi_flash_partitions[] = {
152 { 152 {
153 .name = "bootloader(spi)", 153 .name = "bootloader(spi)",
@@ -178,7 +178,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
178}; 178};
179#endif 179#endif
180 180
181#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 181#if IS_ENABLED(CONFIG_MMC_SPI)
182#define MMC_SPI_CARD_DETECT_INT IRQ_PF5 182#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
183static int bfin_mmc_spi_init(struct device *dev, 183static int bfin_mmc_spi_init(struct device *dev,
184 irqreturn_t (*detect_int)(int, void *), void *data) 184 irqreturn_t (*detect_int)(int, void *), void *data)
@@ -206,7 +206,7 @@ static struct bfin5xx_spi_chip mmc_spi_chip_info = {
206#endif 206#endif
207 207
208static struct spi_board_info bfin_spi_board_info[] __initdata = { 208static struct spi_board_info bfin_spi_board_info[] __initdata = {
209#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 209#if IS_ENABLED(CONFIG_MTD_M25P80)
210 { 210 {
211 /* the modalias must be the same as spi device driver name */ 211 /* the modalias must be the same as spi device driver name */
212 .modalias = "m25p80", /* Name of spi_driver for this device */ 212 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -219,8 +219,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
219 }, 219 },
220#endif 220#endif
221 221
222#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 222#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
223 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
224 { 223 {
225 .modalias = "ad1836", 224 .modalias = "ad1836",
226 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 225 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -231,7 +230,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
231 }, 230 },
232#endif 231#endif
233 232
234#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 233#if IS_ENABLED(CONFIG_SPI_SPIDEV)
235 { 234 {
236 .modalias = "spidev", 235 .modalias = "spidev",
237 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 236 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -239,7 +238,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
239 .chip_select = 1, 238 .chip_select = 1,
240 }, 239 },
241#endif 240#endif
242#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 241#if IS_ENABLED(CONFIG_MMC_SPI)
243 { 242 {
244 .modalias = "mmc_spi", 243 .modalias = "mmc_spi",
245 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 244 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -252,7 +251,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
252#endif 251#endif
253}; 252};
254 253
255#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 254#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
256/* SPI (0) */ 255/* SPI (0) */
257static struct resource bfin_spi0_resource[] = { 256static struct resource bfin_spi0_resource[] = {
258 [0] = { 257 [0] = {
@@ -290,7 +289,7 @@ static struct platform_device bfin_spi0_device = {
290}; 289};
291#endif /* spi master and devices */ 290#endif /* spi master and devices */
292 291
293#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 292#if IS_ENABLED(CONFIG_SERIAL_BFIN)
294#ifdef CONFIG_SERIAL_BFIN_UART0 293#ifdef CONFIG_SERIAL_BFIN_UART0
295static struct resource bfin_uart0_resources[] = { 294static struct resource bfin_uart0_resources[] = {
296 { 295 {
@@ -341,7 +340,7 @@ static struct platform_device bfin_uart0_device = {
341#endif 340#endif
342#endif 341#endif
343 342
344#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 343#if IS_ENABLED(CONFIG_BFIN_SIR)
345#ifdef CONFIG_BFIN_SIR0 344#ifdef CONFIG_BFIN_SIR0
346static struct resource bfin_sir0_resources[] = { 345static struct resource bfin_sir0_resources[] = {
347 { 346 {
@@ -370,8 +369,7 @@ static struct platform_device bfin_sir0_device = {
370#endif 369#endif
371#endif 370#endif
372 371
373#if defined(CONFIG_SERIAL_BFIN_SPORT) || \ 372#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
374 defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
375#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 373#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
376static struct resource bfin_sport0_uart_resources[] = { 374static struct resource bfin_sport0_uart_resources[] = {
377 { 375 {
@@ -442,7 +440,7 @@ static struct platform_device bfin_sport1_uart_device = {
442#endif 440#endif
443#endif 441#endif
444 442
445#if defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 443#if IS_ENABLED(CONFIG_BFIN_SPORT)
446static struct resource bfin_sport0_resources[] = { 444static struct resource bfin_sport0_resources[] = {
447 { 445 {
448 .start = SPORT0_TCR1, 446 .start = SPORT0_TCR1,
@@ -486,7 +484,7 @@ static struct platform_device bfin_sport0_device = {
486}; 484};
487#endif 485#endif
488 486
489#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 487#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
490#include <linux/input.h> 488#include <linux/input.h>
491#include <linux/gpio_keys.h> 489#include <linux/gpio_keys.h>
492 490
@@ -509,7 +507,7 @@ static struct platform_device bfin_device_gpiokeys = {
509}; 507};
510#endif 508#endif
511 509
512#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 510#if IS_ENABLED(CONFIG_I2C_GPIO)
513#include <linux/i2c-gpio.h> 511#include <linux/i2c-gpio.h>
514 512
515static struct i2c_gpio_platform_data i2c_gpio_data = { 513static struct i2c_gpio_platform_data i2c_gpio_data = {
@@ -530,29 +528,29 @@ static struct platform_device i2c_gpio_device = {
530#endif 528#endif
531 529
532static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 530static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
533#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 531#if IS_ENABLED(CONFIG_JOYSTICK_AD7142)
534 { 532 {
535 I2C_BOARD_INFO("ad7142_joystick", 0x2C), 533 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
536 .irq = 39, 534 .irq = 39,
537 }, 535 },
538#endif 536#endif
539#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 537#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
540 { 538 {
541 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 539 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
542 }, 540 },
543#endif 541#endif
544#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 542#if IS_ENABLED(CONFIG_INPUT_PCF8574)
545 { 543 {
546 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 544 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
547 .irq = 39, 545 .irq = 39,
548 }, 546 },
549#endif 547#endif
550#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 548#if IS_ENABLED(CONFIG_FB_BFIN_7393)
551 { 549 {
552 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 550 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
553 }, 551 },
554#endif 552#endif
555#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 553#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
556 { 554 {
557 I2C_BOARD_INFO("ad5252", 0x2f), 555 I2C_BOARD_INFO("ad5252", 0x2f),
558 }, 556 },
@@ -586,9 +584,8 @@ static struct platform_device bfin_dpmc = {
586 }, 584 },
587}; 585};
588 586
589#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) || \ 587#if IS_ENABLED(CONFIG_SND_BF5XX_I2S) || \
590 defined(CONFIG_SND_BF5XX_AC97) || \ 588 IS_ENABLED(CONFIG_SND_BF5XX_AC97)
591 defined(CONFIG_SND_BF5XX_AC97_MODULE)
592 589
593#include <asm/bfin_sport.h> 590#include <asm/bfin_sport.h>
594 591
@@ -640,22 +637,21 @@ static struct resource bfin_snd_resources[][4] = {
640}; 637};
641#endif 638#endif
642 639
643#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 640#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
644static struct platform_device bfin_i2s_pcm = { 641static struct platform_device bfin_i2s_pcm = {
645 .name = "bfin-i2s-pcm-audio", 642 .name = "bfin-i2s-pcm-audio",
646 .id = -1, 643 .id = -1,
647}; 644};
648#endif 645#endif
649 646
650#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 647#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
651static struct platform_device bfin_ac97_pcm = { 648static struct platform_device bfin_ac97_pcm = {
652 .name = "bfin-ac97-pcm-audio", 649 .name = "bfin-ac97-pcm-audio",
653 .id = -1, 650 .id = -1,
654}; 651};
655#endif 652#endif
656 653
657#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 654#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
658 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
659static const char * const ad1836_link[] = { 655static const char * const ad1836_link[] = {
660 "bfin-i2s.0", 656 "bfin-i2s.0",
661 "spi0.4", 657 "spi0.4",
@@ -669,8 +665,7 @@ static struct platform_device bfin_ad1836_machine = {
669}; 665};
670#endif 666#endif
671 667
672#if defined(CONFIG_SND_BF5XX_SOC_AD73311) || \ 668#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
673 defined(CONFIG_SND_BF5XX_SOC_AD73311_MODULE)
674static const unsigned ad73311_gpio[] = { 669static const unsigned ad73311_gpio[] = {
675 GPIO_PF4, 670 GPIO_PF4,
676}; 671};
@@ -684,22 +679,21 @@ static struct platform_device bfin_ad73311_machine = {
684}; 679};
685#endif 680#endif
686 681
687#if defined(CONFIG_SND_SOC_AD73311) || defined(CONFIG_SND_SOC_AD73311_MODULE) 682#if IS_ENABLED(CONFIG_SND_SOC_AD73311)
688static struct platform_device bfin_ad73311_codec_device = { 683static struct platform_device bfin_ad73311_codec_device = {
689 .name = "ad73311", 684 .name = "ad73311",
690 .id = -1, 685 .id = -1,
691}; 686};
692#endif 687#endif
693 688
694#if defined(CONFIG_SND_SOC_AD74111) || defined(CONFIG_SND_SOC_AD74111_MODULE) 689#if IS_ENABLED(CONFIG_SND_SOC_AD74111)
695static struct platform_device bfin_ad74111_codec_device = { 690static struct platform_device bfin_ad74111_codec_device = {
696 .name = "ad74111", 691 .name = "ad74111",
697 .id = -1, 692 .id = -1,
698}; 693};
699#endif 694#endif
700 695
701#if defined(CONFIG_SND_BF5XX_SOC_I2S) || \ 696#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
702 defined(CONFIG_SND_BF5XX_SOC_I2S_MODULE)
703static struct platform_device bfin_i2s = { 697static struct platform_device bfin_i2s = {
704 .name = "bfin-i2s", 698 .name = "bfin-i2s",
705 .id = CONFIG_SND_BF5XX_SPORT_NUM, 699 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -712,8 +706,7 @@ static struct platform_device bfin_i2s = {
712}; 706};
713#endif 707#endif
714 708
715#if defined(CONFIG_SND_BF5XX_SOC_AC97) || \ 709#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
716 defined(CONFIG_SND_BF5XX_SOC_AC97_MODULE)
717static struct platform_device bfin_ac97 = { 710static struct platform_device bfin_ac97 = {
718 .name = "bfin-ac97", 711 .name = "bfin-ac97",
719 .id = CONFIG_SND_BF5XX_SPORT_NUM, 712 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -730,36 +723,35 @@ static struct platform_device *stamp_devices[] __initdata = {
730 723
731 &bfin_dpmc, 724 &bfin_dpmc,
732 725
733#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 726#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
734 &rtc_device, 727 &rtc_device,
735#endif 728#endif
736 729
737#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 730#if IS_ENABLED(CONFIG_SMC91X)
738 &smc91x_device, 731 &smc91x_device,
739#endif 732#endif
740 733
741#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 734#if IS_ENABLED(CONFIG_USB_NET2272)
742 &net2272_bfin_device, 735 &net2272_bfin_device,
743#endif 736#endif
744 737
745#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 738#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
746 &bfin_spi0_device, 739 &bfin_spi0_device,
747#endif 740#endif
748 741
749#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 742#if IS_ENABLED(CONFIG_SERIAL_BFIN)
750#ifdef CONFIG_SERIAL_BFIN_UART0 743#ifdef CONFIG_SERIAL_BFIN_UART0
751 &bfin_uart0_device, 744 &bfin_uart0_device,
752#endif 745#endif
753#endif 746#endif
754 747
755#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 748#if IS_ENABLED(CONFIG_BFIN_SIR)
756#ifdef CONFIG_BFIN_SIR0 749#ifdef CONFIG_BFIN_SIR0
757 &bfin_sir0_device, 750 &bfin_sir0_device,
758#endif 751#endif
759#endif 752#endif
760 753
761#if defined(CONFIG_SERIAL_BFIN_SPORT) || \ 754#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
762 defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
763#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 755#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
764 &bfin_sport0_uart_device, 756 &bfin_sport0_uart_device,
765#endif 757#endif
@@ -768,58 +760,54 @@ static struct platform_device *stamp_devices[] __initdata = {
768#endif 760#endif
769#endif 761#endif
770 762
771#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 763#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
772 &bfin_device_gpiokeys, 764 &bfin_device_gpiokeys,
773#endif 765#endif
774 766
775#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 767#if IS_ENABLED(CONFIG_I2C_GPIO)
776 &i2c_gpio_device, 768 &i2c_gpio_device,
777#endif 769#endif
778 770
779#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE) 771#if IS_ENABLED(CONFIG_MTD_BFIN_ASYNC)
780 &stamp_flash_device, 772 &stamp_flash_device,
781#endif 773#endif
782 774
783#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 775#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
784 &bfin_i2s_pcm, 776 &bfin_i2s_pcm,
785#endif 777#endif
786 778
787#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 779#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
788 &bfin_ac97_pcm, 780 &bfin_ac97_pcm,
789#endif 781#endif
790 782
791#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 783#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
792 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
793 &bfin_ad1836_machine, 784 &bfin_ad1836_machine,
794#endif 785#endif
795 786
796#if defined(CONFIG_SND_BF5XX_SOC_AD73311) || \ 787#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
797 defined(CONFIG_SND_BF5XX_SOC_AD73311_MODULE)
798 &bfin_ad73311_machine, 788 &bfin_ad73311_machine,
799#endif 789#endif
800 790
801#if defined(CONFIG_SND_SOC_AD73311) || defined(CONFIG_SND_SOC_AD73311_MODULE) 791#if IS_ENABLED(CONFIG_SND_SOC_AD73311)
802 &bfin_ad73311_codec_device, 792 &bfin_ad73311_codec_device,
803#endif 793#endif
804 794
805#if defined(CONFIG_SND_SOC_AD74111) || defined(CONFIG_SND_SOC_AD74111_MODULE) 795#if IS_ENABLED(CONFIG_SND_SOC_AD74111)
806 &bfin_ad74111_codec_device, 796 &bfin_ad74111_codec_device,
807#endif 797#endif
808 798
809#if defined(CONFIG_SND_BF5XX_SOC_I2S) || \ 799#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
810 defined(CONFIG_SND_BF5XX_SOC_I2S_MODULE)
811 &bfin_i2s, 800 &bfin_i2s,
812#endif 801#endif
813 802
814#if defined(CONFIG_SND_BF5XX_SOC_AC97) || \ 803#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
815 defined(CONFIG_SND_BF5XX_SOC_AC97_MODULE)
816 &bfin_ac97, 804 &bfin_ac97,
817#endif 805#endif
818}; 806};
819 807
820static int __init net2272_init(void) 808static int __init net2272_init(void)
821{ 809{
822#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 810#if IS_ENABLED(CONFIG_USB_NET2272)
823 int ret; 811 int ret;
824 812
825 /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */ 813 /* Set PF0 to 0, PF1 to 1 make /AMS3 work properly */
@@ -865,7 +853,7 @@ static int __init stamp_init(void)
865 if (ret < 0) 853 if (ret < 0)
866 return ret; 854 return ret;
867 855
868#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 856#if IS_ENABLED(CONFIG_SMC91X)
869 /* 857 /*
870 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC. 858 * setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC.
871 * the bfin-async-map driver takes care of flipping between 859 * the bfin-async-map driver takes care of flipping between
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537e.c b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
index 85e4fc9f9c22..c65c6dbda3da 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537e.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
@@ -16,7 +16,7 @@
16#include <linux/mtd/physmap.h> 16#include <linux/mtd/physmap.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <linux/spi/flash.h> 18#include <linux/spi/flash.h>
19#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 19#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
20#include <linux/usb/isp1362.h> 20#include <linux/usb/isp1362.h>
21#endif 21#endif
22#include <linux/ata_platform.h> 22#include <linux/ata_platform.h>
@@ -32,10 +32,10 @@
32 */ 32 */
33const char bfin_board_name[] = "Bluetechnix CM BF537E"; 33const char bfin_board_name[] = "Bluetechnix CM BF537E";
34 34
35#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 35#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
36/* all SPI peripherals info goes here */ 36/* all SPI peripherals info goes here */
37 37
38#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 38#if IS_ENABLED(CONFIG_MTD_M25P80)
39static struct mtd_partition bfin_spi_flash_partitions[] = { 39static struct mtd_partition bfin_spi_flash_partitions[] = {
40 { 40 {
41 .name = "bootloader(spi)", 41 .name = "bootloader(spi)",
@@ -66,14 +66,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
66}; 66};
67#endif 67#endif
68 68
69#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 69#if IS_ENABLED(CONFIG_MMC_SPI)
70static struct bfin5xx_spi_chip mmc_spi_chip_info = { 70static struct bfin5xx_spi_chip mmc_spi_chip_info = {
71 .enable_dma = 0, 71 .enable_dma = 0,
72}; 72};
73#endif 73#endif
74 74
75static struct spi_board_info bfin_spi_board_info[] __initdata = { 75static struct spi_board_info bfin_spi_board_info[] __initdata = {
76#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 76#if IS_ENABLED(CONFIG_MTD_M25P80)
77 { 77 {
78 /* the modalias must be the same as spi device driver name */ 78 /* the modalias must be the same as spi device driver name */
79 .modalias = "m25p80", /* Name of spi_driver for this device */ 79 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -86,7 +86,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
86 }, 86 },
87#endif 87#endif
88 88
89#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 89#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
90 { 90 {
91 .modalias = "ad183x", 91 .modalias = "ad183x",
92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -95,7 +95,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
95 }, 95 },
96#endif 96#endif
97 97
98#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 98#if IS_ENABLED(CONFIG_MMC_SPI)
99 { 99 {
100 .modalias = "mmc_spi", 100 .modalias = "mmc_spi",
101 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 101 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -144,7 +144,7 @@ static struct platform_device bfin_spi0_device = {
144}; 144};
145#endif /* spi master and devices */ 145#endif /* spi master and devices */
146 146
147#if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE) 147#if IS_ENABLED(CONFIG_SPI_BFIN_SPORT)
148 148
149/* SPORT SPI controller data */ 149/* SPORT SPI controller data */
150static struct bfin5xx_spi_master bfin_sport_spi0_info = { 150static struct bfin5xx_spi_master bfin_sport_spi0_info = {
@@ -209,20 +209,20 @@ static struct platform_device bfin_sport_spi1_device = {
209 209
210#endif /* sport spi master and devices */ 210#endif /* sport spi master and devices */
211 211
212#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 212#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
213static struct platform_device rtc_device = { 213static struct platform_device rtc_device = {
214 .name = "rtc-bfin", 214 .name = "rtc-bfin",
215 .id = -1, 215 .id = -1,
216}; 216};
217#endif 217#endif
218 218
219#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 219#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
220static struct platform_device hitachi_fb_device = { 220static struct platform_device hitachi_fb_device = {
221 .name = "hitachi-tx09", 221 .name = "hitachi-tx09",
222}; 222};
223#endif 223#endif
224 224
225#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 225#if IS_ENABLED(CONFIG_SMC91X)
226#include <linux/smc91x.h> 226#include <linux/smc91x.h>
227 227
228static struct smc91x_platdata smc91x_info = { 228static struct smc91x_platdata smc91x_info = {
@@ -254,7 +254,7 @@ static struct platform_device smc91x_device = {
254}; 254};
255#endif 255#endif
256 256
257#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 257#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
258static struct resource isp1362_hcd_resources[] = { 258static struct resource isp1362_hcd_resources[] = {
259 { 259 {
260 .start = 0x20308000, 260 .start = 0x20308000,
@@ -293,7 +293,7 @@ static struct platform_device isp1362_hcd_device = {
293}; 293};
294#endif 294#endif
295 295
296#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 296#if IS_ENABLED(CONFIG_USB_NET2272)
297static struct resource net2272_bfin_resources[] = { 297static struct resource net2272_bfin_resources[] = {
298 { 298 {
299 .start = 0x20300000, 299 .start = 0x20300000,
@@ -314,7 +314,7 @@ static struct platform_device net2272_bfin_device = {
314}; 314};
315#endif 315#endif
316 316
317#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 317#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
318static struct mtd_partition cm_partitions[] = { 318static struct mtd_partition cm_partitions[] = {
319 { 319 {
320 .name = "bootloader(nor)", 320 .name = "bootloader(nor)",
@@ -363,7 +363,7 @@ static struct platform_device cm_flash_device = {
363}; 363};
364#endif 364#endif
365 365
366#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 366#if IS_ENABLED(CONFIG_SERIAL_BFIN)
367#ifdef CONFIG_SERIAL_BFIN_UART0 367#ifdef CONFIG_SERIAL_BFIN_UART0
368static struct resource bfin_uart0_resources[] = { 368static struct resource bfin_uart0_resources[] = {
369 { 369 {
@@ -498,7 +498,7 @@ static struct platform_device bfin_uart1_device = {
498#endif 498#endif
499#endif 499#endif
500 500
501#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 501#if IS_ENABLED(CONFIG_BFIN_SIR)
502#ifdef CONFIG_BFIN_SIR0 502#ifdef CONFIG_BFIN_SIR0
503static struct resource bfin_sir0_resources[] = { 503static struct resource bfin_sir0_resources[] = {
504 { 504 {
@@ -551,7 +551,7 @@ static struct platform_device bfin_sir1_device = {
551#endif 551#endif
552#endif 552#endif
553 553
554#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 554#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
555static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 555static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
556 556
557static struct resource bfin_twi0_resource[] = { 557static struct resource bfin_twi0_resource[] = {
@@ -578,14 +578,14 @@ static struct platform_device i2c_bfin_twi_device = {
578}; 578};
579#endif 579#endif
580 580
581#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) \ 581#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT) \
582|| defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 582|| IS_ENABLED(CONFIG_BFIN_SPORT)
583unsigned short bfin_sport0_peripherals[] = { 583unsigned short bfin_sport0_peripherals[] = {
584 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, 584 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
585 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0 585 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
586}; 586};
587#endif 587#endif
588#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 588#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
589#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 589#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
590static struct resource bfin_sport0_uart_resources[] = { 590static struct resource bfin_sport0_uart_resources[] = {
591 { 591 {
@@ -650,7 +650,7 @@ static struct platform_device bfin_sport1_uart_device = {
650}; 650};
651#endif 651#endif
652#endif 652#endif
653#if defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 653#if IS_ENABLED(CONFIG_BFIN_SPORT)
654static struct resource bfin_sport0_resources[] = { 654static struct resource bfin_sport0_resources[] = {
655 { 655 {
656 .start = SPORT0_TCR1, 656 .start = SPORT0_TCR1,
@@ -694,7 +694,7 @@ static struct platform_device bfin_sport0_device = {
694}; 694};
695#endif 695#endif
696 696
697#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 697#if IS_ENABLED(CONFIG_BFIN_MAC)
698#include <linux/bfin_mac.h> 698#include <linux/bfin_mac.h>
699static const unsigned short bfin_mac_peripherals[] = P_MII0; 699static const unsigned short bfin_mac_peripherals[] = P_MII0;
700 700
@@ -727,7 +727,7 @@ static struct platform_device bfin_mac_device = {
727}; 727};
728#endif 728#endif
729 729
730#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 730#if IS_ENABLED(CONFIG_PATA_PLATFORM)
731#define PATA_INT IRQ_PF14 731#define PATA_INT IRQ_PF14
732 732
733static struct pata_platform_info bfin_pata_platform_data = { 733static struct pata_platform_info bfin_pata_platform_data = {
@@ -795,19 +795,19 @@ static struct platform_device *cm_bf537e_devices[] __initdata = {
795 795
796 &bfin_dpmc, 796 &bfin_dpmc,
797 797
798#if defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 798#if IS_ENABLED(CONFIG_BFIN_SPORT)
799 &bfin_sport0_device, 799 &bfin_sport0_device,
800#endif 800#endif
801 801
802#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 802#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
803 &hitachi_fb_device, 803 &hitachi_fb_device,
804#endif 804#endif
805 805
806#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 806#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
807 &rtc_device, 807 &rtc_device,
808#endif 808#endif
809 809
810#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 810#if IS_ENABLED(CONFIG_SERIAL_BFIN)
811#ifdef CONFIG_SERIAL_BFIN_UART0 811#ifdef CONFIG_SERIAL_BFIN_UART0
812 &bfin_uart0_device, 812 &bfin_uart0_device,
813#endif 813#endif
@@ -816,7 +816,7 @@ static struct platform_device *cm_bf537e_devices[] __initdata = {
816#endif 816#endif
817#endif 817#endif
818 818
819#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 819#if IS_ENABLED(CONFIG_BFIN_SIR)
820#ifdef CONFIG_BFIN_SIR0 820#ifdef CONFIG_BFIN_SIR0
821 &bfin_sir0_device, 821 &bfin_sir0_device,
822#endif 822#endif
@@ -825,11 +825,11 @@ static struct platform_device *cm_bf537e_devices[] __initdata = {
825#endif 825#endif
826#endif 826#endif
827 827
828#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 828#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
829 &i2c_bfin_twi_device, 829 &i2c_bfin_twi_device,
830#endif 830#endif
831 831
832#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 832#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
833#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 833#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
834 &bfin_sport0_uart_device, 834 &bfin_sport0_uart_device,
835#endif 835#endif
@@ -838,44 +838,44 @@ static struct platform_device *cm_bf537e_devices[] __initdata = {
838#endif 838#endif
839#endif 839#endif
840 840
841#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 841#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
842 &isp1362_hcd_device, 842 &isp1362_hcd_device,
843#endif 843#endif
844 844
845#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 845#if IS_ENABLED(CONFIG_SMC91X)
846 &smc91x_device, 846 &smc91x_device,
847#endif 847#endif
848 848
849#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 849#if IS_ENABLED(CONFIG_BFIN_MAC)
850 &bfin_mii_bus, 850 &bfin_mii_bus,
851 &bfin_mac_device, 851 &bfin_mac_device,
852#endif 852#endif
853 853
854#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 854#if IS_ENABLED(CONFIG_USB_NET2272)
855 &net2272_bfin_device, 855 &net2272_bfin_device,
856#endif 856#endif
857 857
858#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 858#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
859 &bfin_spi0_device, 859 &bfin_spi0_device,
860#endif 860#endif
861 861
862#if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE) 862#if IS_ENABLED(CONFIG_SPI_BFIN_SPORT)
863 &bfin_sport_spi0_device, 863 &bfin_sport_spi0_device,
864 &bfin_sport_spi1_device, 864 &bfin_sport_spi1_device,
865#endif 865#endif
866 866
867#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 867#if IS_ENABLED(CONFIG_PATA_PLATFORM)
868 &bfin_pata_device, 868 &bfin_pata_device,
869#endif 869#endif
870 870
871#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 871#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
872 &cm_flash_device, 872 &cm_flash_device,
873#endif 873#endif
874}; 874};
875 875
876static int __init net2272_init(void) 876static int __init net2272_init(void)
877{ 877{
878#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 878#if IS_ENABLED(CONFIG_USB_NET2272)
879 int ret; 879 int ret;
880 880
881 ret = gpio_request(GPIO_PG14, "net2272"); 881 ret = gpio_request(GPIO_PG14, "net2272");
@@ -895,11 +895,11 @@ static int __init cm_bf537e_init(void)
895{ 895{
896 printk(KERN_INFO "%s(): registering device resources\n", __func__); 896 printk(KERN_INFO "%s(): registering device resources\n", __func__);
897 platform_add_devices(cm_bf537e_devices, ARRAY_SIZE(cm_bf537e_devices)); 897 platform_add_devices(cm_bf537e_devices, ARRAY_SIZE(cm_bf537e_devices));
898#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 898#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
899 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 899 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
900#endif 900#endif
901 901
902#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 902#if IS_ENABLED(CONFIG_PATA_PLATFORM)
903 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN); 903 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
904#endif 904#endif
905 905
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
index 0143d8bef909..af58454b4bff 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537u.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
@@ -16,7 +16,7 @@
16#include <linux/mtd/physmap.h> 16#include <linux/mtd/physmap.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <linux/spi/flash.h> 18#include <linux/spi/flash.h>
19#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 19#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
20#include <linux/usb/isp1362.h> 20#include <linux/usb/isp1362.h>
21#endif 21#endif
22#include <linux/ata_platform.h> 22#include <linux/ata_platform.h>
@@ -32,10 +32,10 @@
32 */ 32 */
33const char bfin_board_name[] = "Bluetechnix CM BF537U"; 33const char bfin_board_name[] = "Bluetechnix CM BF537U";
34 34
35#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 35#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
36/* all SPI peripherals info goes here */ 36/* all SPI peripherals info goes here */
37 37
38#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 38#if IS_ENABLED(CONFIG_MTD_M25P80)
39static struct mtd_partition bfin_spi_flash_partitions[] = { 39static struct mtd_partition bfin_spi_flash_partitions[] = {
40 { 40 {
41 .name = "bootloader(spi)", 41 .name = "bootloader(spi)",
@@ -66,14 +66,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
66}; 66};
67#endif 67#endif
68 68
69#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 69#if IS_ENABLED(CONFIG_MMC_SPI)
70static struct bfin5xx_spi_chip mmc_spi_chip_info = { 70static struct bfin5xx_spi_chip mmc_spi_chip_info = {
71 .enable_dma = 0, 71 .enable_dma = 0,
72}; 72};
73#endif 73#endif
74 74
75static struct spi_board_info bfin_spi_board_info[] __initdata = { 75static struct spi_board_info bfin_spi_board_info[] __initdata = {
76#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 76#if IS_ENABLED(CONFIG_MTD_M25P80)
77 { 77 {
78 /* the modalias must be the same as spi device driver name */ 78 /* the modalias must be the same as spi device driver name */
79 .modalias = "m25p80", /* Name of spi_driver for this device */ 79 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -86,7 +86,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
86 }, 86 },
87#endif 87#endif
88 88
89#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 89#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
90 { 90 {
91 .modalias = "ad183x", 91 .modalias = "ad183x",
92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -95,7 +95,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
95 }, 95 },
96#endif 96#endif
97 97
98#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 98#if IS_ENABLED(CONFIG_MMC_SPI)
99 { 99 {
100 .modalias = "mmc_spi", 100 .modalias = "mmc_spi",
101 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 101 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -144,20 +144,20 @@ static struct platform_device bfin_spi0_device = {
144}; 144};
145#endif /* spi master and devices */ 145#endif /* spi master and devices */
146 146
147#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 147#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
148static struct platform_device rtc_device = { 148static struct platform_device rtc_device = {
149 .name = "rtc-bfin", 149 .name = "rtc-bfin",
150 .id = -1, 150 .id = -1,
151}; 151};
152#endif 152#endif
153 153
154#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 154#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
155static struct platform_device hitachi_fb_device = { 155static struct platform_device hitachi_fb_device = {
156 .name = "hitachi-tx09", 156 .name = "hitachi-tx09",
157}; 157};
158#endif 158#endif
159 159
160#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 160#if IS_ENABLED(CONFIG_SMC91X)
161#include <linux/smc91x.h> 161#include <linux/smc91x.h>
162 162
163static struct smc91x_platdata smc91x_info = { 163static struct smc91x_platdata smc91x_info = {
@@ -189,7 +189,7 @@ static struct platform_device smc91x_device = {
189}; 189};
190#endif 190#endif
191 191
192#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 192#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
193static struct resource isp1362_hcd_resources[] = { 193static struct resource isp1362_hcd_resources[] = {
194 { 194 {
195 .start = 0x20308000, 195 .start = 0x20308000,
@@ -228,7 +228,7 @@ static struct platform_device isp1362_hcd_device = {
228}; 228};
229#endif 229#endif
230 230
231#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 231#if IS_ENABLED(CONFIG_USB_NET2272)
232static struct resource net2272_bfin_resources[] = { 232static struct resource net2272_bfin_resources[] = {
233 { 233 {
234 .start = 0x20200000, 234 .start = 0x20200000,
@@ -249,7 +249,7 @@ static struct platform_device net2272_bfin_device = {
249}; 249};
250#endif 250#endif
251 251
252#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 252#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
253static struct mtd_partition cm_partitions[] = { 253static struct mtd_partition cm_partitions[] = {
254 { 254 {
255 .name = "bootloader(nor)", 255 .name = "bootloader(nor)",
@@ -298,7 +298,7 @@ static struct platform_device cm_flash_device = {
298}; 298};
299#endif 299#endif
300 300
301#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 301#if IS_ENABLED(CONFIG_SERIAL_BFIN)
302#ifdef CONFIG_SERIAL_BFIN_UART0 302#ifdef CONFIG_SERIAL_BFIN_UART0
303static struct resource bfin_uart0_resources[] = { 303static struct resource bfin_uart0_resources[] = {
304 { 304 {
@@ -397,7 +397,7 @@ static struct platform_device bfin_uart1_device = {
397#endif 397#endif
398#endif 398#endif
399 399
400#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 400#if IS_ENABLED(CONFIG_BFIN_SIR)
401#ifdef CONFIG_BFIN_SIR0 401#ifdef CONFIG_BFIN_SIR0
402static struct resource bfin_sir0_resources[] = { 402static struct resource bfin_sir0_resources[] = {
403 { 403 {
@@ -450,7 +450,7 @@ static struct platform_device bfin_sir1_device = {
450#endif 450#endif
451#endif 451#endif
452 452
453#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 453#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
454static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 454static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
455 455
456static struct resource bfin_twi0_resource[] = { 456static struct resource bfin_twi0_resource[] = {
@@ -477,7 +477,7 @@ static struct platform_device i2c_bfin_twi_device = {
477}; 477};
478#endif 478#endif
479 479
480#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 480#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
481#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 481#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
482static struct resource bfin_sport0_uart_resources[] = { 482static struct resource bfin_sport0_uart_resources[] = {
483 { 483 {
@@ -548,7 +548,7 @@ static struct platform_device bfin_sport1_uart_device = {
548#endif 548#endif
549#endif 549#endif
550 550
551#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 551#if IS_ENABLED(CONFIG_BFIN_MAC)
552#include <linux/bfin_mac.h> 552#include <linux/bfin_mac.h>
553static const unsigned short bfin_mac_peripherals[] = P_MII0; 553static const unsigned short bfin_mac_peripherals[] = P_MII0;
554 554
@@ -581,7 +581,7 @@ static struct platform_device bfin_mac_device = {
581}; 581};
582#endif 582#endif
583 583
584#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 584#if IS_ENABLED(CONFIG_PATA_PLATFORM)
585#define PATA_INT IRQ_PF14 585#define PATA_INT IRQ_PF14
586 586
587static struct pata_platform_info bfin_pata_platform_data = { 587static struct pata_platform_info bfin_pata_platform_data = {
@@ -649,15 +649,15 @@ static struct platform_device *cm_bf537u_devices[] __initdata = {
649 649
650 &bfin_dpmc, 650 &bfin_dpmc,
651 651
652#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 652#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
653 &hitachi_fb_device, 653 &hitachi_fb_device,
654#endif 654#endif
655 655
656#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 656#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
657 &rtc_device, 657 &rtc_device,
658#endif 658#endif
659 659
660#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 660#if IS_ENABLED(CONFIG_SERIAL_BFIN)
661#ifdef CONFIG_SERIAL_BFIN_UART0 661#ifdef CONFIG_SERIAL_BFIN_UART0
662 &bfin_uart0_device, 662 &bfin_uart0_device,
663#endif 663#endif
@@ -666,7 +666,7 @@ static struct platform_device *cm_bf537u_devices[] __initdata = {
666#endif 666#endif
667#endif 667#endif
668 668
669#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 669#if IS_ENABLED(CONFIG_BFIN_SIR)
670#ifdef CONFIG_BFIN_SIR0 670#ifdef CONFIG_BFIN_SIR0
671 &bfin_sir0_device, 671 &bfin_sir0_device,
672#endif 672#endif
@@ -675,11 +675,11 @@ static struct platform_device *cm_bf537u_devices[] __initdata = {
675#endif 675#endif
676#endif 676#endif
677 677
678#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 678#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
679 &i2c_bfin_twi_device, 679 &i2c_bfin_twi_device,
680#endif 680#endif
681 681
682#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 682#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
683#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 683#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
684 &bfin_sport0_uart_device, 684 &bfin_sport0_uart_device,
685#endif 685#endif
@@ -688,39 +688,39 @@ static struct platform_device *cm_bf537u_devices[] __initdata = {
688#endif 688#endif
689#endif 689#endif
690 690
691#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 691#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
692 &isp1362_hcd_device, 692 &isp1362_hcd_device,
693#endif 693#endif
694 694
695#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 695#if IS_ENABLED(CONFIG_SMC91X)
696 &smc91x_device, 696 &smc91x_device,
697#endif 697#endif
698 698
699#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 699#if IS_ENABLED(CONFIG_BFIN_MAC)
700 &bfin_mii_bus, 700 &bfin_mii_bus,
701 &bfin_mac_device, 701 &bfin_mac_device,
702#endif 702#endif
703 703
704#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 704#if IS_ENABLED(CONFIG_USB_NET2272)
705 &net2272_bfin_device, 705 &net2272_bfin_device,
706#endif 706#endif
707 707
708#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 708#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
709 &bfin_spi0_device, 709 &bfin_spi0_device,
710#endif 710#endif
711 711
712#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 712#if IS_ENABLED(CONFIG_PATA_PLATFORM)
713 &bfin_pata_device, 713 &bfin_pata_device,
714#endif 714#endif
715 715
716#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 716#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
717 &cm_flash_device, 717 &cm_flash_device,
718#endif 718#endif
719}; 719};
720 720
721static int __init net2272_init(void) 721static int __init net2272_init(void)
722{ 722{
723#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 723#if IS_ENABLED(CONFIG_USB_NET2272)
724 int ret; 724 int ret;
725 725
726 ret = gpio_request(GPIO_PH15, driver_name); 726 ret = gpio_request(GPIO_PH15, driver_name);
@@ -752,11 +752,11 @@ static int __init cm_bf537u_init(void)
752{ 752{
753 printk(KERN_INFO "%s(): registering device resources\n", __func__); 753 printk(KERN_INFO "%s(): registering device resources\n", __func__);
754 platform_add_devices(cm_bf537u_devices, ARRAY_SIZE(cm_bf537u_devices)); 754 platform_add_devices(cm_bf537u_devices, ARRAY_SIZE(cm_bf537u_devices));
755#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 755#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
756 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 756 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
757#endif 757#endif
758 758
759#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 759#if IS_ENABLED(CONFIG_PATA_PLATFORM)
760 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN); 760 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
761#endif 761#endif
762 762
diff --git a/arch/blackfin/mach-bf537/boards/dnp5370.c b/arch/blackfin/mach-bf537/boards/dnp5370.c
index 8bbf0a23fd49..e79b3b810c39 100644
--- a/arch/blackfin/mach-bf537/boards/dnp5370.c
+++ b/arch/blackfin/mach-bf537/boards/dnp5370.c
@@ -41,14 +41,14 @@ const char bfin_board_name[] = "DNP/5370";
41#define FLASH_MAC 0x202f0000 41#define FLASH_MAC 0x202f0000
42#define CONFIG_MTD_PHYSMAP_LEN 0x300000 42#define CONFIG_MTD_PHYSMAP_LEN 0x300000
43 43
44#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 44#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
45static struct platform_device rtc_device = { 45static struct platform_device rtc_device = {
46 .name = "rtc-bfin", 46 .name = "rtc-bfin",
47 .id = -1, 47 .id = -1,
48}; 48};
49#endif 49#endif
50 50
51#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 51#if IS_ENABLED(CONFIG_BFIN_MAC)
52#include <linux/bfin_mac.h> 52#include <linux/bfin_mac.h>
53static const unsigned short bfin_mac_peripherals[] = P_RMII0; 53static const unsigned short bfin_mac_peripherals[] = P_RMII0;
54 54
@@ -81,7 +81,7 @@ static struct platform_device bfin_mac_device = {
81}; 81};
82#endif 82#endif
83 83
84#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 84#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
85static struct mtd_partition asmb_flash_partitions[] = { 85static struct mtd_partition asmb_flash_partitions[] = {
86 { 86 {
87 .name = "bootloader(nor)", 87 .name = "bootloader(nor)",
@@ -125,9 +125,9 @@ static struct platform_device asmb_flash_device = {
125}; 125};
126#endif 126#endif
127 127
128#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 128#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
129 129
130#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 130#if IS_ENABLED(CONFIG_MMC_SPI)
131 131
132static struct bfin5xx_spi_chip mmc_spi_chip_info = { 132static struct bfin5xx_spi_chip mmc_spi_chip_info = {
133 .enable_dma = 0, /* use no dma transfer with this chip*/ 133 .enable_dma = 0, /* use no dma transfer with this chip*/
@@ -135,7 +135,7 @@ static struct bfin5xx_spi_chip mmc_spi_chip_info = {
135 135
136#endif 136#endif
137 137
138#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE) 138#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
139/* This mapping is for at45db642 it has 1056 page size, 139/* This mapping is for at45db642 it has 1056 page size,
140 * partition size and offset should be page aligned 140 * partition size and offset should be page aligned
141 */ 141 */
@@ -166,7 +166,7 @@ static struct bfin5xx_spi_chip spi_dataflash_chip_info = {
166 166
167static struct spi_board_info bfin_spi_board_info[] __initdata = { 167static struct spi_board_info bfin_spi_board_info[] __initdata = {
168/* SD/MMC card reader at SPI bus */ 168/* SD/MMC card reader at SPI bus */
169#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 169#if IS_ENABLED(CONFIG_MMC_SPI)
170 { 170 {
171 .modalias = "mmc_spi", 171 .modalias = "mmc_spi",
172 .max_speed_hz = 20000000, 172 .max_speed_hz = 20000000,
@@ -178,7 +178,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
178#endif 178#endif
179 179
180/* 8 Megabyte Atmel NOR flash chip at SPI bus */ 180/* 8 Megabyte Atmel NOR flash chip at SPI bus */
181#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE) 181#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
182 { 182 {
183 .modalias = "mtd_dataflash", 183 .modalias = "mtd_dataflash",
184 .max_speed_hz = 16700000, 184 .max_speed_hz = 16700000,
@@ -228,7 +228,7 @@ static struct platform_device spi_bfin_master_device = {
228}; 228};
229#endif 229#endif
230 230
231#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 231#if IS_ENABLED(CONFIG_SERIAL_BFIN)
232#ifdef CONFIG_SERIAL_BFIN_UART0 232#ifdef CONFIG_SERIAL_BFIN_UART0
233static struct resource bfin_uart0_resources[] = { 233static struct resource bfin_uart0_resources[] = {
234 { 234 {
@@ -328,7 +328,7 @@ static struct platform_device bfin_uart1_device = {
328#endif 328#endif
329#endif 329#endif
330 330
331#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 331#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
332static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 332static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
333 333
334static struct resource bfin_twi0_resource[] = { 334static struct resource bfin_twi0_resource[] = {
@@ -357,7 +357,7 @@ static struct platform_device i2c_bfin_twi_device = {
357 357
358static struct platform_device *dnp5370_devices[] __initdata = { 358static struct platform_device *dnp5370_devices[] __initdata = {
359 359
360#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 360#if IS_ENABLED(CONFIG_SERIAL_BFIN)
361#ifdef CONFIG_SERIAL_BFIN_UART0 361#ifdef CONFIG_SERIAL_BFIN_UART0
362 &bfin_uart0_device, 362 &bfin_uart0_device,
363#endif 363#endif
@@ -366,24 +366,24 @@ static struct platform_device *dnp5370_devices[] __initdata = {
366#endif 366#endif
367#endif 367#endif
368 368
369#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 369#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
370 &asmb_flash_device, 370 &asmb_flash_device,
371#endif 371#endif
372 372
373#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 373#if IS_ENABLED(CONFIG_BFIN_MAC)
374 &bfin_mii_bus, 374 &bfin_mii_bus,
375 &bfin_mac_device, 375 &bfin_mac_device,
376#endif 376#endif
377 377
378#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 378#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
379 &spi_bfin_master_device, 379 &spi_bfin_master_device,
380#endif 380#endif
381 381
382#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 382#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
383 &i2c_bfin_twi_device, 383 &i2c_bfin_twi_device,
384#endif 384#endif
385 385
386#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 386#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
387 &rtc_device, 387 &rtc_device,
388#endif 388#endif
389 389
diff --git a/arch/blackfin/mach-bf537/boards/minotaur.c b/arch/blackfin/mach-bf537/boards/minotaur.c
index a10f90e444bc..dd7bda07bf90 100644
--- a/arch/blackfin/mach-bf537/boards/minotaur.c
+++ b/arch/blackfin/mach-bf537/boards/minotaur.c
@@ -13,7 +13,7 @@
13#include <linux/mtd/partitions.h> 13#include <linux/mtd/partitions.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/spi/flash.h> 15#include <linux/spi/flash.h>
16#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 16#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
17#include <linux/usb/isp1362.h> 17#include <linux/usb/isp1362.h>
18#endif 18#endif
19#include <linux/ata_platform.h> 19#include <linux/ata_platform.h>
@@ -31,7 +31,7 @@
31 */ 31 */
32const char bfin_board_name[] = "CamSig Minotaur BF537"; 32const char bfin_board_name[] = "CamSig Minotaur BF537";
33 33
34#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 34#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
35static struct resource bfin_pcmcia_cf_resources[] = { 35static struct resource bfin_pcmcia_cf_resources[] = {
36 { 36 {
37 .start = 0x20310000, /* IO PORT */ 37 .start = 0x20310000, /* IO PORT */
@@ -60,14 +60,14 @@ static struct platform_device bfin_pcmcia_cf_device = {
60}; 60};
61#endif 61#endif
62 62
63#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 63#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
64static struct platform_device rtc_device = { 64static struct platform_device rtc_device = {
65 .name = "rtc-bfin", 65 .name = "rtc-bfin",
66 .id = -1, 66 .id = -1,
67}; 67};
68#endif 68#endif
69 69
70#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 70#if IS_ENABLED(CONFIG_BFIN_MAC)
71#include <linux/bfin_mac.h> 71#include <linux/bfin_mac.h>
72static const unsigned short bfin_mac_peripherals[] = P_MII0; 72static const unsigned short bfin_mac_peripherals[] = P_MII0;
73 73
@@ -100,7 +100,7 @@ static struct platform_device bfin_mac_device = {
100}; 100};
101#endif 101#endif
102 102
103#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 103#if IS_ENABLED(CONFIG_USB_NET2272)
104static struct resource net2272_bfin_resources[] = { 104static struct resource net2272_bfin_resources[] = {
105 { 105 {
106 .start = 0x20300000, 106 .start = 0x20300000,
@@ -121,11 +121,10 @@ static struct platform_device net2272_bfin_device = {
121}; 121};
122#endif 122#endif
123 123
124#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 124#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
125/* all SPI peripherals info goes here */ 125/* all SPI peripherals info goes here */
126 126
127#if defined(CONFIG_MTD_M25P80) \ 127#if IS_ENABLED(CONFIG_MTD_M25P80)
128 || defined(CONFIG_MTD_M25P80_MODULE)
129 128
130/* Partition sizes */ 129/* Partition sizes */
131#define FLASH_SIZE 0x00400000 130#define FLASH_SIZE 0x00400000
@@ -162,15 +161,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
162}; 161};
163#endif 162#endif
164 163
165#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 164#if IS_ENABLED(CONFIG_MMC_SPI)
166static struct bfin5xx_spi_chip mmc_spi_chip_info = { 165static struct bfin5xx_spi_chip mmc_spi_chip_info = {
167 .enable_dma = 0, 166 .enable_dma = 0,
168}; 167};
169#endif 168#endif
170 169
171static struct spi_board_info bfin_spi_board_info[] __initdata = { 170static struct spi_board_info bfin_spi_board_info[] __initdata = {
172#if defined(CONFIG_MTD_M25P80) \ 171#if IS_ENABLED(CONFIG_MTD_M25P80)
173 || defined(CONFIG_MTD_M25P80_MODULE)
174 { 172 {
175 /* the modalias must be the same as spi device driver name */ 173 /* the modalias must be the same as spi device driver name */
176 .modalias = "m25p80", /* Name of spi_driver for this device */ 174 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -183,7 +181,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
183 }, 181 },
184#endif 182#endif
185 183
186#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 184#if IS_ENABLED(CONFIG_MMC_SPI)
187 { 185 {
188 .modalias = "mmc_spi", 186 .modalias = "mmc_spi",
189 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */ 187 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
@@ -231,7 +229,7 @@ static struct platform_device bfin_spi0_device = {
231}; 229};
232#endif /* spi master and devices */ 230#endif /* spi master and devices */
233 231
234#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 232#if IS_ENABLED(CONFIG_SERIAL_BFIN)
235#ifdef CONFIG_SERIAL_BFIN_UART0 233#ifdef CONFIG_SERIAL_BFIN_UART0
236static struct resource bfin_uart0_resources[] = { 234static struct resource bfin_uart0_resources[] = {
237 { 235 {
@@ -330,7 +328,7 @@ static struct platform_device bfin_uart1_device = {
330#endif 328#endif
331#endif 329#endif
332 330
333#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 331#if IS_ENABLED(CONFIG_BFIN_SIR)
334#ifdef CONFIG_BFIN_SIR0 332#ifdef CONFIG_BFIN_SIR0
335static struct resource bfin_sir0_resources[] = { 333static struct resource bfin_sir0_resources[] = {
336 { 334 {
@@ -385,7 +383,7 @@ static struct platform_device bfin_sir1_device = {
385#endif 383#endif
386#endif 384#endif
387 385
388#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 386#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
389static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 387static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
390 388
391static struct resource bfin_twi0_resource[] = { 389static struct resource bfin_twi0_resource[] = {
@@ -412,7 +410,7 @@ static struct platform_device i2c_bfin_twi_device = {
412}; 410};
413#endif 411#endif
414 412
415#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 413#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
416#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 414#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
417static struct resource bfin_sport0_uart_resources[] = { 415static struct resource bfin_sport0_uart_resources[] = {
418 { 416 {
@@ -484,28 +482,28 @@ static struct platform_device bfin_sport1_uart_device = {
484#endif 482#endif
485 483
486static struct platform_device *minotaur_devices[] __initdata = { 484static struct platform_device *minotaur_devices[] __initdata = {
487#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 485#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
488 &bfin_pcmcia_cf_device, 486 &bfin_pcmcia_cf_device,
489#endif 487#endif
490 488
491#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 489#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
492 &rtc_device, 490 &rtc_device,
493#endif 491#endif
494 492
495#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 493#if IS_ENABLED(CONFIG_BFIN_MAC)
496 &bfin_mii_bus, 494 &bfin_mii_bus,
497 &bfin_mac_device, 495 &bfin_mac_device,
498#endif 496#endif
499 497
500#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 498#if IS_ENABLED(CONFIG_USB_NET2272)
501 &net2272_bfin_device, 499 &net2272_bfin_device,
502#endif 500#endif
503 501
504#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 502#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
505 &bfin_spi0_device, 503 &bfin_spi0_device,
506#endif 504#endif
507 505
508#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 506#if IS_ENABLED(CONFIG_SERIAL_BFIN)
509#ifdef CONFIG_SERIAL_BFIN_UART0 507#ifdef CONFIG_SERIAL_BFIN_UART0
510 &bfin_uart0_device, 508 &bfin_uart0_device,
511#endif 509#endif
@@ -514,7 +512,7 @@ static struct platform_device *minotaur_devices[] __initdata = {
514#endif 512#endif
515#endif 513#endif
516 514
517#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 515#if IS_ENABLED(CONFIG_BFIN_SIR)
518#ifdef CONFIG_BFIN_SIR0 516#ifdef CONFIG_BFIN_SIR0
519 &bfin_sir0_device, 517 &bfin_sir0_device,
520#endif 518#endif
@@ -523,11 +521,11 @@ static struct platform_device *minotaur_devices[] __initdata = {
523#endif 521#endif
524#endif 522#endif
525 523
526#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 524#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
527 &i2c_bfin_twi_device, 525 &i2c_bfin_twi_device,
528#endif 526#endif
529 527
530#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 528#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
531#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 529#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
532 &bfin_sport0_uart_device, 530 &bfin_sport0_uart_device,
533#endif 531#endif
@@ -542,7 +540,7 @@ static int __init minotaur_init(void)
542{ 540{
543 printk(KERN_INFO "%s(): registering device resources\n", __func__); 541 printk(KERN_INFO "%s(): registering device resources\n", __func__);
544 platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices)); 542 platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
545#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 543#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
546 spi_register_board_info(bfin_spi_board_info, 544 spi_register_board_info(bfin_spi_board_info,
547 ARRAY_SIZE(bfin_spi_board_info)); 545 ARRAY_SIZE(bfin_spi_board_info));
548#endif 546#endif
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
index 6b395510405b..06a50ddb54c0 100644
--- a/arch/blackfin/mach-bf537/boards/pnav10.c
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -30,7 +30,7 @@ const char bfin_board_name[] = "ADI PNAV-1.0";
30 * Driver needs to know address, irq and flag pin. 30 * Driver needs to know address, irq and flag pin.
31 */ 31 */
32 32
33#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 33#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
34static struct resource bfin_pcmcia_cf_resources[] = { 34static struct resource bfin_pcmcia_cf_resources[] = {
35 { 35 {
36 .start = 0x20310000, /* IO PORT */ 36 .start = 0x20310000, /* IO PORT */
@@ -59,14 +59,14 @@ static struct platform_device bfin_pcmcia_cf_device = {
59}; 59};
60#endif 60#endif
61 61
62#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 62#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
63static struct platform_device rtc_device = { 63static struct platform_device rtc_device = {
64 .name = "rtc-bfin", 64 .name = "rtc-bfin",
65 .id = -1, 65 .id = -1,
66}; 66};
67#endif 67#endif
68 68
69#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 69#if IS_ENABLED(CONFIG_SMC91X)
70#include <linux/smc91x.h> 70#include <linux/smc91x.h>
71 71
72static struct smc91x_platdata smc91x_info = { 72static struct smc91x_platdata smc91x_info = {
@@ -99,7 +99,7 @@ static struct platform_device smc91x_device = {
99}; 99};
100#endif 100#endif
101 101
102#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 102#if IS_ENABLED(CONFIG_BFIN_MAC)
103#include <linux/bfin_mac.h> 103#include <linux/bfin_mac.h>
104static const unsigned short bfin_mac_peripherals[] = P_RMII0; 104static const unsigned short bfin_mac_peripherals[] = P_RMII0;
105 105
@@ -132,7 +132,7 @@ static struct platform_device bfin_mac_device = {
132}; 132};
133#endif 133#endif
134 134
135#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 135#if IS_ENABLED(CONFIG_USB_NET2272)
136static struct resource net2272_bfin_resources[] = { 136static struct resource net2272_bfin_resources[] = {
137 { 137 {
138 .start = 0x20300000, 138 .start = 0x20300000,
@@ -153,11 +153,10 @@ static struct platform_device net2272_bfin_device = {
153}; 153};
154#endif 154#endif
155 155
156#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 156#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
157/* all SPI peripherals info goes here */ 157/* all SPI peripherals info goes here */
158 158
159#if defined(CONFIG_MTD_M25P80) \ 159#if IS_ENABLED(CONFIG_MTD_M25P80)
160 || defined(CONFIG_MTD_M25P80_MODULE)
161static struct mtd_partition bfin_spi_flash_partitions[] = { 160static struct mtd_partition bfin_spi_flash_partitions[] = {
162 { 161 {
163 .name = "bootloader(spi)", 162 .name = "bootloader(spi)",
@@ -188,13 +187,13 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
188}; 187};
189#endif 188#endif
190 189
191#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 190#if IS_ENABLED(CONFIG_MMC_SPI)
192static struct bfin5xx_spi_chip mmc_spi_chip_info = { 191static struct bfin5xx_spi_chip mmc_spi_chip_info = {
193 .enable_dma = 0, 192 .enable_dma = 0,
194}; 193};
195#endif 194#endif
196 195
197#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 196#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
198static const struct ad7877_platform_data bfin_ad7877_ts_info = { 197static const struct ad7877_platform_data bfin_ad7877_ts_info = {
199 .model = 7877, 198 .model = 7877,
200 .vref_delay_usecs = 50, /* internal, no capacitor */ 199 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -211,8 +210,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
211#endif 210#endif
212 211
213static struct spi_board_info bfin_spi_board_info[] __initdata = { 212static struct spi_board_info bfin_spi_board_info[] __initdata = {
214#if defined(CONFIG_MTD_M25P80) \ 213#if IS_ENABLED(CONFIG_MTD_M25P80)
215 || defined(CONFIG_MTD_M25P80_MODULE)
216 { 214 {
217 /* the modalias must be the same as spi device driver name */ 215 /* the modalias must be the same as spi device driver name */
218 .modalias = "m25p80", /* Name of spi_driver for this device */ 216 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -225,8 +223,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
225 }, 223 },
226#endif 224#endif
227 225
228#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 226#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
229 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
230 { 227 {
231 .modalias = "ad183x", 228 .modalias = "ad183x",
232 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 229 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -234,7 +231,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
234 .chip_select = 4, 231 .chip_select = 4,
235 }, 232 },
236#endif 233#endif
237#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 234#if IS_ENABLED(CONFIG_MMC_SPI)
238 { 235 {
239 .modalias = "mmc_spi", 236 .modalias = "mmc_spi",
240 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ 237 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
@@ -244,7 +241,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
244 .mode = SPI_MODE_3, 241 .mode = SPI_MODE_3,
245 }, 242 },
246#endif 243#endif
247#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 244#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
248{ 245{
249 .modalias = "ad7877", 246 .modalias = "ad7877",
250 .platform_data = &bfin_ad7877_ts_info, 247 .platform_data = &bfin_ad7877_ts_info,
@@ -294,13 +291,13 @@ static struct platform_device bfin_spi0_device = {
294}; 291};
295#endif /* spi master and devices */ 292#endif /* spi master and devices */
296 293
297#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 294#if IS_ENABLED(CONFIG_FB_BF537_LQ035)
298static struct platform_device bfin_fb_device = { 295static struct platform_device bfin_fb_device = {
299 .name = "bf537-lq035", 296 .name = "bf537-lq035",
300}; 297};
301#endif 298#endif
302 299
303#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 300#if IS_ENABLED(CONFIG_SERIAL_BFIN)
304#ifdef CONFIG_SERIAL_BFIN_UART0 301#ifdef CONFIG_SERIAL_BFIN_UART0
305static struct resource bfin_uart0_resources[] = { 302static struct resource bfin_uart0_resources[] = {
306 { 303 {
@@ -399,7 +396,7 @@ static struct platform_device bfin_uart1_device = {
399#endif 396#endif
400#endif 397#endif
401 398
402#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 399#if IS_ENABLED(CONFIG_BFIN_SIR)
403#ifdef CONFIG_BFIN_SIR0 400#ifdef CONFIG_BFIN_SIR0
404static struct resource bfin_sir0_resources[] = { 401static struct resource bfin_sir0_resources[] = {
405 { 402 {
@@ -455,36 +452,36 @@ static struct platform_device bfin_sir1_device = {
455#endif 452#endif
456 453
457static struct platform_device *stamp_devices[] __initdata = { 454static struct platform_device *stamp_devices[] __initdata = {
458#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 455#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
459 &bfin_pcmcia_cf_device, 456 &bfin_pcmcia_cf_device,
460#endif 457#endif
461 458
462#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 459#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
463 &rtc_device, 460 &rtc_device,
464#endif 461#endif
465 462
466#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 463#if IS_ENABLED(CONFIG_SMC91X)
467 &smc91x_device, 464 &smc91x_device,
468#endif 465#endif
469 466
470#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 467#if IS_ENABLED(CONFIG_BFIN_MAC)
471 &bfin_mii_bus, 468 &bfin_mii_bus,
472 &bfin_mac_device, 469 &bfin_mac_device,
473#endif 470#endif
474 471
475#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 472#if IS_ENABLED(CONFIG_USB_NET2272)
476 &net2272_bfin_device, 473 &net2272_bfin_device,
477#endif 474#endif
478 475
479#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 476#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
480 &bfin_spi0_device, 477 &bfin_spi0_device,
481#endif 478#endif
482 479
483#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 480#if IS_ENABLED(CONFIG_FB_BF537_LQ035)
484 &bfin_fb_device, 481 &bfin_fb_device,
485#endif 482#endif
486 483
487#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 484#if IS_ENABLED(CONFIG_SERIAL_BFIN)
488#ifdef CONFIG_SERIAL_BFIN_UART0 485#ifdef CONFIG_SERIAL_BFIN_UART0
489 &bfin_uart0_device, 486 &bfin_uart0_device,
490#endif 487#endif
@@ -493,7 +490,7 @@ static struct platform_device *stamp_devices[] __initdata = {
493#endif 490#endif
494#endif 491#endif
495 492
496#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 493#if IS_ENABLED(CONFIG_BFIN_SIR)
497#ifdef CONFIG_BFIN_SIR0 494#ifdef CONFIG_BFIN_SIR0
498 &bfin_sir0_device, 495 &bfin_sir0_device,
499#endif 496#endif
@@ -507,7 +504,7 @@ static int __init pnav_init(void)
507{ 504{
508 printk(KERN_INFO "%s(): registering device resources\n", __func__); 505 printk(KERN_INFO "%s(): registering device resources\n", __func__);
509 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 506 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
510#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 507#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
511 spi_register_board_info(bfin_spi_board_info, 508 spi_register_board_info(bfin_spi_board_info,
512 ARRAY_SIZE(bfin_spi_board_info)); 509 ARRAY_SIZE(bfin_spi_board_info));
513#endif 510#endif
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 44fd1d4682ac..de19b8a56007 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -18,7 +18,7 @@
18#include <linux/mtd/physmap.h> 18#include <linux/mtd/physmap.h>
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/spi/flash.h> 20#include <linux/spi/flash.h>
21#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 21#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
22#include <linux/usb/isp1362.h> 22#include <linux/usb/isp1362.h>
23#endif 23#endif
24#include <linux/i2c.h> 24#include <linux/i2c.h>
@@ -53,7 +53,7 @@ const char bfin_board_name[] = "ADI BF537-STAMP";
53 * Driver needs to know address, irq and flag pin. 53 * Driver needs to know address, irq and flag pin.
54 */ 54 */
55 55
56#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 56#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
57#include <linux/usb/isp1760.h> 57#include <linux/usb/isp1760.h>
58static struct resource bfin_isp1760_resources[] = { 58static struct resource bfin_isp1760_resources[] = {
59 [0] = { 59 [0] = {
@@ -88,7 +88,7 @@ static struct platform_device bfin_isp1760_device = {
88}; 88};
89#endif 89#endif
90 90
91#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 91#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
92#include <linux/gpio_keys.h> 92#include <linux/gpio_keys.h>
93 93
94static struct gpio_keys_button bfin_gpio_keys_table[] = { 94static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -111,7 +111,7 @@ static struct platform_device bfin_device_gpiokeys = {
111}; 111};
112#endif 112#endif
113 113
114#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 114#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
115static struct resource bfin_pcmcia_cf_resources[] = { 115static struct resource bfin_pcmcia_cf_resources[] = {
116 { 116 {
117 .start = 0x20310000, /* IO PORT */ 117 .start = 0x20310000, /* IO PORT */
@@ -140,14 +140,14 @@ static struct platform_device bfin_pcmcia_cf_device = {
140}; 140};
141#endif 141#endif
142 142
143#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 143#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
144static struct platform_device rtc_device = { 144static struct platform_device rtc_device = {
145 .name = "rtc-bfin", 145 .name = "rtc-bfin",
146 .id = -1, 146 .id = -1,
147}; 147};
148#endif 148#endif
149 149
150#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 150#if IS_ENABLED(CONFIG_SMC91X)
151#include <linux/smc91x.h> 151#include <linux/smc91x.h>
152 152
153static struct smc91x_platdata smc91x_info = { 153static struct smc91x_platdata smc91x_info = {
@@ -180,7 +180,7 @@ static struct platform_device smc91x_device = {
180}; 180};
181#endif 181#endif
182 182
183#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 183#if IS_ENABLED(CONFIG_DM9000)
184static struct resource dm9000_resources[] = { 184static struct resource dm9000_resources[] = {
185 [0] = { 185 [0] = {
186 .start = 0x203FB800, 186 .start = 0x203FB800,
@@ -207,7 +207,7 @@ static struct platform_device dm9000_device = {
207}; 207};
208#endif 208#endif
209 209
210#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE) 210#if IS_ENABLED(CONFIG_USB_SL811_HCD)
211static struct resource sl811_hcd_resources[] = { 211static struct resource sl811_hcd_resources[] = {
212 { 212 {
213 .start = 0x20340000, 213 .start = 0x20340000,
@@ -251,7 +251,7 @@ static struct platform_device sl811_hcd_device = {
251}; 251};
252#endif 252#endif
253 253
254#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 254#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
255static struct resource isp1362_hcd_resources[] = { 255static struct resource isp1362_hcd_resources[] = {
256 { 256 {
257 .start = 0x20360000, 257 .start = 0x20360000,
@@ -290,7 +290,7 @@ static struct platform_device isp1362_hcd_device = {
290}; 290};
291#endif 291#endif
292 292
293#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 293#if IS_ENABLED(CONFIG_CAN_BFIN)
294static unsigned short bfin_can_peripherals[] = { 294static unsigned short bfin_can_peripherals[] = {
295 P_CAN0_RX, P_CAN0_TX, 0 295 P_CAN0_RX, P_CAN0_TX, 0
296}; 296};
@@ -328,7 +328,7 @@ static struct platform_device bfin_can_device = {
328}; 328};
329#endif 329#endif
330 330
331#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 331#if IS_ENABLED(CONFIG_BFIN_MAC)
332#include <linux/bfin_mac.h> 332#include <linux/bfin_mac.h>
333static const unsigned short bfin_mac_peripherals[] = P_MII0; 333static const unsigned short bfin_mac_peripherals[] = P_MII0;
334 334
@@ -361,7 +361,7 @@ static struct platform_device bfin_mac_device = {
361}; 361};
362#endif 362#endif
363 363
364#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 364#if IS_ENABLED(CONFIG_USB_NET2272)
365static struct resource net2272_bfin_resources[] = { 365static struct resource net2272_bfin_resources[] = {
366 { 366 {
367 .start = 0x20300000, 367 .start = 0x20300000,
@@ -385,7 +385,7 @@ static struct platform_device net2272_bfin_device = {
385}; 385};
386#endif 386#endif
387 387
388#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 388#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
389const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; 389const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
390 390
391static struct mtd_partition bfin_plat_nand_partitions[] = { 391static struct mtd_partition bfin_plat_nand_partitions[] = {
@@ -461,7 +461,7 @@ static void bfin_plat_nand_init(void)
461static void bfin_plat_nand_init(void) {} 461static void bfin_plat_nand_init(void) {}
462#endif 462#endif
463 463
464#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 464#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
465static struct mtd_partition stamp_partitions[] = { 465static struct mtd_partition stamp_partitions[] = {
466 { 466 {
467 .name = "bootloader(nor)", 467 .name = "bootloader(nor)",
@@ -509,8 +509,7 @@ static struct platform_device stamp_flash_device = {
509}; 509};
510#endif 510#endif
511 511
512#if defined(CONFIG_MTD_M25P80) \ 512#if IS_ENABLED(CONFIG_MTD_M25P80)
513 || defined(CONFIG_MTD_M25P80_MODULE)
514static struct mtd_partition bfin_spi_flash_partitions[] = { 513static struct mtd_partition bfin_spi_flash_partitions[] = {
515 { 514 {
516 .name = "bootloader(spi)", 515 .name = "bootloader(spi)",
@@ -541,7 +540,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
541}; 540};
542#endif 541#endif
543 542
544#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 543#if IS_ENABLED(CONFIG_INPUT_AD714X_SPI)
545#include <linux/input/ad714x.h> 544#include <linux/input/ad714x.h>
546 545
547static struct ad714x_slider_plat ad7147_spi_slider_plat[] = { 546static struct ad714x_slider_plat ad7147_spi_slider_plat[] = {
@@ -602,7 +601,7 @@ static struct ad714x_platform_data ad7147_spi_platform_data = {
602}; 601};
603#endif 602#endif
604 603
605#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE) 604#if IS_ENABLED(CONFIG_INPUT_AD714X_I2C)
606#include <linux/input/ad714x.h> 605#include <linux/input/ad714x.h>
607static struct ad714x_button_plat ad7142_i2c_button_plat[] = { 606static struct ad714x_button_plat ad7142_i2c_button_plat[] = {
608 { 607 {
@@ -649,24 +648,24 @@ static struct ad714x_platform_data ad7142_i2c_platform_data = {
649}; 648};
650#endif 649#endif
651 650
652#if defined(CONFIG_AD2S90) || defined(CONFIG_AD2S90_MODULE) 651#if IS_ENABLED(CONFIG_AD2S90)
653static struct bfin5xx_spi_chip ad2s90_spi_chip_info = { 652static struct bfin5xx_spi_chip ad2s90_spi_chip_info = {
654 .enable_dma = 0, 653 .enable_dma = 0,
655}; 654};
656#endif 655#endif
657 656
658#if defined(CONFIG_AD2S120X) || defined(CONFIG_AD2S120X_MODULE) 657#if IS_ENABLED(CONFIG_AD2S1200)
659static unsigned short ad2s120x_platform_data[] = { 658static unsigned short ad2s1200_platform_data[] = {
660 /* used as SAMPLE and RDVEL */ 659 /* used as SAMPLE and RDVEL */
661 GPIO_PF5, GPIO_PF6, 0 660 GPIO_PF5, GPIO_PF6, 0
662}; 661};
663 662
664static struct bfin5xx_spi_chip ad2s120x_spi_chip_info = { 663static struct bfin5xx_spi_chip ad2s1200_spi_chip_info = {
665 .enable_dma = 0, 664 .enable_dma = 0,
666}; 665};
667#endif 666#endif
668 667
669#if defined(CONFIG_AD2S1210) || defined(CONFIG_AD2S1210_MODULE) 668#if IS_ENABLED(CONFIG_AD2S1210)
670static unsigned short ad2s1210_platform_data[] = { 669static unsigned short ad2s1210_platform_data[] = {
671 /* use as SAMPLE, A0, A1 */ 670 /* use as SAMPLE, A0, A1 */
672 GPIO_PF7, GPIO_PF8, GPIO_PF9, 671 GPIO_PF7, GPIO_PF8, GPIO_PF9,
@@ -682,13 +681,13 @@ static struct bfin5xx_spi_chip ad2s1210_spi_chip_info = {
682}; 681};
683#endif 682#endif
684 683
685#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE) 684#if IS_ENABLED(CONFIG_SENSORS_AD7314)
686static struct bfin5xx_spi_chip ad7314_spi_chip_info = { 685static struct bfin5xx_spi_chip ad7314_spi_chip_info = {
687 .enable_dma = 0, 686 .enable_dma = 0,
688}; 687};
689#endif 688#endif
690 689
691#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE) 690#if IS_ENABLED(CONFIG_AD7816)
692static unsigned short ad7816_platform_data[] = { 691static unsigned short ad7816_platform_data[] = {
693 GPIO_PF4, /* rdwr_pin */ 692 GPIO_PF4, /* rdwr_pin */
694 GPIO_PF5, /* convert_pin */ 693 GPIO_PF5, /* convert_pin */
@@ -701,7 +700,7 @@ static struct bfin5xx_spi_chip ad7816_spi_chip_info = {
701}; 700};
702#endif 701#endif
703 702
704#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE) 703#if IS_ENABLED(CONFIG_ADT7310)
705static unsigned long adt7310_platform_data[3] = { 704static unsigned long adt7310_platform_data[3] = {
706/* INT bound temperature alarm event. line 1 */ 705/* INT bound temperature alarm event. line 1 */
707 IRQ_PG4, IRQF_TRIGGER_LOW, 706 IRQ_PG4, IRQF_TRIGGER_LOW,
@@ -714,14 +713,14 @@ static struct bfin5xx_spi_chip adt7310_spi_chip_info = {
714}; 713};
715#endif 714#endif
716 715
717#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE) 716#if IS_ENABLED(CONFIG_AD7298)
718static unsigned short ad7298_platform_data[] = { 717static unsigned short ad7298_platform_data[] = {
719 GPIO_PF7, /* busy_pin */ 718 GPIO_PF7, /* busy_pin */
720 0, 719 0,
721}; 720};
722#endif 721#endif
723 722
724#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE) 723#if IS_ENABLED(CONFIG_ADT7316_SPI)
725static unsigned long adt7316_spi_data[2] = { 724static unsigned long adt7316_spi_data[2] = {
726 IRQF_TRIGGER_LOW, /* interrupt flags */ 725 IRQF_TRIGGER_LOW, /* interrupt flags */
727 GPIO_PF7, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */ 726 GPIO_PF7, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */
@@ -732,7 +731,7 @@ static struct bfin5xx_spi_chip adt7316_spi_chip_info = {
732}; 731};
733#endif 732#endif
734 733
735#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 734#if IS_ENABLED(CONFIG_MMC_SPI)
736#define MMC_SPI_CARD_DETECT_INT IRQ_PF5 735#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
737 736
738static int bfin_mmc_spi_init(struct device *dev, 737static int bfin_mmc_spi_init(struct device *dev,
@@ -759,7 +758,7 @@ static struct bfin5xx_spi_chip mmc_spi_chip_info = {
759}; 758};
760#endif 759#endif
761 760
762#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 761#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
763#include <linux/spi/ad7877.h> 762#include <linux/spi/ad7877.h>
764static const struct ad7877_platform_data bfin_ad7877_ts_info = { 763static const struct ad7877_platform_data bfin_ad7877_ts_info = {
765 .model = 7877, 764 .model = 7877,
@@ -776,7 +775,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
776}; 775};
777#endif 776#endif
778 777
779#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 778#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
780#include <linux/spi/ad7879.h> 779#include <linux/spi/ad7879.h>
781static const struct ad7879_platform_data bfin_ad7879_ts_info = { 780static const struct ad7879_platform_data bfin_ad7879_ts_info = {
782 .model = 7879, /* Model = AD7879 */ 781 .model = 7879, /* Model = AD7879 */
@@ -793,7 +792,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
793}; 792};
794#endif 793#endif
795 794
796#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE) 795#if IS_ENABLED(CONFIG_INPUT_ADXL34X)
797#include <linux/input/adxl34x.h> 796#include <linux/input/adxl34x.h>
798static const struct adxl34x_platform_data adxl34x_info = { 797static const struct adxl34x_platform_data adxl34x_info = {
799 .x_axis_offset = 0, 798 .x_axis_offset = 0,
@@ -832,13 +831,13 @@ static const struct adxl34x_platform_data adxl34x_info = {
832}; 831};
833#endif 832#endif
834 833
835#if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE) 834#if IS_ENABLED(CONFIG_ENC28J60)
836static struct bfin5xx_spi_chip enc28j60_spi_chip_info = { 835static struct bfin5xx_spi_chip enc28j60_spi_chip_info = {
837 .enable_dma = 1, 836 .enable_dma = 1,
838}; 837};
839#endif 838#endif
840 839
841#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE) 840#if IS_ENABLED(CONFIG_ADF702X)
842#include <linux/spi/adf702x.h> 841#include <linux/spi/adf702x.h>
843#define TXREG 0x0160A470 842#define TXREG 0x0160A470
844static const u32 adf7021_regs[] = { 843static const u32 adf7021_regs[] = {
@@ -880,7 +879,7 @@ static inline void adf702x_mac_init(void)
880static inline void adf702x_mac_init(void) {} 879static inline void adf702x_mac_init(void) {}
881#endif 880#endif
882 881
883#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 882#if IS_ENABLED(CONFIG_TOUCHSCREEN_ADS7846)
884#include <linux/spi/ads7846.h> 883#include <linux/spi/ads7846.h>
885static int ads7873_get_pendown_state(void) 884static int ads7873_get_pendown_state(void)
886{ 885{
@@ -899,8 +898,7 @@ static struct ads7846_platform_data __initdata ad7873_pdata = {
899}; 898};
900#endif 899#endif
901 900
902#if defined(CONFIG_MTD_DATAFLASH) \ 901#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
903 || defined(CONFIG_MTD_DATAFLASH_MODULE)
904 902
905static struct mtd_partition bfin_spi_dataflash_partitions[] = { 903static struct mtd_partition bfin_spi_dataflash_partitions[] = {
906 { 904 {
@@ -931,15 +929,14 @@ static struct bfin5xx_spi_chip data_flash_chip_info = {
931}; 929};
932#endif 930#endif
933 931
934#if defined(CONFIG_AD7476) || defined(CONFIG_AD7476_MODULE) 932#if IS_ENABLED(CONFIG_AD7476)
935static struct bfin5xx_spi_chip spi_ad7476_chip_info = { 933static struct bfin5xx_spi_chip spi_ad7476_chip_info = {
936 .enable_dma = 0, /* use dma transfer with this chip*/ 934 .enable_dma = 0, /* use dma transfer with this chip*/
937}; 935};
938#endif 936#endif
939 937
940static struct spi_board_info bfin_spi_board_info[] __initdata = { 938static struct spi_board_info bfin_spi_board_info[] __initdata = {
941#if defined(CONFIG_MTD_M25P80) \ 939#if IS_ENABLED(CONFIG_MTD_M25P80)
942 || defined(CONFIG_MTD_M25P80_MODULE)
943 { 940 {
944 /* the modalias must be the same as spi device driver name */ 941 /* the modalias must be the same as spi device driver name */
945 .modalias = "m25p80", /* Name of spi_driver for this device */ 942 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -951,8 +948,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
951 .mode = SPI_MODE_3, 948 .mode = SPI_MODE_3,
952 }, 949 },
953#endif 950#endif
954#if defined(CONFIG_MTD_DATAFLASH) \ 951#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
955 || defined(CONFIG_MTD_DATAFLASH_MODULE)
956 { /* DataFlash chip */ 952 { /* DataFlash chip */
957 .modalias = "mtd_dataflash", 953 .modalias = "mtd_dataflash",
958 .max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */ 954 .max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */
@@ -964,8 +960,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
964 }, 960 },
965#endif 961#endif
966 962
967#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 963#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
968 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
969 { 964 {
970 .modalias = "ad1836", 965 .modalias = "ad1836",
971 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 966 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -986,7 +981,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
986 }, 981 },
987#endif 982#endif
988 983
989#if defined(CONFIG_SND_SOC_ADAV80X) || defined(CONFIG_SND_SOC_ADV80X_MODULE) 984#if IS_ENABLED(CONFIG_SND_SOC_ADAV80X)
990 { 985 {
991 .modalias = "adav801", 986 .modalias = "adav801",
992 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 987 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -996,7 +991,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
996 }, 991 },
997#endif 992#endif
998 993
999#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 994#if IS_ENABLED(CONFIG_INPUT_AD714X_SPI)
1000 { 995 {
1001 .modalias = "ad714x_captouch", 996 .modalias = "ad714x_captouch",
1002 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 997 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1008,7 +1003,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1008 }, 1003 },
1009#endif 1004#endif
1010 1005
1011#if defined(CONFIG_AD2S90) || defined(CONFIG_AD2S90_MODULE) 1006#if IS_ENABLED(CONFIG_AD2S90)
1012 { 1007 {
1013 .modalias = "ad2s90", 1008 .modalias = "ad2s90",
1014 .bus_num = 0, 1009 .bus_num = 0,
@@ -1019,17 +1014,17 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1019 }, 1014 },
1020#endif 1015#endif
1021 1016
1022#if defined(CONFIG_AD2S120X) || defined(CONFIG_AD2S120X_MODULE) 1017#if IS_ENABLED(CONFIG_AD2S1200)
1023 { 1018 {
1024 .modalias = "ad2s120x", 1019 .modalias = "ad2s1200",
1025 .bus_num = 0, 1020 .bus_num = 0,
1026 .chip_select = 4, /* CS, change it for your board */ 1021 .chip_select = 4, /* CS, change it for your board */
1027 .platform_data = ad2s120x_platform_data, 1022 .platform_data = ad2s1200_platform_data,
1028 .controller_data = &ad2s120x_spi_chip_info, 1023 .controller_data = &ad2s1200_spi_chip_info,
1029 }, 1024 },
1030#endif 1025#endif
1031 1026
1032#if defined(CONFIG_AD2S1210) || defined(CONFIG_AD2S1210_MODULE) 1027#if IS_ENABLED(CONFIG_AD2S1210)
1033 { 1028 {
1034 .modalias = "ad2s1210", 1029 .modalias = "ad2s1210",
1035 .max_speed_hz = 8192000, 1030 .max_speed_hz = 8192000,
@@ -1040,7 +1035,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1040 }, 1035 },
1041#endif 1036#endif
1042 1037
1043#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE) 1038#if IS_ENABLED(CONFIG_SENSORS_AD7314)
1044 { 1039 {
1045 .modalias = "ad7314", 1040 .modalias = "ad7314",
1046 .max_speed_hz = 1000000, 1041 .max_speed_hz = 1000000,
@@ -1051,7 +1046,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1051 }, 1046 },
1052#endif 1047#endif
1053 1048
1054#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE) 1049#if IS_ENABLED(CONFIG_AD7816)
1055 { 1050 {
1056 .modalias = "ad7818", 1051 .modalias = "ad7818",
1057 .max_speed_hz = 1000000, 1052 .max_speed_hz = 1000000,
@@ -1063,7 +1058,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1063 }, 1058 },
1064#endif 1059#endif
1065 1060
1066#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE) 1061#if IS_ENABLED(CONFIG_ADT7310)
1067 { 1062 {
1068 .modalias = "adt7310", 1063 .modalias = "adt7310",
1069 .max_speed_hz = 1000000, 1064 .max_speed_hz = 1000000,
@@ -1076,7 +1071,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1076 }, 1071 },
1077#endif 1072#endif
1078 1073
1079#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE) 1074#if IS_ENABLED(CONFIG_AD7298)
1080 { 1075 {
1081 .modalias = "ad7298", 1076 .modalias = "ad7298",
1082 .max_speed_hz = 1000000, 1077 .max_speed_hz = 1000000,
@@ -1087,7 +1082,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1087 }, 1082 },
1088#endif 1083#endif
1089 1084
1090#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE) 1085#if IS_ENABLED(CONFIG_ADT7316_SPI)
1091 { 1086 {
1092 .modalias = "adt7316", 1087 .modalias = "adt7316",
1093 .max_speed_hz = 1000000, 1088 .max_speed_hz = 1000000,
@@ -1100,7 +1095,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1100 }, 1095 },
1101#endif 1096#endif
1102 1097
1103#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 1098#if IS_ENABLED(CONFIG_MMC_SPI)
1104 { 1099 {
1105 .modalias = "mmc_spi", 1100 .modalias = "mmc_spi",
1106 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 1101 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -1111,7 +1106,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1111 .mode = SPI_MODE_3, 1106 .mode = SPI_MODE_3,
1112 }, 1107 },
1113#endif 1108#endif
1114#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1109#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
1115 { 1110 {
1116 .modalias = "ad7877", 1111 .modalias = "ad7877",
1117 .platform_data = &bfin_ad7877_ts_info, 1112 .platform_data = &bfin_ad7877_ts_info,
@@ -1121,7 +1116,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1121 .chip_select = 1, 1116 .chip_select = 1,
1122 }, 1117 },
1123#endif 1118#endif
1124#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 1119#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
1125 { 1120 {
1126 .modalias = "ad7879", 1121 .modalias = "ad7879",
1127 .platform_data = &bfin_ad7879_ts_info, 1122 .platform_data = &bfin_ad7879_ts_info,
@@ -1132,7 +1127,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1132 .mode = SPI_CPHA | SPI_CPOL, 1127 .mode = SPI_CPHA | SPI_CPOL,
1133 }, 1128 },
1134#endif 1129#endif
1135#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 1130#if IS_ENABLED(CONFIG_SPI_SPIDEV)
1136 { 1131 {
1137 .modalias = "spidev", 1132 .modalias = "spidev",
1138 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1133 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -1140,7 +1135,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1140 .chip_select = 1, 1135 .chip_select = 1,
1141 }, 1136 },
1142#endif 1137#endif
1143#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 1138#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
1144 { 1139 {
1145 .modalias = "bfin-lq035q1-spi", 1140 .modalias = "bfin-lq035q1-spi",
1146 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 1141 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -1149,7 +1144,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1149 .mode = SPI_CPHA | SPI_CPOL, 1144 .mode = SPI_CPHA | SPI_CPOL,
1150 }, 1145 },
1151#endif 1146#endif
1152#if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE) 1147#if IS_ENABLED(CONFIG_ENC28J60)
1153 { 1148 {
1154 .modalias = "enc28j60", 1149 .modalias = "enc28j60",
1155 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 1150 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -1160,7 +1155,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1160 .mode = SPI_MODE_0, 1155 .mode = SPI_MODE_0,
1161 }, 1156 },
1162#endif 1157#endif
1163#if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE) 1158#if IS_ENABLED(CONFIG_INPUT_ADXL34X_SPI)
1164 { 1159 {
1165 .modalias = "adxl34x", 1160 .modalias = "adxl34x",
1166 .platform_data = &adxl34x_info, 1161 .platform_data = &adxl34x_info,
@@ -1171,7 +1166,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1171 .mode = SPI_MODE_3, 1166 .mode = SPI_MODE_3,
1172 }, 1167 },
1173#endif 1168#endif
1174#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE) 1169#if IS_ENABLED(CONFIG_ADF702X)
1175 { 1170 {
1176 .modalias = "adf702x", 1171 .modalias = "adf702x",
1177 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */ 1172 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */
@@ -1181,7 +1176,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1181 .mode = SPI_MODE_0, 1176 .mode = SPI_MODE_0,
1182 }, 1177 },
1183#endif 1178#endif
1184#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 1179#if IS_ENABLED(CONFIG_TOUCHSCREEN_ADS7846)
1185 { 1180 {
1186 .modalias = "ads7846", 1181 .modalias = "ads7846",
1187 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */ 1182 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */
@@ -1192,8 +1187,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1192 .mode = SPI_MODE_0, 1187 .mode = SPI_MODE_0,
1193 }, 1188 },
1194#endif 1189#endif
1195#if defined(CONFIG_AD7476) \ 1190#if IS_ENABLED(CONFIG_AD7476)
1196 || defined(CONFIG_AD7476_MODULE)
1197 { 1191 {
1198 .modalias = "ad7476", /* Name of spi_driver for this device */ 1192 .modalias = "ad7476", /* Name of spi_driver for this device */
1199 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */ 1193 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
@@ -1204,8 +1198,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1204 .mode = SPI_MODE_3, 1198 .mode = SPI_MODE_3,
1205 }, 1199 },
1206#endif 1200#endif
1207#if defined(CONFIG_ADE7753) \ 1201#if IS_ENABLED(CONFIG_ADE7753)
1208 || defined(CONFIG_ADE7753_MODULE)
1209 { 1202 {
1210 .modalias = "ade7753", 1203 .modalias = "ade7753",
1211 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1204 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1215,8 +1208,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1215 .mode = SPI_MODE_1, 1208 .mode = SPI_MODE_1,
1216 }, 1209 },
1217#endif 1210#endif
1218#if defined(CONFIG_ADE7754) \ 1211#if IS_ENABLED(CONFIG_ADE7754)
1219 || defined(CONFIG_ADE7754_MODULE)
1220 { 1212 {
1221 .modalias = "ade7754", 1213 .modalias = "ade7754",
1222 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1214 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1226,8 +1218,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1226 .mode = SPI_MODE_1, 1218 .mode = SPI_MODE_1,
1227 }, 1219 },
1228#endif 1220#endif
1229#if defined(CONFIG_ADE7758) \ 1221#if IS_ENABLED(CONFIG_ADE7758)
1230 || defined(CONFIG_ADE7758_MODULE)
1231 { 1222 {
1232 .modalias = "ade7758", 1223 .modalias = "ade7758",
1233 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1224 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1237,8 +1228,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1237 .mode = SPI_MODE_1, 1228 .mode = SPI_MODE_1,
1238 }, 1229 },
1239#endif 1230#endif
1240#if defined(CONFIG_ADE7759) \ 1231#if IS_ENABLED(CONFIG_ADE7759)
1241 || defined(CONFIG_ADE7759_MODULE)
1242 { 1232 {
1243 .modalias = "ade7759", 1233 .modalias = "ade7759",
1244 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1234 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1248,8 +1238,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1248 .mode = SPI_MODE_1, 1238 .mode = SPI_MODE_1,
1249 }, 1239 },
1250#endif 1240#endif
1251#if defined(CONFIG_ADE7854_SPI) \ 1241#if IS_ENABLED(CONFIG_ADE7854_SPI)
1252 || defined(CONFIG_ADE7854_SPI_MODULE)
1253 { 1242 {
1254 .modalias = "ade7854", 1243 .modalias = "ade7854",
1255 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1244 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1259,8 +1248,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1259 .mode = SPI_MODE_3, 1248 .mode = SPI_MODE_3,
1260 }, 1249 },
1261#endif 1250#endif
1262#if defined(CONFIG_ADIS16060) \ 1251#if IS_ENABLED(CONFIG_ADIS16060)
1263 || defined(CONFIG_ADIS16060_MODULE)
1264 { 1252 {
1265 .modalias = "adis16060_r", 1253 .modalias = "adis16060_r",
1266 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */ 1254 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */
@@ -1278,8 +1266,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1278 .mode = SPI_MODE_1, 1266 .mode = SPI_MODE_1,
1279 }, 1267 },
1280#endif 1268#endif
1281#if defined(CONFIG_ADIS16130) \ 1269#if IS_ENABLED(CONFIG_ADIS16130)
1282 || defined(CONFIG_ADIS16130_MODULE)
1283 { 1270 {
1284 .modalias = "adis16130", 1271 .modalias = "adis16130",
1285 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1272 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1289,8 +1276,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1289 .mode = SPI_MODE_3, 1276 .mode = SPI_MODE_3,
1290 }, 1277 },
1291#endif 1278#endif
1292#if defined(CONFIG_ADIS16201) \ 1279#if IS_ENABLED(CONFIG_ADIS16201)
1293 || defined(CONFIG_ADIS16201_MODULE)
1294 { 1280 {
1295 .modalias = "adis16201", 1281 .modalias = "adis16201",
1296 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1282 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1301,8 +1287,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1301 .irq = IRQ_PF4, 1287 .irq = IRQ_PF4,
1302 }, 1288 },
1303#endif 1289#endif
1304#if defined(CONFIG_ADIS16203) \ 1290#if IS_ENABLED(CONFIG_ADIS16203)
1305 || defined(CONFIG_ADIS16203_MODULE)
1306 { 1291 {
1307 .modalias = "adis16203", 1292 .modalias = "adis16203",
1308 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1293 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1313,8 +1298,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1313 .irq = IRQ_PF4, 1298 .irq = IRQ_PF4,
1314 }, 1299 },
1315#endif 1300#endif
1316#if defined(CONFIG_ADIS16204) \ 1301#if IS_ENABLED(CONFIG_ADIS16204)
1317 || defined(CONFIG_ADIS16204_MODULE)
1318 { 1302 {
1319 .modalias = "adis16204", 1303 .modalias = "adis16204",
1320 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1304 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1325,8 +1309,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1325 .irq = IRQ_PF4, 1309 .irq = IRQ_PF4,
1326 }, 1310 },
1327#endif 1311#endif
1328#if defined(CONFIG_ADIS16209) \ 1312#if IS_ENABLED(CONFIG_ADIS16209)
1329 || defined(CONFIG_ADIS16209_MODULE)
1330 { 1313 {
1331 .modalias = "adis16209", 1314 .modalias = "adis16209",
1332 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1315 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1337,8 +1320,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1337 .irq = IRQ_PF4, 1320 .irq = IRQ_PF4,
1338 }, 1321 },
1339#endif 1322#endif
1340#if defined(CONFIG_ADIS16220) \ 1323#if IS_ENABLED(CONFIG_ADIS16220)
1341 || defined(CONFIG_ADIS16220_MODULE)
1342 { 1324 {
1343 .modalias = "adis16220", 1325 .modalias = "adis16220",
1344 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */ 1326 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */
@@ -1349,8 +1331,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1349 .irq = IRQ_PF4, 1331 .irq = IRQ_PF4,
1350 }, 1332 },
1351#endif 1333#endif
1352#if defined(CONFIG_ADIS16240) \ 1334#if IS_ENABLED(CONFIG_ADIS16240)
1353 || defined(CONFIG_ADIS16240_MODULE)
1354 { 1335 {
1355 .modalias = "adis16240", 1336 .modalias = "adis16240",
1356 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */ 1337 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
@@ -1361,8 +1342,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1361 .irq = IRQ_PF4, 1342 .irq = IRQ_PF4,
1362 }, 1343 },
1363#endif 1344#endif
1364#if defined(CONFIG_ADIS16260) \ 1345#if IS_ENABLED(CONFIG_ADIS16260)
1365 || defined(CONFIG_ADIS16260_MODULE)
1366 { 1346 {
1367 .modalias = "adis16260", 1347 .modalias = "adis16260",
1368 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */ 1348 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
@@ -1373,8 +1353,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1373 .irq = IRQ_PF4, 1353 .irq = IRQ_PF4,
1374 }, 1354 },
1375#endif 1355#endif
1376#if defined(CONFIG_ADIS16261) \ 1356#if IS_ENABLED(CONFIG_ADIS16261)
1377 || defined(CONFIG_ADIS16261_MODULE)
1378 { 1357 {
1379 .modalias = "adis16261", 1358 .modalias = "adis16261",
1380 .max_speed_hz = 2500000, /* max spi clock (SCK) speed in HZ */ 1359 .max_speed_hz = 2500000, /* max spi clock (SCK) speed in HZ */
@@ -1384,8 +1363,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1384 .mode = SPI_MODE_3, 1363 .mode = SPI_MODE_3,
1385 }, 1364 },
1386#endif 1365#endif
1387#if defined(CONFIG_ADIS16300) \ 1366#if IS_ENABLED(CONFIG_ADIS16300)
1388 || defined(CONFIG_ADIS16300_MODULE)
1389 { 1367 {
1390 .modalias = "adis16300", 1368 .modalias = "adis16300",
1391 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1369 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1396,8 +1374,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1396 .irq = IRQ_PF4, 1374 .irq = IRQ_PF4,
1397 }, 1375 },
1398#endif 1376#endif
1399#if defined(CONFIG_ADIS16350) \ 1377#if IS_ENABLED(CONFIG_ADIS16350)
1400 || defined(CONFIG_ADIS16350_MODULE)
1401 { 1378 {
1402 .modalias = "adis16364", 1379 .modalias = "adis16364",
1403 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1380 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1408,8 +1385,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1408 .irq = IRQ_PF4, 1385 .irq = IRQ_PF4,
1409 }, 1386 },
1410#endif 1387#endif
1411#if defined(CONFIG_ADIS16400) \ 1388#if IS_ENABLED(CONFIG_ADIS16400)
1412 || defined(CONFIG_ADIS16400_MODULE)
1413 { 1389 {
1414 .modalias = "adis16400", 1390 .modalias = "adis16400",
1415 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ 1391 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
@@ -1421,7 +1397,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1421#endif 1397#endif
1422}; 1398};
1423 1399
1424#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 1400#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1425/* SPI controller data */ 1401/* SPI controller data */
1426static struct bfin5xx_spi_master bfin_spi0_info = { 1402static struct bfin5xx_spi_master bfin_spi0_info = {
1427 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, 1403 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
@@ -1459,7 +1435,7 @@ static struct platform_device bfin_spi0_device = {
1459}; 1435};
1460#endif /* spi master and devices */ 1436#endif /* spi master and devices */
1461 1437
1462#if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE) 1438#if IS_ENABLED(CONFIG_SPI_BFIN_SPORT)
1463 1439
1464/* SPORT SPI controller data */ 1440/* SPORT SPI controller data */
1465static struct bfin5xx_spi_master bfin_sport_spi0_info = { 1441static struct bfin5xx_spi_master bfin_sport_spi0_info = {
@@ -1524,13 +1500,13 @@ static struct platform_device bfin_sport_spi1_device = {
1524 1500
1525#endif /* sport spi master and devices */ 1501#endif /* sport spi master and devices */
1526 1502
1527#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 1503#if IS_ENABLED(CONFIG_FB_BF537_LQ035)
1528static struct platform_device bfin_fb_device = { 1504static struct platform_device bfin_fb_device = {
1529 .name = "bf537_lq035", 1505 .name = "bf537_lq035",
1530}; 1506};
1531#endif 1507#endif
1532 1508
1533#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 1509#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
1534#include <asm/bfin-lq035q1.h> 1510#include <asm/bfin-lq035q1.h>
1535 1511
1536static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = { 1512static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
@@ -1559,8 +1535,7 @@ static struct platform_device bfin_lq035q1_device = {
1559}; 1535};
1560#endif 1536#endif
1561 1537
1562#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 1538#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
1563 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
1564#include <linux/videodev2.h> 1539#include <linux/videodev2.h>
1565#include <media/blackfin/bfin_capture.h> 1540#include <media/blackfin/bfin_capture.h>
1566#include <media/blackfin/ppi.h> 1541#include <media/blackfin/ppi.h>
@@ -1580,8 +1555,7 @@ static const struct ppi_info ppi_info = {
1580 .pin_req = ppi_req, 1555 .pin_req = ppi_req,
1581}; 1556};
1582 1557
1583#if defined(CONFIG_VIDEO_VS6624) \ 1558#if IS_ENABLED(CONFIG_VIDEO_VS6624)
1584 || defined(CONFIG_VIDEO_VS6624_MODULE)
1585static struct v4l2_input vs6624_inputs[] = { 1559static struct v4l2_input vs6624_inputs[] = {
1586 { 1560 {
1587 .index = 0, 1561 .index = 0,
@@ -1624,7 +1598,7 @@ static struct platform_device bfin_capture_device = {
1624}; 1598};
1625#endif 1599#endif
1626 1600
1627#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 1601#if IS_ENABLED(CONFIG_SERIAL_BFIN)
1628#ifdef CONFIG_SERIAL_BFIN_UART0 1602#ifdef CONFIG_SERIAL_BFIN_UART0
1629static struct resource bfin_uart0_resources[] = { 1603static struct resource bfin_uart0_resources[] = {
1630 { 1604 {
@@ -1735,7 +1709,7 @@ static struct platform_device bfin_uart1_device = {
1735#endif 1709#endif
1736#endif 1710#endif
1737 1711
1738#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 1712#if IS_ENABLED(CONFIG_BFIN_SIR)
1739#ifdef CONFIG_BFIN_SIR0 1713#ifdef CONFIG_BFIN_SIR0
1740static struct resource bfin_sir0_resources[] = { 1714static struct resource bfin_sir0_resources[] = {
1741 { 1715 {
@@ -1790,7 +1764,7 @@ static struct platform_device bfin_sir1_device = {
1790#endif 1764#endif
1791#endif 1765#endif
1792 1766
1793#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1767#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1794static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 1768static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
1795 1769
1796static struct resource bfin_twi0_resource[] = { 1770static struct resource bfin_twi0_resource[] = {
@@ -1817,7 +1791,7 @@ static struct platform_device i2c_bfin_twi_device = {
1817}; 1791};
1818#endif 1792#endif
1819 1793
1820#if defined(CONFIG_KEYBOARD_ADP5588) || defined(CONFIG_KEYBOARD_ADP5588_MODULE) 1794#if IS_ENABLED(CONFIG_KEYBOARD_ADP5588)
1821static const unsigned short adp5588_keymap[ADP5588_KEYMAPSIZE] = { 1795static const unsigned short adp5588_keymap[ADP5588_KEYMAPSIZE] = {
1822 [0] = KEY_GRAVE, 1796 [0] = KEY_GRAVE,
1823 [1] = KEY_1, 1797 [1] = KEY_1,
@@ -1902,7 +1876,7 @@ static struct adp5588_kpad_platform_data adp5588_kpad_data = {
1902}; 1876};
1903#endif 1877#endif
1904 1878
1905#if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE) 1879#if IS_ENABLED(CONFIG_PMIC_ADP5520)
1906#include <linux/mfd/adp5520.h> 1880#include <linux/mfd/adp5520.h>
1907 1881
1908 /* 1882 /*
@@ -2013,14 +1987,14 @@ static struct adp5520_platform_data adp5520_pdev_data = {
2013 1987
2014#endif 1988#endif
2015 1989
2016#if defined(CONFIG_GPIO_ADP5588) || defined(CONFIG_GPIO_ADP5588_MODULE) 1990#if IS_ENABLED(CONFIG_GPIO_ADP5588)
2017static struct adp5588_gpio_platform_data adp5588_gpio_data = { 1991static struct adp5588_gpio_platform_data adp5588_gpio_data = {
2018 .gpio_start = 50, 1992 .gpio_start = 50,
2019 .pullup_dis_mask = 0, 1993 .pullup_dis_mask = 0,
2020}; 1994};
2021#endif 1995#endif
2022 1996
2023#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE) 1997#if IS_ENABLED(CONFIG_BACKLIGHT_ADP8870)
2024#include <linux/i2c/adp8870.h> 1998#include <linux/i2c/adp8870.h>
2025static struct led_info adp8870_leds[] = { 1999static struct led_info adp8870_leds[] = {
2026 { 2000 {
@@ -2072,7 +2046,7 @@ static struct adp8870_backlight_platform_data adp8870_pdata = {
2072}; 2046};
2073#endif 2047#endif
2074 2048
2075#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE) 2049#if IS_ENABLED(CONFIG_BACKLIGHT_ADP8860)
2076#include <linux/i2c/adp8860.h> 2050#include <linux/i2c/adp8860.h>
2077static struct led_info adp8860_leds[] = { 2051static struct led_info adp8860_leds[] = {
2078 { 2052 {
@@ -2114,7 +2088,7 @@ static struct adp8860_backlight_platform_data adp8860_pdata = {
2114}; 2088};
2115#endif 2089#endif
2116 2090
2117#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE) 2091#if IS_ENABLED(CONFIG_REGULATOR_AD5398)
2118static struct regulator_consumer_supply ad5398_consumer = { 2092static struct regulator_consumer_supply ad5398_consumer = {
2119 .supply = "current", 2093 .supply = "current",
2120}; 2094};
@@ -2129,8 +2103,7 @@ static struct regulator_init_data ad5398_regulator_data = {
2129 .consumer_supplies = &ad5398_consumer, 2103 .consumer_supplies = &ad5398_consumer,
2130}; 2104};
2131 2105
2132#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \ 2106#if IS_ENABLED(CONFIG_REGULATOR_VIRTUAL_CONSUMER)
2133 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
2134static struct platform_device ad5398_virt_consumer_device = { 2107static struct platform_device ad5398_virt_consumer_device = {
2135 .name = "reg-virt-consumer", 2108 .name = "reg-virt-consumer",
2136 .id = 0, 2109 .id = 0,
@@ -2139,8 +2112,7 @@ static struct platform_device ad5398_virt_consumer_device = {
2139 }, 2112 },
2140}; 2113};
2141#endif 2114#endif
2142#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2115#if IS_ENABLED(CONFIG_REGULATOR_USERSPACE_CONSUMER)
2143 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2144static struct regulator_bulk_data ad5398_bulk_data = { 2116static struct regulator_bulk_data ad5398_bulk_data = {
2145 .supply = "current", 2117 .supply = "current",
2146}; 2118};
@@ -2161,14 +2133,14 @@ static struct platform_device ad5398_userspace_consumer_device = {
2161#endif 2133#endif
2162#endif 2134#endif
2163 2135
2164#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE) 2136#if IS_ENABLED(CONFIG_ADT7410)
2165/* INT bound temperature alarm event. line 1 */ 2137/* INT bound temperature alarm event. line 1 */
2166static unsigned long adt7410_platform_data[2] = { 2138static unsigned long adt7410_platform_data[2] = {
2167 IRQ_PG4, IRQF_TRIGGER_LOW, 2139 IRQ_PG4, IRQF_TRIGGER_LOW,
2168}; 2140};
2169#endif 2141#endif
2170 2142
2171#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE) 2143#if IS_ENABLED(CONFIG_ADT7316_I2C)
2172/* INT bound temperature alarm event. line 1 */ 2144/* INT bound temperature alarm event. line 1 */
2173static unsigned long adt7316_i2c_data[2] = { 2145static unsigned long adt7316_i2c_data[2] = {
2174 IRQF_TRIGGER_LOW, /* interrupt flags */ 2146 IRQF_TRIGGER_LOW, /* interrupt flags */
@@ -2183,13 +2155,13 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2183 }, 2155 },
2184#endif 2156#endif
2185 2157
2186#if defined(CONFIG_SND_SOC_ADAV80X) || defined(CONFIG_SND_SOC_ADAV80X_MODULE) 2158#if IS_ENABLED(CONFIG_SND_SOC_ADAV80X)
2187 { 2159 {
2188 I2C_BOARD_INFO("adav803", 0x10), 2160 I2C_BOARD_INFO("adav803", 0x10),
2189 }, 2161 },
2190#endif 2162#endif
2191 2163
2192#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE) 2164#if IS_ENABLED(CONFIG_INPUT_AD714X_I2C)
2193 { 2165 {
2194 I2C_BOARD_INFO("ad7142_captouch", 0x2C), 2166 I2C_BOARD_INFO("ad7142_captouch", 0x2C),
2195 .irq = IRQ_PG5, 2167 .irq = IRQ_PG5,
@@ -2197,39 +2169,39 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2197 }, 2169 },
2198#endif 2170#endif
2199 2171
2200#if defined(CONFIG_AD7150) || defined(CONFIG_AD7150_MODULE) 2172#if IS_ENABLED(CONFIG_AD7150)
2201 { 2173 {
2202 I2C_BOARD_INFO("ad7150", 0x48), 2174 I2C_BOARD_INFO("ad7150", 0x48),
2203 .irq = IRQ_PG5, /* fixme: use real interrupt number */ 2175 .irq = IRQ_PG5, /* fixme: use real interrupt number */
2204 }, 2176 },
2205#endif 2177#endif
2206 2178
2207#if defined(CONFIG_AD7152) || defined(CONFIG_AD7152_MODULE) 2179#if IS_ENABLED(CONFIG_AD7152)
2208 { 2180 {
2209 I2C_BOARD_INFO("ad7152", 0x48), 2181 I2C_BOARD_INFO("ad7152", 0x48),
2210 }, 2182 },
2211#endif 2183#endif
2212 2184
2213#if defined(CONFIG_AD774X) || defined(CONFIG_AD774X_MODULE) 2185#if IS_ENABLED(CONFIG_AD774X)
2214 { 2186 {
2215 I2C_BOARD_INFO("ad774x", 0x48), 2187 I2C_BOARD_INFO("ad774x", 0x48),
2216 }, 2188 },
2217#endif 2189#endif
2218 2190
2219#if defined(CONFIG_ADE7854_I2C) || defined(CONFIG_ADE7854_I2C_MODULE) 2191#if IS_ENABLED(CONFIG_ADE7854_I2C)
2220 { 2192 {
2221 I2C_BOARD_INFO("ade7854", 0x38), 2193 I2C_BOARD_INFO("ade7854", 0x38),
2222 }, 2194 },
2223#endif 2195#endif
2224 2196
2225#if defined(CONFIG_ADT75) || defined(CONFIG_ADT75_MODULE) 2197#if IS_ENABLED(CONFIG_SENSORS_LM75)
2226 { 2198 {
2227 I2C_BOARD_INFO("adt75", 0x9), 2199 I2C_BOARD_INFO("adt75", 0x9),
2228 .irq = IRQ_PG5, 2200 .irq = IRQ_PG5,
2229 }, 2201 },
2230#endif 2202#endif
2231 2203
2232#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE) 2204#if IS_ENABLED(CONFIG_ADT7410)
2233 { 2205 {
2234 I2C_BOARD_INFO("adt7410", 0x48), 2206 I2C_BOARD_INFO("adt7410", 0x48),
2235 /* CT critical temperature event. line 0 */ 2207 /* CT critical temperature event. line 0 */
@@ -2238,14 +2210,14 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2238 }, 2210 },
2239#endif 2211#endif
2240 2212
2241#if defined(CONFIG_AD7291) || defined(CONFIG_AD7291_MODULE) 2213#if IS_ENABLED(CONFIG_AD7291)
2242 { 2214 {
2243 I2C_BOARD_INFO("ad7291", 0x20), 2215 I2C_BOARD_INFO("ad7291", 0x20),
2244 .irq = IRQ_PG5, 2216 .irq = IRQ_PG5,
2245 }, 2217 },
2246#endif 2218#endif
2247 2219
2248#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE) 2220#if IS_ENABLED(CONFIG_ADT7316_I2C)
2249 { 2221 {
2250 I2C_BOARD_INFO("adt7316", 0x48), 2222 I2C_BOARD_INFO("adt7316", 0x48),
2251 .irq = IRQ_PG6, 2223 .irq = IRQ_PG6,
@@ -2253,128 +2225,128 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2253 }, 2225 },
2254#endif 2226#endif
2255 2227
2256#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 2228#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
2257 { 2229 {
2258 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 2230 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
2259 }, 2231 },
2260#endif 2232#endif
2261#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 2233#if IS_ENABLED(CONFIG_INPUT_PCF8574)
2262 { 2234 {
2263 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 2235 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
2264 .irq = IRQ_PG6, 2236 .irq = IRQ_PG6,
2265 }, 2237 },
2266#endif 2238#endif
2267#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE) 2239#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_I2C)
2268 { 2240 {
2269 I2C_BOARD_INFO("ad7879", 0x2F), 2241 I2C_BOARD_INFO("ad7879", 0x2F),
2270 .irq = IRQ_PG5, 2242 .irq = IRQ_PG5,
2271 .platform_data = (void *)&bfin_ad7879_ts_info, 2243 .platform_data = (void *)&bfin_ad7879_ts_info,
2272 }, 2244 },
2273#endif 2245#endif
2274#if defined(CONFIG_KEYBOARD_ADP5588) || defined(CONFIG_KEYBOARD_ADP5588_MODULE) 2246#if IS_ENABLED(CONFIG_KEYBOARD_ADP5588)
2275 { 2247 {
2276 I2C_BOARD_INFO("adp5588-keys", 0x34), 2248 I2C_BOARD_INFO("adp5588-keys", 0x34),
2277 .irq = IRQ_PG0, 2249 .irq = IRQ_PG0,
2278 .platform_data = (void *)&adp5588_kpad_data, 2250 .platform_data = (void *)&adp5588_kpad_data,
2279 }, 2251 },
2280#endif 2252#endif
2281#if defined(CONFIG_PMIC_ADP5520) || defined(CONFIG_PMIC_ADP5520_MODULE) 2253#if IS_ENABLED(CONFIG_PMIC_ADP5520)
2282 { 2254 {
2283 I2C_BOARD_INFO("pmic-adp5520", 0x32), 2255 I2C_BOARD_INFO("pmic-adp5520", 0x32),
2284 .irq = IRQ_PG0, 2256 .irq = IRQ_PG0,
2285 .platform_data = (void *)&adp5520_pdev_data, 2257 .platform_data = (void *)&adp5520_pdev_data,
2286 }, 2258 },
2287#endif 2259#endif
2288#if defined(CONFIG_INPUT_ADXL34X_I2C) || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE) 2260#if IS_ENABLED(CONFIG_INPUT_ADXL34X_I2C)
2289 { 2261 {
2290 I2C_BOARD_INFO("adxl34x", 0x53), 2262 I2C_BOARD_INFO("adxl34x", 0x53),
2291 .irq = IRQ_PG3, 2263 .irq = IRQ_PG3,
2292 .platform_data = (void *)&adxl34x_info, 2264 .platform_data = (void *)&adxl34x_info,
2293 }, 2265 },
2294#endif 2266#endif
2295#if defined(CONFIG_GPIO_ADP5588) || defined(CONFIG_GPIO_ADP5588_MODULE) 2267#if IS_ENABLED(CONFIG_GPIO_ADP5588)
2296 { 2268 {
2297 I2C_BOARD_INFO("adp5588-gpio", 0x34), 2269 I2C_BOARD_INFO("adp5588-gpio", 0x34),
2298 .platform_data = (void *)&adp5588_gpio_data, 2270 .platform_data = (void *)&adp5588_gpio_data,
2299 }, 2271 },
2300#endif 2272#endif
2301#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) 2273#if IS_ENABLED(CONFIG_FB_BFIN_7393)
2302 { 2274 {
2303 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 2275 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
2304 }, 2276 },
2305#endif 2277#endif
2306#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 2278#if IS_ENABLED(CONFIG_FB_BF537_LQ035)
2307 { 2279 {
2308 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2F), 2280 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2F),
2309 }, 2281 },
2310#endif 2282#endif
2311#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE) 2283#if IS_ENABLED(CONFIG_BACKLIGHT_ADP8870)
2312 { 2284 {
2313 I2C_BOARD_INFO("adp8870", 0x2B), 2285 I2C_BOARD_INFO("adp8870", 0x2B),
2314 .platform_data = (void *)&adp8870_pdata, 2286 .platform_data = (void *)&adp8870_pdata,
2315 }, 2287 },
2316#endif 2288#endif
2317#if defined(CONFIG_SND_SOC_ADAU1371) || defined(CONFIG_SND_SOC_ADAU1371_MODULE) 2289#if IS_ENABLED(CONFIG_SND_SOC_ADAU1371)
2318 { 2290 {
2319 I2C_BOARD_INFO("adau1371", 0x1A), 2291 I2C_BOARD_INFO("adau1371", 0x1A),
2320 }, 2292 },
2321#endif 2293#endif
2322#if defined(CONFIG_SND_SOC_ADAU1761) || defined(CONFIG_SND_SOC_ADAU1761_MODULE) 2294#if IS_ENABLED(CONFIG_SND_SOC_ADAU1761)
2323 { 2295 {
2324 I2C_BOARD_INFO("adau1761", 0x38), 2296 I2C_BOARD_INFO("adau1761", 0x38),
2325 }, 2297 },
2326#endif 2298#endif
2327#if defined(CONFIG_SND_SOC_ADAU1361) || defined(CONFIG_SND_SOC_ADAU1361_MODULE) 2299#if IS_ENABLED(CONFIG_SND_SOC_ADAU1361)
2328 { 2300 {
2329 I2C_BOARD_INFO("adau1361", 0x38), 2301 I2C_BOARD_INFO("adau1361", 0x38),
2330 }, 2302 },
2331#endif 2303#endif
2332#if defined(CONFIG_SND_SOC_ADAU1701) || defined(CONFIG_SND_SOC_ADAU1701_MODULE) 2304#if IS_ENABLED(CONFIG_SND_SOC_ADAU1701)
2333 { 2305 {
2334 I2C_BOARD_INFO("adau1701", 0x34), 2306 I2C_BOARD_INFO("adau1701", 0x34),
2335 }, 2307 },
2336#endif 2308#endif
2337#if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE) 2309#if IS_ENABLED(CONFIG_AD525X_DPOT)
2338 { 2310 {
2339 I2C_BOARD_INFO("ad5258", 0x18), 2311 I2C_BOARD_INFO("ad5258", 0x18),
2340 }, 2312 },
2341#endif 2313#endif
2342#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 2314#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
2343 { 2315 {
2344 I2C_BOARD_INFO("ssm2602", 0x1b), 2316 I2C_BOARD_INFO("ssm2602", 0x1b),
2345 }, 2317 },
2346#endif 2318#endif
2347#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE) 2319#if IS_ENABLED(CONFIG_REGULATOR_AD5398)
2348 { 2320 {
2349 I2C_BOARD_INFO("ad5398", 0xC), 2321 I2C_BOARD_INFO("ad5398", 0xC),
2350 .platform_data = (void *)&ad5398_regulator_data, 2322 .platform_data = (void *)&ad5398_regulator_data,
2351 }, 2323 },
2352#endif 2324#endif
2353#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE) 2325#if IS_ENABLED(CONFIG_BACKLIGHT_ADP8860)
2354 { 2326 {
2355 I2C_BOARD_INFO("adp8860", 0x2A), 2327 I2C_BOARD_INFO("adp8860", 0x2A),
2356 .platform_data = (void *)&adp8860_pdata, 2328 .platform_data = (void *)&adp8860_pdata,
2357 }, 2329 },
2358#endif 2330#endif
2359#if defined(CONFIG_SND_SOC_ADAU1373) || defined(CONFIG_SND_SOC_ADAU1373_MODULE) 2331#if IS_ENABLED(CONFIG_SND_SOC_ADAU1373)
2360 { 2332 {
2361 I2C_BOARD_INFO("adau1373", 0x1A), 2333 I2C_BOARD_INFO("adau1373", 0x1A),
2362 }, 2334 },
2363#endif 2335#endif
2364#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 2336#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
2365 { 2337 {
2366 I2C_BOARD_INFO("ad5252", 0x2e), 2338 I2C_BOARD_INFO("ad5252", 0x2e),
2367 }, 2339 },
2368#endif 2340#endif
2369}; 2341};
2370#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) \ 2342#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT) \
2371|| defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 2343|| IS_ENABLED(CONFIG_BFIN_SPORT)
2372unsigned short bfin_sport0_peripherals[] = { 2344unsigned short bfin_sport0_peripherals[] = {
2373 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, 2345 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
2374 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0 2346 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
2375}; 2347};
2376#endif 2348#endif
2377#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 2349#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
2378#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 2350#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
2379static struct resource bfin_sport0_uart_resources[] = { 2351static struct resource bfin_sport0_uart_resources[] = {
2380 { 2352 {
@@ -2439,7 +2411,7 @@ static struct platform_device bfin_sport1_uart_device = {
2439}; 2411};
2440#endif 2412#endif
2441#endif 2413#endif
2442#if defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 2414#if IS_ENABLED(CONFIG_BFIN_SPORT)
2443static struct resource bfin_sport0_resources[] = { 2415static struct resource bfin_sport0_resources[] = {
2444 { 2416 {
2445 .start = SPORT0_TCR1, 2417 .start = SPORT0_TCR1,
@@ -2482,7 +2454,7 @@ static struct platform_device bfin_sport0_device = {
2482 }, 2454 },
2483}; 2455};
2484#endif 2456#endif
2485#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 2457#if IS_ENABLED(CONFIG_PATA_PLATFORM)
2486#define CF_IDE_NAND_CARD_USE_HDD_INTERFACE 2458#define CF_IDE_NAND_CARD_USE_HDD_INTERFACE
2487/* #define CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE */ 2459/* #define CF_IDE_NAND_CARD_USE_CF_IN_COMMON_MEMORY_MODE */
2488 2460
@@ -2569,8 +2541,8 @@ static struct platform_device bfin_dpmc = {
2569 }, 2541 },
2570}; 2542};
2571 2543
2572#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) || \ 2544#if IS_ENABLED(CONFIG_SND_BF5XX_I2S) || \
2573 defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 2545 IS_ENABLED(CONFIG_SND_BF5XX_AC97)
2574 2546
2575#define SPORT_REQ(x) \ 2547#define SPORT_REQ(x) \
2576 [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \ 2548 [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \
@@ -2620,22 +2592,21 @@ static struct resource bfin_snd_resources[][4] = {
2620}; 2592};
2621#endif 2593#endif
2622 2594
2623#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 2595#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
2624static struct platform_device bfin_i2s_pcm = { 2596static struct platform_device bfin_i2s_pcm = {
2625 .name = "bfin-i2s-pcm-audio", 2597 .name = "bfin-i2s-pcm-audio",
2626 .id = -1, 2598 .id = -1,
2627}; 2599};
2628#endif 2600#endif
2629 2601
2630#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 2602#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
2631static struct platform_device bfin_ac97_pcm = { 2603static struct platform_device bfin_ac97_pcm = {
2632 .name = "bfin-ac97-pcm-audio", 2604 .name = "bfin-ac97-pcm-audio",
2633 .id = -1, 2605 .id = -1,
2634}; 2606};
2635#endif 2607#endif
2636 2608
2637#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 2609#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
2638 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
2639static const char * const ad1836_link[] = { 2610static const char * const ad1836_link[] = {
2640 "bfin-i2s.0", 2611 "bfin-i2s.0",
2641 "spi0.4", 2612 "spi0.4",
@@ -2649,8 +2620,7 @@ static struct platform_device bfin_ad1836_machine = {
2649}; 2620};
2650#endif 2621#endif
2651 2622
2652#if defined(CONFIG_SND_BF5XX_SOC_AD73311) || \ 2623#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
2653 defined(CONFIG_SND_BF5XX_SOC_AD73311_MODULE)
2654static const unsigned ad73311_gpio[] = { 2624static const unsigned ad73311_gpio[] = {
2655 GPIO_PF4, 2625 GPIO_PF4,
2656}; 2626};
@@ -2664,22 +2634,21 @@ static struct platform_device bfin_ad73311_machine = {
2664}; 2634};
2665#endif 2635#endif
2666 2636
2667#if defined(CONFIG_SND_SOC_AD73311) || defined(CONFIG_SND_SOC_AD73311_MODULE) 2637#if IS_ENABLED(CONFIG_SND_SOC_AD73311)
2668static struct platform_device bfin_ad73311_codec_device = { 2638static struct platform_device bfin_ad73311_codec_device = {
2669 .name = "ad73311", 2639 .name = "ad73311",
2670 .id = -1, 2640 .id = -1,
2671}; 2641};
2672#endif 2642#endif
2673 2643
2674#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) || \ 2644#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X)
2675 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X_MODULE)
2676static struct platform_device bfin_eval_adav801_device = { 2645static struct platform_device bfin_eval_adav801_device = {
2677 .name = "bfin-eval-adav801", 2646 .name = "bfin-eval-adav801",
2678 .id = -1, 2647 .id = -1,
2679}; 2648};
2680#endif 2649#endif
2681 2650
2682#if defined(CONFIG_SND_BF5XX_SOC_I2S) || defined(CONFIG_SND_BF5XX_SOC_I2S_MODULE) 2651#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
2683static struct platform_device bfin_i2s = { 2652static struct platform_device bfin_i2s = {
2684 .name = "bfin-i2s", 2653 .name = "bfin-i2s",
2685 .id = CONFIG_SND_BF5XX_SPORT_NUM, 2654 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -2691,7 +2660,7 @@ static struct platform_device bfin_i2s = {
2691}; 2660};
2692#endif 2661#endif
2693 2662
2694#if defined(CONFIG_SND_BF5XX_SOC_AC97) || defined(CONFIG_SND_BF5XX_SOC_AC97_MODULE) 2663#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
2695static struct platform_device bfin_ac97 = { 2664static struct platform_device bfin_ac97 = {
2696 .name = "bfin-ac97", 2665 .name = "bfin-ac97",
2697 .id = CONFIG_SND_BF5XX_SPORT_NUM, 2666 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -2703,7 +2672,7 @@ static struct platform_device bfin_ac97 = {
2703}; 2672};
2704#endif 2673#endif
2705 2674
2706#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) 2675#if IS_ENABLED(CONFIG_REGULATOR_FIXED_VOLTAGE)
2707#define REGULATOR_ADP122 "adp122" 2676#define REGULATOR_ADP122 "adp122"
2708#define REGULATOR_ADP122_UV 2500000 2677#define REGULATOR_ADP122_UV 2500000
2709 2678
@@ -2741,8 +2710,7 @@ static struct platform_device adp_switch_device = {
2741 }, 2710 },
2742}; 2711};
2743 2712
2744#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2713#if IS_ENABLED(CONFIG_REGULATOR_USERSPACE_CONSUMER)
2745 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2746static struct regulator_bulk_data adp122_bulk_data = { 2714static struct regulator_bulk_data adp122_bulk_data = {
2747 .supply = REGULATOR_ADP122, 2715 .supply = REGULATOR_ADP122,
2748}; 2716};
@@ -2763,8 +2731,7 @@ static struct platform_device adp122_userspace_consumer_device = {
2763#endif 2731#endif
2764#endif 2732#endif
2765 2733
2766#if defined(CONFIG_IIO_GPIO_TRIGGER) || \ 2734#if IS_ENABLED(CONFIG_IIO_GPIO_TRIGGER)
2767 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2768 2735
2769static struct resource iio_gpio_trigger_resources[] = { 2736static struct resource iio_gpio_trigger_resources[] = {
2770 [0] = { 2737 [0] = {
@@ -2781,15 +2748,13 @@ static struct platform_device iio_gpio_trigger = {
2781}; 2748};
2782#endif 2749#endif
2783 2750
2784#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) || \ 2751#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373)
2785 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373_MODULE)
2786static struct platform_device bf5xx_adau1373_device = { 2752static struct platform_device bf5xx_adau1373_device = {
2787 .name = "bfin-eval-adau1373", 2753 .name = "bfin-eval-adau1373",
2788}; 2754};
2789#endif 2755#endif
2790 2756
2791#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) || \ 2757#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701)
2792 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701_MODULE)
2793static struct platform_device bf5xx_adau1701_device = { 2758static struct platform_device bf5xx_adau1701_device = {
2794 .name = "bfin-eval-adau1701", 2759 .name = "bfin-eval-adau1701",
2795}; 2760};
@@ -2798,73 +2763,72 @@ static struct platform_device bf5xx_adau1701_device = {
2798static struct platform_device *stamp_devices[] __initdata = { 2763static struct platform_device *stamp_devices[] __initdata = {
2799 2764
2800 &bfin_dpmc, 2765 &bfin_dpmc,
2801#if defined(CONFIG_BFIN_SPORT) || defined(CONFIG_BFIN_SPORT_MODULE) 2766#if IS_ENABLED(CONFIG_BFIN_SPORT)
2802 &bfin_sport0_device, 2767 &bfin_sport0_device,
2803#endif 2768#endif
2804#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 2769#if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
2805 &bfin_pcmcia_cf_device, 2770 &bfin_pcmcia_cf_device,
2806#endif 2771#endif
2807 2772
2808#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 2773#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
2809 &rtc_device, 2774 &rtc_device,
2810#endif 2775#endif
2811 2776
2812#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE) 2777#if IS_ENABLED(CONFIG_USB_SL811_HCD)
2813 &sl811_hcd_device, 2778 &sl811_hcd_device,
2814#endif 2779#endif
2815 2780
2816#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 2781#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
2817 &isp1362_hcd_device, 2782 &isp1362_hcd_device,
2818#endif 2783#endif
2819 2784
2820#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 2785#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
2821 &bfin_isp1760_device, 2786 &bfin_isp1760_device,
2822#endif 2787#endif
2823 2788
2824#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 2789#if IS_ENABLED(CONFIG_SMC91X)
2825 &smc91x_device, 2790 &smc91x_device,
2826#endif 2791#endif
2827 2792
2828#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) 2793#if IS_ENABLED(CONFIG_DM9000)
2829 &dm9000_device, 2794 &dm9000_device,
2830#endif 2795#endif
2831 2796
2832#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 2797#if IS_ENABLED(CONFIG_CAN_BFIN)
2833 &bfin_can_device, 2798 &bfin_can_device,
2834#endif 2799#endif
2835 2800
2836#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 2801#if IS_ENABLED(CONFIG_BFIN_MAC)
2837 &bfin_mii_bus, 2802 &bfin_mii_bus,
2838 &bfin_mac_device, 2803 &bfin_mac_device,
2839#endif 2804#endif
2840 2805
2841#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 2806#if IS_ENABLED(CONFIG_USB_NET2272)
2842 &net2272_bfin_device, 2807 &net2272_bfin_device,
2843#endif 2808#endif
2844 2809
2845#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 2810#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
2846 &bfin_spi0_device, 2811 &bfin_spi0_device,
2847#endif 2812#endif
2848 2813
2849#if defined(CONFIG_SPI_BFIN_SPORT) || defined(CONFIG_SPI_BFIN_SPORT_MODULE) 2814#if IS_ENABLED(CONFIG_SPI_BFIN_SPORT)
2850 &bfin_sport_spi0_device, 2815 &bfin_sport_spi0_device,
2851 &bfin_sport_spi1_device, 2816 &bfin_sport_spi1_device,
2852#endif 2817#endif
2853 2818
2854#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 2819#if IS_ENABLED(CONFIG_FB_BF537_LQ035)
2855 &bfin_fb_device, 2820 &bfin_fb_device,
2856#endif 2821#endif
2857 2822
2858#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 2823#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
2859 &bfin_lq035q1_device, 2824 &bfin_lq035q1_device,
2860#endif 2825#endif
2861 2826
2862#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 2827#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
2863 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
2864 &bfin_capture_device, 2828 &bfin_capture_device,
2865#endif 2829#endif
2866 2830
2867#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 2831#if IS_ENABLED(CONFIG_SERIAL_BFIN)
2868#ifdef CONFIG_SERIAL_BFIN_UART0 2832#ifdef CONFIG_SERIAL_BFIN_UART0
2869 &bfin_uart0_device, 2833 &bfin_uart0_device,
2870#endif 2834#endif
@@ -2873,7 +2837,7 @@ static struct platform_device *stamp_devices[] __initdata = {
2873#endif 2837#endif
2874#endif 2838#endif
2875 2839
2876#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 2840#if IS_ENABLED(CONFIG_BFIN_SIR)
2877#ifdef CONFIG_BFIN_SIR0 2841#ifdef CONFIG_BFIN_SIR0
2878 &bfin_sir0_device, 2842 &bfin_sir0_device,
2879#endif 2843#endif
@@ -2882,11 +2846,11 @@ static struct platform_device *stamp_devices[] __initdata = {
2882#endif 2846#endif
2883#endif 2847#endif
2884 2848
2885#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 2849#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
2886 &i2c_bfin_twi_device, 2850 &i2c_bfin_twi_device,
2887#endif 2851#endif
2888 2852
2889#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 2853#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
2890#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 2854#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
2891 &bfin_sport0_uart_device, 2855 &bfin_sport0_uart_device,
2892#endif 2856#endif
@@ -2895,95 +2859,86 @@ static struct platform_device *stamp_devices[] __initdata = {
2895#endif 2859#endif
2896#endif 2860#endif
2897 2861
2898#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 2862#if IS_ENABLED(CONFIG_PATA_PLATFORM)
2899 &bfin_pata_device, 2863 &bfin_pata_device,
2900#endif 2864#endif
2901 2865
2902#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 2866#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
2903 &bfin_device_gpiokeys, 2867 &bfin_device_gpiokeys,
2904#endif 2868#endif
2905 2869
2906#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 2870#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
2907 &bfin_async_nand_device, 2871 &bfin_async_nand_device,
2908#endif 2872#endif
2909 2873
2910#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 2874#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
2911 &stamp_flash_device, 2875 &stamp_flash_device,
2912#endif 2876#endif
2913 2877
2914#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 2878#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
2915 &bfin_i2s_pcm, 2879 &bfin_i2s_pcm,
2916#endif 2880#endif
2917 2881
2918#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 2882#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
2919 &bfin_ac97_pcm, 2883 &bfin_ac97_pcm,
2920#endif 2884#endif
2921 2885
2922#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 2886#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
2923 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
2924 &bfin_ad1836_machine, 2887 &bfin_ad1836_machine,
2925#endif 2888#endif
2926 2889
2927#if defined(CONFIG_SND_BF5XX_SOC_AD73311) || \ 2890#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
2928 defined(CONFIG_SND_BF5XX_SOC_AD73311_MODULE)
2929 &bfin_ad73311_machine, 2891 &bfin_ad73311_machine,
2930#endif 2892#endif
2931 2893
2932#if defined(CONFIG_SND_SOC_AD73311) || defined(CONFIG_SND_SOC_AD73311_MODULE) 2894#if IS_ENABLED(CONFIG_SND_SOC_AD73311)
2933 &bfin_ad73311_codec_device, 2895 &bfin_ad73311_codec_device,
2934#endif 2896#endif
2935 2897
2936#if defined(CONFIG_SND_BF5XX_SOC_I2S) || defined(CONFIG_SND_BF5XX_SOC_I2S_MODULE) 2898#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
2937 &bfin_i2s, 2899 &bfin_i2s,
2938#endif 2900#endif
2939 2901
2940#if defined(CONFIG_SND_BF5XX_SOC_AC97) || defined(CONFIG_SND_BF5XX_SOC_AC97_MODULE) 2902#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
2941 &bfin_ac97, 2903 &bfin_ac97,
2942#endif 2904#endif
2943 2905
2944#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE) 2906#if IS_ENABLED(CONFIG_REGULATOR_AD5398)
2945#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \ 2907#if IS_ENABLED(CONFIG_REGULATOR_VIRTUAL_CONSUMER)
2946 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
2947 &ad5398_virt_consumer_device, 2908 &ad5398_virt_consumer_device,
2948#endif 2909#endif
2949#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2910#if IS_ENABLED(CONFIG_REGULATOR_USERSPACE_CONSUMER)
2950 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2951 &ad5398_userspace_consumer_device, 2911 &ad5398_userspace_consumer_device,
2952#endif 2912#endif
2953#endif 2913#endif
2954 2914
2955#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) 2915#if IS_ENABLED(CONFIG_REGULATOR_FIXED_VOLTAGE)
2956 &adp_switch_device, 2916 &adp_switch_device,
2957#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2917#if IS_ENABLED(CONFIG_REGULATOR_USERSPACE_CONSUMER)
2958 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2959 &adp122_userspace_consumer_device, 2918 &adp122_userspace_consumer_device,
2960#endif 2919#endif
2961#endif 2920#endif
2962 2921
2963#if defined(CONFIG_IIO_GPIO_TRIGGER) || \ 2922#if IS_ENABLED(CONFIG_IIO_GPIO_TRIGGER)
2964 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2965 &iio_gpio_trigger, 2923 &iio_gpio_trigger,
2966#endif 2924#endif
2967 2925
2968#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) || \ 2926#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373)
2969 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373_MODULE)
2970 &bf5xx_adau1373_device, 2927 &bf5xx_adau1373_device,
2971#endif 2928#endif
2972 2929
2973#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) || \ 2930#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701)
2974 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701_MODULE)
2975 &bf5xx_adau1701_device, 2931 &bf5xx_adau1701_device,
2976#endif 2932#endif
2977 2933
2978#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) || \ 2934#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X)
2979 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X_MODULE)
2980 &bfin_eval_adav801_device, 2935 &bfin_eval_adav801_device,
2981#endif 2936#endif
2982}; 2937};
2983 2938
2984static int __init net2272_init(void) 2939static int __init net2272_init(void)
2985{ 2940{
2986#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 2941#if IS_ENABLED(CONFIG_USB_NET2272)
2987 int ret; 2942 int ret;
2988 2943
2989 ret = gpio_request(GPIO_PF6, "net2272"); 2944 ret = gpio_request(GPIO_PF6, "net2272");
diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
index e285c3675286..a0211225748d 100644
--- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
@@ -16,7 +16,7 @@
16#include <linux/mtd/physmap.h> 16#include <linux/mtd/physmap.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <linux/spi/flash.h> 18#include <linux/spi/flash.h>
19#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 19#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
20#include <linux/usb/isp1362.h> 20#include <linux/usb/isp1362.h>
21#endif 21#endif
22#include <linux/ata_platform.h> 22#include <linux/ata_platform.h>
@@ -32,10 +32,10 @@
32 */ 32 */
33const char bfin_board_name[] = "Bluetechnix TCM BF537"; 33const char bfin_board_name[] = "Bluetechnix TCM BF537";
34 34
35#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 35#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
36/* all SPI peripherals info goes here */ 36/* all SPI peripherals info goes here */
37 37
38#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 38#if IS_ENABLED(CONFIG_MTD_M25P80)
39static struct mtd_partition bfin_spi_flash_partitions[] = { 39static struct mtd_partition bfin_spi_flash_partitions[] = {
40 { 40 {
41 .name = "bootloader(spi)", 41 .name = "bootloader(spi)",
@@ -66,14 +66,14 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
66}; 66};
67#endif 67#endif
68 68
69#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 69#if IS_ENABLED(CONFIG_MMC_SPI)
70static struct bfin5xx_spi_chip mmc_spi_chip_info = { 70static struct bfin5xx_spi_chip mmc_spi_chip_info = {
71 .enable_dma = 0, 71 .enable_dma = 0,
72}; 72};
73#endif 73#endif
74 74
75static struct spi_board_info bfin_spi_board_info[] __initdata = { 75static struct spi_board_info bfin_spi_board_info[] __initdata = {
76#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 76#if IS_ENABLED(CONFIG_MTD_M25P80)
77 { 77 {
78 /* the modalias must be the same as spi device driver name */ 78 /* the modalias must be the same as spi device driver name */
79 .modalias = "m25p80", /* Name of spi_driver for this device */ 79 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -86,7 +86,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
86 }, 86 },
87#endif 87#endif
88 88
89#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 89#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
90 { 90 {
91 .modalias = "ad183x", 91 .modalias = "ad183x",
92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 92 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -95,7 +95,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
95 }, 95 },
96#endif 96#endif
97 97
98#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 98#if IS_ENABLED(CONFIG_MMC_SPI)
99 { 99 {
100 .modalias = "mmc_spi", 100 .modalias = "mmc_spi",
101 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ 101 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
@@ -144,20 +144,20 @@ static struct platform_device bfin_spi0_device = {
144}; 144};
145#endif /* spi master and devices */ 145#endif /* spi master and devices */
146 146
147#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 147#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
148static struct platform_device rtc_device = { 148static struct platform_device rtc_device = {
149 .name = "rtc-bfin", 149 .name = "rtc-bfin",
150 .id = -1, 150 .id = -1,
151}; 151};
152#endif 152#endif
153 153
154#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 154#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
155static struct platform_device hitachi_fb_device = { 155static struct platform_device hitachi_fb_device = {
156 .name = "hitachi-tx09", 156 .name = "hitachi-tx09",
157}; 157};
158#endif 158#endif
159 159
160#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 160#if IS_ENABLED(CONFIG_SMC91X)
161#include <linux/smc91x.h> 161#include <linux/smc91x.h>
162 162
163static struct smc91x_platdata smc91x_info = { 163static struct smc91x_platdata smc91x_info = {
@@ -189,7 +189,7 @@ static struct platform_device smc91x_device = {
189}; 189};
190#endif 190#endif
191 191
192#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 192#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
193static struct resource isp1362_hcd_resources[] = { 193static struct resource isp1362_hcd_resources[] = {
194 { 194 {
195 .start = 0x20308000, 195 .start = 0x20308000,
@@ -228,7 +228,7 @@ static struct platform_device isp1362_hcd_device = {
228}; 228};
229#endif 229#endif
230 230
231#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 231#if IS_ENABLED(CONFIG_USB_NET2272)
232static struct resource net2272_bfin_resources[] = { 232static struct resource net2272_bfin_resources[] = {
233 { 233 {
234 .start = 0x20300000, 234 .start = 0x20300000,
@@ -249,7 +249,7 @@ static struct platform_device net2272_bfin_device = {
249}; 249};
250#endif 250#endif
251 251
252#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 252#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
253static struct mtd_partition cm_partitions[] = { 253static struct mtd_partition cm_partitions[] = {
254 { 254 {
255 .name = "bootloader(nor)", 255 .name = "bootloader(nor)",
@@ -298,7 +298,7 @@ static struct platform_device cm_flash_device = {
298}; 298};
299#endif 299#endif
300 300
301#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 301#if IS_ENABLED(CONFIG_SERIAL_BFIN)
302#ifdef CONFIG_SERIAL_BFIN_UART0 302#ifdef CONFIG_SERIAL_BFIN_UART0
303static struct resource bfin_uart0_resources[] = { 303static struct resource bfin_uart0_resources[] = {
304 { 304 {
@@ -397,7 +397,7 @@ static struct platform_device bfin_uart1_device = {
397#endif 397#endif
398#endif 398#endif
399 399
400#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 400#if IS_ENABLED(CONFIG_BFIN_SIR)
401#ifdef CONFIG_BFIN_SIR0 401#ifdef CONFIG_BFIN_SIR0
402static struct resource bfin_sir0_resources[] = { 402static struct resource bfin_sir0_resources[] = {
403 { 403 {
@@ -452,7 +452,7 @@ static struct platform_device bfin_sir1_device = {
452#endif 452#endif
453#endif 453#endif
454 454
455#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 455#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
456static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 456static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
457 457
458static struct resource bfin_twi0_resource[] = { 458static struct resource bfin_twi0_resource[] = {
@@ -479,7 +479,7 @@ static struct platform_device i2c_bfin_twi_device = {
479}; 479};
480#endif 480#endif
481 481
482#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 482#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
483#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 483#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
484static struct resource bfin_sport0_uart_resources[] = { 484static struct resource bfin_sport0_uart_resources[] = {
485 { 485 {
@@ -550,7 +550,7 @@ static struct platform_device bfin_sport1_uart_device = {
550#endif 550#endif
551#endif 551#endif
552 552
553#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 553#if IS_ENABLED(CONFIG_BFIN_MAC)
554#include <linux/bfin_mac.h> 554#include <linux/bfin_mac.h>
555static const unsigned short bfin_mac_peripherals[] = P_MII0; 555static const unsigned short bfin_mac_peripherals[] = P_MII0;
556 556
@@ -583,7 +583,7 @@ static struct platform_device bfin_mac_device = {
583}; 583};
584#endif 584#endif
585 585
586#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 586#if IS_ENABLED(CONFIG_PATA_PLATFORM)
587#define PATA_INT IRQ_PF14 587#define PATA_INT IRQ_PF14
588 588
589static struct pata_platform_info bfin_pata_platform_data = { 589static struct pata_platform_info bfin_pata_platform_data = {
@@ -651,15 +651,15 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
651 651
652 &bfin_dpmc, 652 &bfin_dpmc,
653 653
654#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 654#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
655 &hitachi_fb_device, 655 &hitachi_fb_device,
656#endif 656#endif
657 657
658#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 658#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
659 &rtc_device, 659 &rtc_device,
660#endif 660#endif
661 661
662#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 662#if IS_ENABLED(CONFIG_SERIAL_BFIN)
663#ifdef CONFIG_SERIAL_BFIN_UART0 663#ifdef CONFIG_SERIAL_BFIN_UART0
664 &bfin_uart0_device, 664 &bfin_uart0_device,
665#endif 665#endif
@@ -668,7 +668,7 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
668#endif 668#endif
669#endif 669#endif
670 670
671#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 671#if IS_ENABLED(CONFIG_BFIN_SIR)
672#ifdef CONFIG_BFIN_SIR0 672#ifdef CONFIG_BFIN_SIR0
673 &bfin_sir0_device, 673 &bfin_sir0_device,
674#endif 674#endif
@@ -677,11 +677,11 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
677#endif 677#endif
678#endif 678#endif
679 679
680#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 680#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
681 &i2c_bfin_twi_device, 681 &i2c_bfin_twi_device,
682#endif 682#endif
683 683
684#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 684#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
685#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 685#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
686 &bfin_sport0_uart_device, 686 &bfin_sport0_uart_device,
687#endif 687#endif
@@ -690,39 +690,39 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
690#endif 690#endif
691#endif 691#endif
692 692
693#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 693#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
694 &isp1362_hcd_device, 694 &isp1362_hcd_device,
695#endif 695#endif
696 696
697#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 697#if IS_ENABLED(CONFIG_SMC91X)
698 &smc91x_device, 698 &smc91x_device,
699#endif 699#endif
700 700
701#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 701#if IS_ENABLED(CONFIG_BFIN_MAC)
702 &bfin_mii_bus, 702 &bfin_mii_bus,
703 &bfin_mac_device, 703 &bfin_mac_device,
704#endif 704#endif
705 705
706#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 706#if IS_ENABLED(CONFIG_USB_NET2272)
707 &net2272_bfin_device, 707 &net2272_bfin_device,
708#endif 708#endif
709 709
710#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 710#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
711 &bfin_spi0_device, 711 &bfin_spi0_device,
712#endif 712#endif
713 713
714#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 714#if IS_ENABLED(CONFIG_PATA_PLATFORM)
715 &bfin_pata_device, 715 &bfin_pata_device,
716#endif 716#endif
717 717
718#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE) 718#if IS_ENABLED(CONFIG_MTD_GPIO_ADDR)
719 &cm_flash_device, 719 &cm_flash_device,
720#endif 720#endif
721}; 721};
722 722
723static int __init net2272_init(void) 723static int __init net2272_init(void)
724{ 724{
725#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 725#if IS_ENABLED(CONFIG_USB_NET2272)
726 int ret; 726 int ret;
727 727
728 ret = gpio_request(GPIO_PG14, "net2272"); 728 ret = gpio_request(GPIO_PG14, "net2272");
@@ -742,11 +742,11 @@ static int __init tcm_bf537_init(void)
742{ 742{
743 printk(KERN_INFO "%s(): registering device resources\n", __func__); 743 printk(KERN_INFO "%s(): registering device resources\n", __func__);
744 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices)); 744 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
745#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 745#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
746 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 746 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
747#endif 747#endif
748 748
749#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 749#if IS_ENABLED(CONFIG_PATA_PLATFORM)
750 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN); 750 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
751#endif 751#endif
752 752
diff --git a/arch/blackfin/mach-bf538/boards/ezkit.c b/arch/blackfin/mach-bf538/boards/ezkit.c
index 755f0dc12010..ae2fcbb00119 100644
--- a/arch/blackfin/mach-bf538/boards/ezkit.c
+++ b/arch/blackfin/mach-bf538/boards/ezkit.c
@@ -33,14 +33,14 @@ const char bfin_board_name[] = "ADI BF538-EZKIT";
33 */ 33 */
34 34
35 35
36#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 36#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
37static struct platform_device rtc_device = { 37static struct platform_device rtc_device = {
38 .name = "rtc-bfin", 38 .name = "rtc-bfin",
39 .id = -1, 39 .id = -1,
40}; 40};
41#endif /* CONFIG_RTC_DRV_BFIN */ 41#endif /* CONFIG_RTC_DRV_BFIN */
42 42
43#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 43#if IS_ENABLED(CONFIG_SERIAL_BFIN)
44#ifdef CONFIG_SERIAL_BFIN_UART0 44#ifdef CONFIG_SERIAL_BFIN_UART0
45static struct resource bfin_uart0_resources[] = { 45static struct resource bfin_uart0_resources[] = {
46 { 46 {
@@ -199,7 +199,7 @@ static struct platform_device bfin_uart2_device = {
199#endif /* CONFIG_SERIAL_BFIN_UART2 */ 199#endif /* CONFIG_SERIAL_BFIN_UART2 */
200#endif /* CONFIG_SERIAL_BFIN */ 200#endif /* CONFIG_SERIAL_BFIN */
201 201
202#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 202#if IS_ENABLED(CONFIG_BFIN_SIR)
203#ifdef CONFIG_BFIN_SIR0 203#ifdef CONFIG_BFIN_SIR0
204static struct resource bfin_sir0_resources[] = { 204static struct resource bfin_sir0_resources[] = {
205 { 205 {
@@ -277,7 +277,7 @@ static struct platform_device bfin_sir2_device = {
277#endif /* CONFIG_BFIN_SIR2 */ 277#endif /* CONFIG_BFIN_SIR2 */
278#endif /* CONFIG_BFIN_SIR */ 278#endif /* CONFIG_BFIN_SIR */
279 279
280#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 280#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
281#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 281#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
282static struct resource bfin_sport0_uart_resources[] = { 282static struct resource bfin_sport0_uart_resources[] = {
283 { 283 {
@@ -416,7 +416,7 @@ static struct platform_device bfin_sport3_uart_device = {
416#endif /* CONFIG_SERIAL_BFIN_SPORT3_UART */ 416#endif /* CONFIG_SERIAL_BFIN_SPORT3_UART */
417#endif /* CONFIG_SERIAL_BFIN_SPORT */ 417#endif /* CONFIG_SERIAL_BFIN_SPORT */
418 418
419#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 419#if IS_ENABLED(CONFIG_CAN_BFIN)
420static unsigned short bfin_can_peripherals[] = { 420static unsigned short bfin_can_peripherals[] = {
421 P_CAN0_RX, P_CAN0_TX, 0 421 P_CAN0_RX, P_CAN0_TX, 0
422}; 422};
@@ -458,7 +458,7 @@ static struct platform_device bfin_can_device = {
458 * USB-LAN EzExtender board 458 * USB-LAN EzExtender board
459 * Driver needs to know address, irq and flag pin. 459 * Driver needs to know address, irq and flag pin.
460 */ 460 */
461#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 461#if IS_ENABLED(CONFIG_SMC91X)
462#include <linux/smc91x.h> 462#include <linux/smc91x.h>
463 463
464static struct smc91x_platdata smc91x_info = { 464static struct smc91x_platdata smc91x_info = {
@@ -490,10 +490,9 @@ static struct platform_device smc91x_device = {
490}; 490};
491#endif /* CONFIG_SMC91X */ 491#endif /* CONFIG_SMC91X */
492 492
493#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 493#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
494/* all SPI peripherals info goes here */ 494/* all SPI peripherals info goes here */
495#if defined(CONFIG_MTD_M25P80) \ 495#if IS_ENABLED(CONFIG_MTD_M25P80)
496 || defined(CONFIG_MTD_M25P80_MODULE)
497/* SPI flash chip (m25p16) */ 496/* SPI flash chip (m25p16) */
498static struct mtd_partition bfin_spi_flash_partitions[] = { 497static struct mtd_partition bfin_spi_flash_partitions[] = {
499 { 498 {
@@ -521,7 +520,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
521#endif /* CONFIG_MTD_M25P80 */ 520#endif /* CONFIG_MTD_M25P80 */
522#endif /* CONFIG_SPI_BFIN5XX */ 521#endif /* CONFIG_SPI_BFIN5XX */
523 522
524#if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) 523#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
525#include <linux/spi/ad7879.h> 524#include <linux/spi/ad7879.h>
526static const struct ad7879_platform_data bfin_ad7879_ts_info = { 525static const struct ad7879_platform_data bfin_ad7879_ts_info = {
527 .model = 7879, /* Model = AD7879 */ 526 .model = 7879, /* Model = AD7879 */
@@ -538,7 +537,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
538}; 537};
539#endif /* CONFIG_TOUCHSCREEN_AD7879 */ 538#endif /* CONFIG_TOUCHSCREEN_AD7879 */
540 539
541#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 540#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
542#include <asm/bfin-lq035q1.h> 541#include <asm/bfin-lq035q1.h>
543 542
544static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = { 543static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
@@ -568,8 +567,7 @@ static struct platform_device bfin_lq035q1_device = {
568#endif /* CONFIG_FB_BFIN_LQ035Q1 */ 567#endif /* CONFIG_FB_BFIN_LQ035Q1 */
569 568
570static struct spi_board_info bf538_spi_board_info[] __initdata = { 569static struct spi_board_info bf538_spi_board_info[] __initdata = {
571#if defined(CONFIG_MTD_M25P80) \ 570#if IS_ENABLED(CONFIG_MTD_M25P80)
572 || defined(CONFIG_MTD_M25P80_MODULE)
573 { 571 {
574 /* the modalias must be the same as spi device driver name */ 572 /* the modalias must be the same as spi device driver name */
575 .modalias = "m25p80", /* Name of spi_driver for this device */ 573 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -581,7 +579,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
581 .mode = SPI_MODE_3, 579 .mode = SPI_MODE_3,
582 }, 580 },
583#endif /* CONFIG_MTD_M25P80 */ 581#endif /* CONFIG_MTD_M25P80 */
584#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 582#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879_SPI)
585 { 583 {
586 .modalias = "ad7879", 584 .modalias = "ad7879",
587 .platform_data = &bfin_ad7879_ts_info, 585 .platform_data = &bfin_ad7879_ts_info,
@@ -592,7 +590,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
592 .mode = SPI_CPHA | SPI_CPOL, 590 .mode = SPI_CPHA | SPI_CPOL,
593 }, 591 },
594#endif /* CONFIG_TOUCHSCREEN_AD7879_SPI */ 592#endif /* CONFIG_TOUCHSCREEN_AD7879_SPI */
595#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 593#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
596 { 594 {
597 .modalias = "bfin-lq035q1-spi", 595 .modalias = "bfin-lq035q1-spi",
598 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 596 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -601,7 +599,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
601 .mode = SPI_CPHA | SPI_CPOL, 599 .mode = SPI_CPHA | SPI_CPOL,
602 }, 600 },
603#endif /* CONFIG_FB_BFIN_LQ035Q1 */ 601#endif /* CONFIG_FB_BFIN_LQ035Q1 */
604#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 602#if IS_ENABLED(CONFIG_SPI_SPIDEV)
605 { 603 {
606 .modalias = "spidev", 604 .modalias = "spidev",
607 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 605 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -717,7 +715,7 @@ static struct platform_device bf538_spi_master2 = {
717 }, 715 },
718}; 716};
719 717
720#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 718#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
721static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 719static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
722 720
723static struct resource bfin_twi0_resource[] = { 721static struct resource bfin_twi0_resource[] = {
@@ -766,7 +764,7 @@ static struct platform_device i2c_bfin_twi1_device = {
766}; 764};
767#endif /* CONFIG_I2C_BLACKFIN_TWI */ 765#endif /* CONFIG_I2C_BLACKFIN_TWI */
768 766
769#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 767#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
770#include <linux/gpio_keys.h> 768#include <linux/gpio_keys.h>
771 769
772static struct gpio_keys_button bfin_gpio_keys_table[] = { 770static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -814,7 +812,7 @@ static struct platform_device bfin_dpmc = {
814 }, 812 },
815}; 813};
816 814
817#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 815#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
818static struct mtd_partition ezkit_partitions[] = { 816static struct mtd_partition ezkit_partitions[] = {
819 { 817 {
820 .name = "bootloader(nor)", 818 .name = "bootloader(nor)",
@@ -839,7 +837,7 @@ static struct physmap_flash_data ezkit_flash_data = {
839 837
840static struct resource ezkit_flash_resource = { 838static struct resource ezkit_flash_resource = {
841 .start = 0x20000000, 839 .start = 0x20000000,
842#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 840#if IS_ENABLED(CONFIG_SMC91X)
843 .end = 0x202fffff, 841 .end = 0x202fffff,
844#else 842#else
845 .end = 0x203fffff, 843 .end = 0x203fffff,
@@ -862,11 +860,11 @@ static struct platform_device *cm_bf538_devices[] __initdata = {
862 860
863 &bfin_dpmc, 861 &bfin_dpmc,
864 862
865#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 863#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
866 &rtc_device, 864 &rtc_device,
867#endif 865#endif
868 866
869#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 867#if IS_ENABLED(CONFIG_SERIAL_BFIN)
870#ifdef CONFIG_SERIAL_BFIN_UART0 868#ifdef CONFIG_SERIAL_BFIN_UART0
871 &bfin_uart0_device, 869 &bfin_uart0_device,
872#endif 870#endif
@@ -878,18 +876,18 @@ static struct platform_device *cm_bf538_devices[] __initdata = {
878#endif 876#endif
879#endif 877#endif
880 878
881#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 879#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
882 &bf538_spi_master0, 880 &bf538_spi_master0,
883 &bf538_spi_master1, 881 &bf538_spi_master1,
884 &bf538_spi_master2, 882 &bf538_spi_master2,
885#endif 883#endif
886 884
887#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 885#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
888 &i2c_bfin_twi0_device, 886 &i2c_bfin_twi0_device,
889 &i2c_bfin_twi1_device, 887 &i2c_bfin_twi1_device,
890#endif 888#endif
891 889
892#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 890#if IS_ENABLED(CONFIG_BFIN_SIR)
893#ifdef CONFIG_BFIN_SIR0 891#ifdef CONFIG_BFIN_SIR0
894 &bfin_sir0_device, 892 &bfin_sir0_device,
895#endif 893#endif
@@ -901,7 +899,7 @@ static struct platform_device *cm_bf538_devices[] __initdata = {
901#endif 899#endif
902#endif 900#endif
903 901
904#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 902#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
905#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 903#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
906 &bfin_sport0_uart_device, 904 &bfin_sport0_uart_device,
907#endif 905#endif
@@ -916,23 +914,23 @@ static struct platform_device *cm_bf538_devices[] __initdata = {
916#endif 914#endif
917#endif 915#endif
918 916
919#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 917#if IS_ENABLED(CONFIG_CAN_BFIN)
920 &bfin_can_device, 918 &bfin_can_device,
921#endif 919#endif
922 920
923#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 921#if IS_ENABLED(CONFIG_SMC91X)
924 &smc91x_device, 922 &smc91x_device,
925#endif 923#endif
926 924
927#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) 925#if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
928 &bfin_lq035q1_device, 926 &bfin_lq035q1_device,
929#endif 927#endif
930 928
931#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 929#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
932 &bfin_device_gpiokeys, 930 &bfin_device_gpiokeys,
933#endif 931#endif
934 932
935#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 933#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
936 &ezkit_flash_device, 934 &ezkit_flash_device,
937#endif 935#endif
938}; 936};
@@ -942,7 +940,7 @@ static int __init ezkit_init(void)
942 printk(KERN_INFO "%s(): registering device resources\n", __func__); 940 printk(KERN_INFO "%s(): registering device resources\n", __func__);
943 platform_add_devices(cm_bf538_devices, ARRAY_SIZE(cm_bf538_devices)); 941 platform_add_devices(cm_bf538_devices, ARRAY_SIZE(cm_bf538_devices));
944 942
945#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 943#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
946 spi_register_board_info(bf538_spi_board_info, 944 spi_register_board_info(bf538_spi_board_info,
947 ARRAY_SIZE(bf538_spi_board_info)); 945 ARRAY_SIZE(bf538_spi_board_info));
948#endif 946#endif
diff --git a/arch/blackfin/mach-bf548/boards/cm_bf548.c b/arch/blackfin/mach-bf548/boards/cm_bf548.c
index e92543362f35..6d5ffdead067 100644
--- a/arch/blackfin/mach-bf548/boards/cm_bf548.c
+++ b/arch/blackfin/mach-bf548/boards/cm_bf548.c
@@ -37,7 +37,7 @@ const char bfin_board_name[] = "Bluetechnix CM-BF548";
37 * Driver needs to know address, irq and flag pin. 37 * Driver needs to know address, irq and flag pin.
38 */ 38 */
39 39
40#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE) 40#if IS_ENABLED(CONFIG_FB_BF54X_LQ043)
41 41
42#include <mach/bf54x-lq043.h> 42#include <mach/bf54x-lq043.h>
43 43
@@ -69,7 +69,7 @@ static struct platform_device bf54x_lq043_device = {
69}; 69};
70#endif 70#endif
71 71
72#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE) 72#if IS_ENABLED(CONFIG_KEYBOARD_BFIN)
73static unsigned int bf548_keymap[] = { 73static unsigned int bf548_keymap[] = {
74 KEYVAL(0, 0, KEY_ENTER), 74 KEYVAL(0, 0, KEY_ENTER),
75 KEYVAL(0, 1, KEY_HELP), 75 KEYVAL(0, 1, KEY_HELP),
@@ -119,14 +119,14 @@ static struct platform_device bf54x_kpad_device = {
119}; 119};
120#endif 120#endif
121 121
122#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 122#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
123static struct platform_device rtc_device = { 123static struct platform_device rtc_device = {
124 .name = "rtc-bfin", 124 .name = "rtc-bfin",
125 .id = -1, 125 .id = -1,
126}; 126};
127#endif 127#endif
128 128
129#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 129#if IS_ENABLED(CONFIG_SERIAL_BFIN)
130#ifdef CONFIG_SERIAL_BFIN_UART0 130#ifdef CONFIG_SERIAL_BFIN_UART0
131static struct resource bfin_uart0_resources[] = { 131static struct resource bfin_uart0_resources[] = {
132 { 132 {
@@ -353,7 +353,7 @@ static struct platform_device bfin_uart3_device = {
353#endif 353#endif
354#endif 354#endif
355 355
356#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 356#if IS_ENABLED(CONFIG_BFIN_SIR)
357#ifdef CONFIG_BFIN_SIR0 357#ifdef CONFIG_BFIN_SIR0
358static struct resource bfin_sir0_resources[] = { 358static struct resource bfin_sir0_resources[] = {
359 { 359 {
@@ -456,7 +456,7 @@ static struct platform_device bfin_sir3_device = {
456#endif 456#endif
457#endif 457#endif
458 458
459#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 459#if IS_ENABLED(CONFIG_SMSC911X)
460#include <linux/smsc911x.h> 460#include <linux/smsc911x.h>
461 461
462static struct resource smsc911x_resources[] = { 462static struct resource smsc911x_resources[] = {
@@ -491,7 +491,7 @@ static struct platform_device smsc911x_device = {
491}; 491};
492#endif 492#endif
493 493
494#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 494#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
495static struct resource musb_resources[] = { 495static struct resource musb_resources[] = {
496 [0] = { 496 [0] = {
497 .start = 0xFFC03C00, 497 .start = 0xFFC03C00,
@@ -553,7 +553,7 @@ static struct platform_device musb_device = {
553}; 553};
554#endif 554#endif
555 555
556#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 556#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
557#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 557#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
558static struct resource bfin_sport0_uart_resources[] = { 558static struct resource bfin_sport0_uart_resources[] = {
559 { 559 {
@@ -692,7 +692,7 @@ static struct platform_device bfin_sport3_uart_device = {
692#endif 692#endif
693#endif 693#endif
694 694
695#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE) 695#if IS_ENABLED(CONFIG_PATA_BF54X)
696static struct resource bfin_atapi_resources[] = { 696static struct resource bfin_atapi_resources[] = {
697 { 697 {
698 .start = 0xFFC03800, 698 .start = 0xFFC03800,
@@ -714,7 +714,7 @@ static struct platform_device bfin_atapi_device = {
714}; 714};
715#endif 715#endif
716 716
717#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 717#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
718static struct mtd_partition partition_info[] = { 718static struct mtd_partition partition_info[] = {
719 { 719 {
720 .name = "linux kernel(nand)", 720 .name = "linux kernel(nand)",
@@ -760,7 +760,7 @@ static struct platform_device bf5xx_nand_device = {
760}; 760};
761#endif 761#endif
762 762
763#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 763#if IS_ENABLED(CONFIG_SDH_BFIN)
764static struct bfin_sd_host bfin_sdh_data = { 764static struct bfin_sd_host bfin_sdh_data = {
765 .dma_chan = CH_SDH, 765 .dma_chan = CH_SDH,
766 .irq_int0 = IRQ_SDH_MASK0, 766 .irq_int0 = IRQ_SDH_MASK0,
@@ -776,7 +776,7 @@ static struct platform_device bf54x_sdh_device = {
776}; 776};
777#endif 777#endif
778 778
779#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 779#if IS_ENABLED(CONFIG_CAN_BFIN)
780static unsigned short bfin_can_peripherals[] = { 780static unsigned short bfin_can_peripherals[] = {
781 P_CAN0_RX, P_CAN0_TX, 0 781 P_CAN0_RX, P_CAN0_TX, 0
782}; 782};
@@ -814,7 +814,7 @@ static struct platform_device bfin_can_device = {
814}; 814};
815#endif 815#endif
816 816
817#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 817#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
818static struct mtd_partition para_partitions[] = { 818static struct mtd_partition para_partitions[] = {
819 { 819 {
820 .name = "bootloader(nor)", 820 .name = "bootloader(nor)",
@@ -854,10 +854,9 @@ static struct platform_device para_flash_device = {
854}; 854};
855#endif 855#endif
856 856
857#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 857#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
858/* all SPI peripherals info goes here */ 858/* all SPI peripherals info goes here */
859#if defined(CONFIG_MTD_M25P80) \ 859#if IS_ENABLED(CONFIG_MTD_M25P80)
860 || defined(CONFIG_MTD_M25P80_MODULE)
861/* SPI flash chip (m25p16) */ 860/* SPI flash chip (m25p16) */
862static struct mtd_partition bfin_spi_flash_partitions[] = { 861static struct mtd_partition bfin_spi_flash_partitions[] = {
863 { 862 {
@@ -884,7 +883,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
884}; 883};
885#endif 884#endif
886 885
887#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 886#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
888static const struct ad7877_platform_data bfin_ad7877_ts_info = { 887static const struct ad7877_platform_data bfin_ad7877_ts_info = {
889 .model = 7877, 888 .model = 7877,
890 .vref_delay_usecs = 50, /* internal, no capacitor */ 889 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -901,8 +900,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
901#endif 900#endif
902 901
903static struct spi_board_info bf54x_spi_board_info[] __initdata = { 902static struct spi_board_info bf54x_spi_board_info[] __initdata = {
904#if defined(CONFIG_MTD_M25P80) \ 903#if IS_ENABLED(CONFIG_MTD_M25P80)
905 || defined(CONFIG_MTD_M25P80_MODULE)
906 { 904 {
907 /* the modalias must be the same as spi device driver name */ 905 /* the modalias must be the same as spi device driver name */
908 .modalias = "m25p80", /* Name of spi_driver for this device */ 906 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -914,7 +912,7 @@ static struct spi_board_info bf54x_spi_board_info[] __initdata = {
914 .mode = SPI_MODE_3, 912 .mode = SPI_MODE_3,
915 }, 913 },
916#endif 914#endif
917#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 915#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
918{ 916{
919 .modalias = "ad7877", 917 .modalias = "ad7877",
920 .platform_data = &bfin_ad7877_ts_info, 918 .platform_data = &bfin_ad7877_ts_info,
@@ -924,7 +922,7 @@ static struct spi_board_info bf54x_spi_board_info[] __initdata = {
924 .chip_select = 2, 922 .chip_select = 2,
925}, 923},
926#endif 924#endif
927#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 925#if IS_ENABLED(CONFIG_SPI_SPIDEV)
928 { 926 {
929 .modalias = "spidev", 927 .modalias = "spidev",
930 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 928 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -1006,7 +1004,7 @@ static struct platform_device bf54x_spi_master1 = {
1006}; 1004};
1007#endif /* spi master and devices */ 1005#endif /* spi master and devices */
1008 1006
1009#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1007#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1010static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 1008static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
1011 1009
1012static struct resource bfin_twi0_resource[] = { 1010static struct resource bfin_twi0_resource[] = {
@@ -1060,7 +1058,7 @@ static struct platform_device i2c_bfin_twi1_device = {
1060#endif 1058#endif
1061#endif 1059#endif
1062 1060
1063#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1061#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1064#include <linux/gpio_keys.h> 1062#include <linux/gpio_keys.h>
1065 1063
1066static struct gpio_keys_button bfin_gpio_keys_table[] = { 1064static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -1112,11 +1110,11 @@ static struct platform_device *cm_bf548_devices[] __initdata = {
1112 1110
1113 &bfin_dpmc, 1111 &bfin_dpmc,
1114 1112
1115#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 1113#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
1116 &rtc_device, 1114 &rtc_device,
1117#endif 1115#endif
1118 1116
1119#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 1117#if IS_ENABLED(CONFIG_SERIAL_BFIN)
1120#ifdef CONFIG_SERIAL_BFIN_UART0 1118#ifdef CONFIG_SERIAL_BFIN_UART0
1121 &bfin_uart0_device, 1119 &bfin_uart0_device,
1122#endif 1120#endif
@@ -1131,7 +1129,7 @@ static struct platform_device *cm_bf548_devices[] __initdata = {
1131#endif 1129#endif
1132#endif 1130#endif
1133 1131
1134#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 1132#if IS_ENABLED(CONFIG_BFIN_SIR)
1135#ifdef CONFIG_BFIN_SIR0 1133#ifdef CONFIG_BFIN_SIR0
1136 &bfin_sir0_device, 1134 &bfin_sir0_device,
1137#endif 1135#endif
@@ -1146,19 +1144,19 @@ static struct platform_device *cm_bf548_devices[] __initdata = {
1146#endif 1144#endif
1147#endif 1145#endif
1148 1146
1149#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE) 1147#if IS_ENABLED(CONFIG_FB_BF54X_LQ043)
1150 &bf54x_lq043_device, 1148 &bf54x_lq043_device,
1151#endif 1149#endif
1152 1150
1153#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 1151#if IS_ENABLED(CONFIG_SMSC911X)
1154 &smsc911x_device, 1152 &smsc911x_device,
1155#endif 1153#endif
1156 1154
1157#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 1155#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
1158 &musb_device, 1156 &musb_device,
1159#endif 1157#endif
1160 1158
1161#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 1159#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
1162#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 1160#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1163 &bfin_sport0_uart_device, 1161 &bfin_sport0_uart_device,
1164#endif 1162#endif
@@ -1173,43 +1171,43 @@ static struct platform_device *cm_bf548_devices[] __initdata = {
1173#endif 1171#endif
1174#endif 1172#endif
1175 1173
1176#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE) 1174#if IS_ENABLED(CONFIG_PATA_BF54X)
1177 &bfin_atapi_device, 1175 &bfin_atapi_device,
1178#endif 1176#endif
1179 1177
1180#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 1178#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
1181 &bf5xx_nand_device, 1179 &bf5xx_nand_device,
1182#endif 1180#endif
1183 1181
1184#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 1182#if IS_ENABLED(CONFIG_SDH_BFIN)
1185 &bf54x_sdh_device, 1183 &bf54x_sdh_device,
1186#endif 1184#endif
1187 1185
1188#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 1186#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1189 &bf54x_spi_master0, 1187 &bf54x_spi_master0,
1190 &bf54x_spi_master1, 1188 &bf54x_spi_master1,
1191#endif 1189#endif
1192 1190
1193#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE) 1191#if IS_ENABLED(CONFIG_KEYBOARD_BFIN)
1194 &bf54x_kpad_device, 1192 &bf54x_kpad_device,
1195#endif 1193#endif
1196 1194
1197#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1195#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1198 &i2c_bfin_twi0_device, 1196 &i2c_bfin_twi0_device,
1199#if !defined(CONFIG_BF542) 1197#if !defined(CONFIG_BF542)
1200 &i2c_bfin_twi1_device, 1198 &i2c_bfin_twi1_device,
1201#endif 1199#endif
1202#endif 1200#endif
1203 1201
1204#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1202#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1205 &bfin_device_gpiokeys, 1203 &bfin_device_gpiokeys,
1206#endif 1204#endif
1207 1205
1208#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1206#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
1209 &para_flash_device, 1207 &para_flash_device,
1210#endif 1208#endif
1211 1209
1212#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 1210#if IS_ENABLED(CONFIG_CAN_BFIN)
1213 &bfin_can_device, 1211 &bfin_can_device,
1214#endif 1212#endif
1215 1213
@@ -1220,7 +1218,7 @@ static int __init cm_bf548_init(void)
1220 printk(KERN_INFO "%s(): registering device resources\n", __func__); 1218 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1221 platform_add_devices(cm_bf548_devices, ARRAY_SIZE(cm_bf548_devices)); 1219 platform_add_devices(cm_bf548_devices, ARRAY_SIZE(cm_bf548_devices));
1222 1220
1223#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 1221#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1224 spi_register_board_info(bf54x_spi_board_info, 1222 spi_register_board_info(bf54x_spi_board_info,
1225 ARRAY_SIZE(bf54x_spi_board_info)); 1223 ARRAY_SIZE(bf54x_spi_board_info));
1226#endif 1224#endif
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index d495000b81a0..90138e6112c1 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -41,7 +41,7 @@ const char bfin_board_name[] = "ADI BF548-EZKIT";
41 * Driver needs to know address, irq and flag pin. 41 * Driver needs to know address, irq and flag pin.
42 */ 42 */
43 43
44#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 44#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
45#include <linux/usb/isp1760.h> 45#include <linux/usb/isp1760.h>
46static struct resource bfin_isp1760_resources[] = { 46static struct resource bfin_isp1760_resources[] = {
47 [0] = { 47 [0] = {
@@ -76,7 +76,7 @@ static struct platform_device bfin_isp1760_device = {
76}; 76};
77#endif 77#endif
78 78
79#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE) 79#if IS_ENABLED(CONFIG_FB_BF54X_LQ043)
80 80
81#include <mach/bf54x-lq043.h> 81#include <mach/bf54x-lq043.h>
82 82
@@ -108,7 +108,7 @@ static struct platform_device bf54x_lq043_device = {
108}; 108};
109#endif 109#endif
110 110
111#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE) 111#if IS_ENABLED(CONFIG_KEYBOARD_BFIN)
112static const unsigned int bf548_keymap[] = { 112static const unsigned int bf548_keymap[] = {
113 KEYVAL(0, 0, KEY_ENTER), 113 KEYVAL(0, 0, KEY_ENTER),
114 KEYVAL(0, 1, KEY_HELP), 114 KEYVAL(0, 1, KEY_HELP),
@@ -158,7 +158,7 @@ static struct platform_device bf54x_kpad_device = {
158}; 158};
159#endif 159#endif
160 160
161#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 161#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
162#include <asm/bfin_rotary.h> 162#include <asm/bfin_rotary.h>
163 163
164static struct bfin_rotary_platform_data bfin_rotary_data = { 164static struct bfin_rotary_platform_data bfin_rotary_data = {
@@ -190,7 +190,7 @@ static struct platform_device bfin_rotary_device = {
190}; 190};
191#endif 191#endif
192 192
193#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE) 193#if IS_ENABLED(CONFIG_INPUT_ADXL34X)
194#include <linux/input/adxl34x.h> 194#include <linux/input/adxl34x.h>
195static const struct adxl34x_platform_data adxl34x_info = { 195static const struct adxl34x_platform_data adxl34x_info = {
196 .x_axis_offset = 0, 196 .x_axis_offset = 0,
@@ -229,14 +229,14 @@ static const struct adxl34x_platform_data adxl34x_info = {
229}; 229};
230#endif 230#endif
231 231
232#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 232#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
233static struct platform_device rtc_device = { 233static struct platform_device rtc_device = {
234 .name = "rtc-bfin", 234 .name = "rtc-bfin",
235 .id = -1, 235 .id = -1,
236}; 236};
237#endif 237#endif
238 238
239#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 239#if IS_ENABLED(CONFIG_SERIAL_BFIN)
240#ifdef CONFIG_SERIAL_BFIN_UART0 240#ifdef CONFIG_SERIAL_BFIN_UART0
241static struct resource bfin_uart0_resources[] = { 241static struct resource bfin_uart0_resources[] = {
242 { 242 {
@@ -491,7 +491,7 @@ static struct platform_device bfin_uart3_device = {
491#endif 491#endif
492#endif 492#endif
493 493
494#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 494#if IS_ENABLED(CONFIG_BFIN_SIR)
495#ifdef CONFIG_BFIN_SIR0 495#ifdef CONFIG_BFIN_SIR0
496static struct resource bfin_sir0_resources[] = { 496static struct resource bfin_sir0_resources[] = {
497 { 497 {
@@ -594,7 +594,7 @@ static struct platform_device bfin_sir3_device = {
594#endif 594#endif
595#endif 595#endif
596 596
597#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 597#if IS_ENABLED(CONFIG_SMSC911X)
598#include <linux/smsc911x.h> 598#include <linux/smsc911x.h>
599 599
600static struct resource smsc911x_resources[] = { 600static struct resource smsc911x_resources[] = {
@@ -629,7 +629,7 @@ static struct platform_device smsc911x_device = {
629}; 629};
630#endif 630#endif
631 631
632#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 632#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
633static struct resource musb_resources[] = { 633static struct resource musb_resources[] = {
634 [0] = { 634 [0] = {
635 .start = 0xFFC03C00, 635 .start = 0xFFC03C00,
@@ -691,7 +691,7 @@ static struct platform_device musb_device = {
691}; 691};
692#endif 692#endif
693 693
694#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 694#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
695#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 695#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
696static struct resource bfin_sport0_uart_resources[] = { 696static struct resource bfin_sport0_uart_resources[] = {
697 { 697 {
@@ -830,7 +830,7 @@ static struct platform_device bfin_sport3_uart_device = {
830#endif 830#endif
831#endif 831#endif
832 832
833#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 833#if IS_ENABLED(CONFIG_CAN_BFIN)
834 834
835static unsigned short bfin_can0_peripherals[] = { 835static unsigned short bfin_can0_peripherals[] = {
836 P_CAN0_RX, P_CAN0_TX, 0 836 P_CAN0_RX, P_CAN0_TX, 0
@@ -908,7 +908,7 @@ static struct platform_device bfin_can1_device = {
908 908
909#endif 909#endif
910 910
911#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE) 911#if IS_ENABLED(CONFIG_PATA_BF54X)
912static struct resource bfin_atapi_resources[] = { 912static struct resource bfin_atapi_resources[] = {
913 { 913 {
914 .start = 0xFFC03800, 914 .start = 0xFFC03800,
@@ -930,7 +930,7 @@ static struct platform_device bfin_atapi_device = {
930}; 930};
931#endif 931#endif
932 932
933#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 933#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
934static struct mtd_partition partition_info[] = { 934static struct mtd_partition partition_info[] = {
935 { 935 {
936 .name = "bootloader(nand)", 936 .name = "bootloader(nand)",
@@ -980,7 +980,7 @@ static struct platform_device bf5xx_nand_device = {
980}; 980};
981#endif 981#endif
982 982
983#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 983#if IS_ENABLED(CONFIG_SDH_BFIN)
984 984
985static struct bfin_sd_host bfin_sdh_data = { 985static struct bfin_sd_host bfin_sdh_data = {
986 .dma_chan = CH_SDH, 986 .dma_chan = CH_SDH,
@@ -997,7 +997,7 @@ static struct platform_device bf54x_sdh_device = {
997}; 997};
998#endif 998#endif
999 999
1000#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1000#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
1001static struct mtd_partition ezkit_partitions[] = { 1001static struct mtd_partition ezkit_partitions[] = {
1002 { 1002 {
1003 .name = "bootloader(nor)", 1003 .name = "bootloader(nor)",
@@ -1045,8 +1045,7 @@ static struct platform_device ezkit_flash_device = {
1045}; 1045};
1046#endif 1046#endif
1047 1047
1048#if defined(CONFIG_MTD_M25P80) \ 1048#if IS_ENABLED(CONFIG_MTD_M25P80)
1049 || defined(CONFIG_MTD_M25P80_MODULE)
1050/* SPI flash chip (m25p16) */ 1049/* SPI flash chip (m25p16) */
1051static struct mtd_partition bfin_spi_flash_partitions[] = { 1050static struct mtd_partition bfin_spi_flash_partitions[] = {
1052 { 1051 {
@@ -1073,7 +1072,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
1073}; 1072};
1074#endif 1073#endif
1075 1074
1076#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1075#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
1077static const struct ad7877_platform_data bfin_ad7877_ts_info = { 1076static const struct ad7877_platform_data bfin_ad7877_ts_info = {
1078 .model = 7877, 1077 .model = 7877,
1079 .vref_delay_usecs = 50, /* internal, no capacitor */ 1078 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -1495,8 +1494,7 @@ static struct platform_device bfin_gpj_device = {
1495#endif 1494#endif
1496 1495
1497static struct spi_board_info bfin_spi_board_info[] __initdata = { 1496static struct spi_board_info bfin_spi_board_info[] __initdata = {
1498#if defined(CONFIG_MTD_M25P80) \ 1497#if IS_ENABLED(CONFIG_MTD_M25P80)
1499 || defined(CONFIG_MTD_M25P80_MODULE)
1500 { 1498 {
1501 /* the modalias must be the same as spi device driver name */ 1499 /* the modalias must be the same as spi device driver name */
1502 .modalias = "m25p80", /* Name of spi_driver for this device */ 1500 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -1508,8 +1506,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1508 .mode = SPI_MODE_3, 1506 .mode = SPI_MODE_3,
1509 }, 1507 },
1510#endif 1508#endif
1511#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 1509#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
1512 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
1513 { 1510 {
1514 .modalias = "ad183x", 1511 .modalias = "ad183x",
1515 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1512 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -1517,7 +1514,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1517 .chip_select = MAX_CTRL_CS + GPIO_PG6, /* SPI_SSEL2 */ 1514 .chip_select = MAX_CTRL_CS + GPIO_PG6, /* SPI_SSEL2 */
1518 }, 1515 },
1519#endif 1516#endif
1520#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1517#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
1521 { 1518 {
1522 .modalias = "ad7877", 1519 .modalias = "ad7877",
1523 .platform_data = &bfin_ad7877_ts_info, 1520 .platform_data = &bfin_ad7877_ts_info,
@@ -1527,7 +1524,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1527 .chip_select = MAX_CTRL_CS + GPIO_PE5, /* SPI_SSEL2 */ 1524 .chip_select = MAX_CTRL_CS + GPIO_PE5, /* SPI_SSEL2 */
1528 }, 1525 },
1529#endif 1526#endif
1530#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 1527#if IS_ENABLED(CONFIG_SPI_SPIDEV)
1531 { 1528 {
1532 .modalias = "spidev", 1529 .modalias = "spidev",
1533 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1530 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -1535,7 +1532,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1535 .chip_select = MAX_CTRL_CS + GPIO_PE4, /* SPI_SSEL1 */ 1532 .chip_select = MAX_CTRL_CS + GPIO_PE4, /* SPI_SSEL1 */
1536 }, 1533 },
1537#endif 1534#endif
1538#if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE) 1535#if IS_ENABLED(CONFIG_INPUT_ADXL34X_SPI)
1539 { 1536 {
1540 .modalias = "adxl34x", 1537 .modalias = "adxl34x",
1541 .platform_data = &adxl34x_info, 1538 .platform_data = &adxl34x_info,
@@ -1547,7 +1544,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1547 }, 1544 },
1548#endif 1545#endif
1549}; 1546};
1550#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 1547#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1551/* SPI (0) */ 1548/* SPI (0) */
1552static struct resource bfin_spi0_resource[] = { 1549static struct resource bfin_spi0_resource[] = {
1553 [0] = { 1550 [0] = {
@@ -1620,8 +1617,7 @@ static struct platform_device bf54x_spi_master1 = {
1620}; 1617};
1621#endif /* spi master and devices */ 1618#endif /* spi master and devices */
1622 1619
1623#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 1620#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
1624 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
1625#include <linux/videodev2.h> 1621#include <linux/videodev2.h>
1626#include <media/blackfin/bfin_capture.h> 1622#include <media/blackfin/bfin_capture.h>
1627#include <media/blackfin/ppi.h> 1623#include <media/blackfin/ppi.h>
@@ -1641,8 +1637,7 @@ static const struct ppi_info ppi_info = {
1641 .pin_req = ppi_req, 1637 .pin_req = ppi_req,
1642}; 1638};
1643 1639
1644#if defined(CONFIG_VIDEO_VS6624) \ 1640#if IS_ENABLED(CONFIG_VIDEO_VS6624)
1645 || defined(CONFIG_VIDEO_VS6624_MODULE)
1646static struct v4l2_input vs6624_inputs[] = { 1641static struct v4l2_input vs6624_inputs[] = {
1647 { 1642 {
1648 .index = 0, 1643 .index = 0,
@@ -1687,7 +1682,7 @@ static struct platform_device bfin_capture_device = {
1687}; 1682};
1688#endif 1683#endif
1689 1684
1690#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1685#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1691static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 1686static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
1692 1687
1693static struct resource bfin_twi0_resource[] = { 1688static struct resource bfin_twi0_resource[] = {
@@ -1742,7 +1737,7 @@ static struct platform_device i2c_bfin_twi1_device = {
1742#endif 1737#endif
1743 1738
1744static struct i2c_board_info __initdata bfin_i2c_board_info0[] = { 1739static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
1745#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 1740#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
1746 { 1741 {
1747 I2C_BOARD_INFO("ssm2602", 0x1b), 1742 I2C_BOARD_INFO("ssm2602", 0x1b),
1748 }, 1743 },
@@ -1751,25 +1746,25 @@ static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
1751 1746
1752#if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */ 1747#if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
1753static struct i2c_board_info __initdata bfin_i2c_board_info1[] = { 1748static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
1754#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 1749#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
1755 { 1750 {
1756 I2C_BOARD_INFO("pcf8574_lcd", 0x22), 1751 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
1757 }, 1752 },
1758#endif 1753#endif
1759#if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE) 1754#if IS_ENABLED(CONFIG_INPUT_PCF8574)
1760 { 1755 {
1761 I2C_BOARD_INFO("pcf8574_keypad", 0x27), 1756 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
1762 .irq = 212, 1757 .irq = 212,
1763 }, 1758 },
1764#endif 1759#endif
1765#if defined(CONFIG_INPUT_ADXL34X_I2C) || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE) 1760#if IS_ENABLED(CONFIG_INPUT_ADXL34X_I2C)
1766 { 1761 {
1767 I2C_BOARD_INFO("adxl34x", 0x53), 1762 I2C_BOARD_INFO("adxl34x", 0x53),
1768 .irq = IRQ_PC5, 1763 .irq = IRQ_PC5,
1769 .platform_data = (void *)&adxl34x_info, 1764 .platform_data = (void *)&adxl34x_info,
1770 }, 1765 },
1771#endif 1766#endif
1772#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE) 1767#if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
1773 { 1768 {
1774 I2C_BOARD_INFO("ad5252", 0x2f), 1769 I2C_BOARD_INFO("ad5252", 0x2f),
1775 }, 1770 },
@@ -1777,7 +1772,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
1777}; 1772};
1778#endif 1773#endif
1779 1774
1780#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1775#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1781#include <linux/gpio_keys.h> 1776#include <linux/gpio_keys.h>
1782 1777
1783static struct gpio_keys_button bfin_gpio_keys_table[] = { 1778static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -1828,8 +1823,8 @@ static struct platform_device bfin_dpmc = {
1828 }, 1823 },
1829}; 1824};
1830 1825
1831#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) || \ 1826#if IS_ENABLED(CONFIG_SND_BF5XX_I2S) || \
1832 defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 1827 IS_ENABLED(CONFIG_SND_BF5XX_AC97)
1833 1828
1834#define SPORT_REQ(x) \ 1829#define SPORT_REQ(x) \
1835 [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \ 1830 [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \
@@ -1889,35 +1884,35 @@ static struct resource bfin_snd_resources[][4] = {
1889}; 1884};
1890#endif 1885#endif
1891 1886
1892#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 1887#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
1893static struct platform_device bfin_i2s_pcm = { 1888static struct platform_device bfin_i2s_pcm = {
1894 .name = "bfin-i2s-pcm-audio", 1889 .name = "bfin-i2s-pcm-audio",
1895 .id = -1, 1890 .id = -1,
1896}; 1891};
1897#endif 1892#endif
1898 1893
1899#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 1894#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
1900static struct platform_device bfin_ac97_pcm = { 1895static struct platform_device bfin_ac97_pcm = {
1901 .name = "bfin-ac97-pcm-audio", 1896 .name = "bfin-ac97-pcm-audio",
1902 .id = -1, 1897 .id = -1,
1903}; 1898};
1904#endif 1899#endif
1905 1900
1906#if defined(CONFIG_SND_BF5XX_SOC_AD73311) || defined(CONFIG_SND_BF5XX_SOC_AD73311_MODULE) 1901#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD73311)
1907static struct platform_device bfin_ad73311_codec_device = { 1902static struct platform_device bfin_ad73311_codec_device = {
1908 .name = "ad73311", 1903 .name = "ad73311",
1909 .id = -1, 1904 .id = -1,
1910}; 1905};
1911#endif 1906#endif
1912 1907
1913#if defined(CONFIG_SND_BF5XX_SOC_AD1980) || defined(CONFIG_SND_BF5XX_SOC_AD1980_MODULE) 1908#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1980)
1914static struct platform_device bfin_ad1980_codec_device = { 1909static struct platform_device bfin_ad1980_codec_device = {
1915 .name = "ad1980", 1910 .name = "ad1980",
1916 .id = -1, 1911 .id = -1,
1917}; 1912};
1918#endif 1913#endif
1919 1914
1920#if defined(CONFIG_SND_BF5XX_SOC_I2S) || defined(CONFIG_SND_BF5XX_SOC_I2S_MODULE) 1915#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_I2S)
1921static struct platform_device bfin_i2s = { 1916static struct platform_device bfin_i2s = {
1922 .name = "bfin-i2s", 1917 .name = "bfin-i2s",
1923 .id = CONFIG_SND_BF5XX_SPORT_NUM, 1918 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -1929,7 +1924,7 @@ static struct platform_device bfin_i2s = {
1929}; 1924};
1930#endif 1925#endif
1931 1926
1932#if defined(CONFIG_SND_BF5XX_SOC_AC97) || defined(CONFIG_SND_BF5XX_SOC_AC97_MODULE) 1927#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AC97)
1933static struct platform_device bfin_ac97 = { 1928static struct platform_device bfin_ac97 = {
1934 .name = "bfin-ac97", 1929 .name = "bfin-ac97",
1935 .id = CONFIG_SND_BF5XX_SPORT_NUM, 1930 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -1962,11 +1957,11 @@ static struct platform_device *ezkit_devices[] __initdata = {
1962 &bfin_gpj_device, 1957 &bfin_gpj_device,
1963#endif 1958#endif
1964 1959
1965#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 1960#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
1966 &rtc_device, 1961 &rtc_device,
1967#endif 1962#endif
1968 1963
1969#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 1964#if IS_ENABLED(CONFIG_SERIAL_BFIN)
1970#ifdef CONFIG_SERIAL_BFIN_UART0 1965#ifdef CONFIG_SERIAL_BFIN_UART0
1971 &bfin_uart0_device, 1966 &bfin_uart0_device,
1972#endif 1967#endif
@@ -1981,7 +1976,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
1981#endif 1976#endif
1982#endif 1977#endif
1983 1978
1984#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 1979#if IS_ENABLED(CONFIG_BFIN_SIR)
1985#ifdef CONFIG_BFIN_SIR0 1980#ifdef CONFIG_BFIN_SIR0
1986 &bfin_sir0_device, 1981 &bfin_sir0_device,
1987#endif 1982#endif
@@ -1996,23 +1991,23 @@ static struct platform_device *ezkit_devices[] __initdata = {
1996#endif 1991#endif
1997#endif 1992#endif
1998 1993
1999#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE) 1994#if IS_ENABLED(CONFIG_FB_BF54X_LQ043)
2000 &bf54x_lq043_device, 1995 &bf54x_lq043_device,
2001#endif 1996#endif
2002 1997
2003#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 1998#if IS_ENABLED(CONFIG_SMSC911X)
2004 &smsc911x_device, 1999 &smsc911x_device,
2005#endif 2000#endif
2006 2001
2007#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 2002#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
2008 &musb_device, 2003 &musb_device,
2009#endif 2004#endif
2010 2005
2011#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 2006#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
2012 &bfin_isp1760_device, 2007 &bfin_isp1760_device,
2013#endif 2008#endif
2014 2009
2015#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 2010#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
2016#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 2011#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
2017 &bfin_sport0_uart_device, 2012 &bfin_sport0_uart_device,
2018#endif 2013#endif
@@ -2027,72 +2022,71 @@ static struct platform_device *ezkit_devices[] __initdata = {
2027#endif 2022#endif
2028#endif 2023#endif
2029 2024
2030#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 2025#if IS_ENABLED(CONFIG_CAN_BFIN)
2031 &bfin_can0_device, 2026 &bfin_can0_device,
2032 &bfin_can1_device, 2027 &bfin_can1_device,
2033#endif 2028#endif
2034 2029
2035#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE) 2030#if IS_ENABLED(CONFIG_PATA_BF54X)
2036 &bfin_atapi_device, 2031 &bfin_atapi_device,
2037#endif 2032#endif
2038 2033
2039#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 2034#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
2040 &bf5xx_nand_device, 2035 &bf5xx_nand_device,
2041#endif 2036#endif
2042 2037
2043#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 2038#if IS_ENABLED(CONFIG_SDH_BFIN)
2044 &bf54x_sdh_device, 2039 &bf54x_sdh_device,
2045#endif 2040#endif
2046 2041
2047#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 2042#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
2048 &bf54x_spi_master0, 2043 &bf54x_spi_master0,
2049 &bf54x_spi_master1, 2044 &bf54x_spi_master1,
2050#endif 2045#endif
2051#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 2046#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
2052 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
2053 &bfin_capture_device, 2047 &bfin_capture_device,
2054#endif 2048#endif
2055 2049
2056#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE) 2050#if IS_ENABLED(CONFIG_KEYBOARD_BFIN)
2057 &bf54x_kpad_device, 2051 &bf54x_kpad_device,
2058#endif 2052#endif
2059 2053
2060#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 2054#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
2061 &bfin_rotary_device, 2055 &bfin_rotary_device,
2062#endif 2056#endif
2063 2057
2064#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 2058#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
2065 &i2c_bfin_twi0_device, 2059 &i2c_bfin_twi0_device,
2066#if !defined(CONFIG_BF542) 2060#if !defined(CONFIG_BF542)
2067 &i2c_bfin_twi1_device, 2061 &i2c_bfin_twi1_device,
2068#endif 2062#endif
2069#endif 2063#endif
2070 2064
2071#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 2065#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
2072 &bfin_device_gpiokeys, 2066 &bfin_device_gpiokeys,
2073#endif 2067#endif
2074 2068
2075#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 2069#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
2076 &ezkit_flash_device, 2070 &ezkit_flash_device,
2077#endif 2071#endif
2078 2072
2079#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 2073#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
2080 &bfin_i2s_pcm, 2074 &bfin_i2s_pcm,
2081#endif 2075#endif
2082 2076
2083#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 2077#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
2084 &bfin_ac97_pcm, 2078 &bfin_ac97_pcm,
2085#endif 2079#endif
2086 2080
2087#if defined(CONFIG_SND_BF5XX_SOC_AD1980) || defined(CONFIG_SND_BF5XX_SOC_AD1980_MODULE) 2081#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1980)
2088 &bfin_ad1980_codec_device, 2082 &bfin_ad1980_codec_device,
2089#endif 2083#endif
2090 2084
2091#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 2085#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
2092 &bfin_i2s, 2086 &bfin_i2s,
2093#endif 2087#endif
2094 2088
2095#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 2089#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
2096 &bfin_ac97, 2090 &bfin_ac97,
2097#endif 2091#endif
2098}; 2092};
diff --git a/arch/blackfin/mach-bf548/include/mach/defBF544.h b/arch/blackfin/mach-bf548/include/mach/defBF544.h
index 329b2c58228b..018ebfc27f5a 100644
--- a/arch/blackfin/mach-bf548/include/mach/defBF544.h
+++ b/arch/blackfin/mach-bf548/include/mach/defBF544.h
@@ -601,36 +601,6 @@
601#define GU_TRANS 0xff00 /* Transparent Color - G/U Component */ 601#define GU_TRANS 0xff00 /* Transparent Color - G/U Component */
602#define BV_TRANS 0xff0000 /* Transparent Color - B/V Component */ 602#define BV_TRANS 0xff0000 /* Transparent Color - B/V Component */
603 603
604/* Bit masks for HOST_CONTROL */
605
606#define HOST_EN 0x1 /* Host Enable */
607#define HOST_END 0x2 /* Host Endianess */
608#define DATA_SIZE 0x4 /* Data Size */
609#define HOST_RST 0x8 /* Host Reset */
610#define HRDY_OVR 0x20 /* Host Ready Override */
611#define INT_MODE 0x40 /* Interrupt Mode */
612#define BT_EN 0x80 /* Bus Timeout Enable */
613#define EHW 0x100 /* Enable Host Write */
614#define EHR 0x200 /* Enable Host Read */
615#define BDR 0x400 /* Burst DMA Requests */
616
617/* Bit masks for HOST_STATUS */
618
619#define DMA_READY 0x1 /* DMA Ready */
620#define FIFOFULL 0x2 /* FIFO Full */
621#define FIFOEMPTY 0x4 /* FIFO Empty */
622#define DMA_COMPLETE 0x8 /* DMA Complete */
623#define HSHK 0x10 /* Host Handshake */
624#define HSTIMEOUT 0x20 /* Host Timeout */
625#define HIRQ 0x40 /* Host Interrupt Request */
626#define ALLOW_CNFG 0x80 /* Allow New Configuration */
627#define DMA_DIR 0x100 /* DMA Direction */
628#define BTE 0x200 /* Bus Timeout Enabled */
629
630/* Bit masks for HOST_TIMEOUT */
631
632#define COUNT_TIMEOUT 0x7ff /* Host Timeout count */
633
634/* Bit masks for TIMER_ENABLE1 */ 604/* Bit masks for TIMER_ENABLE1 */
635 605
636#define TIMEN8 0x1 /* Timer 8 Enable */ 606#define TIMEN8 0x1 /* Timer 8 Enable */
diff --git a/arch/blackfin/mach-bf548/include/mach/defBF547.h b/arch/blackfin/mach-bf548/include/mach/defBF547.h
index e18de212ba1a..d55dcc0f5324 100644
--- a/arch/blackfin/mach-bf548/include/mach/defBF547.h
+++ b/arch/blackfin/mach-bf548/include/mach/defBF547.h
@@ -581,36 +581,6 @@
581#define GU_TRANS 0xff00 /* Transparent Color - G/U Component */ 581#define GU_TRANS 0xff00 /* Transparent Color - G/U Component */
582#define BV_TRANS 0xff0000 /* Transparent Color - B/V Component */ 582#define BV_TRANS 0xff0000 /* Transparent Color - B/V Component */
583 583
584/* Bit masks for HOST_CONTROL */
585
586#define HOST_EN 0x1 /* Host Enable */
587#define HOST_END 0x2 /* Host Endianess */
588#define DATA_SIZE 0x4 /* Data Size */
589#define HOST_RST 0x8 /* Host Reset */
590#define HRDY_OVR 0x20 /* Host Ready Override */
591#define INT_MODE 0x40 /* Interrupt Mode */
592#define BT_EN 0x80 /* Bus Timeout Enable */
593#define EHW 0x100 /* Enable Host Write */
594#define EHR 0x200 /* Enable Host Read */
595#define BDR 0x400 /* Burst DMA Requests */
596
597/* Bit masks for HOST_STATUS */
598
599#define DMA_READY 0x1 /* DMA Ready */
600#define FIFOFULL 0x2 /* FIFO Full */
601#define FIFOEMPTY 0x4 /* FIFO Empty */
602#define DMA_COMPLETE 0x8 /* DMA Complete */
603#define HSHK 0x10 /* Host Handshake */
604#define HSTIMEOUT 0x20 /* Host Timeout */
605#define HIRQ 0x40 /* Host Interrupt Request */
606#define ALLOW_CNFG 0x80 /* Allow New Configuration */
607#define DMA_DIR 0x100 /* DMA Direction */
608#define BTE 0x200 /* Bus Timeout Enabled */
609
610/* Bit masks for HOST_TIMEOUT */
611
612#define COUNT_TIMEOUT 0x7ff /* Host Timeout count */
613
614/* Bit masks for KPAD_CTL */ 584/* Bit masks for KPAD_CTL */
615 585
616#define KPAD_EN 0x1 /* Keypad Enable */ 586#define KPAD_EN 0x1 /* Keypad Enable */
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c
index 0b74218fdd3a..430b16d5ccb1 100644
--- a/arch/blackfin/mach-bf561/boards/acvilon.c
+++ b/arch/blackfin/mach-bf561/boards/acvilon.c
@@ -60,7 +60,7 @@
60 */ 60 */
61const char bfin_board_name[] = "Acvilon board"; 61const char bfin_board_name[] = "Acvilon board";
62 62
63#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 63#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
64#include <linux/usb/isp1760.h> 64#include <linux/usb/isp1760.h>
65static struct resource bfin_isp1760_resources[] = { 65static struct resource bfin_isp1760_resources[] = {
66 [0] = { 66 [0] = {
@@ -137,7 +137,7 @@ static struct i2c_board_info acvilon_i2c_devs[] __initdata = {
137 }, 137 },
138}; 138};
139 139
140#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE) 140#if IS_ENABLED(CONFIG_MTD_PLATRAM)
141static struct platdata_mtd_ram mtd_ram_data = { 141static struct platdata_mtd_ram mtd_ram_data = {
142 .mapname = "rootfs(RAM)", 142 .mapname = "rootfs(RAM)",
143 .bankwidth = 4, 143 .bankwidth = 4,
@@ -160,7 +160,7 @@ static struct platform_device mtd_ram_device = {
160}; 160};
161#endif 161#endif
162 162
163#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 163#if IS_ENABLED(CONFIG_SMSC911X)
164#include <linux/smsc911x.h> 164#include <linux/smsc911x.h>
165static struct resource smsc911x_resources[] = { 165static struct resource smsc911x_resources[] = {
166 { 166 {
@@ -194,7 +194,7 @@ static struct platform_device smsc911x_device = {
194}; 194};
195#endif 195#endif
196 196
197#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 197#if IS_ENABLED(CONFIG_SERIAL_BFIN)
198#ifdef CONFIG_SERIAL_BFIN_UART0 198#ifdef CONFIG_SERIAL_BFIN_UART0
199static struct resource bfin_uart0_resources[] = { 199static struct resource bfin_uart0_resources[] = {
200 { 200 {
@@ -246,7 +246,7 @@ static struct platform_device bfin_uart0_device = {
246#endif 246#endif
247#endif 247#endif
248 248
249#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 249#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
250 250
251static struct mtd_partition bfin_plat_nand_partitions[] = { 251static struct mtd_partition bfin_plat_nand_partitions[] = {
252 { 252 {
@@ -323,7 +323,7 @@ static void bfin_plat_nand_init(void)
323} 323}
324#endif 324#endif
325 325
326#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE) 326#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
327static struct mtd_partition bfin_spi_dataflash_partitions[] = { 327static struct mtd_partition bfin_spi_dataflash_partitions[] = {
328 { 328 {
329 .name = "bootloader", 329 .name = "bootloader",
@@ -369,7 +369,7 @@ static struct bfin5xx_spi_chip data_flash_chip_info = {
369}; 369};
370#endif 370#endif
371 371
372#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 372#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
373/* SPI (0) */ 373/* SPI (0) */
374static struct resource bfin_spi0_resource[] = { 374static struct resource bfin_spi0_resource[] = {
375 [0] = { 375 [0] = {
@@ -408,7 +408,7 @@ static struct platform_device bfin_spi0_device = {
408#endif 408#endif
409 409
410static struct spi_board_info bfin_spi_board_info[] __initdata = { 410static struct spi_board_info bfin_spi_board_info[] __initdata = {
411#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 411#if IS_ENABLED(CONFIG_SPI_SPIDEV)
412 { 412 {
413 .modalias = "spidev", 413 .modalias = "spidev",
414 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 414 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -416,7 +416,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
416 .chip_select = 3, 416 .chip_select = 3,
417 }, 417 },
418#endif 418#endif
419#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE) 419#if IS_ENABLED(CONFIG_MTD_DATAFLASH)
420 { /* DataFlash chip */ 420 { /* DataFlash chip */
421 .modalias = "mtd_dataflash", 421 .modalias = "mtd_dataflash",
422 .max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */ 422 .max_speed_hz = 33250000, /* max spi clock (SCK) speed in HZ */
@@ -472,11 +472,11 @@ static struct platform_device bfin_dpmc = {
472static struct platform_device *acvilon_devices[] __initdata = { 472static struct platform_device *acvilon_devices[] __initdata = {
473 &bfin_dpmc, 473 &bfin_dpmc,
474 474
475#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 475#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
476 &bfin_spi0_device, 476 &bfin_spi0_device,
477#endif 477#endif
478 478
479#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 479#if IS_ENABLED(CONFIG_SERIAL_BFIN)
480#ifdef CONFIG_SERIAL_BFIN_UART0 480#ifdef CONFIG_SERIAL_BFIN_UART0
481 &bfin_uart0_device, 481 &bfin_uart0_device,
482#endif 482#endif
@@ -484,17 +484,17 @@ static struct platform_device *acvilon_devices[] __initdata = {
484 484
485 &bfin_gpios_device, 485 &bfin_gpios_device,
486 486
487#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 487#if IS_ENABLED(CONFIG_SMSC911X)
488 &smsc911x_device, 488 &smsc911x_device,
489#endif 489#endif
490 490
491 &bfin_i2c_pca_device, 491 &bfin_i2c_pca_device,
492 492
493#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 493#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
494 &bfin_async_nand_device, 494 &bfin_async_nand_device,
495#endif 495#endif
496 496
497#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE) 497#if IS_ENABLED(CONFIG_MTD_PLATRAM)
498 &mtd_ram_device, 498 &mtd_ram_device,
499#endif 499#endif
500 500
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
index d81450f635df..9f777df4cacc 100644
--- a/arch/blackfin/mach-bf561/boards/cm_bf561.c
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -13,7 +13,7 @@
13#include <linux/mtd/partitions.h> 13#include <linux/mtd/partitions.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/spi/flash.h> 15#include <linux/spi/flash.h>
16#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 16#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
17#include <linux/usb/isp1362.h> 17#include <linux/usb/isp1362.h>
18#endif 18#endif
19#include <linux/ata_platform.h> 19#include <linux/ata_platform.h>
@@ -29,10 +29,10 @@
29 */ 29 */
30const char bfin_board_name[] = "Bluetechnix CM BF561"; 30const char bfin_board_name[] = "Bluetechnix CM BF561";
31 31
32#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 32#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
33/* all SPI peripherals info goes here */ 33/* all SPI peripherals info goes here */
34 34
35#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 35#if IS_ENABLED(CONFIG_MTD_M25P80)
36static struct mtd_partition bfin_spi_flash_partitions[] = { 36static struct mtd_partition bfin_spi_flash_partitions[] = {
37 { 37 {
38 .name = "bootloader(spi)", 38 .name = "bootloader(spi)",
@@ -64,7 +64,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
64#endif 64#endif
65 65
66static struct spi_board_info bfin_spi_board_info[] __initdata = { 66static struct spi_board_info bfin_spi_board_info[] __initdata = {
67#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) 67#if IS_ENABLED(CONFIG_MTD_M25P80)
68 { 68 {
69 /* the modalias must be the same as spi device driver name */ 69 /* the modalias must be the same as spi device driver name */
70 .modalias = "m25p80", /* Name of spi_driver for this device */ 70 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -77,7 +77,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
77 }, 77 },
78#endif 78#endif
79 79
80#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 80#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
81 { 81 {
82 .modalias = "ad183x", 82 .modalias = "ad183x",
83 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 83 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -85,7 +85,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
85 .chip_select = 4, 85 .chip_select = 4,
86 }, 86 },
87#endif 87#endif
88#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 88#if IS_ENABLED(CONFIG_MMC_SPI)
89 { 89 {
90 .modalias = "mmc_spi", 90 .modalias = "mmc_spi",
91 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 91 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
@@ -134,14 +134,14 @@ static struct platform_device bfin_spi0_device = {
134#endif /* spi master and devices */ 134#endif /* spi master and devices */
135 135
136 136
137#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 137#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
138static struct platform_device hitachi_fb_device = { 138static struct platform_device hitachi_fb_device = {
139 .name = "hitachi-tx09", 139 .name = "hitachi-tx09",
140}; 140};
141#endif 141#endif
142 142
143 143
144#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 144#if IS_ENABLED(CONFIG_SMC91X)
145#include <linux/smc91x.h> 145#include <linux/smc91x.h>
146 146
147static struct smc91x_platdata smc91x_info = { 147static struct smc91x_platdata smc91x_info = {
@@ -173,7 +173,7 @@ static struct platform_device smc91x_device = {
173}; 173};
174#endif 174#endif
175 175
176#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 176#if IS_ENABLED(CONFIG_SMSC911X)
177#include <linux/smsc911x.h> 177#include <linux/smsc911x.h>
178 178
179static struct resource smsc911x_resources[] = { 179static struct resource smsc911x_resources[] = {
@@ -208,7 +208,7 @@ static struct platform_device smsc911x_device = {
208}; 208};
209#endif 209#endif
210 210
211#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 211#if IS_ENABLED(CONFIG_USB_NET2272)
212static struct resource net2272_bfin_resources[] = { 212static struct resource net2272_bfin_resources[] = {
213 { 213 {
214 .start = 0x24000000, 214 .start = 0x24000000,
@@ -229,7 +229,7 @@ static struct platform_device net2272_bfin_device = {
229}; 229};
230#endif 230#endif
231 231
232#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 232#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
233static struct resource isp1362_hcd_resources[] = { 233static struct resource isp1362_hcd_resources[] = {
234 { 234 {
235 .start = 0x24008000, 235 .start = 0x24008000,
@@ -268,7 +268,7 @@ static struct platform_device isp1362_hcd_device = {
268}; 268};
269#endif 269#endif
270 270
271#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 271#if IS_ENABLED(CONFIG_SERIAL_BFIN)
272#ifdef CONFIG_SERIAL_BFIN_UART0 272#ifdef CONFIG_SERIAL_BFIN_UART0
273static struct resource bfin_uart0_resources[] = { 273static struct resource bfin_uart0_resources[] = {
274 { 274 {
@@ -319,7 +319,7 @@ static struct platform_device bfin_uart0_device = {
319#endif 319#endif
320#endif 320#endif
321 321
322#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 322#if IS_ENABLED(CONFIG_BFIN_SIR)
323#ifdef CONFIG_BFIN_SIR0 323#ifdef CONFIG_BFIN_SIR0
324static struct resource bfin_sir0_resources[] = { 324static struct resource bfin_sir0_resources[] = {
325 { 325 {
@@ -348,7 +348,7 @@ static struct platform_device bfin_sir0_device = {
348#endif 348#endif
349#endif 349#endif
350 350
351#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 351#if IS_ENABLED(CONFIG_PATA_PLATFORM)
352#define PATA_INT IRQ_PF46 352#define PATA_INT IRQ_PF46
353 353
354static struct pata_platform_info bfin_pata_platform_data = { 354static struct pata_platform_info bfin_pata_platform_data = {
@@ -385,7 +385,7 @@ static struct platform_device bfin_pata_device = {
385}; 385};
386#endif 386#endif
387 387
388#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 388#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
389static struct mtd_partition para_partitions[] = { 389static struct mtd_partition para_partitions[] = {
390 { 390 {
391 .name = "bootloader(nor)", 391 .name = "bootloader(nor)",
@@ -456,54 +456,54 @@ static struct platform_device *cm_bf561_devices[] __initdata = {
456 456
457 &bfin_dpmc, 457 &bfin_dpmc,
458 458
459#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 459#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
460 &hitachi_fb_device, 460 &hitachi_fb_device,
461#endif 461#endif
462 462
463#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 463#if IS_ENABLED(CONFIG_SERIAL_BFIN)
464#ifdef CONFIG_SERIAL_BFIN_UART0 464#ifdef CONFIG_SERIAL_BFIN_UART0
465 &bfin_uart0_device, 465 &bfin_uart0_device,
466#endif 466#endif
467#endif 467#endif
468 468
469#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 469#if IS_ENABLED(CONFIG_BFIN_SIR)
470#ifdef CONFIG_BFIN_SIR0 470#ifdef CONFIG_BFIN_SIR0
471 &bfin_sir0_device, 471 &bfin_sir0_device,
472#endif 472#endif
473#endif 473#endif
474 474
475#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 475#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
476 &isp1362_hcd_device, 476 &isp1362_hcd_device,
477#endif 477#endif
478 478
479#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 479#if IS_ENABLED(CONFIG_SMC91X)
480 &smc91x_device, 480 &smc91x_device,
481#endif 481#endif
482 482
483#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 483#if IS_ENABLED(CONFIG_SMSC911X)
484 &smsc911x_device, 484 &smsc911x_device,
485#endif 485#endif
486 486
487#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 487#if IS_ENABLED(CONFIG_USB_NET2272)
488 &net2272_bfin_device, 488 &net2272_bfin_device,
489#endif 489#endif
490 490
491#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 491#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
492 &bfin_spi0_device, 492 &bfin_spi0_device,
493#endif 493#endif
494 494
495#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 495#if IS_ENABLED(CONFIG_PATA_PLATFORM)
496 &bfin_pata_device, 496 &bfin_pata_device,
497#endif 497#endif
498 498
499#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 499#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
500 &para_flash_device, 500 &para_flash_device,
501#endif 501#endif
502}; 502};
503 503
504static int __init net2272_init(void) 504static int __init net2272_init(void)
505{ 505{
506#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 506#if IS_ENABLED(CONFIG_USB_NET2272)
507 int ret; 507 int ret;
508 508
509 ret = gpio_request(GPIO_PF46, "net2272"); 509 ret = gpio_request(GPIO_PF46, "net2272");
@@ -523,11 +523,11 @@ static int __init cm_bf561_init(void)
523{ 523{
524 printk(KERN_INFO "%s(): registering device resources\n", __func__); 524 printk(KERN_INFO "%s(): registering device resources\n", __func__);
525 platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices)); 525 platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices));
526#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 526#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
527 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 527 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
528#endif 528#endif
529 529
530#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) 530#if IS_ENABLED(CONFIG_PATA_PLATFORM)
531 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN); 531 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
532#endif 532#endif
533 533
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 92938e79b9e3..88dee43e7abe 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -25,7 +25,7 @@
25 */ 25 */
26const char bfin_board_name[] = "ADI BF561-EZKIT"; 26const char bfin_board_name[] = "ADI BF561-EZKIT";
27 27
28#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 28#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
29#include <linux/usb/isp1760.h> 29#include <linux/usb/isp1760.h>
30static struct resource bfin_isp1760_resources[] = { 30static struct resource bfin_isp1760_resources[] = {
31 [0] = { 31 [0] = {
@@ -60,7 +60,7 @@ static struct platform_device bfin_isp1760_device = {
60}; 60};
61#endif 61#endif
62 62
63#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 63#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
64#include <linux/usb/isp1362.h> 64#include <linux/usb/isp1362.h>
65 65
66static struct resource isp1362_hcd_resources[] = { 66static struct resource isp1362_hcd_resources[] = {
@@ -101,7 +101,7 @@ static struct platform_device isp1362_hcd_device = {
101}; 101};
102#endif 102#endif
103 103
104#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 104#if IS_ENABLED(CONFIG_USB_NET2272)
105static struct resource net2272_bfin_resources[] = { 105static struct resource net2272_bfin_resources[] = {
106 { 106 {
107 .start = 0x2C000000, 107 .start = 0x2C000000,
@@ -129,7 +129,7 @@ static struct platform_device net2272_bfin_device = {
129 * USB-LAN EzExtender board 129 * USB-LAN EzExtender board
130 * Driver needs to know address, irq and flag pin. 130 * Driver needs to know address, irq and flag pin.
131 */ 131 */
132#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 132#if IS_ENABLED(CONFIG_SMC91X)
133#include <linux/smc91x.h> 133#include <linux/smc91x.h>
134 134
135static struct smc91x_platdata smc91x_info = { 135static struct smc91x_platdata smc91x_info = {
@@ -163,7 +163,7 @@ static struct platform_device smc91x_device = {
163}; 163};
164#endif 164#endif
165 165
166#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 166#if IS_ENABLED(CONFIG_SERIAL_BFIN)
167#ifdef CONFIG_SERIAL_BFIN_UART0 167#ifdef CONFIG_SERIAL_BFIN_UART0
168static struct resource bfin_uart0_resources[] = { 168static struct resource bfin_uart0_resources[] = {
169 { 169 {
@@ -214,7 +214,7 @@ static struct platform_device bfin_uart0_device = {
214#endif 214#endif
215#endif 215#endif
216 216
217#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 217#if IS_ENABLED(CONFIG_BFIN_SIR)
218#ifdef CONFIG_BFIN_SIR0 218#ifdef CONFIG_BFIN_SIR0
219static struct resource bfin_sir0_resources[] = { 219static struct resource bfin_sir0_resources[] = {
220 { 220 {
@@ -243,7 +243,7 @@ static struct platform_device bfin_sir0_device = {
243#endif 243#endif
244#endif 244#endif
245 245
246#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 246#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
247static struct mtd_partition ezkit_partitions[] = { 247static struct mtd_partition ezkit_partitions[] = {
248 { 248 {
249 .name = "bootloader(nor)", 249 .name = "bootloader(nor)",
@@ -291,7 +291,7 @@ static struct platform_device ezkit_flash_device = {
291}; 291};
292#endif 292#endif
293 293
294#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 294#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
295/* SPI (0) */ 295/* SPI (0) */
296static struct resource bfin_spi0_resource[] = { 296static struct resource bfin_spi0_resource[] = {
297 [0] = { 297 [0] = {
@@ -330,8 +330,7 @@ static struct platform_device bfin_spi0_device = {
330#endif 330#endif
331 331
332static struct spi_board_info bfin_spi_board_info[] __initdata = { 332static struct spi_board_info bfin_spi_board_info[] __initdata = {
333#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \ 333#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
334 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
335 { 334 {
336 .modalias = "ad183x", 335 .modalias = "ad183x",
337 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 336 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -341,7 +340,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
341 .mode = SPI_MODE_3, 340 .mode = SPI_MODE_3,
342 }, 341 },
343#endif 342#endif
344#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 343#if IS_ENABLED(CONFIG_SPI_SPIDEV)
345 { 344 {
346 .modalias = "spidev", 345 .modalias = "spidev",
347 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 346 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -351,7 +350,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
351#endif 350#endif
352}; 351};
353 352
354#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 353#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
355#include <linux/input.h> 354#include <linux/input.h>
356#include <linux/gpio_keys.h> 355#include <linux/gpio_keys.h>
357 356
@@ -375,7 +374,7 @@ static struct platform_device bfin_device_gpiokeys = {
375}; 374};
376#endif 375#endif
377 376
378#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 377#if IS_ENABLED(CONFIG_I2C_GPIO)
379#include <linux/i2c-gpio.h> 378#include <linux/i2c-gpio.h>
380 379
381static struct i2c_gpio_platform_data i2c_gpio_data = { 380static struct i2c_gpio_platform_data i2c_gpio_data = {
@@ -422,8 +421,7 @@ static struct platform_device bfin_dpmc = {
422 }, 421 },
423}; 422};
424 423
425#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 424#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
426 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
427#include <linux/videodev2.h> 425#include <linux/videodev2.h>
428#include <media/blackfin/bfin_capture.h> 426#include <media/blackfin/bfin_capture.h>
429#include <media/blackfin/ppi.h> 427#include <media/blackfin/ppi.h>
@@ -443,8 +441,7 @@ static const struct ppi_info ppi_info = {
443 .pin_req = ppi_req, 441 .pin_req = ppi_req,
444}; 442};
445 443
446#if defined(CONFIG_VIDEO_ADV7183) \ 444#if IS_ENABLED(CONFIG_VIDEO_ADV7183)
447 || defined(CONFIG_VIDEO_ADV7183_MODULE)
448#include <media/adv7183.h> 445#include <media/adv7183.h>
449static struct v4l2_input adv7183_inputs[] = { 446static struct v4l2_input adv7183_inputs[] = {
450 { 447 {
@@ -515,7 +512,7 @@ static struct platform_device bfin_capture_device = {
515}; 512};
516#endif 513#endif
517 514
518#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 515#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
519static struct platform_device bfin_i2s = { 516static struct platform_device bfin_i2s = {
520 .name = "bfin-i2s", 517 .name = "bfin-i2s",
521 .id = CONFIG_SND_BF5XX_SPORT_NUM, 518 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -523,7 +520,7 @@ static struct platform_device bfin_i2s = {
523}; 520};
524#endif 521#endif
525 522
526#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 523#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
527static struct platform_device bfin_ac97 = { 524static struct platform_device bfin_ac97 = {
528 .name = "bfin-ac97", 525 .name = "bfin-ac97",
529 .id = CONFIG_SND_BF5XX_SPORT_NUM, 526 .id = CONFIG_SND_BF5XX_SPORT_NUM,
@@ -531,8 +528,7 @@ static struct platform_device bfin_ac97 = {
531}; 528};
532#endif 529#endif
533 530
534#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 531#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
535 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
536static const char * const ad1836_link[] = { 532static const char * const ad1836_link[] = {
537 "bfin-i2s.0", 533 "bfin-i2s.0",
538 "spi0.4", 534 "spi0.4",
@@ -550,72 +546,70 @@ static struct platform_device *ezkit_devices[] __initdata = {
550 546
551 &bfin_dpmc, 547 &bfin_dpmc,
552 548
553#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 549#if IS_ENABLED(CONFIG_SMC91X)
554 &smc91x_device, 550 &smc91x_device,
555#endif 551#endif
556 552
557#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 553#if IS_ENABLED(CONFIG_USB_NET2272)
558 &net2272_bfin_device, 554 &net2272_bfin_device,
559#endif 555#endif
560 556
561#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 557#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
562 &bfin_isp1760_device, 558 &bfin_isp1760_device,
563#endif 559#endif
564 560
565#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) 561#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
566 &bfin_spi0_device, 562 &bfin_spi0_device,
567#endif 563#endif
568 564
569#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 565#if IS_ENABLED(CONFIG_SERIAL_BFIN)
570#ifdef CONFIG_SERIAL_BFIN_UART0 566#ifdef CONFIG_SERIAL_BFIN_UART0
571 &bfin_uart0_device, 567 &bfin_uart0_device,
572#endif 568#endif
573#endif 569#endif
574 570
575#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 571#if IS_ENABLED(CONFIG_BFIN_SIR)
576#ifdef CONFIG_BFIN_SIR0 572#ifdef CONFIG_BFIN_SIR0
577 &bfin_sir0_device, 573 &bfin_sir0_device,
578#endif 574#endif
579#endif 575#endif
580 576
581#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 577#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
582 &bfin_device_gpiokeys, 578 &bfin_device_gpiokeys,
583#endif 579#endif
584 580
585#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 581#if IS_ENABLED(CONFIG_I2C_GPIO)
586 &i2c_gpio_device, 582 &i2c_gpio_device,
587#endif 583#endif
588 584
589#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 585#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
590 &isp1362_hcd_device, 586 &isp1362_hcd_device,
591#endif 587#endif
592 588
593#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 589#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
594 &ezkit_flash_device, 590 &ezkit_flash_device,
595#endif 591#endif
596 592
597#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 593#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
598 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
599 &bfin_capture_device, 594 &bfin_capture_device,
600#endif 595#endif
601 596
602#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 597#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
603 &bfin_i2s, 598 &bfin_i2s,
604#endif 599#endif
605 600
606#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE) 601#if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
607 &bfin_ac97, 602 &bfin_ac97,
608#endif 603#endif
609 604
610#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 605#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
611 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
612 &bfin_ad1836_machine, 606 &bfin_ad1836_machine,
613#endif 607#endif
614}; 608};
615 609
616static int __init net2272_init(void) 610static int __init net2272_init(void)
617{ 611{
618#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE) 612#if IS_ENABLED(CONFIG_USB_NET2272)
619 int ret; 613 int ret;
620 614
621 ret = gpio_request(GPIO_PF11, "net2272"); 615 ret = gpio_request(GPIO_PF11, "net2272");
@@ -641,12 +635,12 @@ static int __init ezkit_init(void)
641 if (ret < 0) 635 if (ret < 0)
642 return ret; 636 return ret;
643 637
644#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 638#if IS_ENABLED(CONFIG_SMC91X)
645 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12)); 639 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
646 SSYNC(); 640 SSYNC();
647#endif 641#endif
648 642
649#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE) 643#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
650 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15)); 644 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
651 bfin_write_FIO0_FLAG_S(1 << 15); 645 bfin_write_FIO0_FLAG_S(1 << 15);
652 SSYNC(); 646 SSYNC();
diff --git a/arch/blackfin/mach-bf561/boards/tepla.c b/arch/blackfin/mach-bf561/boards/tepla.c
index 1a57bc986aad..f87b8cc0cd4c 100644
--- a/arch/blackfin/mach-bf561/boards/tepla.c
+++ b/arch/blackfin/mach-bf561/boards/tepla.c
@@ -42,7 +42,7 @@ static struct platform_device smc91x_device = {
42 .resource = smc91x_resources, 42 .resource = smc91x_resources,
43}; 43};
44 44
45#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 45#if IS_ENABLED(CONFIG_SERIAL_BFIN)
46#ifdef CONFIG_SERIAL_BFIN_UART0 46#ifdef CONFIG_SERIAL_BFIN_UART0
47static struct resource bfin_uart0_resources[] = { 47static struct resource bfin_uart0_resources[] = {
48 { 48 {
@@ -93,7 +93,7 @@ static struct platform_device bfin_uart0_device = {
93#endif 93#endif
94#endif 94#endif
95 95
96#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 96#if IS_ENABLED(CONFIG_BFIN_SIR)
97#ifdef CONFIG_BFIN_SIR0 97#ifdef CONFIG_BFIN_SIR0
98static struct resource bfin_sir0_resources[] = { 98static struct resource bfin_sir0_resources[] = {
99 { 99 {
@@ -125,13 +125,13 @@ static struct platform_device bfin_sir0_device = {
125static struct platform_device *tepla_devices[] __initdata = { 125static struct platform_device *tepla_devices[] __initdata = {
126 &smc91x_device, 126 &smc91x_device,
127 127
128#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 128#if IS_ENABLED(CONFIG_SERIAL_BFIN)
129#ifdef CONFIG_SERIAL_BFIN_UART0 129#ifdef CONFIG_SERIAL_BFIN_UART0
130 &bfin_uart0_device, 130 &bfin_uart0_device,
131#endif 131#endif
132#endif 132#endif
133 133
134#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 134#if IS_ENABLED(CONFIG_BFIN_SIR)
135#ifdef CONFIG_BFIN_SIR0 135#ifdef CONFIG_BFIN_SIR0
136 &bfin_sir0_device, 136 &bfin_sir0_device,
137#endif 137#endif
diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c
index 8de8bc690b36..943f7e95ec15 100644
--- a/arch/blackfin/mach-bf609/boards/ezkit.c
+++ b/arch/blackfin/mach-bf609/boards/ezkit.c
@@ -39,7 +39,7 @@ const char bfin_board_name[] = "ADI BF609-EZKIT";
39 * Driver needs to know address, irq and flag pin. 39 * Driver needs to know address, irq and flag pin.
40 */ 40 */
41 41
42#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 42#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
43#include <linux/usb/isp1760.h> 43#include <linux/usb/isp1760.h>
44static struct resource bfin_isp1760_resources[] = { 44static struct resource bfin_isp1760_resources[] = {
45 [0] = { 45 [0] = {
@@ -74,7 +74,7 @@ static struct platform_device bfin_isp1760_device = {
74}; 74};
75#endif 75#endif
76 76
77#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 77#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
78#include <asm/bfin_rotary.h> 78#include <asm/bfin_rotary.h>
79 79
80static struct bfin_rotary_platform_data bfin_rotary_data = { 80static struct bfin_rotary_platform_data bfin_rotary_data = {
@@ -105,7 +105,7 @@ static struct platform_device bfin_rotary_device = {
105}; 105};
106#endif 106#endif
107 107
108#if defined(CONFIG_STMMAC_ETH) || defined(CONFIG_STMMAC_ETH_MODULE) 108#if IS_ENABLED(CONFIG_STMMAC_ETH)
109#include <linux/stmmac.h> 109#include <linux/stmmac.h>
110#include <linux/phy.h> 110#include <linux/phy.h>
111 111
@@ -159,7 +159,7 @@ static struct platform_device bfin_eth_device = {
159}; 159};
160#endif 160#endif
161 161
162#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE) 162#if IS_ENABLED(CONFIG_INPUT_ADXL34X)
163#include <linux/input/adxl34x.h> 163#include <linux/input/adxl34x.h>
164static const struct adxl34x_platform_data adxl34x_info = { 164static const struct adxl34x_platform_data adxl34x_info = {
165 .x_axis_offset = 0, 165 .x_axis_offset = 0,
@@ -198,14 +198,14 @@ static const struct adxl34x_platform_data adxl34x_info = {
198}; 198};
199#endif 199#endif
200 200
201#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 201#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
202static struct platform_device rtc_device = { 202static struct platform_device rtc_device = {
203 .name = "rtc-bfin", 203 .name = "rtc-bfin",
204 .id = -1, 204 .id = -1,
205}; 205};
206#endif 206#endif
207 207
208#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 208#if IS_ENABLED(CONFIG_SERIAL_BFIN)
209#ifdef CONFIG_SERIAL_BFIN_UART0 209#ifdef CONFIG_SERIAL_BFIN_UART0
210static struct resource bfin_uart0_resources[] = { 210static struct resource bfin_uart0_resources[] = {
211 { 211 {
@@ -355,7 +355,7 @@ static struct platform_device bfin_uart1_device = {
355#endif 355#endif
356#endif 356#endif
357 357
358#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 358#if IS_ENABLED(CONFIG_BFIN_SIR)
359#ifdef CONFIG_BFIN_SIR0 359#ifdef CONFIG_BFIN_SIR0
360static struct resource bfin_sir0_resources[] = { 360static struct resource bfin_sir0_resources[] = {
361 { 361 {
@@ -408,7 +408,7 @@ static struct platform_device bfin_sir1_device = {
408#endif 408#endif
409#endif 409#endif
410 410
411#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 411#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
412static struct resource musb_resources[] = { 412static struct resource musb_resources[] = {
413 [0] = { 413 [0] = {
414 .start = 0xFFCC1000, 414 .start = 0xFFCC1000,
@@ -464,7 +464,7 @@ static struct platform_device musb_device = {
464}; 464};
465#endif 465#endif
466 466
467#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 467#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
468#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 468#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
469static struct resource bfin_sport0_uart_resources[] = { 469static struct resource bfin_sport0_uart_resources[] = {
470 { 470 {
@@ -569,7 +569,7 @@ static struct platform_device bfin_sport2_uart_device = {
569#endif 569#endif
570#endif 570#endif
571 571
572#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 572#if IS_ENABLED(CONFIG_CAN_BFIN)
573 573
574static unsigned short bfin_can0_peripherals[] = { 574static unsigned short bfin_can0_peripherals[] = {
575 P_CAN0_RX, P_CAN0_TX, 0 575 P_CAN0_RX, P_CAN0_TX, 0
@@ -610,7 +610,7 @@ static struct platform_device bfin_can0_device = {
610 610
611#endif 611#endif
612 612
613#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 613#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
614static struct mtd_partition partition_info[] = { 614static struct mtd_partition partition_info[] = {
615 { 615 {
616 .name = "bootloader(nand)", 616 .name = "bootloader(nand)",
@@ -660,7 +660,7 @@ static struct platform_device bfin_nand_device = {
660}; 660};
661#endif 661#endif
662 662
663#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 663#if IS_ENABLED(CONFIG_SDH_BFIN)
664 664
665static struct bfin_sd_host bfin_sdh_data = { 665static struct bfin_sd_host bfin_sdh_data = {
666 .dma_chan = CH_RSI, 666 .dma_chan = CH_RSI,
@@ -677,7 +677,7 @@ static struct platform_device bfin_sdh_device = {
677}; 677};
678#endif 678#endif
679 679
680#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 680#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
681static struct mtd_partition ezkit_partitions[] = { 681static struct mtd_partition ezkit_partitions[] = {
682 { 682 {
683 .name = "bootloader(nor)", 683 .name = "bootloader(nor)",
@@ -741,8 +741,7 @@ static struct platform_device ezkit_flash_device = {
741}; 741};
742#endif 742#endif
743 743
744#if defined(CONFIG_MTD_M25P80) \ 744#if IS_ENABLED(CONFIG_MTD_M25P80)
745 || defined(CONFIG_MTD_M25P80_MODULE)
746/* SPI flash chip (w25q32) */ 745/* SPI flash chip (w25q32) */
747static struct mtd_partition bfin_spi_flash_partitions[] = { 746static struct mtd_partition bfin_spi_flash_partitions[] = {
748 { 747 {
@@ -773,21 +772,20 @@ static struct bfin_spi3_chip spi_flash_chip_info = {
773}; 772};
774#endif 773#endif
775 774
776#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 775#if IS_ENABLED(CONFIG_SPI_SPIDEV)
777static struct bfin_spi3_chip spidev_chip_info = { 776static struct bfin_spi3_chip spidev_chip_info = {
778 .enable_dma = true, 777 .enable_dma = true,
779}; 778};
780#endif 779#endif
781 780
782#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 781#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
783static struct platform_device bfin_i2s_pcm = { 782static struct platform_device bfin_i2s_pcm = {
784 .name = "bfin-i2s-pcm-audio", 783 .name = "bfin-i2s-pcm-audio",
785 .id = -1, 784 .id = -1,
786}; 785};
787#endif 786#endif
788 787
789#if defined(CONFIG_SND_BF6XX_SOC_I2S) || \ 788#if IS_ENABLED(CONFIG_SND_BF6XX_SOC_I2S)
790 defined(CONFIG_SND_BF6XX_SOC_I2S_MODULE)
791#include <asm/bfin_sport3.h> 789#include <asm/bfin_sport3.h>
792static struct resource bfin_snd_resources[] = { 790static struct resource bfin_snd_resources[] = {
793 { 791 {
@@ -841,8 +839,7 @@ static struct platform_device bfin_i2s = {
841}; 839};
842#endif 840#endif
843 841
844#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \ 842#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
845 || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
846static const char * const ad1836_link[] = { 843static const char * const ad1836_link[] = {
847 "bfin-i2s.0", 844 "bfin-i2s.0",
848 "spi0.76", 845 "spi0.76",
@@ -856,14 +853,13 @@ static struct platform_device bfin_ad1836_machine = {
856}; 853};
857#endif 854#endif
858 855
859#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) || \ 856#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61)
860 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61_MODULE)
861static struct platform_device adau1761_device = { 857static struct platform_device adau1761_device = {
862 .name = "bfin-eval-adau1x61", 858 .name = "bfin-eval-adau1x61",
863}; 859};
864#endif 860#endif
865 861
866#if defined(CONFIG_SND_SOC_ADAU1761) || defined(CONFIG_SND_SOC_ADAU1761_MODULE) 862#if IS_ENABLED(CONFIG_SND_SOC_ADAU1761)
867#include <sound/adau17x1.h> 863#include <sound/adau17x1.h>
868static struct adau1761_platform_data adau1761_info = { 864static struct adau1761_platform_data adau1761_info = {
869 .lineout_mode = ADAU1761_OUTPUT_MODE_LINE, 865 .lineout_mode = ADAU1761_OUTPUT_MODE_LINE,
@@ -871,8 +867,7 @@ static struct adau1761_platform_data adau1761_info = {
871}; 867};
872#endif 868#endif
873 869
874#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 870#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
875 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
876#include <linux/videodev2.h> 871#include <linux/videodev2.h>
877#include <media/blackfin/bfin_capture.h> 872#include <media/blackfin/bfin_capture.h>
878#include <media/blackfin/ppi.h> 873#include <media/blackfin/ppi.h>
@@ -882,7 +877,7 @@ static const unsigned short ppi_req[] = {
882 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, 877 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
883 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11, 878 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
884 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15, 879 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15,
885#if !defined(CONFIG_VIDEO_VS6624) && !defined(CONFIG_VIDEO_VS6624_MODULE) 880#if !IS_ENABLED(CONFIG_VIDEO_VS6624)
886 P_PPI0_D16, P_PPI0_D17, P_PPI0_D18, P_PPI0_D19, 881 P_PPI0_D16, P_PPI0_D17, P_PPI0_D18, P_PPI0_D19,
887 P_PPI0_D20, P_PPI0_D21, P_PPI0_D22, P_PPI0_D23, 882 P_PPI0_D20, P_PPI0_D21, P_PPI0_D22, P_PPI0_D23,
888#endif 883#endif
@@ -898,8 +893,7 @@ static const struct ppi_info ppi_info = {
898 .pin_req = ppi_req, 893 .pin_req = ppi_req,
899}; 894};
900 895
901#if defined(CONFIG_VIDEO_VS6624) \ 896#if IS_ENABLED(CONFIG_VIDEO_VS6624)
902 || defined(CONFIG_VIDEO_VS6624_MODULE)
903static struct v4l2_input vs6624_inputs[] = { 897static struct v4l2_input vs6624_inputs[] = {
904 { 898 {
905 .index = 0, 899 .index = 0,
@@ -936,8 +930,7 @@ static struct bfin_capture_config bfin_capture_data = {
936}; 930};
937#endif 931#endif
938 932
939#if defined(CONFIG_VIDEO_ADV7842) \ 933#if IS_ENABLED(CONFIG_VIDEO_ADV7842)
940 || defined(CONFIG_VIDEO_ADV7842_MODULE)
941#include <media/adv7842.h> 934#include <media/adv7842.h>
942 935
943static struct v4l2_input adv7842_inputs[] = { 936static struct v4l2_input adv7842_inputs[] = {
@@ -1067,8 +1060,7 @@ static struct platform_device bfin_capture_device = {
1067}; 1060};
1068#endif 1061#endif
1069 1062
1070#if defined(CONFIG_VIDEO_BLACKFIN_DISPLAY) \ 1063#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_DISPLAY)
1071 || defined(CONFIG_VIDEO_BLACKFIN_DISPLAY_MODULE)
1072#include <linux/videodev2.h> 1064#include <linux/videodev2.h>
1073#include <media/blackfin/bfin_display.h> 1065#include <media/blackfin/bfin_display.h>
1074#include <media/blackfin/ppi.h> 1066#include <media/blackfin/ppi.h>
@@ -1090,8 +1082,7 @@ static const struct ppi_info ppi_info = {
1090 .pin_req = ppi_req_disp, 1082 .pin_req = ppi_req_disp,
1091}; 1083};
1092 1084
1093#if defined(CONFIG_VIDEO_ADV7511) \ 1085#if IS_ENABLED(CONFIG_VIDEO_ADV7511)
1094 || defined(CONFIG_VIDEO_ADV7511_MODULE)
1095#include <media/adv7511.h> 1086#include <media/adv7511.h>
1096 1087
1097static struct v4l2_output adv7511_outputs[] = { 1088static struct v4l2_output adv7511_outputs[] = {
@@ -1313,7 +1304,7 @@ static struct platform_device bfin_crypto_crc_device = {
1313}; 1304};
1314#endif 1305#endif
1315 1306
1316#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1307#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
1317static const struct ad7877_platform_data bfin_ad7877_ts_info = { 1308static const struct ad7877_platform_data bfin_ad7877_ts_info = {
1318 .model = 7877, 1309 .model = 7877,
1319 .vref_delay_usecs = 50, /* internal, no capacitor */ 1310 .vref_delay_usecs = 50, /* internal, no capacitor */
@@ -1679,7 +1670,7 @@ static struct platform_device bfin_gpg_device = {
1679 1670
1680#endif 1671#endif
1681 1672
1682#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 1673#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
1683#include <linux/input.h> 1674#include <linux/input.h>
1684#include <linux/gpio_keys.h> 1675#include <linux/gpio_keys.h>
1685 1676
@@ -1702,8 +1693,7 @@ static struct platform_device bfin_device_gpiokeys = {
1702#endif 1693#endif
1703 1694
1704static struct spi_board_info bfin_spi_board_info[] __initdata = { 1695static struct spi_board_info bfin_spi_board_info[] __initdata = {
1705#if defined(CONFIG_MTD_M25P80) \ 1696#if IS_ENABLED(CONFIG_MTD_M25P80)
1706 || defined(CONFIG_MTD_M25P80_MODULE)
1707 { 1697 {
1708 /* the modalias must be the same as spi device driver name */ 1698 /* the modalias must be the same as spi device driver name */
1709 .modalias = "m25p80", /* Name of spi_driver for this device */ 1699 .modalias = "m25p80", /* Name of spi_driver for this device */
@@ -1715,7 +1705,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1715 .mode = SPI_MODE_3, 1705 .mode = SPI_MODE_3,
1716 }, 1706 },
1717#endif 1707#endif
1718#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 1708#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
1719 { 1709 {
1720 .modalias = "ad7877", 1710 .modalias = "ad7877",
1721 .platform_data = &bfin_ad7877_ts_info, 1711 .platform_data = &bfin_ad7877_ts_info,
@@ -1725,7 +1715,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1725 .chip_select = MAX_CTRL_CS + GPIO_PC15, /* SPI_SSEL4 */ 1715 .chip_select = MAX_CTRL_CS + GPIO_PC15, /* SPI_SSEL4 */
1726 }, 1716 },
1727#endif 1717#endif
1728#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 1718#if IS_ENABLED(CONFIG_SPI_SPIDEV)
1729 { 1719 {
1730 .modalias = "spidev", 1720 .modalias = "spidev",
1731 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1721 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
@@ -1734,7 +1724,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1734 .controller_data = &spidev_chip_info, 1724 .controller_data = &spidev_chip_info,
1735 }, 1725 },
1736#endif 1726#endif
1737#if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE) 1727#if IS_ENABLED(CONFIG_INPUT_ADXL34X_SPI)
1738 { 1728 {
1739 .modalias = "adxl34x", 1729 .modalias = "adxl34x",
1740 .platform_data = &adxl34x_info, 1730 .platform_data = &adxl34x_info,
@@ -1818,7 +1808,7 @@ static struct platform_device bf60x_spi_master1 = {
1818}; 1808};
1819#endif /* spi master and devices */ 1809#endif /* spi master and devices */
1820 1810
1821#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 1811#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
1822static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0}; 1812static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
1823 1813
1824static struct resource bfin_twi0_resource[] = { 1814static struct resource bfin_twi0_resource[] = {
@@ -1871,20 +1861,20 @@ static struct platform_device i2c_bfin_twi1_device = {
1871#endif 1861#endif
1872 1862
1873static struct i2c_board_info __initdata bfin_i2c_board_info0[] = { 1863static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
1874#if defined(CONFIG_INPUT_ADXL34X_I2C) || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE) 1864#if IS_ENABLED(CONFIG_INPUT_ADXL34X_I2C)
1875 { 1865 {
1876 I2C_BOARD_INFO("adxl34x", 0x53), 1866 I2C_BOARD_INFO("adxl34x", 0x53),
1877 .irq = IRQ_PC5, 1867 .irq = IRQ_PC5,
1878 .platform_data = (void *)&adxl34x_info, 1868 .platform_data = (void *)&adxl34x_info,
1879 }, 1869 },
1880#endif 1870#endif
1881#if defined(CONFIG_SND_SOC_ADAU1761) || defined(CONFIG_SND_SOC_ADAU1761_MODULE) 1871#if IS_ENABLED(CONFIG_SND_SOC_ADAU1761)
1882 { 1872 {
1883 I2C_BOARD_INFO("adau1761", 0x38), 1873 I2C_BOARD_INFO("adau1761", 0x38),
1884 .platform_data = (void *)&adau1761_info 1874 .platform_data = (void *)&adau1761_info
1885 }, 1875 },
1886#endif 1876#endif
1887#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE) 1877#if IS_ENABLED(CONFIG_SND_SOC_SSM2602)
1888 { 1878 {
1889 I2C_BOARD_INFO("ssm2602", 0x1b), 1879 I2C_BOARD_INFO("ssm2602", 0x1b),
1890 }, 1880 },
@@ -1942,11 +1932,11 @@ static struct platform_device *ezkit_devices[] __initdata = {
1942 &bfin_gpg_device, 1932 &bfin_gpg_device,
1943#endif 1933#endif
1944 1934
1945#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 1935#if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
1946 &rtc_device, 1936 &rtc_device,
1947#endif 1937#endif
1948 1938
1949#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 1939#if IS_ENABLED(CONFIG_SERIAL_BFIN)
1950#ifdef CONFIG_SERIAL_BFIN_UART0 1940#ifdef CONFIG_SERIAL_BFIN_UART0
1951 &bfin_uart0_device, 1941 &bfin_uart0_device,
1952#endif 1942#endif
@@ -1955,7 +1945,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
1955#endif 1945#endif
1956#endif 1946#endif
1957 1947
1958#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) 1948#if IS_ENABLED(CONFIG_BFIN_SIR)
1959#ifdef CONFIG_BFIN_SIR0 1949#ifdef CONFIG_BFIN_SIR0
1960 &bfin_sir0_device, 1950 &bfin_sir0_device,
1961#endif 1951#endif
@@ -1964,19 +1954,19 @@ static struct platform_device *ezkit_devices[] __initdata = {
1964#endif 1954#endif
1965#endif 1955#endif
1966 1956
1967#if defined(CONFIG_STMMAC_ETH) || defined(CONFIG_STMMAC_ETH_MODULE) 1957#if IS_ENABLED(CONFIG_STMMAC_ETH)
1968 &bfin_eth_device, 1958 &bfin_eth_device,
1969#endif 1959#endif
1970 1960
1971#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) 1961#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
1972 &musb_device, 1962 &musb_device,
1973#endif 1963#endif
1974 1964
1975#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) 1965#if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
1976 &bfin_isp1760_device, 1966 &bfin_isp1760_device,
1977#endif 1967#endif
1978 1968
1979#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 1969#if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
1980#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 1970#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
1981 &bfin_sport0_uart_device, 1971 &bfin_sport0_uart_device,
1982#endif 1972#endif
@@ -1988,15 +1978,15 @@ static struct platform_device *ezkit_devices[] __initdata = {
1988#endif 1978#endif
1989#endif 1979#endif
1990 1980
1991#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) 1981#if IS_ENABLED(CONFIG_CAN_BFIN)
1992 &bfin_can0_device, 1982 &bfin_can0_device,
1993#endif 1983#endif
1994 1984
1995#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 1985#if IS_ENABLED(CONFIG_MTD_NAND_BF5XX)
1996 &bfin_nand_device, 1986 &bfin_nand_device,
1997#endif 1987#endif
1998 1988
1999#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE) 1989#if IS_ENABLED(CONFIG_SDH_BFIN)
2000 &bfin_sdh_device, 1990 &bfin_sdh_device,
2001#endif 1991#endif
2002 1992
@@ -2005,11 +1995,11 @@ static struct platform_device *ezkit_devices[] __initdata = {
2005 &bf60x_spi_master1, 1995 &bf60x_spi_master1,
2006#endif 1996#endif
2007 1997
2008#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE) 1998#if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
2009 &bfin_rotary_device, 1999 &bfin_rotary_device,
2010#endif 2000#endif
2011 2001
2012#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 2002#if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
2013 &i2c_bfin_twi0_device, 2003 &i2c_bfin_twi0_device,
2014#if !defined(CONFIG_BF542) 2004#if !defined(CONFIG_BF542)
2015 &i2c_bfin_twi1_device, 2005 &i2c_bfin_twi1_device,
@@ -2024,34 +2014,29 @@ static struct platform_device *ezkit_devices[] __initdata = {
2024 &bfin_crypto_crc_device, 2014 &bfin_crypto_crc_device,
2025#endif 2015#endif
2026 2016
2027#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 2017#if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
2028 &bfin_device_gpiokeys, 2018 &bfin_device_gpiokeys,
2029#endif 2019#endif
2030 2020
2031#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 2021#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
2032 &ezkit_flash_device, 2022 &ezkit_flash_device,
2033#endif 2023#endif
2034#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE) 2024#if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
2035 &bfin_i2s_pcm, 2025 &bfin_i2s_pcm,
2036#endif 2026#endif
2037#if defined(CONFIG_SND_BF6XX_SOC_I2S) || \ 2027#if IS_ENABLED(CONFIG_SND_BF6XX_SOC_I2S)
2038 defined(CONFIG_SND_BF6XX_SOC_I2S_MODULE)
2039 &bfin_i2s, 2028 &bfin_i2s,
2040#endif 2029#endif
2041#if defined(CONFIG_SND_BF5XX_SOC_AD1836) || \ 2030#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
2042 defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
2043 &bfin_ad1836_machine, 2031 &bfin_ad1836_machine,
2044#endif 2032#endif
2045#if defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) || \ 2033#if IS_ENABLED(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61)
2046 defined(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61_MODULE)
2047 &adau1761_device, 2034 &adau1761_device,
2048#endif 2035#endif
2049#if defined(CONFIG_VIDEO_BLACKFIN_CAPTURE) \ 2036#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
2050 || defined(CONFIG_VIDEO_BLACKFIN_CAPTURE_MODULE)
2051 &bfin_capture_device, 2037 &bfin_capture_device,
2052#endif 2038#endif
2053#if defined(CONFIG_VIDEO_BLACKFIN_DISPLAY) \ 2039#if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_DISPLAY)
2054 || defined(CONFIG_VIDEO_BLACKFIN_DISPLAY_MODULE)
2055 &bfin_display_device, 2040 &bfin_display_device,
2056#endif 2041#endif
2057 2042
@@ -2075,9 +2060,9 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = {
2075 PIN_MAP_MUX_GROUP_DEFAULT("physmap-flash.0", "pinctrl-adi2.0", NULL, "smc0"), 2060 PIN_MAP_MUX_GROUP_DEFAULT("physmap-flash.0", "pinctrl-adi2.0", NULL, "smc0"),
2076 PIN_MAP_MUX_GROUP_DEFAULT("bf609_nl8048.2", "pinctrl-adi2.0", NULL, "ppi2_16b"), 2061 PIN_MAP_MUX_GROUP_DEFAULT("bf609_nl8048.2", "pinctrl-adi2.0", NULL, "ppi2_16b"),
2077 PIN_MAP_MUX_GROUP_DEFAULT("bfin_display.0", "pinctrl-adi2.0", NULL, "ppi0_16b"), 2062 PIN_MAP_MUX_GROUP_DEFAULT("bfin_display.0", "pinctrl-adi2.0", NULL, "ppi0_16b"),
2078#if defined(CONFIG_VIDEO_MT9M114) || defined(CONFIG_VIDEO_MT9M114_MODULE) 2063#if IS_ENABLED(CONFIG_VIDEO_MT9M114)
2079 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_8b"), 2064 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_8b"),
2080#elif defined(CONFIG_VIDEO_VS6624) || defined(CONFIG_VIDEO_VS6624_MODULE) 2065#elif IS_ENABLED(CONFIG_VIDEO_VS6624)
2081 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_16b"), 2066 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_16b"),
2082#else 2067#else
2083 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_24b"), 2068 PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_24b"),
diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c
index 13644ed25489..56200f37cfc8 100644
--- a/arch/blackfin/mach-bf609/clock.c
+++ b/arch/blackfin/mach-bf609/clock.c
@@ -73,24 +73,6 @@ static void clk_reg_write_mask(u32 reg, uint32_t val, uint32_t mask)
73 bfin_write32(reg, val2); 73 bfin_write32(reg, val2);
74} 74}
75 75
76static void clk_reg_set_bits(u32 reg, uint32_t mask)
77{
78 u32 val;
79
80 val = bfin_read32(reg);
81 val |= mask;
82 bfin_write32(reg, val);
83}
84
85static void clk_reg_clear_bits(u32 reg, uint32_t mask)
86{
87 u32 val;
88
89 val = bfin_read32(reg);
90 val &= ~mask;
91 bfin_write32(reg, val);
92}
93
94int wait_for_pll_align(void) 76int wait_for_pll_align(void)
95{ 77{
96 int i = 10000; 78 int i = 10000;
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c
index ad505d9db4a8..0cdd6955c7be 100644
--- a/arch/blackfin/mach-bf609/pm.c
+++ b/arch/blackfin/mach-bf609/pm.c
@@ -210,7 +210,7 @@ void bf609_cpu_pm_enter(suspend_state_t state)
210 210
211#ifdef CONFIG_PM_BFIN_WAKE_PB15 211#ifdef CONFIG_PM_BFIN_WAKE_PB15
212 wakeup |= PB15WE; 212 wakeup |= PB15WE;
213# if CONFIG_PM_BFIN_WAKE_PA15_POL 213# if CONFIG_PM_BFIN_WAKE_PB15_POL
214 wakeup_pol |= PB15WE; 214 wakeup_pol |= PB15WE;
215# endif 215# endif
216#endif 216#endif
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 1325c3bc58e1..12c3afee0f6f 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -45,6 +45,7 @@ config IA64
45 select HAVE_MOD_ARCH_SPECIFIC 45 select HAVE_MOD_ARCH_SPECIFIC
46 select MODULES_USE_ELF_RELA 46 select MODULES_USE_ELF_RELA
47 select ARCH_USE_CMPXCHG_LOCKREF 47 select ARCH_USE_CMPXCHG_LOCKREF
48 select HAVE_ARCH_AUDITSYSCALL
48 default y 49 default y
49 help 50 help
50 The Itanium Processor Family is Intel's 64-bit successor to 51 The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 79b9bcdfe498..9ae08541e30d 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -1,38 +1,38 @@
1config MICROBLAZE 1config MICROBLAZE
2 def_bool y 2 def_bool y
3 select ARCH_MIGHT_HAVE_PC_PARPORT 3 select ARCH_MIGHT_HAVE_PC_PARPORT
4 select HAVE_MEMBLOCK
5 select HAVE_MEMBLOCK_NODE_MAP
6 select HAVE_FUNCTION_TRACER
7 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
8 select HAVE_FUNCTION_GRAPH_TRACER
9 select HAVE_DYNAMIC_FTRACE
10 select HAVE_FTRACE_MCOUNT_RECORD
11 select ARCH_WANT_OPTIONAL_GPIOLIB
12 select HAVE_OPROFILE
13 select HAVE_ARCH_KGDB
14 select HAVE_DMA_ATTRS
15 select HAVE_DMA_API_DEBUG
16 select TRACING_SUPPORT
17 select OF
18 select OF_EARLY_FLATTREE
19 select ARCH_WANT_IPC_PARSE_VERSION 4 select ARCH_WANT_IPC_PARSE_VERSION
20 select HAVE_DEBUG_KMEMLEAK 5 select ARCH_WANT_OPTIONAL_GPIOLIB
21 select IRQ_DOMAIN 6 select BUILDTIME_EXTABLE_SORT
22 select VIRT_TO_BUS 7 select CLKSRC_OF
8 select CLONE_BACKWARDS3
9 select COMMON_CLK
10 select GENERIC_ATOMIC64
11 select GENERIC_CLOCKEVENTS
12 select GENERIC_CPU_DEVICES
13 select GENERIC_IDLE_POLL_SETUP
23 select GENERIC_IRQ_PROBE 14 select GENERIC_IRQ_PROBE
24 select GENERIC_IRQ_SHOW 15 select GENERIC_IRQ_SHOW
25 select GENERIC_PCI_IOMAP 16 select GENERIC_PCI_IOMAP
26 select GENERIC_CPU_DEVICES
27 select GENERIC_ATOMIC64
28 select GENERIC_CLOCKEVENTS
29 select COMMON_CLK
30 select GENERIC_SCHED_CLOCK 17 select GENERIC_SCHED_CLOCK
31 select GENERIC_IDLE_POLL_SETUP 18 select HAVE_ARCH_KGDB
19 select HAVE_DEBUG_KMEMLEAK
20 select HAVE_DMA_API_DEBUG
21 select HAVE_DMA_ATTRS
22 select HAVE_DYNAMIC_FTRACE
23 select HAVE_FTRACE_MCOUNT_RECORD
24 select HAVE_FUNCTION_GRAPH_TRACER
25 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
26 select HAVE_FUNCTION_TRACER
27 select HAVE_MEMBLOCK
28 select HAVE_MEMBLOCK_NODE_MAP
29 select HAVE_OPROFILE
30 select IRQ_DOMAIN
32 select MODULES_USE_ELF_RELA 31 select MODULES_USE_ELF_RELA
33 select CLONE_BACKWARDS3 32 select OF
34 select CLKSRC_OF 33 select OF_EARLY_FLATTREE
35 select BUILDTIME_EXTABLE_SORT 34 select TRACING_SUPPORT
35 select VIRT_TO_BUS
36 36
37config SWAP 37config SWAP
38 def_bool n 38 def_bool n
@@ -74,7 +74,7 @@ source "init/Kconfig"
74 74
75source "kernel/Kconfig.freezer" 75source "kernel/Kconfig.freezer"
76 76
77source "arch/microblaze/platform/Kconfig.platform" 77source "arch/microblaze/Kconfig.platform"
78 78
79menu "Processor type and features" 79menu "Processor type and features"
80 80
diff --git a/arch/microblaze/platform/Kconfig.platform b/arch/microblaze/Kconfig.platform
index db1aa5c22cea..1b3d8c849101 100644
--- a/arch/microblaze/platform/Kconfig.platform
+++ b/arch/microblaze/Kconfig.platform
@@ -5,18 +5,6 @@
5# 5#
6 6
7menu "Platform options" 7menu "Platform options"
8choice
9 prompt "Platform"
10 default PLATFORM_MICROBLAZE_AUTO
11 help
12 Choose which hardware board/platform you are targeting.
13
14config PLATFORM_GENERIC
15 bool "Generic"
16 help
17 Choose this option for the Generic platform.
18
19endchoice
20 8
21config OPT_LIB_FUNCTION 9config OPT_LIB_FUNCTION
22 bool "Optimalized lib function" 10 bool "Optimalized lib function"
@@ -37,8 +25,45 @@ config OPT_LIB_ASM
37 Allows turn on optimalized library function (memcpy and memmove). 25 Allows turn on optimalized library function (memcpy and memmove).
38 Function are written in asm code. 26 Function are written in asm code.
39 27
40if PLATFORM_GENERIC=y 28# Definitions for MICROBLAZE0
41 source "arch/microblaze/platform/generic/Kconfig.auto" 29comment "Definitions for MICROBLAZE0"
42endif 30
31config KERNEL_BASE_ADDR
32 hex "Physical address where Linux Kernel is"
33 default "0x90000000"
34 help
35 BASE Address for kernel
36
37config XILINX_MICROBLAZE0_FAMILY
38 string "Targeted FPGA family"
39 default "virtex5"
40
41config XILINX_MICROBLAZE0_USE_MSR_INSTR
42 int "USE_MSR_INSTR range (0:1)"
43 default 0
44
45config XILINX_MICROBLAZE0_USE_PCMP_INSTR
46 int "USE_PCMP_INSTR range (0:1)"
47 default 0
48
49config XILINX_MICROBLAZE0_USE_BARREL
50 int "USE_BARREL range (0:1)"
51 default 0
52
53config XILINX_MICROBLAZE0_USE_DIV
54 int "USE_DIV range (0:1)"
55 default 0
56
57config XILINX_MICROBLAZE0_USE_HW_MUL
58 int "USE_HW_MUL values (0=NONE, 1=MUL32, 2=MUL64)"
59 default 0
60
61config XILINX_MICROBLAZE0_USE_FPU
62 int "USE_FPU values (0=NONE, 1=BASIC, 2=EXTENDED)"
63 default 0
64
65config XILINX_MICROBLAZE0_HW_VER
66 string "Core version number"
67 default 7.10.d
43 68
44endmenu 69endmenu
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index a69eaf2ab130..740f2b82a182 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -48,7 +48,6 @@ head-y := arch/microblaze/kernel/head.o
48libs-y += arch/microblaze/lib/ 48libs-y += arch/microblaze/lib/
49core-y += arch/microblaze/kernel/ 49core-y += arch/microblaze/kernel/
50core-y += arch/microblaze/mm/ 50core-y += arch/microblaze/mm/
51core-y += arch/microblaze/platform/
52core-$(CONFIG_PCI) += arch/microblaze/pci/ 51core-$(CONFIG_PCI) += arch/microblaze/pci/
53 52
54drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 53drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
diff --git a/arch/microblaze/boot/dts/system.dts b/arch/microblaze/boot/dts/system.dts
index 7cb657892f21..b620da23febb 120000..100644
--- a/arch/microblaze/boot/dts/system.dts
+++ b/arch/microblaze/boot/dts/system.dts
@@ -1 +1,366 @@
1../../platform/generic/system.dts \ No newline at end of file 1/*
2 * Device Tree Generator version: 1.1
3 *
4 * (C) Copyright 2007-2008 Xilinx, Inc.
5 * (C) Copyright 2007-2009 Michal Simek
6 *
7 * Michal SIMEK <monstr@monstr.eu>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) 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., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 *
24 * CAUTION: This file is automatically generated by libgen.
25 * Version: Xilinx EDK 10.1.03 EDK_K_SP3.6
26 *
27 * XPS project directory: Xilinx-ML505-ll_temac-sgdma-MMU-FDT-edk101
28 */
29
30/dts-v1/;
31/ {
32 #address-cells = <1>;
33 #size-cells = <1>;
34 compatible = "xlnx,microblaze";
35 hard-reset-gpios = <&LEDs_8Bit 2 1>;
36 model = "testing";
37 DDR2_SDRAM: memory@90000000 {
38 device_type = "memory";
39 reg = < 0x90000000 0x10000000 >;
40 } ;
41 aliases {
42 ethernet0 = &Hard_Ethernet_MAC;
43 serial0 = &RS232_Uart_1;
44 } ;
45 chosen {
46 bootargs = "console=ttyUL0,115200 highres=on";
47 linux,stdout-path = "/plb@0/serial@84000000";
48 } ;
49 cpus {
50 #address-cells = <1>;
51 #cpus = <0x1>;
52 #size-cells = <0>;
53 microblaze_0: cpu@0 {
54 clock-frequency = <125000000>;
55 compatible = "xlnx,microblaze-7.10.d";
56 d-cache-baseaddr = <0x90000000>;
57 d-cache-highaddr = <0x9fffffff>;
58 d-cache-line-size = <0x10>;
59 d-cache-size = <0x2000>;
60 device_type = "cpu";
61 i-cache-baseaddr = <0x90000000>;
62 i-cache-highaddr = <0x9fffffff>;
63 i-cache-line-size = <0x10>;
64 i-cache-size = <0x2000>;
65 model = "microblaze,7.10.d";
66 reg = <0>;
67 timebase-frequency = <125000000>;
68 xlnx,addr-tag-bits = <0xf>;
69 xlnx,allow-dcache-wr = <0x1>;
70 xlnx,allow-icache-wr = <0x1>;
71 xlnx,area-optimized = <0x0>;
72 xlnx,cache-byte-size = <0x2000>;
73 xlnx,d-lmb = <0x1>;
74 xlnx,d-opb = <0x0>;
75 xlnx,d-plb = <0x1>;
76 xlnx,data-size = <0x20>;
77 xlnx,dcache-addr-tag = <0xf>;
78 xlnx,dcache-always-used = <0x1>;
79 xlnx,dcache-byte-size = <0x2000>;
80 xlnx,dcache-line-len = <0x4>;
81 xlnx,dcache-use-fsl = <0x1>;
82 xlnx,debug-enabled = <0x1>;
83 xlnx,div-zero-exception = <0x1>;
84 xlnx,dopb-bus-exception = <0x0>;
85 xlnx,dynamic-bus-sizing = <0x1>;
86 xlnx,edge-is-positive = <0x1>;
87 xlnx,family = "virtex5";
88 xlnx,endianness = <0x1>;
89 xlnx,fpu-exception = <0x1>;
90 xlnx,fsl-data-size = <0x20>;
91 xlnx,fsl-exception = <0x0>;
92 xlnx,fsl-links = <0x0>;
93 xlnx,i-lmb = <0x1>;
94 xlnx,i-opb = <0x0>;
95 xlnx,i-plb = <0x1>;
96 xlnx,icache-always-used = <0x1>;
97 xlnx,icache-line-len = <0x4>;
98 xlnx,icache-use-fsl = <0x1>;
99 xlnx,ill-opcode-exception = <0x1>;
100 xlnx,instance = "microblaze_0";
101 xlnx,interconnect = <0x1>;
102 xlnx,interrupt-is-edge = <0x0>;
103 xlnx,iopb-bus-exception = <0x0>;
104 xlnx,mmu-dtlb-size = <0x4>;
105 xlnx,mmu-itlb-size = <0x2>;
106 xlnx,mmu-tlb-access = <0x3>;
107 xlnx,mmu-zones = <0x10>;
108 xlnx,number-of-pc-brk = <0x1>;
109 xlnx,number-of-rd-addr-brk = <0x0>;
110 xlnx,number-of-wr-addr-brk = <0x0>;
111 xlnx,opcode-0x0-illegal = <0x1>;
112 xlnx,pvr = <0x2>;
113 xlnx,pvr-user1 = <0x0>;
114 xlnx,pvr-user2 = <0x0>;
115 xlnx,reset-msr = <0x0>;
116 xlnx,sco = <0x0>;
117 xlnx,unaligned-exceptions = <0x1>;
118 xlnx,use-barrel = <0x1>;
119 xlnx,use-dcache = <0x1>;
120 xlnx,use-div = <0x1>;
121 xlnx,use-ext-brk = <0x1>;
122 xlnx,use-ext-nm-brk = <0x1>;
123 xlnx,use-extended-fsl-instr = <0x0>;
124 xlnx,use-fpu = <0x2>;
125 xlnx,use-hw-mul = <0x2>;
126 xlnx,use-icache = <0x1>;
127 xlnx,use-interrupt = <0x1>;
128 xlnx,use-mmu = <0x3>;
129 xlnx,use-msr-instr = <0x1>;
130 xlnx,use-pcmp-instr = <0x1>;
131 } ;
132 } ;
133 mb_plb: plb@0 {
134 #address-cells = <1>;
135 #size-cells = <1>;
136 compatible = "xlnx,plb-v46-1.03.a", "xlnx,plb-v46-1.00.a", "simple-bus";
137 ranges ;
138 FLASH: flash@a0000000 {
139 bank-width = <2>;
140 compatible = "xlnx,xps-mch-emc-2.00.a", "cfi-flash";
141 reg = < 0xa0000000 0x2000000 >;
142 xlnx,family = "virtex5";
143 xlnx,include-datawidth-matching-0 = <0x1>;
144 xlnx,include-datawidth-matching-1 = <0x0>;
145 xlnx,include-datawidth-matching-2 = <0x0>;
146 xlnx,include-datawidth-matching-3 = <0x0>;
147 xlnx,include-negedge-ioregs = <0x0>;
148 xlnx,include-plb-ipif = <0x1>;
149 xlnx,include-wrbuf = <0x1>;
150 xlnx,max-mem-width = <0x10>;
151 xlnx,mch-native-dwidth = <0x20>;
152 xlnx,mch-plb-clk-period-ps = <0x1f40>;
153 xlnx,mch-splb-awidth = <0x20>;
154 xlnx,mch0-accessbuf-depth = <0x10>;
155 xlnx,mch0-protocol = <0x0>;
156 xlnx,mch0-rddatabuf-depth = <0x10>;
157 xlnx,mch1-accessbuf-depth = <0x10>;
158 xlnx,mch1-protocol = <0x0>;
159 xlnx,mch1-rddatabuf-depth = <0x10>;
160 xlnx,mch2-accessbuf-depth = <0x10>;
161 xlnx,mch2-protocol = <0x0>;
162 xlnx,mch2-rddatabuf-depth = <0x10>;
163 xlnx,mch3-accessbuf-depth = <0x10>;
164 xlnx,mch3-protocol = <0x0>;
165 xlnx,mch3-rddatabuf-depth = <0x10>;
166 xlnx,mem0-width = <0x10>;
167 xlnx,mem1-width = <0x20>;
168 xlnx,mem2-width = <0x20>;
169 xlnx,mem3-width = <0x20>;
170 xlnx,num-banks-mem = <0x1>;
171 xlnx,num-channels = <0x0>;
172 xlnx,priority-mode = <0x0>;
173 xlnx,synch-mem-0 = <0x0>;
174 xlnx,synch-mem-1 = <0x0>;
175 xlnx,synch-mem-2 = <0x0>;
176 xlnx,synch-mem-3 = <0x0>;
177 xlnx,synch-pipedelay-0 = <0x2>;
178 xlnx,synch-pipedelay-1 = <0x2>;
179 xlnx,synch-pipedelay-2 = <0x2>;
180 xlnx,synch-pipedelay-3 = <0x2>;
181 xlnx,tavdv-ps-mem-0 = <0x1adb0>;
182 xlnx,tavdv-ps-mem-1 = <0x3a98>;
183 xlnx,tavdv-ps-mem-2 = <0x3a98>;
184 xlnx,tavdv-ps-mem-3 = <0x3a98>;
185 xlnx,tcedv-ps-mem-0 = <0x1adb0>;
186 xlnx,tcedv-ps-mem-1 = <0x3a98>;
187 xlnx,tcedv-ps-mem-2 = <0x3a98>;
188 xlnx,tcedv-ps-mem-3 = <0x3a98>;
189 xlnx,thzce-ps-mem-0 = <0x88b8>;
190 xlnx,thzce-ps-mem-1 = <0x1b58>;
191 xlnx,thzce-ps-mem-2 = <0x1b58>;
192 xlnx,thzce-ps-mem-3 = <0x1b58>;
193 xlnx,thzoe-ps-mem-0 = <0x1b58>;
194 xlnx,thzoe-ps-mem-1 = <0x1b58>;
195 xlnx,thzoe-ps-mem-2 = <0x1b58>;
196 xlnx,thzoe-ps-mem-3 = <0x1b58>;
197 xlnx,tlzwe-ps-mem-0 = <0x88b8>;
198 xlnx,tlzwe-ps-mem-1 = <0x0>;
199 xlnx,tlzwe-ps-mem-2 = <0x0>;
200 xlnx,tlzwe-ps-mem-3 = <0x0>;
201 xlnx,twc-ps-mem-0 = <0x2af8>;
202 xlnx,twc-ps-mem-1 = <0x3a98>;
203 xlnx,twc-ps-mem-2 = <0x3a98>;
204 xlnx,twc-ps-mem-3 = <0x3a98>;
205 xlnx,twp-ps-mem-0 = <0x11170>;
206 xlnx,twp-ps-mem-1 = <0x2ee0>;
207 xlnx,twp-ps-mem-2 = <0x2ee0>;
208 xlnx,twp-ps-mem-3 = <0x2ee0>;
209 xlnx,xcl0-linesize = <0x4>;
210 xlnx,xcl0-writexfer = <0x1>;
211 xlnx,xcl1-linesize = <0x4>;
212 xlnx,xcl1-writexfer = <0x1>;
213 xlnx,xcl2-linesize = <0x4>;
214 xlnx,xcl2-writexfer = <0x1>;
215 xlnx,xcl3-linesize = <0x4>;
216 xlnx,xcl3-writexfer = <0x1>;
217 } ;
218 Hard_Ethernet_MAC: xps-ll-temac@81c00000 {
219 #address-cells = <1>;
220 #size-cells = <1>;
221 compatible = "xlnx,compound";
222 ranges ;
223 ethernet@81c00000 {
224 compatible = "xlnx,xps-ll-temac-1.01.b", "xlnx,xps-ll-temac-1.00.a";
225 interrupt-parent = <&xps_intc_0>;
226 interrupts = < 5 2 >;
227 llink-connected = <&PIM3>;
228 local-mac-address = [ 00 0a 35 00 00 00 ];
229 reg = < 0x81c00000 0x40 >;
230 xlnx,bus2core-clk-ratio = <0x1>;
231 xlnx,phy-type = <0x1>;
232 xlnx,phyaddr = <0x1>;
233 xlnx,rxcsum = <0x0>;
234 xlnx,rxfifo = <0x1000>;
235 xlnx,temac-type = <0x0>;
236 xlnx,txcsum = <0x0>;
237 xlnx,txfifo = <0x1000>;
238 } ;
239 } ;
240 IIC_EEPROM: i2c@81600000 {
241 compatible = "xlnx,xps-iic-2.00.a";
242 interrupt-parent = <&xps_intc_0>;
243 interrupts = < 6 2 >;
244 reg = < 0x81600000 0x10000 >;
245 xlnx,clk-freq = <0x7735940>;
246 xlnx,family = "virtex5";
247 xlnx,gpo-width = <0x1>;
248 xlnx,iic-freq = <0x186a0>;
249 xlnx,scl-inertial-delay = <0x0>;
250 xlnx,sda-inertial-delay = <0x0>;
251 xlnx,ten-bit-adr = <0x0>;
252 } ;
253 LEDs_8Bit: gpio@81400000 {
254 compatible = "xlnx,xps-gpio-1.00.a";
255 interrupt-parent = <&xps_intc_0>;
256 interrupts = < 7 2 >;
257 reg = < 0x81400000 0x10000 >;
258 xlnx,all-inputs = <0x0>;
259 xlnx,all-inputs-2 = <0x0>;
260 xlnx,dout-default = <0x0>;
261 xlnx,dout-default-2 = <0x0>;
262 xlnx,family = "virtex5";
263 xlnx,gpio-width = <0x8>;
264 xlnx,interrupt-present = <0x1>;
265 xlnx,is-bidir = <0x1>;
266 xlnx,is-bidir-2 = <0x1>;
267 xlnx,is-dual = <0x0>;
268 xlnx,tri-default = <0xffffffff>;
269 xlnx,tri-default-2 = <0xffffffff>;
270 #gpio-cells = <2>;
271 gpio-controller;
272 } ;
273
274 gpio-leds {
275 compatible = "gpio-leds";
276
277 heartbeat {
278 label = "Heartbeat";
279 gpios = <&LEDs_8Bit 4 1>;
280 linux,default-trigger = "heartbeat";
281 };
282
283 yellow {
284 label = "Yellow";
285 gpios = <&LEDs_8Bit 5 1>;
286 };
287
288 red {
289 label = "Red";
290 gpios = <&LEDs_8Bit 6 1>;
291 };
292
293 green {
294 label = "Green";
295 gpios = <&LEDs_8Bit 7 1>;
296 };
297 } ;
298 RS232_Uart_1: serial@84000000 {
299 clock-frequency = <125000000>;
300 compatible = "xlnx,xps-uartlite-1.00.a";
301 current-speed = <115200>;
302 device_type = "serial";
303 interrupt-parent = <&xps_intc_0>;
304 interrupts = < 8 0 >;
305 port-number = <0>;
306 reg = < 0x84000000 0x10000 >;
307 xlnx,baudrate = <0x1c200>;
308 xlnx,data-bits = <0x8>;
309 xlnx,family = "virtex5";
310 xlnx,odd-parity = <0x0>;
311 xlnx,use-parity = <0x0>;
312 } ;
313 SysACE_CompactFlash: sysace@83600000 {
314 compatible = "xlnx,xps-sysace-1.00.a";
315 interrupt-parent = <&xps_intc_0>;
316 interrupts = < 4 2 >;
317 reg = < 0x83600000 0x10000 >;
318 xlnx,family = "virtex5";
319 xlnx,mem-width = <0x10>;
320 } ;
321 debug_module: debug@84400000 {
322 compatible = "xlnx,mdm-1.00.d";
323 reg = < 0x84400000 0x10000 >;
324 xlnx,family = "virtex5";
325 xlnx,interconnect = <0x1>;
326 xlnx,jtag-chain = <0x2>;
327 xlnx,mb-dbg-ports = <0x1>;
328 xlnx,uart-width = <0x8>;
329 xlnx,use-uart = <0x1>;
330 xlnx,write-fsl-ports = <0x0>;
331 } ;
332 mpmc@90000000 {
333 #address-cells = <1>;
334 #size-cells = <1>;
335 compatible = "xlnx,mpmc-4.02.a";
336 ranges ;
337 PIM3: sdma@84600180 {
338 compatible = "xlnx,ll-dma-1.00.a";
339 interrupt-parent = <&xps_intc_0>;
340 interrupts = < 2 2 1 2 >;
341 reg = < 0x84600180 0x80 >;
342 } ;
343 } ;
344 xps_intc_0: interrupt-controller@81800000 {
345 #interrupt-cells = <0x2>;
346 compatible = "xlnx,xps-intc-1.00.a";
347 interrupt-controller ;
348 reg = < 0x81800000 0x10000 >;
349 xlnx,kind-of-intr = <0x100>;
350 xlnx,num-intr-inputs = <0x9>;
351 } ;
352 xps_timer_1: timer@83c00000 {
353 compatible = "xlnx,xps-timer-1.00.a";
354 interrupt-parent = <&xps_intc_0>;
355 interrupts = < 3 2 >;
356 reg = < 0x83c00000 0x10000 >;
357 xlnx,count-width = <0x20>;
358 xlnx,family = "virtex5";
359 xlnx,gen0-assert = <0x1>;
360 xlnx,gen1-assert = <0x1>;
361 xlnx,one-timer-only = <0x0>;
362 xlnx,trig0-assert = <0x1>;
363 xlnx,trig1-assert = <0x1>;
364 } ;
365 } ;
366} ;
diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 3fbb7f1db3bc..1e4c3329f62e 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -15,7 +15,6 @@
15#include <asm/page.h> 15#include <asm/page.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/mm.h> /* Get struct page {...} */ 17#include <linux/mm.h> /* Get struct page {...} */
18#include <asm-generic/iomap.h>
19 18
20#ifndef CONFIG_PCI 19#ifndef CONFIG_PCI
21#define _IO_BASE 0 20#define _IO_BASE 0
@@ -25,211 +24,32 @@
25#define _IO_BASE isa_io_base 24#define _IO_BASE isa_io_base
26#define _ISA_MEM_BASE isa_mem_base 25#define _ISA_MEM_BASE isa_mem_base
27#define PCI_DRAM_OFFSET pci_dram_offset 26#define PCI_DRAM_OFFSET pci_dram_offset
28#endif 27struct pci_dev;
28extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
29#define pci_iounmap pci_iounmap
29 30
30extern unsigned long isa_io_base; 31extern unsigned long isa_io_base;
31extern unsigned long pci_io_base;
32extern unsigned long pci_dram_offset; 32extern unsigned long pci_dram_offset;
33
34extern resource_size_t isa_mem_base; 33extern resource_size_t isa_mem_base;
34#endif
35 35
36#define PCI_IOBASE ((void __iomem *)_IO_BASE)
36#define IO_SPACE_LIMIT (0xFFFFFFFF) 37#define IO_SPACE_LIMIT (0xFFFFFFFF)
37 38
38/* the following is needed to support PCI with some drivers */
39
40#define mmiowb()
41
42static inline unsigned char __raw_readb(const volatile void __iomem *addr)
43{
44 return *(volatile unsigned char __force *)addr;
45}
46static inline unsigned short __raw_readw(const volatile void __iomem *addr)
47{
48 return *(volatile unsigned short __force *)addr;
49}
50static inline unsigned int __raw_readl(const volatile void __iomem *addr)
51{
52 return *(volatile unsigned int __force *)addr;
53}
54static inline unsigned long __raw_readq(const volatile void __iomem *addr)
55{
56 return *(volatile unsigned long __force *)addr;
57}
58static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
59{
60 *(volatile unsigned char __force *)addr = v;
61}
62static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
63{
64 *(volatile unsigned short __force *)addr = v;
65}
66static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
67{
68 *(volatile unsigned int __force *)addr = v;
69}
70static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
71{
72 *(volatile unsigned long __force *)addr = v;
73}
74
75/*
76 * read (readb, readw, readl, readq) and write (writeb, writew,
77 * writel, writeq) accessors are for PCI and thus little endian.
78 * Linux 2.4 for Microblaze had this wrong.
79 */
80static inline unsigned char readb(const volatile void __iomem *addr)
81{
82 return *(volatile unsigned char __force *)addr;
83}
84static inline unsigned short readw(const volatile void __iomem *addr)
85{
86 return le16_to_cpu(*(volatile unsigned short __force *)addr);
87}
88static inline unsigned int readl(const volatile void __iomem *addr)
89{
90 return le32_to_cpu(*(volatile unsigned int __force *)addr);
91}
92#define readq readq
93static inline u64 readq(const volatile void __iomem *addr)
94{
95 return le64_to_cpu(__raw_readq(addr));
96}
97static inline void writeb(unsigned char v, volatile void __iomem *addr)
98{
99 *(volatile unsigned char __force *)addr = v;
100}
101static inline void writew(unsigned short v, volatile void __iomem *addr)
102{
103 *(volatile unsigned short __force *)addr = cpu_to_le16(v);
104}
105static inline void writel(unsigned int v, volatile void __iomem *addr)
106{
107 *(volatile unsigned int __force *)addr = cpu_to_le32(v);
108}
109#define writeq(b, addr) __raw_writeq(cpu_to_le64(b), addr)
110
111/* ioread and iowrite variants. thease are for now same as __raw_
112 * variants of accessors. we might check for endianess in the feature
113 */
114#define ioread8(addr) __raw_readb((u8 *)(addr))
115#define ioread16(addr) __raw_readw((u16 *)(addr))
116#define ioread32(addr) __raw_readl((u32 *)(addr))
117#define iowrite8(v, addr) __raw_writeb((u8)(v), (u8 *)(addr))
118#define iowrite16(v, addr) __raw_writew((u16)(v), (u16 *)(addr))
119#define iowrite32(v, addr) __raw_writel((u32)(v), (u32 *)(addr))
120
121#define ioread16be(addr) __raw_readw((u16 *)(addr))
122#define ioread32be(addr) __raw_readl((u32 *)(addr))
123#define iowrite16be(v, addr) __raw_writew((u16)(v), (u16 *)(addr))
124#define iowrite32be(v, addr) __raw_writel((u32)(v), (u32 *)(addr))
125
126/* These are the definitions for the x86 IO instructions
127 * inb/inw/inl/outb/outw/outl, the "string" versions
128 * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions
129 * inb_p/inw_p/...
130 * The macros don't do byte-swapping.
131 */
132#define inb(port) readb((u8 *)((unsigned long)(port)))
133#define outb(val, port) writeb((val), (u8 *)((unsigned long)(port)))
134#define inw(port) readw((u16 *)((unsigned long)(port)))
135#define outw(val, port) writew((val), (u16 *)((unsigned long)(port)))
136#define inl(port) readl((u32 *)((unsigned long)(port)))
137#define outl(val, port) writel((val), (u32 *)((unsigned long)(port)))
138
139#define inb_p(port) inb((port))
140#define outb_p(val, port) outb((val), (port))
141#define inw_p(port) inw((port))
142#define outw_p(val, port) outw((val), (port))
143#define inl_p(port) inl((port))
144#define outl_p(val, port) outl((val), (port))
145
146#define memset_io(a, b, c) memset((void *)(a), (b), (c))
147#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
148#define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
149
150#ifdef CONFIG_MMU 39#ifdef CONFIG_MMU
151
152#define phys_to_virt(addr) ((void *)__phys_to_virt(addr))
153#define virt_to_phys(addr) ((unsigned long)__virt_to_phys(addr))
154#define virt_to_bus(addr) ((unsigned long)__virt_to_phys(addr))
155
156#define page_to_bus(page) (page_to_phys(page)) 40#define page_to_bus(page) (page_to_phys(page))
157#define bus_to_virt(addr) (phys_to_virt(addr))
158 41
159extern void iounmap(void __iomem *addr); 42extern void iounmap(void __iomem *addr);
160/*extern void *__ioremap(phys_addr_t address, unsigned long size,
161 unsigned long flags);*/
162extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
163#define ioremap_writethrough(addr, size) ioremap((addr), (size))
164#define ioremap_nocache(addr, size) ioremap((addr), (size))
165#define ioremap_fullcache(addr, size) ioremap((addr), (size))
166
167#else /* CONFIG_MMU */
168
169/**
170 * virt_to_phys - map virtual addresses to physical
171 * @address: address to remap
172 *
173 * The returned physical address is the physical (CPU) mapping for
174 * the memory address given. It is only valid to use this function on
175 * addresses directly mapped or allocated via kmalloc.
176 *
177 * This function does not give bus mappings for DMA transfers. In
178 * almost all conceivable cases a device driver should not be using
179 * this function
180 */
181static inline unsigned long __iomem virt_to_phys(volatile void *address)
182{
183 return __pa((unsigned long)address);
184}
185
186#define virt_to_bus virt_to_phys
187
188/**
189 * phys_to_virt - map physical address to virtual
190 * @address: address to remap
191 *
192 * The returned virtual address is a current CPU mapping for
193 * the memory address given. It is only valid to use this function on
194 * addresses that have a kernel mapping
195 *
196 * This function does not handle bus mappings for DMA transfers. In
197 * almost all conceivable cases a device driver should not be using
198 * this function
199 */
200static inline void *phys_to_virt(unsigned long address)
201{
202 return (void *)__va(address);
203}
204 43
205#define bus_to_virt(a) phys_to_virt(a) 44extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
206 45#define ioremap_writethrough(addr, size) ioremap((addr), (size))
207static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size, 46#define ioremap_nocache(addr, size) ioremap((addr), (size))
208 unsigned long flags) 47#define ioremap_fullcache(addr, size) ioremap((addr), (size))
209{ 48#define ioremap_wc(addr, size) ioremap((addr), (size))
210 return (void *)address;
211}
212
213#define ioremap(physaddr, size) ((void __iomem *)(unsigned long)(physaddr))
214#define iounmap(addr) ((void)0)
215#define ioremap_nocache(physaddr, size) ioremap(physaddr, size)
216 49
217#endif /* CONFIG_MMU */ 50#endif /* CONFIG_MMU */
218 51
219/* 52/* Big Endian */
220 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
221 * access
222 */
223#define xlate_dev_mem_ptr(p) __va(p)
224
225/*
226 * Convert a virtual cached pointer to an uncached pointer
227 */
228#define xlate_dev_kmem_ptr(p) p
229
230/*
231 * Big Endian
232 */
233#define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a)) 53#define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a))
234#define out_be16(a, v) __raw_writew((v), (a)) 54#define out_be16(a, v) __raw_writew((v), (a))
235 55
@@ -239,10 +59,7 @@ static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size,
239#define writel_be(v, a) out_be32((__force unsigned *)a, v) 59#define writel_be(v, a) out_be32((__force unsigned *)a, v)
240#define readl_be(a) in_be32((__force unsigned *)a) 60#define readl_be(a) in_be32((__force unsigned *)a)
241 61
242/* 62/* Little endian */
243 * Little endian
244 */
245
246#define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a)) 63#define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a))
247#define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a)) 64#define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a))
248 65
@@ -253,100 +70,7 @@ static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size,
253#define out_8(a, v) __raw_writeb((v), (a)) 70#define out_8(a, v) __raw_writeb((v), (a))
254#define in_8(a) __raw_readb(a) 71#define in_8(a) __raw_readb(a)
255 72
256#define mmiowb() 73#include <asm-generic/io.h>
257
258#define ioport_map(port, nr) ((void __iomem *)(port))
259#define ioport_unmap(addr)
260
261/* from asm-generic/io.h */
262#ifndef insb
263static inline void insb(unsigned long addr, void *buffer, int count)
264{
265 if (count) {
266 u8 *buf = buffer;
267 do {
268 u8 x = inb(addr);
269 *buf++ = x;
270 } while (--count);
271 }
272}
273#endif
274
275#ifndef insw
276static inline void insw(unsigned long addr, void *buffer, int count)
277{
278 if (count) {
279 u16 *buf = buffer;
280 do {
281 u16 x = inw(addr);
282 *buf++ = x;
283 } while (--count);
284 }
285}
286#endif
287
288#ifndef insl
289static inline void insl(unsigned long addr, void *buffer, int count)
290{
291 if (count) {
292 u32 *buf = buffer;
293 do {
294 u32 x = inl(addr);
295 *buf++ = x;
296 } while (--count);
297 }
298}
299#endif
300
301#ifndef outsb
302static inline void outsb(unsigned long addr, const void *buffer, int count)
303{
304 if (count) {
305 const u8 *buf = buffer;
306 do {
307 outb(*buf++, addr);
308 } while (--count);
309 }
310}
311#endif
312
313#ifndef outsw
314static inline void outsw(unsigned long addr, const void *buffer, int count)
315{
316 if (count) {
317 const u16 *buf = buffer;
318 do {
319 outw(*buf++, addr);
320 } while (--count);
321 }
322}
323#endif
324
325#ifndef outsl
326static inline void outsl(unsigned long addr, const void *buffer, int count)
327{
328 if (count) {
329 const u32 *buf = buffer;
330 do {
331 outl(*buf++, addr);
332 } while (--count);
333 }
334}
335#endif
336
337#define ioread8_rep(p, dst, count) \
338 insb((unsigned long) (p), (dst), (count))
339#define ioread16_rep(p, dst, count) \
340 insw((unsigned long) (p), (dst), (count))
341#define ioread32_rep(p, dst, count) \
342 insl((unsigned long) (p), (dst), (count))
343
344#define iowrite8_rep(p, src, count) \
345 outsb((unsigned long) (p), (src), (count))
346#define iowrite16_rep(p, src, count) \
347 outsw((unsigned long) (p), (src), (count))
348#define iowrite32_rep(p, src, count) \
349 outsl((unsigned long) (p), (src), (count))
350 74
351#define readb_relaxed readb 75#define readb_relaxed readb
352#define readw_relaxed readw 76#define readw_relaxed readw
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
index d6e0ffea28b6..9d31b057c355 100644
--- a/arch/microblaze/include/asm/processor.h
+++ b/arch/microblaze/include/asm/processor.h
@@ -122,7 +122,7 @@ struct thread_struct {
122} 122}
123 123
124/* Free all resources held by a thread. */ 124/* Free all resources held by a thread. */
125extern inline void release_thread(struct task_struct *dead_task) 125static inline void release_thread(struct task_struct *dead_task)
126{ 126{
127} 127}
128 128
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index f05df5630c84..be84a4d3917f 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -19,14 +19,12 @@ extern char cmd_line[COMMAND_LINE_SIZE];
19 19
20extern char *klimit; 20extern char *klimit;
21 21
22void early_printk(const char *fmt, ...);
23
24int setup_early_printk(char *opt); 22int setup_early_printk(char *opt);
25void remap_early_printk(void); 23void remap_early_printk(void);
26void disable_early_printk(void); 24void disable_early_printk(void);
27 25
28void heartbeat(void); 26void microblaze_heartbeat(void);
29void setup_heartbeat(void); 27void microblaze_setup_heartbeat(void);
30 28
31# ifdef CONFIG_MMU 29# ifdef CONFIG_MMU
32extern void mmu_reset(void); 30extern void mmu_reset(void);
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
index 20043b67d158..8d0791b49b31 100644
--- a/arch/microblaze/include/uapi/asm/unistd.h
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -93,7 +93,7 @@
93#define __NR_settimeofday 79 /* ok */ 93#define __NR_settimeofday 79 /* ok */
94#define __NR_getgroups 80 /* ok */ 94#define __NR_getgroups 80 /* ok */
95#define __NR_setgroups 81 /* ok */ 95#define __NR_setgroups 81 /* ok */
96#define __NR_select 82 /* obsolete -> sys_pselect7 */ 96#define __NR_select 82 /* obsolete -> sys_pselect6 */
97#define __NR_symlink 83 /* symlinkat */ 97#define __NR_symlink 83 /* symlinkat */
98#define __NR_oldlstat 84 /* remove */ 98#define __NR_oldlstat 84 /* remove */
99#define __NR_readlink 85 /* obsolete -> sys_readlinkat */ 99#define __NR_readlink 85 /* obsolete -> sys_readlinkat */
@@ -320,7 +320,7 @@
320#define __NR_readlinkat 305 /* ok */ 320#define __NR_readlinkat 305 /* ok */
321#define __NR_fchmodat 306 /* ok */ 321#define __NR_fchmodat 306 /* ok */
322#define __NR_faccessat 307 /* ok */ 322#define __NR_faccessat 307 /* ok */
323#define __NR_pselect6 308 /* obsolete -> sys_pselect7 */ 323#define __NR_pselect6 308 /* ok */
324#define __NR_ppoll 309 /* ok */ 324#define __NR_ppoll 309 /* ok */
325#define __NR_unshare 310 /* ok */ 325#define __NR_unshare 310 /* ok */
326#define __NR_set_robust_list 311 /* ok */ 326#define __NR_set_robust_list 311 /* ok */
@@ -396,5 +396,7 @@
396#define __NR_process_vm_writev 378 396#define __NR_process_vm_writev 378
397#define __NR_kcmp 379 397#define __NR_kcmp 379
398#define __NR_finit_module 380 398#define __NR_finit_module 380
399#define __NR_sched_setattr 381
400#define __NR_sched_getattr 382
399 401
400#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */ 402#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
index 5b0e512c78e5..08d50cc55e7d 100644
--- a/arch/microblaze/kernel/Makefile
+++ b/arch/microblaze/kernel/Makefile
@@ -16,7 +16,7 @@ extra-y := head.o vmlinux.lds
16 16
17obj-y += dma.o exceptions.o \ 17obj-y += dma.o exceptions.o \
18 hw_exception_handler.o intc.o irq.o \ 18 hw_exception_handler.o intc.o irq.o \
19 process.o prom.o prom_parse.o ptrace.o \ 19 platform.o process.o prom.o prom_parse.o ptrace.o \
20 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o 20 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
21 21
22obj-y += cpu/ 22obj-y += cpu/
diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
index 1879a0527776..4643e3ab9414 100644
--- a/arch/microblaze/kernel/heartbeat.c
+++ b/arch/microblaze/kernel/heartbeat.c
@@ -17,7 +17,7 @@
17 17
18static unsigned int base_addr; 18static unsigned int base_addr;
19 19
20void heartbeat(void) 20void microblaze_heartbeat(void)
21{ 21{
22 static unsigned int cnt, period, dist; 22 static unsigned int cnt, period, dist;
23 23
@@ -42,7 +42,7 @@ void heartbeat(void)
42 } 42 }
43} 43}
44 44
45void setup_heartbeat(void) 45void microblaze_setup_heartbeat(void)
46{ 46{
47 struct device_node *gpio = NULL; 47 struct device_node *gpio = NULL;
48 int *prop; 48 int *prop;
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index 581451ad4687..15c7c12ea0e7 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -32,6 +32,29 @@ static void __iomem *intc_baseaddr;
32#define MER_ME (1<<0) 32#define MER_ME (1<<0)
33#define MER_HIE (1<<1) 33#define MER_HIE (1<<1)
34 34
35static unsigned int (*read_fn)(void __iomem *);
36static void (*write_fn)(u32, void __iomem *);
37
38static void intc_write32(u32 val, void __iomem *addr)
39{
40 iowrite32(val, addr);
41}
42
43static unsigned int intc_read32(void __iomem *addr)
44{
45 return ioread32(addr);
46}
47
48static void intc_write32_be(u32 val, void __iomem *addr)
49{
50 iowrite32be(val, addr);
51}
52
53static unsigned int intc_read32_be(void __iomem *addr)
54{
55 return ioread32be(addr);
56}
57
35static void intc_enable_or_unmask(struct irq_data *d) 58static void intc_enable_or_unmask(struct irq_data *d)
36{ 59{
37 unsigned long mask = 1 << d->hwirq; 60 unsigned long mask = 1 << d->hwirq;
@@ -43,21 +66,21 @@ static void intc_enable_or_unmask(struct irq_data *d)
43 * acks the irq before calling the interrupt handler 66 * acks the irq before calling the interrupt handler
44 */ 67 */
45 if (irqd_is_level_type(d)) 68 if (irqd_is_level_type(d))
46 out_be32(intc_baseaddr + IAR, mask); 69 write_fn(mask, intc_baseaddr + IAR);
47 70
48 out_be32(intc_baseaddr + SIE, mask); 71 write_fn(mask, intc_baseaddr + SIE);
49} 72}
50 73
51static void intc_disable_or_mask(struct irq_data *d) 74static void intc_disable_or_mask(struct irq_data *d)
52{ 75{
53 pr_debug("disable: %ld\n", d->hwirq); 76 pr_debug("disable: %ld\n", d->hwirq);
54 out_be32(intc_baseaddr + CIE, 1 << d->hwirq); 77 write_fn(1 << d->hwirq, intc_baseaddr + CIE);
55} 78}
56 79
57static void intc_ack(struct irq_data *d) 80static void intc_ack(struct irq_data *d)
58{ 81{
59 pr_debug("ack: %ld\n", d->hwirq); 82 pr_debug("ack: %ld\n", d->hwirq);
60 out_be32(intc_baseaddr + IAR, 1 << d->hwirq); 83 write_fn(1 << d->hwirq, intc_baseaddr + IAR);
61} 84}
62 85
63static void intc_mask_ack(struct irq_data *d) 86static void intc_mask_ack(struct irq_data *d)
@@ -65,8 +88,8 @@ static void intc_mask_ack(struct irq_data *d)
65 unsigned long mask = 1 << d->hwirq; 88 unsigned long mask = 1 << d->hwirq;
66 89
67 pr_debug("disable_and_ack: %ld\n", d->hwirq); 90 pr_debug("disable_and_ack: %ld\n", d->hwirq);
68 out_be32(intc_baseaddr + CIE, mask); 91 write_fn(mask, intc_baseaddr + CIE);
69 out_be32(intc_baseaddr + IAR, mask); 92 write_fn(mask, intc_baseaddr + IAR);
70} 93}
71 94
72static struct irq_chip intc_dev = { 95static struct irq_chip intc_dev = {
@@ -83,7 +106,7 @@ unsigned int get_irq(void)
83{ 106{
84 unsigned int hwirq, irq = -1; 107 unsigned int hwirq, irq = -1;
85 108
86 hwirq = in_be32(intc_baseaddr + IVR); 109 hwirq = read_fn(intc_baseaddr + IVR);
87 if (hwirq != -1U) 110 if (hwirq != -1U)
88 irq = irq_find_mapping(root_domain, hwirq); 111 irq = irq_find_mapping(root_domain, hwirq);
89 112
@@ -140,17 +163,25 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
140 pr_info("%s: num_irq=%d, edge=0x%x\n", 163 pr_info("%s: num_irq=%d, edge=0x%x\n",
141 intc->full_name, nr_irq, intr_mask); 164 intc->full_name, nr_irq, intr_mask);
142 165
166 write_fn = intc_write32;
167 read_fn = intc_read32;
168
143 /* 169 /*
144 * Disable all external interrupts until they are 170 * Disable all external interrupts until they are
145 * explicity requested. 171 * explicity requested.
146 */ 172 */
147 out_be32(intc_baseaddr + IER, 0); 173 write_fn(0, intc_baseaddr + IER);
148 174
149 /* Acknowledge any pending interrupts just in case. */ 175 /* Acknowledge any pending interrupts just in case. */
150 out_be32(intc_baseaddr + IAR, 0xffffffff); 176 write_fn(0xffffffff, intc_baseaddr + IAR);
151 177
152 /* Turn on the Master Enable. */ 178 /* Turn on the Master Enable. */
153 out_be32(intc_baseaddr + MER, MER_HIE | MER_ME); 179 write_fn(MER_HIE | MER_ME, intc_baseaddr + MER);
180 if (!(read_fn(intc_baseaddr + MER) & (MER_HIE | MER_ME))) {
181 write_fn = intc_write32_be;
182 read_fn = intc_read32_be;
183 write_fn(MER_HIE | MER_ME, intc_baseaddr + MER);
184 }
154 185
155 /* Yeah, okay, casting the intr_mask to a void* is butt-ugly, but I'm 186 /* Yeah, okay, casting the intr_mask to a void* is butt-ugly, but I'm
156 * lazy and Michal can clean it up to something nicer when he tests 187 * lazy and Michal can clean it up to something nicer when he tests
diff --git a/arch/microblaze/platform/platform.c b/arch/microblaze/kernel/platform.c
index b9529caa507a..b9529caa507a 100644
--- a/arch/microblaze/platform/platform.c
+++ b/arch/microblaze/kernel/platform.c
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 7d1a9c8b1f3d..b2dd37196b3b 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -8,6 +8,7 @@
8 * for more details. 8 * for more details.
9 */ 9 */
10 10
11#include <linux/cpu.h>
11#include <linux/export.h> 12#include <linux/export.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
13#include <linux/pm.h> 14#include <linux/pm.h>
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index d26d7e7a6913..49a07a4d76d0 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -216,7 +216,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
216 /* MS: I need add offset in page */ 216 /* MS: I need add offset in page */
217 address += ((unsigned long)frame->tramp) & ~PAGE_MASK; 217 address += ((unsigned long)frame->tramp) & ~PAGE_MASK;
218 /* MS address is virtual */ 218 /* MS address is virtual */
219 address = virt_to_phys(address); 219 address = __virt_to_phys(address);
220 invalidate_icache_range(address, address + 8); 220 invalidate_icache_range(address, address + 8);
221 flush_dcache_range(address, address + 8); 221 flush_dcache_range(address, address + 8);
222 } 222 }
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index b882ad50535b..329dfbad810b 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -308,7 +308,7 @@ ENTRY(sys_call_table)
308 .long sys_readlinkat /* 305 */ 308 .long sys_readlinkat /* 305 */
309 .long sys_fchmodat 309 .long sys_fchmodat
310 .long sys_faccessat 310 .long sys_faccessat
311 .long sys_ni_syscall /* pselect6 */ 311 .long sys_pselect6
312 .long sys_ppoll 312 .long sys_ppoll
313 .long sys_unshare /* 310 */ 313 .long sys_unshare /* 310 */
314 .long sys_set_robust_list 314 .long sys_set_robust_list
@@ -363,8 +363,8 @@ ENTRY(sys_call_table)
363 .long sys_sendmsg /* 360 */ 363 .long sys_sendmsg /* 360 */
364 .long sys_recvmsg 364 .long sys_recvmsg
365 .long sys_accept4 365 .long sys_accept4
366 .long sys_ni_syscall 366 .long sys_preadv
367 .long sys_ni_syscall 367 .long sys_pwritev
368 .long sys_rt_tgsigqueueinfo /* 365 */ 368 .long sys_rt_tgsigqueueinfo /* 365 */
369 .long sys_perf_event_open 369 .long sys_perf_event_open
370 .long sys_recvmmsg 370 .long sys_recvmmsg
@@ -381,3 +381,5 @@ ENTRY(sys_call_table)
381 .long sys_process_vm_writev 381 .long sys_process_vm_writev
382 .long sys_kcmp 382 .long sys_kcmp
383 .long sys_finit_module 383 .long sys_finit_module
384 .long sys_sched_setattr
385 .long sys_sched_getattr
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index fb0c61443f19..dd96f0e4bfa2 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -43,10 +43,33 @@ static unsigned int timer_clock_freq;
43#define TCSR_PWMA (1<<9) 43#define TCSR_PWMA (1<<9)
44#define TCSR_ENALL (1<<10) 44#define TCSR_ENALL (1<<10)
45 45
46static unsigned int (*read_fn)(void __iomem *);
47static void (*write_fn)(u32, void __iomem *);
48
49static void timer_write32(u32 val, void __iomem *addr)
50{
51 iowrite32(val, addr);
52}
53
54static unsigned int timer_read32(void __iomem *addr)
55{
56 return ioread32(addr);
57}
58
59static void timer_write32_be(u32 val, void __iomem *addr)
60{
61 iowrite32be(val, addr);
62}
63
64static unsigned int timer_read32_be(void __iomem *addr)
65{
66 return ioread32be(addr);
67}
68
46static inline void xilinx_timer0_stop(void) 69static inline void xilinx_timer0_stop(void)
47{ 70{
48 out_be32(timer_baseaddr + TCSR0, 71 write_fn(read_fn(timer_baseaddr + TCSR0) & ~TCSR_ENT,
49 in_be32(timer_baseaddr + TCSR0) & ~TCSR_ENT); 72 timer_baseaddr + TCSR0);
50} 73}
51 74
52static inline void xilinx_timer0_start_periodic(unsigned long load_val) 75static inline void xilinx_timer0_start_periodic(unsigned long load_val)
@@ -54,10 +77,10 @@ static inline void xilinx_timer0_start_periodic(unsigned long load_val)
54 if (!load_val) 77 if (!load_val)
55 load_val = 1; 78 load_val = 1;
56 /* loading value to timer reg */ 79 /* loading value to timer reg */
57 out_be32(timer_baseaddr + TLR0, load_val); 80 write_fn(load_val, timer_baseaddr + TLR0);
58 81
59 /* load the initial value */ 82 /* load the initial value */
60 out_be32(timer_baseaddr + TCSR0, TCSR_LOAD); 83 write_fn(TCSR_LOAD, timer_baseaddr + TCSR0);
61 84
62 /* see timer data sheet for detail 85 /* see timer data sheet for detail
63 * !ENALL - don't enable 'em all 86 * !ENALL - don't enable 'em all
@@ -72,8 +95,8 @@ static inline void xilinx_timer0_start_periodic(unsigned long load_val)
72 * UDT - set the timer as down counter 95 * UDT - set the timer as down counter
73 * !MDT0 - generate mode 96 * !MDT0 - generate mode
74 */ 97 */
75 out_be32(timer_baseaddr + TCSR0, 98 write_fn(TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT,
76 TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT); 99 timer_baseaddr + TCSR0);
77} 100}
78 101
79static inline void xilinx_timer0_start_oneshot(unsigned long load_val) 102static inline void xilinx_timer0_start_oneshot(unsigned long load_val)
@@ -81,13 +104,13 @@ static inline void xilinx_timer0_start_oneshot(unsigned long load_val)
81 if (!load_val) 104 if (!load_val)
82 load_val = 1; 105 load_val = 1;
83 /* loading value to timer reg */ 106 /* loading value to timer reg */
84 out_be32(timer_baseaddr + TLR0, load_val); 107 write_fn(load_val, timer_baseaddr + TLR0);
85 108
86 /* load the initial value */ 109 /* load the initial value */
87 out_be32(timer_baseaddr + TCSR0, TCSR_LOAD); 110 write_fn(TCSR_LOAD, timer_baseaddr + TCSR0);
88 111
89 out_be32(timer_baseaddr + TCSR0, 112 write_fn(TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT,
90 TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT); 113 timer_baseaddr + TCSR0);
91} 114}
92 115
93static int xilinx_timer_set_next_event(unsigned long delta, 116static int xilinx_timer_set_next_event(unsigned long delta,
@@ -133,14 +156,14 @@ static struct clock_event_device clockevent_xilinx_timer = {
133 156
134static inline void timer_ack(void) 157static inline void timer_ack(void)
135{ 158{
136 out_be32(timer_baseaddr + TCSR0, in_be32(timer_baseaddr + TCSR0)); 159 write_fn(read_fn(timer_baseaddr + TCSR0), timer_baseaddr + TCSR0);
137} 160}
138 161
139static irqreturn_t timer_interrupt(int irq, void *dev_id) 162static irqreturn_t timer_interrupt(int irq, void *dev_id)
140{ 163{
141 struct clock_event_device *evt = &clockevent_xilinx_timer; 164 struct clock_event_device *evt = &clockevent_xilinx_timer;
142#ifdef CONFIG_HEART_BEAT 165#ifdef CONFIG_HEART_BEAT
143 heartbeat(); 166 microblaze_heartbeat();
144#endif 167#endif
145 timer_ack(); 168 timer_ack();
146 evt->event_handler(evt); 169 evt->event_handler(evt);
@@ -169,7 +192,7 @@ static __init void xilinx_clockevent_init(void)
169 192
170static u64 xilinx_clock_read(void) 193static u64 xilinx_clock_read(void)
171{ 194{
172 return in_be32(timer_baseaddr + TCR1); 195 return read_fn(timer_baseaddr + TCR1);
173} 196}
174 197
175static cycle_t xilinx_read(struct clocksource *cs) 198static cycle_t xilinx_read(struct clocksource *cs)
@@ -217,10 +240,10 @@ static int __init xilinx_clocksource_init(void)
217 panic("failed to register clocksource"); 240 panic("failed to register clocksource");
218 241
219 /* stop timer1 */ 242 /* stop timer1 */
220 out_be32(timer_baseaddr + TCSR1, 243 write_fn(read_fn(timer_baseaddr + TCSR1) & ~TCSR_ENT,
221 in_be32(timer_baseaddr + TCSR1) & ~TCSR_ENT); 244 timer_baseaddr + TCSR1);
222 /* start timer1 - up counting without interrupt */ 245 /* start timer1 - up counting without interrupt */
223 out_be32(timer_baseaddr + TCSR1, TCSR_TINT|TCSR_ENT|TCSR_ARHT); 246 write_fn(TCSR_TINT|TCSR_ENT|TCSR_ARHT, timer_baseaddr + TCSR1);
224 247
225 /* register timecounter - for ftrace support */ 248 /* register timecounter - for ftrace support */
226 init_xilinx_timecounter(); 249 init_xilinx_timecounter();
@@ -245,6 +268,15 @@ static void __init xilinx_timer_init(struct device_node *timer)
245 BUG(); 268 BUG();
246 } 269 }
247 270
271 write_fn = timer_write32;
272 read_fn = timer_read32;
273
274 write_fn(TCSR_MDT, timer_baseaddr + TCSR0);
275 if (!(read_fn(timer_baseaddr + TCSR0) & TCSR_MDT)) {
276 write_fn = timer_write32_be;
277 read_fn = timer_read32_be;
278 }
279
248 irq = irq_of_parse_and_map(timer, 0); 280 irq = irq_of_parse_and_map(timer, 0);
249 281
250 of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); 282 of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num);
@@ -274,7 +306,7 @@ static void __init xilinx_timer_init(struct device_node *timer)
274 306
275 setup_irq(irq, &timer_irqaction); 307 setup_irq(irq, &timer_irqaction);
276#ifdef CONFIG_HEART_BEAT 308#ifdef CONFIG_HEART_BEAT
277 setup_heartbeat(); 309 microblaze_setup_heartbeat();
278#endif 310#endif
279 xilinx_clocksource_init(); 311 xilinx_clocksource_init();
280 xilinx_clockevent_init(); 312 xilinx_clockevent_init();
diff --git a/arch/microblaze/mm/consistent.c b/arch/microblaze/mm/consistent.c
index dbbf2246a260..e10ad930895e 100644
--- a/arch/microblaze/mm/consistent.c
+++ b/arch/microblaze/mm/consistent.c
@@ -117,7 +117,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
117 ret = (void *)va; 117 ret = (void *)va;
118 118
119 /* This gives us the real physical address of the first page. */ 119 /* This gives us the real physical address of the first page. */
120 *dma_handle = pa = virt_to_bus((void *)vaddr); 120 *dma_handle = pa = __virt_to_phys(vaddr);
121#endif 121#endif
122 122
123 /* 123 /*
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 89077d346714..77bc7c7e6522 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -369,7 +369,7 @@ asmlinkage void __init mmu_init(void)
369 if (initrd_start) { 369 if (initrd_start) {
370 unsigned long size; 370 unsigned long size;
371 size = initrd_end - initrd_start; 371 size = initrd_end - initrd_start;
372 memblock_reserve(virt_to_phys(initrd_start), size); 372 memblock_reserve(__virt_to_phys(initrd_start), size);
373 } 373 }
374#endif /* CONFIG_BLK_DEV_INITRD */ 374#endif /* CONFIG_BLK_DEV_INITRD */
375 375
diff --git a/arch/microblaze/mm/pgtable.c b/arch/microblaze/mm/pgtable.c
index 10b3bd0a980d..4f4520e779a5 100644
--- a/arch/microblaze/mm/pgtable.c
+++ b/arch/microblaze/mm/pgtable.c
@@ -69,10 +69,11 @@ static void __iomem *__ioremap(phys_addr_t addr, unsigned long size,
69 * 69 *
70 * However, allow remap of rootfs: TBD 70 * However, allow remap of rootfs: TBD
71 */ 71 */
72
72 if (mem_init_done && 73 if (mem_init_done &&
73 p >= memory_start && p < virt_to_phys(high_memory) && 74 p >= memory_start && p < virt_to_phys(high_memory) &&
74 !(p >= virt_to_phys((unsigned long)&__bss_stop) && 75 !(p >= __virt_to_phys((phys_addr_t)__bss_stop) &&
75 p < virt_to_phys((unsigned long)__bss_stop))) { 76 p < __virt_to_phys((phys_addr_t)__bss_stop))) {
76 pr_warn("__ioremap(): phys addr "PTE_FMT" is RAM lr %pf\n", 77 pr_warn("__ioremap(): phys addr "PTE_FMT" is RAM lr %pf\n",
77 (unsigned long)p, __builtin_return_address(0)); 78 (unsigned long)p, __builtin_return_address(0));
78 return NULL; 79 return NULL;
diff --git a/arch/microblaze/platform/Makefile b/arch/microblaze/platform/Makefile
deleted file mode 100644
index ea1b75cc5775..000000000000
--- a/arch/microblaze/platform/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for arch/microblaze/platform directory
3#
4#obj-$(CONFIG_PLATFORM_GENERIC) += generic/
5
6obj-y += platform.o
diff --git a/arch/microblaze/platform/generic/Kconfig.auto b/arch/microblaze/platform/generic/Kconfig.auto
deleted file mode 100644
index 25a6f019e94d..000000000000
--- a/arch/microblaze/platform/generic/Kconfig.auto
+++ /dev/null
@@ -1,61 +0,0 @@
1#
2# (C) Copyright 2007 Michal Simek
3#
4# Michal SIMEK <monstr@monstr.eu>
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 as
8# published by the Free Software Foundation; either version 2 of
9# the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19# MA 02111-1307 USA
20#
21
22# Definitions for MICROBLAZE0
23comment "Definitions for MICROBLAZE0"
24
25config KERNEL_BASE_ADDR
26 hex "Physical address where Linux Kernel is"
27 default "0x90000000"
28 help
29 BASE Address for kernel
30
31config XILINX_MICROBLAZE0_FAMILY
32 string "Targeted FPGA family"
33 default "virtex5"
34
35config XILINX_MICROBLAZE0_USE_MSR_INSTR
36 int "USE_MSR_INSTR range (0:1)"
37 default 0
38
39config XILINX_MICROBLAZE0_USE_PCMP_INSTR
40 int "USE_PCMP_INSTR range (0:1)"
41 default 0
42
43config XILINX_MICROBLAZE0_USE_BARREL
44 int "USE_BARREL range (0:1)"
45 default 0
46
47config XILINX_MICROBLAZE0_USE_DIV
48 int "USE_DIV range (0:1)"
49 default 0
50
51config XILINX_MICROBLAZE0_USE_HW_MUL
52 int "USE_HW_MUL values (0=NONE, 1=MUL32, 2=MUL64)"
53 default 0
54
55config XILINX_MICROBLAZE0_USE_FPU
56 int "USE_FPU values (0=NONE, 1=BASIC, 2=EXTENDED)"
57 default 0
58
59config XILINX_MICROBLAZE0_HW_VER
60 string "Core version number"
61 default 7.10.d
diff --git a/arch/microblaze/platform/generic/Makefile b/arch/microblaze/platform/generic/Makefile
deleted file mode 100644
index 9a8b1bd3fa6d..000000000000
--- a/arch/microblaze/platform/generic/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1#
2# Empty Makefile to keep make clean happy
3#
diff --git a/arch/microblaze/platform/generic/system.dts b/arch/microblaze/platform/generic/system.dts
deleted file mode 100644
index b620da23febb..000000000000
--- a/arch/microblaze/platform/generic/system.dts
+++ /dev/null
@@ -1,366 +0,0 @@
1/*
2 * Device Tree Generator version: 1.1
3 *
4 * (C) Copyright 2007-2008 Xilinx, Inc.
5 * (C) Copyright 2007-2009 Michal Simek
6 *
7 * Michal SIMEK <monstr@monstr.eu>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) 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., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 *
24 * CAUTION: This file is automatically generated by libgen.
25 * Version: Xilinx EDK 10.1.03 EDK_K_SP3.6
26 *
27 * XPS project directory: Xilinx-ML505-ll_temac-sgdma-MMU-FDT-edk101
28 */
29
30/dts-v1/;
31/ {
32 #address-cells = <1>;
33 #size-cells = <1>;
34 compatible = "xlnx,microblaze";
35 hard-reset-gpios = <&LEDs_8Bit 2 1>;
36 model = "testing";
37 DDR2_SDRAM: memory@90000000 {
38 device_type = "memory";
39 reg = < 0x90000000 0x10000000 >;
40 } ;
41 aliases {
42 ethernet0 = &Hard_Ethernet_MAC;
43 serial0 = &RS232_Uart_1;
44 } ;
45 chosen {
46 bootargs = "console=ttyUL0,115200 highres=on";
47 linux,stdout-path = "/plb@0/serial@84000000";
48 } ;
49 cpus {
50 #address-cells = <1>;
51 #cpus = <0x1>;
52 #size-cells = <0>;
53 microblaze_0: cpu@0 {
54 clock-frequency = <125000000>;
55 compatible = "xlnx,microblaze-7.10.d";
56 d-cache-baseaddr = <0x90000000>;
57 d-cache-highaddr = <0x9fffffff>;
58 d-cache-line-size = <0x10>;
59 d-cache-size = <0x2000>;
60 device_type = "cpu";
61 i-cache-baseaddr = <0x90000000>;
62 i-cache-highaddr = <0x9fffffff>;
63 i-cache-line-size = <0x10>;
64 i-cache-size = <0x2000>;
65 model = "microblaze,7.10.d";
66 reg = <0>;
67 timebase-frequency = <125000000>;
68 xlnx,addr-tag-bits = <0xf>;
69 xlnx,allow-dcache-wr = <0x1>;
70 xlnx,allow-icache-wr = <0x1>;
71 xlnx,area-optimized = <0x0>;
72 xlnx,cache-byte-size = <0x2000>;
73 xlnx,d-lmb = <0x1>;
74 xlnx,d-opb = <0x0>;
75 xlnx,d-plb = <0x1>;
76 xlnx,data-size = <0x20>;
77 xlnx,dcache-addr-tag = <0xf>;
78 xlnx,dcache-always-used = <0x1>;
79 xlnx,dcache-byte-size = <0x2000>;
80 xlnx,dcache-line-len = <0x4>;
81 xlnx,dcache-use-fsl = <0x1>;
82 xlnx,debug-enabled = <0x1>;
83 xlnx,div-zero-exception = <0x1>;
84 xlnx,dopb-bus-exception = <0x0>;
85 xlnx,dynamic-bus-sizing = <0x1>;
86 xlnx,edge-is-positive = <0x1>;
87 xlnx,family = "virtex5";
88 xlnx,endianness = <0x1>;
89 xlnx,fpu-exception = <0x1>;
90 xlnx,fsl-data-size = <0x20>;
91 xlnx,fsl-exception = <0x0>;
92 xlnx,fsl-links = <0x0>;
93 xlnx,i-lmb = <0x1>;
94 xlnx,i-opb = <0x0>;
95 xlnx,i-plb = <0x1>;
96 xlnx,icache-always-used = <0x1>;
97 xlnx,icache-line-len = <0x4>;
98 xlnx,icache-use-fsl = <0x1>;
99 xlnx,ill-opcode-exception = <0x1>;
100 xlnx,instance = "microblaze_0";
101 xlnx,interconnect = <0x1>;
102 xlnx,interrupt-is-edge = <0x0>;
103 xlnx,iopb-bus-exception = <0x0>;
104 xlnx,mmu-dtlb-size = <0x4>;
105 xlnx,mmu-itlb-size = <0x2>;
106 xlnx,mmu-tlb-access = <0x3>;
107 xlnx,mmu-zones = <0x10>;
108 xlnx,number-of-pc-brk = <0x1>;
109 xlnx,number-of-rd-addr-brk = <0x0>;
110 xlnx,number-of-wr-addr-brk = <0x0>;
111 xlnx,opcode-0x0-illegal = <0x1>;
112 xlnx,pvr = <0x2>;
113 xlnx,pvr-user1 = <0x0>;
114 xlnx,pvr-user2 = <0x0>;
115 xlnx,reset-msr = <0x0>;
116 xlnx,sco = <0x0>;
117 xlnx,unaligned-exceptions = <0x1>;
118 xlnx,use-barrel = <0x1>;
119 xlnx,use-dcache = <0x1>;
120 xlnx,use-div = <0x1>;
121 xlnx,use-ext-brk = <0x1>;
122 xlnx,use-ext-nm-brk = <0x1>;
123 xlnx,use-extended-fsl-instr = <0x0>;
124 xlnx,use-fpu = <0x2>;
125 xlnx,use-hw-mul = <0x2>;
126 xlnx,use-icache = <0x1>;
127 xlnx,use-interrupt = <0x1>;
128 xlnx,use-mmu = <0x3>;
129 xlnx,use-msr-instr = <0x1>;
130 xlnx,use-pcmp-instr = <0x1>;
131 } ;
132 } ;
133 mb_plb: plb@0 {
134 #address-cells = <1>;
135 #size-cells = <1>;
136 compatible = "xlnx,plb-v46-1.03.a", "xlnx,plb-v46-1.00.a", "simple-bus";
137 ranges ;
138 FLASH: flash@a0000000 {
139 bank-width = <2>;
140 compatible = "xlnx,xps-mch-emc-2.00.a", "cfi-flash";
141 reg = < 0xa0000000 0x2000000 >;
142 xlnx,family = "virtex5";
143 xlnx,include-datawidth-matching-0 = <0x1>;
144 xlnx,include-datawidth-matching-1 = <0x0>;
145 xlnx,include-datawidth-matching-2 = <0x0>;
146 xlnx,include-datawidth-matching-3 = <0x0>;
147 xlnx,include-negedge-ioregs = <0x0>;
148 xlnx,include-plb-ipif = <0x1>;
149 xlnx,include-wrbuf = <0x1>;
150 xlnx,max-mem-width = <0x10>;
151 xlnx,mch-native-dwidth = <0x20>;
152 xlnx,mch-plb-clk-period-ps = <0x1f40>;
153 xlnx,mch-splb-awidth = <0x20>;
154 xlnx,mch0-accessbuf-depth = <0x10>;
155 xlnx,mch0-protocol = <0x0>;
156 xlnx,mch0-rddatabuf-depth = <0x10>;
157 xlnx,mch1-accessbuf-depth = <0x10>;
158 xlnx,mch1-protocol = <0x0>;
159 xlnx,mch1-rddatabuf-depth = <0x10>;
160 xlnx,mch2-accessbuf-depth = <0x10>;
161 xlnx,mch2-protocol = <0x0>;
162 xlnx,mch2-rddatabuf-depth = <0x10>;
163 xlnx,mch3-accessbuf-depth = <0x10>;
164 xlnx,mch3-protocol = <0x0>;
165 xlnx,mch3-rddatabuf-depth = <0x10>;
166 xlnx,mem0-width = <0x10>;
167 xlnx,mem1-width = <0x20>;
168 xlnx,mem2-width = <0x20>;
169 xlnx,mem3-width = <0x20>;
170 xlnx,num-banks-mem = <0x1>;
171 xlnx,num-channels = <0x0>;
172 xlnx,priority-mode = <0x0>;
173 xlnx,synch-mem-0 = <0x0>;
174 xlnx,synch-mem-1 = <0x0>;
175 xlnx,synch-mem-2 = <0x0>;
176 xlnx,synch-mem-3 = <0x0>;
177 xlnx,synch-pipedelay-0 = <0x2>;
178 xlnx,synch-pipedelay-1 = <0x2>;
179 xlnx,synch-pipedelay-2 = <0x2>;
180 xlnx,synch-pipedelay-3 = <0x2>;
181 xlnx,tavdv-ps-mem-0 = <0x1adb0>;
182 xlnx,tavdv-ps-mem-1 = <0x3a98>;
183 xlnx,tavdv-ps-mem-2 = <0x3a98>;
184 xlnx,tavdv-ps-mem-3 = <0x3a98>;
185 xlnx,tcedv-ps-mem-0 = <0x1adb0>;
186 xlnx,tcedv-ps-mem-1 = <0x3a98>;
187 xlnx,tcedv-ps-mem-2 = <0x3a98>;
188 xlnx,tcedv-ps-mem-3 = <0x3a98>;
189 xlnx,thzce-ps-mem-0 = <0x88b8>;
190 xlnx,thzce-ps-mem-1 = <0x1b58>;
191 xlnx,thzce-ps-mem-2 = <0x1b58>;
192 xlnx,thzce-ps-mem-3 = <0x1b58>;
193 xlnx,thzoe-ps-mem-0 = <0x1b58>;
194 xlnx,thzoe-ps-mem-1 = <0x1b58>;
195 xlnx,thzoe-ps-mem-2 = <0x1b58>;
196 xlnx,thzoe-ps-mem-3 = <0x1b58>;
197 xlnx,tlzwe-ps-mem-0 = <0x88b8>;
198 xlnx,tlzwe-ps-mem-1 = <0x0>;
199 xlnx,tlzwe-ps-mem-2 = <0x0>;
200 xlnx,tlzwe-ps-mem-3 = <0x0>;
201 xlnx,twc-ps-mem-0 = <0x2af8>;
202 xlnx,twc-ps-mem-1 = <0x3a98>;
203 xlnx,twc-ps-mem-2 = <0x3a98>;
204 xlnx,twc-ps-mem-3 = <0x3a98>;
205 xlnx,twp-ps-mem-0 = <0x11170>;
206 xlnx,twp-ps-mem-1 = <0x2ee0>;
207 xlnx,twp-ps-mem-2 = <0x2ee0>;
208 xlnx,twp-ps-mem-3 = <0x2ee0>;
209 xlnx,xcl0-linesize = <0x4>;
210 xlnx,xcl0-writexfer = <0x1>;
211 xlnx,xcl1-linesize = <0x4>;
212 xlnx,xcl1-writexfer = <0x1>;
213 xlnx,xcl2-linesize = <0x4>;
214 xlnx,xcl2-writexfer = <0x1>;
215 xlnx,xcl3-linesize = <0x4>;
216 xlnx,xcl3-writexfer = <0x1>;
217 } ;
218 Hard_Ethernet_MAC: xps-ll-temac@81c00000 {
219 #address-cells = <1>;
220 #size-cells = <1>;
221 compatible = "xlnx,compound";
222 ranges ;
223 ethernet@81c00000 {
224 compatible = "xlnx,xps-ll-temac-1.01.b", "xlnx,xps-ll-temac-1.00.a";
225 interrupt-parent = <&xps_intc_0>;
226 interrupts = < 5 2 >;
227 llink-connected = <&PIM3>;
228 local-mac-address = [ 00 0a 35 00 00 00 ];
229 reg = < 0x81c00000 0x40 >;
230 xlnx,bus2core-clk-ratio = <0x1>;
231 xlnx,phy-type = <0x1>;
232 xlnx,phyaddr = <0x1>;
233 xlnx,rxcsum = <0x0>;
234 xlnx,rxfifo = <0x1000>;
235 xlnx,temac-type = <0x0>;
236 xlnx,txcsum = <0x0>;
237 xlnx,txfifo = <0x1000>;
238 } ;
239 } ;
240 IIC_EEPROM: i2c@81600000 {
241 compatible = "xlnx,xps-iic-2.00.a";
242 interrupt-parent = <&xps_intc_0>;
243 interrupts = < 6 2 >;
244 reg = < 0x81600000 0x10000 >;
245 xlnx,clk-freq = <0x7735940>;
246 xlnx,family = "virtex5";
247 xlnx,gpo-width = <0x1>;
248 xlnx,iic-freq = <0x186a0>;
249 xlnx,scl-inertial-delay = <0x0>;
250 xlnx,sda-inertial-delay = <0x0>;
251 xlnx,ten-bit-adr = <0x0>;
252 } ;
253 LEDs_8Bit: gpio@81400000 {
254 compatible = "xlnx,xps-gpio-1.00.a";
255 interrupt-parent = <&xps_intc_0>;
256 interrupts = < 7 2 >;
257 reg = < 0x81400000 0x10000 >;
258 xlnx,all-inputs = <0x0>;
259 xlnx,all-inputs-2 = <0x0>;
260 xlnx,dout-default = <0x0>;
261 xlnx,dout-default-2 = <0x0>;
262 xlnx,family = "virtex5";
263 xlnx,gpio-width = <0x8>;
264 xlnx,interrupt-present = <0x1>;
265 xlnx,is-bidir = <0x1>;
266 xlnx,is-bidir-2 = <0x1>;
267 xlnx,is-dual = <0x0>;
268 xlnx,tri-default = <0xffffffff>;
269 xlnx,tri-default-2 = <0xffffffff>;
270 #gpio-cells = <2>;
271 gpio-controller;
272 } ;
273
274 gpio-leds {
275 compatible = "gpio-leds";
276
277 heartbeat {
278 label = "Heartbeat";
279 gpios = <&LEDs_8Bit 4 1>;
280 linux,default-trigger = "heartbeat";
281 };
282
283 yellow {
284 label = "Yellow";
285 gpios = <&LEDs_8Bit 5 1>;
286 };
287
288 red {
289 label = "Red";
290 gpios = <&LEDs_8Bit 6 1>;
291 };
292
293 green {
294 label = "Green";
295 gpios = <&LEDs_8Bit 7 1>;
296 };
297 } ;
298 RS232_Uart_1: serial@84000000 {
299 clock-frequency = <125000000>;
300 compatible = "xlnx,xps-uartlite-1.00.a";
301 current-speed = <115200>;
302 device_type = "serial";
303 interrupt-parent = <&xps_intc_0>;
304 interrupts = < 8 0 >;
305 port-number = <0>;
306 reg = < 0x84000000 0x10000 >;
307 xlnx,baudrate = <0x1c200>;
308 xlnx,data-bits = <0x8>;
309 xlnx,family = "virtex5";
310 xlnx,odd-parity = <0x0>;
311 xlnx,use-parity = <0x0>;
312 } ;
313 SysACE_CompactFlash: sysace@83600000 {
314 compatible = "xlnx,xps-sysace-1.00.a";
315 interrupt-parent = <&xps_intc_0>;
316 interrupts = < 4 2 >;
317 reg = < 0x83600000 0x10000 >;
318 xlnx,family = "virtex5";
319 xlnx,mem-width = <0x10>;
320 } ;
321 debug_module: debug@84400000 {
322 compatible = "xlnx,mdm-1.00.d";
323 reg = < 0x84400000 0x10000 >;
324 xlnx,family = "virtex5";
325 xlnx,interconnect = <0x1>;
326 xlnx,jtag-chain = <0x2>;
327 xlnx,mb-dbg-ports = <0x1>;
328 xlnx,uart-width = <0x8>;
329 xlnx,use-uart = <0x1>;
330 xlnx,write-fsl-ports = <0x0>;
331 } ;
332 mpmc@90000000 {
333 #address-cells = <1>;
334 #size-cells = <1>;
335 compatible = "xlnx,mpmc-4.02.a";
336 ranges ;
337 PIM3: sdma@84600180 {
338 compatible = "xlnx,ll-dma-1.00.a";
339 interrupt-parent = <&xps_intc_0>;
340 interrupts = < 2 2 1 2 >;
341 reg = < 0x84600180 0x80 >;
342 } ;
343 } ;
344 xps_intc_0: interrupt-controller@81800000 {
345 #interrupt-cells = <0x2>;
346 compatible = "xlnx,xps-intc-1.00.a";
347 interrupt-controller ;
348 reg = < 0x81800000 0x10000 >;
349 xlnx,kind-of-intr = <0x100>;
350 xlnx,num-intr-inputs = <0x9>;
351 } ;
352 xps_timer_1: timer@83c00000 {
353 compatible = "xlnx,xps-timer-1.00.a";
354 interrupt-parent = <&xps_intc_0>;
355 interrupts = < 3 2 >;
356 reg = < 0x83c00000 0x10000 >;
357 xlnx,count-width = <0x20>;
358 xlnx,family = "virtex5";
359 xlnx,gen0-assert = <0x1>;
360 xlnx,gen1-assert = <0x1>;
361 xlnx,one-timer-only = <0x0>;
362 xlnx,trig0-assert = <0x1>;
363 xlnx,trig1-assert = <0x1>;
364 } ;
365 } ;
366} ;
diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index 6c488c85d791..c6e9cd2bca8d 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -14,7 +14,7 @@
14#define __ASM_MIPS_SYSCALL_H 14#define __ASM_MIPS_SYSCALL_H
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/audit.h> 17#include <uapi/linux/audit.h>
18#include <linux/elf-em.h> 18#include <linux/elf-em.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
@@ -127,12 +127,11 @@ extern const unsigned long sys_call_table[];
127extern const unsigned long sys32_call_table[]; 127extern const unsigned long sys32_call_table[];
128extern const unsigned long sysn32_call_table[]; 128extern const unsigned long sysn32_call_table[];
129 129
130static inline int syscall_get_arch(struct task_struct *task, 130static inline int syscall_get_arch(void)
131 struct pt_regs *regs)
132{ 131{
133 int arch = EM_MIPS; 132 int arch = EM_MIPS;
134#ifdef CONFIG_64BIT 133#ifdef CONFIG_64BIT
135 if (!test_tsk_thread_flag(task, TIF_32BIT_REGS)) 134 if (!test_thread_flag(TIF_32BIT_REGS))
136 arch |= __AUDIT_ARCH_64BIT; 135 arch |= __AUDIT_ARCH_64BIT;
137#endif 136#endif
138#if defined(__LITTLE_ENDIAN) 137#if defined(__LITTLE_ENDIAN)
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 7271e5a83081..71f85f427034 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -649,7 +649,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
649 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 649 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
650 trace_sys_enter(regs, regs->regs[2]); 650 trace_sys_enter(regs, regs->regs[2]);
651 651
652 audit_syscall_entry(syscall_get_arch(current, regs), 652 audit_syscall_entry(syscall_get_arch(),
653 syscall, 653 syscall,
654 regs->regs[4], regs->regs[5], 654 regs->regs[4], regs->regs[5],
655 regs->regs[6], regs->regs[7]); 655 regs->regs[6], regs->regs[7]);
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c
index aed32b88576c..e1f427f4f5f3 100644
--- a/arch/mips/loongson/lemote-2f/clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -28,16 +28,16 @@ enum {
28}; 28};
29 29
30struct cpufreq_frequency_table loongson2_clockmod_table[] = { 30struct cpufreq_frequency_table loongson2_clockmod_table[] = {
31 {DC_RESV, CPUFREQ_ENTRY_INVALID}, 31 {0, DC_RESV, CPUFREQ_ENTRY_INVALID},
32 {DC_ZERO, CPUFREQ_ENTRY_INVALID}, 32 {0, DC_ZERO, CPUFREQ_ENTRY_INVALID},
33 {DC_25PT, 0}, 33 {0, DC_25PT, 0},
34 {DC_37PT, 0}, 34 {0, DC_37PT, 0},
35 {DC_50PT, 0}, 35 {0, DC_50PT, 0},
36 {DC_62PT, 0}, 36 {0, DC_62PT, 0},
37 {DC_75PT, 0}, 37 {0, DC_75PT, 0},
38 {DC_87PT, 0}, 38 {0, DC_87PT, 0},
39 {DC_DISABLE, 0}, 39 {0, DC_DISABLE, 0},
40 {DC_RESV, CPUFREQ_TABLE_END}, 40 {0, DC_RESV, CPUFREQ_TABLE_END},
41}; 41};
42EXPORT_SYMBOL_GPL(loongson2_clockmod_table); 42EXPORT_SYMBOL_GPL(loongson2_clockmod_table);
43 43
diff --git a/arch/mn10300/include/asm/highmem.h b/arch/mn10300/include/asm/highmem.h
index 7c137cd8aa37..2fbbe4d920aa 100644
--- a/arch/mn10300/include/asm/highmem.h
+++ b/arch/mn10300/include/asm/highmem.h
@@ -70,7 +70,7 @@ static inline void kunmap(struct page *page)
70 * be used in IRQ contexts, so in some (very limited) cases we need 70 * be used in IRQ contexts, so in some (very limited) cases we need
71 * it. 71 * it.
72 */ 72 */
73static inline unsigned long kmap_atomic(struct page *page) 73static inline void *kmap_atomic(struct page *page)
74{ 74{
75 unsigned long vaddr; 75 unsigned long vaddr;
76 int idx, type; 76 int idx, type;
@@ -89,7 +89,7 @@ static inline unsigned long kmap_atomic(struct page *page)
89 set_pte(kmap_pte - idx, mk_pte(page, kmap_prot)); 89 set_pte(kmap_pte - idx, mk_pte(page, kmap_prot));
90 local_flush_tlb_one(vaddr); 90 local_flush_tlb_one(vaddr);
91 91
92 return vaddr; 92 return (void *)vaddr;
93} 93}
94 94
95static inline void __kunmap_atomic(unsigned long vaddr) 95static inline void __kunmap_atomic(unsigned long vaddr)
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bb2a8ec440e7..1faefed32749 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -28,6 +28,7 @@ config PARISC
28 select CLONE_BACKWARDS 28 select CLONE_BACKWARDS
29 select TTY # Needed for pdc_cons.c 29 select TTY # Needed for pdc_cons.c
30 select HAVE_DEBUG_STACKOVERFLOW 30 select HAVE_DEBUG_STACKOVERFLOW
31 select HAVE_ARCH_AUDITSYSCALL
31 32
32 help 33 help
33 The PA-RISC microprocessor is designed by Hewlett-Packard and used 34 The PA-RISC microprocessor is designed by Hewlett-Packard and used
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6c03a94991ad..e0998997943b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -144,6 +144,7 @@ config PPC
144 select HAVE_DEBUG_STACKOVERFLOW 144 select HAVE_DEBUG_STACKOVERFLOW
145 select HAVE_IRQ_EXIT_ON_IRQ_STACK 145 select HAVE_IRQ_EXIT_ON_IRQ_STACK
146 select ARCH_USE_CMPXCHG_LOCKREF if PPC64 146 select ARCH_USE_CMPXCHG_LOCKREF if PPC64
147 select HAVE_ARCH_AUDITSYSCALL
147 148
148config GENERIC_CSUM 149config GENERIC_CSUM
149 def_bool CPU_LITTLE_ENDIAN 150 def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 0f4344e6fbca..4c0cedf4e2c7 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -74,6 +74,7 @@ override CROSS32AS += -mlittle-endian
74LDEMULATION := lppc 74LDEMULATION := lppc
75GNUTARGET := powerpcle 75GNUTARGET := powerpcle
76MULTIPLEWORD := -mno-multiple 76MULTIPLEWORD := -mno-multiple
77KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
77else 78else
78ifeq ($(call cc-option-yn,-mbig-endian),y) 79ifeq ($(call cc-option-yn,-mbig-endian),y)
79override CC += -mbig-endian 80override CC += -mbig-endian
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index c2353bf059fd..175a8b99c196 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -1244,7 +1244,6 @@ CONFIG_DEBUG_SPINLOCK_SLEEP=y
1244CONFIG_DEBUG_HIGHMEM=y 1244CONFIG_DEBUG_HIGHMEM=y
1245CONFIG_DEBUG_INFO=y 1245CONFIG_DEBUG_INFO=y
1246CONFIG_DEBUG_VM=y 1246CONFIG_DEBUG_VM=y
1247CONFIG_DEBUG_WRITECOUNT=y
1248CONFIG_DEBUG_LIST=y 1247CONFIG_DEBUG_LIST=y
1249CONFIG_DEBUG_SG=y 1248CONFIG_DEBUG_SG=y
1250# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1249# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index 139a8308070c..fdee37fab81c 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -174,7 +174,6 @@ CONFIG_DETECT_HUNG_TASK=y
174CONFIG_PROVE_LOCKING=y 174CONFIG_PROVE_LOCKING=y
175CONFIG_DEBUG_LOCKDEP=y 175CONFIG_DEBUG_LOCKDEP=y
176CONFIG_DEBUG_INFO=y 176CONFIG_DEBUG_INFO=y
177CONFIG_DEBUG_WRITECOUNT=y
178CONFIG_DEBUG_MEMORY_INIT=y 177CONFIG_DEBUG_MEMORY_INIT=y
179CONFIG_DEBUG_LIST=y 178CONFIG_DEBUG_LIST=y
180CONFIG_RCU_CPU_STALL_TIMEOUT=60 179CONFIG_RCU_CPU_STALL_TIMEOUT=60
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 9ea8342bd219..a905063281cc 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -306,3 +306,4 @@ CONFIG_KVM_BOOK3S_64=m
306CONFIG_KVM_BOOK3S_64_HV=y 306CONFIG_KVM_BOOK3S_64_HV=y
307CONFIG_TRANSPARENT_HUGEPAGE=y 307CONFIG_TRANSPARENT_HUGEPAGE=y
308CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y 308CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
309CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
diff --git a/arch/powerpc/configs/pseries_le_defconfig b/arch/powerpc/configs/pseries_le_defconfig
index 3c84f9d87980..58e3dbf43ca4 100644
--- a/arch/powerpc/configs/pseries_le_defconfig
+++ b/arch/powerpc/configs/pseries_le_defconfig
@@ -301,3 +301,4 @@ CONFIG_CRYPTO_LZO=m
301# CONFIG_CRYPTO_ANSI_CPRNG is not set 301# CONFIG_CRYPTO_ANSI_CPRNG is not set
302CONFIG_CRYPTO_DEV_NX=y 302CONFIG_CRYPTO_DEV_NX=y
303CONFIG_CRYPTO_DEV_NX_ENCRYPT=m 303CONFIG_CRYPTO_DEV_NX_ENCRYPT=m
304CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
diff --git a/arch/powerpc/include/asm/emulated_ops.h b/arch/powerpc/include/asm/emulated_ops.h
index 4358e3002f35..f00e10e2a335 100644
--- a/arch/powerpc/include/asm/emulated_ops.h
+++ b/arch/powerpc/include/asm/emulated_ops.h
@@ -54,6 +54,7 @@ extern struct ppc_emulated {
54#ifdef CONFIG_PPC64 54#ifdef CONFIG_PPC64
55 struct ppc_emulated_entry mfdscr; 55 struct ppc_emulated_entry mfdscr;
56 struct ppc_emulated_entry mtdscr; 56 struct ppc_emulated_entry mtdscr;
57 struct ppc_emulated_entry lq_stq;
57#endif 58#endif
58} ppc_emulated; 59} ppc_emulated;
59 60
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index fe2aa0b48d2b..a2efdaa020b0 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -87,6 +87,7 @@ extern int opal_enter_rtas(struct rtas_args *args,
87#define OPAL_ASYNC_COMPLETION -15 87#define OPAL_ASYNC_COMPLETION -15
88 88
89/* API Tokens (in r0) */ 89/* API Tokens (in r0) */
90#define OPAL_INVALID_CALL -1
90#define OPAL_CONSOLE_WRITE 1 91#define OPAL_CONSOLE_WRITE 1
91#define OPAL_CONSOLE_READ 2 92#define OPAL_CONSOLE_READ 2
92#define OPAL_RTC_READ 3 93#define OPAL_RTC_READ 3
@@ -177,6 +178,8 @@ extern int opal_enter_rtas(struct rtas_args *args,
177 178
178#ifndef __ASSEMBLY__ 179#ifndef __ASSEMBLY__
179 180
181#include <linux/notifier.h>
182
180/* Other enums */ 183/* Other enums */
181enum OpalVendorApiTokens { 184enum OpalVendorApiTokens {
182 OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999 185 OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999
@@ -422,9 +425,9 @@ enum OpalSysparamPerm {
422}; 425};
423 426
424struct opal_msg { 427struct opal_msg {
425 uint32_t msg_type; 428 __be32 msg_type;
426 uint32_t reserved; 429 __be32 reserved;
427 uint64_t params[8]; 430 __be64 params[8];
428}; 431};
429 432
430struct opal_machine_check_event { 433struct opal_machine_check_event {
@@ -730,7 +733,11 @@ typedef struct oppanel_line {
730/* /sys/firmware/opal */ 733/* /sys/firmware/opal */
731extern struct kobject *opal_kobj; 734extern struct kobject *opal_kobj;
732 735
736/* /ibm,opal */
737extern struct device_node *opal_node;
738
733/* API functions */ 739/* API functions */
740int64_t opal_invalid_call(void);
734int64_t opal_console_write(int64_t term_number, __be64 *length, 741int64_t opal_console_write(int64_t term_number, __be64 *length,
735 const uint8_t *buffer); 742 const uint8_t *buffer);
736int64_t opal_console_read(int64_t term_number, __be64 *length, 743int64_t opal_console_read(int64_t term_number, __be64 *length,
@@ -874,8 +881,7 @@ int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer,
874 size_t length); 881 size_t length);
875int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer, 882int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer,
876 size_t length); 883 size_t length);
877int64_t opal_sensor_read(uint32_t sensor_hndl, int token, 884int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);
878 uint32_t *sensor_data);
879 885
880/* Internal functions */ 886/* Internal functions */
881extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); 887extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data);
@@ -892,6 +898,8 @@ extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
892 int depth, void *data); 898 int depth, void *data);
893 899
894extern int opal_notifier_register(struct notifier_block *nb); 900extern int opal_notifier_register(struct notifier_block *nb);
901extern int opal_notifier_unregister(struct notifier_block *nb);
902
895extern int opal_message_notifier_register(enum OpalMessageType msg_type, 903extern int opal_message_notifier_register(enum OpalMessageType msg_type,
896 struct notifier_block *nb); 904 struct notifier_block *nb);
897extern void opal_notifier_enable(void); 905extern void opal_notifier_enable(void);
@@ -919,6 +927,7 @@ extern void opal_flash_init(void);
919extern int opal_elog_init(void); 927extern int opal_elog_init(void);
920extern void opal_platform_dump_init(void); 928extern void opal_platform_dump_init(void);
921extern void opal_sys_param_init(void); 929extern void opal_sys_param_init(void);
930extern void opal_msglog_init(void);
922 931
923extern int opal_machine_check(struct pt_regs *regs); 932extern int opal_machine_check(struct pt_regs *regs);
924extern bool opal_mce_check_early_recovery(struct pt_regs *regs); 933extern bool opal_mce_check_early_recovery(struct pt_regs *regs);
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 0dcc48af25a3..e5d2e0bc7e03 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -272,6 +272,10 @@
272#define SPRN_HSRR1 0x13B /* Hypervisor Save/Restore 1 */ 272#define SPRN_HSRR1 0x13B /* Hypervisor Save/Restore 1 */
273#define SPRN_IC 0x350 /* Virtual Instruction Count */ 273#define SPRN_IC 0x350 /* Virtual Instruction Count */
274#define SPRN_VTB 0x351 /* Virtual Time Base */ 274#define SPRN_VTB 0x351 /* Virtual Time Base */
275#define SPRN_PMICR 0x354 /* Power Management Idle Control Reg */
276#define SPRN_PMSR 0x355 /* Power Management Status Reg */
277#define SPRN_PMCR 0x374 /* Power Management Control Register */
278
275/* HFSCR and FSCR bit numbers are the same */ 279/* HFSCR and FSCR bit numbers are the same */
276#define FSCR_TAR_LG 8 /* Enable Target Address Register */ 280#define FSCR_TAR_LG 8 /* Enable Target Address Register */
277#define FSCR_EBB_LG 7 /* Enable Event Based Branching */ 281#define FSCR_EBB_LG 7 /* Enable Event Based Branching */
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index a0e1add01ef5..b390f55b0df1 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -150,19 +150,53 @@ struct rtas_suspend_me_data {
150#define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500 150#define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500
151 151
152struct rtas_error_log { 152struct rtas_error_log {
153 unsigned long version:8; /* Architectural version */ 153 /* Byte 0 */
154 unsigned long severity:3; /* Severity level of error */ 154 uint8_t byte0; /* Architectural version */
155 unsigned long disposition:2; /* Degree of recovery */ 155
156 unsigned long extended:1; /* extended log present? */ 156 /* Byte 1 */
157 unsigned long /* reserved */ :2; /* Reserved for future use */ 157 uint8_t byte1;
158 unsigned long initiator:4; /* Initiator of event */ 158 /* XXXXXXXX
159 unsigned long target:4; /* Target of failed operation */ 159 * XXX 3: Severity level of error
160 unsigned long type:8; /* General event or error*/ 160 * XX 2: Degree of recovery
161 unsigned long extended_log_length:32; /* length in bytes */ 161 * X 1: Extended log present?
162 unsigned char buffer[1]; /* Start of extended log */ 162 * XX 2: Reserved
163 */
164
165 /* Byte 2 */
166 uint8_t byte2;
167 /* XXXXXXXX
168 * XXXX 4: Initiator of event
169 * XXXX 4: Target of failed operation
170 */
171 uint8_t byte3; /* General event or error*/
172 __be32 extended_log_length; /* length in bytes */
173 unsigned char buffer[1]; /* Start of extended log */
163 /* Variable length. */ 174 /* Variable length. */
164}; 175};
165 176
177static inline uint8_t rtas_error_severity(const struct rtas_error_log *elog)
178{
179 return (elog->byte1 & 0xE0) >> 5;
180}
181
182static inline uint8_t rtas_error_disposition(const struct rtas_error_log *elog)
183{
184 return (elog->byte1 & 0x18) >> 3;
185}
186
187static inline uint8_t rtas_error_extended(const struct rtas_error_log *elog)
188{
189 return (elog->byte1 & 0x04) >> 2;
190}
191
192#define rtas_error_type(x) ((x)->byte3)
193
194static inline
195uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)
196{
197 return be32_to_cpu(elog->extended_log_length);
198}
199
166#define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14 200#define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14
167 201
168#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8)) 202#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8))
@@ -172,32 +206,35 @@ struct rtas_error_log {
172 */ 206 */
173struct rtas_ext_event_log_v6 { 207struct rtas_ext_event_log_v6 {
174 /* Byte 0 */ 208 /* Byte 0 */
175 uint32_t log_valid:1; /* 1:Log valid */ 209 uint8_t byte0;
176 uint32_t unrecoverable_error:1; /* 1:Unrecoverable error */ 210 /* XXXXXXXX
177 uint32_t recoverable_error:1; /* 1:recoverable (correctable */ 211 * X 1: Log valid
178 /* or successfully retried) */ 212 * X 1: Unrecoverable error
179 uint32_t degraded_operation:1; /* 1:Unrecoverable err, bypassed*/ 213 * X 1: Recoverable (correctable or successfully retried)
180 /* - degraded operation (e.g. */ 214 * X 1: Bypassed unrecoverable error (degraded operation)
181 /* CPU or mem taken off-line) */ 215 * X 1: Predictive error
182 uint32_t predictive_error:1; 216 * X 1: "New" log (always 1 for data returned from RTAS)
183 uint32_t new_log:1; /* 1:"New" log (Always 1 for */ 217 * X 1: Big Endian
184 /* data returned from RTAS */ 218 * X 1: Reserved
185 uint32_t big_endian:1; /* 1: Big endian */ 219 */
186 uint32_t :1; /* reserved */ 220
187 /* Byte 1 */ 221 /* Byte 1 */
188 uint32_t :8; /* reserved */ 222 uint8_t byte1; /* reserved */
223
189 /* Byte 2 */ 224 /* Byte 2 */
190 uint32_t powerpc_format:1; /* Set to 1 (indicating log is */ 225 uint8_t byte2;
191 /* in PowerPC format */ 226 /* XXXXXXXX
192 uint32_t :3; /* reserved */ 227 * X 1: Set to 1 (indicating log is in PowerPC format)
193 uint32_t log_format:4; /* Log format indicator. Define */ 228 * XXX 3: Reserved
194 /* format used for byte 12-2047 */ 229 * XXXX 4: Log format used for bytes 12-2047
230 */
231
195 /* Byte 3 */ 232 /* Byte 3 */
196 uint32_t :8; /* reserved */ 233 uint8_t byte3; /* reserved */
197 /* Byte 4-11 */ 234 /* Byte 4-11 */
198 uint8_t reserved[8]; /* reserved */ 235 uint8_t reserved[8]; /* reserved */
199 /* Byte 12-15 */ 236 /* Byte 12-15 */
200 uint32_t company_id; /* Company ID of the company */ 237 __be32 company_id; /* Company ID of the company */
201 /* that defines the format for */ 238 /* that defines the format for */
202 /* the vendor specific log type */ 239 /* the vendor specific log type */
203 /* Byte 16-end of log */ 240 /* Byte 16-end of log */
@@ -205,6 +242,18 @@ struct rtas_ext_event_log_v6 {
205 /* Variable length. */ 242 /* Variable length. */
206}; 243};
207 244
245static
246inline uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log)
247{
248 return ext_log->byte2 & 0x0F;
249}
250
251static
252inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)
253{
254 return be32_to_cpu(ext_log->company_id);
255}
256
208/* pSeries event log format */ 257/* pSeries event log format */
209 258
210/* Two bytes ASCII section IDs */ 259/* Two bytes ASCII section IDs */
@@ -227,14 +276,26 @@ struct rtas_ext_event_log_v6 {
227 276
228/* Vendor specific Platform Event Log Format, Version 6, section header */ 277/* Vendor specific Platform Event Log Format, Version 6, section header */
229struct pseries_errorlog { 278struct pseries_errorlog {
230 uint16_t id; /* 0x00 2-byte ASCII section ID */ 279 __be16 id; /* 0x00 2-byte ASCII section ID */
231 uint16_t length; /* 0x02 Section length in bytes */ 280 __be16 length; /* 0x02 Section length in bytes */
232 uint8_t version; /* 0x04 Section version */ 281 uint8_t version; /* 0x04 Section version */
233 uint8_t subtype; /* 0x05 Section subtype */ 282 uint8_t subtype; /* 0x05 Section subtype */
234 uint16_t creator_component; /* 0x06 Creator component ID */ 283 __be16 creator_component; /* 0x06 Creator component ID */
235 uint8_t data[]; /* 0x08 Start of section data */ 284 uint8_t data[]; /* 0x08 Start of section data */
236}; 285};
237 286
287static
288inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect)
289{
290 return be16_to_cpu(sect->id);
291}
292
293static
294inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect)
295{
296 return be16_to_cpu(sect->length);
297}
298
238struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, 299struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
239 uint16_t section_id); 300 uint16_t section_id);
240 301
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index de91f3ae631e..94908af308d8 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -73,7 +73,7 @@ static struct aligninfo aligninfo[128] = {
73 { 8, LD+F }, /* 00 0 1001: lfd */ 73 { 8, LD+F }, /* 00 0 1001: lfd */
74 { 4, ST+F+S }, /* 00 0 1010: stfs */ 74 { 4, ST+F+S }, /* 00 0 1010: stfs */
75 { 8, ST+F }, /* 00 0 1011: stfd */ 75 { 8, ST+F }, /* 00 0 1011: stfd */
76 INVALID, /* 00 0 1100 */ 76 { 16, LD }, /* 00 0 1100: lq */
77 { 8, LD }, /* 00 0 1101: ld/ldu/lwa */ 77 { 8, LD }, /* 00 0 1101: ld/ldu/lwa */
78 INVALID, /* 00 0 1110 */ 78 INVALID, /* 00 0 1110 */
79 { 8, ST }, /* 00 0 1111: std/stdu */ 79 { 8, ST }, /* 00 0 1111: std/stdu */
@@ -140,7 +140,7 @@ static struct aligninfo aligninfo[128] = {
140 { 2, LD+SW }, /* 10 0 1100: lhbrx */ 140 { 2, LD+SW }, /* 10 0 1100: lhbrx */
141 { 4, LD+SE }, /* 10 0 1101 lwa */ 141 { 4, LD+SE }, /* 10 0 1101 lwa */
142 { 2, ST+SW }, /* 10 0 1110: sthbrx */ 142 { 2, ST+SW }, /* 10 0 1110: sthbrx */
143 INVALID, /* 10 0 1111 */ 143 { 16, ST }, /* 10 0 1111: stq */
144 INVALID, /* 10 1 0000 */ 144 INVALID, /* 10 1 0000 */
145 INVALID, /* 10 1 0001 */ 145 INVALID, /* 10 1 0001 */
146 INVALID, /* 10 1 0010 */ 146 INVALID, /* 10 1 0010 */
@@ -385,8 +385,6 @@ static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg,
385 char *ptr1 = (char *) &current->thread.TS_FPR(reg+1); 385 char *ptr1 = (char *) &current->thread.TS_FPR(reg+1);
386 int i, ret, sw = 0; 386 int i, ret, sw = 0;
387 387
388 if (!(flags & F))
389 return 0;
390 if (reg & 1) 388 if (reg & 1)
391 return 0; /* invalid form: FRS/FRT must be even */ 389 return 0; /* invalid form: FRS/FRT must be even */
392 if (flags & SW) 390 if (flags & SW)
@@ -406,6 +404,34 @@ static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg,
406 return 1; /* exception handled and fixed up */ 404 return 1; /* exception handled and fixed up */
407} 405}
408 406
407#ifdef CONFIG_PPC64
408static int emulate_lq_stq(struct pt_regs *regs, unsigned char __user *addr,
409 unsigned int reg, unsigned int flags)
410{
411 char *ptr0 = (char *)&regs->gpr[reg];
412 char *ptr1 = (char *)&regs->gpr[reg+1];
413 int i, ret, sw = 0;
414
415 if (reg & 1)
416 return 0; /* invalid form: GPR must be even */
417 if (flags & SW)
418 sw = 7;
419 ret = 0;
420 for (i = 0; i < 8; ++i) {
421 if (!(flags & ST)) {
422 ret |= __get_user(ptr0[i^sw], addr + i);
423 ret |= __get_user(ptr1[i^sw], addr + i + 8);
424 } else {
425 ret |= __put_user(ptr0[i^sw], addr + i);
426 ret |= __put_user(ptr1[i^sw], addr + i + 8);
427 }
428 }
429 if (ret)
430 return -EFAULT;
431 return 1; /* exception handled and fixed up */
432}
433#endif /* CONFIG_PPC64 */
434
409#ifdef CONFIG_SPE 435#ifdef CONFIG_SPE
410 436
411static struct aligninfo spe_aligninfo[32] = { 437static struct aligninfo spe_aligninfo[32] = {
@@ -914,10 +940,20 @@ int fix_alignment(struct pt_regs *regs)
914 flush_fp_to_thread(current); 940 flush_fp_to_thread(current);
915 } 941 }
916 942
917 /* Special case for 16-byte FP loads and stores */ 943 if ((nb == 16)) {
918 if (nb == 16) { 944 if (flags & F) {
919 PPC_WARN_ALIGNMENT(fp_pair, regs); 945 /* Special case for 16-byte FP loads and stores */
920 return emulate_fp_pair(addr, reg, flags); 946 PPC_WARN_ALIGNMENT(fp_pair, regs);
947 return emulate_fp_pair(addr, reg, flags);
948 } else {
949#ifdef CONFIG_PPC64
950 /* Special case for 16-byte loads and stores */
951 PPC_WARN_ALIGNMENT(lq_stq, regs);
952 return emulate_lq_stq(regs, addr, reg, flags);
953#else
954 return 0;
955#endif
956 }
921 } 957 }
922 958
923 PPC_WARN_ALIGNMENT(unaligned, regs); 959 PPC_WARN_ALIGNMENT(unaligned, regs);
diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
index 37d1bb002aa9..1557e7c2c7e1 100644
--- a/arch/powerpc/kernel/cpu_setup_power.S
+++ b/arch/powerpc/kernel/cpu_setup_power.S
@@ -56,7 +56,6 @@ _GLOBAL(__setup_cpu_power8)
56 li r0,0 56 li r0,0
57 mtspr SPRN_LPID,r0 57 mtspr SPRN_LPID,r0
58 mfspr r3,SPRN_LPCR 58 mfspr r3,SPRN_LPCR
59 oris r3, r3, LPCR_AIL_3@h
60 bl __init_LPCR 59 bl __init_LPCR
61 bl __init_HFSCR 60 bl __init_HFSCR
62 bl __init_tlb_power8 61 bl __init_tlb_power8
@@ -75,7 +74,6 @@ _GLOBAL(__restore_cpu_power8)
75 li r0,0 74 li r0,0
76 mtspr SPRN_LPID,r0 75 mtspr SPRN_LPID,r0
77 mfspr r3,SPRN_LPCR 76 mfspr r3,SPRN_LPCR
78 oris r3, r3, LPCR_AIL_3@h
79 bl __init_LPCR 77 bl __init_LPCR
80 bl __init_HFSCR 78 bl __init_HFSCR
81 bl __init_tlb_power8 79 bl __init_tlb_power8
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index d9c650ec7dac..3afd3915921a 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -54,14 +54,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
54 xori r12,r12,MSR_LE ; \ 54 xori r12,r12,MSR_LE ; \
55 mtspr SPRN_SRR1,r12 ; \ 55 mtspr SPRN_SRR1,r12 ; \
56 rfid ; /* return to userspace */ \ 56 rfid ; /* return to userspace */ \
57 b . ; \
582: mfspr r12,SPRN_SRR1 ; \
59 andi. r12,r12,MSR_PR ; \
60 bne 0b ; \
61 mtspr SPRN_SRR0,r3 ; \
62 mtspr SPRN_SRR1,r4 ; \
63 mtspr SPRN_SDR1,r5 ; \
64 rfid ; \
65 b . ; /* prevent speculative execution */ 57 b . ; /* prevent speculative execution */
66 58
67#if defined(CONFIG_RELOCATABLE) 59#if defined(CONFIG_RELOCATABLE)
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index bf0aada02fe4..ad302f845e5d 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -152,7 +152,8 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu)
152 new_paca->paca_index = cpu; 152 new_paca->paca_index = cpu;
153 new_paca->kernel_toc = kernel_toc; 153 new_paca->kernel_toc = kernel_toc;
154 new_paca->kernelbase = (unsigned long) _stext; 154 new_paca->kernelbase = (unsigned long) _stext;
155 new_paca->kernel_msr = MSR_KERNEL; 155 /* Only set MSR:IR/DR when MMU is initialized */
156 new_paca->kernel_msr = MSR_KERNEL & ~(MSR_IR | MSR_DR);
156 new_paca->hw_cpu_id = 0xffff; 157 new_paca->hw_cpu_id = 0xffff;
157 new_paca->kexec_state = KEXEC_STATE_NONE; 158 new_paca->kexec_state = KEXEC_STATE_NONE;
158 new_paca->__current = &init_task; 159 new_paca->__current = &init_task;
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index af064d28b365..31d021506d21 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -610,6 +610,31 @@ out_and_saveregs:
610 tm_save_sprs(thr); 610 tm_save_sprs(thr);
611} 611}
612 612
613extern void __tm_recheckpoint(struct thread_struct *thread,
614 unsigned long orig_msr);
615
616void tm_recheckpoint(struct thread_struct *thread,
617 unsigned long orig_msr)
618{
619 unsigned long flags;
620
621 /* We really can't be interrupted here as the TEXASR registers can't
622 * change and later in the trecheckpoint code, we have a userspace R1.
623 * So let's hard disable over this region.
624 */
625 local_irq_save(flags);
626 hard_irq_disable();
627
628 /* The TM SPRs are restored here, so that TEXASR.FS can be set
629 * before the trecheckpoint and no explosion occurs.
630 */
631 tm_restore_sprs(thread);
632
633 __tm_recheckpoint(thread, orig_msr);
634
635 local_irq_restore(flags);
636}
637
613static inline void tm_recheckpoint_new_task(struct task_struct *new) 638static inline void tm_recheckpoint_new_task(struct task_struct *new)
614{ 639{
615 unsigned long msr; 640 unsigned long msr;
@@ -628,13 +653,10 @@ static inline void tm_recheckpoint_new_task(struct task_struct *new)
628 if (!new->thread.regs) 653 if (!new->thread.regs)
629 return; 654 return;
630 655
631 /* The TM SPRs are restored here, so that TEXASR.FS can be set 656 if (!MSR_TM_ACTIVE(new->thread.regs->msr)){
632 * before the trecheckpoint and no explosion occurs. 657 tm_restore_sprs(&new->thread);
633 */
634 tm_restore_sprs(&new->thread);
635
636 if (!MSR_TM_ACTIVE(new->thread.regs->msr))
637 return; 658 return;
659 }
638 msr = new->thread.tm_orig_msr; 660 msr = new->thread.tm_orig_msr;
639 /* Recheckpoint to restore original checkpointed register state. */ 661 /* Recheckpoint to restore original checkpointed register state. */
640 TM_DEBUG("*** tm_recheckpoint of pid %d " 662 TM_DEBUG("*** tm_recheckpoint of pid %d "
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index dd72bebd708a..668aa4791fd7 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -347,45 +347,45 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
347#endif 347#endif
348 } 348 }
349 349
350 if (found >= 0) { 350 /* Not the boot CPU */
351 DBG("boot cpu: logical %d physical %d\n", found, 351 if (found < 0)
352 be32_to_cpu(intserv[found_thread])); 352 return 0;
353 boot_cpuid = found;
354 set_hard_smp_processor_id(found,
355 be32_to_cpu(intserv[found_thread]));
356 353
357 /* 354 DBG("boot cpu: logical %d physical %d\n", found,
358 * PAPR defines "logical" PVR values for cpus that 355 be32_to_cpu(intserv[found_thread]));
359 * meet various levels of the architecture: 356 boot_cpuid = found;
360 * 0x0f000001 Architecture version 2.04 357 set_hard_smp_processor_id(found, be32_to_cpu(intserv[found_thread]));
361 * 0x0f000002 Architecture version 2.05
362 * If the cpu-version property in the cpu node contains
363 * such a value, we call identify_cpu again with the
364 * logical PVR value in order to use the cpu feature
365 * bits appropriate for the architecture level.
366 *
367 * A POWER6 partition in "POWER6 architected" mode
368 * uses the 0x0f000002 PVR value; in POWER5+ mode
369 * it uses 0x0f000001.
370 */
371 prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
372 if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
373 identify_cpu(0, be32_to_cpup(prop));
374 358
375 identical_pvr_fixup(node); 359 /*
376 } 360 * PAPR defines "logical" PVR values for cpus that
361 * meet various levels of the architecture:
362 * 0x0f000001 Architecture version 2.04
363 * 0x0f000002 Architecture version 2.05
364 * If the cpu-version property in the cpu node contains
365 * such a value, we call identify_cpu again with the
366 * logical PVR value in order to use the cpu feature
367 * bits appropriate for the architecture level.
368 *
369 * A POWER6 partition in "POWER6 architected" mode
370 * uses the 0x0f000002 PVR value; in POWER5+ mode
371 * it uses 0x0f000001.
372 */
373 prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
374 if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
375 identify_cpu(0, be32_to_cpup(prop));
376
377 identical_pvr_fixup(node);
377 378
378 check_cpu_feature_properties(node); 379 check_cpu_feature_properties(node);
379 check_cpu_pa_features(node); 380 check_cpu_pa_features(node);
380 check_cpu_slb_size(node); 381 check_cpu_slb_size(node);
381 382
382#ifdef CONFIG_PPC_PSERIES 383#ifdef CONFIG_PPC64
383 if (nthreads > 1) 384 if (nthreads > 1)
384 cur_cpu_spec->cpu_features |= CPU_FTR_SMT; 385 cur_cpu_spec->cpu_features |= CPU_FTR_SMT;
385 else 386 else
386 cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT; 387 cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT;
387#endif 388#endif
388
389 return 0; 389 return 0;
390} 390}
391 391
@@ -747,6 +747,10 @@ void __init early_init_devtree(void *params)
747 * (altivec support, boot CPU ID, ...) 747 * (altivec support, boot CPU ID, ...)
748 */ 748 */
749 of_scan_flat_dt(early_init_dt_scan_cpus, NULL); 749 of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
750 if (boot_cpuid < 0) {
751 printk("Failed to indentify boot CPU !\n");
752 BUG();
753 }
750 754
751#if defined(CONFIG_SMP) && defined(CONFIG_PPC64) 755#if defined(CONFIG_SMP) && defined(CONFIG_PPC64)
752 /* We'll later wait for secondaries to check in; there are 756 /* We'll later wait for secondaries to check in; there are
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index f386296ff378..8cd5ed049b5d 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -993,21 +993,24 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
993 (struct rtas_ext_event_log_v6 *)log->buffer; 993 (struct rtas_ext_event_log_v6 *)log->buffer;
994 struct pseries_errorlog *sect; 994 struct pseries_errorlog *sect;
995 unsigned char *p, *log_end; 995 unsigned char *p, *log_end;
996 uint32_t ext_log_length = rtas_error_extended_log_length(log);
997 uint8_t log_format = rtas_ext_event_log_format(ext_log);
998 uint32_t company_id = rtas_ext_event_company_id(ext_log);
996 999
997 /* Check that we understand the format */ 1000 /* Check that we understand the format */
998 if (log->extended_log_length < sizeof(struct rtas_ext_event_log_v6) || 1001 if (ext_log_length < sizeof(struct rtas_ext_event_log_v6) ||
999 ext_log->log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG || 1002 log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG ||
1000 ext_log->company_id != RTAS_V6EXT_COMPANY_ID_IBM) 1003 company_id != RTAS_V6EXT_COMPANY_ID_IBM)
1001 return NULL; 1004 return NULL;
1002 1005
1003 log_end = log->buffer + log->extended_log_length; 1006 log_end = log->buffer + ext_log_length;
1004 p = ext_log->vendor_log; 1007 p = ext_log->vendor_log;
1005 1008
1006 while (p < log_end) { 1009 while (p < log_end) {
1007 sect = (struct pseries_errorlog *)p; 1010 sect = (struct pseries_errorlog *)p;
1008 if (sect->id == section_id) 1011 if (pseries_errorlog_id(sect) == section_id)
1009 return sect; 1012 return sect;
1010 p += sect->length; 1013 p += pseries_errorlog_length(sect);
1011 } 1014 }
1012 1015
1013 return NULL; 1016 return NULL;
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index 1130c53ad652..e736387fee6a 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -150,8 +150,8 @@ static void printk_log_rtas(char *buf, int len)
150 struct rtas_error_log *errlog = (struct rtas_error_log *)buf; 150 struct rtas_error_log *errlog = (struct rtas_error_log *)buf;
151 151
152 printk(RTAS_DEBUG "event: %d, Type: %s, Severity: %d\n", 152 printk(RTAS_DEBUG "event: %d, Type: %s, Severity: %d\n",
153 error_log_cnt, rtas_event_type(errlog->type), 153 error_log_cnt, rtas_event_type(rtas_error_type(errlog)),
154 errlog->severity); 154 rtas_error_severity(errlog));
155 } 155 }
156} 156}
157 157
@@ -159,14 +159,16 @@ static int log_rtas_len(char * buf)
159{ 159{
160 int len; 160 int len;
161 struct rtas_error_log *err; 161 struct rtas_error_log *err;
162 uint32_t extended_log_length;
162 163
163 /* rtas fixed header */ 164 /* rtas fixed header */
164 len = 8; 165 len = 8;
165 err = (struct rtas_error_log *)buf; 166 err = (struct rtas_error_log *)buf;
166 if (err->extended && err->extended_log_length) { 167 extended_log_length = rtas_error_extended_log_length(err);
168 if (rtas_error_extended(err) && extended_log_length) {
167 169
168 /* extended header */ 170 /* extended header */
169 len += err->extended_log_length; 171 len += extended_log_length;
170 } 172 }
171 173
172 if (rtas_error_log_max == 0) 174 if (rtas_error_log_max == 0)
@@ -293,15 +295,13 @@ void prrn_schedule_update(u32 scope)
293 295
294static void handle_rtas_event(const struct rtas_error_log *log) 296static void handle_rtas_event(const struct rtas_error_log *log)
295{ 297{
296 if (log->type == RTAS_TYPE_PRRN) { 298 if (rtas_error_type(log) != RTAS_TYPE_PRRN || !prrn_is_enabled())
297 /* For PRRN Events the extended log length is used to denote 299 return;
298 * the scope for calling rtas update-nodes.
299 */
300 if (prrn_is_enabled())
301 prrn_schedule_update(log->extended_log_length);
302 }
303 300
304 return; 301 /* For PRRN Events the extended log length is used to denote
302 * the scope for calling rtas update-nodes.
303 */
304 prrn_schedule_update(rtas_error_extended_log_length(log));
305} 305}
306 306
307#else 307#else
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index bc76cc6b419c..79b7612ac6fa 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -76,6 +76,9 @@ EXPORT_SYMBOL(ppc_md);
76struct machdep_calls *machine_id; 76struct machdep_calls *machine_id;
77EXPORT_SYMBOL(machine_id); 77EXPORT_SYMBOL(machine_id);
78 78
79int boot_cpuid = -1;
80EXPORT_SYMBOL_GPL(boot_cpuid);
81
79unsigned long klimit = (unsigned long) _end; 82unsigned long klimit = (unsigned long) _end;
80 83
81char cmd_line[COMMAND_LINE_SIZE]; 84char cmd_line[COMMAND_LINE_SIZE];
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 04cc4fcca78b..ea4fda60e57b 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -44,8 +44,6 @@
44 44
45extern void bootx_init(unsigned long r4, unsigned long phys); 45extern void bootx_init(unsigned long r4, unsigned long phys);
46 46
47int boot_cpuid = -1;
48EXPORT_SYMBOL_GPL(boot_cpuid);
49int boot_cpuid_phys; 47int boot_cpuid_phys;
50EXPORT_SYMBOL_GPL(boot_cpuid_phys); 48EXPORT_SYMBOL_GPL(boot_cpuid_phys);
51 49
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 4933909cc5c0..fbe24377eda3 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -74,7 +74,6 @@
74#define DBG(fmt...) 74#define DBG(fmt...)
75#endif 75#endif
76 76
77int boot_cpuid = 0;
78int spinning_secondaries; 77int spinning_secondaries;
79u64 ppc64_pft_size; 78u64 ppc64_pft_size;
80 79
@@ -196,6 +195,19 @@ static void fixup_boot_paca(void)
196 get_paca()->data_offset = 0; 195 get_paca()->data_offset = 0;
197} 196}
198 197
198static void cpu_ready_for_interrupts(void)
199{
200 /* Set IR and DR in PACA MSR */
201 get_paca()->kernel_msr = MSR_KERNEL;
202
203 /* Enable AIL if supported */
204 if (cpu_has_feature(CPU_FTR_HVMODE) &&
205 cpu_has_feature(CPU_FTR_ARCH_207S)) {
206 unsigned long lpcr = mfspr(SPRN_LPCR);
207 mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3);
208 }
209}
210
199/* 211/*
200 * Early initialization entry point. This is called by head.S 212 * Early initialization entry point. This is called by head.S
201 * with MMU translation disabled. We rely on the "feature" of 213 * with MMU translation disabled. We rely on the "feature" of
@@ -262,6 +274,14 @@ void __init early_setup(unsigned long dt_ptr)
262 /* Initialize the hash table or TLB handling */ 274 /* Initialize the hash table or TLB handling */
263 early_init_mmu(); 275 early_init_mmu();
264 276
277 /*
278 * At this point, we can let interrupts switch to virtual mode
279 * (the MMU has been setup), so adjust the MSR in the PACA to
280 * have IR and DR set and enable AIL if it exists
281 */
282 cpu_ready_for_interrupts();
283
284 /* Reserve large chunks of memory for use by CMA for KVM */
265 kvm_cma_reserve(); 285 kvm_cma_reserve();
266 286
267 /* 287 /*
@@ -294,6 +314,13 @@ void early_setup_secondary(void)
294 314
295 /* Initialize the hash table or TLB handling */ 315 /* Initialize the hash table or TLB handling */
296 early_init_mmu_secondary(); 316 early_init_mmu_secondary();
317
318 /*
319 * At this point, we can let interrupts switch to virtual mode
320 * (the MMU has been setup), so adjust the MSR in the PACA to
321 * have IR and DR set.
322 */
323 cpu_ready_for_interrupts();
297} 324}
298 325
299#endif /* CONFIG_SMP */ 326#endif /* CONFIG_SMP */
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index a67e00aa3caa..4e47db686b5d 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -881,6 +881,8 @@ static long restore_tm_user_regs(struct pt_regs *regs,
881 * transactional versions should be loaded. 881 * transactional versions should be loaded.
882 */ 882 */
883 tm_enable(); 883 tm_enable();
884 /* Make sure the transaction is marked as failed */
885 current->thread.tm_texasr |= TEXASR_FS;
884 /* This loads the checkpointed FP/VEC state, if used */ 886 /* This loads the checkpointed FP/VEC state, if used */
885 tm_recheckpoint(&current->thread, msr); 887 tm_recheckpoint(&current->thread, msr);
886 /* Get the top half of the MSR */ 888 /* Get the top half of the MSR */
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 8d253c29649b..d501dc4dc3e6 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -527,6 +527,8 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
527 } 527 }
528#endif 528#endif
529 tm_enable(); 529 tm_enable();
530 /* Make sure the transaction is marked as failed */
531 current->thread.tm_texasr |= TEXASR_FS;
530 /* This loads the checkpointed FP/VEC state, if used */ 532 /* This loads the checkpointed FP/VEC state, if used */
531 tm_recheckpoint(&current->thread, msr); 533 tm_recheckpoint(&current->thread, msr);
532 534
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index ef47bcbd4352..03567c05950a 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -307,7 +307,7 @@ dont_backup_fp:
307 * Call with IRQs off, stacks get all out of sync for 307 * Call with IRQs off, stacks get all out of sync for
308 * some periods in here! 308 * some periods in here!
309 */ 309 */
310_GLOBAL(tm_recheckpoint) 310_GLOBAL(__tm_recheckpoint)
311 mfcr r5 311 mfcr r5
312 mflr r0 312 mflr r0
313 stw r5, 8(r1) 313 stw r5, 8(r1)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index df86f0ce2d36..1bd7ca298fa1 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1868,6 +1868,7 @@ struct ppc_emulated ppc_emulated = {
1868#ifdef CONFIG_PPC64 1868#ifdef CONFIG_PPC64
1869 WARN_EMULATED_SETUP(mfdscr), 1869 WARN_EMULATED_SETUP(mfdscr),
1870 WARN_EMULATED_SETUP(mtdscr), 1870 WARN_EMULATED_SETUP(mtdscr),
1871 WARN_EMULATED_SETUP(lq_stq),
1871#endif 1872#endif
1872}; 1873};
1873 1874
diff --git a/arch/powerpc/math-emu/mtfsf.c b/arch/powerpc/math-emu/mtfsf.c
index dbce92e4f046..44b0fc8214f4 100644
--- a/arch/powerpc/math-emu/mtfsf.c
+++ b/arch/powerpc/math-emu/mtfsf.c
@@ -11,48 +11,36 @@ mtfsf(unsigned int FM, u32 *frB)
11 u32 mask; 11 u32 mask;
12 u32 fpscr; 12 u32 fpscr;
13 13
14 if (FM == 0) 14 if (likely(FM == 1))
15 return 0; 15 mask = 0x0f;
16 16 else if (likely(FM == 0xff))
17 if (FM == 0xff) 17 mask = ~0;
18 mask = 0x9fffffff;
19 else { 18 else {
20 mask = 0; 19 mask = ((FM & 1) |
21 if (FM & (1 << 0)) 20 ((FM << 3) & 0x10) |
22 mask |= 0x90000000; 21 ((FM << 6) & 0x100) |
23 if (FM & (1 << 1)) 22 ((FM << 9) & 0x1000) |
24 mask |= 0x0f000000; 23 ((FM << 12) & 0x10000) |
25 if (FM & (1 << 2)) 24 ((FM << 15) & 0x100000) |
26 mask |= 0x00f00000; 25 ((FM << 18) & 0x1000000) |
27 if (FM & (1 << 3)) 26 ((FM << 21) & 0x10000000)) * 15;
28 mask |= 0x000f0000;
29 if (FM & (1 << 4))
30 mask |= 0x0000f000;
31 if (FM & (1 << 5))
32 mask |= 0x00000f00;
33 if (FM & (1 << 6))
34 mask |= 0x000000f0;
35 if (FM & (1 << 7))
36 mask |= 0x0000000f;
37 } 27 }
38 28
39 __FPU_FPSCR &= ~(mask); 29 fpscr = ((__FPU_FPSCR & ~mask) | (frB[1] & mask)) &
40 __FPU_FPSCR |= (frB[1] & mask); 30 ~(FPSCR_VX | FPSCR_FEX | 0x800);
41 31
42 __FPU_FPSCR &= ~(FPSCR_VX); 32 if (fpscr & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI |
43 if (__FPU_FPSCR & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI |
44 FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC | 33 FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC |
45 FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI)) 34 FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI))
46 __FPU_FPSCR |= FPSCR_VX; 35 fpscr |= FPSCR_VX;
47 36
48 fpscr = __FPU_FPSCR; 37 /* The bit order of exception enables and exception status
49 fpscr &= ~(FPSCR_FEX); 38 * is the same. Simply shift and mask to check for enabled
50 if (((fpscr & FPSCR_VX) && (fpscr & FPSCR_VE)) || 39 * exceptions.
51 ((fpscr & FPSCR_OX) && (fpscr & FPSCR_OE)) || 40 */
52 ((fpscr & FPSCR_UX) && (fpscr & FPSCR_UE)) || 41 if (fpscr & (fpscr >> 22) & 0xf8)
53 ((fpscr & FPSCR_ZX) && (fpscr & FPSCR_ZE)) ||
54 ((fpscr & FPSCR_XX) && (fpscr & FPSCR_XE)))
55 fpscr |= FPSCR_FEX; 42 fpscr |= FPSCR_FEX;
43
56 __FPU_FPSCR = fpscr; 44 __FPU_FPSCR = fpscr;
57 45
58#ifdef DEBUG 46#ifdef DEBUG
diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
index c5f734e20b0f..d8746684f606 100644
--- a/arch/powerpc/mm/gup.c
+++ b/arch/powerpc/mm/gup.c
@@ -36,6 +36,11 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
36 do { 36 do {
37 pte_t pte = ACCESS_ONCE(*ptep); 37 pte_t pte = ACCESS_ONCE(*ptep);
38 struct page *page; 38 struct page *page;
39 /*
40 * Similar to the PMD case, NUMA hinting must take slow path
41 */
42 if (pte_numa(pte))
43 return 0;
39 44
40 if ((pte_val(pte) & mask) != result) 45 if ((pte_val(pte) & mask) != result)
41 return 0; 46 return 0;
@@ -75,6 +80,14 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
75 if (pmd_none(pmd) || pmd_trans_splitting(pmd)) 80 if (pmd_none(pmd) || pmd_trans_splitting(pmd))
76 return 0; 81 return 0;
77 if (pmd_huge(pmd) || pmd_large(pmd)) { 82 if (pmd_huge(pmd) || pmd_large(pmd)) {
83 /*
84 * NUMA hinting faults need to be handled in the GUP
85 * slowpath for accounting purposes and so that they
86 * can be serialised against THP migration.
87 */
88 if (pmd_numa(pmd))
89 return 0;
90
78 if (!gup_hugepte((pte_t *)pmdp, PMD_SIZE, addr, next, 91 if (!gup_hugepte((pte_t *)pmdp, PMD_SIZE, addr, next,
79 write, pages, nr)) 92 write, pages, nr))
80 return 0; 93 return 0;
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 30a42e24bf14..4ebbb9e99286 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1591,6 +1591,20 @@ int arch_update_cpu_topology(void)
1591 cpu = cpu_last_thread_sibling(cpu); 1591 cpu = cpu_last_thread_sibling(cpu);
1592 } 1592 }
1593 1593
1594 /*
1595 * In cases where we have nothing to update (because the updates list
1596 * is too short or because the new topology is same as the old one),
1597 * skip invoking update_cpu_topology() via stop-machine(). This is
1598 * necessary (and not just a fast-path optimization) since stop-machine
1599 * can end up electing a random CPU to run update_cpu_topology(), and
1600 * thus trick us into setting up incorrect cpu-node mappings (since
1601 * 'updates' is kzalloc()'ed).
1602 *
1603 * And for the similar reason, we will skip all the following updating.
1604 */
1605 if (!cpumask_weight(&updated_cpus))
1606 goto out;
1607
1594 stop_machine(update_cpu_topology, &updates[0], &updated_cpus); 1608 stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
1595 1609
1596 /* 1610 /*
@@ -1612,6 +1626,7 @@ int arch_update_cpu_topology(void)
1612 changed = 1; 1626 changed = 1;
1613 } 1627 }
1614 1628
1629out:
1615 kfree(updates); 1630 kfree(updates);
1616 return changed; 1631 return changed;
1617} 1632}
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c
index 3844f1397fc3..38e0a1a5cec3 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -170,7 +170,7 @@ EXPORT_SYMBOL_GPL(register_spu_syscalls);
170void unregister_spu_syscalls(struct spufs_calls *calls) 170void unregister_spu_syscalls(struct spufs_calls *calls)
171{ 171{
172 BUG_ON(spufs_calls->owner != calls->owner); 172 BUG_ON(spufs_calls->owner != calls->owner);
173 rcu_assign_pointer(spufs_calls, NULL); 173 RCU_INIT_POINTER(spufs_calls, NULL);
174 synchronize_rcu(); 174 synchronize_rcu();
175} 175}
176EXPORT_SYMBOL_GPL(unregister_spu_syscalls); 176EXPORT_SYMBOL_GPL(unregister_spu_syscalls);
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
index 895e8a20a3fc..c252ee95bddf 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -11,6 +11,12 @@ config PPC_POWERNV
11 select PPC_UDBG_16550 11 select PPC_UDBG_16550
12 select PPC_SCOM 12 select PPC_SCOM
13 select ARCH_RANDOM 13 select ARCH_RANDOM
14 select CPU_FREQ
15 select CPU_FREQ_GOV_PERFORMANCE
16 select CPU_FREQ_GOV_POWERSAVE
17 select CPU_FREQ_GOV_USERSPACE
18 select CPU_FREQ_GOV_ONDEMAND
19 select CPU_FREQ_GOV_CONSERVATIVE
14 default y 20 default y
15 21
16config PPC_POWERNV_RTAS 22config PPC_POWERNV_RTAS
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
index f324ea099503..63cebb9b4d45 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -1,6 +1,7 @@
1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o opal-async.o 1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o opal-async.o
2obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o 2obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
3obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o 3obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
4obj-y += opal-msglog.o
4 5
5obj-$(CONFIG_SMP) += smp.o 6obj-$(CONFIG_SMP) += smp.o
6obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o 7obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c
index cd0c1354d404..32e2adfa5320 100644
--- a/arch/powerpc/platforms/powernv/opal-async.c
+++ b/arch/powerpc/platforms/powernv/opal-async.c
@@ -125,14 +125,15 @@ static int opal_async_comp_event(struct notifier_block *nb,
125{ 125{
126 struct opal_msg *comp_msg = msg; 126 struct opal_msg *comp_msg = msg;
127 unsigned long flags; 127 unsigned long flags;
128 uint64_t token;
128 129
129 if (msg_type != OPAL_MSG_ASYNC_COMP) 130 if (msg_type != OPAL_MSG_ASYNC_COMP)
130 return 0; 131 return 0;
131 132
132 memcpy(&opal_async_responses[comp_msg->params[0]], comp_msg, 133 token = be64_to_cpu(comp_msg->params[0]);
133 sizeof(*comp_msg)); 134 memcpy(&opal_async_responses[token], comp_msg, sizeof(*comp_msg));
134 spin_lock_irqsave(&opal_async_comp_lock, flags); 135 spin_lock_irqsave(&opal_async_comp_lock, flags);
135 __set_bit(comp_msg->params[0], opal_async_complete_map); 136 __set_bit(token, opal_async_complete_map);
136 spin_unlock_irqrestore(&opal_async_comp_lock, flags); 137 spin_unlock_irqrestore(&opal_async_comp_lock, flags);
137 138
138 wake_up(&opal_async_wait); 139 wake_up(&opal_async_wait);
diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
index 0c767c561dc9..b9827b0d87e4 100644
--- a/arch/powerpc/platforms/powernv/opal-dump.c
+++ b/arch/powerpc/platforms/powernv/opal-dump.c
@@ -86,19 +86,14 @@ static int64_t dump_send_ack(uint32_t dump_id)
86 return rc; 86 return rc;
87} 87}
88 88
89static void delay_release_kobj(void *kobj)
90{
91 kobject_put((struct kobject *)kobj);
92}
93
94static ssize_t dump_ack_store(struct dump_obj *dump_obj, 89static ssize_t dump_ack_store(struct dump_obj *dump_obj,
95 struct dump_attribute *attr, 90 struct dump_attribute *attr,
96 const char *buf, 91 const char *buf,
97 size_t count) 92 size_t count)
98{ 93{
99 dump_send_ack(dump_obj->id); 94 dump_send_ack(dump_obj->id);
100 sysfs_schedule_callback(&dump_obj->kobj, delay_release_kobj, 95 sysfs_remove_file_self(&dump_obj->kobj, &attr->attr);
101 &dump_obj->kobj, THIS_MODULE); 96 kobject_put(&dump_obj->kobj);
102 return count; 97 return count;
103} 98}
104 99
diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
index 1d7355bc9db0..ef7bc2a97862 100644
--- a/arch/powerpc/platforms/powernv/opal-elog.c
+++ b/arch/powerpc/platforms/powernv/opal-elog.c
@@ -70,19 +70,14 @@ static ssize_t elog_ack_show(struct elog_obj *elog_obj,
70 return sprintf(buf, "ack - acknowledge log message\n"); 70 return sprintf(buf, "ack - acknowledge log message\n");
71} 71}
72 72
73static void delay_release_kobj(void *kobj)
74{
75 kobject_put((struct kobject *)kobj);
76}
77
78static ssize_t elog_ack_store(struct elog_obj *elog_obj, 73static ssize_t elog_ack_store(struct elog_obj *elog_obj,
79 struct elog_attribute *attr, 74 struct elog_attribute *attr,
80 const char *buf, 75 const char *buf,
81 size_t count) 76 size_t count)
82{ 77{
83 opal_send_ack_elog(elog_obj->id); 78 opal_send_ack_elog(elog_obj->id);
84 sysfs_schedule_callback(&elog_obj->kobj, delay_release_kobj, 79 sysfs_remove_file_self(&elog_obj->kobj, &attr->attr);
85 &elog_obj->kobj, THIS_MODULE); 80 kobject_put(&elog_obj->kobj);
86 return count; 81 return count;
87} 82}
88 83
diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c b/arch/powerpc/platforms/powernv/opal-msglog.c
new file mode 100644
index 000000000000..1bb25b952504
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-msglog.c
@@ -0,0 +1,120 @@
1/*
2 * PowerNV OPAL in-memory console interface
3 *
4 * Copyright 2014 IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <asm/io.h>
13#include <asm/opal.h>
14#include <linux/debugfs.h>
15#include <linux/of.h>
16#include <linux/types.h>
17#include <asm/barrier.h>
18
19/* OPAL in-memory console. Defined in OPAL source at core/console.c */
20struct memcons {
21 __be64 magic;
22#define MEMCONS_MAGIC 0x6630696567726173L
23 __be64 obuf_phys;
24 __be64 ibuf_phys;
25 __be32 obuf_size;
26 __be32 ibuf_size;
27 __be32 out_pos;
28#define MEMCONS_OUT_POS_WRAP 0x80000000u
29#define MEMCONS_OUT_POS_MASK 0x00ffffffu
30 __be32 in_prod;
31 __be32 in_cons;
32};
33
34static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj,
35 struct bin_attribute *bin_attr, char *to,
36 loff_t pos, size_t count)
37{
38 struct memcons *mc = bin_attr->private;
39 const char *conbuf;
40 size_t ret, first_read = 0;
41 uint32_t out_pos, avail;
42
43 if (!mc)
44 return -ENODEV;
45
46 out_pos = be32_to_cpu(ACCESS_ONCE(mc->out_pos));
47
48 /* Now we've read out_pos, put a barrier in before reading the new
49 * data it points to in conbuf. */
50 smp_rmb();
51
52 conbuf = phys_to_virt(be64_to_cpu(mc->obuf_phys));
53
54 /* When the buffer has wrapped, read from the out_pos marker to the end
55 * of the buffer, and then read the remaining data as in the un-wrapped
56 * case. */
57 if (out_pos & MEMCONS_OUT_POS_WRAP) {
58
59 out_pos &= MEMCONS_OUT_POS_MASK;
60 avail = be32_to_cpu(mc->obuf_size) - out_pos;
61
62 ret = memory_read_from_buffer(to, count, &pos,
63 conbuf + out_pos, avail);
64
65 if (ret < 0)
66 goto out;
67
68 first_read = ret;
69 to += first_read;
70 count -= first_read;
71 pos -= avail;
72 }
73
74 /* Sanity check. The firmware should not do this to us. */
75 if (out_pos > be32_to_cpu(mc->obuf_size)) {
76 pr_err("OPAL: memory console corruption. Aborting read.\n");
77 return -EINVAL;
78 }
79
80 ret = memory_read_from_buffer(to, count, &pos, conbuf, out_pos);
81
82 if (ret < 0)
83 goto out;
84
85 ret += first_read;
86out:
87 return ret;
88}
89
90static struct bin_attribute opal_msglog_attr = {
91 .attr = {.name = "msglog", .mode = 0444},
92 .read = opal_msglog_read
93};
94
95void __init opal_msglog_init(void)
96{
97 u64 mcaddr;
98 struct memcons *mc;
99
100 if (of_property_read_u64(opal_node, "ibm,opal-memcons", &mcaddr)) {
101 pr_warn("OPAL: Property ibm,opal-memcons not found, no message log\n");
102 return;
103 }
104
105 mc = phys_to_virt(mcaddr);
106 if (!mc) {
107 pr_warn("OPAL: memory console address is invalid\n");
108 return;
109 }
110
111 if (be64_to_cpu(mc->magic) != MEMCONS_MAGIC) {
112 pr_warn("OPAL: memory console version is invalid\n");
113 return;
114 }
115
116 opal_msglog_attr.private = mc;
117
118 if (sysfs_create_bin_file(opal_kobj, &opal_msglog_attr) != 0)
119 pr_warn("OPAL: sysfs file creation failed\n");
120}
diff --git a/arch/powerpc/platforms/powernv/opal-sensor.c b/arch/powerpc/platforms/powernv/opal-sensor.c
index 663cc9c65613..10271ad1fac4 100644
--- a/arch/powerpc/platforms/powernv/opal-sensor.c
+++ b/arch/powerpc/platforms/powernv/opal-sensor.c
@@ -33,6 +33,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
33{ 33{
34 int ret, token; 34 int ret, token;
35 struct opal_msg msg; 35 struct opal_msg msg;
36 __be32 data;
36 37
37 token = opal_async_get_token_interruptible(); 38 token = opal_async_get_token_interruptible();
38 if (token < 0) { 39 if (token < 0) {
@@ -42,7 +43,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
42 } 43 }
43 44
44 mutex_lock(&opal_sensor_mutex); 45 mutex_lock(&opal_sensor_mutex);
45 ret = opal_sensor_read(sensor_hndl, token, sensor_data); 46 ret = opal_sensor_read(sensor_hndl, token, &data);
46 if (ret != OPAL_ASYNC_COMPLETION) 47 if (ret != OPAL_ASYNC_COMPLETION)
47 goto out_token; 48 goto out_token;
48 49
@@ -53,7 +54,8 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
53 goto out_token; 54 goto out_token;
54 } 55 }
55 56
56 ret = msg.params[1]; 57 *sensor_data = be32_to_cpu(data);
58 ret = be64_to_cpu(msg.params[1]);
57 59
58out_token: 60out_token:
59 mutex_unlock(&opal_sensor_mutex); 61 mutex_unlock(&opal_sensor_mutex);
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 0bd249a26f30..6b614726baf2 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -64,7 +64,7 @@ static int opal_get_sys_param(u32 param_id, u32 length, void *buffer)
64 goto out_token; 64 goto out_token;
65 } 65 }
66 66
67 ret = msg.params[1]; 67 ret = be64_to_cpu(msg.params[1]);
68 68
69out_token: 69out_token:
70 opal_async_release_token(token); 70 opal_async_release_token(token);
@@ -98,7 +98,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer)
98 goto out_token; 98 goto out_token;
99 } 99 }
100 100
101 ret = msg.params[1]; 101 ret = be64_to_cpu(msg.params[1]);
102 102
103out_token: 103out_token:
104 opal_async_release_token(token); 104 opal_async_release_token(token);
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index bb90f9a4e027..f531ffe35b3e 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -61,6 +61,7 @@ _STATIC(opal_return)
61 mtcr r4; 61 mtcr r4;
62 rfid 62 rfid
63 63
64OPAL_CALL(opal_invalid_call, OPAL_INVALID_CALL);
64OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE); 65OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE);
65OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ); 66OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ);
66OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE); 67OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE);
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index e92f2f67640f..49d2f00019e5 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -46,7 +46,7 @@ struct mcheck_recoverable_range {
46static struct mcheck_recoverable_range *mc_recoverable_range; 46static struct mcheck_recoverable_range *mc_recoverable_range;
47static int mc_recoverable_range_len; 47static int mc_recoverable_range_len;
48 48
49static struct device_node *opal_node; 49struct device_node *opal_node;
50static DEFINE_SPINLOCK(opal_write_lock); 50static DEFINE_SPINLOCK(opal_write_lock);
51extern u64 opal_mc_secondary_handler[]; 51extern u64 opal_mc_secondary_handler[];
52static unsigned int *opal_irqs; 52static unsigned int *opal_irqs;
@@ -102,13 +102,13 @@ int __init early_init_dt_scan_opal(unsigned long node,
102int __init early_init_dt_scan_recoverable_ranges(unsigned long node, 102int __init early_init_dt_scan_recoverable_ranges(unsigned long node,
103 const char *uname, int depth, void *data) 103 const char *uname, int depth, void *data)
104{ 104{
105 unsigned long i, size; 105 unsigned long i, psize, size;
106 const __be32 *prop; 106 const __be32 *prop;
107 107
108 if (depth != 1 || strcmp(uname, "ibm,opal") != 0) 108 if (depth != 1 || strcmp(uname, "ibm,opal") != 0)
109 return 0; 109 return 0;
110 110
111 prop = of_get_flat_dt_prop(node, "mcheck-recoverable-ranges", &size); 111 prop = of_get_flat_dt_prop(node, "mcheck-recoverable-ranges", &psize);
112 112
113 if (!prop) 113 if (!prop)
114 return 1; 114 return 1;
@@ -116,6 +116,23 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node,
116 pr_debug("Found machine check recoverable ranges.\n"); 116 pr_debug("Found machine check recoverable ranges.\n");
117 117
118 /* 118 /*
119 * Calculate number of available entries.
120 *
121 * Each recoverable address range entry is (start address, len,
122 * recovery address), 2 cells each for start and recovery address,
123 * 1 cell for len, totalling 5 cells per entry.
124 */
125 mc_recoverable_range_len = psize / (sizeof(*prop) * 5);
126
127 /* Sanity check */
128 if (!mc_recoverable_range_len)
129 return 1;
130
131 /* Size required to hold all the entries. */
132 size = mc_recoverable_range_len *
133 sizeof(struct mcheck_recoverable_range);
134
135 /*
119 * Allocate a buffer to hold the MC recoverable ranges. We would be 136 * Allocate a buffer to hold the MC recoverable ranges. We would be
120 * accessing them in real mode, hence it needs to be within 137 * accessing them in real mode, hence it needs to be within
121 * RMO region. 138 * RMO region.
@@ -124,11 +141,7 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node,
124 ppc64_rma_size)); 141 ppc64_rma_size));
125 memset(mc_recoverable_range, 0, size); 142 memset(mc_recoverable_range, 0, size);
126 143
127 /* 144 for (i = 0; i < mc_recoverable_range_len; i++) {
128 * Each recoverable address entry is an (start address,len,
129 * recover address) pair, * 2 cells each, totalling 4 cells per entry.
130 */
131 for (i = 0; i < size / (sizeof(*prop) * 5); i++) {
132 mc_recoverable_range[i].start_addr = 145 mc_recoverable_range[i].start_addr =
133 of_read_number(prop + (i * 5) + 0, 2); 146 of_read_number(prop + (i * 5) + 0, 2);
134 mc_recoverable_range[i].end_addr = 147 mc_recoverable_range[i].end_addr =
@@ -142,7 +155,6 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node,
142 mc_recoverable_range[i].end_addr, 155 mc_recoverable_range[i].end_addr,
143 mc_recoverable_range[i].recover_addr); 156 mc_recoverable_range[i].recover_addr);
144 } 157 }
145 mc_recoverable_range_len = i;
146 return 1; 158 return 1;
147} 159}
148 160
@@ -180,6 +192,20 @@ int opal_notifier_register(struct notifier_block *nb)
180 atomic_notifier_chain_register(&opal_notifier_head, nb); 192 atomic_notifier_chain_register(&opal_notifier_head, nb);
181 return 0; 193 return 0;
182} 194}
195EXPORT_SYMBOL_GPL(opal_notifier_register);
196
197int opal_notifier_unregister(struct notifier_block *nb)
198{
199 if (!nb) {
200 pr_warning("%s: Invalid argument (%p)\n",
201 __func__, nb);
202 return -EINVAL;
203 }
204
205 atomic_notifier_chain_unregister(&opal_notifier_head, nb);
206 return 0;
207}
208EXPORT_SYMBOL_GPL(opal_notifier_unregister);
183 209
184static void opal_do_notifier(uint64_t events) 210static void opal_do_notifier(uint64_t events)
185{ 211{
@@ -267,6 +293,7 @@ static void opal_handle_message(void)
267 * value in /proc/device-tree. 293 * value in /proc/device-tree.
268 */ 294 */
269 static struct opal_msg msg; 295 static struct opal_msg msg;
296 u32 type;
270 297
271 ret = opal_get_msg(__pa(&msg), sizeof(msg)); 298 ret = opal_get_msg(__pa(&msg), sizeof(msg));
272 /* No opal message pending. */ 299 /* No opal message pending. */
@@ -280,13 +307,14 @@ static void opal_handle_message(void)
280 return; 307 return;
281 } 308 }
282 309
310 type = be32_to_cpu(msg.msg_type);
311
283 /* Sanity check */ 312 /* Sanity check */
284 if (msg.msg_type > OPAL_MSG_TYPE_MAX) { 313 if (type > OPAL_MSG_TYPE_MAX) {
285 pr_warning("%s: Unknown message type: %u\n", 314 pr_warning("%s: Unknown message type: %u\n", __func__, type);
286 __func__, msg.msg_type);
287 return; 315 return;
288 } 316 }
289 opal_message_do_notify(msg.msg_type, (void *)&msg); 317 opal_message_do_notify(type, (void *)&msg);
290} 318}
291 319
292static int opal_message_notify(struct notifier_block *nb, 320static int opal_message_notify(struct notifier_block *nb,
@@ -574,6 +602,8 @@ static int __init opal_init(void)
574 opal_platform_dump_init(); 602 opal_platform_dump_init();
575 /* Setup system parameters interface */ 603 /* Setup system parameters interface */
576 opal_sys_param_init(); 604 opal_sys_param_init();
605 /* Setup message log interface. */
606 opal_msglog_init();
577 } 607 }
578 608
579 return 0; 609 return 0;
@@ -605,3 +635,6 @@ void opal_shutdown(void)
605 mdelay(10); 635 mdelay(10);
606 } 636 }
607} 637}
638
639/* Export this so that test modules can use it */
640EXPORT_SYMBOL_GPL(opal_invalid_call);
diff --git a/arch/powerpc/platforms/pseries/io_event_irq.c b/arch/powerpc/platforms/pseries/io_event_irq.c
index 5ea88d1541f7..0240c4ff878a 100644
--- a/arch/powerpc/platforms/pseries/io_event_irq.c
+++ b/arch/powerpc/platforms/pseries/io_event_irq.c
@@ -82,9 +82,9 @@ static struct pseries_io_event * ioei_find_event(struct rtas_error_log *elog)
82 * RTAS_TYPE_IO only exists in extended event log version 6 or later. 82 * RTAS_TYPE_IO only exists in extended event log version 6 or later.
83 * No need to check event log version. 83 * No need to check event log version.
84 */ 84 */
85 if (unlikely(elog->type != RTAS_TYPE_IO)) { 85 if (unlikely(rtas_error_type(elog) != RTAS_TYPE_IO)) {
86 printk_once(KERN_WARNING "io_event_irq: Unexpected event type %d", 86 printk_once(KERN_WARNING"io_event_irq: Unexpected event type %d",
87 elog->type); 87 rtas_error_type(elog));
88 return NULL; 88 return NULL;
89 } 89 }
90 90
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index d7096f2f7751..0cc240b7f694 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -298,13 +298,13 @@ int nvram_write_os_partition(struct nvram_os_partition *part, char * buff,
298 298
299 rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index); 299 rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index);
300 if (rc <= 0) { 300 if (rc <= 0) {
301 pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc); 301 pr_err("%s: Failed nvram_write (%d)\n", __func__, rc);
302 return rc; 302 return rc;
303 } 303 }
304 304
305 rc = ppc_md.nvram_write(buff, length, &tmp_index); 305 rc = ppc_md.nvram_write(buff, length, &tmp_index);
306 if (rc <= 0) { 306 if (rc <= 0) {
307 pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc); 307 pr_err("%s: Failed nvram_write (%d)\n", __func__, rc);
308 return rc; 308 return rc;
309 } 309 }
310 310
@@ -351,15 +351,14 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff,
351 sizeof(struct err_log_info), 351 sizeof(struct err_log_info),
352 &tmp_index); 352 &tmp_index);
353 if (rc <= 0) { 353 if (rc <= 0) {
354 pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__, 354 pr_err("%s: Failed nvram_read (%d)\n", __func__, rc);
355 rc);
356 return rc; 355 return rc;
357 } 356 }
358 } 357 }
359 358
360 rc = ppc_md.nvram_read(buff, length, &tmp_index); 359 rc = ppc_md.nvram_read(buff, length, &tmp_index);
361 if (rc <= 0) { 360 if (rc <= 0) {
362 pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__, rc); 361 pr_err("%s: Failed nvram_read (%d)\n", __func__, rc);
363 return rc; 362 return rc;
364 } 363 }
365 364
@@ -869,7 +868,7 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
869 break; 868 break;
870 default: 869 default:
871 pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", 870 pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n",
872 __FUNCTION__, (int) reason); 871 __func__, (int) reason);
873 return; 872 return;
874 } 873 }
875 874
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 721c0586b284..9c5778e6ed4b 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -236,7 +236,8 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
236 236
237 rtas_elog = (struct rtas_error_log *)ras_log_buf; 237 rtas_elog = (struct rtas_error_log *)ras_log_buf;
238 238
239 if ((status == 0) && (rtas_elog->severity >= RTAS_SEVERITY_ERROR_SYNC)) 239 if (status == 0 &&
240 rtas_error_severity(rtas_elog) >= RTAS_SEVERITY_ERROR_SYNC)
240 fatal = 1; 241 fatal = 1;
241 else 242 else
242 fatal = 0; 243 fatal = 0;
@@ -300,13 +301,14 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
300 301
301 /* If it isn't an extended log we can use the per cpu 64bit buffer */ 302 /* If it isn't an extended log we can use the per cpu 64bit buffer */
302 h = (struct rtas_error_log *)&savep[1]; 303 h = (struct rtas_error_log *)&savep[1];
303 if (!h->extended) { 304 if (!rtas_error_extended(h)) {
304 memcpy(&__get_cpu_var(mce_data_buf), h, sizeof(__u64)); 305 memcpy(&__get_cpu_var(mce_data_buf), h, sizeof(__u64));
305 errhdr = (struct rtas_error_log *)&__get_cpu_var(mce_data_buf); 306 errhdr = (struct rtas_error_log *)&__get_cpu_var(mce_data_buf);
306 } else { 307 } else {
307 int len; 308 int len, error_log_length;
308 309
309 len = max_t(int, 8+h->extended_log_length, RTAS_ERROR_LOG_MAX); 310 error_log_length = 8 + rtas_error_extended_log_length(h);
311 len = max_t(int, error_log_length, RTAS_ERROR_LOG_MAX);
310 memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX); 312 memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX);
311 memcpy(global_mce_data_buf, h, len); 313 memcpy(global_mce_data_buf, h, len);
312 errhdr = (struct rtas_error_log *)global_mce_data_buf; 314 errhdr = (struct rtas_error_log *)global_mce_data_buf;
@@ -350,23 +352,24 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
350static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err) 352static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err)
351{ 353{
352 int recovered = 0; 354 int recovered = 0;
355 int disposition = rtas_error_disposition(err);
353 356
354 if (!(regs->msr & MSR_RI)) { 357 if (!(regs->msr & MSR_RI)) {
355 /* If MSR_RI isn't set, we cannot recover */ 358 /* If MSR_RI isn't set, we cannot recover */
356 recovered = 0; 359 recovered = 0;
357 360
358 } else if (err->disposition == RTAS_DISP_FULLY_RECOVERED) { 361 } else if (disposition == RTAS_DISP_FULLY_RECOVERED) {
359 /* Platform corrected itself */ 362 /* Platform corrected itself */
360 recovered = 1; 363 recovered = 1;
361 364
362 } else if (err->disposition == RTAS_DISP_LIMITED_RECOVERY) { 365 } else if (disposition == RTAS_DISP_LIMITED_RECOVERY) {
363 /* Platform corrected itself but could be degraded */ 366 /* Platform corrected itself but could be degraded */
364 printk(KERN_ERR "MCE: limited recovery, system may " 367 printk(KERN_ERR "MCE: limited recovery, system may "
365 "be degraded\n"); 368 "be degraded\n");
366 recovered = 1; 369 recovered = 1;
367 370
368 } else if (user_mode(regs) && !is_global_init(current) && 371 } else if (user_mode(regs) && !is_global_init(current) &&
369 err->severity == RTAS_SEVERITY_ERROR_SYNC) { 372 rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) {
370 373
371 /* 374 /*
372 * If we received a synchronous error when in userspace 375 * If we received a synchronous error when in userspace
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c
index 8ba60424be95..2ff630267e9e 100644
--- a/arch/powerpc/sysdev/msi_bitmap.c
+++ b/arch/powerpc/sysdev/msi_bitmap.c
@@ -202,7 +202,7 @@ void __init test_of_node(void)
202 202
203 /* There should really be a struct device_node allocator */ 203 /* There should really be a struct device_node allocator */
204 memset(&of_node, 0, sizeof(of_node)); 204 memset(&of_node, 0, sizeof(of_node));
205 kref_init(&of_node.kobj.kref); 205 of_node_init(&of_node);
206 of_node.full_name = node_name; 206 of_node.full_name = node_name;
207 207
208 check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); 208 check(0 == msi_bitmap_alloc(&bmp, size, &of_node));
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 346d21678ffd..d68fe34799b0 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -103,6 +103,7 @@ config S390
103 select GENERIC_SMP_IDLE_THREAD 103 select GENERIC_SMP_IDLE_THREAD
104 select GENERIC_TIME_VSYSCALL 104 select GENERIC_TIME_VSYSCALL
105 select HAVE_ALIGNED_STRUCT_PAGE if SLUB 105 select HAVE_ALIGNED_STRUCT_PAGE if SLUB
106 select HAVE_ARCH_AUDITSYSCALL
106 select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 107 select HAVE_ARCH_JUMP_LABEL if !MARCH_G5
107 select HAVE_ARCH_SECCOMP_FILTER 108 select HAVE_ARCH_SECCOMP_FILTER
108 select HAVE_ARCH_TRACEHOOK 109 select HAVE_ARCH_TRACEHOOK
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig
index ddaae2f5c913..8df022c43af7 100644
--- a/arch/s390/configs/default_defconfig
+++ b/arch/s390/configs/default_defconfig
@@ -581,7 +581,6 @@ CONFIG_LOCK_STAT=y
581CONFIG_DEBUG_LOCKDEP=y 581CONFIG_DEBUG_LOCKDEP=y
582CONFIG_DEBUG_ATOMIC_SLEEP=y 582CONFIG_DEBUG_ATOMIC_SLEEP=y
583CONFIG_DEBUG_LOCKING_API_SELFTESTS=y 583CONFIG_DEBUG_LOCKING_API_SELFTESTS=y
584CONFIG_DEBUG_WRITECOUNT=y
585CONFIG_DEBUG_LIST=y 584CONFIG_DEBUG_LIST=y
586CONFIG_DEBUG_SG=y 585CONFIG_DEBUG_SG=y
587CONFIG_DEBUG_NOTIFIERS=y 586CONFIG_DEBUG_NOTIFIERS=y
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
index cd29d2f4e4f3..777687055e7b 100644
--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -12,7 +12,7 @@
12#ifndef _ASM_SYSCALL_H 12#ifndef _ASM_SYSCALL_H
13#define _ASM_SYSCALL_H 1 13#define _ASM_SYSCALL_H 1
14 14
15#include <linux/audit.h> 15#include <uapi/linux/audit.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
@@ -89,11 +89,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
89 regs->orig_gpr2 = args[0]; 89 regs->orig_gpr2 = args[0];
90} 90}
91 91
92static inline int syscall_get_arch(struct task_struct *task, 92static inline int syscall_get_arch(void)
93 struct pt_regs *regs)
94{ 93{
95#ifdef CONFIG_COMPAT 94#ifdef CONFIG_COMPAT
96 if (test_tsk_thread_flag(task, TIF_31BIT)) 95 if (test_tsk_thread_flag(current, TIF_31BIT))
97 return AUDIT_ARCH_S390; 96 return AUDIT_ARCH_S390;
98#endif 97#endif
99 return sizeof(long) == 8 ? AUDIT_ARCH_S390X : AUDIT_ARCH_S390; 98 return sizeof(long) == 8 ? AUDIT_ARCH_S390X : AUDIT_ARCH_S390;
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ba55e939a820..834b67c4db5a 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -42,6 +42,7 @@ config SUPERH
42 select MODULES_USE_ELF_RELA 42 select MODULES_USE_ELF_RELA
43 select OLD_SIGSUSPEND 43 select OLD_SIGSUSPEND
44 select OLD_SIGACTION 44 select OLD_SIGACTION
45 select HAVE_ARCH_AUDITSYSCALL
45 help 46 help
46 The SuperH is a RISC processor targeted for use in embedded systems 47 The SuperH is a RISC processor targeted for use in embedded systems
47 and consumer electronics; it was also used in the Sega Dreamcast 48 and consumer electronics; it was also used in the Sega Dreamcast
diff --git a/arch/sh/configs/rsk7203_defconfig b/arch/sh/configs/rsk7203_defconfig
index 4e5229b0c5bb..47236573db83 100644
--- a/arch/sh/configs/rsk7203_defconfig
+++ b/arch/sh/configs/rsk7203_defconfig
@@ -128,7 +128,6 @@ CONFIG_DEBUG_MUTEXES=y
128CONFIG_DEBUG_SPINLOCK_SLEEP=y 128CONFIG_DEBUG_SPINLOCK_SLEEP=y
129CONFIG_DEBUG_INFO=y 129CONFIG_DEBUG_INFO=y
130CONFIG_DEBUG_VM=y 130CONFIG_DEBUG_VM=y
131CONFIG_DEBUG_WRITECOUNT=y
132CONFIG_DEBUG_LIST=y 131CONFIG_DEBUG_LIST=y
133CONFIG_DEBUG_SG=y 132CONFIG_DEBUG_SG=y
134CONFIG_FRAME_POINTER=y 133CONFIG_FRAME_POINTER=y
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 7d8b7e94b93b..29f2e988c56a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -77,6 +77,7 @@ config SPARC64
77 select ARCH_HAVE_NMI_SAFE_CMPXCHG 77 select ARCH_HAVE_NMI_SAFE_CMPXCHG
78 select HAVE_C_RECORDMCOUNT 78 select HAVE_C_RECORDMCOUNT
79 select NO_BOOTMEM 79 select NO_BOOTMEM
80 select HAVE_ARCH_AUDITSYSCALL
80 81
81config ARCH_DEFCONFIG 82config ARCH_DEFCONFIG
82 string 83 string
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 21ca44c4f6d5..6915d28cf118 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -1,6 +1,7 @@
1config UML 1config UML
2 bool 2 bool
3 default y 3 default y
4 select HAVE_ARCH_AUDITSYSCALL
4 select HAVE_UID16 5 select HAVE_UID16
5 select GENERIC_IRQ_SHOW 6 select GENERIC_IRQ_SHOW
6 select GENERIC_CPU_DEVICES 7 select GENERIC_CPU_DEVICES
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5b8ec0f53b57..25d2c6f7325e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -129,6 +129,7 @@ config X86
129 select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 129 select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
130 select HAVE_CC_STACKPROTECTOR 130 select HAVE_CC_STACKPROTECTOR
131 select GENERIC_CPU_AUTOPROBE 131 select GENERIC_CPU_AUTOPROBE
132 select HAVE_ARCH_AUDITSYSCALL
132 133
133config INSTRUCTION_DECODER 134config INSTRUCTION_DECODER
134 def_bool y 135 def_bool y
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 3b9348a0c1a4..602f57e590b5 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -108,7 +108,7 @@ else
108 108
109 # this works around some issues with generating unwind tables in older gccs 109 # this works around some issues with generating unwind tables in older gccs
110 # newer gccs do it by default 110 # newer gccs do it by default
111 KBUILD_CFLAGS += -maccumulate-outgoing-args 111 KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
112endif 112endif
113 113
114# Make sure compiler does not have buggy stack-protector support. 114# Make sure compiler does not have buggy stack-protector support.
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 1e6146137f8e..4703a6c4b8e3 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -112,7 +112,7 @@ __file_size64(void *__fh, efi_char16_t *filename_16,
112 efi_file_info_t *info; 112 efi_file_info_t *info;
113 efi_status_t status; 113 efi_status_t status;
114 efi_guid_t info_guid = EFI_FILE_INFO_ID; 114 efi_guid_t info_guid = EFI_FILE_INFO_ID;
115 u32 info_sz; 115 u64 info_sz;
116 116
117 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16, 117 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16,
118 EFI_FILE_MODE_READ, (u64)0); 118 EFI_FILE_MODE_READ, (u64)0);
@@ -167,31 +167,31 @@ efi_file_size(efi_system_table_t *sys_table, void *__fh,
167} 167}
168 168
169static inline efi_status_t 169static inline efi_status_t
170efi_file_read(void *__fh, void *handle, unsigned long *size, void *addr) 170efi_file_read(void *handle, unsigned long *size, void *addr)
171{ 171{
172 unsigned long func; 172 unsigned long func;
173 173
174 if (efi_early->is64) { 174 if (efi_early->is64) {
175 efi_file_handle_64_t *fh = __fh; 175 efi_file_handle_64_t *fh = handle;
176 176
177 func = (unsigned long)fh->read; 177 func = (unsigned long)fh->read;
178 return efi_early->call(func, handle, size, addr); 178 return efi_early->call(func, handle, size, addr);
179 } else { 179 } else {
180 efi_file_handle_32_t *fh = __fh; 180 efi_file_handle_32_t *fh = handle;
181 181
182 func = (unsigned long)fh->read; 182 func = (unsigned long)fh->read;
183 return efi_early->call(func, handle, size, addr); 183 return efi_early->call(func, handle, size, addr);
184 } 184 }
185} 185}
186 186
187static inline efi_status_t efi_file_close(void *__fh, void *handle) 187static inline efi_status_t efi_file_close(void *handle)
188{ 188{
189 if (efi_early->is64) { 189 if (efi_early->is64) {
190 efi_file_handle_64_t *fh = __fh; 190 efi_file_handle_64_t *fh = handle;
191 191
192 return efi_early->call((unsigned long)fh->close, handle); 192 return efi_early->call((unsigned long)fh->close, handle);
193 } else { 193 } else {
194 efi_file_handle_32_t *fh = __fh; 194 efi_file_handle_32_t *fh = handle;
195 195
196 return efi_early->call((unsigned long)fh->close, handle); 196 return efi_early->call((unsigned long)fh->close, handle);
197 } 197 }
@@ -1016,6 +1016,9 @@ void setup_graphics(struct boot_params *boot_params)
1016 * Because the x86 boot code expects to be passed a boot_params we 1016 * Because the x86 boot code expects to be passed a boot_params we
1017 * need to create one ourselves (usually the bootloader would create 1017 * need to create one ourselves (usually the bootloader would create
1018 * one for us). 1018 * one for us).
1019 *
1020 * The caller is responsible for filling out ->code32_start in the
1021 * returned boot_params.
1019 */ 1022 */
1020struct boot_params *make_boot_params(struct efi_config *c) 1023struct boot_params *make_boot_params(struct efi_config *c)
1021{ 1024{
@@ -1081,8 +1084,6 @@ struct boot_params *make_boot_params(struct efi_config *c)
1081 hdr->vid_mode = 0xffff; 1084 hdr->vid_mode = 0xffff;
1082 hdr->boot_flag = 0xAA55; 1085 hdr->boot_flag = 0xAA55;
1083 1086
1084 hdr->code32_start = (__u64)(unsigned long)image->image_base;
1085
1086 hdr->type_of_loader = 0x21; 1087 hdr->type_of_loader = 0x21;
1087 1088
1088 /* Convert unicode cmdline to ascii */ 1089 /* Convert unicode cmdline to ascii */
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index de9d4200d305..cbed1407a5cd 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -59,6 +59,7 @@ ENTRY(efi_pe_entry)
59 call make_boot_params 59 call make_boot_params
60 cmpl $0, %eax 60 cmpl $0, %eax
61 je fail 61 je fail
62 movl %esi, BP_code32_start(%eax)
62 popl %ecx 63 popl %ecx
63 pushl %eax 64 pushl %eax
64 pushl %ecx 65 pushl %ecx
@@ -90,12 +91,7 @@ fail:
90 hlt 91 hlt
91 jmp fail 92 jmp fail
922: 932:
93 call 3f 94 movl BP_code32_start(%esi), %eax
943:
95 popl %eax
96 subl $3b, %eax
97 subl BP_pref_address(%esi), %eax
98 add BP_code32_start(%esi), %eax
99 leal preferred_addr(%eax), %eax 95 leal preferred_addr(%eax), %eax
100 jmp *%eax 96 jmp *%eax
101 97
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 57e58a5fa210..0d558ee899ae 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -261,6 +261,8 @@ ENTRY(efi_pe_entry)
261 cmpq $0,%rax 261 cmpq $0,%rax
262 je fail 262 je fail
263 mov %rax, %rsi 263 mov %rax, %rsi
264 leaq startup_32(%rip), %rax
265 movl %eax, BP_code32_start(%rsi)
264 jmp 2f /* Skip the relocation */ 266 jmp 2f /* Skip the relocation */
265 267
266handover_entry: 268handover_entry:
@@ -284,12 +286,7 @@ fail:
284 hlt 286 hlt
285 jmp fail 287 jmp fail
2862: 2882:
287 call 3f 289 movl BP_code32_start(%esi), %eax
2883:
289 popq %rax
290 subq $3b, %rax
291 subq BP_pref_address(%rsi), %rax
292 add BP_code32_start(%esi), %eax
293 leaq preferred_addr(%rax), %rax 290 leaq preferred_addr(%rax), %rax
294 jmp *%rax 291 jmp *%rax
295 292
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index aea284b41312..d6a756ae04c8 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -13,7 +13,7 @@
13#ifndef _ASM_X86_SYSCALL_H 13#ifndef _ASM_X86_SYSCALL_H
14#define _ASM_X86_SYSCALL_H 14#define _ASM_X86_SYSCALL_H
15 15
16#include <linux/audit.h> 16#include <uapi/linux/audit.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <asm/asm-offsets.h> /* For NR_syscalls */ 19#include <asm/asm-offsets.h> /* For NR_syscalls */
@@ -91,8 +91,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
91 memcpy(&regs->bx + i, args, n * sizeof(args[0])); 91 memcpy(&regs->bx + i, args, n * sizeof(args[0]));
92} 92}
93 93
94static inline int syscall_get_arch(struct task_struct *task, 94static inline int syscall_get_arch(void)
95 struct pt_regs *regs)
96{ 95{
97 return AUDIT_ARCH_I386; 96 return AUDIT_ARCH_I386;
98} 97}
@@ -221,8 +220,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
221 } 220 }
222} 221}
223 222
224static inline int syscall_get_arch(struct task_struct *task, 223static inline int syscall_get_arch(void)
225 struct pt_regs *regs)
226{ 224{
227#ifdef CONFIG_IA32_EMULATION 225#ifdef CONFIG_IA32_EMULATION
228 /* 226 /*
@@ -234,7 +232,7 @@ static inline int syscall_get_arch(struct task_struct *task,
234 * 232 *
235 * x32 tasks should be considered AUDIT_ARCH_X86_64. 233 * x32 tasks should be considered AUDIT_ARCH_X86_64.
236 */ 234 */
237 if (task_thread_info(task)->status & TS_COMPAT) 235 if (task_thread_info(current)->status & TS_COMPAT)
238 return AUDIT_ARCH_I386; 236 return AUDIT_ARCH_I386;
239#endif 237#endif
240 /* Both x32 and x86_64 are considered "64-bit". */ 238 /* Both x32 and x86_64 are considered "64-bit". */
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index e69182fd01cf..4b28159e0421 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -87,7 +87,9 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
87 num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK; 87 num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK;
88 88
89 retval = 0; 89 retval = 0;
90 if (num_cstate_subtype < (cx->address & MWAIT_SUBSTATE_MASK)) { 90 /* If the HW does not support any sub-states in this C-state */
91 if (num_cstate_subtype == 0) {
92 pr_warn(FW_BUG "ACPI MWAIT C-state 0x%x not supported by HW (0x%x)\n", cx->address, edx_part);
91 retval = -1; 93 retval = -1;
92 goto out; 94 goto out;
93 } 95 }
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 481ae38f6a44..ad28db7e6bde 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1996,7 +1996,8 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
1996 }; 1996 };
1997 1997
1998 /* First tickle the hardware, only then report what went on. -- REW */ 1998 /* First tickle the hardware, only then report what went on. -- REW */
1999 apic_write(APIC_ESR, 0); 1999 if (lapic_get_maxlvt() > 3) /* Due to the Pentium erratum 3AP. */
2000 apic_write(APIC_ESR, 0);
2000 v = apic_read(APIC_ESR); 2001 v = apic_read(APIC_ESR);
2001 ack_APIC_irq(); 2002 ack_APIC_irq();
2002 atomic_inc(&irq_err_count); 2003 atomic_inc(&irq_err_count);
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9b7734b1f975..eeee23ff75ef 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -89,6 +89,9 @@ static DECLARE_WAIT_QUEUE_HEAD(mce_chrdev_wait);
89static DEFINE_PER_CPU(struct mce, mces_seen); 89static DEFINE_PER_CPU(struct mce, mces_seen);
90static int cpu_missing; 90static int cpu_missing;
91 91
92/* CMCI storm detection filter */
93static DEFINE_PER_CPU(unsigned long, mce_polled_error);
94
92/* 95/*
93 * MCA banks polled by the period polling timer for corrected events. 96 * MCA banks polled by the period polling timer for corrected events.
94 * With Intel CMCI, this only has MCA banks which do not support CMCI (if any). 97 * With Intel CMCI, this only has MCA banks which do not support CMCI (if any).
@@ -595,6 +598,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
595{ 598{
596 struct mce m; 599 struct mce m;
597 int i; 600 int i;
601 unsigned long *v;
598 602
599 this_cpu_inc(mce_poll_count); 603 this_cpu_inc(mce_poll_count);
600 604
@@ -614,6 +618,8 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
614 if (!(m.status & MCI_STATUS_VAL)) 618 if (!(m.status & MCI_STATUS_VAL))
615 continue; 619 continue;
616 620
621 v = &get_cpu_var(mce_polled_error);
622 set_bit(0, v);
617 /* 623 /*
618 * Uncorrected or signalled events are handled by the exception 624 * Uncorrected or signalled events are handled by the exception
619 * handler when it is enabled, so don't process those here. 625 * handler when it is enabled, so don't process those here.
@@ -1278,10 +1284,18 @@ static unsigned long mce_adjust_timer_default(unsigned long interval)
1278static unsigned long (*mce_adjust_timer)(unsigned long interval) = 1284static unsigned long (*mce_adjust_timer)(unsigned long interval) =
1279 mce_adjust_timer_default; 1285 mce_adjust_timer_default;
1280 1286
1287static int cmc_error_seen(void)
1288{
1289 unsigned long *v = &__get_cpu_var(mce_polled_error);
1290
1291 return test_and_clear_bit(0, v);
1292}
1293
1281static void mce_timer_fn(unsigned long data) 1294static void mce_timer_fn(unsigned long data)
1282{ 1295{
1283 struct timer_list *t = &__get_cpu_var(mce_timer); 1296 struct timer_list *t = &__get_cpu_var(mce_timer);
1284 unsigned long iv; 1297 unsigned long iv;
1298 int notify;
1285 1299
1286 WARN_ON(smp_processor_id() != data); 1300 WARN_ON(smp_processor_id() != data);
1287 1301
@@ -1296,7 +1310,9 @@ static void mce_timer_fn(unsigned long data)
1296 * polling interval, otherwise increase the polling interval. 1310 * polling interval, otherwise increase the polling interval.
1297 */ 1311 */
1298 iv = __this_cpu_read(mce_next_interval); 1312 iv = __this_cpu_read(mce_next_interval);
1299 if (mce_notify_irq()) { 1313 notify = mce_notify_irq();
1314 notify |= cmc_error_seen();
1315 if (notify) {
1300 iv = max(iv / 2, (unsigned long) HZ/100); 1316 iv = max(iv / 2, (unsigned long) HZ/100);
1301 } else { 1317 } else {
1302 iv = min(iv * 2, round_jiffies_relative(check_interval * HZ)); 1318 iv = min(iv * 2, round_jiffies_relative(check_interval * HZ));
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index fb6156fee6f7..3bdb95ae8c43 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -9,6 +9,7 @@
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/percpu.h> 10#include <linux/percpu.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/cpumask.h>
12#include <asm/apic.h> 13#include <asm/apic.h>
13#include <asm/processor.h> 14#include <asm/processor.h>
14#include <asm/msr.h> 15#include <asm/msr.h>
@@ -137,6 +138,22 @@ unsigned long mce_intel_adjust_timer(unsigned long interval)
137 } 138 }
138} 139}
139 140
141static void cmci_storm_disable_banks(void)
142{
143 unsigned long flags, *owned;
144 int bank;
145 u64 val;
146
147 raw_spin_lock_irqsave(&cmci_discover_lock, flags);
148 owned = __get_cpu_var(mce_banks_owned);
149 for_each_set_bit(bank, owned, MAX_NR_BANKS) {
150 rdmsrl(MSR_IA32_MCx_CTL2(bank), val);
151 val &= ~MCI_CTL2_CMCI_EN;
152 wrmsrl(MSR_IA32_MCx_CTL2(bank), val);
153 }
154 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
155}
156
140static bool cmci_storm_detect(void) 157static bool cmci_storm_detect(void)
141{ 158{
142 unsigned int cnt = __this_cpu_read(cmci_storm_cnt); 159 unsigned int cnt = __this_cpu_read(cmci_storm_cnt);
@@ -158,7 +175,7 @@ static bool cmci_storm_detect(void)
158 if (cnt <= CMCI_STORM_THRESHOLD) 175 if (cnt <= CMCI_STORM_THRESHOLD)
159 return false; 176 return false;
160 177
161 cmci_clear(); 178 cmci_storm_disable_banks();
162 __this_cpu_write(cmci_storm_state, CMCI_STORM_ACTIVE); 179 __this_cpu_write(cmci_storm_state, CMCI_STORM_ACTIVE);
163 r = atomic_add_return(1, &cmci_storm_on_cpus); 180 r = atomic_add_return(1, &cmci_storm_on_cpus);
164 mce_timer_kick(CMCI_POLL_INTERVAL); 181 mce_timer_kick(CMCI_POLL_INTERVAL);
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 6d7d5a1260a6..b0cc3809723d 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -225,7 +225,7 @@ static void __init intel_remapping_check(int num, int slot, int func)
225 * 225 *
226 * And yes, so far on current devices the base addr is always under 4G. 226 * And yes, so far on current devices the base addr is always under 4G.
227 */ 227 */
228static u32 __init intel_stolen_base(int num, int slot, int func) 228static u32 __init intel_stolen_base(int num, int slot, int func, size_t stolen_size)
229{ 229{
230 u32 base; 230 u32 base;
231 231
@@ -244,6 +244,114 @@ static u32 __init intel_stolen_base(int num, int slot, int func)
244#define MB(x) (KB (KB (x))) 244#define MB(x) (KB (KB (x)))
245#define GB(x) (MB (KB (x))) 245#define GB(x) (MB (KB (x)))
246 246
247static size_t __init i830_tseg_size(void)
248{
249 u8 tmp = read_pci_config_byte(0, 0, 0, I830_ESMRAMC);
250
251 if (!(tmp & TSEG_ENABLE))
252 return 0;
253
254 if (tmp & I830_TSEG_SIZE_1M)
255 return MB(1);
256 else
257 return KB(512);
258}
259
260static size_t __init i845_tseg_size(void)
261{
262 u8 tmp = read_pci_config_byte(0, 0, 0, I845_ESMRAMC);
263
264 if (!(tmp & TSEG_ENABLE))
265 return 0;
266
267 switch (tmp & I845_TSEG_SIZE_MASK) {
268 case I845_TSEG_SIZE_512K:
269 return KB(512);
270 case I845_TSEG_SIZE_1M:
271 return MB(1);
272 default:
273 WARN_ON(1);
274 return 0;
275 }
276}
277
278static size_t __init i85x_tseg_size(void)
279{
280 u8 tmp = read_pci_config_byte(0, 0, 0, I85X_ESMRAMC);
281
282 if (!(tmp & TSEG_ENABLE))
283 return 0;
284
285 return MB(1);
286}
287
288static size_t __init i830_mem_size(void)
289{
290 return read_pci_config_byte(0, 0, 0, I830_DRB3) * MB(32);
291}
292
293static size_t __init i85x_mem_size(void)
294{
295 return read_pci_config_byte(0, 0, 1, I85X_DRB3) * MB(32);
296}
297
298/*
299 * On 830/845/85x the stolen memory base isn't available in any
300 * register. We need to calculate it as TOM-TSEG_SIZE-stolen_size.
301 */
302static u32 __init i830_stolen_base(int num, int slot, int func, size_t stolen_size)
303{
304 return i830_mem_size() - i830_tseg_size() - stolen_size;
305}
306
307static u32 __init i845_stolen_base(int num, int slot, int func, size_t stolen_size)
308{
309 return i830_mem_size() - i845_tseg_size() - stolen_size;
310}
311
312static u32 __init i85x_stolen_base(int num, int slot, int func, size_t stolen_size)
313{
314 return i85x_mem_size() - i85x_tseg_size() - stolen_size;
315}
316
317static u32 __init i865_stolen_base(int num, int slot, int func, size_t stolen_size)
318{
319 /*
320 * FIXME is the graphics stolen memory region
321 * always at TOUD? Ie. is it always the last
322 * one to be allocated by the BIOS?
323 */
324 return read_pci_config_16(0, 0, 0, I865_TOUD) << 16;
325}
326
327static size_t __init i830_stolen_size(int num, int slot, int func)
328{
329 size_t stolen_size;
330 u16 gmch_ctrl;
331
332 gmch_ctrl = read_pci_config_16(0, 0, 0, I830_GMCH_CTRL);
333
334 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
335 case I830_GMCH_GMS_STOLEN_512:
336 stolen_size = KB(512);
337 break;
338 case I830_GMCH_GMS_STOLEN_1024:
339 stolen_size = MB(1);
340 break;
341 case I830_GMCH_GMS_STOLEN_8192:
342 stolen_size = MB(8);
343 break;
344 case I830_GMCH_GMS_LOCAL:
345 /* local memory isn't part of the normal address space */
346 stolen_size = 0;
347 break;
348 default:
349 return 0;
350 }
351
352 return stolen_size;
353}
354
247static size_t __init gen3_stolen_size(int num, int slot, int func) 355static size_t __init gen3_stolen_size(int num, int slot, int func)
248{ 356{
249 size_t stolen_size; 357 size_t stolen_size;
@@ -310,7 +418,7 @@ static size_t __init gen6_stolen_size(int num, int slot, int func)
310 return gmch_ctrl << 25; /* 32 MB units */ 418 return gmch_ctrl << 25; /* 32 MB units */
311} 419}
312 420
313static inline size_t gen8_stolen_size(int num, int slot, int func) 421static size_t gen8_stolen_size(int num, int slot, int func)
314{ 422{
315 u16 gmch_ctrl; 423 u16 gmch_ctrl;
316 424
@@ -320,31 +428,74 @@ static inline size_t gen8_stolen_size(int num, int slot, int func)
320 return gmch_ctrl << 25; /* 32 MB units */ 428 return gmch_ctrl << 25; /* 32 MB units */
321} 429}
322 430
323typedef size_t (*stolen_size_fn)(int num, int slot, int func); 431
432struct intel_stolen_funcs {
433 size_t (*size)(int num, int slot, int func);
434 u32 (*base)(int num, int slot, int func, size_t size);
435};
436
437static const struct intel_stolen_funcs i830_stolen_funcs = {
438 .base = i830_stolen_base,
439 .size = i830_stolen_size,
440};
441
442static const struct intel_stolen_funcs i845_stolen_funcs = {
443 .base = i845_stolen_base,
444 .size = i830_stolen_size,
445};
446
447static const struct intel_stolen_funcs i85x_stolen_funcs = {
448 .base = i85x_stolen_base,
449 .size = gen3_stolen_size,
450};
451
452static const struct intel_stolen_funcs i865_stolen_funcs = {
453 .base = i865_stolen_base,
454 .size = gen3_stolen_size,
455};
456
457static const struct intel_stolen_funcs gen3_stolen_funcs = {
458 .base = intel_stolen_base,
459 .size = gen3_stolen_size,
460};
461
462static const struct intel_stolen_funcs gen6_stolen_funcs = {
463 .base = intel_stolen_base,
464 .size = gen6_stolen_size,
465};
466
467static const struct intel_stolen_funcs gen8_stolen_funcs = {
468 .base = intel_stolen_base,
469 .size = gen8_stolen_size,
470};
324 471
325static struct pci_device_id intel_stolen_ids[] __initdata = { 472static struct pci_device_id intel_stolen_ids[] __initdata = {
326 INTEL_I915G_IDS(gen3_stolen_size), 473 INTEL_I830_IDS(&i830_stolen_funcs),
327 INTEL_I915GM_IDS(gen3_stolen_size), 474 INTEL_I845G_IDS(&i845_stolen_funcs),
328 INTEL_I945G_IDS(gen3_stolen_size), 475 INTEL_I85X_IDS(&i85x_stolen_funcs),
329 INTEL_I945GM_IDS(gen3_stolen_size), 476 INTEL_I865G_IDS(&i865_stolen_funcs),
330 INTEL_VLV_M_IDS(gen6_stolen_size), 477 INTEL_I915G_IDS(&gen3_stolen_funcs),
331 INTEL_VLV_D_IDS(gen6_stolen_size), 478 INTEL_I915GM_IDS(&gen3_stolen_funcs),
332 INTEL_PINEVIEW_IDS(gen3_stolen_size), 479 INTEL_I945G_IDS(&gen3_stolen_funcs),
333 INTEL_I965G_IDS(gen3_stolen_size), 480 INTEL_I945GM_IDS(&gen3_stolen_funcs),
334 INTEL_G33_IDS(gen3_stolen_size), 481 INTEL_VLV_M_IDS(&gen6_stolen_funcs),
335 INTEL_I965GM_IDS(gen3_stolen_size), 482 INTEL_VLV_D_IDS(&gen6_stolen_funcs),
336 INTEL_GM45_IDS(gen3_stolen_size), 483 INTEL_PINEVIEW_IDS(&gen3_stolen_funcs),
337 INTEL_G45_IDS(gen3_stolen_size), 484 INTEL_I965G_IDS(&gen3_stolen_funcs),
338 INTEL_IRONLAKE_D_IDS(gen3_stolen_size), 485 INTEL_G33_IDS(&gen3_stolen_funcs),
339 INTEL_IRONLAKE_M_IDS(gen3_stolen_size), 486 INTEL_I965GM_IDS(&gen3_stolen_funcs),
340 INTEL_SNB_D_IDS(gen6_stolen_size), 487 INTEL_GM45_IDS(&gen3_stolen_funcs),
341 INTEL_SNB_M_IDS(gen6_stolen_size), 488 INTEL_G45_IDS(&gen3_stolen_funcs),
342 INTEL_IVB_M_IDS(gen6_stolen_size), 489 INTEL_IRONLAKE_D_IDS(&gen3_stolen_funcs),
343 INTEL_IVB_D_IDS(gen6_stolen_size), 490 INTEL_IRONLAKE_M_IDS(&gen3_stolen_funcs),
344 INTEL_HSW_D_IDS(gen6_stolen_size), 491 INTEL_SNB_D_IDS(&gen6_stolen_funcs),
345 INTEL_HSW_M_IDS(gen6_stolen_size), 492 INTEL_SNB_M_IDS(&gen6_stolen_funcs),
346 INTEL_BDW_M_IDS(gen8_stolen_size), 493 INTEL_IVB_M_IDS(&gen6_stolen_funcs),
347 INTEL_BDW_D_IDS(gen8_stolen_size) 494 INTEL_IVB_D_IDS(&gen6_stolen_funcs),
495 INTEL_HSW_D_IDS(&gen6_stolen_funcs),
496 INTEL_HSW_M_IDS(&gen6_stolen_funcs),
497 INTEL_BDW_M_IDS(&gen8_stolen_funcs),
498 INTEL_BDW_D_IDS(&gen8_stolen_funcs)
348}; 499};
349 500
350static void __init intel_graphics_stolen(int num, int slot, int func) 501static void __init intel_graphics_stolen(int num, int slot, int func)
@@ -361,11 +512,13 @@ static void __init intel_graphics_stolen(int num, int slot, int func)
361 512
362 for (i = 0; i < ARRAY_SIZE(intel_stolen_ids); i++) { 513 for (i = 0; i < ARRAY_SIZE(intel_stolen_ids); i++) {
363 if (intel_stolen_ids[i].device == device) { 514 if (intel_stolen_ids[i].device == device) {
364 stolen_size_fn stolen_size = 515 const struct intel_stolen_funcs *stolen_funcs =
365 (stolen_size_fn)intel_stolen_ids[i].driver_data; 516 (const struct intel_stolen_funcs *)intel_stolen_ids[i].driver_data;
366 size = stolen_size(num, slot, func); 517 size = stolen_funcs->size(num, slot, func);
367 start = intel_stolen_base(num, slot, func); 518 start = stolen_funcs->base(num, slot, func, size);
368 if (size && start) { 519 if (size && start) {
520 printk(KERN_INFO "Reserving Intel graphics stolen memory at 0x%x-0x%x\n",
521 start, start + (u32)size - 1);
369 /* Mark this space as reserved */ 522 /* Mark this space as reserved */
370 e820_add_region(start, size, E820_RESERVED); 523 e820_add_region(start, size, E820_RESERVED);
371 sanitize_e820_map(e820.map, 524 sanitize_e820_map(e820.map,
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 42805fac0092..283a76a9cc40 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -125,7 +125,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
125 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j)); 125 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
126 seq_printf(p, " Machine check polls\n"); 126 seq_printf(p, " Machine check polls\n");
127#endif 127#endif
128#if defined(CONFIG_HYPERV) || defined(CONFIG_XEN) 128#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
129 seq_printf(p, "%*s: ", prec, "THR"); 129 seq_printf(p, "%*s: ", prec, "THR");
130 for_each_online_cpu(j) 130 for_each_online_cpu(j)
131 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); 131 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index ebc987398923..af1d14a9ebda 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -229,6 +229,17 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
229 } 229 }
230 } 230 }
231 231
232 /*
233 * On x86-64 we do not support 16-bit segments due to
234 * IRET leaking the high bits of the kernel stack address.
235 */
236#ifdef CONFIG_X86_64
237 if (!ldt_info.seg_32bit) {
238 error = -EINVAL;
239 goto out_unlock;
240 }
241#endif
242
232 fill_ldt(&ldt, &ldt_info); 243 fill_ldt(&ldt, &ldt_info);
233 if (oldmode) 244 if (oldmode)
234 ldt.avl = 0; 245 ldt.avl = 0;
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 299d49302e7d..0497f719977d 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -1207,23 +1207,31 @@ error:
1207 return ret; 1207 return ret;
1208} 1208}
1209 1209
1210static inline int __init determine_tce_table_size(u64 ram) 1210static inline int __init determine_tce_table_size(void)
1211{ 1211{
1212 int ret; 1212 int ret;
1213 1213
1214 if (specified_table_size != TCE_TABLE_SIZE_UNSPECIFIED) 1214 if (specified_table_size != TCE_TABLE_SIZE_UNSPECIFIED)
1215 return specified_table_size; 1215 return specified_table_size;
1216 1216
1217 /* 1217 if (is_kdump_kernel() && saved_max_pfn) {
1218 * Table sizes are from 0 to 7 (TCE_TABLE_SIZE_64K to 1218 /*
1219 * TCE_TABLE_SIZE_8M). Table size 0 has 8K entries and each 1219 * Table sizes are from 0 to 7 (TCE_TABLE_SIZE_64K to
1220 * larger table size has twice as many entries, so shift the 1220 * TCE_TABLE_SIZE_8M). Table size 0 has 8K entries and each
1221 * max ram address by 13 to divide by 8K and then look at the 1221 * larger table size has twice as many entries, so shift the
1222 * order of the result to choose between 0-7. 1222 * max ram address by 13 to divide by 8K and then look at the
1223 */ 1223 * order of the result to choose between 0-7.
1224 ret = get_order(ram >> 13); 1224 */
1225 if (ret > TCE_TABLE_SIZE_8M) 1225 ret = get_order((saved_max_pfn * PAGE_SIZE) >> 13);
1226 if (ret > TCE_TABLE_SIZE_8M)
1227 ret = TCE_TABLE_SIZE_8M;
1228 } else {
1229 /*
1230 * Use 8M by default (suggested by Muli) if it's not
1231 * kdump kernel and saved_max_pfn isn't set.
1232 */
1226 ret = TCE_TABLE_SIZE_8M; 1233 ret = TCE_TABLE_SIZE_8M;
1234 }
1227 1235
1228 return ret; 1236 return ret;
1229} 1237}
@@ -1418,8 +1426,7 @@ int __init detect_calgary(void)
1418 return -ENOMEM; 1426 return -ENOMEM;
1419 } 1427 }
1420 1428
1421 specified_table_size = determine_tce_table_size((is_kdump_kernel() ? 1429 specified_table_size = determine_tce_table_size();
1422 saved_max_pfn : max_pfn) * PAGE_SIZE);
1423 1430
1424 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) { 1431 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
1425 struct calgary_bus_info *info = &bus_info[bus]; 1432 struct calgary_bus_info *info = &bus_info[bus];
diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
index d87dd6d042d6..dd89a13f1051 100644
--- a/arch/x86/mm/kmemcheck/kmemcheck.c
+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
@@ -78,10 +78,16 @@ early_initcall(kmemcheck_init);
78 */ 78 */
79static int __init param_kmemcheck(char *str) 79static int __init param_kmemcheck(char *str)
80{ 80{
81 int val;
82 int ret;
83
81 if (!str) 84 if (!str)
82 return -EINVAL; 85 return -EINVAL;
83 86
84 sscanf(str, "%d", &kmemcheck_enabled); 87 ret = kstrtoint(str, 0, &val);
88 if (ret)
89 return ret;
90 kmemcheck_enabled = val;
85 return 0; 91 return 0;
86} 92}
87 93
diff --git a/arch/xtensa/configs/iss_defconfig b/arch/xtensa/configs/iss_defconfig
index d57d917ff240..1493c68352d1 100644
--- a/arch/xtensa/configs/iss_defconfig
+++ b/arch/xtensa/configs/iss_defconfig
@@ -627,7 +627,6 @@ CONFIG_SCHED_DEBUG=y
627# CONFIG_DEBUG_KOBJECT is not set 627# CONFIG_DEBUG_KOBJECT is not set
628# CONFIG_DEBUG_INFO is not set 628# CONFIG_DEBUG_INFO is not set
629# CONFIG_DEBUG_VM is not set 629# CONFIG_DEBUG_VM is not set
630# CONFIG_DEBUG_WRITECOUNT is not set
631# CONFIG_DEBUG_MEMORY_INIT is not set 630# CONFIG_DEBUG_MEMORY_INIT is not set
632# CONFIG_DEBUG_LIST is not set 631# CONFIG_DEBUG_LIST is not set
633# CONFIG_DEBUG_SG is not set 632# CONFIG_DEBUG_SG is not set
diff --git a/arch/xtensa/configs/s6105_defconfig b/arch/xtensa/configs/s6105_defconfig
index 583c2b0974ca..12a492ab6d17 100644
--- a/arch/xtensa/configs/s6105_defconfig
+++ b/arch/xtensa/configs/s6105_defconfig
@@ -569,7 +569,6 @@ CONFIG_DEBUG_SPINLOCK_SLEEP=y
569# CONFIG_DEBUG_INFO is not set 569# CONFIG_DEBUG_INFO is not set
570# CONFIG_DEBUG_VM is not set 570# CONFIG_DEBUG_VM is not set
571CONFIG_DEBUG_NOMMU_REGIONS=y 571CONFIG_DEBUG_NOMMU_REGIONS=y
572# CONFIG_DEBUG_WRITECOUNT is not set
573# CONFIG_DEBUG_MEMORY_INIT is not set 572# CONFIG_DEBUG_MEMORY_INIT is not set
574# CONFIG_DEBUG_LIST is not set 573# CONFIG_DEBUG_LIST is not set
575# CONFIG_DEBUG_SG is not set 574# CONFIG_DEBUG_SG is not set
diff --git a/block/blk-core.c b/block/blk-core.c
index 34d7c196338b..a0e3096c4bb5 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1307,7 +1307,7 @@ void __blk_put_request(struct request_queue *q, struct request *req)
1307 struct request_list *rl = blk_rq_rl(req); 1307 struct request_list *rl = blk_rq_rl(req);
1308 1308
1309 BUG_ON(!list_empty(&req->queuelist)); 1309 BUG_ON(!list_empty(&req->queuelist));
1310 BUG_ON(!hlist_unhashed(&req->hash)); 1310 BUG_ON(ELV_ON_HASH(req));
1311 1311
1312 blk_free_request(rl, req); 1312 blk_free_request(rl, req);
1313 freed_request(rl, flags); 1313 freed_request(rl, flags);
diff --git a/block/blk-map.c b/block/blk-map.c
index cca6356d216d..f7b22bc21518 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -188,7 +188,7 @@ EXPORT_SYMBOL(blk_rq_map_user);
188 * unmapping. 188 * unmapping.
189 */ 189 */
190int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, 190int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
191 struct rq_map_data *map_data, struct sg_iovec *iov, 191 struct rq_map_data *map_data, const struct sg_iovec *iov,
192 int iov_count, unsigned int len, gfp_t gfp_mask) 192 int iov_count, unsigned int len, gfp_t gfp_mask)
193{ 193{
194 struct bio *bio; 194 struct bio *bio;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b1bcc619d0ea..1d2a9bdbee57 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -956,6 +956,7 @@ static void blk_mq_hctx_notify(void *data, unsigned long action,
956 unsigned int cpu) 956 unsigned int cpu)
957{ 957{
958 struct blk_mq_hw_ctx *hctx = data; 958 struct blk_mq_hw_ctx *hctx = data;
959 struct request_queue *q = hctx->queue;
959 struct blk_mq_ctx *ctx; 960 struct blk_mq_ctx *ctx;
960 LIST_HEAD(tmp); 961 LIST_HEAD(tmp);
961 962
@@ -965,7 +966,7 @@ static void blk_mq_hctx_notify(void *data, unsigned long action,
965 /* 966 /*
966 * Move ctx entries to new CPU, if this one is going away. 967 * Move ctx entries to new CPU, if this one is going away.
967 */ 968 */
968 ctx = __blk_mq_get_ctx(hctx->queue, cpu); 969 ctx = __blk_mq_get_ctx(q, cpu);
969 970
970 spin_lock(&ctx->lock); 971 spin_lock(&ctx->lock);
971 if (!list_empty(&ctx->rq_list)) { 972 if (!list_empty(&ctx->rq_list)) {
@@ -977,7 +978,7 @@ static void blk_mq_hctx_notify(void *data, unsigned long action,
977 if (list_empty(&tmp)) 978 if (list_empty(&tmp))
978 return; 979 return;
979 980
980 ctx = blk_mq_get_ctx(hctx->queue); 981 ctx = blk_mq_get_ctx(q);
981 spin_lock(&ctx->lock); 982 spin_lock(&ctx->lock);
982 983
983 while (!list_empty(&tmp)) { 984 while (!list_empty(&tmp)) {
@@ -988,10 +989,13 @@ static void blk_mq_hctx_notify(void *data, unsigned long action,
988 list_move_tail(&rq->queuelist, &ctx->rq_list); 989 list_move_tail(&rq->queuelist, &ctx->rq_list);
989 } 990 }
990 991
992 hctx = q->mq_ops->map_queue(q, ctx->cpu);
991 blk_mq_hctx_mark_pending(hctx, ctx); 993 blk_mq_hctx_mark_pending(hctx, ctx);
992 994
993 spin_unlock(&ctx->lock); 995 spin_unlock(&ctx->lock);
994 blk_mq_put_ctx(ctx); 996 blk_mq_put_ctx(ctx);
997
998 blk_mq_run_hw_queue(hctx, true);
995} 999}
996 1000
997static int blk_mq_init_hw_commands(struct blk_mq_hw_ctx *hctx, 1001static int blk_mq_init_hw_commands(struct blk_mq_hw_ctx *hctx,
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index ebd6b6f1bdeb..53b1737e978d 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -30,8 +30,8 @@ static void blk_done_softirq(struct softirq_action *h)
30 while (!list_empty(&local_list)) { 30 while (!list_empty(&local_list)) {
31 struct request *rq; 31 struct request *rq;
32 32
33 rq = list_entry(local_list.next, struct request, queuelist); 33 rq = list_entry(local_list.next, struct request, ipi_list);
34 list_del_init(&rq->queuelist); 34 list_del_init(&rq->ipi_list);
35 rq->q->softirq_done_fn(rq); 35 rq->q->softirq_done_fn(rq);
36 } 36 }
37} 37}
@@ -45,14 +45,9 @@ static void trigger_softirq(void *data)
45 45
46 local_irq_save(flags); 46 local_irq_save(flags);
47 list = this_cpu_ptr(&blk_cpu_done); 47 list = this_cpu_ptr(&blk_cpu_done);
48 /* 48 list_add_tail(&rq->ipi_list, list);
49 * We reuse queuelist for a list of requests to process. Since the
50 * queuelist is used by the block layer only for requests waiting to be
51 * submitted to the device it is unused now.
52 */
53 list_add_tail(&rq->queuelist, list);
54 49
55 if (list->next == &rq->queuelist) 50 if (list->next == &rq->ipi_list)
56 raise_softirq_irqoff(BLOCK_SOFTIRQ); 51 raise_softirq_irqoff(BLOCK_SOFTIRQ);
57 52
58 local_irq_restore(flags); 53 local_irq_restore(flags);
@@ -141,7 +136,7 @@ void __blk_complete_request(struct request *req)
141 struct list_head *list; 136 struct list_head *list;
142do_local: 137do_local:
143 list = this_cpu_ptr(&blk_cpu_done); 138 list = this_cpu_ptr(&blk_cpu_done);
144 list_add_tail(&req->queuelist, list); 139 list_add_tail(&req->ipi_list, list);
145 140
146 /* 141 /*
147 * if the list only contains our just added request, 142 * if the list only contains our just added request,
@@ -149,7 +144,7 @@ do_local:
149 * entries there, someone already raised the irq but it 144 * entries there, someone already raised the irq but it
150 * hasn't run yet. 145 * hasn't run yet.
151 */ 146 */
152 if (list->next == &req->queuelist) 147 if (list->next == &req->ipi_list)
153 raise_softirq_irqoff(BLOCK_SOFTIRQ); 148 raise_softirq_irqoff(BLOCK_SOFTIRQ);
154 } else if (raise_blk_irq(ccpu, req)) 149 } else if (raise_blk_irq(ccpu, req))
155 goto do_local; 150 goto do_local;
diff --git a/block/blk.h b/block/blk.h
index d23b415b8a28..1d880f1f957f 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -78,7 +78,7 @@ static inline void blk_clear_rq_complete(struct request *rq)
78/* 78/*
79 * Internal elevator interface 79 * Internal elevator interface
80 */ 80 */
81#define ELV_ON_HASH(rq) hash_hashed(&(rq)->hash) 81#define ELV_ON_HASH(rq) ((rq)->cmd_flags & REQ_HASHED)
82 82
83void blk_insert_flush(struct request *rq); 83void blk_insert_flush(struct request *rq);
84void blk_abort_flushes(struct request_queue *q); 84void blk_abort_flushes(struct request_queue *q);
diff --git a/block/elevator.c b/block/elevator.c
index 42c45a7d6714..1e01b66a0b92 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -247,6 +247,7 @@ EXPORT_SYMBOL(elevator_exit);
247static inline void __elv_rqhash_del(struct request *rq) 247static inline void __elv_rqhash_del(struct request *rq)
248{ 248{
249 hash_del(&rq->hash); 249 hash_del(&rq->hash);
250 rq->cmd_flags &= ~REQ_HASHED;
250} 251}
251 252
252static void elv_rqhash_del(struct request_queue *q, struct request *rq) 253static void elv_rqhash_del(struct request_queue *q, struct request *rq)
@@ -261,6 +262,7 @@ static void elv_rqhash_add(struct request_queue *q, struct request *rq)
261 262
262 BUG_ON(ELV_ON_HASH(rq)); 263 BUG_ON(ELV_ON_HASH(rq));
263 hash_add(e->hash, &rq->hash, rq_hash_key(rq)); 264 hash_add(e->hash, &rq->hash, rq_hash_key(rq));
265 rq->cmd_flags |= REQ_HASHED;
264} 266}
265 267
266static void elv_rqhash_reposition(struct request_queue *q, struct request *rq) 268static void elv_rqhash_reposition(struct request_queue *q, struct request *rq)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index c205653e9644..ab686b310100 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -31,10 +31,14 @@ menuconfig ACPI
31 ACPI CA, see: 31 ACPI CA, see:
32 <http://acpica.org/> 32 <http://acpica.org/>
33 33
34 ACPI is an open industry specification co-developed by 34 ACPI is an open industry specification originally co-developed by
35 Hewlett-Packard, Intel, Microsoft, Phoenix, and Toshiba. 35 Hewlett-Packard, Intel, Microsoft, Phoenix, and Toshiba. Currently,
36 it is developed by the ACPI Specification Working Group (ASWG) under
37 the UEFI Forum and any UEFI member can join the ASWG and contribute
38 to the ACPI specification.
36 The specification is available at: 39 The specification is available at:
37 <http://www.acpi.info> 40 <http://www.acpi.info>
41 <http://www.uefi.org/acpi/specs>
38 42
39if ACPI 43if ACPI
40 44
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index f0fc6260266b..d9339b442a4e 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -51,12 +51,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
51 " the driver to wait for userspace to write the undock sysfs file " 51 " the driver to wait for userspace to write the undock sysfs file "
52 " before undocking"); 52 " before undocking");
53 53
54static const struct acpi_device_id dock_device_ids[] = {
55 {"LNXDOCK", 0},
56 {"", 0},
57};
58MODULE_DEVICE_TABLE(acpi, dock_device_ids);
59
60struct dock_station { 54struct dock_station {
61 acpi_handle handle; 55 acpi_handle handle;
62 unsigned long last_dock_time; 56 unsigned long last_dock_time;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index f7fd72ac69cf..6776c599816f 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1219,10 +1219,9 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
1219{ 1219{
1220 struct semaphore *sem = NULL; 1220 struct semaphore *sem = NULL;
1221 1221
1222 sem = acpi_os_allocate(sizeof(struct semaphore)); 1222 sem = acpi_os_allocate_zeroed(sizeof(struct semaphore));
1223 if (!sem) 1223 if (!sem)
1224 return AE_NO_MEMORY; 1224 return AE_NO_MEMORY;
1225 memset(sem, 0, sizeof(struct semaphore));
1226 1225
1227 sema_init(sem, initial_units); 1226 sema_init(sem, initial_units);
1228 1227
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 964068553334..c1e31a41f949 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -344,7 +344,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
344 tz->trips.hot.flags.valid = 1; 344 tz->trips.hot.flags.valid = 1;
345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 345 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
346 "Found hot threshold [%lu]\n", 346 "Found hot threshold [%lu]\n",
347 tz->trips.critical.temperature)); 347 tz->trips.hot.temperature));
348 } 348 }
349 } 349 }
350 350
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 0f5f78fa6545..bba526148583 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -164,11 +164,10 @@ acpi_extract_package(union acpi_object *package,
164 * Validate output buffer. 164 * Validate output buffer.
165 */ 165 */
166 if (buffer->length == ACPI_ALLOCATE_BUFFER) { 166 if (buffer->length == ACPI_ALLOCATE_BUFFER) {
167 buffer->pointer = ACPI_ALLOCATE(size_required); 167 buffer->pointer = ACPI_ALLOCATE_ZEROED(size_required);
168 if (!buffer->pointer) 168 if (!buffer->pointer)
169 return AE_NO_MEMORY; 169 return AE_NO_MEMORY;
170 buffer->length = size_required; 170 buffer->length = size_required;
171 memset(buffer->pointer, 0, size_required);
172 } else { 171 } else {
173 if (buffer->length < size_required) { 172 if (buffer->length < size_required) {
174 buffer->length = size_required; 173 buffer->length = size_required;
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 48c7e8af9c96..8b6990e417ec 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -488,6 +488,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
488 }, 488 },
489 }, 489 },
490 { 490 {
491 .callback = video_set_use_native_backlight,
492 .ident = "Thinkpad Helix",
493 .matches = {
494 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
495 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Helix"),
496 },
497 },
498 {
491 .callback = video_set_use_native_backlight, 499 .callback = video_set_use_native_backlight,
492 .ident = "Dell Inspiron 7520", 500 .ident = "Dell Inspiron 7520",
493 .matches = { 501 .matches = {
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 6f54962aae1d..ae098a261fcd 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -705,6 +705,14 @@ static int pm_genpd_runtime_resume(struct device *dev)
705 return 0; 705 return 0;
706} 706}
707 707
708static bool pd_ignore_unused;
709static int __init pd_ignore_unused_setup(char *__unused)
710{
711 pd_ignore_unused = true;
712 return 1;
713}
714__setup("pd_ignore_unused", pd_ignore_unused_setup);
715
708/** 716/**
709 * pm_genpd_poweroff_unused - Power off all PM domains with no devices in use. 717 * pm_genpd_poweroff_unused - Power off all PM domains with no devices in use.
710 */ 718 */
@@ -712,6 +720,11 @@ void pm_genpd_poweroff_unused(void)
712{ 720{
713 struct generic_pm_domain *genpd; 721 struct generic_pm_domain *genpd;
714 722
723 if (pd_ignore_unused) {
724 pr_warn("genpd: Not disabling unused power domains\n");
725 return;
726 }
727
715 mutex_lock(&gpd_list_lock); 728 mutex_lock(&gpd_list_lock);
716 729
717 list_for_each_entry(genpd, &gpd_list, gpd_list_node) 730 list_for_each_entry(genpd, &gpd_list, gpd_list_node)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d0a072463a04..63e30ef096e2 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -761,10 +761,11 @@ skip_format_initialization:
761 if (ret != 0) 761 if (ret != 0)
762 goto err_range; 762 goto err_range;
763 763
764 if (dev) 764 if (dev) {
765 ret = regmap_attach_dev(dev, map, config); 765 ret = regmap_attach_dev(dev, map, config);
766 if (ret != 0) 766 if (ret != 0)
767 goto err_regcache; 767 goto err_regcache;
768 }
768 769
769 return map; 770 return map;
770 771
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 18c76e84d540..68e3992e8838 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -469,24 +469,14 @@ static void drbd_wait_ee_list_empty(struct drbd_device *device,
469 469
470static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flags) 470static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flags)
471{ 471{
472 mm_segment_t oldfs;
473 struct kvec iov = { 472 struct kvec iov = {
474 .iov_base = buf, 473 .iov_base = buf,
475 .iov_len = size, 474 .iov_len = size,
476 }; 475 };
477 struct msghdr msg = { 476 struct msghdr msg = {
478 .msg_iovlen = 1,
479 .msg_iov = (struct iovec *)&iov,
480 .msg_flags = (flags ? flags : MSG_WAITALL | MSG_NOSIGNAL) 477 .msg_flags = (flags ? flags : MSG_WAITALL | MSG_NOSIGNAL)
481 }; 478 };
482 int rv; 479 return kernel_recvmsg(sock, &msg, &iov, 1, size, msg.msg_flags);
483
484 oldfs = get_fs();
485 set_fs(KERNEL_DS);
486 rv = sock_recvmsg(sock, &msg, size, msg.msg_flags);
487 set_fs(oldfs);
488
489 return rv;
490} 480}
491 481
492static int drbd_recv(struct drbd_connection *connection, void *buf, size_t size) 482static int drbd_recv(struct drbd_connection *connection, void *buf, size_t size)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 66e8c3b94ef3..f70a230a2945 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -237,7 +237,7 @@ static int __do_lo_send_write(struct file *file,
237 file_end_write(file); 237 file_end_write(file);
238 if (likely(bw == len)) 238 if (likely(bw == len))
239 return 0; 239 return 0;
240 printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n", 240 printk_ratelimited(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n",
241 (unsigned long long)pos, len); 241 (unsigned long long)pos, len);
242 if (bw >= 0) 242 if (bw >= 0)
243 bw = -EIO; 243 bw = -EIO;
@@ -277,7 +277,7 @@ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,
277 return __do_lo_send_write(lo->lo_backing_file, 277 return __do_lo_send_write(lo->lo_backing_file,
278 page_address(page), bvec->bv_len, 278 page_address(page), bvec->bv_len,
279 pos); 279 pos);
280 printk(KERN_ERR "loop: Transfer error at byte offset %llu, " 280 printk_ratelimited(KERN_ERR "loop: Transfer error at byte offset %llu, "
281 "length %i.\n", (unsigned long long)pos, bvec->bv_len); 281 "length %i.\n", (unsigned long long)pos, bvec->bv_len);
282 if (ret > 0) 282 if (ret > 0)
283 ret = -EIO; 283 ret = -EIO;
@@ -316,7 +316,7 @@ static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos)
316out: 316out:
317 return ret; 317 return ret;
318fail: 318fail:
319 printk(KERN_ERR "loop: Failed to allocate temporary page for write.\n"); 319 printk_ratelimited(KERN_ERR "loop: Failed to allocate temporary page for write.\n");
320 ret = -ENOMEM; 320 ret = -ENOMEM;
321 goto out; 321 goto out;
322} 322}
@@ -345,7 +345,7 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
345 size = p->bsize; 345 size = p->bsize;
346 346
347 if (lo_do_transfer(lo, READ, page, buf->offset, p->page, p->offset, size, IV)) { 347 if (lo_do_transfer(lo, READ, page, buf->offset, p->page, p->offset, size, IV)) {
348 printk(KERN_ERR "loop: transfer error block %ld\n", 348 printk_ratelimited(KERN_ERR "loop: transfer error block %ld\n",
349 page->index); 349 page->index);
350 size = -EINVAL; 350 size = -EINVAL;
351 } 351 }
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 55298db36b2d..3a70ea2f7cd6 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -630,37 +630,29 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
630 } 630 }
631 631
632 case NBD_CLEAR_SOCK: { 632 case NBD_CLEAR_SOCK: {
633 struct file *file; 633 struct socket *sock = nbd->sock;
634
635 nbd->sock = NULL; 634 nbd->sock = NULL;
636 file = nbd->file;
637 nbd->file = NULL;
638 nbd_clear_que(nbd); 635 nbd_clear_que(nbd);
639 BUG_ON(!list_empty(&nbd->queue_head)); 636 BUG_ON(!list_empty(&nbd->queue_head));
640 BUG_ON(!list_empty(&nbd->waiting_queue)); 637 BUG_ON(!list_empty(&nbd->waiting_queue));
641 kill_bdev(bdev); 638 kill_bdev(bdev);
642 if (file) 639 if (sock)
643 fput(file); 640 sockfd_put(sock);
644 return 0; 641 return 0;
645 } 642 }
646 643
647 case NBD_SET_SOCK: { 644 case NBD_SET_SOCK: {
648 struct file *file; 645 struct socket *sock;
649 if (nbd->file) 646 int err;
647 if (nbd->sock)
650 return -EBUSY; 648 return -EBUSY;
651 file = fget(arg); 649 sock = sockfd_lookup(arg, &err);
652 if (file) { 650 if (sock) {
653 struct inode *inode = file_inode(file); 651 nbd->sock = sock;
654 if (S_ISSOCK(inode->i_mode)) { 652 if (max_part > 0)
655 nbd->file = file; 653 bdev->bd_invalidated = 1;
656 nbd->sock = SOCKET_I(inode); 654 nbd->disconnect = 0; /* we're connected now */
657 if (max_part > 0) 655 return 0;
658 bdev->bd_invalidated = 1;
659 nbd->disconnect = 0; /* we're connected now */
660 return 0;
661 } else {
662 fput(file);
663 }
664 } 656 }
665 return -EINVAL; 657 return -EINVAL;
666 } 658 }
@@ -697,12 +689,12 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
697 689
698 case NBD_DO_IT: { 690 case NBD_DO_IT: {
699 struct task_struct *thread; 691 struct task_struct *thread;
700 struct file *file; 692 struct socket *sock;
701 int error; 693 int error;
702 694
703 if (nbd->pid) 695 if (nbd->pid)
704 return -EBUSY; 696 return -EBUSY;
705 if (!nbd->file) 697 if (!nbd->sock)
706 return -EINVAL; 698 return -EINVAL;
707 699
708 mutex_unlock(&nbd->tx_lock); 700 mutex_unlock(&nbd->tx_lock);
@@ -731,15 +723,15 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
731 if (error) 723 if (error)
732 return error; 724 return error;
733 sock_shutdown(nbd, 0); 725 sock_shutdown(nbd, 0);
734 file = nbd->file; 726 sock = nbd->sock;
735 nbd->file = NULL; 727 nbd->sock = NULL;
736 nbd_clear_que(nbd); 728 nbd_clear_que(nbd);
737 dev_warn(disk_to_dev(nbd->disk), "queue cleared\n"); 729 dev_warn(disk_to_dev(nbd->disk), "queue cleared\n");
738 kill_bdev(bdev); 730 kill_bdev(bdev);
739 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue); 731 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
740 set_device_ro(bdev, false); 732 set_device_ro(bdev, false);
741 if (file) 733 if (sock)
742 fput(file); 734 sockfd_put(sock);
743 nbd->flags = 0; 735 nbd->flags = 0;
744 nbd->bytesize = 0; 736 nbd->bytesize = 0;
745 bdev->bd_inode->i_size = 0; 737 bdev->bd_inode->i_size = 0;
@@ -875,9 +867,7 @@ static int __init nbd_init(void)
875 867
876 for (i = 0; i < nbds_max; i++) { 868 for (i = 0; i < nbds_max; i++) {
877 struct gendisk *disk = nbd_dev[i].disk; 869 struct gendisk *disk = nbd_dev[i].disk;
878 nbd_dev[i].file = NULL;
879 nbd_dev[i].magic = NBD_MAGIC; 870 nbd_dev[i].magic = NBD_MAGIC;
880 nbd_dev[i].flags = 0;
881 INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); 871 INIT_LIST_HEAD(&nbd_dev[i].waiting_queue);
882 spin_lock_init(&nbd_dev[i].queue_lock); 872 spin_lock_init(&nbd_dev[i].queue_lock);
883 INIT_LIST_HEAD(&nbd_dev[i].queue_head); 873 INIT_LIST_HEAD(&nbd_dev[i].queue_head);
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index da085ff10d25..7c64fa756cce 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * NVM Express device driver 2 * NVM Express device driver
3 * Copyright (c) 2011, Intel Corporation. 3 * Copyright (c) 2011-2014, Intel Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License, 6 * under the terms and conditions of the GNU General Public License,
@@ -20,10 +20,12 @@
20#include <linux/bio.h> 20#include <linux/bio.h>
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/cpu.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
25#include <linux/fs.h> 26#include <linux/fs.h>
26#include <linux/genhd.h> 27#include <linux/genhd.h>
28#include <linux/hdreg.h>
27#include <linux/idr.h> 29#include <linux/idr.h>
28#include <linux/init.h> 30#include <linux/init.h>
29#include <linux/interrupt.h> 31#include <linux/interrupt.h>
@@ -35,6 +37,7 @@
35#include <linux/module.h> 37#include <linux/module.h>
36#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
37#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/percpu.h>
38#include <linux/poison.h> 41#include <linux/poison.h>
39#include <linux/ptrace.h> 42#include <linux/ptrace.h>
40#include <linux/sched.h> 43#include <linux/sched.h>
@@ -47,6 +50,11 @@
47#define SQ_SIZE(depth) (depth * sizeof(struct nvme_command)) 50#define SQ_SIZE(depth) (depth * sizeof(struct nvme_command))
48#define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion)) 51#define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion))
49#define ADMIN_TIMEOUT (60 * HZ) 52#define ADMIN_TIMEOUT (60 * HZ)
53#define IOD_TIMEOUT (4 * NVME_IO_TIMEOUT)
54
55unsigned char io_timeout = 30;
56module_param(io_timeout, byte, 0644);
57MODULE_PARM_DESC(io_timeout, "timeout in seconds for I/O");
50 58
51static int nvme_major; 59static int nvme_major;
52module_param(nvme_major, int, 0); 60module_param(nvme_major, int, 0);
@@ -58,6 +66,7 @@ static DEFINE_SPINLOCK(dev_list_lock);
58static LIST_HEAD(dev_list); 66static LIST_HEAD(dev_list);
59static struct task_struct *nvme_thread; 67static struct task_struct *nvme_thread;
60static struct workqueue_struct *nvme_workq; 68static struct workqueue_struct *nvme_workq;
69static wait_queue_head_t nvme_kthread_wait;
61 70
62static void nvme_reset_failed_dev(struct work_struct *ws); 71static void nvme_reset_failed_dev(struct work_struct *ws);
63 72
@@ -74,6 +83,7 @@ struct async_cmd_info {
74 * commands and one for I/O commands). 83 * commands and one for I/O commands).
75 */ 84 */
76struct nvme_queue { 85struct nvme_queue {
86 struct rcu_head r_head;
77 struct device *q_dmadev; 87 struct device *q_dmadev;
78 struct nvme_dev *dev; 88 struct nvme_dev *dev;
79 char irqname[24]; /* nvme4294967295-65535\0 */ 89 char irqname[24]; /* nvme4294967295-65535\0 */
@@ -85,6 +95,7 @@ struct nvme_queue {
85 wait_queue_head_t sq_full; 95 wait_queue_head_t sq_full;
86 wait_queue_t sq_cong_wait; 96 wait_queue_t sq_cong_wait;
87 struct bio_list sq_cong; 97 struct bio_list sq_cong;
98 struct list_head iod_bio;
88 u32 __iomem *q_db; 99 u32 __iomem *q_db;
89 u16 q_depth; 100 u16 q_depth;
90 u16 cq_vector; 101 u16 cq_vector;
@@ -95,6 +106,7 @@ struct nvme_queue {
95 u8 cq_phase; 106 u8 cq_phase;
96 u8 cqe_seen; 107 u8 cqe_seen;
97 u8 q_suspended; 108 u8 q_suspended;
109 cpumask_var_t cpu_mask;
98 struct async_cmd_info cmdinfo; 110 struct async_cmd_info cmdinfo;
99 unsigned long cmdid_data[]; 111 unsigned long cmdid_data[];
100}; 112};
@@ -118,7 +130,7 @@ static inline void _nvme_check_size(void)
118 BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512); 130 BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
119} 131}
120 132
121typedef void (*nvme_completion_fn)(struct nvme_dev *, void *, 133typedef void (*nvme_completion_fn)(struct nvme_queue *, void *,
122 struct nvme_completion *); 134 struct nvme_completion *);
123 135
124struct nvme_cmd_info { 136struct nvme_cmd_info {
@@ -190,7 +202,7 @@ static int alloc_cmdid_killable(struct nvme_queue *nvmeq, void *ctx,
190#define CMD_CTX_FLUSH (0x318 + CMD_CTX_BASE) 202#define CMD_CTX_FLUSH (0x318 + CMD_CTX_BASE)
191#define CMD_CTX_ABORT (0x31C + CMD_CTX_BASE) 203#define CMD_CTX_ABORT (0x31C + CMD_CTX_BASE)
192 204
193static void special_completion(struct nvme_dev *dev, void *ctx, 205static void special_completion(struct nvme_queue *nvmeq, void *ctx,
194 struct nvme_completion *cqe) 206 struct nvme_completion *cqe)
195{ 207{
196 if (ctx == CMD_CTX_CANCELLED) 208 if (ctx == CMD_CTX_CANCELLED)
@@ -198,26 +210,26 @@ static void special_completion(struct nvme_dev *dev, void *ctx,
198 if (ctx == CMD_CTX_FLUSH) 210 if (ctx == CMD_CTX_FLUSH)
199 return; 211 return;
200 if (ctx == CMD_CTX_ABORT) { 212 if (ctx == CMD_CTX_ABORT) {
201 ++dev->abort_limit; 213 ++nvmeq->dev->abort_limit;
202 return; 214 return;
203 } 215 }
204 if (ctx == CMD_CTX_COMPLETED) { 216 if (ctx == CMD_CTX_COMPLETED) {
205 dev_warn(&dev->pci_dev->dev, 217 dev_warn(nvmeq->q_dmadev,
206 "completed id %d twice on queue %d\n", 218 "completed id %d twice on queue %d\n",
207 cqe->command_id, le16_to_cpup(&cqe->sq_id)); 219 cqe->command_id, le16_to_cpup(&cqe->sq_id));
208 return; 220 return;
209 } 221 }
210 if (ctx == CMD_CTX_INVALID) { 222 if (ctx == CMD_CTX_INVALID) {
211 dev_warn(&dev->pci_dev->dev, 223 dev_warn(nvmeq->q_dmadev,
212 "invalid id %d completed on queue %d\n", 224 "invalid id %d completed on queue %d\n",
213 cqe->command_id, le16_to_cpup(&cqe->sq_id)); 225 cqe->command_id, le16_to_cpup(&cqe->sq_id));
214 return; 226 return;
215 } 227 }
216 228
217 dev_warn(&dev->pci_dev->dev, "Unknown special completion %p\n", ctx); 229 dev_warn(nvmeq->q_dmadev, "Unknown special completion %p\n", ctx);
218} 230}
219 231
220static void async_completion(struct nvme_dev *dev, void *ctx, 232static void async_completion(struct nvme_queue *nvmeq, void *ctx,
221 struct nvme_completion *cqe) 233 struct nvme_completion *cqe)
222{ 234{
223 struct async_cmd_info *cmdinfo = ctx; 235 struct async_cmd_info *cmdinfo = ctx;
@@ -262,14 +274,34 @@ static void *cancel_cmdid(struct nvme_queue *nvmeq, int cmdid,
262 return ctx; 274 return ctx;
263} 275}
264 276
265struct nvme_queue *get_nvmeq(struct nvme_dev *dev) 277static struct nvme_queue *raw_nvmeq(struct nvme_dev *dev, int qid)
278{
279 return rcu_dereference_raw(dev->queues[qid]);
280}
281
282static struct nvme_queue *get_nvmeq(struct nvme_dev *dev) __acquires(RCU)
283{
284 unsigned queue_id = get_cpu_var(*dev->io_queue);
285 rcu_read_lock();
286 return rcu_dereference(dev->queues[queue_id]);
287}
288
289static void put_nvmeq(struct nvme_queue *nvmeq) __releases(RCU)
266{ 290{
267 return dev->queues[get_cpu() + 1]; 291 rcu_read_unlock();
292 put_cpu_var(nvmeq->dev->io_queue);
268} 293}
269 294
270void put_nvmeq(struct nvme_queue *nvmeq) 295static struct nvme_queue *lock_nvmeq(struct nvme_dev *dev, int q_idx)
296 __acquires(RCU)
271{ 297{
272 put_cpu(); 298 rcu_read_lock();
299 return rcu_dereference(dev->queues[q_idx]);
300}
301
302static void unlock_nvmeq(struct nvme_queue *nvmeq) __releases(RCU)
303{
304 rcu_read_unlock();
273} 305}
274 306
275/** 307/**
@@ -284,6 +316,10 @@ static int nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd)
284 unsigned long flags; 316 unsigned long flags;
285 u16 tail; 317 u16 tail;
286 spin_lock_irqsave(&nvmeq->q_lock, flags); 318 spin_lock_irqsave(&nvmeq->q_lock, flags);
319 if (nvmeq->q_suspended) {
320 spin_unlock_irqrestore(&nvmeq->q_lock, flags);
321 return -EBUSY;
322 }
287 tail = nvmeq->sq_tail; 323 tail = nvmeq->sq_tail;
288 memcpy(&nvmeq->sq_cmds[tail], cmd, sizeof(*cmd)); 324 memcpy(&nvmeq->sq_cmds[tail], cmd, sizeof(*cmd));
289 if (++tail == nvmeq->q_depth) 325 if (++tail == nvmeq->q_depth)
@@ -323,6 +359,7 @@ nvme_alloc_iod(unsigned nseg, unsigned nbytes, gfp_t gfp)
323 iod->npages = -1; 359 iod->npages = -1;
324 iod->length = nbytes; 360 iod->length = nbytes;
325 iod->nents = 0; 361 iod->nents = 0;
362 iod->first_dma = 0ULL;
326 iod->start_time = jiffies; 363 iod->start_time = jiffies;
327 } 364 }
328 365
@@ -371,19 +408,31 @@ static void nvme_end_io_acct(struct bio *bio, unsigned long start_time)
371 part_stat_unlock(); 408 part_stat_unlock();
372} 409}
373 410
374static void bio_completion(struct nvme_dev *dev, void *ctx, 411static void bio_completion(struct nvme_queue *nvmeq, void *ctx,
375 struct nvme_completion *cqe) 412 struct nvme_completion *cqe)
376{ 413{
377 struct nvme_iod *iod = ctx; 414 struct nvme_iod *iod = ctx;
378 struct bio *bio = iod->private; 415 struct bio *bio = iod->private;
379 u16 status = le16_to_cpup(&cqe->status) >> 1; 416 u16 status = le16_to_cpup(&cqe->status) >> 1;
380 417
418 if (unlikely(status)) {
419 if (!(status & NVME_SC_DNR ||
420 bio->bi_rw & REQ_FAILFAST_MASK) &&
421 (jiffies - iod->start_time) < IOD_TIMEOUT) {
422 if (!waitqueue_active(&nvmeq->sq_full))
423 add_wait_queue(&nvmeq->sq_full,
424 &nvmeq->sq_cong_wait);
425 list_add_tail(&iod->node, &nvmeq->iod_bio);
426 wake_up(&nvmeq->sq_full);
427 return;
428 }
429 }
381 if (iod->nents) { 430 if (iod->nents) {
382 dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents, 431 dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents,
383 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 432 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
384 nvme_end_io_acct(bio, iod->start_time); 433 nvme_end_io_acct(bio, iod->start_time);
385 } 434 }
386 nvme_free_iod(dev, iod); 435 nvme_free_iod(nvmeq->dev, iod);
387 if (status) 436 if (status)
388 bio_endio(bio, -EIO); 437 bio_endio(bio, -EIO);
389 else 438 else
@@ -391,8 +440,8 @@ static void bio_completion(struct nvme_dev *dev, void *ctx,
391} 440}
392 441
393/* length is in bytes. gfp flags indicates whether we may sleep. */ 442/* length is in bytes. gfp flags indicates whether we may sleep. */
394int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd, 443int nvme_setup_prps(struct nvme_dev *dev, struct nvme_iod *iod, int total_len,
395 struct nvme_iod *iod, int total_len, gfp_t gfp) 444 gfp_t gfp)
396{ 445{
397 struct dma_pool *pool; 446 struct dma_pool *pool;
398 int length = total_len; 447 int length = total_len;
@@ -405,7 +454,6 @@ int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd,
405 dma_addr_t prp_dma; 454 dma_addr_t prp_dma;
406 int nprps, i; 455 int nprps, i;
407 456
408 cmd->prp1 = cpu_to_le64(dma_addr);
409 length -= (PAGE_SIZE - offset); 457 length -= (PAGE_SIZE - offset);
410 if (length <= 0) 458 if (length <= 0)
411 return total_len; 459 return total_len;
@@ -420,7 +468,7 @@ int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd,
420 } 468 }
421 469
422 if (length <= PAGE_SIZE) { 470 if (length <= PAGE_SIZE) {
423 cmd->prp2 = cpu_to_le64(dma_addr); 471 iod->first_dma = dma_addr;
424 return total_len; 472 return total_len;
425 } 473 }
426 474
@@ -435,13 +483,12 @@ int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd,
435 483
436 prp_list = dma_pool_alloc(pool, gfp, &prp_dma); 484 prp_list = dma_pool_alloc(pool, gfp, &prp_dma);
437 if (!prp_list) { 485 if (!prp_list) {
438 cmd->prp2 = cpu_to_le64(dma_addr); 486 iod->first_dma = dma_addr;
439 iod->npages = -1; 487 iod->npages = -1;
440 return (total_len - length) + PAGE_SIZE; 488 return (total_len - length) + PAGE_SIZE;
441 } 489 }
442 list[0] = prp_list; 490 list[0] = prp_list;
443 iod->first_dma = prp_dma; 491 iod->first_dma = prp_dma;
444 cmd->prp2 = cpu_to_le64(prp_dma);
445 i = 0; 492 i = 0;
446 for (;;) { 493 for (;;) {
447 if (i == PAGE_SIZE / 8) { 494 if (i == PAGE_SIZE / 8) {
@@ -480,10 +527,11 @@ static int nvme_split_and_submit(struct bio *bio, struct nvme_queue *nvmeq,
480 527
481 bio_chain(split, bio); 528 bio_chain(split, bio);
482 529
483 if (bio_list_empty(&nvmeq->sq_cong)) 530 if (!waitqueue_active(&nvmeq->sq_full))
484 add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait); 531 add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait);
485 bio_list_add(&nvmeq->sq_cong, split); 532 bio_list_add(&nvmeq->sq_cong, split);
486 bio_list_add(&nvmeq->sq_cong, bio); 533 bio_list_add(&nvmeq->sq_cong, bio);
534 wake_up(&nvmeq->sq_full);
487 535
488 return 0; 536 return 0;
489} 537}
@@ -536,25 +584,13 @@ static int nvme_map_bio(struct nvme_queue *nvmeq, struct nvme_iod *iod,
536 return length; 584 return length;
537} 585}
538 586
539/*
540 * We reuse the small pool to allocate the 16-byte range here as it is not
541 * worth having a special pool for these or additional cases to handle freeing
542 * the iod.
543 */
544static int nvme_submit_discard(struct nvme_queue *nvmeq, struct nvme_ns *ns, 587static int nvme_submit_discard(struct nvme_queue *nvmeq, struct nvme_ns *ns,
545 struct bio *bio, struct nvme_iod *iod, int cmdid) 588 struct bio *bio, struct nvme_iod *iod, int cmdid)
546{ 589{
547 struct nvme_dsm_range *range; 590 struct nvme_dsm_range *range =
591 (struct nvme_dsm_range *)iod_list(iod)[0];
548 struct nvme_command *cmnd = &nvmeq->sq_cmds[nvmeq->sq_tail]; 592 struct nvme_command *cmnd = &nvmeq->sq_cmds[nvmeq->sq_tail];
549 593
550 range = dma_pool_alloc(nvmeq->dev->prp_small_pool, GFP_ATOMIC,
551 &iod->first_dma);
552 if (!range)
553 return -ENOMEM;
554
555 iod_list(iod)[0] = (__le64 *)range;
556 iod->npages = 0;
557
558 range->cattr = cpu_to_le32(0); 594 range->cattr = cpu_to_le32(0);
559 range->nlb = cpu_to_le32(bio->bi_iter.bi_size >> ns->lba_shift); 595 range->nlb = cpu_to_le32(bio->bi_iter.bi_size >> ns->lba_shift);
560 range->slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector)); 596 range->slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector));
@@ -601,44 +637,22 @@ int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns)
601 return nvme_submit_flush(nvmeq, ns, cmdid); 637 return nvme_submit_flush(nvmeq, ns, cmdid);
602} 638}
603 639
604/* 640static int nvme_submit_iod(struct nvme_queue *nvmeq, struct nvme_iod *iod)
605 * Called with local interrupts disabled and the q_lock held. May not sleep.
606 */
607static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
608 struct bio *bio)
609{ 641{
642 struct bio *bio = iod->private;
643 struct nvme_ns *ns = bio->bi_bdev->bd_disk->private_data;
610 struct nvme_command *cmnd; 644 struct nvme_command *cmnd;
611 struct nvme_iod *iod; 645 int cmdid;
612 enum dma_data_direction dma_dir;
613 int cmdid, length, result;
614 u16 control; 646 u16 control;
615 u32 dsmgmt; 647 u32 dsmgmt;
616 int psegs = bio_phys_segments(ns->queue, bio);
617
618 if ((bio->bi_rw & REQ_FLUSH) && psegs) {
619 result = nvme_submit_flush_data(nvmeq, ns);
620 if (result)
621 return result;
622 }
623 648
624 result = -ENOMEM;
625 iod = nvme_alloc_iod(psegs, bio->bi_iter.bi_size, GFP_ATOMIC);
626 if (!iod)
627 goto nomem;
628 iod->private = bio;
629
630 result = -EBUSY;
631 cmdid = alloc_cmdid(nvmeq, iod, bio_completion, NVME_IO_TIMEOUT); 649 cmdid = alloc_cmdid(nvmeq, iod, bio_completion, NVME_IO_TIMEOUT);
632 if (unlikely(cmdid < 0)) 650 if (unlikely(cmdid < 0))
633 goto free_iod; 651 return cmdid;
634 652
635 if (bio->bi_rw & REQ_DISCARD) { 653 if (bio->bi_rw & REQ_DISCARD)
636 result = nvme_submit_discard(nvmeq, ns, bio, iod, cmdid); 654 return nvme_submit_discard(nvmeq, ns, bio, iod, cmdid);
637 if (result) 655 if ((bio->bi_rw & REQ_FLUSH) && !iod->nents)
638 goto free_cmdid;
639 return result;
640 }
641 if ((bio->bi_rw & REQ_FLUSH) && !psegs)
642 return nvme_submit_flush(nvmeq, ns, cmdid); 656 return nvme_submit_flush(nvmeq, ns, cmdid);
643 657
644 control = 0; 658 control = 0;
@@ -652,42 +666,85 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
652 dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH; 666 dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH;
653 667
654 cmnd = &nvmeq->sq_cmds[nvmeq->sq_tail]; 668 cmnd = &nvmeq->sq_cmds[nvmeq->sq_tail];
655
656 memset(cmnd, 0, sizeof(*cmnd)); 669 memset(cmnd, 0, sizeof(*cmnd));
657 if (bio_data_dir(bio)) {
658 cmnd->rw.opcode = nvme_cmd_write;
659 dma_dir = DMA_TO_DEVICE;
660 } else {
661 cmnd->rw.opcode = nvme_cmd_read;
662 dma_dir = DMA_FROM_DEVICE;
663 }
664
665 result = nvme_map_bio(nvmeq, iod, bio, dma_dir, psegs);
666 if (result <= 0)
667 goto free_cmdid;
668 length = result;
669 670
671 cmnd->rw.opcode = bio_data_dir(bio) ? nvme_cmd_write : nvme_cmd_read;
670 cmnd->rw.command_id = cmdid; 672 cmnd->rw.command_id = cmdid;
671 cmnd->rw.nsid = cpu_to_le32(ns->ns_id); 673 cmnd->rw.nsid = cpu_to_le32(ns->ns_id);
672 length = nvme_setup_prps(nvmeq->dev, &cmnd->common, iod, length, 674 cmnd->rw.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
673 GFP_ATOMIC); 675 cmnd->rw.prp2 = cpu_to_le64(iod->first_dma);
674 cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector)); 676 cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector));
675 cmnd->rw.length = cpu_to_le16((length >> ns->lba_shift) - 1); 677 cmnd->rw.length =
678 cpu_to_le16((bio->bi_iter.bi_size >> ns->lba_shift) - 1);
676 cmnd->rw.control = cpu_to_le16(control); 679 cmnd->rw.control = cpu_to_le16(control);
677 cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt); 680 cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
678 681
679 nvme_start_io_acct(bio);
680 if (++nvmeq->sq_tail == nvmeq->q_depth) 682 if (++nvmeq->sq_tail == nvmeq->q_depth)
681 nvmeq->sq_tail = 0; 683 nvmeq->sq_tail = 0;
682 writel(nvmeq->sq_tail, nvmeq->q_db); 684 writel(nvmeq->sq_tail, nvmeq->q_db);
683 685
684 return 0; 686 return 0;
687}
688
689/*
690 * Called with local interrupts disabled and the q_lock held. May not sleep.
691 */
692static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
693 struct bio *bio)
694{
695 struct nvme_iod *iod;
696 int psegs = bio_phys_segments(ns->queue, bio);
697 int result;
698
699 if ((bio->bi_rw & REQ_FLUSH) && psegs) {
700 result = nvme_submit_flush_data(nvmeq, ns);
701 if (result)
702 return result;
703 }
704
705 iod = nvme_alloc_iod(psegs, bio->bi_iter.bi_size, GFP_ATOMIC);
706 if (!iod)
707 return -ENOMEM;
708
709 iod->private = bio;
710 if (bio->bi_rw & REQ_DISCARD) {
711 void *range;
712 /*
713 * We reuse the small pool to allocate the 16-byte range here
714 * as it is not worth having a special pool for these or
715 * additional cases to handle freeing the iod.
716 */
717 range = dma_pool_alloc(nvmeq->dev->prp_small_pool,
718 GFP_ATOMIC,
719 &iod->first_dma);
720 if (!range) {
721 result = -ENOMEM;
722 goto free_iod;
723 }
724 iod_list(iod)[0] = (__le64 *)range;
725 iod->npages = 0;
726 } else if (psegs) {
727 result = nvme_map_bio(nvmeq, iod, bio,
728 bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
729 psegs);
730 if (result <= 0)
731 goto free_iod;
732 if (nvme_setup_prps(nvmeq->dev, iod, result, GFP_ATOMIC) !=
733 result) {
734 result = -ENOMEM;
735 goto free_iod;
736 }
737 nvme_start_io_acct(bio);
738 }
739 if (unlikely(nvme_submit_iod(nvmeq, iod))) {
740 if (!waitqueue_active(&nvmeq->sq_full))
741 add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait);
742 list_add_tail(&iod->node, &nvmeq->iod_bio);
743 }
744 return 0;
685 745
686 free_cmdid:
687 free_cmdid(nvmeq, cmdid, NULL);
688 free_iod: 746 free_iod:
689 nvme_free_iod(nvmeq->dev, iod); 747 nvme_free_iod(nvmeq->dev, iod);
690 nomem:
691 return result; 748 return result;
692} 749}
693 750
@@ -711,7 +768,7 @@ static int nvme_process_cq(struct nvme_queue *nvmeq)
711 } 768 }
712 769
713 ctx = free_cmdid(nvmeq, cqe.command_id, &fn); 770 ctx = free_cmdid(nvmeq, cqe.command_id, &fn);
714 fn(nvmeq->dev, ctx, &cqe); 771 fn(nvmeq, ctx, &cqe);
715 } 772 }
716 773
717 /* If the controller ignores the cq head doorbell and continuously 774 /* If the controller ignores the cq head doorbell and continuously
@@ -747,7 +804,7 @@ static void nvme_make_request(struct request_queue *q, struct bio *bio)
747 if (!nvmeq->q_suspended && bio_list_empty(&nvmeq->sq_cong)) 804 if (!nvmeq->q_suspended && bio_list_empty(&nvmeq->sq_cong))
748 result = nvme_submit_bio_queue(nvmeq, ns, bio); 805 result = nvme_submit_bio_queue(nvmeq, ns, bio);
749 if (unlikely(result)) { 806 if (unlikely(result)) {
750 if (bio_list_empty(&nvmeq->sq_cong)) 807 if (!waitqueue_active(&nvmeq->sq_full))
751 add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait); 808 add_wait_queue(&nvmeq->sq_full, &nvmeq->sq_cong_wait);
752 bio_list_add(&nvmeq->sq_cong, bio); 809 bio_list_add(&nvmeq->sq_cong, bio);
753 } 810 }
@@ -791,7 +848,7 @@ struct sync_cmd_info {
791 int status; 848 int status;
792}; 849};
793 850
794static void sync_completion(struct nvme_dev *dev, void *ctx, 851static void sync_completion(struct nvme_queue *nvmeq, void *ctx,
795 struct nvme_completion *cqe) 852 struct nvme_completion *cqe)
796{ 853{
797 struct sync_cmd_info *cmdinfo = ctx; 854 struct sync_cmd_info *cmdinfo = ctx;
@@ -804,27 +861,46 @@ static void sync_completion(struct nvme_dev *dev, void *ctx,
804 * Returns 0 on success. If the result is negative, it's a Linux error code; 861 * Returns 0 on success. If the result is negative, it's a Linux error code;
805 * if the result is positive, it's an NVM Express status code 862 * if the result is positive, it's an NVM Express status code
806 */ 863 */
807int nvme_submit_sync_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd, 864static int nvme_submit_sync_cmd(struct nvme_dev *dev, int q_idx,
865 struct nvme_command *cmd,
808 u32 *result, unsigned timeout) 866 u32 *result, unsigned timeout)
809{ 867{
810 int cmdid; 868 int cmdid, ret;
811 struct sync_cmd_info cmdinfo; 869 struct sync_cmd_info cmdinfo;
870 struct nvme_queue *nvmeq;
871
872 nvmeq = lock_nvmeq(dev, q_idx);
873 if (!nvmeq) {
874 unlock_nvmeq(nvmeq);
875 return -ENODEV;
876 }
812 877
813 cmdinfo.task = current; 878 cmdinfo.task = current;
814 cmdinfo.status = -EINTR; 879 cmdinfo.status = -EINTR;
815 880
816 cmdid = alloc_cmdid_killable(nvmeq, &cmdinfo, sync_completion, 881 cmdid = alloc_cmdid(nvmeq, &cmdinfo, sync_completion, timeout);
817 timeout); 882 if (cmdid < 0) {
818 if (cmdid < 0) 883 unlock_nvmeq(nvmeq);
819 return cmdid; 884 return cmdid;
885 }
820 cmd->common.command_id = cmdid; 886 cmd->common.command_id = cmdid;
821 887
822 set_current_state(TASK_KILLABLE); 888 set_current_state(TASK_KILLABLE);
823 nvme_submit_cmd(nvmeq, cmd); 889 ret = nvme_submit_cmd(nvmeq, cmd);
890 if (ret) {
891 free_cmdid(nvmeq, cmdid, NULL);
892 unlock_nvmeq(nvmeq);
893 set_current_state(TASK_RUNNING);
894 return ret;
895 }
896 unlock_nvmeq(nvmeq);
824 schedule_timeout(timeout); 897 schedule_timeout(timeout);
825 898
826 if (cmdinfo.status == -EINTR) { 899 if (cmdinfo.status == -EINTR) {
827 nvme_abort_command(nvmeq, cmdid); 900 nvmeq = lock_nvmeq(dev, q_idx);
901 if (nvmeq)
902 nvme_abort_command(nvmeq, cmdid);
903 unlock_nvmeq(nvmeq);
828 return -EINTR; 904 return -EINTR;
829 } 905 }
830 906
@@ -845,20 +921,26 @@ static int nvme_submit_async_cmd(struct nvme_queue *nvmeq,
845 return cmdid; 921 return cmdid;
846 cmdinfo->status = -EINTR; 922 cmdinfo->status = -EINTR;
847 cmd->common.command_id = cmdid; 923 cmd->common.command_id = cmdid;
848 nvme_submit_cmd(nvmeq, cmd); 924 return nvme_submit_cmd(nvmeq, cmd);
849 return 0;
850} 925}
851 926
852int nvme_submit_admin_cmd(struct nvme_dev *dev, struct nvme_command *cmd, 927int nvme_submit_admin_cmd(struct nvme_dev *dev, struct nvme_command *cmd,
853 u32 *result) 928 u32 *result)
854{ 929{
855 return nvme_submit_sync_cmd(dev->queues[0], cmd, result, ADMIN_TIMEOUT); 930 return nvme_submit_sync_cmd(dev, 0, cmd, result, ADMIN_TIMEOUT);
931}
932
933int nvme_submit_io_cmd(struct nvme_dev *dev, struct nvme_command *cmd,
934 u32 *result)
935{
936 return nvme_submit_sync_cmd(dev, smp_processor_id() + 1, cmd, result,
937 NVME_IO_TIMEOUT);
856} 938}
857 939
858static int nvme_submit_admin_cmd_async(struct nvme_dev *dev, 940static int nvme_submit_admin_cmd_async(struct nvme_dev *dev,
859 struct nvme_command *cmd, struct async_cmd_info *cmdinfo) 941 struct nvme_command *cmd, struct async_cmd_info *cmdinfo)
860{ 942{
861 return nvme_submit_async_cmd(dev->queues[0], cmd, cmdinfo, 943 return nvme_submit_async_cmd(raw_nvmeq(dev, 0), cmd, cmdinfo,
862 ADMIN_TIMEOUT); 944 ADMIN_TIMEOUT);
863} 945}
864 946
@@ -985,6 +1067,7 @@ static void nvme_abort_cmd(int cmdid, struct nvme_queue *nvmeq)
985 struct nvme_command cmd; 1067 struct nvme_command cmd;
986 struct nvme_dev *dev = nvmeq->dev; 1068 struct nvme_dev *dev = nvmeq->dev;
987 struct nvme_cmd_info *info = nvme_cmd_info(nvmeq); 1069 struct nvme_cmd_info *info = nvme_cmd_info(nvmeq);
1070 struct nvme_queue *adminq;
988 1071
989 if (!nvmeq->qid || info[cmdid].aborted) { 1072 if (!nvmeq->qid || info[cmdid].aborted) {
990 if (work_busy(&dev->reset_work)) 1073 if (work_busy(&dev->reset_work))
@@ -1001,7 +1084,8 @@ static void nvme_abort_cmd(int cmdid, struct nvme_queue *nvmeq)
1001 if (!dev->abort_limit) 1084 if (!dev->abort_limit)
1002 return; 1085 return;
1003 1086
1004 a_cmdid = alloc_cmdid(dev->queues[0], CMD_CTX_ABORT, special_completion, 1087 adminq = rcu_dereference(dev->queues[0]);
1088 a_cmdid = alloc_cmdid(adminq, CMD_CTX_ABORT, special_completion,
1005 ADMIN_TIMEOUT); 1089 ADMIN_TIMEOUT);
1006 if (a_cmdid < 0) 1090 if (a_cmdid < 0)
1007 return; 1091 return;
@@ -1018,7 +1102,7 @@ static void nvme_abort_cmd(int cmdid, struct nvme_queue *nvmeq)
1018 1102
1019 dev_warn(nvmeq->q_dmadev, "Aborting I/O %d QID %d\n", cmdid, 1103 dev_warn(nvmeq->q_dmadev, "Aborting I/O %d QID %d\n", cmdid,
1020 nvmeq->qid); 1104 nvmeq->qid);
1021 nvme_submit_cmd(dev->queues[0], &cmd); 1105 nvme_submit_cmd(adminq, &cmd);
1022} 1106}
1023 1107
1024/** 1108/**
@@ -1051,23 +1135,38 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
1051 dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d QID %d\n", cmdid, 1135 dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d QID %d\n", cmdid,
1052 nvmeq->qid); 1136 nvmeq->qid);
1053 ctx = cancel_cmdid(nvmeq, cmdid, &fn); 1137 ctx = cancel_cmdid(nvmeq, cmdid, &fn);
1054 fn(nvmeq->dev, ctx, &cqe); 1138 fn(nvmeq, ctx, &cqe);
1055 } 1139 }
1056} 1140}
1057 1141
1058static void nvme_free_queue(struct nvme_queue *nvmeq) 1142static void nvme_free_queue(struct rcu_head *r)
1059{ 1143{
1144 struct nvme_queue *nvmeq = container_of(r, struct nvme_queue, r_head);
1145
1060 spin_lock_irq(&nvmeq->q_lock); 1146 spin_lock_irq(&nvmeq->q_lock);
1061 while (bio_list_peek(&nvmeq->sq_cong)) { 1147 while (bio_list_peek(&nvmeq->sq_cong)) {
1062 struct bio *bio = bio_list_pop(&nvmeq->sq_cong); 1148 struct bio *bio = bio_list_pop(&nvmeq->sq_cong);
1063 bio_endio(bio, -EIO); 1149 bio_endio(bio, -EIO);
1064 } 1150 }
1151 while (!list_empty(&nvmeq->iod_bio)) {
1152 static struct nvme_completion cqe = {
1153 .status = cpu_to_le16(
1154 (NVME_SC_ABORT_REQ | NVME_SC_DNR) << 1),
1155 };
1156 struct nvme_iod *iod = list_first_entry(&nvmeq->iod_bio,
1157 struct nvme_iod,
1158 node);
1159 list_del(&iod->node);
1160 bio_completion(nvmeq, iod, &cqe);
1161 }
1065 spin_unlock_irq(&nvmeq->q_lock); 1162 spin_unlock_irq(&nvmeq->q_lock);
1066 1163
1067 dma_free_coherent(nvmeq->q_dmadev, CQ_SIZE(nvmeq->q_depth), 1164 dma_free_coherent(nvmeq->q_dmadev, CQ_SIZE(nvmeq->q_depth),
1068 (void *)nvmeq->cqes, nvmeq->cq_dma_addr); 1165 (void *)nvmeq->cqes, nvmeq->cq_dma_addr);
1069 dma_free_coherent(nvmeq->q_dmadev, SQ_SIZE(nvmeq->q_depth), 1166 dma_free_coherent(nvmeq->q_dmadev, SQ_SIZE(nvmeq->q_depth),
1070 nvmeq->sq_cmds, nvmeq->sq_dma_addr); 1167 nvmeq->sq_cmds, nvmeq->sq_dma_addr);
1168 if (nvmeq->qid)
1169 free_cpumask_var(nvmeq->cpu_mask);
1071 kfree(nvmeq); 1170 kfree(nvmeq);
1072} 1171}
1073 1172
@@ -1076,9 +1175,10 @@ static void nvme_free_queues(struct nvme_dev *dev, int lowest)
1076 int i; 1175 int i;
1077 1176
1078 for (i = dev->queue_count - 1; i >= lowest; i--) { 1177 for (i = dev->queue_count - 1; i >= lowest; i--) {
1079 nvme_free_queue(dev->queues[i]); 1178 struct nvme_queue *nvmeq = raw_nvmeq(dev, i);
1179 rcu_assign_pointer(dev->queues[i], NULL);
1180 call_rcu(&nvmeq->r_head, nvme_free_queue);
1080 dev->queue_count--; 1181 dev->queue_count--;
1081 dev->queues[i] = NULL;
1082 } 1182 }
1083} 1183}
1084 1184
@@ -1098,6 +1198,7 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
1098 return 1; 1198 return 1;
1099 } 1199 }
1100 nvmeq->q_suspended = 1; 1200 nvmeq->q_suspended = 1;
1201 nvmeq->dev->online_queues--;
1101 spin_unlock_irq(&nvmeq->q_lock); 1202 spin_unlock_irq(&nvmeq->q_lock);
1102 1203
1103 irq_set_affinity_hint(vector, NULL); 1204 irq_set_affinity_hint(vector, NULL);
@@ -1116,7 +1217,7 @@ static void nvme_clear_queue(struct nvme_queue *nvmeq)
1116 1217
1117static void nvme_disable_queue(struct nvme_dev *dev, int qid) 1218static void nvme_disable_queue(struct nvme_dev *dev, int qid)
1118{ 1219{
1119 struct nvme_queue *nvmeq = dev->queues[qid]; 1220 struct nvme_queue *nvmeq = raw_nvmeq(dev, qid);
1120 1221
1121 if (!nvmeq) 1222 if (!nvmeq)
1122 return; 1223 return;
@@ -1152,6 +1253,9 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
1152 if (!nvmeq->sq_cmds) 1253 if (!nvmeq->sq_cmds)
1153 goto free_cqdma; 1254 goto free_cqdma;
1154 1255
1256 if (qid && !zalloc_cpumask_var(&nvmeq->cpu_mask, GFP_KERNEL))
1257 goto free_sqdma;
1258
1155 nvmeq->q_dmadev = dmadev; 1259 nvmeq->q_dmadev = dmadev;
1156 nvmeq->dev = dev; 1260 nvmeq->dev = dev;
1157 snprintf(nvmeq->irqname, sizeof(nvmeq->irqname), "nvme%dq%d", 1261 snprintf(nvmeq->irqname, sizeof(nvmeq->irqname), "nvme%dq%d",
@@ -1162,15 +1266,20 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
1162 init_waitqueue_head(&nvmeq->sq_full); 1266 init_waitqueue_head(&nvmeq->sq_full);
1163 init_waitqueue_entry(&nvmeq->sq_cong_wait, nvme_thread); 1267 init_waitqueue_entry(&nvmeq->sq_cong_wait, nvme_thread);
1164 bio_list_init(&nvmeq->sq_cong); 1268 bio_list_init(&nvmeq->sq_cong);
1269 INIT_LIST_HEAD(&nvmeq->iod_bio);
1165 nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride]; 1270 nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
1166 nvmeq->q_depth = depth; 1271 nvmeq->q_depth = depth;
1167 nvmeq->cq_vector = vector; 1272 nvmeq->cq_vector = vector;
1168 nvmeq->qid = qid; 1273 nvmeq->qid = qid;
1169 nvmeq->q_suspended = 1; 1274 nvmeq->q_suspended = 1;
1170 dev->queue_count++; 1275 dev->queue_count++;
1276 rcu_assign_pointer(dev->queues[qid], nvmeq);
1171 1277
1172 return nvmeq; 1278 return nvmeq;
1173 1279
1280 free_sqdma:
1281 dma_free_coherent(dmadev, SQ_SIZE(depth), (void *)nvmeq->sq_cmds,
1282 nvmeq->sq_dma_addr);
1174 free_cqdma: 1283 free_cqdma:
1175 dma_free_coherent(dmadev, CQ_SIZE(depth), (void *)nvmeq->cqes, 1284 dma_free_coherent(dmadev, CQ_SIZE(depth), (void *)nvmeq->cqes,
1176 nvmeq->cq_dma_addr); 1285 nvmeq->cq_dma_addr);
@@ -1203,6 +1312,7 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
1203 memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth)); 1312 memset((void *)nvmeq->cqes, 0, CQ_SIZE(nvmeq->q_depth));
1204 nvme_cancel_ios(nvmeq, false); 1313 nvme_cancel_ios(nvmeq, false);
1205 nvmeq->q_suspended = 0; 1314 nvmeq->q_suspended = 0;
1315 dev->online_queues++;
1206} 1316}
1207 1317
1208static int nvme_create_queue(struct nvme_queue *nvmeq, int qid) 1318static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
@@ -1311,12 +1421,11 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
1311 if (result < 0) 1421 if (result < 0)
1312 return result; 1422 return result;
1313 1423
1314 nvmeq = dev->queues[0]; 1424 nvmeq = raw_nvmeq(dev, 0);
1315 if (!nvmeq) { 1425 if (!nvmeq) {
1316 nvmeq = nvme_alloc_queue(dev, 0, 64, 0); 1426 nvmeq = nvme_alloc_queue(dev, 0, 64, 0);
1317 if (!nvmeq) 1427 if (!nvmeq)
1318 return -ENOMEM; 1428 return -ENOMEM;
1319 dev->queues[0] = nvmeq;
1320 } 1429 }
1321 1430
1322 aqa = nvmeq->q_depth - 1; 1431 aqa = nvmeq->q_depth - 1;
@@ -1418,7 +1527,6 @@ void nvme_unmap_user_pages(struct nvme_dev *dev, int write,
1418static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) 1527static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
1419{ 1528{
1420 struct nvme_dev *dev = ns->dev; 1529 struct nvme_dev *dev = ns->dev;
1421 struct nvme_queue *nvmeq;
1422 struct nvme_user_io io; 1530 struct nvme_user_io io;
1423 struct nvme_command c; 1531 struct nvme_command c;
1424 unsigned length, meta_len; 1532 unsigned length, meta_len;
@@ -1492,22 +1600,14 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
1492 c.rw.metadata = cpu_to_le64(meta_dma_addr); 1600 c.rw.metadata = cpu_to_le64(meta_dma_addr);
1493 } 1601 }
1494 1602
1495 length = nvme_setup_prps(dev, &c.common, iod, length, GFP_KERNEL); 1603 length = nvme_setup_prps(dev, iod, length, GFP_KERNEL);
1604 c.rw.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
1605 c.rw.prp2 = cpu_to_le64(iod->first_dma);
1496 1606
1497 nvmeq = get_nvmeq(dev);
1498 /*
1499 * Since nvme_submit_sync_cmd sleeps, we can't keep preemption
1500 * disabled. We may be preempted at any point, and be rescheduled
1501 * to a different CPU. That will cause cacheline bouncing, but no
1502 * additional races since q_lock already protects against other CPUs.
1503 */
1504 put_nvmeq(nvmeq);
1505 if (length != (io.nblocks + 1) << ns->lba_shift) 1607 if (length != (io.nblocks + 1) << ns->lba_shift)
1506 status = -ENOMEM; 1608 status = -ENOMEM;
1507 else if (!nvmeq || nvmeq->q_suspended)
1508 status = -EBUSY;
1509 else 1609 else
1510 status = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT); 1610 status = nvme_submit_io_cmd(dev, &c, NULL);
1511 1611
1512 if (meta_len) { 1612 if (meta_len) {
1513 if (status == NVME_SC_SUCCESS && !(io.opcode & 1)) { 1613 if (status == NVME_SC_SUCCESS && !(io.opcode & 1)) {
@@ -1572,8 +1672,9 @@ static int nvme_user_admin_cmd(struct nvme_dev *dev,
1572 length); 1672 length);
1573 if (IS_ERR(iod)) 1673 if (IS_ERR(iod))
1574 return PTR_ERR(iod); 1674 return PTR_ERR(iod);
1575 length = nvme_setup_prps(dev, &c.common, iod, length, 1675 length = nvme_setup_prps(dev, iod, length, GFP_KERNEL);
1576 GFP_KERNEL); 1676 c.common.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
1677 c.common.prp2 = cpu_to_le64(iod->first_dma);
1577 } 1678 }
1578 1679
1579 timeout = cmd.timeout_ms ? msecs_to_jiffies(cmd.timeout_ms) : 1680 timeout = cmd.timeout_ms ? msecs_to_jiffies(cmd.timeout_ms) :
@@ -1581,8 +1682,7 @@ static int nvme_user_admin_cmd(struct nvme_dev *dev,
1581 if (length != cmd.data_len) 1682 if (length != cmd.data_len)
1582 status = -ENOMEM; 1683 status = -ENOMEM;
1583 else 1684 else
1584 status = nvme_submit_sync_cmd(dev->queues[0], &c, &cmd.result, 1685 status = nvme_submit_sync_cmd(dev, 0, &c, &cmd.result, timeout);
1585 timeout);
1586 1686
1587 if (cmd.data_len) { 1687 if (cmd.data_len) {
1588 nvme_unmap_user_pages(dev, cmd.opcode & 1, iod); 1688 nvme_unmap_user_pages(dev, cmd.opcode & 1, iod);
@@ -1653,25 +1753,51 @@ static void nvme_release(struct gendisk *disk, fmode_t mode)
1653 kref_put(&dev->kref, nvme_free_dev); 1753 kref_put(&dev->kref, nvme_free_dev);
1654} 1754}
1655 1755
1756static int nvme_getgeo(struct block_device *bd, struct hd_geometry *geo)
1757{
1758 /* some standard values */
1759 geo->heads = 1 << 6;
1760 geo->sectors = 1 << 5;
1761 geo->cylinders = get_capacity(bd->bd_disk) >> 11;
1762 return 0;
1763}
1764
1656static const struct block_device_operations nvme_fops = { 1765static const struct block_device_operations nvme_fops = {
1657 .owner = THIS_MODULE, 1766 .owner = THIS_MODULE,
1658 .ioctl = nvme_ioctl, 1767 .ioctl = nvme_ioctl,
1659 .compat_ioctl = nvme_compat_ioctl, 1768 .compat_ioctl = nvme_compat_ioctl,
1660 .open = nvme_open, 1769 .open = nvme_open,
1661 .release = nvme_release, 1770 .release = nvme_release,
1771 .getgeo = nvme_getgeo,
1662}; 1772};
1663 1773
1774static void nvme_resubmit_iods(struct nvme_queue *nvmeq)
1775{
1776 struct nvme_iod *iod, *next;
1777
1778 list_for_each_entry_safe(iod, next, &nvmeq->iod_bio, node) {
1779 if (unlikely(nvme_submit_iod(nvmeq, iod)))
1780 break;
1781 list_del(&iod->node);
1782 if (bio_list_empty(&nvmeq->sq_cong) &&
1783 list_empty(&nvmeq->iod_bio))
1784 remove_wait_queue(&nvmeq->sq_full,
1785 &nvmeq->sq_cong_wait);
1786 }
1787}
1788
1664static void nvme_resubmit_bios(struct nvme_queue *nvmeq) 1789static void nvme_resubmit_bios(struct nvme_queue *nvmeq)
1665{ 1790{
1666 while (bio_list_peek(&nvmeq->sq_cong)) { 1791 while (bio_list_peek(&nvmeq->sq_cong)) {
1667 struct bio *bio = bio_list_pop(&nvmeq->sq_cong); 1792 struct bio *bio = bio_list_pop(&nvmeq->sq_cong);
1668 struct nvme_ns *ns = bio->bi_bdev->bd_disk->private_data; 1793 struct nvme_ns *ns = bio->bi_bdev->bd_disk->private_data;
1669 1794
1670 if (bio_list_empty(&nvmeq->sq_cong)) 1795 if (bio_list_empty(&nvmeq->sq_cong) &&
1796 list_empty(&nvmeq->iod_bio))
1671 remove_wait_queue(&nvmeq->sq_full, 1797 remove_wait_queue(&nvmeq->sq_full,
1672 &nvmeq->sq_cong_wait); 1798 &nvmeq->sq_cong_wait);
1673 if (nvme_submit_bio_queue(nvmeq, ns, bio)) { 1799 if (nvme_submit_bio_queue(nvmeq, ns, bio)) {
1674 if (bio_list_empty(&nvmeq->sq_cong)) 1800 if (!waitqueue_active(&nvmeq->sq_full))
1675 add_wait_queue(&nvmeq->sq_full, 1801 add_wait_queue(&nvmeq->sq_full,
1676 &nvmeq->sq_cong_wait); 1802 &nvmeq->sq_cong_wait);
1677 bio_list_add_head(&nvmeq->sq_cong, bio); 1803 bio_list_add_head(&nvmeq->sq_cong, bio);
@@ -1700,8 +1826,10 @@ static int nvme_kthread(void *data)
1700 queue_work(nvme_workq, &dev->reset_work); 1826 queue_work(nvme_workq, &dev->reset_work);
1701 continue; 1827 continue;
1702 } 1828 }
1829 rcu_read_lock();
1703 for (i = 0; i < dev->queue_count; i++) { 1830 for (i = 0; i < dev->queue_count; i++) {
1704 struct nvme_queue *nvmeq = dev->queues[i]; 1831 struct nvme_queue *nvmeq =
1832 rcu_dereference(dev->queues[i]);
1705 if (!nvmeq) 1833 if (!nvmeq)
1706 continue; 1834 continue;
1707 spin_lock_irq(&nvmeq->q_lock); 1835 spin_lock_irq(&nvmeq->q_lock);
@@ -1710,9 +1838,11 @@ static int nvme_kthread(void *data)
1710 nvme_process_cq(nvmeq); 1838 nvme_process_cq(nvmeq);
1711 nvme_cancel_ios(nvmeq, true); 1839 nvme_cancel_ios(nvmeq, true);
1712 nvme_resubmit_bios(nvmeq); 1840 nvme_resubmit_bios(nvmeq);
1841 nvme_resubmit_iods(nvmeq);
1713 unlock: 1842 unlock:
1714 spin_unlock_irq(&nvmeq->q_lock); 1843 spin_unlock_irq(&nvmeq->q_lock);
1715 } 1844 }
1845 rcu_read_unlock();
1716 } 1846 }
1717 spin_unlock(&dev_list_lock); 1847 spin_unlock(&dev_list_lock);
1718 schedule_timeout(round_jiffies_relative(HZ)); 1848 schedule_timeout(round_jiffies_relative(HZ));
@@ -1787,6 +1917,143 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid,
1787 return NULL; 1917 return NULL;
1788} 1918}
1789 1919
1920static int nvme_find_closest_node(int node)
1921{
1922 int n, val, min_val = INT_MAX, best_node = node;
1923
1924 for_each_online_node(n) {
1925 if (n == node)
1926 continue;
1927 val = node_distance(node, n);
1928 if (val < min_val) {
1929 min_val = val;
1930 best_node = n;
1931 }
1932 }
1933 return best_node;
1934}
1935
1936static void nvme_set_queue_cpus(cpumask_t *qmask, struct nvme_queue *nvmeq,
1937 int count)
1938{
1939 int cpu;
1940 for_each_cpu(cpu, qmask) {
1941 if (cpumask_weight(nvmeq->cpu_mask) >= count)
1942 break;
1943 if (!cpumask_test_and_set_cpu(cpu, nvmeq->cpu_mask))
1944 *per_cpu_ptr(nvmeq->dev->io_queue, cpu) = nvmeq->qid;
1945 }
1946}
1947
1948static void nvme_add_cpus(cpumask_t *mask, const cpumask_t *unassigned_cpus,
1949 const cpumask_t *new_mask, struct nvme_queue *nvmeq, int cpus_per_queue)
1950{
1951 int next_cpu;
1952 for_each_cpu(next_cpu, new_mask) {
1953 cpumask_or(mask, mask, get_cpu_mask(next_cpu));
1954 cpumask_or(mask, mask, topology_thread_cpumask(next_cpu));
1955 cpumask_and(mask, mask, unassigned_cpus);
1956 nvme_set_queue_cpus(mask, nvmeq, cpus_per_queue);
1957 }
1958}
1959
1960static void nvme_create_io_queues(struct nvme_dev *dev)
1961{
1962 unsigned i, max;
1963
1964 max = min(dev->max_qid, num_online_cpus());
1965 for (i = dev->queue_count; i <= max; i++)
1966 if (!nvme_alloc_queue(dev, i, dev->q_depth, i - 1))
1967 break;
1968
1969 max = min(dev->queue_count - 1, num_online_cpus());
1970 for (i = dev->online_queues; i <= max; i++)
1971 if (nvme_create_queue(raw_nvmeq(dev, i), i))
1972 break;
1973}
1974
1975/*
1976 * If there are fewer queues than online cpus, this will try to optimally
1977 * assign a queue to multiple cpus by grouping cpus that are "close" together:
1978 * thread siblings, core, socket, closest node, then whatever else is
1979 * available.
1980 */
1981static void nvme_assign_io_queues(struct nvme_dev *dev)
1982{
1983 unsigned cpu, cpus_per_queue, queues, remainder, i;
1984 cpumask_var_t unassigned_cpus;
1985
1986 nvme_create_io_queues(dev);
1987
1988 queues = min(dev->online_queues - 1, num_online_cpus());
1989 if (!queues)
1990 return;
1991
1992 cpus_per_queue = num_online_cpus() / queues;
1993 remainder = queues - (num_online_cpus() - queues * cpus_per_queue);
1994
1995 if (!alloc_cpumask_var(&unassigned_cpus, GFP_KERNEL))
1996 return;
1997
1998 cpumask_copy(unassigned_cpus, cpu_online_mask);
1999 cpu = cpumask_first(unassigned_cpus);
2000 for (i = 1; i <= queues; i++) {
2001 struct nvme_queue *nvmeq = lock_nvmeq(dev, i);
2002 cpumask_t mask;
2003
2004 cpumask_clear(nvmeq->cpu_mask);
2005 if (!cpumask_weight(unassigned_cpus)) {
2006 unlock_nvmeq(nvmeq);
2007 break;
2008 }
2009
2010 mask = *get_cpu_mask(cpu);
2011 nvme_set_queue_cpus(&mask, nvmeq, cpus_per_queue);
2012 if (cpus_weight(mask) < cpus_per_queue)
2013 nvme_add_cpus(&mask, unassigned_cpus,
2014 topology_thread_cpumask(cpu),
2015 nvmeq, cpus_per_queue);
2016 if (cpus_weight(mask) < cpus_per_queue)
2017 nvme_add_cpus(&mask, unassigned_cpus,
2018 topology_core_cpumask(cpu),
2019 nvmeq, cpus_per_queue);
2020 if (cpus_weight(mask) < cpus_per_queue)
2021 nvme_add_cpus(&mask, unassigned_cpus,
2022 cpumask_of_node(cpu_to_node(cpu)),
2023 nvmeq, cpus_per_queue);
2024 if (cpus_weight(mask) < cpus_per_queue)
2025 nvme_add_cpus(&mask, unassigned_cpus,
2026 cpumask_of_node(
2027 nvme_find_closest_node(
2028 cpu_to_node(cpu))),
2029 nvmeq, cpus_per_queue);
2030 if (cpus_weight(mask) < cpus_per_queue)
2031 nvme_add_cpus(&mask, unassigned_cpus,
2032 unassigned_cpus,
2033 nvmeq, cpus_per_queue);
2034
2035 WARN(cpumask_weight(nvmeq->cpu_mask) != cpus_per_queue,
2036 "nvme%d qid:%d mis-matched queue-to-cpu assignment\n",
2037 dev->instance, i);
2038
2039 irq_set_affinity_hint(dev->entry[nvmeq->cq_vector].vector,
2040 nvmeq->cpu_mask);
2041 cpumask_andnot(unassigned_cpus, unassigned_cpus,
2042 nvmeq->cpu_mask);
2043 cpu = cpumask_next(cpu, unassigned_cpus);
2044 if (remainder && !--remainder)
2045 cpus_per_queue++;
2046 unlock_nvmeq(nvmeq);
2047 }
2048 WARN(cpumask_weight(unassigned_cpus), "nvme%d unassigned online cpus\n",
2049 dev->instance);
2050 i = 0;
2051 cpumask_andnot(unassigned_cpus, cpu_possible_mask, cpu_online_mask);
2052 for_each_cpu(cpu, unassigned_cpus)
2053 *per_cpu_ptr(dev->io_queue, cpu) = (i++ % queues) + 1;
2054 free_cpumask_var(unassigned_cpus);
2055}
2056
1790static int set_queue_count(struct nvme_dev *dev, int count) 2057static int set_queue_count(struct nvme_dev *dev, int count)
1791{ 2058{
1792 int status; 2059 int status;
@@ -1805,13 +2072,26 @@ static size_t db_bar_size(struct nvme_dev *dev, unsigned nr_io_queues)
1805 return 4096 + ((nr_io_queues + 1) * 8 * dev->db_stride); 2072 return 4096 + ((nr_io_queues + 1) * 8 * dev->db_stride);
1806} 2073}
1807 2074
2075static int nvme_cpu_notify(struct notifier_block *self,
2076 unsigned long action, void *hcpu)
2077{
2078 struct nvme_dev *dev = container_of(self, struct nvme_dev, nb);
2079 switch (action) {
2080 case CPU_ONLINE:
2081 case CPU_DEAD:
2082 nvme_assign_io_queues(dev);
2083 break;
2084 }
2085 return NOTIFY_OK;
2086}
2087
1808static int nvme_setup_io_queues(struct nvme_dev *dev) 2088static int nvme_setup_io_queues(struct nvme_dev *dev)
1809{ 2089{
1810 struct nvme_queue *adminq = dev->queues[0]; 2090 struct nvme_queue *adminq = raw_nvmeq(dev, 0);
1811 struct pci_dev *pdev = dev->pci_dev; 2091 struct pci_dev *pdev = dev->pci_dev;
1812 int result, cpu, i, vecs, nr_io_queues, size, q_depth; 2092 int result, i, vecs, nr_io_queues, size;
1813 2093
1814 nr_io_queues = num_online_cpus(); 2094 nr_io_queues = num_possible_cpus();
1815 result = set_queue_count(dev, nr_io_queues); 2095 result = set_queue_count(dev, nr_io_queues);
1816 if (result < 0) 2096 if (result < 0)
1817 return result; 2097 return result;
@@ -1830,7 +2110,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1830 size = db_bar_size(dev, nr_io_queues); 2110 size = db_bar_size(dev, nr_io_queues);
1831 } while (1); 2111 } while (1);
1832 dev->dbs = ((void __iomem *)dev->bar) + 4096; 2112 dev->dbs = ((void __iomem *)dev->bar) + 4096;
1833 dev->queues[0]->q_db = dev->dbs; 2113 adminq->q_db = dev->dbs;
1834 } 2114 }
1835 2115
1836 /* Deregister the admin queue's interrupt */ 2116 /* Deregister the admin queue's interrupt */
@@ -1856,6 +2136,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1856 * number of interrupts. 2136 * number of interrupts.
1857 */ 2137 */
1858 nr_io_queues = vecs; 2138 nr_io_queues = vecs;
2139 dev->max_qid = nr_io_queues;
1859 2140
1860 result = queue_request_irq(dev, adminq, adminq->irqname); 2141 result = queue_request_irq(dev, adminq, adminq->irqname);
1861 if (result) { 2142 if (result) {
@@ -1864,49 +2145,13 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1864 } 2145 }
1865 2146
1866 /* Free previously allocated queues that are no longer usable */ 2147 /* Free previously allocated queues that are no longer usable */
1867 spin_lock(&dev_list_lock); 2148 nvme_free_queues(dev, nr_io_queues + 1);
1868 for (i = dev->queue_count - 1; i > nr_io_queues; i--) { 2149 nvme_assign_io_queues(dev);
1869 struct nvme_queue *nvmeq = dev->queues[i];
1870
1871 spin_lock_irq(&nvmeq->q_lock);
1872 nvme_cancel_ios(nvmeq, false);
1873 spin_unlock_irq(&nvmeq->q_lock);
1874
1875 nvme_free_queue(nvmeq);
1876 dev->queue_count--;
1877 dev->queues[i] = NULL;
1878 }
1879 spin_unlock(&dev_list_lock);
1880
1881 cpu = cpumask_first(cpu_online_mask);
1882 for (i = 0; i < nr_io_queues; i++) {
1883 irq_set_affinity_hint(dev->entry[i].vector, get_cpu_mask(cpu));
1884 cpu = cpumask_next(cpu, cpu_online_mask);
1885 }
1886
1887 q_depth = min_t(int, NVME_CAP_MQES(readq(&dev->bar->cap)) + 1,
1888 NVME_Q_DEPTH);
1889 for (i = dev->queue_count - 1; i < nr_io_queues; i++) {
1890 dev->queues[i + 1] = nvme_alloc_queue(dev, i + 1, q_depth, i);
1891 if (!dev->queues[i + 1]) {
1892 result = -ENOMEM;
1893 goto free_queues;
1894 }
1895 }
1896
1897 for (; i < num_possible_cpus(); i++) {
1898 int target = i % rounddown_pow_of_two(dev->queue_count - 1);
1899 dev->queues[i + 1] = dev->queues[target + 1];
1900 }
1901 2150
1902 for (i = 1; i < dev->queue_count; i++) { 2151 dev->nb.notifier_call = &nvme_cpu_notify;
1903 result = nvme_create_queue(dev->queues[i], i); 2152 result = register_hotcpu_notifier(&dev->nb);
1904 if (result) { 2153 if (result)
1905 for (--i; i > 0; i--) 2154 goto free_queues;
1906 nvme_disable_queue(dev, i);
1907 goto free_queues;
1908 }
1909 }
1910 2155
1911 return 0; 2156 return 0;
1912 2157
@@ -1985,6 +2230,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
1985 2230
1986static int nvme_dev_map(struct nvme_dev *dev) 2231static int nvme_dev_map(struct nvme_dev *dev)
1987{ 2232{
2233 u64 cap;
1988 int bars, result = -ENOMEM; 2234 int bars, result = -ENOMEM;
1989 struct pci_dev *pdev = dev->pci_dev; 2235 struct pci_dev *pdev = dev->pci_dev;
1990 2236
@@ -2008,7 +2254,9 @@ static int nvme_dev_map(struct nvme_dev *dev)
2008 result = -ENODEV; 2254 result = -ENODEV;
2009 goto unmap; 2255 goto unmap;
2010 } 2256 }
2011 dev->db_stride = 1 << NVME_CAP_STRIDE(readq(&dev->bar->cap)); 2257 cap = readq(&dev->bar->cap);
2258 dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH);
2259 dev->db_stride = 1 << NVME_CAP_STRIDE(cap);
2012 dev->dbs = ((void __iomem *)dev->bar) + 4096; 2260 dev->dbs = ((void __iomem *)dev->bar) + 4096;
2013 2261
2014 return 0; 2262 return 0;
@@ -2164,7 +2412,7 @@ static void nvme_disable_io_queues(struct nvme_dev *dev)
2164 atomic_set(&dq.refcount, 0); 2412 atomic_set(&dq.refcount, 0);
2165 dq.worker = &worker; 2413 dq.worker = &worker;
2166 for (i = dev->queue_count - 1; i > 0; i--) { 2414 for (i = dev->queue_count - 1; i > 0; i--) {
2167 struct nvme_queue *nvmeq = dev->queues[i]; 2415 struct nvme_queue *nvmeq = raw_nvmeq(dev, i);
2168 2416
2169 if (nvme_suspend_queue(nvmeq)) 2417 if (nvme_suspend_queue(nvmeq))
2170 continue; 2418 continue;
@@ -2177,19 +2425,38 @@ static void nvme_disable_io_queues(struct nvme_dev *dev)
2177 kthread_stop(kworker_task); 2425 kthread_stop(kworker_task);
2178} 2426}
2179 2427
2428/*
2429* Remove the node from the device list and check
2430* for whether or not we need to stop the nvme_thread.
2431*/
2432static void nvme_dev_list_remove(struct nvme_dev *dev)
2433{
2434 struct task_struct *tmp = NULL;
2435
2436 spin_lock(&dev_list_lock);
2437 list_del_init(&dev->node);
2438 if (list_empty(&dev_list) && !IS_ERR_OR_NULL(nvme_thread)) {
2439 tmp = nvme_thread;
2440 nvme_thread = NULL;
2441 }
2442 spin_unlock(&dev_list_lock);
2443
2444 if (tmp)
2445 kthread_stop(tmp);
2446}
2447
2180static void nvme_dev_shutdown(struct nvme_dev *dev) 2448static void nvme_dev_shutdown(struct nvme_dev *dev)
2181{ 2449{
2182 int i; 2450 int i;
2183 2451
2184 dev->initialized = 0; 2452 dev->initialized = 0;
2453 unregister_hotcpu_notifier(&dev->nb);
2185 2454
2186 spin_lock(&dev_list_lock); 2455 nvme_dev_list_remove(dev);
2187 list_del_init(&dev->node);
2188 spin_unlock(&dev_list_lock);
2189 2456
2190 if (!dev->bar || (dev->bar && readl(&dev->bar->csts) == -1)) { 2457 if (!dev->bar || (dev->bar && readl(&dev->bar->csts) == -1)) {
2191 for (i = dev->queue_count - 1; i >= 0; i--) { 2458 for (i = dev->queue_count - 1; i >= 0; i--) {
2192 struct nvme_queue *nvmeq = dev->queues[i]; 2459 struct nvme_queue *nvmeq = raw_nvmeq(dev, i);
2193 nvme_suspend_queue(nvmeq); 2460 nvme_suspend_queue(nvmeq);
2194 nvme_clear_queue(nvmeq); 2461 nvme_clear_queue(nvmeq);
2195 } 2462 }
@@ -2282,6 +2549,7 @@ static void nvme_free_dev(struct kref *kref)
2282 struct nvme_dev *dev = container_of(kref, struct nvme_dev, kref); 2549 struct nvme_dev *dev = container_of(kref, struct nvme_dev, kref);
2283 2550
2284 nvme_free_namespaces(dev); 2551 nvme_free_namespaces(dev);
2552 free_percpu(dev->io_queue);
2285 kfree(dev->queues); 2553 kfree(dev->queues);
2286 kfree(dev->entry); 2554 kfree(dev->entry);
2287 kfree(dev); 2555 kfree(dev);
@@ -2325,6 +2593,7 @@ static const struct file_operations nvme_dev_fops = {
2325static int nvme_dev_start(struct nvme_dev *dev) 2593static int nvme_dev_start(struct nvme_dev *dev)
2326{ 2594{
2327 int result; 2595 int result;
2596 bool start_thread = false;
2328 2597
2329 result = nvme_dev_map(dev); 2598 result = nvme_dev_map(dev);
2330 if (result) 2599 if (result)
@@ -2335,9 +2604,24 @@ static int nvme_dev_start(struct nvme_dev *dev)
2335 goto unmap; 2604 goto unmap;
2336 2605
2337 spin_lock(&dev_list_lock); 2606 spin_lock(&dev_list_lock);
2607 if (list_empty(&dev_list) && IS_ERR_OR_NULL(nvme_thread)) {
2608 start_thread = true;
2609 nvme_thread = NULL;
2610 }
2338 list_add(&dev->node, &dev_list); 2611 list_add(&dev->node, &dev_list);
2339 spin_unlock(&dev_list_lock); 2612 spin_unlock(&dev_list_lock);
2340 2613
2614 if (start_thread) {
2615 nvme_thread = kthread_run(nvme_kthread, NULL, "nvme");
2616 wake_up(&nvme_kthread_wait);
2617 } else
2618 wait_event_killable(nvme_kthread_wait, nvme_thread);
2619
2620 if (IS_ERR_OR_NULL(nvme_thread)) {
2621 result = nvme_thread ? PTR_ERR(nvme_thread) : -EINTR;
2622 goto disable;
2623 }
2624
2341 result = nvme_setup_io_queues(dev); 2625 result = nvme_setup_io_queues(dev);
2342 if (result && result != -EBUSY) 2626 if (result && result != -EBUSY)
2343 goto disable; 2627 goto disable;
@@ -2346,9 +2630,7 @@ static int nvme_dev_start(struct nvme_dev *dev)
2346 2630
2347 disable: 2631 disable:
2348 nvme_disable_queue(dev, 0); 2632 nvme_disable_queue(dev, 0);
2349 spin_lock(&dev_list_lock); 2633 nvme_dev_list_remove(dev);
2350 list_del_init(&dev->node);
2351 spin_unlock(&dev_list_lock);
2352 unmap: 2634 unmap:
2353 nvme_dev_unmap(dev); 2635 nvme_dev_unmap(dev);
2354 return result; 2636 return result;
@@ -2367,18 +2649,10 @@ static int nvme_remove_dead_ctrl(void *arg)
2367 2649
2368static void nvme_remove_disks(struct work_struct *ws) 2650static void nvme_remove_disks(struct work_struct *ws)
2369{ 2651{
2370 int i;
2371 struct nvme_dev *dev = container_of(ws, struct nvme_dev, reset_work); 2652 struct nvme_dev *dev = container_of(ws, struct nvme_dev, reset_work);
2372 2653
2373 nvme_dev_remove(dev); 2654 nvme_dev_remove(dev);
2374 spin_lock(&dev_list_lock); 2655 nvme_free_queues(dev, 1);
2375 for (i = dev->queue_count - 1; i > 0; i--) {
2376 BUG_ON(!dev->queues[i] || !dev->queues[i]->q_suspended);
2377 nvme_free_queue(dev->queues[i]);
2378 dev->queue_count--;
2379 dev->queues[i] = NULL;
2380 }
2381 spin_unlock(&dev_list_lock);
2382} 2656}
2383 2657
2384static int nvme_dev_resume(struct nvme_dev *dev) 2658static int nvme_dev_resume(struct nvme_dev *dev)
@@ -2441,6 +2715,9 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2441 GFP_KERNEL); 2715 GFP_KERNEL);
2442 if (!dev->queues) 2716 if (!dev->queues)
2443 goto free; 2717 goto free;
2718 dev->io_queue = alloc_percpu(unsigned short);
2719 if (!dev->io_queue)
2720 goto free;
2444 2721
2445 INIT_LIST_HEAD(&dev->namespaces); 2722 INIT_LIST_HEAD(&dev->namespaces);
2446 dev->reset_workfn = nvme_reset_failed_dev; 2723 dev->reset_workfn = nvme_reset_failed_dev;
@@ -2455,6 +2732,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2455 if (result) 2732 if (result)
2456 goto release; 2733 goto release;
2457 2734
2735 kref_init(&dev->kref);
2458 result = nvme_dev_start(dev); 2736 result = nvme_dev_start(dev);
2459 if (result) { 2737 if (result) {
2460 if (result == -EBUSY) 2738 if (result == -EBUSY)
@@ -2462,7 +2740,6 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2462 goto release_pools; 2740 goto release_pools;
2463 } 2741 }
2464 2742
2465 kref_init(&dev->kref);
2466 result = nvme_dev_add(dev); 2743 result = nvme_dev_add(dev);
2467 if (result) 2744 if (result)
2468 goto shutdown; 2745 goto shutdown;
@@ -2491,6 +2768,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2491 release: 2768 release:
2492 nvme_release_instance(dev); 2769 nvme_release_instance(dev);
2493 free: 2770 free:
2771 free_percpu(dev->io_queue);
2494 kfree(dev->queues); 2772 kfree(dev->queues);
2495 kfree(dev->entry); 2773 kfree(dev->entry);
2496 kfree(dev); 2774 kfree(dev);
@@ -2517,6 +2795,7 @@ static void nvme_remove(struct pci_dev *pdev)
2517 nvme_dev_remove(dev); 2795 nvme_dev_remove(dev);
2518 nvme_dev_shutdown(dev); 2796 nvme_dev_shutdown(dev);
2519 nvme_free_queues(dev, 0); 2797 nvme_free_queues(dev, 0);
2798 rcu_barrier();
2520 nvme_release_instance(dev); 2799 nvme_release_instance(dev);
2521 nvme_release_prp_pools(dev); 2800 nvme_release_prp_pools(dev);
2522 kref_put(&dev->kref, nvme_free_dev); 2801 kref_put(&dev->kref, nvme_free_dev);
@@ -2529,6 +2808,7 @@ static void nvme_remove(struct pci_dev *pdev)
2529#define nvme_slot_reset NULL 2808#define nvme_slot_reset NULL
2530#define nvme_error_resume NULL 2809#define nvme_error_resume NULL
2531 2810
2811#ifdef CONFIG_PM_SLEEP
2532static int nvme_suspend(struct device *dev) 2812static int nvme_suspend(struct device *dev)
2533{ 2813{
2534 struct pci_dev *pdev = to_pci_dev(dev); 2814 struct pci_dev *pdev = to_pci_dev(dev);
@@ -2549,6 +2829,7 @@ static int nvme_resume(struct device *dev)
2549 } 2829 }
2550 return 0; 2830 return 0;
2551} 2831}
2832#endif
2552 2833
2553static SIMPLE_DEV_PM_OPS(nvme_dev_pm_ops, nvme_suspend, nvme_resume); 2834static SIMPLE_DEV_PM_OPS(nvme_dev_pm_ops, nvme_suspend, nvme_resume);
2554 2835
@@ -2563,7 +2844,7 @@ static const struct pci_error_handlers nvme_err_handler = {
2563/* Move to pci_ids.h later */ 2844/* Move to pci_ids.h later */
2564#define PCI_CLASS_STORAGE_EXPRESS 0x010802 2845#define PCI_CLASS_STORAGE_EXPRESS 0x010802
2565 2846
2566static DEFINE_PCI_DEVICE_TABLE(nvme_id_table) = { 2847static const struct pci_device_id nvme_id_table[] = {
2567 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, 2848 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
2568 { 0, } 2849 { 0, }
2569}; 2850};
@@ -2585,14 +2866,11 @@ static int __init nvme_init(void)
2585{ 2866{
2586 int result; 2867 int result;
2587 2868
2588 nvme_thread = kthread_run(nvme_kthread, NULL, "nvme"); 2869 init_waitqueue_head(&nvme_kthread_wait);
2589 if (IS_ERR(nvme_thread))
2590 return PTR_ERR(nvme_thread);
2591 2870
2592 result = -ENOMEM;
2593 nvme_workq = create_singlethread_workqueue("nvme"); 2871 nvme_workq = create_singlethread_workqueue("nvme");
2594 if (!nvme_workq) 2872 if (!nvme_workq)
2595 goto kill_kthread; 2873 return -ENOMEM;
2596 2874
2597 result = register_blkdev(nvme_major, "nvme"); 2875 result = register_blkdev(nvme_major, "nvme");
2598 if (result < 0) 2876 if (result < 0)
@@ -2609,8 +2887,6 @@ static int __init nvme_init(void)
2609 unregister_blkdev(nvme_major, "nvme"); 2887 unregister_blkdev(nvme_major, "nvme");
2610 kill_workq: 2888 kill_workq:
2611 destroy_workqueue(nvme_workq); 2889 destroy_workqueue(nvme_workq);
2612 kill_kthread:
2613 kthread_stop(nvme_thread);
2614 return result; 2890 return result;
2615} 2891}
2616 2892
@@ -2619,11 +2895,11 @@ static void __exit nvme_exit(void)
2619 pci_unregister_driver(&nvme_driver); 2895 pci_unregister_driver(&nvme_driver);
2620 unregister_blkdev(nvme_major, "nvme"); 2896 unregister_blkdev(nvme_major, "nvme");
2621 destroy_workqueue(nvme_workq); 2897 destroy_workqueue(nvme_workq);
2622 kthread_stop(nvme_thread); 2898 BUG_ON(nvme_thread && !IS_ERR(nvme_thread));
2623} 2899}
2624 2900
2625MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>"); 2901MODULE_AUTHOR("Matthew Wilcox <willy@linux.intel.com>");
2626MODULE_LICENSE("GPL"); 2902MODULE_LICENSE("GPL");
2627MODULE_VERSION("0.8"); 2903MODULE_VERSION("0.9");
2628module_init(nvme_init); 2904module_init(nvme_init);
2629module_exit(nvme_exit); 2905module_exit(nvme_exit);
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index 4a0ceb64e269..2c3f5be06da1 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -1562,13 +1562,14 @@ static int nvme_trans_send_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr,
1562 res = PTR_ERR(iod); 1562 res = PTR_ERR(iod);
1563 goto out; 1563 goto out;
1564 } 1564 }
1565 length = nvme_setup_prps(dev, &c.common, iod, tot_len, 1565 length = nvme_setup_prps(dev, iod, tot_len, GFP_KERNEL);
1566 GFP_KERNEL);
1567 if (length != tot_len) { 1566 if (length != tot_len) {
1568 res = -ENOMEM; 1567 res = -ENOMEM;
1569 goto out_unmap; 1568 goto out_unmap;
1570 } 1569 }
1571 1570
1571 c.dlfw.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
1572 c.dlfw.prp2 = cpu_to_le64(iod->first_dma);
1572 c.dlfw.numd = cpu_to_le32((tot_len/BYTES_TO_DWORDS) - 1); 1573 c.dlfw.numd = cpu_to_le32((tot_len/BYTES_TO_DWORDS) - 1);
1573 c.dlfw.offset = cpu_to_le32(offset/BYTES_TO_DWORDS); 1574 c.dlfw.offset = cpu_to_le32(offset/BYTES_TO_DWORDS);
1574 } else if (opcode == nvme_admin_activate_fw) { 1575 } else if (opcode == nvme_admin_activate_fw) {
@@ -2033,7 +2034,6 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2033 int res = SNTI_TRANSLATION_SUCCESS; 2034 int res = SNTI_TRANSLATION_SUCCESS;
2034 int nvme_sc; 2035 int nvme_sc;
2035 struct nvme_dev *dev = ns->dev; 2036 struct nvme_dev *dev = ns->dev;
2036 struct nvme_queue *nvmeq;
2037 u32 num_cmds; 2037 u32 num_cmds;
2038 struct nvme_iod *iod; 2038 struct nvme_iod *iod;
2039 u64 unit_len; 2039 u64 unit_len;
@@ -2045,7 +2045,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2045 struct nvme_command c; 2045 struct nvme_command c;
2046 u8 opcode = (is_write ? nvme_cmd_write : nvme_cmd_read); 2046 u8 opcode = (is_write ? nvme_cmd_write : nvme_cmd_read);
2047 u16 control; 2047 u16 control;
2048 u32 max_blocks = nvme_block_nr(ns, dev->max_hw_sectors); 2048 u32 max_blocks = queue_max_hw_sectors(ns->queue);
2049 2049
2050 num_cmds = nvme_trans_io_get_num_cmds(hdr, cdb_info, max_blocks); 2050 num_cmds = nvme_trans_io_get_num_cmds(hdr, cdb_info, max_blocks);
2051 2051
@@ -2093,8 +2093,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2093 res = PTR_ERR(iod); 2093 res = PTR_ERR(iod);
2094 goto out; 2094 goto out;
2095 } 2095 }
2096 retcode = nvme_setup_prps(dev, &c.common, iod, unit_len, 2096 retcode = nvme_setup_prps(dev, iod, unit_len, GFP_KERNEL);
2097 GFP_KERNEL);
2098 if (retcode != unit_len) { 2097 if (retcode != unit_len) {
2099 nvme_unmap_user_pages(dev, 2098 nvme_unmap_user_pages(dev,
2100 (is_write) ? DMA_TO_DEVICE : DMA_FROM_DEVICE, 2099 (is_write) ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
@@ -2103,21 +2102,12 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2103 res = -ENOMEM; 2102 res = -ENOMEM;
2104 goto out; 2103 goto out;
2105 } 2104 }
2105 c.rw.prp1 = cpu_to_le64(sg_dma_address(iod->sg));
2106 c.rw.prp2 = cpu_to_le64(iod->first_dma);
2106 2107
2107 nvme_offset += unit_num_blocks; 2108 nvme_offset += unit_num_blocks;
2108 2109
2109 nvmeq = get_nvmeq(dev); 2110 nvme_sc = nvme_submit_io_cmd(dev, &c, NULL);
2110 /*
2111 * Since nvme_submit_sync_cmd sleeps, we can't keep
2112 * preemption disabled. We may be preempted at any
2113 * point, and be rescheduled to a different CPU. That
2114 * will cause cacheline bouncing, but no additional
2115 * races since q_lock already protects against other
2116 * CPUs.
2117 */
2118 put_nvmeq(nvmeq);
2119 nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL,
2120 NVME_IO_TIMEOUT);
2121 if (nvme_sc != NVME_SC_SUCCESS) { 2111 if (nvme_sc != NVME_SC_SUCCESS) {
2122 nvme_unmap_user_pages(dev, 2112 nvme_unmap_user_pages(dev,
2123 (is_write) ? DMA_TO_DEVICE : DMA_FROM_DEVICE, 2113 (is_write) ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
@@ -2644,7 +2634,6 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2644{ 2634{
2645 int res = SNTI_TRANSLATION_SUCCESS; 2635 int res = SNTI_TRANSLATION_SUCCESS;
2646 int nvme_sc; 2636 int nvme_sc;
2647 struct nvme_queue *nvmeq;
2648 struct nvme_command c; 2637 struct nvme_command c;
2649 u8 immed, pcmod, pc, no_flush, start; 2638 u8 immed, pcmod, pc, no_flush, start;
2650 2639
@@ -2671,10 +2660,7 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2671 c.common.opcode = nvme_cmd_flush; 2660 c.common.opcode = nvme_cmd_flush;
2672 c.common.nsid = cpu_to_le32(ns->ns_id); 2661 c.common.nsid = cpu_to_le32(ns->ns_id);
2673 2662
2674 nvmeq = get_nvmeq(ns->dev); 2663 nvme_sc = nvme_submit_io_cmd(ns->dev, &c, NULL);
2675 put_nvmeq(nvmeq);
2676 nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
2677
2678 res = nvme_trans_status_code(hdr, nvme_sc); 2664 res = nvme_trans_status_code(hdr, nvme_sc);
2679 if (res) 2665 if (res)
2680 goto out; 2666 goto out;
@@ -2697,15 +2683,12 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns,
2697 int res = SNTI_TRANSLATION_SUCCESS; 2683 int res = SNTI_TRANSLATION_SUCCESS;
2698 int nvme_sc; 2684 int nvme_sc;
2699 struct nvme_command c; 2685 struct nvme_command c;
2700 struct nvme_queue *nvmeq;
2701 2686
2702 memset(&c, 0, sizeof(c)); 2687 memset(&c, 0, sizeof(c));
2703 c.common.opcode = nvme_cmd_flush; 2688 c.common.opcode = nvme_cmd_flush;
2704 c.common.nsid = cpu_to_le32(ns->ns_id); 2689 c.common.nsid = cpu_to_le32(ns->ns_id);
2705 2690
2706 nvmeq = get_nvmeq(ns->dev); 2691 nvme_sc = nvme_submit_io_cmd(ns->dev, &c, NULL);
2707 put_nvmeq(nvmeq);
2708 nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
2709 2692
2710 res = nvme_trans_status_code(hdr, nvme_sc); 2693 res = nvme_trans_status_code(hdr, nvme_sc);
2711 if (res) 2694 if (res)
@@ -2872,7 +2855,6 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2872 struct nvme_dev *dev = ns->dev; 2855 struct nvme_dev *dev = ns->dev;
2873 struct scsi_unmap_parm_list *plist; 2856 struct scsi_unmap_parm_list *plist;
2874 struct nvme_dsm_range *range; 2857 struct nvme_dsm_range *range;
2875 struct nvme_queue *nvmeq;
2876 struct nvme_command c; 2858 struct nvme_command c;
2877 int i, nvme_sc, res = -ENOMEM; 2859 int i, nvme_sc, res = -ENOMEM;
2878 u16 ndesc, list_len; 2860 u16 ndesc, list_len;
@@ -2914,10 +2896,7 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2914 c.dsm.nr = cpu_to_le32(ndesc - 1); 2896 c.dsm.nr = cpu_to_le32(ndesc - 1);
2915 c.dsm.attributes = cpu_to_le32(NVME_DSMGMT_AD); 2897 c.dsm.attributes = cpu_to_le32(NVME_DSMGMT_AD);
2916 2898
2917 nvmeq = get_nvmeq(dev); 2899 nvme_sc = nvme_submit_io_cmd(dev, &c, NULL);
2918 put_nvmeq(nvmeq);
2919
2920 nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
2921 res = nvme_trans_status_code(hdr, nvme_sc); 2900 res = nvme_trans_status_code(hdr, nvme_sc);
2922 2901
2923 dma_free_coherent(&dev->pci_dev->dev, ndesc * sizeof(*range), 2902 dma_free_coherent(&dev->pci_dev->dev, ndesc * sizeof(*range),
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 1386749b48ff..fbae63e3d304 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -408,7 +408,7 @@ config APPLICOM
408 408
409config SONYPI 409config SONYPI
410 tristate "Sony Vaio Programmable I/O Control Device support" 410 tristate "Sony Vaio Programmable I/O Control Device support"
411 depends on X86 && PCI && INPUT && !64BIT 411 depends on X86_32 && PCI && INPUT
412 ---help--- 412 ---help---
413 This driver enables access to the Sony Programmable I/O Control 413 This driver enables access to the Sony Programmable I/O Control
414 Device which can be found in many (all ?) Sony Vaio laptops. 414 Device which can be found in many (all ?) Sony Vaio laptops.
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 6928d094451d..60aafb8a1f2e 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -901,9 +901,9 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
901 if (len + offset > PAGE_SIZE) 901 if (len + offset > PAGE_SIZE)
902 len = PAGE_SIZE - offset; 902 len = PAGE_SIZE - offset;
903 903
904 src = buf->ops->map(pipe, buf, 1); 904 src = kmap_atomic(buf->page);
905 memcpy(page_address(page) + offset, src + buf->offset, len); 905 memcpy(page_address(page) + offset, src + buf->offset, len);
906 buf->ops->unmap(pipe, buf, src); 906 kunmap_atomic(src);
907 907
908 sg_set_page(&(sgl->sg[sgl->n]), page, len, offset); 908 sg_set_page(&(sgl->sg[sgl->n]), page, len, offset);
909 } 909 }
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 1e2b9db563ec..0e9cce82844b 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -30,7 +30,7 @@ config ARM_EXYNOS_CPUFREQ
30 30
31config ARM_EXYNOS4210_CPUFREQ 31config ARM_EXYNOS4210_CPUFREQ
32 bool "SAMSUNG EXYNOS4210" 32 bool "SAMSUNG EXYNOS4210"
33 depends on CPU_EXYNOS4210 33 depends on CPU_EXYNOS4210 && !ARCH_MULTIPLATFORM
34 default y 34 default y
35 select ARM_EXYNOS_CPUFREQ 35 select ARM_EXYNOS_CPUFREQ
36 help 36 help
@@ -41,7 +41,7 @@ config ARM_EXYNOS4210_CPUFREQ
41 41
42config ARM_EXYNOS4X12_CPUFREQ 42config ARM_EXYNOS4X12_CPUFREQ
43 bool "SAMSUNG EXYNOS4x12" 43 bool "SAMSUNG EXYNOS4x12"
44 depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) 44 depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412) && !ARCH_MULTIPLATFORM
45 default y 45 default y
46 select ARM_EXYNOS_CPUFREQ 46 select ARM_EXYNOS_CPUFREQ
47 help 47 help
@@ -52,7 +52,7 @@ config ARM_EXYNOS4X12_CPUFREQ
52 52
53config ARM_EXYNOS5250_CPUFREQ 53config ARM_EXYNOS5250_CPUFREQ
54 bool "SAMSUNG EXYNOS5250" 54 bool "SAMSUNG EXYNOS5250"
55 depends on SOC_EXYNOS5250 55 depends on SOC_EXYNOS5250 && !ARCH_MULTIPLATFORM
56 default y 56 default y
57 select ARM_EXYNOS_CPUFREQ 57 select ARM_EXYNOS_CPUFREQ
58 help 58 help
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc
index ca0021a96e19..72564b701b4a 100644
--- a/drivers/cpufreq/Kconfig.powerpc
+++ b/drivers/cpufreq/Kconfig.powerpc
@@ -54,3 +54,11 @@ config PPC_PASEMI_CPUFREQ
54 help 54 help
55 This adds the support for frequency switching on PA Semi 55 This adds the support for frequency switching on PA Semi
56 PWRficient processors. 56 PWRficient processors.
57
58config POWERNV_CPUFREQ
59 tristate "CPU frequency scaling for IBM POWERNV platform"
60 depends on PPC_POWERNV
61 default y
62 help
63 This adds support for CPU frequency switching on IBM POWERNV
64 platform
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 74945652dd7a..0dbb963c1aef 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o
86obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o 86obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o
87obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o 87obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o
88obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o 88obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o
89obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o
89 90
90################################################################################## 91##################################################################################
91# Other platform drivers 92# Other platform drivers
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index d5eaedbe464f..000e4e0afd7e 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -754,7 +754,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
754 goto err_unreg; 754 goto err_unreg;
755 } 755 }
756 756
757 data->freq_table = kmalloc(sizeof(*data->freq_table) * 757 data->freq_table = kzalloc(sizeof(*data->freq_table) *
758 (perf->state_count+1), GFP_KERNEL); 758 (perf->state_count+1), GFP_KERNEL);
759 if (!data->freq_table) { 759 if (!data->freq_table) {
760 result = -ENOMEM; 760 result = -ENOMEM;
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index a1c79f549edb..7b612c8bb09e 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -52,7 +52,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
52static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) 52static int at32_cpufreq_driver_init(struct cpufreq_policy *policy)
53{ 53{
54 unsigned int frequency, rate, min_freq; 54 unsigned int frequency, rate, min_freq;
55 static struct clk *cpuclk; 55 struct clk *cpuclk;
56 int retval, steps, i; 56 int retval, steps, i;
57 57
58 if (policy->cpu != 0) 58 if (policy->cpu != 0)
diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c
index d4573032cbbc..601b88c490cf 100644
--- a/drivers/cpufreq/cris-artpec3-cpufreq.c
+++ b/drivers/cpufreq/cris-artpec3-cpufreq.c
@@ -15,9 +15,9 @@ static struct notifier_block cris_sdram_freq_notifier_block = {
15}; 15};
16 16
17static struct cpufreq_frequency_table cris_freq_table[] = { 17static struct cpufreq_frequency_table cris_freq_table[] = {
18 {0x01, 6000}, 18 {0, 0x01, 6000},
19 {0x02, 200000}, 19 {0, 0x02, 200000},
20 {0, CPUFREQ_TABLE_END}, 20 {0, 0, CPUFREQ_TABLE_END},
21}; 21};
22 22
23static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu) 23static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c
index 13c3361437f7..22b2cdde74d9 100644
--- a/drivers/cpufreq/cris-etraxfs-cpufreq.c
+++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c
@@ -15,9 +15,9 @@ static struct notifier_block cris_sdram_freq_notifier_block = {
15}; 15};
16 16
17static struct cpufreq_frequency_table cris_freq_table[] = { 17static struct cpufreq_frequency_table cris_freq_table[] = {
18 {0x01, 6000}, 18 {0, 0x01, 6000},
19 {0x02, 200000}, 19 {0, 0x02, 200000},
20 {0, CPUFREQ_TABLE_END}, 20 {0, 0, CPUFREQ_TABLE_END},
21}; 21};
22 22
23static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu) 23static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c
index c987e94708f5..7f5d2a68c353 100644
--- a/drivers/cpufreq/elanfreq.c
+++ b/drivers/cpufreq/elanfreq.c
@@ -56,15 +56,15 @@ static struct s_elan_multiplier elan_multiplier[] = {
56}; 56};
57 57
58static struct cpufreq_frequency_table elanfreq_table[] = { 58static struct cpufreq_frequency_table elanfreq_table[] = {
59 {0, 1000}, 59 {0, 0, 1000},
60 {1, 2000}, 60 {0, 1, 2000},
61 {2, 4000}, 61 {0, 2, 4000},
62 {3, 8000}, 62 {0, 3, 8000},
63 {4, 16000}, 63 {0, 4, 16000},
64 {5, 33000}, 64 {0, 5, 33000},
65 {6, 66000}, 65 {0, 6, 66000},
66 {7, 99000}, 66 {0, 7, 99000},
67 {0, CPUFREQ_TABLE_END}, 67 {0, 0, CPUFREQ_TABLE_END},
68}; 68};
69 69
70 70
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index 40d84c43d8f4..6384e5b9a347 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -29,12 +29,12 @@ static unsigned int exynos4210_volt_table[] = {
29}; 29};
30 30
31static struct cpufreq_frequency_table exynos4210_freq_table[] = { 31static struct cpufreq_frequency_table exynos4210_freq_table[] = {
32 {L0, 1200 * 1000}, 32 {0, L0, 1200 * 1000},
33 {L1, 1000 * 1000}, 33 {0, L1, 1000 * 1000},
34 {L2, 800 * 1000}, 34 {0, L2, 800 * 1000},
35 {L3, 500 * 1000}, 35 {0, L3, 500 * 1000},
36 {L4, 200 * 1000}, 36 {0, L4, 200 * 1000},
37 {0, CPUFREQ_TABLE_END}, 37 {0, 0, CPUFREQ_TABLE_END},
38}; 38};
39 39
40static struct apll_freq apll_freq_4210[] = { 40static struct apll_freq apll_freq_4210[] = {
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 7c11ace3b3fc..466c76ad335b 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -30,21 +30,21 @@ static unsigned int exynos4x12_volt_table[] = {
30}; 30};
31 31
32static struct cpufreq_frequency_table exynos4x12_freq_table[] = { 32static struct cpufreq_frequency_table exynos4x12_freq_table[] = {
33 {CPUFREQ_BOOST_FREQ, 1500 * 1000}, 33 {CPUFREQ_BOOST_FREQ, L0, 1500 * 1000},
34 {L1, 1400 * 1000}, 34 {0, L1, 1400 * 1000},
35 {L2, 1300 * 1000}, 35 {0, L2, 1300 * 1000},
36 {L3, 1200 * 1000}, 36 {0, L3, 1200 * 1000},
37 {L4, 1100 * 1000}, 37 {0, L4, 1100 * 1000},
38 {L5, 1000 * 1000}, 38 {0, L5, 1000 * 1000},
39 {L6, 900 * 1000}, 39 {0, L6, 900 * 1000},
40 {L7, 800 * 1000}, 40 {0, L7, 800 * 1000},
41 {L8, 700 * 1000}, 41 {0, L8, 700 * 1000},
42 {L9, 600 * 1000}, 42 {0, L9, 600 * 1000},
43 {L10, 500 * 1000}, 43 {0, L10, 500 * 1000},
44 {L11, 400 * 1000}, 44 {0, L11, 400 * 1000},
45 {L12, 300 * 1000}, 45 {0, L12, 300 * 1000},
46 {L13, 200 * 1000}, 46 {0, L13, 200 * 1000},
47 {0, CPUFREQ_TABLE_END}, 47 {0, 0, CPUFREQ_TABLE_END},
48}; 48};
49 49
50static struct apll_freq *apll_freq_4x12; 50static struct apll_freq *apll_freq_4x12;
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index 5f90b82a4082..363a0b3fe1b1 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -34,23 +34,23 @@ static unsigned int exynos5250_volt_table[] = {
34}; 34};
35 35
36static struct cpufreq_frequency_table exynos5250_freq_table[] = { 36static struct cpufreq_frequency_table exynos5250_freq_table[] = {
37 {L0, 1700 * 1000}, 37 {0, L0, 1700 * 1000},
38 {L1, 1600 * 1000}, 38 {0, L1, 1600 * 1000},
39 {L2, 1500 * 1000}, 39 {0, L2, 1500 * 1000},
40 {L3, 1400 * 1000}, 40 {0, L3, 1400 * 1000},
41 {L4, 1300 * 1000}, 41 {0, L4, 1300 * 1000},
42 {L5, 1200 * 1000}, 42 {0, L5, 1200 * 1000},
43 {L6, 1100 * 1000}, 43 {0, L6, 1100 * 1000},
44 {L7, 1000 * 1000}, 44 {0, L7, 1000 * 1000},
45 {L8, 900 * 1000}, 45 {0, L8, 900 * 1000},
46 {L9, 800 * 1000}, 46 {0, L9, 800 * 1000},
47 {L10, 700 * 1000}, 47 {0, L10, 700 * 1000},
48 {L11, 600 * 1000}, 48 {0, L11, 600 * 1000},
49 {L12, 500 * 1000}, 49 {0, L12, 500 * 1000},
50 {L13, 400 * 1000}, 50 {0, L13, 400 * 1000},
51 {L14, 300 * 1000}, 51 {0, L14, 300 * 1000},
52 {L15, 200 * 1000}, 52 {0, L15, 200 * 1000},
53 {0, CPUFREQ_TABLE_END}, 53 {0, 0, CPUFREQ_TABLE_END},
54}; 54};
55 55
56static struct apll_freq apll_freq_5250[] = { 56static struct apll_freq apll_freq_5250[] = {
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 65a477075b3f..08e7bbcf6d73 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -33,11 +33,10 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
33 continue; 33 continue;
34 } 34 }
35 if (!cpufreq_boost_enabled() 35 if (!cpufreq_boost_enabled()
36 && table[i].driver_data == CPUFREQ_BOOST_FREQ) 36 && (table[i].flags & CPUFREQ_BOOST_FREQ))
37 continue; 37 continue;
38 38
39 pr_debug("table entry %u: %u kHz, %u driver_data\n", 39 pr_debug("table entry %u: %u kHz\n", i, freq);
40 i, freq, table[i].driver_data);
41 if (freq < min_freq) 40 if (freq < min_freq)
42 min_freq = freq; 41 min_freq = freq;
43 if (freq > max_freq) 42 if (freq > max_freq)
@@ -175,8 +174,8 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
175 } else 174 } else
176 *index = optimal.driver_data; 175 *index = optimal.driver_data;
177 176
178 pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, 177 pr_debug("target index is %u, freq is:%u kHz\n", *index,
179 table[*index].driver_data); 178 table[*index].frequency);
180 179
181 return 0; 180 return 0;
182} 181}
@@ -230,7 +229,7 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
230 * show_boost = false and driver_data != BOOST freq 229 * show_boost = false and driver_data != BOOST freq
231 * display NON BOOST freqs 230 * display NON BOOST freqs
232 */ 231 */
233 if (show_boost ^ (table[i].driver_data == CPUFREQ_BOOST_FREQ)) 232 if (show_boost ^ (table[i].flags & CPUFREQ_BOOST_FREQ))
234 continue; 233 continue;
235 234
236 count += sprintf(&buf[count], "%d ", table[i].frequency); 235 count += sprintf(&buf[count], "%d ", table[i].frequency);
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
index a22b5d182e0e..c30aaa6a54e8 100644
--- a/drivers/cpufreq/ia64-acpi-cpufreq.c
+++ b/drivers/cpufreq/ia64-acpi-cpufreq.c
@@ -254,7 +254,7 @@ acpi_cpufreq_cpu_init (
254 } 254 }
255 255
256 /* alloc freq_table */ 256 /* alloc freq_table */
257 data->freq_table = kmalloc(sizeof(*data->freq_table) * 257 data->freq_table = kzalloc(sizeof(*data->freq_table) *
258 (data->acpi_data.state_count + 1), 258 (data->acpi_data.state_count + 1),
259 GFP_KERNEL); 259 GFP_KERNEL);
260 if (!data->freq_table) { 260 if (!data->freq_table) {
@@ -275,7 +275,6 @@ acpi_cpufreq_cpu_init (
275 /* table init */ 275 /* table init */
276 for (i = 0; i <= data->acpi_data.state_count; i++) 276 for (i = 0; i <= data->acpi_data.state_count; i++)
277 { 277 {
278 data->freq_table[i].driver_data = i;
279 if (i < data->acpi_data.state_count) { 278 if (i < data->acpi_data.state_count) {
280 data->freq_table[i].frequency = 279 data->freq_table[i].frequency =
281 data->acpi_data.states[i].core_frequency * 1000; 280 data->acpi_data.states[i].core_frequency * 1000;
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 3d114bc5a97a..37a480680cd0 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -43,9 +43,9 @@ static struct priv
43 * table. 43 * table.
44 */ 44 */
45static struct cpufreq_frequency_table kirkwood_freq_table[] = { 45static struct cpufreq_frequency_table kirkwood_freq_table[] = {
46 {STATE_CPU_FREQ, 0}, /* CPU uses cpuclk */ 46 {0, STATE_CPU_FREQ, 0}, /* CPU uses cpuclk */
47 {STATE_DDR_FREQ, 0}, /* CPU uses ddrclk */ 47 {0, STATE_DDR_FREQ, 0}, /* CPU uses ddrclk */
48 {0, CPUFREQ_TABLE_END}, 48 {0, 0, CPUFREQ_TABLE_END},
49}; 49};
50 50
51static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu) 51static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index 5c440f87ba8a..d00e5d1abd25 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -475,7 +475,7 @@ static int longhaul_get_ranges(void)
475 return -EINVAL; 475 return -EINVAL;
476 } 476 }
477 477
478 longhaul_table = kmalloc((numscales + 1) * sizeof(*longhaul_table), 478 longhaul_table = kzalloc((numscales + 1) * sizeof(*longhaul_table),
479 GFP_KERNEL); 479 GFP_KERNEL);
480 if (!longhaul_table) 480 if (!longhaul_table)
481 return -ENOMEM; 481 return -ENOMEM;
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index a3588d61d933..f0bc31f5db27 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -69,7 +69,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
69 69
70static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) 70static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
71{ 71{
72 static struct clk *cpuclk; 72 struct clk *cpuclk;
73 int i; 73 int i;
74 unsigned long rate; 74 unsigned long rate;
75 int ret; 75 int ret;
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index c4dfa42a75ac..cc3408fc073f 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -59,9 +59,9 @@
59#define CPUFREQ_LOW 1 59#define CPUFREQ_LOW 1
60 60
61static struct cpufreq_frequency_table maple_cpu_freqs[] = { 61static struct cpufreq_frequency_table maple_cpu_freqs[] = {
62 {CPUFREQ_HIGH, 0}, 62 {0, CPUFREQ_HIGH, 0},
63 {CPUFREQ_LOW, 0}, 63 {0, CPUFREQ_LOW, 0},
64 {0, CPUFREQ_TABLE_END}, 64 {0, 0, CPUFREQ_TABLE_END},
65}; 65};
66 66
67/* Power mode data is an array of the 32 bits PCR values to use for 67/* Power mode data is an array of the 32 bits PCR values to use for
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
index 74f593e70e19..529cfd92158f 100644
--- a/drivers/cpufreq/p4-clockmod.c
+++ b/drivers/cpufreq/p4-clockmod.c
@@ -92,16 +92,16 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
92 92
93 93
94static struct cpufreq_frequency_table p4clockmod_table[] = { 94static struct cpufreq_frequency_table p4clockmod_table[] = {
95 {DC_RESV, CPUFREQ_ENTRY_INVALID}, 95 {0, DC_RESV, CPUFREQ_ENTRY_INVALID},
96 {DC_DFLT, 0}, 96 {0, DC_DFLT, 0},
97 {DC_25PT, 0}, 97 {0, DC_25PT, 0},
98 {DC_38PT, 0}, 98 {0, DC_38PT, 0},
99 {DC_50PT, 0}, 99 {0, DC_50PT, 0},
100 {DC_64PT, 0}, 100 {0, DC_64PT, 0},
101 {DC_75PT, 0}, 101 {0, DC_75PT, 0},
102 {DC_88PT, 0}, 102 {0, DC_88PT, 0},
103 {DC_DISABLE, 0}, 103 {0, DC_DISABLE, 0},
104 {DC_RESV, CPUFREQ_TABLE_END}, 104 {0, DC_RESV, CPUFREQ_TABLE_END},
105}; 105};
106 106
107 107
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c
index 6a2b7d3e85a7..84c84b5f0f3a 100644
--- a/drivers/cpufreq/pasemi-cpufreq.c
+++ b/drivers/cpufreq/pasemi-cpufreq.c
@@ -60,12 +60,12 @@ static int current_astate;
60 60
61/* We support 5(A0-A4) power states excluding turbo(A5-A6) modes */ 61/* We support 5(A0-A4) power states excluding turbo(A5-A6) modes */
62static struct cpufreq_frequency_table pas_freqs[] = { 62static struct cpufreq_frequency_table pas_freqs[] = {
63 {0, 0}, 63 {0, 0, 0},
64 {1, 0}, 64 {0, 1, 0},
65 {2, 0}, 65 {0, 2, 0},
66 {3, 0}, 66 {0, 3, 0},
67 {4, 0}, 67 {0, 4, 0},
68 {0, CPUFREQ_TABLE_END}, 68 {0, 0, CPUFREQ_TABLE_END},
69}; 69};
70 70
71/* 71/*
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index cf55d202f332..7615180d7ee3 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -81,9 +81,9 @@ static int is_pmu_based;
81#define CPUFREQ_LOW 1 81#define CPUFREQ_LOW 1
82 82
83static struct cpufreq_frequency_table pmac_cpu_freqs[] = { 83static struct cpufreq_frequency_table pmac_cpu_freqs[] = {
84 {CPUFREQ_HIGH, 0}, 84 {0, CPUFREQ_HIGH, 0},
85 {CPUFREQ_LOW, 0}, 85 {0, CPUFREQ_LOW, 0},
86 {0, CPUFREQ_TABLE_END}, 86 {0, 0, CPUFREQ_TABLE_END},
87}; 87};
88 88
89static inline void local_delay(unsigned long ms) 89static inline void local_delay(unsigned long ms)
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 6a338f8c3860..8bc422977b5b 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -65,9 +65,9 @@
65#define CPUFREQ_LOW 1 65#define CPUFREQ_LOW 1
66 66
67static struct cpufreq_frequency_table g5_cpu_freqs[] = { 67static struct cpufreq_frequency_table g5_cpu_freqs[] = {
68 {CPUFREQ_HIGH, 0}, 68 {0, CPUFREQ_HIGH, 0},
69 {CPUFREQ_LOW, 0}, 69 {0, CPUFREQ_LOW, 0},
70 {0, CPUFREQ_TABLE_END}, 70 {0, 0, CPUFREQ_TABLE_END},
71}; 71};
72 72
73/* Power mode data is an array of the 32 bits PCR values to use for 73/* Power mode data is an array of the 32 bits PCR values to use for
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index 62c6f2e5afce..49f120e1bc7b 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -37,15 +37,15 @@ MODULE_PARM_DESC(bus_frequency, "Bus frequency in kHz");
37 37
38/* Clock ratio multiplied by 10 - see table 27 in AMD#23446 */ 38/* Clock ratio multiplied by 10 - see table 27 in AMD#23446 */
39static struct cpufreq_frequency_table clock_ratio[] = { 39static struct cpufreq_frequency_table clock_ratio[] = {
40 {60, /* 110 -> 6.0x */ 0}, 40 {0, 60, /* 110 -> 6.0x */ 0},
41 {55, /* 011 -> 5.5x */ 0}, 41 {0, 55, /* 011 -> 5.5x */ 0},
42 {50, /* 001 -> 5.0x */ 0}, 42 {0, 50, /* 001 -> 5.0x */ 0},
43 {45, /* 000 -> 4.5x */ 0}, 43 {0, 45, /* 000 -> 4.5x */ 0},
44 {40, /* 010 -> 4.0x */ 0}, 44 {0, 40, /* 010 -> 4.0x */ 0},
45 {35, /* 111 -> 3.5x */ 0}, 45 {0, 35, /* 111 -> 3.5x */ 0},
46 {30, /* 101 -> 3.0x */ 0}, 46 {0, 30, /* 101 -> 3.0x */ 0},
47 {20, /* 100 -> 2.0x */ 0}, 47 {0, 20, /* 100 -> 2.0x */ 0},
48 {0, CPUFREQ_TABLE_END} 48 {0, 0, CPUFREQ_TABLE_END}
49}; 49};
50 50
51static const u8 index_to_register[8] = { 6, 3, 1, 0, 2, 7, 5, 4 }; 51static const u8 index_to_register[8] = { 6, 3, 1, 0, 2, 7, 5, 4 };
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 770a9e1b3468..1b6ae6b57c11 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -623,7 +623,7 @@ static int fill_powernow_table(struct powernow_k8_data *data,
623 if (check_pst_table(data, pst, maxvid)) 623 if (check_pst_table(data, pst, maxvid))
624 return -EINVAL; 624 return -EINVAL;
625 625
626 powernow_table = kmalloc((sizeof(*powernow_table) 626 powernow_table = kzalloc((sizeof(*powernow_table)
627 * (data->numps + 1)), GFP_KERNEL); 627 * (data->numps + 1)), GFP_KERNEL);
628 if (!powernow_table) { 628 if (!powernow_table) {
629 printk(KERN_ERR PFX "powernow_table memory alloc failure\n"); 629 printk(KERN_ERR PFX "powernow_table memory alloc failure\n");
@@ -793,7 +793,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
793 } 793 }
794 794
795 /* fill in data->powernow_table */ 795 /* fill in data->powernow_table */
796 powernow_table = kmalloc((sizeof(*powernow_table) 796 powernow_table = kzalloc((sizeof(*powernow_table)
797 * (data->acpi_data.state_count + 1)), GFP_KERNEL); 797 * (data->acpi_data.state_count + 1)), GFP_KERNEL);
798 if (!powernow_table) { 798 if (!powernow_table) {
799 pr_debug("powernow_table memory alloc failure\n"); 799 pr_debug("powernow_table memory alloc failure\n");
@@ -810,7 +810,6 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
810 810
811 powernow_table[data->acpi_data.state_count].frequency = 811 powernow_table[data->acpi_data.state_count].frequency =
812 CPUFREQ_TABLE_END; 812 CPUFREQ_TABLE_END;
813 powernow_table[data->acpi_data.state_count].driver_data = 0;
814 data->powernow_table = powernow_table; 813 data->powernow_table = powernow_table;
815 814
816 if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) 815 if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
new file mode 100644
index 000000000000..9edccc63245d
--- /dev/null
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -0,0 +1,341 @@
1/*
2 * POWERNV cpufreq driver for the IBM POWER processors
3 *
4 * (C) Copyright IBM 2014
5 *
6 * Author: Vaidyanathan Srinivasan <svaidy at linux.vnet.ibm.com>
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 */
19
20#define pr_fmt(fmt) "powernv-cpufreq: " fmt
21
22#include <linux/kernel.h>
23#include <linux/sysfs.h>
24#include <linux/cpumask.h>
25#include <linux/module.h>
26#include <linux/cpufreq.h>
27#include <linux/smp.h>
28#include <linux/of.h>
29
30#include <asm/cputhreads.h>
31#include <asm/reg.h>
32
33#define POWERNV_MAX_PSTATES 256
34
35static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
36
37/*
38 * Note: The set of pstates consists of contiguous integers, the
39 * smallest of which is indicated by powernv_pstate_info.min, the
40 * largest of which is indicated by powernv_pstate_info.max.
41 *
42 * The nominal pstate is the highest non-turbo pstate in this
43 * platform. This is indicated by powernv_pstate_info.nominal.
44 */
45static struct powernv_pstate_info {
46 int min;
47 int max;
48 int nominal;
49 int nr_pstates;
50} powernv_pstate_info;
51
52/*
53 * Initialize the freq table based on data obtained
54 * from the firmware passed via device-tree
55 */
56static int init_powernv_pstates(void)
57{
58 struct device_node *power_mgt;
59 int i, pstate_min, pstate_max, pstate_nominal, nr_pstates = 0;
60 const __be32 *pstate_ids, *pstate_freqs;
61 u32 len_ids, len_freqs;
62
63 power_mgt = of_find_node_by_path("/ibm,opal/power-mgt");
64 if (!power_mgt) {
65 pr_warn("power-mgt node not found\n");
66 return -ENODEV;
67 }
68
69 if (of_property_read_u32(power_mgt, "ibm,pstate-min", &pstate_min)) {
70 pr_warn("ibm,pstate-min node not found\n");
71 return -ENODEV;
72 }
73
74 if (of_property_read_u32(power_mgt, "ibm,pstate-max", &pstate_max)) {
75 pr_warn("ibm,pstate-max node not found\n");
76 return -ENODEV;
77 }
78
79 if (of_property_read_u32(power_mgt, "ibm,pstate-nominal",
80 &pstate_nominal)) {
81 pr_warn("ibm,pstate-nominal not found\n");
82 return -ENODEV;
83 }
84 pr_info("cpufreq pstate min %d nominal %d max %d\n", pstate_min,
85 pstate_nominal, pstate_max);
86
87 pstate_ids = of_get_property(power_mgt, "ibm,pstate-ids", &len_ids);
88 if (!pstate_ids) {
89 pr_warn("ibm,pstate-ids not found\n");
90 return -ENODEV;
91 }
92
93 pstate_freqs = of_get_property(power_mgt, "ibm,pstate-frequencies-mhz",
94 &len_freqs);
95 if (!pstate_freqs) {
96 pr_warn("ibm,pstate-frequencies-mhz not found\n");
97 return -ENODEV;
98 }
99
100 WARN_ON(len_ids != len_freqs);
101 nr_pstates = min(len_ids, len_freqs) / sizeof(u32);
102 if (!nr_pstates) {
103 pr_warn("No PStates found\n");
104 return -ENODEV;
105 }
106
107 pr_debug("NR PStates %d\n", nr_pstates);
108 for (i = 0; i < nr_pstates; i++) {
109 u32 id = be32_to_cpu(pstate_ids[i]);
110 u32 freq = be32_to_cpu(pstate_freqs[i]);
111
112 pr_debug("PState id %d freq %d MHz\n", id, freq);
113 powernv_freqs[i].frequency = freq * 1000; /* kHz */
114 powernv_freqs[i].driver_data = id;
115 }
116 /* End of list marker entry */
117 powernv_freqs[i].frequency = CPUFREQ_TABLE_END;
118
119 powernv_pstate_info.min = pstate_min;
120 powernv_pstate_info.max = pstate_max;
121 powernv_pstate_info.nominal = pstate_nominal;
122 powernv_pstate_info.nr_pstates = nr_pstates;
123
124 return 0;
125}
126
127/* Returns the CPU frequency corresponding to the pstate_id. */
128static unsigned int pstate_id_to_freq(int pstate_id)
129{
130 int i;
131
132 i = powernv_pstate_info.max - pstate_id;
133 BUG_ON(i >= powernv_pstate_info.nr_pstates || i < 0);
134
135 return powernv_freqs[i].frequency;
136}
137
138/*
139 * cpuinfo_nominal_freq_show - Show the nominal CPU frequency as indicated by
140 * the firmware
141 */
142static ssize_t cpuinfo_nominal_freq_show(struct cpufreq_policy *policy,
143 char *buf)
144{
145 return sprintf(buf, "%u\n",
146 pstate_id_to_freq(powernv_pstate_info.nominal));
147}
148
149struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq =
150 __ATTR_RO(cpuinfo_nominal_freq);
151
152static struct freq_attr *powernv_cpu_freq_attr[] = {
153 &cpufreq_freq_attr_scaling_available_freqs,
154 &cpufreq_freq_attr_cpuinfo_nominal_freq,
155 NULL,
156};
157
158/* Helper routines */
159
160/* Access helpers to power mgt SPR */
161
162static inline unsigned long get_pmspr(unsigned long sprn)
163{
164 switch (sprn) {
165 case SPRN_PMCR:
166 return mfspr(SPRN_PMCR);
167
168 case SPRN_PMICR:
169 return mfspr(SPRN_PMICR);
170
171 case SPRN_PMSR:
172 return mfspr(SPRN_PMSR);
173 }
174 BUG();
175}
176
177static inline void set_pmspr(unsigned long sprn, unsigned long val)
178{
179 switch (sprn) {
180 case SPRN_PMCR:
181 mtspr(SPRN_PMCR, val);
182 return;
183
184 case SPRN_PMICR:
185 mtspr(SPRN_PMICR, val);
186 return;
187 }
188 BUG();
189}
190
191/*
192 * Use objects of this type to query/update
193 * pstates on a remote CPU via smp_call_function.
194 */
195struct powernv_smp_call_data {
196 unsigned int freq;
197 int pstate_id;
198};
199
200/*
201 * powernv_read_cpu_freq: Reads the current frequency on this CPU.
202 *
203 * Called via smp_call_function.
204 *
205 * Note: The caller of the smp_call_function should pass an argument of
206 * the type 'struct powernv_smp_call_data *' along with this function.
207 *
208 * The current frequency on this CPU will be returned via
209 * ((struct powernv_smp_call_data *)arg)->freq;
210 */
211static void powernv_read_cpu_freq(void *arg)
212{
213 unsigned long pmspr_val;
214 s8 local_pstate_id;
215 struct powernv_smp_call_data *freq_data = arg;
216
217 pmspr_val = get_pmspr(SPRN_PMSR);
218
219 /*
220 * The local pstate id corresponds bits 48..55 in the PMSR.
221 * Note: Watch out for the sign!
222 */
223 local_pstate_id = (pmspr_val >> 48) & 0xFF;
224 freq_data->pstate_id = local_pstate_id;
225 freq_data->freq = pstate_id_to_freq(freq_data->pstate_id);
226
227 pr_debug("cpu %d pmsr %016lX pstate_id %d frequency %d kHz\n",
228 raw_smp_processor_id(), pmspr_val, freq_data->pstate_id,
229 freq_data->freq);
230}
231
232/*
233 * powernv_cpufreq_get: Returns the CPU frequency as reported by the
234 * firmware for CPU 'cpu'. This value is reported through the sysfs
235 * file cpuinfo_cur_freq.
236 */
237unsigned int powernv_cpufreq_get(unsigned int cpu)
238{
239 struct powernv_smp_call_data freq_data;
240
241 smp_call_function_any(cpu_sibling_mask(cpu), powernv_read_cpu_freq,
242 &freq_data, 1);
243
244 return freq_data.freq;
245}
246
247/*
248 * set_pstate: Sets the pstate on this CPU.
249 *
250 * This is called via an smp_call_function.
251 *
252 * The caller must ensure that freq_data is of the type
253 * (struct powernv_smp_call_data *) and the pstate_id which needs to be set
254 * on this CPU should be present in freq_data->pstate_id.
255 */
256static void set_pstate(void *freq_data)
257{
258 unsigned long val;
259 unsigned long pstate_ul =
260 ((struct powernv_smp_call_data *) freq_data)->pstate_id;
261
262 val = get_pmspr(SPRN_PMCR);
263 val = val & 0x0000FFFFFFFFFFFFULL;
264
265 pstate_ul = pstate_ul & 0xFF;
266
267 /* Set both global(bits 56..63) and local(bits 48..55) PStates */
268 val = val | (pstate_ul << 56) | (pstate_ul << 48);
269
270 pr_debug("Setting cpu %d pmcr to %016lX\n",
271 raw_smp_processor_id(), val);
272 set_pmspr(SPRN_PMCR, val);
273}
274
275/*
276 * powernv_cpufreq_target_index: Sets the frequency corresponding to
277 * the cpufreq table entry indexed by new_index on the cpus in the
278 * mask policy->cpus
279 */
280static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
281 unsigned int new_index)
282{
283 struct powernv_smp_call_data freq_data;
284
285 freq_data.pstate_id = powernv_freqs[new_index].driver_data;
286
287 /*
288 * Use smp_call_function to send IPI and execute the
289 * mtspr on target CPU. We could do that without IPI
290 * if current CPU is within policy->cpus (core)
291 */
292 smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1);
293
294 return 0;
295}
296
297static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
298{
299 int base, i;
300
301 base = cpu_first_thread_sibling(policy->cpu);
302
303 for (i = 0; i < threads_per_core; i++)
304 cpumask_set_cpu(base + i, policy->cpus);
305
306 return cpufreq_table_validate_and_show(policy, powernv_freqs);
307}
308
309static struct cpufreq_driver powernv_cpufreq_driver = {
310 .name = "powernv-cpufreq",
311 .flags = CPUFREQ_CONST_LOOPS,
312 .init = powernv_cpufreq_cpu_init,
313 .verify = cpufreq_generic_frequency_table_verify,
314 .target_index = powernv_cpufreq_target_index,
315 .get = powernv_cpufreq_get,
316 .attr = powernv_cpu_freq_attr,
317};
318
319static int __init powernv_cpufreq_init(void)
320{
321 int rc = 0;
322
323 /* Discover pstates from device tree and init */
324 rc = init_powernv_pstates();
325 if (rc) {
326 pr_info("powernv-cpufreq disabled. System does not support PState control\n");
327 return rc;
328 }
329
330 return cpufreq_register_driver(&powernv_cpufreq_driver);
331}
332module_init(powernv_cpufreq_init);
333
334static void __exit powernv_cpufreq_exit(void)
335{
336 cpufreq_unregister_driver(&powernv_cpufreq_driver);
337}
338module_exit(powernv_cpufreq_exit);
339
340MODULE_LICENSE("GPL");
341MODULE_AUTHOR("Vaidyanathan Srinivasan <svaidy at linux.vnet.ibm.com>");
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 3bd9123e7026..b7e677be1df0 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -13,7 +13,6 @@
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/cpufreq.h> 14#include <linux/cpufreq.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <sysdev/fsl_soc.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c
index af7b1cabd1e7..5be8a48dba74 100644
--- a/drivers/cpufreq/ppc_cbe_cpufreq.c
+++ b/drivers/cpufreq/ppc_cbe_cpufreq.c
@@ -32,15 +32,15 @@
32 32
33/* the CBE supports an 8 step frequency scaling */ 33/* the CBE supports an 8 step frequency scaling */
34static struct cpufreq_frequency_table cbe_freqs[] = { 34static struct cpufreq_frequency_table cbe_freqs[] = {
35 {1, 0}, 35 {0, 1, 0},
36 {2, 0}, 36 {0, 2, 0},
37 {3, 0}, 37 {0, 3, 0},
38 {4, 0}, 38 {0, 4, 0},
39 {5, 0}, 39 {0, 5, 0},
40 {6, 0}, 40 {0, 6, 0},
41 {8, 0}, 41 {0, 8, 0},
42 {10, 0}, 42 {0, 10, 0},
43 {0, CPUFREQ_TABLE_END}, 43 {0, 0, CPUFREQ_TABLE_END},
44}; 44};
45 45
46/* 46/*
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 826b8be23099..4626f90559b5 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -72,19 +72,19 @@ static struct s3c2416_dvfs s3c2416_dvfs_table[] = {
72#endif 72#endif
73 73
74static struct cpufreq_frequency_table s3c2416_freq_table[] = { 74static struct cpufreq_frequency_table s3c2416_freq_table[] = {
75 { SOURCE_HCLK, FREQ_DVS }, 75 { 0, SOURCE_HCLK, FREQ_DVS },
76 { SOURCE_ARMDIV, 133333 }, 76 { 0, SOURCE_ARMDIV, 133333 },
77 { SOURCE_ARMDIV, 266666 }, 77 { 0, SOURCE_ARMDIV, 266666 },
78 { SOURCE_ARMDIV, 400000 }, 78 { 0, SOURCE_ARMDIV, 400000 },
79 { 0, CPUFREQ_TABLE_END }, 79 { 0, 0, CPUFREQ_TABLE_END },
80}; 80};
81 81
82static struct cpufreq_frequency_table s3c2450_freq_table[] = { 82static struct cpufreq_frequency_table s3c2450_freq_table[] = {
83 { SOURCE_HCLK, FREQ_DVS }, 83 { 0, SOURCE_HCLK, FREQ_DVS },
84 { SOURCE_ARMDIV, 133500 }, 84 { 0, SOURCE_ARMDIV, 133500 },
85 { SOURCE_ARMDIV, 267000 }, 85 { 0, SOURCE_ARMDIV, 267000 },
86 { SOURCE_ARMDIV, 534000 }, 86 { 0, SOURCE_ARMDIV, 534000 },
87 { 0, CPUFREQ_TABLE_END }, 87 { 0, 0, CPUFREQ_TABLE_END },
88}; 88};
89 89
90static unsigned int s3c2416_cpufreq_get_speed(unsigned int cpu) 90static unsigned int s3c2416_cpufreq_get_speed(unsigned int cpu)
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
index a3dc192d21f9..be1b2b5c9753 100644
--- a/drivers/cpufreq/s3c24xx-cpufreq.c
+++ b/drivers/cpufreq/s3c24xx-cpufreq.c
@@ -586,7 +586,7 @@ static int s3c_cpufreq_build_freq(void)
586 size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); 586 size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0);
587 size++; 587 size++;
588 588
589 ftab = kmalloc(sizeof(*ftab) * size, GFP_KERNEL); 589 ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL);
590 if (!ftab) { 590 if (!ftab) {
591 printk(KERN_ERR "%s: no memory for tables\n", __func__); 591 printk(KERN_ERR "%s: no memory for tables\n", __func__);
592 return -ENOMEM; 592 return -ENOMEM;
@@ -664,7 +664,7 @@ int __init s3c_plltab_register(struct cpufreq_frequency_table *plls,
664 664
665 size = sizeof(*vals) * (plls_no + 1); 665 size = sizeof(*vals) * (plls_no + 1);
666 666
667 vals = kmalloc(size, GFP_KERNEL); 667 vals = kzalloc(size, GFP_KERNEL);
668 if (vals) { 668 if (vals) {
669 memcpy(vals, plls, size); 669 memcpy(vals, plls, size);
670 pll_reg = vals; 670 pll_reg = vals;
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c
index c4226de079ab..ff7d3ecb85f0 100644
--- a/drivers/cpufreq/s3c64xx-cpufreq.c
+++ b/drivers/cpufreq/s3c64xx-cpufreq.c
@@ -37,19 +37,19 @@ static struct s3c64xx_dvfs s3c64xx_dvfs_table[] = {
37}; 37};
38 38
39static struct cpufreq_frequency_table s3c64xx_freq_table[] = { 39static struct cpufreq_frequency_table s3c64xx_freq_table[] = {
40 { 0, 66000 }, 40 { 0, 0, 66000 },
41 { 0, 100000 }, 41 { 0, 0, 100000 },
42 { 0, 133000 }, 42 { 0, 0, 133000 },
43 { 1, 200000 }, 43 { 0, 1, 200000 },
44 { 1, 222000 }, 44 { 0, 1, 222000 },
45 { 1, 266000 }, 45 { 0, 1, 266000 },
46 { 2, 333000 }, 46 { 0, 2, 333000 },
47 { 2, 400000 }, 47 { 0, 2, 400000 },
48 { 2, 532000 }, 48 { 0, 2, 532000 },
49 { 2, 533000 }, 49 { 0, 2, 533000 },
50 { 3, 667000 }, 50 { 0, 3, 667000 },
51 { 4, 800000 }, 51 { 0, 4, 800000 },
52 { 0, CPUFREQ_TABLE_END }, 52 { 0, 0, CPUFREQ_TABLE_END },
53}; 53};
54#endif 54#endif
55 55
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 72421534fff5..ab2c1a40d437 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -64,12 +64,12 @@ enum s5pv210_dmc_port {
64}; 64};
65 65
66static struct cpufreq_frequency_table s5pv210_freq_table[] = { 66static struct cpufreq_frequency_table s5pv210_freq_table[] = {
67 {L0, 1000*1000}, 67 {0, L0, 1000*1000},
68 {L1, 800*1000}, 68 {0, L1, 800*1000},
69 {L2, 400*1000}, 69 {0, L2, 400*1000},
70 {L3, 200*1000}, 70 {0, L3, 200*1000},
71 {L4, 100*1000}, 71 {0, L4, 100*1000},
72 {0, CPUFREQ_TABLE_END}, 72 {0, 0, CPUFREQ_TABLE_END},
73}; 73};
74 74
75static struct regulator *arm_regulator; 75static struct regulator *arm_regulator;
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c
index 69371bf0886d..ac84e4818014 100644
--- a/drivers/cpufreq/sc520_freq.c
+++ b/drivers/cpufreq/sc520_freq.c
@@ -33,9 +33,9 @@ static __u8 __iomem *cpuctl;
33#define PFX "sc520_freq: " 33#define PFX "sc520_freq: "
34 34
35static struct cpufreq_frequency_table sc520_freq_table[] = { 35static struct cpufreq_frequency_table sc520_freq_table[] = {
36 {0x01, 100000}, 36 {0, 0x01, 100000},
37 {0x02, 133000}, 37 {0, 0x02, 133000},
38 {0, CPUFREQ_TABLE_END}, 38 {0, 0, CPUFREQ_TABLE_END},
39}; 39};
40 40
41static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu) 41static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu)
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 4cfdcff8a310..38678396636d 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -195,18 +195,15 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
195 cnt = prop->length / sizeof(u32); 195 cnt = prop->length / sizeof(u32);
196 val = prop->value; 196 val = prop->value;
197 197
198 freq_tbl = kmalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL); 198 freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
199 if (!freq_tbl) { 199 if (!freq_tbl) {
200 ret = -ENOMEM; 200 ret = -ENOMEM;
201 goto out_put_node; 201 goto out_put_node;
202 } 202 }
203 203
204 for (i = 0; i < cnt; i++) { 204 for (i = 0; i < cnt; i++)
205 freq_tbl[i].driver_data = i;
206 freq_tbl[i].frequency = be32_to_cpup(val++); 205 freq_tbl[i].frequency = be32_to_cpup(val++);
207 }
208 206
209 freq_tbl[i].driver_data = i;
210 freq_tbl[i].frequency = CPUFREQ_TABLE_END; 207 freq_tbl[i].frequency = CPUFREQ_TABLE_END;
211 208
212 spear_cpufreq.freq_tbl = freq_tbl; 209 spear_cpufreq.freq_tbl = freq_tbl;
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c
index 394ac159312a..1a07b5904ed5 100644
--- a/drivers/cpufreq/speedstep-ich.c
+++ b/drivers/cpufreq/speedstep-ich.c
@@ -49,9 +49,9 @@ static u32 pmbase;
49 * are in kHz for the time being. 49 * are in kHz for the time being.
50 */ 50 */
51static struct cpufreq_frequency_table speedstep_freqs[] = { 51static struct cpufreq_frequency_table speedstep_freqs[] = {
52 {SPEEDSTEP_HIGH, 0}, 52 {0, SPEEDSTEP_HIGH, 0},
53 {SPEEDSTEP_LOW, 0}, 53 {0, SPEEDSTEP_LOW, 0},
54 {0, CPUFREQ_TABLE_END}, 54 {0, 0, CPUFREQ_TABLE_END},
55}; 55};
56 56
57 57
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c
index db5d274dc13a..8635eec96da5 100644
--- a/drivers/cpufreq/speedstep-smi.c
+++ b/drivers/cpufreq/speedstep-smi.c
@@ -42,9 +42,9 @@ static enum speedstep_processor speedstep_processor;
42 * are in kHz for the time being. 42 * are in kHz for the time being.
43 */ 43 */
44static struct cpufreq_frequency_table speedstep_freqs[] = { 44static struct cpufreq_frequency_table speedstep_freqs[] = {
45 {SPEEDSTEP_HIGH, 0}, 45 {0, SPEEDSTEP_HIGH, 0},
46 {SPEEDSTEP_LOW, 0}, 46 {0, SPEEDSTEP_LOW, 0},
47 {0, CPUFREQ_TABLE_END}, 47 {0, 0, CPUFREQ_TABLE_END},
48}; 48};
49 49
50#define GET_SPEEDSTEP_OWNER 0 50#define GET_SPEEDSTEP_OWNER 0
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 13be802b6170..8d045afa7fb4 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -45,7 +45,7 @@ static int ucv2_target(struct cpufreq_policy *policy,
45 freqs.new = target_freq; 45 freqs.new = target_freq;
46 46
47 cpufreq_freq_transition_begin(policy, &freqs); 47 cpufreq_freq_transition_begin(policy, &freqs);
48 ret = clk_set_rate(policy->mclk, target_freq * 1000); 48 ret = clk_set_rate(policy->clk, target_freq * 1000);
49 cpufreq_freq_transition_end(policy, &freqs, ret); 49 cpufreq_freq_transition_end(policy, &freqs, ret);
50 50
51 return ret; 51 return ret;
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index e918b6d0caf7..efe2f175168f 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -293,6 +293,7 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, \
293} 293}
294 294
295define_show_state_function(exit_latency) 295define_show_state_function(exit_latency)
296define_show_state_function(target_residency)
296define_show_state_function(power_usage) 297define_show_state_function(power_usage)
297define_show_state_ull_function(usage) 298define_show_state_ull_function(usage)
298define_show_state_ull_function(time) 299define_show_state_ull_function(time)
@@ -304,6 +305,7 @@ define_store_state_ull_function(disable)
304define_one_state_ro(name, show_state_name); 305define_one_state_ro(name, show_state_name);
305define_one_state_ro(desc, show_state_desc); 306define_one_state_ro(desc, show_state_desc);
306define_one_state_ro(latency, show_state_exit_latency); 307define_one_state_ro(latency, show_state_exit_latency);
308define_one_state_ro(residency, show_state_target_residency);
307define_one_state_ro(power, show_state_power_usage); 309define_one_state_ro(power, show_state_power_usage);
308define_one_state_ro(usage, show_state_usage); 310define_one_state_ro(usage, show_state_usage);
309define_one_state_ro(time, show_state_time); 311define_one_state_ro(time, show_state_time);
@@ -313,6 +315,7 @@ static struct attribute *cpuidle_state_default_attrs[] = {
313 &attr_name.attr, 315 &attr_name.attr,
314 &attr_desc.attr, 316 &attr_desc.attr,
315 &attr_latency.attr, 317 &attr_latency.attr,
318 &attr_residency.attr,
316 &attr_power.attr, 319 &attr_power.attr,
317 &attr_usage.attr, 320 &attr_usage.attr,
318 &attr_time.attr, 321 &attr_time.attr,
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 605b016bcea4..ba06d1d2f99e 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -308,7 +308,7 @@ config DMA_OMAP
308 308
309config DMA_BCM2835 309config DMA_BCM2835
310 tristate "BCM2835 DMA engine support" 310 tristate "BCM2835 DMA engine support"
311 depends on (ARCH_BCM2835 || MACH_BCM2708) 311 depends on ARCH_BCM2835
312 select DMA_ENGINE 312 select DMA_ENGINE
313 select DMA_VIRTUAL_CHANNELS 313 select DMA_VIRTUAL_CHANNELS
314 314
@@ -350,6 +350,16 @@ config MOXART_DMA
350 select DMA_VIRTUAL_CHANNELS 350 select DMA_VIRTUAL_CHANNELS
351 help 351 help
352 Enable support for the MOXA ART SoC DMA controller. 352 Enable support for the MOXA ART SoC DMA controller.
353
354config FSL_EDMA
355 tristate "Freescale eDMA engine support"
356 depends on OF
357 select DMA_ENGINE
358 select DMA_VIRTUAL_CHANNELS
359 help
360 Support the Freescale eDMA engine with programmable channel
361 multiplexing capability for DMA request sources(slot).
362 This module can be found on Freescale Vybrid and LS-1 SoCs.
353 363
354config DMA_ENGINE 364config DMA_ENGINE
355 bool 365 bool
@@ -401,4 +411,13 @@ config DMATEST
401config DMA_ENGINE_RAID 411config DMA_ENGINE_RAID
402 bool 412 bool
403 413
414config QCOM_BAM_DMA
415 tristate "QCOM BAM DMA support"
416 depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
417 select DMA_ENGINE
418 select DMA_VIRTUAL_CHANNELS
419 ---help---
420 Enable support for the QCOM BAM DMA controller. This controller
421 provides DMA capabilities for a variety of on-chip devices.
422
404endif 423endif
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index a029d0f4a1be..5150c82c9caf 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -44,3 +44,5 @@ obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o
44obj-$(CONFIG_TI_CPPI41) += cppi41.o 44obj-$(CONFIG_TI_CPPI41) += cppi41.o
45obj-$(CONFIG_K3_DMA) += k3dma.o 45obj-$(CONFIG_K3_DMA) += k3dma.o
46obj-$(CONFIG_MOXART_DMA) += moxart-dma.o 46obj-$(CONFIG_MOXART_DMA) += moxart-dma.o
47obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
48obj-$(CONFIG_QCOM_BAM_DMA) += qcom_bam_dma.o
diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
index 1e506afa33f5..de361a156b34 100644
--- a/drivers/dma/acpi-dma.c
+++ b/drivers/dma/acpi-dma.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/err.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/list.h> 18#include <linux/list.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
@@ -265,7 +266,7 @@ EXPORT_SYMBOL_GPL(devm_acpi_dma_controller_register);
265 */ 266 */
266void devm_acpi_dma_controller_free(struct device *dev) 267void devm_acpi_dma_controller_free(struct device *dev)
267{ 268{
268 WARN_ON(devres_destroy(dev, devm_acpi_dma_release, NULL, NULL)); 269 WARN_ON(devres_release(dev, devm_acpi_dma_release, NULL, NULL));
269} 270}
270EXPORT_SYMBOL_GPL(devm_acpi_dma_controller_free); 271EXPORT_SYMBOL_GPL(devm_acpi_dma_controller_free);
271 272
@@ -343,7 +344,7 @@ static int acpi_dma_parse_fixed_dma(struct acpi_resource *res, void *data)
343 * @index: index of FixedDMA descriptor for @dev 344 * @index: index of FixedDMA descriptor for @dev
344 * 345 *
345 * Return: 346 * Return:
346 * Pointer to appropriate dma channel on success or NULL on error. 347 * Pointer to appropriate dma channel on success or an error pointer.
347 */ 348 */
348struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev, 349struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
349 size_t index) 350 size_t index)
@@ -358,10 +359,10 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
358 359
359 /* Check if the device was enumerated by ACPI */ 360 /* Check if the device was enumerated by ACPI */
360 if (!dev || !ACPI_HANDLE(dev)) 361 if (!dev || !ACPI_HANDLE(dev))
361 return NULL; 362 return ERR_PTR(-ENODEV);
362 363
363 if (acpi_bus_get_device(ACPI_HANDLE(dev), &adev)) 364 if (acpi_bus_get_device(ACPI_HANDLE(dev), &adev))
364 return NULL; 365 return ERR_PTR(-ENODEV);
365 366
366 memset(&pdata, 0, sizeof(pdata)); 367 memset(&pdata, 0, sizeof(pdata));
367 pdata.index = index; 368 pdata.index = index;
@@ -376,7 +377,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
376 acpi_dev_free_resource_list(&resource_list); 377 acpi_dev_free_resource_list(&resource_list);
377 378
378 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0) 379 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
379 return NULL; 380 return ERR_PTR(-ENODEV);
380 381
381 mutex_lock(&acpi_dma_lock); 382 mutex_lock(&acpi_dma_lock);
382 383
@@ -399,7 +400,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
399 } 400 }
400 401
401 mutex_unlock(&acpi_dma_lock); 402 mutex_unlock(&acpi_dma_lock);
402 return chan; 403 return chan ? chan : ERR_PTR(-EPROBE_DEFER);
403} 404}
404EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index); 405EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
405 406
@@ -413,7 +414,7 @@ EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
413 * the first FixedDMA descriptor is TX and second is RX. 414 * the first FixedDMA descriptor is TX and second is RX.
414 * 415 *
415 * Return: 416 * Return:
416 * Pointer to appropriate dma channel on success or NULL on error. 417 * Pointer to appropriate dma channel on success or an error pointer.
417 */ 418 */
418struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev, 419struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
419 const char *name) 420 const char *name)
@@ -425,7 +426,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
425 else if (!strcmp(name, "rx")) 426 else if (!strcmp(name, "rx"))
426 index = 1; 427 index = 1;
427 else 428 else
428 return NULL; 429 return ERR_PTR(-ENODEV);
429 430
430 return acpi_dma_request_slave_chan_by_index(dev, index); 431 return acpi_dma_request_slave_chan_by_index(dev, index);
431} 432}
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index e2c04dc81e2a..c13a3bb0f594 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1569,7 +1569,6 @@ static int at_dma_remove(struct platform_device *pdev)
1569 1569
1570 /* Disable interrupts */ 1570 /* Disable interrupts */
1571 atc_disable_chan_irq(atdma, chan->chan_id); 1571 atc_disable_chan_irq(atdma, chan->chan_id);
1572 tasklet_disable(&atchan->tasklet);
1573 1572
1574 tasklet_kill(&atchan->tasklet); 1573 tasklet_kill(&atchan->tasklet);
1575 list_del(&chan->device_node); 1574 list_del(&chan->device_node);
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index c18aebf7d5aa..d028f36ae655 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -620,12 +620,15 @@ static int cppi41_stop_chan(struct dma_chan *chan)
620 u32 desc_phys; 620 u32 desc_phys;
621 int ret; 621 int ret;
622 622
623 desc_phys = lower_32_bits(c->desc_phys);
624 desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
625 if (!cdd->chan_busy[desc_num])
626 return 0;
627
623 ret = cppi41_tear_down_chan(c); 628 ret = cppi41_tear_down_chan(c);
624 if (ret) 629 if (ret)
625 return ret; 630 return ret;
626 631
627 desc_phys = lower_32_bits(c->desc_phys);
628 desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
629 WARN_ON(!cdd->chan_busy[desc_num]); 632 WARN_ON(!cdd->chan_busy[desc_num]);
630 cdd->chan_busy[desc_num] = NULL; 633 cdd->chan_busy[desc_num] = NULL;
631 634
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ed610b497518..a886713937fd 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -627,18 +627,13 @@ EXPORT_SYMBOL_GPL(__dma_request_channel);
627struct dma_chan *dma_request_slave_channel_reason(struct device *dev, 627struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
628 const char *name) 628 const char *name)
629{ 629{
630 struct dma_chan *chan;
631
632 /* If device-tree is present get slave info from here */ 630 /* If device-tree is present get slave info from here */
633 if (dev->of_node) 631 if (dev->of_node)
634 return of_dma_request_slave_channel(dev->of_node, name); 632 return of_dma_request_slave_channel(dev->of_node, name);
635 633
636 /* If device was enumerated by ACPI get slave info from here */ 634 /* If device was enumerated by ACPI get slave info from here */
637 if (ACPI_HANDLE(dev)) { 635 if (ACPI_HANDLE(dev))
638 chan = acpi_dma_request_slave_chan_by_name(dev, name); 636 return acpi_dma_request_slave_chan_by_name(dev, name);
639 if (chan)
640 return chan;
641 }
642 637
643 return ERR_PTR(-ENODEV); 638 return ERR_PTR(-ENODEV);
644} 639}
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 05b6dea770a4..e27cec25c59e 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -340,7 +340,7 @@ static unsigned int min_odd(unsigned int x, unsigned int y)
340static void result(const char *err, unsigned int n, unsigned int src_off, 340static void result(const char *err, unsigned int n, unsigned int src_off,
341 unsigned int dst_off, unsigned int len, unsigned long data) 341 unsigned int dst_off, unsigned int len, unsigned long data)
342{ 342{
343 pr_info("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)", 343 pr_info("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)\n",
344 current->comm, n, err, src_off, dst_off, len, data); 344 current->comm, n, err, src_off, dst_off, len, data);
345} 345}
346 346
@@ -348,7 +348,7 @@ static void dbg_result(const char *err, unsigned int n, unsigned int src_off,
348 unsigned int dst_off, unsigned int len, 348 unsigned int dst_off, unsigned int len,
349 unsigned long data) 349 unsigned long data)
350{ 350{
351 pr_debug("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)", 351 pr_debug("%s: result #%u: '%s' with src_off=0x%x dst_off=0x%x len=0x%x (%lu)\n",
352 current->comm, n, err, src_off, dst_off, len, data); 352 current->comm, n, err, src_off, dst_off, len, data);
353} 353}
354 354
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 13ac3f240e79..cfdbb92aae1d 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -33,8 +33,8 @@
33 * of which use ARM any more). See the "Databook" from Synopsys for 33 * of which use ARM any more). See the "Databook" from Synopsys for
34 * information beyond what licensees probably provide. 34 * information beyond what licensees probably provide.
35 * 35 *
36 * The driver has currently been tested only with the Atmel AT32AP7000, 36 * The driver has been tested with the Atmel AT32AP7000, which does not
37 * which does not support descriptor writeback. 37 * support descriptor writeback.
38 */ 38 */
39 39
40static inline bool is_request_line_unset(struct dw_dma_chan *dwc) 40static inline bool is_request_line_unset(struct dw_dma_chan *dwc)
@@ -1479,7 +1479,6 @@ static void dw_dma_off(struct dw_dma *dw)
1479int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata) 1479int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1480{ 1480{
1481 struct dw_dma *dw; 1481 struct dw_dma *dw;
1482 size_t size;
1483 bool autocfg; 1482 bool autocfg;
1484 unsigned int dw_params; 1483 unsigned int dw_params;
1485 unsigned int nr_channels; 1484 unsigned int nr_channels;
@@ -1487,6 +1486,13 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1487 int err; 1486 int err;
1488 int i; 1487 int i;
1489 1488
1489 dw = devm_kzalloc(chip->dev, sizeof(*dw), GFP_KERNEL);
1490 if (!dw)
1491 return -ENOMEM;
1492
1493 dw->regs = chip->regs;
1494 chip->dw = dw;
1495
1490 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS); 1496 dw_params = dma_read_byaddr(chip->regs, DW_PARAMS);
1491 autocfg = dw_params >> DW_PARAMS_EN & 0x1; 1497 autocfg = dw_params >> DW_PARAMS_EN & 0x1;
1492 1498
@@ -1509,9 +1515,9 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1509 else 1515 else
1510 nr_channels = pdata->nr_channels; 1516 nr_channels = pdata->nr_channels;
1511 1517
1512 size = sizeof(struct dw_dma) + nr_channels * sizeof(struct dw_dma_chan); 1518 dw->chan = devm_kcalloc(chip->dev, nr_channels, sizeof(*dw->chan),
1513 dw = devm_kzalloc(chip->dev, size, GFP_KERNEL); 1519 GFP_KERNEL);
1514 if (!dw) 1520 if (!dw->chan)
1515 return -ENOMEM; 1521 return -ENOMEM;
1516 1522
1517 dw->clk = devm_clk_get(chip->dev, "hclk"); 1523 dw->clk = devm_clk_get(chip->dev, "hclk");
@@ -1519,9 +1525,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
1519 return PTR_ERR(dw->clk); 1525 return PTR_ERR(dw->clk);
1520 clk_prepare_enable(dw->clk); 1526 clk_prepare_enable(dw->clk);
1521 1527
1522 dw->regs = chip->regs;
1523 chip->dw = dw;
1524
1525 /* Get hardware configuration parameters */ 1528 /* Get hardware configuration parameters */
1526 if (autocfg) { 1529 if (autocfg) {
1527 max_blk_size = dma_readl(dw, MAX_BLK_SIZE); 1530 max_blk_size = dma_readl(dw, MAX_BLK_SIZE);
diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
index e89fc24b8293..fec59f1a77bb 100644
--- a/drivers/dma/dw/pci.c
+++ b/drivers/dma/dw/pci.c
@@ -75,6 +75,36 @@ static void dw_pci_remove(struct pci_dev *pdev)
75 dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret); 75 dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
76} 76}
77 77
78#ifdef CONFIG_PM_SLEEP
79
80static int dw_pci_suspend_late(struct device *dev)
81{
82 struct pci_dev *pci = to_pci_dev(dev);
83 struct dw_dma_chip *chip = pci_get_drvdata(pci);
84
85 return dw_dma_suspend(chip);
86};
87
88static int dw_pci_resume_early(struct device *dev)
89{
90 struct pci_dev *pci = to_pci_dev(dev);
91 struct dw_dma_chip *chip = pci_get_drvdata(pci);
92
93 return dw_dma_resume(chip);
94};
95
96#else /* !CONFIG_PM_SLEEP */
97
98#define dw_pci_suspend_late NULL
99#define dw_pci_resume_early NULL
100
101#endif /* !CONFIG_PM_SLEEP */
102
103static const struct dev_pm_ops dw_pci_dev_pm_ops = {
104 .suspend_late = dw_pci_suspend_late,
105 .resume_early = dw_pci_resume_early,
106};
107
78static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = { 108static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
79 /* Medfield */ 109 /* Medfield */
80 { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata }, 110 { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
@@ -83,6 +113,9 @@ static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
83 /* BayTrail */ 113 /* BayTrail */
84 { PCI_VDEVICE(INTEL, 0x0f06), (kernel_ulong_t)&dw_pci_pdata }, 114 { PCI_VDEVICE(INTEL, 0x0f06), (kernel_ulong_t)&dw_pci_pdata },
85 { PCI_VDEVICE(INTEL, 0x0f40), (kernel_ulong_t)&dw_pci_pdata }, 115 { PCI_VDEVICE(INTEL, 0x0f40), (kernel_ulong_t)&dw_pci_pdata },
116
117 /* Haswell */
118 { PCI_VDEVICE(INTEL, 0x9c60), (kernel_ulong_t)&dw_pci_pdata },
86 { } 119 { }
87}; 120};
88MODULE_DEVICE_TABLE(pci, dw_pci_id_table); 121MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
@@ -92,6 +125,9 @@ static struct pci_driver dw_pci_driver = {
92 .id_table = dw_pci_id_table, 125 .id_table = dw_pci_id_table,
93 .probe = dw_pci_probe, 126 .probe = dw_pci_probe,
94 .remove = dw_pci_remove, 127 .remove = dw_pci_remove,
128 .driver = {
129 .pm = &dw_pci_dev_pm_ops,
130 },
95}; 131};
96 132
97module_pci_driver(dw_pci_driver); 133module_pci_driver(dw_pci_driver);
diff --git a/drivers/dma/dw/regs.h b/drivers/dma/dw/regs.h
index deb4274f80f4..bb98d3e91e8b 100644
--- a/drivers/dma/dw/regs.h
+++ b/drivers/dma/dw/regs.h
@@ -252,13 +252,13 @@ struct dw_dma {
252 struct tasklet_struct tasklet; 252 struct tasklet_struct tasklet;
253 struct clk *clk; 253 struct clk *clk;
254 254
255 /* channels */
256 struct dw_dma_chan *chan;
255 u8 all_chan_mask; 257 u8 all_chan_mask;
256 258
257 /* hardware configuration */ 259 /* hardware configuration */
258 unsigned char nr_masters; 260 unsigned char nr_masters;
259 unsigned char data_width[4]; 261 unsigned char data_width[4];
260
261 struct dw_dma_chan chan[0];
262}; 262};
263 263
264static inline struct dw_dma_regs __iomem *__dw_regs(struct dw_dma *dw) 264static inline struct dw_dma_regs __iomem *__dw_regs(struct dw_dma *dw)
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index cd8da451d199..cd04eb7b182e 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -539,6 +539,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
539 edma_alloc_slot(EDMA_CTLR(echan->ch_num), 539 edma_alloc_slot(EDMA_CTLR(echan->ch_num),
540 EDMA_SLOT_ANY); 540 EDMA_SLOT_ANY);
541 if (echan->slot[i] < 0) { 541 if (echan->slot[i] < 0) {
542 kfree(edesc);
542 dev_err(dev, "Failed to allocate slot\n"); 543 dev_err(dev, "Failed to allocate slot\n");
543 return NULL; 544 return NULL;
544 } 545 }
@@ -553,8 +554,10 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
553 ret = edma_config_pset(chan, &edesc->pset[i], src_addr, 554 ret = edma_config_pset(chan, &edesc->pset[i], src_addr,
554 dst_addr, burst, dev_width, period_len, 555 dst_addr, burst, dev_width, period_len,
555 direction); 556 direction);
556 if (ret < 0) 557 if (ret < 0) {
558 kfree(edesc);
557 return NULL; 559 return NULL;
560 }
558 561
559 if (direction == DMA_DEV_TO_MEM) 562 if (direction == DMA_DEV_TO_MEM)
560 dst_addr += period_len; 563 dst_addr += period_len;
diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
new file mode 100644
index 000000000000..381e793184ba
--- /dev/null
+++ b/drivers/dma/fsl-edma.c
@@ -0,0 +1,975 @@
1/*
2 * drivers/dma/fsl-edma.c
3 *
4 * Copyright 2013-2014 Freescale Semiconductor, Inc.
5 *
6 * Driver for the Freescale eDMA engine with flexible channel multiplexing
7 * capability for DMA request sources. The eDMA block can be found on some
8 * Vybrid and Layerscape SoCs.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/interrupt.h>
19#include <linux/clk.h>
20#include <linux/dma-mapping.h>
21#include <linux/dmapool.h>
22#include <linux/slab.h>
23#include <linux/spinlock.h>
24#include <linux/of.h>
25#include <linux/of_device.h>
26#include <linux/of_address.h>
27#include <linux/of_irq.h>
28#include <linux/of_dma.h>
29
30#include "virt-dma.h"
31
32#define EDMA_CR 0x00
33#define EDMA_ES 0x04
34#define EDMA_ERQ 0x0C
35#define EDMA_EEI 0x14
36#define EDMA_SERQ 0x1B
37#define EDMA_CERQ 0x1A
38#define EDMA_SEEI 0x19
39#define EDMA_CEEI 0x18
40#define EDMA_CINT 0x1F
41#define EDMA_CERR 0x1E
42#define EDMA_SSRT 0x1D
43#define EDMA_CDNE 0x1C
44#define EDMA_INTR 0x24
45#define EDMA_ERR 0x2C
46
47#define EDMA_TCD_SADDR(x) (0x1000 + 32 * (x))
48#define EDMA_TCD_SOFF(x) (0x1004 + 32 * (x))
49#define EDMA_TCD_ATTR(x) (0x1006 + 32 * (x))
50#define EDMA_TCD_NBYTES(x) (0x1008 + 32 * (x))
51#define EDMA_TCD_SLAST(x) (0x100C + 32 * (x))
52#define EDMA_TCD_DADDR(x) (0x1010 + 32 * (x))
53#define EDMA_TCD_DOFF(x) (0x1014 + 32 * (x))
54#define EDMA_TCD_CITER_ELINK(x) (0x1016 + 32 * (x))
55#define EDMA_TCD_CITER(x) (0x1016 + 32 * (x))
56#define EDMA_TCD_DLAST_SGA(x) (0x1018 + 32 * (x))
57#define EDMA_TCD_CSR(x) (0x101C + 32 * (x))
58#define EDMA_TCD_BITER_ELINK(x) (0x101E + 32 * (x))
59#define EDMA_TCD_BITER(x) (0x101E + 32 * (x))
60
61#define EDMA_CR_EDBG BIT(1)
62#define EDMA_CR_ERCA BIT(2)
63#define EDMA_CR_ERGA BIT(3)
64#define EDMA_CR_HOE BIT(4)
65#define EDMA_CR_HALT BIT(5)
66#define EDMA_CR_CLM BIT(6)
67#define EDMA_CR_EMLM BIT(7)
68#define EDMA_CR_ECX BIT(16)
69#define EDMA_CR_CX BIT(17)
70
71#define EDMA_SEEI_SEEI(x) ((x) & 0x1F)
72#define EDMA_CEEI_CEEI(x) ((x) & 0x1F)
73#define EDMA_CINT_CINT(x) ((x) & 0x1F)
74#define EDMA_CERR_CERR(x) ((x) & 0x1F)
75
76#define EDMA_TCD_ATTR_DSIZE(x) (((x) & 0x0007))
77#define EDMA_TCD_ATTR_DMOD(x) (((x) & 0x001F) << 3)
78#define EDMA_TCD_ATTR_SSIZE(x) (((x) & 0x0007) << 8)
79#define EDMA_TCD_ATTR_SMOD(x) (((x) & 0x001F) << 11)
80#define EDMA_TCD_ATTR_SSIZE_8BIT (0x0000)
81#define EDMA_TCD_ATTR_SSIZE_16BIT (0x0100)
82#define EDMA_TCD_ATTR_SSIZE_32BIT (0x0200)
83#define EDMA_TCD_ATTR_SSIZE_64BIT (0x0300)
84#define EDMA_TCD_ATTR_SSIZE_32BYTE (0x0500)
85#define EDMA_TCD_ATTR_DSIZE_8BIT (0x0000)
86#define EDMA_TCD_ATTR_DSIZE_16BIT (0x0001)
87#define EDMA_TCD_ATTR_DSIZE_32BIT (0x0002)
88#define EDMA_TCD_ATTR_DSIZE_64BIT (0x0003)
89#define EDMA_TCD_ATTR_DSIZE_32BYTE (0x0005)
90
91#define EDMA_TCD_SOFF_SOFF(x) (x)
92#define EDMA_TCD_NBYTES_NBYTES(x) (x)
93#define EDMA_TCD_SLAST_SLAST(x) (x)
94#define EDMA_TCD_DADDR_DADDR(x) (x)
95#define EDMA_TCD_CITER_CITER(x) ((x) & 0x7FFF)
96#define EDMA_TCD_DOFF_DOFF(x) (x)
97#define EDMA_TCD_DLAST_SGA_DLAST_SGA(x) (x)
98#define EDMA_TCD_BITER_BITER(x) ((x) & 0x7FFF)
99
100#define EDMA_TCD_CSR_START BIT(0)
101#define EDMA_TCD_CSR_INT_MAJOR BIT(1)
102#define EDMA_TCD_CSR_INT_HALF BIT(2)
103#define EDMA_TCD_CSR_D_REQ BIT(3)
104#define EDMA_TCD_CSR_E_SG BIT(4)
105#define EDMA_TCD_CSR_E_LINK BIT(5)
106#define EDMA_TCD_CSR_ACTIVE BIT(6)
107#define EDMA_TCD_CSR_DONE BIT(7)
108
109#define EDMAMUX_CHCFG_DIS 0x0
110#define EDMAMUX_CHCFG_ENBL 0x80
111#define EDMAMUX_CHCFG_SOURCE(n) ((n) & 0x3F)
112
113#define DMAMUX_NR 2
114
115#define FSL_EDMA_BUSWIDTHS BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
116 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
117 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \
118 BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)
119
120struct fsl_edma_hw_tcd {
121 u32 saddr;
122 u16 soff;
123 u16 attr;
124 u32 nbytes;
125 u32 slast;
126 u32 daddr;
127 u16 doff;
128 u16 citer;
129 u32 dlast_sga;
130 u16 csr;
131 u16 biter;
132};
133
134struct fsl_edma_sw_tcd {
135 dma_addr_t ptcd;
136 struct fsl_edma_hw_tcd *vtcd;
137};
138
139struct fsl_edma_slave_config {
140 enum dma_transfer_direction dir;
141 enum dma_slave_buswidth addr_width;
142 u32 dev_addr;
143 u32 burst;
144 u32 attr;
145};
146
147struct fsl_edma_chan {
148 struct virt_dma_chan vchan;
149 enum dma_status status;
150 struct fsl_edma_engine *edma;
151 struct fsl_edma_desc *edesc;
152 struct fsl_edma_slave_config fsc;
153 struct dma_pool *tcd_pool;
154};
155
156struct fsl_edma_desc {
157 struct virt_dma_desc vdesc;
158 struct fsl_edma_chan *echan;
159 bool iscyclic;
160 unsigned int n_tcds;
161 struct fsl_edma_sw_tcd tcd[];
162};
163
164struct fsl_edma_engine {
165 struct dma_device dma_dev;
166 void __iomem *membase;
167 void __iomem *muxbase[DMAMUX_NR];
168 struct clk *muxclk[DMAMUX_NR];
169 struct mutex fsl_edma_mutex;
170 u32 n_chans;
171 int txirq;
172 int errirq;
173 bool big_endian;
174 struct fsl_edma_chan chans[];
175};
176
177/*
178 * R/W functions for big- or little-endian registers
179 * the eDMA controller's endian is independent of the CPU core's endian.
180 */
181
182static u16 edma_readw(struct fsl_edma_engine *edma, void __iomem *addr)
183{
184 if (edma->big_endian)
185 return ioread16be(addr);
186 else
187 return ioread16(addr);
188}
189
190static u32 edma_readl(struct fsl_edma_engine *edma, void __iomem *addr)
191{
192 if (edma->big_endian)
193 return ioread32be(addr);
194 else
195 return ioread32(addr);
196}
197
198static void edma_writeb(struct fsl_edma_engine *edma, u8 val, void __iomem *addr)
199{
200 iowrite8(val, addr);
201}
202
203static void edma_writew(struct fsl_edma_engine *edma, u16 val, void __iomem *addr)
204{
205 if (edma->big_endian)
206 iowrite16be(val, addr);
207 else
208 iowrite16(val, addr);
209}
210
211static void edma_writel(struct fsl_edma_engine *edma, u32 val, void __iomem *addr)
212{
213 if (edma->big_endian)
214 iowrite32be(val, addr);
215 else
216 iowrite32(val, addr);
217}
218
219static struct fsl_edma_chan *to_fsl_edma_chan(struct dma_chan *chan)
220{
221 return container_of(chan, struct fsl_edma_chan, vchan.chan);
222}
223
224static struct fsl_edma_desc *to_fsl_edma_desc(struct virt_dma_desc *vd)
225{
226 return container_of(vd, struct fsl_edma_desc, vdesc);
227}
228
229static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan)
230{
231 void __iomem *addr = fsl_chan->edma->membase;
232 u32 ch = fsl_chan->vchan.chan.chan_id;
233
234 edma_writeb(fsl_chan->edma, EDMA_SEEI_SEEI(ch), addr + EDMA_SEEI);
235 edma_writeb(fsl_chan->edma, ch, addr + EDMA_SERQ);
236}
237
238static void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan)
239{
240 void __iomem *addr = fsl_chan->edma->membase;
241 u32 ch = fsl_chan->vchan.chan.chan_id;
242
243 edma_writeb(fsl_chan->edma, ch, addr + EDMA_CERQ);
244 edma_writeb(fsl_chan->edma, EDMA_CEEI_CEEI(ch), addr + EDMA_CEEI);
245}
246
247static void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan,
248 unsigned int slot, bool enable)
249{
250 u32 ch = fsl_chan->vchan.chan.chan_id;
251 void __iomem *muxaddr = fsl_chan->edma->muxbase[ch / DMAMUX_NR];
252 unsigned chans_per_mux, ch_off;
253
254 chans_per_mux = fsl_chan->edma->n_chans / DMAMUX_NR;
255 ch_off = fsl_chan->vchan.chan.chan_id % chans_per_mux;
256
257 if (enable)
258 edma_writeb(fsl_chan->edma,
259 EDMAMUX_CHCFG_ENBL | EDMAMUX_CHCFG_SOURCE(slot),
260 muxaddr + ch_off);
261 else
262 edma_writeb(fsl_chan->edma, EDMAMUX_CHCFG_DIS, muxaddr + ch_off);
263}
264
265static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width)
266{
267 switch (addr_width) {
268 case 1:
269 return EDMA_TCD_ATTR_SSIZE_8BIT | EDMA_TCD_ATTR_DSIZE_8BIT;
270 case 2:
271 return EDMA_TCD_ATTR_SSIZE_16BIT | EDMA_TCD_ATTR_DSIZE_16BIT;
272 case 4:
273 return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT;
274 case 8:
275 return EDMA_TCD_ATTR_SSIZE_64BIT | EDMA_TCD_ATTR_DSIZE_64BIT;
276 default:
277 return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT;
278 }
279}
280
281static void fsl_edma_free_desc(struct virt_dma_desc *vdesc)
282{
283 struct fsl_edma_desc *fsl_desc;
284 int i;
285
286 fsl_desc = to_fsl_edma_desc(vdesc);
287 for (i = 0; i < fsl_desc->n_tcds; i++)
288 dma_pool_free(fsl_desc->echan->tcd_pool,
289 fsl_desc->tcd[i].vtcd,
290 fsl_desc->tcd[i].ptcd);
291 kfree(fsl_desc);
292}
293
294static int fsl_edma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
295 unsigned long arg)
296{
297 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
298 struct dma_slave_config *cfg = (void *)arg;
299 unsigned long flags;
300 LIST_HEAD(head);
301
302 switch (cmd) {
303 case DMA_TERMINATE_ALL:
304 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
305 fsl_edma_disable_request(fsl_chan);
306 fsl_chan->edesc = NULL;
307 vchan_get_all_descriptors(&fsl_chan->vchan, &head);
308 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
309 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
310 return 0;
311
312 case DMA_SLAVE_CONFIG:
313 fsl_chan->fsc.dir = cfg->direction;
314 if (cfg->direction == DMA_DEV_TO_MEM) {
315 fsl_chan->fsc.dev_addr = cfg->src_addr;
316 fsl_chan->fsc.addr_width = cfg->src_addr_width;
317 fsl_chan->fsc.burst = cfg->src_maxburst;
318 fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg->src_addr_width);
319 } else if (cfg->direction == DMA_MEM_TO_DEV) {
320 fsl_chan->fsc.dev_addr = cfg->dst_addr;
321 fsl_chan->fsc.addr_width = cfg->dst_addr_width;
322 fsl_chan->fsc.burst = cfg->dst_maxburst;
323 fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg->dst_addr_width);
324 } else {
325 return -EINVAL;
326 }
327 return 0;
328
329 case DMA_PAUSE:
330 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
331 if (fsl_chan->edesc) {
332 fsl_edma_disable_request(fsl_chan);
333 fsl_chan->status = DMA_PAUSED;
334 }
335 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
336 return 0;
337
338 case DMA_RESUME:
339 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
340 if (fsl_chan->edesc) {
341 fsl_edma_enable_request(fsl_chan);
342 fsl_chan->status = DMA_IN_PROGRESS;
343 }
344 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
345 return 0;
346
347 default:
348 return -ENXIO;
349 }
350}
351
352static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan,
353 struct virt_dma_desc *vdesc, bool in_progress)
354{
355 struct fsl_edma_desc *edesc = fsl_chan->edesc;
356 void __iomem *addr = fsl_chan->edma->membase;
357 u32 ch = fsl_chan->vchan.chan.chan_id;
358 enum dma_transfer_direction dir = fsl_chan->fsc.dir;
359 dma_addr_t cur_addr, dma_addr;
360 size_t len, size;
361 int i;
362
363 /* calculate the total size in this desc */
364 for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++)
365 len += edma_readl(fsl_chan->edma, &(edesc->tcd[i].vtcd->nbytes))
366 * edma_readw(fsl_chan->edma, &(edesc->tcd[i].vtcd->biter));
367
368 if (!in_progress)
369 return len;
370
371 if (dir == DMA_MEM_TO_DEV)
372 cur_addr = edma_readl(fsl_chan->edma, addr + EDMA_TCD_SADDR(ch));
373 else
374 cur_addr = edma_readl(fsl_chan->edma, addr + EDMA_TCD_DADDR(ch));
375
376 /* figure out the finished and calculate the residue */
377 for (i = 0; i < fsl_chan->edesc->n_tcds; i++) {
378 size = edma_readl(fsl_chan->edma, &(edesc->tcd[i].vtcd->nbytes))
379 * edma_readw(fsl_chan->edma, &(edesc->tcd[i].vtcd->biter));
380 if (dir == DMA_MEM_TO_DEV)
381 dma_addr = edma_readl(fsl_chan->edma,
382 &(edesc->tcd[i].vtcd->saddr));
383 else
384 dma_addr = edma_readl(fsl_chan->edma,
385 &(edesc->tcd[i].vtcd->daddr));
386
387 len -= size;
388 if (cur_addr > dma_addr && cur_addr < dma_addr + size) {
389 len += dma_addr + size - cur_addr;
390 break;
391 }
392 }
393
394 return len;
395}
396
397static enum dma_status fsl_edma_tx_status(struct dma_chan *chan,
398 dma_cookie_t cookie, struct dma_tx_state *txstate)
399{
400 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
401 struct virt_dma_desc *vdesc;
402 enum dma_status status;
403 unsigned long flags;
404
405 status = dma_cookie_status(chan, cookie, txstate);
406 if (status == DMA_COMPLETE)
407 return status;
408
409 if (!txstate)
410 return fsl_chan->status;
411
412 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
413 vdesc = vchan_find_desc(&fsl_chan->vchan, cookie);
414 if (fsl_chan->edesc && cookie == fsl_chan->edesc->vdesc.tx.cookie)
415 txstate->residue = fsl_edma_desc_residue(fsl_chan, vdesc, true);
416 else if (vdesc)
417 txstate->residue = fsl_edma_desc_residue(fsl_chan, vdesc, false);
418 else
419 txstate->residue = 0;
420
421 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
422
423 return fsl_chan->status;
424}
425
426static void fsl_edma_set_tcd_params(struct fsl_edma_chan *fsl_chan,
427 u32 src, u32 dst, u16 attr, u16 soff, u32 nbytes,
428 u32 slast, u16 citer, u16 biter, u32 doff, u32 dlast_sga,
429 u16 csr)
430{
431 void __iomem *addr = fsl_chan->edma->membase;
432 u32 ch = fsl_chan->vchan.chan.chan_id;
433
434 /*
435 * TCD parameters have been swapped in fill_tcd_params(),
436 * so just write them to registers in the cpu endian here
437 */
438 writew(0, addr + EDMA_TCD_CSR(ch));
439 writel(src, addr + EDMA_TCD_SADDR(ch));
440 writel(dst, addr + EDMA_TCD_DADDR(ch));
441 writew(attr, addr + EDMA_TCD_ATTR(ch));
442 writew(soff, addr + EDMA_TCD_SOFF(ch));
443 writel(nbytes, addr + EDMA_TCD_NBYTES(ch));
444 writel(slast, addr + EDMA_TCD_SLAST(ch));
445 writew(citer, addr + EDMA_TCD_CITER(ch));
446 writew(biter, addr + EDMA_TCD_BITER(ch));
447 writew(doff, addr + EDMA_TCD_DOFF(ch));
448 writel(dlast_sga, addr + EDMA_TCD_DLAST_SGA(ch));
449 writew(csr, addr + EDMA_TCD_CSR(ch));
450}
451
452static void fill_tcd_params(struct fsl_edma_engine *edma,
453 struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst,
454 u16 attr, u16 soff, u32 nbytes, u32 slast, u16 citer,
455 u16 biter, u16 doff, u32 dlast_sga, bool major_int,
456 bool disable_req, bool enable_sg)
457{
458 u16 csr = 0;
459
460 /*
461 * eDMA hardware SGs require the TCD parameters stored in memory
462 * the same endian as the eDMA module so that they can be loaded
463 * automatically by the engine
464 */
465 edma_writel(edma, src, &(tcd->saddr));
466 edma_writel(edma, dst, &(tcd->daddr));
467 edma_writew(edma, attr, &(tcd->attr));
468 edma_writew(edma, EDMA_TCD_SOFF_SOFF(soff), &(tcd->soff));
469 edma_writel(edma, EDMA_TCD_NBYTES_NBYTES(nbytes), &(tcd->nbytes));
470 edma_writel(edma, EDMA_TCD_SLAST_SLAST(slast), &(tcd->slast));
471 edma_writew(edma, EDMA_TCD_CITER_CITER(citer), &(tcd->citer));
472 edma_writew(edma, EDMA_TCD_DOFF_DOFF(doff), &(tcd->doff));
473 edma_writel(edma, EDMA_TCD_DLAST_SGA_DLAST_SGA(dlast_sga), &(tcd->dlast_sga));
474 edma_writew(edma, EDMA_TCD_BITER_BITER(biter), &(tcd->biter));
475 if (major_int)
476 csr |= EDMA_TCD_CSR_INT_MAJOR;
477
478 if (disable_req)
479 csr |= EDMA_TCD_CSR_D_REQ;
480
481 if (enable_sg)
482 csr |= EDMA_TCD_CSR_E_SG;
483
484 edma_writew(edma, csr, &(tcd->csr));
485}
486
487static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan,
488 int sg_len)
489{
490 struct fsl_edma_desc *fsl_desc;
491 int i;
492
493 fsl_desc = kzalloc(sizeof(*fsl_desc) + sizeof(struct fsl_edma_sw_tcd) * sg_len,
494 GFP_NOWAIT);
495 if (!fsl_desc)
496 return NULL;
497
498 fsl_desc->echan = fsl_chan;
499 fsl_desc->n_tcds = sg_len;
500 for (i = 0; i < sg_len; i++) {
501 fsl_desc->tcd[i].vtcd = dma_pool_alloc(fsl_chan->tcd_pool,
502 GFP_NOWAIT, &fsl_desc->tcd[i].ptcd);
503 if (!fsl_desc->tcd[i].vtcd)
504 goto err;
505 }
506 return fsl_desc;
507
508err:
509 while (--i >= 0)
510 dma_pool_free(fsl_chan->tcd_pool, fsl_desc->tcd[i].vtcd,
511 fsl_desc->tcd[i].ptcd);
512 kfree(fsl_desc);
513 return NULL;
514}
515
516static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic(
517 struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
518 size_t period_len, enum dma_transfer_direction direction,
519 unsigned long flags, void *context)
520{
521 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
522 struct fsl_edma_desc *fsl_desc;
523 dma_addr_t dma_buf_next;
524 int sg_len, i;
525 u32 src_addr, dst_addr, last_sg, nbytes;
526 u16 soff, doff, iter;
527
528 if (!is_slave_direction(fsl_chan->fsc.dir))
529 return NULL;
530
531 sg_len = buf_len / period_len;
532 fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
533 if (!fsl_desc)
534 return NULL;
535 fsl_desc->iscyclic = true;
536
537 dma_buf_next = dma_addr;
538 nbytes = fsl_chan->fsc.addr_width * fsl_chan->fsc.burst;
539 iter = period_len / nbytes;
540
541 for (i = 0; i < sg_len; i++) {
542 if (dma_buf_next >= dma_addr + buf_len)
543 dma_buf_next = dma_addr;
544
545 /* get next sg's physical address */
546 last_sg = fsl_desc->tcd[(i + 1) % sg_len].ptcd;
547
548 if (fsl_chan->fsc.dir == DMA_MEM_TO_DEV) {
549 src_addr = dma_buf_next;
550 dst_addr = fsl_chan->fsc.dev_addr;
551 soff = fsl_chan->fsc.addr_width;
552 doff = 0;
553 } else {
554 src_addr = fsl_chan->fsc.dev_addr;
555 dst_addr = dma_buf_next;
556 soff = 0;
557 doff = fsl_chan->fsc.addr_width;
558 }
559
560 fill_tcd_params(fsl_chan->edma, fsl_desc->tcd[i].vtcd, src_addr,
561 dst_addr, fsl_chan->fsc.attr, soff, nbytes, 0,
562 iter, iter, doff, last_sg, true, false, true);
563 dma_buf_next += period_len;
564 }
565
566 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags);
567}
568
569static struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg(
570 struct dma_chan *chan, struct scatterlist *sgl,
571 unsigned int sg_len, enum dma_transfer_direction direction,
572 unsigned long flags, void *context)
573{
574 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
575 struct fsl_edma_desc *fsl_desc;
576 struct scatterlist *sg;
577 u32 src_addr, dst_addr, last_sg, nbytes;
578 u16 soff, doff, iter;
579 int i;
580
581 if (!is_slave_direction(fsl_chan->fsc.dir))
582 return NULL;
583
584 fsl_desc = fsl_edma_alloc_desc(fsl_chan, sg_len);
585 if (!fsl_desc)
586 return NULL;
587 fsl_desc->iscyclic = false;
588
589 nbytes = fsl_chan->fsc.addr_width * fsl_chan->fsc.burst;
590 for_each_sg(sgl, sg, sg_len, i) {
591 /* get next sg's physical address */
592 last_sg = fsl_desc->tcd[(i + 1) % sg_len].ptcd;
593
594 if (fsl_chan->fsc.dir == DMA_MEM_TO_DEV) {
595 src_addr = sg_dma_address(sg);
596 dst_addr = fsl_chan->fsc.dev_addr;
597 soff = fsl_chan->fsc.addr_width;
598 doff = 0;
599 } else {
600 src_addr = fsl_chan->fsc.dev_addr;
601 dst_addr = sg_dma_address(sg);
602 soff = 0;
603 doff = fsl_chan->fsc.addr_width;
604 }
605
606 iter = sg_dma_len(sg) / nbytes;
607 if (i < sg_len - 1) {
608 last_sg = fsl_desc->tcd[(i + 1)].ptcd;
609 fill_tcd_params(fsl_chan->edma, fsl_desc->tcd[i].vtcd,
610 src_addr, dst_addr, fsl_chan->fsc.attr,
611 soff, nbytes, 0, iter, iter, doff, last_sg,
612 false, false, true);
613 } else {
614 last_sg = 0;
615 fill_tcd_params(fsl_chan->edma, fsl_desc->tcd[i].vtcd,
616 src_addr, dst_addr, fsl_chan->fsc.attr,
617 soff, nbytes, 0, iter, iter, doff, last_sg,
618 true, true, false);
619 }
620 }
621
622 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags);
623}
624
625static void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan)
626{
627 struct fsl_edma_hw_tcd *tcd;
628 struct virt_dma_desc *vdesc;
629
630 vdesc = vchan_next_desc(&fsl_chan->vchan);
631 if (!vdesc)
632 return;
633 fsl_chan->edesc = to_fsl_edma_desc(vdesc);
634 tcd = fsl_chan->edesc->tcd[0].vtcd;
635 fsl_edma_set_tcd_params(fsl_chan, tcd->saddr, tcd->daddr, tcd->attr,
636 tcd->soff, tcd->nbytes, tcd->slast, tcd->citer,
637 tcd->biter, tcd->doff, tcd->dlast_sga, tcd->csr);
638 fsl_edma_enable_request(fsl_chan);
639 fsl_chan->status = DMA_IN_PROGRESS;
640}
641
642static irqreturn_t fsl_edma_tx_handler(int irq, void *dev_id)
643{
644 struct fsl_edma_engine *fsl_edma = dev_id;
645 unsigned int intr, ch;
646 void __iomem *base_addr;
647 struct fsl_edma_chan *fsl_chan;
648
649 base_addr = fsl_edma->membase;
650
651 intr = edma_readl(fsl_edma, base_addr + EDMA_INTR);
652 if (!intr)
653 return IRQ_NONE;
654
655 for (ch = 0; ch < fsl_edma->n_chans; ch++) {
656 if (intr & (0x1 << ch)) {
657 edma_writeb(fsl_edma, EDMA_CINT_CINT(ch),
658 base_addr + EDMA_CINT);
659
660 fsl_chan = &fsl_edma->chans[ch];
661
662 spin_lock(&fsl_chan->vchan.lock);
663 if (!fsl_chan->edesc->iscyclic) {
664 list_del(&fsl_chan->edesc->vdesc.node);
665 vchan_cookie_complete(&fsl_chan->edesc->vdesc);
666 fsl_chan->edesc = NULL;
667 fsl_chan->status = DMA_COMPLETE;
668 } else {
669 vchan_cyclic_callback(&fsl_chan->edesc->vdesc);
670 }
671
672 if (!fsl_chan->edesc)
673 fsl_edma_xfer_desc(fsl_chan);
674
675 spin_unlock(&fsl_chan->vchan.lock);
676 }
677 }
678 return IRQ_HANDLED;
679}
680
681static irqreturn_t fsl_edma_err_handler(int irq, void *dev_id)
682{
683 struct fsl_edma_engine *fsl_edma = dev_id;
684 unsigned int err, ch;
685
686 err = edma_readl(fsl_edma, fsl_edma->membase + EDMA_ERR);
687 if (!err)
688 return IRQ_NONE;
689
690 for (ch = 0; ch < fsl_edma->n_chans; ch++) {
691 if (err & (0x1 << ch)) {
692 fsl_edma_disable_request(&fsl_edma->chans[ch]);
693 edma_writeb(fsl_edma, EDMA_CERR_CERR(ch),
694 fsl_edma->membase + EDMA_CERR);
695 fsl_edma->chans[ch].status = DMA_ERROR;
696 }
697 }
698 return IRQ_HANDLED;
699}
700
701static irqreturn_t fsl_edma_irq_handler(int irq, void *dev_id)
702{
703 if (fsl_edma_tx_handler(irq, dev_id) == IRQ_HANDLED)
704 return IRQ_HANDLED;
705
706 return fsl_edma_err_handler(irq, dev_id);
707}
708
709static void fsl_edma_issue_pending(struct dma_chan *chan)
710{
711 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
712 unsigned long flags;
713
714 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
715
716 if (vchan_issue_pending(&fsl_chan->vchan) && !fsl_chan->edesc)
717 fsl_edma_xfer_desc(fsl_chan);
718
719 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
720}
721
722static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
723 struct of_dma *ofdma)
724{
725 struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data;
726 struct dma_chan *chan, *_chan;
727
728 if (dma_spec->args_count != 2)
729 return NULL;
730
731 mutex_lock(&fsl_edma->fsl_edma_mutex);
732 list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
733 if (chan->client_count)
734 continue;
735 if ((chan->chan_id / DMAMUX_NR) == dma_spec->args[0]) {
736 chan = dma_get_slave_channel(chan);
737 if (chan) {
738 chan->device->privatecnt++;
739 fsl_edma_chan_mux(to_fsl_edma_chan(chan),
740 dma_spec->args[1], true);
741 mutex_unlock(&fsl_edma->fsl_edma_mutex);
742 return chan;
743 }
744 }
745 }
746 mutex_unlock(&fsl_edma->fsl_edma_mutex);
747 return NULL;
748}
749
750static int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
751{
752 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
753
754 fsl_chan->tcd_pool = dma_pool_create("tcd_pool", chan->device->dev,
755 sizeof(struct fsl_edma_hw_tcd),
756 32, 0);
757 return 0;
758}
759
760static void fsl_edma_free_chan_resources(struct dma_chan *chan)
761{
762 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
763 unsigned long flags;
764 LIST_HEAD(head);
765
766 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
767 fsl_edma_disable_request(fsl_chan);
768 fsl_edma_chan_mux(fsl_chan, 0, false);
769 fsl_chan->edesc = NULL;
770 vchan_get_all_descriptors(&fsl_chan->vchan, &head);
771 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
772
773 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
774 dma_pool_destroy(fsl_chan->tcd_pool);
775 fsl_chan->tcd_pool = NULL;
776}
777
778static int fsl_dma_device_slave_caps(struct dma_chan *dchan,
779 struct dma_slave_caps *caps)
780{
781 caps->src_addr_widths = FSL_EDMA_BUSWIDTHS;
782 caps->dstn_addr_widths = FSL_EDMA_BUSWIDTHS;
783 caps->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
784 caps->cmd_pause = true;
785 caps->cmd_terminate = true;
786
787 return 0;
788}
789
790static int
791fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma)
792{
793 int ret;
794
795 fsl_edma->txirq = platform_get_irq_byname(pdev, "edma-tx");
796 if (fsl_edma->txirq < 0) {
797 dev_err(&pdev->dev, "Can't get edma-tx irq.\n");
798 return fsl_edma->txirq;
799 }
800
801 fsl_edma->errirq = platform_get_irq_byname(pdev, "edma-err");
802 if (fsl_edma->errirq < 0) {
803 dev_err(&pdev->dev, "Can't get edma-err irq.\n");
804 return fsl_edma->errirq;
805 }
806
807 if (fsl_edma->txirq == fsl_edma->errirq) {
808 ret = devm_request_irq(&pdev->dev, fsl_edma->txirq,
809 fsl_edma_irq_handler, 0, "eDMA", fsl_edma);
810 if (ret) {
811 dev_err(&pdev->dev, "Can't register eDMA IRQ.\n");
812 return ret;
813 }
814 } else {
815 ret = devm_request_irq(&pdev->dev, fsl_edma->txirq,
816 fsl_edma_tx_handler, 0, "eDMA tx", fsl_edma);
817 if (ret) {
818 dev_err(&pdev->dev, "Can't register eDMA tx IRQ.\n");
819 return ret;
820 }
821
822 ret = devm_request_irq(&pdev->dev, fsl_edma->errirq,
823 fsl_edma_err_handler, 0, "eDMA err", fsl_edma);
824 if (ret) {
825 dev_err(&pdev->dev, "Can't register eDMA err IRQ.\n");
826 return ret;
827 }
828 }
829
830 return 0;
831}
832
833static int fsl_edma_probe(struct platform_device *pdev)
834{
835 struct device_node *np = pdev->dev.of_node;
836 struct fsl_edma_engine *fsl_edma;
837 struct fsl_edma_chan *fsl_chan;
838 struct resource *res;
839 int len, chans;
840 int ret, i;
841
842 ret = of_property_read_u32(np, "dma-channels", &chans);
843 if (ret) {
844 dev_err(&pdev->dev, "Can't get dma-channels.\n");
845 return ret;
846 }
847
848 len = sizeof(*fsl_edma) + sizeof(*fsl_chan) * chans;
849 fsl_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
850 if (!fsl_edma)
851 return -ENOMEM;
852
853 fsl_edma->n_chans = chans;
854 mutex_init(&fsl_edma->fsl_edma_mutex);
855
856 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
857 fsl_edma->membase = devm_ioremap_resource(&pdev->dev, res);
858 if (IS_ERR(fsl_edma->membase))
859 return PTR_ERR(fsl_edma->membase);
860
861 for (i = 0; i < DMAMUX_NR; i++) {
862 char clkname[32];
863
864 res = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i);
865 fsl_edma->muxbase[i] = devm_ioremap_resource(&pdev->dev, res);
866 if (IS_ERR(fsl_edma->muxbase[i]))
867 return PTR_ERR(fsl_edma->muxbase[i]);
868
869 sprintf(clkname, "dmamux%d", i);
870 fsl_edma->muxclk[i] = devm_clk_get(&pdev->dev, clkname);
871 if (IS_ERR(fsl_edma->muxclk[i])) {
872 dev_err(&pdev->dev, "Missing DMAMUX block clock.\n");
873 return PTR_ERR(fsl_edma->muxclk[i]);
874 }
875
876 ret = clk_prepare_enable(fsl_edma->muxclk[i]);
877 if (ret) {
878 dev_err(&pdev->dev, "DMAMUX clk block failed.\n");
879 return ret;
880 }
881
882 }
883
884 ret = fsl_edma_irq_init(pdev, fsl_edma);
885 if (ret)
886 return ret;
887
888 fsl_edma->big_endian = of_property_read_bool(np, "big-endian");
889
890 INIT_LIST_HEAD(&fsl_edma->dma_dev.channels);
891 for (i = 0; i < fsl_edma->n_chans; i++) {
892 struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i];
893
894 fsl_chan->edma = fsl_edma;
895
896 fsl_chan->vchan.desc_free = fsl_edma_free_desc;
897 vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev);
898
899 edma_writew(fsl_edma, 0x0, fsl_edma->membase + EDMA_TCD_CSR(i));
900 fsl_edma_chan_mux(fsl_chan, 0, false);
901 }
902
903 dma_cap_set(DMA_PRIVATE, fsl_edma->dma_dev.cap_mask);
904 dma_cap_set(DMA_SLAVE, fsl_edma->dma_dev.cap_mask);
905 dma_cap_set(DMA_CYCLIC, fsl_edma->dma_dev.cap_mask);
906
907 fsl_edma->dma_dev.dev = &pdev->dev;
908 fsl_edma->dma_dev.device_alloc_chan_resources
909 = fsl_edma_alloc_chan_resources;
910 fsl_edma->dma_dev.device_free_chan_resources
911 = fsl_edma_free_chan_resources;
912 fsl_edma->dma_dev.device_tx_status = fsl_edma_tx_status;
913 fsl_edma->dma_dev.device_prep_slave_sg = fsl_edma_prep_slave_sg;
914 fsl_edma->dma_dev.device_prep_dma_cyclic = fsl_edma_prep_dma_cyclic;
915 fsl_edma->dma_dev.device_control = fsl_edma_control;
916 fsl_edma->dma_dev.device_issue_pending = fsl_edma_issue_pending;
917 fsl_edma->dma_dev.device_slave_caps = fsl_dma_device_slave_caps;
918
919 platform_set_drvdata(pdev, fsl_edma);
920
921 ret = dma_async_device_register(&fsl_edma->dma_dev);
922 if (ret) {
923 dev_err(&pdev->dev, "Can't register Freescale eDMA engine.\n");
924 return ret;
925 }
926
927 ret = of_dma_controller_register(np, fsl_edma_xlate, fsl_edma);
928 if (ret) {
929 dev_err(&pdev->dev, "Can't register Freescale eDMA of_dma.\n");
930 dma_async_device_unregister(&fsl_edma->dma_dev);
931 return ret;
932 }
933
934 /* enable round robin arbitration */
935 edma_writel(fsl_edma, EDMA_CR_ERGA | EDMA_CR_ERCA, fsl_edma->membase + EDMA_CR);
936
937 return 0;
938}
939
940static int fsl_edma_remove(struct platform_device *pdev)
941{
942 struct device_node *np = pdev->dev.of_node;
943 struct fsl_edma_engine *fsl_edma = platform_get_drvdata(pdev);
944 int i;
945
946 of_dma_controller_free(np);
947 dma_async_device_unregister(&fsl_edma->dma_dev);
948
949 for (i = 0; i < DMAMUX_NR; i++)
950 clk_disable_unprepare(fsl_edma->muxclk[i]);
951
952 return 0;
953}
954
955static const struct of_device_id fsl_edma_dt_ids[] = {
956 { .compatible = "fsl,vf610-edma", },
957 { /* sentinel */ }
958};
959MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids);
960
961static struct platform_driver fsl_edma_driver = {
962 .driver = {
963 .name = "fsl-edma",
964 .owner = THIS_MODULE,
965 .of_match_table = fsl_edma_dt_ids,
966 },
967 .probe = fsl_edma_probe,
968 .remove = fsl_edma_remove,
969};
970
971module_platform_driver(fsl_edma_driver);
972
973MODULE_ALIAS("platform:fsl-edma");
974MODULE_DESCRIPTION("Freescale eDMA engine driver");
975MODULE_LICENSE("GPL v2");
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index 6f9ac2022abd..286660a12cc6 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -422,12 +422,12 @@ static irqreturn_t imxdma_err_handler(int irq, void *dev_id)
422 /* Tasklet error handler */ 422 /* Tasklet error handler */
423 tasklet_schedule(&imxdma->channel[i].dma_tasklet); 423 tasklet_schedule(&imxdma->channel[i].dma_tasklet);
424 424
425 printk(KERN_WARNING 425 dev_warn(imxdma->dev,
426 "DMA timeout on channel %d -%s%s%s%s\n", i, 426 "DMA timeout on channel %d -%s%s%s%s\n", i,
427 errcode & IMX_DMA_ERR_BURST ? " burst" : "", 427 errcode & IMX_DMA_ERR_BURST ? " burst" : "",
428 errcode & IMX_DMA_ERR_REQUEST ? " request" : "", 428 errcode & IMX_DMA_ERR_REQUEST ? " request" : "",
429 errcode & IMX_DMA_ERR_TRANSFER ? " transfer" : "", 429 errcode & IMX_DMA_ERR_TRANSFER ? " transfer" : "",
430 errcode & IMX_DMA_ERR_BUFFER ? " buffer" : ""); 430 errcode & IMX_DMA_ERR_BUFFER ? " buffer" : "");
431 } 431 }
432 return IRQ_HANDLED; 432 return IRQ_HANDLED;
433} 433}
@@ -1236,6 +1236,7 @@ static int imxdma_remove(struct platform_device *pdev)
1236static struct platform_driver imxdma_driver = { 1236static struct platform_driver imxdma_driver = {
1237 .driver = { 1237 .driver = {
1238 .name = "imx-dma", 1238 .name = "imx-dma",
1239 .owner = THIS_MODULE,
1239 .of_match_table = imx_dma_of_dev_id, 1240 .of_match_table = imx_dma_of_dev_id,
1240 }, 1241 },
1241 .id_table = imx_dma_devtype, 1242 .id_table = imx_dma_devtype,
diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
index b439679f4126..bf02e7beb51a 100644
--- a/drivers/dma/mmp_pdma.c
+++ b/drivers/dma/mmp_pdma.c
@@ -867,8 +867,8 @@ static int mmp_pdma_chan_init(struct mmp_pdma_device *pdev, int idx, int irq)
867 phy->base = pdev->base; 867 phy->base = pdev->base;
868 868
869 if (irq) { 869 if (irq) {
870 ret = devm_request_irq(pdev->dev, irq, mmp_pdma_chan_handler, 0, 870 ret = devm_request_irq(pdev->dev, irq, mmp_pdma_chan_handler,
871 "pdma", phy); 871 IRQF_SHARED, "pdma", phy);
872 if (ret) { 872 if (ret) {
873 dev_err(pdev->dev, "channel request irq fail!\n"); 873 dev_err(pdev->dev, "channel request irq fail!\n");
874 return ret; 874 return ret;
@@ -957,8 +957,8 @@ static int mmp_pdma_probe(struct platform_device *op)
957 if (irq_num != dma_channels) { 957 if (irq_num != dma_channels) {
958 /* all chan share one irq, demux inside */ 958 /* all chan share one irq, demux inside */
959 irq = platform_get_irq(op, 0); 959 irq = platform_get_irq(op, 0);
960 ret = devm_request_irq(pdev->dev, irq, mmp_pdma_int_handler, 0, 960 ret = devm_request_irq(pdev->dev, irq, mmp_pdma_int_handler,
961 "pdma", pdev); 961 IRQF_SHARED, "pdma", pdev);
962 if (ret) 962 if (ret)
963 return ret; 963 return ret;
964 } 964 }
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index 33f96aaa80c7..724f7f4c9720 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -22,6 +22,7 @@
22#include <mach/regs-icu.h> 22#include <mach/regs-icu.h>
23#include <linux/platform_data/dma-mmp_tdma.h> 23#include <linux/platform_data/dma-mmp_tdma.h>
24#include <linux/of_device.h> 24#include <linux/of_device.h>
25#include <linux/of_dma.h>
25 26
26#include "dmaengine.h" 27#include "dmaengine.h"
27 28
@@ -541,6 +542,45 @@ static int mmp_tdma_chan_init(struct mmp_tdma_device *tdev,
541 return 0; 542 return 0;
542} 543}
543 544
545struct mmp_tdma_filter_param {
546 struct device_node *of_node;
547 unsigned int chan_id;
548};
549
550static bool mmp_tdma_filter_fn(struct dma_chan *chan, void *fn_param)
551{
552 struct mmp_tdma_filter_param *param = fn_param;
553 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
554 struct dma_device *pdma_device = tdmac->chan.device;
555
556 if (pdma_device->dev->of_node != param->of_node)
557 return false;
558
559 if (chan->chan_id != param->chan_id)
560 return false;
561
562 return true;
563}
564
565struct dma_chan *mmp_tdma_xlate(struct of_phandle_args *dma_spec,
566 struct of_dma *ofdma)
567{
568 struct mmp_tdma_device *tdev = ofdma->of_dma_data;
569 dma_cap_mask_t mask = tdev->device.cap_mask;
570 struct mmp_tdma_filter_param param;
571
572 if (dma_spec->args_count != 1)
573 return NULL;
574
575 param.of_node = ofdma->of_node;
576 param.chan_id = dma_spec->args[0];
577
578 if (param.chan_id >= TDMA_CHANNEL_NUM)
579 return NULL;
580
581 return dma_request_channel(mask, mmp_tdma_filter_fn, &param);
582}
583
544static struct of_device_id mmp_tdma_dt_ids[] = { 584static struct of_device_id mmp_tdma_dt_ids[] = {
545 { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA}, 585 { .compatible = "marvell,adma-1.0", .data = (void *)MMP_AUD_TDMA},
546 { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU}, 586 { .compatible = "marvell,pxa910-squ", .data = (void *)PXA910_SQU},
@@ -631,6 +671,16 @@ static int mmp_tdma_probe(struct platform_device *pdev)
631 return ret; 671 return ret;
632 } 672 }
633 673
674 if (pdev->dev.of_node) {
675 ret = of_dma_controller_register(pdev->dev.of_node,
676 mmp_tdma_xlate, tdev);
677 if (ret) {
678 dev_err(tdev->device.dev,
679 "failed to register controller\n");
680 dma_async_device_unregister(&tdev->device);
681 }
682 }
683
634 dev_info(tdev->device.dev, "initialized\n"); 684 dev_info(tdev->device.dev, "initialized\n");
635 return 0; 685 return 0;
636} 686}
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 64ceca2920b8..b19f04f4390b 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -1088,6 +1088,23 @@ static void omap_dma_free(struct omap_dmadev *od)
1088 } 1088 }
1089} 1089}
1090 1090
1091#define OMAP_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
1092 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
1093 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
1094
1095static int omap_dma_device_slave_caps(struct dma_chan *dchan,
1096 struct dma_slave_caps *caps)
1097{
1098 caps->src_addr_widths = OMAP_DMA_BUSWIDTHS;
1099 caps->dstn_addr_widths = OMAP_DMA_BUSWIDTHS;
1100 caps->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
1101 caps->cmd_pause = true;
1102 caps->cmd_terminate = true;
1103 caps->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
1104
1105 return 0;
1106}
1107
1091static int omap_dma_probe(struct platform_device *pdev) 1108static int omap_dma_probe(struct platform_device *pdev)
1092{ 1109{
1093 struct omap_dmadev *od; 1110 struct omap_dmadev *od;
@@ -1118,6 +1135,7 @@ static int omap_dma_probe(struct platform_device *pdev)
1118 od->ddev.device_prep_slave_sg = omap_dma_prep_slave_sg; 1135 od->ddev.device_prep_slave_sg = omap_dma_prep_slave_sg;
1119 od->ddev.device_prep_dma_cyclic = omap_dma_prep_dma_cyclic; 1136 od->ddev.device_prep_dma_cyclic = omap_dma_prep_dma_cyclic;
1120 od->ddev.device_control = omap_dma_control; 1137 od->ddev.device_control = omap_dma_control;
1138 od->ddev.device_slave_caps = omap_dma_device_slave_caps;
1121 od->ddev.dev = &pdev->dev; 1139 od->ddev.dev = &pdev->dev;
1122 INIT_LIST_HEAD(&od->ddev.channels); 1140 INIT_LIST_HEAD(&od->ddev.channels);
1123 INIT_LIST_HEAD(&od->pending); 1141 INIT_LIST_HEAD(&od->pending);
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index 61fdc54a3c88..05fa548bd659 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -964,16 +964,16 @@ static void pch_dma_remove(struct pci_dev *pdev)
964 if (pd) { 964 if (pd) {
965 dma_async_device_unregister(&pd->dma); 965 dma_async_device_unregister(&pd->dma);
966 966
967 free_irq(pdev->irq, pd);
968
967 list_for_each_entry_safe(chan, _c, &pd->dma.channels, 969 list_for_each_entry_safe(chan, _c, &pd->dma.channels,
968 device_node) { 970 device_node) {
969 pd_chan = to_pd_chan(chan); 971 pd_chan = to_pd_chan(chan);
970 972
971 tasklet_disable(&pd_chan->tasklet);
972 tasklet_kill(&pd_chan->tasklet); 973 tasklet_kill(&pd_chan->tasklet);
973 } 974 }
974 975
975 pci_pool_destroy(pd->pool); 976 pci_pool_destroy(pd->pool);
976 free_irq(pdev->irq, pd);
977 pci_iounmap(pdev, pd->membase); 977 pci_iounmap(pdev, pd->membase);
978 pci_release_regions(pdev); 978 pci_release_regions(pdev);
979 pci_disable_device(pdev); 979 pci_disable_device(pdev);
diff --git a/drivers/dma/qcom_bam_dma.c b/drivers/dma/qcom_bam_dma.c
new file mode 100644
index 000000000000..82c923146e49
--- /dev/null
+++ b/drivers/dma/qcom_bam_dma.c
@@ -0,0 +1,1111 @@
1/*
2 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
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 and
6 * only version 2 as 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 * QCOM BAM DMA engine driver
16 *
17 * QCOM BAM DMA blocks are distributed amongst a number of the on-chip
18 * peripherals on the MSM 8x74. The configuration of the channels are dependent
19 * on the way they are hard wired to that specific peripheral. The peripheral
20 * device tree entries specify the configuration of each channel.
21 *
22 * The DMA controller requires the use of external memory for storage of the
23 * hardware descriptors for each channel. The descriptor FIFO is accessed as a
24 * circular buffer and operations are managed according to the offset within the
25 * FIFO. After pipe/channel reset, all of the pipe registers and internal state
26 * are back to defaults.
27 *
28 * During DMA operations, we write descriptors to the FIFO, being careful to
29 * handle wrapping and then write the last FIFO offset to that channel's
30 * P_EVNT_REG register to kick off the transaction. The P_SW_OFSTS register
31 * indicates the current FIFO offset that is being processed, so there is some
32 * indication of where the hardware is currently working.
33 */
34
35#include <linux/kernel.h>
36#include <linux/io.h>
37#include <linux/init.h>
38#include <linux/slab.h>
39#include <linux/module.h>
40#include <linux/interrupt.h>
41#include <linux/dma-mapping.h>
42#include <linux/scatterlist.h>
43#include <linux/device.h>
44#include <linux/platform_device.h>
45#include <linux/of.h>
46#include <linux/of_address.h>
47#include <linux/of_irq.h>
48#include <linux/of_dma.h>
49#include <linux/clk.h>
50#include <linux/dmaengine.h>
51
52#include "dmaengine.h"
53#include "virt-dma.h"
54
55struct bam_desc_hw {
56 u32 addr; /* Buffer physical address */
57 u16 size; /* Buffer size in bytes */
58 u16 flags;
59};
60
61#define DESC_FLAG_INT BIT(15)
62#define DESC_FLAG_EOT BIT(14)
63#define DESC_FLAG_EOB BIT(13)
64
65struct bam_async_desc {
66 struct virt_dma_desc vd;
67
68 u32 num_desc;
69 u32 xfer_len;
70 struct bam_desc_hw *curr_desc;
71
72 enum dma_transfer_direction dir;
73 size_t length;
74 struct bam_desc_hw desc[0];
75};
76
77#define BAM_CTRL 0x0000
78#define BAM_REVISION 0x0004
79#define BAM_SW_REVISION 0x0080
80#define BAM_NUM_PIPES 0x003C
81#define BAM_TIMER 0x0040
82#define BAM_TIMER_CTRL 0x0044
83#define BAM_DESC_CNT_TRSHLD 0x0008
84#define BAM_IRQ_SRCS 0x000C
85#define BAM_IRQ_SRCS_MSK 0x0010
86#define BAM_IRQ_SRCS_UNMASKED 0x0030
87#define BAM_IRQ_STTS 0x0014
88#define BAM_IRQ_CLR 0x0018
89#define BAM_IRQ_EN 0x001C
90#define BAM_CNFG_BITS 0x007C
91#define BAM_IRQ_SRCS_EE(ee) (0x0800 + ((ee) * 0x80))
92#define BAM_IRQ_SRCS_MSK_EE(ee) (0x0804 + ((ee) * 0x80))
93#define BAM_P_CTRL(pipe) (0x1000 + ((pipe) * 0x1000))
94#define BAM_P_RST(pipe) (0x1004 + ((pipe) * 0x1000))
95#define BAM_P_HALT(pipe) (0x1008 + ((pipe) * 0x1000))
96#define BAM_P_IRQ_STTS(pipe) (0x1010 + ((pipe) * 0x1000))
97#define BAM_P_IRQ_CLR(pipe) (0x1014 + ((pipe) * 0x1000))
98#define BAM_P_IRQ_EN(pipe) (0x1018 + ((pipe) * 0x1000))
99#define BAM_P_EVNT_DEST_ADDR(pipe) (0x182C + ((pipe) * 0x1000))
100#define BAM_P_EVNT_REG(pipe) (0x1818 + ((pipe) * 0x1000))
101#define BAM_P_SW_OFSTS(pipe) (0x1800 + ((pipe) * 0x1000))
102#define BAM_P_DATA_FIFO_ADDR(pipe) (0x1824 + ((pipe) * 0x1000))
103#define BAM_P_DESC_FIFO_ADDR(pipe) (0x181C + ((pipe) * 0x1000))
104#define BAM_P_EVNT_TRSHLD(pipe) (0x1828 + ((pipe) * 0x1000))
105#define BAM_P_FIFO_SIZES(pipe) (0x1820 + ((pipe) * 0x1000))
106
107/* BAM CTRL */
108#define BAM_SW_RST BIT(0)
109#define BAM_EN BIT(1)
110#define BAM_EN_ACCUM BIT(4)
111#define BAM_TESTBUS_SEL_SHIFT 5
112#define BAM_TESTBUS_SEL_MASK 0x3F
113#define BAM_DESC_CACHE_SEL_SHIFT 13
114#define BAM_DESC_CACHE_SEL_MASK 0x3
115#define BAM_CACHED_DESC_STORE BIT(15)
116#define IBC_DISABLE BIT(16)
117
118/* BAM REVISION */
119#define REVISION_SHIFT 0
120#define REVISION_MASK 0xFF
121#define NUM_EES_SHIFT 8
122#define NUM_EES_MASK 0xF
123#define CE_BUFFER_SIZE BIT(13)
124#define AXI_ACTIVE BIT(14)
125#define USE_VMIDMT BIT(15)
126#define SECURED BIT(16)
127#define BAM_HAS_NO_BYPASS BIT(17)
128#define HIGH_FREQUENCY_BAM BIT(18)
129#define INACTIV_TMRS_EXST BIT(19)
130#define NUM_INACTIV_TMRS BIT(20)
131#define DESC_CACHE_DEPTH_SHIFT 21
132#define DESC_CACHE_DEPTH_1 (0 << DESC_CACHE_DEPTH_SHIFT)
133#define DESC_CACHE_DEPTH_2 (1 << DESC_CACHE_DEPTH_SHIFT)
134#define DESC_CACHE_DEPTH_3 (2 << DESC_CACHE_DEPTH_SHIFT)
135#define DESC_CACHE_DEPTH_4 (3 << DESC_CACHE_DEPTH_SHIFT)
136#define CMD_DESC_EN BIT(23)
137#define INACTIV_TMR_BASE_SHIFT 24
138#define INACTIV_TMR_BASE_MASK 0xFF
139
140/* BAM NUM PIPES */
141#define BAM_NUM_PIPES_SHIFT 0
142#define BAM_NUM_PIPES_MASK 0xFF
143#define PERIPH_NON_PIPE_GRP_SHIFT 16
144#define PERIPH_NON_PIP_GRP_MASK 0xFF
145#define BAM_NON_PIPE_GRP_SHIFT 24
146#define BAM_NON_PIPE_GRP_MASK 0xFF
147
148/* BAM CNFG BITS */
149#define BAM_PIPE_CNFG BIT(2)
150#define BAM_FULL_PIPE BIT(11)
151#define BAM_NO_EXT_P_RST BIT(12)
152#define BAM_IBC_DISABLE BIT(13)
153#define BAM_SB_CLK_REQ BIT(14)
154#define BAM_PSM_CSW_REQ BIT(15)
155#define BAM_PSM_P_RES BIT(16)
156#define BAM_AU_P_RES BIT(17)
157#define BAM_SI_P_RES BIT(18)
158#define BAM_WB_P_RES BIT(19)
159#define BAM_WB_BLK_CSW BIT(20)
160#define BAM_WB_CSW_ACK_IDL BIT(21)
161#define BAM_WB_RETR_SVPNT BIT(22)
162#define BAM_WB_DSC_AVL_P_RST BIT(23)
163#define BAM_REG_P_EN BIT(24)
164#define BAM_PSM_P_HD_DATA BIT(25)
165#define BAM_AU_ACCUMED BIT(26)
166#define BAM_CMD_ENABLE BIT(27)
167
168#define BAM_CNFG_BITS_DEFAULT (BAM_PIPE_CNFG | \
169 BAM_NO_EXT_P_RST | \
170 BAM_IBC_DISABLE | \
171 BAM_SB_CLK_REQ | \
172 BAM_PSM_CSW_REQ | \
173 BAM_PSM_P_RES | \
174 BAM_AU_P_RES | \
175 BAM_SI_P_RES | \
176 BAM_WB_P_RES | \
177 BAM_WB_BLK_CSW | \
178 BAM_WB_CSW_ACK_IDL | \
179 BAM_WB_RETR_SVPNT | \
180 BAM_WB_DSC_AVL_P_RST | \
181 BAM_REG_P_EN | \
182 BAM_PSM_P_HD_DATA | \
183 BAM_AU_ACCUMED | \
184 BAM_CMD_ENABLE)
185
186/* PIPE CTRL */
187#define P_EN BIT(1)
188#define P_DIRECTION BIT(3)
189#define P_SYS_STRM BIT(4)
190#define P_SYS_MODE BIT(5)
191#define P_AUTO_EOB BIT(6)
192#define P_AUTO_EOB_SEL_SHIFT 7
193#define P_AUTO_EOB_SEL_512 (0 << P_AUTO_EOB_SEL_SHIFT)
194#define P_AUTO_EOB_SEL_256 (1 << P_AUTO_EOB_SEL_SHIFT)
195#define P_AUTO_EOB_SEL_128 (2 << P_AUTO_EOB_SEL_SHIFT)
196#define P_AUTO_EOB_SEL_64 (3 << P_AUTO_EOB_SEL_SHIFT)
197#define P_PREFETCH_LIMIT_SHIFT 9
198#define P_PREFETCH_LIMIT_32 (0 << P_PREFETCH_LIMIT_SHIFT)
199#define P_PREFETCH_LIMIT_16 (1 << P_PREFETCH_LIMIT_SHIFT)
200#define P_PREFETCH_LIMIT_4 (2 << P_PREFETCH_LIMIT_SHIFT)
201#define P_WRITE_NWD BIT(11)
202#define P_LOCK_GROUP_SHIFT 16
203#define P_LOCK_GROUP_MASK 0x1F
204
205/* BAM_DESC_CNT_TRSHLD */
206#define CNT_TRSHLD 0xffff
207#define DEFAULT_CNT_THRSHLD 0x4
208
209/* BAM_IRQ_SRCS */
210#define BAM_IRQ BIT(31)
211#define P_IRQ 0x7fffffff
212
213/* BAM_IRQ_SRCS_MSK */
214#define BAM_IRQ_MSK BAM_IRQ
215#define P_IRQ_MSK P_IRQ
216
217/* BAM_IRQ_STTS */
218#define BAM_TIMER_IRQ BIT(4)
219#define BAM_EMPTY_IRQ BIT(3)
220#define BAM_ERROR_IRQ BIT(2)
221#define BAM_HRESP_ERR_IRQ BIT(1)
222
223/* BAM_IRQ_CLR */
224#define BAM_TIMER_CLR BIT(4)
225#define BAM_EMPTY_CLR BIT(3)
226#define BAM_ERROR_CLR BIT(2)
227#define BAM_HRESP_ERR_CLR BIT(1)
228
229/* BAM_IRQ_EN */
230#define BAM_TIMER_EN BIT(4)
231#define BAM_EMPTY_EN BIT(3)
232#define BAM_ERROR_EN BIT(2)
233#define BAM_HRESP_ERR_EN BIT(1)
234
235/* BAM_P_IRQ_EN */
236#define P_PRCSD_DESC_EN BIT(0)
237#define P_TIMER_EN BIT(1)
238#define P_WAKE_EN BIT(2)
239#define P_OUT_OF_DESC_EN BIT(3)
240#define P_ERR_EN BIT(4)
241#define P_TRNSFR_END_EN BIT(5)
242#define P_DEFAULT_IRQS_EN (P_PRCSD_DESC_EN | P_ERR_EN | P_TRNSFR_END_EN)
243
244/* BAM_P_SW_OFSTS */
245#define P_SW_OFSTS_MASK 0xffff
246
247#define BAM_DESC_FIFO_SIZE SZ_32K
248#define MAX_DESCRIPTORS (BAM_DESC_FIFO_SIZE / sizeof(struct bam_desc_hw) - 1)
249#define BAM_MAX_DATA_SIZE (SZ_32K - 8)
250
251struct bam_chan {
252 struct virt_dma_chan vc;
253
254 struct bam_device *bdev;
255
256 /* configuration from device tree */
257 u32 id;
258
259 struct bam_async_desc *curr_txd; /* current running dma */
260
261 /* runtime configuration */
262 struct dma_slave_config slave;
263
264 /* fifo storage */
265 struct bam_desc_hw *fifo_virt;
266 dma_addr_t fifo_phys;
267
268 /* fifo markers */
269 unsigned short head; /* start of active descriptor entries */
270 unsigned short tail; /* end of active descriptor entries */
271
272 unsigned int initialized; /* is the channel hw initialized? */
273 unsigned int paused; /* is the channel paused? */
274 unsigned int reconfigure; /* new slave config? */
275
276 struct list_head node;
277};
278
279static inline struct bam_chan *to_bam_chan(struct dma_chan *common)
280{
281 return container_of(common, struct bam_chan, vc.chan);
282}
283
284struct bam_device {
285 void __iomem *regs;
286 struct device *dev;
287 struct dma_device common;
288 struct device_dma_parameters dma_parms;
289 struct bam_chan *channels;
290 u32 num_channels;
291
292 /* execution environment ID, from DT */
293 u32 ee;
294
295 struct clk *bamclk;
296 int irq;
297
298 /* dma start transaction tasklet */
299 struct tasklet_struct task;
300};
301
302/**
303 * bam_reset_channel - Reset individual BAM DMA channel
304 * @bchan: bam channel
305 *
306 * This function resets a specific BAM channel
307 */
308static void bam_reset_channel(struct bam_chan *bchan)
309{
310 struct bam_device *bdev = bchan->bdev;
311
312 lockdep_assert_held(&bchan->vc.lock);
313
314 /* reset channel */
315 writel_relaxed(1, bdev->regs + BAM_P_RST(bchan->id));
316 writel_relaxed(0, bdev->regs + BAM_P_RST(bchan->id));
317
318 /* don't allow cpu to reorder BAM register accesses done after this */
319 wmb();
320
321 /* make sure hw is initialized when channel is used the first time */
322 bchan->initialized = 0;
323}
324
325/**
326 * bam_chan_init_hw - Initialize channel hardware
327 * @bchan: bam channel
328 *
329 * This function resets and initializes the BAM channel
330 */
331static void bam_chan_init_hw(struct bam_chan *bchan,
332 enum dma_transfer_direction dir)
333{
334 struct bam_device *bdev = bchan->bdev;
335 u32 val;
336
337 /* Reset the channel to clear internal state of the FIFO */
338 bam_reset_channel(bchan);
339
340 /*
341 * write out 8 byte aligned address. We have enough space for this
342 * because we allocated 1 more descriptor (8 bytes) than we can use
343 */
344 writel_relaxed(ALIGN(bchan->fifo_phys, sizeof(struct bam_desc_hw)),
345 bdev->regs + BAM_P_DESC_FIFO_ADDR(bchan->id));
346 writel_relaxed(BAM_DESC_FIFO_SIZE, bdev->regs +
347 BAM_P_FIFO_SIZES(bchan->id));
348
349 /* enable the per pipe interrupts, enable EOT, ERR, and INT irqs */
350 writel_relaxed(P_DEFAULT_IRQS_EN, bdev->regs + BAM_P_IRQ_EN(bchan->id));
351
352 /* unmask the specific pipe and EE combo */
353 val = readl_relaxed(bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
354 val |= BIT(bchan->id);
355 writel_relaxed(val, bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
356
357 /* don't allow cpu to reorder the channel enable done below */
358 wmb();
359
360 /* set fixed direction and mode, then enable channel */
361 val = P_EN | P_SYS_MODE;
362 if (dir == DMA_DEV_TO_MEM)
363 val |= P_DIRECTION;
364
365 writel_relaxed(val, bdev->regs + BAM_P_CTRL(bchan->id));
366
367 bchan->initialized = 1;
368
369 /* init FIFO pointers */
370 bchan->head = 0;
371 bchan->tail = 0;
372}
373
374/**
375 * bam_alloc_chan - Allocate channel resources for DMA channel.
376 * @chan: specified channel
377 *
378 * This function allocates the FIFO descriptor memory
379 */
380static int bam_alloc_chan(struct dma_chan *chan)
381{
382 struct bam_chan *bchan = to_bam_chan(chan);
383 struct bam_device *bdev = bchan->bdev;
384
385 if (bchan->fifo_virt)
386 return 0;
387
388 /* allocate FIFO descriptor space, but only if necessary */
389 bchan->fifo_virt = dma_alloc_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE,
390 &bchan->fifo_phys, GFP_KERNEL);
391
392 if (!bchan->fifo_virt) {
393 dev_err(bdev->dev, "Failed to allocate desc fifo\n");
394 return -ENOMEM;
395 }
396
397 return 0;
398}
399
400/**
401 * bam_free_chan - Frees dma resources associated with specific channel
402 * @chan: specified channel
403 *
404 * Free the allocated fifo descriptor memory and channel resources
405 *
406 */
407static void bam_free_chan(struct dma_chan *chan)
408{
409 struct bam_chan *bchan = to_bam_chan(chan);
410 struct bam_device *bdev = bchan->bdev;
411 u32 val;
412 unsigned long flags;
413
414 vchan_free_chan_resources(to_virt_chan(chan));
415
416 if (bchan->curr_txd) {
417 dev_err(bchan->bdev->dev, "Cannot free busy channel\n");
418 return;
419 }
420
421 spin_lock_irqsave(&bchan->vc.lock, flags);
422 bam_reset_channel(bchan);
423 spin_unlock_irqrestore(&bchan->vc.lock, flags);
424
425 dma_free_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE, bchan->fifo_virt,
426 bchan->fifo_phys);
427 bchan->fifo_virt = NULL;
428
429 /* mask irq for pipe/channel */
430 val = readl_relaxed(bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
431 val &= ~BIT(bchan->id);
432 writel_relaxed(val, bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
433
434 /* disable irq */
435 writel_relaxed(0, bdev->regs + BAM_P_IRQ_EN(bchan->id));
436}
437
438/**
439 * bam_slave_config - set slave configuration for channel
440 * @chan: dma channel
441 * @cfg: slave configuration
442 *
443 * Sets slave configuration for channel
444 *
445 */
446static void bam_slave_config(struct bam_chan *bchan,
447 struct dma_slave_config *cfg)
448{
449 memcpy(&bchan->slave, cfg, sizeof(*cfg));
450 bchan->reconfigure = 1;
451}
452
453/**
454 * bam_prep_slave_sg - Prep slave sg transaction
455 *
456 * @chan: dma channel
457 * @sgl: scatter gather list
458 * @sg_len: length of sg
459 * @direction: DMA transfer direction
460 * @flags: DMA flags
461 * @context: transfer context (unused)
462 */
463static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
464 struct scatterlist *sgl, unsigned int sg_len,
465 enum dma_transfer_direction direction, unsigned long flags,
466 void *context)
467{
468 struct bam_chan *bchan = to_bam_chan(chan);
469 struct bam_device *bdev = bchan->bdev;
470 struct bam_async_desc *async_desc;
471 struct scatterlist *sg;
472 u32 i;
473 struct bam_desc_hw *desc;
474 unsigned int num_alloc = 0;
475
476
477 if (!is_slave_direction(direction)) {
478 dev_err(bdev->dev, "invalid dma direction\n");
479 return NULL;
480 }
481
482 /* calculate number of required entries */
483 for_each_sg(sgl, sg, sg_len, i)
484 num_alloc += DIV_ROUND_UP(sg_dma_len(sg), BAM_MAX_DATA_SIZE);
485
486 /* allocate enough room to accomodate the number of entries */
487 async_desc = kzalloc(sizeof(*async_desc) +
488 (num_alloc * sizeof(struct bam_desc_hw)), GFP_NOWAIT);
489
490 if (!async_desc)
491 goto err_out;
492
493 async_desc->num_desc = num_alloc;
494 async_desc->curr_desc = async_desc->desc;
495 async_desc->dir = direction;
496
497 /* fill in temporary descriptors */
498 desc = async_desc->desc;
499 for_each_sg(sgl, sg, sg_len, i) {
500 unsigned int remainder = sg_dma_len(sg);
501 unsigned int curr_offset = 0;
502
503 do {
504 desc->addr = sg_dma_address(sg) + curr_offset;
505
506 if (remainder > BAM_MAX_DATA_SIZE) {
507 desc->size = BAM_MAX_DATA_SIZE;
508 remainder -= BAM_MAX_DATA_SIZE;
509 curr_offset += BAM_MAX_DATA_SIZE;
510 } else {
511 desc->size = remainder;
512 remainder = 0;
513 }
514
515 async_desc->length += desc->size;
516 desc++;
517 } while (remainder > 0);
518 }
519
520 return vchan_tx_prep(&bchan->vc, &async_desc->vd, flags);
521
522err_out:
523 kfree(async_desc);
524 return NULL;
525}
526
527/**
528 * bam_dma_terminate_all - terminate all transactions on a channel
529 * @bchan: bam dma channel
530 *
531 * Dequeues and frees all transactions
532 * No callbacks are done
533 *
534 */
535static void bam_dma_terminate_all(struct bam_chan *bchan)
536{
537 unsigned long flag;
538 LIST_HEAD(head);
539
540 /* remove all transactions, including active transaction */
541 spin_lock_irqsave(&bchan->vc.lock, flag);
542 if (bchan->curr_txd) {
543 list_add(&bchan->curr_txd->vd.node, &bchan->vc.desc_issued);
544 bchan->curr_txd = NULL;
545 }
546
547 vchan_get_all_descriptors(&bchan->vc, &head);
548 spin_unlock_irqrestore(&bchan->vc.lock, flag);
549
550 vchan_dma_desc_free_list(&bchan->vc, &head);
551}
552
553/**
554 * bam_control - DMA device control
555 * @chan: dma channel
556 * @cmd: control cmd
557 * @arg: cmd argument
558 *
559 * Perform DMA control command
560 *
561 */
562static int bam_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
563 unsigned long arg)
564{
565 struct bam_chan *bchan = to_bam_chan(chan);
566 struct bam_device *bdev = bchan->bdev;
567 int ret = 0;
568 unsigned long flag;
569
570 switch (cmd) {
571 case DMA_PAUSE:
572 spin_lock_irqsave(&bchan->vc.lock, flag);
573 writel_relaxed(1, bdev->regs + BAM_P_HALT(bchan->id));
574 bchan->paused = 1;
575 spin_unlock_irqrestore(&bchan->vc.lock, flag);
576 break;
577
578 case DMA_RESUME:
579 spin_lock_irqsave(&bchan->vc.lock, flag);
580 writel_relaxed(0, bdev->regs + BAM_P_HALT(bchan->id));
581 bchan->paused = 0;
582 spin_unlock_irqrestore(&bchan->vc.lock, flag);
583 break;
584
585 case DMA_TERMINATE_ALL:
586 bam_dma_terminate_all(bchan);
587 break;
588
589 case DMA_SLAVE_CONFIG:
590 spin_lock_irqsave(&bchan->vc.lock, flag);
591 bam_slave_config(bchan, (struct dma_slave_config *)arg);
592 spin_unlock_irqrestore(&bchan->vc.lock, flag);
593 break;
594
595 default:
596 ret = -ENXIO;
597 break;
598 }
599
600 return ret;
601}
602
603/**
604 * process_channel_irqs - processes the channel interrupts
605 * @bdev: bam controller
606 *
607 * This function processes the channel interrupts
608 *
609 */
610static u32 process_channel_irqs(struct bam_device *bdev)
611{
612 u32 i, srcs, pipe_stts;
613 unsigned long flags;
614 struct bam_async_desc *async_desc;
615
616 srcs = readl_relaxed(bdev->regs + BAM_IRQ_SRCS_EE(bdev->ee));
617
618 /* return early if no pipe/channel interrupts are present */
619 if (!(srcs & P_IRQ))
620 return srcs;
621
622 for (i = 0; i < bdev->num_channels; i++) {
623 struct bam_chan *bchan = &bdev->channels[i];
624
625 if (!(srcs & BIT(i)))
626 continue;
627
628 /* clear pipe irq */
629 pipe_stts = readl_relaxed(bdev->regs +
630 BAM_P_IRQ_STTS(i));
631
632 writel_relaxed(pipe_stts, bdev->regs +
633 BAM_P_IRQ_CLR(i));
634
635 spin_lock_irqsave(&bchan->vc.lock, flags);
636 async_desc = bchan->curr_txd;
637
638 if (async_desc) {
639 async_desc->num_desc -= async_desc->xfer_len;
640 async_desc->curr_desc += async_desc->xfer_len;
641 bchan->curr_txd = NULL;
642
643 /* manage FIFO */
644 bchan->head += async_desc->xfer_len;
645 bchan->head %= MAX_DESCRIPTORS;
646
647 /*
648 * if complete, process cookie. Otherwise
649 * push back to front of desc_issued so that
650 * it gets restarted by the tasklet
651 */
652 if (!async_desc->num_desc)
653 vchan_cookie_complete(&async_desc->vd);
654 else
655 list_add(&async_desc->vd.node,
656 &bchan->vc.desc_issued);
657 }
658
659 spin_unlock_irqrestore(&bchan->vc.lock, flags);
660 }
661
662 return srcs;
663}
664
665/**
666 * bam_dma_irq - irq handler for bam controller
667 * @irq: IRQ of interrupt
668 * @data: callback data
669 *
670 * IRQ handler for the bam controller
671 */
672static irqreturn_t bam_dma_irq(int irq, void *data)
673{
674 struct bam_device *bdev = data;
675 u32 clr_mask = 0, srcs = 0;
676
677 srcs |= process_channel_irqs(bdev);
678
679 /* kick off tasklet to start next dma transfer */
680 if (srcs & P_IRQ)
681 tasklet_schedule(&bdev->task);
682
683 if (srcs & BAM_IRQ)
684 clr_mask = readl_relaxed(bdev->regs + BAM_IRQ_STTS);
685
686 /* don't allow reorder of the various accesses to the BAM registers */
687 mb();
688
689 writel_relaxed(clr_mask, bdev->regs + BAM_IRQ_CLR);
690
691 return IRQ_HANDLED;
692}
693
694/**
695 * bam_tx_status - returns status of transaction
696 * @chan: dma channel
697 * @cookie: transaction cookie
698 * @txstate: DMA transaction state
699 *
700 * Return status of dma transaction
701 */
702static enum dma_status bam_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
703 struct dma_tx_state *txstate)
704{
705 struct bam_chan *bchan = to_bam_chan(chan);
706 struct virt_dma_desc *vd;
707 int ret;
708 size_t residue = 0;
709 unsigned int i;
710 unsigned long flags;
711
712 ret = dma_cookie_status(chan, cookie, txstate);
713 if (ret == DMA_COMPLETE)
714 return ret;
715
716 if (!txstate)
717 return bchan->paused ? DMA_PAUSED : ret;
718
719 spin_lock_irqsave(&bchan->vc.lock, flags);
720 vd = vchan_find_desc(&bchan->vc, cookie);
721 if (vd)
722 residue = container_of(vd, struct bam_async_desc, vd)->length;
723 else if (bchan->curr_txd && bchan->curr_txd->vd.tx.cookie == cookie)
724 for (i = 0; i < bchan->curr_txd->num_desc; i++)
725 residue += bchan->curr_txd->curr_desc[i].size;
726
727 spin_unlock_irqrestore(&bchan->vc.lock, flags);
728
729 dma_set_residue(txstate, residue);
730
731 if (ret == DMA_IN_PROGRESS && bchan->paused)
732 ret = DMA_PAUSED;
733
734 return ret;
735}
736
737/**
738 * bam_apply_new_config
739 * @bchan: bam dma channel
740 * @dir: DMA direction
741 */
742static void bam_apply_new_config(struct bam_chan *bchan,
743 enum dma_transfer_direction dir)
744{
745 struct bam_device *bdev = bchan->bdev;
746 u32 maxburst;
747
748 if (dir == DMA_DEV_TO_MEM)
749 maxburst = bchan->slave.src_maxburst;
750 else
751 maxburst = bchan->slave.dst_maxburst;
752
753 writel_relaxed(maxburst, bdev->regs + BAM_DESC_CNT_TRSHLD);
754
755 bchan->reconfigure = 0;
756}
757
758/**
759 * bam_start_dma - start next transaction
760 * @bchan - bam dma channel
761 */
762static void bam_start_dma(struct bam_chan *bchan)
763{
764 struct virt_dma_desc *vd = vchan_next_desc(&bchan->vc);
765 struct bam_device *bdev = bchan->bdev;
766 struct bam_async_desc *async_desc;
767 struct bam_desc_hw *desc;
768 struct bam_desc_hw *fifo = PTR_ALIGN(bchan->fifo_virt,
769 sizeof(struct bam_desc_hw));
770
771 lockdep_assert_held(&bchan->vc.lock);
772
773 if (!vd)
774 return;
775
776 list_del(&vd->node);
777
778 async_desc = container_of(vd, struct bam_async_desc, vd);
779 bchan->curr_txd = async_desc;
780
781 /* on first use, initialize the channel hardware */
782 if (!bchan->initialized)
783 bam_chan_init_hw(bchan, async_desc->dir);
784
785 /* apply new slave config changes, if necessary */
786 if (bchan->reconfigure)
787 bam_apply_new_config(bchan, async_desc->dir);
788
789 desc = bchan->curr_txd->curr_desc;
790
791 if (async_desc->num_desc > MAX_DESCRIPTORS)
792 async_desc->xfer_len = MAX_DESCRIPTORS;
793 else
794 async_desc->xfer_len = async_desc->num_desc;
795
796 /* set INT on last descriptor */
797 desc[async_desc->xfer_len - 1].flags |= DESC_FLAG_INT;
798
799 if (bchan->tail + async_desc->xfer_len > MAX_DESCRIPTORS) {
800 u32 partial = MAX_DESCRIPTORS - bchan->tail;
801
802 memcpy(&fifo[bchan->tail], desc,
803 partial * sizeof(struct bam_desc_hw));
804 memcpy(fifo, &desc[partial], (async_desc->xfer_len - partial) *
805 sizeof(struct bam_desc_hw));
806 } else {
807 memcpy(&fifo[bchan->tail], desc,
808 async_desc->xfer_len * sizeof(struct bam_desc_hw));
809 }
810
811 bchan->tail += async_desc->xfer_len;
812 bchan->tail %= MAX_DESCRIPTORS;
813
814 /* ensure descriptor writes and dma start not reordered */
815 wmb();
816 writel_relaxed(bchan->tail * sizeof(struct bam_desc_hw),
817 bdev->regs + BAM_P_EVNT_REG(bchan->id));
818}
819
820/**
821 * dma_tasklet - DMA IRQ tasklet
822 * @data: tasklet argument (bam controller structure)
823 *
824 * Sets up next DMA operation and then processes all completed transactions
825 */
826static void dma_tasklet(unsigned long data)
827{
828 struct bam_device *bdev = (struct bam_device *)data;
829 struct bam_chan *bchan;
830 unsigned long flags;
831 unsigned int i;
832
833 /* go through the channels and kick off transactions */
834 for (i = 0; i < bdev->num_channels; i++) {
835 bchan = &bdev->channels[i];
836 spin_lock_irqsave(&bchan->vc.lock, flags);
837
838 if (!list_empty(&bchan->vc.desc_issued) && !bchan->curr_txd)
839 bam_start_dma(bchan);
840 spin_unlock_irqrestore(&bchan->vc.lock, flags);
841 }
842}
843
844/**
845 * bam_issue_pending - starts pending transactions
846 * @chan: dma channel
847 *
848 * Calls tasklet directly which in turn starts any pending transactions
849 */
850static void bam_issue_pending(struct dma_chan *chan)
851{
852 struct bam_chan *bchan = to_bam_chan(chan);
853 unsigned long flags;
854
855 spin_lock_irqsave(&bchan->vc.lock, flags);
856
857 /* if work pending and idle, start a transaction */
858 if (vchan_issue_pending(&bchan->vc) && !bchan->curr_txd)
859 bam_start_dma(bchan);
860
861 spin_unlock_irqrestore(&bchan->vc.lock, flags);
862}
863
864/**
865 * bam_dma_free_desc - free descriptor memory
866 * @vd: virtual descriptor
867 *
868 */
869static void bam_dma_free_desc(struct virt_dma_desc *vd)
870{
871 struct bam_async_desc *async_desc = container_of(vd,
872 struct bam_async_desc, vd);
873
874 kfree(async_desc);
875}
876
877static struct dma_chan *bam_dma_xlate(struct of_phandle_args *dma_spec,
878 struct of_dma *of)
879{
880 struct bam_device *bdev = container_of(of->of_dma_data,
881 struct bam_device, common);
882 unsigned int request;
883
884 if (dma_spec->args_count != 1)
885 return NULL;
886
887 request = dma_spec->args[0];
888 if (request >= bdev->num_channels)
889 return NULL;
890
891 return dma_get_slave_channel(&(bdev->channels[request].vc.chan));
892}
893
894/**
895 * bam_init
896 * @bdev: bam device
897 *
898 * Initialization helper for global bam registers
899 */
900static int bam_init(struct bam_device *bdev)
901{
902 u32 val;
903
904 /* read revision and configuration information */
905 val = readl_relaxed(bdev->regs + BAM_REVISION) >> NUM_EES_SHIFT;
906 val &= NUM_EES_MASK;
907
908 /* check that configured EE is within range */
909 if (bdev->ee >= val)
910 return -EINVAL;
911
912 val = readl_relaxed(bdev->regs + BAM_NUM_PIPES);
913 bdev->num_channels = val & BAM_NUM_PIPES_MASK;
914
915 /* s/w reset bam */
916 /* after reset all pipes are disabled and idle */
917 val = readl_relaxed(bdev->regs + BAM_CTRL);
918 val |= BAM_SW_RST;
919 writel_relaxed(val, bdev->regs + BAM_CTRL);
920 val &= ~BAM_SW_RST;
921 writel_relaxed(val, bdev->regs + BAM_CTRL);
922
923 /* make sure previous stores are visible before enabling BAM */
924 wmb();
925
926 /* enable bam */
927 val |= BAM_EN;
928 writel_relaxed(val, bdev->regs + BAM_CTRL);
929
930 /* set descriptor threshhold, start with 4 bytes */
931 writel_relaxed(DEFAULT_CNT_THRSHLD, bdev->regs + BAM_DESC_CNT_TRSHLD);
932
933 /* Enable default set of h/w workarounds, ie all except BAM_FULL_PIPE */
934 writel_relaxed(BAM_CNFG_BITS_DEFAULT, bdev->regs + BAM_CNFG_BITS);
935
936 /* enable irqs for errors */
937 writel_relaxed(BAM_ERROR_EN | BAM_HRESP_ERR_EN,
938 bdev->regs + BAM_IRQ_EN);
939
940 /* unmask global bam interrupt */
941 writel_relaxed(BAM_IRQ_MSK, bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
942
943 return 0;
944}
945
946static void bam_channel_init(struct bam_device *bdev, struct bam_chan *bchan,
947 u32 index)
948{
949 bchan->id = index;
950 bchan->bdev = bdev;
951
952 vchan_init(&bchan->vc, &bdev->common);
953 bchan->vc.desc_free = bam_dma_free_desc;
954}
955
956static int bam_dma_probe(struct platform_device *pdev)
957{
958 struct bam_device *bdev;
959 struct resource *iores;
960 int ret, i;
961
962 bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL);
963 if (!bdev)
964 return -ENOMEM;
965
966 bdev->dev = &pdev->dev;
967
968 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
969 bdev->regs = devm_ioremap_resource(&pdev->dev, iores);
970 if (IS_ERR(bdev->regs))
971 return PTR_ERR(bdev->regs);
972
973 bdev->irq = platform_get_irq(pdev, 0);
974 if (bdev->irq < 0)
975 return bdev->irq;
976
977 ret = of_property_read_u32(pdev->dev.of_node, "qcom,ee", &bdev->ee);
978 if (ret) {
979 dev_err(bdev->dev, "Execution environment unspecified\n");
980 return ret;
981 }
982
983 bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk");
984 if (IS_ERR(bdev->bamclk))
985 return PTR_ERR(bdev->bamclk);
986
987 ret = clk_prepare_enable(bdev->bamclk);
988 if (ret) {
989 dev_err(bdev->dev, "failed to prepare/enable clock\n");
990 return ret;
991 }
992
993 ret = bam_init(bdev);
994 if (ret)
995 goto err_disable_clk;
996
997 tasklet_init(&bdev->task, dma_tasklet, (unsigned long)bdev);
998
999 bdev->channels = devm_kcalloc(bdev->dev, bdev->num_channels,
1000 sizeof(*bdev->channels), GFP_KERNEL);
1001
1002 if (!bdev->channels) {
1003 ret = -ENOMEM;
1004 goto err_disable_clk;
1005 }
1006
1007 /* allocate and initialize channels */
1008 INIT_LIST_HEAD(&bdev->common.channels);
1009
1010 for (i = 0; i < bdev->num_channels; i++)
1011 bam_channel_init(bdev, &bdev->channels[i], i);
1012
1013 ret = devm_request_irq(bdev->dev, bdev->irq, bam_dma_irq,
1014 IRQF_TRIGGER_HIGH, "bam_dma", bdev);
1015 if (ret)
1016 goto err_disable_clk;
1017
1018 /* set max dma segment size */
1019 bdev->common.dev = bdev->dev;
1020 bdev->common.dev->dma_parms = &bdev->dma_parms;
1021 ret = dma_set_max_seg_size(bdev->common.dev, BAM_MAX_DATA_SIZE);
1022 if (ret) {
1023 dev_err(bdev->dev, "cannot set maximum segment size\n");
1024 goto err_disable_clk;
1025 }
1026
1027 platform_set_drvdata(pdev, bdev);
1028
1029 /* set capabilities */
1030 dma_cap_zero(bdev->common.cap_mask);
1031 dma_cap_set(DMA_SLAVE, bdev->common.cap_mask);
1032
1033 /* initialize dmaengine apis */
1034 bdev->common.device_alloc_chan_resources = bam_alloc_chan;
1035 bdev->common.device_free_chan_resources = bam_free_chan;
1036 bdev->common.device_prep_slave_sg = bam_prep_slave_sg;
1037 bdev->common.device_control = bam_control;
1038 bdev->common.device_issue_pending = bam_issue_pending;
1039 bdev->common.device_tx_status = bam_tx_status;
1040 bdev->common.dev = bdev->dev;
1041
1042 ret = dma_async_device_register(&bdev->common);
1043 if (ret) {
1044 dev_err(bdev->dev, "failed to register dma async device\n");
1045 goto err_disable_clk;
1046 }
1047
1048 ret = of_dma_controller_register(pdev->dev.of_node, bam_dma_xlate,
1049 &bdev->common);
1050 if (ret)
1051 goto err_unregister_dma;
1052
1053 return 0;
1054
1055err_unregister_dma:
1056 dma_async_device_unregister(&bdev->common);
1057err_disable_clk:
1058 clk_disable_unprepare(bdev->bamclk);
1059 return ret;
1060}
1061
1062static int bam_dma_remove(struct platform_device *pdev)
1063{
1064 struct bam_device *bdev = platform_get_drvdata(pdev);
1065 u32 i;
1066
1067 of_dma_controller_free(pdev->dev.of_node);
1068 dma_async_device_unregister(&bdev->common);
1069
1070 /* mask all interrupts for this execution environment */
1071 writel_relaxed(0, bdev->regs + BAM_IRQ_SRCS_MSK_EE(bdev->ee));
1072
1073 devm_free_irq(bdev->dev, bdev->irq, bdev);
1074
1075 for (i = 0; i < bdev->num_channels; i++) {
1076 bam_dma_terminate_all(&bdev->channels[i]);
1077 tasklet_kill(&bdev->channels[i].vc.task);
1078
1079 dma_free_writecombine(bdev->dev, BAM_DESC_FIFO_SIZE,
1080 bdev->channels[i].fifo_virt,
1081 bdev->channels[i].fifo_phys);
1082 }
1083
1084 tasklet_kill(&bdev->task);
1085
1086 clk_disable_unprepare(bdev->bamclk);
1087
1088 return 0;
1089}
1090
1091static const struct of_device_id bam_of_match[] = {
1092 { .compatible = "qcom,bam-v1.4.0", },
1093 {}
1094};
1095MODULE_DEVICE_TABLE(of, bam_of_match);
1096
1097static struct platform_driver bam_dma_driver = {
1098 .probe = bam_dma_probe,
1099 .remove = bam_dma_remove,
1100 .driver = {
1101 .name = "bam-dma-engine",
1102 .owner = THIS_MODULE,
1103 .of_match_table = bam_of_match,
1104 },
1105};
1106
1107module_platform_driver(bam_dma_driver);
1108
1109MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
1110MODULE_DESCRIPTION("QCOM BAM DMA engine driver");
1111MODULE_LICENSE("GPL v2");
diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
index 4eddedb6eb7d..b209a0f17344 100644
--- a/drivers/dma/s3c24xx-dma.c
+++ b/drivers/dma/s3c24xx-dma.c
@@ -192,7 +192,7 @@ struct s3c24xx_dma_phy {
192 unsigned int id; 192 unsigned int id;
193 bool valid; 193 bool valid;
194 void __iomem *base; 194 void __iomem *base;
195 unsigned int irq; 195 int irq;
196 struct clk *clk; 196 struct clk *clk;
197 spinlock_t lock; 197 spinlock_t lock;
198 struct s3c24xx_dma_chan *serving; 198 struct s3c24xx_dma_chan *serving;
diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
index dadd9e010c0b..b4c813831006 100644
--- a/drivers/dma/sh/Kconfig
+++ b/drivers/dma/sh/Kconfig
@@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
29 help 29 help
30 Enable support for the Renesas R-Car series DMA controllers. 30 Enable support for the Renesas R-Car series DMA controllers.
31 31
32config RCAR_AUDMAC_PP
33 tristate "Renesas R-Car Audio DMAC Peripheral Peripheral support"
34 depends on SH_DMAE_BASE
35 help
36 Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral controllers.
37
32config SHDMA_R8A73A4 38config SHDMA_R8A73A4
33 def_bool y 39 def_bool y
34 depends on ARCH_R8A73A4 && SH_DMAE != n 40 depends on ARCH_R8A73A4 && SH_DMAE != n
diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
index e856af23b789..1ce88b28cfc6 100644
--- a/drivers/dma/sh/Makefile
+++ b/drivers/dma/sh/Makefile
@@ -7,3 +7,4 @@ endif
7shdma-objs := $(shdma-y) 7shdma-objs := $(shdma-y)
8obj-$(CONFIG_SUDMAC) += sudmac.o 8obj-$(CONFIG_SUDMAC) += sudmac.o
9obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o 9obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
10obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644
index 000000000000..2de77289a2e9
--- /dev/null
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -0,0 +1,320 @@
1/*
2 * This is for Renesas R-Car Audio-DMAC-peri-peri.
3 *
4 * Copyright (C) 2014 Renesas Electronics Corporation
5 * Copyright (C) 2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * based on the drivers/dma/sh/shdma.c
8 *
9 * Copyright (C) 2011-2012 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
10 * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
11 * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
12 * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
13 *
14 * This 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 */
20#include <linux/delay.h>
21#include <linux/init.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/dmaengine.h>
25#include <linux/platform_data/dma-rcar-audmapp.h>
26#include <linux/platform_device.h>
27#include <linux/shdma-base.h>
28
29/*
30 * DMA register
31 */
32#define PDMASAR 0x00
33#define PDMADAR 0x04
34#define PDMACHCR 0x0c
35
36/* PDMACHCR */
37#define PDMACHCR_DE (1 << 0)
38
39#define AUDMAPP_MAX_CHANNELS 29
40
41/* Default MEMCPY transfer size = 2^2 = 4 bytes */
42#define LOG2_DEFAULT_XFER_SIZE 2
43#define AUDMAPP_SLAVE_NUMBER 256
44#define AUDMAPP_LEN_MAX (16 * 1024 * 1024)
45
46struct audmapp_chan {
47 struct shdma_chan shdma_chan;
48 struct audmapp_slave_config *config;
49 void __iomem *base;
50};
51
52struct audmapp_device {
53 struct shdma_dev shdma_dev;
54 struct audmapp_pdata *pdata;
55 struct device *dev;
56 void __iomem *chan_reg;
57};
58
59#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
60#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device, \
61 struct audmapp_device, shdma_dev.dma_dev)
62
63static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
64{
65 struct audmapp_device *audev = to_dev(auchan);
66 struct device *dev = audev->dev;
67
68 dev_dbg(dev, "w %p : %08x\n", auchan->base + reg, data);
69
70 iowrite32(data, auchan->base + reg);
71}
72
73static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
74{
75 return ioread32(auchan->base + reg);
76}
77
78static void audmapp_halt(struct shdma_chan *schan)
79{
80 struct audmapp_chan *auchan = to_chan(schan);
81 int i;
82
83 audmapp_write(auchan, 0, PDMACHCR);
84
85 for (i = 0; i < 1024; i++) {
86 if (0 == audmapp_read(auchan, PDMACHCR))
87 return;
88 udelay(1);
89 }
90}
91
92static void audmapp_start_xfer(struct shdma_chan *schan,
93 struct shdma_desc *sdecs)
94{
95 struct audmapp_chan *auchan = to_chan(schan);
96 struct audmapp_device *audev = to_dev(auchan);
97 struct audmapp_slave_config *cfg = auchan->config;
98 struct device *dev = audev->dev;
99 u32 chcr = cfg->chcr | PDMACHCR_DE;
100
101 dev_dbg(dev, "src/dst/chcr = %pad/%pad/%x\n",
102 &cfg->src, &cfg->dst, cfg->chcr);
103
104 audmapp_write(auchan, cfg->src, PDMASAR);
105 audmapp_write(auchan, cfg->dst, PDMADAR);
106 audmapp_write(auchan, chcr, PDMACHCR);
107}
108
109static struct audmapp_slave_config *
110audmapp_find_slave(struct audmapp_chan *auchan, int slave_id)
111{
112 struct audmapp_device *audev = to_dev(auchan);
113 struct audmapp_pdata *pdata = audev->pdata;
114 struct audmapp_slave_config *cfg;
115 int i;
116
117 if (slave_id >= AUDMAPP_SLAVE_NUMBER)
118 return NULL;
119
120 for (i = 0, cfg = pdata->slave; i < pdata->slave_num; i++, cfg++)
121 if (cfg->slave_id == slave_id)
122 return cfg;
123
124 return NULL;
125}
126
127static int audmapp_set_slave(struct shdma_chan *schan, int slave_id,
128 dma_addr_t slave_addr, bool try)
129{
130 struct audmapp_chan *auchan = to_chan(schan);
131 struct audmapp_slave_config *cfg =
132 audmapp_find_slave(auchan, slave_id);
133
134 if (!cfg)
135 return -ENODEV;
136 if (try)
137 return 0;
138
139 auchan->config = cfg;
140
141 return 0;
142}
143
144static int audmapp_desc_setup(struct shdma_chan *schan,
145 struct shdma_desc *sdecs,
146 dma_addr_t src, dma_addr_t dst, size_t *len)
147{
148 struct audmapp_chan *auchan = to_chan(schan);
149 struct audmapp_slave_config *cfg = auchan->config;
150
151 if (!cfg)
152 return -ENODEV;
153
154 if (*len > (size_t)AUDMAPP_LEN_MAX)
155 *len = (size_t)AUDMAPP_LEN_MAX;
156
157 return 0;
158}
159
160static void audmapp_setup_xfer(struct shdma_chan *schan,
161 int slave_id)
162{
163}
164
165static dma_addr_t audmapp_slave_addr(struct shdma_chan *schan)
166{
167 return 0; /* always fixed address */
168}
169
170static bool audmapp_channel_busy(struct shdma_chan *schan)
171{
172 struct audmapp_chan *auchan = to_chan(schan);
173 u32 chcr = audmapp_read(auchan, PDMACHCR);
174
175 return chcr & ~PDMACHCR_DE;
176}
177
178static bool audmapp_desc_completed(struct shdma_chan *schan,
179 struct shdma_desc *sdesc)
180{
181 return true;
182}
183
184static struct shdma_desc *audmapp_embedded_desc(void *buf, int i)
185{
186 return &((struct shdma_desc *)buf)[i];
187}
188
189static const struct shdma_ops audmapp_shdma_ops = {
190 .halt_channel = audmapp_halt,
191 .desc_setup = audmapp_desc_setup,
192 .set_slave = audmapp_set_slave,
193 .start_xfer = audmapp_start_xfer,
194 .embedded_desc = audmapp_embedded_desc,
195 .setup_xfer = audmapp_setup_xfer,
196 .slave_addr = audmapp_slave_addr,
197 .channel_busy = audmapp_channel_busy,
198 .desc_completed = audmapp_desc_completed,
199};
200
201static int audmapp_chan_probe(struct platform_device *pdev,
202 struct audmapp_device *audev, int id)
203{
204 struct shdma_dev *sdev = &audev->shdma_dev;
205 struct audmapp_chan *auchan;
206 struct shdma_chan *schan;
207 struct device *dev = audev->dev;
208
209 auchan = devm_kzalloc(dev, sizeof(*auchan), GFP_KERNEL);
210 if (!auchan)
211 return -ENOMEM;
212
213 schan = &auchan->shdma_chan;
214 schan->max_xfer_len = AUDMAPP_LEN_MAX;
215
216 shdma_chan_probe(sdev, schan, id);
217
218 auchan->base = audev->chan_reg + 0x20 + (0x10 * id);
219 dev_dbg(dev, "%02d : %p / %p", id, auchan->base, audev->chan_reg);
220
221 return 0;
222}
223
224static void audmapp_chan_remove(struct audmapp_device *audev)
225{
226 struct dma_device *dma_dev = &audev->shdma_dev.dma_dev;
227 struct shdma_chan *schan;
228 int i;
229
230 shdma_for_each_chan(schan, &audev->shdma_dev, i) {
231 BUG_ON(!schan);
232 shdma_chan_remove(schan);
233 }
234 dma_dev->chancnt = 0;
235}
236
237static int audmapp_probe(struct platform_device *pdev)
238{
239 struct audmapp_pdata *pdata = pdev->dev.platform_data;
240 struct audmapp_device *audev;
241 struct shdma_dev *sdev;
242 struct dma_device *dma_dev;
243 struct resource *res;
244 int err, i;
245
246 if (!pdata)
247 return -ENODEV;
248
249 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
250
251 audev = devm_kzalloc(&pdev->dev, sizeof(*audev), GFP_KERNEL);
252 if (!audev)
253 return -ENOMEM;
254
255 audev->dev = &pdev->dev;
256 audev->pdata = pdata;
257 audev->chan_reg = devm_ioremap_resource(&pdev->dev, res);
258 if (IS_ERR(audev->chan_reg))
259 return PTR_ERR(audev->chan_reg);
260
261 sdev = &audev->shdma_dev;
262 sdev->ops = &audmapp_shdma_ops;
263 sdev->desc_size = sizeof(struct shdma_desc);
264
265 dma_dev = &sdev->dma_dev;
266 dma_dev->copy_align = LOG2_DEFAULT_XFER_SIZE;
267 dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
268
269 err = shdma_init(&pdev->dev, sdev, AUDMAPP_MAX_CHANNELS);
270 if (err < 0)
271 return err;
272
273 platform_set_drvdata(pdev, audev);
274
275 /* Create DMA Channel */
276 for (i = 0; i < AUDMAPP_MAX_CHANNELS; i++) {
277 err = audmapp_chan_probe(pdev, audev, i);
278 if (err)
279 goto chan_probe_err;
280 }
281
282 err = dma_async_device_register(dma_dev);
283 if (err < 0)
284 goto chan_probe_err;
285
286 return err;
287
288chan_probe_err:
289 audmapp_chan_remove(audev);
290 shdma_cleanup(sdev);
291
292 return err;
293}
294
295static int audmapp_remove(struct platform_device *pdev)
296{
297 struct audmapp_device *audev = platform_get_drvdata(pdev);
298 struct dma_device *dma_dev = &audev->shdma_dev.dma_dev;
299
300 dma_async_device_unregister(dma_dev);
301
302 audmapp_chan_remove(audev);
303 shdma_cleanup(&audev->shdma_dev);
304
305 return 0;
306}
307
308static struct platform_driver audmapp_driver = {
309 .probe = audmapp_probe,
310 .remove = audmapp_remove,
311 .driver = {
312 .owner = THIS_MODULE,
313 .name = "rcar-audmapp-engine",
314 },
315};
316module_platform_driver(audmapp_driver);
317
318MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
319MODULE_DESCRIPTION("Renesas R-Car Audio DMAC peri-peri driver");
320MODULE_LICENSE("GPL");
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 2e7b394def80..52396771acbe 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg)
227 struct shdma_chan *schan = to_shdma_chan(chan); 227 struct shdma_chan *schan = to_shdma_chan(chan);
228 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); 228 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
229 const struct shdma_ops *ops = sdev->ops; 229 const struct shdma_ops *ops = sdev->ops;
230 int match = (int)arg; 230 int match = (long)arg;
231 int ret; 231 int ret;
232 232
233 if (match < 0) 233 if (match < 0)
@@ -491,8 +491,8 @@ static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan,
491 } 491 }
492 492
493 dev_dbg(schan->dev, 493 dev_dbg(schan->dev,
494 "chaining (%u/%u)@%x -> %x with %p, cookie %d\n", 494 "chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
495 copy_size, *len, *src, *dst, &new->async_tx, 495 copy_size, *len, src, dst, &new->async_tx,
496 new->async_tx.cookie); 496 new->async_tx.cookie);
497 497
498 new->mark = DESC_PREPARED; 498 new->mark = DESC_PREPARED;
@@ -555,8 +555,8 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
555 goto err_get_desc; 555 goto err_get_desc;
556 556
557 do { 557 do {
558 dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n", 558 dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %pad\n",
559 i, sg, len, (unsigned long long)sg_addr); 559 i, sg, len, &sg_addr);
560 560
561 if (direction == DMA_DEV_TO_MEM) 561 if (direction == DMA_DEV_TO_MEM)
562 new = shdma_add_desc(schan, flags, 562 new = shdma_add_desc(schan, flags,
diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
index 06473a05fe4e..b4ff9d3e56d1 100644
--- a/drivers/dma/sh/shdma-of.c
+++ b/drivers/dma/sh/shdma-of.c
@@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
33 /* Only slave DMA channels can be allocated via DT */ 33 /* Only slave DMA channels can be allocated via DT */
34 dma_cap_set(DMA_SLAVE, mask); 34 dma_cap_set(DMA_SLAVE, mask);
35 35
36 chan = dma_request_channel(mask, shdma_chan_filter, (void *)id); 36 chan = dma_request_channel(mask, shdma_chan_filter,
37 (void *)(uintptr_t)id);
37 if (chan) 38 if (chan)
38 to_shdma_chan(chan)->hw_req = id; 39 to_shdma_chan(chan)->hw_req = id;
39 40
diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
index 0d765c0e21ec..dda7e7563f5d 100644
--- a/drivers/dma/sh/shdmac.c
+++ b/drivers/dma/sh/shdmac.c
@@ -443,6 +443,7 @@ static bool sh_dmae_reset(struct sh_dmae_device *shdev)
443 return ret; 443 return ret;
444} 444}
445 445
446#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARM)
446static irqreturn_t sh_dmae_err(int irq, void *data) 447static irqreturn_t sh_dmae_err(int irq, void *data)
447{ 448{
448 struct sh_dmae_device *shdev = data; 449 struct sh_dmae_device *shdev = data;
@@ -453,6 +454,7 @@ static irqreturn_t sh_dmae_err(int irq, void *data)
453 sh_dmae_reset(shdev); 454 sh_dmae_reset(shdev);
454 return IRQ_HANDLED; 455 return IRQ_HANDLED;
455} 456}
457#endif
456 458
457static bool sh_dmae_desc_completed(struct shdma_chan *schan, 459static bool sh_dmae_desc_completed(struct shdma_chan *schan,
458 struct shdma_desc *sdesc) 460 struct shdma_desc *sdesc)
@@ -637,7 +639,7 @@ static int sh_dmae_resume(struct device *dev)
637#define sh_dmae_resume NULL 639#define sh_dmae_resume NULL
638#endif 640#endif
639 641
640const struct dev_pm_ops sh_dmae_pm = { 642static const struct dev_pm_ops sh_dmae_pm = {
641 .suspend = sh_dmae_suspend, 643 .suspend = sh_dmae_suspend,
642 .resume = sh_dmae_resume, 644 .resume = sh_dmae_resume,
643 .runtime_suspend = sh_dmae_runtime_suspend, 645 .runtime_suspend = sh_dmae_runtime_suspend,
@@ -685,9 +687,12 @@ MODULE_DEVICE_TABLE(of, sh_dmae_of_match);
685static int sh_dmae_probe(struct platform_device *pdev) 687static int sh_dmae_probe(struct platform_device *pdev)
686{ 688{
687 const struct sh_dmae_pdata *pdata; 689 const struct sh_dmae_pdata *pdata;
688 unsigned long irqflags = 0, 690 unsigned long chan_flag[SH_DMAE_MAX_CHANNELS] = {};
689 chan_flag[SH_DMAE_MAX_CHANNELS] = {}; 691 int chan_irq[SH_DMAE_MAX_CHANNELS];
690 int errirq, chan_irq[SH_DMAE_MAX_CHANNELS]; 692#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARM)
693 unsigned long irqflags = 0;
694 int errirq;
695#endif
691 int err, i, irq_cnt = 0, irqres = 0, irq_cap = 0; 696 int err, i, irq_cnt = 0, irqres = 0, irq_cap = 0;
692 struct sh_dmae_device *shdev; 697 struct sh_dmae_device *shdev;
693 struct dma_device *dma_dev; 698 struct dma_device *dma_dev;
diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
index c7e9cdff0708..4e7df43b50d6 100644
--- a/drivers/dma/sh/sudmac.c
+++ b/drivers/dma/sh/sudmac.c
@@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan,
178 struct sudmac_chan *sc = to_chan(schan); 178 struct sudmac_chan *sc = to_chan(schan);
179 struct sudmac_desc *sd = to_desc(sdesc); 179 struct sudmac_desc *sd = to_desc(sdesc);
180 180
181 dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n", 181 dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
182 __func__, src, dst, *len); 182 __func__, &src, &dst, *len);
183 183
184 if (*len > schan->max_xfer_len) 184 if (*len > schan->max_xfer_len)
185 *len = schan->max_xfer_len; 185 *len = schan->max_xfer_len;
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index d4d3a3109b16..a1bd8298d55f 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -18,6 +18,7 @@
18#include <linux/of_device.h> 18#include <linux/of_device.h>
19#include <linux/of_platform.h> 19#include <linux/of_platform.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/of_dma.h>
21#include <linux/sirfsoc_dma.h> 22#include <linux/sirfsoc_dma.h>
22 23
23#include "dmaengine.h" 24#include "dmaengine.h"
@@ -659,6 +660,18 @@ static int sirfsoc_dma_device_slave_caps(struct dma_chan *dchan,
659 return 0; 660 return 0;
660} 661}
661 662
663static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec,
664 struct of_dma *ofdma)
665{
666 struct sirfsoc_dma *sdma = ofdma->of_dma_data;
667 unsigned int request = dma_spec->args[0];
668
669 if (request > SIRFSOC_DMA_CHANNELS)
670 return NULL;
671
672 return dma_get_slave_channel(&sdma->channels[request].chan);
673}
674
662static int sirfsoc_dma_probe(struct platform_device *op) 675static int sirfsoc_dma_probe(struct platform_device *op)
663{ 676{
664 struct device_node *dn = op->dev.of_node; 677 struct device_node *dn = op->dev.of_node;
@@ -764,11 +777,20 @@ static int sirfsoc_dma_probe(struct platform_device *op)
764 if (ret) 777 if (ret)
765 goto free_irq; 778 goto free_irq;
766 779
780 /* Device-tree DMA controller registration */
781 ret = of_dma_controller_register(dn, of_dma_sirfsoc_xlate, sdma);
782 if (ret) {
783 dev_err(dev, "failed to register DMA controller\n");
784 goto unreg_dma_dev;
785 }
786
767 pm_runtime_enable(&op->dev); 787 pm_runtime_enable(&op->dev);
768 dev_info(dev, "initialized SIRFSOC DMAC driver\n"); 788 dev_info(dev, "initialized SIRFSOC DMAC driver\n");
769 789
770 return 0; 790 return 0;
771 791
792unreg_dma_dev:
793 dma_async_device_unregister(dma);
772free_irq: 794free_irq:
773 free_irq(sdma->irq, sdma); 795 free_irq(sdma->irq, sdma);
774irq_dispose: 796irq_dispose:
@@ -781,6 +803,7 @@ static int sirfsoc_dma_remove(struct platform_device *op)
781 struct device *dev = &op->dev; 803 struct device *dev = &op->dev;
782 struct sirfsoc_dma *sdma = dev_get_drvdata(dev); 804 struct sirfsoc_dma *sdma = dev_get_drvdata(dev);
783 805
806 of_dma_controller_free(op->dev.of_node);
784 dma_async_device_unregister(&sdma->dma); 807 dma_async_device_unregister(&sdma->dma);
785 free_irq(sdma->irq, sdma); 808 free_irq(sdma->irq, sdma);
786 irq_dispose_mapping(sdma->irq); 809 irq_dispose_mapping(sdma->irq);
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c
index ff50aeebf0d9..2c41eaece2c1 100644
--- a/drivers/firmware/efi/efi-stub-helper.c
+++ b/drivers/firmware/efi/efi-stub-helper.c
@@ -397,7 +397,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
397 else 397 else
398 chunksize = size; 398 chunksize = size;
399 399
400 status = efi_file_read(fh, files[j].handle, 400 status = efi_file_read(files[j].handle,
401 &chunksize, 401 &chunksize,
402 (void *)addr); 402 (void *)addr);
403 if (status != EFI_SUCCESS) { 403 if (status != EFI_SUCCESS) {
@@ -408,7 +408,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
408 size -= chunksize; 408 size -= chunksize;
409 } 409 }
410 410
411 efi_file_close(fh, files[j].handle); 411 efi_file_close(files[j].handle);
412 } 412 }
413 413
414 } 414 }
@@ -425,7 +425,7 @@ free_file_total:
425 425
426close_handles: 426close_handles:
427 for (k = j; k < i; k++) 427 for (k = j; k < i; k++)
428 efi_file_close(fh, files[k].handle); 428 efi_file_close(files[k].handle);
429free_files: 429free_files:
430 efi_call_early(free_pool, files); 430 efi_call_early(free_pool, files);
431fail: 431fail:
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index b13172cfbeef..bc196f49ec53 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -554,14 +554,6 @@ config SENSORS_IBMPEX
554 This driver can also be built as a module. If so, the module 554 This driver can also be built as a module. If so, the module
555 will be called ibmpex. 555 will be called ibmpex.
556 556
557config SENSORS_IBMPOWERNV
558 tristate "IBM PowerNv Platform temperature/power/fan sensor"
559 depends on PPC_POWERNV
560 default y
561 help
562 If you say yes here you get support for the temperature/fan/power
563 sensors on your platform.
564
565config SENSORS_IIO_HWMON 557config SENSORS_IIO_HWMON
566 tristate "Hwmon driver that uses channels specified via iio maps" 558 tristate "Hwmon driver that uses channels specified via iio maps"
567 depends on IIO 559 depends on IIO
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 199c401bf8d9..c48f9873ac73 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -71,7 +71,6 @@ obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
71obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o 71obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
72obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o 72obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o
73obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o 73obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o
74obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o
75obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o 74obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o
76obj-$(CONFIG_SENSORS_INA209) += ina209.o 75obj-$(CONFIG_SENSORS_INA209) += ina209.o
77obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o 76obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
deleted file mode 100644
index b7b1297a9b02..000000000000
--- a/drivers/hwmon/ibmpowernv.c
+++ /dev/null
@@ -1,529 +0,0 @@
1/*
2 * hwmon driver for temperature/power/fan on IBM PowerNV platform
3 * Copyright (C) 2013 IBM
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/init.h>
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/hwmon.h>
24#include <linux/hwmon-sysfs.h>
25#include <linux/of.h>
26#include <linux/slab.h>
27
28#include <linux/jiffies.h>
29#include <linux/platform_device.h>
30#include <asm/opal.h>
31#include <linux/err.h>
32
33MODULE_DESCRIPTION("IBM PowerNV Platform power/temp/fan sensor hwmon module");
34MODULE_LICENSE("GPL");
35
36#define MAX_ATTR_LENGTH 32
37
38/* Device tree sensor name prefixes. The device tree has the names in the
39 * format "cooling-fan#2-faulted" where the "cooling-fan" is the sensor type,
40 * 2 is the sensor count, and "faulted" is the sensor data attribute type.
41 */
42#define DT_FAULT_ATTR_SUFFIX "faulted"
43#define DT_DATA_ATTR_SUFFIX "data"
44#define DT_THRESHOLD_ATTR_SUFFIX "thrs"
45
46enum sensors {
47 FAN,
48 TEMPERATURE,
49 POWERSUPPLY,
50 POWER,
51 MAX_SENSOR_TYPE,
52};
53
54enum attributes {
55 INPUT,
56 MINIMUM,
57 MAXIMUM,
58 FAULT,
59 MAX_ATTR_TYPES
60};
61
62static struct sensor_name {
63 char *name;
64 char *compaible;
65} sensor_names[] = {
66 {"fan-sensor", "ibm,opal-sensor-cooling-fan"},
67 {"amb-temp-sensor", "ibm,opal-sensor-amb-temp"},
68 {"power-sensor", "ibm,opal-sensor-power-supply"},
69 {"power", "ibm,opal-sensor-power"}
70};
71
72static const char * const attribute_type_table[] = {
73 "input",
74 "min",
75 "max",
76 "fault",
77 NULL
78};
79
80struct pdev_entry {
81 struct list_head list;
82 struct platform_device *pdev;
83 enum sensors type;
84};
85
86static LIST_HEAD(pdev_list);
87
88/* The sensors are categorised on type.
89 *
90 * The sensors of same type are categorised under a common platform device.
91 * So, The pdev is shared by all sensors of same type.
92 * Ex : temp1_input, temp1_max, temp2_input,temp2_max all share same platform
93 * device.
94 *
95 * "sensor_data" is the Platform device specific data.
96 * There is one hwmon_device instance for all the sensors of same type.
97 * This also holds the list of all sensors with same type but different
98 * attribute and index.
99 */
100struct sensor_specific_data {
101 u32 sensor_id; /* The hex value as in the device tree */
102 u32 sensor_index; /* The sensor instance index */
103 struct sensor_device_attribute sd_attr;
104 enum attributes attr_type;
105 char attr_name[64];
106};
107
108struct sensor_data {
109 struct device *hwmon_dev;
110 struct list_head sensor_list;
111 struct device_attribute name_attr;
112};
113
114struct sensor_entry {
115 struct list_head list;
116 struct sensor_specific_data *sensor_data;
117};
118
119static struct platform_device *powernv_sensor_get_pdev(enum sensors type)
120{
121 struct pdev_entry *p;
122 list_for_each_entry(p, &pdev_list, list)
123 if (p->type == type)
124 return p->pdev;
125
126 return NULL;
127}
128
129static struct sensor_specific_data *powernv_sensor_get_sensor_data(
130 struct sensor_data *pdata,
131 int index, enum attributes attr_type)
132{
133 struct sensor_entry *p;
134 list_for_each_entry(p, &pdata->sensor_list, list)
135 if ((p->sensor_data->sensor_index == index) &&
136 (attr_type == p->sensor_data->attr_type))
137 return p->sensor_data;
138
139 return NULL;
140}
141
142static ssize_t show_name(struct device *dev,
143 struct device_attribute *devattr, char *buf)
144{
145 struct platform_device *pdev = to_platform_device(dev);
146
147 return sprintf(buf, "%s\n", pdev->name);
148}
149
150/* Note: Data from the sensors for each sensor type needs to be converted to
151 * the dimension appropriate.
152 */
153static ssize_t show_sensor(struct device *dev,
154 struct device_attribute *devattr, char *buf)
155{
156 struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(devattr);
157 struct platform_device *pdev = to_platform_device(dev);
158 struct sensor_data *pdata = platform_get_drvdata(pdev);
159 struct sensor_specific_data *tdata = NULL;
160 enum sensors sensor_type = pdev->id;
161 u32 x = -1;
162 int ret;
163
164 if (sd_attr && sd_attr->dev_attr.attr.name) {
165 char *pos = strchr(sd_attr->dev_attr.attr.name, '_');
166 int i;
167
168 for (i = 0; i < MAX_ATTR_TYPES; i++) {
169 if (strcmp(pos+1, attribute_type_table[i]) == 0) {
170 tdata = powernv_sensor_get_sensor_data(pdata,
171 sd_attr->index, i);
172 break;
173 }
174 }
175 }
176
177 if (tdata) {
178 ret = opal_get_sensor_data(tdata->sensor_id, &x);
179 if (ret)
180 x = -1;
181 }
182
183 if (sensor_type == TEMPERATURE && x > 0) {
184 /* Temperature comes in Degrees and convert it to
185 * milli-degrees.
186 */
187 x = x*1000;
188 } else if (sensor_type == POWER && x > 0) {
189 /* Power value comes in watts, convert to micro-watts */
190 x = x * 1000000;
191 }
192
193 return sprintf(buf, "%d\n", x);
194}
195
196static u32 get_sensor_index_from_name(const char *name)
197{
198 char *hash_position = strchr(name, '#');
199 u32 index = 0, copy_length;
200 char newbuf[8];
201
202 if (hash_position) {
203 copy_length = strchr(hash_position, '-') - hash_position - 1;
204 if (copy_length < sizeof(newbuf)) {
205 strncpy(newbuf, hash_position + 1, copy_length);
206 sscanf(newbuf, "%d", &index);
207 }
208 }
209
210 return index;
211}
212
213static inline void get_sensor_suffix_from_name(const char *name, char *suffix)
214{
215 char *dash_position = strrchr(name, '-');
216 if (dash_position)
217 strncpy(suffix, dash_position+1, MAX_ATTR_LENGTH);
218 else
219 strcpy(suffix,"");
220}
221
222static int get_sensor_attr_properties(const char *sensor_name,
223 enum sensors sensor_type, enum attributes *attr_type,
224 u32 *sensor_index)
225{
226 char suffix[MAX_ATTR_LENGTH];
227
228 *attr_type = MAX_ATTR_TYPES;
229 *sensor_index = get_sensor_index_from_name(sensor_name);
230 if (*sensor_index == 0)
231 return -EINVAL;
232
233 get_sensor_suffix_from_name(sensor_name, suffix);
234 if (strcmp(suffix, "") == 0)
235 return -EINVAL;
236
237 if (strcmp(suffix, DT_FAULT_ATTR_SUFFIX) == 0)
238 *attr_type = FAULT;
239 else if (strcmp(suffix, DT_DATA_ATTR_SUFFIX) == 0)
240 *attr_type = INPUT;
241 else if ((sensor_type == TEMPERATURE) &&
242 (strcmp(suffix, DT_THRESHOLD_ATTR_SUFFIX) == 0))
243 *attr_type = MAXIMUM;
244 else if ((sensor_type == FAN) &&
245 (strcmp(suffix, DT_THRESHOLD_ATTR_SUFFIX) == 0))
246 *attr_type = MINIMUM;
247 else
248 return -ENOENT;
249
250 if (((sensor_type == FAN) && ((*attr_type == INPUT) ||
251 (*attr_type == MINIMUM)))
252 || ((sensor_type == TEMPERATURE) && ((*attr_type == INPUT) ||
253 (*attr_type == MAXIMUM)))
254 || ((sensor_type == POWER) && ((*attr_type == INPUT))))
255 return 0;
256
257 return -ENOENT;
258}
259
260static int create_sensor_attr(struct sensor_specific_data *tdata,
261 struct device *dev, enum sensors sensor_type,
262 enum attributes attr_type)
263{
264 int err = 0;
265 char temp_file_prefix[50];
266 static const char *const file_name_format = "%s%d_%s";
267
268 tdata->attr_type = attr_type;
269
270 if (sensor_type == FAN)
271 strcpy(temp_file_prefix, "fan");
272 else if (sensor_type == TEMPERATURE)
273 strcpy(temp_file_prefix, "temp");
274 else if (sensor_type == POWERSUPPLY)
275 strcpy(temp_file_prefix, "powersupply");
276 else if (sensor_type == POWER)
277 strcpy(temp_file_prefix, "power");
278
279 snprintf(tdata->attr_name, sizeof(tdata->attr_name), file_name_format,
280 temp_file_prefix, tdata->sensor_index,
281 attribute_type_table[tdata->attr_type]);
282
283 sysfs_attr_init(&tdata->sd_attr.dev_attr.attr);
284 tdata->sd_attr.dev_attr.attr.name = tdata->attr_name;
285 tdata->sd_attr.dev_attr.attr.mode = S_IRUGO;
286 tdata->sd_attr.dev_attr.show = show_sensor;
287
288 tdata->sd_attr.index = tdata->sensor_index;
289 err = device_create_file(dev, &tdata->sd_attr.dev_attr);
290
291 return err;
292}
293
294static int create_name_attr(struct sensor_data *pdata,
295 struct device *dev)
296{
297 sysfs_attr_init(&pdata->name_attr.attr);
298 pdata->name_attr.attr.name = "name";
299 pdata->name_attr.attr.mode = S_IRUGO;
300 pdata->name_attr.show = show_name;
301 return device_create_file(dev, &pdata->name_attr);
302}
303
304static int create_platform_device(enum sensors sensor_type,
305 struct platform_device **pdev)
306{
307 struct pdev_entry *pdev_entry = NULL;
308 int err;
309
310 *pdev = platform_device_alloc(sensor_names[sensor_type].name,
311 sensor_type);
312 if (!*pdev) {
313 pr_err("Device allocation failed\n");
314 err = -ENOMEM;
315 goto exit;
316 }
317
318 pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
319 if (!pdev_entry) {
320 pr_err("Device allocation failed\n");
321 err = -ENOMEM;
322 goto exit_device_put;
323 }
324
325 err = platform_device_add(*pdev);
326 if (err) {
327 pr_err("Device addition failed (%d)\n", err);
328 goto exit_device_free;
329 }
330
331 pdev_entry->pdev = *pdev;
332 pdev_entry->type = (*pdev)->id;
333
334 list_add_tail(&pdev_entry->list, &pdev_list);
335
336 return 0;
337exit_device_free:
338 kfree(pdev_entry);
339exit_device_put:
340 platform_device_put(*pdev);
341exit:
342 return err;
343}
344
345static int create_sensor_data(struct platform_device *pdev)
346{
347 struct sensor_data *pdata = NULL;
348 int err = 0;
349
350 pdata = kzalloc(sizeof(struct sensor_data), GFP_KERNEL);
351 if (!pdata) {
352 err = -ENOMEM;
353 goto exit;
354 }
355
356 err = create_name_attr(pdata, &pdev->dev);
357 if (err)
358 goto exit_free;
359
360 pdata->hwmon_dev = hwmon_device_register(&pdev->dev);
361 if (IS_ERR(pdata->hwmon_dev)) {
362 err = PTR_ERR(pdata->hwmon_dev);
363 dev_err(&pdev->dev, "Class registration failed (%d)\n",
364 err);
365 goto exit_name;
366 }
367
368 INIT_LIST_HEAD(&pdata->sensor_list);
369 platform_set_drvdata(pdev, pdata);
370
371 return 0;
372
373exit_name:
374 device_remove_file(&pdev->dev, &pdata->name_attr);
375exit_free:
376 kfree(pdata);
377exit:
378 return err;
379}
380
381static void delete_sensor_attr(struct sensor_data *pdata)
382{
383 struct sensor_entry *s, *l;
384
385 list_for_each_entry_safe(s, l, &pdata->sensor_list, list) {
386 struct sensor_specific_data *tdata = s->sensor_data;
387 kfree(tdata);
388 list_del(&s->list);
389 kfree(s);
390 }
391}
392
393static int powernv_sensor_init(u32 sensor_id, const struct device_node *np,
394 enum sensors sensor_type, enum attributes attr_type,
395 u32 sensor_index)
396{
397 struct platform_device *pdev = powernv_sensor_get_pdev(sensor_type);
398 struct sensor_specific_data *tdata;
399 struct sensor_entry *sensor_entry;
400 struct sensor_data *pdata;
401 int err = 0;
402
403 if (!pdev) {
404 err = create_platform_device(sensor_type, &pdev);
405 if (err)
406 goto exit;
407
408 err = create_sensor_data(pdev);
409 if (err)
410 goto exit;
411 }
412
413 pdata = platform_get_drvdata(pdev);
414 if (!pdata) {
415 err = -ENOMEM;
416 goto exit;
417 }
418
419 tdata = kzalloc(sizeof(struct sensor_specific_data), GFP_KERNEL);
420 if (!tdata) {
421 err = -ENOMEM;
422 goto exit;
423 }
424
425 tdata->sensor_id = sensor_id;
426 tdata->sensor_index = sensor_index;
427
428 err = create_sensor_attr(tdata, &pdev->dev, sensor_type, attr_type);
429 if (err)
430 goto exit_free;
431
432 sensor_entry = kzalloc(sizeof(struct sensor_entry), GFP_KERNEL);
433 if (!sensor_entry) {
434 err = -ENOMEM;
435 goto exit_attr;
436 }
437
438 sensor_entry->sensor_data = tdata;
439
440 list_add_tail(&sensor_entry->list, &pdata->sensor_list);
441
442 return 0;
443exit_attr:
444 device_remove_file(&pdev->dev, &tdata->sd_attr.dev_attr);
445exit_free:
446 kfree(tdata);
447exit:
448 return err;
449}
450
451static void delete_unregister_sensors(void)
452{
453 struct pdev_entry *p, *n;
454
455 list_for_each_entry_safe(p, n, &pdev_list, list) {
456 struct sensor_data *pdata = platform_get_drvdata(p->pdev);
457 if (pdata) {
458 delete_sensor_attr(pdata);
459
460 hwmon_device_unregister(pdata->hwmon_dev);
461 kfree(pdata);
462 }
463 platform_device_unregister(p->pdev);
464 list_del(&p->list);
465 kfree(p);
466 }
467}
468
469static int __init powernv_hwmon_init(void)
470{
471 struct device_node *opal, *np = NULL;
472 enum attributes attr_type;
473 enum sensors type;
474 const u32 *sensor_id;
475 u32 sensor_index;
476 int err;
477
478 opal = of_find_node_by_path("/ibm,opal/sensors");
479 if (!opal) {
480 pr_err("%s: Opal 'sensors' node not found\n", __func__);
481 return -ENXIO;
482 }
483
484 for_each_child_of_node(opal, np) {
485 if (np->name == NULL)
486 continue;
487
488 for (type = 0; type < MAX_SENSOR_TYPE; type++)
489 if (of_device_is_compatible(np,
490 sensor_names[type].compaible))
491 break;
492
493 if (type == MAX_SENSOR_TYPE)
494 continue;
495
496 if (get_sensor_attr_properties(np->name, type, &attr_type,
497 &sensor_index))
498 continue;
499
500 sensor_id = of_get_property(np, "sensor-id", NULL);
501 if (!sensor_id) {
502 pr_info("%s: %s doesn't have sensor-id\n", __func__,
503 np->name);
504 continue;
505 }
506
507 err = powernv_sensor_init(*sensor_id, np, type, attr_type,
508 sensor_index);
509 if (err) {
510 of_node_put(opal);
511 goto exit;
512 }
513 }
514 of_node_put(opal);
515
516 return 0;
517exit:
518 delete_unregister_sensors();
519 return err;
520
521}
522
523static void powernv_hwmon_exit(void)
524{
525 delete_unregister_sensors();
526}
527
528module_init(powernv_hwmon_init);
529module_exit(powernv_hwmon_exit);
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 014afab1d551..c94db1c5e353 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -110,6 +110,7 @@ config I2C_I801
110 Wellsburg (PCH) 110 Wellsburg (PCH)
111 Coleto Creek (PCH) 111 Coleto Creek (PCH)
112 Wildcat Point-LP (PCH) 112 Wildcat Point-LP (PCH)
113 BayTrail (SOC)
113 114
114 This driver can also be built as a module. If so, the module 115 This driver can also be built as a module. If so, the module
115 will be called i2c-i801. 116 will be called i2c-i801.
@@ -375,6 +376,13 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
375 help 376 help
376 The unit of the TWI clock is kHz. 377 The unit of the TWI clock is kHz.
377 378
379config I2C_CADENCE
380 tristate "Cadence I2C Controller"
381 depends on ARCH_ZYNQ
382 help
383 Say yes here to select Cadence I2C Host Controller. This controller is
384 e.g. used by Xilinx Zynq.
385
378config I2C_CBUS_GPIO 386config I2C_CBUS_GPIO
379 tristate "CBUS I2C driver" 387 tristate "CBUS I2C driver"
380 depends on GPIOLIB 388 depends on GPIOLIB
@@ -432,6 +440,13 @@ config I2C_DESIGNWARE_PCI
432 This driver can also be built as a module. If so, the module 440 This driver can also be built as a module. If so, the module
433 will be called i2c-designware-pci. 441 will be called i2c-designware-pci.
434 442
443config I2C_EFM32
444 tristate "EFM32 I2C controller"
445 depends on ARCH_EFM32 || COMPILE_TEST
446 help
447 This driver supports the i2c block found in Energy Micro's EFM32
448 SoCs.
449
435config I2C_EG20T 450config I2C_EG20T
436 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C" 451 tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C"
437 depends on PCI 452 depends on PCI
@@ -527,7 +542,7 @@ config I2C_MPC
527 542
528config I2C_MV64XXX 543config I2C_MV64XXX
529 tristate "Marvell mv64xxx I2C Controller" 544 tristate "Marvell mv64xxx I2C Controller"
530 depends on (MV64X60 || PLAT_ORION || ARCH_SUNXI) 545 depends on MV64X60 || PLAT_ORION || ARCH_SUNXI
531 help 546 help
532 If you say yes to this option, support will be included for the 547 If you say yes to this option, support will be included for the
533 built-in I2C interface on the Marvell 64xxx line of host bridges. 548 built-in I2C interface on the Marvell 64xxx line of host bridges.
@@ -648,6 +663,16 @@ config I2C_PXA_SLAVE
648 is necessary for systems where the PXA may be a target on the 663 is necessary for systems where the PXA may be a target on the
649 I2C bus. 664 I2C bus.
650 665
666config I2C_QUP
667 tristate "Qualcomm QUP based I2C controller"
668 depends on ARCH_QCOM
669 help
670 If you say yes to this option, support will be included for the
671 built-in I2C interface on the Qualcomm SoCs.
672
673 This driver can also be built as a module. If so, the module
674 will be called i2c-qup.
675
651config I2C_RIIC 676config I2C_RIIC
652 tristate "Renesas RIIC adapter" 677 tristate "Renesas RIIC adapter"
653 depends on ARCH_SHMOBILE || COMPILE_TEST 678 depends on ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index a08931fe73e1..18d18ff9db93 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_I2C_AT91) += i2c-at91.o
33obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o 33obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
34obj-$(CONFIG_I2C_BCM2835) += i2c-bcm2835.o 34obj-$(CONFIG_I2C_BCM2835) += i2c-bcm2835.o
35obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o 35obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
36obj-$(CONFIG_I2C_CADENCE) += i2c-cadence.o
36obj-$(CONFIG_I2C_CBUS_GPIO) += i2c-cbus-gpio.o 37obj-$(CONFIG_I2C_CBUS_GPIO) += i2c-cbus-gpio.o
37obj-$(CONFIG_I2C_CPM) += i2c-cpm.o 38obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
38obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o 39obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
@@ -41,6 +42,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
41i2c-designware-platform-objs := i2c-designware-platdrv.o 42i2c-designware-platform-objs := i2c-designware-platdrv.o
42obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o 43obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
43i2c-designware-pci-objs := i2c-designware-pcidrv.o 44i2c-designware-pci-objs := i2c-designware-pcidrv.o
45obj-$(CONFIG_I2C_EFM32) += i2c-efm32.o
44obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o 46obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
45obj-$(CONFIG_I2C_EXYNOS5) += i2c-exynos5.o 47obj-$(CONFIG_I2C_EXYNOS5) += i2c-exynos5.o
46obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o 48obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
@@ -63,6 +65,7 @@ obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
63obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o 65obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o
64obj-$(CONFIG_I2C_PXA) += i2c-pxa.o 66obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
65obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o 67obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o
68obj-$(CONFIG_I2C_QUP) += i2c-qup.o
66obj-$(CONFIG_I2C_RIIC) += i2c-riic.o 69obj-$(CONFIG_I2C_RIIC) += i2c-riic.o
67obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o 70obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
68obj-$(CONFIG_I2C_S6000) += i2c-s6000.o 71obj-$(CONFIG_I2C_S6000) += i2c-s6000.o
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 7d60d3a1f621..451e305f7971 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -494,7 +494,7 @@ static struct i2c_adapter ali1535_adapter = {
494 .algo = &smbus_algorithm, 494 .algo = &smbus_algorithm,
495}; 495};
496 496
497static DEFINE_PCI_DEVICE_TABLE(ali1535_ids) = { 497static const struct pci_device_id ali1535_ids[] = {
498 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, 498 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
499 { }, 499 { },
500}; 500};
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 4611e4754a67..98a1c97739ba 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -416,7 +416,7 @@ static void ali1563_remove(struct pci_dev *dev)
416 ali1563_shutdown(dev); 416 ali1563_shutdown(dev);
417} 417}
418 418
419static DEFINE_PCI_DEVICE_TABLE(ali1563_id_table) = { 419static const struct pci_device_id ali1563_id_table[] = {
420 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1563) }, 420 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1563) },
421 {}, 421 {},
422}; 422};
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 4823206a4870..2fa21ce9682b 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -476,7 +476,7 @@ static struct i2c_adapter ali15x3_adapter = {
476 .algo = &smbus_algorithm, 476 .algo = &smbus_algorithm,
477}; 477};
478 478
479static DEFINE_PCI_DEVICE_TABLE(ali15x3_ids) = { 479static const struct pci_device_id ali15x3_ids[] = {
480 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, 480 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
481 { 0, } 481 { 0, }
482}; 482};
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 819d3c1062a7..a16f72891358 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -307,7 +307,7 @@ static const char* chipname[] = {
307 "nVidia nForce", "AMD8111", 307 "nVidia nForce", "AMD8111",
308}; 308};
309 309
310static DEFINE_PCI_DEVICE_TABLE(amd756_ids) = { 310static const struct pci_device_id amd756_ids[] = {
311 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_740B), 311 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_740B),
312 .driver_data = AMD756 }, 312 .driver_data = AMD756 },
313 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7413), 313 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7413),
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index f3d4d79855b5..95a80a8f81b5 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -414,7 +414,7 @@ static const struct i2c_algorithm smbus_algorithm = {
414}; 414};
415 415
416 416
417static DEFINE_PCI_DEVICE_TABLE(amd8111_ids) = { 417static const struct pci_device_id amd8111_ids[] = {
418 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS2) }, 418 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS2) },
419 { 0, } 419 { 0, }
420}; 420};
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 843d01268ae9..e95f9ba96790 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -32,7 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/platform_data/dma-atmel.h> 33#include <linux/platform_data/dma-atmel.h>
34 34
35#define TWI_CLK_HZ 100000 /* max 400 Kbits/s */ 35#define DEFAULT_TWI_CLK_HZ 100000 /* max 400 Kbits/s */
36#define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ 36#define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */
37#define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */ 37#define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */
38 38
@@ -711,6 +711,7 @@ static int at91_twi_probe(struct platform_device *pdev)
711 struct resource *mem; 711 struct resource *mem;
712 int rc; 712 int rc;
713 u32 phy_addr; 713 u32 phy_addr;
714 u32 bus_clk_rate;
714 715
715 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 716 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
716 if (!dev) 717 if (!dev)
@@ -756,13 +757,18 @@ static int at91_twi_probe(struct platform_device *pdev)
756 dev->use_dma = true; 757 dev->use_dma = true;
757 } 758 }
758 759
759 at91_calc_twi_clock(dev, TWI_CLK_HZ); 760 rc = of_property_read_u32(dev->dev->of_node, "clock-frequency",
761 &bus_clk_rate);
762 if (rc)
763 bus_clk_rate = DEFAULT_TWI_CLK_HZ;
764
765 at91_calc_twi_clock(dev, bus_clk_rate);
760 at91_init_twi_bus(dev); 766 at91_init_twi_bus(dev);
761 767
762 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91"); 768 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
763 i2c_set_adapdata(&dev->adapter, dev); 769 i2c_set_adapdata(&dev->adapter, dev);
764 dev->adapter.owner = THIS_MODULE; 770 dev->adapter.owner = THIS_MODULE;
765 dev->adapter.class = I2C_CLASS_HWMON; 771 dev->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
766 dev->adapter.algo = &at91_twi_algorithm; 772 dev->adapter.algo = &at91_twi_algorithm;
767 dev->adapter.dev.parent = dev->dev; 773 dev->adapter.dev.parent = dev->dev;
768 dev->adapter.nr = pdev->id; 774 dev->adapter.nr = pdev->id;
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 77df97b932af..c60719577fc3 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -219,7 +219,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
219static int bcm2835_i2c_probe(struct platform_device *pdev) 219static int bcm2835_i2c_probe(struct platform_device *pdev)
220{ 220{
221 struct bcm2835_i2c_dev *i2c_dev; 221 struct bcm2835_i2c_dev *i2c_dev;
222 struct resource *mem, *requested, *irq; 222 struct resource *mem, *irq;
223 u32 bus_clk_rate, divider; 223 u32 bus_clk_rate, divider;
224 int ret; 224 int ret;
225 struct i2c_adapter *adap; 225 struct i2c_adapter *adap;
@@ -234,25 +234,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
234 init_completion(&i2c_dev->completion); 234 init_completion(&i2c_dev->completion);
235 235
236 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 236 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
237 if (!mem) { 237 i2c_dev->regs = devm_ioremap_resource(&pdev->dev, mem);
238 dev_err(&pdev->dev, "No mem resource\n"); 238 if (IS_ERR(i2c_dev->regs))
239 return -ENODEV; 239 return PTR_ERR(i2c_dev->regs);
240 }
241
242 requested = devm_request_mem_region(&pdev->dev, mem->start,
243 resource_size(mem),
244 dev_name(&pdev->dev));
245 if (!requested) {
246 dev_err(&pdev->dev, "Could not claim register region\n");
247 return -EBUSY;
248 }
249
250 i2c_dev->regs = devm_ioremap(&pdev->dev, mem->start,
251 resource_size(mem));
252 if (!i2c_dev->regs) {
253 dev_err(&pdev->dev, "Could not map registers\n");
254 return -ENOMEM;
255 }
256 240
257 i2c_dev->clk = devm_clk_get(&pdev->dev, NULL); 241 i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
258 if (IS_ERR(i2c_dev->clk)) { 242 if (IS_ERR(i2c_dev->clk)) {
@@ -295,7 +279,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
295 adap = &i2c_dev->adapter; 279 adap = &i2c_dev->adapter;
296 i2c_set_adapdata(adap, i2c_dev); 280 i2c_set_adapdata(adap, i2c_dev);
297 adap->owner = THIS_MODULE; 281 adap->owner = THIS_MODULE;
298 adap->class = I2C_CLASS_HWMON; 282 adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
299 strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name)); 283 strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name));
300 adap->algo = &bcm2835_i2c_algo; 284 adap->algo = &bcm2835_i2c_algo;
301 adap->dev.parent = &pdev->dev; 285 adap->dev.parent = &pdev->dev;
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 3b9bd9a3f2b0..e6d5162b6379 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -21,10 +21,10 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/i2c/bfin_twi.h>
24 25
25#include <asm/blackfin.h>
26#include <asm/portmux.h>
27#include <asm/irq.h> 26#include <asm/irq.h>
27#include <asm/portmux.h>
28#include <asm/bfin_twi.h> 28#include <asm/bfin_twi.h>
29 29
30/* SMBus mode*/ 30/* SMBus mode*/
@@ -65,7 +65,6 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
65 /* Transmit next data */ 65 /* Transmit next data */
66 while (iface->writeNum > 0 && 66 while (iface->writeNum > 0 &&
67 (read_FIFO_STAT(iface) & XMTSTAT) != XMT_FULL) { 67 (read_FIFO_STAT(iface) & XMTSTAT) != XMT_FULL) {
68 SSYNC();
69 write_XMT_DATA8(iface, *(iface->transPtr++)); 68 write_XMT_DATA8(iface, *(iface->transPtr++));
70 iface->writeNum--; 69 iface->writeNum--;
71 } 70 }
@@ -248,7 +247,6 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
248 /* Clear interrupt status */ 247 /* Clear interrupt status */
249 write_INT_STAT(iface, twi_int_status); 248 write_INT_STAT(iface, twi_int_status);
250 bfin_twi_handle_interrupt(iface, twi_int_status); 249 bfin_twi_handle_interrupt(iface, twi_int_status);
251 SSYNC();
252 } 250 }
253 spin_unlock_irqrestore(&iface->lock, flags); 251 spin_unlock_irqrestore(&iface->lock, flags);
254 return IRQ_HANDLED; 252 return IRQ_HANDLED;
@@ -294,9 +292,7 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
294 * discarded before start a new operation. 292 * discarded before start a new operation.
295 */ 293 */
296 write_FIFO_CTL(iface, 0x3); 294 write_FIFO_CTL(iface, 0x3);
297 SSYNC();
298 write_FIFO_CTL(iface, 0); 295 write_FIFO_CTL(iface, 0);
299 SSYNC();
300 296
301 if (pmsg->flags & I2C_M_RD) 297 if (pmsg->flags & I2C_M_RD)
302 iface->read_write = I2C_SMBUS_READ; 298 iface->read_write = I2C_SMBUS_READ;
@@ -306,7 +302,6 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
306 if (iface->writeNum > 0) { 302 if (iface->writeNum > 0) {
307 write_XMT_DATA8(iface, *(iface->transPtr++)); 303 write_XMT_DATA8(iface, *(iface->transPtr++));
308 iface->writeNum--; 304 iface->writeNum--;
309 SSYNC();
310 } 305 }
311 } 306 }
312 307
@@ -315,7 +310,6 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
315 310
316 /* Interrupt mask . Enable XMT, RCV interrupt */ 311 /* Interrupt mask . Enable XMT, RCV interrupt */
317 write_INT_MASK(iface, MCOMP | MERR | RCVSERV | XMTSERV); 312 write_INT_MASK(iface, MCOMP | MERR | RCVSERV | XMTSERV);
318 SSYNC();
319 313
320 if (pmsg->len <= 255) 314 if (pmsg->len <= 255)
321 write_MASTER_CTL(iface, pmsg->len << 6); 315 write_MASTER_CTL(iface, pmsg->len << 6);
@@ -329,7 +323,6 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
329 (iface->msg_num > 1 ? RSTART : 0) | 323 (iface->msg_num > 1 ? RSTART : 0) |
330 ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) | 324 ((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) |
331 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); 325 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0));
332 SSYNC();
333 326
334 while (!iface->result) { 327 while (!iface->result) {
335 if (!wait_for_completion_timeout(&iface->complete, 328 if (!wait_for_completion_timeout(&iface->complete,
@@ -453,7 +446,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
453 * start a new operation. 446 * start a new operation.
454 */ 447 */
455 write_FIFO_CTL(iface, 0x3); 448 write_FIFO_CTL(iface, 0x3);
456 SSYNC();
457 write_FIFO_CTL(iface, 0); 449 write_FIFO_CTL(iface, 0);
458 450
459 /* clear int stat */ 451 /* clear int stat */
@@ -461,7 +453,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
461 453
462 /* Set Transmit device address */ 454 /* Set Transmit device address */
463 write_MASTER_ADDR(iface, addr); 455 write_MASTER_ADDR(iface, addr);
464 SSYNC();
465 456
466 switch (iface->cur_mode) { 457 switch (iface->cur_mode) {
467 case TWI_I2C_MODE_STANDARDSUB: 458 case TWI_I2C_MODE_STANDARDSUB:
@@ -469,7 +460,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
469 write_INT_MASK(iface, MCOMP | MERR | 460 write_INT_MASK(iface, MCOMP | MERR |
470 ((iface->read_write == I2C_SMBUS_READ) ? 461 ((iface->read_write == I2C_SMBUS_READ) ?
471 RCVSERV : XMTSERV)); 462 RCVSERV : XMTSERV));
472 SSYNC();
473 463
474 if (iface->writeNum + 1 <= 255) 464 if (iface->writeNum + 1 <= 255)
475 write_MASTER_CTL(iface, (iface->writeNum + 1) << 6); 465 write_MASTER_CTL(iface, (iface->writeNum + 1) << 6);
@@ -484,7 +474,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
484 case TWI_I2C_MODE_COMBINED: 474 case TWI_I2C_MODE_COMBINED:
485 write_XMT_DATA8(iface, iface->command); 475 write_XMT_DATA8(iface, iface->command);
486 write_INT_MASK(iface, MCOMP | MERR | RCVSERV | XMTSERV); 476 write_INT_MASK(iface, MCOMP | MERR | RCVSERV | XMTSERV);
487 SSYNC();
488 477
489 if (iface->writeNum > 0) 478 if (iface->writeNum > 0)
490 write_MASTER_CTL(iface, (iface->writeNum + 1) << 6); 479 write_MASTER_CTL(iface, (iface->writeNum + 1) << 6);
@@ -531,7 +520,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
531 write_INT_MASK(iface, MCOMP | MERR | 520 write_INT_MASK(iface, MCOMP | MERR |
532 ((iface->read_write == I2C_SMBUS_READ) ? 521 ((iface->read_write == I2C_SMBUS_READ) ?
533 RCVSERV : XMTSERV)); 522 RCVSERV : XMTSERV));
534 SSYNC();
535 523
536 /* Master enable */ 524 /* Master enable */
537 write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | 525 write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN |
@@ -539,7 +527,6 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
539 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0)); 527 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0));
540 break; 528 break;
541 } 529 }
542 SSYNC();
543 530
544 while (!iface->result) { 531 while (!iface->result) {
545 if (!wait_for_completion_timeout(&iface->complete, 532 if (!wait_for_completion_timeout(&iface->complete,
@@ -669,7 +656,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
669 strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name)); 656 strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name));
670 p_adap->algo = &bfin_twi_algorithm; 657 p_adap->algo = &bfin_twi_algorithm;
671 p_adap->algo_data = iface; 658 p_adap->algo_data = iface;
672 p_adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 659 p_adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
673 p_adap->dev.parent = &pdev->dev; 660 p_adap->dev.parent = &pdev->dev;
674 p_adap->timeout = 5 * HZ; 661 p_adap->timeout = 5 * HZ;
675 p_adap->retries = 3; 662 p_adap->retries = 3;
@@ -704,7 +691,6 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
704 691
705 /* Enable TWI */ 692 /* Enable TWI */
706 write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); 693 write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA);
707 SSYNC();
708 694
709 rc = i2c_add_numbered_adapter(p_adap); 695 rc = i2c_add_numbered_adapter(p_adap);
710 if (rc < 0) { 696 if (rc < 0) {
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
new file mode 100644
index 000000000000..63f3f03ecc9b
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -0,0 +1,905 @@
1/*
2 * I2C bus driver for the Cadence I2C controller.
3 *
4 * Copyright (C) 2009 - 2014 Xilinx, Inc.
5 *
6 * This program is free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation;
9 * either version 2 of the License, or (at your option) any
10 * later version.
11 */
12
13#include <linux/clk.h>
14#include <linux/delay.h>
15#include <linux/i2c.h>
16#include <linux/interrupt.h>
17#include <linux/io.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21/* Register offsets for the I2C device. */
22#define CDNS_I2C_CR_OFFSET 0x00 /* Control Register, RW */
23#define CDNS_I2C_SR_OFFSET 0x04 /* Status Register, RO */
24#define CDNS_I2C_ADDR_OFFSET 0x08 /* I2C Address Register, RW */
25#define CDNS_I2C_DATA_OFFSET 0x0C /* I2C Data Register, RW */
26#define CDNS_I2C_ISR_OFFSET 0x10 /* IRQ Status Register, RW */
27#define CDNS_I2C_XFER_SIZE_OFFSET 0x14 /* Transfer Size Register, RW */
28#define CDNS_I2C_TIME_OUT_OFFSET 0x1C /* Time Out Register, RW */
29#define CDNS_I2C_IER_OFFSET 0x24 /* IRQ Enable Register, WO */
30#define CDNS_I2C_IDR_OFFSET 0x28 /* IRQ Disable Register, WO */
31
32/* Control Register Bit mask definitions */
33#define CDNS_I2C_CR_HOLD BIT(4) /* Hold Bus bit */
34#define CDNS_I2C_CR_ACK_EN BIT(3)
35#define CDNS_I2C_CR_NEA BIT(2)
36#define CDNS_I2C_CR_MS BIT(1)
37/* Read or Write Master transfer 0 = Transmitter, 1 = Receiver */
38#define CDNS_I2C_CR_RW BIT(0)
39/* 1 = Auto init FIFO to zeroes */
40#define CDNS_I2C_CR_CLR_FIFO BIT(6)
41#define CDNS_I2C_CR_DIVA_SHIFT 14
42#define CDNS_I2C_CR_DIVA_MASK (3 << CDNS_I2C_CR_DIVA_SHIFT)
43#define CDNS_I2C_CR_DIVB_SHIFT 8
44#define CDNS_I2C_CR_DIVB_MASK (0x3f << CDNS_I2C_CR_DIVB_SHIFT)
45
46/* Status Register Bit mask definitions */
47#define CDNS_I2C_SR_BA BIT(8)
48#define CDNS_I2C_SR_RXDV BIT(5)
49
50/*
51 * I2C Address Register Bit mask definitions
52 * Normal addressing mode uses [6:0] bits. Extended addressing mode uses [9:0]
53 * bits. A write access to this register always initiates a transfer if the I2C
54 * is in master mode.
55 */
56#define CDNS_I2C_ADDR_MASK 0x000003FF /* I2C Address Mask */
57
58/*
59 * I2C Interrupt Registers Bit mask definitions
60 * All the four interrupt registers (Status/Mask/Enable/Disable) have the same
61 * bit definitions.
62 */
63#define CDNS_I2C_IXR_ARB_LOST BIT(9)
64#define CDNS_I2C_IXR_RX_UNF BIT(7)
65#define CDNS_I2C_IXR_TX_OVF BIT(6)
66#define CDNS_I2C_IXR_RX_OVF BIT(5)
67#define CDNS_I2C_IXR_SLV_RDY BIT(4)
68#define CDNS_I2C_IXR_TO BIT(3)
69#define CDNS_I2C_IXR_NACK BIT(2)
70#define CDNS_I2C_IXR_DATA BIT(1)
71#define CDNS_I2C_IXR_COMP BIT(0)
72
73#define CDNS_I2C_IXR_ALL_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
74 CDNS_I2C_IXR_RX_UNF | \
75 CDNS_I2C_IXR_TX_OVF | \
76 CDNS_I2C_IXR_RX_OVF | \
77 CDNS_I2C_IXR_SLV_RDY | \
78 CDNS_I2C_IXR_TO | \
79 CDNS_I2C_IXR_NACK | \
80 CDNS_I2C_IXR_DATA | \
81 CDNS_I2C_IXR_COMP)
82
83#define CDNS_I2C_IXR_ERR_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
84 CDNS_I2C_IXR_RX_UNF | \
85 CDNS_I2C_IXR_TX_OVF | \
86 CDNS_I2C_IXR_RX_OVF | \
87 CDNS_I2C_IXR_NACK)
88
89#define CDNS_I2C_ENABLED_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
90 CDNS_I2C_IXR_RX_UNF | \
91 CDNS_I2C_IXR_TX_OVF | \
92 CDNS_I2C_IXR_RX_OVF | \
93 CDNS_I2C_IXR_NACK | \
94 CDNS_I2C_IXR_DATA | \
95 CDNS_I2C_IXR_COMP)
96
97#define CDNS_I2C_TIMEOUT msecs_to_jiffies(1000)
98
99#define CDNS_I2C_FIFO_DEPTH 16
100/* FIFO depth at which the DATA interrupt occurs */
101#define CDNS_I2C_DATA_INTR_DEPTH (CDNS_I2C_FIFO_DEPTH - 2)
102#define CDNS_I2C_MAX_TRANSFER_SIZE 255
103/* Transfer size in multiples of data interrupt depth */
104#define CDNS_I2C_TRANSFER_SIZE (CDNS_I2C_MAX_TRANSFER_SIZE - 3)
105
106#define DRIVER_NAME "cdns-i2c"
107
108#define CDNS_I2C_SPEED_MAX 400000
109#define CDNS_I2C_SPEED_DEFAULT 100000
110
111#define CDNS_I2C_DIVA_MAX 4
112#define CDNS_I2C_DIVB_MAX 64
113
114#define cdns_i2c_readreg(offset) readl_relaxed(id->membase + offset)
115#define cdns_i2c_writereg(val, offset) writel_relaxed(val, id->membase + offset)
116
117/**
118 * struct cdns_i2c - I2C device private data structure
119 * @membase: Base address of the I2C device
120 * @adap: I2C adapter instance
121 * @p_msg: Message pointer
122 * @err_status: Error status in Interrupt Status Register
123 * @xfer_done: Transfer complete status
124 * @p_send_buf: Pointer to transmit buffer
125 * @p_recv_buf: Pointer to receive buffer
126 * @suspended: Flag holding the device's PM status
127 * @send_count: Number of bytes still expected to send
128 * @recv_count: Number of bytes still expected to receive
129 * @irq: IRQ number
130 * @input_clk: Input clock to I2C controller
131 * @i2c_clk: Maximum I2C clock speed
132 * @bus_hold_flag: Flag used in repeated start for clearing HOLD bit
133 * @clk: Pointer to struct clk
134 * @clk_rate_change_nb: Notifier block for clock rate changes
135 */
136struct cdns_i2c {
137 void __iomem *membase;
138 struct i2c_adapter adap;
139 struct i2c_msg *p_msg;
140 int err_status;
141 struct completion xfer_done;
142 unsigned char *p_send_buf;
143 unsigned char *p_recv_buf;
144 u8 suspended;
145 unsigned int send_count;
146 unsigned int recv_count;
147 int irq;
148 unsigned long input_clk;
149 unsigned int i2c_clk;
150 unsigned int bus_hold_flag;
151 struct clk *clk;
152 struct notifier_block clk_rate_change_nb;
153};
154
155#define to_cdns_i2c(_nb) container_of(_nb, struct cdns_i2c, \
156 clk_rate_change_nb)
157
158/**
159 * cdns_i2c_clear_bus_hold() - Clear bus hold bit
160 * @id: Pointer to driver data struct
161 *
162 * Helper to clear the controller's bus hold bit.
163 */
164static void cdns_i2c_clear_bus_hold(struct cdns_i2c *id)
165{
166 u32 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
167 if (reg & CDNS_I2C_CR_HOLD)
168 cdns_i2c_writereg(reg & ~CDNS_I2C_CR_HOLD, CDNS_I2C_CR_OFFSET);
169}
170
171/**
172 * cdns_i2c_isr - Interrupt handler for the I2C device
173 * @irq: irq number for the I2C device
174 * @ptr: void pointer to cdns_i2c structure
175 *
176 * This function handles the data interrupt, transfer complete interrupt and
177 * the error interrupts of the I2C device.
178 *
179 * Return: IRQ_HANDLED always
180 */
181static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
182{
183 unsigned int isr_status, avail_bytes;
184 unsigned int bytes_to_recv, bytes_to_send;
185 struct cdns_i2c *id = ptr;
186 /* Signal completion only after everything is updated */
187 int done_flag = 0;
188 irqreturn_t status = IRQ_NONE;
189
190 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
191
192 /* Handling nack and arbitration lost interrupt */
193 if (isr_status & (CDNS_I2C_IXR_NACK | CDNS_I2C_IXR_ARB_LOST)) {
194 done_flag = 1;
195 status = IRQ_HANDLED;
196 }
197
198 /* Handling Data interrupt */
199 if ((isr_status & CDNS_I2C_IXR_DATA) &&
200 (id->recv_count >= CDNS_I2C_DATA_INTR_DEPTH)) {
201 /* Always read data interrupt threshold bytes */
202 bytes_to_recv = CDNS_I2C_DATA_INTR_DEPTH;
203 id->recv_count -= CDNS_I2C_DATA_INTR_DEPTH;
204 avail_bytes = cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
205
206 /*
207 * if the tranfer size register value is zero, then
208 * check for the remaining bytes and update the
209 * transfer size register.
210 */
211 if (!avail_bytes) {
212 if (id->recv_count > CDNS_I2C_TRANSFER_SIZE)
213 cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
214 CDNS_I2C_XFER_SIZE_OFFSET);
215 else
216 cdns_i2c_writereg(id->recv_count,
217 CDNS_I2C_XFER_SIZE_OFFSET);
218 }
219
220 /* Process the data received */
221 while (bytes_to_recv--)
222 *(id->p_recv_buf)++ =
223 cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
224
225 if (!id->bus_hold_flag &&
226 (id->recv_count <= CDNS_I2C_FIFO_DEPTH))
227 cdns_i2c_clear_bus_hold(id);
228
229 status = IRQ_HANDLED;
230 }
231
232 /* Handling Transfer Complete interrupt */
233 if (isr_status & CDNS_I2C_IXR_COMP) {
234 if (!id->p_recv_buf) {
235 /*
236 * If the device is sending data If there is further
237 * data to be sent. Calculate the available space
238 * in FIFO and fill the FIFO with that many bytes.
239 */
240 if (id->send_count) {
241 avail_bytes = CDNS_I2C_FIFO_DEPTH -
242 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
243 if (id->send_count > avail_bytes)
244 bytes_to_send = avail_bytes;
245 else
246 bytes_to_send = id->send_count;
247
248 while (bytes_to_send--) {
249 cdns_i2c_writereg(
250 (*(id->p_send_buf)++),
251 CDNS_I2C_DATA_OFFSET);
252 id->send_count--;
253 }
254 } else {
255 /*
256 * Signal the completion of transaction and
257 * clear the hold bus bit if there are no
258 * further messages to be processed.
259 */
260 done_flag = 1;
261 }
262 if (!id->send_count && !id->bus_hold_flag)
263 cdns_i2c_clear_bus_hold(id);
264 } else {
265 if (!id->bus_hold_flag)
266 cdns_i2c_clear_bus_hold(id);
267 /*
268 * If the device is receiving data, then signal
269 * the completion of transaction and read the data
270 * present in the FIFO. Signal the completion of
271 * transaction.
272 */
273 while (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) &
274 CDNS_I2C_SR_RXDV) {
275 *(id->p_recv_buf)++ =
276 cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
277 id->recv_count--;
278 }
279 done_flag = 1;
280 }
281
282 status = IRQ_HANDLED;
283 }
284
285 /* Update the status for errors */
286 id->err_status = isr_status & CDNS_I2C_IXR_ERR_INTR_MASK;
287 if (id->err_status)
288 status = IRQ_HANDLED;
289
290 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
291
292 if (done_flag)
293 complete(&id->xfer_done);
294
295 return status;
296}
297
298/**
299 * cdns_i2c_mrecv - Prepare and start a master receive operation
300 * @id: pointer to the i2c device structure
301 */
302static void cdns_i2c_mrecv(struct cdns_i2c *id)
303{
304 unsigned int ctrl_reg;
305 unsigned int isr_status;
306
307 id->p_recv_buf = id->p_msg->buf;
308 id->recv_count = id->p_msg->len;
309
310 /* Put the controller in master receive mode and clear the FIFO */
311 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
312 ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO;
313
314 if (id->p_msg->flags & I2C_M_RECV_LEN)
315 id->recv_count = I2C_SMBUS_BLOCK_MAX + 1;
316
317 /*
318 * Check for the message size against FIFO depth and set the
319 * 'hold bus' bit if it is greater than FIFO depth.
320 */
321 if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
322 ctrl_reg |= CDNS_I2C_CR_HOLD;
323
324 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
325
326 /* Clear the interrupts in interrupt status register */
327 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
328 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
329
330 /*
331 * The no. of bytes to receive is checked against the limit of
332 * max transfer size. Set transfer size register with no of bytes
333 * receive if it is less than transfer size and transfer size if
334 * it is more. Enable the interrupts.
335 */
336 if (id->recv_count > CDNS_I2C_TRANSFER_SIZE)
337 cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
338 CDNS_I2C_XFER_SIZE_OFFSET);
339 else
340 cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET);
341 /* Clear the bus hold flag if bytes to receive is less than FIFO size */
342 if (!id->bus_hold_flag &&
343 ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) &&
344 (id->recv_count <= CDNS_I2C_FIFO_DEPTH))
345 cdns_i2c_clear_bus_hold(id);
346 /* Set the slave address in address register - triggers operation */
347 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
348 CDNS_I2C_ADDR_OFFSET);
349 cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET);
350}
351
352/**
353 * cdns_i2c_msend - Prepare and start a master send operation
354 * @id: pointer to the i2c device
355 */
356static void cdns_i2c_msend(struct cdns_i2c *id)
357{
358 unsigned int avail_bytes;
359 unsigned int bytes_to_send;
360 unsigned int ctrl_reg;
361 unsigned int isr_status;
362
363 id->p_recv_buf = NULL;
364 id->p_send_buf = id->p_msg->buf;
365 id->send_count = id->p_msg->len;
366
367 /* Set the controller in Master transmit mode and clear the FIFO. */
368 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
369 ctrl_reg &= ~CDNS_I2C_CR_RW;
370 ctrl_reg |= CDNS_I2C_CR_CLR_FIFO;
371
372 /*
373 * Check for the message size against FIFO depth and set the
374 * 'hold bus' bit if it is greater than FIFO depth.
375 */
376 if (id->send_count > CDNS_I2C_FIFO_DEPTH)
377 ctrl_reg |= CDNS_I2C_CR_HOLD;
378 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
379
380 /* Clear the interrupts in interrupt status register. */
381 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
382 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
383
384 /*
385 * Calculate the space available in FIFO. Check the message length
386 * against the space available, and fill the FIFO accordingly.
387 * Enable the interrupts.
388 */
389 avail_bytes = CDNS_I2C_FIFO_DEPTH -
390 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
391
392 if (id->send_count > avail_bytes)
393 bytes_to_send = avail_bytes;
394 else
395 bytes_to_send = id->send_count;
396
397 while (bytes_to_send--) {
398 cdns_i2c_writereg((*(id->p_send_buf)++), CDNS_I2C_DATA_OFFSET);
399 id->send_count--;
400 }
401
402 /*
403 * Clear the bus hold flag if there is no more data
404 * and if it is the last message.
405 */
406 if (!id->bus_hold_flag && !id->send_count)
407 cdns_i2c_clear_bus_hold(id);
408 /* Set the slave address in address register - triggers operation. */
409 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
410 CDNS_I2C_ADDR_OFFSET);
411
412 cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET);
413}
414
415/**
416 * cdns_i2c_master_reset - Reset the interface
417 * @adap: pointer to the i2c adapter driver instance
418 *
419 * This function cleanup the fifos, clear the hold bit and status
420 * and disable the interrupts.
421 */
422static void cdns_i2c_master_reset(struct i2c_adapter *adap)
423{
424 struct cdns_i2c *id = adap->algo_data;
425 u32 regval;
426
427 /* Disable the interrupts */
428 cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, CDNS_I2C_IDR_OFFSET);
429 /* Clear the hold bit and fifos */
430 regval = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
431 regval &= ~CDNS_I2C_CR_HOLD;
432 regval |= CDNS_I2C_CR_CLR_FIFO;
433 cdns_i2c_writereg(regval, CDNS_I2C_CR_OFFSET);
434 /* Update the transfercount register to zero */
435 cdns_i2c_writereg(0, CDNS_I2C_XFER_SIZE_OFFSET);
436 /* Clear the interupt status register */
437 regval = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
438 cdns_i2c_writereg(regval, CDNS_I2C_ISR_OFFSET);
439 /* Clear the status register */
440 regval = cdns_i2c_readreg(CDNS_I2C_SR_OFFSET);
441 cdns_i2c_writereg(regval, CDNS_I2C_SR_OFFSET);
442}
443
444static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
445 struct i2c_adapter *adap)
446{
447 int ret;
448 u32 reg;
449
450 id->p_msg = msg;
451 id->err_status = 0;
452 reinit_completion(&id->xfer_done);
453
454 /* Check for the TEN Bit mode on each msg */
455 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
456 if (msg->flags & I2C_M_TEN) {
457 if (reg & CDNS_I2C_CR_NEA)
458 cdns_i2c_writereg(reg & ~CDNS_I2C_CR_NEA,
459 CDNS_I2C_CR_OFFSET);
460 } else {
461 if (!(reg & CDNS_I2C_CR_NEA))
462 cdns_i2c_writereg(reg | CDNS_I2C_CR_NEA,
463 CDNS_I2C_CR_OFFSET);
464 }
465
466 /* Check for the R/W flag on each msg */
467 if (msg->flags & I2C_M_RD)
468 cdns_i2c_mrecv(id);
469 else
470 cdns_i2c_msend(id);
471
472 /* Wait for the signal of completion */
473 ret = wait_for_completion_timeout(&id->xfer_done, adap->timeout);
474 if (!ret) {
475 cdns_i2c_master_reset(adap);
476 dev_err(id->adap.dev.parent,
477 "timeout waiting on completion\n");
478 return -ETIMEDOUT;
479 }
480
481 cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
482 CDNS_I2C_IDR_OFFSET);
483
484 /* If it is bus arbitration error, try again */
485 if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
486 return -EAGAIN;
487
488 return 0;
489}
490
491/**
492 * cdns_i2c_master_xfer - The main i2c transfer function
493 * @adap: pointer to the i2c adapter driver instance
494 * @msgs: pointer to the i2c message structure
495 * @num: the number of messages to transfer
496 *
497 * Initiates the send/recv activity based on the transfer message received.
498 *
499 * Return: number of msgs processed on success, negative error otherwise
500 */
501static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
502 int num)
503{
504 int ret, count;
505 u32 reg;
506 struct cdns_i2c *id = adap->algo_data;
507
508 /* Check if the bus is free */
509 if (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) & CDNS_I2C_SR_BA)
510 return -EAGAIN;
511
512 /*
513 * Set the flag to one when multiple messages are to be
514 * processed with a repeated start.
515 */
516 if (num > 1) {
517 id->bus_hold_flag = 1;
518 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
519 reg |= CDNS_I2C_CR_HOLD;
520 cdns_i2c_writereg(reg, CDNS_I2C_CR_OFFSET);
521 } else {
522 id->bus_hold_flag = 0;
523 }
524
525 /* Process the msg one by one */
526 for (count = 0; count < num; count++, msgs++) {
527 if (count == (num - 1))
528 id->bus_hold_flag = 0;
529
530 ret = cdns_i2c_process_msg(id, msgs, adap);
531 if (ret)
532 return ret;
533
534 /* Report the other error interrupts to application */
535 if (id->err_status) {
536 cdns_i2c_master_reset(adap);
537
538 if (id->err_status & CDNS_I2C_IXR_NACK)
539 return -ENXIO;
540
541 return -EIO;
542 }
543 }
544
545 return num;
546}
547
548/**
549 * cdns_i2c_func - Returns the supported features of the I2C driver
550 * @adap: pointer to the i2c adapter structure
551 *
552 * Return: 32 bit value, each bit corresponding to a feature
553 */
554static u32 cdns_i2c_func(struct i2c_adapter *adap)
555{
556 return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR |
557 (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK) |
558 I2C_FUNC_SMBUS_BLOCK_DATA;
559}
560
561static const struct i2c_algorithm cdns_i2c_algo = {
562 .master_xfer = cdns_i2c_master_xfer,
563 .functionality = cdns_i2c_func,
564};
565
566/**
567 * cdns_i2c_calc_divs - Calculate clock dividers
568 * @f: I2C clock frequency
569 * @input_clk: Input clock frequency
570 * @a: First divider (return value)
571 * @b: Second divider (return value)
572 *
573 * f is used as input and output variable. As input it is used as target I2C
574 * frequency. On function exit f holds the actually resulting I2C frequency.
575 *
576 * Return: 0 on success, negative errno otherwise.
577 */
578static int cdns_i2c_calc_divs(unsigned long *f, unsigned long input_clk,
579 unsigned int *a, unsigned int *b)
580{
581 unsigned long fscl = *f, best_fscl = *f, actual_fscl, temp;
582 unsigned int div_a, div_b, calc_div_a = 0, calc_div_b = 0;
583 unsigned int last_error, current_error;
584
585 /* calculate (divisor_a+1) x (divisor_b+1) */
586 temp = input_clk / (22 * fscl);
587
588 /*
589 * If the calculated value is negative or 0, the fscl input is out of
590 * range. Return error.
591 */
592 if (!temp || (temp > (CDNS_I2C_DIVA_MAX * CDNS_I2C_DIVB_MAX)))
593 return -EINVAL;
594
595 last_error = -1;
596 for (div_a = 0; div_a < CDNS_I2C_DIVA_MAX; div_a++) {
597 div_b = DIV_ROUND_UP(input_clk, 22 * fscl * (div_a + 1));
598
599 if ((div_b < 1) || (div_b > CDNS_I2C_DIVB_MAX))
600 continue;
601 div_b--;
602
603 actual_fscl = input_clk / (22 * (div_a + 1) * (div_b + 1));
604
605 if (actual_fscl > fscl)
606 continue;
607
608 current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
609 (fscl - actual_fscl));
610
611 if (last_error > current_error) {
612 calc_div_a = div_a;
613 calc_div_b = div_b;
614 best_fscl = actual_fscl;
615 last_error = current_error;
616 }
617 }
618
619 *a = calc_div_a;
620 *b = calc_div_b;
621 *f = best_fscl;
622
623 return 0;
624}
625
626/**
627 * cdns_i2c_setclk - This function sets the serial clock rate for the I2C device
628 * @clk_in: I2C clock input frequency in Hz
629 * @id: Pointer to the I2C device structure
630 *
631 * The device must be idle rather than busy transferring data before setting
632 * these device options.
633 * The data rate is set by values in the control register.
634 * The formula for determining the correct register values is
635 * Fscl = Fpclk/(22 x (divisor_a+1) x (divisor_b+1))
636 * See the hardware data sheet for a full explanation of setting the serial
637 * clock rate. The clock can not be faster than the input clock divide by 22.
638 * The two most common clock rates are 100KHz and 400KHz.
639 *
640 * Return: 0 on success, negative error otherwise
641 */
642static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
643{
644 unsigned int div_a, div_b;
645 unsigned int ctrl_reg;
646 int ret = 0;
647 unsigned long fscl = id->i2c_clk;
648
649 ret = cdns_i2c_calc_divs(&fscl, clk_in, &div_a, &div_b);
650 if (ret)
651 return ret;
652
653 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
654 ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK);
655 ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) |
656 (div_b << CDNS_I2C_CR_DIVB_SHIFT));
657 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
658
659 return 0;
660}
661
662/**
663 * cdns_i2c_clk_notifier_cb - Clock rate change callback
664 * @nb: Pointer to notifier block
665 * @event: Notification reason
666 * @data: Pointer to notification data object
667 *
668 * This function is called when the cdns_i2c input clock frequency changes.
669 * The callback checks whether a valid bus frequency can be generated after the
670 * change. If so, the change is acknowledged, otherwise the change is aborted.
671 * New dividers are written to the HW in the pre- or post change notification
672 * depending on the scaling direction.
673 *
674 * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK
675 * to acknowedge the change, NOTIFY_DONE if the notification is
676 * considered irrelevant.
677 */
678static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
679 event, void *data)
680{
681 struct clk_notifier_data *ndata = data;
682 struct cdns_i2c *id = to_cdns_i2c(nb);
683
684 if (id->suspended)
685 return NOTIFY_OK;
686
687 switch (event) {
688 case PRE_RATE_CHANGE:
689 {
690 unsigned long input_clk = ndata->new_rate;
691 unsigned long fscl = id->i2c_clk;
692 unsigned int div_a, div_b;
693 int ret;
694
695 ret = cdns_i2c_calc_divs(&fscl, input_clk, &div_a, &div_b);
696 if (ret) {
697 dev_warn(id->adap.dev.parent,
698 "clock rate change rejected\n");
699 return NOTIFY_STOP;
700 }
701
702 /* scale up */
703 if (ndata->new_rate > ndata->old_rate)
704 cdns_i2c_setclk(ndata->new_rate, id);
705
706 return NOTIFY_OK;
707 }
708 case POST_RATE_CHANGE:
709 id->input_clk = ndata->new_rate;
710 /* scale down */
711 if (ndata->new_rate < ndata->old_rate)
712 cdns_i2c_setclk(ndata->new_rate, id);
713 return NOTIFY_OK;
714 case ABORT_RATE_CHANGE:
715 /* scale up */
716 if (ndata->new_rate > ndata->old_rate)
717 cdns_i2c_setclk(ndata->old_rate, id);
718 return NOTIFY_OK;
719 default:
720 return NOTIFY_DONE;
721 }
722}
723
724/**
725 * cdns_i2c_suspend - Suspend method for the driver
726 * @_dev: Address of the platform_device structure
727 *
728 * Put the driver into low power mode.
729 *
730 * Return: 0 always
731 */
732static int __maybe_unused cdns_i2c_suspend(struct device *_dev)
733{
734 struct platform_device *pdev = container_of(_dev,
735 struct platform_device, dev);
736 struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
737
738 clk_disable(xi2c->clk);
739 xi2c->suspended = 1;
740
741 return 0;
742}
743
744/**
745 * cdns_i2c_resume - Resume from suspend
746 * @_dev: Address of the platform_device structure
747 *
748 * Resume operation after suspend.
749 *
750 * Return: 0 on success and error value on error
751 */
752static int __maybe_unused cdns_i2c_resume(struct device *_dev)
753{
754 struct platform_device *pdev = container_of(_dev,
755 struct platform_device, dev);
756 struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
757 int ret;
758
759 ret = clk_enable(xi2c->clk);
760 if (ret) {
761 dev_err(_dev, "Cannot enable clock.\n");
762 return ret;
763 }
764
765 xi2c->suspended = 0;
766
767 return 0;
768}
769
770static SIMPLE_DEV_PM_OPS(cdns_i2c_dev_pm_ops, cdns_i2c_suspend,
771 cdns_i2c_resume);
772
773/**
774 * cdns_i2c_probe - Platform registration call
775 * @pdev: Handle to the platform device structure
776 *
777 * This function does all the memory allocation and registration for the i2c
778 * device. User can modify the address mode to 10 bit address mode using the
779 * ioctl call with option I2C_TENBIT.
780 *
781 * Return: 0 on success, negative error otherwise
782 */
783static int cdns_i2c_probe(struct platform_device *pdev)
784{
785 struct resource *r_mem;
786 struct cdns_i2c *id;
787 int ret;
788
789 id = devm_kzalloc(&pdev->dev, sizeof(*id), GFP_KERNEL);
790 if (!id)
791 return -ENOMEM;
792
793 platform_set_drvdata(pdev, id);
794
795 r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
796 id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
797 if (IS_ERR(id->membase))
798 return PTR_ERR(id->membase);
799
800 id->irq = platform_get_irq(pdev, 0);
801
802 id->adap.dev.of_node = pdev->dev.of_node;
803 id->adap.algo = &cdns_i2c_algo;
804 id->adap.timeout = CDNS_I2C_TIMEOUT;
805 id->adap.retries = 3; /* Default retry value. */
806 id->adap.algo_data = id;
807 id->adap.dev.parent = &pdev->dev;
808 init_completion(&id->xfer_done);
809 snprintf(id->adap.name, sizeof(id->adap.name),
810 "Cadence I2C at %08lx", (unsigned long)r_mem->start);
811
812 id->clk = devm_clk_get(&pdev->dev, NULL);
813 if (IS_ERR(id->clk)) {
814 dev_err(&pdev->dev, "input clock not found.\n");
815 return PTR_ERR(id->clk);
816 }
817 ret = clk_prepare_enable(id->clk);
818 if (ret) {
819 dev_err(&pdev->dev, "Unable to enable clock.\n");
820 return ret;
821 }
822 id->clk_rate_change_nb.notifier_call = cdns_i2c_clk_notifier_cb;
823 if (clk_notifier_register(id->clk, &id->clk_rate_change_nb))
824 dev_warn(&pdev->dev, "Unable to register clock notifier.\n");
825 id->input_clk = clk_get_rate(id->clk);
826
827 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
828 &id->i2c_clk);
829 if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX))
830 id->i2c_clk = CDNS_I2C_SPEED_DEFAULT;
831
832 cdns_i2c_writereg(CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS,
833 CDNS_I2C_CR_OFFSET);
834
835 ret = cdns_i2c_setclk(id->input_clk, id);
836 if (ret) {
837 dev_err(&pdev->dev, "invalid SCL clock: %u Hz\n", id->i2c_clk);
838 ret = -EINVAL;
839 goto err_clk_dis;
840 }
841
842 ret = devm_request_irq(&pdev->dev, id->irq, cdns_i2c_isr, 0,
843 DRIVER_NAME, id);
844 if (ret) {
845 dev_err(&pdev->dev, "cannot get irq %d\n", id->irq);
846 goto err_clk_dis;
847 }
848
849 ret = i2c_add_adapter(&id->adap);
850 if (ret < 0) {
851 dev_err(&pdev->dev, "reg adap failed: %d\n", ret);
852 goto err_clk_dis;
853 }
854
855 dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n",
856 id->i2c_clk / 1000, (unsigned long)r_mem->start, id->irq);
857
858 return 0;
859
860err_clk_dis:
861 clk_disable_unprepare(id->clk);
862 return ret;
863}
864
865/**
866 * cdns_i2c_remove - Unregister the device after releasing the resources
867 * @pdev: Handle to the platform device structure
868 *
869 * This function frees all the resources allocated to the device.
870 *
871 * Return: 0 always
872 */
873static int cdns_i2c_remove(struct platform_device *pdev)
874{
875 struct cdns_i2c *id = platform_get_drvdata(pdev);
876
877 i2c_del_adapter(&id->adap);
878 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
879 clk_disable_unprepare(id->clk);
880
881 return 0;
882}
883
884static const struct of_device_id cdns_i2c_of_match[] = {
885 { .compatible = "cdns,i2c-r1p10", },
886 { /* end of table */ }
887};
888MODULE_DEVICE_TABLE(of, cdns_i2c_of_match);
889
890static struct platform_driver cdns_i2c_drv = {
891 .driver = {
892 .name = DRIVER_NAME,
893 .owner = THIS_MODULE,
894 .of_match_table = cdns_i2c_of_match,
895 .pm = &cdns_i2c_dev_pm_ops,
896 },
897 .probe = cdns_i2c_probe,
898 .remove = cdns_i2c_remove,
899};
900
901module_platform_driver(cdns_i2c_drv);
902
903MODULE_AUTHOR("Xilinx Inc.");
904MODULE_DESCRIPTION("Cadence I2C bus driver");
905MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index af0b5830303d..389bc68c55ad 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -712,7 +712,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
712 adap = &dev->adapter; 712 adap = &dev->adapter;
713 i2c_set_adapdata(adap, dev); 713 i2c_set_adapdata(adap, dev);
714 adap->owner = THIS_MODULE; 714 adap->owner = THIS_MODULE;
715 adap->class = I2C_CLASS_HWMON; 715 adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
716 strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name)); 716 strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name));
717 adap->algo = &i2c_davinci_algo; 717 adap->algo = &i2c_davinci_algo;
718 adap->dev.parent = &pdev->dev; 718 adap->dev.parent = &pdev->dev;
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 14c4b30d4ccc..22e92c3d3d07 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -218,7 +218,7 @@ i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
218 * 218 *
219 * If your hardware is free from tHD;STA issue, try this one. 219 * If your hardware is free from tHD;STA issue, try this one.
220 */ 220 */
221 return (ic_clk * tSYMBOL + 5000) / 10000 - 8 + offset; 221 return (ic_clk * tSYMBOL + 500000) / 1000000 - 8 + offset;
222 else 222 else
223 /* 223 /*
224 * Conditional expression: 224 * Conditional expression:
@@ -234,7 +234,8 @@ i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
234 * The reason why we need to take into account "tf" here, 234 * The reason why we need to take into account "tf" here,
235 * is the same as described in i2c_dw_scl_lcnt(). 235 * is the same as described in i2c_dw_scl_lcnt().
236 */ 236 */
237 return (ic_clk * (tSYMBOL + tf) + 5000) / 10000 - 3 + offset; 237 return (ic_clk * (tSYMBOL + tf) + 500000) / 1000000
238 - 3 + offset;
238} 239}
239 240
240static u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset) 241static u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset)
@@ -250,7 +251,7 @@ static u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset)
250 * account the fall time of SCL signal (tf). Default tf value 251 * account the fall time of SCL signal (tf). Default tf value
251 * should be 0.3 us, for safety. 252 * should be 0.3 us, for safety.
252 */ 253 */
253 return ((ic_clk * (tLOW + tf) + 5000) / 10000) - 1 + offset; 254 return ((ic_clk * (tLOW + tf) + 500000) / 1000000) - 1 + offset;
254} 255}
255 256
256static void __i2c_dw_enable(struct dw_i2c_dev *dev, bool enable) 257static void __i2c_dw_enable(struct dw_i2c_dev *dev, bool enable)
@@ -287,6 +288,7 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
287 u32 input_clock_khz; 288 u32 input_clock_khz;
288 u32 hcnt, lcnt; 289 u32 hcnt, lcnt;
289 u32 reg; 290 u32 reg;
291 u32 sda_falling_time, scl_falling_time;
290 292
291 input_clock_khz = dev->get_clk_rate_khz(dev); 293 input_clock_khz = dev->get_clk_rate_khz(dev);
292 294
@@ -308,15 +310,18 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
308 310
309 /* set standard and fast speed deviders for high/low periods */ 311 /* set standard and fast speed deviders for high/low periods */
310 312
313 sda_falling_time = dev->sda_falling_time ?: 300; /* ns */
314 scl_falling_time = dev->scl_falling_time ?: 300; /* ns */
315
311 /* Standard-mode */ 316 /* Standard-mode */
312 hcnt = i2c_dw_scl_hcnt(input_clock_khz, 317 hcnt = i2c_dw_scl_hcnt(input_clock_khz,
313 40, /* tHD;STA = tHIGH = 4.0 us */ 318 4000, /* tHD;STA = tHIGH = 4.0 us */
314 3, /* tf = 0.3 us */ 319 sda_falling_time,
315 0, /* 0: DW default, 1: Ideal */ 320 0, /* 0: DW default, 1: Ideal */
316 0); /* No offset */ 321 0); /* No offset */
317 lcnt = i2c_dw_scl_lcnt(input_clock_khz, 322 lcnt = i2c_dw_scl_lcnt(input_clock_khz,
318 47, /* tLOW = 4.7 us */ 323 4700, /* tLOW = 4.7 us */
319 3, /* tf = 0.3 us */ 324 scl_falling_time,
320 0); /* No offset */ 325 0); /* No offset */
321 326
322 /* Allow platforms to specify the ideal HCNT and LCNT values */ 327 /* Allow platforms to specify the ideal HCNT and LCNT values */
@@ -330,13 +335,13 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
330 335
331 /* Fast-mode */ 336 /* Fast-mode */
332 hcnt = i2c_dw_scl_hcnt(input_clock_khz, 337 hcnt = i2c_dw_scl_hcnt(input_clock_khz,
333 6, /* tHD;STA = tHIGH = 0.6 us */ 338 600, /* tHD;STA = tHIGH = 0.6 us */
334 3, /* tf = 0.3 us */ 339 sda_falling_time,
335 0, /* 0: DW default, 1: Ideal */ 340 0, /* 0: DW default, 1: Ideal */
336 0); /* No offset */ 341 0); /* No offset */
337 lcnt = i2c_dw_scl_lcnt(input_clock_khz, 342 lcnt = i2c_dw_scl_lcnt(input_clock_khz,
338 13, /* tLOW = 1.3 us */ 343 1300, /* tLOW = 1.3 us */
339 3, /* tf = 0.3 us */ 344 scl_falling_time,
340 0); /* No offset */ 345 0); /* No offset */
341 346
342 if (dev->fs_hcnt && dev->fs_lcnt) { 347 if (dev->fs_hcnt && dev->fs_lcnt) {
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index e8a756537ed0..d66b6cbc9edc 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -99,6 +99,8 @@ struct dw_i2c_dev {
99 unsigned int rx_fifo_depth; 99 unsigned int rx_fifo_depth;
100 int rx_outstanding; 100 int rx_outstanding;
101 u32 sda_hold_time; 101 u32 sda_hold_time;
102 u32 sda_falling_time;
103 u32 scl_falling_time;
102 u16 ss_hcnt; 104 u16 ss_hcnt;
103 u16 ss_lcnt; 105 u16 ss_lcnt;
104 u16 fs_hcnt; 106 u16 fs_hcnt;
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index f6ed06c966ee..85056c22d21e 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -54,6 +54,16 @@ enum dw_pci_ctl_id_t {
54 medfield_3, 54 medfield_3,
55 medfield_4, 55 medfield_4,
56 medfield_5, 56 medfield_5,
57
58 baytrail,
59};
60
61struct dw_scl_sda_cfg {
62 u32 ss_hcnt;
63 u32 fs_hcnt;
64 u32 ss_lcnt;
65 u32 fs_lcnt;
66 u32 sda_hold;
57}; 67};
58 68
59struct dw_pci_controller { 69struct dw_pci_controller {
@@ -62,12 +72,29 @@ struct dw_pci_controller {
62 u32 tx_fifo_depth; 72 u32 tx_fifo_depth;
63 u32 rx_fifo_depth; 73 u32 rx_fifo_depth;
64 u32 clk_khz; 74 u32 clk_khz;
75 u32 functionality;
76 struct dw_scl_sda_cfg *scl_sda_cfg;
65}; 77};
66 78
67#define INTEL_MID_STD_CFG (DW_IC_CON_MASTER | \ 79#define INTEL_MID_STD_CFG (DW_IC_CON_MASTER | \
68 DW_IC_CON_SLAVE_DISABLE | \ 80 DW_IC_CON_SLAVE_DISABLE | \
69 DW_IC_CON_RESTART_EN) 81 DW_IC_CON_RESTART_EN)
70 82
83#define DW_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C | \
84 I2C_FUNC_SMBUS_BYTE | \
85 I2C_FUNC_SMBUS_BYTE_DATA | \
86 I2C_FUNC_SMBUS_WORD_DATA | \
87 I2C_FUNC_SMBUS_I2C_BLOCK)
88
89/* BayTrail HCNT/LCNT/SDA hold time */
90static struct dw_scl_sda_cfg byt_config = {
91 .ss_hcnt = 0x200,
92 .fs_hcnt = 0x55,
93 .ss_lcnt = 0x200,
94 .fs_lcnt = 0x99,
95 .sda_hold = 0x6,
96};
97
71static struct dw_pci_controller dw_pci_controllers[] = { 98static struct dw_pci_controller dw_pci_controllers[] = {
72 [moorestown_0] = { 99 [moorestown_0] = {
73 .bus_num = 0, 100 .bus_num = 0,
@@ -132,75 +159,40 @@ static struct dw_pci_controller dw_pci_controllers[] = {
132 .rx_fifo_depth = 32, 159 .rx_fifo_depth = 32,
133 .clk_khz = 25000, 160 .clk_khz = 25000,
134 }, 161 },
162 [baytrail] = {
163 .bus_num = -1,
164 .bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
165 .tx_fifo_depth = 32,
166 .rx_fifo_depth = 32,
167 .clk_khz = 100000,
168 .functionality = I2C_FUNC_10BIT_ADDR,
169 .scl_sda_cfg = &byt_config,
170 },
135}; 171};
136static struct i2c_algorithm i2c_dw_algo = { 172static struct i2c_algorithm i2c_dw_algo = {
137 .master_xfer = i2c_dw_xfer, 173 .master_xfer = i2c_dw_xfer,
138 .functionality = i2c_dw_func, 174 .functionality = i2c_dw_func,
139}; 175};
140 176
177#ifdef CONFIG_PM
141static int i2c_dw_pci_suspend(struct device *dev) 178static int i2c_dw_pci_suspend(struct device *dev)
142{ 179{
143 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 180 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
144 struct dw_i2c_dev *i2c = pci_get_drvdata(pdev);
145 int err;
146
147
148 i2c_dw_disable(i2c);
149
150 err = pci_save_state(pdev);
151 if (err) {
152 dev_err(&pdev->dev, "pci_save_state failed\n");
153 return err;
154 }
155
156 err = pci_set_power_state(pdev, PCI_D3hot);
157 if (err) {
158 dev_err(&pdev->dev, "pci_set_power_state failed\n");
159 return err;
160 }
161 181
182 i2c_dw_disable(pci_get_drvdata(pdev));
162 return 0; 183 return 0;
163} 184}
164 185
165static int i2c_dw_pci_resume(struct device *dev) 186static int i2c_dw_pci_resume(struct device *dev)
166{ 187{
167 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 188 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
168 struct dw_i2c_dev *i2c = pci_get_drvdata(pdev);
169 int err;
170 u32 enabled;
171
172 enabled = i2c_dw_is_enabled(i2c);
173 if (enabled)
174 return 0;
175
176 err = pci_set_power_state(pdev, PCI_D0);
177 if (err) {
178 dev_err(&pdev->dev, "pci_set_power_state() failed\n");
179 return err;
180 }
181
182 pci_restore_state(pdev);
183
184 i2c_dw_init(i2c);
185 return 0;
186}
187 189
188static int i2c_dw_pci_runtime_idle(struct device *dev) 190 return i2c_dw_init(pci_get_drvdata(pdev));
189{
190 int err = pm_schedule_suspend(dev, 500);
191 dev_dbg(dev, "runtime_idle called\n");
192
193 if (err != 0)
194 return 0;
195 return -EBUSY;
196} 191}
192#endif
197 193
198static const struct dev_pm_ops i2c_dw_pm_ops = { 194static UNIVERSAL_DEV_PM_OPS(i2c_dw_pm_ops, i2c_dw_pci_suspend,
199 .resume = i2c_dw_pci_resume, 195 i2c_dw_pci_resume, NULL);
200 .suspend = i2c_dw_pci_suspend,
201 SET_RUNTIME_PM_OPS(i2c_dw_pci_suspend, i2c_dw_pci_resume,
202 i2c_dw_pci_runtime_idle)
203};
204 196
205static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev) 197static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
206{ 198{
@@ -214,6 +206,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
214 struct i2c_adapter *adap; 206 struct i2c_adapter *adap;
215 int r; 207 int r;
216 struct dw_pci_controller *controller; 208 struct dw_pci_controller *controller;
209 struct dw_scl_sda_cfg *cfg;
217 210
218 if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) { 211 if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) {
219 dev_err(&pdev->dev, "%s: invalid driver data %ld\n", __func__, 212 dev_err(&pdev->dev, "%s: invalid driver data %ld\n", __func__,
@@ -247,13 +240,18 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
247 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; 240 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
248 dev->base = pcim_iomap_table(pdev)[0]; 241 dev->base = pcim_iomap_table(pdev)[0];
249 dev->dev = &pdev->dev; 242 dev->dev = &pdev->dev;
250 dev->functionality = 243 dev->functionality = controller->functionality |
251 I2C_FUNC_I2C | 244 DW_DEFAULT_FUNCTIONALITY;
252 I2C_FUNC_SMBUS_BYTE | 245
253 I2C_FUNC_SMBUS_BYTE_DATA |
254 I2C_FUNC_SMBUS_WORD_DATA |
255 I2C_FUNC_SMBUS_I2C_BLOCK;
256 dev->master_cfg = controller->bus_cfg; 246 dev->master_cfg = controller->bus_cfg;
247 if (controller->scl_sda_cfg) {
248 cfg = controller->scl_sda_cfg;
249 dev->ss_hcnt = cfg->ss_hcnt;
250 dev->fs_hcnt = cfg->fs_hcnt;
251 dev->ss_lcnt = cfg->ss_lcnt;
252 dev->fs_lcnt = cfg->fs_lcnt;
253 dev->sda_hold_time = cfg->sda_hold;
254 }
257 255
258 pci_set_drvdata(pdev, dev); 256 pci_set_drvdata(pdev, dev);
259 257
@@ -270,8 +268,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
270 adap->algo = &i2c_dw_algo; 268 adap->algo = &i2c_dw_algo;
271 adap->dev.parent = &pdev->dev; 269 adap->dev.parent = &pdev->dev;
272 adap->nr = controller->bus_num; 270 adap->nr = controller->bus_num;
273 snprintf(adap->name, sizeof(adap->name), "i2c-designware-pci-%d", 271
274 adap->nr); 272 snprintf(adap->name, sizeof(adap->name), "i2c-designware-pci");
275 273
276 r = devm_request_irq(&pdev->dev, pdev->irq, i2c_dw_isr, IRQF_SHARED, 274 r = devm_request_irq(&pdev->dev, pdev->irq, i2c_dw_isr, IRQF_SHARED,
277 adap->name, dev); 275 adap->name, dev);
@@ -290,6 +288,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
290 288
291 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); 289 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
292 pm_runtime_use_autosuspend(&pdev->dev); 290 pm_runtime_use_autosuspend(&pdev->dev);
291 pm_runtime_put_autosuspend(&pdev->dev);
293 pm_runtime_allow(&pdev->dev); 292 pm_runtime_allow(&pdev->dev);
294 293
295 return 0; 294 return 0;
@@ -309,7 +308,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
309/* work with hotplug and coldplug */ 308/* work with hotplug and coldplug */
310MODULE_ALIAS("i2c_designware-pci"); 309MODULE_ALIAS("i2c_designware-pci");
311 310
312static DEFINE_PCI_DEVICE_TABLE(i2_designware_pci_ids) = { 311static const struct pci_device_id i2_designware_pci_ids[] = {
313 /* Moorestown */ 312 /* Moorestown */
314 { PCI_VDEVICE(INTEL, 0x0802), moorestown_0 }, 313 { PCI_VDEVICE(INTEL, 0x0802), moorestown_0 },
315 { PCI_VDEVICE(INTEL, 0x0803), moorestown_1 }, 314 { PCI_VDEVICE(INTEL, 0x0803), moorestown_1 },
@@ -321,6 +320,14 @@ static DEFINE_PCI_DEVICE_TABLE(i2_designware_pci_ids) = {
321 { PCI_VDEVICE(INTEL, 0x082C), medfield_0 }, 320 { PCI_VDEVICE(INTEL, 0x082C), medfield_0 },
322 { PCI_VDEVICE(INTEL, 0x082D), medfield_1 }, 321 { PCI_VDEVICE(INTEL, 0x082D), medfield_1 },
323 { PCI_VDEVICE(INTEL, 0x082E), medfield_2 }, 322 { PCI_VDEVICE(INTEL, 0x082E), medfield_2 },
323 /* Baytrail */
324 { PCI_VDEVICE(INTEL, 0x0F41), baytrail },
325 { PCI_VDEVICE(INTEL, 0x0F42), baytrail },
326 { PCI_VDEVICE(INTEL, 0x0F43), baytrail },
327 { PCI_VDEVICE(INTEL, 0x0F44), baytrail },
328 { PCI_VDEVICE(INTEL, 0x0F45), baytrail },
329 { PCI_VDEVICE(INTEL, 0x0F46), baytrail },
330 { PCI_VDEVICE(INTEL, 0x0F47), baytrail },
324 { 0,} 331 { 0,}
325}; 332};
326MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids); 333MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d0bdac0498ce..9c7802614342 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -159,6 +159,13 @@ static int dw_i2c_probe(struct platform_device *pdev)
159 "i2c-sda-hold-time-ns", &ht); 159 "i2c-sda-hold-time-ns", &ht);
160 dev->sda_hold_time = div_u64((u64)ic_clk * ht + 500000, 160 dev->sda_hold_time = div_u64((u64)ic_clk * ht + 500000,
161 1000000); 161 1000000);
162
163 of_property_read_u32(pdev->dev.of_node,
164 "i2c-sda-falling-time-ns",
165 &dev->sda_falling_time);
166 of_property_read_u32(pdev->dev.of_node,
167 "i2c-scl-falling-time-ns",
168 &dev->scl_falling_time);
162 } 169 }
163 170
164 dev->functionality = 171 dev->functionality =
@@ -195,7 +202,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
195 adap = &dev->adapter; 202 adap = &dev->adapter;
196 i2c_set_adapdata(adap, dev); 203 i2c_set_adapdata(adap, dev);
197 adap->owner = THIS_MODULE; 204 adap->owner = THIS_MODULE;
198 adap->class = I2C_CLASS_HWMON; 205 adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
199 strlcpy(adap->name, "Synopsys DesignWare I2C adapter", 206 strlcpy(adap->name, "Synopsys DesignWare I2C adapter",
200 sizeof(adap->name)); 207 sizeof(adap->name));
201 adap->algo = &i2c_dw_algo; 208 adap->algo = &i2c_dw_algo;
diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
new file mode 100644
index 000000000000..777ed409a24a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-efm32.c
@@ -0,0 +1,481 @@
1/*
2 * Copyright (C) 2014 Uwe Kleine-Koenig for Pengutronix
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License version 2 as published by the
6 * Free Software Foundation.
7 */
8#include <linux/module.h>
9#include <linux/platform_device.h>
10#include <linux/i2c.h>
11#include <linux/io.h>
12#include <linux/interrupt.h>
13#include <linux/err.h>
14#include <linux/clk.h>
15
16#define DRIVER_NAME "efm32-i2c"
17
18#define MASK_VAL(mask, val) ((val << __ffs(mask)) & mask)
19
20#define REG_CTRL 0x00
21#define REG_CTRL_EN 0x00001
22#define REG_CTRL_SLAVE 0x00002
23#define REG_CTRL_AUTOACK 0x00004
24#define REG_CTRL_AUTOSE 0x00008
25#define REG_CTRL_AUTOSN 0x00010
26#define REG_CTRL_ARBDIS 0x00020
27#define REG_CTRL_GCAMEN 0x00040
28#define REG_CTRL_CLHR__MASK 0x00300
29#define REG_CTRL_BITO__MASK 0x03000
30#define REG_CTRL_BITO_OFF 0x00000
31#define REG_CTRL_BITO_40PCC 0x01000
32#define REG_CTRL_BITO_80PCC 0x02000
33#define REG_CTRL_BITO_160PCC 0x03000
34#define REG_CTRL_GIBITO 0x08000
35#define REG_CTRL_CLTO__MASK 0x70000
36#define REG_CTRL_CLTO_OFF 0x00000
37
38#define REG_CMD 0x04
39#define REG_CMD_START 0x00001
40#define REG_CMD_STOP 0x00002
41#define REG_CMD_ACK 0x00004
42#define REG_CMD_NACK 0x00008
43#define REG_CMD_CONT 0x00010
44#define REG_CMD_ABORT 0x00020
45#define REG_CMD_CLEARTX 0x00040
46#define REG_CMD_CLEARPC 0x00080
47
48#define REG_STATE 0x08
49#define REG_STATE_BUSY 0x00001
50#define REG_STATE_MASTER 0x00002
51#define REG_STATE_TRANSMITTER 0x00004
52#define REG_STATE_NACKED 0x00008
53#define REG_STATE_BUSHOLD 0x00010
54#define REG_STATE_STATE__MASK 0x000e0
55#define REG_STATE_STATE_IDLE 0x00000
56#define REG_STATE_STATE_WAIT 0x00020
57#define REG_STATE_STATE_START 0x00040
58#define REG_STATE_STATE_ADDR 0x00060
59#define REG_STATE_STATE_ADDRACK 0x00080
60#define REG_STATE_STATE_DATA 0x000a0
61#define REG_STATE_STATE_DATAACK 0x000c0
62
63#define REG_STATUS 0x0c
64#define REG_STATUS_PSTART 0x00001
65#define REG_STATUS_PSTOP 0x00002
66#define REG_STATUS_PACK 0x00004
67#define REG_STATUS_PNACK 0x00008
68#define REG_STATUS_PCONT 0x00010
69#define REG_STATUS_PABORT 0x00020
70#define REG_STATUS_TXC 0x00040
71#define REG_STATUS_TXBL 0x00080
72#define REG_STATUS_RXDATAV 0x00100
73
74#define REG_CLKDIV 0x10
75#define REG_CLKDIV_DIV__MASK 0x001ff
76#define REG_CLKDIV_DIV(div) MASK_VAL(REG_CLKDIV_DIV__MASK, (div))
77
78#define REG_SADDR 0x14
79#define REG_SADDRMASK 0x18
80#define REG_RXDATA 0x1c
81#define REG_RXDATAP 0x20
82#define REG_TXDATA 0x24
83#define REG_IF 0x28
84#define REG_IF_START 0x00001
85#define REG_IF_RSTART 0x00002
86#define REG_IF_ADDR 0x00004
87#define REG_IF_TXC 0x00008
88#define REG_IF_TXBL 0x00010
89#define REG_IF_RXDATAV 0x00020
90#define REG_IF_ACK 0x00040
91#define REG_IF_NACK 0x00080
92#define REG_IF_MSTOP 0x00100
93#define REG_IF_ARBLOST 0x00200
94#define REG_IF_BUSERR 0x00400
95#define REG_IF_BUSHOLD 0x00800
96#define REG_IF_TXOF 0x01000
97#define REG_IF_RXUF 0x02000
98#define REG_IF_BITO 0x04000
99#define REG_IF_CLTO 0x08000
100#define REG_IF_SSTOP 0x10000
101
102#define REG_IFS 0x2c
103#define REG_IFC 0x30
104#define REG_IFC__MASK 0x1ffcf
105
106#define REG_IEN 0x34
107
108#define REG_ROUTE 0x38
109#define REG_ROUTE_SDAPEN 0x00001
110#define REG_ROUTE_SCLPEN 0x00002
111#define REG_ROUTE_LOCATION__MASK 0x00700
112#define REG_ROUTE_LOCATION(n) MASK_VAL(REG_ROUTE_LOCATION__MASK, (n))
113
114struct efm32_i2c_ddata {
115 struct i2c_adapter adapter;
116
117 struct clk *clk;
118 void __iomem *base;
119 unsigned int irq;
120 u8 location;
121 unsigned long frequency;
122
123 /* transfer data */
124 struct completion done;
125 struct i2c_msg *msgs;
126 size_t num_msgs;
127 size_t current_word, current_msg;
128 int retval;
129};
130
131static u32 efm32_i2c_read32(struct efm32_i2c_ddata *ddata, unsigned offset)
132{
133 return readl(ddata->base + offset);
134}
135
136static void efm32_i2c_write32(struct efm32_i2c_ddata *ddata,
137 unsigned offset, u32 value)
138{
139 writel(value, ddata->base + offset);
140}
141
142static void efm32_i2c_send_next_msg(struct efm32_i2c_ddata *ddata)
143{
144 struct i2c_msg *cur_msg = &ddata->msgs[ddata->current_msg];
145
146 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_START);
147 efm32_i2c_write32(ddata, REG_TXDATA, cur_msg->addr << 1 |
148 (cur_msg->flags & I2C_M_RD ? 1 : 0));
149}
150
151static void efm32_i2c_send_next_byte(struct efm32_i2c_ddata *ddata)
152{
153 struct i2c_msg *cur_msg = &ddata->msgs[ddata->current_msg];
154
155 if (ddata->current_word >= cur_msg->len) {
156 /* cur_msg completely transferred */
157 ddata->current_word = 0;
158 ddata->current_msg += 1;
159
160 if (ddata->current_msg >= ddata->num_msgs) {
161 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_STOP);
162 complete(&ddata->done);
163 } else {
164 efm32_i2c_send_next_msg(ddata);
165 }
166 } else {
167 efm32_i2c_write32(ddata, REG_TXDATA,
168 cur_msg->buf[ddata->current_word++]);
169 }
170}
171
172static void efm32_i2c_recv_next_byte(struct efm32_i2c_ddata *ddata)
173{
174 struct i2c_msg *cur_msg = &ddata->msgs[ddata->current_msg];
175
176 cur_msg->buf[ddata->current_word] = efm32_i2c_read32(ddata, REG_RXDATA);
177 ddata->current_word += 1;
178 if (ddata->current_word >= cur_msg->len) {
179 /* cur_msg completely transferred */
180 ddata->current_word = 0;
181 ddata->current_msg += 1;
182
183 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_NACK);
184
185 if (ddata->current_msg >= ddata->num_msgs) {
186 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_STOP);
187 complete(&ddata->done);
188 } else {
189 efm32_i2c_send_next_msg(ddata);
190 }
191 } else {
192 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_ACK);
193 }
194}
195
196static irqreturn_t efm32_i2c_irq(int irq, void *dev_id)
197{
198 struct efm32_i2c_ddata *ddata = dev_id;
199 struct i2c_msg *cur_msg = &ddata->msgs[ddata->current_msg];
200 u32 irqflag = efm32_i2c_read32(ddata, REG_IF);
201 u32 state = efm32_i2c_read32(ddata, REG_STATE);
202
203 efm32_i2c_write32(ddata, REG_IFC, irqflag & REG_IFC__MASK);
204
205 switch (state & REG_STATE_STATE__MASK) {
206 case REG_STATE_STATE_IDLE:
207 /* arbitration lost? */
208 ddata->retval = -EAGAIN;
209 complete(&ddata->done);
210 break;
211 case REG_STATE_STATE_WAIT:
212 /*
213 * huh, this shouldn't happen.
214 * Reset hardware state and get out
215 */
216 ddata->retval = -EIO;
217 efm32_i2c_write32(ddata, REG_CMD,
218 REG_CMD_STOP | REG_CMD_ABORT |
219 REG_CMD_CLEARTX | REG_CMD_CLEARPC);
220 complete(&ddata->done);
221 break;
222 case REG_STATE_STATE_START:
223 /* "caller" is expected to send an address */
224 break;
225 case REG_STATE_STATE_ADDR:
226 /* wait for Ack or NAck of slave */
227 break;
228 case REG_STATE_STATE_ADDRACK:
229 if (state & REG_STATE_NACKED) {
230 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_STOP);
231 ddata->retval = -ENXIO;
232 complete(&ddata->done);
233 } else if (cur_msg->flags & I2C_M_RD) {
234 /* wait for slave to send first data byte */
235 } else {
236 efm32_i2c_send_next_byte(ddata);
237 }
238 break;
239 case REG_STATE_STATE_DATA:
240 if (cur_msg->flags & I2C_M_RD) {
241 efm32_i2c_recv_next_byte(ddata);
242 } else {
243 /* wait for Ack or Nack of slave */
244 }
245 break;
246 case REG_STATE_STATE_DATAACK:
247 if (state & REG_STATE_NACKED) {
248 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_STOP);
249 complete(&ddata->done);
250 } else {
251 efm32_i2c_send_next_byte(ddata);
252 }
253 }
254
255 return IRQ_HANDLED;
256}
257
258static int efm32_i2c_master_xfer(struct i2c_adapter *adap,
259 struct i2c_msg *msgs, int num)
260{
261 struct efm32_i2c_ddata *ddata = i2c_get_adapdata(adap);
262 int ret;
263
264 if (ddata->msgs)
265 return -EBUSY;
266
267 ddata->msgs = msgs;
268 ddata->num_msgs = num;
269 ddata->current_word = 0;
270 ddata->current_msg = 0;
271 ddata->retval = -EIO;
272
273 reinit_completion(&ddata->done);
274
275 dev_dbg(&ddata->adapter.dev, "state: %08x, status: %08x\n",
276 efm32_i2c_read32(ddata, REG_STATE),
277 efm32_i2c_read32(ddata, REG_STATUS));
278
279 efm32_i2c_send_next_msg(ddata);
280
281 wait_for_completion(&ddata->done);
282
283 if (ddata->current_msg >= ddata->num_msgs)
284 ret = ddata->num_msgs;
285 else
286 ret = ddata->retval;
287
288 return ret;
289}
290
291static u32 efm32_i2c_functionality(struct i2c_adapter *adap)
292{
293 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
294}
295
296static const struct i2c_algorithm efm32_i2c_algo = {
297 .master_xfer = efm32_i2c_master_xfer,
298 .functionality = efm32_i2c_functionality,
299};
300
301static u32 efm32_i2c_get_configured_location(struct efm32_i2c_ddata *ddata)
302{
303 u32 reg = efm32_i2c_read32(ddata, REG_ROUTE);
304
305 return (reg & REG_ROUTE_LOCATION__MASK) >>
306 __ffs(REG_ROUTE_LOCATION__MASK);
307}
308
309static int efm32_i2c_probe(struct platform_device *pdev)
310{
311 struct efm32_i2c_ddata *ddata;
312 struct resource *res;
313 unsigned long rate;
314 struct device_node *np = pdev->dev.of_node;
315 u32 location, frequency;
316 int ret;
317 u32 clkdiv;
318
319 if (!np)
320 return -EINVAL;
321
322 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
323 if (!ddata) {
324 dev_dbg(&pdev->dev, "failed to allocate private data\n");
325 return -ENOMEM;
326 }
327 platform_set_drvdata(pdev, ddata);
328
329 init_completion(&ddata->done);
330 strlcpy(ddata->adapter.name, pdev->name, sizeof(ddata->adapter.name));
331 ddata->adapter.owner = THIS_MODULE;
332 ddata->adapter.algo = &efm32_i2c_algo;
333 ddata->adapter.dev.parent = &pdev->dev;
334 ddata->adapter.dev.of_node = pdev->dev.of_node;
335 i2c_set_adapdata(&ddata->adapter, ddata);
336
337 ddata->clk = devm_clk_get(&pdev->dev, NULL);
338 if (IS_ERR(ddata->clk)) {
339 ret = PTR_ERR(ddata->clk);
340 dev_err(&pdev->dev, "failed to get clock: %d\n", ret);
341 return ret;
342 }
343
344 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
345 if (!res) {
346 dev_err(&pdev->dev, "failed to determine base address\n");
347 return -ENODEV;
348 }
349
350 if (resource_size(res) < 0x42) {
351 dev_err(&pdev->dev, "memory resource too small\n");
352 return -EINVAL;
353 }
354
355 ddata->base = devm_ioremap_resource(&pdev->dev, res);
356 if (IS_ERR(ddata->base))
357 return PTR_ERR(ddata->base);
358
359 ret = platform_get_irq(pdev, 0);
360 if (ret <= 0) {
361 dev_err(&pdev->dev, "failed to get irq (%d)\n", ret);
362 if (!ret)
363 ret = -EINVAL;
364 return ret;
365 }
366
367 ddata->irq = ret;
368
369 ret = clk_prepare_enable(ddata->clk);
370 if (ret < 0) {
371 dev_err(&pdev->dev, "failed to enable clock (%d)\n", ret);
372 return ret;
373 }
374
375 ret = of_property_read_u32(np, "efm32,location", &location);
376 if (!ret) {
377 dev_dbg(&pdev->dev, "using location %u\n", location);
378 } else {
379 /* default to location configured in hardware */
380 location = efm32_i2c_get_configured_location(ddata);
381
382 dev_info(&pdev->dev, "fall back to location %u\n", location);
383 }
384
385 ddata->location = location;
386
387 ret = of_property_read_u32(np, "clock-frequency", &frequency);
388 if (!ret) {
389 dev_dbg(&pdev->dev, "using frequency %u\n", frequency);
390 } else {
391 frequency = 100000;
392 dev_info(&pdev->dev, "defaulting to 100 kHz\n");
393 }
394 ddata->frequency = frequency;
395
396 rate = clk_get_rate(ddata->clk);
397 if (!rate) {
398 dev_err(&pdev->dev, "there is no input clock available\n");
399 ret = -EINVAL;
400 goto err_disable_clk;
401 }
402 clkdiv = DIV_ROUND_UP(rate, 8 * ddata->frequency) - 1;
403 if (clkdiv >= 0x200) {
404 dev_err(&pdev->dev,
405 "input clock too fast (%lu) to divide down to bus freq (%lu)",
406 rate, ddata->frequency);
407 ret = -EINVAL;
408 goto err_disable_clk;
409 }
410
411 dev_dbg(&pdev->dev, "input clock = %lu, bus freq = %lu, clkdiv = %lu\n",
412 rate, ddata->frequency, (unsigned long)clkdiv);
413 efm32_i2c_write32(ddata, REG_CLKDIV, REG_CLKDIV_DIV(clkdiv));
414
415 efm32_i2c_write32(ddata, REG_ROUTE, REG_ROUTE_SDAPEN |
416 REG_ROUTE_SCLPEN |
417 REG_ROUTE_LOCATION(ddata->location));
418
419 efm32_i2c_write32(ddata, REG_CTRL, REG_CTRL_EN |
420 REG_CTRL_BITO_160PCC | 0 * REG_CTRL_GIBITO);
421
422 efm32_i2c_write32(ddata, REG_IFC, REG_IFC__MASK);
423 efm32_i2c_write32(ddata, REG_IEN, REG_IF_TXC | REG_IF_ACK | REG_IF_NACK
424 | REG_IF_ARBLOST | REG_IF_BUSERR | REG_IF_RXDATAV);
425
426 /* to make bus idle */
427 efm32_i2c_write32(ddata, REG_CMD, REG_CMD_ABORT);
428
429 ret = request_irq(ddata->irq, efm32_i2c_irq, 0, DRIVER_NAME, ddata);
430 if (ret < 0) {
431 dev_err(&pdev->dev, "failed to request irq (%d)\n", ret);
432 return ret;
433 }
434
435 ret = i2c_add_adapter(&ddata->adapter);
436 if (ret) {
437 dev_err(&pdev->dev, "failed to add i2c adapter (%d)\n", ret);
438 free_irq(ddata->irq, ddata);
439
440err_disable_clk:
441 clk_disable_unprepare(ddata->clk);
442 }
443 return ret;
444}
445
446static int efm32_i2c_remove(struct platform_device *pdev)
447{
448 struct efm32_i2c_ddata *ddata = platform_get_drvdata(pdev);
449
450 i2c_del_adapter(&ddata->adapter);
451 free_irq(ddata->irq, ddata);
452 clk_disable_unprepare(ddata->clk);
453
454 return 0;
455}
456
457static const struct of_device_id efm32_i2c_dt_ids[] = {
458 {
459 .compatible = "energymicro,efm32-i2c",
460 }, {
461 /* sentinel */
462 }
463};
464MODULE_DEVICE_TABLE(of, efm32_i2c_dt_ids);
465
466static struct platform_driver efm32_i2c_driver = {
467 .probe = efm32_i2c_probe,
468 .remove = efm32_i2c_remove,
469
470 .driver = {
471 .name = DRIVER_NAME,
472 .owner = THIS_MODULE,
473 .of_match_table = efm32_i2c_dt_ids,
474 },
475};
476module_platform_driver(efm32_i2c_driver);
477
478MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");
479MODULE_DESCRIPTION("EFM32 i2c driver");
480MODULE_LICENSE("GPL v2");
481MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index e08e458bab02..ff775ac29e49 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -186,7 +186,7 @@ static DEFINE_MUTEX(pch_mutex);
186#define PCI_DEVICE_ID_ML7223_I2C 0x8010 186#define PCI_DEVICE_ID_ML7223_I2C 0x8010
187#define PCI_DEVICE_ID_ML7831_I2C 0x8817 187#define PCI_DEVICE_ID_ML7831_I2C 0x8817
188 188
189static DEFINE_PCI_DEVICE_TABLE(pch_pcidev_id) = { 189static const struct pci_device_id pch_pcidev_id[] = {
190 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C), 1, }, 190 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C), 1, },
191 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, }, 191 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, },
192 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_I2C), 1, }, 192 { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_I2C), 1, },
diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index 9fd711c03dd2..00af0a0a3361 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -566,7 +566,7 @@ static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c,
566static int exynos5_i2c_xfer(struct i2c_adapter *adap, 566static int exynos5_i2c_xfer(struct i2c_adapter *adap,
567 struct i2c_msg *msgs, int num) 567 struct i2c_msg *msgs, int num)
568{ 568{
569 struct exynos5_i2c *i2c = (struct exynos5_i2c *)adap->algo_data; 569 struct exynos5_i2c *i2c = adap->algo_data;
570 int i = 0, ret = 0, stop = 0; 570 int i = 0, ret = 0, stop = 0;
571 571
572 if (i2c->suspended) { 572 if (i2c->suspended) {
@@ -715,6 +715,7 @@ static int exynos5_i2c_remove(struct platform_device *pdev)
715 return 0; 715 return 0;
716} 716}
717 717
718#ifdef CONFIG_PM_SLEEP
718static int exynos5_i2c_suspend_noirq(struct device *dev) 719static int exynos5_i2c_suspend_noirq(struct device *dev)
719{ 720{
720 struct platform_device *pdev = to_platform_device(dev); 721 struct platform_device *pdev = to_platform_device(dev);
@@ -745,6 +746,7 @@ static int exynos5_i2c_resume_noirq(struct device *dev)
745 746
746 return 0; 747 return 0;
747} 748}
749#endif
748 750
749static SIMPLE_DEV_PM_OPS(exynos5_i2c_dev_pm_ops, exynos5_i2c_suspend_noirq, 751static SIMPLE_DEV_PM_OPS(exynos5_i2c_dev_pm_ops, exynos5_i2c_suspend_noirq,
750 exynos5_i2c_resume_noirq); 752 exynos5_i2c_resume_noirq);
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index d9f7e186a4c7..02d2d4abb9dd 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -94,6 +94,9 @@ static int of_i2c_gpio_get_pins(struct device_node *np,
94 *sda_pin = of_get_gpio(np, 0); 94 *sda_pin = of_get_gpio(np, 0);
95 *scl_pin = of_get_gpio(np, 1); 95 *scl_pin = of_get_gpio(np, 1);
96 96
97 if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER)
98 return -EPROBE_DEFER;
99
97 if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { 100 if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) {
98 pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", 101 pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n",
99 np->full_name, *sda_pin, *scl_pin); 102 np->full_name, *sda_pin, *scl_pin);
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index e248257fe517..14d2b76de25f 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -104,7 +104,7 @@ static struct i2c_adapter hydra_adap = {
104 .algo_data = &hydra_bit_data, 104 .algo_data = &hydra_bit_data,
105}; 105};
106 106
107static DEFINE_PCI_DEVICE_TABLE(hydra_ids) = { 107static const struct pci_device_id hydra_ids[] = {
108 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_HYDRA) }, 108 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_HYDRA) },
109 { 0, } 109 { 0, }
110}; 110};
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 349c2d35e792..6777cd6f8776 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -60,6 +60,7 @@
60 Wellsburg (PCH) MS 0x8d7f 32 hard yes yes yes 60 Wellsburg (PCH) MS 0x8d7f 32 hard yes yes yes
61 Coleto Creek (PCH) 0x23b0 32 hard yes yes yes 61 Coleto Creek (PCH) 0x23b0 32 hard yes yes yes
62 Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes 62 Wildcat Point-LP (PCH) 0x9ca2 32 hard yes yes yes
63 BayTrail (SOC) 0x0f12 32 hard yes yes yes
63 64
64 Features supported by this driver: 65 Features supported by this driver:
65 Software PEC no 66 Software PEC no
@@ -161,6 +162,7 @@
161 STATUS_ERROR_FLAGS) 162 STATUS_ERROR_FLAGS)
162 163
163/* Older devices have their ID defined in <linux/pci_ids.h> */ 164/* Older devices have their ID defined in <linux/pci_ids.h> */
165#define PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS 0x0f12
164#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 166#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22
165#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22 167#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22
166/* Patsburg also has three 'Integrated Device Function' SMBus controllers */ 168/* Patsburg also has three 'Integrated Device Function' SMBus controllers */
@@ -789,7 +791,7 @@ static const struct i2c_algorithm smbus_algorithm = {
789 .functionality = i801_func, 791 .functionality = i801_func,
790}; 792};
791 793
792static DEFINE_PCI_DEVICE_TABLE(i801_ids) = { 794static const struct pci_device_id i801_ids[] = {
793 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) }, 795 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) },
794 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) }, 796 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) },
795 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) }, 797 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) },
@@ -822,6 +824,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
822 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2) }, 824 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2) },
823 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS) }, 825 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS) },
824 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_SMBUS) }, 826 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_SMBUS) },
827 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS) },
825 { 0, } 828 { 0, }
826}; 829};
827 830
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 8ce4f517fc56..984492553e95 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -182,7 +182,7 @@ struct ismt_priv {
182/** 182/**
183 * ismt_ids - PCI device IDs supported by this driver 183 * ismt_ids - PCI device IDs supported by this driver
184 */ 184 */
185static DEFINE_PCI_DEVICE_TABLE(ismt_ids) = { 185static const struct pci_device_id ismt_ids[] = {
186 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT0) }, 186 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT0) },
187 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT1) }, 187 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT1) },
188 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_AVOTON_SMT) }, 188 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_AVOTON_SMT) },
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index d52d84937ad3..540ea692bf79 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -17,6 +17,7 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/mv643xx_i2c.h> 18#include <linux/mv643xx_i2c.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/reset.h>
20#include <linux/io.h> 21#include <linux/io.h>
21#include <linux/of.h> 22#include <linux/of.h>
22#include <linux/of_device.h> 23#include <linux/of_device.h>
@@ -97,7 +98,6 @@ enum {
97enum { 98enum {
98 MV64XXX_I2C_ACTION_INVALID, 99 MV64XXX_I2C_ACTION_INVALID,
99 MV64XXX_I2C_ACTION_CONTINUE, 100 MV64XXX_I2C_ACTION_CONTINUE,
100 MV64XXX_I2C_ACTION_SEND_START,
101 MV64XXX_I2C_ACTION_SEND_RESTART, 101 MV64XXX_I2C_ACTION_SEND_RESTART,
102 MV64XXX_I2C_ACTION_OFFLOAD_RESTART, 102 MV64XXX_I2C_ACTION_OFFLOAD_RESTART,
103 MV64XXX_I2C_ACTION_SEND_ADDR_1, 103 MV64XXX_I2C_ACTION_SEND_ADDR_1,
@@ -148,6 +148,8 @@ struct mv64xxx_i2c_data {
148 bool offload_enabled; 148 bool offload_enabled;
149/* 5us delay in order to avoid repeated start timing violation */ 149/* 5us delay in order to avoid repeated start timing violation */
150 bool errata_delay; 150 bool errata_delay;
151 struct reset_control *rstc;
152 bool irq_clear_inverted;
151}; 153};
152 154
153static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = { 155static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = {
@@ -176,11 +178,6 @@ mv64xxx_i2c_prepare_for_io(struct mv64xxx_i2c_data *drv_data,
176{ 178{
177 u32 dir = 0; 179 u32 dir = 0;
178 180
179 drv_data->msg = msg;
180 drv_data->byte_posn = 0;
181 drv_data->bytes_left = msg->len;
182 drv_data->aborting = 0;
183 drv_data->rc = 0;
184 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | 181 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK |
185 MV64XXX_I2C_REG_CONTROL_INTEN | MV64XXX_I2C_REG_CONTROL_TWSIEN; 182 MV64XXX_I2C_REG_CONTROL_INTEN | MV64XXX_I2C_REG_CONTROL_TWSIEN;
186 183
@@ -206,11 +203,6 @@ static int mv64xxx_i2c_offload_msg(struct mv64xxx_i2c_data *drv_data)
206 if (!drv_data->offload_enabled) 203 if (!drv_data->offload_enabled)
207 return -EOPNOTSUPP; 204 return -EOPNOTSUPP;
208 205
209 drv_data->msg = msg;
210 drv_data->byte_posn = 0;
211 drv_data->bytes_left = msg->len;
212 drv_data->aborting = 0;
213 drv_data->rc = 0;
214 /* Only regular transactions can be offloaded */ 206 /* Only regular transactions can be offloaded */
215 if ((msg->flags & ~(I2C_M_TEN | I2C_M_RD)) != 0) 207 if ((msg->flags & ~(I2C_M_TEN | I2C_M_RD)) != 0)
216 return -EINVAL; 208 return -EINVAL;
@@ -419,6 +411,23 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
419 } 411 }
420} 412}
421 413
414static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data)
415{
416 drv_data->msg = drv_data->msgs;
417 drv_data->byte_posn = 0;
418 drv_data->bytes_left = drv_data->msg->len;
419 drv_data->aborting = 0;
420 drv_data->rc = 0;
421
422 /* Can we offload this msg ? */
423 if (mv64xxx_i2c_offload_msg(drv_data) < 0) {
424 /* No, switch to standard path */
425 mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs);
426 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START,
427 drv_data->reg_base + drv_data->reg_offsets.control);
428 }
429}
430
422static void 431static void
423mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) 432mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data)
424{ 433{
@@ -435,14 +444,8 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data)
435 444
436 drv_data->msgs++; 445 drv_data->msgs++;
437 drv_data->num_msgs--; 446 drv_data->num_msgs--;
438 if (mv64xxx_i2c_offload_msg(drv_data) < 0) { 447 mv64xxx_i2c_send_start(drv_data);
439 drv_data->cntl_bits |= MV64XXX_I2C_REG_CONTROL_START;
440 writel(drv_data->cntl_bits,
441 drv_data->reg_base + drv_data->reg_offsets.control);
442 448
443 /* Setup for the next message */
444 mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs);
445 }
446 if (drv_data->errata_delay) 449 if (drv_data->errata_delay)
447 udelay(5); 450 udelay(5);
448 451
@@ -459,16 +462,6 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data)
459 drv_data->reg_base + drv_data->reg_offsets.control); 462 drv_data->reg_base + drv_data->reg_offsets.control);
460 break; 463 break;
461 464
462 case MV64XXX_I2C_ACTION_SEND_START:
463 /* Can we offload this msg ? */
464 if (mv64xxx_i2c_offload_msg(drv_data) < 0) {
465 /* No, switch to standard path */
466 mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs);
467 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START,
468 drv_data->reg_base + drv_data->reg_offsets.control);
469 }
470 break;
471
472 case MV64XXX_I2C_ACTION_SEND_ADDR_1: 465 case MV64XXX_I2C_ACTION_SEND_ADDR_1:
473 writel(drv_data->addr1, 466 writel(drv_data->addr1,
474 drv_data->reg_base + drv_data->reg_offsets.data); 467 drv_data->reg_base + drv_data->reg_offsets.data);
@@ -566,6 +559,11 @@ mv64xxx_i2c_intr(int irq, void *dev_id)
566 status = readl(drv_data->reg_base + drv_data->reg_offsets.status); 559 status = readl(drv_data->reg_base + drv_data->reg_offsets.status);
567 mv64xxx_i2c_fsm(drv_data, status); 560 mv64xxx_i2c_fsm(drv_data, status);
568 mv64xxx_i2c_do_action(drv_data); 561 mv64xxx_i2c_do_action(drv_data);
562
563 if (drv_data->irq_clear_inverted)
564 writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_IFLG,
565 drv_data->reg_base + drv_data->reg_offsets.control);
566
569 rc = IRQ_HANDLED; 567 rc = IRQ_HANDLED;
570 } 568 }
571 spin_unlock_irqrestore(&drv_data->lock, flags); 569 spin_unlock_irqrestore(&drv_data->lock, flags);
@@ -626,12 +624,11 @@ mv64xxx_i2c_execute_msg(struct mv64xxx_i2c_data *drv_data, struct i2c_msg *msg,
626 624
627 spin_lock_irqsave(&drv_data->lock, flags); 625 spin_lock_irqsave(&drv_data->lock, flags);
628 626
629 drv_data->action = MV64XXX_I2C_ACTION_SEND_START;
630 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; 627 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND;
631 628
632 drv_data->send_stop = is_last; 629 drv_data->send_stop = is_last;
633 drv_data->block = 1; 630 drv_data->block = 1;
634 mv64xxx_i2c_do_action(drv_data); 631 mv64xxx_i2c_send_start(drv_data);
635 spin_unlock_irqrestore(&drv_data->lock, flags); 632 spin_unlock_irqrestore(&drv_data->lock, flags);
636 633
637 mv64xxx_i2c_wait_for_completion(drv_data); 634 mv64xxx_i2c_wait_for_completion(drv_data);
@@ -685,6 +682,7 @@ static const struct i2c_algorithm mv64xxx_i2c_algo = {
685 */ 682 */
686static const struct of_device_id mv64xxx_i2c_of_match_table[] = { 683static const struct of_device_id mv64xxx_i2c_of_match_table[] = {
687 { .compatible = "allwinner,sun4i-i2c", .data = &mv64xxx_i2c_regs_sun4i}, 684 { .compatible = "allwinner,sun4i-i2c", .data = &mv64xxx_i2c_regs_sun4i},
685 { .compatible = "allwinner,sun6i-a31-i2c", .data = &mv64xxx_i2c_regs_sun4i},
688 { .compatible = "marvell,mv64xxx-i2c", .data = &mv64xxx_i2c_regs_mv64xxx}, 686 { .compatible = "marvell,mv64xxx-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
689 { .compatible = "marvell,mv78230-i2c", .data = &mv64xxx_i2c_regs_mv64xxx}, 687 { .compatible = "marvell,mv78230-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
690 { .compatible = "marvell,mv78230-a0-i2c", .data = &mv64xxx_i2c_regs_mv64xxx}, 688 { .compatible = "marvell,mv78230-a0-i2c", .data = &mv64xxx_i2c_regs_mv64xxx},
@@ -759,6 +757,16 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
759 } 757 }
760 drv_data->irq = irq_of_parse_and_map(np, 0); 758 drv_data->irq = irq_of_parse_and_map(np, 0);
761 759
760 drv_data->rstc = devm_reset_control_get_optional(dev, NULL);
761 if (IS_ERR(drv_data->rstc)) {
762 if (PTR_ERR(drv_data->rstc) == -EPROBE_DEFER) {
763 rc = -EPROBE_DEFER;
764 goto out;
765 }
766 } else {
767 reset_control_deassert(drv_data->rstc);
768 }
769
762 /* Its not yet defined how timeouts will be specified in device tree. 770 /* Its not yet defined how timeouts will be specified in device tree.
763 * So hard code the value to 1 second. 771 * So hard code the value to 1 second.
764 */ 772 */
@@ -783,6 +791,10 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
783 drv_data->offload_enabled = false; 791 drv_data->offload_enabled = false;
784 drv_data->errata_delay = true; 792 drv_data->errata_delay = true;
785 } 793 }
794
795 if (of_device_is_compatible(np, "allwinner,sun6i-a31-i2c"))
796 drv_data->irq_clear_inverted = true;
797
786out: 798out:
787 return rc; 799 return rc;
788#endif 800#endif
@@ -845,13 +857,13 @@ mv64xxx_i2c_probe(struct platform_device *pd)
845 } 857 }
846 if (drv_data->irq < 0) { 858 if (drv_data->irq < 0) {
847 rc = -ENXIO; 859 rc = -ENXIO;
848 goto exit_clk; 860 goto exit_reset;
849 } 861 }
850 862
851 drv_data->adapter.dev.parent = &pd->dev; 863 drv_data->adapter.dev.parent = &pd->dev;
852 drv_data->adapter.algo = &mv64xxx_i2c_algo; 864 drv_data->adapter.algo = &mv64xxx_i2c_algo;
853 drv_data->adapter.owner = THIS_MODULE; 865 drv_data->adapter.owner = THIS_MODULE;
854 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 866 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
855 drv_data->adapter.nr = pd->id; 867 drv_data->adapter.nr = pd->id;
856 drv_data->adapter.dev.of_node = pd->dev.of_node; 868 drv_data->adapter.dev.of_node = pd->dev.of_node;
857 platform_set_drvdata(pd, drv_data); 869 platform_set_drvdata(pd, drv_data);
@@ -865,7 +877,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
865 dev_err(&drv_data->adapter.dev, 877 dev_err(&drv_data->adapter.dev,
866 "mv64xxx: Can't register intr handler irq%d: %d\n", 878 "mv64xxx: Can't register intr handler irq%d: %d\n",
867 drv_data->irq, rc); 879 drv_data->irq, rc);
868 goto exit_clk; 880 goto exit_reset;
869 } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) { 881 } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) {
870 dev_err(&drv_data->adapter.dev, 882 dev_err(&drv_data->adapter.dev,
871 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); 883 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc);
@@ -876,6 +888,9 @@ mv64xxx_i2c_probe(struct platform_device *pd)
876 888
877exit_free_irq: 889exit_free_irq:
878 free_irq(drv_data->irq, drv_data); 890 free_irq(drv_data->irq, drv_data);
891exit_reset:
892 if (!IS_ERR_OR_NULL(drv_data->rstc))
893 reset_control_assert(drv_data->rstc);
879exit_clk: 894exit_clk:
880#if defined(CONFIG_HAVE_CLK) 895#if defined(CONFIG_HAVE_CLK)
881 /* Not all platforms have a clk */ 896 /* Not all platforms have a clk */
@@ -894,6 +909,8 @@ mv64xxx_i2c_remove(struct platform_device *dev)
894 909
895 i2c_del_adapter(&drv_data->adapter); 910 i2c_del_adapter(&drv_data->adapter);
896 free_irq(drv_data->irq, drv_data); 911 free_irq(drv_data->irq, drv_data);
912 if (!IS_ERR_OR_NULL(drv_data->rstc))
913 reset_control_assert(drv_data->rstc);
897#if defined(CONFIG_HAVE_CLK) 914#if defined(CONFIG_HAVE_CLK)
898 /* Not all platforms have a clk */ 915 /* Not all platforms have a clk */
899 if (!IS_ERR(drv_data->clk)) { 916 if (!IS_ERR(drv_data->clk)) {
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 0cde4e6ab2b2..7170fc892829 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -806,7 +806,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
806 struct mxs_i2c_dev *i2c; 806 struct mxs_i2c_dev *i2c;
807 struct i2c_adapter *adap; 807 struct i2c_adapter *adap;
808 struct resource *res; 808 struct resource *res;
809 resource_size_t res_size;
810 int err, irq; 809 int err, irq;
811 810
812 i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL); 811 i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL);
@@ -819,18 +818,13 @@ static int mxs_i2c_probe(struct platform_device *pdev)
819 } 818 }
820 819
821 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 820 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
822 irq = platform_get_irq(pdev, 0); 821 i2c->regs = devm_ioremap_resource(&pdev->dev, res);
823 822 if (IS_ERR(i2c->regs))
824 if (!res || irq < 0) 823 return PTR_ERR(i2c->regs);
825 return -ENOENT;
826 824
827 res_size = resource_size(res); 825 irq = platform_get_irq(pdev, 0);
828 if (!devm_request_mem_region(dev, res->start, res_size, res->name)) 826 if (irq < 0)
829 return -EBUSY; 827 return irq;
830
831 i2c->regs = devm_ioremap_nocache(dev, res->start, res_size);
832 if (!i2c->regs)
833 return -EBUSY;
834 828
835 err = devm_request_irq(dev, irq, mxs_i2c_isr, 0, dev_name(dev), i2c); 829 err = devm_request_irq(dev, irq, mxs_i2c_isr, 0, dev_name(dev), i2c);
836 if (err) 830 if (err)
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 0038c451095c..ee3a76c7ae97 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -306,7 +306,7 @@ static struct i2c_algorithm smbus_algorithm = {
306}; 306};
307 307
308 308
309static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = { 309static const struct pci_device_id nforce2_ids[] = {
310 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) }, 310 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) },
311 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS) }, 311 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS) },
312 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) }, 312 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) },
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 4443613514ee..28cbe1b2a2ec 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -111,22 +111,6 @@ enum i2c_freq_mode {
111}; 111};
112 112
113/** 113/**
114 * struct nmk_i2c_controller - client specific controller configuration
115 * @clk_freq: clock frequency for the operation mode
116 * @tft: Tx FIFO Threshold in bytes
117 * @rft: Rx FIFO Threshold in bytes
118 * @timeout Slave response timeout(ms)
119 * @sm: speed mode
120 */
121struct nmk_i2c_controller {
122 u32 clk_freq;
123 unsigned char tft;
124 unsigned char rft;
125 int timeout;
126 enum i2c_freq_mode sm;
127};
128
129/**
130 * struct i2c_vendor_data - per-vendor variations 114 * struct i2c_vendor_data - per-vendor variations
131 * @has_mtdws: variant has the MTDWS bit 115 * @has_mtdws: variant has the MTDWS bit
132 * @fifodepth: variant FIFO depth 116 * @fifodepth: variant FIFO depth
@@ -174,12 +158,15 @@ struct i2c_nmk_client {
174 * @irq: interrupt line for the controller. 158 * @irq: interrupt line for the controller.
175 * @virtbase: virtual io memory area. 159 * @virtbase: virtual io memory area.
176 * @clk: hardware i2c block clock. 160 * @clk: hardware i2c block clock.
177 * @cfg: machine provided controller configuration.
178 * @cli: holder of client specific data. 161 * @cli: holder of client specific data.
162 * @clk_freq: clock frequency for the operation mode
163 * @tft: Tx FIFO Threshold in bytes
164 * @rft: Rx FIFO Threshold in bytes
165 * @timeout Slave response timeout (ms)
166 * @sm: speed mode
179 * @stop: stop condition. 167 * @stop: stop condition.
180 * @xfer_complete: acknowledge completion for a I2C message. 168 * @xfer_complete: acknowledge completion for a I2C message.
181 * @result: controller propogated result. 169 * @result: controller propogated result.
182 * @busy: Busy doing transfer.
183 */ 170 */
184struct nmk_i2c_dev { 171struct nmk_i2c_dev {
185 struct i2c_vendor_data *vendor; 172 struct i2c_vendor_data *vendor;
@@ -188,12 +175,15 @@ struct nmk_i2c_dev {
188 int irq; 175 int irq;
189 void __iomem *virtbase; 176 void __iomem *virtbase;
190 struct clk *clk; 177 struct clk *clk;
191 struct nmk_i2c_controller cfg;
192 struct i2c_nmk_client cli; 178 struct i2c_nmk_client cli;
179 u32 clk_freq;
180 unsigned char tft;
181 unsigned char rft;
182 int timeout;
183 enum i2c_freq_mode sm;
193 int stop; 184 int stop;
194 struct completion xfer_complete; 185 struct completion xfer_complete;
195 int result; 186 int result;
196 bool busy;
197}; 187};
198 188
199/* controller's abort causes */ 189/* controller's abort causes */
@@ -386,7 +376,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
386 * slsu = cycles / (1000000000 / f) + 1 376 * slsu = cycles / (1000000000 / f) + 1
387 */ 377 */
388 ns = DIV_ROUND_UP_ULL(1000000000ULL, i2c_clk); 378 ns = DIV_ROUND_UP_ULL(1000000000ULL, i2c_clk);
389 switch (dev->cfg.sm) { 379 switch (dev->sm) {
390 case I2C_FREQ_MODE_FAST: 380 case I2C_FREQ_MODE_FAST:
391 case I2C_FREQ_MODE_FAST_PLUS: 381 case I2C_FREQ_MODE_FAST_PLUS:
392 slsu = DIV_ROUND_UP(100, ns); /* Fast */ 382 slsu = DIV_ROUND_UP(100, ns); /* Fast */
@@ -409,7 +399,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
409 * 2 whereas it is 3 for fast and fastplus mode of 399 * 2 whereas it is 3 for fast and fastplus mode of
410 * operation. TODO - high speed support. 400 * operation. TODO - high speed support.
411 */ 401 */
412 div = (dev->cfg.clk_freq > 100000) ? 3 : 2; 402 div = (dev->clk_freq > 100000) ? 3 : 2;
413 403
414 /* 404 /*
415 * generate the mask for baud rate counters. The controller 405 * generate the mask for baud rate counters. The controller
@@ -419,7 +409,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
419 * so set brcr1 to 0. 409 * so set brcr1 to 0.
420 */ 410 */
421 brcr1 = 0 << 16; 411 brcr1 = 0 << 16;
422 brcr2 = (i2c_clk/(dev->cfg.clk_freq * div)) & 0xffff; 412 brcr2 = (i2c_clk/(dev->clk_freq * div)) & 0xffff;
423 413
424 /* set the baud rate counter register */ 414 /* set the baud rate counter register */
425 writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR); 415 writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR);
@@ -430,7 +420,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
430 * TODO - support for fast mode plus (up to 1Mb/s) 420 * TODO - support for fast mode plus (up to 1Mb/s)
431 * and high speed (up to 3.4 Mb/s) 421 * and high speed (up to 3.4 Mb/s)
432 */ 422 */
433 if (dev->cfg.sm > I2C_FREQ_MODE_FAST) { 423 if (dev->sm > I2C_FREQ_MODE_FAST) {
434 dev_err(&dev->adev->dev, 424 dev_err(&dev->adev->dev,
435 "do not support this mode defaulting to std. mode\n"); 425 "do not support this mode defaulting to std. mode\n");
436 brcr2 = i2c_clk/(100000 * 2) & 0xffff; 426 brcr2 = i2c_clk/(100000 * 2) & 0xffff;
@@ -438,11 +428,11 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
438 writel(I2C_FREQ_MODE_STANDARD << 4, 428 writel(I2C_FREQ_MODE_STANDARD << 4,
439 dev->virtbase + I2C_CR); 429 dev->virtbase + I2C_CR);
440 } 430 }
441 writel(dev->cfg.sm << 4, dev->virtbase + I2C_CR); 431 writel(dev->sm << 4, dev->virtbase + I2C_CR);
442 432
443 /* set the Tx and Rx FIFO threshold */ 433 /* set the Tx and Rx FIFO threshold */
444 writel(dev->cfg.tft, dev->virtbase + I2C_TFTR); 434 writel(dev->tft, dev->virtbase + I2C_TFTR);
445 writel(dev->cfg.rft, dev->virtbase + I2C_RFTR); 435 writel(dev->rft, dev->virtbase + I2C_RFTR);
446} 436}
447 437
448/** 438/**
@@ -674,28 +664,13 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags)
674static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, 664static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
675 struct i2c_msg msgs[], int num_msgs) 665 struct i2c_msg msgs[], int num_msgs)
676{ 666{
677 int status; 667 int status = 0;
678 int i; 668 int i;
679 struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap); 669 struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap);
680 int j; 670 int j;
681 671
682 dev->busy = true;
683
684 pm_runtime_get_sync(&dev->adev->dev); 672 pm_runtime_get_sync(&dev->adev->dev);
685 673
686 status = clk_prepare_enable(dev->clk);
687 if (status) {
688 dev_err(&dev->adev->dev, "can't prepare_enable clock\n");
689 goto out_clk;
690 }
691
692 /* Optionaly enable pins to be muxed in and configured */
693 pinctrl_pm_select_default_state(&dev->adev->dev);
694
695 status = init_hw(dev);
696 if (status)
697 goto out;
698
699 /* Attempt three times to send the message queue */ 674 /* Attempt three times to send the message queue */
700 for (j = 0; j < 3; j++) { 675 for (j = 0; j < 3; j++) {
701 /* setup the i2c controller */ 676 /* setup the i2c controller */
@@ -716,16 +691,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
716 break; 691 break;
717 } 692 }
718 693
719out:
720 clk_disable_unprepare(dev->clk);
721out_clk:
722 /* Optionally let pins go into idle state */
723 pinctrl_pm_select_idle_state(&dev->adev->dev);
724
725 pm_runtime_put_sync(&dev->adev->dev); 694 pm_runtime_put_sync(&dev->adev->dev);
726 695
727 dev->busy = false;
728
729 /* return the no. messages processed */ 696 /* return the no. messages processed */
730 if (status) 697 if (status)
731 return status; 698 return status;
@@ -909,22 +876,15 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)
909 return IRQ_HANDLED; 876 return IRQ_HANDLED;
910} 877}
911 878
912 879#ifdef CONFIG_PM_SLEEP
913#ifdef CONFIG_PM 880static int nmk_i2c_suspend_late(struct device *dev)
914static int nmk_i2c_suspend(struct device *dev)
915{ 881{
916 struct amba_device *adev = to_amba_device(dev);
917 struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev);
918
919 if (nmk_i2c->busy)
920 return -EBUSY;
921
922 pinctrl_pm_select_sleep_state(dev); 882 pinctrl_pm_select_sleep_state(dev);
923 883
924 return 0; 884 return 0;
925} 885}
926 886
927static int nmk_i2c_resume(struct device *dev) 887static int nmk_i2c_resume_early(struct device *dev)
928{ 888{
929 /* First go to the default state */ 889 /* First go to the default state */
930 pinctrl_pm_select_default_state(dev); 890 pinctrl_pm_select_default_state(dev);
@@ -933,19 +893,48 @@ static int nmk_i2c_resume(struct device *dev)
933 893
934 return 0; 894 return 0;
935} 895}
936#else
937#define nmk_i2c_suspend NULL
938#define nmk_i2c_resume NULL
939#endif 896#endif
940 897
941/* 898#ifdef CONFIG_PM
942 * We use noirq so that we suspend late and resume before the wakeup interrupt 899static int nmk_i2c_runtime_suspend(struct device *dev)
943 * to ensure that we do the !pm_runtime_suspended() check in resume before 900{
944 * there has been a regular pm runtime resume (via pm_runtime_get_sync()). 901 struct amba_device *adev = to_amba_device(dev);
945 */ 902 struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev);
903
904 clk_disable_unprepare(nmk_i2c->clk);
905 pinctrl_pm_select_idle_state(dev);
906 return 0;
907}
908
909static int nmk_i2c_runtime_resume(struct device *dev)
910{
911 struct amba_device *adev = to_amba_device(dev);
912 struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev);
913 int ret;
914
915 ret = clk_prepare_enable(nmk_i2c->clk);
916 if (ret) {
917 dev_err(dev, "can't prepare_enable clock\n");
918 return ret;
919 }
920
921 pinctrl_pm_select_default_state(dev);
922
923 ret = init_hw(nmk_i2c);
924 if (ret) {
925 clk_disable_unprepare(nmk_i2c->clk);
926 pinctrl_pm_select_idle_state(dev);
927 }
928
929 return ret;
930}
931#endif
932
946static const struct dev_pm_ops nmk_i2c_pm = { 933static const struct dev_pm_ops nmk_i2c_pm = {
947 .suspend_noirq = nmk_i2c_suspend, 934 SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
948 .resume_noirq = nmk_i2c_resume, 935 SET_PM_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend,
936 nmk_i2c_runtime_resume,
937 NULL)
949}; 938};
950 939
951static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) 940static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap)
@@ -958,118 +947,98 @@ static const struct i2c_algorithm nmk_i2c_algo = {
958 .functionality = nmk_i2c_functionality 947 .functionality = nmk_i2c_functionality
959}; 948};
960 949
961static struct nmk_i2c_controller u8500_i2c = {
962 .tft = 1, /* Tx FIFO threshold */
963 .rft = 8, /* Rx FIFO threshold */
964 .clk_freq = 400000, /* fast mode operation */
965 .timeout = 200, /* Slave response timeout(ms) */
966 .sm = I2C_FREQ_MODE_FAST,
967};
968
969static void nmk_i2c_of_probe(struct device_node *np, 950static void nmk_i2c_of_probe(struct device_node *np,
970 struct nmk_i2c_controller *pdata) 951 struct nmk_i2c_dev *nmk)
971{ 952{
972 of_property_read_u32(np, "clock-frequency", &pdata->clk_freq); 953 /* Default to 100 kHz if no frequency is given in the node */
954 if (of_property_read_u32(np, "clock-frequency", &nmk->clk_freq))
955 nmk->clk_freq = 100000;
973 956
974 /* This driver only supports 'standard' and 'fast' modes of operation. */ 957 /* This driver only supports 'standard' and 'fast' modes of operation. */
975 if (pdata->clk_freq <= 100000) 958 if (nmk->clk_freq <= 100000)
976 pdata->sm = I2C_FREQ_MODE_STANDARD; 959 nmk->sm = I2C_FREQ_MODE_STANDARD;
977 else 960 else
978 pdata->sm = I2C_FREQ_MODE_FAST; 961 nmk->sm = I2C_FREQ_MODE_FAST;
962 nmk->tft = 1; /* Tx FIFO threshold */
963 nmk->rft = 8; /* Rx FIFO threshold */
964 nmk->timeout = 200; /* Slave response timeout(ms) */
979} 965}
980 966
981static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) 967static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
982{ 968{
983 int ret = 0; 969 int ret = 0;
984 struct nmk_i2c_controller *pdata = dev_get_platdata(&adev->dev);
985 struct device_node *np = adev->dev.of_node; 970 struct device_node *np = adev->dev.of_node;
986 struct nmk_i2c_dev *dev; 971 struct nmk_i2c_dev *dev;
987 struct i2c_adapter *adap; 972 struct i2c_adapter *adap;
988 struct i2c_vendor_data *vendor = id->data; 973 struct i2c_vendor_data *vendor = id->data;
989 u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; 974 u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1;
990 975
991 if (!pdata) { 976 dev = devm_kzalloc(&adev->dev, sizeof(struct nmk_i2c_dev), GFP_KERNEL);
992 if (np) { 977 if (!dev) {
993 pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL); 978 dev_err(&adev->dev, "cannot allocate memory\n");
994 if (!pdata) { 979 ret = -ENOMEM;
995 ret = -ENOMEM; 980 goto err_no_mem;
996 goto err_no_mem;
997 }
998 /* Provide the default configuration as a base. */
999 memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
1000 nmk_i2c_of_probe(np, pdata);
1001 } else
1002 /* No i2c configuration found, using the default. */
1003 pdata = &u8500_i2c;
1004 } 981 }
982 dev->vendor = vendor;
983 dev->adev = adev;
984 nmk_i2c_of_probe(np, dev);
1005 985
1006 if (pdata->tft > max_fifo_threshold) { 986 if (dev->tft > max_fifo_threshold) {
1007 dev_warn(&adev->dev, "requested TX FIFO threshold %u, adjusted down to %u\n", 987 dev_warn(&adev->dev, "requested TX FIFO threshold %u, adjusted down to %u\n",
1008 pdata->tft, max_fifo_threshold); 988 dev->tft, max_fifo_threshold);
1009 pdata->tft = max_fifo_threshold; 989 dev->tft = max_fifo_threshold;
1010 } 990 }
1011 991
1012 if (pdata->rft > max_fifo_threshold) { 992 if (dev->rft > max_fifo_threshold) {
1013 dev_warn(&adev->dev, "requested RX FIFO threshold %u, adjusted down to %u\n", 993 dev_warn(&adev->dev, "requested RX FIFO threshold %u, adjusted down to %u\n",
1014 pdata->rft, max_fifo_threshold); 994 dev->rft, max_fifo_threshold);
1015 pdata->rft = max_fifo_threshold; 995 dev->rft = max_fifo_threshold;
1016 } 996 }
1017 997
1018 dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
1019 if (!dev) {
1020 dev_err(&adev->dev, "cannot allocate memory\n");
1021 ret = -ENOMEM;
1022 goto err_no_mem;
1023 }
1024 dev->vendor = vendor;
1025 dev->busy = false;
1026 dev->adev = adev;
1027 amba_set_drvdata(adev, dev); 998 amba_set_drvdata(adev, dev);
1028 999
1029 /* Select default pin state */ 1000 dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
1030 pinctrl_pm_select_default_state(&adev->dev); 1001 resource_size(&adev->res));
1031 /* If possible, let's go to idle until the first transfer */ 1002 if (IS_ERR(dev->virtbase)) {
1032 pinctrl_pm_select_idle_state(&adev->dev);
1033
1034 dev->virtbase = ioremap(adev->res.start, resource_size(&adev->res));
1035 if (!dev->virtbase) {
1036 ret = -ENOMEM; 1003 ret = -ENOMEM;
1037 goto err_no_ioremap; 1004 goto err_no_mem;
1038 } 1005 }
1039 1006
1040 dev->irq = adev->irq[0]; 1007 dev->irq = adev->irq[0];
1041 ret = request_irq(dev->irq, i2c_irq_handler, 0, 1008 ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0,
1042 DRIVER_NAME, dev); 1009 DRIVER_NAME, dev);
1043 if (ret) { 1010 if (ret) {
1044 dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); 1011 dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq);
1045 goto err_irq; 1012 goto err_no_mem;
1046 } 1013 }
1047 1014
1048 pm_suspend_ignore_children(&adev->dev, true); 1015 pm_suspend_ignore_children(&adev->dev, true);
1049 1016
1050 dev->clk = clk_get(&adev->dev, NULL); 1017 dev->clk = devm_clk_get(&adev->dev, NULL);
1051 if (IS_ERR(dev->clk)) { 1018 if (IS_ERR(dev->clk)) {
1052 dev_err(&adev->dev, "could not get i2c clock\n"); 1019 dev_err(&adev->dev, "could not get i2c clock\n");
1053 ret = PTR_ERR(dev->clk); 1020 ret = PTR_ERR(dev->clk);
1054 goto err_no_clk; 1021 goto err_no_mem;
1022 }
1023
1024 ret = clk_prepare_enable(dev->clk);
1025 if (ret) {
1026 dev_err(&adev->dev, "can't prepare_enable clock\n");
1027 goto err_no_mem;
1055 } 1028 }
1056 1029
1030 init_hw(dev);
1031
1057 adap = &dev->adap; 1032 adap = &dev->adap;
1058 adap->dev.of_node = np; 1033 adap->dev.of_node = np;
1059 adap->dev.parent = &adev->dev; 1034 adap->dev.parent = &adev->dev;
1060 adap->owner = THIS_MODULE; 1035 adap->owner = THIS_MODULE;
1061 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 1036 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
1062 adap->algo = &nmk_i2c_algo; 1037 adap->algo = &nmk_i2c_algo;
1063 adap->timeout = msecs_to_jiffies(pdata->timeout); 1038 adap->timeout = msecs_to_jiffies(dev->timeout);
1064 snprintf(adap->name, sizeof(adap->name), 1039 snprintf(adap->name, sizeof(adap->name),
1065 "Nomadik I2C at %pR", &adev->res); 1040 "Nomadik I2C at %pR", &adev->res);
1066 1041
1067 /* fetch the controller configuration from machine */
1068 dev->cfg.clk_freq = pdata->clk_freq;
1069 dev->cfg.tft = pdata->tft;
1070 dev->cfg.rft = pdata->rft;
1071 dev->cfg.sm = pdata->sm;
1072
1073 i2c_set_adapdata(adap, dev); 1042 i2c_set_adapdata(adap, dev);
1074 1043
1075 dev_info(&adev->dev, 1044 dev_info(&adev->dev,
@@ -1079,21 +1048,15 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
1079 ret = i2c_add_adapter(adap); 1048 ret = i2c_add_adapter(adap);
1080 if (ret) { 1049 if (ret) {
1081 dev_err(&adev->dev, "failed to add adapter\n"); 1050 dev_err(&adev->dev, "failed to add adapter\n");
1082 goto err_add_adap; 1051 goto err_no_adap;
1083 } 1052 }
1084 1053
1085 pm_runtime_put(&adev->dev); 1054 pm_runtime_put(&adev->dev);
1086 1055
1087 return 0; 1056 return 0;
1088 1057
1089 err_add_adap: 1058 err_no_adap:
1090 clk_put(dev->clk); 1059 clk_disable_unprepare(dev->clk);
1091 err_no_clk:
1092 free_irq(dev->irq, dev);
1093 err_irq:
1094 iounmap(dev->virtbase);
1095 err_no_ioremap:
1096 kfree(dev);
1097 err_no_mem: 1060 err_no_mem:
1098 1061
1099 return ret; 1062 return ret;
@@ -1110,13 +1073,9 @@ static int nmk_i2c_remove(struct amba_device *adev)
1110 clear_all_interrupts(dev); 1073 clear_all_interrupts(dev);
1111 /* disable the controller */ 1074 /* disable the controller */
1112 i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); 1075 i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE);
1113 free_irq(dev->irq, dev); 1076 clk_disable_unprepare(dev->clk);
1114 iounmap(dev->virtbase);
1115 if (res) 1077 if (res)
1116 release_mem_region(res->start, resource_size(res)); 1078 release_mem_region(res->start, resource_size(res));
1117 clk_put(dev->clk);
1118 pm_runtime_disable(&adev->dev);
1119 kfree(dev);
1120 1079
1121 return 0; 1080 return 0;
1122} 1081}
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 80e06fa45720..1f6369f14fb6 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -246,7 +246,7 @@ static const struct i2c_algorithm ocores_algorithm = {
246static struct i2c_adapter ocores_adapter = { 246static struct i2c_adapter ocores_adapter = {
247 .owner = THIS_MODULE, 247 .owner = THIS_MODULE,
248 .name = "i2c-ocores", 248 .name = "i2c-ocores",
249 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, 249 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED,
250 .algo = &ocores_algorithm, 250 .algo = &ocores_algorithm,
251}; 251};
252 252
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 90dcc2eaac5f..85f8eac9ba18 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -636,7 +636,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
636 int r; 636 int r;
637 637
638 r = pm_runtime_get_sync(dev->dev); 638 r = pm_runtime_get_sync(dev->dev);
639 if (IS_ERR_VALUE(r)) 639 if (r < 0)
640 goto out; 640 goto out;
641 641
642 r = omap_i2c_wait_for_bb(dev); 642 r = omap_i2c_wait_for_bb(dev);
@@ -1155,7 +1155,7 @@ omap_i2c_probe(struct platform_device *pdev)
1155 pm_runtime_use_autosuspend(dev->dev); 1155 pm_runtime_use_autosuspend(dev->dev);
1156 1156
1157 r = pm_runtime_get_sync(dev->dev); 1157 r = pm_runtime_get_sync(dev->dev);
1158 if (IS_ERR_VALUE(r)) 1158 if (r < 0)
1159 goto err_free_mem; 1159 goto err_free_mem;
1160 1160
1161 /* 1161 /*
@@ -1238,7 +1238,7 @@ omap_i2c_probe(struct platform_device *pdev)
1238 adap = &dev->adapter; 1238 adap = &dev->adapter;
1239 i2c_set_adapdata(adap, dev); 1239 i2c_set_adapdata(adap, dev);
1240 adap->owner = THIS_MODULE; 1240 adap->owner = THIS_MODULE;
1241 adap->class = I2C_CLASS_HWMON; 1241 adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
1242 strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); 1242 strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name));
1243 adap->algo = &omap_i2c_algo; 1243 adap->algo = &omap_i2c_algo;
1244 adap->dev.parent = &pdev->dev; 1244 adap->dev.parent = &pdev->dev;
@@ -1276,7 +1276,7 @@ static int omap_i2c_remove(struct platform_device *pdev)
1276 1276
1277 i2c_del_adapter(&dev->adapter); 1277 i2c_del_adapter(&dev->adapter);
1278 ret = pm_runtime_get_sync(&pdev->dev); 1278 ret = pm_runtime_get_sync(&pdev->dev);
1279 if (IS_ERR_VALUE(ret)) 1279 if (ret < 0)
1280 return ret; 1280 return ret;
1281 1281
1282 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 1282 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index 615f632c846f..7a9dce43e115 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -401,7 +401,7 @@ static void pasemi_smb_remove(struct pci_dev *dev)
401 kfree(smbus); 401 kfree(smbus);
402} 402}
403 403
404static DEFINE_PCI_DEVICE_TABLE(pasemi_smb_ids) = { 404static const struct pci_device_id pasemi_smb_ids[] = {
405 { PCI_DEVICE(0x1959, 0xa003) }, 405 { PCI_DEVICE(0x1959, 0xa003) },
406 { 0, } 406 { 0, }
407}; 407};
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 39dd8ec60dfd..a6f54ba27e2a 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -540,7 +540,7 @@ static const struct i2c_algorithm smbus_algorithm = {
540 .functionality = piix4_func, 540 .functionality = piix4_func,
541}; 541};
542 542
543static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = { 543static const struct pci_device_id piix4_ids[] = {
544 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, 544 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) },
545 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) }, 545 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) },
546 { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3) }, 546 { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3) },
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
index 9639be86e53f..417464e9ea2a 100644
--- a/drivers/i2c/busses/i2c-pxa-pci.c
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -148,7 +148,7 @@ static void ce4100_i2c_remove(struct pci_dev *dev)
148 kfree(sds); 148 kfree(sds);
149} 149}
150 150
151static DEFINE_PCI_DEVICE_TABLE(ce4100_i2c_devices) = { 151static const struct pci_device_id ce4100_i2c_devices[] = {
152 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)}, 152 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
153 { }, 153 { },
154}; 154};
diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
new file mode 100644
index 000000000000..1b4cf14f1106
--- /dev/null
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -0,0 +1,768 @@
1/*
2 * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
3 * Copyright (c) 2014, Sony Mobile Communications AB.
4 *
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 and
8 * only version 2 as 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/clk.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/i2c.h>
21#include <linux/interrupt.h>
22#include <linux/io.h>
23#include <linux/module.h>
24#include <linux/of.h>
25#include <linux/platform_device.h>
26#include <linux/pm_runtime.h>
27
28/* QUP Registers */
29#define QUP_CONFIG 0x000
30#define QUP_STATE 0x004
31#define QUP_IO_MODE 0x008
32#define QUP_SW_RESET 0x00c
33#define QUP_OPERATIONAL 0x018
34#define QUP_ERROR_FLAGS 0x01c
35#define QUP_ERROR_FLAGS_EN 0x020
36#define QUP_HW_VERSION 0x030
37#define QUP_MX_OUTPUT_CNT 0x100
38#define QUP_OUT_FIFO_BASE 0x110
39#define QUP_MX_WRITE_CNT 0x150
40#define QUP_MX_INPUT_CNT 0x200
41#define QUP_MX_READ_CNT 0x208
42#define QUP_IN_FIFO_BASE 0x218
43#define QUP_I2C_CLK_CTL 0x400
44#define QUP_I2C_STATUS 0x404
45
46/* QUP States and reset values */
47#define QUP_RESET_STATE 0
48#define QUP_RUN_STATE 1
49#define QUP_PAUSE_STATE 3
50#define QUP_STATE_MASK 3
51
52#define QUP_STATE_VALID BIT(2)
53#define QUP_I2C_MAST_GEN BIT(4)
54
55#define QUP_OPERATIONAL_RESET 0x000ff0
56#define QUP_I2C_STATUS_RESET 0xfffffc
57
58/* QUP OPERATIONAL FLAGS */
59#define QUP_I2C_NACK_FLAG BIT(3)
60#define QUP_OUT_NOT_EMPTY BIT(4)
61#define QUP_IN_NOT_EMPTY BIT(5)
62#define QUP_OUT_FULL BIT(6)
63#define QUP_OUT_SVC_FLAG BIT(8)
64#define QUP_IN_SVC_FLAG BIT(9)
65#define QUP_MX_OUTPUT_DONE BIT(10)
66#define QUP_MX_INPUT_DONE BIT(11)
67
68/* I2C mini core related values */
69#define QUP_CLOCK_AUTO_GATE BIT(13)
70#define I2C_MINI_CORE (2 << 8)
71#define I2C_N_VAL 15
72/* Most significant word offset in FIFO port */
73#define QUP_MSW_SHIFT (I2C_N_VAL + 1)
74
75/* Packing/Unpacking words in FIFOs, and IO modes */
76#define QUP_OUTPUT_BLK_MODE (1 << 10)
77#define QUP_INPUT_BLK_MODE (1 << 12)
78#define QUP_UNPACK_EN BIT(14)
79#define QUP_PACK_EN BIT(15)
80
81#define QUP_REPACK_EN (QUP_UNPACK_EN | QUP_PACK_EN)
82
83#define QUP_OUTPUT_BLOCK_SIZE(x)(((x) >> 0) & 0x03)
84#define QUP_OUTPUT_FIFO_SIZE(x) (((x) >> 2) & 0x07)
85#define QUP_INPUT_BLOCK_SIZE(x) (((x) >> 5) & 0x03)
86#define QUP_INPUT_FIFO_SIZE(x) (((x) >> 7) & 0x07)
87
88/* QUP tags */
89#define QUP_TAG_START (1 << 8)
90#define QUP_TAG_DATA (2 << 8)
91#define QUP_TAG_STOP (3 << 8)
92#define QUP_TAG_REC (4 << 8)
93
94/* Status, Error flags */
95#define I2C_STATUS_WR_BUFFER_FULL BIT(0)
96#define I2C_STATUS_BUS_ACTIVE BIT(8)
97#define I2C_STATUS_ERROR_MASK 0x38000fc
98#define QUP_STATUS_ERROR_FLAGS 0x7c
99
100#define QUP_READ_LIMIT 256
101
102struct qup_i2c_dev {
103 struct device *dev;
104 void __iomem *base;
105 int irq;
106 struct clk *clk;
107 struct clk *pclk;
108 struct i2c_adapter adap;
109
110 int clk_ctl;
111 int out_fifo_sz;
112 int in_fifo_sz;
113 int out_blk_sz;
114 int in_blk_sz;
115
116 unsigned long one_byte_t;
117
118 struct i2c_msg *msg;
119 /* Current posion in user message buffer */
120 int pos;
121 /* I2C protocol errors */
122 u32 bus_err;
123 /* QUP core errors */
124 u32 qup_err;
125
126 struct completion xfer;
127};
128
129static irqreturn_t qup_i2c_interrupt(int irq, void *dev)
130{
131 struct qup_i2c_dev *qup = dev;
132 u32 bus_err;
133 u32 qup_err;
134 u32 opflags;
135
136 bus_err = readl(qup->base + QUP_I2C_STATUS);
137 qup_err = readl(qup->base + QUP_ERROR_FLAGS);
138 opflags = readl(qup->base + QUP_OPERATIONAL);
139
140 if (!qup->msg) {
141 /* Clear Error interrupt */
142 writel(QUP_RESET_STATE, qup->base + QUP_STATE);
143 return IRQ_HANDLED;
144 }
145
146 bus_err &= I2C_STATUS_ERROR_MASK;
147 qup_err &= QUP_STATUS_ERROR_FLAGS;
148
149 if (qup_err) {
150 /* Clear Error interrupt */
151 writel(qup_err, qup->base + QUP_ERROR_FLAGS);
152 goto done;
153 }
154
155 if (bus_err) {
156 /* Clear Error interrupt */
157 writel(QUP_RESET_STATE, qup->base + QUP_STATE);
158 goto done;
159 }
160
161 if (opflags & QUP_IN_SVC_FLAG)
162 writel(QUP_IN_SVC_FLAG, qup->base + QUP_OPERATIONAL);
163
164 if (opflags & QUP_OUT_SVC_FLAG)
165 writel(QUP_OUT_SVC_FLAG, qup->base + QUP_OPERATIONAL);
166
167done:
168 qup->qup_err = qup_err;
169 qup->bus_err = bus_err;
170 complete(&qup->xfer);
171 return IRQ_HANDLED;
172}
173
174static int qup_i2c_poll_state_mask(struct qup_i2c_dev *qup,
175 u32 req_state, u32 req_mask)
176{
177 int retries = 1;
178 u32 state;
179
180 /*
181 * State transition takes 3 AHB clocks cycles + 3 I2C master clock
182 * cycles. So retry once after a 1uS delay.
183 */
184 do {
185 state = readl(qup->base + QUP_STATE);
186
187 if (state & QUP_STATE_VALID &&
188 (state & req_mask) == req_state)
189 return 0;
190
191 udelay(1);
192 } while (retries--);
193
194 return -ETIMEDOUT;
195}
196
197static int qup_i2c_poll_state(struct qup_i2c_dev *qup, u32 req_state)
198{
199 return qup_i2c_poll_state_mask(qup, req_state, QUP_STATE_MASK);
200}
201
202static int qup_i2c_poll_state_valid(struct qup_i2c_dev *qup)
203{
204 return qup_i2c_poll_state_mask(qup, 0, 0);
205}
206
207static int qup_i2c_poll_state_i2c_master(struct qup_i2c_dev *qup)
208{
209 return qup_i2c_poll_state_mask(qup, QUP_I2C_MAST_GEN, QUP_I2C_MAST_GEN);
210}
211
212static int qup_i2c_change_state(struct qup_i2c_dev *qup, u32 state)
213{
214 if (qup_i2c_poll_state_valid(qup) != 0)
215 return -EIO;
216
217 writel(state, qup->base + QUP_STATE);
218
219 if (qup_i2c_poll_state(qup, state) != 0)
220 return -EIO;
221 return 0;
222}
223
224static int qup_i2c_wait_writeready(struct qup_i2c_dev *qup)
225{
226 unsigned long timeout;
227 u32 opflags;
228 u32 status;
229
230 timeout = jiffies + HZ;
231
232 for (;;) {
233 opflags = readl(qup->base + QUP_OPERATIONAL);
234 status = readl(qup->base + QUP_I2C_STATUS);
235
236 if (!(opflags & QUP_OUT_NOT_EMPTY) &&
237 !(status & I2C_STATUS_BUS_ACTIVE))
238 return 0;
239
240 if (time_after(jiffies, timeout))
241 return -ETIMEDOUT;
242
243 usleep_range(qup->one_byte_t, qup->one_byte_t * 2);
244 }
245}
246
247static void qup_i2c_set_write_mode(struct qup_i2c_dev *qup, struct i2c_msg *msg)
248{
249 /* Number of entries to shift out, including the start */
250 int total = msg->len + 1;
251
252 if (total < qup->out_fifo_sz) {
253 /* FIFO mode */
254 writel(QUP_REPACK_EN, qup->base + QUP_IO_MODE);
255 writel(total, qup->base + QUP_MX_WRITE_CNT);
256 } else {
257 /* BLOCK mode (transfer data on chunks) */
258 writel(QUP_OUTPUT_BLK_MODE | QUP_REPACK_EN,
259 qup->base + QUP_IO_MODE);
260 writel(total, qup->base + QUP_MX_OUTPUT_CNT);
261 }
262}
263
264static void qup_i2c_issue_write(struct qup_i2c_dev *qup, struct i2c_msg *msg)
265{
266 u32 addr = msg->addr << 1;
267 u32 qup_tag;
268 u32 opflags;
269 int idx;
270 u32 val;
271
272 if (qup->pos == 0) {
273 val = QUP_TAG_START | addr;
274 idx = 1;
275 } else {
276 val = 0;
277 idx = 0;
278 }
279
280 while (qup->pos < msg->len) {
281 /* Check that there's space in the FIFO for our pair */
282 opflags = readl(qup->base + QUP_OPERATIONAL);
283 if (opflags & QUP_OUT_FULL)
284 break;
285
286 if (qup->pos == msg->len - 1)
287 qup_tag = QUP_TAG_STOP;
288 else
289 qup_tag = QUP_TAG_DATA;
290
291 if (idx & 1)
292 val |= (qup_tag | msg->buf[qup->pos]) << QUP_MSW_SHIFT;
293 else
294 val = qup_tag | msg->buf[qup->pos];
295
296 /* Write out the pair and the last odd value */
297 if (idx & 1 || qup->pos == msg->len - 1)
298 writel(val, qup->base + QUP_OUT_FIFO_BASE);
299
300 qup->pos++;
301 idx++;
302 }
303}
304
305static int qup_i2c_write_one(struct qup_i2c_dev *qup, struct i2c_msg *msg)
306{
307 unsigned long left;
308 int ret;
309
310 qup->msg = msg;
311 qup->pos = 0;
312
313 enable_irq(qup->irq);
314
315 qup_i2c_set_write_mode(qup, msg);
316
317 ret = qup_i2c_change_state(qup, QUP_RUN_STATE);
318 if (ret)
319 goto err;
320
321 writel(qup->clk_ctl, qup->base + QUP_I2C_CLK_CTL);
322
323 do {
324 ret = qup_i2c_change_state(qup, QUP_PAUSE_STATE);
325 if (ret)
326 goto err;
327
328 qup_i2c_issue_write(qup, msg);
329
330 ret = qup_i2c_change_state(qup, QUP_RUN_STATE);
331 if (ret)
332 goto err;
333
334 left = wait_for_completion_timeout(&qup->xfer, HZ);
335 if (!left) {
336 writel(1, qup->base + QUP_SW_RESET);
337 ret = -ETIMEDOUT;
338 goto err;
339 }
340
341 if (qup->bus_err || qup->qup_err) {
342 if (qup->bus_err & QUP_I2C_NACK_FLAG)
343 dev_err(qup->dev, "NACK from %x\n", msg->addr);
344 ret = -EIO;
345 goto err;
346 }
347 } while (qup->pos < msg->len);
348
349 /* Wait for the outstanding data in the fifo to drain */
350 ret = qup_i2c_wait_writeready(qup);
351
352err:
353 disable_irq(qup->irq);
354 qup->msg = NULL;
355
356 return ret;
357}
358
359static void qup_i2c_set_read_mode(struct qup_i2c_dev *qup, int len)
360{
361 if (len < qup->in_fifo_sz) {
362 /* FIFO mode */
363 writel(QUP_REPACK_EN, qup->base + QUP_IO_MODE);
364 writel(len, qup->base + QUP_MX_READ_CNT);
365 } else {
366 /* BLOCK mode (transfer data on chunks) */
367 writel(QUP_INPUT_BLK_MODE | QUP_REPACK_EN,
368 qup->base + QUP_IO_MODE);
369 writel(len, qup->base + QUP_MX_INPUT_CNT);
370 }
371}
372
373static void qup_i2c_issue_read(struct qup_i2c_dev *qup, struct i2c_msg *msg)
374{
375 u32 addr, len, val;
376
377 addr = (msg->addr << 1) | 1;
378
379 /* 0 is used to specify a length 256 (QUP_READ_LIMIT) */
380 len = (msg->len == QUP_READ_LIMIT) ? 0 : msg->len;
381
382 val = ((QUP_TAG_REC | len) << QUP_MSW_SHIFT) | QUP_TAG_START | addr;
383 writel(val, qup->base + QUP_OUT_FIFO_BASE);
384}
385
386
387static void qup_i2c_read_fifo(struct qup_i2c_dev *qup, struct i2c_msg *msg)
388{
389 u32 opflags;
390 u32 val = 0;
391 int idx;
392
393 for (idx = 0; qup->pos < msg->len; idx++) {
394 if ((idx & 1) == 0) {
395 /* Check that FIFO have data */
396 opflags = readl(qup->base + QUP_OPERATIONAL);
397 if (!(opflags & QUP_IN_NOT_EMPTY))
398 break;
399
400 /* Reading 2 words at time */
401 val = readl(qup->base + QUP_IN_FIFO_BASE);
402
403 msg->buf[qup->pos++] = val & 0xFF;
404 } else {
405 msg->buf[qup->pos++] = val >> QUP_MSW_SHIFT;
406 }
407 }
408}
409
410static int qup_i2c_read_one(struct qup_i2c_dev *qup, struct i2c_msg *msg)
411{
412 unsigned long left;
413 int ret;
414
415 /*
416 * The QUP block will issue a NACK and STOP on the bus when reaching
417 * the end of the read, the length of the read is specified as one byte
418 * which limits the possible read to 256 (QUP_READ_LIMIT) bytes.
419 */
420 if (msg->len > QUP_READ_LIMIT) {
421 dev_err(qup->dev, "HW not capable of reads over %d bytes\n",
422 QUP_READ_LIMIT);
423 return -EINVAL;
424 }
425
426 qup->msg = msg;
427 qup->pos = 0;
428
429 enable_irq(qup->irq);
430
431 qup_i2c_set_read_mode(qup, msg->len);
432
433 ret = qup_i2c_change_state(qup, QUP_RUN_STATE);
434 if (ret)
435 goto err;
436
437 writel(qup->clk_ctl, qup->base + QUP_I2C_CLK_CTL);
438
439 ret = qup_i2c_change_state(qup, QUP_PAUSE_STATE);
440 if (ret)
441 goto err;
442
443 qup_i2c_issue_read(qup, msg);
444
445 ret = qup_i2c_change_state(qup, QUP_RUN_STATE);
446 if (ret)
447 goto err;
448
449 do {
450 left = wait_for_completion_timeout(&qup->xfer, HZ);
451 if (!left) {
452 writel(1, qup->base + QUP_SW_RESET);
453 ret = -ETIMEDOUT;
454 goto err;
455 }
456
457 if (qup->bus_err || qup->qup_err) {
458 if (qup->bus_err & QUP_I2C_NACK_FLAG)
459 dev_err(qup->dev, "NACK from %x\n", msg->addr);
460 ret = -EIO;
461 goto err;
462 }
463
464 qup_i2c_read_fifo(qup, msg);
465 } while (qup->pos < msg->len);
466
467err:
468 disable_irq(qup->irq);
469 qup->msg = NULL;
470
471 return ret;
472}
473
474static int qup_i2c_xfer(struct i2c_adapter *adap,
475 struct i2c_msg msgs[],
476 int num)
477{
478 struct qup_i2c_dev *qup = i2c_get_adapdata(adap);
479 int ret, idx;
480
481 ret = pm_runtime_get_sync(qup->dev);
482 if (ret)
483 goto out;
484
485 writel(1, qup->base + QUP_SW_RESET);
486 ret = qup_i2c_poll_state(qup, QUP_RESET_STATE);
487 if (ret)
488 goto out;
489
490 /* Configure QUP as I2C mini core */
491 writel(I2C_MINI_CORE | I2C_N_VAL, qup->base + QUP_CONFIG);
492
493 for (idx = 0; idx < num; idx++) {
494 if (msgs[idx].len == 0) {
495 ret = -EINVAL;
496 goto out;
497 }
498
499 if (qup_i2c_poll_state_i2c_master(qup)) {
500 ret = -EIO;
501 goto out;
502 }
503
504 if (msgs[idx].flags & I2C_M_RD)
505 ret = qup_i2c_read_one(qup, &msgs[idx]);
506 else
507 ret = qup_i2c_write_one(qup, &msgs[idx]);
508
509 if (ret)
510 break;
511
512 ret = qup_i2c_change_state(qup, QUP_RESET_STATE);
513 if (ret)
514 break;
515 }
516
517 if (ret == 0)
518 ret = num;
519out:
520
521 pm_runtime_mark_last_busy(qup->dev);
522 pm_runtime_put_autosuspend(qup->dev);
523
524 return ret;
525}
526
527static u32 qup_i2c_func(struct i2c_adapter *adap)
528{
529 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
530}
531
532static const struct i2c_algorithm qup_i2c_algo = {
533 .master_xfer = qup_i2c_xfer,
534 .functionality = qup_i2c_func,
535};
536
537static void qup_i2c_enable_clocks(struct qup_i2c_dev *qup)
538{
539 clk_prepare_enable(qup->clk);
540 clk_prepare_enable(qup->pclk);
541}
542
543static void qup_i2c_disable_clocks(struct qup_i2c_dev *qup)
544{
545 u32 config;
546
547 qup_i2c_change_state(qup, QUP_RESET_STATE);
548 clk_disable_unprepare(qup->clk);
549 config = readl(qup->base + QUP_CONFIG);
550 config |= QUP_CLOCK_AUTO_GATE;
551 writel(config, qup->base + QUP_CONFIG);
552 clk_disable_unprepare(qup->pclk);
553}
554
555static int qup_i2c_probe(struct platform_device *pdev)
556{
557 static const int blk_sizes[] = {4, 16, 32};
558 struct device_node *node = pdev->dev.of_node;
559 struct qup_i2c_dev *qup;
560 unsigned long one_bit_t;
561 struct resource *res;
562 u32 io_mode, hw_ver, size;
563 int ret, fs_div, hs_div;
564 int src_clk_freq;
565 u32 clk_freq = 100000;
566
567 qup = devm_kzalloc(&pdev->dev, sizeof(*qup), GFP_KERNEL);
568 if (!qup)
569 return -ENOMEM;
570
571 qup->dev = &pdev->dev;
572 init_completion(&qup->xfer);
573 platform_set_drvdata(pdev, qup);
574
575 of_property_read_u32(node, "clock-frequency", &clk_freq);
576
577 /* We support frequencies up to FAST Mode (400KHz) */
578 if (!clk_freq || clk_freq > 400000) {
579 dev_err(qup->dev, "clock frequency not supported %d\n",
580 clk_freq);
581 return -EINVAL;
582 }
583
584 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
585 qup->base = devm_ioremap_resource(qup->dev, res);
586 if (IS_ERR(qup->base))
587 return PTR_ERR(qup->base);
588
589 qup->irq = platform_get_irq(pdev, 0);
590 if (qup->irq < 0) {
591 dev_err(qup->dev, "No IRQ defined\n");
592 return qup->irq;
593 }
594
595 qup->clk = devm_clk_get(qup->dev, "core");
596 if (IS_ERR(qup->clk)) {
597 dev_err(qup->dev, "Could not get core clock\n");
598 return PTR_ERR(qup->clk);
599 }
600
601 qup->pclk = devm_clk_get(qup->dev, "iface");
602 if (IS_ERR(qup->pclk)) {
603 dev_err(qup->dev, "Could not get iface clock\n");
604 return PTR_ERR(qup->pclk);
605 }
606
607 qup_i2c_enable_clocks(qup);
608
609 /*
610 * Bootloaders might leave a pending interrupt on certain QUP's,
611 * so we reset the core before registering for interrupts.
612 */
613 writel(1, qup->base + QUP_SW_RESET);
614 ret = qup_i2c_poll_state_valid(qup);
615 if (ret)
616 goto fail;
617
618 ret = devm_request_irq(qup->dev, qup->irq, qup_i2c_interrupt,
619 IRQF_TRIGGER_HIGH, "i2c_qup", qup);
620 if (ret) {
621 dev_err(qup->dev, "Request %d IRQ failed\n", qup->irq);
622 goto fail;
623 }
624 disable_irq(qup->irq);
625
626 hw_ver = readl(qup->base + QUP_HW_VERSION);
627 dev_dbg(qup->dev, "Revision %x\n", hw_ver);
628
629 io_mode = readl(qup->base + QUP_IO_MODE);
630
631 /*
632 * The block/fifo size w.r.t. 'actual data' is 1/2 due to 'tag'
633 * associated with each byte written/received
634 */
635 size = QUP_OUTPUT_BLOCK_SIZE(io_mode);
636 if (size >= ARRAY_SIZE(blk_sizes))
637 return -EIO;
638 qup->out_blk_sz = blk_sizes[size] / 2;
639
640 size = QUP_INPUT_BLOCK_SIZE(io_mode);
641 if (size >= ARRAY_SIZE(blk_sizes))
642 return -EIO;
643 qup->in_blk_sz = blk_sizes[size] / 2;
644
645 size = QUP_OUTPUT_FIFO_SIZE(io_mode);
646 qup->out_fifo_sz = qup->out_blk_sz * (2 << size);
647
648 size = QUP_INPUT_FIFO_SIZE(io_mode);
649 qup->in_fifo_sz = qup->in_blk_sz * (2 << size);
650
651 src_clk_freq = clk_get_rate(qup->clk);
652 fs_div = ((src_clk_freq / clk_freq) / 2) - 3;
653 hs_div = 3;
654 qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff);
655
656 /*
657 * Time it takes for a byte to be clocked out on the bus.
658 * Each byte takes 9 clock cycles (8 bits + 1 ack).
659 */
660 one_bit_t = (USEC_PER_SEC / clk_freq) + 1;
661 qup->one_byte_t = one_bit_t * 9;
662
663 dev_dbg(qup->dev, "IN:block:%d, fifo:%d, OUT:block:%d, fifo:%d\n",
664 qup->in_blk_sz, qup->in_fifo_sz,
665 qup->out_blk_sz, qup->out_fifo_sz);
666
667 i2c_set_adapdata(&qup->adap, qup);
668 qup->adap.algo = &qup_i2c_algo;
669 qup->adap.dev.parent = qup->dev;
670 qup->adap.dev.of_node = pdev->dev.of_node;
671 strlcpy(qup->adap.name, "QUP I2C adapter", sizeof(qup->adap.name));
672
673 ret = i2c_add_adapter(&qup->adap);
674 if (ret)
675 goto fail;
676
677 pm_runtime_set_autosuspend_delay(qup->dev, MSEC_PER_SEC);
678 pm_runtime_use_autosuspend(qup->dev);
679 pm_runtime_set_active(qup->dev);
680 pm_runtime_enable(qup->dev);
681 return 0;
682
683fail:
684 qup_i2c_disable_clocks(qup);
685 return ret;
686}
687
688static int qup_i2c_remove(struct platform_device *pdev)
689{
690 struct qup_i2c_dev *qup = platform_get_drvdata(pdev);
691
692 disable_irq(qup->irq);
693 qup_i2c_disable_clocks(qup);
694 i2c_del_adapter(&qup->adap);
695 pm_runtime_disable(qup->dev);
696 pm_runtime_set_suspended(qup->dev);
697 return 0;
698}
699
700#ifdef CONFIG_PM
701static int qup_i2c_pm_suspend_runtime(struct device *device)
702{
703 struct qup_i2c_dev *qup = dev_get_drvdata(device);
704
705 dev_dbg(device, "pm_runtime: suspending...\n");
706 qup_i2c_disable_clocks(qup);
707 return 0;
708}
709
710static int qup_i2c_pm_resume_runtime(struct device *device)
711{
712 struct qup_i2c_dev *qup = dev_get_drvdata(device);
713
714 dev_dbg(device, "pm_runtime: resuming...\n");
715 qup_i2c_enable_clocks(qup);
716 return 0;
717}
718#endif
719
720#ifdef CONFIG_PM_SLEEP
721static int qup_i2c_suspend(struct device *device)
722{
723 qup_i2c_pm_suspend_runtime(device);
724 return 0;
725}
726
727static int qup_i2c_resume(struct device *device)
728{
729 qup_i2c_pm_resume_runtime(device);
730 pm_runtime_mark_last_busy(device);
731 pm_request_autosuspend(device);
732 return 0;
733}
734#endif
735
736static const struct dev_pm_ops qup_i2c_qup_pm_ops = {
737 SET_SYSTEM_SLEEP_PM_OPS(
738 qup_i2c_suspend,
739 qup_i2c_resume)
740 SET_RUNTIME_PM_OPS(
741 qup_i2c_pm_suspend_runtime,
742 qup_i2c_pm_resume_runtime,
743 NULL)
744};
745
746static const struct of_device_id qup_i2c_dt_match[] = {
747 { .compatible = "qcom,i2c-qup-v1.1.1" },
748 { .compatible = "qcom,i2c-qup-v2.1.1" },
749 { .compatible = "qcom,i2c-qup-v2.2.1" },
750 {}
751};
752MODULE_DEVICE_TABLE(of, qup_i2c_dt_match);
753
754static struct platform_driver qup_i2c_driver = {
755 .probe = qup_i2c_probe,
756 .remove = qup_i2c_remove,
757 .driver = {
758 .name = "i2c_qup",
759 .owner = THIS_MODULE,
760 .pm = &qup_i2c_qup_pm_ops,
761 .of_match_table = qup_i2c_dt_match,
762 },
763};
764
765module_platform_driver(qup_i2c_driver);
766
767MODULE_LICENSE("GPL v2");
768MODULE_ALIAS("platform:i2c_qup");
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 0282d4d42805..d4fa8eba6e9d 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -638,6 +638,7 @@ static const struct of_device_id rcar_i2c_dt_ids[] = {
638 { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_GEN1 }, 638 { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_GEN1 },
639 { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_GEN1 }, 639 { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_GEN1 },
640 { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_GEN2 }, 640 { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_GEN2 },
641 { .compatible = "renesas,i2c-r8a7791", .data = (void *)I2C_RCAR_GEN2 },
641 {}, 642 {},
642}; 643};
643MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids); 644MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids);
@@ -691,7 +692,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
691 adap = &priv->adap; 692 adap = &priv->adap;
692 adap->nr = pdev->id; 693 adap->nr = pdev->id;
693 adap->algo = &rcar_i2c_algo; 694 adap->algo = &rcar_i2c_algo;
694 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 695 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
695 adap->retries = 3; 696 adap->retries = 3;
696 adap->dev.parent = dev; 697 adap->dev.parent = dev;
697 adap->dev.of_node = dev->of_node; 698 adap->dev.of_node = dev->of_node;
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 684d21e71e4a..ae4491062e41 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -601,6 +601,31 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id)
601 return IRQ_HANDLED; 601 return IRQ_HANDLED;
602} 602}
603 603
604/*
605 * Disable the bus so that we won't get any interrupts from now on, or try
606 * to drive any lines. This is the default state when we don't have
607 * anything to send/receive.
608 *
609 * If there is an event on the bus, or we have a pre-existing event at
610 * kernel boot time, we may not notice the event and the I2C controller
611 * will lock the bus with the I2C clock line low indefinitely.
612 */
613static inline void s3c24xx_i2c_disable_bus(struct s3c24xx_i2c *i2c)
614{
615 unsigned long tmp;
616
617 /* Stop driving the I2C pins */
618 tmp = readl(i2c->regs + S3C2410_IICSTAT);
619 tmp &= ~S3C2410_IICSTAT_TXRXEN;
620 writel(tmp, i2c->regs + S3C2410_IICSTAT);
621
622 /* We don't expect any interrupts now, and don't want send acks */
623 tmp = readl(i2c->regs + S3C2410_IICCON);
624 tmp &= ~(S3C2410_IICCON_IRQEN | S3C2410_IICCON_IRQPEND |
625 S3C2410_IICCON_ACKEN);
626 writel(tmp, i2c->regs + S3C2410_IICCON);
627}
628
604 629
605/* s3c24xx_i2c_set_master 630/* s3c24xx_i2c_set_master
606 * 631 *
@@ -735,7 +760,11 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
735 760
736 s3c24xx_i2c_wait_idle(i2c); 761 s3c24xx_i2c_wait_idle(i2c);
737 762
763 s3c24xx_i2c_disable_bus(i2c);
764
738 out: 765 out:
766 i2c->state = STATE_IDLE;
767
739 return ret; 768 return ret;
740} 769}
741 770
@@ -1004,7 +1033,6 @@ static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
1004 1033
1005static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) 1034static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
1006{ 1035{
1007 unsigned long iicon = S3C2410_IICCON_IRQEN | S3C2410_IICCON_ACKEN;
1008 struct s3c2410_platform_i2c *pdata; 1036 struct s3c2410_platform_i2c *pdata;
1009 unsigned int freq; 1037 unsigned int freq;
1010 1038
@@ -1018,12 +1046,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
1018 1046
1019 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); 1047 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
1020 1048
1021 writel(iicon, i2c->regs + S3C2410_IICCON); 1049 writel(0, i2c->regs + S3C2410_IICCON);
1050 writel(0, i2c->regs + S3C2410_IICSTAT);
1022 1051
1023 /* we need to work out the divisors for the clock... */ 1052 /* we need to work out the divisors for the clock... */
1024 1053
1025 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) { 1054 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) {
1026 writel(0, i2c->regs + S3C2410_IICCON);
1027 dev_err(i2c->dev, "cannot meet bus frequency required\n"); 1055 dev_err(i2c->dev, "cannot meet bus frequency required\n");
1028 return -EINVAL; 1056 return -EINVAL;
1029 } 1057 }
@@ -1031,7 +1059,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
1031 /* todo - check that the i2c lines aren't being dragged anywhere */ 1059 /* todo - check that the i2c lines aren't being dragged anywhere */
1032 1060
1033 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); 1061 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq);
1034 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon); 1062 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02x\n",
1063 readl(i2c->regs + S3C2410_IICCON));
1035 1064
1036 return 0; 1065 return 0;
1037} 1066}
@@ -1106,7 +1135,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1106 i2c->adap.owner = THIS_MODULE; 1135 i2c->adap.owner = THIS_MODULE;
1107 i2c->adap.algo = &s3c24xx_i2c_algorithm; 1136 i2c->adap.algo = &s3c24xx_i2c_algorithm;
1108 i2c->adap.retries = 2; 1137 i2c->adap.retries = 2;
1109 i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 1138 i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
1110 i2c->tx_setup = 50; 1139 i2c->tx_setup = 50;
1111 1140
1112 init_waitqueue_head(&i2c->wait); 1141 init_waitqueue_head(&i2c->wait);
diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 6784f7f527a4..8e3be7ed0586 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -312,7 +312,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
312 goto out; 312 goto out;
313 } 313 }
314 adap = &siic->adapter; 314 adap = &siic->adapter;
315 adap->class = I2C_CLASS_HWMON; 315 adap->class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
316 316
317 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 317 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
318 siic->base = devm_ioremap_resource(&pdev->dev, mem_res); 318 siic->base = devm_ioremap_resource(&pdev->dev, mem_res);
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 79fd96a04386..ac9bc33acef4 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -369,7 +369,7 @@ static struct i2c_adapter sis5595_adapter = {
369 .algo = &smbus_algorithm, 369 .algo = &smbus_algorithm,
370}; 370};
371 371
372static DEFINE_PCI_DEVICE_TABLE(sis5595_ids) = { 372static const struct pci_device_id sis5595_ids[] = {
373 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 373 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
374 { 0, } 374 { 0, }
375}; 375};
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 19b8505d0cdd..c6366733008d 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -510,7 +510,7 @@ static struct i2c_adapter sis630_adapter = {
510 .retries = 3 510 .retries = 3
511}; 511};
512 512
513static DEFINE_PCI_DEVICE_TABLE(sis630_ids) = { 513static const struct pci_device_id sis630_ids[] = {
514 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 514 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
515 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC) }, 515 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC) },
516 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_964) }, 516 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_964) },
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index f8aa0c29f02b..8dc2fc5f74ff 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -244,7 +244,7 @@ static struct i2c_adapter sis96x_adapter = {
244 .algo = &smbus_algorithm, 244 .algo = &smbus_algorithm,
245}; 245};
246 246
247static DEFINE_PCI_DEVICE_TABLE(sis96x_ids) = { 247static const struct pci_device_id sis96x_ids[] = {
248 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_SMBUS) }, 248 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_SMBUS) },
249 { 0, } 249 { 0, }
250}; 250};
diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
index 9cf715d69551..872016196ef3 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -574,7 +574,7 @@ static irqreturn_t st_i2c_isr_thread(int irq, void *data)
574 writel_relaxed(it, i2c_dev->base + SSC_IEN); 574 writel_relaxed(it, i2c_dev->base + SSC_IEN);
575 575
576 st_i2c_set_bits(i2c_dev->base + SSC_I2C, SSC_I2C_STOPG); 576 st_i2c_set_bits(i2c_dev->base + SSC_I2C, SSC_I2C_STOPG);
577 c->result = -EIO; 577 c->result = -EAGAIN;
578 break; 578 break;
579 579
580 default: 580 default:
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
index 5b80ef310841..29b1fb778943 100644
--- a/drivers/i2c/busses/i2c-stu300.c
+++ b/drivers/i2c/busses/i2c-stu300.c
@@ -911,7 +911,7 @@ static int stu300_probe(struct platform_device *pdev)
911 adap = &dev->adapter; 911 adap = &dev->adapter;
912 adap->owner = THIS_MODULE; 912 adap->owner = THIS_MODULE;
913 /* DDC class but actually often used for more generic I2C */ 913 /* DDC class but actually often used for more generic I2C */
914 adap->class = I2C_CLASS_DDC; 914 adap->class = I2C_CLASS_DDC | I2C_CLASS_DEPRECATED;
915 strlcpy(adap->name, "ST Microelectronics DDC I2C adapter", 915 strlcpy(adap->name, "ST Microelectronics DDC I2C adapter",
916 sizeof(adap->name)); 916 sizeof(adap->name));
917 adap->nr = bus_nr; 917 adap->nr = bus_nr;
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 9704537aee3c..00f04cb5b4eb 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -794,7 +794,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
794 794
795 i2c_set_adapdata(&i2c_dev->adapter, i2c_dev); 795 i2c_set_adapdata(&i2c_dev->adapter, i2c_dev);
796 i2c_dev->adapter.owner = THIS_MODULE; 796 i2c_dev->adapter.owner = THIS_MODULE;
797 i2c_dev->adapter.class = I2C_CLASS_HWMON; 797 i2c_dev->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_DEPRECATED;
798 strlcpy(i2c_dev->adapter.name, "Tegra I2C adapter", 798 strlcpy(i2c_dev->adapter.name, "Tegra I2C adapter",
799 sizeof(i2c_dev->adapter.name)); 799 sizeof(i2c_dev->adapter.name));
800 i2c_dev->adapter.algo = &tegra_i2c_algo; 800 i2c_dev->adapter.algo = &tegra_i2c_algo;
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 49d7f14b9d27..f4a1ed757612 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -88,7 +88,7 @@ static struct i2c_adapter vt586b_adapter = {
88}; 88};
89 89
90 90
91static DEFINE_PCI_DEVICE_TABLE(vt586b_ids) = { 91static const struct pci_device_id vt586b_ids[] = {
92 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3) }, 92 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3) },
93 { 0, } 93 { 0, }
94}; 94};
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 40d36df678de..6841200b6e50 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -442,7 +442,7 @@ release_region:
442 return error; 442 return error;
443} 443}
444 444
445static DEFINE_PCI_DEVICE_TABLE(vt596_ids) = { 445static const struct pci_device_id vt596_ids[] = {
446 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596_3), 446 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596_3),
447 .driver_data = SMBBA1 }, 447 .driver_data = SMBBA1 },
448 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596B_3), 448 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596B_3),
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 28107502517f..7731f1795869 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -684,7 +684,7 @@ static const struct i2c_algorithm xiic_algorithm = {
684static struct i2c_adapter xiic_adapter = { 684static struct i2c_adapter xiic_adapter = {
685 .owner = THIS_MODULE, 685 .owner = THIS_MODULE,
686 .name = DRIVER_NAME, 686 .name = DRIVER_NAME,
687 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, 687 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED,
688 .algo = &xiic_algorithm, 688 .algo = &xiic_algorithm,
689}; 689};
690 690
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 2d1d2c5653fb..cb66f9586f76 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -556,7 +556,7 @@ static struct platform_driver scx200_pci_driver = {
556 .remove = scx200_remove, 556 .remove = scx200_remove,
557}; 557};
558 558
559static DEFINE_PCI_DEVICE_TABLE(scx200_isa) = { 559static const struct pci_device_id scx200_isa[] = {
560 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) }, 560 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
561 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) }, 561 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
562 { 0, } 562 { 0, }
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 5fb80b8962a2..7c7f4b856bad 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -48,10 +48,13 @@
48#include <linux/rwsem.h> 48#include <linux/rwsem.h>
49#include <linux/pm_runtime.h> 49#include <linux/pm_runtime.h>
50#include <linux/acpi.h> 50#include <linux/acpi.h>
51#include <linux/jump_label.h>
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
52 53
53#include "i2c-core.h" 54#include "i2c-core.h"
54 55
56#define CREATE_TRACE_POINTS
57#include <trace/events/i2c.h>
55 58
56/* core_lock protects i2c_adapter_idr, and guarantees 59/* core_lock protects i2c_adapter_idr, and guarantees
57 that device detection, deletion of detected devices, and attach_adapter 60 that device detection, deletion of detected devices, and attach_adapter
@@ -62,6 +65,18 @@ static DEFINE_IDR(i2c_adapter_idr);
62static struct device_type i2c_client_type; 65static struct device_type i2c_client_type;
63static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); 66static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
64 67
68static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
69
70void i2c_transfer_trace_reg(void)
71{
72 static_key_slow_inc(&i2c_trace_msg);
73}
74
75void i2c_transfer_trace_unreg(void)
76{
77 static_key_slow_dec(&i2c_trace_msg);
78}
79
65/* ------------------------------------------------------------------------- */ 80/* ------------------------------------------------------------------------- */
66 81
67static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, 82static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
@@ -1686,6 +1701,7 @@ static void __exit i2c_exit(void)
1686 class_compat_unregister(i2c_adapter_compat_class); 1701 class_compat_unregister(i2c_adapter_compat_class);
1687#endif 1702#endif
1688 bus_unregister(&i2c_bus_type); 1703 bus_unregister(&i2c_bus_type);
1704 tracepoint_synchronize_unregister();
1689} 1705}
1690 1706
1691/* We must initialize early, because some subsystems register i2c drivers 1707/* We must initialize early, because some subsystems register i2c drivers
@@ -1716,6 +1732,19 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
1716 unsigned long orig_jiffies; 1732 unsigned long orig_jiffies;
1717 int ret, try; 1733 int ret, try;
1718 1734
1735 /* i2c_trace_msg gets enabled when tracepoint i2c_transfer gets
1736 * enabled. This is an efficient way of keeping the for-loop from
1737 * being executed when not needed.
1738 */
1739 if (static_key_false(&i2c_trace_msg)) {
1740 int i;
1741 for (i = 0; i < num; i++)
1742 if (msgs[i].flags & I2C_M_RD)
1743 trace_i2c_read(adap, &msgs[i], i);
1744 else
1745 trace_i2c_write(adap, &msgs[i], i);
1746 }
1747
1719 /* Retry automatically on arbitration loss */ 1748 /* Retry automatically on arbitration loss */
1720 orig_jiffies = jiffies; 1749 orig_jiffies = jiffies;
1721 for (ret = 0, try = 0; try <= adap->retries; try++) { 1750 for (ret = 0, try = 0; try <= adap->retries; try++) {
@@ -1726,6 +1755,14 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
1726 break; 1755 break;
1727 } 1756 }
1728 1757
1758 if (static_key_false(&i2c_trace_msg)) {
1759 int i;
1760 for (i = 0; i < ret; i++)
1761 if (msgs[i].flags & I2C_M_RD)
1762 trace_i2c_reply(adap, &msgs[i], i);
1763 trace_i2c_result(adap, i, ret);
1764 }
1765
1729 return ret; 1766 return ret;
1730} 1767}
1731EXPORT_SYMBOL(__i2c_transfer); 1768EXPORT_SYMBOL(__i2c_transfer);
@@ -1941,6 +1978,13 @@ static int i2c_detect_address(struct i2c_client *temp_client,
1941 struct i2c_client *client; 1978 struct i2c_client *client;
1942 1979
1943 /* Detection succeeded, instantiate the device */ 1980 /* Detection succeeded, instantiate the device */
1981 if (adapter->class & I2C_CLASS_DEPRECATED)
1982 dev_warn(&adapter->dev,
1983 "This adapter will soon drop class based instantiation of devices. "
1984 "Please make sure client 0x%02x gets instantiated by other means. "
1985 "Check 'Documentation/i2c/instantiating-devices' for details.\n",
1986 info.addr);
1987
1944 dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n", 1988 dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n",
1945 info.type, info.addr); 1989 info.type, info.addr);
1946 client = i2c_new_device(adapter, &info); 1990 client = i2c_new_device(adapter, &info);
@@ -2521,6 +2565,14 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
2521 int try; 2565 int try;
2522 s32 res; 2566 s32 res;
2523 2567
2568 /* If enabled, the following two tracepoints are conditional on
2569 * read_write and protocol.
2570 */
2571 trace_smbus_write(adapter, addr, flags, read_write,
2572 command, protocol, data);
2573 trace_smbus_read(adapter, addr, flags, read_write,
2574 command, protocol);
2575
2524 flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB; 2576 flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
2525 2577
2526 if (adapter->algo->smbus_xfer) { 2578 if (adapter->algo->smbus_xfer) {
@@ -2541,15 +2593,24 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
2541 i2c_unlock_adapter(adapter); 2593 i2c_unlock_adapter(adapter);
2542 2594
2543 if (res != -EOPNOTSUPP || !adapter->algo->master_xfer) 2595 if (res != -EOPNOTSUPP || !adapter->algo->master_xfer)
2544 return res; 2596 goto trace;
2545 /* 2597 /*
2546 * Fall back to i2c_smbus_xfer_emulated if the adapter doesn't 2598 * Fall back to i2c_smbus_xfer_emulated if the adapter doesn't
2547 * implement native support for the SMBus operation. 2599 * implement native support for the SMBus operation.
2548 */ 2600 */
2549 } 2601 }
2550 2602
2551 return i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, 2603 res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write,
2552 command, protocol, data); 2604 command, protocol, data);
2605
2606trace:
2607 /* If enabled, the reply tracepoint is conditional on read_write. */
2608 trace_smbus_reply(adapter, addr, flags, read_write,
2609 command, protocol, data);
2610 trace_smbus_result(adapter, addr, flags, read_write,
2611 command, protocol, res);
2612
2613 return res;
2553} 2614}
2554EXPORT_SYMBOL(i2c_smbus_xfer); 2615EXPORT_SYMBOL(i2c_smbus_xfer);
2555 2616
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 51493ed4643b..a43220c2e3d9 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -196,6 +196,53 @@ static struct cpuidle_state snb_cstates[] = {
196 .enter = NULL } 196 .enter = NULL }
197}; 197};
198 198
199static struct cpuidle_state byt_cstates[] = {
200 {
201 .name = "C1-BYT",
202 .desc = "MWAIT 0x00",
203 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
204 .exit_latency = 1,
205 .target_residency = 1,
206 .enter = &intel_idle },
207 {
208 .name = "C1E-BYT",
209 .desc = "MWAIT 0x01",
210 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
211 .exit_latency = 15,
212 .target_residency = 30,
213 .enter = &intel_idle },
214 {
215 .name = "C6N-BYT",
216 .desc = "MWAIT 0x58",
217 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
218 .exit_latency = 40,
219 .target_residency = 275,
220 .enter = &intel_idle },
221 {
222 .name = "C6S-BYT",
223 .desc = "MWAIT 0x52",
224 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
225 .exit_latency = 140,
226 .target_residency = 560,
227 .enter = &intel_idle },
228 {
229 .name = "C7-BYT",
230 .desc = "MWAIT 0x60",
231 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
232 .exit_latency = 1200,
233 .target_residency = 1500,
234 .enter = &intel_idle },
235 {
236 .name = "C7S-BYT",
237 .desc = "MWAIT 0x64",
238 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
239 .exit_latency = 10000,
240 .target_residency = 20000,
241 .enter = &intel_idle },
242 {
243 .enter = NULL }
244};
245
199static struct cpuidle_state ivb_cstates[] = { 246static struct cpuidle_state ivb_cstates[] = {
200 { 247 {
201 .name = "C1-IVB", 248 .name = "C1-IVB",
@@ -236,6 +283,105 @@ static struct cpuidle_state ivb_cstates[] = {
236 .enter = NULL } 283 .enter = NULL }
237}; 284};
238 285
286static struct cpuidle_state ivt_cstates[] = {
287 {
288 .name = "C1-IVT",
289 .desc = "MWAIT 0x00",
290 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
291 .exit_latency = 1,
292 .target_residency = 1,
293 .enter = &intel_idle },
294 {
295 .name = "C1E-IVT",
296 .desc = "MWAIT 0x01",
297 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
298 .exit_latency = 10,
299 .target_residency = 80,
300 .enter = &intel_idle },
301 {
302 .name = "C3-IVT",
303 .desc = "MWAIT 0x10",
304 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
305 .exit_latency = 59,
306 .target_residency = 156,
307 .enter = &intel_idle },
308 {
309 .name = "C6-IVT",
310 .desc = "MWAIT 0x20",
311 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
312 .exit_latency = 82,
313 .target_residency = 300,
314 .enter = &intel_idle },
315 {
316 .enter = NULL }
317};
318
319static struct cpuidle_state ivt_cstates_4s[] = {
320 {
321 .name = "C1-IVT-4S",
322 .desc = "MWAIT 0x00",
323 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
324 .exit_latency = 1,
325 .target_residency = 1,
326 .enter = &intel_idle },
327 {
328 .name = "C1E-IVT-4S",
329 .desc = "MWAIT 0x01",
330 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
331 .exit_latency = 10,
332 .target_residency = 250,
333 .enter = &intel_idle },
334 {
335 .name = "C3-IVT-4S",
336 .desc = "MWAIT 0x10",
337 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
338 .exit_latency = 59,
339 .target_residency = 300,
340 .enter = &intel_idle },
341 {
342 .name = "C6-IVT-4S",
343 .desc = "MWAIT 0x20",
344 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
345 .exit_latency = 84,
346 .target_residency = 400,
347 .enter = &intel_idle },
348 {
349 .enter = NULL }
350};
351
352static struct cpuidle_state ivt_cstates_8s[] = {
353 {
354 .name = "C1-IVT-8S",
355 .desc = "MWAIT 0x00",
356 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
357 .exit_latency = 1,
358 .target_residency = 1,
359 .enter = &intel_idle },
360 {
361 .name = "C1E-IVT-8S",
362 .desc = "MWAIT 0x01",
363 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
364 .exit_latency = 10,
365 .target_residency = 500,
366 .enter = &intel_idle },
367 {
368 .name = "C3-IVT-8S",
369 .desc = "MWAIT 0x10",
370 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
371 .exit_latency = 59,
372 .target_residency = 600,
373 .enter = &intel_idle },
374 {
375 .name = "C6-IVT-8S",
376 .desc = "MWAIT 0x20",
377 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
378 .exit_latency = 88,
379 .target_residency = 700,
380 .enter = &intel_idle },
381 {
382 .enter = NULL }
383};
384
239static struct cpuidle_state hsw_cstates[] = { 385static struct cpuidle_state hsw_cstates[] = {
240 { 386 {
241 .name = "C1-HSW", 387 .name = "C1-HSW",
@@ -464,11 +610,21 @@ static const struct idle_cpu idle_cpu_snb = {
464 .disable_promotion_to_c1e = true, 610 .disable_promotion_to_c1e = true,
465}; 611};
466 612
613static const struct idle_cpu idle_cpu_byt = {
614 .state_table = byt_cstates,
615 .disable_promotion_to_c1e = true,
616};
617
467static const struct idle_cpu idle_cpu_ivb = { 618static const struct idle_cpu idle_cpu_ivb = {
468 .state_table = ivb_cstates, 619 .state_table = ivb_cstates,
469 .disable_promotion_to_c1e = true, 620 .disable_promotion_to_c1e = true,
470}; 621};
471 622
623static const struct idle_cpu idle_cpu_ivt = {
624 .state_table = ivt_cstates,
625 .disable_promotion_to_c1e = true,
626};
627
472static const struct idle_cpu idle_cpu_hsw = { 628static const struct idle_cpu idle_cpu_hsw = {
473 .state_table = hsw_cstates, 629 .state_table = hsw_cstates,
474 .disable_promotion_to_c1e = true, 630 .disable_promotion_to_c1e = true,
@@ -494,8 +650,10 @@ static const struct x86_cpu_id intel_idle_ids[] = {
494 ICPU(0x2f, idle_cpu_nehalem), 650 ICPU(0x2f, idle_cpu_nehalem),
495 ICPU(0x2a, idle_cpu_snb), 651 ICPU(0x2a, idle_cpu_snb),
496 ICPU(0x2d, idle_cpu_snb), 652 ICPU(0x2d, idle_cpu_snb),
653 ICPU(0x36, idle_cpu_atom),
654 ICPU(0x37, idle_cpu_byt),
497 ICPU(0x3a, idle_cpu_ivb), 655 ICPU(0x3a, idle_cpu_ivb),
498 ICPU(0x3e, idle_cpu_ivb), 656 ICPU(0x3e, idle_cpu_ivt),
499 ICPU(0x3c, idle_cpu_hsw), 657 ICPU(0x3c, idle_cpu_hsw),
500 ICPU(0x3f, idle_cpu_hsw), 658 ICPU(0x3f, idle_cpu_hsw),
501 ICPU(0x45, idle_cpu_hsw), 659 ICPU(0x45, idle_cpu_hsw),
@@ -572,6 +730,39 @@ static void intel_idle_cpuidle_devices_uninit(void)
572 free_percpu(intel_idle_cpuidle_devices); 730 free_percpu(intel_idle_cpuidle_devices);
573 return; 731 return;
574} 732}
733
734/*
735 * intel_idle_state_table_update()
736 *
737 * Update the default state_table for this CPU-id
738 *
739 * Currently used to access tuned IVT multi-socket targets
740 * Assumption: num_sockets == (max_package_num + 1)
741 */
742void intel_idle_state_table_update(void)
743{
744 /* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
745 if (boot_cpu_data.x86_model == 0x3e) { /* IVT */
746 int cpu, package_num, num_sockets = 1;
747
748 for_each_online_cpu(cpu) {
749 package_num = topology_physical_package_id(cpu);
750 if (package_num + 1 > num_sockets) {
751 num_sockets = package_num + 1;
752
753 if (num_sockets > 4)
754 cpuidle_state_table = ivt_cstates_8s;
755 return;
756 }
757 }
758
759 if (num_sockets > 2)
760 cpuidle_state_table = ivt_cstates_4s;
761 /* else, 1 and 2 socket systems use default ivt_cstates */
762 }
763 return;
764}
765
575/* 766/*
576 * intel_idle_cpuidle_driver_init() 767 * intel_idle_cpuidle_driver_init()
577 * allocate, initialize cpuidle_states 768 * allocate, initialize cpuidle_states
@@ -581,10 +772,12 @@ static int __init intel_idle_cpuidle_driver_init(void)
581 int cstate; 772 int cstate;
582 struct cpuidle_driver *drv = &intel_idle_driver; 773 struct cpuidle_driver *drv = &intel_idle_driver;
583 774
775 intel_idle_state_table_update();
776
584 drv->state_count = 1; 777 drv->state_count = 1;
585 778
586 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) { 779 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
587 int num_substates, mwait_hint, mwait_cstate, mwait_substate; 780 int num_substates, mwait_hint, mwait_cstate;
588 781
589 if (cpuidle_state_table[cstate].enter == NULL) 782 if (cpuidle_state_table[cstate].enter == NULL)
590 break; 783 break;
@@ -597,14 +790,13 @@ static int __init intel_idle_cpuidle_driver_init(void)
597 790
598 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags); 791 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
599 mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint); 792 mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
600 mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
601 793
602 /* does the state exist in CPUID.MWAIT? */ 794 /* number of sub-states for this state in CPUID.MWAIT */
603 num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4)) 795 num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
604 & MWAIT_SUBSTATE_MASK; 796 & MWAIT_SUBSTATE_MASK;
605 797
606 /* if sub-state in table is not enumerated by CPUID */ 798 /* if NO sub-states for this state in CPUID, skip it */
607 if ((mwait_substate + 1) > num_substates) 799 if (num_substates == 0)
608 continue; 800 continue;
609 801
610 if (((mwait_cstate + 1) > 2) && 802 if (((mwait_cstate + 1) > 2) &&
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 8ee228e9ab5a..c98fdb185931 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -51,6 +51,8 @@ isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn);
51static int 51static int
52isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd, 52isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
53 struct isert_rdma_wr *wr); 53 struct isert_rdma_wr *wr);
54static int
55isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd);
54 56
55static void 57static void
56isert_qp_event_callback(struct ib_event *e, void *context) 58isert_qp_event_callback(struct ib_event *e, void *context)
@@ -87,7 +89,8 @@ isert_query_device(struct ib_device *ib_dev, struct ib_device_attr *devattr)
87} 89}
88 90
89static int 91static int
90isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id) 92isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id,
93 u8 protection)
91{ 94{
92 struct isert_device *device = isert_conn->conn_device; 95 struct isert_device *device = isert_conn->conn_device;
93 struct ib_qp_init_attr attr; 96 struct ib_qp_init_attr attr;
@@ -119,6 +122,8 @@ isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id)
119 attr.cap.max_recv_sge = 1; 122 attr.cap.max_recv_sge = 1;
120 attr.sq_sig_type = IB_SIGNAL_REQ_WR; 123 attr.sq_sig_type = IB_SIGNAL_REQ_WR;
121 attr.qp_type = IB_QPT_RC; 124 attr.qp_type = IB_QPT_RC;
125 if (protection)
126 attr.create_flags |= IB_QP_CREATE_SIGNATURE_EN;
122 127
123 pr_debug("isert_conn_setup_qp cma_id->device: %p\n", 128 pr_debug("isert_conn_setup_qp cma_id->device: %p\n",
124 cma_id->device); 129 cma_id->device);
@@ -226,7 +231,8 @@ isert_create_device_ib_res(struct isert_device *device)
226 return ret; 231 return ret;
227 232
228 /* asign function handlers */ 233 /* asign function handlers */
229 if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) { 234 if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS &&
235 dev_attr->device_cap_flags & IB_DEVICE_SIGNATURE_HANDOVER) {
230 device->use_fastreg = 1; 236 device->use_fastreg = 1;
231 device->reg_rdma_mem = isert_reg_rdma; 237 device->reg_rdma_mem = isert_reg_rdma;
232 device->unreg_rdma_mem = isert_unreg_rdma; 238 device->unreg_rdma_mem = isert_unreg_rdma;
@@ -236,13 +242,18 @@ isert_create_device_ib_res(struct isert_device *device)
236 device->unreg_rdma_mem = isert_unmap_cmd; 242 device->unreg_rdma_mem = isert_unmap_cmd;
237 } 243 }
238 244
245 /* Check signature cap */
246 device->pi_capable = dev_attr->device_cap_flags &
247 IB_DEVICE_SIGNATURE_HANDOVER ? true : false;
248
239 device->cqs_used = min_t(int, num_online_cpus(), 249 device->cqs_used = min_t(int, num_online_cpus(),
240 device->ib_device->num_comp_vectors); 250 device->ib_device->num_comp_vectors);
241 device->cqs_used = min(ISERT_MAX_CQ, device->cqs_used); 251 device->cqs_used = min(ISERT_MAX_CQ, device->cqs_used);
242 pr_debug("Using %d CQs, device %s supports %d vectors support " 252 pr_debug("Using %d CQs, device %s supports %d vectors support "
243 "Fast registration %d\n", 253 "Fast registration %d pi_capable %d\n",
244 device->cqs_used, device->ib_device->name, 254 device->cqs_used, device->ib_device->name,
245 device->ib_device->num_comp_vectors, device->use_fastreg); 255 device->ib_device->num_comp_vectors, device->use_fastreg,
256 device->pi_capable);
246 device->cq_desc = kzalloc(sizeof(struct isert_cq_desc) * 257 device->cq_desc = kzalloc(sizeof(struct isert_cq_desc) *
247 device->cqs_used, GFP_KERNEL); 258 device->cqs_used, GFP_KERNEL);
248 if (!device->cq_desc) { 259 if (!device->cq_desc) {
@@ -395,6 +406,12 @@ isert_conn_free_fastreg_pool(struct isert_conn *isert_conn)
395 list_del(&fr_desc->list); 406 list_del(&fr_desc->list);
396 ib_free_fast_reg_page_list(fr_desc->data_frpl); 407 ib_free_fast_reg_page_list(fr_desc->data_frpl);
397 ib_dereg_mr(fr_desc->data_mr); 408 ib_dereg_mr(fr_desc->data_mr);
409 if (fr_desc->pi_ctx) {
410 ib_free_fast_reg_page_list(fr_desc->pi_ctx->prot_frpl);
411 ib_dereg_mr(fr_desc->pi_ctx->prot_mr);
412 ib_destroy_mr(fr_desc->pi_ctx->sig_mr);
413 kfree(fr_desc->pi_ctx);
414 }
398 kfree(fr_desc); 415 kfree(fr_desc);
399 ++i; 416 ++i;
400 } 417 }
@@ -406,8 +423,10 @@ isert_conn_free_fastreg_pool(struct isert_conn *isert_conn)
406 423
407static int 424static int
408isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd, 425isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd,
409 struct fast_reg_descriptor *fr_desc) 426 struct fast_reg_descriptor *fr_desc, u8 protection)
410{ 427{
428 int ret;
429
411 fr_desc->data_frpl = ib_alloc_fast_reg_page_list(ib_device, 430 fr_desc->data_frpl = ib_alloc_fast_reg_page_list(ib_device,
412 ISCSI_ISER_SG_TABLESIZE); 431 ISCSI_ISER_SG_TABLESIZE);
413 if (IS_ERR(fr_desc->data_frpl)) { 432 if (IS_ERR(fr_desc->data_frpl)) {
@@ -420,27 +439,88 @@ isert_create_fr_desc(struct ib_device *ib_device, struct ib_pd *pd,
420 if (IS_ERR(fr_desc->data_mr)) { 439 if (IS_ERR(fr_desc->data_mr)) {
421 pr_err("Failed to allocate data frmr err=%ld\n", 440 pr_err("Failed to allocate data frmr err=%ld\n",
422 PTR_ERR(fr_desc->data_mr)); 441 PTR_ERR(fr_desc->data_mr));
423 ib_free_fast_reg_page_list(fr_desc->data_frpl); 442 ret = PTR_ERR(fr_desc->data_mr);
424 return PTR_ERR(fr_desc->data_mr); 443 goto err_data_frpl;
425 } 444 }
426 pr_debug("Create fr_desc %p page_list %p\n", 445 pr_debug("Create fr_desc %p page_list %p\n",
427 fr_desc, fr_desc->data_frpl->page_list); 446 fr_desc, fr_desc->data_frpl->page_list);
447 fr_desc->ind |= ISERT_DATA_KEY_VALID;
448
449 if (protection) {
450 struct ib_mr_init_attr mr_init_attr = {0};
451 struct pi_context *pi_ctx;
452
453 fr_desc->pi_ctx = kzalloc(sizeof(*fr_desc->pi_ctx), GFP_KERNEL);
454 if (!fr_desc->pi_ctx) {
455 pr_err("Failed to allocate pi context\n");
456 ret = -ENOMEM;
457 goto err_data_mr;
458 }
459 pi_ctx = fr_desc->pi_ctx;
460
461 pi_ctx->prot_frpl = ib_alloc_fast_reg_page_list(ib_device,
462 ISCSI_ISER_SG_TABLESIZE);
463 if (IS_ERR(pi_ctx->prot_frpl)) {
464 pr_err("Failed to allocate prot frpl err=%ld\n",
465 PTR_ERR(pi_ctx->prot_frpl));
466 ret = PTR_ERR(pi_ctx->prot_frpl);
467 goto err_pi_ctx;
468 }
428 469
429 fr_desc->valid = true; 470 pi_ctx->prot_mr = ib_alloc_fast_reg_mr(pd, ISCSI_ISER_SG_TABLESIZE);
471 if (IS_ERR(pi_ctx->prot_mr)) {
472 pr_err("Failed to allocate prot frmr err=%ld\n",
473 PTR_ERR(pi_ctx->prot_mr));
474 ret = PTR_ERR(pi_ctx->prot_mr);
475 goto err_prot_frpl;
476 }
477 fr_desc->ind |= ISERT_PROT_KEY_VALID;
478
479 mr_init_attr.max_reg_descriptors = 2;
480 mr_init_attr.flags |= IB_MR_SIGNATURE_EN;
481 pi_ctx->sig_mr = ib_create_mr(pd, &mr_init_attr);
482 if (IS_ERR(pi_ctx->sig_mr)) {
483 pr_err("Failed to allocate signature enabled mr err=%ld\n",
484 PTR_ERR(pi_ctx->sig_mr));
485 ret = PTR_ERR(pi_ctx->sig_mr);
486 goto err_prot_mr;
487 }
488 fr_desc->ind |= ISERT_SIG_KEY_VALID;
489 }
490 fr_desc->ind &= ~ISERT_PROTECTED;
430 491
431 return 0; 492 return 0;
493err_prot_mr:
494 ib_dereg_mr(fr_desc->pi_ctx->prot_mr);
495err_prot_frpl:
496 ib_free_fast_reg_page_list(fr_desc->pi_ctx->prot_frpl);
497err_pi_ctx:
498 kfree(fr_desc->pi_ctx);
499err_data_mr:
500 ib_dereg_mr(fr_desc->data_mr);
501err_data_frpl:
502 ib_free_fast_reg_page_list(fr_desc->data_frpl);
503
504 return ret;
432} 505}
433 506
434static int 507static int
435isert_conn_create_fastreg_pool(struct isert_conn *isert_conn) 508isert_conn_create_fastreg_pool(struct isert_conn *isert_conn, u8 pi_support)
436{ 509{
437 struct fast_reg_descriptor *fr_desc; 510 struct fast_reg_descriptor *fr_desc;
438 struct isert_device *device = isert_conn->conn_device; 511 struct isert_device *device = isert_conn->conn_device;
439 int i, ret; 512 struct se_session *se_sess = isert_conn->conn->sess->se_sess;
513 struct se_node_acl *se_nacl = se_sess->se_node_acl;
514 int i, ret, tag_num;
515 /*
516 * Setup the number of FRMRs based upon the number of tags
517 * available to session in iscsi_target_locate_portal().
518 */
519 tag_num = max_t(u32, ISCSIT_MIN_TAGS, se_nacl->queue_depth);
520 tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
440 521
441 INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
442 isert_conn->conn_fr_pool_size = 0; 522 isert_conn->conn_fr_pool_size = 0;
443 for (i = 0; i < ISCSI_DEF_XMIT_CMDS_MAX; i++) { 523 for (i = 0; i < tag_num; i++) {
444 fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL); 524 fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL);
445 if (!fr_desc) { 525 if (!fr_desc) {
446 pr_err("Failed to allocate fast_reg descriptor\n"); 526 pr_err("Failed to allocate fast_reg descriptor\n");
@@ -449,7 +529,8 @@ isert_conn_create_fastreg_pool(struct isert_conn *isert_conn)
449 } 529 }
450 530
451 ret = isert_create_fr_desc(device->ib_device, 531 ret = isert_create_fr_desc(device->ib_device,
452 isert_conn->conn_pd, fr_desc); 532 isert_conn->conn_pd, fr_desc,
533 pi_support);
453 if (ret) { 534 if (ret) {
454 pr_err("Failed to create fastreg descriptor err=%d\n", 535 pr_err("Failed to create fastreg descriptor err=%d\n",
455 ret); 536 ret);
@@ -480,6 +561,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
480 struct isert_device *device; 561 struct isert_device *device;
481 struct ib_device *ib_dev = cma_id->device; 562 struct ib_device *ib_dev = cma_id->device;
482 int ret = 0; 563 int ret = 0;
564 u8 pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi;
483 565
484 pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n", 566 pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n",
485 cma_id, cma_id->context); 567 cma_id, cma_id->context);
@@ -498,6 +580,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
498 kref_get(&isert_conn->conn_kref); 580 kref_get(&isert_conn->conn_kref);
499 mutex_init(&isert_conn->conn_mutex); 581 mutex_init(&isert_conn->conn_mutex);
500 spin_lock_init(&isert_conn->conn_lock); 582 spin_lock_init(&isert_conn->conn_lock);
583 INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
501 584
502 cma_id->context = isert_conn; 585 cma_id->context = isert_conn;
503 isert_conn->conn_cm_id = cma_id; 586 isert_conn->conn_cm_id = cma_id;
@@ -569,16 +652,13 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
569 goto out_mr; 652 goto out_mr;
570 } 653 }
571 654
572 if (device->use_fastreg) { 655 if (pi_support && !device->pi_capable) {
573 ret = isert_conn_create_fastreg_pool(isert_conn); 656 pr_err("Protection information requested but not supported\n");
574 if (ret) { 657 ret = -EINVAL;
575 pr_err("Conn: %p failed to create fastreg pool\n", 658 goto out_mr;
576 isert_conn);
577 goto out_fastreg;
578 }
579 } 659 }
580 660
581 ret = isert_conn_setup_qp(isert_conn, cma_id); 661 ret = isert_conn_setup_qp(isert_conn, cma_id, pi_support);
582 if (ret) 662 if (ret)
583 goto out_conn_dev; 663 goto out_conn_dev;
584 664
@@ -591,9 +671,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
591 return 0; 671 return 0;
592 672
593out_conn_dev: 673out_conn_dev:
594 if (device->use_fastreg)
595 isert_conn_free_fastreg_pool(isert_conn);
596out_fastreg:
597 ib_dereg_mr(isert_conn->conn_mr); 674 ib_dereg_mr(isert_conn->conn_mr);
598out_mr: 675out_mr:
599 ib_dealloc_pd(isert_conn->conn_pd); 676 ib_dealloc_pd(isert_conn->conn_pd);
@@ -967,6 +1044,18 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
967 } 1044 }
968 if (!login->login_failed) { 1045 if (!login->login_failed) {
969 if (login->login_complete) { 1046 if (login->login_complete) {
1047 if (isert_conn->conn_device->use_fastreg) {
1048 u8 pi_support = login->np->tpg_np->tpg->tpg_attrib.t10_pi;
1049
1050 ret = isert_conn_create_fastreg_pool(isert_conn,
1051 pi_support);
1052 if (ret) {
1053 pr_err("Conn: %p failed to create"
1054 " fastreg pool\n", isert_conn);
1055 return ret;
1056 }
1057 }
1058
970 ret = isert_alloc_rx_descriptors(isert_conn); 1059 ret = isert_alloc_rx_descriptors(isert_conn);
971 if (ret) 1060 if (ret)
972 return ret; 1061 return ret;
@@ -1392,19 +1481,60 @@ isert_rx_completion(struct iser_rx_desc *desc, struct isert_conn *isert_conn,
1392 } 1481 }
1393} 1482}
1394 1483
1484static int
1485isert_map_data_buf(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
1486 struct scatterlist *sg, u32 nents, u32 length, u32 offset,
1487 enum iser_ib_op_code op, struct isert_data_buf *data)
1488{
1489 struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
1490
1491 data->dma_dir = op == ISER_IB_RDMA_WRITE ?
1492 DMA_TO_DEVICE : DMA_FROM_DEVICE;
1493
1494 data->len = length - offset;
1495 data->offset = offset;
1496 data->sg_off = data->offset / PAGE_SIZE;
1497
1498 data->sg = &sg[data->sg_off];
1499 data->nents = min_t(unsigned int, nents - data->sg_off,
1500 ISCSI_ISER_SG_TABLESIZE);
1501 data->len = min_t(unsigned int, data->len, ISCSI_ISER_SG_TABLESIZE *
1502 PAGE_SIZE);
1503
1504 data->dma_nents = ib_dma_map_sg(ib_dev, data->sg, data->nents,
1505 data->dma_dir);
1506 if (unlikely(!data->dma_nents)) {
1507 pr_err("Cmd: unable to dma map SGs %p\n", sg);
1508 return -EINVAL;
1509 }
1510
1511 pr_debug("Mapped cmd: %p count: %u sg: %p sg_nents: %u rdma_len %d\n",
1512 isert_cmd, data->dma_nents, data->sg, data->nents, data->len);
1513
1514 return 0;
1515}
1516
1517static void
1518isert_unmap_data_buf(struct isert_conn *isert_conn, struct isert_data_buf *data)
1519{
1520 struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
1521
1522 ib_dma_unmap_sg(ib_dev, data->sg, data->nents, data->dma_dir);
1523 memset(data, 0, sizeof(*data));
1524}
1525
1526
1527
1395static void 1528static void
1396isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) 1529isert_unmap_cmd(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
1397{ 1530{
1398 struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; 1531 struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
1399 struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
1400 1532
1401 pr_debug("isert_unmap_cmd: %p\n", isert_cmd); 1533 pr_debug("isert_unmap_cmd: %p\n", isert_cmd);
1402 if (wr->sge) { 1534
1535 if (wr->data.sg) {
1403 pr_debug("isert_unmap_cmd: %p unmap_sg op\n", isert_cmd); 1536 pr_debug("isert_unmap_cmd: %p unmap_sg op\n", isert_cmd);
1404 ib_dma_unmap_sg(ib_dev, wr->sge, wr->num_sge, 1537 isert_unmap_data_buf(isert_conn, &wr->data);
1405 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ?
1406 DMA_TO_DEVICE : DMA_FROM_DEVICE);
1407 wr->sge = NULL;
1408 } 1538 }
1409 1539
1410 if (wr->send_wr) { 1540 if (wr->send_wr) {
@@ -1424,7 +1554,6 @@ static void
1424isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn) 1554isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
1425{ 1555{
1426 struct isert_rdma_wr *wr = &isert_cmd->rdma_wr; 1556 struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
1427 struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
1428 LIST_HEAD(unmap_list); 1557 LIST_HEAD(unmap_list);
1429 1558
1430 pr_debug("unreg_fastreg_cmd: %p\n", isert_cmd); 1559 pr_debug("unreg_fastreg_cmd: %p\n", isert_cmd);
@@ -1432,18 +1561,19 @@ isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
1432 if (wr->fr_desc) { 1561 if (wr->fr_desc) {
1433 pr_debug("unreg_fastreg_cmd: %p free fr_desc %p\n", 1562 pr_debug("unreg_fastreg_cmd: %p free fr_desc %p\n",
1434 isert_cmd, wr->fr_desc); 1563 isert_cmd, wr->fr_desc);
1564 if (wr->fr_desc->ind & ISERT_PROTECTED) {
1565 isert_unmap_data_buf(isert_conn, &wr->prot);
1566 wr->fr_desc->ind &= ~ISERT_PROTECTED;
1567 }
1435 spin_lock_bh(&isert_conn->conn_lock); 1568 spin_lock_bh(&isert_conn->conn_lock);
1436 list_add_tail(&wr->fr_desc->list, &isert_conn->conn_fr_pool); 1569 list_add_tail(&wr->fr_desc->list, &isert_conn->conn_fr_pool);
1437 spin_unlock_bh(&isert_conn->conn_lock); 1570 spin_unlock_bh(&isert_conn->conn_lock);
1438 wr->fr_desc = NULL; 1571 wr->fr_desc = NULL;
1439 } 1572 }
1440 1573
1441 if (wr->sge) { 1574 if (wr->data.sg) {
1442 pr_debug("unreg_fastreg_cmd: %p unmap_sg op\n", isert_cmd); 1575 pr_debug("unreg_fastreg_cmd: %p unmap_sg op\n", isert_cmd);
1443 ib_dma_unmap_sg(ib_dev, wr->sge, wr->num_sge, 1576 isert_unmap_data_buf(isert_conn, &wr->data);
1444 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ?
1445 DMA_TO_DEVICE : DMA_FROM_DEVICE);
1446 wr->sge = NULL;
1447 } 1577 }
1448 1578
1449 wr->ib_sge = NULL; 1579 wr->ib_sge = NULL;
@@ -1451,7 +1581,7 @@ isert_unreg_rdma(struct isert_cmd *isert_cmd, struct isert_conn *isert_conn)
1451} 1581}
1452 1582
1453static void 1583static void
1454isert_put_cmd(struct isert_cmd *isert_cmd) 1584isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)
1455{ 1585{
1456 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; 1586 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
1457 struct isert_conn *isert_conn = isert_cmd->conn; 1587 struct isert_conn *isert_conn = isert_cmd->conn;
@@ -1467,8 +1597,21 @@ isert_put_cmd(struct isert_cmd *isert_cmd)
1467 list_del_init(&cmd->i_conn_node); 1597 list_del_init(&cmd->i_conn_node);
1468 spin_unlock_bh(&conn->cmd_lock); 1598 spin_unlock_bh(&conn->cmd_lock);
1469 1599
1470 if (cmd->data_direction == DMA_TO_DEVICE) 1600 if (cmd->data_direction == DMA_TO_DEVICE) {
1471 iscsit_stop_dataout_timer(cmd); 1601 iscsit_stop_dataout_timer(cmd);
1602 /*
1603 * Check for special case during comp_err where
1604 * WRITE_PENDING has been handed off from core,
1605 * but requires an extra target_put_sess_cmd()
1606 * before transport_generic_free_cmd() below.
1607 */
1608 if (comp_err &&
1609 cmd->se_cmd.t_state == TRANSPORT_WRITE_PENDING) {
1610 struct se_cmd *se_cmd = &cmd->se_cmd;
1611
1612 target_put_sess_cmd(se_cmd->se_sess, se_cmd);
1613 }
1614 }
1472 1615
1473 device->unreg_rdma_mem(isert_cmd, isert_conn); 1616 device->unreg_rdma_mem(isert_cmd, isert_conn);
1474 transport_generic_free_cmd(&cmd->se_cmd, 0); 1617 transport_generic_free_cmd(&cmd->se_cmd, 0);
@@ -1523,7 +1666,7 @@ isert_unmap_tx_desc(struct iser_tx_desc *tx_desc, struct ib_device *ib_dev)
1523 1666
1524static void 1667static void
1525isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd, 1668isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
1526 struct ib_device *ib_dev) 1669 struct ib_device *ib_dev, bool comp_err)
1527{ 1670{
1528 if (isert_cmd->pdu_buf_dma != 0) { 1671 if (isert_cmd->pdu_buf_dma != 0) {
1529 pr_debug("Calling ib_dma_unmap_single for isert_cmd->pdu_buf_dma\n"); 1672 pr_debug("Calling ib_dma_unmap_single for isert_cmd->pdu_buf_dma\n");
@@ -1533,7 +1676,77 @@ isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
1533 } 1676 }
1534 1677
1535 isert_unmap_tx_desc(tx_desc, ib_dev); 1678 isert_unmap_tx_desc(tx_desc, ib_dev);
1536 isert_put_cmd(isert_cmd); 1679 isert_put_cmd(isert_cmd, comp_err);
1680}
1681
1682static int
1683isert_check_pi_status(struct se_cmd *se_cmd, struct ib_mr *sig_mr)
1684{
1685 struct ib_mr_status mr_status;
1686 int ret;
1687
1688 ret = ib_check_mr_status(sig_mr, IB_MR_CHECK_SIG_STATUS, &mr_status);
1689 if (ret) {
1690 pr_err("ib_check_mr_status failed, ret %d\n", ret);
1691 goto fail_mr_status;
1692 }
1693
1694 if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
1695 u64 sec_offset_err;
1696 u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
1697
1698 switch (mr_status.sig_err.err_type) {
1699 case IB_SIG_BAD_GUARD:
1700 se_cmd->pi_err = TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
1701 break;
1702 case IB_SIG_BAD_REFTAG:
1703 se_cmd->pi_err = TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED;
1704 break;
1705 case IB_SIG_BAD_APPTAG:
1706 se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
1707 break;
1708 }
1709 sec_offset_err = mr_status.sig_err.sig_err_offset;
1710 do_div(sec_offset_err, block_size);
1711 se_cmd->bad_sector = sec_offset_err + se_cmd->t_task_lba;
1712
1713 pr_err("isert: PI error found type %d at sector 0x%llx "
1714 "expected 0x%x vs actual 0x%x\n",
1715 mr_status.sig_err.err_type,
1716 (unsigned long long)se_cmd->bad_sector,
1717 mr_status.sig_err.expected,
1718 mr_status.sig_err.actual);
1719 ret = 1;
1720 }
1721
1722fail_mr_status:
1723 return ret;
1724}
1725
1726static void
1727isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
1728 struct isert_cmd *isert_cmd)
1729{
1730 struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
1731 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
1732 struct se_cmd *se_cmd = &cmd->se_cmd;
1733 struct isert_conn *isert_conn = isert_cmd->conn;
1734 struct isert_device *device = isert_conn->conn_device;
1735 int ret = 0;
1736
1737 if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
1738 ret = isert_check_pi_status(se_cmd,
1739 wr->fr_desc->pi_ctx->sig_mr);
1740 wr->fr_desc->ind &= ~ISERT_PROTECTED;
1741 }
1742
1743 device->unreg_rdma_mem(isert_cmd, isert_conn);
1744 wr->send_wr_num = 0;
1745 if (ret)
1746 transport_send_check_condition_and_sense(se_cmd,
1747 se_cmd->pi_err, 0);
1748 else
1749 isert_put_response(isert_conn->conn, cmd);
1537} 1750}
1538 1751
1539static void 1752static void
@@ -1545,10 +1758,17 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc,
1545 struct se_cmd *se_cmd = &cmd->se_cmd; 1758 struct se_cmd *se_cmd = &cmd->se_cmd;
1546 struct isert_conn *isert_conn = isert_cmd->conn; 1759 struct isert_conn *isert_conn = isert_cmd->conn;
1547 struct isert_device *device = isert_conn->conn_device; 1760 struct isert_device *device = isert_conn->conn_device;
1761 int ret = 0;
1762
1763 if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
1764 ret = isert_check_pi_status(se_cmd,
1765 wr->fr_desc->pi_ctx->sig_mr);
1766 wr->fr_desc->ind &= ~ISERT_PROTECTED;
1767 }
1548 1768
1549 iscsit_stop_dataout_timer(cmd); 1769 iscsit_stop_dataout_timer(cmd);
1550 device->unreg_rdma_mem(isert_cmd, isert_conn); 1770 device->unreg_rdma_mem(isert_cmd, isert_conn);
1551 cmd->write_data_done = wr->cur_rdma_length; 1771 cmd->write_data_done = wr->data.len;
1552 wr->send_wr_num = 0; 1772 wr->send_wr_num = 0;
1553 1773
1554 pr_debug("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); 1774 pr_debug("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd);
@@ -1557,7 +1777,11 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc,
1557 cmd->i_state = ISTATE_RECEIVED_LAST_DATAOUT; 1777 cmd->i_state = ISTATE_RECEIVED_LAST_DATAOUT;
1558 spin_unlock_bh(&cmd->istate_lock); 1778 spin_unlock_bh(&cmd->istate_lock);
1559 1779
1560 target_execute_cmd(se_cmd); 1780 if (ret)
1781 transport_send_check_condition_and_sense(se_cmd,
1782 se_cmd->pi_err, 0);
1783 else
1784 target_execute_cmd(se_cmd);
1561} 1785}
1562 1786
1563static void 1787static void
@@ -1577,14 +1801,14 @@ isert_do_control_comp(struct work_struct *work)
1577 iscsit_tmr_post_handler(cmd, cmd->conn); 1801 iscsit_tmr_post_handler(cmd, cmd->conn);
1578 1802
1579 cmd->i_state = ISTATE_SENT_STATUS; 1803 cmd->i_state = ISTATE_SENT_STATUS;
1580 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev); 1804 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
1581 break; 1805 break;
1582 case ISTATE_SEND_REJECT: 1806 case ISTATE_SEND_REJECT:
1583 pr_debug("Got isert_do_control_comp ISTATE_SEND_REJECT: >>>\n"); 1807 pr_debug("Got isert_do_control_comp ISTATE_SEND_REJECT: >>>\n");
1584 atomic_dec(&isert_conn->post_send_buf_count); 1808 atomic_dec(&isert_conn->post_send_buf_count);
1585 1809
1586 cmd->i_state = ISTATE_SENT_STATUS; 1810 cmd->i_state = ISTATE_SENT_STATUS;
1587 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev); 1811 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
1588 break; 1812 break;
1589 case ISTATE_SEND_LOGOUTRSP: 1813 case ISTATE_SEND_LOGOUTRSP:
1590 pr_debug("Calling iscsit_logout_post_handler >>>>>>>>>>>>>>\n"); 1814 pr_debug("Calling iscsit_logout_post_handler >>>>>>>>>>>>>>\n");
@@ -1598,7 +1822,7 @@ isert_do_control_comp(struct work_struct *work)
1598 case ISTATE_SEND_TEXTRSP: 1822 case ISTATE_SEND_TEXTRSP:
1599 atomic_dec(&isert_conn->post_send_buf_count); 1823 atomic_dec(&isert_conn->post_send_buf_count);
1600 cmd->i_state = ISTATE_SENT_STATUS; 1824 cmd->i_state = ISTATE_SENT_STATUS;
1601 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev); 1825 isert_completion_put(&isert_cmd->tx_desc, isert_cmd, ib_dev, false);
1602 break; 1826 break;
1603 default: 1827 default:
1604 pr_err("Unknown do_control_comp i_state %d\n", cmd->i_state); 1828 pr_err("Unknown do_control_comp i_state %d\n", cmd->i_state);
@@ -1626,10 +1850,21 @@ isert_response_completion(struct iser_tx_desc *tx_desc,
1626 queue_work(isert_comp_wq, &isert_cmd->comp_work); 1850 queue_work(isert_comp_wq, &isert_cmd->comp_work);
1627 return; 1851 return;
1628 } 1852 }
1629 atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count); 1853
1854 /**
1855 * If send_wr_num is 0 this means that we got
1856 * RDMA completion and we cleared it and we should
1857 * simply decrement the response post. else the
1858 * response is incorporated in send_wr_num, just
1859 * sub it.
1860 **/
1861 if (wr->send_wr_num)
1862 atomic_sub(wr->send_wr_num, &isert_conn->post_send_buf_count);
1863 else
1864 atomic_dec(&isert_conn->post_send_buf_count);
1630 1865
1631 cmd->i_state = ISTATE_SENT_STATUS; 1866 cmd->i_state = ISTATE_SENT_STATUS;
1632 isert_completion_put(tx_desc, isert_cmd, ib_dev); 1867 isert_completion_put(tx_desc, isert_cmd, ib_dev, false);
1633} 1868}
1634 1869
1635static void 1870static void
@@ -1658,8 +1893,9 @@ __isert_send_completion(struct iser_tx_desc *tx_desc,
1658 isert_conn, ib_dev); 1893 isert_conn, ib_dev);
1659 break; 1894 break;
1660 case ISER_IB_RDMA_WRITE: 1895 case ISER_IB_RDMA_WRITE:
1661 pr_err("isert_send_completion: Got ISER_IB_RDMA_WRITE\n"); 1896 pr_debug("isert_send_completion: Got ISER_IB_RDMA_WRITE\n");
1662 dump_stack(); 1897 atomic_sub(wr->send_wr_num, &isert_conn->post_send_buf_count);
1898 isert_completion_rdma_write(tx_desc, isert_cmd);
1663 break; 1899 break;
1664 case ISER_IB_RDMA_READ: 1900 case ISER_IB_RDMA_READ:
1665 pr_debug("isert_send_completion: Got ISER_IB_RDMA_READ:\n"); 1901 pr_debug("isert_send_completion: Got ISER_IB_RDMA_READ:\n");
@@ -1709,8 +1945,20 @@ isert_cq_drain_comp_llist(struct isert_conn *isert_conn, struct ib_device *ib_de
1709 llnode = llist_next(llnode); 1945 llnode = llist_next(llnode);
1710 wr = &t->isert_cmd->rdma_wr; 1946 wr = &t->isert_cmd->rdma_wr;
1711 1947
1712 atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count); 1948 /**
1713 isert_completion_put(t, t->isert_cmd, ib_dev); 1949 * If send_wr_num is 0 this means that we got
1950 * RDMA completion and we cleared it and we should
1951 * simply decrement the response post. else the
1952 * response is incorporated in send_wr_num, just
1953 * sub it.
1954 **/
1955 if (wr->send_wr_num)
1956 atomic_sub(wr->send_wr_num,
1957 &isert_conn->post_send_buf_count);
1958 else
1959 atomic_dec(&isert_conn->post_send_buf_count);
1960
1961 isert_completion_put(t, t->isert_cmd, ib_dev, true);
1714 } 1962 }
1715} 1963}
1716 1964
@@ -1728,15 +1976,27 @@ isert_cq_tx_comp_err(struct iser_tx_desc *tx_desc, struct isert_conn *isert_conn
1728 llnode = llist_next(llnode); 1976 llnode = llist_next(llnode);
1729 wr = &t->isert_cmd->rdma_wr; 1977 wr = &t->isert_cmd->rdma_wr;
1730 1978
1731 atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count); 1979 /**
1732 isert_completion_put(t, t->isert_cmd, ib_dev); 1980 * If send_wr_num is 0 this means that we got
1981 * RDMA completion and we cleared it and we should
1982 * simply decrement the response post. else the
1983 * response is incorporated in send_wr_num, just
1984 * sub it.
1985 **/
1986 if (wr->send_wr_num)
1987 atomic_sub(wr->send_wr_num,
1988 &isert_conn->post_send_buf_count);
1989 else
1990 atomic_dec(&isert_conn->post_send_buf_count);
1991
1992 isert_completion_put(t, t->isert_cmd, ib_dev, true);
1733 } 1993 }
1734 tx_desc->comp_llnode_batch = NULL; 1994 tx_desc->comp_llnode_batch = NULL;
1735 1995
1736 if (!isert_cmd) 1996 if (!isert_cmd)
1737 isert_unmap_tx_desc(tx_desc, ib_dev); 1997 isert_unmap_tx_desc(tx_desc, ib_dev);
1738 else 1998 else
1739 isert_completion_put(tx_desc, isert_cmd, ib_dev); 1999 isert_completion_put(tx_desc, isert_cmd, ib_dev, true);
1740} 2000}
1741 2001
1742static void 2002static void
@@ -1918,6 +2178,36 @@ isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
1918 return isert_post_response(isert_conn, isert_cmd); 2178 return isert_post_response(isert_conn, isert_cmd);
1919} 2179}
1920 2180
2181static void
2182isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
2183{
2184 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
2185 struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
2186 struct isert_device *device = isert_conn->conn_device;
2187
2188 spin_lock_bh(&conn->cmd_lock);
2189 if (!list_empty(&cmd->i_conn_node))
2190 list_del_init(&cmd->i_conn_node);
2191 spin_unlock_bh(&conn->cmd_lock);
2192
2193 if (cmd->data_direction == DMA_TO_DEVICE)
2194 iscsit_stop_dataout_timer(cmd);
2195
2196 device->unreg_rdma_mem(isert_cmd, isert_conn);
2197}
2198
2199static enum target_prot_op
2200isert_get_sup_prot_ops(struct iscsi_conn *conn)
2201{
2202 struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
2203 struct isert_device *device = isert_conn->conn_device;
2204
2205 if (device->pi_capable)
2206 return TARGET_PROT_ALL;
2207
2208 return TARGET_PROT_NORMAL;
2209}
2210
1921static int 2211static int
1922isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, 2212isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
1923 bool nopout_response) 2213 bool nopout_response)
@@ -2099,54 +2389,39 @@ isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2099 struct se_cmd *se_cmd = &cmd->se_cmd; 2389 struct se_cmd *se_cmd = &cmd->se_cmd;
2100 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); 2390 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
2101 struct isert_conn *isert_conn = (struct isert_conn *)conn->context; 2391 struct isert_conn *isert_conn = (struct isert_conn *)conn->context;
2102 struct ib_device *ib_dev = isert_conn->conn_cm_id->device; 2392 struct isert_data_buf *data = &wr->data;
2103 struct ib_send_wr *send_wr; 2393 struct ib_send_wr *send_wr;
2104 struct ib_sge *ib_sge; 2394 struct ib_sge *ib_sge;
2105 struct scatterlist *sg_start; 2395 u32 offset, data_len, data_left, rdma_write_max, va_offset = 0;
2106 u32 sg_off = 0, sg_nents; 2396 int ret = 0, i, ib_sge_cnt;
2107 u32 offset = 0, data_len, data_left, rdma_write_max, va_offset = 0;
2108 int ret = 0, count, i, ib_sge_cnt;
2109 2397
2110 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { 2398 isert_cmd->tx_desc.isert_cmd = isert_cmd;
2111 data_left = se_cmd->data_length;
2112 } else {
2113 sg_off = cmd->write_data_done / PAGE_SIZE;
2114 data_left = se_cmd->data_length - cmd->write_data_done;
2115 offset = cmd->write_data_done;
2116 isert_cmd->tx_desc.isert_cmd = isert_cmd;
2117 }
2118 2399
2119 sg_start = &cmd->se_cmd.t_data_sg[sg_off]; 2400 offset = wr->iser_ib_op == ISER_IB_RDMA_READ ? cmd->write_data_done : 0;
2120 sg_nents = se_cmd->t_data_nents - sg_off; 2401 ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg,
2402 se_cmd->t_data_nents, se_cmd->data_length,
2403 offset, wr->iser_ib_op, &wr->data);
2404 if (ret)
2405 return ret;
2121 2406
2122 count = ib_dma_map_sg(ib_dev, sg_start, sg_nents, 2407 data_left = data->len;
2123 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ? 2408 offset = data->offset;
2124 DMA_TO_DEVICE : DMA_FROM_DEVICE);
2125 if (unlikely(!count)) {
2126 pr_err("Cmd: %p unrable to map SGs\n", isert_cmd);
2127 return -EINVAL;
2128 }
2129 wr->sge = sg_start;
2130 wr->num_sge = sg_nents;
2131 wr->cur_rdma_length = data_left;
2132 pr_debug("Mapped cmd: %p count: %u sg: %p sg_nents: %u rdma_len %d\n",
2133 isert_cmd, count, sg_start, sg_nents, data_left);
2134 2409
2135 ib_sge = kzalloc(sizeof(struct ib_sge) * sg_nents, GFP_KERNEL); 2410 ib_sge = kzalloc(sizeof(struct ib_sge) * data->nents, GFP_KERNEL);
2136 if (!ib_sge) { 2411 if (!ib_sge) {
2137 pr_warn("Unable to allocate ib_sge\n"); 2412 pr_warn("Unable to allocate ib_sge\n");
2138 ret = -ENOMEM; 2413 ret = -ENOMEM;
2139 goto unmap_sg; 2414 goto unmap_cmd;
2140 } 2415 }
2141 wr->ib_sge = ib_sge; 2416 wr->ib_sge = ib_sge;
2142 2417
2143 wr->send_wr_num = DIV_ROUND_UP(sg_nents, isert_conn->max_sge); 2418 wr->send_wr_num = DIV_ROUND_UP(data->nents, isert_conn->max_sge);
2144 wr->send_wr = kzalloc(sizeof(struct ib_send_wr) * wr->send_wr_num, 2419 wr->send_wr = kzalloc(sizeof(struct ib_send_wr) * wr->send_wr_num,
2145 GFP_KERNEL); 2420 GFP_KERNEL);
2146 if (!wr->send_wr) { 2421 if (!wr->send_wr) {
2147 pr_debug("Unable to allocate wr->send_wr\n"); 2422 pr_debug("Unable to allocate wr->send_wr\n");
2148 ret = -ENOMEM; 2423 ret = -ENOMEM;
2149 goto unmap_sg; 2424 goto unmap_cmd;
2150 } 2425 }
2151 2426
2152 wr->isert_cmd = isert_cmd; 2427 wr->isert_cmd = isert_cmd;
@@ -2185,10 +2460,9 @@ isert_map_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2185 } 2460 }
2186 2461
2187 return 0; 2462 return 0;
2188unmap_sg: 2463unmap_cmd:
2189 ib_dma_unmap_sg(ib_dev, sg_start, sg_nents, 2464 isert_unmap_data_buf(isert_conn, data);
2190 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ? 2465
2191 DMA_TO_DEVICE : DMA_FROM_DEVICE);
2192 return ret; 2466 return ret;
2193} 2467}
2194 2468
@@ -2232,49 +2506,70 @@ isert_map_fr_pagelist(struct ib_device *ib_dev,
2232} 2506}
2233 2507
2234static int 2508static int
2235isert_fast_reg_mr(struct fast_reg_descriptor *fr_desc, 2509isert_fast_reg_mr(struct isert_conn *isert_conn,
2236 struct isert_conn *isert_conn, struct scatterlist *sg_start, 2510 struct fast_reg_descriptor *fr_desc,
2237 struct ib_sge *ib_sge, u32 sg_nents, u32 offset, 2511 struct isert_data_buf *mem,
2238 unsigned int data_len) 2512 enum isert_indicator ind,
2513 struct ib_sge *sge)
2239{ 2514{
2240 struct ib_device *ib_dev = isert_conn->conn_cm_id->device; 2515 struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
2516 struct ib_mr *mr;
2517 struct ib_fast_reg_page_list *frpl;
2241 struct ib_send_wr fr_wr, inv_wr; 2518 struct ib_send_wr fr_wr, inv_wr;
2242 struct ib_send_wr *bad_wr, *wr = NULL; 2519 struct ib_send_wr *bad_wr, *wr = NULL;
2243 int ret, pagelist_len; 2520 int ret, pagelist_len;
2244 u32 page_off; 2521 u32 page_off;
2245 u8 key; 2522 u8 key;
2246 2523
2247 sg_nents = min_t(unsigned int, sg_nents, ISCSI_ISER_SG_TABLESIZE); 2524 if (mem->dma_nents == 1) {
2248 page_off = offset % PAGE_SIZE; 2525 sge->lkey = isert_conn->conn_mr->lkey;
2526 sge->addr = ib_sg_dma_address(ib_dev, &mem->sg[0]);
2527 sge->length = ib_sg_dma_len(ib_dev, &mem->sg[0]);
2528 pr_debug("%s:%d sge: addr: 0x%llx length: %u lkey: %x\n",
2529 __func__, __LINE__, sge->addr, sge->length,
2530 sge->lkey);
2531 return 0;
2532 }
2533
2534 if (ind == ISERT_DATA_KEY_VALID) {
2535 /* Registering data buffer */
2536 mr = fr_desc->data_mr;
2537 frpl = fr_desc->data_frpl;
2538 } else {
2539 /* Registering protection buffer */
2540 mr = fr_desc->pi_ctx->prot_mr;
2541 frpl = fr_desc->pi_ctx->prot_frpl;
2542 }
2543
2544 page_off = mem->offset % PAGE_SIZE;
2249 2545
2250 pr_debug("Use fr_desc %p sg_nents %d offset %u\n", 2546 pr_debug("Use fr_desc %p sg_nents %d offset %u\n",
2251 fr_desc, sg_nents, offset); 2547 fr_desc, mem->nents, mem->offset);
2252 2548
2253 pagelist_len = isert_map_fr_pagelist(ib_dev, sg_start, sg_nents, 2549 pagelist_len = isert_map_fr_pagelist(ib_dev, mem->sg, mem->nents,
2254 &fr_desc->data_frpl->page_list[0]); 2550 &frpl->page_list[0]);
2255 2551
2256 if (!fr_desc->valid) { 2552 if (!(fr_desc->ind & ISERT_DATA_KEY_VALID)) {
2257 memset(&inv_wr, 0, sizeof(inv_wr)); 2553 memset(&inv_wr, 0, sizeof(inv_wr));
2258 inv_wr.wr_id = ISER_FASTREG_LI_WRID; 2554 inv_wr.wr_id = ISER_FASTREG_LI_WRID;
2259 inv_wr.opcode = IB_WR_LOCAL_INV; 2555 inv_wr.opcode = IB_WR_LOCAL_INV;
2260 inv_wr.ex.invalidate_rkey = fr_desc->data_mr->rkey; 2556 inv_wr.ex.invalidate_rkey = mr->rkey;
2261 wr = &inv_wr; 2557 wr = &inv_wr;
2262 /* Bump the key */ 2558 /* Bump the key */
2263 key = (u8)(fr_desc->data_mr->rkey & 0x000000FF); 2559 key = (u8)(mr->rkey & 0x000000FF);
2264 ib_update_fast_reg_key(fr_desc->data_mr, ++key); 2560 ib_update_fast_reg_key(mr, ++key);
2265 } 2561 }
2266 2562
2267 /* Prepare FASTREG WR */ 2563 /* Prepare FASTREG WR */
2268 memset(&fr_wr, 0, sizeof(fr_wr)); 2564 memset(&fr_wr, 0, sizeof(fr_wr));
2269 fr_wr.wr_id = ISER_FASTREG_LI_WRID; 2565 fr_wr.wr_id = ISER_FASTREG_LI_WRID;
2270 fr_wr.opcode = IB_WR_FAST_REG_MR; 2566 fr_wr.opcode = IB_WR_FAST_REG_MR;
2271 fr_wr.wr.fast_reg.iova_start = 2567 fr_wr.wr.fast_reg.iova_start = frpl->page_list[0] + page_off;
2272 fr_desc->data_frpl->page_list[0] + page_off; 2568 fr_wr.wr.fast_reg.page_list = frpl;
2273 fr_wr.wr.fast_reg.page_list = fr_desc->data_frpl;
2274 fr_wr.wr.fast_reg.page_list_len = pagelist_len; 2569 fr_wr.wr.fast_reg.page_list_len = pagelist_len;
2275 fr_wr.wr.fast_reg.page_shift = PAGE_SHIFT; 2570 fr_wr.wr.fast_reg.page_shift = PAGE_SHIFT;
2276 fr_wr.wr.fast_reg.length = data_len; 2571 fr_wr.wr.fast_reg.length = mem->len;
2277 fr_wr.wr.fast_reg.rkey = fr_desc->data_mr->rkey; 2572 fr_wr.wr.fast_reg.rkey = mr->rkey;
2278 fr_wr.wr.fast_reg.access_flags = IB_ACCESS_LOCAL_WRITE; 2573 fr_wr.wr.fast_reg.access_flags = IB_ACCESS_LOCAL_WRITE;
2279 2574
2280 if (!wr) 2575 if (!wr)
@@ -2287,15 +2582,157 @@ isert_fast_reg_mr(struct fast_reg_descriptor *fr_desc,
2287 pr_err("fast registration failed, ret:%d\n", ret); 2582 pr_err("fast registration failed, ret:%d\n", ret);
2288 return ret; 2583 return ret;
2289 } 2584 }
2290 fr_desc->valid = false; 2585 fr_desc->ind &= ~ind;
2586
2587 sge->lkey = mr->lkey;
2588 sge->addr = frpl->page_list[0] + page_off;
2589 sge->length = mem->len;
2590
2591 pr_debug("%s:%d sge: addr: 0x%llx length: %u lkey: %x\n",
2592 __func__, __LINE__, sge->addr, sge->length,
2593 sge->lkey);
2594
2595 return ret;
2596}
2597
2598static inline enum ib_t10_dif_type
2599se2ib_prot_type(enum target_prot_type prot_type)
2600{
2601 switch (prot_type) {
2602 case TARGET_DIF_TYPE0_PROT:
2603 return IB_T10DIF_NONE;
2604 case TARGET_DIF_TYPE1_PROT:
2605 return IB_T10DIF_TYPE1;
2606 case TARGET_DIF_TYPE2_PROT:
2607 return IB_T10DIF_TYPE2;
2608 case TARGET_DIF_TYPE3_PROT:
2609 return IB_T10DIF_TYPE3;
2610 default:
2611 return IB_T10DIF_NONE;
2612 }
2613}
2291 2614
2292 ib_sge->lkey = fr_desc->data_mr->lkey; 2615static int
2293 ib_sge->addr = fr_desc->data_frpl->page_list[0] + page_off; 2616isert_set_sig_attrs(struct se_cmd *se_cmd, struct ib_sig_attrs *sig_attrs)
2294 ib_sge->length = data_len; 2617{
2618 enum ib_t10_dif_type ib_prot_type = se2ib_prot_type(se_cmd->prot_type);
2619
2620 sig_attrs->mem.sig_type = IB_SIG_TYPE_T10_DIF;
2621 sig_attrs->wire.sig_type = IB_SIG_TYPE_T10_DIF;
2622 sig_attrs->mem.sig.dif.pi_interval =
2623 se_cmd->se_dev->dev_attrib.block_size;
2624 sig_attrs->wire.sig.dif.pi_interval =
2625 se_cmd->se_dev->dev_attrib.block_size;
2626
2627 switch (se_cmd->prot_op) {
2628 case TARGET_PROT_DIN_INSERT:
2629 case TARGET_PROT_DOUT_STRIP:
2630 sig_attrs->mem.sig.dif.type = IB_T10DIF_NONE;
2631 sig_attrs->wire.sig.dif.type = ib_prot_type;
2632 sig_attrs->wire.sig.dif.bg_type = IB_T10DIF_CRC;
2633 sig_attrs->wire.sig.dif.ref_tag = se_cmd->reftag_seed;
2634 break;
2635 case TARGET_PROT_DOUT_INSERT:
2636 case TARGET_PROT_DIN_STRIP:
2637 sig_attrs->mem.sig.dif.type = ib_prot_type;
2638 sig_attrs->mem.sig.dif.bg_type = IB_T10DIF_CRC;
2639 sig_attrs->mem.sig.dif.ref_tag = se_cmd->reftag_seed;
2640 sig_attrs->wire.sig.dif.type = IB_T10DIF_NONE;
2641 break;
2642 case TARGET_PROT_DIN_PASS:
2643 case TARGET_PROT_DOUT_PASS:
2644 sig_attrs->mem.sig.dif.type = ib_prot_type;
2645 sig_attrs->mem.sig.dif.bg_type = IB_T10DIF_CRC;
2646 sig_attrs->mem.sig.dif.ref_tag = se_cmd->reftag_seed;
2647 sig_attrs->wire.sig.dif.type = ib_prot_type;
2648 sig_attrs->wire.sig.dif.bg_type = IB_T10DIF_CRC;
2649 sig_attrs->wire.sig.dif.ref_tag = se_cmd->reftag_seed;
2650 break;
2651 default:
2652 pr_err("Unsupported PI operation %d\n", se_cmd->prot_op);
2653 return -EINVAL;
2654 }
2295 2655
2296 pr_debug("RDMA ib_sge: addr: 0x%16llx length: %u lkey: %08x\n", 2656 return 0;
2297 ib_sge->addr, ib_sge->length, ib_sge->lkey); 2657}
2658
2659static inline u8
2660isert_set_prot_checks(u8 prot_checks)
2661{
2662 return (prot_checks & TARGET_DIF_CHECK_GUARD ? 0xc0 : 0) |
2663 (prot_checks & TARGET_DIF_CHECK_REFTAG ? 0x30 : 0) |
2664 (prot_checks & TARGET_DIF_CHECK_REFTAG ? 0x0f : 0);
2665}
2666
2667static int
2668isert_reg_sig_mr(struct isert_conn *isert_conn, struct se_cmd *se_cmd,
2669 struct fast_reg_descriptor *fr_desc,
2670 struct ib_sge *data_sge, struct ib_sge *prot_sge,
2671 struct ib_sge *sig_sge)
2672{
2673 struct ib_send_wr sig_wr, inv_wr;
2674 struct ib_send_wr *bad_wr, *wr = NULL;
2675 struct pi_context *pi_ctx = fr_desc->pi_ctx;
2676 struct ib_sig_attrs sig_attrs;
2677 int ret;
2678 u32 key;
2679
2680 memset(&sig_attrs, 0, sizeof(sig_attrs));
2681 ret = isert_set_sig_attrs(se_cmd, &sig_attrs);
2682 if (ret)
2683 goto err;
2684
2685 sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks);
2686
2687 if (!(fr_desc->ind & ISERT_SIG_KEY_VALID)) {
2688 memset(&inv_wr, 0, sizeof(inv_wr));
2689 inv_wr.opcode = IB_WR_LOCAL_INV;
2690 inv_wr.wr_id = ISER_FASTREG_LI_WRID;
2691 inv_wr.ex.invalidate_rkey = pi_ctx->sig_mr->rkey;
2692 wr = &inv_wr;
2693 /* Bump the key */
2694 key = (u8)(pi_ctx->sig_mr->rkey & 0x000000FF);
2695 ib_update_fast_reg_key(pi_ctx->sig_mr, ++key);
2696 }
2697
2698 memset(&sig_wr, 0, sizeof(sig_wr));
2699 sig_wr.opcode = IB_WR_REG_SIG_MR;
2700 sig_wr.wr_id = ISER_FASTREG_LI_WRID;
2701 sig_wr.sg_list = data_sge;
2702 sig_wr.num_sge = 1;
2703 sig_wr.wr.sig_handover.access_flags = IB_ACCESS_LOCAL_WRITE;
2704 sig_wr.wr.sig_handover.sig_attrs = &sig_attrs;
2705 sig_wr.wr.sig_handover.sig_mr = pi_ctx->sig_mr;
2706 if (se_cmd->t_prot_sg)
2707 sig_wr.wr.sig_handover.prot = prot_sge;
2708
2709 if (!wr)
2710 wr = &sig_wr;
2711 else
2712 wr->next = &sig_wr;
2713
2714 ret = ib_post_send(isert_conn->conn_qp, wr, &bad_wr);
2715 if (ret) {
2716 pr_err("fast registration failed, ret:%d\n", ret);
2717 goto err;
2718 }
2719 fr_desc->ind &= ~ISERT_SIG_KEY_VALID;
2720
2721 sig_sge->lkey = pi_ctx->sig_mr->lkey;
2722 sig_sge->addr = 0;
2723 sig_sge->length = se_cmd->data_length;
2724 if (se_cmd->prot_op != TARGET_PROT_DIN_STRIP &&
2725 se_cmd->prot_op != TARGET_PROT_DOUT_INSERT)
2726 /*
2727 * We have protection guards on the wire
2728 * so we need to set a larget transfer
2729 */
2730 sig_sge->length += se_cmd->prot_length;
2298 2731
2732 pr_debug("sig_sge: addr: 0x%llx length: %u lkey: %x\n",
2733 sig_sge->addr, sig_sge->length,
2734 sig_sge->lkey);
2735err:
2299 return ret; 2736 return ret;
2300} 2737}
2301 2738
@@ -2305,62 +2742,82 @@ isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2305{ 2742{
2306 struct se_cmd *se_cmd = &cmd->se_cmd; 2743 struct se_cmd *se_cmd = &cmd->se_cmd;
2307 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); 2744 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
2308 struct isert_conn *isert_conn = (struct isert_conn *)conn->context; 2745 struct isert_conn *isert_conn = conn->context;
2309 struct ib_device *ib_dev = isert_conn->conn_cm_id->device; 2746 struct ib_sge data_sge;
2310 struct ib_send_wr *send_wr; 2747 struct ib_send_wr *send_wr;
2311 struct ib_sge *ib_sge; 2748 struct fast_reg_descriptor *fr_desc = NULL;
2312 struct scatterlist *sg_start; 2749 u32 offset;
2313 struct fast_reg_descriptor *fr_desc; 2750 int ret = 0;
2314 u32 sg_off = 0, sg_nents;
2315 u32 offset = 0, data_len, data_left, rdma_write_max;
2316 int ret = 0, count;
2317 unsigned long flags; 2751 unsigned long flags;
2318 2752
2319 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { 2753 isert_cmd->tx_desc.isert_cmd = isert_cmd;
2320 data_left = se_cmd->data_length;
2321 } else {
2322 offset = cmd->write_data_done;
2323 sg_off = offset / PAGE_SIZE;
2324 data_left = se_cmd->data_length - cmd->write_data_done;
2325 isert_cmd->tx_desc.isert_cmd = isert_cmd;
2326 }
2327 2754
2328 sg_start = &cmd->se_cmd.t_data_sg[sg_off]; 2755 offset = wr->iser_ib_op == ISER_IB_RDMA_READ ? cmd->write_data_done : 0;
2329 sg_nents = se_cmd->t_data_nents - sg_off; 2756 ret = isert_map_data_buf(isert_conn, isert_cmd, se_cmd->t_data_sg,
2757 se_cmd->t_data_nents, se_cmd->data_length,
2758 offset, wr->iser_ib_op, &wr->data);
2759 if (ret)
2760 return ret;
2330 2761
2331 count = ib_dma_map_sg(ib_dev, sg_start, sg_nents, 2762 if (wr->data.dma_nents != 1 ||
2332 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ? 2763 se_cmd->prot_op != TARGET_PROT_NORMAL) {
2333 DMA_TO_DEVICE : DMA_FROM_DEVICE); 2764 spin_lock_irqsave(&isert_conn->conn_lock, flags);
2334 if (unlikely(!count)) { 2765 fr_desc = list_first_entry(&isert_conn->conn_fr_pool,
2335 pr_err("Cmd: %p unrable to map SGs\n", isert_cmd); 2766 struct fast_reg_descriptor, list);
2336 return -EINVAL; 2767 list_del(&fr_desc->list);
2768 spin_unlock_irqrestore(&isert_conn->conn_lock, flags);
2769 wr->fr_desc = fr_desc;
2337 } 2770 }
2338 wr->sge = sg_start;
2339 wr->num_sge = sg_nents;
2340 pr_debug("Mapped cmd: %p count: %u sg: %p sg_nents: %u rdma_len %d\n",
2341 isert_cmd, count, sg_start, sg_nents, data_left);
2342 2771
2343 memset(&wr->s_ib_sge, 0, sizeof(*ib_sge)); 2772 ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->data,
2344 ib_sge = &wr->s_ib_sge; 2773 ISERT_DATA_KEY_VALID, &data_sge);
2345 wr->ib_sge = ib_sge; 2774 if (ret)
2775 goto unmap_cmd;
2776
2777 if (se_cmd->prot_op != TARGET_PROT_NORMAL) {
2778 struct ib_sge prot_sge, sig_sge;
2779
2780 if (se_cmd->t_prot_sg) {
2781 ret = isert_map_data_buf(isert_conn, isert_cmd,
2782 se_cmd->t_prot_sg,
2783 se_cmd->t_prot_nents,
2784 se_cmd->prot_length,
2785 0, wr->iser_ib_op, &wr->prot);
2786 if (ret)
2787 goto unmap_cmd;
2788
2789 ret = isert_fast_reg_mr(isert_conn, fr_desc, &wr->prot,
2790 ISERT_PROT_KEY_VALID, &prot_sge);
2791 if (ret)
2792 goto unmap_prot_cmd;
2793 }
2794
2795 ret = isert_reg_sig_mr(isert_conn, se_cmd, fr_desc,
2796 &data_sge, &prot_sge, &sig_sge);
2797 if (ret)
2798 goto unmap_prot_cmd;
2346 2799
2800 fr_desc->ind |= ISERT_PROTECTED;
2801 memcpy(&wr->s_ib_sge, &sig_sge, sizeof(sig_sge));
2802 } else
2803 memcpy(&wr->s_ib_sge, &data_sge, sizeof(data_sge));
2804
2805 wr->ib_sge = &wr->s_ib_sge;
2347 wr->send_wr_num = 1; 2806 wr->send_wr_num = 1;
2348 memset(&wr->s_send_wr, 0, sizeof(*send_wr)); 2807 memset(&wr->s_send_wr, 0, sizeof(*send_wr));
2349 wr->send_wr = &wr->s_send_wr; 2808 wr->send_wr = &wr->s_send_wr;
2350
2351 wr->isert_cmd = isert_cmd; 2809 wr->isert_cmd = isert_cmd;
2352 rdma_write_max = ISCSI_ISER_SG_TABLESIZE * PAGE_SIZE;
2353 2810
2354 send_wr = &isert_cmd->rdma_wr.s_send_wr; 2811 send_wr = &isert_cmd->rdma_wr.s_send_wr;
2355 send_wr->sg_list = ib_sge; 2812 send_wr->sg_list = &wr->s_ib_sge;
2356 send_wr->num_sge = 1; 2813 send_wr->num_sge = 1;
2357 send_wr->wr_id = (unsigned long)&isert_cmd->tx_desc; 2814 send_wr->wr_id = (unsigned long)&isert_cmd->tx_desc;
2358 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { 2815 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) {
2359 send_wr->opcode = IB_WR_RDMA_WRITE; 2816 send_wr->opcode = IB_WR_RDMA_WRITE;
2360 send_wr->wr.rdma.remote_addr = isert_cmd->read_va; 2817 send_wr->wr.rdma.remote_addr = isert_cmd->read_va;
2361 send_wr->wr.rdma.rkey = isert_cmd->read_stag; 2818 send_wr->wr.rdma.rkey = isert_cmd->read_stag;
2362 send_wr->send_flags = 0; 2819 send_wr->send_flags = se_cmd->prot_op == TARGET_PROT_NORMAL ?
2363 send_wr->next = &isert_cmd->tx_desc.send_wr; 2820 0 : IB_SEND_SIGNALED;
2364 } else { 2821 } else {
2365 send_wr->opcode = IB_WR_RDMA_READ; 2822 send_wr->opcode = IB_WR_RDMA_READ;
2366 send_wr->wr.rdma.remote_addr = isert_cmd->write_va; 2823 send_wr->wr.rdma.remote_addr = isert_cmd->write_va;
@@ -2368,37 +2825,18 @@ isert_reg_rdma(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2368 send_wr->send_flags = IB_SEND_SIGNALED; 2825 send_wr->send_flags = IB_SEND_SIGNALED;
2369 } 2826 }
2370 2827
2371 data_len = min(data_left, rdma_write_max); 2828 return 0;
2372 wr->cur_rdma_length = data_len; 2829unmap_prot_cmd:
2373 2830 if (se_cmd->t_prot_sg)
2374 /* if there is a single dma entry, dma mr is sufficient */ 2831 isert_unmap_data_buf(isert_conn, &wr->prot);
2375 if (count == 1) { 2832unmap_cmd:
2376 ib_sge->addr = ib_sg_dma_address(ib_dev, &sg_start[0]); 2833 if (fr_desc) {
2377 ib_sge->length = ib_sg_dma_len(ib_dev, &sg_start[0]);
2378 ib_sge->lkey = isert_conn->conn_mr->lkey;
2379 wr->fr_desc = NULL;
2380 } else {
2381 spin_lock_irqsave(&isert_conn->conn_lock, flags); 2834 spin_lock_irqsave(&isert_conn->conn_lock, flags);
2382 fr_desc = list_first_entry(&isert_conn->conn_fr_pool, 2835 list_add_tail(&fr_desc->list, &isert_conn->conn_fr_pool);
2383 struct fast_reg_descriptor, list);
2384 list_del(&fr_desc->list);
2385 spin_unlock_irqrestore(&isert_conn->conn_lock, flags); 2836 spin_unlock_irqrestore(&isert_conn->conn_lock, flags);
2386 wr->fr_desc = fr_desc;
2387
2388 ret = isert_fast_reg_mr(fr_desc, isert_conn, sg_start,
2389 ib_sge, sg_nents, offset, data_len);
2390 if (ret) {
2391 list_add_tail(&fr_desc->list, &isert_conn->conn_fr_pool);
2392 goto unmap_sg;
2393 }
2394 } 2837 }
2838 isert_unmap_data_buf(isert_conn, &wr->data);
2395 2839
2396 return 0;
2397
2398unmap_sg:
2399 ib_dma_unmap_sg(ib_dev, sg_start, sg_nents,
2400 (wr->iser_ib_op == ISER_IB_RDMA_WRITE) ?
2401 DMA_TO_DEVICE : DMA_FROM_DEVICE);
2402 return ret; 2840 return ret;
2403} 2841}
2404 2842
@@ -2422,25 +2860,35 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
2422 return rc; 2860 return rc;
2423 } 2861 }
2424 2862
2425 /* 2863 if (se_cmd->prot_op == TARGET_PROT_NORMAL) {
2426 * Build isert_conn->tx_desc for iSCSI response PDU and attach 2864 /*
2427 */ 2865 * Build isert_conn->tx_desc for iSCSI response PDU and attach
2428 isert_create_send_desc(isert_conn, isert_cmd, &isert_cmd->tx_desc); 2866 */
2429 iscsit_build_rsp_pdu(cmd, conn, true, (struct iscsi_scsi_rsp *) 2867 isert_create_send_desc(isert_conn, isert_cmd,
2430 &isert_cmd->tx_desc.iscsi_header); 2868 &isert_cmd->tx_desc);
2431 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); 2869 iscsit_build_rsp_pdu(cmd, conn, true, (struct iscsi_scsi_rsp *)
2432 isert_init_send_wr(isert_conn, isert_cmd, 2870 &isert_cmd->tx_desc.iscsi_header);
2433 &isert_cmd->tx_desc.send_wr, true); 2871 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc);
2872 isert_init_send_wr(isert_conn, isert_cmd,
2873 &isert_cmd->tx_desc.send_wr, true);
2874 isert_cmd->rdma_wr.s_send_wr.next = &isert_cmd->tx_desc.send_wr;
2875 wr->send_wr_num += 1;
2876 }
2434 2877
2435 atomic_add(wr->send_wr_num + 1, &isert_conn->post_send_buf_count); 2878 atomic_add(wr->send_wr_num, &isert_conn->post_send_buf_count);
2436 2879
2437 rc = ib_post_send(isert_conn->conn_qp, wr->send_wr, &wr_failed); 2880 rc = ib_post_send(isert_conn->conn_qp, wr->send_wr, &wr_failed);
2438 if (rc) { 2881 if (rc) {
2439 pr_warn("ib_post_send() failed for IB_WR_RDMA_WRITE\n"); 2882 pr_warn("ib_post_send() failed for IB_WR_RDMA_WRITE\n");
2440 atomic_sub(wr->send_wr_num + 1, &isert_conn->post_send_buf_count); 2883 atomic_sub(wr->send_wr_num, &isert_conn->post_send_buf_count);
2441 } 2884 }
2442 pr_debug("Cmd: %p posted RDMA_WRITE + Response for iSER Data READ\n", 2885
2443 isert_cmd); 2886 if (se_cmd->prot_op == TARGET_PROT_NORMAL)
2887 pr_debug("Cmd: %p posted RDMA_WRITE + Response for iSER Data "
2888 "READ\n", isert_cmd);
2889 else
2890 pr_debug("Cmd: %p posted RDMA_WRITE for iSER Data READ\n",
2891 isert_cmd);
2444 2892
2445 return 1; 2893 return 1;
2446} 2894}
@@ -2815,6 +3263,8 @@ static struct iscsit_transport iser_target_transport = {
2815 .iscsit_get_dataout = isert_get_dataout, 3263 .iscsit_get_dataout = isert_get_dataout,
2816 .iscsit_queue_data_in = isert_put_datain, 3264 .iscsit_queue_data_in = isert_put_datain,
2817 .iscsit_queue_status = isert_put_response, 3265 .iscsit_queue_status = isert_put_response,
3266 .iscsit_aborted_task = isert_aborted_task,
3267 .iscsit_get_sup_prot_ops = isert_get_sup_prot_ops,
2818}; 3268};
2819 3269
2820static int __init isert_init(void) 3270static int __init isert_init(void)
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index f6ae7f5dd408..4c072ae34c01 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -50,11 +50,35 @@ struct iser_tx_desc {
50 struct ib_send_wr send_wr; 50 struct ib_send_wr send_wr;
51} __packed; 51} __packed;
52 52
53enum isert_indicator {
54 ISERT_PROTECTED = 1 << 0,
55 ISERT_DATA_KEY_VALID = 1 << 1,
56 ISERT_PROT_KEY_VALID = 1 << 2,
57 ISERT_SIG_KEY_VALID = 1 << 3,
58};
59
60struct pi_context {
61 struct ib_mr *prot_mr;
62 struct ib_fast_reg_page_list *prot_frpl;
63 struct ib_mr *sig_mr;
64};
65
53struct fast_reg_descriptor { 66struct fast_reg_descriptor {
54 struct list_head list; 67 struct list_head list;
55 struct ib_mr *data_mr; 68 struct ib_mr *data_mr;
56 struct ib_fast_reg_page_list *data_frpl; 69 struct ib_fast_reg_page_list *data_frpl;
57 bool valid; 70 u8 ind;
71 struct pi_context *pi_ctx;
72};
73
74struct isert_data_buf {
75 struct scatterlist *sg;
76 int nents;
77 u32 sg_off;
78 u32 len; /* cur_rdma_length */
79 u32 offset;
80 unsigned int dma_nents;
81 enum dma_data_direction dma_dir;
58}; 82};
59 83
60struct isert_rdma_wr { 84struct isert_rdma_wr {
@@ -63,12 +87,11 @@ struct isert_rdma_wr {
63 enum iser_ib_op_code iser_ib_op; 87 enum iser_ib_op_code iser_ib_op;
64 struct ib_sge *ib_sge; 88 struct ib_sge *ib_sge;
65 struct ib_sge s_ib_sge; 89 struct ib_sge s_ib_sge;
66 int num_sge;
67 struct scatterlist *sge;
68 int send_wr_num; 90 int send_wr_num;
69 struct ib_send_wr *send_wr; 91 struct ib_send_wr *send_wr;
70 struct ib_send_wr s_send_wr; 92 struct ib_send_wr s_send_wr;
71 u32 cur_rdma_length; 93 struct isert_data_buf data;
94 struct isert_data_buf prot;
72 struct fast_reg_descriptor *fr_desc; 95 struct fast_reg_descriptor *fr_desc;
73}; 96};
74 97
@@ -141,6 +164,7 @@ struct isert_cq_desc {
141 164
142struct isert_device { 165struct isert_device {
143 int use_fastreg; 166 int use_fastreg;
167 bool pi_capable;
144 int cqs_used; 168 int cqs_used;
145 int refcount; 169 int refcount;
146 int cq_active_qps[ISERT_MAX_CQ]; 170 int cq_active_qps[ISERT_MAX_CQ];
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 0e537d8d0e47..fe09f2788b15 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1078,6 +1078,7 @@ static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1078static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, 1078static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1079 struct srpt_send_ioctx *ioctx) 1079 struct srpt_send_ioctx *ioctx)
1080{ 1080{
1081 struct ib_device *dev = ch->sport->sdev->device;
1081 struct se_cmd *cmd; 1082 struct se_cmd *cmd;
1082 struct scatterlist *sg, *sg_orig; 1083 struct scatterlist *sg, *sg_orig;
1083 int sg_cnt; 1084 int sg_cnt;
@@ -1124,7 +1125,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1124 1125
1125 db = ioctx->rbufs; 1126 db = ioctx->rbufs;
1126 tsize = cmd->data_length; 1127 tsize = cmd->data_length;
1127 dma_len = sg_dma_len(&sg[0]); 1128 dma_len = ib_sg_dma_len(dev, &sg[0]);
1128 riu = ioctx->rdma_ius; 1129 riu = ioctx->rdma_ius;
1129 1130
1130 /* 1131 /*
@@ -1155,7 +1156,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1155 ++j; 1156 ++j;
1156 if (j < count) { 1157 if (j < count) {
1157 sg = sg_next(sg); 1158 sg = sg_next(sg);
1158 dma_len = sg_dma_len(sg); 1159 dma_len = ib_sg_dma_len(
1160 dev, sg);
1159 } 1161 }
1160 } 1162 }
1161 } else { 1163 } else {
@@ -1192,8 +1194,8 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1192 tsize = cmd->data_length; 1194 tsize = cmd->data_length;
1193 riu = ioctx->rdma_ius; 1195 riu = ioctx->rdma_ius;
1194 sg = sg_orig; 1196 sg = sg_orig;
1195 dma_len = sg_dma_len(&sg[0]); 1197 dma_len = ib_sg_dma_len(dev, &sg[0]);
1196 dma_addr = sg_dma_address(&sg[0]); 1198 dma_addr = ib_sg_dma_address(dev, &sg[0]);
1197 1199
1198 /* this second loop is really mapped sg_addres to rdma_iu->ib_sge */ 1200 /* this second loop is really mapped sg_addres to rdma_iu->ib_sge */
1199 for (i = 0, j = 0; 1201 for (i = 0, j = 0;
@@ -1216,8 +1218,10 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
1216 ++j; 1218 ++j;
1217 if (j < count) { 1219 if (j < count) {
1218 sg = sg_next(sg); 1220 sg = sg_next(sg);
1219 dma_len = sg_dma_len(sg); 1221 dma_len = ib_sg_dma_len(
1220 dma_addr = sg_dma_address(sg); 1222 dev, sg);
1223 dma_addr = ib_sg_dma_address(
1224 dev, sg);
1221 } 1225 }
1222 } 1226 }
1223 } else { 1227 } else {
@@ -2580,7 +2584,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
2580 goto destroy_ib; 2584 goto destroy_ib;
2581 } 2585 }
2582 2586
2583 ch->sess = transport_init_session(); 2587 ch->sess = transport_init_session(TARGET_PROT_NORMAL);
2584 if (IS_ERR(ch->sess)) { 2588 if (IS_ERR(ch->sess)) {
2585 rej->reason = __constant_cpu_to_be32( 2589 rej->reason = __constant_cpu_to_be32(
2586 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); 2590 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
@@ -3081,6 +3085,14 @@ static void srpt_queue_tm_rsp(struct se_cmd *cmd)
3081 srpt_queue_response(cmd); 3085 srpt_queue_response(cmd);
3082} 3086}
3083 3087
3088static void srpt_aborted_task(struct se_cmd *cmd)
3089{
3090 struct srpt_send_ioctx *ioctx = container_of(cmd,
3091 struct srpt_send_ioctx, cmd);
3092
3093 srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx);
3094}
3095
3084static int srpt_queue_status(struct se_cmd *cmd) 3096static int srpt_queue_status(struct se_cmd *cmd)
3085{ 3097{
3086 struct srpt_send_ioctx *ioctx; 3098 struct srpt_send_ioctx *ioctx;
@@ -3928,6 +3940,7 @@ static struct target_core_fabric_ops srpt_template = {
3928 .queue_data_in = srpt_queue_data_in, 3940 .queue_data_in = srpt_queue_data_in,
3929 .queue_status = srpt_queue_status, 3941 .queue_status = srpt_queue_status,
3930 .queue_tm_rsp = srpt_queue_tm_rsp, 3942 .queue_tm_rsp = srpt_queue_tm_rsp,
3943 .aborted_task = srpt_aborted_task,
3931 /* 3944 /*
3932 * Setup function pointers for generic logic in 3945 * Setup function pointers for generic logic in
3933 * target_core_fabric_configfs.c 3946 * target_core_fabric_configfs.c
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 44c358ecf5a1..6de9dfbf61c1 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -416,7 +416,7 @@ config LEDS_MC13783
416 depends on MFD_MC13XXX 416 depends on MFD_MC13XXX
417 help 417 help
418 This option enable support for on-chip LED drivers found 418 This option enable support for on-chip LED drivers found
419 on Freescale Semiconductor MC13783/MC13892 PMIC. 419 on Freescale Semiconductor MC13783/MC13892/MC34708 PMIC.
420 420
421config LEDS_NS2 421config LEDS_NS2
422 tristate "LED support for Network Space v2 GPIO LEDs" 422 tristate "LED support for Network Space v2 GPIO LEDs"
@@ -474,7 +474,7 @@ config LEDS_LM355x
474 474
475config LEDS_OT200 475config LEDS_OT200
476 tristate "LED support for the Bachmann OT200" 476 tristate "LED support for the Bachmann OT200"
477 depends on LEDS_CLASS && HAS_IOMEM 477 depends on LEDS_CLASS && HAS_IOMEM && (X86_32 || COMPILE_TEST)
478 help 478 help
479 This option enables support for the LEDs on the Bachmann OT200. 479 This option enables support for the LEDs on the Bachmann OT200.
480 Say Y to enable LEDs on the Bachmann OT200. 480 Say Y to enable LEDs on the Bachmann OT200.
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index ce8921a753a3..71b40d3bf776 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -39,9 +39,11 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
39 led_cdev->blink_delay_on = delay_on; 39 led_cdev->blink_delay_on = delay_on;
40 led_cdev->blink_delay_off = delay_off; 40 led_cdev->blink_delay_off = delay_off;
41 41
42 /* never on - don't blink */ 42 /* never on - just set to off */
43 if (!delay_on) 43 if (!delay_on) {
44 __led_set_brightness(led_cdev, LED_OFF);
44 return; 45 return;
46 }
45 47
46 /* never off - just set to brightness */ 48 /* never off - just set to brightness */
47 if (!delay_off) { 49 if (!delay_off) {
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index e387f41a9cb7..c3734f10fdd5 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/list.h> 16#include <linux/list.h>
18#include <linux/spinlock.h> 17#include <linux/spinlock.h>
19#include <linux/device.h> 18#include <linux/device.h>
@@ -220,9 +219,12 @@ void led_trigger_unregister(struct led_trigger *trig)
220{ 219{
221 struct led_classdev *led_cdev; 220 struct led_classdev *led_cdev;
222 221
222 if (list_empty_careful(&trig->next_trig))
223 return;
224
223 /* Remove from the list of led triggers */ 225 /* Remove from the list of led triggers */
224 down_write(&triggers_list_lock); 226 down_write(&triggers_list_lock);
225 list_del(&trig->next_trig); 227 list_del_init(&trig->next_trig);
226 up_write(&triggers_list_lock); 228 up_write(&triggers_list_lock);
227 229
228 /* Remove anyone actively using this trigger */ 230 /* Remove anyone actively using this trigger */
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index 5f588c0a376e..d1e1bca90d11 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -11,7 +11,6 @@
11 */ 11 */
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/of.h> 14#include <linux/of.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
17#include <linux/i2c.h> 16#include <linux/i2c.h>
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c
index 7e311a120b11..86b5bdb0c773 100644
--- a/drivers/leds/leds-adp5520.c
+++ b/drivers/leds/leds-adp5520.c
@@ -15,7 +15,6 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h> 18#include <linux/platform_device.h>
20#include <linux/leds.h> 19#include <linux/leds.h>
21#include <linux/workqueue.h> 20#include <linux/workqueue.h>
diff --git a/drivers/leds/leds-asic3.c b/drivers/leds/leds-asic3.c
index 6de216a89a0c..70c74a7f0dfe 100644
--- a/drivers/leds/leds-asic3.c
+++ b/drivers/leds/leds-asic3.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/init.h>
11#include <linux/platform_device.h> 10#include <linux/platform_device.h>
12#include <linux/leds.h> 11#include <linux/leds.h>
13#include <linux/slab.h> 12#include <linux/slab.h>
diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c
index 66d0a57db221..d0452b099aee 100644
--- a/drivers/leds/leds-blinkm.c
+++ b/drivers/leds/leds-blinkm.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23#include <linux/jiffies.h> 22#include <linux/jiffies.h>
24#include <linux/i2c.h> 23#include <linux/i2c.h>
@@ -444,7 +443,7 @@ static void led_work(struct work_struct *work)
444{ 443{
445 int ret; 444 int ret;
446 struct blinkm_led *led; 445 struct blinkm_led *led;
447 struct blinkm_data *data ; 446 struct blinkm_data *data;
448 struct blinkm_work *blm_work = work_to_blmwork(work); 447 struct blinkm_work *blm_work = work_to_blmwork(work);
449 448
450 led = blm_work->blinkm_led; 449 led = blm_work->blinkm_led;
diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index d93e2455da5c..f58a354428e3 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -19,7 +19,7 @@ MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
19MODULE_DESCRIPTION("Clevo mail LED driver"); 19MODULE_DESCRIPTION("Clevo mail LED driver");
20MODULE_LICENSE("GPL"); 20MODULE_LICENSE("GPL");
21 21
22static bool __initdata nodetect; 22static bool nodetect;
23module_param_named(nodetect, nodetect, bool, 0); 23module_param_named(nodetect, nodetect, bool, 0);
24MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection"); 24MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
25 25
@@ -153,7 +153,7 @@ static struct led_classdev clevo_mail_led = {
153 .flags = LED_CORE_SUSPENDRESUME, 153 .flags = LED_CORE_SUSPENDRESUME,
154}; 154};
155 155
156static int clevo_mail_led_probe(struct platform_device *pdev) 156static int __init clevo_mail_led_probe(struct platform_device *pdev)
157{ 157{
158 return led_classdev_register(&pdev->dev, &clevo_mail_led); 158 return led_classdev_register(&pdev->dev, &clevo_mail_led);
159} 159}
@@ -165,7 +165,6 @@ static int clevo_mail_led_remove(struct platform_device *pdev)
165} 165}
166 166
167static struct platform_driver clevo_mail_led_driver = { 167static struct platform_driver clevo_mail_led_driver = {
168 .probe = clevo_mail_led_probe,
169 .remove = clevo_mail_led_remove, 168 .remove = clevo_mail_led_remove,
170 .driver = { 169 .driver = {
171 .name = KBUILD_MODNAME, 170 .name = KBUILD_MODNAME,
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c
index 8abcb66db01c..910339d86edf 100644
--- a/drivers/leds/leds-cobalt-qube.c
+++ b/drivers/leds/leds-cobalt-qube.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * Control the Cobalt Qube/RaQ front LED 4 * Control the Cobalt Qube/RaQ front LED
5 */ 5 */
6#include <linux/init.h>
7#include <linux/io.h> 6#include <linux/io.h>
8#include <linux/ioport.h> 7#include <linux/ioport.h>
9#include <linux/leds.h> 8#include <linux/leds.h>
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c
index 2a4b87f8091a..35dffb100388 100644
--- a/drivers/leds/leds-da903x.c
+++ b/drivers/leds/leds-da903x.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/leds.h> 18#include <linux/leds.h>
20#include <linux/workqueue.h> 19#include <linux/workqueue.h>
diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c
index 865d4faf874a..01486adc7f8b 100644
--- a/drivers/leds/leds-da9052.c
+++ b/drivers/leds/leds-da9052.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/leds.h> 18#include <linux/leds.h>
20#include <linux/workqueue.h> 19#include <linux/workqueue.h>
diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c
index b4d5a44cc41b..2b4dc738dcd6 100644
--- a/drivers/leds/leds-fsg.c
+++ b/drivers/leds/leds-fsg.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
21#include <linux/leds.h> 20#include <linux/leds.h>
22#include <linux/module.h> 21#include <linux/module.h>
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 78b0e273a903..57ff20fecf57 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -11,7 +11,6 @@
11 * 11 *
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
16#include <linux/gpio.h> 15#include <linux/gpio.h>
17#include <linux/leds.h> 16#include <linux/leds.h>
@@ -204,6 +203,9 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
204 led.default_state = LEDS_GPIO_DEFSTATE_OFF; 203 led.default_state = LEDS_GPIO_DEFSTATE_OFF;
205 } 204 }
206 205
206 if (of_get_property(child, "retain-state-suspended", NULL))
207 led.retain_state_suspended = 1;
208
207 ret = create_gpio_led(&led, &priv->leds[priv->num_leds++], 209 ret = create_gpio_led(&led, &priv->leds[priv->num_leds++],
208 &pdev->dev, NULL); 210 &pdev->dev, NULL);
209 if (ret < 0) { 211 if (ret < 0) {
@@ -224,6 +226,8 @@ static const struct of_device_id of_gpio_leds_match[] = {
224 { .compatible = "gpio-leds", }, 226 { .compatible = "gpio-leds", },
225 {}, 227 {},
226}; 228};
229
230MODULE_DEVICE_TABLE(of, of_gpio_leds_match);
227#else /* CONFIG_OF_GPIO */ 231#else /* CONFIG_OF_GPIO */
228static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) 232static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
229{ 233{
diff --git a/drivers/leds/leds-hp6xx.c b/drivers/leds/leds-hp6xx.c
index 366b6055e330..d61a98896c71 100644
--- a/drivers/leds/leds-hp6xx.c
+++ b/drivers/leds/leds-hp6xx.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
17#include <linux/leds.h> 16#include <linux/leds.h>
18#include <asm/hd64461.h> 17#include <asm/hd64461.h>
diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index 027ede73b80d..e2c642c1169b 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/leds.h> 15#include <linux/leds.h>
17#include <linux/mfd/core.h> 16#include <linux/mfd/core.h>
18#include <linux/mutex.h> 17#include <linux/mutex.h>
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 2ec34cfcedce..8ca197af2864 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -25,7 +25,6 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/init.h>
29#include <linux/leds.h> 28#include <linux/leds.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/mutex.h> 30#include <linux/mutex.h>
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 4ade66a2d9d4..cb5ed82994ba 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -25,7 +25,6 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/firmware.h> 26#include <linux/firmware.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/init.h>
29#include <linux/leds.h> 28#include <linux/leds.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/mutex.h> 30#include <linux/mutex.h>
diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c
index bf006f4e44a0..ca85724ab138 100644
--- a/drivers/leds/leds-lp5562.c
+++ b/drivers/leds/leds-lp5562.c
@@ -13,7 +13,6 @@
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/firmware.h> 14#include <linux/firmware.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/init.h>
17#include <linux/leds.h> 16#include <linux/leds.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/mutex.h> 18#include <linux/mutex.h>
@@ -347,9 +346,9 @@ static void lp5562_write_program_memory(struct lp55xx_chip *chip,
347/* check the size of program count */ 346/* check the size of program count */
348static inline bool _is_pc_overflow(struct lp55xx_predef_pattern *ptn) 347static inline bool _is_pc_overflow(struct lp55xx_predef_pattern *ptn)
349{ 348{
350 return (ptn->size_r >= LP5562_PROGRAM_LENGTH || 349 return ptn->size_r >= LP5562_PROGRAM_LENGTH ||
351 ptn->size_g >= LP5562_PROGRAM_LENGTH || 350 ptn->size_g >= LP5562_PROGRAM_LENGTH ||
352 ptn->size_b >= LP5562_PROGRAM_LENGTH); 351 ptn->size_b >= LP5562_PROGRAM_LENGTH;
353} 352}
354 353
355static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode) 354static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode)
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
index 3417e5be7b57..059f5b1f3553 100644
--- a/drivers/leds/leds-lt3593.c
+++ b/drivers/leds/leds-lt3593.c
@@ -17,7 +17,6 @@
17 */ 17 */
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22#include <linux/leds.h> 21#include <linux/leds.h>
23#include <linux/workqueue.h> 22#include <linux/workqueue.h>
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c
index ca87a1b4a0db..f1db88e25138 100644
--- a/drivers/leds/leds-mc13783.c
+++ b/drivers/leds/leds-mc13783.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * LEDs driver for Freescale MC13783/MC13892 2 * LEDs driver for Freescale MC13783/MC13892/MC34708
3 * 3 *
4 * Copyright (C) 2010 Philippe Rétornaz 4 * Copyright (C) 2010 Philippe Rétornaz
5 * 5 *
@@ -17,57 +17,56 @@
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22#include <linux/leds.h> 21#include <linux/leds.h>
22#include <linux/of.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/mfd/mc13xxx.h> 24#include <linux/mfd/mc13xxx.h>
25 25
26#define MC13XXX_REG_LED_CONTROL(x) (51 + (x))
27
28struct mc13xxx_led_devtype { 26struct mc13xxx_led_devtype {
29 int led_min; 27 int led_min;
30 int led_max; 28 int led_max;
31 int num_regs; 29 int num_regs;
30 u32 ledctrl_base;
32}; 31};
33 32
34struct mc13xxx_led { 33struct mc13xxx_led {
35 struct led_classdev cdev; 34 struct led_classdev cdev;
36 struct work_struct work; 35 struct work_struct work;
37 struct mc13xxx *master;
38 enum led_brightness new_brightness; 36 enum led_brightness new_brightness;
39 int id; 37 int id;
38 struct mc13xxx_leds *leds;
40}; 39};
41 40
42struct mc13xxx_leds { 41struct mc13xxx_leds {
42 struct mc13xxx *master;
43 struct mc13xxx_led_devtype *devtype; 43 struct mc13xxx_led_devtype *devtype;
44 int num_leds; 44 int num_leds;
45 struct mc13xxx_led led[0]; 45 struct mc13xxx_led *led;
46}; 46};
47 47
48static unsigned int mc13xxx_max_brightness(int id)
49{
50 if (id >= MC13783_LED_MD && id <= MC13783_LED_KP)
51 return 0x0f;
52 else if (id >= MC13783_LED_R1 && id <= MC13783_LED_B3)
53 return 0x1f;
54
55 return 0x3f;
56}
57
48static void mc13xxx_led_work(struct work_struct *work) 58static void mc13xxx_led_work(struct work_struct *work)
49{ 59{
50 struct mc13xxx_led *led = container_of(work, struct mc13xxx_led, work); 60 struct mc13xxx_led *led = container_of(work, struct mc13xxx_led, work);
51 int reg, mask, value, bank, off, shift; 61 struct mc13xxx_leds *leds = led->leds;
62 unsigned int reg, bank, off, shift;
52 63
53 switch (led->id) { 64 switch (led->id) {
54 case MC13783_LED_MD: 65 case MC13783_LED_MD:
55 reg = MC13XXX_REG_LED_CONTROL(2);
56 shift = 9;
57 mask = 0x0f;
58 value = led->new_brightness >> 4;
59 break;
60 case MC13783_LED_AD: 66 case MC13783_LED_AD:
61 reg = MC13XXX_REG_LED_CONTROL(2);
62 shift = 13;
63 mask = 0x0f;
64 value = led->new_brightness >> 4;
65 break;
66 case MC13783_LED_KP: 67 case MC13783_LED_KP:
67 reg = MC13XXX_REG_LED_CONTROL(2); 68 reg = 2;
68 shift = 17; 69 shift = 9 + (led->id - MC13783_LED_MD) * 4;
69 mask = 0x0f;
70 value = led->new_brightness >> 4;
71 break; 70 break;
72 case MC13783_LED_R1: 71 case MC13783_LED_R1:
73 case MC13783_LED_G1: 72 case MC13783_LED_G1:
@@ -80,44 +79,35 @@ static void mc13xxx_led_work(struct work_struct *work)
80 case MC13783_LED_B3: 79 case MC13783_LED_B3:
81 off = led->id - MC13783_LED_R1; 80 off = led->id - MC13783_LED_R1;
82 bank = off / 3; 81 bank = off / 3;
83 reg = MC13XXX_REG_LED_CONTROL(3) + bank; 82 reg = 3 + bank;
84 shift = (off - bank * 3) * 5 + 6; 83 shift = (off - bank * 3) * 5 + 6;
85 value = led->new_brightness >> 3;
86 mask = 0x1f;
87 break; 84 break;
88 case MC13892_LED_MD: 85 case MC13892_LED_MD:
89 reg = MC13XXX_REG_LED_CONTROL(0);
90 shift = 3;
91 mask = 0x3f;
92 value = led->new_brightness >> 2;
93 break;
94 case MC13892_LED_AD: 86 case MC13892_LED_AD:
95 reg = MC13XXX_REG_LED_CONTROL(0);
96 shift = 15;
97 mask = 0x3f;
98 value = led->new_brightness >> 2;
99 break;
100 case MC13892_LED_KP: 87 case MC13892_LED_KP:
101 reg = MC13XXX_REG_LED_CONTROL(1); 88 reg = (led->id - MC13892_LED_MD) / 2;
102 shift = 3; 89 shift = 3 + (led->id - MC13892_LED_MD) * 12;
103 mask = 0x3f;
104 value = led->new_brightness >> 2;
105 break; 90 break;
106 case MC13892_LED_R: 91 case MC13892_LED_R:
107 case MC13892_LED_G: 92 case MC13892_LED_G:
108 case MC13892_LED_B: 93 case MC13892_LED_B:
109 off = led->id - MC13892_LED_R; 94 off = led->id - MC13892_LED_R;
110 bank = off / 2; 95 bank = off / 2;
111 reg = MC13XXX_REG_LED_CONTROL(2) + bank; 96 reg = 2 + bank;
112 shift = (off - bank * 2) * 12 + 3; 97 shift = (off - bank * 2) * 12 + 3;
113 value = led->new_brightness >> 2; 98 break;
114 mask = 0x3f; 99 case MC34708_LED_R:
100 case MC34708_LED_G:
101 reg = 0;
102 shift = 3 + (led->id - MC34708_LED_R) * 12;
115 break; 103 break;
116 default: 104 default:
117 BUG(); 105 BUG();
118 } 106 }
119 107
120 mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift); 108 mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg,
109 mc13xxx_max_brightness(led->id) << shift,
110 led->new_brightness << shift);
121} 111}
122 112
123static void mc13xxx_led_set(struct led_classdev *led_cdev, 113static void mc13xxx_led_set(struct led_classdev *led_cdev,
@@ -130,47 +120,121 @@ static void mc13xxx_led_set(struct led_classdev *led_cdev,
130 schedule_work(&led->work); 120 schedule_work(&led->work);
131} 121}
132 122
133static int __init mc13xxx_led_probe(struct platform_device *pdev) 123#ifdef CONFIG_OF
124static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
125 struct platform_device *pdev)
134{ 126{
135 struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); 127 struct mc13xxx_leds *leds = platform_get_drvdata(pdev);
136 struct mc13xxx *mcdev = dev_get_drvdata(pdev->dev.parent); 128 struct mc13xxx_leds_platform_data *pdata;
137 struct mc13xxx_led_devtype *devtype = 129 struct device_node *parent, *child;
138 (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; 130 struct device *dev = &pdev->dev;
139 struct mc13xxx_leds *leds; 131 int i = 0, ret = -ENODATA;
140 int i, id, num_leds, ret = -ENODATA; 132
141 u32 reg, init_led = 0; 133 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
134 if (!pdata)
135 return ERR_PTR(-ENOMEM);
136
137 of_node_get(dev->parent->of_node);
138
139 parent = of_find_node_by_name(dev->parent->of_node, "leds");
140 if (!parent)
141 goto out_node_put;
142 142
143 if (!pdata) { 143 ret = of_property_read_u32_array(parent, "led-control",
144 dev_err(&pdev->dev, "Missing platform data\n"); 144 pdata->led_control,
145 return -ENODEV; 145 leds->devtype->num_regs);
146 if (ret)
147 goto out_node_put;
148
149 pdata->num_leds = of_get_child_count(parent);
150
151 pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led),
152 GFP_KERNEL);
153 if (!pdata->led) {
154 ret = -ENOMEM;
155 goto out_node_put;
146 } 156 }
147 157
148 num_leds = pdata->num_leds; 158 for_each_child_of_node(parent, child) {
159 const char *str;
160 u32 tmp;
149 161
150 if ((num_leds < 1) || 162 if (of_property_read_u32(child, "reg", &tmp))
151 (num_leds > (devtype->led_max - devtype->led_min + 1))) { 163 continue;
152 dev_err(&pdev->dev, "Invalid LED count %d\n", num_leds); 164 pdata->led[i].id = leds->devtype->led_min + tmp;
153 return -EINVAL; 165
166 if (!of_property_read_string(child, "label", &str))
167 pdata->led[i].name = str;
168 if (!of_property_read_string(child, "linux,default-trigger",
169 &str))
170 pdata->led[i].default_trigger = str;
171
172 i++;
154 } 173 }
155 174
156 leds = devm_kzalloc(&pdev->dev, num_leds * sizeof(struct mc13xxx_led) + 175 pdata->num_leds = i;
157 sizeof(struct mc13xxx_leds), GFP_KERNEL); 176 ret = i > 0 ? 0 : -ENODATA;
177
178out_node_put:
179 of_node_put(parent);
180
181 return ret ? ERR_PTR(ret) : pdata;
182}
183#else
184static inline struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
185 struct platform_device *pdev)
186{
187 return ERR_PTR(-ENOSYS);
188}
189#endif
190
191static int __init mc13xxx_led_probe(struct platform_device *pdev)
192{
193 struct device *dev = &pdev->dev;
194 struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(dev);
195 struct mc13xxx *mcdev = dev_get_drvdata(dev->parent);
196 struct mc13xxx_led_devtype *devtype =
197 (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data;
198 struct mc13xxx_leds *leds;
199 int i, id, ret = -ENODATA;
200 u32 init_led = 0;
201
202 leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL);
158 if (!leds) 203 if (!leds)
159 return -ENOMEM; 204 return -ENOMEM;
160 205
161 leds->devtype = devtype; 206 leds->devtype = devtype;
162 leds->num_leds = num_leds; 207 leds->master = mcdev;
163 platform_set_drvdata(pdev, leds); 208 platform_set_drvdata(pdev, leds);
164 209
210 if (dev->parent->of_node) {
211 pdata = mc13xxx_led_probe_dt(pdev);
212 if (IS_ERR(pdata))
213 return PTR_ERR(pdata);
214 } else if (!pdata)
215 return -ENODATA;
216
217 leds->num_leds = pdata->num_leds;
218
219 if ((leds->num_leds < 1) ||
220 (leds->num_leds > (devtype->led_max - devtype->led_min + 1))) {
221 dev_err(dev, "Invalid LED count %d\n", leds->num_leds);
222 return -EINVAL;
223 }
224
225 leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led),
226 GFP_KERNEL);
227 if (!leds->led)
228 return -ENOMEM;
229
165 for (i = 0; i < devtype->num_regs; i++) { 230 for (i = 0; i < devtype->num_regs; i++) {
166 reg = pdata->led_control[i]; 231 ret = mc13xxx_reg_write(mcdev, leds->devtype->ledctrl_base + i,
167 WARN_ON(reg >= (1 << 24)); 232 pdata->led_control[i]);
168 ret = mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), reg);
169 if (ret) 233 if (ret)
170 return ret; 234 return ret;
171 } 235 }
172 236
173 for (i = 0; i < num_leds; i++) { 237 for (i = 0; i < leds->num_leds; i++) {
174 const char *name, *trig; 238 const char *name, *trig;
175 239
176 ret = -EINVAL; 240 ret = -EINVAL;
@@ -180,30 +244,29 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
180 trig = pdata->led[i].default_trigger; 244 trig = pdata->led[i].default_trigger;
181 245
182 if ((id > devtype->led_max) || (id < devtype->led_min)) { 246 if ((id > devtype->led_max) || (id < devtype->led_min)) {
183 dev_err(&pdev->dev, "Invalid ID %i\n", id); 247 dev_err(dev, "Invalid ID %i\n", id);
184 break; 248 break;
185 } 249 }
186 250
187 if (init_led & (1 << id)) { 251 if (init_led & (1 << id)) {
188 dev_warn(&pdev->dev, 252 dev_warn(dev, "LED %i already initialized\n", id);
189 "LED %i already initialized\n", id);
190 break; 253 break;
191 } 254 }
192 255
193 init_led |= 1 << id; 256 init_led |= 1 << id;
194 leds->led[i].id = id; 257 leds->led[i].id = id;
195 leds->led[i].master = mcdev; 258 leds->led[i].leds = leds;
196 leds->led[i].cdev.name = name; 259 leds->led[i].cdev.name = name;
197 leds->led[i].cdev.default_trigger = trig; 260 leds->led[i].cdev.default_trigger = trig;
261 leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME;
198 leds->led[i].cdev.brightness_set = mc13xxx_led_set; 262 leds->led[i].cdev.brightness_set = mc13xxx_led_set;
199 leds->led[i].cdev.brightness = LED_OFF; 263 leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id);
200 264
201 INIT_WORK(&leds->led[i].work, mc13xxx_led_work); 265 INIT_WORK(&leds->led[i].work, mc13xxx_led_work);
202 266
203 ret = led_classdev_register(pdev->dev.parent, 267 ret = led_classdev_register(dev->parent, &leds->led[i].cdev);
204 &leds->led[i].cdev);
205 if (ret) { 268 if (ret) {
206 dev_err(&pdev->dev, "Failed to register LED %i\n", id); 269 dev_err(dev, "Failed to register LED %i\n", id);
207 break; 270 break;
208 } 271 }
209 } 272 }
@@ -219,7 +282,6 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
219 282
220static int mc13xxx_led_remove(struct platform_device *pdev) 283static int mc13xxx_led_remove(struct platform_device *pdev)
221{ 284{
222 struct mc13xxx *mcdev = dev_get_drvdata(pdev->dev.parent);
223 struct mc13xxx_leds *leds = platform_get_drvdata(pdev); 285 struct mc13xxx_leds *leds = platform_get_drvdata(pdev);
224 int i; 286 int i;
225 287
@@ -228,9 +290,6 @@ static int mc13xxx_led_remove(struct platform_device *pdev)
228 cancel_work_sync(&leds->led[i].work); 290 cancel_work_sync(&leds->led[i].work);
229 } 291 }
230 292
231 for (i = 0; i < leds->devtype->num_regs; i++)
232 mc13xxx_reg_write(mcdev, MC13XXX_REG_LED_CONTROL(i), 0);
233
234 return 0; 293 return 0;
235} 294}
236 295
@@ -238,17 +297,27 @@ static const struct mc13xxx_led_devtype mc13783_led_devtype = {
238 .led_min = MC13783_LED_MD, 297 .led_min = MC13783_LED_MD,
239 .led_max = MC13783_LED_B3, 298 .led_max = MC13783_LED_B3,
240 .num_regs = 6, 299 .num_regs = 6,
300 .ledctrl_base = 51,
241}; 301};
242 302
243static const struct mc13xxx_led_devtype mc13892_led_devtype = { 303static const struct mc13xxx_led_devtype mc13892_led_devtype = {
244 .led_min = MC13892_LED_MD, 304 .led_min = MC13892_LED_MD,
245 .led_max = MC13892_LED_B, 305 .led_max = MC13892_LED_B,
246 .num_regs = 4, 306 .num_regs = 4,
307 .ledctrl_base = 51,
308};
309
310static const struct mc13xxx_led_devtype mc34708_led_devtype = {
311 .led_min = MC34708_LED_R,
312 .led_max = MC34708_LED_G,
313 .num_regs = 1,
314 .ledctrl_base = 54,
247}; 315};
248 316
249static const struct platform_device_id mc13xxx_led_id_table[] = { 317static const struct platform_device_id mc13xxx_led_id_table[] = {
250 { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, }, 318 { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, },
251 { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, }, 319 { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, },
320 { "mc34708-led", (kernel_ulong_t)&mc34708_led_devtype, },
252 { } 321 { }
253}; 322};
254MODULE_DEVICE_TABLE(platform, mc13xxx_led_id_table); 323MODULE_DEVICE_TABLE(platform, mc13xxx_led_id_table);
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
index 2f9f141084ba..e97f443a6e07 100644
--- a/drivers/leds/leds-netxbig.c
+++ b/drivers/leds/leds-netxbig.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/irq.h> 24#include <linux/irq.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/spinlock.h> 26#include <linux/spinlock.h>
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index c7a4230233ea..efa625883c83 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -23,7 +23,6 @@
23 */ 23 */
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/platform_device.h> 26#include <linux/platform_device.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
29#include <linux/gpio.h> 28#include <linux/gpio.h>
diff --git a/drivers/leds/leds-ot200.c b/drivers/leds/leds-ot200.c
index 98cae529373f..c9d906098466 100644
--- a/drivers/leds/leds-ot200.c
+++ b/drivers/leds/leds-ot200.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/init.h>
12#include <linux/platform_device.h> 11#include <linux/platform_device.h>
13#include <linux/slab.h> 12#include <linux/slab.h>
14#include <linux/leds.h> 13#include <linux/leds.h>
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 605047428b5a..7d0aaed1e23a 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/of_platform.h> 18#include <linux/of_platform.h>
20#include <linux/fb.h> 19#include <linux/fb.h>
@@ -84,6 +83,15 @@ static inline size_t sizeof_pwm_leds_priv(int num_leds)
84 (sizeof(struct led_pwm_data) * num_leds); 83 (sizeof(struct led_pwm_data) * num_leds);
85} 84}
86 85
86static void led_pwm_cleanup(struct led_pwm_priv *priv)
87{
88 while (priv->num_leds--) {
89 led_classdev_unregister(&priv->leds[priv->num_leds].cdev);
90 if (priv->leds[priv->num_leds].can_sleep)
91 cancel_work_sync(&priv->leds[priv->num_leds].work);
92 }
93}
94
87static int led_pwm_create_of(struct platform_device *pdev, 95static int led_pwm_create_of(struct platform_device *pdev,
88 struct led_pwm_priv *priv) 96 struct led_pwm_priv *priv)
89{ 97{
@@ -131,8 +139,7 @@ static int led_pwm_create_of(struct platform_device *pdev,
131 139
132 return 0; 140 return 0;
133err: 141err:
134 while (priv->num_leds--) 142 led_pwm_cleanup(priv);
135 led_classdev_unregister(&priv->leds[priv->num_leds].cdev);
136 143
137 return ret; 144 return ret;
138} 145}
@@ -200,8 +207,8 @@ static int led_pwm_probe(struct platform_device *pdev)
200 return 0; 207 return 0;
201 208
202err: 209err:
203 while (i--) 210 priv->num_leds = i;
204 led_classdev_unregister(&priv->leds[i].cdev); 211 led_pwm_cleanup(priv);
205 212
206 return ret; 213 return ret;
207} 214}
@@ -209,13 +216,8 @@ err:
209static int led_pwm_remove(struct platform_device *pdev) 216static int led_pwm_remove(struct platform_device *pdev)
210{ 217{
211 struct led_pwm_priv *priv = platform_get_drvdata(pdev); 218 struct led_pwm_priv *priv = platform_get_drvdata(pdev);
212 int i;
213 219
214 for (i = 0; i < priv->num_leds; i++) { 220 led_pwm_cleanup(priv);
215 led_classdev_unregister(&priv->leds[i].cdev);
216 if (priv->leds[i].can_sleep)
217 cancel_work_sync(&priv->leds[i].work);
218 }
219 221
220 return 0; 222 return 0;
221} 223}
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index 98174e7240ee..28988b7b4fab 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -12,7 +12,6 @@
12*/ 12*/
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
17#include <linux/leds.h> 16#include <linux/leds.h>
18#include <linux/gpio.h> 17#include <linux/gpio.h>
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
index 5b8f938a8d73..2eb3ef62962b 100644
--- a/drivers/leds/leds-ss4200.c
+++ b/drivers/leds/leds-ss4200.c
@@ -63,7 +63,7 @@ MODULE_LICENSE("GPL");
63/* 63/*
64 * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives. 64 * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives.
65 */ 65 */
66static DEFINE_PCI_DEVICE_TABLE(ich7_lpc_pci_id) = { 66static const struct pci_device_id ich7_lpc_pci_id[] = {
67 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) }, 67 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) },
68 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) }, 68 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) },
69 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30) }, 69 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30) },
@@ -78,7 +78,7 @@ static int __init ss4200_led_dmi_callback(const struct dmi_system_id *id)
78 return 1; 78 return 1;
79} 79}
80 80
81static bool __initdata nodetect; 81static bool nodetect;
82module_param_named(nodetect, nodetect, bool, 0); 82module_param_named(nodetect, nodetect, bool, 0);
83MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection"); 83MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
84 84
diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c
index 0a1a13f3a6a5..e72c974142d0 100644
--- a/drivers/leds/leds-wm831x-status.c
+++ b/drivers/leds/leds-wm831x-status.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/leds.h> 15#include <linux/leds.h>
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c
index 3f75fd22fd49..4133ffe29015 100644
--- a/drivers/leds/leds-wm8350.c
+++ b/drivers/leds/leds-wm8350.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
15#include <linux/leds.h> 14#include <linux/leds.h>
16#include <linux/err.h> 15#include <linux/err.h>
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 118335eccc56..1c3ee9fcaf34 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -26,6 +26,7 @@
26#include <linux/percpu.h> 26#include <linux/percpu.h>
27#include <linux/syscore_ops.h> 27#include <linux/syscore_ops.h>
28#include <linux/rwsem.h> 28#include <linux/rwsem.h>
29#include <linux/cpu.h>
29#include "../leds.h" 30#include "../leds.h"
30 31
31#define MAX_NAME_LEN 8 32#define MAX_NAME_LEN 8
@@ -92,6 +93,26 @@ static struct syscore_ops ledtrig_cpu_syscore_ops = {
92 .resume = ledtrig_cpu_syscore_resume, 93 .resume = ledtrig_cpu_syscore_resume,
93}; 94};
94 95
96static int ledtrig_cpu_notify(struct notifier_block *self,
97 unsigned long action, void *hcpu)
98{
99 switch (action & ~CPU_TASKS_FROZEN) {
100 case CPU_STARTING:
101 ledtrig_cpu(CPU_LED_START);
102 break;
103 case CPU_DYING:
104 ledtrig_cpu(CPU_LED_STOP);
105 break;
106 }
107
108 return NOTIFY_OK;
109}
110
111
112static struct notifier_block ledtrig_cpu_nb = {
113 .notifier_call = ledtrig_cpu_notify,
114};
115
95static int __init ledtrig_cpu_init(void) 116static int __init ledtrig_cpu_init(void)
96{ 117{
97 int cpu; 118 int cpu;
@@ -113,6 +134,7 @@ static int __init ledtrig_cpu_init(void)
113 } 134 }
114 135
115 register_syscore_ops(&ledtrig_cpu_syscore_ops); 136 register_syscore_ops(&ledtrig_cpu_syscore_ops);
137 register_cpu_notifier(&ledtrig_cpu_nb);
116 138
117 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); 139 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n");
118 140
@@ -124,6 +146,8 @@ static void __exit ledtrig_cpu_exit(void)
124{ 146{
125 int cpu; 147 int cpu;
126 148
149 unregister_cpu_notifier(&ledtrig_cpu_nb);
150
127 for_each_possible_cpu(cpu) { 151 for_each_possible_cpu(cpu) {
128 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 152 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
129 153
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 4195a01b1535..9a8e66ae04f5 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1988,7 +1988,6 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
1988 if (mddev->bitmap_info.file) { 1988 if (mddev->bitmap_info.file) {
1989 struct file *f = mddev->bitmap_info.file; 1989 struct file *f = mddev->bitmap_info.file;
1990 mddev->bitmap_info.file = NULL; 1990 mddev->bitmap_info.file = NULL;
1991 restore_bitmap_write_access(f);
1992 fput(f); 1991 fput(f);
1993 } 1992 }
1994 } else { 1993 } else {
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4ad5cc4e63e8..8fda38d23e38 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5181,32 +5181,6 @@ static int restart_array(struct mddev *mddev)
5181 return 0; 5181 return 0;
5182} 5182}
5183 5183
5184/* similar to deny_write_access, but accounts for our holding a reference
5185 * to the file ourselves */
5186static int deny_bitmap_write_access(struct file * file)
5187{
5188 struct inode *inode = file->f_mapping->host;
5189
5190 spin_lock(&inode->i_lock);
5191 if (atomic_read(&inode->i_writecount) > 1) {
5192 spin_unlock(&inode->i_lock);
5193 return -ETXTBSY;
5194 }
5195 atomic_set(&inode->i_writecount, -1);
5196 spin_unlock(&inode->i_lock);
5197
5198 return 0;
5199}
5200
5201void restore_bitmap_write_access(struct file *file)
5202{
5203 struct inode *inode = file->f_mapping->host;
5204
5205 spin_lock(&inode->i_lock);
5206 atomic_set(&inode->i_writecount, 1);
5207 spin_unlock(&inode->i_lock);
5208}
5209
5210static void md_clean(struct mddev *mddev) 5184static void md_clean(struct mddev *mddev)
5211{ 5185{
5212 mddev->array_sectors = 0; 5186 mddev->array_sectors = 0;
@@ -5427,7 +5401,6 @@ static int do_md_stop(struct mddev * mddev, int mode,
5427 5401
5428 bitmap_destroy(mddev); 5402 bitmap_destroy(mddev);
5429 if (mddev->bitmap_info.file) { 5403 if (mddev->bitmap_info.file) {
5430 restore_bitmap_write_access(mddev->bitmap_info.file);
5431 fput(mddev->bitmap_info.file); 5404 fput(mddev->bitmap_info.file);
5432 mddev->bitmap_info.file = NULL; 5405 mddev->bitmap_info.file = NULL;
5433 } 5406 }
@@ -5979,7 +5952,7 @@ abort_export:
5979 5952
5980static int set_bitmap_file(struct mddev *mddev, int fd) 5953static int set_bitmap_file(struct mddev *mddev, int fd)
5981{ 5954{
5982 int err; 5955 int err = 0;
5983 5956
5984 if (mddev->pers) { 5957 if (mddev->pers) {
5985 if (!mddev->pers->quiesce) 5958 if (!mddev->pers->quiesce)
@@ -5991,6 +5964,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
5991 5964
5992 5965
5993 if (fd >= 0) { 5966 if (fd >= 0) {
5967 struct inode *inode;
5994 if (mddev->bitmap) 5968 if (mddev->bitmap)
5995 return -EEXIST; /* cannot add when bitmap is present */ 5969 return -EEXIST; /* cannot add when bitmap is present */
5996 mddev->bitmap_info.file = fget(fd); 5970 mddev->bitmap_info.file = fget(fd);
@@ -6001,10 +5975,21 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
6001 return -EBADF; 5975 return -EBADF;
6002 } 5976 }
6003 5977
6004 err = deny_bitmap_write_access(mddev->bitmap_info.file); 5978 inode = mddev->bitmap_info.file->f_mapping->host;
6005 if (err) { 5979 if (!S_ISREG(inode->i_mode)) {
5980 printk(KERN_ERR "%s: error: bitmap file must be a regular file\n",
5981 mdname(mddev));
5982 err = -EBADF;
5983 } else if (!(mddev->bitmap_info.file->f_mode & FMODE_WRITE)) {
5984 printk(KERN_ERR "%s: error: bitmap file must open for write\n",
5985 mdname(mddev));
5986 err = -EBADF;
5987 } else if (atomic_read(&inode->i_writecount) != 1) {
6006 printk(KERN_ERR "%s: error: bitmap file is already in use\n", 5988 printk(KERN_ERR "%s: error: bitmap file is already in use\n",
6007 mdname(mddev)); 5989 mdname(mddev));
5990 err = -EBUSY;
5991 }
5992 if (err) {
6008 fput(mddev->bitmap_info.file); 5993 fput(mddev->bitmap_info.file);
6009 mddev->bitmap_info.file = NULL; 5994 mddev->bitmap_info.file = NULL;
6010 return err; 5995 return err;
@@ -6027,10 +6012,8 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
6027 mddev->pers->quiesce(mddev, 0); 6012 mddev->pers->quiesce(mddev, 0);
6028 } 6013 }
6029 if (fd < 0) { 6014 if (fd < 0) {
6030 if (mddev->bitmap_info.file) { 6015 if (mddev->bitmap_info.file)
6031 restore_bitmap_write_access(mddev->bitmap_info.file);
6032 fput(mddev->bitmap_info.file); 6016 fput(mddev->bitmap_info.file);
6033 }
6034 mddev->bitmap_info.file = NULL; 6017 mddev->bitmap_info.file = NULL;
6035 } 6018 }
6036 6019
@@ -7182,11 +7165,14 @@ static int md_seq_open(struct inode *inode, struct file *file)
7182 return error; 7165 return error;
7183} 7166}
7184 7167
7168static int md_unloading;
7185static unsigned int mdstat_poll(struct file *filp, poll_table *wait) 7169static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
7186{ 7170{
7187 struct seq_file *seq = filp->private_data; 7171 struct seq_file *seq = filp->private_data;
7188 int mask; 7172 int mask;
7189 7173
7174 if (md_unloading)
7175 return POLLIN|POLLRDNORM|POLLERR|POLLPRI;;
7190 poll_wait(filp, &md_event_waiters, wait); 7176 poll_wait(filp, &md_event_waiters, wait);
7191 7177
7192 /* always allow read */ 7178 /* always allow read */
@@ -8672,6 +8658,7 @@ static __exit void md_exit(void)
8672{ 8658{
8673 struct mddev *mddev; 8659 struct mddev *mddev;
8674 struct list_head *tmp; 8660 struct list_head *tmp;
8661 int delay = 1;
8675 8662
8676 blk_unregister_region(MKDEV(MD_MAJOR,0), 1U << MINORBITS); 8663 blk_unregister_region(MKDEV(MD_MAJOR,0), 1U << MINORBITS);
8677 blk_unregister_region(MKDEV(mdp_major,0), 1U << MINORBITS); 8664 blk_unregister_region(MKDEV(mdp_major,0), 1U << MINORBITS);
@@ -8680,7 +8667,19 @@ static __exit void md_exit(void)
8680 unregister_blkdev(mdp_major, "mdp"); 8667 unregister_blkdev(mdp_major, "mdp");
8681 unregister_reboot_notifier(&md_notifier); 8668 unregister_reboot_notifier(&md_notifier);
8682 unregister_sysctl_table(raid_table_header); 8669 unregister_sysctl_table(raid_table_header);
8670
8671 /* We cannot unload the modules while some process is
8672 * waiting for us in select() or poll() - wake them up
8673 */
8674 md_unloading = 1;
8675 while (waitqueue_active(&md_event_waiters)) {
8676 /* not safe to leave yet */
8677 wake_up(&md_event_waiters);
8678 msleep(delay);
8679 delay += delay;
8680 }
8683 remove_proc_entry("mdstat", NULL); 8681 remove_proc_entry("mdstat", NULL);
8682
8684 for_each_mddev(mddev, tmp) { 8683 for_each_mddev(mddev, tmp) {
8685 export_array(mddev); 8684 export_array(mddev);
8686 mddev->hold_active = 0; 8685 mddev->hold_active = 0;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 07bba96de260..a49d991f3fe1 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -605,7 +605,6 @@ extern int md_check_no_bitmap(struct mddev *mddev);
605extern int md_integrity_register(struct mddev *mddev); 605extern int md_integrity_register(struct mddev *mddev);
606extern void md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev); 606extern void md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev);
607extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale); 607extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
608extern void restore_bitmap_write_access(struct file *file);
609 608
610extern void mddev_init(struct mddev *mddev); 609extern void mddev_init(struct mddev *mddev);
611extern int md_run(struct mddev *mddev); 610extern int md_run(struct mddev *mddev);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4a6ca1cb2e78..56e24c072b62 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -97,6 +97,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
97 struct pool_info *pi = data; 97 struct pool_info *pi = data;
98 struct r1bio *r1_bio; 98 struct r1bio *r1_bio;
99 struct bio *bio; 99 struct bio *bio;
100 int need_pages;
100 int i, j; 101 int i, j;
101 102
102 r1_bio = r1bio_pool_alloc(gfp_flags, pi); 103 r1_bio = r1bio_pool_alloc(gfp_flags, pi);
@@ -119,15 +120,15 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
119 * RESYNC_PAGES for each bio. 120 * RESYNC_PAGES for each bio.
120 */ 121 */
121 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) 122 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery))
122 j = pi->raid_disks; 123 need_pages = pi->raid_disks;
123 else 124 else
124 j = 1; 125 need_pages = 1;
125 while(j--) { 126 for (j = 0; j < need_pages; j++) {
126 bio = r1_bio->bios[j]; 127 bio = r1_bio->bios[j];
127 bio->bi_vcnt = RESYNC_PAGES; 128 bio->bi_vcnt = RESYNC_PAGES;
128 129
129 if (bio_alloc_pages(bio, gfp_flags)) 130 if (bio_alloc_pages(bio, gfp_flags))
130 goto out_free_bio; 131 goto out_free_pages;
131 } 132 }
132 /* If not user-requests, copy the page pointers to all bios */ 133 /* If not user-requests, copy the page pointers to all bios */
133 if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { 134 if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
@@ -141,6 +142,14 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
141 142
142 return r1_bio; 143 return r1_bio;
143 144
145out_free_pages:
146 while (--j >= 0) {
147 struct bio_vec *bv;
148
149 bio_for_each_segment_all(bv, r1_bio->bios[j], i)
150 __free_page(bv->bv_page);
151 }
152
144out_free_bio: 153out_free_bio:
145 while (++j < pi->raid_disks) 154 while (++j < pi->raid_disks)
146 bio_put(r1_bio->bios[j]); 155 bio_put(r1_bio->bios[j]);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 16f5c21963db..25247a852912 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -679,14 +679,9 @@ get_active_stripe(struct r5conf *conf, sector_t sector,
679 init_stripe(sh, sector, previous); 679 init_stripe(sh, sector, previous);
680 atomic_inc(&sh->count); 680 atomic_inc(&sh->count);
681 } 681 }
682 } else { 682 } else if (!atomic_inc_not_zero(&sh->count)) {
683 spin_lock(&conf->device_lock); 683 spin_lock(&conf->device_lock);
684 if (atomic_read(&sh->count)) { 684 if (!atomic_read(&sh->count)) {
685 BUG_ON(!list_empty(&sh->lru)
686 && !test_bit(STRIPE_EXPANDING, &sh->state)
687 && !test_bit(STRIPE_ON_UNPLUG_LIST, &sh->state)
688 );
689 } else {
690 if (!test_bit(STRIPE_HANDLE, &sh->state)) 685 if (!test_bit(STRIPE_HANDLE, &sh->state))
691 atomic_inc(&conf->active_stripes); 686 atomic_inc(&conf->active_stripes);
692 BUG_ON(list_empty(&sh->lru) && 687 BUG_ON(list_empty(&sh->lru) &&
@@ -4552,6 +4547,8 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4552 struct stripe_head *sh; 4547 struct stripe_head *sh;
4553 const int rw = bio_data_dir(bi); 4548 const int rw = bio_data_dir(bi);
4554 int remaining; 4549 int remaining;
4550 DEFINE_WAIT(w);
4551 bool do_prepare;
4555 4552
4556 if (unlikely(bi->bi_rw & REQ_FLUSH)) { 4553 if (unlikely(bi->bi_rw & REQ_FLUSH)) {
4557 md_flush_request(mddev, bi); 4554 md_flush_request(mddev, bi);
@@ -4575,15 +4572,18 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4575 bi->bi_next = NULL; 4572 bi->bi_next = NULL;
4576 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ 4573 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */
4577 4574
4575 prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
4578 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { 4576 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
4579 DEFINE_WAIT(w);
4580 int previous; 4577 int previous;
4581 int seq; 4578 int seq;
4582 4579
4580 do_prepare = false;
4583 retry: 4581 retry:
4584 seq = read_seqcount_begin(&conf->gen_lock); 4582 seq = read_seqcount_begin(&conf->gen_lock);
4585 previous = 0; 4583 previous = 0;
4586 prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE); 4584 if (do_prepare)
4585 prepare_to_wait(&conf->wait_for_overlap, &w,
4586 TASK_UNINTERRUPTIBLE);
4587 if (unlikely(conf->reshape_progress != MaxSector)) { 4587 if (unlikely(conf->reshape_progress != MaxSector)) {
4588 /* spinlock is needed as reshape_progress may be 4588 /* spinlock is needed as reshape_progress may be
4589 * 64bit on a 32bit platform, and so it might be 4589 * 64bit on a 32bit platform, and so it might be
@@ -4604,6 +4604,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4604 : logical_sector >= conf->reshape_safe) { 4604 : logical_sector >= conf->reshape_safe) {
4605 spin_unlock_irq(&conf->device_lock); 4605 spin_unlock_irq(&conf->device_lock);
4606 schedule(); 4606 schedule();
4607 do_prepare = true;
4607 goto retry; 4608 goto retry;
4608 } 4609 }
4609 } 4610 }
@@ -4640,6 +4641,7 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4640 if (must_retry) { 4641 if (must_retry) {
4641 release_stripe(sh); 4642 release_stripe(sh);
4642 schedule(); 4643 schedule();
4644 do_prepare = true;
4643 goto retry; 4645 goto retry;
4644 } 4646 }
4645 } 4647 }
@@ -4663,8 +4665,10 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4663 prepare_to_wait(&conf->wait_for_overlap, 4665 prepare_to_wait(&conf->wait_for_overlap,
4664 &w, TASK_INTERRUPTIBLE); 4666 &w, TASK_INTERRUPTIBLE);
4665 if (logical_sector >= mddev->suspend_lo && 4667 if (logical_sector >= mddev->suspend_lo &&
4666 logical_sector < mddev->suspend_hi) 4668 logical_sector < mddev->suspend_hi) {
4667 schedule(); 4669 schedule();
4670 do_prepare = true;
4671 }
4668 goto retry; 4672 goto retry;
4669 } 4673 }
4670 4674
@@ -4677,9 +4681,9 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4677 md_wakeup_thread(mddev->thread); 4681 md_wakeup_thread(mddev->thread);
4678 release_stripe(sh); 4682 release_stripe(sh);
4679 schedule(); 4683 schedule();
4684 do_prepare = true;
4680 goto retry; 4685 goto retry;
4681 } 4686 }
4682 finish_wait(&conf->wait_for_overlap, &w);
4683 set_bit(STRIPE_HANDLE, &sh->state); 4687 set_bit(STRIPE_HANDLE, &sh->state);
4684 clear_bit(STRIPE_DELAYED, &sh->state); 4688 clear_bit(STRIPE_DELAYED, &sh->state);
4685 if ((bi->bi_rw & REQ_SYNC) && 4689 if ((bi->bi_rw & REQ_SYNC) &&
@@ -4689,10 +4693,10 @@ static void make_request(struct mddev *mddev, struct bio * bi)
4689 } else { 4693 } else {
4690 /* cannot get stripe for read-ahead, just give-up */ 4694 /* cannot get stripe for read-ahead, just give-up */
4691 clear_bit(BIO_UPTODATE, &bi->bi_flags); 4695 clear_bit(BIO_UPTODATE, &bi->bi_flags);
4692 finish_wait(&conf->wait_for_overlap, &w);
4693 break; 4696 break;
4694 } 4697 }
4695 } 4698 }
4699 finish_wait(&conf->wait_for_overlap, &w);
4696 4700
4697 remaining = raid5_dec_bi_active_stripes(bi); 4701 remaining = raid5_dec_bi_active_stripes(bi);
4698 if (remaining == 0) { 4702 if (remaining == 0) {
diff --git a/drivers/media/dvb-frontends/drx39xyj/Kconfig b/drivers/media/dvb-frontends/drx39xyj/Kconfig
index 15628eb5cf0c..6c2ccb6a506b 100644
--- a/drivers/media/dvb-frontends/drx39xyj/Kconfig
+++ b/drivers/media/dvb-frontends/drx39xyj/Kconfig
@@ -1,7 +1,7 @@
1config DVB_DRX39XYJ 1config DVB_DRX39XYJ
2 tristate "Micronas DRX-J demodulator" 2 tristate "Micronas DRX-J demodulator"
3 depends on DVB_CORE && I2C 3 depends on DVB_CORE && I2C
4 default m if DVB_FE_CUSTOMISE 4 default m if !MEDIA_SUBDRV_AUTOSELECT
5 help 5 help
6 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want 6 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
7 to support this frontend. 7 to support this frontend.
diff --git a/drivers/media/dvb-frontends/lgdt3305.c b/drivers/media/dvb-frontends/lgdt3305.c
index 1d2c47378cf8..92c891a571ab 100644
--- a/drivers/media/dvb-frontends/lgdt3305.c
+++ b/drivers/media/dvb-frontends/lgdt3305.c
@@ -1176,6 +1176,7 @@ static struct dvb_frontend_ops lgdt3304_ops = {
1176 }, 1176 },
1177 .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl, 1177 .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl,
1178 .init = lgdt3305_init, 1178 .init = lgdt3305_init,
1179 .sleep = lgdt3305_sleep,
1179 .set_frontend = lgdt3304_set_parameters, 1180 .set_frontend = lgdt3304_set_parameters,
1180 .get_frontend = lgdt3305_get_frontend, 1181 .get_frontend = lgdt3305_get_frontend,
1181 .get_tune_settings = lgdt3305_get_tune_settings, 1182 .get_tune_settings = lgdt3305_get_tune_settings,
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index 32cffca14d0b..d63bc9c13dce 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -297,7 +297,7 @@ struct inittab {
297 u8 val; 297 u8 val;
298}; 298};
299 299
300struct inittab m88rs2000_setup[] = { 300static struct inittab m88rs2000_setup[] = {
301 {DEMOD_WRITE, 0x9a, 0x30}, 301 {DEMOD_WRITE, 0x9a, 0x30},
302 {DEMOD_WRITE, 0x00, 0x01}, 302 {DEMOD_WRITE, 0x00, 0x01},
303 {WRITE_DELAY, 0x19, 0x00}, 303 {WRITE_DELAY, 0x19, 0x00},
@@ -315,7 +315,7 @@ struct inittab m88rs2000_setup[] = {
315 {0xff, 0xaa, 0xff} 315 {0xff, 0xaa, 0xff}
316}; 316};
317 317
318struct inittab m88rs2000_shutdown[] = { 318static struct inittab m88rs2000_shutdown[] = {
319 {DEMOD_WRITE, 0x9a, 0x30}, 319 {DEMOD_WRITE, 0x9a, 0x30},
320 {DEMOD_WRITE, 0xb0, 0x00}, 320 {DEMOD_WRITE, 0xb0, 0x00},
321 {DEMOD_WRITE, 0xf1, 0x89}, 321 {DEMOD_WRITE, 0xf1, 0x89},
@@ -325,7 +325,7 @@ struct inittab m88rs2000_shutdown[] = {
325 {0xff, 0xaa, 0xff} 325 {0xff, 0xaa, 0xff}
326}; 326};
327 327
328struct inittab fe_reset[] = { 328static struct inittab fe_reset[] = {
329 {DEMOD_WRITE, 0x00, 0x01}, 329 {DEMOD_WRITE, 0x00, 0x01},
330 {DEMOD_WRITE, 0x20, 0x81}, 330 {DEMOD_WRITE, 0x20, 0x81},
331 {DEMOD_WRITE, 0x21, 0x80}, 331 {DEMOD_WRITE, 0x21, 0x80},
@@ -363,7 +363,7 @@ struct inittab fe_reset[] = {
363 {0xff, 0xaa, 0xff} 363 {0xff, 0xaa, 0xff}
364}; 364};
365 365
366struct inittab fe_trigger[] = { 366static struct inittab fe_trigger[] = {
367 {DEMOD_WRITE, 0x97, 0x04}, 367 {DEMOD_WRITE, 0x97, 0x04},
368 {DEMOD_WRITE, 0x99, 0x77}, 368 {DEMOD_WRITE, 0x99, 0x77},
369 {DEMOD_WRITE, 0x9b, 0x64}, 369 {DEMOD_WRITE, 0x9b, 0x64},
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 7a77a5b7a075..5c421886d97c 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -49,8 +49,8 @@
49#define VPE_MODULE_NAME "vpe" 49#define VPE_MODULE_NAME "vpe"
50 50
51/* minimum and maximum frame sizes */ 51/* minimum and maximum frame sizes */
52#define MIN_W 128 52#define MIN_W 32
53#define MIN_H 128 53#define MIN_H 32
54#define MAX_W 1920 54#define MAX_W 1920
55#define MAX_H 1080 55#define MAX_H 1080
56 56
@@ -887,6 +887,9 @@ static int job_ready(void *priv)
887 if (v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) < needed) 887 if (v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) < needed)
888 return 0; 888 return 0;
889 889
890 if (v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) < needed)
891 return 0;
892
890 return 1; 893 return 1;
891} 894}
892 895
@@ -1277,18 +1280,17 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1277 s_buf = &s_vb->v4l2_buf; 1280 s_buf = &s_vb->v4l2_buf;
1278 d_buf = &d_vb->v4l2_buf; 1281 d_buf = &d_vb->v4l2_buf;
1279 1282
1283 d_buf->flags = s_buf->flags;
1284
1280 d_buf->timestamp = s_buf->timestamp; 1285 d_buf->timestamp = s_buf->timestamp;
1281 d_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1286 if (s_buf->flags & V4L2_BUF_FLAG_TIMECODE)
1282 d_buf->flags |= s_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1283 if (s_buf->flags & V4L2_BUF_FLAG_TIMECODE) {
1284 d_buf->flags |= V4L2_BUF_FLAG_TIMECODE;
1285 d_buf->timecode = s_buf->timecode; 1287 d_buf->timecode = s_buf->timecode;
1286 } 1288
1287 d_buf->sequence = ctx->sequence; 1289 d_buf->sequence = ctx->sequence;
1288 d_buf->field = ctx->field;
1289 1290
1290 d_q_data = &ctx->q_data[Q_DATA_DST]; 1291 d_q_data = &ctx->q_data[Q_DATA_DST];
1291 if (d_q_data->flags & Q_DATA_INTERLACED) { 1292 if (d_q_data->flags & Q_DATA_INTERLACED) {
1293 d_buf->field = ctx->field;
1292 if (ctx->field == V4L2_FIELD_BOTTOM) { 1294 if (ctx->field == V4L2_FIELD_BOTTOM) {
1293 ctx->sequence++; 1295 ctx->sequence++;
1294 ctx->field = V4L2_FIELD_TOP; 1296 ctx->field = V4L2_FIELD_TOP;
@@ -1297,6 +1299,7 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1297 ctx->field = V4L2_FIELD_BOTTOM; 1299 ctx->field = V4L2_FIELD_BOTTOM;
1298 } 1300 }
1299 } else { 1301 } else {
1302 d_buf->field = V4L2_FIELD_NONE;
1300 ctx->sequence++; 1303 ctx->sequence++;
1301 } 1304 }
1302 1305
@@ -1335,8 +1338,9 @@ static int vpe_querycap(struct file *file, void *priv,
1335{ 1338{
1336 strncpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver) - 1); 1339 strncpy(cap->driver, VPE_MODULE_NAME, sizeof(cap->driver) - 1);
1337 strncpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card) - 1); 1340 strncpy(cap->card, VPE_MODULE_NAME, sizeof(cap->card) - 1);
1338 strlcpy(cap->bus_info, VPE_MODULE_NAME, sizeof(cap->bus_info)); 1341 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
1339 cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING; 1342 VPE_MODULE_NAME);
1343 cap->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
1340 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; 1344 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
1341 return 0; 1345 return 0;
1342} 1346}
@@ -1476,6 +1480,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1476 } 1480 }
1477 } 1481 }
1478 1482
1483 memset(pix->reserved, 0, sizeof(pix->reserved));
1479 for (i = 0; i < pix->num_planes; i++) { 1484 for (i = 0; i < pix->num_planes; i++) {
1480 plane_fmt = &pix->plane_fmt[i]; 1485 plane_fmt = &pix->plane_fmt[i];
1481 depth = fmt->vpdma_fmt[i]->depth; 1486 depth = fmt->vpdma_fmt[i]->depth;
@@ -1487,6 +1492,8 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
1487 1492
1488 plane_fmt->sizeimage = 1493 plane_fmt->sizeimage =
1489 (pix->height * pix->width * depth) >> 3; 1494 (pix->height * pix->width * depth) >> 3;
1495
1496 memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved));
1490 } 1497 }
1491 1498
1492 return 0; 1499 return 0;
@@ -1717,6 +1724,16 @@ static int vpe_buf_prepare(struct vb2_buffer *vb)
1717 q_data = get_q_data(ctx, vb->vb2_queue->type); 1724 q_data = get_q_data(ctx, vb->vb2_queue->type);
1718 num_planes = q_data->fmt->coplanar ? 2 : 1; 1725 num_planes = q_data->fmt->coplanar ? 2 : 1;
1719 1726
1727 if (vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1728 if (!(q_data->flags & Q_DATA_INTERLACED)) {
1729 vb->v4l2_buf.field = V4L2_FIELD_NONE;
1730 } else {
1731 if (vb->v4l2_buf.field != V4L2_FIELD_TOP &&
1732 vb->v4l2_buf.field != V4L2_FIELD_BOTTOM)
1733 return -EINVAL;
1734 }
1735 }
1736
1720 for (i = 0; i < num_planes; i++) { 1737 for (i = 0; i < num_planes; i++) {
1721 if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) { 1738 if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) {
1722 vpe_err(ctx->dev, 1739 vpe_err(ctx->dev,
@@ -1866,9 +1883,11 @@ static int vpe_open(struct file *file)
1866 s_q_data->fmt = &vpe_formats[2]; 1883 s_q_data->fmt = &vpe_formats[2];
1867 s_q_data->width = 1920; 1884 s_q_data->width = 1920;
1868 s_q_data->height = 1080; 1885 s_q_data->height = 1080;
1869 s_q_data->sizeimage[VPE_LUMA] = (s_q_data->width * s_q_data->height * 1886 s_q_data->bytesperline[VPE_LUMA] = (s_q_data->width *
1870 s_q_data->fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3; 1887 s_q_data->fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3;
1871 s_q_data->colorspace = V4L2_COLORSPACE_SMPTE170M; 1888 s_q_data->sizeimage[VPE_LUMA] = (s_q_data->bytesperline[VPE_LUMA] *
1889 s_q_data->height);
1890 s_q_data->colorspace = V4L2_COLORSPACE_REC709;
1872 s_q_data->field = V4L2_FIELD_NONE; 1891 s_q_data->field = V4L2_FIELD_NONE;
1873 s_q_data->c_rect.left = 0; 1892 s_q_data->c_rect.left = 0;
1874 s_q_data->c_rect.top = 0; 1893 s_q_data->c_rect.top = 0;
@@ -2002,7 +2021,7 @@ static struct video_device vpe_videodev = {
2002 .fops = &vpe_fops, 2021 .fops = &vpe_fops,
2003 .ioctl_ops = &vpe_ioctl_ops, 2022 .ioctl_ops = &vpe_ioctl_ops,
2004 .minor = -1, 2023 .minor = -1,
2005 .release = video_device_release, 2024 .release = video_device_release_empty,
2006 .vfl_dir = VFL_DIR_M2M, 2025 .vfl_dir = VFL_DIR_M2M,
2007}; 2026};
2008 2027
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
index 579a52b3edce..0127dd257a57 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -504,6 +504,18 @@ unlock:
504 return ret; 504 return ret;
505} 505}
506 506
507static int img_ir_set_normal_filter(struct rc_dev *dev,
508 struct rc_scancode_filter *sc_filter)
509{
510 return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter);
511}
512
513static int img_ir_set_wakeup_filter(struct rc_dev *dev,
514 struct rc_scancode_filter *sc_filter)
515{
516 return img_ir_set_filter(dev, RC_FILTER_WAKEUP, sc_filter);
517}
518
507/** 519/**
508 * img_ir_set_decoder() - Set the current decoder. 520 * img_ir_set_decoder() - Set the current decoder.
509 * @priv: IR private data. 521 * @priv: IR private data.
@@ -986,7 +998,8 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
986 rdev->map_name = RC_MAP_EMPTY; 998 rdev->map_name = RC_MAP_EMPTY;
987 rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv)); 999 rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv));
988 rdev->input_name = "IMG Infrared Decoder"; 1000 rdev->input_name = "IMG Infrared Decoder";
989 rdev->s_filter = img_ir_set_filter; 1001 rdev->s_filter = img_ir_set_normal_filter;
1002 rdev->s_wakeup_filter = img_ir_set_wakeup_filter;
990 1003
991 /* Register hardware decoder */ 1004 /* Register hardware decoder */
992 error = rc_register_device(rdev); 1005 error = rc_register_device(rdev);
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
index e7a731bc3a9b..751d9d945269 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include "img-ir-hw.h" 7#include "img-ir-hw.h"
8#include <linux/bitrev.h>
8 9
9/* Convert NEC data to a scancode */ 10/* Convert NEC data to a scancode */
10static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols) 11static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
@@ -22,11 +23,11 @@ static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
22 data_inv = (raw >> 24) & 0xff; 23 data_inv = (raw >> 24) & 0xff;
23 if ((data_inv ^ data) != 0xff) { 24 if ((data_inv ^ data) != 0xff) {
24 /* 32-bit NEC (used by Apple and TiVo remotes) */ 25 /* 32-bit NEC (used by Apple and TiVo remotes) */
25 /* scan encoding: aaAAddDD */ 26 /* scan encoding: as transmitted, MSBit = first received bit */
26 *scancode = addr_inv << 24 | 27 *scancode = bitrev8(addr) << 24 |
27 addr << 16 | 28 bitrev8(addr_inv) << 16 |
28 data_inv << 8 | 29 bitrev8(data) << 8 |
29 data; 30 bitrev8(data_inv);
30 } else if ((addr_inv ^ addr) != 0xff) { 31 } else if ((addr_inv ^ addr) != 0xff) {
31 /* Extended NEC */ 32 /* Extended NEC */
32 /* scan encoding: AAaaDD */ 33 /* scan encoding: AAaaDD */
@@ -54,13 +55,15 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
54 55
55 if ((in->data | in->mask) & 0xff000000) { 56 if ((in->data | in->mask) & 0xff000000) {
56 /* 32-bit NEC (used by Apple and TiVo remotes) */ 57 /* 32-bit NEC (used by Apple and TiVo remotes) */
57 /* scan encoding: aaAAddDD */ 58 /* scan encoding: as transmitted, MSBit = first received bit */
58 addr_inv = (in->data >> 24) & 0xff; 59 addr = bitrev8(in->data >> 24);
59 addr_inv_m = (in->mask >> 24) & 0xff; 60 addr_m = bitrev8(in->mask >> 24);
60 addr = (in->data >> 16) & 0xff; 61 addr_inv = bitrev8(in->data >> 16);
61 addr_m = (in->mask >> 16) & 0xff; 62 addr_inv_m = bitrev8(in->mask >> 16);
62 data_inv = (in->data >> 8) & 0xff; 63 data = bitrev8(in->data >> 8);
63 data_inv_m = (in->mask >> 8) & 0xff; 64 data_m = bitrev8(in->mask >> 8);
65 data_inv = bitrev8(in->data >> 0);
66 data_inv_m = bitrev8(in->mask >> 0);
64 } else if ((in->data | in->mask) & 0x00ff0000) { 67 } else if ((in->data | in->mask) & 0x00ff0000) {
65 /* Extended NEC */ 68 /* Extended NEC */
66 /* scan encoding AAaaDD */ 69 /* scan encoding AAaaDD */
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 9de1791d2494..35c42e5e270b 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -172,10 +172,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
172 if (send_32bits) { 172 if (send_32bits) {
173 /* NEC transport, but modified protocol, used by at 173 /* NEC transport, but modified protocol, used by at
174 * least Apple and TiVo remotes */ 174 * least Apple and TiVo remotes */
175 scancode = not_address << 24 | 175 scancode = data->bits;
176 address << 16 |
177 not_command << 8 |
178 command;
179 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode); 176 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode);
180 } else if ((address ^ not_address) != 0xff) { 177 } else if ((address ^ not_address) != 0xff) {
181 /* Extended NEC */ 178 /* Extended NEC */
diff --git a/drivers/media/rc/keymaps/rc-tivo.c b/drivers/media/rc/keymaps/rc-tivo.c
index 5cc1b456e329..454e06295692 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -15,62 +15,62 @@
15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle, 15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle,
16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb 16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb
17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having 17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having
18 * a command/not_command pair, it has a vendor ID of 0x3085, but some keys, the 18 * a command/not_command pair, it has a vendor ID of 0xa10c, but some keys, the
19 * NEC extended checksums do pass, so the table presently has the intended 19 * NEC extended checksums do pass, so the table presently has the intended
20 * values and the checksum-passed versions for those keys. 20 * values and the checksum-passed versions for those keys.
21 */ 21 */
22static struct rc_map_table tivo[] = { 22static struct rc_map_table tivo[] = {
23 { 0x3085f009, KEY_MEDIA }, /* TiVo Button */ 23 { 0xa10c900f, KEY_MEDIA }, /* TiVo Button */
24 { 0x3085e010, KEY_POWER2 }, /* TV Power */ 24 { 0xa10c0807, KEY_POWER2 }, /* TV Power */
25 { 0x3085e011, KEY_TV }, /* Live TV/Swap */ 25 { 0xa10c8807, KEY_TV }, /* Live TV/Swap */
26 { 0x3085c034, KEY_VIDEO_NEXT }, /* TV Input */ 26 { 0xa10c2c03, KEY_VIDEO_NEXT }, /* TV Input */
27 { 0x3085e013, KEY_INFO }, 27 { 0xa10cc807, KEY_INFO },
28 { 0x3085a05f, KEY_CYCLEWINDOWS }, /* Window */ 28 { 0xa10cfa05, KEY_CYCLEWINDOWS }, /* Window */
29 { 0x0085305f, KEY_CYCLEWINDOWS }, 29 { 0x0085305f, KEY_CYCLEWINDOWS },
30 { 0x3085c036, KEY_EPG }, /* Guide */ 30 { 0xa10c6c03, KEY_EPG }, /* Guide */
31 31
32 { 0x3085e014, KEY_UP }, 32 { 0xa10c2807, KEY_UP },
33 { 0x3085e016, KEY_DOWN }, 33 { 0xa10c6807, KEY_DOWN },
34 { 0x3085e017, KEY_LEFT }, 34 { 0xa10ce807, KEY_LEFT },
35 { 0x3085e015, KEY_RIGHT }, 35 { 0xa10ca807, KEY_RIGHT },
36 36
37 { 0x3085e018, KEY_SCROLLDOWN }, /* Red Thumbs Down */ 37 { 0xa10c1807, KEY_SCROLLDOWN }, /* Red Thumbs Down */
38 { 0x3085e019, KEY_SELECT }, 38 { 0xa10c9807, KEY_SELECT },
39 { 0x3085e01a, KEY_SCROLLUP }, /* Green Thumbs Up */ 39 { 0xa10c5807, KEY_SCROLLUP }, /* Green Thumbs Up */
40 40
41 { 0x3085e01c, KEY_VOLUMEUP }, 41 { 0xa10c3807, KEY_VOLUMEUP },
42 { 0x3085e01d, KEY_VOLUMEDOWN }, 42 { 0xa10cb807, KEY_VOLUMEDOWN },
43 { 0x3085e01b, KEY_MUTE }, 43 { 0xa10cd807, KEY_MUTE },
44 { 0x3085d020, KEY_RECORD }, 44 { 0xa10c040b, KEY_RECORD },
45 { 0x3085e01e, KEY_CHANNELUP }, 45 { 0xa10c7807, KEY_CHANNELUP },
46 { 0x3085e01f, KEY_CHANNELDOWN }, 46 { 0xa10cf807, KEY_CHANNELDOWN },
47 { 0x0085301f, KEY_CHANNELDOWN }, 47 { 0x0085301f, KEY_CHANNELDOWN },
48 48
49 { 0x3085d021, KEY_PLAY }, 49 { 0xa10c840b, KEY_PLAY },
50 { 0x3085d023, KEY_PAUSE }, 50 { 0xa10cc40b, KEY_PAUSE },
51 { 0x3085d025, KEY_SLOW }, 51 { 0xa10ca40b, KEY_SLOW },
52 { 0x3085d022, KEY_REWIND }, 52 { 0xa10c440b, KEY_REWIND },
53 { 0x3085d024, KEY_FASTFORWARD }, 53 { 0xa10c240b, KEY_FASTFORWARD },
54 { 0x3085d026, KEY_PREVIOUS }, 54 { 0xa10c640b, KEY_PREVIOUS },
55 { 0x3085d027, KEY_NEXT }, /* ->| */ 55 { 0xa10ce40b, KEY_NEXT }, /* ->| */
56 56
57 { 0x3085b044, KEY_ZOOM }, /* Aspect */ 57 { 0xa10c220d, KEY_ZOOM }, /* Aspect */
58 { 0x3085b048, KEY_STOP }, 58 { 0xa10c120d, KEY_STOP },
59 { 0x3085b04a, KEY_DVD }, /* DVD Menu */ 59 { 0xa10c520d, KEY_DVD }, /* DVD Menu */
60 60
61 { 0x3085d028, KEY_NUMERIC_1 }, 61 { 0xa10c140b, KEY_NUMERIC_1 },
62 { 0x3085d029, KEY_NUMERIC_2 }, 62 { 0xa10c940b, KEY_NUMERIC_2 },
63 { 0x3085d02a, KEY_NUMERIC_3 }, 63 { 0xa10c540b, KEY_NUMERIC_3 },
64 { 0x3085d02b, KEY_NUMERIC_4 }, 64 { 0xa10cd40b, KEY_NUMERIC_4 },
65 { 0x3085d02c, KEY_NUMERIC_5 }, 65 { 0xa10c340b, KEY_NUMERIC_5 },
66 { 0x3085d02d, KEY_NUMERIC_6 }, 66 { 0xa10cb40b, KEY_NUMERIC_6 },
67 { 0x3085d02e, KEY_NUMERIC_7 }, 67 { 0xa10c740b, KEY_NUMERIC_7 },
68 { 0x3085d02f, KEY_NUMERIC_8 }, 68 { 0xa10cf40b, KEY_NUMERIC_8 },
69 { 0x0085302f, KEY_NUMERIC_8 }, 69 { 0x0085302f, KEY_NUMERIC_8 },
70 { 0x3085c030, KEY_NUMERIC_9 }, 70 { 0xa10c0c03, KEY_NUMERIC_9 },
71 { 0x3085c031, KEY_NUMERIC_0 }, 71 { 0xa10c8c03, KEY_NUMERIC_0 },
72 { 0x3085c033, KEY_ENTER }, 72 { 0xa10ccc03, KEY_ENTER },
73 { 0x3085c032, KEY_CLEAR }, 73 { 0xa10c4c03, KEY_CLEAR },
74}; 74};
75 75
76static struct rc_map_list tivo_map = { 76static struct rc_map_list tivo_map = {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 99697aae92ff..970b93d6f399 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -633,19 +633,13 @@ EXPORT_SYMBOL_GPL(rc_repeat);
633static void ir_do_keydown(struct rc_dev *dev, int scancode, 633static void ir_do_keydown(struct rc_dev *dev, int scancode,
634 u32 keycode, u8 toggle) 634 u32 keycode, u8 toggle)
635{ 635{
636 struct rc_scancode_filter *filter; 636 bool new_event = (!dev->keypressed ||
637 bool new_event = !dev->keypressed || 637 dev->last_scancode != scancode ||
638 dev->last_scancode != scancode || 638 dev->last_toggle != toggle);
639 dev->last_toggle != toggle;
640 639
641 if (new_event && dev->keypressed) 640 if (new_event && dev->keypressed)
642 ir_do_keyup(dev, false); 641 ir_do_keyup(dev, false);
643 642
644 /* Generic scancode filtering */
645 filter = &dev->scancode_filters[RC_FILTER_NORMAL];
646 if (filter->mask && ((scancode ^ filter->data) & filter->mask))
647 return;
648
649 input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); 643 input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode);
650 644
651 if (new_event && keycode != KEY_RESERVED) { 645 if (new_event && keycode != KEY_RESERVED) {
@@ -923,6 +917,7 @@ static ssize_t store_protocols(struct device *device,
923 int rc, i, count = 0; 917 int rc, i, count = 0;
924 ssize_t ret; 918 ssize_t ret;
925 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 919 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
920 int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
926 struct rc_scancode_filter local_filter, *filter; 921 struct rc_scancode_filter local_filter, *filter;
927 922
928 /* Device is being removed */ 923 /* Device is being removed */
@@ -1007,24 +1002,23 @@ static ssize_t store_protocols(struct device *device,
1007 * Fall back to clearing the filter. 1002 * Fall back to clearing the filter.
1008 */ 1003 */
1009 filter = &dev->scancode_filters[fattr->type]; 1004 filter = &dev->scancode_filters[fattr->type];
1010 if (old_type != type && filter->mask) { 1005 set_filter = (fattr->type == RC_FILTER_NORMAL)
1006 ? dev->s_filter : dev->s_wakeup_filter;
1007
1008 if (set_filter && old_type != type && filter->mask) {
1011 local_filter = *filter; 1009 local_filter = *filter;
1012 if (!type) { 1010 if (!type) {
1013 /* no protocol => clear filter */ 1011 /* no protocol => clear filter */
1014 ret = -1; 1012 ret = -1;
1015 } else if (!dev->s_filter) {
1016 /* generic filtering => accept any filter */
1017 ret = 0;
1018 } else { 1013 } else {
1019 /* hardware filtering => try setting, otherwise clear */ 1014 /* hardware filtering => try setting, otherwise clear */
1020 ret = dev->s_filter(dev, fattr->type, &local_filter); 1015 ret = set_filter(dev, &local_filter);
1021 } 1016 }
1022 if (ret < 0) { 1017 if (ret < 0) {
1023 /* clear the filter */ 1018 /* clear the filter */
1024 local_filter.data = 0; 1019 local_filter.data = 0;
1025 local_filter.mask = 0; 1020 local_filter.mask = 0;
1026 if (dev->s_filter) 1021 set_filter(dev, &local_filter);
1027 dev->s_filter(dev, fattr->type, &local_filter);
1028 } 1022 }
1029 1023
1030 /* commit the new filter */ 1024 /* commit the new filter */
@@ -1068,7 +1062,10 @@ static ssize_t show_filter(struct device *device,
1068 return -EINVAL; 1062 return -EINVAL;
1069 1063
1070 mutex_lock(&dev->lock); 1064 mutex_lock(&dev->lock);
1071 if (fattr->mask) 1065 if ((fattr->type == RC_FILTER_NORMAL && !dev->s_filter) ||
1066 (fattr->type == RC_FILTER_WAKEUP && !dev->s_wakeup_filter))
1067 val = 0;
1068 else if (fattr->mask)
1072 val = dev->scancode_filters[fattr->type].mask; 1069 val = dev->scancode_filters[fattr->type].mask;
1073 else 1070 else
1074 val = dev->scancode_filters[fattr->type].data; 1071 val = dev->scancode_filters[fattr->type].data;
@@ -1106,6 +1103,7 @@ static ssize_t store_filter(struct device *device,
1106 struct rc_scancode_filter local_filter, *filter; 1103 struct rc_scancode_filter local_filter, *filter;
1107 int ret; 1104 int ret;
1108 unsigned long val; 1105 unsigned long val;
1106 int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter);
1109 1107
1110 /* Device is being removed */ 1108 /* Device is being removed */
1111 if (!dev) 1109 if (!dev)
@@ -1115,9 +1113,11 @@ static ssize_t store_filter(struct device *device,
1115 if (ret < 0) 1113 if (ret < 0)
1116 return ret; 1114 return ret;
1117 1115
1118 /* Scancode filter not supported (but still accept 0) */ 1116 /* Can the scancode filter be set? */
1119 if (!dev->s_filter && fattr->type != RC_FILTER_NORMAL) 1117 set_filter = (fattr->type == RC_FILTER_NORMAL) ? dev->s_filter :
1120 return val ? -EINVAL : count; 1118 dev->s_wakeup_filter;
1119 if (!set_filter)
1120 return -EINVAL;
1121 1121
1122 mutex_lock(&dev->lock); 1122 mutex_lock(&dev->lock);
1123 1123
@@ -1128,16 +1128,16 @@ static ssize_t store_filter(struct device *device,
1128 local_filter.mask = val; 1128 local_filter.mask = val;
1129 else 1129 else
1130 local_filter.data = val; 1130 local_filter.data = val;
1131
1131 if (!dev->enabled_protocols[fattr->type] && local_filter.mask) { 1132 if (!dev->enabled_protocols[fattr->type] && local_filter.mask) {
1132 /* refuse to set a filter unless a protocol is enabled */ 1133 /* refuse to set a filter unless a protocol is enabled */
1133 ret = -EINVAL; 1134 ret = -EINVAL;
1134 goto unlock; 1135 goto unlock;
1135 } 1136 }
1136 if (dev->s_filter) { 1137
1137 ret = dev->s_filter(dev, fattr->type, &local_filter); 1138 ret = set_filter(dev, &local_filter);
1138 if (ret < 0) 1139 if (ret < 0)
1139 goto unlock; 1140 goto unlock;
1140 }
1141 1141
1142 /* Success, commit the new filter */ 1142 /* Success, commit the new filter */
1143 *filter = local_filter; 1143 *filter = local_filter;
@@ -1189,27 +1189,45 @@ static RC_FILTER_ATTR(wakeup_filter, S_IRUGO|S_IWUSR,
1189static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR, 1189static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR,
1190 show_filter, store_filter, RC_FILTER_WAKEUP, true); 1190 show_filter, store_filter, RC_FILTER_WAKEUP, true);
1191 1191
1192static struct attribute *rc_dev_attrs[] = { 1192static struct attribute *rc_dev_protocol_attrs[] = {
1193 &dev_attr_protocols.attr.attr, 1193 &dev_attr_protocols.attr.attr,
1194 NULL,
1195};
1196
1197static struct attribute_group rc_dev_protocol_attr_grp = {
1198 .attrs = rc_dev_protocol_attrs,
1199};
1200
1201static struct attribute *rc_dev_wakeup_protocol_attrs[] = {
1194 &dev_attr_wakeup_protocols.attr.attr, 1202 &dev_attr_wakeup_protocols.attr.attr,
1203 NULL,
1204};
1205
1206static struct attribute_group rc_dev_wakeup_protocol_attr_grp = {
1207 .attrs = rc_dev_wakeup_protocol_attrs,
1208};
1209
1210static struct attribute *rc_dev_filter_attrs[] = {
1195 &dev_attr_filter.attr.attr, 1211 &dev_attr_filter.attr.attr,
1196 &dev_attr_filter_mask.attr.attr, 1212 &dev_attr_filter_mask.attr.attr,
1197 &dev_attr_wakeup_filter.attr.attr,
1198 &dev_attr_wakeup_filter_mask.attr.attr,
1199 NULL, 1213 NULL,
1200}; 1214};
1201 1215
1202static struct attribute_group rc_dev_attr_grp = { 1216static struct attribute_group rc_dev_filter_attr_grp = {
1203 .attrs = rc_dev_attrs, 1217 .attrs = rc_dev_filter_attrs,
1204}; 1218};
1205 1219
1206static const struct attribute_group *rc_dev_attr_groups[] = { 1220static struct attribute *rc_dev_wakeup_filter_attrs[] = {
1207 &rc_dev_attr_grp, 1221 &dev_attr_wakeup_filter.attr.attr,
1208 NULL 1222 &dev_attr_wakeup_filter_mask.attr.attr,
1223 NULL,
1224};
1225
1226static struct attribute_group rc_dev_wakeup_filter_attr_grp = {
1227 .attrs = rc_dev_wakeup_filter_attrs,
1209}; 1228};
1210 1229
1211static struct device_type rc_dev_type = { 1230static struct device_type rc_dev_type = {
1212 .groups = rc_dev_attr_groups,
1213 .release = rc_dev_release, 1231 .release = rc_dev_release,
1214 .uevent = rc_dev_uevent, 1232 .uevent = rc_dev_uevent,
1215}; 1233};
@@ -1266,7 +1284,7 @@ int rc_register_device(struct rc_dev *dev)
1266 static bool raw_init = false; /* raw decoders loaded? */ 1284 static bool raw_init = false; /* raw decoders loaded? */
1267 struct rc_map *rc_map; 1285 struct rc_map *rc_map;
1268 const char *path; 1286 const char *path;
1269 int rc, devno; 1287 int rc, devno, attr = 0;
1270 1288
1271 if (!dev || !dev->map_name) 1289 if (!dev || !dev->map_name)
1272 return -EINVAL; 1290 return -EINVAL;
@@ -1294,6 +1312,16 @@ int rc_register_device(struct rc_dev *dev)
1294 return -ENOMEM; 1312 return -ENOMEM;
1295 } while (test_and_set_bit(devno, ir_core_dev_number)); 1313 } while (test_and_set_bit(devno, ir_core_dev_number));
1296 1314
1315 dev->dev.groups = dev->sysfs_groups;
1316 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp;
1317 if (dev->s_filter)
1318 dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp;
1319 if (dev->s_wakeup_filter)
1320 dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp;
1321 if (dev->change_wakeup_protocol)
1322 dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp;
1323 dev->sysfs_groups[attr++] = NULL;
1324
1297 /* 1325 /*
1298 * Take the lock here, as the device sysfs node will appear 1326 * Take the lock here, as the device sysfs node will appear
1299 * when device_add() is called, which may trigger an ir-keytable udev 1327 * when device_add() is called, which may trigger an ir-keytable udev
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 319adc4f0561..96ccfebce7ca 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1468,7 +1468,8 @@ static int r820t_imr_prepare(struct r820t_priv *priv)
1468static int r820t_multi_read(struct r820t_priv *priv) 1468static int r820t_multi_read(struct r820t_priv *priv)
1469{ 1469{
1470 int rc, i; 1470 int rc, i;
1471 u8 data[2], min = 0, max = 255, sum = 0; 1471 u16 sum = 0;
1472 u8 data[2], min = 255, max = 0;
1472 1473
1473 usleep_range(5000, 6000); 1474 usleep_range(5000, 6000);
1474 1475
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index 76a816511f2f..6ef93ee1fdcb 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -1107,6 +1107,7 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
1107 offset += 200000; 1107 offset += 200000;
1108 } 1108 }
1109#endif 1109#endif
1110 break;
1110 default: 1111 default:
1111 tuner_err("Unsupported tuner type %d.\n", new_type); 1112 tuner_err("Unsupported tuner type %d.\n", new_type);
1112 break; 1113 break;
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c83c16cece01..61d196e8b3ab 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1503,8 +1503,6 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1503 /* RTL2832P devices: */ 1503 /* RTL2832P devices: */
1504 { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131, 1504 { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131,
1505 &rtl2832u_props, "Astrometa DVB-T2", NULL) }, 1505 &rtl2832u_props, "Astrometa DVB-T2", NULL) },
1506 { DVB_USB_DEVICE(USB_VID_KYE, 0x707f,
1507 &rtl2832u_props, "Genius TVGo DVB-T03", NULL) },
1508 { } 1506 { }
1509}; 1507};
1510MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); 1508MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
diff --git a/drivers/media/usb/gspca/jpeg.h b/drivers/media/usb/gspca/jpeg.h
index ab54910418b4..0aa2b671faa4 100644
--- a/drivers/media/usb/gspca/jpeg.h
+++ b/drivers/media/usb/gspca/jpeg.h
@@ -154,7 +154,9 @@ static void jpeg_set_qual(u8 *jpeg_hdr,
154{ 154{
155 int i, sc; 155 int i, sc;
156 156
157 if (quality < 50) 157 if (quality <= 0)
158 sc = 5000;
159 else if (quality < 50)
158 sc = 5000 / quality; 160 sc = 5000 / quality;
159 else 161 else
160 sc = 200 - quality * 2; 162 sc = 200 - quality * 2;
diff --git a/drivers/media/usb/stk1160/stk1160-ac97.c b/drivers/media/usb/stk1160/stk1160-ac97.c
index c46c8be89602..2dd308f9541f 100644
--- a/drivers/media/usb/stk1160/stk1160-ac97.c
+++ b/drivers/media/usb/stk1160/stk1160-ac97.c
@@ -108,7 +108,7 @@ int stk1160_ac97_register(struct stk1160 *dev)
108 "stk1160-mixer"); 108 "stk1160-mixer");
109 snprintf(card->longname, sizeof(card->longname), 109 snprintf(card->longname, sizeof(card->longname),
110 "stk1160 ac97 codec mixer control"); 110 "stk1160 ac97 codec mixer control");
111 strncpy(card->driver, dev->dev->driver->name, sizeof(card->driver)); 111 strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver));
112 112
113 rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus); 113 rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus);
114 if (rc) 114 if (rc)
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 1d15735f9ef9..c9de3d598ea5 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -338,58 +338,28 @@ int rtsx_pci_transfer_data(struct rtsx_pcr *pcr, struct scatterlist *sglist,
338 int num_sg, bool read, int timeout) 338 int num_sg, bool read, int timeout)
339{ 339{
340 struct completion trans_done; 340 struct completion trans_done;
341 u8 dir; 341 int err = 0, count;
342 int err = 0, i, count;
343 long timeleft; 342 long timeleft;
344 unsigned long flags; 343 unsigned long flags;
345 struct scatterlist *sg;
346 enum dma_data_direction dma_dir;
347 u32 val;
348 dma_addr_t addr;
349 unsigned int len;
350
351 dev_dbg(&(pcr->pci->dev), "--> %s: num_sg = %d\n", __func__, num_sg);
352
353 /* don't transfer data during abort processing */
354 if (pcr->remove_pci)
355 return -EINVAL;
356
357 if ((sglist == NULL) || (num_sg <= 0))
358 return -EINVAL;
359 344
360 if (read) { 345 count = rtsx_pci_dma_map_sg(pcr, sglist, num_sg, read);
361 dir = DEVICE_TO_HOST;
362 dma_dir = DMA_FROM_DEVICE;
363 } else {
364 dir = HOST_TO_DEVICE;
365 dma_dir = DMA_TO_DEVICE;
366 }
367
368 count = dma_map_sg(&(pcr->pci->dev), sglist, num_sg, dma_dir);
369 if (count < 1) { 346 if (count < 1) {
370 dev_err(&(pcr->pci->dev), "scatterlist map failed\n"); 347 dev_err(&(pcr->pci->dev), "scatterlist map failed\n");
371 return -EINVAL; 348 return -EINVAL;
372 } 349 }
373 dev_dbg(&(pcr->pci->dev), "DMA mapping count: %d\n", count); 350 dev_dbg(&(pcr->pci->dev), "DMA mapping count: %d\n", count);
374 351
375 val = ((u32)(dir & 0x01) << 29) | TRIG_DMA | ADMA_MODE;
376 pcr->sgi = 0;
377 for_each_sg(sglist, sg, count, i) {
378 addr = sg_dma_address(sg);
379 len = sg_dma_len(sg);
380 rtsx_pci_add_sg_tbl(pcr, addr, len, i == count - 1);
381 }
382 352
383 spin_lock_irqsave(&pcr->lock, flags); 353 spin_lock_irqsave(&pcr->lock, flags);
384 354
385 pcr->done = &trans_done; 355 pcr->done = &trans_done;
386 pcr->trans_result = TRANS_NOT_READY; 356 pcr->trans_result = TRANS_NOT_READY;
387 init_completion(&trans_done); 357 init_completion(&trans_done);
388 rtsx_pci_writel(pcr, RTSX_HDBAR, pcr->host_sg_tbl_addr);
389 rtsx_pci_writel(pcr, RTSX_HDBCTLR, val);
390 358
391 spin_unlock_irqrestore(&pcr->lock, flags); 359 spin_unlock_irqrestore(&pcr->lock, flags);
392 360
361 rtsx_pci_dma_transfer(pcr, sglist, count, read);
362
393 timeleft = wait_for_completion_interruptible_timeout( 363 timeleft = wait_for_completion_interruptible_timeout(
394 &trans_done, msecs_to_jiffies(timeout)); 364 &trans_done, msecs_to_jiffies(timeout));
395 if (timeleft <= 0) { 365 if (timeleft <= 0) {
@@ -413,7 +383,7 @@ out:
413 pcr->done = NULL; 383 pcr->done = NULL;
414 spin_unlock_irqrestore(&pcr->lock, flags); 384 spin_unlock_irqrestore(&pcr->lock, flags);
415 385
416 dma_unmap_sg(&(pcr->pci->dev), sglist, num_sg, dma_dir); 386 rtsx_pci_dma_unmap_sg(pcr, sglist, num_sg, read);
417 387
418 if ((err < 0) && (err != -ENODEV)) 388 if ((err < 0) && (err != -ENODEV))
419 rtsx_pci_stop_cmd(pcr); 389 rtsx_pci_stop_cmd(pcr);
@@ -425,6 +395,73 @@ out:
425} 395}
426EXPORT_SYMBOL_GPL(rtsx_pci_transfer_data); 396EXPORT_SYMBOL_GPL(rtsx_pci_transfer_data);
427 397
398int rtsx_pci_dma_map_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
399 int num_sg, bool read)
400{
401 enum dma_data_direction dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
402
403 if (pcr->remove_pci)
404 return -EINVAL;
405
406 if ((sglist == NULL) || num_sg < 1)
407 return -EINVAL;
408
409 return dma_map_sg(&(pcr->pci->dev), sglist, num_sg, dir);
410}
411EXPORT_SYMBOL_GPL(rtsx_pci_dma_map_sg);
412
413int rtsx_pci_dma_unmap_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
414 int num_sg, bool read)
415{
416 enum dma_data_direction dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
417
418 if (pcr->remove_pci)
419 return -EINVAL;
420
421 if (sglist == NULL || num_sg < 1)
422 return -EINVAL;
423
424 dma_unmap_sg(&(pcr->pci->dev), sglist, num_sg, dir);
425 return num_sg;
426}
427EXPORT_SYMBOL_GPL(rtsx_pci_dma_unmap_sg);
428
429int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
430 int sg_count, bool read)
431{
432 struct scatterlist *sg;
433 dma_addr_t addr;
434 unsigned int len;
435 int i;
436 u32 val;
437 u8 dir = read ? DEVICE_TO_HOST : HOST_TO_DEVICE;
438 unsigned long flags;
439
440 if (pcr->remove_pci)
441 return -EINVAL;
442
443 if ((sglist == NULL) || (sg_count < 1))
444 return -EINVAL;
445
446 val = ((u32)(dir & 0x01) << 29) | TRIG_DMA | ADMA_MODE;
447 pcr->sgi = 0;
448 for_each_sg(sglist, sg, sg_count, i) {
449 addr = sg_dma_address(sg);
450 len = sg_dma_len(sg);
451 rtsx_pci_add_sg_tbl(pcr, addr, len, i == sg_count - 1);
452 }
453
454 spin_lock_irqsave(&pcr->lock, flags);
455
456 rtsx_pci_writel(pcr, RTSX_HDBAR, pcr->host_sg_tbl_addr);
457 rtsx_pci_writel(pcr, RTSX_HDBCTLR, val);
458
459 spin_unlock_irqrestore(&pcr->lock, flags);
460
461 return 0;
462}
463EXPORT_SYMBOL_GPL(rtsx_pci_dma_transfer);
464
428int rtsx_pci_read_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len) 465int rtsx_pci_read_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len)
429{ 466{
430 int err; 467 int err;
@@ -836,6 +873,8 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
836 int_reg = rtsx_pci_readl(pcr, RTSX_BIPR); 873 int_reg = rtsx_pci_readl(pcr, RTSX_BIPR);
837 /* Clear interrupt flag */ 874 /* Clear interrupt flag */
838 rtsx_pci_writel(pcr, RTSX_BIPR, int_reg); 875 rtsx_pci_writel(pcr, RTSX_BIPR, int_reg);
876 dev_dbg(&pcr->pci->dev, "=========== BIPR 0x%8x ==========\n", int_reg);
877
839 if ((int_reg & pcr->bier) == 0) { 878 if ((int_reg & pcr->bier) == 0) {
840 spin_unlock(&pcr->lock); 879 spin_unlock(&pcr->lock);
841 return IRQ_NONE; 880 return IRQ_NONE;
@@ -866,17 +905,28 @@ static irqreturn_t rtsx_pci_isr(int irq, void *dev_id)
866 } 905 }
867 906
868 if (int_reg & (NEED_COMPLETE_INT | DELINK_INT)) { 907 if (int_reg & (NEED_COMPLETE_INT | DELINK_INT)) {
869 if (int_reg & (TRANS_FAIL_INT | DELINK_INT)) { 908 if (int_reg & (TRANS_FAIL_INT | DELINK_INT))
870 pcr->trans_result = TRANS_RESULT_FAIL; 909 pcr->trans_result = TRANS_RESULT_FAIL;
871 if (pcr->done) 910 else if (int_reg & TRANS_OK_INT)
872 complete(pcr->done);
873 } else if (int_reg & TRANS_OK_INT) {
874 pcr->trans_result = TRANS_RESULT_OK; 911 pcr->trans_result = TRANS_RESULT_OK;
875 if (pcr->done) 912
876 complete(pcr->done); 913 if (pcr->done)
914 complete(pcr->done);
915
916 if (int_reg & SD_EXIST) {
917 struct rtsx_slot *slot = &pcr->slots[RTSX_SD_CARD];
918 if (slot && slot->done_transfer)
919 slot->done_transfer(slot->p_dev);
920 }
921
922 if (int_reg & MS_EXIST) {
923 struct rtsx_slot *slot = &pcr->slots[RTSX_SD_CARD];
924 if (slot && slot->done_transfer)
925 slot->done_transfer(slot->p_dev);
877 } 926 }
878 } 927 }
879 928
929
880 if (pcr->card_inserted || pcr->card_removed) 930 if (pcr->card_inserted || pcr->card_removed)
881 schedule_delayed_work(&pcr->carddet_work, 931 schedule_delayed_work(&pcr->carddet_work,
882 msecs_to_jiffies(200)); 932 msecs_to_jiffies(200));
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 7b5424f398ac..452782bffebc 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -415,8 +415,7 @@ static int ioctl_do_sanitize(struct mmc_card *card)
415{ 415{
416 int err; 416 int err;
417 417
418 if (!(mmc_can_sanitize(card) && 418 if (!mmc_can_sanitize(card)) {
419 (card->host->caps2 & MMC_CAP2_SANITIZE))) {
420 pr_warn("%s: %s - SANITIZE is not supported\n", 419 pr_warn("%s: %s - SANITIZE is not supported\n",
421 mmc_hostname(card->host), __func__); 420 mmc_hostname(card->host), __func__);
422 err = -EOPNOTSUPP; 421 err = -EOPNOTSUPP;
@@ -722,19 +721,6 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
722 return result; 721 return result;
723} 722}
724 723
725static int send_stop(struct mmc_card *card, u32 *status)
726{
727 struct mmc_command cmd = {0};
728 int err;
729
730 cmd.opcode = MMC_STOP_TRANSMISSION;
731 cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
732 err = mmc_wait_for_cmd(card->host, &cmd, 5);
733 if (err == 0)
734 *status = cmd.resp[0];
735 return err;
736}
737
738static int get_card_status(struct mmc_card *card, u32 *status, int retries) 724static int get_card_status(struct mmc_card *card, u32 *status, int retries)
739{ 725{
740 struct mmc_command cmd = {0}; 726 struct mmc_command cmd = {0};
@@ -750,6 +736,99 @@ static int get_card_status(struct mmc_card *card, u32 *status, int retries)
750 return err; 736 return err;
751} 737}
752 738
739static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
740 bool hw_busy_detect, struct request *req, int *gen_err)
741{
742 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
743 int err = 0;
744 u32 status;
745
746 do {
747 err = get_card_status(card, &status, 5);
748 if (err) {
749 pr_err("%s: error %d requesting status\n",
750 req->rq_disk->disk_name, err);
751 return err;
752 }
753
754 if (status & R1_ERROR) {
755 pr_err("%s: %s: error sending status cmd, status %#x\n",
756 req->rq_disk->disk_name, __func__, status);
757 *gen_err = 1;
758 }
759
760 /* We may rely on the host hw to handle busy detection.*/
761 if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) &&
762 hw_busy_detect)
763 break;
764
765 /*
766 * Timeout if the device never becomes ready for data and never
767 * leaves the program state.
768 */
769 if (time_after(jiffies, timeout)) {
770 pr_err("%s: Card stuck in programming state! %s %s\n",
771 mmc_hostname(card->host),
772 req->rq_disk->disk_name, __func__);
773 return -ETIMEDOUT;
774 }
775
776 /*
777 * Some cards mishandle the status bits,
778 * so make sure to check both the busy
779 * indication and the card state.
780 */
781 } while (!(status & R1_READY_FOR_DATA) ||
782 (R1_CURRENT_STATE(status) == R1_STATE_PRG));
783
784 return err;
785}
786
787static int send_stop(struct mmc_card *card, unsigned int timeout_ms,
788 struct request *req, int *gen_err, u32 *stop_status)
789{
790 struct mmc_host *host = card->host;
791 struct mmc_command cmd = {0};
792 int err;
793 bool use_r1b_resp = rq_data_dir(req) == WRITE;
794
795 /*
796 * Normally we use R1B responses for WRITE, but in cases where the host
797 * has specified a max_busy_timeout we need to validate it. A failure
798 * means we need to prevent the host from doing hw busy detection, which
799 * is done by converting to a R1 response instead.
800 */
801 if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout))
802 use_r1b_resp = false;
803
804 cmd.opcode = MMC_STOP_TRANSMISSION;
805 if (use_r1b_resp) {
806 cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
807 cmd.busy_timeout = timeout_ms;
808 } else {
809 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
810 }
811
812 err = mmc_wait_for_cmd(host, &cmd, 5);
813 if (err)
814 return err;
815
816 *stop_status = cmd.resp[0];
817
818 /* No need to check card status in case of READ. */
819 if (rq_data_dir(req) == READ)
820 return 0;
821
822 if (!mmc_host_is_spi(host) &&
823 (*stop_status & R1_ERROR)) {
824 pr_err("%s: %s: general error sending stop command, resp %#x\n",
825 req->rq_disk->disk_name, __func__, *stop_status);
826 *gen_err = 1;
827 }
828
829 return card_busy_detect(card, timeout_ms, use_r1b_resp, req, gen_err);
830}
831
753#define ERR_NOMEDIUM 3 832#define ERR_NOMEDIUM 3
754#define ERR_RETRY 2 833#define ERR_RETRY 2
755#define ERR_ABORT 1 834#define ERR_ABORT 1
@@ -866,26 +945,21 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,
866 */ 945 */
867 if (R1_CURRENT_STATE(status) == R1_STATE_DATA || 946 if (R1_CURRENT_STATE(status) == R1_STATE_DATA ||
868 R1_CURRENT_STATE(status) == R1_STATE_RCV) { 947 R1_CURRENT_STATE(status) == R1_STATE_RCV) {
869 err = send_stop(card, &stop_status); 948 err = send_stop(card,
870 if (err) 949 DIV_ROUND_UP(brq->data.timeout_ns, 1000000),
950 req, gen_err, &stop_status);
951 if (err) {
871 pr_err("%s: error %d sending stop command\n", 952 pr_err("%s: error %d sending stop command\n",
872 req->rq_disk->disk_name, err); 953 req->rq_disk->disk_name, err);
873 954 /*
874 /* 955 * If the stop cmd also timed out, the card is probably
875 * If the stop cmd also timed out, the card is probably 956 * not present, so abort. Other errors are bad news too.
876 * not present, so abort. Other errors are bad news too. 957 */
877 */
878 if (err)
879 return ERR_ABORT; 958 return ERR_ABORT;
959 }
960
880 if (stop_status & R1_CARD_ECC_FAILED) 961 if (stop_status & R1_CARD_ECC_FAILED)
881 *ecc_err = 1; 962 *ecc_err = 1;
882 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ)
883 if (stop_status & R1_ERROR) {
884 pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n",
885 req->rq_disk->disk_name, __func__,
886 stop_status);
887 *gen_err = 1;
888 }
889 } 963 }
890 964
891 /* Check for set block count errors */ 965 /* Check for set block count errors */
@@ -1157,8 +1231,7 @@ static int mmc_blk_err_check(struct mmc_card *card,
1157 * program mode, which we have to wait for it to complete. 1231 * program mode, which we have to wait for it to complete.
1158 */ 1232 */
1159 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { 1233 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
1160 u32 status; 1234 int err;
1161 unsigned long timeout;
1162 1235
1163 /* Check stop command response */ 1236 /* Check stop command response */
1164 if (brq->stop.resp[0] & R1_ERROR) { 1237 if (brq->stop.resp[0] & R1_ERROR) {
@@ -1168,39 +1241,10 @@ static int mmc_blk_err_check(struct mmc_card *card,
1168 gen_err = 1; 1241 gen_err = 1;
1169 } 1242 }
1170 1243
1171 timeout = jiffies + msecs_to_jiffies(MMC_BLK_TIMEOUT_MS); 1244 err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, false, req,
1172 do { 1245 &gen_err);
1173 int err = get_card_status(card, &status, 5); 1246 if (err)
1174 if (err) { 1247 return MMC_BLK_CMD_ERR;
1175 pr_err("%s: error %d requesting status\n",
1176 req->rq_disk->disk_name, err);
1177 return MMC_BLK_CMD_ERR;
1178 }
1179
1180 if (status & R1_ERROR) {
1181 pr_err("%s: %s: general error sending status command, card status %#x\n",
1182 req->rq_disk->disk_name, __func__,
1183 status);
1184 gen_err = 1;
1185 }
1186
1187 /* Timeout if the device never becomes ready for data
1188 * and never leaves the program state.
1189 */
1190 if (time_after(jiffies, timeout)) {
1191 pr_err("%s: Card stuck in programming state!"\
1192 " %s %s\n", mmc_hostname(card->host),
1193 req->rq_disk->disk_name, __func__);
1194
1195 return MMC_BLK_CMD_ERR;
1196 }
1197 /*
1198 * Some cards mishandle the status bits,
1199 * so make sure to check both the busy
1200 * indication and the card state.
1201 */
1202 } while (!(status & R1_READY_FOR_DATA) ||
1203 (R1_CURRENT_STATE(status) == R1_STATE_PRG));
1204 } 1248 }
1205 1249
1206 /* if general error occurs, retry the write operation. */ 1250 /* if general error occurs, retry the write operation. */
@@ -1335,7 +1379,6 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
1335 brq->data.blksz = 512; 1379 brq->data.blksz = 512;
1336 brq->stop.opcode = MMC_STOP_TRANSMISSION; 1380 brq->stop.opcode = MMC_STOP_TRANSMISSION;
1337 brq->stop.arg = 0; 1381 brq->stop.arg = 0;
1338 brq->stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
1339 brq->data.blocks = blk_rq_sectors(req); 1382 brq->data.blocks = blk_rq_sectors(req);
1340 1383
1341 /* 1384 /*
@@ -1378,9 +1421,15 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
1378 if (rq_data_dir(req) == READ) { 1421 if (rq_data_dir(req) == READ) {
1379 brq->cmd.opcode = readcmd; 1422 brq->cmd.opcode = readcmd;
1380 brq->data.flags |= MMC_DATA_READ; 1423 brq->data.flags |= MMC_DATA_READ;
1424 if (brq->mrq.stop)
1425 brq->stop.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 |
1426 MMC_CMD_AC;
1381 } else { 1427 } else {
1382 brq->cmd.opcode = writecmd; 1428 brq->cmd.opcode = writecmd;
1383 brq->data.flags |= MMC_DATA_WRITE; 1429 brq->data.flags |= MMC_DATA_WRITE;
1430 if (brq->mrq.stop)
1431 brq->stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B |
1432 MMC_CMD_AC;
1384 } 1433 }
1385 1434
1386 if (do_rel_wr) 1435 if (do_rel_wr)
diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig
index 269d072ef55e..9ebee72d9c3f 100644
--- a/drivers/mmc/core/Kconfig
+++ b/drivers/mmc/core/Kconfig
@@ -2,21 +2,6 @@
2# MMC core configuration 2# MMC core configuration
3# 3#
4 4
5config MMC_UNSAFE_RESUME
6 bool "Assume MMC/SD cards are non-removable (DANGEROUS)"
7 help
8 If you say Y here, the MMC layer will assume that all cards
9 stayed in their respective slots during the suspend. The
10 normal behaviour is to remove them at suspend and
11 redetecting them at resume. Breaking this assumption will
12 in most cases result in data corruption.
13
14 This option is usually just for embedded systems which use
15 a MMC/SD card for rootfs. Most people should say N here.
16
17 This option sets a default which can be overridden by the
18 module parameter "removable=0" or "removable=1".
19
20config MMC_CLKGATE 5config MMC_CLKGATE
21 bool "MMC host clock gating" 6 bool "MMC host clock gating"
22 help 7 help
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 64145a32b917..824644875d41 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -185,24 +185,16 @@ static int mmc_runtime_suspend(struct device *dev)
185{ 185{
186 struct mmc_card *card = mmc_dev_to_card(dev); 186 struct mmc_card *card = mmc_dev_to_card(dev);
187 struct mmc_host *host = card->host; 187 struct mmc_host *host = card->host;
188 int ret = 0;
189 188
190 if (host->bus_ops->runtime_suspend) 189 return host->bus_ops->runtime_suspend(host);
191 ret = host->bus_ops->runtime_suspend(host);
192
193 return ret;
194} 190}
195 191
196static int mmc_runtime_resume(struct device *dev) 192static int mmc_runtime_resume(struct device *dev)
197{ 193{
198 struct mmc_card *card = mmc_dev_to_card(dev); 194 struct mmc_card *card = mmc_dev_to_card(dev);
199 struct mmc_host *host = card->host; 195 struct mmc_host *host = card->host;
200 int ret = 0;
201 196
202 if (host->bus_ops->runtime_resume) 197 return host->bus_ops->runtime_resume(host);
203 ret = host->bus_ops->runtime_resume(host);
204
205 return ret;
206} 198}
207 199
208static int mmc_runtime_idle(struct device *dev) 200static int mmc_runtime_idle(struct device *dev)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 098374b1ab2b..acbc3f2aaaf9 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -34,6 +34,7 @@
34#include <linux/mmc/host.h> 34#include <linux/mmc/host.h>
35#include <linux/mmc/mmc.h> 35#include <linux/mmc/mmc.h>
36#include <linux/mmc/sd.h> 36#include <linux/mmc/sd.h>
37#include <linux/mmc/slot-gpio.h>
37 38
38#include "core.h" 39#include "core.h"
39#include "bus.h" 40#include "bus.h"
@@ -65,23 +66,6 @@ bool use_spi_crc = 1;
65module_param(use_spi_crc, bool, 0); 66module_param(use_spi_crc, bool, 0);
66 67
67/* 68/*
68 * We normally treat cards as removed during suspend if they are not
69 * known to be on a non-removable bus, to avoid the risk of writing
70 * back data to a different card after resume. Allow this to be
71 * overridden if necessary.
72 */
73#ifdef CONFIG_MMC_UNSAFE_RESUME
74bool mmc_assume_removable;
75#else
76bool mmc_assume_removable = 1;
77#endif
78EXPORT_SYMBOL(mmc_assume_removable);
79module_param_named(removable, mmc_assume_removable, bool, 0644);
80MODULE_PARM_DESC(
81 removable,
82 "MMC/SD cards are removable and may be removed during suspend");
83
84/*
85 * Internal function. Schedule delayed work in the MMC work queue. 69 * Internal function. Schedule delayed work in the MMC work queue.
86 */ 70 */
87static int mmc_schedule_delayed_work(struct delayed_work *work, 71static int mmc_schedule_delayed_work(struct delayed_work *work,
@@ -302,7 +286,8 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
302 } 286 }
303 287
304 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 288 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
305 EXT_CSD_BKOPS_START, 1, timeout, use_busy_signal, true); 289 EXT_CSD_BKOPS_START, 1, timeout,
290 use_busy_signal, true, false);
306 if (err) { 291 if (err) {
307 pr_warn("%s: Error %d starting bkops\n", 292 pr_warn("%s: Error %d starting bkops\n",
308 mmc_hostname(card->host), err); 293 mmc_hostname(card->host), err);
@@ -1950,7 +1935,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
1950 cmd.opcode = MMC_ERASE; 1935 cmd.opcode = MMC_ERASE;
1951 cmd.arg = arg; 1936 cmd.arg = arg;
1952 cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; 1937 cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
1953 cmd.cmd_timeout_ms = mmc_erase_timeout(card, arg, qty); 1938 cmd.busy_timeout = mmc_erase_timeout(card, arg, qty);
1954 err = mmc_wait_for_cmd(card->host, &cmd, 0); 1939 err = mmc_wait_for_cmd(card->host, &cmd, 0);
1955 if (err) { 1940 if (err) {
1956 pr_err("mmc_erase: erase error %d, status %#x\n", 1941 pr_err("mmc_erase: erase error %d, status %#x\n",
@@ -2137,7 +2122,7 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
2137 y = 0; 2122 y = 0;
2138 for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) { 2123 for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) {
2139 timeout = mmc_erase_timeout(card, arg, qty + x); 2124 timeout = mmc_erase_timeout(card, arg, qty + x);
2140 if (timeout > host->max_discard_to) 2125 if (timeout > host->max_busy_timeout)
2141 break; 2126 break;
2142 if (timeout < last_timeout) 2127 if (timeout < last_timeout)
2143 break; 2128 break;
@@ -2169,7 +2154,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
2169 struct mmc_host *host = card->host; 2154 struct mmc_host *host = card->host;
2170 unsigned int max_discard, max_trim; 2155 unsigned int max_discard, max_trim;
2171 2156
2172 if (!host->max_discard_to) 2157 if (!host->max_busy_timeout)
2173 return UINT_MAX; 2158 return UINT_MAX;
2174 2159
2175 /* 2160 /*
@@ -2189,7 +2174,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
2189 max_discard = 0; 2174 max_discard = 0;
2190 } 2175 }
2191 pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n", 2176 pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n",
2192 mmc_hostname(host), max_discard, host->max_discard_to); 2177 mmc_hostname(host), max_discard, host->max_busy_timeout);
2193 return max_discard; 2178 return max_discard;
2194} 2179}
2195EXPORT_SYMBOL(mmc_calc_max_discard); 2180EXPORT_SYMBOL(mmc_calc_max_discard);
@@ -2248,9 +2233,6 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check)
2248{ 2233{
2249 struct mmc_card *card = host->card; 2234 struct mmc_card *card = host->card;
2250 2235
2251 if (!host->bus_ops->power_restore)
2252 return -EOPNOTSUPP;
2253
2254 if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) 2236 if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
2255 return -EOPNOTSUPP; 2237 return -EOPNOTSUPP;
2256 2238
@@ -2352,7 +2334,7 @@ int _mmc_detect_card_removed(struct mmc_host *host)
2352{ 2334{
2353 int ret; 2335 int ret;
2354 2336
2355 if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive) 2337 if (host->caps & MMC_CAP_NONREMOVABLE)
2356 return 0; 2338 return 0;
2357 2339
2358 if (!host->card || mmc_card_removed(host->card)) 2340 if (!host->card || mmc_card_removed(host->card))
@@ -2435,7 +2417,7 @@ void mmc_rescan(struct work_struct *work)
2435 * if there is a _removable_ card registered, check whether it is 2417 * if there is a _removable_ card registered, check whether it is
2436 * still present 2418 * still present
2437 */ 2419 */
2438 if (host->bus_ops && host->bus_ops->detect && !host->bus_dead 2420 if (host->bus_ops && !host->bus_dead
2439 && !(host->caps & MMC_CAP_NONREMOVABLE)) 2421 && !(host->caps & MMC_CAP_NONREMOVABLE))
2440 host->bus_ops->detect(host); 2422 host->bus_ops->detect(host);
2441 2423
@@ -2490,6 +2472,7 @@ void mmc_start_host(struct mmc_host *host)
2490 mmc_power_off(host); 2472 mmc_power_off(host);
2491 else 2473 else
2492 mmc_power_up(host, host->ocr_avail); 2474 mmc_power_up(host, host->ocr_avail);
2475 mmc_gpiod_request_cd_irq(host);
2493 _mmc_detect_change(host, 0, false); 2476 _mmc_detect_change(host, 0, false);
2494} 2477}
2495 2478
@@ -2501,6 +2484,8 @@ void mmc_stop_host(struct mmc_host *host)
2501 host->removed = 1; 2484 host->removed = 1;
2502 spin_unlock_irqrestore(&host->lock, flags); 2485 spin_unlock_irqrestore(&host->lock, flags);
2503#endif 2486#endif
2487 if (host->slot.cd_irq >= 0)
2488 disable_irq(host->slot.cd_irq);
2504 2489
2505 host->rescan_disable = 1; 2490 host->rescan_disable = 1;
2506 cancel_delayed_work_sync(&host->detect); 2491 cancel_delayed_work_sync(&host->detect);
@@ -2537,7 +2522,7 @@ int mmc_power_save_host(struct mmc_host *host)
2537 2522
2538 mmc_bus_get(host); 2523 mmc_bus_get(host);
2539 2524
2540 if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) { 2525 if (!host->bus_ops || host->bus_dead) {
2541 mmc_bus_put(host); 2526 mmc_bus_put(host);
2542 return -EINVAL; 2527 return -EINVAL;
2543 } 2528 }
@@ -2563,7 +2548,7 @@ int mmc_power_restore_host(struct mmc_host *host)
2563 2548
2564 mmc_bus_get(host); 2549 mmc_bus_get(host);
2565 2550
2566 if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) { 2551 if (!host->bus_ops || host->bus_dead) {
2567 mmc_bus_put(host); 2552 mmc_bus_put(host);
2568 return -EINVAL; 2553 return -EINVAL;
2569 } 2554 }
@@ -2582,12 +2567,8 @@ EXPORT_SYMBOL(mmc_power_restore_host);
2582 */ 2567 */
2583int mmc_flush_cache(struct mmc_card *card) 2568int mmc_flush_cache(struct mmc_card *card)
2584{ 2569{
2585 struct mmc_host *host = card->host;
2586 int err = 0; 2570 int err = 0;
2587 2571
2588 if (!(host->caps2 & MMC_CAP2_CACHE_CTRL))
2589 return err;
2590
2591 if (mmc_card_mmc(card) && 2572 if (mmc_card_mmc(card) &&
2592 (card->ext_csd.cache_size > 0) && 2573 (card->ext_csd.cache_size > 0) &&
2593 (card->ext_csd.cache_ctrl & 1)) { 2574 (card->ext_csd.cache_ctrl & 1)) {
@@ -2602,44 +2583,6 @@ int mmc_flush_cache(struct mmc_card *card)
2602} 2583}
2603EXPORT_SYMBOL(mmc_flush_cache); 2584EXPORT_SYMBOL(mmc_flush_cache);
2604 2585
2605/*
2606 * Turn the cache ON/OFF.
2607 * Turning the cache OFF shall trigger flushing of the data
2608 * to the non-volatile storage.
2609 * This function should be called with host claimed
2610 */
2611int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
2612{
2613 struct mmc_card *card = host->card;
2614 unsigned int timeout;
2615 int err = 0;
2616
2617 if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
2618 mmc_card_is_removable(host))
2619 return err;
2620
2621 if (card && mmc_card_mmc(card) &&
2622 (card->ext_csd.cache_size > 0)) {
2623 enable = !!enable;
2624
2625 if (card->ext_csd.cache_ctrl ^ enable) {
2626 timeout = enable ? card->ext_csd.generic_cmd6_time : 0;
2627 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
2628 EXT_CSD_CACHE_CTRL, enable, timeout);
2629 if (err)
2630 pr_err("%s: cache %s error %d\n",
2631 mmc_hostname(card->host),
2632 enable ? "on" : "off",
2633 err);
2634 else
2635 card->ext_csd.cache_ctrl = enable;
2636 }
2637 }
2638
2639 return err;
2640}
2641EXPORT_SYMBOL(mmc_cache_ctrl);
2642
2643#ifdef CONFIG_PM 2586#ifdef CONFIG_PM
2644 2587
2645/* Do the card removal on suspend if card is assumed removeable 2588/* Do the card removal on suspend if card is assumed removeable
@@ -2668,7 +2611,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
2668 /* Validate prerequisites for suspend */ 2611 /* Validate prerequisites for suspend */
2669 if (host->bus_ops->pre_suspend) 2612 if (host->bus_ops->pre_suspend)
2670 err = host->bus_ops->pre_suspend(host); 2613 err = host->bus_ops->pre_suspend(host);
2671 if (!err && host->bus_ops->suspend) 2614 if (!err)
2672 break; 2615 break;
2673 2616
2674 /* Calling bus_ops->remove() with a claimed host can deadlock */ 2617 /* Calling bus_ops->remove() with a claimed host can deadlock */
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 114f6bdfbef3..fdea825dbb24 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -419,6 +419,16 @@ int mmc_of_parse(struct mmc_host *host)
419 host->caps |= MMC_CAP_SD_HIGHSPEED; 419 host->caps |= MMC_CAP_SD_HIGHSPEED;
420 if (of_find_property(np, "cap-mmc-highspeed", &len)) 420 if (of_find_property(np, "cap-mmc-highspeed", &len))
421 host->caps |= MMC_CAP_MMC_HIGHSPEED; 421 host->caps |= MMC_CAP_MMC_HIGHSPEED;
422 if (of_find_property(np, "sd-uhs-sdr12", &len))
423 host->caps |= MMC_CAP_UHS_SDR12;
424 if (of_find_property(np, "sd-uhs-sdr25", &len))
425 host->caps |= MMC_CAP_UHS_SDR25;
426 if (of_find_property(np, "sd-uhs-sdr50", &len))
427 host->caps |= MMC_CAP_UHS_SDR50;
428 if (of_find_property(np, "sd-uhs-sdr104", &len))
429 host->caps |= MMC_CAP_UHS_SDR104;
430 if (of_find_property(np, "sd-uhs-ddr50", &len))
431 host->caps |= MMC_CAP_UHS_DDR50;
422 if (of_find_property(np, "cap-power-off-card", &len)) 432 if (of_find_property(np, "cap-power-off-card", &len))
423 host->caps |= MMC_CAP_POWER_OFF_CARD; 433 host->caps |= MMC_CAP_POWER_OFF_CARD;
424 if (of_find_property(np, "cap-sdio-irq", &len)) 434 if (of_find_property(np, "cap-sdio-irq", &len))
@@ -429,6 +439,14 @@ int mmc_of_parse(struct mmc_host *host)
429 host->pm_caps |= MMC_PM_KEEP_POWER; 439 host->pm_caps |= MMC_PM_KEEP_POWER;
430 if (of_find_property(np, "enable-sdio-wakeup", &len)) 440 if (of_find_property(np, "enable-sdio-wakeup", &len))
431 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; 441 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
442 if (of_find_property(np, "mmc-ddr-1_8v", &len))
443 host->caps |= MMC_CAP_1_8V_DDR;
444 if (of_find_property(np, "mmc-ddr-1_2v", &len))
445 host->caps |= MMC_CAP_1_2V_DDR;
446 if (of_find_property(np, "mmc-hs200-1_8v", &len))
447 host->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
448 if (of_find_property(np, "mmc-hs200-1_2v", &len))
449 host->caps2 |= MMC_CAP2_HS200_1_2V_SDR;
432 450
433 return 0; 451 return 0;
434 452
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 98e9eb0f6643..1ab5f3a0af5b 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -856,8 +856,10 @@ static int mmc_select_hs200(struct mmc_card *card)
856 856
857 /* switch to HS200 mode if bus width set successfully */ 857 /* switch to HS200 mode if bus width set successfully */
858 if (!err) 858 if (!err)
859 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 859 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
860 EXT_CSD_HS_TIMING, 2, 0); 860 EXT_CSD_HS_TIMING, 2,
861 card->ext_csd.generic_cmd6_time,
862 true, true, true);
861err: 863err:
862 return err; 864 return err;
863} 865}
@@ -1074,9 +1076,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1074 host->caps2 & MMC_CAP2_HS200) 1076 host->caps2 & MMC_CAP2_HS200)
1075 err = mmc_select_hs200(card); 1077 err = mmc_select_hs200(card);
1076 else if (host->caps & MMC_CAP_MMC_HIGHSPEED) 1078 else if (host->caps & MMC_CAP_MMC_HIGHSPEED)
1077 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1079 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1078 EXT_CSD_HS_TIMING, 1, 1080 EXT_CSD_HS_TIMING, 1,
1079 card->ext_csd.generic_cmd6_time); 1081 card->ext_csd.generic_cmd6_time,
1082 true, true, true);
1080 1083
1081 if (err && err != -EBADMSG) 1084 if (err && err != -EBADMSG)
1082 goto free_card; 1085 goto free_card;
@@ -1287,8 +1290,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1287 * If cache size is higher than 0, this indicates 1290 * If cache size is higher than 0, this indicates
1288 * the existence of cache and it can be turned on. 1291 * the existence of cache and it can be turned on.
1289 */ 1292 */
1290 if ((host->caps2 & MMC_CAP2_CACHE_CTRL) && 1293 if (card->ext_csd.cache_size > 0) {
1291 card->ext_csd.cache_size > 0) {
1292 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1294 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1293 EXT_CSD_CACHE_CTRL, 1, 1295 EXT_CSD_CACHE_CTRL, 1,
1294 card->ext_csd.generic_cmd6_time); 1296 card->ext_csd.generic_cmd6_time);
@@ -1356,11 +1358,9 @@ static int mmc_sleep(struct mmc_host *host)
1356{ 1358{
1357 struct mmc_command cmd = {0}; 1359 struct mmc_command cmd = {0};
1358 struct mmc_card *card = host->card; 1360 struct mmc_card *card = host->card;
1361 unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000);
1359 int err; 1362 int err;
1360 1363
1361 if (host->caps2 & MMC_CAP2_NO_SLEEP_CMD)
1362 return 0;
1363
1364 err = mmc_deselect_cards(host); 1364 err = mmc_deselect_cards(host);
1365 if (err) 1365 if (err)
1366 return err; 1366 return err;
@@ -1369,7 +1369,19 @@ static int mmc_sleep(struct mmc_host *host)
1369 cmd.arg = card->rca << 16; 1369 cmd.arg = card->rca << 16;
1370 cmd.arg |= 1 << 15; 1370 cmd.arg |= 1 << 15;
1371 1371
1372 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; 1372 /*
1373 * If the max_busy_timeout of the host is specified, validate it against
1374 * the sleep cmd timeout. A failure means we need to prevent the host
1375 * from doing hw busy detection, which is done by converting to a R1
1376 * response instead of a R1B.
1377 */
1378 if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) {
1379 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
1380 } else {
1381 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1382 cmd.busy_timeout = timeout_ms;
1383 }
1384
1373 err = mmc_wait_for_cmd(host, &cmd, 0); 1385 err = mmc_wait_for_cmd(host, &cmd, 0);
1374 if (err) 1386 if (err)
1375 return err; 1387 return err;
@@ -1380,8 +1392,8 @@ static int mmc_sleep(struct mmc_host *host)
1380 * SEND_STATUS command to poll the status because that command (and most 1392 * SEND_STATUS command to poll the status because that command (and most
1381 * others) is invalid while the card sleeps. 1393 * others) is invalid while the card sleeps.
1382 */ 1394 */
1383 if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) 1395 if (!cmd.busy_timeout || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
1384 mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000)); 1396 mmc_delay(timeout_ms);
1385 1397
1386 return err; 1398 return err;
1387} 1399}
@@ -1404,7 +1416,7 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type)
1404 1416
1405 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1417 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1406 EXT_CSD_POWER_OFF_NOTIFICATION, 1418 EXT_CSD_POWER_OFF_NOTIFICATION,
1407 notify_type, timeout, true, false); 1419 notify_type, timeout, true, false, false);
1408 if (err) 1420 if (err)
1409 pr_err("%s: Power Off Notification timed out, %u\n", 1421 pr_err("%s: Power Off Notification timed out, %u\n",
1410 mmc_hostname(card->host), timeout); 1422 mmc_hostname(card->host), timeout);
@@ -1484,7 +1496,7 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
1484 goto out; 1496 goto out;
1485 } 1497 }
1486 1498
1487 err = mmc_cache_ctrl(host, 0); 1499 err = mmc_flush_cache(host->card);
1488 if (err) 1500 if (err)
1489 goto out; 1501 goto out;
1490 1502
@@ -1636,16 +1648,6 @@ static int mmc_power_restore(struct mmc_host *host)
1636static const struct mmc_bus_ops mmc_ops = { 1648static const struct mmc_bus_ops mmc_ops = {
1637 .remove = mmc_remove, 1649 .remove = mmc_remove,
1638 .detect = mmc_detect, 1650 .detect = mmc_detect,
1639 .suspend = NULL,
1640 .resume = NULL,
1641 .power_restore = mmc_power_restore,
1642 .alive = mmc_alive,
1643 .shutdown = mmc_shutdown,
1644};
1645
1646static const struct mmc_bus_ops mmc_ops_unsafe = {
1647 .remove = mmc_remove,
1648 .detect = mmc_detect,
1649 .suspend = mmc_suspend, 1651 .suspend = mmc_suspend,
1650 .resume = mmc_resume, 1652 .resume = mmc_resume,
1651 .runtime_suspend = mmc_runtime_suspend, 1653 .runtime_suspend = mmc_runtime_suspend,
@@ -1655,17 +1657,6 @@ static const struct mmc_bus_ops mmc_ops_unsafe = {
1655 .shutdown = mmc_shutdown, 1657 .shutdown = mmc_shutdown,
1656}; 1658};
1657 1659
1658static void mmc_attach_bus_ops(struct mmc_host *host)
1659{
1660 const struct mmc_bus_ops *bus_ops;
1661
1662 if (!mmc_card_is_removable(host))
1663 bus_ops = &mmc_ops_unsafe;
1664 else
1665 bus_ops = &mmc_ops;
1666 mmc_attach_bus(host, bus_ops);
1667}
1668
1669/* 1660/*
1670 * Starting point for MMC card init. 1661 * Starting point for MMC card init.
1671 */ 1662 */
@@ -1685,7 +1676,7 @@ int mmc_attach_mmc(struct mmc_host *host)
1685 if (err) 1676 if (err)
1686 return err; 1677 return err;
1687 1678
1688 mmc_attach_bus_ops(host); 1679 mmc_attach_bus(host, &mmc_ops);
1689 if (host->ocr_avail_mmc) 1680 if (host->ocr_avail_mmc)
1690 host->ocr_avail = host->ocr_avail_mmc; 1681 host->ocr_avail = host->ocr_avail_mmc;
1691 1682
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index e5b5eeb548d1..f51b5ba3bbea 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -405,20 +405,30 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
405 * timeout of zero implies maximum possible timeout 405 * timeout of zero implies maximum possible timeout
406 * @use_busy_signal: use the busy signal as response type 406 * @use_busy_signal: use the busy signal as response type
407 * @send_status: send status cmd to poll for busy 407 * @send_status: send status cmd to poll for busy
408 * @ignore_crc: ignore CRC errors when sending status cmd to poll for busy
408 * 409 *
409 * Modifies the EXT_CSD register for selected card. 410 * Modifies the EXT_CSD register for selected card.
410 */ 411 */
411int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, 412int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
412 unsigned int timeout_ms, bool use_busy_signal, bool send_status) 413 unsigned int timeout_ms, bool use_busy_signal, bool send_status,
414 bool ignore_crc)
413{ 415{
416 struct mmc_host *host = card->host;
414 int err; 417 int err;
415 struct mmc_command cmd = {0}; 418 struct mmc_command cmd = {0};
416 unsigned long timeout; 419 unsigned long timeout;
417 u32 status = 0; 420 u32 status = 0;
418 bool ignore_crc = false; 421 bool use_r1b_resp = use_busy_signal;
419 422
420 BUG_ON(!card); 423 /*
421 BUG_ON(!card->host); 424 * If the cmd timeout and the max_busy_timeout of the host are both
425 * specified, let's validate them. A failure means we need to prevent
426 * the host from doing hw busy detection, which is done by converting
427 * to a R1 response instead of a R1B.
428 */
429 if (timeout_ms && host->max_busy_timeout &&
430 (timeout_ms > host->max_busy_timeout))
431 use_r1b_resp = false;
422 432
423 cmd.opcode = MMC_SWITCH; 433 cmd.opcode = MMC_SWITCH;
424 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | 434 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
@@ -426,17 +436,21 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
426 (value << 8) | 436 (value << 8) |
427 set; 437 set;
428 cmd.flags = MMC_CMD_AC; 438 cmd.flags = MMC_CMD_AC;
429 if (use_busy_signal) 439 if (use_r1b_resp) {
430 cmd.flags |= MMC_RSP_SPI_R1B | MMC_RSP_R1B; 440 cmd.flags |= MMC_RSP_SPI_R1B | MMC_RSP_R1B;
431 else 441 /*
442 * A busy_timeout of zero means the host can decide to use
443 * whatever value it finds suitable.
444 */
445 cmd.busy_timeout = timeout_ms;
446 } else {
432 cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1; 447 cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;
448 }
433 449
434
435 cmd.cmd_timeout_ms = timeout_ms;
436 if (index == EXT_CSD_SANITIZE_START) 450 if (index == EXT_CSD_SANITIZE_START)
437 cmd.sanitize_busy = true; 451 cmd.sanitize_busy = true;
438 452
439 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); 453 err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
440 if (err) 454 if (err)
441 return err; 455 return err;
442 456
@@ -445,24 +459,27 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
445 return 0; 459 return 0;
446 460
447 /* 461 /*
448 * Must check status to be sure of no errors 462 * CRC errors shall only be ignored in cases were CMD13 is used to poll
449 * If CMD13 is to check the busy completion of the timing change, 463 * to detect busy completion.
450 * disable the check of CRC error.
451 */ 464 */
452 if (index == EXT_CSD_HS_TIMING && 465 if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
453 !(card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)) 466 ignore_crc = false;
454 ignore_crc = true; 467
468 /* We have an unspecified cmd timeout, use the fallback value. */
469 if (!timeout_ms)
470 timeout_ms = MMC_OPS_TIMEOUT_MS;
455 471
456 timeout = jiffies + msecs_to_jiffies(MMC_OPS_TIMEOUT_MS); 472 /* Must check status to be sure of no errors. */
473 timeout = jiffies + msecs_to_jiffies(timeout_ms);
457 do { 474 do {
458 if (send_status) { 475 if (send_status) {
459 err = __mmc_send_status(card, &status, ignore_crc); 476 err = __mmc_send_status(card, &status, ignore_crc);
460 if (err) 477 if (err)
461 return err; 478 return err;
462 } 479 }
463 if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) 480 if ((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
464 break; 481 break;
465 if (mmc_host_is_spi(card->host)) 482 if (mmc_host_is_spi(host))
466 break; 483 break;
467 484
468 /* 485 /*
@@ -478,18 +495,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
478 /* Timeout if the device never leaves the program state. */ 495 /* Timeout if the device never leaves the program state. */
479 if (time_after(jiffies, timeout)) { 496 if (time_after(jiffies, timeout)) {
480 pr_err("%s: Card stuck in programming state! %s\n", 497 pr_err("%s: Card stuck in programming state! %s\n",
481 mmc_hostname(card->host), __func__); 498 mmc_hostname(host), __func__);
482 return -ETIMEDOUT; 499 return -ETIMEDOUT;
483 } 500 }
484 } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); 501 } while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
485 502
486 if (mmc_host_is_spi(card->host)) { 503 if (mmc_host_is_spi(host)) {
487 if (status & R1_SPI_ILLEGAL_COMMAND) 504 if (status & R1_SPI_ILLEGAL_COMMAND)
488 return -EBADMSG; 505 return -EBADMSG;
489 } else { 506 } else {
490 if (status & 0xFDFFA000) 507 if (status & 0xFDFFA000)
491 pr_warning("%s: unexpected status %#x after " 508 pr_warn("%s: unexpected status %#x after switch\n",
492 "switch", mmc_hostname(card->host), status); 509 mmc_hostname(host), status);
493 if (status & R1_SWITCH_ERROR) 510 if (status & R1_SWITCH_ERROR)
494 return -EBADMSG; 511 return -EBADMSG;
495 } 512 }
@@ -501,7 +518,8 @@ EXPORT_SYMBOL_GPL(__mmc_switch);
501int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, 518int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
502 unsigned int timeout_ms) 519 unsigned int timeout_ms)
503{ 520{
504 return __mmc_switch(card, set, index, value, timeout_ms, true, true); 521 return __mmc_switch(card, set, index, value, timeout_ms, true, true,
522 false);
505} 523}
506EXPORT_SYMBOL_GPL(mmc_switch); 524EXPORT_SYMBOL_GPL(mmc_switch);
507 525
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 692fdb177294..2dd359d2242f 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1209,16 +1209,6 @@ static int mmc_sd_power_restore(struct mmc_host *host)
1209static const struct mmc_bus_ops mmc_sd_ops = { 1209static const struct mmc_bus_ops mmc_sd_ops = {
1210 .remove = mmc_sd_remove, 1210 .remove = mmc_sd_remove,
1211 .detect = mmc_sd_detect, 1211 .detect = mmc_sd_detect,
1212 .suspend = NULL,
1213 .resume = NULL,
1214 .power_restore = mmc_sd_power_restore,
1215 .alive = mmc_sd_alive,
1216 .shutdown = mmc_sd_suspend,
1217};
1218
1219static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
1220 .remove = mmc_sd_remove,
1221 .detect = mmc_sd_detect,
1222 .runtime_suspend = mmc_sd_runtime_suspend, 1212 .runtime_suspend = mmc_sd_runtime_suspend,
1223 .runtime_resume = mmc_sd_runtime_resume, 1213 .runtime_resume = mmc_sd_runtime_resume,
1224 .suspend = mmc_sd_suspend, 1214 .suspend = mmc_sd_suspend,
@@ -1228,17 +1218,6 @@ static const struct mmc_bus_ops mmc_sd_ops_unsafe = {
1228 .shutdown = mmc_sd_suspend, 1218 .shutdown = mmc_sd_suspend,
1229}; 1219};
1230 1220
1231static void mmc_sd_attach_bus_ops(struct mmc_host *host)
1232{
1233 const struct mmc_bus_ops *bus_ops;
1234
1235 if (!mmc_card_is_removable(host))
1236 bus_ops = &mmc_sd_ops_unsafe;
1237 else
1238 bus_ops = &mmc_sd_ops;
1239 mmc_attach_bus(host, bus_ops);
1240}
1241
1242/* 1221/*
1243 * Starting point for SD card init. 1222 * Starting point for SD card init.
1244 */ 1223 */
@@ -1254,7 +1233,7 @@ int mmc_attach_sd(struct mmc_host *host)
1254 if (err) 1233 if (err)
1255 return err; 1234 return err;
1256 1235
1257 mmc_sd_attach_bus_ops(host); 1236 mmc_attach_bus(host, &mmc_sd_ops);
1258 if (host->ocr_avail_sd) 1237 if (host->ocr_avail_sd)
1259 host->ocr_avail = host->ocr_avail_sd; 1238 host->ocr_avail = host->ocr_avail_sd;
1260 1239
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 46596b71a32f..f7650b899e3d 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/err.h> 11#include <linux/err.h>
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/gpio/consumer.h>
13#include <linux/interrupt.h> 14#include <linux/interrupt.h>
14#include <linux/jiffies.h> 15#include <linux/jiffies.h>
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
@@ -18,8 +19,10 @@
18#include <linux/slab.h> 19#include <linux/slab.h>
19 20
20struct mmc_gpio { 21struct mmc_gpio {
21 int ro_gpio; 22 struct gpio_desc *ro_gpio;
22 int cd_gpio; 23 struct gpio_desc *cd_gpio;
24 bool override_ro_active_level;
25 bool override_cd_active_level;
23 char *ro_label; 26 char *ro_label;
24 char cd_label[0]; 27 char cd_label[0];
25}; 28};
@@ -57,8 +60,6 @@ static int mmc_gpio_alloc(struct mmc_host *host)
57 ctx->ro_label = ctx->cd_label + len; 60 ctx->ro_label = ctx->cd_label + len;
58 snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent)); 61 snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent));
59 snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent)); 62 snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent));
60 ctx->cd_gpio = -EINVAL;
61 ctx->ro_gpio = -EINVAL;
62 host->slot.handler_priv = ctx; 63 host->slot.handler_priv = ctx;
63 } 64 }
64 } 65 }
@@ -72,11 +73,14 @@ int mmc_gpio_get_ro(struct mmc_host *host)
72{ 73{
73 struct mmc_gpio *ctx = host->slot.handler_priv; 74 struct mmc_gpio *ctx = host->slot.handler_priv;
74 75
75 if (!ctx || !gpio_is_valid(ctx->ro_gpio)) 76 if (!ctx || !ctx->ro_gpio)
76 return -ENOSYS; 77 return -ENOSYS;
77 78
78 return !gpio_get_value_cansleep(ctx->ro_gpio) ^ 79 if (ctx->override_ro_active_level)
79 !!(host->caps2 & MMC_CAP2_RO_ACTIVE_HIGH); 80 return !gpiod_get_raw_value_cansleep(ctx->ro_gpio) ^
81 !!(host->caps2 & MMC_CAP2_RO_ACTIVE_HIGH);
82
83 return gpiod_get_value_cansleep(ctx->ro_gpio);
80} 84}
81EXPORT_SYMBOL(mmc_gpio_get_ro); 85EXPORT_SYMBOL(mmc_gpio_get_ro);
82 86
@@ -84,11 +88,14 @@ int mmc_gpio_get_cd(struct mmc_host *host)
84{ 88{
85 struct mmc_gpio *ctx = host->slot.handler_priv; 89 struct mmc_gpio *ctx = host->slot.handler_priv;
86 90
87 if (!ctx || !gpio_is_valid(ctx->cd_gpio)) 91 if (!ctx || !ctx->cd_gpio)
88 return -ENOSYS; 92 return -ENOSYS;
89 93
90 return !gpio_get_value_cansleep(ctx->cd_gpio) ^ 94 if (ctx->override_cd_active_level)
91 !!(host->caps2 & MMC_CAP2_CD_ACTIVE_HIGH); 95 return !gpiod_get_raw_value_cansleep(ctx->cd_gpio) ^
96 !!(host->caps2 & MMC_CAP2_CD_ACTIVE_HIGH);
97
98 return gpiod_get_value_cansleep(ctx->cd_gpio);
92} 99}
93EXPORT_SYMBOL(mmc_gpio_get_cd); 100EXPORT_SYMBOL(mmc_gpio_get_cd);
94 101
@@ -125,12 +132,47 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
125 if (ret < 0) 132 if (ret < 0)
126 return ret; 133 return ret;
127 134
128 ctx->ro_gpio = gpio; 135 ctx->override_ro_active_level = true;
136 ctx->ro_gpio = gpio_to_desc(gpio);
129 137
130 return 0; 138 return 0;
131} 139}
132EXPORT_SYMBOL(mmc_gpio_request_ro); 140EXPORT_SYMBOL(mmc_gpio_request_ro);
133 141
142void mmc_gpiod_request_cd_irq(struct mmc_host *host)
143{
144 struct mmc_gpio *ctx = host->slot.handler_priv;
145 int ret, irq;
146
147 if (host->slot.cd_irq >= 0 || !ctx || !ctx->cd_gpio)
148 return;
149
150 irq = gpiod_to_irq(ctx->cd_gpio);
151
152 /*
153 * Even if gpiod_to_irq() returns a valid IRQ number, the platform might
154 * still prefer to poll, e.g., because that IRQ number is already used
155 * by another unit and cannot be shared.
156 */
157 if (irq >= 0 && host->caps & MMC_CAP_NEEDS_POLL)
158 irq = -EINVAL;
159
160 if (irq >= 0) {
161 ret = devm_request_threaded_irq(&host->class_dev, irq,
162 NULL, mmc_gpio_cd_irqt,
163 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
164 ctx->cd_label, host);
165 if (ret < 0)
166 irq = ret;
167 }
168
169 host->slot.cd_irq = irq;
170
171 if (irq < 0)
172 host->caps |= MMC_CAP_NEEDS_POLL;
173}
174EXPORT_SYMBOL(mmc_gpiod_request_cd_irq);
175
134/** 176/**
135 * mmc_gpio_request_cd - request a gpio for card-detection 177 * mmc_gpio_request_cd - request a gpio for card-detection
136 * @host: mmc host 178 * @host: mmc host
@@ -154,7 +196,6 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
154 unsigned int debounce) 196 unsigned int debounce)
155{ 197{
156 struct mmc_gpio *ctx; 198 struct mmc_gpio *ctx;
157 int irq = gpio_to_irq(gpio);
158 int ret; 199 int ret;
159 200
160 ret = mmc_gpio_alloc(host); 201 ret = mmc_gpio_alloc(host);
@@ -179,29 +220,10 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
179 return ret; 220 return ret;
180 } 221 }
181 222
182 /* 223 ctx->override_cd_active_level = true;
183 * Even if gpio_to_irq() returns a valid IRQ number, the platform might 224 ctx->cd_gpio = gpio_to_desc(gpio);
184 * still prefer to poll, e.g., because that IRQ number is already used
185 * by another unit and cannot be shared.
186 */
187 if (irq >= 0 && host->caps & MMC_CAP_NEEDS_POLL)
188 irq = -EINVAL;
189
190 if (irq >= 0) {
191 ret = devm_request_threaded_irq(&host->class_dev, irq,
192 NULL, mmc_gpio_cd_irqt,
193 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
194 ctx->cd_label, host);
195 if (ret < 0)
196 irq = ret;
197 }
198
199 host->slot.cd_irq = irq;
200
201 if (irq < 0)
202 host->caps |= MMC_CAP_NEEDS_POLL;
203 225
204 ctx->cd_gpio = gpio; 226 mmc_gpiod_request_cd_irq(host);
205 227
206 return 0; 228 return 0;
207} 229}
@@ -219,11 +241,11 @@ void mmc_gpio_free_ro(struct mmc_host *host)
219 struct mmc_gpio *ctx = host->slot.handler_priv; 241 struct mmc_gpio *ctx = host->slot.handler_priv;
220 int gpio; 242 int gpio;
221 243
222 if (!ctx || !gpio_is_valid(ctx->ro_gpio)) 244 if (!ctx || !ctx->ro_gpio)
223 return; 245 return;
224 246
225 gpio = ctx->ro_gpio; 247 gpio = desc_to_gpio(ctx->ro_gpio);
226 ctx->ro_gpio = -EINVAL; 248 ctx->ro_gpio = NULL;
227 249
228 devm_gpio_free(&host->class_dev, gpio); 250 devm_gpio_free(&host->class_dev, gpio);
229} 251}
@@ -241,7 +263,7 @@ void mmc_gpio_free_cd(struct mmc_host *host)
241 struct mmc_gpio *ctx = host->slot.handler_priv; 263 struct mmc_gpio *ctx = host->slot.handler_priv;
242 int gpio; 264 int gpio;
243 265
244 if (!ctx || !gpio_is_valid(ctx->cd_gpio)) 266 if (!ctx || !ctx->cd_gpio)
245 return; 267 return;
246 268
247 if (host->slot.cd_irq >= 0) { 269 if (host->slot.cd_irq >= 0) {
@@ -249,9 +271,87 @@ void mmc_gpio_free_cd(struct mmc_host *host)
249 host->slot.cd_irq = -EINVAL; 271 host->slot.cd_irq = -EINVAL;
250 } 272 }
251 273
252 gpio = ctx->cd_gpio; 274 gpio = desc_to_gpio(ctx->cd_gpio);
253 ctx->cd_gpio = -EINVAL; 275 ctx->cd_gpio = NULL;
254 276
255 devm_gpio_free(&host->class_dev, gpio); 277 devm_gpio_free(&host->class_dev, gpio);
256} 278}
257EXPORT_SYMBOL(mmc_gpio_free_cd); 279EXPORT_SYMBOL(mmc_gpio_free_cd);
280
281/**
282 * mmc_gpiod_request_cd - request a gpio descriptor for card-detection
283 * @host: mmc host
284 * @con_id: function within the GPIO consumer
285 * @idx: index of the GPIO to obtain in the consumer
286 * @override_active_level: ignore %GPIO_ACTIVE_LOW flag
287 * @debounce: debounce time in microseconds
288 *
289 * Use this function in place of mmc_gpio_request_cd() to use the GPIO
290 * descriptor API. Note that it is paired with mmc_gpiod_free_cd() not
291 * mmc_gpio_free_cd(). Note also that it must be called prior to mmc_add_host()
292 * otherwise the caller must also call mmc_gpiod_request_cd_irq().
293 *
294 * Returns zero on success, else an error.
295 */
296int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
297 unsigned int idx, bool override_active_level,
298 unsigned int debounce)
299{
300 struct mmc_gpio *ctx;
301 struct gpio_desc *desc;
302 int ret;
303
304 ret = mmc_gpio_alloc(host);
305 if (ret < 0)
306 return ret;
307
308 ctx = host->slot.handler_priv;
309
310 if (!con_id)
311 con_id = ctx->cd_label;
312
313 desc = devm_gpiod_get_index(host->parent, con_id, idx);
314 if (IS_ERR(desc))
315 return PTR_ERR(desc);
316
317 ret = gpiod_direction_input(desc);
318 if (ret < 0)
319 return ret;
320
321 if (debounce) {
322 ret = gpiod_set_debounce(desc, debounce);
323 if (ret < 0)
324 return ret;
325 }
326
327 ctx->override_cd_active_level = override_active_level;
328 ctx->cd_gpio = desc;
329
330 return 0;
331}
332EXPORT_SYMBOL(mmc_gpiod_request_cd);
333
334/**
335 * mmc_gpiod_free_cd - free the card-detection gpio descriptor
336 * @host: mmc host
337 *
338 * It's provided only for cases that client drivers need to manually free
339 * up the card-detection gpio requested by mmc_gpiod_request_cd().
340 */
341void mmc_gpiod_free_cd(struct mmc_host *host)
342{
343 struct mmc_gpio *ctx = host->slot.handler_priv;
344
345 if (!ctx || !ctx->cd_gpio)
346 return;
347
348 if (host->slot.cd_irq >= 0) {
349 devm_free_irq(&host->class_dev, host->slot.cd_irq, host);
350 host->slot.cd_irq = -EINVAL;
351 }
352
353 devm_gpiod_put(&host->class_dev, ctx->cd_gpio);
354
355 ctx->cd_gpio = NULL;
356}
357EXPORT_SYMBOL(mmc_gpiod_free_cd);
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1384f67abe21..8aaf8c1f3f63 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -263,7 +263,7 @@ config MMC_SDHCI_S3C_DMA
263 263
264config MMC_SDHCI_BCM_KONA 264config MMC_SDHCI_BCM_KONA
265 tristate "SDHCI support on Broadcom KONA platform" 265 tristate "SDHCI support on Broadcom KONA platform"
266 depends on ARCH_BCM 266 depends on ARCH_BCM_MOBILE
267 select MMC_SDHCI_PLTFM 267 select MMC_SDHCI_PLTFM
268 help 268 help
269 This selects the Broadcom Kona Secure Digital Host Controller 269 This selects the Broadcom Kona Secure Digital Host Controller
@@ -334,6 +334,19 @@ config MMC_ATMELMCI
334 334
335 If unsure, say N. 335 If unsure, say N.
336 336
337config MMC_SDHCI_MSM
338 tristate "Qualcomm SDHCI Controller Support"
339 depends on ARCH_QCOM
340 depends on MMC_SDHCI_PLTFM
341 help
342 This selects the Secure Digital Host Controller Interface (SDHCI)
343 support present in Qualcomm SOCs. The controller supports
344 SD/MMC/SDIO devices.
345
346 If you have a controller with this interface, say Y or M here.
347
348 If unsure, say N.
349
337config MMC_MSM 350config MMC_MSM
338 tristate "Qualcomm SDCC Controller Support" 351 tristate "Qualcomm SDCC Controller Support"
339 depends on MMC && (ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50) 352 depends on MMC && (ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50)
@@ -580,14 +593,6 @@ config MMC_DW_EXYNOS
580 Synopsys DesignWare Memory Card Interface driver. Select this option 593 Synopsys DesignWare Memory Card Interface driver. Select this option
581 for platforms based on Exynos4 and Exynos5 SoC's. 594 for platforms based on Exynos4 and Exynos5 SoC's.
582 595
583config MMC_DW_SOCFPGA
584 tristate "SOCFPGA specific extensions for Synopsys DW Memory Card Interface"
585 depends on MMC_DW && MFD_SYSCON
586 select MMC_DW_PLTFM
587 help
588 This selects support for Altera SoCFPGA specific extensions to the
589 Synopsys DesignWare Memory Card Interface driver.
590
591config MMC_DW_K3 596config MMC_DW_K3
592 tristate "K3 specific extensions for Synopsys DW Memory Card Interface" 597 tristate "K3 specific extensions for Synopsys DW Memory Card Interface"
593 depends on MMC_DW 598 depends on MMC_DW
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 3483b6b6b880..0c8aa5e1e304 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -43,7 +43,6 @@ obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o
43obj-$(CONFIG_MMC_DW) += dw_mmc.o 43obj-$(CONFIG_MMC_DW) += dw_mmc.o
44obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o 44obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o
45obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o 45obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o
46obj-$(CONFIG_MMC_DW_SOCFPGA) += dw_mmc-socfpga.o
47obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o 46obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o
48obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o 47obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o
49obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o 48obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o
@@ -64,6 +63,7 @@ obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o
64obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o 63obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o
65obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o 64obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o
66obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o 65obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o
66obj-$(CONFIG_MMC_SDHCI_MSM) += sdhci-msm.o
67 67
68ifeq ($(CONFIG_CB710_DEBUG),y) 68ifeq ($(CONFIG_CB710_DEBUG),y)
69 CFLAGS-cb710-mmc += -DDEBUG 69 CFLAGS-cb710-mmc += -DDEBUG
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index d6153740b77f..5d4c5e0fba2f 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -1192,7 +1192,7 @@ static struct davinci_mmc_config
1192 struct device_node *np; 1192 struct device_node *np;
1193 struct davinci_mmc_config *pdata = pdev->dev.platform_data; 1193 struct davinci_mmc_config *pdata = pdev->dev.platform_data;
1194 const struct of_device_id *match = 1194 const struct of_device_id *match =
1195 of_match_device(of_match_ptr(davinci_mmc_dt_ids), &pdev->dev); 1195 of_match_device(davinci_mmc_dt_ids, &pdev->dev);
1196 u32 data; 1196 u32 data;
1197 1197
1198 np = pdev->dev.of_node; 1198 np = pdev->dev.of_node;
@@ -1468,7 +1468,7 @@ static struct platform_driver davinci_mmcsd_driver = {
1468 .name = "davinci_mmc", 1468 .name = "davinci_mmc",
1469 .owner = THIS_MODULE, 1469 .owner = THIS_MODULE,
1470 .pm = davinci_mmcsd_pm_ops, 1470 .pm = davinci_mmcsd_pm_ops,
1471 .of_match_table = of_match_ptr(davinci_mmc_dt_ids), 1471 .of_match_table = davinci_mmc_dt_ids,
1472 }, 1472 },
1473 .remove = __exit_p(davinci_mmcsd_remove), 1473 .remove = __exit_p(davinci_mmcsd_remove),
1474 .id_table = davinci_mmc_devtype, 1474 .id_table = davinci_mmc_devtype,
diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index f567c219cff4..650f9cc3f7a6 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -50,6 +50,7 @@ static int dw_mci_k3_probe(struct platform_device *pdev)
50 return dw_mci_pltfm_register(pdev, drv_data); 50 return dw_mci_pltfm_register(pdev, drv_data);
51} 51}
52 52
53#ifdef CONFIG_PM_SLEEP
53static int dw_mci_k3_suspend(struct device *dev) 54static int dw_mci_k3_suspend(struct device *dev)
54{ 55{
55 struct dw_mci *host = dev_get_drvdata(dev); 56 struct dw_mci *host = dev_get_drvdata(dev);
@@ -75,6 +76,7 @@ static int dw_mci_k3_resume(struct device *dev)
75 76
76 return dw_mci_resume(host); 77 return dw_mci_resume(host);
77} 78}
79#endif /* CONFIG_PM_SLEEP */
78 80
79static SIMPLE_DEV_PM_OPS(dw_mci_k3_pmops, dw_mci_k3_suspend, dw_mci_k3_resume); 81static SIMPLE_DEV_PM_OPS(dw_mci_k3_pmops, dw_mci_k3_suspend, dw_mci_k3_resume);
80 82
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
index 5c4965655297..d4a47a9f5584 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.c
+++ b/drivers/mmc/host/dw_mmc-pltfm.c
@@ -25,13 +25,17 @@
25#include "dw_mmc.h" 25#include "dw_mmc.h"
26#include "dw_mmc-pltfm.h" 26#include "dw_mmc-pltfm.h"
27 27
28static void dw_mci_rockchip_prepare_command(struct dw_mci *host, u32 *cmdr) 28static void dw_mci_pltfm_prepare_command(struct dw_mci *host, u32 *cmdr)
29{ 29{
30 *cmdr |= SDMMC_CMD_USE_HOLD_REG; 30 *cmdr |= SDMMC_CMD_USE_HOLD_REG;
31} 31}
32 32
33static const struct dw_mci_drv_data rockchip_drv_data = { 33static const struct dw_mci_drv_data rockchip_drv_data = {
34 .prepare_command = dw_mci_rockchip_prepare_command, 34 .prepare_command = dw_mci_pltfm_prepare_command,
35};
36
37static const struct dw_mci_drv_data socfpga_drv_data = {
38 .prepare_command = dw_mci_pltfm_prepare_command,
35}; 39};
36 40
37int dw_mci_pltfm_register(struct platform_device *pdev, 41int dw_mci_pltfm_register(struct platform_device *pdev,
@@ -92,6 +96,8 @@ static const struct of_device_id dw_mci_pltfm_match[] = {
92 { .compatible = "snps,dw-mshc", }, 96 { .compatible = "snps,dw-mshc", },
93 { .compatible = "rockchip,rk2928-dw-mshc", 97 { .compatible = "rockchip,rk2928-dw-mshc",
94 .data = &rockchip_drv_data }, 98 .data = &rockchip_drv_data },
99 { .compatible = "altr,socfpga-dw-mshc",
100 .data = &socfpga_drv_data },
95 {}, 101 {},
96}; 102};
97MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); 103MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match);
@@ -123,7 +129,7 @@ static struct platform_driver dw_mci_pltfm_driver = {
123 .remove = dw_mci_pltfm_remove, 129 .remove = dw_mci_pltfm_remove,
124 .driver = { 130 .driver = {
125 .name = "dw_mmc", 131 .name = "dw_mmc",
126 .of_match_table = of_match_ptr(dw_mci_pltfm_match), 132 .of_match_table = dw_mci_pltfm_match,
127 .pm = &dw_mci_pltfm_pmops, 133 .pm = &dw_mci_pltfm_pmops,
128 }, 134 },
129}; 135};
diff --git a/drivers/mmc/host/dw_mmc-socfpga.c b/drivers/mmc/host/dw_mmc-socfpga.c
deleted file mode 100644
index 3e8e53ae3302..000000000000
--- a/drivers/mmc/host/dw_mmc-socfpga.c
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * Altera SoCFPGA Specific Extensions for Synopsys DW Multimedia Card Interface
3 * driver
4 *
5 * Copyright (C) 2012, Samsung Electronics Co., Ltd.
6 * Copyright (C) 2013 Altera Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Taken from dw_mmc-exynos.c
14 */
15#include <linux/clk.h>
16#include <linux/mfd/syscon.h>
17#include <linux/mmc/host.h>
18#include <linux/mmc/dw_mmc.h>
19#include <linux/module.h>
20#include <linux/of.h>
21#include <linux/platform_device.h>
22#include <linux/regmap.h>
23
24#include "dw_mmc.h"
25#include "dw_mmc-pltfm.h"
26
27#define SYSMGR_SDMMCGRP_CTRL_OFFSET 0x108
28#define DRV_CLK_PHASE_SHIFT_SEL_MASK 0x7
29#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
30 ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
31
32/* SOCFPGA implementation specific driver private data */
33struct dw_mci_socfpga_priv_data {
34 u8 ciu_div; /* card interface unit divisor */
35 u32 hs_timing; /* bitmask for CIU clock phase shift */
36 struct regmap *sysreg; /* regmap for system manager register */
37};
38
39static int dw_mci_socfpga_priv_init(struct dw_mci *host)
40{
41 return 0;
42}
43
44static int dw_mci_socfpga_setup_clock(struct dw_mci *host)
45{
46 struct dw_mci_socfpga_priv_data *priv = host->priv;
47
48 clk_disable_unprepare(host->ciu_clk);
49 regmap_write(priv->sysreg, SYSMGR_SDMMCGRP_CTRL_OFFSET,
50 priv->hs_timing);
51 clk_prepare_enable(host->ciu_clk);
52
53 host->bus_hz /= (priv->ciu_div + 1);
54 return 0;
55}
56
57static void dw_mci_socfpga_prepare_command(struct dw_mci *host, u32 *cmdr)
58{
59 struct dw_mci_socfpga_priv_data *priv = host->priv;
60
61 if (priv->hs_timing & DRV_CLK_PHASE_SHIFT_SEL_MASK)
62 *cmdr |= SDMMC_CMD_USE_HOLD_REG;
63}
64
65static int dw_mci_socfpga_parse_dt(struct dw_mci *host)
66{
67 struct dw_mci_socfpga_priv_data *priv;
68 struct device_node *np = host->dev->of_node;
69 u32 timing[2];
70 u32 div = 0;
71 int ret;
72
73 priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
74 if (!priv) {
75 dev_err(host->dev, "mem alloc failed for private data\n");
76 return -ENOMEM;
77 }
78
79 priv->sysreg = syscon_regmap_lookup_by_compatible("altr,sys-mgr");
80 if (IS_ERR(priv->sysreg)) {
81 dev_err(host->dev, "regmap for altr,sys-mgr lookup failed.\n");
82 return PTR_ERR(priv->sysreg);
83 }
84
85 ret = of_property_read_u32(np, "altr,dw-mshc-ciu-div", &div);
86 if (ret)
87 dev_info(host->dev, "No dw-mshc-ciu-div specified, assuming 1");
88 priv->ciu_div = div;
89
90 ret = of_property_read_u32_array(np,
91 "altr,dw-mshc-sdr-timing", timing, 2);
92 if (ret)
93 return ret;
94
95 priv->hs_timing = SYSMGR_SDMMC_CTRL_SET(timing[0], timing[1]);
96 host->priv = priv;
97 return 0;
98}
99
100static const struct dw_mci_drv_data socfpga_drv_data = {
101 .init = dw_mci_socfpga_priv_init,
102 .setup_clock = dw_mci_socfpga_setup_clock,
103 .prepare_command = dw_mci_socfpga_prepare_command,
104 .parse_dt = dw_mci_socfpga_parse_dt,
105};
106
107static const struct of_device_id dw_mci_socfpga_match[] = {
108 { .compatible = "altr,socfpga-dw-mshc",
109 .data = &socfpga_drv_data, },
110 {},
111};
112MODULE_DEVICE_TABLE(of, dw_mci_socfpga_match);
113
114static int dw_mci_socfpga_probe(struct platform_device *pdev)
115{
116 const struct dw_mci_drv_data *drv_data;
117 const struct of_device_id *match;
118
119 match = of_match_node(dw_mci_socfpga_match, pdev->dev.of_node);
120 drv_data = match->data;
121 return dw_mci_pltfm_register(pdev, drv_data);
122}
123
124static struct platform_driver dw_mci_socfpga_pltfm_driver = {
125 .probe = dw_mci_socfpga_probe,
126 .remove = __exit_p(dw_mci_pltfm_remove),
127 .driver = {
128 .name = "dwmmc_socfpga",
129 .of_match_table = dw_mci_socfpga_match,
130 .pm = &dw_mci_pltfm_pmops,
131 },
132};
133
134module_platform_driver(dw_mci_socfpga_pltfm_driver);
135
136MODULE_DESCRIPTION("Altera SOCFPGA Specific DW-MSHC Driver Extension");
137MODULE_LICENSE("GPL v2");
138MODULE_ALIAS("platform:dwmmc-socfpga");
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index c204b7d1532c..cced599d5aeb 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1345,7 +1345,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
1345 1345
1346 if (!err) { 1346 if (!err) {
1347 if (!data->stop || mrq->sbc) { 1347 if (!data->stop || mrq->sbc) {
1348 if (mrq->sbc) 1348 if (mrq->sbc && data->stop)
1349 data->stop->error = 0; 1349 data->stop->error = 0;
1350 dw_mci_request_end(host, mrq); 1350 dw_mci_request_end(host, mrq);
1351 goto unlock; 1351 goto unlock;
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 6bf24ab917e6..68349779c396 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -185,7 +185,7 @@
185 185
186extern int dw_mci_probe(struct dw_mci *host); 186extern int dw_mci_probe(struct dw_mci *host);
187extern void dw_mci_remove(struct dw_mci *host); 187extern void dw_mci_remove(struct dw_mci *host);
188#ifdef CONFIG_PM 188#ifdef CONFIG_PM_SLEEP
189extern int dw_mci_suspend(struct dw_mci *host); 189extern int dw_mci_suspend(struct dw_mci *host);
190extern int dw_mci_resume(struct dw_mci *host); 190extern int dw_mci_resume(struct dw_mci *host);
191#endif 191#endif
@@ -244,6 +244,7 @@ struct dw_mci_tuning_data {
244 * @prepare_command: handle CMD register extensions. 244 * @prepare_command: handle CMD register extensions.
245 * @set_ios: handle bus specific extensions. 245 * @set_ios: handle bus specific extensions.
246 * @parse_dt: parse implementation specific device tree properties. 246 * @parse_dt: parse implementation specific device tree properties.
247 * @execute_tuning: implementation specific tuning procedure.
247 * 248 *
248 * Provide controller implementation specific extensions. The usage of this 249 * Provide controller implementation specific extensions. The usage of this
249 * data structure is fully optional and usage of each member in this structure 250 * data structure is fully optional and usage of each member in this structure
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index b93122636531..771c60ab4a32 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -921,6 +921,29 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
921{ 921{
922 void __iomem *base = host->base; 922 void __iomem *base = host->base;
923 bool sbc = (cmd == host->mrq->sbc); 923 bool sbc = (cmd == host->mrq->sbc);
924 bool busy_resp = host->variant->busy_detect &&
925 (cmd->flags & MMC_RSP_BUSY);
926
927 /* Check if we need to wait for busy completion. */
928 if (host->busy_status && (status & MCI_ST_CARDBUSY))
929 return;
930
931 /* Enable busy completion if needed and supported. */
932 if (!host->busy_status && busy_resp &&
933 !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) &&
934 (readl(base + MMCISTATUS) & MCI_ST_CARDBUSY)) {
935 writel(readl(base + MMCIMASK0) | MCI_ST_BUSYEND,
936 base + MMCIMASK0);
937 host->busy_status = status & (MCI_CMDSENT|MCI_CMDRESPEND);
938 return;
939 }
940
941 /* At busy completion, mask the IRQ and complete the request. */
942 if (host->busy_status) {
943 writel(readl(base + MMCIMASK0) & ~MCI_ST_BUSYEND,
944 base + MMCIMASK0);
945 host->busy_status = 0;
946 }
924 947
925 host->cmd = NULL; 948 host->cmd = NULL;
926 949
@@ -1139,20 +1162,30 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
1139 status &= ~MCI_IRQ1MASK; 1162 status &= ~MCI_IRQ1MASK;
1140 } 1163 }
1141 1164
1165 /*
1166 * We intentionally clear the MCI_ST_CARDBUSY IRQ here (if it's
1167 * enabled) since the HW seems to be triggering the IRQ on both
1168 * edges while monitoring DAT0 for busy completion.
1169 */
1142 status &= readl(host->base + MMCIMASK0); 1170 status &= readl(host->base + MMCIMASK0);
1143 writel(status, host->base + MMCICLEAR); 1171 writel(status, host->base + MMCICLEAR);
1144 1172
1145 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status); 1173 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
1146 1174
1175 cmd = host->cmd;
1176 if ((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|
1177 MCI_CMDSENT|MCI_CMDRESPEND) && cmd)
1178 mmci_cmd_irq(host, cmd, status);
1179
1147 data = host->data; 1180 data = host->data;
1148 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR| 1181 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
1149 MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND| 1182 MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND|
1150 MCI_DATABLOCKEND) && data) 1183 MCI_DATABLOCKEND) && data)
1151 mmci_data_irq(host, data, status); 1184 mmci_data_irq(host, data, status);
1152 1185
1153 cmd = host->cmd; 1186 /* Don't poll for busy completion in irq context. */
1154 if (status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|MCI_CMDSENT|MCI_CMDRESPEND) && cmd) 1187 if (host->busy_status)
1155 mmci_cmd_irq(host, cmd, status); 1188 status &= ~MCI_ST_CARDBUSY;
1156 1189
1157 ret = 1; 1190 ret = 1;
1158 } while (status); 1191 } while (status);
@@ -1503,12 +1536,6 @@ static int mmci_probe(struct amba_device *dev,
1503 goto clk_disable; 1536 goto clk_disable;
1504 } 1537 }
1505 1538
1506 if (variant->busy_detect) {
1507 mmci_ops.card_busy = mmci_card_busy;
1508 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
1509 }
1510
1511 mmc->ops = &mmci_ops;
1512 /* 1539 /*
1513 * The ARM and ST versions of the block have slightly different 1540 * The ARM and ST versions of the block have slightly different
1514 * clock divider equations which means that the minimum divider 1541 * clock divider equations which means that the minimum divider
@@ -1542,6 +1569,15 @@ static int mmci_probe(struct amba_device *dev,
1542 mmc->caps = plat->capabilities; 1569 mmc->caps = plat->capabilities;
1543 mmc->caps2 = plat->capabilities2; 1570 mmc->caps2 = plat->capabilities2;
1544 1571
1572 if (variant->busy_detect) {
1573 mmci_ops.card_busy = mmci_card_busy;
1574 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
1575 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
1576 mmc->max_busy_timeout = 0;
1577 }
1578
1579 mmc->ops = &mmci_ops;
1580
1545 /* We support these PM capabilities. */ 1581 /* We support these PM capabilities. */
1546 mmc->pm_caps = MMC_PM_KEEP_POWER; 1582 mmc->pm_caps = MMC_PM_KEEP_POWER;
1547 1583
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 84c0e59b792a..58b1b8896bf2 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -140,6 +140,7 @@
140/* Extended status bits for the ST Micro variants */ 140/* Extended status bits for the ST Micro variants */
141#define MCI_ST_SDIOITMASK (1 << 22) 141#define MCI_ST_SDIOITMASK (1 << 22)
142#define MCI_ST_CEATAENDMASK (1 << 23) 142#define MCI_ST_CEATAENDMASK (1 << 23)
143#define MCI_ST_BUSYEND (1 << 24)
143 144
144#define MMCIMASK1 0x040 145#define MMCIMASK1 0x040
145#define MMCIFIFOCNT 0x048 146#define MMCIFIFOCNT 0x048
@@ -187,6 +188,7 @@ struct mmci_host {
187 u32 pwr_reg; 188 u32 pwr_reg;
188 u32 clk_reg; 189 u32 clk_reg;
189 u32 datactrl_reg; 190 u32 datactrl_reg;
191 u32 busy_status;
190 bool vqmmc_enabled; 192 bool vqmmc_enabled;
191 struct mmci_platform_data *plat; 193 struct mmci_platform_data *plat;
192 struct variant_data *variant; 194 struct variant_data *variant;
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 98b6b6ef7e5c..5c2e58b29305 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -26,6 +26,7 @@
26#include <linux/omap-dma.h> 26#include <linux/omap-dma.h>
27#include <linux/mmc/host.h> 27#include <linux/mmc/host.h>
28#include <linux/mmc/card.h> 28#include <linux/mmc/card.h>
29#include <linux/mmc/mmc.h>
29#include <linux/clk.h> 30#include <linux/clk.h>
30#include <linux/scatterlist.h> 31#include <linux/scatterlist.h>
31#include <linux/slab.h> 32#include <linux/slab.h>
@@ -130,7 +131,6 @@ struct mmc_omap_host {
130 u32 dma_rx_burst; 131 u32 dma_rx_burst;
131 struct dma_chan *dma_tx; 132 struct dma_chan *dma_tx;
132 u32 dma_tx_burst; 133 u32 dma_tx_burst;
133 struct resource *mem_res;
134 void __iomem *virt_base; 134 void __iomem *virt_base;
135 unsigned int phys_base; 135 unsigned int phys_base;
136 int irq; 136 int irq;
@@ -153,7 +153,6 @@ struct mmc_omap_host {
153 u32 total_bytes_left; 153 u32 total_bytes_left;
154 154
155 unsigned features; 155 unsigned features;
156 unsigned use_dma:1;
157 unsigned brs_received:1, dma_done:1; 156 unsigned brs_received:1, dma_done:1;
158 unsigned dma_in_use:1; 157 unsigned dma_in_use:1;
159 spinlock_t dma_lock; 158 spinlock_t dma_lock;
@@ -338,6 +337,7 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
338 u32 cmdreg; 337 u32 cmdreg;
339 u32 resptype; 338 u32 resptype;
340 u32 cmdtype; 339 u32 cmdtype;
340 u16 irq_mask;
341 341
342 host->cmd = cmd; 342 host->cmd = cmd;
343 343
@@ -390,12 +390,14 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
390 OMAP_MMC_WRITE(host, CTO, 200); 390 OMAP_MMC_WRITE(host, CTO, 200);
391 OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff); 391 OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff);
392 OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16); 392 OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16);
393 OMAP_MMC_WRITE(host, IE, 393 irq_mask = OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL |
394 OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL | 394 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT |
395 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT | 395 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT |
396 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT | 396 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR |
397 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR | 397 OMAP_MMC_STAT_END_OF_DATA;
398 OMAP_MMC_STAT_END_OF_DATA); 398 if (cmd->opcode == MMC_ERASE)
399 irq_mask &= ~OMAP_MMC_STAT_DATA_TOUT;
400 OMAP_MMC_WRITE(host, IE, irq_mask);
399 OMAP_MMC_WRITE(host, CMD, cmdreg); 401 OMAP_MMC_WRITE(host, CMD, cmdreg);
400} 402}
401 403
@@ -945,7 +947,7 @@ static void
945mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req) 947mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
946{ 948{
947 struct mmc_data *data = req->data; 949 struct mmc_data *data = req->data;
948 int i, use_dma, block_size; 950 int i, use_dma = 1, block_size;
949 unsigned sg_len; 951 unsigned sg_len;
950 952
951 host->data = data; 953 host->data = data;
@@ -970,13 +972,10 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
970 sg_len = (data->blocks == 1) ? 1 : data->sg_len; 972 sg_len = (data->blocks == 1) ? 1 : data->sg_len;
971 973
972 /* Only do DMA for entire blocks */ 974 /* Only do DMA for entire blocks */
973 use_dma = host->use_dma; 975 for (i = 0; i < sg_len; i++) {
974 if (use_dma) { 976 if ((data->sg[i].length % block_size) != 0) {
975 for (i = 0; i < sg_len; i++) { 977 use_dma = 0;
976 if ((data->sg[i].length % block_size) != 0) { 978 break;
977 use_dma = 0;
978 break;
979 }
980 } 979 }
981 } 980 }
982 981
@@ -1239,7 +1238,7 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
1239 1238
1240 mmc->caps = 0; 1239 mmc->caps = 0;
1241 if (host->pdata->slots[id].wires >= 4) 1240 if (host->pdata->slots[id].wires >= 4)
1242 mmc->caps |= MMC_CAP_4_BIT_DATA; 1241 mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_ERASE;
1243 1242
1244 mmc->ops = &mmc_omap_ops; 1243 mmc->ops = &mmc_omap_ops;
1245 mmc->f_min = 400000; 1244 mmc->f_min = 400000;
@@ -1262,6 +1261,13 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
1262 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; 1261 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
1263 mmc->max_seg_size = mmc->max_req_size; 1262 mmc->max_seg_size = mmc->max_req_size;
1264 1263
1264 if (slot->pdata->get_cover_state != NULL) {
1265 setup_timer(&slot->cover_timer, mmc_omap_cover_timer,
1266 (unsigned long)slot);
1267 tasklet_init(&slot->cover_tasklet, mmc_omap_cover_handler,
1268 (unsigned long)slot);
1269 }
1270
1265 r = mmc_add_host(mmc); 1271 r = mmc_add_host(mmc);
1266 if (r < 0) 1272 if (r < 0)
1267 goto err_remove_host; 1273 goto err_remove_host;
@@ -1278,11 +1284,6 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
1278 &dev_attr_cover_switch); 1284 &dev_attr_cover_switch);
1279 if (r < 0) 1285 if (r < 0)
1280 goto err_remove_slot_name; 1286 goto err_remove_slot_name;
1281
1282 setup_timer(&slot->cover_timer, mmc_omap_cover_timer,
1283 (unsigned long)slot);
1284 tasklet_init(&slot->cover_tasklet, mmc_omap_cover_handler,
1285 (unsigned long)slot);
1286 tasklet_schedule(&slot->cover_tasklet); 1287 tasklet_schedule(&slot->cover_tasklet);
1287 } 1288 }
1288 1289
@@ -1333,21 +1334,19 @@ static int mmc_omap_probe(struct platform_device *pdev)
1333 return -EPROBE_DEFER; 1334 return -EPROBE_DEFER;
1334 } 1335 }
1335 1336
1336 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1337 host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host),
1338 GFP_KERNEL);
1339 if (host == NULL)
1340 return -ENOMEM;
1341
1337 irq = platform_get_irq(pdev, 0); 1342 irq = platform_get_irq(pdev, 0);
1338 if (res == NULL || irq < 0) 1343 if (irq < 0)
1339 return -ENXIO; 1344 return -ENXIO;
1340 1345
1341 res = request_mem_region(res->start, resource_size(res), 1346 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1342 pdev->name); 1347 host->virt_base = devm_ioremap_resource(&pdev->dev, res);
1343 if (res == NULL) 1348 if (IS_ERR(host->virt_base))
1344 return -EBUSY; 1349 return PTR_ERR(host->virt_base);
1345
1346 host = kzalloc(sizeof(struct mmc_omap_host), GFP_KERNEL);
1347 if (host == NULL) {
1348 ret = -ENOMEM;
1349 goto err_free_mem_region;
1350 }
1351 1350
1352 INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work); 1351 INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work);
1353 INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work); 1352 INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work);
@@ -1369,20 +1368,11 @@ static int mmc_omap_probe(struct platform_device *pdev)
1369 platform_set_drvdata(pdev, host); 1368 platform_set_drvdata(pdev, host);
1370 1369
1371 host->id = pdev->id; 1370 host->id = pdev->id;
1372 host->mem_res = res;
1373 host->irq = irq;
1374 host->use_dma = 1;
1375 host->irq = irq; 1371 host->irq = irq;
1376 host->phys_base = host->mem_res->start; 1372 host->phys_base = res->start;
1377 host->virt_base = ioremap(res->start, resource_size(res));
1378 if (!host->virt_base)
1379 goto err_ioremap;
1380
1381 host->iclk = clk_get(&pdev->dev, "ick"); 1373 host->iclk = clk_get(&pdev->dev, "ick");
1382 if (IS_ERR(host->iclk)) { 1374 if (IS_ERR(host->iclk))
1383 ret = PTR_ERR(host->iclk); 1375 return PTR_ERR(host->iclk);
1384 goto err_free_mmc_host;
1385 }
1386 clk_enable(host->iclk); 1376 clk_enable(host->iclk);
1387 1377
1388 host->fclk = clk_get(&pdev->dev, "fck"); 1378 host->fclk = clk_get(&pdev->dev, "fck");
@@ -1460,12 +1450,6 @@ err_free_dma:
1460err_free_iclk: 1450err_free_iclk:
1461 clk_disable(host->iclk); 1451 clk_disable(host->iclk);
1462 clk_put(host->iclk); 1452 clk_put(host->iclk);
1463err_free_mmc_host:
1464 iounmap(host->virt_base);
1465err_ioremap:
1466 kfree(host);
1467err_free_mem_region:
1468 release_mem_region(res->start, resource_size(res));
1469 return ret; 1453 return ret;
1470} 1454}
1471 1455
@@ -1493,13 +1477,8 @@ static int mmc_omap_remove(struct platform_device *pdev)
1493 if (host->dma_rx) 1477 if (host->dma_rx)
1494 dma_release_channel(host->dma_rx); 1478 dma_release_channel(host->dma_rx);
1495 1479
1496 iounmap(host->virt_base);
1497 release_mem_region(pdev->resource[0].start,
1498 pdev->resource[0].end - pdev->resource[0].start + 1);
1499 destroy_workqueue(host->mmc_omap_wq); 1480 destroy_workqueue(host->mmc_omap_wq);
1500 1481
1501 kfree(host);
1502
1503 return 0; 1482 return 0;
1504} 1483}
1505 1484
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index dbd32ad3b749..e91ee21549d0 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -45,6 +45,7 @@
45/* OMAP HSMMC Host Controller Registers */ 45/* OMAP HSMMC Host Controller Registers */
46#define OMAP_HSMMC_SYSSTATUS 0x0014 46#define OMAP_HSMMC_SYSSTATUS 0x0014
47#define OMAP_HSMMC_CON 0x002C 47#define OMAP_HSMMC_CON 0x002C
48#define OMAP_HSMMC_SDMASA 0x0100
48#define OMAP_HSMMC_BLK 0x0104 49#define OMAP_HSMMC_BLK 0x0104
49#define OMAP_HSMMC_ARG 0x0108 50#define OMAP_HSMMC_ARG 0x0108
50#define OMAP_HSMMC_CMD 0x010C 51#define OMAP_HSMMC_CMD 0x010C
@@ -58,6 +59,7 @@
58#define OMAP_HSMMC_STAT 0x0130 59#define OMAP_HSMMC_STAT 0x0130
59#define OMAP_HSMMC_IE 0x0134 60#define OMAP_HSMMC_IE 0x0134
60#define OMAP_HSMMC_ISE 0x0138 61#define OMAP_HSMMC_ISE 0x0138
62#define OMAP_HSMMC_AC12 0x013C
61#define OMAP_HSMMC_CAPA 0x0140 63#define OMAP_HSMMC_CAPA 0x0140
62 64
63#define VS18 (1 << 26) 65#define VS18 (1 << 26)
@@ -81,6 +83,7 @@
81#define DTO_MASK 0x000F0000 83#define DTO_MASK 0x000F0000
82#define DTO_SHIFT 16 84#define DTO_SHIFT 16
83#define INIT_STREAM (1 << 1) 85#define INIT_STREAM (1 << 1)
86#define ACEN_ACMD23 (2 << 2)
84#define DP_SELECT (1 << 21) 87#define DP_SELECT (1 << 21)
85#define DDIR (1 << 4) 88#define DDIR (1 << 4)
86#define DMAE 0x1 89#define DMAE 0x1
@@ -97,7 +100,6 @@
97#define SRC (1 << 25) 100#define SRC (1 << 25)
98#define SRD (1 << 26) 101#define SRD (1 << 26)
99#define SOFTRESET (1 << 1) 102#define SOFTRESET (1 << 1)
100#define RESETDONE (1 << 0)
101 103
102/* Interrupt masks for IE and ISE register */ 104/* Interrupt masks for IE and ISE register */
103#define CC_EN (1 << 0) 105#define CC_EN (1 << 0)
@@ -112,13 +114,21 @@
112#define DTO_EN (1 << 20) 114#define DTO_EN (1 << 20)
113#define DCRC_EN (1 << 21) 115#define DCRC_EN (1 << 21)
114#define DEB_EN (1 << 22) 116#define DEB_EN (1 << 22)
117#define ACE_EN (1 << 24)
115#define CERR_EN (1 << 28) 118#define CERR_EN (1 << 28)
116#define BADA_EN (1 << 29) 119#define BADA_EN (1 << 29)
117 120
118#define INT_EN_MASK (BADA_EN | CERR_EN | DEB_EN | DCRC_EN |\ 121#define INT_EN_MASK (BADA_EN | CERR_EN | ACE_EN | DEB_EN | DCRC_EN |\
119 DTO_EN | CIE_EN | CEB_EN | CCRC_EN | CTO_EN | \ 122 DTO_EN | CIE_EN | CEB_EN | CCRC_EN | CTO_EN | \
120 BRR_EN | BWR_EN | TC_EN | CC_EN) 123 BRR_EN | BWR_EN | TC_EN | CC_EN)
121 124
125#define CNI (1 << 7)
126#define ACIE (1 << 4)
127#define ACEB (1 << 3)
128#define ACCE (1 << 2)
129#define ACTO (1 << 1)
130#define ACNE (1 << 0)
131
122#define MMC_AUTOSUSPEND_DELAY 100 132#define MMC_AUTOSUSPEND_DELAY 100
123#define MMC_TIMEOUT_MS 20 /* 20 mSec */ 133#define MMC_TIMEOUT_MS 20 /* 20 mSec */
124#define MMC_TIMEOUT_US 20000 /* 20000 micro Sec */ 134#define MMC_TIMEOUT_US 20000 /* 20000 micro Sec */
@@ -126,6 +136,11 @@
126#define OMAP_MMC_MAX_CLOCK 52000000 136#define OMAP_MMC_MAX_CLOCK 52000000
127#define DRIVER_NAME "omap_hsmmc" 137#define DRIVER_NAME "omap_hsmmc"
128 138
139#define VDD_1V8 1800000 /* 180000 uV */
140#define VDD_3V0 3000000 /* 300000 uV */
141#define VDD_165_195 (ffs(MMC_VDD_165_195) - 1)
142
143#define AUTO_CMD23 (1 << 1) /* Auto CMD23 support */
129/* 144/*
130 * One controller can have multiple slots, like on some omap boards using 145 * One controller can have multiple slots, like on some omap boards using
131 * omap.c controller driver. Luckily this is not currently done on any known 146 * omap.c controller driver. Luckily this is not currently done on any known
@@ -164,7 +179,8 @@ struct omap_hsmmc_host {
164 */ 179 */
165 struct regulator *vcc; 180 struct regulator *vcc;
166 struct regulator *vcc_aux; 181 struct regulator *vcc_aux;
167 int pbias_disable; 182 struct regulator *pbias;
183 bool pbias_enabled;
168 void __iomem *base; 184 void __iomem *base;
169 resource_size_t mapbase; 185 resource_size_t mapbase;
170 spinlock_t irq_lock; /* Prevent races with irq handler */ 186 spinlock_t irq_lock; /* Prevent races with irq handler */
@@ -188,10 +204,19 @@ struct omap_hsmmc_host {
188 int reqs_blocked; 204 int reqs_blocked;
189 int use_reg; 205 int use_reg;
190 int req_in_progress; 206 int req_in_progress;
207 unsigned long clk_rate;
208 unsigned int flags;
191 struct omap_hsmmc_next next_data; 209 struct omap_hsmmc_next next_data;
192 struct omap_mmc_platform_data *pdata; 210 struct omap_mmc_platform_data *pdata;
193}; 211};
194 212
213struct omap_mmc_of_data {
214 u32 reg_offset;
215 u8 controller_flags;
216};
217
218static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
219
195static int omap_hsmmc_card_detect(struct device *dev, int slot) 220static int omap_hsmmc_card_detect(struct device *dev, int slot)
196{ 221{
197 struct omap_hsmmc_host *host = dev_get_drvdata(dev); 222 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
@@ -261,17 +286,19 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
261 */ 286 */
262 if (!host->vcc) 287 if (!host->vcc)
263 return 0; 288 return 0;
264 /*
265 * With DT, never turn OFF the regulator for MMC1. This is because
266 * the pbias cell programming support is still missing when
267 * booting with Device tree
268 */
269 if (host->pbias_disable && !vdd)
270 return 0;
271 289
272 if (mmc_slot(host).before_set_reg) 290 if (mmc_slot(host).before_set_reg)
273 mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); 291 mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
274 292
293 if (host->pbias) {
294 if (host->pbias_enabled == 1) {
295 ret = regulator_disable(host->pbias);
296 if (!ret)
297 host->pbias_enabled = 0;
298 }
299 regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
300 }
301
275 /* 302 /*
276 * Assume Vcc regulator is used only to power the card ... OMAP 303 * Assume Vcc regulator is used only to power the card ... OMAP
277 * VDDS is used to power the pins, optionally with a transceiver to 304 * VDDS is used to power the pins, optionally with a transceiver to
@@ -286,11 +313,12 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
286 * chips/cards need an interface voltage rail too. 313 * chips/cards need an interface voltage rail too.
287 */ 314 */
288 if (power_on) { 315 if (power_on) {
289 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); 316 if (host->vcc)
317 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
290 /* Enable interface voltage rail, if needed */ 318 /* Enable interface voltage rail, if needed */
291 if (ret == 0 && host->vcc_aux) { 319 if (ret == 0 && host->vcc_aux) {
292 ret = regulator_enable(host->vcc_aux); 320 ret = regulator_enable(host->vcc_aux);
293 if (ret < 0) 321 if (ret < 0 && host->vcc)
294 ret = mmc_regulator_set_ocr(host->mmc, 322 ret = mmc_regulator_set_ocr(host->mmc,
295 host->vcc, 0); 323 host->vcc, 0);
296 } 324 }
@@ -298,16 +326,34 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
298 /* Shut down the rail */ 326 /* Shut down the rail */
299 if (host->vcc_aux) 327 if (host->vcc_aux)
300 ret = regulator_disable(host->vcc_aux); 328 ret = regulator_disable(host->vcc_aux);
301 if (!ret) { 329 if (host->vcc) {
302 /* Then proceed to shut down the local regulator */ 330 /* Then proceed to shut down the local regulator */
303 ret = mmc_regulator_set_ocr(host->mmc, 331 ret = mmc_regulator_set_ocr(host->mmc,
304 host->vcc, 0); 332 host->vcc, 0);
305 } 333 }
306 } 334 }
307 335
336 if (host->pbias) {
337 if (vdd <= VDD_165_195)
338 ret = regulator_set_voltage(host->pbias, VDD_1V8,
339 VDD_1V8);
340 else
341 ret = regulator_set_voltage(host->pbias, VDD_3V0,
342 VDD_3V0);
343 if (ret < 0)
344 goto error_set_power;
345
346 if (host->pbias_enabled == 0) {
347 ret = regulator_enable(host->pbias);
348 if (!ret)
349 host->pbias_enabled = 1;
350 }
351 }
352
308 if (mmc_slot(host).after_set_reg) 353 if (mmc_slot(host).after_set_reg)
309 mmc_slot(host).after_set_reg(dev, slot, power_on, vdd); 354 mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
310 355
356error_set_power:
311 return ret; 357 return ret;
312} 358}
313 359
@@ -316,12 +362,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
316 struct regulator *reg; 362 struct regulator *reg;
317 int ocr_value = 0; 363 int ocr_value = 0;
318 364
319 reg = regulator_get(host->dev, "vmmc"); 365 reg = devm_regulator_get(host->dev, "vmmc");
320 if (IS_ERR(reg)) { 366 if (IS_ERR(reg)) {
321 dev_err(host->dev, "vmmc regulator missing\n"); 367 dev_err(host->dev, "unable to get vmmc regulator %ld\n",
368 PTR_ERR(reg));
322 return PTR_ERR(reg); 369 return PTR_ERR(reg);
323 } else { 370 } else {
324 mmc_slot(host).set_power = omap_hsmmc_set_power;
325 host->vcc = reg; 371 host->vcc = reg;
326 ocr_value = mmc_regulator_get_ocrmask(reg); 372 ocr_value = mmc_regulator_get_ocrmask(reg);
327 if (!mmc_slot(host).ocr_mask) { 373 if (!mmc_slot(host).ocr_mask) {
@@ -334,31 +380,29 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
334 return -EINVAL; 380 return -EINVAL;
335 } 381 }
336 } 382 }
383 }
384 mmc_slot(host).set_power = omap_hsmmc_set_power;
337 385
338 /* Allow an aux regulator */ 386 /* Allow an aux regulator */
339 reg = regulator_get(host->dev, "vmmc_aux"); 387 reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
340 host->vcc_aux = IS_ERR(reg) ? NULL : reg; 388 host->vcc_aux = IS_ERR(reg) ? NULL : reg;
341 389
342 /* For eMMC do not power off when not in sleep state */ 390 reg = devm_regulator_get_optional(host->dev, "pbias");
343 if (mmc_slot(host).no_regulator_off_init) 391 host->pbias = IS_ERR(reg) ? NULL : reg;
344 return 0;
345 /*
346 * UGLY HACK: workaround regulator framework bugs.
347 * When the bootloader leaves a supply active, it's
348 * initialized with zero usecount ... and we can't
349 * disable it without first enabling it. Until the
350 * framework is fixed, we need a workaround like this
351 * (which is safe for MMC, but not in general).
352 */
353 if (regulator_is_enabled(host->vcc) > 0 ||
354 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
355 int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
356 392
357 mmc_slot(host).set_power(host->dev, host->slot_id, 393 /* For eMMC do not power off when not in sleep state */
358 1, vdd); 394 if (mmc_slot(host).no_regulator_off_init)
359 mmc_slot(host).set_power(host->dev, host->slot_id, 395 return 0;
360 0, 0); 396 /*
361 } 397 * To disable boot_on regulator, enable regulator
398 * to increase usecount and then disable it.
399 */
400 if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
401 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
402 int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
403
404 mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
405 mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
362 } 406 }
363 407
364 return 0; 408 return 0;
@@ -366,8 +410,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
366 410
367static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) 411static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
368{ 412{
369 regulator_put(host->vcc);
370 regulator_put(host->vcc_aux);
371 mmc_slot(host).set_power = NULL; 413 mmc_slot(host).set_power = NULL;
372} 414}
373 415
@@ -605,9 +647,6 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
605 u32 hctl, capa; 647 u32 hctl, capa;
606 unsigned long timeout; 648 unsigned long timeout;
607 649
608 if (!OMAP_HSMMC_READ(host->base, SYSSTATUS) & RESETDONE)
609 return 1;
610
611 if (host->con == OMAP_HSMMC_READ(host->base, CON) && 650 if (host->con == OMAP_HSMMC_READ(host->base, CON) &&
612 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) && 651 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) &&
613 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) && 652 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) &&
@@ -787,6 +826,11 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
787 826
788 cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22); 827 cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
789 828
829 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) &&
830 host->mrq->sbc) {
831 cmdreg |= ACEN_ACMD23;
832 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg);
833 }
790 if (data) { 834 if (data) {
791 cmdreg |= DP_SELECT | MSBS | BCE; 835 cmdreg |= DP_SELECT | MSBS | BCE;
792 if (data->flags & MMC_DATA_READ) 836 if (data->flags & MMC_DATA_READ)
@@ -864,11 +908,10 @@ omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
864 else 908 else
865 data->bytes_xfered = 0; 909 data->bytes_xfered = 0;
866 910
867 if (!data->stop) { 911 if (data->stop && (data->error || !host->mrq->sbc))
912 omap_hsmmc_start_command(host, data->stop, NULL);
913 else
868 omap_hsmmc_request_done(host, data->mrq); 914 omap_hsmmc_request_done(host, data->mrq);
869 return;
870 }
871 omap_hsmmc_start_command(host, data->stop, NULL);
872} 915}
873 916
874/* 917/*
@@ -879,6 +922,14 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
879{ 922{
880 host->cmd = NULL; 923 host->cmd = NULL;
881 924
925 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) &&
926 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) {
927 omap_hsmmc_start_dma_transfer(host);
928 omap_hsmmc_start_command(host, host->mrq->cmd,
929 host->mrq->data);
930 return;
931 }
932
882 if (cmd->flags & MMC_RSP_PRESENT) { 933 if (cmd->flags & MMC_RSP_PRESENT) {
883 if (cmd->flags & MMC_RSP_136) { 934 if (cmd->flags & MMC_RSP_136) {
884 /* response type 2 */ 935 /* response type 2 */
@@ -892,7 +943,7 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
892 } 943 }
893 } 944 }
894 if ((host->data == NULL && !host->response_busy) || cmd->error) 945 if ((host->data == NULL && !host->response_busy) || cmd->error)
895 omap_hsmmc_request_done(host, cmd->mrq); 946 omap_hsmmc_request_done(host, host->mrq);
896} 947}
897 948
898/* 949/*
@@ -1015,6 +1066,7 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
1015{ 1066{
1016 struct mmc_data *data; 1067 struct mmc_data *data;
1017 int end_cmd = 0, end_trans = 0; 1068 int end_cmd = 0, end_trans = 0;
1069 int error = 0;
1018 1070
1019 data = host->data; 1071 data = host->data;
1020 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status); 1072 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status);
@@ -1029,6 +1081,20 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
1029 else if (status & (CCRC_EN | DCRC_EN)) 1081 else if (status & (CCRC_EN | DCRC_EN))
1030 hsmmc_command_incomplete(host, -EILSEQ, end_cmd); 1082 hsmmc_command_incomplete(host, -EILSEQ, end_cmd);
1031 1083
1084 if (status & ACE_EN) {
1085 u32 ac12;
1086 ac12 = OMAP_HSMMC_READ(host->base, AC12);
1087 if (!(ac12 & ACNE) && host->mrq->sbc) {
1088 end_cmd = 1;
1089 if (ac12 & ACTO)
1090 error = -ETIMEDOUT;
1091 else if (ac12 & (ACCE | ACEB | ACIE))
1092 error = -EILSEQ;
1093 host->mrq->sbc->error = error;
1094 hsmmc_command_incomplete(host, error, end_cmd);
1095 }
1096 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12);
1097 }
1032 if (host->data || host->response_busy) { 1098 if (host->data || host->response_busy) {
1033 end_trans = !end_cmd; 1099 end_trans = !end_cmd;
1034 host->response_busy = 0; 1100 host->response_busy = 0;
@@ -1236,8 +1302,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
1236 } 1302 }
1237 1303
1238 /* Check if next job is already prepared */ 1304 /* Check if next job is already prepared */
1239 if (next || 1305 if (next || data->host_cookie != host->next_data.cookie) {
1240 (!next && data->host_cookie != host->next_data.cookie)) {
1241 dma_len = dma_map_sg(chan->device->dev, data->sg, data->sg_len, 1306 dma_len = dma_map_sg(chan->device->dev, data->sg, data->sg_len,
1242 omap_hsmmc_get_dma_dir(host, data)); 1307 omap_hsmmc_get_dma_dir(host, data));
1243 1308
@@ -1262,7 +1327,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
1262/* 1327/*
1263 * Routine to configure and start DMA for the MMC card 1328 * Routine to configure and start DMA for the MMC card
1264 */ 1329 */
1265static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host, 1330static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
1266 struct mmc_request *req) 1331 struct mmc_request *req)
1267{ 1332{
1268 struct dma_slave_config cfg; 1333 struct dma_slave_config cfg;
@@ -1321,8 +1386,6 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host,
1321 1386
1322 host->dma_ch = 1; 1387 host->dma_ch = 1;
1323 1388
1324 dma_async_issue_pending(chan);
1325
1326 return 0; 1389 return 0;
1327} 1390}
1328 1391
@@ -1338,7 +1401,7 @@ static void set_data_timeout(struct omap_hsmmc_host *host,
1338 if (clkd == 0) 1401 if (clkd == 0)
1339 clkd = 1; 1402 clkd = 1;
1340 1403
1341 cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd); 1404 cycle_ns = 1000000000 / (host->clk_rate / clkd);
1342 timeout = timeout_ns / cycle_ns; 1405 timeout = timeout_ns / cycle_ns;
1343 timeout += timeout_clks; 1406 timeout += timeout_clks;
1344 if (timeout) { 1407 if (timeout) {
@@ -1363,6 +1426,21 @@ static void set_data_timeout(struct omap_hsmmc_host *host,
1363 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg); 1426 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg);
1364} 1427}
1365 1428
1429static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host)
1430{
1431 struct mmc_request *req = host->mrq;
1432 struct dma_chan *chan;
1433
1434 if (!req->data)
1435 return;
1436 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
1437 | (req->data->blocks << 16));
1438 set_data_timeout(host, req->data->timeout_ns,
1439 req->data->timeout_clks);
1440 chan = omap_hsmmc_get_dma_chan(host, req->data);
1441 dma_async_issue_pending(chan);
1442}
1443
1366/* 1444/*
1367 * Configure block length for MMC/SD cards and initiate the transfer. 1445 * Configure block length for MMC/SD cards and initiate the transfer.
1368 */ 1446 */
@@ -1383,12 +1461,8 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)
1383 return 0; 1461 return 0;
1384 } 1462 }
1385 1463
1386 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
1387 | (req->data->blocks << 16));
1388 set_data_timeout(host, req->data->timeout_ns, req->data->timeout_clks);
1389
1390 if (host->use_dma) { 1464 if (host->use_dma) {
1391 ret = omap_hsmmc_start_dma_transfer(host, req); 1465 ret = omap_hsmmc_setup_dma_transfer(host, req);
1392 if (ret != 0) { 1466 if (ret != 0) {
1393 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n"); 1467 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n");
1394 return ret; 1468 return ret;
@@ -1462,6 +1536,7 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
1462 host->reqs_blocked = 0; 1536 host->reqs_blocked = 0;
1463 WARN_ON(host->mrq != NULL); 1537 WARN_ON(host->mrq != NULL);
1464 host->mrq = req; 1538 host->mrq = req;
1539 host->clk_rate = clk_get_rate(host->fclk);
1465 err = omap_hsmmc_prepare_data(host, req); 1540 err = omap_hsmmc_prepare_data(host, req);
1466 if (err) { 1541 if (err) {
1467 req->cmd->error = err; 1542 req->cmd->error = err;
@@ -1471,7 +1546,12 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
1471 mmc_request_done(mmc, req); 1546 mmc_request_done(mmc, req);
1472 return; 1547 return;
1473 } 1548 }
1549 if (req->sbc && !(host->flags & AUTO_CMD23)) {
1550 omap_hsmmc_start_command(host, req->sbc, NULL);
1551 return;
1552 }
1474 1553
1554 omap_hsmmc_start_dma_transfer(host);
1475 omap_hsmmc_start_command(host, req->cmd, req->data); 1555 omap_hsmmc_start_command(host, req->cmd, req->data);
1476} 1556}
1477 1557
@@ -1509,13 +1589,7 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1509 * of external transceiver; but they all handle 1.8V. 1589 * of external transceiver; but they all handle 1.8V.
1510 */ 1590 */
1511 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && 1591 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
1512 (ios->vdd == DUAL_VOLT_OCR_BIT) && 1592 (ios->vdd == DUAL_VOLT_OCR_BIT)) {
1513 /*
1514 * With pbias cell programming missing, this
1515 * can't be allowed on MMC1 when booting with device
1516 * tree.
1517 */
1518 !host->pbias_disable) {
1519 /* 1593 /*
1520 * The mmc_select_voltage fn of the core does 1594 * The mmc_select_voltage fn of the core does
1521 * not seem to set the power_mode to 1595 * not seem to set the power_mode to
@@ -1678,18 +1752,29 @@ static void omap_hsmmc_debugfs(struct mmc_host *mmc)
1678#endif 1752#endif
1679 1753
1680#ifdef CONFIG_OF 1754#ifdef CONFIG_OF
1681static u16 omap4_reg_offset = 0x100; 1755static const struct omap_mmc_of_data omap3_pre_es3_mmc_of_data = {
1756 /* See 35xx errata 2.1.1.128 in SPRZ278F */
1757 .controller_flags = OMAP_HSMMC_BROKEN_MULTIBLOCK_READ,
1758};
1759
1760static const struct omap_mmc_of_data omap4_mmc_of_data = {
1761 .reg_offset = 0x100,
1762};
1682 1763
1683static const struct of_device_id omap_mmc_of_match[] = { 1764static const struct of_device_id omap_mmc_of_match[] = {
1684 { 1765 {
1685 .compatible = "ti,omap2-hsmmc", 1766 .compatible = "ti,omap2-hsmmc",
1686 }, 1767 },
1687 { 1768 {
1769 .compatible = "ti,omap3-pre-es3-hsmmc",
1770 .data = &omap3_pre_es3_mmc_of_data,
1771 },
1772 {
1688 .compatible = "ti,omap3-hsmmc", 1773 .compatible = "ti,omap3-hsmmc",
1689 }, 1774 },
1690 { 1775 {
1691 .compatible = "ti,omap4-hsmmc", 1776 .compatible = "ti,omap4-hsmmc",
1692 .data = &omap4_reg_offset, 1777 .data = &omap4_mmc_of_data,
1693 }, 1778 },
1694 {}, 1779 {},
1695}; 1780};
@@ -1709,7 +1794,7 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
1709 1794
1710 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 1795 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1711 if (!pdata) 1796 if (!pdata)
1712 return NULL; /* out of memory */ 1797 return ERR_PTR(-ENOMEM); /* out of memory */
1713 1798
1714 if (of_find_property(np, "ti,dual-volt", NULL)) 1799 if (of_find_property(np, "ti,dual-volt", NULL))
1715 pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT; 1800 pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT;
@@ -1738,13 +1823,19 @@ static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
1738 if (of_find_property(np, "ti,needs-special-hs-handling", NULL)) 1823 if (of_find_property(np, "ti,needs-special-hs-handling", NULL))
1739 pdata->slots[0].features |= HSMMC_HAS_HSPE_SUPPORT; 1824 pdata->slots[0].features |= HSMMC_HAS_HSPE_SUPPORT;
1740 1825
1826 if (of_find_property(np, "keep-power-in-suspend", NULL))
1827 pdata->slots[0].pm_caps |= MMC_PM_KEEP_POWER;
1828
1829 if (of_find_property(np, "enable-sdio-wakeup", NULL))
1830 pdata->slots[0].pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
1831
1741 return pdata; 1832 return pdata;
1742} 1833}
1743#else 1834#else
1744static inline struct omap_mmc_platform_data 1835static inline struct omap_mmc_platform_data
1745 *of_get_hsmmc_pdata(struct device *dev) 1836 *of_get_hsmmc_pdata(struct device *dev)
1746{ 1837{
1747 return NULL; 1838 return ERR_PTR(-EINVAL);
1748} 1839}
1749#endif 1840#endif
1750 1841
@@ -1759,6 +1850,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
1759 dma_cap_mask_t mask; 1850 dma_cap_mask_t mask;
1760 unsigned tx_req, rx_req; 1851 unsigned tx_req, rx_req;
1761 struct pinctrl *pinctrl; 1852 struct pinctrl *pinctrl;
1853 const struct omap_mmc_of_data *data;
1762 1854
1763 match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev); 1855 match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
1764 if (match) { 1856 if (match) {
@@ -1768,8 +1860,9 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
1768 return PTR_ERR(pdata); 1860 return PTR_ERR(pdata);
1769 1861
1770 if (match->data) { 1862 if (match->data) {
1771 const u16 *offsetp = match->data; 1863 data = match->data;
1772 pdata->reg_offset = *offsetp; 1864 pdata->reg_offset = data->reg_offset;
1865 pdata->controller_flags |= data->controller_flags;
1773 } 1866 }
1774 } 1867 }
1775 1868
@@ -1814,6 +1907,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
1814 host->base = ioremap(host->mapbase, SZ_4K); 1907 host->base = ioremap(host->mapbase, SZ_4K);
1815 host->power_mode = MMC_POWER_OFF; 1908 host->power_mode = MMC_POWER_OFF;
1816 host->next_data.cookie = 1; 1909 host->next_data.cookie = 1;
1910 host->pbias_enabled = 0;
1817 1911
1818 platform_set_drvdata(pdev, host); 1912 platform_set_drvdata(pdev, host);
1819 1913
@@ -1847,10 +1941,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
1847 1941
1848 omap_hsmmc_context_save(host); 1942 omap_hsmmc_context_save(host);
1849 1943
1850 /* This can be removed once we support PBIAS with DT */
1851 if (host->dev->of_node && res->start == 0x4809c000)
1852 host->pbias_disable = 1;
1853
1854 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck"); 1944 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
1855 /* 1945 /*
1856 * MMC can still work without debounce clock. 1946 * MMC can still work without debounce clock.
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index c46feda07d56..5fb994f9a653 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -31,14 +31,9 @@
31#include <linux/mfd/rtsx_pci.h> 31#include <linux/mfd/rtsx_pci.h>
32#include <asm/unaligned.h> 32#include <asm/unaligned.h>
33 33
34/* SD Tuning Data Structure 34struct realtek_next {
35 * Record continuous timing phase path 35 unsigned int sg_count;
36 */ 36 s32 cookie;
37struct timing_phase_path {
38 int start;
39 int end;
40 int mid;
41 int len;
42}; 37};
43 38
44struct realtek_pci_sdmmc { 39struct realtek_pci_sdmmc {
@@ -46,9 +41,18 @@ struct realtek_pci_sdmmc {
46 struct rtsx_pcr *pcr; 41 struct rtsx_pcr *pcr;
47 struct mmc_host *mmc; 42 struct mmc_host *mmc;
48 struct mmc_request *mrq; 43 struct mmc_request *mrq;
49 44 struct mmc_command *cmd;
50 struct mutex host_mutex; 45 struct mmc_data *data;
51 46
47 spinlock_t lock;
48 struct timer_list timer;
49 struct tasklet_struct cmd_tasklet;
50 struct tasklet_struct data_tasklet;
51 struct tasklet_struct finish_tasklet;
52
53 u8 rsp_type;
54 u8 rsp_len;
55 int sg_count;
52 u8 ssc_depth; 56 u8 ssc_depth;
53 unsigned int clock; 57 unsigned int clock;
54 bool vpclk; 58 bool vpclk;
@@ -58,8 +62,13 @@ struct realtek_pci_sdmmc {
58 int power_state; 62 int power_state;
59#define SDMMC_POWER_ON 1 63#define SDMMC_POWER_ON 1
60#define SDMMC_POWER_OFF 0 64#define SDMMC_POWER_OFF 0
65
66 struct realtek_next next_data;
61}; 67};
62 68
69static int sd_start_multi_rw(struct realtek_pci_sdmmc *host,
70 struct mmc_request *mrq);
71
63static inline struct device *sdmmc_dev(struct realtek_pci_sdmmc *host) 72static inline struct device *sdmmc_dev(struct realtek_pci_sdmmc *host)
64{ 73{
65 return &(host->pdev->dev); 74 return &(host->pdev->dev);
@@ -96,6 +105,95 @@ static void sd_print_debug_regs(struct realtek_pci_sdmmc *host)
96#define sd_print_debug_regs(host) 105#define sd_print_debug_regs(host)
97#endif /* DEBUG */ 106#endif /* DEBUG */
98 107
108static void sd_isr_done_transfer(struct platform_device *pdev)
109{
110 struct realtek_pci_sdmmc *host = platform_get_drvdata(pdev);
111
112 spin_lock(&host->lock);
113 if (host->cmd)
114 tasklet_schedule(&host->cmd_tasklet);
115 if (host->data)
116 tasklet_schedule(&host->data_tasklet);
117 spin_unlock(&host->lock);
118}
119
120static void sd_request_timeout(unsigned long host_addr)
121{
122 struct realtek_pci_sdmmc *host = (struct realtek_pci_sdmmc *)host_addr;
123 unsigned long flags;
124
125 spin_lock_irqsave(&host->lock, flags);
126
127 if (!host->mrq) {
128 dev_err(sdmmc_dev(host), "error: no request exist\n");
129 goto out;
130 }
131
132 if (host->cmd)
133 host->cmd->error = -ETIMEDOUT;
134 if (host->data)
135 host->data->error = -ETIMEDOUT;
136
137 dev_dbg(sdmmc_dev(host), "timeout for request\n");
138
139out:
140 tasklet_schedule(&host->finish_tasklet);
141 spin_unlock_irqrestore(&host->lock, flags);
142}
143
144static void sd_finish_request(unsigned long host_addr)
145{
146 struct realtek_pci_sdmmc *host = (struct realtek_pci_sdmmc *)host_addr;
147 struct rtsx_pcr *pcr = host->pcr;
148 struct mmc_request *mrq;
149 struct mmc_command *cmd;
150 struct mmc_data *data;
151 unsigned long flags;
152 bool any_error;
153
154 spin_lock_irqsave(&host->lock, flags);
155
156 del_timer(&host->timer);
157 mrq = host->mrq;
158 if (!mrq) {
159 dev_err(sdmmc_dev(host), "error: no request need finish\n");
160 goto out;
161 }
162
163 cmd = mrq->cmd;
164 data = mrq->data;
165
166 any_error = (mrq->sbc && mrq->sbc->error) ||
167 (mrq->stop && mrq->stop->error) ||
168 (cmd && cmd->error) || (data && data->error);
169
170 if (any_error) {
171 rtsx_pci_stop_cmd(pcr);
172 sd_clear_error(host);
173 }
174
175 if (data) {
176 if (any_error)
177 data->bytes_xfered = 0;
178 else
179 data->bytes_xfered = data->blocks * data->blksz;
180
181 if (!data->host_cookie)
182 rtsx_pci_dma_unmap_sg(pcr, data->sg, data->sg_len,
183 data->flags & MMC_DATA_READ);
184
185 }
186
187 host->mrq = NULL;
188 host->cmd = NULL;
189 host->data = NULL;
190
191out:
192 spin_unlock_irqrestore(&host->lock, flags);
193 mutex_unlock(&pcr->pcr_mutex);
194 mmc_request_done(host->mmc, mrq);
195}
196
99static int sd_read_data(struct realtek_pci_sdmmc *host, u8 *cmd, u16 byte_cnt, 197static int sd_read_data(struct realtek_pci_sdmmc *host, u8 *cmd, u16 byte_cnt,
100 u8 *buf, int buf_len, int timeout) 198 u8 *buf, int buf_len, int timeout)
101{ 199{
@@ -213,8 +311,7 @@ static int sd_write_data(struct realtek_pci_sdmmc *host, u8 *cmd, u16 byte_cnt,
213 return 0; 311 return 0;
214} 312}
215 313
216static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host, 314static void sd_send_cmd(struct realtek_pci_sdmmc *host, struct mmc_command *cmd)
217 struct mmc_command *cmd)
218{ 315{
219 struct rtsx_pcr *pcr = host->pcr; 316 struct rtsx_pcr *pcr = host->pcr;
220 u8 cmd_idx = (u8)cmd->opcode; 317 u8 cmd_idx = (u8)cmd->opcode;
@@ -222,11 +319,14 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
222 int err = 0; 319 int err = 0;
223 int timeout = 100; 320 int timeout = 100;
224 int i; 321 int i;
225 u8 *ptr;
226 int stat_idx = 0;
227 u8 rsp_type; 322 u8 rsp_type;
228 int rsp_len = 5; 323 int rsp_len = 5;
229 bool clock_toggled = false; 324 unsigned long flags;
325
326 if (host->cmd)
327 dev_err(sdmmc_dev(host), "error: cmd already exist\n");
328
329 host->cmd = cmd;
230 330
231 dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n", 331 dev_dbg(sdmmc_dev(host), "%s: SD/MMC CMD %d, arg = 0x%08x\n",
232 __func__, cmd_idx, arg); 332 __func__, cmd_idx, arg);
@@ -261,6 +361,8 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
261 err = -EINVAL; 361 err = -EINVAL;
262 goto out; 362 goto out;
263 } 363 }
364 host->rsp_type = rsp_type;
365 host->rsp_len = rsp_len;
264 366
265 if (rsp_type == SD_RSP_TYPE_R1b) 367 if (rsp_type == SD_RSP_TYPE_R1b)
266 timeout = 3000; 368 timeout = 3000;
@@ -270,8 +372,6 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
270 0xFF, SD_CLK_TOGGLE_EN); 372 0xFF, SD_CLK_TOGGLE_EN);
271 if (err < 0) 373 if (err < 0)
272 goto out; 374 goto out;
273
274 clock_toggled = true;
275 } 375 }
276 376
277 rtsx_pci_init_cmd(pcr); 377 rtsx_pci_init_cmd(pcr);
@@ -295,25 +395,60 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
295 /* Read data from ping-pong buffer */ 395 /* Read data from ping-pong buffer */
296 for (i = PPBUF_BASE2; i < PPBUF_BASE2 + 16; i++) 396 for (i = PPBUF_BASE2; i < PPBUF_BASE2 + 16; i++)
297 rtsx_pci_add_cmd(pcr, READ_REG_CMD, (u16)i, 0, 0); 397 rtsx_pci_add_cmd(pcr, READ_REG_CMD, (u16)i, 0, 0);
298 stat_idx = 16;
299 } else if (rsp_type != SD_RSP_TYPE_R0) { 398 } else if (rsp_type != SD_RSP_TYPE_R0) {
300 /* Read data from SD_CMDx registers */ 399 /* Read data from SD_CMDx registers */
301 for (i = SD_CMD0; i <= SD_CMD4; i++) 400 for (i = SD_CMD0; i <= SD_CMD4; i++)
302 rtsx_pci_add_cmd(pcr, READ_REG_CMD, (u16)i, 0, 0); 401 rtsx_pci_add_cmd(pcr, READ_REG_CMD, (u16)i, 0, 0);
303 stat_idx = 5;
304 } 402 }
305 403
306 rtsx_pci_add_cmd(pcr, READ_REG_CMD, SD_STAT1, 0, 0); 404 rtsx_pci_add_cmd(pcr, READ_REG_CMD, SD_STAT1, 0, 0);
307 405
308 err = rtsx_pci_send_cmd(pcr, timeout); 406 mod_timer(&host->timer, jiffies + msecs_to_jiffies(timeout));
309 if (err < 0) { 407
310 sd_print_debug_regs(host); 408 spin_lock_irqsave(&pcr->lock, flags);
311 sd_clear_error(host); 409 pcr->trans_result = TRANS_NOT_READY;
312 dev_dbg(sdmmc_dev(host), 410 rtsx_pci_send_cmd_no_wait(pcr);
313 "rtsx_pci_send_cmd error (err = %d)\n", err); 411 spin_unlock_irqrestore(&pcr->lock, flags);
412
413 return;
414
415out:
416 cmd->error = err;
417 tasklet_schedule(&host->finish_tasklet);
418}
419
420static void sd_get_rsp(unsigned long host_addr)
421{
422 struct realtek_pci_sdmmc *host = (struct realtek_pci_sdmmc *)host_addr;
423 struct rtsx_pcr *pcr = host->pcr;
424 struct mmc_command *cmd;
425 int i, err = 0, stat_idx;
426 u8 *ptr, rsp_type;
427 unsigned long flags;
428
429 spin_lock_irqsave(&host->lock, flags);
430
431 cmd = host->cmd;
432 host->cmd = NULL;
433
434 if (!cmd) {
435 dev_err(sdmmc_dev(host), "error: cmd not exist\n");
314 goto out; 436 goto out;
315 } 437 }
316 438
439 spin_lock(&pcr->lock);
440 if (pcr->trans_result == TRANS_NO_DEVICE)
441 err = -ENODEV;
442 else if (pcr->trans_result != TRANS_RESULT_OK)
443 err = -EINVAL;
444 spin_unlock(&pcr->lock);
445
446 if (err < 0)
447 goto out;
448
449 rsp_type = host->rsp_type;
450 stat_idx = host->rsp_len;
451
317 if (rsp_type == SD_RSP_TYPE_R0) { 452 if (rsp_type == SD_RSP_TYPE_R0) {
318 err = 0; 453 err = 0;
319 goto out; 454 goto out;
@@ -350,26 +485,106 @@ static void sd_send_cmd_get_rsp(struct realtek_pci_sdmmc *host,
350 cmd->resp[0]); 485 cmd->resp[0]);
351 } 486 }
352 487
488 if (cmd == host->mrq->sbc) {
489 sd_send_cmd(host, host->mrq->cmd);
490 spin_unlock_irqrestore(&host->lock, flags);
491 return;
492 }
493
494 if (cmd == host->mrq->stop)
495 goto out;
496
497 if (cmd->data) {
498 sd_start_multi_rw(host, host->mrq);
499 spin_unlock_irqrestore(&host->lock, flags);
500 return;
501 }
502
353out: 503out:
354 cmd->error = err; 504 cmd->error = err;
355 505
356 if (err && clock_toggled) 506 tasklet_schedule(&host->finish_tasklet);
357 rtsx_pci_write_register(pcr, SD_BUS_STAT, 507 spin_unlock_irqrestore(&host->lock, flags);
358 SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
359} 508}
360 509
361static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq) 510static int sd_pre_dma_transfer(struct realtek_pci_sdmmc *host,
511 struct mmc_data *data, struct realtek_next *next)
512{
513 struct rtsx_pcr *pcr = host->pcr;
514 int read = data->flags & MMC_DATA_READ;
515 int sg_count = 0;
516
517 if (!next && data->host_cookie &&
518 data->host_cookie != host->next_data.cookie) {
519 dev_err(sdmmc_dev(host),
520 "error: invalid cookie data[%d] host[%d]\n",
521 data->host_cookie, host->next_data.cookie);
522 data->host_cookie = 0;
523 }
524
525 if (next || (!next && data->host_cookie != host->next_data.cookie))
526 sg_count = rtsx_pci_dma_map_sg(pcr,
527 data->sg, data->sg_len, read);
528 else
529 sg_count = host->next_data.sg_count;
530
531 if (next) {
532 next->sg_count = sg_count;
533 if (++next->cookie < 0)
534 next->cookie = 1;
535 data->host_cookie = next->cookie;
536 }
537
538 return sg_count;
539}
540
541static void sdmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq,
542 bool is_first_req)
543{
544 struct realtek_pci_sdmmc *host = mmc_priv(mmc);
545 struct mmc_data *data = mrq->data;
546
547 if (data->host_cookie) {
548 dev_err(sdmmc_dev(host),
549 "error: descard already cookie data[%d]\n",
550 data->host_cookie);
551 data->host_cookie = 0;
552 }
553
554 dev_dbg(sdmmc_dev(host), "dma sg prepared: %d\n",
555 sd_pre_dma_transfer(host, data, &host->next_data));
556}
557
558static void sdmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
559 int err)
560{
561 struct realtek_pci_sdmmc *host = mmc_priv(mmc);
562 struct rtsx_pcr *pcr = host->pcr;
563 struct mmc_data *data = mrq->data;
564 int read = data->flags & MMC_DATA_READ;
565
566 rtsx_pci_dma_unmap_sg(pcr, data->sg, data->sg_len, read);
567 data->host_cookie = 0;
568}
569
570static int sd_start_multi_rw(struct realtek_pci_sdmmc *host,
571 struct mmc_request *mrq)
362{ 572{
363 struct rtsx_pcr *pcr = host->pcr; 573 struct rtsx_pcr *pcr = host->pcr;
364 struct mmc_host *mmc = host->mmc; 574 struct mmc_host *mmc = host->mmc;
365 struct mmc_card *card = mmc->card; 575 struct mmc_card *card = mmc->card;
366 struct mmc_data *data = mrq->data; 576 struct mmc_data *data = mrq->data;
367 int uhs = mmc_card_uhs(card); 577 int uhs = mmc_card_uhs(card);
368 int read = (data->flags & MMC_DATA_READ) ? 1 : 0; 578 int read = data->flags & MMC_DATA_READ;
369 u8 cfg2, trans_mode; 579 u8 cfg2, trans_mode;
370 int err; 580 int err;
371 size_t data_len = data->blksz * data->blocks; 581 size_t data_len = data->blksz * data->blocks;
372 582
583 if (host->data)
584 dev_err(sdmmc_dev(host), "error: data already exist\n");
585
586 host->data = data;
587
373 if (read) { 588 if (read) {
374 cfg2 = SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | 589 cfg2 = SD_CALCULATE_CRC7 | SD_CHECK_CRC16 |
375 SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_0; 590 SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_0;
@@ -420,17 +635,56 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
420 rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER, 635 rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER,
421 SD_TRANSFER_END, SD_TRANSFER_END); 636 SD_TRANSFER_END, SD_TRANSFER_END);
422 637
638 mod_timer(&host->timer, jiffies + 10 * HZ);
423 rtsx_pci_send_cmd_no_wait(pcr); 639 rtsx_pci_send_cmd_no_wait(pcr);
424 640
425 err = rtsx_pci_transfer_data(pcr, data->sg, data->sg_len, read, 10000); 641 err = rtsx_pci_dma_transfer(pcr, data->sg, host->sg_count, read);
426 if (err < 0) { 642 if (err < 0) {
427 sd_clear_error(host); 643 data->error = err;
428 return err; 644 tasklet_schedule(&host->finish_tasklet);
429 } 645 }
430
431 return 0; 646 return 0;
432} 647}
433 648
649static void sd_finish_multi_rw(unsigned long host_addr)
650{
651 struct realtek_pci_sdmmc *host = (struct realtek_pci_sdmmc *)host_addr;
652 struct rtsx_pcr *pcr = host->pcr;
653 struct mmc_data *data;
654 int err = 0;
655 unsigned long flags;
656
657 spin_lock_irqsave(&host->lock, flags);
658
659 if (!host->data) {
660 dev_err(sdmmc_dev(host), "error: no data exist\n");
661 goto out;
662 }
663
664 data = host->data;
665 host->data = NULL;
666
667 if (pcr->trans_result == TRANS_NO_DEVICE)
668 err = -ENODEV;
669 else if (pcr->trans_result != TRANS_RESULT_OK)
670 err = -EINVAL;
671
672 if (err < 0) {
673 data->error = err;
674 goto out;
675 }
676
677 if (!host->mrq->sbc && data->stop) {
678 sd_send_cmd(host, data->stop);
679 spin_unlock_irqrestore(&host->lock, flags);
680 return;
681 }
682
683out:
684 tasklet_schedule(&host->finish_tasklet);
685 spin_unlock_irqrestore(&host->lock, flags);
686}
687
434static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host) 688static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
435{ 689{
436 rtsx_pci_write_register(host->pcr, SD_CFG1, 690 rtsx_pci_write_register(host->pcr, SD_CFG1,
@@ -511,85 +765,47 @@ static int sd_change_phase(struct realtek_pci_sdmmc *host,
511 return 0; 765 return 0;
512} 766}
513 767
514static u8 sd_search_final_phase(struct realtek_pci_sdmmc *host, u32 phase_map) 768static inline u32 test_phase_bit(u32 phase_map, unsigned int bit)
515{ 769{
516 struct timing_phase_path path[MAX_PHASE + 1]; 770 bit %= RTSX_PHASE_MAX;
517 int i, j, cont_path_cnt; 771 return phase_map & (1 << bit);
518 int new_block, max_len, final_path_idx; 772}
519 u8 final_phase = 0xFF;
520 773
521 /* Parse phase_map, take it as a bit-ring */ 774static int sd_get_phase_len(u32 phase_map, unsigned int start_bit)
522 cont_path_cnt = 0; 775{
523 new_block = 1; 776 int i;
524 j = 0;
525 for (i = 0; i < MAX_PHASE + 1; i++) {
526 if (phase_map & (1 << i)) {
527 if (new_block) {
528 new_block = 0;
529 j = cont_path_cnt++;
530 path[j].start = i;
531 path[j].end = i;
532 } else {
533 path[j].end = i;
534 }
535 } else {
536 new_block = 1;
537 if (cont_path_cnt) {
538 /* Calculate path length and middle point */
539 int idx = cont_path_cnt - 1;
540 path[idx].len =
541 path[idx].end - path[idx].start + 1;
542 path[idx].mid =
543 path[idx].start + path[idx].len / 2;
544 }
545 }
546 }
547 777
548 if (cont_path_cnt == 0) { 778 for (i = 0; i < RTSX_PHASE_MAX; i++) {
549 dev_dbg(sdmmc_dev(host), "No continuous phase path\n"); 779 if (test_phase_bit(phase_map, start_bit + i) == 0)
550 goto finish; 780 return i;
551 } else {
552 /* Calculate last continuous path length and middle point */
553 int idx = cont_path_cnt - 1;
554 path[idx].len = path[idx].end - path[idx].start + 1;
555 path[idx].mid = path[idx].start + path[idx].len / 2;
556 } 781 }
782 return RTSX_PHASE_MAX;
783}
784
785static u8 sd_search_final_phase(struct realtek_pci_sdmmc *host, u32 phase_map)
786{
787 int start = 0, len = 0;
788 int start_final = 0, len_final = 0;
789 u8 final_phase = 0xFF;
557 790
558 /* Connect the first and last continuous paths if they are adjacent */ 791 if (phase_map == 0) {
559 if (!path[0].start && (path[cont_path_cnt - 1].end == MAX_PHASE)) { 792 dev_err(sdmmc_dev(host), "phase error: [map:%x]\n", phase_map);
560 /* Using negative index */ 793 return final_phase;
561 path[0].start = path[cont_path_cnt - 1].start - MAX_PHASE - 1;
562 path[0].len += path[cont_path_cnt - 1].len;
563 path[0].mid = path[0].start + path[0].len / 2;
564 /* Convert negative middle point index to positive one */
565 if (path[0].mid < 0)
566 path[0].mid += MAX_PHASE + 1;
567 cont_path_cnt--;
568 } 794 }
569 795
570 /* Choose the longest continuous phase path */ 796 while (start < RTSX_PHASE_MAX) {
571 max_len = 0; 797 len = sd_get_phase_len(phase_map, start);
572 final_phase = 0; 798 if (len_final < len) {
573 final_path_idx = 0; 799 start_final = start;
574 for (i = 0; i < cont_path_cnt; i++) { 800 len_final = len;
575 if (path[i].len > max_len) {
576 max_len = path[i].len;
577 final_phase = (u8)path[i].mid;
578 final_path_idx = i;
579 } 801 }
580 802 start += len ? len : 1;
581 dev_dbg(sdmmc_dev(host), "path[%d].start = %d\n",
582 i, path[i].start);
583 dev_dbg(sdmmc_dev(host), "path[%d].end = %d\n",
584 i, path[i].end);
585 dev_dbg(sdmmc_dev(host), "path[%d].len = %d\n",
586 i, path[i].len);
587 dev_dbg(sdmmc_dev(host), "path[%d].mid = %d\n",
588 i, path[i].mid);
589 } 803 }
590 804
591finish: 805 final_phase = (start_final + len_final / 2) % RTSX_PHASE_MAX;
592 dev_dbg(sdmmc_dev(host), "Final chosen phase: %d\n", final_phase); 806 dev_dbg(sdmmc_dev(host), "phase: [map:%x] [maxlen:%d] [final:%d]\n",
807 phase_map, len_final, final_phase);
808
593 return final_phase; 809 return final_phase;
594} 810}
595 811
@@ -635,7 +851,7 @@ static int sd_tuning_phase(struct realtek_pci_sdmmc *host,
635 int err, i; 851 int err, i;
636 u32 raw_phase_map = 0; 852 u32 raw_phase_map = 0;
637 853
638 for (i = MAX_PHASE; i >= 0; i--) { 854 for (i = 0; i < RTSX_PHASE_MAX; i++) {
639 err = sd_tuning_rx_cmd(host, opcode, (u8)i); 855 err = sd_tuning_rx_cmd(host, opcode, (u8)i);
640 if (err == 0) 856 if (err == 0)
641 raw_phase_map |= 1 << i; 857 raw_phase_map |= 1 << i;
@@ -685,6 +901,13 @@ static int sd_tuning_rx(struct realtek_pci_sdmmc *host, u8 opcode)
685 return 0; 901 return 0;
686} 902}
687 903
904static inline bool sd_use_muti_rw(struct mmc_command *cmd)
905{
906 return mmc_op_multi(cmd->opcode) ||
907 (cmd->opcode == MMC_READ_SINGLE_BLOCK) ||
908 (cmd->opcode == MMC_WRITE_BLOCK);
909}
910
688static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq) 911static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
689{ 912{
690 struct realtek_pci_sdmmc *host = mmc_priv(mmc); 913 struct realtek_pci_sdmmc *host = mmc_priv(mmc);
@@ -693,6 +916,14 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
693 struct mmc_data *data = mrq->data; 916 struct mmc_data *data = mrq->data;
694 unsigned int data_size = 0; 917 unsigned int data_size = 0;
695 int err; 918 int err;
919 unsigned long flags;
920
921 mutex_lock(&pcr->pcr_mutex);
922 spin_lock_irqsave(&host->lock, flags);
923
924 if (host->mrq)
925 dev_err(sdmmc_dev(host), "error: request already exist\n");
926 host->mrq = mrq;
696 927
697 if (host->eject) { 928 if (host->eject) {
698 cmd->error = -ENOMEDIUM; 929 cmd->error = -ENOMEDIUM;
@@ -705,8 +936,6 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
705 goto finish; 936 goto finish;
706 } 937 }
707 938
708 mutex_lock(&pcr->pcr_mutex);
709
710 rtsx_pci_start_run(pcr); 939 rtsx_pci_start_run(pcr);
711 940
712 rtsx_pci_switch_clock(pcr, host->clock, host->ssc_depth, 941 rtsx_pci_switch_clock(pcr, host->clock, host->ssc_depth,
@@ -715,46 +944,28 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
715 rtsx_pci_write_register(pcr, CARD_SHARE_MODE, 944 rtsx_pci_write_register(pcr, CARD_SHARE_MODE,
716 CARD_SHARE_MASK, CARD_SHARE_48_SD); 945 CARD_SHARE_MASK, CARD_SHARE_48_SD);
717 946
718 mutex_lock(&host->host_mutex);
719 host->mrq = mrq;
720 mutex_unlock(&host->host_mutex);
721
722 if (mrq->data) 947 if (mrq->data)
723 data_size = data->blocks * data->blksz; 948 data_size = data->blocks * data->blksz;
724 949
725 if (!data_size || mmc_op_multi(cmd->opcode) || 950 if (sd_use_muti_rw(cmd))
726 (cmd->opcode == MMC_READ_SINGLE_BLOCK) || 951 host->sg_count = sd_pre_dma_transfer(host, data, NULL);
727 (cmd->opcode == MMC_WRITE_BLOCK)) {
728 sd_send_cmd_get_rsp(host, cmd);
729
730 if (!cmd->error && data_size) {
731 sd_rw_multi(host, mrq);
732 952
733 if (mmc_op_multi(cmd->opcode) && mrq->stop) 953 if (!data_size || sd_use_muti_rw(cmd)) {
734 sd_send_cmd_get_rsp(host, mrq->stop); 954 if (mrq->sbc)
735 } 955 sd_send_cmd(host, mrq->sbc);
956 else
957 sd_send_cmd(host, cmd);
958 spin_unlock_irqrestore(&host->lock, flags);
736 } else { 959 } else {
960 spin_unlock_irqrestore(&host->lock, flags);
737 sd_normal_rw(host, mrq); 961 sd_normal_rw(host, mrq);
962 tasklet_schedule(&host->finish_tasklet);
738 } 963 }
739 964 return;
740 if (mrq->data) {
741 if (cmd->error || data->error)
742 data->bytes_xfered = 0;
743 else
744 data->bytes_xfered = data->blocks * data->blksz;
745 }
746
747 mutex_unlock(&pcr->pcr_mutex);
748 965
749finish: 966finish:
750 if (cmd->error) 967 tasklet_schedule(&host->finish_tasklet);
751 dev_dbg(sdmmc_dev(host), "cmd->error = %d\n", cmd->error); 968 spin_unlock_irqrestore(&host->lock, flags);
752
753 mutex_lock(&host->host_mutex);
754 host->mrq = NULL;
755 mutex_unlock(&host->host_mutex);
756
757 mmc_request_done(mmc, mrq);
758} 969}
759 970
760static int sd_set_bus_width(struct realtek_pci_sdmmc *host, 971static int sd_set_bus_width(struct realtek_pci_sdmmc *host,
@@ -1189,6 +1400,8 @@ out:
1189} 1400}
1190 1401
1191static const struct mmc_host_ops realtek_pci_sdmmc_ops = { 1402static const struct mmc_host_ops realtek_pci_sdmmc_ops = {
1403 .pre_req = sdmmc_pre_req,
1404 .post_req = sdmmc_post_req,
1192 .request = sdmmc_request, 1405 .request = sdmmc_request,
1193 .set_ios = sdmmc_set_ios, 1406 .set_ios = sdmmc_set_ios,
1194 .get_ro = sdmmc_get_ro, 1407 .get_ro = sdmmc_get_ro,
@@ -1252,6 +1465,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
1252 struct realtek_pci_sdmmc *host; 1465 struct realtek_pci_sdmmc *host;
1253 struct rtsx_pcr *pcr; 1466 struct rtsx_pcr *pcr;
1254 struct pcr_handle *handle = pdev->dev.platform_data; 1467 struct pcr_handle *handle = pdev->dev.platform_data;
1468 unsigned long host_addr;
1255 1469
1256 if (!handle) 1470 if (!handle)
1257 return -ENXIO; 1471 return -ENXIO;
@@ -1275,8 +1489,15 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
1275 pcr->slots[RTSX_SD_CARD].p_dev = pdev; 1489 pcr->slots[RTSX_SD_CARD].p_dev = pdev;
1276 pcr->slots[RTSX_SD_CARD].card_event = rtsx_pci_sdmmc_card_event; 1490 pcr->slots[RTSX_SD_CARD].card_event = rtsx_pci_sdmmc_card_event;
1277 1491
1278 mutex_init(&host->host_mutex); 1492 host_addr = (unsigned long)host;
1493 host->next_data.cookie = 1;
1494 setup_timer(&host->timer, sd_request_timeout, host_addr);
1495 tasklet_init(&host->cmd_tasklet, sd_get_rsp, host_addr);
1496 tasklet_init(&host->data_tasklet, sd_finish_multi_rw, host_addr);
1497 tasklet_init(&host->finish_tasklet, sd_finish_request, host_addr);
1498 spin_lock_init(&host->lock);
1279 1499
1500 pcr->slots[RTSX_SD_CARD].done_transfer = sd_isr_done_transfer;
1280 realtek_init_host(host); 1501 realtek_init_host(host);
1281 1502
1282 mmc_add_host(mmc); 1503 mmc_add_host(mmc);
@@ -1289,6 +1510,8 @@ static int rtsx_pci_sdmmc_drv_remove(struct platform_device *pdev)
1289 struct realtek_pci_sdmmc *host = platform_get_drvdata(pdev); 1510 struct realtek_pci_sdmmc *host = platform_get_drvdata(pdev);
1290 struct rtsx_pcr *pcr; 1511 struct rtsx_pcr *pcr;
1291 struct mmc_host *mmc; 1512 struct mmc_host *mmc;
1513 struct mmc_request *mrq;
1514 unsigned long flags;
1292 1515
1293 if (!host) 1516 if (!host)
1294 return 0; 1517 return 0;
@@ -1296,25 +1519,37 @@ static int rtsx_pci_sdmmc_drv_remove(struct platform_device *pdev)
1296 pcr = host->pcr; 1519 pcr = host->pcr;
1297 pcr->slots[RTSX_SD_CARD].p_dev = NULL; 1520 pcr->slots[RTSX_SD_CARD].p_dev = NULL;
1298 pcr->slots[RTSX_SD_CARD].card_event = NULL; 1521 pcr->slots[RTSX_SD_CARD].card_event = NULL;
1522 pcr->slots[RTSX_SD_CARD].done_transfer = NULL;
1299 mmc = host->mmc; 1523 mmc = host->mmc;
1300 host->eject = true; 1524 mrq = host->mrq;
1301 1525
1302 mutex_lock(&host->host_mutex); 1526 spin_lock_irqsave(&host->lock, flags);
1303 if (host->mrq) { 1527 if (host->mrq) {
1304 dev_dbg(&(pdev->dev), 1528 dev_dbg(&(pdev->dev),
1305 "%s: Controller removed during transfer\n", 1529 "%s: Controller removed during transfer\n",
1306 mmc_hostname(mmc)); 1530 mmc_hostname(mmc));
1307 1531
1308 rtsx_pci_complete_unfinished_transfer(pcr); 1532 if (mrq->sbc)
1533 mrq->sbc->error = -ENOMEDIUM;
1534 if (mrq->cmd)
1535 mrq->cmd->error = -ENOMEDIUM;
1536 if (mrq->stop)
1537 mrq->stop->error = -ENOMEDIUM;
1538 if (mrq->data)
1539 mrq->data->error = -ENOMEDIUM;
1309 1540
1310 host->mrq->cmd->error = -ENOMEDIUM; 1541 tasklet_schedule(&host->finish_tasklet);
1311 if (host->mrq->stop)
1312 host->mrq->stop->error = -ENOMEDIUM;
1313 mmc_request_done(mmc, host->mrq);
1314 } 1542 }
1315 mutex_unlock(&host->host_mutex); 1543 spin_unlock_irqrestore(&host->lock, flags);
1544
1545 del_timer_sync(&host->timer);
1546 tasklet_kill(&host->cmd_tasklet);
1547 tasklet_kill(&host->data_tasklet);
1548 tasklet_kill(&host->finish_tasklet);
1316 1549
1317 mmc_remove_host(mmc); 1550 mmc_remove_host(mmc);
1551 host->eject = true;
1552
1318 mmc_free_host(mmc); 1553 mmc_free_host(mmc);
1319 1554
1320 dev_dbg(&(pdev->dev), 1555 dev_dbg(&(pdev->dev),
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 9ce17f6e4014..ebb3f392b589 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -31,7 +31,6 @@
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/gpio/consumer.h>
35#include <linux/interrupt.h> 34#include <linux/interrupt.h>
36#include <linux/acpi.h> 35#include <linux/acpi.h>
37#include <linux/pm.h> 36#include <linux/pm.h>
@@ -40,13 +39,15 @@
40 39
41#include <linux/mmc/host.h> 40#include <linux/mmc/host.h>
42#include <linux/mmc/pm.h> 41#include <linux/mmc/pm.h>
42#include <linux/mmc/slot-gpio.h>
43#include <linux/mmc/sdhci.h> 43#include <linux/mmc/sdhci.h>
44 44
45#include "sdhci.h" 45#include "sdhci.h"
46 46
47enum { 47enum {
48 SDHCI_ACPI_SD_CD = BIT(0), 48 SDHCI_ACPI_SD_CD = BIT(0),
49 SDHCI_ACPI_RUNTIME_PM = BIT(1), 49 SDHCI_ACPI_RUNTIME_PM = BIT(1),
50 SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL = BIT(2),
50}; 51};
51 52
52struct sdhci_acpi_chip { 53struct sdhci_acpi_chip {
@@ -121,6 +122,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
121}; 122};
122 123
123static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = { 124static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
125 .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
124 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, 126 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
125 .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD, 127 .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD,
126 .flags = SDHCI_ACPI_RUNTIME_PM, 128 .flags = SDHCI_ACPI_RUNTIME_PM,
@@ -128,7 +130,8 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
128}; 130};
129 131
130static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = { 132static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
131 .flags = SDHCI_ACPI_SD_CD | SDHCI_ACPI_RUNTIME_PM, 133 .flags = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL |
134 SDHCI_ACPI_RUNTIME_PM,
132 .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON, 135 .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON,
133}; 136};
134 137
@@ -141,6 +144,7 @@ struct sdhci_acpi_uid_slot {
141static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = { 144static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
142 { "80860F14" , "1" , &sdhci_acpi_slot_int_emmc }, 145 { "80860F14" , "1" , &sdhci_acpi_slot_int_emmc },
143 { "80860F14" , "3" , &sdhci_acpi_slot_int_sd }, 146 { "80860F14" , "3" , &sdhci_acpi_slot_int_sd },
147 { "80860F16" , NULL, &sdhci_acpi_slot_int_sd },
144 { "INT33BB" , "2" , &sdhci_acpi_slot_int_sdio }, 148 { "INT33BB" , "2" , &sdhci_acpi_slot_int_sdio },
145 { "INT33C6" , NULL, &sdhci_acpi_slot_int_sdio }, 149 { "INT33C6" , NULL, &sdhci_acpi_slot_int_sdio },
146 { "INT3436" , NULL, &sdhci_acpi_slot_int_sdio }, 150 { "INT3436" , NULL, &sdhci_acpi_slot_int_sdio },
@@ -150,6 +154,7 @@ static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
150 154
151static const struct acpi_device_id sdhci_acpi_ids[] = { 155static const struct acpi_device_id sdhci_acpi_ids[] = {
152 { "80860F14" }, 156 { "80860F14" },
157 { "80860F16" },
153 { "INT33BB" }, 158 { "INT33BB" },
154 { "INT33C6" }, 159 { "INT33C6" },
155 { "INT3436" }, 160 { "INT3436" },
@@ -192,59 +197,6 @@ static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(acpi_handle handle,
192 return slot; 197 return slot;
193} 198}
194 199
195#ifdef CONFIG_PM_RUNTIME
196
197static irqreturn_t sdhci_acpi_sd_cd(int irq, void *dev_id)
198{
199 mmc_detect_change(dev_id, msecs_to_jiffies(200));
200 return IRQ_HANDLED;
201}
202
203static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc)
204{
205 struct gpio_desc *desc;
206 unsigned long flags;
207 int err, irq;
208
209 desc = devm_gpiod_get_index(dev, "sd_cd", 0);
210 if (IS_ERR(desc)) {
211 err = PTR_ERR(desc);
212 goto out;
213 }
214
215 err = gpiod_direction_input(desc);
216 if (err)
217 goto out_free;
218
219 irq = gpiod_to_irq(desc);
220 if (irq < 0) {
221 err = irq;
222 goto out_free;
223 }
224
225 flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
226 err = devm_request_irq(dev, irq, sdhci_acpi_sd_cd, flags, "sd_cd", mmc);
227 if (err)
228 goto out_free;
229
230 return 0;
231
232out_free:
233 devm_gpiod_put(dev, desc);
234out:
235 dev_warn(dev, "failed to setup card detect wake up\n");
236 return err;
237}
238
239#else
240
241static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc)
242{
243 return 0;
244}
245
246#endif
247
248static int sdhci_acpi_probe(struct platform_device *pdev) 200static int sdhci_acpi_probe(struct platform_device *pdev)
249{ 201{
250 struct device *dev = &pdev->dev; 202 struct device *dev = &pdev->dev;
@@ -332,15 +284,19 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
332 284
333 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; 285 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
334 286
335 err = sdhci_add_host(host);
336 if (err)
337 goto err_free;
338
339 if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) { 287 if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
340 if (sdhci_acpi_add_own_cd(dev, host->mmc)) 288 bool v = sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL);
289
290 if (mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0)) {
291 dev_warn(dev, "failed to setup card detect gpio\n");
341 c->use_runtime_pm = false; 292 c->use_runtime_pm = false;
293 }
342 } 294 }
343 295
296 err = sdhci_add_host(host);
297 if (err)
298 goto err_free;
299
344 if (c->use_runtime_pm) { 300 if (c->use_runtime_pm) {
345 pm_runtime_set_active(dev); 301 pm_runtime_set_active(dev);
346 pm_suspend_ignore_children(dev, 1); 302 pm_suspend_ignore_children(dev, 1);
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 7a190fe4dff1..6f166e63b817 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -54,6 +54,7 @@
54 54
55struct sdhci_bcm_kona_dev { 55struct sdhci_bcm_kona_dev {
56 struct mutex write_lock; /* protect back to back writes */ 56 struct mutex write_lock; /* protect back to back writes */
57 struct clk *external_clk;
57}; 58};
58 59
59 60
@@ -257,6 +258,24 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
257 goto err_pltfm_free; 258 goto err_pltfm_free;
258 } 259 }
259 260
261 /* Get and enable the external clock */
262 kona_dev->external_clk = devm_clk_get(dev, NULL);
263 if (IS_ERR(kona_dev->external_clk)) {
264 dev_err(dev, "Failed to get external clock\n");
265 ret = PTR_ERR(kona_dev->external_clk);
266 goto err_pltfm_free;
267 }
268
269 if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
270 dev_err(dev, "Failed to set rate external clock\n");
271 goto err_pltfm_free;
272 }
273
274 if (clk_prepare_enable(kona_dev->external_clk) != 0) {
275 dev_err(dev, "Failed to enable external clock\n");
276 goto err_pltfm_free;
277 }
278
260 dev_dbg(dev, "non-removable=%c\n", 279 dev_dbg(dev, "non-removable=%c\n",
261 (host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N'); 280 (host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N');
262 dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n", 281 dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n",
@@ -271,7 +290,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
271 290
272 ret = sdhci_bcm_kona_sd_reset(host); 291 ret = sdhci_bcm_kona_sd_reset(host);
273 if (ret) 292 if (ret)
274 goto err_pltfm_free; 293 goto err_clk_disable;
275 294
276 sdhci_bcm_kona_sd_init(host); 295 sdhci_bcm_kona_sd_init(host);
277 296
@@ -307,6 +326,9 @@ err_remove_host:
307err_reset: 326err_reset:
308 sdhci_bcm_kona_sd_reset(host); 327 sdhci_bcm_kona_sd_reset(host);
309 328
329err_clk_disable:
330 clk_disable_unprepare(kona_dev->external_clk);
331
310err_pltfm_free: 332err_pltfm_free:
311 sdhci_pltfm_free(pdev); 333 sdhci_pltfm_free(pdev);
312 334
@@ -314,9 +336,20 @@ err_pltfm_free:
314 return ret; 336 return ret;
315} 337}
316 338
317static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) 339static int sdhci_bcm_kona_remove(struct platform_device *pdev)
318{ 340{
319 return sdhci_pltfm_unregister(pdev); 341 struct sdhci_host *host = platform_get_drvdata(pdev);
342 struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
343 struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv);
344 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
345
346 sdhci_remove_host(host, dead);
347
348 clk_disable_unprepare(kona_dev->external_clk);
349
350 sdhci_pltfm_free(pdev);
351
352 return 0;
320} 353}
321 354
322static struct platform_driver sdhci_bcm_kona_driver = { 355static struct platform_driver sdhci_bcm_kona_driver = {
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 8424839660f8..736d7a2eb7ec 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -208,7 +208,7 @@ static struct platform_driver sdhci_dove_driver = {
208 .name = "sdhci-dove", 208 .name = "sdhci-dove",
209 .owner = THIS_MODULE, 209 .owner = THIS_MODULE,
210 .pm = SDHCI_PLTFM_PMOPS, 210 .pm = SDHCI_PLTFM_PMOPS,
211 .of_match_table = of_match_ptr(sdhci_dove_of_match_table), 211 .of_match_table = sdhci_dove_of_match_table,
212 }, 212 },
213 .probe = sdhci_dove_probe, 213 .probe = sdhci_dove_probe,
214 .remove = sdhci_dove_remove, 214 .remove = sdhci_dove_remove,
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
new file mode 100644
index 000000000000..acb0e9eb55f1
--- /dev/null
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -0,0 +1,618 @@
1/*
2 * drivers/mmc/host/sdhci-msm.c - Qualcomm SDHCI Platform driver
3 *
4 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
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 and
8 * only version 2 as 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/module.h>
18#include <linux/of_device.h>
19#include <linux/regulator/consumer.h>
20#include <linux/delay.h>
21#include <linux/mmc/mmc.h>
22#include <linux/slab.h>
23
24#include "sdhci-pltfm.h"
25
26#define CORE_HC_MODE 0x78
27#define HC_MODE_EN 0x1
28#define CORE_POWER 0x0
29#define CORE_SW_RST BIT(7)
30
31#define MAX_PHASES 16
32#define CORE_DLL_LOCK BIT(7)
33#define CORE_DLL_EN BIT(16)
34#define CORE_CDR_EN BIT(17)
35#define CORE_CK_OUT_EN BIT(18)
36#define CORE_CDR_EXT_EN BIT(19)
37#define CORE_DLL_PDN BIT(29)
38#define CORE_DLL_RST BIT(30)
39#define CORE_DLL_CONFIG 0x100
40#define CORE_DLL_STATUS 0x108
41
42#define CORE_VENDOR_SPEC 0x10c
43#define CORE_CLK_PWRSAVE BIT(1)
44
45#define CDR_SELEXT_SHIFT 20
46#define CDR_SELEXT_MASK (0xf << CDR_SELEXT_SHIFT)
47#define CMUX_SHIFT_PHASE_SHIFT 24
48#define CMUX_SHIFT_PHASE_MASK (7 << CMUX_SHIFT_PHASE_SHIFT)
49
50static const u32 tuning_block_64[] = {
51 0x00ff0fff, 0xccc3ccff, 0xffcc3cc3, 0xeffefffe,
52 0xddffdfff, 0xfbfffbff, 0xff7fffbf, 0xefbdf777,
53 0xf0fff0ff, 0x3cccfc0f, 0xcfcc33cc, 0xeeffefff,
54 0xfdfffdff, 0xffbfffdf, 0xfff7ffbb, 0xde7b7ff7
55};
56
57static const u32 tuning_block_128[] = {
58 0xff00ffff, 0x0000ffff, 0xccccffff, 0xcccc33cc,
59 0xcc3333cc, 0xffffcccc, 0xffffeeff, 0xffeeeeff,
60 0xffddffff, 0xddddffff, 0xbbffffff, 0xbbffffff,
61 0xffffffbb, 0xffffff77, 0x77ff7777, 0xffeeddbb,
62 0x00ffffff, 0x00ffffff, 0xccffff00, 0xcc33cccc,
63 0x3333cccc, 0xffcccccc, 0xffeeffff, 0xeeeeffff,
64 0xddffffff, 0xddffffff, 0xffffffdd, 0xffffffbb,
65 0xffffbbbb, 0xffff77ff, 0xff7777ff, 0xeeddbb77
66};
67
68struct sdhci_msm_host {
69 struct platform_device *pdev;
70 void __iomem *core_mem; /* MSM SDCC mapped address */
71 struct clk *clk; /* main SD/MMC bus clock */
72 struct clk *pclk; /* SDHC peripheral bus clock */
73 struct clk *bus_clk; /* SDHC bus voter clock */
74 struct mmc_host *mmc;
75 struct sdhci_pltfm_data sdhci_msm_pdata;
76};
77
78/* Platform specific tuning */
79static inline int msm_dll_poll_ck_out_en(struct sdhci_host *host, u8 poll)
80{
81 u32 wait_cnt = 50;
82 u8 ck_out_en;
83 struct mmc_host *mmc = host->mmc;
84
85 /* Poll for CK_OUT_EN bit. max. poll time = 50us */
86 ck_out_en = !!(readl_relaxed(host->ioaddr + CORE_DLL_CONFIG) &
87 CORE_CK_OUT_EN);
88
89 while (ck_out_en != poll) {
90 if (--wait_cnt == 0) {
91 dev_err(mmc_dev(mmc), "%s: CK_OUT_EN bit is not %d\n",
92 mmc_hostname(mmc), poll);
93 return -ETIMEDOUT;
94 }
95 udelay(1);
96
97 ck_out_en = !!(readl_relaxed(host->ioaddr + CORE_DLL_CONFIG) &
98 CORE_CK_OUT_EN);
99 }
100
101 return 0;
102}
103
104static int msm_config_cm_dll_phase(struct sdhci_host *host, u8 phase)
105{
106 int rc;
107 static const u8 grey_coded_phase_table[] = {
108 0x0, 0x1, 0x3, 0x2, 0x6, 0x7, 0x5, 0x4,
109 0xc, 0xd, 0xf, 0xe, 0xa, 0xb, 0x9, 0x8
110 };
111 unsigned long flags;
112 u32 config;
113 struct mmc_host *mmc = host->mmc;
114
115 spin_lock_irqsave(&host->lock, flags);
116
117 config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG);
118 config &= ~(CORE_CDR_EN | CORE_CK_OUT_EN);
119 config |= (CORE_CDR_EXT_EN | CORE_DLL_EN);
120 writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG);
121
122 /* Wait until CK_OUT_EN bit of DLL_CONFIG register becomes '0' */
123 rc = msm_dll_poll_ck_out_en(host, 0);
124 if (rc)
125 goto err_out;
126
127 /*
128 * Write the selected DLL clock output phase (0 ... 15)
129 * to CDR_SELEXT bit field of DLL_CONFIG register.
130 */
131 config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG);
132 config &= ~CDR_SELEXT_MASK;
133 config |= grey_coded_phase_table[phase] << CDR_SELEXT_SHIFT;
134 writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG);
135
136 /* Set CK_OUT_EN bit of DLL_CONFIG register to 1. */
137 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
138 | CORE_CK_OUT_EN), host->ioaddr + CORE_DLL_CONFIG);
139
140 /* Wait until CK_OUT_EN bit of DLL_CONFIG register becomes '1' */
141 rc = msm_dll_poll_ck_out_en(host, 1);
142 if (rc)
143 goto err_out;
144
145 config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG);
146 config |= CORE_CDR_EN;
147 config &= ~CORE_CDR_EXT_EN;
148 writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG);
149 goto out;
150
151err_out:
152 dev_err(mmc_dev(mmc), "%s: Failed to set DLL phase: %d\n",
153 mmc_hostname(mmc), phase);
154out:
155 spin_unlock_irqrestore(&host->lock, flags);
156 return rc;
157}
158
159/*
160 * Find out the greatest range of consecuitive selected
161 * DLL clock output phases that can be used as sampling
162 * setting for SD3.0 UHS-I card read operation (in SDR104
163 * timing mode) or for eMMC4.5 card read operation (in HS200
164 * timing mode).
165 * Select the 3/4 of the range and configure the DLL with the
166 * selected DLL clock output phase.
167 */
168
169static int msm_find_most_appropriate_phase(struct sdhci_host *host,
170 u8 *phase_table, u8 total_phases)
171{
172 int ret;
173 u8 ranges[MAX_PHASES][MAX_PHASES] = { {0}, {0} };
174 u8 phases_per_row[MAX_PHASES] = { 0 };
175 int row_index = 0, col_index = 0, selected_row_index = 0, curr_max = 0;
176 int i, cnt, phase_0_raw_index = 0, phase_15_raw_index = 0;
177 bool phase_0_found = false, phase_15_found = false;
178 struct mmc_host *mmc = host->mmc;
179
180 if (!total_phases || (total_phases > MAX_PHASES)) {
181 dev_err(mmc_dev(mmc), "%s: Invalid argument: total_phases=%d\n",
182 mmc_hostname(mmc), total_phases);
183 return -EINVAL;
184 }
185
186 for (cnt = 0; cnt < total_phases; cnt++) {
187 ranges[row_index][col_index] = phase_table[cnt];
188 phases_per_row[row_index] += 1;
189 col_index++;
190
191 if ((cnt + 1) == total_phases) {
192 continue;
193 /* check if next phase in phase_table is consecutive or not */
194 } else if ((phase_table[cnt] + 1) != phase_table[cnt + 1]) {
195 row_index++;
196 col_index = 0;
197 }
198 }
199
200 if (row_index >= MAX_PHASES)
201 return -EINVAL;
202
203 /* Check if phase-0 is present in first valid window? */
204 if (!ranges[0][0]) {
205 phase_0_found = true;
206 phase_0_raw_index = 0;
207 /* Check if cycle exist between 2 valid windows */
208 for (cnt = 1; cnt <= row_index; cnt++) {
209 if (phases_per_row[cnt]) {
210 for (i = 0; i < phases_per_row[cnt]; i++) {
211 if (ranges[cnt][i] == 15) {
212 phase_15_found = true;
213 phase_15_raw_index = cnt;
214 break;
215 }
216 }
217 }
218 }
219 }
220
221 /* If 2 valid windows form cycle then merge them as single window */
222 if (phase_0_found && phase_15_found) {
223 /* number of phases in raw where phase 0 is present */
224 u8 phases_0 = phases_per_row[phase_0_raw_index];
225 /* number of phases in raw where phase 15 is present */
226 u8 phases_15 = phases_per_row[phase_15_raw_index];
227
228 if (phases_0 + phases_15 >= MAX_PHASES)
229 /*
230 * If there are more than 1 phase windows then total
231 * number of phases in both the windows should not be
232 * more than or equal to MAX_PHASES.
233 */
234 return -EINVAL;
235
236 /* Merge 2 cyclic windows */
237 i = phases_15;
238 for (cnt = 0; cnt < phases_0; cnt++) {
239 ranges[phase_15_raw_index][i] =
240 ranges[phase_0_raw_index][cnt];
241 if (++i >= MAX_PHASES)
242 break;
243 }
244
245 phases_per_row[phase_0_raw_index] = 0;
246 phases_per_row[phase_15_raw_index] = phases_15 + phases_0;
247 }
248
249 for (cnt = 0; cnt <= row_index; cnt++) {
250 if (phases_per_row[cnt] > curr_max) {
251 curr_max = phases_per_row[cnt];
252 selected_row_index = cnt;
253 }
254 }
255
256 i = (curr_max * 3) / 4;
257 if (i)
258 i--;
259
260 ret = ranges[selected_row_index][i];
261
262 if (ret >= MAX_PHASES) {
263 ret = -EINVAL;
264 dev_err(mmc_dev(mmc), "%s: Invalid phase selected=%d\n",
265 mmc_hostname(mmc), ret);
266 }
267
268 return ret;
269}
270
271static inline void msm_cm_dll_set_freq(struct sdhci_host *host)
272{
273 u32 mclk_freq = 0, config;
274
275 /* Program the MCLK value to MCLK_FREQ bit field */
276 if (host->clock <= 112000000)
277 mclk_freq = 0;
278 else if (host->clock <= 125000000)
279 mclk_freq = 1;
280 else if (host->clock <= 137000000)
281 mclk_freq = 2;
282 else if (host->clock <= 150000000)
283 mclk_freq = 3;
284 else if (host->clock <= 162000000)
285 mclk_freq = 4;
286 else if (host->clock <= 175000000)
287 mclk_freq = 5;
288 else if (host->clock <= 187000000)
289 mclk_freq = 6;
290 else if (host->clock <= 200000000)
291 mclk_freq = 7;
292
293 config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG);
294 config &= ~CMUX_SHIFT_PHASE_MASK;
295 config |= mclk_freq << CMUX_SHIFT_PHASE_SHIFT;
296 writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG);
297}
298
299/* Initialize the DLL (Programmable Delay Line) */
300static int msm_init_cm_dll(struct sdhci_host *host)
301{
302 struct mmc_host *mmc = host->mmc;
303 int wait_cnt = 50;
304 unsigned long flags;
305
306 spin_lock_irqsave(&host->lock, flags);
307
308 /*
309 * Make sure that clock is always enabled when DLL
310 * tuning is in progress. Keeping PWRSAVE ON may
311 * turn off the clock.
312 */
313 writel_relaxed((readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC)
314 & ~CORE_CLK_PWRSAVE), host->ioaddr + CORE_VENDOR_SPEC);
315
316 /* Write 1 to DLL_RST bit of DLL_CONFIG register */
317 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
318 | CORE_DLL_RST), host->ioaddr + CORE_DLL_CONFIG);
319
320 /* Write 1 to DLL_PDN bit of DLL_CONFIG register */
321 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
322 | CORE_DLL_PDN), host->ioaddr + CORE_DLL_CONFIG);
323 msm_cm_dll_set_freq(host);
324
325 /* Write 0 to DLL_RST bit of DLL_CONFIG register */
326 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
327 & ~CORE_DLL_RST), host->ioaddr + CORE_DLL_CONFIG);
328
329 /* Write 0 to DLL_PDN bit of DLL_CONFIG register */
330 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
331 & ~CORE_DLL_PDN), host->ioaddr + CORE_DLL_CONFIG);
332
333 /* Set DLL_EN bit to 1. */
334 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
335 | CORE_DLL_EN), host->ioaddr + CORE_DLL_CONFIG);
336
337 /* Set CK_OUT_EN bit to 1. */
338 writel_relaxed((readl_relaxed(host->ioaddr + CORE_DLL_CONFIG)
339 | CORE_CK_OUT_EN), host->ioaddr + CORE_DLL_CONFIG);
340
341 /* Wait until DLL_LOCK bit of DLL_STATUS register becomes '1' */
342 while (!(readl_relaxed(host->ioaddr + CORE_DLL_STATUS) &
343 CORE_DLL_LOCK)) {
344 /* max. wait for 50us sec for LOCK bit to be set */
345 if (--wait_cnt == 0) {
346 dev_err(mmc_dev(mmc), "%s: DLL failed to LOCK\n",
347 mmc_hostname(mmc));
348 spin_unlock_irqrestore(&host->lock, flags);
349 return -ETIMEDOUT;
350 }
351 udelay(1);
352 }
353
354 spin_unlock_irqrestore(&host->lock, flags);
355 return 0;
356}
357
358static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
359{
360 int tuning_seq_cnt = 3;
361 u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0;
362 const u32 *tuning_block_pattern = tuning_block_64;
363 int size = sizeof(tuning_block_64); /* Pattern size in bytes */
364 int rc;
365 struct mmc_host *mmc = host->mmc;
366 struct mmc_ios ios = host->mmc->ios;
367
368 /*
369 * Tuning is required for SDR104, HS200 and HS400 cards and
370 * if clock frequency is greater than 100MHz in these modes.
371 */
372 if (host->clock <= 100 * 1000 * 1000 ||
373 !((ios.timing == MMC_TIMING_MMC_HS200) ||
374 (ios.timing == MMC_TIMING_UHS_SDR104)))
375 return 0;
376
377 if ((opcode == MMC_SEND_TUNING_BLOCK_HS200) &&
378 (mmc->ios.bus_width == MMC_BUS_WIDTH_8)) {
379 tuning_block_pattern = tuning_block_128;
380 size = sizeof(tuning_block_128);
381 }
382
383 data_buf = kmalloc(size, GFP_KERNEL);
384 if (!data_buf)
385 return -ENOMEM;
386
387retry:
388 /* First of all reset the tuning block */
389 rc = msm_init_cm_dll(host);
390 if (rc)
391 goto out;
392
393 phase = 0;
394 do {
395 struct mmc_command cmd = { 0 };
396 struct mmc_data data = { 0 };
397 struct mmc_request mrq = {
398 .cmd = &cmd,
399 .data = &data
400 };
401 struct scatterlist sg;
402
403 /* Set the phase in delay line hw block */
404 rc = msm_config_cm_dll_phase(host, phase);
405 if (rc)
406 goto out;
407
408 cmd.opcode = opcode;
409 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
410
411 data.blksz = size;
412 data.blocks = 1;
413 data.flags = MMC_DATA_READ;
414 data.timeout_ns = NSEC_PER_SEC; /* 1 second */
415
416 data.sg = &sg;
417 data.sg_len = 1;
418 sg_init_one(&sg, data_buf, size);
419 memset(data_buf, 0, size);
420 mmc_wait_for_req(mmc, &mrq);
421
422 if (!cmd.error && !data.error &&
423 !memcmp(data_buf, tuning_block_pattern, size)) {
424 /* Tuning is successful at this tuning point */
425 tuned_phases[tuned_phase_cnt++] = phase;
426 dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n",
427 mmc_hostname(mmc), phase);
428 }
429 } while (++phase < ARRAY_SIZE(tuned_phases));
430
431 if (tuned_phase_cnt) {
432 rc = msm_find_most_appropriate_phase(host, tuned_phases,
433 tuned_phase_cnt);
434 if (rc < 0)
435 goto out;
436 else
437 phase = rc;
438
439 /*
440 * Finally set the selected phase in delay
441 * line hw block.
442 */
443 rc = msm_config_cm_dll_phase(host, phase);
444 if (rc)
445 goto out;
446 dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n",
447 mmc_hostname(mmc), phase);
448 } else {
449 if (--tuning_seq_cnt)
450 goto retry;
451 /* Tuning failed */
452 dev_dbg(mmc_dev(mmc), "%s: No tuning point found\n",
453 mmc_hostname(mmc));
454 rc = -EIO;
455 }
456
457out:
458 kfree(data_buf);
459 return rc;
460}
461
462static const struct of_device_id sdhci_msm_dt_match[] = {
463 { .compatible = "qcom,sdhci-msm-v4" },
464 {},
465};
466
467MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match);
468
469static struct sdhci_ops sdhci_msm_ops = {
470 .platform_execute_tuning = sdhci_msm_execute_tuning,
471};
472
473static int sdhci_msm_probe(struct platform_device *pdev)
474{
475 struct sdhci_host *host;
476 struct sdhci_pltfm_host *pltfm_host;
477 struct sdhci_msm_host *msm_host;
478 struct resource *core_memres;
479 int ret;
480 u16 host_version;
481
482 msm_host = devm_kzalloc(&pdev->dev, sizeof(*msm_host), GFP_KERNEL);
483 if (!msm_host)
484 return -ENOMEM;
485
486 msm_host->sdhci_msm_pdata.ops = &sdhci_msm_ops;
487 host = sdhci_pltfm_init(pdev, &msm_host->sdhci_msm_pdata, 0);
488 if (IS_ERR(host))
489 return PTR_ERR(host);
490
491 pltfm_host = sdhci_priv(host);
492 pltfm_host->priv = msm_host;
493 msm_host->mmc = host->mmc;
494 msm_host->pdev = pdev;
495
496 ret = mmc_of_parse(host->mmc);
497 if (ret)
498 goto pltfm_free;
499
500 sdhci_get_of_property(pdev);
501
502 /* Setup SDCC bus voter clock. */
503 msm_host->bus_clk = devm_clk_get(&pdev->dev, "bus");
504 if (!IS_ERR(msm_host->bus_clk)) {
505 /* Vote for max. clk rate for max. performance */
506 ret = clk_set_rate(msm_host->bus_clk, INT_MAX);
507 if (ret)
508 goto pltfm_free;
509 ret = clk_prepare_enable(msm_host->bus_clk);
510 if (ret)
511 goto pltfm_free;
512 }
513
514 /* Setup main peripheral bus clock */
515 msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
516 if (IS_ERR(msm_host->pclk)) {
517 ret = PTR_ERR(msm_host->pclk);
518 dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n", ret);
519 goto bus_clk_disable;
520 }
521
522 ret = clk_prepare_enable(msm_host->pclk);
523 if (ret)
524 goto bus_clk_disable;
525
526 /* Setup SDC MMC clock */
527 msm_host->clk = devm_clk_get(&pdev->dev, "core");
528 if (IS_ERR(msm_host->clk)) {
529 ret = PTR_ERR(msm_host->clk);
530 dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret);
531 goto pclk_disable;
532 }
533
534 ret = clk_prepare_enable(msm_host->clk);
535 if (ret)
536 goto pclk_disable;
537
538 core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
539 msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres);
540
541 if (IS_ERR(msm_host->core_mem)) {
542 dev_err(&pdev->dev, "Failed to remap registers\n");
543 ret = PTR_ERR(msm_host->core_mem);
544 goto clk_disable;
545 }
546
547 /* Reset the core and Enable SDHC mode */
548 writel_relaxed(readl_relaxed(msm_host->core_mem + CORE_POWER) |
549 CORE_SW_RST, msm_host->core_mem + CORE_POWER);
550
551 /* SW reset can take upto 10HCLK + 15MCLK cycles. (min 40us) */
552 usleep_range(1000, 5000);
553 if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
554 dev_err(&pdev->dev, "Stuck in reset\n");
555 ret = -ETIMEDOUT;
556 goto clk_disable;
557 }
558
559 /* Set HC_MODE_EN bit in HC_MODE register */
560 writel_relaxed(HC_MODE_EN, (msm_host->core_mem + CORE_HC_MODE));
561
562 host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
563 host->quirks |= SDHCI_QUIRK_SINGLE_POWER_WRITE;
564
565 host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION));
566 dev_dbg(&pdev->dev, "Host Version: 0x%x Vendor Version 0x%x\n",
567 host_version, ((host_version & SDHCI_VENDOR_VER_MASK) >>
568 SDHCI_VENDOR_VER_SHIFT));
569
570 ret = sdhci_add_host(host);
571 if (ret)
572 goto clk_disable;
573
574 return 0;
575
576clk_disable:
577 clk_disable_unprepare(msm_host->clk);
578pclk_disable:
579 clk_disable_unprepare(msm_host->pclk);
580bus_clk_disable:
581 if (!IS_ERR(msm_host->bus_clk))
582 clk_disable_unprepare(msm_host->bus_clk);
583pltfm_free:
584 sdhci_pltfm_free(pdev);
585 return ret;
586}
587
588static int sdhci_msm_remove(struct platform_device *pdev)
589{
590 struct sdhci_host *host = platform_get_drvdata(pdev);
591 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
592 struct sdhci_msm_host *msm_host = pltfm_host->priv;
593 int dead = (readl_relaxed(host->ioaddr + SDHCI_INT_STATUS) ==
594 0xffffffff);
595
596 sdhci_remove_host(host, dead);
597 sdhci_pltfm_free(pdev);
598 clk_disable_unprepare(msm_host->clk);
599 clk_disable_unprepare(msm_host->pclk);
600 if (!IS_ERR(msm_host->bus_clk))
601 clk_disable_unprepare(msm_host->bus_clk);
602 return 0;
603}
604
605static struct platform_driver sdhci_msm_driver = {
606 .probe = sdhci_msm_probe,
607 .remove = sdhci_msm_remove,
608 .driver = {
609 .name = "sdhci_msm",
610 .owner = THIS_MODULE,
611 .of_match_table = sdhci_msm_dt_match,
612 },
613};
614
615module_platform_driver(sdhci_msm_driver);
616
617MODULE_DESCRIPTION("Qualcomm Secure Digital Host Controller Interface driver");
618MODULE_LICENSE("GPL v2");
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 0955777b6c7e..fdc612120362 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -610,6 +610,18 @@ static const struct sdhci_pci_fixes sdhci_via = {
610 .probe = via_probe, 610 .probe = via_probe,
611}; 611};
612 612
613static int rtsx_probe_slot(struct sdhci_pci_slot *slot)
614{
615 slot->host->mmc->caps2 |= MMC_CAP2_HS200;
616 return 0;
617}
618
619static const struct sdhci_pci_fixes sdhci_rtsx = {
620 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
621 SDHCI_QUIRK2_BROKEN_DDR50,
622 .probe_slot = rtsx_probe_slot,
623};
624
613static const struct pci_device_id pci_ids[] = { 625static const struct pci_device_id pci_ids[] = {
614 { 626 {
615 .vendor = PCI_VENDOR_ID_RICOH, 627 .vendor = PCI_VENDOR_ID_RICOH,
@@ -732,6 +744,14 @@ static const struct pci_device_id pci_ids[] = {
732 }, 744 },
733 745
734 { 746 {
747 .vendor = PCI_VENDOR_ID_REALTEK,
748 .device = 0x5250,
749 .subvendor = PCI_ANY_ID,
750 .subdevice = PCI_ANY_ID,
751 .driver_data = (kernel_ulong_t)&sdhci_rtsx,
752 },
753
754 {
735 .vendor = PCI_VENDOR_ID_INTEL, 755 .vendor = PCI_VENDOR_ID_INTEL,
736 .device = PCI_DEVICE_ID_INTEL_MRST_SD0, 756 .device = PCI_DEVICE_ID_INTEL_MRST_SD0,
737 .subvendor = PCI_ANY_ID, 757 .subvendor = PCI_ANY_ID,
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 793dacd3b841..2fd73b38c303 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -34,6 +34,7 @@
34#include <linux/of_gpio.h> 34#include <linux/of_gpio.h>
35#include <linux/pm.h> 35#include <linux/pm.h>
36#include <linux/pm_runtime.h> 36#include <linux/pm_runtime.h>
37#include <linux/mbus.h>
37 38
38#include "sdhci.h" 39#include "sdhci.h"
39#include "sdhci-pltfm.h" 40#include "sdhci-pltfm.h"
@@ -57,6 +58,60 @@
57#define SDCE_MISC_INT (1<<2) 58#define SDCE_MISC_INT (1<<2)
58#define SDCE_MISC_INT_EN (1<<1) 59#define SDCE_MISC_INT_EN (1<<1)
59 60
61/*
62 * These registers are relative to the second register region, for the
63 * MBus bridge.
64 */
65#define SDHCI_WINDOW_CTRL(i) (0x80 + ((i) << 3))
66#define SDHCI_WINDOW_BASE(i) (0x84 + ((i) << 3))
67#define SDHCI_MAX_WIN_NUM 8
68
69static int mv_conf_mbus_windows(struct platform_device *pdev,
70 const struct mbus_dram_target_info *dram)
71{
72 int i;
73 void __iomem *regs;
74 struct resource *res;
75
76 if (!dram) {
77 dev_err(&pdev->dev, "no mbus dram info\n");
78 return -EINVAL;
79 }
80
81 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
82 if (!res) {
83 dev_err(&pdev->dev, "cannot get mbus registers\n");
84 return -EINVAL;
85 }
86
87 regs = ioremap(res->start, resource_size(res));
88 if (!regs) {
89 dev_err(&pdev->dev, "cannot map mbus registers\n");
90 return -ENOMEM;
91 }
92
93 for (i = 0; i < SDHCI_MAX_WIN_NUM; i++) {
94 writel(0, regs + SDHCI_WINDOW_CTRL(i));
95 writel(0, regs + SDHCI_WINDOW_BASE(i));
96 }
97
98 for (i = 0; i < dram->num_cs; i++) {
99 const struct mbus_dram_window *cs = dram->cs + i;
100
101 /* Write size, attributes and target id to control register */
102 writel(((cs->size - 1) & 0xffff0000) |
103 (cs->mbus_attr << 8) |
104 (dram->mbus_dram_target_id << 4) | 1,
105 regs + SDHCI_WINDOW_CTRL(i));
106 /* Write base address to base register */
107 writel(cs->base, regs + SDHCI_WINDOW_BASE(i));
108 }
109
110 iounmap(regs);
111
112 return 0;
113}
114
60static void pxav3_set_private_registers(struct sdhci_host *host, u8 mask) 115static void pxav3_set_private_registers(struct sdhci_host *host, u8 mask)
61{ 116{
62 struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc)); 117 struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
@@ -187,6 +242,9 @@ static const struct of_device_id sdhci_pxav3_of_match[] = {
187 { 242 {
188 .compatible = "mrvl,pxav3-mmc", 243 .compatible = "mrvl,pxav3-mmc",
189 }, 244 },
245 {
246 .compatible = "marvell,armada-380-sdhci",
247 },
190 {}, 248 {},
191}; 249};
192MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match); 250MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
@@ -219,6 +277,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
219 struct sdhci_pltfm_host *pltfm_host; 277 struct sdhci_pltfm_host *pltfm_host;
220 struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data; 278 struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
221 struct device *dev = &pdev->dev; 279 struct device *dev = &pdev->dev;
280 struct device_node *np = pdev->dev.of_node;
222 struct sdhci_host *host = NULL; 281 struct sdhci_host *host = NULL;
223 struct sdhci_pxa *pxa = NULL; 282 struct sdhci_pxa *pxa = NULL;
224 const struct of_device_id *match; 283 const struct of_device_id *match;
@@ -235,6 +294,14 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
235 kfree(pxa); 294 kfree(pxa);
236 return PTR_ERR(host); 295 return PTR_ERR(host);
237 } 296 }
297
298 if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {
299 ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());
300 if (ret < 0)
301 goto err_mbus_win;
302 }
303
304
238 pltfm_host = sdhci_priv(host); 305 pltfm_host = sdhci_priv(host);
239 pltfm_host->priv = pxa; 306 pltfm_host->priv = pxa;
240 307
@@ -321,6 +388,7 @@ err_add_host:
321 clk_disable_unprepare(clk); 388 clk_disable_unprepare(clk);
322 clk_put(clk); 389 clk_put(clk);
323err_clk_get: 390err_clk_get:
391err_mbus_win:
324 sdhci_pltfm_free(pdev); 392 sdhci_pltfm_free(pdev);
325 kfree(pxa); 393 kfree(pxa);
326 return ret; 394 return ret;
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 6debda952155..d61eb5a70833 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -51,12 +51,13 @@ struct sdhci_s3c {
51 struct platform_device *pdev; 51 struct platform_device *pdev;
52 struct resource *ioarea; 52 struct resource *ioarea;
53 struct s3c_sdhci_platdata *pdata; 53 struct s3c_sdhci_platdata *pdata;
54 unsigned int cur_clk; 54 int cur_clk;
55 int ext_cd_irq; 55 int ext_cd_irq;
56 int ext_cd_gpio; 56 int ext_cd_gpio;
57 57
58 struct clk *clk_io; 58 struct clk *clk_io;
59 struct clk *clk_bus[MAX_BUS_CLK]; 59 struct clk *clk_bus[MAX_BUS_CLK];
60 unsigned long clk_rates[MAX_BUS_CLK];
60}; 61};
61 62
62/** 63/**
@@ -77,32 +78,6 @@ static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
77} 78}
78 79
79/** 80/**
80 * get_curclk - convert ctrl2 register to clock source number
81 * @ctrl2: Control2 register value.
82 */
83static u32 get_curclk(u32 ctrl2)
84{
85 ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
86 ctrl2 >>= S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
87
88 return ctrl2;
89}
90
91static void sdhci_s3c_check_sclk(struct sdhci_host *host)
92{
93 struct sdhci_s3c *ourhost = to_s3c(host);
94 u32 tmp = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
95
96 if (get_curclk(tmp) != ourhost->cur_clk) {
97 dev_dbg(&ourhost->pdev->dev, "restored ctrl2 clock setting\n");
98
99 tmp &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
100 tmp |= ourhost->cur_clk << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
101 writel(tmp, host->ioaddr + S3C_SDHCI_CONTROL2);
102 }
103}
104
105/**
106 * sdhci_s3c_get_max_clk - callback to get maximum clock frequency. 81 * sdhci_s3c_get_max_clk - callback to get maximum clock frequency.
107 * @host: The SDHCI host instance. 82 * @host: The SDHCI host instance.
108 * 83 *
@@ -111,20 +86,11 @@ static void sdhci_s3c_check_sclk(struct sdhci_host *host)
111static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host) 86static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
112{ 87{
113 struct sdhci_s3c *ourhost = to_s3c(host); 88 struct sdhci_s3c *ourhost = to_s3c(host);
114 struct clk *busclk; 89 unsigned long rate, max = 0;
115 unsigned int rate, max; 90 int src;
116 int clk;
117
118 /* note, a reset will reset the clock source */
119
120 sdhci_s3c_check_sclk(host);
121
122 for (max = 0, clk = 0; clk < MAX_BUS_CLK; clk++) {
123 busclk = ourhost->clk_bus[clk];
124 if (!busclk)
125 continue;
126 91
127 rate = clk_get_rate(busclk); 92 for (src = 0; src < MAX_BUS_CLK; src++) {
93 rate = ourhost->clk_rates[src];
128 if (rate > max) 94 if (rate > max)
129 max = rate; 95 max = rate;
130 } 96 }
@@ -144,9 +110,9 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
144{ 110{
145 unsigned long rate; 111 unsigned long rate;
146 struct clk *clksrc = ourhost->clk_bus[src]; 112 struct clk *clksrc = ourhost->clk_bus[src];
147 int div; 113 int shift;
148 114
149 if (!clksrc) 115 if (IS_ERR(clksrc))
150 return UINT_MAX; 116 return UINT_MAX;
151 117
152 /* 118 /*
@@ -158,17 +124,24 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
158 return wanted - rate; 124 return wanted - rate;
159 } 125 }
160 126
161 rate = clk_get_rate(clksrc); 127 rate = ourhost->clk_rates[src];
162 128
163 for (div = 1; div < 256; div *= 2) { 129 for (shift = 0; shift <= 8; ++shift) {
164 if ((rate / div) <= wanted) 130 if ((rate >> shift) <= wanted)
165 break; 131 break;
166 } 132 }
167 133
134 if (shift > 8) {
135 dev_dbg(&ourhost->pdev->dev,
136 "clk %d: rate %ld, min rate %lu > wanted %u\n",
137 src, rate, rate / 256, wanted);
138 return UINT_MAX;
139 }
140
168 dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n", 141 dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n",
169 src, rate, wanted, rate / div); 142 src, rate, wanted, rate >> shift);
170 143
171 return wanted - (rate / div); 144 return wanted - (rate >> shift);
172} 145}
173 146
174/** 147/**
@@ -209,20 +182,22 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
209 struct clk *clk = ourhost->clk_bus[best_src]; 182 struct clk *clk = ourhost->clk_bus[best_src];
210 183
211 clk_prepare_enable(clk); 184 clk_prepare_enable(clk);
212 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]); 185 if (ourhost->cur_clk >= 0)
213 186 clk_disable_unprepare(
214 /* turn clock off to card before changing clock source */ 187 ourhost->clk_bus[ourhost->cur_clk]);
215 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
216 188
217 ourhost->cur_clk = best_src; 189 ourhost->cur_clk = best_src;
218 host->max_clk = clk_get_rate(clk); 190 host->max_clk = ourhost->clk_rates[best_src];
219
220 ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
221 ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
222 ctrl |= best_src << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
223 writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
224 } 191 }
225 192
193 /* turn clock off to card before changing clock source */
194 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
195
196 ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
197 ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
198 ctrl |= best_src << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
199 writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
200
226 /* reprogram default hardware configuration */ 201 /* reprogram default hardware configuration */
227 writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA, 202 writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA,
228 host->ioaddr + S3C64XX_SDHCI_CONTROL4); 203 host->ioaddr + S3C64XX_SDHCI_CONTROL4);
@@ -254,17 +229,17 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
254static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host) 229static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
255{ 230{
256 struct sdhci_s3c *ourhost = to_s3c(host); 231 struct sdhci_s3c *ourhost = to_s3c(host);
257 unsigned int delta, min = UINT_MAX; 232 unsigned long rate, min = ULONG_MAX;
258 int src; 233 int src;
259 234
260 for (src = 0; src < MAX_BUS_CLK; src++) { 235 for (src = 0; src < MAX_BUS_CLK; src++) {
261 delta = sdhci_s3c_consider_clock(ourhost, src, 0); 236 rate = ourhost->clk_rates[src] / 256;
262 if (delta == UINT_MAX) 237 if (!rate)
263 continue; 238 continue;
264 /* delta is a negative value in this case */ 239 if (rate < min)
265 if (-delta < min) 240 min = rate;
266 min = -delta;
267 } 241 }
242
268 return min; 243 return min;
269} 244}
270 245
@@ -272,20 +247,44 @@ static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
272static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host) 247static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
273{ 248{
274 struct sdhci_s3c *ourhost = to_s3c(host); 249 struct sdhci_s3c *ourhost = to_s3c(host);
250 unsigned long rate, max = 0;
251 int src;
275 252
276 return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], UINT_MAX); 253 for (src = 0; src < MAX_BUS_CLK; src++) {
254 struct clk *clk;
255
256 clk = ourhost->clk_bus[src];
257 if (IS_ERR(clk))
258 continue;
259
260 rate = clk_round_rate(clk, ULONG_MAX);
261 if (rate > max)
262 max = rate;
263 }
264
265 return max;
277} 266}
278 267
279/* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */ 268/* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
280static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host) 269static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
281{ 270{
282 struct sdhci_s3c *ourhost = to_s3c(host); 271 struct sdhci_s3c *ourhost = to_s3c(host);
272 unsigned long rate, min = ULONG_MAX;
273 int src;
283 274
284 /* 275 for (src = 0; src < MAX_BUS_CLK; src++) {
285 * initial clock can be in the frequency range of 276 struct clk *clk;
286 * 100KHz-400KHz, so we set it as max value. 277
287 */ 278 clk = ourhost->clk_bus[src];
288 return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], 400000); 279 if (IS_ERR(clk))
280 continue;
281
282 rate = clk_round_rate(clk, 0);
283 if (rate < min)
284 min = rate;
285 }
286
287 return min;
289} 288}
290 289
291/* sdhci_cmu_set_clock - callback on clock change.*/ 290/* sdhci_cmu_set_clock - callback on clock change.*/
@@ -552,6 +551,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
552 sc->host = host; 551 sc->host = host;
553 sc->pdev = pdev; 552 sc->pdev = pdev;
554 sc->pdata = pdata; 553 sc->pdata = pdata;
554 sc->cur_clk = -1;
555 555
556 platform_set_drvdata(pdev, host); 556 platform_set_drvdata(pdev, host);
557 557
@@ -566,25 +566,18 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
566 clk_prepare_enable(sc->clk_io); 566 clk_prepare_enable(sc->clk_io);
567 567
568 for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 568 for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
569 struct clk *clk;
570 char name[14]; 569 char name[14];
571 570
572 snprintf(name, 14, "mmc_busclk.%d", ptr); 571 snprintf(name, 14, "mmc_busclk.%d", ptr);
573 clk = devm_clk_get(dev, name); 572 sc->clk_bus[ptr] = devm_clk_get(dev, name);
574 if (IS_ERR(clk)) 573 if (IS_ERR(sc->clk_bus[ptr]))
575 continue; 574 continue;
576 575
577 clks++; 576 clks++;
578 sc->clk_bus[ptr] = clk; 577 sc->clk_rates[ptr] = clk_get_rate(sc->clk_bus[ptr]);
579
580 /*
581 * save current clock index to know which clock bus
582 * is used later in overriding functions.
583 */
584 sc->cur_clk = ptr;
585 578
586 dev_info(dev, "clock source %d: %s (%ld Hz)\n", 579 dev_info(dev, "clock source %d: %s (%ld Hz)\n",
587 ptr, name, clk_get_rate(clk)); 580 ptr, name, sc->clk_rates[ptr]);
588 } 581 }
589 582
590 if (clks == 0) { 583 if (clks == 0) {
@@ -593,10 +586,6 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
593 goto err_no_busclks; 586 goto err_no_busclks;
594 } 587 }
595 588
596#ifndef CONFIG_PM_RUNTIME
597 clk_prepare_enable(sc->clk_bus[sc->cur_clk]);
598#endif
599
600 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 589 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
601 host->ioaddr = devm_ioremap_resource(&pdev->dev, res); 590 host->ioaddr = devm_ioremap_resource(&pdev->dev, res);
602 if (IS_ERR(host->ioaddr)) { 591 if (IS_ERR(host->ioaddr)) {
@@ -709,10 +698,6 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
709 return 0; 698 return 0;
710 699
711 err_req_regs: 700 err_req_regs:
712#ifndef CONFIG_PM_RUNTIME
713 clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
714#endif
715
716 err_no_busclks: 701 err_no_busclks:
717 clk_disable_unprepare(sc->clk_io); 702 clk_disable_unprepare(sc->clk_io);
718 703
@@ -743,9 +728,6 @@ static int sdhci_s3c_remove(struct platform_device *pdev)
743 pm_runtime_dont_use_autosuspend(&pdev->dev); 728 pm_runtime_dont_use_autosuspend(&pdev->dev);
744 pm_runtime_disable(&pdev->dev); 729 pm_runtime_disable(&pdev->dev);
745 730
746#ifndef CONFIG_PM_RUNTIME
747 clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
748#endif
749 clk_disable_unprepare(sc->clk_io); 731 clk_disable_unprepare(sc->clk_io);
750 732
751 sdhci_free_host(host); 733 sdhci_free_host(host);
@@ -779,7 +761,8 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
779 761
780 ret = sdhci_runtime_suspend_host(host); 762 ret = sdhci_runtime_suspend_host(host);
781 763
782 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]); 764 if (ourhost->cur_clk >= 0)
765 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
783 clk_disable_unprepare(busclk); 766 clk_disable_unprepare(busclk);
784 return ret; 767 return ret;
785} 768}
@@ -792,7 +775,8 @@ static int sdhci_s3c_runtime_resume(struct device *dev)
792 int ret; 775 int ret;
793 776
794 clk_prepare_enable(busclk); 777 clk_prepare_enable(busclk);
795 clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]); 778 if (ourhost->cur_clk >= 0)
779 clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
796 ret = sdhci_runtime_resume_host(host); 780 ret = sdhci_runtime_resume_host(host);
797 return ret; 781 return ret;
798} 782}
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 2dba9f8d1760..0316dec3f006 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/mmc/host.h> 28#include <linux/mmc/host.h>
29#include <linux/mmc/sdhci-spear.h> 29#include <linux/mmc/sdhci-spear.h>
30#include <linux/mmc/slot-gpio.h>
30#include <linux/io.h> 31#include <linux/io.h>
31#include "sdhci.h" 32#include "sdhci.h"
32 33
@@ -40,36 +41,6 @@ static const struct sdhci_ops sdhci_pltfm_ops = {
40 /* Nothing to do for now. */ 41 /* Nothing to do for now. */
41}; 42};
42 43
43/* gpio card detection interrupt handler */
44static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id)
45{
46 struct platform_device *pdev = dev_id;
47 struct sdhci_host *host = platform_get_drvdata(pdev);
48 struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev);
49 unsigned long gpio_irq_type;
50 int val;
51
52 val = gpio_get_value(sdhci->data->card_int_gpio);
53
54 /* val == 1 -> card removed, val == 0 -> card inserted */
55 /* if card removed - set irq for low level, else vice versa */
56 gpio_irq_type = val ? IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH;
57 irq_set_irq_type(irq, gpio_irq_type);
58
59 if (sdhci->data->card_power_gpio >= 0) {
60 if (!sdhci->data->power_always_enb) {
61 /* if card inserted, give power, otherwise remove it */
62 val = sdhci->data->power_active_high ? !val : val ;
63 gpio_set_value(sdhci->data->card_power_gpio, val);
64 }
65 }
66
67 /* inform sdhci driver about card insertion/removal */
68 tasklet_schedule(&host->card_tasklet);
69
70 return IRQ_HANDLED;
71}
72
73#ifdef CONFIG_OF 44#ifdef CONFIG_OF
74static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pdev) 45static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pdev)
75{ 46{
@@ -84,14 +55,12 @@ static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pde
84 /* If pdata is required */ 55 /* If pdata is required */
85 if (cd_gpio != -1) { 56 if (cd_gpio != -1) {
86 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 57 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
87 if (!pdata) { 58 if (!pdata)
88 dev_err(&pdev->dev, "DT: kzalloc failed\n"); 59 dev_err(&pdev->dev, "DT: kzalloc failed\n");
89 return ERR_PTR(-ENOMEM); 60 else
90 } 61 pdata->card_int_gpio = cd_gpio;
91 } 62 }
92 63
93 pdata->card_int_gpio = cd_gpio;
94
95 return pdata; 64 return pdata;
96} 65}
97#else 66#else
@@ -107,41 +76,44 @@ static int sdhci_probe(struct platform_device *pdev)
107 struct sdhci_host *host; 76 struct sdhci_host *host;
108 struct resource *iomem; 77 struct resource *iomem;
109 struct spear_sdhci *sdhci; 78 struct spear_sdhci *sdhci;
79 struct device *dev;
110 int ret; 80 int ret;
111 81
112 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 82 dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev;
113 if (!iomem) { 83 host = sdhci_alloc_host(dev, sizeof(*sdhci));
114 ret = -ENOMEM; 84 if (IS_ERR(host)) {
115 dev_dbg(&pdev->dev, "memory resource not defined\n"); 85 ret = PTR_ERR(host);
86 dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n");
116 goto err; 87 goto err;
117 } 88 }
118 89
119 if (!devm_request_mem_region(&pdev->dev, iomem->start, 90 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
120 resource_size(iomem), "spear-sdhci")) { 91 host->ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
121 ret = -EBUSY; 92 if (IS_ERR(host->ioaddr)) {
122 dev_dbg(&pdev->dev, "cannot request region\n"); 93 ret = PTR_ERR(host->ioaddr);
123 goto err; 94 dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret);
95 goto err_host;
124 } 96 }
125 97
126 sdhci = devm_kzalloc(&pdev->dev, sizeof(*sdhci), GFP_KERNEL); 98 host->hw_name = "sdhci";
127 if (!sdhci) { 99 host->ops = &sdhci_pltfm_ops;
128 ret = -ENOMEM; 100 host->irq = platform_get_irq(pdev, 0);
129 dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n"); 101 host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
130 goto err; 102
131 } 103 sdhci = sdhci_priv(host);
132 104
133 /* clk enable */ 105 /* clk enable */
134 sdhci->clk = clk_get(&pdev->dev, NULL); 106 sdhci->clk = devm_clk_get(&pdev->dev, NULL);
135 if (IS_ERR(sdhci->clk)) { 107 if (IS_ERR(sdhci->clk)) {
136 ret = PTR_ERR(sdhci->clk); 108 ret = PTR_ERR(sdhci->clk);
137 dev_dbg(&pdev->dev, "Error getting clock\n"); 109 dev_dbg(&pdev->dev, "Error getting clock\n");
138 goto err; 110 goto err_host;
139 } 111 }
140 112
141 ret = clk_prepare_enable(sdhci->clk); 113 ret = clk_prepare_enable(sdhci->clk);
142 if (ret) { 114 if (ret) {
143 dev_dbg(&pdev->dev, "Error enabling clock\n"); 115 dev_dbg(&pdev->dev, "Error enabling clock\n");
144 goto put_clk; 116 goto err_host;
145 } 117 }
146 118
147 ret = clk_set_rate(sdhci->clk, 50000000); 119 ret = clk_set_rate(sdhci->clk, 50000000);
@@ -153,118 +125,42 @@ static int sdhci_probe(struct platform_device *pdev)
153 sdhci->data = sdhci_probe_config_dt(pdev); 125 sdhci->data = sdhci_probe_config_dt(pdev);
154 if (IS_ERR(sdhci->data)) { 126 if (IS_ERR(sdhci->data)) {
155 dev_err(&pdev->dev, "DT: Failed to get pdata\n"); 127 dev_err(&pdev->dev, "DT: Failed to get pdata\n");
156 return -ENODEV; 128 goto disable_clk;
157 } 129 }
158 } else { 130 } else {
159 sdhci->data = dev_get_platdata(&pdev->dev); 131 sdhci->data = dev_get_platdata(&pdev->dev);
160 } 132 }
161 133
162 pdev->dev.platform_data = sdhci; 134 /*
163 135 * It is optional to use GPIOs for sdhci card detection. If
164 if (pdev->dev.parent) 136 * sdhci->data is NULL, then use original sdhci lines otherwise
165 host = sdhci_alloc_host(pdev->dev.parent, 0); 137 * GPIO lines. We use the built-in GPIO support for this.
166 else 138 */
167 host = sdhci_alloc_host(&pdev->dev, 0); 139 if (sdhci->data && sdhci->data->card_int_gpio >= 0) {
168 140 ret = mmc_gpio_request_cd(host->mmc,
169 if (IS_ERR(host)) { 141 sdhci->data->card_int_gpio, 0);
170 ret = PTR_ERR(host); 142 if (ret < 0) {
171 dev_dbg(&pdev->dev, "error allocating host\n"); 143 dev_dbg(&pdev->dev,
172 goto disable_clk; 144 "failed to request card-detect gpio%d\n",
173 } 145 sdhci->data->card_int_gpio);
174 146 goto disable_clk;
175 host->hw_name = "sdhci"; 147 }
176 host->ops = &sdhci_pltfm_ops;
177 host->irq = platform_get_irq(pdev, 0);
178 host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
179
180 host->ioaddr = devm_ioremap(&pdev->dev, iomem->start,
181 resource_size(iomem));
182 if (!host->ioaddr) {
183 ret = -ENOMEM;
184 dev_dbg(&pdev->dev, "failed to remap registers\n");
185 goto free_host;
186 } 148 }
187 149
188 ret = sdhci_add_host(host); 150 ret = sdhci_add_host(host);
189 if (ret) { 151 if (ret) {
190 dev_dbg(&pdev->dev, "error adding host\n"); 152 dev_dbg(&pdev->dev, "error adding host\n");
191 goto free_host; 153 goto disable_clk;
192 } 154 }
193 155
194 platform_set_drvdata(pdev, host); 156 platform_set_drvdata(pdev, host);
195 157
196 /*
197 * It is optional to use GPIOs for sdhci Power control & sdhci card
198 * interrupt detection. If sdhci->data is NULL, then use original sdhci
199 * lines otherwise GPIO lines.
200 * If GPIO is selected for power control, then power should be disabled
201 * after card removal and should be enabled when card insertion
202 * interrupt occurs
203 */
204 if (!sdhci->data)
205 return 0;
206
207 if (sdhci->data->card_power_gpio >= 0) {
208 int val = 0;
209
210 ret = devm_gpio_request(&pdev->dev,
211 sdhci->data->card_power_gpio, "sdhci");
212 if (ret < 0) {
213 dev_dbg(&pdev->dev, "gpio request fail: %d\n",
214 sdhci->data->card_power_gpio);
215 goto set_drvdata;
216 }
217
218 if (sdhci->data->power_always_enb)
219 val = sdhci->data->power_active_high;
220 else
221 val = !sdhci->data->power_active_high;
222
223 ret = gpio_direction_output(sdhci->data->card_power_gpio, val);
224 if (ret) {
225 dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
226 sdhci->data->card_power_gpio);
227 goto set_drvdata;
228 }
229 }
230
231 if (sdhci->data->card_int_gpio >= 0) {
232 ret = devm_gpio_request(&pdev->dev, sdhci->data->card_int_gpio,
233 "sdhci");
234 if (ret < 0) {
235 dev_dbg(&pdev->dev, "gpio request fail: %d\n",
236 sdhci->data->card_int_gpio);
237 goto set_drvdata;
238 }
239
240 ret = gpio_direction_input(sdhci->data->card_int_gpio);
241 if (ret) {
242 dev_dbg(&pdev->dev, "gpio set direction fail: %d\n",
243 sdhci->data->card_int_gpio);
244 goto set_drvdata;
245 }
246 ret = devm_request_irq(&pdev->dev,
247 gpio_to_irq(sdhci->data->card_int_gpio),
248 sdhci_gpio_irq, IRQF_TRIGGER_LOW,
249 mmc_hostname(host->mmc), pdev);
250 if (ret) {
251 dev_dbg(&pdev->dev, "gpio request irq fail: %d\n",
252 sdhci->data->card_int_gpio);
253 goto set_drvdata;
254 }
255
256 }
257
258 return 0; 158 return 0;
259 159
260set_drvdata:
261 sdhci_remove_host(host, 1);
262free_host:
263 sdhci_free_host(host);
264disable_clk: 160disable_clk:
265 clk_disable_unprepare(sdhci->clk); 161 clk_disable_unprepare(sdhci->clk);
266put_clk: 162err_host:
267 clk_put(sdhci->clk); 163 sdhci_free_host(host);
268err: 164err:
269 dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret); 165 dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret);
270 return ret; 166 return ret;
@@ -273,7 +169,7 @@ err:
273static int sdhci_remove(struct platform_device *pdev) 169static int sdhci_remove(struct platform_device *pdev)
274{ 170{
275 struct sdhci_host *host = platform_get_drvdata(pdev); 171 struct sdhci_host *host = platform_get_drvdata(pdev);
276 struct spear_sdhci *sdhci = dev_get_platdata(&pdev->dev); 172 struct spear_sdhci *sdhci = sdhci_priv(host);
277 int dead = 0; 173 int dead = 0;
278 u32 scratch; 174 u32 scratch;
279 175
@@ -282,9 +178,8 @@ static int sdhci_remove(struct platform_device *pdev)
282 dead = 1; 178 dead = 1;
283 179
284 sdhci_remove_host(host, dead); 180 sdhci_remove_host(host, dead);
285 sdhci_free_host(host);
286 clk_disable_unprepare(sdhci->clk); 181 clk_disable_unprepare(sdhci->clk);
287 clk_put(sdhci->clk); 182 sdhci_free_host(host);
288 183
289 return 0; 184 return 0;
290} 185}
@@ -293,7 +188,7 @@ static int sdhci_remove(struct platform_device *pdev)
293static int sdhci_suspend(struct device *dev) 188static int sdhci_suspend(struct device *dev)
294{ 189{
295 struct sdhci_host *host = dev_get_drvdata(dev); 190 struct sdhci_host *host = dev_get_drvdata(dev);
296 struct spear_sdhci *sdhci = dev_get_platdata(dev); 191 struct spear_sdhci *sdhci = sdhci_priv(host);
297 int ret; 192 int ret;
298 193
299 ret = sdhci_suspend_host(host); 194 ret = sdhci_suspend_host(host);
@@ -306,7 +201,7 @@ static int sdhci_suspend(struct device *dev)
306static int sdhci_resume(struct device *dev) 201static int sdhci_resume(struct device *dev)
307{ 202{
308 struct sdhci_host *host = dev_get_drvdata(dev); 203 struct sdhci_host *host = dev_get_drvdata(dev);
309 struct spear_sdhci *sdhci = dev_get_platdata(dev); 204 struct spear_sdhci *sdhci = sdhci_priv(host);
310 int ret; 205 int ret;
311 206
312 ret = clk_enable(sdhci->clk); 207 ret = clk_enable(sdhci->clk);
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9ddef4763541..9a79fc4b60ca 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -675,12 +675,12 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
675 return 0xE; 675 return 0xE;
676 676
677 /* Unspecified timeout, assume max */ 677 /* Unspecified timeout, assume max */
678 if (!data && !cmd->cmd_timeout_ms) 678 if (!data && !cmd->busy_timeout)
679 return 0xE; 679 return 0xE;
680 680
681 /* timeout in us */ 681 /* timeout in us */
682 if (!data) 682 if (!data)
683 target_timeout = cmd->cmd_timeout_ms * 1000; 683 target_timeout = cmd->busy_timeout * 1000;
684 else { 684 else {
685 target_timeout = data->timeout_ns / 1000; 685 target_timeout = data->timeout_ns / 1000;
686 if (host->clock) 686 if (host->clock)
@@ -1019,8 +1019,8 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
1019 } 1019 }
1020 1020
1021 timeout = jiffies; 1021 timeout = jiffies;
1022 if (!cmd->data && cmd->cmd_timeout_ms > 9000) 1022 if (!cmd->data && cmd->busy_timeout > 9000)
1023 timeout += DIV_ROUND_UP(cmd->cmd_timeout_ms, 1000) * HZ + HZ; 1023 timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
1024 else 1024 else
1025 timeout += 10 * HZ; 1025 timeout += 10 * HZ;
1026 mod_timer(&host->timer, timeout); 1026 mod_timer(&host->timer, timeout);
@@ -2026,12 +2026,11 @@ out:
2026 host->tuning_count * HZ); 2026 host->tuning_count * HZ);
2027 /* Tuning mode 1 limits the maximum data length to 4MB */ 2027 /* Tuning mode 1 limits the maximum data length to 4MB */
2028 mmc->max_blk_count = (4 * 1024 * 1024) / mmc->max_blk_size; 2028 mmc->max_blk_count = (4 * 1024 * 1024) / mmc->max_blk_size;
2029 } else { 2029 } else if (host->flags & SDHCI_USING_RETUNING_TIMER) {
2030 host->flags &= ~SDHCI_NEEDS_RETUNING; 2030 host->flags &= ~SDHCI_NEEDS_RETUNING;
2031 /* Reload the new initial value for timer */ 2031 /* Reload the new initial value for timer */
2032 if (host->tuning_mode == SDHCI_TUNING_MODE_1) 2032 mod_timer(&host->tuning_timer, jiffies +
2033 mod_timer(&host->tuning_timer, jiffies + 2033 host->tuning_count * HZ);
2034 host->tuning_count * HZ);
2035 } 2034 }
2036 2035
2037 /* 2036 /*
@@ -2434,9 +2433,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
2434 2433
2435 if (host->runtime_suspended) { 2434 if (host->runtime_suspended) {
2436 spin_unlock(&host->lock); 2435 spin_unlock(&host->lock);
2437 pr_warning("%s: got irq while runtime suspended\n", 2436 return IRQ_NONE;
2438 mmc_hostname(host->mmc));
2439 return IRQ_HANDLED;
2440 } 2437 }
2441 2438
2442 intmask = sdhci_readl(host, SDHCI_INT_STATUS); 2439 intmask = sdhci_readl(host, SDHCI_INT_STATUS);
@@ -2941,7 +2938,7 @@ int sdhci_add_host(struct sdhci_host *host)
2941 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) 2938 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
2942 host->timeout_clk = mmc->f_max / 1000; 2939 host->timeout_clk = mmc->f_max / 1000;
2943 2940
2944 mmc->max_discard_to = (1 << 27) / host->timeout_clk; 2941 mmc->max_busy_timeout = (1 << 27) / host->timeout_clk;
2945 2942
2946 mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23; 2943 mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
2947 2944
@@ -3020,7 +3017,8 @@ int sdhci_add_host(struct sdhci_host *host)
3020 } else if (caps[1] & SDHCI_SUPPORT_SDR50) 3017 } else if (caps[1] & SDHCI_SUPPORT_SDR50)
3021 mmc->caps |= MMC_CAP_UHS_SDR50; 3018 mmc->caps |= MMC_CAP_UHS_SDR50;
3022 3019
3023 if (caps[1] & SDHCI_SUPPORT_DDR50) 3020 if ((caps[1] & SDHCI_SUPPORT_DDR50) &&
3021 !(host->quirks2 & SDHCI_QUIRK2_BROKEN_DDR50))
3024 mmc->caps |= MMC_CAP_UHS_DDR50; 3022 mmc->caps |= MMC_CAP_UHS_DDR50;
3025 3023
3026 /* Does the host need tuning for SDR50? */ 3024 /* Does the host need tuning for SDR50? */
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 2d6ce257a273..91058dabd11a 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -37,6 +37,8 @@
37 37
38struct sh_mobile_sdhi_of_data { 38struct sh_mobile_sdhi_of_data {
39 unsigned long tmio_flags; 39 unsigned long tmio_flags;
40 unsigned long capabilities;
41 unsigned long capabilities2;
40}; 42};
41 43
42static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = { 44static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
@@ -45,6 +47,31 @@ static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
45 }, 47 },
46}; 48};
47 49
50static const struct sh_mobile_sdhi_of_data of_rcar_gen1_compatible = {
51 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE,
52 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
53};
54
55static const struct sh_mobile_sdhi_of_data of_rcar_gen2_compatible = {
56 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE,
57 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
58 .capabilities2 = MMC_CAP2_NO_MULTI_READ,
59};
60
61static const struct of_device_id sh_mobile_sdhi_of_match[] = {
62 { .compatible = "renesas,sdhi-shmobile" },
63 { .compatible = "renesas,sdhi-sh7372" },
64 { .compatible = "renesas,sdhi-sh73a0", .data = &sh_mobile_sdhi_of_cfg[0], },
65 { .compatible = "renesas,sdhi-r8a73a4", .data = &sh_mobile_sdhi_of_cfg[0], },
66 { .compatible = "renesas,sdhi-r8a7740", .data = &sh_mobile_sdhi_of_cfg[0], },
67 { .compatible = "renesas,sdhi-r8a7778", .data = &of_rcar_gen1_compatible, },
68 { .compatible = "renesas,sdhi-r8a7779", .data = &of_rcar_gen1_compatible, },
69 { .compatible = "renesas,sdhi-r8a7790", .data = &of_rcar_gen2_compatible, },
70 { .compatible = "renesas,sdhi-r8a7791", .data = &of_rcar_gen2_compatible, },
71 {},
72};
73MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
74
48struct sh_mobile_sdhi { 75struct sh_mobile_sdhi {
49 struct clk *clk; 76 struct clk *clk;
50 struct tmio_mmc_data mmc_data; 77 struct tmio_mmc_data mmc_data;
@@ -114,19 +141,6 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = {
114 .cd_wakeup = sh_mobile_sdhi_cd_wakeup, 141 .cd_wakeup = sh_mobile_sdhi_cd_wakeup,
115}; 142};
116 143
117static const struct of_device_id sh_mobile_sdhi_of_match[] = {
118 { .compatible = "renesas,sdhi-shmobile" },
119 { .compatible = "renesas,sdhi-sh7372" },
120 { .compatible = "renesas,sdhi-sh73a0", .data = &sh_mobile_sdhi_of_cfg[0], },
121 { .compatible = "renesas,sdhi-r8a73a4", .data = &sh_mobile_sdhi_of_cfg[0], },
122 { .compatible = "renesas,sdhi-r8a7740", .data = &sh_mobile_sdhi_of_cfg[0], },
123 { .compatible = "renesas,sdhi-r8a7778", .data = &sh_mobile_sdhi_of_cfg[0], },
124 { .compatible = "renesas,sdhi-r8a7779", .data = &sh_mobile_sdhi_of_cfg[0], },
125 { .compatible = "renesas,sdhi-r8a7790", .data = &sh_mobile_sdhi_of_cfg[0], },
126 {},
127};
128MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
129
130static int sh_mobile_sdhi_probe(struct platform_device *pdev) 144static int sh_mobile_sdhi_probe(struct platform_device *pdev)
131{ 145{
132 const struct of_device_id *of_id = 146 const struct of_device_id *of_id =
@@ -212,6 +226,8 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
212 if (of_id && of_id->data) { 226 if (of_id && of_id->data) {
213 const struct sh_mobile_sdhi_of_data *of_data = of_id->data; 227 const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
214 mmc_data->flags |= of_data->tmio_flags; 228 mmc_data->flags |= of_data->tmio_flags;
229 mmc_data->capabilities |= of_data->capabilities;
230 mmc_data->capabilities2 |= of_data->capabilities2;
215 } 231 }
216 232
217 /* SD control register space size is 0x100, 0x200 for bus_shift=1 */ 233 /* SD control register space size is 0x100, 0x200 for bus_shift=1 */
@@ -316,10 +332,10 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
316} 332}
317 333
318static const struct dev_pm_ops tmio_mmc_dev_pm_ops = { 334static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
319 .suspend = tmio_mmc_host_suspend, 335 SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_host_suspend, tmio_mmc_host_resume)
320 .resume = tmio_mmc_host_resume, 336 SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
321 .runtime_suspend = tmio_mmc_host_runtime_suspend, 337 tmio_mmc_host_runtime_resume,
322 .runtime_resume = tmio_mmc_host_runtime_resume, 338 NULL)
323}; 339};
324 340
325static struct platform_driver sh_mobile_sdhi_driver = { 341static struct platform_driver sh_mobile_sdhi_driver = {
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 1900abb04236..cfad844730d8 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -23,38 +23,37 @@
23 23
24#include "tmio_mmc.h" 24#include "tmio_mmc.h"
25 25
26#ifdef CONFIG_PM 26#ifdef CONFIG_PM_SLEEP
27static int tmio_mmc_suspend(struct platform_device *dev, pm_message_t state) 27static int tmio_mmc_suspend(struct device *dev)
28{ 28{
29 const struct mfd_cell *cell = mfd_get_cell(dev); 29 struct platform_device *pdev = to_platform_device(dev);
30 const struct mfd_cell *cell = mfd_get_cell(pdev);
30 int ret; 31 int ret;
31 32
32 ret = tmio_mmc_host_suspend(&dev->dev); 33 ret = tmio_mmc_host_suspend(dev);
33 34
34 /* Tell MFD core it can disable us now.*/ 35 /* Tell MFD core it can disable us now.*/
35 if (!ret && cell->disable) 36 if (!ret && cell->disable)
36 cell->disable(dev); 37 cell->disable(pdev);
37 38
38 return ret; 39 return ret;
39} 40}
40 41
41static int tmio_mmc_resume(struct platform_device *dev) 42static int tmio_mmc_resume(struct device *dev)
42{ 43{
43 const struct mfd_cell *cell = mfd_get_cell(dev); 44 struct platform_device *pdev = to_platform_device(dev);
45 const struct mfd_cell *cell = mfd_get_cell(pdev);
44 int ret = 0; 46 int ret = 0;
45 47
46 /* Tell the MFD core we are ready to be enabled */ 48 /* Tell the MFD core we are ready to be enabled */
47 if (cell->resume) 49 if (cell->resume)
48 ret = cell->resume(dev); 50 ret = cell->resume(pdev);
49 51
50 if (!ret) 52 if (!ret)
51 ret = tmio_mmc_host_resume(&dev->dev); 53 ret = tmio_mmc_host_resume(dev);
52 54
53 return ret; 55 return ret;
54} 56}
55#else
56#define tmio_mmc_suspend NULL
57#define tmio_mmc_resume NULL
58#endif 57#endif
59 58
60static int tmio_mmc_probe(struct platform_device *pdev) 59static int tmio_mmc_probe(struct platform_device *pdev)
@@ -134,15 +133,18 @@ static int tmio_mmc_remove(struct platform_device *pdev)
134 133
135/* ------------------- device registration ----------------------- */ 134/* ------------------- device registration ----------------------- */
136 135
136static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
137 SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume)
138};
139
137static struct platform_driver tmio_mmc_driver = { 140static struct platform_driver tmio_mmc_driver = {
138 .driver = { 141 .driver = {
139 .name = "tmio-mmc", 142 .name = "tmio-mmc",
140 .owner = THIS_MODULE, 143 .owner = THIS_MODULE,
144 .pm = &tmio_mmc_dev_pm_ops,
141 }, 145 },
142 .probe = tmio_mmc_probe, 146 .probe = tmio_mmc_probe,
143 .remove = tmio_mmc_remove, 147 .remove = tmio_mmc_remove,
144 .suspend = tmio_mmc_suspend,
145 .resume = tmio_mmc_resume,
146}; 148};
147 149
148module_platform_driver(tmio_mmc_driver); 150module_platform_driver(tmio_mmc_driver);
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index aaa9c7e9e730..100ffe0b2faf 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -162,16 +162,15 @@ static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
162} 162}
163#endif 163#endif
164 164
165#ifdef CONFIG_PM 165#ifdef CONFIG_PM_SLEEP
166int tmio_mmc_host_suspend(struct device *dev); 166int tmio_mmc_host_suspend(struct device *dev);
167int tmio_mmc_host_resume(struct device *dev); 167int tmio_mmc_host_resume(struct device *dev);
168#else
169#define tmio_mmc_host_suspend NULL
170#define tmio_mmc_host_resume NULL
171#endif 168#endif
172 169
170#ifdef CONFIG_PM_RUNTIME
173int tmio_mmc_host_runtime_suspend(struct device *dev); 171int tmio_mmc_host_runtime_suspend(struct device *dev);
174int tmio_mmc_host_runtime_resume(struct device *dev); 172int tmio_mmc_host_runtime_resume(struct device *dev);
173#endif
175 174
176static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr) 175static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr)
177{ 176{
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 8d8abf23a611..faf0924e71cb 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1142,7 +1142,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
1142} 1142}
1143EXPORT_SYMBOL(tmio_mmc_host_remove); 1143EXPORT_SYMBOL(tmio_mmc_host_remove);
1144 1144
1145#ifdef CONFIG_PM 1145#ifdef CONFIG_PM_SLEEP
1146int tmio_mmc_host_suspend(struct device *dev) 1146int tmio_mmc_host_suspend(struct device *dev)
1147{ 1147{
1148 struct mmc_host *mmc = dev_get_drvdata(dev); 1148 struct mmc_host *mmc = dev_get_drvdata(dev);
@@ -1165,9 +1165,9 @@ int tmio_mmc_host_resume(struct device *dev)
1165 return 0; 1165 return 0;
1166} 1166}
1167EXPORT_SYMBOL(tmio_mmc_host_resume); 1167EXPORT_SYMBOL(tmio_mmc_host_resume);
1168#endif
1168 1169
1169#endif /* CONFIG_PM */ 1170#ifdef CONFIG_PM_RUNTIME
1170
1171int tmio_mmc_host_runtime_suspend(struct device *dev) 1171int tmio_mmc_host_runtime_suspend(struct device *dev)
1172{ 1172{
1173 return 0; 1173 return 0;
@@ -1184,5 +1184,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
1184 return 0; 1184 return 0;
1185} 1185}
1186EXPORT_SYMBOL(tmio_mmc_host_runtime_resume); 1186EXPORT_SYMBOL(tmio_mmc_host_runtime_resume);
1187#endif
1187 1188
1188MODULE_LICENSE("GPL v2"); 1189MODULE_LICENSE("GPL v2");
diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c
index c0105a2e269a..d2c386f09d69 100644
--- a/drivers/mmc/host/ushc.c
+++ b/drivers/mmc/host/ushc.c
@@ -504,7 +504,7 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
504 ret = -ENOMEM; 504 ret = -ENOMEM;
505 goto err; 505 goto err;
506 } 506 }
507 ushc->csw = kzalloc(sizeof(struct ushc_cbw), GFP_KERNEL); 507 ushc->csw = kzalloc(sizeof(struct ushc_csw), GFP_KERNEL);
508 if (ushc->csw == NULL) { 508 if (ushc->csw == NULL) {
509 ret = -ENOMEM; 509 ret = -ENOMEM;
510 goto err; 510 goto err;
diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
index e902ed7846b0..498d1f799085 100644
--- a/drivers/mmc/host/wmt-sdmmc.c
+++ b/drivers/mmc/host/wmt-sdmmc.c
@@ -757,7 +757,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
757 struct device_node *np = pdev->dev.of_node; 757 struct device_node *np = pdev->dev.of_node;
758 const struct of_device_id *of_id = 758 const struct of_device_id *of_id =
759 of_match_device(wmt_mci_dt_ids, &pdev->dev); 759 of_match_device(wmt_mci_dt_ids, &pdev->dev);
760 const struct wmt_mci_caps *wmt_caps = of_id->data; 760 const struct wmt_mci_caps *wmt_caps;
761 int ret; 761 int ret;
762 int regular_irq, dma_irq; 762 int regular_irq, dma_irq;
763 763
@@ -766,6 +766,8 @@ static int wmt_mci_probe(struct platform_device *pdev)
766 return -EFAULT; 766 return -EFAULT;
767 } 767 }
768 768
769 wmt_caps = of_id->data;
770
769 if (!np) { 771 if (!np) {
770 dev_err(&pdev->dev, "Missing SDMMC description in devicetree\n"); 772 dev_err(&pdev->dev, "Missing SDMMC description in devicetree\n");
771 return -EFAULT; 773 return -EFAULT;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d9f85464b362..69aff72c8957 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4492,6 +4492,7 @@ static int __init bonding_init(void)
4492out: 4492out:
4493 return res; 4493 return res;
4494err: 4494err:
4495 bond_destroy_debugfs();
4495 bond_netlink_fini(); 4496 bond_netlink_fini();
4496err_link: 4497err_link:
4497 unregister_pernet_subsys(&bond_net_ops); 4498 unregister_pernet_subsys(&bond_net_ops);
diff --git a/drivers/net/ethernet/8390/apne.c b/drivers/net/ethernet/8390/apne.c
index 30104b60da85..c56ac9ebc08f 100644
--- a/drivers/net/ethernet/8390/apne.c
+++ b/drivers/net/ethernet/8390/apne.c
@@ -560,9 +560,7 @@ static struct net_device *apne_dev;
560static int __init apne_module_init(void) 560static int __init apne_module_init(void)
561{ 561{
562 apne_dev = apne_probe(-1); 562 apne_dev = apne_probe(-1);
563 if (IS_ERR(apne_dev)) 563 return PTR_ERR_OR_ZERO(apne_dev);
564 return PTR_ERR(apne_dev);
565 return 0;
566} 564}
567 565
568static void __exit apne_module_exit(void) 566static void __exit apne_module_exit(void)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index fcaeeb8a4929..28460676b8ca 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -268,15 +268,6 @@ static unsigned int emac_setup(struct net_device *ndev)
268 writel(reg_val | EMAC_TX_MODE_ABORTED_FRAME_EN, 268 writel(reg_val | EMAC_TX_MODE_ABORTED_FRAME_EN,
269 db->membase + EMAC_TX_MODE_REG); 269 db->membase + EMAC_TX_MODE_REG);
270 270
271 /* set up RX */
272 reg_val = readl(db->membase + EMAC_RX_CTL_REG);
273
274 writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN |
275 EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN |
276 EMAC_RX_CTL_ACCEPT_MULTICAST_EN |
277 EMAC_RX_CTL_ACCEPT_BROADCAST_EN,
278 db->membase + EMAC_RX_CTL_REG);
279
280 /* set MAC */ 271 /* set MAC */
281 /* set MAC CTL0 */ 272 /* set MAC CTL0 */
282 reg_val = readl(db->membase + EMAC_MAC_CTL0_REG); 273 reg_val = readl(db->membase + EMAC_MAC_CTL0_REG);
@@ -309,6 +300,26 @@ static unsigned int emac_setup(struct net_device *ndev)
309 return 0; 300 return 0;
310} 301}
311 302
303static void emac_set_rx_mode(struct net_device *ndev)
304{
305 struct emac_board_info *db = netdev_priv(ndev);
306 unsigned int reg_val;
307
308 /* set up RX */
309 reg_val = readl(db->membase + EMAC_RX_CTL_REG);
310
311 if (ndev->flags & IFF_PROMISC)
312 reg_val |= EMAC_RX_CTL_PASS_ALL_EN;
313 else
314 reg_val &= ~EMAC_RX_CTL_PASS_ALL_EN;
315
316 writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN |
317 EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN |
318 EMAC_RX_CTL_ACCEPT_MULTICAST_EN |
319 EMAC_RX_CTL_ACCEPT_BROADCAST_EN,
320 db->membase + EMAC_RX_CTL_REG);
321}
322
312static unsigned int emac_powerup(struct net_device *ndev) 323static unsigned int emac_powerup(struct net_device *ndev)
313{ 324{
314 struct emac_board_info *db = netdev_priv(ndev); 325 struct emac_board_info *db = netdev_priv(ndev);
@@ -782,6 +793,7 @@ static const struct net_device_ops emac_netdev_ops = {
782 .ndo_stop = emac_stop, 793 .ndo_stop = emac_stop,
783 .ndo_start_xmit = emac_start_xmit, 794 .ndo_start_xmit = emac_start_xmit,
784 .ndo_tx_timeout = emac_timeout, 795 .ndo_tx_timeout = emac_timeout,
796 .ndo_set_rx_mode = emac_set_rx_mode,
785 .ndo_do_ioctl = emac_ioctl, 797 .ndo_do_ioctl = emac_ioctl,
786 .ndo_change_mtu = eth_change_mtu, 798 .ndo_change_mtu = eth_change_mtu,
787 .ndo_validate_addr = eth_validate_addr, 799 .ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.c b/drivers/net/ethernet/intel/e1000/e1000_hw.c
index 2879b9631e15..c1d3fdb296a0 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_hw.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_hw.c
@@ -115,8 +115,6 @@ static DEFINE_SPINLOCK(e1000_phy_lock);
115 */ 115 */
116static s32 e1000_set_phy_type(struct e1000_hw *hw) 116static s32 e1000_set_phy_type(struct e1000_hw *hw)
117{ 117{
118 e_dbg("e1000_set_phy_type");
119
120 if (hw->mac_type == e1000_undefined) 118 if (hw->mac_type == e1000_undefined)
121 return -E1000_ERR_PHY_TYPE; 119 return -E1000_ERR_PHY_TYPE;
122 120
@@ -159,8 +157,6 @@ static void e1000_phy_init_script(struct e1000_hw *hw)
159 u32 ret_val; 157 u32 ret_val;
160 u16 phy_saved_data; 158 u16 phy_saved_data;
161 159
162 e_dbg("e1000_phy_init_script");
163
164 if (hw->phy_init_script) { 160 if (hw->phy_init_script) {
165 msleep(20); 161 msleep(20);
166 162
@@ -253,8 +249,6 @@ static void e1000_phy_init_script(struct e1000_hw *hw)
253 */ 249 */
254s32 e1000_set_mac_type(struct e1000_hw *hw) 250s32 e1000_set_mac_type(struct e1000_hw *hw)
255{ 251{
256 e_dbg("e1000_set_mac_type");
257
258 switch (hw->device_id) { 252 switch (hw->device_id) {
259 case E1000_DEV_ID_82542: 253 case E1000_DEV_ID_82542:
260 switch (hw->revision_id) { 254 switch (hw->revision_id) {
@@ -365,8 +359,6 @@ void e1000_set_media_type(struct e1000_hw *hw)
365{ 359{
366 u32 status; 360 u32 status;
367 361
368 e_dbg("e1000_set_media_type");
369
370 if (hw->mac_type != e1000_82543) { 362 if (hw->mac_type != e1000_82543) {
371 /* tbi_compatibility is only valid on 82543 */ 363 /* tbi_compatibility is only valid on 82543 */
372 hw->tbi_compatibility_en = false; 364 hw->tbi_compatibility_en = false;
@@ -415,8 +407,6 @@ s32 e1000_reset_hw(struct e1000_hw *hw)
415 u32 led_ctrl; 407 u32 led_ctrl;
416 s32 ret_val; 408 s32 ret_val;
417 409
418 e_dbg("e1000_reset_hw");
419
420 /* For 82542 (rev 2.0), disable MWI before issuing a device reset */ 410 /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
421 if (hw->mac_type == e1000_82542_rev2_0) { 411 if (hw->mac_type == e1000_82542_rev2_0) {
422 e_dbg("Disabling MWI on 82542 rev 2.0\n"); 412 e_dbg("Disabling MWI on 82542 rev 2.0\n");
@@ -566,8 +556,6 @@ s32 e1000_init_hw(struct e1000_hw *hw)
566 u32 mta_size; 556 u32 mta_size;
567 u32 ctrl_ext; 557 u32 ctrl_ext;
568 558
569 e_dbg("e1000_init_hw");
570
571 /* Initialize Identification LED */ 559 /* Initialize Identification LED */
572 ret_val = e1000_id_led_init(hw); 560 ret_val = e1000_id_led_init(hw);
573 if (ret_val) { 561 if (ret_val) {
@@ -683,8 +671,6 @@ static s32 e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
683 u16 eeprom_data; 671 u16 eeprom_data;
684 s32 ret_val; 672 s32 ret_val;
685 673
686 e_dbg("e1000_adjust_serdes_amplitude");
687
688 if (hw->media_type != e1000_media_type_internal_serdes) 674 if (hw->media_type != e1000_media_type_internal_serdes)
689 return E1000_SUCCESS; 675 return E1000_SUCCESS;
690 676
@@ -730,8 +716,6 @@ s32 e1000_setup_link(struct e1000_hw *hw)
730 s32 ret_val; 716 s32 ret_val;
731 u16 eeprom_data; 717 u16 eeprom_data;
732 718
733 e_dbg("e1000_setup_link");
734
735 /* Read and store word 0x0F of the EEPROM. This word contains bits 719 /* Read and store word 0x0F of the EEPROM. This word contains bits
736 * that determine the hardware's default PAUSE (flow control) mode, 720 * that determine the hardware's default PAUSE (flow control) mode,
737 * a bit that determines whether the HW defaults to enabling or 721 * a bit that determines whether the HW defaults to enabling or
@@ -848,8 +832,6 @@ static s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
848 u32 signal = 0; 832 u32 signal = 0;
849 s32 ret_val; 833 s32 ret_val;
850 834
851 e_dbg("e1000_setup_fiber_serdes_link");
852
853 /* On adapters with a MAC newer than 82544, SWDP 1 will be 835 /* On adapters with a MAC newer than 82544, SWDP 1 will be
854 * set when the optics detect a signal. On older adapters, it will be 836 * set when the optics detect a signal. On older adapters, it will be
855 * cleared when there is a signal. This applies to fiber media only. 837 * cleared when there is a signal. This applies to fiber media only.
@@ -1051,8 +1033,6 @@ static s32 e1000_copper_link_preconfig(struct e1000_hw *hw)
1051 s32 ret_val; 1033 s32 ret_val;
1052 u16 phy_data; 1034 u16 phy_data;
1053 1035
1054 e_dbg("e1000_copper_link_preconfig");
1055
1056 ctrl = er32(CTRL); 1036 ctrl = er32(CTRL);
1057 /* With 82543, we need to force speed and duplex on the MAC equal to 1037 /* With 82543, we need to force speed and duplex on the MAC equal to
1058 * what the PHY speed and duplex configuration is. In addition, we need 1038 * what the PHY speed and duplex configuration is. In addition, we need
@@ -1112,8 +1092,6 @@ static s32 e1000_copper_link_igp_setup(struct e1000_hw *hw)
1112 s32 ret_val; 1092 s32 ret_val;
1113 u16 phy_data; 1093 u16 phy_data;
1114 1094
1115 e_dbg("e1000_copper_link_igp_setup");
1116
1117 if (hw->phy_reset_disable) 1095 if (hw->phy_reset_disable)
1118 return E1000_SUCCESS; 1096 return E1000_SUCCESS;
1119 1097
@@ -1254,8 +1232,6 @@ static s32 e1000_copper_link_mgp_setup(struct e1000_hw *hw)
1254 s32 ret_val; 1232 s32 ret_val;
1255 u16 phy_data; 1233 u16 phy_data;
1256 1234
1257 e_dbg("e1000_copper_link_mgp_setup");
1258
1259 if (hw->phy_reset_disable) 1235 if (hw->phy_reset_disable)
1260 return E1000_SUCCESS; 1236 return E1000_SUCCESS;
1261 1237
@@ -1362,8 +1338,6 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
1362 s32 ret_val; 1338 s32 ret_val;
1363 u16 phy_data; 1339 u16 phy_data;
1364 1340
1365 e_dbg("e1000_copper_link_autoneg");
1366
1367 /* Perform some bounds checking on the hw->autoneg_advertised 1341 /* Perform some bounds checking on the hw->autoneg_advertised
1368 * parameter. If this variable is zero, then set it to the default. 1342 * parameter. If this variable is zero, then set it to the default.
1369 */ 1343 */
@@ -1432,7 +1406,6 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
1432static s32 e1000_copper_link_postconfig(struct e1000_hw *hw) 1406static s32 e1000_copper_link_postconfig(struct e1000_hw *hw)
1433{ 1407{
1434 s32 ret_val; 1408 s32 ret_val;
1435 e_dbg("e1000_copper_link_postconfig");
1436 1409
1437 if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_ce4100)) { 1410 if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_ce4100)) {
1438 e1000_config_collision_dist(hw); 1411 e1000_config_collision_dist(hw);
@@ -1473,8 +1446,6 @@ static s32 e1000_setup_copper_link(struct e1000_hw *hw)
1473 u16 i; 1446 u16 i;
1474 u16 phy_data; 1447 u16 phy_data;
1475 1448
1476 e_dbg("e1000_setup_copper_link");
1477
1478 /* Check if it is a valid PHY and set PHY mode if necessary. */ 1449 /* Check if it is a valid PHY and set PHY mode if necessary. */
1479 ret_val = e1000_copper_link_preconfig(hw); 1450 ret_val = e1000_copper_link_preconfig(hw);
1480 if (ret_val) 1451 if (ret_val)
@@ -1554,8 +1525,6 @@ s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
1554 u16 mii_autoneg_adv_reg; 1525 u16 mii_autoneg_adv_reg;
1555 u16 mii_1000t_ctrl_reg; 1526 u16 mii_1000t_ctrl_reg;
1556 1527
1557 e_dbg("e1000_phy_setup_autoneg");
1558
1559 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ 1528 /* Read the MII Auto-Neg Advertisement Register (Address 4). */
1560 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); 1529 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
1561 if (ret_val) 1530 if (ret_val)
@@ -1707,8 +1676,6 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
1707 u16 phy_data; 1676 u16 phy_data;
1708 u16 i; 1677 u16 i;
1709 1678
1710 e_dbg("e1000_phy_force_speed_duplex");
1711
1712 /* Turn off Flow control if we are forcing speed and duplex. */ 1679 /* Turn off Flow control if we are forcing speed and duplex. */
1713 hw->fc = E1000_FC_NONE; 1680 hw->fc = E1000_FC_NONE;
1714 1681
@@ -1939,8 +1906,6 @@ void e1000_config_collision_dist(struct e1000_hw *hw)
1939{ 1906{
1940 u32 tctl, coll_dist; 1907 u32 tctl, coll_dist;
1941 1908
1942 e_dbg("e1000_config_collision_dist");
1943
1944 if (hw->mac_type < e1000_82543) 1909 if (hw->mac_type < e1000_82543)
1945 coll_dist = E1000_COLLISION_DISTANCE_82542; 1910 coll_dist = E1000_COLLISION_DISTANCE_82542;
1946 else 1911 else
@@ -1970,8 +1935,6 @@ static s32 e1000_config_mac_to_phy(struct e1000_hw *hw)
1970 s32 ret_val; 1935 s32 ret_val;
1971 u16 phy_data; 1936 u16 phy_data;
1972 1937
1973 e_dbg("e1000_config_mac_to_phy");
1974
1975 /* 82544 or newer MAC, Auto Speed Detection takes care of 1938 /* 82544 or newer MAC, Auto Speed Detection takes care of
1976 * MAC speed/duplex configuration. 1939 * MAC speed/duplex configuration.
1977 */ 1940 */
@@ -2049,8 +2012,6 @@ s32 e1000_force_mac_fc(struct e1000_hw *hw)
2049{ 2012{
2050 u32 ctrl; 2013 u32 ctrl;
2051 2014
2052 e_dbg("e1000_force_mac_fc");
2053
2054 /* Get the current configuration of the Device Control Register */ 2015 /* Get the current configuration of the Device Control Register */
2055 ctrl = er32(CTRL); 2016 ctrl = er32(CTRL);
2056 2017
@@ -2120,8 +2081,6 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)
2120 u16 speed; 2081 u16 speed;
2121 u16 duplex; 2082 u16 duplex;
2122 2083
2123 e_dbg("e1000_config_fc_after_link_up");
2124
2125 /* Check for the case where we have fiber media and auto-neg failed 2084 /* Check for the case where we have fiber media and auto-neg failed
2126 * so we had to force link. In this case, we need to force the 2085 * so we had to force link. In this case, we need to force the
2127 * configuration of the MAC to match the "fc" parameter. 2086 * configuration of the MAC to match the "fc" parameter.
@@ -2337,8 +2296,6 @@ static s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)
2337 u32 status; 2296 u32 status;
2338 s32 ret_val = E1000_SUCCESS; 2297 s32 ret_val = E1000_SUCCESS;
2339 2298
2340 e_dbg("e1000_check_for_serdes_link_generic");
2341
2342 ctrl = er32(CTRL); 2299 ctrl = er32(CTRL);
2343 status = er32(STATUS); 2300 status = er32(STATUS);
2344 rxcw = er32(RXCW); 2301 rxcw = er32(RXCW);
@@ -2449,8 +2406,6 @@ s32 e1000_check_for_link(struct e1000_hw *hw)
2449 s32 ret_val; 2406 s32 ret_val;
2450 u16 phy_data; 2407 u16 phy_data;
2451 2408
2452 e_dbg("e1000_check_for_link");
2453
2454 ctrl = er32(CTRL); 2409 ctrl = er32(CTRL);
2455 status = er32(STATUS); 2410 status = er32(STATUS);
2456 2411
@@ -2632,8 +2587,6 @@ s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
2632 s32 ret_val; 2587 s32 ret_val;
2633 u16 phy_data; 2588 u16 phy_data;
2634 2589
2635 e_dbg("e1000_get_speed_and_duplex");
2636
2637 if (hw->mac_type >= e1000_82543) { 2590 if (hw->mac_type >= e1000_82543) {
2638 status = er32(STATUS); 2591 status = er32(STATUS);
2639 if (status & E1000_STATUS_SPEED_1000) { 2592 if (status & E1000_STATUS_SPEED_1000) {
@@ -2699,7 +2652,6 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw)
2699 u16 i; 2652 u16 i;
2700 u16 phy_data; 2653 u16 phy_data;
2701 2654
2702 e_dbg("e1000_wait_autoneg");
2703 e_dbg("Waiting for Auto-Neg to complete.\n"); 2655 e_dbg("Waiting for Auto-Neg to complete.\n");
2704 2656
2705 /* We will wait for autoneg to complete or 4.5 seconds to expire. */ 2657 /* We will wait for autoneg to complete or 4.5 seconds to expire. */
@@ -2866,8 +2818,6 @@ s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 reg_addr, u16 *phy_data)
2866 u32 ret_val; 2818 u32 ret_val;
2867 unsigned long flags; 2819 unsigned long flags;
2868 2820
2869 e_dbg("e1000_read_phy_reg");
2870
2871 spin_lock_irqsave(&e1000_phy_lock, flags); 2821 spin_lock_irqsave(&e1000_phy_lock, flags);
2872 2822
2873 if ((hw->phy_type == e1000_phy_igp) && 2823 if ((hw->phy_type == e1000_phy_igp) &&
@@ -2894,8 +2844,6 @@ static s32 e1000_read_phy_reg_ex(struct e1000_hw *hw, u32 reg_addr,
2894 u32 mdic = 0; 2844 u32 mdic = 0;
2895 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1; 2845 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1;
2896 2846
2897 e_dbg("e1000_read_phy_reg_ex");
2898
2899 if (reg_addr > MAX_PHY_REG_ADDRESS) { 2847 if (reg_addr > MAX_PHY_REG_ADDRESS) {
2900 e_dbg("PHY Address %d is out of range\n", reg_addr); 2848 e_dbg("PHY Address %d is out of range\n", reg_addr);
2901 return -E1000_ERR_PARAM; 2849 return -E1000_ERR_PARAM;
@@ -3008,8 +2956,6 @@ s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 reg_addr, u16 phy_data)
3008 u32 ret_val; 2956 u32 ret_val;
3009 unsigned long flags; 2957 unsigned long flags;
3010 2958
3011 e_dbg("e1000_write_phy_reg");
3012
3013 spin_lock_irqsave(&e1000_phy_lock, flags); 2959 spin_lock_irqsave(&e1000_phy_lock, flags);
3014 2960
3015 if ((hw->phy_type == e1000_phy_igp) && 2961 if ((hw->phy_type == e1000_phy_igp) &&
@@ -3036,8 +2982,6 @@ static s32 e1000_write_phy_reg_ex(struct e1000_hw *hw, u32 reg_addr,
3036 u32 mdic = 0; 2982 u32 mdic = 0;
3037 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1; 2983 const u32 phy_addr = (hw->mac_type == e1000_ce4100) ? hw->phy_addr : 1;
3038 2984
3039 e_dbg("e1000_write_phy_reg_ex");
3040
3041 if (reg_addr > MAX_PHY_REG_ADDRESS) { 2985 if (reg_addr > MAX_PHY_REG_ADDRESS) {
3042 e_dbg("PHY Address %d is out of range\n", reg_addr); 2986 e_dbg("PHY Address %d is out of range\n", reg_addr);
3043 return -E1000_ERR_PARAM; 2987 return -E1000_ERR_PARAM;
@@ -3129,8 +3073,6 @@ s32 e1000_phy_hw_reset(struct e1000_hw *hw)
3129 u32 ctrl, ctrl_ext; 3073 u32 ctrl, ctrl_ext;
3130 u32 led_ctrl; 3074 u32 led_ctrl;
3131 3075
3132 e_dbg("e1000_phy_hw_reset");
3133
3134 e_dbg("Resetting Phy...\n"); 3076 e_dbg("Resetting Phy...\n");
3135 3077
3136 if (hw->mac_type > e1000_82543) { 3078 if (hw->mac_type > e1000_82543) {
@@ -3189,8 +3131,6 @@ s32 e1000_phy_reset(struct e1000_hw *hw)
3189 s32 ret_val; 3131 s32 ret_val;
3190 u16 phy_data; 3132 u16 phy_data;
3191 3133
3192 e_dbg("e1000_phy_reset");
3193
3194 switch (hw->phy_type) { 3134 switch (hw->phy_type) {
3195 case e1000_phy_igp: 3135 case e1000_phy_igp:
3196 ret_val = e1000_phy_hw_reset(hw); 3136 ret_val = e1000_phy_hw_reset(hw);
@@ -3229,8 +3169,6 @@ static s32 e1000_detect_gig_phy(struct e1000_hw *hw)
3229 u16 phy_id_high, phy_id_low; 3169 u16 phy_id_high, phy_id_low;
3230 bool match = false; 3170 bool match = false;
3231 3171
3232 e_dbg("e1000_detect_gig_phy");
3233
3234 if (hw->phy_id != 0) 3172 if (hw->phy_id != 0)
3235 return E1000_SUCCESS; 3173 return E1000_SUCCESS;
3236 3174
@@ -3301,7 +3239,6 @@ static s32 e1000_detect_gig_phy(struct e1000_hw *hw)
3301static s32 e1000_phy_reset_dsp(struct e1000_hw *hw) 3239static s32 e1000_phy_reset_dsp(struct e1000_hw *hw)
3302{ 3240{
3303 s32 ret_val; 3241 s32 ret_val;
3304 e_dbg("e1000_phy_reset_dsp");
3305 3242
3306 do { 3243 do {
3307 ret_val = e1000_write_phy_reg(hw, 29, 0x001d); 3244 ret_val = e1000_write_phy_reg(hw, 29, 0x001d);
@@ -3333,8 +3270,6 @@ static s32 e1000_phy_igp_get_info(struct e1000_hw *hw,
3333 u16 phy_data, min_length, max_length, average; 3270 u16 phy_data, min_length, max_length, average;
3334 e1000_rev_polarity polarity; 3271 e1000_rev_polarity polarity;
3335 3272
3336 e_dbg("e1000_phy_igp_get_info");
3337
3338 /* The downshift status is checked only once, after link is established, 3273 /* The downshift status is checked only once, after link is established,
3339 * and it stored in the hw->speed_downgraded parameter. 3274 * and it stored in the hw->speed_downgraded parameter.
3340 */ 3275 */
@@ -3414,8 +3349,6 @@ static s32 e1000_phy_m88_get_info(struct e1000_hw *hw,
3414 u16 phy_data; 3349 u16 phy_data;
3415 e1000_rev_polarity polarity; 3350 e1000_rev_polarity polarity;
3416 3351
3417 e_dbg("e1000_phy_m88_get_info");
3418
3419 /* The downshift status is checked only once, after link is established, 3352 /* The downshift status is checked only once, after link is established,
3420 * and it stored in the hw->speed_downgraded parameter. 3353 * and it stored in the hw->speed_downgraded parameter.
3421 */ 3354 */
@@ -3487,8 +3420,6 @@ s32 e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info)
3487 s32 ret_val; 3420 s32 ret_val;
3488 u16 phy_data; 3421 u16 phy_data;
3489 3422
3490 e_dbg("e1000_phy_get_info");
3491
3492 phy_info->cable_length = e1000_cable_length_undefined; 3423 phy_info->cable_length = e1000_cable_length_undefined;
3493 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined; 3424 phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined;
3494 phy_info->cable_polarity = e1000_rev_polarity_undefined; 3425 phy_info->cable_polarity = e1000_rev_polarity_undefined;
@@ -3527,8 +3458,6 @@ s32 e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info)
3527 3458
3528s32 e1000_validate_mdi_setting(struct e1000_hw *hw) 3459s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
3529{ 3460{
3530 e_dbg("e1000_validate_mdi_settings");
3531
3532 if (!hw->autoneg && (hw->mdix == 0 || hw->mdix == 3)) { 3461 if (!hw->autoneg && (hw->mdix == 0 || hw->mdix == 3)) {
3533 e_dbg("Invalid MDI setting detected\n"); 3462 e_dbg("Invalid MDI setting detected\n");
3534 hw->mdix = 1; 3463 hw->mdix = 1;
@@ -3551,8 +3480,6 @@ s32 e1000_init_eeprom_params(struct e1000_hw *hw)
3551 s32 ret_val = E1000_SUCCESS; 3480 s32 ret_val = E1000_SUCCESS;
3552 u16 eeprom_size; 3481 u16 eeprom_size;
3553 3482
3554 e_dbg("e1000_init_eeprom_params");
3555
3556 switch (hw->mac_type) { 3483 switch (hw->mac_type) {
3557 case e1000_82542_rev2_0: 3484 case e1000_82542_rev2_0:
3558 case e1000_82542_rev2_1: 3485 case e1000_82542_rev2_1:
@@ -3770,8 +3697,6 @@ static s32 e1000_acquire_eeprom(struct e1000_hw *hw)
3770 struct e1000_eeprom_info *eeprom = &hw->eeprom; 3697 struct e1000_eeprom_info *eeprom = &hw->eeprom;
3771 u32 eecd, i = 0; 3698 u32 eecd, i = 0;
3772 3699
3773 e_dbg("e1000_acquire_eeprom");
3774
3775 eecd = er32(EECD); 3700 eecd = er32(EECD);
3776 3701
3777 /* Request EEPROM Access */ 3702 /* Request EEPROM Access */
@@ -3871,8 +3796,6 @@ static void e1000_release_eeprom(struct e1000_hw *hw)
3871{ 3796{
3872 u32 eecd; 3797 u32 eecd;
3873 3798
3874 e_dbg("e1000_release_eeprom");
3875
3876 eecd = er32(EECD); 3799 eecd = er32(EECD);
3877 3800
3878 if (hw->eeprom.type == e1000_eeprom_spi) { 3801 if (hw->eeprom.type == e1000_eeprom_spi) {
@@ -3920,8 +3843,6 @@ static s32 e1000_spi_eeprom_ready(struct e1000_hw *hw)
3920 u16 retry_count = 0; 3843 u16 retry_count = 0;
3921 u8 spi_stat_reg; 3844 u8 spi_stat_reg;
3922 3845
3923 e_dbg("e1000_spi_eeprom_ready");
3924
3925 /* Read "Status Register" repeatedly until the LSB is cleared. The 3846 /* Read "Status Register" repeatedly until the LSB is cleared. The
3926 * EEPROM will signal that the command has been completed by clearing 3847 * EEPROM will signal that the command has been completed by clearing
3927 * bit 0 of the internal status register. If it's not cleared within 3848 * bit 0 of the internal status register. If it's not cleared within
@@ -3974,8 +3895,6 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,
3974 struct e1000_eeprom_info *eeprom = &hw->eeprom; 3895 struct e1000_eeprom_info *eeprom = &hw->eeprom;
3975 u32 i = 0; 3896 u32 i = 0;
3976 3897
3977 e_dbg("e1000_read_eeprom");
3978
3979 if (hw->mac_type == e1000_ce4100) { 3898 if (hw->mac_type == e1000_ce4100) {
3980 GBE_CONFIG_FLASH_READ(GBE_CONFIG_BASE_VIRT, offset, words, 3899 GBE_CONFIG_FLASH_READ(GBE_CONFIG_BASE_VIRT, offset, words,
3981 data); 3900 data);
@@ -4076,8 +3995,6 @@ s32 e1000_validate_eeprom_checksum(struct e1000_hw *hw)
4076 u16 checksum = 0; 3995 u16 checksum = 0;
4077 u16 i, eeprom_data; 3996 u16 i, eeprom_data;
4078 3997
4079 e_dbg("e1000_validate_eeprom_checksum");
4080
4081 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { 3998 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
4082 if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { 3999 if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
4083 e_dbg("EEPROM Read Error\n"); 4000 e_dbg("EEPROM Read Error\n");
@@ -4112,8 +4029,6 @@ s32 e1000_update_eeprom_checksum(struct e1000_hw *hw)
4112 u16 checksum = 0; 4029 u16 checksum = 0;
4113 u16 i, eeprom_data; 4030 u16 i, eeprom_data;
4114 4031
4115 e_dbg("e1000_update_eeprom_checksum");
4116
4117 for (i = 0; i < EEPROM_CHECKSUM_REG; i++) { 4032 for (i = 0; i < EEPROM_CHECKSUM_REG; i++) {
4118 if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { 4033 if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
4119 e_dbg("EEPROM Read Error\n"); 4034 e_dbg("EEPROM Read Error\n");
@@ -4154,8 +4069,6 @@ static s32 e1000_do_write_eeprom(struct e1000_hw *hw, u16 offset, u16 words,
4154 struct e1000_eeprom_info *eeprom = &hw->eeprom; 4069 struct e1000_eeprom_info *eeprom = &hw->eeprom;
4155 s32 status = 0; 4070 s32 status = 0;
4156 4071
4157 e_dbg("e1000_write_eeprom");
4158
4159 if (hw->mac_type == e1000_ce4100) { 4072 if (hw->mac_type == e1000_ce4100) {
4160 GBE_CONFIG_FLASH_WRITE(GBE_CONFIG_BASE_VIRT, offset, words, 4073 GBE_CONFIG_FLASH_WRITE(GBE_CONFIG_BASE_VIRT, offset, words,
4161 data); 4074 data);
@@ -4205,8 +4118,6 @@ static s32 e1000_write_eeprom_spi(struct e1000_hw *hw, u16 offset, u16 words,
4205 struct e1000_eeprom_info *eeprom = &hw->eeprom; 4118 struct e1000_eeprom_info *eeprom = &hw->eeprom;
4206 u16 widx = 0; 4119 u16 widx = 0;
4207 4120
4208 e_dbg("e1000_write_eeprom_spi");
4209
4210 while (widx < words) { 4121 while (widx < words) {
4211 u8 write_opcode = EEPROM_WRITE_OPCODE_SPI; 4122 u8 write_opcode = EEPROM_WRITE_OPCODE_SPI;
4212 4123
@@ -4274,8 +4185,6 @@ static s32 e1000_write_eeprom_microwire(struct e1000_hw *hw, u16 offset,
4274 u16 words_written = 0; 4185 u16 words_written = 0;
4275 u16 i = 0; 4186 u16 i = 0;
4276 4187
4277 e_dbg("e1000_write_eeprom_microwire");
4278
4279 /* Send the write enable command to the EEPROM (3-bit opcode plus 4188 /* Send the write enable command to the EEPROM (3-bit opcode plus
4280 * 6/8-bit dummy address beginning with 11). It's less work to include 4189 * 6/8-bit dummy address beginning with 11). It's less work to include
4281 * the 11 of the dummy address as part of the opcode than it is to shift 4190 * the 11 of the dummy address as part of the opcode than it is to shift
@@ -4354,8 +4263,6 @@ s32 e1000_read_mac_addr(struct e1000_hw *hw)
4354 u16 offset; 4263 u16 offset;
4355 u16 eeprom_data, i; 4264 u16 eeprom_data, i;
4356 4265
4357 e_dbg("e1000_read_mac_addr");
4358
4359 for (i = 0; i < NODE_ADDRESS_SIZE; i += 2) { 4266 for (i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
4360 offset = i >> 1; 4267 offset = i >> 1;
4361 if (e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) { 4268 if (e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
@@ -4394,8 +4301,6 @@ static void e1000_init_rx_addrs(struct e1000_hw *hw)
4394 u32 i; 4301 u32 i;
4395 u32 rar_num; 4302 u32 rar_num;
4396 4303
4397 e_dbg("e1000_init_rx_addrs");
4398
4399 /* Setup the receive address. */ 4304 /* Setup the receive address. */
4400 e_dbg("Programming MAC Address into RAR[0]\n"); 4305 e_dbg("Programming MAC Address into RAR[0]\n");
4401 4306
@@ -4553,8 +4458,6 @@ static s32 e1000_id_led_init(struct e1000_hw *hw)
4553 u16 eeprom_data, i, temp; 4458 u16 eeprom_data, i, temp;
4554 const u16 led_mask = 0x0F; 4459 const u16 led_mask = 0x0F;
4555 4460
4556 e_dbg("e1000_id_led_init");
4557
4558 if (hw->mac_type < e1000_82540) { 4461 if (hw->mac_type < e1000_82540) {
4559 /* Nothing to do */ 4462 /* Nothing to do */
4560 return E1000_SUCCESS; 4463 return E1000_SUCCESS;
@@ -4626,8 +4529,6 @@ s32 e1000_setup_led(struct e1000_hw *hw)
4626 u32 ledctl; 4529 u32 ledctl;
4627 s32 ret_val = E1000_SUCCESS; 4530 s32 ret_val = E1000_SUCCESS;
4628 4531
4629 e_dbg("e1000_setup_led");
4630
4631 switch (hw->mac_type) { 4532 switch (hw->mac_type) {
4632 case e1000_82542_rev2_0: 4533 case e1000_82542_rev2_0:
4633 case e1000_82542_rev2_1: 4534 case e1000_82542_rev2_1:
@@ -4678,8 +4579,6 @@ s32 e1000_cleanup_led(struct e1000_hw *hw)
4678{ 4579{
4679 s32 ret_val = E1000_SUCCESS; 4580 s32 ret_val = E1000_SUCCESS;
4680 4581
4681 e_dbg("e1000_cleanup_led");
4682
4683 switch (hw->mac_type) { 4582 switch (hw->mac_type) {
4684 case e1000_82542_rev2_0: 4583 case e1000_82542_rev2_0:
4685 case e1000_82542_rev2_1: 4584 case e1000_82542_rev2_1:
@@ -4714,8 +4613,6 @@ s32 e1000_led_on(struct e1000_hw *hw)
4714{ 4613{
4715 u32 ctrl = er32(CTRL); 4614 u32 ctrl = er32(CTRL);
4716 4615
4717 e_dbg("e1000_led_on");
4718
4719 switch (hw->mac_type) { 4616 switch (hw->mac_type) {
4720 case e1000_82542_rev2_0: 4617 case e1000_82542_rev2_0:
4721 case e1000_82542_rev2_1: 4618 case e1000_82542_rev2_1:
@@ -4760,8 +4657,6 @@ s32 e1000_led_off(struct e1000_hw *hw)
4760{ 4657{
4761 u32 ctrl = er32(CTRL); 4658 u32 ctrl = er32(CTRL);
4762 4659
4763 e_dbg("e1000_led_off");
4764
4765 switch (hw->mac_type) { 4660 switch (hw->mac_type) {
4766 case e1000_82542_rev2_0: 4661 case e1000_82542_rev2_0:
4767 case e1000_82542_rev2_1: 4662 case e1000_82542_rev2_1:
@@ -4889,8 +4784,6 @@ static void e1000_clear_hw_cntrs(struct e1000_hw *hw)
4889 */ 4784 */
4890void e1000_reset_adaptive(struct e1000_hw *hw) 4785void e1000_reset_adaptive(struct e1000_hw *hw)
4891{ 4786{
4892 e_dbg("e1000_reset_adaptive");
4893
4894 if (hw->adaptive_ifs) { 4787 if (hw->adaptive_ifs) {
4895 if (!hw->ifs_params_forced) { 4788 if (!hw->ifs_params_forced) {
4896 hw->current_ifs_val = 0; 4789 hw->current_ifs_val = 0;
@@ -4917,8 +4810,6 @@ void e1000_reset_adaptive(struct e1000_hw *hw)
4917 */ 4810 */
4918void e1000_update_adaptive(struct e1000_hw *hw) 4811void e1000_update_adaptive(struct e1000_hw *hw)
4919{ 4812{
4920 e_dbg("e1000_update_adaptive");
4921
4922 if (hw->adaptive_ifs) { 4813 if (hw->adaptive_ifs) {
4923 if ((hw->collision_delta *hw->ifs_ratio) > hw->tx_packet_delta) { 4814 if ((hw->collision_delta *hw->ifs_ratio) > hw->tx_packet_delta) {
4924 if (hw->tx_packet_delta > MIN_NUM_XMITS) { 4815 if (hw->tx_packet_delta > MIN_NUM_XMITS) {
@@ -5114,8 +5005,6 @@ static s32 e1000_get_cable_length(struct e1000_hw *hw, u16 *min_length,
5114 u16 i, phy_data; 5005 u16 i, phy_data;
5115 u16 cable_length; 5006 u16 cable_length;
5116 5007
5117 e_dbg("e1000_get_cable_length");
5118
5119 *min_length = *max_length = 0; 5008 *min_length = *max_length = 0;
5120 5009
5121 /* Use old method for Phy older than IGP */ 5010 /* Use old method for Phy older than IGP */
@@ -5231,8 +5120,6 @@ static s32 e1000_check_polarity(struct e1000_hw *hw,
5231 s32 ret_val; 5120 s32 ret_val;
5232 u16 phy_data; 5121 u16 phy_data;
5233 5122
5234 e_dbg("e1000_check_polarity");
5235
5236 if (hw->phy_type == e1000_phy_m88) { 5123 if (hw->phy_type == e1000_phy_m88) {
5237 /* return the Polarity bit in the Status register. */ 5124 /* return the Polarity bit in the Status register. */
5238 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, 5125 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
@@ -5299,8 +5186,6 @@ static s32 e1000_check_downshift(struct e1000_hw *hw)
5299 s32 ret_val; 5186 s32 ret_val;
5300 u16 phy_data; 5187 u16 phy_data;
5301 5188
5302 e_dbg("e1000_check_downshift");
5303
5304 if (hw->phy_type == e1000_phy_igp) { 5189 if (hw->phy_type == e1000_phy_igp) {
5305 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH, 5190 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH,
5306 &phy_data); 5191 &phy_data);
@@ -5411,8 +5296,6 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)
5411 s32 ret_val; 5296 s32 ret_val;
5412 u16 phy_data, phy_saved_data, speed, duplex, i; 5297 u16 phy_data, phy_saved_data, speed, duplex, i;
5413 5298
5414 e_dbg("e1000_config_dsp_after_link_change");
5415
5416 if (hw->phy_type != e1000_phy_igp) 5299 if (hw->phy_type != e1000_phy_igp)
5417 return E1000_SUCCESS; 5300 return E1000_SUCCESS;
5418 5301
@@ -5546,8 +5429,6 @@ static s32 e1000_set_phy_mode(struct e1000_hw *hw)
5546 s32 ret_val; 5429 s32 ret_val;
5547 u16 eeprom_data; 5430 u16 eeprom_data;
5548 5431
5549 e_dbg("e1000_set_phy_mode");
5550
5551 if ((hw->mac_type == e1000_82545_rev_3) && 5432 if ((hw->mac_type == e1000_82545_rev_3) &&
5552 (hw->media_type == e1000_media_type_copper)) { 5433 (hw->media_type == e1000_media_type_copper)) {
5553 ret_val = 5434 ret_val =
@@ -5594,7 +5475,6 @@ static s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
5594{ 5475{
5595 s32 ret_val; 5476 s32 ret_val;
5596 u16 phy_data; 5477 u16 phy_data;
5597 e_dbg("e1000_set_d3_lplu_state");
5598 5478
5599 if (hw->phy_type != e1000_phy_igp) 5479 if (hw->phy_type != e1000_phy_igp)
5600 return E1000_SUCCESS; 5480 return E1000_SUCCESS;
@@ -5699,8 +5579,6 @@ static s32 e1000_set_vco_speed(struct e1000_hw *hw)
5699 u16 default_page = 0; 5579 u16 default_page = 0;
5700 u16 phy_data; 5580 u16 phy_data;
5701 5581
5702 e_dbg("e1000_set_vco_speed");
5703
5704 switch (hw->mac_type) { 5582 switch (hw->mac_type) {
5705 case e1000_82545_rev_3: 5583 case e1000_82545_rev_3:
5706 case e1000_82546_rev_3: 5584 case e1000_82546_rev_3:
@@ -5872,7 +5750,6 @@ static s32 e1000_polarity_reversal_workaround(struct e1000_hw *hw)
5872 */ 5750 */
5873static s32 e1000_get_auto_rd_done(struct e1000_hw *hw) 5751static s32 e1000_get_auto_rd_done(struct e1000_hw *hw)
5874{ 5752{
5875 e_dbg("e1000_get_auto_rd_done");
5876 msleep(5); 5753 msleep(5);
5877 return E1000_SUCCESS; 5754 return E1000_SUCCESS;
5878} 5755}
@@ -5887,7 +5764,6 @@ static s32 e1000_get_auto_rd_done(struct e1000_hw *hw)
5887 */ 5764 */
5888static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw) 5765static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw)
5889{ 5766{
5890 e_dbg("e1000_get_phy_cfg_done");
5891 msleep(10); 5767 msleep(10);
5892 return E1000_SUCCESS; 5768 return E1000_SUCCESS;
5893} 5769}
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 46e6544ed1b7..27058dfe418b 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -2682,14 +2682,13 @@ static int e1000_tso(struct e1000_adapter *adapter,
2682 u32 cmd_length = 0; 2682 u32 cmd_length = 0;
2683 u16 ipcse = 0, tucse, mss; 2683 u16 ipcse = 0, tucse, mss;
2684 u8 ipcss, ipcso, tucss, tucso, hdr_len; 2684 u8 ipcss, ipcso, tucss, tucso, hdr_len;
2685 int err;
2686 2685
2687 if (skb_is_gso(skb)) { 2686 if (skb_is_gso(skb)) {
2688 if (skb_header_cloned(skb)) { 2687 int err;
2689 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 2688
2690 if (err) 2689 err = skb_cow_head(skb, 0);
2691 return err; 2690 if (err < 0)
2692 } 2691 return err;
2693 2692
2694 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 2693 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
2695 mss = skb_shinfo(skb)->gso_size; 2694 mss = skb_shinfo(skb)->gso_size;
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index dce377b59b2c..d50c91e50528 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -5100,16 +5100,14 @@ static int e1000_tso(struct e1000_ring *tx_ring, struct sk_buff *skb)
5100 u32 cmd_length = 0; 5100 u32 cmd_length = 0;
5101 u16 ipcse = 0, mss; 5101 u16 ipcse = 0, mss;
5102 u8 ipcss, ipcso, tucss, tucso, hdr_len; 5102 u8 ipcss, ipcso, tucss, tucso, hdr_len;
5103 int err;
5103 5104
5104 if (!skb_is_gso(skb)) 5105 if (!skb_is_gso(skb))
5105 return 0; 5106 return 0;
5106 5107
5107 if (skb_header_cloned(skb)) { 5108 err = skb_cow_head(skb, 0);
5108 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 5109 if (err < 0)
5109 5110 return err;
5110 if (err)
5111 return err;
5112 }
5113 5111
5114 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 5112 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
5115 mss = skb_shinfo(skb)->gso_size; 5113 mss = skb_shinfo(skb)->gso_size;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index 53be5f44d015..b9f50f40abe1 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -1114,20 +1114,18 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
1114 u64 *cd_type_cmd_tso_mss, u32 *cd_tunneling) 1114 u64 *cd_type_cmd_tso_mss, u32 *cd_tunneling)
1115{ 1115{
1116 u32 cd_cmd, cd_tso_len, cd_mss; 1116 u32 cd_cmd, cd_tso_len, cd_mss;
1117 struct ipv6hdr *ipv6h;
1117 struct tcphdr *tcph; 1118 struct tcphdr *tcph;
1118 struct iphdr *iph; 1119 struct iphdr *iph;
1119 u32 l4len; 1120 u32 l4len;
1120 int err; 1121 int err;
1121 struct ipv6hdr *ipv6h;
1122 1122
1123 if (!skb_is_gso(skb)) 1123 if (!skb_is_gso(skb))
1124 return 0; 1124 return 0;
1125 1125
1126 if (skb_header_cloned(skb)) { 1126 err = skb_cow_head(skb, 0);
1127 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 1127 if (err < 0)
1128 if (err) 1128 return err;
1129 return err;
1130 }
1131 1129
1132 if (protocol == htons(ETH_P_IP)) { 1130 if (protocol == htons(ETH_P_IP)) {
1133 iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb); 1131 iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index e35e66ffa782..2797548fde0d 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1412,6 +1412,14 @@ restart_watchdog:
1412 schedule_work(&adapter->adminq_task); 1412 schedule_work(&adapter->adminq_task);
1413} 1413}
1414 1414
1415/**
1416 * i40evf_configure_rss - increment to next available tx queue
1417 * @adapter: board private structure
1418 * @j: queue counter
1419 *
1420 * Helper function for RSS programming to increment through available
1421 * queus. Returns the next queue value.
1422 **/
1415static int next_queue(struct i40evf_adapter *adapter, int j) 1423static int next_queue(struct i40evf_adapter *adapter, int j)
1416{ 1424{
1417 j += 1; 1425 j += 1;
@@ -1451,10 +1459,14 @@ static void i40evf_configure_rss(struct i40evf_adapter *adapter)
1451 /* Populate the LUT with max no. of queues in round robin fashion */ 1459 /* Populate the LUT with max no. of queues in round robin fashion */
1452 j = adapter->vsi_res->num_queue_pairs; 1460 j = adapter->vsi_res->num_queue_pairs;
1453 for (i = 0; i <= I40E_VFQF_HLUT_MAX_INDEX; i++) { 1461 for (i = 0; i <= I40E_VFQF_HLUT_MAX_INDEX; i++) {
1454 lut = next_queue(adapter, j); 1462 j = next_queue(adapter, j);
1455 lut |= next_queue(adapter, j) << 8; 1463 lut = j;
1456 lut |= next_queue(adapter, j) << 16; 1464 j = next_queue(adapter, j);
1457 lut |= next_queue(adapter, j) << 24; 1465 lut |= j << 8;
1466 j = next_queue(adapter, j);
1467 lut |= j << 16;
1468 j = next_queue(adapter, j);
1469 lut |= j << 24;
1458 wr32(hw, I40E_VFQF_HLUT(i), lut); 1470 wr32(hw, I40E_VFQF_HLUT(i), lut);
1459 } 1471 }
1460 i40e_flush(hw); 1472 i40e_flush(hw);
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 7fbe1e925143..27130065d92a 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -241,7 +241,6 @@ struct igb_ring {
241 struct igb_tx_buffer *tx_buffer_info; 241 struct igb_tx_buffer *tx_buffer_info;
242 struct igb_rx_buffer *rx_buffer_info; 242 struct igb_rx_buffer *rx_buffer_info;
243 }; 243 };
244 unsigned long last_rx_timestamp;
245 void *desc; /* descriptor ring memory */ 244 void *desc; /* descriptor ring memory */
246 unsigned long flags; /* ring specific flags */ 245 unsigned long flags; /* ring specific flags */
247 void __iomem *tail; /* pointer to ring tail register */ 246 void __iomem *tail; /* pointer to ring tail register */
@@ -437,6 +436,7 @@ struct igb_adapter {
437 struct hwtstamp_config tstamp_config; 436 struct hwtstamp_config tstamp_config;
438 unsigned long ptp_tx_start; 437 unsigned long ptp_tx_start;
439 unsigned long last_rx_ptp_check; 438 unsigned long last_rx_ptp_check;
439 unsigned long last_rx_timestamp;
440 spinlock_t tmreg_lock; 440 spinlock_t tmreg_lock;
441 struct cyclecounter cc; 441 struct cyclecounter cc;
442 struct timecounter tc; 442 struct timecounter tc;
@@ -533,20 +533,6 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter);
533void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb); 533void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
534void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, unsigned char *va, 534void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, unsigned char *va,
535 struct sk_buff *skb); 535 struct sk_buff *skb);
536static inline void igb_ptp_rx_hwtstamp(struct igb_ring *rx_ring,
537 union e1000_adv_rx_desc *rx_desc,
538 struct sk_buff *skb)
539{
540 if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TS) &&
541 !igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))
542 igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
543
544 /* Update the last_rx_timestamp timer in order to enable watchdog check
545 * for error case of latched timestamp on a dropped packet.
546 */
547 rx_ring->last_rx_timestamp = jiffies;
548}
549
550int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr); 536int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
551int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr); 537int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
552#ifdef CONFIG_IGB_HWMON 538#ifdef CONFIG_IGB_HWMON
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 30198185d19a..fb98d4602f9d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4605,6 +4605,7 @@ static int igb_tso(struct igb_ring *tx_ring,
4605 struct sk_buff *skb = first->skb; 4605 struct sk_buff *skb = first->skb;
4606 u32 vlan_macip_lens, type_tucmd; 4606 u32 vlan_macip_lens, type_tucmd;
4607 u32 mss_l4len_idx, l4len; 4607 u32 mss_l4len_idx, l4len;
4608 int err;
4608 4609
4609 if (skb->ip_summed != CHECKSUM_PARTIAL) 4610 if (skb->ip_summed != CHECKSUM_PARTIAL)
4610 return 0; 4611 return 0;
@@ -4612,11 +4613,9 @@ static int igb_tso(struct igb_ring *tx_ring,
4612 if (!skb_is_gso(skb)) 4613 if (!skb_is_gso(skb))
4613 return 0; 4614 return 0;
4614 4615
4615 if (skb_header_cloned(skb)) { 4616 err = skb_cow_head(skb, 0);
4616 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 4617 if (err < 0)
4617 if (err) 4618 return err;
4618 return err;
4619 }
4620 4619
4621 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ 4620 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
4622 type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP; 4621 type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP;
@@ -6955,7 +6954,9 @@ static void igb_process_skb_fields(struct igb_ring *rx_ring,
6955 6954
6956 igb_rx_checksum(rx_ring, rx_desc, skb); 6955 igb_rx_checksum(rx_ring, rx_desc, skb);
6957 6956
6958 igb_ptp_rx_hwtstamp(rx_ring, rx_desc, skb); 6957 if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TS) &&
6958 !igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))
6959 igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
6959 6960
6960 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) && 6961 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
6961 igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) { 6962 igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) {
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 2cca8fd5e574..9209d652e1c9 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -427,10 +427,8 @@ static void igb_ptp_overflow_check(struct work_struct *work)
427void igb_ptp_rx_hang(struct igb_adapter *adapter) 427void igb_ptp_rx_hang(struct igb_adapter *adapter)
428{ 428{
429 struct e1000_hw *hw = &adapter->hw; 429 struct e1000_hw *hw = &adapter->hw;
430 struct igb_ring *rx_ring;
431 u32 tsyncrxctl = rd32(E1000_TSYNCRXCTL); 430 u32 tsyncrxctl = rd32(E1000_TSYNCRXCTL);
432 unsigned long rx_event; 431 unsigned long rx_event;
433 int n;
434 432
435 if (hw->mac.type != e1000_82576) 433 if (hw->mac.type != e1000_82576)
436 return; 434 return;
@@ -445,11 +443,8 @@ void igb_ptp_rx_hang(struct igb_adapter *adapter)
445 443
446 /* Determine the most recent watchdog or rx_timestamp event */ 444 /* Determine the most recent watchdog or rx_timestamp event */
447 rx_event = adapter->last_rx_ptp_check; 445 rx_event = adapter->last_rx_ptp_check;
448 for (n = 0; n < adapter->num_rx_queues; n++) { 446 if (time_after(adapter->last_rx_timestamp, rx_event))
449 rx_ring = adapter->rx_ring[n]; 447 rx_event = adapter->last_rx_timestamp;
450 if (time_after(rx_ring->last_rx_timestamp, rx_event))
451 rx_event = rx_ring->last_rx_timestamp;
452 }
453 448
454 /* Only need to read the high RXSTMP register to clear the lock */ 449 /* Only need to read the high RXSTMP register to clear the lock */
455 if (time_is_before_jiffies(rx_event + 5 * HZ)) { 450 if (time_is_before_jiffies(rx_event + 5 * HZ)) {
@@ -540,6 +535,11 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
540 regval |= (u64)rd32(E1000_RXSTMPH) << 32; 535 regval |= (u64)rd32(E1000_RXSTMPH) << 32;
541 536
542 igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval); 537 igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval);
538
539 /* Update the last_rx_timestamp timer in order to enable watchdog check
540 * for error case of latched timestamp on a dropped packet.
541 */
542 adapter->last_rx_timestamp = jiffies;
543} 543}
544 544
545/** 545/**
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index b7ab03a2f28f..d608599e123a 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1910,20 +1910,18 @@ static int igbvf_tso(struct igbvf_adapter *adapter,
1910 struct sk_buff *skb, u32 tx_flags, u8 *hdr_len) 1910 struct sk_buff *skb, u32 tx_flags, u8 *hdr_len)
1911{ 1911{
1912 struct e1000_adv_tx_context_desc *context_desc; 1912 struct e1000_adv_tx_context_desc *context_desc;
1913 unsigned int i;
1914 int err;
1915 struct igbvf_buffer *buffer_info; 1913 struct igbvf_buffer *buffer_info;
1916 u32 info = 0, tu_cmd = 0; 1914 u32 info = 0, tu_cmd = 0;
1917 u32 mss_l4len_idx, l4len; 1915 u32 mss_l4len_idx, l4len;
1916 unsigned int i;
1917 int err;
1918
1918 *hdr_len = 0; 1919 *hdr_len = 0;
1919 1920
1920 if (skb_header_cloned(skb)) { 1921 err = skb_cow_head(skb, 0);
1921 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 1922 if (err < 0) {
1922 if (err) { 1923 dev_err(&adapter->pdev->dev, "igbvf_tso returning an error\n");
1923 dev_err(&adapter->pdev->dev, 1924 return err;
1924 "igbvf_tso returning an error\n");
1925 return err;
1926 }
1927 } 1925 }
1928 1926
1929 l4len = tcp_hdrlen(skb); 1927 l4len = tcp_hdrlen(skb);
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index f42c201f727f..60801273915c 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -1220,17 +1220,15 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1220 unsigned int i; 1220 unsigned int i;
1221 u8 ipcss, ipcso, tucss, tucso, hdr_len; 1221 u8 ipcss, ipcso, tucss, tucso, hdr_len;
1222 u16 ipcse, tucse, mss; 1222 u16 ipcse, tucse, mss;
1223 int err;
1224 1223
1225 if (likely(skb_is_gso(skb))) { 1224 if (likely(skb_is_gso(skb))) {
1226 struct ixgb_buffer *buffer_info; 1225 struct ixgb_buffer *buffer_info;
1227 struct iphdr *iph; 1226 struct iphdr *iph;
1227 int err;
1228 1228
1229 if (skb_header_cloned(skb)) { 1229 err = skb_cow_head(skb, 0);
1230 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 1230 if (err < 0)
1231 if (err) 1231 return err;
1232 return err;
1233 }
1234 1232
1235 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1233 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1236 mss = skb_shinfo(skb)->gso_size; 1234 mss = skb_shinfo(skb)->gso_size;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 55c53a1cbb62..1a12c1dd7a27 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -811,6 +811,7 @@ enum ixgbe_state_t {
811 __IXGBE_DISABLED, 811 __IXGBE_DISABLED,
812 __IXGBE_REMOVING, 812 __IXGBE_REMOVING,
813 __IXGBE_SERVICE_SCHED, 813 __IXGBE_SERVICE_SCHED,
814 __IXGBE_SERVICE_INITED,
814 __IXGBE_IN_SFP_INIT, 815 __IXGBE_IN_SFP_INIT,
815 __IXGBE_PTP_RUNNING, 816 __IXGBE_PTP_RUNNING,
816 __IXGBE_PTP_TX_IN_PROGRESS, 817 __IXGBE_PTP_TX_IN_PROGRESS,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 8436c651b735..c4c526b7f99f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -297,7 +297,8 @@ static void ixgbe_remove_adapter(struct ixgbe_hw *hw)
297 return; 297 return;
298 hw->hw_addr = NULL; 298 hw->hw_addr = NULL;
299 e_dev_err("Adapter removed\n"); 299 e_dev_err("Adapter removed\n");
300 ixgbe_service_event_schedule(adapter); 300 if (test_bit(__IXGBE_SERVICE_INITED, &adapter->state))
301 ixgbe_service_event_schedule(adapter);
301} 302}
302 303
303void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg) 304void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg)
@@ -6509,6 +6510,7 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
6509 struct sk_buff *skb = first->skb; 6510 struct sk_buff *skb = first->skb;
6510 u32 vlan_macip_lens, type_tucmd; 6511 u32 vlan_macip_lens, type_tucmd;
6511 u32 mss_l4len_idx, l4len; 6512 u32 mss_l4len_idx, l4len;
6513 int err;
6512 6514
6513 if (skb->ip_summed != CHECKSUM_PARTIAL) 6515 if (skb->ip_summed != CHECKSUM_PARTIAL)
6514 return 0; 6516 return 0;
@@ -6516,11 +6518,9 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,
6516 if (!skb_is_gso(skb)) 6518 if (!skb_is_gso(skb))
6517 return 0; 6519 return 0;
6518 6520
6519 if (skb_header_cloned(skb)) { 6521 err = skb_cow_head(skb, 0);
6520 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 6522 if (err < 0)
6521 if (err) 6523 return err;
6522 return err;
6523 }
6524 6524
6525 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ 6525 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
6526 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; 6526 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP;
@@ -7077,8 +7077,8 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
7077 IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT; 7077 IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT;
7078 if (tx_flags & IXGBE_TX_FLAGS_SW_VLAN) { 7078 if (tx_flags & IXGBE_TX_FLAGS_SW_VLAN) {
7079 struct vlan_ethhdr *vhdr; 7079 struct vlan_ethhdr *vhdr;
7080 if (skb_header_cloned(skb) && 7080
7081 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 7081 if (skb_cow_head(skb, 0))
7082 goto out_drop; 7082 goto out_drop;
7083 vhdr = (struct vlan_ethhdr *)skb->data; 7083 vhdr = (struct vlan_ethhdr *)skb->data;
7084 vhdr->h_vlan_TCI = htons(tx_flags >> 7084 vhdr->h_vlan_TCI = htons(tx_flags >>
@@ -8023,6 +8023,10 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8023 /* EEPROM */ 8023 /* EEPROM */
8024 memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops)); 8024 memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops));
8025 eec = IXGBE_READ_REG(hw, IXGBE_EEC); 8025 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
8026 if (ixgbe_removed(hw->hw_addr)) {
8027 err = -EIO;
8028 goto err_ioremap;
8029 }
8026 /* If EEPROM is valid (bit 8 = 1), use default otherwise use bit bang */ 8030 /* If EEPROM is valid (bit 8 = 1), use default otherwise use bit bang */
8027 if (!(eec & (1 << 8))) 8031 if (!(eec & (1 << 8)))
8028 hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic; 8032 hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic;
@@ -8185,7 +8189,12 @@ skip_sriov:
8185 setup_timer(&adapter->service_timer, &ixgbe_service_timer, 8189 setup_timer(&adapter->service_timer, &ixgbe_service_timer,
8186 (unsigned long) adapter); 8190 (unsigned long) adapter);
8187 8191
8192 if (ixgbe_removed(hw->hw_addr)) {
8193 err = -EIO;
8194 goto err_sw_init;
8195 }
8188 INIT_WORK(&adapter->service_task, ixgbe_service_task); 8196 INIT_WORK(&adapter->service_task, ixgbe_service_task);
8197 set_bit(__IXGBE_SERVICE_INITED, &adapter->state);
8189 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); 8198 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state);
8190 8199
8191 err = ixgbe_init_interrupt_scheme(adapter); 8200 err = ixgbe_init_interrupt_scheme(adapter);
@@ -8494,6 +8503,9 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
8494 8503
8495skip_bad_vf_detection: 8504skip_bad_vf_detection:
8496#endif /* CONFIG_PCI_IOV */ 8505#endif /* CONFIG_PCI_IOV */
8506 if (!test_bit(__IXGBE_SERVICE_INITED, &adapter->state))
8507 return PCI_ERS_RESULT_DISCONNECT;
8508
8497 rtnl_lock(); 8509 rtnl_lock();
8498 netif_device_detach(netdev); 8510 netif_device_detach(netdev);
8499 8511
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index e7e7d695816b..a0a1de9ce238 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -421,6 +421,7 @@ enum ixbgevf_state_t {
421 __IXGBEVF_DOWN, 421 __IXGBEVF_DOWN,
422 __IXGBEVF_DISABLED, 422 __IXGBEVF_DISABLED,
423 __IXGBEVF_REMOVING, 423 __IXGBEVF_REMOVING,
424 __IXGBEVF_WORK_INIT,
424}; 425};
425 426
426struct ixgbevf_cb { 427struct ixgbevf_cb {
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 4ba139b2d25a..d0799e8e31e4 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -107,7 +107,8 @@ static void ixgbevf_remove_adapter(struct ixgbe_hw *hw)
107 return; 107 return;
108 hw->hw_addr = NULL; 108 hw->hw_addr = NULL;
109 dev_err(&adapter->pdev->dev, "Adapter removed\n"); 109 dev_err(&adapter->pdev->dev, "Adapter removed\n");
110 schedule_work(&adapter->watchdog_task); 110 if (test_bit(__IXGBEVF_WORK_INIT, &adapter->state))
111 schedule_work(&adapter->watchdog_task);
111} 112}
112 113
113static void ixgbevf_check_remove(struct ixgbe_hw *hw, u32 reg) 114static void ixgbevf_check_remove(struct ixgbe_hw *hw, u32 reg)
@@ -2838,6 +2839,7 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring,
2838 struct sk_buff *skb = first->skb; 2839 struct sk_buff *skb = first->skb;
2839 u32 vlan_macip_lens, type_tucmd; 2840 u32 vlan_macip_lens, type_tucmd;
2840 u32 mss_l4len_idx, l4len; 2841 u32 mss_l4len_idx, l4len;
2842 int err;
2841 2843
2842 if (skb->ip_summed != CHECKSUM_PARTIAL) 2844 if (skb->ip_summed != CHECKSUM_PARTIAL)
2843 return 0; 2845 return 0;
@@ -2845,11 +2847,9 @@ static int ixgbevf_tso(struct ixgbevf_ring *tx_ring,
2845 if (!skb_is_gso(skb)) 2847 if (!skb_is_gso(skb))
2846 return 0; 2848 return 0;
2847 2849
2848 if (skb_header_cloned(skb)) { 2850 err = skb_cow_head(skb, 0);
2849 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 2851 if (err < 0)
2850 if (err) 2852 return err;
2851 return err;
2852 }
2853 2853
2854 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ 2854 /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
2855 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; 2855 type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP;
@@ -3573,8 +3573,13 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3573 adapter->watchdog_timer.function = ixgbevf_watchdog; 3573 adapter->watchdog_timer.function = ixgbevf_watchdog;
3574 adapter->watchdog_timer.data = (unsigned long)adapter; 3574 adapter->watchdog_timer.data = (unsigned long)adapter;
3575 3575
3576 if (IXGBE_REMOVED(hw->hw_addr)) {
3577 err = -EIO;
3578 goto err_sw_init;
3579 }
3576 INIT_WORK(&adapter->reset_task, ixgbevf_reset_task); 3580 INIT_WORK(&adapter->reset_task, ixgbevf_reset_task);
3577 INIT_WORK(&adapter->watchdog_task, ixgbevf_watchdog_task); 3581 INIT_WORK(&adapter->watchdog_task, ixgbevf_watchdog_task);
3582 set_bit(__IXGBEVF_WORK_INIT, &adapter->state);
3578 3583
3579 err = ixgbevf_init_interrupt_scheme(adapter); 3584 err = ixgbevf_init_interrupt_scheme(adapter);
3580 if (err) 3585 if (err)
@@ -3667,6 +3672,9 @@ static pci_ers_result_t ixgbevf_io_error_detected(struct pci_dev *pdev,
3667 struct net_device *netdev = pci_get_drvdata(pdev); 3672 struct net_device *netdev = pci_get_drvdata(pdev);
3668 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 3673 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
3669 3674
3675 if (!test_bit(__IXGBEVF_WORK_INIT, &adapter->state))
3676 return PCI_ERS_RESULT_DISCONNECT;
3677
3670 rtnl_lock(); 3678 rtnl_lock();
3671 netif_device_detach(netdev); 3679 netif_device_detach(netdev);
3672 3680
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 5d5fec6c4eb0..36aa109416c4 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -687,7 +687,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
687 687
688 cpsw_dual_emac_src_port_detect(status, priv, ndev, skb); 688 cpsw_dual_emac_src_port_detect(status, priv, ndev, skb);
689 689
690 if (unlikely(status < 0)) { 690 if (unlikely(status < 0) || unlikely(!netif_running(ndev))) {
691 /* the interface is going down, skbs are purged */ 691 /* the interface is going down, skbs are purged */
692 dev_kfree_skb_any(skb); 692 dev_kfree_skb_any(skb);
693 return; 693 return;
@@ -1201,8 +1201,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
1201 for_each_slave(priv, cpsw_slave_open, priv); 1201 for_each_slave(priv, cpsw_slave_open, priv);
1202 1202
1203 /* Add default VLAN */ 1203 /* Add default VLAN */
1204 if (!priv->data.dual_emac) 1204 cpsw_add_default_vlan(priv);
1205 cpsw_add_default_vlan(priv);
1206 1205
1207 if (!cpsw_common_res_usage_state(priv)) { 1206 if (!cpsw_common_res_usage_state(priv)) {
1208 /* setup tx dma to fixed prio and zero offset */ 1207 /* setup tx dma to fixed prio and zero offset */
@@ -1253,6 +1252,12 @@ static int cpsw_ndo_open(struct net_device *ndev)
1253 cpsw_set_coalesce(ndev, &coal); 1252 cpsw_set_coalesce(ndev, &coal);
1254 } 1253 }
1255 1254
1255 napi_enable(&priv->napi);
1256 cpdma_ctlr_start(priv->dma);
1257 cpsw_intr_enable(priv);
1258 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
1259 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
1260
1256 prim_cpsw = cpsw_get_slave_priv(priv, 0); 1261 prim_cpsw = cpsw_get_slave_priv(priv, 0);
1257 if (prim_cpsw->irq_enabled == false) { 1262 if (prim_cpsw->irq_enabled == false) {
1258 if ((priv == prim_cpsw) || !netif_running(prim_cpsw->ndev)) { 1263 if ((priv == prim_cpsw) || !netif_running(prim_cpsw->ndev)) {
@@ -1261,12 +1266,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
1261 } 1266 }
1262 } 1267 }
1263 1268
1264 napi_enable(&priv->napi);
1265 cpdma_ctlr_start(priv->dma);
1266 cpsw_intr_enable(priv);
1267 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
1268 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
1269
1270 if (priv->data.dual_emac) 1269 if (priv->data.dual_emac)
1271 priv->slaves[priv->emac_port].open_stat = true; 1270 priv->slaves[priv->emac_port].open_stat = true;
1272 return 0; 1271 return 0;
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 13010b4dae5b..d18f711d0b0c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -747,6 +747,7 @@ struct ndis_oject_header {
747#define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4 0 747#define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4 0
748#define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6 1 748#define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6 1
749 749
750#define VERSION_4_OFFLOAD_SIZE 22
750/* 751/*
751 * New offload OIDs for NDIS 6 752 * New offload OIDs for NDIS 6
752 */ 753 */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index daddea2654ce..f7629ecefa84 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -344,7 +344,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
344 memset(init_packet, 0, sizeof(struct nvsp_message)); 344 memset(init_packet, 0, sizeof(struct nvsp_message));
345 345
346 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_4) 346 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_4)
347 ndis_version = 0x00050001; 347 ndis_version = 0x00060001;
348 else 348 else
349 ndis_version = 0x0006001e; 349 ndis_version = 0x0006001e;
350 350
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 4e4cf9e0c8d7..31e55fba7cad 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -319,7 +319,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
319 packet = kzalloc(sizeof(struct hv_netvsc_packet) + 319 packet = kzalloc(sizeof(struct hv_netvsc_packet) +
320 (num_data_pgs * sizeof(struct hv_page_buffer)) + 320 (num_data_pgs * sizeof(struct hv_page_buffer)) +
321 sizeof(struct rndis_message) + 321 sizeof(struct rndis_message) +
322 NDIS_VLAN_PPI_SIZE, GFP_ATOMIC); 322 NDIS_VLAN_PPI_SIZE +
323 NDIS_CSUM_PPI_SIZE +
324 NDIS_LSO_PPI_SIZE, GFP_ATOMIC);
323 if (!packet) { 325 if (!packet) {
324 /* out of memory, drop packet */ 326 /* out of memory, drop packet */
325 netdev_err(net, "unable to allocate hv_netvsc_packet\n"); 327 netdev_err(net, "unable to allocate hv_netvsc_packet\n");
@@ -396,7 +398,30 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
396 csum_info->transmit.tcp_checksum = 1; 398 csum_info->transmit.tcp_checksum = 1;
397 csum_info->transmit.tcp_header_offset = hdr_offset; 399 csum_info->transmit.tcp_header_offset = hdr_offset;
398 } else if (net_trans_info & INFO_UDP) { 400 } else if (net_trans_info & INFO_UDP) {
399 csum_info->transmit.udp_checksum = 1; 401 /* UDP checksum offload is not supported on ws2008r2.
402 * Furthermore, on ws2012 and ws2012r2, there are some
403 * issues with udp checksum offload from Linux guests.
404 * (these are host issues).
405 * For now compute the checksum here.
406 */
407 struct udphdr *uh;
408 u16 udp_len;
409
410 ret = skb_cow_head(skb, 0);
411 if (ret)
412 goto drop;
413
414 uh = udp_hdr(skb);
415 udp_len = ntohs(uh->len);
416 uh->check = 0;
417 uh->check = csum_tcpudp_magic(ip_hdr(skb)->saddr,
418 ip_hdr(skb)->daddr,
419 udp_len, IPPROTO_UDP,
420 csum_partial(uh, udp_len, 0));
421 if (uh->check == 0)
422 uh->check = CSUM_MANGLED_0;
423
424 csum_info->transmit.udp_checksum = 0;
400 } 425 }
401 goto do_send; 426 goto do_send;
402 427
@@ -436,6 +461,7 @@ do_send:
436 461
437 ret = netvsc_send(net_device_ctx->device_ctx, packet); 462 ret = netvsc_send(net_device_ctx->device_ctx, packet);
438 463
464drop:
439 if (ret == 0) { 465 if (ret == 0) {
440 net->stats.tx_bytes += skb->len; 466 net->stats.tx_bytes += skb->len;
441 net->stats.tx_packets++; 467 net->stats.tx_packets++;
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 4a37e3db9e32..143a98caf618 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -641,6 +641,16 @@ int rndis_filter_set_offload_params(struct hv_device *hdev,
641 struct rndis_set_complete *set_complete; 641 struct rndis_set_complete *set_complete;
642 u32 extlen = sizeof(struct ndis_offload_params); 642 u32 extlen = sizeof(struct ndis_offload_params);
643 int ret, t; 643 int ret, t;
644 u32 vsp_version = nvdev->nvsp_version;
645
646 if (vsp_version <= NVSP_PROTOCOL_VERSION_4) {
647 extlen = VERSION_4_OFFLOAD_SIZE;
648 /* On NVSP_PROTOCOL_VERSION_4 and below, we do not support
649 * UDP checksum offload.
650 */
651 req_offloads->udp_ip_v4_csum = 0;
652 req_offloads->udp_ip_v6_csum = 0;
653 }
644 654
645 request = get_rndis_request(rdev, RNDIS_MSG_SET, 655 request = get_rndis_request(rdev, RNDIS_MSG_SET,
646 RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen); 656 RNDIS_MESSAGE_SIZE(struct rndis_set_request) + extlen);
@@ -674,7 +684,7 @@ int rndis_filter_set_offload_params(struct hv_device *hdev,
674 } else { 684 } else {
675 set_complete = &request->response_msg.msg.set_complete; 685 set_complete = &request->response_msg.msg.set_complete;
676 if (set_complete->status != RNDIS_STATUS_SUCCESS) { 686 if (set_complete->status != RNDIS_STATUS_SUCCESS) {
677 netdev_err(ndev, "Fail to set MAC on host side:0x%x\n", 687 netdev_err(ndev, "Fail to set offload on host side:0x%x\n",
678 set_complete->status); 688 set_complete->status);
679 ret = -EINVAL; 689 ret = -EINVAL;
680 } 690 }
diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index f3cdf64997d6..63aa9d9e34c5 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -78,11 +78,19 @@ static void ntb_netdev_event_handler(void *data, int status)
78 netdev_dbg(ndev, "Event %x, Link %x\n", status, 78 netdev_dbg(ndev, "Event %x, Link %x\n", status,
79 ntb_transport_link_query(dev->qp)); 79 ntb_transport_link_query(dev->qp));
80 80
81 /* Currently, only link status event is supported */ 81 switch (status) {
82 if (status) 82 case NTB_LINK_DOWN:
83 netif_carrier_on(ndev);
84 else
85 netif_carrier_off(ndev); 83 netif_carrier_off(ndev);
84 break;
85 case NTB_LINK_UP:
86 if (!ntb_transport_link_query(dev->qp))
87 return;
88
89 netif_carrier_on(ndev);
90 break;
91 default:
92 netdev_warn(ndev, "Unsupported event type %d\n", status);
93 }
86} 94}
87 95
88static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, 96static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
@@ -182,8 +190,10 @@ static int ntb_netdev_open(struct net_device *ndev)
182 190
183 rc = ntb_transport_rx_enqueue(dev->qp, skb, skb->data, 191 rc = ntb_transport_rx_enqueue(dev->qp, skb, skb->data,
184 ndev->mtu + ETH_HLEN); 192 ndev->mtu + ETH_HLEN);
185 if (rc == -EINVAL) 193 if (rc == -EINVAL) {
194 dev_kfree_skb(skb);
186 goto err; 195 goto err;
196 }
187 } 197 }
188 198
189 netif_carrier_off(ndev); 199 netif_carrier_off(ndev);
@@ -367,12 +377,15 @@ static void ntb_netdev_remove(struct pci_dev *pdev)
367{ 377{
368 struct net_device *ndev; 378 struct net_device *ndev;
369 struct ntb_netdev *dev; 379 struct ntb_netdev *dev;
380 bool found = false;
370 381
371 list_for_each_entry(dev, &dev_list, list) { 382 list_for_each_entry(dev, &dev_list, list) {
372 if (dev->pdev == pdev) 383 if (dev->pdev == pdev) {
384 found = true;
373 break; 385 break;
386 }
374 } 387 }
375 if (dev == NULL) 388 if (!found)
376 return; 389 return;
377 390
378 list_del(&dev->list); 391 list_del(&dev->list);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1d788f19135b..1b6d09aef427 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -756,12 +756,8 @@ void phy_state_machine(struct work_struct *work)
756 netif_carrier_on(phydev->attached_dev); 756 netif_carrier_on(phydev->attached_dev);
757 phydev->adjust_link(phydev->attached_dev); 757 phydev->adjust_link(phydev->attached_dev);
758 758
759 } else if (0 == phydev->link_timeout--) { 759 } else if (0 == phydev->link_timeout--)
760 needs_aneg = 1; 760 needs_aneg = 1;
761 /* If we have the magic_aneg bit, we try again */
762 if (phydev->drv->flags & PHY_HAS_MAGICANEG)
763 break;
764 }
765 break; 761 break;
766 case PHY_NOLINK: 762 case PHY_NOLINK:
767 err = phy_read_status(phydev); 763 err = phy_read_status(phydev);
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 18e12a3f7fc3..3fbfb0869030 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -929,6 +929,9 @@ static int read_mii_word(struct net_device *netdev, int phy_id, int reg)
929 struct r8152 *tp = netdev_priv(netdev); 929 struct r8152 *tp = netdev_priv(netdev);
930 int ret; 930 int ret;
931 931
932 if (test_bit(RTL8152_UNPLUG, &tp->flags))
933 return -ENODEV;
934
932 if (phy_id != R8152_PHY_ID) 935 if (phy_id != R8152_PHY_ID)
933 return -EINVAL; 936 return -EINVAL;
934 937
@@ -949,6 +952,9 @@ void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val)
949{ 952{
950 struct r8152 *tp = netdev_priv(netdev); 953 struct r8152 *tp = netdev_priv(netdev);
951 954
955 if (test_bit(RTL8152_UNPLUG, &tp->flags))
956 return;
957
952 if (phy_id != R8152_PHY_ID) 958 if (phy_id != R8152_PHY_ID)
953 return; 959 return;
954 960
@@ -1962,6 +1968,9 @@ static int rtl_enable(struct r8152 *tp)
1962 1968
1963static int rtl8152_enable(struct r8152 *tp) 1969static int rtl8152_enable(struct r8152 *tp)
1964{ 1970{
1971 if (test_bit(RTL8152_UNPLUG, &tp->flags))
1972 return -ENODEV;
1973
1965 set_tx_qlen(tp); 1974 set_tx_qlen(tp);
1966 rtl_set_eee_plus(tp); 1975 rtl_set_eee_plus(tp);
1967 1976
@@ -1994,6 +2003,9 @@ static void r8153_set_rx_agg(struct r8152 *tp)
1994 2003
1995static int rtl8153_enable(struct r8152 *tp) 2004static int rtl8153_enable(struct r8152 *tp)
1996{ 2005{
2006 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2007 return -ENODEV;
2008
1997 set_tx_qlen(tp); 2009 set_tx_qlen(tp);
1998 rtl_set_eee_plus(tp); 2010 rtl_set_eee_plus(tp);
1999 r8153_set_rx_agg(tp); 2011 r8153_set_rx_agg(tp);
@@ -2006,6 +2018,11 @@ static void rtl8152_disable(struct r8152 *tp)
2006 u32 ocp_data; 2018 u32 ocp_data;
2007 int i; 2019 int i;
2008 2020
2021 if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
2022 rtl_drop_queued_tx(tp);
2023 return;
2024 }
2025
2009 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2026 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
2010 ocp_data &= ~RCR_ACPT_ALL; 2027 ocp_data &= ~RCR_ACPT_ALL;
2011 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); 2028 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
@@ -2232,6 +2249,9 @@ static void r8152b_exit_oob(struct r8152 *tp)
2232 u32 ocp_data; 2249 u32 ocp_data;
2233 int i; 2250 int i;
2234 2251
2252 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2253 return;
2254
2235 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2255 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
2236 ocp_data &= ~RCR_ACPT_ALL; 2256 ocp_data &= ~RCR_ACPT_ALL;
2237 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); 2257 ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
@@ -2460,6 +2480,9 @@ static void r8153_first_init(struct r8152 *tp)
2460 u32 ocp_data; 2480 u32 ocp_data;
2461 int i; 2481 int i;
2462 2482
2483 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2484 return;
2485
2463 rxdy_gated_en(tp, true); 2486 rxdy_gated_en(tp, true);
2464 r8153_teredo_off(tp); 2487 r8153_teredo_off(tp);
2465 2488
@@ -2687,6 +2710,11 @@ out:
2687 2710
2688static void rtl8152_down(struct r8152 *tp) 2711static void rtl8152_down(struct r8152 *tp)
2689{ 2712{
2713 if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
2714 rtl_drop_queued_tx(tp);
2715 return;
2716 }
2717
2690 r8152_power_cut_en(tp, false); 2718 r8152_power_cut_en(tp, false);
2691 r8152b_disable_aldps(tp); 2719 r8152b_disable_aldps(tp);
2692 r8152b_enter_oob(tp); 2720 r8152b_enter_oob(tp);
@@ -2695,6 +2723,11 @@ static void rtl8152_down(struct r8152 *tp)
2695 2723
2696static void rtl8153_down(struct r8152 *tp) 2724static void rtl8153_down(struct r8152 *tp)
2697{ 2725{
2726 if (test_bit(RTL8152_UNPLUG, &tp->flags)) {
2727 rtl_drop_queued_tx(tp);
2728 return;
2729 }
2730
2698 r8153_u1u2en(tp, false); 2731 r8153_u1u2en(tp, false);
2699 r8153_power_cut_en(tp, false); 2732 r8153_power_cut_en(tp, false);
2700 r8153_disable_aldps(tp); 2733 r8153_disable_aldps(tp);
@@ -2904,6 +2937,9 @@ static void r8152b_init(struct r8152 *tp)
2904{ 2937{
2905 u32 ocp_data; 2938 u32 ocp_data;
2906 2939
2940 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2941 return;
2942
2907 if (tp->version == RTL_VER_01) { 2943 if (tp->version == RTL_VER_01) {
2908 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); 2944 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE);
2909 ocp_data &= ~LED_MODE_MASK; 2945 ocp_data &= ~LED_MODE_MASK;
@@ -2939,6 +2975,9 @@ static void r8153_init(struct r8152 *tp)
2939 u32 ocp_data; 2975 u32 ocp_data;
2940 int i; 2976 int i;
2941 2977
2978 if (test_bit(RTL8152_UNPLUG, &tp->flags))
2979 return;
2980
2942 r8153_u1u2en(tp, false); 2981 r8153_u1u2en(tp, false);
2943 2982
2944 for (i = 0; i < 500; i++) { 2983 for (i = 0; i < 500; i++) {
@@ -3213,6 +3252,9 @@ static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
3213 struct mii_ioctl_data *data = if_mii(rq); 3252 struct mii_ioctl_data *data = if_mii(rq);
3214 int res; 3253 int res;
3215 3254
3255 if (test_bit(RTL8152_UNPLUG, &tp->flags))
3256 return -ENODEV;
3257
3216 res = usb_autopm_get_interface(tp->intf); 3258 res = usb_autopm_get_interface(tp->intf);
3217 if (res < 0) 3259 if (res < 0)
3218 goto out; 3260 goto out;
@@ -3293,12 +3335,18 @@ static void r8152b_get_version(struct r8152 *tp)
3293 3335
3294static void rtl8152_unload(struct r8152 *tp) 3336static void rtl8152_unload(struct r8152 *tp)
3295{ 3337{
3338 if (test_bit(RTL8152_UNPLUG, &tp->flags))
3339 return;
3340
3296 if (tp->version != RTL_VER_01) 3341 if (tp->version != RTL_VER_01)
3297 r8152_power_cut_en(tp, true); 3342 r8152_power_cut_en(tp, true);
3298} 3343}
3299 3344
3300static void rtl8153_unload(struct r8152 *tp) 3345static void rtl8153_unload(struct r8152 *tp)
3301{ 3346{
3347 if (test_bit(RTL8152_UNPLUG, &tp->flags))
3348 return;
3349
3302 r8153_power_cut_en(tp, true); 3350 r8153_power_cut_en(tp, true);
3303} 3351}
3304 3352
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 3b3e91057a4c..00fb8badbacc 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -1004,11 +1004,9 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
1004 case ATH9K_ANI_FIRSTEP_LEVEL:{ 1004 case ATH9K_ANI_FIRSTEP_LEVEL:{
1005 u32 level = param; 1005 u32 level = param;
1006 1006
1007 value = level * 2; 1007 value = level;
1008 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG, 1008 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
1009 AR_PHY_FIND_SIG_FIRSTEP, value); 1009 AR_PHY_FIND_SIG_FIRSTEP, value);
1010 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
1011 AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
1012 1010
1013 if (level != aniState->firstepLevel) { 1011 if (level != aniState->firstepLevel) {
1014 ath_dbg(common, ANI, 1012 ath_dbg(common, ANI,
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 471e0f624e81..bd9e634879e6 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -312,10 +312,9 @@ static void ath9k_csa_update_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
312 312
313void ath9k_csa_update(struct ath_softc *sc) 313void ath9k_csa_update(struct ath_softc *sc)
314{ 314{
315 ieee80211_iterate_active_interfaces(sc->hw, 315 ieee80211_iterate_active_interfaces_atomic(sc->hw,
316 IEEE80211_IFACE_ITER_NORMAL, 316 IEEE80211_IFACE_ITER_NORMAL,
317 ath9k_csa_update_vif, 317 ath9k_csa_update_vif, sc);
318 sc);
319} 318}
320 319
321void ath9k_beacon_tasklet(unsigned long data) 320void ath9k_beacon_tasklet(unsigned long data)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index e8149e3dbdd5..289f3d8924b5 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -471,8 +471,11 @@ static void ath9k_htc_tx_process(struct ath9k_htc_priv *priv,
471 if (!txok || !vif || !txs) 471 if (!txok || !vif || !txs)
472 goto send_mac80211; 472 goto send_mac80211;
473 473
474 if (txs->ts_flags & ATH9K_HTC_TXSTAT_ACK) 474 if (txs->ts_flags & ATH9K_HTC_TXSTAT_ACK) {
475 tx_info->flags |= IEEE80211_TX_STAT_ACK; 475 tx_info->flags |= IEEE80211_TX_STAT_ACK;
476 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
477 tx_info->flags |= IEEE80211_TX_STAT_AMPDU;
478 }
476 479
477 if (txs->ts_flags & ATH9K_HTC_TXSTAT_FILT) 480 if (txs->ts_flags & ATH9K_HTC_TXSTAT_FILT)
478 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 481 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index c0a4e866edca..cbbb02a6b13b 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -670,6 +670,7 @@ static const struct ieee80211_iface_combination if_comb[] = {
670 .num_different_channels = 1, 670 .num_different_channels = 1,
671 .beacon_int_infra_match = true, 671 .beacon_int_infra_match = true,
672 }, 672 },
673#ifdef CONFIG_ATH9K_DFS_CERTIFIED
673 { 674 {
674 .limits = if_dfs_limits, 675 .limits = if_dfs_limits,
675 .n_limits = ARRAY_SIZE(if_dfs_limits), 676 .n_limits = ARRAY_SIZE(if_dfs_limits),
@@ -679,6 +680,7 @@ static const struct ieee80211_iface_combination if_comb[] = {
679 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | 680 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
680 BIT(NL80211_CHAN_WIDTH_20), 681 BIT(NL80211_CHAN_WIDTH_20),
681 } 682 }
683#endif
682}; 684};
683 685
684static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) 686static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 05ee7f10cc8f..24ccbe96e0c8 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -5176,22 +5176,22 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev,
5176 int ch = new_channel->hw_value; 5176 int ch = new_channel->hw_value;
5177 5177
5178 u16 old_band_5ghz; 5178 u16 old_band_5ghz;
5179 u32 tmp32; 5179 u16 tmp16;
5180 5180
5181 old_band_5ghz = 5181 old_band_5ghz =
5182 b43_phy_read(dev, B43_NPHY_BANDCTL) & B43_NPHY_BANDCTL_5GHZ; 5182 b43_phy_read(dev, B43_NPHY_BANDCTL) & B43_NPHY_BANDCTL_5GHZ;
5183 if (new_channel->band == IEEE80211_BAND_5GHZ && !old_band_5ghz) { 5183 if (new_channel->band == IEEE80211_BAND_5GHZ && !old_band_5ghz) {
5184 tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR); 5184 tmp16 = b43_read16(dev, B43_MMIO_PSM_PHY_HDR);
5185 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4); 5185 b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
5186 b43_phy_set(dev, B43_PHY_B_BBCFG, 0xC000); 5186 b43_phy_set(dev, B43_PHY_B_BBCFG, 0xC000);
5187 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32); 5187 b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
5188 b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ); 5188 b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ);
5189 } else if (new_channel->band == IEEE80211_BAND_2GHZ && old_band_5ghz) { 5189 } else if (new_channel->band == IEEE80211_BAND_2GHZ && old_band_5ghz) {
5190 b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ); 5190 b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ);
5191 tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR); 5191 tmp16 = b43_read16(dev, B43_MMIO_PSM_PHY_HDR);
5192 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4); 5192 b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
5193 b43_phy_mask(dev, B43_PHY_B_BBCFG, 0x3FFF); 5193 b43_phy_mask(dev, B43_PHY_B_BBCFG, 0x3FFF);
5194 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32); 5194 b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
5195 } 5195 }
5196 5196
5197 b43_chantab_phy_upload(dev, e); 5197 b43_chantab_phy_upload(dev, e);
diff --git a/drivers/net/wireless/rsi/rsi_91x_core.c b/drivers/net/wireless/rsi/rsi_91x_core.c
index e89535e86caf..1a8d32138593 100644
--- a/drivers/net/wireless/rsi/rsi_91x_core.c
+++ b/drivers/net/wireless/rsi/rsi_91x_core.c
@@ -102,10 +102,10 @@ static u8 rsi_core_determine_hal_queue(struct rsi_common *common)
102 } 102 }
103 103
104get_queue_num: 104get_queue_num:
105 q_num = 0;
106 recontend_queue = false; 105 recontend_queue = false;
107 106
108 q_num = rsi_determine_min_weight_queue(common); 107 q_num = rsi_determine_min_weight_queue(common);
108
109 q_len = skb_queue_len(&common->tx_queue[ii]); 109 q_len = skb_queue_len(&common->tx_queue[ii]);
110 ii = q_num; 110 ii = q_num;
111 111
@@ -118,7 +118,9 @@ get_queue_num:
118 } 118 }
119 } 119 }
120 120
121 common->tx_qinfo[q_num].pkt_contended = 0; 121 if (q_num < NUM_EDCA_QUEUES)
122 common->tx_qinfo[q_num].pkt_contended = 0;
123
122 /* Adjust the back off values for all queues again */ 124 /* Adjust the back off values for all queues again */
123 recontend_queue = rsi_recalculate_weights(common); 125 recontend_queue = rsi_recalculate_weights(common);
124 126
diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
index 7e4ef4554411..c466246a323f 100644
--- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c
+++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
@@ -289,32 +289,29 @@ int rsi_init_dbgfs(struct rsi_hw *adapter)
289 const struct rsi_dbg_files *files; 289 const struct rsi_dbg_files *files;
290 290
291 dev_dbgfs = kzalloc(sizeof(*dev_dbgfs), GFP_KERNEL); 291 dev_dbgfs = kzalloc(sizeof(*dev_dbgfs), GFP_KERNEL);
292 if (!dev_dbgfs)
293 return -ENOMEM;
294
292 adapter->dfsentry = dev_dbgfs; 295 adapter->dfsentry = dev_dbgfs;
293 296
294 snprintf(devdir, sizeof(devdir), "%s", 297 snprintf(devdir, sizeof(devdir), "%s",
295 wiphy_name(adapter->hw->wiphy)); 298 wiphy_name(adapter->hw->wiphy));
296 dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL);
297 299
298 if (IS_ERR(dev_dbgfs->subdir)) { 300 dev_dbgfs->subdir = debugfs_create_dir(devdir, NULL);
299 if (dev_dbgfs->subdir == ERR_PTR(-ENODEV))
300 rsi_dbg(ERR_ZONE,
301 "%s:Debugfs has not been mounted\n", __func__);
302 else
303 rsi_dbg(ERR_ZONE, "debugfs:%s not created\n", devdir);
304 301
305 adapter->dfsentry = NULL; 302 if (!dev_dbgfs->subdir) {
306 kfree(dev_dbgfs); 303 kfree(dev_dbgfs);
307 return (int)PTR_ERR(dev_dbgfs->subdir); 304 return -ENOMEM;
308 } else { 305 }
309 for (ii = 0; ii < adapter->num_debugfs_entries; ii++) { 306
310 files = &dev_debugfs_files[ii]; 307 for (ii = 0; ii < adapter->num_debugfs_entries; ii++) {
311 dev_dbgfs->rsi_files[ii] = 308 files = &dev_debugfs_files[ii];
312 debugfs_create_file(files->name, 309 dev_dbgfs->rsi_files[ii] =
313 files->perms, 310 debugfs_create_file(files->name,
314 dev_dbgfs->subdir, 311 files->perms,
315 common, 312 dev_dbgfs->subdir,
316 &files->fops); 313 common,
317 } 314 &files->fops);
318 } 315 }
319 return 0; 316 return 0;
320} 317}
diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 2361a6849ad7..73694295648f 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -738,7 +738,7 @@ int rsi_hal_load_key(struct rsi_common *common,
738 * 738 *
739 * Return: 0 on success, corresponding error code on failure. 739 * Return: 0 on success, corresponding error code on failure.
740 */ 740 */
741static u8 rsi_load_bootup_params(struct rsi_common *common) 741static int rsi_load_bootup_params(struct rsi_common *common)
742{ 742{
743 struct sk_buff *skb; 743 struct sk_buff *skb;
744 struct rsi_boot_params *boot_params; 744 struct rsi_boot_params *boot_params;
@@ -1272,6 +1272,7 @@ int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg)
1272{ 1272{
1273 s32 msg_len = (le16_to_cpu(*(__le16 *)&msg[0]) & 0x0fff); 1273 s32 msg_len = (le16_to_cpu(*(__le16 *)&msg[0]) & 0x0fff);
1274 u16 msg_type = (msg[2]); 1274 u16 msg_type = (msg[2]);
1275 int ret;
1275 1276
1276 rsi_dbg(FSM_ZONE, "%s: Msg Len: %d, Msg Type: %4x\n", 1277 rsi_dbg(FSM_ZONE, "%s: Msg Len: %d, Msg Type: %4x\n",
1277 __func__, msg_len, msg_type); 1278 __func__, msg_len, msg_type);
@@ -1284,8 +1285,9 @@ int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg)
1284 if (common->fsm_state == FSM_CARD_NOT_READY) { 1285 if (common->fsm_state == FSM_CARD_NOT_READY) {
1285 rsi_set_default_parameters(common); 1286 rsi_set_default_parameters(common);
1286 1287
1287 if (rsi_load_bootup_params(common)) 1288 ret = rsi_load_bootup_params(common);
1288 return -ENOMEM; 1289 if (ret)
1290 return ret;
1289 else 1291 else
1290 common->fsm_state = FSM_BOOT_PARAMS_SENT; 1292 common->fsm_state = FSM_BOOT_PARAMS_SENT;
1291 } else { 1293 } else {
diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c
index 852453f386e2..2e39d38d6a9e 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c
@@ -756,12 +756,13 @@ fail:
756static void rsi_disconnect(struct sdio_func *pfunction) 756static void rsi_disconnect(struct sdio_func *pfunction)
757{ 757{
758 struct rsi_hw *adapter = sdio_get_drvdata(pfunction); 758 struct rsi_hw *adapter = sdio_get_drvdata(pfunction);
759 struct rsi_91x_sdiodev *dev = 759 struct rsi_91x_sdiodev *dev;
760 (struct rsi_91x_sdiodev *)adapter->rsi_dev;
761 760
762 if (!adapter) 761 if (!adapter)
763 return; 762 return;
764 763
764 dev = (struct rsi_91x_sdiodev *)adapter->rsi_dev;
765
765 dev->write_fail = 2; 766 dev->write_fail = 2;
766 rsi_mac80211_detach(adapter); 767 rsi_mac80211_detach(adapter);
767 768
diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
index f1cb99cafed8..20d11ccfffe3 100644
--- a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
+++ b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c
@@ -247,7 +247,7 @@ static int rsi_process_pkt(struct rsi_common *common)
247 if (!common->rx_data_pkt) { 247 if (!common->rx_data_pkt) {
248 rsi_dbg(ERR_ZONE, "%s: Failed in memory allocation\n", 248 rsi_dbg(ERR_ZONE, "%s: Failed in memory allocation\n",
249 __func__); 249 __func__);
250 return -1; 250 return -ENOMEM;
251 } 251 }
252 252
253 status = rsi_sdio_host_intf_read_pkt(adapter, 253 status = rsi_sdio_host_intf_read_pkt(adapter,
@@ -260,12 +260,10 @@ static int rsi_process_pkt(struct rsi_common *common)
260 } 260 }
261 261
262 status = rsi_read_pkt(common, rcv_pkt_len); 262 status = rsi_read_pkt(common, rcv_pkt_len);
263 kfree(common->rx_data_pkt);
264 return status;
265 263
266fail: 264fail:
267 kfree(common->rx_data_pkt); 265 kfree(common->rx_data_pkt);
268 return -1; 266 return status;
269} 267}
270 268
271/** 269/**
diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index bb1bf96670eb..4c46e5631e2f 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -154,24 +154,30 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
154 u16 *value, 154 u16 *value,
155 u16 len) 155 u16 len)
156{ 156{
157 u8 temp_buf[4]; 157 u8 *buf;
158 int status = 0; 158 int status = -ENOMEM;
159
160 buf = kmalloc(0x04, GFP_KERNEL);
161 if (!buf)
162 return status;
159 163
160 status = usb_control_msg(usbdev, 164 status = usb_control_msg(usbdev,
161 usb_rcvctrlpipe(usbdev, 0), 165 usb_rcvctrlpipe(usbdev, 0),
162 USB_VENDOR_REGISTER_READ, 166 USB_VENDOR_REGISTER_READ,
163 USB_TYPE_VENDOR, 167 USB_TYPE_VENDOR,
164 ((reg & 0xffff0000) >> 16), (reg & 0xffff), 168 ((reg & 0xffff0000) >> 16), (reg & 0xffff),
165 (void *)temp_buf, 169 (void *)buf,
166 len, 170 len,
167 HZ * 5); 171 HZ * 5);
168 172
169 *value = (temp_buf[0] | (temp_buf[1] << 8)); 173 *value = (buf[0] | (buf[1] << 8));
170 if (status < 0) { 174 if (status < 0) {
171 rsi_dbg(ERR_ZONE, 175 rsi_dbg(ERR_ZONE,
172 "%s: Reg read failed with error code :%d\n", 176 "%s: Reg read failed with error code :%d\n",
173 __func__, status); 177 __func__, status);
174 } 178 }
179 kfree(buf);
180
175 return status; 181 return status;
176} 182}
177 183
@@ -190,8 +196,12 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
190 u16 value, 196 u16 value,
191 u16 len) 197 u16 len)
192{ 198{
193 u8 usb_reg_buf[4]; 199 u8 *usb_reg_buf;
194 int status = 0; 200 int status = -ENOMEM;
201
202 usb_reg_buf = kmalloc(0x04, GFP_KERNEL);
203 if (!usb_reg_buf)
204 return status;
195 205
196 usb_reg_buf[0] = (value & 0x00ff); 206 usb_reg_buf[0] = (value & 0x00ff);
197 usb_reg_buf[1] = (value & 0xff00) >> 8; 207 usb_reg_buf[1] = (value & 0xff00) >> 8;
@@ -212,6 +222,8 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
212 "%s: Reg write failed with error code :%d\n", 222 "%s: Reg write failed with error code :%d\n",
213 __func__, status); 223 __func__, status);
214 } 224 }
225 kfree(usb_reg_buf);
226
215 return status; 227 return status;
216} 228}
217 229
@@ -286,7 +298,7 @@ int rsi_usb_write_register_multiple(struct rsi_hw *adapter,
286 return -ENOMEM; 298 return -ENOMEM;
287 299
288 while (count) { 300 while (count) {
289 transfer = min_t(int, count, 4096); 301 transfer = (u8)(min_t(u32, count, 4096));
290 memcpy(buf, data, transfer); 302 memcpy(buf, data, transfer);
291 status = usb_control_msg(dev->usbdev, 303 status = usb_control_msg(dev->usbdev,
292 usb_sndctrlpipe(dev->usbdev, 0), 304 usb_sndctrlpipe(dev->usbdev, 0),
diff --git a/drivers/net/wireless/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/net/wireless/rtlwifi/btcoexist/halbtcoutsrc.c
index b6722de64a31..33da3dfcfa4f 100644
--- a/drivers/net/wireless/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -625,17 +625,7 @@ bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
625 else 625 else
626 btcoexist->binded = true; 626 btcoexist->binded = true;
627 627
628#if (defined(CONFIG_PCI_HCI))
629 btcoexist->chip_interface = BTC_INTF_PCI;
630#elif (defined(CONFIG_USB_HCI))
631 btcoexist->chip_interface = BTC_INTF_USB;
632#elif (defined(CONFIG_SDIO_HCI))
633 btcoexist->chip_interface = BTC_INTF_SDIO;
634#elif (defined(CONFIG_GSPI_HCI))
635 btcoexist->chip_interface = BTC_INTF_GSPI;
636#else
637 btcoexist->chip_interface = BTC_INTF_UNKNOWN; 628 btcoexist->chip_interface = BTC_INTF_UNKNOWN;
638#endif
639 629
640 if (NULL == btcoexist->adapter) 630 if (NULL == btcoexist->adapter)
641 btcoexist->adapter = adapter; 631 btcoexist->adapter = adapter;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 057b05700f8b..158b5e639fc7 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1291,13 +1291,13 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
1291 for (i = 0; i < NET_TX_RING_SIZE; i++) { 1291 for (i = 0; i < NET_TX_RING_SIZE; i++) {
1292 skb_entry_set_link(&np->tx_skbs[i], i+1); 1292 skb_entry_set_link(&np->tx_skbs[i], i+1);
1293 np->grant_tx_ref[i] = GRANT_INVALID_REF; 1293 np->grant_tx_ref[i] = GRANT_INVALID_REF;
1294 np->grant_tx_page[i] = NULL;
1294 } 1295 }
1295 1296
1296 /* Clear out rx_skbs */ 1297 /* Clear out rx_skbs */
1297 for (i = 0; i < NET_RX_RING_SIZE; i++) { 1298 for (i = 0; i < NET_RX_RING_SIZE; i++) {
1298 np->rx_skbs[i] = NULL; 1299 np->rx_skbs[i] = NULL;
1299 np->grant_rx_ref[i] = GRANT_INVALID_REF; 1300 np->grant_rx_ref[i] = GRANT_INVALID_REF;
1300 np->grant_tx_page[i] = NULL;
1301 } 1301 }
1302 1302
1303 /* A grant for every tx ring slot */ 1303 /* A grant for every tx ring slot */
diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
index 170e8e60cdb7..372e08c4ffef 100644
--- a/drivers/ntb/ntb_hw.c
+++ b/drivers/ntb/ntb_hw.c
@@ -91,7 +91,7 @@ static struct dentry *debugfs_dir;
91/* Translate memory window 0,1 to BAR 2,4 */ 91/* Translate memory window 0,1 to BAR 2,4 */
92#define MW_TO_BAR(mw) (mw * NTB_MAX_NUM_MW + 2) 92#define MW_TO_BAR(mw) (mw * NTB_MAX_NUM_MW + 2)
93 93
94static DEFINE_PCI_DEVICE_TABLE(ntb_pci_tbl) = { 94static const struct pci_device_id ntb_pci_tbl[] = {
95 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_BWD)}, 95 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_BWD)},
96 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_JSF)}, 96 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_JSF)},
97 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_SNB)}, 97 {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_SNB)},
@@ -120,7 +120,8 @@ MODULE_DEVICE_TABLE(pci, ntb_pci_tbl);
120 * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 120 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
121 */ 121 */
122int ntb_register_event_callback(struct ntb_device *ndev, 122int ntb_register_event_callback(struct ntb_device *ndev,
123 void (*func)(void *handle, enum ntb_hw_event event)) 123 void (*func)(void *handle,
124 enum ntb_hw_event event))
124{ 125{
125 if (ndev->event_cb) 126 if (ndev->event_cb)
126 return -EINVAL; 127 return -EINVAL;
@@ -715,9 +716,9 @@ static int ntb_xeon_setup(struct ntb_device *ndev)
715 SNB_PBAR4LMT_OFFSET); 716 SNB_PBAR4LMT_OFFSET);
716 /* HW errata on the Limit registers. They can only be 717 /* HW errata on the Limit registers. They can only be
717 * written when the base register is 4GB aligned and 718 * written when the base register is 4GB aligned and
718 * < 32bit. This should already be the case based on the 719 * < 32bit. This should already be the case based on
719 * driver defaults, but write the Limit registers first 720 * the driver defaults, but write the Limit registers
720 * just in case. 721 * first just in case.
721 */ 722 */
722 } else { 723 } else {
723 ndev->limits.max_mw = SNB_MAX_MW; 724 ndev->limits.max_mw = SNB_MAX_MW;
@@ -739,9 +740,9 @@ static int ntb_xeon_setup(struct ntb_device *ndev)
739 writeq(0, ndev->reg_base + SNB_PBAR4LMT_OFFSET); 740 writeq(0, ndev->reg_base + SNB_PBAR4LMT_OFFSET);
740 /* HW errata on the Limit registers. They can only be 741 /* HW errata on the Limit registers. They can only be
741 * written when the base register is 4GB aligned and 742 * written when the base register is 4GB aligned and
742 * < 32bit. This should already be the case based on the 743 * < 32bit. This should already be the case based on
743 * driver defaults, but write the Limit registers first 744 * the driver defaults, but write the Limit registers
744 * just in case. 745 * first just in case.
745 */ 746 */
746 } 747 }
747 748
@@ -785,7 +786,7 @@ static int ntb_xeon_setup(struct ntb_device *ndev)
785 /* B2B_XLAT_OFFSET is a 64bit register, but can 786 /* B2B_XLAT_OFFSET is a 64bit register, but can
786 * only take 32bit writes 787 * only take 32bit writes
787 */ 788 */
788 writel(SNB_MBAR01_DSD_ADDR & 0xffffffff, 789 writel(SNB_MBAR01_USD_ADDR & 0xffffffff,
789 ndev->reg_base + SNB_B2B_XLAT_OFFSETL); 790 ndev->reg_base + SNB_B2B_XLAT_OFFSETL);
790 writel(SNB_MBAR01_USD_ADDR >> 32, 791 writel(SNB_MBAR01_USD_ADDR >> 32,
791 ndev->reg_base + SNB_B2B_XLAT_OFFSETU); 792 ndev->reg_base + SNB_B2B_XLAT_OFFSETU);
@@ -803,7 +804,7 @@ static int ntb_xeon_setup(struct ntb_device *ndev)
803 ndev->conn_type = NTB_CONN_RP; 804 ndev->conn_type = NTB_CONN_RP;
804 805
805 if (xeon_errata_workaround) { 806 if (xeon_errata_workaround) {
806 dev_err(&ndev->pdev->dev, 807 dev_err(&ndev->pdev->dev,
807 "NTB-RP disabled due to hardware errata. To disregard this warning and potentially lock-up the system, add the parameter 'xeon_errata_workaround=0'.\n"); 808 "NTB-RP disabled due to hardware errata. To disregard this warning and potentially lock-up the system, add the parameter 'xeon_errata_workaround=0'.\n");
808 return -EINVAL; 809 return -EINVAL;
809 } 810 }
@@ -1079,111 +1080,131 @@ static irqreturn_t ntb_interrupt(int irq, void *dev)
1079 return IRQ_HANDLED; 1080 return IRQ_HANDLED;
1080} 1081}
1081 1082
1082static int ntb_setup_msix(struct ntb_device *ndev) 1083static int ntb_setup_snb_msix(struct ntb_device *ndev, int msix_entries)
1083{ 1084{
1084 struct pci_dev *pdev = ndev->pdev; 1085 struct pci_dev *pdev = ndev->pdev;
1085 struct msix_entry *msix; 1086 struct msix_entry *msix;
1086 int msix_entries;
1087 int rc, i; 1087 int rc, i;
1088 u16 val;
1089 1088
1090 if (!pdev->msix_cap) { 1089 if (msix_entries < ndev->limits.msix_cnt)
1091 rc = -EIO; 1090 return -ENOSPC;
1092 goto err;
1093 }
1094 1091
1095 rc = pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &val); 1092 rc = pci_enable_msix_exact(pdev, ndev->msix_entries, msix_entries);
1096 if (rc) 1093 if (rc < 0)
1097 goto err; 1094 return rc;
1098 1095
1099 msix_entries = msix_table_size(val); 1096 for (i = 0; i < msix_entries; i++) {
1100 if (msix_entries > ndev->limits.msix_cnt) { 1097 msix = &ndev->msix_entries[i];
1101 rc = -EINVAL; 1098 WARN_ON(!msix->vector);
1102 goto err; 1099
1100 if (i == msix_entries - 1) {
1101 rc = request_irq(msix->vector,
1102 xeon_event_msix_irq, 0,
1103 "ntb-event-msix", ndev);
1104 if (rc)
1105 goto err;
1106 } else {
1107 rc = request_irq(msix->vector,
1108 xeon_callback_msix_irq, 0,
1109 "ntb-callback-msix",
1110 &ndev->db_cb[i]);
1111 if (rc)
1112 goto err;
1113 }
1103 } 1114 }
1104 1115
1105 ndev->msix_entries = kmalloc(sizeof(struct msix_entry) * msix_entries, 1116 ndev->num_msix = msix_entries;
1106 GFP_KERNEL); 1117 ndev->max_cbs = msix_entries - 1;
1107 if (!ndev->msix_entries) { 1118
1108 rc = -ENOMEM; 1119 return 0;
1109 goto err; 1120
1121err:
1122 while (--i >= 0) {
1123 /* Code never reaches here for entry nr 'ndev->num_msix - 1' */
1124 msix = &ndev->msix_entries[i];
1125 free_irq(msix->vector, &ndev->db_cb[i]);
1110 } 1126 }
1111 1127
1112 for (i = 0; i < msix_entries; i++) 1128 pci_disable_msix(pdev);
1113 ndev->msix_entries[i].entry = i; 1129 ndev->num_msix = 0;
1114 1130
1115 rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries); 1131 return rc;
1116 if (rc < 0) 1132}
1117 goto err1;
1118 if (rc > 0) {
1119 /* On SNB, the link interrupt is always tied to 4th vector. If
1120 * we can't get all 4, then we can't use MSI-X.
1121 */
1122 if (ndev->hw_type != BWD_HW) {
1123 rc = -EIO;
1124 goto err1;
1125 }
1126 1133
1127 dev_warn(&pdev->dev, 1134static int ntb_setup_bwd_msix(struct ntb_device *ndev, int msix_entries)
1128 "Only %d MSI-X vectors. Limiting the number of queues to that number.\n", 1135{
1129 rc); 1136 struct pci_dev *pdev = ndev->pdev;
1130 msix_entries = rc; 1137 struct msix_entry *msix;
1138 int rc, i;
1131 1139
1132 rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries); 1140 msix_entries = pci_enable_msix_range(pdev, ndev->msix_entries,
1133 if (rc) 1141 1, msix_entries);
1134 goto err1; 1142 if (msix_entries < 0)
1135 } 1143 return msix_entries;
1136 1144
1137 for (i = 0; i < msix_entries; i++) { 1145 for (i = 0; i < msix_entries; i++) {
1138 msix = &ndev->msix_entries[i]; 1146 msix = &ndev->msix_entries[i];
1139 WARN_ON(!msix->vector); 1147 WARN_ON(!msix->vector);
1140 1148
1141 /* Use the last MSI-X vector for Link status */ 1149 rc = request_irq(msix->vector, bwd_callback_msix_irq, 0,
1142 if (ndev->hw_type == BWD_HW) { 1150 "ntb-callback-msix", &ndev->db_cb[i]);
1143 rc = request_irq(msix->vector, bwd_callback_msix_irq, 0, 1151 if (rc)
1144 "ntb-callback-msix", &ndev->db_cb[i]); 1152 goto err;
1145 if (rc)
1146 goto err2;
1147 } else {
1148 if (i == msix_entries - 1) {
1149 rc = request_irq(msix->vector,
1150 xeon_event_msix_irq, 0,
1151 "ntb-event-msix", ndev);
1152 if (rc)
1153 goto err2;
1154 } else {
1155 rc = request_irq(msix->vector,
1156 xeon_callback_msix_irq, 0,
1157 "ntb-callback-msix",
1158 &ndev->db_cb[i]);
1159 if (rc)
1160 goto err2;
1161 }
1162 }
1163 } 1153 }
1164 1154
1165 ndev->num_msix = msix_entries; 1155 ndev->num_msix = msix_entries;
1156 ndev->max_cbs = msix_entries;
1157
1158 return 0;
1159
1160err:
1161 while (--i >= 0)
1162 free_irq(msix->vector, &ndev->db_cb[i]);
1163
1164 pci_disable_msix(pdev);
1165 ndev->num_msix = 0;
1166
1167 return rc;
1168}
1169
1170static int ntb_setup_msix(struct ntb_device *ndev)
1171{
1172 struct pci_dev *pdev = ndev->pdev;
1173 int msix_entries;
1174 int rc, i;
1175
1176 msix_entries = pci_msix_vec_count(pdev);
1177 if (msix_entries < 0) {
1178 rc = msix_entries;
1179 goto err;
1180 } else if (msix_entries > ndev->limits.msix_cnt) {
1181 rc = -EINVAL;
1182 goto err;
1183 }
1184
1185 ndev->msix_entries = kmalloc(sizeof(struct msix_entry) * msix_entries,
1186 GFP_KERNEL);
1187 if (!ndev->msix_entries) {
1188 rc = -ENOMEM;
1189 goto err;
1190 }
1191
1192 for (i = 0; i < msix_entries; i++)
1193 ndev->msix_entries[i].entry = i;
1194
1166 if (ndev->hw_type == BWD_HW) 1195 if (ndev->hw_type == BWD_HW)
1167 ndev->max_cbs = msix_entries; 1196 rc = ntb_setup_bwd_msix(ndev, msix_entries);
1168 else 1197 else
1169 ndev->max_cbs = msix_entries - 1; 1198 rc = ntb_setup_snb_msix(ndev, msix_entries);
1199 if (rc)
1200 goto err1;
1170 1201
1171 return 0; 1202 return 0;
1172 1203
1173err2:
1174 while (--i >= 0) {
1175 msix = &ndev->msix_entries[i];
1176 if (ndev->hw_type != BWD_HW && i == ndev->num_msix - 1)
1177 free_irq(msix->vector, ndev);
1178 else
1179 free_irq(msix->vector, &ndev->db_cb[i]);
1180 }
1181 pci_disable_msix(pdev);
1182err1: 1204err1:
1183 kfree(ndev->msix_entries); 1205 kfree(ndev->msix_entries);
1184 dev_err(&pdev->dev, "Error allocating MSI-X interrupt\n");
1185err: 1206err:
1186 ndev->num_msix = 0; 1207 dev_err(&pdev->dev, "Error allocating MSI-X interrupt\n");
1187 return rc; 1208 return rc;
1188} 1209}
1189 1210
@@ -1281,6 +1302,7 @@ static void ntb_free_interrupts(struct ntb_device *ndev)
1281 free_irq(msix->vector, &ndev->db_cb[i]); 1302 free_irq(msix->vector, &ndev->db_cb[i]);
1282 } 1303 }
1283 pci_disable_msix(pdev); 1304 pci_disable_msix(pdev);
1305 kfree(ndev->msix_entries);
1284 } else { 1306 } else {
1285 free_irq(pdev->irq, ndev); 1307 free_irq(pdev->irq, ndev);
1286 1308
diff --git a/drivers/ntb/ntb_hw.h b/drivers/ntb/ntb_hw.h
index bbdb7edca10c..465517b7393e 100644
--- a/drivers/ntb/ntb_hw.h
+++ b/drivers/ntb/ntb_hw.h
@@ -45,6 +45,7 @@
45 * Contact Information: 45 * Contact Information:
46 * Jon Mason <jon.mason@intel.com> 46 * Jon Mason <jon.mason@intel.com>
47 */ 47 */
48#include <linux/ntb.h>
48 49
49#define PCI_DEVICE_ID_INTEL_NTB_B2B_JSF 0x3725 50#define PCI_DEVICE_ID_INTEL_NTB_B2B_JSF 0x3725
50#define PCI_DEVICE_ID_INTEL_NTB_PS_JSF 0x3726 51#define PCI_DEVICE_ID_INTEL_NTB_PS_JSF 0x3726
@@ -60,8 +61,6 @@
60#define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F 61#define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F
61#define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E 62#define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E
62 63
63#define msix_table_size(control) ((control & PCI_MSIX_FLAGS_QSIZE)+1)
64
65#ifndef readq 64#ifndef readq
66static inline u64 readq(void __iomem *addr) 65static inline u64 readq(void __iomem *addr)
67{ 66{
@@ -83,9 +82,6 @@ static inline void writeq(u64 val, void __iomem *addr)
83#define NTB_BAR_MASK ((1 << NTB_BAR_MMIO) | (1 << NTB_BAR_23) |\ 82#define NTB_BAR_MASK ((1 << NTB_BAR_MMIO) | (1 << NTB_BAR_23) |\
84 (1 << NTB_BAR_45)) 83 (1 << NTB_BAR_45))
85 84
86#define NTB_LINK_DOWN 0
87#define NTB_LINK_UP 1
88
89#define NTB_HB_TIMEOUT msecs_to_jiffies(1000) 85#define NTB_HB_TIMEOUT msecs_to_jiffies(1000)
90 86
91#define NTB_MAX_NUM_MW 2 87#define NTB_MAX_NUM_MW 2
@@ -233,7 +229,7 @@ int ntb_register_db_callback(struct ntb_device *ndev, unsigned int idx,
233 int db_num)); 229 int db_num));
234void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx); 230void ntb_unregister_db_callback(struct ntb_device *ndev, unsigned int idx);
235int ntb_register_event_callback(struct ntb_device *ndev, 231int ntb_register_event_callback(struct ntb_device *ndev,
236 void (*event_cb_func) (void *handle, 232 void (*event_cb_func)(void *handle,
237 enum ntb_hw_event event)); 233 enum ntb_hw_event event));
238void ntb_unregister_event_callback(struct ntb_device *ndev); 234void ntb_unregister_event_callback(struct ntb_device *ndev);
239int ntb_get_max_spads(struct ntb_device *ndev); 235int ntb_get_max_spads(struct ntb_device *ndev);
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 3217f394d45b..9dd63b822025 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -56,7 +56,6 @@
56#include <linux/pci.h> 56#include <linux/pci.h>
57#include <linux/slab.h> 57#include <linux/slab.h>
58#include <linux/types.h> 58#include <linux/types.h>
59#include <linux/ntb.h>
60#include "ntb_hw.h" 59#include "ntb_hw.h"
61 60
62#define NTB_TRANSPORT_VERSION 3 61#define NTB_TRANSPORT_VERSION 3
@@ -107,8 +106,8 @@ struct ntb_transport_qp {
107 struct ntb_rx_info __iomem *rx_info; 106 struct ntb_rx_info __iomem *rx_info;
108 struct ntb_rx_info *remote_rx_info; 107 struct ntb_rx_info *remote_rx_info;
109 108
110 void (*tx_handler) (struct ntb_transport_qp *qp, void *qp_data, 109 void (*tx_handler)(struct ntb_transport_qp *qp, void *qp_data,
111 void *data, int len); 110 void *data, int len);
112 struct list_head tx_free_q; 111 struct list_head tx_free_q;
113 spinlock_t ntb_tx_free_q_lock; 112 spinlock_t ntb_tx_free_q_lock;
114 void __iomem *tx_mw; 113 void __iomem *tx_mw;
@@ -117,8 +116,8 @@ struct ntb_transport_qp {
117 unsigned int tx_max_entry; 116 unsigned int tx_max_entry;
118 unsigned int tx_max_frame; 117 unsigned int tx_max_frame;
119 118
120 void (*rx_handler) (struct ntb_transport_qp *qp, void *qp_data, 119 void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data,
121 void *data, int len); 120 void *data, int len);
122 struct list_head rx_pend_q; 121 struct list_head rx_pend_q;
123 struct list_head rx_free_q; 122 struct list_head rx_free_q;
124 spinlock_t ntb_rx_pend_q_lock; 123 spinlock_t ntb_rx_pend_q_lock;
@@ -129,7 +128,7 @@ struct ntb_transport_qp {
129 unsigned int rx_max_frame; 128 unsigned int rx_max_frame;
130 dma_cookie_t last_cookie; 129 dma_cookie_t last_cookie;
131 130
132 void (*event_handler) (void *data, int status); 131 void (*event_handler)(void *data, int status);
133 struct delayed_work link_work; 132 struct delayed_work link_work;
134 struct work_struct link_cleanup; 133 struct work_struct link_cleanup;
135 134
@@ -480,7 +479,7 @@ static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
480} 479}
481 480
482static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock, 481static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock,
483 struct list_head *list) 482 struct list_head *list)
484{ 483{
485 struct ntb_queue_entry *entry; 484 struct ntb_queue_entry *entry;
486 unsigned long flags; 485 unsigned long flags;
@@ -839,7 +838,7 @@ static void ntb_qp_link_work(struct work_struct *work)
839} 838}
840 839
841static int ntb_transport_init_queue(struct ntb_transport *nt, 840static int ntb_transport_init_queue(struct ntb_transport *nt,
842 unsigned int qp_num) 841 unsigned int qp_num)
843{ 842{
844 struct ntb_transport_qp *qp; 843 struct ntb_transport_qp *qp;
845 unsigned int num_qps_mw, tx_size; 844 unsigned int num_qps_mw, tx_size;
@@ -1055,7 +1054,7 @@ static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset,
1055 if (!chan) 1054 if (!chan)
1056 goto err; 1055 goto err;
1057 1056
1058 if (len < copy_bytes) 1057 if (len < copy_bytes)
1059 goto err_wait; 1058 goto err_wait;
1060 1059
1061 device = chan->device; 1060 device = chan->device;
@@ -1190,8 +1189,7 @@ out:
1190 return 0; 1189 return 0;
1191 1190
1192err: 1191err:
1193 ntb_list_add(&qp->ntb_rx_pend_q_lock, &entry->entry, 1192 ntb_list_add(&qp->ntb_rx_pend_q_lock, &entry->entry, &qp->rx_pend_q);
1194 &qp->rx_pend_q);
1195 /* Ensure that the data is fully copied out before clearing the flag */ 1193 /* Ensure that the data is fully copied out before clearing the flag */
1196 wmb(); 1194 wmb();
1197 hdr->flags = 0; 1195 hdr->flags = 0;
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 5f67843c7fb7..27df2c533b09 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -53,6 +53,18 @@ config ACERHDF
53 If you have an Acer Aspire One netbook, say Y or M 53 If you have an Acer Aspire One netbook, say Y or M
54 here. 54 here.
55 55
56config ALIENWARE_WMI
57 tristate "Alienware Special feature control"
58 depends on ACPI
59 depends on LEDS_CLASS
60 depends on NEW_LEDS
61 depends on ACPI_WMI
62 ---help---
63 This is a driver for controlling Alienware BIOS driven
64 features. It exposes an interface for controlling the AlienFX
65 zones on Alienware machines that don't contain a dedicated AlienFX
66 USB MCU such as the X51 and X51-R2.
67
56config ASUS_LAPTOP 68config ASUS_LAPTOP
57 tristate "Asus Laptop Extras" 69 tristate "Asus Laptop Extras"
58 depends on ACPI 70 depends on ACPI
@@ -196,7 +208,7 @@ config HP_ACCEL
196 be called hp_accel. 208 be called hp_accel.
197 209
198config HP_WIRELESS 210config HP_WIRELESS
199 tristate "HP WIRELESS" 211 tristate "HP wireless button"
200 depends on ACPI 212 depends on ACPI
201 depends on INPUT 213 depends on INPUT
202 help 214 help
@@ -817,12 +829,4 @@ config PVPANIC
817 a paravirtualized device provided by QEMU; it lets a virtual machine 829 a paravirtualized device provided by QEMU; it lets a virtual machine
818 (guest) communicate panic events to the host. 830 (guest) communicate panic events to the host.
819 831
820config INTEL_BAYTRAIL_MBI
821 tristate
822 depends on PCI
823 ---help---
824 Needed on Baytrail platforms for access to the IOSF Sideband Mailbox
825 Interface. This is a requirement for systems that need to configure
826 the PUNIT for power management features such as RAPL.
827
828endif # X86_PLATFORM_DEVICES 832endif # X86_PLATFORM_DEVICES
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 9b87cfc42b84..1a2eafc9d48e 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -55,4 +55,4 @@ obj-$(CONFIG_INTEL_RST) += intel-rst.o
55obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o 55obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o
56 56
57obj-$(CONFIG_PVPANIC) += pvpanic.o 57obj-$(CONFIG_PVPANIC) += pvpanic.o
58obj-$(CONFIG_INTEL_BAYTRAIL_MBI) += intel_baytrail.o 58obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
new file mode 100644
index 000000000000..541f9514f76f
--- /dev/null
+++ b/drivers/platform/x86/alienware-wmi.c
@@ -0,0 +1,565 @@
1/*
2 * Alienware AlienFX control
3 *
4 * Copyright (C) 2014 Dell Inc <mario_limonciello@dell.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 */
17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
20#include <linux/acpi.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/dmi.h>
24#include <linux/acpi.h>
25#include <linux/leds.h>
26
27#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
28#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
29#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492"
30
31#define WMAX_METHOD_HDMI_SOURCE 0x1
32#define WMAX_METHOD_HDMI_STATUS 0x2
33#define WMAX_METHOD_BRIGHTNESS 0x3
34#define WMAX_METHOD_ZONE_CONTROL 0x4
35
36MODULE_AUTHOR("Mario Limonciello <mario_limonciello@dell.com>");
37MODULE_DESCRIPTION("Alienware special feature control");
38MODULE_LICENSE("GPL");
39MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID);
40MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID);
41
42enum INTERFACE_FLAGS {
43 LEGACY,
44 WMAX,
45};
46
47enum LEGACY_CONTROL_STATES {
48 LEGACY_RUNNING = 1,
49 LEGACY_BOOTING = 0,
50 LEGACY_SUSPEND = 3,
51};
52
53enum WMAX_CONTROL_STATES {
54 WMAX_RUNNING = 0xFF,
55 WMAX_BOOTING = 0,
56 WMAX_SUSPEND = 3,
57};
58
59struct quirk_entry {
60 u8 num_zones;
61};
62
63static struct quirk_entry *quirks;
64
65static struct quirk_entry quirk_unknown = {
66 .num_zones = 2,
67};
68
69static struct quirk_entry quirk_x51_family = {
70 .num_zones = 3,
71};
72
73static int dmi_matched(const struct dmi_system_id *dmi)
74{
75 quirks = dmi->driver_data;
76 return 1;
77}
78
79static struct dmi_system_id alienware_quirks[] = {
80 {
81 .callback = dmi_matched,
82 .ident = "Alienware X51 R1",
83 .matches = {
84 DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
85 DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51"),
86 },
87 .driver_data = &quirk_x51_family,
88 },
89 {
90 .callback = dmi_matched,
91 .ident = "Alienware X51 R2",
92 .matches = {
93 DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
94 DMI_MATCH(DMI_PRODUCT_NAME, "Alienware X51 R2"),
95 },
96 .driver_data = &quirk_x51_family,
97 },
98 {}
99};
100
101struct color_platform {
102 u8 blue;
103 u8 green;
104 u8 red;
105} __packed;
106
107struct platform_zone {
108 u8 location;
109 struct device_attribute *attr;
110 struct color_platform colors;
111};
112
113struct wmax_brightness_args {
114 u32 led_mask;
115 u32 percentage;
116};
117
118struct hdmi_args {
119 u8 arg;
120};
121
122struct legacy_led_args {
123 struct color_platform colors;
124 u8 brightness;
125 u8 state;
126} __packed;
127
128struct wmax_led_args {
129 u32 led_mask;
130 struct color_platform colors;
131 u8 state;
132} __packed;
133
134static struct platform_device *platform_device;
135static struct device_attribute *zone_dev_attrs;
136static struct attribute **zone_attrs;
137static struct platform_zone *zone_data;
138
139static struct platform_driver platform_driver = {
140 .driver = {
141 .name = "alienware-wmi",
142 .owner = THIS_MODULE,
143 }
144};
145
146static struct attribute_group zone_attribute_group = {
147 .name = "rgb_zones",
148};
149
150static u8 interface;
151static u8 lighting_control_state;
152static u8 global_brightness;
153
154/*
155 * Helpers used for zone control
156*/
157static int parse_rgb(const char *buf, struct platform_zone *zone)
158{
159 long unsigned int rgb;
160 int ret;
161 union color_union {
162 struct color_platform cp;
163 int package;
164 } repackager;
165
166 ret = kstrtoul(buf, 16, &rgb);
167 if (ret)
168 return ret;
169
170 /* RGB triplet notation is 24-bit hexadecimal */
171 if (rgb > 0xFFFFFF)
172 return -EINVAL;
173
174 repackager.package = rgb & 0x0f0f0f0f;
175 pr_debug("alienware-wmi: r: %d g:%d b: %d\n",
176 repackager.cp.red, repackager.cp.green, repackager.cp.blue);
177 zone->colors = repackager.cp;
178 return 0;
179}
180
181static struct platform_zone *match_zone(struct device_attribute *attr)
182{
183 int i;
184 for (i = 0; i < quirks->num_zones; i++) {
185 if ((struct device_attribute *)zone_data[i].attr == attr) {
186 pr_debug("alienware-wmi: matched zone location: %d\n",
187 zone_data[i].location);
188 return &zone_data[i];
189 }
190 }
191 return NULL;
192}
193
194/*
195 * Individual RGB zone control
196*/
197static int alienware_update_led(struct platform_zone *zone)
198{
199 int method_id;
200 acpi_status status;
201 char *guid;
202 struct acpi_buffer input;
203 struct legacy_led_args legacy_args;
204 struct wmax_led_args wmax_args;
205 if (interface == WMAX) {
206 wmax_args.led_mask = 1 << zone->location;
207 wmax_args.colors = zone->colors;
208 wmax_args.state = lighting_control_state;
209 guid = WMAX_CONTROL_GUID;
210 method_id = WMAX_METHOD_ZONE_CONTROL;
211
212 input.length = (acpi_size) sizeof(wmax_args);
213 input.pointer = &wmax_args;
214 } else {
215 legacy_args.colors = zone->colors;
216 legacy_args.brightness = global_brightness;
217 legacy_args.state = 0;
218 if (lighting_control_state == LEGACY_BOOTING ||
219 lighting_control_state == LEGACY_SUSPEND) {
220 guid = LEGACY_POWER_CONTROL_GUID;
221 legacy_args.state = lighting_control_state;
222 } else
223 guid = LEGACY_CONTROL_GUID;
224 method_id = zone->location + 1;
225
226 input.length = (acpi_size) sizeof(legacy_args);
227 input.pointer = &legacy_args;
228 }
229 pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id);
230
231 status = wmi_evaluate_method(guid, 1, method_id, &input, NULL);
232 if (ACPI_FAILURE(status))
233 pr_err("alienware-wmi: zone set failure: %u\n", status);
234 return ACPI_FAILURE(status);
235}
236
237static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
238 char *buf)
239{
240 struct platform_zone *target_zone;
241 target_zone = match_zone(attr);
242 if (target_zone == NULL)
243 return sprintf(buf, "red: -1, green: -1, blue: -1\n");
244 return sprintf(buf, "red: %d, green: %d, blue: %d\n",
245 target_zone->colors.red,
246 target_zone->colors.green, target_zone->colors.blue);
247
248}
249
250static ssize_t zone_set(struct device *dev, struct device_attribute *attr,
251 const char *buf, size_t count)
252{
253 struct platform_zone *target_zone;
254 int ret;
255 target_zone = match_zone(attr);
256 if (target_zone == NULL) {
257 pr_err("alienware-wmi: invalid target zone\n");
258 return 1;
259 }
260 ret = parse_rgb(buf, target_zone);
261 if (ret)
262 return ret;
263 ret = alienware_update_led(target_zone);
264 return ret ? ret : count;
265}
266
267/*
268 * LED Brightness (Global)
269*/
270static int wmax_brightness(int brightness)
271{
272 acpi_status status;
273 struct acpi_buffer input;
274 struct wmax_brightness_args args = {
275 .led_mask = 0xFF,
276 .percentage = brightness,
277 };
278 input.length = (acpi_size) sizeof(args);
279 input.pointer = &args;
280 status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1,
281 WMAX_METHOD_BRIGHTNESS, &input, NULL);
282 if (ACPI_FAILURE(status))
283 pr_err("alienware-wmi: brightness set failure: %u\n", status);
284 return ACPI_FAILURE(status);
285}
286
287static void global_led_set(struct led_classdev *led_cdev,
288 enum led_brightness brightness)
289{
290 int ret;
291 global_brightness = brightness;
292 if (interface == WMAX)
293 ret = wmax_brightness(brightness);
294 else
295 ret = alienware_update_led(&zone_data[0]);
296 if (ret)
297 pr_err("LED brightness update failed\n");
298}
299
300static enum led_brightness global_led_get(struct led_classdev *led_cdev)
301{
302 return global_brightness;
303}
304
305static struct led_classdev global_led = {
306 .brightness_set = global_led_set,
307 .brightness_get = global_led_get,
308 .name = "alienware::global_brightness",
309};
310
311/*
312 * Lighting control state device attribute (Global)
313*/
314static ssize_t show_control_state(struct device *dev,
315 struct device_attribute *attr, char *buf)
316{
317 if (lighting_control_state == LEGACY_BOOTING)
318 return scnprintf(buf, PAGE_SIZE, "[booting] running suspend\n");
319 else if (lighting_control_state == LEGACY_SUSPEND)
320 return scnprintf(buf, PAGE_SIZE, "booting running [suspend]\n");
321 return scnprintf(buf, PAGE_SIZE, "booting [running] suspend\n");
322}
323
324static ssize_t store_control_state(struct device *dev,
325 struct device_attribute *attr,
326 const char *buf, size_t count)
327{
328 long unsigned int val;
329 if (strcmp(buf, "booting\n") == 0)
330 val = LEGACY_BOOTING;
331 else if (strcmp(buf, "suspend\n") == 0)
332 val = LEGACY_SUSPEND;
333 else if (interface == LEGACY)
334 val = LEGACY_RUNNING;
335 else
336 val = WMAX_RUNNING;
337 lighting_control_state = val;
338 pr_debug("alienware-wmi: updated control state to %d\n",
339 lighting_control_state);
340 return count;
341}
342
343static DEVICE_ATTR(lighting_control_state, 0644, show_control_state,
344 store_control_state);
345
346static int alienware_zone_init(struct platform_device *dev)
347{
348 int i;
349 char buffer[10];
350 char *name;
351
352 if (interface == WMAX) {
353 global_led.max_brightness = 100;
354 lighting_control_state = WMAX_RUNNING;
355 } else if (interface == LEGACY) {
356 global_led.max_brightness = 0x0F;
357 lighting_control_state = LEGACY_RUNNING;
358 }
359 global_brightness = global_led.max_brightness;
360
361 /*
362 * - zone_dev_attrs num_zones + 1 is for individual zones and then
363 * null terminated
364 * - zone_attrs num_zones + 2 is for all attrs in zone_dev_attrs +
365 * the lighting control + null terminated
366 * - zone_data num_zones is for the distinct zones
367 */
368 zone_dev_attrs =
369 kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1),
370 GFP_KERNEL);
371 if (!zone_dev_attrs)
372 return -ENOMEM;
373
374 zone_attrs =
375 kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2),
376 GFP_KERNEL);
377 if (!zone_attrs)
378 return -ENOMEM;
379
380 zone_data =
381 kzalloc(sizeof(struct platform_zone) * (quirks->num_zones),
382 GFP_KERNEL);
383 if (!zone_data)
384 return -ENOMEM;
385
386 for (i = 0; i < quirks->num_zones; i++) {
387 sprintf(buffer, "zone%02X", i);
388 name = kstrdup(buffer, GFP_KERNEL);
389 if (name == NULL)
390 return 1;
391 sysfs_attr_init(&zone_dev_attrs[i].attr);
392 zone_dev_attrs[i].attr.name = name;
393 zone_dev_attrs[i].attr.mode = 0644;
394 zone_dev_attrs[i].show = zone_show;
395 zone_dev_attrs[i].store = zone_set;
396 zone_data[i].location = i;
397 zone_attrs[i] = &zone_dev_attrs[i].attr;
398 zone_data[i].attr = &zone_dev_attrs[i];
399 }
400 zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr;
401 zone_attribute_group.attrs = zone_attrs;
402
403 led_classdev_register(&dev->dev, &global_led);
404
405 return sysfs_create_group(&dev->dev.kobj, &zone_attribute_group);
406}
407
408static void alienware_zone_exit(struct platform_device *dev)
409{
410 sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group);
411 led_classdev_unregister(&global_led);
412 if (zone_dev_attrs) {
413 int i;
414 for (i = 0; i < quirks->num_zones; i++)
415 kfree(zone_dev_attrs[i].attr.name);
416 }
417 kfree(zone_dev_attrs);
418 kfree(zone_data);
419 kfree(zone_attrs);
420}
421
422/*
423 The HDMI mux sysfs node indicates the status of the HDMI input mux.
424 It can toggle between standard system GPU output and HDMI input.
425*/
426static ssize_t show_hdmi(struct device *dev, struct device_attribute *attr,
427 char *buf)
428{
429 acpi_status status;
430 struct acpi_buffer input;
431 union acpi_object *obj;
432 u32 tmp = 0;
433 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
434 struct hdmi_args in_args = {
435 .arg = 0,
436 };
437 input.length = (acpi_size) sizeof(in_args);
438 input.pointer = &in_args;
439 status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1,
440 WMAX_METHOD_HDMI_STATUS, &input, &output);
441
442 if (ACPI_SUCCESS(status)) {
443 obj = (union acpi_object *)output.pointer;
444 if (obj && obj->type == ACPI_TYPE_INTEGER)
445 tmp = (u32) obj->integer.value;
446 if (tmp == 1)
447 return scnprintf(buf, PAGE_SIZE,
448 "[input] gpu unknown\n");
449 else if (tmp == 2)
450 return scnprintf(buf, PAGE_SIZE,
451 "input [gpu] unknown\n");
452 }
453 pr_err("alienware-wmi: unknown HDMI status: %d\n", status);
454 return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n");
455}
456
457static ssize_t toggle_hdmi(struct device *dev, struct device_attribute *attr,
458 const char *buf, size_t count)
459{
460 struct acpi_buffer input;
461 acpi_status status;
462 struct hdmi_args args;
463 if (strcmp(buf, "gpu\n") == 0)
464 args.arg = 1;
465 else if (strcmp(buf, "input\n") == 0)
466 args.arg = 2;
467 else
468 args.arg = 3;
469 pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf);
470 input.length = (acpi_size) sizeof(args);
471 input.pointer = &args;
472 status = wmi_evaluate_method(WMAX_CONTROL_GUID, 1,
473 WMAX_METHOD_HDMI_SOURCE, &input, NULL);
474 if (ACPI_FAILURE(status))
475 pr_err("alienware-wmi: HDMI toggle failed: results: %u\n",
476 status);
477 return count;
478}
479
480static DEVICE_ATTR(hdmi, S_IRUGO | S_IWUSR, show_hdmi, toggle_hdmi);
481
482static void remove_hdmi(struct platform_device *device)
483{
484 device_remove_file(&device->dev, &dev_attr_hdmi);
485}
486
487static int create_hdmi(void)
488{
489 int ret = -ENOMEM;
490 ret = device_create_file(&platform_device->dev, &dev_attr_hdmi);
491 if (ret)
492 goto error_create_hdmi;
493 return 0;
494
495error_create_hdmi:
496 remove_hdmi(platform_device);
497 return ret;
498}
499
500static int __init alienware_wmi_init(void)
501{
502 int ret;
503
504 if (wmi_has_guid(LEGACY_CONTROL_GUID))
505 interface = LEGACY;
506 else if (wmi_has_guid(WMAX_CONTROL_GUID))
507 interface = WMAX;
508 else {
509 pr_warn("alienware-wmi: No known WMI GUID found\n");
510 return -ENODEV;
511 }
512
513 dmi_check_system(alienware_quirks);
514 if (quirks == NULL)
515 quirks = &quirk_unknown;
516
517 ret = platform_driver_register(&platform_driver);
518 if (ret)
519 goto fail_platform_driver;
520 platform_device = platform_device_alloc("alienware-wmi", -1);
521 if (!platform_device) {
522 ret = -ENOMEM;
523 goto fail_platform_device1;
524 }
525 ret = platform_device_add(platform_device);
526 if (ret)
527 goto fail_platform_device2;
528
529 if (interface == WMAX) {
530 ret = create_hdmi();
531 if (ret)
532 goto fail_prep_hdmi;
533 }
534
535 ret = alienware_zone_init(platform_device);
536 if (ret)
537 goto fail_prep_zones;
538
539 return 0;
540
541fail_prep_zones:
542 alienware_zone_exit(platform_device);
543fail_prep_hdmi:
544 platform_device_del(platform_device);
545fail_platform_device2:
546 platform_device_put(platform_device);
547fail_platform_device1:
548 platform_driver_unregister(&platform_driver);
549fail_platform_driver:
550 return ret;
551}
552
553module_init(alienware_wmi_init);
554
555static void __exit alienware_wmi_exit(void)
556{
557 if (platform_device) {
558 alienware_zone_exit(platform_device);
559 remove_hdmi(platform_device);
560 platform_device_unregister(platform_device);
561 platform_driver_unregister(&platform_driver);
562 }
563}
564
565module_exit(alienware_wmi_exit);
diff --git a/drivers/platform/x86/fujitsu-tablet.c b/drivers/platform/x86/fujitsu-tablet.c
index 570926c10014..c3784baceae3 100644
--- a/drivers/platform/x86/fujitsu-tablet.c
+++ b/drivers/platform/x86/fujitsu-tablet.c
@@ -71,6 +71,44 @@ static unsigned short keymap_Lifebook_Tseries[KEYMAP_LEN] __initdata = {
71 KEY_LEFTALT 71 KEY_LEFTALT
72}; 72};
73 73
74static unsigned short keymap_Lifebook_T901[KEYMAP_LEN] __initdata = {
75 KEY_RESERVED,
76 KEY_RESERVED,
77 KEY_RESERVED,
78 KEY_RESERVED,
79 KEY_SCROLLDOWN,
80 KEY_SCROLLUP,
81 KEY_CYCLEWINDOWS,
82 KEY_LEFTCTRL,
83 KEY_RESERVED,
84 KEY_RESERVED,
85 KEY_RESERVED,
86 KEY_RESERVED,
87 KEY_RESERVED,
88 KEY_RESERVED,
89 KEY_RESERVED,
90 KEY_LEFTMETA
91};
92
93static unsigned short keymap_Lifebook_T902[KEYMAP_LEN] __initdata = {
94 KEY_RESERVED,
95 KEY_VOLUMEDOWN,
96 KEY_VOLUMEUP,
97 KEY_CYCLEWINDOWS,
98 KEY_PROG1,
99 KEY_PROG2,
100 KEY_LEFTMETA,
101 KEY_RESERVED,
102 KEY_RESERVED,
103 KEY_RESERVED,
104 KEY_RESERVED,
105 KEY_RESERVED,
106 KEY_RESERVED,
107 KEY_RESERVED,
108 KEY_RESERVED,
109 KEY_RESERVED,
110};
111
74static unsigned short keymap_Lifebook_U810[KEYMAP_LEN] __initdata = { 112static unsigned short keymap_Lifebook_U810[KEYMAP_LEN] __initdata = {
75 KEY_RESERVED, 113 KEY_RESERVED,
76 KEY_RESERVED, 114 KEY_RESERVED,
@@ -302,6 +340,33 @@ static int fujitsu_dmi_stylistic(const struct dmi_system_id *dmi)
302static const struct dmi_system_id dmi_ids[] __initconst = { 340static const struct dmi_system_id dmi_ids[] __initconst = {
303 { 341 {
304 .callback = fujitsu_dmi_lifebook, 342 .callback = fujitsu_dmi_lifebook,
343 .ident = "Fujitsu Lifebook T901",
344 .matches = {
345 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
346 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook T901")
347 },
348 .driver_data = keymap_Lifebook_T901
349 },
350 {
351 .callback = fujitsu_dmi_lifebook,
352 .ident = "Fujitsu Lifebook T901",
353 .matches = {
354 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
355 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T901")
356 },
357 .driver_data = keymap_Lifebook_T901
358 },
359 {
360 .callback = fujitsu_dmi_lifebook,
361 .ident = "Fujitsu Lifebook T902",
362 .matches = {
363 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
364 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T902")
365 },
366 .driver_data = keymap_Lifebook_T902
367 },
368 {
369 .callback = fujitsu_dmi_lifebook,
305 .ident = "Fujitsu Siemens P/T Series", 370 .ident = "Fujitsu Siemens P/T Series",
306 .matches = { 371 .matches = {
307 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), 372 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
diff --git a/drivers/platform/x86/intel_baytrail.c b/drivers/platform/x86/intel_baytrail.c
deleted file mode 100644
index f96626b17260..000000000000
--- a/drivers/platform/x86/intel_baytrail.c
+++ /dev/null
@@ -1,224 +0,0 @@
1/*
2 * Baytrail IOSF-SB MailBox Interface Driver
3 * Copyright (c) 2013, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *
15 * The IOSF-SB is a fabric bus available on Atom based SOC's that uses a
16 * mailbox interface (MBI) to communicate with mutiple devices. This
17 * driver implements BayTrail-specific access to this interface.
18 */
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/spinlock.h>
23#include <linux/pci.h>
24
25#include "intel_baytrail.h"
26
27static DEFINE_SPINLOCK(iosf_mbi_lock);
28
29static inline u32 iosf_mbi_form_mcr(u8 op, u8 port, u8 offset)
30{
31 return (op << 24) | (port << 16) | (offset << 8) | BT_MBI_ENABLE;
32}
33
34static struct pci_dev *mbi_pdev; /* one mbi device */
35
36/* Hold lock before calling */
37static int iosf_mbi_pci_read_mdr(u32 mcrx, u32 mcr, u32 *mdr)
38{
39 int result;
40
41 if (!mbi_pdev)
42 return -ENODEV;
43
44 if (mcrx) {
45 result = pci_write_config_dword(mbi_pdev,
46 BT_MBI_MCRX_OFFSET, mcrx);
47 if (result < 0)
48 goto iosf_mbi_read_err;
49 }
50
51 result = pci_write_config_dword(mbi_pdev,
52 BT_MBI_MCR_OFFSET, mcr);
53 if (result < 0)
54 goto iosf_mbi_read_err;
55
56 result = pci_read_config_dword(mbi_pdev,
57 BT_MBI_MDR_OFFSET, mdr);
58 if (result < 0)
59 goto iosf_mbi_read_err;
60
61 return 0;
62
63iosf_mbi_read_err:
64 dev_err(&mbi_pdev->dev, "error: PCI config operation returned %d\n",
65 result);
66 return result;
67}
68
69/* Hold lock before calling */
70static int iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
71{
72 int result;
73
74 if (!mbi_pdev)
75 return -ENODEV;
76
77 result = pci_write_config_dword(mbi_pdev,
78 BT_MBI_MDR_OFFSET, mdr);
79 if (result < 0)
80 goto iosf_mbi_write_err;
81
82 if (mcrx) {
83 result = pci_write_config_dword(mbi_pdev,
84 BT_MBI_MCRX_OFFSET, mcrx);
85 if (result < 0)
86 goto iosf_mbi_write_err;
87 }
88
89 result = pci_write_config_dword(mbi_pdev,
90 BT_MBI_MCR_OFFSET, mcr);
91 if (result < 0)
92 goto iosf_mbi_write_err;
93
94 return 0;
95
96iosf_mbi_write_err:
97 dev_err(&mbi_pdev->dev, "error: PCI config operation returned %d\n",
98 result);
99 return result;
100}
101
102int bt_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
103{
104 u32 mcr, mcrx;
105 unsigned long flags;
106 int ret;
107
108 /*Access to the GFX unit is handled by GPU code */
109 BUG_ON(port == BT_MBI_UNIT_GFX);
110
111 mcr = iosf_mbi_form_mcr(opcode, port, offset & BT_MBI_MASK_LO);
112 mcrx = offset & BT_MBI_MASK_HI;
113
114 spin_lock_irqsave(&iosf_mbi_lock, flags);
115 ret = iosf_mbi_pci_read_mdr(mcrx, mcr, mdr);
116 spin_unlock_irqrestore(&iosf_mbi_lock, flags);
117
118 return ret;
119}
120EXPORT_SYMBOL(bt_mbi_read);
121
122int bt_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
123{
124 u32 mcr, mcrx;
125 unsigned long flags;
126 int ret;
127
128 /*Access to the GFX unit is handled by GPU code */
129 BUG_ON(port == BT_MBI_UNIT_GFX);
130
131 mcr = iosf_mbi_form_mcr(opcode, port, offset & BT_MBI_MASK_LO);
132 mcrx = offset & BT_MBI_MASK_HI;
133
134 spin_lock_irqsave(&iosf_mbi_lock, flags);
135 ret = iosf_mbi_pci_write_mdr(mcrx, mcr, mdr);
136 spin_unlock_irqrestore(&iosf_mbi_lock, flags);
137
138 return ret;
139}
140EXPORT_SYMBOL(bt_mbi_write);
141
142int bt_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
143{
144 u32 mcr, mcrx;
145 u32 value;
146 unsigned long flags;
147 int ret;
148
149 /*Access to the GFX unit is handled by GPU code */
150 BUG_ON(port == BT_MBI_UNIT_GFX);
151
152 mcr = iosf_mbi_form_mcr(opcode, port, offset & BT_MBI_MASK_LO);
153 mcrx = offset & BT_MBI_MASK_HI;
154
155 spin_lock_irqsave(&iosf_mbi_lock, flags);
156
157 /* Read current mdr value */
158 ret = iosf_mbi_pci_read_mdr(mcrx, mcr & BT_MBI_RD_MASK, &value);
159 if (ret < 0) {
160 spin_unlock_irqrestore(&iosf_mbi_lock, flags);
161 return ret;
162 }
163
164 /* Apply mask */
165 value &= ~mask;
166 mdr &= mask;
167 value |= mdr;
168
169 /* Write back */
170 ret = iosf_mbi_pci_write_mdr(mcrx, mcr | BT_MBI_WR_MASK, value);
171
172 spin_unlock_irqrestore(&iosf_mbi_lock, flags);
173
174 return ret;
175}
176EXPORT_SYMBOL(bt_mbi_modify);
177
178static int iosf_mbi_probe(struct pci_dev *pdev,
179 const struct pci_device_id *unused)
180{
181 int ret;
182
183 ret = pci_enable_device(pdev);
184 if (ret < 0) {
185 dev_err(&pdev->dev, "error: could not enable device\n");
186 return ret;
187 }
188
189 mbi_pdev = pci_dev_get(pdev);
190 return 0;
191}
192
193static DEFINE_PCI_DEVICE_TABLE(iosf_mbi_pci_ids) = {
194 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0F00) },
195 { 0, },
196};
197MODULE_DEVICE_TABLE(pci, iosf_mbi_pci_ids);
198
199static struct pci_driver iosf_mbi_pci_driver = {
200 .name = "iosf_mbi_pci",
201 .probe = iosf_mbi_probe,
202 .id_table = iosf_mbi_pci_ids,
203};
204
205static int __init bt_mbi_init(void)
206{
207 return pci_register_driver(&iosf_mbi_pci_driver);
208}
209
210static void __exit bt_mbi_exit(void)
211{
212 pci_unregister_driver(&iosf_mbi_pci_driver);
213 if (mbi_pdev) {
214 pci_dev_put(mbi_pdev);
215 mbi_pdev = NULL;
216 }
217}
218
219module_init(bt_mbi_init);
220module_exit(bt_mbi_exit);
221
222MODULE_AUTHOR("David E. Box <david.e.box@linux.intel.com>");
223MODULE_DESCRIPTION("BayTrail Mailbox Interface accessor");
224MODULE_LICENSE("GPL v2");
diff --git a/drivers/platform/x86/intel_baytrail.h b/drivers/platform/x86/intel_baytrail.h
deleted file mode 100644
index 8bcc311262e9..000000000000
--- a/drivers/platform/x86/intel_baytrail.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * intel_baytrail.h: MailBox access support for Intel BayTrail platforms
3 */
4
5#ifndef INTEL_BAYTRAIL_MBI_SYMS_H
6#define INTEL_BAYTRAIL_MBI_SYMS_H
7
8#define BT_MBI_MCR_OFFSET 0xD0
9#define BT_MBI_MDR_OFFSET 0xD4
10#define BT_MBI_MCRX_OFFSET 0xD8
11
12#define BT_MBI_RD_MASK 0xFEFFFFFF
13#define BT_MBI_WR_MASK 0X01000000
14
15#define BT_MBI_MASK_HI 0xFFFFFF00
16#define BT_MBI_MASK_LO 0x000000FF
17#define BT_MBI_ENABLE 0xF0
18
19/* BT-SB unit access methods */
20#define BT_MBI_UNIT_AUNIT 0x00
21#define BT_MBI_UNIT_SMC 0x01
22#define BT_MBI_UNIT_CPU 0x02
23#define BT_MBI_UNIT_BUNIT 0x03
24#define BT_MBI_UNIT_PMC 0x04
25#define BT_MBI_UNIT_GFX 0x06
26#define BT_MBI_UNIT_SMI 0x0C
27#define BT_MBI_UNIT_USB 0x43
28#define BT_MBI_UNIT_SATA 0xA3
29#define BT_MBI_UNIT_PCIE 0xA6
30
31/* Read/write opcodes */
32#define BT_MBI_AUNIT_READ 0x10
33#define BT_MBI_AUNIT_WRITE 0x11
34#define BT_MBI_SMC_READ 0x10
35#define BT_MBI_SMC_WRITE 0x11
36#define BT_MBI_CPU_READ 0x10
37#define BT_MBI_CPU_WRITE 0x11
38#define BT_MBI_BUNIT_READ 0x10
39#define BT_MBI_BUNIT_WRITE 0x11
40#define BT_MBI_PMC_READ 0x06
41#define BT_MBI_PMC_WRITE 0x07
42#define BT_MBI_GFX_READ 0x00
43#define BT_MBI_GFX_WRITE 0x01
44#define BT_MBI_SMIO_READ 0x06
45#define BT_MBI_SMIO_WRITE 0x07
46#define BT_MBI_USB_READ 0x06
47#define BT_MBI_USB_WRITE 0x07
48#define BT_MBI_SATA_READ 0x00
49#define BT_MBI_SATA_WRITE 0x01
50#define BT_MBI_PCIE_READ 0x00
51#define BT_MBI_PCIE_WRITE 0x01
52
53/**
54 * bt_mbi_read() - MailBox Interface read command
55 * @port: port indicating subunit being accessed
56 * @opcode: port specific read or write opcode
57 * @offset: register address offset
58 * @mdr: register data to be read
59 *
60 * Locking is handled by spinlock - cannot sleep.
61 * Return: Nonzero on error
62 */
63int bt_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
64
65/**
66 * bt_mbi_write() - MailBox unmasked write command
67 * @port: port indicating subunit being accessed
68 * @opcode: port specific read or write opcode
69 * @offset: register address offset
70 * @mdr: register data to be written
71 *
72 * Locking is handled by spinlock - cannot sleep.
73 * Return: Nonzero on error
74 */
75int bt_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
76
77/**
78 * bt_mbi_modify() - MailBox masked write command
79 * @port: port indicating subunit being accessed
80 * @opcode: port specific read or write opcode
81 * @offset: register address offset
82 * @mdr: register data being modified
83 * @mask: mask indicating bits in mdr to be modified
84 *
85 * Locking is handled by spinlock - cannot sleep.
86 * Return: Nonzero on error
87 */
88int bt_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
89
90#endif /* INTEL_BAYTRAIL_MBI_SYMS_H */
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 609d38779b26..3f870972247c 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -449,6 +449,7 @@ static struct attribute_group pcc_attr_group = {
449 449
450/* hotkey input device driver */ 450/* hotkey input device driver */
451 451
452static int sleep_keydown_seen;
452static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc) 453static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
453{ 454{
454 struct input_dev *hotk_input_dev = pcc->input_dev; 455 struct input_dev *hotk_input_dev = pcc->input_dev;
@@ -462,6 +463,16 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
462 "error getting hotkey status\n")); 463 "error getting hotkey status\n"));
463 return; 464 return;
464 } 465 }
466
467 /* hack: some firmware sends no key down for sleep / hibernate */
468 if ((result & 0xf) == 0x7 || (result & 0xf) == 0xa) {
469 if (result & 0x80)
470 sleep_keydown_seen = 1;
471 if (!sleep_keydown_seen)
472 sparse_keymap_report_event(hotk_input_dev,
473 result & 0xf, 0x80, false);
474 }
475
465 if (!sparse_keymap_report_event(hotk_input_dev, 476 if (!sparse_keymap_report_event(hotk_input_dev,
466 result & 0xf, result & 0x80, false)) 477 result & 0xf, result & 0x80, false))
467 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 478 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 8f8551a63cc0..9c5a07417b2b 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -76,8 +76,6 @@ do { \
76 pr_warn(fmt, ##__VA_ARGS__); \ 76 pr_warn(fmt, ##__VA_ARGS__); \
77} while (0) 77} while (0)
78 78
79#define SONY_LAPTOP_DRIVER_VERSION "0.6"
80
81#define SONY_NC_CLASS "sony-nc" 79#define SONY_NC_CLASS "sony-nc"
82#define SONY_NC_HID "SNY5001" 80#define SONY_NC_HID "SNY5001"
83#define SONY_NC_DRIVER_NAME "Sony Notebook Control Driver" 81#define SONY_NC_DRIVER_NAME "Sony Notebook Control Driver"
@@ -89,7 +87,6 @@ do { \
89MODULE_AUTHOR("Stelian Pop, Mattia Dongili"); 87MODULE_AUTHOR("Stelian Pop, Mattia Dongili");
90MODULE_DESCRIPTION("Sony laptop extras driver (SPIC and SNC ACPI device)"); 88MODULE_DESCRIPTION("Sony laptop extras driver (SPIC and SNC ACPI device)");
91MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
92MODULE_VERSION(SONY_LAPTOP_DRIVER_VERSION);
93 90
94static int debug; 91static int debug;
95module_param(debug, int, 0); 92module_param(debug, int, 0);
@@ -129,7 +126,8 @@ static int kbd_backlight = -1;
129module_param(kbd_backlight, int, 0444); 126module_param(kbd_backlight, int, 0444);
130MODULE_PARM_DESC(kbd_backlight, 127MODULE_PARM_DESC(kbd_backlight,
131 "set this to 0 to disable keyboard backlight, " 128 "set this to 0 to disable keyboard backlight, "
132 "1 to enable it (default: no change from current value)"); 129 "1 to enable it with automatic control and 2 to have it always "
130 "on (default: no change from current value)");
133 131
134static int kbd_backlight_timeout = -1; 132static int kbd_backlight_timeout = -1;
135module_param(kbd_backlight_timeout, int, 0444); 133module_param(kbd_backlight_timeout, int, 0444);
@@ -152,7 +150,8 @@ static void sony_nc_battery_care_cleanup(struct platform_device *pd);
152static int sony_nc_thermal_setup(struct platform_device *pd); 150static int sony_nc_thermal_setup(struct platform_device *pd);
153static void sony_nc_thermal_cleanup(struct platform_device *pd); 151static void sony_nc_thermal_cleanup(struct platform_device *pd);
154 152
155static int sony_nc_lid_resume_setup(struct platform_device *pd); 153static int sony_nc_lid_resume_setup(struct platform_device *pd,
154 unsigned int handle);
156static void sony_nc_lid_resume_cleanup(struct platform_device *pd); 155static void sony_nc_lid_resume_cleanup(struct platform_device *pd);
157 156
158static int sony_nc_gfx_switch_setup(struct platform_device *pd, 157static int sony_nc_gfx_switch_setup(struct platform_device *pd,
@@ -163,6 +162,21 @@ static int __sony_nc_gfx_switch_status_get(void);
163static int sony_nc_highspeed_charging_setup(struct platform_device *pd); 162static int sony_nc_highspeed_charging_setup(struct platform_device *pd);
164static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd); 163static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd);
165 164
165static int sony_nc_lowbatt_setup(struct platform_device *pd);
166static void sony_nc_lowbatt_cleanup(struct platform_device *pd);
167
168static int sony_nc_fanspeed_setup(struct platform_device *pd);
169static void sony_nc_fanspeed_cleanup(struct platform_device *pd);
170
171static int sony_nc_usb_charge_setup(struct platform_device *pd);
172static void sony_nc_usb_charge_cleanup(struct platform_device *pd);
173
174static int sony_nc_panelid_setup(struct platform_device *pd);
175static void sony_nc_panelid_cleanup(struct platform_device *pd);
176
177static int sony_nc_smart_conn_setup(struct platform_device *pd);
178static void sony_nc_smart_conn_cleanup(struct platform_device *pd);
179
166static int sony_nc_touchpad_setup(struct platform_device *pd, 180static int sony_nc_touchpad_setup(struct platform_device *pd,
167 unsigned int handle); 181 unsigned int handle);
168static void sony_nc_touchpad_cleanup(struct platform_device *pd); 182static void sony_nc_touchpad_cleanup(struct platform_device *pd);
@@ -1122,6 +1136,8 @@ static struct sony_nc_event sony_100_events[] = {
1122 { 0x25, SONYPI_EVENT_ANYBUTTON_RELEASED }, 1136 { 0x25, SONYPI_EVENT_ANYBUTTON_RELEASED },
1123 { 0xa6, SONYPI_EVENT_HELP_PRESSED }, 1137 { 0xa6, SONYPI_EVENT_HELP_PRESSED },
1124 { 0x26, SONYPI_EVENT_ANYBUTTON_RELEASED }, 1138 { 0x26, SONYPI_EVENT_ANYBUTTON_RELEASED },
1139 { 0xa8, SONYPI_EVENT_FNKEY_1 },
1140 { 0x28, SONYPI_EVENT_ANYBUTTON_RELEASED },
1125 { 0, 0 }, 1141 { 0, 0 },
1126}; 1142};
1127 1143
@@ -1339,7 +1355,8 @@ static void sony_nc_function_setup(struct acpi_device *device,
1339 result); 1355 result);
1340 break; 1356 break;
1341 case 0x0119: 1357 case 0x0119:
1342 result = sony_nc_lid_resume_setup(pf_device); 1358 case 0x015D:
1359 result = sony_nc_lid_resume_setup(pf_device, handle);
1343 if (result) 1360 if (result)
1344 pr_err("couldn't set up lid resume function (%d)\n", 1361 pr_err("couldn't set up lid resume function (%d)\n",
1345 result); 1362 result);
@@ -1381,6 +1398,36 @@ static void sony_nc_function_setup(struct acpi_device *device,
1381 pr_err("couldn't set up keyboard backlight function (%d)\n", 1398 pr_err("couldn't set up keyboard backlight function (%d)\n",
1382 result); 1399 result);
1383 break; 1400 break;
1401 case 0x0121:
1402 result = sony_nc_lowbatt_setup(pf_device);
1403 if (result)
1404 pr_err("couldn't set up low battery function (%d)\n",
1405 result);
1406 break;
1407 case 0x0149:
1408 result = sony_nc_fanspeed_setup(pf_device);
1409 if (result)
1410 pr_err("couldn't set up fan speed function (%d)\n",
1411 result);
1412 break;
1413 case 0x0155:
1414 result = sony_nc_usb_charge_setup(pf_device);
1415 if (result)
1416 pr_err("couldn't set up USB charge support (%d)\n",
1417 result);
1418 break;
1419 case 0x011D:
1420 result = sony_nc_panelid_setup(pf_device);
1421 if (result)
1422 pr_err("couldn't set up panel ID function (%d)\n",
1423 result);
1424 break;
1425 case 0x0168:
1426 result = sony_nc_smart_conn_setup(pf_device);
1427 if (result)
1428 pr_err("couldn't set up smart connect support (%d)\n",
1429 result);
1430 break;
1384 default: 1431 default:
1385 continue; 1432 continue;
1386 } 1433 }
@@ -1420,6 +1467,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
1420 sony_nc_battery_care_cleanup(pd); 1467 sony_nc_battery_care_cleanup(pd);
1421 break; 1468 break;
1422 case 0x0119: 1469 case 0x0119:
1470 case 0x015D:
1423 sony_nc_lid_resume_cleanup(pd); 1471 sony_nc_lid_resume_cleanup(pd);
1424 break; 1472 break;
1425 case 0x0122: 1473 case 0x0122:
@@ -1444,6 +1492,21 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
1444 case 0x0163: 1492 case 0x0163:
1445 sony_nc_kbd_backlight_cleanup(pd, handle); 1493 sony_nc_kbd_backlight_cleanup(pd, handle);
1446 break; 1494 break;
1495 case 0x0121:
1496 sony_nc_lowbatt_cleanup(pd);
1497 break;
1498 case 0x0149:
1499 sony_nc_fanspeed_cleanup(pd);
1500 break;
1501 case 0x0155:
1502 sony_nc_usb_charge_cleanup(pd);
1503 break;
1504 case 0x011D:
1505 sony_nc_panelid_cleanup(pd);
1506 break;
1507 case 0x0168:
1508 sony_nc_smart_conn_cleanup(pd);
1509 break;
1447 default: 1510 default:
1448 continue; 1511 continue;
1449 } 1512 }
@@ -1719,7 +1782,7 @@ static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value)
1719{ 1782{
1720 int result; 1783 int result;
1721 1784
1722 if (value > 1) 1785 if (value > 2)
1723 return -EINVAL; 1786 return -EINVAL;
1724 1787
1725 if (sony_call_snc_handle(kbdbl_ctl->handle, 1788 if (sony_call_snc_handle(kbdbl_ctl->handle,
@@ -1727,8 +1790,10 @@ static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value)
1727 return -EIO; 1790 return -EIO;
1728 1791
1729 /* Try to turn the light on/off immediately */ 1792 /* Try to turn the light on/off immediately */
1730 sony_call_snc_handle(kbdbl_ctl->handle, 1793 if (value != 1)
1731 (value << 0x10) | (kbdbl_ctl->base + 0x100), &result); 1794 sony_call_snc_handle(kbdbl_ctl->handle,
1795 (value << 0x0f) | (kbdbl_ctl->base + 0x100),
1796 &result);
1732 1797
1733 kbdbl_ctl->mode = value; 1798 kbdbl_ctl->mode = value;
1734 1799
@@ -2221,9 +2286,14 @@ static void sony_nc_thermal_resume(void)
2221#endif 2286#endif
2222 2287
2223/* resume on LID open */ 2288/* resume on LID open */
2289#define LID_RESUME_S5 0
2290#define LID_RESUME_S4 1
2291#define LID_RESUME_S3 2
2292#define LID_RESUME_MAX 3
2224struct snc_lid_resume_control { 2293struct snc_lid_resume_control {
2225 struct device_attribute attrs[3]; 2294 struct device_attribute attrs[LID_RESUME_MAX];
2226 unsigned int status; 2295 unsigned int status;
2296 int handle;
2227}; 2297};
2228static struct snc_lid_resume_control *lid_ctl; 2298static struct snc_lid_resume_control *lid_ctl;
2229 2299
@@ -2231,8 +2301,9 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev,
2231 struct device_attribute *attr, 2301 struct device_attribute *attr,
2232 const char *buffer, size_t count) 2302 const char *buffer, size_t count)
2233{ 2303{
2234 unsigned int result, pos; 2304 unsigned int result;
2235 unsigned long value; 2305 unsigned long value;
2306 unsigned int pos = LID_RESUME_S5;
2236 if (count > 31) 2307 if (count > 31)
2237 return -EINVAL; 2308 return -EINVAL;
2238 2309
@@ -2245,21 +2316,21 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev,
2245 * +--------------+ 2316 * +--------------+
2246 * 2 1 0 2317 * 2 1 0
2247 */ 2318 */
2248 if (strcmp(attr->attr.name, "lid_resume_S3") == 0) 2319 while (pos < LID_RESUME_MAX) {
2249 pos = 2; 2320 if (&lid_ctl->attrs[pos].attr == &attr->attr)
2250 else if (strcmp(attr->attr.name, "lid_resume_S4") == 0) 2321 break;
2251 pos = 1; 2322 pos++;
2252 else if (strcmp(attr->attr.name, "lid_resume_S5") == 0) 2323 }
2253 pos = 0; 2324 if (pos == LID_RESUME_MAX)
2254 else 2325 return -EINVAL;
2255 return -EINVAL;
2256 2326
2257 if (value) 2327 if (value)
2258 value = lid_ctl->status | (1 << pos); 2328 value = lid_ctl->status | (1 << pos);
2259 else 2329 else
2260 value = lid_ctl->status & ~(1 << pos); 2330 value = lid_ctl->status & ~(1 << pos);
2261 2331
2262 if (sony_call_snc_handle(0x0119, value << 0x10 | 0x0100, &result)) 2332 if (sony_call_snc_handle(lid_ctl->handle, value << 0x10 | 0x0100,
2333 &result))
2263 return -EIO; 2334 return -EIO;
2264 2335
2265 lid_ctl->status = value; 2336 lid_ctl->status = value;
@@ -2268,29 +2339,27 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev,
2268} 2339}
2269 2340
2270static ssize_t sony_nc_lid_resume_show(struct device *dev, 2341static ssize_t sony_nc_lid_resume_show(struct device *dev,
2271 struct device_attribute *attr, char *buffer) 2342 struct device_attribute *attr,
2343 char *buffer)
2272{ 2344{
2273 unsigned int pos; 2345 unsigned int pos = LID_RESUME_S5;
2274 2346
2275 if (strcmp(attr->attr.name, "lid_resume_S3") == 0) 2347 while (pos < LID_RESUME_MAX) {
2276 pos = 2; 2348 if (&lid_ctl->attrs[pos].attr == &attr->attr)
2277 else if (strcmp(attr->attr.name, "lid_resume_S4") == 0) 2349 return snprintf(buffer, PAGE_SIZE, "%d\n",
2278 pos = 1; 2350 (lid_ctl->status >> pos) & 0x01);
2279 else if (strcmp(attr->attr.name, "lid_resume_S5") == 0) 2351 pos++;
2280 pos = 0; 2352 }
2281 else 2353 return -EINVAL;
2282 return -EINVAL;
2283
2284 return snprintf(buffer, PAGE_SIZE, "%d\n",
2285 (lid_ctl->status >> pos) & 0x01);
2286} 2354}
2287 2355
2288static int sony_nc_lid_resume_setup(struct platform_device *pd) 2356static int sony_nc_lid_resume_setup(struct platform_device *pd,
2357 unsigned int handle)
2289{ 2358{
2290 unsigned int result; 2359 unsigned int result;
2291 int i; 2360 int i;
2292 2361
2293 if (sony_call_snc_handle(0x0119, 0x0000, &result)) 2362 if (sony_call_snc_handle(handle, 0x0000, &result))
2294 return -EIO; 2363 return -EIO;
2295 2364
2296 lid_ctl = kzalloc(sizeof(struct snc_lid_resume_control), GFP_KERNEL); 2365 lid_ctl = kzalloc(sizeof(struct snc_lid_resume_control), GFP_KERNEL);
@@ -2298,26 +2367,29 @@ static int sony_nc_lid_resume_setup(struct platform_device *pd)
2298 return -ENOMEM; 2367 return -ENOMEM;
2299 2368
2300 lid_ctl->status = result & 0x7; 2369 lid_ctl->status = result & 0x7;
2370 lid_ctl->handle = handle;
2301 2371
2302 sysfs_attr_init(&lid_ctl->attrs[0].attr); 2372 sysfs_attr_init(&lid_ctl->attrs[0].attr);
2303 lid_ctl->attrs[0].attr.name = "lid_resume_S3"; 2373 lid_ctl->attrs[LID_RESUME_S5].attr.name = "lid_resume_S5";
2304 lid_ctl->attrs[0].attr.mode = S_IRUGO | S_IWUSR; 2374 lid_ctl->attrs[LID_RESUME_S5].attr.mode = S_IRUGO | S_IWUSR;
2305 lid_ctl->attrs[0].show = sony_nc_lid_resume_show; 2375 lid_ctl->attrs[LID_RESUME_S5].show = sony_nc_lid_resume_show;
2306 lid_ctl->attrs[0].store = sony_nc_lid_resume_store; 2376 lid_ctl->attrs[LID_RESUME_S5].store = sony_nc_lid_resume_store;
2307 2377
2308 sysfs_attr_init(&lid_ctl->attrs[1].attr); 2378 if (handle == 0x0119) {
2309 lid_ctl->attrs[1].attr.name = "lid_resume_S4"; 2379 sysfs_attr_init(&lid_ctl->attrs[1].attr);
2310 lid_ctl->attrs[1].attr.mode = S_IRUGO | S_IWUSR; 2380 lid_ctl->attrs[LID_RESUME_S4].attr.name = "lid_resume_S4";
2311 lid_ctl->attrs[1].show = sony_nc_lid_resume_show; 2381 lid_ctl->attrs[LID_RESUME_S4].attr.mode = S_IRUGO | S_IWUSR;
2312 lid_ctl->attrs[1].store = sony_nc_lid_resume_store; 2382 lid_ctl->attrs[LID_RESUME_S4].show = sony_nc_lid_resume_show;
2313 2383 lid_ctl->attrs[LID_RESUME_S4].store = sony_nc_lid_resume_store;
2314 sysfs_attr_init(&lid_ctl->attrs[2].attr); 2384
2315 lid_ctl->attrs[2].attr.name = "lid_resume_S5"; 2385 sysfs_attr_init(&lid_ctl->attrs[2].attr);
2316 lid_ctl->attrs[2].attr.mode = S_IRUGO | S_IWUSR; 2386 lid_ctl->attrs[LID_RESUME_S3].attr.name = "lid_resume_S3";
2317 lid_ctl->attrs[2].show = sony_nc_lid_resume_show; 2387 lid_ctl->attrs[LID_RESUME_S3].attr.mode = S_IRUGO | S_IWUSR;
2318 lid_ctl->attrs[2].store = sony_nc_lid_resume_store; 2388 lid_ctl->attrs[LID_RESUME_S3].show = sony_nc_lid_resume_show;
2319 2389 lid_ctl->attrs[LID_RESUME_S3].store = sony_nc_lid_resume_store;
2320 for (i = 0; i < 3; i++) { 2390 }
2391 for (i = 0; i < LID_RESUME_MAX &&
2392 lid_ctl->attrs[LID_RESUME_S3].attr.name; i++) {
2321 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]); 2393 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]);
2322 if (result) 2394 if (result)
2323 goto liderror; 2395 goto liderror;
@@ -2340,8 +2412,12 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
2340 int i; 2412 int i;
2341 2413
2342 if (lid_ctl) { 2414 if (lid_ctl) {
2343 for (i = 0; i < 3; i++) 2415 for (i = 0; i < LID_RESUME_MAX; i++) {
2416 if (!lid_ctl->attrs[i].attr.name)
2417 break;
2418
2344 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); 2419 device_remove_file(&pd->dev, &lid_ctl->attrs[i]);
2420 }
2345 2421
2346 kfree(lid_ctl); 2422 kfree(lid_ctl);
2347 lid_ctl = NULL; 2423 lid_ctl = NULL;
@@ -2524,6 +2600,355 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd)
2524 } 2600 }
2525} 2601}
2526 2602
2603/* low battery function */
2604static struct device_attribute *lowbatt_handle;
2605
2606static ssize_t sony_nc_lowbatt_store(struct device *dev,
2607 struct device_attribute *attr,
2608 const char *buffer, size_t count)
2609{
2610 unsigned int result;
2611 unsigned long value;
2612
2613 if (count > 31)
2614 return -EINVAL;
2615
2616 if (kstrtoul(buffer, 10, &value) || value > 1)
2617 return -EINVAL;
2618
2619 if (sony_call_snc_handle(0x0121, value << 8, &result))
2620 return -EIO;
2621
2622 return count;
2623}
2624
2625static ssize_t sony_nc_lowbatt_show(struct device *dev,
2626 struct device_attribute *attr, char *buffer)
2627{
2628 unsigned int result;
2629
2630 if (sony_call_snc_handle(0x0121, 0x0200, &result))
2631 return -EIO;
2632
2633 return snprintf(buffer, PAGE_SIZE, "%d\n", result & 1);
2634}
2635
2636static int sony_nc_lowbatt_setup(struct platform_device *pd)
2637{
2638 unsigned int result;
2639
2640 lowbatt_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2641 if (!lowbatt_handle)
2642 return -ENOMEM;
2643
2644 sysfs_attr_init(&lowbatt_handle->attr);
2645 lowbatt_handle->attr.name = "lowbatt_hibernate";
2646 lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR;
2647 lowbatt_handle->show = sony_nc_lowbatt_show;
2648 lowbatt_handle->store = sony_nc_lowbatt_store;
2649
2650 result = device_create_file(&pd->dev, lowbatt_handle);
2651 if (result) {
2652 kfree(lowbatt_handle);
2653 lowbatt_handle = NULL;
2654 return result;
2655 }
2656
2657 return 0;
2658}
2659
2660static void sony_nc_lowbatt_cleanup(struct platform_device *pd)
2661{
2662 if (lowbatt_handle) {
2663 device_remove_file(&pd->dev, lowbatt_handle);
2664 kfree(lowbatt_handle);
2665 lowbatt_handle = NULL;
2666 }
2667}
2668
2669/* fan speed function */
2670static struct device_attribute *fan_handle, *hsf_handle;
2671
2672static ssize_t sony_nc_hsfan_store(struct device *dev,
2673 struct device_attribute *attr,
2674 const char *buffer, size_t count)
2675{
2676 unsigned int result;
2677 unsigned long value;
2678
2679 if (count > 31)
2680 return -EINVAL;
2681
2682 if (kstrtoul(buffer, 10, &value) || value > 1)
2683 return -EINVAL;
2684
2685 if (sony_call_snc_handle(0x0149, value << 0x10 | 0x0200, &result))
2686 return -EIO;
2687
2688 return count;
2689}
2690
2691static ssize_t sony_nc_hsfan_show(struct device *dev,
2692 struct device_attribute *attr, char *buffer)
2693{
2694 unsigned int result;
2695
2696 if (sony_call_snc_handle(0x0149, 0x0100, &result))
2697 return -EIO;
2698
2699 return snprintf(buffer, PAGE_SIZE, "%d\n", result & 0x01);
2700}
2701
2702static ssize_t sony_nc_fanspeed_show(struct device *dev,
2703 struct device_attribute *attr, char *buffer)
2704{
2705 unsigned int result;
2706
2707 if (sony_call_snc_handle(0x0149, 0x0300, &result))
2708 return -EIO;
2709
2710 return snprintf(buffer, PAGE_SIZE, "%d\n", result & 0xff);
2711}
2712
2713static int sony_nc_fanspeed_setup(struct platform_device *pd)
2714{
2715 unsigned int result;
2716
2717 fan_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2718 if (!fan_handle)
2719 return -ENOMEM;
2720
2721 hsf_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2722 if (!hsf_handle) {
2723 result = -ENOMEM;
2724 goto out_hsf_handle_alloc;
2725 }
2726
2727 sysfs_attr_init(&fan_handle->attr);
2728 fan_handle->attr.name = "fanspeed";
2729 fan_handle->attr.mode = S_IRUGO;
2730 fan_handle->show = sony_nc_fanspeed_show;
2731 fan_handle->store = NULL;
2732
2733 sysfs_attr_init(&hsf_handle->attr);
2734 hsf_handle->attr.name = "fan_forced";
2735 hsf_handle->attr.mode = S_IRUGO | S_IWUSR;
2736 hsf_handle->show = sony_nc_hsfan_show;
2737 hsf_handle->store = sony_nc_hsfan_store;
2738
2739 result = device_create_file(&pd->dev, fan_handle);
2740 if (result)
2741 goto out_fan_handle;
2742
2743 result = device_create_file(&pd->dev, hsf_handle);
2744 if (result)
2745 goto out_hsf_handle;
2746
2747 return 0;
2748
2749out_hsf_handle:
2750 device_remove_file(&pd->dev, fan_handle);
2751
2752out_fan_handle:
2753 kfree(hsf_handle);
2754 hsf_handle = NULL;
2755
2756out_hsf_handle_alloc:
2757 kfree(fan_handle);
2758 fan_handle = NULL;
2759 return result;
2760}
2761
2762static void sony_nc_fanspeed_cleanup(struct platform_device *pd)
2763{
2764 if (fan_handle) {
2765 device_remove_file(&pd->dev, fan_handle);
2766 kfree(fan_handle);
2767 fan_handle = NULL;
2768 }
2769 if (hsf_handle) {
2770 device_remove_file(&pd->dev, hsf_handle);
2771 kfree(hsf_handle);
2772 hsf_handle = NULL;
2773 }
2774}
2775
2776/* USB charge function */
2777static struct device_attribute *uc_handle;
2778
2779static ssize_t sony_nc_usb_charge_store(struct device *dev,
2780 struct device_attribute *attr,
2781 const char *buffer, size_t count)
2782{
2783 unsigned int result;
2784 unsigned long value;
2785
2786 if (count > 31)
2787 return -EINVAL;
2788
2789 if (kstrtoul(buffer, 10, &value) || value > 1)
2790 return -EINVAL;
2791
2792 if (sony_call_snc_handle(0x0155, value << 0x10 | 0x0100, &result))
2793 return -EIO;
2794
2795 return count;
2796}
2797
2798static ssize_t sony_nc_usb_charge_show(struct device *dev,
2799 struct device_attribute *attr, char *buffer)
2800{
2801 unsigned int result;
2802
2803 if (sony_call_snc_handle(0x0155, 0x0000, &result))
2804 return -EIO;
2805
2806 return snprintf(buffer, PAGE_SIZE, "%d\n", result & 0x01);
2807}
2808
2809static int sony_nc_usb_charge_setup(struct platform_device *pd)
2810{
2811 unsigned int result;
2812
2813 if (sony_call_snc_handle(0x0155, 0x0000, &result) || !(result & 0x01)) {
2814 /* some models advertise the handle but have no implementation
2815 * for it
2816 */
2817 pr_info("No USB Charge capability found\n");
2818 return 0;
2819 }
2820
2821 uc_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2822 if (!uc_handle)
2823 return -ENOMEM;
2824
2825 sysfs_attr_init(&uc_handle->attr);
2826 uc_handle->attr.name = "usb_charge";
2827 uc_handle->attr.mode = S_IRUGO | S_IWUSR;
2828 uc_handle->show = sony_nc_usb_charge_show;
2829 uc_handle->store = sony_nc_usb_charge_store;
2830
2831 result = device_create_file(&pd->dev, uc_handle);
2832 if (result) {
2833 kfree(uc_handle);
2834 uc_handle = NULL;
2835 return result;
2836 }
2837
2838 return 0;
2839}
2840
2841static void sony_nc_usb_charge_cleanup(struct platform_device *pd)
2842{
2843 if (uc_handle) {
2844 device_remove_file(&pd->dev, uc_handle);
2845 kfree(uc_handle);
2846 uc_handle = NULL;
2847 }
2848}
2849
2850/* Panel ID function */
2851static struct device_attribute *panel_handle;
2852
2853static ssize_t sony_nc_panelid_show(struct device *dev,
2854 struct device_attribute *attr, char *buffer)
2855{
2856 unsigned int result;
2857
2858 if (sony_call_snc_handle(0x011D, 0x0000, &result))
2859 return -EIO;
2860
2861 return snprintf(buffer, PAGE_SIZE, "%d\n", result);
2862}
2863
2864static int sony_nc_panelid_setup(struct platform_device *pd)
2865{
2866 unsigned int result;
2867
2868 panel_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2869 if (!panel_handle)
2870 return -ENOMEM;
2871
2872 sysfs_attr_init(&panel_handle->attr);
2873 panel_handle->attr.name = "panel_id";
2874 panel_handle->attr.mode = S_IRUGO;
2875 panel_handle->show = sony_nc_panelid_show;
2876 panel_handle->store = NULL;
2877
2878 result = device_create_file(&pd->dev, panel_handle);
2879 if (result) {
2880 kfree(panel_handle);
2881 panel_handle = NULL;
2882 return result;
2883 }
2884
2885 return 0;
2886}
2887
2888static void sony_nc_panelid_cleanup(struct platform_device *pd)
2889{
2890 if (panel_handle) {
2891 device_remove_file(&pd->dev, panel_handle);
2892 kfree(panel_handle);
2893 panel_handle = NULL;
2894 }
2895}
2896
2897/* smart connect function */
2898static struct device_attribute *sc_handle;
2899
2900static ssize_t sony_nc_smart_conn_store(struct device *dev,
2901 struct device_attribute *attr,
2902 const char *buffer, size_t count)
2903{
2904 unsigned int result;
2905 unsigned long value;
2906
2907 if (count > 31)
2908 return -EINVAL;
2909
2910 if (kstrtoul(buffer, 10, &value) || value > 1)
2911 return -EINVAL;
2912
2913 if (sony_call_snc_handle(0x0168, value << 0x10, &result))
2914 return -EIO;
2915
2916 return count;
2917}
2918
2919static int sony_nc_smart_conn_setup(struct platform_device *pd)
2920{
2921 unsigned int result;
2922
2923 sc_handle = kzalloc(sizeof(struct device_attribute), GFP_KERNEL);
2924 if (!sc_handle)
2925 return -ENOMEM;
2926
2927 sysfs_attr_init(&sc_handle->attr);
2928 sc_handle->attr.name = "smart_connect";
2929 sc_handle->attr.mode = S_IWUSR;
2930 sc_handle->show = NULL;
2931 sc_handle->store = sony_nc_smart_conn_store;
2932
2933 result = device_create_file(&pd->dev, sc_handle);
2934 if (result) {
2935 kfree(sc_handle);
2936 sc_handle = NULL;
2937 return result;
2938 }
2939
2940 return 0;
2941}
2942
2943static void sony_nc_smart_conn_cleanup(struct platform_device *pd)
2944{
2945 if (sc_handle) {
2946 device_remove_file(&pd->dev, sc_handle);
2947 kfree(sc_handle);
2948 sc_handle = NULL;
2949 }
2950}
2951
2527/* Touchpad enable/disable */ 2952/* Touchpad enable/disable */
2528struct touchpad_control { 2953struct touchpad_control {
2529 struct device_attribute attr; 2954 struct device_attribute attr;
@@ -2726,8 +3151,6 @@ static int sony_nc_add(struct acpi_device *device)
2726 int result = 0; 3151 int result = 0;
2727 struct sony_nc_value *item; 3152 struct sony_nc_value *item;
2728 3153
2729 pr_info("%s v%s\n", SONY_NC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
2730
2731 sony_nc_acpi_device = device; 3154 sony_nc_acpi_device = device;
2732 strcpy(acpi_device_class(device), "sony/hotkey"); 3155 strcpy(acpi_device_class(device), "sony/hotkey");
2733 3156
@@ -2821,6 +3244,7 @@ static int sony_nc_add(struct acpi_device *device)
2821 } 3244 }
2822 } 3245 }
2823 3246
3247 pr_info("SNC setup done.\n");
2824 return 0; 3248 return 0;
2825 3249
2826out_sysfs: 3250out_sysfs:
@@ -4259,8 +4683,6 @@ static int sony_pic_add(struct acpi_device *device)
4259 struct sony_pic_ioport *io, *tmp_io; 4683 struct sony_pic_ioport *io, *tmp_io;
4260 struct sony_pic_irq *irq, *tmp_irq; 4684 struct sony_pic_irq *irq, *tmp_irq;
4261 4685
4262 pr_info("%s v%s\n", SONY_PIC_DRIVER_NAME, SONY_LAPTOP_DRIVER_VERSION);
4263
4264 spic_dev.acpi_dev = device; 4686 spic_dev.acpi_dev = device;
4265 strcpy(acpi_device_class(device), "sony/hotkey"); 4687 strcpy(acpi_device_class(device), "sony/hotkey");
4266 sony_pic_detect_device_type(&spic_dev); 4688 sony_pic_detect_device_type(&spic_dev);
@@ -4360,6 +4782,7 @@ static int sony_pic_add(struct acpi_device *device)
4360 if (result) 4782 if (result)
4361 goto err_remove_pf; 4783 goto err_remove_pf;
4362 4784
4785 pr_info("SPIC setup done.\n");
4363 return 0; 4786 return 0;
4364 4787
4365err_remove_pf: 4788err_remove_pf:
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 94bb6157c957..15e61c16736e 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2321,53 +2321,55 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
2321 } 2321 }
2322} 2322}
2323 2323
2324static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2325 struct tp_nvram_state *newn,
2326 const u32 event_mask)
2327{
2328
2329#define TPACPI_COMPARE_KEY(__scancode, __member) \ 2324#define TPACPI_COMPARE_KEY(__scancode, __member) \
2330 do { \ 2325do { \
2331 if ((event_mask & (1 << __scancode)) && \ 2326 if ((event_mask & (1 << __scancode)) && \
2332 oldn->__member != newn->__member) \ 2327 oldn->__member != newn->__member) \
2333 tpacpi_hotkey_send_key(__scancode); \ 2328 tpacpi_hotkey_send_key(__scancode); \
2334 } while (0) 2329} while (0)
2335 2330
2336#define TPACPI_MAY_SEND_KEY(__scancode) \ 2331#define TPACPI_MAY_SEND_KEY(__scancode) \
2337 do { \ 2332do { \
2338 if (event_mask & (1 << __scancode)) \ 2333 if (event_mask & (1 << __scancode)) \
2339 tpacpi_hotkey_send_key(__scancode); \ 2334 tpacpi_hotkey_send_key(__scancode); \
2340 } while (0) 2335} while (0)
2341 2336
2342 void issue_volchange(const unsigned int oldvol, 2337static void issue_volchange(const unsigned int oldvol,
2343 const unsigned int newvol) 2338 const unsigned int newvol,
2344 { 2339 const u32 event_mask)
2345 unsigned int i = oldvol; 2340{
2341 unsigned int i = oldvol;
2346 2342
2347 while (i > newvol) { 2343 while (i > newvol) {
2348 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN); 2344 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
2349 i--; 2345 i--;
2350 } 2346 }
2351 while (i < newvol) { 2347 while (i < newvol) {
2352 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP); 2348 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
2353 i++; 2349 i++;
2354 }
2355 } 2350 }
2351}
2356 2352
2357 void issue_brightnesschange(const unsigned int oldbrt, 2353static void issue_brightnesschange(const unsigned int oldbrt,
2358 const unsigned int newbrt) 2354 const unsigned int newbrt,
2359 { 2355 const u32 event_mask)
2360 unsigned int i = oldbrt; 2356{
2357 unsigned int i = oldbrt;
2361 2358
2362 while (i > newbrt) { 2359 while (i > newbrt) {
2363 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND); 2360 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
2364 i--; 2361 i--;
2365 }
2366 while (i < newbrt) {
2367 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
2368 i++;
2369 }
2370 } 2362 }
2363 while (i < newbrt) {
2364 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
2365 i++;
2366 }
2367}
2368
2369static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2370 struct tp_nvram_state *newn,
2371 const u32 event_mask)
2372{
2371 2373
2372 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle); 2374 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
2373 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle); 2375 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
@@ -2402,7 +2404,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2402 oldn->volume_level != newn->volume_level) { 2404 oldn->volume_level != newn->volume_level) {
2403 /* recently muted, or repeated mute keypress, or 2405 /* recently muted, or repeated mute keypress, or
2404 * multiple presses ending in mute */ 2406 * multiple presses ending in mute */
2405 issue_volchange(oldn->volume_level, newn->volume_level); 2407 issue_volchange(oldn->volume_level, newn->volume_level,
2408 event_mask);
2406 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE); 2409 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
2407 } 2410 }
2408 } else { 2411 } else {
@@ -2412,7 +2415,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2412 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP); 2415 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
2413 } 2416 }
2414 if (oldn->volume_level != newn->volume_level) { 2417 if (oldn->volume_level != newn->volume_level) {
2415 issue_volchange(oldn->volume_level, newn->volume_level); 2418 issue_volchange(oldn->volume_level, newn->volume_level,
2419 event_mask);
2416 } else if (oldn->volume_toggle != newn->volume_toggle) { 2420 } else if (oldn->volume_toggle != newn->volume_toggle) {
2417 /* repeated vol up/down keypress at end of scale ? */ 2421 /* repeated vol up/down keypress at end of scale ? */
2418 if (newn->volume_level == 0) 2422 if (newn->volume_level == 0)
@@ -2425,7 +2429,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
2425 /* handle brightness */ 2429 /* handle brightness */
2426 if (oldn->brightness_level != newn->brightness_level) { 2430 if (oldn->brightness_level != newn->brightness_level) {
2427 issue_brightnesschange(oldn->brightness_level, 2431 issue_brightnesschange(oldn->brightness_level,
2428 newn->brightness_level); 2432 newn->brightness_level, event_mask);
2429 } else if (oldn->brightness_toggle != newn->brightness_toggle) { 2433 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
2430 /* repeated key presses that didn't change state */ 2434 /* repeated key presses that didn't change state */
2431 if (newn->brightness_level == 0) 2435 if (newn->brightness_level == 0)
@@ -3437,6 +3441,106 @@ err_exit:
3437 return (res < 0)? res : 1; 3441 return (res < 0)? res : 1;
3438} 3442}
3439 3443
3444/* Thinkpad X1 Carbon support 5 modes including Home mode, Web browser
3445 * mode, Web conference mode, Function mode and Lay-flat mode.
3446 * We support Home mode and Function mode currently.
3447 *
3448 * Will consider support rest of modes in future.
3449 *
3450 */
3451enum ADAPTIVE_KEY_MODE {
3452 HOME_MODE,
3453 WEB_BROWSER_MODE,
3454 WEB_CONFERENCE_MODE,
3455 FUNCTION_MODE,
3456 LAYFLAT_MODE
3457};
3458
3459const int adaptive_keyboard_modes[] = {
3460 HOME_MODE,
3461/* WEB_BROWSER_MODE = 2,
3462 WEB_CONFERENCE_MODE = 3, */
3463 FUNCTION_MODE
3464};
3465
3466#define DFR_CHANGE_ROW 0x101
3467#define DFR_SHOW_QUICKVIEW_ROW 0x102
3468
3469/* press Fn key a while second, it will switch to Function Mode. Then
3470 * release Fn key, previous mode be restored.
3471 */
3472static bool adaptive_keyboard_mode_is_saved;
3473static int adaptive_keyboard_prev_mode;
3474
3475static int adaptive_keyboard_get_next_mode(int mode)
3476{
3477 size_t i;
3478 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1;
3479
3480 for (i = 0; i <= max_mode; i++) {
3481 if (adaptive_keyboard_modes[i] == mode)
3482 break;
3483 }
3484
3485 if (i >= max_mode)
3486 i = 0;
3487 else
3488 i++;
3489
3490 return adaptive_keyboard_modes[i];
3491}
3492
3493static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
3494{
3495 u32 current_mode = 0;
3496 int new_mode = 0;
3497
3498 switch (scancode) {
3499 case DFR_CHANGE_ROW:
3500 if (adaptive_keyboard_mode_is_saved) {
3501 new_mode = adaptive_keyboard_prev_mode;
3502 adaptive_keyboard_mode_is_saved = false;
3503 } else {
3504 if (!acpi_evalf(
3505 hkey_handle, &current_mode,
3506 "GTRW", "dd", 0)) {
3507 pr_err("Cannot read adaptive keyboard mode\n");
3508 return false;
3509 } else {
3510 new_mode = adaptive_keyboard_get_next_mode(
3511 current_mode);
3512 }
3513 }
3514
3515 if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd", new_mode)) {
3516 pr_err("Cannot set adaptive keyboard mode\n");
3517 return false;
3518 }
3519
3520 return true;
3521
3522 case DFR_SHOW_QUICKVIEW_ROW:
3523 if (!acpi_evalf(hkey_handle,
3524 &adaptive_keyboard_prev_mode,
3525 "GTRW", "dd", 0)) {
3526 pr_err("Cannot read adaptive keyboard mode\n");
3527 return false;
3528 } else {
3529 adaptive_keyboard_mode_is_saved = true;
3530
3531 if (!acpi_evalf(hkey_handle,
3532 NULL, "STRW", "vd", FUNCTION_MODE)) {
3533 pr_err("Cannot set adaptive keyboard mode\n");
3534 return false;
3535 }
3536 }
3537 return true;
3538
3539 default:
3540 return false;
3541 }
3542}
3543
3440static bool hotkey_notify_hotkey(const u32 hkey, 3544static bool hotkey_notify_hotkey(const u32 hkey,
3441 bool *send_acpi_ev, 3545 bool *send_acpi_ev,
3442 bool *ignore_acpi_ev) 3546 bool *ignore_acpi_ev)
@@ -3456,6 +3560,8 @@ static bool hotkey_notify_hotkey(const u32 hkey,
3456 *ignore_acpi_ev = true; 3560 *ignore_acpi_ev = true;
3457 } 3561 }
3458 return true; 3562 return true;
3563 } else {
3564 return adaptive_keyboard_hotkey_notify_hotkey(scancode);
3459 } 3565 }
3460 return false; 3566 return false;
3461} 3567}
@@ -3728,13 +3834,28 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
3728 3834
3729static void hotkey_suspend(void) 3835static void hotkey_suspend(void)
3730{ 3836{
3837 int hkeyv;
3838
3731 /* Do these on suspend, we get the events on early resume! */ 3839 /* Do these on suspend, we get the events on early resume! */
3732 hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE; 3840 hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE;
3733 hotkey_autosleep_ack = 0; 3841 hotkey_autosleep_ack = 0;
3842
3843 /* save previous mode of adaptive keyboard of X1 Carbon */
3844 if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
3845 if ((hkeyv >> 8) == 2) {
3846 if (!acpi_evalf(hkey_handle,
3847 &adaptive_keyboard_prev_mode,
3848 "GTRW", "dd", 0)) {
3849 pr_err("Cannot read adaptive keyboard mode.\n");
3850 }
3851 }
3852 }
3734} 3853}
3735 3854
3736static void hotkey_resume(void) 3855static void hotkey_resume(void)
3737{ 3856{
3857 int hkeyv;
3858
3738 tpacpi_disable_brightness_delay(); 3859 tpacpi_disable_brightness_delay();
3739 3860
3740 if (hotkey_status_set(true) < 0 || 3861 if (hotkey_status_set(true) < 0 ||
@@ -3747,6 +3868,18 @@ static void hotkey_resume(void)
3747 hotkey_wakeup_reason_notify_change(); 3868 hotkey_wakeup_reason_notify_change();
3748 hotkey_wakeup_hotunplug_complete_notify_change(); 3869 hotkey_wakeup_hotunplug_complete_notify_change();
3749 hotkey_poll_setup_safe(false); 3870 hotkey_poll_setup_safe(false);
3871
3872 /* restore previous mode of adapive keyboard of X1 Carbon */
3873 if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
3874 if ((hkeyv >> 8) == 2) {
3875 if (!acpi_evalf(hkey_handle,
3876 NULL,
3877 "STRW", "vd",
3878 adaptive_keyboard_prev_mode)) {
3879 pr_err("Cannot set adaptive keyboard mode.\n");
3880 }
3881 }
3882 }
3750} 3883}
3751 3884
3752/* procfs -------------------------------------------------------------- */ 3885/* procfs -------------------------------------------------------------- */
@@ -8447,9 +8580,21 @@ static void mute_led_exit(void)
8447 tpacpi_led_set(i, false); 8580 tpacpi_led_set(i, false);
8448} 8581}
8449 8582
8583static void mute_led_resume(void)
8584{
8585 int i;
8586
8587 for (i = 0; i < TPACPI_LED_MAX; i++) {
8588 struct tp_led_table *t = &led_tables[i];
8589 if (t->state >= 0)
8590 mute_led_on_off(t, t->state);
8591 }
8592}
8593
8450static struct ibm_struct mute_led_driver_data = { 8594static struct ibm_struct mute_led_driver_data = {
8451 .name = "mute_led", 8595 .name = "mute_led",
8452 .exit = mute_led_exit, 8596 .exit = mute_led_exit,
8597 .resume = mute_led_resume,
8453}; 8598};
8454 8599
8455/**************************************************************************** 8600/****************************************************************************
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 90dd7645a9e5..46473ca7566b 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -5,6 +5,7 @@
5 * Copyright (C) 2002-2004 John Belmonte 5 * Copyright (C) 2002-2004 John Belmonte
6 * Copyright (C) 2008 Philip Langdale 6 * Copyright (C) 2008 Philip Langdale
7 * Copyright (C) 2010 Pierre Ducroquet 7 * Copyright (C) 2010 Pierre Ducroquet
8 * Copyright (C) 2014 Azael Avalos
8 * 9 *
9 * 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
10 * 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
@@ -37,7 +38,7 @@
37 38
38#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 39#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
39 40
40#define TOSHIBA_ACPI_VERSION "0.19" 41#define TOSHIBA_ACPI_VERSION "0.20"
41#define PROC_INTERFACE_VERSION 1 42#define PROC_INTERFACE_VERSION 1
42 43
43#include <linux/kernel.h> 44#include <linux/kernel.h>
@@ -77,6 +78,9 @@ MODULE_LICENSE("GPL");
77 * However the ACPI methods seem to be incomplete in some areas (for 78 * However the ACPI methods seem to be incomplete in some areas (for
78 * example they allow setting, but not reading, the LCD brightness value), 79 * example they allow setting, but not reading, the LCD brightness value),
79 * so this is still useful. 80 * so this is still useful.
81 *
82 * SCI stands for "System Configuration Interface" which aim is to
83 * conceal differences in hardware between different models.
80 */ 84 */
81 85
82#define HCI_WORDS 6 86#define HCI_WORDS 6
@@ -84,12 +88,23 @@ MODULE_LICENSE("GPL");
84/* operations */ 88/* operations */
85#define HCI_SET 0xff00 89#define HCI_SET 0xff00
86#define HCI_GET 0xfe00 90#define HCI_GET 0xfe00
91#define SCI_OPEN 0xf100
92#define SCI_CLOSE 0xf200
93#define SCI_GET 0xf300
94#define SCI_SET 0xf400
87 95
88/* return codes */ 96/* return codes */
89#define HCI_SUCCESS 0x0000 97#define HCI_SUCCESS 0x0000
90#define HCI_FAILURE 0x1000 98#define HCI_FAILURE 0x1000
91#define HCI_NOT_SUPPORTED 0x8000 99#define HCI_NOT_SUPPORTED 0x8000
92#define HCI_EMPTY 0x8c00 100#define HCI_EMPTY 0x8c00
101#define HCI_DATA_NOT_AVAILABLE 0x8d20
102#define HCI_NOT_INITIALIZED 0x8d50
103#define SCI_OPEN_CLOSE_OK 0x0044
104#define SCI_ALREADY_OPEN 0x8100
105#define SCI_NOT_OPENED 0x8200
106#define SCI_INPUT_DATA_ERROR 0x8300
107#define SCI_NOT_PRESENT 0x8600
93 108
94/* registers */ 109/* registers */
95#define HCI_FAN 0x0004 110#define HCI_FAN 0x0004
@@ -99,13 +114,22 @@ MODULE_LICENSE("GPL");
99#define HCI_HOTKEY_EVENT 0x001e 114#define HCI_HOTKEY_EVENT 0x001e
100#define HCI_LCD_BRIGHTNESS 0x002a 115#define HCI_LCD_BRIGHTNESS 0x002a
101#define HCI_WIRELESS 0x0056 116#define HCI_WIRELESS 0x0056
117#define HCI_ACCELEROMETER 0x006d
118#define HCI_KBD_ILLUMINATION 0x0095
119#define HCI_ECO_MODE 0x0097
120#define HCI_ACCELEROMETER2 0x00a6
121#define SCI_ILLUMINATION 0x014e
122#define SCI_KBD_ILLUM_STATUS 0x015c
123#define SCI_TOUCHPAD 0x050e
102 124
103/* field definitions */ 125/* field definitions */
126#define HCI_ACCEL_MASK 0x7fff
104#define HCI_HOTKEY_DISABLE 0x0b 127#define HCI_HOTKEY_DISABLE 0x0b
105#define HCI_HOTKEY_ENABLE 0x09 128#define HCI_HOTKEY_ENABLE 0x09
106#define HCI_LCD_BRIGHTNESS_BITS 3 129#define HCI_LCD_BRIGHTNESS_BITS 3
107#define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS) 130#define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
108#define HCI_LCD_BRIGHTNESS_LEVELS (1 << HCI_LCD_BRIGHTNESS_BITS) 131#define HCI_LCD_BRIGHTNESS_LEVELS (1 << HCI_LCD_BRIGHTNESS_BITS)
132#define HCI_MISC_SHIFT 0x10
109#define HCI_VIDEO_OUT_LCD 0x1 133#define HCI_VIDEO_OUT_LCD 0x1
110#define HCI_VIDEO_OUT_CRT 0x2 134#define HCI_VIDEO_OUT_CRT 0x2
111#define HCI_VIDEO_OUT_TV 0x4 135#define HCI_VIDEO_OUT_TV 0x4
@@ -113,6 +137,8 @@ MODULE_LICENSE("GPL");
113#define HCI_WIRELESS_BT_PRESENT 0x0f 137#define HCI_WIRELESS_BT_PRESENT 0x0f
114#define HCI_WIRELESS_BT_ATTACH 0x40 138#define HCI_WIRELESS_BT_ATTACH 0x40
115#define HCI_WIRELESS_BT_POWER 0x80 139#define HCI_WIRELESS_BT_POWER 0x80
140#define SCI_KBD_MODE_FNZ 0x1
141#define SCI_KBD_MODE_AUTO 0x2
116 142
117struct toshiba_acpi_dev { 143struct toshiba_acpi_dev {
118 struct acpi_device *acpi_dev; 144 struct acpi_device *acpi_dev;
@@ -122,10 +148,14 @@ struct toshiba_acpi_dev {
122 struct work_struct hotkey_work; 148 struct work_struct hotkey_work;
123 struct backlight_device *backlight_dev; 149 struct backlight_device *backlight_dev;
124 struct led_classdev led_dev; 150 struct led_classdev led_dev;
151 struct led_classdev kbd_led;
152 struct led_classdev eco_led;
125 153
126 int force_fan; 154 int force_fan;
127 int last_key_event; 155 int last_key_event;
128 int key_event_valid; 156 int key_event_valid;
157 int kbd_mode;
158 int kbd_time;
129 159
130 unsigned int illumination_supported:1; 160 unsigned int illumination_supported:1;
131 unsigned int video_supported:1; 161 unsigned int video_supported:1;
@@ -134,6 +164,12 @@ struct toshiba_acpi_dev {
134 unsigned int ntfy_supported:1; 164 unsigned int ntfy_supported:1;
135 unsigned int info_supported:1; 165 unsigned int info_supported:1;
136 unsigned int tr_backlight_supported:1; 166 unsigned int tr_backlight_supported:1;
167 unsigned int kbd_illum_supported:1;
168 unsigned int kbd_led_registered:1;
169 unsigned int touchpad_supported:1;
170 unsigned int eco_supported:1;
171 unsigned int accelerometer_supported:1;
172 unsigned int sysfs_created:1;
137 173
138 struct mutex mutex; 174 struct mutex mutex;
139}; 175};
@@ -280,21 +316,94 @@ static acpi_status hci_read2(struct toshiba_acpi_dev *dev, u32 reg,
280 return status; 316 return status;
281} 317}
282 318
319/* common sci tasks
320 */
321
322static int sci_open(struct toshiba_acpi_dev *dev)
323{
324 u32 in[HCI_WORDS] = { SCI_OPEN, 0, 0, 0, 0, 0 };
325 u32 out[HCI_WORDS];
326 acpi_status status;
327
328 status = hci_raw(dev, in, out);
329 if (ACPI_FAILURE(status) || out[0] == HCI_FAILURE) {
330 pr_err("ACPI call to open SCI failed\n");
331 return 0;
332 }
333
334 if (out[0] == SCI_OPEN_CLOSE_OK) {
335 return 1;
336 } else if (out[0] == SCI_ALREADY_OPEN) {
337 pr_info("Toshiba SCI already opened\n");
338 return 1;
339 } else if (out[0] == SCI_NOT_PRESENT) {
340 pr_info("Toshiba SCI is not present\n");
341 }
342
343 return 0;
344}
345
346static void sci_close(struct toshiba_acpi_dev *dev)
347{
348 u32 in[HCI_WORDS] = { SCI_CLOSE, 0, 0, 0, 0, 0 };
349 u32 out[HCI_WORDS];
350 acpi_status status;
351
352 status = hci_raw(dev, in, out);
353 if (ACPI_FAILURE(status) || out[0] == HCI_FAILURE) {
354 pr_err("ACPI call to close SCI failed\n");
355 return;
356 }
357
358 if (out[0] == SCI_OPEN_CLOSE_OK)
359 return;
360 else if (out[0] == SCI_NOT_OPENED)
361 pr_info("Toshiba SCI not opened\n");
362 else if (out[0] == SCI_NOT_PRESENT)
363 pr_info("Toshiba SCI is not present\n");
364}
365
366static acpi_status sci_read(struct toshiba_acpi_dev *dev, u32 reg,
367 u32 *out1, u32 *result)
368{
369 u32 in[HCI_WORDS] = { SCI_GET, reg, 0, 0, 0, 0 };
370 u32 out[HCI_WORDS];
371 acpi_status status = hci_raw(dev, in, out);
372 *out1 = out[2];
373 *result = (ACPI_SUCCESS(status)) ? out[0] : HCI_FAILURE;
374 return status;
375}
376
377static acpi_status sci_write(struct toshiba_acpi_dev *dev, u32 reg,
378 u32 in1, u32 *result)
379{
380 u32 in[HCI_WORDS] = { SCI_SET, reg, in1, 0, 0, 0 };
381 u32 out[HCI_WORDS];
382 acpi_status status = hci_raw(dev, in, out);
383 *result = (ACPI_SUCCESS(status)) ? out[0] : HCI_FAILURE;
384 return status;
385}
386
283/* Illumination support */ 387/* Illumination support */
284static int toshiba_illumination_available(struct toshiba_acpi_dev *dev) 388static int toshiba_illumination_available(struct toshiba_acpi_dev *dev)
285{ 389{
286 u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 }; 390 u32 in[HCI_WORDS] = { SCI_GET, SCI_ILLUMINATION, 0, 0, 0, 0 };
287 u32 out[HCI_WORDS]; 391 u32 out[HCI_WORDS];
288 acpi_status status; 392 acpi_status status;
289 393
290 in[0] = 0xf100; 394 if (!sci_open(dev))
395 return 0;
396
291 status = hci_raw(dev, in, out); 397 status = hci_raw(dev, in, out);
292 if (ACPI_FAILURE(status)) { 398 sci_close(dev);
399 if (ACPI_FAILURE(status) || out[0] == HCI_FAILURE) {
400 pr_err("ACPI call to query Illumination support failed\n");
401 return 0;
402 } else if (out[0] == HCI_NOT_SUPPORTED || out[1] != 1) {
293 pr_info("Illumination device not available\n"); 403 pr_info("Illumination device not available\n");
294 return 0; 404 return 0;
295 } 405 }
296 in[0] = 0xf400; 406
297 status = hci_raw(dev, in, out);
298 return 1; 407 return 1;
299} 408}
300 409
@@ -303,82 +412,270 @@ static void toshiba_illumination_set(struct led_classdev *cdev,
303{ 412{
304 struct toshiba_acpi_dev *dev = container_of(cdev, 413 struct toshiba_acpi_dev *dev = container_of(cdev,
305 struct toshiba_acpi_dev, led_dev); 414 struct toshiba_acpi_dev, led_dev);
306 u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 }; 415 u32 state, result;
307 u32 out[HCI_WORDS];
308 acpi_status status; 416 acpi_status status;
309 417
310 /* First request : initialize communication. */ 418 /* First request : initialize communication. */
311 in[0] = 0xf100; 419 if (!sci_open(dev))
312 status = hci_raw(dev, in, out); 420 return;
421
422 /* Switch the illumination on/off */
423 state = brightness ? 1 : 0;
424 status = sci_write(dev, SCI_ILLUMINATION, state, &result);
425 sci_close(dev);
313 if (ACPI_FAILURE(status)) { 426 if (ACPI_FAILURE(status)) {
314 pr_info("Illumination device not available\n"); 427 pr_err("ACPI call for illumination failed\n");
428 return;
429 } else if (result == HCI_NOT_SUPPORTED) {
430 pr_info("Illumination not supported\n");
315 return; 431 return;
316 } 432 }
433}
317 434
318 if (brightness) { 435static enum led_brightness toshiba_illumination_get(struct led_classdev *cdev)
319 /* Switch the illumination on */ 436{
320 in[0] = 0xf400; 437 struct toshiba_acpi_dev *dev = container_of(cdev,
321 in[1] = 0x14e; 438 struct toshiba_acpi_dev, led_dev);
322 in[2] = 1; 439 u32 state, result;
323 status = hci_raw(dev, in, out); 440 acpi_status status;
324 if (ACPI_FAILURE(status)) { 441
325 pr_info("ACPI call for illumination failed\n"); 442 /* First request : initialize communication. */
326 return; 443 if (!sci_open(dev))
327 } 444 return LED_OFF;
328 } else { 445
329 /* Switch the illumination off */ 446 /* Check the illumination */
330 in[0] = 0xf400; 447 status = sci_read(dev, SCI_ILLUMINATION, &state, &result);
331 in[1] = 0x14e; 448 sci_close(dev);
332 in[2] = 0; 449 if (ACPI_FAILURE(status) || result == SCI_INPUT_DATA_ERROR) {
333 status = hci_raw(dev, in, out); 450 pr_err("ACPI call for illumination failed\n");
334 if (ACPI_FAILURE(status)) { 451 return LED_OFF;
335 pr_info("ACPI call for illumination failed.\n"); 452 } else if (result == HCI_NOT_SUPPORTED) {
336 return; 453 pr_info("Illumination not supported\n");
337 } 454 return LED_OFF;
338 } 455 }
339 456
340 /* Last request : close communication. */ 457 return state ? LED_FULL : LED_OFF;
341 in[0] = 0xf200;
342 in[1] = 0;
343 in[2] = 0;
344 hci_raw(dev, in, out);
345} 458}
346 459
347static enum led_brightness toshiba_illumination_get(struct led_classdev *cdev) 460/* KBD Illumination */
461static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev *dev, u32 time)
462{
463 u32 result;
464 acpi_status status;
465
466 if (!sci_open(dev))
467 return -EIO;
468
469 status = sci_write(dev, SCI_KBD_ILLUM_STATUS, time, &result);
470 sci_close(dev);
471 if (ACPI_FAILURE(status) || result == SCI_INPUT_DATA_ERROR) {
472 pr_err("ACPI call to set KBD backlight status failed\n");
473 return -EIO;
474 } else if (result == HCI_NOT_SUPPORTED) {
475 pr_info("Keyboard backlight status not supported\n");
476 return -ENODEV;
477 }
478
479 return 0;
480}
481
482static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev *dev, u32 *time)
483{
484 u32 result;
485 acpi_status status;
486
487 if (!sci_open(dev))
488 return -EIO;
489
490 status = sci_read(dev, SCI_KBD_ILLUM_STATUS, time, &result);
491 sci_close(dev);
492 if (ACPI_FAILURE(status) || result == SCI_INPUT_DATA_ERROR) {
493 pr_err("ACPI call to get KBD backlight status failed\n");
494 return -EIO;
495 } else if (result == HCI_NOT_SUPPORTED) {
496 pr_info("Keyboard backlight status not supported\n");
497 return -ENODEV;
498 }
499
500 return 0;
501}
502
503static enum led_brightness toshiba_kbd_backlight_get(struct led_classdev *cdev)
348{ 504{
349 struct toshiba_acpi_dev *dev = container_of(cdev, 505 struct toshiba_acpi_dev *dev = container_of(cdev,
350 struct toshiba_acpi_dev, led_dev); 506 struct toshiba_acpi_dev, kbd_led);
351 u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 }; 507 u32 state, result;
508 acpi_status status;
509
510 /* Check the keyboard backlight state */
511 status = hci_read1(dev, HCI_KBD_ILLUMINATION, &state, &result);
512 if (ACPI_FAILURE(status) || result == SCI_INPUT_DATA_ERROR) {
513 pr_err("ACPI call to get the keyboard backlight failed\n");
514 return LED_OFF;
515 } else if (result == HCI_NOT_SUPPORTED) {
516 pr_info("Keyboard backlight not supported\n");
517 return LED_OFF;
518 }
519
520 return state ? LED_FULL : LED_OFF;
521}
522
523static void toshiba_kbd_backlight_set(struct led_classdev *cdev,
524 enum led_brightness brightness)
525{
526 struct toshiba_acpi_dev *dev = container_of(cdev,
527 struct toshiba_acpi_dev, kbd_led);
528 u32 state, result;
529 acpi_status status;
530
531 /* Set the keyboard backlight state */
532 state = brightness ? 1 : 0;
533 status = hci_write1(dev, HCI_KBD_ILLUMINATION, state, &result);
534 if (ACPI_FAILURE(status) || result == SCI_INPUT_DATA_ERROR) {
535 pr_err("ACPI call to set KBD Illumination mode failed\n");
536 return;
537 } else if (result == HCI_NOT_SUPPORTED) {
538 pr_info("Keyboard backlight not supported\n");
539 return;
540 }
541}
542
543/* TouchPad support */
544static int toshiba_touchpad_set(struct toshiba_acpi_dev *dev, u32 state)
545{
546 u32 result;
547 acpi_status status;
548
549 if (!sci_open(dev))
550 return -EIO;
551
552 status = sci_write(dev, SCI_TOUCHPAD, state, &result);
553 sci_close(dev);
554 if (ACPI_FAILURE(status)) {
555 pr_err("ACPI call to set the touchpad failed\n");
556 return -EIO;
557 } else if (result == HCI_NOT_SUPPORTED) {
558 return -ENODEV;
559 }
560
561 return 0;
562}
563
564static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state)
565{
566 u32 result;
567 acpi_status status;
568
569 if (!sci_open(dev))
570 return -EIO;
571
572 status = sci_read(dev, SCI_TOUCHPAD, state, &result);
573 sci_close(dev);
574 if (ACPI_FAILURE(status)) {
575 pr_err("ACPI call to query the touchpad failed\n");
576 return -EIO;
577 } else if (result == HCI_NOT_SUPPORTED) {
578 return -ENODEV;
579 }
580
581 return 0;
582}
583
584/* Eco Mode support */
585static int toshiba_eco_mode_available(struct toshiba_acpi_dev *dev)
586{
587 acpi_status status;
588 u32 in[HCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 1, 0, 0 };
589 u32 out[HCI_WORDS];
590
591 status = hci_raw(dev, in, out);
592 if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
593 pr_info("ACPI call to get ECO led failed\n");
594 return 0;
595 }
596
597 return 1;
598}
599
600static enum led_brightness toshiba_eco_mode_get_status(struct led_classdev *cdev)
601{
602 struct toshiba_acpi_dev *dev = container_of(cdev,
603 struct toshiba_acpi_dev, eco_led);
604 u32 in[HCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 1, 0, 0 };
352 u32 out[HCI_WORDS]; 605 u32 out[HCI_WORDS];
353 acpi_status status; 606 acpi_status status;
354 enum led_brightness result;
355 607
356 /* First request : initialize communication. */
357 in[0] = 0xf100;
358 status = hci_raw(dev, in, out); 608 status = hci_raw(dev, in, out);
359 if (ACPI_FAILURE(status)) { 609 if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
360 pr_info("Illumination device not available\n"); 610 pr_err("ACPI call to get ECO led failed\n");
361 return LED_OFF; 611 return LED_OFF;
362 } 612 }
363 613
364 /* Check the illumination */ 614 return out[2] ? LED_FULL : LED_OFF;
365 in[0] = 0xf300; 615}
366 in[1] = 0x14e; 616
617static void toshiba_eco_mode_set_status(struct led_classdev *cdev,
618 enum led_brightness brightness)
619{
620 struct toshiba_acpi_dev *dev = container_of(cdev,
621 struct toshiba_acpi_dev, eco_led);
622 u32 in[HCI_WORDS] = { HCI_SET, HCI_ECO_MODE, 0, 1, 0, 0 };
623 u32 out[HCI_WORDS];
624 acpi_status status;
625
626 /* Switch the Eco Mode led on/off */
627 in[2] = (brightness) ? 1 : 0;
367 status = hci_raw(dev, in, out); 628 status = hci_raw(dev, in, out);
368 if (ACPI_FAILURE(status)) { 629 if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
369 pr_info("ACPI call for illumination failed.\n"); 630 pr_err("ACPI call to set ECO led failed\n");
370 return LED_OFF; 631 return;
371 } 632 }
633}
372 634
373 result = out[2] ? LED_FULL : LED_OFF; 635/* Accelerometer support */
636static int toshiba_accelerometer_supported(struct toshiba_acpi_dev *dev)
637{
638 u32 in[HCI_WORDS] = { HCI_GET, HCI_ACCELEROMETER2, 0, 0, 0, 0 };
639 u32 out[HCI_WORDS];
640 acpi_status status;
641
642 /* Check if the accelerometer call exists,
643 * this call also serves as initialization
644 */
645 status = hci_raw(dev, in, out);
646 if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
647 pr_err("ACPI call to query the accelerometer failed\n");
648 return -EIO;
649 } else if (out[0] == HCI_DATA_NOT_AVAILABLE ||
650 out[0] == HCI_NOT_INITIALIZED) {
651 pr_err("Accelerometer not initialized\n");
652 return -EIO;
653 } else if (out[0] == HCI_NOT_SUPPORTED) {
654 pr_info("Accelerometer not supported\n");
655 return -ENODEV;
656 }
657
658 return 0;
659}
660
661static int toshiba_accelerometer_get(struct toshiba_acpi_dev *dev,
662 u32 *xy, u32 *z)
663{
664 u32 in[HCI_WORDS] = { HCI_GET, HCI_ACCELEROMETER, 0, 1, 0, 0 };
665 u32 out[HCI_WORDS];
666 acpi_status status;
667
668 /* Check the Accelerometer status */
669 status = hci_raw(dev, in, out);
670 if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
671 pr_err("ACPI call to query the accelerometer failed\n");
672 return -EIO;
673 }
374 674
375 /* Last request : close communication. */ 675 *xy = out[2];
376 in[0] = 0xf200; 676 *z = out[4];
377 in[1] = 0;
378 in[2] = 0;
379 hci_raw(dev, in, out);
380 677
381 return result; 678 return 0;
382} 679}
383 680
384/* Bluetooth rfkill handlers */ 681/* Bluetooth rfkill handlers */
@@ -904,6 +1201,177 @@ static const struct backlight_ops toshiba_backlight_data = {
904 .update_status = set_lcd_status, 1201 .update_status = set_lcd_status,
905}; 1202};
906 1203
1204/*
1205 * Sysfs files
1206 */
1207
1208static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
1209 struct device_attribute *attr,
1210 const char *buf, size_t count)
1211{
1212 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1213 int mode = -1;
1214 int time = -1;
1215
1216 if (sscanf(buf, "%i", &mode) != 1 && (mode != 2 || mode != 1))
1217 return -EINVAL;
1218
1219 /* Set the Keyboard Backlight Mode where:
1220 * Mode - Auto (2) | FN-Z (1)
1221 * Auto - KBD backlight turns off automatically in given time
1222 * FN-Z - KBD backlight "toggles" when hotkey pressed
1223 */
1224 if (mode != -1 && toshiba->kbd_mode != mode) {
1225 time = toshiba->kbd_time << HCI_MISC_SHIFT;
1226 time = time + toshiba->kbd_mode;
1227 if (toshiba_kbd_illum_status_set(toshiba, time) < 0)
1228 return -EIO;
1229 toshiba->kbd_mode = mode;
1230 }
1231
1232 return count;
1233}
1234
1235static ssize_t toshiba_kbd_bl_mode_show(struct device *dev,
1236 struct device_attribute *attr,
1237 char *buf)
1238{
1239 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1240 u32 time;
1241
1242 if (toshiba_kbd_illum_status_get(toshiba, &time) < 0)
1243 return -EIO;
1244
1245 return sprintf(buf, "%i\n", time & 0x07);
1246}
1247
1248static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev,
1249 struct device_attribute *attr,
1250 const char *buf, size_t count)
1251{
1252 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1253 int time = -1;
1254
1255 if (sscanf(buf, "%i", &time) != 1 && (time < 0 || time > 60))
1256 return -EINVAL;
1257
1258 /* Set the Keyboard Backlight Timeout: 0-60 seconds */
1259 if (time != -1 && toshiba->kbd_time != time) {
1260 time = time << HCI_MISC_SHIFT;
1261 time = (toshiba->kbd_mode == SCI_KBD_MODE_AUTO) ?
1262 time + 1 : time + 2;
1263 if (toshiba_kbd_illum_status_set(toshiba, time) < 0)
1264 return -EIO;
1265 toshiba->kbd_time = time >> HCI_MISC_SHIFT;
1266 }
1267
1268 return count;
1269}
1270
1271static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev,
1272 struct device_attribute *attr,
1273 char *buf)
1274{
1275 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1276 u32 time;
1277
1278 if (toshiba_kbd_illum_status_get(toshiba, &time) < 0)
1279 return -EIO;
1280
1281 return sprintf(buf, "%i\n", time >> HCI_MISC_SHIFT);
1282}
1283
1284static ssize_t toshiba_touchpad_store(struct device *dev,
1285 struct device_attribute *attr,
1286 const char *buf, size_t count)
1287{
1288 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1289 int state;
1290
1291 /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */
1292 if (sscanf(buf, "%i", &state) == 1 && (state == 0 || state == 1)) {
1293 if (toshiba_touchpad_set(toshiba, state) < 0)
1294 return -EIO;
1295 }
1296
1297 return count;
1298}
1299
1300static ssize_t toshiba_touchpad_show(struct device *dev,
1301 struct device_attribute *attr, char *buf)
1302{
1303 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1304 u32 state;
1305 int ret;
1306
1307 ret = toshiba_touchpad_get(toshiba, &state);
1308 if (ret < 0)
1309 return ret;
1310
1311 return sprintf(buf, "%i\n", state);
1312}
1313
1314static ssize_t toshiba_position_show(struct device *dev,
1315 struct device_attribute *attr, char *buf)
1316{
1317 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1318 u32 xyval, zval, tmp;
1319 u16 x, y, z;
1320 int ret;
1321
1322 xyval = zval = 0;
1323 ret = toshiba_accelerometer_get(toshiba, &xyval, &zval);
1324 if (ret < 0)
1325 return ret;
1326
1327 x = xyval & HCI_ACCEL_MASK;
1328 tmp = xyval >> HCI_MISC_SHIFT;
1329 y = tmp & HCI_ACCEL_MASK;
1330 z = zval & HCI_ACCEL_MASK;
1331
1332 return sprintf(buf, "%d %d %d\n", x, y, z);
1333}
1334
1335static DEVICE_ATTR(kbd_backlight_mode, S_IRUGO | S_IWUSR,
1336 toshiba_kbd_bl_mode_show, toshiba_kbd_bl_mode_store);
1337static DEVICE_ATTR(kbd_backlight_timeout, S_IRUGO | S_IWUSR,
1338 toshiba_kbd_bl_timeout_show, toshiba_kbd_bl_timeout_store);
1339static DEVICE_ATTR(touchpad, S_IRUGO | S_IWUSR,
1340 toshiba_touchpad_show, toshiba_touchpad_store);
1341static DEVICE_ATTR(position, S_IRUGO, toshiba_position_show, NULL);
1342
1343static struct attribute *toshiba_attributes[] = {
1344 &dev_attr_kbd_backlight_mode.attr,
1345 &dev_attr_kbd_backlight_timeout.attr,
1346 &dev_attr_touchpad.attr,
1347 &dev_attr_position.attr,
1348 NULL,
1349};
1350
1351static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
1352 struct attribute *attr, int idx)
1353{
1354 struct device *dev = container_of(kobj, struct device, kobj);
1355 struct toshiba_acpi_dev *drv = dev_get_drvdata(dev);
1356 bool exists = true;
1357
1358 if (attr == &dev_attr_kbd_backlight_mode.attr)
1359 exists = (drv->kbd_illum_supported) ? true : false;
1360 else if (attr == &dev_attr_kbd_backlight_timeout.attr)
1361 exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false;
1362 else if (attr == &dev_attr_touchpad.attr)
1363 exists = (drv->touchpad_supported) ? true : false;
1364 else if (attr == &dev_attr_position.attr)
1365 exists = (drv->accelerometer_supported) ? true : false;
1366
1367 return exists ? attr->mode : 0;
1368}
1369
1370static struct attribute_group toshiba_attr_group = {
1371 .is_visible = toshiba_sysfs_is_visible,
1372 .attrs = toshiba_attributes,
1373};
1374
907static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str, 1375static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
908 struct serio *port) 1376 struct serio *port)
909{ 1377{
@@ -1106,6 +1574,10 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
1106 1574
1107 remove_toshiba_proc_entries(dev); 1575 remove_toshiba_proc_entries(dev);
1108 1576
1577 if (dev->sysfs_created)
1578 sysfs_remove_group(&dev->acpi_dev->dev.kobj,
1579 &toshiba_attr_group);
1580
1109 if (dev->ntfy_supported) { 1581 if (dev->ntfy_supported) {
1110 i8042_remove_filter(toshiba_acpi_i8042_filter); 1582 i8042_remove_filter(toshiba_acpi_i8042_filter);
1111 cancel_work_sync(&dev->hotkey_work); 1583 cancel_work_sync(&dev->hotkey_work);
@@ -1127,6 +1599,12 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
1127 if (dev->illumination_supported) 1599 if (dev->illumination_supported)
1128 led_classdev_unregister(&dev->led_dev); 1600 led_classdev_unregister(&dev->led_dev);
1129 1601
1602 if (dev->kbd_led_registered)
1603 led_classdev_unregister(&dev->kbd_led);
1604
1605 if (dev->eco_supported)
1606 led_classdev_unregister(&dev->eco_led);
1607
1130 if (toshiba_acpi) 1608 if (toshiba_acpi)
1131 toshiba_acpi = NULL; 1609 toshiba_acpi = NULL;
1132 1610
@@ -1172,6 +1650,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
1172 dev->acpi_dev = acpi_dev; 1650 dev->acpi_dev = acpi_dev;
1173 dev->method_hci = hci_method; 1651 dev->method_hci = hci_method;
1174 acpi_dev->driver_data = dev; 1652 acpi_dev->driver_data = dev;
1653 dev_set_drvdata(&acpi_dev->dev, dev);
1175 1654
1176 if (toshiba_acpi_setup_keyboard(dev)) 1655 if (toshiba_acpi_setup_keyboard(dev))
1177 pr_info("Unable to activate hotkeys\n"); 1656 pr_info("Unable to activate hotkeys\n");
@@ -1212,6 +1691,40 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
1212 dev->illumination_supported = 1; 1691 dev->illumination_supported = 1;
1213 } 1692 }
1214 1693
1694 if (toshiba_eco_mode_available(dev)) {
1695 dev->eco_led.name = "toshiba::eco_mode";
1696 dev->eco_led.max_brightness = 1;
1697 dev->eco_led.brightness_set = toshiba_eco_mode_set_status;
1698 dev->eco_led.brightness_get = toshiba_eco_mode_get_status;
1699 if (!led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led))
1700 dev->eco_supported = 1;
1701 }
1702
1703 ret = toshiba_kbd_illum_status_get(dev, &dummy);
1704 if (!ret) {
1705 dev->kbd_time = dummy >> HCI_MISC_SHIFT;
1706 dev->kbd_mode = dummy & 0x07;
1707 }
1708 dev->kbd_illum_supported = !ret;
1709 /*
1710 * Only register the LED if KBD illumination is supported
1711 * and the keyboard backlight operation mode is set to FN-Z
1712 */
1713 if (dev->kbd_illum_supported && dev->kbd_mode == SCI_KBD_MODE_FNZ) {
1714 dev->kbd_led.name = "toshiba::kbd_backlight";
1715 dev->kbd_led.max_brightness = 1;
1716 dev->kbd_led.brightness_set = toshiba_kbd_backlight_set;
1717 dev->kbd_led.brightness_get = toshiba_kbd_backlight_get;
1718 if (!led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led))
1719 dev->kbd_led_registered = 1;
1720 }
1721
1722 ret = toshiba_touchpad_get(dev, &dummy);
1723 dev->touchpad_supported = !ret;
1724
1725 ret = toshiba_accelerometer_supported(dev);
1726 dev->accelerometer_supported = !ret;
1727
1215 /* Determine whether or not BIOS supports fan and video interfaces */ 1728 /* Determine whether or not BIOS supports fan and video interfaces */
1216 1729
1217 ret = get_video_status(dev, &dummy); 1730 ret = get_video_status(dev, &dummy);
@@ -1220,6 +1733,14 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
1220 ret = get_fan_status(dev, &dummy); 1733 ret = get_fan_status(dev, &dummy);
1221 dev->fan_supported = !ret; 1734 dev->fan_supported = !ret;
1222 1735
1736 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj,
1737 &toshiba_attr_group);
1738 if (ret) {
1739 dev->sysfs_created = 0;
1740 goto error;
1741 }
1742 dev->sysfs_created = !ret;
1743
1223 create_toshiba_proc_entries(dev); 1744 create_toshiba_proc_entries(dev);
1224 1745
1225 toshiba_acpi = dev; 1746 toshiba_acpi = dev;
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 1cd8584a7b88..903eb37f047a 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -392,6 +392,15 @@ config REGULATOR_PALMAS
392 on the muxing. This is handled automatically in the driver by 392 on the muxing. This is handled automatically in the driver by
393 reading the mux info from OTP. 393 reading the mux info from OTP.
394 394
395config REGULATOR_PBIAS
396 tristate "PBIAS OMAP regulator driver"
397 depends on (ARCH_OMAP || COMPILE_TEST) && MFD_SYSCON
398 help
399 Say y here to support pbias regulator for mmc1:SD card i/o
400 on OMAP SoCs.
401 This driver provides support for OMAP pbias modelled
402 regulators.
403
395config REGULATOR_PCAP 404config REGULATOR_PCAP
396 tristate "Motorola PCAP2 regulator driver" 405 tristate "Motorola PCAP2 regulator driver"
397 depends on EZX_PCAP 406 depends on EZX_PCAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index f0fe0c50b59c..12ef277a48b4 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
55obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o 55obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
56obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o 56obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
57obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o 57obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
58obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
58obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o 59obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
59obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o 60obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
60obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o 61obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c
index ab08ca7cfb08..c3750c5b382b 100644
--- a/drivers/regulator/bcm590xx-regulator.c
+++ b/drivers/regulator/bcm590xx-regulator.c
@@ -123,6 +123,7 @@ struct bcm590xx_info {
123#define BCM590XX_REG_RANGES(_name, _ranges) \ 123#define BCM590XX_REG_RANGES(_name, _ranges) \
124 { \ 124 { \
125 .name = #_name, \ 125 .name = #_name, \
126 .n_voltages = 64, \
126 .n_linear_ranges = ARRAY_SIZE(_ranges), \ 127 .n_linear_ranges = ARRAY_SIZE(_ranges), \
127 .linear_ranges = _ranges, \ 128 .linear_ranges = _ranges, \
128 } 129 }
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
new file mode 100644
index 000000000000..ded3b3574209
--- /dev/null
+++ b/drivers/regulator/pbias-regulator.c
@@ -0,0 +1,255 @@
1/*
2 * pbias-regulator.c
3 *
4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
5 * Author: Balaji T K <balajitk@ti.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 as
9 * published by the Free Software Foundation version 2.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/err.h>
18#include <linux/io.h>
19#include <linux/module.h>
20#include <linux/mfd/syscon.h>
21#include <linux/platform_device.h>
22#include <linux/regulator/driver.h>
23#include <linux/regulator/machine.h>
24#include <linux/regulator/of_regulator.h>
25#include <linux/regmap.h>
26#include <linux/slab.h>
27#include <linux/of.h>
28#include <linux/of_device.h>
29
30struct pbias_reg_info {
31 u32 enable;
32 u32 enable_mask;
33 u32 vmode;
34 unsigned int enable_time;
35 char *name;
36};
37
38struct pbias_regulator_data {
39 struct regulator_desc desc;
40 void __iomem *pbias_addr;
41 unsigned int pbias_reg;
42 struct regulator_dev *dev;
43 struct regmap *syscon;
44 const struct pbias_reg_info *info;
45 int voltage;
46};
47
48static int pbias_regulator_set_voltage(struct regulator_dev *dev,
49 int min_uV, int max_uV, unsigned *selector)
50{
51 struct pbias_regulator_data *data = rdev_get_drvdata(dev);
52 const struct pbias_reg_info *info = data->info;
53 int ret, vmode;
54
55 if (min_uV <= 1800000)
56 vmode = 0;
57 else if (min_uV > 1800000)
58 vmode = info->vmode;
59
60 ret = regmap_update_bits(data->syscon, data->pbias_reg,
61 info->vmode, vmode);
62
63 return ret;
64}
65
66static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
67{
68 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
69 const struct pbias_reg_info *info = data->info;
70 int value, voltage;
71
72 regmap_read(data->syscon, data->pbias_reg, &value);
73 value &= info->vmode;
74
75 voltage = value ? 3000000 : 1800000;
76
77 return voltage;
78}
79
80static int pbias_regulator_enable(struct regulator_dev *rdev)
81{
82 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
83 const struct pbias_reg_info *info = data->info;
84 int ret;
85
86 ret = regmap_update_bits(data->syscon, data->pbias_reg,
87 info->enable_mask, info->enable);
88
89 return ret;
90}
91
92static int pbias_regulator_disable(struct regulator_dev *rdev)
93{
94 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
95 const struct pbias_reg_info *info = data->info;
96 int ret;
97
98 ret = regmap_update_bits(data->syscon, data->pbias_reg,
99 info->enable_mask, 0);
100 return ret;
101}
102
103static int pbias_regulator_is_enable(struct regulator_dev *rdev)
104{
105 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
106 const struct pbias_reg_info *info = data->info;
107 int value;
108
109 regmap_read(data->syscon, data->pbias_reg, &value);
110
111 return (value & info->enable_mask) == info->enable_mask;
112}
113
114static struct regulator_ops pbias_regulator_voltage_ops = {
115 .set_voltage = pbias_regulator_set_voltage,
116 .get_voltage = pbias_regulator_get_voltage,
117 .enable = pbias_regulator_enable,
118 .disable = pbias_regulator_disable,
119 .is_enabled = pbias_regulator_is_enable,
120};
121
122static const struct pbias_reg_info pbias_mmc_omap2430 = {
123 .enable = BIT(1),
124 .enable_mask = BIT(1),
125 .vmode = BIT(0),
126 .enable_time = 100,
127 .name = "pbias_mmc_omap2430"
128};
129
130static const struct pbias_reg_info pbias_sim_omap3 = {
131 .enable = BIT(9),
132 .enable_mask = BIT(9),
133 .vmode = BIT(8),
134 .enable_time = 100,
135 .name = "pbias_sim_omap3"
136};
137
138static const struct pbias_reg_info pbias_mmc_omap4 = {
139 .enable = BIT(26) | BIT(22),
140 .enable_mask = BIT(26) | BIT(25) | BIT(22),
141 .vmode = BIT(21),
142 .enable_time = 100,
143 .name = "pbias_mmc_omap4"
144};
145
146static const struct pbias_reg_info pbias_mmc_omap5 = {
147 .enable = BIT(27) | BIT(26),
148 .enable_mask = BIT(27) | BIT(25) | BIT(26),
149 .vmode = BIT(21),
150 .enable_time = 100,
151 .name = "pbias_mmc_omap5"
152};
153
154static struct of_regulator_match pbias_matches[] = {
155 { .name = "pbias_mmc_omap2430", .driver_data = (void *)&pbias_mmc_omap2430},
156 { .name = "pbias_sim_omap3", .driver_data = (void *)&pbias_sim_omap3},
157 { .name = "pbias_mmc_omap4", .driver_data = (void *)&pbias_mmc_omap4},
158 { .name = "pbias_mmc_omap5", .driver_data = (void *)&pbias_mmc_omap5},
159};
160#define PBIAS_NUM_REGS ARRAY_SIZE(pbias_matches)
161
162static const struct of_device_id pbias_of_match[] = {
163 { .compatible = "ti,pbias-omap", },
164 {},
165};
166MODULE_DEVICE_TABLE(of, pbias_of_match);
167
168static int pbias_regulator_probe(struct platform_device *pdev)
169{
170 struct device_node *np = pdev->dev.of_node;
171 struct pbias_regulator_data *drvdata;
172 struct resource *res;
173 struct regulator_config cfg = { };
174 struct regmap *syscon;
175 const struct pbias_reg_info *info;
176 int ret = 0;
177 int count, idx, data_idx = 0;
178
179 count = of_regulator_match(&pdev->dev, np, pbias_matches,
180 PBIAS_NUM_REGS);
181 if (count < 0)
182 return count;
183
184 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data)
185 * count, GFP_KERNEL);
186 if (drvdata == NULL) {
187 dev_err(&pdev->dev, "Failed to allocate device data\n");
188 return -ENOMEM;
189 }
190
191 syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
192 if (IS_ERR(syscon))
193 return PTR_ERR(syscon);
194
195 cfg.dev = &pdev->dev;
196
197 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) {
198 if (!pbias_matches[idx].init_data ||
199 !pbias_matches[idx].of_node)
200 continue;
201
202 info = pbias_matches[idx].driver_data;
203 if (!info)
204 return -ENODEV;
205
206 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
207 if (!res)
208 return -EINVAL;
209
210 drvdata[data_idx].pbias_reg = res->start;
211 drvdata[data_idx].syscon = syscon;
212 drvdata[data_idx].info = info;
213 drvdata[data_idx].desc.name = info->name;
214 drvdata[data_idx].desc.owner = THIS_MODULE;
215 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
216 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
217 drvdata[data_idx].desc.n_voltages = 2;
218 drvdata[data_idx].desc.enable_time = info->enable_time;
219
220 cfg.init_data = pbias_matches[idx].init_data;
221 cfg.driver_data = &drvdata[data_idx];
222 cfg.of_node = pbias_matches[idx].of_node;
223
224 drvdata[data_idx].dev = devm_regulator_register(&pdev->dev,
225 &drvdata[data_idx].desc, &cfg);
226 if (IS_ERR(drvdata[data_idx].dev)) {
227 ret = PTR_ERR(drvdata[data_idx].dev);
228 dev_err(&pdev->dev,
229 "Failed to register regulator: %d\n", ret);
230 goto err_regulator;
231 }
232 data_idx++;
233 }
234
235 platform_set_drvdata(pdev, drvdata);
236
237err_regulator:
238 return ret;
239}
240
241static struct platform_driver pbias_regulator_driver = {
242 .probe = pbias_regulator_probe,
243 .driver = {
244 .name = "pbias-regulator",
245 .owner = THIS_MODULE,
246 .of_match_table = of_match_ptr(pbias_of_match),
247 },
248};
249
250module_platform_driver(pbias_regulator_driver);
251
252MODULE_AUTHOR("Balaji T K <balajitk@ti.com>");
253MODULE_DESCRIPTION("pbias voltage regulator");
254MODULE_LICENSE("GPL");
255MODULE_ALIAS("platform:pbias-regulator");
diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
index 808b3aa7a42c..f19a30f0fb42 100644
--- a/drivers/regulator/s2mpa01.c
+++ b/drivers/regulator/s2mpa01.c
@@ -192,13 +192,11 @@ static int s2mpa01_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
192 if (!ramp_enable) 192 if (!ramp_enable)
193 goto ramp_disable; 193 goto ramp_disable;
194 194
195 if (enable_shift) { 195 ret = regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1,
196 ret = regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1, 196 1 << enable_shift, 1 << enable_shift);
197 1 << enable_shift, 1 << enable_shift); 197 if (ret) {
198 if (ret) { 198 dev_err(&rdev->dev, "failed to enable ramp rate\n");
199 dev_err(&rdev->dev, "failed to enable ramp rate\n"); 199 return ret;
200 return ret;
201 }
202 } 200 }
203 201
204 ramp_val = get_ramp_delay(ramp_delay); 202 ramp_val = get_ramp_delay(ramp_delay);
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 68fd54702edb..e713c162fbd4 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -202,13 +202,11 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
202 if (!ramp_enable) 202 if (!ramp_enable)
203 goto ramp_disable; 203 goto ramp_disable;
204 204
205 if (enable_shift) { 205 ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP,
206 ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP, 206 1 << enable_shift, 1 << enable_shift);
207 1 << enable_shift, 1 << enable_shift); 207 if (ret) {
208 if (ret) { 208 dev_err(&rdev->dev, "failed to enable ramp rate\n");
209 dev_err(&rdev->dev, "failed to enable ramp rate\n"); 209 return ret;
210 return ret;
211 }
212 } 210 }
213 211
214 ramp_val = get_ramp_delay(ramp_delay); 212 ramp_val = get_ramp_delay(ramp_delay);
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index f05badabd69e..92f19a005dc3 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -964,6 +964,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
964 config.driver_data = s5m8767; 964 config.driver_data = s5m8767;
965 config.regmap = iodev->regmap_pmic; 965 config.regmap = iodev->regmap_pmic;
966 config.of_node = pdata->regulators[i].reg_node; 966 config.of_node = pdata->regulators[i].reg_node;
967 config.ena_gpio = config.ena_gpio_flags = 0;
967 if (pdata->regulators[i].ext_control_gpio) 968 if (pdata->regulators[i].ext_control_gpio)
968 s5m8767_regulator_config_ext_control(s5m8767, 969 s5m8767_regulator_config_ext_control(s5m8767,
969 &pdata->regulators[i], &config); 970 &pdata->regulators[i], &config);
diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 129f7b997866..3841b9813109 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -201,23 +201,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
201 } 201 }
202 202
203 bootreg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 203 bootreg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
204 if (!bootreg_res) {
205 dev_err(dev,
206 "platform_get_resource(IORESOURCE_MEM, 0): NULL\n");
207 return -EADDRNOTAVAIL;
208 }
209
210 chipsig_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
211 if (!chipsig_res) {
212 dev_err(dev,
213 "platform_get_resource(IORESOURCE_MEM, 1): NULL\n");
214 return -EADDRNOTAVAIL;
215 }
216
217 bootreg = devm_ioremap_resource(dev, bootreg_res); 204 bootreg = devm_ioremap_resource(dev, bootreg_res);
218 if (IS_ERR(bootreg)) 205 if (IS_ERR(bootreg))
219 return PTR_ERR(bootreg); 206 return PTR_ERR(bootreg);
220 207
208 chipsig_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
221 chipsig = devm_ioremap_resource(dev, chipsig_res); 209 chipsig = devm_ioremap_resource(dev, chipsig_res);
222 if (IS_ERR(chipsig)) 210 if (IS_ERR(chipsig))
223 return PTR_ERR(chipsig); 211 return PTR_ERR(chipsig);
@@ -301,8 +289,6 @@ static int da8xx_rproc_remove(struct platform_device *pdev)
301 */ 289 */
302 disable_irq(drproc->irq); 290 disable_irq(drproc->irq);
303 291
304 devm_clk_put(dev, drproc->dsp_clk);
305
306 rproc_del(rproc); 292 rproc_del(rproc);
307 rproc_put(rproc); 293 rproc_put(rproc);
308 294
diff --git a/drivers/remoteproc/ste_modem_rproc.c b/drivers/remoteproc/ste_modem_rproc.c
index 1ec39a4c0b3e..c4ac9104dd8e 100644
--- a/drivers/remoteproc/ste_modem_rproc.c
+++ b/drivers/remoteproc/ste_modem_rproc.c
@@ -164,7 +164,7 @@ sproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw)
164} 164}
165 165
166/* STE modem firmware handler operations */ 166/* STE modem firmware handler operations */
167const struct rproc_fw_ops sproc_fw_ops = { 167static const struct rproc_fw_ops sproc_fw_ops = {
168 .load = sproc_load_segments, 168 .load = sproc_load_segments,
169 .find_rsc_table = sproc_find_rsc_table, 169 .find_rsc_table = sproc_find_rsc_table,
170 .find_loaded_rsc_table = sproc_find_loaded_rsc_table, 170 .find_loaded_rsc_table = sproc_find_loaded_rsc_table,
@@ -193,7 +193,7 @@ static void sproc_kick_callback(struct ste_modem_device *mdev, int vqid)
193 sproc_dbg(sproc, "no message was found in vqid %d\n", vqid); 193 sproc_dbg(sproc, "no message was found in vqid %d\n", vqid);
194} 194}
195 195
196struct ste_modem_dev_cb sproc_dev_cb = { 196static struct ste_modem_dev_cb sproc_dev_cb = {
197 .kick = sproc_kick_callback, 197 .kick = sproc_kick_callback,
198}; 198};
199 199
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c8bd092fc945..02832d64d918 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -263,6 +263,9 @@ config SCSI_SCAN_ASYNC
263 You can override this choice by specifying "scsi_mod.scan=sync" 263 You can override this choice by specifying "scsi_mod.scan=sync"
264 or async on the kernel's command line. 264 or async on the kernel's command line.
265 265
266 Note that this setting also affects whether resuming from
267 system suspend will be performed asynchronously.
268
266menu "SCSI Transports" 269menu "SCSI Transports"
267 depends on SCSI 270 depends on SCSI
268 271
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index bfb6d07d87f0..11854845393b 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -125,7 +125,7 @@ static inline int iscsi_sw_sk_state_check(struct sock *sk)
125 return 0; 125 return 0;
126} 126}
127 127
128static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag) 128static void iscsi_sw_tcp_data_ready(struct sock *sk)
129{ 129{
130 struct iscsi_conn *conn; 130 struct iscsi_conn *conn;
131 struct iscsi_tcp_conn *tcp_conn; 131 struct iscsi_tcp_conn *tcp_conn;
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index 666fe09378fa..f42ecb238af5 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -40,7 +40,7 @@ struct iscsi_sw_tcp_conn {
40 40
41 struct iscsi_sw_tcp_send out; 41 struct iscsi_sw_tcp_send out;
42 /* old values for socket callbacks */ 42 /* old values for socket callbacks */
43 void (*old_data_ready)(struct sock *, int); 43 void (*old_data_ready)(struct sock *);
44 void (*old_state_change)(struct sock *); 44 void (*old_state_change)(struct sock *);
45 void (*old_write_space)(struct sock *); 45 void (*old_write_space)(struct sock *);
46 46
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 788c4fe2b0c9..68fb66fdb757 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -684,6 +684,20 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
684 qlt_xmit_tm_rsp(mcmd); 684 qlt_xmit_tm_rsp(mcmd);
685} 685}
686 686
687static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
688{
689 struct qla_tgt_cmd *cmd = container_of(se_cmd,
690 struct qla_tgt_cmd, se_cmd);
691 struct scsi_qla_host *vha = cmd->vha;
692 struct qla_hw_data *ha = vha->hw;
693
694 if (!cmd->sg_mapped)
695 return;
696
697 pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
698 cmd->sg_mapped = 0;
699}
700
687/* Local pointer to allocated TCM configfs fabric module */ 701/* Local pointer to allocated TCM configfs fabric module */
688struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs; 702struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs;
689struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs; 703struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs;
@@ -1468,7 +1482,7 @@ static int tcm_qla2xxx_check_initiator_node_acl(
1468 } 1482 }
1469 se_tpg = &tpg->se_tpg; 1483 se_tpg = &tpg->se_tpg;
1470 1484
1471 se_sess = transport_init_session(); 1485 se_sess = transport_init_session(TARGET_PROT_NORMAL);
1472 if (IS_ERR(se_sess)) { 1486 if (IS_ERR(se_sess)) {
1473 pr_err("Unable to initialize struct se_session\n"); 1487 pr_err("Unable to initialize struct se_session\n");
1474 return PTR_ERR(se_sess); 1488 return PTR_ERR(se_sess);
@@ -1877,6 +1891,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
1877 .queue_data_in = tcm_qla2xxx_queue_data_in, 1891 .queue_data_in = tcm_qla2xxx_queue_data_in,
1878 .queue_status = tcm_qla2xxx_queue_status, 1892 .queue_status = tcm_qla2xxx_queue_status,
1879 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp, 1893 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1894 .aborted_task = tcm_qla2xxx_aborted_task,
1880 /* 1895 /*
1881 * Setup function pointers for generic logic in 1896 * Setup function pointers for generic logic in
1882 * target_core_fabric_configfs.c 1897 * target_core_fabric_configfs.c
@@ -1926,6 +1941,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
1926 .queue_data_in = tcm_qla2xxx_queue_data_in, 1941 .queue_data_in = tcm_qla2xxx_queue_data_in,
1927 .queue_status = tcm_qla2xxx_queue_status, 1942 .queue_status = tcm_qla2xxx_queue_status,
1928 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp, 1943 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1944 .aborted_task = tcm_qla2xxx_aborted_task,
1929 /* 1945 /*
1930 * Setup function pointers for generic logic in 1946 * Setup function pointers for generic logic in
1931 * target_core_fabric_configfs.c 1947 * target_core_fabric_configfs.c
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c4d632c27a3e..88d46fe6bf98 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -91,6 +91,15 @@ EXPORT_SYMBOL(scsi_logging_level);
91ASYNC_DOMAIN(scsi_sd_probe_domain); 91ASYNC_DOMAIN(scsi_sd_probe_domain);
92EXPORT_SYMBOL(scsi_sd_probe_domain); 92EXPORT_SYMBOL(scsi_sd_probe_domain);
93 93
94/*
95 * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
96 * asynchronous system resume operations. It is marked 'exclusive' to avoid
97 * being included in the async_synchronize_full() that is invoked by
98 * dpm_resume()
99 */
100ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
101EXPORT_SYMBOL(scsi_sd_pm_domain);
102
94/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI. 103/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
95 * You may not alter any existing entry (although adding new ones is 104 * You may not alter any existing entry (although adding new ones is
96 * encouraged once assigned by ANSI/INCITS T10 105 * encouraged once assigned by ANSI/INCITS T10
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5681c05ac506..65a123d9c676 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -184,7 +184,7 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
184 */ 184 */
185int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 185int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
186 int data_direction, void *buffer, unsigned bufflen, 186 int data_direction, void *buffer, unsigned bufflen,
187 unsigned char *sense, int timeout, int retries, int flags, 187 unsigned char *sense, int timeout, int retries, u64 flags,
188 int *resid) 188 int *resid)
189{ 189{
190 struct request *req; 190 struct request *req;
@@ -235,7 +235,7 @@ EXPORT_SYMBOL(scsi_execute);
235int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd, 235int scsi_execute_req_flags(struct scsi_device *sdev, const unsigned char *cmd,
236 int data_direction, void *buffer, unsigned bufflen, 236 int data_direction, void *buffer, unsigned bufflen,
237 struct scsi_sense_hdr *sshdr, int timeout, int retries, 237 struct scsi_sense_hdr *sshdr, int timeout, int retries,
238 int *resid, int flags) 238 int *resid, u64 flags)
239{ 239{
240 char *sense = NULL; 240 char *sense = NULL;
241 int result; 241 int result;
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index 001e9ceda4c3..7454498c4091 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -18,35 +18,77 @@
18 18
19#ifdef CONFIG_PM_SLEEP 19#ifdef CONFIG_PM_SLEEP
20 20
21static int scsi_dev_type_suspend(struct device *dev, int (*cb)(struct device *)) 21static int do_scsi_suspend(struct device *dev, const struct dev_pm_ops *pm)
22{ 22{
23 return pm && pm->suspend ? pm->suspend(dev) : 0;
24}
25
26static int do_scsi_freeze(struct device *dev, const struct dev_pm_ops *pm)
27{
28 return pm && pm->freeze ? pm->freeze(dev) : 0;
29}
30
31static int do_scsi_poweroff(struct device *dev, const struct dev_pm_ops *pm)
32{
33 return pm && pm->poweroff ? pm->poweroff(dev) : 0;
34}
35
36static int do_scsi_resume(struct device *dev, const struct dev_pm_ops *pm)
37{
38 return pm && pm->resume ? pm->resume(dev) : 0;
39}
40
41static int do_scsi_thaw(struct device *dev, const struct dev_pm_ops *pm)
42{
43 return pm && pm->thaw ? pm->thaw(dev) : 0;
44}
45
46static int do_scsi_restore(struct device *dev, const struct dev_pm_ops *pm)
47{
48 return pm && pm->restore ? pm->restore(dev) : 0;
49}
50
51static int scsi_dev_type_suspend(struct device *dev,
52 int (*cb)(struct device *, const struct dev_pm_ops *))
53{
54 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
23 int err; 55 int err;
24 56
57 /* flush pending in-flight resume operations, suspend is synchronous */
58 async_synchronize_full_domain(&scsi_sd_pm_domain);
59
25 err = scsi_device_quiesce(to_scsi_device(dev)); 60 err = scsi_device_quiesce(to_scsi_device(dev));
26 if (err == 0) { 61 if (err == 0) {
27 if (cb) { 62 err = cb(dev, pm);
28 err = cb(dev); 63 if (err)
29 if (err) 64 scsi_device_resume(to_scsi_device(dev));
30 scsi_device_resume(to_scsi_device(dev));
31 }
32 } 65 }
33 dev_dbg(dev, "scsi suspend: %d\n", err); 66 dev_dbg(dev, "scsi suspend: %d\n", err);
34 return err; 67 return err;
35} 68}
36 69
37static int scsi_dev_type_resume(struct device *dev, int (*cb)(struct device *)) 70static int scsi_dev_type_resume(struct device *dev,
71 int (*cb)(struct device *, const struct dev_pm_ops *))
38{ 72{
73 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
39 int err = 0; 74 int err = 0;
40 75
41 if (cb) 76 err = cb(dev, pm);
42 err = cb(dev);
43 scsi_device_resume(to_scsi_device(dev)); 77 scsi_device_resume(to_scsi_device(dev));
44 dev_dbg(dev, "scsi resume: %d\n", err); 78 dev_dbg(dev, "scsi resume: %d\n", err);
79
80 if (err == 0) {
81 pm_runtime_disable(dev);
82 pm_runtime_set_active(dev);
83 pm_runtime_enable(dev);
84 }
85
45 return err; 86 return err;
46} 87}
47 88
48static int 89static int
49scsi_bus_suspend_common(struct device *dev, int (*cb)(struct device *)) 90scsi_bus_suspend_common(struct device *dev,
91 int (*cb)(struct device *, const struct dev_pm_ops *))
50{ 92{
51 int err = 0; 93 int err = 0;
52 94
@@ -66,20 +108,54 @@ scsi_bus_suspend_common(struct device *dev, int (*cb)(struct device *))
66 return err; 108 return err;
67} 109}
68 110
69static int 111static void async_sdev_resume(void *dev, async_cookie_t cookie)
70scsi_bus_resume_common(struct device *dev, int (*cb)(struct device *))
71{ 112{
72 int err = 0; 113 scsi_dev_type_resume(dev, do_scsi_resume);
114}
73 115
74 if (scsi_is_sdev_device(dev)) 116static void async_sdev_thaw(void *dev, async_cookie_t cookie)
75 err = scsi_dev_type_resume(dev, cb); 117{
118 scsi_dev_type_resume(dev, do_scsi_thaw);
119}
76 120
77 if (err == 0) { 121static void async_sdev_restore(void *dev, async_cookie_t cookie)
122{
123 scsi_dev_type_resume(dev, do_scsi_restore);
124}
125
126static int scsi_bus_resume_common(struct device *dev,
127 int (*cb)(struct device *, const struct dev_pm_ops *))
128{
129 async_func_t fn;
130
131 if (!scsi_is_sdev_device(dev))
132 fn = NULL;
133 else if (cb == do_scsi_resume)
134 fn = async_sdev_resume;
135 else if (cb == do_scsi_thaw)
136 fn = async_sdev_thaw;
137 else if (cb == do_scsi_restore)
138 fn = async_sdev_restore;
139 else
140 fn = NULL;
141
142 if (fn) {
143 async_schedule_domain(fn, dev, &scsi_sd_pm_domain);
144
145 /*
146 * If a user has disabled async probing a likely reason
147 * is due to a storage enclosure that does not inject
148 * staggered spin-ups. For safety, make resume
149 * synchronous as well in that case.
150 */
151 if (strncmp(scsi_scan_type, "async", 5) != 0)
152 async_synchronize_full_domain(&scsi_sd_pm_domain);
153 } else {
78 pm_runtime_disable(dev); 154 pm_runtime_disable(dev);
79 pm_runtime_set_active(dev); 155 pm_runtime_set_active(dev);
80 pm_runtime_enable(dev); 156 pm_runtime_enable(dev);
81 } 157 }
82 return err; 158 return 0;
83} 159}
84 160
85static int scsi_bus_prepare(struct device *dev) 161static int scsi_bus_prepare(struct device *dev)
@@ -97,38 +173,32 @@ static int scsi_bus_prepare(struct device *dev)
97 173
98static int scsi_bus_suspend(struct device *dev) 174static int scsi_bus_suspend(struct device *dev)
99{ 175{
100 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 176 return scsi_bus_suspend_common(dev, do_scsi_suspend);
101 return scsi_bus_suspend_common(dev, pm ? pm->suspend : NULL);
102} 177}
103 178
104static int scsi_bus_resume(struct device *dev) 179static int scsi_bus_resume(struct device *dev)
105{ 180{
106 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 181 return scsi_bus_resume_common(dev, do_scsi_resume);
107 return scsi_bus_resume_common(dev, pm ? pm->resume : NULL);
108} 182}
109 183
110static int scsi_bus_freeze(struct device *dev) 184static int scsi_bus_freeze(struct device *dev)
111{ 185{
112 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 186 return scsi_bus_suspend_common(dev, do_scsi_freeze);
113 return scsi_bus_suspend_common(dev, pm ? pm->freeze : NULL);
114} 187}
115 188
116static int scsi_bus_thaw(struct device *dev) 189static int scsi_bus_thaw(struct device *dev)
117{ 190{
118 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 191 return scsi_bus_resume_common(dev, do_scsi_thaw);
119 return scsi_bus_resume_common(dev, pm ? pm->thaw : NULL);
120} 192}
121 193
122static int scsi_bus_poweroff(struct device *dev) 194static int scsi_bus_poweroff(struct device *dev)
123{ 195{
124 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 196 return scsi_bus_suspend_common(dev, do_scsi_poweroff);
125 return scsi_bus_suspend_common(dev, pm ? pm->poweroff : NULL);
126} 197}
127 198
128static int scsi_bus_restore(struct device *dev) 199static int scsi_bus_restore(struct device *dev)
129{ 200{
130 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 201 return scsi_bus_resume_common(dev, do_scsi_restore);
131 return scsi_bus_resume_common(dev, pm ? pm->restore : NULL);
132} 202}
133 203
134#else /* CONFIG_PM_SLEEP */ 204#else /* CONFIG_PM_SLEEP */
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index f079a598bed4..48e5b657e79f 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -112,6 +112,7 @@ extern void scsi_exit_procfs(void);
112#endif /* CONFIG_PROC_FS */ 112#endif /* CONFIG_PROC_FS */
113 113
114/* scsi_scan.c */ 114/* scsi_scan.c */
115extern char scsi_scan_type[];
115extern int scsi_complete_async_scans(void); 116extern int scsi_complete_async_scans(void);
116extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, 117extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
117 unsigned int, unsigned int, int); 118 unsigned int, unsigned int, int);
@@ -166,6 +167,7 @@ static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; }
166static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} 167static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
167#endif /* CONFIG_PM_RUNTIME */ 168#endif /* CONFIG_PM_RUNTIME */
168 169
170extern struct async_domain scsi_sd_pm_domain;
169extern struct async_domain scsi_sd_probe_domain; 171extern struct async_domain scsi_sd_probe_domain;
170 172
171/* 173/*
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 27f96d5b7680..e02b3aab56ce 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(max_luns,
97#define SCSI_SCAN_TYPE_DEFAULT "sync" 97#define SCSI_SCAN_TYPE_DEFAULT "sync"
98#endif 98#endif
99 99
100static char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT; 100char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT;
101 101
102module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO); 102module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
103MODULE_PARM_DESC(scan, "sync, async or none"); 103MODULE_PARM_DESC(scan, "sync, async or none");
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 89e6c04ac595..efcbcd182863 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3026,6 +3026,7 @@ static int sd_remove(struct device *dev)
3026 devt = disk_devt(sdkp->disk); 3026 devt = disk_devt(sdkp->disk);
3027 scsi_autopm_get_device(sdkp->device); 3027 scsi_autopm_get_device(sdkp->device);
3028 3028
3029 async_synchronize_full_domain(&scsi_sd_pm_domain);
3029 async_synchronize_full_domain(&scsi_sd_probe_domain); 3030 async_synchronize_full_domain(&scsi_sd_probe_domain);
3030 blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn); 3031 blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn);
3031 blk_queue_unprep_rq(sdkp->device->request_queue, NULL); 3032 blk_queue_unprep_rq(sdkp->device->request_queue, NULL);
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index d92fe4037e94..6b349e301869 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -3000,7 +3000,11 @@ sym_dequeue_from_squeue(struct sym_hcb *np, int i, int target, int lun, int task
3000 if ((target == -1 || cp->target == target) && 3000 if ((target == -1 || cp->target == target) &&
3001 (lun == -1 || cp->lun == lun) && 3001 (lun == -1 || cp->lun == lun) &&
3002 (task == -1 || cp->tag == task)) { 3002 (task == -1 || cp->tag == task)) {
3003#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
3003 sym_set_cam_status(cp->cmd, DID_SOFT_ERROR); 3004 sym_set_cam_status(cp->cmd, DID_SOFT_ERROR);
3005#else
3006 sym_set_cam_status(cp->cmd, DID_REQUEUE);
3007#endif
3004 sym_remque(&cp->link_ccbq); 3008 sym_remque(&cp->link_ccbq);
3005 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq); 3009 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
3006 } 3010 }
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index efe1960af2b3..60f2b41c7310 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -383,7 +383,7 @@ config SPI_RSPI
383 383
384config SPI_QUP 384config SPI_QUP
385 tristate "Qualcomm SPI controller with QUP interface" 385 tristate "Qualcomm SPI controller with QUP interface"
386 depends on ARCH_MSM_DT || (ARM && COMPILE_TEST) 386 depends on ARCH_QCOM || (ARM && COMPILE_TEST)
387 help 387 help
388 Qualcomm Universal Peripheral (QUP) core is an AHB slave that 388 Qualcomm Universal Peripheral (QUP) core is an AHB slave that
389 provides a common data path (an output FIFO and an input FIFO) 389 provides a common data path (an output FIFO and an input FIFO)
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 6fb2b75df821..e767f5831b9c 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -441,7 +441,8 @@ static void fsl_espi_do_one_msg(struct spi_message *m)
441 441
442 m->actual_length = espi_trans.actual_length; 442 m->actual_length = espi_trans.actual_length;
443 m->status = espi_trans.status; 443 m->status = espi_trans.status;
444 m->complete(m->context); 444 if (m->complete)
445 m->complete(m->context);
445} 446}
446 447
447static int fsl_espi_setup(struct spi_device *spi) 448static int fsl_espi_setup(struct spi_device *spi)
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index f35488ed62a9..b3e7775034db 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -408,7 +408,8 @@ static void fsl_spi_do_one_msg(struct spi_message *m)
408 } 408 }
409 409
410 m->status = status; 410 m->status = status;
411 m->complete(m->context); 411 if (m->complete)
412 m->complete(m->context);
412 413
413 if (status || !cs_change) { 414 if (status || !cs_change) {
414 ndelay(nsecs); 415 ndelay(nsecs);
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 3822eef2ef9d..577d23a12763 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -300,7 +300,8 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master,
300 } 300 }
301 301
302 m->status = status; 302 m->status = status;
303 m->complete(m->context); 303 if (m->complete)
304 m->complete(m->context);
304 305
305 if (status || !cs_change) 306 if (status || !cs_change)
306 mpc512x_psc_spi_deactivate_cs(spi); 307 mpc512x_psc_spi_deactivate_cs(spi);
diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c
index 3d18d9351185..de532aa11d34 100644
--- a/drivers/spi/spi-mpc52xx-psc.c
+++ b/drivers/spi/spi-mpc52xx-psc.c
@@ -247,7 +247,8 @@ static void mpc52xx_psc_spi_work(struct work_struct *work)
247 } 247 }
248 248
249 m->status = status; 249 m->status = status;
250 m->complete(m->context); 250 if (m->complete)
251 m->complete(m->context);
251 252
252 if (status || !cs_change) 253 if (status || !cs_change)
253 mpc52xx_psc_spi_deactivate_cs(spi); 254 mpc52xx_psc_spi_deactivate_cs(spi);
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index aac2a5ddd964..b07db4b62d80 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -234,7 +234,8 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
234 dev_err(&ms->master->dev, "mode fault\n"); 234 dev_err(&ms->master->dev, "mode fault\n");
235 mpc52xx_spi_chipsel(ms, 0); 235 mpc52xx_spi_chipsel(ms, 0);
236 ms->message->status = -EIO; 236 ms->message->status = -EIO;
237 ms->message->complete(ms->message->context); 237 if (ms->message->complete)
238 ms->message->complete(ms->message->context);
238 ms->state = mpc52xx_spi_fsmstate_idle; 239 ms->state = mpc52xx_spi_fsmstate_idle;
239 return FSM_CONTINUE; 240 return FSM_CONTINUE;
240 } 241 }
@@ -288,7 +289,8 @@ mpc52xx_spi_fsmstate_wait(int irq, struct mpc52xx_spi *ms, u8 status, u8 data)
288 ms->msg_count++; 289 ms->msg_count++;
289 mpc52xx_spi_chipsel(ms, 0); 290 mpc52xx_spi_chipsel(ms, 0);
290 ms->message->status = 0; 291 ms->message->status = 0;
291 ms->message->complete(ms->message->context); 292 if (ms->message->complete)
293 ms->message->complete(ms->message->context);
292 ms->state = mpc52xx_spi_fsmstate_idle; 294 ms->state = mpc52xx_spi_fsmstate_idle;
293 return FSM_CONTINUE; 295 return FSM_CONTINUE;
294 } 296 }
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 2941c5b96ebc..4dc77df38864 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1379,12 +1379,13 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1379 1379
1380 INIT_LIST_HEAD(&mcspi->ctx.cs); 1380 INIT_LIST_HEAD(&mcspi->ctx.cs);
1381 1381
1382 mcspi->dma_channels = kcalloc(master->num_chipselect, 1382 mcspi->dma_channels = devm_kcalloc(&pdev->dev, master->num_chipselect,
1383 sizeof(struct omap2_mcspi_dma), 1383 sizeof(struct omap2_mcspi_dma),
1384 GFP_KERNEL); 1384 GFP_KERNEL);
1385 1385 if (mcspi->dma_channels == NULL) {
1386 if (mcspi->dma_channels == NULL) 1386 status = -ENOMEM;
1387 goto free_master; 1387 goto free_master;
1388 }
1388 1389
1389 for (i = 0; i < master->num_chipselect; i++) { 1390 for (i = 0; i < master->num_chipselect; i++) {
1390 char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name; 1391 char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name;
@@ -1426,7 +1427,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1426 } 1427 }
1427 1428
1428 if (status < 0) 1429 if (status < 0)
1429 goto dma_chnl_free; 1430 goto free_master;
1430 1431
1431 pm_runtime_use_autosuspend(&pdev->dev); 1432 pm_runtime_use_autosuspend(&pdev->dev);
1432 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); 1433 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
@@ -1444,8 +1445,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1444 1445
1445disable_pm: 1446disable_pm:
1446 pm_runtime_disable(&pdev->dev); 1447 pm_runtime_disable(&pdev->dev);
1447dma_chnl_free:
1448 kfree(mcspi->dma_channels);
1449free_master: 1448free_master:
1450 spi_master_put(master); 1449 spi_master_put(master);
1451 return status; 1450 return status;
@@ -1453,19 +1452,12 @@ free_master:
1453 1452
1454static int omap2_mcspi_remove(struct platform_device *pdev) 1453static int omap2_mcspi_remove(struct platform_device *pdev)
1455{ 1454{
1456 struct spi_master *master; 1455 struct spi_master *master = platform_get_drvdata(pdev);
1457 struct omap2_mcspi *mcspi; 1456 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1458 struct omap2_mcspi_dma *dma_channels;
1459
1460 master = platform_get_drvdata(pdev);
1461 mcspi = spi_master_get_devdata(master);
1462 dma_channels = mcspi->dma_channels;
1463 1457
1464 pm_runtime_put_sync(mcspi->dev); 1458 pm_runtime_put_sync(mcspi->dev);
1465 pm_runtime_disable(&pdev->dev); 1459 pm_runtime_disable(&pdev->dev);
1466 1460
1467 kfree(dma_channels);
1468
1469 return 0; 1461 return 0;
1470} 1462}
1471 1463
diff --git a/drivers/spi/spi-sh.c b/drivers/spi/spi-sh.c
index f6f2c7010177..03edf5ed0e9f 100644
--- a/drivers/spi/spi-sh.c
+++ b/drivers/spi/spi-sh.c
@@ -322,7 +322,8 @@ static void spi_sh_work(struct work_struct *work)
322 spin_lock_irqsave(&ss->lock, flags); 322 spin_lock_irqsave(&ss->lock, flags);
323 323
324 mesg->status = 0; 324 mesg->status = 0;
325 mesg->complete(mesg->context); 325 if (mesg->complete)
326 mesg->complete(mesg->context);
326 } 327 }
327 328
328 clear_fifo(ss); 329 clear_fifo(ss);
@@ -340,7 +341,8 @@ static void spi_sh_work(struct work_struct *work)
340 341
341 error: 342 error:
342 mesg->status = ret; 343 mesg->status = ret;
343 mesg->complete(mesg->context); 344 if (mesg->complete)
345 mesg->complete(mesg->context);
344 346
345 spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, 347 spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD,
346 SPI_SH_CR1); 348 SPI_SH_CR1);
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c
index 820b499816f8..5f183baa91a9 100644
--- a/drivers/spi/spi-txx9.c
+++ b/drivers/spi/spi-txx9.c
@@ -262,7 +262,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m)
262 262
263exit: 263exit:
264 m->status = status; 264 m->status = status;
265 m->complete(m->context); 265 if (m->complete)
266 m->complete(m->context);
266 267
267 /* normally deactivate chipselect ... unless no error and 268 /* normally deactivate chipselect ... unless no error and
268 * cs_change has hinted that the next message will probably 269 * cs_change has hinted that the next message will probably
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
index a54b506ba7ca..37758d1c8a68 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
@@ -99,16 +99,7 @@ ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
99 struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; 99 struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
100 unsigned int niov = tx->tx_niov; 100 unsigned int niov = tx->tx_niov;
101#endif 101#endif
102 struct msghdr msg = { 102 struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
103 .msg_name = NULL,
104 .msg_namelen = 0,
105 .msg_iov = scratchiov,
106 .msg_iovlen = niov,
107 .msg_control = NULL,
108 .msg_controllen = 0,
109 .msg_flags = MSG_DONTWAIT
110 };
111 mm_segment_t oldmm = get_fs();
112 int i; 103 int i;
113 104
114 for (nob = i = 0; i < niov; i++) { 105 for (nob = i = 0; i < niov; i++) {
@@ -120,9 +111,7 @@ ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
120 nob < tx->tx_resid) 111 nob < tx->tx_resid)
121 msg.msg_flags |= MSG_MORE; 112 msg.msg_flags |= MSG_MORE;
122 113
123 set_fs (KERNEL_DS); 114 rc = kernel_sendmsg(sock, &msg, (struct kvec *)scratchiov, niov, nob);
124 rc = sock_sendmsg(sock, &msg, nob);
125 set_fs (oldmm);
126 } 115 }
127 return rc; 116 return rc;
128} 117}
@@ -174,16 +163,7 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
174 struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov; 163 struct iovec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
175 unsigned int niov = tx->tx_nkiov; 164 unsigned int niov = tx->tx_nkiov;
176#endif 165#endif
177 struct msghdr msg = { 166 struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
178 .msg_name = NULL,
179 .msg_namelen = 0,
180 .msg_iov = scratchiov,
181 .msg_iovlen = niov,
182 .msg_control = NULL,
183 .msg_controllen = 0,
184 .msg_flags = MSG_DONTWAIT
185 };
186 mm_segment_t oldmm = get_fs();
187 int i; 167 int i;
188 168
189 for (nob = i = 0; i < niov; i++) { 169 for (nob = i = 0; i < niov; i++) {
@@ -196,9 +176,7 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
196 nob < tx->tx_resid) 176 nob < tx->tx_resid)
197 msg.msg_flags |= MSG_MORE; 177 msg.msg_flags |= MSG_MORE;
198 178
199 set_fs (KERNEL_DS); 179 rc = kernel_sendmsg(sock, &msg, (struct kvec *)scratchiov, niov, nob);
200 rc = sock_sendmsg(sock, &msg, nob);
201 set_fs (oldmm);
202 180
203 for (i = 0; i < niov; i++) 181 for (i = 0; i < niov; i++)
204 kunmap(kiov[i].kiov_page); 182 kunmap(kiov[i].kiov_page);
@@ -237,15 +215,8 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn)
237#endif 215#endif
238 struct iovec *iov = conn->ksnc_rx_iov; 216 struct iovec *iov = conn->ksnc_rx_iov;
239 struct msghdr msg = { 217 struct msghdr msg = {
240 .msg_name = NULL,
241 .msg_namelen = 0,
242 .msg_iov = scratchiov,
243 .msg_iovlen = niov,
244 .msg_control = NULL,
245 .msg_controllen = 0,
246 .msg_flags = 0 218 .msg_flags = 0
247 }; 219 };
248 mm_segment_t oldmm = get_fs();
249 int nob; 220 int nob;
250 int i; 221 int i;
251 int rc; 222 int rc;
@@ -263,10 +234,8 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn)
263 } 234 }
264 LASSERT (nob <= conn->ksnc_rx_nob_wanted); 235 LASSERT (nob <= conn->ksnc_rx_nob_wanted);
265 236
266 set_fs (KERNEL_DS); 237 rc = kernel_recvmsg(conn->ksnc_sock, &msg,
267 rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); 238 (struct kvec *)scratchiov, niov, nob, MSG_DONTWAIT);
268 /* NB this is just a boolean..........................^ */
269 set_fs (oldmm);
270 239
271 saved_csum = 0; 240 saved_csum = 0;
272 if (conn->ksnc_proto == &ksocknal_protocol_v2x) { 241 if (conn->ksnc_proto == &ksocknal_protocol_v2x) {
@@ -355,14 +324,8 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
355#endif 324#endif
356 lnet_kiov_t *kiov = conn->ksnc_rx_kiov; 325 lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
357 struct msghdr msg = { 326 struct msghdr msg = {
358 .msg_name = NULL,
359 .msg_namelen = 0,
360 .msg_iov = scratchiov,
361 .msg_control = NULL,
362 .msg_controllen = 0,
363 .msg_flags = 0 327 .msg_flags = 0
364 }; 328 };
365 mm_segment_t oldmm = get_fs();
366 int nob; 329 int nob;
367 int i; 330 int i;
368 int rc; 331 int rc;
@@ -370,13 +333,14 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
370 void *addr; 333 void *addr;
371 int sum; 334 int sum;
372 int fragnob; 335 int fragnob;
336 int n;
373 337
374 /* NB we can't trust socket ops to either consume our iovs 338 /* NB we can't trust socket ops to either consume our iovs
375 * or leave them alone. */ 339 * or leave them alone. */
376 addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages); 340 addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages);
377 if (addr != NULL) { 341 if (addr != NULL) {
378 nob = scratchiov[0].iov_len; 342 nob = scratchiov[0].iov_len;
379 msg.msg_iovlen = 1; 343 n = 1;
380 344
381 } else { 345 } else {
382 for (nob = i = 0; i < niov; i++) { 346 for (nob = i = 0; i < niov; i++) {
@@ -384,15 +348,13 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
384 scratchiov[i].iov_base = kmap(kiov[i].kiov_page) + 348 scratchiov[i].iov_base = kmap(kiov[i].kiov_page) +
385 kiov[i].kiov_offset; 349 kiov[i].kiov_offset;
386 } 350 }
387 msg.msg_iovlen = niov; 351 n = niov;
388 } 352 }
389 353
390 LASSERT (nob <= conn->ksnc_rx_nob_wanted); 354 LASSERT (nob <= conn->ksnc_rx_nob_wanted);
391 355
392 set_fs (KERNEL_DS); 356 rc = kernel_recvmsg(conn->ksnc_sock, &msg,
393 rc = sock_recvmsg (conn->ksnc_sock, &msg, nob, MSG_DONTWAIT); 357 (struct kvec *)scratchiov, n, nob, MSG_DONTWAIT);
394 /* NB this is just a boolean.......................^ */
395 set_fs (oldmm);
396 358
397 if (conn->ksnc_msg.ksm_csum != 0) { 359 if (conn->ksnc_msg.ksm_csum != 0) {
398 for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) { 360 for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
@@ -655,7 +617,7 @@ extern void ksocknal_write_callback (ksock_conn_t *conn);
655 * socket call back in Linux 617 * socket call back in Linux
656 */ 618 */
657static void 619static void
658ksocknal_data_ready (struct sock *sk, int n) 620ksocknal_data_ready (struct sock *sk)
659{ 621{
660 ksock_conn_t *conn; 622 ksock_conn_t *conn;
661 623
@@ -666,7 +628,7 @@ ksocknal_data_ready (struct sock *sk, int n)
666 conn = sk->sk_user_data; 628 conn = sk->sk_user_data;
667 if (conn == NULL) { /* raced with ksocknal_terminate_conn */ 629 if (conn == NULL) { /* raced with ksocknal_terminate_conn */
668 LASSERT (sk->sk_data_ready != &ksocknal_data_ready); 630 LASSERT (sk->sk_data_ready != &ksocknal_data_ready);
669 sk->sk_data_ready (sk, n); 631 sk->sk_data_ready (sk);
670 } else 632 } else
671 ksocknal_read_callback(conn); 633 ksocknal_read_callback(conn);
672 634
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
index e6069d78af6b..7539fe16d76f 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
@@ -265,17 +265,11 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
265 * empty enough to take the whole message immediately */ 265 * empty enough to take the whole message immediately */
266 266
267 for (;;) { 267 for (;;) {
268 struct iovec iov = { 268 struct kvec iov = {
269 .iov_base = buffer, 269 .iov_base = buffer,
270 .iov_len = nob 270 .iov_len = nob
271 }; 271 };
272 struct msghdr msg = { 272 struct msghdr msg = {
273 .msg_name = NULL,
274 .msg_namelen = 0,
275 .msg_iov = &iov,
276 .msg_iovlen = 1,
277 .msg_control = NULL,
278 .msg_controllen = 0,
279 .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0 273 .msg_flags = (timeout == 0) ? MSG_DONTWAIT : 0
280 }; 274 };
281 275
@@ -297,11 +291,9 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout)
297 } 291 }
298 } 292 }
299 293
300 set_fs (KERNEL_DS);
301 then = jiffies; 294 then = jiffies;
302 rc = sock_sendmsg (sock, &msg, iov.iov_len); 295 rc = kernel_sendmsg(sock, &msg, &iov, 1, nob);
303 ticks -= jiffies - then; 296 ticks -= jiffies - then;
304 set_fs (oldmm);
305 297
306 if (rc == nob) 298 if (rc == nob)
307 return 0; 299 return 0;
@@ -338,17 +330,11 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
338 LASSERT (ticks > 0); 330 LASSERT (ticks > 0);
339 331
340 for (;;) { 332 for (;;) {
341 struct iovec iov = { 333 struct kvec iov = {
342 .iov_base = buffer, 334 .iov_base = buffer,
343 .iov_len = nob 335 .iov_len = nob
344 }; 336 };
345 struct msghdr msg = { 337 struct msghdr msg = {
346 .msg_name = NULL,
347 .msg_namelen = 0,
348 .msg_iov = &iov,
349 .msg_iovlen = 1,
350 .msg_control = NULL,
351 .msg_controllen = 0,
352 .msg_flags = 0 338 .msg_flags = 0
353 }; 339 };
354 340
@@ -367,11 +353,9 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout)
367 return rc; 353 return rc;
368 } 354 }
369 355
370 set_fs(KERNEL_DS);
371 then = jiffies; 356 then = jiffies;
372 rc = sock_recvmsg(sock, &msg, iov.iov_len, 0); 357 rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0);
373 ticks -= jiffies - then; 358 ticks -= jiffies - then;
374 set_fs(oldmm);
375 359
376 if (rc < 0) 360 if (rc < 0)
377 return rc; 361 return rc;
diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c
index ab06891f7fc7..80d48b5ae247 100644
--- a/drivers/staging/lustre/lustre/llite/symlink.c
+++ b/drivers/staging/lustre/lustre/llite/symlink.c
@@ -115,27 +115,6 @@ failed:
115 return rc; 115 return rc;
116} 116}
117 117
118static int ll_readlink(struct dentry *dentry, char *buffer, int buflen)
119{
120 struct inode *inode = dentry->d_inode;
121 struct ptlrpc_request *request;
122 char *symname;
123 int rc;
124
125 CDEBUG(D_VFSTRACE, "VFS Op\n");
126
127 ll_inode_size_lock(inode);
128 rc = ll_readlink_internal(inode, &request, &symname);
129 if (rc)
130 GOTO(out, rc);
131
132 rc = vfs_readlink(dentry, buffer, buflen, symname);
133 out:
134 ptlrpc_req_finished(request);
135 ll_inode_size_unlock(inode);
136 return rc;
137}
138
139static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) 118static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd)
140{ 119{
141 struct inode *inode = dentry->d_inode; 120 struct inode *inode = dentry->d_inode;
@@ -175,7 +154,7 @@ static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cooki
175} 154}
176 155
177struct inode_operations ll_fast_symlink_inode_operations = { 156struct inode_operations ll_fast_symlink_inode_operations = {
178 .readlink = ll_readlink, 157 .readlink = generic_readlink,
179 .setattr = ll_setattr, 158 .setattr = ll_setattr,
180 .follow_link = ll_follow_link, 159 .follow_link = ll_follow_link,
181 .put_link = ll_put_link, 160 .put_link = ll_put_link,
diff --git a/drivers/staging/media/msi3101/msi001.c b/drivers/staging/media/msi3101/msi001.c
index ac43bae10102..bd0b93cb6c53 100644
--- a/drivers/staging/media/msi3101/msi001.c
+++ b/drivers/staging/media/msi3101/msi001.c
@@ -201,7 +201,7 @@ static int msi001_set_tuner(struct msi001 *s)
201 dev_dbg(&s->spi->dev, "%s: bandwidth selected=%d\n", 201 dev_dbg(&s->spi->dev, "%s: bandwidth selected=%d\n",
202 __func__, bandwidth_lut[i].freq); 202 __func__, bandwidth_lut[i].freq);
203 203
204 f_vco = (f_rf + f_if + f_if1) * lo_div; 204 f_vco = (u64) (f_rf + f_if + f_if1) * lo_div;
205 tmp64 = f_vco; 205 tmp64 = f_vco;
206 m = do_div(tmp64, F_REF * R_REF); 206 m = do_div(tmp64, F_REF * R_REF);
207 n = (unsigned int) tmp64; 207 n = (unsigned int) tmp64;
diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
index 260d1b736721..65d351f99da2 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -913,7 +913,6 @@ static int msi3101_set_usb_adc(struct msi3101_state *s)
913 913
914 /* set tuner, subdev, filters according to sampling rate */ 914 /* set tuner, subdev, filters according to sampling rate */
915 bandwidth_auto = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO); 915 bandwidth_auto = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
916 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
917 if (v4l2_ctrl_g_ctrl(bandwidth_auto)) { 916 if (v4l2_ctrl_g_ctrl(bandwidth_auto)) {
918 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH); 917 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
919 v4l2_ctrl_s_ctrl(bandwidth, s->f_adc); 918 v4l2_ctrl_s_ctrl(bandwidth, s->f_adc);
@@ -1078,6 +1077,7 @@ static int msi3101_start_streaming(struct vb2_queue *vq, unsigned int count)
1078static int msi3101_stop_streaming(struct vb2_queue *vq) 1077static int msi3101_stop_streaming(struct vb2_queue *vq)
1079{ 1078{
1080 struct msi3101_state *s = vb2_get_drv_priv(vq); 1079 struct msi3101_state *s = vb2_get_drv_priv(vq);
1080 int ret;
1081 dev_dbg(&s->udev->dev, "%s:\n", __func__); 1081 dev_dbg(&s->udev->dev, "%s:\n", __func__);
1082 1082
1083 if (mutex_lock_interruptible(&s->v4l2_lock)) 1083 if (mutex_lock_interruptible(&s->v4l2_lock))
@@ -1090,17 +1090,22 @@ static int msi3101_stop_streaming(struct vb2_queue *vq)
1090 1090
1091 /* according to tests, at least 700us delay is required */ 1091 /* according to tests, at least 700us delay is required */
1092 msleep(20); 1092 msleep(20);
1093 msi3101_ctrl_msg(s, CMD_STOP_STREAMING, 0); 1093 ret = msi3101_ctrl_msg(s, CMD_STOP_STREAMING, 0);
1094 if (ret)
1095 goto err_sleep_tuner;
1094 1096
1095 /* sleep USB IF / ADC */ 1097 /* sleep USB IF / ADC */
1096 msi3101_ctrl_msg(s, CMD_WREG, 0x01000003); 1098 ret = msi3101_ctrl_msg(s, CMD_WREG, 0x01000003);
1099 if (ret)
1100 goto err_sleep_tuner;
1097 1101
1102err_sleep_tuner:
1098 /* sleep tuner */ 1103 /* sleep tuner */
1099 v4l2_subdev_call(s->v4l2_subdev, core, s_power, 0); 1104 ret = v4l2_subdev_call(s->v4l2_subdev, core, s_power, 0);
1100 1105
1101 mutex_unlock(&s->v4l2_lock); 1106 mutex_unlock(&s->v4l2_lock);
1102 1107
1103 return 0; 1108 return ret;
1104} 1109}
1105 1110
1106static struct vb2_ops msi3101_vb2_ops = { 1111static struct vb2_ops msi3101_vb2_ops = {
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 773d8ca07a00..de692d7011a5 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -86,7 +86,6 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
86 struct stub_device *sdev = dev_get_drvdata(dev); 86 struct stub_device *sdev = dev_get_drvdata(dev);
87 int sockfd = 0; 87 int sockfd = 0;
88 struct socket *socket; 88 struct socket *socket;
89 ssize_t err = -EINVAL;
90 int rv; 89 int rv;
91 90
92 if (!sdev) { 91 if (!sdev) {
@@ -99,6 +98,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
99 return -EINVAL; 98 return -EINVAL;
100 99
101 if (sockfd != -1) { 100 if (sockfd != -1) {
101 int err;
102 dev_info(dev, "stub up\n"); 102 dev_info(dev, "stub up\n");
103 103
104 spin_lock_irq(&sdev->ud.lock); 104 spin_lock_irq(&sdev->ud.lock);
@@ -108,7 +108,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
108 goto err; 108 goto err;
109 } 109 }
110 110
111 socket = sockfd_to_socket(sockfd); 111 socket = sockfd_lookup(sockfd, &err);
112 if (!socket) 112 if (!socket)
113 goto err; 113 goto err;
114 114
@@ -141,7 +141,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
141 141
142err: 142err:
143 spin_unlock_irq(&sdev->ud.lock); 143 spin_unlock_irq(&sdev->ud.lock);
144 return err; 144 return -EINVAL;
145} 145}
146static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd); 146static DEVICE_ATTR(usbip_sockfd, S_IWUSR, NULL, store_sockfd);
147 147
@@ -211,7 +211,7 @@ static void stub_shutdown_connection(struct usbip_device *ud)
211 * not touch NULL socket. 211 * not touch NULL socket.
212 */ 212 */
213 if (ud->tcp_socket) { 213 if (ud->tcp_socket) {
214 fput(ud->tcp_socket->file); 214 sockfd_put(ud->tcp_socket);
215 ud->tcp_socket = NULL; 215 ud->tcp_socket = NULL;
216 } 216 }
217 217
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 184fa70365db..facaaf003f19 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -382,31 +382,6 @@ err:
382} 382}
383EXPORT_SYMBOL_GPL(usbip_recv); 383EXPORT_SYMBOL_GPL(usbip_recv);
384 384
385struct socket *sockfd_to_socket(unsigned int sockfd)
386{
387 struct socket *socket;
388 struct file *file;
389 struct inode *inode;
390
391 file = fget(sockfd);
392 if (!file) {
393 pr_err("invalid sockfd\n");
394 return NULL;
395 }
396
397 inode = file_inode(file);
398
399 if (!inode || !S_ISSOCK(inode->i_mode)) {
400 fput(file);
401 return NULL;
402 }
403
404 socket = SOCKET_I(inode);
405
406 return socket;
407}
408EXPORT_SYMBOL_GPL(sockfd_to_socket);
409
410/* there may be more cases to tweak the flags. */ 385/* there may be more cases to tweak the flags. */
411static unsigned int tweak_transfer_flags(unsigned int flags) 386static unsigned int tweak_transfer_flags(unsigned int flags)
412{ 387{
diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
index 732fb636a1e5..f555d834f134 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/staging/usbip/usbip_common.h
@@ -299,7 +299,6 @@ void usbip_dump_urb(struct urb *purb);
299void usbip_dump_header(struct usbip_header *pdu); 299void usbip_dump_header(struct usbip_header *pdu);
300 300
301int usbip_recv(struct socket *sock, void *buf, int size); 301int usbip_recv(struct socket *sock, void *buf, int size);
302struct socket *sockfd_to_socket(unsigned int sockfd);
303 302
304void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd, 303void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
305 int pack); 304 int pack);
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index 1e84577230ef..70e17551943d 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -788,7 +788,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
788 788
789 /* active connection is closed */ 789 /* active connection is closed */
790 if (vdev->ud.tcp_socket) { 790 if (vdev->ud.tcp_socket) {
791 fput(vdev->ud.tcp_socket->file); 791 sockfd_put(vdev->ud.tcp_socket);
792 vdev->ud.tcp_socket = NULL; 792 vdev->ud.tcp_socket = NULL;
793 } 793 }
794 pr_info("release socket\n"); 794 pr_info("release socket\n");
@@ -835,7 +835,7 @@ static void vhci_device_reset(struct usbip_device *ud)
835 vdev->udev = NULL; 835 vdev->udev = NULL;
836 836
837 if (ud->tcp_socket) { 837 if (ud->tcp_socket) {
838 fput(ud->tcp_socket->file); 838 sockfd_put(ud->tcp_socket);
839 ud->tcp_socket = NULL; 839 ud->tcp_socket = NULL;
840 } 840 }
841 ud->status = VDEV_ST_NULL; 841 ud->status = VDEV_ST_NULL;
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c
index e0980324fb03..47bddcdde0a6 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -176,6 +176,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
176 struct socket *socket; 176 struct socket *socket;
177 int sockfd = 0; 177 int sockfd = 0;
178 __u32 rhport = 0, devid = 0, speed = 0; 178 __u32 rhport = 0, devid = 0, speed = 0;
179 int err;
179 180
180 /* 181 /*
181 * @rhport: port number of vhci_hcd 182 * @rhport: port number of vhci_hcd
@@ -194,8 +195,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
194 return -EINVAL; 195 return -EINVAL;
195 196
196 /* Extract socket from fd. */ 197 /* Extract socket from fd. */
197 /* The correct way to clean this up is to fput(socket->file). */ 198 socket = sockfd_lookup(sockfd, &err);
198 socket = sockfd_to_socket(sockfd);
199 if (!socket) 199 if (!socket)
200 return -EINVAL; 200 return -EINVAL;
201 201
@@ -211,7 +211,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
211 spin_unlock(&vdev->ud.lock); 211 spin_unlock(&vdev->ud.lock);
212 spin_unlock(&the_controller->lock); 212 spin_unlock(&the_controller->lock);
213 213
214 fput(socket->file); 214 sockfd_put(socket);
215 215
216 dev_err(dev, "port %d already used\n", rhport); 216 dev_err(dev, "port %d already used\n", rhport);
217 return -EINVAL; 217 return -EINVAL;
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index b83ec378d04f..78cab13bbb1b 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -499,6 +499,23 @@ static int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
499 return 0; 499 return 0;
500} 500}
501 501
502static void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
503{
504 bool scsi_cmd = (cmd->iscsi_opcode == ISCSI_OP_SCSI_CMD);
505
506 spin_lock_bh(&conn->cmd_lock);
507 if (!list_empty(&cmd->i_conn_node))
508 list_del_init(&cmd->i_conn_node);
509 spin_unlock_bh(&conn->cmd_lock);
510
511 __iscsit_free_cmd(cmd, scsi_cmd, true);
512}
513
514static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)
515{
516 return TARGET_PROT_NORMAL;
517}
518
502static struct iscsit_transport iscsi_target_transport = { 519static struct iscsit_transport iscsi_target_transport = {
503 .name = "iSCSI/TCP", 520 .name = "iSCSI/TCP",
504 .transport_type = ISCSI_TCP, 521 .transport_type = ISCSI_TCP,
@@ -513,6 +530,8 @@ static struct iscsit_transport iscsi_target_transport = {
513 .iscsit_response_queue = iscsit_response_queue, 530 .iscsit_response_queue = iscsit_response_queue,
514 .iscsit_queue_data_in = iscsit_queue_rsp, 531 .iscsit_queue_data_in = iscsit_queue_rsp,
515 .iscsit_queue_status = iscsit_queue_rsp, 532 .iscsit_queue_status = iscsit_queue_rsp,
533 .iscsit_aborted_task = iscsit_aborted_task,
534 .iscsit_get_sup_prot_ops = iscsit_get_sup_prot_ops,
516}; 535};
517 536
518static int __init iscsi_target_init_module(void) 537static int __init iscsi_target_init_module(void)
@@ -1503,6 +1522,16 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1503{ 1522{
1504 u32 payload_length = ntoh24(hdr->dlength); 1523 u32 payload_length = ntoh24(hdr->dlength);
1505 1524
1525 if (!(hdr->flags & ISCSI_FLAG_CMD_FINAL)) {
1526 pr_err("NopOUT Flag's, Left Most Bit not set, protocol error.\n");
1527 if (!cmd)
1528 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,
1529 (unsigned char *)hdr);
1530
1531 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
1532 (unsigned char *)hdr);
1533 }
1534
1506 if (hdr->itt == RESERVED_ITT && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) { 1535 if (hdr->itt == RESERVED_ITT && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) {
1507 pr_err("NOPOUT ITT is reserved, but Immediate Bit is" 1536 pr_err("NOPOUT ITT is reserved, but Immediate Bit is"
1508 " not set, protocol error.\n"); 1537 " not set, protocol error.\n");
@@ -2468,6 +2497,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
2468{ 2497{
2469 struct iscsi_cmd *cmd; 2498 struct iscsi_cmd *cmd;
2470 struct iscsi_conn *conn_p; 2499 struct iscsi_conn *conn_p;
2500 bool found = false;
2471 2501
2472 /* 2502 /*
2473 * Only send a Asynchronous Message on connections whos network 2503 * Only send a Asynchronous Message on connections whos network
@@ -2476,11 +2506,12 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
2476 list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) { 2506 list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) {
2477 if (conn_p->conn_state == TARG_CONN_STATE_LOGGED_IN) { 2507 if (conn_p->conn_state == TARG_CONN_STATE_LOGGED_IN) {
2478 iscsit_inc_conn_usage_count(conn_p); 2508 iscsit_inc_conn_usage_count(conn_p);
2509 found = true;
2479 break; 2510 break;
2480 } 2511 }
2481 } 2512 }
2482 2513
2483 if (!conn_p) 2514 if (!found)
2484 return; 2515 return;
2485 2516
2486 cmd = iscsit_allocate_cmd(conn_p, TASK_RUNNING); 2517 cmd = iscsit_allocate_cmd(conn_p, TASK_RUNNING);
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 1c0088fe9e99..ae03f3e5de1e 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1052,6 +1052,11 @@ TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR);
1052 */ 1052 */
1053DEF_TPG_ATTRIB(default_erl); 1053DEF_TPG_ATTRIB(default_erl);
1054TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); 1054TPG_ATTR(default_erl, S_IRUGO | S_IWUSR);
1055/*
1056 * Define iscsi_tpg_attrib_s_t10_pi
1057 */
1058DEF_TPG_ATTRIB(t10_pi);
1059TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR);
1055 1060
1056static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { 1061static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
1057 &iscsi_tpg_attrib_authentication.attr, 1062 &iscsi_tpg_attrib_authentication.attr,
@@ -1064,6 +1069,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
1064 &iscsi_tpg_attrib_prod_mode_write_protect.attr, 1069 &iscsi_tpg_attrib_prod_mode_write_protect.attr,
1065 &iscsi_tpg_attrib_demo_mode_discovery.attr, 1070 &iscsi_tpg_attrib_demo_mode_discovery.attr,
1066 &iscsi_tpg_attrib_default_erl.attr, 1071 &iscsi_tpg_attrib_default_erl.attr,
1072 &iscsi_tpg_attrib_t10_pi.attr,
1067 NULL, 1073 NULL,
1068}; 1074};
1069 1075
@@ -1815,6 +1821,13 @@ static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
1815 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); 1821 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
1816} 1822}
1817 1823
1824static void lio_aborted_task(struct se_cmd *se_cmd)
1825{
1826 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1827
1828 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1829}
1830
1818static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg) 1831static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1819{ 1832{
1820 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1833 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
@@ -1999,6 +2012,7 @@ int iscsi_target_register_configfs(void)
1999 fabric->tf_ops.queue_data_in = &lio_queue_data_in; 2012 fabric->tf_ops.queue_data_in = &lio_queue_data_in;
2000 fabric->tf_ops.queue_status = &lio_queue_status; 2013 fabric->tf_ops.queue_status = &lio_queue_status;
2001 fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp; 2014 fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp;
2015 fabric->tf_ops.aborted_task = &lio_aborted_task;
2002 /* 2016 /*
2003 * Setup function pointers for generic logic in target_core_fabric_configfs.c 2017 * Setup function pointers for generic logic in target_core_fabric_configfs.c
2004 */ 2018 */
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index 48f7b3bf4e8c..6960f22909ae 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -58,7 +58,8 @@
58#define TA_DEMO_MODE_DISCOVERY 1 58#define TA_DEMO_MODE_DISCOVERY 1
59#define TA_DEFAULT_ERL 0 59#define TA_DEFAULT_ERL 0
60#define TA_CACHE_CORE_NPS 0 60#define TA_CACHE_CORE_NPS 0
61 61/* T10 protection information disabled by default */
62#define TA_DEFAULT_T10_PI 0
62 63
63#define ISCSI_IOV_DATA_BUFFER 5 64#define ISCSI_IOV_DATA_BUFFER 5
64 65
@@ -556,7 +557,7 @@ struct iscsi_conn {
556 struct completion rx_half_close_comp; 557 struct completion rx_half_close_comp;
557 /* socket used by this connection */ 558 /* socket used by this connection */
558 struct socket *sock; 559 struct socket *sock;
559 void (*orig_data_ready)(struct sock *, int); 560 void (*orig_data_ready)(struct sock *);
560 void (*orig_state_change)(struct sock *); 561 void (*orig_state_change)(struct sock *);
561#define LOGIN_FLAGS_READ_ACTIVE 1 562#define LOGIN_FLAGS_READ_ACTIVE 1
562#define LOGIN_FLAGS_CLOSED 2 563#define LOGIN_FLAGS_CLOSED 2
@@ -765,6 +766,7 @@ struct iscsi_tpg_attrib {
765 u32 prod_mode_write_protect; 766 u32 prod_mode_write_protect;
766 u32 demo_mode_discovery; 767 u32 demo_mode_discovery;
767 u32 default_erl; 768 u32 default_erl;
769 u8 t10_pi;
768 struct iscsi_portal_group *tpg; 770 struct iscsi_portal_group *tpg;
769}; 771};
770 772
@@ -787,6 +789,7 @@ struct iscsi_np {
787 void *np_context; 789 void *np_context;
788 struct iscsit_transport *np_transport; 790 struct iscsit_transport *np_transport;
789 struct list_head np_list; 791 struct list_head np_list;
792 struct iscsi_tpg_np *tpg_np;
790} ____cacheline_aligned; 793} ____cacheline_aligned;
791 794
792struct iscsi_tpg_np { 795struct iscsi_tpg_np {
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index e29279e6b577..8739b98f6f93 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -259,6 +259,7 @@ static int iscsi_login_zero_tsih_s1(
259{ 259{
260 struct iscsi_session *sess = NULL; 260 struct iscsi_session *sess = NULL;
261 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; 261 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
262 enum target_prot_op sup_pro_ops;
262 int ret; 263 int ret;
263 264
264 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL); 265 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
@@ -320,8 +321,9 @@ static int iscsi_login_zero_tsih_s1(
320 kfree(sess); 321 kfree(sess);
321 return -ENOMEM; 322 return -ENOMEM;
322 } 323 }
324 sup_pro_ops = conn->conn_transport->iscsit_get_sup_prot_ops(conn);
323 325
324 sess->se_sess = transport_init_session(); 326 sess->se_sess = transport_init_session(sup_pro_ops);
325 if (IS_ERR(sess->se_sess)) { 327 if (IS_ERR(sess->se_sess)) {
326 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 328 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
327 ISCSI_LOGIN_STATUS_NO_RESOURCES); 329 ISCSI_LOGIN_STATUS_NO_RESOURCES);
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
index 582ba84075ec..75b685960e80 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -375,7 +375,7 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
375 return 0; 375 return 0;
376} 376}
377 377
378static void iscsi_target_sk_data_ready(struct sock *sk, int count) 378static void iscsi_target_sk_data_ready(struct sock *sk)
379{ 379{
380 struct iscsi_conn *conn = sk->sk_user_data; 380 struct iscsi_conn *conn = sk->sk_user_data;
381 bool rc; 381 bool rc;
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index 44a5471de00f..eb96b20dc09e 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -225,6 +225,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
225 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT; 225 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT;
226 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY; 226 a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY;
227 a->default_erl = TA_DEFAULT_ERL; 227 a->default_erl = TA_DEFAULT_ERL;
228 a->t10_pi = TA_DEFAULT_T10_PI;
228} 229}
229 230
230int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg) 231int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
@@ -500,6 +501,7 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
500 init_completion(&tpg_np->tpg_np_comp); 501 init_completion(&tpg_np->tpg_np_comp);
501 kref_init(&tpg_np->tpg_np_kref); 502 kref_init(&tpg_np->tpg_np_kref);
502 tpg_np->tpg_np = np; 503 tpg_np->tpg_np = np;
504 np->tpg_np = tpg_np;
503 tpg_np->tpg = tpg; 505 tpg_np->tpg = tpg;
504 506
505 spin_lock(&tpg->tpg_np_lock); 507 spin_lock(&tpg->tpg_np_lock);
@@ -858,3 +860,22 @@ int iscsit_ta_default_erl(
858 860
859 return 0; 861 return 0;
860} 862}
863
864int iscsit_ta_t10_pi(
865 struct iscsi_portal_group *tpg,
866 u32 flag)
867{
868 struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
869
870 if ((flag != 0) && (flag != 1)) {
871 pr_err("Illegal value %d\n", flag);
872 return -EINVAL;
873 }
874
875 a->t10_pi = flag;
876 pr_debug("iSCSI_TPG[%hu] - T10 Protection information bit:"
877 " %s\n", tpg->tpgt, (a->t10_pi) ?
878 "ON" : "OFF");
879
880 return 0;
881}
diff --git a/drivers/target/iscsi/iscsi_target_tpg.h b/drivers/target/iscsi/iscsi_target_tpg.h
index 213c0fc7fdc9..0a182f2aa8a2 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.h
+++ b/drivers/target/iscsi/iscsi_target_tpg.h
@@ -39,5 +39,6 @@ extern int iscsit_ta_demo_mode_write_protect(struct iscsi_portal_group *, u32);
39extern int iscsit_ta_prod_mode_write_protect(struct iscsi_portal_group *, u32); 39extern int iscsit_ta_prod_mode_write_protect(struct iscsi_portal_group *, u32);
40extern int iscsit_ta_demo_mode_discovery(struct iscsi_portal_group *, u32); 40extern int iscsit_ta_demo_mode_discovery(struct iscsi_portal_group *, u32);
41extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32); 41extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32);
42extern int iscsit_ta_t10_pi(struct iscsi_portal_group *, u32);
42 43
43#endif /* ISCSI_TARGET_TPG_H */ 44#endif /* ISCSI_TARGET_TPG_H */
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index e655b042ed18..53e157cb8c54 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -705,8 +705,8 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
705} 705}
706EXPORT_SYMBOL(iscsit_release_cmd); 706EXPORT_SYMBOL(iscsit_release_cmd);
707 707
708static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, 708void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,
709 bool check_queues) 709 bool check_queues)
710{ 710{
711 struct iscsi_conn *conn = cmd->conn; 711 struct iscsi_conn *conn = cmd->conn;
712 712
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h
index 561a424d1980..a68508c4fec8 100644
--- a/drivers/target/iscsi/iscsi_target_util.h
+++ b/drivers/target/iscsi/iscsi_target_util.h
@@ -30,6 +30,7 @@ extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_co
30extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); 30extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *);
31extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); 31extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
32extern void iscsit_release_cmd(struct iscsi_cmd *); 32extern void iscsit_release_cmd(struct iscsi_cmd *);
33extern void __iscsit_free_cmd(struct iscsi_cmd *, bool, bool);
33extern void iscsit_free_cmd(struct iscsi_cmd *, bool); 34extern void iscsit_free_cmd(struct iscsi_cmd *, bool);
34extern int iscsit_check_session_usage_count(struct iscsi_session *); 35extern int iscsit_check_session_usage_count(struct iscsi_session *);
35extern void iscsit_dec_session_usage_count(struct iscsi_session *); 36extern void iscsit_dec_session_usage_count(struct iscsi_session *);
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index fadad7c5f635..c886ad1c39fb 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -212,6 +212,10 @@ static void tcm_loop_submission_work(struct work_struct *work)
212 se_cmd->se_cmd_flags |= SCF_BIDI; 212 se_cmd->se_cmd_flags |= SCF_BIDI;
213 213
214 } 214 }
215
216 if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
217 se_cmd->prot_pto = true;
218
215 rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, 219 rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
216 &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, 220 &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
217 scsi_bufflen(sc), tcm_loop_sam_attr(sc), 221 scsi_bufflen(sc), tcm_loop_sam_attr(sc),
@@ -915,6 +919,11 @@ static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
915 wake_up(&tl_tmr->tl_tmr_wait); 919 wake_up(&tl_tmr->tl_tmr_wait);
916} 920}
917 921
922static void tcm_loop_aborted_task(struct se_cmd *se_cmd)
923{
924 return;
925}
926
918static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba) 927static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
919{ 928{
920 switch (tl_hba->tl_proto_id) { 929 switch (tl_hba->tl_proto_id) {
@@ -1009,7 +1018,7 @@ static int tcm_loop_make_nexus(
1009 /* 1018 /*
1010 * Initialize the struct se_session pointer 1019 * Initialize the struct se_session pointer
1011 */ 1020 */
1012 tl_nexus->se_sess = transport_init_session(); 1021 tl_nexus->se_sess = transport_init_session(TARGET_PROT_ALL);
1013 if (IS_ERR(tl_nexus->se_sess)) { 1022 if (IS_ERR(tl_nexus->se_sess)) {
1014 ret = PTR_ERR(tl_nexus->se_sess); 1023 ret = PTR_ERR(tl_nexus->se_sess);
1015 goto out; 1024 goto out;
@@ -1483,6 +1492,7 @@ static int tcm_loop_register_configfs(void)
1483 fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in; 1492 fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in;
1484 fabric->tf_ops.queue_status = &tcm_loop_queue_status; 1493 fabric->tf_ops.queue_status = &tcm_loop_queue_status;
1485 fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp; 1494 fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp;
1495 fabric->tf_ops.aborted_task = &tcm_loop_aborted_task;
1486 1496
1487 /* 1497 /*
1488 * Setup function pointers for generic logic in target_core_fabric_configfs.c 1498 * Setup function pointers for generic logic in target_core_fabric_configfs.c
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 24884cac19ce..e7e93727553c 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -210,7 +210,7 @@ static struct sbp_session *sbp_session_create(
210 return ERR_PTR(-ENOMEM); 210 return ERR_PTR(-ENOMEM);
211 } 211 }
212 212
213 sess->se_sess = transport_init_session(); 213 sess->se_sess = transport_init_session(TARGET_PROT_NORMAL);
214 if (IS_ERR(sess->se_sess)) { 214 if (IS_ERR(sess->se_sess)) {
215 pr_err("failed to init se_session\n"); 215 pr_err("failed to init se_session\n");
216 216
@@ -1846,6 +1846,11 @@ static void sbp_queue_tm_rsp(struct se_cmd *se_cmd)
1846{ 1846{
1847} 1847}
1848 1848
1849static void sbp_aborted_task(struct se_cmd *se_cmd)
1850{
1851 return;
1852}
1853
1849static int sbp_check_stop_free(struct se_cmd *se_cmd) 1854static int sbp_check_stop_free(struct se_cmd *se_cmd)
1850{ 1855{
1851 struct sbp_target_request *req = container_of(se_cmd, 1856 struct sbp_target_request *req = container_of(se_cmd,
@@ -2526,6 +2531,7 @@ static struct target_core_fabric_ops sbp_ops = {
2526 .queue_data_in = sbp_queue_data_in, 2531 .queue_data_in = sbp_queue_data_in,
2527 .queue_status = sbp_queue_status, 2532 .queue_status = sbp_queue_status,
2528 .queue_tm_rsp = sbp_queue_tm_rsp, 2533 .queue_tm_rsp = sbp_queue_tm_rsp,
2534 .aborted_task = sbp_aborted_task,
2529 .check_stop_free = sbp_check_stop_free, 2535 .check_stop_free = sbp_check_stop_free,
2530 2536
2531 .fabric_make_wwn = sbp_make_tport, 2537 .fabric_make_wwn = sbp_make_tport,
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index c3d9df6aaf5f..fcbe6125b73e 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -455,11 +455,26 @@ out:
455 return rc; 455 return rc;
456} 456}
457 457
458static inline int core_alua_state_nonoptimized( 458static inline void set_ascq(struct se_cmd *cmd, u8 alua_ascq)
459{
460 /*
461 * Set SCSI additional sense code (ASC) to 'LUN Not Accessible';
462 * The ALUA additional sense code qualifier (ASCQ) is determined
463 * by the ALUA primary or secondary access state..
464 */
465 pr_debug("[%s]: ALUA TG Port not available, "
466 "SenseKey: NOT_READY, ASC/ASCQ: "
467 "0x04/0x%02x\n",
468 cmd->se_tfo->get_fabric_name(), alua_ascq);
469
470 cmd->scsi_asc = 0x04;
471 cmd->scsi_ascq = alua_ascq;
472}
473
474static inline void core_alua_state_nonoptimized(
459 struct se_cmd *cmd, 475 struct se_cmd *cmd,
460 unsigned char *cdb, 476 unsigned char *cdb,
461 int nonop_delay_msecs, 477 int nonop_delay_msecs)
462 u8 *alua_ascq)
463{ 478{
464 /* 479 /*
465 * Set SCF_ALUA_NON_OPTIMIZED here, this value will be checked 480 * Set SCF_ALUA_NON_OPTIMIZED here, this value will be checked
@@ -468,13 +483,11 @@ static inline int core_alua_state_nonoptimized(
468 */ 483 */
469 cmd->se_cmd_flags |= SCF_ALUA_NON_OPTIMIZED; 484 cmd->se_cmd_flags |= SCF_ALUA_NON_OPTIMIZED;
470 cmd->alua_nonop_delay = nonop_delay_msecs; 485 cmd->alua_nonop_delay = nonop_delay_msecs;
471 return 0;
472} 486}
473 487
474static inline int core_alua_state_lba_dependent( 488static inline int core_alua_state_lba_dependent(
475 struct se_cmd *cmd, 489 struct se_cmd *cmd,
476 struct t10_alua_tg_pt_gp *tg_pt_gp, 490 struct t10_alua_tg_pt_gp *tg_pt_gp)
477 u8 *alua_ascq)
478{ 491{
479 struct se_device *dev = cmd->se_dev; 492 struct se_device *dev = cmd->se_dev;
480 u64 segment_size, segment_mult, sectors, lba; 493 u64 segment_size, segment_mult, sectors, lba;
@@ -520,7 +533,7 @@ static inline int core_alua_state_lba_dependent(
520 } 533 }
521 if (!cur_map) { 534 if (!cur_map) {
522 spin_unlock(&dev->t10_alua.lba_map_lock); 535 spin_unlock(&dev->t10_alua.lba_map_lock);
523 *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE; 536 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
524 return 1; 537 return 1;
525 } 538 }
526 list_for_each_entry(map_mem, &cur_map->lba_map_mem_list, 539 list_for_each_entry(map_mem, &cur_map->lba_map_mem_list,
@@ -531,11 +544,11 @@ static inline int core_alua_state_lba_dependent(
531 switch(map_mem->lba_map_mem_alua_state) { 544 switch(map_mem->lba_map_mem_alua_state) {
532 case ALUA_ACCESS_STATE_STANDBY: 545 case ALUA_ACCESS_STATE_STANDBY:
533 spin_unlock(&dev->t10_alua.lba_map_lock); 546 spin_unlock(&dev->t10_alua.lba_map_lock);
534 *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY; 547 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
535 return 1; 548 return 1;
536 case ALUA_ACCESS_STATE_UNAVAILABLE: 549 case ALUA_ACCESS_STATE_UNAVAILABLE:
537 spin_unlock(&dev->t10_alua.lba_map_lock); 550 spin_unlock(&dev->t10_alua.lba_map_lock);
538 *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE; 551 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
539 return 1; 552 return 1;
540 default: 553 default:
541 break; 554 break;
@@ -548,8 +561,7 @@ static inline int core_alua_state_lba_dependent(
548 561
549static inline int core_alua_state_standby( 562static inline int core_alua_state_standby(
550 struct se_cmd *cmd, 563 struct se_cmd *cmd,
551 unsigned char *cdb, 564 unsigned char *cdb)
552 u8 *alua_ascq)
553{ 565{
554 /* 566 /*
555 * Allowed CDBs for ALUA_ACCESS_STATE_STANDBY as defined by 567 * Allowed CDBs for ALUA_ACCESS_STATE_STANDBY as defined by
@@ -570,7 +582,7 @@ static inline int core_alua_state_standby(
570 case MI_REPORT_TARGET_PGS: 582 case MI_REPORT_TARGET_PGS:
571 return 0; 583 return 0;
572 default: 584 default:
573 *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY; 585 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
574 return 1; 586 return 1;
575 } 587 }
576 case MAINTENANCE_OUT: 588 case MAINTENANCE_OUT:
@@ -578,7 +590,7 @@ static inline int core_alua_state_standby(
578 case MO_SET_TARGET_PGS: 590 case MO_SET_TARGET_PGS:
579 return 0; 591 return 0;
580 default: 592 default:
581 *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY; 593 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
582 return 1; 594 return 1;
583 } 595 }
584 case REQUEST_SENSE: 596 case REQUEST_SENSE:
@@ -588,7 +600,7 @@ static inline int core_alua_state_standby(
588 case WRITE_BUFFER: 600 case WRITE_BUFFER:
589 return 0; 601 return 0;
590 default: 602 default:
591 *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY; 603 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
592 return 1; 604 return 1;
593 } 605 }
594 606
@@ -597,8 +609,7 @@ static inline int core_alua_state_standby(
597 609
598static inline int core_alua_state_unavailable( 610static inline int core_alua_state_unavailable(
599 struct se_cmd *cmd, 611 struct se_cmd *cmd,
600 unsigned char *cdb, 612 unsigned char *cdb)
601 u8 *alua_ascq)
602{ 613{
603 /* 614 /*
604 * Allowed CDBs for ALUA_ACCESS_STATE_UNAVAILABLE as defined by 615 * Allowed CDBs for ALUA_ACCESS_STATE_UNAVAILABLE as defined by
@@ -613,7 +624,7 @@ static inline int core_alua_state_unavailable(
613 case MI_REPORT_TARGET_PGS: 624 case MI_REPORT_TARGET_PGS:
614 return 0; 625 return 0;
615 default: 626 default:
616 *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE; 627 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
617 return 1; 628 return 1;
618 } 629 }
619 case MAINTENANCE_OUT: 630 case MAINTENANCE_OUT:
@@ -621,7 +632,7 @@ static inline int core_alua_state_unavailable(
621 case MO_SET_TARGET_PGS: 632 case MO_SET_TARGET_PGS:
622 return 0; 633 return 0;
623 default: 634 default:
624 *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE; 635 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
625 return 1; 636 return 1;
626 } 637 }
627 case REQUEST_SENSE: 638 case REQUEST_SENSE:
@@ -629,7 +640,7 @@ static inline int core_alua_state_unavailable(
629 case WRITE_BUFFER: 640 case WRITE_BUFFER:
630 return 0; 641 return 0;
631 default: 642 default:
632 *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE; 643 set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
633 return 1; 644 return 1;
634 } 645 }
635 646
@@ -638,8 +649,7 @@ static inline int core_alua_state_unavailable(
638 649
639static inline int core_alua_state_transition( 650static inline int core_alua_state_transition(
640 struct se_cmd *cmd, 651 struct se_cmd *cmd,
641 unsigned char *cdb, 652 unsigned char *cdb)
642 u8 *alua_ascq)
643{ 653{
644 /* 654 /*
645 * Allowed CDBs for ALUA_ACCESS_STATE_TRANSITION as defined by 655 * Allowed CDBs for ALUA_ACCESS_STATE_TRANSITION as defined by
@@ -654,7 +664,7 @@ static inline int core_alua_state_transition(
654 case MI_REPORT_TARGET_PGS: 664 case MI_REPORT_TARGET_PGS:
655 return 0; 665 return 0;
656 default: 666 default:
657 *alua_ascq = ASCQ_04H_ALUA_STATE_TRANSITION; 667 set_ascq(cmd, ASCQ_04H_ALUA_STATE_TRANSITION);
658 return 1; 668 return 1;
659 } 669 }
660 case REQUEST_SENSE: 670 case REQUEST_SENSE:
@@ -662,7 +672,7 @@ static inline int core_alua_state_transition(
662 case WRITE_BUFFER: 672 case WRITE_BUFFER:
663 return 0; 673 return 0;
664 default: 674 default:
665 *alua_ascq = ASCQ_04H_ALUA_STATE_TRANSITION; 675 set_ascq(cmd, ASCQ_04H_ALUA_STATE_TRANSITION);
666 return 1; 676 return 1;
667 } 677 }
668 678
@@ -684,8 +694,6 @@ target_alua_state_check(struct se_cmd *cmd)
684 struct t10_alua_tg_pt_gp *tg_pt_gp; 694 struct t10_alua_tg_pt_gp *tg_pt_gp;
685 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem; 695 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
686 int out_alua_state, nonop_delay_msecs; 696 int out_alua_state, nonop_delay_msecs;
687 u8 alua_ascq;
688 int ret;
689 697
690 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) 698 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)
691 return 0; 699 return 0;
@@ -701,9 +709,8 @@ target_alua_state_check(struct se_cmd *cmd)
701 if (atomic_read(&port->sep_tg_pt_secondary_offline)) { 709 if (atomic_read(&port->sep_tg_pt_secondary_offline)) {
702 pr_debug("ALUA: Got secondary offline status for local" 710 pr_debug("ALUA: Got secondary offline status for local"
703 " target port\n"); 711 " target port\n");
704 alua_ascq = ASCQ_04H_ALUA_OFFLINE; 712 set_ascq(cmd, ASCQ_04H_ALUA_OFFLINE);
705 ret = 1; 713 return TCM_CHECK_CONDITION_NOT_READY;
706 goto out;
707 } 714 }
708 /* 715 /*
709 * Second, obtain the struct t10_alua_tg_pt_gp_member pointer to the 716 * Second, obtain the struct t10_alua_tg_pt_gp_member pointer to the
@@ -731,20 +738,23 @@ target_alua_state_check(struct se_cmd *cmd)
731 738
732 switch (out_alua_state) { 739 switch (out_alua_state) {
733 case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED: 740 case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED:
734 ret = core_alua_state_nonoptimized(cmd, cdb, 741 core_alua_state_nonoptimized(cmd, cdb, nonop_delay_msecs);
735 nonop_delay_msecs, &alua_ascq);
736 break; 742 break;
737 case ALUA_ACCESS_STATE_STANDBY: 743 case ALUA_ACCESS_STATE_STANDBY:
738 ret = core_alua_state_standby(cmd, cdb, &alua_ascq); 744 if (core_alua_state_standby(cmd, cdb))
745 return TCM_CHECK_CONDITION_NOT_READY;
739 break; 746 break;
740 case ALUA_ACCESS_STATE_UNAVAILABLE: 747 case ALUA_ACCESS_STATE_UNAVAILABLE:
741 ret = core_alua_state_unavailable(cmd, cdb, &alua_ascq); 748 if (core_alua_state_unavailable(cmd, cdb))
749 return TCM_CHECK_CONDITION_NOT_READY;
742 break; 750 break;
743 case ALUA_ACCESS_STATE_TRANSITION: 751 case ALUA_ACCESS_STATE_TRANSITION:
744 ret = core_alua_state_transition(cmd, cdb, &alua_ascq); 752 if (core_alua_state_transition(cmd, cdb))
753 return TCM_CHECK_CONDITION_NOT_READY;
745 break; 754 break;
746 case ALUA_ACCESS_STATE_LBA_DEPENDENT: 755 case ALUA_ACCESS_STATE_LBA_DEPENDENT:
747 ret = core_alua_state_lba_dependent(cmd, tg_pt_gp, &alua_ascq); 756 if (core_alua_state_lba_dependent(cmd, tg_pt_gp))
757 return TCM_CHECK_CONDITION_NOT_READY;
748 break; 758 break;
749 /* 759 /*
750 * OFFLINE is a secondary ALUA target port group access state, that is 760 * OFFLINE is a secondary ALUA target port group access state, that is
@@ -757,23 +767,6 @@ target_alua_state_check(struct se_cmd *cmd)
757 return TCM_INVALID_CDB_FIELD; 767 return TCM_INVALID_CDB_FIELD;
758 } 768 }
759 769
760out:
761 if (ret > 0) {
762 /*
763 * Set SCSI additional sense code (ASC) to 'LUN Not Accessible';
764 * The ALUA additional sense code qualifier (ASCQ) is determined
765 * by the ALUA primary or secondary access state..
766 */
767 pr_debug("[%s]: ALUA TG Port not available, "
768 "SenseKey: NOT_READY, ASC/ASCQ: "
769 "0x04/0x%02x\n",
770 cmd->se_tfo->get_fabric_name(), alua_ascq);
771
772 cmd->scsi_asc = 0x04;
773 cmd->scsi_ascq = alua_ascq;
774 return TCM_CHECK_CONDITION_NOT_READY;
775 }
776
777 return 0; 770 return 0;
778} 771}
779 772
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f0e85b119692..60a9ae6df763 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -457,6 +457,10 @@ static int target_fabric_tf_ops_check(
457 pr_err("Missing tfo->queue_tm_rsp()\n"); 457 pr_err("Missing tfo->queue_tm_rsp()\n");
458 return -EINVAL; 458 return -EINVAL;
459 } 459 }
460 if (!tfo->aborted_task) {
461 pr_err("Missing tfo->aborted_task()\n");
462 return -EINVAL;
463 }
460 /* 464 /*
461 * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() 465 * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn()
462 * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in 466 * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index cf991a91a8a9..7d6cddaec525 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -854,25 +854,6 @@ static int fd_init_prot(struct se_device *dev)
854 return 0; 854 return 0;
855} 855}
856 856
857static void fd_init_format_buf(struct se_device *dev, unsigned char *buf,
858 u32 unit_size, u32 *ref_tag, u16 app_tag,
859 bool inc_reftag)
860{
861 unsigned char *p = buf;
862 int i;
863
864 for (i = 0; i < unit_size; i += dev->prot_length) {
865 *((u16 *)&p[0]) = 0xffff;
866 *((__be16 *)&p[2]) = cpu_to_be16(app_tag);
867 *((__be32 *)&p[4]) = cpu_to_be32(*ref_tag);
868
869 if (inc_reftag)
870 (*ref_tag)++;
871
872 p += dev->prot_length;
873 }
874}
875
876static int fd_format_prot(struct se_device *dev) 857static int fd_format_prot(struct se_device *dev)
877{ 858{
878 struct fd_dev *fd_dev = FD_DEV(dev); 859 struct fd_dev *fd_dev = FD_DEV(dev);
@@ -880,10 +861,8 @@ static int fd_format_prot(struct se_device *dev)
880 sector_t prot_length, prot; 861 sector_t prot_length, prot;
881 unsigned char *buf; 862 unsigned char *buf;
882 loff_t pos = 0; 863 loff_t pos = 0;
883 u32 ref_tag = 0;
884 int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size; 864 int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size;
885 int rc, ret = 0, size, len; 865 int rc, ret = 0, size, len;
886 bool inc_reftag = false;
887 866
888 if (!dev->dev_attrib.pi_prot_type) { 867 if (!dev->dev_attrib.pi_prot_type) {
889 pr_err("Unable to format_prot while pi_prot_type == 0\n"); 868 pr_err("Unable to format_prot while pi_prot_type == 0\n");
@@ -894,37 +873,20 @@ static int fd_format_prot(struct se_device *dev)
894 return -ENODEV; 873 return -ENODEV;
895 } 874 }
896 875
897 switch (dev->dev_attrib.pi_prot_type) {
898 case TARGET_DIF_TYPE3_PROT:
899 ref_tag = 0xffffffff;
900 break;
901 case TARGET_DIF_TYPE2_PROT:
902 case TARGET_DIF_TYPE1_PROT:
903 inc_reftag = true;
904 break;
905 default:
906 break;
907 }
908
909 buf = vzalloc(unit_size); 876 buf = vzalloc(unit_size);
910 if (!buf) { 877 if (!buf) {
911 pr_err("Unable to allocate FILEIO prot buf\n"); 878 pr_err("Unable to allocate FILEIO prot buf\n");
912 return -ENOMEM; 879 return -ENOMEM;
913 } 880 }
914
915 prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length; 881 prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length;
916 size = prot_length; 882 size = prot_length;
917 883
918 pr_debug("Using FILEIO prot_length: %llu\n", 884 pr_debug("Using FILEIO prot_length: %llu\n",
919 (unsigned long long)prot_length); 885 (unsigned long long)prot_length);
920 886
887 memset(buf, 0xff, unit_size);
921 for (prot = 0; prot < prot_length; prot += unit_size) { 888 for (prot = 0; prot < prot_length; prot += unit_size) {
922
923 fd_init_format_buf(dev, buf, unit_size, &ref_tag, 0xffff,
924 inc_reftag);
925
926 len = min(unit_size, size); 889 len = min(unit_size, size);
927
928 rc = kernel_write(prot_fd, buf, len, pos); 890 rc = kernel_write(prot_fd, buf, len, pos);
929 if (rc != len) { 891 if (rc != len) {
930 pr_err("vfs_write to prot file failed: %d\n", rc); 892 pr_err("vfs_write to prot file failed: %d\n", rc);
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 554d4f75a75a..9e0232cca92e 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -203,10 +203,9 @@ static void iblock_free_device(struct se_device *dev)
203 203
204 if (ib_dev->ibd_bd != NULL) 204 if (ib_dev->ibd_bd != NULL)
205 blkdev_put(ib_dev->ibd_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL); 205 blkdev_put(ib_dev->ibd_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
206 if (ib_dev->ibd_bio_set != NULL) { 206 if (ib_dev->ibd_bio_set != NULL)
207 bioset_integrity_free(ib_dev->ibd_bio_set);
208 bioset_free(ib_dev->ibd_bio_set); 207 bioset_free(ib_dev->ibd_bio_set);
209 } 208
210 kfree(ib_dev); 209 kfree(ib_dev);
211} 210}
212 211
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 66a5aba5a0d9..b920db3388cd 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -242,7 +242,7 @@ static void rd_release_prot_space(struct rd_dev *rd_dev)
242 rd_dev->sg_prot_count = 0; 242 rd_dev->sg_prot_count = 0;
243} 243}
244 244
245static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length) 245static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length, int block_size)
246{ 246{
247 struct rd_dev_sg_table *sg_table; 247 struct rd_dev_sg_table *sg_table;
248 u32 total_sg_needed, sg_tables; 248 u32 total_sg_needed, sg_tables;
@@ -252,8 +252,13 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length)
252 252
253 if (rd_dev->rd_flags & RDF_NULLIO) 253 if (rd_dev->rd_flags & RDF_NULLIO)
254 return 0; 254 return 0;
255 255 /*
256 total_sg_needed = rd_dev->rd_page_count / prot_length; 256 * prot_length=8byte dif data
257 * tot sg needed = rd_page_count * (PGSZ/block_size) *
258 * (prot_length/block_size) + pad
259 * PGSZ canceled each other.
260 */
261 total_sg_needed = (rd_dev->rd_page_count * prot_length / block_size) + 1;
257 262
258 sg_tables = (total_sg_needed / max_sg_per_table) + 1; 263 sg_tables = (total_sg_needed / max_sg_per_table) + 1;
259 264
@@ -606,7 +611,8 @@ static int rd_init_prot(struct se_device *dev)
606 if (!dev->dev_attrib.pi_prot_type) 611 if (!dev->dev_attrib.pi_prot_type)
607 return 0; 612 return 0;
608 613
609 return rd_build_prot_space(rd_dev, dev->prot_length); 614 return rd_build_prot_space(rd_dev, dev->prot_length,
615 dev->dev_attrib.block_size);
610} 616}
611 617
612static void rd_free_prot(struct se_device *dev) 618static void rd_free_prot(struct se_device *dev)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 77e6531fb0a1..e0229592ec55 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -89,6 +89,7 @@ static sense_reason_t
89sbc_emulate_readcapacity_16(struct se_cmd *cmd) 89sbc_emulate_readcapacity_16(struct se_cmd *cmd)
90{ 90{
91 struct se_device *dev = cmd->se_dev; 91 struct se_device *dev = cmd->se_dev;
92 struct se_session *sess = cmd->se_sess;
92 unsigned char *rbuf; 93 unsigned char *rbuf;
93 unsigned char buf[32]; 94 unsigned char buf[32];
94 unsigned long long blocks = dev->transport->get_blocks(dev); 95 unsigned long long blocks = dev->transport->get_blocks(dev);
@@ -109,8 +110,10 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
109 /* 110 /*
110 * Set P_TYPE and PROT_EN bits for DIF support 111 * Set P_TYPE and PROT_EN bits for DIF support
111 */ 112 */
112 if (dev->dev_attrib.pi_prot_type) 113 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
113 buf[12] = (dev->dev_attrib.pi_prot_type - 1) << 1 | 0x1; 114 if (dev->dev_attrib.pi_prot_type)
115 buf[12] = (dev->dev_attrib.pi_prot_type - 1) << 1 | 0x1;
116 }
114 117
115 if (dev->transport->get_lbppbe) 118 if (dev->transport->get_lbppbe)
116 buf[13] = dev->transport->get_lbppbe(dev) & 0x0f; 119 buf[13] = dev->transport->get_lbppbe(dev) & 0x0f;
@@ -425,13 +428,14 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd)
425 goto out; 428 goto out;
426 } 429 }
427 430
428 write_sg = kzalloc(sizeof(struct scatterlist) * cmd->t_data_nents, 431 write_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
429 GFP_KERNEL); 432 GFP_KERNEL);
430 if (!write_sg) { 433 if (!write_sg) {
431 pr_err("Unable to allocate compare_and_write sg\n"); 434 pr_err("Unable to allocate compare_and_write sg\n");
432 ret = TCM_OUT_OF_RESOURCES; 435 ret = TCM_OUT_OF_RESOURCES;
433 goto out; 436 goto out;
434 } 437 }
438 sg_init_table(write_sg, cmd->t_data_nents);
435 /* 439 /*
436 * Setup verify and write data payloads from total NumberLBAs. 440 * Setup verify and write data payloads from total NumberLBAs.
437 */ 441 */
@@ -569,30 +573,85 @@ sbc_compare_and_write(struct se_cmd *cmd)
569 return TCM_NO_SENSE; 573 return TCM_NO_SENSE;
570} 574}
571 575
576static int
577sbc_set_prot_op_checks(u8 protect, enum target_prot_type prot_type,
578 bool is_write, struct se_cmd *cmd)
579{
580 if (is_write) {
581 cmd->prot_op = protect ? TARGET_PROT_DOUT_PASS :
582 TARGET_PROT_DOUT_INSERT;
583 switch (protect) {
584 case 0x0:
585 case 0x3:
586 cmd->prot_checks = 0;
587 break;
588 case 0x1:
589 case 0x5:
590 cmd->prot_checks = TARGET_DIF_CHECK_GUARD;
591 if (prot_type == TARGET_DIF_TYPE1_PROT)
592 cmd->prot_checks |= TARGET_DIF_CHECK_REFTAG;
593 break;
594 case 0x2:
595 if (prot_type == TARGET_DIF_TYPE1_PROT)
596 cmd->prot_checks = TARGET_DIF_CHECK_REFTAG;
597 break;
598 case 0x4:
599 cmd->prot_checks = TARGET_DIF_CHECK_GUARD;
600 break;
601 default:
602 pr_err("Unsupported protect field %d\n", protect);
603 return -EINVAL;
604 }
605 } else {
606 cmd->prot_op = protect ? TARGET_PROT_DIN_PASS :
607 TARGET_PROT_DIN_STRIP;
608 switch (protect) {
609 case 0x0:
610 case 0x1:
611 case 0x5:
612 cmd->prot_checks = TARGET_DIF_CHECK_GUARD;
613 if (prot_type == TARGET_DIF_TYPE1_PROT)
614 cmd->prot_checks |= TARGET_DIF_CHECK_REFTAG;
615 break;
616 case 0x2:
617 if (prot_type == TARGET_DIF_TYPE1_PROT)
618 cmd->prot_checks = TARGET_DIF_CHECK_REFTAG;
619 break;
620 case 0x3:
621 cmd->prot_checks = 0;
622 break;
623 case 0x4:
624 cmd->prot_checks = TARGET_DIF_CHECK_GUARD;
625 break;
626 default:
627 pr_err("Unsupported protect field %d\n", protect);
628 return -EINVAL;
629 }
630 }
631
632 return 0;
633}
634
572static bool 635static bool
573sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb, 636sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
574 u32 sectors) 637 u32 sectors, bool is_write)
575{ 638{
576 if (!cmd->t_prot_sg || !cmd->t_prot_nents) 639 u8 protect = cdb[1] >> 5;
640
641 if ((!cmd->t_prot_sg || !cmd->t_prot_nents) && cmd->prot_pto)
577 return true; 642 return true;
578 643
579 switch (dev->dev_attrib.pi_prot_type) { 644 switch (dev->dev_attrib.pi_prot_type) {
580 case TARGET_DIF_TYPE3_PROT: 645 case TARGET_DIF_TYPE3_PROT:
581 if (!(cdb[1] & 0xe0))
582 return true;
583
584 cmd->reftag_seed = 0xffffffff; 646 cmd->reftag_seed = 0xffffffff;
585 break; 647 break;
586 case TARGET_DIF_TYPE2_PROT: 648 case TARGET_DIF_TYPE2_PROT:
587 if (cdb[1] & 0xe0) 649 if (protect)
588 return false; 650 return false;
589 651
590 cmd->reftag_seed = cmd->t_task_lba; 652 cmd->reftag_seed = cmd->t_task_lba;
591 break; 653 break;
592 case TARGET_DIF_TYPE1_PROT: 654 case TARGET_DIF_TYPE1_PROT:
593 if (!(cdb[1] & 0xe0))
594 return true;
595
596 cmd->reftag_seed = cmd->t_task_lba; 655 cmd->reftag_seed = cmd->t_task_lba;
597 break; 656 break;
598 case TARGET_DIF_TYPE0_PROT: 657 case TARGET_DIF_TYPE0_PROT:
@@ -600,9 +659,15 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
600 return true; 659 return true;
601 } 660 }
602 661
662 if (sbc_set_prot_op_checks(protect, dev->dev_attrib.pi_prot_type,
663 is_write, cmd))
664 return false;
665
603 cmd->prot_type = dev->dev_attrib.pi_prot_type; 666 cmd->prot_type = dev->dev_attrib.pi_prot_type;
604 cmd->prot_length = dev->prot_length * sectors; 667 cmd->prot_length = dev->prot_length * sectors;
605 cmd->prot_handover = PROT_SEPERATED; 668 pr_debug("%s: prot_type=%d, prot_length=%d prot_op=%d prot_checks=%d\n",
669 __func__, cmd->prot_type, cmd->prot_length,
670 cmd->prot_op, cmd->prot_checks);
606 671
607 return true; 672 return true;
608} 673}
@@ -628,7 +693,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
628 sectors = transport_get_sectors_10(cdb); 693 sectors = transport_get_sectors_10(cdb);
629 cmd->t_task_lba = transport_lba_32(cdb); 694 cmd->t_task_lba = transport_lba_32(cdb);
630 695
631 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 696 if (!sbc_check_prot(dev, cmd, cdb, sectors, false))
632 return TCM_UNSUPPORTED_SCSI_OPCODE; 697 return TCM_UNSUPPORTED_SCSI_OPCODE;
633 698
634 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 699 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
@@ -639,7 +704,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
639 sectors = transport_get_sectors_12(cdb); 704 sectors = transport_get_sectors_12(cdb);
640 cmd->t_task_lba = transport_lba_32(cdb); 705 cmd->t_task_lba = transport_lba_32(cdb);
641 706
642 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 707 if (!sbc_check_prot(dev, cmd, cdb, sectors, false))
643 return TCM_UNSUPPORTED_SCSI_OPCODE; 708 return TCM_UNSUPPORTED_SCSI_OPCODE;
644 709
645 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 710 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
@@ -650,7 +715,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
650 sectors = transport_get_sectors_16(cdb); 715 sectors = transport_get_sectors_16(cdb);
651 cmd->t_task_lba = transport_lba_64(cdb); 716 cmd->t_task_lba = transport_lba_64(cdb);
652 717
653 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 718 if (!sbc_check_prot(dev, cmd, cdb, sectors, false))
654 return TCM_UNSUPPORTED_SCSI_OPCODE; 719 return TCM_UNSUPPORTED_SCSI_OPCODE;
655 720
656 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 721 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
@@ -669,7 +734,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
669 sectors = transport_get_sectors_10(cdb); 734 sectors = transport_get_sectors_10(cdb);
670 cmd->t_task_lba = transport_lba_32(cdb); 735 cmd->t_task_lba = transport_lba_32(cdb);
671 736
672 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 737 if (!sbc_check_prot(dev, cmd, cdb, sectors, true))
673 return TCM_UNSUPPORTED_SCSI_OPCODE; 738 return TCM_UNSUPPORTED_SCSI_OPCODE;
674 739
675 if (cdb[1] & 0x8) 740 if (cdb[1] & 0x8)
@@ -682,7 +747,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
682 sectors = transport_get_sectors_12(cdb); 747 sectors = transport_get_sectors_12(cdb);
683 cmd->t_task_lba = transport_lba_32(cdb); 748 cmd->t_task_lba = transport_lba_32(cdb);
684 749
685 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 750 if (!sbc_check_prot(dev, cmd, cdb, sectors, true))
686 return TCM_UNSUPPORTED_SCSI_OPCODE; 751 return TCM_UNSUPPORTED_SCSI_OPCODE;
687 752
688 if (cdb[1] & 0x8) 753 if (cdb[1] & 0x8)
@@ -695,7 +760,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
695 sectors = transport_get_sectors_16(cdb); 760 sectors = transport_get_sectors_16(cdb);
696 cmd->t_task_lba = transport_lba_64(cdb); 761 cmd->t_task_lba = transport_lba_64(cdb);
697 762
698 if (!sbc_check_prot(dev, cmd, cdb, sectors)) 763 if (!sbc_check_prot(dev, cmd, cdb, sectors, true))
699 return TCM_UNSUPPORTED_SCSI_OPCODE; 764 return TCM_UNSUPPORTED_SCSI_OPCODE;
700 765
701 if (cdb[1] & 0x8) 766 if (cdb[1] & 0x8)
@@ -1031,6 +1096,50 @@ err:
1031} 1096}
1032EXPORT_SYMBOL(sbc_execute_unmap); 1097EXPORT_SYMBOL(sbc_execute_unmap);
1033 1098
1099void
1100sbc_dif_generate(struct se_cmd *cmd)
1101{
1102 struct se_device *dev = cmd->se_dev;
1103 struct se_dif_v1_tuple *sdt;
1104 struct scatterlist *dsg, *psg = cmd->t_prot_sg;
1105 sector_t sector = cmd->t_task_lba;
1106 void *daddr, *paddr;
1107 int i, j, offset = 0;
1108
1109 for_each_sg(cmd->t_data_sg, dsg, cmd->t_data_nents, i) {
1110 daddr = kmap_atomic(sg_page(dsg)) + dsg->offset;
1111 paddr = kmap_atomic(sg_page(psg)) + psg->offset;
1112
1113 for (j = 0; j < dsg->length; j += dev->dev_attrib.block_size) {
1114
1115 if (offset >= psg->length) {
1116 kunmap_atomic(paddr);
1117 psg = sg_next(psg);
1118 paddr = kmap_atomic(sg_page(psg)) + psg->offset;
1119 offset = 0;
1120 }
1121
1122 sdt = paddr + offset;
1123 sdt->guard_tag = cpu_to_be16(crc_t10dif(daddr + j,
1124 dev->dev_attrib.block_size));
1125 if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT)
1126 sdt->ref_tag = cpu_to_be32(sector & 0xffffffff);
1127 sdt->app_tag = 0;
1128
1129 pr_debug("DIF WRITE INSERT sector: %llu guard_tag: 0x%04x"
1130 " app_tag: 0x%04x ref_tag: %u\n",
1131 (unsigned long long)sector, sdt->guard_tag,
1132 sdt->app_tag, be32_to_cpu(sdt->ref_tag));
1133
1134 sector++;
1135 offset += sizeof(struct se_dif_v1_tuple);
1136 }
1137
1138 kunmap_atomic(paddr);
1139 kunmap_atomic(daddr);
1140 }
1141}
1142
1034static sense_reason_t 1143static sense_reason_t
1035sbc_dif_v1_verify(struct se_device *dev, struct se_dif_v1_tuple *sdt, 1144sbc_dif_v1_verify(struct se_device *dev, struct se_dif_v1_tuple *sdt,
1036 const void *p, sector_t sector, unsigned int ei_lba) 1145 const void *p, sector_t sector, unsigned int ei_lba)
@@ -1162,9 +1271,9 @@ sbc_dif_verify_write(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1162} 1271}
1163EXPORT_SYMBOL(sbc_dif_verify_write); 1272EXPORT_SYMBOL(sbc_dif_verify_write);
1164 1273
1165sense_reason_t 1274static sense_reason_t
1166sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors, 1275__sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1167 unsigned int ei_lba, struct scatterlist *sg, int sg_off) 1276 unsigned int ei_lba, struct scatterlist *sg, int sg_off)
1168{ 1277{
1169 struct se_device *dev = cmd->se_dev; 1278 struct se_device *dev = cmd->se_dev;
1170 struct se_dif_v1_tuple *sdt; 1279 struct se_dif_v1_tuple *sdt;
@@ -1217,8 +1326,31 @@ sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1217 kunmap_atomic(paddr); 1326 kunmap_atomic(paddr);
1218 kunmap_atomic(daddr); 1327 kunmap_atomic(daddr);
1219 } 1328 }
1220 sbc_dif_copy_prot(cmd, sectors, true, sg, sg_off);
1221 1329
1222 return 0; 1330 return 0;
1223} 1331}
1332
1333sense_reason_t
1334sbc_dif_read_strip(struct se_cmd *cmd)
1335{
1336 struct se_device *dev = cmd->se_dev;
1337 u32 sectors = cmd->prot_length / dev->prot_length;
1338
1339 return __sbc_dif_verify_read(cmd, cmd->t_task_lba, sectors, 0,
1340 cmd->t_prot_sg, 0);
1341}
1342
1343sense_reason_t
1344sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1345 unsigned int ei_lba, struct scatterlist *sg, int sg_off)
1346{
1347 sense_reason_t rc;
1348
1349 rc = __sbc_dif_verify_read(cmd, start, sectors, ei_lba, sg, sg_off);
1350 if (rc)
1351 return rc;
1352
1353 sbc_dif_copy_prot(cmd, sectors, true, sg, sg_off);
1354 return 0;
1355}
1224EXPORT_SYMBOL(sbc_dif_verify_read); 1356EXPORT_SYMBOL(sbc_dif_verify_read);
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 3bebc71ea033..8653666612a8 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -71,6 +71,7 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
71{ 71{
72 struct se_lun *lun = cmd->se_lun; 72 struct se_lun *lun = cmd->se_lun;
73 struct se_device *dev = cmd->se_dev; 73 struct se_device *dev = cmd->se_dev;
74 struct se_session *sess = cmd->se_sess;
74 75
75 /* Set RMB (removable media) for tape devices */ 76 /* Set RMB (removable media) for tape devices */
76 if (dev->transport->get_device_type(dev) == TYPE_TAPE) 77 if (dev->transport->get_device_type(dev) == TYPE_TAPE)
@@ -101,10 +102,13 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
101 if (dev->dev_attrib.emulate_3pc) 102 if (dev->dev_attrib.emulate_3pc)
102 buf[5] |= 0x8; 103 buf[5] |= 0x8;
103 /* 104 /*
104 * Set Protection (PROTECT) bit when DIF has been enabled. 105 * Set Protection (PROTECT) bit when DIF has been enabled on the
106 * device, and the transport supports VERIFY + PASS.
105 */ 107 */
106 if (dev->dev_attrib.pi_prot_type) 108 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
107 buf[5] |= 0x1; 109 if (dev->dev_attrib.pi_prot_type)
110 buf[5] |= 0x1;
111 }
108 112
109 buf[7] = 0x2; /* CmdQue=1 */ 113 buf[7] = 0x2; /* CmdQue=1 */
110 114
@@ -473,16 +477,19 @@ static sense_reason_t
473spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) 477spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
474{ 478{
475 struct se_device *dev = cmd->se_dev; 479 struct se_device *dev = cmd->se_dev;
480 struct se_session *sess = cmd->se_sess;
476 481
477 buf[3] = 0x3c; 482 buf[3] = 0x3c;
478 /* 483 /*
479 * Set GRD_CHK + REF_CHK for TYPE1 protection, or GRD_CHK 484 * Set GRD_CHK + REF_CHK for TYPE1 protection, or GRD_CHK
480 * only for TYPE3 protection. 485 * only for TYPE3 protection.
481 */ 486 */
482 if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT) 487 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
483 buf[4] = 0x5; 488 if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT)
484 else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT) 489 buf[4] = 0x5;
485 buf[4] = 0x4; 490 else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT)
491 buf[4] = 0x4;
492 }
486 493
487 /* Set HEADSUP, ORDSUP, SIMPSUP */ 494 /* Set HEADSUP, ORDSUP, SIMPSUP */
488 buf[5] = 0x07; 495 buf[5] = 0x07;
@@ -762,7 +769,7 @@ out:
762 return ret; 769 return ret;
763} 770}
764 771
765static int spc_modesense_rwrecovery(struct se_device *dev, u8 pc, u8 *p) 772static int spc_modesense_rwrecovery(struct se_cmd *cmd, u8 pc, u8 *p)
766{ 773{
767 p[0] = 0x01; 774 p[0] = 0x01;
768 p[1] = 0x0a; 775 p[1] = 0x0a;
@@ -775,8 +782,11 @@ out:
775 return 12; 782 return 12;
776} 783}
777 784
778static int spc_modesense_control(struct se_device *dev, u8 pc, u8 *p) 785static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p)
779{ 786{
787 struct se_device *dev = cmd->se_dev;
788 struct se_session *sess = cmd->se_sess;
789
780 p[0] = 0x0a; 790 p[0] = 0x0a;
781 p[1] = 0x0a; 791 p[1] = 0x0a;
782 792
@@ -868,8 +878,10 @@ static int spc_modesense_control(struct se_device *dev, u8 pc, u8 *p)
868 * type, shall not modify the contents of the LOGICAL BLOCK REFERENCE 878 * type, shall not modify the contents of the LOGICAL BLOCK REFERENCE
869 * TAG field. 879 * TAG field.
870 */ 880 */
871 if (dev->dev_attrib.pi_prot_type) 881 if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
872 p[5] |= 0x80; 882 if (dev->dev_attrib.pi_prot_type)
883 p[5] |= 0x80;
884 }
873 885
874 p[8] = 0xff; 886 p[8] = 0xff;
875 p[9] = 0xff; 887 p[9] = 0xff;
@@ -879,8 +891,10 @@ out:
879 return 12; 891 return 12;
880} 892}
881 893
882static int spc_modesense_caching(struct se_device *dev, u8 pc, u8 *p) 894static int spc_modesense_caching(struct se_cmd *cmd, u8 pc, u8 *p)
883{ 895{
896 struct se_device *dev = cmd->se_dev;
897
884 p[0] = 0x08; 898 p[0] = 0x08;
885 p[1] = 0x12; 899 p[1] = 0x12;
886 900
@@ -896,7 +910,7 @@ out:
896 return 20; 910 return 20;
897} 911}
898 912
899static int spc_modesense_informational_exceptions(struct se_device *dev, u8 pc, unsigned char *p) 913static int spc_modesense_informational_exceptions(struct se_cmd *cmd, u8 pc, unsigned char *p)
900{ 914{
901 p[0] = 0x1c; 915 p[0] = 0x1c;
902 p[1] = 0x0a; 916 p[1] = 0x0a;
@@ -912,7 +926,7 @@ out:
912static struct { 926static struct {
913 uint8_t page; 927 uint8_t page;
914 uint8_t subpage; 928 uint8_t subpage;
915 int (*emulate)(struct se_device *, u8, unsigned char *); 929 int (*emulate)(struct se_cmd *, u8, unsigned char *);
916} modesense_handlers[] = { 930} modesense_handlers[] = {
917 { .page = 0x01, .subpage = 0x00, .emulate = spc_modesense_rwrecovery }, 931 { .page = 0x01, .subpage = 0x00, .emulate = spc_modesense_rwrecovery },
918 { .page = 0x08, .subpage = 0x00, .emulate = spc_modesense_caching }, 932 { .page = 0x08, .subpage = 0x00, .emulate = spc_modesense_caching },
@@ -1050,7 +1064,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)
1050 * the only two possibilities). 1064 * the only two possibilities).
1051 */ 1065 */
1052 if ((modesense_handlers[i].subpage & ~subpage) == 0) { 1066 if ((modesense_handlers[i].subpage & ~subpage) == 0) {
1053 ret = modesense_handlers[i].emulate(dev, pc, &buf[length]); 1067 ret = modesense_handlers[i].emulate(cmd, pc, &buf[length]);
1054 if (!ten && length + ret >= 255) 1068 if (!ten && length + ret >= 255)
1055 break; 1069 break;
1056 length += ret; 1070 length += ret;
@@ -1063,7 +1077,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)
1063 for (i = 0; i < ARRAY_SIZE(modesense_handlers); ++i) 1077 for (i = 0; i < ARRAY_SIZE(modesense_handlers); ++i)
1064 if (modesense_handlers[i].page == page && 1078 if (modesense_handlers[i].page == page &&
1065 modesense_handlers[i].subpage == subpage) { 1079 modesense_handlers[i].subpage == subpage) {
1066 length += modesense_handlers[i].emulate(dev, pc, &buf[length]); 1080 length += modesense_handlers[i].emulate(cmd, pc, &buf[length]);
1067 goto set_length; 1081 goto set_length;
1068 } 1082 }
1069 1083
@@ -1095,7 +1109,6 @@ set_length:
1095 1109
1096static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) 1110static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1097{ 1111{
1098 struct se_device *dev = cmd->se_dev;
1099 char *cdb = cmd->t_task_cdb; 1112 char *cdb = cmd->t_task_cdb;
1100 bool ten = cdb[0] == MODE_SELECT_10; 1113 bool ten = cdb[0] == MODE_SELECT_10;
1101 int off = ten ? 8 : 4; 1114 int off = ten ? 8 : 4;
@@ -1131,7 +1144,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1131 if (modesense_handlers[i].page == page && 1144 if (modesense_handlers[i].page == page &&
1132 modesense_handlers[i].subpage == subpage) { 1145 modesense_handlers[i].subpage == subpage) {
1133 memset(tbuf, 0, SE_MODE_PAGE_BUF); 1146 memset(tbuf, 0, SE_MODE_PAGE_BUF);
1134 length = modesense_handlers[i].emulate(dev, 0, tbuf); 1147 length = modesense_handlers[i].emulate(cmd, 0, tbuf);
1135 goto check_contents; 1148 goto check_contents;
1136 } 1149 }
1137 1150
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 70c638f730af..f7cd95e8111a 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -87,14 +87,17 @@ static void core_tmr_handle_tas_abort(
87 struct se_cmd *cmd, 87 struct se_cmd *cmd,
88 int tas) 88 int tas)
89{ 89{
90 bool remove = true;
90 /* 91 /*
91 * TASK ABORTED status (TAS) bit support 92 * TASK ABORTED status (TAS) bit support
92 */ 93 */
93 if ((tmr_nacl && 94 if ((tmr_nacl &&
94 (tmr_nacl == cmd->se_sess->se_node_acl)) || tas) 95 (tmr_nacl != cmd->se_sess->se_node_acl)) && tas) {
96 remove = false;
95 transport_send_task_abort(cmd); 97 transport_send_task_abort(cmd);
98 }
96 99
97 transport_cmd_finish_abort(cmd, 0); 100 transport_cmd_finish_abort(cmd, remove);
98} 101}
99 102
100static int target_check_cdb_and_preempt(struct list_head *list, 103static int target_check_cdb_and_preempt(struct list_head *list,
@@ -127,6 +130,11 @@ void core_tmr_abort_task(
127 130
128 if (dev != se_cmd->se_dev) 131 if (dev != se_cmd->se_dev)
129 continue; 132 continue;
133
134 /* skip se_cmd associated with tmr */
135 if (tmr->task_cmd == se_cmd)
136 continue;
137
130 ref_tag = se_cmd->se_tfo->get_task_tag(se_cmd); 138 ref_tag = se_cmd->se_tfo->get_task_tag(se_cmd);
131 if (tmr->ref_task_tag != ref_tag) 139 if (tmr->ref_task_tag != ref_tag)
132 continue; 140 continue;
@@ -150,18 +158,9 @@ void core_tmr_abort_task(
150 158
151 cancel_work_sync(&se_cmd->work); 159 cancel_work_sync(&se_cmd->work);
152 transport_wait_for_tasks(se_cmd); 160 transport_wait_for_tasks(se_cmd);
153 /*
154 * Now send SAM_STAT_TASK_ABORTED status for the referenced
155 * se_cmd descriptor..
156 */
157 transport_send_task_abort(se_cmd);
158 /*
159 * Also deal with possible extra acknowledge reference..
160 */
161 if (se_cmd->se_cmd_flags & SCF_ACK_KREF)
162 target_put_sess_cmd(se_sess, se_cmd);
163 161
164 target_put_sess_cmd(se_sess, se_cmd); 162 target_put_sess_cmd(se_sess, se_cmd);
163 transport_cmd_finish_abort(se_cmd, true);
165 164
166 printk("ABORT_TASK: Sending TMR_FUNCTION_COMPLETE for" 165 printk("ABORT_TASK: Sending TMR_FUNCTION_COMPLETE for"
167 " ref_tag: %d\n", ref_tag); 166 " ref_tag: %d\n", ref_tag);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 2956250b7225..d4b98690a736 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -235,7 +235,7 @@ void transport_subsystem_check_init(void)
235 sub_api_initialized = 1; 235 sub_api_initialized = 1;
236} 236}
237 237
238struct se_session *transport_init_session(void) 238struct se_session *transport_init_session(enum target_prot_op sup_prot_ops)
239{ 239{
240 struct se_session *se_sess; 240 struct se_session *se_sess;
241 241
@@ -251,6 +251,7 @@ struct se_session *transport_init_session(void)
251 INIT_LIST_HEAD(&se_sess->sess_wait_list); 251 INIT_LIST_HEAD(&se_sess->sess_wait_list);
252 spin_lock_init(&se_sess->sess_cmd_lock); 252 spin_lock_init(&se_sess->sess_cmd_lock);
253 kref_init(&se_sess->sess_kref); 253 kref_init(&se_sess->sess_kref);
254 se_sess->sup_prot_ops = sup_prot_ops;
254 255
255 return se_sess; 256 return se_sess;
256} 257}
@@ -288,12 +289,13 @@ int transport_alloc_session_tags(struct se_session *se_sess,
288EXPORT_SYMBOL(transport_alloc_session_tags); 289EXPORT_SYMBOL(transport_alloc_session_tags);
289 290
290struct se_session *transport_init_session_tags(unsigned int tag_num, 291struct se_session *transport_init_session_tags(unsigned int tag_num,
291 unsigned int tag_size) 292 unsigned int tag_size,
293 enum target_prot_op sup_prot_ops)
292{ 294{
293 struct se_session *se_sess; 295 struct se_session *se_sess;
294 int rc; 296 int rc;
295 297
296 se_sess = transport_init_session(); 298 se_sess = transport_init_session(sup_prot_ops);
297 if (IS_ERR(se_sess)) 299 if (IS_ERR(se_sess))
298 return se_sess; 300 return se_sess;
299 301
@@ -603,6 +605,15 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
603 605
604void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) 606void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
605{ 607{
608 if (cmd->se_cmd_flags & SCF_SE_LUN_CMD)
609 transport_lun_remove_cmd(cmd);
610 /*
611 * Allow the fabric driver to unmap any resources before
612 * releasing the descriptor via TFO->release_cmd()
613 */
614 if (remove)
615 cmd->se_tfo->aborted_task(cmd);
616
606 if (transport_cmd_check_stop_to_fabric(cmd)) 617 if (transport_cmd_check_stop_to_fabric(cmd))
607 return; 618 return;
608 if (remove) 619 if (remove)
@@ -1365,6 +1376,13 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
1365 target_put_sess_cmd(se_sess, se_cmd); 1376 target_put_sess_cmd(se_sess, se_cmd);
1366 return 0; 1377 return 0;
1367 } 1378 }
1379
1380 rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1381 if (rc != 0) {
1382 transport_generic_request_failure(se_cmd, rc);
1383 return 0;
1384 }
1385
1368 /* 1386 /*
1369 * Save pointers for SGLs containing protection information, 1387 * Save pointers for SGLs containing protection information,
1370 * if present. 1388 * if present.
@@ -1374,11 +1392,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
1374 se_cmd->t_prot_nents = sgl_prot_count; 1392 se_cmd->t_prot_nents = sgl_prot_count;
1375 } 1393 }
1376 1394
1377 rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1378 if (rc != 0) {
1379 transport_generic_request_failure(se_cmd, rc);
1380 return 0;
1381 }
1382 /* 1395 /*
1383 * When a non zero sgl_count has been passed perform SGL passthrough 1396 * When a non zero sgl_count has been passed perform SGL passthrough
1384 * mapping for pre-allocated fabric memory instead of having target 1397 * mapping for pre-allocated fabric memory instead of having target
@@ -1754,6 +1767,15 @@ void target_execute_cmd(struct se_cmd *cmd)
1754 cmd->t_state = TRANSPORT_PROCESSING; 1767 cmd->t_state = TRANSPORT_PROCESSING;
1755 cmd->transport_state |= CMD_T_ACTIVE|CMD_T_BUSY|CMD_T_SENT; 1768 cmd->transport_state |= CMD_T_ACTIVE|CMD_T_BUSY|CMD_T_SENT;
1756 spin_unlock_irq(&cmd->t_state_lock); 1769 spin_unlock_irq(&cmd->t_state_lock);
1770 /*
1771 * Perform WRITE_INSERT of PI using software emulation when backend
1772 * device has PI enabled, if the transport has not already generated
1773 * PI using hardware WRITE_INSERT offload.
1774 */
1775 if (cmd->prot_op == TARGET_PROT_DOUT_INSERT) {
1776 if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DOUT_INSERT))
1777 sbc_dif_generate(cmd);
1778 }
1757 1779
1758 if (target_handle_task_attr(cmd)) { 1780 if (target_handle_task_attr(cmd)) {
1759 spin_lock_irq(&cmd->t_state_lock); 1781 spin_lock_irq(&cmd->t_state_lock);
@@ -1883,6 +1905,21 @@ static void transport_handle_queue_full(
1883 schedule_work(&cmd->se_dev->qf_work_queue); 1905 schedule_work(&cmd->se_dev->qf_work_queue);
1884} 1906}
1885 1907
1908static bool target_check_read_strip(struct se_cmd *cmd)
1909{
1910 sense_reason_t rc;
1911
1912 if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) {
1913 rc = sbc_dif_read_strip(cmd);
1914 if (rc) {
1915 cmd->pi_err = rc;
1916 return true;
1917 }
1918 }
1919
1920 return false;
1921}
1922
1886static void target_complete_ok_work(struct work_struct *work) 1923static void target_complete_ok_work(struct work_struct *work)
1887{ 1924{
1888 struct se_cmd *cmd = container_of(work, struct se_cmd, work); 1925 struct se_cmd *cmd = container_of(work, struct se_cmd, work);
@@ -1947,6 +1984,22 @@ static void target_complete_ok_work(struct work_struct *work)
1947 cmd->data_length; 1984 cmd->data_length;
1948 } 1985 }
1949 spin_unlock(&cmd->se_lun->lun_sep_lock); 1986 spin_unlock(&cmd->se_lun->lun_sep_lock);
1987 /*
1988 * Perform READ_STRIP of PI using software emulation when
1989 * backend had PI enabled, if the transport will not be
1990 * performing hardware READ_STRIP offload.
1991 */
1992 if (cmd->prot_op == TARGET_PROT_DIN_STRIP &&
1993 target_check_read_strip(cmd)) {
1994 ret = transport_send_check_condition_and_sense(cmd,
1995 cmd->pi_err, 0);
1996 if (ret == -EAGAIN || ret == -ENOMEM)
1997 goto queue_full;
1998
1999 transport_lun_remove_cmd(cmd);
2000 transport_cmd_check_stop_to_fabric(cmd);
2001 return;
2002 }
1950 2003
1951 trace_target_cmd_complete(cmd); 2004 trace_target_cmd_complete(cmd);
1952 ret = cmd->se_tfo->queue_data_in(cmd); 2005 ret = cmd->se_tfo->queue_data_in(cmd);
@@ -2039,6 +2092,10 @@ static inline void transport_free_pages(struct se_cmd *cmd)
2039 transport_free_sgl(cmd->t_bidi_data_sg, cmd->t_bidi_data_nents); 2092 transport_free_sgl(cmd->t_bidi_data_sg, cmd->t_bidi_data_nents);
2040 cmd->t_bidi_data_sg = NULL; 2093 cmd->t_bidi_data_sg = NULL;
2041 cmd->t_bidi_data_nents = 0; 2094 cmd->t_bidi_data_nents = 0;
2095
2096 transport_free_sgl(cmd->t_prot_sg, cmd->t_prot_nents);
2097 cmd->t_prot_sg = NULL;
2098 cmd->t_prot_nents = 0;
2042} 2099}
2043 2100
2044/** 2101/**
@@ -2202,6 +2259,14 @@ transport_generic_new_cmd(struct se_cmd *cmd)
2202 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 2259 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
2203 } 2260 }
2204 2261
2262 if (cmd->prot_op != TARGET_PROT_NORMAL) {
2263 ret = target_alloc_sgl(&cmd->t_prot_sg,
2264 &cmd->t_prot_nents,
2265 cmd->prot_length, true);
2266 if (ret < 0)
2267 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
2268 }
2269
2205 ret = target_alloc_sgl(&cmd->t_data_sg, &cmd->t_data_nents, 2270 ret = target_alloc_sgl(&cmd->t_data_sg, &cmd->t_data_nents,
2206 cmd->data_length, zero_flag); 2271 cmd->data_length, zero_flag);
2207 if (ret < 0) 2272 if (ret < 0)
@@ -2770,13 +2835,17 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
2770 if (!(cmd->transport_state & CMD_T_ABORTED)) 2835 if (!(cmd->transport_state & CMD_T_ABORTED))
2771 return 0; 2836 return 0;
2772 2837
2773 if (!send_status || (cmd->se_cmd_flags & SCF_SENT_DELAYED_TAS)) 2838 /*
2839 * If cmd has been aborted but either no status is to be sent or it has
2840 * already been sent, just return
2841 */
2842 if (!send_status || !(cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS))
2774 return 1; 2843 return 1;
2775 2844
2776 pr_debug("Sending delayed SAM_STAT_TASK_ABORTED status for CDB: 0x%02x ITT: 0x%08x\n", 2845 pr_debug("Sending delayed SAM_STAT_TASK_ABORTED status for CDB: 0x%02x ITT: 0x%08x\n",
2777 cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd)); 2846 cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd));
2778 2847
2779 cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS; 2848 cmd->se_cmd_flags &= ~SCF_SEND_DELAYED_TAS;
2780 cmd->scsi_status = SAM_STAT_TASK_ABORTED; 2849 cmd->scsi_status = SAM_STAT_TASK_ABORTED;
2781 trace_target_cmd_complete(cmd); 2850 trace_target_cmd_complete(cmd);
2782 cmd->se_tfo->queue_status(cmd); 2851 cmd->se_tfo->queue_status(cmd);
@@ -2790,7 +2859,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
2790 unsigned long flags; 2859 unsigned long flags;
2791 2860
2792 spin_lock_irqsave(&cmd->t_state_lock, flags); 2861 spin_lock_irqsave(&cmd->t_state_lock, flags);
2793 if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION | SCF_SENT_DELAYED_TAS)) { 2862 if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION)) {
2794 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2863 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2795 return; 2864 return;
2796 } 2865 }
@@ -2805,6 +2874,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
2805 if (cmd->data_direction == DMA_TO_DEVICE) { 2874 if (cmd->data_direction == DMA_TO_DEVICE) {
2806 if (cmd->se_tfo->write_pending_status(cmd) != 0) { 2875 if (cmd->se_tfo->write_pending_status(cmd) != 0) {
2807 cmd->transport_state |= CMD_T_ABORTED; 2876 cmd->transport_state |= CMD_T_ABORTED;
2877 cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS;
2808 smp_mb__after_atomic_inc(); 2878 smp_mb__after_atomic_inc();
2809 return; 2879 return;
2810 } 2880 }
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 752863acecb8..a0bcfd3e7e7d 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -94,20 +94,19 @@ struct ft_lun {
94 */ 94 */
95struct ft_tpg { 95struct ft_tpg {
96 u32 index; 96 u32 index;
97 struct ft_lport_acl *lport_acl; 97 struct ft_lport_wwn *lport_wwn;
98 struct ft_tport *tport; /* active tport or NULL */ 98 struct ft_tport *tport; /* active tport or NULL */
99 struct list_head list; /* linkage in ft_lport_acl tpg_list */
100 struct list_head lun_list; /* head of LUNs */ 99 struct list_head lun_list; /* head of LUNs */
101 struct se_portal_group se_tpg; 100 struct se_portal_group se_tpg;
102 struct workqueue_struct *workqueue; 101 struct workqueue_struct *workqueue;
103}; 102};
104 103
105struct ft_lport_acl { 104struct ft_lport_wwn {
106 u64 wwpn; 105 u64 wwpn;
107 char name[FT_NAMELEN]; 106 char name[FT_NAMELEN];
108 struct list_head list; 107 struct list_head ft_wwn_node;
109 struct list_head tpg_list; 108 struct ft_tpg *tpg;
110 struct se_wwn fc_lport_wwn; 109 struct se_wwn se_wwn;
111}; 110};
112 111
113/* 112/*
@@ -128,7 +127,6 @@ struct ft_cmd {
128 u32 sg_cnt; /* No. of item in scatterlist */ 127 u32 sg_cnt; /* No. of item in scatterlist */
129}; 128};
130 129
131extern struct list_head ft_lport_list;
132extern struct mutex ft_lport_lock; 130extern struct mutex ft_lport_lock;
133extern struct fc4_prov ft_prov; 131extern struct fc4_prov ft_prov;
134extern struct target_fabric_configfs *ft_configfs; 132extern struct target_fabric_configfs *ft_configfs;
@@ -163,6 +161,7 @@ int ft_write_pending_status(struct se_cmd *);
163u32 ft_get_task_tag(struct se_cmd *); 161u32 ft_get_task_tag(struct se_cmd *);
164int ft_get_cmd_state(struct se_cmd *); 162int ft_get_cmd_state(struct se_cmd *);
165void ft_queue_tm_resp(struct se_cmd *); 163void ft_queue_tm_resp(struct se_cmd *);
164void ft_aborted_task(struct se_cmd *);
166 165
167/* 166/*
168 * other internal functions. 167 * other internal functions.
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 8b2c1aaf81de..01cf37f212c3 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -426,6 +426,11 @@ void ft_queue_tm_resp(struct se_cmd *se_cmd)
426 ft_send_resp_code(cmd, code); 426 ft_send_resp_code(cmd, code);
427} 427}
428 428
429void ft_aborted_task(struct se_cmd *se_cmd)
430{
431 return;
432}
433
429static void ft_send_work(struct work_struct *work); 434static void ft_send_work(struct work_struct *work);
430 435
431/* 436/*
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index e879da81ad93..efdcb9663a1a 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -50,7 +50,7 @@
50 50
51struct target_fabric_configfs *ft_configfs; 51struct target_fabric_configfs *ft_configfs;
52 52
53LIST_HEAD(ft_lport_list); 53static LIST_HEAD(ft_wwn_list);
54DEFINE_MUTEX(ft_lport_lock); 54DEFINE_MUTEX(ft_lport_lock);
55 55
56unsigned int ft_debug_logging; 56unsigned int ft_debug_logging;
@@ -298,7 +298,7 @@ static struct se_portal_group *ft_add_tpg(
298 struct config_group *group, 298 struct config_group *group,
299 const char *name) 299 const char *name)
300{ 300{
301 struct ft_lport_acl *lacl; 301 struct ft_lport_wwn *ft_wwn;
302 struct ft_tpg *tpg; 302 struct ft_tpg *tpg;
303 struct workqueue_struct *wq; 303 struct workqueue_struct *wq;
304 unsigned long index; 304 unsigned long index;
@@ -318,12 +318,17 @@ static struct se_portal_group *ft_add_tpg(
318 if (index > UINT_MAX) 318 if (index > UINT_MAX)
319 return NULL; 319 return NULL;
320 320
321 lacl = container_of(wwn, struct ft_lport_acl, fc_lport_wwn); 321 if ((index != 1)) {
322 pr_err("Error, a single TPG=1 is used for HW port mappings\n");
323 return ERR_PTR(-ENOSYS);
324 }
325
326 ft_wwn = container_of(wwn, struct ft_lport_wwn, se_wwn);
322 tpg = kzalloc(sizeof(*tpg), GFP_KERNEL); 327 tpg = kzalloc(sizeof(*tpg), GFP_KERNEL);
323 if (!tpg) 328 if (!tpg)
324 return NULL; 329 return NULL;
325 tpg->index = index; 330 tpg->index = index;
326 tpg->lport_acl = lacl; 331 tpg->lport_wwn = ft_wwn;
327 INIT_LIST_HEAD(&tpg->lun_list); 332 INIT_LIST_HEAD(&tpg->lun_list);
328 333
329 wq = alloc_workqueue("tcm_fc", 0, 1); 334 wq = alloc_workqueue("tcm_fc", 0, 1);
@@ -342,7 +347,7 @@ static struct se_portal_group *ft_add_tpg(
342 tpg->workqueue = wq; 347 tpg->workqueue = wq;
343 348
344 mutex_lock(&ft_lport_lock); 349 mutex_lock(&ft_lport_lock);
345 list_add_tail(&tpg->list, &lacl->tpg_list); 350 ft_wwn->tpg = tpg;
346 mutex_unlock(&ft_lport_lock); 351 mutex_unlock(&ft_lport_lock);
347 352
348 return &tpg->se_tpg; 353 return &tpg->se_tpg;
@@ -351,6 +356,7 @@ static struct se_portal_group *ft_add_tpg(
351static void ft_del_tpg(struct se_portal_group *se_tpg) 356static void ft_del_tpg(struct se_portal_group *se_tpg)
352{ 357{
353 struct ft_tpg *tpg = container_of(se_tpg, struct ft_tpg, se_tpg); 358 struct ft_tpg *tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
359 struct ft_lport_wwn *ft_wwn = tpg->lport_wwn;
354 360
355 pr_debug("del tpg %s\n", 361 pr_debug("del tpg %s\n",
356 config_item_name(&tpg->se_tpg.tpg_group.cg_item)); 362 config_item_name(&tpg->se_tpg.tpg_group.cg_item));
@@ -361,7 +367,7 @@ static void ft_del_tpg(struct se_portal_group *se_tpg)
361 synchronize_rcu(); 367 synchronize_rcu();
362 368
363 mutex_lock(&ft_lport_lock); 369 mutex_lock(&ft_lport_lock);
364 list_del(&tpg->list); 370 ft_wwn->tpg = NULL;
365 if (tpg->tport) { 371 if (tpg->tport) {
366 tpg->tport->tpg = NULL; 372 tpg->tport->tpg = NULL;
367 tpg->tport = NULL; 373 tpg->tport = NULL;
@@ -380,15 +386,11 @@ static void ft_del_tpg(struct se_portal_group *se_tpg)
380 */ 386 */
381struct ft_tpg *ft_lport_find_tpg(struct fc_lport *lport) 387struct ft_tpg *ft_lport_find_tpg(struct fc_lport *lport)
382{ 388{
383 struct ft_lport_acl *lacl; 389 struct ft_lport_wwn *ft_wwn;
384 struct ft_tpg *tpg;
385 390
386 list_for_each_entry(lacl, &ft_lport_list, list) { 391 list_for_each_entry(ft_wwn, &ft_wwn_list, ft_wwn_node) {
387 if (lacl->wwpn == lport->wwpn) { 392 if (ft_wwn->wwpn == lport->wwpn)
388 list_for_each_entry(tpg, &lacl->tpg_list, list) 393 return ft_wwn->tpg;
389 return tpg; /* XXX for now return first entry */
390 return NULL;
391 }
392 } 394 }
393 return NULL; 395 return NULL;
394} 396}
@@ -401,50 +403,49 @@ struct ft_tpg *ft_lport_find_tpg(struct fc_lport *lport)
401 * Add lport to allowed config. 403 * Add lport to allowed config.
402 * The name is the WWPN in lower-case ASCII, colon-separated bytes. 404 * The name is the WWPN in lower-case ASCII, colon-separated bytes.
403 */ 405 */
404static struct se_wwn *ft_add_lport( 406static struct se_wwn *ft_add_wwn(
405 struct target_fabric_configfs *tf, 407 struct target_fabric_configfs *tf,
406 struct config_group *group, 408 struct config_group *group,
407 const char *name) 409 const char *name)
408{ 410{
409 struct ft_lport_acl *lacl; 411 struct ft_lport_wwn *ft_wwn;
410 struct ft_lport_acl *old_lacl; 412 struct ft_lport_wwn *old_ft_wwn;
411 u64 wwpn; 413 u64 wwpn;
412 414
413 pr_debug("add lport %s\n", name); 415 pr_debug("add wwn %s\n", name);
414 if (ft_parse_wwn(name, &wwpn, 1) < 0) 416 if (ft_parse_wwn(name, &wwpn, 1) < 0)
415 return NULL; 417 return NULL;
416 lacl = kzalloc(sizeof(*lacl), GFP_KERNEL); 418 ft_wwn = kzalloc(sizeof(*ft_wwn), GFP_KERNEL);
417 if (!lacl) 419 if (!ft_wwn)
418 return NULL; 420 return NULL;
419 lacl->wwpn = wwpn; 421 ft_wwn->wwpn = wwpn;
420 INIT_LIST_HEAD(&lacl->tpg_list);
421 422
422 mutex_lock(&ft_lport_lock); 423 mutex_lock(&ft_lport_lock);
423 list_for_each_entry(old_lacl, &ft_lport_list, list) { 424 list_for_each_entry(old_ft_wwn, &ft_wwn_list, ft_wwn_node) {
424 if (old_lacl->wwpn == wwpn) { 425 if (old_ft_wwn->wwpn == wwpn) {
425 mutex_unlock(&ft_lport_lock); 426 mutex_unlock(&ft_lport_lock);
426 kfree(lacl); 427 kfree(ft_wwn);
427 return NULL; 428 return NULL;
428 } 429 }
429 } 430 }
430 list_add_tail(&lacl->list, &ft_lport_list); 431 list_add_tail(&ft_wwn->ft_wwn_node, &ft_wwn_list);
431 ft_format_wwn(lacl->name, sizeof(lacl->name), wwpn); 432 ft_format_wwn(ft_wwn->name, sizeof(ft_wwn->name), wwpn);
432 mutex_unlock(&ft_lport_lock); 433 mutex_unlock(&ft_lport_lock);
433 434
434 return &lacl->fc_lport_wwn; 435 return &ft_wwn->se_wwn;
435} 436}
436 437
437static void ft_del_lport(struct se_wwn *wwn) 438static void ft_del_wwn(struct se_wwn *wwn)
438{ 439{
439 struct ft_lport_acl *lacl = container_of(wwn, 440 struct ft_lport_wwn *ft_wwn = container_of(wwn,
440 struct ft_lport_acl, fc_lport_wwn); 441 struct ft_lport_wwn, se_wwn);
441 442
442 pr_debug("del lport %s\n", lacl->name); 443 pr_debug("del wwn %s\n", ft_wwn->name);
443 mutex_lock(&ft_lport_lock); 444 mutex_lock(&ft_lport_lock);
444 list_del(&lacl->list); 445 list_del(&ft_wwn->ft_wwn_node);
445 mutex_unlock(&ft_lport_lock); 446 mutex_unlock(&ft_lport_lock);
446 447
447 kfree(lacl); 448 kfree(ft_wwn);
448} 449}
449 450
450static ssize_t ft_wwn_show_attr_version( 451static ssize_t ft_wwn_show_attr_version(
@@ -471,7 +472,7 @@ static char *ft_get_fabric_wwn(struct se_portal_group *se_tpg)
471{ 472{
472 struct ft_tpg *tpg = se_tpg->se_tpg_fabric_ptr; 473 struct ft_tpg *tpg = se_tpg->se_tpg_fabric_ptr;
473 474
474 return tpg->lport_acl->name; 475 return tpg->lport_wwn->name;
475} 476}
476 477
477static u16 ft_get_tag(struct se_portal_group *se_tpg) 478static u16 ft_get_tag(struct se_portal_group *se_tpg)
@@ -536,12 +537,13 @@ static struct target_core_fabric_ops ft_fabric_ops = {
536 .queue_data_in = ft_queue_data_in, 537 .queue_data_in = ft_queue_data_in,
537 .queue_status = ft_queue_status, 538 .queue_status = ft_queue_status,
538 .queue_tm_rsp = ft_queue_tm_resp, 539 .queue_tm_rsp = ft_queue_tm_resp,
540 .aborted_task = ft_aborted_task,
539 /* 541 /*
540 * Setup function pointers for generic logic in 542 * Setup function pointers for generic logic in
541 * target_core_fabric_configfs.c 543 * target_core_fabric_configfs.c
542 */ 544 */
543 .fabric_make_wwn = &ft_add_lport, 545 .fabric_make_wwn = &ft_add_wwn,
544 .fabric_drop_wwn = &ft_del_lport, 546 .fabric_drop_wwn = &ft_del_wwn,
545 .fabric_make_tpg = &ft_add_tpg, 547 .fabric_make_tpg = &ft_add_tpg,
546 .fabric_drop_tpg = &ft_del_tpg, 548 .fabric_drop_tpg = &ft_del_tpg,
547 .fabric_post_link = NULL, 549 .fabric_post_link = NULL,
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index ae52c08dad09..21ce50880c79 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -51,7 +51,7 @@ static void ft_sess_delete_all(struct ft_tport *);
51 * Lookup or allocate target local port. 51 * Lookup or allocate target local port.
52 * Caller holds ft_lport_lock. 52 * Caller holds ft_lport_lock.
53 */ 53 */
54static struct ft_tport *ft_tport_create(struct fc_lport *lport) 54static struct ft_tport *ft_tport_get(struct fc_lport *lport)
55{ 55{
56 struct ft_tpg *tpg; 56 struct ft_tpg *tpg;
57 struct ft_tport *tport; 57 struct ft_tport *tport;
@@ -68,6 +68,7 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
68 68
69 if (tport) { 69 if (tport) {
70 tport->tpg = tpg; 70 tport->tpg = tpg;
71 tpg->tport = tport;
71 return tport; 72 return tport;
72 } 73 }
73 74
@@ -114,7 +115,7 @@ static void ft_tport_delete(struct ft_tport *tport)
114void ft_lport_add(struct fc_lport *lport, void *arg) 115void ft_lport_add(struct fc_lport *lport, void *arg)
115{ 116{
116 mutex_lock(&ft_lport_lock); 117 mutex_lock(&ft_lport_lock);
117 ft_tport_create(lport); 118 ft_tport_get(lport);
118 mutex_unlock(&ft_lport_lock); 119 mutex_unlock(&ft_lport_lock);
119} 120}
120 121
@@ -211,7 +212,8 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
211 return NULL; 212 return NULL;
212 213
213 sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS, 214 sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS,
214 sizeof(struct ft_cmd)); 215 sizeof(struct ft_cmd),
216 TARGET_PROT_NORMAL);
215 if (IS_ERR(sess->se_sess)) { 217 if (IS_ERR(sess->se_sess)) {
216 kfree(sess); 218 kfree(sess);
217 return NULL; 219 return NULL;
@@ -350,7 +352,7 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
350 struct ft_node_acl *acl; 352 struct ft_node_acl *acl;
351 u32 fcp_parm; 353 u32 fcp_parm;
352 354
353 tport = ft_tport_create(rdata->local_port); 355 tport = ft_tport_get(rdata->local_port);
354 if (!tport) 356 if (!tport)
355 goto not_target; /* not a target for this local port */ 357 goto not_target; /* not a target for this local port */
356 358
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 45af765a3198..a99c63152b8d 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -62,12 +62,16 @@ enum imx_thermal_trip {
62#define IMX_POLLING_DELAY 2000 /* millisecond */ 62#define IMX_POLLING_DELAY 2000 /* millisecond */
63#define IMX_PASSIVE_DELAY 1000 63#define IMX_PASSIVE_DELAY 1000
64 64
65#define FACTOR0 10000000
66#define FACTOR1 15976
67#define FACTOR2 4297157
68
65struct imx_thermal_data { 69struct imx_thermal_data {
66 struct thermal_zone_device *tz; 70 struct thermal_zone_device *tz;
67 struct thermal_cooling_device *cdev; 71 struct thermal_cooling_device *cdev;
68 enum thermal_device_mode mode; 72 enum thermal_device_mode mode;
69 struct regmap *tempmon; 73 struct regmap *tempmon;
70 int c1, c2; /* See formula in imx_get_sensor_data() */ 74 u32 c1, c2; /* See formula in imx_get_sensor_data() */
71 unsigned long temp_passive; 75 unsigned long temp_passive;
72 unsigned long temp_critical; 76 unsigned long temp_critical;
73 unsigned long alarm_temp; 77 unsigned long alarm_temp;
@@ -84,7 +88,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data *data,
84 int alarm_value; 88 int alarm_value;
85 89
86 data->alarm_temp = alarm_temp; 90 data->alarm_temp = alarm_temp;
87 alarm_value = (alarm_temp - data->c2) / data->c1; 91 alarm_value = (data->c2 - alarm_temp) / data->c1;
88 regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_ALARM_VALUE_MASK); 92 regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_ALARM_VALUE_MASK);
89 regmap_write(map, TEMPSENSE0 + REG_SET, alarm_value << 93 regmap_write(map, TEMPSENSE0 + REG_SET, alarm_value <<
90 TEMPSENSE0_ALARM_VALUE_SHIFT); 94 TEMPSENSE0_ALARM_VALUE_SHIFT);
@@ -136,7 +140,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
136 n_meas = (val & TEMPSENSE0_TEMP_CNT_MASK) >> TEMPSENSE0_TEMP_CNT_SHIFT; 140 n_meas = (val & TEMPSENSE0_TEMP_CNT_MASK) >> TEMPSENSE0_TEMP_CNT_SHIFT;
137 141
138 /* See imx_get_sensor_data() for formula derivation */ 142 /* See imx_get_sensor_data() for formula derivation */
139 *temp = data->c2 + data->c1 * n_meas; 143 *temp = data->c2 - n_meas * data->c1;
140 144
141 /* Update alarm value to next higher trip point */ 145 /* Update alarm value to next higher trip point */
142 if (data->alarm_temp == data->temp_passive && *temp >= data->temp_passive) 146 if (data->alarm_temp == data->temp_passive && *temp >= data->temp_passive)
@@ -305,6 +309,7 @@ static int imx_get_sensor_data(struct platform_device *pdev)
305 int t1, t2, n1, n2; 309 int t1, t2, n1, n2;
306 int ret; 310 int ret;
307 u32 val; 311 u32 val;
312 u64 temp64;
308 313
309 map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, 314 map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
310 "fsl,tempmon-data"); 315 "fsl,tempmon-data");
@@ -330,6 +335,8 @@ static int imx_get_sensor_data(struct platform_device *pdev)
330 * [31:20] - sensor value @ 25C 335 * [31:20] - sensor value @ 25C
331 * [19:8] - sensor value of hot 336 * [19:8] - sensor value of hot
332 * [7:0] - hot temperature value 337 * [7:0] - hot temperature value
338 * Use universal formula now and only need sensor value @ 25C
339 * slope = 0.4297157 - (0.0015976 * 25C fuse)
333 */ 340 */
334 n1 = val >> 20; 341 n1 = val >> 20;
335 n2 = (val & 0xfff00) >> 8; 342 n2 = (val & 0xfff00) >> 8;
@@ -337,20 +344,26 @@ static int imx_get_sensor_data(struct platform_device *pdev)
337 t1 = 25; /* t1 always 25C */ 344 t1 = 25; /* t1 always 25C */
338 345
339 /* 346 /*
340 * Derived from linear interpolation, 347 * Derived from linear interpolation:
341 * Tmeas = T2 + (Nmeas - N2) * (T1 - T2) / (N1 - N2) 348 * slope = 0.4297157 - (0.0015976 * 25C fuse)
349 * slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0
350 * (Nmeas - n1) / (Tmeas - t1) = slope
342 * We want to reduce this down to the minimum computation necessary 351 * We want to reduce this down to the minimum computation necessary
343 * for each temperature read. Also, we want Tmeas in millicelsius 352 * for each temperature read. Also, we want Tmeas in millicelsius
344 * and we don't want to lose precision from integer division. So... 353 * and we don't want to lose precision from integer division. So...
345 * milli_Tmeas = 1000 * T2 + 1000 * (Nmeas - N2) * (T1 - T2) / (N1 - N2) 354 * Tmeas = (Nmeas - n1) / slope + t1
346 * Let constant c1 = 1000 * (T1 - T2) / (N1 - N2) 355 * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1
347 * milli_Tmeas = (1000 * T2) + c1 * (Nmeas - N2) 356 * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1
348 * milli_Tmeas = (1000 * T2) + (c1 * Nmeas) - (c1 * N2) 357 * Let constant c1 = (-1000 / slope)
349 * Let constant c2 = (1000 * T2) - (c1 * N2) 358 * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1
350 * milli_Tmeas = c2 + (c1 * Nmeas) 359 * Let constant c2 = n1 *c1 + 1000 * t1
360 * milli_Tmeas = c2 - Nmeas * c1
351 */ 361 */
352 data->c1 = 1000 * (t1 - t2) / (n1 - n2); 362 temp64 = FACTOR0;
353 data->c2 = 1000 * t2 - data->c1 * n2; 363 temp64 *= 1000;
364 do_div(temp64, FACTOR1 * n1 - FACTOR2);
365 data->c1 = temp64;
366 data->c2 = n1 * data->c1 + 1000 * t1;
354 367
355 /* 368 /*
356 * Set the default passive cooling trip point to 20 °C below the 369 * Set the default passive cooling trip point to 20 °C below the
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 79a09d02bbca..5a37940b02c9 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -299,12 +299,17 @@ static void _rcar_thermal_irq_ctrl(struct rcar_thermal_priv *priv, int enable)
299static void rcar_thermal_work(struct work_struct *work) 299static void rcar_thermal_work(struct work_struct *work)
300{ 300{
301 struct rcar_thermal_priv *priv; 301 struct rcar_thermal_priv *priv;
302 unsigned long cctemp, nctemp;
302 303
303 priv = container_of(work, struct rcar_thermal_priv, work.work); 304 priv = container_of(work, struct rcar_thermal_priv, work.work);
304 305
306 rcar_thermal_get_temp(priv->zone, &cctemp);
305 rcar_thermal_update_temp(priv); 307 rcar_thermal_update_temp(priv);
306 rcar_thermal_irq_enable(priv); 308 rcar_thermal_irq_enable(priv);
307 thermal_zone_device_update(priv->zone); 309
310 rcar_thermal_get_temp(priv->zone, &nctemp);
311 if (nctemp != cctemp)
312 thermal_zone_device_update(priv->zone);
308} 313}
309 314
310static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status) 315static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status)
@@ -313,7 +318,7 @@ static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status)
313 318
314 status = (status >> rcar_id_to_shift(priv)) & 0x3; 319 status = (status >> rcar_id_to_shift(priv)) & 0x3;
315 320
316 if (status & 0x3) { 321 if (status) {
317 dev_dbg(dev, "thermal%d %s%s\n", 322 dev_dbg(dev, "thermal%d %s%s\n",
318 priv->id, 323 priv->id,
319 (status & 0x2) ? "Rising " : "", 324 (status & 0x2) ? "Rising " : "",
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 74c0e3474d6e..3ab12ee359b7 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -1500,10 +1500,8 @@ static int ti_bandgap_resume(struct device *dev)
1500 1500
1501 return ti_bandgap_restore_ctxt(bgp); 1501 return ti_bandgap_restore_ctxt(bgp);
1502} 1502}
1503static const struct dev_pm_ops ti_bandgap_dev_pm_ops = { 1503static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
1504 SET_SYSTEM_SLEEP_PM_OPS(ti_bandgap_suspend, 1504 ti_bandgap_resume);
1505 ti_bandgap_resume)
1506};
1507 1505
1508#define DEV_PM_OPS (&ti_bandgap_dev_pm_ops) 1506#define DEV_PM_OPS (&ti_bandgap_dev_pm_ops)
1509#else 1507#else
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index b01659bd4f7c..a585079b4b38 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -61,6 +61,7 @@ static struct hvc_opal_priv *hvc_opal_privs[MAX_NR_HVC_CONSOLES];
61/* For early boot console */ 61/* For early boot console */
62static struct hvc_opal_priv hvc_opal_boot_priv; 62static struct hvc_opal_priv hvc_opal_boot_priv;
63static u32 hvc_opal_boot_termno; 63static u32 hvc_opal_boot_termno;
64static bool hvc_opal_event_registered;
64 65
65static const struct hv_ops hvc_opal_raw_ops = { 66static const struct hv_ops hvc_opal_raw_ops = {
66 .get_chars = opal_get_chars, 67 .get_chars = opal_get_chars,
@@ -161,6 +162,18 @@ static const struct hv_ops hvc_opal_hvsi_ops = {
161 .tiocmset = hvc_opal_hvsi_tiocmset, 162 .tiocmset = hvc_opal_hvsi_tiocmset,
162}; 163};
163 164
165static int hvc_opal_console_event(struct notifier_block *nb,
166 unsigned long events, void *change)
167{
168 if (events & OPAL_EVENT_CONSOLE_INPUT)
169 hvc_kick();
170 return 0;
171}
172
173static struct notifier_block hvc_opal_console_nb = {
174 .notifier_call = hvc_opal_console_event,
175};
176
164static int hvc_opal_probe(struct platform_device *dev) 177static int hvc_opal_probe(struct platform_device *dev)
165{ 178{
166 const struct hv_ops *ops; 179 const struct hv_ops *ops;
@@ -170,6 +183,7 @@ static int hvc_opal_probe(struct platform_device *dev)
170 unsigned int termno, boot = 0; 183 unsigned int termno, boot = 0;
171 const __be32 *reg; 184 const __be32 *reg;
172 185
186
173 if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) { 187 if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) {
174 proto = HV_PROTOCOL_RAW; 188 proto = HV_PROTOCOL_RAW;
175 ops = &hvc_opal_raw_ops; 189 ops = &hvc_opal_raw_ops;
@@ -213,12 +227,18 @@ static int hvc_opal_probe(struct platform_device *dev)
213 dev->dev.of_node->full_name, 227 dev->dev.of_node->full_name,
214 boot ? " (boot console)" : ""); 228 boot ? " (boot console)" : "");
215 229
216 /* We don't do IRQ yet */ 230 /* We don't do IRQ ... */
217 hp = hvc_alloc(termno, 0, ops, MAX_VIO_PUT_CHARS); 231 hp = hvc_alloc(termno, 0, ops, MAX_VIO_PUT_CHARS);
218 if (IS_ERR(hp)) 232 if (IS_ERR(hp))
219 return PTR_ERR(hp); 233 return PTR_ERR(hp);
220 dev_set_drvdata(&dev->dev, hp); 234 dev_set_drvdata(&dev->dev, hp);
221 235
236 /* ... but we use OPAL event to kick the console */
237 if (!hvc_opal_event_registered) {
238 opal_notifier_register(&hvc_opal_console_nb);
239 hvc_opal_event_registered = true;
240 }
241
222 return 0; 242 return 0;
223} 243}
224 244
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index b0e540137e39..90ca082935f6 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -65,6 +65,7 @@ static void tty_audit_log(const char *description, int major, int minor,
65{ 65{
66 struct audit_buffer *ab; 66 struct audit_buffer *ab;
67 struct task_struct *tsk = current; 67 struct task_struct *tsk = current;
68 pid_t pid = task_pid_nr(tsk);
68 uid_t uid = from_kuid(&init_user_ns, task_uid(tsk)); 69 uid_t uid = from_kuid(&init_user_ns, task_uid(tsk));
69 uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(tsk)); 70 uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(tsk));
70 unsigned int sessionid = audit_get_sessionid(tsk); 71 unsigned int sessionid = audit_get_sessionid(tsk);
@@ -74,7 +75,7 @@ static void tty_audit_log(const char *description, int major, int minor,
74 char name[sizeof(tsk->comm)]; 75 char name[sizeof(tsk->comm)];
75 76
76 audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d" 77 audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d"
77 " minor=%d comm=", description, tsk->pid, uid, 78 " minor=%d comm=", description, pid, uid,
78 loginuid, sessionid, major, minor); 79 loginuid, sessionid, major, minor);
79 get_task_comm(name, tsk); 80 get_task_comm(name, tsk);
80 audit_log_untrustedstring(ab, name); 81 audit_log_untrustedstring(ab, name);
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
index 460c266b8e24..f058c0368d61 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -1471,6 +1471,11 @@ static void usbg_queue_tm_rsp(struct se_cmd *se_cmd)
1471{ 1471{
1472} 1472}
1473 1473
1474static void usbg_aborted_task(struct se_cmd *se_cmd)
1475{
1476 return;
1477}
1478
1474static const char *usbg_check_wwn(const char *name) 1479static const char *usbg_check_wwn(const char *name)
1475{ 1480{
1476 const char *n; 1481 const char *n;
@@ -1726,7 +1731,7 @@ static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name)
1726 pr_err("Unable to allocate struct tcm_vhost_nexus\n"); 1731 pr_err("Unable to allocate struct tcm_vhost_nexus\n");
1727 goto err_unlock; 1732 goto err_unlock;
1728 } 1733 }
1729 tv_nexus->tvn_se_sess = transport_init_session(); 1734 tv_nexus->tvn_se_sess = transport_init_session(TARGET_PROT_NORMAL);
1730 if (IS_ERR(tv_nexus->tvn_se_sess)) 1735 if (IS_ERR(tv_nexus->tvn_se_sess))
1731 goto err_free; 1736 goto err_free;
1732 1737
@@ -1897,6 +1902,7 @@ static struct target_core_fabric_ops usbg_ops = {
1897 .queue_data_in = usbg_send_read_response, 1902 .queue_data_in = usbg_send_read_response,
1898 .queue_status = usbg_send_status_response, 1903 .queue_status = usbg_send_status_response,
1899 .queue_tm_rsp = usbg_queue_tm_rsp, 1904 .queue_tm_rsp = usbg_queue_tm_rsp,
1905 .aborted_task = usbg_aborted_task,
1900 .check_stop_free = usbg_check_stop_free, 1906 .check_stop_free = usbg_check_stop_free,
1901 1907
1902 .fabric_make_wwn = usbg_make_tport, 1908 .fabric_make_wwn = usbg_make_tport,
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index e1e22e0f01e8..be414d2b2b22 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -818,9 +818,9 @@ static int vhost_net_release(struct inode *inode, struct file *f)
818 vhost_dev_cleanup(&n->dev, false); 818 vhost_dev_cleanup(&n->dev, false);
819 vhost_net_vq_reset(n); 819 vhost_net_vq_reset(n);
820 if (tx_sock) 820 if (tx_sock)
821 fput(tx_sock->file); 821 sockfd_put(tx_sock);
822 if (rx_sock) 822 if (rx_sock)
823 fput(rx_sock->file); 823 sockfd_put(rx_sock);
824 /* Make sure no callbacks are outstanding */ 824 /* Make sure no callbacks are outstanding */
825 synchronize_rcu_bh(); 825 synchronize_rcu_bh();
826 /* We do an extra flush before freeing memory, 826 /* We do an extra flush before freeing memory,
@@ -860,7 +860,7 @@ static struct socket *get_raw_socket(int fd)
860 } 860 }
861 return sock; 861 return sock;
862err: 862err:
863 fput(sock->file); 863 sockfd_put(sock);
864 return ERR_PTR(r); 864 return ERR_PTR(r);
865} 865}
866 866
@@ -966,7 +966,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
966 966
967 if (oldsock) { 967 if (oldsock) {
968 vhost_net_flush_vq(n, index); 968 vhost_net_flush_vq(n, index);
969 fput(oldsock->file); 969 sockfd_put(oldsock);
970 } 970 }
971 971
972 mutex_unlock(&n->dev.mutex); 972 mutex_unlock(&n->dev.mutex);
@@ -978,7 +978,7 @@ err_used:
978 if (ubufs) 978 if (ubufs)
979 vhost_net_ubuf_put_wait_and_free(ubufs); 979 vhost_net_ubuf_put_wait_and_free(ubufs);
980err_ubufs: 980err_ubufs:
981 fput(sock->file); 981 sockfd_put(sock);
982err_vq: 982err_vq:
983 mutex_unlock(&vq->mutex); 983 mutex_unlock(&vq->mutex);
984err: 984err:
@@ -1009,9 +1009,9 @@ static long vhost_net_reset_owner(struct vhost_net *n)
1009done: 1009done:
1010 mutex_unlock(&n->dev.mutex); 1010 mutex_unlock(&n->dev.mutex);
1011 if (tx_sock) 1011 if (tx_sock)
1012 fput(tx_sock->file); 1012 sockfd_put(tx_sock);
1013 if (rx_sock) 1013 if (rx_sock)
1014 fput(rx_sock->file); 1014 sockfd_put(rx_sock);
1015 return err; 1015 return err;
1016} 1016}
1017 1017
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index e48d4a672580..cf50ce93975b 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -539,6 +539,11 @@ static void tcm_vhost_queue_tm_rsp(struct se_cmd *se_cmd)
539 return; 539 return;
540} 540}
541 541
542static void tcm_vhost_aborted_task(struct se_cmd *se_cmd)
543{
544 return;
545}
546
542static void tcm_vhost_free_evt(struct vhost_scsi *vs, struct tcm_vhost_evt *evt) 547static void tcm_vhost_free_evt(struct vhost_scsi *vs, struct tcm_vhost_evt *evt)
543{ 548{
544 vs->vs_events_nr--; 549 vs->vs_events_nr--;
@@ -1740,7 +1745,8 @@ static int tcm_vhost_make_nexus(struct tcm_vhost_tpg *tpg,
1740 */ 1745 */
1741 tv_nexus->tvn_se_sess = transport_init_session_tags( 1746 tv_nexus->tvn_se_sess = transport_init_session_tags(
1742 TCM_VHOST_DEFAULT_TAGS, 1747 TCM_VHOST_DEFAULT_TAGS,
1743 sizeof(struct tcm_vhost_cmd)); 1748 sizeof(struct tcm_vhost_cmd),
1749 TARGET_PROT_NORMAL);
1744 if (IS_ERR(tv_nexus->tvn_se_sess)) { 1750 if (IS_ERR(tv_nexus->tvn_se_sess)) {
1745 mutex_unlock(&tpg->tv_tpg_mutex); 1751 mutex_unlock(&tpg->tv_tpg_mutex);
1746 kfree(tv_nexus); 1752 kfree(tv_nexus);
@@ -2131,6 +2137,7 @@ static struct target_core_fabric_ops tcm_vhost_ops = {
2131 .queue_data_in = tcm_vhost_queue_data_in, 2137 .queue_data_in = tcm_vhost_queue_data_in,
2132 .queue_status = tcm_vhost_queue_status, 2138 .queue_status = tcm_vhost_queue_status,
2133 .queue_tm_rsp = tcm_vhost_queue_tm_rsp, 2139 .queue_tm_rsp = tcm_vhost_queue_tm_rsp,
2140 .aborted_task = tcm_vhost_aborted_task,
2134 /* 2141 /*
2135 * Setup callers for generic logic in target_core_fabric_configfs.c 2142 * Setup callers for generic logic in target_core_fabric_configfs.c
2136 */ 2143 */
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 27d3cf255e78..bd2172c2d650 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -347,7 +347,7 @@ struct backlight_device *backlight_device_register(const char *name,
347 347
348 rc = device_register(&new_bd->dev); 348 rc = device_register(&new_bd->dev);
349 if (rc) { 349 if (rc) {
350 kfree(new_bd); 350 put_device(&new_bd->dev);
351 return ERR_PTR(rc); 351 return ERR_PTR(rc);
352 } 352 }
353 353
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 81fb12770c2a..a2eba12e1cb7 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -13,6 +13,8 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/of_gpio.h>
16#include <linux/platform_data/gpio_backlight.h> 18#include <linux/platform_data/gpio_backlight.h>
17#include <linux/platform_device.h> 19#include <linux/platform_device.h>
18#include <linux/slab.h> 20#include <linux/slab.h>
@@ -23,6 +25,7 @@ struct gpio_backlight {
23 25
24 int gpio; 26 int gpio;
25 int active; 27 int active;
28 int def_value;
26}; 29};
27 30
28static int gpio_backlight_update_status(struct backlight_device *bl) 31static int gpio_backlight_update_status(struct backlight_device *bl)
@@ -60,6 +63,29 @@ static const struct backlight_ops gpio_backlight_ops = {
60 .check_fb = gpio_backlight_check_fb, 63 .check_fb = gpio_backlight_check_fb,
61}; 64};
62 65
66static int gpio_backlight_probe_dt(struct platform_device *pdev,
67 struct gpio_backlight *gbl)
68{
69 struct device_node *np = pdev->dev.of_node;
70 enum of_gpio_flags gpio_flags;
71
72 gbl->gpio = of_get_gpio_flags(np, 0, &gpio_flags);
73
74 if (!gpio_is_valid(gbl->gpio)) {
75 if (gbl->gpio != -EPROBE_DEFER) {
76 dev_err(&pdev->dev,
77 "Error: The gpios parameter is missing or invalid.\n");
78 }
79 return gbl->gpio;
80 }
81
82 gbl->active = (gpio_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
83
84 gbl->def_value = of_property_read_bool(np, "default-on");
85
86 return 0;
87}
88
63static int gpio_backlight_probe(struct platform_device *pdev) 89static int gpio_backlight_probe(struct platform_device *pdev)
64{ 90{
65 struct gpio_backlight_platform_data *pdata = 91 struct gpio_backlight_platform_data *pdata =
@@ -67,10 +93,12 @@ static int gpio_backlight_probe(struct platform_device *pdev)
67 struct backlight_properties props; 93 struct backlight_properties props;
68 struct backlight_device *bl; 94 struct backlight_device *bl;
69 struct gpio_backlight *gbl; 95 struct gpio_backlight *gbl;
96 struct device_node *np = pdev->dev.of_node;
70 int ret; 97 int ret;
71 98
72 if (!pdata) { 99 if (!pdata && !np) {
73 dev_err(&pdev->dev, "failed to find platform data\n"); 100 dev_err(&pdev->dev,
101 "failed to find platform data or device tree node.\n");
74 return -ENODEV; 102 return -ENODEV;
75 } 103 }
76 104
@@ -79,14 +107,22 @@ static int gpio_backlight_probe(struct platform_device *pdev)
79 return -ENOMEM; 107 return -ENOMEM;
80 108
81 gbl->dev = &pdev->dev; 109 gbl->dev = &pdev->dev;
82 gbl->fbdev = pdata->fbdev; 110
83 gbl->gpio = pdata->gpio; 111 if (np) {
84 gbl->active = pdata->active_low ? 0 : 1; 112 ret = gpio_backlight_probe_dt(pdev, gbl);
113 if (ret)
114 return ret;
115 } else {
116 gbl->fbdev = pdata->fbdev;
117 gbl->gpio = pdata->gpio;
118 gbl->active = pdata->active_low ? 0 : 1;
119 gbl->def_value = pdata->def_value;
120 }
85 121
86 ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT | 122 ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT |
87 (gbl->active ? GPIOF_INIT_LOW 123 (gbl->active ? GPIOF_INIT_LOW
88 : GPIOF_INIT_HIGH), 124 : GPIOF_INIT_HIGH),
89 pdata->name); 125 pdata ? pdata->name : "backlight");
90 if (ret < 0) { 126 if (ret < 0) {
91 dev_err(&pdev->dev, "unable to request GPIO\n"); 127 dev_err(&pdev->dev, "unable to request GPIO\n");
92 return ret; 128 return ret;
@@ -103,17 +139,25 @@ static int gpio_backlight_probe(struct platform_device *pdev)
103 return PTR_ERR(bl); 139 return PTR_ERR(bl);
104 } 140 }
105 141
106 bl->props.brightness = pdata->def_value; 142 bl->props.brightness = gbl->def_value;
107 backlight_update_status(bl); 143 backlight_update_status(bl);
108 144
109 platform_set_drvdata(pdev, bl); 145 platform_set_drvdata(pdev, bl);
110 return 0; 146 return 0;
111} 147}
112 148
149#ifdef CONFIG_OF
150static struct of_device_id gpio_backlight_of_match[] = {
151 { .compatible = "gpio-backlight" },
152 { /* sentinel */ }
153};
154#endif
155
113static struct platform_driver gpio_backlight_driver = { 156static struct platform_driver gpio_backlight_driver = {
114 .driver = { 157 .driver = {
115 .name = "gpio-backlight", 158 .name = "gpio-backlight",
116 .owner = THIS_MODULE, 159 .owner = THIS_MODULE,
160 .of_match_table = of_match_ptr(gpio_backlight_of_match),
117 }, 161 },
118 .probe = gpio_backlight_probe, 162 .probe = gpio_backlight_probe,
119}; 163};
diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c
index 6fd60adf922e..5f36808d214f 100644
--- a/drivers/video/backlight/lm3639_bl.c
+++ b/drivers/video/backlight/lm3639_bl.c
@@ -349,8 +349,9 @@ static int lm3639_probe(struct i2c_client *client,
349 props.brightness = pdata->init_brt_led; 349 props.brightness = pdata->init_brt_led;
350 props.max_brightness = pdata->max_brt_led; 350 props.max_brightness = pdata->max_brt_led;
351 pchip->bled = 351 pchip->bled =
352 backlight_device_register("lm3639_bled", pchip->dev, pchip, 352 devm_backlight_device_register(pchip->dev, "lm3639_bled",
353 &lm3639_bled_ops, &props); 353 pchip->dev, pchip, &lm3639_bled_ops,
354 &props);
354 if (IS_ERR(pchip->bled)) { 355 if (IS_ERR(pchip->bled)) {
355 dev_err(&client->dev, "fail : backlight register\n"); 356 dev_err(&client->dev, "fail : backlight register\n");
356 ret = PTR_ERR(pchip->bled); 357 ret = PTR_ERR(pchip->bled);
@@ -360,7 +361,7 @@ static int lm3639_probe(struct i2c_client *client,
360 ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode); 361 ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode);
361 if (ret < 0) { 362 if (ret < 0) {
362 dev_err(&client->dev, "failed : add sysfs entries\n"); 363 dev_err(&client->dev, "failed : add sysfs entries\n");
363 goto err_bled_mode; 364 goto err_out;
364 } 365 }
365 366
366 /* flash */ 367 /* flash */
@@ -391,8 +392,6 @@ err_torch:
391 led_classdev_unregister(&pchip->cdev_flash); 392 led_classdev_unregister(&pchip->cdev_flash);
392err_flash: 393err_flash:
393 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); 394 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode);
394err_bled_mode:
395 backlight_device_unregister(pchip->bled);
396err_out: 395err_out:
397 return ret; 396 return ret;
398} 397}
@@ -407,10 +406,8 @@ static int lm3639_remove(struct i2c_client *client)
407 led_classdev_unregister(&pchip->cdev_torch); 406 led_classdev_unregister(&pchip->cdev_torch);
408 if (&pchip->cdev_flash) 407 if (&pchip->cdev_flash)
409 led_classdev_unregister(&pchip->cdev_flash); 408 led_classdev_unregister(&pchip->cdev_flash);
410 if (pchip->bled) { 409 if (pchip->bled)
411 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); 410 device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode);
412 backlight_device_unregister(pchip->bled);
413 }
414 return 0; 411 return 0;
415} 412}
416 413
@@ -432,6 +429,6 @@ static struct i2c_driver lm3639_i2c_driver = {
432module_i2c_driver(lm3639_i2c_driver); 429module_i2c_driver(lm3639_i2c_driver);
433 430
434MODULE_DESCRIPTION("Texas Instruments Backlight+Flash LED driver for LM3639"); 431MODULE_DESCRIPTION("Texas Instruments Backlight+Flash LED driver for LM3639");
435MODULE_AUTHOR("Daniel Jeong <daniel.jeong@ti.com>"); 432MODULE_AUTHOR("Daniel Jeong <gshark.jeong@gmail.com>");
436MODULE_AUTHOR("G.Shark Jeong <gshark.jeong@gmail.com>"); 433MODULE_AUTHOR("Ldd Mlp <ldd-mlp@list.ti.com>");
437MODULE_LICENSE("GPL v2"); 434MODULE_LICENSE("GPL v2");
diff --git a/fs/aio.c b/fs/aio.c
index 062a5f6a1448..12a3de0ee6da 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -52,7 +52,8 @@
52struct aio_ring { 52struct aio_ring {
53 unsigned id; /* kernel internal index number */ 53 unsigned id; /* kernel internal index number */
54 unsigned nr; /* number of io_events */ 54 unsigned nr; /* number of io_events */
55 unsigned head; 55 unsigned head; /* Written to by userland or under ring_lock
56 * mutex by aio_read_events_ring(). */
56 unsigned tail; 57 unsigned tail;
57 58
58 unsigned magic; 59 unsigned magic;
@@ -243,6 +244,11 @@ static void aio_free_ring(struct kioctx *ctx)
243{ 244{
244 int i; 245 int i;
245 246
247 /* Disconnect the kiotx from the ring file. This prevents future
248 * accesses to the kioctx from page migration.
249 */
250 put_aio_ring_file(ctx);
251
246 for (i = 0; i < ctx->nr_pages; i++) { 252 for (i = 0; i < ctx->nr_pages; i++) {
247 struct page *page; 253 struct page *page;
248 pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i, 254 pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i,
@@ -254,8 +260,6 @@ static void aio_free_ring(struct kioctx *ctx)
254 put_page(page); 260 put_page(page);
255 } 261 }
256 262
257 put_aio_ring_file(ctx);
258
259 if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) { 263 if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) {
260 kfree(ctx->ring_pages); 264 kfree(ctx->ring_pages);
261 ctx->ring_pages = NULL; 265 ctx->ring_pages = NULL;
@@ -283,29 +287,38 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
283{ 287{
284 struct kioctx *ctx; 288 struct kioctx *ctx;
285 unsigned long flags; 289 unsigned long flags;
290 pgoff_t idx;
286 int rc; 291 int rc;
287 292
288 rc = 0; 293 rc = 0;
289 294
290 /* Make sure the old page hasn't already been changed */ 295 /* mapping->private_lock here protects against the kioctx teardown. */
291 spin_lock(&mapping->private_lock); 296 spin_lock(&mapping->private_lock);
292 ctx = mapping->private_data; 297 ctx = mapping->private_data;
293 if (ctx) { 298 if (!ctx) {
294 pgoff_t idx; 299 rc = -EINVAL;
295 spin_lock_irqsave(&ctx->completion_lock, flags); 300 goto out;
296 idx = old->index; 301 }
297 if (idx < (pgoff_t)ctx->nr_pages) { 302
298 if (ctx->ring_pages[idx] != old) 303 /* The ring_lock mutex. The prevents aio_read_events() from writing
299 rc = -EAGAIN; 304 * to the ring's head, and prevents page migration from mucking in
300 } else 305 * a partially initialized kiotx.
301 rc = -EINVAL; 306 */
302 spin_unlock_irqrestore(&ctx->completion_lock, flags); 307 if (!mutex_trylock(&ctx->ring_lock)) {
308 rc = -EAGAIN;
309 goto out;
310 }
311
312 idx = old->index;
313 if (idx < (pgoff_t)ctx->nr_pages) {
314 /* Make sure the old page hasn't already been changed */
315 if (ctx->ring_pages[idx] != old)
316 rc = -EAGAIN;
303 } else 317 } else
304 rc = -EINVAL; 318 rc = -EINVAL;
305 spin_unlock(&mapping->private_lock);
306 319
307 if (rc != 0) 320 if (rc != 0)
308 return rc; 321 goto out_unlock;
309 322
310 /* Writeback must be complete */ 323 /* Writeback must be complete */
311 BUG_ON(PageWriteback(old)); 324 BUG_ON(PageWriteback(old));
@@ -314,38 +327,26 @@ static int aio_migratepage(struct address_space *mapping, struct page *new,
314 rc = migrate_page_move_mapping(mapping, new, old, NULL, mode, 1); 327 rc = migrate_page_move_mapping(mapping, new, old, NULL, mode, 1);
315 if (rc != MIGRATEPAGE_SUCCESS) { 328 if (rc != MIGRATEPAGE_SUCCESS) {
316 put_page(new); 329 put_page(new);
317 return rc; 330 goto out_unlock;
318 } 331 }
319 332
320 /* We can potentially race against kioctx teardown here. Use the 333 /* Take completion_lock to prevent other writes to the ring buffer
321 * address_space's private data lock to protect the mapping's 334 * while the old page is copied to the new. This prevents new
322 * private_data. 335 * events from being lost.
323 */ 336 */
324 spin_lock(&mapping->private_lock); 337 spin_lock_irqsave(&ctx->completion_lock, flags);
325 ctx = mapping->private_data; 338 migrate_page_copy(new, old);
326 if (ctx) { 339 BUG_ON(ctx->ring_pages[idx] != old);
327 pgoff_t idx; 340 ctx->ring_pages[idx] = new;
328 spin_lock_irqsave(&ctx->completion_lock, flags); 341 spin_unlock_irqrestore(&ctx->completion_lock, flags);
329 migrate_page_copy(new, old);
330 idx = old->index;
331 if (idx < (pgoff_t)ctx->nr_pages) {
332 /* And only do the move if things haven't changed */
333 if (ctx->ring_pages[idx] == old)
334 ctx->ring_pages[idx] = new;
335 else
336 rc = -EAGAIN;
337 } else
338 rc = -EINVAL;
339 spin_unlock_irqrestore(&ctx->completion_lock, flags);
340 } else
341 rc = -EBUSY;
342 spin_unlock(&mapping->private_lock);
343 342
344 if (rc == MIGRATEPAGE_SUCCESS) 343 /* The old page is no longer accessible. */
345 put_page(old); 344 put_page(old);
346 else
347 put_page(new);
348 345
346out_unlock:
347 mutex_unlock(&ctx->ring_lock);
348out:
349 spin_unlock(&mapping->private_lock);
349 return rc; 350 return rc;
350} 351}
351#endif 352#endif
@@ -380,7 +381,7 @@ static int aio_setup_ring(struct kioctx *ctx)
380 file = aio_private_file(ctx, nr_pages); 381 file = aio_private_file(ctx, nr_pages);
381 if (IS_ERR(file)) { 382 if (IS_ERR(file)) {
382 ctx->aio_ring_file = NULL; 383 ctx->aio_ring_file = NULL;
383 return -EAGAIN; 384 return -ENOMEM;
384 } 385 }
385 386
386 ctx->aio_ring_file = file; 387 ctx->aio_ring_file = file;
@@ -415,7 +416,7 @@ static int aio_setup_ring(struct kioctx *ctx)
415 416
416 if (unlikely(i != nr_pages)) { 417 if (unlikely(i != nr_pages)) {
417 aio_free_ring(ctx); 418 aio_free_ring(ctx);
418 return -EAGAIN; 419 return -ENOMEM;
419 } 420 }
420 421
421 ctx->mmap_size = nr_pages * PAGE_SIZE; 422 ctx->mmap_size = nr_pages * PAGE_SIZE;
@@ -429,7 +430,7 @@ static int aio_setup_ring(struct kioctx *ctx)
429 if (IS_ERR((void *)ctx->mmap_base)) { 430 if (IS_ERR((void *)ctx->mmap_base)) {
430 ctx->mmap_size = 0; 431 ctx->mmap_size = 0;
431 aio_free_ring(ctx); 432 aio_free_ring(ctx);
432 return -EAGAIN; 433 return -ENOMEM;
433 } 434 }
434 435
435 pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base); 436 pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base);
@@ -556,6 +557,10 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
556 rcu_read_unlock(); 557 rcu_read_unlock();
557 spin_unlock(&mm->ioctx_lock); 558 spin_unlock(&mm->ioctx_lock);
558 559
560 /* While kioctx setup is in progress,
561 * we are protected from page migration
562 * changes ring_pages by ->ring_lock.
563 */
559 ring = kmap_atomic(ctx->ring_pages[0]); 564 ring = kmap_atomic(ctx->ring_pages[0]);
560 ring->id = ctx->id; 565 ring->id = ctx->id;
561 kunmap_atomic(ring); 566 kunmap_atomic(ring);
@@ -640,24 +645,28 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
640 645
641 ctx->max_reqs = nr_events; 646 ctx->max_reqs = nr_events;
642 647
643 if (percpu_ref_init(&ctx->users, free_ioctx_users))
644 goto err;
645
646 if (percpu_ref_init(&ctx->reqs, free_ioctx_reqs))
647 goto err;
648
649 spin_lock_init(&ctx->ctx_lock); 648 spin_lock_init(&ctx->ctx_lock);
650 spin_lock_init(&ctx->completion_lock); 649 spin_lock_init(&ctx->completion_lock);
651 mutex_init(&ctx->ring_lock); 650 mutex_init(&ctx->ring_lock);
651 /* Protect against page migration throughout kiotx setup by keeping
652 * the ring_lock mutex held until setup is complete. */
653 mutex_lock(&ctx->ring_lock);
652 init_waitqueue_head(&ctx->wait); 654 init_waitqueue_head(&ctx->wait);
653 655
654 INIT_LIST_HEAD(&ctx->active_reqs); 656 INIT_LIST_HEAD(&ctx->active_reqs);
655 657
658 if (percpu_ref_init(&ctx->users, free_ioctx_users))
659 goto err;
660
661 if (percpu_ref_init(&ctx->reqs, free_ioctx_reqs))
662 goto err;
663
656 ctx->cpu = alloc_percpu(struct kioctx_cpu); 664 ctx->cpu = alloc_percpu(struct kioctx_cpu);
657 if (!ctx->cpu) 665 if (!ctx->cpu)
658 goto err; 666 goto err;
659 667
660 if (aio_setup_ring(ctx) < 0) 668 err = aio_setup_ring(ctx);
669 if (err < 0)
661 goto err; 670 goto err;
662 671
663 atomic_set(&ctx->reqs_available, ctx->nr_events - 1); 672 atomic_set(&ctx->reqs_available, ctx->nr_events - 1);
@@ -683,6 +692,9 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
683 if (err) 692 if (err)
684 goto err_cleanup; 693 goto err_cleanup;
685 694
695 /* Release the ring_lock mutex now that all setup is complete. */
696 mutex_unlock(&ctx->ring_lock);
697
686 pr_debug("allocated ioctx %p[%ld]: mm=%p mask=0x%x\n", 698 pr_debug("allocated ioctx %p[%ld]: mm=%p mask=0x%x\n",
687 ctx, ctx->user_id, mm, ctx->nr_events); 699 ctx, ctx->user_id, mm, ctx->nr_events);
688 return ctx; 700 return ctx;
@@ -692,6 +704,7 @@ err_cleanup:
692err_ctx: 704err_ctx:
693 aio_free_ring(ctx); 705 aio_free_ring(ctx);
694err: 706err:
707 mutex_unlock(&ctx->ring_lock);
695 free_percpu(ctx->cpu); 708 free_percpu(ctx->cpu);
696 free_percpu(ctx->reqs.pcpu_count); 709 free_percpu(ctx->reqs.pcpu_count);
697 free_percpu(ctx->users.pcpu_count); 710 free_percpu(ctx->users.pcpu_count);
@@ -1024,6 +1037,7 @@ static long aio_read_events_ring(struct kioctx *ctx,
1024 1037
1025 mutex_lock(&ctx->ring_lock); 1038 mutex_lock(&ctx->ring_lock);
1026 1039
1040 /* Access to ->ring_pages here is protected by ctx->ring_lock. */
1027 ring = kmap_atomic(ctx->ring_pages[0]); 1041 ring = kmap_atomic(ctx->ring_pages[0]);
1028 head = ring->head; 1042 head = ring->head;
1029 tail = ring->tail; 1043 tail = ring->tail;
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 3182c0e68b42..232e03d4780d 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -103,6 +103,9 @@ static struct autofs_dev_ioctl *copy_dev_ioctl(struct autofs_dev_ioctl __user *i
103 if (tmp.size < sizeof(tmp)) 103 if (tmp.size < sizeof(tmp))
104 return ERR_PTR(-EINVAL); 104 return ERR_PTR(-EINVAL);
105 105
106 if (tmp.size > (PATH_MAX + sizeof(tmp)))
107 return ERR_PTR(-ENAMETOOLONG);
108
106 return memdup_user(in, tmp.size); 109 return memdup_user(in, tmp.size);
107} 110}
108 111
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 29696b78d1f4..1c2ce0c87711 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -182,6 +182,9 @@ static int bdev_integrity_enabled(struct block_device *bdev, int rw)
182 */ 182 */
183int bio_integrity_enabled(struct bio *bio) 183int bio_integrity_enabled(struct bio *bio)
184{ 184{
185 if (!bio_is_rw(bio))
186 return 0;
187
185 /* Already protected? */ 188 /* Already protected? */
186 if (bio_integrity(bio)) 189 if (bio_integrity(bio))
187 return 0; 190 return 0;
@@ -309,10 +312,9 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate)
309{ 312{
310 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); 313 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
311 struct blk_integrity_exchg bix; 314 struct blk_integrity_exchg bix;
312 struct bio_vec bv; 315 struct bio_vec *bv;
313 struct bvec_iter iter;
314 sector_t sector; 316 sector_t sector;
315 unsigned int sectors, ret = 0; 317 unsigned int sectors, ret = 0, i;
316 void *prot_buf = bio->bi_integrity->bip_buf; 318 void *prot_buf = bio->bi_integrity->bip_buf;
317 319
318 if (operate) 320 if (operate)
@@ -323,16 +325,16 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate)
323 bix.disk_name = bio->bi_bdev->bd_disk->disk_name; 325 bix.disk_name = bio->bi_bdev->bd_disk->disk_name;
324 bix.sector_size = bi->sector_size; 326 bix.sector_size = bi->sector_size;
325 327
326 bio_for_each_segment(bv, bio, iter) { 328 bio_for_each_segment_all(bv, bio, i) {
327 void *kaddr = kmap_atomic(bv.bv_page); 329 void *kaddr = kmap_atomic(bv->bv_page);
328 bix.data_buf = kaddr + bv.bv_offset; 330 bix.data_buf = kaddr + bv->bv_offset;
329 bix.data_size = bv.bv_len; 331 bix.data_size = bv->bv_len;
330 bix.prot_buf = prot_buf; 332 bix.prot_buf = prot_buf;
331 bix.sector = sector; 333 bix.sector = sector;
332 334
333 if (operate) { 335 if (operate)
334 bi->generate_fn(&bix); 336 bi->generate_fn(&bix);
335 } else { 337 else {
336 ret = bi->verify_fn(&bix); 338 ret = bi->verify_fn(&bix);
337 if (ret) { 339 if (ret) {
338 kunmap_atomic(kaddr); 340 kunmap_atomic(kaddr);
@@ -340,7 +342,7 @@ static int bio_integrity_generate_verify(struct bio *bio, int operate)
340 } 342 }
341 } 343 }
342 344
343 sectors = bv.bv_len / bi->sector_size; 345 sectors = bv->bv_len / bi->sector_size;
344 sector += sectors; 346 sector += sectors;
345 prot_buf += sectors * bi->tuple_size; 347 prot_buf += sectors * bi->tuple_size;
346 348
diff --git a/fs/bio.c b/fs/bio.c
index b1bc722b89aa..6f0362b77806 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1002,7 +1002,7 @@ struct bio_map_data {
1002}; 1002};
1003 1003
1004static void bio_set_map_data(struct bio_map_data *bmd, struct bio *bio, 1004static void bio_set_map_data(struct bio_map_data *bmd, struct bio *bio,
1005 struct sg_iovec *iov, int iov_count, 1005 const struct sg_iovec *iov, int iov_count,
1006 int is_our_pages) 1006 int is_our_pages)
1007{ 1007{
1008 memcpy(bmd->sgvecs, iov, sizeof(struct sg_iovec) * iov_count); 1008 memcpy(bmd->sgvecs, iov, sizeof(struct sg_iovec) * iov_count);
@@ -1022,7 +1022,7 @@ static struct bio_map_data *bio_alloc_map_data(int nr_segs,
1022 sizeof(struct sg_iovec) * iov_count, gfp_mask); 1022 sizeof(struct sg_iovec) * iov_count, gfp_mask);
1023} 1023}
1024 1024
1025static int __bio_copy_iov(struct bio *bio, struct sg_iovec *iov, int iov_count, 1025static int __bio_copy_iov(struct bio *bio, const struct sg_iovec *iov, int iov_count,
1026 int to_user, int from_user, int do_free_page) 1026 int to_user, int from_user, int do_free_page)
1027{ 1027{
1028 int ret = 0, i; 1028 int ret = 0, i;
@@ -1120,7 +1120,7 @@ EXPORT_SYMBOL(bio_uncopy_user);
1120 */ 1120 */
1121struct bio *bio_copy_user_iov(struct request_queue *q, 1121struct bio *bio_copy_user_iov(struct request_queue *q,
1122 struct rq_map_data *map_data, 1122 struct rq_map_data *map_data,
1123 struct sg_iovec *iov, int iov_count, 1123 const struct sg_iovec *iov, int iov_count,
1124 int write_to_vm, gfp_t gfp_mask) 1124 int write_to_vm, gfp_t gfp_mask)
1125{ 1125{
1126 struct bio_map_data *bmd; 1126 struct bio_map_data *bmd;
@@ -1259,7 +1259,7 @@ EXPORT_SYMBOL(bio_copy_user);
1259 1259
1260static struct bio *__bio_map_user_iov(struct request_queue *q, 1260static struct bio *__bio_map_user_iov(struct request_queue *q,
1261 struct block_device *bdev, 1261 struct block_device *bdev,
1262 struct sg_iovec *iov, int iov_count, 1262 const struct sg_iovec *iov, int iov_count,
1263 int write_to_vm, gfp_t gfp_mask) 1263 int write_to_vm, gfp_t gfp_mask)
1264{ 1264{
1265 int i, j; 1265 int i, j;
@@ -1407,7 +1407,7 @@ EXPORT_SYMBOL(bio_map_user);
1407 * device. Returns an error pointer in case of error. 1407 * device. Returns an error pointer in case of error.
1408 */ 1408 */
1409struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev, 1409struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev,
1410 struct sg_iovec *iov, int iov_count, 1410 const struct sg_iovec *iov, int iov_count,
1411 int write_to_vm, gfp_t gfp_mask) 1411 int write_to_vm, gfp_t gfp_mask)
1412{ 1412{
1413 struct bio *bio; 1413 struct bio *bio;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index ba0d2b05bb78..552a8d13bc32 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1518,7 +1518,7 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1518 BUG_ON(iocb->ki_pos != pos); 1518 BUG_ON(iocb->ki_pos != pos);
1519 1519
1520 blk_start_plug(&plug); 1520 blk_start_plug(&plug);
1521 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 1521 ret = __generic_file_aio_write(iocb, iov, nr_segs);
1522 if (ret > 0) { 1522 if (ret > 0) {
1523 ssize_t err; 1523 ssize_t err;
1524 1524
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index ecb5832c0967..5a201d81049c 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -323,6 +323,8 @@ void btrfs_destroy_workqueue(struct btrfs_workqueue *wq)
323 323
324void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max) 324void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max)
325{ 325{
326 if (!wq)
327 return;
326 wq->normal->max_active = max; 328 wq->normal->max_active = max;
327 if (wq->high) 329 if (wq->high)
328 wq->high->max_active = max; 330 wq->high->max_active = max;
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index aad7201ad11b..10db21fa0926 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -330,7 +330,10 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
330 goto out; 330 goto out;
331 } 331 }
332 332
333 root_level = btrfs_old_root_level(root, time_seq); 333 if (path->search_commit_root)
334 root_level = btrfs_header_level(root->commit_root);
335 else
336 root_level = btrfs_old_root_level(root, time_seq);
334 337
335 if (root_level + 1 == level) { 338 if (root_level + 1 == level) {
336 srcu_read_unlock(&fs_info->subvol_srcu, index); 339 srcu_read_unlock(&fs_info->subvol_srcu, index);
@@ -1099,9 +1102,9 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
1099 * 1102 *
1100 * returns 0 on success, < 0 on error. 1103 * returns 0 on success, < 0 on error.
1101 */ 1104 */
1102int btrfs_find_all_roots(struct btrfs_trans_handle *trans, 1105static int __btrfs_find_all_roots(struct btrfs_trans_handle *trans,
1103 struct btrfs_fs_info *fs_info, u64 bytenr, 1106 struct btrfs_fs_info *fs_info, u64 bytenr,
1104 u64 time_seq, struct ulist **roots) 1107 u64 time_seq, struct ulist **roots)
1105{ 1108{
1106 struct ulist *tmp; 1109 struct ulist *tmp;
1107 struct ulist_node *node = NULL; 1110 struct ulist_node *node = NULL;
@@ -1137,6 +1140,20 @@ int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
1137 return 0; 1140 return 0;
1138} 1141}
1139 1142
1143int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
1144 struct btrfs_fs_info *fs_info, u64 bytenr,
1145 u64 time_seq, struct ulist **roots)
1146{
1147 int ret;
1148
1149 if (!trans)
1150 down_read(&fs_info->commit_root_sem);
1151 ret = __btrfs_find_all_roots(trans, fs_info, bytenr, time_seq, roots);
1152 if (!trans)
1153 up_read(&fs_info->commit_root_sem);
1154 return ret;
1155}
1156
1140/* 1157/*
1141 * this makes the path point to (inum INODE_ITEM ioff) 1158 * this makes the path point to (inum INODE_ITEM ioff)
1142 */ 1159 */
@@ -1516,6 +1533,8 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
1516 if (IS_ERR(trans)) 1533 if (IS_ERR(trans))
1517 return PTR_ERR(trans); 1534 return PTR_ERR(trans);
1518 btrfs_get_tree_mod_seq(fs_info, &tree_mod_seq_elem); 1535 btrfs_get_tree_mod_seq(fs_info, &tree_mod_seq_elem);
1536 } else {
1537 down_read(&fs_info->commit_root_sem);
1519 } 1538 }
1520 1539
1521 ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid, 1540 ret = btrfs_find_all_leafs(trans, fs_info, extent_item_objectid,
@@ -1526,8 +1545,8 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
1526 1545
1527 ULIST_ITER_INIT(&ref_uiter); 1546 ULIST_ITER_INIT(&ref_uiter);
1528 while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) { 1547 while (!ret && (ref_node = ulist_next(refs, &ref_uiter))) {
1529 ret = btrfs_find_all_roots(trans, fs_info, ref_node->val, 1548 ret = __btrfs_find_all_roots(trans, fs_info, ref_node->val,
1530 tree_mod_seq_elem.seq, &roots); 1549 tree_mod_seq_elem.seq, &roots);
1531 if (ret) 1550 if (ret)
1532 break; 1551 break;
1533 ULIST_ITER_INIT(&root_uiter); 1552 ULIST_ITER_INIT(&root_uiter);
@@ -1549,6 +1568,8 @@ out:
1549 if (!search_commit_root) { 1568 if (!search_commit_root) {
1550 btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem); 1569 btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
1551 btrfs_end_transaction(trans, fs_info->extent_root); 1570 btrfs_end_transaction(trans, fs_info->extent_root);
1571 } else {
1572 up_read(&fs_info->commit_root_sem);
1552 } 1573 }
1553 1574
1554 return ret; 1575 return ret;
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 88d1b1eedc9c..1bcfcdb23cf4 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2769,9 +2769,13 @@ again:
2769 * the commit roots are read only 2769 * the commit roots are read only
2770 * so we always do read locks 2770 * so we always do read locks
2771 */ 2771 */
2772 if (p->need_commit_sem)
2773 down_read(&root->fs_info->commit_root_sem);
2772 b = root->commit_root; 2774 b = root->commit_root;
2773 extent_buffer_get(b); 2775 extent_buffer_get(b);
2774 level = btrfs_header_level(b); 2776 level = btrfs_header_level(b);
2777 if (p->need_commit_sem)
2778 up_read(&root->fs_info->commit_root_sem);
2775 if (!p->skip_locking) 2779 if (!p->skip_locking)
2776 btrfs_tree_read_lock(b); 2780 btrfs_tree_read_lock(b);
2777 } else { 2781 } else {
@@ -5360,7 +5364,6 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5360{ 5364{
5361 int ret; 5365 int ret;
5362 int cmp; 5366 int cmp;
5363 struct btrfs_trans_handle *trans = NULL;
5364 struct btrfs_path *left_path = NULL; 5367 struct btrfs_path *left_path = NULL;
5365 struct btrfs_path *right_path = NULL; 5368 struct btrfs_path *right_path = NULL;
5366 struct btrfs_key left_key; 5369 struct btrfs_key left_key;
@@ -5378,9 +5381,6 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5378 u64 right_blockptr; 5381 u64 right_blockptr;
5379 u64 left_gen; 5382 u64 left_gen;
5380 u64 right_gen; 5383 u64 right_gen;
5381 u64 left_start_ctransid;
5382 u64 right_start_ctransid;
5383 u64 ctransid;
5384 5384
5385 left_path = btrfs_alloc_path(); 5385 left_path = btrfs_alloc_path();
5386 if (!left_path) { 5386 if (!left_path) {
@@ -5404,21 +5404,6 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5404 right_path->search_commit_root = 1; 5404 right_path->search_commit_root = 1;
5405 right_path->skip_locking = 1; 5405 right_path->skip_locking = 1;
5406 5406
5407 spin_lock(&left_root->root_item_lock);
5408 left_start_ctransid = btrfs_root_ctransid(&left_root->root_item);
5409 spin_unlock(&left_root->root_item_lock);
5410
5411 spin_lock(&right_root->root_item_lock);
5412 right_start_ctransid = btrfs_root_ctransid(&right_root->root_item);
5413 spin_unlock(&right_root->root_item_lock);
5414
5415 trans = btrfs_join_transaction(left_root);
5416 if (IS_ERR(trans)) {
5417 ret = PTR_ERR(trans);
5418 trans = NULL;
5419 goto out;
5420 }
5421
5422 /* 5407 /*
5423 * Strategy: Go to the first items of both trees. Then do 5408 * Strategy: Go to the first items of both trees. Then do
5424 * 5409 *
@@ -5455,6 +5440,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5455 * the right if possible or go up and right. 5440 * the right if possible or go up and right.
5456 */ 5441 */
5457 5442
5443 down_read(&left_root->fs_info->commit_root_sem);
5458 left_level = btrfs_header_level(left_root->commit_root); 5444 left_level = btrfs_header_level(left_root->commit_root);
5459 left_root_level = left_level; 5445 left_root_level = left_level;
5460 left_path->nodes[left_level] = left_root->commit_root; 5446 left_path->nodes[left_level] = left_root->commit_root;
@@ -5464,6 +5450,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5464 right_root_level = right_level; 5450 right_root_level = right_level;
5465 right_path->nodes[right_level] = right_root->commit_root; 5451 right_path->nodes[right_level] = right_root->commit_root;
5466 extent_buffer_get(right_path->nodes[right_level]); 5452 extent_buffer_get(right_path->nodes[right_level]);
5453 up_read(&left_root->fs_info->commit_root_sem);
5467 5454
5468 if (left_level == 0) 5455 if (left_level == 0)
5469 btrfs_item_key_to_cpu(left_path->nodes[left_level], 5456 btrfs_item_key_to_cpu(left_path->nodes[left_level],
@@ -5482,67 +5469,6 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
5482 advance_left = advance_right = 0; 5469 advance_left = advance_right = 0;
5483 5470
5484 while (1) { 5471 while (1) {
5485 /*
5486 * We need to make sure the transaction does not get committed
5487 * while we do anything on commit roots. This means, we need to
5488 * join and leave transactions for every item that we process.
5489 */
5490 if (trans && btrfs_should_end_transaction(trans, left_root)) {
5491 btrfs_release_path(left_path);
5492 btrfs_release_path(right_path);
5493
5494 ret = btrfs_end_transaction(trans, left_root);
5495 trans = NULL;
5496 if (ret < 0)
5497 goto out;
5498 }
5499 /* now rejoin the transaction */
5500 if (!trans) {
5501 trans = btrfs_join_transaction(left_root);
5502 if (IS_ERR(trans)) {
5503 ret = PTR_ERR(trans);
5504 trans = NULL;
5505 goto out;
5506 }
5507
5508 spin_lock(&left_root->root_item_lock);
5509 ctransid = btrfs_root_ctransid(&left_root->root_item);
5510 spin_unlock(&left_root->root_item_lock);
5511 if (ctransid != left_start_ctransid)
5512 left_start_ctransid = 0;
5513
5514 spin_lock(&right_root->root_item_lock);
5515 ctransid = btrfs_root_ctransid(&right_root->root_item);
5516 spin_unlock(&right_root->root_item_lock);
5517 if (ctransid != right_start_ctransid)
5518 right_start_ctransid = 0;
5519
5520 if (!left_start_ctransid || !right_start_ctransid) {
5521 WARN(1, KERN_WARNING
5522 "BTRFS: btrfs_compare_tree detected "
5523 "a change in one of the trees while "
5524 "iterating. This is probably a "
5525 "bug.\n");
5526 ret = -EIO;
5527 goto out;
5528 }
5529
5530 /*
5531 * the commit root may have changed, so start again
5532 * where we stopped
5533 */
5534 left_path->lowest_level = left_level;
5535 right_path->lowest_level = right_level;
5536 ret = btrfs_search_slot(NULL, left_root,
5537 &left_key, left_path, 0, 0);
5538 if (ret < 0)
5539 goto out;
5540 ret = btrfs_search_slot(NULL, right_root,
5541 &right_key, right_path, 0, 0);
5542 if (ret < 0)
5543 goto out;
5544 }
5545
5546 if (advance_left && !left_end_reached) { 5472 if (advance_left && !left_end_reached) {
5547 ret = tree_advance(left_root, left_path, &left_level, 5473 ret = tree_advance(left_root, left_path, &left_level,
5548 left_root_level, 5474 left_root_level,
@@ -5672,14 +5598,6 @@ out:
5672 btrfs_free_path(left_path); 5598 btrfs_free_path(left_path);
5673 btrfs_free_path(right_path); 5599 btrfs_free_path(right_path);
5674 kfree(tmp_buf); 5600 kfree(tmp_buf);
5675
5676 if (trans) {
5677 if (!ret)
5678 ret = btrfs_end_transaction(trans, left_root);
5679 else
5680 btrfs_end_transaction(trans, left_root);
5681 }
5682
5683 return ret; 5601 return ret;
5684} 5602}
5685 5603
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index bc96c03dd259..4c48df572bd6 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -609,6 +609,7 @@ struct btrfs_path {
609 unsigned int skip_locking:1; 609 unsigned int skip_locking:1;
610 unsigned int leave_spinning:1; 610 unsigned int leave_spinning:1;
611 unsigned int search_commit_root:1; 611 unsigned int search_commit_root:1;
612 unsigned int need_commit_sem:1;
612}; 613};
613 614
614/* 615/*
@@ -986,7 +987,8 @@ struct btrfs_dev_replace_item {
986#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) 987#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
987#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) 988#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
988#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) 989#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
989#define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE 990#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
991 BTRFS_SPACE_INFO_GLOBAL_RSV)
990 992
991enum btrfs_raid_types { 993enum btrfs_raid_types {
992 BTRFS_RAID_RAID10, 994 BTRFS_RAID_RAID10,
@@ -1018,6 +1020,12 @@ enum btrfs_raid_types {
1018 */ 1020 */
1019#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) 1021#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
1020 1022
1023/*
1024 * A fake block group type that is used to communicate global block reserve
1025 * size to userspace via the SPACE_INFO ioctl.
1026 */
1027#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
1028
1021#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \ 1029#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \
1022 BTRFS_AVAIL_ALLOC_BIT_SINGLE) 1030 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
1023 1031
@@ -1440,7 +1448,7 @@ struct btrfs_fs_info {
1440 */ 1448 */
1441 struct mutex ordered_extent_flush_mutex; 1449 struct mutex ordered_extent_flush_mutex;
1442 1450
1443 struct rw_semaphore extent_commit_sem; 1451 struct rw_semaphore commit_root_sem;
1444 1452
1445 struct rw_semaphore cleanup_work_sem; 1453 struct rw_semaphore cleanup_work_sem;
1446 1454
@@ -1711,7 +1719,6 @@ struct btrfs_root {
1711 struct btrfs_block_rsv *block_rsv; 1719 struct btrfs_block_rsv *block_rsv;
1712 1720
1713 /* free ino cache stuff */ 1721 /* free ino cache stuff */
1714 struct mutex fs_commit_mutex;
1715 struct btrfs_free_space_ctl *free_ino_ctl; 1722 struct btrfs_free_space_ctl *free_ino_ctl;
1716 enum btrfs_caching_type cached; 1723 enum btrfs_caching_type cached;
1717 spinlock_t cache_lock; 1724 spinlock_t cache_lock;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index bd0f752b797b..029d46c2e170 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -329,6 +329,8 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
329{ 329{
330 struct extent_state *cached_state = NULL; 330 struct extent_state *cached_state = NULL;
331 int ret; 331 int ret;
332 bool need_lock = (current->journal_info ==
333 (void *)BTRFS_SEND_TRANS_STUB);
332 334
333 if (!parent_transid || btrfs_header_generation(eb) == parent_transid) 335 if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
334 return 0; 336 return 0;
@@ -336,6 +338,11 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
336 if (atomic) 338 if (atomic)
337 return -EAGAIN; 339 return -EAGAIN;
338 340
341 if (need_lock) {
342 btrfs_tree_read_lock(eb);
343 btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
344 }
345
339 lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1, 346 lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1,
340 0, &cached_state); 347 0, &cached_state);
341 if (extent_buffer_uptodate(eb) && 348 if (extent_buffer_uptodate(eb) &&
@@ -347,10 +354,21 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
347 "found %llu\n", 354 "found %llu\n",
348 eb->start, parent_transid, btrfs_header_generation(eb)); 355 eb->start, parent_transid, btrfs_header_generation(eb));
349 ret = 1; 356 ret = 1;
350 clear_extent_buffer_uptodate(eb); 357
358 /*
359 * Things reading via commit roots that don't have normal protection,
360 * like send, can have a really old block in cache that may point at a
361 * block that has been free'd and re-allocated. So don't clear uptodate
362 * if we find an eb that is under IO (dirty/writeback) because we could
363 * end up reading in the stale data and then writing it back out and
364 * making everybody very sad.
365 */
366 if (!extent_buffer_under_io(eb))
367 clear_extent_buffer_uptodate(eb);
351out: 368out:
352 unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1, 369 unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1,
353 &cached_state, GFP_NOFS); 370 &cached_state, GFP_NOFS);
371 btrfs_tree_read_unlock_blocking(eb);
354 return ret; 372 return ret;
355} 373}
356 374
@@ -1546,7 +1564,6 @@ int btrfs_init_fs_root(struct btrfs_root *root)
1546 root->subv_writers = writers; 1564 root->subv_writers = writers;
1547 1565
1548 btrfs_init_free_ino_ctl(root); 1566 btrfs_init_free_ino_ctl(root);
1549 mutex_init(&root->fs_commit_mutex);
1550 spin_lock_init(&root->cache_lock); 1567 spin_lock_init(&root->cache_lock);
1551 init_waitqueue_head(&root->cache_wait); 1568 init_waitqueue_head(&root->cache_wait);
1552 1569
@@ -2324,7 +2341,7 @@ int open_ctree(struct super_block *sb,
2324 mutex_init(&fs_info->transaction_kthread_mutex); 2341 mutex_init(&fs_info->transaction_kthread_mutex);
2325 mutex_init(&fs_info->cleaner_mutex); 2342 mutex_init(&fs_info->cleaner_mutex);
2326 mutex_init(&fs_info->volume_mutex); 2343 mutex_init(&fs_info->volume_mutex);
2327 init_rwsem(&fs_info->extent_commit_sem); 2344 init_rwsem(&fs_info->commit_root_sem);
2328 init_rwsem(&fs_info->cleanup_work_sem); 2345 init_rwsem(&fs_info->cleanup_work_sem);
2329 init_rwsem(&fs_info->subvol_sem); 2346 init_rwsem(&fs_info->subvol_sem);
2330 sema_init(&fs_info->uuid_tree_rescan_sem, 1); 2347 sema_init(&fs_info->uuid_tree_rescan_sem, 1);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c6b6a6e3e735..1306487c82cf 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -419,7 +419,7 @@ static noinline void caching_thread(struct btrfs_work *work)
419again: 419again:
420 mutex_lock(&caching_ctl->mutex); 420 mutex_lock(&caching_ctl->mutex);
421 /* need to make sure the commit_root doesn't disappear */ 421 /* need to make sure the commit_root doesn't disappear */
422 down_read(&fs_info->extent_commit_sem); 422 down_read(&fs_info->commit_root_sem);
423 423
424next: 424next:
425 ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0); 425 ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
@@ -443,10 +443,10 @@ next:
443 break; 443 break;
444 444
445 if (need_resched() || 445 if (need_resched() ||
446 rwsem_is_contended(&fs_info->extent_commit_sem)) { 446 rwsem_is_contended(&fs_info->commit_root_sem)) {
447 caching_ctl->progress = last; 447 caching_ctl->progress = last;
448 btrfs_release_path(path); 448 btrfs_release_path(path);
449 up_read(&fs_info->extent_commit_sem); 449 up_read(&fs_info->commit_root_sem);
450 mutex_unlock(&caching_ctl->mutex); 450 mutex_unlock(&caching_ctl->mutex);
451 cond_resched(); 451 cond_resched();
452 goto again; 452 goto again;
@@ -513,7 +513,7 @@ next:
513 513
514err: 514err:
515 btrfs_free_path(path); 515 btrfs_free_path(path);
516 up_read(&fs_info->extent_commit_sem); 516 up_read(&fs_info->commit_root_sem);
517 517
518 free_excluded_extents(extent_root, block_group); 518 free_excluded_extents(extent_root, block_group);
519 519
@@ -633,10 +633,10 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
633 return 0; 633 return 0;
634 } 634 }
635 635
636 down_write(&fs_info->extent_commit_sem); 636 down_write(&fs_info->commit_root_sem);
637 atomic_inc(&caching_ctl->count); 637 atomic_inc(&caching_ctl->count);
638 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups); 638 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups);
639 up_write(&fs_info->extent_commit_sem); 639 up_write(&fs_info->commit_root_sem);
640 640
641 btrfs_get_block_group(cache); 641 btrfs_get_block_group(cache);
642 642
@@ -2444,7 +2444,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2444 spin_unlock(&locked_ref->lock); 2444 spin_unlock(&locked_ref->lock);
2445 spin_lock(&delayed_refs->lock); 2445 spin_lock(&delayed_refs->lock);
2446 spin_lock(&locked_ref->lock); 2446 spin_lock(&locked_ref->lock);
2447 if (rb_first(&locked_ref->ref_root)) { 2447 if (rb_first(&locked_ref->ref_root) ||
2448 locked_ref->extent_op) {
2448 spin_unlock(&locked_ref->lock); 2449 spin_unlock(&locked_ref->lock);
2449 spin_unlock(&delayed_refs->lock); 2450 spin_unlock(&delayed_refs->lock);
2450 continue; 2451 continue;
@@ -5470,7 +5471,7 @@ void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
5470 struct btrfs_block_group_cache *cache; 5471 struct btrfs_block_group_cache *cache;
5471 struct btrfs_space_info *space_info; 5472 struct btrfs_space_info *space_info;
5472 5473
5473 down_write(&fs_info->extent_commit_sem); 5474 down_write(&fs_info->commit_root_sem);
5474 5475
5475 list_for_each_entry_safe(caching_ctl, next, 5476 list_for_each_entry_safe(caching_ctl, next,
5476 &fs_info->caching_block_groups, list) { 5477 &fs_info->caching_block_groups, list) {
@@ -5489,7 +5490,7 @@ void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
5489 else 5490 else
5490 fs_info->pinned_extents = &fs_info->freed_extents[0]; 5491 fs_info->pinned_extents = &fs_info->freed_extents[0];
5491 5492
5492 up_write(&fs_info->extent_commit_sem); 5493 up_write(&fs_info->commit_root_sem);
5493 5494
5494 list_for_each_entry_rcu(space_info, &fs_info->space_info, list) 5495 list_for_each_entry_rcu(space_info, &fs_info->space_info, list)
5495 percpu_counter_set(&space_info->total_bytes_pinned, 0); 5496 percpu_counter_set(&space_info->total_bytes_pinned, 0);
@@ -5744,6 +5745,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
5744 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu", 5745 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
5745 bytenr, parent, root_objectid, owner_objectid, 5746 bytenr, parent, root_objectid, owner_objectid,
5746 owner_offset); 5747 owner_offset);
5748 btrfs_abort_transaction(trans, extent_root, ret);
5749 goto out;
5747 } else { 5750 } else {
5748 btrfs_abort_transaction(trans, extent_root, ret); 5751 btrfs_abort_transaction(trans, extent_root, ret);
5749 goto out; 5752 goto out;
@@ -8255,14 +8258,14 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
8255 struct btrfs_caching_control *caching_ctl; 8258 struct btrfs_caching_control *caching_ctl;
8256 struct rb_node *n; 8259 struct rb_node *n;
8257 8260
8258 down_write(&info->extent_commit_sem); 8261 down_write(&info->commit_root_sem);
8259 while (!list_empty(&info->caching_block_groups)) { 8262 while (!list_empty(&info->caching_block_groups)) {
8260 caching_ctl = list_entry(info->caching_block_groups.next, 8263 caching_ctl = list_entry(info->caching_block_groups.next,
8261 struct btrfs_caching_control, list); 8264 struct btrfs_caching_control, list);
8262 list_del(&caching_ctl->list); 8265 list_del(&caching_ctl->list);
8263 put_caching_control(caching_ctl); 8266 put_caching_control(caching_ctl);
8264 } 8267 }
8265 up_write(&info->extent_commit_sem); 8268 up_write(&info->commit_root_sem);
8266 8269
8267 spin_lock(&info->block_group_cache_lock); 8270 spin_lock(&info->block_group_cache_lock);
8268 while ((n = rb_last(&info->block_group_cache_tree)) != NULL) { 8271 while ((n = rb_last(&info->block_group_cache_tree)) != NULL) {
@@ -8336,9 +8339,15 @@ static void __link_block_group(struct btrfs_space_info *space_info,
8336 struct btrfs_block_group_cache *cache) 8339 struct btrfs_block_group_cache *cache)
8337{ 8340{
8338 int index = get_block_group_index(cache); 8341 int index = get_block_group_index(cache);
8342 bool first = false;
8339 8343
8340 down_write(&space_info->groups_sem); 8344 down_write(&space_info->groups_sem);
8341 if (list_empty(&space_info->block_groups[index])) { 8345 if (list_empty(&space_info->block_groups[index]))
8346 first = true;
8347 list_add_tail(&cache->list, &space_info->block_groups[index]);
8348 up_write(&space_info->groups_sem);
8349
8350 if (first) {
8342 struct kobject *kobj = &space_info->block_group_kobjs[index]; 8351 struct kobject *kobj = &space_info->block_group_kobjs[index];
8343 int ret; 8352 int ret;
8344 8353
@@ -8350,8 +8359,6 @@ static void __link_block_group(struct btrfs_space_info *space_info,
8350 kobject_put(&space_info->kobj); 8359 kobject_put(&space_info->kobj);
8351 } 8360 }
8352 } 8361 }
8353 list_add_tail(&cache->list, &space_info->block_groups[index]);
8354 up_write(&space_info->groups_sem);
8355} 8362}
8356 8363
8357static struct btrfs_block_group_cache * 8364static struct btrfs_block_group_cache *
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ae69a00387e7..3955e475ceec 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -749,6 +749,7 @@ again:
749 * our range starts 749 * our range starts
750 */ 750 */
751 node = tree_search(tree, start); 751 node = tree_search(tree, start);
752process_node:
752 if (!node) 753 if (!node)
753 break; 754 break;
754 755
@@ -769,7 +770,10 @@ again:
769 if (start > end) 770 if (start > end)
770 break; 771 break;
771 772
772 cond_resched_lock(&tree->lock); 773 if (!cond_resched_lock(&tree->lock)) {
774 node = rb_next(node);
775 goto process_node;
776 }
773 } 777 }
774out: 778out:
775 spin_unlock(&tree->lock); 779 spin_unlock(&tree->lock);
@@ -4306,7 +4310,7 @@ static void __free_extent_buffer(struct extent_buffer *eb)
4306 kmem_cache_free(extent_buffer_cache, eb); 4310 kmem_cache_free(extent_buffer_cache, eb);
4307} 4311}
4308 4312
4309static int extent_buffer_under_io(struct extent_buffer *eb) 4313int extent_buffer_under_io(struct extent_buffer *eb)
4310{ 4314{
4311 return (atomic_read(&eb->io_pages) || 4315 return (atomic_read(&eb->io_pages) ||
4312 test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags) || 4316 test_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags) ||
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 58b27e5ab521..c488b45237bf 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -320,6 +320,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb);
320int set_extent_buffer_uptodate(struct extent_buffer *eb); 320int set_extent_buffer_uptodate(struct extent_buffer *eb);
321int clear_extent_buffer_uptodate(struct extent_buffer *eb); 321int clear_extent_buffer_uptodate(struct extent_buffer *eb);
322int extent_buffer_uptodate(struct extent_buffer *eb); 322int extent_buffer_uptodate(struct extent_buffer *eb);
323int extent_buffer_under_io(struct extent_buffer *eb);
323int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, 324int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset,
324 unsigned long min_len, char **map, 325 unsigned long min_len, char **map,
325 unsigned long *map_start, 326 unsigned long *map_start,
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c660527af838..eb742c07e7a4 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -425,13 +425,8 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
425 struct page *page = prepared_pages[pg]; 425 struct page *page = prepared_pages[pg];
426 /* 426 /*
427 * Copy data from userspace to the current page 427 * Copy data from userspace to the current page
428 *
429 * Disable pagefault to avoid recursive lock since
430 * the pages are already locked
431 */ 428 */
432 pagefault_disable();
433 copied = iov_iter_copy_from_user_atomic(page, i, offset, count); 429 copied = iov_iter_copy_from_user_atomic(page, i, offset, count);
434 pagefault_enable();
435 430
436 /* Flush processor's dcache for this page */ 431 /* Flush processor's dcache for this page */
437 flush_dcache_page(page); 432 flush_dcache_page(page);
@@ -1665,7 +1660,7 @@ again:
1665static ssize_t __btrfs_direct_write(struct kiocb *iocb, 1660static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1666 const struct iovec *iov, 1661 const struct iovec *iov,
1667 unsigned long nr_segs, loff_t pos, 1662 unsigned long nr_segs, loff_t pos,
1668 loff_t *ppos, size_t count, size_t ocount) 1663 size_t count, size_t ocount)
1669{ 1664{
1670 struct file *file = iocb->ki_filp; 1665 struct file *file = iocb->ki_filp;
1671 struct iov_iter i; 1666 struct iov_iter i;
@@ -1674,7 +1669,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1674 loff_t endbyte; 1669 loff_t endbyte;
1675 int err; 1670 int err;
1676 1671
1677 written = generic_file_direct_write(iocb, iov, &nr_segs, pos, ppos, 1672 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
1678 count, ocount); 1673 count, ocount);
1679 1674
1680 if (written < 0 || written == count) 1675 if (written < 0 || written == count)
@@ -1693,7 +1688,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb,
1693 if (err) 1688 if (err)
1694 goto out; 1689 goto out;
1695 written += written_buffered; 1690 written += written_buffered;
1696 *ppos = pos + written_buffered; 1691 iocb->ki_pos = pos + written_buffered;
1697 invalidate_mapping_pages(file->f_mapping, pos >> PAGE_CACHE_SHIFT, 1692 invalidate_mapping_pages(file->f_mapping, pos >> PAGE_CACHE_SHIFT,
1698 endbyte >> PAGE_CACHE_SHIFT); 1693 endbyte >> PAGE_CACHE_SHIFT);
1699out: 1694out:
@@ -1725,8 +1720,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1725 struct file *file = iocb->ki_filp; 1720 struct file *file = iocb->ki_filp;
1726 struct inode *inode = file_inode(file); 1721 struct inode *inode = file_inode(file);
1727 struct btrfs_root *root = BTRFS_I(inode)->root; 1722 struct btrfs_root *root = BTRFS_I(inode)->root;
1728 loff_t *ppos = &iocb->ki_pos;
1729 u64 start_pos; 1723 u64 start_pos;
1724 u64 end_pos;
1730 ssize_t num_written = 0; 1725 ssize_t num_written = 0;
1731 ssize_t err = 0; 1726 ssize_t err = 0;
1732 size_t count, ocount; 1727 size_t count, ocount;
@@ -1781,7 +1776,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1781 1776
1782 start_pos = round_down(pos, root->sectorsize); 1777 start_pos = round_down(pos, root->sectorsize);
1783 if (start_pos > i_size_read(inode)) { 1778 if (start_pos > i_size_read(inode)) {
1784 err = btrfs_cont_expand(inode, i_size_read(inode), start_pos); 1779 /* Expand hole size to cover write data, preventing empty gap */
1780 end_pos = round_up(pos + iov->iov_len, root->sectorsize);
1781 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos);
1785 if (err) { 1782 if (err) {
1786 mutex_unlock(&inode->i_mutex); 1783 mutex_unlock(&inode->i_mutex);
1787 goto out; 1784 goto out;
@@ -1793,7 +1790,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1793 1790
1794 if (unlikely(file->f_flags & O_DIRECT)) { 1791 if (unlikely(file->f_flags & O_DIRECT)) {
1795 num_written = __btrfs_direct_write(iocb, iov, nr_segs, 1792 num_written = __btrfs_direct_write(iocb, iov, nr_segs,
1796 pos, ppos, count, ocount); 1793 pos, count, ocount);
1797 } else { 1794 } else {
1798 struct iov_iter i; 1795 struct iov_iter i;
1799 1796
@@ -1801,7 +1798,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1801 1798
1802 num_written = __btrfs_buffered_write(file, &i, pos); 1799 num_written = __btrfs_buffered_write(file, &i, pos);
1803 if (num_written > 0) 1800 if (num_written > 0)
1804 *ppos = pos + num_written; 1801 iocb->ki_pos = pos + num_written;
1805 } 1802 }
1806 1803
1807 mutex_unlock(&inode->i_mutex); 1804 mutex_unlock(&inode->i_mutex);
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index ab485e57b6fe..cc8ca193d830 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -55,7 +55,7 @@ static int caching_kthread(void *data)
55 key.type = BTRFS_INODE_ITEM_KEY; 55 key.type = BTRFS_INODE_ITEM_KEY;
56again: 56again:
57 /* need to make sure the commit_root doesn't disappear */ 57 /* need to make sure the commit_root doesn't disappear */
58 mutex_lock(&root->fs_commit_mutex); 58 down_read(&fs_info->commit_root_sem);
59 59
60 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 60 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
61 if (ret < 0) 61 if (ret < 0)
@@ -88,7 +88,7 @@ again:
88 btrfs_item_key_to_cpu(leaf, &key, 0); 88 btrfs_item_key_to_cpu(leaf, &key, 0);
89 btrfs_release_path(path); 89 btrfs_release_path(path);
90 root->cache_progress = last; 90 root->cache_progress = last;
91 mutex_unlock(&root->fs_commit_mutex); 91 up_read(&fs_info->commit_root_sem);
92 schedule_timeout(1); 92 schedule_timeout(1);
93 goto again; 93 goto again;
94 } else 94 } else
@@ -127,7 +127,7 @@ next:
127 btrfs_unpin_free_ino(root); 127 btrfs_unpin_free_ino(root);
128out: 128out:
129 wake_up(&root->cache_wait); 129 wake_up(&root->cache_wait);
130 mutex_unlock(&root->fs_commit_mutex); 130 up_read(&fs_info->commit_root_sem);
131 131
132 btrfs_free_path(path); 132 btrfs_free_path(path);
133 133
@@ -223,11 +223,11 @@ again:
223 * or the caching work is done. 223 * or the caching work is done.
224 */ 224 */
225 225
226 mutex_lock(&root->fs_commit_mutex); 226 down_write(&root->fs_info->commit_root_sem);
227 spin_lock(&root->cache_lock); 227 spin_lock(&root->cache_lock);
228 if (root->cached == BTRFS_CACHE_FINISHED) { 228 if (root->cached == BTRFS_CACHE_FINISHED) {
229 spin_unlock(&root->cache_lock); 229 spin_unlock(&root->cache_lock);
230 mutex_unlock(&root->fs_commit_mutex); 230 up_write(&root->fs_info->commit_root_sem);
231 goto again; 231 goto again;
232 } 232 }
233 spin_unlock(&root->cache_lock); 233 spin_unlock(&root->cache_lock);
@@ -240,7 +240,7 @@ again:
240 else 240 else
241 __btrfs_add_free_space(pinned, objectid, 1); 241 __btrfs_add_free_space(pinned, objectid, 1);
242 242
243 mutex_unlock(&root->fs_commit_mutex); 243 up_write(&root->fs_info->commit_root_sem);
244 } 244 }
245} 245}
246 246
@@ -250,7 +250,7 @@ again:
250 * and others will just be dropped, because the commit root we were 250 * and others will just be dropped, because the commit root we were
251 * searching has changed. 251 * searching has changed.
252 * 252 *
253 * Must be called with root->fs_commit_mutex held 253 * Must be called with root->fs_info->commit_root_sem held
254 */ 254 */
255void btrfs_unpin_free_ino(struct btrfs_root *root) 255void btrfs_unpin_free_ino(struct btrfs_root *root)
256{ 256{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 06e9a4152b14..5f805bc944fa 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -394,6 +394,14 @@ static noinline int compress_file_range(struct inode *inode,
394 (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size)) 394 (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
395 btrfs_add_inode_defrag(NULL, inode); 395 btrfs_add_inode_defrag(NULL, inode);
396 396
397 /*
398 * skip compression for a small file range(<=blocksize) that
399 * isn't an inline extent, since it dosen't save disk space at all.
400 */
401 if ((end - start + 1) <= blocksize &&
402 (start > 0 || end + 1 < BTRFS_I(inode)->disk_i_size))
403 goto cleanup_and_bail_uncompressed;
404
397 actual_end = min_t(u64, isize, end + 1); 405 actual_end = min_t(u64, isize, end + 1);
398again: 406again:
399 will_compress = 0; 407 will_compress = 0;
@@ -1271,6 +1279,15 @@ next_slot:
1271 disk_bytenr += cur_offset - found_key.offset; 1279 disk_bytenr += cur_offset - found_key.offset;
1272 num_bytes = min(end + 1, extent_end) - cur_offset; 1280 num_bytes = min(end + 1, extent_end) - cur_offset;
1273 /* 1281 /*
1282 * if there are pending snapshots for this root,
1283 * we fall into common COW way.
1284 */
1285 if (!nolock) {
1286 err = btrfs_start_nocow_write(root);
1287 if (!err)
1288 goto out_check;
1289 }
1290 /*
1274 * force cow if csum exists in the range. 1291 * force cow if csum exists in the range.
1275 * this ensure that csum for a given extent are 1292 * this ensure that csum for a given extent are
1276 * either valid or do not exist. 1293 * either valid or do not exist.
@@ -1289,6 +1306,8 @@ next_slot:
1289out_check: 1306out_check:
1290 if (extent_end <= start) { 1307 if (extent_end <= start) {
1291 path->slots[0]++; 1308 path->slots[0]++;
1309 if (!nolock && nocow)
1310 btrfs_end_nocow_write(root);
1292 goto next_slot; 1311 goto next_slot;
1293 } 1312 }
1294 if (!nocow) { 1313 if (!nocow) {
@@ -1306,8 +1325,11 @@ out_check:
1306 ret = cow_file_range(inode, locked_page, 1325 ret = cow_file_range(inode, locked_page,
1307 cow_start, found_key.offset - 1, 1326 cow_start, found_key.offset - 1,
1308 page_started, nr_written, 1); 1327 page_started, nr_written, 1);
1309 if (ret) 1328 if (ret) {
1329 if (!nolock && nocow)
1330 btrfs_end_nocow_write(root);
1310 goto error; 1331 goto error;
1332 }
1311 cow_start = (u64)-1; 1333 cow_start = (u64)-1;
1312 } 1334 }
1313 1335
@@ -1354,8 +1376,11 @@ out_check:
1354 BTRFS_DATA_RELOC_TREE_OBJECTID) { 1376 BTRFS_DATA_RELOC_TREE_OBJECTID) {
1355 ret = btrfs_reloc_clone_csums(inode, cur_offset, 1377 ret = btrfs_reloc_clone_csums(inode, cur_offset,
1356 num_bytes); 1378 num_bytes);
1357 if (ret) 1379 if (ret) {
1380 if (!nolock && nocow)
1381 btrfs_end_nocow_write(root);
1358 goto error; 1382 goto error;
1383 }
1359 } 1384 }
1360 1385
1361 extent_clear_unlock_delalloc(inode, cur_offset, 1386 extent_clear_unlock_delalloc(inode, cur_offset,
@@ -1363,6 +1388,8 @@ out_check:
1363 locked_page, EXTENT_LOCKED | 1388 locked_page, EXTENT_LOCKED |
1364 EXTENT_DELALLOC, PAGE_UNLOCK | 1389 EXTENT_DELALLOC, PAGE_UNLOCK |
1365 PAGE_SET_PRIVATE2); 1390 PAGE_SET_PRIVATE2);
1391 if (!nolock && nocow)
1392 btrfs_end_nocow_write(root);
1366 cur_offset = extent_end; 1393 cur_offset = extent_end;
1367 if (cur_offset > end) 1394 if (cur_offset > end)
1368 break; 1395 break;
@@ -8476,19 +8503,20 @@ static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput,
8476 else 8503 else
8477 iput(inode); 8504 iput(inode);
8478 ret = -ENOMEM; 8505 ret = -ENOMEM;
8479 break; 8506 goto out;
8480 } 8507 }
8481 list_add_tail(&work->list, &works); 8508 list_add_tail(&work->list, &works);
8482 btrfs_queue_work(root->fs_info->flush_workers, 8509 btrfs_queue_work(root->fs_info->flush_workers,
8483 &work->work); 8510 &work->work);
8484 ret++; 8511 ret++;
8485 if (nr != -1 && ret >= nr) 8512 if (nr != -1 && ret >= nr)
8486 break; 8513 goto out;
8487 cond_resched(); 8514 cond_resched();
8488 spin_lock(&root->delalloc_lock); 8515 spin_lock(&root->delalloc_lock);
8489 } 8516 }
8490 spin_unlock(&root->delalloc_lock); 8517 spin_unlock(&root->delalloc_lock);
8491 8518
8519out:
8492 list_for_each_entry_safe(work, next, &works, list) { 8520 list_for_each_entry_safe(work, next, &works, list) {
8493 list_del_init(&work->list); 8521 list_del_init(&work->list);
8494 btrfs_wait_and_free_delalloc_work(work); 8522 btrfs_wait_and_free_delalloc_work(work);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 0401397b5c92..e79ff6b90cb7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1472,6 +1472,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
1472 struct btrfs_trans_handle *trans; 1472 struct btrfs_trans_handle *trans;
1473 struct btrfs_device *device = NULL; 1473 struct btrfs_device *device = NULL;
1474 char *sizestr; 1474 char *sizestr;
1475 char *retptr;
1475 char *devstr = NULL; 1476 char *devstr = NULL;
1476 int ret = 0; 1477 int ret = 0;
1477 int mod = 0; 1478 int mod = 0;
@@ -1539,8 +1540,8 @@ static noinline int btrfs_ioctl_resize(struct file *file,
1539 mod = 1; 1540 mod = 1;
1540 sizestr++; 1541 sizestr++;
1541 } 1542 }
1542 new_size = memparse(sizestr, NULL); 1543 new_size = memparse(sizestr, &retptr);
1543 if (new_size == 0) { 1544 if (*retptr != '\0' || new_size == 0) {
1544 ret = -EINVAL; 1545 ret = -EINVAL;
1545 goto out_free; 1546 goto out_free;
1546 } 1547 }
@@ -3140,8 +3141,9 @@ process_slot:
3140 new_key.offset + datal, 3141 new_key.offset + datal,
3141 1); 3142 1);
3142 if (ret) { 3143 if (ret) {
3143 btrfs_abort_transaction(trans, root, 3144 if (ret != -EINVAL)
3144 ret); 3145 btrfs_abort_transaction(trans,
3146 root, ret);
3145 btrfs_end_transaction(trans, root); 3147 btrfs_end_transaction(trans, root);
3146 goto out; 3148 goto out;
3147 } 3149 }
@@ -3538,6 +3540,11 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
3538 up_read(&info->groups_sem); 3540 up_read(&info->groups_sem);
3539 } 3541 }
3540 3542
3543 /*
3544 * Global block reserve, exported as a space_info
3545 */
3546 slot_count++;
3547
3541 /* space_slots == 0 means they are asking for a count */ 3548 /* space_slots == 0 means they are asking for a count */
3542 if (space_args.space_slots == 0) { 3549 if (space_args.space_slots == 0) {
3543 space_args.total_spaces = slot_count; 3550 space_args.total_spaces = slot_count;
@@ -3596,6 +3603,21 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
3596 up_read(&info->groups_sem); 3603 up_read(&info->groups_sem);
3597 } 3604 }
3598 3605
3606 /*
3607 * Add global block reserve
3608 */
3609 if (slot_count) {
3610 struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv;
3611
3612 spin_lock(&block_rsv->lock);
3613 space.total_bytes = block_rsv->size;
3614 space.used_bytes = block_rsv->size - block_rsv->reserved;
3615 spin_unlock(&block_rsv->lock);
3616 space.flags = BTRFS_SPACE_INFO_GLOBAL_RSV;
3617 memcpy(dest, &space, sizeof(space));
3618 space_args.total_spaces++;
3619 }
3620
3599 user_dest = (struct btrfs_ioctl_space_info __user *) 3621 user_dest = (struct btrfs_ioctl_space_info __user *)
3600 (arg + sizeof(struct btrfs_ioctl_space_args)); 3622 (arg + sizeof(struct btrfs_ioctl_space_args));
3601 3623
@@ -4531,9 +4553,8 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file,
4531 } 4553 }
4532 4554
4533 args64 = kmalloc(sizeof(*args64), GFP_NOFS); 4555 args64 = kmalloc(sizeof(*args64), GFP_NOFS);
4534 if (IS_ERR(args64)) { 4556 if (!args64) {
4535 ret = PTR_ERR(args64); 4557 ret = -ENOMEM;
4536 args64 = NULL;
4537 goto out; 4558 goto out;
4538 } 4559 }
4539 4560
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index def428a25b2a..7f92ab1daa87 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2317,7 +2317,6 @@ void free_reloc_roots(struct list_head *list)
2317static noinline_for_stack 2317static noinline_for_stack
2318int merge_reloc_roots(struct reloc_control *rc) 2318int merge_reloc_roots(struct reloc_control *rc)
2319{ 2319{
2320 struct btrfs_trans_handle *trans;
2321 struct btrfs_root *root; 2320 struct btrfs_root *root;
2322 struct btrfs_root *reloc_root; 2321 struct btrfs_root *reloc_root;
2323 u64 last_snap; 2322 u64 last_snap;
@@ -2375,26 +2374,6 @@ again:
2375 list_add_tail(&reloc_root->root_list, 2374 list_add_tail(&reloc_root->root_list,
2376 &reloc_roots); 2375 &reloc_roots);
2377 goto out; 2376 goto out;
2378 } else if (!ret) {
2379 /*
2380 * recover the last snapshot tranid to avoid
2381 * the space balance break NOCOW.
2382 */
2383 root = read_fs_root(rc->extent_root->fs_info,
2384 objectid);
2385 if (IS_ERR(root))
2386 continue;
2387
2388 trans = btrfs_join_transaction(root);
2389 BUG_ON(IS_ERR(trans));
2390
2391 /* Check if the fs/file tree was snapshoted or not. */
2392 if (btrfs_root_last_snapshot(&root->root_item) ==
2393 otransid - 1)
2394 btrfs_set_root_last_snapshot(&root->root_item,
2395 last_snap);
2396
2397 btrfs_end_transaction(trans, root);
2398 } 2377 }
2399 } 2378 }
2400 2379
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 93e6d7172844..0be77993378e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2235,6 +2235,47 @@ behind_scrub_pages:
2235 return 0; 2235 return 0;
2236} 2236}
2237 2237
2238/*
2239 * Given a physical address, this will calculate it's
2240 * logical offset. if this is a parity stripe, it will return
2241 * the most left data stripe's logical offset.
2242 *
2243 * return 0 if it is a data stripe, 1 means parity stripe.
2244 */
2245static int get_raid56_logic_offset(u64 physical, int num,
2246 struct map_lookup *map, u64 *offset)
2247{
2248 int i;
2249 int j = 0;
2250 u64 stripe_nr;
2251 u64 last_offset;
2252 int stripe_index;
2253 int rot;
2254
2255 last_offset = (physical - map->stripes[num].physical) *
2256 nr_data_stripes(map);
2257 *offset = last_offset;
2258 for (i = 0; i < nr_data_stripes(map); i++) {
2259 *offset = last_offset + i * map->stripe_len;
2260
2261 stripe_nr = *offset;
2262 do_div(stripe_nr, map->stripe_len);
2263 do_div(stripe_nr, nr_data_stripes(map));
2264
2265 /* Work out the disk rotation on this stripe-set */
2266 rot = do_div(stripe_nr, map->num_stripes);
2267 /* calculate which stripe this data locates */
2268 rot += i;
2269 stripe_index = rot % map->num_stripes;
2270 if (stripe_index == num)
2271 return 0;
2272 if (stripe_index < num)
2273 j++;
2274 }
2275 *offset = last_offset + j * map->stripe_len;
2276 return 1;
2277}
2278
2238static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, 2279static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2239 struct map_lookup *map, 2280 struct map_lookup *map,
2240 struct btrfs_device *scrub_dev, 2281 struct btrfs_device *scrub_dev,
@@ -2256,6 +2297,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2256 u64 physical; 2297 u64 physical;
2257 u64 logical; 2298 u64 logical;
2258 u64 logic_end; 2299 u64 logic_end;
2300 u64 physical_end;
2259 u64 generation; 2301 u64 generation;
2260 int mirror_num; 2302 int mirror_num;
2261 struct reada_control *reada1; 2303 struct reada_control *reada1;
@@ -2269,16 +2311,10 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2269 u64 extent_len; 2311 u64 extent_len;
2270 struct btrfs_device *extent_dev; 2312 struct btrfs_device *extent_dev;
2271 int extent_mirror_num; 2313 int extent_mirror_num;
2272 int stop_loop; 2314 int stop_loop = 0;
2273
2274 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
2275 BTRFS_BLOCK_GROUP_RAID6)) {
2276 if (num >= nr_data_stripes(map)) {
2277 return 0;
2278 }
2279 }
2280 2315
2281 nstripes = length; 2316 nstripes = length;
2317 physical = map->stripes[num].physical;
2282 offset = 0; 2318 offset = 0;
2283 do_div(nstripes, map->stripe_len); 2319 do_div(nstripes, map->stripe_len);
2284 if (map->type & BTRFS_BLOCK_GROUP_RAID0) { 2320 if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
@@ -2296,6 +2332,11 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2296 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { 2332 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
2297 increment = map->stripe_len; 2333 increment = map->stripe_len;
2298 mirror_num = num % map->num_stripes + 1; 2334 mirror_num = num % map->num_stripes + 1;
2335 } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
2336 BTRFS_BLOCK_GROUP_RAID6)) {
2337 get_raid56_logic_offset(physical, num, map, &offset);
2338 increment = map->stripe_len * nr_data_stripes(map);
2339 mirror_num = 1;
2299 } else { 2340 } else {
2300 increment = map->stripe_len; 2341 increment = map->stripe_len;
2301 mirror_num = 1; 2342 mirror_num = 1;
@@ -2319,7 +2360,15 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2319 * to not hold off transaction commits 2360 * to not hold off transaction commits
2320 */ 2361 */
2321 logical = base + offset; 2362 logical = base + offset;
2322 2363 physical_end = physical + nstripes * map->stripe_len;
2364 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
2365 BTRFS_BLOCK_GROUP_RAID6)) {
2366 get_raid56_logic_offset(physical_end, num,
2367 map, &logic_end);
2368 logic_end += base;
2369 } else {
2370 logic_end = logical + increment * nstripes;
2371 }
2323 wait_event(sctx->list_wait, 2372 wait_event(sctx->list_wait,
2324 atomic_read(&sctx->bios_in_flight) == 0); 2373 atomic_read(&sctx->bios_in_flight) == 0);
2325 scrub_blocked_if_needed(fs_info); 2374 scrub_blocked_if_needed(fs_info);
@@ -2328,7 +2377,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2328 key_start.objectid = logical; 2377 key_start.objectid = logical;
2329 key_start.type = BTRFS_EXTENT_ITEM_KEY; 2378 key_start.type = BTRFS_EXTENT_ITEM_KEY;
2330 key_start.offset = (u64)0; 2379 key_start.offset = (u64)0;
2331 key_end.objectid = base + offset + nstripes * increment; 2380 key_end.objectid = logic_end;
2332 key_end.type = BTRFS_METADATA_ITEM_KEY; 2381 key_end.type = BTRFS_METADATA_ITEM_KEY;
2333 key_end.offset = (u64)-1; 2382 key_end.offset = (u64)-1;
2334 reada1 = btrfs_reada_add(root, &key_start, &key_end); 2383 reada1 = btrfs_reada_add(root, &key_start, &key_end);
@@ -2338,7 +2387,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2338 key_start.offset = logical; 2387 key_start.offset = logical;
2339 key_end.objectid = BTRFS_EXTENT_CSUM_OBJECTID; 2388 key_end.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
2340 key_end.type = BTRFS_EXTENT_CSUM_KEY; 2389 key_end.type = BTRFS_EXTENT_CSUM_KEY;
2341 key_end.offset = base + offset + nstripes * increment; 2390 key_end.offset = logic_end;
2342 reada2 = btrfs_reada_add(csum_root, &key_start, &key_end); 2391 reada2 = btrfs_reada_add(csum_root, &key_start, &key_end);
2343 2392
2344 if (!IS_ERR(reada1)) 2393 if (!IS_ERR(reada1))
@@ -2356,11 +2405,17 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2356 /* 2405 /*
2357 * now find all extents for each stripe and scrub them 2406 * now find all extents for each stripe and scrub them
2358 */ 2407 */
2359 logical = base + offset;
2360 physical = map->stripes[num].physical;
2361 logic_end = logical + increment * nstripes;
2362 ret = 0; 2408 ret = 0;
2363 while (logical < logic_end) { 2409 while (physical < physical_end) {
2410 /* for raid56, we skip parity stripe */
2411 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
2412 BTRFS_BLOCK_GROUP_RAID6)) {
2413 ret = get_raid56_logic_offset(physical, num,
2414 map, &logical);
2415 logical += base;
2416 if (ret)
2417 goto skip;
2418 }
2364 /* 2419 /*
2365 * canceled? 2420 * canceled?
2366 */ 2421 */
@@ -2504,15 +2559,29 @@ again:
2504 scrub_free_csums(sctx); 2559 scrub_free_csums(sctx);
2505 if (extent_logical + extent_len < 2560 if (extent_logical + extent_len <
2506 key.objectid + bytes) { 2561 key.objectid + bytes) {
2507 logical += increment; 2562 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
2508 physical += map->stripe_len; 2563 BTRFS_BLOCK_GROUP_RAID6)) {
2509 2564 /*
2565 * loop until we find next data stripe
2566 * or we have finished all stripes.
2567 */
2568 do {
2569 physical += map->stripe_len;
2570 ret = get_raid56_logic_offset(
2571 physical, num,
2572 map, &logical);
2573 logical += base;
2574 } while (physical < physical_end && ret);
2575 } else {
2576 physical += map->stripe_len;
2577 logical += increment;
2578 }
2510 if (logical < key.objectid + bytes) { 2579 if (logical < key.objectid + bytes) {
2511 cond_resched(); 2580 cond_resched();
2512 goto again; 2581 goto again;
2513 } 2582 }
2514 2583
2515 if (logical >= logic_end) { 2584 if (physical >= physical_end) {
2516 stop_loop = 1; 2585 stop_loop = 1;
2517 break; 2586 break;
2518 } 2587 }
@@ -2521,6 +2590,7 @@ next:
2521 path->slots[0]++; 2590 path->slots[0]++;
2522 } 2591 }
2523 btrfs_release_path(path); 2592 btrfs_release_path(path);
2593skip:
2524 logical += increment; 2594 logical += increment;
2525 physical += map->stripe_len; 2595 physical += map->stripe_len;
2526 spin_lock(&sctx->stat_lock); 2596 spin_lock(&sctx->stat_lock);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 9b6da9d55f9a..1ac3ca98c429 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -493,6 +493,7 @@ static struct btrfs_path *alloc_path_for_send(void)
493 return NULL; 493 return NULL;
494 path->search_commit_root = 1; 494 path->search_commit_root = 1;
495 path->skip_locking = 1; 495 path->skip_locking = 1;
496 path->need_commit_sem = 1;
496 return path; 497 return path;
497} 498}
498 499
@@ -771,29 +772,22 @@ out:
771/* 772/*
772 * Helper function to retrieve some fields from an inode item. 773 * Helper function to retrieve some fields from an inode item.
773 */ 774 */
774static int get_inode_info(struct btrfs_root *root, 775static int __get_inode_info(struct btrfs_root *root, struct btrfs_path *path,
775 u64 ino, u64 *size, u64 *gen, 776 u64 ino, u64 *size, u64 *gen, u64 *mode, u64 *uid,
776 u64 *mode, u64 *uid, u64 *gid, 777 u64 *gid, u64 *rdev)
777 u64 *rdev)
778{ 778{
779 int ret; 779 int ret;
780 struct btrfs_inode_item *ii; 780 struct btrfs_inode_item *ii;
781 struct btrfs_key key; 781 struct btrfs_key key;
782 struct btrfs_path *path;
783
784 path = alloc_path_for_send();
785 if (!path)
786 return -ENOMEM;
787 782
788 key.objectid = ino; 783 key.objectid = ino;
789 key.type = BTRFS_INODE_ITEM_KEY; 784 key.type = BTRFS_INODE_ITEM_KEY;
790 key.offset = 0; 785 key.offset = 0;
791 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 786 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
792 if (ret < 0)
793 goto out;
794 if (ret) { 787 if (ret) {
795 ret = -ENOENT; 788 if (ret > 0)
796 goto out; 789 ret = -ENOENT;
790 return ret;
797 } 791 }
798 792
799 ii = btrfs_item_ptr(path->nodes[0], path->slots[0], 793 ii = btrfs_item_ptr(path->nodes[0], path->slots[0],
@@ -811,7 +805,22 @@ static int get_inode_info(struct btrfs_root *root,
811 if (rdev) 805 if (rdev)
812 *rdev = btrfs_inode_rdev(path->nodes[0], ii); 806 *rdev = btrfs_inode_rdev(path->nodes[0], ii);
813 807
814out: 808 return ret;
809}
810
811static int get_inode_info(struct btrfs_root *root,
812 u64 ino, u64 *size, u64 *gen,
813 u64 *mode, u64 *uid, u64 *gid,
814 u64 *rdev)
815{
816 struct btrfs_path *path;
817 int ret;
818
819 path = alloc_path_for_send();
820 if (!path)
821 return -ENOMEM;
822 ret = __get_inode_info(root, path, ino, size, gen, mode, uid, gid,
823 rdev);
815 btrfs_free_path(path); 824 btrfs_free_path(path);
816 return ret; 825 return ret;
817} 826}
@@ -1085,6 +1094,7 @@ out:
1085struct backref_ctx { 1094struct backref_ctx {
1086 struct send_ctx *sctx; 1095 struct send_ctx *sctx;
1087 1096
1097 struct btrfs_path *path;
1088 /* number of total found references */ 1098 /* number of total found references */
1089 u64 found; 1099 u64 found;
1090 1100
@@ -1155,8 +1165,9 @@ static int __iterate_backrefs(u64 ino, u64 offset, u64 root, void *ctx_)
1155 * There are inodes that have extents that lie behind its i_size. Don't 1165 * There are inodes that have extents that lie behind its i_size. Don't
1156 * accept clones from these extents. 1166 * accept clones from these extents.
1157 */ 1167 */
1158 ret = get_inode_info(found->root, ino, &i_size, NULL, NULL, NULL, NULL, 1168 ret = __get_inode_info(found->root, bctx->path, ino, &i_size, NULL, NULL,
1159 NULL); 1169 NULL, NULL, NULL);
1170 btrfs_release_path(bctx->path);
1160 if (ret < 0) 1171 if (ret < 0)
1161 return ret; 1172 return ret;
1162 1173
@@ -1235,12 +1246,17 @@ static int find_extent_clone(struct send_ctx *sctx,
1235 if (!tmp_path) 1246 if (!tmp_path)
1236 return -ENOMEM; 1247 return -ENOMEM;
1237 1248
1249 /* We only use this path under the commit sem */
1250 tmp_path->need_commit_sem = 0;
1251
1238 backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_NOFS); 1252 backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_NOFS);
1239 if (!backref_ctx) { 1253 if (!backref_ctx) {
1240 ret = -ENOMEM; 1254 ret = -ENOMEM;
1241 goto out; 1255 goto out;
1242 } 1256 }
1243 1257
1258 backref_ctx->path = tmp_path;
1259
1244 if (data_offset >= ino_size) { 1260 if (data_offset >= ino_size) {
1245 /* 1261 /*
1246 * There may be extents that lie behind the file's size. 1262 * There may be extents that lie behind the file's size.
@@ -1268,8 +1284,10 @@ static int find_extent_clone(struct send_ctx *sctx,
1268 } 1284 }
1269 logical = disk_byte + btrfs_file_extent_offset(eb, fi); 1285 logical = disk_byte + btrfs_file_extent_offset(eb, fi);
1270 1286
1287 down_read(&sctx->send_root->fs_info->commit_root_sem);
1271 ret = extent_from_logical(sctx->send_root->fs_info, disk_byte, tmp_path, 1288 ret = extent_from_logical(sctx->send_root->fs_info, disk_byte, tmp_path,
1272 &found_key, &flags); 1289 &found_key, &flags);
1290 up_read(&sctx->send_root->fs_info->commit_root_sem);
1273 btrfs_release_path(tmp_path); 1291 btrfs_release_path(tmp_path);
1274 1292
1275 if (ret < 0) 1293 if (ret < 0)
@@ -4418,6 +4436,9 @@ static int send_hole(struct send_ctx *sctx, u64 end)
4418 p = fs_path_alloc(); 4436 p = fs_path_alloc();
4419 if (!p) 4437 if (!p)
4420 return -ENOMEM; 4438 return -ENOMEM;
4439 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
4440 if (ret < 0)
4441 goto tlv_put_failure;
4421 memset(sctx->read_buf, 0, BTRFS_SEND_READ_SIZE); 4442 memset(sctx->read_buf, 0, BTRFS_SEND_READ_SIZE);
4422 while (offset < end) { 4443 while (offset < end) {
4423 len = min_t(u64, end - offset, BTRFS_SEND_READ_SIZE); 4444 len = min_t(u64, end - offset, BTRFS_SEND_READ_SIZE);
@@ -4425,9 +4446,6 @@ static int send_hole(struct send_ctx *sctx, u64 end)
4425 ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); 4446 ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE);
4426 if (ret < 0) 4447 if (ret < 0)
4427 break; 4448 break;
4428 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
4429 if (ret < 0)
4430 break;
4431 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); 4449 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p);
4432 TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); 4450 TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset);
4433 TLV_PUT(sctx, BTRFS_SEND_A_DATA, sctx->read_buf, len); 4451 TLV_PUT(sctx, BTRFS_SEND_A_DATA, sctx->read_buf, len);
@@ -4968,7 +4986,9 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
4968 4986
4969 if (S_ISREG(sctx->cur_inode_mode)) { 4987 if (S_ISREG(sctx->cur_inode_mode)) {
4970 if (need_send_hole(sctx)) { 4988 if (need_send_hole(sctx)) {
4971 if (sctx->cur_inode_last_extent == (u64)-1) { 4989 if (sctx->cur_inode_last_extent == (u64)-1 ||
4990 sctx->cur_inode_last_extent <
4991 sctx->cur_inode_size) {
4972 ret = get_last_extent(sctx, (u64)-1); 4992 ret = get_last_extent(sctx, (u64)-1);
4973 if (ret) 4993 if (ret)
4974 goto out; 4994 goto out;
@@ -5367,57 +5387,21 @@ out:
5367static int full_send_tree(struct send_ctx *sctx) 5387static int full_send_tree(struct send_ctx *sctx)
5368{ 5388{
5369 int ret; 5389 int ret;
5370 struct btrfs_trans_handle *trans = NULL;
5371 struct btrfs_root *send_root = sctx->send_root; 5390 struct btrfs_root *send_root = sctx->send_root;
5372 struct btrfs_key key; 5391 struct btrfs_key key;
5373 struct btrfs_key found_key; 5392 struct btrfs_key found_key;
5374 struct btrfs_path *path; 5393 struct btrfs_path *path;
5375 struct extent_buffer *eb; 5394 struct extent_buffer *eb;
5376 int slot; 5395 int slot;
5377 u64 start_ctransid;
5378 u64 ctransid;
5379 5396
5380 path = alloc_path_for_send(); 5397 path = alloc_path_for_send();
5381 if (!path) 5398 if (!path)
5382 return -ENOMEM; 5399 return -ENOMEM;
5383 5400
5384 spin_lock(&send_root->root_item_lock);
5385 start_ctransid = btrfs_root_ctransid(&send_root->root_item);
5386 spin_unlock(&send_root->root_item_lock);
5387
5388 key.objectid = BTRFS_FIRST_FREE_OBJECTID; 5401 key.objectid = BTRFS_FIRST_FREE_OBJECTID;
5389 key.type = BTRFS_INODE_ITEM_KEY; 5402 key.type = BTRFS_INODE_ITEM_KEY;
5390 key.offset = 0; 5403 key.offset = 0;
5391 5404
5392join_trans:
5393 /*
5394 * We need to make sure the transaction does not get committed
5395 * while we do anything on commit roots. Join a transaction to prevent
5396 * this.
5397 */
5398 trans = btrfs_join_transaction(send_root);
5399 if (IS_ERR(trans)) {
5400 ret = PTR_ERR(trans);
5401 trans = NULL;
5402 goto out;
5403 }
5404
5405 /*
5406 * Make sure the tree has not changed after re-joining. We detect this
5407 * by comparing start_ctransid and ctransid. They should always match.
5408 */
5409 spin_lock(&send_root->root_item_lock);
5410 ctransid = btrfs_root_ctransid(&send_root->root_item);
5411 spin_unlock(&send_root->root_item_lock);
5412
5413 if (ctransid != start_ctransid) {
5414 WARN(1, KERN_WARNING "BTRFS: the root that you're trying to "
5415 "send was modified in between. This is "
5416 "probably a bug.\n");
5417 ret = -EIO;
5418 goto out;
5419 }
5420
5421 ret = btrfs_search_slot_for_read(send_root, &key, path, 1, 0); 5405 ret = btrfs_search_slot_for_read(send_root, &key, path, 1, 0);
5422 if (ret < 0) 5406 if (ret < 0)
5423 goto out; 5407 goto out;
@@ -5425,19 +5409,6 @@ join_trans:
5425 goto out_finish; 5409 goto out_finish;
5426 5410
5427 while (1) { 5411 while (1) {
5428 /*
5429 * When someone want to commit while we iterate, end the
5430 * joined transaction and rejoin.
5431 */
5432 if (btrfs_should_end_transaction(trans, send_root)) {
5433 ret = btrfs_end_transaction(trans, send_root);
5434 trans = NULL;
5435 if (ret < 0)
5436 goto out;
5437 btrfs_release_path(path);
5438 goto join_trans;
5439 }
5440
5441 eb = path->nodes[0]; 5412 eb = path->nodes[0];
5442 slot = path->slots[0]; 5413 slot = path->slots[0];
5443 btrfs_item_key_to_cpu(eb, &found_key, slot); 5414 btrfs_item_key_to_cpu(eb, &found_key, slot);
@@ -5465,12 +5436,6 @@ out_finish:
5465 5436
5466out: 5437out:
5467 btrfs_free_path(path); 5438 btrfs_free_path(path);
5468 if (trans) {
5469 if (!ret)
5470 ret = btrfs_end_transaction(trans, send_root);
5471 else
5472 btrfs_end_transaction(trans, send_root);
5473 }
5474 return ret; 5439 return ret;
5475} 5440}
5476 5441
@@ -5718,7 +5683,9 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
5718 NULL); 5683 NULL);
5719 sort_clone_roots = 1; 5684 sort_clone_roots = 1;
5720 5685
5686 current->journal_info = (void *)BTRFS_SEND_TRANS_STUB;
5721 ret = send_subvol(sctx); 5687 ret = send_subvol(sctx);
5688 current->journal_info = NULL;
5722 if (ret < 0) 5689 if (ret < 0)
5723 goto out; 5690 goto out;
5724 5691
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9dbf42395153..5011aadacab8 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -66,6 +66,8 @@
66static const struct super_operations btrfs_super_ops; 66static const struct super_operations btrfs_super_ops;
67static struct file_system_type btrfs_fs_type; 67static struct file_system_type btrfs_fs_type;
68 68
69static int btrfs_remount(struct super_block *sb, int *flags, char *data);
70
69static const char *btrfs_decode_error(int errno) 71static const char *btrfs_decode_error(int errno)
70{ 72{
71 char *errstr = "unknown"; 73 char *errstr = "unknown";
@@ -1185,6 +1187,26 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
1185 mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, 1187 mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
1186 newargs); 1188 newargs);
1187 kfree(newargs); 1189 kfree(newargs);
1190
1191 if (PTR_RET(mnt) == -EBUSY) {
1192 if (flags & MS_RDONLY) {
1193 mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,
1194 newargs);
1195 } else {
1196 int r;
1197 mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
1198 newargs);
1199 if (IS_ERR(mnt))
1200 return ERR_CAST(mnt);
1201
1202 r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
1203 if (r < 0) {
1204 /* FIXME: release vfsmount mnt ??*/
1205 return ERR_PTR(r);
1206 }
1207 }
1208 }
1209
1188 if (IS_ERR(mnt)) 1210 if (IS_ERR(mnt))
1189 return ERR_CAST(mnt); 1211 return ERR_CAST(mnt);
1190 1212
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index a04707f740d6..7579f6d0b854 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -75,10 +75,21 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction)
75 } 75 }
76} 76}
77 77
78static noinline void switch_commit_root(struct btrfs_root *root) 78static noinline void switch_commit_roots(struct btrfs_transaction *trans,
79 struct btrfs_fs_info *fs_info)
79{ 80{
80 free_extent_buffer(root->commit_root); 81 struct btrfs_root *root, *tmp;
81 root->commit_root = btrfs_root_node(root); 82
83 down_write(&fs_info->commit_root_sem);
84 list_for_each_entry_safe(root, tmp, &trans->switch_commits,
85 dirty_list) {
86 list_del_init(&root->dirty_list);
87 free_extent_buffer(root->commit_root);
88 root->commit_root = btrfs_root_node(root);
89 if (is_fstree(root->objectid))
90 btrfs_unpin_free_ino(root);
91 }
92 up_write(&fs_info->commit_root_sem);
82} 93}
83 94
84static inline void extwriter_counter_inc(struct btrfs_transaction *trans, 95static inline void extwriter_counter_inc(struct btrfs_transaction *trans,
@@ -208,6 +219,7 @@ loop:
208 INIT_LIST_HEAD(&cur_trans->pending_snapshots); 219 INIT_LIST_HEAD(&cur_trans->pending_snapshots);
209 INIT_LIST_HEAD(&cur_trans->ordered_operations); 220 INIT_LIST_HEAD(&cur_trans->ordered_operations);
210 INIT_LIST_HEAD(&cur_trans->pending_chunks); 221 INIT_LIST_HEAD(&cur_trans->pending_chunks);
222 INIT_LIST_HEAD(&cur_trans->switch_commits);
211 list_add_tail(&cur_trans->list, &fs_info->trans_list); 223 list_add_tail(&cur_trans->list, &fs_info->trans_list);
212 extent_io_tree_init(&cur_trans->dirty_pages, 224 extent_io_tree_init(&cur_trans->dirty_pages,
213 fs_info->btree_inode->i_mapping); 225 fs_info->btree_inode->i_mapping);
@@ -375,7 +387,8 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
375 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) 387 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state))
376 return ERR_PTR(-EROFS); 388 return ERR_PTR(-EROFS);
377 389
378 if (current->journal_info) { 390 if (current->journal_info &&
391 current->journal_info != (void *)BTRFS_SEND_TRANS_STUB) {
379 WARN_ON(type & TRANS_EXTWRITERS); 392 WARN_ON(type & TRANS_EXTWRITERS);
380 h = current->journal_info; 393 h = current->journal_info;
381 h->use_count++; 394 h->use_count++;
@@ -919,9 +932,6 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
919 return ret; 932 return ret;
920 } 933 }
921 934
922 if (root != root->fs_info->extent_root)
923 switch_commit_root(root);
924
925 return 0; 935 return 0;
926} 936}
927 937
@@ -977,15 +987,16 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
977 list_del_init(next); 987 list_del_init(next);
978 root = list_entry(next, struct btrfs_root, dirty_list); 988 root = list_entry(next, struct btrfs_root, dirty_list);
979 989
990 if (root != fs_info->extent_root)
991 list_add_tail(&root->dirty_list,
992 &trans->transaction->switch_commits);
980 ret = update_cowonly_root(trans, root); 993 ret = update_cowonly_root(trans, root);
981 if (ret) 994 if (ret)
982 return ret; 995 return ret;
983 } 996 }
984 997
985 down_write(&fs_info->extent_commit_sem); 998 list_add_tail(&fs_info->extent_root->dirty_list,
986 switch_commit_root(fs_info->extent_root); 999 &trans->transaction->switch_commits);
987 up_write(&fs_info->extent_commit_sem);
988
989 btrfs_after_dev_replace_commit(fs_info); 1000 btrfs_after_dev_replace_commit(fs_info);
990 1001
991 return 0; 1002 return 0;
@@ -1042,11 +1053,8 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
1042 smp_wmb(); 1053 smp_wmb();
1043 1054
1044 if (root->commit_root != root->node) { 1055 if (root->commit_root != root->node) {
1045 mutex_lock(&root->fs_commit_mutex); 1056 list_add_tail(&root->dirty_list,
1046 switch_commit_root(root); 1057 &trans->transaction->switch_commits);
1047 btrfs_unpin_free_ino(root);
1048 mutex_unlock(&root->fs_commit_mutex);
1049
1050 btrfs_set_root_node(&root->root_item, 1058 btrfs_set_root_node(&root->root_item,
1051 root->node); 1059 root->node);
1052 } 1060 }
@@ -1857,11 +1865,15 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1857 1865
1858 btrfs_set_root_node(&root->fs_info->tree_root->root_item, 1866 btrfs_set_root_node(&root->fs_info->tree_root->root_item,
1859 root->fs_info->tree_root->node); 1867 root->fs_info->tree_root->node);
1860 switch_commit_root(root->fs_info->tree_root); 1868 list_add_tail(&root->fs_info->tree_root->dirty_list,
1869 &cur_trans->switch_commits);
1861 1870
1862 btrfs_set_root_node(&root->fs_info->chunk_root->root_item, 1871 btrfs_set_root_node(&root->fs_info->chunk_root->root_item,
1863 root->fs_info->chunk_root->node); 1872 root->fs_info->chunk_root->node);
1864 switch_commit_root(root->fs_info->chunk_root); 1873 list_add_tail(&root->fs_info->chunk_root->dirty_list,
1874 &cur_trans->switch_commits);
1875
1876 switch_commit_roots(cur_trans, root->fs_info);
1865 1877
1866 assert_qgroups_uptodate(trans); 1878 assert_qgroups_uptodate(trans);
1867 update_super_roots(root); 1879 update_super_roots(root);
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 6ac037e9f9f0..b57b924e8e03 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -57,6 +57,7 @@ struct btrfs_transaction {
57 struct list_head pending_snapshots; 57 struct list_head pending_snapshots;
58 struct list_head ordered_operations; 58 struct list_head ordered_operations;
59 struct list_head pending_chunks; 59 struct list_head pending_chunks;
60 struct list_head switch_commits;
60 struct btrfs_delayed_ref_root delayed_refs; 61 struct btrfs_delayed_ref_root delayed_refs;
61 int aborted; 62 int aborted;
62}; 63};
@@ -78,6 +79,8 @@ struct btrfs_transaction {
78#define TRANS_EXTWRITERS (__TRANS_USERSPACE | __TRANS_START | \ 79#define TRANS_EXTWRITERS (__TRANS_USERSPACE | __TRANS_START | \
79 __TRANS_ATTACH) 80 __TRANS_ATTACH)
80 81
82#define BTRFS_SEND_TRANS_STUB 1
83
81struct btrfs_trans_handle { 84struct btrfs_trans_handle {
82 u64 transid; 85 u64 transid;
83 u64 bytes_reserved; 86 u64 bytes_reserved;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index d241130a32fd..49d7fab73360 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -448,6 +448,14 @@ static void pending_bios_fn(struct btrfs_work *work)
448 run_scheduled_bios(device); 448 run_scheduled_bios(device);
449} 449}
450 450
451/*
452 * Add new device to list of registered devices
453 *
454 * Returns:
455 * 1 - first time device is seen
456 * 0 - device already known
457 * < 0 - error
458 */
451static noinline int device_list_add(const char *path, 459static noinline int device_list_add(const char *path,
452 struct btrfs_super_block *disk_super, 460 struct btrfs_super_block *disk_super,
453 u64 devid, struct btrfs_fs_devices **fs_devices_ret) 461 u64 devid, struct btrfs_fs_devices **fs_devices_ret)
@@ -455,6 +463,7 @@ static noinline int device_list_add(const char *path,
455 struct btrfs_device *device; 463 struct btrfs_device *device;
456 struct btrfs_fs_devices *fs_devices; 464 struct btrfs_fs_devices *fs_devices;
457 struct rcu_string *name; 465 struct rcu_string *name;
466 int ret = 0;
458 u64 found_transid = btrfs_super_generation(disk_super); 467 u64 found_transid = btrfs_super_generation(disk_super);
459 468
460 fs_devices = find_fsid(disk_super->fsid); 469 fs_devices = find_fsid(disk_super->fsid);
@@ -495,6 +504,7 @@ static noinline int device_list_add(const char *path,
495 fs_devices->num_devices++; 504 fs_devices->num_devices++;
496 mutex_unlock(&fs_devices->device_list_mutex); 505 mutex_unlock(&fs_devices->device_list_mutex);
497 506
507 ret = 1;
498 device->fs_devices = fs_devices; 508 device->fs_devices = fs_devices;
499 } else if (!device->name || strcmp(device->name->str, path)) { 509 } else if (!device->name || strcmp(device->name->str, path)) {
500 name = rcu_string_strdup(path, GFP_NOFS); 510 name = rcu_string_strdup(path, GFP_NOFS);
@@ -513,7 +523,8 @@ static noinline int device_list_add(const char *path,
513 fs_devices->latest_trans = found_transid; 523 fs_devices->latest_trans = found_transid;
514 } 524 }
515 *fs_devices_ret = fs_devices; 525 *fs_devices_ret = fs_devices;
516 return 0; 526
527 return ret;
517} 528}
518 529
519static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) 530static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
@@ -910,17 +921,19 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
910 transid = btrfs_super_generation(disk_super); 921 transid = btrfs_super_generation(disk_super);
911 total_devices = btrfs_super_num_devices(disk_super); 922 total_devices = btrfs_super_num_devices(disk_super);
912 923
913 if (disk_super->label[0]) {
914 if (disk_super->label[BTRFS_LABEL_SIZE - 1])
915 disk_super->label[BTRFS_LABEL_SIZE - 1] = '\0';
916 printk(KERN_INFO "BTRFS: device label %s ", disk_super->label);
917 } else {
918 printk(KERN_INFO "BTRFS: device fsid %pU ", disk_super->fsid);
919 }
920
921 printk(KERN_CONT "devid %llu transid %llu %s\n", devid, transid, path);
922
923 ret = device_list_add(path, disk_super, devid, fs_devices_ret); 924 ret = device_list_add(path, disk_super, devid, fs_devices_ret);
925 if (ret > 0) {
926 if (disk_super->label[0]) {
927 if (disk_super->label[BTRFS_LABEL_SIZE - 1])
928 disk_super->label[BTRFS_LABEL_SIZE - 1] = '\0';
929 printk(KERN_INFO "BTRFS: device label %s ", disk_super->label);
930 } else {
931 printk(KERN_INFO "BTRFS: device fsid %pU ", disk_super->fsid);
932 }
933
934 printk(KERN_CONT "devid %llu transid %llu %s\n", devid, transid, path);
935 ret = 0;
936 }
924 if (!ret && fs_devices_ret) 937 if (!ret && fs_devices_ret)
925 (*fs_devices_ret)->total_devices = total_devices; 938 (*fs_devices_ret)->total_devices = total_devices;
926 939
diff --git a/fs/buffer.c b/fs/buffer.c
index 8c53a2b15ecb..9ddb9fc7d923 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2114,8 +2114,8 @@ EXPORT_SYMBOL(generic_write_end);
2114 * Returns true if all buffers which correspond to a file portion 2114 * Returns true if all buffers which correspond to a file portion
2115 * we want to read are uptodate. 2115 * we want to read are uptodate.
2116 */ 2116 */
2117int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc, 2117int block_is_partially_uptodate(struct page *page, unsigned long from,
2118 unsigned long from) 2118 unsigned long count)
2119{ 2119{
2120 unsigned block_start, block_end, blocksize; 2120 unsigned block_start, block_end, blocksize;
2121 unsigned to; 2121 unsigned to;
@@ -2127,7 +2127,7 @@ int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
2127 2127
2128 head = page_buffers(page); 2128 head = page_buffers(page);
2129 blocksize = head->b_size; 2129 blocksize = head->b_size;
2130 to = min_t(unsigned, PAGE_CACHE_SIZE - from, desc->count); 2130 to = min_t(unsigned, PAGE_CACHE_SIZE - from, count);
2131 to = from + to; 2131 to = from + to;
2132 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize) 2132 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize)
2133 return 0; 2133 return 0;
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
index 622f4696e484..5b99bafc31d1 100644
--- a/fs/cachefiles/bind.c
+++ b/fs/cachefiles/bind.c
@@ -124,7 +124,6 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
124 /* check parameters */ 124 /* check parameters */
125 ret = -EOPNOTSUPP; 125 ret = -EOPNOTSUPP;
126 if (!root->d_inode || 126 if (!root->d_inode ||
127 !root->d_inode->i_op ||
128 !root->d_inode->i_op->lookup || 127 !root->d_inode->i_op->lookup ||
129 !root->d_inode->i_op->mkdir || 128 !root->d_inode->i_op->mkdir ||
130 !root->d_inode->i_op->setxattr || 129 !root->d_inode->i_op->setxattr ||
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 6494d9f673aa..c0a681705104 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -779,8 +779,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
779 } 779 }
780 780
781 ret = -EPERM; 781 ret = -EPERM;
782 if (!subdir->d_inode->i_op || 782 if (!subdir->d_inode->i_op->setxattr ||
783 !subdir->d_inode->i_op->setxattr ||
784 !subdir->d_inode->i_op->getxattr || 783 !subdir->d_inode->i_op->getxattr ||
785 !subdir->d_inode->i_op->lookup || 784 !subdir->d_inode->i_op->lookup ||
786 !subdir->d_inode->i_op->mkdir || 785 !subdir->d_inode->i_op->mkdir ||
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 66075a4ad979..39da1c2efa50 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -601,7 +601,7 @@ ceph_sync_direct_write(struct kiocb *iocb, const struct iovec *iov,
601 false); 601 false);
602 if (IS_ERR(req)) { 602 if (IS_ERR(req)) {
603 ret = PTR_ERR(req); 603 ret = PTR_ERR(req);
604 goto out; 604 break;
605 } 605 }
606 606
607 num_pages = calc_pages_for(page_align, len); 607 num_pages = calc_pages_for(page_align, len);
@@ -719,7 +719,7 @@ static ssize_t ceph_sync_write(struct kiocb *iocb, const struct iovec *iov,
719 false); 719 false);
720 if (IS_ERR(req)) { 720 if (IS_ERR(req)) {
721 ret = PTR_ERR(req); 721 ret = PTR_ERR(req);
722 goto out; 722 break;
723 } 723 }
724 724
725 /* 725 /*
@@ -972,6 +972,7 @@ retry_snap:
972 } 972 }
973 } else { 973 } else {
974 loff_t old_size = inode->i_size; 974 loff_t old_size = inode->i_size;
975 struct iov_iter from;
975 /* 976 /*
976 * No need to acquire the i_truncate_mutex. Because 977 * No need to acquire the i_truncate_mutex. Because
977 * the MDS revokes Fwb caps before sending truncate 978 * the MDS revokes Fwb caps before sending truncate
@@ -979,9 +980,10 @@ retry_snap:
979 * are pending vmtruncate. So write and vmtruncate 980 * are pending vmtruncate. So write and vmtruncate
980 * can not run at the same time 981 * can not run at the same time
981 */ 982 */
982 written = generic_file_buffered_write(iocb, iov, nr_segs, 983 iov_iter_init(&from, iov, nr_segs, count, 0);
983 pos, &iocb->ki_pos, 984 written = generic_perform_write(file, &from, pos);
984 count, 0); 985 if (likely(written >= 0))
986 iocb->ki_pos = pos + written;
985 if (inode->i_size > old_size) 987 if (inode->i_size > old_size)
986 ceph_fscache_update_objectsize(inode); 988 ceph_fscache_update_objectsize(inode);
987 mutex_unlock(&inode->i_mutex); 989 mutex_unlock(&inode->i_mutex);
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index efbe08289292..fdf941b44ff1 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -1,9 +1,8 @@
1#include <linux/ceph/ceph_debug.h>
1#include <linux/in.h> 2#include <linux/in.h>
2 3
3#include "super.h" 4#include "super.h"
4#include "mds_client.h" 5#include "mds_client.h"
5#include <linux/ceph/ceph_debug.h>
6
7#include "ioctl.h" 6#include "ioctl.h"
8 7
9 8
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2c70cbe35d39..df9c9141c099 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -850,7 +850,6 @@ const struct inode_operations cifs_file_inode_ops = {
850/* revalidate:cifs_revalidate, */ 850/* revalidate:cifs_revalidate, */
851 .setattr = cifs_setattr, 851 .setattr = cifs_setattr,
852 .getattr = cifs_getattr, /* do we need this anymore? */ 852 .getattr = cifs_getattr, /* do we need this anymore? */
853 .rename = cifs_rename,
854 .permission = cifs_permission, 853 .permission = cifs_permission,
855#ifdef CONFIG_CIFS_XATTR 854#ifdef CONFIG_CIFS_XATTR
856 .setxattr = cifs_setxattr, 855 .setxattr = cifs_setxattr,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 216d7e99f921..8807442c94dd 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2579,19 +2579,32 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
2579 struct cifsInodeInfo *cinode = CIFS_I(inode); 2579 struct cifsInodeInfo *cinode = CIFS_I(inode);
2580 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; 2580 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
2581 ssize_t rc = -EACCES; 2581 ssize_t rc = -EACCES;
2582 loff_t lock_pos = pos; 2582 loff_t lock_pos = iocb->ki_pos;
2583 2583
2584 if (file->f_flags & O_APPEND)
2585 lock_pos = i_size_read(inode);
2586 /* 2584 /*
2587 * We need to hold the sem to be sure nobody modifies lock list 2585 * We need to hold the sem to be sure nobody modifies lock list
2588 * with a brlock that prevents writing. 2586 * with a brlock that prevents writing.
2589 */ 2587 */
2590 down_read(&cinode->lock_sem); 2588 down_read(&cinode->lock_sem);
2589 mutex_lock(&inode->i_mutex);
2590 if (file->f_flags & O_APPEND)
2591 lock_pos = i_size_read(inode);
2591 if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs), 2592 if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs),
2592 server->vals->exclusive_lock_type, NULL, 2593 server->vals->exclusive_lock_type, NULL,
2593 CIFS_WRITE_OP)) 2594 CIFS_WRITE_OP)) {
2594 rc = generic_file_aio_write(iocb, iov, nr_segs, pos); 2595 rc = __generic_file_aio_write(iocb, iov, nr_segs);
2596 mutex_unlock(&inode->i_mutex);
2597
2598 if (rc > 0) {
2599 ssize_t err;
2600
2601 err = generic_write_sync(file, iocb->ki_pos - rc, rc);
2602 if (rc < 0)
2603 rc = err;
2604 }
2605 } else {
2606 mutex_unlock(&inode->i_mutex);
2607 }
2595 up_read(&cinode->lock_sem); 2608 up_read(&cinode->lock_sem);
2596 return rc; 2609 return rc;
2597} 2610}
@@ -2727,56 +2740,27 @@ cifs_retry_async_readv(struct cifs_readdata *rdata)
2727/** 2740/**
2728 * cifs_readdata_to_iov - copy data from pages in response to an iovec 2741 * cifs_readdata_to_iov - copy data from pages in response to an iovec
2729 * @rdata: the readdata response with list of pages holding data 2742 * @rdata: the readdata response with list of pages holding data
2730 * @iov: vector in which we should copy the data 2743 * @iter: destination for our data
2731 * @nr_segs: number of segments in vector
2732 * @offset: offset into file of the first iovec
2733 * @copied: used to return the amount of data copied to the iov
2734 * 2744 *
2735 * This function copies data from a list of pages in a readdata response into 2745 * This function copies data from a list of pages in a readdata response into
2736 * an array of iovecs. It will first calculate where the data should go 2746 * an array of iovecs. It will first calculate where the data should go
2737 * based on the info in the readdata and then copy the data into that spot. 2747 * based on the info in the readdata and then copy the data into that spot.
2738 */ 2748 */
2739static ssize_t 2749static int
2740cifs_readdata_to_iov(struct cifs_readdata *rdata, const struct iovec *iov, 2750cifs_readdata_to_iov(struct cifs_readdata *rdata, struct iov_iter *iter)
2741 unsigned long nr_segs, loff_t offset, ssize_t *copied)
2742{ 2751{
2743 int rc = 0; 2752 size_t remaining = rdata->bytes;
2744 struct iov_iter ii;
2745 size_t pos = rdata->offset - offset;
2746 ssize_t remaining = rdata->bytes;
2747 unsigned char *pdata;
2748 unsigned int i; 2753 unsigned int i;
2749 2754
2750 /* set up iov_iter and advance to the correct offset */
2751 iov_iter_init(&ii, iov, nr_segs, iov_length(iov, nr_segs), 0);
2752 iov_iter_advance(&ii, pos);
2753
2754 *copied = 0;
2755 for (i = 0; i < rdata->nr_pages; i++) { 2755 for (i = 0; i < rdata->nr_pages; i++) {
2756 ssize_t copy;
2757 struct page *page = rdata->pages[i]; 2756 struct page *page = rdata->pages[i];
2758 2757 size_t copy = min(remaining, PAGE_SIZE);
2759 /* copy a whole page or whatever's left */ 2758 size_t written = copy_page_to_iter(page, 0, copy, iter);
2760 copy = min_t(ssize_t, remaining, PAGE_SIZE); 2759 remaining -= written;
2761 2760 if (written < copy && iov_iter_count(iter) > 0)
2762 /* ...but limit it to whatever space is left in the iov */ 2761 break;
2763 copy = min_t(ssize_t, copy, iov_iter_count(&ii));
2764
2765 /* go while there's data to be copied and no errors */
2766 if (copy && !rc) {
2767 pdata = kmap(page);
2768 rc = memcpy_toiovecend(ii.iov, pdata, ii.iov_offset,
2769 (int)copy);
2770 kunmap(page);
2771 if (!rc) {
2772 *copied += copy;
2773 remaining -= copy;
2774 iov_iter_advance(&ii, copy);
2775 }
2776 }
2777 } 2762 }
2778 2763 return remaining ? -EFAULT : 0;
2779 return rc;
2780} 2764}
2781 2765
2782static void 2766static void
@@ -2837,20 +2821,21 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server,
2837 return total_read > 0 ? total_read : result; 2821 return total_read > 0 ? total_read : result;
2838} 2822}
2839 2823
2840static ssize_t 2824ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov,
2841cifs_iovec_read(struct file *file, const struct iovec *iov, 2825 unsigned long nr_segs, loff_t pos)
2842 unsigned long nr_segs, loff_t *poffset)
2843{ 2826{
2827 struct file *file = iocb->ki_filp;
2844 ssize_t rc; 2828 ssize_t rc;
2845 size_t len, cur_len; 2829 size_t len, cur_len;
2846 ssize_t total_read = 0; 2830 ssize_t total_read = 0;
2847 loff_t offset = *poffset; 2831 loff_t offset = pos;
2848 unsigned int npages; 2832 unsigned int npages;
2849 struct cifs_sb_info *cifs_sb; 2833 struct cifs_sb_info *cifs_sb;
2850 struct cifs_tcon *tcon; 2834 struct cifs_tcon *tcon;
2851 struct cifsFileInfo *open_file; 2835 struct cifsFileInfo *open_file;
2852 struct cifs_readdata *rdata, *tmp; 2836 struct cifs_readdata *rdata, *tmp;
2853 struct list_head rdata_list; 2837 struct list_head rdata_list;
2838 struct iov_iter to;
2854 pid_t pid; 2839 pid_t pid;
2855 2840
2856 if (!nr_segs) 2841 if (!nr_segs)
@@ -2860,6 +2845,8 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
2860 if (!len) 2845 if (!len)
2861 return 0; 2846 return 0;
2862 2847
2848 iov_iter_init(&to, iov, nr_segs, len, 0);
2849
2863 INIT_LIST_HEAD(&rdata_list); 2850 INIT_LIST_HEAD(&rdata_list);
2864 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2851 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
2865 open_file = file->private_data; 2852 open_file = file->private_data;
@@ -2917,55 +2904,44 @@ error:
2917 if (!list_empty(&rdata_list)) 2904 if (!list_empty(&rdata_list))
2918 rc = 0; 2905 rc = 0;
2919 2906
2907 len = iov_iter_count(&to);
2920 /* the loop below should proceed in the order of increasing offsets */ 2908 /* the loop below should proceed in the order of increasing offsets */
2921restart_loop:
2922 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { 2909 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) {
2910 again:
2923 if (!rc) { 2911 if (!rc) {
2924 ssize_t copied;
2925
2926 /* FIXME: freezable sleep too? */ 2912 /* FIXME: freezable sleep too? */
2927 rc = wait_for_completion_killable(&rdata->done); 2913 rc = wait_for_completion_killable(&rdata->done);
2928 if (rc) 2914 if (rc)
2929 rc = -EINTR; 2915 rc = -EINTR;
2930 else if (rdata->result) 2916 else if (rdata->result) {
2931 rc = rdata->result; 2917 rc = rdata->result;
2932 else { 2918 /* resend call if it's a retryable error */
2933 rc = cifs_readdata_to_iov(rdata, iov, 2919 if (rc == -EAGAIN) {
2934 nr_segs, *poffset, 2920 rc = cifs_retry_async_readv(rdata);
2935 &copied); 2921 goto again;
2936 total_read += copied; 2922 }
2923 } else {
2924 rc = cifs_readdata_to_iov(rdata, &to);
2937 } 2925 }
2938 2926
2939 /* resend call if it's a retryable error */
2940 if (rc == -EAGAIN) {
2941 rc = cifs_retry_async_readv(rdata);
2942 goto restart_loop;
2943 }
2944 } 2927 }
2945 list_del_init(&rdata->list); 2928 list_del_init(&rdata->list);
2946 kref_put(&rdata->refcount, cifs_uncached_readdata_release); 2929 kref_put(&rdata->refcount, cifs_uncached_readdata_release);
2947 } 2930 }
2948 2931
2932 total_read = len - iov_iter_count(&to);
2933
2949 cifs_stats_bytes_read(tcon, total_read); 2934 cifs_stats_bytes_read(tcon, total_read);
2950 *poffset += total_read;
2951 2935
2952 /* mask nodata case */ 2936 /* mask nodata case */
2953 if (rc == -ENODATA) 2937 if (rc == -ENODATA)
2954 rc = 0; 2938 rc = 0;
2955 2939
2956 return total_read ? total_read : rc; 2940 if (total_read) {
2957} 2941 iocb->ki_pos = pos + total_read;
2958 2942 return total_read;
2959ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov, 2943 }
2960 unsigned long nr_segs, loff_t pos) 2944 return rc;
2961{
2962 ssize_t read;
2963
2964 read = cifs_iovec_read(iocb->ki_filp, iov, nr_segs, &pos);
2965 if (read > 0)
2966 iocb->ki_pos = pos;
2967
2968 return read;
2969} 2945}
2970 2946
2971ssize_t 2947ssize_t
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 3190ca973dd6..1e5b45359509 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -424,7 +424,7 @@ int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
424} 424}
425 425
426/* Data available on socket or listen socket received a connect */ 426/* Data available on socket or listen socket received a connect */
427static void lowcomms_data_ready(struct sock *sk, int count_unused) 427static void lowcomms_data_ready(struct sock *sk)
428{ 428{
429 struct connection *con = sock2con(sk); 429 struct connection *con = sock2con(sk);
430 if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags)) 430 if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags))
diff --git a/fs/exec.c b/fs/exec.c
index 9e81c630dfa7..476f3ebf437e 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -813,7 +813,7 @@ EXPORT_SYMBOL(kernel_read);
813 813
814ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) 814ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len)
815{ 815{
816 ssize_t res = file->f_op->read(file, (void __user *)addr, len, &pos); 816 ssize_t res = vfs_read(file, (void __user *)addr, len, &pos);
817 if (res > 0) 817 if (res > 0)
818 flush_icache_range(addr, addr + len); 818 flush_icache_range(addr, addr + len);
819 return res; 819 return res;
diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index 7682b970d0f1..4e2c032ab8a1 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -21,12 +21,12 @@
21#undef ORE_DBGMSG2 21#undef ORE_DBGMSG2
22#define ORE_DBGMSG2 ORE_DBGMSG 22#define ORE_DBGMSG2 ORE_DBGMSG
23 23
24struct page *_raid_page_alloc(void) 24static struct page *_raid_page_alloc(void)
25{ 25{
26 return alloc_page(GFP_KERNEL); 26 return alloc_page(GFP_KERNEL);
27} 27}
28 28
29void _raid_page_free(struct page *p) 29static void _raid_page_free(struct page *p)
30{ 30{
31 __free_page(p); 31 __free_page(p);
32} 32}
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 9d9763328734..ed73ed8ebbee 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -543,7 +543,7 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev,
543 return !(odi->systemid_len || odi->osdname_len); 543 return !(odi->systemid_len || odi->osdname_len);
544} 544}
545 545
546int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs, 546static int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs,
547 struct exofs_dev **peds) 547 struct exofs_dev **peds)
548{ 548{
549 struct __alloc_ore_devs_and_exofs_devs { 549 struct __alloc_ore_devs_and_exofs_devs {
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 4e508fc83dcf..ca7502d89fde 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -146,7 +146,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov,
146 overwrite = 1; 146 overwrite = 1;
147 } 147 }
148 148
149 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 149 ret = __generic_file_aio_write(iocb, iov, nr_segs);
150 mutex_unlock(&inode->i_mutex); 150 mutex_unlock(&inode->i_mutex);
151 151
152 if (ret > 0) { 152 if (ret > 0) {
diff --git a/fs/file.c b/fs/file.c
index b61293badfb1..8f294cfac697 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -25,7 +25,10 @@
25 25
26int sysctl_nr_open __read_mostly = 1024*1024; 26int sysctl_nr_open __read_mostly = 1024*1024;
27int sysctl_nr_open_min = BITS_PER_LONG; 27int sysctl_nr_open_min = BITS_PER_LONG;
28int sysctl_nr_open_max = 1024 * 1024; /* raised later */ 28/* our max() is unusable in constant expressions ;-/ */
29#define __const_max(x, y) ((x) < (y) ? (x) : (y))
30int sysctl_nr_open_max = __const_max(INT_MAX, ~(size_t)0/sizeof(void *)) &
31 -BITS_PER_LONG;
29 32
30static void *alloc_fdmem(size_t size) 33static void *alloc_fdmem(size_t size)
31{ 34{
@@ -429,12 +432,6 @@ void exit_files(struct task_struct *tsk)
429 } 432 }
430} 433}
431 434
432void __init files_defer_init(void)
433{
434 sysctl_nr_open_max = min((size_t)INT_MAX, ~(size_t)0/sizeof(void *)) &
435 -BITS_PER_LONG;
436}
437
438struct files_struct init_files = { 435struct files_struct init_files = {
439 .count = ATOMIC_INIT(1), 436 .count = ATOMIC_INIT(1),
440 .fdt = &init_files.fdtab, 437 .fdt = &init_files.fdtab,
diff --git a/fs/file_table.c b/fs/file_table.c
index 01071c4d752e..a374f5033e97 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -52,7 +52,6 @@ static void file_free_rcu(struct rcu_head *head)
52static inline void file_free(struct file *f) 52static inline void file_free(struct file *f)
53{ 53{
54 percpu_counter_dec(&nr_files); 54 percpu_counter_dec(&nr_files);
55 file_check_state(f);
56 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); 55 call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
57} 56}
58 57
@@ -178,47 +177,12 @@ struct file *alloc_file(struct path *path, fmode_t mode,
178 file->f_mapping = path->dentry->d_inode->i_mapping; 177 file->f_mapping = path->dentry->d_inode->i_mapping;
179 file->f_mode = mode; 178 file->f_mode = mode;
180 file->f_op = fop; 179 file->f_op = fop;
181
182 /*
183 * These mounts don't really matter in practice
184 * for r/o bind mounts. They aren't userspace-
185 * visible. We do this for consistency, and so
186 * that we can do debugging checks at __fput()
187 */
188 if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) {
189 file_take_write(file);
190 WARN_ON(mnt_clone_write(path->mnt));
191 }
192 if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 180 if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
193 i_readcount_inc(path->dentry->d_inode); 181 i_readcount_inc(path->dentry->d_inode);
194 return file; 182 return file;
195} 183}
196EXPORT_SYMBOL(alloc_file); 184EXPORT_SYMBOL(alloc_file);
197 185
198/**
199 * drop_file_write_access - give up ability to write to a file
200 * @file: the file to which we will stop writing
201 *
202 * This is a central place which will give up the ability
203 * to write to @file, along with access to write through
204 * its vfsmount.
205 */
206static void drop_file_write_access(struct file *file)
207{
208 struct vfsmount *mnt = file->f_path.mnt;
209 struct dentry *dentry = file->f_path.dentry;
210 struct inode *inode = dentry->d_inode;
211
212 put_write_access(inode);
213
214 if (special_file(inode->i_mode))
215 return;
216 if (file_check_writeable(file) != 0)
217 return;
218 __mnt_drop_write(mnt);
219 file_release_write(file);
220}
221
222/* the real guts of fput() - releasing the last reference to file 186/* the real guts of fput() - releasing the last reference to file
223 */ 187 */
224static void __fput(struct file *file) 188static void __fput(struct file *file)
@@ -253,8 +217,10 @@ static void __fput(struct file *file)
253 put_pid(file->f_owner.pid); 217 put_pid(file->f_owner.pid);
254 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 218 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
255 i_readcount_dec(inode); 219 i_readcount_dec(inode);
256 if (file->f_mode & FMODE_WRITE) 220 if (file->f_mode & FMODE_WRITER) {
257 drop_file_write_access(file); 221 put_write_access(inode);
222 __mnt_drop_write(mnt);
223 }
258 file->f_path.dentry = NULL; 224 file->f_path.dentry = NULL;
259 file->f_path.mnt = NULL; 225 file->f_path.mnt = NULL;
260 file->f_inode = NULL; 226 file->f_inode = NULL;
@@ -359,6 +325,5 @@ void __init files_init(unsigned long mempages)
359 325
360 n = (mempages * (PAGE_SIZE / 1024)) / 10; 326 n = (mempages * (PAGE_SIZE / 1024)) / 10;
361 files_stat.max_files = max_t(unsigned long, n, NR_FILE); 327 files_stat.max_files = max_t(unsigned long, n, NR_FILE);
362 files_defer_init();
363 percpu_counter_init(&nr_files, 0); 328 percpu_counter_init(&nr_files, 0);
364} 329}
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 0a648bb455ae..aac71ce373e4 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -667,15 +667,15 @@ static void fuse_copy_finish(struct fuse_copy_state *cs)
667 struct pipe_buffer *buf = cs->currbuf; 667 struct pipe_buffer *buf = cs->currbuf;
668 668
669 if (!cs->write) { 669 if (!cs->write) {
670 buf->ops->unmap(cs->pipe, buf, cs->mapaddr); 670 kunmap_atomic(cs->mapaddr);
671 } else { 671 } else {
672 kunmap(buf->page); 672 kunmap_atomic(cs->mapaddr);
673 buf->len = PAGE_SIZE - cs->len; 673 buf->len = PAGE_SIZE - cs->len;
674 } 674 }
675 cs->currbuf = NULL; 675 cs->currbuf = NULL;
676 cs->mapaddr = NULL; 676 cs->mapaddr = NULL;
677 } else if (cs->mapaddr) { 677 } else if (cs->mapaddr) {
678 kunmap(cs->pg); 678 kunmap_atomic(cs->mapaddr);
679 if (cs->write) { 679 if (cs->write) {
680 flush_dcache_page(cs->pg); 680 flush_dcache_page(cs->pg);
681 set_page_dirty_lock(cs->pg); 681 set_page_dirty_lock(cs->pg);
@@ -706,7 +706,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
706 706
707 BUG_ON(!cs->nr_segs); 707 BUG_ON(!cs->nr_segs);
708 cs->currbuf = buf; 708 cs->currbuf = buf;
709 cs->mapaddr = buf->ops->map(cs->pipe, buf, 0); 709 cs->mapaddr = kmap_atomic(buf->page);
710 cs->len = buf->len; 710 cs->len = buf->len;
711 cs->buf = cs->mapaddr + buf->offset; 711 cs->buf = cs->mapaddr + buf->offset;
712 cs->pipebufs++; 712 cs->pipebufs++;
@@ -726,7 +726,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
726 buf->len = 0; 726 buf->len = 0;
727 727
728 cs->currbuf = buf; 728 cs->currbuf = buf;
729 cs->mapaddr = kmap(page); 729 cs->mapaddr = kmap_atomic(page);
730 cs->buf = cs->mapaddr; 730 cs->buf = cs->mapaddr;
731 cs->len = PAGE_SIZE; 731 cs->len = PAGE_SIZE;
732 cs->pipebufs++; 732 cs->pipebufs++;
@@ -745,7 +745,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs)
745 return err; 745 return err;
746 BUG_ON(err != 1); 746 BUG_ON(err != 1);
747 offset = cs->addr % PAGE_SIZE; 747 offset = cs->addr % PAGE_SIZE;
748 cs->mapaddr = kmap(cs->pg); 748 cs->mapaddr = kmap_atomic(cs->pg);
749 cs->buf = cs->mapaddr + offset; 749 cs->buf = cs->mapaddr + offset;
750 cs->len = min(PAGE_SIZE - offset, cs->seglen); 750 cs->len = min(PAGE_SIZE - offset, cs->seglen);
751 cs->seglen -= cs->len; 751 cs->seglen -= cs->len;
@@ -874,7 +874,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
874out_fallback_unlock: 874out_fallback_unlock:
875 unlock_page(newpage); 875 unlock_page(newpage);
876out_fallback: 876out_fallback:
877 cs->mapaddr = buf->ops->map(cs->pipe, buf, 1); 877 cs->mapaddr = kmap_atomic(buf->page);
878 cs->buf = cs->mapaddr + buf->offset; 878 cs->buf = cs->mapaddr + buf->offset;
879 879
880 err = lock_request(cs->fc, cs->req); 880 err = lock_request(cs->fc, cs->req);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 48992cac714b..13f8bdec5110 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1086,9 +1086,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
1086 if (mapping_writably_mapped(mapping)) 1086 if (mapping_writably_mapped(mapping))
1087 flush_dcache_page(page); 1087 flush_dcache_page(page);
1088 1088
1089 pagefault_disable();
1090 tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes); 1089 tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
1091 pagefault_enable();
1092 flush_dcache_page(page); 1090 flush_dcache_page(page);
1093 1091
1094 mark_page_accessed(page); 1092 mark_page_accessed(page);
@@ -1237,8 +1235,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
1237 goto out; 1235 goto out;
1238 1236
1239 if (file->f_flags & O_DIRECT) { 1237 if (file->f_flags & O_DIRECT) {
1240 written = generic_file_direct_write(iocb, iov, &nr_segs, 1238 written = generic_file_direct_write(iocb, iov, &nr_segs, pos,
1241 pos, &iocb->ki_pos,
1242 count, ocount); 1239 count, ocount);
1243 if (written < 0 || written == count) 1240 if (written < 0 || written == count)
1244 goto out; 1241 goto out;
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 10d6c41aecad..6bf06a07f3e0 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -235,6 +235,7 @@ out_err:
235 if (warned++ == 0) 235 if (warned++ == 0)
236 printk(KERN_WARNING 236 printk(KERN_WARNING
237 "lockd_up: makesock failed, error=%d\n", err); 237 "lockd_up: makesock failed, error=%d\n", err);
238 svc_shutdown_net(serv, net);
238 return err; 239 return err;
239} 240}
240 241
diff --git a/fs/mount.h b/fs/mount.h
index b29e42f05f34..d55297f2fa05 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -10,7 +10,7 @@ struct mnt_namespace {
10 struct user_namespace *user_ns; 10 struct user_namespace *user_ns;
11 u64 seq; /* Sequence number to prevent loops */ 11 u64 seq; /* Sequence number to prevent loops */
12 wait_queue_head_t poll; 12 wait_queue_head_t poll;
13 int event; 13 u64 event;
14}; 14};
15 15
16struct mnt_pcp { 16struct mnt_pcp {
@@ -104,6 +104,9 @@ struct proc_mounts {
104 struct mnt_namespace *ns; 104 struct mnt_namespace *ns;
105 struct path root; 105 struct path root;
106 int (*show)(struct seq_file *, struct vfsmount *); 106 int (*show)(struct seq_file *, struct vfsmount *);
107 void *cached_mount;
108 u64 cached_event;
109 loff_t cached_index;
107}; 110};
108 111
109#define proc_mounts(p) (container_of((p), struct proc_mounts, m)) 112#define proc_mounts(p) (container_of((p), struct proc_mounts, m))
diff --git a/fs/namei.c b/fs/namei.c
index 88339f59efb5..c6157c894fce 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -358,6 +358,7 @@ int generic_permission(struct inode *inode, int mask)
358 358
359 return -EACCES; 359 return -EACCES;
360} 360}
361EXPORT_SYMBOL(generic_permission);
361 362
362/* 363/*
363 * We _really_ want to just do "generic_permission()" without 364 * We _really_ want to just do "generic_permission()" without
@@ -455,6 +456,7 @@ int inode_permission(struct inode *inode, int mask)
455 return retval; 456 return retval;
456 return __inode_permission(inode, mask); 457 return __inode_permission(inode, mask);
457} 458}
459EXPORT_SYMBOL(inode_permission);
458 460
459/** 461/**
460 * path_get - get a reference to a path 462 * path_get - get a reference to a path
@@ -924,6 +926,7 @@ int follow_up(struct path *path)
924 path->mnt = &parent->mnt; 926 path->mnt = &parent->mnt;
925 return 1; 927 return 1;
926} 928}
929EXPORT_SYMBOL(follow_up);
927 930
928/* 931/*
929 * Perform an automount 932 * Perform an automount
@@ -1085,6 +1088,7 @@ int follow_down_one(struct path *path)
1085 } 1088 }
1086 return 0; 1089 return 0;
1087} 1090}
1091EXPORT_SYMBOL(follow_down_one);
1088 1092
1089static inline bool managed_dentry_might_block(struct dentry *dentry) 1093static inline bool managed_dentry_might_block(struct dentry *dentry)
1090{ 1094{
@@ -1223,6 +1227,7 @@ int follow_down(struct path *path)
1223 } 1227 }
1224 return 0; 1228 return 0;
1225} 1229}
1230EXPORT_SYMBOL(follow_down);
1226 1231
1227/* 1232/*
1228 * Skip to top of mountpoint pile in refwalk mode for follow_dotdot() 1233 * Skip to top of mountpoint pile in refwalk mode for follow_dotdot()
@@ -2025,6 +2030,7 @@ int kern_path(const char *name, unsigned int flags, struct path *path)
2025 *path = nd.path; 2030 *path = nd.path;
2026 return res; 2031 return res;
2027} 2032}
2033EXPORT_SYMBOL(kern_path);
2028 2034
2029/** 2035/**
2030 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair 2036 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
@@ -2049,6 +2055,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
2049 *path = nd.path; 2055 *path = nd.path;
2050 return err; 2056 return err;
2051} 2057}
2058EXPORT_SYMBOL(vfs_path_lookup);
2052 2059
2053/* 2060/*
2054 * Restricted form of lookup. Doesn't follow links, single-component only, 2061 * Restricted form of lookup. Doesn't follow links, single-component only,
@@ -2111,6 +2118,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
2111 2118
2112 return __lookup_hash(&this, base, 0); 2119 return __lookup_hash(&this, base, 0);
2113} 2120}
2121EXPORT_SYMBOL(lookup_one_len);
2114 2122
2115int user_path_at_empty(int dfd, const char __user *name, unsigned flags, 2123int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
2116 struct path *path, int *empty) 2124 struct path *path, int *empty)
@@ -2135,6 +2143,7 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
2135{ 2143{
2136 return user_path_at_empty(dfd, name, flags, path, NULL); 2144 return user_path_at_empty(dfd, name, flags, path, NULL);
2137} 2145}
2146EXPORT_SYMBOL(user_path_at);
2138 2147
2139/* 2148/*
2140 * NB: most callers don't do anything directly with the reference to the 2149 * NB: most callers don't do anything directly with the reference to the
@@ -2477,6 +2486,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
2477 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2486 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
2478 return NULL; 2487 return NULL;
2479} 2488}
2489EXPORT_SYMBOL(lock_rename);
2480 2490
2481void unlock_rename(struct dentry *p1, struct dentry *p2) 2491void unlock_rename(struct dentry *p1, struct dentry *p2)
2482{ 2492{
@@ -2486,6 +2496,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
2486 mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex); 2496 mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
2487 } 2497 }
2488} 2498}
2499EXPORT_SYMBOL(unlock_rename);
2489 2500
2490int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 2501int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2491 bool want_excl) 2502 bool want_excl)
@@ -2506,6 +2517,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2506 fsnotify_create(dir, dentry); 2517 fsnotify_create(dir, dentry);
2507 return error; 2518 return error;
2508} 2519}
2520EXPORT_SYMBOL(vfs_create);
2509 2521
2510static int may_open(struct path *path, int acc_mode, int flag) 2522static int may_open(struct path *path, int acc_mode, int flag)
2511{ 2523{
@@ -3375,6 +3387,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
3375 fsnotify_create(dir, dentry); 3387 fsnotify_create(dir, dentry);
3376 return error; 3388 return error;
3377} 3389}
3390EXPORT_SYMBOL(vfs_mknod);
3378 3391
3379static int may_mknod(umode_t mode) 3392static int may_mknod(umode_t mode)
3380{ 3393{
@@ -3464,6 +3477,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
3464 fsnotify_mkdir(dir, dentry); 3477 fsnotify_mkdir(dir, dentry);
3465 return error; 3478 return error;
3466} 3479}
3480EXPORT_SYMBOL(vfs_mkdir);
3467 3481
3468SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) 3482SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
3469{ 3483{
@@ -3518,6 +3532,7 @@ void dentry_unhash(struct dentry *dentry)
3518 __d_drop(dentry); 3532 __d_drop(dentry);
3519 spin_unlock(&dentry->d_lock); 3533 spin_unlock(&dentry->d_lock);
3520} 3534}
3535EXPORT_SYMBOL(dentry_unhash);
3521 3536
3522int vfs_rmdir(struct inode *dir, struct dentry *dentry) 3537int vfs_rmdir(struct inode *dir, struct dentry *dentry)
3523{ 3538{
@@ -3555,6 +3570,7 @@ out:
3555 d_delete(dentry); 3570 d_delete(dentry);
3556 return error; 3571 return error;
3557} 3572}
3573EXPORT_SYMBOL(vfs_rmdir);
3558 3574
3559static long do_rmdir(int dfd, const char __user *pathname) 3575static long do_rmdir(int dfd, const char __user *pathname)
3560{ 3576{
@@ -3672,6 +3688,7 @@ out:
3672 3688
3673 return error; 3689 return error;
3674} 3690}
3691EXPORT_SYMBOL(vfs_unlink);
3675 3692
3676/* 3693/*
3677 * Make sure that the actual truncation of the file will occur outside its 3694 * Make sure that the actual truncation of the file will occur outside its
@@ -3785,6 +3802,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
3785 fsnotify_create(dir, dentry); 3802 fsnotify_create(dir, dentry);
3786 return error; 3803 return error;
3787} 3804}
3805EXPORT_SYMBOL(vfs_symlink);
3788 3806
3789SYSCALL_DEFINE3(symlinkat, const char __user *, oldname, 3807SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
3790 int, newdfd, const char __user *, newname) 3808 int, newdfd, const char __user *, newname)
@@ -3893,6 +3911,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
3893 fsnotify_link(dir, inode, new_dentry); 3911 fsnotify_link(dir, inode, new_dentry);
3894 return error; 3912 return error;
3895} 3913}
3914EXPORT_SYMBOL(vfs_link);
3896 3915
3897/* 3916/*
3898 * Hardlinks are often used in delicate situations. We avoid 3917 * Hardlinks are often used in delicate situations. We avoid
@@ -4152,6 +4171,7 @@ out:
4152 4171
4153 return error; 4172 return error;
4154} 4173}
4174EXPORT_SYMBOL(vfs_rename);
4155 4175
4156SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, 4176SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname,
4157 int, newdfd, const char __user *, newname, unsigned int, flags) 4177 int, newdfd, const char __user *, newname, unsigned int, flags)
@@ -4304,11 +4324,9 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
4304 return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0); 4324 return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
4305} 4325}
4306 4326
4307int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link) 4327int readlink_copy(char __user *buffer, int buflen, const char *link)
4308{ 4328{
4309 int len; 4329 int len = PTR_ERR(link);
4310
4311 len = PTR_ERR(link);
4312 if (IS_ERR(link)) 4330 if (IS_ERR(link))
4313 goto out; 4331 goto out;
4314 4332
@@ -4320,6 +4338,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
4320out: 4338out:
4321 return len; 4339 return len;
4322} 4340}
4341EXPORT_SYMBOL(readlink_copy);
4323 4342
4324/* 4343/*
4325 * A helper for ->readlink(). This should be used *ONLY* for symlinks that 4344 * A helper for ->readlink(). This should be used *ONLY* for symlinks that
@@ -4337,11 +4356,12 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4337 if (IS_ERR(cookie)) 4356 if (IS_ERR(cookie))
4338 return PTR_ERR(cookie); 4357 return PTR_ERR(cookie);
4339 4358
4340 res = vfs_readlink(dentry, buffer, buflen, nd_get_link(&nd)); 4359 res = readlink_copy(buffer, buflen, nd_get_link(&nd));
4341 if (dentry->d_inode->i_op->put_link) 4360 if (dentry->d_inode->i_op->put_link)
4342 dentry->d_inode->i_op->put_link(dentry, &nd, cookie); 4361 dentry->d_inode->i_op->put_link(dentry, &nd, cookie);
4343 return res; 4362 return res;
4344} 4363}
4364EXPORT_SYMBOL(generic_readlink);
4345 4365
4346/* get the link contents into pagecache */ 4366/* get the link contents into pagecache */
4347static char *page_getlink(struct dentry * dentry, struct page **ppage) 4367static char *page_getlink(struct dentry * dentry, struct page **ppage)
@@ -4361,14 +4381,14 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
4361int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) 4381int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
4362{ 4382{
4363 struct page *page = NULL; 4383 struct page *page = NULL;
4364 char *s = page_getlink(dentry, &page); 4384 int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page));
4365 int res = vfs_readlink(dentry,buffer,buflen,s);
4366 if (page) { 4385 if (page) {
4367 kunmap(page); 4386 kunmap(page);
4368 page_cache_release(page); 4387 page_cache_release(page);
4369 } 4388 }
4370 return res; 4389 return res;
4371} 4390}
4391EXPORT_SYMBOL(page_readlink);
4372 4392
4373void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd) 4393void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
4374{ 4394{
@@ -4376,6 +4396,7 @@ void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
4376 nd_set_link(nd, page_getlink(dentry, &page)); 4396 nd_set_link(nd, page_getlink(dentry, &page));
4377 return page; 4397 return page;
4378} 4398}
4399EXPORT_SYMBOL(page_follow_link_light);
4379 4400
4380void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) 4401void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
4381{ 4402{
@@ -4386,6 +4407,7 @@ void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
4386 page_cache_release(page); 4407 page_cache_release(page);
4387 } 4408 }
4388} 4409}
4410EXPORT_SYMBOL(page_put_link);
4389 4411
4390/* 4412/*
4391 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS 4413 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
@@ -4423,45 +4445,18 @@ retry:
4423fail: 4445fail:
4424 return err; 4446 return err;
4425} 4447}
4448EXPORT_SYMBOL(__page_symlink);
4426 4449
4427int page_symlink(struct inode *inode, const char *symname, int len) 4450int page_symlink(struct inode *inode, const char *symname, int len)
4428{ 4451{
4429 return __page_symlink(inode, symname, len, 4452 return __page_symlink(inode, symname, len,
4430 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS)); 4453 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS));
4431} 4454}
4455EXPORT_SYMBOL(page_symlink);
4432 4456
4433const struct inode_operations page_symlink_inode_operations = { 4457const struct inode_operations page_symlink_inode_operations = {
4434 .readlink = generic_readlink, 4458 .readlink = generic_readlink,
4435 .follow_link = page_follow_link_light, 4459 .follow_link = page_follow_link_light,
4436 .put_link = page_put_link, 4460 .put_link = page_put_link,
4437}; 4461};
4438
4439EXPORT_SYMBOL(user_path_at);
4440EXPORT_SYMBOL(follow_down_one);
4441EXPORT_SYMBOL(follow_down);
4442EXPORT_SYMBOL(follow_up);
4443EXPORT_SYMBOL(get_write_access); /* nfsd */
4444EXPORT_SYMBOL(lock_rename);
4445EXPORT_SYMBOL(lookup_one_len);
4446EXPORT_SYMBOL(page_follow_link_light);
4447EXPORT_SYMBOL(page_put_link);
4448EXPORT_SYMBOL(page_readlink);
4449EXPORT_SYMBOL(__page_symlink);
4450EXPORT_SYMBOL(page_symlink);
4451EXPORT_SYMBOL(page_symlink_inode_operations); 4462EXPORT_SYMBOL(page_symlink_inode_operations);
4452EXPORT_SYMBOL(kern_path);
4453EXPORT_SYMBOL(vfs_path_lookup);
4454EXPORT_SYMBOL(inode_permission);
4455EXPORT_SYMBOL(unlock_rename);
4456EXPORT_SYMBOL(vfs_create);
4457EXPORT_SYMBOL(vfs_link);
4458EXPORT_SYMBOL(vfs_mkdir);
4459EXPORT_SYMBOL(vfs_mknod);
4460EXPORT_SYMBOL(generic_permission);
4461EXPORT_SYMBOL(vfs_readlink);
4462EXPORT_SYMBOL(vfs_rename);
4463EXPORT_SYMBOL(vfs_rmdir);
4464EXPORT_SYMBOL(vfs_symlink);
4465EXPORT_SYMBOL(vfs_unlink);
4466EXPORT_SYMBOL(dentry_unhash);
4467EXPORT_SYMBOL(generic_readlink);
diff --git a/fs/namespace.c b/fs/namespace.c
index 2ffc5a2905d4..182bc41cd887 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -52,7 +52,7 @@ static int __init set_mphash_entries(char *str)
52} 52}
53__setup("mphash_entries=", set_mphash_entries); 53__setup("mphash_entries=", set_mphash_entries);
54 54
55static int event; 55static u64 event;
56static DEFINE_IDA(mnt_id_ida); 56static DEFINE_IDA(mnt_id_ida);
57static DEFINE_IDA(mnt_group_ida); 57static DEFINE_IDA(mnt_group_ida);
58static DEFINE_SPINLOCK(mnt_id_lock); 58static DEFINE_SPINLOCK(mnt_id_lock);
@@ -414,9 +414,7 @@ EXPORT_SYMBOL_GPL(mnt_clone_write);
414 */ 414 */
415int __mnt_want_write_file(struct file *file) 415int __mnt_want_write_file(struct file *file)
416{ 416{
417 struct inode *inode = file_inode(file); 417 if (!(file->f_mode & FMODE_WRITER))
418
419 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode))
420 return __mnt_want_write(file->f_path.mnt); 418 return __mnt_want_write(file->f_path.mnt);
421 else 419 else
422 return mnt_clone_write(file->f_path.mnt); 420 return mnt_clone_write(file->f_path.mnt);
@@ -570,13 +568,17 @@ int sb_prepare_remount_readonly(struct super_block *sb)
570static void free_vfsmnt(struct mount *mnt) 568static void free_vfsmnt(struct mount *mnt)
571{ 569{
572 kfree(mnt->mnt_devname); 570 kfree(mnt->mnt_devname);
573 mnt_free_id(mnt);
574#ifdef CONFIG_SMP 571#ifdef CONFIG_SMP
575 free_percpu(mnt->mnt_pcp); 572 free_percpu(mnt->mnt_pcp);
576#endif 573#endif
577 kmem_cache_free(mnt_cache, mnt); 574 kmem_cache_free(mnt_cache, mnt);
578} 575}
579 576
577static void delayed_free_vfsmnt(struct rcu_head *head)
578{
579 free_vfsmnt(container_of(head, struct mount, mnt_rcu));
580}
581
580/* call under rcu_read_lock */ 582/* call under rcu_read_lock */
581bool legitimize_mnt(struct vfsmount *bastard, unsigned seq) 583bool legitimize_mnt(struct vfsmount *bastard, unsigned seq)
582{ 584{
@@ -848,6 +850,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
848 850
849 root = mount_fs(type, flags, name, data); 851 root = mount_fs(type, flags, name, data);
850 if (IS_ERR(root)) { 852 if (IS_ERR(root)) {
853 mnt_free_id(mnt);
851 free_vfsmnt(mnt); 854 free_vfsmnt(mnt);
852 return ERR_CAST(root); 855 return ERR_CAST(root);
853 } 856 }
@@ -885,7 +888,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
885 goto out_free; 888 goto out_free;
886 } 889 }
887 890
888 mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD; 891 mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~(MNT_WRITE_HOLD|MNT_MARKED);
889 /* Don't allow unprivileged users to change mount flags */ 892 /* Don't allow unprivileged users to change mount flags */
890 if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY)) 893 if ((flag & CL_UNPRIVILEGED) && (mnt->mnt.mnt_flags & MNT_READONLY))
891 mnt->mnt.mnt_flags |= MNT_LOCK_READONLY; 894 mnt->mnt.mnt_flags |= MNT_LOCK_READONLY;
@@ -928,20 +931,11 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
928 return mnt; 931 return mnt;
929 932
930 out_free: 933 out_free:
934 mnt_free_id(mnt);
931 free_vfsmnt(mnt); 935 free_vfsmnt(mnt);
932 return ERR_PTR(err); 936 return ERR_PTR(err);
933} 937}
934 938
935static void delayed_free(struct rcu_head *head)
936{
937 struct mount *mnt = container_of(head, struct mount, mnt_rcu);
938 kfree(mnt->mnt_devname);
939#ifdef CONFIG_SMP
940 free_percpu(mnt->mnt_pcp);
941#endif
942 kmem_cache_free(mnt_cache, mnt);
943}
944
945static void mntput_no_expire(struct mount *mnt) 939static void mntput_no_expire(struct mount *mnt)
946{ 940{
947put_again: 941put_again:
@@ -991,7 +985,7 @@ put_again:
991 dput(mnt->mnt.mnt_root); 985 dput(mnt->mnt.mnt_root);
992 deactivate_super(mnt->mnt.mnt_sb); 986 deactivate_super(mnt->mnt.mnt_sb);
993 mnt_free_id(mnt); 987 mnt_free_id(mnt);
994 call_rcu(&mnt->mnt_rcu, delayed_free); 988 call_rcu(&mnt->mnt_rcu, delayed_free_vfsmnt);
995} 989}
996 990
997void mntput(struct vfsmount *mnt) 991void mntput(struct vfsmount *mnt)
@@ -1100,14 +1094,29 @@ static void *m_start(struct seq_file *m, loff_t *pos)
1100 struct proc_mounts *p = proc_mounts(m); 1094 struct proc_mounts *p = proc_mounts(m);
1101 1095
1102 down_read(&namespace_sem); 1096 down_read(&namespace_sem);
1103 return seq_list_start(&p->ns->list, *pos); 1097 if (p->cached_event == p->ns->event) {
1098 void *v = p->cached_mount;
1099 if (*pos == p->cached_index)
1100 return v;
1101 if (*pos == p->cached_index + 1) {
1102 v = seq_list_next(v, &p->ns->list, &p->cached_index);
1103 return p->cached_mount = v;
1104 }
1105 }
1106
1107 p->cached_event = p->ns->event;
1108 p->cached_mount = seq_list_start(&p->ns->list, *pos);
1109 p->cached_index = *pos;
1110 return p->cached_mount;
1104} 1111}
1105 1112
1106static void *m_next(struct seq_file *m, void *v, loff_t *pos) 1113static void *m_next(struct seq_file *m, void *v, loff_t *pos)
1107{ 1114{
1108 struct proc_mounts *p = proc_mounts(m); 1115 struct proc_mounts *p = proc_mounts(m);
1109 1116
1110 return seq_list_next(v, &p->ns->list, pos); 1117 p->cached_mount = seq_list_next(v, &p->ns->list, pos);
1118 p->cached_index = *pos;
1119 return p->cached_mount;
1111} 1120}
1112 1121
1113static void m_stop(struct seq_file *m, void *v) 1122static void m_stop(struct seq_file *m, void *v)
@@ -1661,9 +1670,9 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1661 if (err) 1670 if (err)
1662 goto out; 1671 goto out;
1663 err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list); 1672 err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list);
1673 lock_mount_hash();
1664 if (err) 1674 if (err)
1665 goto out_cleanup_ids; 1675 goto out_cleanup_ids;
1666 lock_mount_hash();
1667 for (p = source_mnt; p; p = next_mnt(p, source_mnt)) 1676 for (p = source_mnt; p; p = next_mnt(p, source_mnt))
1668 set_mnt_shared(p); 1677 set_mnt_shared(p);
1669 } else { 1678 } else {
@@ -1690,6 +1699,11 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1690 return 0; 1699 return 0;
1691 1700
1692 out_cleanup_ids: 1701 out_cleanup_ids:
1702 while (!hlist_empty(&tree_list)) {
1703 child = hlist_entry(tree_list.first, struct mount, mnt_hash);
1704 umount_tree(child, 0);
1705 }
1706 unlock_mount_hash();
1693 cleanup_group_ids(source_mnt, NULL); 1707 cleanup_group_ids(source_mnt, NULL);
1694 out: 1708 out:
1695 return err; 1709 return err;
@@ -2044,7 +2058,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
2044 struct mount *parent; 2058 struct mount *parent;
2045 int err; 2059 int err;
2046 2060
2047 mnt_flags &= ~(MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | MNT_DOOMED | MNT_SYNC_UMOUNT); 2061 mnt_flags &= ~MNT_INTERNAL_FLAGS;
2048 2062
2049 mp = lock_mount(path); 2063 mp = lock_mount(path);
2050 if (IS_ERR(mp)) 2064 if (IS_ERR(mp))
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index c320ac52353e..08b8ea8c353e 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -339,7 +339,7 @@ ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
339 if (val) 339 if (val)
340 goto finished; 340 goto finished;
341 341
342 DDPRINTK("ncp_lookup_validate: %pd2 not valid, age=%ld, server lookup\n", 342 ncp_dbg(2, "%pd2 not valid, age=%ld, server lookup\n",
343 dentry, NCP_GET_AGE(dentry)); 343 dentry, NCP_GET_AGE(dentry));
344 344
345 len = sizeof(__name); 345 len = sizeof(__name);
@@ -358,7 +358,7 @@ ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
358 res = ncp_obtain_info(server, dir, __name, &(finfo.i)); 358 res = ncp_obtain_info(server, dir, __name, &(finfo.i));
359 } 359 }
360 finfo.volume = finfo.i.volNumber; 360 finfo.volume = finfo.i.volNumber;
361 DDPRINTK("ncp_lookup_validate: looked for %pd/%s, res=%d\n", 361 ncp_dbg(2, "looked for %pd/%s, res=%d\n",
362 dentry->d_parent, __name, res); 362 dentry->d_parent, __name, res);
363 /* 363 /*
364 * If we didn't find it, or if it has a different dirEntNum to 364 * If we didn't find it, or if it has a different dirEntNum to
@@ -372,14 +372,14 @@ ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
372 ncp_new_dentry(dentry); 372 ncp_new_dentry(dentry);
373 val=1; 373 val=1;
374 } else 374 } else
375 DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n"); 375 ncp_dbg(2, "found, but dirEntNum changed\n");
376 376
377 ncp_update_inode2(inode, &finfo); 377 ncp_update_inode2(inode, &finfo);
378 mutex_unlock(&inode->i_mutex); 378 mutex_unlock(&inode->i_mutex);
379 } 379 }
380 380
381finished: 381finished:
382 DDPRINTK("ncp_lookup_validate: result=%d\n", val); 382 ncp_dbg(2, "result=%d\n", val);
383 dput(parent); 383 dput(parent);
384 return val; 384 return val;
385} 385}
@@ -453,8 +453,7 @@ static int ncp_readdir(struct file *file, struct dir_context *ctx)
453 ctl.page = NULL; 453 ctl.page = NULL;
454 ctl.cache = NULL; 454 ctl.cache = NULL;
455 455
456 DDPRINTK("ncp_readdir: reading %pD2, pos=%d\n", file, 456 ncp_dbg(2, "reading %pD2, pos=%d\n", file, (int)ctx->pos);
457 (int) ctx->pos);
458 457
459 result = -EIO; 458 result = -EIO;
460 /* Do not generate '.' and '..' when server is dead. */ 459 /* Do not generate '.' and '..' when server is dead. */
@@ -697,8 +696,7 @@ ncp_read_volume_list(struct file *file, struct dir_context *ctx,
697 struct ncp_entry_info entry; 696 struct ncp_entry_info entry;
698 int i; 697 int i;
699 698
700 DPRINTK("ncp_read_volume_list: pos=%ld\n", 699 ncp_dbg(1, "pos=%ld\n", (unsigned long)ctx->pos);
701 (unsigned long) ctx->pos);
702 700
703 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { 701 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) {
704 int inval_dentry; 702 int inval_dentry;
@@ -708,12 +706,11 @@ ncp_read_volume_list(struct file *file, struct dir_context *ctx,
708 if (!strlen(info.volume_name)) 706 if (!strlen(info.volume_name))
709 continue; 707 continue;
710 708
711 DPRINTK("ncp_read_volume_list: found vol: %s\n", 709 ncp_dbg(1, "found vol: %s\n", info.volume_name);
712 info.volume_name);
713 710
714 if (ncp_lookup_volume(server, info.volume_name, 711 if (ncp_lookup_volume(server, info.volume_name,
715 &entry.i)) { 712 &entry.i)) {
716 DPRINTK("ncpfs: could not lookup vol %s\n", 713 ncp_dbg(1, "could not lookup vol %s\n",
717 info.volume_name); 714 info.volume_name);
718 continue; 715 continue;
719 } 716 }
@@ -738,14 +735,13 @@ ncp_do_readdir(struct file *file, struct dir_context *ctx,
738 int more; 735 int more;
739 size_t bufsize; 736 size_t bufsize;
740 737
741 DPRINTK("ncp_do_readdir: %pD2, fpos=%ld\n", file, 738 ncp_dbg(1, "%pD2, fpos=%ld\n", file, (unsigned long)ctx->pos);
742 (unsigned long) ctx->pos); 739 ncp_vdbg("init %pD, volnum=%d, dirent=%u\n",
743 PPRINTK("ncp_do_readdir: init %pD, volnum=%d, dirent=%u\n", 740 file, NCP_FINFO(dir)->volNumber, NCP_FINFO(dir)->dirEntNum);
744 file, NCP_FINFO(dir)->volNumber, NCP_FINFO(dir)->dirEntNum);
745 741
746 err = ncp_initialize_search(server, dir, &seq); 742 err = ncp_initialize_search(server, dir, &seq);
747 if (err) { 743 if (err) {
748 DPRINTK("ncp_do_readdir: init failed, err=%d\n", err); 744 ncp_dbg(1, "init failed, err=%d\n", err);
749 return; 745 return;
750 } 746 }
751 /* We MUST NOT use server->buffer_size handshaked with server if we are 747 /* We MUST NOT use server->buffer_size handshaked with server if we are
@@ -808,8 +804,7 @@ int ncp_conn_logged_in(struct super_block *sb)
808 goto out; 804 goto out;
809 result = -ENOENT; 805 result = -ENOENT;
810 if (ncp_get_volume_root(server, __name, &volNumber, &dirEntNum, &DosDirNum)) { 806 if (ncp_get_volume_root(server, __name, &volNumber, &dirEntNum, &DosDirNum)) {
811 PPRINTK("ncp_conn_logged_in: %s not found\n", 807 ncp_vdbg("%s not found\n", server->m.mounted_vol);
812 server->m.mounted_vol);
813 goto out; 808 goto out;
814 } 809 }
815 dent = sb->s_root; 810 dent = sb->s_root;
@@ -822,10 +817,10 @@ int ncp_conn_logged_in(struct super_block *sb)
822 NCP_FINFO(ino)->DosDirNum = DosDirNum; 817 NCP_FINFO(ino)->DosDirNum = DosDirNum;
823 result = 0; 818 result = 0;
824 } else { 819 } else {
825 DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n"); 820 ncp_dbg(1, "sb->s_root->d_inode == NULL!\n");
826 } 821 }
827 } else { 822 } else {
828 DPRINTK("ncpfs: sb->s_root == NULL!\n"); 823 ncp_dbg(1, "sb->s_root == NULL!\n");
829 } 824 }
830 } else 825 } else
831 result = 0; 826 result = 0;
@@ -846,7 +841,7 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, unsig
846 if (!ncp_conn_valid(server)) 841 if (!ncp_conn_valid(server))
847 goto finished; 842 goto finished;
848 843
849 PPRINTK("ncp_lookup: server lookup for %pd2\n", dentry); 844 ncp_vdbg("server lookup for %pd2\n", dentry);
850 845
851 len = sizeof(__name); 846 len = sizeof(__name);
852 if (ncp_is_server_root(dir)) { 847 if (ncp_is_server_root(dir)) {
@@ -854,15 +849,15 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, unsig
854 dentry->d_name.len, 1); 849 dentry->d_name.len, 1);
855 if (!res) 850 if (!res)
856 res = ncp_lookup_volume(server, __name, &(finfo.i)); 851 res = ncp_lookup_volume(server, __name, &(finfo.i));
857 if (!res) 852 if (!res)
858 ncp_update_known_namespace(server, finfo.i.volNumber, NULL); 853 ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
859 } else { 854 } else {
860 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 855 res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
861 dentry->d_name.len, !ncp_preserve_case(dir)); 856 dentry->d_name.len, !ncp_preserve_case(dir));
862 if (!res) 857 if (!res)
863 res = ncp_obtain_info(server, dir, __name, &(finfo.i)); 858 res = ncp_obtain_info(server, dir, __name, &(finfo.i));
864 } 859 }
865 PPRINTK("ncp_lookup: looked for %pd2, res=%d\n", dentry, res); 860 ncp_vdbg("looked for %pd2, res=%d\n", dentry, res);
866 /* 861 /*
867 * If we didn't find an entry, make a negative dentry. 862 * If we didn't find an entry, make a negative dentry.
868 */ 863 */
@@ -886,7 +881,7 @@ add_entry:
886 } 881 }
887 882
888finished: 883finished:
889 PPRINTK("ncp_lookup: result=%d\n", error); 884 ncp_vdbg("result=%d\n", error);
890 return ERR_PTR(error); 885 return ERR_PTR(error);
891} 886}
892 887
@@ -909,7 +904,7 @@ out:
909 return error; 904 return error;
910 905
911out_close: 906out_close:
912 PPRINTK("ncp_instantiate: %pd2 failed, closing file\n", dentry); 907 ncp_vdbg("%pd2 failed, closing file\n", dentry);
913 ncp_close_file(NCP_SERVER(dir), finfo->file_handle); 908 ncp_close_file(NCP_SERVER(dir), finfo->file_handle);
914 goto out; 909 goto out;
915} 910}
@@ -923,7 +918,7 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, umode_t mode,
923 int opmode; 918 int opmode;
924 __u8 __name[NCP_MAXPATHLEN + 1]; 919 __u8 __name[NCP_MAXPATHLEN + 1];
925 920
926 PPRINTK("ncp_create_new: creating %pd2, mode=%hx\n", dentry, mode); 921 ncp_vdbg("creating %pd2, mode=%hx\n", dentry, mode);
927 922
928 ncp_age_dentry(server, dentry); 923 ncp_age_dentry(server, dentry);
929 len = sizeof(__name); 924 len = sizeof(__name);
@@ -952,7 +947,7 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, umode_t mode,
952 error = -ENAMETOOLONG; 947 error = -ENAMETOOLONG;
953 else if (result < 0) 948 else if (result < 0)
954 error = result; 949 error = result;
955 DPRINTK("ncp_create: %pd2 failed\n", dentry); 950 ncp_dbg(1, "%pd2 failed\n", dentry);
956 goto out; 951 goto out;
957 } 952 }
958 opmode = O_WRONLY; 953 opmode = O_WRONLY;
@@ -985,7 +980,7 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
985 int error, len; 980 int error, len;
986 __u8 __name[NCP_MAXPATHLEN + 1]; 981 __u8 __name[NCP_MAXPATHLEN + 1];
987 982
988 DPRINTK("ncp_mkdir: making %pd2\n", dentry); 983 ncp_dbg(1, "making %pd2\n", dentry);
989 984
990 ncp_age_dentry(server, dentry); 985 ncp_age_dentry(server, dentry);
991 len = sizeof(__name); 986 len = sizeof(__name);
@@ -1022,7 +1017,7 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
1022 int error, result, len; 1017 int error, result, len;
1023 __u8 __name[NCP_MAXPATHLEN + 1]; 1018 __u8 __name[NCP_MAXPATHLEN + 1];
1024 1019
1025 DPRINTK("ncp_rmdir: removing %pd2\n", dentry); 1020 ncp_dbg(1, "removing %pd2\n", dentry);
1026 1021
1027 len = sizeof(__name); 1022 len = sizeof(__name);
1028 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, 1023 error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
@@ -1067,13 +1062,13 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
1067 int error; 1062 int error;
1068 1063
1069 server = NCP_SERVER(dir); 1064 server = NCP_SERVER(dir);
1070 DPRINTK("ncp_unlink: unlinking %pd2\n", dentry); 1065 ncp_dbg(1, "unlinking %pd2\n", dentry);
1071 1066
1072 /* 1067 /*
1073 * Check whether to close the file ... 1068 * Check whether to close the file ...
1074 */ 1069 */
1075 if (inode) { 1070 if (inode) {
1076 PPRINTK("ncp_unlink: closing file\n"); 1071 ncp_vdbg("closing file\n");
1077 ncp_make_closed(inode); 1072 ncp_make_closed(inode);
1078 } 1073 }
1079 1074
@@ -1087,7 +1082,7 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
1087#endif 1082#endif
1088 switch (error) { 1083 switch (error) {
1089 case 0x00: 1084 case 0x00:
1090 DPRINTK("ncp: removed %pd2\n", dentry); 1085 ncp_dbg(1, "removed %pd2\n", dentry);
1091 break; 1086 break;
1092 case 0x85: 1087 case 0x85:
1093 case 0x8A: 1088 case 0x8A:
@@ -1120,7 +1115,7 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
1120 int old_len, new_len; 1115 int old_len, new_len;
1121 __u8 __old_name[NCP_MAXPATHLEN + 1], __new_name[NCP_MAXPATHLEN + 1]; 1116 __u8 __old_name[NCP_MAXPATHLEN + 1], __new_name[NCP_MAXPATHLEN + 1];
1122 1117
1123 DPRINTK("ncp_rename: %pd2 to %pd2\n", old_dentry, new_dentry); 1118 ncp_dbg(1, "%pd2 to %pd2\n", old_dentry, new_dentry);
1124 1119
1125 ncp_age_dentry(server, old_dentry); 1120 ncp_age_dentry(server, old_dentry);
1126 ncp_age_dentry(server, new_dentry); 1121 ncp_age_dentry(server, new_dentry);
@@ -1150,8 +1145,8 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
1150#endif 1145#endif
1151 switch (error) { 1146 switch (error) {
1152 case 0x00: 1147 case 0x00:
1153 DPRINTK("ncp renamed %pd -> %pd.\n", 1148 ncp_dbg(1, "renamed %pd -> %pd\n",
1154 old_dentry, new_dentry); 1149 old_dentry, new_dentry);
1155 break; 1150 break;
1156 case 0x9E: 1151 case 0x9E:
1157 error = -ENAMETOOLONG; 1152 error = -ENAMETOOLONG;
@@ -1173,7 +1168,7 @@ static int ncp_mknod(struct inode * dir, struct dentry *dentry,
1173 if (!new_valid_dev(rdev)) 1168 if (!new_valid_dev(rdev))
1174 return -EINVAL; 1169 return -EINVAL;
1175 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) { 1170 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) {
1176 DPRINTK(KERN_DEBUG "ncp_mknod: mode = 0%ho\n", mode); 1171 ncp_dbg(1, "mode = 0%ho\n", mode);
1177 return ncp_create_new(dir, dentry, mode, rdev, 0); 1172 return ncp_create_new(dir, dentry, mode, rdev, 0);
1178 } 1173 }
1179 return -EPERM; /* Strange, but true */ 1174 return -EPERM; /* Strange, but true */
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 8f5074e1ecb9..77640a8bfb87 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -6,6 +6,8 @@
6 * 6 *
7 */ 7 */
8 8
9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
9#include <asm/uaccess.h> 11#include <asm/uaccess.h>
10 12
11#include <linux/time.h> 13#include <linux/time.h>
@@ -34,11 +36,11 @@ int ncp_make_open(struct inode *inode, int right)
34 36
35 error = -EINVAL; 37 error = -EINVAL;
36 if (!inode) { 38 if (!inode) {
37 printk(KERN_ERR "ncp_make_open: got NULL inode\n"); 39 pr_err("%s: got NULL inode\n", __func__);
38 goto out; 40 goto out;
39 } 41 }
40 42
41 DPRINTK("ncp_make_open: opened=%d, volume # %u, dir entry # %u\n", 43 ncp_dbg(1, "opened=%d, volume # %u, dir entry # %u\n",
42 atomic_read(&NCP_FINFO(inode)->opened), 44 atomic_read(&NCP_FINFO(inode)->opened),
43 NCP_FINFO(inode)->volNumber, 45 NCP_FINFO(inode)->volNumber,
44 NCP_FINFO(inode)->dirEntNum); 46 NCP_FINFO(inode)->dirEntNum);
@@ -71,7 +73,7 @@ int ncp_make_open(struct inode *inode, int right)
71 break; 73 break;
72 } 74 }
73 if (result) { 75 if (result) {
74 PPRINTK("ncp_make_open: failed, result=%d\n", result); 76 ncp_vdbg("failed, result=%d\n", result);
75 goto out_unlock; 77 goto out_unlock;
76 } 78 }
77 /* 79 /*
@@ -83,7 +85,7 @@ int ncp_make_open(struct inode *inode, int right)
83 } 85 }
84 86
85 access = NCP_FINFO(inode)->access; 87 access = NCP_FINFO(inode)->access;
86 PPRINTK("ncp_make_open: file open, access=%x\n", access); 88 ncp_vdbg("file open, access=%x\n", access);
87 if (access == right || access == O_RDWR) { 89 if (access == right || access == O_RDWR) {
88 atomic_inc(&NCP_FINFO(inode)->opened); 90 atomic_inc(&NCP_FINFO(inode)->opened);
89 error = 0; 91 error = 0;
@@ -107,7 +109,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
107 void* freepage; 109 void* freepage;
108 size_t freelen; 110 size_t freelen;
109 111
110 DPRINTK("ncp_file_read: enter %pd2\n", dentry); 112 ncp_dbg(1, "enter %pd2\n", dentry);
111 113
112 pos = *ppos; 114 pos = *ppos;
113 115
@@ -124,7 +126,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
124 126
125 error = ncp_make_open(inode, O_RDONLY); 127 error = ncp_make_open(inode, O_RDONLY);
126 if (error) { 128 if (error) {
127 DPRINTK(KERN_ERR "ncp_file_read: open failed, error=%d\n", error); 129 ncp_dbg(1, "open failed, error=%d\n", error);
128 return error; 130 return error;
129 } 131 }
130 132
@@ -165,7 +167,7 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
165 167
166 file_accessed(file); 168 file_accessed(file);
167 169
168 DPRINTK("ncp_file_read: exit %pd2\n", dentry); 170 ncp_dbg(1, "exit %pd2\n", dentry);
169outrel: 171outrel:
170 ncp_inode_close(inode); 172 ncp_inode_close(inode);
171 return already_read ? already_read : error; 173 return already_read ? already_read : error;
@@ -182,7 +184,7 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
182 int errno; 184 int errno;
183 void* bouncebuffer; 185 void* bouncebuffer;
184 186
185 DPRINTK("ncp_file_write: enter %pd2\n", dentry); 187 ncp_dbg(1, "enter %pd2\n", dentry);
186 if ((ssize_t) count < 0) 188 if ((ssize_t) count < 0)
187 return -EINVAL; 189 return -EINVAL;
188 pos = *ppos; 190 pos = *ppos;
@@ -211,7 +213,7 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
211 return 0; 213 return 0;
212 errno = ncp_make_open(inode, O_WRONLY); 214 errno = ncp_make_open(inode, O_WRONLY);
213 if (errno) { 215 if (errno) {
214 DPRINTK(KERN_ERR "ncp_file_write: open failed, error=%d\n", errno); 216 ncp_dbg(1, "open failed, error=%d\n", errno);
215 return errno; 217 return errno;
216 } 218 }
217 bufsize = NCP_SERVER(inode)->buffer_size; 219 bufsize = NCP_SERVER(inode)->buffer_size;
@@ -261,7 +263,7 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
261 i_size_write(inode, pos); 263 i_size_write(inode, pos);
262 mutex_unlock(&inode->i_mutex); 264 mutex_unlock(&inode->i_mutex);
263 } 265 }
264 DPRINTK("ncp_file_write: exit %pd2\n", dentry); 266 ncp_dbg(1, "exit %pd2\n", dentry);
265outrel: 267outrel:
266 ncp_inode_close(inode); 268 ncp_inode_close(inode);
267 return already_written ? already_written : errno; 269 return already_written ? already_written : errno;
@@ -269,7 +271,7 @@ outrel:
269 271
270static int ncp_release(struct inode *inode, struct file *file) { 272static int ncp_release(struct inode *inode, struct file *file) {
271 if (ncp_make_closed(inode)) { 273 if (ncp_make_closed(inode)) {
272 DPRINTK("ncp_release: failed to close\n"); 274 ncp_dbg(1, "failed to close\n");
273 } 275 }
274 return 0; 276 return 0;
275} 277}
diff --git a/fs/ncpfs/getopt.c b/fs/ncpfs/getopt.c
index 0af3349de851..03ffde1f44d6 100644
--- a/fs/ncpfs/getopt.c
+++ b/fs/ncpfs/getopt.c
@@ -2,6 +2,8 @@
2 * getopt.c 2 * getopt.c
3 */ 3 */
4 4
5#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6
5#include <linux/kernel.h> 7#include <linux/kernel.h>
6#include <linux/string.h> 8#include <linux/string.h>
7 9
@@ -46,8 +48,8 @@ int ncp_getopt(const char *caller, char **options, const struct ncp_option *opts
46 if (opts->has_arg & OPT_NOPARAM) { 48 if (opts->has_arg & OPT_NOPARAM) {
47 return opts->val; 49 return opts->val;
48 } 50 }
49 printk(KERN_INFO "%s: the %s option requires an argument\n", 51 pr_info("%s: the %s option requires an argument\n",
50 caller, token); 52 caller, token);
51 return -EINVAL; 53 return -EINVAL;
52 } 54 }
53 if (opts->has_arg & OPT_INT) { 55 if (opts->has_arg & OPT_INT) {
@@ -57,18 +59,18 @@ int ncp_getopt(const char *caller, char **options, const struct ncp_option *opts
57 if (!*v) { 59 if (!*v) {
58 return opts->val; 60 return opts->val;
59 } 61 }
60 printk(KERN_INFO "%s: invalid numeric value in %s=%s\n", 62 pr_info("%s: invalid numeric value in %s=%s\n",
61 caller, token, val); 63 caller, token, val);
62 return -EDOM; 64 return -EDOM;
63 } 65 }
64 if (opts->has_arg & OPT_STRING) { 66 if (opts->has_arg & OPT_STRING) {
65 return opts->val; 67 return opts->val;
66 } 68 }
67 printk(KERN_INFO "%s: unexpected argument %s to the %s option\n", 69 pr_info("%s: unexpected argument %s to the %s option\n",
68 caller, val, token); 70 caller, val, token);
69 return -EINVAL; 71 return -EINVAL;
70 } 72 }
71 } 73 }
72 printk(KERN_INFO "%s: Unrecognized mount option %s\n", caller, token); 74 pr_info("%s: Unrecognized mount option %s\n", caller, token);
73 return -EOPNOTSUPP; 75 return -EOPNOTSUPP;
74} 76}
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 647d86d2db39..e31e589369a4 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/module.h> 14#include <linux/module.h>
13 15
14#include <asm/uaccess.h> 16#include <asm/uaccess.h>
@@ -133,7 +135,7 @@ void ncp_update_inode(struct inode *inode, struct ncp_entry_info *nwinfo)
133 NCP_FINFO(inode)->access = nwinfo->access; 135 NCP_FINFO(inode)->access = nwinfo->access;
134 memcpy(NCP_FINFO(inode)->file_handle, nwinfo->file_handle, 136 memcpy(NCP_FINFO(inode)->file_handle, nwinfo->file_handle,
135 sizeof(nwinfo->file_handle)); 137 sizeof(nwinfo->file_handle));
136 DPRINTK("ncp_update_inode: updated %s, volnum=%d, dirent=%u\n", 138 ncp_dbg(1, "updated %s, volnum=%d, dirent=%u\n",
137 nwinfo->i.entryName, NCP_FINFO(inode)->volNumber, 139 nwinfo->i.entryName, NCP_FINFO(inode)->volNumber,
138 NCP_FINFO(inode)->dirEntNum); 140 NCP_FINFO(inode)->dirEntNum);
139} 141}
@@ -141,8 +143,7 @@ void ncp_update_inode(struct inode *inode, struct ncp_entry_info *nwinfo)
141static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi) 143static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi)
142{ 144{
143 /* NFS namespace mode overrides others if it's set. */ 145 /* NFS namespace mode overrides others if it's set. */
144 DPRINTK(KERN_DEBUG "ncp_update_dates_and_mode: (%s) nfs.mode=0%o\n", 146 ncp_dbg(1, "(%s) nfs.mode=0%o\n", nwi->entryName, nwi->nfs.mode);
145 nwi->entryName, nwi->nfs.mode);
146 if (nwi->nfs.mode) { 147 if (nwi->nfs.mode) {
147 /* XXX Security? */ 148 /* XXX Security? */
148 inode->i_mode = nwi->nfs.mode; 149 inode->i_mode = nwi->nfs.mode;
@@ -230,7 +231,7 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
230 231
231 ncp_update_attrs(inode, nwinfo); 232 ncp_update_attrs(inode, nwinfo);
232 233
233 DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode); 234 ncp_dbg(2, "inode->i_mode = %u\n", inode->i_mode);
234 235
235 set_nlink(inode, 1); 236 set_nlink(inode, 1);
236 inode->i_uid = server->m.uid; 237 inode->i_uid = server->m.uid;
@@ -258,7 +259,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
258 struct inode *inode; 259 struct inode *inode;
259 260
260 if (info == NULL) { 261 if (info == NULL) {
261 printk(KERN_ERR "ncp_iget: info is NULL\n"); 262 pr_err("%s: info is NULL\n", __func__);
262 return NULL; 263 return NULL;
263 } 264 }
264 265
@@ -290,7 +291,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
290 } 291 }
291 insert_inode_hash(inode); 292 insert_inode_hash(inode);
292 } else 293 } else
293 printk(KERN_ERR "ncp_iget: iget failed!\n"); 294 pr_err("%s: iget failed!\n", __func__);
294 return inode; 295 return inode;
295} 296}
296 297
@@ -301,12 +302,12 @@ ncp_evict_inode(struct inode *inode)
301 clear_inode(inode); 302 clear_inode(inode);
302 303
303 if (S_ISDIR(inode->i_mode)) { 304 if (S_ISDIR(inode->i_mode)) {
304 DDPRINTK("ncp_evict_inode: put directory %ld\n", inode->i_ino); 305 ncp_dbg(2, "put directory %ld\n", inode->i_ino);
305 } 306 }
306 307
307 if (ncp_make_closed(inode) != 0) { 308 if (ncp_make_closed(inode) != 0) {
308 /* We can't do anything but complain. */ 309 /* We can't do anything but complain. */
309 printk(KERN_ERR "ncp_evict_inode: could not close\n"); 310 pr_err("%s: could not close\n", __func__);
310 } 311 }
311} 312}
312 313
@@ -469,9 +470,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
469{ 470{
470 struct ncp_mount_data_kernel data; 471 struct ncp_mount_data_kernel data;
471 struct ncp_server *server; 472 struct ncp_server *server;
472 struct file *ncp_filp;
473 struct inode *root_inode; 473 struct inode *root_inode;
474 struct inode *sock_inode;
475 struct socket *sock; 474 struct socket *sock;
476 int error; 475 int error;
477 int default_bufsize; 476 int default_bufsize;
@@ -540,18 +539,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
540 if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) || 539 if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) ||
541 !gid_valid(data.gid)) 540 !gid_valid(data.gid))
542 goto out; 541 goto out;
543 error = -EBADF; 542 sock = sockfd_lookup(data.ncp_fd, &error);
544 ncp_filp = fget(data.ncp_fd);
545 if (!ncp_filp)
546 goto out;
547 error = -ENOTSOCK;
548 sock_inode = file_inode(ncp_filp);
549 if (!S_ISSOCK(sock_inode->i_mode))
550 goto out_fput;
551 sock = SOCKET_I(sock_inode);
552 if (!sock) 543 if (!sock)
553 goto out_fput; 544 goto out;
554 545
555 if (sock->type == SOCK_STREAM) 546 if (sock->type == SOCK_STREAM)
556 default_bufsize = 0xF000; 547 default_bufsize = 0xF000;
557 else 548 else
@@ -573,27 +564,16 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
573 if (error) 564 if (error)
574 goto out_fput; 565 goto out_fput;
575 566
576 server->ncp_filp = ncp_filp;
577 server->ncp_sock = sock; 567 server->ncp_sock = sock;
578 568
579 if (data.info_fd != -1) { 569 if (data.info_fd != -1) {
580 struct socket *info_sock; 570 struct socket *info_sock = sockfd_lookup(data.info_fd, &error);
581
582 error = -EBADF;
583 server->info_filp = fget(data.info_fd);
584 if (!server->info_filp)
585 goto out_bdi;
586 error = -ENOTSOCK;
587 sock_inode = file_inode(server->info_filp);
588 if (!S_ISSOCK(sock_inode->i_mode))
589 goto out_fput2;
590 info_sock = SOCKET_I(sock_inode);
591 if (!info_sock) 571 if (!info_sock)
592 goto out_fput2; 572 goto out_bdi;
573 server->info_sock = info_sock;
593 error = -EBADFD; 574 error = -EBADFD;
594 if (info_sock->type != SOCK_STREAM) 575 if (info_sock->type != SOCK_STREAM)
595 goto out_fput2; 576 goto out_fput2;
596 server->info_sock = info_sock;
597 } 577 }
598 578
599/* server->lock = 0; */ 579/* server->lock = 0; */
@@ -621,7 +601,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
621 now because of PATH_MAX changes.. */ 601 now because of PATH_MAX changes.. */
622 if (server->m.time_out < 1) { 602 if (server->m.time_out < 1) {
623 server->m.time_out = 10; 603 server->m.time_out = 10;
624 printk(KERN_INFO "You need to recompile your ncpfs utils..\n"); 604 pr_info("You need to recompile your ncpfs utils..\n");
625 } 605 }
626 server->m.time_out = server->m.time_out * HZ / 100; 606 server->m.time_out = server->m.time_out * HZ / 100;
627 server->m.file_mode = (server->m.file_mode & S_IRWXUGO) | S_IFREG; 607 server->m.file_mode = (server->m.file_mode & S_IRWXUGO) | S_IFREG;
@@ -682,7 +662,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
682 ncp_unlock_server(server); 662 ncp_unlock_server(server);
683 if (error < 0) 663 if (error < 0)
684 goto out_rxbuf; 664 goto out_rxbuf;
685 DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb)); 665 ncp_dbg(1, "NCP_SBP(sb) = %p\n", NCP_SBP(sb));
686 666
687 error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */ 667 error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */
688#ifdef CONFIG_NCPFS_PACKET_SIGNING 668#ifdef CONFIG_NCPFS_PACKET_SIGNING
@@ -710,7 +690,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
710 if (ncp_negotiate_buffersize(server, default_bufsize, 690 if (ncp_negotiate_buffersize(server, default_bufsize,
711 &(server->buffer_size)) != 0) 691 &(server->buffer_size)) != 0)
712 goto out_disconnect; 692 goto out_disconnect;
713 DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size); 693 ncp_dbg(1, "bufsize = %d\n", server->buffer_size);
714 694
715 memset(&finfo, 0, sizeof(finfo)); 695 memset(&finfo, 0, sizeof(finfo));
716 finfo.i.attributes = aDIR; 696 finfo.i.attributes = aDIR;
@@ -739,7 +719,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
739 root_inode = ncp_iget(sb, &finfo); 719 root_inode = ncp_iget(sb, &finfo);
740 if (!root_inode) 720 if (!root_inode)
741 goto out_disconnect; 721 goto out_disconnect;
742 DPRINTK("ncp_fill_super: root vol=%d\n", NCP_FINFO(root_inode)->volNumber); 722 ncp_dbg(1, "root vol=%d\n", NCP_FINFO(root_inode)->volNumber);
743 sb->s_root = d_make_root(root_inode); 723 sb->s_root = d_make_root(root_inode);
744 if (!sb->s_root) 724 if (!sb->s_root)
745 goto out_disconnect; 725 goto out_disconnect;
@@ -765,17 +745,12 @@ out_nls:
765 mutex_destroy(&server->root_setup_lock); 745 mutex_destroy(&server->root_setup_lock);
766 mutex_destroy(&server->mutex); 746 mutex_destroy(&server->mutex);
767out_fput2: 747out_fput2:
768 if (server->info_filp) 748 if (server->info_sock)
769 fput(server->info_filp); 749 sockfd_put(server->info_sock);
770out_bdi: 750out_bdi:
771 bdi_destroy(&server->bdi); 751 bdi_destroy(&server->bdi);
772out_fput: 752out_fput:
773 /* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: 753 sockfd_put(sock);
774 *
775 * The previously used put_filp(ncp_filp); was bogus, since
776 * it doesn't perform proper unlocking.
777 */
778 fput(ncp_filp);
779out: 754out:
780 put_pid(data.wdog_pid); 755 put_pid(data.wdog_pid);
781 sb->s_fs_info = NULL; 756 sb->s_fs_info = NULL;
@@ -808,9 +783,9 @@ static void ncp_put_super(struct super_block *sb)
808 mutex_destroy(&server->root_setup_lock); 783 mutex_destroy(&server->root_setup_lock);
809 mutex_destroy(&server->mutex); 784 mutex_destroy(&server->mutex);
810 785
811 if (server->info_filp) 786 if (server->info_sock)
812 fput(server->info_filp); 787 sockfd_put(server->info_sock);
813 fput(server->ncp_filp); 788 sockfd_put(server->ncp_sock);
814 kill_pid(server->m.wdog_pid, SIGTERM, 1); 789 kill_pid(server->m.wdog_pid, SIGTERM, 1);
815 put_pid(server->m.wdog_pid); 790 put_pid(server->m.wdog_pid);
816 791
@@ -985,8 +960,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
985 if ((attr->ia_valid & ATTR_SIZE) != 0) { 960 if ((attr->ia_valid & ATTR_SIZE) != 0) {
986 int written; 961 int written;
987 962
988 DPRINTK("ncpfs: trying to change size to %ld\n", 963 ncp_dbg(1, "trying to change size to %llu\n", attr->ia_size);
989 attr->ia_size);
990 964
991 if ((result = ncp_make_open(inode, O_WRONLY)) < 0) { 965 if ((result = ncp_make_open(inode, O_WRONLY)) < 0) {
992 result = -EACCES; 966 result = -EACCES;
@@ -1072,7 +1046,7 @@ MODULE_ALIAS_FS("ncpfs");
1072static int __init init_ncp_fs(void) 1046static int __init init_ncp_fs(void)
1073{ 1047{
1074 int err; 1048 int err;
1075 DPRINTK("ncpfs: init_ncp_fs called\n"); 1049 ncp_dbg(1, "called\n");
1076 1050
1077 err = init_inodecache(); 1051 err = init_inodecache();
1078 if (err) 1052 if (err)
@@ -1089,7 +1063,7 @@ out1:
1089 1063
1090static void __exit exit_ncp_fs(void) 1064static void __exit exit_ncp_fs(void)
1091{ 1065{
1092 DPRINTK("ncpfs: exit_ncp_fs called\n"); 1066 ncp_dbg(1, "called\n");
1093 unregister_filesystem(&ncp_fs_type); 1067 unregister_filesystem(&ncp_fs_type);
1094 destroy_inodecache(); 1068 destroy_inodecache();
1095} 1069}
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 60426ccb3b65..d5659d96ee7f 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -41,7 +41,7 @@ ncp_get_fs_info(struct ncp_server * server, struct inode *inode,
41 return -EFAULT; 41 return -EFAULT;
42 42
43 if (info.version != NCP_GET_FS_INFO_VERSION) { 43 if (info.version != NCP_GET_FS_INFO_VERSION) {
44 DPRINTK("info.version invalid: %d\n", info.version); 44 ncp_dbg(1, "info.version invalid: %d\n", info.version);
45 return -EINVAL; 45 return -EINVAL;
46 } 46 }
47 /* TODO: info.addr = server->m.serv_addr; */ 47 /* TODO: info.addr = server->m.serv_addr; */
@@ -66,7 +66,7 @@ ncp_get_fs_info_v2(struct ncp_server * server, struct inode *inode,
66 return -EFAULT; 66 return -EFAULT;
67 67
68 if (info2.version != NCP_GET_FS_INFO_VERSION_V2) { 68 if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
69 DPRINTK("info.version invalid: %d\n", info2.version); 69 ncp_dbg(1, "info.version invalid: %d\n", info2.version);
70 return -EINVAL; 70 return -EINVAL;
71 } 71 }
72 info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); 72 info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid);
@@ -132,7 +132,7 @@ ncp_get_compat_fs_info_v2(struct ncp_server * server, struct inode *inode,
132 return -EFAULT; 132 return -EFAULT;
133 133
134 if (info2.version != NCP_GET_FS_INFO_VERSION_V2) { 134 if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
135 DPRINTK("info.version invalid: %d\n", info2.version); 135 ncp_dbg(1, "info.version invalid: %d\n", info2.version);
136 return -EINVAL; 136 return -EINVAL;
137 } 137 }
138 info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid); 138 info2.mounted_uid = from_kuid_munged(current_user_ns(), server->m.mounted_uid);
@@ -308,8 +308,7 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
308 else 308 else
309 result = server->reply_size; 309 result = server->reply_size;
310 ncp_unlock_server(server); 310 ncp_unlock_server(server);
311 DPRINTK("ncp_ioctl: copy %d bytes\n", 311 ncp_dbg(1, "copy %d bytes\n", result);
312 result);
313 if (result >= 0) 312 if (result >= 0)
314 if (copy_to_user(request.data, bouncebuffer, result)) 313 if (copy_to_user(request.data, bouncebuffer, result))
315 result = -EFAULT; 314 result = -EFAULT;
@@ -385,9 +384,9 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
385 sr.namespace = server->name_space[sr.volNumber]; 384 sr.namespace = server->name_space[sr.volNumber];
386 result = 0; 385 result = 0;
387 } else 386 } else
388 DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 387 ncp_dbg(1, "s_root->d_inode==NULL\n");
389 } else 388 } else
390 DPRINTK("ncpfs: s_root==NULL\n"); 389 ncp_dbg(1, "s_root==NULL\n");
391 } else { 390 } else {
392 sr.volNumber = -1; 391 sr.volNumber = -1;
393 sr.namespace = 0; 392 sr.namespace = 0;
@@ -440,11 +439,11 @@ static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg
440 NCP_FINFO(s_inode)->DosDirNum = dosde; 439 NCP_FINFO(s_inode)->DosDirNum = dosde;
441 server->root_setuped = 1; 440 server->root_setuped = 1;
442 } else { 441 } else {
443 DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 442 ncp_dbg(1, "s_root->d_inode==NULL\n");
444 result = -EIO; 443 result = -EIO;
445 } 444 }
446 } else { 445 } else {
447 DPRINTK("ncpfs: s_root==NULL\n"); 446 ncp_dbg(1, "s_root==NULL\n");
448 result = -EIO; 447 result = -EIO;
449 } 448 }
450 } 449 }
diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c
index 3c5dd55d284c..b359d12eb359 100644
--- a/fs/ncpfs/mmap.c
+++ b/fs/ncpfs/mmap.c
@@ -107,7 +107,7 @@ int ncp_mmap(struct file *file, struct vm_area_struct *vma)
107{ 107{
108 struct inode *inode = file_inode(file); 108 struct inode *inode = file_inode(file);
109 109
110 DPRINTK("ncp_mmap: called\n"); 110 ncp_dbg(1, "called\n");
111 111
112 if (!ncp_conn_valid(NCP_SERVER(inode))) 112 if (!ncp_conn_valid(NCP_SERVER(inode)))
113 return -EIO; 113 return -EIO;
diff --git a/fs/ncpfs/ncp_fs.h b/fs/ncpfs/ncp_fs.h
index 31831afe1c3b..b9f69e1b1f43 100644
--- a/fs/ncpfs/ncp_fs.h
+++ b/fs/ncpfs/ncp_fs.h
@@ -2,30 +2,32 @@
2#include "ncp_fs_i.h" 2#include "ncp_fs_i.h"
3#include "ncp_fs_sb.h" 3#include "ncp_fs_sb.h"
4 4
5/* define because it is easy to change PRINTK to {*}PRINTK */
6#define PRINTK(format, args...) printk(KERN_DEBUG format , ## args)
7
8#undef NCPFS_PARANOIA 5#undef NCPFS_PARANOIA
9#ifdef NCPFS_PARANOIA 6#ifdef NCPFS_PARANOIA
10#define PPRINTK(format, args...) PRINTK(format , ## args) 7#define ncp_vdbg(fmt, ...) \
8 pr_debug(fmt, ##__VA_ARGS__)
11#else 9#else
12#define PPRINTK(format, args...) 10#define ncp_vdbg(fmt, ...) \
11do { \
12 if (0) \
13 pr_debug(fmt, ##__VA_ARGS__); \
14} while (0)
13#endif 15#endif
14 16
15#ifndef DEBUG_NCP 17#ifndef DEBUG_NCP
16#define DEBUG_NCP 0 18#define DEBUG_NCP 0
17#endif 19#endif
18#if DEBUG_NCP > 0 20
19#define DPRINTK(format, args...) PRINTK(format , ## args) 21#if DEBUG_NCP > 0 && !defined(DEBUG)
20#else 22#define DEBUG
21#define DPRINTK(format, args...)
22#endif
23#if DEBUG_NCP > 1
24#define DDPRINTK(format, args...) PRINTK(format , ## args)
25#else
26#define DDPRINTK(format, args...)
27#endif 23#endif
28 24
25#define ncp_dbg(level, fmt, ...) \
26do { \
27 if (level <= DEBUG_NCP) \
28 pr_debug(fmt, ##__VA_ARGS__); \
29} while (0)
30
29#define NCP_MAX_RPC_TIMEOUT (6*HZ) 31#define NCP_MAX_RPC_TIMEOUT (6*HZ)
30 32
31 33
diff --git a/fs/ncpfs/ncp_fs_sb.h b/fs/ncpfs/ncp_fs_sb.h
index b81e97adc5a9..55e26fd80886 100644
--- a/fs/ncpfs/ncp_fs_sb.h
+++ b/fs/ncpfs/ncp_fs_sb.h
@@ -45,9 +45,7 @@ struct ncp_server {
45 45
46 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2]; 46 __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
47 47
48 struct file *ncp_filp; /* File pointer to ncp socket */
49 struct socket *ncp_sock;/* ncp socket */ 48 struct socket *ncp_sock;/* ncp socket */
50 struct file *info_filp;
51 struct socket *info_sock; 49 struct socket *info_sock;
52 50
53 u8 sequence; 51 u8 sequence;
@@ -111,7 +109,7 @@ struct ncp_server {
111 109
112 spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */ 110 spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
113 111
114 void (*data_ready)(struct sock* sk, int len); 112 void (*data_ready)(struct sock* sk);
115 void (*error_report)(struct sock* sk); 113 void (*error_report)(struct sock* sk);
116 void (*write_space)(struct sock* sk); /* STREAM mode only */ 114 void (*write_space)(struct sock* sk); /* STREAM mode only */
117 struct { 115 struct {
@@ -153,7 +151,7 @@ extern void ncp_tcp_tx_proc(struct work_struct *work);
153extern void ncpdgram_rcv_proc(struct work_struct *work); 151extern void ncpdgram_rcv_proc(struct work_struct *work);
154extern void ncpdgram_timeout_proc(struct work_struct *work); 152extern void ncpdgram_timeout_proc(struct work_struct *work);
155extern void ncpdgram_timeout_call(unsigned long server); 153extern void ncpdgram_timeout_call(unsigned long server);
156extern void ncp_tcp_data_ready(struct sock* sk, int len); 154extern void ncp_tcp_data_ready(struct sock* sk);
157extern void ncp_tcp_write_space(struct sock* sk); 155extern void ncp_tcp_write_space(struct sock* sk);
158extern void ncp_tcp_error_report(struct sock* sk); 156extern void ncp_tcp_error_report(struct sock* sk);
159 157
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 981a95617fc9..482387532f54 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -9,14 +9,14 @@
9 * 9 *
10 */ 10 */
11 11
12 12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 13
14#include "ncp_fs.h" 14#include "ncp_fs.h"
15 15
16static inline void assert_server_locked(struct ncp_server *server) 16static inline void assert_server_locked(struct ncp_server *server)
17{ 17{
18 if (server->lock == 0) { 18 if (server->lock == 0) {
19 DPRINTK("ncpfs: server not locked!\n"); 19 ncp_dbg(1, "server not locked!\n");
20 } 20 }
21} 21}
22 22
@@ -75,7 +75,7 @@ static void ncp_add_pstring(struct ncp_server *server, const char *s)
75 int len = strlen(s); 75 int len = strlen(s);
76 assert_server_locked(server); 76 assert_server_locked(server);
77 if (len > 255) { 77 if (len > 255) {
78 DPRINTK("ncpfs: string too long: %s\n", s); 78 ncp_dbg(1, "string too long: %s\n", s);
79 len = 255; 79 len = 255;
80 } 80 }
81 ncp_add_byte(server, len); 81 ncp_add_byte(server, len);
@@ -225,7 +225,7 @@ int ncp_get_volume_info_with_number(struct ncp_server* server,
225 result = -EIO; 225 result = -EIO;
226 len = ncp_reply_byte(server, 29); 226 len = ncp_reply_byte(server, 29);
227 if (len > NCP_VOLNAME_LEN) { 227 if (len > NCP_VOLNAME_LEN) {
228 DPRINTK("ncpfs: volume name too long: %d\n", len); 228 ncp_dbg(1, "volume name too long: %d\n", len);
229 goto out; 229 goto out;
230 } 230 }
231 memcpy(&(target->volume_name), ncp_reply_data(server, 30), len); 231 memcpy(&(target->volume_name), ncp_reply_data(server, 30), len);
@@ -259,7 +259,7 @@ int ncp_get_directory_info(struct ncp_server* server, __u8 n,
259 result = -EIO; 259 result = -EIO;
260 len = ncp_reply_byte(server, 21); 260 len = ncp_reply_byte(server, 21);
261 if (len > NCP_VOLNAME_LEN) { 261 if (len > NCP_VOLNAME_LEN) {
262 DPRINTK("ncpfs: volume name too long: %d\n", len); 262 ncp_dbg(1, "volume name too long: %d\n", len);
263 goto out; 263 goto out;
264 } 264 }
265 memcpy(&(target->volume_name), ncp_reply_data(server, 22), len); 265 memcpy(&(target->volume_name), ncp_reply_data(server, 22), len);
@@ -295,9 +295,9 @@ ncp_make_closed(struct inode *inode)
295 err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle); 295 err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
296 296
297 if (!err) 297 if (!err)
298 PPRINTK("ncp_make_closed: volnum=%d, dirent=%u, error=%d\n", 298 ncp_vdbg("volnum=%d, dirent=%u, error=%d\n",
299 NCP_FINFO(inode)->volNumber, 299 NCP_FINFO(inode)->volNumber,
300 NCP_FINFO(inode)->dirEntNum, err); 300 NCP_FINFO(inode)->dirEntNum, err);
301 } 301 }
302 mutex_unlock(&NCP_FINFO(inode)->open_mutex); 302 mutex_unlock(&NCP_FINFO(inode)->open_mutex);
303 return err; 303 return err;
@@ -394,8 +394,7 @@ int ncp_obtain_nfs_info(struct ncp_server *server,
394 394
395 if ((result = ncp_request(server, 87)) == 0) { 395 if ((result = ncp_request(server, 87)) == 0) {
396 ncp_extract_nfs_info(ncp_reply_data(server, 0), &target->nfs); 396 ncp_extract_nfs_info(ncp_reply_data(server, 0), &target->nfs);
397 DPRINTK(KERN_DEBUG 397 ncp_dbg(1, "(%s) mode=0%o, rdev=0x%x\n",
398 "ncp_obtain_nfs_info: (%s) mode=0%o, rdev=0x%x\n",
399 target->entryName, target->nfs.mode, 398 target->entryName, target->nfs.mode,
400 target->nfs.rdev); 399 target->nfs.rdev);
401 } else { 400 } else {
@@ -425,7 +424,7 @@ int ncp_obtain_info(struct ncp_server *server, struct inode *dir, const char *pa
425 int result; 424 int result;
426 425
427 if (target == NULL) { 426 if (target == NULL) {
428 printk(KERN_ERR "ncp_obtain_info: invalid call\n"); 427 pr_err("%s: invalid call\n", __func__);
429 return -EINVAL; 428 return -EINVAL;
430 } 429 }
431 ncp_init_request(server); 430 ncp_init_request(server);
@@ -498,7 +497,7 @@ ncp_get_known_namespace(struct ncp_server *server, __u8 volume)
498 namespace = ncp_reply_data(server, 2); 497 namespace = ncp_reply_data(server, 2);
499 498
500 while (no_namespaces > 0) { 499 while (no_namespaces > 0) {
501 DPRINTK("get_namespaces: found %d on %d\n", *namespace, volume); 500 ncp_dbg(1, "found %d on %d\n", *namespace, volume);
502 501
503#ifdef CONFIG_NCPFS_NFS_NS 502#ifdef CONFIG_NCPFS_NFS_NS
504 if ((*namespace == NW_NS_NFS) && !(server->m.flags&NCP_MOUNT_NO_NFS)) 503 if ((*namespace == NW_NS_NFS) && !(server->m.flags&NCP_MOUNT_NO_NFS))
@@ -531,8 +530,7 @@ ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns)
531 if (ret_ns) 530 if (ret_ns)
532 *ret_ns = ns; 531 *ret_ns = ns;
533 532
534 DPRINTK("lookup_vol: namespace[%d] = %d\n", 533 ncp_dbg(1, "namespace[%d] = %d\n", volume, server->name_space[volume]);
535 volume, server->name_space[volume]);
536 534
537 if (server->name_space[volume] == ns) 535 if (server->name_space[volume] == ns)
538 return 0; 536 return 0;
@@ -596,7 +594,7 @@ ncp_get_volume_root(struct ncp_server *server,
596{ 594{
597 int result; 595 int result;
598 596
599 DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname); 597 ncp_dbg(1, "looking up vol %s\n", volname);
600 598
601 ncp_init_request(server); 599 ncp_init_request(server);
602 ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */ 600 ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 3a1587222c8a..471bc3d1139e 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -8,6 +8,7 @@
8 * 8 *
9 */ 9 */
10 10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11 12
12#include <linux/time.h> 13#include <linux/time.h>
13#include <linux/errno.h> 14#include <linux/errno.h>
@@ -96,11 +97,11 @@ static void ncp_req_put(struct ncp_request_reply *req)
96 kfree(req); 97 kfree(req);
97} 98}
98 99
99void ncp_tcp_data_ready(struct sock *sk, int len) 100void ncp_tcp_data_ready(struct sock *sk)
100{ 101{
101 struct ncp_server *server = sk->sk_user_data; 102 struct ncp_server *server = sk->sk_user_data;
102 103
103 server->data_ready(sk, len); 104 server->data_ready(sk);
104 schedule_work(&server->rcv.tq); 105 schedule_work(&server->rcv.tq);
105} 106}
106 107
@@ -231,7 +232,7 @@ static void __ncptcp_try_send(struct ncp_server *server)
231 return; 232 return;
232 233
233 if (result < 0) { 234 if (result < 0) {
234 printk(KERN_ERR "ncpfs: tcp: Send failed: %d\n", result); 235 pr_err("tcp: Send failed: %d\n", result);
235 __ncp_abort_request(server, rq, result); 236 __ncp_abort_request(server, rq, result);
236 return; 237 return;
237 } 238 }
@@ -332,7 +333,7 @@ static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *
332 mutex_lock(&server->rcv.creq_mutex); 333 mutex_lock(&server->rcv.creq_mutex);
333 if (!ncp_conn_valid(server)) { 334 if (!ncp_conn_valid(server)) {
334 mutex_unlock(&server->rcv.creq_mutex); 335 mutex_unlock(&server->rcv.creq_mutex);
335 printk(KERN_ERR "ncpfs: tcp: Server died\n"); 336 pr_err("tcp: Server died\n");
336 return -EIO; 337 return -EIO;
337 } 338 }
338 ncp_req_get(req); 339 ncp_req_get(req);
@@ -405,15 +406,15 @@ void ncpdgram_rcv_proc(struct work_struct *work)
405 } 406 }
406 result = _recv(sock, buf, sizeof(buf), MSG_DONTWAIT); 407 result = _recv(sock, buf, sizeof(buf), MSG_DONTWAIT);
407 if (result < 0) { 408 if (result < 0) {
408 DPRINTK("recv failed with %d\n", result); 409 ncp_dbg(1, "recv failed with %d\n", result);
409 continue; 410 continue;
410 } 411 }
411 if (result < 10) { 412 if (result < 10) {
412 DPRINTK("too short (%u) watchdog packet\n", result); 413 ncp_dbg(1, "too short (%u) watchdog packet\n", result);
413 continue; 414 continue;
414 } 415 }
415 if (buf[9] != '?') { 416 if (buf[9] != '?') {
416 DPRINTK("bad signature (%02X) in watchdog packet\n", buf[9]); 417 ncp_dbg(1, "bad signature (%02X) in watchdog packet\n", buf[9]);
417 continue; 418 continue;
418 } 419 }
419 buf[9] = 'Y'; 420 buf[9] = 'Y';
@@ -448,7 +449,7 @@ void ncpdgram_rcv_proc(struct work_struct *work)
448 result -= 8; 449 result -= 8;
449 hdrl = sock->sk->sk_family == AF_INET ? 8 : 6; 450 hdrl = sock->sk->sk_family == AF_INET ? 8 : 6;
450 if (sign_verify_reply(server, server->rxbuf + hdrl, result - hdrl, cpu_to_le32(result), server->rxbuf + result)) { 451 if (sign_verify_reply(server, server->rxbuf + hdrl, result - hdrl, cpu_to_le32(result), server->rxbuf + result)) {
451 printk(KERN_INFO "ncpfs: Signature violation\n"); 452 pr_info("Signature violation\n");
452 result = -EIO; 453 result = -EIO;
453 } 454 }
454 } 455 }
@@ -524,7 +525,7 @@ static int do_tcp_rcv(struct ncp_server *server, void *buffer, size_t len)
524 return result; 525 return result;
525 } 526 }
526 if (result > len) { 527 if (result > len) {
527 printk(KERN_ERR "ncpfs: tcp: bug in recvmsg (%u > %Zu)\n", result, len); 528 pr_err("tcp: bug in recvmsg (%u > %Zu)\n", result, len);
528 return -EIO; 529 return -EIO;
529 } 530 }
530 return result; 531 return result;
@@ -552,9 +553,9 @@ static int __ncptcp_rcv_proc(struct ncp_server *server)
552 __ncptcp_abort(server); 553 __ncptcp_abort(server);
553 } 554 }
554 if (result < 0) { 555 if (result < 0) {
555 printk(KERN_ERR "ncpfs: tcp: error in recvmsg: %d\n", result); 556 pr_err("tcp: error in recvmsg: %d\n", result);
556 } else { 557 } else {
557 DPRINTK(KERN_ERR "ncpfs: tcp: EOF\n"); 558 ncp_dbg(1, "tcp: EOF\n");
558 } 559 }
559 return -EIO; 560 return -EIO;
560 } 561 }
@@ -566,20 +567,20 @@ static int __ncptcp_rcv_proc(struct ncp_server *server)
566 switch (server->rcv.state) { 567 switch (server->rcv.state) {
567 case 0: 568 case 0:
568 if (server->rcv.buf.magic != htonl(NCP_TCP_RCVD_MAGIC)) { 569 if (server->rcv.buf.magic != htonl(NCP_TCP_RCVD_MAGIC)) {
569 printk(KERN_ERR "ncpfs: tcp: Unexpected reply type %08X\n", ntohl(server->rcv.buf.magic)); 570 pr_err("tcp: Unexpected reply type %08X\n", ntohl(server->rcv.buf.magic));
570 __ncptcp_abort(server); 571 __ncptcp_abort(server);
571 return -EIO; 572 return -EIO;
572 } 573 }
573 datalen = ntohl(server->rcv.buf.len) & 0x0FFFFFFF; 574 datalen = ntohl(server->rcv.buf.len) & 0x0FFFFFFF;
574 if (datalen < 10) { 575 if (datalen < 10) {
575 printk(KERN_ERR "ncpfs: tcp: Unexpected reply len %d\n", datalen); 576 pr_err("tcp: Unexpected reply len %d\n", datalen);
576 __ncptcp_abort(server); 577 __ncptcp_abort(server);
577 return -EIO; 578 return -EIO;
578 } 579 }
579#ifdef CONFIG_NCPFS_PACKET_SIGNING 580#ifdef CONFIG_NCPFS_PACKET_SIGNING
580 if (server->sign_active) { 581 if (server->sign_active) {
581 if (datalen < 18) { 582 if (datalen < 18) {
582 printk(KERN_ERR "ncpfs: tcp: Unexpected reply len %d\n", datalen); 583 pr_err("tcp: Unexpected reply len %d\n", datalen);
583 __ncptcp_abort(server); 584 __ncptcp_abort(server);
584 return -EIO; 585 return -EIO;
585 } 586 }
@@ -604,7 +605,7 @@ cont:;
604 server->rcv.len = datalen - 10; 605 server->rcv.len = datalen - 10;
605 break; 606 break;
606 } 607 }
607 DPRINTK("ncpfs: tcp: Unexpected NCP type %02X\n", type); 608 ncp_dbg(1, "tcp: Unexpected NCP type %02X\n", type);
608skipdata2:; 609skipdata2:;
609 server->rcv.state = 2; 610 server->rcv.state = 2;
610skipdata:; 611skipdata:;
@@ -614,11 +615,11 @@ skipdata:;
614 } 615 }
615 req = server->rcv.creq; 616 req = server->rcv.creq;
616 if (!req) { 617 if (!req) {
617 DPRINTK(KERN_ERR "ncpfs: Reply without appropriate request\n"); 618 ncp_dbg(1, "Reply without appropriate request\n");
618 goto skipdata2; 619 goto skipdata2;
619 } 620 }
620 if (datalen > req->datalen + 8) { 621 if (datalen > req->datalen + 8) {
621 printk(KERN_ERR "ncpfs: tcp: Unexpected reply len %d (expected at most %Zd)\n", datalen, req->datalen + 8); 622 pr_err("tcp: Unexpected reply len %d (expected at most %Zd)\n", datalen, req->datalen + 8);
622 server->rcv.state = 3; 623 server->rcv.state = 3;
623 goto skipdata; 624 goto skipdata;
624 } 625 }
@@ -638,12 +639,12 @@ skipdata:;
638 req = server->rcv.creq; 639 req = server->rcv.creq;
639 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) { 640 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) {
640 if (((struct ncp_reply_header*)server->rxbuf)->sequence != server->sequence) { 641 if (((struct ncp_reply_header*)server->rxbuf)->sequence != server->sequence) {
641 printk(KERN_ERR "ncpfs: tcp: Bad sequence number\n"); 642 pr_err("tcp: Bad sequence number\n");
642 __ncp_abort_request(server, req, -EIO); 643 __ncp_abort_request(server, req, -EIO);
643 return -EIO; 644 return -EIO;
644 } 645 }
645 if ((((struct ncp_reply_header*)server->rxbuf)->conn_low | (((struct ncp_reply_header*)server->rxbuf)->conn_high << 8)) != server->connection) { 646 if ((((struct ncp_reply_header*)server->rxbuf)->conn_low | (((struct ncp_reply_header*)server->rxbuf)->conn_high << 8)) != server->connection) {
646 printk(KERN_ERR "ncpfs: tcp: Connection number mismatch\n"); 647 pr_err("tcp: Connection number mismatch\n");
647 __ncp_abort_request(server, req, -EIO); 648 __ncp_abort_request(server, req, -EIO);
648 return -EIO; 649 return -EIO;
649 } 650 }
@@ -651,7 +652,7 @@ skipdata:;
651#ifdef CONFIG_NCPFS_PACKET_SIGNING 652#ifdef CONFIG_NCPFS_PACKET_SIGNING
652 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { 653 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) {
653 if (sign_verify_reply(server, server->rxbuf + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16), &server->rcv.buf.type)) { 654 if (sign_verify_reply(server, server->rxbuf + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16), &server->rcv.buf.type)) {
654 printk(KERN_ERR "ncpfs: tcp: Signature violation\n"); 655 pr_err("tcp: Signature violation\n");
655 __ncp_abort_request(server, req, -EIO); 656 __ncp_abort_request(server, req, -EIO);
656 return -EIO; 657 return -EIO;
657 } 658 }
@@ -742,7 +743,7 @@ static int ncp_do_request(struct ncp_server *server, int size,
742 int result; 743 int result;
743 744
744 if (server->lock == 0) { 745 if (server->lock == 0) {
745 printk(KERN_ERR "ncpfs: Server not locked!\n"); 746 pr_err("Server not locked!\n");
746 return -EIO; 747 return -EIO;
747 } 748 }
748 if (!ncp_conn_valid(server)) { 749 if (!ncp_conn_valid(server)) {
@@ -781,7 +782,7 @@ static int ncp_do_request(struct ncp_server *server, int size,
781 spin_unlock_irqrestore(&current->sighand->siglock, flags); 782 spin_unlock_irqrestore(&current->sighand->siglock, flags);
782 } 783 }
783 784
784 DDPRINTK("do_ncp_rpc_call returned %d\n", result); 785 ncp_dbg(2, "do_ncp_rpc_call returned %d\n", result);
785 786
786 return result; 787 return result;
787} 788}
@@ -811,7 +812,7 @@ int ncp_request2(struct ncp_server *server, int function,
811 812
812 result = ncp_do_request(server, server->current_size, reply, size); 813 result = ncp_do_request(server, server->current_size, reply, size);
813 if (result < 0) { 814 if (result < 0) {
814 DPRINTK("ncp_request_error: %d\n", result); 815 ncp_dbg(1, "ncp_request_error: %d\n", result);
815 goto out; 816 goto out;
816 } 817 }
817 server->completion = reply->completion_code; 818 server->completion = reply->completion_code;
@@ -822,7 +823,7 @@ int ncp_request2(struct ncp_server *server, int function,
822 result = reply->completion_code; 823 result = reply->completion_code;
823 824
824 if (result != 0) 825 if (result != 0)
825 PPRINTK("ncp_request: completion code=%x\n", result); 826 ncp_vdbg("completion code=%x\n", result);
826out: 827out:
827 return result; 828 return result;
828} 829}
@@ -865,14 +866,14 @@ void ncp_lock_server(struct ncp_server *server)
865{ 866{
866 mutex_lock(&server->mutex); 867 mutex_lock(&server->mutex);
867 if (server->lock) 868 if (server->lock)
868 printk(KERN_WARNING "ncp_lock_server: was locked!\n"); 869 pr_warn("%s: was locked!\n", __func__);
869 server->lock = 1; 870 server->lock = 1;
870} 871}
871 872
872void ncp_unlock_server(struct ncp_server *server) 873void ncp_unlock_server(struct ncp_server *server)
873{ 874{
874 if (!server->lock) { 875 if (!server->lock) {
875 printk(KERN_WARNING "ncp_unlock_server: was not locked!\n"); 876 pr_warn("%s: was not locked!\n", __func__);
876 return; 877 return;
877 } 878 }
878 server->lock = 0; 879 server->lock = 0;
diff --git a/fs/ncpfs/symlink.c b/fs/ncpfs/symlink.c
index 52439ddc8de0..1a63bfdb4a65 100644
--- a/fs/ncpfs/symlink.c
+++ b/fs/ncpfs/symlink.c
@@ -112,7 +112,7 @@ int ncp_symlink(struct inode *dir, struct dentry *dentry, const char *symname) {
112 __le32 attr; 112 __le32 attr;
113 unsigned int hdr; 113 unsigned int hdr;
114 114
115 DPRINTK("ncp_symlink(dir=%p,dentry=%p,symname=%s)\n",dir,dentry,symname); 115 ncp_dbg(1, "dir=%p, dentry=%p, symname=%s\n", dir, dentry, symname);
116 116
117 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) 117 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber))
118 kludge = 0; 118 kludge = 0;
diff --git a/fs/nfsd/acl.h b/fs/nfsd/acl.h
index a812fd1b92a4..b481e1f5eecc 100644
--- a/fs/nfsd/acl.h
+++ b/fs/nfsd/acl.h
@@ -39,9 +39,13 @@ struct nfs4_acl;
39struct svc_fh; 39struct svc_fh;
40struct svc_rqst; 40struct svc_rqst;
41 41
42/* Maximum ACL we'll accept from client; chosen (somewhat arbitrarily) to 42/*
43 * fit in a page: */ 43 * Maximum ACL we'll accept from a client; chosen (somewhat
44#define NFS4_ACL_MAX 170 44 * arbitrarily) so that kmalloc'ing the ACL shouldn't require a
45 * high-order allocation. This allows 204 ACEs on x86_64:
46 */
47#define NFS4_ACL_MAX ((PAGE_SIZE - sizeof(struct nfs4_acl)) \
48 / sizeof(struct nfs4_ace))
45 49
46struct nfs4_acl *nfs4_acl_new(int); 50struct nfs4_acl *nfs4_acl_new(int);
47int nfs4_acl_get_whotype(char *, u32); 51int nfs4_acl_get_whotype(char *, u32);
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index d190e33d0ec2..6f3f392d48af 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -542,7 +542,10 @@ posix_state_to_acl(struct posix_acl_state *state, unsigned int flags)
542 * up setting a 3-element effective posix ACL with all 542 * up setting a 3-element effective posix ACL with all
543 * permissions zero. 543 * permissions zero.
544 */ 544 */
545 nace = 4 + state->users->n + state->groups->n; 545 if (!state->users->n && !state->groups->n)
546 nace = 3;
547 else /* Note we also include a MASK ACE in this case: */
548 nace = 4 + state->users->n + state->groups->n;
546 pacl = posix_acl_alloc(nace, GFP_KERNEL); 549 pacl = posix_acl_alloc(nace, GFP_KERNEL);
547 if (!pacl) 550 if (!pacl)
548 return ERR_PTR(-ENOMEM); 551 return ERR_PTR(-ENOMEM);
@@ -586,9 +589,11 @@ posix_state_to_acl(struct posix_acl_state *state, unsigned int flags)
586 add_to_mask(state, &state->groups->aces[i].perms); 589 add_to_mask(state, &state->groups->aces[i].perms);
587 } 590 }
588 591
589 pace++; 592 if (!state->users->n && !state->groups->n) {
590 pace->e_tag = ACL_MASK; 593 pace++;
591 low_mode_from_nfs4(state->mask.allow, &pace->e_perm, flags); 594 pace->e_tag = ACL_MASK;
595 low_mode_from_nfs4(state->mask.allow, &pace->e_perm, flags);
596 }
592 597
593 pace++; 598 pace++;
594 pace->e_tag = ACL_OTHER; 599 pace->e_tag = ACL_OTHER;
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 7f05cd140de3..39c8ef875f91 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/sunrpc/clnt.h> 34#include <linux/sunrpc/clnt.h>
35#include <linux/sunrpc/xprt.h>
35#include <linux/sunrpc/svc_xprt.h> 36#include <linux/sunrpc/svc_xprt.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
37#include "nfsd.h" 38#include "nfsd.h"
@@ -635,6 +636,22 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
635 } 636 }
636} 637}
637 638
639static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
640{
641 struct rpc_xprt *xprt;
642
643 if (args->protocol != XPRT_TRANSPORT_BC_TCP)
644 return rpc_create(args);
645
646 xprt = args->bc_xprt->xpt_bc_xprt;
647 if (xprt) {
648 xprt_get(xprt);
649 return rpc_create_xprt(args, xprt);
650 }
651
652 return rpc_create(args);
653}
654
638static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) 655static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
639{ 656{
640 struct rpc_timeout timeparms = { 657 struct rpc_timeout timeparms = {
@@ -674,7 +691,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
674 args.authflavor = ses->se_cb_sec.flavor; 691 args.authflavor = ses->se_cb_sec.flavor;
675 } 692 }
676 /* Create RPC client */ 693 /* Create RPC client */
677 client = rpc_create(&args); 694 client = create_backchannel_client(&args);
678 if (IS_ERR(client)) { 695 if (IS_ERR(client)) {
679 dprintk("NFSD: couldn't create callback client: %ld\n", 696 dprintk("NFSD: couldn't create callback client: %ld\n",
680 PTR_ERR(client)); 697 PTR_ERR(client));
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 82189b208af3..d543222babf3 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1273,6 +1273,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
1273 struct nfsd4_op *op; 1273 struct nfsd4_op *op;
1274 struct nfsd4_operation *opdesc; 1274 struct nfsd4_operation *opdesc;
1275 struct nfsd4_compound_state *cstate = &resp->cstate; 1275 struct nfsd4_compound_state *cstate = &resp->cstate;
1276 struct svc_fh *current_fh = &cstate->current_fh;
1277 struct svc_fh *save_fh = &cstate->save_fh;
1276 int slack_bytes; 1278 int slack_bytes;
1277 u32 plen = 0; 1279 u32 plen = 0;
1278 __be32 status; 1280 __be32 status;
@@ -1288,11 +1290,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
1288 resp->tag = args->tag; 1290 resp->tag = args->tag;
1289 resp->opcnt = 0; 1291 resp->opcnt = 0;
1290 resp->rqstp = rqstp; 1292 resp->rqstp = rqstp;
1291 resp->cstate.minorversion = args->minorversion; 1293 cstate->minorversion = args->minorversion;
1292 resp->cstate.replay_owner = NULL; 1294 cstate->replay_owner = NULL;
1293 resp->cstate.session = NULL; 1295 cstate->session = NULL;
1294 fh_init(&resp->cstate.current_fh, NFS4_FHSIZE); 1296 fh_init(current_fh, NFS4_FHSIZE);
1295 fh_init(&resp->cstate.save_fh, NFS4_FHSIZE); 1297 fh_init(save_fh, NFS4_FHSIZE);
1296 /* 1298 /*
1297 * Don't use the deferral mechanism for NFSv4; compounds make it 1299 * Don't use the deferral mechanism for NFSv4; compounds make it
1298 * too hard to avoid non-idempotency problems. 1300 * too hard to avoid non-idempotency problems.
@@ -1345,20 +1347,28 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
1345 1347
1346 opdesc = OPDESC(op); 1348 opdesc = OPDESC(op);
1347 1349
1348 if (!cstate->current_fh.fh_dentry) { 1350 if (!current_fh->fh_dentry) {
1349 if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) { 1351 if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
1350 op->status = nfserr_nofilehandle; 1352 op->status = nfserr_nofilehandle;
1351 goto encode_op; 1353 goto encode_op;
1352 } 1354 }
1353 } else if (cstate->current_fh.fh_export->ex_fslocs.migrated && 1355 } else if (current_fh->fh_export->ex_fslocs.migrated &&
1354 !(opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) { 1356 !(opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) {
1355 op->status = nfserr_moved; 1357 op->status = nfserr_moved;
1356 goto encode_op; 1358 goto encode_op;
1357 } 1359 }
1358 1360
1361 fh_clear_wcc(current_fh);
1362
1359 /* If op is non-idempotent */ 1363 /* If op is non-idempotent */
1360 if (opdesc->op_flags & OP_MODIFIES_SOMETHING) { 1364 if (opdesc->op_flags & OP_MODIFIES_SOMETHING) {
1361 plen = opdesc->op_rsize_bop(rqstp, op); 1365 plen = opdesc->op_rsize_bop(rqstp, op);
1366 /*
1367 * If there's still another operation, make sure
1368 * we'll have space to at least encode an error:
1369 */
1370 if (resp->opcnt < args->opcnt)
1371 plen += COMPOUND_ERR_SLACK_SPACE;
1362 op->status = nfsd4_check_resp_size(resp, plen); 1372 op->status = nfsd4_check_resp_size(resp, plen);
1363 } 1373 }
1364 1374
@@ -1377,12 +1387,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
1377 clear_current_stateid(cstate); 1387 clear_current_stateid(cstate);
1378 1388
1379 if (need_wrongsec_check(rqstp)) 1389 if (need_wrongsec_check(rqstp))
1380 op->status = check_nfsd_access(cstate->current_fh.fh_export, rqstp); 1390 op->status = check_nfsd_access(current_fh->fh_export, rqstp);
1381 } 1391 }
1382 1392
1383encode_op: 1393encode_op:
1384 /* Only from SEQUENCE */ 1394 /* Only from SEQUENCE */
1385 if (resp->cstate.status == nfserr_replay_cache) { 1395 if (cstate->status == nfserr_replay_cache) {
1386 dprintk("%s NFS4.1 replay from cache\n", __func__); 1396 dprintk("%s NFS4.1 replay from cache\n", __func__);
1387 status = op->status; 1397 status = op->status;
1388 goto out; 1398 goto out;
@@ -1411,10 +1421,10 @@ encode_op:
1411 nfsd4_increment_op_stats(op->opnum); 1421 nfsd4_increment_op_stats(op->opnum);
1412 } 1422 }
1413 1423
1414 resp->cstate.status = status; 1424 cstate->status = status;
1415 fh_put(&resp->cstate.current_fh); 1425 fh_put(current_fh);
1416 fh_put(&resp->cstate.save_fh); 1426 fh_put(save_fh);
1417 BUG_ON(resp->cstate.replay_owner); 1427 BUG_ON(cstate->replay_owner);
1418out: 1428out:
1419 /* Reset deferral mechanism for RPC deferrals */ 1429 /* Reset deferral mechanism for RPC deferrals */
1420 rqstp->rq_usedeferral = 1; 1430 rqstp->rq_usedeferral = 1;
@@ -1523,7 +1533,8 @@ static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *o
1523 1533
1524static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1534static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1525{ 1535{
1526 return (op_encode_hdr_size + 2 + 1024) * sizeof(__be32); 1536 return (op_encode_hdr_size + 2 + XDR_QUADLEN(NFS4_VERIFIER_SIZE)) *
1537 sizeof(__be32);
1527} 1538}
1528 1539
1529static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1540static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index d5d070fbeb35..3ba65979a3cd 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1538,7 +1538,7 @@ out_err:
1538} 1538}
1539 1539
1540/* 1540/*
1541 * Cache a reply. nfsd4_check_drc_limit() has bounded the cache size. 1541 * Cache a reply. nfsd4_check_resp_size() has bounded the cache size.
1542 */ 1542 */
1543void 1543void
1544nfsd4_store_cache_entry(struct nfsd4_compoundres *resp) 1544nfsd4_store_cache_entry(struct nfsd4_compoundres *resp)
@@ -1596,7 +1596,7 @@ nfsd4_enc_sequence_replay(struct nfsd4_compoundargs *args,
1596 * The sequence operation is not cached because we can use the slot and 1596 * The sequence operation is not cached because we can use the slot and
1597 * session values. 1597 * session values.
1598 */ 1598 */
1599__be32 1599static __be32
1600nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp, 1600nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
1601 struct nfsd4_sequence *seq) 1601 struct nfsd4_sequence *seq)
1602{ 1602{
@@ -1605,9 +1605,8 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
1605 1605
1606 dprintk("--> %s slot %p\n", __func__, slot); 1606 dprintk("--> %s slot %p\n", __func__, slot);
1607 1607
1608 /* Either returns 0 or nfserr_retry_uncached */
1609 status = nfsd4_enc_sequence_replay(resp->rqstp->rq_argp, resp); 1608 status = nfsd4_enc_sequence_replay(resp->rqstp->rq_argp, resp);
1610 if (status == nfserr_retry_uncached_rep) 1609 if (status)
1611 return status; 1610 return status;
1612 1611
1613 /* The sequence operation has been encoded, cstate->datap set. */ 1612 /* The sequence operation has been encoded, cstate->datap set. */
@@ -2287,7 +2286,8 @@ out:
2287 if (!list_empty(&clp->cl_revoked)) 2286 if (!list_empty(&clp->cl_revoked))
2288 seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED; 2287 seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED;
2289out_no_session: 2288out_no_session:
2290 kfree(conn); 2289 if (conn)
2290 free_conn(conn);
2291 spin_unlock(&nn->client_lock); 2291 spin_unlock(&nn->client_lock);
2292 return status; 2292 return status;
2293out_put_session: 2293out_put_session:
@@ -3627,8 +3627,11 @@ static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask,
3627 return nfserr_bad_stateid; 3627 return nfserr_bad_stateid;
3628 status = lookup_clientid(&stateid->si_opaque.so_clid, sessions, 3628 status = lookup_clientid(&stateid->si_opaque.so_clid, sessions,
3629 nn, &cl); 3629 nn, &cl);
3630 if (status == nfserr_stale_clientid) 3630 if (status == nfserr_stale_clientid) {
3631 if (sessions)
3632 return nfserr_bad_stateid;
3631 return nfserr_stale_stateid; 3633 return nfserr_stale_stateid;
3634 }
3632 if (status) 3635 if (status)
3633 return status; 3636 return status;
3634 *s = find_stateid_by_type(cl, stateid, typemask); 3637 *s = find_stateid_by_type(cl, stateid, typemask);
@@ -5062,7 +5065,6 @@ nfs4_state_destroy_net(struct net *net)
5062 int i; 5065 int i;
5063 struct nfs4_client *clp = NULL; 5066 struct nfs4_client *clp = NULL;
5064 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 5067 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
5065 struct rb_node *node, *tmp;
5066 5068
5067 for (i = 0; i < CLIENT_HASH_SIZE; i++) { 5069 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
5068 while (!list_empty(&nn->conf_id_hashtbl[i])) { 5070 while (!list_empty(&nn->conf_id_hashtbl[i])) {
@@ -5071,13 +5073,11 @@ nfs4_state_destroy_net(struct net *net)
5071 } 5073 }
5072 } 5074 }
5073 5075
5074 node = rb_first(&nn->unconf_name_tree); 5076 for (i = 0; i < CLIENT_HASH_SIZE; i++) {
5075 while (node != NULL) { 5077 while (!list_empty(&nn->unconf_id_hashtbl[i])) {
5076 tmp = node; 5078 clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash);
5077 node = rb_next(tmp); 5079 destroy_client(clp);
5078 clp = rb_entry(tmp, struct nfs4_client, cl_namenode); 5080 }
5079 rb_erase(tmp, &nn->unconf_name_tree);
5080 destroy_client(clp);
5081 } 5081 }
5082 5082
5083 kfree(nn->sessionid_hashtbl); 5083 kfree(nn->sessionid_hashtbl);
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 63f2395c57ed..2723c1badd01 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -294,7 +294,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
294 READ32(nace); 294 READ32(nace);
295 295
296 if (nace > NFS4_ACL_MAX) 296 if (nace > NFS4_ACL_MAX)
297 return nfserr_resource; 297 return nfserr_fbig;
298 298
299 *acl = nfs4_acl_new(nace); 299 *acl = nfs4_acl_new(nace);
300 if (*acl == NULL) 300 if (*acl == NULL)
@@ -1222,7 +1222,6 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
1222 } 1222 }
1223 write->wr_head.iov_base = p; 1223 write->wr_head.iov_base = p;
1224 write->wr_head.iov_len = avail; 1224 write->wr_head.iov_len = avail;
1225 WARN_ON(avail != (XDR_QUADLEN(avail) << 2));
1226 write->wr_pagelist = argp->pagelist; 1225 write->wr_pagelist = argp->pagelist;
1227 1226
1228 len = XDR_QUADLEN(write->wr_buflen) << 2; 1227 len = XDR_QUADLEN(write->wr_buflen) << 2;
@@ -2483,6 +2482,8 @@ out_acl:
2483 goto out; 2482 goto out;
2484 } 2483 }
2485 if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { 2484 if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) {
2485 if ((buflen -= 16) < 0)
2486 goto out_resource;
2486 WRITE32(3); 2487 WRITE32(3);
2487 WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD0); 2488 WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD0);
2488 WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD1); 2489 WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD1);
@@ -2499,8 +2500,10 @@ out:
2499 security_release_secctx(context, contextlen); 2500 security_release_secctx(context, contextlen);
2500#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ 2501#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
2501 kfree(acl); 2502 kfree(acl);
2502 if (tempfh) 2503 if (tempfh) {
2503 fh_put(tempfh); 2504 fh_put(tempfh);
2505 kfree(tempfh);
2506 }
2504 return status; 2507 return status;
2505out_nfserr: 2508out_nfserr:
2506 status = nfserrno(err); 2509 status = nfserrno(err);
@@ -3471,6 +3474,9 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr,
3471 struct nfsd4_test_stateid_id *stateid, *next; 3474 struct nfsd4_test_stateid_id *stateid, *next;
3472 __be32 *p; 3475 __be32 *p;
3473 3476
3477 if (nfserr)
3478 return nfserr;
3479
3474 RESERVE_SPACE(4 + (4 * test_stateid->ts_num_ids)); 3480 RESERVE_SPACE(4 + (4 * test_stateid->ts_num_ids));
3475 *p++ = htonl(test_stateid->ts_num_ids); 3481 *p++ = htonl(test_stateid->ts_num_ids);
3476 3482
@@ -3579,8 +3585,6 @@ __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 pad)
3579 return 0; 3585 return 0;
3580 3586
3581 session = resp->cstate.session; 3587 session = resp->cstate.session;
3582 if (session == NULL)
3583 return 0;
3584 3588
3585 if (xb->page_len == 0) { 3589 if (xb->page_len == 0) {
3586 length = (char *)resp->p - (char *)xb->head[0].iov_base + pad; 3590 length = (char *)resp->p - (char *)xb->head[0].iov_base + pad;
@@ -3620,9 +3624,17 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
3620 BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) || 3624 BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) ||
3621 !nfsd4_enc_ops[op->opnum]); 3625 !nfsd4_enc_ops[op->opnum]);
3622 op->status = nfsd4_enc_ops[op->opnum](resp, op->status, &op->u); 3626 op->status = nfsd4_enc_ops[op->opnum](resp, op->status, &op->u);
3623 /* nfsd4_check_drc_limit guarantees enough room for error status */ 3627 /* nfsd4_check_resp_size guarantees enough room for error status */
3624 if (!op->status) 3628 if (!op->status)
3625 op->status = nfsd4_check_resp_size(resp, 0); 3629 op->status = nfsd4_check_resp_size(resp, 0);
3630 if (op->status == nfserr_resource && nfsd4_has_session(&resp->cstate)) {
3631 struct nfsd4_slot *slot = resp->cstate.slot;
3632
3633 if (slot->sl_flags & NFSD4_SLOT_CACHETHIS)
3634 op->status = nfserr_rep_too_big_to_cache;
3635 else
3636 op->status = nfserr_rep_too_big;
3637 }
3626 if (so) { 3638 if (so) {
3627 so->so_replay.rp_status = op->status; 3639 so->so_replay.rp_status = op->status;
3628 so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); 3640 so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1);
@@ -3691,6 +3703,12 @@ int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp)
3691int 3703int
3692nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundargs *args) 3704nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundargs *args)
3693{ 3705{
3706 if (rqstp->rq_arg.head[0].iov_len % 4) {
3707 /* client is nuts */
3708 dprintk("%s: compound not properly padded! (peeraddr=%pISc xid=0x%x)",
3709 __func__, svc_addr(rqstp), be32_to_cpu(rqstp->rq_xid));
3710 return 0;
3711 }
3694 args->p = p; 3712 args->p = p;
3695 args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len; 3713 args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len;
3696 args->pagelist = rqstp->rq_arg.pages; 3714 args->pagelist = rqstp->rq_arg.pages;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 7f555179bf81..f34d9de802ab 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -699,6 +699,11 @@ static ssize_t __write_ports_addfd(char *buf, struct net *net)
699 if (err != 0 || fd < 0) 699 if (err != 0 || fd < 0)
700 return -EINVAL; 700 return -EINVAL;
701 701
702 if (svc_alien_sock(net, fd)) {
703 printk(KERN_ERR "%s: socket net is different to NFSd's one\n", __func__);
704 return -EINVAL;
705 }
706
702 err = nfsd_create_serv(net); 707 err = nfsd_create_serv(net);
703 if (err != 0) 708 if (err != 0)
704 return err; 709 return err;
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 30f34ab02137..479eb681c27c 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -282,7 +282,7 @@ void nfsd_lockd_shutdown(void);
282 * reason. 282 * reason.
283 */ 283 */
284#define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */ 284#define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */
285#define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */ 285#define COMPOUND_ERR_SLACK_SPACE 16 /* OP_SETATTR */
286 286
287#define NFSD_LAUNDROMAT_MINTIMEOUT 1 /* seconds */ 287#define NFSD_LAUNDROMAT_MINTIMEOUT 1 /* seconds */
288 288
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
index 4775bc4896c8..ad67964d0bb1 100644
--- a/fs/nfsd/nfsfh.h
+++ b/fs/nfsd/nfsfh.h
@@ -133,6 +133,17 @@ fh_init(struct svc_fh *fhp, int maxsize)
133 133
134#ifdef CONFIG_NFSD_V3 134#ifdef CONFIG_NFSD_V3
135/* 135/*
136 * The wcc data stored in current_fh should be cleared
137 * between compound ops.
138 */
139static inline void
140fh_clear_wcc(struct svc_fh *fhp)
141{
142 fhp->fh_post_saved = 0;
143 fhp->fh_pre_saved = 0;
144}
145
146/*
136 * Fill in the pre_op attr for the wcc data 147 * Fill in the pre_op attr for the wcc data
137 */ 148 */
138static inline void 149static inline void
@@ -152,7 +163,8 @@ fill_pre_wcc(struct svc_fh *fhp)
152 163
153extern void fill_post_wcc(struct svc_fh *); 164extern void fill_post_wcc(struct svc_fh *);
154#else 165#else
155#define fill_pre_wcc(ignored) 166#define fh_clear_wcc(ignored)
167#define fill_pre_wcc(ignored)
156#define fill_post_wcc(notused) 168#define fill_post_wcc(notused)
157#endif /* CONFIG_NFSD_V3 */ 169#endif /* CONFIG_NFSD_V3 */
158 170
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index b17d93214d01..9c769a47ac5a 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -152,7 +152,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
152 type = (stat->mode & S_IFMT); 152 type = (stat->mode & S_IFMT);
153 153
154 *p++ = htonl(nfs_ftypes[type >> 12]); 154 *p++ = htonl(nfs_ftypes[type >> 12]);
155 *p++ = htonl((u32) (stat->mode & S_IALLUGO)); 155 *p++ = htonl((u32) stat->mode);
156 *p++ = htonl((u32) stat->nlink); 156 *p++ = htonl((u32) stat->nlink);
157 *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid)); 157 *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
158 *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid)); 158 *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 915808b36df7..16f0673a423c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -404,6 +404,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
404 umode_t ftype = 0; 404 umode_t ftype = 0;
405 __be32 err; 405 __be32 err;
406 int host_err; 406 int host_err;
407 bool get_write_count;
407 int size_change = 0; 408 int size_change = 0;
408 409
409 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) 410 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
@@ -411,10 +412,18 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
411 if (iap->ia_valid & ATTR_SIZE) 412 if (iap->ia_valid & ATTR_SIZE)
412 ftype = S_IFREG; 413 ftype = S_IFREG;
413 414
415 /* Callers that do fh_verify should do the fh_want_write: */
416 get_write_count = !fhp->fh_dentry;
417
414 /* Get inode */ 418 /* Get inode */
415 err = fh_verify(rqstp, fhp, ftype, accmode); 419 err = fh_verify(rqstp, fhp, ftype, accmode);
416 if (err) 420 if (err)
417 goto out; 421 goto out;
422 if (get_write_count) {
423 host_err = fh_want_write(fhp);
424 if (host_err)
425 return nfserrno(host_err);
426 }
418 427
419 dentry = fhp->fh_dentry; 428 dentry = fhp->fh_dentry;
420 inode = dentry->d_inode; 429 inode = dentry->d_inode;
@@ -1706,10 +1715,10 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1706 dput(odentry); 1715 dput(odentry);
1707 out_nfserr: 1716 out_nfserr:
1708 err = nfserrno(host_err); 1717 err = nfserrno(host_err);
1709 1718 /*
1710 /* we cannot reply on fh_unlock on the two filehandles, 1719 * We cannot rely on fh_unlock on the two filehandles,
1711 * as that would do the wrong thing if the two directories 1720 * as that would do the wrong thing if the two directories
1712 * were the same, so again we do it by hand 1721 * were the same, so again we do it by hand.
1713 */ 1722 */
1714 fill_post_wcc(ffhp); 1723 fill_post_wcc(ffhp);
1715 fill_post_wcc(tfhp); 1724 fill_post_wcc(tfhp);
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index d278a0d03496..5ea7df305083 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -574,8 +574,6 @@ extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
574 struct nfsd4_compound_state *, 574 struct nfsd4_compound_state *,
575 struct nfsd4_setclientid_confirm *setclientid_confirm); 575 struct nfsd4_setclientid_confirm *setclientid_confirm);
576extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp); 576extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp);
577extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
578 struct nfsd4_sequence *seq);
579extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp, 577extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
580 struct nfsd4_compound_state *, struct nfsd4_exchange_id *); 578 struct nfsd4_compound_state *, struct nfsd4_exchange_id *);
581extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_backchannel_ctl *); 579extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_backchannel_ctl *);
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 9d8153ebacfb..f47af5e6e230 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1704,8 +1704,6 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1704 iput(bvi); 1704 iput(bvi);
1705skip_large_index_stuff: 1705skip_large_index_stuff:
1706 /* Setup the operations for this index inode. */ 1706 /* Setup the operations for this index inode. */
1707 vi->i_op = NULL;
1708 vi->i_fop = NULL;
1709 vi->i_mapping->a_ops = &ntfs_mst_aops; 1707 vi->i_mapping->a_ops = &ntfs_mst_aops;
1710 vi->i_blocks = ni->allocated_size >> 9; 1708 vi->i_blocks = ni->allocated_size >> 9;
1711 /* 1709 /*
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index eb649d23a4de..c6b90e670389 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -137,7 +137,7 @@ static int o2net_sys_err_translations[O2NET_ERR_MAX] =
137static void o2net_sc_connect_completed(struct work_struct *work); 137static void o2net_sc_connect_completed(struct work_struct *work);
138static void o2net_rx_until_empty(struct work_struct *work); 138static void o2net_rx_until_empty(struct work_struct *work);
139static void o2net_shutdown_sc(struct work_struct *work); 139static void o2net_shutdown_sc(struct work_struct *work);
140static void o2net_listen_data_ready(struct sock *sk, int bytes); 140static void o2net_listen_data_ready(struct sock *sk);
141static void o2net_sc_send_keep_req(struct work_struct *work); 141static void o2net_sc_send_keep_req(struct work_struct *work);
142static void o2net_idle_timer(unsigned long data); 142static void o2net_idle_timer(unsigned long data);
143static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 143static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
@@ -597,9 +597,9 @@ static void o2net_set_nn_state(struct o2net_node *nn,
597} 597}
598 598
599/* see o2net_register_callbacks() */ 599/* see o2net_register_callbacks() */
600static void o2net_data_ready(struct sock *sk, int bytes) 600static void o2net_data_ready(struct sock *sk)
601{ 601{
602 void (*ready)(struct sock *sk, int bytes); 602 void (*ready)(struct sock *sk);
603 603
604 read_lock(&sk->sk_callback_lock); 604 read_lock(&sk->sk_callback_lock);
605 if (sk->sk_user_data) { 605 if (sk->sk_user_data) {
@@ -613,7 +613,7 @@ static void o2net_data_ready(struct sock *sk, int bytes)
613 } 613 }
614 read_unlock(&sk->sk_callback_lock); 614 read_unlock(&sk->sk_callback_lock);
615 615
616 ready(sk, bytes); 616 ready(sk);
617} 617}
618 618
619/* see o2net_register_callbacks() */ 619/* see o2net_register_callbacks() */
@@ -916,57 +916,30 @@ static struct o2net_msg_handler *o2net_handler_get(u32 msg_type, u32 key)
916 916
917static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len) 917static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len)
918{ 918{
919 int ret; 919 struct kvec vec = { .iov_len = len, .iov_base = data, };
920 mm_segment_t oldfs; 920 struct msghdr msg = { .msg_flags = MSG_DONTWAIT, };
921 struct kvec vec = { 921 return kernel_recvmsg(sock, &msg, &vec, 1, len, msg.msg_flags);
922 .iov_len = len,
923 .iov_base = data,
924 };
925 struct msghdr msg = {
926 .msg_iovlen = 1,
927 .msg_iov = (struct iovec *)&vec,
928 .msg_flags = MSG_DONTWAIT,
929 };
930
931 oldfs = get_fs();
932 set_fs(get_ds());
933 ret = sock_recvmsg(sock, &msg, len, msg.msg_flags);
934 set_fs(oldfs);
935
936 return ret;
937} 922}
938 923
939static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, 924static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec,
940 size_t veclen, size_t total) 925 size_t veclen, size_t total)
941{ 926{
942 int ret; 927 int ret;
943 mm_segment_t oldfs; 928 struct msghdr msg;
944 struct msghdr msg = {
945 .msg_iov = (struct iovec *)vec,
946 .msg_iovlen = veclen,
947 };
948 929
949 if (sock == NULL) { 930 if (sock == NULL) {
950 ret = -EINVAL; 931 ret = -EINVAL;
951 goto out; 932 goto out;
952 } 933 }
953 934
954 oldfs = get_fs(); 935 ret = kernel_sendmsg(sock, &msg, vec, veclen, total);
955 set_fs(get_ds()); 936 if (likely(ret == total))
956 ret = sock_sendmsg(sock, &msg, total); 937 return 0;
957 set_fs(oldfs); 938 mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, total);
958 if (ret != total) { 939 if (ret >= 0)
959 mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, 940 ret = -EPIPE; /* should be smarter, I bet */
960 total);
961 if (ret >= 0)
962 ret = -EPIPE; /* should be smarter, I bet */
963 goto out;
964 }
965
966 ret = 0;
967out: 941out:
968 if (ret < 0) 942 mlog(0, "returning error: %d\n", ret);
969 mlog(0, "returning error: %d\n", ret);
970 return ret; 943 return ret;
971} 944}
972 945
@@ -1953,9 +1926,9 @@ static void o2net_accept_many(struct work_struct *work)
1953 cond_resched(); 1926 cond_resched();
1954} 1927}
1955 1928
1956static void o2net_listen_data_ready(struct sock *sk, int bytes) 1929static void o2net_listen_data_ready(struct sock *sk)
1957{ 1930{
1958 void (*ready)(struct sock *sk, int bytes); 1931 void (*ready)(struct sock *sk);
1959 1932
1960 read_lock(&sk->sk_callback_lock); 1933 read_lock(&sk->sk_callback_lock);
1961 ready = sk->sk_user_data; 1934 ready = sk->sk_user_data;
@@ -1978,7 +1951,6 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes)
1978 */ 1951 */
1979 1952
1980 if (sk->sk_state == TCP_LISTEN) { 1953 if (sk->sk_state == TCP_LISTEN) {
1981 mlog(ML_TCP, "bytes: %d\n", bytes);
1982 queue_work(o2net_wq, &o2net_listen_work); 1954 queue_work(o2net_wq, &o2net_listen_work);
1983 } else { 1955 } else {
1984 ready = NULL; 1956 ready = NULL;
@@ -1987,7 +1959,7 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes)
1987out: 1959out:
1988 read_unlock(&sk->sk_callback_lock); 1960 read_unlock(&sk->sk_callback_lock);
1989 if (ready != NULL) 1961 if (ready != NULL)
1990 ready(sk, bytes); 1962 ready(sk);
1991} 1963}
1992 1964
1993static int o2net_open_listening_sock(__be32 addr, __be16 port) 1965static int o2net_open_listening_sock(__be32 addr, __be16 port)
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 4cbcb65784a3..dc024367110a 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -165,7 +165,7 @@ struct o2net_sock_container {
165 165
166 /* original handlers for the sockets */ 166 /* original handlers for the sockets */
167 void (*sc_state_change)(struct sock *sk); 167 void (*sc_state_change)(struct sock *sk);
168 void (*sc_data_ready)(struct sock *sk, int bytes); 168 void (*sc_data_ready)(struct sock *sk);
169 169
170 u32 sc_msg_key; 170 u32 sc_msg_key;
171 u16 sc_msg_type; 171 u16 sc_msg_type;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index ff33c5ef87f2..8970dcf74de5 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2367,15 +2367,18 @@ relock:
2367 2367
2368 if (direct_io) { 2368 if (direct_io) {
2369 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos, 2369 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
2370 ppos, count, ocount); 2370 count, ocount);
2371 if (written < 0) { 2371 if (written < 0) {
2372 ret = written; 2372 ret = written;
2373 goto out_dio; 2373 goto out_dio;
2374 } 2374 }
2375 } else { 2375 } else {
2376 struct iov_iter from;
2377 iov_iter_init(&from, iov, nr_segs, count, 0);
2376 current->backing_dev_info = file->f_mapping->backing_dev_info; 2378 current->backing_dev_info = file->f_mapping->backing_dev_info;
2377 written = generic_file_buffered_write(iocb, iov, nr_segs, *ppos, 2379 written = generic_perform_write(file, &from, *ppos);
2378 ppos, count, 0); 2380 if (likely(written >= 0))
2381 iocb->ki_pos = *ppos + written;
2379 current->backing_dev_info = NULL; 2382 current->backing_dev_info = NULL;
2380 } 2383 }
2381 2384
diff --git a/fs/open.c b/fs/open.c
index 631aea815def..3d30eb1fc95e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -655,35 +655,6 @@ out:
655 return error; 655 return error;
656} 656}
657 657
658/*
659 * You have to be very careful that these write
660 * counts get cleaned up in error cases and
661 * upon __fput(). This should probably never
662 * be called outside of __dentry_open().
663 */
664static inline int __get_file_write_access(struct inode *inode,
665 struct vfsmount *mnt)
666{
667 int error;
668 error = get_write_access(inode);
669 if (error)
670 return error;
671 /*
672 * Do not take mount writer counts on
673 * special files since no writes to
674 * the mount itself will occur.
675 */
676 if (!special_file(inode->i_mode)) {
677 /*
678 * Balanced in __fput()
679 */
680 error = __mnt_want_write(mnt);
681 if (error)
682 put_write_access(inode);
683 }
684 return error;
685}
686
687int open_check_o_direct(struct file *f) 658int open_check_o_direct(struct file *f)
688{ 659{
689 /* NB: we're sure to have correct a_ops only after f_op->open */ 660 /* NB: we're sure to have correct a_ops only after f_op->open */
@@ -708,26 +679,28 @@ static int do_dentry_open(struct file *f,
708 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK | 679 f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
709 FMODE_PREAD | FMODE_PWRITE; 680 FMODE_PREAD | FMODE_PWRITE;
710 681
711 if (unlikely(f->f_flags & O_PATH))
712 f->f_mode = FMODE_PATH;
713
714 path_get(&f->f_path); 682 path_get(&f->f_path);
715 inode = f->f_inode = f->f_path.dentry->d_inode; 683 inode = f->f_inode = f->f_path.dentry->d_inode;
716 if (f->f_mode & FMODE_WRITE) {
717 error = __get_file_write_access(inode, f->f_path.mnt);
718 if (error)
719 goto cleanup_file;
720 if (!special_file(inode->i_mode))
721 file_take_write(f);
722 }
723
724 f->f_mapping = inode->i_mapping; 684 f->f_mapping = inode->i_mapping;
725 685
726 if (unlikely(f->f_mode & FMODE_PATH)) { 686 if (unlikely(f->f_flags & O_PATH)) {
687 f->f_mode = FMODE_PATH;
727 f->f_op = &empty_fops; 688 f->f_op = &empty_fops;
728 return 0; 689 return 0;
729 } 690 }
730 691
692 if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) {
693 error = get_write_access(inode);
694 if (unlikely(error))
695 goto cleanup_file;
696 error = __mnt_want_write(f->f_path.mnt);
697 if (unlikely(error)) {
698 put_write_access(inode);
699 goto cleanup_file;
700 }
701 f->f_mode |= FMODE_WRITER;
702 }
703
731 /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */ 704 /* POSIX.1-2008/SUSv4 Section XSI 2.9.7 */
732 if (S_ISREG(inode->i_mode)) 705 if (S_ISREG(inode->i_mode))
733 f->f_mode |= FMODE_ATOMIC_POS; 706 f->f_mode |= FMODE_ATOMIC_POS;
@@ -764,18 +737,9 @@ static int do_dentry_open(struct file *f,
764 737
765cleanup_all: 738cleanup_all:
766 fops_put(f->f_op); 739 fops_put(f->f_op);
767 if (f->f_mode & FMODE_WRITE) { 740 if (f->f_mode & FMODE_WRITER) {
768 put_write_access(inode); 741 put_write_access(inode);
769 if (!special_file(inode->i_mode)) { 742 __mnt_drop_write(f->f_path.mnt);
770 /*
771 * We don't consider this a real
772 * mnt_want/drop_write() pair
773 * because it all happenend right
774 * here, so just reset the state.
775 */
776 file_reset_write(f);
777 __mnt_drop_write(f->f_path.mnt);
778 }
779 } 743 }
780cleanup_file: 744cleanup_file:
781 path_put(&f->f_path); 745 path_put(&f->f_path);
diff --git a/fs/pipe.c b/fs/pipe.c
index 78fd0d0788db..034bffac3f97 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -142,55 +142,6 @@ pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len,
142 return 0; 142 return 0;
143} 143}
144 144
145static int
146pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len,
147 int atomic)
148{
149 unsigned long copy;
150
151 while (len > 0) {
152 while (!iov->iov_len)
153 iov++;
154 copy = min_t(unsigned long, len, iov->iov_len);
155
156 if (atomic) {
157 if (__copy_to_user_inatomic(iov->iov_base, from, copy))
158 return -EFAULT;
159 } else {
160 if (copy_to_user(iov->iov_base, from, copy))
161 return -EFAULT;
162 }
163 from += copy;
164 len -= copy;
165 iov->iov_base += copy;
166 iov->iov_len -= copy;
167 }
168 return 0;
169}
170
171/*
172 * Attempt to pre-fault in the user memory, so we can use atomic copies.
173 * Returns the number of bytes not faulted in.
174 */
175static int iov_fault_in_pages_write(struct iovec *iov, unsigned long len)
176{
177 while (!iov->iov_len)
178 iov++;
179
180 while (len > 0) {
181 unsigned long this_len;
182
183 this_len = min_t(unsigned long, len, iov->iov_len);
184 if (fault_in_pages_writeable(iov->iov_base, this_len))
185 break;
186
187 len -= this_len;
188 iov++;
189 }
190
191 return len;
192}
193
194/* 145/*
195 * Pre-fault in the user memory, so we can use atomic copies. 146 * Pre-fault in the user memory, so we can use atomic copies.
196 */ 147 */
@@ -226,52 +177,6 @@ static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
226} 177}
227 178
228/** 179/**
229 * generic_pipe_buf_map - virtually map a pipe buffer
230 * @pipe: the pipe that the buffer belongs to
231 * @buf: the buffer that should be mapped
232 * @atomic: whether to use an atomic map
233 *
234 * Description:
235 * This function returns a kernel virtual address mapping for the
236 * pipe_buffer passed in @buf. If @atomic is set, an atomic map is provided
237 * and the caller has to be careful not to fault before calling
238 * the unmap function.
239 *
240 * Note that this function calls kmap_atomic() if @atomic != 0.
241 */
242void *generic_pipe_buf_map(struct pipe_inode_info *pipe,
243 struct pipe_buffer *buf, int atomic)
244{
245 if (atomic) {
246 buf->flags |= PIPE_BUF_FLAG_ATOMIC;
247 return kmap_atomic(buf->page);
248 }
249
250 return kmap(buf->page);
251}
252EXPORT_SYMBOL(generic_pipe_buf_map);
253
254/**
255 * generic_pipe_buf_unmap - unmap a previously mapped pipe buffer
256 * @pipe: the pipe that the buffer belongs to
257 * @buf: the buffer that should be unmapped
258 * @map_data: the data that the mapping function returned
259 *
260 * Description:
261 * This function undoes the mapping that ->map() provided.
262 */
263void generic_pipe_buf_unmap(struct pipe_inode_info *pipe,
264 struct pipe_buffer *buf, void *map_data)
265{
266 if (buf->flags & PIPE_BUF_FLAG_ATOMIC) {
267 buf->flags &= ~PIPE_BUF_FLAG_ATOMIC;
268 kunmap_atomic(map_data);
269 } else
270 kunmap(buf->page);
271}
272EXPORT_SYMBOL(generic_pipe_buf_unmap);
273
274/**
275 * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer 180 * generic_pipe_buf_steal - attempt to take ownership of a &pipe_buffer
276 * @pipe: the pipe that the buffer belongs to 181 * @pipe: the pipe that the buffer belongs to
277 * @buf: the buffer to attempt to steal 182 * @buf: the buffer to attempt to steal
@@ -351,8 +256,6 @@ EXPORT_SYMBOL(generic_pipe_buf_release);
351 256
352static const struct pipe_buf_operations anon_pipe_buf_ops = { 257static const struct pipe_buf_operations anon_pipe_buf_ops = {
353 .can_merge = 1, 258 .can_merge = 1,
354 .map = generic_pipe_buf_map,
355 .unmap = generic_pipe_buf_unmap,
356 .confirm = generic_pipe_buf_confirm, 259 .confirm = generic_pipe_buf_confirm,
357 .release = anon_pipe_buf_release, 260 .release = anon_pipe_buf_release,
358 .steal = generic_pipe_buf_steal, 261 .steal = generic_pipe_buf_steal,
@@ -361,8 +264,6 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
361 264
362static const struct pipe_buf_operations packet_pipe_buf_ops = { 265static const struct pipe_buf_operations packet_pipe_buf_ops = {
363 .can_merge = 0, 266 .can_merge = 0,
364 .map = generic_pipe_buf_map,
365 .unmap = generic_pipe_buf_unmap,
366 .confirm = generic_pipe_buf_confirm, 267 .confirm = generic_pipe_buf_confirm,
367 .release = anon_pipe_buf_release, 268 .release = anon_pipe_buf_release,
368 .steal = generic_pipe_buf_steal, 269 .steal = generic_pipe_buf_steal,
@@ -379,12 +280,15 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
379 ssize_t ret; 280 ssize_t ret;
380 struct iovec *iov = (struct iovec *)_iov; 281 struct iovec *iov = (struct iovec *)_iov;
381 size_t total_len; 282 size_t total_len;
283 struct iov_iter iter;
382 284
383 total_len = iov_length(iov, nr_segs); 285 total_len = iov_length(iov, nr_segs);
384 /* Null read succeeds. */ 286 /* Null read succeeds. */
385 if (unlikely(total_len == 0)) 287 if (unlikely(total_len == 0))
386 return 0; 288 return 0;
387 289
290 iov_iter_init(&iter, iov, nr_segs, total_len, 0);
291
388 do_wakeup = 0; 292 do_wakeup = 0;
389 ret = 0; 293 ret = 0;
390 __pipe_lock(pipe); 294 __pipe_lock(pipe);
@@ -394,9 +298,9 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
394 int curbuf = pipe->curbuf; 298 int curbuf = pipe->curbuf;
395 struct pipe_buffer *buf = pipe->bufs + curbuf; 299 struct pipe_buffer *buf = pipe->bufs + curbuf;
396 const struct pipe_buf_operations *ops = buf->ops; 300 const struct pipe_buf_operations *ops = buf->ops;
397 void *addr;
398 size_t chars = buf->len; 301 size_t chars = buf->len;
399 int error, atomic; 302 size_t written;
303 int error;
400 304
401 if (chars > total_len) 305 if (chars > total_len)
402 chars = total_len; 306 chars = total_len;
@@ -408,21 +312,10 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
408 break; 312 break;
409 } 313 }
410 314
411 atomic = !iov_fault_in_pages_write(iov, chars); 315 written = copy_page_to_iter(buf->page, buf->offset, chars, &iter);
412redo: 316 if (unlikely(written < chars)) {
413 addr = ops->map(pipe, buf, atomic);
414 error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars, atomic);
415 ops->unmap(pipe, buf, addr);
416 if (unlikely(error)) {
417 /*
418 * Just retry with the slow path if we failed.
419 */
420 if (atomic) {
421 atomic = 0;
422 goto redo;
423 }
424 if (!ret) 317 if (!ret)
425 ret = error; 318 ret = -EFAULT;
426 break; 319 break;
427 } 320 }
428 ret += chars; 321 ret += chars;
@@ -538,10 +431,16 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
538 431
539 iov_fault_in_pages_read(iov, chars); 432 iov_fault_in_pages_read(iov, chars);
540redo1: 433redo1:
541 addr = ops->map(pipe, buf, atomic); 434 if (atomic)
435 addr = kmap_atomic(buf->page);
436 else
437 addr = kmap(buf->page);
542 error = pipe_iov_copy_from_user(offset + addr, iov, 438 error = pipe_iov_copy_from_user(offset + addr, iov,
543 chars, atomic); 439 chars, atomic);
544 ops->unmap(pipe, buf, addr); 440 if (atomic)
441 kunmap_atomic(addr);
442 else
443 kunmap(buf->page);
545 ret = error; 444 ret = error;
546 do_wakeup = 1; 445 do_wakeup = 1;
547 if (error) { 446 if (error) {
diff --git a/fs/pnode.c b/fs/pnode.c
index 88396df725b4..302bf22c4a30 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -164,46 +164,94 @@ static struct mount *propagation_next(struct mount *m,
164 } 164 }
165} 165}
166 166
167/* 167static struct mount *next_group(struct mount *m, struct mount *origin)
168 * return the source mount to be used for cloning
169 *
170 * @dest the current destination mount
171 * @last_dest the last seen destination mount
172 * @last_src the last seen source mount
173 * @type return CL_SLAVE if the new mount has to be
174 * cloned as a slave.
175 */
176static struct mount *get_source(struct mount *dest,
177 struct mount *last_dest,
178 struct mount *last_src,
179 int *type)
180{ 168{
181 struct mount *p_last_src = NULL; 169 while (1) {
182 struct mount *p_last_dest = NULL; 170 while (1) {
183 171 struct mount *next;
184 while (last_dest != dest->mnt_master) { 172 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
185 p_last_dest = last_dest; 173 return first_slave(m);
186 p_last_src = last_src; 174 next = next_peer(m);
187 last_dest = last_dest->mnt_master; 175 if (m->mnt_group_id == origin->mnt_group_id) {
188 last_src = last_src->mnt_master; 176 if (next == origin)
177 return NULL;
178 } else if (m->mnt_slave.next != &next->mnt_slave)
179 break;
180 m = next;
181 }
182 /* m is the last peer */
183 while (1) {
184 struct mount *master = m->mnt_master;
185 if (m->mnt_slave.next != &master->mnt_slave_list)
186 return next_slave(m);
187 m = next_peer(master);
188 if (master->mnt_group_id == origin->mnt_group_id)
189 break;
190 if (master->mnt_slave.next == &m->mnt_slave)
191 break;
192 m = master;
193 }
194 if (m == origin)
195 return NULL;
189 } 196 }
197}
190 198
191 if (p_last_dest) { 199/* all accesses are serialized by namespace_sem */
192 do { 200static struct user_namespace *user_ns;
193 p_last_dest = next_peer(p_last_dest); 201static struct mount *last_dest, *last_source, *dest_master;
194 } while (IS_MNT_NEW(p_last_dest)); 202static struct mountpoint *mp;
195 /* is that a peer of the earlier? */ 203static struct hlist_head *list;
196 if (dest == p_last_dest) { 204
197 *type = CL_MAKE_SHARED; 205static int propagate_one(struct mount *m)
198 return p_last_src; 206{
207 struct mount *child;
208 int type;
209 /* skip ones added by this propagate_mnt() */
210 if (IS_MNT_NEW(m))
211 return 0;
212 /* skip if mountpoint isn't covered by it */
213 if (!is_subdir(mp->m_dentry, m->mnt.mnt_root))
214 return 0;
215 if (m->mnt_group_id == last_dest->mnt_group_id) {
216 type = CL_MAKE_SHARED;
217 } else {
218 struct mount *n, *p;
219 for (n = m; ; n = p) {
220 p = n->mnt_master;
221 if (p == dest_master || IS_MNT_MARKED(p)) {
222 while (last_dest->mnt_master != p) {
223 last_source = last_source->mnt_master;
224 last_dest = last_source->mnt_parent;
225 }
226 if (n->mnt_group_id != last_dest->mnt_group_id) {
227 last_source = last_source->mnt_master;
228 last_dest = last_source->mnt_parent;
229 }
230 break;
231 }
199 } 232 }
233 type = CL_SLAVE;
234 /* beginning of peer group among the slaves? */
235 if (IS_MNT_SHARED(m))
236 type |= CL_MAKE_SHARED;
200 } 237 }
201 /* slave of the earlier, then */ 238
202 *type = CL_SLAVE; 239 /* Notice when we are propagating across user namespaces */
203 /* beginning of peer group among the slaves? */ 240 if (m->mnt_ns->user_ns != user_ns)
204 if (IS_MNT_SHARED(dest)) 241 type |= CL_UNPRIVILEGED;
205 *type |= CL_MAKE_SHARED; 242 child = copy_tree(last_source, last_source->mnt.mnt_root, type);
206 return last_src; 243 if (IS_ERR(child))
244 return PTR_ERR(child);
245 mnt_set_mountpoint(m, mp, child);
246 last_dest = m;
247 last_source = child;
248 if (m->mnt_master != dest_master) {
249 read_seqlock_excl(&mount_lock);
250 SET_MNT_MARK(m->mnt_master);
251 read_sequnlock_excl(&mount_lock);
252 }
253 hlist_add_head(&child->mnt_hash, list);
254 return 0;
207} 255}
208 256
209/* 257/*
@@ -222,56 +270,48 @@ static struct mount *get_source(struct mount *dest,
222int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp, 270int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp,
223 struct mount *source_mnt, struct hlist_head *tree_list) 271 struct mount *source_mnt, struct hlist_head *tree_list)
224{ 272{
225 struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns; 273 struct mount *m, *n;
226 struct mount *m, *child;
227 int ret = 0; 274 int ret = 0;
228 struct mount *prev_dest_mnt = dest_mnt; 275
229 struct mount *prev_src_mnt = source_mnt; 276 /*
230 HLIST_HEAD(tmp_list); 277 * we don't want to bother passing tons of arguments to
231 278 * propagate_one(); everything is serialized by namespace_sem,
232 for (m = propagation_next(dest_mnt, dest_mnt); m; 279 * so globals will do just fine.
233 m = propagation_next(m, dest_mnt)) { 280 */
234 int type; 281 user_ns = current->nsproxy->mnt_ns->user_ns;
235 struct mount *source; 282 last_dest = dest_mnt;
236 283 last_source = source_mnt;
237 if (IS_MNT_NEW(m)) 284 mp = dest_mp;
238 continue; 285 list = tree_list;
239 286 dest_master = dest_mnt->mnt_master;
240 source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); 287
241 288 /* all peers of dest_mnt, except dest_mnt itself */
242 /* Notice when we are propagating across user namespaces */ 289 for (n = next_peer(dest_mnt); n != dest_mnt; n = next_peer(n)) {
243 if (m->mnt_ns->user_ns != user_ns) 290 ret = propagate_one(n);
244 type |= CL_UNPRIVILEGED; 291 if (ret)
245
246 child = copy_tree(source, source->mnt.mnt_root, type);
247 if (IS_ERR(child)) {
248 ret = PTR_ERR(child);
249 tmp_list = *tree_list;
250 tmp_list.first->pprev = &tmp_list.first;
251 INIT_HLIST_HEAD(tree_list);
252 goto out; 292 goto out;
253 } 293 }
254 294
255 if (is_subdir(dest_mp->m_dentry, m->mnt.mnt_root)) { 295 /* all slave groups */
256 mnt_set_mountpoint(m, dest_mp, child); 296 for (m = next_group(dest_mnt, dest_mnt); m;
257 hlist_add_head(&child->mnt_hash, tree_list); 297 m = next_group(m, dest_mnt)) {
258 } else { 298 /* everything in that slave group */
259 /* 299 n = m;
260 * This can happen if the parent mount was bind mounted 300 do {
261 * on some subdirectory of a shared/slave mount. 301 ret = propagate_one(n);
262 */ 302 if (ret)
263 hlist_add_head(&child->mnt_hash, &tmp_list); 303 goto out;
264 } 304 n = next_peer(n);
265 prev_dest_mnt = m; 305 } while (n != m);
266 prev_src_mnt = child;
267 } 306 }
268out: 307out:
269 lock_mount_hash(); 308 read_seqlock_excl(&mount_lock);
270 while (!hlist_empty(&tmp_list)) { 309 hlist_for_each_entry(n, tree_list, mnt_hash) {
271 child = hlist_entry(tmp_list.first, struct mount, mnt_hash); 310 m = n->mnt_parent;
272 umount_tree(child, 0); 311 if (m->mnt_master != dest_mnt->mnt_master)
312 CLEAR_MNT_MARK(m->mnt_master);
273 } 313 }
274 unlock_mount_hash(); 314 read_sequnlock_excl(&mount_lock);
275 return ret; 315 return ret;
276} 316}
277 317
diff --git a/fs/pnode.h b/fs/pnode.h
index fc28a27fa892..4a246358b031 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -16,6 +16,9 @@
16#define IS_MNT_NEW(m) (!(m)->mnt_ns) 16#define IS_MNT_NEW(m) (!(m)->mnt_ns)
17#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED) 17#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED)
18#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE) 18#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE)
19#define IS_MNT_MARKED(m) ((m)->mnt.mnt_flags & MNT_MARKED)
20#define SET_MNT_MARK(m) ((m)->mnt.mnt_flags |= MNT_MARKED)
21#define CLEAR_MNT_MARK(m) ((m)->mnt.mnt_flags &= ~MNT_MARKED)
19 22
20#define CL_EXPIRE 0x01 23#define CL_EXPIRE 0x01
21#define CL_SLAVE 0x02 24#define CL_SLAVE 0x02
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 6b7087e2e8fb..2d696b0c93bf 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -200,41 +200,9 @@ static int proc_root_link(struct dentry *dentry, struct path *path)
200 return result; 200 return result;
201} 201}
202 202
203static int proc_pid_cmdline(struct task_struct *task, char * buffer) 203static int proc_pid_cmdline(struct task_struct *task, char *buffer)
204{ 204{
205 int res = 0; 205 return get_cmdline(task, buffer, PAGE_SIZE);
206 unsigned int len;
207 struct mm_struct *mm = get_task_mm(task);
208 if (!mm)
209 goto out;
210 if (!mm->arg_end)
211 goto out_mm; /* Shh! No looking before we're done */
212
213 len = mm->arg_end - mm->arg_start;
214
215 if (len > PAGE_SIZE)
216 len = PAGE_SIZE;
217
218 res = access_process_vm(task, mm->arg_start, buffer, len, 0);
219
220 // If the nul at the end of args has been overwritten, then
221 // assume application is using setproctitle(3).
222 if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE) {
223 len = strnlen(buffer, res);
224 if (len < res) {
225 res = len;
226 } else {
227 len = mm->env_end - mm->env_start;
228 if (len > PAGE_SIZE - res)
229 len = PAGE_SIZE - res;
230 res += access_process_vm(task, mm->env_start, buffer+res, len, 0);
231 res = strnlen(buffer, res);
232 }
233 }
234out_mm:
235 mmput(mm);
236out:
237 return res;
238} 206}
239 207
240static int proc_pid_auxv(struct task_struct *task, char *buffer) 208static int proc_pid_auxv(struct task_struct *task, char *buffer)
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 9ae46b87470d..89026095f2b5 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
146 struct task_struct *task; 146 struct task_struct *task;
147 void *ns; 147 void *ns;
148 char name[50]; 148 char name[50];
149 int len = -EACCES; 149 int res = -EACCES;
150 150
151 task = get_proc_task(inode); 151 task = get_proc_task(inode);
152 if (!task) 152 if (!task)
@@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
155 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 155 if (!ptrace_may_access(task, PTRACE_MODE_READ))
156 goto out_put_task; 156 goto out_put_task;
157 157
158 len = -ENOENT; 158 res = -ENOENT;
159 ns = ns_ops->get(task); 159 ns = ns_ops->get(task);
160 if (!ns) 160 if (!ns)
161 goto out_put_task; 161 goto out_put_task;
162 162
163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns)); 163 snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns));
164 len = strlen(name); 164 res = readlink_copy(buffer, buflen, name);
165
166 if (len > buflen)
167 len = buflen;
168 if (copy_to_user(buffer, name, len))
169 len = -EFAULT;
170
171 ns_ops->put(ns); 165 ns_ops->put(ns);
172out_put_task: 166out_put_task:
173 put_task_struct(task); 167 put_task_struct(task);
174out: 168out:
175 return len; 169 return res;
176} 170}
177 171
178static const struct inode_operations proc_ns_link_inode_operations = { 172static const struct inode_operations proc_ns_link_inode_operations = {
diff --git a/fs/proc/self.c b/fs/proc/self.c
index ffeb202ec942..4348bb8907c2 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -16,7 +16,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
16 if (!tgid) 16 if (!tgid)
17 return -ENOENT; 17 return -ENOENT;
18 sprintf(tmp, "%d", tgid); 18 sprintf(tmp, "%d", tgid);
19 return vfs_readlink(dentry,buffer,buflen,tmp); 19 return readlink_copy(buffer, buflen, tmp);
20} 20}
21 21
22static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) 22static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 7be26f03a3f5..1a81373947f3 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -267,6 +267,7 @@ static int mounts_open_common(struct inode *inode, struct file *file,
267 p->root = root; 267 p->root = root;
268 p->m.poll_event = ns->event; 268 p->m.poll_event = ns->event;
269 p->show = show; 269 p->show = show;
270 p->cached_event = ~0ULL;
270 271
271 return 0; 272 return 0;
272 273
diff --git a/fs/splice.c b/fs/splice.c
index 12028fa41def..9bc07d2b53cf 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -136,8 +136,6 @@ error:
136 136
137const struct pipe_buf_operations page_cache_pipe_buf_ops = { 137const struct pipe_buf_operations page_cache_pipe_buf_ops = {
138 .can_merge = 0, 138 .can_merge = 0,
139 .map = generic_pipe_buf_map,
140 .unmap = generic_pipe_buf_unmap,
141 .confirm = page_cache_pipe_buf_confirm, 139 .confirm = page_cache_pipe_buf_confirm,
142 .release = page_cache_pipe_buf_release, 140 .release = page_cache_pipe_buf_release,
143 .steal = page_cache_pipe_buf_steal, 141 .steal = page_cache_pipe_buf_steal,
@@ -156,8 +154,6 @@ static int user_page_pipe_buf_steal(struct pipe_inode_info *pipe,
156 154
157static const struct pipe_buf_operations user_page_pipe_buf_ops = { 155static const struct pipe_buf_operations user_page_pipe_buf_ops = {
158 .can_merge = 0, 156 .can_merge = 0,
159 .map = generic_pipe_buf_map,
160 .unmap = generic_pipe_buf_unmap,
161 .confirm = generic_pipe_buf_confirm, 157 .confirm = generic_pipe_buf_confirm,
162 .release = page_cache_pipe_buf_release, 158 .release = page_cache_pipe_buf_release,
163 .steal = user_page_pipe_buf_steal, 159 .steal = user_page_pipe_buf_steal,
@@ -547,8 +543,6 @@ EXPORT_SYMBOL(generic_file_splice_read);
547 543
548static const struct pipe_buf_operations default_pipe_buf_ops = { 544static const struct pipe_buf_operations default_pipe_buf_ops = {
549 .can_merge = 0, 545 .can_merge = 0,
550 .map = generic_pipe_buf_map,
551 .unmap = generic_pipe_buf_unmap,
552 .confirm = generic_pipe_buf_confirm, 546 .confirm = generic_pipe_buf_confirm,
553 .release = generic_pipe_buf_release, 547 .release = generic_pipe_buf_release,
554 .steal = generic_pipe_buf_steal, 548 .steal = generic_pipe_buf_steal,
@@ -564,8 +558,6 @@ static int generic_pipe_buf_nosteal(struct pipe_inode_info *pipe,
564/* Pipe buffer operations for a socket and similar. */ 558/* Pipe buffer operations for a socket and similar. */
565const struct pipe_buf_operations nosteal_pipe_buf_ops = { 559const struct pipe_buf_operations nosteal_pipe_buf_ops = {
566 .can_merge = 0, 560 .can_merge = 0,
567 .map = generic_pipe_buf_map,
568 .unmap = generic_pipe_buf_unmap,
569 .confirm = generic_pipe_buf_confirm, 561 .confirm = generic_pipe_buf_confirm,
570 .release = generic_pipe_buf_release, 562 .release = generic_pipe_buf_release,
571 .steal = generic_pipe_buf_nosteal, 563 .steal = generic_pipe_buf_nosteal,
@@ -767,13 +759,13 @@ int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
767 goto out; 759 goto out;
768 760
769 if (buf->page != page) { 761 if (buf->page != page) {
770 char *src = buf->ops->map(pipe, buf, 1); 762 char *src = kmap_atomic(buf->page);
771 char *dst = kmap_atomic(page); 763 char *dst = kmap_atomic(page);
772 764
773 memcpy(dst + offset, src + buf->offset, this_len); 765 memcpy(dst + offset, src + buf->offset, this_len);
774 flush_dcache_page(page); 766 flush_dcache_page(page);
775 kunmap_atomic(dst); 767 kunmap_atomic(dst);
776 buf->ops->unmap(pipe, buf, src); 768 kunmap_atomic(src);
777 } 769 }
778 ret = pagecache_write_end(file, mapping, sd->pos, this_len, this_len, 770 ret = pagecache_write_end(file, mapping, sd->pos, this_len, this_len,
779 page, fsdata); 771 page, fsdata);
@@ -1067,9 +1059,9 @@ static int write_pipe_buf(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
1067 void *data; 1059 void *data;
1068 loff_t tmp = sd->pos; 1060 loff_t tmp = sd->pos;
1069 1061
1070 data = buf->ops->map(pipe, buf, 0); 1062 data = kmap(buf->page);
1071 ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp); 1063 ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp);
1072 buf->ops->unmap(pipe, buf, data); 1064 kunmap(buf->page);
1073 1065
1074 return ret; 1066 return ret;
1075} 1067}
@@ -1528,116 +1520,48 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1528static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf, 1520static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
1529 struct splice_desc *sd) 1521 struct splice_desc *sd)
1530{ 1522{
1531 char *src; 1523 int n = copy_page_to_iter(buf->page, buf->offset, sd->len, sd->u.data);
1532 int ret; 1524 return n == sd->len ? n : -EFAULT;
1533
1534 /*
1535 * See if we can use the atomic maps, by prefaulting in the
1536 * pages and doing an atomic copy
1537 */
1538 if (!fault_in_pages_writeable(sd->u.userptr, sd->len)) {
1539 src = buf->ops->map(pipe, buf, 1);
1540 ret = __copy_to_user_inatomic(sd->u.userptr, src + buf->offset,
1541 sd->len);
1542 buf->ops->unmap(pipe, buf, src);
1543 if (!ret) {
1544 ret = sd->len;
1545 goto out;
1546 }
1547 }
1548
1549 /*
1550 * No dice, use slow non-atomic map and copy
1551 */
1552 src = buf->ops->map(pipe, buf, 0);
1553
1554 ret = sd->len;
1555 if (copy_to_user(sd->u.userptr, src + buf->offset, sd->len))
1556 ret = -EFAULT;
1557
1558 buf->ops->unmap(pipe, buf, src);
1559out:
1560 if (ret > 0)
1561 sd->u.userptr += ret;
1562 return ret;
1563} 1525}
1564 1526
1565/* 1527/*
1566 * For lack of a better implementation, implement vmsplice() to userspace 1528 * For lack of a better implementation, implement vmsplice() to userspace
1567 * as a simple copy of the pipes pages to the user iov. 1529 * as a simple copy of the pipes pages to the user iov.
1568 */ 1530 */
1569static long vmsplice_to_user(struct file *file, const struct iovec __user *iov, 1531static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
1570 unsigned long nr_segs, unsigned int flags) 1532 unsigned long nr_segs, unsigned int flags)
1571{ 1533{
1572 struct pipe_inode_info *pipe; 1534 struct pipe_inode_info *pipe;
1573 struct splice_desc sd; 1535 struct splice_desc sd;
1574 ssize_t size;
1575 int error;
1576 long ret; 1536 long ret;
1537 struct iovec iovstack[UIO_FASTIOV];
1538 struct iovec *iov = iovstack;
1539 struct iov_iter iter;
1540 ssize_t count = 0;
1577 1541
1578 pipe = get_pipe_info(file); 1542 pipe = get_pipe_info(file);
1579 if (!pipe) 1543 if (!pipe)
1580 return -EBADF; 1544 return -EBADF;
1581 1545
1582 pipe_lock(pipe); 1546 ret = rw_copy_check_uvector(READ, uiov, nr_segs,
1583 1547 ARRAY_SIZE(iovstack), iovstack, &iov);
1584 error = ret = 0; 1548 if (ret <= 0)
1585 while (nr_segs) { 1549 return ret;
1586 void __user *base;
1587 size_t len;
1588
1589 /*
1590 * Get user address base and length for this iovec.
1591 */
1592 error = get_user(base, &iov->iov_base);
1593 if (unlikely(error))
1594 break;
1595 error = get_user(len, &iov->iov_len);
1596 if (unlikely(error))
1597 break;
1598
1599 /*
1600 * Sanity check this iovec. 0 read succeeds.
1601 */
1602 if (unlikely(!len))
1603 break;
1604 if (unlikely(!base)) {
1605 error = -EFAULT;
1606 break;
1607 }
1608
1609 if (unlikely(!access_ok(VERIFY_WRITE, base, len))) {
1610 error = -EFAULT;
1611 break;
1612 }
1613
1614 sd.len = 0;
1615 sd.total_len = len;
1616 sd.flags = flags;
1617 sd.u.userptr = base;
1618 sd.pos = 0;
1619
1620 size = __splice_from_pipe(pipe, &sd, pipe_to_user);
1621 if (size < 0) {
1622 if (!ret)
1623 ret = size;
1624
1625 break;
1626 }
1627
1628 ret += size;
1629 1550
1630 if (size < len) 1551 iov_iter_init(&iter, iov, nr_segs, count, 0);
1631 break;
1632 1552
1633 nr_segs--; 1553 sd.len = 0;
1634 iov++; 1554 sd.total_len = count;
1635 } 1555 sd.flags = flags;
1556 sd.u.data = &iter;
1557 sd.pos = 0;
1636 1558
1559 pipe_lock(pipe);
1560 ret = __splice_from_pipe(pipe, &sd, pipe_to_user);
1637 pipe_unlock(pipe); 1561 pipe_unlock(pipe);
1638 1562
1639 if (!ret) 1563 if (iov != iovstack)
1640 ret = error; 1564 kfree(iov);
1641 1565
1642 return ret; 1566 return ret;
1643} 1567}
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 1037637957c7..d2c170f8b035 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -171,7 +171,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
171 } else 171 } else
172 up_write(&iinfo->i_data_sem); 172 up_write(&iinfo->i_data_sem);
173 173
174 retval = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 174 retval = __generic_file_aio_write(iocb, iov, nr_segs);
175 mutex_unlock(&inode->i_mutex); 175 mutex_unlock(&inode->i_mutex);
176 176
177 if (retval > 0) { 177 if (retval > 0) {
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 003c0051b62f..79e96ce98733 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -699,7 +699,7 @@ xfs_file_dio_aio_write(
699 699
700 trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0); 700 trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0);
701 ret = generic_file_direct_write(iocb, iovp, 701 ret = generic_file_direct_write(iocb, iovp,
702 &nr_segs, pos, &iocb->ki_pos, count, ocount); 702 &nr_segs, pos, count, ocount);
703 703
704out: 704out:
705 xfs_rw_iunlock(ip, iolock); 705 xfs_rw_iunlock(ip, iolock);
@@ -715,7 +715,7 @@ xfs_file_buffered_aio_write(
715 const struct iovec *iovp, 715 const struct iovec *iovp,
716 unsigned long nr_segs, 716 unsigned long nr_segs,
717 loff_t pos, 717 loff_t pos,
718 size_t ocount) 718 size_t count)
719{ 719{
720 struct file *file = iocb->ki_filp; 720 struct file *file = iocb->ki_filp;
721 struct address_space *mapping = file->f_mapping; 721 struct address_space *mapping = file->f_mapping;
@@ -724,7 +724,7 @@ xfs_file_buffered_aio_write(
724 ssize_t ret; 724 ssize_t ret;
725 int enospc = 0; 725 int enospc = 0;
726 int iolock = XFS_IOLOCK_EXCL; 726 int iolock = XFS_IOLOCK_EXCL;
727 size_t count = ocount; 727 struct iov_iter from;
728 728
729 xfs_rw_ilock(ip, iolock); 729 xfs_rw_ilock(ip, iolock);
730 730
@@ -732,14 +732,15 @@ xfs_file_buffered_aio_write(
732 if (ret) 732 if (ret)
733 goto out; 733 goto out;
734 734
735 iov_iter_init(&from, iovp, nr_segs, count, 0);
735 /* We can write back this queue in page reclaim */ 736 /* We can write back this queue in page reclaim */
736 current->backing_dev_info = mapping->backing_dev_info; 737 current->backing_dev_info = mapping->backing_dev_info;
737 738
738write_retry: 739write_retry:
739 trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0); 740 trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0);
740 ret = generic_file_buffered_write(iocb, iovp, nr_segs, 741 ret = generic_perform_write(file, &from, pos);
741 pos, &iocb->ki_pos, count, 0); 742 if (likely(ret >= 0))
742 743 iocb->ki_pos = pos + ret;
743 /* 744 /*
744 * If we just got an ENOSPC, try to write back all dirty inodes to 745 * If we just got an ENOSPC, try to write back all dirty inodes to
745 * convert delalloc space to free up some of the excess reserved 746 * convert delalloc space to free up some of the excess reserved
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index bcfe61202115..0b18776b075e 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -271,32 +271,6 @@ xfs_open_by_handle(
271 return error; 271 return error;
272} 272}
273 273
274/*
275 * This is a copy from fs/namei.c:vfs_readlink(), except for removing it's
276 * unused first argument.
277 */
278STATIC int
279do_readlink(
280 char __user *buffer,
281 int buflen,
282 const char *link)
283{
284 int len;
285
286 len = PTR_ERR(link);
287 if (IS_ERR(link))
288 goto out;
289
290 len = strlen(link);
291 if (len > (unsigned) buflen)
292 len = buflen;
293 if (copy_to_user(buffer, link, len))
294 len = -EFAULT;
295 out:
296 return len;
297}
298
299
300int 274int
301xfs_readlink_by_handle( 275xfs_readlink_by_handle(
302 struct file *parfilp, 276 struct file *parfilp,
@@ -334,7 +308,7 @@ xfs_readlink_by_handle(
334 error = -xfs_readlink(XFS_I(dentry->d_inode), link); 308 error = -xfs_readlink(XFS_I(dentry->d_inode), link);
335 if (error) 309 if (error)
336 goto out_kfree; 310 goto out_kfree;
337 error = do_readlink(hreq->ohandle, olen, link); 311 error = readlink_copy(hreq->ohandle, olen, link);
338 if (error) 312 if (error)
339 goto out_kfree; 313 goto out_kfree;
340 314
diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c898c1bb..70bef78912b7 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -4,7 +4,8 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/irqflags.h> 5#include <linux/irqflags.h>
6 6
7extern unsigned long wrong_size_cmpxchg(volatile void *ptr); 7extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
8 __noreturn;
8 9
9/* 10/*
10 * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned 11 * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 5b09392db673..d401e5463fb0 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -144,8 +144,6 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
144 144
145/** 145/**
146 * syscall_get_arch - return the AUDIT_ARCH for the current system call 146 * syscall_get_arch - return the AUDIT_ARCH for the current system call
147 * @task: task of interest, must be in system call entry tracing
148 * @regs: task_pt_regs() of @task
149 * 147 *
150 * Returns the AUDIT_ARCH_* based on the system call convention in use. 148 * Returns the AUDIT_ARCH_* based on the system call convention in use.
151 * 149 *
@@ -155,5 +153,5 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
155 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must 153 * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
156 * provide an implementation of this. 154 * provide an implementation of this.
157 */ 155 */
158int syscall_get_arch(struct task_struct *task, struct pt_regs *regs); 156int syscall_get_arch(void);
159#endif /* _ASM_SYSCALL_H */ 157#endif /* _ASM_SYSCALL_H */
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 97d5497debc1..595f85c392ac 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -56,6 +56,12 @@ extern bool i915_gpu_turbo_disable(void);
56 56
57#define I830_GMCH_CTRL 0x52 57#define I830_GMCH_CTRL 0x52
58 58
59#define I830_GMCH_GMS_MASK 0x70
60#define I830_GMCH_GMS_LOCAL 0x10
61#define I830_GMCH_GMS_STOLEN_512 0x20
62#define I830_GMCH_GMS_STOLEN_1024 0x30
63#define I830_GMCH_GMS_STOLEN_8192 0x40
64
59#define I855_GMCH_GMS_MASK 0xF0 65#define I855_GMCH_GMS_MASK 0xF0
60#define I855_GMCH_GMS_STOLEN_0M 0x0 66#define I855_GMCH_GMS_STOLEN_0M 0x0
61#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4) 67#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4)
@@ -72,4 +78,18 @@ extern bool i915_gpu_turbo_disable(void);
72#define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4) 78#define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4)
73#define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4) 79#define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4)
74 80
81#define I830_DRB3 0x63
82#define I85X_DRB3 0x43
83#define I865_TOUD 0xc4
84
85#define I830_ESMRAMC 0x91
86#define I845_ESMRAMC 0x9e
87#define I85X_ESMRAMC 0x61
88#define TSEG_ENABLE (1 << 0)
89#define I830_TSEG_SIZE_512K (0 << 1)
90#define I830_TSEG_SIZE_1M (1 << 1)
91#define I845_TSEG_SIZE_MASK (3 << 1)
92#define I845_TSEG_SIZE_512K (2 << 1)
93#define I845_TSEG_SIZE_1M (3 << 1)
94
75#endif /* _I915_DRM_H_ */ 95#endif /* _I915_DRM_H_ */
diff --git a/include/linux/acpi_dma.h b/include/linux/acpi_dma.h
index fb0298082916..329436d38e66 100644
--- a/include/linux/acpi_dma.h
+++ b/include/linux/acpi_dma.h
@@ -16,6 +16,7 @@
16 16
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/err.h>
19#include <linux/dmaengine.h> 20#include <linux/dmaengine.h>
20 21
21/** 22/**
@@ -103,12 +104,12 @@ static inline void devm_acpi_dma_controller_free(struct device *dev)
103static inline struct dma_chan *acpi_dma_request_slave_chan_by_index( 104static inline struct dma_chan *acpi_dma_request_slave_chan_by_index(
104 struct device *dev, size_t index) 105 struct device *dev, size_t index)
105{ 106{
106 return NULL; 107 return ERR_PTR(-ENODEV);
107} 108}
108static inline struct dma_chan *acpi_dma_request_slave_chan_by_name( 109static inline struct dma_chan *acpi_dma_request_slave_chan_by_name(
109 struct device *dev, const char *name) 110 struct device *dev, const char *name)
110{ 111{
111 return NULL; 112 return ERR_PTR(-ENODEV);
112} 113}
113 114
114#define acpi_dma_simple_xlate NULL 115#define acpi_dma_simple_xlate NULL
diff --git a/include/linux/audit.h b/include/linux/audit.h
index ec1464df4c60..22cfddb75566 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -79,6 +79,14 @@ extern int is_audit_feature_set(int which);
79extern int __init audit_register_class(int class, unsigned *list); 79extern int __init audit_register_class(int class, unsigned *list);
80extern int audit_classify_syscall(int abi, unsigned syscall); 80extern int audit_classify_syscall(int abi, unsigned syscall);
81extern int audit_classify_arch(int arch); 81extern int audit_classify_arch(int arch);
82/* only for compat system calls */
83extern unsigned compat_write_class[];
84extern unsigned compat_read_class[];
85extern unsigned compat_dir_class[];
86extern unsigned compat_chattr_class[];
87extern unsigned compat_signal_class[];
88
89extern int __weak audit_classify_compat_syscall(int abi, unsigned syscall);
82 90
83/* audit_names->type values */ 91/* audit_names->type values */
84#define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */ 92#define AUDIT_TYPE_UNKNOWN 0 /* we don't know yet */
@@ -94,6 +102,12 @@ struct filename;
94 102
95extern void audit_log_session_info(struct audit_buffer *ab); 103extern void audit_log_session_info(struct audit_buffer *ab);
96 104
105#ifdef CONFIG_AUDIT_COMPAT_GENERIC
106#define audit_is_compat(arch) (!((arch) & __AUDIT_ARCH_64BIT))
107#else
108#define audit_is_compat(arch) false
109#endif
110
97#ifdef CONFIG_AUDITSYSCALL 111#ifdef CONFIG_AUDITSYSCALL
98/* These are defined in auditsc.c */ 112/* These are defined in auditsc.c */
99 /* Public API */ 113 /* Public API */
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 5a4d39b4686b..bba550826921 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -216,9 +216,9 @@ static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
216} 216}
217 217
218#define for_each_bvec(bvl, bio_vec, iter, start) \ 218#define for_each_bvec(bvl, bio_vec, iter, start) \
219 for ((iter) = start; \ 219 for (iter = (start); \
220 (bvl) = bvec_iter_bvec((bio_vec), (iter)), \ 220 (iter).bi_size && \
221 (iter).bi_size; \ 221 ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
222 bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len)) 222 bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
223 223
224 224
@@ -388,7 +388,7 @@ struct sg_iovec;
388struct rq_map_data; 388struct rq_map_data;
389extern struct bio *bio_map_user_iov(struct request_queue *, 389extern struct bio *bio_map_user_iov(struct request_queue *,
390 struct block_device *, 390 struct block_device *,
391 struct sg_iovec *, int, int, gfp_t); 391 const struct sg_iovec *, int, int, gfp_t);
392extern void bio_unmap_user(struct bio *); 392extern void bio_unmap_user(struct bio *);
393extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, 393extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
394 gfp_t); 394 gfp_t);
@@ -414,7 +414,8 @@ extern int bio_alloc_pages(struct bio *bio, gfp_t gfp);
414extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *, 414extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *,
415 unsigned long, unsigned int, int, gfp_t); 415 unsigned long, unsigned int, int, gfp_t);
416extern struct bio *bio_copy_user_iov(struct request_queue *, 416extern struct bio *bio_copy_user_iov(struct request_queue *,
417 struct rq_map_data *, struct sg_iovec *, 417 struct rq_map_data *,
418 const struct sg_iovec *,
418 int, int, gfp_t); 419 int, int, gfp_t);
419extern int bio_uncopy_user(struct bio *); 420extern int bio_uncopy_user(struct bio *);
420void zero_fill_bio(struct bio *bio); 421void zero_fill_bio(struct bio *bio);
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index bbc3a6c88fce..aa0eaa2d0bd8 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -189,6 +189,7 @@ enum rq_flag_bits {
189 __REQ_KERNEL, /* direct IO to kernel pages */ 189 __REQ_KERNEL, /* direct IO to kernel pages */
190 __REQ_PM, /* runtime pm request */ 190 __REQ_PM, /* runtime pm request */
191 __REQ_END, /* last of chain of requests */ 191 __REQ_END, /* last of chain of requests */
192 __REQ_HASHED, /* on IO scheduler merge hash */
192 __REQ_NR_BITS, /* stops here */ 193 __REQ_NR_BITS, /* stops here */
193}; 194};
194 195
@@ -241,5 +242,6 @@ enum rq_flag_bits {
241#define REQ_KERNEL (1ULL << __REQ_KERNEL) 242#define REQ_KERNEL (1ULL << __REQ_KERNEL)
242#define REQ_PM (1ULL << __REQ_PM) 243#define REQ_PM (1ULL << __REQ_PM)
243#define REQ_END (1ULL << __REQ_END) 244#define REQ_END (1ULL << __REQ_END)
245#define REQ_HASHED (1ULL << __REQ_HASHED)
244 246
245#endif /* __LINUX_BLK_TYPES_H */ 247#endif /* __LINUX_BLK_TYPES_H */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1e1fa3f93d5f..0d84981ee03f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -118,7 +118,18 @@ struct request {
118 struct bio *bio; 118 struct bio *bio;
119 struct bio *biotail; 119 struct bio *biotail;
120 120
121 struct hlist_node hash; /* merge hash */ 121 /*
122 * The hash is used inside the scheduler, and killed once the
123 * request reaches the dispatch list. The ipi_list is only used
124 * to queue the request for softirq completion, which is long
125 * after the request has been unhashed (and even removed from
126 * the dispatch list).
127 */
128 union {
129 struct hlist_node hash; /* merge hash */
130 struct list_head ipi_list;
131 };
132
122 /* 133 /*
123 * The rb_node is only used inside the io scheduler, requests 134 * The rb_node is only used inside the io scheduler, requests
124 * are pruned when moved to the dispatch queue. So let the 135 * are pruned when moved to the dispatch queue. So let the
@@ -824,8 +835,8 @@ extern int blk_rq_map_user(struct request_queue *, struct request *,
824extern int blk_rq_unmap_user(struct bio *); 835extern int blk_rq_unmap_user(struct bio *);
825extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t); 836extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t);
826extern int blk_rq_map_user_iov(struct request_queue *, struct request *, 837extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
827 struct rq_map_data *, struct sg_iovec *, int, 838 struct rq_map_data *, const struct sg_iovec *,
828 unsigned int, gfp_t); 839 int, unsigned int, gfp_t);
829extern int blk_execute_rq(struct request_queue *, struct gendisk *, 840extern int blk_execute_rq(struct request_queue *, struct gendisk *,
830 struct request *, int); 841 struct request *, int);
831extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, 842extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index d77797a52b7b..c40302f909ce 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -210,8 +210,8 @@ int block_write_full_page(struct page *page, get_block_t *get_block,
210int block_write_full_page_endio(struct page *page, get_block_t *get_block, 210int block_write_full_page_endio(struct page *page, get_block_t *get_block,
211 struct writeback_control *wbc, bh_end_io_t *handler); 211 struct writeback_control *wbc, bh_end_io_t *handler);
212int block_read_full_page(struct page*, get_block_t*); 212int block_read_full_page(struct page*, get_block_t*);
213int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc, 213int block_is_partially_uptodate(struct page *page, unsigned long from,
214 unsigned long from); 214 unsigned long count);
215int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, 215int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len,
216 unsigned flags, struct page **pagep, get_block_t *get_block); 216 unsigned flags, struct page **pagep, get_block_t *get_block);
217int __block_write_begin(struct page *page, loff_t pos, unsigned len, 217int __block_write_begin(struct page *page, loff_t pos, unsigned len,
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
new file mode 100644
index 000000000000..d1e49d52b640
--- /dev/null
+++ b/include/linux/compiler-clang.h
@@ -0,0 +1,12 @@
1#ifndef __LINUX_COMPILER_H
2#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
3#endif
4
5/* Some compiler specific definitions are overwritten here
6 * for Clang compiler
7 */
8
9#ifdef uninitialized_var
10#undef uninitialized_var
11#define uninitialized_var(x) x = *(&(x))
12#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 2472740d7ab2..ee7239ea1583 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *);
63# include <linux/compiler-intel.h> 63# include <linux/compiler-intel.h>
64#endif 64#endif
65 65
66/* Clang compiler defines __GNUC__. So we will overwrite implementations
67 * coming from above header files here
68 */
69#ifdef __clang__
70#include <linux/compiler-clang.h>
71#endif
72
66/* 73/*
67 * Generic compiler-dependent macros required for kernel 74 * Generic compiler-dependent macros required for kernel
68 * build go below this comment. Actual compiler/compiler version 75 * build go below this comment. Actual compiler/compiler version
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c48e595f623e..5ae5100c1f24 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -455,11 +455,14 @@ extern struct cpufreq_governor cpufreq_gov_conservative;
455 * FREQUENCY TABLE HELPERS * 455 * FREQUENCY TABLE HELPERS *
456 *********************************************************************/ 456 *********************************************************************/
457 457
458#define CPUFREQ_ENTRY_INVALID ~0 458/* Special Values of .frequency field */
459#define CPUFREQ_TABLE_END ~1 459#define CPUFREQ_ENTRY_INVALID ~0
460#define CPUFREQ_BOOST_FREQ ~2 460#define CPUFREQ_TABLE_END ~1
461/* Special Values of .flags field */
462#define CPUFREQ_BOOST_FREQ (1 << 0)
461 463
462struct cpufreq_frequency_table { 464struct cpufreq_frequency_table {
465 unsigned int flags;
463 unsigned int driver_data; /* driver specific data, not used by core */ 466 unsigned int driver_data; /* driver specific data, not used by core */
464 unsigned int frequency; /* kHz - doesn't need to be in ascending 467 unsigned int frequency; /* kHz - doesn't need to be in ascending
465 * order */ 468 * order */
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c5c92d59e531..8300fb87b84a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -341,15 +341,11 @@ enum dma_slave_buswidth {
341 * and this struct will then be passed in as an argument to the 341 * and this struct will then be passed in as an argument to the
342 * DMA engine device_control() function. 342 * DMA engine device_control() function.
343 * 343 *
344 * The rationale for adding configuration information to this struct 344 * The rationale for adding configuration information to this struct is as
345 * is as follows: if it is likely that most DMA slave controllers in 345 * follows: if it is likely that more than one DMA slave controllers in
346 * the world will support the configuration option, then make it 346 * the world will support the configuration option, then make it generic.
347 * generic. If not: if it is fixed so that it be sent in static from 347 * If not: if it is fixed so that it be sent in static from the platform
348 * the platform data, then prefer to do that. Else, if it is neither 348 * data, then prefer to do that.
349 * fixed at runtime, nor generic enough (such as bus mastership on
350 * some CPU family and whatnot) then create a custom slave config
351 * struct and pass that, then make this config a member of that
352 * struct, if applicable.
353 */ 349 */
354struct dma_slave_config { 350struct dma_slave_config {
355 enum dma_transfer_direction direction; 351 enum dma_transfer_direction direction;
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
index 481ab2345d6b..68b4024184de 100644
--- a/include/linux/dw_dmac.h
+++ b/include/linux/dw_dmac.h
@@ -1,6 +1,5 @@
1/* 1/*
2 * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on 2 * Driver for the Synopsys DesignWare DMA Controller
3 * AVR32 systems.)
4 * 3 *
5 * Copyright (C) 2007 Atmel Corporation 4 * Copyright (C) 2007 Atmel Corporation
6 * Copyright (C) 2010-2011 ST Microelectronics 5 * Copyright (C) 2010-2011 ST Microelectronics
@@ -44,8 +43,6 @@ struct dw_dma_slave {
44 * @nr_masters: Number of AHB masters supported by the controller 43 * @nr_masters: Number of AHB masters supported by the controller
45 * @data_width: Maximum data width supported by hardware per AHB master 44 * @data_width: Maximum data width supported by hardware per AHB master
46 * (0 - 8bits, 1 - 16bits, ..., 5 - 256bits) 45 * (0 - 8bits, 1 - 16bits, ..., 5 - 256bits)
47 * @sd: slave specific data. Used for configuring channels
48 * @sd_count: count of slave data structures passed.
49 */ 46 */
50struct dw_dma_platform_data { 47struct dw_dma_platform_data {
51 unsigned int nr_channels; 48 unsigned int nr_channels;
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 70e8e21c0a30..230f87bdf5ad 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -63,8 +63,6 @@ struct file_operations;
63struct vfsmount; 63struct vfsmount;
64struct dentry; 64struct dentry;
65 65
66extern void __init files_defer_init(void);
67
68#define rcu_dereference_check_fdtable(files, fdtfd) \ 66#define rcu_dereference_check_fdtable(files, fdtfd) \
69 rcu_dereference_check((fdtfd), lockdep_is_held(&(files)->file_lock)) 67 rcu_dereference_check((fdtfd), lockdep_is_held(&(files)->file_lock))
70 68
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 81048f9bc783..7a9c5bca2b76 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -48,6 +48,7 @@ struct cred;
48struct swap_info_struct; 48struct swap_info_struct;
49struct seq_file; 49struct seq_file;
50struct workqueue_struct; 50struct workqueue_struct;
51struct iov_iter;
51 52
52extern void __init inode_init(void); 53extern void __init inode_init(void);
53extern void __init inode_init_early(void); 54extern void __init inode_init_early(void);
@@ -125,6 +126,8 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
125 126
126/* File needs atomic accesses to f_pos */ 127/* File needs atomic accesses to f_pos */
127#define FMODE_ATOMIC_POS ((__force fmode_t)0x8000) 128#define FMODE_ATOMIC_POS ((__force fmode_t)0x8000)
129/* Write access to underlying fs */
130#define FMODE_WRITER ((__force fmode_t)0x10000)
128 131
129/* File was opened by fanotify and shouldn't generate fanotify events */ 132/* File was opened by fanotify and shouldn't generate fanotify events */
130#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 133#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
@@ -293,38 +296,6 @@ struct page;
293struct address_space; 296struct address_space;
294struct writeback_control; 297struct writeback_control;
295 298
296struct iov_iter {
297 const struct iovec *iov;
298 unsigned long nr_segs;
299 size_t iov_offset;
300 size_t count;
301};
302
303size_t iov_iter_copy_from_user_atomic(struct page *page,
304 struct iov_iter *i, unsigned long offset, size_t bytes);
305size_t iov_iter_copy_from_user(struct page *page,
306 struct iov_iter *i, unsigned long offset, size_t bytes);
307void iov_iter_advance(struct iov_iter *i, size_t bytes);
308int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
309size_t iov_iter_single_seg_count(const struct iov_iter *i);
310
311static inline void iov_iter_init(struct iov_iter *i,
312 const struct iovec *iov, unsigned long nr_segs,
313 size_t count, size_t written)
314{
315 i->iov = iov;
316 i->nr_segs = nr_segs;
317 i->iov_offset = 0;
318 i->count = count + written;
319
320 iov_iter_advance(i, written);
321}
322
323static inline size_t iov_iter_count(struct iov_iter *i)
324{
325 return i->count;
326}
327
328/* 299/*
329 * "descriptor" for what we're up to with a read. 300 * "descriptor" for what we're up to with a read.
330 * This allows us to use the same read code yet 301 * This allows us to use the same read code yet
@@ -383,7 +354,7 @@ struct address_space_operations {
383 int (*migratepage) (struct address_space *, 354 int (*migratepage) (struct address_space *,
384 struct page *, struct page *, enum migrate_mode); 355 struct page *, struct page *, enum migrate_mode);
385 int (*launder_page) (struct page *); 356 int (*launder_page) (struct page *);
386 int (*is_partially_uptodate) (struct page *, read_descriptor_t *, 357 int (*is_partially_uptodate) (struct page *, unsigned long,
387 unsigned long); 358 unsigned long);
388 void (*is_dirty_writeback) (struct page *, bool *, bool *); 359 void (*is_dirty_writeback) (struct page *, bool *, bool *);
389 int (*error_remove_page)(struct address_space *, struct page *); 360 int (*error_remove_page)(struct address_space *, struct page *);
@@ -770,9 +741,6 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
770 index < ra->start + ra->size); 741 index < ra->start + ra->size);
771} 742}
772 743
773#define FILE_MNT_WRITE_TAKEN 1
774#define FILE_MNT_WRITE_RELEASED 2
775
776struct file { 744struct file {
777 union { 745 union {
778 struct llist_node fu_llist; 746 struct llist_node fu_llist;
@@ -810,9 +778,6 @@ struct file {
810 struct list_head f_tfile_llink; 778 struct list_head f_tfile_llink;
811#endif /* #ifdef CONFIG_EPOLL */ 779#endif /* #ifdef CONFIG_EPOLL */
812 struct address_space *f_mapping; 780 struct address_space *f_mapping;
813#ifdef CONFIG_DEBUG_WRITECOUNT
814 unsigned long f_mnt_write_state;
815#endif
816} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ 781} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
817 782
818struct file_handle { 783struct file_handle {
@@ -830,49 +795,6 @@ static inline struct file *get_file(struct file *f)
830#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) 795#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1)
831#define file_count(x) atomic_long_read(&(x)->f_count) 796#define file_count(x) atomic_long_read(&(x)->f_count)
832 797
833#ifdef CONFIG_DEBUG_WRITECOUNT
834static inline void file_take_write(struct file *f)
835{
836 WARN_ON(f->f_mnt_write_state != 0);
837 f->f_mnt_write_state = FILE_MNT_WRITE_TAKEN;
838}
839static inline void file_release_write(struct file *f)
840{
841 f->f_mnt_write_state |= FILE_MNT_WRITE_RELEASED;
842}
843static inline void file_reset_write(struct file *f)
844{
845 f->f_mnt_write_state = 0;
846}
847static inline void file_check_state(struct file *f)
848{
849 /*
850 * At this point, either both or neither of these bits
851 * should be set.
852 */
853 WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN);
854 WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_RELEASED);
855}
856static inline int file_check_writeable(struct file *f)
857{
858 if (f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN)
859 return 0;
860 printk(KERN_WARNING "writeable file with no "
861 "mnt_want_write()\n");
862 WARN_ON(1);
863 return -EINVAL;
864}
865#else /* !CONFIG_DEBUG_WRITECOUNT */
866static inline void file_take_write(struct file *filp) {}
867static inline void file_release_write(struct file *filp) {}
868static inline void file_reset_write(struct file *filp) {}
869static inline void file_check_state(struct file *filp) {}
870static inline int file_check_writeable(struct file *filp)
871{
872 return 0;
873}
874#endif /* CONFIG_DEBUG_WRITECOUNT */
875
876#define MAX_NON_LFS ((1UL<<31) - 1) 798#define MAX_NON_LFS ((1UL<<31) - 1)
877 799
878/* Page cache limit. The filesystems should put that into their s_maxbytes 800/* Page cache limit. The filesystems should put that into their s_maxbytes
@@ -2481,16 +2403,13 @@ extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2481extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); 2403extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
2482extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr, 2404extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr,
2483 unsigned long size, pgoff_t pgoff); 2405 unsigned long size, pgoff_t pgoff);
2484extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
2485int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); 2406int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
2486extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t); 2407extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t);
2487extern ssize_t __generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, 2408extern ssize_t __generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long);
2488 loff_t *);
2489extern ssize_t generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, loff_t); 2409extern ssize_t generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, loff_t);
2490extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *, 2410extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *,
2491 unsigned long *, loff_t, loff_t *, size_t, size_t); 2411 unsigned long *, loff_t, size_t, size_t);
2492extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *, 2412extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t);
2493 unsigned long, loff_t, loff_t *, size_t, ssize_t);
2494extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); 2413extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos);
2495extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2414extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
2496extern int generic_segment_checks(const struct iovec *iov, 2415extern int generic_segment_checks(const struct iovec *iov,
@@ -2582,7 +2501,7 @@ extern const struct file_operations generic_ro_fops;
2582 2501
2583#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) 2502#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
2584 2503
2585extern int vfs_readlink(struct dentry *, char __user *, int, const char *); 2504extern int readlink_copy(char __user *, int, const char *);
2586extern int page_readlink(struct dentry *, char __user *, int); 2505extern int page_readlink(struct dentry *, char __user *, int);
2587extern void *page_follow_link_light(struct dentry *, struct nameidata *); 2506extern void *page_follow_link_light(struct dentry *, struct nameidata *);
2588extern void page_put_link(struct dentry *, struct nameidata *, void *); 2507extern void page_put_link(struct dentry *, struct nameidata *, void *);
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index cdc30111d2f8..d16da3e53bc7 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -7,6 +7,7 @@
7#include <linux/percpu.h> 7#include <linux/percpu.h>
8#include <linux/hardirq.h> 8#include <linux/hardirq.h>
9#include <linux/perf_event.h> 9#include <linux/perf_event.h>
10#include <linux/tracepoint.h>
10 11
11struct trace_array; 12struct trace_array;
12struct trace_buffer; 13struct trace_buffer;
@@ -232,6 +233,7 @@ enum {
232 TRACE_EVENT_FL_IGNORE_ENABLE_BIT, 233 TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
233 TRACE_EVENT_FL_WAS_ENABLED_BIT, 234 TRACE_EVENT_FL_WAS_ENABLED_BIT,
234 TRACE_EVENT_FL_USE_CALL_FILTER_BIT, 235 TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
236 TRACE_EVENT_FL_TRACEPOINT_BIT,
235}; 237};
236 238
237/* 239/*
@@ -244,6 +246,7 @@ enum {
244 * (used for module unloading, if a module event is enabled, 246 * (used for module unloading, if a module event is enabled,
245 * it is best to clear the buffers that used it). 247 * it is best to clear the buffers that used it).
246 * USE_CALL_FILTER - For ftrace internal events, don't use file filter 248 * USE_CALL_FILTER - For ftrace internal events, don't use file filter
249 * TRACEPOINT - Event is a tracepoint
247 */ 250 */
248enum { 251enum {
249 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT), 252 TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
@@ -252,12 +255,17 @@ enum {
252 TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT), 255 TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
253 TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT), 256 TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT),
254 TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT), 257 TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
258 TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
255}; 259};
256 260
257struct ftrace_event_call { 261struct ftrace_event_call {
258 struct list_head list; 262 struct list_head list;
259 struct ftrace_event_class *class; 263 struct ftrace_event_class *class;
260 char *name; 264 union {
265 char *name;
266 /* Set TRACE_EVENT_FL_TRACEPOINT flag when using "tp" */
267 struct tracepoint *tp;
268 };
261 struct trace_event event; 269 struct trace_event event;
262 const char *print_fmt; 270 const char *print_fmt;
263 struct event_filter *filter; 271 struct event_filter *filter;
@@ -271,6 +279,7 @@ struct ftrace_event_call {
271 * bit 3: ftrace internal event (do not enable) 279 * bit 3: ftrace internal event (do not enable)
272 * bit 4: Event was enabled by module 280 * bit 4: Event was enabled by module
273 * bit 5: use call filter rather than file filter 281 * bit 5: use call filter rather than file filter
282 * bit 6: Event is a tracepoint
274 */ 283 */
275 int flags; /* static flags of different events */ 284 int flags; /* static flags of different events */
276 285
@@ -283,6 +292,15 @@ struct ftrace_event_call {
283#endif 292#endif
284}; 293};
285 294
295static inline const char *
296ftrace_event_name(struct ftrace_event_call *call)
297{
298 if (call->flags & TRACE_EVENT_FL_TRACEPOINT)
299 return call->tp ? call->tp->name : NULL;
300 else
301 return call->name;
302}
303
286struct trace_array; 304struct trace_array;
287struct ftrace_subsystem_dir; 305struct ftrace_subsystem_dir;
288 306
@@ -353,7 +371,7 @@ struct ftrace_event_file {
353#define __TRACE_EVENT_FLAGS(name, value) \ 371#define __TRACE_EVENT_FLAGS(name, value) \
354 static int __init trace_init_flags_##name(void) \ 372 static int __init trace_init_flags_##name(void) \
355 { \ 373 { \
356 event_##name.flags = value; \ 374 event_##name.flags |= value; \
357 return 0; \ 375 return 0; \
358 } \ 376 } \
359 early_initcall(trace_init_flags_##name); 377 early_initcall(trace_init_flags_##name);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index deddeb8c337c..b556e0ab946f 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -487,6 +487,7 @@ void i2c_unlock_adapter(struct i2c_adapter *);
487#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ 487#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
488#define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */ 488#define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */
489#define I2C_CLASS_SPD (1<<7) /* Memory modules */ 489#define I2C_CLASS_SPD (1<<7) /* Memory modules */
490#define I2C_CLASS_DEPRECATED (1<<8) /* Warn users that adapter will stop using classes */
490 491
491/* Internal numbers to terminate lists */ 492/* Internal numbers to terminate lists */
492#define I2C_CLIENT_END 0xfffeU 493#define I2C_CLIENT_END 0xfffeU
diff --git a/include/linux/i2c/bfin_twi.h b/include/linux/i2c/bfin_twi.h
new file mode 100644
index 000000000000..135a4e0876ae
--- /dev/null
+++ b/include/linux/i2c/bfin_twi.h
@@ -0,0 +1,145 @@
1/*
2 * i2c-bfin-twi.h - interface to ADI TWI controller
3 *
4 * Copyright 2005-2014 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __I2C_BFIN_TWI_H__
10#define __I2C_BFIN_TWI_H__
11
12#include <linux/types.h>
13#include <linux/i2c.h>
14
15/*
16 * ADI twi registers layout
17 */
18struct bfin_twi_regs {
19 u16 clkdiv;
20 u16 dummy1;
21 u16 control;
22 u16 dummy2;
23 u16 slave_ctl;
24 u16 dummy3;
25 u16 slave_stat;
26 u16 dummy4;
27 u16 slave_addr;
28 u16 dummy5;
29 u16 master_ctl;
30 u16 dummy6;
31 u16 master_stat;
32 u16 dummy7;
33 u16 master_addr;
34 u16 dummy8;
35 u16 int_stat;
36 u16 dummy9;
37 u16 int_mask;
38 u16 dummy10;
39 u16 fifo_ctl;
40 u16 dummy11;
41 u16 fifo_stat;
42 u16 dummy12;
43 u32 __pad[20];
44 u16 xmt_data8;
45 u16 dummy13;
46 u16 xmt_data16;
47 u16 dummy14;
48 u16 rcv_data8;
49 u16 dummy15;
50 u16 rcv_data16;
51 u16 dummy16;
52};
53
54struct bfin_twi_iface {
55 int irq;
56 spinlock_t lock;
57 char read_write;
58 u8 command;
59 u8 *transPtr;
60 int readNum;
61 int writeNum;
62 int cur_mode;
63 int manual_stop;
64 int result;
65 struct i2c_adapter adap;
66 struct completion complete;
67 struct i2c_msg *pmsg;
68 int msg_num;
69 int cur_msg;
70 u16 saved_clkdiv;
71 u16 saved_control;
72 struct bfin_twi_regs __iomem *regs_base;
73};
74
75/* ******************** TWO-WIRE INTERFACE (TWI) MASKS ********************/
76/* TWI_CLKDIV Macros (Use: *pTWI_CLKDIV = CLKLOW(x)|CLKHI(y); ) */
77#define CLKLOW(x) ((x) & 0xFF) /* Periods Clock Is Held Low */
78#define CLKHI(y) (((y)&0xFF)<<0x8) /* Periods Before New Clock Low */
79
80/* TWI_PRESCALE Masks */
81#define PRESCALE 0x007F /* SCLKs Per Internal Time Reference (10MHz) */
82#define TWI_ENA 0x0080 /* TWI Enable */
83#define SCCB 0x0200 /* SCCB Compatibility Enable */
84
85/* TWI_SLAVE_CTL Masks */
86#define SEN 0x0001 /* Slave Enable */
87#define SADD_LEN 0x0002 /* Slave Address Length */
88#define STDVAL 0x0004 /* Slave Transmit Data Valid */
89#define NAK 0x0008 /* NAK Generated At Conclusion Of Transfer */
90#define GEN 0x0010 /* General Call Address Matching Enabled */
91
92/* TWI_SLAVE_STAT Masks */
93#define SDIR 0x0001 /* Slave Transfer Direction (RX/TX*) */
94#define GCALL 0x0002 /* General Call Indicator */
95
96/* TWI_MASTER_CTL Masks */
97#define MEN 0x0001 /* Master Mode Enable */
98#define MADD_LEN 0x0002 /* Master Address Length */
99#define MDIR 0x0004 /* Master Transmit Direction (RX/TX*) */
100#define FAST 0x0008 /* Use Fast Mode Timing Specs */
101#define STOP 0x0010 /* Issue Stop Condition */
102#define RSTART 0x0020 /* Repeat Start or Stop* At End Of Transfer */
103#define DCNT 0x3FC0 /* Data Bytes To Transfer */
104#define SDAOVR 0x4000 /* Serial Data Override */
105#define SCLOVR 0x8000 /* Serial Clock Override */
106
107/* TWI_MASTER_STAT Masks */
108#define MPROG 0x0001 /* Master Transfer In Progress */
109#define LOSTARB 0x0002 /* Lost Arbitration Indicator (Xfer Aborted) */
110#define ANAK 0x0004 /* Address Not Acknowledged */
111#define DNAK 0x0008 /* Data Not Acknowledged */
112#define BUFRDERR 0x0010 /* Buffer Read Error */
113#define BUFWRERR 0x0020 /* Buffer Write Error */
114#define SDASEN 0x0040 /* Serial Data Sense */
115#define SCLSEN 0x0080 /* Serial Clock Sense */
116#define BUSBUSY 0x0100 /* Bus Busy Indicator */
117
118/* TWI_INT_SRC and TWI_INT_ENABLE Masks */
119#define SINIT 0x0001 /* Slave Transfer Initiated */
120#define SCOMP 0x0002 /* Slave Transfer Complete */
121#define SERR 0x0004 /* Slave Transfer Error */
122#define SOVF 0x0008 /* Slave Overflow */
123#define MCOMP 0x0010 /* Master Transfer Complete */
124#define MERR 0x0020 /* Master Transfer Error */
125#define XMTSERV 0x0040 /* Transmit FIFO Service */
126#define RCVSERV 0x0080 /* Receive FIFO Service */
127
128/* TWI_FIFO_CTRL Masks */
129#define XMTFLUSH 0x0001 /* Transmit Buffer Flush */
130#define RCVFLUSH 0x0002 /* Receive Buffer Flush */
131#define XMTINTLEN 0x0004 /* Transmit Buffer Interrupt Length */
132#define RCVINTLEN 0x0008 /* Receive Buffer Interrupt Length */
133
134/* TWI_FIFO_STAT Masks */
135#define XMTSTAT 0x0003 /* Transmit FIFO Status */
136#define XMT_EMPTY 0x0000 /* Transmit FIFO Empty */
137#define XMT_HALF 0x0001 /* Transmit FIFO Has 1 Byte To Write */
138#define XMT_FULL 0x0003 /* Transmit FIFO Full (2 Bytes To Write) */
139
140#define RCVSTAT 0x000C /* Receive FIFO Status */
141#define RCV_EMPTY 0x0000 /* Receive FIFO Empty */
142#define RCV_HALF 0x0004 /* Receive FIFO Has 1 Byte To Read */
143#define RCV_FULL 0x000C /* Receive FIFO Full (2 Bytes To Read) */
144
145#endif
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index ac39d910e70b..a326c850f046 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -104,6 +104,9 @@ enum {
104 MC13892_LED_R, 104 MC13892_LED_R,
105 MC13892_LED_G, 105 MC13892_LED_G,
106 MC13892_LED_B, 106 MC13892_LED_B,
107 /* MC34708 LED IDs */
108 MC34708_LED_R,
109 MC34708_LED_G,
107}; 110};
108 111
109struct mc13xxx_led_platform_data { 112struct mc13xxx_led_platform_data {
@@ -163,6 +166,9 @@ struct mc13xxx_leds_platform_data {
163#define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21) 166#define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21)
164/* MC13892 LED Control 3 */ 167/* MC13892 LED Control 3 */
165#define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9) 168#define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9)
169/* MC34708 LED Control 0 */
170#define MC34708_LED_C0_CURRENT_R(x) (((x) & 0x3) << 9)
171#define MC34708_LED_C0_CURRENT_G(x) (((x) & 0x3) << 21)
166 u32 led_control[MAX_LED_CONTROL_REGS]; 172 u32 led_control[MAX_LED_CONTROL_REGS];
167}; 173};
168 174
diff --git a/include/linux/mfd/rtsx_common.h b/include/linux/mfd/rtsx_common.h
index 443176ee1ab0..7c36cc55d2c7 100644
--- a/include/linux/mfd/rtsx_common.h
+++ b/include/linux/mfd/rtsx_common.h
@@ -45,6 +45,7 @@ struct platform_device;
45struct rtsx_slot { 45struct rtsx_slot {
46 struct platform_device *p_dev; 46 struct platform_device *p_dev;
47 void (*card_event)(struct platform_device *p_dev); 47 void (*card_event)(struct platform_device *p_dev);
48 void (*done_transfer)(struct platform_device *p_dev);
48}; 49};
49 50
50#endif 51#endif
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 0ce772105508..8d6bbd609ad9 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -144,7 +144,7 @@
144#define HOST_TO_DEVICE 0 144#define HOST_TO_DEVICE 0
145#define DEVICE_TO_HOST 1 145#define DEVICE_TO_HOST 1
146 146
147#define MAX_PHASE 31 147#define RTSX_PHASE_MAX 32
148#define RX_TUNING_CNT 3 148#define RX_TUNING_CNT 3
149 149
150/* SG descriptor */ 150/* SG descriptor */
@@ -943,6 +943,12 @@ void rtsx_pci_send_cmd_no_wait(struct rtsx_pcr *pcr);
943int rtsx_pci_send_cmd(struct rtsx_pcr *pcr, int timeout); 943int rtsx_pci_send_cmd(struct rtsx_pcr *pcr, int timeout);
944int rtsx_pci_transfer_data(struct rtsx_pcr *pcr, struct scatterlist *sglist, 944int rtsx_pci_transfer_data(struct rtsx_pcr *pcr, struct scatterlist *sglist,
945 int num_sg, bool read, int timeout); 945 int num_sg, bool read, int timeout);
946int rtsx_pci_dma_map_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
947 int num_sg, bool read);
948int rtsx_pci_dma_unmap_sg(struct rtsx_pcr *pcr, struct scatterlist *sglist,
949 int num_sg, bool read);
950int rtsx_pci_dma_transfer(struct rtsx_pcr *pcr, struct scatterlist *sglist,
951 int sg_count, bool read);
946int rtsx_pci_read_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len); 952int rtsx_pci_read_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len);
947int rtsx_pci_write_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len); 953int rtsx_pci_write_ppbuf(struct rtsx_pcr *pcr, u8 *buf, int buf_len);
948int rtsx_pci_card_pull_ctl_enable(struct rtsx_pcr *pcr, int card); 954int rtsx_pci_card_pull_ctl_enable(struct rtsx_pcr *pcr, int card);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index abc848412e3c..bf9811e1321a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1204,6 +1204,7 @@ void account_page_writeback(struct page *page);
1204int set_page_dirty(struct page *page); 1204int set_page_dirty(struct page *page);
1205int set_page_dirty_lock(struct page *page); 1205int set_page_dirty_lock(struct page *page);
1206int clear_page_dirty_for_io(struct page *page); 1206int clear_page_dirty_for_io(struct page *page);
1207int get_cmdline(struct task_struct *task, char *buffer, int buflen);
1207 1208
1208/* Is the vma a continuation of the stack vma above it? */ 1209/* Is the vma a continuation of the stack vma above it? */
1209static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr) 1210static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 87079fc38011..f206e29f94d7 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -95,7 +95,7 @@ struct mmc_command {
95 * actively failing requests 95 * actively failing requests
96 */ 96 */
97 97
98 unsigned int cmd_timeout_ms; /* in milliseconds */ 98 unsigned int busy_timeout; /* busy detect timeout in ms */
99 /* Set this flag only for blocking sanitize request */ 99 /* Set this flag only for blocking sanitize request */
100 bool sanitize_busy; 100 bool sanitize_busy;
101 101
@@ -152,7 +152,7 @@ extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
152 struct mmc_command *, int); 152 struct mmc_command *, int);
153extern void mmc_start_bkops(struct mmc_card *card, bool from_exception); 153extern void mmc_start_bkops(struct mmc_card *card, bool from_exception);
154extern int __mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int, bool, 154extern int __mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int, bool,
155 bool); 155 bool, bool);
156extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int); 156extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
157extern int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd); 157extern int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
158 158
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 99f5709ac343..cb61ea4d6945 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -264,15 +264,12 @@ struct mmc_host {
264 u32 caps2; /* More host capabilities */ 264 u32 caps2; /* More host capabilities */
265 265
266#define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */ 266#define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */
267#define MMC_CAP2_CACHE_CTRL (1 << 1) /* Allow cache control */
268#define MMC_CAP2_FULL_PWR_CYCLE (1 << 2) /* Can do full power cycle */ 267#define MMC_CAP2_FULL_PWR_CYCLE (1 << 2) /* Can do full power cycle */
269#define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */ 268#define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */
270#define MMC_CAP2_NO_SLEEP_CMD (1 << 4) /* Don't allow sleep command */
271#define MMC_CAP2_HS200_1_8V_SDR (1 << 5) /* can support */ 269#define MMC_CAP2_HS200_1_8V_SDR (1 << 5) /* can support */
272#define MMC_CAP2_HS200_1_2V_SDR (1 << 6) /* can support */ 270#define MMC_CAP2_HS200_1_2V_SDR (1 << 6) /* can support */
273#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ 271#define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \
274 MMC_CAP2_HS200_1_2V_SDR) 272 MMC_CAP2_HS200_1_2V_SDR)
275#define MMC_CAP2_BROKEN_VOLTAGE (1 << 7) /* Use the broken voltage */
276#define MMC_CAP2_HC_ERASE_SZ (1 << 9) /* High-capacity erase size */ 273#define MMC_CAP2_HC_ERASE_SZ (1 << 9) /* High-capacity erase size */
277#define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10) /* Card-detect signal active high */ 274#define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10) /* Card-detect signal active high */
278#define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11) /* Write-protect signal active high */ 275#define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11) /* Write-protect signal active high */
@@ -281,7 +278,6 @@ struct mmc_host {
281#define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \ 278#define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \
282 MMC_CAP2_PACKED_WR) 279 MMC_CAP2_PACKED_WR)
283#define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14) /* Don't power up before scan */ 280#define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14) /* Don't power up before scan */
284#define MMC_CAP2_SANITIZE (1 << 15) /* Support Sanitize */
285 281
286 mmc_pm_flag_t pm_caps; /* supported pm features */ 282 mmc_pm_flag_t pm_caps; /* supported pm features */
287 283
@@ -304,7 +300,7 @@ struct mmc_host {
304 unsigned int max_req_size; /* maximum number of bytes in one req */ 300 unsigned int max_req_size; /* maximum number of bytes in one req */
305 unsigned int max_blk_size; /* maximum size of one mmc block */ 301 unsigned int max_blk_size; /* maximum size of one mmc block */
306 unsigned int max_blk_count; /* maximum number of blocks in one req */ 302 unsigned int max_blk_count; /* maximum number of blocks in one req */
307 unsigned int max_discard_to; /* max. discard timeout in ms */ 303 unsigned int max_busy_timeout; /* max busy timeout in ms */
308 304
309 /* private data */ 305 /* private data */
310 spinlock_t lock; /* lock for claim and bus ops */ 306 spinlock_t lock; /* lock for claim and bus ops */
@@ -388,8 +384,6 @@ int mmc_power_restore_host(struct mmc_host *host);
388void mmc_detect_change(struct mmc_host *, unsigned long delay); 384void mmc_detect_change(struct mmc_host *, unsigned long delay);
389void mmc_request_done(struct mmc_host *, struct mmc_request *); 385void mmc_request_done(struct mmc_host *, struct mmc_request *);
390 386
391int mmc_cache_ctrl(struct mmc_host *, u8);
392
393static inline void mmc_signal_sdio_irq(struct mmc_host *host) 387static inline void mmc_signal_sdio_irq(struct mmc_host *host)
394{ 388{
395 host->ops->enable_sdio_irq(host, 0); 389 host->ops->enable_sdio_irq(host, 0);
@@ -424,12 +418,9 @@ static inline int mmc_regulator_get_supply(struct mmc_host *mmc)
424 418
425int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); 419int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *);
426 420
427/* Module parameter */
428extern bool mmc_assume_removable;
429
430static inline int mmc_card_is_removable(struct mmc_host *host) 421static inline int mmc_card_is_removable(struct mmc_host *host)
431{ 422{
432 return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; 423 return !(host->caps & MMC_CAP_NONREMOVABLE);
433} 424}
434 425
435static inline int mmc_card_keep_power(struct mmc_host *host) 426static inline int mmc_card_keep_power(struct mmc_host *host)
diff --git a/include/linux/mmc/sdhci-spear.h b/include/linux/mmc/sdhci-spear.h
index e78c0e236e9d..8cc095a76cf8 100644
--- a/include/linux/mmc/sdhci-spear.h
+++ b/include/linux/mmc/sdhci-spear.h
@@ -18,17 +18,9 @@
18/* 18/*
19 * struct sdhci_plat_data: spear sdhci platform data structure 19 * struct sdhci_plat_data: spear sdhci platform data structure
20 * 20 *
21 * @card_power_gpio: gpio pin for enabling/disabling power to sdhci socket
22 * @power_active_high: if set, enable power to sdhci socket by setting
23 * card_power_gpio
24 * @power_always_enb: If set, then enable power on probe, otherwise enable only
25 * on card insertion and disable on card removal.
26 * card_int_gpio: gpio pin used for card detection 21 * card_int_gpio: gpio pin used for card detection
27 */ 22 */
28struct sdhci_plat_data { 23struct sdhci_plat_data {
29 int card_power_gpio;
30 int power_active_high;
31 int power_always_enb;
32 int card_int_gpio; 24 int card_int_gpio;
33}; 25};
34 26
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 362927c48f97..7be12b883485 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -100,6 +100,8 @@ struct sdhci_host {
100#define SDHCI_QUIRK2_BROKEN_HOST_CONTROL (1<<5) 100#define SDHCI_QUIRK2_BROKEN_HOST_CONTROL (1<<5)
101/* Controller does not support HS200 */ 101/* Controller does not support HS200 */
102#define SDHCI_QUIRK2_BROKEN_HS200 (1<<6) 102#define SDHCI_QUIRK2_BROKEN_HS200 (1<<6)
103/* Controller does not support DDR50 */
104#define SDHCI_QUIRK2_BROKEN_DDR50 (1<<7)
103 105
104 int irq; /* Device IRQ */ 106 int irq; /* Device IRQ */
105 void __iomem *ioaddr; /* Mapped address */ 107 void __iomem *ioaddr; /* Mapped address */
diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h
index b0c73e4cacea..d2433381e828 100644
--- a/include/linux/mmc/slot-gpio.h
+++ b/include/linux/mmc/slot-gpio.h
@@ -22,4 +22,10 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
22 unsigned int debounce); 22 unsigned int debounce);
23void mmc_gpio_free_cd(struct mmc_host *host); 23void mmc_gpio_free_cd(struct mmc_host *host);
24 24
25int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
26 unsigned int idx, bool override_active_level,
27 unsigned int debounce);
28void mmc_gpiod_free_cd(struct mmc_host *host);
29void mmc_gpiod_request_cd_irq(struct mmc_host *host);
30
25#endif 31#endif
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 9a165a213d93..44eeef0da186 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -556,6 +556,11 @@ struct amba_id {
556 * See documentation of "x86_match_cpu" for details. 556 * See documentation of "x86_match_cpu" for details.
557 */ 557 */
558 558
559/*
560 * MODULE_DEVICE_TABLE expects this struct to be called x86cpu_device_id.
561 * Although gcc seems to ignore this error, clang fails without this define.
562 */
563#define x86cpu_device_id x86_cpu_id
559struct x86_cpu_id { 564struct x86_cpu_id {
560 __u16 vendor; 565 __u16 vendor;
561 __u16 family; 566 __u16 family;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 371d346fa270..839bac270904 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -44,6 +44,8 @@ struct mnt_namespace;
44#define MNT_SHARED_MASK (MNT_UNBINDABLE) 44#define MNT_SHARED_MASK (MNT_UNBINDABLE)
45#define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE) 45#define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE)
46 46
47#define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
48 MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED)
47 49
48#define MNT_INTERNAL 0x4000 50#define MNT_INTERNAL 0x4000
49 51
@@ -51,6 +53,7 @@ struct mnt_namespace;
51#define MNT_LOCKED 0x800000 53#define MNT_LOCKED 0x800000
52#define MNT_DOOMED 0x1000000 54#define MNT_DOOMED 0x1000000
53#define MNT_SYNC_UMOUNT 0x2000000 55#define MNT_SYNC_UMOUNT 0x2000000
56#define MNT_MARKED 0x4000000
54 57
55struct vfsmount { 58struct vfsmount {
56 struct dentry *mnt_root; /* root of the mounted tree */ 59 struct dentry *mnt_root; /* root of the mounted tree */
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index ae4981ebd18e..f62f78aef4ac 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -24,8 +24,7 @@ struct request;
24struct nbd_device { 24struct nbd_device {
25 int flags; 25 int flags;
26 int harderror; /* Code of hard error */ 26 int harderror; /* Code of hard error */
27 struct socket * sock; 27 struct socket * sock; /* If == NULL, device is not ready, yet */
28 struct file * file; /* If == NULL, device is not ready, yet */
29 int magic; 28 int magic;
30 29
31 spinlock_t queue_lock; 30 spinlock_t queue_lock;
diff --git a/include/linux/ntb.h b/include/linux/ntb.h
index f6a15205853b..9ac1a62fc6f5 100644
--- a/include/linux/ntb.h
+++ b/include/linux/ntb.h
@@ -50,8 +50,13 @@ struct ntb_transport_qp;
50 50
51struct ntb_client { 51struct ntb_client {
52 struct device_driver driver; 52 struct device_driver driver;
53 int (*probe) (struct pci_dev *pdev); 53 int (*probe)(struct pci_dev *pdev);
54 void (*remove) (struct pci_dev *pdev); 54 void (*remove)(struct pci_dev *pdev);
55};
56
57enum {
58 NTB_LINK_DOWN = 0,
59 NTB_LINK_UP,
55}; 60};
56 61
57int ntb_register_client(struct ntb_client *drvr); 62int ntb_register_client(struct ntb_client *drvr);
@@ -60,11 +65,11 @@ int ntb_register_client_dev(char *device_name);
60void ntb_unregister_client_dev(char *device_name); 65void ntb_unregister_client_dev(char *device_name);
61 66
62struct ntb_queue_handlers { 67struct ntb_queue_handlers {
63 void (*rx_handler) (struct ntb_transport_qp *qp, void *qp_data, 68 void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data,
64 void *data, int len); 69 void *data, int len);
65 void (*tx_handler) (struct ntb_transport_qp *qp, void *qp_data, 70 void (*tx_handler)(struct ntb_transport_qp *qp, void *qp_data,
66 void *data, int len); 71 void *data, int len);
67 void (*event_handler) (void *data, int status); 72 void (*event_handler)(void *data, int status);
68}; 73};
69 74
70unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp); 75unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp);
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 6b9aafed225f..a50173ca1d72 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -66,20 +66,25 @@ enum {
66 66
67#define NVME_VS(major, minor) (major << 16 | minor) 67#define NVME_VS(major, minor) (major << 16 | minor)
68 68
69#define NVME_IO_TIMEOUT (5 * HZ) 69extern unsigned char io_timeout;
70#define NVME_IO_TIMEOUT (io_timeout * HZ)
70 71
71/* 72/*
72 * Represents an NVM Express device. Each nvme_dev is a PCI function. 73 * Represents an NVM Express device. Each nvme_dev is a PCI function.
73 */ 74 */
74struct nvme_dev { 75struct nvme_dev {
75 struct list_head node; 76 struct list_head node;
76 struct nvme_queue **queues; 77 struct nvme_queue __rcu **queues;
78 unsigned short __percpu *io_queue;
77 u32 __iomem *dbs; 79 u32 __iomem *dbs;
78 struct pci_dev *pci_dev; 80 struct pci_dev *pci_dev;
79 struct dma_pool *prp_page_pool; 81 struct dma_pool *prp_page_pool;
80 struct dma_pool *prp_small_pool; 82 struct dma_pool *prp_small_pool;
81 int instance; 83 int instance;
82 int queue_count; 84 unsigned queue_count;
85 unsigned online_queues;
86 unsigned max_qid;
87 int q_depth;
83 u32 db_stride; 88 u32 db_stride;
84 u32 ctrl_config; 89 u32 ctrl_config;
85 struct msix_entry *entry; 90 struct msix_entry *entry;
@@ -89,6 +94,7 @@ struct nvme_dev {
89 struct miscdevice miscdev; 94 struct miscdevice miscdev;
90 work_func_t reset_workfn; 95 work_func_t reset_workfn;
91 struct work_struct reset_work; 96 struct work_struct reset_work;
97 struct notifier_block nb;
92 char name[12]; 98 char name[12];
93 char serial[20]; 99 char serial[20];
94 char model[40]; 100 char model[40];
@@ -131,6 +137,7 @@ struct nvme_iod {
131 int length; /* Of data, in bytes */ 137 int length; /* Of data, in bytes */
132 unsigned long start_time; 138 unsigned long start_time;
133 dma_addr_t first_dma; 139 dma_addr_t first_dma;
140 struct list_head node;
134 struct scatterlist sg[0]; 141 struct scatterlist sg[0];
135}; 142};
136 143
@@ -146,16 +153,12 @@ static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
146 */ 153 */
147void nvme_free_iod(struct nvme_dev *dev, struct nvme_iod *iod); 154void nvme_free_iod(struct nvme_dev *dev, struct nvme_iod *iod);
148 155
149int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd, 156int nvme_setup_prps(struct nvme_dev *, struct nvme_iod *, int , gfp_t);
150 struct nvme_iod *iod, int total_len, gfp_t gfp);
151struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write, 157struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
152 unsigned long addr, unsigned length); 158 unsigned long addr, unsigned length);
153void nvme_unmap_user_pages(struct nvme_dev *dev, int write, 159void nvme_unmap_user_pages(struct nvme_dev *dev, int write,
154 struct nvme_iod *iod); 160 struct nvme_iod *iod);
155struct nvme_queue *get_nvmeq(struct nvme_dev *dev); 161int nvme_submit_io_cmd(struct nvme_dev *, struct nvme_command *, u32 *);
156void put_nvmeq(struct nvme_queue *nvmeq);
157int nvme_submit_sync_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd,
158 u32 *result, unsigned timeout);
159int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns); 162int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns);
160int nvme_submit_admin_cmd(struct nvme_dev *, struct nvme_command *, 163int nvme_submit_admin_cmd(struct nvme_dev *, struct nvme_command *,
161 u32 *result); 164 u32 *result);
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 4d9389c79e61..eb8b8ac6df3c 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -83,23 +83,6 @@ struct pipe_buf_operations {
83 int can_merge; 83 int can_merge;
84 84
85 /* 85 /*
86 * ->map() returns a virtual address mapping of the pipe buffer.
87 * The last integer flag reflects whether this should be an atomic
88 * mapping or not. The atomic map is faster, however you can't take
89 * page faults before calling ->unmap() again. So if you need to eg
90 * access user data through copy_to/from_user(), then you must get
91 * a non-atomic map. ->map() uses the kmap_atomic slot for
92 * atomic maps, you have to be careful if mapping another page as
93 * source or destination for a copy.
94 */
95 void * (*map)(struct pipe_inode_info *, struct pipe_buffer *, int);
96
97 /*
98 * Undoes ->map(), finishes the virtual mapping of the pipe buffer.
99 */
100 void (*unmap)(struct pipe_inode_info *, struct pipe_buffer *, void *);
101
102 /*
103 * ->confirm() verifies that the data in the pipe buffer is there 86 * ->confirm() verifies that the data in the pipe buffer is there
104 * and that the contents are good. If the pages in the pipe belong 87 * and that the contents are good. If the pages in the pipe belong
105 * to a file system, we may need to wait for IO completion in this 88 * to a file system, we may need to wait for IO completion in this
@@ -150,8 +133,6 @@ struct pipe_inode_info *alloc_pipe_info(void);
150void free_pipe_info(struct pipe_inode_info *); 133void free_pipe_info(struct pipe_inode_info *);
151 134
152/* Generic pipe buffer ops functions */ 135/* Generic pipe buffer ops functions */
153void *generic_pipe_buf_map(struct pipe_inode_info *, struct pipe_buffer *, int);
154void generic_pipe_buf_unmap(struct pipe_inode_info *, struct pipe_buffer *, void *);
155void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); 136void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *);
156int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *); 137int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *);
157int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *); 138int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *);
diff --git a/include/linux/platform_data/dma-rcar-audmapp.h b/include/linux/platform_data/dma-rcar-audmapp.h
new file mode 100644
index 000000000000..471fffebbeb4
--- /dev/null
+++ b/include/linux/platform_data/dma-rcar-audmapp.h
@@ -0,0 +1,34 @@
1/*
2 * This is for Renesas R-Car Audio-DMAC-peri-peri.
3 *
4 * Copyright (C) 2014 Renesas Electronics Corporation
5 * Copyright (C) 2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This file is based on the include/linux/sh_dma.h
8 *
9 * Header for the new SH dmaengine driver
10 *
11 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
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 version 2 as
15 * published by the Free Software Foundation.
16 */
17#ifndef SH_AUDMAPP_H
18#define SH_AUDMAPP_H
19
20#include <linux/dmaengine.h>
21
22struct audmapp_slave_config {
23 int slave_id;
24 dma_addr_t src;
25 dma_addr_t dst;
26 u32 chcr;
27};
28
29struct audmapp_pdata {
30 struct audmapp_slave_config *slave;
31 int slave_num;
32};
33
34#endif /* SH_AUDMAPP_H */
diff --git a/include/linux/platform_data/i2c-s3c2410.h b/include/linux/platform_data/i2c-s3c2410.h
index 2a50048c1c44..05af66b840b9 100644
--- a/include/linux/platform_data/i2c-s3c2410.h
+++ b/include/linux/platform_data/i2c-s3c2410.h
@@ -1,5 +1,4 @@
1/* arch/arm/plat-s3c/include/plat/iic.h 1/*
2 *
3 * Copyright 2004-2009 Simtec Electronics 2 * Copyright 2004-2009 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 3 * Ben Dooks <ben@simtec.co.uk>
5 * 4 *
@@ -10,8 +9,8 @@
10 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
11*/ 10*/
12 11
13#ifndef __ASM_ARCH_IIC_H 12#ifndef __I2C_S3C2410_H
14#define __ASM_ARCH_IIC_H __FILE__ 13#define __I2C_S3C2410_H __FILE__
15 14
16#define S3C_IICFLG_FILTER (1<<0) /* enable s3c2440 filter */ 15#define S3C_IICFLG_FILTER (1<<0) /* enable s3c2440 filter */
17 16
@@ -76,4 +75,4 @@ extern void s3c_i2c7_cfg_gpio(struct platform_device *dev);
76 75
77extern struct s3c2410_platform_i2c default_i2c_data; 76extern struct s3c2410_platform_i2c default_i2c_data;
78 77
79#endif /* __ASM_ARCH_IIC_H */ 78#endif /* __I2C_S3C2410_H */
diff --git a/include/linux/platform_data/leds-s3c24xx.h b/include/linux/platform_data/leds-s3c24xx.h
index d8a7672519b6..441a6f290649 100644
--- a/include/linux/platform_data/leds-s3c24xx.h
+++ b/include/linux/platform_data/leds-s3c24xx.h
@@ -1,5 +1,4 @@
1/* arch/arm/mach-s3c2410/include/mach/leds-gpio.h 1/*
2 *
3 * Copyright (c) 2006 Simtec Electronics 2 * Copyright (c) 2006 Simtec Electronics
4 * http://armlinux.simtec.co.uk/ 3 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
@@ -11,8 +10,8 @@
11 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
12*/ 11*/
13 12
14#ifndef __ASM_ARCH_LEDSGPIO_H 13#ifndef __LEDS_S3C24XX_H
15#define __ASM_ARCH_LEDSGPIO_H "leds-gpio.h" 14#define __LEDS_S3C24XX_H
16 15
17#define S3C24XX_LEDF_ACTLOW (1<<0) /* LED is on when GPIO low */ 16#define S3C24XX_LEDF_ACTLOW (1<<0) /* LED is on when GPIO low */
18#define S3C24XX_LEDF_TRISTATE (1<<1) /* tristate to turn off */ 17#define S3C24XX_LEDF_TRISTATE (1<<1) /* tristate to turn off */
@@ -25,4 +24,4 @@ struct s3c24xx_led_platdata {
25 char *def_trigger; 24 char *def_trigger;
26}; 25};
27 26
28#endif /* __ASM_ARCH_LEDSGPIO_H */ 27#endif /* __LEDS_S3C24XX_H */
diff --git a/include/linux/platform_data/mmc-msm_sdcc.h b/include/linux/platform_data/mmc-msm_sdcc.h
index ffcd9e3a6a7e..55aa873c9396 100644
--- a/include/linux/platform_data/mmc-msm_sdcc.h
+++ b/include/linux/platform_data/mmc-msm_sdcc.h
@@ -1,8 +1,5 @@
1/* 1#ifndef __MMC_MSM_SDCC_H
2 * arch/arm/include/asm/mach/mmc.h 2#define __MMC_MSM_SDCC_H
3 */
4#ifndef ASMARM_MACH_MMC_H
5#define ASMARM_MACH_MMC_H
6 3
7#include <linux/mmc/host.h> 4#include <linux/mmc/host.h>
8#include <linux/mmc/card.h> 5#include <linux/mmc/card.h>
diff --git a/include/linux/platform_data/mmc-mvsdio.h b/include/linux/platform_data/mmc-mvsdio.h
index 1190efedcb94..d02704cd3695 100644
--- a/include/linux/platform_data/mmc-mvsdio.h
+++ b/include/linux/platform_data/mmc-mvsdio.h
@@ -1,13 +1,11 @@
1/* 1/*
2 * arch/arm/plat-orion/include/plat/mvsdio.h
3 *
4 * This file is licensed under the terms of the GNU General Public 2 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any 3 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied. 4 * warranty of any kind, whether express or implied.
7 */ 5 */
8 6
9#ifndef __MACH_MVSDIO_H 7#ifndef __MMC_MVSDIO_H
10#define __MACH_MVSDIO_H 8#define __MMC_MVSDIO_H
11 9
12#include <linux/mbus.h> 10#include <linux/mbus.h>
13 11
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 075b3056c0c0..25f54c79f757 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1719,6 +1719,24 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
1719} 1719}
1720 1720
1721 1721
1722static inline int pid_alive(const struct task_struct *p);
1723static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
1724{
1725 pid_t pid = 0;
1726
1727 rcu_read_lock();
1728 if (pid_alive(tsk))
1729 pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
1730 rcu_read_unlock();
1731
1732 return pid;
1733}
1734
1735static inline pid_t task_ppid_nr(const struct task_struct *tsk)
1736{
1737 return task_ppid_nr_ns(tsk, &init_pid_ns);
1738}
1739
1722static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, 1740static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
1723 struct pid_namespace *ns) 1741 struct pid_namespace *ns)
1724{ 1742{
@@ -1758,7 +1776,7 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1758 * 1776 *
1759 * Return: 1 if the process is alive. 0 otherwise. 1777 * Return: 1 if the process is alive. 0 otherwise.
1760 */ 1778 */
1761static inline int pid_alive(struct task_struct *p) 1779static inline int pid_alive(const struct task_struct *p)
1762{ 1780{
1763 return p->pids[PIDTYPE_PID].pid != NULL; 1781 return p->pids[PIDTYPE_PID].pid != NULL;
1764} 1782}
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 8af2804bab16..70736b98c721 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -130,6 +130,8 @@ struct rpc_create_args {
130#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) 130#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
131 131
132struct rpc_clnt *rpc_create(struct rpc_create_args *args); 132struct rpc_clnt *rpc_create(struct rpc_create_args *args);
133struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
134 struct rpc_xprt *xprt);
133struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, 135struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
134 const struct rpc_program *, u32); 136 const struct rpc_program *, u32);
135void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt); 137void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 62fd1b756e99..2e780134f449 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -22,7 +22,7 @@ struct svc_sock {
22 22
23 /* We keep the old state_change and data_ready CB's here */ 23 /* We keep the old state_change and data_ready CB's here */
24 void (*sk_ostate)(struct sock *); 24 void (*sk_ostate)(struct sock *);
25 void (*sk_odata)(struct sock *, int bytes); 25 void (*sk_odata)(struct sock *);
26 void (*sk_owspace)(struct sock *); 26 void (*sk_owspace)(struct sock *);
27 27
28 /* private TCP part */ 28 /* private TCP part */
@@ -56,6 +56,7 @@ int svc_recv(struct svc_rqst *, long);
56int svc_send(struct svc_rqst *); 56int svc_send(struct svc_rqst *);
57void svc_drop(struct svc_rqst *); 57void svc_drop(struct svc_rqst *);
58void svc_sock_update_bufs(struct svc_serv *serv); 58void svc_sock_update_bufs(struct svc_serv *serv);
59bool svc_alien_sock(struct net *net, int fd);
59int svc_addsock(struct svc_serv *serv, const int fd, 60int svc_addsock(struct svc_serv *serv, const int fd,
60 char *name_return, const size_t len); 61 char *name_return, const size_t len);
61void svc_init_xprt_sock(void); 62void svc_init_xprt_sock(void);
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 8097b9df6773..3e5efb2b236e 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -295,13 +295,24 @@ int xprt_adjust_timeout(struct rpc_rqst *req);
295void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task); 295void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
296void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task); 296void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
297void xprt_release(struct rpc_task *task); 297void xprt_release(struct rpc_task *task);
298struct rpc_xprt * xprt_get(struct rpc_xprt *xprt);
299void xprt_put(struct rpc_xprt *xprt); 298void xprt_put(struct rpc_xprt *xprt);
300struct rpc_xprt * xprt_alloc(struct net *net, size_t size, 299struct rpc_xprt * xprt_alloc(struct net *net, size_t size,
301 unsigned int num_prealloc, 300 unsigned int num_prealloc,
302 unsigned int max_req); 301 unsigned int max_req);
303void xprt_free(struct rpc_xprt *); 302void xprt_free(struct rpc_xprt *);
304 303
304/**
305 * xprt_get - return a reference to an RPC transport.
306 * @xprt: pointer to the transport
307 *
308 */
309static inline struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
310{
311 if (atomic_inc_not_zero(&xprt->count))
312 return xprt;
313 return NULL;
314}
315
305static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) 316static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
306{ 317{
307 return p + xprt->tsh_size; 318 return p + xprt->tsh_size;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 697ceb70a9a9..a4a0588c5397 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -119,8 +119,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
119 static struct syscall_metadata __syscall_meta_##sname; \ 119 static struct syscall_metadata __syscall_meta_##sname; \
120 static struct ftrace_event_call __used \ 120 static struct ftrace_event_call __used \
121 event_enter_##sname = { \ 121 event_enter_##sname = { \
122 .name = "sys_enter"#sname, \
123 .class = &event_class_syscall_enter, \ 122 .class = &event_class_syscall_enter, \
123 { \
124 .name = "sys_enter"#sname, \
125 }, \
124 .event.funcs = &enter_syscall_print_funcs, \ 126 .event.funcs = &enter_syscall_print_funcs, \
125 .data = (void *)&__syscall_meta_##sname,\ 127 .data = (void *)&__syscall_meta_##sname,\
126 .flags = TRACE_EVENT_FL_CAP_ANY, \ 128 .flags = TRACE_EVENT_FL_CAP_ANY, \
@@ -133,8 +135,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
133 static struct syscall_metadata __syscall_meta_##sname; \ 135 static struct syscall_metadata __syscall_meta_##sname; \
134 static struct ftrace_event_call __used \ 136 static struct ftrace_event_call __used \
135 event_exit_##sname = { \ 137 event_exit_##sname = { \
136 .name = "sys_exit"#sname, \
137 .class = &event_class_syscall_exit, \ 138 .class = &event_class_syscall_exit, \
139 { \
140 .name = "sys_exit"#sname, \
141 }, \
138 .event.funcs = &exit_syscall_print_funcs, \ 142 .event.funcs = &exit_syscall_print_funcs, \
139 .data = (void *)&__syscall_meta_##sname,\ 143 .data = (void *)&__syscall_meta_##sname,\
140 .flags = TRACE_EVENT_FL_CAP_ANY, \ 144 .flags = TRACE_EVENT_FL_CAP_ANY, \
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 812b2553dfd8..9d30ee469c2a 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -6,7 +6,7 @@
6 * 6 *
7 * See Documentation/trace/tracepoints.txt. 7 * See Documentation/trace/tracepoints.txt.
8 * 8 *
9 * (C) Copyright 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> 9 * Copyright (C) 2008-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * 10 *
11 * Heavily inspired from the Linux Kernel Markers. 11 * Heavily inspired from the Linux Kernel Markers.
12 * 12 *
@@ -21,6 +21,7 @@
21 21
22struct module; 22struct module;
23struct tracepoint; 23struct tracepoint;
24struct notifier_block;
24 25
25struct tracepoint_func { 26struct tracepoint_func {
26 void *func; 27 void *func;
@@ -35,31 +36,38 @@ struct tracepoint {
35 struct tracepoint_func __rcu *funcs; 36 struct tracepoint_func __rcu *funcs;
36}; 37};
37 38
38/*
39 * Connect a probe to a tracepoint.
40 * Internal API, should not be used directly.
41 */
42extern int tracepoint_probe_register(const char *name, void *probe, void *data);
43
44/*
45 * Disconnect a probe from a tracepoint.
46 * Internal API, should not be used directly.
47 */
48extern int 39extern int
49tracepoint_probe_unregister(const char *name, void *probe, void *data); 40tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data);
41extern int
42tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
43extern void
44for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
45 void *priv);
50 46
51#ifdef CONFIG_MODULES 47#ifdef CONFIG_MODULES
52struct tp_module { 48struct tp_module {
53 struct list_head list; 49 struct list_head list;
54 unsigned int num_tracepoints; 50 struct module *mod;
55 struct tracepoint * const *tracepoints_ptrs;
56}; 51};
52
57bool trace_module_has_bad_taint(struct module *mod); 53bool trace_module_has_bad_taint(struct module *mod);
54extern int register_tracepoint_module_notifier(struct notifier_block *nb);
55extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
58#else 56#else
59static inline bool trace_module_has_bad_taint(struct module *mod) 57static inline bool trace_module_has_bad_taint(struct module *mod)
60{ 58{
61 return false; 59 return false;
62} 60}
61static inline
62int register_tracepoint_module_notifier(struct notifier_block *nb)
63{
64 return 0;
65}
66static inline
67int unregister_tracepoint_module_notifier(struct notifier_block *nb)
68{
69 return 0;
70}
63#endif /* CONFIG_MODULES */ 71#endif /* CONFIG_MODULES */
64 72
65/* 73/*
@@ -72,6 +80,11 @@ static inline void tracepoint_synchronize_unregister(void)
72 synchronize_sched(); 80 synchronize_sched();
73} 81}
74 82
83#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
84extern void syscall_regfunc(void);
85extern void syscall_unregfunc(void);
86#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
87
75#define PARAMS(args...) args 88#define PARAMS(args...) args
76 89
77#endif /* _LINUX_TRACEPOINT_H */ 90#endif /* _LINUX_TRACEPOINT_H */
@@ -160,14 +173,14 @@ static inline void tracepoint_synchronize_unregister(void)
160 static inline int \ 173 static inline int \
161 register_trace_##name(void (*probe)(data_proto), void *data) \ 174 register_trace_##name(void (*probe)(data_proto), void *data) \
162 { \ 175 { \
163 return tracepoint_probe_register(#name, (void *)probe, \ 176 return tracepoint_probe_register(&__tracepoint_##name, \
164 data); \ 177 (void *)probe, data); \
165 } \ 178 } \
166 static inline int \ 179 static inline int \
167 unregister_trace_##name(void (*probe)(data_proto), void *data) \ 180 unregister_trace_##name(void (*probe)(data_proto), void *data) \
168 { \ 181 { \
169 return tracepoint_probe_unregister(#name, (void *)probe, \ 182 return tracepoint_probe_unregister(&__tracepoint_##name,\
170 data); \ 183 (void *)probe, data); \
171 } \ 184 } \
172 static inline void \ 185 static inline void \
173 check_trace_callback_type_##name(void (*cb)(data_proto)) \ 186 check_trace_callback_type_##name(void (*cb)(data_proto)) \
diff --git a/include/linux/uio.h b/include/linux/uio.h
index c55ce243cc09..199bcc34241b 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -9,14 +9,23 @@
9#ifndef __LINUX_UIO_H 9#ifndef __LINUX_UIO_H
10#define __LINUX_UIO_H 10#define __LINUX_UIO_H
11 11
12#include <linux/kernel.h>
12#include <uapi/linux/uio.h> 13#include <uapi/linux/uio.h>
13 14
15struct page;
14 16
15struct kvec { 17struct kvec {
16 void *iov_base; /* and that should *never* hold a userland pointer */ 18 void *iov_base; /* and that should *never* hold a userland pointer */
17 size_t iov_len; 19 size_t iov_len;
18}; 20};
19 21
22struct iov_iter {
23 const struct iovec *iov;
24 unsigned long nr_segs;
25 size_t iov_offset;
26 size_t count;
27};
28
20/* 29/*
21 * Total number of bytes covered by an iovec. 30 * Total number of bytes covered by an iovec.
22 * 31 *
@@ -34,8 +43,51 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
34 return ret; 43 return ret;
35} 44}
36 45
46static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
47{
48 return (struct iovec) {
49 .iov_base = iter->iov->iov_base + iter->iov_offset,
50 .iov_len = min(iter->count,
51 iter->iov->iov_len - iter->iov_offset),
52 };
53}
54
55#define iov_for_each(iov, iter, start) \
56 for (iter = (start); \
57 (iter).count && \
58 ((iov = iov_iter_iovec(&(iter))), 1); \
59 iov_iter_advance(&(iter), (iov).iov_len))
60
37unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); 61unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to);
38 62
63size_t iov_iter_copy_from_user_atomic(struct page *page,
64 struct iov_iter *i, unsigned long offset, size_t bytes);
65size_t iov_iter_copy_from_user(struct page *page,
66 struct iov_iter *i, unsigned long offset, size_t bytes);
67void iov_iter_advance(struct iov_iter *i, size_t bytes);
68int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
69size_t iov_iter_single_seg_count(const struct iov_iter *i);
70size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
71 struct iov_iter *i);
72
73static inline void iov_iter_init(struct iov_iter *i,
74 const struct iovec *iov, unsigned long nr_segs,
75 size_t count, size_t written)
76{
77 i->iov = iov;
78 i->nr_segs = nr_segs;
79 i->iov_offset = 0;
80 i->count = count + written;
81
82 iov_iter_advance(i, written);
83}
84
85static inline size_t iov_iter_count(struct iov_iter *i)
86{
87 return i->count;
88}
89
39int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); 90int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
40int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len); 91int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len);
92
41#endif 93#endif
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 0b9f890ce431..fde142e5f25a 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -60,6 +60,7 @@ enum rc_filter_type {
60/** 60/**
61 * struct rc_dev - represents a remote control device 61 * struct rc_dev - represents a remote control device
62 * @dev: driver model's view of this device 62 * @dev: driver model's view of this device
63 * @sysfs_groups: sysfs attribute groups
63 * @input_name: name of the input child device 64 * @input_name: name of the input child device
64 * @input_phys: physical path to the input child device 65 * @input_phys: physical path to the input child device
65 * @input_id: id of the input child device (struct input_id) 66 * @input_id: id of the input child device (struct input_id)
@@ -112,10 +113,12 @@ enum rc_filter_type {
112 * device doesn't interrupt host until it sees IR pulses 113 * device doesn't interrupt host until it sees IR pulses
113 * @s_learning_mode: enable wide band receiver used for learning 114 * @s_learning_mode: enable wide band receiver used for learning
114 * @s_carrier_report: enable carrier reports 115 * @s_carrier_report: enable carrier reports
115 * @s_filter: set the scancode filter of a given type 116 * @s_filter: set the scancode filter
117 * @s_wakeup_filter: set the wakeup scancode filter
116 */ 118 */
117struct rc_dev { 119struct rc_dev {
118 struct device dev; 120 struct device dev;
121 const struct attribute_group *sysfs_groups[5];
119 const char *input_name; 122 const char *input_name;
120 const char *input_phys; 123 const char *input_phys;
121 struct input_id input_id; 124 struct input_id input_id;
@@ -159,8 +162,9 @@ struct rc_dev {
159 int (*s_learning_mode)(struct rc_dev *dev, int enable); 162 int (*s_learning_mode)(struct rc_dev *dev, int enable);
160 int (*s_carrier_report) (struct rc_dev *dev, int enable); 163 int (*s_carrier_report) (struct rc_dev *dev, int enable);
161 int (*s_filter)(struct rc_dev *dev, 164 int (*s_filter)(struct rc_dev *dev,
162 enum rc_filter_type type,
163 struct rc_scancode_filter *filter); 165 struct rc_scancode_filter *filter);
166 int (*s_wakeup_filter)(struct rc_dev *dev,
167 struct rc_scancode_filter *filter);
164}; 168};
165 169
166#define to_rc_dev(d) container_of(d, struct rc_dev, dev) 170#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index c38a005bd0cf..6fab66c5c5af 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -67,7 +67,6 @@ enum p9_trans_status {
67 * @REQ_STATUS_ALLOC: request has been allocated but not sent 67 * @REQ_STATUS_ALLOC: request has been allocated but not sent
68 * @REQ_STATUS_UNSENT: request waiting to be sent 68 * @REQ_STATUS_UNSENT: request waiting to be sent
69 * @REQ_STATUS_SENT: request sent to server 69 * @REQ_STATUS_SENT: request sent to server
70 * @REQ_STATUS_FLSH: a flush has been sent for this request
71 * @REQ_STATUS_RCVD: response received from server 70 * @REQ_STATUS_RCVD: response received from server
72 * @REQ_STATUS_FLSHD: request has been flushed 71 * @REQ_STATUS_FLSHD: request has been flushed
73 * @REQ_STATUS_ERROR: request encountered an error on the client side 72 * @REQ_STATUS_ERROR: request encountered an error on the client side
@@ -83,7 +82,6 @@ enum p9_req_status_t {
83 REQ_STATUS_ALLOC, 82 REQ_STATUS_ALLOC,
84 REQ_STATUS_UNSENT, 83 REQ_STATUS_UNSENT,
85 REQ_STATUS_SENT, 84 REQ_STATUS_SENT,
86 REQ_STATUS_FLSH,
87 REQ_STATUS_RCVD, 85 REQ_STATUS_RCVD,
88 REQ_STATUS_FLSHD, 86 REQ_STATUS_FLSHD,
89 REQ_STATUS_ERROR, 87 REQ_STATUS_ERROR,
@@ -130,7 +128,6 @@ struct p9_req_t {
130 * @proto_version: 9P protocol version to use 128 * @proto_version: 9P protocol version to use
131 * @trans_mod: module API instantiated with this client 129 * @trans_mod: module API instantiated with this client
132 * @trans: tranport instance state and API 130 * @trans: tranport instance state and API
133 * @conn: connection state information used by trans_fd
134 * @fidpool: fid handle accounting for session 131 * @fidpool: fid handle accounting for session
135 * @fidlist: List of active fid handles 132 * @fidlist: List of active fid handles
136 * @tagpool - transaction id accounting for session 133 * @tagpool - transaction id accounting for session
@@ -159,7 +156,6 @@ struct p9_client {
159 struct p9_trans_module *trans_mod; 156 struct p9_trans_module *trans_mod;
160 enum p9_trans_status status; 157 enum p9_trans_status status;
161 void *trans; 158 void *trans;
162 struct p9_conn *conn;
163 159
164 struct p9_idpool *fidpool; 160 struct p9_idpool *fidpool;
165 struct list_head fidlist; 161 struct list_head fidlist;
@@ -261,7 +257,7 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
261int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status); 257int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
262int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl); 258int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);
263struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); 259struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
264void p9_client_cb(struct p9_client *c, struct p9_req_t *req); 260void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status);
265 261
266int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); 262int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int);
267int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *); 263int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *);
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index 9a36d9297114..d9fa68f26c41 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -40,6 +40,8 @@
40 * @close: member function to discard a connection on this transport 40 * @close: member function to discard a connection on this transport
41 * @request: member function to issue a request to the transport 41 * @request: member function to issue a request to the transport
42 * @cancel: member function to cancel a request (if it hasn't been sent) 42 * @cancel: member function to cancel a request (if it hasn't been sent)
43 * @cancelled: member function to notify that a cancelled request will not
44 * not receive a reply
43 * 45 *
44 * This is the basic API for a transport module which is registered by the 46 * This is the basic API for a transport module which is registered by the
45 * transport module with the 9P core network module and used by the client 47 * transport module with the 9P core network module and used by the client
@@ -58,6 +60,7 @@ struct p9_trans_module {
58 void (*close) (struct p9_client *); 60 void (*close) (struct p9_client *);
59 int (*request) (struct p9_client *, struct p9_req_t *req); 61 int (*request) (struct p9_client *, struct p9_req_t *req);
60 int (*cancel) (struct p9_client *, struct p9_req_t *req); 62 int (*cancel) (struct p9_client *, struct p9_req_t *req);
63 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
61 int (*zc_request)(struct p9_client *, struct p9_req_t *, 64 int (*zc_request)(struct p9_client *, struct p9_req_t *,
62 char *, char *, int , int, int, int); 65 char *, char *, int , int, int, int);
63}; 66};
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index a3353f45ef94..8e4de46c052e 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -101,7 +101,7 @@ void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int);
101int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb); 101int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
102int sctp_inet_listen(struct socket *sock, int backlog); 102int sctp_inet_listen(struct socket *sock, int backlog);
103void sctp_write_space(struct sock *sk); 103void sctp_write_space(struct sock *sk);
104void sctp_data_ready(struct sock *sk, int len); 104void sctp_data_ready(struct sock *sk);
105unsigned int sctp_poll(struct file *file, struct socket *sock, 105unsigned int sctp_poll(struct file *file, struct socket *sock,
106 poll_table *wait); 106 poll_table *wait);
107void sctp_sock_rfree(struct sk_buff *skb); 107void sctp_sock_rfree(struct sk_buff *skb);
diff --git a/include/net/sock.h b/include/net/sock.h
index 06a5668f05c9..8338a14e4805 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -418,7 +418,7 @@ struct sock {
418 u32 sk_classid; 418 u32 sk_classid;
419 struct cg_proto *sk_cgrp; 419 struct cg_proto *sk_cgrp;
420 void (*sk_state_change)(struct sock *sk); 420 void (*sk_state_change)(struct sock *sk);
421 void (*sk_data_ready)(struct sock *sk, int bytes); 421 void (*sk_data_ready)(struct sock *sk);
422 void (*sk_write_space)(struct sock *sk); 422 void (*sk_write_space)(struct sock *sk);
423 void (*sk_error_report)(struct sock *sk); 423 void (*sk_error_report)(struct sock *sk);
424 int (*sk_backlog_rcv)(struct sock *sk, 424 int (*sk_backlog_rcv)(struct sock *sk,
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 4e845b80efd3..5853c913d2b0 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -423,11 +423,11 @@ extern int scsi_is_target_device(const struct device *);
423extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, 423extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
424 int data_direction, void *buffer, unsigned bufflen, 424 int data_direction, void *buffer, unsigned bufflen,
425 unsigned char *sense, int timeout, int retries, 425 unsigned char *sense, int timeout, int retries,
426 int flag, int *resid); 426 u64 flags, int *resid);
427extern int scsi_execute_req_flags(struct scsi_device *sdev, 427extern int scsi_execute_req_flags(struct scsi_device *sdev,
428 const unsigned char *cmd, int data_direction, void *buffer, 428 const unsigned char *cmd, int data_direction, void *buffer,
429 unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout, 429 unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
430 int retries, int *resid, int flags); 430 int retries, int *resid, u64 flags);
431static inline int scsi_execute_req(struct scsi_device *sdev, 431static inline int scsi_execute_req(struct scsi_device *sdev,
432 const unsigned char *cmd, int data_direction, void *buffer, 432 const unsigned char *cmd, int data_direction, void *buffer,
433 unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout, 433 unsigned bufflen, struct scsi_sense_hdr *sshdr, int timeout,
diff --git a/include/sound/cs8427.h b/include/sound/cs8427.h
index f862cfff5f6a..0b6a1876639b 100644
--- a/include/sound/cs8427.h
+++ b/include/sound/cs8427.h
@@ -188,6 +188,7 @@
188 188
189struct snd_pcm_substream; 189struct snd_pcm_substream;
190 190
191int snd_cs8427_init(struct snd_i2c_bus *bus, struct snd_i2c_device *device);
191int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr, 192int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr,
192 unsigned int reset_timeout, struct snd_i2c_device **r_cs8427); 193 unsigned int reset_timeout, struct snd_i2c_device **r_cs8427);
193int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, 194int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg,
diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h
index 4483fadfa68d..33b487b5da92 100644
--- a/include/target/iscsi/iscsi_transport.h
+++ b/include/target/iscsi/iscsi_transport.h
@@ -21,6 +21,8 @@ struct iscsit_transport {
21 int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool); 21 int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool);
22 int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *); 22 int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *);
23 int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *); 23 int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *);
24 void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *);
25 enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *);
24}; 26};
25 27
26static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd) 28static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd)
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 7020e33e742e..3a1c1eea1fff 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -73,10 +73,12 @@ sense_reason_t sbc_execute_unmap(struct se_cmd *cmd,
73 sense_reason_t (*do_unmap_fn)(struct se_cmd *cmd, void *priv, 73 sense_reason_t (*do_unmap_fn)(struct se_cmd *cmd, void *priv,
74 sector_t lba, sector_t nolb), 74 sector_t lba, sector_t nolb),
75 void *priv); 75 void *priv);
76void sbc_dif_generate(struct se_cmd *);
76sense_reason_t sbc_dif_verify_write(struct se_cmd *, sector_t, unsigned int, 77sense_reason_t sbc_dif_verify_write(struct se_cmd *, sector_t, unsigned int,
77 unsigned int, struct scatterlist *, int); 78 unsigned int, struct scatterlist *, int);
78sense_reason_t sbc_dif_verify_read(struct se_cmd *, sector_t, unsigned int, 79sense_reason_t sbc_dif_verify_read(struct se_cmd *, sector_t, unsigned int,
79 unsigned int, struct scatterlist *, int); 80 unsigned int, struct scatterlist *, int);
81sense_reason_t sbc_dif_read_strip(struct se_cmd *);
80 82
81void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); 83void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
82int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); 84int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1772fadcff62..9ec9864ecf38 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -162,7 +162,7 @@ enum se_cmd_flags_table {
162 SCF_SENT_CHECK_CONDITION = 0x00000800, 162 SCF_SENT_CHECK_CONDITION = 0x00000800,
163 SCF_OVERFLOW_BIT = 0x00001000, 163 SCF_OVERFLOW_BIT = 0x00001000,
164 SCF_UNDERFLOW_BIT = 0x00002000, 164 SCF_UNDERFLOW_BIT = 0x00002000,
165 SCF_SENT_DELAYED_TAS = 0x00004000, 165 SCF_SEND_DELAYED_TAS = 0x00004000,
166 SCF_ALUA_NON_OPTIMIZED = 0x00008000, 166 SCF_ALUA_NON_OPTIMIZED = 0x00008000,
167 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000, 167 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000,
168 SCF_ACK_KREF = 0x00040000, 168 SCF_ACK_KREF = 0x00040000,
@@ -442,19 +442,18 @@ struct se_tmr_req {
442}; 442};
443 443
444enum target_prot_op { 444enum target_prot_op {
445 TARGET_PROT_NORMAL = 0, 445 TARGET_PROT_NORMAL = 0,
446 TARGET_PROT_DIN_INSERT, 446 TARGET_PROT_DIN_INSERT = (1 << 0),
447 TARGET_PROT_DOUT_INSERT, 447 TARGET_PROT_DOUT_INSERT = (1 << 1),
448 TARGET_PROT_DIN_STRIP, 448 TARGET_PROT_DIN_STRIP = (1 << 2),
449 TARGET_PROT_DOUT_STRIP, 449 TARGET_PROT_DOUT_STRIP = (1 << 3),
450 TARGET_PROT_DIN_PASS, 450 TARGET_PROT_DIN_PASS = (1 << 4),
451 TARGET_PROT_DOUT_PASS, 451 TARGET_PROT_DOUT_PASS = (1 << 5),
452}; 452};
453 453
454enum target_prot_ho { 454#define TARGET_PROT_ALL TARGET_PROT_DIN_INSERT | TARGET_PROT_DOUT_INSERT | \
455 PROT_SEPERATED, 455 TARGET_PROT_DIN_STRIP | TARGET_PROT_DOUT_STRIP | \
456 PROT_INTERLEAVED, 456 TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS
457};
458 457
459enum target_prot_type { 458enum target_prot_type {
460 TARGET_DIF_TYPE0_PROT, 459 TARGET_DIF_TYPE0_PROT,
@@ -463,6 +462,12 @@ enum target_prot_type {
463 TARGET_DIF_TYPE3_PROT, 462 TARGET_DIF_TYPE3_PROT,
464}; 463};
465 464
465enum target_core_dif_check {
466 TARGET_DIF_CHECK_GUARD = 0x1 << 0,
467 TARGET_DIF_CHECK_APPTAG = 0x1 << 1,
468 TARGET_DIF_CHECK_REFTAG = 0x1 << 2,
469};
470
466struct se_dif_v1_tuple { 471struct se_dif_v1_tuple {
467 __be16 guard_tag; 472 __be16 guard_tag;
468 __be16 app_tag; 473 __be16 app_tag;
@@ -556,13 +561,14 @@ struct se_cmd {
556 /* DIF related members */ 561 /* DIF related members */
557 enum target_prot_op prot_op; 562 enum target_prot_op prot_op;
558 enum target_prot_type prot_type; 563 enum target_prot_type prot_type;
564 u8 prot_checks;
559 u32 prot_length; 565 u32 prot_length;
560 u32 reftag_seed; 566 u32 reftag_seed;
561 struct scatterlist *t_prot_sg; 567 struct scatterlist *t_prot_sg;
562 unsigned int t_prot_nents; 568 unsigned int t_prot_nents;
563 enum target_prot_ho prot_handover;
564 sense_reason_t pi_err; 569 sense_reason_t pi_err;
565 sector_t bad_sector; 570 sector_t bad_sector;
571 bool prot_pto;
566}; 572};
567 573
568struct se_ua { 574struct se_ua {
@@ -603,6 +609,7 @@ struct se_node_acl {
603struct se_session { 609struct se_session {
604 unsigned sess_tearing_down:1; 610 unsigned sess_tearing_down:1;
605 u64 sess_bin_isid; 611 u64 sess_bin_isid;
612 enum target_prot_op sup_prot_ops;
606 struct se_node_acl *se_node_acl; 613 struct se_node_acl *se_node_acl;
607 struct se_portal_group *se_tpg; 614 struct se_portal_group *se_tpg;
608 void *fabric_sess_ptr; 615 void *fabric_sess_ptr;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 0218d689b3d7..22a4e98eec80 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -62,6 +62,7 @@ struct target_core_fabric_ops {
62 int (*queue_data_in)(struct se_cmd *); 62 int (*queue_data_in)(struct se_cmd *);
63 int (*queue_status)(struct se_cmd *); 63 int (*queue_status)(struct se_cmd *);
64 void (*queue_tm_rsp)(struct se_cmd *); 64 void (*queue_tm_rsp)(struct se_cmd *);
65 void (*aborted_task)(struct se_cmd *);
65 /* 66 /*
66 * fabric module calls for target_core_fabric_configfs.c 67 * fabric module calls for target_core_fabric_configfs.c
67 */ 68 */
@@ -83,10 +84,11 @@ struct target_core_fabric_ops {
83 void (*fabric_drop_nodeacl)(struct se_node_acl *); 84 void (*fabric_drop_nodeacl)(struct se_node_acl *);
84}; 85};
85 86
86struct se_session *transport_init_session(void); 87struct se_session *transport_init_session(enum target_prot_op);
87int transport_alloc_session_tags(struct se_session *, unsigned int, 88int transport_alloc_session_tags(struct se_session *, unsigned int,
88 unsigned int); 89 unsigned int);
89struct se_session *transport_init_session_tags(unsigned int, unsigned int); 90struct se_session *transport_init_session_tags(unsigned int, unsigned int,
91 enum target_prot_op);
90void __transport_register_session(struct se_portal_group *, 92void __transport_register_session(struct se_portal_group *,
91 struct se_node_acl *, struct se_session *, void *); 93 struct se_node_acl *, struct se_session *, void *);
92void transport_register_session(struct se_portal_group *, 94void transport_register_session(struct se_portal_group *,
diff --git a/include/trace/events/i2c.h b/include/trace/events/i2c.h
new file mode 100644
index 000000000000..fe17187df65d
--- /dev/null
+++ b/include/trace/events/i2c.h
@@ -0,0 +1,372 @@
1/* I2C and SMBUS message transfer tracepoints
2 *
3 * Copyright (C) 2013 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#undef TRACE_SYSTEM
12#define TRACE_SYSTEM i2c
13
14#if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ)
15#define _TRACE_I2C_H
16
17#include <linux/i2c.h>
18#include <linux/tracepoint.h>
19
20/*
21 * drivers/i2c/i2c-core.c
22 */
23extern void i2c_transfer_trace_reg(void);
24extern void i2c_transfer_trace_unreg(void);
25
26/*
27 * __i2c_transfer() write request
28 */
29TRACE_EVENT_FN(i2c_write,
30 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
31 int num),
32 TP_ARGS(adap, msg, num),
33 TP_STRUCT__entry(
34 __field(int, adapter_nr )
35 __field(__u16, msg_nr )
36 __field(__u16, addr )
37 __field(__u16, flags )
38 __field(__u16, len )
39 __dynamic_array(__u8, buf, msg->len) ),
40 TP_fast_assign(
41 __entry->adapter_nr = adap->nr;
42 __entry->msg_nr = num;
43 __entry->addr = msg->addr;
44 __entry->flags = msg->flags;
45 __entry->len = msg->len;
46 memcpy(__get_dynamic_array(buf), msg->buf, msg->len);
47 ),
48 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
49 __entry->adapter_nr,
50 __entry->msg_nr,
51 __entry->addr,
52 __entry->flags,
53 __entry->len,
54 __entry->len, __get_dynamic_array(buf)
55 ),
56 i2c_transfer_trace_reg,
57 i2c_transfer_trace_unreg);
58
59/*
60 * __i2c_transfer() read request
61 */
62TRACE_EVENT_FN(i2c_read,
63 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
64 int num),
65 TP_ARGS(adap, msg, num),
66 TP_STRUCT__entry(
67 __field(int, adapter_nr )
68 __field(__u16, msg_nr )
69 __field(__u16, addr )
70 __field(__u16, flags )
71 __field(__u16, len )
72 ),
73 TP_fast_assign(
74 __entry->adapter_nr = adap->nr;
75 __entry->msg_nr = num;
76 __entry->addr = msg->addr;
77 __entry->flags = msg->flags;
78 __entry->len = msg->len;
79 ),
80 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u",
81 __entry->adapter_nr,
82 __entry->msg_nr,
83 __entry->addr,
84 __entry->flags,
85 __entry->len
86 ),
87 i2c_transfer_trace_reg,
88 i2c_transfer_trace_unreg);
89
90/*
91 * __i2c_transfer() read reply
92 */
93TRACE_EVENT_FN(i2c_reply,
94 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
95 int num),
96 TP_ARGS(adap, msg, num),
97 TP_STRUCT__entry(
98 __field(int, adapter_nr )
99 __field(__u16, msg_nr )
100 __field(__u16, addr )
101 __field(__u16, flags )
102 __field(__u16, len )
103 __dynamic_array(__u8, buf, msg->len) ),
104 TP_fast_assign(
105 __entry->adapter_nr = adap->nr;
106 __entry->msg_nr = num;
107 __entry->addr = msg->addr;
108 __entry->flags = msg->flags;
109 __entry->len = msg->len;
110 memcpy(__get_dynamic_array(buf), msg->buf, msg->len);
111 ),
112 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
113 __entry->adapter_nr,
114 __entry->msg_nr,
115 __entry->addr,
116 __entry->flags,
117 __entry->len,
118 __entry->len, __get_dynamic_array(buf)
119 ),
120 i2c_transfer_trace_reg,
121 i2c_transfer_trace_unreg);
122
123/*
124 * __i2c_transfer() result
125 */
126TRACE_EVENT_FN(i2c_result,
127 TP_PROTO(const struct i2c_adapter *adap, int num, int ret),
128 TP_ARGS(adap, num, ret),
129 TP_STRUCT__entry(
130 __field(int, adapter_nr )
131 __field(__u16, nr_msgs )
132 __field(__s16, ret )
133 ),
134 TP_fast_assign(
135 __entry->adapter_nr = adap->nr;
136 __entry->nr_msgs = num;
137 __entry->ret = ret;
138 ),
139 TP_printk("i2c-%d n=%u ret=%d",
140 __entry->adapter_nr,
141 __entry->nr_msgs,
142 __entry->ret
143 ),
144 i2c_transfer_trace_reg,
145 i2c_transfer_trace_unreg);
146
147/*
148 * i2c_smbus_xfer() write data or procedure call request
149 */
150TRACE_EVENT_CONDITION(smbus_write,
151 TP_PROTO(const struct i2c_adapter *adap,
152 u16 addr, unsigned short flags,
153 char read_write, u8 command, int protocol,
154 const union i2c_smbus_data *data),
155 TP_ARGS(adap, addr, flags, read_write, command, protocol, data),
156 TP_CONDITION(read_write == I2C_SMBUS_WRITE ||
157 protocol == I2C_SMBUS_PROC_CALL ||
158 protocol == I2C_SMBUS_BLOCK_PROC_CALL),
159 TP_STRUCT__entry(
160 __field(int, adapter_nr )
161 __field(__u16, addr )
162 __field(__u16, flags )
163 __field(__u8, command )
164 __field(__u8, len )
165 __field(__u32, protocol )
166 __array(__u8, buf, I2C_SMBUS_BLOCK_MAX + 2) ),
167 TP_fast_assign(
168 __entry->adapter_nr = adap->nr;
169 __entry->addr = addr;
170 __entry->flags = flags;
171 __entry->command = command;
172 __entry->protocol = protocol;
173
174 switch (protocol) {
175 case I2C_SMBUS_BYTE_DATA:
176 __entry->len = 1;
177 goto copy;
178 case I2C_SMBUS_WORD_DATA:
179 case I2C_SMBUS_PROC_CALL:
180 __entry->len = 2;
181 goto copy;
182 case I2C_SMBUS_BLOCK_DATA:
183 case I2C_SMBUS_BLOCK_PROC_CALL:
184 case I2C_SMBUS_I2C_BLOCK_DATA:
185 __entry->len = data->block[0] + 1;
186 copy:
187 memcpy(__entry->buf, data->block, __entry->len);
188 break;
189 case I2C_SMBUS_QUICK:
190 case I2C_SMBUS_BYTE:
191 case I2C_SMBUS_I2C_BLOCK_BROKEN:
192 default:
193 __entry->len = 0;
194 }
195 ),
196 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
197 __entry->adapter_nr,
198 __entry->addr,
199 __entry->flags,
200 __entry->command,
201 __print_symbolic(__entry->protocol,
202 { I2C_SMBUS_QUICK, "QUICK" },
203 { I2C_SMBUS_BYTE, "BYTE" },
204 { I2C_SMBUS_BYTE_DATA, "BYTE_DATA" },
205 { I2C_SMBUS_WORD_DATA, "WORD_DATA" },
206 { I2C_SMBUS_PROC_CALL, "PROC_CALL" },
207 { I2C_SMBUS_BLOCK_DATA, "BLOCK_DATA" },
208 { I2C_SMBUS_I2C_BLOCK_BROKEN, "I2C_BLOCK_BROKEN" },
209 { I2C_SMBUS_BLOCK_PROC_CALL, "BLOCK_PROC_CALL" },
210 { I2C_SMBUS_I2C_BLOCK_DATA, "I2C_BLOCK_DATA" }),
211 __entry->len,
212 __entry->len, __entry->buf
213 ));
214
215/*
216 * i2c_smbus_xfer() read data request
217 */
218TRACE_EVENT_CONDITION(smbus_read,
219 TP_PROTO(const struct i2c_adapter *adap,
220 u16 addr, unsigned short flags,
221 char read_write, u8 command, int protocol),
222 TP_ARGS(adap, addr, flags, read_write, command, protocol),
223 TP_CONDITION(!(read_write == I2C_SMBUS_WRITE ||
224 protocol == I2C_SMBUS_PROC_CALL ||
225 protocol == I2C_SMBUS_BLOCK_PROC_CALL)),
226 TP_STRUCT__entry(
227 __field(int, adapter_nr )
228 __field(__u16, flags )
229 __field(__u16, addr )
230 __field(__u8, command )
231 __field(__u32, protocol )
232 __array(__u8, buf, I2C_SMBUS_BLOCK_MAX + 2) ),
233 TP_fast_assign(
234 __entry->adapter_nr = adap->nr;
235 __entry->addr = addr;
236 __entry->flags = flags;
237 __entry->command = command;
238 __entry->protocol = protocol;
239 ),
240 TP_printk("i2c-%d a=%03x f=%04x c=%x %s",
241 __entry->adapter_nr,
242 __entry->addr,
243 __entry->flags,
244 __entry->command,
245 __print_symbolic(__entry->protocol,
246 { I2C_SMBUS_QUICK, "QUICK" },
247 { I2C_SMBUS_BYTE, "BYTE" },
248 { I2C_SMBUS_BYTE_DATA, "BYTE_DATA" },
249 { I2C_SMBUS_WORD_DATA, "WORD_DATA" },
250 { I2C_SMBUS_PROC_CALL, "PROC_CALL" },
251 { I2C_SMBUS_BLOCK_DATA, "BLOCK_DATA" },
252 { I2C_SMBUS_I2C_BLOCK_BROKEN, "I2C_BLOCK_BROKEN" },
253 { I2C_SMBUS_BLOCK_PROC_CALL, "BLOCK_PROC_CALL" },
254 { I2C_SMBUS_I2C_BLOCK_DATA, "I2C_BLOCK_DATA" })
255 ));
256
257/*
258 * i2c_smbus_xfer() read data or procedure call reply
259 */
260TRACE_EVENT_CONDITION(smbus_reply,
261 TP_PROTO(const struct i2c_adapter *adap,
262 u16 addr, unsigned short flags,
263 char read_write, u8 command, int protocol,
264 const union i2c_smbus_data *data),
265 TP_ARGS(adap, addr, flags, read_write, command, protocol, data),
266 TP_CONDITION(read_write == I2C_SMBUS_READ),
267 TP_STRUCT__entry(
268 __field(int, adapter_nr )
269 __field(__u16, addr )
270 __field(__u16, flags )
271 __field(__u8, command )
272 __field(__u8, len )
273 __field(__u32, protocol )
274 __array(__u8, buf, I2C_SMBUS_BLOCK_MAX + 2) ),
275 TP_fast_assign(
276 __entry->adapter_nr = adap->nr;
277 __entry->addr = addr;
278 __entry->flags = flags;
279 __entry->command = command;
280 __entry->protocol = protocol;
281
282 switch (protocol) {
283 case I2C_SMBUS_BYTE:
284 case I2C_SMBUS_BYTE_DATA:
285 __entry->len = 1;
286 goto copy;
287 case I2C_SMBUS_WORD_DATA:
288 case I2C_SMBUS_PROC_CALL:
289 __entry->len = 2;
290 goto copy;
291 case I2C_SMBUS_BLOCK_DATA:
292 case I2C_SMBUS_BLOCK_PROC_CALL:
293 case I2C_SMBUS_I2C_BLOCK_DATA:
294 __entry->len = data->block[0] + 1;
295 copy:
296 memcpy(__entry->buf, data->block, __entry->len);
297 break;
298 case I2C_SMBUS_QUICK:
299 case I2C_SMBUS_I2C_BLOCK_BROKEN:
300 default:
301 __entry->len = 0;
302 }
303 ),
304 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
305 __entry->adapter_nr,
306 __entry->addr,
307 __entry->flags,
308 __entry->command,
309 __print_symbolic(__entry->protocol,
310 { I2C_SMBUS_QUICK, "QUICK" },
311 { I2C_SMBUS_BYTE, "BYTE" },
312 { I2C_SMBUS_BYTE_DATA, "BYTE_DATA" },
313 { I2C_SMBUS_WORD_DATA, "WORD_DATA" },
314 { I2C_SMBUS_PROC_CALL, "PROC_CALL" },
315 { I2C_SMBUS_BLOCK_DATA, "BLOCK_DATA" },
316 { I2C_SMBUS_I2C_BLOCK_BROKEN, "I2C_BLOCK_BROKEN" },
317 { I2C_SMBUS_BLOCK_PROC_CALL, "BLOCK_PROC_CALL" },
318 { I2C_SMBUS_I2C_BLOCK_DATA, "I2C_BLOCK_DATA" }),
319 __entry->len,
320 __entry->len, __entry->buf
321 ));
322
323/*
324 * i2c_smbus_xfer() result
325 */
326TRACE_EVENT(smbus_result,
327 TP_PROTO(const struct i2c_adapter *adap,
328 u16 addr, unsigned short flags,
329 char read_write, u8 command, int protocol,
330 int res),
331 TP_ARGS(adap, addr, flags, read_write, command, protocol, res),
332 TP_STRUCT__entry(
333 __field(int, adapter_nr )
334 __field(__u16, addr )
335 __field(__u16, flags )
336 __field(__u8, read_write )
337 __field(__u8, command )
338 __field(__s16, res )
339 __field(__u32, protocol )
340 ),
341 TP_fast_assign(
342 __entry->adapter_nr = adap->nr;
343 __entry->addr = addr;
344 __entry->flags = flags;
345 __entry->read_write = read_write;
346 __entry->command = command;
347 __entry->protocol = protocol;
348 __entry->res = res;
349 ),
350 TP_printk("i2c-%d a=%03x f=%04x c=%x %s %s res=%d",
351 __entry->adapter_nr,
352 __entry->addr,
353 __entry->flags,
354 __entry->command,
355 __print_symbolic(__entry->protocol,
356 { I2C_SMBUS_QUICK, "QUICK" },
357 { I2C_SMBUS_BYTE, "BYTE" },
358 { I2C_SMBUS_BYTE_DATA, "BYTE_DATA" },
359 { I2C_SMBUS_WORD_DATA, "WORD_DATA" },
360 { I2C_SMBUS_PROC_CALL, "PROC_CALL" },
361 { I2C_SMBUS_BLOCK_DATA, "BLOCK_DATA" },
362 { I2C_SMBUS_I2C_BLOCK_BROKEN, "I2C_BLOCK_BROKEN" },
363 { I2C_SMBUS_BLOCK_PROC_CALL, "BLOCK_PROC_CALL" },
364 { I2C_SMBUS_I2C_BLOCK_DATA, "I2C_BLOCK_DATA" }),
365 __entry->read_write == I2C_SMBUS_WRITE ? "wr" : "rd",
366 __entry->res
367 ));
368
369#endif /* _TRACE_I2C_H */
370
371/* This part must be outside protection */
372#include <trace/define_trace.h>
diff --git a/include/trace/events/syscalls.h b/include/trace/events/syscalls.h
index 5a4c04a75b3d..14e49c798135 100644
--- a/include/trace/events/syscalls.h
+++ b/include/trace/events/syscalls.h
@@ -13,9 +13,6 @@
13 13
14#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS 14#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
15 15
16extern void syscall_regfunc(void);
17extern void syscall_unregfunc(void);
18
19TRACE_EVENT_FN(sys_enter, 16TRACE_EVENT_FN(sys_enter,
20 17
21 TP_PROTO(struct pt_regs *regs, long id), 18 TP_PROTO(struct pt_regs *regs, long id),
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 8765126b328c..0a1a4f7caf09 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -470,10 +470,13 @@ static inline notrace int ftrace_get_offsets_##call( \
470 * }; 470 * };
471 * 471 *
472 * static struct ftrace_event_call event_<call> = { 472 * static struct ftrace_event_call event_<call> = {
473 * .name = "<call>",
474 * .class = event_class_<template>, 473 * .class = event_class_<template>,
474 * {
475 * .tp = &__tracepoint_<call>,
476 * },
475 * .event = &ftrace_event_type_<call>, 477 * .event = &ftrace_event_type_<call>,
476 * .print_fmt = print_fmt_<call>, 478 * .print_fmt = print_fmt_<call>,
479 * .flags = TRACE_EVENT_FL_TRACEPOINT,
477 * }; 480 * };
478 * // its only safe to use pointers when doing linker tricks to 481 * // its only safe to use pointers when doing linker tricks to
479 * // create an array. 482 * // create an array.
@@ -605,10 +608,13 @@ static struct ftrace_event_class __used __refdata event_class_##call = { \
605#define DEFINE_EVENT(template, call, proto, args) \ 608#define DEFINE_EVENT(template, call, proto, args) \
606 \ 609 \
607static struct ftrace_event_call __used event_##call = { \ 610static struct ftrace_event_call __used event_##call = { \
608 .name = #call, \
609 .class = &event_class_##template, \ 611 .class = &event_class_##template, \
612 { \
613 .tp = &__tracepoint_##call, \
614 }, \
610 .event.funcs = &ftrace_event_type_funcs_##template, \ 615 .event.funcs = &ftrace_event_type_funcs_##template, \
611 .print_fmt = print_fmt_##template, \ 616 .print_fmt = print_fmt_##template, \
617 .flags = TRACE_EVENT_FL_TRACEPOINT, \
612}; \ 618}; \
613static struct ftrace_event_call __used \ 619static struct ftrace_event_call __used \
614__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call 620__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
@@ -619,10 +625,13 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
619static const char print_fmt_##call[] = print; \ 625static const char print_fmt_##call[] = print; \
620 \ 626 \
621static struct ftrace_event_call __used event_##call = { \ 627static struct ftrace_event_call __used event_##call = { \
622 .name = #call, \
623 .class = &event_class_##template, \ 628 .class = &event_class_##template, \
629 { \
630 .tp = &__tracepoint_##call, \
631 }, \
624 .event.funcs = &ftrace_event_type_funcs_##call, \ 632 .event.funcs = &ftrace_event_type_funcs_##call, \
625 .print_fmt = print_fmt_##call, \ 633 .print_fmt = print_fmt_##call, \
634 .flags = TRACE_EVENT_FL_TRACEPOINT, \
626}; \ 635}; \
627static struct ftrace_event_call __used \ 636static struct ftrace_event_call __used \
628__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call 637__attribute__((section("_ftrace_events"))) *__event_##call = &event_##call
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 2d48fe1274ca..11917f747cb4 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -70,7 +70,6 @@
70#define AUDIT_TTY_SET 1017 /* Set TTY auditing status */ 70#define AUDIT_TTY_SET 1017 /* Set TTY auditing status */
71#define AUDIT_SET_FEATURE 1018 /* Turn an audit feature on or off */ 71#define AUDIT_SET_FEATURE 1018 /* Turn an audit feature on or off */
72#define AUDIT_GET_FEATURE 1019 /* Get which features are enabled */ 72#define AUDIT_GET_FEATURE 1019 /* Get which features are enabled */
73#define AUDIT_FEATURE_CHANGE 1020 /* audit log listing feature changes */
74 73
75#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages mostly uninteresting to kernel */ 74#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages mostly uninteresting to kernel */
76#define AUDIT_USER_AVC 1107 /* We filter this differently */ 75#define AUDIT_USER_AVC 1107 /* We filter this differently */
@@ -109,6 +108,8 @@
109#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */ 108#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
110#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */ 109#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
111#define AUDIT_SECCOMP 1326 /* Secure Computing event */ 110#define AUDIT_SECCOMP 1326 /* Secure Computing event */
111#define AUDIT_PROCTITLE 1327 /* Proctitle emit event */
112#define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
112 113
113#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ 114#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
114#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ 115#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
diff --git a/include/uapi/linux/capability.h b/include/uapi/linux/capability.h
index ba478fa3012e..154dd6d3c8fe 100644
--- a/include/uapi/linux/capability.h
+++ b/include/uapi/linux/capability.h
@@ -308,8 +308,12 @@ struct vfs_cap_data {
308 308
309#define CAP_LEASE 28 309#define CAP_LEASE 28
310 310
311/* Allow writing the audit log via unicast netlink socket */
312
311#define CAP_AUDIT_WRITE 29 313#define CAP_AUDIT_WRITE 29
312 314
315/* Allow configuration of audit via unicast netlink socket */
316
313#define CAP_AUDIT_CONTROL 30 317#define CAP_AUDIT_CONTROL 30
314 318
315#define CAP_SETFCAP 31 319#define CAP_SETFCAP 31
diff --git a/include/uapi/linux/nvme.h b/include/uapi/linux/nvme.h
index e5ab62201119..096fe1c6f83d 100644
--- a/include/uapi/linux/nvme.h
+++ b/include/uapi/linux/nvme.h
@@ -434,6 +434,7 @@ enum {
434 NVME_SC_REFTAG_CHECK = 0x284, 434 NVME_SC_REFTAG_CHECK = 0x284,
435 NVME_SC_COMPARE_FAILED = 0x285, 435 NVME_SC_COMPARE_FAILED = 0x285,
436 NVME_SC_ACCESS_DENIED = 0x286, 436 NVME_SC_ACCESS_DENIED = 0x286,
437 NVME_SC_DNR = 0x4000,
437}; 438};
438 439
439struct nvme_completion { 440struct nvme_completion {
diff --git a/include/uapi/linux/v4l2-common.h b/include/uapi/linux/v4l2-common.h
index 270db8914c01..9bf508ad0957 100644
--- a/include/uapi/linux/v4l2-common.h
+++ b/include/uapi/linux/v4l2-common.h
@@ -29,6 +29,8 @@
29#ifndef __V4L2_COMMON__ 29#ifndef __V4L2_COMMON__
30#define __V4L2_COMMON__ 30#define __V4L2_COMMON__
31 31
32#include <linux/types.h>
33
32/* 34/*
33 * 35 *
34 * Selection interface definitions 36 * Selection interface definitions
diff --git a/init/Kconfig b/init/Kconfig
index 427ba60d638f..765018c24cf9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -292,9 +292,12 @@ config AUDIT
292 logging of avc messages output). Does not do system-call 292 logging of avc messages output). Does not do system-call
293 auditing without CONFIG_AUDITSYSCALL. 293 auditing without CONFIG_AUDITSYSCALL.
294 294
295config HAVE_ARCH_AUDITSYSCALL
296 bool
297
295config AUDITSYSCALL 298config AUDITSYSCALL
296 bool "Enable system-call auditing support" 299 bool "Enable system-call auditing support"
297 depends on AUDIT && (X86 || PARISC || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || (ARM && AEABI && !OABI_COMPAT) || ALPHA) 300 depends on AUDIT && HAVE_ARCH_AUDITSYSCALL
298 default y if SECURITY_SELINUX 301 default y if SECURITY_SELINUX
299 help 302 help
300 Enable low-overhead system-call auditing infrastructure that 303 Enable low-overhead system-call auditing infrastructure that
diff --git a/kernel/audit.c b/kernel/audit.c
index 95a20f3f52f1..7c2893602d06 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -182,7 +182,7 @@ struct audit_buffer {
182 182
183struct audit_reply { 183struct audit_reply {
184 __u32 portid; 184 __u32 portid;
185 struct net *net; 185 struct net *net;
186 struct sk_buff *skb; 186 struct sk_buff *skb;
187}; 187};
188 188
@@ -396,7 +396,7 @@ static void audit_printk_skb(struct sk_buff *skb)
396 if (printk_ratelimit()) 396 if (printk_ratelimit())
397 pr_notice("type=%d %s\n", nlh->nlmsg_type, data); 397 pr_notice("type=%d %s\n", nlh->nlmsg_type, data);
398 else 398 else
399 audit_log_lost("printk limit exceeded\n"); 399 audit_log_lost("printk limit exceeded");
400 } 400 }
401 401
402 audit_hold_skb(skb); 402 audit_hold_skb(skb);
@@ -412,7 +412,7 @@ static void kauditd_send_skb(struct sk_buff *skb)
412 BUG_ON(err != -ECONNREFUSED); /* Shouldn't happen */ 412 BUG_ON(err != -ECONNREFUSED); /* Shouldn't happen */
413 if (audit_pid) { 413 if (audit_pid) {
414 pr_err("*NO* daemon at audit_pid=%d\n", audit_pid); 414 pr_err("*NO* daemon at audit_pid=%d\n", audit_pid);
415 audit_log_lost("auditd disappeared\n"); 415 audit_log_lost("auditd disappeared");
416 audit_pid = 0; 416 audit_pid = 0;
417 audit_sock = NULL; 417 audit_sock = NULL;
418 } 418 }
@@ -607,7 +607,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
607{ 607{
608 int err = 0; 608 int err = 0;
609 609
610 /* Only support the initial namespaces for now. */ 610 /* Only support initial user namespace for now. */
611 /* 611 /*
612 * We return ECONNREFUSED because it tricks userspace into thinking 612 * We return ECONNREFUSED because it tricks userspace into thinking
613 * that audit was not configured into the kernel. Lots of users 613 * that audit was not configured into the kernel. Lots of users
@@ -618,8 +618,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
618 * userspace will reject all logins. This should be removed when we 618 * userspace will reject all logins. This should be removed when we
619 * support non init namespaces!! 619 * support non init namespaces!!
620 */ 620 */
621 if ((current_user_ns() != &init_user_ns) || 621 if (current_user_ns() != &init_user_ns)
622 (task_active_pid_ns(current) != &init_pid_ns))
623 return -ECONNREFUSED; 622 return -ECONNREFUSED;
624 623
625 switch (msg_type) { 624 switch (msg_type) {
@@ -639,6 +638,11 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
639 case AUDIT_TTY_SET: 638 case AUDIT_TTY_SET:
640 case AUDIT_TRIM: 639 case AUDIT_TRIM:
641 case AUDIT_MAKE_EQUIV: 640 case AUDIT_MAKE_EQUIV:
641 /* Only support auditd and auditctl in initial pid namespace
642 * for now. */
643 if ((task_active_pid_ns(current) != &init_pid_ns))
644 return -EPERM;
645
642 if (!capable(CAP_AUDIT_CONTROL)) 646 if (!capable(CAP_AUDIT_CONTROL))
643 err = -EPERM; 647 err = -EPERM;
644 break; 648 break;
@@ -659,6 +663,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
659{ 663{
660 int rc = 0; 664 int rc = 0;
661 uid_t uid = from_kuid(&init_user_ns, current_uid()); 665 uid_t uid = from_kuid(&init_user_ns, current_uid());
666 pid_t pid = task_tgid_nr(current);
662 667
663 if (!audit_enabled && msg_type != AUDIT_USER_AVC) { 668 if (!audit_enabled && msg_type != AUDIT_USER_AVC) {
664 *ab = NULL; 669 *ab = NULL;
@@ -668,7 +673,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
668 *ab = audit_log_start(NULL, GFP_KERNEL, msg_type); 673 *ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
669 if (unlikely(!*ab)) 674 if (unlikely(!*ab))
670 return rc; 675 return rc;
671 audit_log_format(*ab, "pid=%d uid=%u", task_tgid_vnr(current), uid); 676 audit_log_format(*ab, "pid=%d uid=%u", pid, uid);
672 audit_log_session_info(*ab); 677 audit_log_session_info(*ab);
673 audit_log_task_context(*ab); 678 audit_log_task_context(*ab);
674 679
@@ -1097,7 +1102,7 @@ static void __net_exit audit_net_exit(struct net *net)
1097 audit_sock = NULL; 1102 audit_sock = NULL;
1098 } 1103 }
1099 1104
1100 rcu_assign_pointer(aunet->nlsk, NULL); 1105 RCU_INIT_POINTER(aunet->nlsk, NULL);
1101 synchronize_net(); 1106 synchronize_net();
1102 netlink_kernel_release(sock); 1107 netlink_kernel_release(sock);
1103} 1108}
@@ -1829,11 +1834,11 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1829 spin_unlock_irq(&tsk->sighand->siglock); 1834 spin_unlock_irq(&tsk->sighand->siglock);
1830 1835
1831 audit_log_format(ab, 1836 audit_log_format(ab,
1832 " ppid=%ld pid=%d auid=%u uid=%u gid=%u" 1837 " ppid=%d pid=%d auid=%u uid=%u gid=%u"
1833 " euid=%u suid=%u fsuid=%u" 1838 " euid=%u suid=%u fsuid=%u"
1834 " egid=%u sgid=%u fsgid=%u tty=%s ses=%u", 1839 " egid=%u sgid=%u fsgid=%u tty=%s ses=%u",
1835 sys_getppid(), 1840 task_ppid_nr(tsk),
1836 tsk->pid, 1841 task_pid_nr(tsk),
1837 from_kuid(&init_user_ns, audit_get_loginuid(tsk)), 1842 from_kuid(&init_user_ns, audit_get_loginuid(tsk)),
1838 from_kuid(&init_user_ns, cred->uid), 1843 from_kuid(&init_user_ns, cred->uid),
1839 from_kgid(&init_user_ns, cred->gid), 1844 from_kgid(&init_user_ns, cred->gid),
diff --git a/kernel/audit.h b/kernel/audit.h
index 8df132214606..7bb65730c890 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -106,6 +106,11 @@ struct audit_names {
106 bool should_free; 106 bool should_free;
107}; 107};
108 108
109struct audit_proctitle {
110 int len; /* length of the cmdline field. */
111 char *value; /* the cmdline field */
112};
113
109/* The per-task audit context. */ 114/* The per-task audit context. */
110struct audit_context { 115struct audit_context {
111 int dummy; /* must be the first element */ 116 int dummy; /* must be the first element */
@@ -202,6 +207,7 @@ struct audit_context {
202 } execve; 207 } execve;
203 }; 208 };
204 int fds[2]; 209 int fds[2];
210 struct audit_proctitle proctitle;
205 211
206#if AUDIT_DEBUG 212#if AUDIT_DEBUG
207 int put_count; 213 int put_count;
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 92062fd6cc8c..8e9bc9c3dbb7 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -19,6 +19,8 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/kernel.h> 24#include <linux/kernel.h>
23#include <linux/audit.h> 25#include <linux/audit.h>
24#include <linux/kthread.h> 26#include <linux/kthread.h>
@@ -226,7 +228,7 @@ static int audit_match_signal(struct audit_entry *entry)
226#endif 228#endif
227 229
228/* Common user-space to kernel rule translation. */ 230/* Common user-space to kernel rule translation. */
229static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule) 231static inline struct audit_entry *audit_to_entry_common(struct audit_rule_data *rule)
230{ 232{
231 unsigned listnr; 233 unsigned listnr;
232 struct audit_entry *entry; 234 struct audit_entry *entry;
@@ -249,7 +251,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
249 ; 251 ;
250 } 252 }
251 if (unlikely(rule->action == AUDIT_POSSIBLE)) { 253 if (unlikely(rule->action == AUDIT_POSSIBLE)) {
252 printk(KERN_ERR "AUDIT_POSSIBLE is deprecated\n"); 254 pr_err("AUDIT_POSSIBLE is deprecated\n");
253 goto exit_err; 255 goto exit_err;
254 } 256 }
255 if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS) 257 if (rule->action != AUDIT_NEVER && rule->action != AUDIT_ALWAYS)
@@ -403,7 +405,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
403 int i; 405 int i;
404 char *str; 406 char *str;
405 407
406 entry = audit_to_entry_common((struct audit_rule *)data); 408 entry = audit_to_entry_common(data);
407 if (IS_ERR(entry)) 409 if (IS_ERR(entry))
408 goto exit_nofree; 410 goto exit_nofree;
409 411
@@ -431,6 +433,19 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
431 f->val = 0; 433 f->val = 0;
432 } 434 }
433 435
436 if ((f->type == AUDIT_PID) || (f->type == AUDIT_PPID)) {
437 struct pid *pid;
438 rcu_read_lock();
439 pid = find_vpid(f->val);
440 if (!pid) {
441 rcu_read_unlock();
442 err = -ESRCH;
443 goto exit_free;
444 }
445 f->val = pid_nr(pid);
446 rcu_read_unlock();
447 }
448
434 err = audit_field_valid(entry, f); 449 err = audit_field_valid(entry, f);
435 if (err) 450 if (err)
436 goto exit_free; 451 goto exit_free;
@@ -479,8 +494,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
479 /* Keep currently invalid fields around in case they 494 /* Keep currently invalid fields around in case they
480 * become valid after a policy reload. */ 495 * become valid after a policy reload. */
481 if (err == -EINVAL) { 496 if (err == -EINVAL) {
482 printk(KERN_WARNING "audit rule for LSM " 497 pr_warn("audit rule for LSM \'%s\' is invalid\n",
483 "\'%s\' is invalid\n", str); 498 str);
484 err = 0; 499 err = 0;
485 } 500 }
486 if (err) { 501 if (err) {
@@ -709,8 +724,8 @@ static inline int audit_dupe_lsm_field(struct audit_field *df,
709 /* Keep currently invalid fields around in case they 724 /* Keep currently invalid fields around in case they
710 * become valid after a policy reload. */ 725 * become valid after a policy reload. */
711 if (ret == -EINVAL) { 726 if (ret == -EINVAL) {
712 printk(KERN_WARNING "audit rule for LSM \'%s\' is " 727 pr_warn("audit rule for LSM \'%s\' is invalid\n",
713 "invalid\n", df->lsm_str); 728 df->lsm_str);
714 ret = 0; 729 ret = 0;
715 } 730 }
716 731
@@ -1240,12 +1255,14 @@ static int audit_filter_user_rules(struct audit_krule *rule, int type,
1240 1255
1241 for (i = 0; i < rule->field_count; i++) { 1256 for (i = 0; i < rule->field_count; i++) {
1242 struct audit_field *f = &rule->fields[i]; 1257 struct audit_field *f = &rule->fields[i];
1258 pid_t pid;
1243 int result = 0; 1259 int result = 0;
1244 u32 sid; 1260 u32 sid;
1245 1261
1246 switch (f->type) { 1262 switch (f->type) {
1247 case AUDIT_PID: 1263 case AUDIT_PID:
1248 result = audit_comparator(task_pid_vnr(current), f->op, f->val); 1264 pid = task_pid_nr(current);
1265 result = audit_comparator(pid, f->op, f->val);
1249 break; 1266 break;
1250 case AUDIT_UID: 1267 case AUDIT_UID:
1251 result = audit_uid_comparator(current_uid(), f->op, f->uid); 1268 result = audit_uid_comparator(current_uid(), f->op, f->uid);
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 7aef2f4b6c64..f251a5e8d17a 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -42,6 +42,8 @@
42 * and <dustin.kirkland@us.ibm.com> for LSPP certification compliance. 42 * and <dustin.kirkland@us.ibm.com> for LSPP certification compliance.
43 */ 43 */
44 44
45#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
46
45#include <linux/init.h> 47#include <linux/init.h>
46#include <asm/types.h> 48#include <asm/types.h>
47#include <linux/atomic.h> 49#include <linux/atomic.h>
@@ -68,6 +70,7 @@
68#include <linux/capability.h> 70#include <linux/capability.h>
69#include <linux/fs_struct.h> 71#include <linux/fs_struct.h>
70#include <linux/compat.h> 72#include <linux/compat.h>
73#include <linux/ctype.h>
71 74
72#include "audit.h" 75#include "audit.h"
73 76
@@ -79,6 +82,9 @@
79/* no execve audit message should be longer than this (userspace limits) */ 82/* no execve audit message should be longer than this (userspace limits) */
80#define MAX_EXECVE_AUDIT_LEN 7500 83#define MAX_EXECVE_AUDIT_LEN 7500
81 84
85/* max length to print of cmdline/proctitle value during audit */
86#define MAX_PROCTITLE_AUDIT_LEN 128
87
82/* number of audit rules */ 88/* number of audit rules */
83int audit_n_rules; 89int audit_n_rules;
84 90
@@ -451,15 +457,17 @@ static int audit_filter_rules(struct task_struct *tsk,
451 struct audit_field *f = &rule->fields[i]; 457 struct audit_field *f = &rule->fields[i];
452 struct audit_names *n; 458 struct audit_names *n;
453 int result = 0; 459 int result = 0;
460 pid_t pid;
454 461
455 switch (f->type) { 462 switch (f->type) {
456 case AUDIT_PID: 463 case AUDIT_PID:
457 result = audit_comparator(tsk->pid, f->op, f->val); 464 pid = task_pid_nr(tsk);
465 result = audit_comparator(pid, f->op, f->val);
458 break; 466 break;
459 case AUDIT_PPID: 467 case AUDIT_PPID:
460 if (ctx) { 468 if (ctx) {
461 if (!ctx->ppid) 469 if (!ctx->ppid)
462 ctx->ppid = sys_getppid(); 470 ctx->ppid = task_ppid_nr(tsk);
463 result = audit_comparator(ctx->ppid, f->op, f->val); 471 result = audit_comparator(ctx->ppid, f->op, f->val);
464 } 472 }
465 break; 473 break;
@@ -805,7 +813,8 @@ void audit_filter_inodes(struct task_struct *tsk, struct audit_context *ctx)
805 rcu_read_unlock(); 813 rcu_read_unlock();
806} 814}
807 815
808static inline struct audit_context *audit_get_context(struct task_struct *tsk, 816/* Transfer the audit context pointer to the caller, clearing it in the tsk's struct */
817static inline struct audit_context *audit_take_context(struct task_struct *tsk,
809 int return_valid, 818 int return_valid,
810 long return_code) 819 long return_code)
811{ 820{
@@ -842,6 +851,13 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk,
842 return context; 851 return context;
843} 852}
844 853
854static inline void audit_proctitle_free(struct audit_context *context)
855{
856 kfree(context->proctitle.value);
857 context->proctitle.value = NULL;
858 context->proctitle.len = 0;
859}
860
845static inline void audit_free_names(struct audit_context *context) 861static inline void audit_free_names(struct audit_context *context)
846{ 862{
847 struct audit_names *n, *next; 863 struct audit_names *n, *next;
@@ -850,16 +866,15 @@ static inline void audit_free_names(struct audit_context *context)
850 if (context->put_count + context->ino_count != context->name_count) { 866 if (context->put_count + context->ino_count != context->name_count) {
851 int i = 0; 867 int i = 0;
852 868
853 printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d" 869 pr_err("%s:%d(:%d): major=%d in_syscall=%d"
854 " name_count=%d put_count=%d" 870 " name_count=%d put_count=%d ino_count=%d"
855 " ino_count=%d [NOT freeing]\n", 871 " [NOT freeing]\n", __FILE__, __LINE__,
856 __FILE__, __LINE__,
857 context->serial, context->major, context->in_syscall, 872 context->serial, context->major, context->in_syscall,
858 context->name_count, context->put_count, 873 context->name_count, context->put_count,
859 context->ino_count); 874 context->ino_count);
860 list_for_each_entry(n, &context->names_list, list) { 875 list_for_each_entry(n, &context->names_list, list) {
861 printk(KERN_ERR "names[%d] = %p = %s\n", i++, 876 pr_err("names[%d] = %p = %s\n", i++, n->name,
862 n->name, n->name->name ?: "(null)"); 877 n->name->name ?: "(null)");
863 } 878 }
864 dump_stack(); 879 dump_stack();
865 return; 880 return;
@@ -955,6 +970,7 @@ static inline void audit_free_context(struct audit_context *context)
955 audit_free_aux(context); 970 audit_free_aux(context);
956 kfree(context->filterkey); 971 kfree(context->filterkey);
957 kfree(context->sockaddr); 972 kfree(context->sockaddr);
973 audit_proctitle_free(context);
958 kfree(context); 974 kfree(context);
959} 975}
960 976
@@ -1157,7 +1173,7 @@ static void audit_log_execve_info(struct audit_context *context,
1157 */ 1173 */
1158 buf = kmalloc(MAX_EXECVE_AUDIT_LEN + 1, GFP_KERNEL); 1174 buf = kmalloc(MAX_EXECVE_AUDIT_LEN + 1, GFP_KERNEL);
1159 if (!buf) { 1175 if (!buf) {
1160 audit_panic("out of memory for argv string\n"); 1176 audit_panic("out of memory for argv string");
1161 return; 1177 return;
1162 } 1178 }
1163 1179
@@ -1271,6 +1287,59 @@ static void show_special(struct audit_context *context, int *call_panic)
1271 audit_log_end(ab); 1287 audit_log_end(ab);
1272} 1288}
1273 1289
1290static inline int audit_proctitle_rtrim(char *proctitle, int len)
1291{
1292 char *end = proctitle + len - 1;
1293 while (end > proctitle && !isprint(*end))
1294 end--;
1295
1296 /* catch the case where proctitle is only 1 non-print character */
1297 len = end - proctitle + 1;
1298 len -= isprint(proctitle[len-1]) == 0;
1299 return len;
1300}
1301
1302static void audit_log_proctitle(struct task_struct *tsk,
1303 struct audit_context *context)
1304{
1305 int res;
1306 char *buf;
1307 char *msg = "(null)";
1308 int len = strlen(msg);
1309 struct audit_buffer *ab;
1310
1311 ab = audit_log_start(context, GFP_KERNEL, AUDIT_PROCTITLE);
1312 if (!ab)
1313 return; /* audit_panic or being filtered */
1314
1315 audit_log_format(ab, "proctitle=");
1316
1317 /* Not cached */
1318 if (!context->proctitle.value) {
1319 buf = kmalloc(MAX_PROCTITLE_AUDIT_LEN, GFP_KERNEL);
1320 if (!buf)
1321 goto out;
1322 /* Historically called this from procfs naming */
1323 res = get_cmdline(tsk, buf, MAX_PROCTITLE_AUDIT_LEN);
1324 if (res == 0) {
1325 kfree(buf);
1326 goto out;
1327 }
1328 res = audit_proctitle_rtrim(buf, res);
1329 if (res == 0) {
1330 kfree(buf);
1331 goto out;
1332 }
1333 context->proctitle.value = buf;
1334 context->proctitle.len = res;
1335 }
1336 msg = context->proctitle.value;
1337 len = context->proctitle.len;
1338out:
1339 audit_log_n_untrustedstring(ab, msg, len);
1340 audit_log_end(ab);
1341}
1342
1274static void audit_log_exit(struct audit_context *context, struct task_struct *tsk) 1343static void audit_log_exit(struct audit_context *context, struct task_struct *tsk)
1275{ 1344{
1276 int i, call_panic = 0; 1345 int i, call_panic = 0;
@@ -1388,6 +1457,8 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1388 audit_log_name(context, n, NULL, i++, &call_panic); 1457 audit_log_name(context, n, NULL, i++, &call_panic);
1389 } 1458 }
1390 1459
1460 audit_log_proctitle(tsk, context);
1461
1391 /* Send end of event record to help user space know we are finished */ 1462 /* Send end of event record to help user space know we are finished */
1392 ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE); 1463 ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
1393 if (ab) 1464 if (ab)
@@ -1406,7 +1477,7 @@ void __audit_free(struct task_struct *tsk)
1406{ 1477{
1407 struct audit_context *context; 1478 struct audit_context *context;
1408 1479
1409 context = audit_get_context(tsk, 0, 0); 1480 context = audit_take_context(tsk, 0, 0);
1410 if (!context) 1481 if (!context)
1411 return; 1482 return;
1412 1483
@@ -1500,7 +1571,7 @@ void __audit_syscall_exit(int success, long return_code)
1500 else 1571 else
1501 success = AUDITSC_FAILURE; 1572 success = AUDITSC_FAILURE;
1502 1573
1503 context = audit_get_context(tsk, success, return_code); 1574 context = audit_take_context(tsk, success, return_code);
1504 if (!context) 1575 if (!context)
1505 return; 1576 return;
1506 1577
@@ -1550,7 +1621,7 @@ static inline void handle_one(const struct inode *inode)
1550 if (likely(put_tree_ref(context, chunk))) 1621 if (likely(put_tree_ref(context, chunk)))
1551 return; 1622 return;
1552 if (unlikely(!grow_tree_refs(context))) { 1623 if (unlikely(!grow_tree_refs(context))) {
1553 printk(KERN_WARNING "out of memory, audit has lost a tree reference\n"); 1624 pr_warn("out of memory, audit has lost a tree reference\n");
1554 audit_set_auditable(context); 1625 audit_set_auditable(context);
1555 audit_put_chunk(chunk); 1626 audit_put_chunk(chunk);
1556 unroll_tree_refs(context, p, count); 1627 unroll_tree_refs(context, p, count);
@@ -1609,8 +1680,7 @@ retry:
1609 goto retry; 1680 goto retry;
1610 } 1681 }
1611 /* too bad */ 1682 /* too bad */
1612 printk(KERN_WARNING 1683 pr_warn("out of memory, audit has lost a tree reference\n");
1613 "out of memory, audit has lost a tree reference\n");
1614 unroll_tree_refs(context, p, count); 1684 unroll_tree_refs(context, p, count);
1615 audit_set_auditable(context); 1685 audit_set_auditable(context);
1616 return; 1686 return;
@@ -1682,7 +1752,7 @@ void __audit_getname(struct filename *name)
1682 1752
1683 if (!context->in_syscall) { 1753 if (!context->in_syscall) {
1684#if AUDIT_DEBUG == 2 1754#if AUDIT_DEBUG == 2
1685 printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n", 1755 pr_err("%s:%d(:%d): ignoring getname(%p)\n",
1686 __FILE__, __LINE__, context->serial, name); 1756 __FILE__, __LINE__, context->serial, name);
1687 dump_stack(); 1757 dump_stack();
1688#endif 1758#endif
@@ -1721,15 +1791,15 @@ void audit_putname(struct filename *name)
1721 BUG_ON(!context); 1791 BUG_ON(!context);
1722 if (!name->aname || !context->in_syscall) { 1792 if (!name->aname || !context->in_syscall) {
1723#if AUDIT_DEBUG == 2 1793#if AUDIT_DEBUG == 2
1724 printk(KERN_ERR "%s:%d(:%d): final_putname(%p)\n", 1794 pr_err("%s:%d(:%d): final_putname(%p)\n",
1725 __FILE__, __LINE__, context->serial, name); 1795 __FILE__, __LINE__, context->serial, name);
1726 if (context->name_count) { 1796 if (context->name_count) {
1727 struct audit_names *n; 1797 struct audit_names *n;
1728 int i = 0; 1798 int i = 0;
1729 1799
1730 list_for_each_entry(n, &context->names_list, list) 1800 list_for_each_entry(n, &context->names_list, list)
1731 printk(KERN_ERR "name[%d] = %p = %s\n", i++, 1801 pr_err("name[%d] = %p = %s\n", i++, n->name,
1732 n->name, n->name->name ?: "(null)"); 1802 n->name->name ?: "(null)");
1733 } 1803 }
1734#endif 1804#endif
1735 final_putname(name); 1805 final_putname(name);
@@ -1738,9 +1808,8 @@ void audit_putname(struct filename *name)
1738 else { 1808 else {
1739 ++context->put_count; 1809 ++context->put_count;
1740 if (context->put_count > context->name_count) { 1810 if (context->put_count > context->name_count) {
1741 printk(KERN_ERR "%s:%d(:%d): major=%d" 1811 pr_err("%s:%d(:%d): major=%d in_syscall=%d putname(%p)"
1742 " in_syscall=%d putname(%p) name_count=%d" 1812 " name_count=%d put_count=%d\n",
1743 " put_count=%d\n",
1744 __FILE__, __LINE__, 1813 __FILE__, __LINE__,
1745 context->serial, context->major, 1814 context->serial, context->major,
1746 context->in_syscall, name->name, 1815 context->in_syscall, name->name,
@@ -1981,12 +2050,10 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
1981 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); 2050 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1982 if (!ab) 2051 if (!ab)
1983 return; 2052 return;
1984 audit_log_format(ab, "pid=%d uid=%u" 2053 audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
1985 " old-auid=%u new-auid=%u old-ses=%u new-ses=%u" 2054 audit_log_task_context(ab);
1986 " res=%d", 2055 audit_log_format(ab, " old-auid=%u auid=%u old-ses=%u ses=%u res=%d",
1987 current->pid, uid, 2056 oldloginuid, loginuid, oldsessionid, sessionid, !rc);
1988 oldloginuid, loginuid, oldsessionid, sessionid,
1989 !rc);
1990 audit_log_end(ab); 2057 audit_log_end(ab);
1991} 2058}
1992 2059
@@ -2208,7 +2275,7 @@ void __audit_ptrace(struct task_struct *t)
2208{ 2275{
2209 struct audit_context *context = current->audit_context; 2276 struct audit_context *context = current->audit_context;
2210 2277
2211 context->target_pid = t->pid; 2278 context->target_pid = task_pid_nr(t);
2212 context->target_auid = audit_get_loginuid(t); 2279 context->target_auid = audit_get_loginuid(t);
2213 context->target_uid = task_uid(t); 2280 context->target_uid = task_uid(t);
2214 context->target_sessionid = audit_get_sessionid(t); 2281 context->target_sessionid = audit_get_sessionid(t);
@@ -2233,7 +2300,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2233 2300
2234 if (audit_pid && t->tgid == audit_pid) { 2301 if (audit_pid && t->tgid == audit_pid) {
2235 if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) { 2302 if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) {
2236 audit_sig_pid = tsk->pid; 2303 audit_sig_pid = task_pid_nr(tsk);
2237 if (uid_valid(tsk->loginuid)) 2304 if (uid_valid(tsk->loginuid))
2238 audit_sig_uid = tsk->loginuid; 2305 audit_sig_uid = tsk->loginuid;
2239 else 2306 else
@@ -2247,7 +2314,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2247 /* optimize the common case by putting first signal recipient directly 2314 /* optimize the common case by putting first signal recipient directly
2248 * in audit_context */ 2315 * in audit_context */
2249 if (!ctx->target_pid) { 2316 if (!ctx->target_pid) {
2250 ctx->target_pid = t->tgid; 2317 ctx->target_pid = task_tgid_nr(t);
2251 ctx->target_auid = audit_get_loginuid(t); 2318 ctx->target_auid = audit_get_loginuid(t);
2252 ctx->target_uid = t_uid; 2319 ctx->target_uid = t_uid;
2253 ctx->target_sessionid = audit_get_sessionid(t); 2320 ctx->target_sessionid = audit_get_sessionid(t);
@@ -2268,7 +2335,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2268 } 2335 }
2269 BUG_ON(axp->pid_count >= AUDIT_AUX_PIDS); 2336 BUG_ON(axp->pid_count >= AUDIT_AUX_PIDS);
2270 2337
2271 axp->target_pid[axp->pid_count] = t->tgid; 2338 axp->target_pid[axp->pid_count] = task_tgid_nr(t);
2272 axp->target_auid[axp->pid_count] = audit_get_loginuid(t); 2339 axp->target_auid[axp->pid_count] = audit_get_loginuid(t);
2273 axp->target_uid[axp->pid_count] = t_uid; 2340 axp->target_uid[axp->pid_count] = t_uid;
2274 axp->target_sessionid[axp->pid_count] = audit_get_sessionid(t); 2341 axp->target_sessionid[axp->pid_count] = audit_get_sessionid(t);
@@ -2368,7 +2435,7 @@ static void audit_log_task(struct audit_buffer *ab)
2368 from_kgid(&init_user_ns, gid), 2435 from_kgid(&init_user_ns, gid),
2369 sessionid); 2436 sessionid);
2370 audit_log_task_context(ab); 2437 audit_log_task_context(ab);
2371 audit_log_format(ab, " pid=%d comm=", current->pid); 2438 audit_log_format(ab, " pid=%d comm=", task_pid_nr(current));
2372 audit_log_untrustedstring(ab, current->comm); 2439 audit_log_untrustedstring(ab, current->comm);
2373 if (mm) { 2440 if (mm) {
2374 down_read(&mm->mmap_sem); 2441 down_read(&mm->mmap_sem);
diff --git a/kernel/futex.c b/kernel/futex.c
index 67dacaf93e56..5f589279e462 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -70,7 +70,10 @@
70#include "locking/rtmutex_common.h" 70#include "locking/rtmutex_common.h"
71 71
72/* 72/*
73 * Basic futex operation and ordering guarantees: 73 * READ this before attempting to hack on futexes!
74 *
75 * Basic futex operation and ordering guarantees
76 * =============================================
74 * 77 *
75 * The waiter reads the futex value in user space and calls 78 * The waiter reads the futex value in user space and calls
76 * futex_wait(). This function computes the hash bucket and acquires 79 * futex_wait(). This function computes the hash bucket and acquires
@@ -119,7 +122,7 @@
119 * sys_futex(WAIT, futex, val); 122 * sys_futex(WAIT, futex, val);
120 * futex_wait(futex, val); 123 * futex_wait(futex, val);
121 * 124 *
122 * waiters++; 125 * waiters++; (a)
123 * mb(); (A) <-- paired with -. 126 * mb(); (A) <-- paired with -.
124 * | 127 * |
125 * lock(hash_bucket(futex)); | 128 * lock(hash_bucket(futex)); |
@@ -135,14 +138,14 @@
135 * unlock(hash_bucket(futex)); 138 * unlock(hash_bucket(futex));
136 * schedule(); if (waiters) 139 * schedule(); if (waiters)
137 * lock(hash_bucket(futex)); 140 * lock(hash_bucket(futex));
138 * wake_waiters(futex); 141 * else wake_waiters(futex);
139 * unlock(hash_bucket(futex)); 142 * waiters--; (b) unlock(hash_bucket(futex));
140 * 143 *
141 * Where (A) orders the waiters increment and the futex value read -- this 144 * Where (A) orders the waiters increment and the futex value read through
142 * is guaranteed by the head counter in the hb spinlock; and where (B) 145 * atomic operations (see hb_waiters_inc) and where (B) orders the write
143 * orders the write to futex and the waiters read -- this is done by the 146 * to futex and the waiters read -- this is done by the barriers in
144 * barriers in get_futex_key_refs(), through either ihold or atomic_inc, 147 * get_futex_key_refs(), through either ihold or atomic_inc, depending on the
145 * depending on the futex type. 148 * futex type.
146 * 149 *
147 * This yields the following case (where X:=waiters, Y:=futex): 150 * This yields the following case (where X:=waiters, Y:=futex):
148 * 151 *
@@ -155,6 +158,17 @@
155 * Which guarantees that x==0 && y==0 is impossible; which translates back into 158 * Which guarantees that x==0 && y==0 is impossible; which translates back into
156 * the guarantee that we cannot both miss the futex variable change and the 159 * the guarantee that we cannot both miss the futex variable change and the
157 * enqueue. 160 * enqueue.
161 *
162 * Note that a new waiter is accounted for in (a) even when it is possible that
163 * the wait call can return error, in which case we backtrack from it in (b).
164 * Refer to the comment in queue_lock().
165 *
166 * Similarly, in order to account for waiters being requeued on another
167 * address we always increment the waiters for the destination bucket before
168 * acquiring the lock. It then decrements them again after releasing it -
169 * the code that actually moves the futex(es) between hash buckets (requeue_futex)
170 * will do the additional required waiter count housekeeping. This is done for
171 * double_lock_hb() and double_unlock_hb(), respectively.
158 */ 172 */
159 173
160#ifndef CONFIG_HAVE_FUTEX_CMPXCHG 174#ifndef CONFIG_HAVE_FUTEX_CMPXCHG
@@ -1452,6 +1466,7 @@ retry:
1452 hb2 = hash_futex(&key2); 1466 hb2 = hash_futex(&key2);
1453 1467
1454retry_private: 1468retry_private:
1469 hb_waiters_inc(hb2);
1455 double_lock_hb(hb1, hb2); 1470 double_lock_hb(hb1, hb2);
1456 1471
1457 if (likely(cmpval != NULL)) { 1472 if (likely(cmpval != NULL)) {
@@ -1461,6 +1476,7 @@ retry_private:
1461 1476
1462 if (unlikely(ret)) { 1477 if (unlikely(ret)) {
1463 double_unlock_hb(hb1, hb2); 1478 double_unlock_hb(hb1, hb2);
1479 hb_waiters_dec(hb2);
1464 1480
1465 ret = get_user(curval, uaddr1); 1481 ret = get_user(curval, uaddr1);
1466 if (ret) 1482 if (ret)
@@ -1510,6 +1526,7 @@ retry_private:
1510 break; 1526 break;
1511 case -EFAULT: 1527 case -EFAULT:
1512 double_unlock_hb(hb1, hb2); 1528 double_unlock_hb(hb1, hb2);
1529 hb_waiters_dec(hb2);
1513 put_futex_key(&key2); 1530 put_futex_key(&key2);
1514 put_futex_key(&key1); 1531 put_futex_key(&key1);
1515 ret = fault_in_user_writeable(uaddr2); 1532 ret = fault_in_user_writeable(uaddr2);
@@ -1519,6 +1536,7 @@ retry_private:
1519 case -EAGAIN: 1536 case -EAGAIN:
1520 /* The owner was exiting, try again. */ 1537 /* The owner was exiting, try again. */
1521 double_unlock_hb(hb1, hb2); 1538 double_unlock_hb(hb1, hb2);
1539 hb_waiters_dec(hb2);
1522 put_futex_key(&key2); 1540 put_futex_key(&key2);
1523 put_futex_key(&key1); 1541 put_futex_key(&key1);
1524 cond_resched(); 1542 cond_resched();
@@ -1594,6 +1612,7 @@ retry_private:
1594 1612
1595out_unlock: 1613out_unlock:
1596 double_unlock_hb(hb1, hb2); 1614 double_unlock_hb(hb1, hb2);
1615 hb_waiters_dec(hb2);
1597 1616
1598 /* 1617 /*
1599 * drop_futex_key_refs() must be called outside the spinlocks. During 1618 * drop_futex_key_refs() must be called outside the spinlocks. During
diff --git a/kernel/relay.c b/kernel/relay.c
index 52d6a6f56261..5a56d3c8dc03 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1195,8 +1195,6 @@ static void relay_pipe_buf_release(struct pipe_inode_info *pipe,
1195 1195
1196static const struct pipe_buf_operations relay_pipe_buf_ops = { 1196static const struct pipe_buf_operations relay_pipe_buf_ops = {
1197 .can_merge = 0, 1197 .can_merge = 0,
1198 .map = generic_pipe_buf_map,
1199 .unmap = generic_pipe_buf_unmap,
1200 .confirm = generic_pipe_buf_confirm, 1198 .confirm = generic_pipe_buf_confirm,
1201 .release = relay_pipe_buf_release, 1199 .release = relay_pipe_buf_release,
1202 .steal = generic_pipe_buf_steal, 1200 .steal = generic_pipe_buf_steal,
@@ -1253,7 +1251,7 @@ static ssize_t subbuf_splice_actor(struct file *in,
1253 subbuf_pages = rbuf->chan->alloc_size >> PAGE_SHIFT; 1251 subbuf_pages = rbuf->chan->alloc_size >> PAGE_SHIFT;
1254 pidx = (read_start / PAGE_SIZE) % subbuf_pages; 1252 pidx = (read_start / PAGE_SIZE) % subbuf_pages;
1255 poff = read_start & ~PAGE_MASK; 1253 poff = read_start & ~PAGE_MASK;
1256 nr_pages = min_t(unsigned int, subbuf_pages, pipe->buffers); 1254 nr_pages = min_t(unsigned int, subbuf_pages, spd.nr_pages_max);
1257 1255
1258 for (total_len = 0; spd.nr_pages < nr_pages; spd.nr_pages++) { 1256 for (total_len = 0; spd.nr_pages < nr_pages; spd.nr_pages++) {
1259 unsigned int this_len, this_end, private; 1257 unsigned int this_len, this_end, private;
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index fd609bd9d6dd..d8d046c0726a 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -71,7 +71,7 @@ static void populate_seccomp_data(struct seccomp_data *sd)
71 struct pt_regs *regs = task_pt_regs(task); 71 struct pt_regs *regs = task_pt_regs(task);
72 72
73 sd->nr = syscall_get_nr(task, regs); 73 sd->nr = syscall_get_nr(task, regs);
74 sd->arch = syscall_get_arch(task, regs); 74 sd->arch = syscall_get_arch();
75 75
76 /* Unroll syscall_get_args to help gcc on arm. */ 76 /* Unroll syscall_get_args to help gcc on arm. */
77 syscall_get_arguments(task, regs, 0, 1, (unsigned long *) &sd->args[0]); 77 syscall_get_arguments(task, regs, 0, 1, (unsigned long *) &sd->args[0]);
@@ -348,7 +348,7 @@ static void seccomp_send_sigsys(int syscall, int reason)
348 info.si_code = SYS_SECCOMP; 348 info.si_code = SYS_SECCOMP;
349 info.si_call_addr = (void __user *)KSTK_EIP(current); 349 info.si_call_addr = (void __user *)KSTK_EIP(current);
350 info.si_errno = reason; 350 info.si_errno = reason;
351 info.si_arch = syscall_get_arch(current, task_pt_regs(current)); 351 info.si_arch = syscall_get_arch();
352 info.si_syscall = syscall; 352 info.si_syscall = syscall;
353 force_sig_info(SIGSYS, &info, current); 353 force_sig_info(SIGSYS, &info, current);
354} 354}
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9be67c5e5b0f..737b0efa1a62 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3611,6 +3611,8 @@ static const char readme_msg[] =
3611#ifdef CONFIG_TRACER_SNAPSHOT 3611#ifdef CONFIG_TRACER_SNAPSHOT
3612 "\t\t snapshot\n" 3612 "\t\t snapshot\n"
3613#endif 3613#endif
3614 "\t\t dump\n"
3615 "\t\t cpudump\n"
3614 "\t example: echo do_fault:traceoff > set_ftrace_filter\n" 3616 "\t example: echo do_fault:traceoff > set_ftrace_filter\n"
3615 "\t echo do_trap:traceoff:3 > set_ftrace_filter\n" 3617 "\t echo do_trap:traceoff:3 > set_ftrace_filter\n"
3616 "\t The first one will disable tracing every time do_fault is hit\n" 3618 "\t The first one will disable tracing every time do_fault is hit\n"
@@ -4390,8 +4392,6 @@ static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
4390 4392
4391static const struct pipe_buf_operations tracing_pipe_buf_ops = { 4393static const struct pipe_buf_operations tracing_pipe_buf_ops = {
4392 .can_merge = 0, 4394 .can_merge = 0,
4393 .map = generic_pipe_buf_map,
4394 .unmap = generic_pipe_buf_unmap,
4395 .confirm = generic_pipe_buf_confirm, 4395 .confirm = generic_pipe_buf_confirm,
4396 .release = generic_pipe_buf_release, 4396 .release = generic_pipe_buf_release,
4397 .steal = generic_pipe_buf_steal, 4397 .steal = generic_pipe_buf_steal,
@@ -4486,7 +4486,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
4486 trace_access_lock(iter->cpu_file); 4486 trace_access_lock(iter->cpu_file);
4487 4487
4488 /* Fill as many pages as possible. */ 4488 /* Fill as many pages as possible. */
4489 for (i = 0, rem = len; i < pipe->buffers && rem; i++) { 4489 for (i = 0, rem = len; i < spd.nr_pages_max && rem; i++) {
4490 spd.pages[i] = alloc_page(GFP_KERNEL); 4490 spd.pages[i] = alloc_page(GFP_KERNEL);
4491 if (!spd.pages[i]) 4491 if (!spd.pages[i])
4492 break; 4492 break;
@@ -5279,8 +5279,6 @@ static void buffer_pipe_buf_get(struct pipe_inode_info *pipe,
5279/* Pipe buffer operations for a buffer. */ 5279/* Pipe buffer operations for a buffer. */
5280static const struct pipe_buf_operations buffer_pipe_buf_ops = { 5280static const struct pipe_buf_operations buffer_pipe_buf_ops = {
5281 .can_merge = 0, 5281 .can_merge = 0,
5282 .map = generic_pipe_buf_map,
5283 .unmap = generic_pipe_buf_unmap,
5284 .confirm = generic_pipe_buf_confirm, 5282 .confirm = generic_pipe_buf_confirm,
5285 .release = buffer_pipe_buf_release, 5283 .release = buffer_pipe_buf_release,
5286 .steal = generic_pipe_buf_steal, 5284 .steal = generic_pipe_buf_steal,
@@ -5356,7 +5354,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5356 trace_access_lock(iter->cpu_file); 5354 trace_access_lock(iter->cpu_file);
5357 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); 5355 entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
5358 5356
5359 for (i = 0; i < pipe->buffers && len && entries; i++, len -= PAGE_SIZE) { 5357 for (i = 0; i < spd.nr_pages_max && len && entries; i++, len -= PAGE_SIZE) {
5360 struct page *page; 5358 struct page *page;
5361 int r; 5359 int r;
5362 5360
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 83a4378dc5e0..3ddfd8f62c05 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -223,24 +223,25 @@ int ftrace_event_reg(struct ftrace_event_call *call,
223{ 223{
224 struct ftrace_event_file *file = data; 224 struct ftrace_event_file *file = data;
225 225
226 WARN_ON(!(call->flags & TRACE_EVENT_FL_TRACEPOINT));
226 switch (type) { 227 switch (type) {
227 case TRACE_REG_REGISTER: 228 case TRACE_REG_REGISTER:
228 return tracepoint_probe_register(call->name, 229 return tracepoint_probe_register(call->tp,
229 call->class->probe, 230 call->class->probe,
230 file); 231 file);
231 case TRACE_REG_UNREGISTER: 232 case TRACE_REG_UNREGISTER:
232 tracepoint_probe_unregister(call->name, 233 tracepoint_probe_unregister(call->tp,
233 call->class->probe, 234 call->class->probe,
234 file); 235 file);
235 return 0; 236 return 0;
236 237
237#ifdef CONFIG_PERF_EVENTS 238#ifdef CONFIG_PERF_EVENTS
238 case TRACE_REG_PERF_REGISTER: 239 case TRACE_REG_PERF_REGISTER:
239 return tracepoint_probe_register(call->name, 240 return tracepoint_probe_register(call->tp,
240 call->class->perf_probe, 241 call->class->perf_probe,
241 call); 242 call);
242 case TRACE_REG_PERF_UNREGISTER: 243 case TRACE_REG_PERF_UNREGISTER:
243 tracepoint_probe_unregister(call->name, 244 tracepoint_probe_unregister(call->tp,
244 call->class->perf_probe, 245 call->class->perf_probe,
245 call); 246 call);
246 return 0; 247 return 0;
@@ -352,7 +353,7 @@ static int __ftrace_event_enable_disable(struct ftrace_event_file *file,
352 if (ret) { 353 if (ret) {
353 tracing_stop_cmdline_record(); 354 tracing_stop_cmdline_record();
354 pr_info("event trace: Could not enable event " 355 pr_info("event trace: Could not enable event "
355 "%s\n", call->name); 356 "%s\n", ftrace_event_name(call));
356 break; 357 break;
357 } 358 }
358 set_bit(FTRACE_EVENT_FL_ENABLED_BIT, &file->flags); 359 set_bit(FTRACE_EVENT_FL_ENABLED_BIT, &file->flags);
@@ -481,27 +482,29 @@ __ftrace_set_clr_event_nolock(struct trace_array *tr, const char *match,
481{ 482{
482 struct ftrace_event_file *file; 483 struct ftrace_event_file *file;
483 struct ftrace_event_call *call; 484 struct ftrace_event_call *call;
485 const char *name;
484 int ret = -EINVAL; 486 int ret = -EINVAL;
485 487
486 list_for_each_entry(file, &tr->events, list) { 488 list_for_each_entry(file, &tr->events, list) {
487 489
488 call = file->event_call; 490 call = file->event_call;
491 name = ftrace_event_name(call);
489 492
490 if (!call->name || !call->class || !call->class->reg) 493 if (!name || !call->class || !call->class->reg)
491 continue; 494 continue;
492 495
493 if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) 496 if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)
494 continue; 497 continue;
495 498
496 if (match && 499 if (match &&
497 strcmp(match, call->name) != 0 && 500 strcmp(match, name) != 0 &&
498 strcmp(match, call->class->system) != 0) 501 strcmp(match, call->class->system) != 0)
499 continue; 502 continue;
500 503
501 if (sub && strcmp(sub, call->class->system) != 0) 504 if (sub && strcmp(sub, call->class->system) != 0)
502 continue; 505 continue;
503 506
504 if (event && strcmp(event, call->name) != 0) 507 if (event && strcmp(event, name) != 0)
505 continue; 508 continue;
506 509
507 ftrace_event_enable_disable(file, set); 510 ftrace_event_enable_disable(file, set);
@@ -699,7 +702,7 @@ static int t_show(struct seq_file *m, void *v)
699 702
700 if (strcmp(call->class->system, TRACE_SYSTEM) != 0) 703 if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
701 seq_printf(m, "%s:", call->class->system); 704 seq_printf(m, "%s:", call->class->system);
702 seq_printf(m, "%s\n", call->name); 705 seq_printf(m, "%s\n", ftrace_event_name(call));
703 706
704 return 0; 707 return 0;
705} 708}
@@ -792,7 +795,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
792 mutex_lock(&event_mutex); 795 mutex_lock(&event_mutex);
793 list_for_each_entry(file, &tr->events, list) { 796 list_for_each_entry(file, &tr->events, list) {
794 call = file->event_call; 797 call = file->event_call;
795 if (!call->name || !call->class || !call->class->reg) 798 if (!ftrace_event_name(call) || !call->class || !call->class->reg)
796 continue; 799 continue;
797 800
798 if (system && strcmp(call->class->system, system->name) != 0) 801 if (system && strcmp(call->class->system, system->name) != 0)
@@ -907,7 +910,7 @@ static int f_show(struct seq_file *m, void *v)
907 910
908 switch ((unsigned long)v) { 911 switch ((unsigned long)v) {
909 case FORMAT_HEADER: 912 case FORMAT_HEADER:
910 seq_printf(m, "name: %s\n", call->name); 913 seq_printf(m, "name: %s\n", ftrace_event_name(call));
911 seq_printf(m, "ID: %d\n", call->event.type); 914 seq_printf(m, "ID: %d\n", call->event.type);
912 seq_printf(m, "format:\n"); 915 seq_printf(m, "format:\n");
913 return 0; 916 return 0;
@@ -1527,6 +1530,7 @@ event_create_dir(struct dentry *parent, struct ftrace_event_file *file)
1527 struct trace_array *tr = file->tr; 1530 struct trace_array *tr = file->tr;
1528 struct list_head *head; 1531 struct list_head *head;
1529 struct dentry *d_events; 1532 struct dentry *d_events;
1533 const char *name;
1530 int ret; 1534 int ret;
1531 1535
1532 /* 1536 /*
@@ -1540,10 +1544,11 @@ event_create_dir(struct dentry *parent, struct ftrace_event_file *file)
1540 } else 1544 } else
1541 d_events = parent; 1545 d_events = parent;
1542 1546
1543 file->dir = debugfs_create_dir(call->name, d_events); 1547 name = ftrace_event_name(call);
1548 file->dir = debugfs_create_dir(name, d_events);
1544 if (!file->dir) { 1549 if (!file->dir) {
1545 pr_warning("Could not create debugfs '%s' directory\n", 1550 pr_warning("Could not create debugfs '%s' directory\n",
1546 call->name); 1551 name);
1547 return -1; 1552 return -1;
1548 } 1553 }
1549 1554
@@ -1567,7 +1572,7 @@ event_create_dir(struct dentry *parent, struct ftrace_event_file *file)
1567 ret = call->class->define_fields(call); 1572 ret = call->class->define_fields(call);
1568 if (ret < 0) { 1573 if (ret < 0) {
1569 pr_warning("Could not initialize trace point" 1574 pr_warning("Could not initialize trace point"
1570 " events/%s\n", call->name); 1575 " events/%s\n", name);
1571 return -1; 1576 return -1;
1572 } 1577 }
1573 } 1578 }
@@ -1631,15 +1636,17 @@ static void event_remove(struct ftrace_event_call *call)
1631static int event_init(struct ftrace_event_call *call) 1636static int event_init(struct ftrace_event_call *call)
1632{ 1637{
1633 int ret = 0; 1638 int ret = 0;
1639 const char *name;
1634 1640
1635 if (WARN_ON(!call->name)) 1641 name = ftrace_event_name(call);
1642 if (WARN_ON(!name))
1636 return -EINVAL; 1643 return -EINVAL;
1637 1644
1638 if (call->class->raw_init) { 1645 if (call->class->raw_init) {
1639 ret = call->class->raw_init(call); 1646 ret = call->class->raw_init(call);
1640 if (ret < 0 && ret != -ENOSYS) 1647 if (ret < 0 && ret != -ENOSYS)
1641 pr_warn("Could not initialize trace events/%s\n", 1648 pr_warn("Could not initialize trace events/%s\n",
1642 call->name); 1649 name);
1643 } 1650 }
1644 1651
1645 return ret; 1652 return ret;
@@ -1885,7 +1892,7 @@ __trace_add_event_dirs(struct trace_array *tr)
1885 ret = __trace_add_new_event(call, tr); 1892 ret = __trace_add_new_event(call, tr);
1886 if (ret < 0) 1893 if (ret < 0)
1887 pr_warning("Could not create directory for event %s\n", 1894 pr_warning("Could not create directory for event %s\n",
1888 call->name); 1895 ftrace_event_name(call));
1889 } 1896 }
1890} 1897}
1891 1898
@@ -1894,18 +1901,20 @@ find_event_file(struct trace_array *tr, const char *system, const char *event)
1894{ 1901{
1895 struct ftrace_event_file *file; 1902 struct ftrace_event_file *file;
1896 struct ftrace_event_call *call; 1903 struct ftrace_event_call *call;
1904 const char *name;
1897 1905
1898 list_for_each_entry(file, &tr->events, list) { 1906 list_for_each_entry(file, &tr->events, list) {
1899 1907
1900 call = file->event_call; 1908 call = file->event_call;
1909 name = ftrace_event_name(call);
1901 1910
1902 if (!call->name || !call->class || !call->class->reg) 1911 if (!name || !call->class || !call->class->reg)
1903 continue; 1912 continue;
1904 1913
1905 if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) 1914 if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)
1906 continue; 1915 continue;
1907 1916
1908 if (strcmp(event, call->name) == 0 && 1917 if (strcmp(event, name) == 0 &&
1909 strcmp(system, call->class->system) == 0) 1918 strcmp(system, call->class->system) == 0)
1910 return file; 1919 return file;
1911 } 1920 }
@@ -1973,7 +1982,7 @@ event_enable_print(struct seq_file *m, unsigned long ip,
1973 seq_printf(m, "%s:%s:%s", 1982 seq_printf(m, "%s:%s:%s",
1974 data->enable ? ENABLE_EVENT_STR : DISABLE_EVENT_STR, 1983 data->enable ? ENABLE_EVENT_STR : DISABLE_EVENT_STR,
1975 data->file->event_call->class->system, 1984 data->file->event_call->class->system,
1976 data->file->event_call->name); 1985 ftrace_event_name(data->file->event_call));
1977 1986
1978 if (data->count == -1) 1987 if (data->count == -1)
1979 seq_printf(m, ":unlimited\n"); 1988 seq_printf(m, ":unlimited\n");
@@ -2193,7 +2202,7 @@ __trace_early_add_event_dirs(struct trace_array *tr)
2193 ret = event_create_dir(tr->event_dir, file); 2202 ret = event_create_dir(tr->event_dir, file);
2194 if (ret < 0) 2203 if (ret < 0)
2195 pr_warning("Could not create directory for event %s\n", 2204 pr_warning("Could not create directory for event %s\n",
2196 file->event_call->name); 2205 ftrace_event_name(file->event_call));
2197 } 2206 }
2198} 2207}
2199 2208
@@ -2217,7 +2226,7 @@ __trace_early_add_events(struct trace_array *tr)
2217 ret = __trace_early_add_new_event(call, tr); 2226 ret = __trace_early_add_new_event(call, tr);
2218 if (ret < 0) 2227 if (ret < 0)
2219 pr_warning("Could not create early event %s\n", 2228 pr_warning("Could not create early event %s\n",
2220 call->name); 2229 ftrace_event_name(call));
2221 } 2230 }
2222} 2231}
2223 2232
@@ -2549,7 +2558,7 @@ static __init void event_trace_self_tests(void)
2549 continue; 2558 continue;
2550#endif 2559#endif
2551 2560
2552 pr_info("Testing event %s: ", call->name); 2561 pr_info("Testing event %s: ", ftrace_event_name(call));
2553 2562
2554 /* 2563 /*
2555 * If an event is already enabled, someone is using 2564 * If an event is already enabled, someone is using
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 8efbb69b04f0..925f537f07d1 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -1095,7 +1095,7 @@ event_enable_trigger_print(struct seq_file *m, struct event_trigger_ops *ops,
1095 seq_printf(m, "%s:%s:%s", 1095 seq_printf(m, "%s:%s:%s",
1096 enable_data->enable ? ENABLE_EVENT_STR : DISABLE_EVENT_STR, 1096 enable_data->enable ? ENABLE_EVENT_STR : DISABLE_EVENT_STR,
1097 enable_data->file->event_call->class->system, 1097 enable_data->file->event_call->class->system,
1098 enable_data->file->event_call->name); 1098 ftrace_event_name(enable_data->file->event_call));
1099 1099
1100 if (data->count == -1) 1100 if (data->count == -1)
1101 seq_puts(m, ":unlimited"); 1101 seq_puts(m, ":unlimited");
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index ee0a5098ac43..d4ddde28a81a 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -173,9 +173,11 @@ struct ftrace_event_class __refdata event_class_ftrace_##call = { \
173}; \ 173}; \
174 \ 174 \
175struct ftrace_event_call __used event_##call = { \ 175struct ftrace_event_call __used event_##call = { \
176 .name = #call, \
177 .event.type = etype, \
178 .class = &event_class_ftrace_##call, \ 176 .class = &event_class_ftrace_##call, \
177 { \
178 .name = #call, \
179 }, \
180 .event.type = etype, \
179 .print_fmt = print, \ 181 .print_fmt = print, \
180 .flags = TRACE_EVENT_FL_IGNORE_ENABLE | TRACE_EVENT_FL_USE_CALL_FILTER, \ 182 .flags = TRACE_EVENT_FL_IGNORE_ENABLE | TRACE_EVENT_FL_USE_CALL_FILTER, \
181}; \ 183}; \
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index d021d21dd150..903ae28962be 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -341,7 +341,7 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
341 struct trace_kprobe *tk; 341 struct trace_kprobe *tk;
342 342
343 list_for_each_entry(tk, &probe_list, list) 343 list_for_each_entry(tk, &probe_list, list)
344 if (strcmp(tk->tp.call.name, event) == 0 && 344 if (strcmp(ftrace_event_name(&tk->tp.call), event) == 0 &&
345 strcmp(tk->tp.call.class->system, group) == 0) 345 strcmp(tk->tp.call.class->system, group) == 0)
346 return tk; 346 return tk;
347 return NULL; 347 return NULL;
@@ -516,7 +516,8 @@ static int register_trace_kprobe(struct trace_kprobe *tk)
516 mutex_lock(&probe_lock); 516 mutex_lock(&probe_lock);
517 517
518 /* Delete old (same name) event if exist */ 518 /* Delete old (same name) event if exist */
519 old_tk = find_trace_kprobe(tk->tp.call.name, tk->tp.call.class->system); 519 old_tk = find_trace_kprobe(ftrace_event_name(&tk->tp.call),
520 tk->tp.call.class->system);
520 if (old_tk) { 521 if (old_tk) {
521 ret = unregister_trace_kprobe(old_tk); 522 ret = unregister_trace_kprobe(old_tk);
522 if (ret < 0) 523 if (ret < 0)
@@ -564,7 +565,8 @@ static int trace_kprobe_module_callback(struct notifier_block *nb,
564 if (ret) 565 if (ret)
565 pr_warning("Failed to re-register probe %s on" 566 pr_warning("Failed to re-register probe %s on"
566 "%s: %d\n", 567 "%s: %d\n",
567 tk->tp.call.name, mod->name, ret); 568 ftrace_event_name(&tk->tp.call),
569 mod->name, ret);
568 } 570 }
569 } 571 }
570 mutex_unlock(&probe_lock); 572 mutex_unlock(&probe_lock);
@@ -818,7 +820,8 @@ static int probes_seq_show(struct seq_file *m, void *v)
818 int i; 820 int i;
819 821
820 seq_printf(m, "%c", trace_kprobe_is_return(tk) ? 'r' : 'p'); 822 seq_printf(m, "%c", trace_kprobe_is_return(tk) ? 'r' : 'p');
821 seq_printf(m, ":%s/%s", tk->tp.call.class->system, tk->tp.call.name); 823 seq_printf(m, ":%s/%s", tk->tp.call.class->system,
824 ftrace_event_name(&tk->tp.call));
822 825
823 if (!tk->symbol) 826 if (!tk->symbol)
824 seq_printf(m, " 0x%p", tk->rp.kp.addr); 827 seq_printf(m, " 0x%p", tk->rp.kp.addr);
@@ -876,7 +879,8 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)
876{ 879{
877 struct trace_kprobe *tk = v; 880 struct trace_kprobe *tk = v;
878 881
879 seq_printf(m, " %-44s %15lu %15lu\n", tk->tp.call.name, tk->nhit, 882 seq_printf(m, " %-44s %15lu %15lu\n",
883 ftrace_event_name(&tk->tp.call), tk->nhit,
880 tk->rp.kp.nmissed); 884 tk->rp.kp.nmissed);
881 885
882 return 0; 886 return 0;
@@ -1011,7 +1015,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags,
1011 field = (struct kprobe_trace_entry_head *)iter->ent; 1015 field = (struct kprobe_trace_entry_head *)iter->ent;
1012 tp = container_of(event, struct trace_probe, call.event); 1016 tp = container_of(event, struct trace_probe, call.event);
1013 1017
1014 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1018 if (!trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call)))
1015 goto partial; 1019 goto partial;
1016 1020
1017 if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET)) 1021 if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET))
@@ -1047,7 +1051,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags,
1047 field = (struct kretprobe_trace_entry_head *)iter->ent; 1051 field = (struct kretprobe_trace_entry_head *)iter->ent;
1048 tp = container_of(event, struct trace_probe, call.event); 1052 tp = container_of(event, struct trace_probe, call.event);
1049 1053
1050 if (!trace_seq_printf(s, "%s: (", tp->call.name)) 1054 if (!trace_seq_printf(s, "%s: (", ftrace_event_name(&tp->call)))
1051 goto partial; 1055 goto partial;
1052 1056
1053 if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET)) 1057 if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET))
@@ -1286,7 +1290,8 @@ static int register_kprobe_event(struct trace_kprobe *tk)
1286 call->data = tk; 1290 call->data = tk;
1287 ret = trace_add_event_call(call); 1291 ret = trace_add_event_call(call);
1288 if (ret) { 1292 if (ret) {
1289 pr_info("Failed to register kprobe event: %s\n", call->name); 1293 pr_info("Failed to register kprobe event: %s\n",
1294 ftrace_event_name(call));
1290 kfree(call->print_fmt); 1295 kfree(call->print_fmt);
1291 unregister_ftrace_event(&call->event); 1296 unregister_ftrace_event(&call->event);
1292 } 1297 }
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index ca0e79e2abaa..a436de18aa99 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -431,7 +431,7 @@ int ftrace_raw_output_prep(struct trace_iterator *iter,
431 } 431 }
432 432
433 trace_seq_init(p); 433 trace_seq_init(p);
434 ret = trace_seq_printf(s, "%s: ", event->name); 434 ret = trace_seq_printf(s, "%s: ", ftrace_event_name(event));
435 if (!ret) 435 if (!ret)
436 return TRACE_TYPE_PARTIAL_LINE; 436 return TRACE_TYPE_PARTIAL_LINE;
437 437
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index e4473367e7a4..930e51462dc8 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -294,7 +294,7 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
294 struct trace_uprobe *tu; 294 struct trace_uprobe *tu;
295 295
296 list_for_each_entry(tu, &uprobe_list, list) 296 list_for_each_entry(tu, &uprobe_list, list)
297 if (strcmp(tu->tp.call.name, event) == 0 && 297 if (strcmp(ftrace_event_name(&tu->tp.call), event) == 0 &&
298 strcmp(tu->tp.call.class->system, group) == 0) 298 strcmp(tu->tp.call.class->system, group) == 0)
299 return tu; 299 return tu;
300 300
@@ -324,7 +324,8 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
324 mutex_lock(&uprobe_lock); 324 mutex_lock(&uprobe_lock);
325 325
326 /* register as an event */ 326 /* register as an event */
327 old_tu = find_probe_event(tu->tp.call.name, tu->tp.call.class->system); 327 old_tu = find_probe_event(ftrace_event_name(&tu->tp.call),
328 tu->tp.call.class->system);
328 if (old_tu) { 329 if (old_tu) {
329 /* delete old event */ 330 /* delete old event */
330 ret = unregister_trace_uprobe(old_tu); 331 ret = unregister_trace_uprobe(old_tu);
@@ -599,7 +600,8 @@ static int probes_seq_show(struct seq_file *m, void *v)
599 char c = is_ret_probe(tu) ? 'r' : 'p'; 600 char c = is_ret_probe(tu) ? 'r' : 'p';
600 int i; 601 int i;
601 602
602 seq_printf(m, "%c:%s/%s", c, tu->tp.call.class->system, tu->tp.call.name); 603 seq_printf(m, "%c:%s/%s", c, tu->tp.call.class->system,
604 ftrace_event_name(&tu->tp.call));
603 seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset); 605 seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset);
604 606
605 for (i = 0; i < tu->tp.nr_args; i++) 607 for (i = 0; i < tu->tp.nr_args; i++)
@@ -649,7 +651,8 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)
649{ 651{
650 struct trace_uprobe *tu = v; 652 struct trace_uprobe *tu = v;
651 653
652 seq_printf(m, " %s %-44s %15lu\n", tu->filename, tu->tp.call.name, tu->nhit); 654 seq_printf(m, " %s %-44s %15lu\n", tu->filename,
655 ftrace_event_name(&tu->tp.call), tu->nhit);
653 return 0; 656 return 0;
654} 657}
655 658
@@ -844,12 +847,14 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e
844 tu = container_of(event, struct trace_uprobe, tp.call.event); 847 tu = container_of(event, struct trace_uprobe, tp.call.event);
845 848
846 if (is_ret_probe(tu)) { 849 if (is_ret_probe(tu)) {
847 if (!trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", tu->tp.call.name, 850 if (!trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)",
851 ftrace_event_name(&tu->tp.call),
848 entry->vaddr[1], entry->vaddr[0])) 852 entry->vaddr[1], entry->vaddr[0]))
849 goto partial; 853 goto partial;
850 data = DATAOF_TRACE_ENTRY(entry, true); 854 data = DATAOF_TRACE_ENTRY(entry, true);
851 } else { 855 } else {
852 if (!trace_seq_printf(s, "%s: (0x%lx)", tu->tp.call.name, 856 if (!trace_seq_printf(s, "%s: (0x%lx)",
857 ftrace_event_name(&tu->tp.call),
853 entry->vaddr[0])) 858 entry->vaddr[0]))
854 goto partial; 859 goto partial;
855 data = DATAOF_TRACE_ENTRY(entry, false); 860 data = DATAOF_TRACE_ENTRY(entry, false);
@@ -1275,7 +1280,8 @@ static int register_uprobe_event(struct trace_uprobe *tu)
1275 ret = trace_add_event_call(call); 1280 ret = trace_add_event_call(call);
1276 1281
1277 if (ret) { 1282 if (ret) {
1278 pr_info("Failed to register uprobe event: %s\n", call->name); 1283 pr_info("Failed to register uprobe event: %s\n",
1284 ftrace_event_name(call));
1279 kfree(call->print_fmt); 1285 kfree(call->print_fmt);
1280 unregister_ftrace_event(&call->event); 1286 unregister_ftrace_event(&call->event);
1281 } 1287 }
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index fb0a38a26555..ac5b23cf7212 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2008 Mathieu Desnoyers 2 * Copyright (C) 2008-2014 Mathieu Desnoyers
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -33,39 +33,27 @@ extern struct tracepoint * const __stop___tracepoints_ptrs[];
33/* Set to 1 to enable tracepoint debug output */ 33/* Set to 1 to enable tracepoint debug output */
34static const int tracepoint_debug; 34static const int tracepoint_debug;
35 35
36#ifdef CONFIG_MODULES
36/* 37/*
37 * Tracepoints mutex protects the builtin and module tracepoints and the hash 38 * Tracepoint module list mutex protects the local module list.
38 * table, as well as the local module list.
39 */ 39 */
40static DEFINE_MUTEX(tracepoints_mutex); 40static DEFINE_MUTEX(tracepoint_module_list_mutex);
41 41
42#ifdef CONFIG_MODULES 42/* Local list of struct tp_module */
43/* Local list of struct module */
44static LIST_HEAD(tracepoint_module_list); 43static LIST_HEAD(tracepoint_module_list);
45#endif /* CONFIG_MODULES */ 44#endif /* CONFIG_MODULES */
46 45
47/* 46/*
48 * Tracepoint hash table, containing the active tracepoints. 47 * tracepoints_mutex protects the builtin and module tracepoints.
49 * Protected by tracepoints_mutex. 48 * tracepoints_mutex nests inside tracepoint_module_list_mutex.
50 */ 49 */
51#define TRACEPOINT_HASH_BITS 6 50static DEFINE_MUTEX(tracepoints_mutex);
52#define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS)
53static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
54 51
55/* 52/*
56 * Note about RCU : 53 * Note about RCU :
57 * It is used to delay the free of multiple probes array until a quiescent 54 * It is used to delay the free of multiple probes array until a quiescent
58 * state is reached. 55 * state is reached.
59 * Tracepoint entries modifications are protected by the tracepoints_mutex.
60 */ 56 */
61struct tracepoint_entry {
62 struct hlist_node hlist;
63 struct tracepoint_func *funcs;
64 int refcount; /* Number of times armed. 0 if disarmed. */
65 int enabled; /* Tracepoint enabled */
66 char name[0];
67};
68
69struct tp_probes { 57struct tp_probes {
70 struct rcu_head rcu; 58 struct rcu_head rcu;
71 struct tracepoint_func probes[0]; 59 struct tracepoint_func probes[0];
@@ -92,34 +80,33 @@ static inline void release_probes(struct tracepoint_func *old)
92 } 80 }
93} 81}
94 82
95static void debug_print_probes(struct tracepoint_entry *entry) 83static void debug_print_probes(struct tracepoint_func *funcs)
96{ 84{
97 int i; 85 int i;
98 86
99 if (!tracepoint_debug || !entry->funcs) 87 if (!tracepoint_debug || !funcs)
100 return; 88 return;
101 89
102 for (i = 0; entry->funcs[i].func; i++) 90 for (i = 0; funcs[i].func; i++)
103 printk(KERN_DEBUG "Probe %d : %p\n", i, entry->funcs[i].func); 91 printk(KERN_DEBUG "Probe %d : %p\n", i, funcs[i].func);
104} 92}
105 93
106static struct tracepoint_func * 94static struct tracepoint_func *func_add(struct tracepoint_func **funcs,
107tracepoint_entry_add_probe(struct tracepoint_entry *entry, 95 struct tracepoint_func *tp_func)
108 void *probe, void *data)
109{ 96{
110 int nr_probes = 0; 97 int nr_probes = 0;
111 struct tracepoint_func *old, *new; 98 struct tracepoint_func *old, *new;
112 99
113 if (WARN_ON(!probe)) 100 if (WARN_ON(!tp_func->func))
114 return ERR_PTR(-EINVAL); 101 return ERR_PTR(-EINVAL);
115 102
116 debug_print_probes(entry); 103 debug_print_probes(*funcs);
117 old = entry->funcs; 104 old = *funcs;
118 if (old) { 105 if (old) {
119 /* (N -> N+1), (N != 0, 1) probes */ 106 /* (N -> N+1), (N != 0, 1) probes */
120 for (nr_probes = 0; old[nr_probes].func; nr_probes++) 107 for (nr_probes = 0; old[nr_probes].func; nr_probes++)
121 if (old[nr_probes].func == probe && 108 if (old[nr_probes].func == tp_func->func &&
122 old[nr_probes].data == data) 109 old[nr_probes].data == tp_func->data)
123 return ERR_PTR(-EEXIST); 110 return ERR_PTR(-EEXIST);
124 } 111 }
125 /* + 2 : one for new probe, one for NULL func */ 112 /* + 2 : one for new probe, one for NULL func */
@@ -128,33 +115,30 @@ tracepoint_entry_add_probe(struct tracepoint_entry *entry,
128 return ERR_PTR(-ENOMEM); 115 return ERR_PTR(-ENOMEM);
129 if (old) 116 if (old)
130 memcpy(new, old, nr_probes * sizeof(struct tracepoint_func)); 117 memcpy(new, old, nr_probes * sizeof(struct tracepoint_func));
131 new[nr_probes].func = probe; 118 new[nr_probes] = *tp_func;
132 new[nr_probes].data = data;
133 new[nr_probes + 1].func = NULL; 119 new[nr_probes + 1].func = NULL;
134 entry->refcount = nr_probes + 1; 120 *funcs = new;
135 entry->funcs = new; 121 debug_print_probes(*funcs);
136 debug_print_probes(entry);
137 return old; 122 return old;
138} 123}
139 124
140static void * 125static void *func_remove(struct tracepoint_func **funcs,
141tracepoint_entry_remove_probe(struct tracepoint_entry *entry, 126 struct tracepoint_func *tp_func)
142 void *probe, void *data)
143{ 127{
144 int nr_probes = 0, nr_del = 0, i; 128 int nr_probes = 0, nr_del = 0, i;
145 struct tracepoint_func *old, *new; 129 struct tracepoint_func *old, *new;
146 130
147 old = entry->funcs; 131 old = *funcs;
148 132
149 if (!old) 133 if (!old)
150 return ERR_PTR(-ENOENT); 134 return ERR_PTR(-ENOENT);
151 135
152 debug_print_probes(entry); 136 debug_print_probes(*funcs);
153 /* (N -> M), (N > 1, M >= 0) probes */ 137 /* (N -> M), (N > 1, M >= 0) probes */
154 if (probe) { 138 if (tp_func->func) {
155 for (nr_probes = 0; old[nr_probes].func; nr_probes++) { 139 for (nr_probes = 0; old[nr_probes].func; nr_probes++) {
156 if (old[nr_probes].func == probe && 140 if (old[nr_probes].func == tp_func->func &&
157 old[nr_probes].data == data) 141 old[nr_probes].data == tp_func->data)
158 nr_del++; 142 nr_del++;
159 } 143 }
160 } 144 }
@@ -165,9 +149,8 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry,
165 */ 149 */
166 if (nr_probes - nr_del == 0) { 150 if (nr_probes - nr_del == 0) {
167 /* N -> 0, (N > 1) */ 151 /* N -> 0, (N > 1) */
168 entry->funcs = NULL; 152 *funcs = NULL;
169 entry->refcount = 0; 153 debug_print_probes(*funcs);
170 debug_print_probes(entry);
171 return old; 154 return old;
172 } else { 155 } else {
173 int j = 0; 156 int j = 0;
@@ -177,91 +160,35 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry,
177 if (new == NULL) 160 if (new == NULL)
178 return ERR_PTR(-ENOMEM); 161 return ERR_PTR(-ENOMEM);
179 for (i = 0; old[i].func; i++) 162 for (i = 0; old[i].func; i++)
180 if (old[i].func != probe || old[i].data != data) 163 if (old[i].func != tp_func->func
164 || old[i].data != tp_func->data)
181 new[j++] = old[i]; 165 new[j++] = old[i];
182 new[nr_probes - nr_del].func = NULL; 166 new[nr_probes - nr_del].func = NULL;
183 entry->refcount = nr_probes - nr_del; 167 *funcs = new;
184 entry->funcs = new;
185 } 168 }
186 debug_print_probes(entry); 169 debug_print_probes(*funcs);
187 return old; 170 return old;
188} 171}
189 172
190/* 173/*
191 * Get tracepoint if the tracepoint is present in the tracepoint hash table. 174 * Add the probe function to a tracepoint.
192 * Must be called with tracepoints_mutex held.
193 * Returns NULL if not present.
194 */ 175 */
195static struct tracepoint_entry *get_tracepoint(const char *name) 176static int tracepoint_add_func(struct tracepoint *tp,
177 struct tracepoint_func *func)
196{ 178{
197 struct hlist_head *head; 179 struct tracepoint_func *old, *tp_funcs;
198 struct tracepoint_entry *e;
199 u32 hash = jhash(name, strlen(name), 0);
200
201 head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
202 hlist_for_each_entry(e, head, hlist) {
203 if (!strcmp(name, e->name))
204 return e;
205 }
206 return NULL;
207}
208 180
209/* 181 if (tp->regfunc && !static_key_enabled(&tp->key))
210 * Add the tracepoint to the tracepoint hash table. Must be called with 182 tp->regfunc();
211 * tracepoints_mutex held.
212 */
213static struct tracepoint_entry *add_tracepoint(const char *name)
214{
215 struct hlist_head *head;
216 struct tracepoint_entry *e;
217 size_t name_len = strlen(name) + 1;
218 u32 hash = jhash(name, name_len-1, 0);
219
220 head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
221 hlist_for_each_entry(e, head, hlist) {
222 if (!strcmp(name, e->name)) {
223 printk(KERN_NOTICE
224 "tracepoint %s busy\n", name);
225 return ERR_PTR(-EEXIST); /* Already there */
226 }
227 }
228 /*
229 * Using kmalloc here to allocate a variable length element. Could
230 * cause some memory fragmentation if overused.
231 */
232 e = kmalloc(sizeof(struct tracepoint_entry) + name_len, GFP_KERNEL);
233 if (!e)
234 return ERR_PTR(-ENOMEM);
235 memcpy(&e->name[0], name, name_len);
236 e->funcs = NULL;
237 e->refcount = 0;
238 e->enabled = 0;
239 hlist_add_head(&e->hlist, head);
240 return e;
241}
242 183
243/* 184 tp_funcs = rcu_dereference_protected(tp->funcs,
244 * Remove the tracepoint from the tracepoint hash table. Must be called with 185 lockdep_is_held(&tracepoints_mutex));
245 * mutex_lock held. 186 old = func_add(&tp_funcs, func);
246 */ 187 if (IS_ERR(old)) {
247static inline void remove_tracepoint(struct tracepoint_entry *e) 188 WARN_ON_ONCE(1);
248{ 189 return PTR_ERR(old);
249 hlist_del(&e->hlist); 190 }
250 kfree(e); 191 release_probes(old);
251}
252
253/*
254 * Sets the probe callback corresponding to one tracepoint.
255 */
256static void set_tracepoint(struct tracepoint_entry **entry,
257 struct tracepoint *elem, int active)
258{
259 WARN_ON(strcmp((*entry)->name, elem->name) != 0);
260
261 if (elem->regfunc && !static_key_enabled(&elem->key) && active)
262 elem->regfunc();
263 else if (elem->unregfunc && static_key_enabled(&elem->key) && !active)
264 elem->unregfunc();
265 192
266 /* 193 /*
267 * rcu_assign_pointer has a smp_wmb() which makes sure that the new 194 * rcu_assign_pointer has a smp_wmb() which makes sure that the new
@@ -270,193 +197,90 @@ static void set_tracepoint(struct tracepoint_entry **entry,
270 * include/linux/tracepoints.h. A matching smp_read_barrier_depends() 197 * include/linux/tracepoints.h. A matching smp_read_barrier_depends()
271 * is used. 198 * is used.
272 */ 199 */
273 rcu_assign_pointer(elem->funcs, (*entry)->funcs); 200 rcu_assign_pointer(tp->funcs, tp_funcs);
274 if (active && !static_key_enabled(&elem->key)) 201 if (!static_key_enabled(&tp->key))
275 static_key_slow_inc(&elem->key); 202 static_key_slow_inc(&tp->key);
276 else if (!active && static_key_enabled(&elem->key)) 203 return 0;
277 static_key_slow_dec(&elem->key);
278} 204}
279 205
280/* 206/*
281 * Disable a tracepoint and its probe callback. 207 * Remove a probe function from a tracepoint.
282 * Note: only waiting an RCU period after setting elem->call to the empty 208 * Note: only waiting an RCU period after setting elem->call to the empty
283 * function insures that the original callback is not used anymore. This insured 209 * function insures that the original callback is not used anymore. This insured
284 * by preempt_disable around the call site. 210 * by preempt_disable around the call site.
285 */ 211 */
286static void disable_tracepoint(struct tracepoint *elem) 212static int tracepoint_remove_func(struct tracepoint *tp,
213 struct tracepoint_func *func)
287{ 214{
288 if (elem->unregfunc && static_key_enabled(&elem->key)) 215 struct tracepoint_func *old, *tp_funcs;
289 elem->unregfunc();
290
291 if (static_key_enabled(&elem->key))
292 static_key_slow_dec(&elem->key);
293 rcu_assign_pointer(elem->funcs, NULL);
294}
295 216
296/** 217 tp_funcs = rcu_dereference_protected(tp->funcs,
297 * tracepoint_update_probe_range - Update a probe range 218 lockdep_is_held(&tracepoints_mutex));
298 * @begin: beginning of the range 219 old = func_remove(&tp_funcs, func);
299 * @end: end of the range 220 if (IS_ERR(old)) {
300 * 221 WARN_ON_ONCE(1);
301 * Updates the probe callback corresponding to a range of tracepoints. 222 return PTR_ERR(old);
302 * Called with tracepoints_mutex held.
303 */
304static void tracepoint_update_probe_range(struct tracepoint * const *begin,
305 struct tracepoint * const *end)
306{
307 struct tracepoint * const *iter;
308 struct tracepoint_entry *mark_entry;
309
310 if (!begin)
311 return;
312
313 for (iter = begin; iter < end; iter++) {
314 mark_entry = get_tracepoint((*iter)->name);
315 if (mark_entry) {
316 set_tracepoint(&mark_entry, *iter,
317 !!mark_entry->refcount);
318 mark_entry->enabled = !!mark_entry->refcount;
319 } else {
320 disable_tracepoint(*iter);
321 }
322 } 223 }
323} 224 release_probes(old);
324
325#ifdef CONFIG_MODULES
326void module_update_tracepoints(void)
327{
328 struct tp_module *tp_mod;
329
330 list_for_each_entry(tp_mod, &tracepoint_module_list, list)
331 tracepoint_update_probe_range(tp_mod->tracepoints_ptrs,
332 tp_mod->tracepoints_ptrs + tp_mod->num_tracepoints);
333}
334#else /* CONFIG_MODULES */
335void module_update_tracepoints(void)
336{
337}
338#endif /* CONFIG_MODULES */
339 225
226 if (!tp_funcs) {
227 /* Removed last function */
228 if (tp->unregfunc && static_key_enabled(&tp->key))
229 tp->unregfunc();
340 230
341/* 231 if (static_key_enabled(&tp->key))
342 * Update probes, removing the faulty probes. 232 static_key_slow_dec(&tp->key);
343 * Called with tracepoints_mutex held.
344 */
345static void tracepoint_update_probes(void)
346{
347 /* Core kernel tracepoints */
348 tracepoint_update_probe_range(__start___tracepoints_ptrs,
349 __stop___tracepoints_ptrs);
350 /* tracepoints in modules. */
351 module_update_tracepoints();
352}
353
354static struct tracepoint_func *
355tracepoint_add_probe(const char *name, void *probe, void *data)
356{
357 struct tracepoint_entry *entry;
358 struct tracepoint_func *old;
359
360 entry = get_tracepoint(name);
361 if (!entry) {
362 entry = add_tracepoint(name);
363 if (IS_ERR(entry))
364 return (struct tracepoint_func *)entry;
365 } 233 }
366 old = tracepoint_entry_add_probe(entry, probe, data); 234 rcu_assign_pointer(tp->funcs, tp_funcs);
367 if (IS_ERR(old) && !entry->refcount) 235 return 0;
368 remove_tracepoint(entry);
369 return old;
370} 236}
371 237
372/** 238/**
373 * tracepoint_probe_register - Connect a probe to a tracepoint 239 * tracepoint_probe_register - Connect a probe to a tracepoint
374 * @name: tracepoint name 240 * @tp: tracepoint
375 * @probe: probe handler 241 * @probe: probe handler
376 * @data: probe private data
377 *
378 * Returns:
379 * - 0 if the probe was successfully registered, and tracepoint
380 * callsites are currently loaded for that probe,
381 * - -ENODEV if the probe was successfully registered, but no tracepoint
382 * callsite is currently loaded for that probe,
383 * - other negative error value on error.
384 *
385 * When tracepoint_probe_register() returns either 0 or -ENODEV,
386 * parameters @name, @probe, and @data may be used by the tracepoint
387 * infrastructure until the probe is unregistered.
388 * 242 *
389 * The probe address must at least be aligned on the architecture pointer size. 243 * Returns 0 if ok, error value on error.
244 * Note: if @tp is within a module, the caller is responsible for
245 * unregistering the probe before the module is gone. This can be
246 * performed either with a tracepoint module going notifier, or from
247 * within module exit functions.
390 */ 248 */
391int tracepoint_probe_register(const char *name, void *probe, void *data) 249int tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data)
392{ 250{
393 struct tracepoint_func *old; 251 struct tracepoint_func tp_func;
394 struct tracepoint_entry *entry; 252 int ret;
395 int ret = 0;
396 253
397 mutex_lock(&tracepoints_mutex); 254 mutex_lock(&tracepoints_mutex);
398 old = tracepoint_add_probe(name, probe, data); 255 tp_func.func = probe;
399 if (IS_ERR(old)) { 256 tp_func.data = data;
400 mutex_unlock(&tracepoints_mutex); 257 ret = tracepoint_add_func(tp, &tp_func);
401 return PTR_ERR(old);
402 }
403 tracepoint_update_probes(); /* may update entry */
404 entry = get_tracepoint(name);
405 /* Make sure the entry was enabled */
406 if (!entry || !entry->enabled)
407 ret = -ENODEV;
408 mutex_unlock(&tracepoints_mutex); 258 mutex_unlock(&tracepoints_mutex);
409 release_probes(old);
410 return ret; 259 return ret;
411} 260}
412EXPORT_SYMBOL_GPL(tracepoint_probe_register); 261EXPORT_SYMBOL_GPL(tracepoint_probe_register);
413 262
414static struct tracepoint_func *
415tracepoint_remove_probe(const char *name, void *probe, void *data)
416{
417 struct tracepoint_entry *entry;
418 struct tracepoint_func *old;
419
420 entry = get_tracepoint(name);
421 if (!entry)
422 return ERR_PTR(-ENOENT);
423 old = tracepoint_entry_remove_probe(entry, probe, data);
424 if (IS_ERR(old))
425 return old;
426 if (!entry->refcount)
427 remove_tracepoint(entry);
428 return old;
429}
430
431/** 263/**
432 * tracepoint_probe_unregister - Disconnect a probe from a tracepoint 264 * tracepoint_probe_unregister - Disconnect a probe from a tracepoint
433 * @name: tracepoint name 265 * @tp: tracepoint
434 * @probe: probe function pointer 266 * @probe: probe function pointer
435 * @data: probe private data
436 * 267 *
437 * We do not need to call a synchronize_sched to make sure the probes have 268 * Returns 0 if ok, error value on error.
438 * finished running before doing a module unload, because the module unload
439 * itself uses stop_machine(), which insures that every preempt disabled section
440 * have finished.
441 */ 269 */
442int tracepoint_probe_unregister(const char *name, void *probe, void *data) 270int tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data)
443{ 271{
444 struct tracepoint_func *old; 272 struct tracepoint_func tp_func;
273 int ret;
445 274
446 mutex_lock(&tracepoints_mutex); 275 mutex_lock(&tracepoints_mutex);
447 old = tracepoint_remove_probe(name, probe, data); 276 tp_func.func = probe;
448 if (IS_ERR(old)) { 277 tp_func.data = data;
449 mutex_unlock(&tracepoints_mutex); 278 ret = tracepoint_remove_func(tp, &tp_func);
450 return PTR_ERR(old);
451 }
452 tracepoint_update_probes(); /* may update entry */
453 mutex_unlock(&tracepoints_mutex); 279 mutex_unlock(&tracepoints_mutex);
454 release_probes(old); 280 return ret;
455 return 0;
456} 281}
457EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); 282EXPORT_SYMBOL_GPL(tracepoint_probe_unregister);
458 283
459
460#ifdef CONFIG_MODULES 284#ifdef CONFIG_MODULES
461bool trace_module_has_bad_taint(struct module *mod) 285bool trace_module_has_bad_taint(struct module *mod)
462{ 286{
@@ -464,6 +288,74 @@ bool trace_module_has_bad_taint(struct module *mod)
464 (1 << TAINT_UNSIGNED_MODULE)); 288 (1 << TAINT_UNSIGNED_MODULE));
465} 289}
466 290
291static BLOCKING_NOTIFIER_HEAD(tracepoint_notify_list);
292
293/**
294 * register_tracepoint_notifier - register tracepoint coming/going notifier
295 * @nb: notifier block
296 *
297 * Notifiers registered with this function are called on module
298 * coming/going with the tracepoint_module_list_mutex held.
299 * The notifier block callback should expect a "struct tp_module" data
300 * pointer.
301 */
302int register_tracepoint_module_notifier(struct notifier_block *nb)
303{
304 struct tp_module *tp_mod;
305 int ret;
306
307 mutex_lock(&tracepoint_module_list_mutex);
308 ret = blocking_notifier_chain_register(&tracepoint_notify_list, nb);
309 if (ret)
310 goto end;
311 list_for_each_entry(tp_mod, &tracepoint_module_list, list)
312 (void) nb->notifier_call(nb, MODULE_STATE_COMING, tp_mod);
313end:
314 mutex_unlock(&tracepoint_module_list_mutex);
315 return ret;
316}
317EXPORT_SYMBOL_GPL(register_tracepoint_module_notifier);
318
319/**
320 * unregister_tracepoint_notifier - unregister tracepoint coming/going notifier
321 * @nb: notifier block
322 *
323 * The notifier block callback should expect a "struct tp_module" data
324 * pointer.
325 */
326int unregister_tracepoint_module_notifier(struct notifier_block *nb)
327{
328 struct tp_module *tp_mod;
329 int ret;
330
331 mutex_lock(&tracepoint_module_list_mutex);
332 ret = blocking_notifier_chain_unregister(&tracepoint_notify_list, nb);
333 if (ret)
334 goto end;
335 list_for_each_entry(tp_mod, &tracepoint_module_list, list)
336 (void) nb->notifier_call(nb, MODULE_STATE_GOING, tp_mod);
337end:
338 mutex_unlock(&tracepoint_module_list_mutex);
339 return ret;
340
341}
342EXPORT_SYMBOL_GPL(unregister_tracepoint_module_notifier);
343
344/*
345 * Ensure the tracer unregistered the module's probes before the module
346 * teardown is performed. Prevents leaks of probe and data pointers.
347 */
348static void tp_module_going_check_quiescent(struct tracepoint * const *begin,
349 struct tracepoint * const *end)
350{
351 struct tracepoint * const *iter;
352
353 if (!begin)
354 return;
355 for (iter = begin; iter < end; iter++)
356 WARN_ON_ONCE((*iter)->funcs);
357}
358
467static int tracepoint_module_coming(struct module *mod) 359static int tracepoint_module_coming(struct module *mod)
468{ 360{
469 struct tp_module *tp_mod; 361 struct tp_module *tp_mod;
@@ -479,36 +371,41 @@ static int tracepoint_module_coming(struct module *mod)
479 */ 371 */
480 if (trace_module_has_bad_taint(mod)) 372 if (trace_module_has_bad_taint(mod))
481 return 0; 373 return 0;
482 mutex_lock(&tracepoints_mutex); 374 mutex_lock(&tracepoint_module_list_mutex);
483 tp_mod = kmalloc(sizeof(struct tp_module), GFP_KERNEL); 375 tp_mod = kmalloc(sizeof(struct tp_module), GFP_KERNEL);
484 if (!tp_mod) { 376 if (!tp_mod) {
485 ret = -ENOMEM; 377 ret = -ENOMEM;
486 goto end; 378 goto end;
487 } 379 }
488 tp_mod->num_tracepoints = mod->num_tracepoints; 380 tp_mod->mod = mod;
489 tp_mod->tracepoints_ptrs = mod->tracepoints_ptrs;
490 list_add_tail(&tp_mod->list, &tracepoint_module_list); 381 list_add_tail(&tp_mod->list, &tracepoint_module_list);
491 tracepoint_update_probe_range(mod->tracepoints_ptrs, 382 blocking_notifier_call_chain(&tracepoint_notify_list,
492 mod->tracepoints_ptrs + mod->num_tracepoints); 383 MODULE_STATE_COMING, tp_mod);
493end: 384end:
494 mutex_unlock(&tracepoints_mutex); 385 mutex_unlock(&tracepoint_module_list_mutex);
495 return ret; 386 return ret;
496} 387}
497 388
498static int tracepoint_module_going(struct module *mod) 389static void tracepoint_module_going(struct module *mod)
499{ 390{
500 struct tp_module *pos; 391 struct tp_module *tp_mod;
501 392
502 if (!mod->num_tracepoints) 393 if (!mod->num_tracepoints)
503 return 0; 394 return;
504 395
505 mutex_lock(&tracepoints_mutex); 396 mutex_lock(&tracepoint_module_list_mutex);
506 tracepoint_update_probe_range(mod->tracepoints_ptrs, 397 list_for_each_entry(tp_mod, &tracepoint_module_list, list) {
507 mod->tracepoints_ptrs + mod->num_tracepoints); 398 if (tp_mod->mod == mod) {
508 list_for_each_entry(pos, &tracepoint_module_list, list) { 399 blocking_notifier_call_chain(&tracepoint_notify_list,
509 if (pos->tracepoints_ptrs == mod->tracepoints_ptrs) { 400 MODULE_STATE_GOING, tp_mod);
510 list_del(&pos->list); 401 list_del(&tp_mod->list);
511 kfree(pos); 402 kfree(tp_mod);
403 /*
404 * Called the going notifier before checking for
405 * quiescence.
406 */
407 tp_module_going_check_quiescent(mod->tracepoints_ptrs,
408 mod->tracepoints_ptrs + mod->num_tracepoints);
512 break; 409 break;
513 } 410 }
514 } 411 }
@@ -518,12 +415,11 @@ static int tracepoint_module_going(struct module *mod)
518 * flag on "going", in case a module taints the kernel only after being 415 * flag on "going", in case a module taints the kernel only after being
519 * loaded. 416 * loaded.
520 */ 417 */
521 mutex_unlock(&tracepoints_mutex); 418 mutex_unlock(&tracepoint_module_list_mutex);
522 return 0;
523} 419}
524 420
525int tracepoint_module_notify(struct notifier_block *self, 421static int tracepoint_module_notify(struct notifier_block *self,
526 unsigned long val, void *data) 422 unsigned long val, void *data)
527{ 423{
528 struct module *mod = data; 424 struct module *mod = data;
529 int ret = 0; 425 int ret = 0;
@@ -535,24 +431,58 @@ int tracepoint_module_notify(struct notifier_block *self,
535 case MODULE_STATE_LIVE: 431 case MODULE_STATE_LIVE:
536 break; 432 break;
537 case MODULE_STATE_GOING: 433 case MODULE_STATE_GOING:
538 ret = tracepoint_module_going(mod); 434 tracepoint_module_going(mod);
435 break;
436 case MODULE_STATE_UNFORMED:
539 break; 437 break;
540 } 438 }
541 return ret; 439 return ret;
542} 440}
543 441
544struct notifier_block tracepoint_module_nb = { 442static struct notifier_block tracepoint_module_nb = {
545 .notifier_call = tracepoint_module_notify, 443 .notifier_call = tracepoint_module_notify,
546 .priority = 0, 444 .priority = 0,
547}; 445};
548 446
549static int init_tracepoints(void) 447static __init int init_tracepoints(void)
550{ 448{
551 return register_module_notifier(&tracepoint_module_nb); 449 int ret;
450
451 ret = register_module_notifier(&tracepoint_module_nb);
452 if (ret)
453 pr_warning("Failed to register tracepoint module enter notifier\n");
454
455 return ret;
552} 456}
553__initcall(init_tracepoints); 457__initcall(init_tracepoints);
554#endif /* CONFIG_MODULES */ 458#endif /* CONFIG_MODULES */
555 459
460static void for_each_tracepoint_range(struct tracepoint * const *begin,
461 struct tracepoint * const *end,
462 void (*fct)(struct tracepoint *tp, void *priv),
463 void *priv)
464{
465 struct tracepoint * const *iter;
466
467 if (!begin)
468 return;
469 for (iter = begin; iter < end; iter++)
470 fct(*iter, priv);
471}
472
473/**
474 * for_each_kernel_tracepoint - iteration on all kernel tracepoints
475 * @fct: callback
476 * @priv: private data
477 */
478void for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
479 void *priv)
480{
481 for_each_tracepoint_range(__start___tracepoints_ptrs,
482 __stop___tracepoints_ptrs, fct, priv);
483}
484EXPORT_SYMBOL_GPL(for_each_kernel_tracepoint);
485
556#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS 486#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
557 487
558/* NB: reg/unreg are called while guarded with the tracepoints_mutex */ 488/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
diff --git a/lib/Kconfig b/lib/Kconfig
index 5d4984c505f8..4771fb3f4da4 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -182,6 +182,15 @@ config AUDIT_GENERIC
182 depends on AUDIT && !AUDIT_ARCH 182 depends on AUDIT && !AUDIT_ARCH
183 default y 183 default y
184 184
185config AUDIT_ARCH_COMPAT_GENERIC
186 bool
187 default n
188
189config AUDIT_COMPAT_GENERIC
190 bool
191 depends on AUDIT_GENERIC && AUDIT_ARCH_COMPAT_GENERIC && COMPAT
192 default y
193
185config RANDOM32_SELFTEST 194config RANDOM32_SELFTEST
186 bool "PRNG perform self test on init" 195 bool "PRNG perform self test on init"
187 default n 196 default n
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index dd7f8858188a..140b66a874c1 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1045,16 +1045,6 @@ config DEBUG_BUGVERBOSE
1045 of the BUG call as well as the EIP and oops trace. This aids 1045 of the BUG call as well as the EIP and oops trace. This aids
1046 debugging but costs about 70-100K of memory. 1046 debugging but costs about 70-100K of memory.
1047 1047
1048config DEBUG_WRITECOUNT
1049 bool "Debug filesystem writers count"
1050 depends on DEBUG_KERNEL
1051 help
1052 Enable this to catch wrong use of the writers count in struct
1053 vfsmount. This will increase the size of each file struct by
1054 32 bits.
1055
1056 If unsure, say N.
1057
1058config DEBUG_LIST 1048config DEBUG_LIST
1059 bool "Debug linked list manipulation" 1049 bool "Debug linked list manipulation"
1060 depends on DEBUG_KERNEL 1050 depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 48140e3ba73f..0cd7b68e1382 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o
96obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o 96obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
97obj-$(CONFIG_SMP) += percpu_counter.o 97obj-$(CONFIG_SMP) += percpu_counter.o
98obj-$(CONFIG_AUDIT_GENERIC) += audit.o 98obj-$(CONFIG_AUDIT_GENERIC) += audit.o
99obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o
99 100
100obj-$(CONFIG_SWIOTLB) += swiotlb.o 101obj-$(CONFIG_SWIOTLB) += swiotlb.o
101obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o 102obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
diff --git a/lib/audit.c b/lib/audit.c
index 76bbed4a20e5..1d726a22565b 100644
--- a/lib/audit.c
+++ b/lib/audit.c
@@ -30,11 +30,17 @@ static unsigned signal_class[] = {
30 30
31int audit_classify_arch(int arch) 31int audit_classify_arch(int arch)
32{ 32{
33 return 0; 33 if (audit_is_compat(arch))
34 return 1;
35 else
36 return 0;
34} 37}
35 38
36int audit_classify_syscall(int abi, unsigned syscall) 39int audit_classify_syscall(int abi, unsigned syscall)
37{ 40{
41 if (audit_is_compat(abi))
42 return audit_classify_compat_syscall(abi, syscall);
43
38 switch(syscall) { 44 switch(syscall) {
39#ifdef __NR_open 45#ifdef __NR_open
40 case __NR_open: 46 case __NR_open:
@@ -57,6 +63,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
57 63
58static int __init audit_classes_init(void) 64static int __init audit_classes_init(void)
59{ 65{
66#ifdef CONFIG_AUDIT_COMPAT_GENERIC
67 audit_register_class(AUDIT_CLASS_WRITE_32, compat_write_class);
68 audit_register_class(AUDIT_CLASS_READ_32, compat_read_class);
69 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, compat_dir_class);
70 audit_register_class(AUDIT_CLASS_CHATTR_32, compat_chattr_class);
71 audit_register_class(AUDIT_CLASS_SIGNAL_32, compat_signal_class);
72#endif
60 audit_register_class(AUDIT_CLASS_WRITE, write_class); 73 audit_register_class(AUDIT_CLASS_WRITE, write_class);
61 audit_register_class(AUDIT_CLASS_READ, read_class); 74 audit_register_class(AUDIT_CLASS_READ, read_class);
62 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 75 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
diff --git a/lib/compat_audit.c b/lib/compat_audit.c
new file mode 100644
index 000000000000..873f75b640ab
--- /dev/null
+++ b/lib/compat_audit.c
@@ -0,0 +1,50 @@
1#include <linux/init.h>
2#include <linux/types.h>
3#include <asm/unistd32.h>
4
5unsigned compat_dir_class[] = {
6#include <asm-generic/audit_dir_write.h>
7~0U
8};
9
10unsigned compat_read_class[] = {
11#include <asm-generic/audit_read.h>
12~0U
13};
14
15unsigned compat_write_class[] = {
16#include <asm-generic/audit_write.h>
17~0U
18};
19
20unsigned compat_chattr_class[] = {
21#include <asm-generic/audit_change_attr.h>
22~0U
23};
24
25unsigned compat_signal_class[] = {
26#include <asm-generic/audit_signal.h>
27~0U
28};
29
30int audit_classify_compat_syscall(int abi, unsigned syscall)
31{
32 switch (syscall) {
33#ifdef __NR_open
34 case __NR_open:
35 return 2;
36#endif
37#ifdef __NR_openat
38 case __NR_openat:
39 return 3;
40#endif
41#ifdef __NR_socketcall
42 case __NR_socketcall:
43 return 4;
44#endif
45 case __NR_execve:
46 return 5;
47 default:
48 return 1;
49 }
50}
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 8280a5dd1727..7dd33577b905 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -169,7 +169,7 @@ static int percpu_counter_hotcpu_callback(struct notifier_block *nb,
169 struct percpu_counter *fbc; 169 struct percpu_counter *fbc;
170 170
171 compute_batch_value(); 171 compute_batch_value();
172 if (action != CPU_DEAD) 172 if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
173 return NOTIFY_OK; 173 return NOTIFY_OK;
174 174
175 cpu = (unsigned long)hcpu; 175 cpu = (unsigned long)hcpu;
diff --git a/mm/Makefile b/mm/Makefile
index 9e5aaf92197d..b484452dac57 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -17,7 +17,8 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
17 util.o mmzone.o vmstat.o backing-dev.o \ 17 util.o mmzone.o vmstat.o backing-dev.o \
18 mm_init.o mmu_context.o percpu.o slab_common.o \ 18 mm_init.o mmu_context.o percpu.o slab_common.o \
19 compaction.o balloon_compaction.o vmacache.o \ 19 compaction.o balloon_compaction.o vmacache.o \
20 interval_tree.o list_lru.o workingset.o $(mmu-y) 20 interval_tree.o list_lru.o workingset.o \
21 iov_iter.o $(mmu-y)
21 22
22obj-y += init-mm.o 23obj-y += init-mm.o
23 24
diff --git a/mm/filemap.c b/mm/filemap.c
index 27ebc0c9571b..a82fbe4c9e8e 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -77,7 +77,7 @@
77 * ->mmap_sem 77 * ->mmap_sem
78 * ->lock_page (access_process_vm) 78 * ->lock_page (access_process_vm)
79 * 79 *
80 * ->i_mutex (generic_file_buffered_write) 80 * ->i_mutex (generic_perform_write)
81 * ->mmap_sem (fault_in_pages_readable->do_page_fault) 81 * ->mmap_sem (fault_in_pages_readable->do_page_fault)
82 * 82 *
83 * bdi->wb.list_lock 83 * bdi->wb.list_lock
@@ -1428,7 +1428,8 @@ static void shrink_readahead_size_eio(struct file *filp,
1428 * do_generic_file_read - generic file read routine 1428 * do_generic_file_read - generic file read routine
1429 * @filp: the file to read 1429 * @filp: the file to read
1430 * @ppos: current file position 1430 * @ppos: current file position
1431 * @desc: read_descriptor 1431 * @iter: data destination
1432 * @written: already copied
1432 * 1433 *
1433 * This is a generic file read routine, and uses the 1434 * This is a generic file read routine, and uses the
1434 * mapping->a_ops->readpage() function for the actual low-level stuff. 1435 * mapping->a_ops->readpage() function for the actual low-level stuff.
@@ -1436,8 +1437,8 @@ static void shrink_readahead_size_eio(struct file *filp,
1436 * This is really ugly. But the goto's actually try to clarify some 1437 * This is really ugly. But the goto's actually try to clarify some
1437 * of the logic when it comes to error handling etc. 1438 * of the logic when it comes to error handling etc.
1438 */ 1439 */
1439static void do_generic_file_read(struct file *filp, loff_t *ppos, 1440static ssize_t do_generic_file_read(struct file *filp, loff_t *ppos,
1440 read_descriptor_t *desc) 1441 struct iov_iter *iter, ssize_t written)
1441{ 1442{
1442 struct address_space *mapping = filp->f_mapping; 1443 struct address_space *mapping = filp->f_mapping;
1443 struct inode *inode = mapping->host; 1444 struct inode *inode = mapping->host;
@@ -1447,12 +1448,12 @@ static void do_generic_file_read(struct file *filp, loff_t *ppos,
1447 pgoff_t prev_index; 1448 pgoff_t prev_index;
1448 unsigned long offset; /* offset into pagecache page */ 1449 unsigned long offset; /* offset into pagecache page */
1449 unsigned int prev_offset; 1450 unsigned int prev_offset;
1450 int error; 1451 int error = 0;
1451 1452
1452 index = *ppos >> PAGE_CACHE_SHIFT; 1453 index = *ppos >> PAGE_CACHE_SHIFT;
1453 prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT; 1454 prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT;
1454 prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1); 1455 prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1);
1455 last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; 1456 last_index = (*ppos + iter->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
1456 offset = *ppos & ~PAGE_CACHE_MASK; 1457 offset = *ppos & ~PAGE_CACHE_MASK;
1457 1458
1458 for (;;) { 1459 for (;;) {
@@ -1487,7 +1488,7 @@ find_page:
1487 if (!page->mapping) 1488 if (!page->mapping)
1488 goto page_not_up_to_date_locked; 1489 goto page_not_up_to_date_locked;
1489 if (!mapping->a_ops->is_partially_uptodate(page, 1490 if (!mapping->a_ops->is_partially_uptodate(page,
1490 desc, offset)) 1491 offset, iter->count))
1491 goto page_not_up_to_date_locked; 1492 goto page_not_up_to_date_locked;
1492 unlock_page(page); 1493 unlock_page(page);
1493 } 1494 }
@@ -1537,24 +1538,23 @@ page_ok:
1537 /* 1538 /*
1538 * Ok, we have the page, and it's up-to-date, so 1539 * Ok, we have the page, and it's up-to-date, so
1539 * now we can copy it to user space... 1540 * now we can copy it to user space...
1540 *
1541 * The file_read_actor routine returns how many bytes were
1542 * actually used..
1543 * NOTE! This may not be the same as how much of a user buffer
1544 * we filled up (we may be padding etc), so we can only update
1545 * "pos" here (the actor routine has to update the user buffer
1546 * pointers and the remaining count).
1547 */ 1541 */
1548 ret = file_read_actor(desc, page, offset, nr); 1542
1543 ret = copy_page_to_iter(page, offset, nr, iter);
1549 offset += ret; 1544 offset += ret;
1550 index += offset >> PAGE_CACHE_SHIFT; 1545 index += offset >> PAGE_CACHE_SHIFT;
1551 offset &= ~PAGE_CACHE_MASK; 1546 offset &= ~PAGE_CACHE_MASK;
1552 prev_offset = offset; 1547 prev_offset = offset;
1553 1548
1554 page_cache_release(page); 1549 page_cache_release(page);
1555 if (ret == nr && desc->count) 1550 written += ret;
1556 continue; 1551 if (!iov_iter_count(iter))
1557 goto out; 1552 goto out;
1553 if (ret < nr) {
1554 error = -EFAULT;
1555 goto out;
1556 }
1557 continue;
1558 1558
1559page_not_up_to_date: 1559page_not_up_to_date:
1560 /* Get exclusive access to the page ... */ 1560 /* Get exclusive access to the page ... */
@@ -1589,6 +1589,7 @@ readpage:
1589 if (unlikely(error)) { 1589 if (unlikely(error)) {
1590 if (error == AOP_TRUNCATED_PAGE) { 1590 if (error == AOP_TRUNCATED_PAGE) {
1591 page_cache_release(page); 1591 page_cache_release(page);
1592 error = 0;
1592 goto find_page; 1593 goto find_page;
1593 } 1594 }
1594 goto readpage_error; 1595 goto readpage_error;
@@ -1619,7 +1620,6 @@ readpage:
1619 1620
1620readpage_error: 1621readpage_error:
1621 /* UHHUH! A synchronous read error occurred. Report it */ 1622 /* UHHUH! A synchronous read error occurred. Report it */
1622 desc->error = error;
1623 page_cache_release(page); 1623 page_cache_release(page);
1624 goto out; 1624 goto out;
1625 1625
@@ -1630,16 +1630,17 @@ no_cached_page:
1630 */ 1630 */
1631 page = page_cache_alloc_cold(mapping); 1631 page = page_cache_alloc_cold(mapping);
1632 if (!page) { 1632 if (!page) {
1633 desc->error = -ENOMEM; 1633 error = -ENOMEM;
1634 goto out; 1634 goto out;
1635 } 1635 }
1636 error = add_to_page_cache_lru(page, mapping, 1636 error = add_to_page_cache_lru(page, mapping,
1637 index, GFP_KERNEL); 1637 index, GFP_KERNEL);
1638 if (error) { 1638 if (error) {
1639 page_cache_release(page); 1639 page_cache_release(page);
1640 if (error == -EEXIST) 1640 if (error == -EEXIST) {
1641 error = 0;
1641 goto find_page; 1642 goto find_page;
1642 desc->error = error; 1643 }
1643 goto out; 1644 goto out;
1644 } 1645 }
1645 goto readpage; 1646 goto readpage;
@@ -1652,44 +1653,7 @@ out:
1652 1653
1653 *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset; 1654 *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
1654 file_accessed(filp); 1655 file_accessed(filp);
1655} 1656 return written ? written : error;
1656
1657int file_read_actor(read_descriptor_t *desc, struct page *page,
1658 unsigned long offset, unsigned long size)
1659{
1660 char *kaddr;
1661 unsigned long left, count = desc->count;
1662
1663 if (size > count)
1664 size = count;
1665
1666 /*
1667 * Faults on the destination of a read are common, so do it before
1668 * taking the kmap.
1669 */
1670 if (!fault_in_pages_writeable(desc->arg.buf, size)) {
1671 kaddr = kmap_atomic(page);
1672 left = __copy_to_user_inatomic(desc->arg.buf,
1673 kaddr + offset, size);
1674 kunmap_atomic(kaddr);
1675 if (left == 0)
1676 goto success;
1677 }
1678
1679 /* Do it the slow way */
1680 kaddr = kmap(page);
1681 left = __copy_to_user(desc->arg.buf, kaddr + offset, size);
1682 kunmap(page);
1683
1684 if (left) {
1685 size -= left;
1686 desc->error = -EFAULT;
1687 }
1688success:
1689 desc->count = count - size;
1690 desc->written += size;
1691 desc->arg.buf += size;
1692 return size;
1693} 1657}
1694 1658
1695/* 1659/*
@@ -1747,14 +1711,15 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
1747{ 1711{
1748 struct file *filp = iocb->ki_filp; 1712 struct file *filp = iocb->ki_filp;
1749 ssize_t retval; 1713 ssize_t retval;
1750 unsigned long seg = 0;
1751 size_t count; 1714 size_t count;
1752 loff_t *ppos = &iocb->ki_pos; 1715 loff_t *ppos = &iocb->ki_pos;
1716 struct iov_iter i;
1753 1717
1754 count = 0; 1718 count = 0;
1755 retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE); 1719 retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
1756 if (retval) 1720 if (retval)
1757 return retval; 1721 return retval;
1722 iov_iter_init(&i, iov, nr_segs, count, 0);
1758 1723
1759 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 1724 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
1760 if (filp->f_flags & O_DIRECT) { 1725 if (filp->f_flags & O_DIRECT) {
@@ -1776,6 +1741,11 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
1776 if (retval > 0) { 1741 if (retval > 0) {
1777 *ppos = pos + retval; 1742 *ppos = pos + retval;
1778 count -= retval; 1743 count -= retval;
1744 /*
1745 * If we did a short DIO read we need to skip the
1746 * section of the iov that we've already read data into.
1747 */
1748 iov_iter_advance(&i, retval);
1779 } 1749 }
1780 1750
1781 /* 1751 /*
@@ -1792,39 +1762,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
1792 } 1762 }
1793 } 1763 }
1794 1764
1795 count = retval; 1765 retval = do_generic_file_read(filp, ppos, &i, retval);
1796 for (seg = 0; seg < nr_segs; seg++) {
1797 read_descriptor_t desc;
1798 loff_t offset = 0;
1799
1800 /*
1801 * If we did a short DIO read we need to skip the section of the
1802 * iov that we've already read data into.
1803 */
1804 if (count) {
1805 if (count > iov[seg].iov_len) {
1806 count -= iov[seg].iov_len;
1807 continue;
1808 }
1809 offset = count;
1810 count = 0;
1811 }
1812
1813 desc.written = 0;
1814 desc.arg.buf = iov[seg].iov_base + offset;
1815 desc.count = iov[seg].iov_len - offset;
1816 if (desc.count == 0)
1817 continue;
1818 desc.error = 0;
1819 do_generic_file_read(filp, ppos, &desc);
1820 retval += desc.written;
1821 if (desc.error) {
1822 retval = retval ?: desc.error;
1823 break;
1824 }
1825 if (desc.count > 0)
1826 break;
1827 }
1828out: 1766out:
1829 return retval; 1767 return retval;
1830} 1768}
@@ -2335,150 +2273,6 @@ struct page *read_cache_page_gfp(struct address_space *mapping,
2335} 2273}
2336EXPORT_SYMBOL(read_cache_page_gfp); 2274EXPORT_SYMBOL(read_cache_page_gfp);
2337 2275
2338static size_t __iovec_copy_from_user_inatomic(char *vaddr,
2339 const struct iovec *iov, size_t base, size_t bytes)
2340{
2341 size_t copied = 0, left = 0;
2342
2343 while (bytes) {
2344 char __user *buf = iov->iov_base + base;
2345 int copy = min(bytes, iov->iov_len - base);
2346
2347 base = 0;
2348 left = __copy_from_user_inatomic(vaddr, buf, copy);
2349 copied += copy;
2350 bytes -= copy;
2351 vaddr += copy;
2352 iov++;
2353
2354 if (unlikely(left))
2355 break;
2356 }
2357 return copied - left;
2358}
2359
2360/*
2361 * Copy as much as we can into the page and return the number of bytes which
2362 * were successfully copied. If a fault is encountered then return the number of
2363 * bytes which were copied.
2364 */
2365size_t iov_iter_copy_from_user_atomic(struct page *page,
2366 struct iov_iter *i, unsigned long offset, size_t bytes)
2367{
2368 char *kaddr;
2369 size_t copied;
2370
2371 BUG_ON(!in_atomic());
2372 kaddr = kmap_atomic(page);
2373 if (likely(i->nr_segs == 1)) {
2374 int left;
2375 char __user *buf = i->iov->iov_base + i->iov_offset;
2376 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
2377 copied = bytes - left;
2378 } else {
2379 copied = __iovec_copy_from_user_inatomic(kaddr + offset,
2380 i->iov, i->iov_offset, bytes);
2381 }
2382 kunmap_atomic(kaddr);
2383
2384 return copied;
2385}
2386EXPORT_SYMBOL(iov_iter_copy_from_user_atomic);
2387
2388/*
2389 * This has the same sideeffects and return value as
2390 * iov_iter_copy_from_user_atomic().
2391 * The difference is that it attempts to resolve faults.
2392 * Page must not be locked.
2393 */
2394size_t iov_iter_copy_from_user(struct page *page,
2395 struct iov_iter *i, unsigned long offset, size_t bytes)
2396{
2397 char *kaddr;
2398 size_t copied;
2399
2400 kaddr = kmap(page);
2401 if (likely(i->nr_segs == 1)) {
2402 int left;
2403 char __user *buf = i->iov->iov_base + i->iov_offset;
2404 left = __copy_from_user(kaddr + offset, buf, bytes);
2405 copied = bytes - left;
2406 } else {
2407 copied = __iovec_copy_from_user_inatomic(kaddr + offset,
2408 i->iov, i->iov_offset, bytes);
2409 }
2410 kunmap(page);
2411 return copied;
2412}
2413EXPORT_SYMBOL(iov_iter_copy_from_user);
2414
2415void iov_iter_advance(struct iov_iter *i, size_t bytes)
2416{
2417 BUG_ON(i->count < bytes);
2418
2419 if (likely(i->nr_segs == 1)) {
2420 i->iov_offset += bytes;
2421 i->count -= bytes;
2422 } else {
2423 const struct iovec *iov = i->iov;
2424 size_t base = i->iov_offset;
2425 unsigned long nr_segs = i->nr_segs;
2426
2427 /*
2428 * The !iov->iov_len check ensures we skip over unlikely
2429 * zero-length segments (without overruning the iovec).
2430 */
2431 while (bytes || unlikely(i->count && !iov->iov_len)) {
2432 int copy;
2433
2434 copy = min(bytes, iov->iov_len - base);
2435 BUG_ON(!i->count || i->count < copy);
2436 i->count -= copy;
2437 bytes -= copy;
2438 base += copy;
2439 if (iov->iov_len == base) {
2440 iov++;
2441 nr_segs--;
2442 base = 0;
2443 }
2444 }
2445 i->iov = iov;
2446 i->iov_offset = base;
2447 i->nr_segs = nr_segs;
2448 }
2449}
2450EXPORT_SYMBOL(iov_iter_advance);
2451
2452/*
2453 * Fault in the first iovec of the given iov_iter, to a maximum length
2454 * of bytes. Returns 0 on success, or non-zero if the memory could not be
2455 * accessed (ie. because it is an invalid address).
2456 *
2457 * writev-intensive code may want this to prefault several iovecs -- that
2458 * would be possible (callers must not rely on the fact that _only_ the
2459 * first iovec will be faulted with the current implementation).
2460 */
2461int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
2462{
2463 char __user *buf = i->iov->iov_base + i->iov_offset;
2464 bytes = min(bytes, i->iov->iov_len - i->iov_offset);
2465 return fault_in_pages_readable(buf, bytes);
2466}
2467EXPORT_SYMBOL(iov_iter_fault_in_readable);
2468
2469/*
2470 * Return the count of just the current iov_iter segment.
2471 */
2472size_t iov_iter_single_seg_count(const struct iov_iter *i)
2473{
2474 const struct iovec *iov = i->iov;
2475 if (i->nr_segs == 1)
2476 return i->count;
2477 else
2478 return min(i->count, iov->iov_len - i->iov_offset);
2479}
2480EXPORT_SYMBOL(iov_iter_single_seg_count);
2481
2482/* 2276/*
2483 * Performs necessary checks before doing a write 2277 * Performs necessary checks before doing a write
2484 * 2278 *
@@ -2585,7 +2379,7 @@ EXPORT_SYMBOL(pagecache_write_end);
2585 2379
2586ssize_t 2380ssize_t
2587generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov, 2381generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
2588 unsigned long *nr_segs, loff_t pos, loff_t *ppos, 2382 unsigned long *nr_segs, loff_t pos,
2589 size_t count, size_t ocount) 2383 size_t count, size_t ocount)
2590{ 2384{
2591 struct file *file = iocb->ki_filp; 2385 struct file *file = iocb->ki_filp;
@@ -2646,7 +2440,7 @@ generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
2646 i_size_write(inode, pos); 2440 i_size_write(inode, pos);
2647 mark_inode_dirty(inode); 2441 mark_inode_dirty(inode);
2648 } 2442 }
2649 *ppos = pos; 2443 iocb->ki_pos = pos;
2650 } 2444 }
2651out: 2445out:
2652 return written; 2446 return written;
@@ -2692,7 +2486,7 @@ found:
2692} 2486}
2693EXPORT_SYMBOL(grab_cache_page_write_begin); 2487EXPORT_SYMBOL(grab_cache_page_write_begin);
2694 2488
2695static ssize_t generic_perform_write(struct file *file, 2489ssize_t generic_perform_write(struct file *file,
2696 struct iov_iter *i, loff_t pos) 2490 struct iov_iter *i, loff_t pos)
2697{ 2491{
2698 struct address_space *mapping = file->f_mapping; 2492 struct address_space *mapping = file->f_mapping;
@@ -2742,9 +2536,7 @@ again:
2742 if (mapping_writably_mapped(mapping)) 2536 if (mapping_writably_mapped(mapping))
2743 flush_dcache_page(page); 2537 flush_dcache_page(page);
2744 2538
2745 pagefault_disable();
2746 copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes); 2539 copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes);
2747 pagefault_enable();
2748 flush_dcache_page(page); 2540 flush_dcache_page(page);
2749 2541
2750 mark_page_accessed(page); 2542 mark_page_accessed(page);
@@ -2782,27 +2574,7 @@ again:
2782 2574
2783 return written ? written : status; 2575 return written ? written : status;
2784} 2576}
2785 2577EXPORT_SYMBOL(generic_perform_write);
2786ssize_t
2787generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2788 unsigned long nr_segs, loff_t pos, loff_t *ppos,
2789 size_t count, ssize_t written)
2790{
2791 struct file *file = iocb->ki_filp;
2792 ssize_t status;
2793 struct iov_iter i;
2794
2795 iov_iter_init(&i, iov, nr_segs, count, written);
2796 status = generic_perform_write(file, &i, pos);
2797
2798 if (likely(status >= 0)) {
2799 written += status;
2800 *ppos = pos + status;
2801 }
2802
2803 return written ? written : status;
2804}
2805EXPORT_SYMBOL(generic_file_buffered_write);
2806 2578
2807/** 2579/**
2808 * __generic_file_aio_write - write data to a file 2580 * __generic_file_aio_write - write data to a file
@@ -2824,16 +2596,18 @@ EXPORT_SYMBOL(generic_file_buffered_write);
2824 * avoid syncing under i_mutex. 2596 * avoid syncing under i_mutex.
2825 */ 2597 */
2826ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 2598ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2827 unsigned long nr_segs, loff_t *ppos) 2599 unsigned long nr_segs)
2828{ 2600{
2829 struct file *file = iocb->ki_filp; 2601 struct file *file = iocb->ki_filp;
2830 struct address_space * mapping = file->f_mapping; 2602 struct address_space * mapping = file->f_mapping;
2831 size_t ocount; /* original count */ 2603 size_t ocount; /* original count */
2832 size_t count; /* after file limit checks */ 2604 size_t count; /* after file limit checks */
2833 struct inode *inode = mapping->host; 2605 struct inode *inode = mapping->host;
2834 loff_t pos; 2606 loff_t pos = iocb->ki_pos;
2835 ssize_t written; 2607 ssize_t written = 0;
2836 ssize_t err; 2608 ssize_t err;
2609 ssize_t status;
2610 struct iov_iter from;
2837 2611
2838 ocount = 0; 2612 ocount = 0;
2839 err = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ); 2613 err = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ);
@@ -2841,12 +2615,9 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2841 return err; 2615 return err;
2842 2616
2843 count = ocount; 2617 count = ocount;
2844 pos = *ppos;
2845 2618
2846 /* We can write back this queue in page reclaim */ 2619 /* We can write back this queue in page reclaim */
2847 current->backing_dev_info = mapping->backing_dev_info; 2620 current->backing_dev_info = mapping->backing_dev_info;
2848 written = 0;
2849
2850 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); 2621 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
2851 if (err) 2622 if (err)
2852 goto out; 2623 goto out;
@@ -2862,45 +2633,47 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2862 if (err) 2633 if (err)
2863 goto out; 2634 goto out;
2864 2635
2636 iov_iter_init(&from, iov, nr_segs, count, 0);
2637
2865 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2638 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
2866 if (unlikely(file->f_flags & O_DIRECT)) { 2639 if (unlikely(file->f_flags & O_DIRECT)) {
2867 loff_t endbyte; 2640 loff_t endbyte;
2868 ssize_t written_buffered;
2869 2641
2870 written = generic_file_direct_write(iocb, iov, &nr_segs, pos, 2642 written = generic_file_direct_write(iocb, iov, &from.nr_segs, pos,
2871 ppos, count, ocount); 2643 count, ocount);
2872 if (written < 0 || written == count) 2644 if (written < 0 || written == count)
2873 goto out; 2645 goto out;
2646 iov_iter_advance(&from, written);
2647
2874 /* 2648 /*
2875 * direct-io write to a hole: fall through to buffered I/O 2649 * direct-io write to a hole: fall through to buffered I/O
2876 * for completing the rest of the request. 2650 * for completing the rest of the request.
2877 */ 2651 */
2878 pos += written; 2652 pos += written;
2879 count -= written; 2653 count -= written;
2880 written_buffered = generic_file_buffered_write(iocb, iov, 2654
2881 nr_segs, pos, ppos, count, 2655 status = generic_perform_write(file, &from, pos);
2882 written);
2883 /* 2656 /*
2884 * If generic_file_buffered_write() retuned a synchronous error 2657 * If generic_perform_write() returned a synchronous error
2885 * then we want to return the number of bytes which were 2658 * then we want to return the number of bytes which were
2886 * direct-written, or the error code if that was zero. Note 2659 * direct-written, or the error code if that was zero. Note
2887 * that this differs from normal direct-io semantics, which 2660 * that this differs from normal direct-io semantics, which
2888 * will return -EFOO even if some bytes were written. 2661 * will return -EFOO even if some bytes were written.
2889 */ 2662 */
2890 if (written_buffered < 0) { 2663 if (unlikely(status < 0) && !written) {
2891 err = written_buffered; 2664 err = status;
2892 goto out; 2665 goto out;
2893 } 2666 }
2894 2667 iocb->ki_pos = pos + status;
2895 /* 2668 /*
2896 * We need to ensure that the page cache pages are written to 2669 * We need to ensure that the page cache pages are written to
2897 * disk and invalidated to preserve the expected O_DIRECT 2670 * disk and invalidated to preserve the expected O_DIRECT
2898 * semantics. 2671 * semantics.
2899 */ 2672 */
2900 endbyte = pos + written_buffered - written - 1; 2673 endbyte = pos + status - 1;
2901 err = filemap_write_and_wait_range(file->f_mapping, pos, endbyte); 2674 err = filemap_write_and_wait_range(file->f_mapping, pos, endbyte);
2902 if (err == 0) { 2675 if (err == 0) {
2903 written = written_buffered; 2676 written += status;
2904 invalidate_mapping_pages(mapping, 2677 invalidate_mapping_pages(mapping,
2905 pos >> PAGE_CACHE_SHIFT, 2678 pos >> PAGE_CACHE_SHIFT,
2906 endbyte >> PAGE_CACHE_SHIFT); 2679 endbyte >> PAGE_CACHE_SHIFT);
@@ -2911,8 +2684,9 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2911 */ 2684 */
2912 } 2685 }
2913 } else { 2686 } else {
2914 written = generic_file_buffered_write(iocb, iov, nr_segs, 2687 written = generic_perform_write(file, &from, pos);
2915 pos, ppos, count, written); 2688 if (likely(written >= 0))
2689 iocb->ki_pos = pos + written;
2916 } 2690 }
2917out: 2691out:
2918 current->backing_dev_info = NULL; 2692 current->backing_dev_info = NULL;
@@ -2941,7 +2715,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2941 BUG_ON(iocb->ki_pos != pos); 2715 BUG_ON(iocb->ki_pos != pos);
2942 2716
2943 mutex_lock(&inode->i_mutex); 2717 mutex_lock(&inode->i_mutex);
2944 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 2718 ret = __generic_file_aio_write(iocb, iov, nr_segs);
2945 mutex_unlock(&inode->i_mutex); 2719 mutex_unlock(&inode->i_mutex);
2946 2720
2947 if (ret > 0) { 2721 if (ret > 0) {
diff --git a/mm/iov_iter.c b/mm/iov_iter.c
new file mode 100644
index 000000000000..10e46cd721de
--- /dev/null
+++ b/mm/iov_iter.c
@@ -0,0 +1,224 @@
1#include <linux/export.h>
2#include <linux/uio.h>
3#include <linux/pagemap.h>
4
5size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
6 struct iov_iter *i)
7{
8 size_t skip, copy, left, wanted;
9 const struct iovec *iov;
10 char __user *buf;
11 void *kaddr, *from;
12
13 if (unlikely(bytes > i->count))
14 bytes = i->count;
15
16 if (unlikely(!bytes))
17 return 0;
18
19 wanted = bytes;
20 iov = i->iov;
21 skip = i->iov_offset;
22 buf = iov->iov_base + skip;
23 copy = min(bytes, iov->iov_len - skip);
24
25 if (!fault_in_pages_writeable(buf, copy)) {
26 kaddr = kmap_atomic(page);
27 from = kaddr + offset;
28
29 /* first chunk, usually the only one */
30 left = __copy_to_user_inatomic(buf, from, copy);
31 copy -= left;
32 skip += copy;
33 from += copy;
34 bytes -= copy;
35
36 while (unlikely(!left && bytes)) {
37 iov++;
38 buf = iov->iov_base;
39 copy = min(bytes, iov->iov_len);
40 left = __copy_to_user_inatomic(buf, from, copy);
41 copy -= left;
42 skip = copy;
43 from += copy;
44 bytes -= copy;
45 }
46 if (likely(!bytes)) {
47 kunmap_atomic(kaddr);
48 goto done;
49 }
50 offset = from - kaddr;
51 buf += copy;
52 kunmap_atomic(kaddr);
53 copy = min(bytes, iov->iov_len - skip);
54 }
55 /* Too bad - revert to non-atomic kmap */
56 kaddr = kmap(page);
57 from = kaddr + offset;
58 left = __copy_to_user(buf, from, copy);
59 copy -= left;
60 skip += copy;
61 from += copy;
62 bytes -= copy;
63 while (unlikely(!left && bytes)) {
64 iov++;
65 buf = iov->iov_base;
66 copy = min(bytes, iov->iov_len);
67 left = __copy_to_user(buf, from, copy);
68 copy -= left;
69 skip = copy;
70 from += copy;
71 bytes -= copy;
72 }
73 kunmap(page);
74done:
75 i->count -= wanted - bytes;
76 i->nr_segs -= iov - i->iov;
77 i->iov = iov;
78 i->iov_offset = skip;
79 return wanted - bytes;
80}
81EXPORT_SYMBOL(copy_page_to_iter);
82
83static size_t __iovec_copy_from_user_inatomic(char *vaddr,
84 const struct iovec *iov, size_t base, size_t bytes)
85{
86 size_t copied = 0, left = 0;
87
88 while (bytes) {
89 char __user *buf = iov->iov_base + base;
90 int copy = min(bytes, iov->iov_len - base);
91
92 base = 0;
93 left = __copy_from_user_inatomic(vaddr, buf, copy);
94 copied += copy;
95 bytes -= copy;
96 vaddr += copy;
97 iov++;
98
99 if (unlikely(left))
100 break;
101 }
102 return copied - left;
103}
104
105/*
106 * Copy as much as we can into the page and return the number of bytes which
107 * were successfully copied. If a fault is encountered then return the number of
108 * bytes which were copied.
109 */
110size_t iov_iter_copy_from_user_atomic(struct page *page,
111 struct iov_iter *i, unsigned long offset, size_t bytes)
112{
113 char *kaddr;
114 size_t copied;
115
116 kaddr = kmap_atomic(page);
117 if (likely(i->nr_segs == 1)) {
118 int left;
119 char __user *buf = i->iov->iov_base + i->iov_offset;
120 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
121 copied = bytes - left;
122 } else {
123 copied = __iovec_copy_from_user_inatomic(kaddr + offset,
124 i->iov, i->iov_offset, bytes);
125 }
126 kunmap_atomic(kaddr);
127
128 return copied;
129}
130EXPORT_SYMBOL(iov_iter_copy_from_user_atomic);
131
132/*
133 * This has the same sideeffects and return value as
134 * iov_iter_copy_from_user_atomic().
135 * The difference is that it attempts to resolve faults.
136 * Page must not be locked.
137 */
138size_t iov_iter_copy_from_user(struct page *page,
139 struct iov_iter *i, unsigned long offset, size_t bytes)
140{
141 char *kaddr;
142 size_t copied;
143
144 kaddr = kmap(page);
145 if (likely(i->nr_segs == 1)) {
146 int left;
147 char __user *buf = i->iov->iov_base + i->iov_offset;
148 left = __copy_from_user(kaddr + offset, buf, bytes);
149 copied = bytes - left;
150 } else {
151 copied = __iovec_copy_from_user_inatomic(kaddr + offset,
152 i->iov, i->iov_offset, bytes);
153 }
154 kunmap(page);
155 return copied;
156}
157EXPORT_SYMBOL(iov_iter_copy_from_user);
158
159void iov_iter_advance(struct iov_iter *i, size_t bytes)
160{
161 BUG_ON(i->count < bytes);
162
163 if (likely(i->nr_segs == 1)) {
164 i->iov_offset += bytes;
165 i->count -= bytes;
166 } else {
167 const struct iovec *iov = i->iov;
168 size_t base = i->iov_offset;
169 unsigned long nr_segs = i->nr_segs;
170
171 /*
172 * The !iov->iov_len check ensures we skip over unlikely
173 * zero-length segments (without overruning the iovec).
174 */
175 while (bytes || unlikely(i->count && !iov->iov_len)) {
176 int copy;
177
178 copy = min(bytes, iov->iov_len - base);
179 BUG_ON(!i->count || i->count < copy);
180 i->count -= copy;
181 bytes -= copy;
182 base += copy;
183 if (iov->iov_len == base) {
184 iov++;
185 nr_segs--;
186 base = 0;
187 }
188 }
189 i->iov = iov;
190 i->iov_offset = base;
191 i->nr_segs = nr_segs;
192 }
193}
194EXPORT_SYMBOL(iov_iter_advance);
195
196/*
197 * Fault in the first iovec of the given iov_iter, to a maximum length
198 * of bytes. Returns 0 on success, or non-zero if the memory could not be
199 * accessed (ie. because it is an invalid address).
200 *
201 * writev-intensive code may want this to prefault several iovecs -- that
202 * would be possible (callers must not rely on the fact that _only_ the
203 * first iovec will be faulted with the current implementation).
204 */
205int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
206{
207 char __user *buf = i->iov->iov_base + i->iov_offset;
208 bytes = min(bytes, i->iov->iov_len - i->iov_offset);
209 return fault_in_pages_readable(buf, bytes);
210}
211EXPORT_SYMBOL(iov_iter_fault_in_readable);
212
213/*
214 * Return the count of just the current iov_iter segment.
215 */
216size_t iov_iter_single_seg_count(const struct iov_iter *i)
217{
218 const struct iovec *iov = i->iov;
219 if (i->nr_segs == 1)
220 return i->count;
221 else
222 return min(i->count, iov->iov_len - i->iov_offset);
223}
224EXPORT_SYMBOL(iov_iter_single_seg_count);
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
index cb79065c19e5..8505c9262b35 100644
--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -23,129 +23,44 @@
23 23
24/** 24/**
25 * process_vm_rw_pages - read/write pages from task specified 25 * process_vm_rw_pages - read/write pages from task specified
26 * @task: task to read/write from 26 * @pages: array of pointers to pages we want to copy
27 * @mm: mm for task
28 * @process_pages: struct pages area that can store at least
29 * nr_pages_to_copy struct page pointers
30 * @pa: address of page in task to start copying from/to
31 * @start_offset: offset in page to start copying from/to 27 * @start_offset: offset in page to start copying from/to
32 * @len: number of bytes to copy 28 * @len: number of bytes to copy
33 * @lvec: iovec array specifying where to copy to/from 29 * @iter: where to copy to/from locally
34 * @lvec_cnt: number of elements in iovec array
35 * @lvec_current: index in iovec array we are up to
36 * @lvec_offset: offset in bytes from current iovec iov_base we are up to
37 * @vm_write: 0 means copy from, 1 means copy to 30 * @vm_write: 0 means copy from, 1 means copy to
38 * @nr_pages_to_copy: number of pages to copy
39 * @bytes_copied: returns number of bytes successfully copied
40 * Returns 0 on success, error code otherwise 31 * Returns 0 on success, error code otherwise
41 */ 32 */
42static int process_vm_rw_pages(struct task_struct *task, 33static int process_vm_rw_pages(struct page **pages,
43 struct mm_struct *mm, 34 unsigned offset,
44 struct page **process_pages, 35 size_t len,
45 unsigned long pa, 36 struct iov_iter *iter,
46 unsigned long start_offset, 37 int vm_write)
47 unsigned long len,
48 const struct iovec *lvec,
49 unsigned long lvec_cnt,
50 unsigned long *lvec_current,
51 size_t *lvec_offset,
52 int vm_write,
53 unsigned int nr_pages_to_copy,
54 ssize_t *bytes_copied)
55{ 38{
56 int pages_pinned;
57 void *target_kaddr;
58 int pgs_copied = 0;
59 int j;
60 int ret;
61 ssize_t bytes_to_copy;
62 ssize_t rc = 0;
63
64 *bytes_copied = 0;
65
66 /* Get the pages we're interested in */
67 down_read(&mm->mmap_sem);
68 pages_pinned = get_user_pages(task, mm, pa,
69 nr_pages_to_copy,
70 vm_write, 0, process_pages, NULL);
71 up_read(&mm->mmap_sem);
72
73 if (pages_pinned != nr_pages_to_copy) {
74 rc = -EFAULT;
75 goto end;
76 }
77
78 /* Do the copy for each page */ 39 /* Do the copy for each page */
79 for (pgs_copied = 0; 40 while (len && iov_iter_count(iter)) {
80 (pgs_copied < nr_pages_to_copy) && (*lvec_current < lvec_cnt); 41 struct page *page = *pages++;
81 pgs_copied++) { 42 size_t copy = PAGE_SIZE - offset;
82 /* Make sure we have a non zero length iovec */ 43 size_t copied;
83 while (*lvec_current < lvec_cnt 44
84 && lvec[*lvec_current].iov_len == 0) 45 if (copy > len)
85 (*lvec_current)++; 46 copy = len;
86 if (*lvec_current == lvec_cnt) 47
87 break; 48 if (vm_write) {
88 49 if (copy > iov_iter_count(iter))
89 /* 50 copy = iov_iter_count(iter);
90 * Will copy smallest of: 51 copied = iov_iter_copy_from_user(page, iter,
91 * - bytes remaining in page 52 offset, copy);
92 * - bytes remaining in destination iovec 53 iov_iter_advance(iter, copied);
93 */ 54 set_page_dirty_lock(page);
94 bytes_to_copy = min_t(ssize_t, PAGE_SIZE - start_offset,
95 len - *bytes_copied);
96 bytes_to_copy = min_t(ssize_t, bytes_to_copy,
97 lvec[*lvec_current].iov_len
98 - *lvec_offset);
99
100 target_kaddr = kmap(process_pages[pgs_copied]) + start_offset;
101
102 if (vm_write)
103 ret = copy_from_user(target_kaddr,
104 lvec[*lvec_current].iov_base
105 + *lvec_offset,
106 bytes_to_copy);
107 else
108 ret = copy_to_user(lvec[*lvec_current].iov_base
109 + *lvec_offset,
110 target_kaddr, bytes_to_copy);
111 kunmap(process_pages[pgs_copied]);
112 if (ret) {
113 *bytes_copied += bytes_to_copy - ret;
114 pgs_copied++;
115 rc = -EFAULT;
116 goto end;
117 }
118 *bytes_copied += bytes_to_copy;
119 *lvec_offset += bytes_to_copy;
120 if (*lvec_offset == lvec[*lvec_current].iov_len) {
121 /*
122 * Need to copy remaining part of page into the
123 * next iovec if there are any bytes left in page
124 */
125 (*lvec_current)++;
126 *lvec_offset = 0;
127 start_offset = (start_offset + bytes_to_copy)
128 % PAGE_SIZE;
129 if (start_offset)
130 pgs_copied--;
131 } else { 55 } else {
132 start_offset = 0; 56 copied = copy_page_to_iter(page, offset, copy, iter);
133 }
134 }
135
136end:
137 if (vm_write) {
138 for (j = 0; j < pages_pinned; j++) {
139 if (j < pgs_copied)
140 set_page_dirty_lock(process_pages[j]);
141 put_page(process_pages[j]);
142 } 57 }
143 } else { 58 len -= copied;
144 for (j = 0; j < pages_pinned; j++) 59 if (copied < copy && iov_iter_count(iter))
145 put_page(process_pages[j]); 60 return -EFAULT;
61 offset = 0;
146 } 62 }
147 63 return 0;
148 return rc;
149} 64}
150 65
151/* Maximum number of pages kmalloc'd to hold struct page's during copy */ 66/* Maximum number of pages kmalloc'd to hold struct page's during copy */
@@ -155,67 +70,60 @@ end:
155 * process_vm_rw_single_vec - read/write pages from task specified 70 * process_vm_rw_single_vec - read/write pages from task specified
156 * @addr: start memory address of target process 71 * @addr: start memory address of target process
157 * @len: size of area to copy to/from 72 * @len: size of area to copy to/from
158 * @lvec: iovec array specifying where to copy to/from locally 73 * @iter: where to copy to/from locally
159 * @lvec_cnt: number of elements in iovec array
160 * @lvec_current: index in iovec array we are up to
161 * @lvec_offset: offset in bytes from current iovec iov_base we are up to
162 * @process_pages: struct pages area that can store at least 74 * @process_pages: struct pages area that can store at least
163 * nr_pages_to_copy struct page pointers 75 * nr_pages_to_copy struct page pointers
164 * @mm: mm for task 76 * @mm: mm for task
165 * @task: task to read/write from 77 * @task: task to read/write from
166 * @vm_write: 0 means copy from, 1 means copy to 78 * @vm_write: 0 means copy from, 1 means copy to
167 * @bytes_copied: returns number of bytes successfully copied
168 * Returns 0 on success or on failure error code 79 * Returns 0 on success or on failure error code
169 */ 80 */
170static int process_vm_rw_single_vec(unsigned long addr, 81static int process_vm_rw_single_vec(unsigned long addr,
171 unsigned long len, 82 unsigned long len,
172 const struct iovec *lvec, 83 struct iov_iter *iter,
173 unsigned long lvec_cnt,
174 unsigned long *lvec_current,
175 size_t *lvec_offset,
176 struct page **process_pages, 84 struct page **process_pages,
177 struct mm_struct *mm, 85 struct mm_struct *mm,
178 struct task_struct *task, 86 struct task_struct *task,
179 int vm_write, 87 int vm_write)
180 ssize_t *bytes_copied)
181{ 88{
182 unsigned long pa = addr & PAGE_MASK; 89 unsigned long pa = addr & PAGE_MASK;
183 unsigned long start_offset = addr - pa; 90 unsigned long start_offset = addr - pa;
184 unsigned long nr_pages; 91 unsigned long nr_pages;
185 ssize_t bytes_copied_loop;
186 ssize_t rc = 0; 92 ssize_t rc = 0;
187 unsigned long nr_pages_copied = 0;
188 unsigned long nr_pages_to_copy;
189 unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES 93 unsigned long max_pages_per_loop = PVM_MAX_KMALLOC_PAGES
190 / sizeof(struct pages *); 94 / sizeof(struct pages *);
191 95
192 *bytes_copied = 0;
193
194 /* Work out address and page range required */ 96 /* Work out address and page range required */
195 if (len == 0) 97 if (len == 0)
196 return 0; 98 return 0;
197 nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1; 99 nr_pages = (addr + len - 1) / PAGE_SIZE - addr / PAGE_SIZE + 1;
198 100
199 while ((nr_pages_copied < nr_pages) && (*lvec_current < lvec_cnt)) { 101 while (!rc && nr_pages && iov_iter_count(iter)) {
200 nr_pages_to_copy = min(nr_pages - nr_pages_copied, 102 int pages = min(nr_pages, max_pages_per_loop);
201 max_pages_per_loop); 103 size_t bytes;
202 104
203 rc = process_vm_rw_pages(task, mm, process_pages, pa, 105 /* Get the pages we're interested in */
204 start_offset, len, 106 down_read(&mm->mmap_sem);
205 lvec, lvec_cnt, 107 pages = get_user_pages(task, mm, pa, pages,
206 lvec_current, lvec_offset, 108 vm_write, 0, process_pages, NULL);
207 vm_write, nr_pages_to_copy, 109 up_read(&mm->mmap_sem);
208 &bytes_copied_loop);
209 start_offset = 0;
210 *bytes_copied += bytes_copied_loop;
211 110
212 if (rc < 0) { 111 if (pages <= 0)
213 return rc; 112 return -EFAULT;
214 } else { 113
215 len -= bytes_copied_loop; 114 bytes = pages * PAGE_SIZE - start_offset;
216 nr_pages_copied += nr_pages_to_copy; 115 if (bytes > len)
217 pa += nr_pages_to_copy * PAGE_SIZE; 116 bytes = len;
218 } 117
118 rc = process_vm_rw_pages(process_pages,
119 start_offset, bytes, iter,
120 vm_write);
121 len -= bytes;
122 start_offset = 0;
123 nr_pages -= pages;
124 pa += pages * PAGE_SIZE;
125 while (pages)
126 put_page(process_pages[--pages]);
219 } 127 }
220 128
221 return rc; 129 return rc;
@@ -228,8 +136,7 @@ static int process_vm_rw_single_vec(unsigned long addr,
228/** 136/**
229 * process_vm_rw_core - core of reading/writing pages from task specified 137 * process_vm_rw_core - core of reading/writing pages from task specified
230 * @pid: PID of process to read/write from/to 138 * @pid: PID of process to read/write from/to
231 * @lvec: iovec array specifying where to copy to/from locally 139 * @iter: where to copy to/from locally
232 * @liovcnt: size of lvec array
233 * @rvec: iovec array specifying where to copy to/from in the other process 140 * @rvec: iovec array specifying where to copy to/from in the other process
234 * @riovcnt: size of rvec array 141 * @riovcnt: size of rvec array
235 * @flags: currently unused 142 * @flags: currently unused
@@ -238,8 +145,7 @@ static int process_vm_rw_single_vec(unsigned long addr,
238 * return less bytes than expected if an error occurs during the copying 145 * return less bytes than expected if an error occurs during the copying
239 * process. 146 * process.
240 */ 147 */
241static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec, 148static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
242 unsigned long liovcnt,
243 const struct iovec *rvec, 149 const struct iovec *rvec,
244 unsigned long riovcnt, 150 unsigned long riovcnt,
245 unsigned long flags, int vm_write) 151 unsigned long flags, int vm_write)
@@ -250,13 +156,10 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
250 struct mm_struct *mm; 156 struct mm_struct *mm;
251 unsigned long i; 157 unsigned long i;
252 ssize_t rc = 0; 158 ssize_t rc = 0;
253 ssize_t bytes_copied_loop;
254 ssize_t bytes_copied = 0;
255 unsigned long nr_pages = 0; 159 unsigned long nr_pages = 0;
256 unsigned long nr_pages_iov; 160 unsigned long nr_pages_iov;
257 unsigned long iov_l_curr_idx = 0;
258 size_t iov_l_curr_offset = 0;
259 ssize_t iov_len; 161 ssize_t iov_len;
162 size_t total_len = iov_iter_count(iter);
260 163
261 /* 164 /*
262 * Work out how many pages of struct pages we're going to need 165 * Work out how many pages of struct pages we're going to need
@@ -310,24 +213,20 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
310 goto put_task_struct; 213 goto put_task_struct;
311 } 214 }
312 215
313 for (i = 0; i < riovcnt && iov_l_curr_idx < liovcnt; i++) { 216 for (i = 0; i < riovcnt && iov_iter_count(iter) && !rc; i++)
314 rc = process_vm_rw_single_vec( 217 rc = process_vm_rw_single_vec(
315 (unsigned long)rvec[i].iov_base, rvec[i].iov_len, 218 (unsigned long)rvec[i].iov_base, rvec[i].iov_len,
316 lvec, liovcnt, &iov_l_curr_idx, &iov_l_curr_offset, 219 iter, process_pages, mm, task, vm_write);
317 process_pages, mm, task, vm_write, &bytes_copied_loop); 220
318 bytes_copied += bytes_copied_loop; 221 /* copied = space before - space after */
319 if (rc != 0) { 222 total_len -= iov_iter_count(iter);
320 /* If we have managed to copy any data at all then 223
321 we return the number of bytes copied. Otherwise 224 /* If we have managed to copy any data at all then
322 we return the error code */ 225 we return the number of bytes copied. Otherwise
323 if (bytes_copied) 226 we return the error code */
324 rc = bytes_copied; 227 if (total_len)
325 goto put_mm; 228 rc = total_len;
326 }
327 }
328 229
329 rc = bytes_copied;
330put_mm:
331 mmput(mm); 230 mmput(mm);
332 231
333put_task_struct: 232put_task_struct:
@@ -363,6 +262,7 @@ static ssize_t process_vm_rw(pid_t pid,
363 struct iovec iovstack_r[UIO_FASTIOV]; 262 struct iovec iovstack_r[UIO_FASTIOV];
364 struct iovec *iov_l = iovstack_l; 263 struct iovec *iov_l = iovstack_l;
365 struct iovec *iov_r = iovstack_r; 264 struct iovec *iov_r = iovstack_r;
265 struct iov_iter iter;
366 ssize_t rc; 266 ssize_t rc;
367 267
368 if (flags != 0) 268 if (flags != 0)
@@ -378,13 +278,14 @@ static ssize_t process_vm_rw(pid_t pid,
378 if (rc <= 0) 278 if (rc <= 0)
379 goto free_iovecs; 279 goto free_iovecs;
380 280
281 iov_iter_init(&iter, iov_l, liovcnt, rc, 0);
282
381 rc = rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, UIO_FASTIOV, 283 rc = rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, UIO_FASTIOV,
382 iovstack_r, &iov_r); 284 iovstack_r, &iov_r);
383 if (rc <= 0) 285 if (rc <= 0)
384 goto free_iovecs; 286 goto free_iovecs;
385 287
386 rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags, 288 rc = process_vm_rw_core(pid, &iter, iov_r, riovcnt, flags, vm_write);
387 vm_write);
388 289
389free_iovecs: 290free_iovecs:
390 if (iov_r != iovstack_r) 291 if (iov_r != iovstack_r)
@@ -424,6 +325,7 @@ compat_process_vm_rw(compat_pid_t pid,
424 struct iovec iovstack_r[UIO_FASTIOV]; 325 struct iovec iovstack_r[UIO_FASTIOV];
425 struct iovec *iov_l = iovstack_l; 326 struct iovec *iov_l = iovstack_l;
426 struct iovec *iov_r = iovstack_r; 327 struct iovec *iov_r = iovstack_r;
328 struct iov_iter iter;
427 ssize_t rc = -EFAULT; 329 ssize_t rc = -EFAULT;
428 330
429 if (flags != 0) 331 if (flags != 0)
@@ -439,14 +341,14 @@ compat_process_vm_rw(compat_pid_t pid,
439 &iov_l); 341 &iov_l);
440 if (rc <= 0) 342 if (rc <= 0)
441 goto free_iovecs; 343 goto free_iovecs;
344 iov_iter_init(&iter, iov_l, liovcnt, rc, 0);
442 rc = compat_rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, 345 rc = compat_rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt,
443 UIO_FASTIOV, iovstack_r, 346 UIO_FASTIOV, iovstack_r,
444 &iov_r); 347 &iov_r);
445 if (rc <= 0) 348 if (rc <= 0)
446 goto free_iovecs; 349 goto free_iovecs;
447 350
448 rc = process_vm_rw_core(pid, iov_l, liovcnt, iov_r, riovcnt, flags, 351 rc = process_vm_rw_core(pid, &iter, iov_r, riovcnt, flags, vm_write);
449 vm_write);
450 352
451free_iovecs: 353free_iovecs:
452 if (iov_r != iovstack_r) 354 if (iov_r != iovstack_r)
diff --git a/mm/shmem.c b/mm/shmem.c
index 70273f8df586..8f1a95406bae 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1402,13 +1402,25 @@ shmem_write_end(struct file *file, struct address_space *mapping,
1402 return copied; 1402 return copied;
1403} 1403}
1404 1404
1405static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_t *desc, read_actor_t actor) 1405static ssize_t shmem_file_aio_read(struct kiocb *iocb,
1406 const struct iovec *iov, unsigned long nr_segs, loff_t pos)
1406{ 1407{
1407 struct inode *inode = file_inode(filp); 1408 struct file *file = iocb->ki_filp;
1409 struct inode *inode = file_inode(file);
1408 struct address_space *mapping = inode->i_mapping; 1410 struct address_space *mapping = inode->i_mapping;
1409 pgoff_t index; 1411 pgoff_t index;
1410 unsigned long offset; 1412 unsigned long offset;
1411 enum sgp_type sgp = SGP_READ; 1413 enum sgp_type sgp = SGP_READ;
1414 int error;
1415 ssize_t retval;
1416 size_t count;
1417 loff_t *ppos = &iocb->ki_pos;
1418 struct iov_iter iter;
1419
1420 retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
1421 if (retval)
1422 return retval;
1423 iov_iter_init(&iter, iov, nr_segs, count, 0);
1412 1424
1413 /* 1425 /*
1414 * Might this read be for a stacking filesystem? Then when reading 1426 * Might this read be for a stacking filesystem? Then when reading
@@ -1436,10 +1448,10 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_
1436 break; 1448 break;
1437 } 1449 }
1438 1450
1439 desc->error = shmem_getpage(inode, index, &page, sgp, NULL); 1451 error = shmem_getpage(inode, index, &page, sgp, NULL);
1440 if (desc->error) { 1452 if (error) {
1441 if (desc->error == -EINVAL) 1453 if (error == -EINVAL)
1442 desc->error = 0; 1454 error = 0;
1443 break; 1455 break;
1444 } 1456 }
1445 if (page) 1457 if (page)
@@ -1483,61 +1495,26 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_
1483 /* 1495 /*
1484 * Ok, we have the page, and it's up-to-date, so 1496 * Ok, we have the page, and it's up-to-date, so
1485 * now we can copy it to user space... 1497 * now we can copy it to user space...
1486 *
1487 * The actor routine returns how many bytes were actually used..
1488 * NOTE! This may not be the same as how much of a user buffer
1489 * we filled up (we may be padding etc), so we can only update
1490 * "pos" here (the actor routine has to update the user buffer
1491 * pointers and the remaining count).
1492 */ 1498 */
1493 ret = actor(desc, page, offset, nr); 1499 ret = copy_page_to_iter(page, offset, nr, &iter);
1500 retval += ret;
1494 offset += ret; 1501 offset += ret;
1495 index += offset >> PAGE_CACHE_SHIFT; 1502 index += offset >> PAGE_CACHE_SHIFT;
1496 offset &= ~PAGE_CACHE_MASK; 1503 offset &= ~PAGE_CACHE_MASK;
1497 1504
1498 page_cache_release(page); 1505 page_cache_release(page);
1499 if (ret != nr || !desc->count) 1506 if (!iov_iter_count(&iter))
1500 break; 1507 break;
1501 1508 if (ret < nr) {
1509 error = -EFAULT;
1510 break;
1511 }
1502 cond_resched(); 1512 cond_resched();
1503 } 1513 }
1504 1514
1505 *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; 1515 *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
1506 file_accessed(filp); 1516 file_accessed(file);
1507} 1517 return retval ? retval : error;
1508
1509static ssize_t shmem_file_aio_read(struct kiocb *iocb,
1510 const struct iovec *iov, unsigned long nr_segs, loff_t pos)
1511{
1512 struct file *filp = iocb->ki_filp;
1513 ssize_t retval;
1514 unsigned long seg;
1515 size_t count;
1516 loff_t *ppos = &iocb->ki_pos;
1517
1518 retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
1519 if (retval)
1520 return retval;
1521
1522 for (seg = 0; seg < nr_segs; seg++) {
1523 read_descriptor_t desc;
1524
1525 desc.written = 0;
1526 desc.arg.buf = iov[seg].iov_base;
1527 desc.count = iov[seg].iov_len;
1528 if (desc.count == 0)
1529 continue;
1530 desc.error = 0;
1531 do_shmem_file_read(filp, ppos, &desc, file_read_actor);
1532 retval += desc.written;
1533 if (desc.error) {
1534 retval = retval ?: desc.error;
1535 break;
1536 }
1537 if (desc.count > 0)
1538 break;
1539 }
1540 return retval;
1541} 1518}
1542 1519
1543static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, 1520static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
@@ -1576,7 +1553,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
1576 index = *ppos >> PAGE_CACHE_SHIFT; 1553 index = *ppos >> PAGE_CACHE_SHIFT;
1577 loff = *ppos & ~PAGE_CACHE_MASK; 1554 loff = *ppos & ~PAGE_CACHE_MASK;
1578 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 1555 req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
1579 nr_pages = min(req_pages, pipe->buffers); 1556 nr_pages = min(req_pages, spd.nr_pages_max);
1580 1557
1581 spd.nr_pages = find_get_pages_contig(mapping, index, 1558 spd.nr_pages = find_get_pages_contig(mapping, index,
1582 nr_pages, spd.pages); 1559 nr_pages, spd.pages);
diff --git a/mm/util.c b/mm/util.c
index d7813e6d4cc7..f380af7ea779 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -446,6 +446,54 @@ unsigned long vm_commit_limit(void)
446 return allowed; 446 return allowed;
447} 447}
448 448
449/**
450 * get_cmdline() - copy the cmdline value to a buffer.
451 * @task: the task whose cmdline value to copy.
452 * @buffer: the buffer to copy to.
453 * @buflen: the length of the buffer. Larger cmdline values are truncated
454 * to this length.
455 * Returns the size of the cmdline field copied. Note that the copy does
456 * not guarantee an ending NULL byte.
457 */
458int get_cmdline(struct task_struct *task, char *buffer, int buflen)
459{
460 int res = 0;
461 unsigned int len;
462 struct mm_struct *mm = get_task_mm(task);
463 if (!mm)
464 goto out;
465 if (!mm->arg_end)
466 goto out_mm; /* Shh! No looking before we're done */
467
468 len = mm->arg_end - mm->arg_start;
469
470 if (len > buflen)
471 len = buflen;
472
473 res = access_process_vm(task, mm->arg_start, buffer, len, 0);
474
475 /*
476 * If the nul at the end of args has been overwritten, then
477 * assume application is using setproctitle(3).
478 */
479 if (res > 0 && buffer[res-1] != '\0' && len < buflen) {
480 len = strnlen(buffer, res);
481 if (len < res) {
482 res = len;
483 } else {
484 len = mm->env_end - mm->env_start;
485 if (len > buflen - res)
486 len = buflen - res;
487 res += access_process_vm(task, mm->env_start,
488 buffer+res, len, 0);
489 res = strnlen(buffer, res);
490 }
491 }
492out_mm:
493 mmput(mm);
494out:
495 return res;
496}
449 497
450/* Tracepoints definitions. */ 498/* Tracepoints definitions. */
451EXPORT_TRACEPOINT_SYMBOL(kmalloc); 499EXPORT_TRACEPOINT_SYMBOL(kmalloc);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 06879ead7380..9b6497eda806 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1862,7 +1862,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
1862 struct zone *zone = lruvec_zone(lruvec); 1862 struct zone *zone = lruvec_zone(lruvec);
1863 unsigned long anon_prio, file_prio; 1863 unsigned long anon_prio, file_prio;
1864 enum scan_balance scan_balance; 1864 enum scan_balance scan_balance;
1865 unsigned long anon, file, free; 1865 unsigned long anon, file;
1866 bool force_scan = false; 1866 bool force_scan = false;
1867 unsigned long ap, fp; 1867 unsigned long ap, fp;
1868 enum lru_list lru; 1868 enum lru_list lru;
@@ -1916,20 +1916,6 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
1916 get_lru_size(lruvec, LRU_INACTIVE_FILE); 1916 get_lru_size(lruvec, LRU_INACTIVE_FILE);
1917 1917
1918 /* 1918 /*
1919 * If it's foreseeable that reclaiming the file cache won't be
1920 * enough to get the zone back into a desirable shape, we have
1921 * to swap. Better start now and leave the - probably heavily
1922 * thrashing - remaining file pages alone.
1923 */
1924 if (global_reclaim(sc)) {
1925 free = zone_page_state(zone, NR_FREE_PAGES);
1926 if (unlikely(file + free <= high_wmark_pages(zone))) {
1927 scan_balance = SCAN_ANON;
1928 goto out;
1929 }
1930 }
1931
1932 /*
1933 * There is enough inactive page cache, do not reclaim 1919 * There is enough inactive page cache, do not reclaim
1934 * anything from the anonymous working set right now. 1920 * anything from the anonymous working set right now.
1935 */ 1921 */
diff --git a/net/9p/client.c b/net/9p/client.c
index 9186550d77a6..0004cbaac4a4 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -415,9 +415,17 @@ static void p9_free_req(struct p9_client *c, struct p9_req_t *r)
415 * req: request received 415 * req: request received
416 * 416 *
417 */ 417 */
418void p9_client_cb(struct p9_client *c, struct p9_req_t *req) 418void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)
419{ 419{
420 p9_debug(P9_DEBUG_MUX, " tag %d\n", req->tc->tag); 420 p9_debug(P9_DEBUG_MUX, " tag %d\n", req->tc->tag);
421
422 /*
423 * This barrier is needed to make sure any change made to req before
424 * the other thread wakes up will indeed be seen by the waiting side.
425 */
426 smp_wmb();
427 req->status = status;
428
421 wake_up(req->wq); 429 wake_up(req->wq);
422 p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc->tag); 430 p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc->tag);
423} 431}
@@ -655,16 +663,13 @@ static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
655 if (IS_ERR(req)) 663 if (IS_ERR(req))
656 return PTR_ERR(req); 664 return PTR_ERR(req);
657 665
658
659 /* 666 /*
660 * if we haven't received a response for oldreq, 667 * if we haven't received a response for oldreq,
661 * remove it from the list 668 * remove it from the list
662 */ 669 */
663 if (oldreq->status == REQ_STATUS_FLSH) { 670 if (oldreq->status == REQ_STATUS_SENT)
664 spin_lock(&c->lock); 671 if (c->trans_mod->cancelled)
665 list_del(&oldreq->req_list); 672 c->trans_mod->cancelled(c, oldreq);
666 spin_unlock(&c->lock);
667 }
668 673
669 p9_free_req(c, req); 674 p9_free_req(c, req);
670 return 0; 675 return 0;
@@ -751,6 +756,12 @@ again:
751 err = wait_event_interruptible(*req->wq, 756 err = wait_event_interruptible(*req->wq,
752 req->status >= REQ_STATUS_RCVD); 757 req->status >= REQ_STATUS_RCVD);
753 758
759 /*
760 * Make sure our req is coherent with regard to updates in other
761 * threads - echoes to wmb() in the callback
762 */
763 smp_rmb();
764
754 if ((err == -ERESTARTSYS) && (c->status == Connected) 765 if ((err == -ERESTARTSYS) && (c->status == Connected)
755 && (type == P9_TFLUSH)) { 766 && (type == P9_TFLUSH)) {
756 sigpending = 1; 767 sigpending = 1;
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index b7bd7f2961bf..80d08f6664cb 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -66,20 +66,6 @@ struct p9_fd_opts {
66 int privport; 66 int privport;
67}; 67};
68 68
69/**
70 * struct p9_trans_fd - transport state
71 * @rd: reference to file to read from
72 * @wr: reference of file to write to
73 * @conn: connection state reference
74 *
75 */
76
77struct p9_trans_fd {
78 struct file *rd;
79 struct file *wr;
80 struct p9_conn *conn;
81};
82
83/* 69/*
84 * Option Parsing (code inspired by NFS code) 70 * Option Parsing (code inspired by NFS code)
85 * - a little lazy - parse all fd-transport options 71 * - a little lazy - parse all fd-transport options
@@ -159,6 +145,20 @@ struct p9_conn {
159 unsigned long wsched; 145 unsigned long wsched;
160}; 146};
161 147
148/**
149 * struct p9_trans_fd - transport state
150 * @rd: reference to file to read from
151 * @wr: reference of file to write to
152 * @conn: connection state reference
153 *
154 */
155
156struct p9_trans_fd {
157 struct file *rd;
158 struct file *wr;
159 struct p9_conn conn;
160};
161
162static void p9_poll_workfn(struct work_struct *work); 162static void p9_poll_workfn(struct work_struct *work);
163 163
164static DEFINE_SPINLOCK(p9_poll_lock); 164static DEFINE_SPINLOCK(p9_poll_lock);
@@ -212,15 +212,9 @@ static void p9_conn_cancel(struct p9_conn *m, int err)
212 m->err = err; 212 m->err = err;
213 213
214 list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { 214 list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) {
215 req->status = REQ_STATUS_ERROR;
216 if (!req->t_err)
217 req->t_err = err;
218 list_move(&req->req_list, &cancel_list); 215 list_move(&req->req_list, &cancel_list);
219 } 216 }
220 list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { 217 list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) {
221 req->status = REQ_STATUS_ERROR;
222 if (!req->t_err)
223 req->t_err = err;
224 list_move(&req->req_list, &cancel_list); 218 list_move(&req->req_list, &cancel_list);
225 } 219 }
226 spin_unlock_irqrestore(&m->client->lock, flags); 220 spin_unlock_irqrestore(&m->client->lock, flags);
@@ -228,7 +222,9 @@ static void p9_conn_cancel(struct p9_conn *m, int err)
228 list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { 222 list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) {
229 p9_debug(P9_DEBUG_ERROR, "call back req %p\n", req); 223 p9_debug(P9_DEBUG_ERROR, "call back req %p\n", req);
230 list_del(&req->req_list); 224 list_del(&req->req_list);
231 p9_client_cb(m->client, req); 225 if (!req->t_err)
226 req->t_err = err;
227 p9_client_cb(m->client, req, REQ_STATUS_ERROR);
232 } 228 }
233} 229}
234 230
@@ -302,6 +298,7 @@ static void p9_read_work(struct work_struct *work)
302{ 298{
303 int n, err; 299 int n, err;
304 struct p9_conn *m; 300 struct p9_conn *m;
301 int status = REQ_STATUS_ERROR;
305 302
306 m = container_of(work, struct p9_conn, rq); 303 m = container_of(work, struct p9_conn, rq);
307 304
@@ -348,8 +345,7 @@ static void p9_read_work(struct work_struct *work)
348 "mux %p pkt: size: %d bytes tag: %d\n", m, n, tag); 345 "mux %p pkt: size: %d bytes tag: %d\n", m, n, tag);
349 346
350 m->req = p9_tag_lookup(m->client, tag); 347 m->req = p9_tag_lookup(m->client, tag);
351 if (!m->req || (m->req->status != REQ_STATUS_SENT && 348 if (!m->req || (m->req->status != REQ_STATUS_SENT)) {
352 m->req->status != REQ_STATUS_FLSH)) {
353 p9_debug(P9_DEBUG_ERROR, "Unexpected packet tag %d\n", 349 p9_debug(P9_DEBUG_ERROR, "Unexpected packet tag %d\n",
354 tag); 350 tag);
355 err = -EIO; 351 err = -EIO;
@@ -375,10 +371,10 @@ static void p9_read_work(struct work_struct *work)
375 p9_debug(P9_DEBUG_TRANS, "got new packet\n"); 371 p9_debug(P9_DEBUG_TRANS, "got new packet\n");
376 spin_lock(&m->client->lock); 372 spin_lock(&m->client->lock);
377 if (m->req->status != REQ_STATUS_ERROR) 373 if (m->req->status != REQ_STATUS_ERROR)
378 m->req->status = REQ_STATUS_RCVD; 374 status = REQ_STATUS_RCVD;
379 list_del(&m->req->req_list); 375 list_del(&m->req->req_list);
380 spin_unlock(&m->client->lock); 376 spin_unlock(&m->client->lock);
381 p9_client_cb(m->client, m->req); 377 p9_client_cb(m->client, m->req, status);
382 m->rbuf = NULL; 378 m->rbuf = NULL;
383 m->rpos = 0; 379 m->rpos = 0;
384 m->rsize = 0; 380 m->rsize = 0;
@@ -573,21 +569,19 @@ p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
573} 569}
574 570
575/** 571/**
576 * p9_conn_create - allocate and initialize the per-session mux data 572 * p9_conn_create - initialize the per-session mux data
577 * @client: client instance 573 * @client: client instance
578 * 574 *
579 * Note: Creates the polling task if this is the first session. 575 * Note: Creates the polling task if this is the first session.
580 */ 576 */
581 577
582static struct p9_conn *p9_conn_create(struct p9_client *client) 578static void p9_conn_create(struct p9_client *client)
583{ 579{
584 int n; 580 int n;
585 struct p9_conn *m; 581 struct p9_trans_fd *ts = client->trans;
582 struct p9_conn *m = &ts->conn;
586 583
587 p9_debug(P9_DEBUG_TRANS, "client %p msize %d\n", client, client->msize); 584 p9_debug(P9_DEBUG_TRANS, "client %p msize %d\n", client, client->msize);
588 m = kzalloc(sizeof(struct p9_conn), GFP_KERNEL);
589 if (!m)
590 return ERR_PTR(-ENOMEM);
591 585
592 INIT_LIST_HEAD(&m->mux_list); 586 INIT_LIST_HEAD(&m->mux_list);
593 m->client = client; 587 m->client = client;
@@ -609,8 +603,6 @@ static struct p9_conn *p9_conn_create(struct p9_client *client)
609 p9_debug(P9_DEBUG_TRANS, "mux %p can write\n", m); 603 p9_debug(P9_DEBUG_TRANS, "mux %p can write\n", m);
610 set_bit(Wpending, &m->wsched); 604 set_bit(Wpending, &m->wsched);
611 } 605 }
612
613 return m;
614} 606}
615 607
616/** 608/**
@@ -669,7 +661,7 @@ static int p9_fd_request(struct p9_client *client, struct p9_req_t *req)
669{ 661{
670 int n; 662 int n;
671 struct p9_trans_fd *ts = client->trans; 663 struct p9_trans_fd *ts = client->trans;
672 struct p9_conn *m = ts->conn; 664 struct p9_conn *m = &ts->conn;
673 665
674 p9_debug(P9_DEBUG_TRANS, "mux %p task %p tcall %p id %d\n", 666 p9_debug(P9_DEBUG_TRANS, "mux %p task %p tcall %p id %d\n",
675 m, current, req->tc, req->tc->id); 667 m, current, req->tc, req->tc->id);
@@ -704,14 +696,26 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req)
704 list_del(&req->req_list); 696 list_del(&req->req_list);
705 req->status = REQ_STATUS_FLSHD; 697 req->status = REQ_STATUS_FLSHD;
706 ret = 0; 698 ret = 0;
707 } else if (req->status == REQ_STATUS_SENT) 699 }
708 req->status = REQ_STATUS_FLSH;
709
710 spin_unlock(&client->lock); 700 spin_unlock(&client->lock);
711 701
712 return ret; 702 return ret;
713} 703}
714 704
705static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)
706{
707 p9_debug(P9_DEBUG_TRANS, "client %p req %p\n", client, req);
708
709 /* we haven't received a response for oldreq,
710 * remove it from the list.
711 */
712 spin_lock(&client->lock);
713 list_del(&req->req_list);
714 spin_unlock(&client->lock);
715
716 return 0;
717}
718
715/** 719/**
716 * parse_opts - parse mount options into p9_fd_opts structure 720 * parse_opts - parse mount options into p9_fd_opts structure
717 * @params: options string passed from mount 721 * @params: options string passed from mount
@@ -780,7 +784,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
780 784
781static int p9_fd_open(struct p9_client *client, int rfd, int wfd) 785static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
782{ 786{
783 struct p9_trans_fd *ts = kmalloc(sizeof(struct p9_trans_fd), 787 struct p9_trans_fd *ts = kzalloc(sizeof(struct p9_trans_fd),
784 GFP_KERNEL); 788 GFP_KERNEL);
785 if (!ts) 789 if (!ts)
786 return -ENOMEM; 790 return -ENOMEM;
@@ -806,9 +810,8 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)
806{ 810{
807 struct p9_trans_fd *p; 811 struct p9_trans_fd *p;
808 struct file *file; 812 struct file *file;
809 int ret;
810 813
811 p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL); 814 p = kzalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
812 if (!p) 815 if (!p)
813 return -ENOMEM; 816 return -ENOMEM;
814 817
@@ -829,20 +832,12 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)
829 832
830 p->rd->f_flags |= O_NONBLOCK; 833 p->rd->f_flags |= O_NONBLOCK;
831 834
832 p->conn = p9_conn_create(client); 835 p9_conn_create(client);
833 if (IS_ERR(p->conn)) {
834 ret = PTR_ERR(p->conn);
835 p->conn = NULL;
836 kfree(p);
837 sockfd_put(csocket);
838 sockfd_put(csocket);
839 return ret;
840 }
841 return 0; 836 return 0;
842} 837}
843 838
844/** 839/**
845 * p9_mux_destroy - cancels all pending requests and frees mux resources 840 * p9_mux_destroy - cancels all pending requests of mux
846 * @m: mux to destroy 841 * @m: mux to destroy
847 * 842 *
848 */ 843 */
@@ -859,7 +854,6 @@ static void p9_conn_destroy(struct p9_conn *m)
859 p9_conn_cancel(m, -ECONNRESET); 854 p9_conn_cancel(m, -ECONNRESET);
860 855
861 m->client = NULL; 856 m->client = NULL;
862 kfree(m);
863} 857}
864 858
865/** 859/**
@@ -881,7 +875,7 @@ static void p9_fd_close(struct p9_client *client)
881 875
882 client->status = Disconnected; 876 client->status = Disconnected;
883 877
884 p9_conn_destroy(ts->conn); 878 p9_conn_destroy(&ts->conn);
885 879
886 if (ts->rd) 880 if (ts->rd)
887 fput(ts->rd); 881 fput(ts->rd);
@@ -1033,14 +1027,7 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1033 return err; 1027 return err;
1034 1028
1035 p = (struct p9_trans_fd *) client->trans; 1029 p = (struct p9_trans_fd *) client->trans;
1036 p->conn = p9_conn_create(client); 1030 p9_conn_create(client);
1037 if (IS_ERR(p->conn)) {
1038 err = PTR_ERR(p->conn);
1039 p->conn = NULL;
1040 fput(p->rd);
1041 fput(p->wr);
1042 return err;
1043 }
1044 1031
1045 return 0; 1032 return 0;
1046} 1033}
@@ -1053,6 +1040,7 @@ static struct p9_trans_module p9_tcp_trans = {
1053 .close = p9_fd_close, 1040 .close = p9_fd_close,
1054 .request = p9_fd_request, 1041 .request = p9_fd_request,
1055 .cancel = p9_fd_cancel, 1042 .cancel = p9_fd_cancel,
1043 .cancelled = p9_fd_cancelled,
1056 .owner = THIS_MODULE, 1044 .owner = THIS_MODULE,
1057}; 1045};
1058 1046
@@ -1064,6 +1052,7 @@ static struct p9_trans_module p9_unix_trans = {
1064 .close = p9_fd_close, 1052 .close = p9_fd_close,
1065 .request = p9_fd_request, 1053 .request = p9_fd_request,
1066 .cancel = p9_fd_cancel, 1054 .cancel = p9_fd_cancel,
1055 .cancelled = p9_fd_cancelled,
1067 .owner = THIS_MODULE, 1056 .owner = THIS_MODULE,
1068}; 1057};
1069 1058
@@ -1075,6 +1064,7 @@ static struct p9_trans_module p9_fd_trans = {
1075 .close = p9_fd_close, 1064 .close = p9_fd_close,
1076 .request = p9_fd_request, 1065 .request = p9_fd_request,
1077 .cancel = p9_fd_cancel, 1066 .cancel = p9_fd_cancel,
1067 .cancelled = p9_fd_cancelled,
1078 .owner = THIS_MODULE, 1068 .owner = THIS_MODULE,
1079}; 1069};
1080 1070
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 8f68df5d2973..14ad43b5cf89 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -193,6 +193,8 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
193 if (!*p) 193 if (!*p)
194 continue; 194 continue;
195 token = match_token(p, tokens, args); 195 token = match_token(p, tokens, args);
196 if (token == Opt_err)
197 continue;
196 r = match_int(&args[0], &option); 198 r = match_int(&args[0], &option);
197 if (r < 0) { 199 if (r < 0) {
198 p9_debug(P9_DEBUG_ERROR, 200 p9_debug(P9_DEBUG_ERROR,
@@ -305,8 +307,7 @@ handle_recv(struct p9_client *client, struct p9_trans_rdma *rdma,
305 } 307 }
306 308
307 req->rc = c->rc; 309 req->rc = c->rc;
308 req->status = REQ_STATUS_RCVD; 310 p9_client_cb(client, req, REQ_STATUS_RCVD);
309 p9_client_cb(client, req);
310 311
311 return; 312 return;
312 313
@@ -511,6 +512,11 @@ dont_need_post_recv:
511 goto send_error; 512 goto send_error;
512 } 513 }
513 514
515 /* Mark request as `sent' *before* we actually send it,
516 * because doing if after could erase the REQ_STATUS_RCVD
517 * status in case of a very fast reply.
518 */
519 req->status = REQ_STATUS_SENT;
514 err = ib_post_send(rdma->qp, &wr, &bad_wr); 520 err = ib_post_send(rdma->qp, &wr, &bad_wr);
515 if (err) 521 if (err)
516 goto send_error; 522 goto send_error;
@@ -520,6 +526,7 @@ dont_need_post_recv:
520 526
521 /* Handle errors that happened during or while preparing the send: */ 527 /* Handle errors that happened during or while preparing the send: */
522 send_error: 528 send_error:
529 req->status = REQ_STATUS_ERROR;
523 kfree(c); 530 kfree(c);
524 p9_debug(P9_DEBUG_ERROR, "Error %d in rdma_request()\n", err); 531 p9_debug(P9_DEBUG_ERROR, "Error %d in rdma_request()\n", err);
525 532
@@ -582,12 +589,24 @@ static struct p9_trans_rdma *alloc_rdma(struct p9_rdma_opts *opts)
582 return rdma; 589 return rdma;
583} 590}
584 591
585/* its not clear to me we can do anything after send has been posted */
586static int rdma_cancel(struct p9_client *client, struct p9_req_t *req) 592static int rdma_cancel(struct p9_client *client, struct p9_req_t *req)
587{ 593{
594 /* Nothing to do here.
595 * We will take care of it (if we have to) in rdma_cancelled()
596 */
588 return 1; 597 return 1;
589} 598}
590 599
600/* A request has been fully flushed without a reply.
601 * That means we have posted one buffer in excess.
602 */
603static int rdma_cancelled(struct p9_client *client, struct p9_req_t *req)
604{
605 struct p9_trans_rdma *rdma = client->trans;
606 atomic_inc(&rdma->excess_rc);
607 return 0;
608}
609
591/** 610/**
592 * trans_create_rdma - Transport method for creating atransport instance 611 * trans_create_rdma - Transport method for creating atransport instance
593 * @client: client instance 612 * @client: client instance
@@ -721,6 +740,7 @@ static struct p9_trans_module p9_rdma_trans = {
721 .close = rdma_close, 740 .close = rdma_close,
722 .request = rdma_request, 741 .request = rdma_request,
723 .cancel = rdma_cancel, 742 .cancel = rdma_cancel,
743 .cancelled = rdma_cancelled,
724}; 744};
725 745
726/** 746/**
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index ac2666c1d011..6940d8fe8971 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -164,8 +164,7 @@ static void req_done(struct virtqueue *vq)
164 p9_debug(P9_DEBUG_TRANS, ": rc %p\n", rc); 164 p9_debug(P9_DEBUG_TRANS, ": rc %p\n", rc);
165 p9_debug(P9_DEBUG_TRANS, ": lookup tag %d\n", rc->tag); 165 p9_debug(P9_DEBUG_TRANS, ": lookup tag %d\n", rc->tag);
166 req = p9_tag_lookup(chan->client, rc->tag); 166 req = p9_tag_lookup(chan->client, rc->tag);
167 req->status = REQ_STATUS_RCVD; 167 p9_client_cb(chan->client, req, REQ_STATUS_RCVD);
168 p9_client_cb(chan->client, req);
169 } 168 }
170} 169}
171 170
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 8215f7cb170b..ba291ce4bdff 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -68,7 +68,7 @@ static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
68 68
69 sk = sk_atm(atmarpd); 69 sk = sk_atm(atmarpd);
70 skb_queue_tail(&sk->sk_receive_queue, skb); 70 skb_queue_tail(&sk->sk_receive_queue, skb);
71 sk->sk_data_ready(sk, skb->len); 71 sk->sk_data_ready(sk);
72 return 0; 72 return 0;
73} 73}
74 74
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 5a2f602d07e1..4c5b8ba0f84f 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -152,7 +152,7 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
152 atm_force_charge(priv->lecd, skb2->truesize); 152 atm_force_charge(priv->lecd, skb2->truesize);
153 sk = sk_atm(priv->lecd); 153 sk = sk_atm(priv->lecd);
154 skb_queue_tail(&sk->sk_receive_queue, skb2); 154 skb_queue_tail(&sk->sk_receive_queue, skb2);
155 sk->sk_data_ready(sk, skb2->len); 155 sk->sk_data_ready(sk);
156 } 156 }
157} 157}
158#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 158#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
@@ -447,7 +447,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
447 atm_force_charge(priv->lecd, skb2->truesize); 447 atm_force_charge(priv->lecd, skb2->truesize);
448 sk = sk_atm(priv->lecd); 448 sk = sk_atm(priv->lecd);
449 skb_queue_tail(&sk->sk_receive_queue, skb2); 449 skb_queue_tail(&sk->sk_receive_queue, skb2);
450 sk->sk_data_ready(sk, skb2->len); 450 sk->sk_data_ready(sk);
451 } 451 }
452 } 452 }
453#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 453#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
@@ -530,13 +530,13 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
530 atm_force_charge(priv->lecd, skb->truesize); 530 atm_force_charge(priv->lecd, skb->truesize);
531 sk = sk_atm(priv->lecd); 531 sk = sk_atm(priv->lecd);
532 skb_queue_tail(&sk->sk_receive_queue, skb); 532 skb_queue_tail(&sk->sk_receive_queue, skb);
533 sk->sk_data_ready(sk, skb->len); 533 sk->sk_data_ready(sk);
534 534
535 if (data != NULL) { 535 if (data != NULL) {
536 pr_debug("about to send %d bytes of data\n", data->len); 536 pr_debug("about to send %d bytes of data\n", data->len);
537 atm_force_charge(priv->lecd, data->truesize); 537 atm_force_charge(priv->lecd, data->truesize);
538 skb_queue_tail(&sk->sk_receive_queue, data); 538 skb_queue_tail(&sk->sk_receive_queue, data);
539 sk->sk_data_ready(sk, skb->len); 539 sk->sk_data_ready(sk);
540 } 540 }
541 541
542 return 0; 542 return 0;
@@ -616,7 +616,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
616 616
617 pr_debug("%s: To daemon\n", dev->name); 617 pr_debug("%s: To daemon\n", dev->name);
618 skb_queue_tail(&sk->sk_receive_queue, skb); 618 skb_queue_tail(&sk->sk_receive_queue, skb);
619 sk->sk_data_ready(sk, skb->len); 619 sk->sk_data_ready(sk);
620 } else { /* Data frame, queue to protocol handlers */ 620 } else { /* Data frame, queue to protocol handlers */
621 struct lec_arp_table *entry; 621 struct lec_arp_table *entry;
622 unsigned char *src, *dst; 622 unsigned char *src, *dst;
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 91dc58f1124d..e8e0e7a8a23d 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -706,7 +706,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
706 dprintk("(%s) control packet arrived\n", dev->name); 706 dprintk("(%s) control packet arrived\n", dev->name);
707 /* Pass control packets to daemon */ 707 /* Pass control packets to daemon */
708 skb_queue_tail(&sk->sk_receive_queue, skb); 708 skb_queue_tail(&sk->sk_receive_queue, skb);
709 sk->sk_data_ready(sk, skb->len); 709 sk->sk_data_ready(sk);
710 return; 710 return;
711 } 711 }
712 712
@@ -992,7 +992,7 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc)
992 992
993 sk = sk_atm(mpc->mpoad_vcc); 993 sk = sk_atm(mpc->mpoad_vcc);
994 skb_queue_tail(&sk->sk_receive_queue, skb); 994 skb_queue_tail(&sk->sk_receive_queue, skb);
995 sk->sk_data_ready(sk, skb->len); 995 sk->sk_data_ready(sk);
996 996
997 return 0; 997 return 0;
998} 998}
@@ -1273,7 +1273,7 @@ static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry)
1273 1273
1274 sk = sk_atm(vcc); 1274 sk = sk_atm(vcc);
1275 skb_queue_tail(&sk->sk_receive_queue, skb); 1275 skb_queue_tail(&sk->sk_receive_queue, skb);
1276 sk->sk_data_ready(sk, skb->len); 1276 sk->sk_data_ready(sk);
1277 dprintk("exiting\n"); 1277 dprintk("exiting\n");
1278} 1278}
1279 1279
diff --git a/net/atm/raw.c b/net/atm/raw.c
index b4f7b9ff3c74..2e17e97a7a8b 100644
--- a/net/atm/raw.c
+++ b/net/atm/raw.c
@@ -25,7 +25,7 @@ static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
25 struct sock *sk = sk_atm(vcc); 25 struct sock *sk = sk_atm(vcc);
26 26
27 skb_queue_tail(&sk->sk_receive_queue, skb); 27 skb_queue_tail(&sk->sk_receive_queue, skb);
28 sk->sk_data_ready(sk, skb->len); 28 sk->sk_data_ready(sk);
29 } 29 }
30} 30}
31 31
diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index 4176887e72eb..523bce72f698 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -51,7 +51,7 @@ static void sigd_put_skb(struct sk_buff *skb)
51#endif 51#endif
52 atm_force_charge(sigd, skb->truesize); 52 atm_force_charge(sigd, skb->truesize);
53 skb_queue_tail(&sk_atm(sigd)->sk_receive_queue, skb); 53 skb_queue_tail(&sk_atm(sigd)->sk_receive_queue, skb);
54 sk_atm(sigd)->sk_data_ready(sk_atm(sigd), skb->len); 54 sk_atm(sigd)->sk_data_ready(sk_atm(sigd));
55} 55}
56 56
57static void modify_qos(struct atm_vcc *vcc, struct atmsvc_msg *msg) 57static void modify_qos(struct atm_vcc *vcc, struct atmsvc_msg *msg)
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 96f4cab3a2f9..7ed8ab724819 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -422,7 +422,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
422 422
423 if (sk) { 423 if (sk) {
424 if (!sock_flag(sk, SOCK_DEAD)) 424 if (!sock_flag(sk, SOCK_DEAD))
425 sk->sk_data_ready(sk, skb->len); 425 sk->sk_data_ready(sk);
426 sock_put(sk); 426 sock_put(sk);
427 } else { 427 } else {
428free: 428free:
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f59e00c2daa9..ef5e5b04f34f 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1271,7 +1271,7 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
1271 1271
1272 if (parent) { 1272 if (parent) {
1273 bt_accept_unlink(sk); 1273 bt_accept_unlink(sk);
1274 parent->sk_data_ready(parent, 0); 1274 parent->sk_data_ready(parent);
1275 } else { 1275 } else {
1276 sk->sk_state_change(sk); 1276 sk->sk_state_change(sk);
1277 } 1277 }
@@ -1327,7 +1327,7 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
1327 sk->sk_state_change(sk); 1327 sk->sk_state_change(sk);
1328 1328
1329 if (parent) 1329 if (parent)
1330 parent->sk_data_ready(parent, 0); 1330 parent->sk_data_ready(parent);
1331 1331
1332 release_sock(sk); 1332 release_sock(sk);
1333} 1333}
@@ -1340,7 +1340,7 @@ static void l2cap_sock_defer_cb(struct l2cap_chan *chan)
1340 1340
1341 parent = bt_sk(sk)->parent; 1341 parent = bt_sk(sk)->parent;
1342 if (parent) 1342 if (parent)
1343 parent->sk_data_ready(parent, 0); 1343 parent->sk_data_ready(parent);
1344 1344
1345 release_sock(sk); 1345 release_sock(sk);
1346} 1346}
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 633cceeb943e..cf620260affa 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -186,9 +186,9 @@ static void rfcomm_l2state_change(struct sock *sk)
186 rfcomm_schedule(); 186 rfcomm_schedule();
187} 187}
188 188
189static void rfcomm_l2data_ready(struct sock *sk, int bytes) 189static void rfcomm_l2data_ready(struct sock *sk)
190{ 190{
191 BT_DBG("%p bytes %d", sk, bytes); 191 BT_DBG("%p", sk);
192 rfcomm_schedule(); 192 rfcomm_schedule();
193} 193}
194 194
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index eabd25ab5ad9..c603a5eb4720 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -54,7 +54,7 @@ static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb)
54 54
55 atomic_add(skb->len, &sk->sk_rmem_alloc); 55 atomic_add(skb->len, &sk->sk_rmem_alloc);
56 skb_queue_tail(&sk->sk_receive_queue, skb); 56 skb_queue_tail(&sk->sk_receive_queue, skb);
57 sk->sk_data_ready(sk, skb->len); 57 sk->sk_data_ready(sk);
58 58
59 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) 59 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
60 rfcomm_dlc_throttle(d); 60 rfcomm_dlc_throttle(d);
@@ -84,7 +84,7 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
84 sock_set_flag(sk, SOCK_ZAPPED); 84 sock_set_flag(sk, SOCK_ZAPPED);
85 bt_accept_unlink(sk); 85 bt_accept_unlink(sk);
86 } 86 }
87 parent->sk_data_ready(parent, 0); 87 parent->sk_data_ready(parent);
88 } else { 88 } else {
89 if (d->state == BT_CONNECTED) 89 if (d->state == BT_CONNECTED)
90 rfcomm_session_getaddr(d->session, 90 rfcomm_session_getaddr(d->session,
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index ab1e6fcca4c5..c06dbd3938e8 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1024,7 +1024,7 @@ static void sco_conn_ready(struct sco_conn *conn)
1024 sk->sk_state = BT_CONNECTED; 1024 sk->sk_state = BT_CONNECTED;
1025 1025
1026 /* Wake up parent */ 1026 /* Wake up parent */
1027 parent->sk_data_ready(parent, 1); 1027 parent->sk_data_ready(parent);
1028 1028
1029 bh_unlock_sock(parent); 1029 bh_unlock_sock(parent);
1030 1030
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index d0cca3c65f01..7985deaff52f 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -73,7 +73,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
73 goto drop; 73 goto drop;
74 74
75 if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid)) 75 if (!br_allowed_ingress(p->br, nbp_get_vlan_info(p), skb, &vid))
76 goto drop; 76 goto out;
77 77
78 /* insert into forwarding database after filtering to avoid spoofing */ 78 /* insert into forwarding database after filtering to avoid spoofing */
79 br = p->br; 79 br = p->br;
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 91510712c7a7..4a3716102789 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -170,7 +170,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
170 * rejected. 170 * rejected.
171 */ 171 */
172 if (!v) 172 if (!v)
173 return false; 173 goto drop;
174 174
175 /* If vlan tx offload is disabled on bridge device and frame was 175 /* If vlan tx offload is disabled on bridge device and frame was
176 * sent from vlan device on the bridge device, it does not have 176 * sent from vlan device on the bridge device, it does not have
@@ -193,7 +193,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
193 * vlan untagged or priority-tagged traffic belongs to. 193 * vlan untagged or priority-tagged traffic belongs to.
194 */ 194 */
195 if (pvid == VLAN_N_VID) 195 if (pvid == VLAN_N_VID)
196 return false; 196 goto drop;
197 197
198 /* PVID is set on this port. Any untagged or priority-tagged 198 /* PVID is set on this port. Any untagged or priority-tagged
199 * ingress frame is considered to belong to this vlan. 199 * ingress frame is considered to belong to this vlan.
@@ -216,7 +216,8 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
216 /* Frame had a valid vlan tag. See if vlan is allowed */ 216 /* Frame had a valid vlan tag. See if vlan is allowed */
217 if (test_bit(*vid, v->vlan_bitmap)) 217 if (test_bit(*vid, v->vlan_bitmap))
218 return true; 218 return true;
219 219drop:
220 kfree_skb(skb);
220 return false; 221 return false;
221} 222}
222 223
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index d6be3edb7a43..e8437094d15f 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -124,7 +124,6 @@ static void caif_flow_ctrl(struct sock *sk, int mode)
124static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) 124static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
125{ 125{
126 int err; 126 int err;
127 int skb_len;
128 unsigned long flags; 127 unsigned long flags;
129 struct sk_buff_head *list = &sk->sk_receive_queue; 128 struct sk_buff_head *list = &sk->sk_receive_queue;
130 struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); 129 struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
@@ -153,14 +152,13 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
153 * may be freed by other threads of control pulling packets 152 * may be freed by other threads of control pulling packets
154 * from the queue. 153 * from the queue.
155 */ 154 */
156 skb_len = skb->len;
157 spin_lock_irqsave(&list->lock, flags); 155 spin_lock_irqsave(&list->lock, flags);
158 if (!sock_flag(sk, SOCK_DEAD)) 156 if (!sock_flag(sk, SOCK_DEAD))
159 __skb_queue_tail(list, skb); 157 __skb_queue_tail(list, skb);
160 spin_unlock_irqrestore(&list->lock, flags); 158 spin_unlock_irqrestore(&list->lock, flags);
161 159
162 if (!sock_flag(sk, SOCK_DEAD)) 160 if (!sock_flag(sk, SOCK_DEAD))
163 sk->sk_data_ready(sk, skb_len); 161 sk->sk_data_ready(sk);
164 else 162 else
165 kfree_skb(skb); 163 kfree_skb(skb);
166 return 0; 164 return 0;
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 4f55f9ce63fa..dac7f9b98687 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -383,7 +383,7 @@ static void con_sock_state_closed(struct ceph_connection *con)
383 */ 383 */
384 384
385/* data available on socket, or listen socket received a connect */ 385/* data available on socket, or listen socket received a connect */
386static void ceph_sock_data_ready(struct sock *sk, int count_unused) 386static void ceph_sock_data_ready(struct sock *sk)
387{ 387{
388 struct ceph_connection *con = sk->sk_user_data; 388 struct ceph_connection *con = sk->sk_user_data;
389 if (atomic_read(&con->msgr->stopping)) { 389 if (atomic_read(&con->msgr->stopping)) {
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index d068ec25db1e..0304f981f7ff 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3338,7 +3338,9 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3338 queue_map = skb_get_queue_mapping(pkt_dev->skb); 3338 queue_map = skb_get_queue_mapping(pkt_dev->skb);
3339 txq = netdev_get_tx_queue(odev, queue_map); 3339 txq = netdev_get_tx_queue(odev, queue_map);
3340 3340
3341 __netif_tx_lock_bh(txq); 3341 local_bh_disable();
3342
3343 HARD_TX_LOCK(odev, txq, smp_processor_id());
3342 3344
3343 if (unlikely(netif_xmit_frozen_or_drv_stopped(txq))) { 3345 if (unlikely(netif_xmit_frozen_or_drv_stopped(txq))) {
3344 ret = NETDEV_TX_BUSY; 3346 ret = NETDEV_TX_BUSY;
@@ -3374,7 +3376,9 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
3374 pkt_dev->last_ok = 0; 3376 pkt_dev->last_ok = 0;
3375 } 3377 }
3376unlock: 3378unlock:
3377 __netif_tx_unlock_bh(txq); 3379 HARD_TX_UNLOCK(odev, txq);
3380
3381 local_bh_enable();
3378 3382
3379 /* If pkt_dev->count is zero, then run forever */ 3383 /* If pkt_dev->count is zero, then run forever */
3380 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) { 3384 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 30c7d35dd862..1b62343f5837 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3458,8 +3458,6 @@ static void sock_rmem_free(struct sk_buff *skb)
3458 */ 3458 */
3459int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb) 3459int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
3460{ 3460{
3461 int len = skb->len;
3462
3463 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 3461 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
3464 (unsigned int)sk->sk_rcvbuf) 3462 (unsigned int)sk->sk_rcvbuf)
3465 return -ENOMEM; 3463 return -ENOMEM;
@@ -3474,7 +3472,7 @@ int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
3474 3472
3475 skb_queue_tail(&sk->sk_error_queue, skb); 3473 skb_queue_tail(&sk->sk_error_queue, skb);
3476 if (!sock_flag(sk, SOCK_DEAD)) 3474 if (!sock_flag(sk, SOCK_DEAD))
3477 sk->sk_data_ready(sk, len); 3475 sk->sk_data_ready(sk);
3478 return 0; 3476 return 0;
3479} 3477}
3480EXPORT_SYMBOL(sock_queue_err_skb); 3478EXPORT_SYMBOL(sock_queue_err_skb);
@@ -3937,12 +3935,14 @@ EXPORT_SYMBOL_GPL(skb_scrub_packet);
3937unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) 3935unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
3938{ 3936{
3939 const struct skb_shared_info *shinfo = skb_shinfo(skb); 3937 const struct skb_shared_info *shinfo = skb_shinfo(skb);
3940 unsigned int hdr_len;
3941 3938
3942 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) 3939 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
3943 hdr_len = tcp_hdrlen(skb); 3940 return tcp_hdrlen(skb) + shinfo->gso_size;
3944 else 3941
3945 hdr_len = sizeof(struct udphdr); 3942 /* UFO sets gso_size to the size of the fragmentation
3946 return hdr_len + shinfo->gso_size; 3943 * payload, i.e. the size of the L4 (UDP) header is already
3944 * accounted for.
3945 */
3946 return shinfo->gso_size;
3947} 3947}
3948EXPORT_SYMBOL_GPL(skb_gso_transport_seglen); 3948EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
diff --git a/net/core/sock.c b/net/core/sock.c
index c0fc6bdad1e3..b4fff008136f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -428,7 +428,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
428 spin_unlock_irqrestore(&list->lock, flags); 428 spin_unlock_irqrestore(&list->lock, flags);
429 429
430 if (!sock_flag(sk, SOCK_DEAD)) 430 if (!sock_flag(sk, SOCK_DEAD))
431 sk->sk_data_ready(sk, skb_len); 431 sk->sk_data_ready(sk);
432 return 0; 432 return 0;
433} 433}
434EXPORT_SYMBOL(sock_queue_rcv_skb); 434EXPORT_SYMBOL(sock_queue_rcv_skb);
@@ -2196,7 +2196,7 @@ static void sock_def_error_report(struct sock *sk)
2196 rcu_read_unlock(); 2196 rcu_read_unlock();
2197} 2197}
2198 2198
2199static void sock_def_readable(struct sock *sk, int len) 2199static void sock_def_readable(struct sock *sk)
2200{ 2200{
2201 struct socket_wq *wq; 2201 struct socket_wq *wq;
2202 2202
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 14cdafad7a90..3c8ec7d4a34e 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -28,7 +28,7 @@ static void dccp_enqueue_skb(struct sock *sk, struct sk_buff *skb)
28 __skb_pull(skb, dccp_hdr(skb)->dccph_doff * 4); 28 __skb_pull(skb, dccp_hdr(skb)->dccph_doff * 4);
29 __skb_queue_tail(&sk->sk_receive_queue, skb); 29 __skb_queue_tail(&sk->sk_receive_queue, skb);
30 skb_set_owner_r(skb, sk); 30 skb_set_owner_r(skb, sk);
31 sk->sk_data_ready(sk, 0); 31 sk->sk_data_ready(sk);
32} 32}
33 33
34static void dccp_fin(struct sock *sk, struct sk_buff *skb) 34static void dccp_fin(struct sock *sk, struct sk_buff *skb)
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 9e2f78bc1553..c69eb9c4fbb8 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -237,7 +237,7 @@ int dccp_child_process(struct sock *parent, struct sock *child,
237 237
238 /* Wakeup parent, send SIGIO */ 238 /* Wakeup parent, send SIGIO */
239 if (state == DCCP_RESPOND && child->sk_state != state) 239 if (state == DCCP_RESPOND && child->sk_state != state)
240 parent->sk_data_ready(parent, 0); 240 parent->sk_data_ready(parent);
241 } else { 241 } else {
242 /* Alas, it is possible again, because we do lookup 242 /* Alas, it is possible again, because we do lookup
243 * in main socket hash table and lock on listening 243 * in main socket hash table and lock on listening
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index c344163e6ac0..fe5f01485d33 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -585,7 +585,6 @@ out:
585static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig, struct sk_buff_head *queue) 585static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig, struct sk_buff_head *queue)
586{ 586{
587 int err; 587 int err;
588 int skb_len;
589 588
590 /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces 589 /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
591 number of warnings when compiling with -W --ANK 590 number of warnings when compiling with -W --ANK
@@ -600,12 +599,11 @@ static __inline__ int dn_queue_skb(struct sock *sk, struct sk_buff *skb, int sig
600 if (err) 599 if (err)
601 goto out; 600 goto out;
602 601
603 skb_len = skb->len;
604 skb_set_owner_r(skb, sk); 602 skb_set_owner_r(skb, sk);
605 skb_queue_tail(queue, skb); 603 skb_queue_tail(queue, skb);
606 604
607 if (!sock_flag(sk, SOCK_DEAD)) 605 if (!sock_flag(sk, SOCK_DEAD))
608 sk->sk_data_ready(sk, skb_len); 606 sk->sk_data_ready(sk);
609out: 607out:
610 return err; 608 return err;
611} 609}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index ec4f762efda5..94213c891565 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -463,6 +463,7 @@ static const struct net_device_ops ipgre_netdev_ops = {
463static void ipgre_tunnel_setup(struct net_device *dev) 463static void ipgre_tunnel_setup(struct net_device *dev)
464{ 464{
465 dev->netdev_ops = &ipgre_netdev_ops; 465 dev->netdev_ops = &ipgre_netdev_ops;
466 dev->type = ARPHRD_IPGRE;
466 ip_tunnel_setup(dev, ipgre_net_id); 467 ip_tunnel_setup(dev, ipgre_net_id);
467} 468}
468 469
@@ -501,7 +502,6 @@ static int ipgre_tunnel_init(struct net_device *dev)
501 memcpy(dev->dev_addr, &iph->saddr, 4); 502 memcpy(dev->dev_addr, &iph->saddr, 4);
502 memcpy(dev->broadcast, &iph->daddr, 4); 503 memcpy(dev->broadcast, &iph->daddr, 4);
503 504
504 dev->type = ARPHRD_IPGRE;
505 dev->flags = IFF_NOARP; 505 dev->flags = IFF_NOARP;
506 dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; 506 dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
507 dev->addr_len = 4; 507 dev->addr_len = 4;
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 687ddef4e574..afcee51b90ed 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -337,6 +337,7 @@ static const struct net_device_ops vti_netdev_ops = {
337static void vti_tunnel_setup(struct net_device *dev) 337static void vti_tunnel_setup(struct net_device *dev)
338{ 338{
339 dev->netdev_ops = &vti_netdev_ops; 339 dev->netdev_ops = &vti_netdev_ops;
340 dev->type = ARPHRD_TUNNEL;
340 ip_tunnel_setup(dev, vti_net_id); 341 ip_tunnel_setup(dev, vti_net_id);
341} 342}
342 343
@@ -348,7 +349,6 @@ static int vti_tunnel_init(struct net_device *dev)
348 memcpy(dev->dev_addr, &iph->saddr, 4); 349 memcpy(dev->dev_addr, &iph->saddr, 4);
349 memcpy(dev->broadcast, &iph->daddr, 4); 350 memcpy(dev->broadcast, &iph->daddr, 4);
350 351
351 dev->type = ARPHRD_TUNNEL;
352 dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); 352 dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr);
353 dev->mtu = ETH_DATA_LEN; 353 dev->mtu = ETH_DATA_LEN;
354 dev->flags = IFF_NOARP; 354 dev->flags = IFF_NOARP;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e1661f46fd19..d6b46eb2f94c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4413,7 +4413,7 @@ queue_and_out:
4413 if (eaten > 0) 4413 if (eaten > 0)
4414 kfree_skb_partial(skb, fragstolen); 4414 kfree_skb_partial(skb, fragstolen);
4415 if (!sock_flag(sk, SOCK_DEAD)) 4415 if (!sock_flag(sk, SOCK_DEAD))
4416 sk->sk_data_ready(sk, 0); 4416 sk->sk_data_ready(sk);
4417 return; 4417 return;
4418 } 4418 }
4419 4419
@@ -4914,7 +4914,7 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t
4914 BUG(); 4914 BUG();
4915 tp->urg_data = TCP_URG_VALID | tmp; 4915 tp->urg_data = TCP_URG_VALID | tmp;
4916 if (!sock_flag(sk, SOCK_DEAD)) 4916 if (!sock_flag(sk, SOCK_DEAD))
4917 sk->sk_data_ready(sk, 0); 4917 sk->sk_data_ready(sk);
4918 } 4918 }
4919 } 4919 }
4920} 4920}
@@ -5000,11 +5000,11 @@ static bool tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb,
5000 (tcp_flag_word(tcp_hdr(skb)) & TCP_FLAG_PSH) || 5000 (tcp_flag_word(tcp_hdr(skb)) & TCP_FLAG_PSH) ||
5001 (atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1))) { 5001 (atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1))) {
5002 tp->ucopy.wakeup = 1; 5002 tp->ucopy.wakeup = 1;
5003 sk->sk_data_ready(sk, 0); 5003 sk->sk_data_ready(sk);
5004 } 5004 }
5005 } else if (chunk > 0) { 5005 } else if (chunk > 0) {
5006 tp->ucopy.wakeup = 1; 5006 tp->ucopy.wakeup = 1;
5007 sk->sk_data_ready(sk, 0); 5007 sk->sk_data_ready(sk);
5008 } 5008 }
5009out: 5009out:
5010 return copied_early; 5010 return copied_early;
@@ -5275,7 +5275,7 @@ no_ack:
5275#endif 5275#endif
5276 if (eaten) 5276 if (eaten)
5277 kfree_skb_partial(skb, fragstolen); 5277 kfree_skb_partial(skb, fragstolen);
5278 sk->sk_data_ready(sk, 0); 5278 sk->sk_data_ready(sk);
5279 return; 5279 return;
5280 } 5280 }
5281 } 5281 }
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6379894ec210..438f3b95143d 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1434,7 +1434,7 @@ static int tcp_v4_conn_req_fastopen(struct sock *sk,
1434 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 1434 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
1435 tp->syn_data_acked = 1; 1435 tp->syn_data_acked = 1;
1436 } 1436 }
1437 sk->sk_data_ready(sk, 0); 1437 sk->sk_data_ready(sk);
1438 bh_unlock_sock(child); 1438 bh_unlock_sock(child);
1439 sock_put(child); 1439 sock_put(child);
1440 WARN_ON(req->sk == NULL); 1440 WARN_ON(req->sk == NULL);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ca788ada5bd3..05c1b155251d 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -745,7 +745,7 @@ int tcp_child_process(struct sock *parent, struct sock *child,
745 skb->len); 745 skb->len);
746 /* Wakeup parent, send SIGIO */ 746 /* Wakeup parent, send SIGIO */
747 if (state == TCP_SYN_RECV && child->sk_state != state) 747 if (state == TCP_SYN_RECV && child->sk_state != state)
748 parent->sk_data_ready(parent, 0); 748 parent->sk_data_ready(parent);
749 } else { 749 } else {
750 /* Alas, it is possible again, because we do lookup 750 /* Alas, it is possible again, because we do lookup
751 * in main socket hash table and lock on listening 751 * in main socket hash table and lock on listening
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5ca56cee2dae..e289830ed6e3 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -798,7 +798,7 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,
798 __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr); 798 __tcp_v6_send_check(buff, &fl6.saddr, &fl6.daddr);
799 799
800 fl6.flowi6_proto = IPPROTO_TCP; 800 fl6.flowi6_proto = IPPROTO_TCP;
801 if (rt6_need_strict(&fl6.daddr) || !oif) 801 if (rt6_need_strict(&fl6.daddr) && !oif)
802 fl6.flowi6_oif = inet6_iif(skb); 802 fl6.flowi6_oif = inet6_iif(skb);
803 else 803 else
804 fl6.flowi6_oif = oif; 804 fl6.flowi6_oif = oif;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index a5e03119107a..01e77b0ae075 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1757,7 +1757,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
1757 1757
1758 /* Wake up accept */ 1758 /* Wake up accept */
1759 nsk->sk_state = IUCV_CONNECTED; 1759 nsk->sk_state = IUCV_CONNECTED;
1760 sk->sk_data_ready(sk, 1); 1760 sk->sk_data_ready(sk);
1761 err = 0; 1761 err = 0;
1762fail: 1762fail:
1763 bh_unlock_sock(sk); 1763 bh_unlock_sock(sk);
@@ -1968,7 +1968,7 @@ static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb)
1968 if (!err) { 1968 if (!err) {
1969 iucv_accept_enqueue(sk, nsk); 1969 iucv_accept_enqueue(sk, nsk);
1970 nsk->sk_state = IUCV_CONNECTED; 1970 nsk->sk_state = IUCV_CONNECTED;
1971 sk->sk_data_ready(sk, 1); 1971 sk->sk_data_ready(sk);
1972 } else 1972 } else
1973 iucv_sock_kill(nsk); 1973 iucv_sock_kill(nsk);
1974 bh_unlock_sock(sk); 1974 bh_unlock_sock(sk);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index e72589a8400d..f3c83073afc4 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -205,7 +205,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
205 if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) { 205 if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) {
206 skb_set_owner_r(*skb2, sk); 206 skb_set_owner_r(*skb2, sk);
207 skb_queue_tail(&sk->sk_receive_queue, *skb2); 207 skb_queue_tail(&sk->sk_receive_queue, *skb2);
208 sk->sk_data_ready(sk, (*skb2)->len); 208 sk->sk_data_ready(sk);
209 *skb2 = NULL; 209 *skb2 = NULL;
210 err = 0; 210 err = 0;
211 } 211 }
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index d276e2d4a589..950909f04ee6 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -753,9 +753,9 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
753 session->deref = pppol2tp_session_sock_put; 753 session->deref = pppol2tp_session_sock_put;
754 754
755 /* If PMTU discovery was enabled, use the MTU that was discovered */ 755 /* If PMTU discovery was enabled, use the MTU that was discovered */
756 dst = sk_dst_get(sk); 756 dst = sk_dst_get(tunnel->sock);
757 if (dst != NULL) { 757 if (dst != NULL) {
758 u32 pmtu = dst_mtu(__sk_dst_get(sk)); 758 u32 pmtu = dst_mtu(__sk_dst_get(tunnel->sock));
759 if (pmtu != 0) 759 if (pmtu != 0)
760 session->mtu = session->mru = pmtu - 760 session->mtu = session->mru = pmtu -
761 PPPOL2TP_HEADER_OVERHEAD; 761 PPPOL2TP_HEADER_OVERHEAD;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index c2d585c4f7c5..894cda0206bb 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1653,7 +1653,7 @@ static int __netlink_sendskb(struct sock *sk, struct sk_buff *skb)
1653 else 1653 else
1654#endif /* CONFIG_NETLINK_MMAP */ 1654#endif /* CONFIG_NETLINK_MMAP */
1655 skb_queue_tail(&sk->sk_receive_queue, skb); 1655 skb_queue_tail(&sk->sk_receive_queue, skb);
1656 sk->sk_data_ready(sk, len); 1656 sk->sk_data_ready(sk);
1657 return len; 1657 return len;
1658} 1658}
1659 1659
@@ -2394,7 +2394,7 @@ out:
2394 return err ? : copied; 2394 return err ? : copied;
2395} 2395}
2396 2396
2397static void netlink_data_ready(struct sock *sk, int len) 2397static void netlink_data_ready(struct sock *sk)
2398{ 2398{
2399 BUG(); 2399 BUG();
2400} 2400}
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index b74aa0755521..ede50d197e10 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1011,7 +1011,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
1011 skb_queue_head(&sk->sk_receive_queue, skb); 1011 skb_queue_head(&sk->sk_receive_queue, skb);
1012 1012
1013 if (!sock_flag(sk, SOCK_DEAD)) 1013 if (!sock_flag(sk, SOCK_DEAD))
1014 sk->sk_data_ready(sk, skb->len); 1014 sk->sk_data_ready(sk);
1015 1015
1016 bh_unlock_sock(sk); 1016 bh_unlock_sock(sk);
1017 1017
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index b486f12ae243..b4671958fcf9 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -976,7 +976,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
976 new_sk->sk_state = LLCP_CONNECTED; 976 new_sk->sk_state = LLCP_CONNECTED;
977 977
978 /* Wake the listening processes */ 978 /* Wake the listening processes */
979 parent->sk_data_ready(parent, 0); 979 parent->sk_data_ready(parent);
980 980
981 /* Send CC */ 981 /* Send CC */
982 nfc_llcp_send_cc(new_sock); 982 nfc_llcp_send_cc(new_sock);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 72e0c71fb01d..b85c67ccb797 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1848,7 +1848,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
1848 skb->dropcount = atomic_read(&sk->sk_drops); 1848 skb->dropcount = atomic_read(&sk->sk_drops);
1849 __skb_queue_tail(&sk->sk_receive_queue, skb); 1849 __skb_queue_tail(&sk->sk_receive_queue, skb);
1850 spin_unlock(&sk->sk_receive_queue.lock); 1850 spin_unlock(&sk->sk_receive_queue.lock);
1851 sk->sk_data_ready(sk, skb->len); 1851 sk->sk_data_ready(sk);
1852 return 0; 1852 return 0;
1853 1853
1854drop_n_acct: 1854drop_n_acct:
@@ -2054,7 +2054,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2054 else 2054 else
2055 prb_clear_blk_fill_status(&po->rx_ring); 2055 prb_clear_blk_fill_status(&po->rx_ring);
2056 2056
2057 sk->sk_data_ready(sk, 0); 2057 sk->sk_data_ready(sk);
2058 2058
2059drop_n_restore: 2059drop_n_restore:
2060 if (skb_head != skb->data && skb_shared(skb)) { 2060 if (skb_head != skb->data && skb_shared(skb)) {
@@ -2069,7 +2069,7 @@ ring_is_full:
2069 po->stats.stats1.tp_drops++; 2069 po->stats.stats1.tp_drops++;
2070 spin_unlock(&sk->sk_receive_queue.lock); 2070 spin_unlock(&sk->sk_receive_queue.lock);
2071 2071
2072 sk->sk_data_ready(sk, 0); 2072 sk->sk_data_ready(sk);
2073 kfree_skb(copy_skb); 2073 kfree_skb(copy_skb);
2074 goto drop_n_restore; 2074 goto drop_n_restore;
2075} 2075}
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index a2fba7edfd1f..66dc65e7c6a1 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -37,7 +37,7 @@
37struct gprs_dev { 37struct gprs_dev {
38 struct sock *sk; 38 struct sock *sk;
39 void (*old_state_change)(struct sock *); 39 void (*old_state_change)(struct sock *);
40 void (*old_data_ready)(struct sock *, int); 40 void (*old_data_ready)(struct sock *);
41 void (*old_write_space)(struct sock *); 41 void (*old_write_space)(struct sock *);
42 42
43 struct net_device *dev; 43 struct net_device *dev;
@@ -146,7 +146,7 @@ drop:
146 return err; 146 return err;
147} 147}
148 148
149static void gprs_data_ready(struct sock *sk, int len) 149static void gprs_data_ready(struct sock *sk)
150{ 150{
151 struct gprs_dev *gp = sk->sk_user_data; 151 struct gprs_dev *gp = sk->sk_user_data;
152 struct sk_buff *skb; 152 struct sk_buff *skb;
diff --git a/net/phonet/pep.c b/net/phonet/pep.c
index e77411735de8..70a547ea5177 100644
--- a/net/phonet/pep.c
+++ b/net/phonet/pep.c
@@ -462,10 +462,9 @@ out:
462queue: 462queue:
463 skb->dev = NULL; 463 skb->dev = NULL;
464 skb_set_owner_r(skb, sk); 464 skb_set_owner_r(skb, sk);
465 err = skb->len;
466 skb_queue_tail(queue, skb); 465 skb_queue_tail(queue, skb);
467 if (!sock_flag(sk, SOCK_DEAD)) 466 if (!sock_flag(sk, SOCK_DEAD))
468 sk->sk_data_ready(sk, err); 467 sk->sk_data_ready(sk);
469 return NET_RX_SUCCESS; 468 return NET_RX_SUCCESS;
470} 469}
471 470
@@ -587,10 +586,9 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
587 pn->rx_credits--; 586 pn->rx_credits--;
588 skb->dev = NULL; 587 skb->dev = NULL;
589 skb_set_owner_r(skb, sk); 588 skb_set_owner_r(skb, sk);
590 err = skb->len;
591 skb_queue_tail(&sk->sk_receive_queue, skb); 589 skb_queue_tail(&sk->sk_receive_queue, skb);
592 if (!sock_flag(sk, SOCK_DEAD)) 590 if (!sock_flag(sk, SOCK_DEAD))
593 sk->sk_data_ready(sk, err); 591 sk->sk_data_ready(sk);
594 return NET_RX_SUCCESS; 592 return NET_RX_SUCCESS;
595 593
596 case PNS_PEP_CONNECT_RESP: 594 case PNS_PEP_CONNECT_RESP:
@@ -698,7 +696,7 @@ static int pep_do_rcv(struct sock *sk, struct sk_buff *skb)
698 skb_queue_head(&sk->sk_receive_queue, skb); 696 skb_queue_head(&sk->sk_receive_queue, skb);
699 sk_acceptq_added(sk); 697 sk_acceptq_added(sk);
700 if (!sock_flag(sk, SOCK_DEAD)) 698 if (!sock_flag(sk, SOCK_DEAD))
701 sk->sk_data_ready(sk, 0); 699 sk->sk_data_ready(sk);
702 return NET_RX_SUCCESS; 700 return NET_RX_SUCCESS;
703 701
704 case PNS_PEP_DISCONNECT_REQ: 702 case PNS_PEP_DISCONNECT_REQ:
diff --git a/net/rds/tcp.h b/net/rds/tcp.h
index 9cf2927d0021..65637491f728 100644
--- a/net/rds/tcp.h
+++ b/net/rds/tcp.h
@@ -61,12 +61,12 @@ void rds_tcp_state_change(struct sock *sk);
61/* tcp_listen.c */ 61/* tcp_listen.c */
62int rds_tcp_listen_init(void); 62int rds_tcp_listen_init(void);
63void rds_tcp_listen_stop(void); 63void rds_tcp_listen_stop(void);
64void rds_tcp_listen_data_ready(struct sock *sk, int bytes); 64void rds_tcp_listen_data_ready(struct sock *sk);
65 65
66/* tcp_recv.c */ 66/* tcp_recv.c */
67int rds_tcp_recv_init(void); 67int rds_tcp_recv_init(void);
68void rds_tcp_recv_exit(void); 68void rds_tcp_recv_exit(void);
69void rds_tcp_data_ready(struct sock *sk, int bytes); 69void rds_tcp_data_ready(struct sock *sk);
70int rds_tcp_recv(struct rds_connection *conn); 70int rds_tcp_recv(struct rds_connection *conn);
71void rds_tcp_inc_free(struct rds_incoming *inc); 71void rds_tcp_inc_free(struct rds_incoming *inc);
72int rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iovec *iov, 72int rds_tcp_inc_copy_to_user(struct rds_incoming *inc, struct iovec *iov,
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index 7787537e9c2e..4e638f851185 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -108,9 +108,9 @@ static void rds_tcp_accept_worker(struct work_struct *work)
108 cond_resched(); 108 cond_resched();
109} 109}
110 110
111void rds_tcp_listen_data_ready(struct sock *sk, int bytes) 111void rds_tcp_listen_data_ready(struct sock *sk)
112{ 112{
113 void (*ready)(struct sock *sk, int bytes); 113 void (*ready)(struct sock *sk);
114 114
115 rdsdebug("listen data ready sk %p\n", sk); 115 rdsdebug("listen data ready sk %p\n", sk);
116 116
@@ -132,7 +132,7 @@ void rds_tcp_listen_data_ready(struct sock *sk, int bytes)
132 132
133out: 133out:
134 read_unlock(&sk->sk_callback_lock); 134 read_unlock(&sk->sk_callback_lock);
135 ready(sk, bytes); 135 ready(sk);
136} 136}
137 137
138int rds_tcp_listen_init(void) 138int rds_tcp_listen_init(void)
diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c
index 4fac4f2bb9dc..9ae6e0a264ec 100644
--- a/net/rds/tcp_recv.c
+++ b/net/rds/tcp_recv.c
@@ -314,13 +314,13 @@ int rds_tcp_recv(struct rds_connection *conn)
314 return ret; 314 return ret;
315} 315}
316 316
317void rds_tcp_data_ready(struct sock *sk, int bytes) 317void rds_tcp_data_ready(struct sock *sk)
318{ 318{
319 void (*ready)(struct sock *sk, int bytes); 319 void (*ready)(struct sock *sk);
320 struct rds_connection *conn; 320 struct rds_connection *conn;
321 struct rds_tcp_connection *tc; 321 struct rds_tcp_connection *tc;
322 322
323 rdsdebug("data ready sk %p bytes %d\n", sk, bytes); 323 rdsdebug("data ready sk %p\n", sk);
324 324
325 read_lock(&sk->sk_callback_lock); 325 read_lock(&sk->sk_callback_lock);
326 conn = sk->sk_user_data; 326 conn = sk->sk_user_data;
@@ -337,7 +337,7 @@ void rds_tcp_data_ready(struct sock *sk, int bytes)
337 queue_delayed_work(rds_wq, &conn->c_recv_w, 0); 337 queue_delayed_work(rds_wq, &conn->c_recv_w, 0);
338out: 338out:
339 read_unlock(&sk->sk_callback_lock); 339 read_unlock(&sk->sk_callback_lock);
340 ready(sk, bytes); 340 ready(sk);
341} 341}
342 342
343int rds_tcp_recv_init(void) 343int rds_tcp_recv_init(void)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index c2cca2ee6aef..8451c8cdc9de 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1041,7 +1041,7 @@ int rose_rx_call_request(struct sk_buff *skb, struct net_device *dev, struct ros
1041 rose_start_heartbeat(make); 1041 rose_start_heartbeat(make);
1042 1042
1043 if (!sock_flag(sk, SOCK_DEAD)) 1043 if (!sock_flag(sk, SOCK_DEAD))
1044 sk->sk_data_ready(sk, skb->len); 1044 sk->sk_data_ready(sk);
1045 1045
1046 return 1; 1046 return 1;
1047} 1047}
diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
index 73742647c135..63b21e580de9 100644
--- a/net/rxrpc/ar-input.c
+++ b/net/rxrpc/ar-input.c
@@ -113,7 +113,7 @@ int rxrpc_queue_rcv_skb(struct rxrpc_call *call, struct sk_buff *skb,
113 spin_unlock_bh(&sk->sk_receive_queue.lock); 113 spin_unlock_bh(&sk->sk_receive_queue.lock);
114 114
115 if (!sock_flag(sk, SOCK_DEAD)) 115 if (!sock_flag(sk, SOCK_DEAD))
116 sk->sk_data_ready(sk, skb_len); 116 sk->sk_data_ready(sk);
117 } 117 }
118 skb = NULL; 118 skb = NULL;
119 } else { 119 } else {
@@ -632,14 +632,14 @@ cant_find_conn:
632 * handle data received on the local endpoint 632 * handle data received on the local endpoint
633 * - may be called in interrupt context 633 * - may be called in interrupt context
634 */ 634 */
635void rxrpc_data_ready(struct sock *sk, int count) 635void rxrpc_data_ready(struct sock *sk)
636{ 636{
637 struct rxrpc_skb_priv *sp; 637 struct rxrpc_skb_priv *sp;
638 struct rxrpc_local *local; 638 struct rxrpc_local *local;
639 struct sk_buff *skb; 639 struct sk_buff *skb;
640 int ret; 640 int ret;
641 641
642 _enter("%p, %d", sk, count); 642 _enter("%p", sk);
643 643
644 ASSERT(!irqs_disabled()); 644 ASSERT(!irqs_disabled());
645 645
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index c831d44b0841..ba9fd36d3f15 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -518,7 +518,7 @@ void rxrpc_UDP_error_handler(struct work_struct *);
518 */ 518 */
519extern const char *rxrpc_pkts[]; 519extern const char *rxrpc_pkts[];
520 520
521void rxrpc_data_ready(struct sock *, int); 521void rxrpc_data_ready(struct sock *);
522int rxrpc_queue_rcv_skb(struct rxrpc_call *, struct sk_buff *, bool, bool); 522int rxrpc_queue_rcv_skb(struct rxrpc_call *, struct sk_buff *, bool, bool);
523void rxrpc_fast_process_packet(struct rxrpc_call *, struct sk_buff *); 523void rxrpc_fast_process_packet(struct rxrpc_call *, struct sk_buff *);
524 524
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 5f83a6a2fa67..e13519e9df80 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6604,6 +6604,12 @@ static void sctp_wake_up_waiters(struct sock *sk,
6604 if (asoc->ep->sndbuf_policy) 6604 if (asoc->ep->sndbuf_policy)
6605 return __sctp_write_space(asoc); 6605 return __sctp_write_space(asoc);
6606 6606
6607 /* If association goes down and is just flushing its
6608 * outq, then just normally notify others.
6609 */
6610 if (asoc->base.dead)
6611 return sctp_write_space(sk);
6612
6607 /* Accounting for the sndbuf space is per socket, so we 6613 /* Accounting for the sndbuf space is per socket, so we
6608 * need to wake up others, try to be fair and in case of 6614 * need to wake up others, try to be fair and in case of
6609 * other associations, let them have a go first instead 6615 * other associations, let them have a go first instead
@@ -6739,7 +6745,7 @@ do_nonblock:
6739 goto out; 6745 goto out;
6740} 6746}
6741 6747
6742void sctp_data_ready(struct sock *sk, int len) 6748void sctp_data_ready(struct sock *sk)
6743{ 6749{
6744 struct socket_wq *wq; 6750 struct socket_wq *wq;
6745 6751
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index 5dc94117e9d4..7144eb6a1b95 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -259,7 +259,7 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
259 sctp_ulpq_clear_pd(ulpq); 259 sctp_ulpq_clear_pd(ulpq);
260 260
261 if (queue == &sk->sk_receive_queue) 261 if (queue == &sk->sk_receive_queue)
262 sk->sk_data_ready(sk, 0); 262 sk->sk_data_ready(sk);
263 return 1; 263 return 1;
264 264
265out_free: 265out_free:
@@ -1135,5 +1135,5 @@ void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, gfp_t gfp)
1135 1135
1136 /* If there is data waiting, send it up the socket now. */ 1136 /* If there is data waiting, send it up the socket now. */
1137 if (sctp_ulpq_clear_pd(ulpq) || ev) 1137 if (sctp_ulpq_clear_pd(ulpq) || ev)
1138 sk->sk_data_ready(sk, 0); 1138 sk->sk_data_ready(sk);
1139} 1139}
diff --git a/net/sunrpc/Kconfig b/net/sunrpc/Kconfig
index 241b54f30204..0754d0f466d2 100644
--- a/net/sunrpc/Kconfig
+++ b/net/sunrpc/Kconfig
@@ -9,19 +9,6 @@ config SUNRPC_BACKCHANNEL
9 bool 9 bool
10 depends on SUNRPC 10 depends on SUNRPC
11 11
12config SUNRPC_XPRT_RDMA
13 tristate
14 depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS
15 default SUNRPC && INFINIBAND
16 help
17 This option allows the NFS client and server to support
18 an RDMA-enabled transport.
19
20 To compile RPC client RDMA transport support as a module,
21 choose M here: the module will be called xprtrdma.
22
23 If unsure, say N.
24
25config SUNRPC_SWAP 12config SUNRPC_SWAP
26 bool 13 bool
27 depends on SUNRPC 14 depends on SUNRPC
@@ -57,3 +44,29 @@ config SUNRPC_DEBUG
57 but makes troubleshooting NFS issues significantly harder. 44 but makes troubleshooting NFS issues significantly harder.
58 45
59 If unsure, say Y. 46 If unsure, say Y.
47
48config SUNRPC_XPRT_RDMA_CLIENT
49 tristate "RPC over RDMA Client Support"
50 depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS
51 default SUNRPC && INFINIBAND
52 help
53 This option allows the NFS client to support an RDMA-enabled
54 transport.
55
56 To compile RPC client RDMA transport support as a module,
57 choose M here: the module will be called xprtrdma.
58
59 If unsure, say N.
60
61config SUNRPC_XPRT_RDMA_SERVER
62 tristate "RPC over RDMA Server Support"
63 depends on SUNRPC && INFINIBAND && INFINIBAND_ADDR_TRANS
64 default SUNRPC && INFINIBAND
65 help
66 This option allows the NFS server to support an RDMA-enabled
67 transport.
68
69 To compile RPC server RDMA transport support as a module,
70 choose M here: the module will be called svcrdma.
71
72 If unsure, say N.
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile
index 8209a0411bca..e5a7a1cac8f3 100644
--- a/net/sunrpc/Makefile
+++ b/net/sunrpc/Makefile
@@ -5,7 +5,8 @@
5 5
6obj-$(CONFIG_SUNRPC) += sunrpc.o 6obj-$(CONFIG_SUNRPC) += sunrpc.o
7obj-$(CONFIG_SUNRPC_GSS) += auth_gss/ 7obj-$(CONFIG_SUNRPC_GSS) += auth_gss/
8obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma/ 8
9obj-y += xprtrdma/
9 10
10sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ 11sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \
11 auth.o auth_null.o auth_unix.o auth_generic.o \ 12 auth.o auth_null.o auth_unix.o auth_generic.o \
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index f400445d1a44..2e6ab10734f6 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -438,6 +438,38 @@ out_no_rpciod:
438 return ERR_PTR(err); 438 return ERR_PTR(err);
439} 439}
440 440
441struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
442 struct rpc_xprt *xprt)
443{
444 struct rpc_clnt *clnt = NULL;
445
446 clnt = rpc_new_client(args, xprt, NULL);
447 if (IS_ERR(clnt))
448 return clnt;
449
450 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
451 int err = rpc_ping(clnt);
452 if (err != 0) {
453 rpc_shutdown_client(clnt);
454 return ERR_PTR(err);
455 }
456 }
457
458 clnt->cl_softrtry = 1;
459 if (args->flags & RPC_CLNT_CREATE_HARDRTRY)
460 clnt->cl_softrtry = 0;
461
462 if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
463 clnt->cl_autobind = 1;
464 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
465 clnt->cl_discrtry = 1;
466 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
467 clnt->cl_chatty = 1;
468
469 return clnt;
470}
471EXPORT_SYMBOL_GPL(rpc_create_xprt);
472
441/** 473/**
442 * rpc_create - create an RPC client and transport with one call 474 * rpc_create - create an RPC client and transport with one call
443 * @args: rpc_clnt create argument structure 475 * @args: rpc_clnt create argument structure
@@ -451,7 +483,6 @@ out_no_rpciod:
451struct rpc_clnt *rpc_create(struct rpc_create_args *args) 483struct rpc_clnt *rpc_create(struct rpc_create_args *args)
452{ 484{
453 struct rpc_xprt *xprt; 485 struct rpc_xprt *xprt;
454 struct rpc_clnt *clnt;
455 struct xprt_create xprtargs = { 486 struct xprt_create xprtargs = {
456 .net = args->net, 487 .net = args->net,
457 .ident = args->protocol, 488 .ident = args->protocol,
@@ -515,30 +546,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
515 if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT) 546 if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT)
516 xprt->resvport = 0; 547 xprt->resvport = 0;
517 548
518 clnt = rpc_new_client(args, xprt, NULL); 549 return rpc_create_xprt(args, xprt);
519 if (IS_ERR(clnt))
520 return clnt;
521
522 if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
523 int err = rpc_ping(clnt);
524 if (err != 0) {
525 rpc_shutdown_client(clnt);
526 return ERR_PTR(err);
527 }
528 }
529
530 clnt->cl_softrtry = 1;
531 if (args->flags & RPC_CLNT_CREATE_HARDRTRY)
532 clnt->cl_softrtry = 0;
533
534 if (args->flags & RPC_CLNT_CREATE_AUTOBIND)
535 clnt->cl_autobind = 1;
536 if (args->flags & RPC_CLNT_CREATE_DISCRTRY)
537 clnt->cl_discrtry = 1;
538 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
539 clnt->cl_chatty = 1;
540
541 return clnt;
542} 550}
543EXPORT_SYMBOL_GPL(rpc_create); 551EXPORT_SYMBOL_GPL(rpc_create);
544 552
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index b6e59f0a9475..43bcb4699d69 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -60,7 +60,7 @@
60 60
61static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, 61static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
62 int flags); 62 int flags);
63static void svc_udp_data_ready(struct sock *, int); 63static void svc_udp_data_ready(struct sock *);
64static int svc_udp_recvfrom(struct svc_rqst *); 64static int svc_udp_recvfrom(struct svc_rqst *);
65static int svc_udp_sendto(struct svc_rqst *); 65static int svc_udp_sendto(struct svc_rqst *);
66static void svc_sock_detach(struct svc_xprt *); 66static void svc_sock_detach(struct svc_xprt *);
@@ -403,14 +403,14 @@ static void svc_sock_setbufsize(struct socket *sock, unsigned int snd,
403/* 403/*
404 * INET callback when data has been received on the socket. 404 * INET callback when data has been received on the socket.
405 */ 405 */
406static void svc_udp_data_ready(struct sock *sk, int count) 406static void svc_udp_data_ready(struct sock *sk)
407{ 407{
408 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; 408 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
409 wait_queue_head_t *wq = sk_sleep(sk); 409 wait_queue_head_t *wq = sk_sleep(sk);
410 410
411 if (svsk) { 411 if (svsk) {
412 dprintk("svc: socket %p(inet %p), count=%d, busy=%d\n", 412 dprintk("svc: socket %p(inet %p), busy=%d\n",
413 svsk, sk, count, 413 svsk, sk,
414 test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags)); 414 test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
415 set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); 415 set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
416 svc_xprt_enqueue(&svsk->sk_xprt); 416 svc_xprt_enqueue(&svsk->sk_xprt);
@@ -731,7 +731,7 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
731 * A data_ready event on a listening socket means there's a connection 731 * A data_ready event on a listening socket means there's a connection
732 * pending. Do not use state_change as a substitute for it. 732 * pending. Do not use state_change as a substitute for it.
733 */ 733 */
734static void svc_tcp_listen_data_ready(struct sock *sk, int count_unused) 734static void svc_tcp_listen_data_ready(struct sock *sk)
735{ 735{
736 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; 736 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
737 wait_queue_head_t *wq; 737 wait_queue_head_t *wq;
@@ -783,7 +783,7 @@ static void svc_tcp_state_change(struct sock *sk)
783 wake_up_interruptible_all(wq); 783 wake_up_interruptible_all(wq);
784} 784}
785 785
786static void svc_tcp_data_ready(struct sock *sk, int count) 786static void svc_tcp_data_ready(struct sock *sk)
787{ 787{
788 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data; 788 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
789 wait_queue_head_t *wq = sk_sleep(sk); 789 wait_queue_head_t *wq = sk_sleep(sk);
@@ -1397,6 +1397,22 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
1397 return svsk; 1397 return svsk;
1398} 1398}
1399 1399
1400bool svc_alien_sock(struct net *net, int fd)
1401{
1402 int err;
1403 struct socket *sock = sockfd_lookup(fd, &err);
1404 bool ret = false;
1405
1406 if (!sock)
1407 goto out;
1408 if (sock_net(sock->sk) != net)
1409 ret = true;
1410 sockfd_put(sock);
1411out:
1412 return ret;
1413}
1414EXPORT_SYMBOL_GPL(svc_alien_sock);
1415
1400/** 1416/**
1401 * svc_addsock - add a listener socket to an RPC service 1417 * svc_addsock - add a listener socket to an RPC service
1402 * @serv: pointer to RPC service to which to add a new listener 1418 * @serv: pointer to RPC service to which to add a new listener
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 1504bb11e4f3..dd97ba3c4456 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -833,8 +833,20 @@ xdr_buf_from_iov(struct kvec *iov, struct xdr_buf *buf)
833} 833}
834EXPORT_SYMBOL_GPL(xdr_buf_from_iov); 834EXPORT_SYMBOL_GPL(xdr_buf_from_iov);
835 835
836/* Sets subbuf to the portion of buf of length len beginning base bytes 836/**
837 * from the start of buf. Returns -1 if base of length are out of bounds. */ 837 * xdr_buf_subsegment - set subbuf to a portion of buf
838 * @buf: an xdr buffer
839 * @subbuf: the result buffer
840 * @base: beginning of range in bytes
841 * @len: length of range in bytes
842 *
843 * sets @subbuf to an xdr buffer representing the portion of @buf of
844 * length @len starting at offset @base.
845 *
846 * @buf and @subbuf may be pointers to the same struct xdr_buf.
847 *
848 * Returns -1 if base of length are out of bounds.
849 */
838int 850int
839xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf, 851xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
840 unsigned int base, unsigned int len) 852 unsigned int base, unsigned int len)
@@ -847,9 +859,8 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
847 len -= subbuf->head[0].iov_len; 859 len -= subbuf->head[0].iov_len;
848 base = 0; 860 base = 0;
849 } else { 861 } else {
850 subbuf->head[0].iov_base = NULL;
851 subbuf->head[0].iov_len = 0;
852 base -= buf->head[0].iov_len; 862 base -= buf->head[0].iov_len;
863 subbuf->head[0].iov_len = 0;
853 } 864 }
854 865
855 if (base < buf->page_len) { 866 if (base < buf->page_len) {
@@ -871,9 +882,8 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
871 len -= subbuf->tail[0].iov_len; 882 len -= subbuf->tail[0].iov_len;
872 base = 0; 883 base = 0;
873 } else { 884 } else {
874 subbuf->tail[0].iov_base = NULL;
875 subbuf->tail[0].iov_len = 0;
876 base -= buf->tail[0].iov_len; 885 base -= buf->tail[0].iov_len;
886 subbuf->tail[0].iov_len = 0;
877 } 887 }
878 888
879 if (base || len) 889 if (base || len)
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 7d4df99f761f..d173f79947c6 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1383,15 +1383,3 @@ void xprt_put(struct rpc_xprt *xprt)
1383 if (atomic_dec_and_test(&xprt->count)) 1383 if (atomic_dec_and_test(&xprt->count))
1384 xprt_destroy(xprt); 1384 xprt_destroy(xprt);
1385} 1385}
1386
1387/**
1388 * xprt_get - return a reference to an RPC transport.
1389 * @xprt: pointer to the transport
1390 *
1391 */
1392struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
1393{
1394 if (atomic_inc_not_zero(&xprt->count))
1395 return xprt;
1396 return NULL;
1397}
diff --git a/net/sunrpc/xprtrdma/Makefile b/net/sunrpc/xprtrdma/Makefile
index 5a8f268bdd30..da5136fd5694 100644
--- a/net/sunrpc/xprtrdma/Makefile
+++ b/net/sunrpc/xprtrdma/Makefile
@@ -1,8 +1,8 @@
1obj-$(CONFIG_SUNRPC_XPRT_RDMA) += xprtrdma.o 1obj-$(CONFIG_SUNRPC_XPRT_RDMA_CLIENT) += xprtrdma.o
2 2
3xprtrdma-y := transport.o rpc_rdma.o verbs.o 3xprtrdma-y := transport.o rpc_rdma.o verbs.o
4 4
5obj-$(CONFIG_SUNRPC_XPRT_RDMA) += svcrdma.o 5obj-$(CONFIG_SUNRPC_XPRT_RDMA_SERVER) += svcrdma.o
6 6
7svcrdma-y := svc_rdma.o svc_rdma_transport.o \ 7svcrdma-y := svc_rdma.o svc_rdma_transport.o \
8 svc_rdma_marshal.o svc_rdma_sendto.o svc_rdma_recvfrom.o 8 svc_rdma_marshal.o svc_rdma_sendto.o svc_rdma_recvfrom.o
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
index 0ce75524ed21..8d904e4eef15 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
@@ -90,6 +90,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
90 sge_no++; 90 sge_no++;
91 } 91 }
92 rqstp->rq_respages = &rqstp->rq_pages[sge_no]; 92 rqstp->rq_respages = &rqstp->rq_pages[sge_no];
93 rqstp->rq_next_page = rqstp->rq_respages + 1;
93 94
94 /* We should never run out of SGE because the limit is defined to 95 /* We should never run out of SGE because the limit is defined to
95 * support the max allowed RPC data length 96 * support the max allowed RPC data length
@@ -169,6 +170,7 @@ static int map_read_chunks(struct svcxprt_rdma *xprt,
169 */ 170 */
170 head->arg.pages[page_no] = rqstp->rq_arg.pages[page_no]; 171 head->arg.pages[page_no] = rqstp->rq_arg.pages[page_no];
171 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no+1]; 172 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no+1];
173 rqstp->rq_next_page = rqstp->rq_respages + 1;
172 174
173 byte_count -= sge_bytes; 175 byte_count -= sge_bytes;
174 ch_bytes -= sge_bytes; 176 ch_bytes -= sge_bytes;
@@ -276,6 +278,7 @@ static int fast_reg_read_chunks(struct svcxprt_rdma *xprt,
276 278
277 /* rq_respages points one past arg pages */ 279 /* rq_respages points one past arg pages */
278 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no]; 280 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
281 rqstp->rq_next_page = rqstp->rq_respages + 1;
279 282
280 /* Create the reply and chunk maps */ 283 /* Create the reply and chunk maps */
281 offset = 0; 284 offset = 0;
@@ -520,13 +523,6 @@ next_sge:
520 for (ch_no = 0; &rqstp->rq_pages[ch_no] < rqstp->rq_respages; ch_no++) 523 for (ch_no = 0; &rqstp->rq_pages[ch_no] < rqstp->rq_respages; ch_no++)
521 rqstp->rq_pages[ch_no] = NULL; 524 rqstp->rq_pages[ch_no] = NULL;
522 525
523 /*
524 * Detach res pages. If svc_release sees any it will attempt to
525 * put them.
526 */
527 while (rqstp->rq_next_page != rqstp->rq_respages)
528 *(--rqstp->rq_next_page) = NULL;
529
530 return err; 526 return err;
531} 527}
532 528
@@ -550,7 +546,7 @@ static int rdma_read_complete(struct svc_rqst *rqstp,
550 546
551 /* rq_respages starts after the last arg page */ 547 /* rq_respages starts after the last arg page */
552 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no]; 548 rqstp->rq_respages = &rqstp->rq_arg.pages[page_no];
553 rqstp->rq_next_page = &rqstp->rq_arg.pages[page_no]; 549 rqstp->rq_next_page = rqstp->rq_respages + 1;
554 550
555 /* Rebuild rq_arg head and tail. */ 551 /* Rebuild rq_arg head and tail. */
556 rqstp->rq_arg.head[0] = head->arg.head[0]; 552 rqstp->rq_arg.head[0] = head->arg.head[0];
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index c1d124dc772b..7e024a51617e 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -265,6 +265,7 @@ static dma_addr_t dma_map_xdr(struct svcxprt_rdma *xprt,
265 xdr_off -= xdr->head[0].iov_len; 265 xdr_off -= xdr->head[0].iov_len;
266 if (xdr_off < xdr->page_len) { 266 if (xdr_off < xdr->page_len) {
267 /* This offset is in the page list */ 267 /* This offset is in the page list */
268 xdr_off += xdr->page_base;
268 page = xdr->pages[xdr_off >> PAGE_SHIFT]; 269 page = xdr->pages[xdr_off >> PAGE_SHIFT];
269 xdr_off &= ~PAGE_MASK; 270 xdr_off &= ~PAGE_MASK;
270 } else { 271 } else {
@@ -625,6 +626,7 @@ static int send_reply(struct svcxprt_rdma *rdma,
625 if (page_no+1 >= sge_no) 626 if (page_no+1 >= sge_no)
626 ctxt->sge[page_no+1].length = 0; 627 ctxt->sge[page_no+1].length = 0;
627 } 628 }
629 rqstp->rq_next_page = rqstp->rq_respages + 1;
628 BUG_ON(sge_no > rdma->sc_max_sge); 630 BUG_ON(sge_no > rdma->sc_max_sge);
629 memset(&send_wr, 0, sizeof send_wr); 631 memset(&send_wr, 0, sizeof send_wr);
630 ctxt->wr_op = IB_WR_SEND; 632 ctxt->wr_op = IB_WR_SEND;
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
index 62e4f9bcc387..25688fa2207f 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
@@ -477,8 +477,7 @@ struct page *svc_rdma_get_page(void)
477 477
478 while ((page = alloc_page(GFP_KERNEL)) == NULL) { 478 while ((page = alloc_page(GFP_KERNEL)) == NULL) {
479 /* If we can't get memory, wait a bit and try again */ 479 /* If we can't get memory, wait a bit and try again */
480 printk(KERN_INFO "svcrdma: out of memory...retrying in 1000 " 480 printk(KERN_INFO "svcrdma: out of memory...retrying in 1s\n");
481 "jiffies.\n");
482 schedule_timeout_uninterruptible(msecs_to_jiffies(1000)); 481 schedule_timeout_uninterruptible(msecs_to_jiffies(1000));
483 } 482 }
484 return page; 483 return page;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 966763d735e9..25a3dcf15cae 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -254,7 +254,7 @@ struct sock_xprt {
254 /* 254 /*
255 * Saved socket callback addresses 255 * Saved socket callback addresses
256 */ 256 */
257 void (*old_data_ready)(struct sock *, int); 257 void (*old_data_ready)(struct sock *);
258 void (*old_state_change)(struct sock *); 258 void (*old_state_change)(struct sock *);
259 void (*old_write_space)(struct sock *); 259 void (*old_write_space)(struct sock *);
260 void (*old_error_report)(struct sock *); 260 void (*old_error_report)(struct sock *);
@@ -909,6 +909,12 @@ static void xs_tcp_close(struct rpc_xprt *xprt)
909 xs_tcp_shutdown(xprt); 909 xs_tcp_shutdown(xprt);
910} 910}
911 911
912static void xs_xprt_free(struct rpc_xprt *xprt)
913{
914 xs_free_peer_addresses(xprt);
915 xprt_free(xprt);
916}
917
912/** 918/**
913 * xs_destroy - prepare to shutdown a transport 919 * xs_destroy - prepare to shutdown a transport
914 * @xprt: doomed transport 920 * @xprt: doomed transport
@@ -919,8 +925,7 @@ static void xs_destroy(struct rpc_xprt *xprt)
919 dprintk("RPC: xs_destroy xprt %p\n", xprt); 925 dprintk("RPC: xs_destroy xprt %p\n", xprt);
920 926
921 xs_close(xprt); 927 xs_close(xprt);
922 xs_free_peer_addresses(xprt); 928 xs_xprt_free(xprt);
923 xprt_free(xprt);
924 module_put(THIS_MODULE); 929 module_put(THIS_MODULE);
925} 930}
926 931
@@ -946,7 +951,7 @@ static int xs_local_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
946 * 951 *
947 * Currently this assumes we can read the whole reply in a single gulp. 952 * Currently this assumes we can read the whole reply in a single gulp.
948 */ 953 */
949static void xs_local_data_ready(struct sock *sk, int len) 954static void xs_local_data_ready(struct sock *sk)
950{ 955{
951 struct rpc_task *task; 956 struct rpc_task *task;
952 struct rpc_xprt *xprt; 957 struct rpc_xprt *xprt;
@@ -1009,7 +1014,7 @@ static void xs_local_data_ready(struct sock *sk, int len)
1009 * @len: how much data to read 1014 * @len: how much data to read
1010 * 1015 *
1011 */ 1016 */
1012static void xs_udp_data_ready(struct sock *sk, int len) 1017static void xs_udp_data_ready(struct sock *sk)
1013{ 1018{
1014 struct rpc_task *task; 1019 struct rpc_task *task;
1015 struct rpc_xprt *xprt; 1020 struct rpc_xprt *xprt;
@@ -1432,7 +1437,7 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
1432 * @bytes: how much data to read 1437 * @bytes: how much data to read
1433 * 1438 *
1434 */ 1439 */
1435static void xs_tcp_data_ready(struct sock *sk, int bytes) 1440static void xs_tcp_data_ready(struct sock *sk)
1436{ 1441{
1437 struct rpc_xprt *xprt; 1442 struct rpc_xprt *xprt;
1438 read_descriptor_t rd_desc; 1443 read_descriptor_t rd_desc;
@@ -2532,6 +2537,10 @@ static void bc_close(struct rpc_xprt *xprt)
2532 2537
2533static void bc_destroy(struct rpc_xprt *xprt) 2538static void bc_destroy(struct rpc_xprt *xprt)
2534{ 2539{
2540 dprintk("RPC: bc_destroy xprt %p\n", xprt);
2541
2542 xs_xprt_free(xprt);
2543 module_put(THIS_MODULE);
2535} 2544}
2536 2545
2537static struct rpc_xprt_ops xs_local_ops = { 2546static struct rpc_xprt_ops xs_local_ops = {
@@ -2732,7 +2741,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
2732 return xprt; 2741 return xprt;
2733 ret = ERR_PTR(-EINVAL); 2742 ret = ERR_PTR(-EINVAL);
2734out_err: 2743out_err:
2735 xprt_free(xprt); 2744 xs_xprt_free(xprt);
2736 return ret; 2745 return ret;
2737} 2746}
2738 2747
@@ -2810,7 +2819,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
2810 return xprt; 2819 return xprt;
2811 ret = ERR_PTR(-EINVAL); 2820 ret = ERR_PTR(-EINVAL);
2812out_err: 2821out_err:
2813 xprt_free(xprt); 2822 xs_xprt_free(xprt);
2814 return ret; 2823 return ret;
2815} 2824}
2816 2825
@@ -2885,12 +2894,11 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
2885 xprt->address_strings[RPC_DISPLAY_ADDR], 2894 xprt->address_strings[RPC_DISPLAY_ADDR],
2886 xprt->address_strings[RPC_DISPLAY_PROTO]); 2895 xprt->address_strings[RPC_DISPLAY_PROTO]);
2887 2896
2888
2889 if (try_module_get(THIS_MODULE)) 2897 if (try_module_get(THIS_MODULE))
2890 return xprt; 2898 return xprt;
2891 ret = ERR_PTR(-EINVAL); 2899 ret = ERR_PTR(-EINVAL);
2892out_err: 2900out_err:
2893 xprt_free(xprt); 2901 xs_xprt_free(xprt);
2894 return ret; 2902 return ret;
2895} 2903}
2896 2904
@@ -2907,15 +2915,6 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2907 struct svc_sock *bc_sock; 2915 struct svc_sock *bc_sock;
2908 struct rpc_xprt *ret; 2916 struct rpc_xprt *ret;
2909 2917
2910 if (args->bc_xprt->xpt_bc_xprt) {
2911 /*
2912 * This server connection already has a backchannel
2913 * transport; we can't create a new one, as we wouldn't
2914 * be able to match replies based on xid any more. So,
2915 * reuse the already-existing one:
2916 */
2917 return args->bc_xprt->xpt_bc_xprt;
2918 }
2919 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries, 2918 xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries,
2920 xprt_tcp_slot_table_entries); 2919 xprt_tcp_slot_table_entries);
2921 if (IS_ERR(xprt)) 2920 if (IS_ERR(xprt))
@@ -2973,13 +2972,14 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
2973 */ 2972 */
2974 xprt_set_connected(xprt); 2973 xprt_set_connected(xprt);
2975 2974
2976
2977 if (try_module_get(THIS_MODULE)) 2975 if (try_module_get(THIS_MODULE))
2978 return xprt; 2976 return xprt;
2977
2978 args->bc_xprt->xpt_bc_xprt = NULL;
2979 xprt_put(xprt); 2979 xprt_put(xprt);
2980 ret = ERR_PTR(-EINVAL); 2980 ret = ERR_PTR(-EINVAL);
2981out_err: 2981out_err:
2982 xprt_free(xprt); 2982 xs_xprt_free(xprt);
2983 return ret; 2983 return ret;
2984} 2984}
2985 2985
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 646a930eefbf..a538a02f869b 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -119,7 +119,7 @@ static struct tipc_conn *tipc_conn_lookup(struct tipc_server *s, int conid)
119 return con; 119 return con;
120} 120}
121 121
122static void sock_data_ready(struct sock *sk, int unused) 122static void sock_data_ready(struct sock *sk)
123{ 123{
124 struct tipc_conn *con; 124 struct tipc_conn *con;
125 125
@@ -297,7 +297,7 @@ static int tipc_accept_from_sock(struct tipc_conn *con)
297 newcon->usr_data = s->tipc_conn_new(newcon->conid); 297 newcon->usr_data = s->tipc_conn_new(newcon->conid);
298 298
299 /* Wake up receive process in case of 'SYN+' message */ 299 /* Wake up receive process in case of 'SYN+' message */
300 newsock->sk->sk_data_ready(newsock->sk, 0); 300 newsock->sk->sk_data_ready(newsock->sk);
301 return ret; 301 return ret;
302} 302}
303 303
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index adc12e227303..3c0256962f7d 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -45,7 +45,7 @@
45#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ 45#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
46 46
47static int backlog_rcv(struct sock *sk, struct sk_buff *skb); 47static int backlog_rcv(struct sock *sk, struct sk_buff *skb);
48static void tipc_data_ready(struct sock *sk, int len); 48static void tipc_data_ready(struct sock *sk);
49static void tipc_write_space(struct sock *sk); 49static void tipc_write_space(struct sock *sk);
50static int tipc_release(struct socket *sock); 50static int tipc_release(struct socket *sock);
51static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags); 51static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags);
@@ -1248,7 +1248,7 @@ static void tipc_write_space(struct sock *sk)
1248 * @sk: socket 1248 * @sk: socket
1249 * @len: the length of messages 1249 * @len: the length of messages
1250 */ 1250 */
1251static void tipc_data_ready(struct sock *sk, int len) 1251static void tipc_data_ready(struct sock *sk)
1252{ 1252{
1253 struct socket_wq *wq; 1253 struct socket_wq *wq;
1254 1254
@@ -1410,7 +1410,7 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
1410 __skb_queue_tail(&sk->sk_receive_queue, buf); 1410 __skb_queue_tail(&sk->sk_receive_queue, buf);
1411 skb_set_owner_r(buf, sk); 1411 skb_set_owner_r(buf, sk);
1412 1412
1413 sk->sk_data_ready(sk, 0); 1413 sk->sk_data_ready(sk);
1414 return TIPC_OK; 1414 return TIPC_OK;
1415} 1415}
1416 1416
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 94404f19f9de..bb7e8ba821f4 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1217,7 +1217,7 @@ restart:
1217 __skb_queue_tail(&other->sk_receive_queue, skb); 1217 __skb_queue_tail(&other->sk_receive_queue, skb);
1218 spin_unlock(&other->sk_receive_queue.lock); 1218 spin_unlock(&other->sk_receive_queue.lock);
1219 unix_state_unlock(other); 1219 unix_state_unlock(other);
1220 other->sk_data_ready(other, 0); 1220 other->sk_data_ready(other);
1221 sock_put(other); 1221 sock_put(other);
1222 return 0; 1222 return 0;
1223 1223
@@ -1600,7 +1600,7 @@ restart:
1600 if (max_level > unix_sk(other)->recursion_level) 1600 if (max_level > unix_sk(other)->recursion_level)
1601 unix_sk(other)->recursion_level = max_level; 1601 unix_sk(other)->recursion_level = max_level;
1602 unix_state_unlock(other); 1602 unix_state_unlock(other);
1603 other->sk_data_ready(other, len); 1603 other->sk_data_ready(other);
1604 sock_put(other); 1604 sock_put(other);
1605 scm_destroy(siocb->scm); 1605 scm_destroy(siocb->scm);
1606 return len; 1606 return len;
@@ -1706,7 +1706,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1706 if (max_level > unix_sk(other)->recursion_level) 1706 if (max_level > unix_sk(other)->recursion_level)
1707 unix_sk(other)->recursion_level = max_level; 1707 unix_sk(other)->recursion_level = max_level;
1708 unix_state_unlock(other); 1708 unix_state_unlock(other);
1709 other->sk_data_ready(other, size); 1709 other->sk_data_ready(other);
1710 sent += size; 1710 sent += size;
1711 } 1711 }
1712 1712
diff --git a/net/vmw_vsock/vmci_transport_notify.c b/net/vmw_vsock/vmci_transport_notify.c
index 9a730744e7bc..9b7f207f2bee 100644
--- a/net/vmw_vsock/vmci_transport_notify.c
+++ b/net/vmw_vsock/vmci_transport_notify.c
@@ -315,7 +315,7 @@ vmci_transport_handle_wrote(struct sock *sk,
315 struct vsock_sock *vsk = vsock_sk(sk); 315 struct vsock_sock *vsk = vsock_sk(sk);
316 PKT_FIELD(vsk, sent_waiting_read) = false; 316 PKT_FIELD(vsk, sent_waiting_read) = false;
317#endif 317#endif
318 sk->sk_data_ready(sk, 0); 318 sk->sk_data_ready(sk);
319} 319}
320 320
321static void vmci_transport_notify_pkt_socket_init(struct sock *sk) 321static void vmci_transport_notify_pkt_socket_init(struct sock *sk)
diff --git a/net/vmw_vsock/vmci_transport_notify_qstate.c b/net/vmw_vsock/vmci_transport_notify_qstate.c
index 622bd7aa1016..dc9c7929a2f9 100644
--- a/net/vmw_vsock/vmci_transport_notify_qstate.c
+++ b/net/vmw_vsock/vmci_transport_notify_qstate.c
@@ -92,7 +92,7 @@ vmci_transport_handle_wrote(struct sock *sk,
92 bool bottom_half, 92 bool bottom_half,
93 struct sockaddr_vm *dst, struct sockaddr_vm *src) 93 struct sockaddr_vm *dst, struct sockaddr_vm *src)
94{ 94{
95 sk->sk_data_ready(sk, 0); 95 sk->sk_data_ready(sk);
96} 96}
97 97
98static void vsock_block_update_write_window(struct sock *sk) 98static void vsock_block_update_write_window(struct sock *sk)
@@ -290,7 +290,7 @@ vmci_transport_notify_pkt_recv_post_dequeue(
290 /* See the comment in 290 /* See the comment in
291 * vmci_transport_notify_pkt_send_post_enqueue(). 291 * vmci_transport_notify_pkt_send_post_enqueue().
292 */ 292 */
293 sk->sk_data_ready(sk, 0); 293 sk->sk_data_ready(sk);
294 } 294 }
295 295
296 return err; 296 return err;
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 6177479c7de9..5ad4418ef093 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1064,7 +1064,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
1064 x25_start_heartbeat(make); 1064 x25_start_heartbeat(make);
1065 1065
1066 if (!sock_flag(sk, SOCK_DEAD)) 1066 if (!sock_flag(sk, SOCK_DEAD))
1067 sk->sk_data_ready(sk, skb->len); 1067 sk->sk_data_ready(sk);
1068 rc = 1; 1068 rc = 1;
1069 sock_put(sk); 1069 sock_put(sk);
1070out: 1070out:
diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index d1b0dc79bb6f..7ac50098a375 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -79,7 +79,7 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
79 skb_set_owner_r(skbn, sk); 79 skb_set_owner_r(skbn, sk);
80 skb_queue_tail(&sk->sk_receive_queue, skbn); 80 skb_queue_tail(&sk->sk_receive_queue, skbn);
81 if (!sock_flag(sk, SOCK_DEAD)) 81 if (!sock_flag(sk, SOCK_DEAD))
82 sk->sk_data_ready(sk, skbn->len); 82 sk->sk_data_ready(sk);
83 83
84 return 0; 84 return 0;
85} 85}
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 9f0ee22b914f..003bc263105a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -65,12 +65,22 @@ warning- := $(empty)
65warning-1 := -Wextra -Wunused -Wno-unused-parameter 65warning-1 := -Wextra -Wunused -Wno-unused-parameter
66warning-1 += -Wmissing-declarations 66warning-1 += -Wmissing-declarations
67warning-1 += -Wmissing-format-attribute 67warning-1 += -Wmissing-format-attribute
68warning-1 += -Wmissing-prototypes 68warning-1 += $(call cc-option, -Wmissing-prototypes)
69warning-1 += -Wold-style-definition 69warning-1 += -Wold-style-definition
70warning-1 += $(call cc-option, -Wmissing-include-dirs) 70warning-1 += $(call cc-option, -Wmissing-include-dirs)
71warning-1 += $(call cc-option, -Wunused-but-set-variable) 71warning-1 += $(call cc-option, -Wunused-but-set-variable)
72warning-1 += $(call cc-disable-warning, missing-field-initializers) 72warning-1 += $(call cc-disable-warning, missing-field-initializers)
73 73
74# Clang
75warning-1 += $(call cc-disable-warning, initializer-overrides)
76warning-1 += $(call cc-disable-warning, unused-value)
77warning-1 += $(call cc-disable-warning, format)
78warning-1 += $(call cc-disable-warning, unknown-warning-option)
79warning-1 += $(call cc-disable-warning, sign-compare)
80warning-1 += $(call cc-disable-warning, format-zero-length)
81warning-1 += $(call cc-disable-warning, uninitialized)
82warning-1 += $(call cc-option, -fcatch-undefined-behavior)
83
74warning-2 := -Waggregate-return 84warning-2 := -Waggregate-return
75warning-2 += -Wcast-align 85warning-2 += -Wcast-align
76warning-2 += -Wdisabled-optimization 86warning-2 += -Wdisabled-optimization
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
index b78fca994a15..9ca667bcaee9 100644
--- a/scripts/bootgraph.pl
+++ b/scripts/bootgraph.pl
@@ -38,6 +38,31 @@
38# 38#
39 39
40use strict; 40use strict;
41use Getopt::Long;
42my $header = 0;
43
44sub help {
45 my $text = << "EOM";
46Usage:
471) dmesg | perl scripts/bootgraph.pl [OPTION] > output.svg
482) perl scripts/bootgraph.pl -h
49
50Options:
51 -header Insert kernel version and date
52EOM
53 my $std=shift;
54 if ($std == 1) {
55 print STDERR $text;
56 } else {
57 print $text;
58 }
59 exit;
60}
61
62GetOptions(
63 'h|help' =>\&help,
64 'header' =>\$header
65);
41 66
42my %start; 67my %start;
43my %end; 68my %end;
@@ -49,6 +74,11 @@ my $count = 0;
49my %pids; 74my %pids;
50my %pidctr; 75my %pidctr;
51 76
77my $headerstep = 20;
78my $xheader = 15;
79my $yheader = 25;
80my $cyheader = 0;
81
52while (<>) { 82while (<>) {
53 my $line = $_; 83 my $line = $_;
54 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) { 84 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) {
@@ -112,15 +142,23 @@ if ($count == 0) {
112 print STDERR <<END; 142 print STDERR <<END;
113No data found in the dmesg. Make sure that 'printk.time=1' and 143No data found in the dmesg. Make sure that 'printk.time=1' and
114'initcall_debug' are passed on the kernel command line. 144'initcall_debug' are passed on the kernel command line.
115Usage:
116 dmesg | perl scripts/bootgraph.pl > output.svg
117END 145END
146 help(1);
118 exit 1; 147 exit 1;
119} 148}
120 149
121print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; 150print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
122print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; 151print "<svg width=\"2000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
123 152
153
154if ($header) {
155 my $version = `uname -a`;
156 my $date = `date`;
157 print "<text transform=\"translate($xheader,$yheader)\">Kernel version: $version</text>\n";
158 $cyheader = $yheader+$headerstep;
159 print "<text transform=\"translate($xheader,$cyheader)\">Date: $date</text>\n";
160}
161
124my @styles; 162my @styles;
125 163
126$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; 164$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index e18f8402e37c..dd58dab5d411 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -7,7 +7,7 @@
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Options: --no-includes --include-headers 8// Options: --no-includes --include-headers
9// 9//
10// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO 10// Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO
11// Version min: 2.6.39 11// Version min: 2.6.39
12// 12//
13 13
@@ -62,35 +62,35 @@ position p3;
62p << r1.p1; 62p << r1.p1;
63@@ 63@@
64 64
65coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 65coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
66 66
67 67
68@script:python depends on org@ 68@script:python depends on org@
69p << r2.p2; 69p << r2.p2;
70@@ 70@@
71 71
72coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 72coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
73 73
74@script:python depends on org@ 74@script:python depends on org@
75p << r3.p3; 75p << r3.p3;
76@@ 76@@
77 77
78coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") 78coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
79 79
80@script:python depends on report@ 80@script:python depends on report@
81p << r1.p1; 81p << r1.p1;
82@@ 82@@
83 83
84coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 84coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
85 85
86@script:python depends on report@ 86@script:python depends on report@
87p << r2.p2; 87p << r2.p2;
88@@ 88@@
89 89
90coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 90coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
91 91
92@script:python depends on report@ 92@script:python depends on report@
93p << r3.p3; 93p << r3.p3;
94@@ 94@@
95 95
96coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") 96coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
diff --git a/scripts/coccinelle/misc/memcpy-assign.cocci b/scripts/coccinelle/misc/memcpy-assign.cocci
deleted file mode 100644
index afd058be497f..000000000000
--- a/scripts/coccinelle/misc/memcpy-assign.cocci
+++ /dev/null
@@ -1,103 +0,0 @@
1//
2// Replace memcpy with struct assignment.
3//
4// Confidence: High
5// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
6// URL: http://coccinelle.lip6.fr/
7// Comments:
8// Options: --no-includes --include-headers
9
10virtual patch
11virtual report
12virtual context
13virtual org
14
15@r1 depends on !patch@
16identifier struct_name;
17struct struct_name to;
18struct struct_name from;
19struct struct_name *top;
20struct struct_name *fromp;
21position p;
22@@
23memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\))
24
25@script:python depends on report@
26p << r1.p;
27@@
28coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
29
30@depends on context@
31position r1.p;
32@@
33*memcpy@p(...);
34
35@script:python depends on org@
36p << r1.p;
37@@
38cocci.print_main("Replace memcpy with struct assignment",p)
39
40@depends on patch@
41identifier struct_name;
42struct struct_name to;
43struct struct_name from;
44@@
45(
46-memcpy(&(to), &(from), sizeof(to));
47+to = from;
48|
49-memcpy(&(to), &(from), sizeof(from));
50+to = from;
51|
52-memcpy(&(to), &(from), sizeof(struct struct_name));
53+to = from;
54)
55
56@depends on patch@
57identifier struct_name;
58struct struct_name to;
59struct struct_name *from;
60@@
61(
62-memcpy(&(to), from, sizeof(to));
63+to = *from;
64|
65-memcpy(&(to), from, sizeof(*from));
66+to = *from;
67|
68-memcpy(&(to), from, sizeof(struct struct_name));
69+to = *from;
70)
71
72@depends on patch@
73identifier struct_name;
74struct struct_name *to;
75struct struct_name from;
76@@
77(
78-memcpy(to, &(from), sizeof(*to));
79+ *to = from;
80|
81-memcpy(to, &(from), sizeof(from));
82+ *to = from;
83|
84-memcpy(to, &(from), sizeof(struct struct_name));
85+ *to = from;
86)
87
88@depends on patch@
89identifier struct_name;
90struct struct_name *to;
91struct struct_name *from;
92@@
93(
94-memcpy(to, from, sizeof(*to));
95+ *to = *from;
96|
97-memcpy(to, from, sizeof(*from));
98+ *to = *from;
99|
100-memcpy(to, from, sizeof(struct struct_name));
101+ *to = *from;
102)
103
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index f221ddf69080..cfb8440cc0b2 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
78 78
79 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" 79 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\"
80) > .tmpcompile 80) > .tmpcompile
81 81
82# Only replace the real compile.h if the new one is different, 82# Only replace the real compile.h if the new one is different,
diff --git a/scripts/objdiff b/scripts/objdiff
new file mode 100755
index 000000000000..b3e4f10bfc3e
--- /dev/null
+++ b/scripts/objdiff
@@ -0,0 +1,141 @@
1#!/bin/bash
2
3# objdiff - a small script for validating that a commit or series of commits
4# didn't change object code.
5#
6# Copyright 2014, Jason Cooper <jason@lakedaemon.net>
7#
8# Licensed under the terms of the GNU GPL version 2
9
10# usage example:
11#
12# $ git checkout COMMIT_A
13# $ <your fancy build command here>
14# $ ./scripts/objdiff record path/to/*.o
15#
16# $ git checkout COMMIT_B
17# $ <your fancy build command here>
18# $ ./scripts/objdiff record path/to/*.o
19#
20# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
21# $
22
23# And to clean up (everything is in .tmp_objdiff/*)
24# $ ./scripts/objdiff clean all
25#
26# Note: 'make mrproper' will also remove .tmp_objdiff
27
28GIT_DIR="`git rev-parse --git-dir`"
29
30if [ -d "$GIT_DIR" ]; then
31 TMPD="${GIT_DIR%git}tmp_objdiff"
32
33 [ -d "$TMPD" ] || mkdir "$TMPD"
34else
35 echo "ERROR: git directory not found."
36 exit 1
37fi
38
39usage() {
40 echo "Usage: $0 <command> <args>"
41 echo " record <list of object files>"
42 echo " diff <commitA> <commitB>"
43 echo " clean all | <commit>"
44 exit 1
45}
46
47dorecord() {
48 [ $# -eq 0 ] && usage
49
50 FILES="$*"
51
52 CMT="`git rev-parse --short HEAD`"
53
54 OBJDUMP="${CROSS_COMPILE}objdump"
55 OBJDIFFD="$TMPD/$CMT"
56
57 [ ! -d "$OBJDIFFD" ] && mkdir -p "$OBJDIFFD"
58
59 for f in $FILES; do
60 dn="${f%/*}"
61 bn="${f##*/}"
62
63 [ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn"
64
65 # remove addresses for a more clear diff
66 # http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
67 $OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \
68 >"$OBJDIFFD/$dn/$bn"
69 done
70}
71
72dodiff() {
73 [ $# -ne 2 ] && [ $# -ne 0 ] && usage
74
75 if [ $# -eq 0 ]; then
76 SRC="`git rev-parse --short HEAD^`"
77 DST="`git rev-parse --short HEAD`"
78 else
79 SRC="`git rev-parse --short $1`"
80 DST="`git rev-parse --short $2`"
81 fi
82
83 DIFF="`which colordiff`"
84
85 if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then
86 DIFF="`which diff`"
87 fi
88
89 SRCD="$TMPD/$SRC"
90 DSTD="$TMPD/$DST"
91
92 if [ ! -d "$SRCD" ]; then
93 echo "ERROR: $SRCD doesn't exist"
94 exit 1
95 fi
96
97 if [ ! -d "$DSTD" ]; then
98 echo "ERROR: $DSTD doesn't exist"
99 exit 1
100 fi
101
102 $DIFF -Nurd $SRCD $DSTD
103}
104
105doclean() {
106 [ $# -eq 0 ] && usage
107 [ $# -gt 1 ] && usage
108
109 if [ "x$1" = "xall" ]; then
110 rm -rf $TMPD/*
111 else
112 CMT="`git rev-parse --short $1`"
113
114 if [ -d "$TMPD/$CMT" ]; then
115 rm -rf $TMPD/$CMT
116 else
117 echo "$CMT not found"
118 fi
119 fi
120}
121
122[ $# -eq 0 ] && usage
123
124case "$1" in
125 record)
126 shift
127 dorecord $*
128 ;;
129 diff)
130 shift
131 dodiff $*
132 ;;
133 clean)
134 shift
135 doclean $*
136 ;;
137 *)
138 echo "Unrecognized command '$1'"
139 exit 1
140 ;;
141esac
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 58c455929091..f2c5b006a3d7 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -11,11 +11,10 @@ if [ "$KBUILD_VERBOSE" = "1" ]; then
11 set -x 11 set -x
12fi 12fi
13 13
14# This is a duplicate of RCS_FIND_IGNORE without escaped '()' 14# RCS_FIND_IGNORE has escaped ()s -- remove them.
15ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ 15ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )"
16 -name CVS -o -name .pc -o -name .hg -o \ 16# tags and cscope files should also ignore MODVERSION *.mod.c files
17 -name .git ) \ 17ignore="$ignore ( -name *.mod.c ) -prune -o"
18 -prune -o"
19 18
20# Do not use full path if we do not use O=.. builds 19# Do not use full path if we do not use O=.. builds
21# Use make O=. {tags|cscope} 20# Use make O=. {tags|cscope}
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index babd8626bf96..6b540f1822e0 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -139,7 +139,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
139 int error; 139 int error;
140 int size; 140 int size;
141 141
142 if (!inode->i_op || !inode->i_op->getxattr) 142 if (!inode->i_op->getxattr)
143 return -EOPNOTSUPP; 143 return -EOPNOTSUPP;
144 desc = init_desc(type); 144 desc = init_desc(type);
145 if (IS_ERR(desc)) 145 if (IS_ERR(desc))
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 996092f21b64..6e0bd933b6a9 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -64,7 +64,7 @@ static int evm_find_protected_xattrs(struct dentry *dentry)
64 int error; 64 int error;
65 int count = 0; 65 int count = 0;
66 66
67 if (!inode->i_op || !inode->i_op->getxattr) 67 if (!inode->i_op->getxattr)
68 return -EOPNOTSUPP; 68 return -EOPNOTSUPP;
69 69
70 for (xattr = evm_config_xattrnames; *xattr != NULL; xattr++) { 70 for (xattr = evm_config_xattrnames; *xattr != NULL; xattr++) {
diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c
index aab9fa5a8231..90987d15b6fe 100644
--- a/security/integrity/integrity_audit.c
+++ b/security/integrity/integrity_audit.c
@@ -40,7 +40,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
40 40
41 ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno); 41 ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno);
42 audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u", 42 audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
43 current->pid, 43 task_pid_nr(current),
44 from_kuid(&init_user_ns, current_cred()->uid), 44 from_kuid(&init_user_ns, current_cred()->uid),
45 from_kuid(&init_user_ns, audit_get_loginuid(current)), 45 from_kuid(&init_user_ns, audit_get_loginuid(current)),
46 audit_get_sessionid(current)); 46 audit_get_sessionid(current));
diff --git a/security/lsm_audit.c b/security/lsm_audit.c
index 9a62045e6282..69fdf3bc765b 100644
--- a/security/lsm_audit.c
+++ b/security/lsm_audit.c
@@ -220,7 +220,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
220 */ 220 */
221 BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2); 221 BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2);
222 222
223 audit_log_format(ab, " pid=%d comm=", tsk->pid); 223 audit_log_format(ab, " pid=%d comm=", task_pid_nr(tsk));
224 audit_log_untrustedstring(ab, tsk->comm); 224 audit_log_untrustedstring(ab, tsk->comm);
225 225
226 switch (a->type) { 226 switch (a->type) {
@@ -278,9 +278,12 @@ static void dump_common_audit_data(struct audit_buffer *ab,
278 } 278 }
279 case LSM_AUDIT_DATA_TASK: 279 case LSM_AUDIT_DATA_TASK:
280 tsk = a->u.tsk; 280 tsk = a->u.tsk;
281 if (tsk && tsk->pid) { 281 if (tsk) {
282 audit_log_format(ab, " pid=%d comm=", tsk->pid); 282 pid_t pid = task_pid_nr(tsk);
283 audit_log_untrustedstring(ab, tsk->comm); 283 if (pid) {
284 audit_log_format(ab, " pid=%d comm=", pid);
285 audit_log_untrustedstring(ab, tsk->comm);
286 }
284 } 287 }
285 break; 288 break;
286 case LSM_AUDIT_DATA_NET: 289 case LSM_AUDIT_DATA_NET:
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 80a09c37cac8..a3386d119425 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -173,7 +173,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
173 * Use filesystem name if filesystem does not support rename() 173 * Use filesystem name if filesystem does not support rename()
174 * operation. 174 * operation.
175 */ 175 */
176 if (inode->i_op && !inode->i_op->rename) 176 if (!inode->i_op->rename)
177 goto prepend_filesystem_name; 177 goto prepend_filesystem_name;
178 } 178 }
179 /* Prepend device name. */ 179 /* Prepend device name. */
@@ -282,7 +282,7 @@ char *tomoyo_realpath_from_path(struct path *path)
282 * Get local name for filesystems without rename() operation 282 * Get local name for filesystems without rename() operation
283 * or dentry without vfsmount. 283 * or dentry without vfsmount.
284 */ 284 */
285 if (!path->mnt || (inode->i_op && !inode->i_op->rename)) 285 if (!path->mnt || !inode->i_op->rename)
286 pos = tomoyo_get_local_path(path->dentry, buf, 286 pos = tomoyo_get_local_path(path->dentry, buf,
287 buf_len - 1); 287 buf_len - 1);
288 /* Get absolute name for the rest. */ 288 /* Get absolute name for the rest. */
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c
index 6c2dc3863ac0..7e21621e492a 100644
--- a/sound/i2c/cs8427.c
+++ b/sound/i2c/cs8427.c
@@ -150,10 +150,8 @@ static void snd_cs8427_free(struct snd_i2c_device *device)
150 kfree(device->private_data); 150 kfree(device->private_data);
151} 151}
152 152
153int snd_cs8427_create(struct snd_i2c_bus *bus, 153int snd_cs8427_init(struct snd_i2c_bus *bus,
154 unsigned char addr, 154 struct snd_i2c_device *device)
155 unsigned int reset_timeout,
156 struct snd_i2c_device **r_cs8427)
157{ 155{
158 static unsigned char initvals1[] = { 156 static unsigned char initvals1[] = {
159 CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, 157 CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC,
@@ -200,22 +198,10 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
200 Inhibit E->F transfers. */ 198 Inhibit E->F transfers. */
201 CS8427_UD | CS8427_EFTUI | CS8427_DETUI, 199 CS8427_UD | CS8427_EFTUI | CS8427_DETUI,
202 }; 200 };
201 struct cs8427 *chip = device->private_data;
203 int err; 202 int err;
204 struct cs8427 *chip;
205 struct snd_i2c_device *device;
206 unsigned char buf[24]; 203 unsigned char buf[24];
207 204
208 if ((err = snd_i2c_device_create(bus, "CS8427",
209 CS8427_ADDR | (addr & 7),
210 &device)) < 0)
211 return err;
212 chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL);
213 if (chip == NULL) {
214 snd_i2c_device_free(device);
215 return -ENOMEM;
216 }
217 device->private_free = snd_cs8427_free;
218
219 snd_i2c_lock(bus); 205 snd_i2c_lock(bus);
220 err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER); 206 err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER);
221 if (err != CS8427_VER8427A) { 207 if (err != CS8427_VER8427A) {
@@ -264,10 +250,44 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
264 snd_i2c_unlock(bus); 250 snd_i2c_unlock(bus);
265 251
266 /* turn on run bit and rock'n'roll */ 252 /* turn on run bit and rock'n'roll */
253 snd_cs8427_reset(device);
254
255 return 0;
256
257__fail:
258 snd_i2c_unlock(bus);
259
260 return err;
261}
262EXPORT_SYMBOL(snd_cs8427_init);
263
264int snd_cs8427_create(struct snd_i2c_bus *bus,
265 unsigned char addr,
266 unsigned int reset_timeout,
267 struct snd_i2c_device **r_cs8427)
268{
269 int err;
270 struct cs8427 *chip;
271 struct snd_i2c_device *device;
272
273 err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7),
274 &device);
275 if (err < 0)
276 return err;
277 chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL);
278 if (chip == NULL) {
279 snd_i2c_device_free(device);
280 return -ENOMEM;
281 }
282 device->private_free = snd_cs8427_free;
283
267 if (reset_timeout < 1) 284 if (reset_timeout < 1)
268 reset_timeout = 1; 285 reset_timeout = 1;
269 chip->reset_timeout = reset_timeout; 286 chip->reset_timeout = reset_timeout;
270 snd_cs8427_reset(device); 287
288 err = snd_cs8427_init(bus, device);
289 if (err)
290 goto __fail;
271 291
272#if 0 // it's nice for read tests 292#if 0 // it's nice for read tests
273 { 293 {
@@ -286,7 +306,6 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
286 return 0; 306 return 0;
287 307
288 __fail: 308 __fail:
289 snd_i2c_unlock(bus);
290 snd_i2c_device_free(device); 309 snd_i2c_device_free(device);
291 return err < 0 ? err : -EIO; 310 return err < 0 ? err : -EIO;
292} 311}
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index a7cc49e96068..d10ef7675268 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -725,15 +725,4 @@ struct platform_driver au1000_ac97c_driver = {
725 .remove = au1000_ac97_remove, 725 .remove = au1000_ac97_remove,
726}; 726};
727 727
728static int __init au1000_ac97_load(void) 728module_platform_driver(au1000_ac97c_driver);
729{
730 return platform_driver_register(&au1000_ac97c_driver);
731}
732
733static void __exit au1000_ac97_unload(void)
734{
735 platform_driver_unregister(&au1000_ac97c_driver);
736}
737
738module_init(au1000_ac97_load);
739module_exit(au1000_ac97_unload);
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
index 4918b7145b73..ec1ee07df59d 100644
--- a/sound/oss/ad1848.c
+++ b/sound/oss/ad1848.c
@@ -50,8 +50,6 @@
50#include <linux/pnp.h> 50#include <linux/pnp.h>
51#include <linux/spinlock.h> 51#include <linux/spinlock.h>
52 52
53#define DEB(x)
54#define DEB1(x)
55#include "sound_config.h" 53#include "sound_config.h"
56 54
57#include "ad1848.h" 55#include "ad1848.h"
@@ -1016,8 +1014,6 @@ static void ad1848_close(int dev)
1016 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc; 1014 ad1848_info *devc = (ad1848_info *) audio_devs[dev]->devc;
1017 ad1848_port_info *portc = (ad1848_port_info *) audio_devs[dev]->portc; 1015 ad1848_port_info *portc = (ad1848_port_info *) audio_devs[dev]->portc;
1018 1016
1019 DEB(printk("ad1848_close(void)\n"));
1020
1021 devc->intr_active = 0; 1017 devc->intr_active = 0;
1022 ad1848_halt(dev); 1018 ad1848_halt(dev);
1023 1019
diff --git a/sound/oss/dmasound/dmasound_paula.c b/sound/oss/dmasound/dmasound_paula.c
index 87910e992133..c2d45a5848bc 100644
--- a/sound/oss/dmasound/dmasound_paula.c
+++ b/sound/oss/dmasound/dmasound_paula.c
@@ -733,19 +733,7 @@ static struct platform_driver amiga_audio_driver = {
733 }, 733 },
734}; 734};
735 735
736static int __init amiga_audio_init(void) 736module_platform_driver_probe(amiga_audio_driver, amiga_audio_probe);
737{
738 return platform_driver_probe(&amiga_audio_driver, amiga_audio_probe);
739}
740
741module_init(amiga_audio_init);
742
743static void __exit amiga_audio_exit(void)
744{
745 platform_driver_unregister(&amiga_audio_driver);
746}
747
748module_exit(amiga_audio_exit);
749 737
750MODULE_LICENSE("GPL"); 738MODULE_LICENSE("GPL");
751MODULE_ALIAS("platform:amiga-audio"); 739MODULE_ALIAS("platform:amiga-audio");
diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c
index c5c24409ceb0..4709e592e2cc 100644
--- a/sound/oss/opl3.c
+++ b/sound/oss/opl3.c
@@ -275,7 +275,6 @@ static int opl3_kill_note (int devno, int voice, int note, int velocity)
275 devc->v_alloc->map[voice] = 0; 275 devc->v_alloc->map[voice] = 0;
276 276
277 map = &pv_map[devc->lv_map[voice]]; 277 map = &pv_map[devc->lv_map[voice]];
278 DEB(printk("Kill note %d\n", voice));
279 278
280 if (map->voice_mode == 0) 279 if (map->voice_mode == 0)
281 return 0; 280 return 0;
@@ -873,8 +872,6 @@ static void opl3_aftertouch(int dev, int voice, int pressure)
873 872
874 map = &pv_map[devc->lv_map[voice]]; 873 map = &pv_map[devc->lv_map[voice]];
875 874
876 DEB(printk("Aftertouch %d\n", voice));
877
878 if (map->voice_mode == 0) 875 if (map->voice_mode == 0)
879 return; 876 return;
880 877
diff --git a/sound/oss/pas2_mixer.c b/sound/oss/pas2_mixer.c
index a0bcb85c3904..50b5bd501247 100644
--- a/sound/oss/pas2_mixer.c
+++ b/sound/oss/pas2_mixer.c
@@ -21,10 +21,6 @@
21 21
22#include "pas2.h" 22#include "pas2.h"
23 23
24#ifndef DEB
25#define DEB(what) /* (what) */
26#endif
27
28extern int pas_translate_code; 24extern int pas_translate_code;
29extern char pas_model; 25extern char pas_model;
30extern int *pas_osp; 26extern int *pas_osp;
@@ -120,8 +116,6 @@ pas_mixer_set(int whichDev, unsigned int level)
120{ 116{
121 int left, right, devmask, changed, i, mixer = 0; 117 int left, right, devmask, changed, i, mixer = 0;
122 118
123 DEB(printk("static int pas_mixer_set(int whichDev = %d, unsigned int level = %X)\n", whichDev, level));
124
125 left = level & 0x7f; 119 left = level & 0x7f;
126 right = (level & 0x7f00) >> 8; 120 right = (level & 0x7f00) >> 8;
127 121
@@ -207,8 +201,6 @@ pas_mixer_reset(void)
207{ 201{
208 int foo; 202 int foo;
209 203
210 DEB(printk("pas2_mixer.c: void pas_mixer_reset(void)\n"));
211
212 for (foo = 0; foo < SOUND_MIXER_NRDEVICES; foo++) 204 for (foo = 0; foo < SOUND_MIXER_NRDEVICES; foo++)
213 pas_mixer_set(foo, levels[foo]); 205 pas_mixer_set(foo, levels[foo]);
214 206
@@ -220,7 +212,6 @@ static int pas_mixer_ioctl(int dev, unsigned int cmd, void __user *arg)
220 int level,v ; 212 int level,v ;
221 int __user *p = (int __user *)arg; 213 int __user *p = (int __user *)arg;
222 214
223 DEB(printk("pas2_mixer.c: int pas_mixer_ioctl(unsigned int cmd = %X, unsigned int arg = %X)\n", cmd, arg));
224 if (cmd == SOUND_MIXER_PRIVATE1) { /* Set loudness bit */ 215 if (cmd == SOUND_MIXER_PRIVATE1) { /* Set loudness bit */
225 if (get_user(level, p)) 216 if (get_user(level, p))
226 return -EFAULT; 217 return -EFAULT;
diff --git a/sound/oss/pas2_pcm.c b/sound/oss/pas2_pcm.c
index 6f13ab4afc6b..474803b52f7d 100644
--- a/sound/oss/pas2_pcm.c
+++ b/sound/oss/pas2_pcm.c
@@ -22,10 +22,6 @@
22 22
23#include "pas2.h" 23#include "pas2.h"
24 24
25#ifndef DEB
26#define DEB(WHAT)
27#endif
28
29#define PAS_PCM_INTRBITS (0x08) 25#define PAS_PCM_INTRBITS (0x08)
30/* 26/*
31 * Sample buffer timer interrupt enable 27 * Sample buffer timer interrupt enable
@@ -156,8 +152,6 @@ static int pas_audio_ioctl(int dev, unsigned int cmd, void __user *arg)
156 int val, ret; 152 int val, ret;
157 int __user *p = arg; 153 int __user *p = arg;
158 154
159 DEB(printk("pas2_pcm.c: static int pas_audio_ioctl(unsigned int cmd = %X, unsigned int arg = %X)\n", cmd, arg));
160
161 switch (cmd) 155 switch (cmd)
162 { 156 {
163 case SOUND_PCM_WRITE_RATE: 157 case SOUND_PCM_WRITE_RATE:
@@ -204,8 +198,6 @@ static int pas_audio_ioctl(int dev, unsigned int cmd, void __user *arg)
204 198
205static void pas_audio_reset(int dev) 199static void pas_audio_reset(int dev)
206{ 200{
207 DEB(printk("pas2_pcm.c: static void pas_audio_reset(void)\n"));
208
209 pas_write(pas_read(0xF8A) & ~0x40, 0xF8A); /* Disable PCM */ 201 pas_write(pas_read(0xF8A) & ~0x40, 0xF8A); /* Disable PCM */
210} 202}
211 203
@@ -214,8 +206,6 @@ static int pas_audio_open(int dev, int mode)
214 int err; 206 int err;
215 unsigned long flags; 207 unsigned long flags;
216 208
217 DEB(printk("pas2_pcm.c: static int pas_audio_open(int mode = %X)\n", mode));
218
219 spin_lock_irqsave(&pas_lock, flags); 209 spin_lock_irqsave(&pas_lock, flags);
220 if (pcm_busy) 210 if (pcm_busy)
221 { 211 {
@@ -239,8 +229,6 @@ static void pas_audio_close(int dev)
239{ 229{
240 unsigned long flags; 230 unsigned long flags;
241 231
242 DEB(printk("pas2_pcm.c: static void pas_audio_close(void)\n"));
243
244 spin_lock_irqsave(&pas_lock, flags); 232 spin_lock_irqsave(&pas_lock, flags);
245 233
246 pas_audio_reset(dev); 234 pas_audio_reset(dev);
@@ -256,8 +244,6 @@ static void pas_audio_output_block(int dev, unsigned long buf, int count,
256{ 244{
257 unsigned long flags, cnt; 245 unsigned long flags, cnt;
258 246
259 DEB(printk("pas2_pcm.c: static void pas_audio_output_block(char *buf = %P, int count = %X)\n", buf, count));
260
261 cnt = count; 247 cnt = count;
262 if (audio_devs[dev]->dmap_out->dma > 3) 248 if (audio_devs[dev]->dmap_out->dma > 3)
263 cnt >>= 1; 249 cnt >>= 1;
@@ -303,8 +289,6 @@ static void pas_audio_start_input(int dev, unsigned long buf, int count,
303 unsigned long flags; 289 unsigned long flags;
304 int cnt; 290 int cnt;
305 291
306 DEB(printk("pas2_pcm.c: static void pas_audio_start_input(char *buf = %P, int count = %X)\n", buf, count));
307
308 cnt = count; 292 cnt = count;
309 if (audio_devs[dev]->dmap_out->dma > 3) 293 if (audio_devs[dev]->dmap_out->dma > 3)
310 cnt >>= 1; 294 cnt >>= 1;
@@ -388,8 +372,6 @@ static struct audio_driver pas_audio_driver =
388 372
389void __init pas_pcm_init(struct address_info *hw_config) 373void __init pas_pcm_init(struct address_info *hw_config)
390{ 374{
391 DEB(printk("pas2_pcm.c: long pas_pcm_init()\n"));
392
393 pcm_bitsok = 8; 375 pcm_bitsok = 8;
394 if (pas_read(0xEF8B) & 0x08) 376 if (pas_read(0xEF8B) & 0x08)
395 pcm_bitsok |= 16; 377 pcm_bitsok |= 16;
diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c
index 851a1da46be1..3d50fb4236ed 100644
--- a/sound/oss/sb_common.c
+++ b/sound/oss/sb_common.c
@@ -226,8 +226,6 @@ int sb_dsp_reset(sb_devc * devc)
226{ 226{
227 int loopc; 227 int loopc;
228 228
229 DEB(printk("Entered sb_dsp_reset()\n"));
230
231 if (devc->model == MDL_ESS) return ess_dsp_reset (devc); 229 if (devc->model == MDL_ESS) return ess_dsp_reset (devc);
232 230
233 /* This is only for non-ESS chips */ 231 /* This is only for non-ESS chips */
@@ -246,8 +244,6 @@ int sb_dsp_reset(sb_devc * devc)
246 return 0; /* Sorry */ 244 return 0; /* Sorry */
247 } 245 }
248 246
249 DEB(printk("sb_dsp_reset() OK\n"));
250
251 return 1; 247 return 1;
252} 248}
253 249
diff --git a/sound/oss/sb_ess.c b/sound/oss/sb_ess.c
index 0e7254bde4c2..b47a69026f1b 100644
--- a/sound/oss/sb_ess.c
+++ b/sound/oss/sb_ess.c
@@ -865,8 +865,6 @@ printk(KERN_INFO "FKS: ess_dsp_reset 1\n");
865ess_show_mixerregs (devc); 865ess_show_mixerregs (devc);
866#endif 866#endif
867 867
868 DEB(printk("Entered ess_dsp_reset()\n"));
869
870 outb(3, DSP_RESET); /* Reset FIFO too */ 868 outb(3, DSP_RESET); /* Reset FIFO too */
871 869
872 udelay(10); 870 udelay(10);
@@ -881,8 +879,6 @@ ess_show_mixerregs (devc);
881 } 879 }
882 ess_extended (devc); 880 ess_extended (devc);
883 881
884 DEB(printk("sb_dsp_reset() OK\n"));
885
886#ifdef FKS_LOGGING 882#ifdef FKS_LOGGING
887printk(KERN_INFO "FKS: dsp_reset 2\n"); 883printk(KERN_INFO "FKS: dsp_reset 2\n");
888ess_show_mixerregs (devc); 884ess_show_mixerregs (devc);
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 9b9f7d385134..c0eea1dfe90f 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -216,8 +216,6 @@ int sequencer_write(int dev, struct file *file, const char __user *buf, int coun
216 216
217 dev = dev >> 4; 217 dev = dev >> 4;
218 218
219 DEB(printk("sequencer_write(dev=%d, count=%d)\n", dev, count));
220
221 if (mode == OPEN_READ) 219 if (mode == OPEN_READ)
222 return -EIO; 220 return -EIO;
223 221
@@ -959,8 +957,6 @@ int sequencer_open(int dev, struct file *file)
959 dev = dev >> 4; 957 dev = dev >> 4;
960 mode = translate_mode(file); 958 mode = translate_mode(file);
961 959
962 DEB(printk("sequencer_open(dev=%d)\n", dev));
963
964 if (!sequencer_ok) 960 if (!sequencer_ok)
965 { 961 {
966/* printk("Sound card: sequencer not initialized\n");*/ 962/* printk("Sound card: sequencer not initialized\n");*/
@@ -1133,8 +1129,6 @@ void sequencer_release(int dev, struct file *file)
1133 1129
1134 dev = dev >> 4; 1130 dev = dev >> 4;
1135 1131
1136 DEB(printk("sequencer_release(dev=%d)\n", dev));
1137
1138 /* 1132 /*
1139 * Wait until the queue is empty (if we don't have nonblock) 1133 * Wait until the queue is empty (if we don't have nonblock)
1140 */ 1134 */
diff --git a/sound/oss/sound_config.h b/sound/oss/sound_config.h
index 9d35c4c65b9b..f2554ab78f5e 100644
--- a/sound/oss/sound_config.h
+++ b/sound/oss/sound_config.h
@@ -123,10 +123,6 @@ static inline int translate_mode(struct file *file)
123#include "sound_calls.h" 123#include "sound_calls.h"
124#include "dev_table.h" 124#include "dev_table.h"
125 125
126#ifndef DEB
127#define DEB(x)
128#endif
129
130#ifndef DDB 126#ifndef DDB
131#define DDB(x) do {} while (0) 127#define DDB(x) do {} while (0)
132#endif 128#endif
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index e7780349cc55..b70c7c8f9c5d 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -154,7 +154,6 @@ static ssize_t sound_read(struct file *file, char __user *buf, size_t count, lof
154 154
155 mutex_lock(&soundcard_mutex); 155 mutex_lock(&soundcard_mutex);
156 156
157 DEB(printk("sound_read(dev=%d, count=%d)\n", dev, count));
158 switch (dev & 0x0f) { 157 switch (dev & 0x0f) {
159 case SND_DEV_DSP: 158 case SND_DEV_DSP:
160 case SND_DEV_DSP16: 159 case SND_DEV_DSP16:
@@ -180,7 +179,6 @@ static ssize_t sound_write(struct file *file, const char __user *buf, size_t cou
180 int ret = -EINVAL; 179 int ret = -EINVAL;
181 180
182 mutex_lock(&soundcard_mutex); 181 mutex_lock(&soundcard_mutex);
183 DEB(printk("sound_write(dev=%d, count=%d)\n", dev, count));
184 switch (dev & 0x0f) { 182 switch (dev & 0x0f) {
185 case SND_DEV_SEQ: 183 case SND_DEV_SEQ:
186 case SND_DEV_SEQ2: 184 case SND_DEV_SEQ2:
@@ -206,7 +204,6 @@ static int sound_open(struct inode *inode, struct file *file)
206 int dev = iminor(inode); 204 int dev = iminor(inode);
207 int retval; 205 int retval;
208 206
209 DEB(printk("sound_open(dev=%d)\n", dev));
210 if ((dev >= SND_NDEVS) || (dev < 0)) { 207 if ((dev >= SND_NDEVS) || (dev < 0)) {
211 printk(KERN_ERR "Invalid minor device %d\n", dev); 208 printk(KERN_ERR "Invalid minor device %d\n", dev);
212 return -ENXIO; 209 return -ENXIO;
@@ -257,7 +254,6 @@ static int sound_release(struct inode *inode, struct file *file)
257 int dev = iminor(inode); 254 int dev = iminor(inode);
258 255
259 mutex_lock(&soundcard_mutex); 256 mutex_lock(&soundcard_mutex);
260 DEB(printk("sound_release(dev=%d)\n", dev));
261 switch (dev & 0x0f) { 257 switch (dev & 0x0f) {
262 case SND_DEV_CTL: 258 case SND_DEV_CTL:
263 module_put(mixer_devs[dev >> 4]->owner); 259 module_put(mixer_devs[dev >> 4]->owner);
@@ -351,7 +347,6 @@ static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
351 if (!access_ok(VERIFY_WRITE, p, len)) 347 if (!access_ok(VERIFY_WRITE, p, len))
352 return -EFAULT; 348 return -EFAULT;
353 } 349 }
354 DEB(printk("sound_ioctl(dev=%d, cmd=0x%x, arg=0x%x)\n", dev, cmd, arg));
355 if (cmd == OSS_GETVERSION) 350 if (cmd == OSS_GETVERSION)
356 return __put_user(SOUND_VERSION, (int __user *)p); 351 return __put_user(SOUND_VERSION, (int __user *)p);
357 352
@@ -409,7 +404,6 @@ static unsigned int sound_poll(struct file *file, poll_table * wait)
409 struct inode *inode = file_inode(file); 404 struct inode *inode = file_inode(file);
410 int dev = iminor(inode); 405 int dev = iminor(inode);
411 406
412 DEB(printk("sound_poll(dev=%d)\n", dev));
413 switch (dev & 0x0f) { 407 switch (dev & 0x0f) {
414 case SND_DEV_SEQ: 408 case SND_DEV_SEQ:
415 case SND_DEV_SEQ2: 409 case SND_DEV_SEQ2:
diff --git a/sound/oss/uart401.c b/sound/oss/uart401.c
index 5433c6f5eca2..62b8869f5a4c 100644
--- a/sound/oss/uart401.c
+++ b/sound/oss/uart401.c
@@ -274,19 +274,12 @@ static int reset_uart401(uart401_devc * devc)
274 } 274 }
275 } 275 }
276 276
277 277 /* Flush input before enabling interrupts */
278 if (ok) 278 if (ok)
279 { 279 uart401_input_loop(devc);
280 DEB(printk("Reset UART401 OK\n"));
281 }
282 else 280 else
283 DDB(printk("Reset UART401 failed - No hardware detected.\n")); 281 DDB(printk("Reset UART401 failed - No hardware detected.\n"));
284 282
285 if (ok)
286 uart401_input_loop(devc); /*
287 * Flush input before enabling interrupts
288 */
289
290 return ok; 283 return ok;
291} 284}
292 285
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 97993e17f46a..248b90abb882 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -187,13 +187,14 @@ azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
187 struct azx_dev *azx_dev = &chip->azx_dev[dev]; 187 struct azx_dev *azx_dev = &chip->azx_dev[dev];
188 dsp_lock(azx_dev); 188 dsp_lock(azx_dev);
189 if (!azx_dev->opened && !dsp_is_locked(azx_dev)) { 189 if (!azx_dev->opened && !dsp_is_locked(azx_dev)) {
190 res = azx_dev; 190 if (azx_dev->assigned_key == key) {
191 if (res->assigned_key == key) { 191 azx_dev->opened = 1;
192 res->opened = 1; 192 azx_dev->assigned_key = key;
193 res->assigned_key = key;
194 dsp_unlock(azx_dev); 193 dsp_unlock(azx_dev);
195 return azx_dev; 194 return azx_dev;
196 } 195 }
196 if (!res)
197 res = azx_dev;
197 } 198 }
198 dsp_unlock(azx_dev); 199 dsp_unlock(azx_dev);
199 } 200 }
@@ -1604,7 +1605,7 @@ static void azx_exit_link_reset(struct azx *chip)
1604} 1605}
1605 1606
1606/* reset codec link */ 1607/* reset codec link */
1607static int azx_reset(struct azx *chip, int full_reset) 1608static int azx_reset(struct azx *chip, bool full_reset)
1608{ 1609{
1609 if (!full_reset) 1610 if (!full_reset)
1610 goto __skip; 1611 goto __skip;
@@ -1701,7 +1702,7 @@ static void azx_int_clear(struct azx *chip)
1701/* 1702/*
1702 * reset and start the controller registers 1703 * reset and start the controller registers
1703 */ 1704 */
1704void azx_init_chip(struct azx *chip, int full_reset) 1705void azx_init_chip(struct azx *chip, bool full_reset)
1705{ 1706{
1706 if (chip->initialized) 1707 if (chip->initialized)
1707 return; 1708 return;
@@ -1758,7 +1759,7 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
1758 1759
1759#ifdef CONFIG_PM_RUNTIME 1760#ifdef CONFIG_PM_RUNTIME
1760 if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME) 1761 if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME)
1761 if (chip->card->dev->power.runtime_status != RPM_ACTIVE) 1762 if (!pm_runtime_active(chip->card->dev))
1762 return IRQ_NONE; 1763 return IRQ_NONE;
1763#endif 1764#endif
1764 1765
@@ -1841,7 +1842,7 @@ static void azx_bus_reset(struct hda_bus *bus)
1841 1842
1842 bus->in_reset = 1; 1843 bus->in_reset = 1;
1843 azx_stop_chip(chip); 1844 azx_stop_chip(chip);
1844 azx_init_chip(chip, 1); 1845 azx_init_chip(chip, true);
1845#ifdef CONFIG_PM 1846#ifdef CONFIG_PM
1846 if (chip->initialized) { 1847 if (chip->initialized) {
1847 struct azx_pcm *p; 1848 struct azx_pcm *p;
@@ -1948,7 +1949,7 @@ int azx_codec_create(struct azx *chip, const char *model,
1948 * get back to the sanity state. 1949 * get back to the sanity state.
1949 */ 1950 */
1950 azx_stop_chip(chip); 1951 azx_stop_chip(chip);
1951 azx_init_chip(chip, 1); 1952 azx_init_chip(chip, true);
1952 } 1953 }
1953 } 1954 }
1954 } 1955 }
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
index 1d2e3be2bae6..baf0e77330af 100644
--- a/sound/pci/hda/hda_controller.h
+++ b/sound/pci/hda/hda_controller.h
@@ -37,7 +37,7 @@ int azx_alloc_stream_pages(struct azx *chip);
37void azx_free_stream_pages(struct azx *chip); 37void azx_free_stream_pages(struct azx *chip);
38 38
39/* Low level azx interface */ 39/* Low level azx interface */
40void azx_init_chip(struct azx *chip, int full_reset); 40void azx_init_chip(struct azx *chip, bool full_reset);
41void azx_stop_chip(struct azx *chip); 41void azx_stop_chip(struct azx *chip);
42void azx_enter_link_reset(struct azx *chip); 42void azx_enter_link_reset(struct azx *chip);
43irqreturn_t azx_interrupt(int irq, void *dev_id); 43irqreturn_t azx_interrupt(int irq, void *dev_id);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 77ca894f8284..d6bca62ef387 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -636,7 +636,7 @@ static int azx_resume(struct device *dev)
636 return -EIO; 636 return -EIO;
637 azx_init_pci(chip); 637 azx_init_pci(chip);
638 638
639 azx_init_chip(chip, 1); 639 azx_init_chip(chip, true);
640 640
641 snd_hda_resume(chip->bus); 641 snd_hda_resume(chip->bus);
642 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 642 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -689,7 +689,7 @@ static int azx_runtime_resume(struct device *dev)
689 status = azx_readw(chip, STATESTS); 689 status = azx_readw(chip, STATESTS);
690 690
691 azx_init_pci(chip); 691 azx_init_pci(chip);
692 azx_init_chip(chip, 1); 692 azx_init_chip(chip, true);
693 693
694 bus = chip->bus; 694 bus = chip->bus;
695 if (status && bus) { 695 if (status && bus) {
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ea2351d119f0..14ae979a92ea 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3026,6 +3026,11 @@ static void alc283_init(struct hda_codec *codec)
3026 bool hp_pin_sense; 3026 bool hp_pin_sense;
3027 int val; 3027 int val;
3028 3028
3029 if (!spec->gen.autocfg.hp_outs) {
3030 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3031 hp_pin = spec->gen.autocfg.line_out_pins[0];
3032 }
3033
3029 alc283_restore_default_value(codec); 3034 alc283_restore_default_value(codec);
3030 3035
3031 if (!hp_pin) 3036 if (!hp_pin)
@@ -3062,6 +3067,11 @@ static void alc283_shutup(struct hda_codec *codec)
3062 bool hp_pin_sense; 3067 bool hp_pin_sense;
3063 int val; 3068 int val;
3064 3069
3070 if (!spec->gen.autocfg.hp_outs) {
3071 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3072 hp_pin = spec->gen.autocfg.line_out_pins[0];
3073 }
3074
3065 if (!hp_pin) { 3075 if (!hp_pin) {
3066 alc269_shutup(codec); 3076 alc269_shutup(codec);
3067 return; 3077 return;
@@ -3085,6 +3095,7 @@ static void alc283_shutup(struct hda_codec *codec)
3085 3095
3086 if (hp_pin_sense) 3096 if (hp_pin_sense)
3087 msleep(100); 3097 msleep(100);
3098 alc_auto_setup_eapd(codec, false);
3088 snd_hda_shutup_pins(codec); 3099 snd_hda_shutup_pins(codec);
3089 alc_write_coef_idx(codec, 0x43, 0x9614); 3100 alc_write_coef_idx(codec, 0x43, 0x9614);
3090} 3101}
@@ -3361,8 +3372,9 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
3361 3372
3362 if (spec->mute_led_polarity) 3373 if (spec->mute_led_polarity)
3363 enabled = !enabled; 3374 enabled = !enabled;
3364 pinval = AC_PINCTL_IN_EN | 3375 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3365 (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); 3376 pinval &= ~AC_PINCTL_VREFEN;
3377 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
3366 if (spec->mute_led_nid) 3378 if (spec->mute_led_nid)
3367 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); 3379 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
3368} 3380}
@@ -3994,6 +4006,10 @@ static void alc283_fixup_chromebook(struct hda_codec *codec,
3994 spec->gen.mixer_nid = 0; 4006 spec->gen.mixer_nid = 0;
3995 break; 4007 break;
3996 case HDA_FIXUP_ACT_INIT: 4008 case HDA_FIXUP_ACT_INIT:
4009 /* MIC2-VREF control */
4010 /* Set to manual mode */
4011 val = alc_read_coef_idx(codec, 0x06);
4012 alc_write_coef_idx(codec, 0x06, val & ~0x000c);
3997 /* Enable Line1 input control by verb */ 4013 /* Enable Line1 input control by verb */
3998 val = alc_read_coef_idx(codec, 0x1a); 4014 val = alc_read_coef_idx(codec, 0x1a);
3999 alc_write_coef_idx(codec, 0x1a, val | (1 << 4)); 4015 alc_write_coef_idx(codec, 0x1a, val | (1 << 4));
@@ -4602,6 +4618,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4602 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4618 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4603 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4619 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4604 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4620 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4621 SND_PCI_QUIRK(0x1028, 0x0667, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4605 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4622 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4606 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4623 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4607 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4624 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
@@ -4768,7 +4785,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
4768 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, 4785 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
4769 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, 4786 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
4770 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"}, 4787 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
4771 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-chrome"}, 4788 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
4772 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"}, 4789 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
4773 {} 4790 {}
4774}; 4791};
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index ed2144eee38a..496dbd0ad5db 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -579,12 +579,37 @@ static struct snd_ak4xxx_private akm_vx442_priv = {
579#ifdef CONFIG_PM_SLEEP 579#ifdef CONFIG_PM_SLEEP
580static int snd_ice1712_delta_resume(struct snd_ice1712 *ice) 580static int snd_ice1712_delta_resume(struct snd_ice1712 *ice)
581{ 581{
582 unsigned char akm_backup[AK4XXX_IMAGE_SIZE]; 582 unsigned char akm_img_bak[AK4XXX_IMAGE_SIZE];
583 unsigned char akm_vol_bak[AK4XXX_IMAGE_SIZE];
584
585 /* init spdif */
586 switch (ice->eeprom.subvendor) {
587 case ICE1712_SUBDEVICE_AUDIOPHILE:
588 case ICE1712_SUBDEVICE_DELTA410:
589 case ICE1712_SUBDEVICE_DELTA1010E:
590 case ICE1712_SUBDEVICE_DELTA1010LT:
591 case ICE1712_SUBDEVICE_VX442:
592 case ICE1712_SUBDEVICE_DELTA66E:
593 snd_cs8427_init(ice->i2c, ice->cs8427);
594 break;
595 case ICE1712_SUBDEVICE_DELTA1010:
596 case ICE1712_SUBDEVICE_MEDIASTATION:
597 /* nothing */
598 break;
599 case ICE1712_SUBDEVICE_DELTADIO2496:
600 case ICE1712_SUBDEVICE_DELTA66:
601 /* Set spdif defaults */
602 snd_ice1712_delta_cs8403_spdif_write(ice, ice->spdif.cs8403_bits);
603 break;
604 }
605
583 /* init codec and restore registers */ 606 /* init codec and restore registers */
584 if (ice->akm_codecs) { 607 if (ice->akm_codecs) {
585 memcpy(akm_backup, ice->akm->images, sizeof(akm_backup)); 608 memcpy(akm_img_bak, ice->akm->images, sizeof(akm_img_bak));
609 memcpy(akm_vol_bak, ice->akm->volumes, sizeof(akm_vol_bak));
586 snd_akm4xxx_init(ice->akm); 610 snd_akm4xxx_init(ice->akm);
587 memcpy(ice->akm->images, akm_backup, sizeof(akm_backup)); 611 memcpy(ice->akm->images, akm_img_bak, sizeof(akm_img_bak));
612 memcpy(ice->akm->volumes, akm_vol_bak, sizeof(akm_vol_bak));
588 snd_akm4xxx_reset(ice->akm, 0); 613 snd_akm4xxx_reset(ice->akm, 0);
589 } 614 }
590 615
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 291672fc4a99..d9b9e4595f17 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -685,9 +685,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pointer(struct snd_pcm_substream *
685 if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1)) 685 if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1))
686 return 0; 686 return 0;
687 ptr = runtime->buffer_size - inw(ice->ddma_port + 4); 687 ptr = runtime->buffer_size - inw(ice->ddma_port + 4);
688 ptr = bytes_to_frames(substream->runtime, ptr);
688 if (ptr == runtime->buffer_size) 689 if (ptr == runtime->buffer_size)
689 ptr = 0; 690 ptr = 0;
690 return bytes_to_frames(substream->runtime, ptr); 691 return ptr;
691} 692}
692 693
693static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substream *substream) 694static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substream *substream)
@@ -704,9 +705,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substrea
704 addr = ICE1712_DSC_ADDR0; 705 addr = ICE1712_DSC_ADDR0;
705 ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) - 706 ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) -
706 ice->playback_con_virt_addr[substream->number]; 707 ice->playback_con_virt_addr[substream->number];
708 ptr = bytes_to_frames(substream->runtime, ptr);
707 if (ptr == substream->runtime->buffer_size) 709 if (ptr == substream->runtime->buffer_size)
708 ptr = 0; 710 ptr = 0;
709 return bytes_to_frames(substream->runtime, ptr); 711 return ptr;
710} 712}
711 713
712static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *substream) 714static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *substream)
@@ -717,9 +719,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s
717 if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1)) 719 if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1))
718 return 0; 720 return 0;
719 ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr; 721 ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr;
722 ptr = bytes_to_frames(substream->runtime, ptr);
720 if (ptr == substream->runtime->buffer_size) 723 if (ptr == substream->runtime->buffer_size)
721 ptr = 0; 724 ptr = 0;
722 return bytes_to_frames(substream->runtime, ptr); 725 return ptr;
723} 726}
724 727
725static const struct snd_pcm_hardware snd_ice1712_playback = { 728static const struct snd_pcm_hardware snd_ice1712_playback = {
@@ -1048,6 +1051,8 @@ __out:
1048 old = inb(ICEMT(ice, RATE)); 1051 old = inb(ICEMT(ice, RATE));
1049 if (!force && old == val) 1052 if (!force && old == val)
1050 goto __out; 1053 goto __out;
1054
1055 ice->cur_rate = rate;
1051 outb(val, ICEMT(ice, RATE)); 1056 outb(val, ICEMT(ice, RATE));
1052 spin_unlock_irqrestore(&ice->reg_lock, flags); 1057 spin_unlock_irqrestore(&ice->reg_lock, flags);
1053 1058
@@ -1114,9 +1119,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substre
1114 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START)) 1119 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START))
1115 return 0; 1120 return 0;
1116 ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2); 1121 ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2);
1122 ptr = bytes_to_frames(substream->runtime, ptr);
1117 if (ptr == substream->runtime->buffer_size) 1123 if (ptr == substream->runtime->buffer_size)
1118 ptr = 0; 1124 ptr = 0;
1119 return bytes_to_frames(substream->runtime, ptr); 1125 return ptr;
1120} 1126}
1121 1127
1122static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substream *substream) 1128static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substream *substream)
@@ -1127,9 +1133,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea
1127 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW)) 1133 if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW))
1128 return 0; 1134 return 0;
1129 ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2); 1135 ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2);
1136 ptr = bytes_to_frames(substream->runtime, ptr);
1130 if (ptr == substream->runtime->buffer_size) 1137 if (ptr == substream->runtime->buffer_size)
1131 ptr = 0; 1138 ptr = 0;
1132 return bytes_to_frames(substream->runtime, ptr); 1139 return ptr;
1133} 1140}
1134 1141
1135static const struct snd_pcm_hardware snd_ice1712_playback_pro = { 1142static const struct snd_pcm_hardware snd_ice1712_playback_pro = {
@@ -2832,6 +2839,12 @@ static int snd_ice1712_suspend(struct device *dev)
2832 snd_pcm_suspend_all(ice->pcm_ds); 2839 snd_pcm_suspend_all(ice->pcm_ds);
2833 snd_ac97_suspend(ice->ac97); 2840 snd_ac97_suspend(ice->ac97);
2834 2841
2842 spin_lock_irq(&ice->reg_lock);
2843 ice->pm_saved_is_spdif_master = is_spdif_master(ice);
2844 ice->pm_saved_spdif_ctrl = inw(ICEMT(ice, ROUTE_SPDOUT));
2845 ice->pm_saved_route = inw(ICEMT(ice, ROUTE_PSDOUT03));
2846 spin_unlock_irq(&ice->reg_lock);
2847
2835 if (ice->pm_suspend) 2848 if (ice->pm_suspend)
2836 ice->pm_suspend(ice); 2849 ice->pm_suspend(ice);
2837 2850
@@ -2846,6 +2859,7 @@ static int snd_ice1712_resume(struct device *dev)
2846 struct pci_dev *pci = to_pci_dev(dev); 2859 struct pci_dev *pci = to_pci_dev(dev);
2847 struct snd_card *card = dev_get_drvdata(dev); 2860 struct snd_card *card = dev_get_drvdata(dev);
2848 struct snd_ice1712 *ice = card->private_data; 2861 struct snd_ice1712 *ice = card->private_data;
2862 int rate;
2849 2863
2850 if (!ice->pm_suspend_enabled) 2864 if (!ice->pm_suspend_enabled)
2851 return 0; 2865 return 0;
@@ -2860,14 +2874,37 @@ static int snd_ice1712_resume(struct device *dev)
2860 2874
2861 pci_set_master(pci); 2875 pci_set_master(pci);
2862 2876
2877 if (ice->cur_rate)
2878 rate = ice->cur_rate;
2879 else
2880 rate = PRO_RATE_DEFAULT;
2881
2863 if (snd_ice1712_chip_init(ice) < 0) { 2882 if (snd_ice1712_chip_init(ice) < 0) {
2864 snd_card_disconnect(card); 2883 snd_card_disconnect(card);
2865 return -EIO; 2884 return -EIO;
2866 } 2885 }
2867 2886
2887 ice->cur_rate = rate;
2888
2868 if (ice->pm_resume) 2889 if (ice->pm_resume)
2869 ice->pm_resume(ice); 2890 ice->pm_resume(ice);
2870 2891
2892 if (ice->pm_saved_is_spdif_master) {
2893 /* switching to external clock via SPDIF */
2894 spin_lock_irq(&ice->reg_lock);
2895 outb(inb(ICEMT(ice, RATE)) | ICE1712_SPDIF_MASTER,
2896 ICEMT(ice, RATE));
2897 spin_unlock_irq(&ice->reg_lock);
2898 snd_ice1712_set_input_clock_source(ice, 1);
2899 } else {
2900 /* internal on-card clock */
2901 snd_ice1712_set_pro_rate(ice, rate, 1);
2902 snd_ice1712_set_input_clock_source(ice, 0);
2903 }
2904
2905 outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
2906 outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
2907
2871 if (ice->ac97) 2908 if (ice->ac97)
2872 snd_ac97_resume(ice->ac97); 2909 snd_ac97_resume(ice->ac97);
2873 2910
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index 09f7e773bafb..f500905e9373 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -902,7 +902,6 @@ static int alc5623_probe(struct snd_soc_codec *codec)
902{ 902{
903 struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); 903 struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
904 struct snd_soc_dapm_context *dapm = &codec->dapm; 904 struct snd_soc_dapm_context *dapm = &codec->dapm;
905 int ret;
906 905
907 alc5623_reset(codec); 906 alc5623_reset(codec);
908 907
@@ -961,7 +960,7 @@ static int alc5623_probe(struct snd_soc_codec *codec)
961 return -EINVAL; 960 return -EINVAL;
962 } 961 }
963 962
964 return ret; 963 return 0;
965} 964}
966 965
967/* power down chip */ 966/* power down chip */
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
index ec071a6306ef..85942ca36cbf 100644
--- a/sound/soc/codecs/alc5632.c
+++ b/sound/soc/codecs/alc5632.c
@@ -1061,7 +1061,6 @@ static int alc5632_resume(struct snd_soc_codec *codec)
1061static int alc5632_probe(struct snd_soc_codec *codec) 1061static int alc5632_probe(struct snd_soc_codec *codec)
1062{ 1062{
1063 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec); 1063 struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec);
1064 int ret;
1065 1064
1066 /* power on device */ 1065 /* power on device */
1067 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1066 alc5632_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
@@ -1075,7 +1074,7 @@ static int alc5632_probe(struct snd_soc_codec *codec)
1075 return -EINVAL; 1074 return -EINVAL;
1076 } 1075 }
1077 1076
1078 return ret; 1077 return 0;
1079} 1078}
1080 1079
1081/* power down chip */ 1080/* power down chip */
@@ -1191,11 +1190,18 @@ static const struct i2c_device_id alc5632_i2c_table[] = {
1191}; 1190};
1192MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table); 1191MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
1193 1192
1193static const struct of_device_id alc5632_of_match[] = {
1194 { .compatible = "realtek,alc5632", },
1195 { }
1196};
1197MODULE_DEVICE_TABLE(of, alc5632_of_match);
1198
1194/* i2c codec control layer */ 1199/* i2c codec control layer */
1195static struct i2c_driver alc5632_i2c_driver = { 1200static struct i2c_driver alc5632_i2c_driver = {
1196 .driver = { 1201 .driver = {
1197 .name = "alc5632", 1202 .name = "alc5632",
1198 .owner = THIS_MODULE, 1203 .owner = THIS_MODULE,
1204 .of_match_table = of_match_ptr(alc5632_of_match),
1199 }, 1205 },
1200 .probe = alc5632_i2c_probe, 1206 .probe = alc5632_i2c_probe,
1201 .remove = alc5632_i2c_remove, 1207 .remove = alc5632_i2c_remove,
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index f0ca6bee6771..460d35547a68 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -1259,7 +1259,7 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
1259 } 1259 }
1260 1260
1261 dev_info(&i2c_client->dev, "Cirrus Logic CS42L52, Revision: %02X\n", 1261 dev_info(&i2c_client->dev, "Cirrus Logic CS42L52, Revision: %02X\n",
1262 reg & 0xFF); 1262 reg & CS42L52_CHIP_REV_MASK);
1263 1263
1264 /* Set Platform Data */ 1264 /* Set Platform Data */
1265 if (cs42l52->pdata.mica_diff_cfg) 1265 if (cs42l52->pdata.mica_diff_cfg)
diff --git a/sound/soc/codecs/cs42l52.h b/sound/soc/codecs/cs42l52.h
index 6fb8f00f4191..ac445993e6bf 100644
--- a/sound/soc/codecs/cs42l52.h
+++ b/sound/soc/codecs/cs42l52.h
@@ -37,7 +37,7 @@
37#define CS42L52_CHIP_REV_A0 0x00 37#define CS42L52_CHIP_REV_A0 0x00
38#define CS42L52_CHIP_REV_A1 0x01 38#define CS42L52_CHIP_REV_A1 0x01
39#define CS42L52_CHIP_REV_B0 0x02 39#define CS42L52_CHIP_REV_B0 0x02
40#define CS42L52_CHIP_REV_MASK 0x03 40#define CS42L52_CHIP_REV_MASK 0x07
41 41
42#define CS42L52_PWRCTL1 0x02 42#define CS42L52_PWRCTL1 0x02
43#define CS42L52_PWRCTL1_PDN_ALL 0x9F 43#define CS42L52_PWRCTL1_PDN_ALL 0x9F
diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c
index 082299a4e2fa..85020322eee7 100644
--- a/sound/soc/codecs/cs42xx8.c
+++ b/sound/soc/codecs/cs42xx8.c
@@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap)
495 regcache_cache_bypass(cs42xx8->regmap, true); 495 regcache_cache_bypass(cs42xx8->regmap, true);
496 496
497 /* Validate the chip ID */ 497 /* Validate the chip ID */
498 regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val); 498 ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val);
499 if (val < 0) { 499 if (ret < 0) {
500 dev_err(dev, "failed to get device ID: %x", val); 500 dev_err(dev, "failed to get device ID, ret = %d", ret);
501 ret = -EINVAL;
502 goto err_enable; 501 goto err_enable;
503 } 502 }
504 503
505 /* The top four bits of the chip ID should be 0000 */ 504 /* The top four bits of the chip ID should be 0000 */
506 if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) { 505 if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) {
507 dev_err(dev, "unmatched chip ID: %d\n", 506 dev_err(dev, "unmatched chip ID: %d\n",
508 val & CS42XX8_CHIPID_CHIP_ID_MASK); 507 (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4);
509 ret = -EINVAL; 508 ret = -EINVAL;
510 goto err_enable; 509 goto err_enable;
511 } 510 }
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c
index 7d168ec71cd7..48f3fef68484 100644
--- a/sound/soc/codecs/da732x.c
+++ b/sound/soc/codecs/da732x.c
@@ -1571,7 +1571,8 @@ static int da732x_i2c_probe(struct i2c_client *i2c,
1571 } 1571 }
1572 1572
1573 dev_info(&i2c->dev, "Revision: %d.%d\n", 1573 dev_info(&i2c->dev, "Revision: %d.%d\n",
1574 (reg & DA732X_ID_MAJOR_MASK), (reg & DA732X_ID_MINOR_MASK)); 1574 (reg & DA732X_ID_MAJOR_MASK) >> 4,
1575 (reg & DA732X_ID_MINOR_MASK));
1575 1576
1576 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da732x, 1577 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da732x,
1577 da732x_dai, ARRAY_SIZE(da732x_dai)); 1578 da732x_dai, ARRAY_SIZE(da732x_dai));
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 98c6e104357c..f7b0b37aa858 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -2399,11 +2399,18 @@ static const struct i2c_device_id max98090_i2c_id[] = {
2399}; 2399};
2400MODULE_DEVICE_TABLE(i2c, max98090_i2c_id); 2400MODULE_DEVICE_TABLE(i2c, max98090_i2c_id);
2401 2401
2402static const struct of_device_id max98090_of_match[] = {
2403 { .compatible = "maxim,max98090", },
2404 { }
2405};
2406MODULE_DEVICE_TABLE(of, max98090_of_match);
2407
2402static struct i2c_driver max98090_i2c_driver = { 2408static struct i2c_driver max98090_i2c_driver = {
2403 .driver = { 2409 .driver = {
2404 .name = "max98090", 2410 .name = "max98090",
2405 .owner = THIS_MODULE, 2411 .owner = THIS_MODULE,
2406 .pm = &max98090_pm, 2412 .pm = &max98090_pm,
2413 .of_match_table = of_match_ptr(max98090_of_match),
2407 }, 2414 },
2408 .probe = max98090_i2c_probe, 2415 .probe = max98090_i2c_probe,
2409 .remove = max98090_i2c_remove, 2416 .remove = max98090_i2c_remove,
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index 0061ae6b6716..68b4dd622b87 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -2074,6 +2074,14 @@ static const struct i2c_device_id rt5640_i2c_id[] = {
2074}; 2074};
2075MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); 2075MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id);
2076 2076
2077#if defined(CONFIG_OF)
2078static const struct of_device_id rt5640_of_match[] = {
2079 { .compatible = "realtek,rt5640", },
2080 {},
2081};
2082MODULE_DEVICE_TABLE(of, rt5640_of_match);
2083#endif
2084
2077#ifdef CONFIG_ACPI 2085#ifdef CONFIG_ACPI
2078static struct acpi_device_id rt5640_acpi_match[] = { 2086static struct acpi_device_id rt5640_acpi_match[] = {
2079 { "INT33CA", 0 }, 2087 { "INT33CA", 0 },
@@ -2203,6 +2211,7 @@ static struct i2c_driver rt5640_i2c_driver = {
2203 .name = "rt5640", 2211 .name = "rt5640",
2204 .owner = THIS_MODULE, 2212 .owner = THIS_MODULE,
2205 .acpi_match_table = ACPI_PTR(rt5640_acpi_match), 2213 .acpi_match_table = ACPI_PTR(rt5640_acpi_match),
2214 .of_match_table = of_match_ptr(rt5640_of_match),
2206 }, 2215 },
2207 .probe = rt5640_i2c_probe, 2216 .probe = rt5640_i2c_probe,
2208 .remove = rt5640_i2c_remove, 2217 .remove = rt5640_i2c_remove,
diff --git a/sound/soc/codecs/tlv320aic23-i2c.c b/sound/soc/codecs/tlv320aic23-i2c.c
index 20fc46092c2c..b73c94ebcc2a 100644
--- a/sound/soc/codecs/tlv320aic23-i2c.c
+++ b/sound/soc/codecs/tlv320aic23-i2c.c
@@ -43,9 +43,16 @@ static const struct i2c_device_id tlv320aic23_id[] = {
43 43
44MODULE_DEVICE_TABLE(i2c, tlv320aic23_id); 44MODULE_DEVICE_TABLE(i2c, tlv320aic23_id);
45 45
46static const struct of_device_id tlv320aic23_of_match[] = {
47 { .compatible = "ti,tlv320aic23", },
48 { }
49};
50MODULE_DEVICE_TABLE(of, tlv320aic23_of_match);
51
46static struct i2c_driver tlv320aic23_i2c_driver = { 52static struct i2c_driver tlv320aic23_i2c_driver = {
47 .driver = { 53 .driver = {
48 .name = "tlv320aic23-codec", 54 .name = "tlv320aic23-codec",
55 .of_match_table = of_match_ptr(tlv320aic23_of_match),
49 }, 56 },
50 .probe = tlv320aic23_i2c_probe, 57 .probe = tlv320aic23_i2c_probe,
51 .remove = __exit_p(tlv320aic23_i2c_remove), 58 .remove = __exit_p(tlv320aic23_i2c_remove),
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index a01ae97c90aa..4f75cac462d1 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -336,7 +336,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
336 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 336 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
337 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 337 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
338 338
339 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 339 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
340 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 340 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
341 break; 341 break;
342 342
@@ -344,7 +344,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
344 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 344 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
345 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 345 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
346 346
347 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 347 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
348 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 348 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
349 break; 349 break;
350 350
@@ -352,7 +352,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
352 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); 352 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
353 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); 353 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
354 354
355 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); 355 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
356 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); 356 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
357 break; 357 break;
358 358
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index c4a423111673..56da8c8c5960 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -23,6 +23,71 @@
23 23
24#include "fsl_sai.h" 24#include "fsl_sai.h"
25 25
26#define FSL_SAI_FLAGS (FSL_SAI_CSR_SEIE |\
27 FSL_SAI_CSR_FEIE)
28
29static irqreturn_t fsl_sai_isr(int irq, void *devid)
30{
31 struct fsl_sai *sai = (struct fsl_sai *)devid;
32 struct device *dev = &sai->pdev->dev;
33 u32 xcsr, mask;
34
35 /* Only handle those what we enabled */
36 mask = (FSL_SAI_FLAGS >> FSL_SAI_CSR_xIE_SHIFT) << FSL_SAI_CSR_xF_SHIFT;
37
38 /* Tx IRQ */
39 regmap_read(sai->regmap, FSL_SAI_TCSR, &xcsr);
40 xcsr &= mask;
41
42 if (xcsr & FSL_SAI_CSR_WSF)
43 dev_dbg(dev, "isr: Start of Tx word detected\n");
44
45 if (xcsr & FSL_SAI_CSR_SEF)
46 dev_warn(dev, "isr: Tx Frame sync error detected\n");
47
48 if (xcsr & FSL_SAI_CSR_FEF) {
49 dev_warn(dev, "isr: Transmit underrun detected\n");
50 /* FIFO reset for safety */
51 xcsr |= FSL_SAI_CSR_FR;
52 }
53
54 if (xcsr & FSL_SAI_CSR_FWF)
55 dev_dbg(dev, "isr: Enabled transmit FIFO is empty\n");
56
57 if (xcsr & FSL_SAI_CSR_FRF)
58 dev_dbg(dev, "isr: Transmit FIFO watermark has been reached\n");
59
60 regmap_update_bits(sai->regmap, FSL_SAI_TCSR,
61 FSL_SAI_CSR_xF_W_MASK | FSL_SAI_CSR_FR, xcsr);
62
63 /* Rx IRQ */
64 regmap_read(sai->regmap, FSL_SAI_RCSR, &xcsr);
65 xcsr &= mask;
66
67 if (xcsr & FSL_SAI_CSR_WSF)
68 dev_dbg(dev, "isr: Start of Rx word detected\n");
69
70 if (xcsr & FSL_SAI_CSR_SEF)
71 dev_warn(dev, "isr: Rx Frame sync error detected\n");
72
73 if (xcsr & FSL_SAI_CSR_FEF) {
74 dev_warn(dev, "isr: Receive overflow detected\n");
75 /* FIFO reset for safety */
76 xcsr |= FSL_SAI_CSR_FR;
77 }
78
79 if (xcsr & FSL_SAI_CSR_FWF)
80 dev_dbg(dev, "isr: Enabled receive FIFO is full\n");
81
82 if (xcsr & FSL_SAI_CSR_FRF)
83 dev_dbg(dev, "isr: Receive FIFO watermark has been reached\n");
84
85 regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
86 FSL_SAI_CSR_xF_W_MASK | FSL_SAI_CSR_FR, xcsr);
87
88 return IRQ_HANDLED;
89}
90
26static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, 91static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
27 int clk_id, unsigned int freq, int fsl_dir) 92 int clk_id, unsigned int freq, int fsl_dir)
28{ 93{
@@ -114,7 +179,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
114 * that is, together with the last bit of the previous 179 * that is, together with the last bit of the previous
115 * data word. 180 * data word.
116 */ 181 */
117 val_cr2 &= ~FSL_SAI_CR2_BCP; 182 val_cr2 |= FSL_SAI_CR2_BCP;
118 val_cr4 |= FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP; 183 val_cr4 |= FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP;
119 break; 184 break;
120 case SND_SOC_DAIFMT_LEFT_J: 185 case SND_SOC_DAIFMT_LEFT_J:
@@ -122,7 +187,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
122 * Frame high, one word length for frame sync, 187 * Frame high, one word length for frame sync,
123 * frame sync asserts with the first bit of the frame. 188 * frame sync asserts with the first bit of the frame.
124 */ 189 */
125 val_cr2 &= ~FSL_SAI_CR2_BCP; 190 val_cr2 |= FSL_SAI_CR2_BCP;
126 val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP); 191 val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP);
127 break; 192 break;
128 case SND_SOC_DAIFMT_DSP_A: 193 case SND_SOC_DAIFMT_DSP_A:
@@ -132,7 +197,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
132 * that is, together with the last bit of the previous 197 * that is, together with the last bit of the previous
133 * data word. 198 * data word.
134 */ 199 */
135 val_cr2 &= ~FSL_SAI_CR2_BCP; 200 val_cr2 |= FSL_SAI_CR2_BCP;
136 val_cr4 &= ~FSL_SAI_CR4_FSP; 201 val_cr4 &= ~FSL_SAI_CR4_FSP;
137 val_cr4 |= FSL_SAI_CR4_FSE; 202 val_cr4 |= FSL_SAI_CR4_FSE;
138 sai->is_dsp_mode = true; 203 sai->is_dsp_mode = true;
@@ -142,7 +207,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,
142 * Frame high, one bit for frame sync, 207 * Frame high, one bit for frame sync,
143 * frame sync asserts with the first bit of the frame. 208 * frame sync asserts with the first bit of the frame.
144 */ 209 */
145 val_cr2 &= ~FSL_SAI_CR2_BCP; 210 val_cr2 |= FSL_SAI_CR2_BCP;
146 val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP); 211 val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP);
147 sai->is_dsp_mode = true; 212 sai->is_dsp_mode = true;
148 break; 213 break;
@@ -373,8 +438,8 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai)
373{ 438{
374 struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev); 439 struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev);
375 440
376 regmap_update_bits(sai->regmap, FSL_SAI_TCSR, 0xffffffff, 0x0); 441 regmap_update_bits(sai->regmap, FSL_SAI_TCSR, 0xffffffff, FSL_SAI_FLAGS);
377 regmap_update_bits(sai->regmap, FSL_SAI_RCSR, 0xffffffff, 0x0); 442 regmap_update_bits(sai->regmap, FSL_SAI_RCSR, 0xffffffff, FSL_SAI_FLAGS);
378 regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK, 443 regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK,
379 FSL_SAI_MAXBURST_TX * 2); 444 FSL_SAI_MAXBURST_TX * 2);
380 regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK, 445 regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK,
@@ -490,12 +555,14 @@ static int fsl_sai_probe(struct platform_device *pdev)
490 struct fsl_sai *sai; 555 struct fsl_sai *sai;
491 struct resource *res; 556 struct resource *res;
492 void __iomem *base; 557 void __iomem *base;
493 int ret; 558 int irq, ret;
494 559
495 sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); 560 sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL);
496 if (!sai) 561 if (!sai)
497 return -ENOMEM; 562 return -ENOMEM;
498 563
564 sai->pdev = pdev;
565
499 sai->big_endian_regs = of_property_read_bool(np, "big-endian-regs"); 566 sai->big_endian_regs = of_property_read_bool(np, "big-endian-regs");
500 if (sai->big_endian_regs) 567 if (sai->big_endian_regs)
501 fsl_sai_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG; 568 fsl_sai_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG;
@@ -514,6 +581,18 @@ static int fsl_sai_probe(struct platform_device *pdev)
514 return PTR_ERR(sai->regmap); 581 return PTR_ERR(sai->regmap);
515 } 582 }
516 583
584 irq = platform_get_irq(pdev, 0);
585 if (irq < 0) {
586 dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
587 return irq;
588 }
589
590 ret = devm_request_irq(&pdev->dev, irq, fsl_sai_isr, 0, np->name, sai);
591 if (ret) {
592 dev_err(&pdev->dev, "failed to claim irq %u\n", irq);
593 return ret;
594 }
595
517 sai->dma_params_rx.addr = res->start + FSL_SAI_RDR; 596 sai->dma_params_rx.addr = res->start + FSL_SAI_RDR;
518 sai->dma_params_tx.addr = res->start + FSL_SAI_TDR; 597 sai->dma_params_tx.addr = res->start + FSL_SAI_TDR;
519 sai->dma_params_rx.maxburst = FSL_SAI_MAXBURST_RX; 598 sai->dma_params_rx.maxburst = FSL_SAI_MAXBURST_RX;
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index e432260be598..a264185c7138 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -37,7 +37,21 @@
37 37
38/* SAI Transmit/Recieve Control Register */ 38/* SAI Transmit/Recieve Control Register */
39#define FSL_SAI_CSR_TERE BIT(31) 39#define FSL_SAI_CSR_TERE BIT(31)
40#define FSL_SAI_CSR_FR BIT(25)
41#define FSL_SAI_CSR_xF_SHIFT 16
42#define FSL_SAI_CSR_xF_W_SHIFT 18
43#define FSL_SAI_CSR_xF_MASK (0x1f << FSL_SAI_CSR_xF_SHIFT)
44#define FSL_SAI_CSR_xF_W_MASK (0x7 << FSL_SAI_CSR_xF_W_SHIFT)
45#define FSL_SAI_CSR_WSF BIT(20)
46#define FSL_SAI_CSR_SEF BIT(19)
47#define FSL_SAI_CSR_FEF BIT(18)
40#define FSL_SAI_CSR_FWF BIT(17) 48#define FSL_SAI_CSR_FWF BIT(17)
49#define FSL_SAI_CSR_FRF BIT(16)
50#define FSL_SAI_CSR_xIE_SHIFT 8
51#define FSL_SAI_CSR_WSIE BIT(12)
52#define FSL_SAI_CSR_SEIE BIT(11)
53#define FSL_SAI_CSR_FEIE BIT(10)
54#define FSL_SAI_CSR_FWIE BIT(9)
41#define FSL_SAI_CSR_FRIE BIT(8) 55#define FSL_SAI_CSR_FRIE BIT(8)
42#define FSL_SAI_CSR_FRDE BIT(0) 56#define FSL_SAI_CSR_FRDE BIT(0)
43 57
@@ -99,6 +113,7 @@
99#define FSL_SAI_MAXBURST_RX 6 113#define FSL_SAI_MAXBURST_RX 6
100 114
101struct fsl_sai { 115struct fsl_sai {
116 struct platform_device *pdev;
102 struct regmap *regmap; 117 struct regmap *regmap;
103 118
104 bool big_endian_regs; 119 bool big_endian_regs;
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c
index 4a88e36c82ec..76b072bd4ba2 100644
--- a/sound/soc/samsung/ac97.c
+++ b/sound/soc/samsung/ac97.c
@@ -39,15 +39,15 @@ struct s3c_ac97_info {
39}; 39};
40static struct s3c_ac97_info s3c_ac97; 40static struct s3c_ac97_info s3c_ac97;
41 41
42static struct s3c2410_dma_client s3c_dma_client_out = { 42static struct s3c_dma_client s3c_dma_client_out = {
43 .name = "AC97 PCMOut" 43 .name = "AC97 PCMOut"
44}; 44};
45 45
46static struct s3c2410_dma_client s3c_dma_client_in = { 46static struct s3c_dma_client s3c_dma_client_in = {
47 .name = "AC97 PCMIn" 47 .name = "AC97 PCMIn"
48}; 48};
49 49
50static struct s3c2410_dma_client s3c_dma_client_micin = { 50static struct s3c_dma_client s3c_dma_client_micin = {
51 .name = "AC97 MicIn" 51 .name = "AC97 MicIn"
52}; 52};
53 53
diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h
index 225e5378014e..ad7c0f04f00d 100644
--- a/sound/soc/samsung/dma.h
+++ b/sound/soc/samsung/dma.h
@@ -14,8 +14,12 @@
14 14
15#include <sound/dmaengine_pcm.h> 15#include <sound/dmaengine_pcm.h>
16 16
17struct s3c_dma_client {
18 char *name;
19};
20
17struct s3c_dma_params { 21struct s3c_dma_params {
18 struct s3c2410_dma_client *client; /* stream identifier */ 22 struct s3c_dma_client *client; /* stream identifier */
19 int channel; /* Channel ID */ 23 int channel; /* Channel ID */
20 dma_addr_t dma_addr; 24 dma_addr_t dma_addr;
21 int dma_size; /* Size of the DMA transfer */ 25 int dma_size; /* Size of the DMA transfer */
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 0a9b44c940ce..048ead967199 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -1211,10 +1211,10 @@ static int samsung_i2s_probe(struct platform_device *pdev)
1211 pri_dai->dma_playback.dma_addr = regs_base + I2STXD; 1211 pri_dai->dma_playback.dma_addr = regs_base + I2STXD;
1212 pri_dai->dma_capture.dma_addr = regs_base + I2SRXD; 1212 pri_dai->dma_capture.dma_addr = regs_base + I2SRXD;
1213 pri_dai->dma_playback.client = 1213 pri_dai->dma_playback.client =
1214 (struct s3c2410_dma_client *)&pri_dai->dma_playback; 1214 (struct s3c_dma_client *)&pri_dai->dma_playback;
1215 pri_dai->dma_playback.ch_name = "tx"; 1215 pri_dai->dma_playback.ch_name = "tx";
1216 pri_dai->dma_capture.client = 1216 pri_dai->dma_capture.client =
1217 (struct s3c2410_dma_client *)&pri_dai->dma_capture; 1217 (struct s3c_dma_client *)&pri_dai->dma_capture;
1218 pri_dai->dma_capture.ch_name = "rx"; 1218 pri_dai->dma_capture.ch_name = "rx";
1219 pri_dai->dma_playback.dma_size = 4; 1219 pri_dai->dma_playback.dma_size = 4;
1220 pri_dai->dma_capture.dma_size = 4; 1220 pri_dai->dma_capture.dma_size = 4;
@@ -1233,7 +1233,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)
1233 } 1233 }
1234 sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; 1234 sec_dai->dma_playback.dma_addr = regs_base + I2STXDS;
1235 sec_dai->dma_playback.client = 1235 sec_dai->dma_playback.client =
1236 (struct s3c2410_dma_client *)&sec_dai->dma_playback; 1236 (struct s3c_dma_client *)&sec_dai->dma_playback;
1237 sec_dai->dma_playback.ch_name = "tx-sec"; 1237 sec_dai->dma_playback.ch_name = "tx-sec";
1238 1238
1239 if (!np) { 1239 if (!np) {
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c
index 6a5e4bf6ac96..ab54e297957c 100644
--- a/sound/soc/samsung/pcm.c
+++ b/sound/soc/samsung/pcm.c
@@ -20,7 +20,6 @@
20#include <sound/pcm_params.h> 20#include <sound/pcm_params.h>
21 21
22#include <linux/platform_data/asoc-s3c.h> 22#include <linux/platform_data/asoc-s3c.h>
23#include <mach/dma.h>
24 23
25#include "dma.h" 24#include "dma.h"
26#include "pcm.h" 25#include "pcm.h"
@@ -132,11 +131,11 @@ struct s3c_pcm_info {
132 struct s3c_dma_params *dma_capture; 131 struct s3c_dma_params *dma_capture;
133}; 132};
134 133
135static struct s3c2410_dma_client s3c_pcm_dma_client_out = { 134static struct s3c_dma_client s3c_pcm_dma_client_out = {
136 .name = "PCM Stereo out" 135 .name = "PCM Stereo out"
137}; 136};
138 137
139static struct s3c2410_dma_client s3c_pcm_dma_client_in = { 138static struct s3c_dma_client s3c_pcm_dma_client_in = {
140 .name = "PCM Stereo in" 139 .name = "PCM Stereo in"
141}; 140};
142 141
diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c
index d0794458963a..e9bb5d7a71ee 100644
--- a/sound/soc/samsung/s3c2412-i2s.c
+++ b/sound/soc/samsung/s3c2412-i2s.c
@@ -33,11 +33,11 @@
33#include "regs-i2s-v2.h" 33#include "regs-i2s-v2.h"
34#include "s3c2412-i2s.h" 34#include "s3c2412-i2s.h"
35 35
36static struct s3c2410_dma_client s3c2412_dma_client_out = { 36static struct s3c_dma_client s3c2412_dma_client_out = {
37 .name = "I2S PCM Stereo out" 37 .name = "I2S PCM Stereo out"
38}; 38};
39 39
40static struct s3c2410_dma_client s3c2412_dma_client_in = { 40static struct s3c_dma_client s3c2412_dma_client_in = {
41 .name = "I2S PCM Stereo in" 41 .name = "I2S PCM Stereo in"
42}; 42};
43 43
diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c
index f31e916dd8c4..d7b8457b5650 100644
--- a/sound/soc/samsung/s3c24xx-i2s.c
+++ b/sound/soc/samsung/s3c24xx-i2s.c
@@ -31,11 +31,11 @@
31#include "dma.h" 31#include "dma.h"
32#include "s3c24xx-i2s.h" 32#include "s3c24xx-i2s.h"
33 33
34static struct s3c2410_dma_client s3c24xx_dma_client_out = { 34static struct s3c_dma_client s3c24xx_dma_client_out = {
35 .name = "I2S PCM Stereo out" 35 .name = "I2S PCM Stereo out"
36}; 36};
37 37
38static struct s3c2410_dma_client s3c24xx_dma_client_in = { 38static struct s3c_dma_client s3c24xx_dma_client_in = {
39 .name = "I2S PCM Stereo in" 39 .name = "I2S PCM Stereo in"
40}; 40};
41 41
diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c
index 28487dcc4538..cfe63b7bcc9f 100644
--- a/sound/soc/samsung/spdif.c
+++ b/sound/soc/samsung/spdif.c
@@ -18,7 +18,6 @@
18#include <sound/pcm_params.h> 18#include <sound/pcm_params.h>
19 19
20#include <linux/platform_data/asoc-s3c.h> 20#include <linux/platform_data/asoc-s3c.h>
21#include <mach/dma.h>
22 21
23#include "dma.h" 22#include "dma.h"
24#include "spdif.h" 23#include "spdif.h"
@@ -94,7 +93,7 @@ struct samsung_spdif_info {
94 struct s3c_dma_params *dma_playback; 93 struct s3c_dma_params *dma_playback;
95}; 94};
96 95
97static struct s3c2410_dma_client spdif_dma_client_out = { 96static struct s3c_dma_client spdif_dma_client_out = {
98 .name = "S/PDIF Stereo out", 97 .name = "S/PDIF Stereo out",
99}; 98};
100 99
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 49de5c1284f6..131336d40492 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1501,7 +1501,8 @@ static void retire_playback_urb(struct snd_usb_substream *subs,
1501 * The error should be lower than 2ms since the estimate relies 1501 * The error should be lower than 2ms since the estimate relies
1502 * on two reads of a counter updated every ms. 1502 * on two reads of a counter updated every ms.
1503 */ 1503 */
1504 if (abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2) 1504 if (printk_ratelimit() &&
1505 abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2)
1505 dev_dbg(&subs->dev->dev, 1506 dev_dbg(&subs->dev->dev,
1506 "delay: estimated %d, actual %d\n", 1507 "delay: estimated %d, actual %d\n",
1507 est_delay, subs->last_delay); 1508 est_delay, subs->last_delay);
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index b4ddb748356c..56bfb523c5bb 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -47,21 +47,22 @@ displays the statistics gathered since it was forked.
47.PP 47.PP
48.SH FIELD DESCRIPTIONS 48.SH FIELD DESCRIPTIONS
49.nf 49.nf
50\fBpk\fP processor package number. 50\fBPackage\fP processor package number.
51\fBcor\fP processor core number. 51\fBCore\fP processor core number.
52\fBCPU\fP Linux CPU (logical processor) number. 52\fBCPU\fP Linux CPU (logical processor) number.
53Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology. 53Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology.
54\fB%c0\fP percent of the interval that the CPU retired instructions. 54\fBAVG_MHz\fP number of cycles executed divided by time elapsed.
55\fBGHz\fP average clock rate while the CPU was in c0 state. 55\fB%Buzy\fP percent of the interval that the CPU retired instructions, aka. % of time in "C0" state.
56\fBTSC\fP average GHz that the TSC ran during the entire interval. 56\fBBzy_MHz\fP average clock rate while the CPU was busy (in "c0" state).
57\fB%c1, %c3, %c6, %c7\fP show the percentage residency in hardware core idle states. 57\fBTSC_MHz\fP average MHz that the TSC ran during the entire interval.
58\fBCTMP\fP Degrees Celsius reported by the per-core Digital Thermal Sensor. 58\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states.
59\fBPTMP\fP Degrees Celsius reported by the per-package Package Thermal Monitor. 59\fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor.
60\fB%pc2, %pc3, %pc6, %pc7\fP percentage residency in hardware package idle states. 60\fBPkgTtmp\fP Degrees Celsius reported by the per-package Package Thermal Monitor.
61\fBPkg_W\fP Watts consumed by the whole package. 61\fBPkg%pc2, Pkg%pc3, Pkg%pc6, Pkg%pc7\fP percentage residency in hardware package idle states.
62\fBCor_W\fP Watts consumed by the core part of the package. 62\fBPkgWatt\fP Watts consumed by the whole package.
63\fBGFX_W\fP Watts consumed by the Graphics part of the package -- available only on client processors. 63\fBCorWatt\fP Watts consumed by the core part of the package.
64\fBRAM_W\fP Watts consumed by the DRAM DIMMS -- available only on server processors. 64\fBGFXWatt\fP Watts consumed by the Graphics part of the package -- available only on client processors.
65\fBRAMWatt\fP Watts consumed by the DRAM DIMMS -- available only on server processors.
65\fBPKG_%\fP percent of the interval that RAPL throttling was active on the Package. 66\fBPKG_%\fP percent of the interval that RAPL throttling was active on the Package.
66\fBRAM_%\fP percent of the interval that RAPL throttling was active on DRAM. 67\fBRAM_%\fP percent of the interval that RAPL throttling was active on DRAM.
67.fi 68.fi
@@ -78,29 +79,17 @@ For Watts columns, the summary is a system total.
78Subsequent rows show per-CPU statistics. 79Subsequent rows show per-CPU statistics.
79 80
80.nf 81.nf
81[root@sandy]# ./turbostat 82[root@ivy]# ./turbostat
82cor CPU %c0 GHz TSC %c1 %c3 %c6 %c7 CTMP PTMP %pc2 %pc3 %pc6 %pc7 Pkg_W Cor_W GFX_W 83 Core CPU Avg_MHz %Busy Bzy_MHz TSC_MHz SMI CPU%c1 CPU%c3 CPU%c6 CPU%c7 CoreTmp PkgTmp Pkg%pc2 Pkg%pc3 Pkg%pc6 Pkg%pc7 PkgWatt CorWatt GFXWatt
83 0.06 0.80 2.29 0.11 0.00 0.00 99.83 47 40 0.26 0.01 0.44 98.78 3.49 0.12 0.14 84 - - 6 0.36 1596 3492 0 0.59 0.01 99.04 0.00 23 24 23.82 0.01 72.47 0.00 6.40 1.01 0.00
84 0 0 0.07 0.80 2.29 0.07 0.00 0.00 99.86 40 40 0.26 0.01 0.44 98.78 3.49 0.12 0.14 85 0 0 9 0.58 1596 3492 0 0.28 0.01 99.13 0.00 23 24 23.82 0.01 72.47 0.00 6.40 1.01 0.00
85 0 4 0.03 0.80 2.29 0.12 86 0 4 1 0.07 1596 3492 0 0.79
86 1 1 0.04 0.80 2.29 0.25 0.01 0.00 99.71 40 87 1 1 10 0.65 1596 3492 0 0.59 0.00 98.76 0.00 23
87 1 5 0.16 0.80 2.29 0.13 88 1 5 5 0.28 1596 3492 0 0.95
88 2 2 0.05 0.80 2.29 0.06 0.01 0.00 99.88 40 89 2 2 10 0.66 1596 3492 0 0.41 0.01 98.92 0.00 23
89 2 6 0.03 0.80 2.29 0.08 90 2 6 2 0.10 1597 3492 0 0.97
90 3 3 0.05 0.80 2.29 0.08 0.00 0.00 99.87 47 91 3 3 3 0.20 1596 3492 0 0.44 0.00 99.37 0.00 23
91 3 7 0.04 0.84 2.29 0.09 92 3 7 5 0.31 1596 3492 0 0.33
92.fi
93.SH SUMMARY EXAMPLE
94The "-s" option prints the column headers just once,
95and then the one line system summary for each sample interval.
96
97.nf
98[root@wsm]# turbostat -S
99 %c0 GHz TSC %c1 %c3 %c6 CTMP %pc3 %pc6
100 1.40 2.81 3.38 10.78 43.47 44.35 42 13.67 2.09
101 1.34 2.90 3.38 11.48 58.96 28.23 41 19.89 0.15
102 1.55 2.72 3.38 26.73 37.66 34.07 42 2.53 2.80
103 1.37 2.83 3.38 16.95 60.05 21.63 42 5.76 0.20
104.fi 93.fi
105.SH VERBOSE EXAMPLE 94.SH VERBOSE EXAMPLE
106The "-v" option adds verbosity to the output: 95The "-v" option adds verbosity to the output:
@@ -154,55 +143,35 @@ eg. Here a cycle soaker is run on 1 CPU (see %c0) for a few seconds
154until ^C while the other CPUs are mostly idle: 143until ^C while the other CPUs are mostly idle:
155 144
156.nf 145.nf
157[root@x980 lenb]# ./turbostat cat /dev/zero > /dev/null 146root@ivy: turbostat cat /dev/zero > /dev/null
158^C 147^C
159cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 148 Core CPU Avg_MHz %Busy Bzy_MHz TSC_MHz SMI CPU%c1 CPU%c3 CPU%c6 CPU%c7 CoreTmp PkgTmp Pkg%pc2 Pkg%pc3 Pkg%pc6 Pkg%pc7 PkgWatt CorWatt GFXWatt
160 8.86 3.61 3.38 15.06 31.19 44.89 0.00 0.00 149 - - 496 12.75 3886 3492 0 13.16 0.04 74.04 0.00 36 36 0.00 0.00 0.00 0.00 23.15 17.65 0.00
161 0 0 1.46 3.22 3.38 16.84 29.48 52.22 0.00 0.00 150 0 0 22 0.57 3830 3492 0 0.83 0.02 98.59 0.00 27 36 0.00 0.00 0.00 0.00 23.15 17.65 0.00
162 0 6 0.21 3.06 3.38 18.09 151 0 4 9 0.24 3829 3492 0 1.15
163 1 2 0.53 3.33 3.38 2.80 46.40 50.27 152 1 1 4 0.09 3783 3492 0 99.91 0.00 0.00 0.00 36
164 1 8 0.89 3.47 3.38 2.44 153 1 5 3880 99.82 3888 3492 0 0.18
165 2 4 1.36 3.43 3.38 9.04 23.71 65.89 154 2 2 17 0.44 3813 3492 0 0.77 0.04 98.75 0.00 28
166 2 10 0.18 2.86 3.38 10.22 155 2 6 12 0.32 3823 3492 0 0.89
167 8 1 0.04 2.87 3.38 99.96 0.01 0.00 156 3 3 16 0.43 3844 3492 0 0.63 0.11 98.84 0.00 30
168 8 7 99.72 3.63 3.38 0.27 157 3 7 4 0.11 3827 3492 0 0.94
169 9 3 0.31 3.21 3.38 7.64 56.55 35.50 15830.372243 sec
170 9 9 0.08 2.95 3.38 7.88 159
171 10 5 1.42 3.43 3.38 2.14 30.99 65.44
172 10 11 0.16 2.88 3.38 3.40
173.fi 160.fi
174Above the cycle soaker drives cpu7 up its 3.6 GHz turbo limit 161Above the cycle soaker drives cpu5 up its 3.8 GHz turbo limit
175while the other processors are generally in various states of idle. 162while the other processors are generally in various states of idle.
176 163
177Note that cpu1 and cpu7 are HT siblings within core8. 164Note that cpu1 and cpu5 are HT siblings within core1.
178As cpu7 is very busy, it prevents its sibling, cpu1, 165As cpu5 is very busy, it prevents its sibling, cpu1,
179from entering a c-state deeper than c1. 166from entering a c-state deeper than c1.
180 167
181Note that turbostat reports average GHz of 3.63, while 168Note that the Avg_MHz column reflects the total number of cycles executed
182the arithmetic average of the GHz column above is lower. 169divided by the measurement interval. If the %Busy column is 100%,
183This is a weighted average, where the weight is %c0. ie. it is the total number of 170then the processor was running at that speed the entire interval.
184un-halted cycles elapsed per time divided by the number of CPUs. 171The Avg_MHz multiplied by the %Busy results in the Bzy_MHz --
185.SH SMI COUNTING EXAMPLE 172which is the average frequency while the processor was executing --
186On Intel Nehalem and newer processors, MSR 0x34 is a System Management Mode Interrupt (SMI) counter. 173not including any non-busy idle time.
187This counter is shown by default under the "SMI" column. 174
188.nf
189[root@x980 ~]# turbostat
190cor CPU %c0 GHz TSC SMI %c1 %c3 %c6 CTMP %pc3 %pc6
191 0.11 1.91 3.38 0 1.84 0.26 97.79 29 0.82 83.87
192 0 0 0.40 1.63 3.38 0 10.27 0.12 89.20 20 0.82 83.88
193 0 6 0.06 1.63 3.38 0 10.61
194 1 2 0.37 2.63 3.38 0 0.02 0.10 99.51 22
195 1 8 0.01 1.62 3.38 0 0.39
196 2 4 0.07 1.62 3.38 0 0.04 0.07 99.82 23
197 2 10 0.02 1.62 3.38 0 0.09
198 8 1 0.23 1.64 3.38 0 0.10 1.07 98.60 24
199 8 7 0.02 1.64 3.38 0 0.31
200 9 3 0.03 1.62 3.38 0 0.03 0.05 99.89 29
201 9 9 0.02 1.62 3.38 0 0.05
202 10 5 0.07 1.62 3.38 0 0.08 0.12 99.73 27
203 10 11 0.03 1.62 3.38 0 0.13
204^C
205.fi
206.SH NOTES 175.SH NOTES
207 176
208.B "turbostat " 177.B "turbostat "
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 77eb130168da..7c9d8e71eb9e 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -56,7 +56,7 @@ unsigned int do_slm_cstates;
56unsigned int use_c1_residency_msr; 56unsigned int use_c1_residency_msr;
57unsigned int has_aperf; 57unsigned int has_aperf;
58unsigned int has_epb; 58unsigned int has_epb;
59unsigned int units = 1000000000; /* Ghz etc */ 59unsigned int units = 1000000; /* MHz etc */
60unsigned int genuine_intel; 60unsigned int genuine_intel;
61unsigned int has_invariant_tsc; 61unsigned int has_invariant_tsc;
62unsigned int do_nehalem_platform_info; 62unsigned int do_nehalem_platform_info;
@@ -264,88 +264,93 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
264 return 0; 264 return 0;
265} 265}
266 266
267/*
268 * Example Format w/ field column widths:
269 *
270 * Package Core CPU Avg_MHz Bzy_MHz TSC_MHz SMI %Busy CPU_%c1 CPU_%c3 CPU_%c6 CPU_%c7 CoreTmp PkgTmp Pkg%pc2 Pkg%pc3 Pkg%pc6 Pkg%pc7 PkgWatt CorWatt GFXWatt
271 * 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567
272 */
273
267void print_header(void) 274void print_header(void)
268{ 275{
269 if (show_pkg) 276 if (show_pkg)
270 outp += sprintf(outp, "pk"); 277 outp += sprintf(outp, "Package ");
271 if (show_pkg)
272 outp += sprintf(outp, " ");
273 if (show_core) 278 if (show_core)
274 outp += sprintf(outp, "cor"); 279 outp += sprintf(outp, " Core ");
275 if (show_cpu) 280 if (show_cpu)
276 outp += sprintf(outp, " CPU"); 281 outp += sprintf(outp, " CPU ");
277 if (show_pkg || show_core || show_cpu) 282 if (has_aperf)
278 outp += sprintf(outp, " "); 283 outp += sprintf(outp, "Avg_MHz ");
279 if (do_nhm_cstates) 284 if (do_nhm_cstates)
280 outp += sprintf(outp, " %%c0"); 285 outp += sprintf(outp, " %%Busy ");
281 if (has_aperf) 286 if (has_aperf)
282 outp += sprintf(outp, " GHz"); 287 outp += sprintf(outp, "Bzy_MHz ");
283 outp += sprintf(outp, " TSC"); 288 outp += sprintf(outp, "TSC_MHz ");
284 if (do_smi) 289 if (do_smi)
285 outp += sprintf(outp, " SMI"); 290 outp += sprintf(outp, " SMI ");
286 if (extra_delta_offset32) 291 if (extra_delta_offset32)
287 outp += sprintf(outp, " count 0x%03X", extra_delta_offset32); 292 outp += sprintf(outp, " count 0x%03X ", extra_delta_offset32);
288 if (extra_delta_offset64) 293 if (extra_delta_offset64)
289 outp += sprintf(outp, " COUNT 0x%03X", extra_delta_offset64); 294 outp += sprintf(outp, " COUNT 0x%03X ", extra_delta_offset64);
290 if (extra_msr_offset32) 295 if (extra_msr_offset32)
291 outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset32); 296 outp += sprintf(outp, " MSR 0x%03X ", extra_msr_offset32);
292 if (extra_msr_offset64) 297 if (extra_msr_offset64)
293 outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64); 298 outp += sprintf(outp, " MSR 0x%03X ", extra_msr_offset64);
294 if (do_nhm_cstates) 299 if (do_nhm_cstates)
295 outp += sprintf(outp, " %%c1"); 300 outp += sprintf(outp, " CPU%%c1 ");
296 if (do_nhm_cstates && !do_slm_cstates) 301 if (do_nhm_cstates && !do_slm_cstates)
297 outp += sprintf(outp, " %%c3"); 302 outp += sprintf(outp, " CPU%%c3 ");
298 if (do_nhm_cstates) 303 if (do_nhm_cstates)
299 outp += sprintf(outp, " %%c6"); 304 outp += sprintf(outp, " CPU%%c6 ");
300 if (do_snb_cstates) 305 if (do_snb_cstates)
301 outp += sprintf(outp, " %%c7"); 306 outp += sprintf(outp, " CPU%%c7 ");
302 307
303 if (do_dts) 308 if (do_dts)
304 outp += sprintf(outp, " CTMP"); 309 outp += sprintf(outp, "CoreTmp ");
305 if (do_ptm) 310 if (do_ptm)
306 outp += sprintf(outp, " PTMP"); 311 outp += sprintf(outp, " PkgTmp ");
307 312
308 if (do_snb_cstates) 313 if (do_snb_cstates)
309 outp += sprintf(outp, " %%pc2"); 314 outp += sprintf(outp, "Pkg%%pc2 ");
310 if (do_nhm_cstates && !do_slm_cstates) 315 if (do_nhm_cstates && !do_slm_cstates)
311 outp += sprintf(outp, " %%pc3"); 316 outp += sprintf(outp, "Pkg%%pc3 ");
312 if (do_nhm_cstates && !do_slm_cstates) 317 if (do_nhm_cstates && !do_slm_cstates)
313 outp += sprintf(outp, " %%pc6"); 318 outp += sprintf(outp, "Pkg%%pc6 ");
314 if (do_snb_cstates) 319 if (do_snb_cstates)
315 outp += sprintf(outp, " %%pc7"); 320 outp += sprintf(outp, "Pkg%%pc7 ");
316 if (do_c8_c9_c10) { 321 if (do_c8_c9_c10) {
317 outp += sprintf(outp, " %%pc8"); 322 outp += sprintf(outp, "Pkg%%pc8 ");
318 outp += sprintf(outp, " %%pc9"); 323 outp += sprintf(outp, "Pkg%%pc9 ");
319 outp += sprintf(outp, " %%pc10"); 324 outp += sprintf(outp, "Pk%%pc10 ");
320 } 325 }
321 326
322 if (do_rapl && !rapl_joules) { 327 if (do_rapl && !rapl_joules) {
323 if (do_rapl & RAPL_PKG) 328 if (do_rapl & RAPL_PKG)
324 outp += sprintf(outp, " Pkg_W"); 329 outp += sprintf(outp, "PkgWatt ");
325 if (do_rapl & RAPL_CORES) 330 if (do_rapl & RAPL_CORES)
326 outp += sprintf(outp, " Cor_W"); 331 outp += sprintf(outp, "CorWatt ");
327 if (do_rapl & RAPL_GFX) 332 if (do_rapl & RAPL_GFX)
328 outp += sprintf(outp, " GFX_W"); 333 outp += sprintf(outp, "GFXWatt ");
329 if (do_rapl & RAPL_DRAM) 334 if (do_rapl & RAPL_DRAM)
330 outp += sprintf(outp, " RAM_W"); 335 outp += sprintf(outp, "RAMWatt ");
331 if (do_rapl & RAPL_PKG_PERF_STATUS) 336 if (do_rapl & RAPL_PKG_PERF_STATUS)
332 outp += sprintf(outp, " PKG_%%"); 337 outp += sprintf(outp, " PKG_%% ");
333 if (do_rapl & RAPL_DRAM_PERF_STATUS) 338 if (do_rapl & RAPL_DRAM_PERF_STATUS)
334 outp += sprintf(outp, " RAM_%%"); 339 outp += sprintf(outp, " RAM_%% ");
335 } else { 340 } else {
336 if (do_rapl & RAPL_PKG) 341 if (do_rapl & RAPL_PKG)
337 outp += sprintf(outp, " Pkg_J"); 342 outp += sprintf(outp, " Pkg_J ");
338 if (do_rapl & RAPL_CORES) 343 if (do_rapl & RAPL_CORES)
339 outp += sprintf(outp, " Cor_J"); 344 outp += sprintf(outp, " Cor_J ");
340 if (do_rapl & RAPL_GFX) 345 if (do_rapl & RAPL_GFX)
341 outp += sprintf(outp, " GFX_J"); 346 outp += sprintf(outp, " GFX_J ");
342 if (do_rapl & RAPL_DRAM) 347 if (do_rapl & RAPL_DRAM)
343 outp += sprintf(outp, " RAM_W"); 348 outp += sprintf(outp, " RAM_W ");
344 if (do_rapl & RAPL_PKG_PERF_STATUS) 349 if (do_rapl & RAPL_PKG_PERF_STATUS)
345 outp += sprintf(outp, " PKG_%%"); 350 outp += sprintf(outp, " PKG_%% ");
346 if (do_rapl & RAPL_DRAM_PERF_STATUS) 351 if (do_rapl & RAPL_DRAM_PERF_STATUS)
347 outp += sprintf(outp, " RAM_%%"); 352 outp += sprintf(outp, " RAM_%% ");
348 outp += sprintf(outp, " time"); 353 outp += sprintf(outp, " time ");
349 354
350 } 355 }
351 outp += sprintf(outp, "\n"); 356 outp += sprintf(outp, "\n");
@@ -410,25 +415,12 @@ int dump_counters(struct thread_data *t, struct core_data *c,
410 415
411/* 416/*
412 * column formatting convention & formats 417 * column formatting convention & formats
413 * package: "pk" 2 columns %2d
414 * core: "cor" 3 columns %3d
415 * CPU: "CPU" 3 columns %3d
416 * Pkg_W: %6.2
417 * Cor_W: %6.2
418 * GFX_W: %5.2
419 * RAM_W: %5.2
420 * GHz: "GHz" 3 columns %3.2
421 * TSC: "TSC" 3 columns %3.2
422 * SMI: "SMI" 4 columns %4d
423 * percentage " %pc3" %6.2
424 * Perf Status percentage: %5.2
425 * "CTMP" 4 columns %4d
426 */ 418 */
427int format_counters(struct thread_data *t, struct core_data *c, 419int format_counters(struct thread_data *t, struct core_data *c,
428 struct pkg_data *p) 420 struct pkg_data *p)
429{ 421{
430 double interval_float; 422 double interval_float;
431 char *fmt5, *fmt6; 423 char *fmt8;
432 424
433 /* if showing only 1st thread in core and this isn't one, bail out */ 425 /* if showing only 1st thread in core and this isn't one, bail out */
434 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 426 if (show_core_only && !(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
@@ -443,65 +435,52 @@ int format_counters(struct thread_data *t, struct core_data *c,
443 /* topo columns, print blanks on 1st (average) line */ 435 /* topo columns, print blanks on 1st (average) line */
444 if (t == &average.threads) { 436 if (t == &average.threads) {
445 if (show_pkg) 437 if (show_pkg)
446 outp += sprintf(outp, " "); 438 outp += sprintf(outp, " -");
447 if (show_pkg && show_core)
448 outp += sprintf(outp, " ");
449 if (show_core) 439 if (show_core)
450 outp += sprintf(outp, " "); 440 outp += sprintf(outp, " -");
451 if (show_cpu) 441 if (show_cpu)
452 outp += sprintf(outp, " " " "); 442 outp += sprintf(outp, " -");
453 } else { 443 } else {
454 if (show_pkg) { 444 if (show_pkg) {
455 if (p) 445 if (p)
456 outp += sprintf(outp, "%2d", p->package_id); 446 outp += sprintf(outp, "%8d", p->package_id);
457 else 447 else
458 outp += sprintf(outp, " "); 448 outp += sprintf(outp, " -");
459 } 449 }
460 if (show_pkg && show_core)
461 outp += sprintf(outp, " ");
462 if (show_core) { 450 if (show_core) {
463 if (c) 451 if (c)
464 outp += sprintf(outp, "%3d", c->core_id); 452 outp += sprintf(outp, "%8d", c->core_id);
465 else 453 else
466 outp += sprintf(outp, " "); 454 outp += sprintf(outp, " -");
467 } 455 }
468 if (show_cpu) 456 if (show_cpu)
469 outp += sprintf(outp, " %3d", t->cpu_id); 457 outp += sprintf(outp, "%8d", t->cpu_id);
470 } 458 }
459
460 /* AvgMHz */
461 if (has_aperf)
462 outp += sprintf(outp, "%8.0f",
463 1.0 / units * t->aperf / interval_float);
464
471 /* %c0 */ 465 /* %c0 */
472 if (do_nhm_cstates) { 466 if (do_nhm_cstates) {
473 if (show_pkg || show_core || show_cpu)
474 outp += sprintf(outp, " ");
475 if (!skip_c0) 467 if (!skip_c0)
476 outp += sprintf(outp, "%6.2f", 100.0 * t->mperf/t->tsc); 468 outp += sprintf(outp, "%8.2f", 100.0 * t->mperf/t->tsc);
477 else 469 else
478 outp += sprintf(outp, " ****"); 470 outp += sprintf(outp, "********");
479 } 471 }
480 472
481 /* GHz */ 473 /* BzyMHz */
482 if (has_aperf) { 474 if (has_aperf)
483 if (!aperf_mperf_unstable) { 475 outp += sprintf(outp, "%8.0f",
484 outp += sprintf(outp, " %3.2f", 476 1.0 * t->tsc / units * t->aperf / t->mperf / interval_float);
485 1.0 * t->tsc / units * t->aperf /
486 t->mperf / interval_float);
487 } else {
488 if (t->aperf > t->tsc || t->mperf > t->tsc) {
489 outp += sprintf(outp, " ***");
490 } else {
491 outp += sprintf(outp, "%3.1f*",
492 1.0 * t->tsc /
493 units * t->aperf /
494 t->mperf / interval_float);
495 }
496 }
497 }
498 477
499 /* TSC */ 478 /* TSC */
500 outp += sprintf(outp, "%5.2f", 1.0 * t->tsc/units/interval_float); 479 outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float);
501 480
502 /* SMI */ 481 /* SMI */
503 if (do_smi) 482 if (do_smi)
504 outp += sprintf(outp, "%4d", t->smi_count); 483 outp += sprintf(outp, "%8d", t->smi_count);
505 484
506 /* delta */ 485 /* delta */
507 if (extra_delta_offset32) 486 if (extra_delta_offset32)
@@ -520,9 +499,9 @@ int format_counters(struct thread_data *t, struct core_data *c,
520 499
521 if (do_nhm_cstates) { 500 if (do_nhm_cstates) {
522 if (!skip_c1) 501 if (!skip_c1)
523 outp += sprintf(outp, " %6.2f", 100.0 * t->c1/t->tsc); 502 outp += sprintf(outp, "%8.2f", 100.0 * t->c1/t->tsc);
524 else 503 else
525 outp += sprintf(outp, " ****"); 504 outp += sprintf(outp, "********");
526 } 505 }
527 506
528 /* print per-core data only for 1st thread in core */ 507 /* print per-core data only for 1st thread in core */
@@ -530,79 +509,76 @@ int format_counters(struct thread_data *t, struct core_data *c,
530 goto done; 509 goto done;
531 510
532 if (do_nhm_cstates && !do_slm_cstates) 511 if (do_nhm_cstates && !do_slm_cstates)
533 outp += sprintf(outp, " %6.2f", 100.0 * c->c3/t->tsc); 512 outp += sprintf(outp, "%8.2f", 100.0 * c->c3/t->tsc);
534 if (do_nhm_cstates) 513 if (do_nhm_cstates)
535 outp += sprintf(outp, " %6.2f", 100.0 * c->c6/t->tsc); 514 outp += sprintf(outp, "%8.2f", 100.0 * c->c6/t->tsc);
536 if (do_snb_cstates) 515 if (do_snb_cstates)
537 outp += sprintf(outp, " %6.2f", 100.0 * c->c7/t->tsc); 516 outp += sprintf(outp, "%8.2f", 100.0 * c->c7/t->tsc);
538 517
539 if (do_dts) 518 if (do_dts)
540 outp += sprintf(outp, " %4d", c->core_temp_c); 519 outp += sprintf(outp, "%8d", c->core_temp_c);
541 520
542 /* print per-package data only for 1st core in package */ 521 /* print per-package data only for 1st core in package */
543 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) 522 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
544 goto done; 523 goto done;
545 524
546 if (do_ptm) 525 if (do_ptm)
547 outp += sprintf(outp, " %4d", p->pkg_temp_c); 526 outp += sprintf(outp, "%8d", p->pkg_temp_c);
548 527
549 if (do_snb_cstates) 528 if (do_snb_cstates)
550 outp += sprintf(outp, " %6.2f", 100.0 * p->pc2/t->tsc); 529 outp += sprintf(outp, "%8.2f", 100.0 * p->pc2/t->tsc);
551 if (do_nhm_cstates && !do_slm_cstates) 530 if (do_nhm_cstates && !do_slm_cstates)
552 outp += sprintf(outp, " %6.2f", 100.0 * p->pc3/t->tsc); 531 outp += sprintf(outp, "%8.2f", 100.0 * p->pc3/t->tsc);
553 if (do_nhm_cstates && !do_slm_cstates) 532 if (do_nhm_cstates && !do_slm_cstates)
554 outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); 533 outp += sprintf(outp, "%8.2f", 100.0 * p->pc6/t->tsc);
555 if (do_snb_cstates) 534 if (do_snb_cstates)
556 outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); 535 outp += sprintf(outp, "%8.2f", 100.0 * p->pc7/t->tsc);
557 if (do_c8_c9_c10) { 536 if (do_c8_c9_c10) {
558 outp += sprintf(outp, " %6.2f", 100.0 * p->pc8/t->tsc); 537 outp += sprintf(outp, "%8.2f", 100.0 * p->pc8/t->tsc);
559 outp += sprintf(outp, " %6.2f", 100.0 * p->pc9/t->tsc); 538 outp += sprintf(outp, "%8.2f", 100.0 * p->pc9/t->tsc);
560 outp += sprintf(outp, " %6.2f", 100.0 * p->pc10/t->tsc); 539 outp += sprintf(outp, "%8.2f", 100.0 * p->pc10/t->tsc);
561 } 540 }
562 541
563 /* 542 /*
564 * If measurement interval exceeds minimum RAPL Joule Counter range, 543 * If measurement interval exceeds minimum RAPL Joule Counter range,
565 * indicate that results are suspect by printing "**" in fraction place. 544 * indicate that results are suspect by printing "**" in fraction place.
566 */ 545 */
567 if (interval_float < rapl_joule_counter_range) { 546 if (interval_float < rapl_joule_counter_range)
568 fmt5 = " %5.2f"; 547 fmt8 = "%8.2f";
569 fmt6 = " %6.2f"; 548 else
570 } else { 549 fmt8 = " %6.0f**";
571 fmt5 = " %3.0f**";
572 fmt6 = " %4.0f**";
573 }
574 550
575 if (do_rapl && !rapl_joules) { 551 if (do_rapl && !rapl_joules) {
576 if (do_rapl & RAPL_PKG) 552 if (do_rapl & RAPL_PKG)
577 outp += sprintf(outp, fmt6, p->energy_pkg * rapl_energy_units / interval_float); 553 outp += sprintf(outp, fmt8, p->energy_pkg * rapl_energy_units / interval_float);
578 if (do_rapl & RAPL_CORES) 554 if (do_rapl & RAPL_CORES)
579 outp += sprintf(outp, fmt6, p->energy_cores * rapl_energy_units / interval_float); 555 outp += sprintf(outp, fmt8, p->energy_cores * rapl_energy_units / interval_float);
580 if (do_rapl & RAPL_GFX) 556 if (do_rapl & RAPL_GFX)
581 outp += sprintf(outp, fmt5, p->energy_gfx * rapl_energy_units / interval_float); 557 outp += sprintf(outp, fmt8, p->energy_gfx * rapl_energy_units / interval_float);
582 if (do_rapl & RAPL_DRAM) 558 if (do_rapl & RAPL_DRAM)
583 outp += sprintf(outp, fmt5, p->energy_dram * rapl_energy_units / interval_float); 559 outp += sprintf(outp, fmt8, p->energy_dram * rapl_energy_units / interval_float);
584 if (do_rapl & RAPL_PKG_PERF_STATUS) 560 if (do_rapl & RAPL_PKG_PERF_STATUS)
585 outp += sprintf(outp, fmt5, 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float); 561 outp += sprintf(outp, fmt8, 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float);
586 if (do_rapl & RAPL_DRAM_PERF_STATUS) 562 if (do_rapl & RAPL_DRAM_PERF_STATUS)
587 outp += sprintf(outp, fmt5, 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float); 563 outp += sprintf(outp, fmt8, 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float);
588 } else { 564 } else {
589 if (do_rapl & RAPL_PKG) 565 if (do_rapl & RAPL_PKG)
590 outp += sprintf(outp, fmt6, 566 outp += sprintf(outp, fmt8,
591 p->energy_pkg * rapl_energy_units); 567 p->energy_pkg * rapl_energy_units);
592 if (do_rapl & RAPL_CORES) 568 if (do_rapl & RAPL_CORES)
593 outp += sprintf(outp, fmt6, 569 outp += sprintf(outp, fmt8,
594 p->energy_cores * rapl_energy_units); 570 p->energy_cores * rapl_energy_units);
595 if (do_rapl & RAPL_GFX) 571 if (do_rapl & RAPL_GFX)
596 outp += sprintf(outp, fmt5, 572 outp += sprintf(outp, fmt8,
597 p->energy_gfx * rapl_energy_units); 573 p->energy_gfx * rapl_energy_units);
598 if (do_rapl & RAPL_DRAM) 574 if (do_rapl & RAPL_DRAM)
599 outp += sprintf(outp, fmt5, 575 outp += sprintf(outp, fmt8,
600 p->energy_dram * rapl_energy_units); 576 p->energy_dram * rapl_energy_units);
601 if (do_rapl & RAPL_PKG_PERF_STATUS) 577 if (do_rapl & RAPL_PKG_PERF_STATUS)
602 outp += sprintf(outp, fmt5, 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float); 578 outp += sprintf(outp, fmt8, 100.0 * p->rapl_pkg_perf_status * rapl_time_units / interval_float);
603 if (do_rapl & RAPL_DRAM_PERF_STATUS) 579 if (do_rapl & RAPL_DRAM_PERF_STATUS)
604 outp += sprintf(outp, fmt5, 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float); 580 outp += sprintf(outp, fmt8, 100.0 * p->rapl_dram_perf_status * rapl_time_units / interval_float);
605 outp += sprintf(outp, fmt5, interval_float); 581 outp += sprintf(outp, fmt8, interval_float);
606 582
607 } 583 }
608done: 584done:
@@ -1516,6 +1492,9 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model)
1516 case 0x46: /* HSW */ 1492 case 0x46: /* HSW */
1517 case 0x37: /* BYT */ 1493 case 0x37: /* BYT */
1518 case 0x4D: /* AVN */ 1494 case 0x4D: /* AVN */
1495 case 0x3D: /* BDW */
1496 case 0x4F: /* BDX */
1497 case 0x56: /* BDX-DE */
1519 return 1; 1498 return 1;
1520 case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1499 case 0x2E: /* Nehalem-EX Xeon - Beckton */
1521 case 0x2F: /* Westmere-EX Xeon - Eagleton */ 1500 case 0x2F: /* Westmere-EX Xeon - Eagleton */
@@ -1629,9 +1608,12 @@ void rapl_probe(unsigned int family, unsigned int model)
1629 case 0x3C: /* HSW */ 1608 case 0x3C: /* HSW */
1630 case 0x45: /* HSW */ 1609 case 0x45: /* HSW */
1631 case 0x46: /* HSW */ 1610 case 0x46: /* HSW */
1611 case 0x3D: /* BDW */
1632 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO; 1612 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO;
1633 break; 1613 break;
1634 case 0x3F: /* HSX */ 1614 case 0x3F: /* HSX */
1615 case 0x4F: /* BDX */
1616 case 0x56: /* BDX-DE */
1635 do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO; 1617 do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO;
1636 break; 1618 break;
1637 case 0x2D: 1619 case 0x2D:
@@ -1875,6 +1857,9 @@ int is_snb(unsigned int family, unsigned int model)
1875 case 0x3F: /* HSW */ 1857 case 0x3F: /* HSW */
1876 case 0x45: /* HSW */ 1858 case 0x45: /* HSW */
1877 case 0x46: /* HSW */ 1859 case 0x46: /* HSW */
1860 case 0x3D: /* BDW */
1861 case 0x4F: /* BDX */
1862 case 0x56: /* BDX-DE */
1878 return 1; 1863 return 1;
1879 } 1864 }
1880 return 0; 1865 return 0;
@@ -1886,7 +1871,8 @@ int has_c8_c9_c10(unsigned int family, unsigned int model)
1886 return 0; 1871 return 0;
1887 1872
1888 switch (model) { 1873 switch (model) {
1889 case 0x45: 1874 case 0x45: /* HSW */
1875 case 0x3D: /* BDW */
1890 return 1; 1876 return 1;
1891 } 1877 }
1892 return 0; 1878 return 0;
@@ -2455,7 +2441,7 @@ int main(int argc, char **argv)
2455 cmdline(argc, argv); 2441 cmdline(argc, argv);
2456 2442
2457 if (verbose) 2443 if (verbose)
2458 fprintf(stderr, "turbostat v3.6 Dec 2, 2013" 2444 fprintf(stderr, "turbostat v3.7 Feb 6, 2014"
2459 " - Len Brown <lenb@kernel.org>\n"); 2445 " - Len Brown <lenb@kernel.org>\n");
2460 2446
2461 turbostat_init(); 2447 turbostat_init();
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 5081e809821f..22fa819a9b6a 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -277,7 +277,7 @@ int kvm_timer_hyp_init(void)
277 277
278 host_vtimer_irq = ppi; 278 host_vtimer_irq = ppi;
279 279
280 err = register_cpu_notifier(&kvm_timer_cpu_nb); 280 err = __register_cpu_notifier(&kvm_timer_cpu_nb);
281 if (err) { 281 if (err) {
282 kvm_err("Cannot register timer CPU notifier\n"); 282 kvm_err("Cannot register timer CPU notifier\n");
283 goto out_free; 283 goto out_free;
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 8ca405cd7c1a..47b29834a6b6 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1496,7 +1496,7 @@ int kvm_vgic_hyp_init(void)
1496 goto out; 1496 goto out;
1497 } 1497 }
1498 1498
1499 ret = register_cpu_notifier(&vgic_cpu_nb); 1499 ret = __register_cpu_notifier(&vgic_cpu_nb);
1500 if (ret) { 1500 if (ret) {
1501 kvm_err("Cannot register vgic CPU notifier\n"); 1501 kvm_err("Cannot register vgic CPU notifier\n");
1502 goto out_free_irq; 1502 goto out_free_irq;